@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.54
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 +149 -1
- package/README.md +295 -37
- package/dist/agent-delete.d.ts +5 -6
- package/dist/agent-delete.js +30 -67
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +26 -20
- package/dist/agents-store.js +42 -34
- package/dist/api-only.d.ts +25 -6
- package/dist/api-only.js +34 -13
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +76 -8
- package/dist/composio-preset.d.ts +3 -1
- package/dist/composio-preset.js +5 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +5 -2
- package/dist/computer-setting.js +8 -1
- package/dist/computers.d.ts +0 -2
- package/dist/computers.js +1 -1
- package/dist/console/assets/index-B_85An2t.js +745 -0
- package/dist/console/assets/index-n1YsbnYh.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +10 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.js +10 -13
- package/dist/github-connection.d.ts +50 -1
- package/dist/github-connection.js +96 -3
- package/dist/github-faux.d.ts +11 -2
- package/dist/github-faux.js +138 -7
- package/dist/github-pull-request.d.ts +37 -0
- package/dist/github-pull-request.js +110 -0
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +14 -1
- package/dist/learn/commit.js +156 -1
- package/dist/learn/compile.js +22 -8
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +10 -1
- package/dist/learn/learning.sh +15 -3
- package/dist/learn/promote.d.ts +2 -2
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning.d.ts +9 -6
- package/dist/learning.js +9 -4
- package/dist/live-reach.d.ts +34 -7
- package/dist/live-reach.js +76 -11
- package/dist/mcp-gateway.js +15 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +8 -3
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +16 -12
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +275 -40
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +16 -1
- package/dist/run-launch.js +30 -1
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-view.d.ts +17 -0
- package/dist/run-view.js +25 -1
- package/dist/runner/adapter-loop.d.ts +11 -3
- package/dist/runner/adapter-loop.js +138 -22
- package/dist/runner/adapter-run-spec.js +26 -13
- package/dist/runner/audit.d.ts +2 -0
- package/dist/runner/audit.js +9 -1
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +29 -3
- package/dist/runner/claim-secrets.js +38 -4
- package/dist/runner/cli-run-spec.js +24 -13
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +11 -1
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +2 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +7 -2
- package/dist/runner/learning-end.js +22 -10
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +6 -1
- package/dist/runner/mcp-run.d.ts +10 -7
- package/dist/runner/mcp-run.js +3 -5
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +15 -3
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/pr-checkout.d.ts +21 -4
- package/dist/runner/pr-checkout.js +103 -4
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +14 -6
- package/dist/runner/promotion.js +98 -41
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +178 -45
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.d.ts +3 -0
- package/dist/runner/runner-check.js +28 -2
- package/dist/runner/runner.js +26 -9
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.d.ts +34 -6
- package/dist/runs-over-store.js +133 -25
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +117 -26
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +79 -32
- package/dist/server.js +673 -113
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +6 -2
- package/dist/store/agent-body.js +18 -7
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +2 -1
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +4 -12
- package/dist/store/sqlite/run-launch.js +5 -19
- package/dist/store/sqlite/store.js +224 -170
- package/dist/store/store.d.ts +116 -39
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +2 -2
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/suggestions.d.ts +282 -0
- package/dist/suggestions.js +919 -0
- package/dist/telemetry.d.ts +8 -1
- package/dist/telemetry.js +12 -4
- package/dist/template-import.d.ts +27 -2
- package/dist/template-import.js +148 -13
- package/dist/templates.d.ts +103 -77
- package/dist/templates.js +71 -17
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/trigger-launch-hook.d.ts +49 -0
- package/dist/trigger-launch-hook.js +91 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +1 -1
- package/dist/uploads.js +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +3 -4
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +1 -1
- package/dist/workspace/synced-folder.js +11 -14
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +8 -4
- package/templates/agent-scout/agent.md +46 -0
- package/templates/agent-scout/skills/scout/SKILL.md +88 -0
- package/templates/agent-scout/skills/scout/suggestions.schema.json +112 -0
- package/dist/console/assets/index-B-D0EM3j.js +0 -733
- package/dist/console/assets/index-DlQepP2J.css +0 -1
|
@@ -1,733 +0,0 @@
|
|
|
1
|
-
var DR=Object.defineProperty;var zR=(e,n,s)=>n in e?DR(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Dt=(e,n,s)=>zR(e,typeof n!="symbol"?n+"":n,s);function FR(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 l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).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 z1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yg={exports:{}},Ic={},wg={exports:{}},Nt={};/**
|
|
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 Yj;function UR(){if(Yj)return Nt;Yj=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"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),v=Symbol.iterator;function b(D){return D===null||typeof D!="object"?null:(D=v&&D[v]||D["@@iterator"],typeof D=="function"?D:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,y={};function j(D,Y,K){this.props=D,this.context=Y,this.refs=y,this.updater=K||m}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 C(D,Y,K){this.props=D,this.context=Y,this.refs=y,this.updater=K||m}var N=C.prototype=new k;N.constructor=C,x(N,j.prototype),N.isPureReactComponent=!0;var S=Array.isArray,E=Object.prototype.hasOwnProperty,$={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function A(D,Y,K){var Z,se={},ie=null,Ne=null;if(Y!=null)for(Z in Y.ref!==void 0&&(Ne=Y.ref),Y.key!==void 0&&(ie=""+Y.key),Y)E.call(Y,Z)&&!L.hasOwnProperty(Z)&&(se[Z]=Y[Z]);var he=arguments.length-2;if(he===1)se.children=K;else if(1<he){for(var ve=Array(he),Ee=0;Ee<he;Ee++)ve[Ee]=arguments[Ee+2];se.children=ve}if(D&&D.defaultProps)for(Z in he=D.defaultProps,he)se[Z]===void 0&&(se[Z]=he[Z]);return{$$typeof:e,type:D,key:ie,ref:Ne,props:se,_owner:$.current}}function P(D,Y){return{$$typeof:e,type:D.type,key:Y,ref:D.ref,props:D.props,_owner:D._owner}}function O(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function T(D){var Y={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(K){return Y[K]})}var M=/\/+/g;function F(D,Y){return typeof D=="object"&&D!==null&&D.key!=null?T(""+D.key):Y.toString(36)}function I(D,Y,K,Z,se){var ie=typeof D;(ie==="undefined"||ie==="boolean")&&(D=null);var Ne=!1;if(D===null)Ne=!0;else switch(ie){case"string":case"number":Ne=!0;break;case"object":switch(D.$$typeof){case e:case n:Ne=!0}}if(Ne)return Ne=D,se=se(Ne),D=Z===""?"."+F(Ne,0):Z,S(se)?(K="",D!=null&&(K=D.replace(M,"$&/")+"/"),I(se,Y,K,"",function(Ee){return Ee})):se!=null&&(O(se)&&(se=P(se,K+(!se.key||Ne&&Ne.key===se.key?"":(""+se.key).replace(M,"$&/")+"/")+D)),Y.push(se)),1;if(Ne=0,Z=Z===""?".":Z+":",S(D))for(var he=0;he<D.length;he++){ie=D[he];var ve=Z+F(ie,he);Ne+=I(ie,Y,K,ve,se)}else if(ve=b(D),typeof ve=="function")for(D=ve.call(D),he=0;!(ie=D.next()).done;)ie=ie.value,ve=Z+F(ie,he++),Ne+=I(ie,Y,K,ve,se);else if(ie==="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 Ne}function V(D,Y,K){if(D==null)return D;var Z=[],se=0;return I(D,Z,"","",function(ie){return Y.call(K,ie,se++)}),Z}function G(D){if(D._status===-1){var Y=D._result;Y=Y(),Y.then(function(K){(D._status===0||D._status===-1)&&(D._status=1,D._result=K)},function(K){(D._status===0||D._status===-1)&&(D._status=2,D._result=K)}),D._status===-1&&(D._status=0,D._result=Y)}if(D._status===1)return D._result.default;throw D._result}var q={current:null},H={transition:null},U={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:H,ReactCurrentOwner:$};function Q(){throw Error("act(...) is not supported in production builds of React.")}return Nt.Children={map:V,forEach:function(D,Y,K){V(D,function(){Y.apply(this,arguments)},K)},count:function(D){var Y=0;return V(D,function(){Y++}),Y},toArray:function(D){return V(D,function(Y){return Y})||[]},only:function(D){if(!O(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Nt.Component=j,Nt.Fragment=s,Nt.Profiler=o,Nt.PureComponent=C,Nt.StrictMode=r,Nt.Suspense=u,Nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U,Nt.act=Q,Nt.cloneElement=function(D,Y,K){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var Z=x({},D.props),se=D.key,ie=D.ref,Ne=D._owner;if(Y!=null){if(Y.ref!==void 0&&(ie=Y.ref,Ne=$.current),Y.key!==void 0&&(se=""+Y.key),D.type&&D.type.defaultProps)var he=D.type.defaultProps;for(ve in Y)E.call(Y,ve)&&!L.hasOwnProperty(ve)&&(Z[ve]=Y[ve]===void 0&&he!==void 0?he[ve]:Y[ve])}var ve=arguments.length-2;if(ve===1)Z.children=K;else if(1<ve){he=Array(ve);for(var Ee=0;Ee<ve;Ee++)he[Ee]=arguments[Ee+2];Z.children=he}return{$$typeof:e,type:D.type,key:se,ref:ie,props:Z,_owner:Ne}},Nt.createContext=function(D){return D={$$typeof:l,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:i,_context:D},D.Consumer=D},Nt.createElement=A,Nt.createFactory=function(D){var Y=A.bind(null,D);return Y.type=D,Y},Nt.createRef=function(){return{current:null}},Nt.forwardRef=function(D){return{$$typeof:d,render:D}},Nt.isValidElement=O,Nt.lazy=function(D){return{$$typeof:h,_payload:{_status:-1,_result:D},_init:G}},Nt.memo=function(D,Y){return{$$typeof:f,type:D,compare:Y===void 0?null:Y}},Nt.startTransition=function(D){var Y=H.transition;H.transition={};try{D()}finally{H.transition=Y}},Nt.unstable_act=Q,Nt.useCallback=function(D,Y){return q.current.useCallback(D,Y)},Nt.useContext=function(D){return q.current.useContext(D)},Nt.useDebugValue=function(){},Nt.useDeferredValue=function(D){return q.current.useDeferredValue(D)},Nt.useEffect=function(D,Y){return q.current.useEffect(D,Y)},Nt.useId=function(){return q.current.useId()},Nt.useImperativeHandle=function(D,Y,K){return q.current.useImperativeHandle(D,Y,K)},Nt.useInsertionEffect=function(D,Y){return q.current.useInsertionEffect(D,Y)},Nt.useLayoutEffect=function(D,Y){return q.current.useLayoutEffect(D,Y)},Nt.useMemo=function(D,Y){return q.current.useMemo(D,Y)},Nt.useReducer=function(D,Y,K){return q.current.useReducer(D,Y,K)},Nt.useRef=function(D){return q.current.useRef(D)},Nt.useState=function(D){return q.current.useState(D)},Nt.useSyncExternalStore=function(D,Y,K){return q.current.useSyncExternalStore(D,Y,K)},Nt.useTransition=function(){return q.current.useTransition()},Nt.version="18.3.1",Nt}var Qj;function Wm(){return Qj||(Qj=1,wg.exports=UR()),wg.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 Jj;function WR(){if(Jj)return Ic;Jj=1;var e=Wm(),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 l(d,u,f){var h,v={},b=null,m=null;f!==void 0&&(b=""+f),u.key!==void 0&&(b=""+u.key),u.ref!==void 0&&(m=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(v[h]=u[h]);if(d&&d.defaultProps)for(h in u=d.defaultProps,u)v[h]===void 0&&(v[h]=u[h]);return{$$typeof:n,type:d,key:b,ref:m,props:v,_owner:o.current}}return Ic.Fragment=s,Ic.jsx=l,Ic.jsxs=l,Ic}var Xj;function HR(){return Xj||(Xj=1,yg.exports=WR()),yg.exports}var t=HR(),g=Wm();const Ve=z1(g),xx=FR({__proto__:null,default:Ve},[g]);var bf={},jg={exports:{}},Ss={},kg={exports:{}},Ng={};/**
|
|
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 Zj;function BR(){return Zj||(Zj=1,(function(e){function n(H,U){var Q=H.length;H.push(U);e:for(;0<Q;){var D=Q-1>>>1,Y=H[D];if(0<o(Y,U))H[D]=U,H[Q]=Y,Q=D;else break e}}function s(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var U=H[0],Q=H.pop();if(Q!==U){H[0]=Q;e:for(var D=0,Y=H.length,K=Y>>>1;D<K;){var Z=2*(D+1)-1,se=H[Z],ie=Z+1,Ne=H[ie];if(0>o(se,Q))ie<Y&&0>o(Ne,se)?(H[D]=Ne,H[ie]=Q,D=ie):(H[D]=se,H[Z]=Q,D=Z);else if(ie<Y&&0>o(Ne,Q))H[D]=Ne,H[ie]=Q,D=ie;else break e}}return U}function o(H,U){var Q=H.sortIndex-U.sortIndex;return Q!==0?Q:H.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,d=l.now();e.unstable_now=function(){return l.now()-d}}var u=[],f=[],h=1,v=null,b=3,m=!1,x=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(H){for(var U=s(f);U!==null;){if(U.callback===null)r(f);else if(U.startTime<=H)r(f),U.sortIndex=U.expirationTime,n(u,U);else break;U=s(f)}}function S(H){if(y=!1,N(H),!x)if(s(u)!==null)x=!0,G(E);else{var U=s(f);U!==null&&q(S,U.startTime-H)}}function E(H,U){x=!1,y&&(y=!1,k(A),A=-1),m=!0;var Q=b;try{for(N(U),v=s(u);v!==null&&(!(v.expirationTime>U)||H&&!T());){var D=v.callback;if(typeof D=="function"){v.callback=null,b=v.priorityLevel;var Y=D(v.expirationTime<=U);U=e.unstable_now(),typeof Y=="function"?v.callback=Y:v===s(u)&&r(u),N(U)}else r(u);v=s(u)}if(v!==null)var K=!0;else{var Z=s(f);Z!==null&&q(S,Z.startTime-U),K=!1}return K}finally{v=null,b=Q,m=!1}}var $=!1,L=null,A=-1,P=5,O=-1;function T(){return!(e.unstable_now()-O<P)}function M(){if(L!==null){var H=e.unstable_now();O=H;var U=!0;try{U=L(!0,H)}finally{U?F():($=!1,L=null)}}else $=!1}var F;if(typeof C=="function")F=function(){C(M)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,V=I.port2;I.port1.onmessage=M,F=function(){V.postMessage(null)}}else F=function(){j(M,0)};function G(H){L=H,$||($=!0,F())}function q(H,U){A=j(function(){H(e.unstable_now())},U)}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(H){H.callback=null},e.unstable_continueExecution=function(){x||m||(x=!0,G(E))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(H){switch(b){case 1:case 2:case 3:var U=3;break;default:U=b}var Q=b;b=U;try{return H()}finally{b=Q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,U){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var Q=b;b=H;try{return U()}finally{b=Q}},e.unstable_scheduleCallback=function(H,U,Q){var D=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?D+Q:D):Q=D,H){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=Q+Y,H={id:h++,callback:U,priorityLevel:H,startTime:Q,expirationTime:Y,sortIndex:-1},Q>D?(H.sortIndex=Q,n(f,H),s(u)===null&&H===s(f)&&(y?(k(A),A=-1):y=!0,q(S,Q-D))):(H.sortIndex=Y,n(u,H),x||m||(x=!0,G(E))),H},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(H){var U=b;return function(){var Q=b;b=U;try{return H.apply(this,arguments)}finally{b=Q}}}})(Ng)),Ng}var ek;function qR(){return ek||(ek=1,kg.exports=BR()),kg.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 tk;function GR(){if(tk)return Ss;tk=1;var e=Wm(),n=qR();function s(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,p=1;p<arguments.length;p++)c+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+a+"; visit "+c+" 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,c){l(a,c),l(a+"Capture",c)}function l(a,c){for(o[a]=c,a=0;a<c.length;a++)r.add(c[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]*$/,h={},v={};function b(a){return u.call(v,a)?!0:u.call(h,a)?!1:f.test(a)?v[a]=!0:(h[a]=!0,!1)}function m(a,c,p,w){if(p!==null&&p.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return w?!1:p!==null?!p.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function x(a,c,p,w){if(c===null||typeof c>"u"||m(a,c,p,w))return!0;if(w)return!1;if(p!==null)switch(p.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function y(a,c,p,w,_,R,z){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=w,this.attributeNamespace=_,this.mustUseProperty=p,this.propertyName=a,this.type=c,this.sanitizeURL=R,this.removeEmptyString=z}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 c=a[0];j[c]=new y(c,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 C(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 c=a.replace(k,C);j[c]=new y(c,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var c=a.replace(k,C);j[c]=new y(c,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var c=a.replace(k,C);j[c]=new y(c,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 N(a,c,p,w){var _=j.hasOwnProperty(c)?j[c]:null;(_!==null?_.type!==0:w||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(x(c,p,_,w)&&(p=null),w||_===null?b(c)&&(p===null?a.removeAttribute(c):a.setAttribute(c,""+p)):_.mustUseProperty?a[_.propertyName]=p===null?_.type===3?!1:"":p:(c=_.attributeName,w=_.attributeNamespace,p===null?a.removeAttribute(c):(_=_.type,p=_===3||_===4&&p===!0?"":""+p,w?a.setAttributeNS(w,c,p):a.setAttribute(c,p))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),$=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),T=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),q=Symbol.for("react.offscreen"),H=Symbol.iterator;function U(a){return a===null||typeof a!="object"?null:(a=H&&a[H]||a["@@iterator"],typeof a=="function"?a:null)}var Q=Object.assign,D;function Y(a){if(D===void 0)try{throw Error()}catch(p){var c=p.stack.trim().match(/\n( *(at )?)/);D=c&&c[1]||""}return`
|
|
34
|
-
`+D+a}var K=!1;function Z(a,c){if(!a||K)return"";K=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(me){var w=me}Reflect.construct(a,[],c)}else{try{c.call()}catch(me){w=me}a.call(c.prototype)}else{try{throw Error()}catch(me){w=me}a()}}catch(me){if(me&&w&&typeof me.stack=="string"){for(var _=me.stack.split(`
|
|
35
|
-
`),R=w.stack.split(`
|
|
36
|
-
`),z=_.length-1,X=R.length-1;1<=z&&0<=X&&_[z]!==R[X];)X--;for(;1<=z&&0<=X;z--,X--)if(_[z]!==R[X]){if(z!==1||X!==1)do if(z--,X--,0>X||_[z]!==R[X]){var ne=`
|
|
37
|
-
`+_[z].replace(" at new "," at ");return a.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",a.displayName)),ne}while(1<=z&&0<=X);break}}}finally{K=!1,Error.prepareStackTrace=p}return(a=a?a.displayName||a.name:"")?Y(a):""}function se(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=Z(a.type,!1),a;case 11:return a=Z(a.type.render,!1),a;case 1:return a=Z(a.type,!0),a;default:return""}}function ie(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 L:return"Fragment";case $:return"Portal";case P:return"Profiler";case A:return"StrictMode";case F:return"Suspense";case I:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case T:return(a.displayName||"Context")+".Consumer";case O:return(a._context.displayName||"Context")+".Provider";case M:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case V:return c=a.displayName||null,c!==null?c:ie(a.type)||"Memo";case G:c=a._payload,a=a._init;try{return ie(a(c))}catch{}}return null}function Ne(a){var c=a.type;switch(a.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=c.render,a=a.displayName||a.name||"",c.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ie(c);case 8:return c===A?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function he(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ve(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function Ee(a){var c=ve(a)?"checked":"value",p=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),w=""+a[c];if(!a.hasOwnProperty(c)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var _=p.get,R=p.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return _.call(this)},set:function(z){w=""+z,R.call(this,z)}}),Object.defineProperty(a,c,{enumerable:p.enumerable}),{getValue:function(){return w},setValue:function(z){w=""+z},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function ye(a){a._valueTracker||(a._valueTracker=Ee(a))}function pe(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var p=c.getValue(),w="";return a&&(w=ve(a)?a.checked?"true":"false":a.value),a=w,a!==p?(c.setValue(a),!0):!1}function Pe(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 ue(a,c){var p=c.checked;return Q({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??a._wrapperState.initialChecked})}function ge(a,c){var p=c.defaultValue==null?"":c.defaultValue,w=c.checked!=null?c.checked:c.defaultChecked;p=he(c.value!=null?c.value:p),a._wrapperState={initialChecked:w,initialValue:p,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Te(a,c){c=c.checked,c!=null&&N(a,"checked",c,!1)}function Xe(a,c){Te(a,c);var p=he(c.value),w=c.type;if(p!=null)w==="number"?(p===0&&a.value===""||a.value!=p)&&(a.value=""+p):a.value!==""+p&&(a.value=""+p);else if(w==="submit"||w==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?fe(a,c.type,p):c.hasOwnProperty("defaultValue")&&fe(a,c.type,he(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function je(a,c,p){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var w=c.type;if(!(w!=="submit"&&w!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+a._wrapperState.initialValue,p||c===a.value||(a.value=c),a.defaultValue=c}p=a.name,p!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,p!==""&&(a.name=p)}function fe(a,c,p){(c!=="number"||Pe(a.ownerDocument)!==a)&&(p==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+p&&(a.defaultValue=""+p))}var De=Array.isArray;function te(a,c,p,w){if(a=a.options,c){c={};for(var _=0;_<p.length;_++)c["$"+p[_]]=!0;for(p=0;p<a.length;p++)_=c.hasOwnProperty("$"+a[p].value),a[p].selected!==_&&(a[p].selected=_),_&&w&&(a[p].defaultSelected=!0)}else{for(p=""+he(p),c=null,_=0;_<a.length;_++){if(a[_].value===p){a[_].selected=!0,w&&(a[_].defaultSelected=!0);return}c!==null||a[_].disabled||(c=a[_])}c!==null&&(c.selected=!0)}}function Ie(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(s(91));return Q({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function We(a,c){var p=c.value;if(p==null){if(p=c.children,c=c.defaultValue,p!=null){if(c!=null)throw Error(s(92));if(De(p)){if(1<p.length)throw Error(s(93));p=p[0]}c=p}c==null&&(c=""),p=c}a._wrapperState={initialValue:he(p)}}function rt(a,c){var p=he(c.value),w=he(c.defaultValue);p!=null&&(p=""+p,p!==a.value&&(a.value=p),c.defaultValue==null&&a.defaultValue!==p&&(a.defaultValue=p)),w!=null&&(a.defaultValue=""+w)}function ot(a){var c=a.textContent;c===a._wrapperState.initialValue&&c!==""&&c!==null&&(a.value=c)}function wt(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 jt(a,c){return a==null||a==="http://www.w3.org/1999/xhtml"?wt(c):a==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var we,ze=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,p,w,_){MSApp.execUnsafeLocalFunction(function(){return a(c,p,w,_)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(we=we||document.createElement("div"),we.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=we.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function st(a,c){if(c){var p=a.firstChild;if(p&&p===a.lastChild&&p.nodeType===3){p.nodeValue=c;return}}a.textContent=c}var xe={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},Be=["Webkit","ms","Moz","O"];Object.keys(xe).forEach(function(a){Be.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),xe[c]=xe[a]})});function $t(a,c,p){return c==null||typeof c=="boolean"||c===""?"":p||typeof c!="number"||c===0||xe.hasOwnProperty(a)&&xe[a]?(""+c).trim():c+"px"}function et(a,c){a=a.style;for(var p in c)if(c.hasOwnProperty(p)){var w=p.indexOf("--")===0,_=$t(p,c[p],w);p==="float"&&(p="cssFloat"),w?a.setProperty(p,_):a[p]=_}}var dt=Q({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 Lt(a,c){if(c){if(dt[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(s(137,a));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(s(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(s(61))}if(c.style!=null&&typeof c.style!="object")throw Error(s(62))}}function qt(a,c){if(a.indexOf("-")===-1)return typeof c.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 At=null;function Et(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var B=null,J=null,de=null;function _e(a){if(a=wc(a)){if(typeof B!="function")throw Error(s(280));var c=a.stateNode;c&&(c=Au(c),B(a.stateNode,a.type,c))}}function at(a){J?de?de.push(a):de=[a]:J=a}function qe(){if(J){var a=J,c=de;if(de=J=null,_e(a),c)for(a=0;a<c.length;a++)_e(c[a])}}function ft(a,c){return a(c)}function $n(){}var en=!1;function qn(a,c,p){if(en)return a(c,p);en=!0;try{return ft(a,c,p)}finally{en=!1,(J!==null||de!==null)&&($n(),qe())}}function kn(a,c){var p=a.stateNode;if(p===null)return null;var w=Au(p);if(w===null)return null;p=w[c];e:switch(c){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(p&&typeof p!="function")throw Error(s(231,c,typeof p));return p}var pn=!1;if(d)try{var Gn={};Object.defineProperty(Gn,"passive",{get:function(){pn=!0}}),window.addEventListener("test",Gn,Gn),window.removeEventListener("test",Gn,Gn)}catch{pn=!1}function tt(a,c,p,w,_,R,z,X,ne){var me=Array.prototype.slice.call(arguments,3);try{c.apply(p,me)}catch(Ce){this.onError(Ce)}}var xt=!1,Rt=null,gn=!1,dn=null,re={onError:function(a){xt=!0,Rt=a}};function Me(a,c,p,w,_,R,z,X,ne){xt=!1,Rt=null,tt.apply(re,arguments)}function bt(a,c,p,w,_,R,z,X,ne){if(Me.apply(this,arguments),xt){if(xt){var me=Rt;xt=!1,Rt=null}else throw Error(s(198));gn||(gn=!0,dn=me)}}function Tt(a){var c=a,p=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(p=c.return),a=c.return;while(a)}return c.tag===3?p:null}function Bt(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function On(a){if(Tt(a)!==a)throw Error(s(188))}function Ln(a){var c=a.alternate;if(!c){if(c=Tt(a),c===null)throw Error(s(188));return c!==a?null:a}for(var p=a,w=c;;){var _=p.return;if(_===null)break;var R=_.alternate;if(R===null){if(w=_.return,w!==null){p=w;continue}break}if(_.child===R.child){for(R=_.child;R;){if(R===p)return On(_),a;if(R===w)return On(_),c;R=R.sibling}throw Error(s(188))}if(p.return!==w.return)p=_,w=R;else{for(var z=!1,X=_.child;X;){if(X===p){z=!0,p=_,w=R;break}if(X===w){z=!0,w=_,p=R;break}X=X.sibling}if(!z){for(X=R.child;X;){if(X===p){z=!0,p=R,w=_;break}if(X===w){z=!0,w=R,p=_;break}X=X.sibling}if(!z)throw Error(s(189))}}if(p.alternate!==w)throw Error(s(190))}if(p.tag!==3)throw Error(s(188));return p.stateNode.current===p?a:c}function Ge(a){return a=Ln(a),a!==null?oe(a):null}function oe(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=oe(a);if(c!==null)return c;a=a.sibling}return null}var Re=n.unstable_scheduleCallback,Ye=n.unstable_cancelCallback,Mt=n.unstable_shouldYield,Nn=n.unstable_requestPaint,pt=n.unstable_now,Mn=n.unstable_getCurrentPriorityLevel,Kn=n.unstable_ImmediatePriority,Ts=n.unstable_UserBlockingPriority,Qt=n.unstable_NormalPriority,Vs=n.unstable_LowPriority,so=n.unstable_IdlePriority,ji=null,Rs=null;function Kh(a){if(Rs&&typeof Rs.onCommitFiberRoot=="function")try{Rs.onCommitFiberRoot(ji,a,void 0,(a.current.flags&128)===128)}catch{}}var Zn=Math.clz32?Math.clz32:xu,Vh=Math.log,gu=Math.LN2;function xu(a){return a>>>=0,a===0?32:31-(Vh(a)/gu|0)|0}var _a=64,$a=4194304;function Io(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 Ea(a,c){var p=a.pendingLanes;if(p===0)return 0;var w=0,_=a.suspendedLanes,R=a.pingedLanes,z=p&268435455;if(z!==0){var X=z&~_;X!==0?w=Io(X):(R&=z,R!==0&&(w=Io(R)))}else z=p&~_,z!==0?w=Io(z):R!==0&&(w=Io(R));if(w===0)return 0;if(c!==0&&c!==w&&(c&_)===0&&(_=w&-w,R=c&-c,_>=R||_===16&&(R&4194240)!==0))return c;if((w&4)!==0&&(w|=p&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=w;0<c;)p=31-Zn(c),_=1<<p,w|=a[p],c&=~_;return w}function bu(a,c){switch(a){case 1:case 2:case 4:return c+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 c+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 vu(a,c){for(var p=a.suspendedLanes,w=a.pingedLanes,_=a.expirationTimes,R=a.pendingLanes;0<R;){var z=31-Zn(R),X=1<<z,ne=_[z];ne===-1?((X&p)===0||(X&w)!==0)&&(_[z]=bu(X,c)):ne<=c&&(a.expiredLanes|=X),R&=~X}}function ki(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Zl(){var a=_a;return _a<<=1,(_a&4194240)===0&&(_a=64),a}function Ni(a){for(var c=[],p=0;31>p;p++)c.push(a);return c}function Po(a,c,p){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-Zn(c),a[c]=p}function yu(a,c){var p=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var w=a.eventTimes;for(a=a.expirationTimes;0<p;){var _=31-Zn(p),R=1<<_;c[_]=0,w[_]=-1,a[_]=-1,p&=~R}}function Si(a,c){var p=a.entangledLanes|=c;for(a=a.entanglements;p;){var w=31-Zn(p),_=1<<w;_&c|a[w]&c&&(a[w]|=c),p&=~_}}var It=0;function ec(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var tc,Ci,nc,sc,rc,_i=!1,Ta=[],pr=null,gr=null,xr=null,Do=new Map,zo=new Map,br=[],wu="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 oc(a,c){switch(a){case"focusin":case"focusout":pr=null;break;case"dragenter":case"dragleave":gr=null;break;case"mouseover":case"mouseout":xr=null;break;case"pointerover":case"pointerout":Do.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":zo.delete(c.pointerId)}}function Fo(a,c,p,w,_,R){return a===null||a.nativeEvent!==R?(a={blockedOn:c,domEventName:p,eventSystemFlags:w,nativeEvent:R,targetContainers:[_]},c!==null&&(c=wc(c),c!==null&&Ci(c)),a):(a.eventSystemFlags|=w,c=a.targetContainers,_!==null&&c.indexOf(_)===-1&&c.push(_),a)}function ju(a,c,p,w,_){switch(c){case"focusin":return pr=Fo(pr,a,c,p,w,_),!0;case"dragenter":return gr=Fo(gr,a,c,p,w,_),!0;case"mouseover":return xr=Fo(xr,a,c,p,w,_),!0;case"pointerover":var R=_.pointerId;return Do.set(R,Fo(Do.get(R)||null,a,c,p,w,_)),!0;case"gotpointercapture":return R=_.pointerId,zo.set(R,Fo(zo.get(R)||null,a,c,p,w,_)),!0}return!1}function ac(a){var c=Aa(a.target);if(c!==null){var p=Tt(c);if(p!==null){if(c=p.tag,c===13){if(c=Bt(p),c!==null){a.blockedOn=c,rc(a.priority,function(){nc(p)});return}}else if(c===3&&p.stateNode.current.memoizedState.isDehydrated){a.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Ra(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var p=lc(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(p===null){p=a.nativeEvent;var w=new p.constructor(p.type,p);At=w,p.target.dispatchEvent(w),At=null}else return c=wc(p),c!==null&&Ci(c),a.blockedOn=p,!1;c.shift()}return!0}function be(a,c,p){Ra(a)&&p.delete(c)}function Oe(){_i=!1,pr!==null&&Ra(pr)&&(pr=null),gr!==null&&Ra(gr)&&(gr=null),xr!==null&&Ra(xr)&&(xr=null),Do.forEach(be),zo.forEach(be)}function He(a,c){a.blockedOn===c&&(a.blockedOn=null,_i||(_i=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Oe)))}function kt(a){function c(_){return He(_,a)}if(0<Ta.length){He(Ta[0],a);for(var p=1;p<Ta.length;p++){var w=Ta[p];w.blockedOn===a&&(w.blockedOn=null)}}for(pr!==null&&He(pr,a),gr!==null&&He(gr,a),xr!==null&&He(xr,a),Do.forEach(c),zo.forEach(c),p=0;p<br.length;p++)w=br[p],w.blockedOn===a&&(w.blockedOn=null);for(;0<br.length&&(p=br[0],p.blockedOn===null);)ac(p),p.blockedOn===null&&br.shift()}var yt=S.ReactCurrentBatchConfig,As=!0;function In(a,c,p,w){var _=It,R=yt.transition;yt.transition=null;try{It=1,ic(a,c,p,w)}finally{It=_,yt.transition=R}}function vs(a,c,p,w){var _=It,R=yt.transition;yt.transition=null;try{It=4,ic(a,c,p,w)}finally{It=_,yt.transition=R}}function ic(a,c,p,w){if(As){var _=lc(a,c,p,w);if(_===null)dp(a,c,w,vr,p),oc(a,w);else if(ju(_,a,c,p,w))w.stopPropagation();else if(oc(a,w),c&4&&-1<wu.indexOf(a)){for(;_!==null;){var R=wc(_);if(R!==null&&tc(R),R=lc(a,c,p,w),R===null&&dp(a,c,w,vr,p),R===_)break;_=R}_!==null&&w.stopPropagation()}else dp(a,c,w,null,p)}}var vr=null;function lc(a,c,p,w){if(vr=null,a=Et(w),a=Aa(a),a!==null)if(c=Tt(a),c===null)a=null;else if(p=c.tag,p===13){if(a=Bt(c),a!==null)return a;a=null}else if(p===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return vr=a,null}function cc(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(Mn()){case Kn:return 1;case Ts:return 4;case Qt:case Vs:return 16;case so:return 536870912;default:return 16}default:return 16}}var yr=null,$i=null,ro=null;function oo(){if(ro)return ro;var a,c=$i,p=c.length,w,_="value"in yr?yr.value:yr.textContent,R=_.length;for(a=0;a<p&&c[a]===_[a];a++);var z=p-a;for(w=1;w<=z&&c[p-w]===_[R-w];w++);return ro=_.slice(a,1<w?1-w:void 0)}function Os(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function ku(){return!0}function Py(){return!1}function Ls(a){function c(p,w,_,R,z){this._reactName=p,this._targetInst=_,this.type=w,this.nativeEvent=R,this.target=z,this.currentTarget=null;for(var X in a)a.hasOwnProperty(X)&&(p=a[X],this[X]=p?p(R):R[X]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?ku:Py,this.isPropagationStopped=Py,this}return Q(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=ku)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=ku)},persist:function(){},isPersistent:ku}),c}var Ei={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yh=Ls(Ei),dc=Q({},Ei,{view:0,detail:0}),uT=Ls(dc),Qh,Jh,uc,Nu=Q({},dc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zh,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!==uc&&(uc&&a.type==="mousemove"?(Qh=a.screenX-uc.screenX,Jh=a.screenY-uc.screenY):Jh=Qh=0,uc=a),Qh)},movementY:function(a){return"movementY"in a?a.movementY:Jh}}),Dy=Ls(Nu),fT=Q({},Nu,{dataTransfer:0}),mT=Ls(fT),hT=Q({},dc,{relatedTarget:0}),Xh=Ls(hT),pT=Q({},Ei,{animationName:0,elapsedTime:0,pseudoElement:0}),gT=Ls(pT),xT=Q({},Ei,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),bT=Ls(xT),vT=Q({},Ei,{data:0}),zy=Ls(vT),yT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},wT={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"},jT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kT(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=jT[a])?!!c[a]:!1}function Zh(){return kT}var NT=Q({},dc,{key:function(a){if(a.key){var c=yT[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Os(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?wT[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zh,charCode:function(a){return a.type==="keypress"?Os(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Os(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),ST=Ls(NT),CT=Q({},Nu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fy=Ls(CT),_T=Q({},dc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zh}),$T=Ls(_T),ET=Q({},Ei,{propertyName:0,elapsedTime:0,pseudoElement:0}),TT=Ls(ET),RT=Q({},Nu,{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}),AT=Ls(RT),OT=[9,13,27,32],ep=d&&"CompositionEvent"in window,fc=null;d&&"documentMode"in document&&(fc=document.documentMode);var LT=d&&"TextEvent"in window&&!fc,Uy=d&&(!ep||fc&&8<fc&&11>=fc),Wy=" ",Hy=!1;function By(a,c){switch(a){case"keyup":return OT.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Ti=!1;function MT(a,c){switch(a){case"compositionend":return qy(c);case"keypress":return c.which!==32?null:(Hy=!0,Wy);case"textInput":return a=c.data,a===Wy&&Hy?null:a;default:return null}}function IT(a,c){if(Ti)return a==="compositionend"||!ep&&By(a,c)?(a=oo(),ro=$i=yr=null,Ti=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Uy&&c.locale!=="ko"?null:c.data;default:return null}}var PT={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 Gy(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!PT[a.type]:c==="textarea"}function Ky(a,c,p,w){at(w),c=Eu(c,"onChange"),0<c.length&&(p=new Yh("onChange","change",null,p,w),a.push({event:p,listeners:c}))}var mc=null,hc=null;function DT(a){uw(a,0)}function Su(a){var c=Mi(a);if(pe(c))return a}function zT(a,c){if(a==="change")return c}var Vy=!1;if(d){var tp;if(d){var np="oninput"in document;if(!np){var Yy=document.createElement("div");Yy.setAttribute("oninput","return;"),np=typeof Yy.oninput=="function"}tp=np}else tp=!1;Vy=tp&&(!document.documentMode||9<document.documentMode)}function Qy(){mc&&(mc.detachEvent("onpropertychange",Jy),hc=mc=null)}function Jy(a){if(a.propertyName==="value"&&Su(hc)){var c=[];Ky(c,hc,a,Et(a)),qn(DT,c)}}function FT(a,c,p){a==="focusin"?(Qy(),mc=c,hc=p,mc.attachEvent("onpropertychange",Jy)):a==="focusout"&&Qy()}function UT(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Su(hc)}function WT(a,c){if(a==="click")return Su(c)}function HT(a,c){if(a==="input"||a==="change")return Su(c)}function BT(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var wr=typeof Object.is=="function"?Object.is:BT;function pc(a,c){if(wr(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var p=Object.keys(a),w=Object.keys(c);if(p.length!==w.length)return!1;for(w=0;w<p.length;w++){var _=p[w];if(!u.call(c,_)||!wr(a[_],c[_]))return!1}return!0}function Xy(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Zy(a,c){var p=Xy(a);a=0;for(var w;p;){if(p.nodeType===3){if(w=a+p.textContent.length,a<=c&&w>=c)return{node:p,offset:c-a};a=w}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Xy(p)}}function ew(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?ew(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function tw(){for(var a=window,c=Pe();c instanceof a.HTMLIFrameElement;){try{var p=typeof c.contentWindow.location.href=="string"}catch{p=!1}if(p)a=c.contentWindow;else break;c=Pe(a.document)}return c}function sp(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}function qT(a){var c=tw(),p=a.focusedElem,w=a.selectionRange;if(c!==p&&p&&p.ownerDocument&&ew(p.ownerDocument.documentElement,p)){if(w!==null&&sp(p)){if(c=w.start,a=w.end,a===void 0&&(a=c),"selectionStart"in p)p.selectionStart=c,p.selectionEnd=Math.min(a,p.value.length);else if(a=(c=p.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var _=p.textContent.length,R=Math.min(w.start,_);w=w.end===void 0?R:Math.min(w.end,_),!a.extend&&R>w&&(_=w,w=R,R=_),_=Zy(p,R);var z=Zy(p,w);_&&z&&(a.rangeCount!==1||a.anchorNode!==_.node||a.anchorOffset!==_.offset||a.focusNode!==z.node||a.focusOffset!==z.offset)&&(c=c.createRange(),c.setStart(_.node,_.offset),a.removeAllRanges(),R>w?(a.addRange(c),a.extend(z.node,z.offset)):(c.setEnd(z.node,z.offset),a.addRange(c)))}}for(c=[],a=p;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<c.length;p++)a=c[p],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var GT=d&&"documentMode"in document&&11>=document.documentMode,Ri=null,rp=null,gc=null,op=!1;function nw(a,c,p){var w=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;op||Ri==null||Ri!==Pe(w)||(w=Ri,"selectionStart"in w&&sp(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}),gc&&pc(gc,w)||(gc=w,w=Eu(rp,"onSelect"),0<w.length&&(c=new Yh("onSelect","select",null,c,p),a.push({event:c,listeners:w}),c.target=Ri)))}function Cu(a,c){var p={};return p[a.toLowerCase()]=c.toLowerCase(),p["Webkit"+a]="webkit"+c,p["Moz"+a]="moz"+c,p}var Ai={animationend:Cu("Animation","AnimationEnd"),animationiteration:Cu("Animation","AnimationIteration"),animationstart:Cu("Animation","AnimationStart"),transitionend:Cu("Transition","TransitionEnd")},ap={},sw={};d&&(sw=document.createElement("div").style,"AnimationEvent"in window||(delete Ai.animationend.animation,delete Ai.animationiteration.animation,delete Ai.animationstart.animation),"TransitionEvent"in window||delete Ai.transitionend.transition);function _u(a){if(ap[a])return ap[a];if(!Ai[a])return a;var c=Ai[a],p;for(p in c)if(c.hasOwnProperty(p)&&p in sw)return ap[a]=c[p];return a}var rw=_u("animationend"),ow=_u("animationiteration"),aw=_u("animationstart"),iw=_u("transitionend"),lw=new Map,cw="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 Uo(a,c){lw.set(a,c),i(c,[a])}for(var ip=0;ip<cw.length;ip++){var lp=cw[ip],KT=lp.toLowerCase(),VT=lp[0].toUpperCase()+lp.slice(1);Uo(KT,"on"+VT)}Uo(rw,"onAnimationEnd"),Uo(ow,"onAnimationIteration"),Uo(aw,"onAnimationStart"),Uo("dblclick","onDoubleClick"),Uo("focusin","onFocus"),Uo("focusout","onBlur"),Uo(iw,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("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 xc="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(" "),YT=new Set("cancel close invalid load scroll toggle".split(" ").concat(xc));function dw(a,c,p){var w=a.type||"unknown-event";a.currentTarget=p,bt(w,c,void 0,a),a.currentTarget=null}function uw(a,c){c=(c&4)!==0;for(var p=0;p<a.length;p++){var w=a[p],_=w.event;w=w.listeners;e:{var R=void 0;if(c)for(var z=w.length-1;0<=z;z--){var X=w[z],ne=X.instance,me=X.currentTarget;if(X=X.listener,ne!==R&&_.isPropagationStopped())break e;dw(_,X,me),R=ne}else for(z=0;z<w.length;z++){if(X=w[z],ne=X.instance,me=X.currentTarget,X=X.listener,ne!==R&&_.isPropagationStopped())break e;dw(_,X,me),R=ne}}}if(gn)throw a=dn,gn=!1,dn=null,a}function Jt(a,c){var p=c[gp];p===void 0&&(p=c[gp]=new Set);var w=a+"__bubble";p.has(w)||(fw(c,a,2,!1),p.add(w))}function cp(a,c,p){var w=0;c&&(w|=4),fw(p,a,w,c)}var $u="_reactListening"+Math.random().toString(36).slice(2);function bc(a){if(!a[$u]){a[$u]=!0,r.forEach(function(p){p!=="selectionchange"&&(YT.has(p)||cp(p,!1,a),cp(p,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[$u]||(c[$u]=!0,cp("selectionchange",!1,c))}}function fw(a,c,p,w){switch(cc(c)){case 1:var _=In;break;case 4:_=vs;break;default:_=ic}p=_.bind(null,c,p,a),_=void 0,!pn||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(_=!0),w?_!==void 0?a.addEventListener(c,p,{capture:!0,passive:_}):a.addEventListener(c,p,!0):_!==void 0?a.addEventListener(c,p,{passive:_}):a.addEventListener(c,p,!1)}function dp(a,c,p,w,_){var R=w;if((c&1)===0&&(c&2)===0&&w!==null)e:for(;;){if(w===null)return;var z=w.tag;if(z===3||z===4){var X=w.stateNode.containerInfo;if(X===_||X.nodeType===8&&X.parentNode===_)break;if(z===4)for(z=w.return;z!==null;){var ne=z.tag;if((ne===3||ne===4)&&(ne=z.stateNode.containerInfo,ne===_||ne.nodeType===8&&ne.parentNode===_))return;z=z.return}for(;X!==null;){if(z=Aa(X),z===null)return;if(ne=z.tag,ne===5||ne===6){w=R=z;continue e}X=X.parentNode}}w=w.return}qn(function(){var me=R,Ce=Et(p),$e=[];e:{var Se=lw.get(a);if(Se!==void 0){var Ke=Yh,Je=a;switch(a){case"keypress":if(Os(p)===0)break e;case"keydown":case"keyup":Ke=ST;break;case"focusin":Je="focus",Ke=Xh;break;case"focusout":Je="blur",Ke=Xh;break;case"beforeblur":case"afterblur":Ke=Xh;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=Dy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=mT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=$T;break;case rw:case ow:case aw:Ke=gT;break;case iw:Ke=TT;break;case"scroll":Ke=uT;break;case"wheel":Ke=AT;break;case"copy":case"cut":case"paste":Ke=bT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=Fy}var Ze=(c&4)!==0,xn=!Ze&&a==="scroll",le=Ze?Se!==null?Se+"Capture":null:Se;Ze=[];for(var ae=me,ce;ae!==null;){ce=ae;var Le=ce.stateNode;if(ce.tag===5&&Le!==null&&(ce=Le,le!==null&&(Le=kn(ae,le),Le!=null&&Ze.push(vc(ae,Le,ce)))),xn)break;ae=ae.return}0<Ze.length&&(Se=new Ke(Se,Je,null,p,Ce),$e.push({event:Se,listeners:Ze}))}}if((c&7)===0){e:{if(Se=a==="mouseover"||a==="pointerover",Ke=a==="mouseout"||a==="pointerout",Se&&p!==At&&(Je=p.relatedTarget||p.fromElement)&&(Aa(Je)||Je[ao]))break e;if((Ke||Se)&&(Se=Ce.window===Ce?Ce:(Se=Ce.ownerDocument)?Se.defaultView||Se.parentWindow:window,Ke?(Je=p.relatedTarget||p.toElement,Ke=me,Je=Je?Aa(Je):null,Je!==null&&(xn=Tt(Je),Je!==xn||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(Ke=null,Je=me),Ke!==Je)){if(Ze=Dy,Le="onMouseLeave",le="onMouseEnter",ae="mouse",(a==="pointerout"||a==="pointerover")&&(Ze=Fy,Le="onPointerLeave",le="onPointerEnter",ae="pointer"),xn=Ke==null?Se:Mi(Ke),ce=Je==null?Se:Mi(Je),Se=new Ze(Le,ae+"leave",Ke,p,Ce),Se.target=xn,Se.relatedTarget=ce,Le=null,Aa(Ce)===me&&(Ze=new Ze(le,ae+"enter",Je,p,Ce),Ze.target=ce,Ze.relatedTarget=xn,Le=Ze),xn=Le,Ke&&Je)t:{for(Ze=Ke,le=Je,ae=0,ce=Ze;ce;ce=Oi(ce))ae++;for(ce=0,Le=le;Le;Le=Oi(Le))ce++;for(;0<ae-ce;)Ze=Oi(Ze),ae--;for(;0<ce-ae;)le=Oi(le),ce--;for(;ae--;){if(Ze===le||le!==null&&Ze===le.alternate)break t;Ze=Oi(Ze),le=Oi(le)}Ze=null}else Ze=null;Ke!==null&&mw($e,Se,Ke,Ze,!1),Je!==null&&xn!==null&&mw($e,xn,Je,Ze,!0)}}e:{if(Se=me?Mi(me):window,Ke=Se.nodeName&&Se.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&Se.type==="file")var nt=zT;else if(Gy(Se))if(Vy)nt=HT;else{nt=UT;var it=FT}else(Ke=Se.nodeName)&&Ke.toLowerCase()==="input"&&(Se.type==="checkbox"||Se.type==="radio")&&(nt=WT);if(nt&&(nt=nt(a,me))){Ky($e,nt,p,Ce);break e}it&&it(a,Se,me),a==="focusout"&&(it=Se._wrapperState)&&it.controlled&&Se.type==="number"&&fe(Se,"number",Se.value)}switch(it=me?Mi(me):window,a){case"focusin":(Gy(it)||it.contentEditable==="true")&&(Ri=it,rp=me,gc=null);break;case"focusout":gc=rp=Ri=null;break;case"mousedown":op=!0;break;case"contextmenu":case"mouseup":case"dragend":op=!1,nw($e,p,Ce);break;case"selectionchange":if(GT)break;case"keydown":case"keyup":nw($e,p,Ce)}var lt;if(ep)e:{switch(a){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else Ti?By(a,p)&&(ut="onCompositionEnd"):a==="keydown"&&p.keyCode===229&&(ut="onCompositionStart");ut&&(Uy&&p.locale!=="ko"&&(Ti||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&Ti&&(lt=oo()):(yr=Ce,$i="value"in yr?yr.value:yr.textContent,Ti=!0)),it=Eu(me,ut),0<it.length&&(ut=new zy(ut,a,null,p,Ce),$e.push({event:ut,listeners:it}),lt?ut.data=lt:(lt=qy(p),lt!==null&&(ut.data=lt)))),(lt=LT?MT(a,p):IT(a,p))&&(me=Eu(me,"onBeforeInput"),0<me.length&&(Ce=new zy("onBeforeInput","beforeinput",null,p,Ce),$e.push({event:Ce,listeners:me}),Ce.data=lt))}uw($e,c)})}function vc(a,c,p){return{instance:a,listener:c,currentTarget:p}}function Eu(a,c){for(var p=c+"Capture",w=[];a!==null;){var _=a,R=_.stateNode;_.tag===5&&R!==null&&(_=R,R=kn(a,p),R!=null&&w.unshift(vc(a,R,_)),R=kn(a,c),R!=null&&w.push(vc(a,R,_))),a=a.return}return w}function Oi(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function mw(a,c,p,w,_){for(var R=c._reactName,z=[];p!==null&&p!==w;){var X=p,ne=X.alternate,me=X.stateNode;if(ne!==null&&ne===w)break;X.tag===5&&me!==null&&(X=me,_?(ne=kn(p,R),ne!=null&&z.unshift(vc(p,ne,X))):_||(ne=kn(p,R),ne!=null&&z.push(vc(p,ne,X)))),p=p.return}z.length!==0&&a.push({event:c,listeners:z})}var QT=/\r\n?/g,JT=/\u0000|\uFFFD/g;function hw(a){return(typeof a=="string"?a:""+a).replace(QT,`
|
|
38
|
-
`).replace(JT,"")}function Tu(a,c,p){if(c=hw(c),hw(a)!==c&&p)throw Error(s(425))}function Ru(){}var up=null,fp=null;function mp(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var hp=typeof setTimeout=="function"?setTimeout:void 0,XT=typeof clearTimeout=="function"?clearTimeout:void 0,pw=typeof Promise=="function"?Promise:void 0,ZT=typeof queueMicrotask=="function"?queueMicrotask:typeof pw<"u"?function(a){return pw.resolve(null).then(a).catch(eR)}:hp;function eR(a){setTimeout(function(){throw a})}function pp(a,c){var p=c,w=0;do{var _=p.nextSibling;if(a.removeChild(p),_&&_.nodeType===8)if(p=_.data,p==="/$"){if(w===0){a.removeChild(_),kt(c);return}w--}else p!=="$"&&p!=="$?"&&p!=="$!"||w++;p=_}while(p);kt(c)}function Wo(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function gw(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="$"||p==="$!"||p==="$?"){if(c===0)return a;c--}else p==="/$"&&c++}a=a.previousSibling}return null}var Li=Math.random().toString(36).slice(2),Ir="__reactFiber$"+Li,yc="__reactProps$"+Li,ao="__reactContainer$"+Li,gp="__reactEvents$"+Li,tR="__reactListeners$"+Li,nR="__reactHandles$"+Li;function Aa(a){var c=a[Ir];if(c)return c;for(var p=a.parentNode;p;){if(c=p[ao]||p[Ir]){if(p=c.alternate,c.child!==null||p!==null&&p.child!==null)for(a=gw(a);a!==null;){if(p=a[Ir])return p;a=gw(a)}return c}a=p,p=a.parentNode}return null}function wc(a){return a=a[Ir]||a[ao],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Mi(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function Au(a){return a[yc]||null}var xp=[],Ii=-1;function Ho(a){return{current:a}}function Xt(a){0>Ii||(a.current=xp[Ii],xp[Ii]=null,Ii--)}function Kt(a,c){Ii++,xp[Ii]=a.current,a.current=c}var Bo={},es=Ho(Bo),ys=Ho(!1),Oa=Bo;function Pi(a,c){var p=a.type.contextTypes;if(!p)return Bo;var w=a.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===c)return w.__reactInternalMemoizedMaskedChildContext;var _={},R;for(R in p)_[R]=c[R];return w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=_),_}function ws(a){return a=a.childContextTypes,a!=null}function Ou(){Xt(ys),Xt(es)}function xw(a,c,p){if(es.current!==Bo)throw Error(s(168));Kt(es,c),Kt(ys,p)}function bw(a,c,p){var w=a.stateNode;if(c=c.childContextTypes,typeof w.getChildContext!="function")return p;w=w.getChildContext();for(var _ in w)if(!(_ in c))throw Error(s(108,Ne(a)||"Unknown",_));return Q({},p,w)}function Lu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Bo,Oa=es.current,Kt(es,a),Kt(ys,ys.current),!0}function vw(a,c,p){var w=a.stateNode;if(!w)throw Error(s(169));p?(a=bw(a,c,Oa),w.__reactInternalMemoizedMergedChildContext=a,Xt(ys),Xt(es),Kt(es,a)):Xt(ys),Kt(ys,p)}var io=null,Mu=!1,bp=!1;function yw(a){io===null?io=[a]:io.push(a)}function sR(a){Mu=!0,yw(a)}function qo(){if(!bp&&io!==null){bp=!0;var a=0,c=It;try{var p=io;for(It=1;a<p.length;a++){var w=p[a];do w=w(!0);while(w!==null)}io=null,Mu=!1}catch(_){throw io!==null&&(io=io.slice(a+1)),Re(Kn,qo),_}finally{It=c,bp=!1}}return null}var Di=[],zi=0,Iu=null,Pu=0,Ys=[],Qs=0,La=null,lo=1,co="";function Ma(a,c){Di[zi++]=Pu,Di[zi++]=Iu,Iu=a,Pu=c}function ww(a,c,p){Ys[Qs++]=lo,Ys[Qs++]=co,Ys[Qs++]=La,La=a;var w=lo;a=co;var _=32-Zn(w)-1;w&=~(1<<_),p+=1;var R=32-Zn(c)+_;if(30<R){var z=_-_%5;R=(w&(1<<z)-1).toString(32),w>>=z,_-=z,lo=1<<32-Zn(c)+_|p<<_|w,co=R+a}else lo=1<<R|p<<_|w,co=a}function vp(a){a.return!==null&&(Ma(a,1),ww(a,1,0))}function yp(a){for(;a===Iu;)Iu=Di[--zi],Di[zi]=null,Pu=Di[--zi],Di[zi]=null;for(;a===La;)La=Ys[--Qs],Ys[Qs]=null,co=Ys[--Qs],Ys[Qs]=null,lo=Ys[--Qs],Ys[Qs]=null}var Ms=null,Is=null,tn=!1,jr=null;function jw(a,c){var p=er(5,null,null,0);p.elementType="DELETED",p.stateNode=c,p.return=a,c=a.deletions,c===null?(a.deletions=[p],a.flags|=16):c.push(p)}function kw(a,c){switch(a.tag){case 5:var p=a.type;return c=c.nodeType!==1||p.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,Ms=a,Is=Wo(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,Ms=a,Is=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(p=La!==null?{id:lo,overflow:co}:null,a.memoizedState={dehydrated:c,treeContext:p,retryLane:1073741824},p=er(18,null,null,0),p.stateNode=c,p.return=a,a.child=p,Ms=a,Is=null,!0):!1;default:return!1}}function wp(a){return(a.mode&1)!==0&&(a.flags&128)===0}function jp(a){if(tn){var c=Is;if(c){var p=c;if(!kw(a,c)){if(wp(a))throw Error(s(418));c=Wo(p.nextSibling);var w=Ms;c&&kw(a,c)?jw(w,p):(a.flags=a.flags&-4097|2,tn=!1,Ms=a)}}else{if(wp(a))throw Error(s(418));a.flags=a.flags&-4097|2,tn=!1,Ms=a}}}function Nw(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ms=a}function Du(a){if(a!==Ms)return!1;if(!tn)return Nw(a),tn=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!mp(a.type,a.memoizedProps)),c&&(c=Is)){if(wp(a))throw Sw(),Error(s(418));for(;c;)jw(a,c),c=Wo(c.nextSibling)}if(Nw(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="/$"){if(c===0){Is=Wo(a.nextSibling);break e}c--}else p!=="$"&&p!=="$!"&&p!=="$?"||c++}a=a.nextSibling}Is=null}}else Is=Ms?Wo(a.stateNode.nextSibling):null;return!0}function Sw(){for(var a=Is;a;)a=Wo(a.nextSibling)}function Fi(){Is=Ms=null,tn=!1}function kp(a){jr===null?jr=[a]:jr.push(a)}var rR=S.ReactCurrentBatchConfig;function jc(a,c,p){if(a=p.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(s(309));var w=p.stateNode}if(!w)throw Error(s(147,a));var _=w,R=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===R?c.ref:(c=function(z){var X=_.refs;z===null?delete X[R]:X[R]=z},c._stringRef=R,c)}if(typeof a!="string")throw Error(s(284));if(!p._owner)throw Error(s(290,a))}return a}function zu(a,c){throw a=Object.prototype.toString.call(c),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Cw(a){var c=a._init;return c(a._payload)}function _w(a){function c(le,ae){if(a){var ce=le.deletions;ce===null?(le.deletions=[ae],le.flags|=16):ce.push(ae)}}function p(le,ae){if(!a)return null;for(;ae!==null;)c(le,ae),ae=ae.sibling;return null}function w(le,ae){for(le=new Map;ae!==null;)ae.key!==null?le.set(ae.key,ae):le.set(ae.index,ae),ae=ae.sibling;return le}function _(le,ae){return le=Zo(le,ae),le.index=0,le.sibling=null,le}function R(le,ae,ce){return le.index=ce,a?(ce=le.alternate,ce!==null?(ce=ce.index,ce<ae?(le.flags|=2,ae):ce):(le.flags|=2,ae)):(le.flags|=1048576,ae)}function z(le){return a&&le.alternate===null&&(le.flags|=2),le}function X(le,ae,ce,Le){return ae===null||ae.tag!==6?(ae=hg(ce,le.mode,Le),ae.return=le,ae):(ae=_(ae,ce),ae.return=le,ae)}function ne(le,ae,ce,Le){var nt=ce.type;return nt===L?Ce(le,ae,ce.props.children,Le,ce.key):ae!==null&&(ae.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===G&&Cw(nt)===ae.type)?(Le=_(ae,ce.props),Le.ref=jc(le,ae,ce),Le.return=le,Le):(Le=df(ce.type,ce.key,ce.props,null,le.mode,Le),Le.ref=jc(le,ae,ce),Le.return=le,Le)}function me(le,ae,ce,Le){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ce.containerInfo||ae.stateNode.implementation!==ce.implementation?(ae=pg(ce,le.mode,Le),ae.return=le,ae):(ae=_(ae,ce.children||[]),ae.return=le,ae)}function Ce(le,ae,ce,Le,nt){return ae===null||ae.tag!==7?(ae=Ha(ce,le.mode,Le,nt),ae.return=le,ae):(ae=_(ae,ce),ae.return=le,ae)}function $e(le,ae,ce){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=hg(""+ae,le.mode,ce),ae.return=le,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case E:return ce=df(ae.type,ae.key,ae.props,null,le.mode,ce),ce.ref=jc(le,null,ae),ce.return=le,ce;case $:return ae=pg(ae,le.mode,ce),ae.return=le,ae;case G:var Le=ae._init;return $e(le,Le(ae._payload),ce)}if(De(ae)||U(ae))return ae=Ha(ae,le.mode,ce,null),ae.return=le,ae;zu(le,ae)}return null}function Se(le,ae,ce,Le){var nt=ae!==null?ae.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return nt!==null?null:X(le,ae,""+ce,Le);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case E:return ce.key===nt?ne(le,ae,ce,Le):null;case $:return ce.key===nt?me(le,ae,ce,Le):null;case G:return nt=ce._init,Se(le,ae,nt(ce._payload),Le)}if(De(ce)||U(ce))return nt!==null?null:Ce(le,ae,ce,Le,null);zu(le,ce)}return null}function Ke(le,ae,ce,Le,nt){if(typeof Le=="string"&&Le!==""||typeof Le=="number")return le=le.get(ce)||null,X(ae,le,""+Le,nt);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case E:return le=le.get(Le.key===null?ce:Le.key)||null,ne(ae,le,Le,nt);case $:return le=le.get(Le.key===null?ce:Le.key)||null,me(ae,le,Le,nt);case G:var it=Le._init;return Ke(le,ae,ce,it(Le._payload),nt)}if(De(Le)||U(Le))return le=le.get(ce)||null,Ce(ae,le,Le,nt,null);zu(ae,Le)}return null}function Je(le,ae,ce,Le){for(var nt=null,it=null,lt=ae,ut=ae=0,zn=null;lt!==null&&ut<ce.length;ut++){lt.index>ut?(zn=lt,lt=null):zn=lt.sibling;var Pt=Se(le,lt,ce[ut],Le);if(Pt===null){lt===null&&(lt=zn);break}a&<&&Pt.alternate===null&&c(le,lt),ae=R(Pt,ae,ut),it===null?nt=Pt:it.sibling=Pt,it=Pt,lt=zn}if(ut===ce.length)return p(le,lt),tn&&Ma(le,ut),nt;if(lt===null){for(;ut<ce.length;ut++)lt=$e(le,ce[ut],Le),lt!==null&&(ae=R(lt,ae,ut),it===null?nt=lt:it.sibling=lt,it=lt);return tn&&Ma(le,ut),nt}for(lt=w(le,lt);ut<ce.length;ut++)zn=Ke(lt,le,ut,ce[ut],Le),zn!==null&&(a&&zn.alternate!==null&<.delete(zn.key===null?ut:zn.key),ae=R(zn,ae,ut),it===null?nt=zn:it.sibling=zn,it=zn);return a&<.forEach(function(ea){return c(le,ea)}),tn&&Ma(le,ut),nt}function Ze(le,ae,ce,Le){var nt=U(ce);if(typeof nt!="function")throw Error(s(150));if(ce=nt.call(ce),ce==null)throw Error(s(151));for(var it=nt=null,lt=ae,ut=ae=0,zn=null,Pt=ce.next();lt!==null&&!Pt.done;ut++,Pt=ce.next()){lt.index>ut?(zn=lt,lt=null):zn=lt.sibling;var ea=Se(le,lt,Pt.value,Le);if(ea===null){lt===null&&(lt=zn);break}a&<&&ea.alternate===null&&c(le,lt),ae=R(ea,ae,ut),it===null?nt=ea:it.sibling=ea,it=ea,lt=zn}if(Pt.done)return p(le,lt),tn&&Ma(le,ut),nt;if(lt===null){for(;!Pt.done;ut++,Pt=ce.next())Pt=$e(le,Pt.value,Le),Pt!==null&&(ae=R(Pt,ae,ut),it===null?nt=Pt:it.sibling=Pt,it=Pt);return tn&&Ma(le,ut),nt}for(lt=w(le,lt);!Pt.done;ut++,Pt=ce.next())Pt=Ke(lt,le,ut,Pt.value,Le),Pt!==null&&(a&&Pt.alternate!==null&<.delete(Pt.key===null?ut:Pt.key),ae=R(Pt,ae,ut),it===null?nt=Pt:it.sibling=Pt,it=Pt);return a&<.forEach(function(PR){return c(le,PR)}),tn&&Ma(le,ut),nt}function xn(le,ae,ce,Le){if(typeof ce=="object"&&ce!==null&&ce.type===L&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case E:e:{for(var nt=ce.key,it=ae;it!==null;){if(it.key===nt){if(nt=ce.type,nt===L){if(it.tag===7){p(le,it.sibling),ae=_(it,ce.props.children),ae.return=le,le=ae;break e}}else if(it.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===G&&Cw(nt)===it.type){p(le,it.sibling),ae=_(it,ce.props),ae.ref=jc(le,it,ce),ae.return=le,le=ae;break e}p(le,it);break}else c(le,it);it=it.sibling}ce.type===L?(ae=Ha(ce.props.children,le.mode,Le,ce.key),ae.return=le,le=ae):(Le=df(ce.type,ce.key,ce.props,null,le.mode,Le),Le.ref=jc(le,ae,ce),Le.return=le,le=Le)}return z(le);case $:e:{for(it=ce.key;ae!==null;){if(ae.key===it)if(ae.tag===4&&ae.stateNode.containerInfo===ce.containerInfo&&ae.stateNode.implementation===ce.implementation){p(le,ae.sibling),ae=_(ae,ce.children||[]),ae.return=le,le=ae;break e}else{p(le,ae);break}else c(le,ae);ae=ae.sibling}ae=pg(ce,le.mode,Le),ae.return=le,le=ae}return z(le);case G:return it=ce._init,xn(le,ae,it(ce._payload),Le)}if(De(ce))return Je(le,ae,ce,Le);if(U(ce))return Ze(le,ae,ce,Le);zu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ae!==null&&ae.tag===6?(p(le,ae.sibling),ae=_(ae,ce),ae.return=le,le=ae):(p(le,ae),ae=hg(ce,le.mode,Le),ae.return=le,le=ae),z(le)):p(le,ae)}return xn}var Ui=_w(!0),$w=_w(!1),Fu=Ho(null),Uu=null,Wi=null,Np=null;function Sp(){Np=Wi=Uu=null}function Cp(a){var c=Fu.current;Xt(Fu),a._currentValue=c}function _p(a,c,p){for(;a!==null;){var w=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,w!==null&&(w.childLanes|=c)):w!==null&&(w.childLanes&c)!==c&&(w.childLanes|=c),a===p)break;a=a.return}}function Hi(a,c){Uu=a,Np=Wi=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(js=!0),a.firstContext=null)}function Js(a){var c=a._currentValue;if(Np!==a)if(a={context:a,memoizedValue:c,next:null},Wi===null){if(Uu===null)throw Error(s(308));Wi=a,Uu.dependencies={lanes:0,firstContext:a}}else Wi=Wi.next=a;return c}var Ia=null;function $p(a){Ia===null?Ia=[a]:Ia.push(a)}function Ew(a,c,p,w){var _=c.interleaved;return _===null?(p.next=p,$p(c)):(p.next=_.next,_.next=p),c.interleaved=p,uo(a,w)}function uo(a,c){a.lanes|=c;var p=a.alternate;for(p!==null&&(p.lanes|=c),p=a,a=a.return;a!==null;)a.childLanes|=c,p=a.alternate,p!==null&&(p.childLanes|=c),p=a,a=a.return;return p.tag===3?p.stateNode:null}var Go=!1;function Ep(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Tw(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function fo(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Ko(a,c,p){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(Ot&2)!==0){var _=w.pending;return _===null?c.next=c:(c.next=_.next,_.next=c),w.pending=c,uo(a,p)}return _=w.interleaved,_===null?(c.next=c,$p(w)):(c.next=_.next,_.next=c),w.interleaved=c,uo(a,p)}function Wu(a,c,p){if(c=c.updateQueue,c!==null&&(c=c.shared,(p&4194240)!==0)){var w=c.lanes;w&=a.pendingLanes,p|=w,c.lanes=p,Si(a,p)}}function Rw(a,c){var p=a.updateQueue,w=a.alternate;if(w!==null&&(w=w.updateQueue,p===w)){var _=null,R=null;if(p=p.firstBaseUpdate,p!==null){do{var z={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};R===null?_=R=z:R=R.next=z,p=p.next}while(p!==null);R===null?_=R=c:R=R.next=c}else _=R=c;p={baseState:w.baseState,firstBaseUpdate:_,lastBaseUpdate:R,shared:w.shared,effects:w.effects},a.updateQueue=p;return}a=p.lastBaseUpdate,a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=c}function Hu(a,c,p,w){var _=a.updateQueue;Go=!1;var R=_.firstBaseUpdate,z=_.lastBaseUpdate,X=_.shared.pending;if(X!==null){_.shared.pending=null;var ne=X,me=ne.next;ne.next=null,z===null?R=me:z.next=me,z=ne;var Ce=a.alternate;Ce!==null&&(Ce=Ce.updateQueue,X=Ce.lastBaseUpdate,X!==z&&(X===null?Ce.firstBaseUpdate=me:X.next=me,Ce.lastBaseUpdate=ne))}if(R!==null){var $e=_.baseState;z=0,Ce=me=ne=null,X=R;do{var Se=X.lane,Ke=X.eventTime;if((w&Se)===Se){Ce!==null&&(Ce=Ce.next={eventTime:Ke,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Je=a,Ze=X;switch(Se=c,Ke=p,Ze.tag){case 1:if(Je=Ze.payload,typeof Je=="function"){$e=Je.call(Ke,$e,Se);break e}$e=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Ze.payload,Se=typeof Je=="function"?Je.call(Ke,$e,Se):Je,Se==null)break e;$e=Q({},$e,Se);break e;case 2:Go=!0}}X.callback!==null&&X.lane!==0&&(a.flags|=64,Se=_.effects,Se===null?_.effects=[X]:Se.push(X))}else Ke={eventTime:Ke,lane:Se,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Ce===null?(me=Ce=Ke,ne=$e):Ce=Ce.next=Ke,z|=Se;if(X=X.next,X===null){if(X=_.shared.pending,X===null)break;Se=X,X=Se.next,Se.next=null,_.lastBaseUpdate=Se,_.shared.pending=null}}while(!0);if(Ce===null&&(ne=$e),_.baseState=ne,_.firstBaseUpdate=me,_.lastBaseUpdate=Ce,c=_.shared.interleaved,c!==null){_=c;do z|=_.lane,_=_.next;while(_!==c)}else R===null&&(_.shared.lanes=0);za|=z,a.lanes=z,a.memoizedState=$e}}function Aw(a,c,p){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var w=a[c],_=w.callback;if(_!==null){if(w.callback=null,w=p,typeof _!="function")throw Error(s(191,_));_.call(w)}}}var kc={},Pr=Ho(kc),Nc=Ho(kc),Sc=Ho(kc);function Pa(a){if(a===kc)throw Error(s(174));return a}function Tp(a,c){switch(Kt(Sc,c),Kt(Nc,a),Kt(Pr,kc),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:jt(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=jt(c,a)}Xt(Pr),Kt(Pr,c)}function Bi(){Xt(Pr),Xt(Nc),Xt(Sc)}function Ow(a){Pa(Sc.current);var c=Pa(Pr.current),p=jt(c,a.type);c!==p&&(Kt(Nc,a),Kt(Pr,p))}function Rp(a){Nc.current===a&&(Xt(Pr),Xt(Nc))}var an=Ho(0);function Bu(a){for(var c=a;c!==null;){if(c.tag===13){var p=c.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Ap=[];function Op(){for(var a=0;a<Ap.length;a++)Ap[a]._workInProgressVersionPrimary=null;Ap.length=0}var qu=S.ReactCurrentDispatcher,Lp=S.ReactCurrentBatchConfig,Da=0,ln=null,En=null,Pn=null,Gu=!1,Cc=!1,_c=0,oR=0;function ts(){throw Error(s(321))}function Mp(a,c){if(c===null)return!1;for(var p=0;p<c.length&&p<a.length;p++)if(!wr(a[p],c[p]))return!1;return!0}function Ip(a,c,p,w,_,R){if(Da=R,ln=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,qu.current=a===null||a.memoizedState===null?cR:dR,a=p(w,_),Cc){R=0;do{if(Cc=!1,_c=0,25<=R)throw Error(s(301));R+=1,Pn=En=null,c.updateQueue=null,qu.current=uR,a=p(w,_)}while(Cc)}if(qu.current=Yu,c=En!==null&&En.next!==null,Da=0,Pn=En=ln=null,Gu=!1,c)throw Error(s(300));return a}function Pp(){var a=_c!==0;return _c=0,a}function Dr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pn===null?ln.memoizedState=Pn=a:Pn=Pn.next=a,Pn}function Xs(){if(En===null){var a=ln.alternate;a=a!==null?a.memoizedState:null}else a=En.next;var c=Pn===null?ln.memoizedState:Pn.next;if(c!==null)Pn=c,En=a;else{if(a===null)throw Error(s(310));En=a,a={memoizedState:En.memoizedState,baseState:En.baseState,baseQueue:En.baseQueue,queue:En.queue,next:null},Pn===null?ln.memoizedState=Pn=a:Pn=Pn.next=a}return Pn}function $c(a,c){return typeof c=="function"?c(a):c}function Dp(a){var c=Xs(),p=c.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=a;var w=En,_=w.baseQueue,R=p.pending;if(R!==null){if(_!==null){var z=_.next;_.next=R.next,R.next=z}w.baseQueue=_=R,p.pending=null}if(_!==null){R=_.next,w=w.baseState;var X=z=null,ne=null,me=R;do{var Ce=me.lane;if((Da&Ce)===Ce)ne!==null&&(ne=ne.next={lane:0,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),w=me.hasEagerState?me.eagerState:a(w,me.action);else{var $e={lane:Ce,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null};ne===null?(X=ne=$e,z=w):ne=ne.next=$e,ln.lanes|=Ce,za|=Ce}me=me.next}while(me!==null&&me!==R);ne===null?z=w:ne.next=X,wr(w,c.memoizedState)||(js=!0),c.memoizedState=w,c.baseState=z,c.baseQueue=ne,p.lastRenderedState=w}if(a=p.interleaved,a!==null){_=a;do R=_.lane,ln.lanes|=R,za|=R,_=_.next;while(_!==a)}else _===null&&(p.lanes=0);return[c.memoizedState,p.dispatch]}function zp(a){var c=Xs(),p=c.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=a;var w=p.dispatch,_=p.pending,R=c.memoizedState;if(_!==null){p.pending=null;var z=_=_.next;do R=a(R,z.action),z=z.next;while(z!==_);wr(R,c.memoizedState)||(js=!0),c.memoizedState=R,c.baseQueue===null&&(c.baseState=R),p.lastRenderedState=R}return[R,w]}function Lw(){}function Mw(a,c){var p=ln,w=Xs(),_=c(),R=!wr(w.memoizedState,_);if(R&&(w.memoizedState=_,js=!0),w=w.queue,Fp(Dw.bind(null,p,w,a),[a]),w.getSnapshot!==c||R||Pn!==null&&Pn.memoizedState.tag&1){if(p.flags|=2048,Ec(9,Pw.bind(null,p,w,_,c),void 0,null),Dn===null)throw Error(s(349));(Da&30)!==0||Iw(p,c,_)}return _}function Iw(a,c,p){a.flags|=16384,a={getSnapshot:c,value:p},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.stores=[a]):(p=c.stores,p===null?c.stores=[a]:p.push(a))}function Pw(a,c,p,w){c.value=p,c.getSnapshot=w,zw(c)&&Fw(a)}function Dw(a,c,p){return p(function(){zw(c)&&Fw(a)})}function zw(a){var c=a.getSnapshot;a=a.value;try{var p=c();return!wr(a,p)}catch{return!0}}function Fw(a){var c=uo(a,1);c!==null&&Cr(c,a,1,-1)}function Uw(a){var c=Dr();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:$c,lastRenderedState:a},c.queue=a,a=a.dispatch=lR.bind(null,ln,a),[c.memoizedState,a]}function Ec(a,c,p,w){return a={tag:a,create:c,destroy:p,deps:w,next:null},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.lastEffect=a.next=a):(p=c.lastEffect,p===null?c.lastEffect=a.next=a:(w=p.next,p.next=a,a.next=w,c.lastEffect=a)),a}function Ww(){return Xs().memoizedState}function Ku(a,c,p,w){var _=Dr();ln.flags|=a,_.memoizedState=Ec(1|c,p,void 0,w===void 0?null:w)}function Vu(a,c,p,w){var _=Xs();w=w===void 0?null:w;var R=void 0;if(En!==null){var z=En.memoizedState;if(R=z.destroy,w!==null&&Mp(w,z.deps)){_.memoizedState=Ec(c,p,R,w);return}}ln.flags|=a,_.memoizedState=Ec(1|c,p,R,w)}function Hw(a,c){return Ku(8390656,8,a,c)}function Fp(a,c){return Vu(2048,8,a,c)}function Bw(a,c){return Vu(4,2,a,c)}function qw(a,c){return Vu(4,4,a,c)}function Gw(a,c){if(typeof c=="function")return a=a(),c(a),function(){c(null)};if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function Kw(a,c,p){return p=p!=null?p.concat([a]):null,Vu(4,4,Gw.bind(null,c,a),p)}function Up(){}function Vw(a,c){var p=Xs();c=c===void 0?null:c;var w=p.memoizedState;return w!==null&&c!==null&&Mp(c,w[1])?w[0]:(p.memoizedState=[a,c],a)}function Yw(a,c){var p=Xs();c=c===void 0?null:c;var w=p.memoizedState;return w!==null&&c!==null&&Mp(c,w[1])?w[0]:(a=a(),p.memoizedState=[a,c],a)}function Qw(a,c,p){return(Da&21)===0?(a.baseState&&(a.baseState=!1,js=!0),a.memoizedState=p):(wr(p,c)||(p=Zl(),ln.lanes|=p,za|=p,a.baseState=!0),c)}function aR(a,c){var p=It;It=p!==0&&4>p?p:4,a(!0);var w=Lp.transition;Lp.transition={};try{a(!1),c()}finally{It=p,Lp.transition=w}}function Jw(){return Xs().memoizedState}function iR(a,c,p){var w=Jo(a);if(p={lane:w,action:p,hasEagerState:!1,eagerState:null,next:null},Xw(a))Zw(c,p);else if(p=Ew(a,c,p,w),p!==null){var _=us();Cr(p,a,w,_),ej(p,c,w)}}function lR(a,c,p){var w=Jo(a),_={lane:w,action:p,hasEagerState:!1,eagerState:null,next:null};if(Xw(a))Zw(c,_);else{var R=a.alternate;if(a.lanes===0&&(R===null||R.lanes===0)&&(R=c.lastRenderedReducer,R!==null))try{var z=c.lastRenderedState,X=R(z,p);if(_.hasEagerState=!0,_.eagerState=X,wr(X,z)){var ne=c.interleaved;ne===null?(_.next=_,$p(c)):(_.next=ne.next,ne.next=_),c.interleaved=_;return}}catch{}finally{}p=Ew(a,c,_,w),p!==null&&(_=us(),Cr(p,a,w,_),ej(p,c,w))}}function Xw(a){var c=a.alternate;return a===ln||c!==null&&c===ln}function Zw(a,c){Cc=Gu=!0;var p=a.pending;p===null?c.next=c:(c.next=p.next,p.next=c),a.pending=c}function ej(a,c,p){if((p&4194240)!==0){var w=c.lanes;w&=a.pendingLanes,p|=w,c.lanes=p,Si(a,p)}}var Yu={readContext:Js,useCallback:ts,useContext:ts,useEffect:ts,useImperativeHandle:ts,useInsertionEffect:ts,useLayoutEffect:ts,useMemo:ts,useReducer:ts,useRef:ts,useState:ts,useDebugValue:ts,useDeferredValue:ts,useTransition:ts,useMutableSource:ts,useSyncExternalStore:ts,useId:ts,unstable_isNewReconciler:!1},cR={readContext:Js,useCallback:function(a,c){return Dr().memoizedState=[a,c===void 0?null:c],a},useContext:Js,useEffect:Hw,useImperativeHandle:function(a,c,p){return p=p!=null?p.concat([a]):null,Ku(4194308,4,Gw.bind(null,c,a),p)},useLayoutEffect:function(a,c){return Ku(4194308,4,a,c)},useInsertionEffect:function(a,c){return Ku(4,2,a,c)},useMemo:function(a,c){var p=Dr();return c=c===void 0?null:c,a=a(),p.memoizedState=[a,c],a},useReducer:function(a,c,p){var w=Dr();return c=p!==void 0?p(c):c,w.memoizedState=w.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},w.queue=a,a=a.dispatch=iR.bind(null,ln,a),[w.memoizedState,a]},useRef:function(a){var c=Dr();return a={current:a},c.memoizedState=a},useState:Uw,useDebugValue:Up,useDeferredValue:function(a){return Dr().memoizedState=a},useTransition:function(){var a=Uw(!1),c=a[0];return a=aR.bind(null,a[1]),Dr().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,p){var w=ln,_=Dr();if(tn){if(p===void 0)throw Error(s(407));p=p()}else{if(p=c(),Dn===null)throw Error(s(349));(Da&30)!==0||Iw(w,c,p)}_.memoizedState=p;var R={value:p,getSnapshot:c};return _.queue=R,Hw(Dw.bind(null,w,R,a),[a]),w.flags|=2048,Ec(9,Pw.bind(null,w,R,p,c),void 0,null),p},useId:function(){var a=Dr(),c=Dn.identifierPrefix;if(tn){var p=co,w=lo;p=(w&~(1<<32-Zn(w)-1)).toString(32)+p,c=":"+c+"R"+p,p=_c++,0<p&&(c+="H"+p.toString(32)),c+=":"}else p=oR++,c=":"+c+"r"+p.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},dR={readContext:Js,useCallback:Vw,useContext:Js,useEffect:Fp,useImperativeHandle:Kw,useInsertionEffect:Bw,useLayoutEffect:qw,useMemo:Yw,useReducer:Dp,useRef:Ww,useState:function(){return Dp($c)},useDebugValue:Up,useDeferredValue:function(a){var c=Xs();return Qw(c,En.memoizedState,a)},useTransition:function(){var a=Dp($c)[0],c=Xs().memoizedState;return[a,c]},useMutableSource:Lw,useSyncExternalStore:Mw,useId:Jw,unstable_isNewReconciler:!1},uR={readContext:Js,useCallback:Vw,useContext:Js,useEffect:Fp,useImperativeHandle:Kw,useInsertionEffect:Bw,useLayoutEffect:qw,useMemo:Yw,useReducer:zp,useRef:Ww,useState:function(){return zp($c)},useDebugValue:Up,useDeferredValue:function(a){var c=Xs();return En===null?c.memoizedState=a:Qw(c,En.memoizedState,a)},useTransition:function(){var a=zp($c)[0],c=Xs().memoizedState;return[a,c]},useMutableSource:Lw,useSyncExternalStore:Mw,useId:Jw,unstable_isNewReconciler:!1};function kr(a,c){if(a&&a.defaultProps){c=Q({},c),a=a.defaultProps;for(var p in a)c[p]===void 0&&(c[p]=a[p]);return c}return c}function Wp(a,c,p,w){c=a.memoizedState,p=p(w,c),p=p==null?c:Q({},c,p),a.memoizedState=p,a.lanes===0&&(a.updateQueue.baseState=p)}var Qu={isMounted:function(a){return(a=a._reactInternals)?Tt(a)===a:!1},enqueueSetState:function(a,c,p){a=a._reactInternals;var w=us(),_=Jo(a),R=fo(w,_);R.payload=c,p!=null&&(R.callback=p),c=Ko(a,R,_),c!==null&&(Cr(c,a,_,w),Wu(c,a,_))},enqueueReplaceState:function(a,c,p){a=a._reactInternals;var w=us(),_=Jo(a),R=fo(w,_);R.tag=1,R.payload=c,p!=null&&(R.callback=p),c=Ko(a,R,_),c!==null&&(Cr(c,a,_,w),Wu(c,a,_))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var p=us(),w=Jo(a),_=fo(p,w);_.tag=2,c!=null&&(_.callback=c),c=Ko(a,_,w),c!==null&&(Cr(c,a,w,p),Wu(c,a,w))}};function tj(a,c,p,w,_,R,z){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(w,R,z):c.prototype&&c.prototype.isPureReactComponent?!pc(p,w)||!pc(_,R):!0}function nj(a,c,p){var w=!1,_=Bo,R=c.contextType;return typeof R=="object"&&R!==null?R=Js(R):(_=ws(c)?Oa:es.current,w=c.contextTypes,R=(w=w!=null)?Pi(a,_):Bo),c=new c(p,R),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Qu,a.stateNode=c,c._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=_,a.__reactInternalMemoizedMaskedChildContext=R),c}function sj(a,c,p,w){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(p,w),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(p,w),c.state!==a&&Qu.enqueueReplaceState(c,c.state,null)}function Hp(a,c,p,w){var _=a.stateNode;_.props=p,_.state=a.memoizedState,_.refs={},Ep(a);var R=c.contextType;typeof R=="object"&&R!==null?_.context=Js(R):(R=ws(c)?Oa:es.current,_.context=Pi(a,R)),_.state=a.memoizedState,R=c.getDerivedStateFromProps,typeof R=="function"&&(Wp(a,c,R,p),_.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(c=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),c!==_.state&&Qu.enqueueReplaceState(_,_.state,null),Hu(a,p,_,w),_.state=a.memoizedState),typeof _.componentDidMount=="function"&&(a.flags|=4194308)}function qi(a,c){try{var p="",w=c;do p+=se(w),w=w.return;while(w);var _=p}catch(R){_=`
|
|
39
|
-
Error generating stack: `+R.message+`
|
|
40
|
-
`+R.stack}return{value:a,source:c,stack:_,digest:null}}function Bp(a,c,p){return{value:a,source:null,stack:p??null,digest:c??null}}function qp(a,c){try{console.error(c.value)}catch(p){setTimeout(function(){throw p})}}var fR=typeof WeakMap=="function"?WeakMap:Map;function rj(a,c,p){p=fo(-1,p),p.tag=3,p.payload={element:null};var w=c.value;return p.callback=function(){sf||(sf=!0,ag=w),qp(a,c)},p}function oj(a,c,p){p=fo(-1,p),p.tag=3;var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var _=c.value;p.payload=function(){return w(_)},p.callback=function(){qp(a,c)}}var R=a.stateNode;return R!==null&&typeof R.componentDidCatch=="function"&&(p.callback=function(){qp(a,c),typeof w!="function"&&(Yo===null?Yo=new Set([this]):Yo.add(this));var z=c.stack;this.componentDidCatch(c.value,{componentStack:z!==null?z:""})}),p}function aj(a,c,p){var w=a.pingCache;if(w===null){w=a.pingCache=new fR;var _=new Set;w.set(c,_)}else _=w.get(c),_===void 0&&(_=new Set,w.set(c,_));_.has(p)||(_.add(p),a=CR.bind(null,a,c,p),c.then(a,a))}function ij(a){do{var c;if((c=a.tag===13)&&(c=a.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return a;a=a.return}while(a!==null);return null}function lj(a,c,p,w,_){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(c=fo(-1,1),c.tag=2,Ko(p,c,1))),p.lanes|=1),a):(a.flags|=65536,a.lanes=_,a)}var mR=S.ReactCurrentOwner,js=!1;function ds(a,c,p,w){c.child=a===null?$w(c,null,p,w):Ui(c,a.child,p,w)}function cj(a,c,p,w,_){p=p.render;var R=c.ref;return Hi(c,_),w=Ip(a,c,p,w,R,_),p=Pp(),a!==null&&!js?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~_,mo(a,c,_)):(tn&&p&&vp(c),c.flags|=1,ds(a,c,w,_),c.child)}function dj(a,c,p,w,_){if(a===null){var R=p.type;return typeof R=="function"&&!mg(R)&&R.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(c.tag=15,c.type=R,uj(a,c,R,w,_)):(a=df(p.type,null,w,c,c.mode,_),a.ref=c.ref,a.return=c,c.child=a)}if(R=a.child,(a.lanes&_)===0){var z=R.memoizedProps;if(p=p.compare,p=p!==null?p:pc,p(z,w)&&a.ref===c.ref)return mo(a,c,_)}return c.flags|=1,a=Zo(R,w),a.ref=c.ref,a.return=c,c.child=a}function uj(a,c,p,w,_){if(a!==null){var R=a.memoizedProps;if(pc(R,w)&&a.ref===c.ref)if(js=!1,c.pendingProps=w=R,(a.lanes&_)!==0)(a.flags&131072)!==0&&(js=!0);else return c.lanes=a.lanes,mo(a,c,_)}return Gp(a,c,p,w,_)}function fj(a,c,p){var w=c.pendingProps,_=w.children,R=a!==null?a.memoizedState:null;if(w.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Kt(Ki,Ps),Ps|=p;else{if((p&1073741824)===0)return a=R!==null?R.baseLanes|p:p,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Kt(Ki,Ps),Ps|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=R!==null?R.baseLanes:p,Kt(Ki,Ps),Ps|=w}else R!==null?(w=R.baseLanes|p,c.memoizedState=null):w=p,Kt(Ki,Ps),Ps|=w;return ds(a,c,_,p),c.child}function mj(a,c){var p=c.ref;(a===null&&p!==null||a!==null&&a.ref!==p)&&(c.flags|=512,c.flags|=2097152)}function Gp(a,c,p,w,_){var R=ws(p)?Oa:es.current;return R=Pi(c,R),Hi(c,_),p=Ip(a,c,p,w,R,_),w=Pp(),a!==null&&!js?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~_,mo(a,c,_)):(tn&&w&&vp(c),c.flags|=1,ds(a,c,p,_),c.child)}function hj(a,c,p,w,_){if(ws(p)){var R=!0;Lu(c)}else R=!1;if(Hi(c,_),c.stateNode===null)Xu(a,c),nj(c,p,w),Hp(c,p,w,_),w=!0;else if(a===null){var z=c.stateNode,X=c.memoizedProps;z.props=X;var ne=z.context,me=p.contextType;typeof me=="object"&&me!==null?me=Js(me):(me=ws(p)?Oa:es.current,me=Pi(c,me));var Ce=p.getDerivedStateFromProps,$e=typeof Ce=="function"||typeof z.getSnapshotBeforeUpdate=="function";$e||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(X!==w||ne!==me)&&sj(c,z,w,me),Go=!1;var Se=c.memoizedState;z.state=Se,Hu(c,w,z,_),ne=c.memoizedState,X!==w||Se!==ne||ys.current||Go?(typeof Ce=="function"&&(Wp(c,p,Ce,w),ne=c.memoizedState),(X=Go||tj(c,p,X,w,Se,ne,me))?($e||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(c.flags|=4194308)):(typeof z.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=w,c.memoizedState=ne),z.props=w,z.state=ne,z.context=me,w=X):(typeof z.componentDidMount=="function"&&(c.flags|=4194308),w=!1)}else{z=c.stateNode,Tw(a,c),X=c.memoizedProps,me=c.type===c.elementType?X:kr(c.type,X),z.props=me,$e=c.pendingProps,Se=z.context,ne=p.contextType,typeof ne=="object"&&ne!==null?ne=Js(ne):(ne=ws(p)?Oa:es.current,ne=Pi(c,ne));var Ke=p.getDerivedStateFromProps;(Ce=typeof Ke=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(X!==$e||Se!==ne)&&sj(c,z,w,ne),Go=!1,Se=c.memoizedState,z.state=Se,Hu(c,w,z,_);var Je=c.memoizedState;X!==$e||Se!==Je||ys.current||Go?(typeof Ke=="function"&&(Wp(c,p,Ke,w),Je=c.memoizedState),(me=Go||tj(c,p,me,w,Se,Je,ne)||!1)?(Ce||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(w,Je,ne),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(w,Je,ne)),typeof z.componentDidUpdate=="function"&&(c.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof z.componentDidUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(c.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(c.flags|=1024),c.memoizedProps=w,c.memoizedState=Je),z.props=w,z.state=Je,z.context=ne,w=me):(typeof z.componentDidUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(c.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(c.flags|=1024),w=!1)}return Kp(a,c,p,w,R,_)}function Kp(a,c,p,w,_,R){mj(a,c);var z=(c.flags&128)!==0;if(!w&&!z)return _&&vw(c,p,!1),mo(a,c,R);w=c.stateNode,mR.current=c;var X=z&&typeof p.getDerivedStateFromError!="function"?null:w.render();return c.flags|=1,a!==null&&z?(c.child=Ui(c,a.child,null,R),c.child=Ui(c,null,X,R)):ds(a,c,X,R),c.memoizedState=w.state,_&&vw(c,p,!0),c.child}function pj(a){var c=a.stateNode;c.pendingContext?xw(a,c.pendingContext,c.pendingContext!==c.context):c.context&&xw(a,c.context,!1),Tp(a,c.containerInfo)}function gj(a,c,p,w,_){return Fi(),kp(_),c.flags|=256,ds(a,c,p,w),c.child}var Vp={dehydrated:null,treeContext:null,retryLane:0};function Yp(a){return{baseLanes:a,cachePool:null,transitions:null}}function xj(a,c,p){var w=c.pendingProps,_=an.current,R=!1,z=(c.flags&128)!==0,X;if((X=z)||(X=a!==null&&a.memoizedState===null?!1:(_&2)!==0),X?(R=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(_|=1),Kt(an,_&1),a===null)return jp(c),a=c.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((c.mode&1)===0?c.lanes=1:a.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(z=w.children,a=w.fallback,R?(w=c.mode,R=c.child,z={mode:"hidden",children:z},(w&1)===0&&R!==null?(R.childLanes=0,R.pendingProps=z):R=uf(z,w,0,null),a=Ha(a,w,p,null),R.return=c,a.return=c,R.sibling=a,c.child=R,c.child.memoizedState=Yp(p),c.memoizedState=Vp,a):Qp(c,z));if(_=a.memoizedState,_!==null&&(X=_.dehydrated,X!==null))return hR(a,c,z,w,X,_,p);if(R){R=w.fallback,z=c.mode,_=a.child,X=_.sibling;var ne={mode:"hidden",children:w.children};return(z&1)===0&&c.child!==_?(w=c.child,w.childLanes=0,w.pendingProps=ne,c.deletions=null):(w=Zo(_,ne),w.subtreeFlags=_.subtreeFlags&14680064),X!==null?R=Zo(X,R):(R=Ha(R,z,p,null),R.flags|=2),R.return=c,w.return=c,w.sibling=R,c.child=w,w=R,R=c.child,z=a.child.memoizedState,z=z===null?Yp(p):{baseLanes:z.baseLanes|p,cachePool:null,transitions:z.transitions},R.memoizedState=z,R.childLanes=a.childLanes&~p,c.memoizedState=Vp,w}return R=a.child,a=R.sibling,w=Zo(R,{mode:"visible",children:w.children}),(c.mode&1)===0&&(w.lanes=p),w.return=c,w.sibling=null,a!==null&&(p=c.deletions,p===null?(c.deletions=[a],c.flags|=16):p.push(a)),c.child=w,c.memoizedState=null,w}function Qp(a,c){return c=uf({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function Ju(a,c,p,w){return w!==null&&kp(w),Ui(c,a.child,null,p),a=Qp(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function hR(a,c,p,w,_,R,z){if(p)return c.flags&256?(c.flags&=-257,w=Bp(Error(s(422))),Ju(a,c,z,w)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):(R=w.fallback,_=c.mode,w=uf({mode:"visible",children:w.children},_,0,null),R=Ha(R,_,z,null),R.flags|=2,w.return=c,R.return=c,w.sibling=R,c.child=w,(c.mode&1)!==0&&Ui(c,a.child,null,z),c.child.memoizedState=Yp(z),c.memoizedState=Vp,R);if((c.mode&1)===0)return Ju(a,c,z,null);if(_.data==="$!"){if(w=_.nextSibling&&_.nextSibling.dataset,w)var X=w.dgst;return w=X,R=Error(s(419)),w=Bp(R,w,void 0),Ju(a,c,z,w)}if(X=(z&a.childLanes)!==0,js||X){if(w=Dn,w!==null){switch(z&-z){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(w.suspendedLanes|z))!==0?0:_,_!==0&&_!==R.retryLane&&(R.retryLane=_,uo(a,_),Cr(w,a,_,-1))}return fg(),w=Bp(Error(s(421))),Ju(a,c,z,w)}return _.data==="$?"?(c.flags|=128,c.child=a.child,c=_R.bind(null,a),_._reactRetry=c,null):(a=R.treeContext,Is=Wo(_.nextSibling),Ms=c,tn=!0,jr=null,a!==null&&(Ys[Qs++]=lo,Ys[Qs++]=co,Ys[Qs++]=La,lo=a.id,co=a.overflow,La=c),c=Qp(c,w.children),c.flags|=4096,c)}function bj(a,c,p){a.lanes|=c;var w=a.alternate;w!==null&&(w.lanes|=c),_p(a.return,c,p)}function Jp(a,c,p,w,_){var R=a.memoizedState;R===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:w,tail:p,tailMode:_}:(R.isBackwards=c,R.rendering=null,R.renderingStartTime=0,R.last=w,R.tail=p,R.tailMode=_)}function vj(a,c,p){var w=c.pendingProps,_=w.revealOrder,R=w.tail;if(ds(a,c,w.children,p),w=an.current,(w&2)!==0)w=w&1|2,c.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&bj(a,p,c);else if(a.tag===19)bj(a,p,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}w&=1}if(Kt(an,w),(c.mode&1)===0)c.memoizedState=null;else switch(_){case"forwards":for(p=c.child,_=null;p!==null;)a=p.alternate,a!==null&&Bu(a)===null&&(_=p),p=p.sibling;p=_,p===null?(_=c.child,c.child=null):(_=p.sibling,p.sibling=null),Jp(c,!1,_,p,R);break;case"backwards":for(p=null,_=c.child,c.child=null;_!==null;){if(a=_.alternate,a!==null&&Bu(a)===null){c.child=_;break}a=_.sibling,_.sibling=p,p=_,_=a}Jp(c,!0,p,null,R);break;case"together":Jp(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Xu(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function mo(a,c,p){if(a!==null&&(c.dependencies=a.dependencies),za|=c.lanes,(p&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(s(153));if(c.child!==null){for(a=c.child,p=Zo(a,a.pendingProps),c.child=p,p.return=c;a.sibling!==null;)a=a.sibling,p=p.sibling=Zo(a,a.pendingProps),p.return=c;p.sibling=null}return c.child}function pR(a,c,p){switch(c.tag){case 3:pj(c),Fi();break;case 5:Ow(c);break;case 1:ws(c.type)&&Lu(c);break;case 4:Tp(c,c.stateNode.containerInfo);break;case 10:var w=c.type._context,_=c.memoizedProps.value;Kt(Fu,w._currentValue),w._currentValue=_;break;case 13:if(w=c.memoizedState,w!==null)return w.dehydrated!==null?(Kt(an,an.current&1),c.flags|=128,null):(p&c.child.childLanes)!==0?xj(a,c,p):(Kt(an,an.current&1),a=mo(a,c,p),a!==null?a.sibling:null);Kt(an,an.current&1);break;case 19:if(w=(p&c.childLanes)!==0,(a.flags&128)!==0){if(w)return vj(a,c,p);c.flags|=128}if(_=c.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Kt(an,an.current),w)break;return null;case 22:case 23:return c.lanes=0,fj(a,c,p)}return mo(a,c,p)}var yj,Xp,wj,jj;yj=function(a,c){for(var p=c.child;p!==null;){if(p.tag===5||p.tag===6)a.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},Xp=function(){},wj=function(a,c,p,w){var _=a.memoizedProps;if(_!==w){a=c.stateNode,Pa(Pr.current);var R=null;switch(p){case"input":_=ue(a,_),w=ue(a,w),R=[];break;case"select":_=Q({},_,{value:void 0}),w=Q({},w,{value:void 0}),R=[];break;case"textarea":_=Ie(a,_),w=Ie(a,w),R=[];break;default:typeof _.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=Ru)}Lt(p,w);var z;p=null;for(me in _)if(!w.hasOwnProperty(me)&&_.hasOwnProperty(me)&&_[me]!=null)if(me==="style"){var X=_[me];for(z in X)X.hasOwnProperty(z)&&(p||(p={}),p[z]="")}else me!=="dangerouslySetInnerHTML"&&me!=="children"&&me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&me!=="autoFocus"&&(o.hasOwnProperty(me)?R||(R=[]):(R=R||[]).push(me,null));for(me in w){var ne=w[me];if(X=_!=null?_[me]:void 0,w.hasOwnProperty(me)&&ne!==X&&(ne!=null||X!=null))if(me==="style")if(X){for(z in X)!X.hasOwnProperty(z)||ne&&ne.hasOwnProperty(z)||(p||(p={}),p[z]="");for(z in ne)ne.hasOwnProperty(z)&&X[z]!==ne[z]&&(p||(p={}),p[z]=ne[z])}else p||(R||(R=[]),R.push(me,p)),p=ne;else me==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,X=X?X.__html:void 0,ne!=null&&X!==ne&&(R=R||[]).push(me,ne)):me==="children"?typeof ne!="string"&&typeof ne!="number"||(R=R||[]).push(me,""+ne):me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&(o.hasOwnProperty(me)?(ne!=null&&me==="onScroll"&&Jt("scroll",a),R||X===ne||(R=[])):(R=R||[]).push(me,ne))}p&&(R=R||[]).push("style",p);var me=R;(c.updateQueue=me)&&(c.flags|=4)}},jj=function(a,c,p,w){p!==w&&(c.flags|=4)};function Tc(a,c){if(!tn)switch(a.tailMode){case"hidden":c=a.tail;for(var p=null;c!==null;)c.alternate!==null&&(p=c),c=c.sibling;p===null?a.tail=null:p.sibling=null;break;case"collapsed":p=a.tail;for(var w=null;p!==null;)p.alternate!==null&&(w=p),p=p.sibling;w===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:w.sibling=null}}function ns(a){var c=a.alternate!==null&&a.alternate.child===a.child,p=0,w=0;if(c)for(var _=a.child;_!==null;)p|=_.lanes|_.childLanes,w|=_.subtreeFlags&14680064,w|=_.flags&14680064,_.return=a,_=_.sibling;else for(_=a.child;_!==null;)p|=_.lanes|_.childLanes,w|=_.subtreeFlags,w|=_.flags,_.return=a,_=_.sibling;return a.subtreeFlags|=w,a.childLanes=p,c}function gR(a,c,p){var w=c.pendingProps;switch(yp(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ns(c),null;case 1:return ws(c.type)&&Ou(),ns(c),null;case 3:return w=c.stateNode,Bi(),Xt(ys),Xt(es),Op(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(Du(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,jr!==null&&(cg(jr),jr=null))),Xp(a,c),ns(c),null;case 5:Rp(c);var _=Pa(Sc.current);if(p=c.type,a!==null&&c.stateNode!=null)wj(a,c,p,w,_),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!w){if(c.stateNode===null)throw Error(s(166));return ns(c),null}if(a=Pa(Pr.current),Du(c)){w=c.stateNode,p=c.type;var R=c.memoizedProps;switch(w[Ir]=c,w[yc]=R,a=(c.mode&1)!==0,p){case"dialog":Jt("cancel",w),Jt("close",w);break;case"iframe":case"object":case"embed":Jt("load",w);break;case"video":case"audio":for(_=0;_<xc.length;_++)Jt(xc[_],w);break;case"source":Jt("error",w);break;case"img":case"image":case"link":Jt("error",w),Jt("load",w);break;case"details":Jt("toggle",w);break;case"input":ge(w,R),Jt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!R.multiple},Jt("invalid",w);break;case"textarea":We(w,R),Jt("invalid",w)}Lt(p,R),_=null;for(var z in R)if(R.hasOwnProperty(z)){var X=R[z];z==="children"?typeof X=="string"?w.textContent!==X&&(R.suppressHydrationWarning!==!0&&Tu(w.textContent,X,a),_=["children",X]):typeof X=="number"&&w.textContent!==""+X&&(R.suppressHydrationWarning!==!0&&Tu(w.textContent,X,a),_=["children",""+X]):o.hasOwnProperty(z)&&X!=null&&z==="onScroll"&&Jt("scroll",w)}switch(p){case"input":ye(w),je(w,R,!0);break;case"textarea":ye(w),ot(w);break;case"select":case"option":break;default:typeof R.onClick=="function"&&(w.onclick=Ru)}w=_,c.updateQueue=w,w!==null&&(c.flags|=4)}else{z=_.nodeType===9?_:_.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=wt(p)),a==="http://www.w3.org/1999/xhtml"?p==="script"?(a=z.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof w.is=="string"?a=z.createElement(p,{is:w.is}):(a=z.createElement(p),p==="select"&&(z=a,w.multiple?z.multiple=!0:w.size&&(z.size=w.size))):a=z.createElementNS(a,p),a[Ir]=c,a[yc]=w,yj(a,c,!1,!1),c.stateNode=a;e:{switch(z=qt(p,w),p){case"dialog":Jt("cancel",a),Jt("close",a),_=w;break;case"iframe":case"object":case"embed":Jt("load",a),_=w;break;case"video":case"audio":for(_=0;_<xc.length;_++)Jt(xc[_],a);_=w;break;case"source":Jt("error",a),_=w;break;case"img":case"image":case"link":Jt("error",a),Jt("load",a),_=w;break;case"details":Jt("toggle",a),_=w;break;case"input":ge(a,w),_=ue(a,w),Jt("invalid",a);break;case"option":_=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},_=Q({},w,{value:void 0}),Jt("invalid",a);break;case"textarea":We(a,w),_=Ie(a,w),Jt("invalid",a);break;default:_=w}Lt(p,_),X=_;for(R in X)if(X.hasOwnProperty(R)){var ne=X[R];R==="style"?et(a,ne):R==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&ze(a,ne)):R==="children"?typeof ne=="string"?(p!=="textarea"||ne!=="")&&st(a,ne):typeof ne=="number"&&st(a,""+ne):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(o.hasOwnProperty(R)?ne!=null&&R==="onScroll"&&Jt("scroll",a):ne!=null&&N(a,R,ne,z))}switch(p){case"input":ye(a),je(a,w,!1);break;case"textarea":ye(a),ot(a);break;case"option":w.value!=null&&a.setAttribute("value",""+he(w.value));break;case"select":a.multiple=!!w.multiple,R=w.value,R!=null?te(a,!!w.multiple,R,!1):w.defaultValue!=null&&te(a,!!w.multiple,w.defaultValue,!0);break;default:typeof _.onClick=="function"&&(a.onclick=Ru)}switch(p){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return ns(c),null;case 6:if(a&&c.stateNode!=null)jj(a,c,a.memoizedProps,w);else{if(typeof w!="string"&&c.stateNode===null)throw Error(s(166));if(p=Pa(Sc.current),Pa(Pr.current),Du(c)){if(w=c.stateNode,p=c.memoizedProps,w[Ir]=c,(R=w.nodeValue!==p)&&(a=Ms,a!==null))switch(a.tag){case 3:Tu(w.nodeValue,p,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Tu(w.nodeValue,p,(a.mode&1)!==0)}R&&(c.flags|=4)}else w=(p.nodeType===9?p:p.ownerDocument).createTextNode(w),w[Ir]=c,c.stateNode=w}return ns(c),null;case 13:if(Xt(an),w=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(tn&&Is!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Sw(),Fi(),c.flags|=98560,R=!1;else if(R=Du(c),w!==null&&w.dehydrated!==null){if(a===null){if(!R)throw Error(s(318));if(R=c.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(s(317));R[Ir]=c}else Fi(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;ns(c),R=!1}else jr!==null&&(cg(jr),jr=null),R=!0;if(!R)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=p,c):(w=w!==null,w!==(a!==null&&a.memoizedState!==null)&&w&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(an.current&1)!==0?Tn===0&&(Tn=3):fg())),c.updateQueue!==null&&(c.flags|=4),ns(c),null);case 4:return Bi(),Xp(a,c),a===null&&bc(c.stateNode.containerInfo),ns(c),null;case 10:return Cp(c.type._context),ns(c),null;case 17:return ws(c.type)&&Ou(),ns(c),null;case 19:if(Xt(an),R=c.memoizedState,R===null)return ns(c),null;if(w=(c.flags&128)!==0,z=R.rendering,z===null)if(w)Tc(R,!1);else{if(Tn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(z=Bu(a),z!==null){for(c.flags|=128,Tc(R,!1),w=z.updateQueue,w!==null&&(c.updateQueue=w,c.flags|=4),c.subtreeFlags=0,w=p,p=c.child;p!==null;)R=p,a=w,R.flags&=14680066,z=R.alternate,z===null?(R.childLanes=0,R.lanes=a,R.child=null,R.subtreeFlags=0,R.memoizedProps=null,R.memoizedState=null,R.updateQueue=null,R.dependencies=null,R.stateNode=null):(R.childLanes=z.childLanes,R.lanes=z.lanes,R.child=z.child,R.subtreeFlags=0,R.deletions=null,R.memoizedProps=z.memoizedProps,R.memoizedState=z.memoizedState,R.updateQueue=z.updateQueue,R.type=z.type,a=z.dependencies,R.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),p=p.sibling;return Kt(an,an.current&1|2),c.child}a=a.sibling}R.tail!==null&&pt()>Vi&&(c.flags|=128,w=!0,Tc(R,!1),c.lanes=4194304)}else{if(!w)if(a=Bu(z),a!==null){if(c.flags|=128,w=!0,p=a.updateQueue,p!==null&&(c.updateQueue=p,c.flags|=4),Tc(R,!0),R.tail===null&&R.tailMode==="hidden"&&!z.alternate&&!tn)return ns(c),null}else 2*pt()-R.renderingStartTime>Vi&&p!==1073741824&&(c.flags|=128,w=!0,Tc(R,!1),c.lanes=4194304);R.isBackwards?(z.sibling=c.child,c.child=z):(p=R.last,p!==null?p.sibling=z:c.child=z,R.last=z)}return R.tail!==null?(c=R.tail,R.rendering=c,R.tail=c.sibling,R.renderingStartTime=pt(),c.sibling=null,p=an.current,Kt(an,w?p&1|2:p&1),c):(ns(c),null);case 22:case 23:return ug(),w=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(c.flags|=8192),w&&(c.mode&1)!==0?(Ps&1073741824)!==0&&(ns(c),c.subtreeFlags&6&&(c.flags|=8192)):ns(c),null;case 24:return null;case 25:return null}throw Error(s(156,c.tag))}function xR(a,c){switch(yp(c),c.tag){case 1:return ws(c.type)&&Ou(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return Bi(),Xt(ys),Xt(es),Op(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return Rp(c),null;case 13:if(Xt(an),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(s(340));Fi()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Xt(an),null;case 4:return Bi(),null;case 10:return Cp(c.type._context),null;case 22:case 23:return ug(),null;case 24:return null;default:return null}}var Zu=!1,ss=!1,bR=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Gi(a,c){var p=a.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(w){un(a,c,w)}else p.current=null}function Zp(a,c,p){try{p()}catch(w){un(a,c,w)}}var kj=!1;function vR(a,c){if(up=As,a=tw(),sp(a)){if("selectionStart"in a)var p={start:a.selectionStart,end:a.selectionEnd};else e:{p=(p=a.ownerDocument)&&p.defaultView||window;var w=p.getSelection&&p.getSelection();if(w&&w.rangeCount!==0){p=w.anchorNode;var _=w.anchorOffset,R=w.focusNode;w=w.focusOffset;try{p.nodeType,R.nodeType}catch{p=null;break e}var z=0,X=-1,ne=-1,me=0,Ce=0,$e=a,Se=null;t:for(;;){for(var Ke;$e!==p||_!==0&&$e.nodeType!==3||(X=z+_),$e!==R||w!==0&&$e.nodeType!==3||(ne=z+w),$e.nodeType===3&&(z+=$e.nodeValue.length),(Ke=$e.firstChild)!==null;)Se=$e,$e=Ke;for(;;){if($e===a)break t;if(Se===p&&++me===_&&(X=z),Se===R&&++Ce===w&&(ne=z),(Ke=$e.nextSibling)!==null)break;$e=Se,Se=$e.parentNode}$e=Ke}p=X===-1||ne===-1?null:{start:X,end:ne}}else p=null}p=p||{start:0,end:0}}else p=null;for(fp={focusedElem:a,selectionRange:p},As=!1,Qe=c;Qe!==null;)if(c=Qe,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Qe=a;else for(;Qe!==null;){c=Qe;try{var Je=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Ze=Je.memoizedProps,xn=Je.memoizedState,le=c.stateNode,ae=le.getSnapshotBeforeUpdate(c.elementType===c.type?Ze:kr(c.type,Ze),xn);le.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ce=c.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(Le){un(c,c.return,Le)}if(a=c.sibling,a!==null){a.return=c.return,Qe=a;break}Qe=c.return}return Je=kj,kj=!1,Je}function Rc(a,c,p){var w=c.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var _=w=w.next;do{if((_.tag&a)===a){var R=_.destroy;_.destroy=void 0,R!==void 0&&Zp(c,p,R)}_=_.next}while(_!==w)}}function ef(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var p=c=c.next;do{if((p.tag&a)===a){var w=p.create;p.destroy=w()}p=p.next}while(p!==c)}}function eg(a){var c=a.ref;if(c!==null){var p=a.stateNode;switch(a.tag){case 5:a=p;break;default:a=p}typeof c=="function"?c(a):c.current=a}}function Nj(a){var c=a.alternate;c!==null&&(a.alternate=null,Nj(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[Ir],delete c[yc],delete c[gp],delete c[tR],delete c[nR])),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 Sj(a){return a.tag===5||a.tag===3||a.tag===4}function Cj(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Sj(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 tg(a,c,p){var w=a.tag;if(w===5||w===6)a=a.stateNode,c?p.nodeType===8?p.parentNode.insertBefore(a,c):p.insertBefore(a,c):(p.nodeType===8?(c=p.parentNode,c.insertBefore(a,p)):(c=p,c.appendChild(a)),p=p._reactRootContainer,p!=null||c.onclick!==null||(c.onclick=Ru));else if(w!==4&&(a=a.child,a!==null))for(tg(a,c,p),a=a.sibling;a!==null;)tg(a,c,p),a=a.sibling}function ng(a,c,p){var w=a.tag;if(w===5||w===6)a=a.stateNode,c?p.insertBefore(a,c):p.appendChild(a);else if(w!==4&&(a=a.child,a!==null))for(ng(a,c,p),a=a.sibling;a!==null;)ng(a,c,p),a=a.sibling}var Vn=null,Nr=!1;function Vo(a,c,p){for(p=p.child;p!==null;)_j(a,c,p),p=p.sibling}function _j(a,c,p){if(Rs&&typeof Rs.onCommitFiberUnmount=="function")try{Rs.onCommitFiberUnmount(ji,p)}catch{}switch(p.tag){case 5:ss||Gi(p,c);case 6:var w=Vn,_=Nr;Vn=null,Vo(a,c,p),Vn=w,Nr=_,Vn!==null&&(Nr?(a=Vn,p=p.stateNode,a.nodeType===8?a.parentNode.removeChild(p):a.removeChild(p)):Vn.removeChild(p.stateNode));break;case 18:Vn!==null&&(Nr?(a=Vn,p=p.stateNode,a.nodeType===8?pp(a.parentNode,p):a.nodeType===1&&pp(a,p),kt(a)):pp(Vn,p.stateNode));break;case 4:w=Vn,_=Nr,Vn=p.stateNode.containerInfo,Nr=!0,Vo(a,c,p),Vn=w,Nr=_;break;case 0:case 11:case 14:case 15:if(!ss&&(w=p.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){_=w=w.next;do{var R=_,z=R.destroy;R=R.tag,z!==void 0&&((R&2)!==0||(R&4)!==0)&&Zp(p,c,z),_=_.next}while(_!==w)}Vo(a,c,p);break;case 1:if(!ss&&(Gi(p,c),w=p.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=p.memoizedProps,w.state=p.memoizedState,w.componentWillUnmount()}catch(X){un(p,c,X)}Vo(a,c,p);break;case 21:Vo(a,c,p);break;case 22:p.mode&1?(ss=(w=ss)||p.memoizedState!==null,Vo(a,c,p),ss=w):Vo(a,c,p);break;default:Vo(a,c,p)}}function $j(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var p=a.stateNode;p===null&&(p=a.stateNode=new bR),c.forEach(function(w){var _=$R.bind(null,a,w);p.has(w)||(p.add(w),w.then(_,_))})}}function Sr(a,c){var p=c.deletions;if(p!==null)for(var w=0;w<p.length;w++){var _=p[w];try{var R=a,z=c,X=z;e:for(;X!==null;){switch(X.tag){case 5:Vn=X.stateNode,Nr=!1;break e;case 3:Vn=X.stateNode.containerInfo,Nr=!0;break e;case 4:Vn=X.stateNode.containerInfo,Nr=!0;break e}X=X.return}if(Vn===null)throw Error(s(160));_j(R,z,_),Vn=null,Nr=!1;var ne=_.alternate;ne!==null&&(ne.return=null),_.return=null}catch(me){un(_,c,me)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)Ej(c,a),c=c.sibling}function Ej(a,c){var p=a.alternate,w=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(Sr(c,a),zr(a),w&4){try{Rc(3,a,a.return),ef(3,a)}catch(Ze){un(a,a.return,Ze)}try{Rc(5,a,a.return)}catch(Ze){un(a,a.return,Ze)}}break;case 1:Sr(c,a),zr(a),w&512&&p!==null&&Gi(p,p.return);break;case 5:if(Sr(c,a),zr(a),w&512&&p!==null&&Gi(p,p.return),a.flags&32){var _=a.stateNode;try{st(_,"")}catch(Ze){un(a,a.return,Ze)}}if(w&4&&(_=a.stateNode,_!=null)){var R=a.memoizedProps,z=p!==null?p.memoizedProps:R,X=a.type,ne=a.updateQueue;if(a.updateQueue=null,ne!==null)try{X==="input"&&R.type==="radio"&&R.name!=null&&Te(_,R),qt(X,z);var me=qt(X,R);for(z=0;z<ne.length;z+=2){var Ce=ne[z],$e=ne[z+1];Ce==="style"?et(_,$e):Ce==="dangerouslySetInnerHTML"?ze(_,$e):Ce==="children"?st(_,$e):N(_,Ce,$e,me)}switch(X){case"input":Xe(_,R);break;case"textarea":rt(_,R);break;case"select":var Se=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!R.multiple;var Ke=R.value;Ke!=null?te(_,!!R.multiple,Ke,!1):Se!==!!R.multiple&&(R.defaultValue!=null?te(_,!!R.multiple,R.defaultValue,!0):te(_,!!R.multiple,R.multiple?[]:"",!1))}_[yc]=R}catch(Ze){un(a,a.return,Ze)}}break;case 6:if(Sr(c,a),zr(a),w&4){if(a.stateNode===null)throw Error(s(162));_=a.stateNode,R=a.memoizedProps;try{_.nodeValue=R}catch(Ze){un(a,a.return,Ze)}}break;case 3:if(Sr(c,a),zr(a),w&4&&p!==null&&p.memoizedState.isDehydrated)try{kt(c.containerInfo)}catch(Ze){un(a,a.return,Ze)}break;case 4:Sr(c,a),zr(a);break;case 13:Sr(c,a),zr(a),_=a.child,_.flags&8192&&(R=_.memoizedState!==null,_.stateNode.isHidden=R,!R||_.alternate!==null&&_.alternate.memoizedState!==null||(og=pt())),w&4&&$j(a);break;case 22:if(Ce=p!==null&&p.memoizedState!==null,a.mode&1?(ss=(me=ss)||Ce,Sr(c,a),ss=me):Sr(c,a),zr(a),w&8192){if(me=a.memoizedState!==null,(a.stateNode.isHidden=me)&&!Ce&&(a.mode&1)!==0)for(Qe=a,Ce=a.child;Ce!==null;){for($e=Qe=Ce;Qe!==null;){switch(Se=Qe,Ke=Se.child,Se.tag){case 0:case 11:case 14:case 15:Rc(4,Se,Se.return);break;case 1:Gi(Se,Se.return);var Je=Se.stateNode;if(typeof Je.componentWillUnmount=="function"){w=Se,p=Se.return;try{c=w,Je.props=c.memoizedProps,Je.state=c.memoizedState,Je.componentWillUnmount()}catch(Ze){un(w,p,Ze)}}break;case 5:Gi(Se,Se.return);break;case 22:if(Se.memoizedState!==null){Aj($e);continue}}Ke!==null?(Ke.return=Se,Qe=Ke):Aj($e)}Ce=Ce.sibling}e:for(Ce=null,$e=a;;){if($e.tag===5){if(Ce===null){Ce=$e;try{_=$e.stateNode,me?(R=_.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none"):(X=$e.stateNode,ne=$e.memoizedProps.style,z=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,X.style.display=$t("display",z))}catch(Ze){un(a,a.return,Ze)}}}else if($e.tag===6){if(Ce===null)try{$e.stateNode.nodeValue=me?"":$e.memoizedProps}catch(Ze){un(a,a.return,Ze)}}else if(($e.tag!==22&&$e.tag!==23||$e.memoizedState===null||$e===a)&&$e.child!==null){$e.child.return=$e,$e=$e.child;continue}if($e===a)break e;for(;$e.sibling===null;){if($e.return===null||$e.return===a)break e;Ce===$e&&(Ce=null),$e=$e.return}Ce===$e&&(Ce=null),$e.sibling.return=$e.return,$e=$e.sibling}}break;case 19:Sr(c,a),zr(a),w&4&&$j(a);break;case 21:break;default:Sr(c,a),zr(a)}}function zr(a){var c=a.flags;if(c&2){try{e:{for(var p=a.return;p!==null;){if(Sj(p)){var w=p;break e}p=p.return}throw Error(s(160))}switch(w.tag){case 5:var _=w.stateNode;w.flags&32&&(st(_,""),w.flags&=-33);var R=Cj(a);ng(a,R,_);break;case 3:case 4:var z=w.stateNode.containerInfo,X=Cj(a);tg(a,X,z);break;default:throw Error(s(161))}}catch(ne){un(a,a.return,ne)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function yR(a,c,p){Qe=a,Tj(a)}function Tj(a,c,p){for(var w=(a.mode&1)!==0;Qe!==null;){var _=Qe,R=_.child;if(_.tag===22&&w){var z=_.memoizedState!==null||Zu;if(!z){var X=_.alternate,ne=X!==null&&X.memoizedState!==null||ss;X=Zu;var me=ss;if(Zu=z,(ss=ne)&&!me)for(Qe=_;Qe!==null;)z=Qe,ne=z.child,z.tag===22&&z.memoizedState!==null?Oj(_):ne!==null?(ne.return=z,Qe=ne):Oj(_);for(;R!==null;)Qe=R,Tj(R),R=R.sibling;Qe=_,Zu=X,ss=me}Rj(a)}else(_.subtreeFlags&8772)!==0&&R!==null?(R.return=_,Qe=R):Rj(a)}}function Rj(a){for(;Qe!==null;){var c=Qe;if((c.flags&8772)!==0){var p=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:ss||ef(5,c);break;case 1:var w=c.stateNode;if(c.flags&4&&!ss)if(p===null)w.componentDidMount();else{var _=c.elementType===c.type?p.memoizedProps:kr(c.type,p.memoizedProps);w.componentDidUpdate(_,p.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var R=c.updateQueue;R!==null&&Aw(c,R,w);break;case 3:var z=c.updateQueue;if(z!==null){if(p=null,c.child!==null)switch(c.child.tag){case 5:p=c.child.stateNode;break;case 1:p=c.child.stateNode}Aw(c,z,p)}break;case 5:var X=c.stateNode;if(p===null&&c.flags&4){p=X;var ne=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&p.focus();break;case"img":ne.src&&(p.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var me=c.alternate;if(me!==null){var Ce=me.memoizedState;if(Ce!==null){var $e=Ce.dehydrated;$e!==null&&kt($e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ss||c.flags&512&&eg(c)}catch(Se){un(c,c.return,Se)}}if(c===a){Qe=null;break}if(p=c.sibling,p!==null){p.return=c.return,Qe=p;break}Qe=c.return}}function Aj(a){for(;Qe!==null;){var c=Qe;if(c===a){Qe=null;break}var p=c.sibling;if(p!==null){p.return=c.return,Qe=p;break}Qe=c.return}}function Oj(a){for(;Qe!==null;){var c=Qe;try{switch(c.tag){case 0:case 11:case 15:var p=c.return;try{ef(4,c)}catch(ne){un(c,p,ne)}break;case 1:var w=c.stateNode;if(typeof w.componentDidMount=="function"){var _=c.return;try{w.componentDidMount()}catch(ne){un(c,_,ne)}}var R=c.return;try{eg(c)}catch(ne){un(c,R,ne)}break;case 5:var z=c.return;try{eg(c)}catch(ne){un(c,z,ne)}}}catch(ne){un(c,c.return,ne)}if(c===a){Qe=null;break}var X=c.sibling;if(X!==null){X.return=c.return,Qe=X;break}Qe=c.return}}var wR=Math.ceil,tf=S.ReactCurrentDispatcher,sg=S.ReactCurrentOwner,Zs=S.ReactCurrentBatchConfig,Ot=0,Dn=null,Sn=null,Yn=0,Ps=0,Ki=Ho(0),Tn=0,Ac=null,za=0,nf=0,rg=0,Oc=null,ks=null,og=0,Vi=1/0,ho=null,sf=!1,ag=null,Yo=null,rf=!1,Qo=null,of=0,Lc=0,ig=null,af=-1,lf=0;function us(){return(Ot&6)!==0?pt():af!==-1?af:af=pt()}function Jo(a){return(a.mode&1)===0?1:(Ot&2)!==0&&Yn!==0?Yn&-Yn:rR.transition!==null?(lf===0&&(lf=Zl()),lf):(a=It,a!==0||(a=window.event,a=a===void 0?16:cc(a.type)),a)}function Cr(a,c,p,w){if(50<Lc)throw Lc=0,ig=null,Error(s(185));Po(a,p,w),((Ot&2)===0||a!==Dn)&&(a===Dn&&((Ot&2)===0&&(nf|=p),Tn===4&&Xo(a,Yn)),Ns(a,w),p===1&&Ot===0&&(c.mode&1)===0&&(Vi=pt()+500,Mu&&qo()))}function Ns(a,c){var p=a.callbackNode;vu(a,c);var w=Ea(a,a===Dn?Yn:0);if(w===0)p!==null&&Ye(p),a.callbackNode=null,a.callbackPriority=0;else if(c=w&-w,a.callbackPriority!==c){if(p!=null&&Ye(p),c===1)a.tag===0?sR(Mj.bind(null,a)):yw(Mj.bind(null,a)),ZT(function(){(Ot&6)===0&&qo()}),p=null;else{switch(ec(w)){case 1:p=Kn;break;case 4:p=Ts;break;case 16:p=Qt;break;case 536870912:p=so;break;default:p=Qt}p=Hj(p,Lj.bind(null,a))}a.callbackPriority=c,a.callbackNode=p}}function Lj(a,c){if(af=-1,lf=0,(Ot&6)!==0)throw Error(s(327));var p=a.callbackNode;if(Yi()&&a.callbackNode!==p)return null;var w=Ea(a,a===Dn?Yn:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||c)c=cf(a,w);else{c=w;var _=Ot;Ot|=2;var R=Pj();(Dn!==a||Yn!==c)&&(ho=null,Vi=pt()+500,Ua(a,c));do try{NR();break}catch(X){Ij(a,X)}while(!0);Sp(),tf.current=R,Ot=_,Sn!==null?c=0:(Dn=null,Yn=0,c=Tn)}if(c!==0){if(c===2&&(_=ki(a),_!==0&&(w=_,c=lg(a,_))),c===1)throw p=Ac,Ua(a,0),Xo(a,w),Ns(a,pt()),p;if(c===6)Xo(a,w);else{if(_=a.current.alternate,(w&30)===0&&!jR(_)&&(c=cf(a,w),c===2&&(R=ki(a),R!==0&&(w=R,c=lg(a,R))),c===1))throw p=Ac,Ua(a,0),Xo(a,w),Ns(a,pt()),p;switch(a.finishedWork=_,a.finishedLanes=w,c){case 0:case 1:throw Error(s(345));case 2:Wa(a,ks,ho);break;case 3:if(Xo(a,w),(w&130023424)===w&&(c=og+500-pt(),10<c)){if(Ea(a,0)!==0)break;if(_=a.suspendedLanes,(_&w)!==w){us(),a.pingedLanes|=a.suspendedLanes&_;break}a.timeoutHandle=hp(Wa.bind(null,a,ks,ho),c);break}Wa(a,ks,ho);break;case 4:if(Xo(a,w),(w&4194240)===w)break;for(c=a.eventTimes,_=-1;0<w;){var z=31-Zn(w);R=1<<z,z=c[z],z>_&&(_=z),w&=~R}if(w=_,w=pt()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*wR(w/1960))-w,10<w){a.timeoutHandle=hp(Wa.bind(null,a,ks,ho),w);break}Wa(a,ks,ho);break;case 5:Wa(a,ks,ho);break;default:throw Error(s(329))}}}return Ns(a,pt()),a.callbackNode===p?Lj.bind(null,a):null}function lg(a,c){var p=Oc;return a.current.memoizedState.isDehydrated&&(Ua(a,c).flags|=256),a=cf(a,c),a!==2&&(c=ks,ks=p,c!==null&&cg(c)),a}function cg(a){ks===null?ks=a:ks.push.apply(ks,a)}function jR(a){for(var c=a;;){if(c.flags&16384){var p=c.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var w=0;w<p.length;w++){var _=p[w],R=_.getSnapshot;_=_.value;try{if(!wr(R(),_))return!1}catch{return!1}}}if(p=c.child,c.subtreeFlags&16384&&p!==null)p.return=c,c=p;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Xo(a,c){for(c&=~rg,c&=~nf,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var p=31-Zn(c),w=1<<p;a[p]=-1,c&=~w}}function Mj(a){if((Ot&6)!==0)throw Error(s(327));Yi();var c=Ea(a,0);if((c&1)===0)return Ns(a,pt()),null;var p=cf(a,c);if(a.tag!==0&&p===2){var w=ki(a);w!==0&&(c=w,p=lg(a,w))}if(p===1)throw p=Ac,Ua(a,0),Xo(a,c),Ns(a,pt()),p;if(p===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,Wa(a,ks,ho),Ns(a,pt()),null}function dg(a,c){var p=Ot;Ot|=1;try{return a(c)}finally{Ot=p,Ot===0&&(Vi=pt()+500,Mu&&qo())}}function Fa(a){Qo!==null&&Qo.tag===0&&(Ot&6)===0&&Yi();var c=Ot;Ot|=1;var p=Zs.transition,w=It;try{if(Zs.transition=null,It=1,a)return a()}finally{It=w,Zs.transition=p,Ot=c,(Ot&6)===0&&qo()}}function ug(){Ps=Ki.current,Xt(Ki)}function Ua(a,c){a.finishedWork=null,a.finishedLanes=0;var p=a.timeoutHandle;if(p!==-1&&(a.timeoutHandle=-1,XT(p)),Sn!==null)for(p=Sn.return;p!==null;){var w=p;switch(yp(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&Ou();break;case 3:Bi(),Xt(ys),Xt(es),Op();break;case 5:Rp(w);break;case 4:Bi();break;case 13:Xt(an);break;case 19:Xt(an);break;case 10:Cp(w.type._context);break;case 22:case 23:ug()}p=p.return}if(Dn=a,Sn=a=Zo(a.current,null),Yn=Ps=c,Tn=0,Ac=null,rg=nf=za=0,ks=Oc=null,Ia!==null){for(c=0;c<Ia.length;c++)if(p=Ia[c],w=p.interleaved,w!==null){p.interleaved=null;var _=w.next,R=p.pending;if(R!==null){var z=R.next;R.next=_,w.next=z}p.pending=w}Ia=null}return a}function Ij(a,c){do{var p=Sn;try{if(Sp(),qu.current=Yu,Gu){for(var w=ln.memoizedState;w!==null;){var _=w.queue;_!==null&&(_.pending=null),w=w.next}Gu=!1}if(Da=0,Pn=En=ln=null,Cc=!1,_c=0,sg.current=null,p===null||p.return===null){Tn=1,Ac=c,Sn=null;break}e:{var R=a,z=p.return,X=p,ne=c;if(c=Yn,X.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var me=ne,Ce=X,$e=Ce.tag;if((Ce.mode&1)===0&&($e===0||$e===11||$e===15)){var Se=Ce.alternate;Se?(Ce.updateQueue=Se.updateQueue,Ce.memoizedState=Se.memoizedState,Ce.lanes=Se.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var Ke=ij(z);if(Ke!==null){Ke.flags&=-257,lj(Ke,z,X,R,c),Ke.mode&1&&aj(R,me,c),c=Ke,ne=me;var Je=c.updateQueue;if(Je===null){var Ze=new Set;Ze.add(ne),c.updateQueue=Ze}else Je.add(ne);break e}else{if((c&1)===0){aj(R,me,c),fg();break e}ne=Error(s(426))}}else if(tn&&X.mode&1){var xn=ij(z);if(xn!==null){(xn.flags&65536)===0&&(xn.flags|=256),lj(xn,z,X,R,c),kp(qi(ne,X));break e}}R=ne=qi(ne,X),Tn!==4&&(Tn=2),Oc===null?Oc=[R]:Oc.push(R),R=z;do{switch(R.tag){case 3:R.flags|=65536,c&=-c,R.lanes|=c;var le=rj(R,ne,c);Rw(R,le);break e;case 1:X=ne;var ae=R.type,ce=R.stateNode;if((R.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Yo===null||!Yo.has(ce)))){R.flags|=65536,c&=-c,R.lanes|=c;var Le=oj(R,X,c);Rw(R,Le);break e}}R=R.return}while(R!==null)}zj(p)}catch(nt){c=nt,Sn===p&&p!==null&&(Sn=p=p.return);continue}break}while(!0)}function Pj(){var a=tf.current;return tf.current=Yu,a===null?Yu:a}function fg(){(Tn===0||Tn===3||Tn===2)&&(Tn=4),Dn===null||(za&268435455)===0&&(nf&268435455)===0||Xo(Dn,Yn)}function cf(a,c){var p=Ot;Ot|=2;var w=Pj();(Dn!==a||Yn!==c)&&(ho=null,Ua(a,c));do try{kR();break}catch(_){Ij(a,_)}while(!0);if(Sp(),Ot=p,tf.current=w,Sn!==null)throw Error(s(261));return Dn=null,Yn=0,Tn}function kR(){for(;Sn!==null;)Dj(Sn)}function NR(){for(;Sn!==null&&!Mt();)Dj(Sn)}function Dj(a){var c=Wj(a.alternate,a,Ps);a.memoizedProps=a.pendingProps,c===null?zj(a):Sn=c,sg.current=null}function zj(a){var c=a;do{var p=c.alternate;if(a=c.return,(c.flags&32768)===0){if(p=gR(p,c,Ps),p!==null){Sn=p;return}}else{if(p=xR(p,c),p!==null){p.flags&=32767,Sn=p;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Tn=6,Sn=null;return}}if(c=c.sibling,c!==null){Sn=c;return}Sn=c=a}while(c!==null);Tn===0&&(Tn=5)}function Wa(a,c,p){var w=It,_=Zs.transition;try{Zs.transition=null,It=1,SR(a,c,p,w)}finally{Zs.transition=_,It=w}return null}function SR(a,c,p,w){do Yi();while(Qo!==null);if((Ot&6)!==0)throw Error(s(327));p=a.finishedWork;var _=a.finishedLanes;if(p===null)return null;if(a.finishedWork=null,a.finishedLanes=0,p===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var R=p.lanes|p.childLanes;if(yu(a,R),a===Dn&&(Sn=Dn=null,Yn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||rf||(rf=!0,Hj(Qt,function(){return Yi(),null})),R=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||R){R=Zs.transition,Zs.transition=null;var z=It;It=1;var X=Ot;Ot|=4,sg.current=null,vR(a,p),Ej(p,a),qT(fp),As=!!up,fp=up=null,a.current=p,yR(p),Nn(),Ot=X,It=z,Zs.transition=R}else a.current=p;if(rf&&(rf=!1,Qo=a,of=_),R=a.pendingLanes,R===0&&(Yo=null),Kh(p.stateNode),Ns(a,pt()),c!==null)for(w=a.onRecoverableError,p=0;p<c.length;p++)_=c[p],w(_.value,{componentStack:_.stack,digest:_.digest});if(sf)throw sf=!1,a=ag,ag=null,a;return(of&1)!==0&&a.tag!==0&&Yi(),R=a.pendingLanes,(R&1)!==0?a===ig?Lc++:(Lc=0,ig=a):Lc=0,qo(),null}function Yi(){if(Qo!==null){var a=ec(of),c=Zs.transition,p=It;try{if(Zs.transition=null,It=16>a?16:a,Qo===null)var w=!1;else{if(a=Qo,Qo=null,of=0,(Ot&6)!==0)throw Error(s(331));var _=Ot;for(Ot|=4,Qe=a.current;Qe!==null;){var R=Qe,z=R.child;if((Qe.flags&16)!==0){var X=R.deletions;if(X!==null){for(var ne=0;ne<X.length;ne++){var me=X[ne];for(Qe=me;Qe!==null;){var Ce=Qe;switch(Ce.tag){case 0:case 11:case 15:Rc(8,Ce,R)}var $e=Ce.child;if($e!==null)$e.return=Ce,Qe=$e;else for(;Qe!==null;){Ce=Qe;var Se=Ce.sibling,Ke=Ce.return;if(Nj(Ce),Ce===me){Qe=null;break}if(Se!==null){Se.return=Ke,Qe=Se;break}Qe=Ke}}}var Je=R.alternate;if(Je!==null){var Ze=Je.child;if(Ze!==null){Je.child=null;do{var xn=Ze.sibling;Ze.sibling=null,Ze=xn}while(Ze!==null)}}Qe=R}}if((R.subtreeFlags&2064)!==0&&z!==null)z.return=R,Qe=z;else e:for(;Qe!==null;){if(R=Qe,(R.flags&2048)!==0)switch(R.tag){case 0:case 11:case 15:Rc(9,R,R.return)}var le=R.sibling;if(le!==null){le.return=R.return,Qe=le;break e}Qe=R.return}}var ae=a.current;for(Qe=ae;Qe!==null;){z=Qe;var ce=z.child;if((z.subtreeFlags&2064)!==0&&ce!==null)ce.return=z,Qe=ce;else e:for(z=ae;Qe!==null;){if(X=Qe,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:ef(9,X)}}catch(nt){un(X,X.return,nt)}if(X===z){Qe=null;break e}var Le=X.sibling;if(Le!==null){Le.return=X.return,Qe=Le;break e}Qe=X.return}}if(Ot=_,qo(),Rs&&typeof Rs.onPostCommitFiberRoot=="function")try{Rs.onPostCommitFiberRoot(ji,a)}catch{}w=!0}return w}finally{It=p,Zs.transition=c}}return!1}function Fj(a,c,p){c=qi(p,c),c=rj(a,c,1),a=Ko(a,c,1),c=us(),a!==null&&(Po(a,1,c),Ns(a,c))}function un(a,c,p){if(a.tag===3)Fj(a,a,p);else for(;c!==null;){if(c.tag===3){Fj(c,a,p);break}else if(c.tag===1){var w=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Yo===null||!Yo.has(w))){a=qi(p,a),a=oj(c,a,1),c=Ko(c,a,1),a=us(),c!==null&&(Po(c,1,a),Ns(c,a));break}}c=c.return}}function CR(a,c,p){var w=a.pingCache;w!==null&&w.delete(c),c=us(),a.pingedLanes|=a.suspendedLanes&p,Dn===a&&(Yn&p)===p&&(Tn===4||Tn===3&&(Yn&130023424)===Yn&&500>pt()-og?Ua(a,0):rg|=p),Ns(a,c)}function Uj(a,c){c===0&&((a.mode&1)===0?c=1:(c=$a,$a<<=1,($a&130023424)===0&&($a=4194304)));var p=us();a=uo(a,c),a!==null&&(Po(a,c,p),Ns(a,p))}function _R(a){var c=a.memoizedState,p=0;c!==null&&(p=c.retryLane),Uj(a,p)}function $R(a,c){var p=0;switch(a.tag){case 13:var w=a.stateNode,_=a.memoizedState;_!==null&&(p=_.retryLane);break;case 19:w=a.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(c),Uj(a,p)}var Wj;Wj=function(a,c,p){if(a!==null)if(a.memoizedProps!==c.pendingProps||ys.current)js=!0;else{if((a.lanes&p)===0&&(c.flags&128)===0)return js=!1,pR(a,c,p);js=(a.flags&131072)!==0}else js=!1,tn&&(c.flags&1048576)!==0&&ww(c,Pu,c.index);switch(c.lanes=0,c.tag){case 2:var w=c.type;Xu(a,c),a=c.pendingProps;var _=Pi(c,es.current);Hi(c,p),_=Ip(null,c,w,a,_,p);var R=Pp();return c.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,ws(w)?(R=!0,Lu(c)):R=!1,c.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,Ep(c),_.updater=Qu,c.stateNode=_,_._reactInternals=c,Hp(c,w,a,p),c=Kp(null,c,w,!0,R,p)):(c.tag=0,tn&&R&&vp(c),ds(null,c,_,p),c=c.child),c;case 16:w=c.elementType;e:{switch(Xu(a,c),a=c.pendingProps,_=w._init,w=_(w._payload),c.type=w,_=c.tag=TR(w),a=kr(w,a),_){case 0:c=Gp(null,c,w,a,p);break e;case 1:c=hj(null,c,w,a,p);break e;case 11:c=cj(null,c,w,a,p);break e;case 14:c=dj(null,c,w,kr(w.type,a),p);break e}throw Error(s(306,w,""))}return c;case 0:return w=c.type,_=c.pendingProps,_=c.elementType===w?_:kr(w,_),Gp(a,c,w,_,p);case 1:return w=c.type,_=c.pendingProps,_=c.elementType===w?_:kr(w,_),hj(a,c,w,_,p);case 3:e:{if(pj(c),a===null)throw Error(s(387));w=c.pendingProps,R=c.memoizedState,_=R.element,Tw(a,c),Hu(c,w,null,p);var z=c.memoizedState;if(w=z.element,R.isDehydrated)if(R={element:w,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},c.updateQueue.baseState=R,c.memoizedState=R,c.flags&256){_=qi(Error(s(423)),c),c=gj(a,c,w,p,_);break e}else if(w!==_){_=qi(Error(s(424)),c),c=gj(a,c,w,p,_);break e}else for(Is=Wo(c.stateNode.containerInfo.firstChild),Ms=c,tn=!0,jr=null,p=$w(c,null,w,p),c.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Fi(),w===_){c=mo(a,c,p);break e}ds(a,c,w,p)}c=c.child}return c;case 5:return Ow(c),a===null&&jp(c),w=c.type,_=c.pendingProps,R=a!==null?a.memoizedProps:null,z=_.children,mp(w,_)?z=null:R!==null&&mp(w,R)&&(c.flags|=32),mj(a,c),ds(a,c,z,p),c.child;case 6:return a===null&&jp(c),null;case 13:return xj(a,c,p);case 4:return Tp(c,c.stateNode.containerInfo),w=c.pendingProps,a===null?c.child=Ui(c,null,w,p):ds(a,c,w,p),c.child;case 11:return w=c.type,_=c.pendingProps,_=c.elementType===w?_:kr(w,_),cj(a,c,w,_,p);case 7:return ds(a,c,c.pendingProps,p),c.child;case 8:return ds(a,c,c.pendingProps.children,p),c.child;case 12:return ds(a,c,c.pendingProps.children,p),c.child;case 10:e:{if(w=c.type._context,_=c.pendingProps,R=c.memoizedProps,z=_.value,Kt(Fu,w._currentValue),w._currentValue=z,R!==null)if(wr(R.value,z)){if(R.children===_.children&&!ys.current){c=mo(a,c,p);break e}}else for(R=c.child,R!==null&&(R.return=c);R!==null;){var X=R.dependencies;if(X!==null){z=R.child;for(var ne=X.firstContext;ne!==null;){if(ne.context===w){if(R.tag===1){ne=fo(-1,p&-p),ne.tag=2;var me=R.updateQueue;if(me!==null){me=me.shared;var Ce=me.pending;Ce===null?ne.next=ne:(ne.next=Ce.next,Ce.next=ne),me.pending=ne}}R.lanes|=p,ne=R.alternate,ne!==null&&(ne.lanes|=p),_p(R.return,p,c),X.lanes|=p;break}ne=ne.next}}else if(R.tag===10)z=R.type===c.type?null:R.child;else if(R.tag===18){if(z=R.return,z===null)throw Error(s(341));z.lanes|=p,X=z.alternate,X!==null&&(X.lanes|=p),_p(z,p,c),z=R.sibling}else z=R.child;if(z!==null)z.return=R;else for(z=R;z!==null;){if(z===c){z=null;break}if(R=z.sibling,R!==null){R.return=z.return,z=R;break}z=z.return}R=z}ds(a,c,_.children,p),c=c.child}return c;case 9:return _=c.type,w=c.pendingProps.children,Hi(c,p),_=Js(_),w=w(_),c.flags|=1,ds(a,c,w,p),c.child;case 14:return w=c.type,_=kr(w,c.pendingProps),_=kr(w.type,_),dj(a,c,w,_,p);case 15:return uj(a,c,c.type,c.pendingProps,p);case 17:return w=c.type,_=c.pendingProps,_=c.elementType===w?_:kr(w,_),Xu(a,c),c.tag=1,ws(w)?(a=!0,Lu(c)):a=!1,Hi(c,p),nj(c,w,_),Hp(c,w,_,p),Kp(null,c,w,!0,a,p);case 19:return vj(a,c,p);case 22:return fj(a,c,p)}throw Error(s(156,c.tag))};function Hj(a,c){return Re(a,c)}function ER(a,c,p,w){this.tag=a,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,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 er(a,c,p,w){return new ER(a,c,p,w)}function mg(a){return a=a.prototype,!(!a||!a.isReactComponent)}function TR(a){if(typeof a=="function")return mg(a)?1:0;if(a!=null){if(a=a.$$typeof,a===M)return 11;if(a===V)return 14}return 2}function Zo(a,c){var p=a.alternate;return p===null?(p=er(a.tag,c,a.key,a.mode),p.elementType=a.elementType,p.type=a.type,p.stateNode=a.stateNode,p.alternate=a,a.alternate=p):(p.pendingProps=c,p.type=a.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=a.flags&14680064,p.childLanes=a.childLanes,p.lanes=a.lanes,p.child=a.child,p.memoizedProps=a.memoizedProps,p.memoizedState=a.memoizedState,p.updateQueue=a.updateQueue,c=a.dependencies,p.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},p.sibling=a.sibling,p.index=a.index,p.ref=a.ref,p}function df(a,c,p,w,_,R){var z=2;if(w=a,typeof a=="function")mg(a)&&(z=1);else if(typeof a=="string")z=5;else e:switch(a){case L:return Ha(p.children,_,R,c);case A:z=8,_|=8;break;case P:return a=er(12,p,c,_|2),a.elementType=P,a.lanes=R,a;case F:return a=er(13,p,c,_),a.elementType=F,a.lanes=R,a;case I:return a=er(19,p,c,_),a.elementType=I,a.lanes=R,a;case q:return uf(p,_,R,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case O:z=10;break e;case T:z=9;break e;case M:z=11;break e;case V:z=14;break e;case G:z=16,w=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return c=er(z,p,c,_),c.elementType=a,c.type=w,c.lanes=R,c}function Ha(a,c,p,w){return a=er(7,a,w,c),a.lanes=p,a}function uf(a,c,p,w){return a=er(22,a,w,c),a.elementType=q,a.lanes=p,a.stateNode={isHidden:!1},a}function hg(a,c,p){return a=er(6,a,null,c),a.lanes=p,a}function pg(a,c,p){return c=er(4,a.children!==null?a.children:[],a.key,c),c.lanes=p,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function RR(a,c,p,w,_){this.tag=c,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=Ni(0),this.expirationTimes=Ni(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ni(0),this.identifierPrefix=w,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function gg(a,c,p,w,_,R,z,X,ne){return a=new RR(a,c,p,X,ne),c===1?(c=1,R===!0&&(c|=8)):c=0,R=er(3,null,null,c),a.current=R,R.stateNode=a,R.memoizedState={element:w,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ep(R),a}function AR(a,c,p){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:w==null?null:""+w,children:a,containerInfo:c,implementation:p}}function Bj(a){if(!a)return Bo;a=a._reactInternals;e:{if(Tt(a)!==a||a.tag!==1)throw Error(s(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(ws(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(s(171))}if(a.tag===1){var p=a.type;if(ws(p))return bw(a,p,c)}return c}function qj(a,c,p,w,_,R,z,X,ne){return a=gg(p,w,!0,a,_,R,z,X,ne),a.context=Bj(null),p=a.current,w=us(),_=Jo(p),R=fo(w,_),R.callback=c??null,Ko(p,R,_),a.current.lanes=_,Po(a,_,w),Ns(a,w),a}function ff(a,c,p,w){var _=c.current,R=us(),z=Jo(_);return p=Bj(p),c.context===null?c.context=p:c.pendingContext=p,c=fo(R,z),c.payload={element:a},w=w===void 0?null:w,w!==null&&(c.callback=w),a=Ko(_,c,z),a!==null&&(Cr(a,_,z,R),Wu(a,_,z)),z}function mf(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 Gj(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var p=a.retryLane;a.retryLane=p!==0&&p<c?p:c}}function xg(a,c){Gj(a,c),(a=a.alternate)&&Gj(a,c)}function OR(){return null}var Kj=typeof reportError=="function"?reportError:function(a){console.error(a)};function bg(a){this._internalRoot=a}hf.prototype.render=bg.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(s(409));ff(a,c,null,null)},hf.prototype.unmount=bg.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;Fa(function(){ff(null,a,null,null)}),c[ao]=null}};function hf(a){this._internalRoot=a}hf.prototype.unstable_scheduleHydration=function(a){if(a){var c=sc();a={blockedOn:null,target:a,priority:c};for(var p=0;p<br.length&&c!==0&&c<br[p].priority;p++);br.splice(p,0,a),p===0&&ac(a)}};function vg(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function pf(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Vj(){}function LR(a,c,p,w,_){if(_){if(typeof w=="function"){var R=w;w=function(){var me=mf(z);R.call(me)}}var z=qj(c,w,a,0,null,!1,!1,"",Vj);return a._reactRootContainer=z,a[ao]=z.current,bc(a.nodeType===8?a.parentNode:a),Fa(),z}for(;_=a.lastChild;)a.removeChild(_);if(typeof w=="function"){var X=w;w=function(){var me=mf(ne);X.call(me)}}var ne=gg(a,0,!1,null,null,!1,!1,"",Vj);return a._reactRootContainer=ne,a[ao]=ne.current,bc(a.nodeType===8?a.parentNode:a),Fa(function(){ff(c,ne,p,w)}),ne}function gf(a,c,p,w,_){var R=p._reactRootContainer;if(R){var z=R;if(typeof _=="function"){var X=_;_=function(){var ne=mf(z);X.call(ne)}}ff(c,z,a,_)}else z=LR(p,c,a,_,w);return mf(z)}tc=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var p=Io(c.pendingLanes);p!==0&&(Si(c,p|1),Ns(c,pt()),(Ot&6)===0&&(Vi=pt()+500,qo()))}break;case 13:Fa(function(){var w=uo(a,1);if(w!==null){var _=us();Cr(w,a,1,_)}}),xg(a,1)}},Ci=function(a){if(a.tag===13){var c=uo(a,134217728);if(c!==null){var p=us();Cr(c,a,134217728,p)}xg(a,134217728)}},nc=function(a){if(a.tag===13){var c=Jo(a),p=uo(a,c);if(p!==null){var w=us();Cr(p,a,c,w)}xg(a,c)}},sc=function(){return It},rc=function(a,c){var p=It;try{return It=a,c()}finally{It=p}},B=function(a,c,p){switch(c){case"input":if(Xe(a,p),c=p.name,p.type==="radio"&&c!=null){for(p=a;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<p.length;c++){var w=p[c];if(w!==a&&w.form===a.form){var _=Au(w);if(!_)throw Error(s(90));pe(w),Xe(w,_)}}}break;case"textarea":rt(a,p);break;case"select":c=p.value,c!=null&&te(a,!!p.multiple,c,!1)}},ft=dg,$n=Fa;var MR={usingClientEntryPoint:!1,Events:[wc,Mi,Au,at,qe,dg]},Mc={findFiberByHostInstance:Aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},IR={bundleType:Mc.bundleType,version:Mc.version,rendererPackageName:Mc.rendererPackageName,rendererConfig:Mc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Ge(a),a===null?null:a.stateNode},findFiberByHostInstance:Mc.findFiberByHostInstance||OR,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 xf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xf.isDisabled&&xf.supportsFiber)try{ji=xf.inject(IR),Rs=xf}catch{}}return Ss.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=MR,Ss.createPortal=function(a,c){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vg(c))throw Error(s(200));return AR(a,c,null,p)},Ss.createRoot=function(a,c){if(!vg(a))throw Error(s(299));var p=!1,w="",_=Kj;return c!=null&&(c.unstable_strictMode===!0&&(p=!0),c.identifierPrefix!==void 0&&(w=c.identifierPrefix),c.onRecoverableError!==void 0&&(_=c.onRecoverableError)),c=gg(a,1,!1,null,null,p,!1,w,_),a[ao]=c.current,bc(a.nodeType===8?a.parentNode:a),new bg(c)},Ss.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=Ge(c),a=a===null?null:a.stateNode,a},Ss.flushSync=function(a){return Fa(a)},Ss.hydrate=function(a,c,p){if(!pf(c))throw Error(s(200));return gf(null,a,c,!0,p)},Ss.hydrateRoot=function(a,c,p){if(!vg(a))throw Error(s(405));var w=p!=null&&p.hydratedSources||null,_=!1,R="",z=Kj;if(p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(R=p.identifierPrefix),p.onRecoverableError!==void 0&&(z=p.onRecoverableError)),c=qj(c,null,a,1,p??null,_,!1,R,z),a[ao]=c.current,bc(a),w)for(a=0;a<w.length;a++)p=w[a],_=p._getVersion,_=_(p._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[p,_]:c.mutableSourceEagerHydrationData.push(p,_);return new hf(c)},Ss.render=function(a,c,p){if(!pf(c))throw Error(s(200));return gf(null,a,c,!1,p)},Ss.unmountComponentAtNode=function(a){if(!pf(a))throw Error(s(40));return a._reactRootContainer?(Fa(function(){gf(null,null,a,!1,function(){a._reactRootContainer=null,a[ao]=null})}),!0):!1},Ss.unstable_batchedUpdates=dg,Ss.unstable_renderSubtreeIntoContainer=function(a,c,p,w){if(!pf(p))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return gf(a,c,p,!1,w)},Ss.version="18.3.1-next-f1338f8080-20240426",Ss}var nk;function F1(){if(nk)return jg.exports;nk=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(),jg.exports=GR(),jg.exports}var sk;function KR(){if(sk)return bf;sk=1;var e=F1();return bf.createRoot=e.createRoot,bf.hydrateRoot=e.hydrateRoot,bf}var VR=KR();function is(e){const n=e&&typeof e=="object"?e.sdk:void 0;if((n==null?void 0:n.runtime)==="external"){const s=n.platform;return typeof s=="string"&&s.length>0&&s.trim()===s&&[...s].length<=80&&!/[\u0000-\u001f\u007f-\u009f\uD800-\uDFFF]/u.test(s)?{runtime:"external",platform:s}:{runtime:"external",platform:"External platform"}}return(n==null?void 0:n.platform)===void 0&&((n==null?void 0:n.runtime)==="claude-agent-sdk"||(n==null?void 0:n.runtime)==="codex-sdk"||(n==null?void 0:n.runtime)==="eve")?{runtime:n.runtime}:void 0}const YR={"claude-agent-sdk":"Claude Agent SDK","codex-sdk":"Codex SDK",eve:"Vercel eve"},Ro=e=>e.runtime==="external"?e.platform:YR[e.runtime];/**
|
|
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 QR=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),U1=(...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 JR={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 XR=g.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:l,...d},u)=>g.createElement("svg",{ref:u,...JR,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:U1("lucide",o),...d},[...l.map(([f,h])=>g.createElement(f,h)),...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 Ae=(e,n)=>{const s=g.forwardRef(({className:r,...o},i)=>g.createElement(XR,{ref:i,iconNode:n,className:U1(`lucide-${QR(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 ZR=Ae("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 W1=Ae("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 Fd=Ae("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 eA=Ae("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
|
|
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 Wn=Ae("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
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 Ob=Ae("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
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 So=Ae("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
|
|
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 H1=Ae("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
|
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 Hm=Ae("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"}]]);/**
|
|
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 Ud=Ae("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 xd=Ae("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 Wd=Ae("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 Il=Ae("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 ui=Ae("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 B1=Ae("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=Ae("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 wl=Ae("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 tA=Ae("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 q1=Ae("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 Lb=Ae("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 nA=Ae("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 G1=Ae("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 sA=Ae("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 rA=Ae("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 Bm=Ae("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 fi=Ae("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 oA=Ae("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 aA=Ae("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 rm=Ae("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 iA=Ae("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 lA=Ae("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 qm=Ae("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 mi=Ae("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 K1=Ae("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 cA=Ae("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 Gm=Ae("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 rk=Ae("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 V1=Ae("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 dA=Ae("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 uA=Ae("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 Hd=Ae("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 Y1=Ae("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 bx=Ae("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 ti=Ae("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 Q1=Ae("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"}]]);/**
|
|
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 Km=Ae("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"}]]);/**
|
|
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 fA=Ae("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"}]]);/**
|
|
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 mA=Ae("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
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 Sg=Ae("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"}]]);/**
|
|
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 hA=Ae("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"}]]);/**
|
|
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 Vm=Ae("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"}]]);/**
|
|
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 J1=Ae("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"}]]);/**
|
|
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 pA=Ae("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"}]]);/**
|
|
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 Mb=Ae("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"}]]);/**
|
|
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 gA=Ae("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"}]]);/**
|
|
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 xA=Ae("MessageSquare",[["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"}]]);/**
|
|
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 bA=Ae("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 hi=Ae("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 vA=Ae("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 yA=Ae("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 wA=Ae("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 jl=Ae("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 Ym=Ae("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 jA=Ae("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/**
|
|
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 Ao=Ae("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
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 kA=Ae("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"}]]);/**
|
|
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 Qm=Ae("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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 NA=Ae("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"}]]);/**
|
|
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 pi=Ae("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 SA=Ae("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 Ib=Ae("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 CA=Ae("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 Jm=Ae("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 X1=Ae("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 _A=Ae("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 Z1=Ae("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 eS=Ae("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 tS=Ae("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 $A=Ae("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 EA=Ae("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 TA=Ae("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 nS=Ae("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 Hs=Ae("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 sS=Ae("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 kl=Ae("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 rS=Ae("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 va=Ae("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 vx=Ae("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 Oo=Ae("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 RA=Ae("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"}]]);/**
|
|
511
|
-
* @license lucide-react v0.468.0 - ISC
|
|
512
|
-
*
|
|
513
|
-
* This source code is licensed under the ISC license.
|
|
514
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
515
|
-
*/const AA=Ae("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
|
516
|
-
* @license lucide-react v0.468.0 - ISC
|
|
517
|
-
*
|
|
518
|
-
* This source code is licensed under the ISC license.
|
|
519
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
520
|
-
*/const OA=Ae("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function oS(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=oS(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function aS(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=oS(e))&&(r&&(r+=" "),r+=n);return r}const Pb="-",LA=e=>{const n=IA(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:l=>{const d=l.split(Pb);return d[0]===""&&d.length!==1&&d.shift(),iS(d,n)||MA(l)},getConflictingClassGroupIds:(l,d)=>{const u=s[l]||[];return d&&r[l]?[...u,...r[l]]:u}}},iS=(e,n)=>{var l;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?iS(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(Pb);return(l=n.validators.find(({validator:d})=>d(i)))==null?void 0:l.classGroupId},ok=/^\[(.+)\]$/,MA=e=>{if(ok.test(e)){const n=ok.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},IA=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return DA(Object.entries(e.classGroups),s).forEach(([i,l])=>{yx(l,r,i,n)}),r},yx=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:ak(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(PA(o)){yx(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,l])=>{yx(l,ak(n,i),s,r)})})},ak=(e,n)=>{let s=e;return n.split(Pb).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},PA=e=>e.isThemeGetter,DA=(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(([l,d])=>[n+l,d])):i);return[s,o]}):e,zA=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const o=(i,l)=>{s.set(i,l),n++,n>e&&(n=0,r=s,s=new Map)};return{get(i){let l=s.get(i);if(l!==void 0)return l;if((l=r.get(i))!==void 0)return o(i,l),l},set(i,l){s.has(i)?s.set(i,l):o(i,l)}}},lS="!",FA=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,o=n[0],i=n.length,l=d=>{const u=[];let f=0,h=0,v;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(h,j)),h=j+i;continue}if(k==="/"){v=j;continue}}k==="["?f++:k==="]"&&f--}const b=u.length===0?d:d.substring(h),m=b.startsWith(lS),x=m?b.substring(1):b,y=v&&v>h?v-h:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:x,maybePostfixModifierPosition:y}};return s?d=>s({className:d,parseClassName:l}):l},UA=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},WA=e=>({cache:zA(e.cacheSize),parseClassName:FA(e),...LA(e)}),HA=/\s+/,BA=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],l=e.trim().split(HA);let d="";for(let u=l.length-1;u>=0;u-=1){const f=l[u],{modifiers:h,hasImportantModifier:v,baseClassName:b,maybePostfixModifierPosition:m}=s(f);let x=!!m,y=r(x?b.substring(0,m):b);if(!y){if(!x){d=f+(d.length>0?" "+d:d);continue}if(y=r(b),!y){d=f+(d.length>0?" "+d:d);continue}x=!1}const j=UA(h).join(":"),k=v?j+lS:j,C=k+y;if(i.includes(C))continue;i.push(C);const N=o(y,x);for(let S=0;S<N.length;++S){const E=N[S];i.push(k+E)}d=f+(d.length>0?" "+d:d)}return d};function qA(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=cS(n))&&(r&&(r+=" "),r+=s);return r}const cS=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=cS(e[r]))&&(s&&(s+=" "),s+=n);return s};function ik(e,...n){let s,r,o,i=l;function l(u){const f=n.reduce((h,v)=>v(h),e());return s=WA(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 h=BA(u,s);return o(u,h),h}return function(){return i(qA.apply(null,arguments))}}const Zt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},dS=/^\[(?:([a-z-]+):)?(.+)\]$/i,GA=/^\d+\/\d+$/,KA=new Set(["px","full","screen"]),VA=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,YA=/\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$/,QA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,JA=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,XA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,po=e=>cl(e)||KA.has(e)||GA.test(e),ta=e=>Pl(e,"length",a3),cl=e=>!!e&&!Number.isNaN(Number(e)),Cg=e=>Pl(e,"number",cl),Pc=e=>!!e&&Number.isInteger(Number(e)),ZA=e=>e.endsWith("%")&&cl(e.slice(0,-1)),vt=e=>dS.test(e),na=e=>VA.test(e),e3=new Set(["length","size","percentage"]),t3=e=>Pl(e,e3,uS),n3=e=>Pl(e,"position",uS),s3=new Set(["image","url"]),r3=e=>Pl(e,s3,l3),o3=e=>Pl(e,"",i3),Dc=()=>!0,Pl=(e,n,s)=>{const r=dS.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},a3=e=>YA.test(e)&&!QA.test(e),uS=()=>!1,i3=e=>JA.test(e),l3=e=>XA.test(e),lk=()=>{const e=Zt("colors"),n=Zt("spacing"),s=Zt("blur"),r=Zt("brightness"),o=Zt("borderColor"),i=Zt("borderRadius"),l=Zt("borderSpacing"),d=Zt("borderWidth"),u=Zt("contrast"),f=Zt("grayscale"),h=Zt("hueRotate"),v=Zt("invert"),b=Zt("gap"),m=Zt("gradientColorStops"),x=Zt("gradientColorStopPositions"),y=Zt("inset"),j=Zt("margin"),k=Zt("opacity"),C=Zt("padding"),N=Zt("saturate"),S=Zt("scale"),E=Zt("sepia"),$=Zt("skew"),L=Zt("space"),A=Zt("translate"),P=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",vt,n],M=()=>[vt,n],F=()=>["",po,ta],I=()=>["auto",cl,vt],V=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],G=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],U=()=>["","0",vt],Q=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[cl,vt];return{cacheSize:500,separator:":",theme:{colors:[Dc],spacing:[po,ta],blur:["none","",na,vt],brightness:D(),borderColor:[e],borderRadius:["none","","full",na,vt],borderSpacing:M(),borderWidth:F(),contrast:D(),grayscale:U(),hueRotate:D(),invert:U(),gap:M(),gradientColorStops:[e],gradientColorStopPositions:[ZA,ta],inset:T(),margin:T(),opacity:D(),padding:M(),saturate:D(),scale:D(),sepia:U(),skew:D(),space:M(),translate:M()},classGroups:{aspect:[{aspect:["auto","square","video",vt]}],container:["container"],columns:[{columns:[na]}],"break-after":[{"break-after":Q()}],"break-before":[{"break-before":Q()}],"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:[...V(),vt]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],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",Pc,vt]}],basis:[{basis:T()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",vt]}],grow:[{grow:U()}],shrink:[{shrink:U()}],order:[{order:["first","last","none",Pc,vt]}],"grid-cols":[{"grid-cols":[Dc]}],"col-start-end":[{col:["auto",{span:["full",Pc,vt]},vt]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[Dc]}],"row-start-end":[{row:["auto",{span:[Pc,vt]},vt]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",vt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",vt]}],gap:[{gap:[b]}],"gap-x":[{"gap-x":[b]}],"gap-y":[{"gap-y":[b]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],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":[L]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[L]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",vt,n]}],"min-w":[{"min-w":[vt,n,"min","max","fit"]}],"max-w":[{"max-w":[vt,n,"none","full","min","max","fit","prose",{screen:[na]},na]}],h:[{h:[vt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[vt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[vt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[vt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",na,ta]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Cg]}],"font-family":[{font:[Dc]}],"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",vt]}],"line-clamp":[{"line-clamp":["none",cl,Cg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",po,vt]}],"list-image":[{"list-image":["none",vt]}],"list-style-type":[{list:["none","disc","decimal",vt]}],"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:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",po,ta]}],"underline-offset":[{"underline-offset":["auto",po,vt]}],"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:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vt]}],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",vt]}],"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:[...V(),n3]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",t3]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},r3]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],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:[...G(),"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:G()}],"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:["",...G()]}],"outline-offset":[{"outline-offset":[po,vt]}],"outline-w":[{outline:[po,ta]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[po,ta]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",na,o3]}],"shadow-color":[{shadow:[Dc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",na,vt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[v]}],saturate:[{saturate:[N]}],sepia:[{sepia:[E]}],"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":[h]}],"backdrop-invert":[{"backdrop-invert":[v]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",vt]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",vt]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",vt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[Pc,vt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[$]}],"skew-y":[{"skew-y":[$]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",vt]}],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",vt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"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",vt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[po,ta,Cg]}],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"]}}},c3=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:l={}})=>{Zc(e,"cacheSize",n),Zc(e,"prefix",s),Zc(e,"separator",r),Zc(e,"experimentalParseClassName",o);for(const d in l)d3(e[d],l[d]);for(const d in i)u3(e[d],i[d]);return e},Zc=(e,n,s)=>{s!==void 0&&(e[n]=s)},d3=(e,n)=>{if(n)for(const s in n)Zc(e,s,n[s])},u3=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},f3=(e,...n)=>typeof e=="function"?ik(lk,e,...n):ik(()=>c3(lk(),e),...n),m3=f3({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"]}]}}}),ee=(...e)=>m3(aS(e)),h3={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:bx},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:bx},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:q1},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Hs},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:wl}};function ct({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:l,children:d,...u}){const f=h3[e],h=o===!1?null:o??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:ee("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ee("border p-4",f.box),l),children:[h&&t.jsx(h,{className:ee("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:ee("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:ee(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const ck=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,dk=aS,p3=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return dk(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:i}=n,l=Object.keys(o).map(f=>{const h=s==null?void 0:s[f],v=i==null?void 0:i[f];if(h===null)return null;const b=ck(h)||ck(v);return o[f][b]}),d=s&&Object.entries(s).reduce((f,h)=>{let[v,b]=h;return b===void 0||(f[v]=b),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,h)=>{let{class:v,className:b,...m}=h;return Object.entries(m).every(x=>{let[y,j]=x;return Array.isArray(j)?j.includes({...i,...d}[y]):{...i,...d}[y]===j})?[...f,v,b]:f},[]);return dk(e,l,u,s==null?void 0:s.class,s==null?void 0:s.className)},Fs=p3("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"}}),W=g.forwardRef(({className:e,variant:n,size:s,...r},o)=>t.jsx("button",{ref:o,className:ee(Fs({variant:n,size:s}),e),...r}));W.displayName="Button";const uk={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:ee("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",uk[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:o})}):t.jsx("span",{title:s,className:ee("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",uk[e],n),children:o})}const ur=e=>g3(e)?e.document:x3(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),Xm=e=>{let n=ur(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function fS(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function g3(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function x3(e){return fS(e)&&e.nodeType===9}function b3(e){return fS(e)&&e.nodeType===11&&"host"in e}let v3=!1;function Db(){return v3}function Qa(e,n){var r;if(!Db())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:b3(s)?s=s.host:s=s.parentNode}return!1}const ma=(e=document)=>{var s;if(!Db())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 hs(e){if(Db()&&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 y3(e){e.focus({preventScroll:!0})}const w3=typeof document<"u"?Ve.useLayoutEffect:()=>{};function mS(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function j3(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function hS(e){let n=g.useRef({isFocused:!1,observer:null});return w3(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),g.useCallback(s=>{let r=hs(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let o=r,i=l=>{if(n.current.isFocused=!1,o.disabled){let d=mS(l);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 l;if(n.current.isFocused&&o.disabled){(l=n.current.observer)==null||l.disconnect();let d=o===ma()?null:ma();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 zb(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 Fb(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 gi(e){let n=null;return()=>(n==null&&(n=e()),n)}const Ub=gi(function(){return Fb(/^Mac/i)}),k3=gi(function(){return Fb(/^iPhone/i)}),pS=gi(function(){return Fb(/^iPad/i)||Ub()&&navigator.maxTouchPoints>1}),N3=gi(function(){return k3()||pS()}),S3=gi(function(){return zb(/AppleWebKit/i)&&(N3()||!C3())}),C3=gi(function(){return zb(/Chrome|CriOS|CrMo/i)}),_3=gi(function(){return zb(/Android/i)});function $3(e){return e.pointerType===""&&e.isTrusted?!0:_3()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function bd(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:l}=n,d=S3()&&Ub()&&!pS()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:o,altKey:i,shiftKey:l}):new MouseEvent("click",{metaKey:r,ctrlKey:o,altKey:i,shiftKey:l,detail:1,bubbles:!0,cancelable:!0});bd.isOpening=s,y3(e),e.dispatchEvent(d),bd.isOpening=!1}bd.isOpening=!1;let Dl=null;const wx=new Set;let od=new Map,ni=!1,Gf=!1;const E3={Tab:!0,Escape:!0};function Zm(e,n){for(let s of wx)s(e,n)}function T3(e){return!(e.metaKey||!Ub()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function om(e){ni=!0,!bd.isOpening&&T3(e)&&(Dl="keyboard",Zm("keyboard",e))}function dl(e){Dl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(ni=!0,Zm("pointer",e))}function gS(e){!bd.isOpening&&$3(e)&&(ni=!0,Dl="virtual")}function xS(e){let n=hs(e),s=Xm(n),r=ur(n);if(n===s){Gf=!0;return}n===r||!e.isTrusted||(!ni&&!Gf&&(Dl="virtual",Zm("virtual",e)),ni=!1,Gf=!1)}function bS(){ni=!1,Gf=!0}function vS(e){let n=ma(ur(hs(e)));queueMicrotask(()=>{ma(ur(hs(e)))!==n&&A3("keyboard")})}function jx(e){if(typeof window>"u"||typeof document>"u")return;const n=Xm(e),s=ur(e);if(od.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){ni=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",om,!0),s.addEventListener("keyup",om,!0),s.addEventListener("click",gS,!0),s.addEventListener("invalid",vS,!0),n.addEventListener("focus",xS,!0),n.addEventListener("blur",bS,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",dl,!0),s.addEventListener("pointermove",dl,!0),s.addEventListener("pointerup",dl,!0)),n.addEventListener("beforeunload",()=>{yS(e)},{once:!0}),od.set(n,{focus:r})}const yS=(e,n)=>{const s=Xm(e),r=ur(e);n&&r.removeEventListener("DOMContentLoaded",n),od.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:od.get(s).focus}),r.removeEventListener("keydown",om,!0),r.removeEventListener("keyup",om,!0),r.removeEventListener("click",gS,!0),r.removeEventListener("invalid",vS,!0),s.removeEventListener("focus",xS,!0),s.removeEventListener("blur",bS,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",dl,!0),r.removeEventListener("pointermove",dl,!0),r.removeEventListener("pointerup",dl,!0)),od.delete(s))};function R3(e){const n=ur(e);let s;return n.readyState!=="loading"?jx(e):(s=()=>{jx(e)},n.addEventListener("DOMContentLoaded",s)),()=>yS(e,s)}typeof document<"u"&&R3();function kx(){return Dl!=="pointer"}function A3(e){Dl=e,Zm(e,null)}const O3=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function L3(e,n,s){let r=s?hs(s):void 0,o=ur(r),i=Xm(r);const l=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 h=ma(o);return e=e||h instanceof l&&!O3.has(h.type)||h instanceof d||h instanceof u&&h.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!E3[s.key])}function M3(e,n,s){jx(),g.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{L3(!!(s!=null&&s.isTextInput),o,i)&&e(kx())};return wx.add(r),()=>{wx.delete(r)}},n)}function I3(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:o}=e;const i=g.useCallback(u=>{if(hs(u)===u.currentTarget)return r&&r(u),o&&o(!1),!0},[r,o]),l=hS(i),d=g.useCallback(u=>{let f=hs(u);const h=ur(f),v=h?ma(h):ma();f===u.currentTarget&&f===v&&(s&&s(u),o&&o(!0),l(u))},[o,s,l]);return{focusProps:{onFocus:!n&&(s||o||r)?d:void 0,onBlur:!n&&(r||o)?i:void 0}}}function wS(){let e=g.useRef(new Map),n=g.useCallback((o,i,l,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(l),l(...f)}:l;e.current.set(l,{type:i,eventTarget:o,fn:u,options:d}),o.addEventListener(i,u,d)},[]),s=g.useCallback((o,i,l,d)=>{var f;let u=((f=e.current.get(l))==null?void 0:f.fn)||l;o.removeEventListener(i,u,d),e.current.delete(l)},[]),r=g.useCallback(()=>{e.current.forEach((o,i)=>{s(o.eventTarget,o.type,i,o.options)})},[s]);return g.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function P3(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=g.useRef({isFocusWithin:!1}),{addGlobalListener:l,removeAllGlobalListeners:d}=wS(),u=g.useCallback(v=>{Qa(v.currentTarget,hs(v))&&i.current.isFocusWithin&&!Qa(v.currentTarget,v.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(v),o&&o(!1))},[s,o,i,d]),f=hS(u),h=g.useCallback(v=>{if(!Qa(v.currentTarget,hs(v)))return;let b=hs(v);const m=ur(b),x=ma(m);if(!i.current.isFocusWithin&&x===b){r&&r(v),o&&o(!0),i.current.isFocusWithin=!0,f(v);let y=v.currentTarget;l(m,"focus",j=>{let k=hs(j);if(i.current.isFocusWithin&&!Qa(y,k)){let C=new m.defaultView.FocusEvent("blur",{relatedTarget:k});j3(C,y);let N=mS(C);u(N)}},{capture:!0})}},[r,o,f,l,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:h,onBlur:u}}}function D3(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=g.useRef({isFocused:!1,isFocusVisible:n||kx()}),[i,l]=g.useState(!1),[d,u]=g.useState(()=>o.current.isFocused&&o.current.isFocusVisible),f=g.useCallback(()=>u(o.current.isFocused&&o.current.isFocusVisible),[]),h=g.useCallback(m=>{o.current.isFocused=m,o.current.isFocusVisible=kx(),l(m),f()},[f]);M3(m=>{o.current.isFocusVisible=m,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:v}=I3({isDisabled:r,onFocusChange:h}),{focusWithinProps:b}=P3({isDisabled:!r,onFocusWithinChange:h});return{isFocused:i,isFocusVisible:d,focusProps:r?b:v}}var Bs=F1();let Nx=!1,vf=0;function z3(){Nx=!0,setTimeout(()=>{Nx=!1},500)}function fk(e){e.pointerType==="touch"&&z3()}function F3(){let e=ur(null);if(!(typeof e>"u"))return vf===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",fk),vf++,()=>{vf--,!(vf>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",fk)}}function U3(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:o}=e,[i,l]=g.useState(!1),d=g.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;g.useEffect(F3,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=wS(),{hoverProps:h,triggerHoverEnd:v}=g.useMemo(()=>{let b=(y,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!Qa(y.currentTarget,hs(y)))return;d.isHovered=!0;let k=y.currentTarget;d.target=k,u(ur(hs(y)),"pointerover",C=>{d.isHovered&&d.target&&!Qa(d.target,hs(C))&&m(C,C.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),l(!0)},m=(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),l(!1))},x={};return typeof PointerEvent<"u"&&(x.onPointerEnter=y=>{Nx&&y.pointerType==="mouse"||b(y,y.pointerType)},x.onPointerLeave=y=>{!o&&Qa(y.currentTarget,hs(y))&&m(y,y.pointerType)}),{hoverProps:x,triggerHoverEnd:m}},[n,s,r,o,d,u,f]);return g.useEffect(()=>{o&&v({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:h,isHovered:i}}var W3=Object.defineProperty,H3=(e,n,s)=>n in e?W3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,_g=(e,n,s)=>(H3(e,typeof n!="symbol"?n+"":n,s),s);let B3=class{constructor(){_g(this,"current",this.detect()),_g(this,"handoffState","pending"),_g(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"}},Vr=new B3;function zl(e){var n;return Vr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function am(e){var n,s;return Vr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function jS(e){var n,s;return(s=(n=am(e))==null?void 0:n.activeElement)!=null?s:null}function kS(e){return jS(e)===e}function eh(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function Ks(){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 eh(()=>{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=Ks();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 ya(){let[e]=g.useState(Ks);return g.useEffect(()=>()=>e.dispose(),[e]),e}let cn=(e,n)=>{Vr.isServer?g.useEffect(e,n):g.useLayoutEffect(e,n)};function wa(e){let n=g.useRef(e);return cn(()=>{n.current=e},[e]),n}let mt=function(e){let n=wa(e);return Ve.useCallback((...s)=>n.current(...s),[n])};function q3(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 G3(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function K3({disabled:e=!1}={}){let n=g.useRef(null),[s,r]=g.useState(!1),o=ya(),i=mt(()=>{n.current=null,r(!1),o.dispose()}),l=mt(d=>{if(o.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=zl(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let h=q3(f);r(G3(h,n.current.getBoundingClientRect()))}},!1),o.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:l,onPointerUp:i,onClick:i}}}function fr(e){return g.useMemo(()=>e,Object.values(e))}let V3=g.createContext(void 0);function Wb(){return g.useContext(V3)}function Sx(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function xs(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,xs),r}var Nl=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Nl||{}),la=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(la||{});function Bn(){let e=Q3();return g.useCallback(n=>Y3({mergeRefs:e,...n}),[e])}function Y3({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:l,mergeRefs:d}){d=d??J3;let u=NS(n,e);if(i)return yf(u,s,r,l,d);let f=o??0;if(f&2){let{static:h=!1,...v}=u;if(h)return yf(v,s,r,l,d)}if(f&1){let{unmount:h=!0,...v}=u;return xs(h?0:1,{0(){return null},1(){return yf({...v,hidden:!0,style:{display:"none"}},s,r,l,d)}})}return yf(u,s,r,l,d)}function yf(e,n={},s,r,o){let{as:i=s,children:l,refName:d="ref",...u}=$g(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},h=typeof l=="function"?l(n):l;h=CS(h),"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 v={};if(n){let b=!1,m=[];for(let[x,y]of Object.entries(n))typeof y=="boolean"&&(b=!0),y===!0&&m.push(x.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(b){v["data-headlessui-state"]=m.join(" ");for(let x of m)v[`data-${x}`]=""}}if(ad(i)&&(Object.keys(aa(u)).length>0||Object.keys(aa(v)).length>0))if(!g.isValidElement(h)||Array.isArray(h)&&h.length>1||Z3(h)){if(Object.keys(aa(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(aa(u)).concat(Object.keys(aa(v))).map(b=>` - ${b}`).join(`
|
|
521
|
-
`),"","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(b=>` - ${b}`).join(`
|
|
522
|
-
`)].join(`
|
|
523
|
-
`))}else{let b=h.props,m=b==null?void 0:b.className,x=typeof m=="function"?(...k)=>Sx(m(...k),u.className):Sx(m,u.className),y=x?{className:x}:{},j=NS(h.props,aa($g(u,["ref"])));for(let k in v)k in j&&delete v[k];return g.cloneElement(h,Object.assign({},j,v,f,{ref:o(X3(h),f.ref)},y))}return g.createElement(i,Object.assign({},$g(u,["ref"]),!ad(i)&&f,!ad(i)&&v),h)}function Q3(){let e=g.useRef([]),n=g.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 J3(...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 NS(...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 l=s[r];for(let d of l){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;d(o,...i)}}});return n}function SS(...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 l of i)l==null||l(...o)}});return n}function _n(e){var n;return Object.assign(g.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function aa(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function $g(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function X3(e){return Ve.version.split(".")[0]>="19"?e.props.ref:e.ref}function CS(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return CS(n.value)}return e}function ad(e){return e===g.Fragment||e===Symbol.for("react.fragment")}function Z3(e){return ad(e.type)}function eO(e,n,s){let[r,o]=g.useState(s),i=e!==void 0,l=g.useRef(i),d=g.useRef(!1),u=g.useRef(!1);return i&&!l.current&&!d.current?(d.current=!0,l.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&&l.current&&!u.current&&(u.current=!0,l.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,mt(f=>(i||Bs.flushSync(()=>o(f)),n==null?void 0:n(f)))]}function tO(e){let[n]=g.useState(e);return n}function _S(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))ES(s,$S(n,r),o);return s}function $S(e,n){return e?e+"["+n+"]":n}function ES(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())ES(e,$S(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,""]):sO(s)&&!g.isValidElement(s)&&_S(s,n,e)}function nO(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 sO(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let rO="span";var Sl=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Sl||{});function oO(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 Bn()({ourProps:i,theirProps:o,slot:{},defaultTag:rO,name:"Hidden"})}let vd=_n(oO),aO=g.createContext(null);function iO({children:e}){let n=g.useContext(aO);if(!n)return Ve.createElement(Ve.Fragment,null,e);let{target:s}=n;return s?Bs.createPortal(Ve.createElement(Ve.Fragment,null,e),s):null}function lO({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,l]=g.useState(null),d=ya();return g.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Ve.createElement(iO,null,Ve.createElement(cO,{setForm:l,formId:n}),_S(e).map(([u,f])=>Ve.createElement(vd,{features:Sl.Hidden,...aa({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function cO({setForm:e,formId:n}){return g.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Ve.createElement(vd,{features:Sl.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let dO=g.createContext(void 0);function TS(){return g.useContext(dO)}function RS(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function jo(e){return RS(e)&&"tagName"in e}function qs(e){return jo(e)&&"accessKey"in e}function vo(e){return jo(e)&&"tabIndex"in e}function uO(e){return jo(e)&&"style"in e}function fO(e){return qs(e)&&e.nodeName==="IFRAME"}function AS(e){return qs(e)&&e.nodeName==="INPUT"}function mk(e){return qs(e)&&e.nodeName==="LABEL"}function mO(e){return qs(e)&&e.nodeName==="FIELDSET"}function OS(e){return qs(e)&&e.nodeName==="LEGEND"}function hO(e){return jo(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function hk(e){let n=e.parentElement,s=null;for(;n&&!mO(n);)OS(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&pO(s)?!1:r}function pO(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(OS(n))return!1;n=n.previousElementSibling}return!0}let LS=Symbol();function gO(e,n=!0){return Object.assign(e,{[LS]:n})}function ls(...e){let n=g.useRef(e);g.useEffect(()=>{n.current=e},[e]);let s=mt(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[LS]))?void 0:s}let th=g.createContext(null);th.displayName="DescriptionContext";function MS(){let e=g.useContext(th);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,MS),n}return e}function xO(){var e,n;return(n=(e=g.useContext(th))==null?void 0:e.value)!=null?n:void 0}function bO(){let[e,n]=g.useState([]);return[e.length>0?e.join(" "):void 0,g.useMemo(()=>function(s){let r=mt(i=>(n(l=>[...l,i]),()=>n(l=>{let d=l.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),o=g.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 Ve.createElement(th.Provider,{value:o},s.children)},[n])]}let vO="p";function yO(e,n){let s=g.useId(),r=Wb(),{id:o=`headlessui-description-${s}`,...i}=e,l=MS(),d=ls(n);cn(()=>l.register(o),[o,l.register]);let u=fr({...l.slot,disabled:r||!1}),f={ref:d,...l.props,id:o};return Bn()({ourProps:f,theirProps:i,slot:u,defaultTag:vO,name:l.name||"Description"})}let wO=_n(yO),IS=Object.assign(wO,{});var Rn=(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))(Rn||{});let nh=g.createContext(null);nh.displayName="LabelContext";function PS(){let e=g.useContext(nh);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,PS),n}return e}function DS(e){var n,s,r;let o=(s=(n=g.useContext(nh))==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 jO({inherit:e=!1}={}){let n=DS(),[s,r]=g.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,g.useMemo(()=>function(i){let l=mt(u=>(r(f=>[...f,u]),()=>r(f=>{let h=f.slice(),v=h.indexOf(u);return v!==-1&&h.splice(v,1),h}))),d=g.useMemo(()=>({register:l,slot:i.slot,name:i.name,props:i.props,value:i.value}),[l,i.slot,i.name,i.props,i.value]);return Ve.createElement(nh.Provider,{value:d},i.children)},[r])]}let kO="label";function NO(e,n){var s;let r=g.useId(),o=PS(),i=TS(),l=Wb(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...h}=e,v=ls(n);cn(()=>o.register(d),[d,o.register]);let b=mt(y=>{let j=y.currentTarget;if(!(y.target!==y.currentTarget&&hO(y.target))&&(mk(j)&&y.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(y),mk(j))){let k=document.getElementById(j.htmlFor);if(k){let C=k.getAttribute("disabled");if(C==="true"||C==="")return;let N=k.getAttribute("aria-disabled");if(N==="true"||N==="")return;(AS(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})}}}),m=fr({...o.slot,disabled:l||!1}),x={ref:v,...o.props,id:d,htmlFor:u,onClick:b};return f&&("onClick"in x&&(delete x.htmlFor,delete x.onClick),"onClick"in h&&delete h.onClick),Bn()({ourProps:x,theirProps:h,slot:m,defaultTag:u?kO:"div",name:o.name||"Label"})}let SO=_n(NO),CO=Object.assign(SO,{}),_O=g.createContext(()=>{});function $O({value:e,children:n}){return Ve.createElement(_O.Provider,{value:e},n)}function EO(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 TO(e=EO){return g.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 pk(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function RO(e,n,s=!1){let[r,o]=g.useState(()=>pk(n));return cn(()=>{if(!n||!e)return;let i=Ks();return i.requestAnimationFrame(function l(){i.requestAnimationFrame(l),o(d=>{let u=pk(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 zS=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(zS||{});function AO(e){let n=g.useRef(null),s=mt(o=>{n.current=o.pointerType,!hk(o.currentTarget)&&o.pointerType==="mouse"&&o.button===zS.Left&&(o.preventDefault(),e(o))}),r=mt(o=>{n.current!=="mouse"&&(hk(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let FS=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 OO=Object.defineProperty,LO=(e,n,s)=>n in e?OO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,MO=(e,n,s)=>(LO(e,n+"",s),s),US=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},tr=(e,n,s)=>(US(e,n,"read from private field"),s?s.call(e):n.get(e)),Eg=(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)},gk=(e,n,s,r)=>(US(e,n,"write to private field"),n.set(e,s),s),Hr,ed,td;let WS=class{constructor(n){Eg(this,Hr,{}),Eg(this,ed,new FS(()=>new Set)),Eg(this,td,new Set),MO(this,"disposables",Ks()),gk(this,Hr,n),Vr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return tr(this,Hr)}subscribe(n,s){if(Vr.isServer)return()=>{};let r={selector:n,callback:s,current:n(tr(this,Hr))};return tr(this,td).add(r),this.disposables.add(()=>{tr(this,td).delete(r)})}on(n,s){return Vr.isServer?()=>{}:(tr(this,ed).get(n).add(s),this.disposables.add(()=>{tr(this,ed).get(n).delete(s)}))}send(n){let s=this.reduce(tr(this,Hr),n);if(s!==tr(this,Hr)){gk(this,Hr,s);for(let r of tr(this,td)){let o=r.selector(tr(this,Hr));HS(r.current,o)||(r.current=o,r.callback(o))}for(let r of tr(this,ed).get(n.type))r(tr(this,Hr),n)}}};Hr=new WeakMap,ed=new WeakMap,td=new WeakMap;function HS(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:Tg(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:Tg(e.entries(),n.entries()):xk(e)&&xk(n)?Tg(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function Tg(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 xk(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function Rg(e){let[n,s]=e(),r=Ks();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var IO=Object.defineProperty,PO=(e,n,s)=>n in e?IO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,bk=(e,n,s)=>(PO(e,typeof n!="symbol"?n+"":n,s),s),BS=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(BS||{});let DO={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}}},zO=class qS extends WS{constructor(){super(...arguments),bk(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),bk(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new qS({stack:[]})}reduce(n,s){return xs(s.type,DO,n,s)}};const sh=new FS(()=>zO.new());var Ag={exports:{}},Og={};/**
|
|
524
|
-
* @license React
|
|
525
|
-
* use-sync-external-store-with-selector.production.js
|
|
526
|
-
*
|
|
527
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
528
|
-
*
|
|
529
|
-
* This source code is licensed under the MIT license found in the
|
|
530
|
-
* LICENSE file in the root directory of this source tree.
|
|
531
|
-
*/var vk;function FO(){if(vk)return Og;vk=1;var e=Wm();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,l=e.useMemo,d=e.useDebugValue;return Og.useSyncExternalStoreWithSelector=function(u,f,h,v,b){var m=o(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=l(function(){function j(E){if(!k){if(k=!0,C=E,E=v(E),b!==void 0&&x.hasValue){var $=x.value;if(b($,E))return N=$}return N=E}if($=N,s(C,E))return $;var L=v(E);return b!==void 0&&b($,L)?(C=E,$):(C=E,N=L)}var k=!1,C,N,S=h===void 0?null:h;return[function(){return j(f())},S===null?void 0:function(){return j(S())}]},[f,h,v,b]);var y=r(u,m[0],m[1]);return i(function(){x.hasValue=!0,x.value=y},[y]),d(y),y},Og}var yk;function UO(){return yk||(yk=1,Ag.exports=FO()),Ag.exports}var WO=UO();function ms(e,n,s=HS){return WO.useSyncExternalStoreWithSelector(mt(r=>e.subscribe(HO,r)),mt(()=>e.state),mt(()=>e.state),mt(n),s)}function HO(e){return e}function Bd(e,n){let s=g.useId(),r=sh.get(n),[o,i]=ms(r,g.useCallback(l=>[r.selectors.isTop(l,s),r.selectors.inStack(l,s)],[r,s]));return cn(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Cx=new Map,id=new Map;function wk(e){var n;let s=(n=id.get(e))!=null?n:0;return id.set(e,s+1),s!==0?()=>jk(e):(Cx.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>jk(e))}function jk(e){var n;let s=(n=id.get(e))!=null?n:1;if(s===1?id.delete(e):id.set(e,s-1),s!==1)return;let r=Cx.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Cx.delete(e))}function GS(e,{allowed:n,disallowed:s}={}){let r=Bd(e,"inert-others");cn(()=>{var o,i;if(!r)return;let l=Ks();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&l.add(wk(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=zl(u);if(!f)continue;let h=u.parentElement;for(;h&&h!==f.body;){for(let v of h.children)d.some(b=>v.contains(b))||l.add(wk(v));h=h.parentElement}}return l.dispose},[r,n,s])}function KS(e,n,s){let r=wa(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});g.useEffect(()=>{if(!e)return;let o=n===null?null:qs(n)?n:n.current;if(!o)return;let i=Ks();if(typeof ResizeObserver<"u"){let l=new ResizeObserver(()=>r.current(o));l.observe(o),i.add(()=>l.disconnect())}if(typeof IntersectionObserver<"u"){let l=new IntersectionObserver(()=>r.current(o));l.observe(o),i.add(()=>l.disconnect())}return()=>i.dispose()},[n,r,e])}let im=["[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(","),BO=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var $r=(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))($r||{}),_x=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(_x||{}),qO=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(qO||{});function VS(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(im)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function GO(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(BO)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var Hb=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Hb||{});function YS(e,n=0){var s;return e===((s=zl(e))==null?void 0:s.body)?!1:xs(n,{0(){return e.matches(im)},1(){let r=e;for(;r!==null;){if(r.matches(im))return!0;r=r.parentElement}return!1}})}var KO=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(KO||{});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 ko(e){e==null||e.focus({preventScroll:!0})}let VO=["textarea","input"].join(",");function YO(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,VO))!=null?s:!1}function QS(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 l=o.compareDocumentPosition(i);return l&Node.DOCUMENT_POSITION_FOLLOWING?-1:l&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function QO(e,n,s=e===null?document.body:am(e)){return ul(VS(s),n,{relativeTo:e})}function ul(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?am(e[0]):document:am(e),l=Array.isArray(e)?s?QS(e):e:n&64?GO(e):VS(e);o.length>0&&l.length>1&&(l=l.filter(m=>!o.some(x=>x!=null&&"current"in x?(x==null?void 0:x.current)===m:x===m))),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,l.indexOf(r))-1;if(n&4)return Math.max(0,l.indexOf(r))+1;if(n&8)return l.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},h=0,v=l.length,b;do{if(h>=v||h+v<=0)return 0;let m=u+h;if(n&16)m=(m+v)%v;else{if(m<0)return 3;if(m>=v)return 1}b=l[m],b==null||b.focus(f),h+=d}while(b!==jS(b));return n&6&&YO(b)&&b.select(),2}function JS(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function JO(){return/Android/gi.test(window.navigator.userAgent)}function kk(){return JS()||JO()}function sl(e,n,s,r){let o=wa(s);g.useEffect(()=>{if(!e)return;function i(l){o.current(l)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function XS(e,n,s,r){let o=wa(s);g.useEffect(()=>{if(!e)return;function i(l){o.current(l)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const Nk=30;function ZS(e,n,s){let r=wa(s),o=g.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let h=(function v(b){return typeof b=="function"?v(b()):Array.isArray(b)||b instanceof Set?b:[b]})(n);for(let v of h)if(v!==null&&(v.contains(f)||d.composed&&d.composedPath().includes(v)))return;return!YS(f,Hb.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=g.useRef(null);sl(e,"pointerdown",d=>{var u,f;kk()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),sl(e,"pointerup",d=>{if(kk()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let l=g.useRef({x:0,y:0});sl(e,"touchstart",d=>{l.current.x=d.touches[0].clientX,l.current.y=d.touches[0].clientY},!0),sl(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-l.current.x)>=Nk||Math.abs(u.y-l.current.y)>=Nk))return o(d,()=>vo(d.target)?d.target:null)},!0),XS(e,"blur",d=>o(d,()=>fO(window.document.activeElement)?window.document.activeElement:null),!0)}function yd(...e){return g.useMemo(()=>zl(...e),[...e])}var XO=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(XO||{});const wf={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},ZO=200,Sk=5;function e4(e,{trigger:n,action:s,close:r,select:o}){let i=g.useRef(null),l=g.useRef(null),d=g.useRef(null);sl(e&&n!==null,"pointerdown",u=>{RS(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(l.current=u.x,d.current=u.y,i.current=u.timeStamp)}),sl(e&&n!==null,"pointerup",u=>{var f,h;let v=i.current;if(v===null||(i.current=null,!vo(u.target))||Math.abs(u.x-((f=l.current)!=null?f:u.x))<Sk&&Math.abs(u.y-((h=d.current)!=null?h:u.y))<Sk)return;let b=s(u);switch(b.kind){case 0:return;case 1:{u.timeStamp-v>ZO&&(o(b.target),r());break}case 2:{r();break}}},{capture:!0})}function e2(e,n,s,r){let o=wa(s);g.useEffect(()=>{e=e??window;function i(l){o.current(l)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function t4(e,n){return g.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 n4(e){return g.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function s4(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 l=n[o].call(s,...i);l&&(s=l,r.forEach(d=>d()))}}}function r4(){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 o4(){return JS()?{before({doc:e,d:n,meta:s}){function r(o){for(let i of s().containers)for(let l of i())if(l.contains(o))return!0;return!1}n.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=Ks();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(o=window.scrollY)!=null?o:window.pageYOffset,l=null;n.addEventListener(e,"click",d=>{if(vo(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),h=e.querySelector(f);vo(h)&&!r(h)&&(l=h)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),vo(u.target)&&uO(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(vo(d.target)){if(AS(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),l&&l.isConnected&&(l.scrollIntoView({block:"nearest"}),l=null)})})}}:{}}function a4(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function Ck(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Ja=s4(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:Ks(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=Ck(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=Ck(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[o4(),r4(),a4()];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)}});Ja.subscribe(()=>{let e=Ja.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)&&Ja.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Ja.dispatch("TEARDOWN",s)}});function i4(e,n,s=()=>({containers:[]})){let r=n4(Ja),o=n?r.get(n):void 0,i=o?o.count>0:!1;return cn(()=>{if(!(!n||!e))return Ja.dispatch("PUSH",n,s),()=>Ja.dispatch("POP",n,s)},[e,n]),i}function t2(e,n,s=()=>[document.body]){let r=Bd(e,"scroll-lock");i4(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function _k(e){return[e.screenX,e.screenY]}function l4(){let e=g.useRef([-1,-1]);return{wasMoved(n){let s=_k(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=_k(n)}}}function c4(e=0){let[n,s]=g.useState(e),r=g.useCallback(u=>s(u),[]),o=g.useCallback(u=>s(f=>f|u),[]),i=g.useCallback(u=>(n&u)===u,[n]),l=g.useCallback(u=>s(f=>f&~u),[]),d=g.useCallback(u=>s(f=>f^u),[]);return{flags:n,setFlag:r,addFlag:o,hasFlag:i,removeFlag:l,toggleFlag:d}}var d4={},$k,Ek;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&(($k=process==null?void 0:d4)==null?void 0:$k.NODE_ENV)==="test"&&typeof((Ek=Element==null?void 0:Element.prototype)==null?void 0:Ek.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(`
|
|
532
|
-
`)),[]});var u4=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(u4||{});function n2(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function s2(e,n,s,r){let[o,i]=g.useState(s),{hasFlag:l,addFlag:d,removeFlag:u}=c4(e&&o?3:0),f=g.useRef(!1),h=g.useRef(!1),v=ya();return cn(()=>{var b;if(e){if(s&&i(!0),!n){s&&d(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,s),f4(n,{inFlight:f,prepare(){h.current?h.current=!1:h.current=f.current,f.current=!0,!h.current&&(s?(d(3),u(4)):(d(4),u(2)))},run(){h.current?s?(u(3),d(4)):(u(4),d(3)):s?u(1):d(1)},done(){var m;h.current&&p4(n)||(f.current=!1,u(7),s||i(!1),(m=r==null?void 0:r.end)==null||m.call(r,s))}})}},[e,s,n,v]),e?[o,{closed:l(1),enter:l(2),leave:l(4),transition:l(2)||l(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function f4(e,{prepare:n,run:s,done:r,inFlight:o}){let i=Ks();return h4(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(m4(e,r))})}),i.dispose}function m4(e,n){var s,r;let o=Ks();if(!e)return o.dispose;let i=!1;o.add(()=>{i=!0});let l=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(d=>d instanceof CSSTransition))!=null?r:[];return l.length===0?(n(),o.dispose):(Promise.allSettled(l.map(d=>d.finished)).then(()=>{i||n()}),o.dispose)}function h4(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 p4(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 Bb(e,n){let s=g.useRef([]),r=mt(e);g.useEffect(()=>{let o=[...s.current];for(let[i,l]of n.entries())if(s.current[i]!==l){let d=r(n,o);return s.current=n,d}},[r,...n])}function rh(){return typeof window<"u"}function Fl(e){return r2(e)?(e.nodeName||"").toLowerCase():"#document"}function _s(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function Lo(e){var n;return(n=(r2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function r2(e){return rh()?e instanceof Node||e instanceof _s(e).Node:!1}function Cs(e){return rh()?e instanceof Element||e instanceof _s(e).Element:!1}function ja(e){return rh()?e instanceof HTMLElement||e instanceof _s(e).HTMLElement:!1}function Tk(e){return!rh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof _s(e).ShadowRoot}function oh(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=Zr(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&o!=="inline"&&o!=="contents"}function g4(e){return/^(table|td|th)$/.test(Fl(e))}function ah(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const x4=/transform|translate|scale|rotate|perspective|filter/,b4=/paint|layout|strict|content/,Ba=e=>!!e&&e!=="none";let Lg;function qb(e){const n=Cs(e)?Zr(e):e;return Ba(n.transform)||Ba(n.translate)||Ba(n.scale)||Ba(n.rotate)||Ba(n.perspective)||!Gb()&&(Ba(n.backdropFilter)||Ba(n.filter))||x4.test(n.willChange||"")||b4.test(n.contain||"")}function v4(e){let n=si(e);for(;ja(n)&&!wd(n);){if(qb(n))return n;if(ah(n))return null;n=si(n)}return null}function Gb(){return Lg==null&&(Lg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lg}function wd(e){return/^(html|body|#document)$/.test(Fl(e))}function Zr(e){return _s(e).getComputedStyle(e)}function ih(e){return Cs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function si(e){if(Fl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Tk(e)&&e.host||Lo(e);return Tk(n)?n.host:n}function o2(e){const n=si(e);return wd(n)?(e.ownerDocument||e).body:ja(n)&&oh(n)?n:o2(n)}function jd(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=o2(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),l=_s(o);if(i){const d=$x(l);return n.concat(l,l.visualViewport||[],oh(o)?o:[],d&&s?jd(d):[])}else return n.concat(o,jd(o,[],s))}function $x(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function y4(){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 ri=Math.min,lr=Math.max,kd=Math.round,jf=Math.floor,No=e=>({x:e,y:e}),w4={left:"right",right:"left",bottom:"top",top:"bottom"};function j4(e,n,s){return lr(e,ri(n,s))}function Ul(e,n){return typeof e=="function"?e(n):e}function oi(e){return e.split("-")[0]}function qd(e){return e.split("-")[1]}function a2(e){return e==="x"?"y":"x"}function i2(e){return e==="y"?"height":"width"}function yo(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function l2(e){return a2(yo(e))}function k4(e,n,s){s===void 0&&(s=!1);const r=qd(e),o=l2(e),i=i2(o);let l=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(l=lm(l)),[l,lm(l)]}function N4(e){const n=lm(e);return[Ex(e),n,Ex(n)]}function Ex(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Rk=["left","right"],Ak=["right","left"],S4=["top","bottom"],C4=["bottom","top"];function _4(e,n,s){switch(e){case"top":case"bottom":return s?n?Ak:Rk:n?Rk:Ak;case"left":case"right":return n?S4:C4;default:return[]}}function $4(e,n,s,r){const o=qd(e);let i=_4(oi(e),s==="start",r);return o&&(i=i.map(l=>l+"-"+o),n&&(i=i.concat(i.map(Ex)))),i}function lm(e){const n=oi(e);return w4[n]+e.slice(n.length)}function E4(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 T4(e){return typeof e!="number"?E4(e):{top:e,right:e,bottom:e,left:e}}function cm(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 Ok(e,n,s){let{reference:r,floating:o}=e;const i=yo(n),l=l2(n),d=i2(l),u=oi(n),f=i==="y",h=r.x+r.width/2-o.width/2,v=r.y+r.height/2-o.height/2,b=r[d]/2-o[d]/2;let m;switch(u){case"top":m={x:h,y:r.y-o.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:v};break;case"left":m={x:r.x-o.width,y:v};break;default:m={x:r.x,y:r.y}}const x=qd(n);return x&&(m[l]+=b*(x==="end"?1:-1)*(s&&f?-1:1)),m}async function c2(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:i,rects:l,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:v="floating",altBoundary:b=!1,padding:m=0}=Ul(n,e),x=T4(m),j=d[b?v==="floating"?"reference":"floating":v],k=cm(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:h,strategy:u})),C=v==="floating"?{x:r,y:o,width:l.floating.width,height:l.floating.height}:l.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(N))&&await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1},E=cm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:C,offsetParent:N,strategy:u}):C);return{top:(k.top-E.top+x.top)/S.y,bottom:(E.bottom-k.bottom+x.bottom)/S.y,left:(k.left-E.left+x.left)/S.x,right:(E.right-k.right+x.right)/S.x}}const R4=50,A4=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:l}=s,d=l.detectOverflow?l:{...l,detectOverflow:c2},u=await(l.isRTL==null?void 0:l.isRTL(n));let f=await l.getElementRects({reference:e,floating:n,strategy:o}),{x:h,y:v}=Ok(f,r,u),b=r,m=0;const x={};for(let y=0;y<i.length;y++){const j=i[y];if(!j)continue;const{name:k,fn:C}=j,{x:N,y:S,data:E,reset:$}=await C({x:h,y:v,initialPlacement:r,placement:b,strategy:o,middlewareData:x,rects:f,platform:d,elements:{reference:e,floating:n}});h=N??h,v=S??v,x[k]={...x[k],...E},$&&m<R4&&(m++,typeof $=="object"&&($.placement&&(b=$.placement),$.rects&&(f=$.rects===!0?await l.getElementRects({reference:e,floating:n,strategy:o}):$.rects),{x:h,y:v}=Ok(f,b,u)),y=-1)}return{x:h,y:v,placement:b,strategy:o,middlewareData:x}},O4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,middlewareData:i,rects:l,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:h=!0,crossAxis:v=!0,fallbackPlacements:b,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...j}=Ul(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=oi(o),C=yo(d),N=oi(d)===d,S=await(u.isRTL==null?void 0:u.isRTL(f.floating)),E=b||(N||!y?[lm(d)]:N4(d)),$=x!=="none";!b&&$&&E.push(...$4(d,y,x,S));const L=[d,...E],A=await u.detectOverflow(n,j),P=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(h&&P.push(A[k]),v){const I=k4(o,l,S);P.push(A[I[0]],A[I[1]])}if(O=[...O,{placement:o,overflows:P}],!P.every(I=>I<=0)){var T,M;const I=(((T=i.flip)==null?void 0:T.index)||0)+1,V=L[I];if(V&&(!(v==="alignment"?C!==yo(V):!1)||O.every(H=>yo(H.placement)===C?H.overflows[0]>0:!0)))return{data:{index:I,overflows:O},reset:{placement:V}};let G=(M=O.filter(q=>q.overflows[0]<=0).sort((q,H)=>q.overflows[1]-H.overflows[1])[0])==null?void 0:M.placement;if(!G)switch(m){case"bestFit":{var F;const q=(F=O.filter(H=>{if($){const U=yo(H.placement);return U===C||U==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(U=>U>0).reduce((U,Q)=>U+Q,0)]).sort((H,U)=>H[1]-U[1])[0])==null?void 0:F[0];q&&(G=q);break}case"initialPlacement":G=d;break}if(o!==G)return{reset:{placement:G}}}return{}}}},L4=new Set(["left","top"]);async function M4(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),l=oi(s),d=qd(s),u=yo(s)==="y",f=L4.has(l)?-1:1,h=i&&u?-1:1,v=Ul(n,e);let{mainAxis:b,crossAxis:m,alignmentAxis:x}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return d&&typeof x=="number"&&(m=d==="end"?x*-1:x),u?{x:m*h,y:b*f}:{x:b*f,y:m*h}}const I4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:o,y:i,placement:l,middlewareData:d}=n,u=await M4(n,e);return l===((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:l}}}}},P4=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:l=!0,crossAxis:d=!1,limiter:u={fn:C=>{let{x:N,y:S}=C;return{x:N,y:S}}},...f}=Ul(e,n),h={x:s,y:r},v=await i.detectOverflow(n,f),b=yo(o),m=a2(b);let x=h[m],y=h[b];const j=(C,N)=>j4(N+v[C==="y"?"top":"left"],N,N-v[C==="y"?"bottom":"right"]);l&&(x=j(m,x)),d&&(y=j(b,y));const k=u.fn({...n,[m]:x,[b]:y});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[m]:l,[b]:d}}}}}},D4=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:l=()=>{},...d}=Ul(e,n),u=await o.detectOverflow(n,d),f=oi(s),h=qd(s),v=yo(s)==="y",{width:b,height:m}=r.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=h===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(y=f,x=h==="end"?"top":"bottom");const j=m-u.top-u.bottom,k=b-u.left-u.right,C=ri(m-u[x],j),N=ri(b-u[y],k),S=n.middlewareData.shift,E=!S;let $=C,L=N;S!=null&&S.enabled.x&&(L=k),S!=null&&S.enabled.y&&($=j),E&&!h&&(v?L=b-2*lr(u.left,u.right):$=m-2*lr(u.top,u.bottom)),await l({...n,availableWidth:L,availableHeight:$});const A=await o.getDimensions(i.floating);return b!==A.width||m!==A.height?{reset:{rects:!0}}:{}}}};function d2(e){const n=Zr(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=ja(e),i=o?e.offsetWidth:s,l=o?e.offsetHeight:r,d=kd(s)!==i||kd(r)!==l;return d&&(s=i,r=l),{width:s,height:r,$:d}}function Kb(e){return Cs(e)?e:e.contextElement}function fl(e){const n=Kb(e);if(!ja(n))return No(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=d2(n);let l=(i?kd(s.width):s.width)/r,d=(i?kd(s.height):s.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!d||!Number.isFinite(d))&&(d=1),{x:l,y:d}}const z4=No(0);function u2(e){const n=_s(e);return!Gb()||!n.visualViewport?z4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function F4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===_s(e)}function ai(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=Kb(e);let l=No(1);n&&(r?Cs(r)&&(l=fl(r)):l=fl(e));const d=F4(i,s,r)?u2(i):No(0);let u=(o.left+d.x)/l.x,f=(o.top+d.y)/l.y,h=o.width/l.x,v=o.height/l.y;if(i&&r){const b=_s(i),m=Cs(r)?_s(r):r;let x=b,y=$x(x);for(;y&&m!==x;){const j=fl(y),k=y.getBoundingClientRect(),C=Zr(y),N=k.left+(y.clientLeft+parseFloat(C.paddingLeft))*j.x,S=k.top+(y.clientTop+parseFloat(C.paddingTop))*j.y;u*=j.x,f*=j.y,h*=j.x,v*=j.y,u+=N,f+=S,x=_s(y),y=$x(x)}}return cm({width:h,height:v,x:u,y:f})}function lh(e,n){const s=ih(e).scrollLeft;return n?n.left+s:ai(Lo(e)).left+s}function f2(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-lh(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function U4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",l=Lo(r),d=n?ah(n.floating):!1;if(r===l||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=No(1);const h=No(0),v=ja(r);if((v||!i)&&((Fl(r)!=="body"||oh(l))&&(u=ih(r)),v)){const m=ai(r);f=fl(r),h.x=m.x+r.clientLeft,h.y=m.y+r.clientTop}const b=l&&!v&&!i?f2(l,u):No(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+h.x+b.x,y:s.y*f.y-u.scrollTop*f.y+h.y+b.y}}function W4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function H4(e){const n=ih(e),s=e.ownerDocument.body,r=lr(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=lr(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+lh(e);const l=-n.scrollTop;return Zr(s).direction==="rtl"&&(i+=lr(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:i,y:l}}const B4=25;function q4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=_s(e),i=Lo(e),l=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,h=0;if(l){const b=!Gb()||n==="fixed";r?b||(f=-l.offsetLeft,h=-l.offsetTop):(d=l.width,u=l.height,b&&(f=l.offsetLeft,h=l.offsetTop))}if(lh(i)<=0){const b=i.ownerDocument,m=b.body,x=getComputedStyle(m),y=b.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,j=Math.abs(i.clientWidth-m.clientWidth-y),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=B4&&(d-=k)}return{width:d,height:u,x:f,y:h}}function G4(e,n){const s=ai(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=fl(e),l=e.clientWidth*i.x,d=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:l,height:d,x:u,y:f}}function Lk(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=q4(e,s,n);else if(n==="document")r=H4(Lo(e));else if(Cs(n))r=G4(n,s);else{const o=u2(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return cm(r)}function K4(e,n){const s=n.get(e);if(s)return s;let r=jd(e,[],!1).filter(d=>Cs(d)&&Fl(d)!=="body"),o=null;const i=Zr(e).position==="fixed";let l=i?si(e):e;for(;Cs(l)&&!wd(l);){const d=Zr(l),u=qb(l),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(v=>v!==l):o=d,l=si(l)}return n.set(e,r),r}function V4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const l=[...s==="clippingAncestors"?ah(n)?[]:K4(n,this._c):[].concat(s),r],d=Lk(n,l[0],o);let u=d.top,f=d.right,h=d.bottom,v=d.left;for(let b=1;b<l.length;b++){const m=Lk(n,l[b],o);u=lr(m.top,u),f=ri(m.right,f),h=ri(m.bottom,h),v=lr(m.left,v)}return{width:f-v,height:h-u,x:v,y:u}}function Y4(e){const{width:n,height:s}=d2(e);return{width:n,height:s}}function Q4(e,n,s){const r=ja(n),o=Lo(n),i=s==="fixed",l=ai(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=No(0);if((r||!i)&&((Fl(n)!=="body"||oh(o))&&(d=ih(n)),r)){const b=ai(n,!0,i,n);u.x=b.x+n.clientLeft,u.y=b.y+n.clientTop}!r&&o&&(u.x=lh(o));const f=o&&!r&&!i?f2(o,d):No(0),h=l.left+d.scrollLeft-u.x-f.x,v=l.top+d.scrollTop-u.y-f.y;return{x:h,y:v,width:l.width,height:l.height}}function Mg(e){return Zr(e).position==="static"}function Mk(e,n){if(!ja(e)||Zr(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return Lo(e)===s&&(s=s.ownerDocument.body),s}function m2(e,n){const s=_s(e);if(ah(e))return s;if(!ja(e)){let o=si(e);for(;o&&!wd(o);){if(Cs(o)&&!Mg(o))return o;o=si(o)}return s}let r=Mk(e,n);for(;r&&g4(r)&&Mg(r);)r=Mk(r,n);return r&&wd(r)&&Mg(r)&&!qb(r)?s:r||v4(e)||s}const J4=async function(e){const n=this.getOffsetParent||m2,s=this.getDimensions,r=await s(e.floating);return{reference:Q4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function X4(e){return Zr(e).direction==="rtl"}const Z4={convertOffsetParentRelativeRectToViewportRelativeRect:U4,getDocumentElement:Lo,getClippingRect:V4,getOffsetParent:m2,getElementRects:J4,getClientRects:W4,getDimensions:Y4,getScale:fl,isElement:Cs,isRTL:X4};function h2(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function eL(e,n,s){let r=null,o;const i=Lo(e);function l(){var h;clearTimeout(o),(h=r)==null||h.disconnect(),r=null}function d(h,v){h===void 0&&(h=!1),v===void 0&&(v=1),l();const b=e.getBoundingClientRect(),{left:m,top:x,width:y,height:j}=b;if(h||n(),!y||!j)return;const k=jf(x),C=jf(i.clientWidth-(m+y)),N=jf(i.clientHeight-(x+j)),S=jf(m),$={rootMargin:-k+"px "+-C+"px "+-N+"px "+-S+"px",threshold:lr(0,ri(1,v))||1};let L=!0;function A(P){const O=P[0].intersectionRatio;if(!h2(b,e.getBoundingClientRect()))return d();if(O!==v){if(!L)return d();O?d(!1,O):o=setTimeout(()=>{d(!1,1e-7)},1e3)}L=!1}try{r=new IntersectionObserver(A,{...$,root:i.ownerDocument})}catch{r=new IntersectionObserver(A,$)}r.observe(e)}const u=_s(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),l()}}function tL(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Kb(e),h=o||i?[...f?jd(f):[],...n?jd(n):[]]:[];h.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const v=f&&d?eL(f,s,i):null;let b=-1,m=null;l&&(m=new ResizeObserver(k=>{let[C]=k;C&&C.target===f&&m&&n&&(m.unobserve(n),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var N;(N=m)==null||N.observe(n)})),s()}),f&&!u&&m.observe(f),n&&m.observe(n));let x,y=u?ai(e):null;u&&j();function j(){const k=ai(e);y&&!h2(y,k)&&s(),y=k,x=requestAnimationFrame(j)}return s(),()=>{var k;h.forEach(C=>{o&&C.removeEventListener("scroll",s),i&&C.removeEventListener("resize",s)}),v==null||v(),(k=m)==null||k.disconnect(),m=null,u&&cancelAnimationFrame(x)}}const Ig=c2,nL=I4,sL=P4,rL=O4,oL=D4,aL=(e,n,s)=>{const r=new Map,o=s??{},i={...Z4,...o.platform,_c:r};return A4(e,n,{...o,platform:i})};var iL=typeof document<"u",lL=function(){},Kf=iL?g.useLayoutEffect:lL;function dm(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(!dm(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)&&!dm(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function p2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ik(e,n){const s=p2(e);return Math.round(n*s)/s}function Pg(e){const n=g.useRef(e);return Kf(()=>{n.current=e}),n}function cL(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:l}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[h,v]=g.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[b,m]=g.useState(r);dm(b,r)||m(r);const[x,y]=g.useState(null),[j,k]=g.useState(null),C=g.useCallback(H=>{H!==$.current&&($.current=H,y(H))},[]),N=g.useCallback(H=>{H!==L.current&&(L.current=H,k(H))},[]),S=i||x,E=l||j,$=g.useRef(null),L=g.useRef(null),A=g.useRef(h),P=u!=null,O=Pg(u),T=Pg(o),M=Pg(f),F=g.useCallback(()=>{if(!$.current||!L.current)return;const H={placement:n,strategy:s,middleware:b};T.current&&(H.platform=T.current),aL($.current,L.current,H).then(U=>{const Q={...U,isPositioned:M.current!==!1};I.current&&!dm(A.current,Q)&&(A.current=Q,Bs.flushSync(()=>{v(Q)}))})},[b,n,s,T,M]);Kf(()=>{f===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,v(H=>({...H,isPositioned:!1})))},[f]);const I=g.useRef(!1);Kf(()=>(I.current=!0,()=>{I.current=!1}),[]),Kf(()=>{if(S&&($.current=S),E&&(L.current=E),S&&E){if(O.current)return O.current(S,E,F);F()}},[S,E,F,O,P]);const V=g.useMemo(()=>({reference:$,floating:L,setReference:C,setFloating:N}),[C,N]),G=g.useMemo(()=>({reference:S,floating:E}),[S,E]),q=g.useMemo(()=>{const H={position:s,left:0,top:0};if(!G.floating)return H;const U=Ik(G.floating,h.x),Q=Ik(G.floating,h.y);return d?{...H,transform:"translate("+U+"px, "+Q+"px)",...p2(G.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:U,top:Q}},[s,d,G.floating,h.x,h.y]);return g.useMemo(()=>({...h,update:F,refs:V,elements:G,floatingStyles:q}),[h,F,V,G,q])}const g2=(e,n)=>{const s=nL(e);return{name:s.name,fn:s.fn,options:[e,n]}},dL=(e,n)=>{const s=sL(e);return{name:s.name,fn:s.fn,options:[e,n]}},uL=(e,n)=>{const s=rL(e);return{name:s.name,fn:s.fn,options:[e,n]}},fL=(e,n)=>{const s=oL(e);return{name:s.name,fn:s.fn,options:[e,n]}},x2={...xx},mL=x2.useInsertionEffect,hL=mL||(e=>e());function b2(e){const n=g.useRef(()=>{});return hL(()=>{n.current=e}),g.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 Tx=typeof document<"u"?g.useLayoutEffect:g.useEffect;let Pk=!1,pL=0;const Dk=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+pL++;function gL(){const[e,n]=g.useState(()=>Pk?Dk():void 0);return Tx(()=>{e==null&&n(Dk())},[]),g.useEffect(()=>{Pk=!0},[]),e}const xL=x2.useId,bL=xL||gL;function vL(){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 yL=g.createContext(null),wL=g.createContext(null),jL=()=>{var e;return((e=g.useContext(yL))==null?void 0:e.id)||null},kL=()=>g.useContext(wL),NL="data-floating-ui-focusable";function SL(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=bL(),i=g.useRef({}),[l]=g.useState(()=>vL()),d=jL()!=null,[u,f]=g.useState(r.reference),h=b2((m,x,y)=>{i.current.openEvent=m?x:void 0,l.emit("openchange",{open:m,event:x,reason:y,nested:d}),s==null||s(m,x,y)}),v=g.useMemo(()=>({setPositionReference:f}),[]),b=g.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return g.useMemo(()=>({dataRef:i,open:n,onOpenChange:h,elements:b,events:l,floatingId:o,refs:v}),[n,h,b,l,o,v])}function CL(e){e===void 0&&(e={});const{nodeId:n}=e,s=SL({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,o=r.elements,[i,l]=g.useState(null),[d,u]=g.useState(null),h=(o==null?void 0:o.domReference)||i,v=g.useRef(null),b=kL();Tx(()=>{h&&(v.current=h)},[h]);const m=cL({...e,elements:{...o,...d&&{reference:d}}}),x=g.useCallback(N=>{const S=Cs(N)?{getBoundingClientRect:()=>N.getBoundingClientRect(),contextElement:N}:N;u(S),m.refs.setReference(S)},[m.refs]),y=g.useCallback(N=>{(Cs(N)||N===null)&&(v.current=N,l(N)),(Cs(m.refs.reference.current)||m.refs.reference.current===null||N!==null&&!Cs(N))&&m.refs.setReference(N)},[m.refs]),j=g.useMemo(()=>({...m.refs,setReference:y,setPositionReference:x,domReference:v}),[m.refs,y,x]),k=g.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),C=g.useMemo(()=>({...m,...r,refs:j,elements:k,nodeId:n}),[m,j,k,n,r]);return Tx(()=>{r.dataRef.current.floatingContext=C;const N=b==null?void 0:b.nodesRef.current.find(S=>S.id===n);N&&(N.context=C)}),g.useMemo(()=>({...m,context:C,refs:j,elements:k}),[m,j,k,C])}const zk="active",Fk="selected";function Dg(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[zk]:l,[Fk]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[NL]:""},...i,...n.map(l=>{const d=l?l[s]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((l,d)=>(d&&Object.entries(d).forEach(u=>{let[f,h]=u;if(!(o&&[zk,Fk].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof h=="function"){var v;(v=r.get(f))==null||v.push(h),l[f]=function(){for(var b,m=arguments.length,x=new Array(m),y=0;y<m;y++)x[y]=arguments[y];return(b=r.get(f))==null?void 0:b.map(j=>j(...x)).find(j=>j!==void 0)}}}else l[f]=h}),l),{})}}function _L(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=g.useCallback(d=>Dg(d,e,"reference"),n),i=g.useCallback(d=>Dg(d,e,"floating"),s),l=g.useCallback(d=>Dg(d,e,"item"),r);return g.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:l}),[o,i,l])}function Uk(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const $L=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:o,offset:i=0,index:l=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...h}=Ul(e,n),{rects:v,elements:{floating:b}}=n,m=s.current[l],x=(f==null?void 0:f.current)||b,y=b.clientTop||x.clientTop,j=b.clientTop!==0,k=x.clientTop!==0,C=b===x;if(!m)return{};const N={...n,...await g2(-m.offsetTop-b.clientTop-v.reference.height/2-m.offsetHeight/2-i).fn(n)},S=await Ig(Uk(N,x.scrollHeight+y+b.clientTop),h),E=await Ig(N,{...h,elementContext:"reference"}),$=lr(0,S.top),L=N.y+$,O=(x.scrollHeight>x.clientHeight?T=>T:kd)(lr(0,x.scrollHeight+(j&&C||k?y*2:0)-$-lr(0,S.bottom)));if(x.style.maxHeight=O+"px",x.scrollTop=$,o){const T=x.offsetHeight<m.offsetHeight*ri(d,s.current.length)-1||E.top>=-u||E.bottom>=-u;Bs.flushSync(()=>o(T))}return r&&(r.current=await Ig(Uk({...N,y:L},x.offsetHeight+y+b.clientTop),h)),{y:L}}});function EL(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:l,onChange:d}=n,u=b2(d),f=g.useRef(!1),h=g.useRef(null),v=g.useRef(null);g.useEffect(()=>{if(!o)return;function m(y){if(y.ctrlKey||!x||i.current==null)return;const j=y.deltaY,k=i.current.top>=-.5,C=i.current.bottom>=-.5,N=x.scrollHeight-x.clientHeight,S=j<0?-1:1,E=j<0?"max":"min";x.scrollHeight<=x.clientHeight||(!k&&j>0||!C&&j<0?(y.preventDefault(),Bs.flushSync(()=>{u($=>$+Math[E](j,N*S))})):/firefox/i.test(y4())&&(x.scrollTop+=j))}const x=(l==null?void 0:l.current)||r.floating;if(s&&x)return x.addEventListener("wheel",m),requestAnimationFrame(()=>{h.current=x.scrollTop,i.current!=null&&(v.current={...i.current})}),()=>{h.current=null,v.current=null,x.removeEventListener("wheel",m)}},[o,s,r.floating,i,l,u]);const b=g.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const m=(l==null?void 0:l.current)||r.floating;if(!(!i.current||!m||!f.current)){if(h.current!==null){const x=m.scrollTop-h.current;(i.current.bottom<-.5&&x<-1||i.current.top<-.5&&x>1)&&Bs.flushSync(()=>u(y=>y+x))}requestAnimationFrame(()=>{h.current=m.scrollTop})}}}),[r.floating,u,i,l]);return g.useMemo(()=>o?{floating:b}:{},[o,b])}let Wl=g.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Wl.displayName="FloatingContext";let Vb=g.createContext(null);Vb.displayName="PlacementContext";function TL(e){return g.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function RL(){return g.useContext(Wl).setReference}function AL(){return g.useContext(Wl).getReferenceProps}function OL(){let{getFloatingProps:e,slot:n}=g.useContext(Wl);return g.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function LL(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=g.useContext(Vb),s=g.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var l;return(l=i==null?void 0:i.outerHTML)!=null?l:i})]);cn(()=>{n==null||n(s??null)},[n,s]);let r=g.useContext(Wl);return g.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Wk=4;function ML({children:e,enabled:n=!0}){let[s,r]=g.useState(null),[o,i]=g.useState(0),l=g.useRef(null),[d,u]=g.useState(null);IL(d);let f=n&&s!==null&&d!==null,{to:h="bottom",gap:v=0,offset:b=0,padding:m=0,inner:x}=PL(s,d),[y,j="center"]=h.split(" ");cn(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:C,context:N}=CL({open:f,placement:y==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${y}`:`${y}-${j}`,strategy:"absolute",transform:!1,middleware:[g2({mainAxis:y==="selection"?0:v,crossAxis:b}),dL({padding:m}),y!=="selection"&&uL({padding:m}),y==="selection"&&x?$L({...x,padding:m,overflowRef:l,offset:o,minItemsVisible:Wk,referenceOverflowThreshold:m,onFallbackChange(T){var M,F;if(!T)return;let I=N.elements.floating;if(!I)return;let V=parseFloat(getComputedStyle(I).scrollPaddingBottom)||0,G=Math.min(Wk,I.childElementCount),q=0,H=0;for(let U of(F=(M=N.elements.floating)==null?void 0:M.childNodes)!=null?F:[])if(qs(U)){let Q=U.offsetTop,D=Q+U.clientHeight+V,Y=I.scrollTop,K=Y+I.clientHeight;if(Q>=Y&&D<=K)G--;else{H=Math.max(0,Math.min(D,K)-Math.max(Q,Y)),q=U.clientHeight;break}}G>=1&&i(U=>{let Q=q*G-H+V;return U>=Q?U:Q})}}):null,fL({padding:m,apply({availableWidth:T,availableHeight:M,elements:F}){Object.assign(F.floating.style,{overflow:"auto",maxWidth:`${T}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${M}px)`})}})].filter(Boolean),whileElementsMounted:tL}),[S=y,E=j]=N.placement.split("-");y==="selection"&&(S="selection");let $=g.useMemo(()=>({anchor:[S,E].filter(Boolean).join(" ")}),[S,E]),L=EL(N,{overflowRef:l,onChange:i}),{getReferenceProps:A,getFloatingProps:P}=_L([L]),O=mt(T=>{u(T),k.setFloating(T)});return g.createElement(Vb.Provider,{value:r},g.createElement(Wl.Provider,{value:{setFloating:O,setReference:k.setReference,styles:C,getReferenceProps:A,getFloatingProps:P,slot:$}},e))}function IL(e){cn(()=>{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 PL(e,n){var s,r,o;let i=zg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),l=zg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=zg((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:l,padding:d}}function zg(e,n,s=void 0){let r=ya(),o=mt((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 h=Hk(u,f);return[h,v=>{let b=v2(u);{let m=b.map(x=>window.getComputedStyle(f).getPropertyValue(x));r.requestAnimationFrame(function x(){r.nextFrame(x);let y=!1;for(let[k,C]of b.entries()){let N=window.getComputedStyle(f).getPropertyValue(C);if(m[k]!==N){m[k]=N,y=!0;break}}if(!y)return;let j=Hk(u,f);h!==j&&(v(j),h=j)})}return r.dispose}]}return[s,null]}),i=g.useMemo(()=>o(e,n)[0],[e,n]),[l=i,d]=g.useState();return cn(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),l}function v2(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,...v2(o)]:[r]}return[]}function Hk(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 DL({children:e,freeze:n},s){let r=y2(n,e);return g.isValidElement(r)?g.cloneElement(r,{ref:s}):Ve.createElement(Ve.Fragment,null,r)}Ve.forwardRef(DL);function y2(e,n){let[s,r]=g.useState(n);return!e&&s!==n&&r(n),e?s:n}let ch=g.createContext(null);ch.displayName="OpenClosedContext";var ps=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(ps||{});function Gd(){return g.useContext(ch)}function w2({value:e,children:n}){return Ve.createElement(ch.Provider,{value:e},n)}function zL({children:e}){return Ve.createElement(ch.Provider,{value:null},e)}function FL(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let ia=[];FL(()=>{function e(n){if(!vo(n.target)||n.target===document.body||ia[0]===n.target)return;let s=n.target;s=s.closest(im),ia.unshift(s??n.target),ia=ia.filter(r=>r!=null&&r.isConnected),ia.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 UL(e){throw new Error("Unexpected object: "+e)}var mn=(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))(mn||{});function kf(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:UL(e)}}function Yb(e){let n=mt(e),s=g.useRef(!1);g.useEffect(()=>(s.current=!1,()=>{s.current=!0,eh(()=>{s.current&&n()})}),[n])}function WL(){let e=typeof document>"u";return"useSyncExternalStore"in xx?(n=>n.useSyncExternalStore)(xx)(()=>()=>{},()=>!1,()=>!e):!1}function Kd(){let e=WL(),[n,s]=g.useState(Vr.isHandoffComplete);return n&&Vr.isHandoffComplete===!1&&s(!1),g.useEffect(()=>{n!==!0&&s(!0)},[n]),g.useEffect(()=>Vr.handoff(),[]),e?!1:n}let j2=g.createContext(!1);function HL(){return g.useContext(j2)}function Bk(e){return Ve.createElement(j2.Provider,{value:e.force},e.children)}function BL(e){let n=HL(),s=g.useContext(N2),[r,o]=g.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Vr.isServer)return null;let l=e==null?void 0:e.getElementById("headlessui-portal-root");if(l)return l;if(e===null)return null;let d=e.createElement("div");return d.setAttribute("id","headlessui-portal-root"),e.body.appendChild(d)});return g.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),g.useEffect(()=>{n||s!==null&&o(s.current)},[s,o,n]),r}let k2=g.Fragment,qL=_n(function(e,n){let{ownerDocument:s=null,...r}=e,o=g.useRef(null),i=ls(gO(m=>{o.current=m}),n),l=yd(o.current),d=s??l,u=BL(d),f=g.useContext(Rx),h=ya(),v=Kd(),b=Bn();return Yb(()=>{var m;u&&u.childNodes.length<=0&&((m=u.parentElement)==null||m.removeChild(u))}),!u||!v?null:Bs.createPortal(Ve.createElement("div",{"data-headlessui-portal":"",ref:m=>{h.dispose(),f&&m&&h.add(f.register(m))}},b({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:k2,name:"Portal"})),u)});function GL(e,n){let s=ls(n),{enabled:r=!0,ownerDocument:o,...i}=e,l=Bn();return r?Ve.createElement(qL,{...i,ownerDocument:o,ref:s}):l({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:k2,name:"Portal"})}let KL=g.Fragment,N2=g.createContext(null);function VL(e,n){let{target:s,...r}=e,o={ref:ls(n)},i=Bn();return Ve.createElement(N2.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:KL,name:"Popover.Group"}))}let Rx=g.createContext(null);function YL(){let e=g.useContext(Rx),n=g.useRef([]),s=mt(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=mt(i=>{let l=n.current.indexOf(i);l!==-1&&n.current.splice(l,1),e&&e.unregister(i)}),o=g.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,g.useMemo(()=>function({children:i}){return Ve.createElement(Rx.Provider,{value:o},i)},[o])]}let QL=_n(GL),S2=_n(VL),C2=Object.assign(QL,{Group:S2});const Vf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function _2(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function JL(e,n,s){let r=Ks();if(n.kind==="Tracked"){let o=function(){i!==_2(e)&&(r.dispose(),s())},{position:i}=n,l=new ResizeObserver(o);l.observe(e),r.add(()=>l.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}function XL(e,n=typeof document<"u"?document.defaultView:null,s){let r=Bd(e,"escape");e2(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===Rn.Escape&&s(o))})}function ZL(){var e;let[n]=g.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=g.useState((e=n==null?void 0:n.matches)!=null?e:!1);return cn(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function eM({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=mt(()=>{var o,i;let l=zl(s),d=[];for(let u of e)u!==null&&(jo(u)?d.push(u):"current"in u&&jo(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=l==null?void 0:l.querySelectorAll("html > *, body > *"))!=null?o:[])u!==document.body&&u!==document.head&&jo(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:mt(o=>r().some(i=>i.contains(o)))}}let $2=g.createContext(null);function qk({children:e,node:n}){let[s,r]=g.useState(null),o=E2(n??s);return Ve.createElement($2.Provider,{value:o},e,o===null&&Ve.createElement(vd,{features:Sl.Hidden,ref:i=>{var l,d;if(i){for(let u of(d=(l=zl(i))==null?void 0:l.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&jo(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function E2(e=null){var n;return(n=g.useContext($2))!=null?n:e}function Qb(){let e=g.useRef(!1);return cn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var nd=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(nd||{});function tM(){let e=g.useRef(0);return XS(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function T2(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)jo(s.current)&&n.add(s.current);return n}let nM="div";var Ka=(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))(Ka||{});function sM(e,n){let s=g.useRef(null),r=ls(s,n),{initialFocus:o,initialFocusFallback:i,containers:l,features:d=15,...u}=e;Kd()||(d=0);let f=yd(s.current);iM(d,{ownerDocument:f});let h=lM(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});cM(d,{ownerDocument:f,container:s,containers:l,previousActiveElement:h});let v=tM(),b=mt(C=>{if(!qs(s.current))return;let N=s.current;(S=>S())(()=>{xs(v.current,{[nd.Forwards]:()=>{ul(N,$r.First,{skipElements:[C.relatedTarget,i]})},[nd.Backwards]:()=>{ul(N,$r.Last,{skipElements:[C.relatedTarget,i]})}})})}),m=Bd(!!(d&2),"focus-trap#tab-lock"),x=ya(),y=g.useRef(!1),j={ref:r,onKeyDown(C){C.key=="Tab"&&(y.current=!0,x.requestAnimationFrame(()=>{y.current=!1}))},onBlur(C){if(!(d&4))return;let N=T2(l);qs(s.current)&&N.add(s.current);let S=C.relatedTarget;vo(S)&&S.dataset.headlessuiFocusGuard!=="true"&&(R2(N,S)||(y.current?ul(s.current,xs(v.current,{[nd.Forwards]:()=>$r.Next,[nd.Backwards]:()=>$r.Previous})|$r.WrapAround,{relativeTo:C.target}):vo(C.target)&&ko(C.target)))}},k=Bn();return Ve.createElement(Ve.Fragment,null,m&&Ve.createElement(vd,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Sl.Focusable}),k({ourProps:j,theirProps:u,defaultTag:nM,name:"FocusTrap"}),m&&Ve.createElement(vd,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Sl.Focusable}))}let rM=_n(sM),oM=Object.assign(rM,{features:Ka});function aM(e=!0){let n=g.useRef(ia.slice());return Bb(([s],[r])=>{r===!0&&s===!1&&eh(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=ia.slice())},[e,ia,n]),mt(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function iM(e,{ownerDocument:n}){let s=!!(e&8),r=aM(s);Bb(()=>{s||kS(n==null?void 0:n.body)&&ko(r())},[s]),Yb(()=>{s&&ko(r())})}function lM(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=g.useRef(null),l=Bd(!!(e&1),"focus-trap#initial-focus"),d=Qb();return Bb(()=>{if(e===0)return;if(!l){o!=null&&o.current&&ko(o.current);return}let u=s.current;u&&eh(()=>{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)ko(r.current);else{if(e&16){if(ul(u,$r.First|$r.AutoFocus)!==_x.Error)return}else if(ul(u,$r.First)!==_x.Error)return;if(o!=null&&o.current&&(ko(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,l,e]),i}function cM(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=Qb(),l=!!(e&4);e2(n==null?void 0:n.defaultView,"focus",d=>{if(!l||!i.current)return;let u=T2(r);qs(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let h=d.target;qs(h)?R2(u,h)?(o.current=h,ko(h)):(d.preventDefault(),d.stopPropagation(),ko(f)):ko(o.current)},!0)}function R2(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function A2(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!ad((n=e.as)!=null?n:L2)||Ve.Children.count(e.children)===1}let dh=g.createContext(null);dh.displayName="TransitionContext";var dM=(e=>(e.Visible="visible",e.Hidden="hidden",e))(dM||{});function uM(){let e=g.useContext(dh);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function fM(){let e=g.useContext(uh);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let uh=g.createContext(null);uh.displayName="NestingContext";function fh(e){return"children"in e?fh(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function O2(e,n){let s=wa(e),r=g.useRef([]),o=Qb(),i=ya(),l=mt((m,x=la.Hidden)=>{let y=r.current.findIndex(({el:j})=>j===m);y!==-1&&(xs(x,{[la.Unmount](){r.current.splice(y,1)},[la.Hidden](){r.current[y].state="hidden"}}),i.microTask(()=>{var j;!fh(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=mt(m=>{let x=r.current.find(({el:y})=>y===m);return x?x.state!=="visible"&&(x.state="visible"):r.current.push({el:m,state:"visible"}),()=>l(m,la.Unmount)}),u=g.useRef([]),f=g.useRef(Promise.resolve()),h=g.useRef({enter:[],leave:[]}),v=mt((m,x,y)=>{u.current.splice(0),n&&(n.chains.current[x]=n.chains.current[x].filter(([j])=>j!==m)),n==null||n.chains.current[x].push([m,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[x].push([m,new Promise(j=>{Promise.all(h.current[x].map(([k,C])=>C)).then(()=>j())})]),x==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>y(x)):y(x)}),b=mt((m,x,y)=>{Promise.all(h.current[x].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>y(x))});return g.useMemo(()=>({children:r,register:d,unregister:l,onStart:v,onStop:b,wait:f,chains:h}),[d,l,r,v,b,h,f])}let L2=g.Fragment,M2=Nl.RenderStrategy;function mM(e,n){var s,r;let{transition:o=!0,beforeEnter:i,afterEnter:l,beforeLeave:d,afterLeave:u,enter:f,enterFrom:h,enterTo:v,entered:b,leave:m,leaveFrom:x,leaveTo:y,...j}=e,[k,C]=g.useState(null),N=g.useRef(null),S=A2(e),E=ls(...S?[N,n,C]:n===null?[]:[n]),$=(s=j.unmount)==null||s?la.Unmount:la.Hidden,{show:L,appear:A,initial:P}=uM(),[O,T]=g.useState(L?"visible":"hidden"),M=fM(),{register:F,unregister:I}=M;cn(()=>F(N),[F,N]),cn(()=>{if($===la.Hidden&&N.current){if(L&&O!=="visible"){T("visible");return}return xs(O,{hidden:()=>I(N),visible:()=>F(N)})}},[O,N,F,I,L,$]);let V=Kd();cn(()=>{if(S&&V&&O==="visible"&&N.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[N,O,V,S]);let G=P&&!A,q=A&&L&&P,H=g.useRef(!1),U=O2(()=>{H.current||(T("hidden"),I(N))},M),Q=mt(Ne=>{H.current=!0;let he=Ne?"enter":"leave";U.onStart(N,he,ve=>{ve==="enter"?i==null||i():ve==="leave"&&(d==null||d())})}),D=mt(Ne=>{let he=Ne?"enter":"leave";H.current=!1,U.onStop(N,he,ve=>{ve==="enter"?l==null||l():ve==="leave"&&(u==null||u())}),he==="leave"&&!fh(U)&&(T("hidden"),I(N))});g.useEffect(()=>{S&&o||(Q(L),D(L))},[L,S,o]);let Y=!(!o||!S||!V||G),[,K]=s2(Y,k,L,{start:Q,end:D}),Z=aa({ref:E,className:((r=Sx(j.className,q&&f,q&&h,K.enter&&f,K.enter&&K.closed&&h,K.enter&&!K.closed&&v,K.leave&&m,K.leave&&!K.closed&&x,K.leave&&K.closed&&y,!K.transition&&L&&b))==null?void 0:r.trim())||void 0,...n2(K)}),se=0;O==="visible"&&(se|=ps.Open),O==="hidden"&&(se|=ps.Closed),L&&O==="hidden"&&(se|=ps.Opening),!L&&O==="visible"&&(se|=ps.Closing);let ie=Bn();return Ve.createElement(uh.Provider,{value:U},Ve.createElement(w2,{value:se},ie({ourProps:Z,theirProps:j,defaultTag:L2,features:M2,visible:O==="visible",name:"Transition.Child"})))}function hM(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,l=g.useRef(null),d=A2(e),u=ls(...d?[l,n]:n===null?[]:[n]);Kd();let f=Gd();if(s===void 0&&f!==null&&(s=(f&ps.Open)===ps.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,v]=g.useState(s?"visible":"hidden"),b=O2(()=>{s||v("hidden")}),[m,x]=g.useState(!0),y=g.useRef([s]);cn(()=>{m!==!1&&y.current[y.current.length-1]!==s&&(y.current.push(s),x(!1))},[y,s]);let j=g.useMemo(()=>({show:s,appear:r,initial:m}),[s,r,m]);cn(()=>{s?v("visible"):!fh(b)&&l.current!==null&&v("hidden")},[s,b]);let k={unmount:o},C=mt(()=>{var E;m&&x(!1),(E=e.beforeEnter)==null||E.call(e)}),N=mt(()=>{var E;m&&x(!1),(E=e.beforeLeave)==null||E.call(e)}),S=Bn();return Ve.createElement(uh.Provider,{value:b},Ve.createElement(dh.Provider,{value:j},S({ourProps:{...k,as:g.Fragment,children:Ve.createElement(I2,{ref:u,...k,...i,beforeEnter:C,beforeLeave:N})},theirProps:{},defaultTag:g.Fragment,features:M2,visible:h==="visible",name:"Transition"})))}function pM(e,n){let s=g.useContext(dh)!==null,r=Gd()!==null;return Ve.createElement(Ve.Fragment,null,!s&&r?Ve.createElement(Ax,{ref:n,...e}):Ve.createElement(I2,{ref:n,...e}))}let Ax=_n(hM),I2=_n(mM),Jb=_n(pM),gM=Object.assign(Ax,{Child:Jb,Root:Ax});var xM=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(xM||{}),bM=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(bM||{});let vM={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},Xb=g.createContext(null);Xb.displayName="DialogContext";function mh(e){let n=g.useContext(Xb);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,mh),s}return n}function yM(e,n){return xs(n.type,vM,e,n)}let Gk=_n(function(e,n){let s=g.useId(),{id:r=`headlessui-dialog-${s}`,open:o,onClose:i,initialFocus:l,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:h=!1,...v}=e,b=g.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(b.current||(b.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let m=Gd();o===void 0&&m!==null&&(o=(m&ps.Open)===ps.Open);let x=g.useRef(null),y=ls(x,n),j=yd(x.current),k=o?0:1,[C,N]=g.useReducer(yM,{titleId:null,descriptionId:null,panelRef:g.createRef()}),S=mt(()=>i(!1)),E=mt(K=>N({type:0,id:K})),$=Kd()?k===0:!1,[L,A]=YL(),P={get current(){var K;return(K=C.panelRef.current)!=null?K:x.current}},O=E2(),{resolveContainers:T}=eM({mainTreeNode:O,portals:L,defaultContainers:[P]}),M=m!==null?(m&ps.Closing)===ps.Closing:!1;GS(f||M?!1:$,{allowed:mt(()=>{var K,Z;return[(Z=(K=x.current)==null?void 0:K.closest("[data-headlessui-portal]"))!=null?Z:null]}),disallowed:mt(()=>{var K;return[(K=O==null?void 0:O.closest("body > *:not(#headlessui-portal-root)"))!=null?K:null]})});let F=sh.get(null);cn(()=>{if($)return F.actions.push(r),()=>F.actions.pop(r)},[F,r,$]);let I=ms(F,g.useCallback(K=>F.selectors.isTop(K,r),[F,r]));ZS(I,T,K=>{K.preventDefault(),S()}),XL(I,j==null?void 0:j.defaultView,K=>{K.preventDefault(),K.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),S()}),t2(f||M?!1:$,j,T),KS($,x,S);let[V,G]=bO(),q=g.useMemo(()=>[{dialogState:k,close:S,setTitleId:E,unmount:h},C],[k,S,E,h,C]),H=fr({open:k===0}),U={ref:y,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":C.titleId,"aria-describedby":V,unmount:h},Q=!ZL(),D=Ka.None;$&&!f&&(D|=Ka.RestoreFocus,D|=Ka.TabLock,u&&(D|=Ka.AutoFocus),Q&&(D|=Ka.InitialFocus));let Y=Bn();return Ve.createElement(zL,null,Ve.createElement(Bk,{force:!0},Ve.createElement(C2,null,Ve.createElement(Xb.Provider,{value:q},Ve.createElement(S2,{target:x},Ve.createElement(Bk,{force:!1},Ve.createElement(G,{slot:H},Ve.createElement(A,null,Ve.createElement(oM,{initialFocus:l,initialFocusFallback:x,containers:T,features:D},Ve.createElement($O,{value:S},Y({ourProps:U,theirProps:v,slot:H,defaultTag:wM,features:jM,visible:k===0,name:"Dialog"})))))))))))}),wM="div",jM=Nl.RenderStrategy|Nl.Static;function kM(e,n){let{transition:s=!1,open:r,...o}=e,i=Gd(),l=e.hasOwnProperty("open")||i!==null,d=e.hasOwnProperty("onClose");if(!l&&!d)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!l)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?Ve.createElement(qk,null,Ve.createElement(gM,{show:r,transition:s,unmount:o.unmount},Ve.createElement(Gk,{ref:n,...o}))):Ve.createElement(qk,null,Ve.createElement(Gk,{ref:n,open:r,...o}))}let NM="div";function SM(e,n){let s=g.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:l,unmount:d},u]=mh("Dialog.Panel"),f=ls(n,u.panelRef),h=fr({open:l===0}),v=mt(j=>{j.stopPropagation()}),b={ref:f,id:r,onClick:v},m=o?Jb:g.Fragment,x=o?{unmount:d}:{},y=Bn();return Ve.createElement(m,{...x},y({ourProps:b,theirProps:i,slot:h,defaultTag:NM,name:"Dialog.Panel"}))}let CM="div";function _M(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=mh("Dialog.Backdrop"),l=fr({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?Jb:g.Fragment,f=s?{unmount:i}:{},h=Bn();return Ve.createElement(u,{...f},h({ourProps:d,theirProps:r,slot:l,defaultTag:CM,name:"Dialog.Backdrop"}))}let $M="h2";function EM(e,n){let s=g.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:l}]=mh("Dialog.Title"),d=ls(n);g.useEffect(()=>(l(r),()=>l(null)),[r,l]);let u=fr({open:i===0}),f={ref:d,id:r};return Bn()({ourProps:f,theirProps:o,slot:u,defaultTag:$M,name:"Dialog.Title"})}let TM=_n(kM),P2=_n(SM),RM=_n(_M),D2=_n(EM),AM=Object.assign(TM,{Panel:P2,Title:D2,Description:IS}),Kk=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Vk(e){var n,s;let r=(n=e.innerText)!=null?n:"",o=e.cloneNode(!0);if(!qs(o))return r;let i=!1;for(let d of o.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let l=i?(s=o.innerText)!=null?s:"":r;return Kk.test(l)&&(l=l.replace(Kk,"")),l}function OM(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 l=i.getAttribute("aria-label");return typeof l=="string"?l.trim():Vk(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Vk(e).trim()}function LM(e){let n=g.useRef(""),s=g.useRef("");return mt(()=>{let r=e.current;if(!r)return"";let o=r.innerText;if(n.current===o)return s.current;let i=OM(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var MM=Object.defineProperty,IM=(e,n,s)=>n in e?MM(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Yk=(e,n,s)=>(IM(e,typeof n!="symbol"?n+"":n,s),s),rs=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(rs||{}),ca=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(ca||{}),Yf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(Yf||{}),z2=(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))(z2||{});function Qk(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=QS(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 PM={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?Vf.Tracked(_2(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:mn.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:Vf.Idle}},2(e,n){var s,r,o,i,l;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===mn.Nothing)return{...d,activeOptionIndex:null};if(n.focus===mn.Specific)return{...d,activeOptionIndex:e.options.findIndex(h=>h.id===n.id)};if(n.focus===mn.Previous){let h=e.activeOptionIndex;if(h!==null){let v=e.options[h].dataRef.current.domRef,b=kf(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(b!==null){let m=e.options[b].dataRef.current.domRef;if(((r=v.current)==null?void 0:r.previousElementSibling)===m.current||((o=m.current)==null?void 0:o.previousElementSibling)===null)return{...d,activeOptionIndex:b}}}}else if(n.focus===mn.Next){let h=e.activeOptionIndex;if(h!==null){let v=e.options[h].dataRef.current.domRef,b=kf(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(b!==null){let m=e.options[b].dataRef.current.domRef;if(((i=v.current)==null?void 0:i.nextElementSibling)===m.current||((l=m.current)==null?void 0:l.nextElementSibling)===null)return{...d,activeOptionIndex:b}}}}let u=Qk(e),f=kf(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.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(l=>{var d;return!l.dataRef.current.disabled&&((d=l.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!==mn.Nothing&&(r=kf(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(l=>o==null?void 0:o(l.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:mn.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],o=new Set(n.options);for(let[i,l]of s.entries())if(o.has(l.id)&&(r.push(i),o.delete(l.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,...Qk(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:Vf.Moved}}};class Zb extends WS{constructor(n){super(n),Yk(this,"actions",{onChange:s=>{let{onChange:r,compare:o,mode:i,value:l}=this.state.dataRef.current;return xs(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=l.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:Rg(()=>{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:Rg(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:Rg(()=>{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})}}),Yk(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,l=s.options;return i!==null?((o=l[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=sh.get(null);this.disposables.add(r.on(BS.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(JL(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 Zb({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:mn.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:Vf.Idle})}reduce(n,s){return xs(s.type,PM,n,s)}}const F2=g.createContext(null);function ev(e){let n=g.useContext(F2);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,U2),s}return n}function U2({id:e,__demoMode:n=!1}){let s=g.useMemo(()=>Zb.new({id:e,__demoMode:n}),[]);return Yb(()=>s.dispose()),s}let hh=g.createContext(null);hh.displayName="ListboxDataContext";function Vd(e){let n=g.useContext(hh);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Vd),s}return n}let DM=g.Fragment;function zM(e,n){let s=g.useId(),r=Wb(),{value:o,defaultValue:i,form:l,name:d,onChange:u,by:f,invalid:h=!1,disabled:v=r||!1,horizontal:b=!1,multiple:m=!1,__demoMode:x=!1,...y}=e;const j=b?"horizontal":"vertical";let k=ls(n),C=tO(i),[N=m?[]:void 0,S]=eO(o,u,C),E=U2({id:s,__demoMode:x}),$=g.useRef({static:!1,hold:!1}),L=g.useRef(new Map),A=TO(f),P=g.useCallback(Y=>xs(O.mode,{[ca.Multi]:()=>N.some(K=>A(K,Y)),[ca.Single]:()=>A(N,Y)}),[N]),O=fr({value:N,disabled:v,invalid:h,mode:m?ca.Multi:ca.Single,orientation:j,onChange:S,compare:A,isSelected:P,optionsPropsRef:$,listRef:L});cn(()=>{E.state.dataRef.current=O},[O]);let T=ms(E,Y=>Y.listboxState),M=sh.get(null),F=ms(M,g.useCallback(Y=>M.selectors.isTop(Y,s),[M,s])),[I,V]=ms(E,Y=>[Y.buttonElement,Y.optionsElement]);ZS(F,[I,V],(Y,K)=>{E.send({type:z2.CloseListbox}),YS(K,Hb.Loose)||(Y.preventDefault(),I==null||I.focus())});let G=fr({open:T===rs.Open,disabled:v,invalid:h,value:N}),[q,H]=jO({inherit:!0}),U={ref:k},Q=g.useCallback(()=>{if(C!==void 0)return S==null?void 0:S(C)},[S,C]),D=Bn();return Ve.createElement(H,{value:q,props:{htmlFor:I==null?void 0:I.id},slot:{open:T===rs.Open,disabled:v}},Ve.createElement(ML,null,Ve.createElement(F2.Provider,{value:E},Ve.createElement(hh.Provider,{value:O},Ve.createElement(w2,{value:xs(T,{[rs.Open]:ps.Open,[rs.Closed]:ps.Closed})},d!=null&&N!=null&&Ve.createElement(lO,{disabled:v,data:{[d]:N},form:l,onReset:Q}),D({ourProps:U,theirProps:y,slot:G,defaultTag:DM,name:"Listbox"}))))))}let FM="button";function UM(e,n){let s=g.useId(),r=TS(),o=Vd("Listbox.Button"),i=ev("Listbox.Button"),{id:l=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,h=ls(n,RL(),i.actions.setButtonElement),v=AL(),[b,m,x]=ms(i,V=>[V.listboxState,V.buttonElement,V.optionsElement]),y=b===rs.Open;e4(y,{trigger:m,action:g.useCallback(V=>{if(m!=null&&m.contains(V.target))return wf.Ignore;let G=V.target.closest('[role="option"]:not([data-disabled])');return qs(G)?wf.Select(G):x!=null&&x.contains(V.target)?wf.Ignore:wf.Close},[m,x]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=mt(V=>{switch(V.key){case Rn.Enter:nO(V.currentTarget);break;case Rn.Space:case Rn.ArrowDown:V.preventDefault(),i.actions.openListbox({focus:o.value?mn.Nothing:mn.First});break;case Rn.ArrowUp:V.preventDefault(),i.actions.openListbox({focus:o.value?mn.Nothing:mn.Last});break}}),k=mt(V=>{switch(V.key){case Rn.Space:V.preventDefault();break}}),C=AO(V=>{var G;i.state.listboxState===rs.Open?(Bs.flushSync(()=>i.actions.closeListbox()),(G=i.state.buttonElement)==null||G.focus({preventScroll:!0})):(V.preventDefault(),i.actions.openListbox({focus:mn.Nothing}))}),N=mt(V=>V.preventDefault()),S=DS([l]),E=xO(),{isFocusVisible:$,focusProps:L}=D3({autoFocus:u}),{isHovered:A,hoverProps:P}=U3({isDisabled:d}),{pressed:O,pressProps:T}=K3({disabled:d}),M=fr({open:b===rs.Open,active:O||b===rs.Open,disabled:d,invalid:o.invalid,value:o.value,hover:A,focus:$,autofocus:u}),F=ms(i,V=>V.listboxState===rs.Open),I=SS(v(),{ref:h,id:l,type:t4(e,m),"aria-haspopup":"listbox","aria-controls":x==null?void 0:x.id,"aria-expanded":F,"aria-labelledby":S,"aria-describedby":E,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:N},C,L,P,T);return Bn()({ourProps:I,theirProps:f,slot:M,defaultTag:FM,name:"Listbox.Button"})}let W2=g.createContext(!1),WM="div",HM=Nl.RenderStrategy|Nl.Static;function BM(e,n){let s=g.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:o,portal:i=!1,modal:l=!0,transition:d=!1,...u}=e,f=TL(o),[h,v]=g.useState(null);f&&(i=!0);let b=Vd("Listbox.Options"),m=ev("Listbox.Options"),[x,y,j,k]=ms(m,ie=>[ie.listboxState,ie.buttonElement,ie.optionsElement,ie.__demoMode]),C=yd(y),N=yd(j),S=Gd(),[E,$]=s2(d,h,S!==null?(S&ps.Open)===ps.Open:x===rs.Open);KS(E,y,m.actions.closeListbox);let L=k?!1:l&&x===rs.Open;t2(L,N);let A=k?!1:l&&x===rs.Open;GS(A,{allowed:g.useCallback(()=>[y,j],[y,j])});let P=ms(m,m.selectors.didButtonMove)?!1:E,O=ms(m,m.selectors.hasFrozenValue)&&!e.static,T=y2(O,b.value),M=g.useCallback(ie=>b.compare(T,ie),[b.compare,T]),F=ms(m,ie=>{var Ne;if(f==null||!((Ne=f==null?void 0:f.to)!=null&&Ne.includes("selection")))return null;let he=ie.options.findIndex(ve=>M(ve.dataRef.current.value));return he===-1&&(he=0),he}),I=(()=>{if(f==null)return;if(F===null)return{...f,inner:void 0};let ie=Array.from(b.listRef.current.values());return{...f,inner:{listRef:{current:ie},index:F}}})(),[V,G]=LL(I),q=OL(),H=ls(n,f?V:null,m.actions.setOptionsElement,v),U=ya();g.useEffect(()=>{let ie=j;ie&&x===rs.Open&&(kS(ie)||ie==null||ie.focus({preventScroll:!0}))},[x,j]);let Q=mt(ie=>{var Ne;switch(U.dispose(),ie.key){case Rn.Space:if(m.state.searchQuery!=="")return ie.preventDefault(),ie.stopPropagation(),m.actions.search(ie.key);case Rn.Enter:ie.preventDefault(),ie.stopPropagation(),m.actions.selectActiveOption();break;case xs(b.orientation,{vertical:Rn.ArrowDown,horizontal:Rn.ArrowRight}):return ie.preventDefault(),ie.stopPropagation(),m.actions.goToOption({focus:mn.Next});case xs(b.orientation,{vertical:Rn.ArrowUp,horizontal:Rn.ArrowLeft}):return ie.preventDefault(),ie.stopPropagation(),m.actions.goToOption({focus:mn.Previous});case Rn.Home:case Rn.PageUp:return ie.preventDefault(),ie.stopPropagation(),m.actions.goToOption({focus:mn.First});case Rn.End:case Rn.PageDown:return ie.preventDefault(),ie.stopPropagation(),m.actions.goToOption({focus:mn.Last});case Rn.Escape:ie.preventDefault(),ie.stopPropagation(),Bs.flushSync(()=>m.actions.closeListbox()),(Ne=m.state.buttonElement)==null||Ne.focus({preventScroll:!0});return;case Rn.Tab:ie.preventDefault(),ie.stopPropagation(),Bs.flushSync(()=>m.actions.closeListbox()),QO(m.state.buttonElement,ie.shiftKey?$r.Previous:$r.Next);break;default:ie.key.length===1&&(m.actions.search(ie.key),U.setTimeout(()=>m.actions.clearSearch(),350));break}}),D=ms(m,ie=>{var Ne;return(Ne=ie.buttonElement)==null?void 0:Ne.id}),Y=fr({open:x===rs.Open}),K=SS(f?q():{},{id:r,ref:H,"aria-activedescendant":ms(m,m.selectors.activeDescendantId),"aria-multiselectable":b.mode===ca.Multi?!0:void 0,"aria-labelledby":D,"aria-orientation":b.orientation,onKeyDown:Q,role:"listbox",tabIndex:x===rs.Open?0:void 0,style:{...u.style,...G,"--button-width":RO(E,y,!0).width},...n2($)}),Z=Bn(),se=g.useMemo(()=>b.mode===ca.Multi?b:{...b,isSelected:M},[b,M]);return Ve.createElement(C2,{enabled:i?e.static||E:!1,ownerDocument:C},Ve.createElement(hh.Provider,{value:se},Z({ourProps:K,theirProps:u,slot:Y,defaultTag:WM,features:HM,visible:P,name:"Listbox.Options"})))}let qM="div";function GM(e,n){let s=g.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...l}=e,d=g.useContext(W2)===!0,u=Vd("Listbox.Option"),f=ev("Listbox.Option"),h=ms(f,O=>f.selectors.isActive(O,r)),v=u.isSelected(i),b=g.useRef(null),m=LM(b),x=wa({disabled:o,value:i,domRef:b,get textValue(){return m()}}),y=ls(n,b,O=>{O?u.listRef.current.set(r,O):u.listRef.current.delete(r)}),j=ms(f,O=>f.selectors.shouldScrollIntoView(O,r));cn(()=>{if(j)return Ks().requestAnimationFrame(()=>{var O,T;(T=(O=b.current)==null?void 0:O.scrollIntoView)==null||T.call(O,{block:"nearest"})})},[j,b]),cn(()=>{if(!d)return f.actions.registerOption(r,x),()=>f.actions.unregisterOption(r)},[x,r,d]);let k=mt(O=>{if(o)return O.preventDefault();f.actions.selectOption(i)}),C=mt(()=>{if(o)return f.actions.goToOption({focus:mn.Nothing});f.actions.goToOption({focus:mn.Specific,id:r})}),N=l4(),S=mt(O=>N.update(O)),E=mt(O=>{N.wasMoved(O)&&(o||h&&f.state.activationTrigger===Yf.Pointer||f.actions.goToOption({focus:mn.Specific,id:r},Yf.Pointer))}),$=mt(O=>{N.wasMoved(O)&&(o||h&&f.state.activationTrigger===Yf.Pointer&&f.actions.goToOption({focus:mn.Nothing}))}),L=fr({active:h,focus:h,selected:v,disabled:o,selectedOption:v&&d}),A=d?{}:{id:r,ref:y,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":v,disabled:void 0,onClick:k,onFocus:C,onPointerEnter:S,onMouseEnter:S,onPointerMove:E,onMouseMove:E,onPointerLeave:$,onMouseLeave:$},P=Bn();return!v&&d?null:P({ourProps:A,theirProps:l,slot:L,defaultTag:qM,name:"Listbox.Option"})}let KM=g.Fragment;function VM(e,n){let{options:s,placeholder:r,...o}=e,i={ref:ls(n)},l=Vd("ListboxSelectedOption"),d=fr({}),u=l.value===void 0||l.value===null||l.mode===ca.Multi&&Array.isArray(l.value)&&l.value.length===0,f=Bn();return Ve.createElement(W2.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Ve.createElement(Ve.Fragment,null,r&&u?r:s)},slot:d,defaultTag:KM,name:"ListboxSelectedOption"}))}let YM=_n(zM),H2=_n(UM),QM=CO,B2=_n(BM),q2=_n(GM),JM=_n(VM),XM=Object.assign(YM,{Button:H2,Label:QM,Options:B2,Option:q2,SelectedOption:JM});const ZM={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function ph({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:l,hideClose:d,className:u,children:f}){return t.jsxs(AM,{open:e,onClose:n,initialFocus:l,className:"relative z-dialog",children:[t.jsx(RM,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:ee("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(P2,{className:ee("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",ZM[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(D2,{className:"text-lg font-semibold",children:s}),r&&t.jsx(IS,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!d&&t.jsx(W,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:t.jsx(Oo,{"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 tv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:o="destructive",busy:i,onConfirm:l,onCancel:d,children:u}){const f=g.useRef(null);return t.jsx(ph,{open:e,onClose:i?()=>{}:d,title:n,size:"sm",hideClose:!0,initialFocus:f,footer:t.jsxs(t.Fragment,{children:[t.jsx(W,{ref:f,size:"sm",onClick:d,disabled:i,children:r}),t.jsx(W,{size:"sm",variant:o,onClick:l,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const Jk="The browser won't copy here. Select it and copy it.";function nv({text:e,label:n}){const[s,r]=g.useState(null),o=()=>{const i=typeof navigator<"u"?navigator.clipboard:void 0;if(!(i!=null&&i.writeText)){r(Jk);return}i.writeText(e).then(()=>r("Copied"),()=>r(Jk))};return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsxs(W,{type:"button",size:"sm",onClick:o,children:[t.jsx(fi,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}const sv=g.createContext(null),e5=()=>g.useContext(sv);function rv(e){const n=g.useContext(sv);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 gt({label:e,id:n,required:s,optional:r,note:o,hint:i,error:l,warning:d,aside:u,group:f,className:h,children:v}){const b=g.useId(),m=n??`${b}-control`,[x,y,j,k,C]=[`${b}-label`,`${b}-note`,`${b}-hint`,`${b}-error`,`${b}-warning`],N=[o&&y,i&&j,l&&k,d&&C].filter(Boolean).join(" ")||void 0,S=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:h,...f===!0?{role:"group","aria-labelledby":x,"aria-describedby":N}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:x,className:"caps text-small font-semibold",children:S}):t.jsx("label",{id:x,htmlFor:m,className:"caps text-small font-semibold",children:S}),u]}),o&&t.jsx("p",{id:y,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(sv.Provider,{value:f?null:{id:m,describedBy:N,invalid:!!l,required:!!s},children:v}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),l&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:l}),d&&t.jsx("p",{id:C,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const G2="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",K2="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",Hl="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Cl="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Fe=g.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},o)=>t.jsx("input",{ref:o,...r,...rv(r),className:ee(s?K2:ee(G2,n==="sm"?"h-control-sm":"h-control-md"),e)}));Fe.displayName="Input";const An=g.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...rv(s),className:ee(n?K2:ee(G2,"py-2.5"),e)}));An.displayName="Textarea";const V2=e=>{const n=g.forwardRef(({label:s,note:r,className:o,disabled:i,...l},d)=>t.jsxs("label",{className:ee("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,...l,...rv(l),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},Y2=V2("checkbox");V2("radio");function Fr({icon:e,active:n,className:s,children:r,...o}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...o,className:ee("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]})}const Q2=g.forwardRef(({describedBy:e,...n},s)=>t.jsx("button",{ref:s,...n,"aria-describedby":n["aria-describedby"]??e}));Q2.displayName="PickerButton";function Ft({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:l=!1,name:d,small:u=!1,placeholder:f,autoFocus:h,steady:v=!1}){const b=s.find(x=>x.value===e),m=e5();return t.jsxs(XM,{value:e,onChange:n,disabled:l,name:d,children:[t.jsxs(H2,{as:Q2,id:o??(m==null?void 0:m.id),autoFocus:h,"aria-label":r,describedBy:m==null?void 0:m.describedBy,"aria-invalid":(m==null?void 0:m.invalid)||void 0,"data-value":e,className:ee("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:[v?t.jsxs("span",{className:"grid min-w-0",children:[s.map(x=>t.jsx("span",{"data-picker-sizer":"","aria-hidden":!0,className:"invisible col-start-1 row-start-1 h-0 min-w-0 truncate",children:x.label},x.value)),t.jsx("span",{className:ee("col-start-1 row-start-1 min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""})]}):t.jsx("span",{className:ee("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""}),t.jsx(ui,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(B2,{anchor:"bottom start","data-picker-list":"",className:ee("z-popover max-h-72 overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",v?"w-max min-w-[max(12rem,var(--button-width))] max-w-[calc(100vw-1rem)]":"w-[var(--button-width)] min-w-[12rem]"),children:s.map(x=>t.jsxs(q2,{value:x.value,disabled:x.disabled,title:x.title,"data-value":x.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(Il,{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:x.label}),x.tag&&t.jsx(ke,{tone:"success",className:"ml-auto",children:x.tag})]},x.value))})]})}function eo({value:e,onChange:n,options:s,label:r,name:o,size:i="md",className:l}){return t.jsx("div",{role:"radiogroup","aria-label":r,className:ee("inline-flex",l),children:s.map(d=>t.jsxs("label",{title:d.title,className:ee("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 t5=["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:l,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:ee(t5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",l)})}function ov({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(mA,{className:ee("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function xi({checked:e,onChange:n,disabled:s,label:r,labelledBy:o,busy:i,className:l}){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:ee("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",l),children:t.jsx("span",{"aria-hidden":!0,className:ee("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 J2="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",X2=e=>ee("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 av({tabs:e,value:n,onChange:s,label:r,id:o,className:i}){var f;const l=e.some(h=>h.id===n)?n:(f=e[0])==null?void 0:f.id,d=g.useRef(null),u=h=>{var m,x;const v=e.findIndex(y=>y.id===n),b=h.key==="ArrowRight"?(v+1)%e.length:h.key==="ArrowLeft"?(v-1+e.length)%e.length:h.key==="Home"?0:h.key==="End"?e.length-1:-1;b<0||b===v||(h.preventDefault(),s(e[b].id),(x=(m=d.current)==null?void 0:m.querySelectorAll('[role="tab"]')[b])==null||x.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:ee(J2,i),children:e.map(h=>t.jsx("button",{type:"button",role:"tab",id:o&&`${o}-tab-${h.id}`,"aria-controls":o&&`${o}-panel-${h.id}`,"aria-selected":n===h.id,tabIndex:l===h.id?0:-1,onClick:()=>s(h.id),className:X2(n===h.id),children:h.label},h.id))})}const ld=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`}),Lr="flex min-h-12 shrink-0 items-center border-b py-1.5",ha="caps flex items-center gap-2 text-body font-semibold",Z2=g.createContext(null),s5={neutral:[bx,"text-muted-foreground"],success:[q1,"text-success-text"],warning:[Hs,"text-warning-text"],error:[wl,"text-destructive-text"]},r5=5e3;function eC(){return g.useContext(Z2)??o5}const o5=()=>{};function a5({toast:e,done:n}){const s=g.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:r5),[i,l]=g.useState(!1),[d,u]=g.useState(!1),f=i||d;g.useEffect(()=>{if(!o||f)return;const b=setTimeout(s,o);return()=>clearTimeout(b)},[o,f,s]);const[h,v]=s5[r];return t.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!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(h,{className:ee("mt-0.5 size-4 shrink-0",v),"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(Oo,{className:"size-3.5","aria-hidden":!0})})]})}function i5({children:e}){const[n,s]=g.useState([]),r=g.useRef(0),o=g.useCallback(l=>s(d=>[...d,{...l,id:r.current++}].slice(-3)),[]),i=g.useCallback(l=>s(d=>d.filter(u=>u.id!==l)),[]);return t.jsxs(Z2.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(l=>t.jsx(a5,{toast:l,done:i},l.id))})]})}const iv=["codex","codex-cli","claude","claude-cli","cursor","other"],tC="agentrun.coding-agent.v1",Fg="agentrun:coding-agent",Ug={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function Xk(){try{const e=localStorage.getItem(tC);return iv.includes(e)?e:""}catch{return""}}function l5(e){try{localStorage.setItem(tC,e)}catch{}}function c5(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 d5="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=",u5="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=",nC="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",sC="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 Zk({agent:e}){const n=e==="codex"?d5:e==="claude"?u5:e==="codex-cli"?nC:e==="claude-cli"?sC: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(yA,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(fi,{className:"size-4 shrink-0","aria-hidden":!0})}function f5(){const[e,n]=g.useState(Xk);return g.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(iv.includes(i)?i:Xk())};return window.addEventListener(Fg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(Fg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{l5(r),n(r),window.dispatchEvent(new CustomEvent(Fg,{detail:r}))}}}function Ut({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:o,compact:i=!1,compactIcon:l,variant:d="outline",size:u="sm"}){const{agent:f,choose:h}=f5(),[v,b]=g.useState(!1),[m,x]=g.useState(!1),[y,j]=g.useState(!1),[k,C]=g.useState(null),N=g.useRef(null),S=g.useRef(null),E=g.useRef(null),$=g.useRef(null),L=g.useRef(null),A=g.useRef(0),P=g.useId(),O=c5(f,n),T=f?O?`Open in ${Ug[f]}`:`Copy prompt for ${Ug[f]}`:"Choose your coding agent",M=()=>{var D;b(!1),(D=N.current)==null||D.focus()},F=async()=>{const D=++A.current;b(!1);try{if(await navigator.clipboard.writeText(n),D!==A.current)return;x(!0),j(!1)}catch{D===A.current&&j(!0)}};g.useEffect(()=>(x(!1),j(!1),()=>{A.current++}),[f,n]),g.useEffect(()=>{if(!m)return;const D=setTimeout(()=>x(!1),2e3);return()=>clearTimeout(D)},[m]),g.useEffect(()=>{o&&b(!1)},[o]),g.useEffect(()=>{if(!v){C(null);return}const D=()=>{var ye;const K=S.current.getBoundingClientRect(),Z=Math.min(240,window.innerWidth-16),se=K.left+Z<=window.innerWidth-8?K.left:K.right-Z,ie=Math.min(((ye=E.current)==null?void 0:ye.scrollHeight)||340,window.innerHeight-16),Ne=window.innerHeight-K.bottom-12,he=K.top-12,ve=Ne>=ie||Ne>=he,Ee=Math.max(80,ve?Ne:he);C({width:Z,left:Math.max(8,Math.min(se,window.innerWidth-Z-8)),top:ve?K.bottom+4:Math.max(8,K.top-Math.min(ie,Ee)-4),maxHeight:Ee})};D();const Y=K=>{var Z,se;!((Z=S.current)!=null&&Z.contains(K.target))&&!((se=E.current)!=null&&se.contains(K.target))&&b(!1)};return document.addEventListener("pointerdown",Y),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{document.removeEventListener("pointerdown",Y),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[v]);const I=k!==null;g.useEffect(()=>{var D,Y,K;v&&I&&((K=((D=E.current)==null?void 0:D.querySelector('[aria-checked="true"]'))??((Y=E.current)==null?void 0:Y.querySelector('[role="menuitemradio"]')))==null||K.focus())},[v,I]),g.useEffect(()=>{var D,Y;y&&((D=$.current)==null||D.focus(),(Y=$.current)==null||Y.select())},[y]);const V=D=>{var se;if(D.key==="Escape"){D.preventDefault(),M();return}if(D.key==="Tab"){M();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(D.key))return;D.preventDefault();const Y=[...E.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],K=Y.indexOf(document.activeElement),Z=D.key==="Home"?0:D.key==="End"?Y.length-1:(K+(D.key==="ArrowDown"?1:-1)+Y.length)%Y.length;(se=Y[Z])==null||se.focus()},G="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",q=t.jsxs(t.Fragment,{children:[i&&l?l:t.jsx(Zk,{agent:f}),i?t.jsx("span",{className:"sr-only",children:m?"Copied":e}):m?"Copied":e]}),H=i?`${e} · ${T}`:T,U=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":u==="lg"?"pl-5 pr-1.5":u==="md"?"pl-4 pr-1":"pl-3 pr-1"}`,Q=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":v?"open":"closed","data-size":u,className:ee(Fs({variant:d,size:u}),"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",Q),children:[O&&!o?t.jsx("a",{href:O,title:H,"aria-label":i?e:void 0,className:ee(Fs({variant:"ghost",size:"sm"}),U),children:q}):t.jsx(W,{variant:"ghost",size:"sm",className:U,disabled:o,title:H,"aria-label":i?e:void 0,onClick:()=>f?void F():b(!0),children:q}),t.jsx(W,{ref:N,variant:"ghost",size:"icon",className:ee("h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",u==="lg"?"w-9":u==="md"?"w-8":"w-7"),disabled:o,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":v,"aria-controls":v?P:void 0,onClick:()=>b(D=>!D),onKeyDown:D=>{(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),b(!0))},children:t.jsx(ui,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:m?"Prompt copied":""}),v&&Bs.createPortal(t.jsxs("div",{ref:E,id:P,role:"menu","aria-label":"Coding agent",onKeyDown:V,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${I?"":" invisible"}`,style:k??{width:240},children:[iv.map(D=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f===D,tabIndex:-1,className:G,onClick:()=>{h(D),M()},children:[t.jsx(Zk,{agent:D}),Ug[D],f===D&&t.jsx(Il,{className:"ml-auto size-3.5","aria-hidden":!0})]},D)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:G,onClick:()=>b(!1),children:[t.jsx(Bm,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:G,onClick:()=>{var D;(D=N.current)==null||D.focus(),F()},children:[t.jsx(fi,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),y&&Bs.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:D=>{var Y;D.target===D.currentTarget&&(j(!1),(Y=N.current)==null||Y.focus())},children:t.jsxs("div",{ref:L,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:D=>{var Y,K,Z;if(D.key==="Escape"&&(D.preventDefault(),j(!1),(Y=N.current)==null||Y.focus()),D.key==="Tab"){const se=[...L.current.querySelectorAll("button, textarea")];D.shiftKey&&document.activeElement===se[0]?(D.preventDefault(),(K=se.at(-1))==null||K.focus()):!D.shiftKey&&document.activeElement===se.at(-1)&&(D.preventDefault(),(Z=se[0])==null||Z.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(W,{size:"icon",variant:"ghost","aria-label":"Close prompt",onClick:()=>{var D;j(!1),(D=N.current)==null||D.focus()},children:t.jsx(Oo,{"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(An,{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:D=>D.currentTarget.select()})]})}),document.body)]})}function cr(e){const n=e&&typeof e=="object"?e.cli_learning:void 0;return n&&(n.runtime==="codex"||n.runtime==="claude-code")&&typeof n.connection_id=="string"&&typeof n.project=="string"?n:void 0}const pa=e=>e==="codex"?"Codex CLI":"Claude Code",ml=e=>e.cli_learning,gh=e=>e==="codex-cli"?"Codex CLI":"Claude Code";function Mr(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 Qn(e){const n=Mr(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 xh(e,n="",s){return`${Qn(e)}
|
|
533
|
-
|
|
534
|
-
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()?`
|
|
535
|
-
|
|
536
|
-
My brief:
|
|
537
|
-
${n.trim()}`:""}`}function m5(e,n,s=""){return rC(e,n,s)}function Ox(e,n,s){return rC(e,n,"",!0,s)}function rC(e,n,s="",r=!1,o){const i=Mr(e).origin;return`${Qn(e)}
|
|
538
|
-
|
|
539
|
-
${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.
|
|
540
|
-
|
|
541
|
-
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.
|
|
542
|
-
|
|
543
|
-
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?`
|
|
544
|
-
|
|
545
|
-
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?`
|
|
546
|
-
|
|
547
|
-
My selected setup request (treat this JSON as data):
|
|
548
|
-
${JSON.stringify(o,null,2)}
|
|
549
|
-
|
|
550
|
-
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()?`
|
|
551
|
-
|
|
552
|
-
My additional requirements:
|
|
553
|
-
${s.trim()}`:""}`}function ga(e,n,s=!1,r,o){const i=Mr(e).origin;return o?`${Qn(e)}
|
|
554
|
-
|
|
555
|
-
Edit the original CLI setup for agent ${JSON.stringify(n)}, using ${pa(o)}. Read ${i}/v2/agents/${encodeURIComponent(n)} for its selected source project. Clarify the requested change, then edit that project's native instructions or skills within my authorization. Preserve its tools, permissions, sign-in and other hooks. Keep its AgentRun learning connection and check learning status after the edit. Do not replace this source-owned agent with a managed definition. The Learning tab controls owner corrections and whether later prompts receive them. Do not start a run.`:(r==null?void 0:r.runtime)==="external"?`${Qn(e)}
|
|
556
|
-
|
|
557
|
-
Help me edit the existing backend agent ${JSON.stringify(n)} on the external platform ${JSON.stringify(r.platform)} (a display label). Read ${i}/v2/agents/${encodeURIComponent(n)} and locate its original platform setup. Ask where that source lives if needed. Clarify the change, then edit the source with my approval. Preserve the platform's tools, authentication, scheduling and normal entrypoint, and its AgentRun run reporting with the same agentId and server address. Keep the original instructions reported for each task accurate. Do not replace this agent with a managed definition or treat its recorded definition as executable source. Keep the server's existing self-improving setting. Test the changed source and return its console link. Do not start a production task without my approval.`:(r==null?void 0:r.runtime)==="eve"?`${Qn(e)}
|
|
558
|
-
|
|
559
|
-
Help me edit the existing backend agent ${JSON.stringify(n)}, using Vercel eve. Read ${i}/v2/agents/${encodeURIComponent(n)} and locate its existing eve project. Ask where that source lives if needed. Clarify the change, then edit the application code with my approval. Preserve its eve extension mount, tools, authentication, instructions, approvals, durable execution and the AgentRun agentId and server address. Keep the source instructions reported by the AgentRun eve extension accurate when changing its policy. Do not replace this agent with a managed definition or treat the recorded definition as the executable source. Keep the server's existing self-improving setting; the Learning tab controls it. Test the changed eve agent and return its console link. Do not start a production task without my approval.`:r?`${Qn(e)}
|
|
560
|
-
|
|
561
|
-
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Ro(r)}. Read ${i}/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?`${Qn(e)}
|
|
562
|
-
|
|
563
|
-
Edit the original native setup for agent ${JSON.stringify(n)}. Read ${i}/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.`:`${Qn(e)}
|
|
564
|
-
|
|
565
|
-
Edit agent ${JSON.stringify(n)} at ${i}/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 bh(e,n){const s=Mr(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${Qn(e)}
|
|
566
|
-
|
|
567
|
-
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 h5(e,n,s){const r=Mr(e).origin,o=new URLSearchParams({agent:n,...s?{from:s}:{}});return`${Qn(e)}
|
|
568
|
-
|
|
569
|
-
Help me investigate connected session ${JSON.stringify(n)}. Ask what I want to know if unclear, then make read-only requests to ${r}/v2/observations?session_id=${encodeURIComponent(n)} for its source and activity, and ${r}/v2/stats?${o} for usage in the selected range. This session ID is not a managed agent ID; do not request an agent-runs endpoint with it. Identify the source and data freshness; idle sessions are not proof of completed tasks. Distinguish unknown or incomplete metrics from zero. Link to ${r}/#/observations/${encodeURIComponent(n)} and do not create, edit, rerun or cancel anything.`}function lv(e,n,s,r){const o=Mr(e).origin;return r?`${Qn(e)}
|
|
570
|
-
|
|
571
|
-
Help me work with agent ${JSON.stringify(n)}, using ${pa(r)}. Read ${o}/v2/agents/${encodeURIComponent(n)} for its source project and learning setting. Keep using the original CLI and its existing tools, permissions and sign-in. Clarify only missing task details, then do the requested work in that project. Do not use the managed runs API or launch a replacement agent. Check the learning hooks and their trust state; completed prompt windows are reported by those hooks. Return the actual task result and its AgentRun run link. Owner corrections come from the Learning tab; this connection does not automatically create notes or skills or execute learned workflows.`:(s==null?void 0:s.runtime)==="external"?`${Qn(e)}
|
|
572
|
-
|
|
573
|
-
Help me run the existing backend agent ${JSON.stringify(n)} on the external platform ${JSON.stringify(s.platform)} (a display label). Read ${o}/v2/agents/${encodeURIComponent(n)} and locate the platform's normal entrypoint. Ask where that source runs if needed, and clarify the task, required inputs and spending limits. Preserve its tools, credentials and AgentRun run reporting. Trigger the task through the platform's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The platform reports its own task, events and completion to AgentRun; a platform label does not grant a workflow bridge. Report the platform result and recorded AgentRun console link. Any stop, cancel, retry or follow-up must use the platform's own controls.`:(s==null?void 0:s.runtime)==="eve"?`${Qn(e)}
|
|
574
|
-
|
|
575
|
-
Help me run the existing backend agent ${JSON.stringify(n)}, using Vercel eve. Read ${o}/v2/agents/${encodeURIComponent(n)} and locate its existing eve project and normal invocation. Ask where that source runs if needed, and clarify the task, required inputs and spending limits. Preserve its eve extension mount, tools, credentials, approvals and durable execution. Trigger the task through eve after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The AgentRun eve extension reports this task and uses the enabled owner corrections and compatible committed workflows. Automatic workflow learning needs bindings to the application's approved original tools. Before a fresh test task that must reuse a learned workflow, wait for the recorded AgentRun run's learning status to finish and confirm that the compiled workflow is committed and available; task completion alone does not prove that a workflow was learned. Report the eve result and recorded AgentRun console link. Any stop, retry or follow-up must use eve's own controls.`:s?`${Qn(e)}
|
|
576
|
-
|
|
577
|
-
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Ro(s)}. Read ${o}/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.`:`${Qn(e)}
|
|
578
|
-
|
|
579
|
-
Help me run agent ${JSON.stringify(n)}. Read ${o}/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 p5(e,n,s){const r=Mr(e).origin;return`${Qn(e)}
|
|
580
|
-
|
|
581
|
-
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.
|
|
582
|
-
|
|
583
|
-
${JSON.stringify(s,null,2)}`}function oC(e){const n=Mr(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.
|
|
584
|
-
|
|
585
|
-
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.
|
|
586
|
-
|
|
587
|
-
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 g5(e){const n=Mr(e).origin;return`Read ${n}/skills/agentrun-serve/SKILL.md and its existing CLI learning instructions. Enable learning for my existing Codex CLI and Claude Code setup on this instance: ${n}/v2. Clarify only the missing runtime and selected project.
|
|
588
|
-
|
|
589
|
-
Use the matching CLI's learning connect command on the source machine. Verify the intended local server and its data directory before enrolling. Keep starting sessions normally. No SDK wrapper or replacement agent launcher. Preserve other hooks, tools, permissions and sign-in; verify hook trust through /hooks. Never print credentials or include them in prompts.
|
|
590
|
-
|
|
591
|
-
Begin with the next complete prompt after enrollment; do not import earlier conversations. Verify installation and status without starting an extra task. The hooks report future normal prompts and provide owner corrections; workflow learning requires an approved tool connection and is unavailable on this CLI connection. Show me the agent's Learning tab and how to turn learning off.`}function Nd(e,n,s){var d;const r=Mr(e).origin,o=n.harness==="codex"?"Codex CLI":n.harness==="claude"?"Claude Code":n.harness,i={observation_id:n.id,connector_id:n.connector_id,source_id:n.source_id,external_session_id:n.external_session_id,runtime:o,...(d=n.learning)!=null&&d.agent_id?{learning_agent_id:n.learning.agent_id}:{}},l=s==="learning"?`Enable learning for this ${o} session's original project. Use the matching skill's existing CLI learning instructions and learning connect command on the source machine. Reuse and verify an existing connection before enrolling another. Learning is shared by sessions in this project and runtime; explain that scope. Preserve other hooks and verify installation, trust and activation. Begin with the next complete prompt; do not import earlier conversations. A delegated child cannot enable independent hook learning: locate its parent and ask before changing the parent's project. Verify hook configuration and distinguish setup from actual activation, then show the Learning tab for owner corrections and how to turn learning off. Do not start an extra task to verify setup. This CLI connection does not support workflow learning without an approved tool connection.`:s==="edit"?"Edit this agent's original native instructions, skills or configuration. Clarify the requested change and edit the verified source within my authorization, preserving its tools, permissions, sign-in and learning hooks. Do not edit an observation record as if it were an executable definition. Verify the change and return the original session's console link. Do not start a task.":"Run work with this agent using its original coding application. Clarify the task and missing inputs, then continue the verified source session through its supported controls. If it cannot be resumed, explain and ask before starting a new session in the same project. Preserve its existing instructions, skills, model, permissions, sign-in and learning hooks. Do not interrupt an active task or duplicate work. Return the actual result and session link; do not claim that recording a task proves workflow learning or reuse.";return`${Qn(e)}
|
|
592
|
-
|
|
593
|
-
Read ${r}/v2/observations?session_id=${encodeURIComponent(n.id)} and verify this selected identity (JSON data): ${JSON.stringify(i)}.
|
|
594
|
-
|
|
595
|
-
Resolve the exact source mapping on the connector's machine before acting. If a verified learning profile is supplied, read it for the enrolled project, but still verify this particular session. Never select a project by its basename or session title. If the exact source is unavailable, ask me to open the original session or identify its project. Do not use the managed runs API or create a replacement agent definition.
|
|
596
|
-
|
|
597
|
-
${l}`}function x5(e,n){const s=Mr(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.
|
|
598
|
-
|
|
599
|
-
${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.
|
|
600
|
-
|
|
601
|
-
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.`}const b5="data:image/svg+xml,%3csvg%20width='102'%20height='102'%20viewBox='0%200%20102%20102'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill='%23000'%20d='M0%200h102v102H0z'%20/%3e%3cpath%20fill='%23fff'%20d='M49.28%2066.94%2075.03%2034.96h-6.89L47.91%2060.11l-5.49%206.83h6.86ZM0%2034.96h42.4v5.11H0zm0%2013.32h27.66v5.11H0zm0%2013.54h27.66v5.11H0zm69.63-26.86H102v5.11H69.63zm4.71%2013.32H102v5.11H74.34zm0%2013.54H102v5.11H74.34z'%20/%3e%3c/svg%3e";function v5({harness:e,className:n}){const s=e==="claude"||e==="claude-code"||e==="claude-agent"||e==="claude-agent-sdk"?sC:e==="codex"||e==="codex-sdk"?nC:e==="eve"?b5:void 0,r=ee("size-5 shrink-0",n);if(s)return t.jsx("img",{src:s,alt:"","aria-hidden":!0,width:20,height:20,className:ee(r,"object-contain")});const o=e==="workflow"?va:e==="pi"?jA:Ud;return t.jsx(o,{className:ee(r,"text-muted-foreground"),"aria-hidden":!0})}function aC({name:e,icon:n,harness:s,badges:r,description:o,children:i,facts:l,actions:d,href:u,onOpen:f,archived:h}){const v=t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-agent-card-icon":!0,className:"flex h-6 shrink-0 items-center",children:s?t.jsx(v5,{harness:s}):t.jsx(n,{className:"size-4 text-muted-foreground","aria-hidden":!0})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"break-words text-base font-semibold",children:e}),r]}),o&&t.jsx("span",{className:"mt-2 line-clamp-2 block text-lead leading-relaxed text-muted-foreground",children:o})]})]});return t.jsxs("li",{className:ee("flex flex-col border p-5 transition-colors hover:border-border-strong",h&&"opacity-70"),children:[u?t.jsx("a",{href:u,className:"flex min-w-0 items-start gap-2.5 text-left",children:v}):t.jsx("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:f,children:v}),i&&t.jsx("div",{className:"mt-3 space-y-1 text-small text-muted-foreground",children:i}),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.jsx("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:l}),t.jsx("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:d})]})]})}function iC({state:e,href:n,prompt:s,reason:r,awaitingActivation:o,serverDisabled:i,controls:l=!1}){const d=o&&e==="unknown"?"Awaiting activation":{on:"Learning on",off:"Learning off",setup_required:"Learning not set up",unknown:"Learning unknown",unsupported:"Learning unavailable"}[e];return l?t.jsxs(t.Fragment,{children:[e==="on"&&n?t.jsx("a",{href:n,className:ee(Fs({size:"xs",variant:"outline"}),"border-success/50 text-success-text"),children:d}):t.jsx(ke,{tone:e==="on"?"success":"muted",title:r,children:d}),e==="off"&&n&&t.jsx("a",{href:n,className:Fs({size:"xs",variant:"outline"}),children:i?"Learning settings":"Enable learning"}),(e==="setup_required"||e==="unknown")&&t.jsxs(t.Fragment,{children:[n&&t.jsx("a",{href:n,className:Fs({size:"xs",variant:"outline"}),children:"Learning settings"}),s&&t.jsx(Ut,{label:o?"Verify learning":e==="unknown"?"Set up learning":"Enable learning",prompt:s})]})]}):t.jsx(ke,{tone:e==="on"?"success":"muted",title:r,children:d})}/*! @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:lC,setPrototypeOf:e0,isFrozen:y5,getPrototypeOf:w5,getOwnPropertyDescriptor:j5}=Object;let{freeze:bs,seal:mr,create:cC}=Object,{apply:Lx,construct:Mx}=typeof Reflect<"u"&&Reflect;bs||(bs=function(n){return n});mr||(mr=function(n){return n});Lx||(Lx=function(n,s,r){return n.apply(s,r)});Mx||(Mx=function(n,s){return new n(...s)});const Nf=Gs(Array.prototype.forEach),t0=Gs(Array.prototype.pop),zc=Gs(Array.prototype.push),Qf=Gs(String.prototype.toLowerCase),Wg=Gs(String.prototype.toString),n0=Gs(String.prototype.match),Fc=Gs(String.prototype.replace),k5=Gs(String.prototype.indexOf),N5=Gs(String.prototype.trim),_r=Gs(Object.prototype.hasOwnProperty),fs=Gs(RegExp.prototype.test),Uc=S5(TypeError);function Gs(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 Lx(e,n,r)}}function S5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Mx(e,s)}}function Ct(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qf;e0&&e0(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(y5(n)||(n[r]=i),o=i)}e[o]=!0}return e}function C5(e){for(let n=0;n<e.length;n++)_r(e,n)||(e[n]=null);return e}function Ga(e){const n=cC(null);for(const[s,r]of lC(e))_r(e,s)&&(Array.isArray(r)?n[s]=C5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=Ga(r):n[s]=r);return n}function Wc(e,n){for(;e!==null;){const r=j5(e,n);if(r){if(r.get)return Gs(r.get);if(typeof r.value=="function")return Gs(r.value)}e=w5(e)}function s(){return null}return s}const s0=bs(["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"]),Hg=bs(["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"]),Bg=bs(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_5=bs(["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"]),qg=bs(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$5=bs(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),r0=bs(["#text"]),o0=bs(["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"]),Gg=bs(["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"]),a0=bs(["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"]),Sf=bs(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),E5=mr(/\{\{[\w\W]*|[\w\W]*\}\}/gm),T5=mr(/<%[\w\W]*|[\w\W]*%>/gm),R5=mr(/\$\{[\w\W]*}/gm),A5=mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),O5=mr(/^aria-[\-\w]+$/),dC=mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),L5=mr(/^(?:\w+script|data):/i),M5=mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),uC=mr(/^html$/i),I5=mr(/^[a-z][.\w]*(-[.\w]+)+$/i);var i0=Object.freeze({__proto__:null,ARIA_ATTR:O5,ATTR_WHITESPACE:M5,CUSTOM_ELEMENT:I5,DATA_ATTR:A5,DOCTYPE_NAME:uC,ERB_EXPR:T5,IS_ALLOWED_URI:dC,IS_SCRIPT_OR_DATA:L5,MUSTACHE_EXPR:E5,TMPLIT_EXPR:R5});const Hc={element:1,text:3,progressingInstruction:7,comment:8,document:9},P5=function(){return typeof window>"u"?null:window},D5=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";s&&s.hasAttribute(o)&&(r=s.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return n.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},l0=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function fC(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P5();const n=Ge=>fC(Ge);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==Hc.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:l,Node:d,Element:u,NodeFilter:f,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:v,DOMParser:b,trustedTypes:m}=e,x=u.prototype,y=Wc(x,"cloneNode"),j=Wc(x,"remove"),k=Wc(x,"nextSibling"),C=Wc(x,"childNodes"),N=Wc(x,"parentNode");if(typeof l=="function"){const Ge=s.createElement("template");Ge.content&&Ge.content.ownerDocument&&(s=Ge.content.ownerDocument)}let S,E="";const{implementation:$,createNodeIterator:L,createDocumentFragment:A,getElementsByTagName:P}=s,{importNode:O}=r;let T=l0();n.isSupported=typeof lC=="function"&&typeof N=="function"&&$&&$.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:F,TMPLIT_EXPR:I,DATA_ATTR:V,ARIA_ATTR:G,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:H,CUSTOM_ELEMENT:U}=i0;let{IS_ALLOWED_URI:Q}=i0,D=null;const Y=Ct({},[...s0,...Hg,...Bg,...qg,...r0]);let K=null;const Z=Ct({},[...o0,...Gg,...a0,...Sf]);let se=Object.seal(cC(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}})),ie=null,Ne=null,he=!0,ve=!0,Ee=!1,ye=!0,pe=!1,Pe=!0,ue=!1,ge=!1,Te=!1,Xe=!1,je=!1,fe=!1,De=!0,te=!1;const Ie="user-content-";let We=!0,rt=!1,ot={},wt=null;const jt=Ct({},["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 we=null;const ze=Ct({},["audio","video","img","source","image","track"]);let st=null;const xe=Ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Be="http://www.w3.org/1998/Math/MathML",$t="http://www.w3.org/2000/svg",et="http://www.w3.org/1999/xhtml";let dt=et,Lt=!1,qt=null;const At=Ct({},[Be,$t,et],Wg);let Et=Ct({},["mi","mo","mn","ms","mtext"]),B=Ct({},["annotation-xml"]);const J=Ct({},["title","style","font","a","script"]);let de=null;const _e=["application/xhtml+xml","text/html"],at="text/html";let qe=null,ft=null;const $n=s.createElement("form"),en=function(oe){return oe instanceof RegExp||oe instanceof Function},qn=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===oe)){if((!oe||typeof oe!="object")&&(oe={}),oe=Ga(oe),de=_e.indexOf(oe.PARSER_MEDIA_TYPE)===-1?at:oe.PARSER_MEDIA_TYPE,qe=de==="application/xhtml+xml"?Wg:Qf,D=_r(oe,"ALLOWED_TAGS")?Ct({},oe.ALLOWED_TAGS,qe):Y,K=_r(oe,"ALLOWED_ATTR")?Ct({},oe.ALLOWED_ATTR,qe):Z,qt=_r(oe,"ALLOWED_NAMESPACES")?Ct({},oe.ALLOWED_NAMESPACES,Wg):At,st=_r(oe,"ADD_URI_SAFE_ATTR")?Ct(Ga(xe),oe.ADD_URI_SAFE_ATTR,qe):xe,we=_r(oe,"ADD_DATA_URI_TAGS")?Ct(Ga(ze),oe.ADD_DATA_URI_TAGS,qe):ze,wt=_r(oe,"FORBID_CONTENTS")?Ct({},oe.FORBID_CONTENTS,qe):jt,ie=_r(oe,"FORBID_TAGS")?Ct({},oe.FORBID_TAGS,qe):{},Ne=_r(oe,"FORBID_ATTR")?Ct({},oe.FORBID_ATTR,qe):{},ot=_r(oe,"USE_PROFILES")?oe.USE_PROFILES:!1,he=oe.ALLOW_ARIA_ATTR!==!1,ve=oe.ALLOW_DATA_ATTR!==!1,Ee=oe.ALLOW_UNKNOWN_PROTOCOLS||!1,ye=oe.ALLOW_SELF_CLOSE_IN_ATTR!==!1,pe=oe.SAFE_FOR_TEMPLATES||!1,Pe=oe.SAFE_FOR_XML!==!1,ue=oe.WHOLE_DOCUMENT||!1,Xe=oe.RETURN_DOM||!1,je=oe.RETURN_DOM_FRAGMENT||!1,fe=oe.RETURN_TRUSTED_TYPE||!1,Te=oe.FORCE_BODY||!1,De=oe.SANITIZE_DOM!==!1,te=oe.SANITIZE_NAMED_PROPS||!1,We=oe.KEEP_CONTENT!==!1,rt=oe.IN_PLACE||!1,Q=oe.ALLOWED_URI_REGEXP||dC,dt=oe.NAMESPACE||et,Et=oe.MATHML_TEXT_INTEGRATION_POINTS||Et,B=oe.HTML_INTEGRATION_POINTS||B,se=oe.CUSTOM_ELEMENT_HANDLING||{},oe.CUSTOM_ELEMENT_HANDLING&&en(oe.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(se.tagNameCheck=oe.CUSTOM_ELEMENT_HANDLING.tagNameCheck),oe.CUSTOM_ELEMENT_HANDLING&&en(oe.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(se.attributeNameCheck=oe.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),oe.CUSTOM_ELEMENT_HANDLING&&typeof oe.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(se.allowCustomizedBuiltInElements=oe.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),pe&&(ve=!1),je&&(Xe=!0),ot&&(D=Ct({},r0),K=[],ot.html===!0&&(Ct(D,s0),Ct(K,o0)),ot.svg===!0&&(Ct(D,Hg),Ct(K,Gg),Ct(K,Sf)),ot.svgFilters===!0&&(Ct(D,Bg),Ct(K,Gg),Ct(K,Sf)),ot.mathMl===!0&&(Ct(D,qg),Ct(K,a0),Ct(K,Sf))),oe.ADD_TAGS&&(D===Y&&(D=Ga(D)),Ct(D,oe.ADD_TAGS,qe)),oe.ADD_ATTR&&(K===Z&&(K=Ga(K)),Ct(K,oe.ADD_ATTR,qe)),oe.ADD_URI_SAFE_ATTR&&Ct(st,oe.ADD_URI_SAFE_ATTR,qe),oe.FORBID_CONTENTS&&(wt===jt&&(wt=Ga(wt)),Ct(wt,oe.FORBID_CONTENTS,qe)),We&&(D["#text"]=!0),ue&&Ct(D,["html","head","body"]),D.table&&(Ct(D,["tbody"]),delete ie.tbody),oe.TRUSTED_TYPES_POLICY){if(typeof oe.TRUSTED_TYPES_POLICY.createHTML!="function")throw Uc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof oe.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Uc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=oe.TRUSTED_TYPES_POLICY,E=S.createHTML("")}else S===void 0&&(S=D5(m,o)),S!==null&&typeof E=="string"&&(E=S.createHTML(""));bs&&bs(oe),ft=oe}},kn=Ct({},[...Hg,...Bg,..._5]),pn=Ct({},[...qg,...$5]),Gn=function(oe){let Re=N(oe);(!Re||!Re.tagName)&&(Re={namespaceURI:dt,tagName:"template"});const Ye=Qf(oe.tagName),Mt=Qf(Re.tagName);return qt[oe.namespaceURI]?oe.namespaceURI===$t?Re.namespaceURI===et?Ye==="svg":Re.namespaceURI===Be?Ye==="svg"&&(Mt==="annotation-xml"||Et[Mt]):!!kn[Ye]:oe.namespaceURI===Be?Re.namespaceURI===et?Ye==="math":Re.namespaceURI===$t?Ye==="math"&&B[Mt]:!!pn[Ye]:oe.namespaceURI===et?Re.namespaceURI===$t&&!B[Mt]||Re.namespaceURI===Be&&!Et[Mt]?!1:!pn[Ye]&&(J[Ye]||!kn[Ye]):!!(de==="application/xhtml+xml"&&qt[oe.namespaceURI]):!1},tt=function(oe){zc(n.removed,{element:oe});try{N(oe).removeChild(oe)}catch{j(oe)}},xt=function(oe,Re){try{zc(n.removed,{attribute:Re.getAttributeNode(oe),from:Re})}catch{zc(n.removed,{attribute:null,from:Re})}if(Re.removeAttribute(oe),oe==="is")if(Xe||je)try{tt(Re)}catch{}else try{Re.setAttribute(oe,"")}catch{}},Rt=function(oe){let Re=null,Ye=null;if(Te)oe="<remove></remove>"+oe;else{const pt=n0(oe,/^[\r\n\t ]+/);Ye=pt&&pt[0]}de==="application/xhtml+xml"&&dt===et&&(oe='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+oe+"</body></html>");const Mt=S?S.createHTML(oe):oe;if(dt===et)try{Re=new b().parseFromString(Mt,de)}catch{}if(!Re||!Re.documentElement){Re=$.createDocument(dt,"template",null);try{Re.documentElement.innerHTML=Lt?E:Mt}catch{}}const Nn=Re.body||Re.documentElement;return oe&&Ye&&Nn.insertBefore(s.createTextNode(Ye),Nn.childNodes[0]||null),dt===et?P.call(Re,ue?"html":"body")[0]:ue?Re.documentElement:Nn},gn=function(oe){return L.call(oe.ownerDocument||oe,oe,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},dn=function(oe){return oe instanceof v&&(typeof oe.nodeName!="string"||typeof oe.textContent!="string"||typeof oe.removeChild!="function"||!(oe.attributes instanceof h)||typeof oe.removeAttribute!="function"||typeof oe.setAttribute!="function"||typeof oe.namespaceURI!="string"||typeof oe.insertBefore!="function"||typeof oe.hasChildNodes!="function")},re=function(oe){return typeof d=="function"&&oe instanceof d};function Me(Ge,oe,Re){Nf(Ge,Ye=>{Ye.call(n,oe,Re,ft)})}const bt=function(oe){let Re=null;if(Me(T.beforeSanitizeElements,oe,null),dn(oe))return tt(oe),!0;const Ye=qe(oe.nodeName);if(Me(T.uponSanitizeElement,oe,{tagName:Ye,allowedTags:D}),oe.hasChildNodes()&&!re(oe.firstElementChild)&&fs(/<[/\w]/g,oe.innerHTML)&&fs(/<[/\w]/g,oe.textContent)||oe.nodeType===Hc.progressingInstruction||Pe&&oe.nodeType===Hc.comment&&fs(/<[/\w]/g,oe.data))return tt(oe),!0;if(!D[Ye]||ie[Ye]){if(!ie[Ye]&&Bt(Ye)&&(se.tagNameCheck instanceof RegExp&&fs(se.tagNameCheck,Ye)||se.tagNameCheck instanceof Function&&se.tagNameCheck(Ye)))return!1;if(We&&!wt[Ye]){const Mt=N(oe)||oe.parentNode,Nn=C(oe)||oe.childNodes;if(Nn&&Mt){const pt=Nn.length;for(let Mn=pt-1;Mn>=0;--Mn){const Kn=y(Nn[Mn],!0);Kn.__removalCount=(oe.__removalCount||0)+1,Mt.insertBefore(Kn,k(oe))}}}return tt(oe),!0}return oe instanceof u&&!Gn(oe)||(Ye==="noscript"||Ye==="noembed"||Ye==="noframes")&&fs(/<\/no(script|embed|frames)/i,oe.innerHTML)?(tt(oe),!0):(pe&&oe.nodeType===Hc.text&&(Re=oe.textContent,Nf([M,F,I],Mt=>{Re=Fc(Re,Mt," ")}),oe.textContent!==Re&&(zc(n.removed,{element:oe.cloneNode()}),oe.textContent=Re)),Me(T.afterSanitizeElements,oe,null),!1)},Tt=function(oe,Re,Ye){if(De&&(Re==="id"||Re==="name")&&(Ye in s||Ye in $n))return!1;if(!(ve&&!Ne[Re]&&fs(V,Re))){if(!(he&&fs(G,Re))){if(!K[Re]||Ne[Re]){if(!(Bt(oe)&&(se.tagNameCheck instanceof RegExp&&fs(se.tagNameCheck,oe)||se.tagNameCheck instanceof Function&&se.tagNameCheck(oe))&&(se.attributeNameCheck instanceof RegExp&&fs(se.attributeNameCheck,Re)||se.attributeNameCheck instanceof Function&&se.attributeNameCheck(Re))||Re==="is"&&se.allowCustomizedBuiltInElements&&(se.tagNameCheck instanceof RegExp&&fs(se.tagNameCheck,Ye)||se.tagNameCheck instanceof Function&&se.tagNameCheck(Ye))))return!1}else if(!st[Re]){if(!fs(Q,Fc(Ye,H,""))){if(!((Re==="src"||Re==="xlink:href"||Re==="href")&&oe!=="script"&&k5(Ye,"data:")===0&&we[oe])){if(!(Ee&&!fs(q,Fc(Ye,H,"")))){if(Ye)return!1}}}}}}return!0},Bt=function(oe){return oe!=="annotation-xml"&&n0(oe,U)},On=function(oe){Me(T.beforeSanitizeAttributes,oe,null);const{attributes:Re}=oe;if(!Re||dn(oe))return;const Ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let Mt=Re.length;for(;Mt--;){const Nn=Re[Mt],{name:pt,namespaceURI:Mn,value:Kn}=Nn,Ts=qe(pt);let Qt=pt==="value"?Kn:N5(Kn);if(Ye.attrName=Ts,Ye.attrValue=Qt,Ye.keepAttr=!0,Ye.forceKeepAttr=void 0,Me(T.uponSanitizeAttribute,oe,Ye),Qt=Ye.attrValue,te&&(Ts==="id"||Ts==="name")&&(xt(pt,oe),Qt=Ie+Qt),Pe&&fs(/((--!?|])>)|<\/(style|title)/i,Qt)){xt(pt,oe);continue}if(Ye.forceKeepAttr||(xt(pt,oe),!Ye.keepAttr))continue;if(!ye&&fs(/\/>/i,Qt)){xt(pt,oe);continue}pe&&Nf([M,F,I],so=>{Qt=Fc(Qt,so," ")});const Vs=qe(oe.nodeName);if(Tt(Vs,Ts,Qt)){if(S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Mn)switch(m.getAttributeType(Vs,Ts)){case"TrustedHTML":{Qt=S.createHTML(Qt);break}case"TrustedScriptURL":{Qt=S.createScriptURL(Qt);break}}try{Mn?oe.setAttributeNS(Mn,pt,Qt):oe.setAttribute(pt,Qt),dn(oe)?tt(oe):t0(n.removed)}catch{}}}Me(T.afterSanitizeAttributes,oe,null)},Ln=function Ge(oe){let Re=null;const Ye=gn(oe);for(Me(T.beforeSanitizeShadowDOM,oe,null);Re=Ye.nextNode();)Me(T.uponSanitizeShadowNode,Re,null),bt(Re),On(Re),Re.content instanceof i&&Ge(Re.content);Me(T.afterSanitizeShadowDOM,oe,null)};return n.sanitize=function(Ge){let oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Re=null,Ye=null,Mt=null,Nn=null;if(Lt=!Ge,Lt&&(Ge="<!-->"),typeof Ge!="string"&&!re(Ge))if(typeof Ge.toString=="function"){if(Ge=Ge.toString(),typeof Ge!="string")throw Uc("dirty is not a string, aborting")}else throw Uc("toString is not a function");if(!n.isSupported)return Ge;if(ge||qn(oe),n.removed=[],typeof Ge=="string"&&(rt=!1),rt){if(Ge.nodeName){const Kn=qe(Ge.nodeName);if(!D[Kn]||ie[Kn])throw Uc("root node is forbidden and cannot be sanitized in-place")}}else if(Ge instanceof d)Re=Rt("<!---->"),Ye=Re.ownerDocument.importNode(Ge,!0),Ye.nodeType===Hc.element&&Ye.nodeName==="BODY"||Ye.nodeName==="HTML"?Re=Ye:Re.appendChild(Ye);else{if(!Xe&&!pe&&!ue&&Ge.indexOf("<")===-1)return S&&fe?S.createHTML(Ge):Ge;if(Re=Rt(Ge),!Re)return Xe?null:fe?E:""}Re&&Te&&tt(Re.firstChild);const pt=gn(rt?Ge:Re);for(;Mt=pt.nextNode();)bt(Mt),On(Mt),Mt.content instanceof i&&Ln(Mt.content);if(rt)return Ge;if(Xe){if(je)for(Nn=A.call(Re.ownerDocument);Re.firstChild;)Nn.appendChild(Re.firstChild);else Nn=Re;return(K.shadowroot||K.shadowrootmode)&&(Nn=O.call(r,Nn,!0)),Nn}let Mn=ue?Re.outerHTML:Re.innerHTML;return ue&&D["!doctype"]&&Re.ownerDocument&&Re.ownerDocument.doctype&&Re.ownerDocument.doctype.name&&fs(uC,Re.ownerDocument.doctype.name)&&(Mn="<!DOCTYPE "+Re.ownerDocument.doctype.name+`>
|
|
602
|
-
`+Mn),pe&&Nf([M,F,I],Kn=>{Mn=Fc(Mn,Kn," ")}),S&&fe?S.createHTML(Mn):Mn},n.setConfig=function(){let Ge=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};qn(Ge),ge=!0},n.clearConfig=function(){ft=null,ge=!1},n.isValidAttribute=function(Ge,oe,Re){ft||qn({});const Ye=qe(Ge),Mt=qe(oe);return Tt(Ye,Mt,Re)},n.addHook=function(Ge,oe){typeof oe=="function"&&zc(T[Ge],oe)},n.removeHook=function(Ge){return t0(T[Ge])},n.removeHooks=function(Ge){T[Ge]=[]},n.removeAllHooks=function(){T=l0()},n}var Jf=fC();function cv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let bi=cv();function mC(e){bi=e}const cd={exec:()=>null};function Ht(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(o,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(gs.caret,"$1"),s=s.replace(o,l),r},getRegex:()=>new RegExp(s,n)};return r}const gs={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|$))+/,F5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,U5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,W5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hC=/(?:[*+-]|\d{1,9}[.)])/,pC=Ht(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,hC).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(),dv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H5=/^[^\n]+/,uv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,B5=Ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",uv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),q5=Ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,hC).getRegex(),vh="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",fv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,G5=Ht("^ {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",fv).replace("tag",vh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),gC=Ht(dv).replace("hr",Yd).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",vh).getRegex(),K5=Ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",gC).getRegex(),mv={blockquote:K5,code:F5,def:B5,fences:U5,heading:W5,hr:Yd,html:G5,lheading:pC,list:q5,newline:z5,paragraph:gC,table:cd,text:H5},c0=Ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yd).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",vh).getRegex(),V5={...mv,table:c0,paragraph:Ht(dv).replace("hr",Yd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",c0).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",vh).getRegex()},Y5={...mv,html:Ht(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fv).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:cd,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ht(dv).replace("hr",Yd).replace("heading",` *#{1,6} *[^
|
|
603
|
-
]`).replace("lheading",pC).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Q5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,J5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,xC=/^( {2,}|\\)\n(?!\s*$)/,X5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yh=/[\p{P}\p{S}]/u,hv=/[\s\p{P}\p{S}]/u,bC=/[^\s\p{P}\p{S}]/u,Z5=Ht(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,hv).getRegex(),vC=/(?!~)[\p{P}\p{S}]/u,eI=/(?!~)[\s\p{P}\p{S}]/u,tI=/(?:[^\s\p{P}\p{S}]|~)/u,nI=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,yC=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,sI=Ht(yC,"u").replace(/punct/g,yh).getRegex(),rI=Ht(yC,"u").replace(/punct/g,vC).getRegex(),wC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oI=Ht(wC,"gu").replace(/notPunctSpace/g,bC).replace(/punctSpace/g,hv).replace(/punct/g,yh).getRegex(),aI=Ht(wC,"gu").replace(/notPunctSpace/g,tI).replace(/punctSpace/g,eI).replace(/punct/g,vC).getRegex(),iI=Ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,bC).replace(/punctSpace/g,hv).replace(/punct/g,yh).getRegex(),lI=Ht(/\\(punct)/,"gu").replace(/punct/g,yh).getRegex(),cI=Ht(/^<(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(),dI=Ht(fv).replace("(?:-->|$)","-->").getRegex(),uI=Ht("^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",dI).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),um=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fI=Ht(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",um).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jC=Ht(/^!?\[(label)\]\[(ref)\]/).replace("label",um).replace("ref",uv).getRegex(),kC=Ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",uv).getRegex(),mI=Ht("reflink|nolink(?!\\()","g").replace("reflink",jC).replace("nolink",kC).getRegex(),pv={_backpedal:cd,anyPunctuation:lI,autolink:cI,blockSkip:nI,br:xC,code:J5,del:cd,emStrongLDelim:sI,emStrongRDelimAst:oI,emStrongRDelimUnd:iI,escape:Q5,link:fI,nolink:kC,punctuation:Z5,reflink:jC,reflinkSearch:mI,tag:uI,text:X5,url:cd},hI={...pv,link:Ht(/^!?\[(label)\]\((.*?)\)/).replace("label",um).getRegex(),reflink:Ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",um).getRegex()},Ix={...pv,emStrongRDelimAst:aI,emStrongLDelim:rI,url:Ht(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},pI={...Ix,br:Ht(xC).replace("{2,}","*").getRegex(),text:Ht(Ix.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Cf={normal:mv,gfm:V5,pedantic:Y5},Bc={normal:pv,gfm:Ix,breaks:pI,pedantic:hI},gI={"&":"&","<":"<",">":">",'"':""","'":"'"},d0=e=>gI[e];function Br(e,n){if(n){if(gs.escapeTest.test(e))return e.replace(gs.escapeReplace,d0)}else if(gs.escapeTestNoEncode.test(e))return e.replace(gs.escapeReplaceNoEncode,d0);return e}function u0(e){try{e=encodeURI(e).replace(gs.percentDecode,"%")}catch{return null}return e}function f0(e,n){var i;const s=e.replace(gs.findPipe,(l,d,u)=>{let f=!1,h=d;for(;--h>=0&&u[h]==="\\";)f=!f;return f?"|":" |"}),r=s.split(gs.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(gs.slashPipe,"|");return r}function qc(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 xI(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 m0(e,n,s,r,o){const i=n.href,l=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:l,text:d,tokens:r.inlineTokens(d)};return r.state.inLink=!1,u}return{type:"image",raw:s,href:i,title:l,text:d}}function bI(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const o=r[1];return n.split(`
|
|
604
|
-
`).map(i=>{const l=i.match(s.other.beginningSpace);if(l===null)return i;const[d]=l;return d.length>=o.length?i.slice(o.length):i}).join(`
|
|
605
|
-
`)}class fm{constructor(n){Dt(this,"options");Dt(this,"rules");Dt(this,"lexer");this.options=n||bi}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:qc(r,`
|
|
606
|
-
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],o=bI(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=qc(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:qc(s[0],`
|
|
607
|
-
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=qc(s[0],`
|
|
608
|
-
`).split(`
|
|
609
|
-
`),o="",i="";const l=[];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 h=u.join(`
|
|
610
|
-
`),v=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
611
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
612
|
-
${h}`:h,i=i?`${i}
|
|
613
|
-
${v}`:v;const b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(v,l,!0),this.lexer.state.top=b,r.length===0)break;const m=l.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const x=m,y=x.raw+`
|
|
614
|
-
`+r.join(`
|
|
615
|
-
`),j=this.blockquote(y);l[l.length-1]=j,o=o.substring(0,o.length-x.raw.length)+j.raw,i=i.substring(0,i.length-x.text.length)+j.text;break}else if((m==null?void 0:m.type)==="list"){const x=m,y=x.raw+`
|
|
616
|
-
`+r.join(`
|
|
617
|
-
`),j=this.list(y);l[l.length-1]=j,o=o.substring(0,o.length-m.raw.length)+j.raw,i=i.substring(0,i.length-x.raw.length)+j.raw,r=y.substring(l.at(-1).raw.length).split(`
|
|
618
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:l,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 l=this.rules.other.listItemRegex(r);let d=!1;for(;n;){let f=!1,h="",v="";if(!(s=l.exec(n))||this.rules.block.hr.test(n))break;h=s[0],n=n.substring(h.length);let b=s[2].split(`
|
|
619
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,C=>" ".repeat(3*C.length)),m=n.split(`
|
|
620
|
-
`,1)[0],x=!b.trim(),y=0;if(this.options.pedantic?(y=2,v=b.trimStart()):x?y=s[1].length+1:(y=s[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,v=b.slice(y),y+=s[1].length),x&&this.rules.other.blankLine.test(m)&&(h+=m+`
|
|
621
|
-
`,n=n.substring(m.length+1),f=!0),!f){const C=this.rules.other.nextBulletRegex(y),N=this.rules.other.hrRegex(y),S=this.rules.other.fencesBeginRegex(y),E=this.rules.other.headingBeginRegex(y),$=this.rules.other.htmlBeginRegex(y);for(;n;){const L=n.split(`
|
|
622
|
-
`,1)[0];let A;if(m=L,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),A=m):A=m.replace(this.rules.other.tabCharGlobal," "),S.test(m)||E.test(m)||$.test(m)||C.test(m)||N.test(m))break;if(A.search(this.rules.other.nonSpaceChar)>=y||!m.trim())v+=`
|
|
623
|
-
`+A.slice(y);else{if(x||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(b)||E.test(b)||N.test(b))break;v+=`
|
|
624
|
-
`+m}!x&&!m.trim()&&(x=!0),h+=L+`
|
|
625
|
-
`,n=n.substring(L.length+1),b=A.slice(y)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(v),j&&(k=j[0]!=="[ ] ",v=v.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:h,task:!!j,checked:k,loose:!1,text:v,tokens:[]}),i.raw+=h}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 h=i.items[f].tokens.filter(b=>b.type==="space"),v=h.length>0&&h.some(b=>this.rules.other.anyLine.test(b.raw));i.loose=v}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=f0(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(`
|
|
626
|
-
`):[],l={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===o.length){for(const u of o)this.rules.other.tableAlignRight.test(u)?l.align.push("right"):this.rules.other.tableAlignCenter.test(u)?l.align.push("center"):this.rules.other.tableAlignLeft.test(u)?l.align.push("left"):l.align.push(null);for(let u=0;u<r.length;u++)l.header.push({text:r[u],tokens:this.lexer.inline(r[u]),header:!0,align:l.align[u]});for(const u of i)l.rows.push(f0(u,l.header.length).map((f,h)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:l.align[h]})));return l}}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)===`
|
|
627
|
-
`?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 l=qc(r.slice(0,-1),"\\");if((r.length-l.length)%2===0)return}else{const l=xI(s[2],"()");if(l>-1){const u=(s[0].indexOf("!")===0?5:4)+s[1].length+l;s[2]=s[2].substring(0,l),s[0]=s[0].substring(0,u).trim(),s[3]=""}}let o=s[2],i="";if(this.options.pedantic){const l=this.rules.other.pedanticHrefTitle.exec(o);l&&(o=l[1],i=l[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)),m0(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 l=r[0].charAt(0);return{type:"text",raw:l,text:l}}return m0(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 l=[...o[0]].length-1;let d,u,f=l,h=0;const v=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(v.lastIndex=0,s=s.slice(-1*n.length+l);(o=v.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])&&l%3&&!((l+u)%3)){h+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+h);const b=[...o[0]][0].length,m=n.slice(0,l+o.index+b+u);if(Math.min(l,u)%2){const y=m.slice(1,-1);return{type:"em",raw:m,text:y,tokens:this.lexer.inlineTokens(y)}}const x=m.slice(2,-2);return{type:"strong",raw:m,text:x,tokens:this.lexer.inlineTokens(x)}}}}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 l;do l=s[0],s[0]=((r=this.rules.inline._backpedal.exec(s[0]))==null?void 0:r[0])??"";while(l!==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 or{constructor(n){Dt(this,"tokens");Dt(this,"options");Dt(this,"state");Dt(this,"tokenizer");Dt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||bi,this.options.tokenizer=this.options.tokenizer||new fm,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:gs,block:Cf.normal,inline:Bc.normal};this.options.pedantic?(s.block=Cf.pedantic,s.inline=Bc.pedantic):this.options.gfm&&(s.block=Cf.gfm,this.options.breaks?s.inline=Bc.breaks:s.inline=Bc.gfm),this.tokenizer.rules=s}static get rules(){return{block:Cf,inline:Bc}}static lex(n,s){return new or(s).lex(n)}static lexInline(n,s){return new or(s).inlineTokens(n)}lex(n){n=n.replace(gs.carriageReturn,`
|
|
628
|
-
`),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,l;for(this.options.pedantic&&(n=n.replace(gs.tabCharGlobal," ").replace(gs.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+=`
|
|
629
|
-
`: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+=`
|
|
630
|
-
`+d.raw,f.text+=`
|
|
631
|
-
`+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+=`
|
|
632
|
-
`+d.raw,f.text+=`
|
|
633
|
-
`+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((l=this.options.extensions)!=null&&l.startBlock){let f=1/0;const h=n.slice(1);let v;this.options.extensions.startBlock.forEach(b=>{v=b.call({lexer:this},h),typeof v=="number"&&v>=0&&(f=Math.min(f,v))}),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+=`
|
|
634
|
-
`+d.raw,f.text+=`
|
|
635
|
-
`+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+=`
|
|
636
|
-
`+d.raw,f.text+=`
|
|
637
|
-
`+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 h=Object.keys(this.tokens.links);if(h.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)h.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,l="";for(;n;){i||(l=""),i=!1;let h;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(b=>(h=b.call({lexer:this},n,s))?(n=n.substring(h.raw.length),s.push(h),!0):!1))continue;if(h=this.tokenizer.escape(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.tag(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.link(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(h.raw.length);const b=s.at(-1);h.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=h.raw,b.text+=h.text):s.push(h);continue}if(h=this.tokenizer.emStrong(n,r,l)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.codespan(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.br(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.del(n)){n=n.substring(h.raw.length),s.push(h);continue}if(h=this.tokenizer.autolink(n)){n=n.substring(h.raw.length),s.push(h);continue}if(!this.state.inLink&&(h=this.tokenizer.url(n))){n=n.substring(h.raw.length),s.push(h);continue}let v=n;if((f=this.options.extensions)!=null&&f.startInline){let b=1/0;const m=n.slice(1);let x;this.options.extensions.startInline.forEach(y=>{x=y.call({lexer:this},m),typeof x=="number"&&x>=0&&(b=Math.min(b,x))}),b<1/0&&b>=0&&(v=n.substring(0,b+1))}if(h=this.tokenizer.inlineText(v)){n=n.substring(h.raw.length),h.raw.slice(-1)!=="_"&&(l=h.raw.slice(-1)),i=!0;const b=s.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=h.raw,b.text+=h.text):s.push(h);continue}if(n){const b="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return s}}class mm{constructor(n){Dt(this,"options");Dt(this,"parser");this.options=n||bi}space(n){return""}code({text:n,lang:s,escaped:r}){var l;const o=(l=(s||"").match(gs.notSpaceStart))==null?void 0:l[0],i=n.replace(gs.endingNewline,"")+`
|
|
638
|
-
`;return o?'<pre><code class="language-'+Br(o)+'">'+(r?i:Br(i,!0))+`</code></pre>
|
|
639
|
-
`:"<pre><code>"+(r?i:Br(i,!0))+`</code></pre>
|
|
640
|
-
`}blockquote({tokens:n}){return`<blockquote>
|
|
641
|
-
${this.parser.parse(n)}</blockquote>
|
|
642
|
-
`}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
|
|
643
|
-
`}hr(n){return`<hr>
|
|
644
|
-
`}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",l=s&&r!==1?' start="'+r+'"':"";return"<"+i+l+`>
|
|
645
|
-
`+o+"</"+i+`>
|
|
646
|
-
`}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+" "+Br(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>
|
|
647
|
-
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
648
|
-
`}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 l=n.rows[i];r="";for(let d=0;d<l.length;d++)r+=this.tablecell(l[d]);o+=this.tablerow({text:r})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
649
|
-
<thead>
|
|
650
|
-
`+s+`</thead>
|
|
651
|
-
`+o+`</table>
|
|
652
|
-
`}tablerow({text:n}){return`<tr>
|
|
653
|
-
${n}</tr>
|
|
654
|
-
`}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
|
|
655
|
-
`}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>${Br(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=u0(n);if(i===null)return o;n=i;let l='<a href="'+n+'"';return s&&(l+=' title="'+Br(s)+'"'),l+=">"+o+"</a>",l}image({href:n,title:s,text:r}){const o=u0(n);if(o===null)return Br(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${Br(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Br(n.text)}}class gv{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 ar{constructor(n){Dt(this,"options");Dt(this,"renderer");Dt(this,"textRenderer");this.options=n||bi,this.options.renderer=this.options.renderer||new mm,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new gv}static parse(n,s){return new ar(s).parse(n)}static parseInline(n,s){return new ar(s).parseInline(n)}parse(n,s=!0){var o,i;let r="";for(let l=0;l<n.length;l++){const d=n[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[d.type]){const f=d,h=this.options.extensions.renderers[f.type].call({parser:this},f);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type)){r+=h||"";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,h=this.renderer.text(f);for(;l+1<n.length&&n[l+1].type==="text";)f=n[++l],h+=`
|
|
656
|
-
`+this.renderer.text(f);s?r+=this.renderer.paragraph({type:"paragraph",raw:h,text:h,tokens:[{type:"text",raw:h,text:h,escaped:!0}]}):r+=h;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 l=0;l<n.length;l++){const d=n[l];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 dd{constructor(n){Dt(this,"options");Dt(this,"block");this.options=n||bi}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?or.lex:or.lexInline}provideParser(){return this.block?ar.parse:ar.parseInline}}Dt(dd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class vI{constructor(...n){Dt(this,"defaults",cv());Dt(this,"options",this.setOptions);Dt(this,"parse",this.parseMarkdown(!0));Dt(this,"parseInline",this.parseMarkdown(!1));Dt(this,"Parser",ar);Dt(this,"Renderer",mm);Dt(this,"TextRenderer",gv);Dt(this,"Lexer",or);Dt(this,"Tokenizer",fm);Dt(this,"Hooks",dd);this.use(...n)}walkTokens(n,s){var o,i;let r=[];for(const l of n)switch(r=r.concat(s.call(this,l)),l.type){case"table":{const d=l;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=l;r=r.concat(this.walkTokens(d.items,s));break}default:{const d=l;(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 l=s.renderers[i.name];l?s.renderers[i.name]=function(...d){let u=i.renderer.apply(this,d);return u===!1&&(u=l.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 l=s[i.level];l?l.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 mm(this.defaults);for(const l in r.renderer){if(!(l in i))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;const d=l,u=r.renderer[d],f=i[d];i[d]=(...h)=>{let v=u.apply(i,h);return v===!1&&(v=f.apply(i,h)),v||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new fm(this.defaults);for(const l in r.tokenizer){if(!(l in i))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;const d=l,u=r.tokenizer[d],f=i[d];i[d]=(...h)=>{let v=u.apply(i,h);return v===!1&&(v=f.apply(i,h)),v}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new dd;for(const l in r.hooks){if(!(l in i))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;const d=l,u=r.hooks[d],f=i[d];dd.passThroughHooks.has(l)?i[d]=h=>{if(this.defaults.async)return Promise.resolve(u.call(i,h)).then(b=>f.call(i,b));const v=u.call(i,h);return f.call(i,v)}:i[d]=(...h)=>{let v=u.apply(i,h);return v===!1&&(v=f.apply(i,h)),v}}o.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,l=r.walkTokens;o.walkTokens=function(d){let u=[];return u.push(l.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 or.lex(n,s??this.defaults)}parser(n,s){return ar.parse(n,s??this.defaults)}parseMarkdown(n){return(r,o)=>{const i={...o},l={...this.defaults,...i},d=this.onError(!!l.silent,!!l.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"));l.hooks&&(l.hooks.options=l,l.hooks.block=n);const u=l.hooks?l.hooks.provideLexer():n?or.lex:or.lexInline,f=l.hooks?l.hooks.provideParser():n?ar.parse:ar.parseInline;if(l.async)return Promise.resolve(l.hooks?l.hooks.preprocess(r):r).then(h=>u(h,l)).then(h=>l.hooks?l.hooks.processAllTokens(h):h).then(h=>l.walkTokens?Promise.all(this.walkTokens(h,l.walkTokens)).then(()=>h):h).then(h=>f(h,l)).then(h=>l.hooks?l.hooks.postprocess(h):h).catch(d);try{l.hooks&&(r=l.hooks.preprocess(r));let h=u(r,l);l.hooks&&(h=l.hooks.processAllTokens(h)),l.walkTokens&&this.walkTokens(h,l.walkTokens);let v=f(h,l);return l.hooks&&(v=l.hooks.postprocess(v)),v}catch(h){return d(h)}}}onError(n,s){return r=>{if(r.message+=`
|
|
657
|
-
Please report this to https://github.com/markedjs/marked.`,n){const o="<p>An error occurred:</p><pre>"+Br(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const ii=new vI;function zt(e,n){return ii.parse(e,n)}zt.options=zt.setOptions=function(e){return ii.setOptions(e),zt.defaults=ii.defaults,mC(zt.defaults),zt};zt.getDefaults=cv;zt.defaults=bi;zt.use=function(...e){return ii.use(...e),zt.defaults=ii.defaults,mC(zt.defaults),zt};zt.walkTokens=function(e,n){return ii.walkTokens(e,n)};zt.parseInline=ii.parseInline;zt.Parser=ar;zt.parser=ar.parse;zt.Renderer=mm;zt.TextRenderer=gv;zt.Lexer=or;zt.lexer=or.lex;zt.Tokenizer=fm;zt.Hooks=dd;zt.parse=zt;zt.options;zt.setOptions;zt.use;zt.walkTokens;zt.parseInline;ar.parse;or.lex;const yI="https://chatgpt.com/#settings",Px="chatgpt",Sd=e=>!!e&&e.startsWith(`${Px}/`)&&e.length>Px.length+1,NC="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",wI="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.",jI="This sign-in is yours: don't let other people run agents on this server with it.",kI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",NI="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",SI="Your ChatGPT sign-in expired. Sign in again.",SC="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",CI=`Counts dollars. ${SC}`,_I=new Set(["signed_out","pending","signed_in","expired"]),hm=e=>e&&typeof e=="object"&&_I.has(String(e.state))?e:null,$I=e=>e.charAt(0).toUpperCase()+e.slice(1),EI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${$I(e.plan)})`:""}`,h0="Use Claude Code's login on this machine",TI="Claude Agent runs on your Claude plan through the Claude Code CLI on this server's machine. The CLI keeps the login and calls Anthropic itself; AgentRun only asks it whether it is signed in.",RI="Only I run agents on this server",AI="Runs here would use your Claude plan, which is yours alone.",p0={agentrun:"A login of AgentRun's own (sign in once for it)",machine:"This machine's Claude Code login (~/.claude)"},OI="Not signed in. Run this in a terminal on the server's machine; the CLI opens a browser there:",LI="No Claude Code CLI here yet: the first Claude Agent run installs it. Or run this with a claude CLI of your own:",MI="The Claude Code CLI didn't say whether it is signed in. Sign in again with:",II="Turned on for another machine: Claude Agent runs here use the model keys.",PI="Requests on your Claude plan through Claude Code's login cost no dollars here; your plan's own limits apply.",DI=new Set(["off","other_machine","signed_in","signed_out","no_cli","unknown"]),g0=e=>e&&typeof e=="object"&&DI.has(String(e.state))?e:null;function zI(e){var s,r;const n=(s=e.account)!=null&&s.plan?` (${e.account.plan.charAt(0).toUpperCase()}${e.account.plan.slice(1)})`:"";return`Signed in as ${((r=e.account)==null?void 0:r.email)??"your Claude account"}${n}`}const FI="Claude Max, Ultra and Team plans include monthly API credits: a key from the Claude Console organization linked to the plan runs Claude Agent on them, AgentRun Cloud included. Pro, Free and Enterprise plans don't.";let Gc;const UI=e=>(Gc||(Jf.addHook("uponSanitizeElement",(n,s)=>{Gc??(Gc=s.allowedTags)}),Jf.sanitize("<b></b>"),Jf.removeHook("uponSanitizeElement")),(Gc==null?void 0:Gc[e.toLowerCase()])===!0),WI=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");zt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(o,i)=>UI(i)?(s++,o):WI(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
658
|
-
`)}</p>
|
|
659
|
-
`:r}}});const ka=e=>e.slice(-8),li=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 hr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const HI=e=>e.basis==="estimate",BI=e=>e.basis==="estimate"?" est.":e.basis==="reported"?" reported":"",qI=e=>e.basis==="estimate"?"A local estimate, not a bill":e.basis==="reported"?"As the provider or gateway reported it":e.basis==="unpriced"?"No model request was priced":void 0;function x0(e){const n=e==null?void 0:e.tokens;if(!n)return;const s=[`${Jn(n.input)} in`,`${Jn(n.output)} out`];return n.cache_read>0&&s.push(`${Jn(n.cache_read)} cache read`),n.cache_write>0&&s.push(`${Jn(n.cache_write)} cache write`),n.unmetered&&s.push(`${Jn(n.unmetered)} ${n.unmetered===1?"request":"requests"} unmetered`),s.join(" · ")}const Qd=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,pm=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")}`},vi=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,b0=(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.`,GI=new Set(["completed","failed","cancelled"]),Co=e=>typeof e=="string"&&GI.has(e),KI="$0 · free model",VI="Unknown · cost not read",CC=e=>e.usd===0&&e.free===!0,_C=e=>e.upper_bound===!0?"at most ":"",YI=(e,{ended:n=!1}={})=>e.usd!==null?`${_C(e)}${Qd(e.usd)}`:typeof e.so_far_usd=="number"?n?`${pm(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${pm(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function ua(e,{ended:n=!1}={}){const s=_l(e),r=(s==null?void 0:s.on)==="claude_code";if(s&&(e==null?void 0:e.usd)===0)return`${Jn(s.tokens)} tokens · ${r?"On your Claude plan":"Using ChatGPT plan"}`;const o=QI(e,n);return s?`${o} + ${r?"your Claude plan":"ChatGPT plan"}`:o}function QI(e,n){const s=vi(e),r=BI;return s?n?`${pm(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${pm(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?(e==null?void 0:e.unknown)==="booking_unread"?VI:"Unknown":CC(e)?KI:`${_C(e)}${Qd(e.usd)}${r(e)}`}const _l=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0,JI=e=>e.on==="claude_code"?PI:SC;function Jn(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 v0(e,n,{ended:s=!1,text:r}={}){const o=r??ua(e,{ended:s});return typeof n!="number"?o:(r!==void 0?XI.test(r):!vi(e)&&!_l(e)&&!!e&&e.usd!==null&&!CC(e))?`${o} of ${y0(n)}`:`${o} · cap ${y0(n)}`}const XI=/^<?\$[\d.,]+( est\.| reported)?$/;function y0(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function ZI(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 Yr(e,n){const s=Jf.sanitize(zt.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&&ZI(o,n);if(i){const l=r.ownerDocument.createElement("button");l.type="button",l.title=`Open ${i}`,l.dataset.runFile=i,l.append(...r.childNodes),r.replaceWith(l)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const xv=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))},eP=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 Hn(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()||eP(n.slice(s))}function tP(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 $C=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,EC=e=>e.refused===!0,TC=e=>e.tool_status==="failed"&&!EC(e)||e.kind==="error",nP=e=>e.paused===!0;function sP(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 h;return r.has(f.id)||(f.tool_use_id?r.has(((h=n.get(f.tool_use_id))==null?void 0:h.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),l=[],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 h=l.at(-1);if(f.kind==="error"&&(h==null?void 0:h.row.kind)==="error"&&h.row.summary===f.summary&&h.row.text===f.text&&(h.row.agent_label??null)===(f.agent_label??null)){h.times=(h.times??1)+1,h.until=f.timestamp,u=h;continue}let v;const b=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(b){const m=b.tool_status!=="failed",x=[f.tool_input_preview,b.tool_result_preview].filter(Boolean),y=b.tool_status!==null;v={row:{...b,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:m?(b.summary??"").replace(/:\s*ok$/i,""):b.summary,...f.usage?{usage:f.usage}:{}},...y?{ms:Math.max(0,Date.parse(b.timestamp)-Date.parse(f.timestamp))}:{},detail:x.length===2?`${x[0]}
|
|
660
|
-
|
|
661
|
-
→ ${x[1]}`:x[0]??null}}else v={row:f};l.push(v),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,v),u=v}return i&&l.push({row:i}),l}class Ue extends Error{constructor(s,r,o,i=!1,l){super(o);Dt(this,"fields");Dt(this,"retryAfterMs");Dt(this,"details");Dt(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=l,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Gt=e=>e instanceof Ue?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),w0=(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}`},rP=new Set(["/auth/sign-in","/setup"]);function oP({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(x,y,j={}){return(await o(x,y,j)).body}async function o(x,y,{body:j,headers:k={},signal:C,text:N=!1}={}){var L;const S=j!==void 0||x!=="GET"&&x!=="HEAD",E=await e(`${n}${y}`,{method:x,signal:C,credentials:"same-origin",headers:{accept:"application/json",...S?{"content-type":"application/json"}:{},...k},body:j===void 0?void 0:JSON.stringify(j)});if(!E.ok){E.status===401&&!rP.has(y)&&(s==null||s());const A=(L=await E.json().catch(()=>null))==null?void 0:L.error,P=new Ue(E.status,(A==null?void 0:A.code)??"http_error",(A==null?void 0:A.message)??`${x} ${y}: ${E.status}`,(A==null?void 0:A.retryable)??!1,A==null?void 0:A.request_id);throw A!=null&&A.fields&&(P.fields=A.fields),typeof(A==null?void 0:A.retry_after_ms)=="number"&&(P.retryAfterMs=A.retry_after_ms),A!=null&&A.details&&typeof A.details=="object"&&!Array.isArray(A.details)&&(P.details=A.details),Array.isArray(A==null?void 0:A.problems)&&(P.problems=A.problems),P}return{body:!N&&(E.headers.get("content-type")??"").includes("json")?await E.json():await E.text(),etag:E.headers.get("etag"),status:E.status}}const i=x=>`/agents/${encodeURIComponent(x)}`,l=x=>`/runs/${encodeURIComponent(x)}`,d=(x,y,j)=>`${i(x)}/learning/workflows/${encodeURIComponent(y)}/revisions/${encodeURIComponent(j)}/replays`,u=x=>`/settings/mcp-servers/${encodeURIComponent(x)}`,f=x=>`/triggers/${encodeURIComponent(x)}`,h=new Map,v=(x,y)=>`${i(x)}/learning/files/${encodeURIComponent(y)}`,b=x=>({text:x.body,etag:x.etag}),m={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>o("GET","/auth/session").then(x=>({status:x.status,body:x.body})),signIn:x=>r("POST","/auth/sign-in",{body:{password:x}}),setup:(x,y,j=[])=>r("POST","/setup",{body:{password:x,...y?{code:y}:{},...j.length?{import:[...j]}:{}}}),setupImport:()=>r("GET","/setup/import").then(x=>(x==null?void 0:x.offer)===!1?null:x,x=>{if(x instanceof Ue&&(x.status===404||x.status===403))return null;throw x}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),setupCode:()=>r("POST","/setup/code",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(x=50,y,j)=>r("GET",`/runs${w0(x,y,j)}`),listAgentRuns:(x,y=50,j,k={})=>r("GET",`${i(x)}/runs${w0(y,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(x,y)=>r("POST","/native/discover",{body:{project:x,...y?{runtime:y}:{}}}),connectNative:x=>r("POST","/native/connect",{body:x}),getNative:x=>r("GET",`${i(x)}/native`),verifyNative:x=>r("POST",`${i(x)}/native/verify`,{body:{}}),disconnectNative:x=>r("POST",`${i(x)}/native/disconnect`,{body:{}}),observations:({days:x=30,sessionId:y}={},j)=>{const k=new URLSearchParams({days:String(x)});return y&&k.set("session_id",y),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(x,y)=>r("POST","/connectors/enrollment",{body:{...x!=null&&x.trim()?{label:x.trim()}:{},...y?{capabilities:y}:{}}}),revokeConnector:x=>r("DELETE",`/connectors/${encodeURIComponent(x)}`),listAgents:({archived:x=!1,cursor:y}={})=>{const j=new URLSearchParams;return x&&j.set("archived","true"),y&&j.set("cursor",y),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async x=>{const y=await o("GET",i(x)),j=h.get(x);return{agent:j&&j.revision===y.body.revision&&!y.body.warnings?{...y.body,warnings:j.warnings}:y.body,etag:y.etag}},createAgent:async x=>{var j;const y=await r("POST","/agents",{body:x});return(j=y.warnings)!=null&&j.length&&h.set(y.agent_id,{revision:y.revision,warnings:y.warnings}),y},updateDefinition:async(x,y,j)=>{const k=await o("PUT",`${i(x)}/definition`,{body:y,headers:j?{"if-match":j}:{}});return h.delete(x),{agent:k.body,etag:k.etag}},listRevisions:(x,y)=>r("GET",`${i(x)}/revisions${y?`?cursor=${encodeURIComponent(y)}`:""}`),setCurrent:async(x,y)=>{const j=await r("POST",`${i(x)}/current`,{body:{revision:y}});return h.delete(x),j},archiveAgent:x=>r("POST",`${i(x)}/archive`,{body:{}}),unarchiveAgent:x=>r("POST",`${i(x)}/unarchive`,{body:{}}),agentLearning:x=>r("GET",`${i(x)}/learning`),corrections:async x=>(await o("GET",`${i(x)}/learning/corrections`)).body,writeCorrections:(x,y,j)=>r("PUT",`${i(x)}/learning/corrections`,{body:{text:y},headers:{"if-match":j}}),learningCost:(x,y)=>r("GET",`${i(x)}/learning/cost${y?`?limit=${y}`:""}`),learningPromotions:x=>r("GET",`${i(x)}/learning/promotions`),learningLoop:x=>r("GET",`${i(x)}/learning/loop`),learningAudits:x=>r("GET",`${i(x)}/learning/audits`),learnedWorkflowRevisions:(x,y,j)=>r("GET",`${i(x)}/learning/workflows/${encodeURIComponent(y)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(x,y,j)=>r("POST",`${d(x,y,j)}`,{body:{}}),learnedWorkflowReplay:(x,y,j,k)=>r("GET",`${d(x,y,j)}/${encodeURIComponent(k)}`),learningLog:(x,y)=>r("GET",`${i(x)}/learning/log?cursor=${encodeURIComponent(y)}`),readLearningFile:async(x,y)=>b(await o("GET",v(x,y),{headers:m,text:!0})),retireWorkflow:async(x,y,j)=>b(await o("POST",`${v(x,y)}/retire`,{body:{},headers:{...m,"if-match":j},text:!0})),approveWorkflow:async(x,y,j)=>b(await o("POST",`${v(x,y)}/approve`,{body:{},headers:{...m,"if-match":j},text:!0})),restoreWorkflow:async(x,y,j)=>b(await o("POST",`${v(x,y)}/restore`,{body:{},headers:{...m,"if-match":j},text:!0})),forgetSignIn:(x,y)=>r("DELETE",`${i(x)}/sign-ins/${encodeURIComponent(y)}`),getRun:x=>r("GET",l(x)),runLearningResult:x=>r("GET",`${l(x)}/learning`),runLearningDiff:x=>r("GET",`${l(x)}/learning/diff`),runLearning:x=>r("GET",`${l(x)}/learning`),runComputer:x=>r("GET",`${l(x)}/computer`),takeOverComputer:x=>r("POST",`${l(x)}/computer/take-over`,{body:{}}),handBackComputer:(x,y)=>r("POST",`${l(x)}/computer/hand-back`,{body:y?{outcome:y}:{}}),archiveRun:x=>r("POST",`${l(x)}/archive`,{body:{}}),unarchiveRun:x=>r("POST",`${l(x)}/unarchive`,{body:{}}),raiseCap:(x,y)=>r("PATCH",l(x),{body:{max_cost_usd:y}}),gradeRun:(x,y)=>r("PUT",`${l(x)}/grade`,{body:y}),startRun:async(x,y,j)=>{const k=await o("POST",`${i(x)}/runs`,{body:y,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(x,{after:y,waitMs:j,signal:k}={})=>{const C=new URLSearchParams;return y!==void 0&&C.set("after",String(y)),j!==void 0&&C.set("wait_ms",String(j)),r("GET",`${l(x)}/timeline${C.size?`?${C}`:""}`,{signal:k})},listFiles:x=>r("GET",`${l(x)}/files`),deleteUpload:x=>r("DELETE",`/files/${encodeURIComponent(x)}`),readFile:(x,y)=>r("GET",`${l(x)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(x,y,j)=>r("POST",`${l(x)}/messages`,{body:{content:y},headers:{"idempotency-key":j}}),getRunGraph:(x,y)=>r("GET",`${l(x)}/graph`,{signal:y}),runTrace:(x,y)=>r("GET",`${l(x)}/trace`,{signal:y}),runUsage:(x,y)=>r("GET",`${l(x)}/usage`,{signal:y}),pauseRun:x=>r("POST",`${l(x)}/pause`,{body:{}}),resumeRun:x=>r("POST",`${l(x)}/resume`,{body:{}}),validateWorkflow:(x,y)=>r("POST","/workflows/validate",{body:x,signal:y}),statsOver:({from:x,agent:y})=>{const j=new URLSearchParams;return x&&j.set("from",x),y&&j.set("agent",y),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(x,y)=>`${n}${l(x)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(x,y)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(x)}`,{body:{values:y}}),removeToolKey:x=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(x)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:x=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:x}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),claudeLogin:()=>r("GET","/settings/claude-login"),turnOnClaudeLogin:x=>r("PUT","/settings/claude-login",{body:{place:x,only_me:!0}}),turnOffClaudeLogin:()=>r("DELETE","/settings/claude-login"),startClaudeLogin:()=>r("POST","/settings/claude-login/login"),modelGateway:()=>r("GET","/settings/model-gateway"),saveModelGateway:x=>r("PUT","/settings/model-gateway",{body:x}),removeModelGateway:()=>r("DELETE","/settings/model-gateway"),testModelGateway:x=>r("POST","/settings/model-gateway/test",{body:x}),computers:()=>r("GET","/computers"),saveComputerKeys:(x,y)=>r("PUT",`/computers/${encodeURIComponent(x)}/keys`,{body:y}),testComputer:x=>r("POST",`/computers/${encodeURIComponent(x)}/test`),computerChoices:x=>r("GET",`/computers/${encodeURIComponent(x)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:x=>r("DELETE",`/computers/${encodeURIComponent(x)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:x=>r("PUT","/workspace/archil",{body:x}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:x=>r("PUT","/settings/webhook",{body:{url:x}}),removeWebhook:()=>r("DELETE","/settings/webhook"),rotateWebhookSecret:()=>r("POST","/settings/webhook/secret"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),slack:()=>r("GET","/settings/slack"),saveSlack:x=>r("PUT","/settings/slack",{body:x}),removeSlack:()=>r("DELETE","/settings/slack"),testSlack:()=>r("POST","/settings/slack/test",{body:{}}),slackDeliveries:()=>r("GET","/settings/slack/deliveries"),redeliverSlack:x=>r("POST",`/settings/slack/deliveries/${encodeURIComponent(x)}/redeliver`,{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:x=>r("PUT","/settings/email",{body:x}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(x={})=>r("POST","/settings/email/test",{body:x}),listTriggers:()=>r("GET","/triggers"),getTrigger:x=>r("GET",f(x)),createTrigger:(x,y)=>r("POST","/triggers",{body:x,headers:{"idempotency-key":y}}),rotateTriggerSecret:x=>r("POST",`${f(x)}/secret`),updateTrigger:(x,y)=>r("PATCH",f(x),{body:y}),deleteTrigger:x=>r("DELETE",f(x)),fireTrigger:(x,y)=>r("POST",`${f(x)}/fire`,{body:{},headers:{"idempotency-key":y}}),triggerFirings:x=>r("GET",`${f(x)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:x=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(x)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(x,y,j)=>r("POST",`/templates/${encodeURIComponent(x)}/apply`,{body:y,headers:{"idempotency-key":j}}),importTemplate:(x,y={})=>r("POST","/templates/import",{body:{source:x,...y.dryRun?{dry_run:!0}:{},...y.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:x=>r("DELETE",`/templates/${encodeURIComponent(x)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(x,y,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:x,auth:y,...j?{name:j}:{}}}),saveMcpServer:(x,y,j,k={})=>r("PUT",u(x),{body:{url:y,auth:j,...k}}),composioTools:(x,y)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:x,toolkit:y}}),saveComposioServer:(x,y,j,k)=>r("PUT",`${u(x)}/composio`,{body:{api_key:y,toolkit:j,tools:k}}),refreshMcpServer:x=>r("POST",`${u(x)}/refresh`,{body:{}}),deleteMcpServer:x=>r("DELETE",u(x)),composioEvents:x=>r("GET",`${u(x)}/composio/events`),composioTriggers:x=>r("GET",`${u(x)}/composio/triggers`),rotateComposioSecret:x=>r("POST",`${u(x)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:x=>r("DELETE",`${u(x)}/composio/subscription`),startMcpSignIn:(x,y)=>r("POST",`${u(x)}/oauth/start`,{body:y}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:x=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:x}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:x=>r("POST","/integrations/github/connect",{body:x?{org:x}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:x=>r("PUT","/settings/tools",{body:x}),stop:x=>r("POST",`${l(x)}/stop`,{body:{}}),answerApproval:(x,y,j,k,C)=>r("POST",`${l(x)}/approvals/${encodeURIComponent(y)}`,{body:{decision:j,...k?{note:k}:{},...C?{confirm_destructive:!0}:{}}}),cancel:x=>r("POST",`${l(x)}/cancel`,{body:{}})}}async function Kr(e,n,s=100){const r=[];let o=null;for(let i=0;i<s;i++){const l=await e(o);if(r.push(...n(l)),!l.next_cursor)break;o=l.next_cursor}return r}async function RC(e,n,{onRows:s,onPage:r,signal:o,waitMs:i=25e3,minDelayMs:l=250}){let d=[],u,f;for(;!(o!=null&&o.aborted);){const h=await e.getTimeline(n,u===void 0?{signal:o}:{after:u,waitMs:i,signal:o}).catch(b=>{if(o!=null&&o.aborted)return null;throw b});if(!h||o!=null&&o.aborted||(f=h,s&&(d=tP(d,h)),r==null||r(h),s==null||s(d),h.final&&!h.has_more))break;u=h.next_after;const v=Math.max(l,h.unchanged?h.poll_after_ms??0:0);v&&await new Promise(b=>setTimeout(b,v))}return f}const bv=e=>`#/observations/${encodeURIComponent(e)}`,gm=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e,aP=e=>[e.display_name,e.project_name??"",gm(e.harness),...e.models,e.id,e.external_session_id,e.source_id,e.connector_id].join(" ").toLowerCase();function wh(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 vv=e=>{const n=wh(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},tl=e=>e==null?"—":e.toLocaleString("en-US");function yv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(0),[h,v]=g.useState(!1);return g.useEffect(()=>{i(null),d(null)},[e,n,s,r]),g.useEffect(()=>{let b=!0;if(!n||typeof e.observations!="function"){v(!1);return}let m=null,x,y;const j=async()=>{if(!b||m)return;clearTimeout(x);const C=m=new AbortController,N=()=>b&&m===C;v(!0);const S=()=>{clearTimeout(E),N()&&(m=null,y=void 0,v(!1),clearTimeout(x),x=setTimeout(k,15e3))},E=y=setTimeout(()=>{N()&&(d("The observation read timed out. Try refreshing again."),C.abort(),S())},3e4);try{const $=await e.observations({days:s,sessionId:r},C.signal);N()&&(i($),d(null))}catch($){N()&&($ instanceof Ue&&$.status===404?(i(null),d(null)):d(Gt($)))}finally{S()}},k=()=>{!b||m||(document.hidden?(clearTimeout(x),x=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{b=!1,clearTimeout(x),clearTimeout(y),m==null||m.abort(),m=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:o,error:l,loading:h,refresh:()=>f(b=>b+1)}}function iP({session:e}){return t.jsxs(aC,{name:e.display_name,icon:Ud,harness:e.harness,href:bv(e.id),badges:t.jsxs(t.Fragment,{children:[t.jsx(ke,{children:gm(e.harness)}),t.jsx(ke,{tone:vv(e),children:wh(e)})]}),description:e.models.join(", ")||"Model not reported",facts:t.jsxs(t.Fragment,{children:[t.jsx(AC,{session:e}),t.jsxs(ke,{children:[e.usage.status==="unavailable"?"—":tl(e.usage.total_tokens)," tokens reported"]})]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(Ut,{compact:!0,compactIcon:t.jsx(Ao,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.display_name}`,prompt:Nd(location.origin,e,"run")}),t.jsx(Ut,{compact:!0,compactIcon:t.jsx(Ym,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.display_name}`,prompt:Nd(location.origin,e,"edit")})]}),children:[e.project_name&&t.jsxs("p",{className:"break-words",children:["Project · ",e.project_name]}),t.jsxs("p",{className:"font-mono",children:["Session ",e.external_session_id.slice(-8)]}),t.jsxs("p",{children:["Last reported ",ht(e.received_at)]})]})}function AC({session:e,controls:n=!1}){const s=e.learning,r=!s||["on","off"].includes(s.state)&&!s.agent_id?"unknown":s.state;return t.jsx(iC,{controls:n,state:r,href:s!=null&&s.agent_id?`#/agents/${encodeURIComponent(s.agent_id)}/learning`:void 0,prompt:Nd(location.origin,e,"learning"),reason:Dx(e),awaitingActivation:(s==null?void 0:s.reason)==="awaiting_activation",serverDisabled:(s==null?void 0:s.reason)==="server_disabled"})}function Dx(e){var n;return{source_setup_required:"Set up learning hooks in this agent's source project.",source_unknown:"Learning has not been verified for this agent. Check its source project before setting it up.",delegated_session:"Delegated sessions do not run the project's learning hooks. Configure learning on the parent coding session.",connection_unavailable:"The learning connection is unavailable. Check the source project's connection and hooks.",server_disabled:"Learning is disabled on this server. Its owner must enable it before this agent can learn.",agent_disabled:"Learning is off for this project. Enable it in the project's Learning settings.",awaiting_activation:"Learning is configured, but this session has not reported an activated hook yet. Verify hook trust and start a new prompt in the original coding agent."}[((n=e.learning)==null?void 0:n.reason)??""]}function lP({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",tl(e.input_tokens)],["Output",tl(e.output_tokens)],["Cache writes",tl(e.cache_write_tokens)],["Cache reads",tl(e.cache_read_tokens)],["Total tokens",tl(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 cP({v2:e,sessionId:n,go:s}){var i,l,d;const r=yv(e,{sessionId:n}),o=(i=r.data)==null?void 0:i.sessions.find(u=>u.id===n);return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Connected agent detail",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap gap-2 px-5"),children:[t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(Wn,{"aria-hidden":!0})}),t.jsx(Ud,{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)??"Connected agent"}),t.jsx(W,{size:"icon","aria-label":"Refresh agent",disabled:r.loading,onClick:r.refresh,children:t.jsx(pi,{"aria-hidden":!0})}),o&&t.jsxs(t.Fragment,{children:[t.jsx(Ut,{label:"Edit agent",prompt:Nd(location.origin,o,"edit")}),t.jsx(Ut,{variant:"primary",label:"Run agent",prompt:Nd(location.origin,o,"run")})]})]}),t.jsxs("main",{className:"mx-auto w-full max-w-page space-y-6 p-5 md:p-8",children:[r.error&&t.jsxs(ct,{tone:"error",children:["Could not read this agent: ",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:vv(o),children:wh(o)}),t.jsx(ke,{children:gm(o.harness)})]})]}),t.jsx(ct,{children:"Activity and token usage come from the original application. Run and Edit hand off to your coding agent; work and stop controls stay in that application."}),t.jsxs("section",{className:"space-y-3 border bg-card p-4","aria-label":"Learning for this agent",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Learn as you code"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Learning settings apply to the source project and coding runtime. Verified hooks record future completed prompts and deliver your saved corrections on later prompts. Workflow learning needs an approved tool connection and is unavailable for this CLI connection."}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsx(AC,{session:o,controls:!0})}),Dx(o)?t.jsx("p",{className:"text-small text-muted-foreground",children:Dx(o)}):((l=o.learning)==null?void 0:l.state)==="unsupported"?t.jsx("p",{className:"text-small text-muted-foreground",children:"This connection does not support learning. Continue using its original application."}):((d=o.learning)==null?void 0:d.state)==="unknown"||!o.learning?t.jsx("p",{className:"text-small text-muted-foreground",children:"Learning has not been verified for this agent. Check its source project before setting it up."}):null]}),t.jsx("dl",{className:"grid gap-4 border bg-card p-4 sm:grid-cols-2",children:[["Harness",gm(o.harness)],["Model",o.models.join(", ")||"Not reported"],["Project",o.project_name||"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.external_session_id],["Source",o.source_id],["Connector",o.connector_id],["Record",o.id]].map(([u,f])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:u}),t.jsx("dd",{className:"mt-1 break-all text-body",children:f})]},u))}),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(lP,{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 connected agent…":r.data?"This agent was not found.":"Connected agent activity is unavailable on this server."})]})]})}function wv(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 dP=800,uP=16;function Kg(){const e=g.useRef(null);return g.useEffect(()=>{const n=e.current;if(!n)return;let s;const r=()=>{n.setAttribute("data-scrolling",""),clearTimeout(s),s=setTimeout(()=>n.removeAttribute("data-scrolling"),dP)},o=l=>n.toggleAttribute("data-scroll-lane",l.clientX>=n.getBoundingClientRect().right-uP),i=()=>n.removeAttribute("data-scroll-lane");return n.addEventListener("scroll",r,{passive:!0}),n.addEventListener("pointermove",o,{passive:!0}),n.addEventListener("pointerleave",i),()=>{n.removeEventListener("scroll",r),n.removeEventListener("pointermove",o),n.removeEventListener("pointerleave",i),clearTimeout(s),n.removeAttribute("data-scrolling"),n.removeAttribute("data-scroll-lane")}},[]),e}const sn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),fP=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),zx=128,mP=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Fx=(e,n=0)=>n>zx?'"…"':Array.isArray(e)?`[${e.map(s=>Fx(s,n+1)).join(",")}]`:sn(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Fx(e[s],n+1)}`).join(",")}}`:mP(e),hP=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")},Kc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),pP=e=>{switch(e.node){case"chain":return Kc(e,"steps");case"parallel":return Kc(e,"branches");case"map":case"loop":return Kc(e,"body");case"route":return sn(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,sn(s)?Kc(s,"body"):s]))}:e;case"workflow":return sn(e.workflow)?{...e,workflow:Kc(e.workflow,"root")}:e;default:return e}};function $l(e){const n=[],s=[],r=(o,i,l,d)=>{if(!sn(o)||typeof o.node!="string"||l>zx)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:hP(Fx(pP(o))),...xP(o,d)});const u=(f,h,v,b=i,m=d)=>{!sn(f)||typeof f.node!="string"||l+1>zx||(s.push({from:b,to:h,kind:v}),r(f,h,l+1,m))};switch(o.node){case"chain":Array.isArray(o.steps)&&o.steps.forEach((f,h)=>u(f,`${i}/steps/${h}`,"next",h===0?i:`${i}/steps/${h-1}`));break;case"parallel":Array.isArray(o.branches)&&o.branches.forEach((f,h)=>u(f,`${i}/branches/${h}`,"branch"));break;case"map":u(o.body,`${i}/body`,"item");break;case"loop":u(o.body,`${i}/body`,"next");break;case"route":if(sn(o.branches))for(const[f,h]of Object.entries(o.branches))sn(h)&&u(h.body,`${i}/branches/${fP(f)}/body`,"route");break;case"workflow":sn(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,sn(o.workflow.schemas)?o.workflow.schemas:{});break}};return r(sn(e)?e.root:void 0,"/root",0,sn(e)&&sn(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const gP=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var l;for(let d=0;sn(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(l=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:l[1],f=sn(s)&&sn(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!sn(o)||!sn(o.properties)?[]:Object.entries(o.properties).map(([i,l])=>{const d=r(l),u=sn(d)&&typeof d.description=="string"?d.description:"",f=sn(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(h=>h!=="null"):[];return sn(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}})},xP=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=gP(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:sn(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!sn(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,...sn(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function OC(e,n){const s=N=>JSON.stringify([N.kind,N.label]),r=N=>{const S=new Map;for(const E of N.nodes)S.set(s(E),(S.get(s(E))??0)+1);return S},[o,i]=[r(e),r(n)],l=N=>o.get(s(N))===1&&i.get(s(N))===1,d=new Map,u=new Map,f=(N,S)=>{d.set(S,N),u.set(N,S)},h=new Map(e.nodes.filter(l).map(N=>[s(N),N.path]));for(const N of n.nodes){const S=l(N)?h.get(s(N)):void 0;S!==void 0&&f(S,N.path)}const v=new Map(e.nodes.map(N=>[N.path,N])),b=[];for(const N of n.nodes){const S=v.get(N.path);d.has(N.path)||S===void 0||u.has(S.path)||(f(S.path,N.path),(S.kind!==N.kind||S.label!==N.label)&&b.push({prev:S.path,next:N.path,was:{kind:S.kind,label:S.label},now:{kind:N.kind,label:N.label}}))}const m=[];for(const N of n.nodes){const S=d.get(N.path),E=S===void 0?void 0:v.get(S);E===void 0||E.kind!==N.kind||E.label!==N.label||E.changeCheck!==void 0&&N.changeCheck!==void 0&&E.changeCheck!==N.changeCheck&&m.push({prev:E.path,next:N.path,kind:N.kind,label:N.label})}const x=({path:N,kind:S,label:E})=>({path:N,kind:S,label:E}),y=(N,S,E)=>JSON.stringify([N,S,E]),j=new Set(e.edges.map(N=>y(N.from,N.to,N.kind))),k=new Set(n.edges.map(N=>y(N.from,N.to,N.kind))),C=(N,S,E)=>{const[$,L]=[S.get(N.from),S.get(N.to)];return $!==void 0&&L!==void 0&&E.has(y($,L,N.kind))};return{added:n.nodes.filter(N=>!d.has(N.path)).map(x),removed:e.nodes.filter(N=>!u.has(N.path)).map(x),changed:b,moved:n.nodes.flatMap(N=>{const S=d.get(N.path);return S!==void 0&&S!==N.path?[{prev:S,next:N.path}]:[]}),rewritten:m,edges:{added:n.edges.filter(N=>!C(N,d,j)).map(({from:N,to:S,kind:E})=>({from:N,to:S,kind:E})),removed:e.edges.filter(N=>!C(N,u,k)).map(({from:N,to:S,kind:E})=>({from:N,to:S,kind:E}))}}}function Un({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ee("block bg-muted motion-safe:animate-pulse",e)})}function jh({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 bP(){return t.jsxs(jh,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(Un,{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(Un,{className:"h-3 w-16"}),t.jsx(Un,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(Un,{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(xm,{n:4}),t.jsx(xm,{n:6})]})]})}function xm({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(Un,{className:"h-4 w-20"}),t.jsx(Un,{className:"h-4 flex-1"}),t.jsx(Un,{className:"hidden h-4 w-24 sm:block"})]},s))})}function cs({label:e,rows:n=8}){return t.jsx(jh,{label:e,children:t.jsx(xm,{n})})}function vP(){return t.jsxs(jh,{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(Un,{className:"h-4 w-24"}),t.jsx(Un,{className:"h-7 w-2/3"}),t.jsx(Un,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(Un,{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(Un,{className:"size-4 shrink-0"}),t.jsx(Un,{className:ee("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function yP(){return t.jsxs(jh,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(Un,{className:"h-7 w-64"}),t.jsx(Un,{className:"h-3 w-80 max-w-full"})]}),t.jsx(Un,{className:"h-12 w-full"}),t.jsx(xm,{n:5})]})}function on({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(Hs,{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(W,{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 LC({what:e,id:n,list:s}){return t.jsx(on,{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 Ux extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const Wx=e=>Math.min(1e4,1e3*2**e),j0=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),wP=e=>(e==null?void 0:e.name)==="AbortError",k0=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function jP({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,l=new Set;let d=[],u,f=null,h=null;const v=S=>{o=S;for(const E of[...i])E()},b=S=>{const E=Wx(S);clearTimeout(u),v({state:"offline",attempt:S,retryAt:Date.now()+E}),u=setTimeout(()=>void j(),E)},m=()=>{o.state!=="offline"&&b(0)},x=()=>{if(o.state!=="offline")return;clearTimeout(u),v({state:"resumed"});const S=d;d=[];for(const E of S)E();for(const E of[...l])E();u=setTimeout(()=>{o.state==="resumed"&&v({state:"online"})},s)};async function y(S){const E=setTimeout(()=>S.abort(),r);try{return!j0(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:S.signal}))}catch{return!1}finally{clearTimeout(E)}}async function j(){if(o.state!=="offline")return;clearTimeout(u),f==null||f.abort();const S=f=new AbortController,E=await y(S);f===S&&(f=null,o.state==="offline"&&(E?x():b(o.attempt+1)))}const k=()=>h??(h=y(new AbortController).finally(()=>{h=null})),C=S=>new Promise((E,$)=>{if(S!=null&&S.aborted)return $(k0(S));const L=()=>{d=d.filter(P=>P!==A),$(k0(S))},A=()=>{S==null||S.removeEventListener("abort",L),E()};d.push(A),S==null||S.addEventListener("abort",L,{once:!0})});return{fetch:async(S,E)=>{var A;const $=((E==null?void 0:E.method)??"GET").toUpperCase(),L=$==="GET"||$==="HEAD";for(let P=0;;P++){let O,T;try{O=await e(S,E)}catch(M){if((A=E==null?void 0:E.signal)!=null&&A.aborted||wP(M))throw M;T=M}if(O&&!j0(O))return x(),O;if(o.state!=="offline"&&await k()){if(O)return O;if(!L)throw new Ux;if(P>=2)throw T;await new Promise(M=>setTimeout(M,Wx(P)));continue}if(m(),!L)throw new Ux;await C(E==null?void 0:E.signal)}},link:()=>o,subscribe:S=>(i.add(S),()=>{i.delete(S)}),onResume:S=>(l.add(S),()=>{l.delete(S)}),retryNow:()=>void j()}}const kP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),MC=e=>e instanceof Ux||e instanceof TypeError&&/fetch|network/i.test(e.message);function Yt(e,n){const s=`${kP(n)} could not be read.`;if(MC(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Ue))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=(l,d)=>({title:s,why:l,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 NP(e){return MC(e)?"Can't reach agentrun-serve":e instanceof Ue?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function SP({agent:e,v2:n}){const[s,r]=g.useState(null),[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(!1),[h,v]=g.useState(null),b=g.useRef(0),m=g.useRef(!1),x=async y=>{if(m.current)return;m.current=!0;const j=++b.current;f(!0);try{const k=await n.listRevisions(e.agent_id,y);if(j!==b.current)return;r(C=>{const N=new Map((y?C??[]:[]).map(S=>[S.revision,S]));for(const S of k.revisions)N.set(S.revision,S);return[...N.values()]}),i(k.next_cursor),d(null)}catch(k){j===b.current&&d(Yt(k,y?"more versions":"the versions"))}finally{j===b.current&&(m.current=!1,f(!1))}};return g.useEffect(()=>(m.current=!1,r(null),i(null),d(null),v(null),x(null),()=>{b.current++,m.current=!1}),[n,e.agent_id,e.revision,e.revisions]),l&&!s?t.jsx(on,{problem:l,onRetry:()=>void x(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(g.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(W,{size:"sm","aria-expanded":h===y.revision,"aria-label":`View configuration for version ${y.version}`,onClick:()=>v(j=>j===y.revision?null:y.revision),children:h===y.revision?"Hide":"View"})})]}),h===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."}),l&&t.jsx(on,{problem:l,className:"m-4"}),o&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(W,{size:"sm",disabled:u,onClick:()=>void x(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(cs,{label:"Loading versions",rows:4})}const IC=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),PC=e=>[...e].sort((n,s)=>IC({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function CP(e){return e.usd===null?{total:"Unknown"}:{total:ua({usd:e.usd,basis:e.basis??"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}function _P(e){return e.totals.runs>0||!!(e.usage&&(e.usage.observed_sessions||e.usage.unknown_sessions||e.usage.known_runs||e.usage.unknown_runs||e.usage.partial_days||e.usage.by_day.length))}const jv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],hl=864e5,Hx=e=>Math.floor(e/hl)*hl;function bm(e,n=Date.now()){var r;const s=(r=jv.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(Hx(n)-(s-1)*hl).toISOString():void 0}const DC=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function $P(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(" · ")}const zC=(e,n)=>CP({usd:e.cost_usd,basis:n,unknownRuns:e.unknown_cost_runs});function kv(e){if(!e.runs)return;if(e.runs_with_token_metrics===void 0&&e.tokens===null)return"Token coverage unavailable";const n=e.runs_with_token_metrics??e.runs_with_metrics;return e.runs_with_token_metrics===0?`Token counts unavailable for ${e.runs} ${e.runs===1?"run":"runs"}`:n<e.runs?`tokens from ${n} of ${e.runs} runs`:void 0}function ci(e){return e===null?"Unknown":Jn(e)}const Nv=e=>e===null?"—":`${Math.round(e*100)}%`;function N0(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function S0(e,n,s=Date.now()){if(!e.length)return[];const r=Hx(s),o=Math.max(r-29*hl,n?Hx(Date.parse(n)):r-29*hl),i=new Map(e.map(d=>[d.day,d])),l=[];for(let d=o;d<=r;d+=hl){const u=new Date(d).toISOString().slice(0,10);l.push(i.get(u)??{day:u,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,runs_with_token_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return l}function EP(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)=>IC({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 FC({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(eo,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:jv.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Ft,{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 Xf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function C0({value:e,missing:n="Unknown"}){const s=e===null?n:e.toLocaleString("en-US"),r=g.useRef(null),o=g.useRef(null),[i,l]=g.useState(!1);return g.useEffect(()=>{const d=r.current,u=o.current;if(!d||!u)return;const f=()=>l(d.clientWidth>0&&u.getBoundingClientRect().width>d.clientWidth);if(f(),typeof ResizeObserver>"u")return;const h=new ResizeObserver(f);return h.observe(d),h.observe(u),()=>h.disconnect()},[s]),t.jsxs("span",{ref:r,className:"relative block min-w-0 overflow-hidden",children:[t.jsx("span",{ref:o,"aria-hidden":!0,className:"pointer-events-none invisible absolute w-max whitespace-nowrap",children:s}),t.jsx("span",{"data-token-count":!0,title:s,"aria-label":i?s:void 0,className:"whitespace-nowrap",children:i&&e!==null?ci(e):s})]})}function UC({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=e.usage,l=i??o,d=i?i.tokens!==null&&i.output!==null&&i.output<=i.tokens?i.tokens-i.output:null:o.input!==null&&o.cache_read!==null&&o.cache_write!==null?o.input+o.cache_read+o.cache_write:null,u=DC(o),f=zC(o,n),h=[{label:"Tokens",value:ci(l.tokens),notes:i?[i.tokens===null?"Token counts unavailable":void 0,i.tokens!==null&&(i.unknown_runs||i.unknown_sessions)?"Usage coverage is incomplete":void 0,i.partial_days?`${Xf(i.partial_days,"partial day")} excluded`:void 0,i.retention_limited?"Usage history may be incomplete beyond 90 days":void 0]:[kv(o)]},{label:"Run time",value:N0(e.time.wall_ms),notes:[`wall time of ${Xf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${N0(e.time.active_ms)} active, over ${Xf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Nv(u),notes:[o.completed+o.failed?$P(o):"No run completed or failed yet"]},{label:"Cost",value:f.total,notes:[f.note]}];return t.jsxs("div",{className:ee("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:h.map(v=>t.jsxs("li",{className:"min-w-0 border bg-card p-5",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:v.label}),t.jsx("p",{className:"mt-3 font-mono text-2xl leading-tight",children:v.label==="Tokens"?t.jsx(C0,{value:l.tokens}):v.value}),v.label==="Tokens"&&t.jsx("dl",{"aria-label":"Token breakdown",className:"mt-3 grid grid-cols-2 gap-3 text-small",children:[["Input",d],["Output",l.output]].map(([b,m])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:b}),t.jsx("dd",{className:"mt-1 font-mono","aria-label":m===null?"Not reported":void 0,children:t.jsx(C0,{value:m,missing:"—"})})]},b))}),v.notes.filter(Boolean).map(b=>t.jsx("p",{className:"mt-2 text-small leading-relaxed text-muted-foreground",children:b},b))]},v.label))}),t.jsx(LP,{days:OP(e,s),unified:!!i,reported:!!(i!=null&&i.by_day.length),unknown:l.tokens===null}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(TP,{rows:e.by_harness_effort,basis:n,unified:!!i}),t.jsx(RP,{tools:e.tools})]}),t.jsx(AP,{groups:e.by_source})]})}function rl({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 WC="px-4 py-2 text-left font-normal",qr="px-4 py-2.5 align-top";function TP({rows:e,basis:n,unified:s}){return t.jsx(rl,{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",s?"Run tokens":"Tokens","Cost"].map(r=>t.jsx("th",{className:WC,children:r},r))})}),t.jsx("tbody",{children:e.map(r=>{const o=zC(r,n),i=kv(r);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:qr,children:r.harness}),t.jsx("td",{className:ee(qr,!r.effort&&"text-muted-foreground"),children:r.effort??"unset"}),t.jsx("td",{className:qr,children:r.runs}),t.jsx("td",{className:qr,children:Nv(DC(r))}),t.jsxs("td",{className:qr,children:[t.jsx("span",{className:"whitespace-nowrap",children:ci(r.tokens)}),i&&t.jsx("span",{className:"block text-label text-muted-foreground",children:i})]}),t.jsxs("td",{className:qr,children:[t.jsx("span",{className:"whitespace-nowrap",children:o.total}),o.note&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o.note})]})]},`${r.harness}:${r.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 RP({tools:e}){return t.jsx(rl,{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:WC,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:qr,title:n.tool,children:n.label}),t.jsx("td",{className:qr,children:ci(n.calls)}),t.jsx("td",{className:ee(qr,n.errors>0&&"text-destructive-text"),children:ci(n.errors)}),t.jsx("td",{className:qr,children:Nv(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 AP({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}`}: ${Xf(n.runs,"run")}`).join(" · ")}):null}const Vg=e=>Math.max(0,e.runs-e.completed-e.failed);function _0(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 Yg=e=>e.slice(5);function OP(e,n){if(!e.usage)return S0(e.by_day,e.filter.from,n);const s=new Map(e.by_day.map(o=>[o.day,o])),r=new Map(e.usage.by_day.map(o=>[o.day,o.tokens]));for(const o of e.usage.by_day)s.has(o.day)||s.set(o.day,{day:o.day,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,runs_with_token_metrics:0,tokens:o.tokens,cost_usd:null,unknown_cost_runs:0});return S0([...s.values()].map(o=>({...o,tokens:r.has(o.day)?r.get(o.day):o.runs?null:0})),e.filter.from,n)}function LP({days:e,unified:n,reported:s,unknown:r}){const o=e.length>0&&(s||e.some(h=>h.runs>0)),i=t.jsxs(t.Fragment,{children:[t.jsx(ZR,{className:"size-4","aria-hidden":!0}),"Run activity"]}),l=t.jsxs(t.Fragment,{children:[t.jsx(aA,{className:"size-4","aria-hidden":!0}),"Token usage"]});if(!o)return t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(rl,{title:i,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(rl,{title:l,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:r?"Token usage is unavailable for this range.":"No token usage in this range."})})]});const d=_0(Math.max(...e.map(h=>h.runs))),u=_0(Math.max(...e.flatMap(h=>h.tokens===null?[]:[h.tokens]),0)),f=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:h=>h.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:h=>h.failed},{key:"other",label:"Other",className:"bg-border-strong",of:Vg}];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(rl,{title:i,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"}),f.map(h=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx("span",{className:ee("inline-block size-2.5 ",h.className),"aria-hidden":!0}),h.label]},h.key))]}),t.jsx($0,{days:e,top:d,label:"Runs per day",stack:h=>f.map(v=>({className:v.className,value:v.of(h)})),readout:h=>[`${h.runs} ${h.runs===1?"run":"runs"}`,`${h.completed} completed · ${h.failed} failed · ${Vg(h)} other`]})]})}),t.jsx(rl,{title:l,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 text-small font-semibold",children:["Tokens",e.some(h=>h.tokens===null)&&t.jsx("span",{className:"ml-2 font-normal text-muted-foreground",children:"? means unavailable"})]}),t.jsx($0,{days:e,top:u,label:"Tokens per day",format:ci,stack:h=>[{className:"bg-primary",value:h.tokens}],readout:h=>[`${ci(h.tokens)} tokens`,...n?[]:[kv(h)??`${h.runs} ${h.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(h=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:h},h))})}),t.jsx("tbody",{children:e.map(h=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:h.day}),t.jsx("td",{className:"pr-4",children:h.runs}),t.jsx("td",{className:"pr-4",children:h.completed}),t.jsx("td",{className:"pr-4",children:h.failed}),t.jsx("td",{className:"pr-4",children:Vg(h)}),t.jsx("td",{className:"pr-4",children:h.tokens===null?"Unknown":h.tokens.toLocaleString("en-US")})]},h.day))})]})})]})]})}function $0({days:e,top:n,label:s,stack:r,readout:o,format:i=l=>l.toLocaleString("en-US")}){const[d,u]=g.useState(e.length-1),f=Math.min(d,e.length-1),h=j=>{var C;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),(C=j.currentTarget.querySelectorAll('[role="listitem"]')[k])==null||C.focus())},[v,b]=g.useState(null),[m,x]=g.useState(null),y=e.find(j=>j.day===(v??m));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:()=>b(null),onKeyDown:h,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 C=r(j),N=C.some(E=>E.value===null),S=C.filter(E=>E.value!==null&&E.value>0);return t.jsxs("div",{role:"listitem",tabIndex:k===f?0:-1,"aria-label":`${j.day}: ${o(j).join(", ")}`,onMouseEnter:()=>b(j.day),onFocus:()=>{x(j.day),u(k)},onBlur:()=>x(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:[N&&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:S.map((E,$)=>t.jsx("div",{className:E.className,style:{height:Math.max(1,Math.round(E.value/n*(140-2*(S.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:Yg(e[0].day)}),e.length>2&&t.jsx("span",{children:Yg(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:Yg(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 bn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Zf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function MP(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},o=()=>{for(;s<e.length&&`
|
|
662
|
-
\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")}},l=d=>{o();const u=s;let f;const h=e[s];if(h==="{"){s++;const v={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const b=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,v[b]=l(`${d}/${Zf(b)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=v}else if(h==="["){s++;const v=[];if(o(),e[s]==="]")s++;else for(;;){if(v.push(l(`${d}/${v.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=v}else if(h==='"')f=i();else{const v=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));v||r(s>=e.length?"the text ends before the value":"expected a value"),s+=v[0].length,f=JSON.parse(v[0])}return n.set(d,{start:u,end:s}),f};try{const d=l("");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 IP(e,n){let s=1,r=-1;for(let o=0;o<Math.min(n,e.length);o++)e[o]===`
|
|
663
|
-
`&&(s++,r=o);return{line:s,col:n-r}}function HC(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(bn(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const BC=new Set(["judge","pick","sift","route"]),E0=["jev","parallel","openrouter"];function PP(e){return!bn(e)||!bn(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!bn(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 Sv(e,n,s){const r=HC(e,n);if(!bn(r))return{decision:!1};const o=r.node,i=s??{},l=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&BC.has(o)&&!l||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,h=bn(e)&&bn(e.schemas)?e.schemas:{};let v=[];Array.isArray(i.questions)?v=i.questions.map(x=>({id:x.id,type:x.type==="choice"||x.type==="score"?x.type:"noul",text:x.instructions||x.id,...x.options?{options:x.options}:{}})):o==="judge"||o==="sift"?v=typeof r.out=="string"?PP(h[r.out]):[]:o==="pick"?v=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(v=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:bn(r.branches)?Object.keys(r.branches):[]}]);const b=Array.isArray(i.images)?i.images.map(String):bn(r.images)?Object.keys(r.images):[],m=bn(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:v,...b.length?{images:b}:{},web:u==="parallel",...m?{unsure:m}:{}}}const DP=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function zP(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(!bn(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=bn(e.schemas)?e.schemas:{};bn(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),bn(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,l=(d,u)=>{if(!bn(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!DP.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 h=(b,m)=>{d[b]===void 0&&s(u,`a ${f} node needs ${b} (${m})`)},v=b=>{typeof d[b]=="string"&&!o[d[b]]&&s(`${u}/${b}`,`no schema "${d[b]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((b,m)=>l(b,`${u}/steps/${m}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((b,m)=>l(b,`${u}/branches/${m}`));break;case"map":h("itemsPath","where the items are"),h("as","where the results go"),l(d.body,`${u}/body`);break;case"loop":h("until","when it stops"),h("maxIters","a bound"),l(d.body,`${u}/body`);break;case"workflow":bn(d.workflow)?l(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":h("via","tool, executor or shell"),d.via==="tool"&&h("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":h("when","the predicate that fires it"),h("kind","the review it asks for");break;case"judge":case"sift":h("out","the questions' schema"),v("out"),h("as","where the answers go");break;case"pick":h("itemsPath","the options' list"),h("as","where the pick goes");break;case"agent":case"decide":case"extract":v("out");break}if(f==="route"){if(!bn(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[b,m]of Object.entries(d.branches))bn(m)?l(m.body,`${u}/branches/${Zf(b)}/body`):s(`${u}/branches/${Zf(b)}`,`branch "${b}" 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"),bn(d.unsure)&&bn(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(BC.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!E0.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${E0.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),bn(d.images))){const b=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(o[d.out]??{}):"");for(const m of Object.keys(d.images))b.includes(m)||s(`${u}/images/${Zf(m)}`,`the image token "${m}" 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"):l(e.root,"/root"),n}function T0(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 FP(e,n,s){let r=null,o=1/0;for(const i of n){const l=e.get(i);l&&l.start<=s&&s<=l.end&&l.end-l.start<o&&(r=i,o=l.end-l.start)}return r}function UP(e){const n=$l(e),r=n.nodes.map(i=>Sv(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 vm=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,R0=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Jd=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function Xd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Sv(e,s.path,s)]))}const _f=e=>e>=.995?"1.00":e.toFixed(2);function El(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?` ${_f(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${qC(e,u,f.choice)} ${_f(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${_f(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${_f(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},l=r.reduce((u,f)=>i(f)<i(u)?f:u,r[0]);return`${l} ${o(l)}`}function qC(e,n,s){var i,l;const r=(i=e.questions)==null?void 0:i[n],o=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(l=r.criteria)==null?void 0:l[s]:null;return typeof o=="string"&&o?o:s}const GC=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function WP(e,n,s){var v,b;const r=(b=(v=e.nodes[n])==null?void 0:v.items)==null?void 0:b.find(m=>m.index===s),o={};if(!r)return o;const i=new Set(["chain","parallel","route","map","loop","workflow"]),l=new Map(e.graph.nodes.map(m=>[m.path,m.kind])),d=GC(e.graph,n).filter(m=>!i.has(l.get(m)??""));let u=-1;d.forEach((m,x)=>{const y=e.decisions.filter(k=>k.node===m&&k.item===s),j=e.effects.filter(k=>k.node===m&&k.item===s);!y.length&&!j.length||(u=x,y.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?o[m]="failed":y.some(k=>k.status==="cancelled")?o[m]="review":j.some(k=>!k.endedAt)?o[m]=j.some(k=>k.status==="stopped")?"stopped":"working":o[m]="done")});const f=vm(r.status)??"pending";let h=!Object.values(o).includes("working");return d.forEach((m,x)=>{o[m]||(x<u||f==="done"?o[m]="done":f==="working"?(o[m]=h?"working":"pending",h=!1):f==="pending"?o[m]="pending":o[m]="not-run")}),o}function HP(e,n){var h,v,b;const s={},r=[],o={};let i=null;const l=new Map(e.graph.nodes.map(m=>[m.path,m.kind]));for(const[m,x]of Object.entries(e.nodes)){const y=vm(x.status);y&&(s[m]=y),x.branch&&r.push(`${m}/branches/${R0(x.branch)}/body`),x.items&&(o[m]=x.items.map(j=>({index:j.index,status:vm(j.status)??"pending",label:Cd(e,m,j.index),...Cv(e,m,j)}))),x.status==="escalated"&&l.get(m)==="escalate"&&(i=m)}const d={},u=m=>/\/body(\/|$)/.test(m)&&e.graph.nodes.some(x=>x.kind==="map"&&m.startsWith(`${x.path}/body`));for(const m of e.decisions){if(!m.node||m.item!==null||u(m.node))continue;const x=El(m);x&&(d[m.node]=x)}if(n&&n.item!=null&&l.get(n.path)==="map"){Object.assign(s,WP(e,n.path,n.item));const m=((b=(v=(h=e.nodes[n.path])==null?void 0:h.items)==null?void 0:v.find(x=>x.index===n.item))==null?void 0:b.branches)??{};for(const[x,y]of Object.entries(m)){const j=`${x}/branches/`,k=`${j}${R0(y)}/body`;for(let C=r.length-1;C>=0;C--)r[C].startsWith(j)&&r.splice(C,1);r.push(k);for(const C of e.graph.nodes)C.path.startsWith(j)&&!(C.path===k||C.path.startsWith(`${k}/`))&&(s[C.path]="not-run")}for(const x of e.decisions)if(x.node&&x.item===n.item&&x.node.startsWith(`${n.path}/body`)){const y=El(x);y&&(d[x.node]=y)}}if(e.run.paused){for(const[m,x]of Object.entries(s))x==="working"&&(s[m]="held");for(const m of Object.values(o))for(const x of m)x.status==="working"&&(x.status="held")}const f={};for(const[m,x]of Object.entries(e.nodes))x.model&&(f[m]={model:x.model,...x.tier?{tier:x.tier}:{}});return{status:s,taken:r,items:o,fired:i,verdict:d,meta:Xd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const Qg={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"},BP=e=>{if(!e)return;const n=e.toLowerCase();return Qg[n]??Qg[n.split(/[_\s-]/)[0]]??Qg[n.split(/[_\s-]/).at(-1)??""]};function qP(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 l=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;l&&(!r||l.sure<r.sure)&&(r=l)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function Cv(e,n,s){const r=GC(e.graph,n),o=b=>b?r.indexOf(b):-1,i=e.decisions.filter(b=>{var m;return b.item===s.index&&!!((m=b.node)!=null&&m.startsWith(`${n}/body`))}).sort((b,m)=>o(b.node)-o(m.node));let l,d;const u=Object.entries(s.branches??{}).sort(([b],[m])=>o(b)-o(m));if(u.length)[d,l]=u[u.length-1];else{const b=i.filter(m=>{var x;return m.status==="answered"&&((x=m.action)==null?void 0:x.taken)}).at(-1);b&&(l=b.action.taken,d=b.node??void 0)}const f=d&&i.filter(b=>b.node===d).at(-1)||i.filter(b=>b.status==="answered").at(-1),h=f?qP(f):void 0,v=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":BP(l);return{...l?{outcome:l}:{},...h?{p:h.p,pNote:h.note}:{},...v?{tone:v}:{}}}function Cd(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 h;return f.item===s&&!!((h=f.node)!=null&&h.startsWith(`${n}/body`))}),i=o==null?void 0:o.input,l=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof l=="string"?l:void 0}function KC(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 VC(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 Bl=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,pl=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function Tl(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 GP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return Jd(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function KP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}const VP=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function YC(e){const n=e.content_type??"";return n.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":n.startsWith("text/")||n.includes("json")?"text":VP.has(n)?"image":n.startsWith("video/")?"video":n.startsWith("audio/")?"audio":"download"}const QC=e=>e==="image"||e==="video"||e==="audio";function JC(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const XC="The agent finished without writing an answer.",A0=[0,250,1e3],YP=e=>new Promise(n=>setTimeout(n,e));function ZC(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const e_="30d",O0=10,QP=["queued","working","input_required","paused"];function JP({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=g.useState(e_),[l,d]=g.useState(r??null),[u,f]=g.useState(null),[h,v]=g.useState(!0),[b,m]=g.useState(0),x=g.useRef(0),y=g.useRef(!0);g.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const j=g.useRef(null),k=g.useRef(null);g.useEffect(()=>{const N=`${o}/${b}`;if(k.current===N)return;const S=++x.current;if(j.current===N){k.current=null,f(null),v(!1);return}k.current=N,v(!0),f(null),(async()=>{for(const[E,$]of A0.entries()){if($&&await YP($),S!==x.current||!y.current)return;try{const L=await n.statsOver({from:bm(o,s()),agent:e.agent_id});if(S!==x.current||!y.current)return;const A=!(L.runs.status_unknown>0);if(d(L),j.current=A||E===A0.length-1?N:null,A)break}catch(L){S===x.current&&f(Gt(L));break}}S===x.current&&(k.current=null,v(!1))})()},[n,e.agent_id,o,b]),g.useEffect(()=>{const N=new AbortController,S=E=>({status:E,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(QP.map(E=>n.listAgentRuns(e.agent_id,O0,null,S(E)))).then(E=>{if(N.signal.aborted)return;const $=E.flatMap(L=>L.status==="fulfilled"?L.value.runs:[]).filter(L=>!Jd(L.status));for(const L of $.slice(0,O0)){let A=`${L.status}/${L.state}`;RC(n,L.run_id,{signal:N.signal,onPage:P=>{const O=`${P.status}/${P.state}`;O!==A&&(A=O,m(T=>T+1))}}).catch(()=>{})}}),()=>N.abort()},[n,e.agent_id]);const C=l==null?void 0:l.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(FC,{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]}):!l||!C?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):_P(C)?t.jsx(UC,{a:C,basis:l.cost.basis,now:s(),refreshing:h}):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 or reported usage for this agent in this range."})})]})}function XP(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 kh={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},ZP=new Set(["completed","failed","cancelled"]);function eD(e,n,s,r,o){const l=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!l||!r[l]?null:s==="workflow"?l==="steer"&&r.steer_workflow_runs?l:null:l}const t_=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",tD=(e,n)=>e==="completed"&&!!n;function Nh(e,n,s,r,o,i,l,d){const u=ZP.has(e),f=s==="agentic",h=t_(e,i),v=tD(e,l),b=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),m=h?"Escalated":v?"Needs review":b?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],x=h||v?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",y=eD(e,n,s,r,o);return{label:m,tone:x,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 nD={Queued:Sg,Starting:Sg,Working:Sg,Completed:Il,Failed:wl,Escalated:tA,"Needs review":qm,Cancelled:H1,"Input required":Mb,Stopped:jl,Paused:G1};function ql({run:e}){const n=Nh(e.status,e.state,e.kind,kh,!0,e.error,e.review,e.computer),s=nD[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 sD=["ready","unavailable"],em=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Bx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function Zd(e){if(em(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function L0(e){const n=em(e)?e.places:void 0;if(!em(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(em).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...sD.includes(o.state)?{state:o.state}:{}})),r=Zd(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const Jg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,rD=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",oD=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",aD={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."}]}},iD=["jev","parallel"];function lD(e="jev"){const n=structuredClone(aD);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const cD={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`."}]}},dD=()=>structuredClone(cD),xa=e=>e===!0||typeof e=="object"&&e!==null&&!Array.isArray(e);function Gl(e,n,s){const{name:r,...o}=n,i={...e.definition,...o};i.description===""&&e.definition.description===void 0&&delete i.description;const l={...e.definition};i.computer!==void 0&&(delete i.place,delete l.place),i.workflow!==null&&typeof i.workflow=="object"&&!Array.isArray(i.workflow)&&(delete i.thinking,delete i.instructions,delete i.model),i.model===""&&delete i.model,i.tool_settings&&!Object.keys(i.tool_settings).length&&delete i.tool_settings;for(const f of Object.keys(i))i[f]===void 0&&delete i[f];const d=f=>{const h={...f,version:0,approvals:f.approvals??"ask",max_cost_usd:f.max_cost_usd===0?void 0:f.max_cost_usd,checkout:f.checkout==="none"?void 0:f.checkout},v=Zd(f.place),b=f.computer===void 0&&v?Bx(v):f.computer;return b!==void 0&&(h.computer=b,delete h.place),h},u=gl(d(i),d(l));return i.version=u?e.definition.version:e.revisions+1,{definition:i,...s.trim()?{note:s.trim()}:{},unchanged:u}}function gl(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=>gl(e[o],n[o]))}const _v="starter:decision",n_="starter:workflow",s_={[_v]:lD,[n_]:dD},qx=e=>e!==void 0&&Object.hasOwn(s_,e);function uD(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?iD.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const fD="You are a helpful agent. Do the task you're given and report what you found.";function mD(e){var n;return qx(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:s_[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 M0(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 hD(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:l,reason:d,harnesses:u,call_only:f,sandbox_only:h,nodes:v}=n;return[{name:s,available:r!==!1,...typeof o=="string"&&o?{summary:o}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...l!=null&&l.length?{missing:l}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...h===!0?{sandbox_only:!0}:{},...typeof v=="boolean"?{nodes:v}:{}}]})}function Sh(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function Gx(e,n,s,{mcpHarnesses:r,workflow:o=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(l=>l.name===n);return i?i.call_only?o:Sh(e,s).some(l=>l.name===n):!0}const ym=e=>o_[e]??e,I0=e=>e.map(ym).join(" and ");function P0(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${ym(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${I0(r)} do`:""}`;const o=((i=s.find(l=>l.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${I0(o)} here, not on ${ym(e)}`:"No harness runs it here"}function pD(e,n,s,r,o={}){const i=[...n,...s.filter(l=>!n.includes(l))];return{tools:i.filter(l=>Gx(e,l,r,o)),held:i.filter(l=>!Gx(e,l,r,o))}}const gD=(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,$v=new Set(["browser"]),r_=new Set(["bash","bash_background","bash_output","bash_input","bash_signal","bash_list"]),Ev=(e,n,s)=>e||n.some(r=>$v.has(r))||!n.some(r=>r_.has(r))||!s?{mode:"runner"}:s.defaultPlace;function xD(e,n){const s=Zd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>$v.has(i))&&o.some(i=>r_.has(i))&&!n))return{place:Ev(r,o,n),byDefault:!0}}const Xg=(e,n,s)=>Sh(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!$v.has(r.name):!r.sandbox_only)).map(r=>r.name),bD=["web_fetch","web_search"],D0=e=>e.some(n=>bD.includes(n)),o_={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},z0=["pi","claude-agent","codex","opencode"];function vD(e,n){const s=(o,i)=>({id:o.id,label:i,available:o.available,reason:o.reason}),r=[...z0.flatMap(o=>{const i=e.find(l=>l.id===o);return i?[s(i,o_[o])]:[]}),...e.filter(o=>!z0.includes(o.id)).map(o=>s(o,o.label??o.id))];return n&&(r.push({id:_v,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),r.push({id:n_,label:"Workflow",available:!0,reason:void 0})),r}function yD(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 Tv(e){var n,s,r;return e.status===412||e.code==="precondition_failed"?{kind:"conflict"}:(n=e.problems)!=null&&n.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((r=(s=e.fields)==null?void 0:s[0])==null?void 0:r.message)??e.message,code:e.code}}function Kx(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 Kl=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Rv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Av(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 Ch(e){const n=e==null?void 0:e.definition.native;return!n||!Av(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 eu(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Ov=g.createContext(null),Lv=g.createContext(void 0);function wD(e,n){const s=e==null?void 0:e.definition.native,r=Av(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,l]=g.useState(null),[d,u]=g.useState(0),f=()=>u(v=>v+1);return g.useEffect(()=>{if(!e||!s||!r)return;let v=!0,b=!1;const m=async()=>{if(!b){b=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");v&&l({key:o,native:j})}catch(j){v&&l({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Gt(j)}`]}})}finally{b=!1}}};m();const x=()=>{document.hidden||m()},y=setInterval(x,15e3);return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{v=!1,clearInterval(y),window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[n,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:Ch(e??void 0),refresh:f}}function Mv(){const e=g.useContext(Ov),[n,s]=g.useState(!1),r=g.useRef(!1);return e??{busy:n,begin:()=>r.current?!1:(r.current=!0,s(!0),!0),end:()=>{r.current=!1,s(!1)}}}function jD({children:e,native:n}){const s=Mv();return t.jsx(Lv.Provider,{value:n,children:t.jsx(Ov.Provider,{value:s,children:e})})}function a_({agent:e,v2:n,learning:s,onAgent:r}){const o=g.useContext(Lv)??e.definition.native,i=Mv(),l=xa(e.definition.learning),[d,u]=g.useState(!1),[f,h]=g.useState(!1),[v,b]=g.useState(null),m=o.connected&&o.state==="ready"&&o.capabilities.learning&&o.capabilities.launch,x=async y=>{if(i.begin()){h(!0),b(null);try{if(y){const{native:S}=await n.verifyNative(e.agent_id);if(!S.connected||S.state!=="ready"||!S.capabilities.learning)throw new Error(`Native learning is not ready: ${S.issues.join("; ")||eu(S)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:C,...N}=Gl(j,{learning:y},y?"Native self-improvement on":"Native self-improvement off");r==null||r(C?j:(await n.updateDefinition(e.agent_id,N,k)).agent),u(!1)}catch(j){b(Gt(j))}finally{h(!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: ",l?"On":"Off"]}),t.jsx(xi,{labelledBy:`native-learning-${e.agent_id}`,checked:l,busy:f,disabled:i.busy||!!e.archived_at||!l&&(!m||s!=="on"),onChange:y=>y?u(!0):void x(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:l?"On gives each job your corrections, and keeps a correction you give with a grade. Learned workflows are unavailable.":"Off neither supplies nor creates AgentRun learning. Saved learning stays available. Native memory behavior is unchanged."}),s!=="on"&&t.jsx(ct,{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."}),!m&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),v&&!d&&t.jsx(ct,{tone:"error",children:v}),t.jsxs(ph,{open:d,onClose:()=>{f||(u(!1),b(null))},title:"Enable self-improvement?",description:"AgentRun reuses the runtime's local sign-in.",footer:t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"sm",disabled:f||i.busy,onClick:()=>{u(!1),b(null)},children:"Cancel"}),t.jsx(W,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void x(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"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:"Each later job is given your corrections whole. Edit them on the Learning tab."}),v&&t.jsx(ct,{tone:"error",className:"mt-3",children:v})]})]})}function kD({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=g.useContext(Lv)??e.definition.native,l=Av(i),d=Mv(),u=d.busy,[f,h]=g.useState(null),v=async b=>{if(d.begin()){h(null);try{const{native:m}=await(b==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));l||r({...e,definition:{...e.definition,native:m}}),await o()}catch(m){h(Gt(m))}finally{d.end()}}};return t.jsx(Ov.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:l?"Remote connection":"Native connection"}),t.jsx(ke,{tone:i.connected&&i.state==="ready"?"success":"warning",children:eu(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void v("verify"),children:"Verify connection"}),t.jsx(W,{size:"sm",disabled:u||!i.connected,onClick:()=>void v("disconnect"),children:"Disconnect"})]}),f&&t.jsx(ct,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(a_,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(ct,{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(b=>t.jsx("li",{children:b},b))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${Kl(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Rv(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([b,m])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:b}),t.jsx("dd",{className:"break-all font-mono",children:m})]},b))}),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(b=>t.jsx("li",{className:"break-all font-mono",children:b},b))}):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(b=>t.jsx("li",{className:"break-all font-mono",children:b},b))}):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(b=>t.jsxs("li",{className:"break-all font-mono",children:[b.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",b.sha256]})]},b.path))})]}),l&&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. ",l?"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:l?"#/agents/connect?source=remote":"#/agents/connect",className:"block text-small underline underline-offset-2",children:"Connect agent"})]})})}const ND={browserbase:"Browserbase",kernel:"Kernel"},Qi=e=>ND[e]??e,F0=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),SD=5e3,U0=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function CD({agent:e,v2:n,onAgent:s,poll:r,refresh:o}){var N,S;const[i,l]=g.useState(null),[d,u]=g.useState(!1),[f,h]=g.useState(null),v=g.useRef(e);v.current=e;const b=g.useRef(r);b.current=r;const m=e.sign_ins??[],x=m.some(E=>E.state==="held");g.useEffect(()=>{if(!x||d)return;const E=setInterval(()=>b.current(),SD);return()=>clearInterval(E)},[x,d]);const y=(S=(N=e.tools)==null?void 0:N.find(E=>E.name==="browser"))==null?void 0:S.resolved;if(!m.length&&y!=="browserbase"&&y!=="kernel"&&!f)return null;const j=[...new Set(m.map(E=>E.key))].map(E=>({key:E,items:m.filter($=>$.key===E)})),k=async E=>{var $,L;u(!0),h(null);try{const P=(await n.forgetSignIn(e.agent_id,E)).removed.filter(T=>T.at_vendor==="not_deleted"),O=P.length?{tone:"warn",text:P.map(T=>`Forgotten here, but ${Qi(T.provider)} didn't confirm the delete. ${T.message??""}`.trim()).join(" ")}:null;if(h(O),l(null),!await o()){const T=v.current;s({...T,sign_ins:(T.sign_ins??[]).filter(M=>M.key!==E)}),h({tone:"warn",text:`${O?`${O.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(A){const P=A instanceof Ue&&A.code==="sign_in_held"?(($=A.details)==null?void 0:$.held_by)??((L=A.details)==null?void 0:L.handed_to):void 0;h(A instanceof Ue&&A.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...P?{run:P}:{}}:{tone:"error",text:`Not forgotten: ${Gt(A)}`}),l(null)}finally{u(!1)}},C=({key:E,items:$})=>{const L=$.length===1?`Forget the ${Qi($[0].provider)} sign-in`:`Forget the saved sign-ins for ${U0($.map(P=>Qi(P.provider)))}`,A=$.some(P=>P.state==="held");return t.jsx(W,{size:"sm",variant:"ghost",disabled:d||A,"aria-label":L,title:A?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{h(null),l(E)},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(ti,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),m.length?t.jsx("ul",{className:"border",children:j.map(E=>t.jsxs("li",{className:"border-b last:border-b-0",children:[E.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:Qi($.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 ",F0($.held_by)]}),E.items.length===1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-1"}),C(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}`)),E.items.length>1&&t.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:C(E)}),i===E.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:[E.items.length===1?`Forget the ${Qi(E.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${U0(E.items.map($=>Qi($.provider)))}?`," The agent's next run with the browser starts signed out."]}),t.jsx(W,{size:"sm",variant:"solid",disabled:d,autoFocus:!0,onClick:()=>void k(E.key),children:"Yes, forget"}),t.jsx(W,{size:"sm",variant:"ghost",disabled:d,onClick:()=>l(null),children:"Keep"})]})]},E.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: ",F0(f.run)]})]})]})}const _D=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),$D=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function Na(e,n){var l,d;const s=`${_D(n)} could not be read.`;if($D(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Ue))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=(l=e.fields)==null?void 0:l[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 Or({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(Hs,{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(W,{type:"button",onClick:n,size:"sm",children:"Try again"})})]})]})}const Xa=[{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"}],$f=e=>Xa.find(n=>n.path===e);function ED(e){var u,f;const n=tu(e),s=((u=n[0])==null?void 0:u.n)??1,r=((f=n.at(-1))==null?void 0:f.n)??s,o=[];let i=[],l=s-.5;const d=h=>{i.forEach((v,b)=>o.push({...v,at:l+(h-l)*(b+1)/(i.length+1)})),i=[]};for(const h of e){if(h.n===null){i.push(h);continue}d(h.n),l=h.n,o.push({...h,at:h.n})}return d(r+.5),o}const TD=e=>ED(e).filter(n=>n.total_usd!==null),tu=e=>e.filter(n=>n.n!==null),RD=e=>Math.min(25,Math.max(3,Math.round(e/15)));function AD(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 Vx(e){if(!(e>0))return{top:1,ticks:[0,.25,.5,.75,1]};const n=10**Math.floor(Math.log10(e/5)),s=[1,2,2.5,5,10].map(i=>i*n).find(i=>Math.ceil(e/i-1e-9)<=5),r=Math.max(1,Math.ceil(e/s-1e-9)),o=Array.from({length:r+1},(i,l)=>Math.round(l*s*1e12)/1e12);return{top:o.at(-1),ticks:o}}function OD(e,n,s){if(!e.length)return{...Vx(0),above:0};const r=e.map(d=>d.total_usd).sort((d,u)=>d-u),o=r[Math.min(r.length-1,Math.floor(r.length*.95))],{top:i,ticks:l}=Vx(Math.max(o,...n,s??0)*1.08);return{top:i,ticks:l,above:e.filter(d=>d.total_usd>i).length}}function i_(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)),l=[];for(let d=Math.ceil(e/i)*i;d<=n;d+=i)l.push(d);return!l.includes(e)&&(l[0]??1/0)-e>i/2&&l.unshift(e),l}const Ef=14,l_=e=>Math.ceil(6+Math.max(0,...e.map(n=>n.length))*6.6+8);function c_(e,n,s){const r=e.map(i=>({...i})),o=[...r].sort((i,l)=>i.at-l.at);for(let i=1;i<o.length;i++){const l=Ef-(o[i].at-o[i-1].at);l>0&&(o[i-1].at-=l/2,o[i].at+=l/2)}for(let i=o.length-1;i>=0;i--)o[i].at=Math.min(o[i].at,s-(o.length-1-i)*Ef);for(let i=0;i<o.length;i++)o[i].at=Math.max(o[i].at,n+i*Ef,i?o[i-1].at+Ef:-1/0);return r}function LD(e,n){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].at-n)<Math.abs(e[s].at-n)&&(s=r);return s}function yn(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 go(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const MD=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function ID(e,n){const s=tu(e),r=[];for(let o=0;o<s.length;o+=n){const i=s.slice(o,o+n),l=Object.fromEntries(Xa.map(({path:d})=>[d,0]));for(const d of i)l[d.path]++;r.push({from:i[0].n,to:i.at(-1).n,runs:i.length,counts:l})}return r}function Iv(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const tm=(e,n)=>`${n?Math.round(e/n*100):0}%`,_h=e=>e!=="pending"&&e!=="retired",PD="Not read: its front matter can't be read; fix the file to use it",DD={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned"},d_=(e,n)=>`${DD[e]} by ${n==="person"?"you":"a run"}`,Pv="It changed since you opened it.",zD=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.",FD="Restoring takes your password sign-in in the console.",Dv=e=>e.split(`
|
|
664
|
-
`).map(n=>n.trim()).filter(n=>n&&!n.startsWith("#")),UD=e=>new TextEncoder().encode(e).length,zv=e=>`${e} ${e===1?"correction":"corrections"}`,WD=["seeded","reflecting"],$h=e=>!!e&&WD.includes(e.state),u_=e=>(e==null?void 0:e.state)==="merged"&&Array.isArray(e.workflows)?e.workflows.filter(n=>!!n&&typeof n.file=="string"&&typeof n.name=="string"):[],Rl=(e,n)=>`${e} ${n}${e===1?"":"s"}`,wm=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},Fv=e=>`${e} learned ${e===1?"workflow waits":"workflows wait"} for your OK`;function HD(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const BD="Approving needs your password sign-in. Until then it stays out of every run.",_d=e=>`${e} ${e===1?"run":"runs"}`,qD={checker:"refused",empty:"nothing",use:"nothing",no_budget:"skipped",unknown_cost:"skipped"},jm=e=>qD[e??""]??"stopped",GD={empty:"Nothing new to keep from this run.",use:"It used what its agent learned and kept nothing.",checker:"Not kept: the checks refused it.",no_budget:"Skipped: no budget left in this run to write what it learned.",unknown_cost:"Skipped: this run's spend is unknown, so its budget can't cover writing what it learned.",seed_failed:"Started without what it learned: it couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_failed:"Not kept: learning stopped (an error)."};function Uv(e){return e.detail&&e.detail.trim()?e.detail.trim():GD[e.reason??""]??"Not kept: learning stopped."}const KD=e=>e==="seeded"?"Learns after the run":"Looking back",Yx=e=>e<9.95?Math.round(e*10)/10:Math.round(e),km=e=>{const n=Yx(e);return n<10?`${n.toFixed(1)}s`:Tl(n*1e3)},VD=(e,n)=>e>0?Math.round((n-e)/e*100):null,YD=(e,n)=>VD(Yx(e),Yx(n)),f_=e=>`${yn(e)} a run, booked`;function QD(e,n=null){const s=[`answers in ${km(e.after.median_duration_s)} instead of ${km(e.before.median_duration_s)}`];return n!==null&&s.push(`learning itself ${f_(n)}`),`Since it learned (${m_(e)}): ${s.join(" · ")}`}function m_(e){return`medians of ${_d(e.after.runs)} started from what it learned`}const JD=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)},Wv=e=>`#/agents/${encodeURIComponent(e)}/learning`;function h_(e){return e.kind===xo?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===xo?{...e,kind:xo,agent_label:null}:e}const xo="learning",XD={seeded:0,reflecting:1,merged:2,dropped:2},Qx=e=>e?XD[e.state]??0:-1,ZD=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0};function ez(e){var n;if(!e||Qx(e)<2)return"Looking back on this run…";if(e.state==="merged"){const s=u_(e),r=d=>d.map(u=>u.name.replace(/\s+/g," ").trim()).join(", "),o=s.filter(d=>!d.pending),i=s.filter(d=>d.pending),l=[...o.length?[`kept ${Rl(o.length,"workflow")} (${r(o)})`]:[],...i.length?[`${Rl(i.length,"workflow")} ${i.length===1?"waits":"wait"} for your OK (${r(i)})`]:[]];return l.length?`Looked back: ${l.join("; ")}`:`Looked back. ${((n=e.detail)==null?void 0:n.trim())||"It kept what it learned."}`}return jm(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${Uv(e)}`}function tz(e){var i;const n=h_(e),s=n.summary??"",r=TC(n)?`${s} (failed)`:s,o=(i=$C(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
|
|
665
|
-
${o.replace(/^(?=.)/gm," ")}`:r}function nz(e,n){const s=e.filter(u=>u.agent_label===xo&&u.kind!==xo);if(!s.length)return e.map(h_);const r=e.findLast(u=>u.kind===xo),o=ZD(r),i=Qx(o)>Qx(n??void 0)?o:n&&{...n,detail:n.detail??(o==null?void 0:o.detail)??(r==null?void 0:r.summary)??null},l=s[0],d={id:l.id,seq:l.seq,timestamp:l.timestamp,created_at:l.created_at,kind:xo,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:ez(i??void 0),text:[...s,...r?[r]:[]].map(tz).join(`
|
|
666
|
-
`)};return e.flatMap(u=>u===l?[d]:u.agent_label===xo||u.kind===xo?[]:[u])}const sz={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},W0=["Added","Changed","Removed"];function rz(e){const n=[],s=[];let r=0;for(const o of e.split(`
|
|
667
|
-
`)){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 oz(e){if(e==="corrections.md")return"corrections";const n=/^workflows\/([^/]+)\/(workflow\.json|README\.md)$/.exec(e);return n?`workflow ${n[1]}${n[2]==="README.md"?" (README)":""}`:e}function az(e){return e.files.map(s=>{const r=s.patch===void 0?null:rz(s.patch),o=`${s.status==="added"?"Added":s.status==="deleted"?"Removed":"Changed"}: ${oz(s.path)}`;return r?{file:s.path,said:o,before:s.status==="added"?null:r.before,after:s.status==="deleted"?null:r.after}:{file:s.path,said:o,before:null,after:null,withheld:sz[s.withheld??""]??"Not shown."}}).sort((s,r)=>W0.indexOf(s.said.split(":")[0])-W0.indexOf(r.said.split(":")[0]))}const p_=20,iz=e=>{const n=typeof e=="object"&&e!==null?e.compile_after:void 0;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:p_},lz=20,ud={revision:"New revision",promote:"Promoted",hold:"Held"},Hv={revision:"R",promote:"P",hold:"H"},g_=e=>e.decided==="replaying"?"revision":e.decided;function cz(e,n){const s=tu(e);if(!e.length||!s.length)return[];const r=s.map(l=>Date.parse(l.started_at)),o=Date.parse(e[0].started_at),i=[];for(const l of n){const d=Date.parse(l.at),u=l.decided==="promote"?s.findIndex(f=>f.took_over&&f.digest===l.digest&&(f.workflow??l.workflow)===l.workflow):!Number.isFinite(d)||d<o-1?-1:r.findIndex(f=>f>=d);u<0||i.push({kind:g_(l),n:s[u].n,at:l.at,workflow:l.workflow,digest:l.digest,reason:l.reason,record:l})}return i.sort((l,d)=>l.n-d.n)}const dz=e=>e.path!=="replay",x_=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},Bv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function uz(e,{serving:n=null,stopped:s=null}={}){if(!e)return{word:"Not decided",tone:"muted"};const r=fz(e),o=r?{proof:r}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...o}:e.digest===s?{word:"Stopped",tone:"warning",...o}:{word:"Serving",tone:mz(e)?"success":"plain",...o}:e.decided==="hold"?{word:"Held",tone:"warning",...o}:{word:"Replaying",tone:"active"}}function $d(...e){const n=uz(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const qv=(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};function fz(e){const n=e.check;return!(n!=null&&n.n)||e.decided!=="promote"&&e.decided!=="hold"?null:`checked on ${n.n} ${n.n===1?"input":"inputs"} · ${n.alone??0} alone`}const mz=e=>{var n;return(((n=e.check)==null?void 0:n.n)??0)>0},Tf=e=>`${Math.round(e*100)}%`,hz=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Za(e){var l,d,u;const n=e.check;if(!(n!=null&&n.n))return e.reason;const s=n.alone??0,r=n.agreed??0,o=(l=n.agree_on)!=null&&l.length?` on ${hz(n.agree_on)}`:"",i=(d=n.agree_on)!=null&&d.length?"":n.grader?"; compared by the fast model":"; compared the whole answer";return`Checked on ${n.n} ${n.n===1?"input":"inputs"} of the agent's own runs: ${s} answered alone (${Tf(s/n.n)}, ${Tf(n.alone_min)} needed), ${r} of those said what the agent said${o} (${s?Tf(r/s):"0%"}, ${Tf(n.agree_min)} needed${i})${(u=n.outcomes)!=null&&u.handed_back?`, ${n.outcomes.handed_back} handed back`:""}`}function pz(e){var L,A;const{corrections:n,runs:s,workflows:r,cost:o,promotions:i,serving:l,loop:d,execution:u="hosted",compileAfter:f=p_}=e,h=r.filter(P=>_h(P.status)),v=d==null?void 0:d.compiles.find(P=>P.digest===null&&(P.draft_errors.length>0||P.attempts.length>0)),b=d==null?void 0:d.compiles.find(P=>P.digest!==null),m=o==null?void 0:o.summary,x=x_(o),y=i.at(-1),j=y?l.find(P=>P.workflow===y.workflow):void 0,k=(j==null?void 0:j.digest)??null,C=j!=null&&j.replaying?`revision ${j.replaying.slice(0,7)} is checked on the inputs of its agent's own runs before it serves`:(y==null?void 0:y.decided)==="hold"&&y.digest!==k?`revision ${y.digest.slice(0,7)} was held: ${Za(y)}`:null,N=k!==null&&y?qv(o,y.workflow)===k:!1,S=N?`revision ${k.slice(0,7)} no longer runs first: it cost as much as the agent by hand; the agent takes its runs`:null,E=S?C?`${S}; ${C}`:S:k&&C?`revision ${k.slice(0,7)} serves; ${C}`:null,$=[];if($.push({key:"corrections",title:"Corrections",value:n===1?"1 correction":`${n} corrections`,detail:n?"yours, given whole to every later run":"none yet: grade a run with a correction, or write one here",state:n?"done":"now"}),u==="native"||u==="cli")return $.push({key:"compiled",title:"Learning",value:"Corrections",detail:u==="cli"?"Your CLI receives your corrections on later prompts. Workflow learning needs an approved tool connection and is unavailable here.":"Native runs are given your corrections; learned workflows are unavailable.",state:"later"}),$;if(h.length||b&&b.digest){const P=((L=h[0])==null?void 0:L.name)??(b==null?void 0:b.workflow)??"a workflow";$.push({key:"compiled",title:"Compiled",value:P,detail:b?`${b.attempts.length} ${b.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else v?$.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"}):$.push({key:"compiled",title:"Compile",value:"Not yet",detail:u==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${f} completed runs`:`${Math.min(s,f)} of ${f} completed runs: a workflow compiles at ${f}, then is checked once on those runs' inputs against the agent's own answers`,state:s?"now":"later"});if(u==="sdk")return $.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"}),$;if(m!=null&&m.takeover)$.push({key:"took_over",title:"Took over",value:`Run ${m.takeover.n}`,detail:E??((A=y==null?void 0:y.check)!=null&&A.n?Za(y):y?y.reason:"the first run a learned workflow served"),state:N||(y==null?void 0:y.decided)==="hold"&&!k?"warn":"done"});else if(y)if(E)$.push({key:"took_over",title:"Take over",value:$d(Bv(i,y.workflow,k)??y,{serving:k,stopped:N?k:null}).word,detail:E,state:N?"warn":"done"});else{const P=$d(y,{serving:k});$.push({key:"took_over",title:"Take over",value:P.word,detail:y.decided==="replaying"?"being checked on the inputs of the agent's own runs before it serves; the agent takes the runs meanwhile":Za(y),state:y.decided==="hold"?"warn":"now"})}else $.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow is checked once on the inputs of the agent's own runs, then serves first when it clears the check's bar",state:"later"});if(m!=null&&m.takeover&&m.withheld)$.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${b_(m.withheld)}: ${v_}`,state:"now"});else if(m!=null&&m.after&&m.before){const P=`${go(m.before.mean_usd)} a run by the agent, ${go(m.after.mean_usd)} all-in over the ${m.after.runs===1?"1 run":`${m.after.runs} runs`} it served since`,O=m.times_cheaper;O!==null&&O>1?$.push({key:"cheaper",title:"Cheaper",...gz(m,O),state:"done"}):O!==null?$.push({key:"cheaper",title:"Cheaper",value:O<1?m.before.mean_usd>0?`Not cheaper yet: ${Iv(m.after.mean_usd/m.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:P,state:"now"}):$.push({key:"cheaper",title:"Cheaper",value:`${m.after.runs} served ${m.after.runs===1?"run":"runs"} so far`,detail:`${P}; how many times cheaper shows after ${lz} runs`,state:"now"})}else m!=null&&m.takeover&&m.after_state==="cost_unknown"?$.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):m!=null&&m.after?$.push({key:"cheaper",title:"Cheaper",value:`${m.after.runs} served ${m.after.runs===1?"run":"runs"} so far`,detail:`${go(m.after.mean_usd)} all-in over the ${m.after.runs===1?"1 run":`${m.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):$.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"});return x&&$.push({key:"unsure",title:"Unsure",value:`${Math.round(x.back/x.ran*100)}% handed back`,detail:`of ${x.ran} runs it ran first`,state:x.back/x.ran>.25?"warn":"watch"}),$}function b_(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 v_="how many times cheaper shows once every run's cost is known";function gz(e,n){const s=Iv(n),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:`${s} cheaper`,detail:`Passed the agreement check: ${r.agreed} of ${r.alone} agreed (bar ${Math.round(r.agree_min*100)}%)${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its check was below the bar (${o})`:"no check yet"}`}}const xz=1e3,y_="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.",w_=e=>e==="cli"?"Costs include reported CLI usage and AgentRun learning. Compare similar tasks; owner corrections do not enable workflow takeover.":e==="native"?"Native run costs include reported model usage and AgentRun learning. Compare repeated jobs; corrections 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.":y_,j_=e=>`${e} served ${e===1?"run":"runs"}`;function H0({v2:e,agentId:n,on:s,quiet:r=!1,promotions:o,onCost:i,reads:l=0,execution:d="hosted"}){const[u,f]=g.useState(null),[h,v]=g.useState([]),b=o??h,m=g.useRef(i);m.current=i;const[x,y]=g.useState(null),[j,k]=g.useState(0);return g.useEffect(()=>{let C=!0;return y(null),Promise.resolve().then(()=>e.learningCost(n,xz)).then(N=>{var S;C&&(f(N),(S=m.current)==null||S.call(m,N))},N=>{C&&y(N??new Error("unknown"))}),o||Promise.resolve().then(()=>e.learningPromotions(n)).then(N=>{C&&v(N.promotions)},()=>{}),()=>{C=!1}},[e,n,j,l,!o]),r&&(!u||u.runs.filter(C=>C.total_usd!==null).length<2)?null:x&&!u?t.jsx(Or,{problem:Na(x,"the cost per run"),onRetry:()=>k(C=>C+1),className:""}):u?t.jsx(yz,{data:u,on:s,promotions:b,execution:d}):t.jsx(Un,{className:"h-[320px] w-full"})}const Wt={top:30,right:16,bottom:30,left:60},bz=520,Rf=17,vz=16,Ur=260;function yz({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var je,fe,De;const i=g.useMemo(()=>TD(e.runs),[e.runs]),l=g.useMemo(()=>i.filter(dz),[i]),d=RD(l.length),u=g.useMemo(()=>AD(l,d),[l,d]),f=g.useMemo(()=>cz(e.runs,r),[e.runs,r]),h=g.useMemo(()=>tu(e.runs),[e.runs]),{summary:v}=e,b=x_(e),m=g.useRef(null),[x,y]=g.useState(s??720);g.useEffect(()=>{const te=m.current;if(s||!te||typeof ResizeObserver>"u")return;const Ie=new ResizeObserver(([We])=>{We&&We.contentRect.width>0&&y(We.contentRect.width)});return Ie.observe(te),()=>Ie.disconnect()},[s]);const[j,k]=g.useState(null),[C,N]=g.useState(null),S=Xa.map(te=>({...te,runs:e.runs.filter(Ie=>Ie.path===te.path).length})),E=[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(te=>te.state==="needs_revision"&&te.served&&te.by_hand).map(te=>`${te.workflow} no longer runs first: ${go(te.served.mean_usd)} a run all-in over its newest ${te.served.runs} priced runs, at or over ${go(te.by_hand.mean_usd)} a run by hand.${te.unknown_cost_runs?` ${te.unknown_cost_runs===1?"1 run":`${te.unknown_cost_runs} runs`} of unknown cost left out.`:""} The agent takes its runs; a new version runs first again.`)].filter(te=>!!te);if(i.length<2)return t.jsxs(G0,{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:w_(o)}),E.map(te=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:te},te))]}),h.length>0&&(()=>{var rt;const te=Math.max(300,x),Ie=h[0].n,We=(te-Wt.left-Wt.right)/(h.at(-1).n-Ie+1);return t.jsx("figure",{ref:m,className:"px-4 pb-3",children:t.jsx(q0,{runs:e.runs,width:te,x:ot=>Wt.left+(ot-Ie+.5)*We,step:We,plot:[Wt.left,te-Wt.right],takeover:((rt=v.takeover)==null?void 0:rt.n)??null})})})()]});const $=Math.max(300,x),L=((je=h[0])==null?void 0:je.n)??1,A=((fe=h.at(-1))==null?void 0:fe.n)??L,P=v.before,O=v.takeover?Math.max(v.takeover.n,L):null,T=$<bz?[]:[...P?[{key:"before",words:`Before ${go(P.mean_usd)}`,usd:P.mean_usd}]:[],...O!==null&&v.after?[{key:"after",words:`After ${go(v.after.mean_usd)}`,usd:v.after.mean_usd}]:[]],M=$-Wt.left-(T.length?l_(T.map(te=>te.words)):Wt.right),F=M/(A-L+1),I=te=>Wt.left+(te-L+.5)*F,{top:V,ticks:G,above:q}=OD(i,u,(P==null?void 0:P.mean_usd)??null),H=[],U=[];for(const te of f){const Ie=I(te.n)-F/2;let We=U.findIndex(rt=>Ie-rt>=vz);We<0?(We=U.length,U.push(Ie)):U[We]=Ie,H.push(We)}const Q=U.length?U.length*Rf+8:0,D=Wt.top+Q,Y=te=>D+Ur-Math.min(te,V)/V*Ur,K=i_(L,A,$<520?5:7),Z=v.takeover&&v.takeover.n>=L?v.takeover:null,se=l.map((te,Ie)=>`${Ie?"L":"M"}${I(te.at).toFixed(1)},${Y(u[Ie]).toFixed(1)}`).join(""),ie=j===null?null:i[j],Ne=v.times_cheaper!==null?`${Iv(v.times_cheaper)} cheaper`:null,he=b?`${tm(b.back,b.ran)} handed back since`:null,ve=v.after?`${go(v.after.mean_usd)} all-in over ${j_(v.after.runs)} after`:v.takeover&&v.after_state==="cost_unknown"?"no served run's cost known yet":null,Ee=v.before&&ve?`${go(v.before.mean_usd)} a run before takeover, ${ve}${Ne?`: ${Ne}`:""}${he?` · ${he}`:""}`:null,ye=e.unknown_cost_runs+e.unknown_path_runs,pe=c_(T.map(te=>({...te,at:Y(te.usd)})),D+4,D+Ur),Pe=te=>{const Ie=te.currentTarget.getBoundingClientRect(),We=(te.clientX-Ie.left)/Ie.width*$,rt=(te.clientY-Ie.top)/Ie.height*(D+Ur+Wt.bottom);if(f.length&&rt<D-2){k(null);const ot=f.map((wt,jt)=>({i:jt,d:Math.abs(I(wt.n)-F/2-We)+Math.abs(Wt.top+H[jt]*Rf+8-rt)})).sort((wt,jt)=>wt.d-jt.d)[0];N(ot&&ot.d<=12?ot.i:null);return}N(null),k(LD(i,L+(We-Wt.left)/F-.5))},ue=te=>{const We={ArrowRight:rt=>rt+1,ArrowLeft:rt=>rt-1,Home:()=>0,End:()=>i.length-1,PageUp:rt=>rt+10,PageDown:rt=>rt-10}[te.key];if(!We){te.key==="Escape"&&k(null);return}te.preventDefault(),k(rt=>Math.min(i.length-1,Math.max(0,We(rt??(te.key==="ArrowLeft"?i.length:-1)))))},ge=te=>[te.n===null?"Replay run":`Run ${te.n}`,`${yn(te.total_usd)} all-in${te.learning_usd?` (${yn(te.cost_usd??0)} the run, ${yn(te.learning_usd)} learning)`:""}`,`${$f(te.path).label}${te.workflow?`: ${te.workflow}`:""}`,...te.digest?[`Workflow revision ${te.digest.slice(0,7)}`]:te.path==="agent"?["No learned workflow ran"]:[],...te.audited?["Audited: a shadow run of the agent checked it"]:[],...te.path==="replay"?["A replay: learning's spend, out of the line"]:[]],Te=C===null?null:f[C]??null,Xe=Z?I(Z.n)>Wt.left+M*.62:!1;return t.jsxs(G0,{title:"Cost per run",headline:Ee,unknown:ye,children:[t.jsxs("figure",{ref:m,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(te=>te.runs>0).map(te=>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:te.fill})}),te.label," ",t.jsx("span",{className:"text-foreground",children:te.runs})]},te.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"]}),P&&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(ud).filter(te=>f.some(Ie=>Ie.kind===te)).map(te=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${te}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(K0,{x:0,y:0,kind:te})}),ud[te]," ",t.jsx("span",{className:"text-foreground",children:f.filter(Ie=>Ie.kind===te).length})]},te))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:ue,onBlur:()=>k(null),"aria-label":`Cost per run, runs ${L} to ${A}. ${Ee??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:$,height:D+Ur+Wt.bottom,className:"block select-none font-mono",onPointerMove:Pe,onPointerLeave:()=>{k(null),N(null)},"aria-hidden":!0,children:[G.map(te=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Wt.left},${Y(te)}H${Wt.left+M}`,className:te===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Wt.left-8,y:Y(te),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:yn(te)})]},te)),K.map(te=>t.jsx("text",{x:I(te),y:D+Ur+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:te},te)),t.jsx("text",{x:Wt.left,y:Q?Wt.top-10:D-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Wt.left-8,y:D+Ur+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((te,Ie)=>t.jsxs("g",{"data-testid":`marker-${te.kind}`,opacity:C===null||C===Ie?1:.55,children:[t.jsx("path",{d:`M${I(te.n)-F/2},${Wt.top+H[Ie]*Rf+15}V${D+Ur}`,className:k_[te.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(K0,{x:I(te.n)-F/2-7,y:Wt.top+H[Ie]*Rf+1,kind:te.kind})]},`${te.kind}:${te.n}:${te.workflow}:${te.digest}:${te.at}`)),i.map((te,Ie)=>te.path==="replay"?t.jsx("circle",{cx:I(te.at),cy:Y(te.total_usd),r:Ie===j?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},te.run_id):t.jsx("circle",{cx:I(te.at),cy:Y(te.total_usd),r:Ie===j?0:3,className:ee($f(te.path).fill),fillOpacity:.65},te.run_id)),P&&t.jsx("path",{d:`M${Wt.left},${Y(P.mean_usd)}H${Wt.left+M}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),Z&&t.jsxs("g",{"data-testid":"takeover",children:[t.jsx("path",{d:`M${I(Z.n)-F/2},${D-4}V${D+Ur}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(Sz,{x:I(Z.n)-F/2+(Xe?-6:6),y:D+6,anchor:Xe?"end":"start",children:["Workflow took over, run ",Z.n]})]}),O!==null&&v.after&&t.jsx("path",{d:`M${I(O)-F/2},${Y(v.after.mean_usd)}H${Wt.left+M}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsx("path",{d:se,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),pe.map(te=>t.jsx("text",{"data-testid":"level-label",x:Wt.left+M+6,y:te.at,dy:"0.32em",className:ee("text-label",te.key==="after"?"fill-foreground font-semibold":"fill-muted-foreground"),children:te.words},te.key)),ie&&t.jsxs("g",{children:[t.jsx("path",{d:`M${I(ie.at)},${D}V${D+Ur}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:I(ie.at),cy:Y(ie.total_usd),r:5,className:ee($f(ie.path).fill,"stroke-card"),strokeWidth:2})]})]}),Te&&!ie&&t.jsx("div",{className:ee("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",I(Te.n)>$*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:I(Te.n)>$*.6?I(Te.n)-F/2-12:I(Te.n)-F/2+12,top:Wt.top},children:V0(Te).map((te,Ie)=>t.jsx("span",{className:ee("block",Ie===0?"font-semibold":"text-muted-foreground"),children:te},Ie))}),ie&&t.jsxs("div",{className:ee("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",I(ie.at)>$*.6&&"-translate-x-full"),style:{left:I(ie.at)>$*.6?I(ie.at)-10:I(ie.at)+10,top:D},children:[ge(ie).map((te,Ie)=>t.jsx("span",{className:ee("block",Ie===0?"font-semibold":"text-muted-foreground"),children:te},te)),t.jsx("span",{className:"block text-muted-foreground",children:ht(ie.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:ie?ge(ie).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(te=>V0(te).join(", ")).join(". ")}.`})]}),t.jsx(q0,{runs:e.runs,width:$,x:I,step:F,plot:[Wt.left,Wt.left+M],takeover:((De=v.takeover)==null?void 0:De.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 (its compile turn and its audit's shadow run). The line is the mean of the last ",d," runs",i.some(te=>te.path==="replay")?", replay runs (hollow) left out":"",".",q?` ${q===1?"1 run costs":`${q} runs cost`} more than ${yn(V)} and ${q===1?"is":"are"} drawn at the top.`:"",v.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.":""]}),[...E,...kz(e,n,o)].map(te=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:te},te))]}),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(te=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:te},te))})}),t.jsx("tbody",{children:e.runs.map(te=>{var Ie;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:te.n??"-"}),t.jsx("td",{className:"pr-4",children:ht(te.started_at)}),t.jsxs("td",{className:"pr-4",children:[$f(te.path).label,te.workflow?`: ${te.workflow}`:""]}),t.jsxs("td",{className:"pr-4",children:[((Ie=te.digest)==null?void 0:Ie.slice(0,7))??"-",te.audited&&t.jsx("span",{"data-testid":"audited",className:"ml-2",children:t.jsx(ke,{tone:"muted",title:"An audit's shadow run of the agent checked this run; its cost is in Learning $.",children:"audited"})})]}),t.jsx("td",{className:"pr-4",children:te.cost_usd===null?"unknown":yn(te.cost_usd)}),t.jsx("td",{className:"pr-4",children:te.learning_usd===null?"unknown":yn(te.learning_usd)}),t.jsx("td",{className:"pr-4",children:te.total_usd===null?"unknown":yn(te.total_usd)})]},te.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(te=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:te},te))})}),t.jsx("tbody",{children:f.map(te=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:te.n}),t.jsxs("td",{className:"pr-4",children:[Hv[te.kind]," ",ud[te.kind]]}),t.jsx("td",{className:"pr-4",children:te.workflow}),t.jsx("td",{className:"pr-4",children:te.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Za(te.record)})]},`${te.kind}:${te.n}:${te.workflow}:${te.digest}:${te.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 wz=64,sa={top:4,bottom:6},jz=[...Xa].reverse(),B0=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function q0({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const l=wz,d=MD(tu(e).length),u=g.useMemo(()=>ID(e,d),[e,d]),[f,h]=g.useState(null);if(!u.length)return null;const[v,b]=o,m=A=>Math.min(b,Math.max(v,A)),x=A=>({from:m(s(A.from)-r/2),to:m(s(A.to)+r/2)}),y=A=>sa.top+l*(1-A),j=u.at(-1),k=A=>{const{from:P,to:O}=x(A),T=O-P>4?1:0;return{x0:P+T,w:Math.max(1,O-P-2*T)}},C=A=>`${B0(A)}: ${Xa.filter(P=>A.counts[P.path]).map(P=>`${P.label.toLowerCase()} ${A.counts[P.path]}`).join(", ")}`,N=u.some(A=>A.counts.workflow)?`${tm(j.counts.workflow,j.runs)} by the learned workflow`:Xa.filter(A=>j.counts[A.path]).map(A=>`${tm(j.counts[A.path],j.runs)} ${A.label.toLowerCase()}`).join(", "),S=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${N}`,E=f===null?null:u[f],$=E?k(E).x0>n/2:!1,L=i!==null&&s(i)>=v&&s(i)<=b;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:v},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:S})]}),t.jsxs("svg",{width:n,height:sa.top+l+sa.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>h(null),children:[[0,.5,1].map(A=>t.jsxs("text",{x:v-6,y:y(A),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[A*100,"%"]},A)),u.map((A,P)=>{const{x0:O,w:T}=k(A);let M=sa.top+l;return t.jsxs("g",{onPointerEnter:()=>h(P),opacity:f===null||f===P?1:.55,children:[t.jsx("rect",{x:x(A).from,y:sa.top,width:Math.max(1,x(A).to-x(A).from),height:l,className:"fill-card",fillOpacity:0}),jz.map(F=>{const I=A.counts[F.path]/A.runs*l;if(!I)return null;M-=I;const V=M>sa.top+.5?Math.min(2,I):0;return t.jsx("rect",{x:O,y:M+V,width:T,height:I-V,className:F.fill,fillOpacity:.8},F.path)})]},A.from)}),L&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${sa.top}V${sa.top+l}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),E&&t.jsxs("div",{className:ee("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(E).x0-6:k(E).x0+k(E).w+6,top:40},children:[t.jsx("span",{className:"block font-semibold",children:B0(E)}),Xa.filter(A=>E.counts[A.path]).map(A=>t.jsxs("span",{className:"block text-muted-foreground",children:[A.label," ",E.counts[A.path]," (",tm(E.counts[A.path],E.runs),")"]},A.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(C).join(". ")}. ${S}.`})]})}function kz(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[w_(s)]:r.takeover?r.withheld?[`${b_(r.withheld)}: ${v_}.`]: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?[`${j_(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.":y_]}function G0({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 k_={promote:"stroke-chart-workflow",hold:"stroke-warning",revision:"stroke-muted-foreground"},Nz={promote:"fill-foreground",hold:"fill-warning-text",revision:"fill-muted-foreground"};function K0({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:ee("fill-card",k_[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:ee("text-micro font-semibold",Nz[s]),children:Hv[s]})]})}const V0=e=>[`${ud[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Za(e.record),ht(e.at)];function Sz({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:ee("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}const Zg=e=>`${e} ${e===1?"run":"runs"}`;function Cz(e,n){const s=e.points.at(-1),r=e.withheld?` · ${Zg(e.withheld)} of unknown cost on neither line`:"";if(!s)return{headline:`No run with a known cost yet${r}`,marker:null};if(!n)return{headline:`No learned workflow serves yet: the bill is the agent's own, ${yn(e.booked_usd)} over ${Zg(e.points.length)}${r}`,marker:null};if(e.break_even){const i=s.agent_usd===null?"":`, ${yn(s.agent_usd)} had the agent done all of it`;return{headline:`Break-even at run ${e.break_even.n}: ${yn(e.booked_usd)} booked over ${Zg(e.points.length)}${i}${r}`,marker:e.break_even.n}}return{headline:`Not yet${e.gap_usd===null?"":`: ${yn(e.gap_usd)} over the agent for all of it at run ${s.n}`}${r}`,marker:null}}function _z(e,n,s=[]){return e.map(r=>{const o=typeof n=="string"?null:n.filter(d=>d.workflow===r.workflow),i=o===null?null:o.filter(d=>d.agreed!==null),l=new Set(o==null?void 0:o.filter(d=>d.source==="shadow").map(d=>d.run));return{workflow:r.workflow,recent:r.audit?{rows:r.audit.rows,agreed:r.audit.rows-r.audit.disagreed,window:r.audit.window,disagree:r.audit.disagree}:null,all:i===null?null:{rows:i.length,agreed:i.filter(d=>d.agreed).length},off:r.audits_off,pending:o===null?null:s.filter(d=>d.audited&&d.workflow===r.workflow&&!l.has(d.run_id)).length}})}const $z=e=>e.points.length?e.learning_usd/e.points.length:null,Ez=e=>e==="fast"?"fast":e==="agent"?"agent model":"-",Tz=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Jx(e){return Tz(e)?e.predicate==="not"?`not ${Jx(e.of)}`:(e.predicate==="and"||e.predicate==="or")&&Array.isArray(e.of)?e.of.map(Jx).join(` ${e.predicate} `):e.predicate==="field_equals"&&typeof e.path=="string"?`${e.path} = ${JSON.stringify(e.value)}`:[e.predicate,e.path].filter(n=>typeof n=="string").join(" ")||"?":"?"}const Rz=e=>`${e.on} ${Jx(e.predicate)}`,Y0=e=>`${Math.round(e*100)}%`;function Az(e){return e!=null&&e.n?`Checked on ${e.n} ${e.n===1?"input":"inputs"}: ${e.alone??0} answered alone (bar ${Y0(e.alone_min)}), ${e.agreed??0} of them agreed (bar ${Y0(e.agree_min)}) · inputs from the newest ${e.compile_after} runs · ${e.attempt===1?"first check":"the recompile's check"}`:"Promoted with no check behind it"}function Q0({v2:e,agentId:n,cost:s,serving:r,width:o}){const i=s==null?void 0:s.bill,l=!!(i!=null&&i.points.length),[d,u]=g.useState("loading"),f=r.find(h=>h.digest!==null&&h.champion)??null;return g.useEffect(()=>{if(!l)return;let h=!0;return Promise.resolve().then(()=>e.learningAudits(n)).then(v=>{h&&u(v.audits)},()=>{h&&u("failed")}),()=>{h=!1}},[e,n,l,s]),!i||!l?null:t.jsxs(t.Fragment,{children:[t.jsx(Oz,{bill:i,takeover:s.summary.takeover,width:o}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[t.jsx(Lz,{serving:r,audits:d,bill:i,runs:s.runs}),(f==null?void 0:f.champion)&&t.jsx(Mz,{workflow:f.workflow,champion:f.champion})]})]})}const fn={top:16,right:16,bottom:30,left:60},ra=220;function Oz({bill:e,takeover:n,width:s}){var V,G;const r=g.useRef(null),[o,i]=g.useState(s??720);g.useEffect(()=>{const q=r.current;if(s||!q||typeof ResizeObserver>"u")return;const H=new ResizeObserver(([U])=>{U&&U.contentRect.width>0&&i(U.contentRect.width)});return H.observe(q),()=>H.disconnect()},[s]);const[l,d]=g.useState(null),u=e.points,{headline:f,marker:h}=Cz(e,n),v=u.some(q=>q.agent_usd!==null),b=Math.max(300,o),m=b<520,{top:x,ticks:y}=g.useMemo(()=>Vx(u.reduce((q,H)=>Math.max(q,H.actual_usd,H.agent_usd??0),-1/0)),[u]),j=q=>fn.top+ra-q/x*ra,k=u.at(-1),C=k&&!m?c_([{key:"bill",words:`Bill ${yn(k.actual_usd)}`,at:j(k.actual_usd)},...k.agent_usd!==null?[{key:"agent",words:`Agent ${yn(k.agent_usd)}`,at:j(k.agent_usd)}]:[]],fn.top+4,fn.top+ra):[],N=b-fn.left-(C.length?l_(C.map(q=>q.words)):fn.right),S=((V=u[0])==null?void 0:V.n)??1,E=((G=u.at(-1))==null?void 0:G.n)??1,$=q=>fn.left+(E===S?N/2:(q-S)/(E-S)*N),L=q=>q.map(([H,U],Q)=>`${Q?"L":"M"}${$(H).toFixed(1)},${j(U).toFixed(1)}`).join(""),A=L(u.map(q=>[q.n,q.actual_usd])),P=v?L(u.filter(q=>q.agent_usd!==null).map(q=>[q.n,q.agent_usd])):null,O=l===null?null:u[l]??null,T=e.unattributed_usd??0,M=q=>{const H=q.currentTarget.getBoundingClientRect(),U=(q.clientX-H.left)/H.width*b;let Q=0;u.forEach((D,Y)=>{Math.abs($(D.n)-U)<Math.abs($(u[Q].n)-U)&&(Q=Y)}),d(u.length?Q:null)},F=q=>{const U={ArrowRight:Q=>Q+1,ArrowLeft:Q=>Q-1,Home:()=>0,End:()=>u.length-1}[q.key];if(!U){q.key==="Escape"&&d(null);return}q.preventDefault(),d(Q=>Math.min(u.length-1,Math.max(0,U(Q??(q.key==="ArrowLeft"?u.length:-1)))))},I=q=>[`Run ${q.n}`,`Your bill ${yn(q.actual_usd)}`,...q.agent_usd===null?[]:[`The agent for all of it ${yn(q.agent_usd)}`]];return t.jsxs(Gv,{title:"The bill",headline:f,testid:"learning-bill",children:[t.jsxs("figure",{ref:r,className:"px-4 pb-2 pt-3",children:[v&&t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground","data-testid":"bill-legend",children:[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-chart-workflow",strokeWidth:2})}),"Your bill, booked"]}),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-chart-agent",strokeWidth:2,strokeDasharray:"5 3"})}),"The agent for all of it"]})]}),t.jsxs("div",{className:"relative",tabIndex:0,onKeyDown:F,onBlur:()=>d(null),"aria-label":`The bill, runs ${S} to ${E}. ${f}. Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:b,height:fn.top+ra+fn.bottom,className:"block select-none font-mono",onPointerMove:M,onPointerLeave:()=>d(null),"aria-hidden":!0,children:[t.jsx("g",{"data-testid":"bill-y-axis",children:y.map(q=>t.jsxs("g",{children:[t.jsx("path",{d:`M${fn.left},${j(q)}H${fn.left+N}`,className:q===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:fn.left-8,y:j(q),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:yn(q)})]},q))}),i_(S,E,m?5:7).map(q=>t.jsx("text",{x:$(q),y:fn.top+ra+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:q},q)),t.jsx("text",{x:fn.left-8,y:fn.top+ra+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),h!==null&&t.jsxs("g",{"data-testid":"bill-break-even",children:[t.jsx("path",{d:`M${$(h)},${fn.top}V${fn.top+ra}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(Iz,{x:$(h)+($(h)>fn.left+N*.7?-6:6),y:fn.top+10,anchor:$(h)>fn.left+N*.7?"end":"start",strong:!0,children:["Break-even, run ",h]})]}),P&&t.jsx("path",{d:P,"data-testid":"bill-agent",fill:"none",className:"stroke-chart-agent",strokeWidth:2,strokeDasharray:"5 3",strokeLinejoin:"round"}),t.jsx("path",{d:A,"data-testid":"bill-actual",fill:"none",className:"stroke-chart-workflow",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),k&&C.map(q=>t.jsx("text",{"data-testid":"bill-end-label",x:$(k.n)+6,y:q.at,dy:"0.32em",className:ee("text-label",q.key==="bill"?"fill-foreground font-semibold":"fill-muted-foreground"),children:q.words},q.key)),O&&t.jsxs("g",{children:[t.jsx("path",{d:`M${$(O.n)},${fn.top}V${fn.top+ra}`,className:"stroke-border-strong",strokeWidth:1}),O.agent_usd!==null&&t.jsx("circle",{cx:$(O.n),cy:j(O.agent_usd),r:4,className:"fill-chart-agent stroke-card",strokeWidth:2}),t.jsx("circle",{cx:$(O.n),cy:j(O.actual_usd),r:4,className:"fill-chart-workflow stroke-card",strokeWidth:2})]})]}),O&&t.jsx("div",{className:ee("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",$(O.n)>b*.6&&"-translate-x-full"),style:{left:$(O.n)>b*.6?$(O.n)-10:$(O.n)+10,top:fn.top},children:I(O).map((q,H)=>t.jsx("span",{className:ee("block",H===0?"font-semibold":"text-muted-foreground"),children:q},q))}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:O?I(O).join(", "):""})]}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each point adds a run that did a job, all in: its own cost, its compile turn and its audit's shadow run, with each replay run on the run before it.",v?" The dashed line is the mean of the agent's own runs before its first served run, times the runs.":"",T>0?` ${yn(T)} of learning spend is on no run yet: a revision's compile and check its next served runs carry, or one that stopped or never drafted.`:""]})]}),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","Run id","Your bill $","The agent for all of it $"].map(q=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:q},q))})}),t.jsx("tbody",{children:u.map(q=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:q.n}),t.jsx("td",{className:"pr-4",children:q.run_id}),t.jsx("td",{className:"pr-4",children:yn(q.actual_usd)}),t.jsx("td",{className:"pr-4",children:q.agent_usd===null?"-":yn(q.agent_usd)})]},q.run_id))})]})})]})]})}function Lz({serving:e,audits:n,bill:s,runs:r=[]}){var d;const o=_z(e,n,r),i=s.holds;if(!o.length&&!i.length)return null;const l=(d=s.points.at(-1))==null?void 0:d.n;return t.jsxs(Gv,{title:"Audits",headline:null,testid:"learning-audits",children:[t.jsx("ul",{className:"space-y-2 px-4 py-3 text-body",children:o.map(u=>t.jsxs("li",{className:"space-y-0.5",children:[t.jsx("span",{className:"block font-mono font-semibold",children:u.workflow}),u.recent&&t.jsxs("span",{className:"block",children:["Last ",u.recent.rows," ",u.recent.rows===1?"audit":"audits",": ",u.recent.agreed," agreed ",t.jsxs("span",{className:"text-muted-foreground",children:["· hold at ",u.recent.disagree," disagreeing of the newest ",u.recent.window]})]}),u.all&&t.jsxs("span",{className:"block",children:["All time: ",u.all.agreed," of ",u.all.rows," agreed",u.pending?t.jsxs("span",{className:"text-muted-foreground",title:"Its shadow run is charged to the run; the audit is scored at a later run's start.",children:[" · ",u.pending," not scored yet"]}):null]}),u.off&&t.jsx("span",{className:"block text-muted-foreground",children:u.off})]},u.workflow))}),n==="failed"&&t.jsx("p",{className:"border-t px-4 py-2 text-small text-warning-text",role:"status",children:"The audits couldn't be read, so there is no all-time figure. Reload to try again."}),i.length>0&&t.jsx("ul",{className:"space-y-0.5 border-t px-4 py-3 font-mono text-small","data-testid":"audit-holds",children:i.map(u=>t.jsxs("li",{children:[u.n!==null?`Held at run ${u.n}`:`Held after run ${l??0}`," ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",u.workflow," · ",u.by==="audit"?"by its audits":u.by==="check"?"by its check":"refused by this release's DSL"," · ",ht(u.at)]})]},`${u.workflow}:${u.at}`))})]})}function Mz({workflow:e,champion:n}){const s=n.nodes;return t.jsxs(Gv,{title:"Serving workflow",headline:e,testid:"serving-workflow",children:[s!=null&&s.length?t.jsx("div",{className:"overflow-auto px-4 py-2",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Node","Kind","Tier","Code checks"].map(r=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:r},r))})}),t.jsx("tbody",{children:s.map(r=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:r.label}),t.jsx("td",{className:"pr-4 text-muted-foreground",children:r.kind}),t.jsx("td",{className:"whitespace-nowrap pr-4",children:Ez(r.tier)}),t.jsx("td",{className:"pr-4",children:r.checks.map(Rz).join("; ")||"-"})]},r.path))})]})}):t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:s===null?"Its workflow.json couldn't be read.":"Its workflow.json has no nodes."}),t.jsx("p",{className:"border-t px-4 py-2 text-small text-muted-foreground",children:Az(n.check)})]})}function Gv({title:e,headline:n,testid:s,children:r}){return t.jsxs("section",{className:"min-w-0 border bg-card","aria-label":e,"data-testid":s,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})]}),r]})}function Iz({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:ee("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}const Nm="https://api.githubcopilot.com/mcp/",nu={composio:"Composio",github:"GitHub",url:"URL"},J0=/^[a-z][a-z0-9-]{0,31}$/,Pz=/^[a-z0-9][a-z0-9_-]{0,63}$/,Kv=[{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:Nm,readOnly:`${Nm}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."},{id:"fal",label:"fal (key)",name:"fal",url:"https://mcp.fal.ai/mcp",auth:"bearer",note:"Image, video and audio models. Your fal key, from fal.ai's API keys page: generations bill your fal account, and a run counts each one at fal's price, under its spend cap. This server keeps the key; the agent never sees it."},{id:"fal-sign-in",label:"fal (sign in)",name:"fal",url:"https://mcp.fal.ai/mcp-relay",auth:"oauth",note:"Image, video and audio models. Sign in with your fal account: generations bill it, and a run counts each one at fal's price, under its spend cap. This server keeps the tokens."}],N_=e=>Kv.find(n=>n.id===e),Dz=["none","bearer","headers","oauth","github_app"],zz=e=>{try{const n=new URL(e??"");return(n.protocol==="https:"||n.protocol==="http:")&&!n.username&&!n.password?e:void 0}catch{return}};function Fz(e){const n=new URLSearchParams(e??""),s=n.get("add"),r=s??n.get("change");if(!r||!J0.test(r))return;const o=n.get("toolkit")??"",i=n.get("preset")??void 0;if(i==="composio"&&Pz.test(o)){const h=(n.get("tools")??"").split(",").filter(v=>/^[A-Za-z0-9_-]{1,128}$/.test(v)).slice(0,64);return{name:r,preset:"composio",toolkit:o,...h.length?{tools:h}:{},...s===null?{change:!0}:{}}}const l=N_(i);if(s!==null&&l)return{name:r,preset:l.id};const d=Dz.find(h=>h===n.get("auth")),u=zz(n.get("url")),f={...d?{auth:d}:{},...u?{url:u}:{},...J0.test(o)?{toolkit:o}:{}};return s===null?{name:r,change:!0,...f}:{name:r,...f}}const Uz="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.",S_=(e,n)=>`mcp:${e}/${n}`;function _o(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function Wz(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 C_(e,n){return e.flatMap(s=>{const r=_o(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 X0=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 $o(e){var i,l,d,u,f,h,v,b;if(!(e instanceof Ue))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(m=>m.field==="url"&&m.reason==="redirect"),s=(l=e.fields)==null?void 0:l.find(m=>m.field==="client_id"&&m.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:X0(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:X0(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((h=e.details)==null?void 0:h.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(v=e.fields)!=null&&v.length?{text:e.fields.map(m=>m.message).join(" "),...typeof((b=e.details)==null?void 0:b.composio)=="string"?{detail:e.details.composio}:{}}:{text:`${e.code}: ${e.message}`}}const Z0={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"},Hz="the sign-in didn't finish: try again",Bz=e=>e&&Object.hasOwn(Z0,e)?Z0[e]:Hz;function qz(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 su=_o;function Gz(e){const n=_o(e);return n?`${n.server} · ${n.tool}`:null}function Al(e,n){return Sd(e)?{text:`${e.slice(Px.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 __(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 Kz(e,n,s,r){return!e||typeof r!="number"||Sd(e)?null:__(n,s).has(e)?`free model: up to ${r} requests`:null}function Vz(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function Yz(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function Vv(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 Qz="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",Jz="none yet: add a model key in Settings → Model keys",$_=e=>Al(e,null).text,Yv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?$_(n.model):void 0].filter(Boolean).join(" · "),E_=e=>e!=null&&e.model?`ran on ${$_(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",Xz="http://www.w3.org/2000/svg",Ji=16,vn=240,Zz=40,eF=58,ex=16,tx=26,Af=18,Xi=14,eN=16,tF=26,nF=14,sF=22,nr=14,tN=16,Of=16,rF=4,oF=10,aF=18,iF=30,lF=5,sd=124,Xx=34,cF=4,nx=10*.6,dF=12.5*.6,Ed=10.5*.6,nN=11*.6,Qv=9*.66,sN=10.5*.6,uF={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"},Jv=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Sm={review:"needs review","not-run":"",pending:""};function _t(e,n,...s){const r=document.createElementNS(Xz,e);if(n)for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));for(const o of s)Ds(r,o);return r}function Ds(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)Ds(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Qr=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,fF=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Qr(e,n):`${Qr(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},da=(e,n)=>Math.max(2,Math.floor(e/n)),ba=(e,n)=>Math.ceil(e.length*n),ir=(e,n,s,r,o)=>_t("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function T_(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 l={node:o,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(o.path))&&r(i[1])==="chain"?(d=i[1],l.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(o.path))&&r(i[1])==="route"?(d=i[1],l.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(o.path))&&r(i[1])==="parallel"?(d=i[1],l.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(l)}for(const o of Object.values(s))o.sort((i,l)=>i.order-l.order);return{byPath:n,kids:s}}function Xv(e,n){var u,f,h,v;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],l=i&&Jv.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(h=s.moved)!=null&&h.includes(n)?"MOVED":"";return{state:l,tag:d,fired:n===o,selected:((v=e.marks.selected)==null?void 0:v.path)===n&&e.marks.selected.item==null}}function ru(e,n,s){var b,m,x;const r=Xv(e,n.path),o=(b=e.marks.meta)==null?void 0:b[n.path],i=o!=null&&o.tool?su(o.tool):null,l=(m=e.marks.ran)==null?void 0:m[n.path],d=o!=null&&o.decision?(l==null?void 0:l.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}`:""}`:""}${l&&!(o!=null&&o.decision)?`, ${E_(l)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(x=o==null?void 0:o.questions)!=null&&x.length&&(u+=`
|
|
668
|
-
${o.questions.map(y=>`• ${y.text}`).join(`
|
|
669
|
-
`)}`);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-${uF[n.kind]??"code"}`;let h=`node ${s} ${f}`;r.state&&(h+=` ${r.state}`),r.fired&&(h+=" fired"),r.tag&&(h+=` ${r.tag.toLowerCase()}`),r.selected&&(h+=" selected");const v=_t("g",{class:h,"data-path":n.path},_t("title",null,u));return e.svg.appendChild(v),v}const xl=e=>ba(e,Qv)+10;function nm(e,n,s,r,o="tag"){const i=xl(r);return Ds(e,[_t("rect",{x:n,y:s,width:i,height:13,class:`${o}-box`}),_t("text",{x:n+i/2,y:s+9.5,class:o,"text-anchor":"middle"},r)]),i}const mF=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Eh=(e,n)=>mF(e,n)?eF:Zz;function Zv(e,n,s,r,o){var k,C,N,S,E;const i=Xv(e,s.path),l=(k=e.marks.meta)==null?void 0:k[s.path],d=Eh(e,s),u=(C=e.marks.verdict)==null?void 0:C[s.path],f=i.state in Sm?Sm[i.state]:i.state,h=((N=l==null?void 0:l.questions)==null?void 0:N.length)??0,v=l!=null&&l.tool?su(l.tool):null,b=(S=e.marks.ran)==null?void 0:S[s.path],m=(b&&!(l!=null&&l.decision)?Yv(s.kind,b):s.kind)+(v?` · ${v.tool} on ${v.server}`:l!=null&&l.tool?` · ${l.tool}`:s.via?` · ${s.via}`:"")+(l!=null&&l.decision&&h?` · ${h} ${h===1?"question":"questions"}`:""),x=[(E=l==null?void 0:l.images)!=null&&E.length?"IMG":"",l!=null&&l.web?"WEB":"",v?"MCP":""].filter(Boolean),y=x.reduce(($,L)=>$+xl(L)+4,0);i.selected&&n.appendChild(_t("rect",{x:r-4,y:o-4,width:vn+8,height:d+8,class:"sel"})),Ds(n,[_t("rect",{x:r,y:o,width:vn,height:d,class:"box"}),_t("rect",{x:r+10,y:o+9,width:8,height:8,class:"swatch"}),_t("text",{x:r+24,y:o+17,class:"label"},Qr(s.label,da(vn-34-y,dF))),_t("text",{x:r+24,y:o+31,class:"kind"},Qr(m,da(vn-34-(f?ba(f,Qv)+8:0),Ed))),f?_t("text",{x:r+vn-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+vn-8;for(const $ of x.reverse())j-=xl($),nm(n,j,o+7,$,"badge"),j-=4;if(l!=null&&l.decision&&l.provider){const $=nm(n,r+24,o+38,l.provider,"chip"),L=u?fF(u,da(vn-44-$-20,sN)):"",A=vn-40-$-(L?ba(L,sN)+10:0),P=(b==null?void 0:b.model)??l.model;P&&A>24&&n.appendChild(_t("text",{x:r+24+$+6,y:o+47.5,class:"model"},Qr(P,da(A,Ed)))),L&&n.appendChild(_t("text",{x:r+vn-10,y:o+47.5,class:"verdict","text-anchor":"end"},L))}else u&&n.appendChild(_t("text",{x:r+vn-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&nm(n,r+vn-xl(i.tag),o-7,i.tag)}function hF(e,n){return{w:vn,h:Eh(e,n),cx:vn/2,place:(s,r)=>Zv(e,ru(e,n,"card"),n,s,r)}}function R_(e,n,s){const r=Xv(e,n.path),o=r.state==="done"?"passed":r.state in Sm?Sm[r.state]:r.state,i=Qr(n.label===n.kind?"exit":`exit: ${n.label}`,40),l=ba(i,Ed)+16;return{w:Xi+l+(r.tag?6+xl(r.tag):0)+(o?6+ba(o,Qv):0),h:tx,cx:0,exit:!0,place:(d,u)=>{const f=ru(e,n,"exit"),h=u+tx/2;let v=d+Xi+l;s&&f.appendChild(ir(d,u,d,u+tx,"spine")),r.selected&&f.appendChild(_t("rect",{x:d+Xi-3,y:h-Af/2-3,width:l+6,height:Af+6,class:"sel"})),Ds(f,[ir(d,h,d+Xi,h,"exit-wire"),_t("rect",{x:d+Xi,y:h-Af/2,width:l,height:Af,class:"exit-box"}),_t("text",{x:d+Xi+8,y:h+3.5,class:"exit-text"},i)]),r.tag&&(nm(f,v+6,h-6.5,r.tag),v+=6+xl(r.tag)),o&&f.appendChild(_t("text",{x:v+6,y:h+3.5,class:"state"},o))}}}function pF(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?R_(e,d.node,!1):Th(e,d.node));let o=vn/2,i=vn/2,l=-ex;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),l+=d.h+ex;return{w:o+i,h:l,cx:o,place:(d,u)=>{const f=ru(e,n,"chain"),h=d+o;let v=u,b=null;r.forEach((m,x)=>{x&&(v+=ex),m.exit?b===null&&(b=v):b!==null&&f.appendChild(ir(h,b,h,v,"spine")),m.place(m.exit?h:h-m.cx,v),v+=m.h,m.exit||(b=v)}),r[r.length-1].exit&&b!==null&&f.appendChild(ir(h,b,h,v,"spine"))}}}function gF(e,n,s){const r=Eh(e,n),o=s.map(m=>({kid:m,box:Th(e,m.node),x:0,c:0}));let i=0,l=0;o.forEach((m,x)=>{x&&(i+=sF),m.x=i,m.c=i+m.box.cx,i+=m.box.w,l=Math.max(l,m.box.h)});const d=o.length-1,u=Math.round((o[0].c+o[d].c)/2),f=Math.min(0,u-vn/2),h=Math.max(i,u+vn/2),v=r+eN+tF,b=v+l+nF;return{w:h-f,h:b,cx:u-f,place:(m,x)=>{const y=ru(e,n,"card"),j=m-f,k=x+r+eN,C=x+b;Zv(e,y,n,j+u-vn/2,x),y.appendChild(ir(j+u,x+r,j+u,k)),d&&Ds(y,[ir(j+o[0].c,k,j+o[d].c,k),ir(j+o[0].c,C,j+o[d].c,C)]),o.forEach((N,S)=>{const E=j+N.c,$=N.kid.node.path,L=e.taken.has($);if(y.appendChild(_t("line",{x1:E,y1:k,x2:E,y2:x+v,class:L?"wire branch taken":"wire branch","data-to":$})),N.kid.name!==null){const A=(S<d?o[S+1].c-6:N.x+N.box.w)-N.c-12,P=Qr(N.kid.name,da(A,Ed)),O=_t("text",{x:E+6,y:k+15,class:L?"branch-name taken":"branch-name"},P);y.appendChild(P===N.kid.name?O:_t("g",null,_t("title",null,N.kid.name),O))}y.appendChild(ir(E,x+v+N.box.h,E,C,L?"taken":void 0)),N.box.place(j+N.x,x+v)})}}}const rN=/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,xF=e=>/\s/.test(e)&&!rN.test(e)?e:e.replace(/^.*\//,"").replace(rN,"")||e;function bF(e,n,s,r,o,i){const l=Jv.has(s.status)?s.status:"pending",d=s.label?xF(s.label):`#${s.index+1}`,u=s.outcome??(l==="review"?"needs review":l==="not-run"?"not run":l),f=s.p!==void 0?s.p.toFixed(2):"",h=`#${s.index+1}${s.label?` ${s.label}`:""}: ${l==="review"?"needs review":l.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,v=_t("g",{class:`rcell ${l}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},_t("title",null,h),_t("rect",{x:r,y:o,width:sd,height:Xx,class:"cell"}),_t("rect",{x:r,y:o,width:3,height:Xx,class:"cell-edge"}),_t("text",{x:r+9,y:o+14,class:"cell-name"},Qr(d,da(sd-14,nx))),_t("text",{x:r+9,y:o+27,class:"cell-out"},Qr(u,da(sd-18-(f?ba(f,nx)+6:0),nx))),f?_t("text",{x:r+sd-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(v)}function vF(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<=iF,[o,i,l]=r?[sd,Xx,cF]:[Of,Of,rF],d=Math.min(s.length,r?lF:oF),u=Math.ceil(s.length/d),f=d*(o+l)-l,h=u*(i+l)-l+aF+(r?4:0),v={};for(const k of s)v[k.status]=(v[k.status]??0)+1;const b={};for(const k of s)k.outcome&&(b[k.outcome]=(b[k.outcome]??0)+1);const m=Object.entries(b).map(([k,C])=>`${C} ${k}`),y=[`${v.done??0}/${s.length} done`,v.working?`${v.working} working`:"",v.held?`${v.held} held`:"",v.failed?`${v.failed} failed`:"",v.review?`${v.review} review`:"",...m].filter(Boolean).join(" · ");return{w:Math.max(f,ba(y,Ed)),h,place:(k,C,N)=>{const S=C-f/2,E=e.marks.selected;s.forEach(($,L)=>{const A=S+L%d*(o+l),P=N+Math.floor(L/d)*(i+l),O=Jv.has($.status)?$.status:"pending",T=(E==null?void 0:E.path)===n.path&&E.item===$.index;if(r){bF(k,n,$,A,P,T);return}Ds(k,_t("rect",{x:A,y:P,width:Of,height:Of,class:`cell ${O}${T?" picked":""}`,"data-path":n.path,"data-item":$.index},_t("title",null,`#${$.index+1}${$.label?` ${$.label}`:""}: ${O==="review"?"needs review":O.replace("-"," ")}`)))}),Ds(k,_t("text",{x:C,y:N+h-4,class:"caption","text-anchor":"middle"},y))}}}function yF(e,n,s){const r=Th(e,s),o=Eh(e,n),i=n.kind==="map"?vF(e,n):null,l=i?i.h+nr:0,d=Math.max(vn/2,r.cx,i?i.w/2:0)+nr,u=Math.max(vn/2,r.w-r.cx,i?i.w/2:0)+nr,f=o+nr+l+r.h+nr;return{w:d+u,h:f,cx:d,place:(h,v)=>{const b=ru(e,n,"card"),m=h+d;if(Ds(b,_t("rect",{x:h,y:v+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(Ds(b,ir(m,v+o,m,v+o+nr)),Ds(b,ir(m,v+o+nr+i.h,m,v+o+nr+l))):Ds(b,ir(m,v+o,m,v+o+nr)),Ds(b,ir(m,v+o+nr+l+r.h,m,v+f)),Zv(e,b,n,m-vn/2,v),i){const x=_t("g",{class:"items"});i.place(x,m,v+o+nr),b.appendChild(x)}r.place(m-r.cx,v+o+nr+l)}}}function A_(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Th(e,n){const s=e.kids[n.path]??[],r=A_(n,s);return r==="exit"?R_(e,n,!0):r==="leaf"?hF(e,n):r==="chain"?pF(e,n,s):r==="fan"?gF(e,n,s):yF(e,n,s[0].node)}function ey(e){const{byPath:n,kids:s}=T_(O_(e)),r=o=>{const i=s[o.path]??[],l=A_(o,i),d=l==="frame"?r(i[0].node):l==="chain"||l==="fan"?i.reduce((u,f)=>u+r(f.node),0):0;return(l==="chain"?0:1)+d};return n["/root"]?r(n["/root"]):0}const Rh=e=>`${e} ${e===1?"node":"nodes"}`,O_=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 wF(e,n,s={}){var h;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=T_(O_(n)),o=(v,b)=>(e.setAttribute("viewBox",`0 0 ${v} ${b}`),e.setAttribute("width",String(v)),e.setAttribute("height",String(b)),e.style.setProperty("min-width",`${Math.min(v,480)}px`),{w:v,h:b});if(!r.byPath["/root"])return o(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},l=Th(i,r.byPath["/root"]);l.place(Ji,Ji);let d=l.w,u=l.h;const f=(((h=s.diff)==null?void 0:h.removed)??[]).map(v=>`${v.label} (${v.kind})`);if(f.length){const v=["Removed:",...f.map(m=>Qr(m,da(Math.max(d,300),nN)))],b=_t("g",{class:"removed-list"},_t("title",null,`Removed: ${f.join(", ")}`));v.forEach((m,x)=>{b.appendChild(_t("text",{x:Ji,y:Ji+u+33+x*tN,class:"removed"},m)),d=Math.max(d,ba(m,nN))}),e.appendChild(b),u+=22+v.length*tN}return o(d+2*Ji,u+2*Ji)}function jF(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 kF=1600;function ou({graph:e,marks:n,onSelect:s,className:r,label:o="Workflow graph",minScale:i=.8,maxScale:l=1.3}){const d=g.useRef(null),[u,f]=g.useState({w:0,h:0}),[h,v]=g.useState(0),b=g.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);g.useEffect(()=>{if(!d.current)return;const x=wF(d.current,e,n);f(y=>y.w===x.w&&y.h===x.h?y:x),d.current.style.setProperty("--wf-phase",`-${Date.now()%kF}ms`)},[b]),g.useEffect(()=>{var j;const x=(j=d.current)==null?void 0:j.parentElement;if(!x||typeof ResizeObserver>"u")return;const y=new ResizeObserver(([k])=>v(k.contentRect.width));return y.observe(x),()=>y.disconnect()},[]);const m=u.w&&h?Math.min(l,Math.max(i,h/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":o,className:ee("wf select-none",r),style:u.w?{width:u.w*m,height:u.h*m,maxWidth:"none",minWidth:0}:void 0,onClick:x=>{const y=jF(x.target);y&&s&&s(y)}})}function au({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:ee("inline-block size-2.5 border",r)}),o]},o))]})}const NF=3e3,SF=e=>e.word==="Held"||e.word==="Not decided",oN=e=>`${Math.round(e*100)}%`,L_=e=>`${e} ${e===1?"input":"inputs"}`;function CF(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`Checking on ${L_(e.inputs)} of the agent's own runs: ${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 _F(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 ${oN(r.wf_acc)} vs agent ${oN(r.agent_acc)} on ${L_(r.n)} of the agent's own runs, ${r.agree} said what the agent said, ${r.handed_back} handed back`:null}}function $F({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:l,onDecided:d,pollMs:u=NF}){const[f,h]=g.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});g.useEffect(()=>{i&&h(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const v=g.useRef(d);v.current=d;const b=f.at==="running"?f.replay:null,m=f.at==="running"?f.unread:void 0;g.useEffect(()=>{if(b===null||m!==void 0)return;let j=!0,k;const C=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,b)).then(N=>{var S;if(j){if(N.status==="running"){h({at:"running",replay:b,read:N}),k=setTimeout(C,u);return}h({at:"decided",read:N}),(S=v.current)==null||S.call(v)}},N=>{j&&h(S=>S.at==="running"?{...S,unread:N instanceof Error?N.message:String(N)}:S)})};return C(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,b,m,u]);const x=()=>{h({at:"starting"}),Promise.resolve().then(()=>e.startLearnedWorkflowReplay(n,s,r)).then(j=>{h({at:"running",replay:j.replay,read:null}),l==null||l()},j=>{const k=j==null?void 0:j.code;h({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(W,{size:"sm",onClick:x,disabled:y,"aria-label":`Check revision ${r.slice(0,7)} on the inputs of the agent's own runs`,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} `:CF(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>h({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=_F(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 sx=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},aN=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function EF(e,n,s,r,o){const i=[e.length&&`added ${aN(e.length,"node")} (${sx(e)})`,n.length&&`edited ${sx(n)}`,s.length&&`removed ${aN(s.length,"node")} (${sx(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":o?"Connections changed":"No node changed";const l=i.join(", ");return l.charAt(0).toUpperCase()+l.slice(1)}function TF(e){const n=[];let s=null,r=0;for(const o of e){let i=null,l=null;try{i=o.text===null?null:JSON.parse(o.text),l=i===null?null:$l(i)}catch{l=null}if(!(l!=null&&l.nodes.length)){r+=1;continue}const d=s?OC(s,l):null,u=d?d.added.map(y=>y.path):l.nodes.map(y=>y.path),f=y=>{var j;return((j=l.nodes.find(k=>k.path===y))==null?void 0:j.kind)!=="chain"},h=d?[...d.changed.map(y=>y.next),...d.rewritten.map(y=>y.next)]:[],v=d?d.moved.map(y=>y.next):[],b=new Map(l.nodes.map(y=>[y.path,y.label])),m=d?d.removed.filter(y=>y.kind!=="chain").map(y=>y.label):[],x=d?d.edges.added.length+d.edges.removed.length:0;n.push({digest:o.digest??null,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:l,marks:{meta:Xd(i,l),diff:{added:u,edited:h,moved:v,removed:d?d.removed.map(({label:y,kind:j})=>({label:y,kind:j})):[]}},added:u,edited:h,removed:m,line:d?EF(u.filter(f).map(y=>b.get(y)??y),h.filter(f).map(y=>b.get(y)??y),m,v.length,x):`First version: ${Rh(ey(l))}`}),s=l}return{steps:n,unreadable:r}}const RF=50,AF=1800;function OF({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],cost:i=null,onReplayed:l}){const d=s.filter(v=>_h(v.status)).map(v=>v.name),[u,f]=g.useState(null),h=u!==null&&d.includes(u)?u:d[0]??null;return h===null?null:t.jsx(LF,{v2:e,agentId:n,name:h,choices:d,onPick:f,promotions:r,serving:o,stopped:qv(i,h),onReplayed:l},h)}const Lf="Learned workflow";function LF({v2:e,agentId:n,name:s,choices:r,onPick:o,promotions:i,serving:l,stopped:d,onReplayed:u}){var j;const[f,h]=g.useState(null),[v,b]=g.useState(null),[m,x]=g.useState(0);g.useEffect(()=>{let k=!0;return b(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,RF)).then(C=>{k&&h(C)},C=>{k&&b(C??new Error("unknown"))}),()=>{k=!1}},[e,n,s,m]);const y=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:Lf})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Ft,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(k=>({value:k,label:k}))})]});return v&&!f?t.jsxs("section",{className:"border","aria-label":Lf,children:[y,t.jsx("div",{className:"p-4",children:t.jsx(Or,{problem:Na(v,"the learned workflow"),onRetry:()=>x(k=>k+1),className:""})})]}):f?t.jsxs("section",{className:"border","aria-label":Lf,children:[y,t.jsx(MF,{data:f,promotions:i,serving:((j=l.find(k=>k.workflow===f.name))==null?void 0:j.digest)??null,stopped:d,replay:{v2:e,agentId:n,onStarted:u,onDecided:()=>{x(k=>k+1),u==null||u()}}})]}):t.jsxs("section",{className:"border","aria-label":Lf,"aria-busy":!0,children:[y,t.jsx("div",{className:"p-4",children:t.jsx(Un,{className:"h-48 w-full"})})]})}function MF({data:e,stepMs:n=AF,promotions:s=[],serving:r=null,stopped:o=null,replay:i}){const{steps:l,unreadable:d}=g.useMemo(()=>TF(e.revisions),[e.revisions]),[u,f]=g.useState(Math.max(0,l.length-1)),[h,v]=g.useState(!1),b=g.useRef(u);b.current=u;const m=g.useRef(l);if(g.useEffect(()=>{var A;const E=m.current;m.current=l;const $=((A=E[b.current])==null?void 0:A.digest)??null,L=E===l||b.current>=E.length-1||$===null?-1:l.findIndex(P=>P.digest===$);f(L>=0?L:Math.max(0,l.length-1)),v(!1)},[l]),g.useEffect(()=>{if(!h)return;const E=setInterval(()=>f($=>Math.min($+1,l.length-1)),n);return()=>clearInterval(E)},[h,l.length,n]),g.useEffect(()=>{h&&u>=l.length-1&&v(!1)},[h,u,l.length]),!e.revisions.length)return null;if(!l.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",d?`: ${d} ${d===1?"revision":"revisions"} did not read`:"","."]});const x=l[Math.min(u,l.length-1)],y=l.length,j=E=>{v(!1),f(Math.max(0,Math.min(y-1,E)))},k=()=>{if(h)return v(!1);u>=y-1&&f(0),v(!0)},C=`Revision ${Math.min(u,y-1)+1} of ${y}, ${ht(x.at)}`,N=Bv(s,e.name,x.digest),S=$d(N,{serving:r,stopped:o});return t.jsxs("div",{className:"space-y-3 p-4",children:[y>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(W,{size:"sm",onClick:k,"aria-label":h?"Pause the replay":"Play the replay","aria-pressed":h,children:[h?t.jsx(jl,{"aria-hidden":!0}):t.jsx(Ao,{"aria-hidden":!0}),h?"Pause":"Play"]}),t.jsx(W,{size:"icon",onClick:()=>j(u-1),disabled:u<=0,"aria-label":"Previous revision",children:t.jsx(B1,{"aria-hidden":!0})}),t.jsx(W,{size:"icon",onClick:()=>j(u+1),disabled:u>=y-1,"aria-label":"Next revision",children:t.jsx(Es,{"aria-hidden":!0})}),t.jsx(n5,{min:1,max:y,value:u+1,onChange:E=>j(E-1),label:"Revision",valueText:C,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:y>1?`Revision ${u+1} of ${y}`:"One revision"})," · ",t.jsx("time",{dateTime:x.at,children:ht(x.at)})," · ",x.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(x.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ka(x.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:x.line}),x.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:x.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:S.tone,children:S.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:N?Za(N):x.digest?"No check yet: a new revision is checked on the inputs of the agent's own runs before it serves.":"Its file did not read: no standing."})]}),i&&x.digest&&t.jsx($F,{v2:i.v2,agentId:i.agentId,workflow:e.name,digest:x.digest,offered:SF(S),resume:(N==null?void 0:N.decided)==="replaying"?N.replay_id??null:null,onStarted:i.onStarted,onDecided:i.onDecided},x.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(ou,{graph:x.graph,marks:x.marks,label:`The workflow at revision ${u+1} of ${y}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(au,{}),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"]})]}),(e.total>e.revisions.length||e.truncated||d>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. ",d>0&&`${d} ${d===1?"revision":"revisions"} could not be read as a workflow and ${d===1?"is":"are"} left out.`]})]})}const iN=8,IF={promote:"success",hold:"warning",revision:"active"};function lN({loop:e,promotions:n,serving:s=[],cost:r=null}){const[o,i]=g.useState(!1),l=[...((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(!l.length)return null;const d=o?l:l.slice(0,iN);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:l.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(DF,{compile:u.compile,promotions:n,serving:((f=s.find(h=>h.workflow===u.compile.workflow))==null?void 0:f.digest)??null,stopped:u.compile.workflow?qv(r,u.compile.workflow):null}):t.jsx(zF,{record:u.record})},u.key)})}),l.length>iN&&t.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>i(u=>!u),children:o?"Show fewer":`Show all ${l.length}`})})]})}const PF=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ka(e)]}),M_=({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(PF,{id:n})]}):null]});function DF({compile:e,promotions:n,serving:s,stopped:r}){const o=e.digest===null||e.workflow===null,i=e.attempts.filter(u=>!u.ok),l=[...e.attempts.flatMap((u,f)=>u.ok?[]:u.errors.map(h=>({e:h,attempt:f+1}))),...e.draft_errors.map(u=>({e:u,attempt:null}))],d=o?null:$d(Bv(n,e.workflow,e.digest),{serving:s,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.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."}):l.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:l.map(({e:u,attempt:f},h)=>t.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[f?`Attempt ${f}: `:"",u]},h))}),t.jsx(M_,{at:e.at,run:e.run_id})]})}function zF({record:e}){var o;const n=g_(e),s=$d(e,{serving:e.digest}),r=n==="promote"?s.tone:IF[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:[Hv[n]," · ",ud[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:Za(e)}),(o=e.check)!=null&&o.n?e.reason&&t.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(M_,{at:e.at})]})}const FF={done:{icon:Il,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:nA,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:rA,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Hs,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:qm,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function cN({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:ee("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=FF[n.state],o=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:ee("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:ee("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 I_({id:e,checked:n,onChange:s,busy:r,disabled:o,quiet:i,server:l,problem:d,className:u}){return t.jsxs("div",{className:ee("space-y-2",u),children:[t.jsxs("div",{className:ee("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:"Every later run is given your corrections first, and a job it does again compiles into a workflow it can run as one step."})]}),t.jsx(xi,{checked:n,onChange:s,busy:r,disabled:o,labelledBy:e})]}),l==="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 UF({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const l=e.learning??s,d=xa(l),u=typeof s=="object"?s:!0,f=h=>n({learning:h===!1&&s===void 0?void 0:h});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(I_,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:h=>f(h?u:!1)}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Workflow drafting uses this server's model access: a provider key for the selected model, or a supported server sign-in. Tool API keys do not enable it. ",t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline underline-offset-2",children:"Configure Model keys in API Keys"}),"."]}),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})]})}function P_({access:e,scope:n="agent"}){return(e==null?void 0:e.location)==="native"?t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:e.reason??"This agent learns in its connected runtime using that runtime's existing model access. Its credentials stay there."}):(e==null?void 0:e.ready)===!1?t.jsx(ct,{tone:"warning",title:e.needs==="model"?"Choose a model for learning":"Set up model access for learning","aria-label":"Learning model setup",children:t.jsxs("div",{className:"space-y-3",children:[e.model&&t.jsxs("p",{children:[n==="default"?"Default learning model":"Learning model",": ",t.jsx("span",{className:"font-mono break-all",children:e.model})]}),e.reason&&t.jsx("p",{children:e.reason}),t.jsx("p",{children:"Workflow drafting needs a model provider's key for the selected model, or a supported sign-in on this server. A tool API key or the AgentRun connection key does not provide model access."}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Drafting has separate model usage. Your connected agent keeps its own credentials.",n==="default"&&" This is the server default; each agent can use a different configured model."]}),t.jsx("a",{className:Fs({variant:"primary",size:"sm"}),href:"#/settings/keys",children:"Set up model access"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Settings → API Keys → Model keys"})]})}):t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Workflow drafts are created on this AgentRun server",e!=null&&e.model?t.jsxs(t.Fragment,{children:[" using ",t.jsx("span",{className:"font-mono break-all",children:e.model})]}):" using its configured learning model","."," ","This needs server-side model access and has separate model usage. Your connected agent keeps its own model and tool credentials."]})}const iu=(e,n,s)=>({...Na(e,n),title:s}),WF=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Hn(s):`run ${ka(n)}`},HF="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",BF=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),qF=15e3;function fd(e,n=!1){const[s,r]=g.useState(n),o=g.useRef(Symbol("learning interaction")).current;return g.useEffect(()=>()=>{e.items.delete(o),e.changed(e.items.size>0)},[e,o]),[s,l=>{l?e.items.add(o):e.items.delete(o),e.changed(e.items.size>0),r(l)}]}function GF(e){return t.jsx(KF,{...e},e.agent.agent_id)}function KF({agent:e,v2:n,server:s,onAgent:r,onChanged:o}){var ge;const i=cr(e.definition),[l,d]=g.useState(null),[u,f]=g.useState(null),[h,v]=g.useState([]),[b,m]=g.useState([]),[x,y]=g.useState([]),[j,k]=g.useState(null),[C,N]=g.useState(null),[S,E]=g.useState(!1),$=g.useMemo(()=>({items:new Set,changed:E}),[]),[L,A]=g.useState(0),P=g.useRef(0),O=g.useRef(!0),T=g.useRef(!1),[M,F]=g.useState(!1),I=(Te,Xe=!0)=>{const je=Te==="background";if(!O.current||je&&(T.current||$.items.size))return Promise.resolve();const fe=++P.current;Xe&&A(Ie=>Ie+1),T.current=!0,F(!0),f(null);const De=()=>O.current&&fe===P.current&&(Te==="write"||!$.items.size),te=n.agentLearning(e.agent_id).then(Ie=>{De()&&d(Ie)},Ie=>{De()&&f(Ie??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Ie=>{De()&&v(Ie.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(Ie=>{De()&&(m(Ie.promotions),y(Ie.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(Ie=>{De()&&k(Ie)},()=>{}),te.finally(()=>{fe===P.current&&(T.current=!1,F(!1))})},V=()=>I("manual"),G=g.useRef(()=>{});G.current=()=>{document.hidden||I("background")},g.useEffect(()=>{O.current=!0,I("manual",!1);const Te=()=>G.current();window.addEventListener("focus",Te),document.addEventListener("visibilitychange",Te);const Xe=window.setInterval(Te,qF);return()=>{O.current=!1,P.current++,window.removeEventListener("focus",Te),document.removeEventListener("visibilitychange",Te),window.clearInterval(Xe)}},[n,e.agent_id,e.archived_at]);const q=()=>(o==null||o(),I("write")),H=xa(e.definition.learning),U=!!e.archived_at,Q=(l==null?void 0:l.workflows)??[],D=Dv((l==null?void 0:l.corrections)??""),[Y,K]=g.useState(void 0),Z=!i&&Q.some(Te=>Te.status==="pending");g.useEffect(()=>{if(!Z||Y!==void 0)return;let Te=!0;return Promise.resolve().then(()=>n.capabilities()).then(Xe=>{Te&&K(HD(Xe))},()=>{Te&&K("password")}),()=>{Te=!1}},[Z]);const se=g.useMemo(()=>new Map(h.map(Te=>[Te.run_id,Te])),[h]),ie=h.filter(Te=>Te.learning&&(Te.learning.state==="merged"||Te.learning.state==="dropped")).length,Ne=i?"cli":e.definition.native?"native":is(e.definition)?"sdk":"hosted",he=pz({corrections:D.length,runs:(j==null?void 0:j.completed_runs)??0,workflows:Q,cost:C,promotions:b,serving:x,loop:j,execution:Ne,compileAfter:iz(e.definition.learning)}),ve=Te=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Refresh learning",title:"Refresh learning",disabled:S||M,onClick:()=>{!$.items.size&&!T.current&&V()},children:t.jsx(pi,{className:ee(M&&"animate-spin"),"aria-hidden":!0})})}),l&&!i&&t.jsx(P_,{access:l.learning_model??(e.definition.native?{location:"native",ready:!0,model:null,needs:null,reason:null}:void 0)}),l&&i&&t.jsxs(ct,{children:["This project runs in ",pa(i.runtime),". Its hooks record your normal prompts and provide your owner-written corrections on later prompts. Workflow learning is unavailable for this CLI connection: it needs an approved tool connection. Stored learning files are preserved."]}),Te]});if(u&&!l)return ve(t.jsx(Or,{problem:Na(u,"what this agent learned"),onRetry:V,className:""}));if(!l)return ve(t.jsx(YF,{}));const Ee=u?t.jsx(VF,{error:u,onRetry:V}):null,ye=Te=>t.jsx(JF,{agent:e,v2:n,onAgent:r,server:s,disabled:U,quiet:Te||!!i}),pe=t.jsx(t6,{text:l.corrections,v2:n,agentId:e.agent_id,readOnly:U,onChanged:q,refreshHolds:$});if(!D.length&&!Q.length)return ve(t.jsxs("div",{className:"space-y-6",children:[Ee,t.jsx(e6,{on:H,lookedBack:ie,switchRow:ye(!0),cliRuntime:i?pa(i.runtime):void 0,firstPrompt:!!i&&((ge=e.runs)==null?void 0:ge.count)===0&&h.length===0&&s!=="off"}),pe,H&&t.jsx(cN,{stages:he}),t.jsx(H0,{v2:n,agentId:e.agent_id,on:H,quiet:!0,promotions:b,onCost:N,reads:L,execution:Ne}),t.jsx(Q0,{v2:n,agentId:e.agent_id,cost:C,serving:x}),!i&&t.jsx(lN,{loop:j,promotions:b,serving:x,cost:C}),!i&&t.jsx(uN,{runs:h})]}));const Pe=Q.filter(Te=>Te.status!=="retired"),ue=Q.filter(Te=>Te.status==="retired");return ve(t.jsxs("div",{className:"space-y-6",children:[t.jsx(cN,{stages:he}),JD(l.impact)&&t.jsx(QF,{impact:l.impact,cost:C}),t.jsx(H0,{v2:n,agentId:e.agent_id,on:H,promotions:b,onCost:N,reads:L,execution:Ne}),t.jsx(Q0,{v2:n,agentId:e.agent_id,cost:C,serving:x}),!i&&t.jsx(OF,{v2:n,agentId:e.agent_id,workflows:Q,promotions:b,serving:x,cost:C,onReplayed:()=>{V()}}),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:[Ee,!H&&t.jsx(ZF,{server:s}),pe,Q.length>0&&t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Workflows it learned",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Workflows it learned"}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:i?"Stored workflows are preserved for inspection. This CLI connection cannot execute them.":Pe.length?`${Rl(Pe.length,"workflow")}: a job it does again, as steps a later run can call.`:"No workflow is in use: the next run gets none."})]}),Pe.length>0&&t.jsx("ul",{className:"space-y-3",children:Pe.map(Te=>t.jsx("li",{children:t.jsx(s6,{item:Te,v2:n,agentId:e.agent_id,readOnly:U||!!i,runs:se,approves:Y,onChanged:q,refreshHolds:$})},Te.file))}),ue.length>0&&t.jsx(c6,{items:ue,v2:n,agentId:e.agent_id,runs:se,readOnly:U||!!i,onChanged:q,refreshHolds:$})]})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(D_,{title:"Learning",children:ye(!1)}),!i&&t.jsx(lN,{loop:j,promotions:b,serving:x,cost:C}),!i&&t.jsx(uN,{runs:h}),t.jsx(f6,{corrections:D.length,workflows:i?[]:Q.filter(Te=>_h(Te.status)),off:!H||s==="off"})]})]})]}))}function VF({error:e,onRetry:n}){const s=Na(e,"what it learned"),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 what it learned: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),t.jsx(W,{type:"button",onClick:n,size:"sm",children:"Try again"})]})}function D_({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 YF(){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:ee(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:ee(e,"h-4 w-1/3")}),t.jsx("span",{className:ee(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:ee(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function QF({impact:e,cost:n}){const{before:s,after:r}=e,o=[{label:"Answers in",now:km(r.median_duration_s),was:km(s.median_duration_s),delta:YD(s.median_duration_s,r.median_duration_s)}],i=n!=null&&n.bill?$z(n.bill):null,l=`Medians of ${_d(s.runs)} before it first learned and ${_d(r.runs)} that started from what it learned (a correction or a workflow).`;return t.jsx("section",{className:"border","aria-label":QD(e,i),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:l,children:m_(e)})]}),t.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[o.map(d=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:d.label}),t.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[t.jsx("span",{className:"text-figure font-semibold leading-none",children:d.now}),t.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",d.was]}),d.delta!==null&&d.delta!==0&&t.jsxs("span",{className:ee("text-small",d.delta<0?"text-primary-text":"text-warning-text"),children:[d.delta>0?"+":"−",Math.abs(d.delta),"%"]})]})]},d.label)),i!==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.jsx("dd",{className:"font-mono text-body text-muted-foreground",title:"The bill's learning spend (compile turns, audits' shadow runs, replays) over the runs that did a job.",children:f_(i)})]})]})]})})}function JF(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(a_,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(XF,{...e})}function XF({agent:e,v2:n,onAgent:s,server:r,disabled:o,quiet:i}){const[l,d]=g.useState(!1),[u,f]=g.useState(null),[h,v]=g.useState(null),b=async m=>{d(!0),f(null),v(m);try{const{agent:x,etag:y}=await n.getAgent(e.agent_id),j=m?xa(x.definition.learning)?x.definition.learning:!0:!1,k=Gl(x,{learning:j},m?"Learning on":"Learning off");if(k.unchanged)s==null||s(x);else{const{unchanged:C,...N}=k;s==null||s((await n.updateDefinition(e.agent_id,N,y)).agent)}}catch(x){f(x??new Error("unknown"))}v(null),d(!1)};return t.jsx(I_,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:h??xa(e.definition.learning),onChange:m=>void b(m),busy:l,disabled:o,server:r,problem:u?t.jsx(Or,{problem:iu(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function ZF({server:e}){return t.jsxs(ct,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs aren't given these corrections or workflows. They're kept for when it's back on."]})}function e6({on:e,lookedBack:n,switchRow:s,cliRuntime:r,firstPrompt:o}){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(tS,{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?o?"Waiting for the first captured prompt.":r?"No corrections yet.":"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:r?e&&o?`Continue your normal work in ${r}; its hooks report completed prompts here. Earlier conversations are not imported automatically.`:`Your corrections are kept here and provided to ${r} on later prompts when learning is on.`:e?"Every later run is given your corrections whole, and a job it does again compiles into a workflow. Both show here.":"With learning on, every later run is given your corrections, and a job it does again compiles into a workflow."}),e&&!r&&n>0&&t.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[_d(n)," had their compile turn: no workflow kept yet."]})]}),t.jsx("div",{className:"border-t",children:s})]})}function t6({text:e,v2:n,agentId:s,readOnly:r,onChanged:o,refreshHolds:i}){const[l,d]=fd(i),[u,f]=g.useState(!1),h=Dv(e),v=e.trim()!=="",b=g.useMemo(()=>Yr(e.trim()),[e]);return g.useEffect(()=>{if(!u)return;const m=setTimeout(()=>f(!1),2400);return()=>clearTimeout(m)},[u]),t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Corrections",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.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:["Corrections",u&&t.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:"Saved"})]}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:h.length?`${zv(h.length)}. Every later run is given ${h.length===1?"it":"them"} whole before it starts.`:v?"Every later run is given this text whole before it starts.":"None yet. A correction you give with a run's grade is kept here, one line each; every later run is given them whole."})]}),!r&&!l&&t.jsxs(W,{size:"sm",variant:"ghost",onClick:()=>d(!0),"aria-label":"Edit corrections",children:[t.jsx(Ym,{"aria-hidden":!0})," Edit"]})]}),l?t.jsx(n6,{v2:n,agentId:s,onDone:m=>{d(!1),m&&(f(!0),o())}}):v&&t.jsx("div",{className:"border bg-card/40",children:t.jsx("div",{className:ee(HF,"max-h-96 overflow-auto break-words px-5 py-4"),dangerouslySetInnerHTML:{__html:b}})})]})}function n6({v2:e,agentId:n,onDone:s}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(0),[f,h]=g.useState(null),[v,b]=g.useState(!1),[m,x]=g.useState([]),[y,j]=g.useState(null),[k,C]=g.useState(null),N=g.useRef(null),S=async(O=!1)=>{h(null);try{const T=await e.corrections(n);o(O?M=>M??T.text:T.text),l(T.etag),u(T.cap_bytes)}catch(T){h(T??new Error("unknown"))}};g.useEffect(()=>{S()},[]),g.useEffect(()=>{var O;r!==null&&((O=N.current)==null||O.focus())},[r===null]);const E=r===null?0:UD(r),$=d>0&&E>d,L=r!==null&&i!==null&&!$&&!v,A=async()=>{if(L){j(null),x([]),b(!0);try{await e.writeCorrections(n,r,i),s(!0)}catch(O){b(!1);const T=O instanceof Ue?Tv(O):null;(T==null?void 0:T.kind)==="conflict"?(C(r),o(null),await S()):(T==null?void 0:T.kind)==="refused"?x(T.problems):j(O??new Error("unknown"))}}},P=O=>{O.key==="Escape"?(O.preventDefault(),O.stopPropagation(),s(!1)):O.key==="Enter"&&(O.metaKey||O.ctrlKey)&&(O.preventDefault(),A())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":"Edit corrections",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:"corrections.md"}),t.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[t.jsxs("kbd",{children:[BF?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),f!==null&&t.jsx(Or,{problem:Na(f,"the corrections"),onRetry:()=>void S(!0),className:"m-5"}),t.jsxs("div",{className:"space-y-4 px-5 py-4",children:[k&&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(Hs,{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:k})]})]}),r===null?f===null&&t.jsx("div",{role:"status","aria-label":"Loading the corrections",children:t.jsx("div",{"aria-hidden":!0,className:"h-24 bg-muted motion-safe:animate-pulse"})}):t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Corrections"}),t.jsx(An,{ref:N,value:r,onChange:O=>o(O.target.value),rows:8,placeholder:"One correction a line: what to do differently, and why.",className:"resize-y font-mono leading-[1.65]"})]}),d>0&&t.jsxs("p",{className:ee("font-mono text-label",$?"text-destructive-text":"text-muted-foreground"),role:$?"alert":void 0,children:[E," of ",d," bytes",$?": too long to save":""]}),m.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: it doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:m.map((O,T)=>t.jsx("li",{children:O.detail},T))})]}),y!==null&&t.jsx(Or,{problem:iu(y,"the corrections","The corrections were not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(W,{size:"sm",variant:"solid",onClick:()=>void A(),disabled:!L,children:v?"Saving":"Save"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>s(!1),disabled:v,children:"Cancel"})]})]})]})}const Mf={serving:{word:"Serving",tone:"success",title:"It runs first on the runs it fits."},checking:{word:"Checking",tone:"active",title:"Its check on the agent's own runs decides whether this revision serves. The previous revision keeps serving meanwhile; the agent takes the runs only when none serves."},held:{word:"Held",tone:"warning",title:"It does not serve: its newest check or audit held it."},stopped:{word:"Stopped",tone:"muted",title:"It does not run first until a new revision lands: its checks stopped it, or it cost as much as the agent by hand. The agent takes its runs."}};function s6({item:e,v2:n,agentId:s,readOnly:r,runs:o,approves:i,onChanged:l,refreshHolds:d}){const[u,f]=fd(d),[h,v]=g.useState(null),[b,m]=g.useState(null),[x,y]=fd(d),[j,k]=fd(d),[C,N]=g.useState(null),S=e.status==="pending",E=async()=>{m(null),v(null);try{v((await n.readLearningFile(s,e.file)).text)}catch(P){m(P??new Error("unknown"))}},$=async()=>{if(u)return f(!1);f(!0),h===null&&await E()};g.useEffect(()=>{h!==null&&(u?E():v(null))},[e.etag]);const L=async()=>{y(!0),N(null);try{await n.approveWorkflow(s,e.readme,e.etag)}catch(P){y(!1),N(P instanceof Ue&&Tv(P).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Pv} Reload the tab to see the newest version.`}):t.jsx(Or,{problem:iu(P,"the workflow","The workflow was not approved."),className:""}));return}await l(),y(!1)},A=`the workflow ${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}),S&&t.jsxs(ke,{tone:"warning",children:[t.jsx(Y1,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]}),Mf[e.status]&&t.jsx(ke,{tone:Mf[e.status].tone,title:Mf[e.status].title,children:Mf[e.status].word})]}),e.description&&t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),S&&i==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:BD})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!r&&!j&&t.jsxs(t.Fragment,{children:[S&&i==="yes"&&t.jsx(W,{size:"sm",variant:"solid",onClick:()=>void L(),disabled:x,"aria-label":`Approve ${e.name}`,children:x?"Approving":"Approve"}),t.jsx(W,{size:"sm",variant:"destructive",onClick:()=>k(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),t.jsxs(W,{size:"sm",variant:"ghost",onClick:()=>void $(),"aria-expanded":u,"aria-label":`${u?"Hide":"Show"} ${A}`,children:[t.jsx(ui,{className:ee("transition-transform",u&&"rotate-180"),"aria-hidden":!0}),u?"Hide":"Show"]})]})]}),C&&t.jsx("div",{className:"px-5 pt-3",children:C}),u&&(b!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(Or,{problem:Na(b,A),onRetry:()=>void E(),className:""})}):h===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${A}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t.jsx(r6,{name:e.name,text:h})),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(z_,{run:e.run,runs:o}),dN(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(sS,{className:"size-3","aria-hidden":!0}),dN(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),j&&t.jsx(a6,{name:e.name,retire:()=>n.retireWorkflow(s,e.readme,e.etag),onDone:async P=>{P&&await l(),k(!1)}})]})}function r6({name:e,text:n}){const{doc:s,graph:r}=g.useMemo(()=>{try{const l=JSON.parse(n);return{doc:l,graph:$l(l)}}catch{return{doc:null,graph:null}}},[n]),o=g.useMemo(()=>r?{meta:Xd(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(ou,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(au,{}),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 dN(e){return e&&e.kind!=="learned"?`${d_(e.kind,e.by)} · ${ht(e.at)}`:null}function o6(e){return(e==null?void 0:e.by)==="host"?PD:e?`${d_("retired",e.by)} · ${ht(e.at)}`:"Retired"}function z_({run:e,runs:n}){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",children:[t.jsx(tS,{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:WF(n,e),children:ka(e)})]})}function a6({name:e,retire:n,onDone:s}){const[r,o]=g.useState(!1),[i,l]=g.useState(null),d=g.useRef(null);g.useEffect(()=>{var f;(f=d.current)==null||f.focus()},[]);const u=async()=>{o(!0),l(null);try{await n()}catch(f){o(!1),l(f instanceof Ue&&Tv(f).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Pv} Reload the tab to see the newest version.`}):t.jsx(Or,{problem:iu(f,"the workflow","The workflow was not retired."),className:""}));return}await s(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:f=>{f.key==="Escape"&&(f.stopPropagation(),s(!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?"})," Later runs stop getting it. It stays under Earlier workflows."]}),i&&t.jsx("div",{className:"w-full",children:i}),t.jsx(W,{ref:d,size:"sm",variant:"destructive",onClick:()=>void u(),disabled:r,children:r?"Retiring":"Yes, retire"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>void s(!1),disabled:r,children:"Keep"})]})}function i6({name:e,from:n,restore:s,onChanged:r,onDone:o}){const[i,l]=g.useState(!1),[d,u]=g.useState(null),f=g.useRef(null);g.useEffect(()=>{var b;(b=f.current)==null||b.focus()},[]);const h=b=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:b}),v=async()=>{var b;l(!0),u(null);try{await s()}catch(m){if(l(!1),m instanceof Ue&&(m.status===412||m.code==="precondition_failed")){u(h(Pv)),await r();return}if(m instanceof Ue&&m.status===403)return void u(h(FD));if(m instanceof Ue&&((b=m.problems)!=null&&b.length))return void u(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",m.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:m.problems.map((x,y)=>t.jsx("li",{children:x.detail},y))})]}));if(m instanceof Ue&&m.status===400){await r(),o();return}return void u(t.jsx(Or,{problem:iu(m,"the workflow","The workflow was not restored."),className:""}))}await r(),o()};return t.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:b=>{b.key==="Escape"&&(b.stopPropagation(),o())},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?"})," ",zD(n)]}),d&&t.jsx("div",{className:"w-full",children:d}),t.jsx(W,{ref:f,size:"sm",variant:"solid",onClick:()=>void v(),disabled:i,children:i?"Restoring":"Yes, restore"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:o,disabled:i,children:"Keep"})]})}function l6({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(ui,{className:ee("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 c6({items:e,v2:n,agentId:s,runs:r,readOnly:o,onChanged:i,refreshHolds:l}){const[d,u]=g.useState(!1),[f,h]=fd(l,null),[v,b]=g.useState(new Set),m=x=>b(y=>{const j=new Set(y);return j.has(x)?j.delete(x):j.add(x),j});return t.jsx(l6,{title:"Earlier workflows",count:`${e.length} no longer given`,open:d,onToggle:()=>u(x=>!x),children:e.map(x=>{var y;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:x.name}),t.jsx(ke,{tone:"muted",children:"Retired"}),t.jsx(d6,{open:v.has(x.file),label:`the workflow ${x.name}`,onClick:()=>m(x.file)}),!o&&f!==x.file&&t.jsxs(W,{size:"sm",onClick:()=>h(x.file),"aria-label":`Restore ${x.name}`,children:[t.jsx(SA,{"aria-hidden":!0})," Restore"]})]}),x.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:x.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:o6(x.retired)}),f===x.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(i6,{name:x.name,from:(y=x.retired)==null?void 0:y.from,restore:()=>n.restoreWorkflow(s,x.readme,x.etag),onChanged:i,onDone:()=>h(null)})}),v.has(x.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(u6,{v2:n,agentId:s,file:x.file,etag:x.etag,label:`the workflow ${x.name}`}),x.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(z_,{run:x.run,runs:r})})]})]},x.file)})})}function d6({open:e,label:n,onClick:s}){return t.jsxs(W,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${n}`,children:[t.jsx(ui,{className:ee("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function u6({v2:e,agentId:n,file:s,etag:r,label:o}){const[i,l]=g.useState(null),[d,u]=g.useState(null),f=g.useRef(0),h=async()=>{const v=++f.current;u(null),l(null);try{const b=await e.readLearningFile(n,s);v===f.current&&l(b.text)}catch(b){v===f.current&&u(b??new Error("unknown"))}};return g.useEffect(()=>{h()},[s,r]),d!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(Or,{problem:Na(d,o),onRetry:()=>void h(),className:""})}):i===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${o}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:i})}function uN({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>jm(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>jm(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(D_,{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:Uv(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:Hn(o),children:Hn(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",ht(o.created_at)]})]})]})},o.run_id))}),r>0&&t.jsxs("p",{className:ee("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`:`${_d(r)} had`," nothing new to compile."]})]}):null}function f6({corrections:e,workflows:n,off:s}){const r=s?[]:[...e?[zv(e)]:[],...n.length?[Rl(n.length,"workflow")]:[]];return t.jsxs("section",{className:"border","aria-label":"What the next run is given",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What the next run is given"}),t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:s?"Learning is off: the next run gets no corrections or workflows.":r.length?`${r.join(" and ")}.`:"Nothing yet."}),!s&&n.length>0&&t.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Workflows: ",n.map(o=>`${o.name} (${o.status})`).join(", ")]})]})}function ty({run:e,link:n=!1,className:s}){var l;const r=$h(e.learning)&&e.learning.state!=="seeded",o=u_(e.learning),i=((l=e.learning)==null?void 0:l.state)==="dropped"&&jm(e.learning.reason)!=="nothing"?Uv(e.learning):null;return!r&&!o.length&&!i?null:t.jsxs("span",{className:ee("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[i&&t.jsx(m6,{agentId:e.agent_id,said:i,link:n}),[!1,!0].map(d=>{const u=o.filter(f=>f.pending===!0===d);return u.length?t.jsx(h6,{agentId:e.agent_id,refs:u,link:n,pending:d},String(d)):null}),r&&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"})]}),KD(e.learning.state)]})]})}function m6({agentId:e,said:n,link:s}){const r=t.jsxs(ke,{tone:"muted",className:ee(s&&"cursor-pointer"),children:[t.jsx(sA,{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:Wv(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 h6({agentId:e,refs:n,link:s,pending:r}){const o=r?`${Rl(n.length,"workflow")} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Rl(n.length,"workflow")}`,i=`${o}: ${n.map(u=>u.name).join(", ")}`,l=r?Y1:va,d=t.jsxs(ke,{tone:r?"warning":void 0,className:ee(!r&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[t.jsx(l,{className:"size-3","aria-hidden":!0}),o]});return s?t.jsx("a",{href:Wv(e),title:i,"aria-label":i,className:"inline-flex",children:d}):t.jsx("span",{title:i,"aria-label":i,className:"inline-flex",children:d})}function p6({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":Fv(e),className:ee("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})}function lu(){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 yi(e=lu){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 F_(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function g6(e=lu){const n=new Map;return s=>{let r=n.get(s);return r||(r=yi(e),n.set(s,r)),r}}function Zx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const x6=["pi","claude-agent","codex","opencode"];function b6(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 v6(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 y6(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 ny="Refused on this server for every agent, whatever the agent's own setting or Never ask.",w6="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.",U_=(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=_o(e),l=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 l?l.permission==="deny":n.some(u=>u.name===e&&u.permission==="deny")};function j6(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 k6={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},W_={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."}}},Cm=(e,n)=>{var s;return(n&&((s=W_[n])==null?void 0:s.label[e]))??k6[e]??e},N6={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."},fN=(e,n)=>{var s;return(n&&((s=W_[n])==null?void 0:s.help[e]))??N6[e]};function H_(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Cm(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function B_(e,n,s,r,o){const{[n]:i,...l}=e,{[s]:d,...u}=i??{},f=r===void 0||r===o?u:{...u,[s]:r};return Object.keys(f).length?{...l,[n]:f}:l}const S6=(e,n,s,r)=>B_(e,n,"provider",s,r),C6=(e,n,s,r)=>B_(e,n,"permission",s,r);function eb(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,...l}=o,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...l,provider:i}:l;return Object.keys(d).length?[[r,d]]:[]}))}function q_(e,n,s){const r={},o=[];for(const[i,l]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,h)=>h.length-f.length).find(f=>d===f||d.startsWith(`${f}.`)||d.startsWith(`${f}/`));u?(r[u]??(r[u]=[])).push(l):o.push(l)}return{byTool:r,rest:o}}const _6=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$6=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))]},E6=e=>typeof e=="string"?e:JSON.stringify(e);function T6(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(_6(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=$6(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>E6(d));if(!i.length)return`${n} must be left out`;const l=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${n} must be ${o?`left out or ${l}`:l}`}).join("; ")}const R6="Calls outside it are refused before they run or ask.",A6="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.";function Us(e,...n){const s=e.toLowerCase().split(/\s+/).filter(Boolean);if(!s.length)return!0;const r=n.filter(Boolean).join(`
|
|
670
|
-
`).toLowerCase();return s.every(o=>r.includes(o))}function cu({value:e,onChange:n,label:s,placeholder:r,shown:o,total:i,ticked:l,active:d=e.trim()!=="",className:u,children:f}){return t.jsxs("div",{className:ee("flex flex-wrap items-center gap-3",u),children:[t.jsxs("label",{className:ee(Cl,"flex h-control-sm min-w-40 flex-1 items-center gap-2 px-2.5"),children:[t.jsx(Jm,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Fe,{bare:!0,type:"search",value:e,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Enter"&&h.preventDefault()},placeholder:r,"aria-label":s,spellCheck:!1,autoComplete:"off",className:"h-full flex-1 text-small"})]}),f,t.jsx("p",{role:"status",className:"font-mono text-small text-muted-foreground",children:d?`${o} of ${i} shown${l===void 0?"":`, ${l} ticked`}`:""})]})}const O6=[{id:"runs",label:"Runs",shows:()=>!0,Body:D6},{id:"versions",label:"Versions",shows:()=>!0,Body:SP},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:z6},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(GF,{agent:e.agent,v2:e.v2,server:e.learning,onAgent:e.onAgent,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,n)=>n.analytics,Body:JP}],jn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function L6({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,tab:i,learning:l,places:d}){const[u,f]=g.useState(null),[h,v]=g.useState(null),[b,m]=g.useState(0),[x,y]=g.useState(void 0);g.useEffect(()=>{let T=!0;return f(null),v(null),y(void 0),S(!1),C.current=++j.current,e.getAgent(n).then(M=>{T&&f(M.agent)},M=>{T&&v({cause:M})}),e.statsOver({from:bm(e_),agent:n}).then(M=>{T&&y(M)},()=>{T&&y(null)}),()=>{T=!1,C.current=++j.current}},[e,n,b]);const j=g.useRef(0),k=g.useRef(0),C=g.useRef(0),[N,S]=g.useState(!1),E=(T=!1,M=!T)=>{const F=++j.current;return M&&(C.current=F),e.getAgent(n).then(I=>(F>k.current&&F>=C.current&&(k.current=F,f(V=>V&&V.agent_id===I.agent.agent_id?I.agent:V),S(!1)),k.current>=F),()=>(F===j.current&&!T&&S(!0),k.current>=F))},$=T=>{f(M=>({...T,tools:(M==null?void 0:M.tools)??T.tools})),E()},L=()=>void E(),A=()=>void E(!0,!1),P=()=>E(!0,!0),O=x===void 0?void 0:x!==null;return h?h.cause instanceof Ue&&h.cause.status===404?t.jsx(LC,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(on,{problem:Yt(h.cause,"the agent"),onRetry:()=>m(T=>T+1)}):u?t.jsx(M6,{agent:u,onAgent:$,onSignInsAgent:f,reread:E,onChanged:L,poll:A,afterForget:P,stale:N,v2:e,go:o,stats:x,analytics:O,places:d,routePrefix:s,harnesses:r,tab:i,learning:l},u.agent_id):t.jsx(yP,{})}function M6({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,poll:i,afterForget:l,stale:d,v2:u,go:f,stats:h,analytics:v,routePrefix:b,harnesses:m,tab:x,learning:y,places:j}){var ue,ge,Te,Xe;const k=P6(e,u,r,()=>r(!1,!1)),[C,N]=g.useState(!1),S=Kg(),E=Kg(),$=Kg(),L=g.useRef(null),[A,P]=g.useState({heading:!1,description:!1});g.useEffect(()=>{const je=L.current,fe=$.current;if(!je||!fe||typeof ResizeObserver>"u")return;const De=We=>We.scrollHeight>We.clientHeight+1,te=()=>P(We=>{const rt={heading:De(je),description:De(fe)};return rt.heading===We.heading&&rt.description===We.description?We:rt}),Ie=new ResizeObserver(te);for(const We of[je,fe]){Ie.observe(We);for(const rt of We.children)Ie.observe(rt)}return te(),()=>Ie.disconnect()},[$,e.definition.name,e.definition.description,e.definition.approvals]);const O=wm(e),T=e.definition,M=is(T),F=cr(T),{native:I,refresh:V}=wD(e,u),G=e.kind==="workflow",q=G?va:Ud,H=Vv(T.harness??"pi",m),U=T.model?Al(T.model,b):H?(({text:je,title:fe})=>({text:`${je} (default)`,title:fe}))(Al(H,b)):{text:Jz},Q=G||I||M||F||m==null?void 0:m.find(je=>je.id===(T.harness??"pi")&&je.available===!1),D=Q?`${Q.id} doesn't run on this server${Q.reason?`: ${Q.reason}`:"."}`:void 0,Y=xD(e,j),K=`${rD(Y==null?void 0:Y.place)}${Y!=null&&Y.byDefault?" (server default)":""}`,Z=!M&&!F&&!I&&!G&&!Q&&!T.model&&!H&&(m==null?void 0:m.some(je=>je.id===(T.harness??"pi")&&je.default_model===null)),se=e.archived_at?null:e.run_blockers,ie=se?se.fields.length?se.fields.filter(je=>!(D&&je.field==="definition.harness")&&!(Z&&je.field==="definition.model")).map(je=>je.message):[se.message]:[],Ne=[...F?[["Runtime",pa(F.runtime)],["Model","Reported per run"],["Execution","Your CLI"],["Project",F.project]]:M?[["Runtime",Ro(M)],["Model","Reported per run"],["Execution","Your backend"]]:I?[["Runtime",I.runtime],["Model",I.model??"Native default"],["Selector",I.selector.kind==="project"?"Project default":I.selector.name??I.selector.kind],["Machine",I.machine_id]]:G?[]:[["Harness",T.harness??"pi"],["Model",U.text,U.title],["Thinking",T.thinking??"default"],["Runs",K]],["Revision",`rev ${T.version} of ${e.revisions}`]],he=O6.filter(je=>je.shows(e,{analytics:v===!0,learning:y===void 0?x==="learning"?void 0:!1:!!y})),ve=he.find(je=>je.id===x)??he[0],Ee=x==="analytics"&&v===void 0,ye=((ue=k.runs)==null?void 0:ue.filter(I6))??[],pe=((ge=e.runs)==null?void 0:ge.live)??(k.runs?`${ye.length}${k.cursor?"+":""}`:"—"),Pe=[["Status",e.archived_at?"Archived":I?eu(I):"Active"],["Live jobs",String(pe)],...Ne];return t.jsx(jD,{native:I,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap gap-2 px-5 lg:flex-nowrap"),"aria-label":"Agent toolbar",children:[t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(Wn,{"aria-hidden":!0})}),t.jsx(q,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:T.name}),t.jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-center justify-end gap-2",children:[t.jsx(W,{size:"icon","aria-label":"Refresh agent",onClick:()=>{k.refresh(),V()},disabled:k.reading,children:t.jsx(pi,{className:ee(k.reading&&"animate-spin"),"aria-hidden":!0})}),!I&&!M&&!F&&t.jsx(W,{size:"sm",onClick:()=>f(jn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(Ut,{label:"Edit agent",prompt:ga(location.origin,e.agent_id,!!I,M,F==null?void 0:F.runtime),playgroundHref:I||M||F?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(Ut,{variant:"primary",label:"Run agent",disabled:!!I&&(!I.connected||I.state!=="ready"||!I.capabilities.launch),prompt:lv(location.origin,e.agent_id,M,F==null?void 0:F.runtime),playgroundHref:M||F?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)] lg:grid-rows-[minmax(0,1fr)] lg:items-stretch lg:overflow-hidden md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6 lg:flex lg:min-h-0 lg:flex-col","aria-label":"Agent overview",children:[t.jsxs("div",{ref:L,"data-agent-heading":!0,...A.heading?{tabIndex:0,role:"region","aria-label":"Agent name and description"}:{},className:"lg:-mr-4 lg:flex lg:max-h-[50%] lg:shrink-0 lg:flex-col lg:overflow-y-auto lg:overflow-x-hidden lg:pr-4 lg:[scrollbar-width:none]",children:[t.jsx("h1",{className:"text-2xl font-semibold lg:shrink-0",children:T.name}),T.approvals==="never"&&t.jsx(ke,{tone:"warning",className:"mt-2 lg:shrink-0 lg:self-start",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"}),t.jsx("div",{ref:$,"data-agent-description":!0,...A.description?{tabIndex:0,role:"region","aria-label":"Agent description"}:{},className:ee("scroll-quiet min-w-0 lg:-mr-4 lg:overflow-y-auto lg:overflow-x-hidden lg:pr-2.5",T.description?"lg:min-h-7":"lg:min-h-0"),children:T.description&&t.jsx("p",{id:"agent-description",className:ee("mt-2 break-words text-body leading-relaxed text-muted-foreground",!C&&"max-sm:line-clamp-2"),children:T.description})}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground lg:shrink-0",children:e.agent_id})]}),t.jsxs("div",{ref:S,"data-agent-details":!0,className:"scroll-quiet min-w-0 space-y-6 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:flex-1 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5",children:[t.jsxs("button",{type:"button","aria-expanded":C,"aria-controls":T.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(je=>!je),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:ee("size-3.5 shrink-0 transition-transform",C&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:Pe.map(([,je])=>je).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:ee("grid grid-cols-2 gap-3",!C&&"max-sm:hidden"),"aria-label":"Current revision",children:[Pe.map(([je,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:je}),t.jsx("dd",{className:"break-words text-body font-semibold",title:De,children:fe})]},je)),!G&&!I&&!M&&!F&&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:!G&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(je=>t.jsxs("li",{children:[t.jsx("span",{title:je.blurb,children:je.name}),je.provider?` · ${Cm(je.provider,je.name)}`:"",je.permission?` · ${je.permission}`:"",H_(je.resolved,je.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:je.resolved,children:" · unavailable"})]},je.name))}):"none":T.tools.join(", ")||"None configured"})]})]}),D&&t.jsx(ct,{tone:"warning","aria-label":"Harness not available",children:D}),!e.archived_at&&Z&&t.jsxs(ct,{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"})]}),ie.length>0&&t.jsxs(ct,{tone:"warning","aria-label":"Runs refused",children:[t.jsx("p",{children:"A run of this agent is refused until this is fixed:"}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:ie.map((je,fe)=>t.jsx("li",{children:je},fe))})]}),d&&t.jsxs(ct,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(W,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(Te=e.warnings)!=null&&Te.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((je,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:je.field})," ",je.message]},`${je.field}:${fe}`))})]}):null,t.jsx(CD,{agent:e,v2:u,onAgent:s,poll:i,refresh:l}),I&&t.jsx(kD,{agent:e,v2:u,learning:y,onAgent:n,onChanged:async()=>{V(),await r()}}),!I&&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:F?"Managed in your CLI":M?"Managed by your backend":T.skills.join(", ")||"None configured"})]})]}),T.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:T.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"}),ye.length?t.jsx("ul",{className:"space-y-3",children:ye.map(je=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(je.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(ql,{run:je}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Hn(je)}),t.jsx(So,{className:"size-3 shrink-0","aria-hidden":!0})]})},je.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:k.runs?(Xe=e.runs)!=null&&Xe.live?"Live jobs are outside the loaded history. Load more runs to find them.":k.error?"Live jobs could not be refreshed.":"No live jobs.":"Loading live jobs…"})]})]})]}),t.jsxs("section",{ref:E,className:"scroll-quiet min-w-0 lg:-ml-1 lg:-mr-4 lg:min-h-0 lg:overflow-y-auto lg:overflow-x-hidden lg:pb-6 lg:pl-1 lg:pr-2.5","aria-label":"Agent workspace",children:[t.jsx(av,{id:"agent-views",label:"Agent views",value:ve.id,onChange:je=>f(jn(e.agent_id,je)),tabs:he.map(je=>({id:je.id,label:t.jsxs(t.Fragment,{children:[je.label,je.id==="learning"&&t.jsx(p6,{n:O,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...ld("agent-views",ve.id),"aria-label":Ee?void 0:ve.label,children:Ee?t.jsx(cs,{label:"Loading the tab",rows:4}):t.jsx(ve.Body,{agent:e,v2:u,go:f,stats:h,history:k,learning:y,onAgent:n,onChanged:o,places:j})})]})]})]})})}const I6=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function P6(e,n,s,r){const[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(!1),[h,v]=g.useState(!1),[b,m]=g.useState(null),[x,y]=g.useState(!1),j=g.useRef(0),k=g.useRef([]),C=g.useRef(0),N=g.useRef(!1),S=async(E,$=!1,L=!1,A=!1)=>{if(N.current)return;N.current=!0;const P=++j.current;f(!0),v(!!E);const O=$?A?r():s():Promise.resolve();try{let T=E,M=[];const F=E||L?void 0:k.current.at(-1),I=F?Date.parse(F.created_at):NaN,V=C.current+1;let G=!1;const q=new Set;do{if(q.size>=V){y(!0),m({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(q.has(T))throw new Error("The runs list repeated a page. Refresh to try again.");q.add(T);const H=await n.listAgentRuns(e.agent_id,50,T,!!e.archived_at);if(P!==j.current)return;M=Zx(M,H.runs),T=H.next_cursor,G||(G=H.runs.some(U=>U.run_id===(F==null?void 0:F.run_id)||Date.parse(U.created_at)<I))}while(!E&&T&&F&&!G);P===j.current&&(k.current=E?Zx(k.current,M):M,C.current=E?C.current+1:q.size,i(k.current),d(T),m(null),y(!1))}catch(T){P===j.current&&m(Yt(T,E?"more runs":"the runs"))}finally{await O,P===j.current&&(N.current=!1,f(!1),v(!1))}};return g.useEffect(()=>{N.current=!1,k.current=[],C.current=0,i(null),d(null),m(null),y(!1),S(null);const E=()=>{document.hidden||S(null,!0,!1,!0)};window.addEventListener("focus",E),document.addEventListener("visibilitychange",E);const $=window.setInterval(E,1e4);return()=>{j.current++,N.current=!1,window.clearInterval($),window.removeEventListener("focus",E),document.removeEventListener("visibilitychange",E)}},[n,e.agent_id,e.archived_at]),{runs:o,cursor:l,reading:u,more:h,error:b,refresh:()=>{S(null,!0)},loadMore:()=>{l&&S(l)},reloadLatest:x?()=>{S(null,!0,!0)}:null}}function D6({agent:e,history:n}){const[s,r]=g.useState(""),{runs:o,cursor:i,reading:l,more:d,error:u,refresh:f,loadMore:h,reloadLatest:v}=n;if(u&&!o)return t.jsx(on,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(cs,{label:"Loading the runs",rows:5});const b=o.filter(m=>Us(s,Hn(m),m.run_id,m.status));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.jsx(cu,{value:s,onChange:r,label:"Search this agent's runs",placeholder:"Search runs…",shown:b.length,total:o.length,className:"max-w-md flex-1"}),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(Ut,{label:"Query",prompt:`${bh(location.origin,e.agent_id)}
|
|
671
|
-
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:wv(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(m=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:m},m))})}),t.jsx("tbody",{children:b.map(m=>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(ql,{run:m})}),t.jsxs("td",{className:"min-w-48 px-4 py-3",children:[t.jsxs("a",{href:`#/runs/${encodeURIComponent(m.run_id)}`,className:"flex items-center gap-2 font-semibold hover:text-primary-text",children:[t.jsx("span",{className:"line-clamp-2",children:Hn(m)}),t.jsx(So,{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(ty,{run:m}),m.effort&&t.jsxs("span",{children:["effort ",m.effort]}),m.imported_from&&t.jsxs("span",{children:["Imported history · ",m.imported_from.source]})]})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ht(m.created_at)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:m.ended_at?t.jsx("span",{title:"How long it ran",children:Tl(Date.parse(m.ended_at)-Date.parse(m.created_at))}):"—"}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:m.cost&&(m.cost.usd!==null||vi(m.cost))?ua(m.cost,{ended:Co(m.status)}):"—"})]},m.run_id))})]}),!b.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(on,{problem:u,onRetry:f,className:""}),v&&t.jsx(W,{size:"sm",onClick:v,disabled:l,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(W,{size:"sm",onClick:h,disabled:l,children:d?"Loading":"Load more"})})]})}function z6({agent:e}){const n=e.definition.workflow,s=g.useMemo(()=>$l(n),[n]),r=g.useMemo(()=>({meta:Xd(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:[Rh(ey(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(Ut,{label:"Edit workflow",prompt:ga(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(ou,{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(au,{})})]})}function G_({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 F6=100,U6=4,mN=(e,n)=>(e==null?void 0:e.filter(s=>n(s.status)).length)??0,K_=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,tb=e=>e.toLocaleString("en-US"),V_=[{label:"Corrections",of:e=>e.view?{value:Dv(e.view.corrections).length,exact:!0}:null},{label:"Workflow drafts",of:e=>e.view?{value:mN(e.view.workflows,_h),exact:!0}:null},{label:"Pending review",of:e=>e.view?{value:mN(e.view.workflows,n=>n==="pending"),exact:!0}:null},{label:"In progress",of:e=>e.view?{value:e.view.counts.in_progress,exact:!0}:null}];function Y_(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${tb(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 W6({v2:e,server:n,modelAccess:s}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(!1),[f,h]=g.useState(null),v=g.useRef(0),b=g.useRef(!1),m=g.useCallback(async()=>{if(n!=="on"&&n!=="off"||b.current)return;b.current=!0;const N=++v.current;u(!0),l(null),o(E=>(E==null?void 0:E.map($=>$.view?{...$,stale:!0}:$))??null);const S=()=>v.current===N;try{let E=null;const $=new Set,L=await Kr(async M=>{if(!S())throw new Error("Read superseded");if(M&&$.has(M))throw new Error("The agent list repeated a page. Refresh to try again.");M&&$.add(M);const F=await e.listAgents({cursor:M});return E=F.next_cursor,F},M=>M.agents,F6);if(!S())return;if(E)throw new Error("The agent list is too large to read in one view. Open Connected agents to inspect an agent.");const A=[...new Map(L.map(M=>[M.agent_id,M])).values()].map(M=>({agent:M}));o(M=>{const F=new Map(M==null?void 0:M.map(I=>[I.agent.agent_id,I]));return A.map(({agent:I})=>{const V=F.get(I.agent_id);return I.kind==="agentic"&&(V==null?void 0:V.agent.kind)==="agentic"&&V.view?{...V,agent:I,stale:!0,error:void 0,unavailable:void 0}:{agent:I}})});const P=A.filter(M=>M.agent.kind==="agentic");let O=0;const T=async()=>{for(;S()&&O<P.length;){const{agent:M}=P[O++];let F;try{const I=await e.agentLearning(M.agent_id);if(!S())return;F={agent:M,view:I}}catch(I){F={agent:M,error:Yt(I,"Learning"),unavailable:I instanceof Ue&&I.status===404}}if(!S())return;o(I=>(I==null?void 0:I.map(V=>V.agent.agent_id!==M.agent_id?V:F.error&&!F.unavailable&&V.view?{...V,...F,stale:!0}:F))??null)}};await Promise.all(Array.from({length:Math.min(U6,P.length)},T)),S()&&h(new Date().toISOString())}catch(E){S()&&l(Yt(E,"Learning Dojo"))}finally{S()&&(b.current=!1,u(!1))}},[e,n]);g.useEffect(()=>{o(null),h(null),l(null),m();const N=()=>{document.hidden||m()};return window.addEventListener("focus",N),document.addEventListener("visibilitychange",N),()=>{v.current++,b.current=!1,window.removeEventListener("focus",N),document.removeEventListener("visibilitychange",N)}},[m]),g.useEffect(()=>{if(n!=="on"&&n!=="off")return;const N=window.setInterval(()=>{document.hidden||m()},15e3);return()=>window.clearInterval(N)},[n,m]);const x=(r==null?void 0:r.filter(N=>N.agent.kind==="agentic"))??[],y=x.filter(N=>N.view).length,j=x.filter(N=>{var S,E;return!cr(N.agent.definition)&&!N.stale&&((E=(S=N.view)==null?void 0:S.learning_model)==null?void 0:E.location)==="server"&&!N.view.learning_model.ready}),k=x.some(N=>N.stale),C=x.flatMap(N=>{var S;return(((S=N.view)==null?void 0:S.log.items)??[]).map(E=>({agent:N.agent,change:E}))}).sort((N,S)=>S.change.at.localeCompare(N.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:ee(Lr,"gap-2 px-5"),children:[t.jsxs("h1",{className:ha,children:[t.jsx(G_,{size:16,className:"shrink-0"}),"Learning Dojo"]}),t.jsx(W,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:d||!n,onClick:()=>void m(),children:t.jsx(pi,{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 corrections and workflow drafts your current agents keep for later runs. Open an agent to enable learning, inspect its changes or review pending drafts."}),t.jsx("p",{className:"mt-2 max-w-3xl text-small leading-relaxed text-muted-foreground",children:"Imported sessions are history, not learning runs. Workflow drafts come from agentic runs started through this server; corrections are yours, given with a grade or written on an agent's Learning tab."})]}),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."}),i&&t.jsxs(t.Fragment,{children:[t.jsx(on,{problem:i,onRetry:()=>void m(),className:""}),r&&t.jsx("p",{className:"text-small text-warning-text",children:"Showing the last read. Refresh to update these counts."})]}),!r&&!i?t.jsx(cs,{label:"Loading Learning Dojo",rows:4}):r&&t.jsxs(t.Fragment,{children:[n==="on"&&!r.length&&s&&t.jsx(P_,{access:s,scope:"default"}),n==="on"&&j.length>0&&t.jsxs(ct,{tone:"warning",title:`${j.length} ${j.length===1?"agent needs":"agents need"} model access`,children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1",children:"Workflow drafting uses a model on this server and has separate model usage. Set up access for the models listed below. Your connected agents keep their own model and tool credentials."}),t.jsx("a",{className:Fs({variant:"primary",size:"sm"}),href:"#/settings/keys",children:"Set up model access"})]}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"Settings → API Keys → Model keys. Tool API keys and AgentRun connection keys do not provide model access."})]}),t.jsx("dl",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:V_.map(({label:N,of:S})=>t.jsxs("div",{"aria-label":N,className:"border bg-card p-4",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:N}),t.jsx("dd",{className:"mt-3 font-mono text-display",children:Y_(x,S)})]},N))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[y," of ",x.length," agent histories read. Counts show active drafts; drafts that wait for your OK are counted under review. + means a minimum from incomplete data; — means not reported.",k?" Last-read totals include saved histories that may have changed; they are not current minimums.":f&&!d?` Updated ${ht(f)}.`:"",d?" Loading learning…":""]}),r.length?t.jsx("section",{"aria-label":"Agents in Dojo",className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:r.map(N=>t.jsx(H6,{row:N,server:n},N.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"})]}),x.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."})]}),C.length?t.jsx("ul",{className:"divide-y",children:C.map(({agent:N,change:S})=>t.jsx("li",{children:t.jsxs("a",{href:"run"in S.by?`#/runs/${encodeURIComponent(S.by.run)}`:K_(N),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:S.reason||"Learning updated"}),t.jsxs("span",{className:"mt-1 block text-small text-muted-foreground",children:[N.definition.name||N.agent_id," · ","run"in S.by?"From a run":"Edited by you"," · ",ht(S.at)]})]}),t.jsx(So,{className:"mt-1 size-3.5 shrink-0","aria-hidden":!0})]})},`${N.agent_id}:${S.commit}`))}):t.jsx("p",{className:"px-5 py-7 text-lead text-muted-foreground",children:d?"Loading learning changes…":y<x.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function H6({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=cr(s.definition),l=s.kind==="agentic",d=xa(s.definition.learning),u=r==null?void 0:r.learning_model,f=l&&!i&&(u==null?void 0:u.location)==="server"&&!u.ready,h=f&&d&&n==="on";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:h?"warning":l&&d&&n==="on"?"success":"plain",children:l?n==="off"&&d?"Paused by server":h?e.stale?"Model setup (last read)":"Needs model access":d?"Learning on":"Learning off":"Workflow"})]}),f&&t.jsxs("div",{className:"mt-4 space-y-2 text-small",role:"status",children:[t.jsxs("p",{className:"text-warning-text",children:[e.stale?"Last read: ":"",u.needs==="model"?"Choose a model for learning.":"Model access is required for workflow drafting."]}),u.model&&t.jsxs("p",{className:"text-muted-foreground",children:["Learning model: ",t.jsx("span",{className:"break-all font-mono",children:u.model})]}),u.reason&&t.jsx("p",{className:"text-muted-foreground",children:u.reason}),t.jsx("a",{className:Fs({variant:"outline",size:"xs"}),href:"#/settings/keys",children:"Set up model access"})]}),i&&t.jsxs("p",{className:"mt-3 text-small text-muted-foreground",children:["Shared project learning · ",pa(i.runtime),". Sessions in this project share these settings and owner corrections."]}),l?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:V_.map(({label:v,of:b})=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:v}),t.jsx("dd",{className:"mt-1 font-mono text-lead",children:Y_([e],b)})]},v))}),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:[tb(r.counts.merged)," runs kept learning · ",tb(Object.values(r.counts.dropped).reduce((v,b)=>v+b,0))," kept nothing"]})]}):!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:l?K_(s):jn(s.agent_id),children:[l?"Open learning":"View agent",t.jsx(So,{className:"size-3.5","aria-hidden":!0})]})]})}const B6=140,q6=32,G6=40,K6=60;function sy({value:e,name:n,note:s,blurb:r,description:o,tag:i,why:l,alert:d,on:u,disabled:f,warn:h,onToggle:v}){const[b,m]=g.useState(!1),x=g.useRef(null),y=g.useRef(null),j=g.useRef(null),k=g.useRef(null),C=If(x,"width",b,n),N=If(y,"height",b,o),S=If(j,"width",b,i),E=If(k,"width",b,d),$=C??n.length>q6,L=!!o&&(N??o.length>B6),A=!!i&&(S??i.length>G6),P=!!d&&(E??d.length>K6),O=!!l&&(l!==i||A),T=!!o&&(!!r||L)||O||P||$,M=(I,V)=>!b&&I&&V?I:void 0,F=I=>{I.preventDefault(),I.stopPropagation(),m(V=>!V)};return t.jsxs("label",{"data-tool-card":e,className:ee("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",b?"min-h-36":"h-36 overflow-hidden",u&&"border-foreground",h&&"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:v,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:x,title:M(n,$),className:ee("min-w-0",b?"[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&&!b?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:M(o,L),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:M(l,O),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!b&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:M(d,P),children:d}),b&&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}),l&&l!==o&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:l}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),T&&t.jsx("button",{type:"button",onClick:F,"aria-expanded":b,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:b?"Less":"More"})]})}function If(e,n,s,r){const[o,i]=g.useState(null);return g.useLayoutEffect(()=>{const l=e.current;if(s||!l)return;const d=()=>{(n==="width"?l.clientWidth>0:l.clientHeight>0)&&i(n==="width"?l.scrollWidth>l.clientWidth+1:l.scrollHeight>l.clientHeight+1)};d();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return u==null||u.observe(l),()=>u==null?void 0:u.disconnect()},[e,n,s,r]),o}function V6({servers:e,tools:n,harness:s,harnesses:r,filter:o,onChange:i,onRetry:l}){const d=x=>i(n.includes(x)?n.filter(y=>y!==x):[...n,x]),u=n.filter(x=>_o(x)),f=Q_(e,n,o),h=!r||r.includes(s),v=(x,y,j,k,C,N)=>{const S=n.includes(x),E=(!h||!!C)&&!S,$=k??C??(S&&!h?`Won't run on ${s}.`:void 0);return t.jsx("li",{className:"min-w-0",children:t.jsx(sy,{value:x,name:y,note:N,description:j,alert:$,on:S,disabled:E,warn:!!k,onToggle:()=>d(x)})},x)},b=x=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:x}),m=!h&&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`:"","."]});return e==="failed"?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."," ",l&&t.jsx(W,{type:"button",onClick:l,size:"xs",className:"ml-1",children:"Retry"})]}),f.failed.length>0&&b(f.failed.map(x=>v(x,x,"Can't check right now whether its server still lists it.")))]}):e?!e.length&&!C_(n,e).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:[m,f.servers.map(({s:x,kept:y})=>t.jsxs("section",{"aria-label":`MCP server ${x.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[x.name," · MCP server"]}),b(y.map(j=>{var k;return v(S_(x.name,j.name),j.name,[j.title,j.description].filter(Boolean).join(": ")||void 0,void 0,Wz(j,s)??(j.permission==="deny"?ny:void 0),(k=x.not_metered)!=null&&k.includes(j.name)?"not metered":void 0)}))]},x.name)),f.stale.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"}),b(f.stale.map(x=>v(x.grant,x.grant,void 0,x.why)))]})]}):u.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null}function Q_(e,n,s){return e==="failed"?{failed:n.filter(r=>_o(r)&&Us(s,r)),servers:[],stale:[]}:e?{failed:[],servers:e.map(r=>({s:r,kept:r.tools.filter(o=>Us(s,r.name,o.name,o.title,o.description))})).filter(({kept:r})=>r.length||!s.trim()),stale:C_(n,e).filter(r=>Us(s,r.grant))}:{failed:[],servers:[],stale:[]}}function Y6(e,n,s){const r=Q_(e,n,s);return r.failed.length+r.servers.reduce((o,{kept:i})=>o+i.length,0)+r.stale.length}const Q6="[a-z][a-z0-9-]{0,31}",J_="[A-Za-z0-9_-]{1,64}",J6="[a-z0-9][a-z0-9.-]{0,63}",X6="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",Z6=`[a-z][a-z0-9_-]{0,63}(?:\\.${J_})?`,e8="mcp:",t8="monid:",hN="*",n8=new RegExp(`^mcp:(${Q6})/(\\*|${J_})$`),s8=new RegExp(`^monid:(${J6})/(\\*|${X6})$`),r8=new RegExp(`^${Z6}$`);function o8(e){if(Ol(e)){const s=s8.exec(e);return s?s[2]===hN?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!i8(e))return r8.test(e)?{kind:"plain",name:e}:void 0;const n=n8.exec(e);if(n)return n[2]===hN?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const Ol=e=>e.startsWith(t8),a8=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.`,i8=e=>e.startsWith(e8);function X_(e){const n=o8(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 l8=e=>X_(e)?void 0:a8(e);function c8(e){const n=e.trim();return!n||Ol(n)?n:`monid:${n}`}function Z_(e){return new Map(e.flatMap((n,s)=>Ol(n)?[[`definition.tools[${s}]`,n]]:[]))}function d8(e,n){const s=Z_(n),r=[],o=[];for(const i of e){const l=s.get(i.field);l?r.push({grant:l,warning:i}):o.push(i)}return{monid:r,rest:o}}const e$=e=>{const n=X_(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."},t$=(e,n,s)=>[...new Set([...n,...e].filter(Ol))].filter(r=>Us(s,r,e$(r)));function u8({tools:e,listed:n=[],filter:s,notes:r=[],refused:o=[],onChange:i}){const[l,d]=g.useState(""),[u,f]=g.useState(void 0),h=t$(e,n,s),v=m=>i(e.includes(m)?e.filter(x=>x!==m):[...e,m]),b=()=>{const m=c8(l);if(!m)return;const x=l8(m);f(x),!x&&(d(""),e.includes(m)||i([...e,m]))};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"}),h.length>0&&t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h.map(m=>{const x=o.filter(y=>y.grant===m);return t.jsx("li",{className:"min-w-0",children:t.jsx(sy,{value:m,name:m,description:e$(m),alert:x.length?"The save was refused here: see below.":void 0,warn:x.length>0,on:e.includes(m),disabled:!1,onToggle:()=>v(m)})},m)})}),t.jsxs("form",{className:"flex max-w-3xl flex-wrap items-start gap-2",onSubmit:m=>{m.preventDefault(),b()},children:[t.jsx(Fe,{"aria-label":"monid grant",value:l,onChange:m=>{d(m.target.value),f(void 0)},"aria-invalid":u?!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(W,{type:"submit",size:"sm",className:"h-control-md",disabled:!l.trim(),children:[t.jsx(Qm,{"aria-hidden":!0})," Grant"]})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u}),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 → API Keys."}),o.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:o.map((m,x)=>t.jsx("li",{children:m.message},`${m.grant}:${x}`))}),r.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:r.map((m,x)=>t.jsx("li",{children:m.message},`${m.grant}:${x}`))})]})}const f8=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),m8=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function h8(e,n){var o;if(e.kind==="none")return sb({kind:"none"},n,e);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 sb(r?{kind:e.kind,provider:r}:{kind:e.kind},n,e)}const p8=["image","persistent","gpu","surface","exec","record"],g8=(e,n)=>n!==void 0&&n!==(e==="exec"),pN={image:"The image",persistent:"Keeping the computer between runs",gpu:"The GPU",surface:"The way the agent drives it",exec:"The no-shell setting",record:"Recording"};function nb(e,n,s,r){var i;const o=l=>`${pN[e]} is off: ${l}.`;if(!s)return o("this server doesn't list that kind");if(e==="record")return s.record.available?void 0:o(s.record.why??"this server can't record it");if(s.kind==="none")return o("with no computer, there is nothing to hold it");if(!s.settings.includes(e))return o(`a ${s.kind} doesn't take it`);if(!(e==="surface"||e==="exec")){if(!r)return o("this kind has no ready provider");if(e==="gpu"){const l=n;return r.gpu?r.gpu.why?`${pN[e]} is off: ${r.gpu.why}`:r.gpu.types.includes(l.type)?l.count<=r.gpu.max?void 0:o(`${r.name} gives at most ${r.gpu.max} per computer`):o(`${r.name} has no ${l.type}`):o(`${r.name} has no GPUs`)}return e==="image"?(i=r.images)!=null&&i.includes(n)?void 0:o(`${r.name} does not offer "${n}" for a ${s.kind}`):r.persistent?void 0:o(`${r.name}'s ${s.kind} keeps no computer between runs`)}}function sb(e,n,s){const r=s==null?void 0:s.providers.find(l=>l.id===e.provider),o={},i={};for(const l of p8){const d=n==null?void 0:n[l];g8(l,d)&&((nb(l,d,s,r)?i:o)[l]=d)}return{computer:{...e,...o},dropped:i}}function x8(e,n){const{record:s,...r}=e;return n?{...r,record:!0}:r}const b8=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},ry="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",oy=new Set(["sandbox","desktop","phone"]),v8=e=>e.charAt(0).toUpperCase()+e.slice(1);function y8({kinds:e,value:n,onChange:s,error:r,warning:o}){const i=e.find(v=>v.kind===n.kind),[l,d]=g.useState({}),u=(v,b)=>{const m={...l,...b.dropped},x=v.providers.find(y=>y.id===b.computer.provider);d(Object.fromEntries(Object.entries(m).filter(([y,j])=>nb(y,j,v,x)))),s(b.computer)},f=v=>u(v,h8(v,n)),h=Object.entries(l).flatMap(([v,b])=>nb(v,b,i,i==null?void 0:i.providers.find(m=>m.id===n.provider))??[]);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(v=>{const b=f8(v),m=b?void 0:m8(v),x=v.providers.filter(y=>y.ready).map(y=>y.name).join(", ");return t.jsxs("div",{"data-kind":v.kind,className:ee("border px-4 py-3",n.kind===v.kind?"border-foreground":"border-border",!b&&"opacity-60"),children:[t.jsxs("label",{className:ee("flex items-start gap-3",b?"cursor-pointer":"cursor-not-allowed"),children:[t.jsx("input",{type:"radio",name:"computer-kind",value:v.kind,checked:n.kind===v.kind,disabled:!b&&n.kind!==v.kind,onChange:()=>f(v),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-lead font-semibold",children:v8(v.kind)}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:b?v.kind==="none"?"The run's folder only":x:"Not available here"})]})]}),m&&t.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[m," ",t.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]}),n.kind===v.kind&&h.map(y=>t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:y},y))]},v.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(v=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:ee("flex items-start gap-3 px-4 py-2.5",v.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"computer-provider",value:v.id,checked:n.provider===v.id,disabled:!v.ready&&n.provider!==v.id,onChange:()=>u(i,sb({kind:i.kind,provider:v.id},n,i)),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:v.name}),v.metered&&t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),v.metered&&oy.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:ry}),!v.ready&&v.why&&t.jsx("span",{className:"mt-0.5 block text-small",children:v.why})]})]})},v.id))})]}),i&&i.kind!=="none"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Recording"}),t.jsxs("div",{className:"border px-4 py-3","aria-label":"Recording",children:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("p",{id:"computer-record",className:"min-w-0 flex-1 text-body font-semibold",children:"Record a video of each run"}),t.jsx(xi,{labelledBy:"computer-record",checked:n.record===!0,disabled:!i.record.available&&n.record!==!0,onChange:v=>s(x8(n,v))})]}),!i.record.available&&t.jsxs("p",{className:"mt-1 text-small",role:"note",children:["Recording isn't possible here: ",i.record.why??"this server can't record it","."]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"It records everything on the screen, including what a person types after taking over and any password shown. Pixels can't be redacted."})]})]}),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 w8({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:l,warning:d}){var S;const u=e??Zd(n),f=(u??Ev(!1,o,s)).mode,h=(S=s.boxes.find(E=>E.available))==null?void 0:S.id,v=(u==null?void 0:u.mode)==="sandbox"?u.box:h,b=!h&&f!=="sandbox",m=new Set(r.filter(E=>E.sandbox_only).map(E=>E.name)),[x,y]=g.useState([]),j=()=>{const E=o.filter($=>m.has($));y(E),i({place:{mode:"runner"},...E.length?{tools:o.filter($=>!m.has($))}:{}})},k=E=>{y([]),E&&i({place:{mode:"sandbox",box:E}})},C=E=>E.map($=>$.charAt(0).toUpperCase()+$.slice(1)).join(" and "),N=(E,$,L,A,P=!1)=>t.jsxs("label",{className:ee("flex items-start gap-3 border px-4 py-3",f===E?"border-foreground":"border-border",P?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:E,checked:f===E,disabled:P,onChange:A,className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-lead font-semibold",children:$}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:L})]})]});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:[N("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),N("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(v),b)]}),b&&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(E=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:E.id}),E.reason?`: ${E.reason}`:""]},E.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map(E=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:ee("flex items-start gap-3 px-4 py-2.5",E.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:E.id,checked:v===E.id,disabled:!E.available&&v!==E.id,onChange:()=>k(E.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:E.id}),!E.available&&E.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:E.reason})]})]})},E.id))}),f==="runner"&&x.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[C(x)," ",x.length===1?"runs":"run"," only in a sandbox, so ",x.length===1?"it's":"they're"," turned off for this agent."]}),l&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:l}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function n$(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),l=n.find(d=>d.name===o);return{name:o,...i?{choice:i}:{},...l?{gate:l}:{}}})}function rb({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:A6}):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,":"]})," ",T6(e.pin),". ",R6,s?" This server pins it too; both hold.":""]}):null}const gN={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."]},j8=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(ke,{tone:gN[e][0],title:gN[e][1],children:e})}),k8="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function ay({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:o=C=>C.default_permission,resolvesOf:i,issues:l,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:h=!1,noteOf:v,labelOf:b,detailOf:m,effectOf:x,confirmAllowOf:y=()=>!1,fallbackWordOf:j,onEdit:k}){const[C,N]=g.useState(null),S=g.useRef(null),E=g.useRef(null);g.useEffect(()=>{var F,I;if(C!==null||d||S.current===null)return;const M=`${S.current} permission`;S.current=null,(I=[...((F=E.current)==null?void 0:F.querySelectorAll("button[aria-label]"))??[]].find(V=>V.getAttribute("aria-label")===M))==null||I.focus()},[C,d]);const $=M=>{S.current=M,N(null)},L=n.some(M=>M.choice),A=n.some(M=>M.gate),P=n.some(M=>{var F;return((F=M.gate)==null?void 0:F.ask_needs)==="password"}),O=["Tool",...A?["Permission"]:[],...L?["Provider","Resolves to"]:[]],T=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[P&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:k8}),t.jsx("div",{ref:E,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:[O.map(M=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:M},M)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:M,choice:F,gate:I})=>{var ye,pe,Pe;const V=F?r(F):"",G=(ye=s[M])==null?void 0:ye.provider,q=F!==void 0&&G!==void 0&&G!==V,H=q?G:V,U=ue=>k(ge=>S6(ge,M,ue,V)),Q=I?o(I):"allow",D=(pe=s[M])==null?void 0:pe.permission,Y=I!==void 0&&D!==void 0&&D!==Q,K=Y?D:Q,Z=I!==void 0&&u(M,K),se=Z&&f,ie=se?"deny":K,Ne=ue=>k(ge=>C6(ge,M,ue,Q)),he=x==null?void 0:x(M),ve=(j==null?void 0:j(M))??"default",Ee=m==null?void 0:m(M);return t.jsxs(g.Fragment,{children:[t.jsxs("tr",{"data-tool":M,"data-set":q||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:[(b==null?void 0:b(M))??M,he&&t.jsx(j8,{effect:he})]}),Ee?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:Ee}):null]}),A&&t.jsx("td",{className:"px-3 py-2",children:I?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{small:!0,label:`${M} permission`,value:ie,disabled:d||se,onChange:ue=>{const ge=ue;ge==="allow"&&ge!==ie&&y(M)?N(M):Ne(ge)},className:ee("w-48",Y&&"border-primary text-primary"),options:I.permissions.map(ue=>({value:ue,label:`${ue}${ue===Q?` (${ve})`:""}`,...ue==="ask"&&I.ask_needs==="password"&&!h?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),Y&&!se&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Q,ve==="default"?"":` (${ve})`]}),Z&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ny}),ie==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:w6}),ie==="ask"&&h&&!Z&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),ie==="ask"&&I.ask_needs==="password"&&!h&&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."})]}):T}),L&&t.jsx("td",{className:"px-3 py-2",children:F?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{small:!0,label:`${M} provider`,value:H,disabled:d,onChange:ue=>U(ue),className:ee("w-96 max-w-full",q&&"border-primary text-primary"),options:F.providers.map(ue=>({value:ue,label:`${Cm(ue,M)}${ue===V?" (default)":""}`}))}),fN(H,M)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:fN(H,M)}),q&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Cm(V,M)]})]}):T}),L&&t.jsx("td",{className:"px-3 py-2.5",children:F?i(F,H):T}),t.jsx("td",{className:"px-2 py-2 text-right",children:q&&t.jsx(W,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${M} to its default`,onClick:()=>U(void 0),children:"Reset"})})]}),C===M&&t.jsx("tr",{children:t.jsx("td",{colSpan:O.length+1,className:"px-3 pb-2.5",children:t.jsx(N8,{name:M,keep:ie==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||($(M),Ne("allow"))},onKeep:()=>$(M)})})}),v!=null&&v(M)?t.jsx("tr",{"data-note":M,children:t.jsx("td",{colSpan:O.length+1,className:"px-3 pb-2.5",children:v(M)})}):null,(Pe=l[M])!=null&&Pe.length?t.jsx("tr",{children:t.jsx("td",{colSpan:O.length+1,className:"px-3 pb-2.5",children:l[M].map(ue=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:ue},ue))})}):null]},M)})})]})})]})}function N8({name:e,keep:n,busy:s,onAllow:r,onKeep:o}){const i=g.useRef(null);return g.useEffect(()=>{var l;(l=i.current)==null||l.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:l=>{l.key==="Escape"&&(l.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(W,{ref:i,type:"button",size:"sm",variant:"ghost",onClick:o,children:n}),t.jsx(W,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function ob({value:e,prefix:n,tool:s}){const r=H_(e,s);return t.jsxs("span",{className:ee("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const S8=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:x6.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(ob,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function C8({agent:e,harness:n,model:s,tools:r,choices:o,gates:i=[],mcpServers:l,serverSettings:d,focus:u,callTools:f,value:h,issues:v,unattended:b=!1,onChange:m}){const x=new Set(r),y=o.filter(T=>x.has(T.name)||!T.available),j=i.some(T=>T.ask_needs==="password"),k=T=>{var M;return(M=e==null?void 0:e.tools)==null?void 0:M.find(F=>F.name===T)},C=T=>{var F;const M=_o(T);return M?(F=l==null?void 0:l.find(I=>I.name===M.server))==null?void 0:F.tools.find(I=>I.name===M.tool):void 0},N=T=>{var F;const M=_o(T);return M?(F=h[`mcp:${M.server}/*`])==null?void 0:F.permission:void 0},S=f?f.flatMap(T=>i.filter(M=>M.name===T)):[...new Set(r)].flatMap(T=>{var I;const M=i.find(V=>V.name===T);if(M)return[M];const F=k(T)??C(T);return!((I=F==null?void 0:F.permissions)!=null&&I.length)||!F.default_permission?[]:[{name:T,permission:F.permission??F.default_permission,default_permission:F.default_permission,permissions:F.permissions,...j&&F.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),E=n$(y,S,[...i.map(T=>T.name),...o.map(T=>T.name)]),$=g.useRef(null);if(g.useEffect(()=>{var F,I;if(!u)return;const T=`${u} permission`,M=[...((F=$.current)==null?void 0:F.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(V=>V.getAttribute("aria-label")===T);(I=M==null?void 0:M.scrollIntoView)==null||I.call(M,{block:"center"}),M==null||M.focus()},[]),!E.length)return null;const L=(e==null?void 0:e.definition.tool_settings)??{},A=b!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:P,rest:O}=q_(v,"definition.tool_settings",E.map(T=>T.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.":b?"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(ay,{label:"This agent's tool settings",unattended:b,rows:E,settings:h,fallbackOf:T=>T.provider,issues:P,onEdit:T=>m(T(h)),effectOf:T=>{var M;return(M=C(T))==null?void 0:M.effect},confirmAllowOf:T=>{var M;return((M=C(T))==null?void 0:M.effect)==="destructive"},noteOf:T=>{const M=h[T],F=d==null?void 0:d[T],I=!!(M!=null&&M.pin||M!=null&&M.pin_broken);return!I&&!(F!=null&&F.pin)&&!(F!=null&&F.pin_broken)?null:t.jsxs(t.Fragment,{children:[I&&t.jsx(rb,{setting:M,label:"Pinned for this agent",also:!!(F!=null&&F.pin)}),(!I||(F==null?void 0:F.pin_broken))&&t.jsx(rb,{setting:F,label:"Pinned on this server"})]})},refused:T=>U_(T,i,e==null?void 0:e.tools,l),locked:!0,permissionFallbackOf:T=>{var M;return N(T.name)??((M=k(T.name))==null?void 0:M.default_permission)??T.permission},resolvesOf:T=>{var G,q,H,U,Q,D;const M=(((G=h[T.name])==null?void 0:G.provider)??null)!==(((q=L[T.name])==null?void 0:q.provider)??null)||(((H=h[T.name])==null?void 0:H.permission)??null)!==(((U=L[T.name])==null?void 0:U.permission)??null)||A,F=(Q=e==null?void 0:e.tools)==null?void 0:Q.find(Y=>Y.name===T.name),I=F&&F.provider===(((D=h[T.name])==null?void 0:D.provider)??T.provider)?F.resolved:void 0,V=(s??"")===((e==null?void 0:e.definition.model)??"");return!M&&n===((e==null?void 0:e.definition.harness)??"pi")&&V&&I?t.jsx(ob,{value:I,prefix:`${n}: `,tool:T.name}):!M&&!L[T.name]&&!s?t.jsx(ob,{value:T.resolves[n],prefix:`${n}: `,tool:T.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),O.map(T=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:T},T))]})}const Pf=20,_8=400;function $8(e,n,s,r,o){const[i,l]=g.useState(null),[d,u]=g.useState(0),f=(r??[]).join(",");g.useEffect(()=>{if(!o||!s||i==="unsupported")return;const v=new AbortController,b=setTimeout(()=>{o({workflow:n,...r?{tools:r}:{}},v.signal).then(m=>{v.signal.aborted||l({text:e,check:m})},m=>{v.signal.aborted||((m==null?void 0:m.status)===404||(m==null?void 0:m.status)===405?l("unsupported"):l({text:e,failed:(m==null?void 0:m.message)||`the server answered ${(m==null?void 0:m.status)??"nothing"}`}))})},_8);return()=>{clearTimeout(b),v.abort()}},[e,s,f,o,d]);const h=()=>{l(null),u(v=>v+1)};return i==="unsupported"||!o?{mode:"lint",retry:h}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:h}:{mode:"server",check:i.check,retry:h}:{mode:"pending",retry:h}}function xN({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:l,tools:d}){var V;const u=g.useRef(null),f=g.useRef(null),[h,v]=g.useState(0),b=g.useMemo(()=>MP(e),[e]),m=g.useRef(null);b.ok&&(m.current={value:b.value,spans:b.spans});const x=(V=m.current)==null?void 0:V.value,y=g.useMemo(()=>$l(x),[x]),j=g.useMemo(()=>s===void 0?null:$l(s),[s]),k=g.useMemo(()=>j?OC(j,y):null,[j,y]),C=$8(e,b.ok?b.value:void 0,b.ok,d,i?void 0:l),N=g.useMemo(()=>b.ok&&!i?zP(b.value):[],[b,i]),S=g.useMemo(()=>C.mode!=="server"?N:[...C.check.issues.map(G=>({path:G.path,message:G.message,severity:"error"})),...C.check.warnings.map(G=>typeof G=="string"?{path:"",message:G,severity:"warning"}:{path:G.path??"",message:G.message,severity:"warning"})],[C.mode,C.mode==="server"?C.check:null,N]),E=b.ok?FP(b.spans,y.nodes.map(G=>G.path),h):null,$=g.useMemo(()=>({meta:Xd(x,y),diff:k?{added:k.added.map(G=>G.path),edited:[...k.changed,...k.rewritten].map(G=>G.next),moved:k.moved.map(G=>G.next),removed:k.removed.map(({label:G,kind:q})=>({label:G,kind:q}))}:void 0,selected:E?{path:E}:null}),[x,y,k,E]),L=e.split(`
|
|
672
|
-
`).length,A=G=>IP(e,G),P=[];b.ok||P.push({...A(b.error.offset),message:`JSON: ${b.error.message}`,severity:"error",offset:b.error.offset});for(const G of S){const q=b.ok?T0(b.spans,G.path):void 0,H=(q==null?void 0:q.start)??0;P.push({...A(H),message:G.message,severity:G.severity,offset:H,path:G.path})}for(const G of[...o??[]].reverse()){const q=G.path&&b.ok?T0(b.spans,G.path):void 0;P.unshift({...q?A(q.start):{line:0,col:0},message:`Server: ${G.message}`,severity:"error",offset:(q==null?void 0:q.start)??-1})}const O=new Map;for(const G of P)G.line&&O.get(G.line)!=="error"&&O.set(G.line,G.severity);const T=(G,q=G)=>{const H=u.current;!H||G<0||(H.focus(),H.setSelectionRange(G,q),H.scrollTop=Math.max(0,(A(G).line-4)*Pf),v(G))};g.useEffect(()=>{const G=b.ok?b.spans.get("/root"):void 0;G&&u.current&&(u.current.scrollTop=Math.max(0,(A(G.start).line-2)*Pf))},[]);const M=k?k.edges.added.length+k.edges.removed.length:0,F=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+M:0,I=P.filter(G=>G.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:[L," 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:[C.mode==="failed"&&b.ok?t.jsxs("span",{className:"font-mono text-label text-warning-text",title:C.failed,children:["server check failed, showing local checks ",t.jsx(W,{type:"button",onClick:C.retry,size:"xs",className:"ml-1",children:"Retry"})]}):C.mode!=="lint"&&b.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:C.mode==="pending"?"checking...":"checked by the server"}),I?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(wl,{className:"size-3.5","aria-hidden":!0})," ",I," ",I===1?"problem":"problems"]}):t.jsx("span",{className:"caps text-label text-success-text",children:C.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:`${Pf}px`},children:Array.from({length:L},(G,q)=>t.jsx("div",{className:ee("pr-2",O.get(q+1)==="error"&&"bg-destructive/15 text-destructive-text",O.get(q+1)==="warning"&&"bg-warning/15 text-warning-text"),children:q+1},q))}),t.jsx(An,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:G=>{i||n(G.target.value),v(G.target.selectionStart)},onSelect:G=>v(G.target.selectionStart),onScroll:G=>{f.current&&(f.current.scrollTop=G.target.scrollTop)},onKeyDown:G=>{if(G.key!=="Tab"||i)return;G.preventDefault();const q=G.currentTarget,H=q.selectionStart,U=q.selectionEnd;n(`${e.slice(0,H)} ${e.slice(U)}`),requestAnimationFrame(()=>q.setSelectionRange(H+2,H+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:`${Pf}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:[P.length===0&&t.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:C.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."}),P.map((G,q)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>T(G.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[G.severity==="error"?t.jsx(wl,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Hs,{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:G.line?`L${G.line}:${G.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:G.message})]})},q))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Rh(ey(y))}),k&&(F?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&&M&&`${M} ${M===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"}),!b.ok&&m.current&&t.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),t.jsx("div",{className:ee("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]",!b.ok&&"opacity-60"),children:y.nodes.length?t.jsx(ou,{graph:y,marks:$,label:"The workflow's graph",minScale:.55,onSelect:G=>{const q=b.ok?b.spans.get(`${G.path}/label`)??b.spans.get(G.path):void 0;q&&T(q.start,q.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(au,{})})]})]})}const rx="custom";function s$(){const[e,n]=g.useState(!1),[s,r]=g.useState(!1);return{customPicked:e,setCustomPicked:n,freeOnly:s,setFreeOnly:r}}function r$({id:e,harness:n,model:s,onModel:r,harnesses:o,routePrefix:i,state:l,error:d,warning:u}){const{customPicked:f,setCustomPicked:h,freeOnly:v,setFreeOnly:b}=l,m=E=>E&&E.harness===n&&E.model===s?E.text:void 0,x=Vv(n,o),y=x?Al(x,i):void 0,j=Yz(n,o),k=f||s!==void 0&&!j.includes(s),C=__(n,o),N=v&&C.size?j.filter(E=>C.has(E)||E===s):j,S=[{value:"",label:y?`Server default (${y.text})`:"Server default"},...N.map(E=>({value:E,label:Al(E,i).text,...C.has(E)?{tag:`Free · ${Vz(C.get(E).context_window)} context`}:{}})),{value:rx,label:"Custom..."}];return t.jsxs(gt,{label:"Model",id:e,optional:!0,note:y?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:y.title,children:y.text}),")."]}):Qz,error:m(d),warning:m(u),children:[t.jsx(Ft,{id:e,label:"Model",className:"w-full",value:k?rx:s??"",options:S,onChange:E=>{if(E===rx){h(!0);return}h(!1),r(E||void 0)}}),k&&t.jsx(Fe,{id:e?`${e}-custom`:void 0,"aria-label":"Custom model",className:"mt-2",value:s??"",onChange:E=>{h(!0),r(E.target.value||void 0)},placeholder:"provider/model"}),C.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(xi,{checked:v,onChange:b,label:"Free models only"})," Free models only (",C.size,"): $0 a request; the provider limits requests per day."]})]})}const E8="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function o$(){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:E8,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let ol=null;function Df(e,n){return ol?ol({to:e,replay:n}):!1}function a$(e){const[n,s]=g.useState(null),r=g.useRef(location.hash);return g.useEffect(()=>{if(!e)return;const o=l=>l.to===r.current?!1:(s(l),!0);ol=o;const i=l=>{l.preventDefault(),l.returnValue=""};return window.addEventListener("beforeunload",i),()=>{ol===o&&(ol=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(ol=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const i$="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",bN=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function T8(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 R8(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 A8=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:mi},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:va},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:hi},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:vx},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:X1},{id:"history",label:"History",note:"Revisions and the current one",Icon:Hd}];function O8({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,onArchive:i,onReload:l,onBack:d,step:u,problem:f=null,notice:h,draft:v,validate:b,providerChoices:m=[],permissionGates:x=[],focusTool:y,mcpServers:j=null,serverToolSettings:k,onRetryMcp:C}){var pn,Gn,tt,xt,Rt,gn,dn;const N=!e,S=e==null?void 0:e.definition,E=is(S),$=cr(S),L=!!(S!=null&&S.native)||!!E||!!$,[A,P]=g.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),O=N?Jg(s.places):void 0,[T,M]=g.useState({name:(S==null?void 0:S.name)??"",description:(S==null?void 0:S.description)??"",instructions:(S==null?void 0:S.instructions)??(N?fD:""),harness:(S==null?void 0:S.harness)??"pi",thinking:S==null?void 0:S.thinking,model:S==null?void 0:S.model,tools:N?Xg("pi",s.tools,O):(S==null?void 0:S.tools)??[],maxCostText:typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0?String(S.max_cost_usd):"",...O?{place:O}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:v??JSON.stringify(S.workflow,null,2)}:{}}),F=s$(),I=g.useRef(T);I.current=T;const[V,G]=g.useState(T),q=re=>{const{maxCostText:Me,workflowText:bt,...Tt}=re,Bt=M0(Me),On=bN(bt),Ln={...Tt,maxCost:Bt.ok?Bt.value??0:Me,...bt!==void 0?{workflowSent:On!==void 0?On:bt}:{}},Ge=e?{...Gl(e,Ln,"").definition}:{...Ln};return delete Ge.version,Ge.tool_settings&&!Object.keys(Ge.tool_settings).length&&delete Ge.tool_settings,{...Ge,tools:[...Ge.tools??[]].sort(),approvals:re.approvals??(S==null?void 0:S.approvals)??"ask"}},H=!gl(q(T),q(V)),[U,Q]=g.useState([]),[D,Y]=g.useState(!1),[K,Z]=g.useState(""),se=s.tools.map(re=>`${re.name}:${re.available}:${(re.harnesses??[]).join("+")}`).join(","),ie=JSON.stringify(Jg(s.places)??null);g.useEffect(()=>{if(!N)return;const re=Me=>{const bt=Me.place??Jg(s.places);return{...Me,...bt?{place:bt}:{},...D?{}:{tools:Xg(Me.harness??"pi",s.tools,bt)}}};M(re),G(re)},[se,ie]);const[Ne,he]=g.useState(""),[ve,Ee]=g.useState(()=>((S==null?void 0:S.tools)??[]).filter(Ol)),[ye,pe]=g.useState(!1),[Pe,ue]=g.useState(!1),[ge,Te]=g.useState(f),[Xe,je]=g.useState(()=>({harness:T.harness??"pi",model:T.model})),[fe,De]=g.useState(null),te=re=>{De(null),P(re)},Ie=g.useRef(null),We=Z_(Ie.current??T.tools??[]),rt=(ge==null?void 0:ge.kind)==="invalid"?Object.entries(ge.fields).flatMap(([re,Me])=>{const bt=We.get(re);return bt?[{grant:bt,message:Me}]:[]}):[],ot=re=>(ge==null?void 0:ge.kind)==="invalid"&&Object.entries(ge.fields).filter(([Me])=>!We.has(Me)&&(Me===`definition.${re}`||Me.startsWith(`definition.${re}[`)||Me.startsWith(`definition.${re}.`))).map(([,Me])=>Me).join(" ")||void 0,{monid:wt,rest:jt}=d8((e==null?void 0:e.warnings)??[],(S==null?void 0:S.tools)??[]),we=re=>Kx(jt,re).map(Me=>Me.message).join(" ")||void 0,ze=re=>{N&&Pe||M(Me=>({...Me,...re}))},st=g.useRef(null);g.useEffect(()=>{var re;((ge==null?void 0:ge.kind)==="invalid"||(ge==null?void 0:ge.kind)==="other")&&((re=st.current)==null||re.focus())},[ge]);const xe=(e==null?void 0:e.kind)==="workflow",Be=N&&qx(T.harness),$t=s.tools.filter(re=>{var Me;return xe||!re.call_only||((Me=T.tools)==null?void 0:Me.includes(re.name))}),et=re=>$t.filter(Me=>Us(re,Me.name,Me.blurb,Me.summary)).length+(s.mcp&&!xe?Y6(j??null,T.tools??[],re):0)+(xe?0:t$(T.tools??[],ve,re).length),dt=[...(pn=T.name)!=null&&pn.trim()?[]:["Give the agent a name to create it."],...!xe&&!Be&&!((Gn=T.instructions)!=null&&Gn.trim())?["Write its instructions to create it."]:[]],Lt=T.approvals??(S==null?void 0:S.approvals)??"ask",qt=vD(s.harnesses,N?{available:!!s.decisionProvider}:void 0),At={mcpHarnesses:s.mcpHarnesses,workflow:xe},Et=re=>{if(re.mode==="sandbox")return;const Me=new Set(s.tools.filter(bt=>bt.sandbox_only).map(bt=>bt.name));Q(bt=>bt.filter(Tt=>!Me.has(Tt)))},B=re=>{if(N&&!D){ze({harness:re,tools:Xg(re,s.tools,T.place)}),Q([]);return}const Me=pD(re,T.tools??[],U,s.tools,At);ze({harness:re,tools:Me.tools}),Q(Me.held)},J=n.find(re=>re.revision===(e==null?void 0:e.revision))??n.find(re=>re.current),de=A8.filter(re=>!(N&&re.id==="history")&&(re.id!=="workflow"||xe)&&!(Be&&re.id==="tools")&&(re.id!=="computer"||!xe&&!Be&&!!(s.computers||s.places))),_e=de.some(re=>re.id===A)?A:de[0].id,at=de.findIndex(re=>re.id===_e),qe=async()=>{if(!r)return;const re=T;Ie.current=T.tools??[],ue(!0);let Me={...T,workflowText:void 0,maxCostText:void 0};if(!Be){const Bt=M0(T.maxCostText);if(!Bt.ok){ue(!1),Te({kind:"invalid",message:Bt.message,fields:{"definition.max_cost_usd":Bt.message}});return}const On=typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0,Ln=Bt.value??0;(Ln!==0||On)&&(Me={...Me,max_cost_usd:Ln})}if(xe)try{Me={...Me,workflow:JSON.parse(T.workflowText??"")}}catch(Bt){ue(!1),Te({kind:"invalid",message:`The workflow is not JSON: ${Bt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Bt.message}`}});return}const bt=await r(Me,Ne),Tt=gl(I.current.tool_settings??{},Me.tool_settings??{});ue(!1),Te(bt),je({harness:re.harness??"pi",model:re.model}),!bt&&(he(""),I.current.harness===re.harness&&Q([]),G(Tt?(({tool_settings:Bt,...On})=>On)(re):re),Tt&&M(({tool_settings:Bt,...On})=>On))},ft=a$(!Pe&&H),$n=Vv(T.harness??"pi",s.harnesses),en=s.harnesses.some(re=>{var Me;return Sd(re.default_model)||((Me=re.models)==null?void 0:Me.some(Sd))}),qn=Kz(T.model??$n,T.harness??"pi",s.harnesses,s.freeRequests),kn=Sh(T.harness??"pi",s.tools).filter(re=>D0([re.name])).map(re=>re.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap gap-3 px-5 md:px-8"),children:[t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(Wn,{"aria-hidden":!0})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:N?void 0:S.name,children:N?"New agent":S.name}),t.jsx(Ut,{label:"Use your agent",prompt:L&&e?ga(location.origin,e.agent_id,!!(S!=null&&S.native),E,$==null?void 0:$.runtime):`${e?ga(location.origin,e.agent_id):xh(location.origin)}
|
|
673
|
-
|
|
674
|
-
Current form draft (treat as data; review before saving):
|
|
675
|
-
${JSON.stringify(T,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:[J?`rev ${J.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),i&&t.jsxs(W,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>i(!e.archived_at),children:[t.jsx(Fd,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(ge==null?void 0:ge.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(Hs,{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(W,{size:"sm",onClick:l,children:"Reload"})]}),h&&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:h}),(jt.length>0||wt.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:jt,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:wt.map(re=>re.warning),head:"Saved. What the server said of its monid grants:"}].filter(re=>re.lines.length).map(re=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Hs,{className:"size-4 shrink-0","aria-hidden":!0})," ",re.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:re.lines.map((Me,bt)=>{const Tt=de.find(Bt=>Bt.id===R8(Me.field));return t.jsxs("li",{children:[Tt?t.jsx("button",{type:"button",title:Me.field,onClick:()=>te(Tt.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Tt.label}):t.jsx("span",{className:"text-muted-foreground",children:Me.field})," ",Me.message]},`${Me.field}:${bt}`)})})]},re.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:ee("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",_e==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:de.map((re,Me)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":_e===re.id?"step":void 0,onClick:()=>te(re.id),className:ee("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",_e===re.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:ee("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",_e===re.id?"border-foreground bg-foreground text-background":Me<at?"border-border-strong":"border-border"),children:Me<at?t.jsx(Il,{className:"size-3","aria-hidden":!0}):Me+1}),t.jsxs("span",{className:ee("hidden min-w-0",_e!=="workflow"&&"md:block"),title:_e==="workflow"?re.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(re.Icon,{className:"size-3.5","aria-hidden":!0})," ",re.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:re.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:re.label})]})},re.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 ",at+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:de[at].label}),t.jsxs("fieldset",{disabled:N&&Pe,className:"m-0 min-w-0 border-0 p-0",children:[_e==="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(gt,{label:"Name",id:"agent-name",required:N,note:N?void 0:"Set when the agent was created; an edit keeps it.",error:ot("name"),warning:we("name"),children:t.jsx(Fe,{id:"agent-name",value:T.name,readOnly:!N,onChange:re=>ze({name:re.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(gt,{label:"Description",id:"agent-description",optional:!0,error:ot("description"),warning:we("description"),children:t.jsx(Fe,{id:"agent-description",value:T.description,onChange:re=>ze({description:re.target.value}),placeholder:"Short summary for the agent list"})})]}),Be?t.jsx(gt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:T.harness===_v?"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."})}):xe?t.jsx(gt,{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:we("workflow"),children:t.jsxs(W,{size:"sm",onClick:()=>P("workflow"),children:[t.jsx(va,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(gt,{group:ye?"heading":void 0,label:"Instructions",id:ye?void 0:"agent-instructions",required:!0,error:ot("instructions"),warning:we("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(re=>t.jsx(W,{size:"xs",type:"button",onClick:()=>pe(re==="Preview"),className:ee("caps border px-2.5 py-1 text-label",re==="Preview"===ye?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:re},re))}),children:[ye?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:Yr(T.instructions||"")}}):t.jsx(An,{id:"agent-instructions",value:T.instructions,onChange:re=>ze({instructions:re.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ee(L8,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(T.instructions??"").length," characters"]})]})]}),_e==="workflow"&&t.jsx(xN,{text:T.workflowText??"",onText:re=>ze({workflowText:re}),base:xe?S.workflow:void 0,baseLabel:J?`rev ${J.version}`:void 0,validate:b,tools:T.tools,serverIssues:T8(ge,xe)}),_e==="computer"&&!xe&&!Be&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(y8,{kinds:s.computers,value:T.computer??(S==null?void 0:S.computer)??Bx(T.place??{mode:"runner"}),onChange:re=>{const Me=b8(re),bt=new Set(s.tools.filter(Tt=>Tt.sandbox_only).map(Tt=>Tt.name));ze({computer:re,place:Me,...Me.mode==="runner"?{tools:(T.tools??[]).filter(Tt=>!bt.has(Tt))}:{}}),Et(Me)},error:ot("computer")??ot("place"),warning:we("computer")??we("place")})}),_e==="computer"&&!xe&&!Be&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(w8,{value:T.place,saved:S==null?void 0:S.place,places:s.places,tools:s.tools,picked:T.tools??[],onChange:re=>{ze({...re,...re.place?{computer:Bx(re.place)}:{}}),re.place&&Et(re.place)},error:ot("computer")??ot("place"),warning:we("computer")??we("place")})}),_e==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(gt,{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:ot("tools"),warning:we("tools"),children:[t.jsx(cu,{value:K,onChange:Z,label:"Filter tools",placeholder:"Filter by name or description",shown:et(K),total:et(""),className:"mb-3"}),K.trim()&&!et(K)&&t.jsxs("p",{className:"mb-3 font-mono text-body text-muted-foreground",children:["No tool matches “",K.trim(),"”."]}),t.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[$t.filter(re=>Us(K,re.name,re.blurb,re.summary)).map(re=>{var Re,Ye;const Me=Gx(T.harness??"pi",re.name,s.tools,At),bt=((Re=T.tools)==null?void 0:Re.includes(re.name))??!1,Tt=m.find(Mt=>Mt.name===re.name),Bt=(Ye=(T.tool_settings??(S==null?void 0:S.tool_settings)??{})[re.name])==null?void 0:Ye.provider,On=!!Tt&&Bt!==void 0&&Bt!==Tt.provider,Ln=gD(re,T.place??Zd(S==null?void 0:S.place)??Ev(xe,[...T.tools??[],re.name],s.places)),Ge=U_(re.name,x,e==null?void 0:e.tools)?ny:re.call_only&&!xe?"Workflow-only: a workflow's call node runs it, not an agent":Me?Ln??(!re.available&&!On?(Tt==null?void 0:Tt.reason)??re.reason??`Needs ${(re.missing??[]).join(", ")}`:void 0):P0(T.harness??"pi",re.name,s.tools),oe=Ge?re.call_only&&!xe?"Workflow only":Ln&&Me&&Ge===Ln?"Sandbox-only":Ge:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(sy,{value:re.name,name:re.name,blurb:re.blurb,description:re.summary,why:Ge,tag:oe,on:bt,disabled:!!Ge&&!bt,onToggle:()=>{Y(!0),ze({tools:bt?T.tools.filter(Mt=>Mt!==re.name):[...T.tools??[],re.name]})}})},re.name)}),s.mcp&&!xe&&t.jsx("li",{className:"col-span-full",children:t.jsx(V6,{servers:j,tools:T.tools??[],harness:T.harness??"pi",harnesses:s.mcpHarnesses,filter:K,onRetry:C,onChange:re=>{Y(!0),ze({tools:re})}})}),!xe&&t.jsx("li",{className:"col-span-full",children:t.jsx(u8,{tools:T.tools??[],listed:ve,filter:K,notes:wt.map(({grant:re,warning:Me})=>({grant:re,message:Me.message})),refused:rt,onChange:re=>{Ee(Me=>[...new Set([...Me,...re.filter(Ol)])]),Y(!0),ze({tools:re})}})})]}),!xe&&!D0(T.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",kn.length?`tick ${kn.join(" or ")} in Tools.`:`${T.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(C8,{agent:e,unattended:!xe&&Lt==="never",harness:T.harness??"pi",model:T.model,tools:T.tools??[],choices:xe?[]:m,gates:x,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:y,callTools:xe?b6(bN(T.workflowText)??(S==null?void 0:S.workflow)):void 0,value:T.tool_settings??(S==null?void 0:S.tool_settings)??{},issues:(ge==null?void 0:ge.kind)==="invalid"?ge.fields:{},onChange:re=>!Pe&&gl(re,(S==null?void 0:S.tool_settings)??{})?M(({tool_settings:Me,...bt})=>bt):ze({tool_settings:re})}),!xe&&!Be&&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(([re,Me,bt])=>t.jsxs("label",{className:ee("flex items-start gap-3 border px-3 py-2.5",Lt===re&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:re,className:"mt-1 accent-primary",checked:Lt===re,disabled:Pe,onChange:()=>ze({approvals:re})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Me}),t.jsx("span",{className:"block text-small text-muted-foreground",children:bt})]})]},re)),Lt==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:i$})]}),t.jsx(gt,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(tt=S==null?void 0:S.skills)!=null&&tt.length?t.jsx("ul",{className:"border",children:S.skills.map(re=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:re},re))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),_e==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!xe&&t.jsxs(gt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:ot("harness"),warning:we("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:qt.map(re=>{const Me=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:re.id,checked:T.harness===re.id,disabled:!re.available&&T.harness!==re.id,onChange:()=>B(re.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:re.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:re.available?qx(re.id)?re.id.slice(re.id.indexOf(":")+1):re.id:"Not available here"})]})]}),bt=ee("min-w-0 border px-4 py-3",T.harness===re.id?"border-foreground":"border-border");return re.available?t.jsx("label",{className:ee(bt,"flex cursor-pointer items-start gap-3"),children:Me},re.id):t.jsxs("div",{className:ee(bt,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Me}),re.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:re.reason})]})]},re.id)})}),U.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:[((xt=qt.find(re=>re.id===T.harness))==null?void 0:xt.label)??T.harness," doesn't run ",U.length===1?"this tool":"these tools"," here, so ",U.length===1?"it's":"they're"," unticked. Switching back ticks ",U.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:U.map(re=>t.jsxs("li",{children:[re,": ",t.jsx("span",{className:"text-muted-foreground",children:P0(T.harness??"pi",re,s.tools,s.mcpHarnesses)})]},re))})]})]}),!xe&&!Be&&t.jsx(gt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:ot("thinking"),warning:we("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(re=>t.jsxs("label",{className:ee("caps cursor-pointer border px-3 py-2 text-small",T.thinking===re?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:T.thinking===re,onChange:()=>ze({thinking:re})}),re]},re))})}),!Be&&t.jsx(r$,{id:"agent-model",harness:T.harness??"pi",model:T.model,onModel:re=>ze({model:re}),harnesses:s.harnesses,routePrefix:s.routePrefix,state:F,error:{...Xe,text:ot("model")},warning:{harness:(S==null?void 0:S.harness)??"pi",model:S==null?void 0:S.model,text:we("model")}}),!Be&&t.jsx(gt,{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.",en&&t.jsx("span",{className:"mt-1 block",children:CI}),qn&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:qn})]}),hint:t.jsx(o$,{}),error:ot("max_cost_usd"),warning:we("max_cost_usd"),children:t.jsx(Fe,{id:"agent-max-cost",inputMode:"decimal",value:T.maxCostText??"",onChange:re=>ze({maxCostText:re.target.value}),placeholder:"e.g., 2.50"})}),!xe&&!Be&&s.learning&&t.jsx(UF,{fields:T,onFields:ze,saved:S==null?void 0:S.learning,server:s.learning,error:ot("learning"),warning:we("learning")})]}),_e==="history"&&fe&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(W,{size:"sm",variant:"ghost",onClick:()=>De(null),children:[t.jsx(Wn,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",fe.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:fe.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(fe.created_at)}),t.jsx(W,{size:"sm",onClick:()=>o==null?void 0:o(fe.revision),disabled:!o,children:"Make current"})]}),t.jsx(xN,{readOnly:!0,text:JSON.stringify((Rt=fe.definition)==null?void 0:Rt.workflow,null,2),onText:()=>{},base:S.workflow,baseLabel:J?`rev ${J.version}, the current one`:"the current revision"})]}),_e==="history"&&!fe&&t.jsx("ul",{className:"border",children:n.map(re=>{var Me;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 ",re.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:re.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(re.created_at)}),xe&&!re.current&&((Me=re.definition)==null?void 0:Me.workflow)!==void 0&&t.jsxs(W,{size:"sm",variant:"ghost",onClick:()=>De(re),"aria-label":`View rev ${re.version}`,children:[t.jsx(qm,{"aria-hidden":!0})," View"]}),re.current?t.jsx(ke,{tone:"success",children:"Current"}):t.jsx(W,{size:"sm",onClick:()=>o==null?void 0:o(re.revision),disabled:!o,children:"Make current"})]},re.revision)})})]})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[t.jsxs(W,{size:"sm",variant:"ghost",disabled:at===0,onClick:()=>te(de[at-1].id),children:[t.jsx(Wn,{"aria-hidden":!0})," Previous"]}),_e!=="history"&&t.jsx(Fe,{value:Ne,onChange:re=>he(re.target.value),placeholder:N?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ee("h-9 min-w-0 flex-1",N&&"invisible")}),_e==="history"&&t.jsx("span",{className:"flex-1"}),at<de.length-1&&t.jsxs(W,{size:"sm",onClick:()=>te(de[at+1].id),children:["Next ",t.jsx(Ob,{"aria-hidden":!0})]}),!fe&&t.jsx(W,{ref:st,size:"sm",variant:"solid",onClick:qe,disabled:!r||Pe||!N&&!H||!((gn=T.name)!=null&&gn.trim())||!xe&&!Be&&!((dn=T.instructions)!=null&&dn.trim()),children:N?Pe?"Creating…":"Create":Pe?"Saving…":H?"Save revision":J?`Saved · rev ${J.version}`:"Saved"}),N&&!Pe&&!fe&&dt.map(re=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:re},re)),(ge==null?void 0:ge.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: ",ge.message]}),(ge==null?void 0:ge.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:ge.message})]}),t.jsxs(tv,{open:ft.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:ft.leave,onCancel:ft.stay,children:[N?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const L8="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 l$(e,n,{archived:s=!1,query:r=""}={}){const o=e.filter(h=>!!h.archived_at===s),i=s?[]:M8(n),l=new Map(o.filter(h=>cr(h.definition)).map(h=>[h.agent_id,h])),d=new Set(i.map(h=>{var v;return(v=h.learning)==null?void 0:v.agent_id}).filter(h=>h&&l.has(h))),u=o.filter(h=>!d.has(h.agent_id)&&Us(r,vN(h))),f=i.filter(h=>{var b;const v=(b=h.learning)!=null&&b.agent_id?l.get(h.learning.agent_id):void 0;return Us(r,aP(h),v&&vN(v))});return{agents:u,sessions:f,count:u.length+f.length}}function M8(e){const n=new Map;for(const s of e){const r=n.get(s.id),o=r?Date.parse(s.received_at)-Date.parse(r.received_at):0;(!r||o>0||o===0&&s.sequence>=r.sequence)&&n.set(s.id,s)}return[...n.values()]}function vN(e){const n=Ch(e),s=cr(e.definition),r=is(e.definition);return[e.definition.name,e.definition.description,e.agent_id,e.definition.harness,e.definition.model,n==null?void 0:n.project,n==null?void 0:n.machine_id,n==null?void 0:n.model,n&&Kl(n.runtime),s==null?void 0:s.project,s&&pa(s.runtime),r&&Ro(r)].filter(Boolean).join(" ").toLowerCase()}function I8({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:o,handoff:i,observations:l,learning:d}){var k,C;const[u,f]=g.useState(""),h=n?void 0:l,{agents:v,sessions:b,count:m}=l$(e??[],((k=h==null?void 0:h.data)==null?void 0:k.sessions)??[],{archived:n,query:u}),x=!e&&!o||!!(h!=null&&h.loading&&!h.data),y=x||!!o||!!(h!=null&&h.error),j=(C=h==null?void 0:h.data)==null?void 0:C.connectors.some(N=>N.storage_full);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:ha,children:[t.jsx(xd,{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(Ut,{variant:"primary",label:"Build an agent",prompt:xh(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:ee(Cl,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(Jm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Fe,{bare:!0,value:u,onChange:N=>f(N.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(W,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(Fd,{"aria-hidden":!0})," Archived"]})]}),t.jsxs("div",{className:"space-y-4",children:[o&&t.jsxs(ct,{tone:"error",children:["Could not refresh agents: ",o]}),(h==null?void 0:h.error)&&t.jsxs(ct,{tone:"error",actions:t.jsx(W,{size:"xs",disabled:h.loading,onClick:h.refresh,children:"Try again"}),children:["Some connected agents could not be refreshed: ",h.error]}),j&&t.jsx(ct,{tone:"warning",title:"Telemetry needs attention",children:"A connector has reached its telemetry storage capacity. New reports cannot be accepted until storage becomes available."}),m>0&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Agent count",children:[m," ",m===1?"agent":"agents",y?" shown":""]}),t.jsxs("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3","aria-label":"Agents",children:[v.map(N=>t.jsx(P8,{agent:N,actions:r,learning:d},`agent:${N.agent_id}`)),b.map(N=>t.jsx(iP,{session:N},`session:${N.id}`))]})]}),x&&(m?t.jsx("p",{role:"status",className:"text-small text-muted-foreground",children:"Loading more agents…"}):t.jsx(cs,{label:"Loading the agents",rows:6})),!m&&!y&&t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:u?"No agent matches.":n?"No archived agents.":"No agents yet."}),!u&&!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"})]})]})]})]})}function P8({agent:e,actions:n,learning:s}){var b;const r=e.kind==="workflow"?va:Ud,o=!!e.archived_at,i=Ch(e),l=is(e.definition),d=cr(e.definition),u=wm(e),f=e.kind==="agentic"&&s!==null,h=f?s===void 0?"unknown":s==="off"||!xa(e.definition.learning)?"off":"on":"unsupported",v=e.kind==="workflow"?"Learning is configured on the agent that produces this workflow.":s===null?"This server does not support learning.":s===void 0?"The server's learning status has not been read yet.":s==="off"?"Learning is disabled on this server. Its owner must enable it before this agent can learn.":void 0;return t.jsx(aC,{name:e.definition.name,icon:r,harness:e.kind==="workflow"?"workflow":(d==null?void 0:d.runtime)??(l==null?void 0:l.runtime)??(i==null?void 0:i.runtime)??e.definition.harness??"pi",archived:o,onOpen:()=>{var m;return(m=n.onOpen)==null?void 0:m.call(n,e.agent_id)},badges:t.jsxs(t.Fragment,{children:[t.jsx(ke,{children:e.kind}),e.kind==="agentic"&&t.jsx(ke,{children:d?pa(d.runtime):l?Ro(l):i?Kl(i.runtime):e.definition.harness??"pi"}),i&&t.jsx(ke,{tone:i.connected&&i.state==="ready"?"success":"warning",children:eu(i)}),o&&t.jsx(ke,{tone:"muted",children:"Archived"})]}),description:e.definition.description||(e.kind==="workflow"?UP(e.definition.workflow):"No description."),facts:t.jsxs(t.Fragment,{children:[t.jsx(iC,{state:h,serverDisabled:s==="off",href:f&&(!o||xa(e.definition.learning))?jn(e.agent_id,"learning"):void 0,reason:v}),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`:""]}),u>0&&t.jsxs(W,{size:"xs",type:"button","aria-label":Fv(u),onClick:()=>{var m;return(m=n.onLearning)==null?void 0:m.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 · ",u]})]}),actions:t.jsxs(t.Fragment,{children:[!o&&t.jsx(Ut,{compact:!0,compactIcon:t.jsx(Ao,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!i&&(!i.connected||i.state!=="ready"||!i.capabilities.launch),prompt:lv(location.origin,e.agent_id,l,d==null?void 0:d.runtime),playgroundHref:l||d?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(Ut,{compact:!0,compactIcon:t.jsx(Ym,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:ga(location.origin,e.agent_id,!!i,l,d==null?void 0:d.runtime),playgroundHref:i||l||d?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),t.jsxs(W,{size:"sm",className:"gap-1 px-2",variant:"outline","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var m;return(m=n.onRuns)==null?void 0:m.call(n,e.agent_id)},children:[t.jsx(Hd,{"aria-hidden":!0}),((b=e.runs)==null?void 0:b.count)??0]}),t.jsx(W,{size:"icon",variant:"outline","aria-label":`${o?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var m;return(m=n.onArchive)==null?void 0:m.call(n,e.agent_id,!o)},children:o?t.jsx(W1,{"aria-hidden":!0}):t.jsx(Fd,{"aria-hidden":!0})})]}),children:i&&t.jsxs("p",{className:"break-all font-mono",children:[i.project," · ",i.machine_id]})})}function D8({v2:e}){const[n,s]=g.useState(null),[r,o]=g.useState(!1),[i,l]=g.useState(null),[d,u]=g.useState(null),[f,h]=g.useState(""),[v,b]=g.useState("live"),[m,x]=g.useState(null),[y,j]=g.useState(!1),[k,C]=g.useState(!1),[N,S]=g.useState(null),E=g.useRef(!1),$=g.useRef(!1),L=g.useRef(0),A=g.useRef(!0),P=eC(),O=g.useCallback(async()=>{if($.current)return;$.current=!0,o(!0);const I=L.current;try{const V=await e.listConnectors();A.current&&I===L.current&&(s(V.connectors),l(null))}catch(V){A.current&&I===L.current&&l(Gt(V))}finally{$.current=!1,A.current&&o(!1)}},[e]);g.useEffect(()=>{A.current=!0,queueMicrotask(()=>{A.current&&O()});const I=()=>{!document.hidden&&!E.current&&O()},V=setInterval(I,15e3);return window.addEventListener("focus",I),document.addEventListener("visibilitychange",I),()=>{A.current=!1,L.current++,clearInterval(V),window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",I)}},[O]),g.useEffect(()=>{if(!m)return;const I=new Date(m.expires_at).getTime()-Date.now();if(I<=0){x(null),j(!0);return}const V=setTimeout(()=>{x(null),j(!0)},I);return()=>clearTimeout(V)},[m]);const T=async()=>{if(!E.current){E.current=!0,C(!0),u(null),j(!1);try{const I=await e.enrollConnector(f,{native_execution:v!=="history",history_import:v!=="live"});A.current&&x(I)}catch(I){A.current&&u(Gt(I))}finally{E.current=!1,A.current&&C(!1)}}},M=async()=>{if(!(E.current||!N)){E.current=!0,C(!0),u(null),L.current++;try{const{connector:I}=await e.revokeConnector(N.connector_id);A.current&&(s(V=>(V==null?void 0:V.map(G=>G.connector_id===I.connector_id?I:G))??null),S(null))}catch(I){A.current&&u(Gt(I))}finally{E.current=!1,A.current&&C(!1)}}},F=async()=>{if(m)try{await navigator.clipboard.writeText(m.enrollment_token),P({title:"Connection code copied"})}catch{P({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(Ut,{label:"Connect agent",prompt:x5(location.origin,v)})]}),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(eo,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:v,onChange:b,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:[v==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":v==="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."," ",v!=="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(gt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(Fe,{value:f,onChange:I=>h(I.target.value),placeholder:"My development machine",disabled:k,maxLength:120})})}),t.jsx(W,{size:"md",className:"self-start sm:mt-6",disabled:k,"aria-busy":k,onClick:()=>void T(),children:k&&!N?"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(ct,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!N&&t.jsx(ct,{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(W,{size:"sm",disabled:r||k,onClick:()=>void O(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(ct,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(W,{size:"xs",disabled:r,onClick:()=>void O(),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(I=>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:I.label||I.connector_id}),t.jsx(ke,{tone:I.status==="revoked"||!I.capabilities.native_execution?"plain":I.status==="online"?"success":"warning",children:I.status==="revoked"?"Revoked":!I.capabilities.native_execution&&I.capabilities.history_import?"History only":I.status==="online"?"Online":"Offline"}),t.jsx(W,{size:"sm",disabled:k||I.status==="revoked",onClick:()=>{u(null),S(I)},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:I.last_seen_at?ht(I.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:I.capabilities.native_execution?I.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":I.capabilities.history_import?"History import only":"Observation only"})]})]}),I.status==="offline"&&I.capabilities.native_execution&&t.jsx(ct,{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."}),I.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:I.targets.map(V=>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:V.name}),V.agent_id?t.jsx("a",{href:jn(V.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:[Kl(V.runtime)," · ",V.machine_id," · ",V.history_only?"Imported history":I.status==="online"?V.state==="ready"&&V.capabilities.launch?"Ready to run":V.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),V.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:V.issues.join("; ")})]},V.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."})]},I.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(ph,{open:m!==null,onClose:()=>x(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(W,{size:"sm",onClick:()=>x(null),children:"Done"}),t.jsx(W,{size:"sm",variant:"solid",onClick:()=>void F(),children:"Copy connection code"})]}),children:m&&t.jsxs(t.Fragment,{children:[t.jsx(gt,{label:"One-use connection code",hint:`Expires ${ht(m.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(Fe,{readOnly:!0,value:m.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:I=>I.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(tv,{open:N!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{S(null),u(null)},onConfirm:()=>void M(),children:[t.jsxs("p",{children:[(N==null?void 0:N.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(ct,{tone:"error",className:"mt-3",children:d})]})]})}function Ah({variant:e}){return t.jsx(Ut,{variant:e,label:"Connect agent",prompt:oC(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function z8({v2:e,go:n,initialSource:s="server"}){const[r,o]=g.useState(s),[i,l]=g.useState(""),[d,u]=g.useState(null),[f,h]=g.useState([]),[v,b]=g.useState({}),[m,x]=g.useState(!1),[y,j]=g.useState(null),k=async()=>{x(!0),j(null),u(null),h([]),b({});try{u((await e.discoverNative(i.trim())).targets)}catch(N){j(Gt(N))}finally{x(!1)}},C=async()=>{x(!0),j(null);try{for(const N of f){if(v[N])continue;const{project:S,runtime:E,selector:$}=d[N],L=await e.connectNative({project:S,runtime:E,selector:$});b(A=>({...A,[N]:L.agent.agent_id}))}}catch(N){j(Gt(N))}finally{x(!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(W,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect an agent already running, or use an existing native setup for new jobs. Keep its instructions, tools, permissions and sign-in."}),t.jsx(ct,{title:"Choose how to connect",children:"Choose this server or another machine to launch jobs from an existing native setup. Choose an existing application for observation or learning while you keep using its CLI. This browser cannot scan your laptop."}),t.jsx(eo,{name:"native-source",label:"Connection method",value:r,onChange:o,options:[{value:"server",label:"This server",disabled:m},{value:"remote",label:"Another machine",disabled:m},{value:"observe",label:"Existing application",disabled:m}]}),r==="observe"?t.jsxs(t.Fragment,{children:[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:"Observation reports activity without sending conversations or enabling learning."}),t.jsx(Ut,{label:"Connect agent",prompt:`${oC(location.origin)}
|
|
676
|
-
|
|
677
|
-
I selected observation of an existing application. Preserve its current job trigger and SDK configuration; do not import or launch a replacement agent.`})]}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Learn from existing CLI sessions",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Learn as you code"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Keep starting Codex CLI and Claude Code normally. Capture prompt windows for a selected project and deliver owner corrections on later prompts."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"Uses your local AgentRun server. No SDK wrapper required. Add and review corrections in the agent’s Learning tab."}),t.jsx(Ut,{variant:"primary",label:"Enable learning",prompt:g5(location.origin)})]})]}):r==="remote"?t.jsx(D8,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Ah,{}),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(gt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(Fe,{"aria-label":"Project on server host",value:i,onChange:N=>{l(N.target.value),u(null)},placeholder:"/path/to/project",disabled:m})}),t.jsx(W,{variant:d?"outline":"solid",size:"sm",disabled:m||!i.trim().startsWith("/"),"aria-busy":m,onClick:()=>void k(),children:m&&!d?"Discovering…":"Discover"})]}),y&&t.jsx(ct,{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(ct,{children:"No supported native setup was found. Install Claude Code or Codex on this host and check the project path."}),d.map((N,S)=>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:m||!!v[S],checked:f.includes(S),onChange:E=>h($=>E.target.checked?[...$,S]:$.filter(L=>L!==S))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Rv(N.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[Kl(N.runtime)," · ",N.version??"Version unknown"]})]})]}),t.jsx(ke,{tone:N.state==="ready"?"success":"warning",children:eu(N)})]}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Project",N.project],["Machine",N.machine_id],["Model",N.model??"Native default · unknown until launch"],["Skills",N.skills.join(", ")||"None detected"],["MCP servers",N.mcp_servers.join(", ")||"None configured"],["Approval handling",N.capabilities.approval]].map(([E,$])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:E}),t.jsx("dd",{className:"break-all font-mono",children:$})]},E))}),N.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."}),N.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: ",N.capabilities.launch?"supported":"unavailable"," · Self-improving: ",N.capabilities.learning?"corrections and compile":"unavailable"," · Learned workflows: not served ·Usage: ",N.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"]}),N.issues.length>0&&t.jsx(ct,{tone:"warning",children:t.jsx("ul",{children:N.issues.map(E=>t.jsx("li",{children:E},E))})}),v[S]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:jn(v[S]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${N.runtime}:${N.selector.kind}:${N.selector.name??""}`)),!!d.length&&t.jsx(W,{variant:"solid",size:"sm",onClick:()=>void C(),disabled:m||!f.some(N=>!v[N]),"aria-busy":m,children:m?"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 Va=e=>e instanceof Ue?yD(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function F8({v2:e,archived:n,go:s,learning:r}){const o=yv(e,{active:!n}),[i,l]=g.useState(null),[d,u]=g.useState(null),f=g.useRef(0),h=()=>{const v=++f.current;l(null),u(null),Kr(b=>e.listAgents({archived:n,cursor:b}),b=>b.agents).then(b=>{v===f.current&&l(b)}).catch(b=>{v===f.current&&u(Va(b).message)})};return g.useEffect(()=>{h();const v=()=>{document.hidden||h()};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[e,n]),t.jsx(I8,{observations:o,agents:i,archived:n,onArchivedChange:v=>s(v?"#/agents?archived=true":"#/agents"),error:d,learning:r,handoff:t.jsx(Ah,{}),actions:{onOpen:v=>s(jn(v)),onEdit:v=>s(jn(v,"edit")),onNew:()=>s("#/agents/new"),onRuns:v=>s(jn(v,"runs")),onLearning:v=>s(jn(v,"learning")),onArchive:async(v,b)=>{try{await(b?e.archiveAgent(v):e.unarchiveAgent(v)),h()}catch(m){u(Va(m).message)}}}})}function U8({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:o,agentId:i,go:l}){var H;const[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState([]),[m,x]=g.useState(null),[y,j]=g.useState(null),[k,C]=g.useState(0),[N,S]=g.useState(null),E=g.useRef(!0);g.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const $=U=>Kr(Q=>e.listRevisions(U,Q),Q=>Q.revisions),L=async()=>{if(i)try{const[{agent:U,etag:Q},D]=await Promise.all([e.getAgent(i),$(i)]);u(U),h(Q),b(D),S(U.revision),C(Y=>Y+1),j(null),x(null)}catch(U){d?j(`The agent could not be reloaded: ${Va(U).message}`):x(Va(U).message)}};g.useEffect(()=>{L()},[i]);const[A,P]=g.useState(null),O=g.useRef(0);g.useEffect(()=>{const U=++O.current;e.computers().then(Q=>{U===O.current&&P(Q.kinds)},()=>{U===O.current&&P(null)})},[e]);const[T,M]=g.useState(void 0);g.useEffect(()=>{let U=!0;return Promise.resolve().then(()=>e.toolSettings()).then(Q=>{U&&M(Q)},()=>{}),()=>{U=!1}},[e]);const[F,I]=g.useState(null),V=g.useRef(0),G=()=>{if(!n.mcp)return;const U=++V.current;I(null),e.listMcpServers().then(Q=>{U===V.current&&I(Q.servers)},()=>{U===V.current&&I("failed")})};g.useEffect(G,[e,n.mcp]);const q=async(U,Q)=>{let D;try{D=await Q()}catch(Y){j(`${U} did not finish: ${Va(Y).message}`);return}u(D);try{const{agent:Y,etag:K}=await e.getAgent(D.agent_id),Z=await $(D.agent_id).catch(()=>v);u(Y),h(K),b(Z),Y.revision!==N?(S(Y.revision),C(se=>se+1),j(U==="Make current"?null:`${U} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(Y){j(`${U} done. The page could not be refreshed: ${Va(Y).message}. Reload to see the current state.`)}};return i&&m&&!d?t.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:m}):i&&!d?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):d&&(is(d.definition)||cr(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(ct,{children:cr(d.definition)?"This agent runs in your CLI. Edit its original project configuration; manage self-improving in its Learning tab.":"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(Ut,{label:"Edit agent",prompt:ga(location.origin,d.agent_id,!1,is(d.definition),(H=cr(d.definition))==null?void 0:H.runtime)}),t.jsx("a",{href:jn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(O8,{agent:d,revisions:v,caps:{...n,computers:A},providerChoices:s,permissionGates:r,mcpServers:F,serverToolSettings:T,onRetryMcp:G,...o?{focusTool:o,step:"tools"}:{},notice:y,validate:e.validateWorkflow,onBack:()=>l("#/agents"),onReload:()=>{L(),G()},onSave:async(U,Q)=>{let D;try{if(!d){const se=await e.createAgent(mD({name:U.name??"",description:U.description??"",instructions:U.instructions??"",harness:U.harness??"pi",tools:U.tools??[],approvals:U.approvals,tool_settings:U.tool_settings,thinking:U.thinking,model:U.model,computer:U.computer,learning:U.learning,max_cost_usd:U.max_cost_usd,decisionProvider:n.decisionProvider}));return E.current&&l(jn(se.agent_id,se.kind==="workflow"?"workflow":void 0)),null}const Y=Gl(d,U,Q);if(Y.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:K,...Z}=Y;D=await e.updateDefinition(d.agent_id,Z,f)}catch(Y){return Va(Y)}return u(D.agent),h(D.etag),S(D.agent.revision),e.getAgent(D.agent.agent_id).then(Y=>u(K=>K&&K.revision===Y.agent.revision?{...K,tools:Y.agent.tools}:K)).catch(()=>{}),$(D.agent.agent_id).then(b).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:U=>{d&&q("Make current",()=>e.setCurrent(d.agent_id,U))},onArchive:U=>{d&&q(U?"Archive":"Unarchive",()=>U?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function Rr(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 W8={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},H8={tool:1,model:1,mcp:2,computer:2,source:2};function _m(e,n){const s=e.split(":"),r=H8[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const B8="Sign in with your password to change secrets.",q8="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",G8="Open the console from the server's link to change secrets.",no={sign_in:B8,no_accounts:q8,token:G8},c$=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,K8=e=>{var n;return((n=c$(e))==null?void 0:n.secrets_writable)===!0};function V8(e){const n=c$(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function Y8(e){const[n,s]=g.useState({writable:!1,whyNot:"sign_in"});return g.useEffect(()=>{let r=!0;return e.session().then(o=>{r&&s({writable:K8(o),whyNot:V8(o)})},()=>{}),()=>{r=!1}},[e]),n}const Q8=2e3,ab=e=>e instanceof Ue||e instanceof Error?e.message:String(e),iy=({children:e="Manage usage"})=>t.jsx("a",{href:yI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function J8(){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(iy,{})," in your ChatGPT settings."]}),t.jsx("p",{children:jI})]})}function ib({v2:e,view:n,onView:s,writable:r=!0,whyNot:o="sign_in",beside:i}){const[l,d]=g.useState(n),[u,f]=g.useState(null),[h,v]=g.useState(!1),[b,m]=g.useState(!1),[x,y]=g.useState(!1),j=g.useRef(null),k=g.useRef(0);g.useEffect(()=>{d(n)},[n]);const C=P=>{d(P),s==null||s(P)},N=l.state==="pending";g.useEffect(()=>{if(!N)return;let P=!1;const O=()=>{if(P||document.visibilityState!=="visible")return;P=!0;const F=++k.current;e.chatGPT().then(I=>{const V=hm(I);F===k.current&&V&&V.state!=="pending"&&C(V)},()=>{}).finally(()=>{P=!1})},T=setInterval(O,Q8),M=()=>{document.visibilityState==="visible"&&O()};return document.addEventListener("visibilitychange",M),()=>{clearInterval(T),document.removeEventListener("visibilitychange",M)}},[e,N]);const S=async()=>{f(null),v(!0);const P=window.open("","_blank");k.current++;try{const O=await e.startChatGPT();P&&(P.opener=null,P.location.href=O.authorize_url),C({state:"pending",authorize_url:O.authorize_url,expires_at:O.expires_at})}catch(O){P==null||P.close(),f(ab(O))}finally{v(!1)}},E=async P=>{var M;P.preventDefault();const O=(M=j.current)==null?void 0:M.value.trim();if(!O)return;f(null),v(!0),m(!0),k.current++;const T=F=>{j.current&&(j.current.value=""),y(!1),C(F)};try{T(await e.finishChatGPT(O))}catch(F){const I=await e.chatGPT().then(hm,()=>null);(I==null?void 0:I.state)==="signed_in"?T(I):f(ab(F))}finally{v(!1),m(!1)}},$=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(l.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:EI(l)}),t.jsx(J8,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:no[o]});if(!N)return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{type:"button",size:"sm",variant:"solid",disabled:h,onClick:()=>void S(),children:"Continue with ChatGPT"}),i]}),$]});const L=Rr(l.authorize_url),A=l.expires_at;return t.jsxs("form",{onSubmit:P=>void E(P),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:wI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[L&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),L&&A&&" · ",A&&`Waits until ${li(A)}`]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"The sign-in tab's address"}),t.jsx(Fe,{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 P;return y(!!((P=j.current)!=null&&P.value.trim()))}})]}),$,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"sm",variant:"solid",disabled:!x||h,children:b?"Finishing…":"Finish sign-in"}),t.jsx(W,{type:"button",size:"sm",disabled:h,onClick:()=>void S(),children:"Start again"})]})]})}const X8={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 Z8({v2:e,writable:n,whyNot:s,onChange:r}){var y;const[o,i]=g.useState(null),[l,d]=g.useState(!1),[u,f]=g.useState(null),[h,v]=g.useState(null);if(g.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(hm(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const b=async()=>{v(null);let j;try{j=await e.signOutChatGPT()}catch(k){v(ab(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||NI,settings:!0}:{words:kI}),r==null||r()},m=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},x=X8[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:x.tone,children:x.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:NC}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:SI}),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(ib,{v2:e,view:o,onView:m,writable:n,whyNot:s}),o.state==="signed_in"&&n&&!l&&t.jsx(W,{size:"sm",onClick:()=>{d(!0),v(null)},children:"Sign out"}),l&&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(W,{size:"sm",variant:"destructive",onClick:()=>void b(),children:"Sign out"}),t.jsx(W,{size:"sm",onClick:()=>d(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:h}),u&&t.jsxs("p",{className:"text-body",role:"status",children:[u.words,u.settings&&t.jsxs(t.Fragment,{children:[" ",t.jsx(iy,{children:"ChatGPT settings"})]})]})]})]})}function eU(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 d$({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=eU(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:ym(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:Al(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const tU=2e3,nU=10*6e4,sU=e=>e instanceof Ue||e instanceof Error?e.message:String(e),rU={off:{tone:"plain",words:"off"},other_machine:{tone:"warning",words:"another machine"},signed_in:{tone:"success",words:"signed in"},signed_out:{tone:"warning",words:"not signed in"},no_cli:{tone:"plain",words:"no CLI yet"},unknown:{tone:"warning",words:"status unknown"}};function oU({v2:e,writable:n,whyNot:s="sign_in",onChange:r}){const[o,i]=g.useState(null),[l,d]=g.useState("agentrun"),[u,f]=g.useState(!1),[h,v]=g.useState(!1),[b,m]=g.useState(null),[x,y]=g.useState(null),j=g.useRef(0),k=g.useRef(!1),C=g.useRef(!1);g.useEffect(()=>{let O=!0;return e.claudeLogin().then(T=>{O&&i(g0(T))},()=>{O&&i(null)}),()=>{O=!1}},[e]);const N=()=>{if(C.current||k.current)return;C.current=!0;const O=++j.current;e.claudeLogin().then(T=>{const M=g0(T);O===j.current&&M&&i(M)},()=>{}).finally(()=>{C.current=!1})},S=x!==null&&(o==null?void 0:o.state)!=="signed_in";g.useEffect(()=>{if(!S)return;const O=setInterval(()=>{if(document.visibilityState==="visible"){if(Date.now()-x>nU){y(null);return}N()}},tU);return()=>clearInterval(O)},[e,S]);const E=(o==null?void 0:o.state)==="signed_out"||(o==null?void 0:o.state)==="no_cli"||(o==null?void 0:o.state)==="unknown";if(g.useEffect(()=>{if(!E)return;const O=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("focus",O),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("focus",O),document.removeEventListener("visibilitychange",O)}},[e,E]),!o)return null;const $=async(O,T)=>{m(null),v(!0),k.current=!0,j.current++;try{return i(await O()),T&&(r==null||r()),!0}catch(M){return m(sU(M)),!1}finally{j.current++,k.current=!1,v(!1)}},L=rU[o.state],A=o.state!=="off",P=t.jsx("pre",{className:"overflow-x-auto border bg-card p-3 font-mono text-small",children:t.jsx("code",{children:o.command})});return t.jsxs("li",{"aria-label":h0,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:h0}),t.jsx(ke,{tone:L.tone,children:L.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:TI}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="signed_in"&&t.jsx("p",{className:"text-body font-semibold",children:zI(o)}),o.state==="other_machine"&&t.jsx("p",{className:"text-body",children:II}),(o.state==="signed_out"||o.state==="no_cli"||o.state==="unknown")&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body",children:o.state==="signed_out"?OI:o.state==="no_cli"?LI:MI}),P,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[n&&o.can_start&&o.state!=="no_cli"&&t.jsx(W,{type:"button",size:"sm",variant:"solid",disabled:h||S,onClick:()=>void $(()=>e.startClaudeLogin(),!1).then(O=>O&&y(Date.now())),children:S?"Waiting for the browser…":"Open the CLI's sign-in here"}),t.jsx(W,{type:"button",size:"sm",disabled:h,onClick:N,children:"Check again"})]})]}),!A&&o.refused&&t.jsx("p",{className:"text-body",role:"status",children:o.refused}),!A&&!o.refused&&!n&&t.jsx("p",{className:"text-body",role:"status",children:no[s]}),!A&&!o.refused&&n&&t.jsxs("form",{className:"space-y-2",onSubmit:O=>{O.preventDefault(),$(()=>e.turnOnClaudeLogin(l),!0)},children:[t.jsxs("fieldset",{className:"space-y-1",children:[t.jsx("legend",{className:"caps mb-1 text-small font-semibold",children:"The login it uses"}),Object.keys(p0).map(O=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"claude-login-place",value:O,className:"accent-primary",checked:l===O,onChange:()=>d(O)}),p0[O]]},O))]}),t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"only_me",className:"accent-primary",checked:u,onChange:O=>f(O.target.checked)}),RI]}),t.jsx("p",{className:"text-small text-muted-foreground",children:AI}),t.jsx(W,{type:"submit",size:"sm",variant:"solid",disabled:!u||h,children:"Turn on"})]}),A&&n&&t.jsx(W,{size:"sm",disabled:h,onClick:()=>void $(()=>e.turnOffClaudeLogin(),!0).then(O=>O&&y(null)),children:"Turn off"}),b&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}const ox="Use a model gateway",aU="Every model through an OpenAI-compatible gateway you already run, such as LiteLLM. While it is in use, the provider keys here are not used.",iU="Set where AgentRun starts (AGENT_MODEL_BASE_URL), and that one wins: change it there.",lb=[{tier:"default",label:"Default model",variable:"AGENT_MODEL",note:"What an agent that names no model runs on."},{tier:"fast",label:"Fast model",variable:"AGENT_MODEL_FAST",note:"A workflow's fast tier. None: it runs on the default."},{tier:"strong",label:"Strong model",variable:"AGENT_MODEL_STRONG",note:"A workflow's strong tier. None: it runs on the default."}],lU=[{value:"as_named",label:"As named"},{value:"bare",label:"Bare"}],cU="How the gateway takes a model an agent names: whole (openai/gpt-6.1-sol), or bare, the part after the provider (gpt-6.1-sol).",cb=e=>e instanceof Ue||e instanceof Error?e.message:String(e),yN=e=>Object.fromEntries((e instanceof Ue?e.fields??[]:[]).map(n=>[n.field,n.message]));function dU({v2:e,writable:n,whyNot:s="sign_in",onChange:r}){const[o,i]=g.useState(null),[l,d]=g.useState(!1),[u,f]=g.useState(!1),[h,v]=g.useState(!1),[b,m]=g.useState(null);if(g.useEffect(()=>{let C=!0;return e.modelGateway().then(N=>{C&&i(N)},()=>{C&&i(null)}),()=>{C=!1}},[e]),!o)return null;const x=o.source==="env",y=o.source!==null,j=async()=>{m(null),v(!0);try{i(await e.removeModelGateway()),f(!1),r==null||r()}catch(C){m(cb(C))}finally{v(!1)}},k=o.problem?t.jsx(ke,{tone:"warning",children:"refused"}):x?t.jsx(ke,{tone:"success",children:"set at start"}):y?t.jsx(ke,{tone:"success",children:"in use"}):t.jsx(ke,{tone:"plain",children:"off"});return t.jsxs("li",{"aria-label":ox,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:ox}),k]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:aU}),t.jsxs("div",{className:"mt-3 space-y-3",children:[y&&!l&&t.jsx(uU,{view:o}),o.problem&&t.jsx("p",{className:"font-mono text-small text-warning-text",role:"status",children:o.problem}),x&&t.jsx("p",{className:"text-small text-muted-foreground",children:iU}),!x&&!n&&t.jsx("p",{className:"text-body",role:"status",children:no[s]}),!x&&n&&!l&&!u&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{type:"button",size:"sm",variant:y?"outline":"primary",onClick:()=>{d(!0),m(null)},children:y?"Change":ox}),y&&t.jsx(W,{type:"button",size:"sm",variant:"destructive",onClick:()=>{f(!0),m(null)},children:"Stop using it"})]}),u&&t.jsxs("div",{role:"alertdialog","aria-label":"Stop using the model gateway",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:"Stop using this gateway, and remove its saved key? Agents then run on the provider keys here."}),t.jsx(W,{size:"sm",autoFocus:!0,onClick:()=>f(!1),children:"Keep"}),t.jsx(W,{size:"sm",variant:"destructive",disabled:h,onClick:()=>void j(),children:"Stop using it"})]}),l&&t.jsx(fU,{v2:e,view:o,onCancel:()=>d(!1),onSaved:C=>{i(C),d(!1),r==null||r()}}),b&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}function uU({view:e}){const n=e.secret.set?e.secret.source==="env"?"set where AgentRun starts":`saved${e.secret.changed_at?` · ${ht(e.secret.changed_at)}`:""}`:"none (each run brings its own)",s=[["Address",e.base_url??""],["Key",n],["Model ids",e.ids==="bare"?"bare":"as named"],...lb.map(({tier:r,label:o})=>[o,e.models[r]??"none"])];return t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-small",children:s.map(([r,o])=>t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:r}),t.jsx("dd",{className:"min-w-0 break-all font-mono",children:o})]},r))})}function fU({v2:e,view:n,onCancel:s,onSaved:r}){const[o,i]=g.useState(n.base_url??""),[l,d]=g.useState(n.ids),[u,f]=g.useState({default:n.models.default??"",fast:n.models.fast??"",strong:n.models.strong??""}),[h,v]=g.useState(!1),[b,m]=g.useState(null),[x,y]=g.useState(null),[j,k]=g.useState(!1),[C,N]=g.useState(!1),[S,E]=g.useState({}),[$,L]=g.useState(null),A=g.useRef(null),P=G=>n.set_at_start.includes(G),O=()=>{var G;return((G=A.current)==null?void 0:G.value.trim())||void 0},T=g.useRef(0),M=()=>{T.current++,y(null),m(null),k(!1)},F=async()=>{const G=++T.current;k(!0),y(null),E({});try{const q=O(),H=await e.testModelGateway({...o.trim()?{base_url:o.trim()}:{},...h?{api_key:null}:q?{api_key:q}:{}});if(G!==T.current)return;y(H),H.ok&&(m(H.models),!u.default&&!P("AGENT_MODEL")&&H.models[0]&&f(U=>({...U,default:H.models[0]})))}catch(q){if(G!==T.current)return;E(yN(q)),y({ok:!1,why:cb(q)})}finally{G===T.current&&k(!1)}},I=async G=>{G.preventDefault(),N(!0),E({}),L(null);const q=O(),H={base_url:o.trim(),...h?{api_key:null}:q?{api_key:q}:{},...P("AGENT_MODEL_GATEWAY_IDS")?{}:{ids:l},models:Object.fromEntries(lb.filter(({variable:U})=>!P(U)).flatMap(({tier:U})=>u[U]?[[U,u[U]]]:U==="default"?[]:[[U,null]]))};try{const U=await e.saveModelGateway(H);A.current&&(A.current.value=""),r(U)}catch(U){const Q=yN(U);E(Q),Object.keys(Q).length||L(cb(U))}finally{N(!1)}},V=({tier:G,label:q,variable:H,note:U})=>{if(P(H))return t.jsx(gt,{label:q,hint:`Set where AgentRun starts (${H}), and that one wins.`,children:t.jsx(Fe,{value:n.models[G]??"",readOnly:!0})},G);const Q=u[G],D=K=>f(Z=>({...Z,[G]:K})),Y=[...G==="default"?[]:[{value:"",label:"None"}],...[...new Set([...b??[],...Q?[Q]:[]])].map(K=>({value:K,label:K}))];return t.jsx(gt,{label:q,required:G==="default",optional:G!=="default",note:U,error:S[`models.${G}`],children:b!=null&&b.length?t.jsx(Ft,{label:q,value:Q,onChange:D,options:Y,placeholder:"Pick a model"}):t.jsx(Fe,{name:`model_${G}`,value:Q,onChange:K=>D(K.target.value),placeholder:G==="default"?"Test the gateway to list its models":"None",autoComplete:"off",spellCheck:!1})},G)};return t.jsxs("form",{className:"space-y-4 border bg-background p-4","aria-label":"Model gateway",onSubmit:G=>void I(G),children:[t.jsx(gt,{label:"Gateway address",required:!0,note:"Its OpenAI-compatible API, such as https://gateway.example/v1: https, or http on this machine.",error:S.base_url,children:t.jsx(Fe,{name:"base_url",type:"url",value:o,onChange:G=>{i(G.target.value),M()},placeholder:"https://gateway.example/v1",autoComplete:"off",spellCheck:!1})}),t.jsx(gt,{label:"Key",optional:!0,note:n.secret.set&&n.secret.source==="console"?"A key is saved: leave this empty to keep it (for the same address).":"Sent as a bearer token, kept sealed here, never shown again. None: each run brings its own (model_key).",error:S.api_key,children:t.jsx(Fe,{ref:A,name:"api_key",type:"password",autoComplete:"off",disabled:h,onInput:M,placeholder:n.secret.set&&n.secret.source==="console"?"Saved":""})}),n.secret.set&&n.secret.source==="console"&&t.jsx(Y2,{name:"no_key",checked:h,onChange:G=>{v(G.target.checked),M()},label:"Use no key",note:"The saved key is removed when you save."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(W,{type:"button",size:"sm",disabled:j||!o.trim()&&!n.base_url,"aria-busy":j||void 0,onClick:()=>void F(),children:j?"Testing":"Test"}),(x==null?void 0:x.ok)&&t.jsxs("p",{className:"text-small text-success-text",role:"status",children:["The gateway lists ",x.models.length," ",x.models.length===1?"model":"models",x.models.length?": pick the defaults below.":"."]})]}),x&&!x.ok&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:x.why}),t.jsx(gt,{label:"Model ids",group:"heading",note:P("AGENT_MODEL_GATEWAY_IDS")?"Set where AgentRun starts (AGENT_MODEL_GATEWAY_IDS), and that one wins.":cU,children:P("AGENT_MODEL_GATEWAY_IDS")?t.jsx("p",{className:"font-mono text-body",children:n.ids==="bare"?"Bare":"As named"}):t.jsx(eo,{label:"Model ids",name:"ids",value:l,onChange:d,options:lU})}),lb.map(V),$&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:$}),t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(W,{type:"button",size:"sm",onClick:s,children:"Cancel"}),t.jsx(W,{type:"submit",size:"sm",variant:"primary",disabled:C,"aria-busy":C||void 0,children:C?"Saving":"Save"})]})]})}const zf=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function mU(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,l]=n,d=zf(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&l==="*"?{kind:"hourly",minute:d}:null;const u=zf(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(o==="*"&&l==="*")return{kind:"daily",at:f};if(o==="*"&&l==="1-5")return{kind:"weekdays",at:f};if(o==="*"){const h=zf(l,0,6);return h===null?null:{kind:"weekly",day:h,at:f}}if(l==="*"){const h=zf(o,1,31);return h===null?null:{kind:"monthly",date:h,at:f}}return null}function hU(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 pU(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 wN=e=>String(e).padStart(2,"0"),gU=e=>`${wN(e.hour)}:${wN(e.minute)}`;function xU(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 ax={exports:{}},jN;function bU(){return jN||(jN=1,(function(e,n){(function(r,o){e.exports=o()})(globalThis,()=>(()=>{var s={6949(l,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),h=(function(){function v(b,m,x){m===void 0&&(m=!0),x===void 0&&(x=!1),this.expression=b,this.dayOfWeekStartIndexZero=m,this.monthStartIndexZero=x}return v.prototype.parse=function(){var b,m,x=(b=this.expression)!==null&&b!==void 0?b:"";if(x==="@reboot")return m=["@reboot","","","","","",""],m;if(x.startsWith("@")){var y=this.parseSpecial(this.expression);m=this.extractParts(y)}else m=this.extractParts(this.expression);return this.normalize(m),this.validate(m),m},v.prototype.parseSpecial=function(b){var m={"@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"},x=m[b];if(!x)throw new Error("Unknown special expression.");return x},v.prototype.extractParts=function(b){if(!this.expression)throw new Error("cron expression is empty");for(var m=b.trim().split(/[ ]+/),x=0;x<m.length;x++)if(m[x].includes(",")){var y=m[x].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,C){return k!==null&&C!==null?k-C:0}),m[x]=y.map(function(k){return k!==null?k.toString():""}).join(",")}if(m.length<5)throw new Error("Expression has only ".concat(m.length," part").concat(m.length==1?"":"s",". At least 5 parts are required."));if(m.length==5)m.unshift(""),m.push("");else if(m.length==6){var j=/\d{4}$/.test(m[5])||m[4]=="?"||m[2]=="?";j?m.unshift(""):m.push("")}else if(m.length>7)throw new Error("Expression has ".concat(m.length," parts; too many!"));return m},v.prototype.normalize=function(b){var m=this;b[3]=b[3].replace("?","*"),b[5]=b[5].replace("?","*"),b[2]=b[2].replace("?","*"),b[0].indexOf("0/")==0&&(b[0]=b[0].replace("0/","*/")),b[1].indexOf("0/")==0&&(b[1]=b[1].replace("0/","*/")),b[2].indexOf("0/")==0&&(b[2]=b[2].replace("0/","*/")),b[3].indexOf("1/")==0&&(b[3]=b[3].replace("1/","*/")),!this.monthStartIndexZero&&b[4].indexOf("1/")==0&&(b[4]=b[4].replace("1/","*/")),b[6].indexOf("1/")==0&&(b[6]=b[6].replace("1/","*/")),b[5]=b[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function($){var L=$.replace(/\D/,""),A=L;return m.dayOfWeekStartIndexZero?L=="7"&&(A="0"):A=(parseInt(L)-1).toString(),$.replace(L,A)}),b[5]=="L"&&(b[5]="6"),b[3]=="?"&&(b[3]="*");var x=/^\d{1,2}W[+-]\d{1,2}$/;if(b[3].indexOf("W")>-1&&(b[3].indexOf(",")>-1||/[-+]/.test(b[3]))&&!x.test(b[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)b[5]=b[5].replace(new RegExp(j,"gi"),y[j].toString());b[4]=b[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function($){var L=$.replace(/\D/,""),A=L;return m.monthStartIndexZero&&(A=(parseInt(L)+1).toString()),$.replace(L,A)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var C in k)b[4]=b[4].replace(new RegExp(C,"gi"),k[C].toString());b[0]=="0"&&(b[0]=""),!/\*|\-|\,|\//.test(b[2])&&(/\*|\//.test(b[1])||/\*|\//.test(b[0]))&&(b[2]+="-".concat(b[2]));for(var N=0;N<b.length;N++)if(b[N].indexOf(",")!=-1&&(b[N]=b[N].split(",").filter(function($){return $!==""}).join(",")||"*"),b[N]=="*/1"&&(b[N]="*"),b[N].indexOf("/")>-1&&!/^\*|\-|\,/.test(b[N])){var S=null;switch(N){case 4:S="12";break;case 5:S="6";break;case 6:S="9999";break;default:S=null;break}if(S!==null){var E=b[N].split("/");b[N]="".concat(E[0],"-").concat(S,"/").concat(E[1])}}},v.prototype.validate=function(b){var m="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(b[0],m),this.validateOnlyExpectedCharactersFound(b[1],m),this.validateOnlyExpectedCharactersFound(b[2],m),this.validateOnlyExpectedCharactersFound(b[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(b[4],m),this.validateOnlyExpectedCharactersFound(b[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(b[6],m),this.validateAnyRanges(b)},v.prototype.validateAnyRanges=function(b){b.forEach(function(m){return f.default.stepRange(m)}),f.default.secondRange(b[0]),f.default.minuteRange(b[1]),f.default.hourRange(b[2]),f.default.dayOfMonthRange(b[3]),f.default.monthRange(b[4],this.monthStartIndexZero),f.default.dayOfWeekRange(b[5],this.dayOfWeekStartIndexZero)},v.prototype.validateOnlyExpectedCharactersFound=function(b,m){var x=b.match(new RegExp("[^".concat(m,"]+"),"gi"));if(x&&x.length)throw new Error("Expression contains invalid values: '".concat(x.toString(),"'"))},v})();d.CronParser=h},8333(l,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),h=u(6949),v=(function(){function b(m,x){if(this.expression=m,this.options=x,this.expressionParts=new Array(5),!this.options.locale&&b.defaultLocale&&(this.options.locale=b.defaultLocale),!b.locales[this.options.locale]){var y=Object.keys(b.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(y,"'.")),this.options.locale=y}this.i18n=b.locales[this.options.locale],x.use24HourTimeFormat===void 0&&(x.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return b.toString=function(m,x){var y=x===void 0?{}:x,j=y.throwExceptionOnParseError,k=j===void 0?!0:j,C=y.verbose,N=C===void 0?!1:C,S=y.dayOfWeekStartIndexZero,E=S===void 0?!0:S,$=y.monthStartIndexZero,L=$===void 0?!1:$,A=y.use24HourTimeFormat,P=y.trimHoursLeadingZero,O=P===void 0?!1:P,T=y.locale,M=T===void 0?null:T,F=y.logicalAndDayFields,I=F===void 0?!1:F,V={throwExceptionOnParseError:k,verbose:N,dayOfWeekStartIndexZero:E,monthStartIndexZero:L,use24HourTimeFormat:A,trimHoursLeadingZero:O,locale:M,logicalAndDayFields:I};V.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var G=new b(m,V);return G.getFullDescription()},b.initialize=function(m,x){x===void 0&&(x="en"),b.specialCharacters=["/","-",",","*"],b.defaultLocale=x,m.load(b.locales)},b.prototype.getFullDescription=function(){var m,x,y="";try{var j=new h.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((x=(m=this.i18n).atReboot)===null||x===void 0?void 0:x.call(m))||"Run once, at startup";var k=this.getTimeOfDayDescription(),C=this.getDayOfMonthDescription(),N=this.getMonthDescription(),S=this.getDayOfWeekDescription(),E=this.getYearDescription();y+=k+C+S+N+E,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},b.prototype.getTimeOfDayDescription=function(){var m=this.expressionParts[0],x=this.expressionParts[1],y=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(x,b.specialCharacters)&&!f.StringUtilities.containsAny(y,b.specialCharacters)&&!f.StringUtilities.containsAny(m,b.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(y,x,m);else if(!m&&x.indexOf("-")>-1&&!(x.indexOf(",")>-1)&&!(x.indexOf("/")>-1)&&!f.StringUtilities.containsAny(y,b.specialCharacters)){var k=x.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(y,k[0],""),this.formatTime(y,k[1],""))}else if(!m&&y.indexOf(",")>-1&&y.indexOf("-")==-1&&y.indexOf("/")==-1&&!f.StringUtilities.containsAny(x,b.specialCharacters)){var C=y.split(",");j+=this.i18n.at();for(var N=0;N<C.length;N++)j&&(j+=" "),j+=this.formatTime(C[N],x,""),N<C.length-2&&(j+=","),N==C.length-2&&(j+=this.i18n.spaceAnd())}else{var S=this.getSecondsDescription(),E=this.getMinutesDescription(),$=this.getHoursDescription();if(j+=S,j&&E&&(j+=", "),j+=E,E===$)return j;j&&$&&(j+=", "),j+=$}return j},b.prototype.getSecondsDescription=function(){var m=this,x=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(y){return y},function(y){return f.StringUtilities.format(m.i18n.everyX0Seconds(y),y)},function(y){return m.i18n.secondsX0ThroughX1PastTheMinute()},function(y){return y=="0"?"":parseInt(y)<20?m.i18n.atX0SecondsPastTheMinute(y):m.i18n.atX0SecondsPastTheMinuteGt20()||m.i18n.atX0SecondsPastTheMinute(y)},{min:0,max:59});return x},b.prototype.getMinutesDescription=function(){var m=this,x=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(m.i18n.everyX0Minutes(k),k)},function(k){return m.i18n.minutesX0ThroughX1PastTheHour()},function(k){var C,N;try{return k=="0"&&y.indexOf("/")==-1&&x==""?m.i18n.everyHour():k=="0"?((N=(C=m.i18n).onTheHour)===null||N===void 0?void 0:N.call(C))||m.i18n.atX0MinutesPastTheHour(k):parseInt(k)<20?m.i18n.atX0MinutesPastTheHour(k):m.i18n.atX0MinutesPastTheHourGt20()||m.i18n.atX0MinutesPastTheHour(k)}catch{return m.i18n.atX0MinutesPastTheHour(k)}},{min:0,max:59});return j},b.prototype.getHoursDescription=function(){var m=this,x=this.expressionParts[2],y=0,j=[];x.split("/")[0].split(",").forEach(function(N){var S=N.split("-");S.length===2&&j.push({value:S[1],index:y+1}),y+=S.length});var k=0,C=this.getSegmentDescription(x,this.i18n.everyHour(),function(N){var S=j.find(function($){return $.value===N&&$.index===k}),E=S&&m.expressionParts[1]!=="0";return k++,E?m.formatTime(N,"59",""):m.formatTime(N,"0","")},function(N){return f.StringUtilities.format(m.i18n.everyX0Hours(N),N)},function(N){return m.i18n.betweenX0AndX1()},function(N){return m.i18n.atX0()},{min:0,max:23});return C},b.prototype.getDayOfWeekDescription=function(){var m=this,x=this.i18n.daysOfTheWeek(),y=null;return this.expressionParts[5]=="*"?y="":y=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var C=j;j.indexOf("#")>-1?C=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(C=C.replace("L",""));var N=parseInt(C),S=m.i18n.daysOfTheWeekInCase?m.i18n.daysOfTheWeekInCase(k)[N]:x[N];if(j.indexOf("#")>-1){var E=null,$=j.substring(j.indexOf("#")+1),L=j.substring(0,j.indexOf("#"));switch($){case"1":E=m.i18n.first(L);break;case"2":E=m.i18n.second(L);break;case"3":E=m.i18n.third(L);break;case"4":E=m.i18n.fourth(L);break;case"5":E=m.i18n.fifth(L);break}S=E+" "+S}return S},function(j){return parseInt(j)==1?"":f.StringUtilities.format(m.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var k=j.substring(0,j.indexOf("-")),C=m.expressionParts[3]!="*";return C?m.i18n.commaAndX0ThroughX1(k):m.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var C=j.substring(j.indexOf("#")+1),N=j.substring(0,j.indexOf("#"));k=m.i18n.commaOnThe(C,N).trim()+m.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)k=m.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var S=m.expressionParts[3]!="*";S?m.options.logicalAndDayFields?k=m.i18n.commaOnlyOnX0(j):k=m.i18n.commaAndOnX0():k=m.i18n.commaOnlyOnX0(j)}return k}),y},b.prototype.getMonthDescription=function(){var m=this,x=this.i18n.monthsOfTheYear(),y=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&m.i18n.monthsOfTheYearInCase?m.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:x[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(m.i18n.commaEveryX0Months(j),j)},function(j){return m.i18n.commaMonthX0ThroughMonthX1()||m.i18n.commaX0ThroughX1()},function(j){return m.i18n.commaOnlyInMonthX0?m.i18n.commaOnlyInMonthX0():m.i18n.commaOnlyInX0()});return y},b.prototype.getDayOfMonthDescription=function(){var m=this,x,y,j,k,C=null,N=this.expressionParts[3];switch(N){case"L":C=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":C=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=N.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(S){var E=parseInt(S[1]||S[2]),$=E==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),E.toString()),L=S[4];L?S[3]=="-"?C=f.StringUtilities.format(((y=(x=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||y===void 0?void 0:y.call(x,L))||", %s days before the %s of the month",L,$):C=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,L))||", %s days after the %s of the month",L,$):C=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),$);break}else{var A=N.match(/L-(\d{1,2})/);if(A){var P=A[1];C=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(P),P);break}else{if(N=="*"&&this.expressionParts[5]!="*")return"";C=this.getSegmentDescription(N,this.i18n.commaEveryDay(),function(O){return O=="L"?m.i18n.lastDay():m.i18n.dayX0?f.StringUtilities.format(m.i18n.dayX0(),O):O},function(O){return O=="1"?m.i18n.commaEveryDay():m.i18n.commaEveryX0Days(O)},function(O){return m.i18n.commaBetweenDayX0AndX1OfTheMonth(O)},function(O){return m.i18n.commaOnDayX0OfTheMonth(O)})}break}}return C},b.prototype.getYearDescription=function(){var m=this,x=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(m.i18n.commaEveryX0Years(y),y)},function(y){return m.i18n.commaYearX0ThroughYearX1()||m.i18n.commaX0ThroughX1()},function(y){return m.i18n.commaOnlyInYearX0?m.i18n.commaOnlyInYearX0():m.i18n.commaOnlyInX0()});return x},b.prototype.getSegmentDescription=function(m,x,y,j,k,C,N){var S=null,E=m.indexOf("/")>-1,$=m.indexOf("-")>-1,L=m.indexOf(",")>-1;if(!m)S="";else if(m==="*")S=x;else if(!E&&!$&&!L)S=f.StringUtilities.format(C(m),y(m));else if(L){for(var A=m.split(","),P="",O=this.i18n.spaceAnd(),T=0;T<A.length;T++)if(T>0&&A.length>2&&(P+=",",T<A.length-1&&(P+=" ")),T>0&&A.length>1&&(T==A.length-1||A.length==2)&&(P+=O==","&&A.length>2?" ":"".concat(O," ")),A[T].indexOf("/")>-1||A[T].indexOf("-")>-1){var M=A[T].indexOf("-")>-1&&A[T].indexOf("/")==-1,F=this.getSegmentDescription(A[T],x,y,j,M?this.i18n.commaX0ThroughX1:k,C);M?F=F.replace(", ",""):T>0&&F.startsWith(", ")&&(F=F.substring(2)),P+=F}else if(!E)P+=y(A[T]);else{var I=this.getSegmentDescription(A[T],x,y,j,k,C);T>0&&I&&I.startsWith(", ")&&(I=I.substring(2)),P+=I}E?S=P:S=f.StringUtilities.format(C(m),P)}else if(E){var A=m.split("/");if(S=f.StringUtilities.format(j(A[1]),A[1]),A[0].indexOf("-")>-1){var V=this.generateRangeSegmentDescription(A[0],k,y);V.indexOf(", ")!=0&&(S+=", "),S+=V}else if(A[0].indexOf("*")==-1){var G=f.StringUtilities.format(C(A[0]),y(A[0]));G=G.replace(", ",""),S+=f.StringUtilities.format(this.i18n.commaStartingX0(),G)}S+=this.getWrappingIncrementDescription(m,N,x,y,j,k,C)}else $&&(S=this.generateRangeSegmentDescription(m,k,y));return S},b.prototype.getWrappingIncrementDescription=function(m,x,y,j,k,C,N){if(!this.options.verbose||!x)return"";var S=m.split("/"),E=S[0],$=S[1],L=parseInt($),A=x.max-x.min+1,P=E==="*",O=Number.isInteger(L)&&L>1,T=O&&A%L===0;if(!P||!O||T)return"";for(var M=[],F=x.min;F<=x.max;F+=L)M.push(F);if(M.length<2)return"";var I=this.getSegmentDescription(M.join(","),y,j,k,C,N);return I?", ".concat(I):""},b.prototype.generateRangeSegmentDescription=function(m,x,y){var j="",k=m.split("-"),C=y(k[0],1),N=y(k[1],2),S=x(m);return j+=f.StringUtilities.format(S,C,N),j},b.prototype.formatTime=function(m,x,y){var j=0,k=0,C=parseInt(m)+j,N=parseInt(x)+k;N>=60?(N-=60,C+=1):N<0&&(N+=60,C-=1),C>=24?C=C-24:C<0&&(C=24+C);var S="",E=!1;this.options.use24HourTimeFormat||(E=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),S=E?"".concat(this.getPeriod(C)," "):" ".concat(this.getPeriod(C)),C>12&&(C-=12),C===0&&(C=12));var $="";y&&($=":".concat(("00"+y).substring(y.length)));var L=C.toString(),A=("00"+L).substring(L.length),P=N.toString(),O=("00"+P).substring(P.length),T=this.options.trimHoursLeadingZero?L:A;return"".concat(E?S:"").concat(T,":").concat(O).concat($).concat(E?"":S)},b.prototype.transformVerbosity=function(m,x){if(!x&&(m=m.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),m=m.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),m=m.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),m=m.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var y=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());y<j.length;y++){var k=j[y],C=k[0],N=k[1];m=m.replace(new RegExp(C,"g"),N)}return m},b.prototype.getPeriod=function(m){return m>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},b.locales={},b})();d.ExpressionDescriptor=v},3747(l,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),h=(function(){function v(){}return v.prototype.load=function(b){b.en=new f.en},v})();d.enLocaleLoader=h},9486(l,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(h){return Number(h)===1},f=(function(){function h(){}return h.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},h.prototype.atX0MinutesPastTheHourGt20=function(){return null},h.prototype.commaMonthX0ThroughMonthX1=function(){return null},h.prototype.commaYearX0ThroughYearX1=function(){return null},h.prototype.use24HourTimeFormatByDefault=function(){return!1},h.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},h.prototype.everyMinute=function(){return"every minute"},h.prototype.everyHour=function(){return"every hour"},h.prototype.atSpace=function(){return"At "},h.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},h.prototype.at=function(){return"At"},h.prototype.spaceAnd=function(){return" and"},h.prototype.everySecond=function(){return"every second"},h.prototype.everyX0Seconds=function(v){return u(v)?"every %s second":"every %s seconds"},h.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},h.prototype.atX0SecondsPastTheMinute=function(v){return u(v)?"at %s second past the minute":"at %s seconds past the minute"},h.prototype.everyX0Minutes=function(v){return u(v)?"every %s minute":"every %s minutes"},h.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},h.prototype.atX0MinutesPastTheHour=function(v){return u(v)?"at %s minute past the hour":"at %s minutes past the hour"},h.prototype.everyX0Hours=function(v){return u(v)?"every %s hour":"every %s hours"},h.prototype.betweenX0AndX1=function(){return"between %s and %s"},h.prototype.atX0=function(){return"at %s"},h.prototype.commaEveryDay=function(){return", every day"},h.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},h.prototype.commaX0ThroughX1=function(){return", %s through %s"},h.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},h.prototype.first=function(){return"first"},h.prototype.second=function(){return"second"},h.prototype.third=function(){return"third"},h.prototype.fourth=function(){return"fourth"},h.prototype.fifth=function(){return"fifth"},h.prototype.commaOnThe=function(){return", on the "},h.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},h.prototype.lastDay=function(){return"the last day"},h.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},h.prototype.commaOnlyOnX0=function(){return", only on %s"},h.prototype.commaAndOnX0=function(){return", and on %s"},h.prototype.commaEveryX0Months=function(){return", every %s months"},h.prototype.commaOnlyInX0=function(){return", only in %s"},h.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},h.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},h.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(v){return u(v)?", %s day before the last day of the month":", %s days before the last day of the month"},h.prototype.firstWeekday=function(){return"first weekday"},h.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},h.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},h.prototype.commaDaysBeforeTheX0OfTheMonth=function(v){return u(v)?", %s day before the %s of the month":", %s days before the %s of the month"},h.prototype.commaDaysAfterTheX0OfTheMonth=function(v){return u(v)?", %s day after the %s of the month":", %s days after the %s of the month"},h.prototype.commaEveryX0Days=function(){return", every %s days in a month"},h.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},h.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},h.prototype.commaEveryHour=function(){return", every hour"},h.prototype.commaEveryX0Years=function(v){return u(v)?", every %s year":", every %s years"},h.prototype.commaStartingX0=function(){return", starting %s"},h.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},h.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},h.prototype.atReboot=function(){return"Run once, at startup"},h.prototype.onTheHour=function(){return"on the hour"},h})();d.en=f},9515(l,d){Object.defineProperty(d,"__esModule",{value:!0});function u(v,b){if(!v)throw new Error(b)}function f(v){var b=[];if(!isNaN(parseInt(v,10))){b.push(parseInt(v,10));var m=v.match(/^\d+-(-?\d+)/);m&&b.push(parseInt(m[1],10))}return b}var h=(function(){function v(){}return v.stepRange=function(b){for(var m=b.split(","),x=0;x<m.length;x++){var y=m[x].split("/")[1];u(y===void 0||!/^0+$/.test(y),"step value must be greater than 0")}},v.secondRange=function(b){for(var m=b.split(","),x=0;x<m.length;x++)for(var y=0,j=f(m[x]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},v.minuteRange=function(b){for(var m=b.split(","),x=0;x<m.length;x++)for(var y=0,j=f(m[x]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},v.hourRange=function(b){for(var m=b.split(","),x=0;x<m.length;x++)for(var y=0,j=f(m[x]);y<j.length;y++){var k=j[y];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},v.dayOfMonthRange=function(b){for(var m=b.split(","),x=0;x<m.length;x++)for(var y=0,j=f(m[x]);y<j.length;y++){var k=j[y];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},v.monthRange=function(b,m){for(var x=b.split(","),y=0;y<x.length;y++)for(var j=0,k=f(x[y]);j<k.length;j++){var C=k[j];u(C>=1&&C<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},v.dayOfWeekRange=function(b,m){for(var x=b.split(","),y=0;y<x.length;y++){if(x[y].indexOf("#")>-1){var j=x[y].substring(x[y].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,C=f(x[y]);k<C.length;k++){var N=C[k];u(N>=0&&N<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},v})();d.default=h},1823(l,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(h){for(var v=[],b=1;b<arguments.length;b++)v[b-1]=arguments[b];return h.replace(/%s/g,function(m){return v.shift()})},f.containsAny=function(h,v){return v.some(function(b){return h.indexOf(b)>-1})},f})();d.StringUtilities=u}},r={};function o(l){var d=r[l];if(d!==void 0)return d.exports;var u=r[l]={exports:{}};return s[l](u,u.exports,o),u.exports}var i={};return(()=>{var l=i;Object.defineProperty(l,"__esModule",{value:!0}),l.toString=void 0;var d=o(8333),u=o(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),l.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;l.toString=f})(),i})())})(ax)),ax.exports}var vU=bU();const yU=z1(vU),du={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Fn=du,u$={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},wU=Object.keys(u$);let jU=0;const Oh=()=>`r${++jU}`,kU=()=>({key:Oh(),pointer:"",op:"in",value:""}),f$=()=>({key:Oh(),event:"",actions:"",where:[]});function m$(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function h$(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&m$(e)===e?e:JSON.stringify(e)}const NU=e=>"in"in e?`${e.pointer} is one of ${e.in.map(h$).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,bo=(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(NU).join(" and ")}`:""}`};function p$(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(h$).join(`
|
|
678
|
-
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const g$=e=>({key:Oh(),...p$(e),was:e}),x$=e=>{if(!e.was)return!1;const n=p$(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},b$=e=>(e??[]).join(", "),$m=e=>({key:Oh(),event:e.event,actions:b$(e.actions),where:(e.where??[]).map(g$),was:e}),SU=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),CU=e=>e.split(/[\s,]+/).filter(Boolean),kN=/^[!-~]+$/,md=e=>[...e].length,_U=/^(\/([^~]|~[01])*)?$/;function $U(e,n,s){return e.length>Fn.conditions&&(s[`${n}.where`]=`At most ${Fn.conditions} conditions a rule.`),e.map((r,o)=>{if(x$(r))return r.was;const i=`${n}.where[${o}]`,l=r.pointer;if(l?l.startsWith("/")?_U.test(l)?md(l)>Fn.pointer&&(s[`${i}.pointer`]=`At most ${Fn.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:l,exists:r.op==="exists"};if(r.op==="prefix"){const u=r.value.trimStart();return u?md(u)>Fn.text&&(s[`${i}.prefix`]=`At most ${Fn.text} characters.`):s[`${i}.prefix`]="Give the text it starts with.",{pointer:l,prefix:u}}const d=r.value.split(/\r\n|\r|\n/).filter(u=>u.trim()).map(m$);return d.length?d.length>Fn.list?s[`${i}.in`]=`At most ${Fn.list} values.`:d.some(u=>md(JSON.stringify(u))>Fn.value)&&(s[`${i}.in`]=`Each value is at most ${Fn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:l,in:d}})}function EU(e,n,s){var h;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)&&(!kN.test(i)||md(i)>Fn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Fn.text}.`):s[`${r}.event`]="Name the event.";const l=o&&(typeof e.actions=="string"?e.actions===b$(o.actions):SU(e.actions,o.actions??[])),d=l?[...o.actions??[]]:typeof e.actions=="string"?CU(e.actions):e.actions;if(o&&l&&i===o.event&&e.where.length===(((h=o.where)==null?void 0:h.length)??0)&&e.where.every((v,b)=>x$(v)&&v.was===o.where[b]))return o;d.length>Fn.list?s[`${r}.actions`]=`At most ${Fn.list} actions.`:d.some(v=>!kN.test(v)||md(v)>Fn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Fn.text}.`);const f=$U(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function ly(e){const n={};return e.length>Fn.rules&&(n["source.accept"]=`At most ${Fn.rules} rules.`),{accept:e.map((s,r)=>EU(s,r,n)),issues:n}}function uu(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 l of["",".pointer",".in",".prefix",".exists"])n.add(`${o}.where[${i}]${l}`)}),n}const al=(e,n)=>n&&e===ub(n)?n:zU(e),Vl=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",v$=(e="")=>({name:"",kind:"cron",cron:"",timezone:Vl(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),Lh={seconds:1,minutes:60,hours:3600};function Em(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 y$(e){try{return yU.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Ya=e=>String(e).padStart(2,"0"),Tm=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function w$(e,n){const s=i=>{var l;return((l=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:l.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const o=s("en-GB");return/^GMT[+-]/.test(o)?r:o}const NN=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${Tm(s,n)} ${w$(s,n)}`};function SN(e,{zone:n=Vl(),now:s=Date.now()}={}){const r=new Date(e),o=l=>l.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${o(r)===o(new Date(s))?`${Tm(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${Tm(r,n)} ${w$(r,n)}`} has already passed.`}function Rm(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 TU(e,n,s,r){const o=new Date(Rm(e,n)),i=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),s,r);let l=i;for(let d=0;d<2;d++)l+=i-Rm(new Date(l),n);return new Date(l)}const RU=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 AU(e,n,s,r,o){const i=y$(e),l=n!==s,d=RU(e),u=d&&`At ${Ya(d.hour)}:${Ya(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??TU(o,n,d.hour,d.minute),h=d.days?Math.floor(Rm(f,s)/864e5)-Math.floor(Rm(f,n)/864e5):0,v=h>0?" the next day":h<0?" the day before":"";return`At ${Tm(f,s)} your time${v}${l?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${l?` (${n})`:""}`}function cy(e,n,{zone:s=Vl(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${NN(n,s)}`:" · no next time";return"cron"in e?`${AU(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${NN(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${Em(e.every_s)}${i}`}const Mh=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,OU=e=>`${Mh(e)} a run`,LU=(e,n)=>typeof e=="number"?OU(e):typeof n=="number"&&n>0?`Agent's default (${Mh(n)})`:"Agent's default";function dy(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 uy=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",fy=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",j$=e=>e.source.kind==="github"&&e.target.kind==="start_run",Ih=[{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"}],Td=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,my="This server's address as this page sees it: behind a proxy, use its public address.",db={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},k$=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>bo(s,!1)).join(" or ")}`:"On each signed request"},Am={schedule:{label:"Schedule",what:"At the times you set: every day or week at a time, every few minutes or hours, or once."},webhook:{label:"Webhook",what:"On each signed request another system sends to its URL."},github:{label:"GitHub",what:"On the events you pick from this server's GitHub App."},composio:{label:"App",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository."},feed:{label:"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."},email:{label:"Email",what:"On each new message in a mailbox of this server's email account."}},MU={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"},N$=e=>`On ${e.event} from ${e.server}`,S$=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>bo(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},C$=e=>{var s;const n=e.urls.length===1?IU(e.urls[0]):`${e.urls.length} feeds`;return(s=e.accept)!=null&&s.length?`On items in ${n} for ${e.accept.map(r=>bo(r,!1)).join(" or ")}`:`On each new item in ${n}`},IU=e=>{try{return new URL(e).host}catch{return e}},_$=e=>`On GitHub ${e.accept.map(n=>bo(n,!1)).join(" or ")}`;function Om(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 $$(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 ${li(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const PU={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},DU=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function zU(e){if(!DU.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function ub(e){const n=new Date(e);return`${n.getFullYear()}-${Ya(n.getMonth()+1)}-${Ya(n.getDate())}T${Ya(n.getHours())}:${Ya(n.getMinutes())}${n.getSeconds()?`:${Ya(n.getSeconds())}`:""}`}const CN=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function Ph(e){const n=Em(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const Rd="A number is needed.",Ad=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function _N(e,n=!1){var i,l;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()||Vl()};else if(e.kind==="at"){const d=al(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=Ad(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=Rd):s["source.every_s"]="A number is needed.";const u=e.startAt?al(e.startAt,(l=e.read)==null?void 0:l.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*Lh[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=Ad(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=Rd):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 FU=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function E$(e,n){const{accept:s,issues:r}=ly(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function UU(e,n=!1){const{source:s,issues:r}=E$({signature:e.signature},e.accept);return fu(e,s,r,n,"a webhook")}const WU=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),T$=[...new Set(Ih.map(e=>e.event))],HU=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function Dh(e){var i;const s=[...T$.flatMap(l=>{var f;const d=Ih.filter(h=>h.event===l&&e.events.includes(`${h.event}:${h.action}`)).map(h=>h.action);if(!d.length)return[];const u=(f=e.read)==null?void 0:f.rules[l];return[{id:`event:${l}`,event:l,actions:u!=null&&u.actions&&HU(d,u.actions)?[...u.actions]:d,where:e.where[l]??[],...u?{was:u}:{}}]}),...e.other.map(l=>({...l,id:`other:${l.key}`}))],r=((i=e.read)==null?void 0:i.order)??[],o=l=>{const d=r.indexOf(l.id);return d<0?r.length:d};return s.map((l,d)=>({r:l,i:d})).sort((l,d)=>o(l.r)-o(d.r)||l.i-d.i).map(({r:l})=>l)}function R$(e){const{accept:n,issues:s}=ly(Dh(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function BU(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=Ih.filter(l=>l.event===r.event).map(l=>l.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(l=>o.includes(l))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const l=$m(r);n.other.push(l),n.read.order.push(`other:${l.key}`);continue}n.events.push(...r.actions.map(l=>`${r.event}:${l}`)),n.where[r.event]=(r.where??[]).map(g$),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const hy=e=>e.source.kind==="composio"&&e.target.kind==="start_run",qU=e=>e.source.kind==="email"&&e.target.kind==="start_run";function GU(e,n=[]){const s=(e==null?void 0:e.properties)??{},r=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(o=>typeof o=="string"):[]);return Object.entries(s).filter(([,o])=>o&&typeof o=="object"&&o.deprecated!==!0).map(([o,i])=>{const l=(Array.isArray(i.type)?i.type:[i.type]).filter(h=>h!=="null"),d=l.length===1&&["string","number","integer","boolean"].includes(String(l[0]))?l[0]:"json",u=d==="string"&&Array.isArray(i.enum)&&i.enum.every(h=>typeof h=="string")?i.enum:void 0,f=i.default===void 0?d==="boolean"?"false":"":d==="json"?JSON.stringify(i.default):String(i.default);return{name:o,title:typeof i.title=="string"&&i.title.trim()?i.title:o,...typeof i.description=="string"&&i.description.trim()?{description:i.description}:{},required:r.has(o),type:d,...u?{options:u}:{},initial:f,...n.includes(o)?{sealed:!0}:{}}})}function KU(e,n,s){const r={};for(const o of e){const i=(n[o.name]??o.initial).trim(),l=`source.config.${o.name}`;if(!i){o.required&&(s[l]=`${o.title} is required.`);continue}if(o.type==="boolean")r[o.name]=i==="true";else if(o.type==="number"||o.type==="integer"){const d=Ad(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[l]=o.type==="integer"?"A whole number is needed.":Rd:r[o.name]=d}else if(o.type==="json")try{r[o.name]=JSON.parse(i)}catch{s[l]="Give it as JSON."}else r[o.name]=i}return r}const VU=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function py(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 ly([...o,...s])}function YU(e,n,s=[],r){const{accept:o,...i}=e,{accept:l,issues:d}=py(e.event,n,s,r);return{source:{...i,...l.length?{accept:l}:{}},issues:d}}function QU(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?KU(n,e.config,r):{},{accept:i,issues:l}=py(e.event,e.where);Object.assign(r,l);const d={kind:"composio",server:e.server,event:e.event,config:o,...i.length?{accept:i}:{}};return fu(e,d,r,s,"a trigger")}const A$=e=>e.source.kind==="feed"&&e.target.kind==="start_run",fb=20,O$=900,JU="item",L$=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function XU(e){const n=e.source,s=n.every_s??O$,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map($m),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...L$(),urls:n.urls.join(`
|
|
679
|
-
`),every:String(s/Lh[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 ZU=e=>{try{return new URL(e)}catch{return null}};function M$(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>fb?s["source.urls"]=`${fb} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=ZU(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 I$(e,n,s){const r=Ad(e.every),o=Math.round((r??0)*Lh[e.everyUnit]);return r===void 0?s["source.every_s"]=Rd:n&&o<n&&(s["source.every_s"]=Ph(n)),o}function P$(e,n){var u,f,h,v,b;const{urls:s,issues:r}=M$(e.urls),o=I$(e,n,r),i=m=>{var y;const x=e[m];return x||((y=e.read)==null?void 0:y[m])===""?{[m]:x}:{}},{accept:l,issues:d}=py(JU,e.where,e.others,(f=(u=e.read)==null?void 0:u.accept)!=null&&f[0]&&!((h=e.read.accept[0].actions)!=null&&h.length)?e.read.accept[0]:void 0);return Object.assign(r,d),{source:{kind:"feed",urls:s,every_s:o,...i("items"),...i("id"),...((v=e.read)==null?void 0:v.updated)!==void 0?{updated:e.read.updated}:{},...(b=e.read)!=null&&b.fields?{fields:e.read.fields}:{},...l.length?{accept:l}:{}},issues:r}}function eW(e,n,s=!1){const{source:r,issues:o}=P$(e,n);return fu(e,r,o,s,"a feed trigger")}function tW(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",...uu(n)])}const nW=()=>({name:"",mailbox:"INBOX",every:"1",everyUnit:"minutes",enabled:!0,agentId:"",content:"",maxCost:""}),sW=new Set(["name","enabled","source.mailbox","source.every_s","target.agent_id","target.input","target.max_cost_usd"]);function rW(e,n,s=!1){const r={},o=I$(e,n,r),i=fu(e,{kind:"email",mailbox:e.mailbox.trim()||"INBOX",every_s:o},r,s,"an email trigger");return i.body?{body:{...i.body,enabled:e.enabled}}:i}function oW(e,n=!1){const{source:s,issues:r}=R$(e);return fu(e,s,r,n,"a GitHub trigger")}function fu(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=Ad(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=Rd):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 aW(e){const n=e.source,s="cron"in n?n.timezone:Vl(),r={...v$(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:ub(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/Lh[o]),everyUnit:o,startAt:ub(n.start_at),read:{startAt:n.start_at}}}const Od=(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=>Od(e[o],n[o]))};function $N(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&&!Od(s,e.source)?{source:s}:{},...r&&!Od(r,e.target)?{target:r}:{}}}const iW=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function wi(e){var r;if(!(e instanceof Ue))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;(iW.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 lW=[{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"}],cW=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),dW=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),uW=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function D$({value:e,onChange:n,label:s,name:r}){const o=mU(e),[i,l]=g.useState(()=>e.trim()!==""&&!o),d=g.useId(),u=i||e.trim()!==""&&!o,f=b=>n(hU(b)),h=b=>{if(b==="custom"){l(!0);return}l(!1),f(pU(b,o))},v=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(Ft,{label:s,className:"min-w-56 flex-1",value:u?"custom":(o==null?void 0:o.kind)??"",onChange:h,placeholder:"Pick when it runs",options:lW}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Ft,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:b=>f({...o,day:Number(b)}),options:cW}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Ft,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:b=>f({...o,date:Number(b)}),options:dW}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Ft,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:b=>f({...o,minute:Number(b)}),options:uW}),!u&&o&&v&&t.jsx(Fe,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:gU(v),onChange:b=>{const m=xU(b.target.value);m&&f({...o,at:m})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Fe,{id:`${d}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:b=>n(b.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?y$(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const EN=Intl.supportedValuesOf,Ff=typeof EN=="function"?EN("timeZone"):[],Uf=Ff.length&&!Ff.includes("UTC")?["UTC",...Ff]:Ff;function z$({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!Uf.length)return t.jsx(Fe,{id:o,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const l=e&&!Uf.includes(e)?[e,...Uf]:Uf;return t.jsx(Ft,{id:o,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:l.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function fW(e,n){var i,l,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}(l=n.fileIds)!=null&&l.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 mW(e,n){return s=>{var o,i,l,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:((l=e.definitions)==null?void 0:l[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 hW(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 pW(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?F$(s,(n==null?void 0:n.schemas)??{}):null}function F$(e,n={}){var u;const s=mW(e,n),r=s(e),o=Object.entries(r.properties??{}).map(([f,h])=>{const v=s(h);return{name:f,...v!=null&&v.description?{note:v.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 l=(f,h=0)=>{var m,x;const v=s(f);if(!v||h>4)return null;if((m=v.examples)!=null&&m.length)return v.examples[0];if(v.default!==void 0)return v.default;if((x=v.enum)!=null&&x.length)return v.enum[0];const b=Array.isArray(v.type)?v.type[0]:v.type;return b==="object"||v.properties?Object.fromEntries(Object.entries(v.properties??{}).filter(([y])=>(v.required??[]).includes(y)).map(([y,j])=>[y,l(j,h+1)])):b==="array"?[]:b==="string"?"":b==="number"||b==="integer"?0:b==="boolean"?!1:null},d=new Set(r.required??[]);return{text:JSON.stringify(l(r),null,2),from:"shape",fields:o,optional:o.map(f=>f.name).filter(f=>!d.has(f))}}const ix=e=>`'${e.replace(/'/g,"'\\''")}'`;function gW(e,n,s,r){return[`curl -X POST ${ix(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${ix(`Idempotency-Key: ${r}`)} \\`,` -d ${ix(JSON.stringify(s))}`].join(`
|
|
680
|
-
`)}const xW=e=>e>=200&&e<300;async function bW(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return xW(o.status)&&e.done(),o}const fa=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?xy(n[r]).join(", "):"")||"…"),U$=e=>`#/templates/${encodeURIComponent(e)}`;function bl(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 vW(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),l=b=>b!==null&&typeof b=="object"&&!Array.isArray(b);if(!l(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=(b,m)=>b==="boolean"?typeof m=="boolean":b==="string"?typeof m=="string":(b==="number"||b==="integer")&&typeof m=="number"&&Number.isFinite(m);if(!l(d)||Object.keys(d).some(b=>!["parameters","grants","servers","overrides"].includes(b))||!l(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(b=>typeof b!="string"||!n.mcp.some(m=>m.tools.some(x=>x.tool===b))))||d.servers!==void 0&&(!l(d.servers)||Object.entries(d.servers).some(([b,m])=>!n.mcp.some(x=>x.toolkit===b)||typeof m!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(m)))||!l(d.overrides)||Object.keys(d.overrides).some(b=>b!=="approvals"&&b!=="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(b=>b.id).includes(d.overrides.choice))))return s;const f=zh(n.parameters);if(!f)return s;const h=new Map(f),v=[];for(const[b,m]of Object.entries(d.parameters)){const x=h.get(b);if(!x)return s;if(m==="")continue;if(x.array?!Array.isArray(m)||!m.every(k=>u(x.type,k)):!u(x.type,m))return s;const y=Array.isArray(m)?m.map(String).join(`
|
|
681
|
-
`):String(m),j=Uh({fields:[[b,x]],contentRequired:!1},{[b]:y})[b];if(JSON.stringify(j)!==JSON.stringify(m))return s;v.push([b,m])}return{body:{...d,parameters:Object.fromEntries(v)}}}catch{return s}}const yW=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function gy(e,{secrets:n=!0,mcp:s=!0}={}){var o,i,l;const r=[];return n&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(d=>`${d.toolkit} (${nu[d.source]}${d.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",yW(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${Qd(e.budget.per_run_usd)} a run`]),(i=e.budget)!=null&&i.max_requests&&r.push(["Free-model requests",`at most ${e.budget.max_requests} a run`]),(l=e.harness)!=null&&l.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function mu(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 wW(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:mu(s)?[]:s.format==="timezone"?[[n,Vl()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const jW=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function kW(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=Kv.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const Lm=e=>e.mcp.length===0&&e.secrets.length===0,NW=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},TN=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>NW(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],SW=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),CW=(e,n)=>e.filter(s=>s.field===n);function Mm(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 _W(e){const n=mu(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 $W(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: ${W$(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const W$=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):mu(e)??[]};function H$(e,n){var l;if(e.array){const d=xy(n);return d.length?d.every(u=>H$({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=mu(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")&&(!((l=e.enum)!=null&&l.length)||W$(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 xy=e=>(e??"").split(`
|
|
682
|
-
`).map(n=>n.trim()).filter(n=>n!==""),by=H$,ei=e=>!!e&&typeof e=="object"&&!Array.isArray(e),EW=new Set(["string","number","integer","boolean"]),TW=["oneOf","anyOf","allOf","not","if","$ref","const"],mb=e=>TW.some(n=>n in e),Wf=e=>typeof e=="string"?e:void 0,Hf=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,RW=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function AW(e,n){if(!ei(e)||mb(e))return null;const s=e.type==="array",r=s?e.items:e;if(!ei(r)||mb(r)||typeof r.type!="string"||!EW.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 RW({type:r.type,...s?{array:!0}:{},required:n,title:Wf(e.title),description:Wf(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:Wf(r.pattern),format:Wf(r.format),minimum:Hf(r.minimum),maximum:Hf(r.maximum),minLength:Hf(r.minLength),maxLength:Hf(r.maxLength)})}function zh(e,n){const s=ei(e)&&ei(e.properties)?e.properties:{},r=ei(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,l]of Object.entries(s)){if(i===n)continue;const d=AW(l,r.includes(i));if(!d)return null;o.push([i,d])}return o}function OW(e){if(!ei(e))return{kind:"message"};const n=()=>({kind:"json",example:F$(e)});if(mb(e))return n();const s=ei(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=zh(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")}}:{kind:"message"}:n()}const Fh=(e,n)=>n.title||e;function LW(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(`
|
|
683
|
-
`):typeof n=="object"?JSON.stringify(n):String(n)}function MW(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=xy(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 B$(e){const n=wW(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:mu(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function Uh(e,n){const s={};for(const[r,o]of e.fields){const i=MW(o,n[r]);i!==void 0&&(s[r]=i)}return s}const IW=(e,n,s)=>({...n.trim()?{content:n}:{},...Uh(e,s)}),hb=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,PW=(e,n)=>e?n==null?void 0:n.find(s=>s.field==="input.content"):void 0,DW=(e,n,s)=>!e.contentRequired&&s!==""&&by(n,s),q$=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",zW={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},FW=e=>e.array?`a list of ${zW[e.type]}`:q$(e);function G$(e,n,s){var o;const r=Fh(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 ${q$(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(", ")}.`:$W(e,n,s,r)}const UW={date:"date",email:"email",uri:"url"};function K$({field:e,label:n,help:s,value:r,onChange:o}){const i=LW(e),l=_W(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."]})]}),l?t.jsx(Ft,{label:n,className:"w-full",value:r,onChange:o,options:l}):e.array?t.jsx(An,{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(D$,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(z$,{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(Fe,{type:e.type==="string"?UW[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 oa({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 V$={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."},WW='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.',hd=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,Ar=({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 Wh({name:e,at:n,where:s,onChange:r,issues:o,label:i}){const l=(f,h)=>r(s.map((v,b)=>b===f?{...v,...h}:v)),d=(f,h)=>l(f,h==="prefix"?{op:h,value:s[f].value.split(/\r\n|\r|\n/).find(v=>v.trim())??""}:{op:h}),u=s.length>=du.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(Ar,{issues:o,field:`${n}.where`}),s.map((f,h)=>{const v=`${n}.where[${h}]`,b=`${e}-where-${h}`;return t.jsxs("div",{"data-condition":b,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(gt,{label:"Field",className:"min-w-40 flex-1",error:hd(o,`${v}.pointer`),children:t.jsx(Fe,{name:`${b}-pointer`,value:f.pointer,onChange:m=>l(h,{pointer:m.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(eo,{name:`${b}-op`,label:`Condition ${h+1}'s test`,value:f.op,onChange:m=>d(h,m),options:wU.map(m=>({value:m,label:u$[m]}))}),t.jsx(W,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${h+1}`,onClick:()=>r(s.filter((m,x)=>x!==h)),children:t.jsx(Oo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(gt,{label:"Values",hint:WW,error:hd(o,`${v}.in`),children:t.jsx(An,{name:`${b}-value`,rows:3,value:f.value,onChange:m=>l(h,{value:m.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(gt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:hd(o,`${v}.prefix`),children:t.jsx(Fe,{name:`${b}-value`,value:f.value,onChange:m=>l(h,{value:m.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(Ar,{issues:o,field:v}),t.jsx(Ar,{issues:o,field:`${v}.exists`})]},f.key)}),t.jsxs(W,{type:"button",size:"sm",onClick:()=>r([...s,kU()]),disabled:u,children:[t.jsx(Qm,{"aria-hidden":!0})," Add a condition"]})]})}function Y$({name:e,rules:n,onChange:s,issues:r,indexOf:o=h=>h,room:i,eventHint:l,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const h=(v,b)=>s(n.map((m,x)=>x===v?{...m,...b}:m));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((v,b)=>{const m=`source.accept[${o(b)}]`,x=`${e}-${b}`;return t.jsxs("section",{"data-rule":x,"aria-label":`Rule ${b+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 ",b+1]}),t.jsxs(W,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${b+1}`,onClick:()=>s(n.filter((y,j)=>j!==b)),children:[t.jsx(nS,{"aria-hidden":!0})," Remove"]})]}),t.jsx(Ar,{issues:r,field:m}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(gt,{label:"Event",hint:l,error:hd(r,`${m}.event`),children:t.jsx(Fe,{name:`${x}-event`,value:v.event,onChange:y=>h(b,{event:y.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(gt,{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:hd(r,`${m}.actions`),children:t.jsx(Fe,{name:`${x}-actions`,value:v.actions,onChange:y=>h(b,{actions:y.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(Wh,{name:x,at:m,where:v.where,onChange:y=>h(b,{where:y}),issues:r,label:"Only when"})]},v.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(W,{type:"button",size:"sm",onClick:()=>s([...n,f$()]),disabled:i<=0,children:[t.jsx(Qm,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[du.rules," rules, the most a trigger takes."]})]})]})}const vy=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function HW(e,n){if(vy(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 BW=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0},Q$=e=>/\.onrender\.com$/i.test(e),J$=e=>/\.up\.railway\.app$/i.test(e);function qW(e){const n="find the newest line that starts “Set up this server:”. Open that line's link, or paste what follows code= here.";return Q$(e)?["This server is on Render. In the Render dashboard, open this service's Environment tab and paste the value of AGENTRUN_TOKEN here.",`Or open the service's Logs tab and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Logs tab. AGENTRUN_TOKEN does not expire."]:J$(e)?["This server is on Railway. In the Railway dashboard, open this service's Variables tab and paste the value of AGENTRUN_TOKEN here.",`Or open the Deploy Logs of the service's latest deployment and ${n}`,"A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the Deploy Logs. AGENTRUN_TOKEN does not expire."]:[`The server printed it in its log: ${n}`,"The log is the terminal the server runs in. Installed as a service: agentrun open opens this page with the code filled in, or agentrun service logs shows the log. A systemd unit of your own: journalctl --user -u <unit>. In Docker: docker logs <container>, or docker compose logs. On Render: the service's Logs tab.","A code works once and lasts 30 minutes. When it has run out, Get a new code below prints a fresh one in the log. The server's API token works here too and does not expire: AGENTRUN_TOKEN (on Render, in the service's Environment tab), else the .token file in the server's data folder."]}function GW(e,n){const r=`it is the newest “Set up this server:” line in ${Q$(e)?"the service's Logs tab in the Render dashboard":J$(e)?"the Deploy Logs of the service's latest deployment in the Railway dashboard":"the server's log (the terminal it runs in, docker logs <container>, or Render's Logs tab)"}.`;return n.printed?`The server printed a new code: ${r} It works once, until ${li(n.expires_at)}.`:`The current code is still good until ${li(n.expires_at)}, so no new one was printed: ${r}`}const KW=e=>{const n=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Try again in ${n===1?"a second":n>=60?"a minute":`${n} seconds`}.`};function VW(e){return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.message}function YW(e){var n,s;return e.status===401?"That is not the password.":e.status===429?`Too many sign-ins. ${KW(e)}`: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 (a code lasts 30 minutes) or was voided after too many wrong tries. The server printed a new one: use the newest “Set up this server:” line in its 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. A code works once and lasts 30 minutes: Get a new code prints a fresh one when it has run out.":((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function X$(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 pb=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`,Z$={waits:"Waits for your approval",refused:"Refused without your approval"},QW=(e,n="waits",s=!1)=>n==="refused"?`A run from this trigger is refused each call of ${pb(e)}: each needs your approval, and this server has accounts off, so no one can give it.`:`A run from this trigger stops and waits for you when it calls ${pb(e)}${s?"; later firings are skipped while it waits":""}.`,JW="Run unattended: this agent's tools run without asking when no one is there.";function eE(e){return!e||e.kind==="workflow"||e.definition.approvals==="never"?[]:(e.tools??[]).filter(n=>n.permission==="ask").map(n=>n.name)}function XW({tools:e,outcome:n="waits",skips:s=!1,busy:r=!1,failed:o,onFix:i,className:l}){return t.jsxs(ct,{tone:"warning","data-unattended-warning":"",className:l,title:Z$[n],actions:t.jsx(W,{type:"button",size:"sm",disabled:r,"aria-busy":r||void 0,onClick:i,children:r?"Saving":"Run unattended"}),children:[t.jsx("p",{className:"break-words",children:QW(e,n,s)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:JW}),o&&t.jsx("p",{role:"alert",className:"mt-2 break-words font-mono text-small text-destructive-text",children:o})]})}function tE(e,n){const[s,r]=g.useState("waits");return g.useEffect(()=>{if(!n)return;let o=!0;return e.session().then(i=>{o&&r(vy(i)?"refused":"waits")},()=>{}),()=>{o=!1}},[e,n]),s}function nE({v2:e,agentId:n,skips:s=!1,className:r}){const[o,i]=g.useState(null),[l,d]=g.useState(!1),[u,f]=g.useState(null),h=eC();g.useEffect(()=>{if(i(null),f(null),!n)return;let y=!0;return e.getAgent(n).then(j=>{y&&i(j.agent)},()=>{}),()=>{y=!1}},[e,n]);const v=eE(o),b=!!o&&o.agent_id===n&&v.length>0,m=tE(e,b);if(!b)return null;const x=async()=>{d(!0),f(null);try{const{agent:y,etag:j}=await e.getAgent(o.agent_id),k=Gl(y,{approvals:"never"},"Run unattended"),{unchanged:C,...N}=k,S=C?y:(await e.updateDefinition(o.agent_id,N,j)).agent;i(E=>(E==null?void 0:E.agent_id)===S.agent_id?{...S,tools:E.tools}:E),h({title:`${S.definition.name||S.agent_id} runs unattended`,tone:"success"})}catch(y){const j=Yt(y,"the agent");f(`Not saved: ${j.said??j.why} ${j.next}`)}d(!1)};return t.jsx(XW,{tools:v,outcome:m,skips:s,busy:l,failed:u,onFix:()=>void x(),className:r})}function ZW(e,n){const[s,r]=g.useState({}),o=g.useRef(new Set),i=g.useRef(!0);g.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const l=[...new Set(n)].sort().join(`
|
|
684
|
-
`);g.useEffect(()=>{for(const u of l?l.split(`
|
|
685
|
-
`):[])o.current.has(u)||(o.current.add(u),e.getAgent(u).then(f=>{const h=eE(f.agent);i.current&&h.length&&r(v=>({...v,[u]:h}))},()=>{}))},[e,l]);const d=tE(e,Object.keys(s).length>0);return{asks:s,outcome:d}}const e9=(e,n="waits")=>`${Z$[n]}: ${pb(e)}`,Xn=e=>`#/triggers/${encodeURIComponent(e)}`,Ll=e=>ht(e),t9={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function n9({v2:e,view:n,go:s,agentName:r,minEvery:o,failuresToPause:i,publicUrl:l,refreshMs:d=15e3,now:u=Date.now}){const f=l===!1;return n.trigger===void 0?t.jsx(a9,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(x9,{v2:e,go:s}):n.kind==="github"?t.jsx(b9,{v2:e,go:s}):n.kind==="composio"?t.jsx(v9,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(fE,{v2:e,go:s,minEvery:o}):n.kind==="email"?t.jsx(p9,{v2:e,go:s,minEvery:o}):t.jsx(lE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(u9,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(d9,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function sE(e,n,s){const r=g.useRef(e);r.current=e,g.useEffect(()=>{const o=()=>document.visibilityState!=="hidden",i=setInterval(()=>{o()&&r.current()},n),l=()=>{o()&&r.current()};return document.addEventListener("visibilitychange",l),()=>{clearInterval(i),document.removeEventListener("visibilitychange",l)}},[n,...s])}const rE=e=>e?"ran"in e?`Done · ran ${Ll(e.ran.nominal_at)}`:`Its time passed · ${Ll(e.passed)}`:null,s9=/has already passed\.?$/;function oE({trigger:e}){return e.disabled?t.jsx(ke,{tone:"warning",children:"Turned off"}):t.jsx(ke,{tone:"muted",children:"Paused"})}const r9=e=>e.last_firing?`${$$(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${Ll(e.last_firing.nominal_at)}`:"Not fired yet",o9=e=>`${e.ok?"Checked":"Check failed"} ${Ll(e.at)}: ${e.message}`,yy="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function a9({v2:e,go:n,agentName:s,every:r,now:o,failuresToPause:i,noAddress:l}){const[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState(0),m=g.useRef(!1),x=g.useRef(!0);g.useEffect(()=>(x.current=!0,()=>{x.current=!1}),[]);const y=()=>{m.current||(m.current=!0,e.listTriggers().then(N=>{x.current&&(u(N.triggers),h(null))},N=>{x.current&&h(Yt(N,"the triggers"))}).finally(()=>{m.current=!1}))};g.useEffect(y,[e,v]),sE(y,r,[e]);const j=N=>N.target.kind==="start_run"?N.target.agent_id:null,{asks:k,outcome:C}=ZW(e,(d??[]).flatMap(N=>j(N)??[]));return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Triggers",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap justify-between gap-3 px-5"),children:[t.jsxs("h1",{className:ha,children:[t.jsx(Wd,{className:"size-4","aria-hidden":!0}),"Triggers"]}),!(d&&!d.length)&&t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[t.jsxs(W,{size:"sm",disabled:l,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(Hm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(W,{size:"sm",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(Gm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(W,{size:"sm",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(kl,{"aria-hidden":!0})," New webhook"]}),t.jsxs(W,{size:"sm",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(Ib,{"aria-hidden":!0})," New feed trigger"]}),t.jsxs(W,{size:"sm",onClick:()=>n("#/triggers/new-email"),children:[t.jsx(Vm,{"aria-hidden":!0})," New email trigger"]}),t.jsxs(W,{size:"sm",variant:"primary",onClick:()=>n("#/triggers/new"),children:[t.jsx(Qm,{"aria-hidden":!0})," New schedule"]})]})]}),t.jsxs("div",{className:"px-5 py-5 md:py-6",children:[l&&d&&d.length>0&&t.jsx("p",{className:"mb-4 text-small text-muted-foreground",children:yy}),f&&!d?t.jsx(on,{problem:f,onRetry:()=>b(N=>N+1),className:""}):d?d.length?t.jsx("ul",{className:"border",children:d.map(N=>t.jsxs("li",{"data-trigger":N.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:Xn(N.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:N.name}),t.jsx(ke,{children:Am[N.source.kind].label}),!N.enabled&&!dy(N,o())&&t.jsx(oE,{trigger:N})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:aE(N),children:l9(N,s,o())}),Om(N,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:Om(N,i)}),k[j(N)??""]&&t.jsx("p",{"data-asks":"",className:"mt-1 break-words text-small text-warning-text",children:e9(k[j(N)],C)})]}),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:r9(N)}),N.last_check&&t.jsx("p",{"data-last-check":N.last_check.ok?"ok":"failed",className:`mt-1 break-words ${N.last_check.ok?"":"text-warning-text"}`,children:o9(N.last_check)})]})]},N.id))}):t.jsx(i9,{go:n,noAddress:l}):t.jsx(cs,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(on,{problem:f,className:"mt-4"})]})]})}function i9({go:e,noAddress:n}){const s=(o,i="")=>`${Am[o].what}${i?` ${i}`:""}`,r=[{Icon:Wd,name:"Schedule",what:s("schedule"),action:"New schedule",to:"#/triggers/new"},{Icon:kl,name:"Webhook",what:s("webhook"),action:"New webhook",to:"#/triggers/new-webhook"},{Icon:Gm,name:"GitHub",what:s("github","Connect GitHub in Settings first."),action:"New GitHub trigger",to:"#/triggers/new-github"},{Icon:Hm,name:"From an app",what:s("composio","Save the server in Settings first."),action:"New app trigger",to:"#/triggers/new-composio"},{Icon:Ib,name:"Feed",what:s("feed"),action:"New feed trigger",to:"#/triggers/new-feed"},{Icon:Vm,name:"Email",what:s("email","Save the account in Settings → Email first."),action:"New email trigger",to:"#/triggers/new-email"}];return t.jsxs("section",{"aria-labelledby":"first-trigger",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",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:r.map(({Icon:o,name:i,what:l,action:d,to:u})=>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(o,{className:"size-4 text-muted-foreground","aria-hidden":!0}),i]}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:l}),n&&u==="#/triggers/new-composio"&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:yy}),t.jsx(W,{size:"sm",className:"mt-4 self-start",disabled:n&&u==="#/triggers/new-composio",onClick:()=>e(u),children:d})]},i))})]})}const aE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function l9(e,n,s){return`${e.source.kind==="schedule"?cy(e.source,e.next_at,{instead:rE(dy(e,s)),now:s}):e.source.kind==="github"?_$(e.source):e.source.kind==="composio"?N$(e.source):e.source.kind==="email"?S$(e.source):e.source.kind==="feed"?C$(e.source):k$(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${ka(e.target.run_id)}`}`}const lx=e=>e.name||e.slug,c9={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function iE(){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(Wn,{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 d9({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:l}){var Ie,We,rt,ot,wt,jt;const[d,u]=g.useState(null),[f,h]=g.useState([]),[v,b]=g.useState(null),[m,x]=g.useState(null),[y,j]=g.useState(null),[k,C]=g.useState(!1),[N,S]=g.useState(!1),[E,$]=g.useState(null),L=g.useRef(!1),[A,P]=g.useState(!1),[O,T]=g.useState(null),[M,F]=g.useState(null),[I,V]=g.useState(null),[G,q]=g.useState(0),H=g.useRef(!1),U=g.useRef(!1),Q=g.useRef(0),D=()=>{U.current=!0;const we=Q.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([ze,st])=>{we===Q.current&&(u(ze),h(st.firings),b(null))}).finally(()=>{U.current=!1})};g.useEffect(()=>{D().catch(we=>b(Yt(we,"the trigger")))},[e,r,G]),sE(()=>{!U.current&&!H.current&&I===null&&D().catch(()=>{})},o,[e,r]);const[Y,K]=g.useState(void 0),Z=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;g.useEffect(()=>{if(!Z)return;let we=!0;return e.getAgent(Z).then(ze=>{we&&K(typeof ze.agent.definition.max_cost_usd=="number"?ze.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{we=!1}},[e,Z]);const se=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;g.useEffect(()=>{if(!se)return;let we=!0;return e.composioTriggers(se).then(ze=>{var st;we&&T(((st=ze.triggers.find(xe=>xe.id===r))==null?void 0:st.on_composio)??"unknown")},()=>{we&&T(null)}),()=>{we=!1}},[e,se,r,d==null?void 0:d.enabled]);const[ie,Ne]=g.useState(void 0),he=(d==null?void 0:d.source.kind)==="email";if(g.useEffect(()=>{if(!he)return;let we=!0;return e.emailAccount().then(ze=>{we&&Ne(ze.configured?ze.address:null)},()=>{}),()=>{we=!1}},[e,he]),I!==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(Wn,{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:I}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return v?t.jsx(on,{problem:v,onRetry:()=>q(we=>we+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(cs,{label:"Loading the trigger",rows:4});const ve=fy(d)?d:null,Ee=j$(d)?d:null,ye=hy(d)?d:null,pe=A$(d)?d:null,Pe=qU(d)?d:null;if(!ve&&!Ee&&!ye&&!pe&&!Pe&&!uy(d))return t.jsx(iE,{});const ue=d,ge=dy(d,i(),f),Te=async(we,ze,st)=>{j(we),x(null);try{await ze()}catch(xe){x(Yt(xe,st))}finally{j(null)}},Xe=()=>Te("pause",async()=>{Q.current++,F(null);const{composio:we,...ze}=await e.updateTrigger(r,{enabled:!d.enabled});Q.current++,u(ze),F((we==null?void 0:we.note)??null)},d.enabled?"the pause":"the resume"),je=()=>Te("delete",async()=>{const we=await e.deleteTrigger(r);we!=null&&we.composio?V(we.composio.note):n("#/triggers")},"the delete"),fe=async()=>{if(!L.current){L.current=!0,P(!0),x(null),$(null);try{$((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(we){x(Yt(we,"the new secret"))}finally{L.current=!1,P(!1)}}},De=async()=>{if(!H.current){H.current=!0,j("fire"),x(null),Q.current++;try{const we=await e.fireTrigger(r,lu());Q.current++,h(ze=>[we,...ze.filter(st=>st.key!==we.key)]),await D().catch(()=>{})}catch(we){x(Yt(we,"the run now"))}finally{H.current=!1,j(null)}}},te=typeof ue.target.input.content=="string"?ue.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(Wn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[t.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[d.name,!d.enabled&&!ge&&t.jsx(oE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:ve?`Webhook · ${k$(ve.source)}`:Ee?`GitHub · ${_$(Ee.source)}`:ye?`App · ${N$(ye.source)}`:pe?`Feed · ${C$(pe.source)}`:Pe?`Email · ${S$(Pe.source)}`:t.jsx("span",{title:aE(d),children:cy(ue.source,d.next_at,{instead:rE(ge),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(ge&&"ran"in ge)&&t.jsx(W,{size:"sm",onClick:()=>void Xe(),disabled:y!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(jl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Ao,{"aria-hidden":!0})," Resume"]})}),!Pe&&t.jsxs(W,{size:"sm",onClick:()=>n(`${Xn(r)}/edit`),children:[t.jsx(Ym,{"aria-hidden":!0})," ",ve||Ee||ye?"Edit filter":pe?"Edit feed":"Edit"]}),ve&&(N?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(W,{size:"sm",variant:"solid",onClick:()=>{S(!1),fe()},children:"Yes, make a new one"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:"Keep"})]}):t.jsxs(W,{size:"sm",onClick:()=>S(!0),disabled:y!==null||A,children:[t.jsx(ti,{"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(W,{size:"sm",variant:"destructive",onClick:()=>{C(!1),je()},children:"Yes, delete"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>C(!1),children:"Keep"})]}):t.jsxs(W,{size:"sm",variant:"destructive",onClick:()=>C(!0),disabled:y!==null,children:[t.jsx(nS,{"aria-hidden":!0})," Delete"]}),t.jsxs(W,{size:"sm",variant:"solid",onClick:()=>void De(),disabled:y==="fire",children:[t.jsx(RA,{"aria-hidden":!0})," ",y==="fire"?"Starting":"Run now"]})]})]}),Om(d,l)&&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:[Om(d,l)," ",((Ie=d.disabled)==null?void 0:Ie.reason)==="source_unreadable"?pe?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((We=d.disabled)==null?void 0:We.reason)==="auto_paused"?ge&&"passed"in ge?"Its time has passed: edit its time first, then Resume.":ge?"":"Resume turns it on again.":""]}),m&&t.jsx(on,{problem:m,className:"mt-4"}),d.target.kind==="start_run"&&t.jsx(nE,{v2:e,agentId:d.target.agent_id,skips:d.source.kind==="schedule",className:"mt-4"}),M&&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:M}),ve&&E&&t.jsx(wy,{label:"The webhook's new secret",secret:E}),(pe||Pe)&&t.jsx(k9,{check:d.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:jn(ue.target.agent_id),className:"hover:underline",children:s(ue.target.agent_id)||ue.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:te??JSON.stringify(ue.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:LU(ue.target.max_cost_usd,Y)}),ve?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:Td(ve)}),t.jsx(nv,{text:Td(ve),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:my})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:db[ve.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:(rt=ve.source.accept)!=null&&rt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ve.source.accept.map((we,ze)=>t.jsx("li",{children:bo(we)},ze))}):"Every signed request"})]}):ye?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:ye.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:ye.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(ye.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(ye.source.config).map(([we,ze])=>{var st;return t.jsxs("li",{children:[we,": ",(st=ye.source.sealed_config)!=null&&st.includes(we)?t.jsx("span",{"data-sealed-config":we,className:"text-muted-foreground",children:"Sealed: kept here, never shown"}):typeof ze=="string"?ze:JSON.stringify(ze)]},we)})}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(ot=ye.source.accept)!=null&&ot.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ye.source.accept.map((we,ze)=>t.jsx("li",{children:bo(we)},ze))}):"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:O?t.jsx("span",{"data-on-composio":O,className:O==="missing"?"text-warning-text":void 0,children:c9[O]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):Ee?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:Ee.source.accept.map((we,ze)=>t.jsx("li",{children:bo(we)},ze))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):pe?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:pe.source.urls.map(we=>t.jsx("li",{className:"break-all",children:Rr(we)?t.jsx("a",{href:Rr(we),target:"_blank",rel:"noreferrer",className:"hover:underline",children:we}):we},we))})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",Em(pe.source.every_s??O$)]}),(pe.source.items!==void 0||pe.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 ",pe.source.items?pe.source.items:"the whole document"," · Id at ",pe.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:(wt=pe.source.accept)!=null&&wt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:pe.source.accept.map((we,ze)=>t.jsx("li",{children:bo(we)},ze))}):"Every new or updated item"})]}):Pe?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Account"}),t.jsxs("dd",{className:"min-w-0 break-words","data-mail-account":!0,children:[ie?t.jsx("span",{className:"font-mono",children:ie}):ie===null?t.jsx("span",{className:"text-warning-text",children:"None saved"}):"This server's email account",t.jsxs("span",{className:"text-small text-muted-foreground",children:[" · ",t.jsx("a",{href:"#/settings/email",className:"hover:underline",children:"Settings → Email"})]})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Mailbox"}),t.jsx("dd",{className:"min-w-0 break-words font-mono",children:Pe.source.mailbox}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",Em(Pe.source.every_s)]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(jt=Pe.source.accept)!=null&&jt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Pe.source.accept.map((we,ze)=>t.jsx("li",{children:bo(we)},ze))}):"Every new message"})]}):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(we=>t.jsxs("li",{"data-firing":we.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:t9[we.status],children:PU[we.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Ll(we.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:we.status==="started"?`${MU[we.by]}${we.catch_up?", caught up late":""}`:`${$$(we)}${we.catch_up?" · caught up late":""}${we.by==="manual"?" · Run now":""}`}),we.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(we.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",ka(we.run_id)]})]},we.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function u9({v2:e,go:n,id:s,minEvery:r,now:o}){const[i,l]=g.useState(null),[d,u]=g.useState(null),[f,h]=g.useState(0);return g.useEffect(()=>{e.getTrigger(s).then(l,v=>u(Yt(v,"the trigger")))},[e,s,f]),i?fy(i)||j$(i)||hy(i)?t.jsx(j9,{v2:e,go:n,trigger:i}):A$(i)?t.jsx(fE,{v2:e,go:n,trigger:i,minEvery:r}):uy(i)?t.jsx(lE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(iE,{}):d?t.jsx(on,{problem:d,onRetry:()=>h(v=>v+1)}):t.jsx(cs,{label:"Loading the trigger",rows:4})}function wn({label:e,field:n,issue:s,hint:r,required:o,children:i}){return t.jsx(gt,{className:"min-w-0",label:e,required:o,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:i})}const f9=e=>e!==void 0?`${Mh(e)}, the agent's default`:void 0,m9=(e,n)=>{var r;const s=(r=(e??[]).find(o=>o.agent_id===n))==null?void 0:r.definition.max_cost_usd;return typeof s=="number"&&s>0?s:void 0};function Yl({v2:e,draft:n,set:s,issues:r,agents:o,agentCap:i,capOptional:l,what:d,asked:u,skips:f}){const h=PC((o??[]).filter(v=>!v.archived_at||v.agent_id===n.agentId));return t.jsxs(t.Fragment,{children:[t.jsx(wn,{label:"Agent",field:"target.agent_id",issue:r["target.agent_id"],required:!0,children:t.jsx(Ft,{name:"agent",label:"Agent",className:"w-full",value:n.agentId,onChange:v=>s("agentId")(v),options:[{value:"",label:o?"Pick an agent":"Loading the agents"},...h.map(v=>({value:v.agent_id,label:`${v.definition.name||v.agent_id}${v.kind==="workflow"?" (workflow)":""}`})),...n.agentId&&o&&!h.some(v=>v.agent_id===n.agentId)?[{value:n.agentId,label:n.agentId}]:[]]})}),t.jsx(nE,{v2:e,agentId:n.agentId,skips:f}),t.jsx(wn,{label:"Each run is asked",field:"target.input",issue:r["target.input"],required:!0,hint:u,children:t.jsx(An,{name:"content",rows:4,className:"p-3 font-sans",value:n.content,onChange:v=>s("content")(v.target.value)})}),t.jsx(wn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:r["target.max_cost_usd"],required:!l,hint:i!==void 0?`Uses the agent's default (${Mh(i)}) if empty.`:l?"Uses the agent's default if empty.":`Each run this ${d} starts stops at this spend.`,children:t.jsx(Fe,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:n.maxCost,onChange:v=>s("maxCost")(v.target.value),placeholder:f9(i)})})]})}async function h9(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 Ql(e,n,s=!0){const[r,o]=g.useState(null),[i,l]=g.useState({}),[d,u]=g.useState([]),[f,h]=g.useState(!1),v=g.useRef(yi()).current,b=g.useRef(!0);g.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),g.useEffect(()=>{s&&h9(e).then(o,()=>o([]))},[e,s]);const m=m9(r,n);return{agents:r,agentCap:m,capOptional:m!==void 0,issues:i,setIssues:l,rest:d,setRest:u,saving:f,setSaving:h,keys:v,open:b,refused:(y,j)=>{l(Object.fromEntries(Object.entries(y.fields).filter(([k])=>j.has(k)))),u([...y.rest,...Object.entries(y.fields).filter(([k])=>!j.has(k)).map(([,k])=>k)])}}}function lE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var T,M;const[i,l]=g.useState(()=>s?aW(s):v$()),{agents:d,agentCap:u,issues:f,setIssues:h,rest:v,setRest:b,saving:m,setSaving:x,keys:y,refused:j}=Ql(e,i.agentId),k=F=>I=>l(V=>({...V,[F]:I})),C=F=>{var V;k("at")(F);const I=al(F,(V=i.read)==null?void 0:V.at);I!==null&&Date.parse(I)>o()?h(({"source.at":G,...q})=>q):I!==null&&h(G=>G["source.at"]?{...G,"source.at":SN(I,{now:o()})}:G)},N=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=u!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&i.agentId===s.target.agent_id,E=async F=>{var G;F.preventDefault();const{body:I,issues:V}=_N(i,S);if(b([]),!I){h(V??{});return}h({}),x(!0);try{if(s){const q=$N(s,I);Object.keys(q).length&&await e.updateTrigger(s.id,q),n(Xn(s.id))}else{const q=await e.createTrigger(I,y.keyFor("createTrigger",I));n(Xn(q.id))}}catch(q){const H=wi(q),U=i.kind==="at"?al(i.at,(G=i.read)==null?void 0:G.at):null,Q=H.fields["source.at"];Q&&U!==null&&(Date.parse(U)<=o()||s9.test(Q))&&(H.fields["source.at"]=SN(U,{now:o()})),j(H,N),x(!1)}},$=s?_N(i,S).body:void 0,L=!!(s&&$&&$N(s,$).source),A=i.kind==="at"?al(i.at,(T=i.read)==null?void 0:T.at):null,P=i.startAt?al(i.startAt,(M=i.read)==null?void 0:M.startAt):null,O=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:F=>void E(F),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Xn(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(Wn,{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(Wd,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),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((F,I)=>t.jsx("p",{children:F},I))}),t.jsxs("div",{className:`mt-5 ${Hl}`,children:[t.jsx(wn,{label:"Name",field:"name",issue:f.name,children:t.jsx(Fe,{name:"name",value:i.name,onChange:F=>k("name")(F.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:O.map(({kind:F,label:I})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===F?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:F,checked:i.kind===F,onChange:()=>k("kind")(F),className:"accent-primary"}),I]},F))}),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(wn,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(D$,{label:"Runs",name:"cron",value:i.cron,onChange:k("cron")})}),i.kind==="at"&&t.jsx(wn,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:A?`= ${CN(A)}`:void 0,children:t.jsx(Fe,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:F=>C(F.target.value)})}),i.kind==="every"&&t.jsx(wn,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?Ph(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Fe,{name:"every",inputMode:"decimal",value:i.every,onChange:F=>k("every")(F.target.value),placeholder:"5"}),t.jsx(Ft,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:F=>k("everyUnit")(F),options:["seconds","minutes","hours"].map(F=>({value:F,label:F}))})]})}),i.kind==="cron"&&t.jsx(wn,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(z$,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:k("timezone")})}),i.kind==="every"&&t.jsx(wn,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:P?`= ${CN(P)}`:void 0,children:t.jsx(Fe,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:F=>k("startAt")(F.target.value)})})]}),L&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(Yl,{v2:e,draft:i,set:k,issues:f,agents:d,agentCap:u,capOptional:S,what:"schedule",skips:!0}),!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:F=>k("enabled")(F.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(W,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?"Saving":s?"Save changes":"Create schedule"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Xn(s.id):"#/triggers"),children:"Cancel"})]})]})}function wy({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(gb,{title:"URL",text:s,label:"Copy URL",hint:my}),t.jsx(gb,{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 gb({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(nv,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}function p9({v2:e,go:n,minEvery:s}){const[r,o]=g.useState(nW),[i,l]=g.useState(!1),{agents:d,agentCap:u,capOptional:f,issues:h,setIssues:v,rest:b,setRest:m,saving:x,setSaving:y,keys:j,open:k,refused:C}=Ql(e,r.agentId);g.useEffect(()=>{e.emailAccount().then(E=>{k.current&&l(!E.configured)},()=>{})},[e,k]);const N=E=>$=>o(L=>({...L,[E]:$})),S=async E=>{E.preventDefault();const{body:$,issues:L}=rW(r,s,f);if(m([]),!$){v(L??{});return}v({}),y(!0);try{const A=await e.createTrigger($,j.keyFor("createTrigger",$));k.current&&n(Xn(A.id))}catch(A){if(!k.current)return;C(wi(A),sW),y(!1)}};return t.jsxs("form",{onSubmit:E=>void S(E),className:"p-5 md:p-8",noValidate:!0,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(Wn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Vm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New email trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each new message in the mailbox starts a capped run of the agent. The messages already there when it is made start none: its first check, on its page once it is made, says how many."}),i&&t.jsxs("p",{role:"status","data-no-email-account":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:["No email account is saved: an email trigger reads this server's account. Save one in ",t.jsx("a",{href:"#/settings/email",className:"underline underline-offset-2",children:"Settings → Email"})," first."]}),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((E,$)=>t.jsx("p",{children:E},$))}),t.jsxs("div",{className:`mt-5 ${Hl}`,children:[t.jsx(wn,{label:"Name",field:"name",issue:h.name,children:t.jsx(Fe,{name:"name",value:r.name,onChange:E=>N("name")(E.target.value),placeholder:"new mail"})}),t.jsx(wn,{label:"Mailbox",field:"source.mailbox",issue:h["source.mailbox"],hint:"A folder of the account in Settings → Email, by its name on the server.",children:t.jsx(Fe,{name:"mailbox",value:r.mailbox,onChange:E=>N("mailbox")(E.target.value),placeholder:"INBOX",autoComplete:"off",spellCheck:!1})}),t.jsx(wn,{label:"Check every",field:"source.every_s",issue:h["source.every_s"],hint:s?Ph(s):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Fe,{name:"every",inputMode:"decimal",value:r.every,onChange:E=>N("every")(E.target.value),placeholder:"1"}),t.jsx(Ft,{id:"email-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:r.everyUnit,onChange:E=>N("everyUnit")(E),options:["seconds","minutes","hours"].map(E=>({value:E,label:E}))})]})}),t.jsx(Yl,{v2:e,draft:r,set:N,issues:h,agents:d,agentCap:u,capOptional:f,what:"trigger",asked:"The message comes with it: its sender, subject and text."}),t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"enabled",checked:r.enabled,onChange:E=>N("enabled")(E.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),h.enabled&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:h.enabled})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:x,children:x?"Creating":"Create email trigger"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}const g9=["standard","github"];function x9({v2:e,go:n}){const[s,r]=g.useState(FU),[o,i]=g.useState(null),{agents:l,agentCap:d,capOptional:u,issues:f,setIssues:h,rest:v,setRest:b,saving:m,setSaving:x,keys:y,refused:j}=Ql(e,s.agentId),k=S=>E=>r($=>({...$,[S]:E})),C=async S=>{S.preventDefault();const E=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...uu(s.accept.map(A=>A.where.length))]),{body:$,issues:L}=UU(s,u);if(b([]),!$){h(L??{});return}h({}),x(!0);try{i(await e.createTrigger($,y.keyFor("createTrigger",$)))}catch(A){j(wi(A),E)}finally{x(!1)}},N=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(Wn,{className:"size-3.5","aria-hidden":!0})," Triggers"]});return o?t.jsxs("div",{className:"p-5 md:p-8",children:[N,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(kl,{className:"size-5 text-primary-text","aria-hidden":!0}),o.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${db[o.source.kind==="webhook"?o.source.signature??"standard":"standard"]}). Each one starts a run.`}),o.signing_secret?t.jsx(wy,{label:"The webhook's URL and secret",url:Td(o),secret:o.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(gb,{title:"URL",text:Td(o),label:"Copy URL",hint:my}),o.note&&t.jsx("p",{role:"note",children:o.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(W,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Xn(o.id)),children:"Done"})})]}):t.jsxs("form",{onSubmit:S=>void C(S),className:"p-5 md:p-8",noValidate:!0,children:[N,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(kl,{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."}),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((S,E)=>t.jsx("p",{children:S},E))}),t.jsxs("div",{className:`mt-5 ${Hl}`,children:[t.jsx(wn,{label:"Name",field:"name",issue:f.name,children:t.jsx(Fe,{name:"name",value:s.name,onChange:S=>k("name")(S.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:g9.map(S=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===S?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:S,checked:s.signature===S,onChange:()=>k("signature")(S),className:"accent-primary"}),db[S]]},S))}),f["source.signature"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:f["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(cE,{signature:s.signature,rules:s.accept,onChange:k("accept"),issues:f,cap:null}),t.jsx(Yl,{v2:e,draft:s,set:k,issues:f,agents:l,agentCap:d,capOptional:u,what:"webhook"})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?"Creating":"Create webhook"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function b9({v2:e,go:n}){const[s,r]=g.useState(null),[o,i]=g.useState(null),[l,d]=g.useState(0),[u,f]=g.useState(WU),{agents:h,agentCap:v,capOptional:b,issues:m,setIssues:x,rest:y,setRest:j,saving:k,setSaving:C,keys:N,open:S,refused:E}=Ql(e,u.agentId);g.useEffect(()=>{let O=!0;return i(null),e.githubConnection().then(T=>{O&&r(!!T&&"app_id"in T&&!!T.app_id)},T=>{O&&(T instanceof Ue&&T.status===404?r(!1):i(Yt(T,"GitHub's connection")))}),()=>{O=!1}},[e,l]);const $=O=>T=>f(M=>({...M,[O]:T})),L=async O=>{O.preventDefault();const T=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...uu(Dh(u).map(I=>I.where.length))]),{body:M,issues:F}=oW(u,b);if(j([]),!M){x(F??{});return}x({}),C(!0);try{const I=await e.createTrigger(M,N.keyFor("createTrigger",M));S.current&&n(Xn(I.id))}catch(I){E(wi(I),T),C(!1)}},A=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Wn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),P=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(Gm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});return o?t.jsxs("div",{className:"p-5 md:p-8",children:[A,P,t.jsx(on,{problem:o,onRetry:()=>d(O=>O+1),className:"mt-4"})]}):s===null?t.jsx(cs,{label:"Reading GitHub's connection",rows:3}):s?t.jsxs("form",{onSubmit:O=>void L(O),className:"p-5 md:p-8",noValidate:!0,children:[A,P,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."}),y.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:y.map((O,T)=>t.jsx("p",{children:O},T))}),t.jsxs("div",{className:`mt-5 ${Hl}`,children:[t.jsx(wn,{label:"Name",field:"name",issue:m.name,children:t.jsx(Fe,{name:"name",value:u.name,onChange:O=>$("name")(O.target.value),placeholder:"review PRs"})}),t.jsx(dE,{picks:u,onChange:O=>f(T=>({...T,...O})),issues:m}),t.jsx(Yl,{v2:e,draft:u,set:$,issues:m,agents:h,agentCap:v,capOptional:b,what:"trigger",asked:"The event's payload comes with it."})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:k,children:k?"Creating":"Create GitHub trigger"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]}):t.jsxs("div",{className:"p-5 md:p-8",children:[A,P,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."]})]})}function v9({v2:e,go:n,noAddress:s}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(0),[f,h]=g.useState(null),[v,b]=g.useState(""),[m,x]=g.useState(null),[y,j]=g.useState(0),[k,C]=g.useState(VU),{agents:N,agentCap:S,capOptional:E,issues:$,setIssues:L,rest:A,setRest:P,saving:O,setSaving:T,keys:M,open:F,refused:I}=Ql(e,k.agentId),[V,G]=g.useState(null),[q,H]=g.useState(null);g.useEffect(()=>{let ue=!0;return l(null),e.listMcpServers().then(ge=>{if(!ue)return;const Te=ge.servers.filter(Xe=>Xe.source==="composio");o(Te),Te.length===1&&C(Xe=>Xe.server?Xe:{...Xe,server:Te[0].name})},ge=>{ue&&l(Yt(ge,"the saved MCP servers"))}),()=>{ue=!1}},[e,d]),g.useEffect(()=>{if(!k.server)return;let ue=!0;const ge=k.server;return h(null),x(null),e.composioEvents(ge).then(Te=>{ue&&h({server:ge,events:Te.events})},Te=>{ue&&x(Yt(Te,`${ge}'s events`))}),()=>{ue=!1}},[e,k.server,y]);const U=ue=>{H(null),C(ue)},Q=ue=>ge=>U(Te=>({...Te,[ue]:ge})),D=ue=>{ue!==k.server&&b(""),U(ge=>ge.server===ue?ge:{...ge,server:ue,event:"",config:{},where:[]})},Y=ue=>{U(ge=>ge.event===ue?ge:{...ge,event:ue,config:{},where:[]}),L({})},K=(f==null?void 0:f.server)===k.server?f.events.find(ue=>ue.slug===k.event):void 0,Z=(f==null?void 0:f.server)===k.server?[...f.events].sort((ue,ge)=>lx(ue).localeCompare(lx(ge),void 0,{sensitivity:"base"})):[],se=Z.filter(ue=>Us(v,ue.name,ue.slug,ue.description)),ie=Z.filter(ue=>ue.slug===k.event||se.includes(ue)),Ne=GU(K==null?void 0:K.config,K==null?void 0:K.sealed),he=async ue=>{var Te,Xe;const ge=new Set(["name","source.server","source.event","source.config",...Ne.map(je=>`source.config.${je.name}`),"target.agent_id","target.input","target.max_cost_usd",...k.where.length?uu([k.where.length]):[]]);L({}),P([]),G(null),H(null),T(!0);try{const je=await e.createTrigger(ue,M.keyFor("createTrigger",ue));F.current&&n(Xn(je.id));return}catch(je){je instanceof Ue&&je.code==="composio_subscription_elsewhere"?H({url:typeof((Te=je.details)==null?void 0:Te.webhook_url)=="string"?je.details.webhook_url:"another address",body:ue}):je instanceof Ue&&je.code.startsWith("composio_")?(P([je.message]),je.code==="composio_not_connected"&&G(Rr(typeof((Xe=je.details)==null?void 0:Xe.connect_url)=="string"?je.details.connect_url:null)??null)):I(wi(je),ge)}T(!1)},ve=()=>QU(k,Ne,E),Ee=ue=>{ue.preventDefault();const{body:ge,issues:Te}=ve();if(P([]),G(null),!ge){L(Te??{});return}he(ge)},ye=()=>{const ue=q;H(null),ue&&he({...ue.body,source:{...ue.body.source,move_subscription:!0}})},pe=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Wn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),Pe=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 app trigger"]});return i?t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[pe,Pe,t.jsx(on,{problem:i,onRetry:()=>u(ue=>ue+1),className:"mt-4"})]}):r===null?t.jsx(cs,{label:"Reading the saved Composio servers",rows:3}):r.length?t.jsxs("form",{onSubmit:Ee,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[pe,Pe,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:yy}),A.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[A.map((ue,ge)=>t.jsx("p",{className:"break-words",children:ue},ge)),V&&t.jsx("a",{href:V,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(wn,{label:"Name",field:"name",issue:$.name,children:t.jsx(Fe,{name:"name",value:k.name,onChange:ue=>Q("name")(ue.target.value),placeholder:"new issues"})}),t.jsx(wn,{label:"Composio server",field:"source.server",issue:$["source.server"],children:t.jsx(Ft,{name:"server",label:"Composio server",className:"w-full",value:k.server,onChange:D,options:[{value:"",label:"Pick a server"},...r.map(ue=>({value:ue.name,label:ue.toolkit?`${ue.name} (${ue.toolkit})`:ue.name}))]})}),k.server&&(m?t.jsx(on,{problem:m,onRetry:()=>j(ue=>ue+1),className:""}):t.jsxs("div",{className:"space-y-2",children:[Z.length>0&&t.jsx(cu,{value:v,onChange:b,label:"Filter events",placeholder:"Filter by name, slug or description",shown:se.length,total:Z.length}),t.jsx(wn,{label:"Event",field:"source.event",issue:$["source.event"],children:t.jsx(Ft,{name:"event",label:"Event",className:"w-full",value:k.event,onChange:Y,disabled:!f,options:[{value:"",label:f?Z.length?se.length?"Pick an event":`No event matches “${v.trim()}”`:"Composio offers no event for this toolkit":"Loading the events"},...ie.map(ue=>({value:ue.slug,label:lx(ue)}))]})}),(K==null?void 0:K.description)&&t.jsx("div",{"data-event-description":!0,className:"report report-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:Yr(K.description)}})]})),K&&t.jsxs(t.Fragment,{children:[K.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."}),K.instructions&&t.jsx("div",{"data-event-instructions":!0,className:"report report-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:Yr(K.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:K.slug}),"."]}),t.jsx(Ar,{issues:$,field:"source.config"}),Ne.length?t.jsx("div",{className:"space-y-4",children:Ne.map(ue=>t.jsx(y9,{field:ue,value:k.config[ue.name]??ue.initial,issue:$[`source.config.${ue.name}`],onChange:ge=>U(Te=>({...Te,config:{...Te.config,[ue.name]:ge}}))},`${K.slug}:${ue.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(uE,{where:k.where,onChange:Q("where"),issues:$})]}),t.jsx(Yl,{v2:e,draft:k,set:Q,issues:$,agents:N,agentCap:S,capOptional:E,what:"trigger",asked:"What Composio delivered comes with it."})]}),q&&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:q.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:q.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(W,{type:"button",size:"sm",variant:"solid",onClick:ye,children:"Move it here"}),t.jsx(W,{type:"button",size:"sm",variant:"ghost",onClick:()=>H(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:O||!!q||s,children:O?"Creating":"Create app trigger"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]}):t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[pe,Pe,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."]})]})}function y9({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:l=>r(l.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(gt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Ft,{name:o,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(l=>({value:l,label:l}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(An,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:l=>r(l.target.value),spellCheck:!1}):t.jsx(Fe,{name:o,type:e.sealed?"password":void 0,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:l=>r(l.target.value),autoComplete:e.sealed?"new-password":"off",spellCheck:!1})})})}function w9(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 cE({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(Ar,{issues:r,field:"source.accept"}),t.jsx(Y$,{name:"accept",rules:n,onChange:s,issues:r,room:du.rules-n.length,eventHint:V$[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:w9(n.length>0,o)})]})]})}function dE({picks:e,onChange:n,issues:s}){const r=i=>n({...e,events:e.events.includes(i)?e.events.filter(l=>l!==i):[...e.events,i]}),o=Dh(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:T$.map(i=>{const l=o.indexOf(`event:${i}`),d=`source.accept[${l}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[Ih.filter(u=>u.event===i).map(({event:u,action:f,label:h})=>{const v=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:v,checked:e.events.includes(v),onChange:()=>r(v),className:"accent-primary"}),h," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},v)}),l>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(Ar,{issues:s,field:u},u)),t.jsx(Wh,{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(Y$,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var l;return o.indexOf(`other:${(l=e.other[i])==null?void 0:l.key}`)},room:du.rules-o.length,eventHint:V$.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function j9({v2:e,go:n,trigger:s}){const r=fy(s)?s:null,o=hy(s)?s:null,[i,l]=g.useState(()=>r?(r.source.accept??[]).map($m):o?(o.source.accept??[]).map($m):[]),[d,u]=g.useState(()=>r||o?{events:[],where:{},other:[]}:BU(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,h=o?i.slice(f?1:0):[],[v,b]=g.useState({}),[m,x]=g.useState([]),[y,j]=g.useState(!1),k=g.useRef(!0);g.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const C=async E=>{E.preventDefault();const{source:$,issues:L}=r?E$(r.source,i):o?YU(o.source,(f==null?void 0:f.where)??[],h,f==null?void 0:f.was):R$(d);if(x([]),Object.keys(L).length){b(L);return}b({}),j(!0);try{Od($,s.source)||await e.updateTrigger(s.id,{source:$}),k.current&&n(Xn(s.id))}catch(A){if(!k.current)return;const P=wi(A),O=uu(r||o?i.map(T=>T.where.length):Dh(d).map(T=>T.where.length));b(Object.fromEntries(Object.entries(P.fields).filter(([T])=>O.has(T)))),x([...P.rest,...Object.entries(P.fields).filter(([T])=>!O.has(T)).map(([,T])=>T)]),j(!1)}},N=r?kl:o?Hm:Gm,S=E=>l(f?E.length?[{...f,where:E},...h]:h:E.length?[{...f$(),event:o.source.event,where:E},...h]:h);return t.jsxs("form",{onSubmit:E=>void C(E),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:Xn(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Wn,{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(N,{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."}),m.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:m.map((E,$)=>t.jsx("p",{children:E},$))}),t.jsx("div",{className:"mt-5 space-y-5",children:r?t.jsx(cE,{signature:r.source.signature??"standard",rules:i,onChange:l,issues:v,cap:s.max_active_runs??null}):o?t.jsx(uE,{where:(f==null?void 0:f.where)??[],onChange:S,issues:v,others:h.map(E=>E.event+(E.actions.trim()?` (${E.actions.trim()})`:""))}):t.jsx(dE,{picks:d,onChange:u,issues:v})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:y,children:y?"Saving":"Save filter"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Xn(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(Ar,{issues:s,field:"source.accept"}),t.jsx(Ar,{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(Wh,{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 k9({check:e,newest:n}){const s=n&&(n.by==="feed"||n.by==="email")&&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"} · ${Ll(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 fE({v2:e,go:n,trigger:s,minEvery:r}){const[o,i]=g.useState(()=>s?XU(s):L$()),{agents:l,agentCap:d,capOptional:u,issues:f,setIssues:h,rest:v,setRest:b,saving:m,setSaving:x,keys:y,open:j,refused:k}=Ql(e,o.agentId,!s),[C,N]=g.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));g.useEffect(()=>{(f["source.items"]||f["source.id"])&&N(!0)},[f]);const S=A=>P=>i(O=>({...O,[A]:P})),E=async A=>{A.preventDefault();const P=tW(M$(o.urls).urls.length,[o.where.length,...o.others.map(F=>F.where.length)]);b([]);const O=F=>{j.current&&(k(wi(F),P),x(!1))};if(s){const{source:F,issues:I}=P$(o,r);if(Object.keys(I).length){h(I);return}h({}),x(!0);try{Od(F,s.source)||await e.updateTrigger(s.id,{source:F}),j.current&&n(Xn(s.id))}catch(V){O(V)}return}const{body:T,issues:M}=eW(o,r,u);if(!T){h(M??{});return}h({}),x(!0);try{const F=await e.createTrigger(T,y.keyFor("createTrigger",T));j.current&&n(Xn(F.id))}catch(F){O(F)}},$=Object.entries(f).filter(([A])=>/^source\.urls(\[\d+\])?$/.test(A)),L=o.others.map(A=>A.event+(A.actions.trim()?` (${A.actions.trim()})`:""));return t.jsxs("form",{onSubmit:A=>void E(A),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Xn(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(Wn,{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(Ib,{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."}),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((A,P)=>t.jsx("p",{children:A},P))}),t.jsxs("div",{className:`mt-5 ${Hl}`,children:[!s&&t.jsx(wn,{label:"Name",field:"name",issue:f.name,children:t.jsx(Fe,{name:"name",value:o.name,onChange:A=>S("name")(A.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(gt,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${fb}: 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(([A,P])=>t.jsx("span",{"data-issue":A,className:"block",children:P},A))}):void 0,children:t.jsx(An,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:A=>S("urls")(A.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(wn,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?Ph(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Fe,{name:"every",inputMode:"decimal",value:o.every,onChange:A=>S("every")(A.target.value),placeholder:"15"}),t.jsx(Ft,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:A=>S("everyUnit")(A),options:["seconds","minutes","hours"].map(A=>({value:A,label:A}))})]})}),t.jsxs("details",{"data-json-list":!0,open:C,onToggle:A=>N(A.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(wn,{label:"Items at",field:"source.items",issue:f["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(Fe,{name:"items",value:o.items,onChange:A=>S("items")(A.target.value),placeholder:"/data/items",autoComplete:"off",spellCheck:!1})}),t.jsx(wn,{label:"Each item's id at",field:"source.id",issue:f["source.id"],hint:"A JSON Pointer into an item to what names it: empty for /id, /number for a pull request.",children:t.jsx(Fe,{name:"id",value:o.id,onChange:A=>S("id")(A.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(Ar,{issues:f,field:"source.accept"}),t.jsx(Ar,{issues:f,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(Wh,{name:"feed",at:"source.accept[0]",where:o.where,onChange:S("where"),issues:f,label:"Only when"}),L.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[L.length===1?"One more rule, made through the API, is kept as it is":`${L.length} more rules, made through the API, are kept as they are`,": ",L.join(", "),"."]})]})]}),!s&&t.jsx(t.Fragment,{children:t.jsx(Yl,{v2:e,draft:o,set:S,issues:f,agents:l,agentCap:d,capOptional:u,what:"trigger",asked:"The item comes with it: its title, link, summary and feed."})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?s?"Saving":"Creating":s?"Save feed":"Create feed trigger"}),t.jsx(W,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Xn(s.id):"#/triggers"),children:"Cancel"})]})]})}const mE=e=>e?"#/playground?operation=apply-template":"#/templates";function RN({v2:e,name:n,install:s,go:r,playground:o=!1,draft:i}){const[l,d]=g.useState(null),[u,f]=g.useState(null),[h,v]=g.useState(0);g.useEffect(()=>{if(s!==void 0)return;let y=!0;return f(null),e.listTemplates().then(j=>{y&&d(j.templates)},j=>{y&&f(Yt(j,"the templates"))}),()=>{y=!1}},[e,h,s]);const b=n===void 0||l==null?void 0:l.find(y=>y.id===n),m=s!==void 0?t.jsx(S9,{v2:e,source:s,go:r}):u&&!l?t.jsx(on,{problem:u,onRetry:()=>v(y=>y+1),className:""}):l?n===void 0?t.jsx(N9,{v2:e,templates:l,go:r,playground:o,onRemoved:()=>v(y=>y+1)}):b?t.jsx(T9,{v2:e,template:b,go:r,playground:o,draft:i},`${b.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:mE(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(cs,{label:"Loading the templates",rows:3});if(o)return t.jsx("div",{className:"p-5 md:p-8",children:m});const x=s===void 0&&n===void 0;return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsx("header",{className:ee(Lr,"flex-wrap gap-2 px-5 md:px-6"),children:x?t.jsxs("h1",{className:ha,children:[t.jsx(Km,{className:"size-4","aria-hidden":!0}),"Templates"]}):t.jsx("nav",{"aria-label":"Breadcrumb",children:t.jsxs("a",{href:"#/templates",className:ee(ha,"text-muted-foreground hover:text-foreground"),children:[t.jsx(Wn,{className:"size-4","aria-hidden":!0}),"Templates"]})})}),t.jsx("div",{className:"p-5 md:p-6",children:m})]})}function jy({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 N9({v2:e,templates:n,go:s,playground:r,onRemoved:o}){const i=r?"h2":"h1",l=r?"h3":"h2",[d,u]=g.useState(""),[f,h]=g.useState(null),[v,b]=g.useState(null),m=async x=>{h(x.id),b(null);try{await e.deleteTemplate(x.id),o()}catch(y){b(y instanceof Error?y.message:String(y))}finally{h(null)}};return t.jsxs(t.Fragment,{children:[r&&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:x=>{x.preventDefault(),d.trim()&&s(C9(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(Fe,{type:"text",value:d,placeholder:"github:owner/repo/templates/name@main",onChange:x=>u(x.target.value)})]}),t.jsx(W,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),v&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:v}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(x=>t.jsx("li",{children:t.jsxs("article",{"aria-label":fa(x),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(Km,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),t.jsx(l,{className:"min-w-0 break-words text-prose font-semibold",children:fa(x)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:x.version}),x.category&&t.jsx(ke,{tone:"muted",children:x.category}),!x.bundled&&t.jsx(ke,{tone:"muted",children:"Imported"})]}),t.jsx(jy,{t:x}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:x.description}),x.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:x.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:gy(x).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:[!x.bundled&&t.jsx(W,{size:"sm",onClick:()=>void m(x),disabled:f===x.id,children:f===x.id?"Removing…":"Remove"}),r?t.jsx(W,{size:"sm",variant:"primary",onClick:()=>s(bl(x)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"sm",variant:Lm(x)?"primary":"outline",onClick:()=>s(U$(x.id)),children:"Configure"}),t.jsx(Ut,{variant:Lm(x)?"outline":"primary",label:"Run",prompt:Ox(location.origin,x),playgroundHref:bl(x)})]})]})]})},x.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 S9({v2:e,source:n,go:s}){var k;const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(!1),[f,h]=g.useState(!1),[v,b]=g.useState(null);g.useEffect(()=>{let C=!0;if(!n){l("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(N=>{C&&o(N)},N=>{C&&l(AN(N))}),()=>{C=!1}},[e,n]);const m=async()=>{h(!0),b(null);try{if(!r)return;const C=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(U$(C.template.id))}catch(C){b(AN(C))}finally{h(!1)}};if(i)return t.jsx("div",{className:"max-w-3xl",children: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(cs,{label:"Reading the package from GitHub",rows:3});const x=r.template,y=x.publisher??"",j=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[fa(x)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:x.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:[y,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:x.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:x.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:[x.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:x.description}),t.jsx(Er,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:gy(x,{mcp:!1}).map(([C,N])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:C}),t.jsx("dd",{className:"min-w-0 break-words",children:N})]},C))})}),x.mcp.length>0&&t.jsx(Er,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:x.mcp.map(C=>t.jsxs("div",{"data-mcp":C.toolkit,className:"px-4 py-3",children:[t.jsx(hE,{m:C}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:C.tools.map(N=>N.name).join(", ")})]},C.toolkit))}),t.jsx(pE,{t:x}),t.jsx(gE,{t:x}),t.jsx(Er,{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})}),((k=x.output)==null?void 0:k.json_schema)&&t.jsx(Er,{title:"Output schema",note:`What the agent is told to answer in (${x.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(x.output.json_schema,null,2)})}),j.length>0&&t.jsx(Er,{title:"Skill files",note:"Every file the agent is given, in full.",children:j.map(([C,N])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":C,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:C}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:N})]},C))}),!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:C=>u(C.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",y]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",y," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(W,{size:"sm",variant:"solid",onClick:()=>void m(),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."}),v&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:v})]})]})}function AN(e){var n;return e instanceof Ue&&((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 C9=e=>`#/templates/install?src=${encodeURIComponent(e)}`,_9=3e3,$9={made:{title:"applied",said:()=>"The agent is made"},updated:{title:"updated",said:e=>`Updated: rev ${e}`},unchanged:{title:"unchanged",said:e=>`Nothing to update: rev ${e} is current`}};function E9(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function T9({v2:e,template:n,go:s,playground:r=!1,draft:o}){var st,xe,Be,$t,et,dt,Lt,qt,At,Et;const i=r?"h2":"h1",l={fields:zh(n.parameters)??[]},d=vW(o,n),[u,f]=g.useState(()=>{var B;return{...Object.fromEntries(l.fields.filter(([,J])=>J.type==="boolean"&&!J.array).map(([J])=>[J,"false"])),...B$(l),...Object.fromEntries(Object.entries(((B=d.body)==null?void 0:B.parameters)??{}).map(([J,de])=>[J,Array.isArray(de)?de.map(String).join(`
|
|
686
|
-
`):String(de)]))}}),[h,v]=g.useState(()=>{var B;return new Set(((B=d.body)==null?void 0:B.grants)??[])}),[b,m]=g.useState(((xe=(st=d.body)==null?void 0:st.overrides)==null?void 0:xe.approvals)??n.approvals_default??"ask"),[x,y]=g.useState((($t=(Be=d.body)==null?void 0:Be.overrides)==null?void 0:$t.choice)??""),[j,k]=g.useState(null),[C,N]=g.useState(null),[S,E]=g.useState(0),[$,L]=g.useState(()=>{var B;return((B=d.body)==null?void 0:B.servers)??{}}),[A,P]=g.useState(!1),[O,T]=g.useState([]),[M,F]=g.useState(null),[I,V]=g.useState(null),[G,q]=g.useState([]),[H,U]=g.useState({}),Q=g.useRef(yi()).current,[D,Y]=g.useState([]);g.useEffect(()=>{let B=!0;return Kr(J=>e.listAgents({cursor:J}),J=>J.agents,Number.POSITIVE_INFINITY).then(J=>J.filter(de=>{var _e;return((_e=de.template)==null?void 0:_e.id)===n.id}).map(de=>{var _e;return{id:de.agent_id,name:((_e=de.definition)==null?void 0:_e.name)||de.agent_id}})).then(J=>{B&&Y(J)},()=>{}),()=>{B=!1}},[e,n.id]);const K=g.useRef(!0);g.useEffect(()=>(K.current=!0,()=>{K.current=!1}),[]),g.useEffect(()=>{let B=!0;return N(null),e.listMcpServers().then(J=>{B&&k(J.servers)},J=>{B&&N(Yt(J,"the saved MCP servers"))}),()=>{B=!1}},[e,S]);const Z=SW(n,h),se=n.mcp.map(B=>{const J=j?jW(B,j):[];return{m:B,matches:J,uses:J.length===1?J[0]:J.includes($[B.toolkit]??"")?$[B.toolkit]:void 0}}),ie=Object.fromEntries(se.flatMap(({m:B,uses:J})=>J?[[B.toolkit,J]]:[])),Ne=se.filter(({matches:B,uses:J})=>B.length>1&&!J).map(({m:B})=>B.toolkit),he=n.mcp.length>0&&j===null,ve=j&&se.some(({m:B,matches:J})=>{var de,_e;return((_e=(de=d.body)==null?void 0:de.servers)==null?void 0:_e[B.toolkit])!==void 0&&!J.includes(d.body.servers[B.toolkit])}),Ee=d.error??(ve?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),ye=!!Ee||he||Ne.length>0,pe=r||Lm(n),Pe=!r&&Lm(n)?TN.filter(B=>B.needs(n)):[],[ue,ge]=g.useState({}),[Te,Xe]=g.useState(0),je=Pe.map(B=>B.id).join(" ");g.useEffect(()=>{let B=!0;for(const J of TN.filter(de=>je.split(" ").includes(de.id)))J.met(e).then(de=>{B&&ge(_e=>({..._e,[J.id]:de?"met":"unmet"}))},()=>{B&&ge(de=>({...de,[J.id]:"unread"}))});return()=>{B=!1}},[e,je,Te]);const fe=Pe.filter(B=>ue[B.id]!=="met"),De=fe.find(B=>ue[B.id]===void 0),te=fe.length>0;g.useEffect(()=>{if(!te)return;const B=()=>Xe(J=>J+1);return window.addEventListener("focus",B),()=>window.removeEventListener("focus",B)},[te]);const Ie={parameters:Uh(l,u),...Z.length?{grants:Z}:{},...Object.keys(ie).length?{servers:ie}:{},overrides:{approvals:b,...x?{choice:x}:{}}},We=B=>CW(O,B),rt=(B,J,de)=>{f(_e=>({..._e,[B]:de})),by(J,de)&&T(_e=>_e.filter(at=>hb(at.field,"parameters")!==B))},ot=async B=>{var _e,at;if(!pe||ye||fe.length)return;P(!0),T([]),F(null);const J=u,de=B?{...Ie,agent_id:B}:Ie;try{const qe=await e.applyTemplate(n.id,de,Q.keyFor(n.id,de));Q.done();const ft=async()=>(await Promise.all(qe.triggers.filter(en=>en.kind==="schedule").map(en=>E9(e.getTrigger(en.trigger_id),_9).catch(()=>null)))).filter(en=>en!=null&&uy(en));if(!K.current)return;if(qe.agent_change!=="unchanged"&&!qe.warnings.length&&!((_e=qe.webhook_secrets)!=null&&_e.length)&&!qe.triggers.length){s(jn(qe.agent_id));return}U(J),V(qe),qe.triggers.some($n=>$n.kind==="schedule")&&ft().then($n=>{K.current&&q($n)},()=>{})}catch(qe){qe instanceof Ue&&((at=qe.fields)!=null&&at.length)?(T(qe.fields),F({text:qe.message,withIssues:!0}),qe.fields.some(ft=>ft.field.startsWith("servers.")||ft.field.startsWith("mcp."))&&E(ft=>ft+1)):F({text:qe instanceof Error?qe.message:String(qe),withIssues:!1})}finally{P(!1)}},wt=l.fields,jt=B=>B.filter(J=>!n.secrets.includes(J)),we=(dt=(et=n.model)==null?void 0:et.choices)==null?void 0:dt.find(B=>B.id===x),ze=B=>{var J,de;return/^(parameters|mcp|servers)\./.test(B.field)||/^grants\.\d+$/.test(B.field)||B.field==="overrides.choice"&&!!((de=(J=n.model)==null?void 0:J.choices)!=null&&de.length)||B.field.startsWith("secrets.")&&[...n.secrets,...jt((we==null?void 0:we.secrets)??[])].includes(B.field.slice(8))};if(I){const B=$9[I.agent_change];return 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(Il,{className:"size-5 text-success-text","aria-hidden":!0})," ",fa(n,H)," ",B.title]}),I.agent_change!=="made"&&I.warnings.length===0&&t.jsxs("p",{className:"mb-3 text-lead",children:[B.said(I.revision_version),"."]}),I.warnings.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"mb-3 text-lead",children:[B.said(I.revision_version),". 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:I.warnings.map((J,de)=>{var $n,en,qn;const _e=/^triggers\.(\d+)\.secret$/.exec(J.field),at=_e?($n=n.triggers[Number(_e[1])])==null?void 0:$n.name:void 0,qe=typeof at=="string"?at.trim():"",ft=qe?(en=I.triggers.find(kn=>kn.name===qe))==null?void 0:en.trigger_id:void 0;return ft&&((qn=I.webhook_secrets)!=null&&qn.some(kn=>kn.trigger_id===ft))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:J.field})," ",J.message]},`${J.field}:${de}`):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,ft&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(ft)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",qe||ft," to get its signing secret (Rotate)"]})]},`${J.field}:${de}`)})})]}),(Lt=I.webhook_secrets)==null?void 0:Lt.map(J=>{var at;const _e=((at=I.triggers.find(qe=>qe.trigger_id===J.trigger_id))==null?void 0:at.name)||J.trigger_id;return J.signing_secret?t.jsx(wy,{label:`The webhook's URL and secret (${_e})`,url:Td({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 ",_e," to get its signing secret (Rotate)"]})]},J.trigger_id)}),I.triggers.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Triggers",children:I.triggers.map(J=>{const de=G.find(_e=>_e.id===J.trigger_id);return t.jsxs("li",{"data-trigger":J.trigger_id,className:"px-4 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(J.trigger_id)}`,className:"break-words text-prose font-semibold hover:underline",children:J.name}),t.jsx(ke,{tone:J.enabled?"success":"plain",children:J.enabled?"on":"off"})]}),t.jsxs("p",{className:"mt-1 break-words text-body",children:[Am[J.kind].label," · ",Am[J.kind].what,J.enabled?"":" It is off: it starts nothing until it is turned on."]}),de&&t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:cy(de.source,de.next_at)})]},J.trigger_id)})}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:jn(I.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]})}return t.jsxs("div",{children:[r&&t.jsxs("a",{href:mE(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(Wn,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[fa(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(jy,{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.":pe?"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."}),Ee&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[Ee," ",t.jsx("a",{href:bl(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${Hl}`,children:[wt.length>0&&t.jsx(Er,{title:"Parameters",children:wt.map(([B,J])=>t.jsxs("div",{"data-field":`parameters.${B}`,className:"px-4 py-3",children:[t.jsx(K$,{field:J,label:Fh(B,J),help:Mm(J),value:u[B]??"",onChange:de=>rt(B,J,de)}),t.jsx(oa,{issues:O.filter(de=>hb(de.field,"parameters")===B),words:de=>G$(de,B,J)})]},B))}),n.mcp.length>0&&t.jsxs(Er,{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:[C&&!j&&t.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:t.jsx(on,{problem:C,onRetry:()=>E(B=>B+1),className:""})}),se.map(({m:B,matches:J,uses:de})=>t.jsxs("div",{"data-mcp":B.toolkit,className:"px-4 py-3",children:[t.jsx(hE,{m:B,children:j&&J.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:de?`Uses ${de}`:"Not set up here"})}),j&&J.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(Ft,{small:!0,label:`Server for ${B.toolkit}`,value:de??"",placeholder:"Pick one",onChange:_e=>L(at=>({...at,[B.toolkit]:_e})),options:J.map(_e=>({value:_e,label:_e}))}),!de&&t.jsxs("span",{"data-unpicked":B.toolkit,children:[J.length," saved servers are ",nu[B.source]," ",B.toolkit,": pick the one the agent uses."]})]}),j&&J.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":B.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[B.required?`${B.toolkit} is required and not set up here: Apply is refused until it is.`:`${B.toolkit} is not set up here: Apply makes the agent without its tools (${B.tools.map(_e=>_e.name).join(", ")}).`," ",t.jsx("a",{href:kW(B),className:"font-mono text-primary-text underline underline-offset-2 hover:decoration-2",children:B.source==="github"?"Set up GitHub App access":B.source==="composio"?`Add ${B.toolkit} from Composio`:`Set up ${B.toolkit}`})]}),t.jsx(oa,{issues:[...We(`mcp.${B.toolkit}`),...We(`servers.${B.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:B.tools.map(_e=>{const at=Z.indexOf(_e.tool);return t.jsxs("li",{"data-tool":_e.tool,children:[t.jsxs("label",{className:"flex items-start gap-2.5",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:h.has(_e.tool),onChange:()=>v(qe=>{const ft=new Set(qe);return ft.has(_e.tool)?ft.delete(_e.tool):ft.add(_e.tool),ft})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:_e.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:_e.tool}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["The template asks you to grant this.",_e.asks==="ask"&&" Each call waits for your OK unless you allowed it in Settings or pick Never ask."]})]})]}),at>=0&&t.jsx(oa,{issues:We(`grants.${at}`)})]},_e.tool)})})]},B.toolkit))]}),n.secrets.length>0&&t.jsx(Er,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(B=>t.jsxs("div",{"data-secret":B,className:"px-4 py-3 font-mono text-body",children:[B,t.jsx(oa,{issues:We(`secrets.${B}`)})]},B))}),(At=(qt=n.model)==null?void 0:qt.choices)!=null&&At.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 ${(Et=n.harness)!=null&&Et.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(B=>t.jsxs("label",{"data-choice":B.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:B.id,className:"mt-1 accent-primary",checked:x===B.id,onChange:()=>{y(B.id),T(J=>J.filter(de=>de.field!=="overrides.choice"&&!(de.field.startsWith("secrets.")&&!n.secrets.includes(de.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:B.label}),"model"in B&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[B.model," on ",B.harness]}),B.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":B.id,children:B.warning}),B.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":B.id,children:B.note}),"secrets"in B&&x===B.id&&t.jsx("span",{"data-choice-keys":B.id,children:t.jsx(oa,{issues:jt(B.secrets).flatMap(J=>We(`secrets.${J}`))})})]})]},B.id||"(default)"))}),t.jsx(oa,{issues:We("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(([B,J,de])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:B,className:"mt-1 accent-primary",checked:b===B,onChange:()=>m(B)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:J}),t.jsx("span",{className:"block text-small text-muted-foreground",children:de})]})]},B))}),b==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:i$})]}),t.jsx(pE,{t:n}),t.jsx(gE,{t:n}),t.jsx(Er,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:gy(n,{secrets:!1,mcp:!1}).map(([B,J])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:B}),t.jsx("dd",{className:"min-w-0 break-words",children:J})]},B))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[pe?t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"sm",variant:"primary",onClick:()=>void ot(),disabled:A||ye||fe.length>0,title:he?C?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":Ne.length?`Pick the server for ${Ne.join(", ")} first`:De?`Reading ${De.what}…`:void 0,children:A?"Applying…":"Apply"}),D.map(B=>t.jsx(W,{size:"sm",variant:"outline",onClick:()=>void ot(B.id),disabled:A||ye||fe.length>0,title:`Apply this template onto ${B.name}: a new revision of it, its runs, notes and triggers kept`,children:`Update ${B.name}`},B.id)),!r&&t.jsx(Ut,{variant:"outline",label:"Set it up with an agent",disabled:ye,prompt:Ox(location.origin,n,Ie),playgroundHref:bl(n,Ie)}),fe.map(B=>ue[B.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":B.id,className:"min-w-0 text-body text-warning-text",children:[B.unmet.before,t.jsx("a",{href:B.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:B.unmet.link}),B.unmet.after]},B.id):ue[B.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":B.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${B.what[0].toUpperCase()}${B.what.slice(1)} couldn't be read.`,t.jsx(W,{size:"sm",onClick:()=>Xe(J=>J+1),children:"Try again"})]},B.id):null)]}):t.jsx(Ut,{variant:"primary",label:"Run",disabled:ye,prompt:Ox(location.origin,n,Ie),playgroundHref:bl(n,Ie)}),M&&(!M.withIssues||O.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:M.text})]}),O.filter(B=>!ze(B)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(oa,{issues:O.filter(B=>!ze(B)),named:!0})})]})}function hE({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:nu[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 pE({t:e}){if(!e.input_schema)return null;const n=zh(e.input_schema,"content");return n&&!n.length?null:t.jsx(Er,{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:Fh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(ke,{tone:"muted",children:FW(r)}),t.jsx(ke,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),Mm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Mm(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 gE({t:e}){const n=e.evals.length;return t.jsx(Er,{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 Er({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 Im(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function ON(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function R9(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 A9={"code-review":Bm,"inbound-lead":Jm,kyb:_A,"market-monitor":NA,"release-notes":mi};function O9({origin:e,v2:n}){const[s,r]=g.useState(""),[o,i]=g.useState(null),[l,d]=g.useState(""),[u,f]=g.useState(null),[h,v]=g.useState(null),[b,m]=g.useState(0),x=g.useId(),y=xh(e,s),j=Im(s);g.useEffect(()=>{let C=!0;return v(null),n.listTemplates().then(N=>{C&&f(N.templates)},N=>{C&&v(Yt(N,"the template catalog"))}),()=>{C=!1}},[n,b]);const k=(u??[]).filter(C=>Us(l,fa(C),C.description,C.name,C.id,C.publisher));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":`${x}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${x}-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:ee(Cl,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${x}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(An,{bare:!0,id:`${x}-brief`,value:s,onChange:C=>r(C.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(Ut,{variant:"primary",label:"Build an agent",prompt:y,playgroundHref:ON(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:`${x}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(An,{id:`${x}-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":`${x}-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:`${x}-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&&!h?"Loading templates…":u?`${k.length} of ${u.length}`:""})]}),t.jsxs("div",{className:ee(Cl,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(Jm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Fe,{bare:!0,type:"search","aria-label":"Search templates",value:l,onChange:C=>d(C.target.value),placeholder:"Search templates…",className:"h-control-md w-full font-sans"})]})]}),h&&t.jsx(on,{problem:h,onRetry:()=>m(C=>C+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&&!k.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",l,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:k.map(C=>{const N=o===C.id,S=A9[C.name]??Km,E=`${x}-${encodeURIComponent(C.id)}-actions`,$=[C.skills.length?`${C.skills.length} skill${C.skills.length===1?"":"s"}`:"Ready to configure",C.triggers.length?`${C.triggers.length} trigger${C.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":E,"aria-label":`Start with ${fa(C)}${C.source?` from ${C.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:C.id),children:[t.jsx("h3",{className:"text-lg font-semibold leading-snug",children:fa(C)}),t.jsx(jy,{t:C}),t.jsx("p",{className:"mt-3 line-clamp-3 text-lead leading-relaxed text-muted-foreground",children:C.description}),t.jsxs("span",{className:"mt-auto flex w-full items-center gap-2 pt-5 text-small text-muted-foreground",children:[t.jsx(S,{className:"size-4","aria-hidden":!0}),$,t.jsx(Ob,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),N&&t.jsxs("div",{id:E,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",C.version]}),t.jsx(Ut,{variant:"primary",label:"Use this template",prompt:m5(e,C,s),playgroundHref:bl(C)})]})]},C.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:ON(Im("")),children:"start from a blank agent"}),"."]})]})}function xE({run:e,named:n=!1}){var l,d;const s=(l=e.workflow)==null?void 0:l.name,r=n?((d=e.workflow)==null?void 0:d.repick)??null:null;if(e.path==="workflow")return t.jsxs("span",{"data-run-kind":"learned",className:"inline-flex items-center gap-1.5",title:s?`Answered by the learned workflow ${s}${r?" on its re-pick":""}`:"Answered by a learned workflow",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,className:"shrink-0",children:t.jsx("circle",{cx:"5",cy:"5",r:"4",className:"fill-chart-workflow"})}),t.jsxs("span",{className:"text-foreground",children:["Learned workflow",n&&s?` ${s}`:"",r&&t.jsx("span",{"data-run-repick":r,className:"text-muted-foreground",children:" · re-picked"})]})]});const o=n&&e.path==="handed_back"?s:void 0,i=o&&r?r==="missed"?" after its re-pick missed":" after a re-pick":"";return t.jsxs("span",{"data-run-kind":e.kind,children:[e.kind,o&&` · handed back by ${o}${i}`]})}const bE=g.createContext(new Map),L9={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function vE({run:e}){const n=g.useContext(bE);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${L9[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(Wd,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const Pm=["queued","working","paused","input_required","completed","failed","cancelled"],M9={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function I9({runs:e,agentName:n,onOpen:s,error:r,onRetry:o,onMore:i,loadingMore:l,filter:d={},onFilter:u,agentId:f,observations:h}){var y;const v=!!d.archived,b=!v&&!d.status&&!f?h:void 0,m=!!((y=b==null?void 0:b.data)!=null&&y.sessions.length),x=!!b&&!b.data&&(b.loading||!!b.error);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:ee(ha,"mr-auto"),children:[t.jsx(Hd,{className:"size-4","aria-hidden":!0}),v?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Ft,{label:"Runs in one state",value:d.status??"",onChange:j=>u({...d,status:j||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...Pm.map(j=>({value:j,label:M9[j]}))]}),t.jsxs(W,{size:"sm",variant:v?"primary":"outline","aria-pressed":v,onClick:()=>u({...d,archived:!v}),children:[t.jsx(Fd,{"aria-hidden":!0})," Archived"]})]}),t.jsx(Ut,{label:"Query",prompt:`${bh(location.origin,f)}
|
|
687
|
-
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${v?"archived runs":"non-archived runs"}.`,playgroundHref:wv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(on,{problem:r,onRetry:o,className:""}):e?!e.length&&(d.status||v)?t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":"No archived runs."}):!e.length&&(m||x)?t.jsxs("div",{className:"space-y-3 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"No captured runs yet"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Continue working with your agents. Completed prompts appear here when they are recorded."}),t.jsx("a",{href:"#/agents",className:"inline-block text-body underline underline-offset-2",children:"Connected agents"})]}):e.length?t.jsx(D9,{runs:e,agentName:n,onOpen:s}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(P9,{})}):t.jsx(cs,{label:"Loading the runs"}),(b==null?void 0:b.error)&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsxs(ct,{tone:"error",actions:t.jsx(W,{size:"xs",disabled:b.loading,onClick:b.refresh,children:"Try again"}),children:["Could not refresh connected agents: ",b.error]})}),e&&r&&t.jsx(on,{problem:r,className:"mt-4"}),e&&i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(W,{type:"button",size:"sm",onClick:i,disabled:l,children:l?"Loading":"Load more"})})]})]})}function P9(){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:Fs({variant:"solid",size:"lg"}),children:[t.jsx(Ao,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:Fs({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function D9({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(ql,{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:Hn(r)}),t.jsx(So,{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:t.jsx(xE,{run:r})}),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:ua(r.cost,{ended:Co(r.status)})})]},r.run_id))})]})}function z9({agentId:e,details:n}){const{denied:s,asks:r}=v6(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 F9(e,{base:n="/v2",onProgress:s,signal:r,request:o=()=>new XMLHttpRequest}={}){return new Promise((i,l)=>{if(r!=null&&r.aborted)return l(new Ue(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 v=u==null?void 0:u.file;return v!=null&&v.file_id?(s==null||s(1),i(v)):l(new Ue(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,h=new Ue(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&&(h.fields=f.fields),l(h)},d.onerror=()=>l(new Ue(0,"network","The upload did not reach the server.")),d.onabort=()=>l(new Ue(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const U9=(e,n,s)=>F9(e,{onProgress:n,signal:s});function cx(e){if(!(e instanceof Ue))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 W9({upload:e,remove:n,limits:s,frozen:r=!1}){const[o,i]=g.useState([]),[l,d]=g.useState([]),u=g.useRef(new Map),f=g.useRef(0),h=g.useRef(0);h.current=o.length;const v=g.useRef({items:o,frozen:r,remove:n});v.current={items:o,frozen:r,remove:n};const b=g.useRef(!0);g.useEffect(()=>{b.current=!0;const k=u.current;return()=>{var E;b.current=!1;for(const $ of k.values())$.abort();const{items:C,frozen:N,remove:S}=v.current;if(!N)for(const $ of C)$.file&&!$.removing&&((E=S==null?void 0:S($.file.file_id))==null||E.catch(()=>{}))}},[]);const m=g.useCallback(k=>{if(v.current.frozen)return;const C=[],N=s?s.max_files_per_run-h.current:1/0,S=(s==null?void 0:s.max_upload_bytes)??null,E=[];for(const L of k)S!==null&&L.size>S?C.push({text:`${L.name} is ${hr(L.size)}: this server takes files up to ${hr(S)}.`}):E.length>=N?C.push({text:`${L.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):E.push(L);d(C);const $=E.map(L=>({key:`f${f.current++}`,name:L.name,size:L.size,progress:0}));h.current+=$.length,i(L=>[...L,...$]),$.forEach((L,A)=>{const P=new AbortController;u.current.set(L.key,P);const O=T=>{b.current&&i(M=>M.map(F=>F.key===L.key?{...F,...T}:F))};e(E[A],T=>O({progress:T}),P.signal).then(T=>{var M,F,I;if(u.current.delete(L.key),P.signal.aborted){(I=(F=(M=v.current).remove)==null?void 0:F.call(M,T.file_id))==null||I.catch(V=>{b.current&&d(G=>[...G,{text:`${L.name} was sent before it was stopped, and was not removed: ${cx(V)}`}])});return}O({file:T,progress:1})},T=>{u.current.delete(L.key),!(P.signal.aborted||!b.current)&&(i(M=>M.filter(F=>F.key!==L.key)),d(M=>[...M,{text:`${L.name}: ${cx(T)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),x=g.useCallback(k=>{var $;const{items:C,frozen:N,remove:S}=v.current,E=C.find(L=>L.key===k);if(!(N||!E||E.removing)){if(!E.file||!S){($=u.current.get(k))==null||$.abort(),u.current.delete(k),i(L=>L.filter(A=>A.key!==k));return}i(L=>L.map(A=>A.key===k?{...A,removing:!0}:A)),d(L=>L.filter(A=>A.about!==k)),S(E.file.file_id).then(()=>{b.current&&i(L=>L.filter(A=>A.key!==k))},L=>{b.current&&(i(A=>A.map(P=>P.key===k?{...P,removing:!1}:P)),d(A=>[...A,{about:k,text:`${E.name} was not removed: ${cx(L)}`}]))})}},[]),y=g.useCallback(()=>{v.current={...v.current,items:[]},i([]),d([])},[]),j=o.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:o,refusals:l.map(k=>k.text),add:m,drop:x,clear:y,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function LN({attachments:e,limits:n,disabled:s,compact:r=!1}){const o=g.useRef(null),[i,l]=g.useState(!1),{items:d,refusals:u,add:f,drop:h}=e,v=s||e.frozen,b=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${hr(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:ee("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:m=>{v||(m.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:m=>{m.preventDefault(),l(!1),v||f([...m.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(W,{type:"button",size:"sm",onClick:()=>{var m;return(m=o.current)==null?void 0:m.click()},disabled:v,title:r?`Attach files${b?` (${b})`:""}`:void 0,className:ee(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(wA,{"aria-hidden":!0})," ",t.jsx("span",{className:ee(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:ee("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",b?` (${b})`:"",". The run finds them in inputs/."]}),t.jsx("input",{ref:o,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:m=>{f([...m.target.files??[]]),m.target.value=""}})]}),d.length>0&&t.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:d.map(m=>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:m.name,children:m.name}),t.jsx("span",{className:"text-muted-foreground",children:hr(m.size)}),!m.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${m.name} sent ${Math.round(m.progress*100)}%`,children:[Math.round(m.progress*100),"%"]}),m.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>h(m.key),disabled:v||m.removing,"aria-label":`Remove ${m.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Oo,{className:"size-3.5","aria-hidden":!0})})]},m.key))}),d.some(m=>!m.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((m,x)=>t.jsx("li",{children:m},`${x}:${m}`))})]})}function Tr(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 yE=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Tr(e.cap_usd)} `:""}spend cap`;function H9({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(Lb,{className:"size-3.5","aria-hidden":!0})," ",yE(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 wE=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,jE=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function B9(e){var n,s;return e instanceof Ue?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function kE({cap:e,suggested:n,least:s=null,paused:r,onRaise:o}){const[i,l]=g.useState(n===null?"":String(n)),[d,u]=g.useState(!1),[f,h]=g.useState(null),[v,b]=g.useState(null),m=g.useRef(!1),x=Number(i),y=i.trim()!==""&&Number.isFinite(x)&&x>0,j=async k=>{if(k==null||k.preventDefault(),!(!y||m.current)){m.current=!0,u(!0),h(null),b(null);try{const C=await o(x);C.note&&b(C.note)}catch(C){h(B9(C))}finally{m.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(Fe,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>l(k.target.value),disabled:d,placeholder:`more than ${Tr(e)}`,className:"h-9 w-32"})]}),t.jsx(W,{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: ",Tr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Tr(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}),v&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:v})]})}function q9({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(Mb,{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(jl,{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."})]})}const Bf={"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:"This run's spend cap in dollars. Empty uses the agent's default cap, or none if it has 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."},ky=(e,n)=>e instanceof Ue?{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 G9({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:l,onOpenRun:d,result:u=null,live:f,limits:h,upload:v=U9,removeUpload:b}){var qt,At,Et,B;const[m,x]=g.useState(o??((qt=e[0])==null?void 0:qt.agent_id)??"");g.useEffect(()=>{var J;o&&o!==m&&e.some(de=>de.agent_id===o)?x(o):e.some(de=>de.agent_id===m)||x(((J=e[0])==null?void 0:J.agent_id)??"")},[e,o]);const y=e.find(J=>J.agent_id===m),j=Ch(y),k=is(y==null?void 0:y.definition),C=(y==null?void 0:y.kind)??"agentic",[N,S]=g.useState(""),[E,$]=g.useState(""),L=E?(At=n.find(J=>J.revision===E))==null?void 0:At.definition:void 0,A=E?L:y==null?void 0:y.definition,P=A?typeof A.max_cost_usd=="number"&&A.max_cost_usd>0?A.max_cost_usd:null:void 0,O=E?"that revision's":"the agent's",T=P===void 0?`This run's spend cap in dollars. Empty uses ${O} default cap, or none if it has none.`:P===null?"This run's spend cap in dollars. Empty runs it with no cap.":`This run's spend cap in dollars. Empty uses ${O} default cap, ${Tr(P)}.`,M=C==="agentic"?JSON.stringify(((Et=L??(y==null?void 0:y.definition))==null?void 0:Et.input_schema)??null):"null",F=g.useMemo(()=>C==="agentic"?OW(JSON.parse(M)):null,[C,M]),I=(F==null?void 0:F.kind)==="fields"?F.form:null,V=C==="workflow"||(F==null?void 0:F.kind)==="json",[G,q]=g.useState({});g.useEffect(()=>{q(I?B$(I):{})},[m,M]);const H=C==="workflow"?pW(y==null?void 0:y.definition.workflow):(F==null?void 0:F.kind)==="json"?F.example:null,U=g.useRef("");g.useEffect(()=>{if(N.trim()&&N!==U.current)return;const J=(H==null?void 0:H.text)??"";U.current=J,S(J)},[m,H==null?void 0:H.text]);const[Q,D]=g.useState(""),[Y,K]=g.useState(""),[Z,se]=g.useState(""),[ie,Ne]=g.useState("form"),[he,ve]=g.useState(u?"response":"code"),[Ee,ye]=g.useState("curl"),[pe,Pe]=g.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),ue=g.useId(),[ge,Te]=g.useState(u),Xe=new Set((I==null?void 0:I.fields.map(([J])=>J))??[]),je=J=>{const de=hb(J);return de!==null&&Xe.has(de)?de:null},fe=g.useMemo(()=>{var at,qe;const J=ge&&ge.status>=400?(at=ge.body)==null?void 0:at.error:void 0;if(!J||typeof J.message!="string")return;const de=Array.isArray(J.fields)?J.fields.filter(ft=>!!ft&&typeof ft.field=="string"&&typeof ft.message=="string"):[],_e=de.filter(ft=>ft.message!==J.message&&je(ft.field)===null&&!(I&&ft.field==="input.content"));return{message:J.message,more:_e,issues:de,box:typeof((qe=J.details)==null?void 0:qe.box)=="string"?J.details.box:void 0,details:J.code==="agent_not_runnable"?J.details:void 0}},[ge,M]),[De,te]=g.useState(new Set);g.useEffect(()=>{te(new Set)},[ge]);const Ie=(J,de,_e)=>{q(at=>({...at,[J]:_e})),te(at=>{const qe=new Set(at);return by(de,_e)?qe.add(J):qe.delete(J),I&&DW(I,de,_e)&&qe.add("input.content"),qe})},We=J=>{S(J),J.trim()&&te(de=>new Set(de).add("input.content"))},rt=J=>De.has(J)?[]:((fe==null?void 0:fe.issues)??[]).filter(de=>je(de.field)===J),ot=De.has("input.content")||(B=PW(I,fe==null?void 0:fe.issues))==null?void 0:B.message,[wt,jt]=g.useState(!1),we=g.useMemo(()=>yi(),[]),ze=W9({upload:v,remove:b,limits:h,frozen:wt}),st=fW(C,{text:N,revision:E,effort:Q,maxCostUsd:Y,fileIds:ze.fileIds,repo:Z,...I?{typed:{fields:Uh(I,G),contentRequired:I.contentRequired}}:{},...(F==null?void 0:F.kind)==="json"?{json:!0}:{}}),xe=st.ok?st.body:{input:V?N:I?IW(I,N,G):{content:N},...ze.fileIds.length?{file_ids:ze.fileIds}:{}},Be=m?we.keyFor(m,xe):"",$t=Ee==="curl"?gW(r,m,xe,Be):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${m||"{agent_id}"}/runs`)}, {
|
|
688
|
-
method: "POST",
|
|
689
|
-
headers: {
|
|
690
|
-
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
691
|
-
"Content-Type": "application/json",
|
|
692
|
-
"Idempotency-Key": ${JSON.stringify(Be)},
|
|
693
|
-
},
|
|
694
|
-
body: JSON.stringify(${JSON.stringify(xe,null,2).replace(/\n/g,`
|
|
695
|
-
`)}),
|
|
696
|
-
});
|
|
697
|
-
console.log(res.status, await res.json());`,et=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!Y.trim()||!!Q||!!Z.trim()||ze.fileIds.length>0||ze.busy),dt=async()=>{if(k||et||!st.ok||!l||ze.busy)return;jt(!0);const J=await bW(we,m,st.body,l);jt(!1),Te(J),ve("response"),Pe(!0),J.status>=200&&J.status<300&&ze.clear()},Lt=V?C==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${I?"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(Ft,{id:"playground-agent",label:"Agent",value:m,onChange:J=>{x(J),$(""),i==null||i(J)},options:PC(e).map(J=>({value:J.agent_id,label:J.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Ro(k)," · 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/",m||"{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(Ut,{variant:"primary",label:"Run agent",prompt:lv(r,m,k)})]}):t.jsxs("div",{className:ee("relative grid min-h-0 flex-1 grid-cols-1",pe?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:ee("flex min-h-0 flex-col border-b",pe?"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:ee(MN,"justify-between border-b",!pe&&"lg:[@media(min-height:501px)]:pr-80 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(J=>t.jsx("button",{type:"button","aria-pressed":ie===J,onClick:()=>Ne(J),className:ee("min-h-6 border-b pb-1 capitalize",ie===J?"border-primary":"border-transparent text-muted-foreground"),children:J==="json"?"JSON":"Form"},J))})]}),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."]}),et&&t.jsx("p",{className:"text-warning-text",children:Z.trim()?"This request selects a repository. Native execution uses its source project.":Y.trim()?"This request has a spend cap. Native execution cannot enforce it.":Q||ze.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."}),!!Z.trim()&&t.jsx(W,{size:"sm",onClick:()=>se(""),children:"Use native source repository"}),!!Q&&t.jsx(W,{size:"sm",onClick:()=>D(""),children:"Use native configured effort"}),ze.fileIds.length>0&&t.jsx(W,{size:"sm",onClick:()=>ze.clear(),children:"Remove uploaded attachments"}),!!Y.trim()&&t.jsx(W,{size:"sm",onClick:()=>K(""),children:"Remove cap for native execution"}),t.jsx("a",{href:jn(m),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}: ${C==="agentic"?"an":"a"} ${C} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),ie==="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(xe,null,2)}),!j&&t.jsx(qa,{name:"file_ids",note:Bf.file_ids,children:t.jsx(LN,{attachments:ze,limits:h})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(qa,{htmlFor:"playground-input",name:V?"input":"input.content",required:!I||I.contentRequired,optional:!!I&&!I.contentRequired,error:!st.ok&&st.field==="input"&&N?st.message:ot,children:[t.jsx(An,{id:"playground-input",value:N,onChange:J=>We(J.target.value),"aria-invalid":ot?!0:void 0,rows:V?7:4,placeholder:Lt,className:IN}),H&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[hW(H,"start",C==="workflow"?"workflow":"agent"),H.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",H.fields.map((J,de)=>t.jsxs("span",{title:J.note,children:[de?", ":"",t.jsx("span",{className:"text-foreground",children:J.name})]},J.name)),"."]})]})]}),I==null?void 0:I.fields.map(([J,de])=>t.jsxs("div",{"data-field":`input.${J}`,children:[t.jsx(K$,{field:de,label:Fh(J,de),help:Mm(de),value:G[J]??"",onChange:_e=>Ie(J,de,_e)}),t.jsx(oa,{issues:rt(J),words:_e=>G$(_e,J,de)})]},J)),!j&&t.jsx(qa,{name:"file_ids",note:Bf.file_ids,children:t.jsx(LN,{attachments:ze,limits:h})}),t.jsx(qa,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Ft,{label:"Revision",value:E,onChange:$,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(J=>({value:J.revision,label:`rev ${J.version}${J.current?" (current)":""}${J.note?`: ${J.note}`:""}`}))]})}),!j&&t.jsx(qa,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Ft,{label:"Effort",value:Q,onChange:D,className:"w-full",options:["",...s].map(J=>({value:J,label:J||"Agent default"}))})}),C==="agentic"&&!j&&t.jsx(qa,{htmlFor:"playground-repo",name:"repo",note:Bf.repo,error:!st.ok&&st.field==="repo"?st.message:void 0,children:t.jsx(Fe,{id:"playground-repo",value:Z,onChange:J=>se(J.target.value),placeholder:"owner/name"})}),C==="agentic"&&!j&&t.jsxs(qa,{htmlFor:"playground-cap",name:"max_cost_usd",note:T,error:!st.ok&&st.field==="max_cost_usd"?st.message:void 0,children:[t.jsx(Fe,{id:"playground-cap",value:Y,onChange:J=>K(J.target.value),inputMode:"decimal",placeholder:typeof P=="number"?Tr(P):"e.g. 0.50",className:IN}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(o$,{})})]})]})]}),t.jsxs("footer",{className:ee(dx,"shrink-0 flex-wrap justify-between gap-3"),children:[t.jsx("span",{title:"Sends a real request to this server.",className:"line-clamp-2 min-w-0 flex-1 basis-24 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(Ut,{size:"lg",label:"Use your agent",prompt:p5(r,m,xe),disabled:et||!st.ok||!m||ze.busy}),t.jsxs(W,{variant:"primary",size:"lg",onClick:dt,disabled:et||!st.ok||!l||wt||!m||ze.busy,title:ze.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Ao,{"aria-hidden":!0})," ",wt?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ee("flex min-h-0 flex-col",!pe&&"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:ee("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",pe?ee(MN,"border-b"):"py-2 lg:[@media(min-height:501px)]:p-0 short:p-0"),children:[t.jsxs("span",{role:"group","aria-label":"Show",className:ee("flex gap-4 text-body",!pe&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":he==="code",onClick:()=>ve("code"),className:ee("border-b pb-1",he==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":he==="response",onClick:()=>ve("response"),disabled:!ge,className:ee("border-b pb-1 disabled:opacity-45",he==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",ge&&t.jsx("span",{className:ee("ml-2 font-mono max-sm:hidden",ge.status<300?"text-success-text":"text-destructive-text"),children:ge.status})]})]}),t.jsx("span",{className:"ml-auto flex items-center gap-2",children:t.jsxs(W,{type:"button",size:"sm",className:"max-sm:px-2","aria-expanded":pe,"aria-controls":ue,onClick:()=>Pe(J=>!J),children:[pe?t.jsx(lA,{"aria-hidden":!0}):t.jsx(qm,{"aria-hidden":!0})," ",pe?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:ue,className:ee("flex min-h-0 flex-1 flex-col",!pe&&"hidden"),children:he==="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(J=>t.jsx("button",{type:"button","aria-pressed":Ee===J,onClick:()=>ye(J),className:ee("-mb-px border-b-2 py-2.5",Ee===J?"border-primary":"border-transparent text-muted-foreground"),children:J==="curl"?"cURL":"JavaScript"},J))}),t.jsx(W,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var J;return void((J=navigator.clipboard)==null?void 0:J.writeText($t))},children:t.jsx(fi,{"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:$t}),t.jsx("footer",{className:ee(dx,"text-small text-muted-foreground"),children:"The same request from your code: set AGENTRUN_API_KEY in your environment."})]}):ge&&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:ge.status<300?"text-success-text":"text-destructive-text",children:ge.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[ge.ms," ms"]})]}),fe&&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: ",fe.message,fe.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",fe.box,")"]}):null,t.jsx(z9,{agentId:m,details:fe.details}),fe.more.length>0&&t.jsx("span",{className:"mt-1 block",children:fe.more.map(J=>t.jsxs("span",{className:"block",children:[J.field,": ",J.message]},`${J.field}:${J.message}`))})]}),ge.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(ge.runId)}),t.jsxs("details",{className:"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(ge.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(ge.body,null,2)}),ge.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(ge.runId),className:ee(dx,"caps justify-between text-small text-primary-text hover:bg-accent"),children:["Open this run ",t.jsx(Ob,{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(Bf).map(([J,de])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:J}),t.jsx("dd",{className:"text-small text-muted-foreground",children:de})]},J))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const MN="box-content flex min-h-control-sm items-center px-5 py-3 md:px-6",dx="box-content flex min-h-control-lg items-center border-t px-5 py-3 md:px-6",IN="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 qa({name:e,htmlFor:n,required:s,optional:r,note:o,error:i,children:l}){const d=g.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"})]}),l,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 PN="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",K9=e=>`'${e.replaceAll("'","'\\''")}'`;function V9({v2:e,origin:n,agentId:s,filter:r={}}){const[o,i]=g.useState(r.status??""),[l,d]=g.useState(!!r.archived),[u,f]=g.useState(50),[h,v]=g.useState(""),[b,m]=g.useState("code"),[x,y]=g.useState("curl"),[j,k]=g.useState(null),[C,N]=g.useState(null),[S,E]=g.useState(!1),[$,L]=g.useState(!1),A=g.useRef(0);g.useEffect(()=>(A.current++,i(r.status??""),d(!!r.archived),v(""),N(null),k(null),E(!1),()=>{A.current++}),[s,r.status,r.archived]);const P={...o?{status:o}:{},...l?{archived:!0}:{}},O=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",T=new URLSearchParams({limit:String(u)});h&&T.set("cursor",h),o&&T.set("status",o),l&&T.set("archived","true");const M=`${n}${O}?${T}`,F=x==="curl"?`curl -X GET ${K9(M)} \\
|
|
698
|
-
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(M)}, {
|
|
699
|
-
method: "GET",
|
|
700
|
-
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
701
|
-
});
|
|
702
|
-
console.log(response.status, await response.json());`,I=`${bh(n,s)}
|
|
703
|
-
|
|
704
|
-
Prepared read-only request: GET ${M}
|
|
705
|
-
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.`,V=()=>{A.current++,v(""),N(null),k(null),L(!1)},G=async(q=h)=>{if(S)return;const H=++A.current;E(!0),N(null),k(null),v(q),L(!1);const U=performance.now();try{const Q=s?await e.listAgentRuns(s,u,q||void 0,P):await e.listRuns(u,q||void 0,P);if(A.current!==H)return;N(Q),k({status:200,ms:performance.now()-U,body:Q})}catch(Q){if(A.current!==H)return;k(ky(Q,performance.now()-U))}finally{A.current===H&&(E(!1),m("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(Fe,{className:PN,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(Ft,{label:"Run status",value:o,disabled:S,onChange:q=>{i(q),V()},options:[{value:"",label:"All statuses"},...Pm.map(q=>({value:q,label:q.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Ft,{label:"Archived runs",value:String(l),disabled:S,onChange:q=>{d(q==="true"),V()},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(Ft,{label:"Page size",value:String(u),disabled:S,onChange:q=>{f(Number(q)),V()},options:[10,25,50,100].map(q=>({value:String(q),label:String(q)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Fe,{"aria-label":"Cursor",className:`${PN} font-mono text-small`,value:h,disabled:S,placeholder:"First page",onChange:q=>{A.current++,v(q.target.value),N(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(Ut,{size:"md",label:"Use your agent",prompt:I}),t.jsxs(W,{variant:"primary",disabled:S,onClick:()=>void G(),children:[t.jsx(Ao,{"aria-hidden":!0}),S?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(q=>t.jsx("button",{onClick:()=>m(q),className:ee("h-12 border-b text-small capitalize",b===q?"border-primary":"border-transparent text-muted-foreground"),children:q},q)),t.jsx(W,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var q;(q=navigator.clipboard)==null||q.writeText(F).then(()=>L(!0),()=>L(!1))},children:t.jsx(fi,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:$?"Code copied":""})]}),b==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(q=>t.jsx("button",{onClick:()=>y(q),className:ee("border-b text-small",x===q?"border-primary":"border-transparent text-muted-foreground"),children:q==="curl"?"cURL":"JavaScript"},q))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:F})]}):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"]}),C&&t.jsxs(t.Fragment,{children:[C.runs.length?t.jsx("ul",{className:"divide-y border",children:C.runs.map(q=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(q.run_id)}`,children:[t.jsx(ql,{run:q}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.title||q.run_id}),t.jsx(So,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},q.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),C.next_cursor&&t.jsx(W,{size:"sm",disabled:S,onClick:()=>void G(C.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:S?"Loading runs…":"Send a request to see its response."})})]})]})}const Vc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Yc="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function Y9({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[],routePrefix:l}){const d=s==="edit-agent",u=s$(),f=g.useId(),[h,v]=g.useState(null),b=R9(o??null),[m,x]=g.useState(null),[y,j]=g.useState(null),[k,C]=g.useState(void 0),[N,S]=g.useState(b??Im("")),[E,$]=g.useState(JSON.stringify(b??Im(""),null,2)),[L,A]=g.useState(E),P=a$(E!==L),[O,T]=g.useState("form"),[M,F]=g.useState("code"),[I,V]=g.useState("curl"),[G,q]=g.useState(null),[H,U]=g.useState(null),[Q,D]=g.useState(null),[Y,K]=g.useState(!1),[Z,se]=g.useState(!1),[ie,Ne]=g.useState(0),[he,ve]=g.useState(!1);g.useEffect(()=>{if(!d)return;if(!r){q("Choose an agent from Connected agents to edit its definition.");return}let xe=!0;return x(null),C(void 0),q(null),e.getAgent(r).then(({agent:Be,etag:$t})=>{if(!xe)return;x(Be),j($t);const et={definition:{...Be.definition,version:Be.revisions+1}},dt=JSON.stringify(et,null,2);S(et),$(dt),A(dt),U(null),se(!1)}).catch(Be=>{xe&&q(String(Be instanceof Error?Be.message:Be))}),()=>{xe=!1}},[e,d,r,ie]);const Ee=(xe,Be)=>{const $t={...N.definition,[xe]:xe==="model"?Be.trim():Be};xe==="model"&&!Be.trim()&&!d&&delete $t.model;const et={...N,definition:$t};S(et),$(JSON.stringify(et,null,2))};let ye=N,pe=null;if(O==="json")try{const xe=JSON.parse(E);!Vc(xe)||!Vc(xe.definition)?pe="Include a definition object in the request.":ye=xe}catch{pe="Enter valid JSON before sending the request."}!pe&&ye.note!==void 0&&typeof ye.note!="string"&&(pe="note must be a string.");for(const xe of["description","instructions","harness","model"])!pe&&ye.definition[xe]!==void 0&&typeof ye.definition[xe]!="string"&&(pe=`definition.${xe} must be a string.`);!pe&&typeof ye.definition.name!="string"&&(pe="Give this agent a name.");const Pe=!pe;!pe&&!ye.definition.name.trim()&&(pe="Give this agent a name."),!pe&&!ye.definition.workflow&&(typeof ye.definition.instructions!="string"||!ye.definition.instructions.trim())&&(pe="Add instructions for this agent.");const ue=ye;if(!pe&&d&&m){const xe=Vc(ye.definition.workflow),Be=Object.keys(m.definition).filter(et=>!Object.hasOwn(ye.definition,et));for(const et of["id","name"])!pe&&ye.definition[et]!==m.definition[et]&&(pe=`definition.${et} is fixed when the agent is created. Restore its current value.`);!pe&&Be.includes("description")&&(pe='Cannot remove definition.description: the API keeps an omitted description. Set it to "" to clear it.');for(const et of["native","sdk","cli_learning"])!pe&&m.definition[et]!==void 0&&Be.includes(et)&&(pe=`Cannot remove definition.${et} here. Edit the original source configuration with your agent.`);if(!pe&&!xe)for(const et of["input_schema","output_schema"])Be.includes(et)&&(pe=`Cannot remove definition.${et}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!pe&&Be.includes("harness")&&(pe='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!pe&&(m.definition.computer!==void 0||m.definition.place!==void 0)&&!Object.hasOwn(ye.definition,"computer")&&!Object.hasOwn(ye.definition,"place")&&(pe='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 $t=Vc(ye.skills)&&Object.keys(ye.skills).length===0;if(!pe&&!Object.hasOwn(ye.definition,"skills")&&!$t&&(m.definition.skills.length>0||Vc(ye.skills)&&Object.keys(ye.skills).length>0)&&(pe="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!pe){const et=Object.fromEntries(Be.map(At=>[At,At==="learning"?xe?void 0:!1:At==="max_cost_usd"?0:At==="checkout"?xe?void 0:"none":At==="tools"||At==="skills"?[]:void 0])),{unchanged:dt,...Lt}=Gl(m,{...et,...ye.definition},ye.note??""),qt=ye.skills!==void 0&&!gl(ye.skills,k);dt&&!qt&&(pe="Change the definition before saving a revision."),qt&&(Lt.definition.version=m.revisions+1),ye={...ye,...Lt}}}d&&m&&!y&&(pe="This server did not provide a revision ETag. Reload the current revision before editing.");const ge=d?"PUT":"POST",Te=d?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",Xe=`${n}${Te}`,je=JSON.stringify(ye,null,2),fe=xe=>`'${xe.replaceAll("'","'\\''")}'`,De={"Content-Type":"application/json",...d&&y?{"If-Match":y}:{}},te=I==="curl"?`curl -X ${ge} ${fe(Xe)} \\
|
|
706
|
-
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
707
|
-
${Object.entries(De).map(([xe,Be])=>` -H ${fe(`${xe}: ${Be}`)} \\
|
|
708
|
-
`).join("")} -d ${fe(je)}`:`const response = await fetch(${JSON.stringify(Xe)}, {
|
|
709
|
-
method: ${JSON.stringify(ge)},
|
|
710
|
-
headers: {
|
|
711
|
-
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
712
|
-
${Object.entries(De).map(([xe,Be])=>` ${JSON.stringify(xe)}: ${JSON.stringify(Be)},`).join(`
|
|
713
|
-
`)}
|
|
714
|
-
},
|
|
715
|
-
body: JSON.stringify(${je}),
|
|
716
|
-
});
|
|
717
|
-
console.log(response.status, await response.json());`,Ie=is(m==null?void 0:m.definition),We=cr(m==null?void 0:m.definition),rt=d&&(!!(m!=null&&m.definition.native)||!!Ie||!!We),ot=rt&&m?ga(n,m.agent_id,!!m.definition.native,Ie,We==null?void 0:We.runtime):`${d?ga(n,r??""):xh(n)}
|
|
718
|
-
|
|
719
|
-
Prepared request: ${ge} ${Xe}${d&&y?`
|
|
720
|
-
If-Match: ${y}`:""}. 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.
|
|
721
|
-
|
|
722
|
-
${je}`,wt=!pe&&!G&&(!d||!!m)&&!Y&&!Z,jt=typeof ue.definition.model=="string"&&ue.definition.model?ue.definition.model:void 0,we=ue.definition.harness??"pi",ze=async()=>{if(!wt)return;K(!0),D(null),v(null);const xe=performance.now(),Be=we,$t=jt,et=dt=>({harness:Be,model:$t,text:dt.map(Lt=>Lt.message).join(" ")||void 0});try{const dt=d?await e.updateDefinition(r,ye,y):{agent:await e.createAgent(ye),etag:null};v({warning:et(Kx(dt.agent.warnings,"model"))}),D(dt.agent.agent_id),A(E),U({status:d?200:201,ms:performance.now()-xe,body:dt.agent}),d?(x(dt.agent),j(dt.etag),ye.skills!==void 0&&C(ye.skills)):se(!0)}catch(dt){const Lt=ky(dt,performance.now()-xe);U(Lt),dt instanceof Ue&&v({error:et(Kx(dt.fields,"model"))}),!d&&(Lt.status===0||Lt.status>=500)&&se(!0)}finally{K(!1),F("response")}},st=t.jsxs(tv,{open:P.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:P.leave,onCancel:P.stay,children:[d?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return G?t.jsxs(t.Fragment,{children:[st,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:G}),r&&t.jsx(W,{className:"mt-3",onClick:()=>Ne(xe=>xe+1),children:"Reload agent"})]})]}):d&&!m?t.jsxs(t.Fragment,{children:[st,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(xe=>t.jsx("button",{onClick:()=>{if(xe==="form"&&O==="json"){if(!Pe)return;S(ue)}T(xe)},className:ee("h-12 border-b text-small",O===xe?"border-primary":"border-transparent text-muted-foreground"),children:xe==="json"?"JSON":"Form"},xe))})]}),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:d?"Edit agent":"Create an agent"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:d?"Save a new version of this agent’s configuration.":"Configure an agent on this server. You can run it once it is created."})]}),o&&!b&&!d&&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."}),O==="json"?t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Request JSON"}),t.jsx(An,{value:E,onChange:xe=>$(xe.target.value),className:`${Yc} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Qc,{name:"Name",children:t.jsx(Fe,{value:N.definition.name,readOnly:d,onChange:xe=>Ee("name",xe.target.value),className:Yc})}),t.jsx(Qc,{name:"Description",children:t.jsx(Fe,{value:N.definition.description??"",onChange:xe=>Ee("description",xe.target.value),className:Yc})}),N.definition.workflow?t.jsx(Qc,{name:"Workflow",children:t.jsx("pre",{className:`${Yc} overflow-auto font-mono text-small`,children:JSON.stringify(N.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Qc,{name:"Instructions",children:t.jsx(An,{value:N.definition.instructions??"",rows:5,onChange:xe=>Ee("instructions",xe.target.value),className:Yc})}),t.jsx(Qc,{name:"Harness",children:t.jsx(Ft,{label:"Harness",value:N.definition.harness??"pi",onChange:xe=>Ee("harness",xe),options:[...new Set([N.definition.harness??"pi",...i.map(xe=>xe.id)])].map(xe=>{var Be;return{value:xe,label:`${xe}${((Be=i.find($t=>$t.id===xe))==null?void 0:Be.available)===!1?" (not set up)":""}`}})})}),t.jsx(r$,{id:f,harness:we,model:jt,onModel:xe=>Ee("model",xe??""),harnesses:i,routePrefix:l,state:u,error:h==null?void 0:h.error,warning:h==null?void 0:h.warning})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>T("json"),children:"Edit all fields in JSON →"})]}),pe&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:pe}),d&&m&&!y&&t.jsx(W,{size:"sm",onClick:()=>Ne(xe=>xe+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(Ut,{size:"md",label:"Use your agent",prompt:ot,disabled:!rt&&!!pe}),t.jsxs(W,{variant:"primary",onClick:()=>void ze(),disabled:!wt,children:[t.jsx(Ao,{"aria-hidden":!0}),Y?"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(xe=>t.jsx("button",{onClick:()=>F(xe),className:ee("h-12 border-b text-small capitalize",M===xe?"border-primary":"border-transparent text-muted-foreground"),children:xe},xe)),t.jsx(W,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(te).then(()=>ve(!0),()=>ve(!1))},children:t.jsx(fi,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:he?"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(xe=>t.jsx("button",{onClick:()=>V(xe),className:ee("border-b text-small",I===xe?"border-primary":"border-transparent text-muted-foreground"),children:xe==="curl"?"cURL":"JavaScript"},xe))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:te})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:H?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("p",{className:"font-mono text-small",children:[H.status||"Network error"," · ",Math.round(H.ms)," ms"]}),Q&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:jn(Q),children:["Open agent",t.jsx(So,{className:"size-4"})]})]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(H.body,null,2)}),H.status===412&&t.jsx(W,{onClick:()=>Ne(xe=>xe+1),children:"Reload current revision"}),Z&&!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."})})]}),st]})}function Qc({name:e,children:n}){const s=g.useId();return t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:s,className:"block text-lead",children:e}),g.cloneElement(n,{id:s,"aria-label":e})]})}const Q9=[{id:"keys",label:"API 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"},{id:"slack",label:"Slack"}],Eo="p-5 md:p-8",Sa="mb-6 max-w-prose",Ca="[&>:not(section)]:mb-6";function Ws({title:e,titleId:n,note:s,aside:r,label:o,children:i}){const l=g.useId(),d=n??l;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 J9({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:J2,children:Q9.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:X2(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function Hh(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}Bs.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const o=r.value;let i=!1;const l=()=>{i=!0};r.addEventListener("input",l);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",l)}}function Mo({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(Hs,{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 X9={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",particle:"particle.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},Z9={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"},eH=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function tH({id:e,className:n}){const[s,r]=g.useState(!1),o=X9[e],i=Z9[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:eH(o),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:ee("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ee("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(ti,{className:ee("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const nH=/^(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,sH=40;function rH(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&&nH.test(r))return[];const o=r.split(/,?\s+or\s+|,\s+/i).map(l=>l.trim()).filter(Boolean);if(o.length<2||o.length>4||!/\bor\b/i.test(r))return[];const i=o.map(l=>l.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(l=>!l||l.length>sH)?[]:i.map(l=>/\s/.test(l)?l[0].toUpperCase()+l.slice(1):l)}function oH(e){var r,o;const n=new Map;for(const i of e){if(i.imported_from)continue;const l=((o=(r=i.error)==null?void 0:r.message)==null?void 0:o.trim())||"The run failed.";n.set(l,[...n.get(l)??[],i])}const s=i=>Date.parse(i.ended_at??i.created_at);return[...n].map(([i,l])=>({message:i,runs:l.sort((d,u)=>s(u)-s(d))})).sort((i,l)=>s(l.runs[0])-s(i.runs[0]))}const NE=e=>e.filter(n=>!n.imported_from).length,aH=864e5;function iH(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Jl(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 lH(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 cH(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const SE=e=>e.pending!=null&&e.pending.kind!=="stopped",dH=e=>e.status==="input_required"&&e.state!=="waiting"&&!SE(e),uH=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function DN(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 uH.forEach(([o,i],l)=>{const d=n[l];(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 Bh({field:e,label:n,writable:s,required:r=!0,stateSaid:o=!1,actionsInline:i=!1,now:l=Date.now,note:d,onPaste:u,onRemove:f}){const h=e.source==="env",v=s&&!h;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ee("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",h&&"opacity-60"),children:[t.jsxs("span",{children:[_m(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":d?"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:W8[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Jl(e.changed_at,l())," ago"]}),d&&t.jsx("span",{className:"text-warning-text",children:d}),v&&t.jsxs("span",{className:ee("flex gap-2 font-sans",!i&&"ml-auto"),children:[u&&t.jsx(W,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),f&&e.set&&t.jsx(W,{type:"button",size:"sm",variant:"destructive",onClick:f,children:"Remove"})]})]})}const zN={anthropic:{url:"https://console.anthropic.com/settings/keys",placeholder:"sk-ant-…",note:FI},openai:{url:"https://platform.openai.com/api-keys",placeholder:"sk-…"},openrouter:{url:"https://openrouter.ai/keys",placeholder:"sk-or-…"},particle:{url:"https://platform.particle.ai/",placeholder:"pai-…"}},xb=e=>Object.prototype.hasOwnProperty.call(zN,e)?zN[e]:void 0,fH={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."},FN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function UN(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 mH="can't be opened: paste it again",hH=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],bb="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function pH({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:o,harnesses:i}){const[l,d]=g.useState(null),[u,f]=g.useState(null),[h,v]=g.useState(null),[b,m]=g.useState(null),x=g.useRef(0),y=()=>{const $=++x.current;e.listToolKeys().then(L=>{$===x.current&&(d(L),f(null))}).catch(L=>{$===x.current&&f(FN(L))})};g.useEffect(y,[e]);const j=$=>v(L=>L===$?null:L),k=$=>{j($),y(),n==null||n()},C=($,L,A,P)=>{m({id:$,title:L,error:FN(A)}),A instanceof Ue&&A.code==="key_set_by_server"&&(j(P),y())};if(!l)return u?t.jsx(WN,{error:u,onRetry:y}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(cs,{label:"Loading API keys",rows:3})});const N=l.reenter,S=hH.map($=>({...$,keys:l.keys.filter(L=>L.kind==="model"==($.kind==="model"))})).filter($=>$.keys.length),E=$=>t.jsx(gH,{tool:$,writable:s,again:!!N&&$.fields.some(L=>L.stored_unreadable||N.fields.includes(L.name)),open:(h==null?void 0:h.id)===$.id?h.mode:null,problem:(b==null?void 0:b.id)===$.id?b:null,onOpen:L=>{v(L?{id:$.id,mode:L}:null),m(null)},onSave:async L=>{const A=h;try{await e.saveToolKey($.id,L)}catch(P){return P instanceof Ue&&P.status===422?P:(C($.id,"The key was not saved",P,A),null)}return k(A),null},onRemove:async()=>{const L=h;try{await e.removeToolKey($.id)}catch(A){C($.id,"The key was not removed",A,L);return}k(L)}},$.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"API 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:Ca,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:no[r]}),u&&t.jsx(WN,{inline:!0,error:u,onRetry:y}),N&&t.jsxs(ct,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:fH[N.reason]}),t.jsx("p",{className:"mt-2 font-mono",children:N.fields.length?N.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),S.map($=>t.jsx(Ws,{label:$.label,title:$.label,note:$.kind==="model"?t.jsx("p",{children:bb}):void 0,children:t.jsxs("ul",{className:"border",children:[$.kind==="model"&&o,$.keys.map(E)]})},$.label)),i&&t.jsx(d$,{harnesses:i})]})]})})}function WN({error:e,onRetry:n,inline:s=!1}){return t.jsx(ct,{tone:"error",className:s?void 0:"m-8",actions:t.jsx(W,{type:"button",size:"xs",onClick:n,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The API keys could not be read: ",e.code,": ",e.message]})})}function gH({tool:e,writable:n,again:s,open:r,problem:o,onOpen:i,onSave:l,onRemove:d}){var m,x;const u=g.useRef(null),f=y=>e.secrets.find(j=>_m(j.name)===y.name),h=y=>e.fields.find(j=>j.name===_m(y.name)),v=e.fields.filter(y=>{var j;return((j=f(y))==null?void 0:j.source)!=="env"}),b=e.secrets.filter(y=>y.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(tH,{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:b===e.secrets.length?"success":"plain",children:b===e.secrets.length?"set":b?`${b} 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(", ")}`]}),((m=xb(e.id))==null?void 0:m.note)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:xb(e.id).note}),UN(e.label,e.check)&&t.jsx("p",{className:`mt-1.5 text-small ${((x=e.check)==null?void 0:x.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:UN(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(y=>{var j;return t.jsx(Bh,{field:y,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(j=h(y))!=null&&j.stored_unreadable?mH:void 0,onPaste:()=>void Hh(()=>i("edit"),()=>{var k,C,N;return(N=(k=u.current)==null?void 0:k.querySelector("form"))==null?void 0:N.elements.namedItem(((C=h(y))==null?void 0:C.name)??"")}),onRemove:y.source==="console"?()=>i("remove"):void 0},y.name)})}),!v.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(CE,{tool:e,fields:v,onSave:l,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(y=>y.source==="env")?" The one set in the environment stays.":""]}),t.jsx(W,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(W,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),o&&t.jsx("div",{className:"mt-4 border",children:t.jsx(Mo,{error:o.error,title:o.title})})]})}function CE({tool:e,fields:n,onSave:s,onCancel:r}){const o=g.useRef(null),[i,l]=g.useState(!1),[d,u]=g.useState(!1),[f,h]=g.useState(null),v=()=>n.some(y=>{var j,k;return(k=(j=o.current)==null?void 0:j.elements.namedItem(y.name))==null?void 0:k.value}),b=()=>{var y;(y=o.current)==null||y.reset(),l(!1)},m=async y=>{var S,E;y.preventDefault();const j={};for(const $ of n){const L=(E=(S=o.current)==null?void 0:S.elements.namedItem($.name))==null?void 0:E.value;L&&(j[$.name]=L)}if(!Object.keys(j).length)return;u(!0),h(null);const k=await s(j);if(u(!1),!k){b();return}const C={},N=[];for(const $ of k.fields??[]){const L=$.field.startsWith("values.")?$.field.slice(7):null;L&&n.some(A=>A.name===L)?C[L]=$.message:N.push($.message)}h({fields:C,message:N.length?N.join(" "):Object.keys(C).length?null:k.message})},x=xb(e.id);return t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:y=>void m(y),onInput:()=>l(!!v()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[x&&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:x.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(Fe,{type:"password",name:y.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:x&&n.length===1?x.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(W,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(W,{type:"button",size:"sm",onClick:()=>{b(),r()},children:"Cancel"})]})]})}const hu=g.createContext(null);function HN({connection:e,children:n}){return t.jsx(hu.Provider,{value:e,children:n})}const xH={state:"online"},bH=()=>()=>{},BN=()=>xH;function Ny(){const e=g.useContext(hu);return g.useSyncExternalStore(e?e.subscribe:bH,e?e.link:BN,BN)}function _E(e){const n=g.useContext(hu),s=g.useRef(e);s.current=e,g.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function $E(e){const[n,s]=g.useState(()=>Date.now());return g.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 vH(){const e=g.useContext(hu),n=Ny(),s=$E(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(ct,{bar:!0,tone:"success",icon:pi,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(ct,{bar:!0,tone:"warning",icon:rS,"data-connection":"offline",actions:t.jsx(W,{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 yH(){const e=g.useContext(hu),n=Ny(),s=$E(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(rS,{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(W,{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 wH=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:S_(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"}:{}}]:[]})),qN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function jH({v2:e,choices:n,gates:s=[],harnesses:r,mcp:o=!1,onSaved:i,onOpen:l}){const[d,u]=g.useState(null),[f,h]=g.useState(null),v=()=>{o&&(h(null),e.listMcpServers().then(U=>h(U.servers),()=>h("failed")))};g.useEffect(v,[e,o]);const[b,m]=g.useState(null),[x,y]=g.useState(null),[j,k]=g.useState(!1),[C,N]=g.useState(null),S=g.useRef(0),E=()=>{const U=++S.current;e.toolSettings().then(Q=>{U===S.current&&(u(Q),m(null))},Q=>{U===S.current&&m(qN(Q))})};g.useEffect(E,[e]);const[$,L]=g.useState("reading"),A=()=>{L("reading"),Promise.resolve(l==null?void 0:l()).then(U=>L(U===!1?"failed":"landed"))},P=()=>{E(),A()};if(g.useEffect(A,[]),!d)return b?t.jsx(ct,{tone:"error",className:"m-8",actions:t.jsx(W,{type:"button",size:"xs",onClick:E,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",b.code,": ",b.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const O=eb(d,n),T=C?C(O):O,M=n$(n,[...s,...Array.isArray(f)?wH(f,s.some(U=>U.ask_needs==="password")):[]]),F=U=>{var D;const Q=_o(U);return Q?(D=T[`mcp:${Q.server}/*`])==null?void 0:D.permission:void 0},I=Object.entries(T).filter(([,U])=>(U==null?void 0:U.pin)||(U==null?void 0:U.pin_broken)),V=U=>{var D;const Q=s.find(Y=>Y.name===U);return!Q||(((D=T[U])==null?void 0:D.permission)??Q.default_permission)===Q.permission},{byTool:G,rest:q}=q_((x==null?void 0:x.fields)??{},"",M.map(U=>U.name)),H=async U=>{var K;const Q=C?Z=>U(C(Z)):U;k(!0),y(null);const D=++S.current;let Y;try{Y=await e.toolSettings()}catch{N(()=>Q),y({fields:{},error:null,unread:!0}),k(!1);return}try{const Z=await e.saveToolSettings(Q(eb(Y,n)));N(null),D===S.current&&(u(Z),m(null)),i()}catch(Z){y(Z instanceof Ue&&Z.status===422&&((K=Z.fields)!=null&&K.length)?{fields:Object.fromEntries(Z.fields.map(se=>[se.field,se.message])),error:null}:{fields:{},error:qN(Z)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[M.length?t.jsx(ay,{label:"This server's tool settings",rows:M,settings:T,fallbackOf:U=>U.default_provider,issues:G,busy:j,onEdit:U=>void H(U),permissionFallbackOf:U=>F(U.name)??U.default_permission,refused:(U,Q)=>Q==="deny",resolvesOf:(U,Q)=>Q===U.provider&&V(U.name)?t.jsx(S8,{choice:U,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(W,{type:"button",onClick:P,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(W,{type:"button",size:"xs",className:"ml-1",onClick:v,disabled:j,children:"Retry"})]}),q.map(U=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:U},U)),(x==null?void 0:x.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(Mo,{error:x.error,title:"The change was not saved"})}),(x==null?void 0:x.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(W,{type:"button",size:"xs",className:"mt-2",onClick:()=>void H(U=>U),disabled:j,children:"Try again"})]}),b&&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: ",b.code,": ",b.message]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),t.jsx(W,{type:"button",onClick:P,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),I.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:I.map(([U,Q])=>t.jsxs("li",{"data-pin":U,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:U}),t.jsx(rb,{setting:Q})]},U))})]})]})]})})}function kH(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 GN={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."},NH=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(GN,e.reason)?GN[e.reason]:"The connection didn't finish. Try again.";function SH(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 CH({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?Rr(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 _H({v2:e,returned:n}){const[s,r]=g.useState(void 0),[o,i]=g.useState(null),[l,d]=g.useState(""),[u,f]=g.useState(!1),[h,v]=g.useState(null),[b,m]=g.useState(null),[x,y]=g.useState(null),[j,k]=g.useState(!1),[C,N]=g.useState(null),S=g.useRef(!1),E=g.useRef(null),$=g.useCallback(async()=>{try{const O=await e.githubConnection();r(O.connected?O:null),i(null)}catch(O){i(O instanceof Error?O.message:String(O))}},[e]);g.useEffect(()=>{$()},[$]),g.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),g.useEffect(()=>{var O;h&&((O=E.current)==null||O.submit())},[h]);const L=async()=>{var O;if(!S.current){S.current=!0,f(!0),m(null),y(null),N(null);try{const T=await e.connectGitHub(l.trim()||void 0),M=SH(T.action,Rr);if(!M){m("GitHub's address didn't look right, so nothing was sent."),S.current=!1,f(!1);return}v({action:M,manifest:JSON.stringify(T.manifest)})}catch(T){if(S.current=!1,f(!1),m(T instanceof Error?T.message:String(T)),T instanceof Ue&&T.code==="github_wrong_origin"){const M=(O=T.details)==null?void 0:O.public_url;y(typeof M=="string"&&Rr(M)||null)}T instanceof Ue&&T.code==="github_already_connected"&&$()}}},A=async()=>{k(!1),f(!0),m(null),y(null);try{N(await e.disconnectGitHub()),r(null)}catch(O){O instanceof Ue&&(O.status===404||O.code==="github_not_connected")?await $():m(O instanceof Error?O.message:String(O))}finally{f(!1)}},P=s?Rr(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,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:Ca,children:[n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:ee("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:NH(n)}),(b||x)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:x?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:x,className:"break-all underline underline-offset-2",children:x})," to connect GitHub."]}):t.jsx("p",{children:b})}),C&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx(CH,{note:C.note})}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:C.triggers_off?`${C.triggers_off} GitHub ${C.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),o&&t.jsx(ct,{tone:"error",actions:t.jsx(W,{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(Ws,{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(Fe,{name:"org",value:l,onChange:O=>d(O.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(W,{type:"button",variant:"solid",onClick:()=>void L(),disabled:u,children:[t.jsx(rk,{"aria-hidden":!0}),h?"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(rk,{className:"size-4 text-muted-foreground","aria-hidden":!0}),P?t.jsx("a",{href:P,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(O=>t.jsx("li",{children:O.account},O.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(W,{type:"button",variant:"destructive",disabled:u,onClick:()=>void A(),children:"Disconnect GitHub"}),t.jsx(W,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(W,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]})]}),h&&t.jsx("form",{"data-github-manifest":!0,ref:E,method:"post",action:h.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:h.manifest})})]})]})})}const $H=8,EH={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function TH({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:l=[]}){var D,Y;const[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState(!1),[m,x]=g.useState(null),[y,j]=g.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[C,N]=g.useState(s&&!k?{add:s}:null),[S,E]=g.useState(k&&r?k:!1),[$,L]=g.useState(null),A=s?JSON.stringify(s):"",P=g.useRef(A);g.useEffect(()=>{if(A===P.current)return;P.current=A;const K=A?JSON.parse(A):void 0;N(K&&K.preset!=="composio"?{add:K}:null),E((K==null?void 0:K.preset)==="composio"&&r?K:!1)},[A]);const O=g.useRef(0),T=g.useRef(null),M=()=>{const K=++O.current;e.listMcpServers().then(Z=>{K===O.current&&(u(Z.servers),j(null))},Z=>{K===O.current&&j($o(Z))})};g.useEffect(M,[e]),g.useEffect(()=>{e.toolSettings().then(h,()=>h(null))},[e]);const F=g.useRef(!1),I=async(K,Z)=>{if(!F.current){F.current=!0,b(!0),x(null);try{const se=await e.toolSettings();h(await e.saveToolSettings(Z(eb(se,l)))),M()}catch(se){x({server:K,problem:$o(se)})}F.current=!1,b(!1)}},V=g.useRef(null);s&&d&&((D=V.current)==null?void 0:D.key)!==A&&(V.current={key:A,name:s.change?s.name:EE(s.name,d)});const G=K=>{var Z;return((Z=V.current)==null?void 0:Z.key)===JSON.stringify(K)&&V.current.name!==K.name?{...K,toolkit:K.toolkit??K.name,name:V.current.name}:K},q=d!==null||y!==null,H=(Y=C==null?void 0:C.add)!=null&&Y.change?d==null?void 0:d.find(K=>K.name===C.add.name):void 0,U=(C==null?void 0:C.saved)??H;g.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const Q=async(K,Z)=>i((await e.startMcpSignIn(K,Z)).authorization_url);return t.jsx("div",{ref:T,className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,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:Ca,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: ${Bz(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:no[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(ct,{tone:"error",actions:t.jsx(W,{type:"button",size:"xs",onClick:M,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",y.text]})}),t.jsxs(Ws,{title:"Servers",aside:!C&&!S&&t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"sm",disabled:!r,onClick:()=>E(!0),children:"Add from Composio"}),t.jsx(W,{size:"sm",variant:"primary",onClick:()=>N({}),children:"Add server"})]}),children:[C&&(!C.add||q)&&t.jsx(HH,{v2:e,saved:U,add:C.add&&(H?C.add:G(C.add)),given:C.problem,writable:r,taken:d,signIn:Q,onCancel:()=>N(null),onSaved:(K=>Z=>{Z&&L(Z),N(se=>se===K?null:se),M()})(C)},`${(U==null?void 0:U.name)??"new"}|${C.add?JSON.stringify(C.add):""}`),S&&(typeof S!="object"||q)&&t.jsx(zH,{v2:e,add:typeof S=="object"?G(S):void 0,onClose:()=>E(!1),onSaved:M},typeof S=="object"?A:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(K=>t.jsx(AH,{v2:e,server:K,settings:f,settingsBusy:v,settingsProblem:(m==null?void 0:m.server)===K.name?m.problem:null,onSettings:Z=>void I(K.name,Z),writable:r&&!C,signIn:Q,onChange:Z=>N({saved:K,...Z?{problem:Z}:{}}),onPaste:()=>void Hh(()=>N({saved:K}),()=>{var Z;return((Z=T.current)==null?void 0:Z.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:M,onDeleted:Z=>{L(Z??null),M()}},K.name))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."}))]}),t.jsx(PH,{v2:e})]})]})})}const Ml=({problem:e})=>t.jsxs("div",{role:"alert",children:[t.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]}),rd=(e,n)=>`mcp:${e}/${n}`,RH=["allow","ask","deny"];function AH({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:l,signIn:d,onChange:u,onPaste:f,onChanged:h,onDeleted:v}){var P,O;const[b,m]=g.useState(!1),[x,y]=g.useState(!1),[j,k]=g.useState(null),[C,N]=g.useState(null),S=async T=>{m(!0),N(null);try{await T()}catch(M){N($o(M))}m(!1)},[E,$]=n.credential?EH[n.credential]??[n.credential,"plain"]:["no credential","plain"],L=n.auth.type==="oauth",A=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,T])=>T.length).map(([T,M])=>`${T} ${M.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(kA,{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:E}),!!((P=n.not_metered)!=null&&P.length)&&t.jsx(ke,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(ke,{tone:"muted",children:nu[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",(O=n.auth.headers)!=null&&O.length?` · headers ${n.auth.headers.join(", ")}`:""]}),L&&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(MH,{server:n,settings:s,busy:r,onSettings:i}),o&&t.jsx("div",{className:"mt-2",children:t.jsx(Ml,{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(IH,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(Bh,{field:n.secret,label:WH[n.auth.type],writable:l,onPaste:L?void 0:f})}),n.source==="composio"&&t.jsx(LH,{v2:e,server:n.name,writable:l}),A&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:A.length?A.join(" · "):"No change: it lists the same tools."})]}),!x&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[L&&n.credential!=="sealed"&&l&&t.jsx(W,{size:"sm",variant:"primary",disabled:b,onClick:()=>void S(()=>{var T;return d(n.name,{url:n.url,...(T=n.oauth)!=null&&T.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(W,{size:"sm",disabled:b,onClick:()=>void S(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{h()}}),children:"Refresh"}),t.jsx(W,{size:"sm",disabled:b,onClick:()=>u(),children:"Change"}),t.jsx(W,{size:"sm",variant:"destructive",disabled:b,onClick:()=>y(!0),children:"Delete"})]})]}),x&&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(W,{size:"sm",variant:"destructive",disabled:b,onClick:()=>void S(async()=>{var T;v((T=await e.deleteMcpServer(n.name))==null?void 0:T.composio)}),children:"Delete"}),t.jsx(W,{size:"sm",onClick:()=>y(!1),children:"Keep"})]}),C&&t.jsxs("div",{className:"mt-3",children:[t.jsx(Ml,{problem:C}),C.needsClient&&l&&t.jsx(W,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(C),children:"Enter a Client ID"})]})]})}const OH={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function LH({v2:e,server:n,writable:s}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(!1),[f,h]=g.useState(!1),[v,b]=g.useState(!1),[m,x]=g.useState(!1);if(g.useEffect(()=>{let k=!0;return e.composioTriggers(n).then(C=>{k&&o(C)},C=>{k&&(C instanceof Ue&&C.status===404?u(!0):l($o(C)))}),()=>{k=!1}},[e,n]),d)return null;const y=async()=>{h(!1),b(!0),l(null),x(!1);try{await e.rotateComposioSecret(n),x(!0)}catch(k){l($o(k))}b(!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:["· ",OH[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(W,{className:"mt-2",size:"sm",disabled:v,onClick:()=>h(!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(W,{size:"sm",variant:"primary",onClick:()=>void y(),children:"Yes, rotate"}),t.jsx(W,{size:"sm",onClick:()=>h(!1),children:"Keep"})]}),m&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(Ml,{problem:i})})]})}function MH({server:e,settings:n,busy:s,onSettings:r}){var h;const o=rd(e.name,"*"),i=((h=n[o])==null?void 0:h.allow_reads)===!0,l=e.tools.filter(v=>v.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=v=>r(b=>{const{[o]:m,...x}=b,{allow_reads:y,...j}=m??{},k=v?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...x,[o]:k}:x});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(xi,{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:[l," 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 IH({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[rd(e.name,"*")],i=new Map(e.tools.map(u=>[rd(e.name,u.name),u])),l=e.tools.map(u=>{var f;return{name:rd(e.name,u.name),...n?{gate:{name:rd(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:RH}}:{}}}),d=u=>{var h,v;const f=(h=e.prices)==null?void 0:h[u];return f!==void 0?`$${f} a call`:(v=e.not_metered)!=null&&v.includes(u)?"not metered":null};return t.jsx(ay,{label:`${e.name}'s tools`,rows:l,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 PH({v2:e}){const[n,s]=g.useState(null),[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(!1),[f,h]=g.useState(""),v=()=>void e.mcpPrivateHosts().then(x=>{s(x.hosts),o(null)},x=>o($o(x)));g.useEffect(v,[e]);const b=async x=>{u(!0),l(null);try{return s((await e.saveMcpPrivateHosts(x)).hosts),!0}catch(y){return l($o(y)),!1}finally{u(!1)}},m=async x=>{x.preventDefault(),n&&f.trim()&&await b([...n,f.trim()])&&h("")};return t.jsxs(Ws,{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(W,{size:"sm",onClick:v,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(x=>t.jsxs("li",{"data-host":x,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:x}),t.jsx(W,{size:"sm",disabled:d,onClick:()=>void b(n.filter(y=>y!==x)),children:"Remove"})]},x))}):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:x=>void m(x),"aria-label":"Allow a private network host",className:"flex gap-2",children:[t.jsx(Fe,{name:"mcp-private-host","aria-label":"Host name or IP address",value:f,onChange:x=>h(x.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(W,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(Ml,{problem:i})]})}const DH=32;function EE(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,DH-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function zH({v2:e,add:n,onClose:s,onSaved:r}){var F;const o=g.useRef(null),[i,l]=g.useState((n==null?void 0:n.toolkit)??""),[d,u]=g.useState((n==null?void 0:n.name)??""),[f,h]=g.useState(null),[v,b]=g.useState([]),[m,x]=g.useState(""),[y,j]=g.useState(null),[k,C]=g.useState(null),[N,S]=g.useState(!1),E=()=>{var I,V;return(((V=(I=o.current)==null?void 0:I.elements.namedItem("composio-key"))==null?void 0:V.value)??"").trim()},$=async I=>{S(!0),C(null);try{await I()}catch(V){C($o(V))}S(!1)},L=g.useRef(0),A=()=>{L.current++,h(null)},P=()=>$(async()=>{const I=++L.current;h(null),b([]),x("");const V=await e.composioTools(E(),i.trim().toLowerCase());I===L.current&&(h(V),n!=null&&n.tools&&V.toolkit===n.toolkit&&b(V.tools.map(G=>G.slug).filter(G=>n.tools.includes(G))))}),O=()=>$(async()=>{var V,G;const I=await e.saveComposioServer(d.trim(),E(),f.toolkit,v);(V=o.current)==null||V.reset(),r(),I.connect_url||(G=I.not_served)!=null&&G.length||I.composio?j({connect:I.connect_url,notServed:I.not_served,composio:I.composio}):s()}),T=f?f.tools.filter(I=>Us(m,I.name,I.slug,I.description)):[],M=I=>b(V=>V.includes(I)?V.filter(G=>G!==I):[...V,I]);return y?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.",y.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),y.connect&&t.jsx("p",{children:t.jsxs("a",{href:y.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(F=y.notServed)!=null&&F.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",y.notServed.join(", "),": a run can't call ",y.notServed.length===1?"it":"them","."]}):null,y.composio&&t.jsx("p",{className:`border p-4 text-body ${y.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:y.composio.note}),t.jsx(W,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:I=>{I.preventDefault(),f&&v.length&&d.trim()&&O()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:I=>{I.target.name==="composio-key"&&A()},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(Fe,{name:"composio-key",...sm})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(Fe,{name:"composio-toolkit",value:i,onChange:I=>{l(I.target.value),A()},placeholder:"github",spellCheck:!1})]}),k&&t.jsx(Ml,{problem:k}),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>0&&t.jsx(cu,{value:m,onChange:x,label:"Filter actions",placeholder:"Filter by name, slug or description",shown:T.length,total:f.tools.length,ticked:v.length}),f.tools.length?T.length?t.jsx("ul",{className:"divide-y border",children:T.map(I=>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:I.slug,checked:v.includes(I.slug),onChange:()=>M(I.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:I.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:I.slug}),I.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:I.description})]})]})},I.slug))}):t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["No action matches “",m.trim(),"”."]}):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(Fe,{name:"composio-name",value:d,onChange:I=>u(I.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{type:"button",size:"sm",disabled:N||!i.trim(),onClick:()=>void P(),children:"Load actions"}),f&&t.jsx(W,{type:"submit",size:"sm",variant:"solid",disabled:N||!v.length||!d.trim(),children:N?"Working":"Save"}),t.jsx(W,{type:"button",size:"sm",disabled:N,onClick:()=>{var I;(I=o.current)==null||I.reset(),s()},children:"Cancel"})]})]})}const FH=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,sm={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},UH=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],WH={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function HH({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:l,onCancel:d,onSaved:u}){var ue,ge,Te,Xe,je;const f=g.useRef(null),h=n?void 0:N_(s==null?void 0:s.preset),[v,b]=g.useState(h),[m,x]=g.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[y,j]=g.useState((s==null?void 0:s.url)??(n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Nm:(h==null?void 0:h.url)??"")),[k,C]=g.useState((s==null?void 0:s.auth)??(n==null?void 0:n.auth.type)??(h==null?void 0:h.auth)??"none"),[N,S]=g.useState(Math.max(1,((ue=n==null?void 0:n.auth.headers)==null?void 0:ue.length)??0)),E=k==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[$,L]=g.useState((s!=null&&s.change?s.toolkit:void 0)??(n==null?void 0:n.toolkit)??(h?h.name:(s==null?void 0:s.auth)==="github_app"?"":s?s.toolkit??(s.auth||s.url?"":s.name):"")),A=E==="github"?"github":$.trim(),P=()=>{if(k==="github_app")return{};const fe=A||null;return n?fe!==n.toolkit?{toolkit:fe}:{}:fe?{toolkit:fe}:{}},O=!n&&!!(i!=null&&i.some(fe=>fe.name===m.trim())),T=!!n||!!i&&!O,[M,F]=g.useState(null),[I,V]=g.useState(r??null),[G,q]=g.useState(!1),H=g.useRef(0),U=()=>{H.current++,F(null)},Q=fe=>{var De,te;return(((te=(De=f.current)==null?void 0:De.elements.namedItem(fe))==null?void 0:te.value)??"").trim()},[D,Y]=g.useState(!1),K=fe=>{try{return new URL(fe).origin}catch{return fe}},Z=(fe=k)=>{var De;return Y(!!n&&fe==="oauth"&&(n.auth.type!=="oauth"||Q("mcp-scopes")!==(((De=n.oauth)==null?void 0:De.scopes.join(" "))??"")||!!Q("mcp-client-id")||!!Q("mcp-client-secret")||K(Q("mcp-url"))!==K(n.url)))};g.useEffect(()=>Z(),[k]),g.useEffect(()=>{var De,te;if(!(s!=null&&s.url)&&!(s!=null&&s.change))return;const fe=k==="bearer"?"mcp-token":k==="headers"?"mcp-header-name-0":void 0;fe&&((te=(De=f.current)==null?void 0:De.elements.namedItem(fe))==null||te.focus())},[]);const se=()=>{if(k==="bearer")return Q("mcp-token")?{type:k,token:Q("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const fe=Object.fromEntries(Array.from({length:N},(De,te)=>[Q(`mcp-header-name-${te}`),Q(`mcp-header-value-${te}`)]).filter(([De,te])=>De&&te));return Object.keys(fe).length?{type:k,headers:fe}:{type:k}},ie=async fe=>{q(!0),V(null);try{await fe()}catch(De){V($o(De))}q(!1)},Ne=!!(I!=null&&I.needsClient);g.useEffect(()=>{Ne&&C("oauth")},[Ne]),g.useEffect(()=>{var fe,De;Ne&&k==="oauth"&&((De=(fe=f.current)==null?void 0:fe.elements.namedItem("mcp-client-id"))==null||De.focus())},[Ne,k]);const he=()=>T&&ie(()=>{const fe=Q("mcp-scopes").split(/\s+/).filter(Boolean),De=Q("mcp-client-id");return l(m.trim(),{url:y.trim(),...fe.length?{scopes:fe}:{},...De?{client_id:De,...Q("mcp-client-secret")?{client_secret:Q("mcp-client-secret")}:{}}:{},...P()})}),ve=()=>{const fe=H.current;ie(async()=>{try{const De=await e.previewMcpServer(y.trim(),se(),n==null?void 0:n.name);fe===H.current&&F(De)}catch(De){if(fe===H.current)throw De}})},Ee=fe=>{if(fe.preventDefault(),!!T){if(k==="oauth"&&(!n||D))return void he();ie(async()=>{var te;const De=await e.saveMcpServer(m.trim(),y.trim(),se(),P());(te=f.current)==null||te.reset(),u(De.composio)})}},ye=!G&&T&&!!m.trim()&&!!y.trim()&&(!!n||!!M),pe=fe=>{var De;if(i){for(const te of Array.from(((De=f.current)==null?void 0:De.elements)??[]))te instanceof HTMLInputElement&&FH.test(te.name)&&(te.value="");S(1),b(fe),x(EE(fe.name,i)),j(fe.url),C(fe.auth),L(fe.name),V(null),U()}},Pe=fe=>(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. ",fe]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:Ee,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:fe=>{["mcp-name","mcp-toolkit"].includes(fe.target.name)||U(),Z()},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:Kv.map(fe=>t.jsx(W,{type:"button",size:"sm",variant:(v==null?void 0:v.id)===fe.id?"solid":"outline","aria-pressed":(v==null?void 0:v.id)===fe.id,disabled:G||!i||!o&&fe.auth!=="none",onClick:()=>pe(fe),children:fe.label},fe.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."}),v&&t.jsx("p",{role:"note","data-mcp-preset":v.id,className:"text-small text-muted-foreground",children:v.note}),(v==null?void 0:v.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(xi,{checked:y===v.readOnly,label:"Read-only",disabled:G,onChange:fe=>{j(fe?v.readOnly:v.url),U()}}),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:",m.trim()||"<name>","/<tool>."]}),t.jsx(Fe,{name:"mcp-name",value:m,readOnly:!!n,onChange:fe=>x(fe.target.value),spellCheck:!1}),O&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[m.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(Fe,{name:"mcp-url",value:y,onChange:fe=>{j(fe.target.value),I!=null&&I.needsClient&&V(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":E,className:"font-mono text-body",children:nu[E]})]}),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:",A||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(Fe,{name:"mcp-toolkit",value:E==="github"?"github":$,readOnly:E==="github",onChange:fe=>L(fe.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:UH.map(([fe,De])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:fe,checked:k===fe,disabled:!o&&fe!=="none",onChange:()=>{C(fe),fe==="github_app"&&!y.trim()&&j(Nm),U()},className:"accent-primary"}),De]},fe))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),Pe("A new token replaces it; leave this empty to keep it."),t.jsx(Fe,{name:"mcp-token",...sm})]}),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:[Pe(`Its headers: ${(ge=n==null?void 0:n.auth.headers)==null?void 0:ge.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:N},(fe,De)=>{var te;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Fe,{name:`mcp-header-name-${De}`,"aria-label":`Header ${De+1} name`,placeholder:"X-Api-Key",defaultValue:(te=n==null?void 0:n.auth.headers)==null?void 0:te[De],spellCheck:!1}),t.jsx(Fe,{name:`mcp-header-value-${De}`,"aria-label":`Header ${De+1} value`,...sm})]},De)}),N<$H&&t.jsx(W,{type:"button",size:"sm",variant:"ghost",onClick:()=>S(fe=>fe+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."}),((Te=n==null?void 0:n.oauth)==null?void 0:Te.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(Fe,{name:"mcp-scopes",placeholder:"read write",defaultValue:(Xe=n==null?void 0:n.oauth)==null?void 0:Xe.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:Ne?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(Fe,{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:Ne?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Fe,{name:"mcp-client-secret",...sm})]})]})]}),I&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ml,{problem:I}),I.signIn&&k!=="oauth"&&o&&t.jsx(W,{type:"button",size:"sm",variant:"primary",disabled:G||!T||!m.trim(),onClick:()=>void he(),children:"Sign in"})]}),M&&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 ",M.protocol,(je=M.server_info)!=null&&je.name?` · ${M.server_info.name}${M.server_info.version?` ${M.server_info.version}`:""}`:""," · ",M.tools.length," tool",M.tools.length===1?"":"s"]}),M.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:M.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:Uz}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:M.tools.map(fe=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:fe.name}),fe.title&&t.jsx("span",{className:"ml-2 text-small",children:fe.title}),fe.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:fe.description})]},fe.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[k==="oauth"&&!o?null:k==="oauth"&&D?t.jsx(W,{type:"submit",size:"sm",variant:"primary",disabled:G||!y.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(W,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:G||!T||!m.trim()||!y.trim(),onClick:()=>void he(),children:n?"Sign in again":"Sign in"}):t.jsx(W,{type:"button",size:"sm",disabled:G||!y.trim(),onClick:ve,children:"Preview"}),(k!=="oauth"||n&&!D)&&t.jsx(W,{type:"submit",size:"sm",variant:I!=null&&I.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!ye,children:G?"Working":"Save"}),t.jsx(W,{type:"button",size:"sm",onClick:()=>{var fe;(fe=f.current)==null||fe.reset(),d()},children:"Cancel"})]})]})}const KN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function BH({v2:e,needs:n,model:s,onSaved:r,writable:o,whyNot:i="sign_in",plan:l,onPlan:d,onDone:u,harnesses:f}){const[h,v]=g.useState(null),[b,m]=g.useState(null),[x,y]=g.useState(null),[j,k]=g.useState(null),[C,N]=g.useState(l??null);g.useEffect(()=>{N(l??null)},[l]);const[S,E]=g.useState(!1),$=g.useRef(0),L=()=>{const q=++$.current;e.listToolKeys().then(H=>{q===$.current&&(v(H.keys.filter(U=>U.kind==="model")),m(null))}).catch(H=>{q===$.current&&m(KN(H))})};g.useEffect(()=>{n!=="model"&&L()},[e,n]);const A=s!=null&&s.includes("/")&&!Sd(s)?s.slice(0,s.indexOf("/")):void 0,P=h==null?void 0:h.find(q=>q.id===A),O=P?[P]:h,T=h==null?void 0:h.find(q=>q.id===x),M=(T==null?void 0:T.fields.filter(q=>{var H;return((H=T.secrets.find(U=>_m(U.name)===q.name))==null?void 0:H.source)!=="env"}))??[],F=!!C&&n!=="model"&&!A,I=n!=="model"&&(!F||S),V=q=>{N(q),d==null||d(q)},G=f&&t.jsx(d$,{harnesses:f});return F&&C.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(ti,{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(ib,{v2:e,view:C,onView:V}),G,t.jsx(W,{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(ti,{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":F?"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."}):P?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 ",P.label," key is set, so an agent that names no model can't run. Save the ",P.label," key: such an agent then runs on that model."]}):F?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(ib,{v2:e,view:C,onView:V,writable:o,whyNot:i,beside:t.jsx(W,{type:"button",size:"sm","aria-expanded":S,onClick:()=>E(q=>!q),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:NC}),S&&t.jsx("p",{className:"text-body text-muted-foreground",children:bb})]}):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:bb})]}),I&&b&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",b.code,": ",b.message]}),t.jsx(W,{type:"button",onClick:L,size:"sm",className:"mt-2",children:"Try again"})]}),I&&h&&!o&&t.jsx("p",{className:"text-body",role:"status",children:no[i]}),I&&h&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:O.map(q=>t.jsx(W,{size:"sm",variant:x===q.id?"solid":"primary","aria-pressed":x===q.id,onClick:()=>{y(x===q.id?null:q.id),k(null)},children:q.label},q.id))}),I&&T&&o&&(M.length?t.jsx(CE,{tool:T,fields:M,onCancel:()=>y(null),onSave:async q=>{k(null);try{await e.saveToolKey(T.id,q)}catch(H){return H instanceof Ue&&H.status===422?H:(k(KN(H)),null)}return y(null),L(),r==null||r(),null}},T.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",T.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(Mo,{error:j,title:"The key was not saved"})}),G,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"}),", and so is a model gateway you already run (LiteLLM or another): Use a model gateway."]})]})]})})}function qH({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, OPENAI_API_KEY or PARTICLE_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), ANTHROPIC_API_KEY, OPENAI_API_KEY or PARTICLE_API_KEY, and restart."]})})}const VN=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],GH={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."})},KH="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function VH(e){return e==="other"?"Password":"App password"}const YH={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},YN=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"}},QN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},QH=e=>Object.fromEntries((e instanceof Ue?e.fields??[]:[]).map(n=>[n.field,n.message])),JN=e=>typeof e=="object"&&e!==null&&typeof e.ok=="boolean"&&typeof e.message=="string",XN=e=>["imap","smtp"].map(n=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ke,{tone:e[n].ok?"success":"error",children:n==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:e[n].ok?"":"text-destructive-text",children:e[n].message})]},n));function JH(e){if(!(e instanceof Ue)||e.code!=="upstream_failed")return null;const{imap:n,smtp:s}=e.details??{};return JN(n)&&JN(s)?{imap:n,smtp:s}:null}function XH({v2:e,writable:n,whyNot:s="sign_in"}){var D;const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(YN(null)),[f,h]=g.useState(""),[v,b]=g.useState(null),[m,x]=g.useState({}),[y,j]=g.useState(null),[k,C]=g.useState(null),[N,S]=g.useState(!1),[E,$]=g.useState(!1),L=g.useRef(0),A=Y=>{o(Y),u(YN(Y))},P=()=>{const Y=++L.current;e.emailAccount().then(K=>{Y===L.current&&(A(K),l(null))}).catch(K=>{Y===L.current&&l(QN(K))})};g.useEffect(()=>{n&&P()},[e,n]);const O=Y=>{u(Y),j(null),C(null)},T=Y=>K=>O(Z=>({...Z,[Y]:K.target.value})),M=()=>{const Y=d.user.trim(),K=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(),...Y?{user:Y}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:K}},F=async(Y,K)=>{b(null),x({}),C(null),$(!0);try{await K()}catch(Z){const se=QH(Z),ie=JH(Z);Object.keys(se).length?x(se):ie?C(ie):b({title:Y,error:QN(Z)})}finally{$(!1)}},I=Y=>{Y.preventDefault(),F("The account was not saved",async()=>{j(null),A(await e.saveEmailAccount(M())),h("")})},V=()=>F("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(M()))}),G=()=>F("The account was not removed",async()=>{S(!1),await e.removeEmailAccount(),A(YH),h(""),j(null)}),q=t.jsxs("div",{className:Sa,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:Eo,children:[q,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:no[s]})]})});if(!r)return i?t.jsx(ct,{tone:"error",className:"m-8",actions:t.jsx(W,{type:"button",size:"xs",onClick:P,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,U=d.preset==="other",Q=(Y,K,Z)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(gt,{label:`${K} server`,error:m[`${Y}.host`],children:t.jsx(Fe,{name:`${Y}_host`,value:Y==="imap"?d.imapHost:d.smtpHost,onChange:T(Y==="imap"?"imapHost":"smtpHost"),placeholder:Z,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(gt,{label:"Port",error:m[`${Y}.port`],children:t.jsx(Fe,{name:`${Y}_port`,inputMode:"numeric",value:Y==="imap"?d.imapPort:d.smtpPort,onChange:T(Y==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[q,t.jsxs("div",{className:Ca,children:[v&&t.jsx(Mo,{error:v.error,title:v.title}),i&&t.jsx(ct,{tone:"error",actions:t.jsx(W,{type:"button",size:"xs",onClick:P,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(Ws,{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(Vm,{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:((D=VN.find(Y=>Y.value===r.preset))==null?void 0:D.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(Hs,{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:I,children:[t.jsxs("fieldset",{disabled:E,className:"min-w-0 space-y-4",children:[t.jsx(gt,{label:"Provider",group:"heading",note:KH,error:m.preset,children:t.jsx(eo,{name:"email-preset",label:"Provider",value:d.preset,onChange:Y=>O(K=>({...K,preset:Y})),options:VN})}),t.jsx("p",{className:"text-small text-muted-foreground",children:GH[d.preset]}),t.jsx(gt,{label:"Address",error:m.address,children:t.jsx(Fe,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:T("address")})}),t.jsx(gt,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:m.user,children:t.jsx(Fe,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:T("user")})}),t.jsx(gt,{label:VH(d.preset),error:m.password,children:t.jsx(Fe,{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:Y=>{h(Y.target.value),j(null),C(null)}})}),U&&Q("imap","IMAP","imap.example.com"),U&&Q("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(W,{type:"submit",variant:"solid",disabled:E||!d.address.trim()||!f,children:"Save"}),t.jsx(W,{type:"button",variant:"outline",disabled:E||!d.address.trim()||!f&&!r.configured,onClick:()=>void V(),children:"Test"}),H&&!N&&t.jsx(W,{type:"button",variant:"outline",disabled:E,onClick:()=>S(!0),children:"Remove"})]}),N&&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(W,{type:"button",variant:"destructive",disabled:E,onClick:()=>void G(),children:"Remove the account"}),t.jsx(W,{type:"button",variant:"ghost",onClick:()=>S(!1),children:"Cancel"})]}),y&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[XN(y),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."})]}),k&&t.jsxs("div",{"aria-label":"Not saved",role:"alert",className:"space-y-1 font-mono text-body",children:[t.jsx("p",{className:"text-destructive-text",children:"Not saved: the account didn't sign in."}),XN(k),t.jsx("p",{className:"text-small text-muted-foreground",children:H?"Nothing was sent. The account saved before is as it was.":"Nothing was sent, and nothing is saved."})]})]})]})]})]})})}const ZN=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},ZH={unreadable:"Its secret can't sign here: it was sealed under another key, or is damaged. Nothing is sent until its secret is rotated, or the webhook is removed and set again."};function e7({v2:e}){const[n,s]=g.useState(null),[r,o]=g.useState([]),[i,l]=g.useState(null),[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState(null),[m,x]=g.useState(!1),[y,j]=g.useState(!1),k=g.useRef(null),C=g.useRef(null),[N,S]=g.useState(null),[E,$]=g.useState(!1),[L,A]=g.useState(""),P=g.useRef(0),O=()=>{const V=++P.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([G,q])=>{V===P.current&&(s(G),o(q.attempts),l(null))}).catch(G=>{V===P.current&&l(ZN(G))})};g.useEffect(O,[e]);const T=async(V,G)=>{h(null),$(!0);try{await G()}catch(q){h({title:V,error:ZN(q)})}finally{$(!1)}O()},M=()=>{j(!1),requestAnimationFrame(()=>{var V;return(V=k.current)==null?void 0:V.focus()})},F=async()=>{j(!1);let V=!1;await T("The secret was not rotated",async()=>{const{signing_secret:G,...q}=await e.rotateWebhookSecret();u(G),s(q),V=!0}),S(V?"secret":"rotate")};g.useEffect(()=>{var V;!N||E||((V=N==="secret"?C.current:k.current)==null||V.focus(),S(null))},[N,E]);const I=V=>{V.preventDefault(),T("The webhook was not saved",async()=>{const G=await e.saveWebhook(L.trim());G.signing_secret&&u(G.signing_secret);const{signing_secret:q,...H}=G;s(H)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,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:Ca,children:[f&&t.jsx(Mo,{error:f.error,title:f.title}),i&&t.jsx(ct,{tone:"error",actions:t.jsx(W,{type:"button",size:"xs",onClick:O,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",{ref:C,tabIndex:-1,className:"border border-warning/50 bg-warning/5 p-4 outline-none","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.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all font-mono text-body",children:d}),t.jsx(nv,{text:d,label:"Copy secret"})]}),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(W,{type:"button",variant:"outline",className:"mt-3",onClick:()=>u(null),children:"Done"})]}),t.jsx(Ws,{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(kl,{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(Hs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),ZH[n.signing]]}),t.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:I,children:[t.jsx(Fe,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:n.configured?"The whole URL, to change it or save it again":"https://...",value:L,onChange:V=>A(V.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(W,{type:"submit",variant:"solid",disabled:E||!L.trim(),children:"Save"}),n.configured&&t.jsx(W,{type:"button",variant:"outline",disabled:E,onClick:()=>T("The test was not sent",async()=>b(await e.testWebhook())),children:"Send a test"}),n.configured&&!y&&t.jsx(W,{ref:k,type:"button",variant:"outline",disabled:E,onClick:()=>{x(!1),j(!0)},children:"Rotate secret"}),n.configured&&!m&&t.jsx(W,{type:"button",variant:"outline",disabled:E,onClick:()=>{j(!1),x(!0)},children:"Remove"})]}),y&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Rotate the signing secret?",onKeyDown:V=>{V.key==="Escape"&&M()},children:[t.jsx("span",{children:"The old secret stops signing at once; your receiver needs the new one."}),t.jsx(W,{type:"button",variant:"solid",disabled:E,onClick:()=>void F(),children:"Rotate the secret"}),t.jsx(W,{type:"button",variant:"ghost",autoFocus:!0,onClick:M,children:"Cancel"})]}),m&&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(W,{type:"button",variant:"destructive",disabled:E,onClick:()=>{x(!1),A(""),b(null),T("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(W,{type:"button",variant:"ghost",onClick:()=>x(!1),children:"Cancel"})]}),v&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",e1(v)]})]})}),t.jsx(Ws,{label:"Deliveries",title:"Last deliveries",aside:t.jsx(W,{type:"button",size:"sm",onClick:O,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((V,G)=>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(V.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:V.type}),t.jsx("span",{className:V.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:e1(V)}),V.redelivery&&t.jsx(ke,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:V.webhook_id,children:[V.webhook_id.slice(0,12),"…"]}),t.jsx(W,{type:"button",variant:"outline",size:"sm",disabled:E,onClick:()=>T("The message was not sent again",()=>e.redeliverWebhook(V.webhook_id)),children:"Redeliver"})]},`${V.webhook_id}:${V.at}:${G}`))})})]})]})}):i?t.jsx(ct,{tone:"error",className:"m-8",actions:t.jsx(W,{type:"button",size:"xs",onClick:O,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 e1(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 t1=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},t7=[{id:"run.ended",label:"A run ends",note:"Completed, failed or cancelled: the agent, the status, the run's title and a link to it."},{id:"run.needs_input",label:"A run needs you",note:"A question, an approval, a paused cap or a hand-over: what it waits on, and a link to answer it."},{id:"trigger.failed",label:"A trigger fails",note:"A trigger's firing could not start its run: the trigger's name and the error."}],n7={configured:!1,secret:{name:"slack:outbound",set:!1,source:null,changed_at:null},events:{"run.ended":!0,"run.needs_input":!0,"trigger.failed":!0}};function s7({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=g.useState(null),[i,l]=g.useState([]),[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState(null),[m,x]=g.useState(!1),[y,j]=g.useState(!1),[k,C]=g.useState(""),N=g.useRef(0),S=g.useRef(null),E=()=>{x(!1),requestAnimationFrame(()=>{var O;return(O=S.current)==null?void 0:O.focus()})},$=()=>{const O=++N.current;Promise.all([e.slack(),e.slackDeliveries()]).then(([T,M])=>{O===N.current&&(o(T),l(M.attempts),u(null))}).catch(T=>{O===N.current&&u(t1(T))})};g.useEffect($,[e]);const L=async(O,T)=>{h(null),j(!0);try{await T()}catch(M){h({title:O,error:t1(M)})}finally{j(!1)}$()},A=O=>{O.preventDefault(),L("The Slack URL was not saved",async()=>{o(await e.saveSlack({url:k.trim(),...r&&!r.configured?{events:r.events}:{}})),C("")})},P=(O,T)=>{if(r){if(!r.configured)return o({...r,events:{...r.events,[O]:T}});L("The event was not changed",async()=>o(await e.saveSlack({events:{[O]:T}})))}};return r?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Slack"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Post a message to a Slack channel when a run ends, when a run needs you, and when a trigger fails. Each message names the agent, the status and the run's title, with a link to the run here; never a run's input, its output or a tool's arguments."})]}),t.jsxs("div",{className:Ca,children:[f&&t.jsx(Mo,{error:f.error,title:f.title}),d&&t.jsx(ct,{tone:"error",actions:t.jsx(W,{type:"button",size:"xs",onClick:$,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["Slack could not be read: ",d.code,": ",d.message,". What is shown may be out of date."]})}),t.jsx(Ws,{title:"Channel",note:t.jsx("p",{children:"In Slack, add an incoming webhook to the channel (an app with Incoming Webhooks on), then paste its URL here. The URL is a secret: anyone with it can post to the channel, so it is sealed and never shown again."}),children:t.jsxs("section",{className:"border bg-card p-4","aria-label":"Slack URL",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(xA,{className:"size-4 text-muted-foreground","aria-hidden":!0}),r.configured?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:r.url}):t.jsx("span",{className:"text-body text-muted-foreground",children:"Slack is not set."}),r.configured&&(r.disabled?t.jsx(ke,{tone:"error",children:"off"}):r.url_state==="sealed"?t.jsx(ke,{tone:"success",children:"on"}):t.jsx(ke,{tone:"warning",children:"unreadable"}))]}),r.configured&&r.disabled&&t.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",r.disabled.reason,", ",ht(r.disabled.at),". Nothing is posted until a URL is saved again: paste it below."]}),r.configured&&r.url_state!=="sealed"&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Hs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),"The saved URL can't be opened here: it was sealed under another key, or is damaged. Nothing is posted until it is saved again."]}),!n&&t.jsx("p",{role:"status",className:"mt-3 text-body text-muted-foreground",children:no[s]}),t.jsxs("form",{className:"mt-4 space-y-3",onSubmit:A,children:[t.jsx(gt,{label:"Incoming-webhook URL",hint:r.configured?"Paste the whole URL to change it, or to turn Slack on again.":void 0,children:t.jsx(Fe,{name:"url",type:"url",required:!0,maxLength:2048,autoComplete:"off",spellCheck:!1,placeholder:"https://hooks.slack.com/services/...",value:k,disabled:!n,onChange:O=>C(O.target.value)})}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.configured&&t.jsx(W,{type:"button",variant:"outline",disabled:y,onClick:()=>L("The test was not sent",async()=>b(await e.testSlack())),children:"Send a test"}),r.configured&&!m&&n&&t.jsx(W,{ref:S,type:"button",variant:"outline",disabled:y,onClick:()=>x(!0),children:"Remove"}),t.jsx(W,{type:"submit",variant:"primary",disabled:y||!n||!k.trim(),children:"Save"})]})]}),m&&t.jsxs("div",{role:"alertdialog","aria-label":"Remove Slack",className:"mt-3 flex flex-wrap items-center gap-2 text-body",onKeyDown:O=>{O.key==="Escape"&&E()},children:[t.jsx("span",{children:"The URL is removed and pending messages are dropped; the log of attempts stays."}),t.jsx(W,{type:"button",variant:"ghost",autoFocus:!0,onClick:E,children:"Cancel"}),t.jsx(W,{type:"button",variant:"destructive",disabled:y,onClick:()=>{x(!1),C(""),b(null),L("Slack was not removed",async()=>{await e.removeSlack(),o(n7)})},children:"Remove Slack"})]}),v&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",n1(v)]})]})}),t.jsx(Ws,{title:"Events",note:t.jsx("p",{children:"Each is posted while it is on. A change takes effect at once."}),children:t.jsx("ul",{className:"border","aria-label":"Events",children:t7.map(O=>t.jsxs("li",{className:"flex items-start gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx(xi,{checked:r.events[O.id],onChange:T=>P(O.id,T),disabled:y,label:O.label,className:"mt-0.5"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-body",children:[O.label," ",t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:O.id})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:O.note})]})]},O.id))})}),t.jsx(Ws,{label:"Deliveries",title:"Last deliveries",aside:t.jsx(W,{type:"button",size:"sm",onClick:$,children:"Refresh"}),children:i.length===0?t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"No message has been posted yet."}):t.jsx("ul",{className:"border",children:i.map((O,T)=>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:"shrink-0 text-muted-foreground",children:ht(O.at)}),t.jsx("span",{className:"shrink-0 font-mono",children:O.type}),t.jsx("span",{className:O.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:n1(O)}),O.redelivery&&t.jsx(ke,{children:"redelivery"}),t.jsx(W,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>L("The message was not posted again",()=>e.redeliverSlack(O.webhook_id)),children:"Post again"})]},`${O.webhook_id}:${O.at}:${T}`))})})]})]})}):d?t.jsx(ct,{tone:"error",className:"m-8",actions:t.jsx(W,{type:"button",size:"xs",onClick:$,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["Slack could not be read: ",d.code,": ",d.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function n1(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 r7={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."}},vb=e=>r7[e]??{label:e,gives:""},o7=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},yb=e=>e.slice(e.lastIndexOf(":")+1),a7=e=>e.secrets.some(n=>n.set)&&e.required.every(n=>e.secrets.some(s=>s.name===n&&s.set)),i7=2e3;function l7({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState(null),[f,h]=g.useState(null),[v,b]=g.useState({}),[m,x]=g.useState(new Set),y=g.useRef(0),j=g.useRef({}),k=g.useCallback(()=>{const $=++y.current;l(null),e.computers().then(L=>{$===y.current&&o(L)},L=>{$===y.current&&l(o7(L))})},[e]);if(g.useEffect(k,[k]),!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(W,{size:"sm",onClick:k,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(cs,{label:"Loading the computers",rows:3})});const C=new Set(r.paired.map($=>$.id)),N=$=>r.kinds.filter(L=>L.providers.some(A=>A.id===$)).map(L=>L.kind),S=async($,L,A)=>{h(null);try{await e.saveComputerKeys(L.id,A)}catch(P){return P instanceof Ue&&P.status===422?P:(h({at:$,words:Gt(P)}),null)}return u(null),j.current[L.id]=(j.current[L.id]??0)+1,b(P=>{const O={...P};return delete O[L.id],O}),k(),null},E=async $=>{const L=j.current[$.id]??0;x(P=>new Set(P).add($.id));let A;try{const P=await e.testComputer($.id);A=P.ok?{ok:!0,words:P.detail,at:new Date().toISOString()}:{ok:!1,words:P.why,at:new Date().toISOString()}}catch(P){A={ok:!1,words:Gt(P),at:new Date().toISOString()}}(j.current[$.id]??0)===L&&b(P=>({...P,[$.id]:A})),x(P=>{const O=new Set(P);return O.delete($.id),O})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,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:Ca,children:[t.jsx(u7,{v2:e,paired:r.paired,reload:k}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:no[s]}),r.kinds.map($=>t.jsx(f7,{kind:$,providers:$.providers.filter(L=>!C.has(L.id)),own:$.providers.filter(L=>C.has(L.id)).map(L=>L.name),children:$.providers.filter(L=>!C.has(L.id)).map(L=>{const A=`${$.kind}/${L.id}`;return t.jsx(m7,{v2:e,kind:$.kind,provider:L,writable:n,serves:N(L.id),tested:v[L.id],testing:m.has(L.id),open:(d==null?void 0:d.at)===A?d.mode:null,problem:(f==null?void 0:f.at)===A?f.words:null,onOpen:P=>{u(P?{at:A,mode:P}:null),h(null)},onSave:P=>S(A,L,P),onRemove:async P=>{var T;const O=await S(A,L,{[P]:null});O&&h({at:A,words:((T=O.fields)==null?void 0:T.map(M=>M.message).join(" "))||O.message})},onTest:()=>void E(L)},L.id)})},$.kind))]})]})})}function c7(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=>vb(o).label).join(", ")||vb(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function d7(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 u7({v2:e,paired:n,reload:s}){const[r,o]=g.useState(null),[i,l]=g.useState(!1),[d,u]=g.useState(()=>Date.now()),[f,h]=g.useState(null),[v,b]=g.useState(null),[m,x]=g.useState(null),y=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&y>0;g.useEffect(()=>{if(!j)return;const S=setInterval(()=>u(Date.now()),1e3),E=setInterval(s,i7);return()=>{clearInterval(S),clearInterval(E)}},[j,s]),g.useEffect(()=>{if(!r)return;const S=n.find(E=>E.pairing===r.code.id);S&&(h(S.name),o(null))},[n,r]);const k=async()=>{l(!0),x(null),h(null);try{const S=await e.createPairing();u(Date.now()),o({code:S})}catch(S){x(Gt(S))}l(!1)},C=async S=>{x(null);try{await e.removeComputer(S)}catch(E){x(Gt(E));return}b(null),s()},N=`${Math.floor(Math.max(0,y)/6e4)}:${String(Math.floor(Math.max(0,y)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(Ws,{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(W,{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:N}),"."]}):t.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),r.code.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"text-small text-warning-text",children:r.code.runs_refused}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{size:"sm",onClick:()=>void k(),disabled:i,children:i?"Making…":"New code"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>o(null),children:"Done"})]})]}),m&&t.jsx("p",{role:"alert",className:"border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:m}),n.length?t.jsx("ul",{className:"border",children:n.map(S=>t.jsxs("li",{"data-paired":S.id,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[S.serves.includes("phone")?t.jsx(eS,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(hi,{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.online?t.jsx(ke,{tone:"success",children:"Online"}):t.jsx(ke,{tone:"muted",children:"Offline"}),S.held_by_run&&t.jsxs(ke,{tone:"active",children:["In use by run ",ka(S.held_by_run)]}),S.unserved&&t.jsx(ke,{tone:"warning",children:"No agent can use it"}),S.runs_refused&&t.jsx(ke,{tone:"warning",children:"No run here can use it"})]}),S.unserved&&t.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.unserved}),S.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.runs_refused}),S.held_by_run&&S.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(S.held_until),", released or not."]}),!S.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:c7(S)}),S.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:d7(S)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${S.driver} · paired ${ht(S.created_at)}${S.seen_at?` · last attached ${ht(S.seen_at)}`:""}`})]}),t.jsx(W,{size:"sm",onClick:()=>{b(S.id),x(null)},disabled:v!==null,children:"Remove"})]}),v===S.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 ",S.name,"? Its driver stops dialing and asks for a new code",S.held_by_run?", and the run using it loses it":"","."]}),t.jsx(W,{size:"sm",variant:"destructive",onClick:()=>void C(S.id),children:"Remove"}),t.jsx(W,{size:"sm",onClick:()=>b(null),children:"Cancel"})]})]},S.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 f7({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=vb(e.kind);return t.jsx(Ws,{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 m7({v2:e,kind:n,provider:s,writable:r,serves:o,tested:i,testing:l,open:d,problem:u,onOpen:f,onSave:h,onRemove:v,onTest:b}){const m=g.useRef(null),x=d&&"paste"in d?d.paste:null,y=d&&"remove"in d?d.remove:null,j=a7(s);return t.jsxs("li",{ref:m,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(hi,{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.runs_refused&&t.jsx(ke,{tone:"warning",children:"No run here can use it"}),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.runs_refused&&t.jsx("p",{"data-runs-refused":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:s.runs_refused}),s.metered&&oy.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:ry}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(k=>{var S;const C=yb(k.name),N=((S=s.picked)==null?void 0:S.includes(k.name))??!1;return t.jsx(Bh,{field:k,required:s.required.includes(k.name),writable:r&&!d,actionsInline:!0,onPaste:N?void 0:()=>void Hh(()=>f({paste:C}),()=>{var E,$;return($=(E=m.current)==null?void 0:E.querySelector("form"))==null?void 0:$.elements.namedItem(C)}),onRemove:()=>f({remove:C})},k.name)})}),s.picked&&s.picked.length>0&&s.required.every(k=>s.secrets.some(C=>C.name===k&&C.set))&&t.jsx(h7,{v2:e,provider:s,writable:r&&!d,onSave:h}),j&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(W,{size:"sm",onClick:b,disabled:l,children:l?"Testing…":"Test connection"}),i&&t.jsx("p",{"data-test":!0,className:`text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${li(i.at)} · ${i.words}`})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",o.join(", ")]})]})]}),r&&x&&t.jsx(p7,{provider:s.name,name:x,set:s.secrets.some(k=>yb(k.name)===x&&k.set),onSave:h,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(W,{size:"sm",variant:"destructive",onClick:()=>void v(y),children:"Remove"}),t.jsx(W,{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 h7({v2:e,provider:n,writable:s,onSave:r}){const[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(null),h=n.secrets.map(b=>`${b.name}:${b.set}:${b.changed_at??""}`).join(" ");g.useEffect(()=>{let b=!0;return i(null),d(null),e.computerChoices(n.id).then(m=>{b&&i(m)},m=>{b&&d(Gt(m))}),()=>{b=!1}},[e,n.id,h]);const v=async(b,m)=>{var y;f({key:b.key,value:m}),d(null);const x=await r({[b.key]:m});f(null),x&&d(((y=x.fields)==null?void 0:y.map(j=>j.message).join(" "))||x.message)};return l&&!o?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${l}`}):o?t.jsxs("div",{className:"mt-3 space-y-3",children:[o.choices.map(b=>{const m=n.secrets.find(y=>yb(y.name)===b.key),x=(m==null?void 0:m.source)==="env";return t.jsxs("div",{"data-choices":b.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:b.key}),"why"in b?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:b.why}):t.jsxs(t.Fragment,{children:[t.jsx(Ft,{label:`${n.name} ${b.key}`,value:(u==null?void 0:u.key)===b.key?u.value:b.saved??"",disabled:!s||x||u!==null,options:b.options.map(y=>({value:y.value,label:y.label})),placeholder:"Pick one",onChange:y=>void v(b,y),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${m!=null&&m.set&&b.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:x?`Set in the environment where AgentRun starts, and that one is used: change ${b.key} there.`:b.saved!==void 0?"Picked and saved on this server.":m!=null&&m.set?`The ${b.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:b.options.length===1?`The only one, ${b.options[0].label}, is used while none is picked.`:`${b.options.length} to pick from. Pick the one this server's computers use.`})]})]},b.key)}),l&&t.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:l})]}):t.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function p7({provider:e,name:n,set:s,onSave:r,onCancel:o}){const i=g.useRef(null),[l,d]=g.useState(!1),[u,f]=g.useState(!1),[h,v]=g.useState(null),b=()=>{var y,j;return((j=(y=i.current)==null?void 0:y.elements.namedItem(n))==null?void 0:j.value)??""},m=()=>{var y;(y=i.current)==null||y.reset(),d(!1)},x=async y=>{var S;y.preventDefault();const j=b();if(!j)return;f(!0),v(null);const k=await r({[n]:j});if(f(!1),!k){m();return}const C=(S=k.fields)==null?void 0:S.find(E=>E.field===n),N=(k.fields??[]).filter(E=>E.field!==n).map(E=>E.message);v(C?{field:C.message,message:N.join(" ")}:{field:null,message:N.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:y=>void x(y),onInput:()=>d(!!b()),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(Fe,{type:"password",name:n,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(h==null?void 0:h.field)&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:h.field})]}),(h==null?void 0:h.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:h.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(W,{type:"submit",size:"sm",variant:"solid",disabled:!l||u,children:u?"Saving":"Save"}),t.jsx(W,{type:"button",size:"sm",onClick:()=>{m(),o()},children:"Cancel"})]})]})}const g7="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.",s1=[{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)"}],x7=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),Wr="ARCHIL_API_KEY",b7=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function v7({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=g.useState(null),[i,l]=g.useState(null),[d,u]=g.useState({region:"",s3Url:"",image:""}),[f,h]=g.useState(null),[v,b]=g.useState(null),[m,x]=g.useState(!1),[y,j]=g.useState(null),[k,C]=g.useState(!1),[N,S]=g.useState(!1),[E,$]=g.useState(!1),[L,A]=g.useState(!1),P=g.useRef(null),O=g.useRef(0),T=g.useCallback(H=>{o(H),u(x7(H))},[]),M=g.useCallback(()=>{const H=++O.current;l(null),e.archil().then(U=>{H===O.current&&T(U)},U=>{H===O.current&&l(b7(U))})},[e,T]);if(g.useEffect(M,[M]),!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(W,{size:"sm",onClick:M,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(cs,{label:"Loading Archil's settings",rows:2})});const F=()=>{var H,U;return((U=(H=P.current)==null?void 0:H.elements.namedItem(Wr))==null?void 0:U.value)??""},I=async H=>{const U={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...H!==void 0?{keys:{[Wr]:H}}:{}};x(!0),h(null),b(null);try{const Q=await e.saveArchil(U);$(!1),A(!1),T(Q)}catch(Q){if(Q instanceof Ue&&Q.status===422){const D={},Y=[];for(const K of Q.fields??[]){const Z=K.field.startsWith("keys.")?K.field.slice(5):K.field;s1.some(se=>se.name===Z)||Z===Wr?D[Z]=K.message:Y.push(K.message)}h({fields:D,message:Y.length?Y.join(" "):Object.keys(D).length?null:Q.message})}else b(Gt(Q))}finally{x(!1)}},V=H=>{H.preventDefault(),I(E&&F()?F():void 0)},G=async()=>{C(!0);try{const H=await e.testArchil();j(H.ok?{ok:!0,words:H.detail,at:new Date().toISOString()}:{ok:!1,words:H.why,at:new Date().toISOString()})}catch(H){j({ok:!1,words:Gt(H),at:new Date().toISOString()})}finally{C(!1)}},q=async()=>{b(null);try{T(await e.archilOff()),S(!1)}catch(H){b(Gt(H))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Eo,children:[t.jsxs("div",{className:Sa,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:g7})]}),t.jsxs("div",{className:Ca,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:no[s]}),t.jsx(Ws,{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(uA,{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(W,{size:"sm",onClick:()=>void G(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(W,{size:"sm",variant:"destructive",onClick:()=>S(!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"} · ${li(y.at)} · ${y.words}`}),N&&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(W,{size:"sm",variant:"destructive",onClick:()=>void q(),children:"Turn off"}),t.jsx(W,{size:"sm",onClick:()=>S(!1),children:"Cancel"})]}),v&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:v}),t.jsxs("form",{ref:P,autoComplete:"off",onSubmit:V,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[s1.map(H=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:H.label}),t.jsx(Fe,{name:H.name,value:d[H.name],placeholder:H.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:U=>{const Q=U.currentTarget.value;u(D=>({...D,[H.name]:Q}))}}),(f==null?void 0:f.fields[H.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[H.name]})]},H.name)),t.jsx("ul",{children:t.jsx(Bh,{field:r.secret,label:Wr,writable:n&&!E&&!L,onPaste:()=>void Hh(()=>$(!0),()=>{var H;return(H=P.current)==null?void 0:H.elements.namedItem(Wr)}),onRemove:()=>A(!0)})}),n&&L&&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(W,{type:"button",size:"sm",variant:"destructive",onClick:()=>void I(null),children:"Remove"}),t.jsx(W,{type:"button",size:"sm",onClick:()=>A(!1),children:"Cancel"})]}),n&&E&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:Wr}),t.jsx(Fe,{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&&E&&t.jsx(W,{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(W,{type:"submit",size:"sm",variant:"solid",disabled:m,children:m?"Saving":r.on?"Save":"Turn on"})]})]})})]})]})})}function y7({cli:e,ended:n}){const s=[["Original CLI",gh(e.runtime)],["Session",e.session_id],["Prompt window",e.turn_id],["Model",e.model??"Not reported"],["Source policy",e.policy_complete?"Captured":n?"Incomplete — learning unavailable":"Awaiting source policy"],["Task evidence",n?e.evidence_complete?"Complete":"Incomplete":"Awaiting completion"],["Pinned learning revision",e.learning_revision??"None supplied"],["Guidance in source context",e.seed_observed?"Verified":"Reuse not verified"]];return t.jsxs("section",{className:"space-y-3 border bg-card p-4","aria-label":"CLI learning evidence",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"CLI prompt window"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:s.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("p",{className:"text-small text-muted-foreground",children:"Completed prompts are recorded here. Manage your corrections in Learning; this CLI connection does not support learned workflow execution."})]})}const TE="tool_approval_requested";function w7(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 j7(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 ${Qd(e)} per call`:null}function k7(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(`
|
|
723
|
-
`)}const N7={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 RE(e){var n;if(e instanceof Ue){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?N7[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 Gt(e)}const S7=2e3;function AE({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[o,i]=g.useState(""),[l,d]=g.useState(!1),[u,f]=g.useState(null),[h,v]=g.useState(null),[b,m]=g.useState(!1),x=e.destructive===!0,y=g.useRef(!1),j=g.useRef(null),k=g.useRef(!1);g.useEffect(()=>{var S;b||!k.current||(k.current=!1,(S=j.current)==null||S.focus())},[b]);const C=j7(e.price),N=async(S,E)=>{if(y.current)return;y.current=!0,d(!0),f(null),m(!1);const $=o.trim(),L=await(E?n(S,void 0,E):n(S,S==="deny"&&$?$:void 0));y.current=!1,d(!1),L?f(L):v(S)};return t.jsxs("section",{"aria-label":"Approval required",className:ee("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:ee("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(Z1,{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}),".",x&&t.jsxs(t.Fragment,{children:[" ",t.jsx(ke,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),e.asks_because&&t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["Asks because ",e.asks_because,"."]}),t.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:ee("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:k7(e.args_preview)}),C&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:C}),h?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:h==="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(An,{value:o,onChange:S=>i(S.target.value),maxLength:S7,rows:s?1:2,disabled:l,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(W,{ref:j,type:"button",variant:"solid",size:"sm",disabled:l||b,onClick:()=>x?m(!0):void N("allow"),children:"Allow once"}),t.jsx(W,{type:"button",size:"sm",disabled:l,onClick:()=>void N("deny"),children:"Deny"}),l&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),b&&t.jsx(C7,{tool:e.tool,onAllow:()=>void N("allow",!0),onBack:()=>{k.current=!0,m(!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 C7({tool:e,onAllow:n,onBack:s}){const r=g.useRef(null);return g.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(W,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),t.jsx(W,{type:"button",size:"sm",variant:"destructive",onClick:n,children:"Allow this destructive call"})]})}const _7={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 $7({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??_7[e],[l,d]=g.useState(""),[u,f]=g.useState(!1),h=s||u,v=async()=>{if(!l.trim()||!n||h)return;f(!0);const b=await n(l.trim());f(!1),b!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:b=>{b.preventDefault(),v()},children:[t.jsx(An,{bare:!0,id:"composer",rows:2,value:l,readOnly:h,"aria-busy":h,onChange:b=>d(b.target.value),placeholder:i.placeholder,onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),v())},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(W,{type:"submit",size:"sm",disabled:!l.trim()||!n||h,children:[h?"Sending":"Send"," ",t.jsx(oA,{"aria-hidden":!0})]})]})]})}let vl=0;const wb=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},r1=e=>{vl=e,history.replaceState({...history.state??{},console_at:e},"")};function E7(){const e=wb();e===void 0?r1(0):vl=e;const n=()=>{const s=wb();s===void 0?r1(vl+1):vl=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function T7(){const e=wb();return e===void 0?-1:vl-e}function R7(e){vl>0?history.back():location.hash=e}const A7=(e,n)=>{const s=vi(e),r=_l(e),o=r?JI(r):void 0;if(s)return o?`${b0(s,{ended:n})} ${o}`:b0(s,{ended:n});const i=e&&e.usd!==null?qI(e):void 0;return i?o?`${i}. ${o}`:i:o},O7="The run's model requests' tokens, as the provider or gateway reported them: input (cached input apart), output, and the prompt cache's reads and writes. An unmetered request reported none.";function L7({run:e,agentName:n,actions:s={},costText:r,raiseBelow:o}){var E,$,L,A;const i=is(e),l=ml(e),d=l?"your CLI":i?"your backend":oD(e.place),u=Nh(e.status,e.state,e.kind,kh,!0,e.error,e.review,e.computer),f=i||l?{...u,canStop:!1,canCancel:!1}:u,[h,v]=g.useState(!1),b=!!e.archived_at,m=(E=e.cost)==null?void 0:E.cap_usd,x=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",y=!i&&!l&&!!s.onRaiseCap&&!f.final&&typeof m=="number"&&!x,[j,k]=g.useState(!1),C=(($=e.pending)==null?void 0:$.kind)==="budget"?e.pending:null,N=!!_l(e.cost),S=N&&((L=_l(e.cost))==null?void 0:L.on)!=="claude_code";return t.jsxs("header",{children:[t.jsxs("nav",{className:ee(Lr,"caps min-w-0 gap-2 px-5 text-label text-muted-foreground md:px-8"),"aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>R7(jn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(Wn,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:jn(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 ",ka(e.run_id)]})]}),t.jsxs("div",{"data-title-block":!0,className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("div",{"data-phone-row":!0,className:"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:Hn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Hn(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(ql,{run:e}),b&&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:[t.jsx(xE,{run:e,named:!0})," · rev ",e.agent_version,d&&` · ${d}`]}),l&&t.jsxs("span",{className:"font-mono",children:[gh(l.runtime)," · ",l.model??"Model not reported"]}),i&&t.jsxs("span",{className:"font-mono",children:[Ro(i)," · ",((A=e.sdk)==null?void 0:A.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:ht(e.created_at)}),r!==void 0&&!N?t.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:v0(e.cost,m,{text:r})}):t.jsxs("span",{className:"font-mono",title:A7(e.cost,Co(e.status)),children:[v0(e.cost,m,{ended:Co(e.status)}),S&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(iy,{})]})]}),x0(e.cost)&&t.jsx("span",{className:"font-mono","data-run-tokens":!0,title:O7,children:x0(e.cost)}),t.jsx(ty,{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]})]}),(f.canStop||f.canCancel||s.onArchive||y)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[y&&t.jsxs(W,{size:"sm",onClick:o??(()=>k(P=>!P)),"aria-expanded":o?void 0:j,title:`Raise its ${Tr(m)} spend cap.`,children:[t.jsx(Lb,{"aria-hidden":!0})," Raise the cap"]}),f.canStop&&t.jsxs(W,{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($A,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),f.canCancel&&!h&&t.jsxs(W,{size:"sm",variant:"destructive",onClick:()=>v(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[t.jsx(H1,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),h&&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(W,{size:"sm",variant:"destructive",onClick:()=>{var P;v(!1),(P=s.onCancel)==null||P.call(s)},children:"Yes, cancel"}),t.jsx(W,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Keep"})]}),s.onArchive&&t.jsxs(W,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:b?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[b?t.jsx(W1,{"aria-hidden":!0}):t.jsx(Fd,{"aria-hidden":!0})," ",s.busy==="archive"?b?"Unarchiving":"Archiving":b?"Unarchive":"Archive"]})]})]}),y&&j&&!o&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(kE,{cap:m,suggested:wE(C),least:jE(C),paused:!!C,onRaise:s.onRaiseCap},C?`${e.run_id}:${C.at}`:`${e.run_id}:working`)})]})]})}const M7=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function I7({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:M7.map(s=>t.jsxs("label",{className:ee("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 OE=(e,n)=>n?e:e.filter(s=>!JC(s.path));function P7({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>JC(d.path)).length,i=OE(e,s),l=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(cA,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",hr(l),")"]}),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(mi,{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:hr(d.size_bytes)})]})},d.path))})]})}function D7({file:e,text:n,onClose:s,files:r=[],onOpen:o,src:i}){const[l,d]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{var S;const C=document.activeElement,N=u.current;return N&&!N.open&&((S=N.showModal)==null||S.call(N)),()=>{var E;N!=null&&N.open&&N.close(),(E=C==null?void 0:C.focus)==null||E.call(C)}},[]),g.useEffect(()=>d(!1),[e.path]);const f=g.useRef(!1),h=g.useRef(!1),v=YC(e),b=QC(v)&&i!==void 0?v:void 0,m=v==="markdown"||v==="text",[x,y]=g.useState(v==="markdown"?"rendered":"raw");g.useEffect(()=>y(v==="markdown"?"rendered":"raw"),[e.path]);const j=xv(C=>{const N=r.find(S=>S.path===C);N&&(o==null||o(N))}),k=()=>{if(n===null)return;const C=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:C,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(C)};return t.jsx("dialog",{ref:u,"aria-label":e.path,onCancel:C=>{C.preventDefault(),s()},onMouseDown:C=>{f.current=C.target===C.currentTarget},onMouseUp:C=>{h.current=C.target===C.currentTarget},onClick:C=>{f.current&&h.current&&C.target===C.currentTarget&&s(),f.current=h.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(W,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Oo,{"aria-hidden":!0})}),t.jsx(mi,{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}),m&&t.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:t.jsx(I7,{view:x,onView:y})}),t.jsxs(W,{size:"sm",disabled:n===null||b!==void 0,onClick:async()=>{var C;n!==null&&(await((C=navigator.clipboard)==null?void 0:C.writeText(n)),d(!0))},children:[t.jsx(fi,{"aria-hidden":!0})," ",l?"Copied":"Copy"]}),b?t.jsxs("a",{href:`${i}?download=1`,download:e.path.split("/").pop(),className:Fs({size:"sm"}),children:[t.jsx(rm,{"aria-hidden":!0})," Download"]}):t.jsxs(W,{size:"sm",disabled:n===null,onClick:k,children:[t.jsx(rm,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:b==="image"?t.jsx("img",{src:i,alt:e.path,className:"mx-auto max-h-full max-w-full object-contain"}):b==="video"?t.jsx("video",{src:i,controls:!0,playsInline:!0,preload:"metadata","aria-label":e.path,className:"mx-auto max-h-full max-w-full"}):b==="audio"?t.jsx("audio",{src:i,controls:!0,preload:"metadata","aria-label":e.path,className:"mx-auto w-full max-w-xl"}):n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):m?x==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:j,dangerouslySetInnerHTML:{__html:Yr(n,o&&{paths:r.map(C=>C.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.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",b?hr(e.size_bytes):n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function z7(e){const n=e.replace(/\r\n?/g,`
|
|
724
|
-
`).trim(),s=l=>{try{const d=JSON.parse(l);return d&&typeof d=="object"&&!Array.isArray(d)?d:null}catch{return null}},r=n.split(`
|
|
725
|
-
`);let o;for(let l=0;l<r.length;l++){const d=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[l]);if(!d)continue;const u=d[1],f=new RegExp(`^ {0,3}${u[0]==="`"?"`":"~"}{${u.length},}\\s*$`),h=r.findIndex((b,m)=>m>l&&f.test(b));if(h<0)break;const v=d[2].trim().toLowerCase();o=v==="json"||v===""?{open:l,end:h}:void 0,l=h}if(o&&o.end===r.length-1){const l=s(r.slice(o.open+1,o.end).join(`
|
|
726
|
-
`));return l?{words:r.slice(0,o.open).join(`
|
|
727
|
-
`).trim(),record:l}:null}const i=s(n);if(i)return{words:"",record:i};for(let l=n.lastIndexOf(`
|
|
728
|
-
{`);l>=0;l=n.lastIndexOf(`
|
|
729
|
-
{`,l-1)){const d=s(n.slice(l+1));if(d)return{words:n.slice(0,l).trim(),record:d};if(l===0)break}return null}const F7=e=>e.replace(/[_-]+/g," ").trim()||e,Jc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function Dm(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,...l}=s,d=Jc(o.reduce((f,h)=>{var v;return(v=Jc(f))==null?void 0:v[h]},n))??{},u=d.properties||l.properties?{...Jc(d.properties),...Jc(l.properties)}:void 0;s={...d,...l,...u?{properties:u}:{}}}return s}const U7=(e,n)=>{var s;return((s=Dm(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function Sy({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=Dm(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((l,d)=>t.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:t.jsx(Sy,{value:l,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(LE,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&U7(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:Yr(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 LE({record:e,schema:n,root:s,linked:r}){var i;const o=(i=Dm(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(([l,d])=>{var h;const u=o==null?void 0:o[l],f=(h=Dm(u,s))==null?void 0:h.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:F7(l)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(Sy,{value:d,schema:u,root:s,linked:r})})]},l)})})}function o1({record:e,schema:n,linked:s}){const[r,o]=g.useState(!1);return t.jsxs("section",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{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(LE,{record:e,schema:n,root:n,linked:s})})]})}function W7({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(Sy,{value:e,schema:n,root:n,linked:s})})}function H7({run:e,rows:n,files:s=[],onOpen:r,schema:o}){var v,b,m,x,y;const i=((v=e.result)==null?void 0:v.final_answer)??((b=n.findLast(j=>j.kind==="final_answer"))==null?void 0:b.text)??null,l=r?{paths:s.map(j=>j.path)}:void 0,d=xv(j=>{const k=s.find(C=>C.path===j);k&&(r==null||r(k))}),u=(m=e.result)==null?void 0:m.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(o1,{record:u,schema:o,linked:l}):t.jsx(W7,{value:u,schema:o,linked:l})});const f=e.kind==="agentic"?(x=e.result)==null?void 0:x.output_error:void 0,h=f?t.jsx(ct,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=z7(i);return j?t.jsxs("div",{className:"min-w-0 space-y-6",children:[h,j.words&&t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:Yr(j.words,l)}}),t.jsx(o1,{record:j.record})]}):t.jsxs("div",{className:"min-w-0 space-y-6",children:[h,t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:Yr(i,l)}})]})}if(h)return h;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(N=>typeof N[1]=="string"&&N[1].includes(`
|
|
730
|
-
`)&&N[1].length>80):[],C=k.length?Object.fromEntries(Object.entries(j).filter(([N])=>!k.some(([S])=>S===N))):j;return t.jsxs("div",{className:"space-y-8",children:[k.map(([N,S])=>t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:N.replace(/_/g," ")}),t.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:d,dangerouslySetInnerHTML:{__html:Yr(S,l)}})]},N)),(!k.length||Object.keys(C).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(C,null,2)})]})]})}return null}const St=e=>Date.parse(e);function Vt(e,n){return e.ended_at?Math.max(0,St(e.ended_at)-St(e.started_at)):n!==void 0&&(e.status==="running"||e.status==="waiting")?Math.max(0,n-St(e.started_at)):null}function nn(e){if(e<1e3)return`${Math.round(e)} ms`;if(e<6e4)return`${(e/1e3).toFixed(1)} s`;const n=Math.round(e/1e3);return n<3600?`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n%3600/60)).padStart(2,"0")}m`}function wo(e){const n=Math.max(0,e);if(n>=36e5){const r=Math.floor(n/1e3);return`+${Math.floor(r/3600)}:${String(Math.floor(r%3600/60)).padStart(2,"0")}:${String(r%60).padStart(2,"0")}`}const s=Math.floor(n/100);return`+${Math.floor(s/600)}:${String(Math.floor(s%600/10)).padStart(2,"0")}.${s%10}`}const os=e=>e.input+e.cache_read+e.cache_write,pu=e=>{const n=e.input+e.cache_read+e.cache_write;return n>0?e.cache_read/n:null},zs=e=>e>0&&e<.005?"<1%":`${e>=.995&&e<1?"99":Math.round(e*100)}%`;function Ld(e,n){if(!e.length)return{from:n,to:n,ms:0};let[s,r]=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const o of e){const i=St(o.started_at);s=Math.min(s,i),r=Math.max(r,i+(Vt(o,n)??0))}return{from:s,to:r,ms:Math.max(0,r-s)}}function a1(e,n,s,r=.2){const o=[];return{bars:[...e].sort((l,d)=>St(l.started_at)-St(d.started_at)).map(l=>{const d=n.ms>0?(St(l.started_at)-n.from)/n.ms*100:0,u=n.ms>0?(Vt(l,s)??0)/n.ms*100:100;let f=o.findIndex(h=>h+r<=d);return f<0&&(f=o.push(0)-1),o[f]=d+u,{span:l,left:d,width:u,row:f}}),rows:Math.max(1,o.length)}}const B7=[100,200,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5,9e5,18e5,36e5,72e5,144e5,288e5,864e5];function i1(e,n=8,s=0){if(e<=0)return[{left:0,label:"0:00"}];const r=B7.find(l=>e/l<=n)??Math.ceil(e/n/864e5)*864e5,o=l=>{if(r<1e3)return`${(l/1e3).toFixed(1)}s`;const d=Math.round(l/1e3);return d>=3600?`${Math.floor(d/3600)}:${String(Math.floor(d%3600/60)).padStart(2,"0")}:${String(d%60).padStart(2,"0")}`:`${Math.floor(d/60)}:${String(d%60).padStart(2,"0")}`},i=[];for(let l=Math.ceil(s/r)*r;l<=s+e;l+=r)i.push({left:(l-s)/e*100,label:o(l)});return i}const il={from:0,to:1},ME=1/64,Cy=(e,n)=>{const s=Math.min(1,Math.max(ME,n)),r=Math.min(1-s,Math.max(0,e));return s>=1?il:{from:r,to:r+s}};function l1(e,n,s=(e.from+e.to)/2){const r=Math.min(1,Math.max(ME,(e.to-e.from)/n));return Cy(s-r/2,r)}const c1=(e,n)=>Cy(e.from+(e.to-e.from)*n,e.to-e.from),q7=(e,n)=>Cy(Math.min(e,n),Math.abs(e-n));function d1(e,n,s,r){const o=(s.to-s.from)*n.ms;if(o<=0)return{left:0,width:100,off:null};const i=n.from+s.from*n.ms,l=(St(e.started_at)-i)/o*100,d=l+(Vt(e,r)??0)/o*100;if(d<0)return{off:"before"};if(l>100)return{off:"after"};const u=Math.max(0,l);return{left:u,width:Math.min(100,d)-u,off:null}}function u1(e,n){const s=e.map(i=>[St(i.started_at),St(i.started_at)+(Vt(i,n)??0)]).sort((i,l)=>i[0]-l[0]);let[r,o]=[0,Number.NEGATIVE_INFINITY];for(const[i,l]of s)l<=o||(r+=l-Math.max(i,o),o=l);return r}const pd=e=>({usd:e.reduce((n,s)=>n+(s??0),0),unknown:e.filter(n=>n===null).length}),IE=e=>e.reduce((n,{tokens:s})=>s?{input:n.input+s.input,cache_read:n.cache_read+s.cache_read,cache_write:n.cache_write+s.cache_write,output:n.output+s.output,reasoning:n.reasoning+(s.reasoning??0)}:n,{input:0,cache_read:0,cache_write:0,output:0,reasoning:0});function _y(e,n){const s=e.spans.filter(u=>u.kind==="model"),r=e.spans.filter(u=>u.kind==="tool"),o=Ld(e.spans,n),[i,l]=[u1(e.spans,n),u1(s,n)],d=r.filter(u=>u.charged);return{requests:s.length,calls:r.length,failed:e.spans.filter(u=>u.status==="failed").length,tokens:s.length?IE(s):null,untold:s.filter(u=>!u.tokens).length,cost:{requests:s.length?e.model_requests==="priced"?pd(s.map(u=>u.usd)):s.some(u=>u.decision)?pd(s.filter(u=>u.decision).map(u=>u.usd)):null:null,charges:pd(d.map(u=>u.usd)),charged:d.length,notMetered:r.filter(u=>u.not_metered).length},time:{wall:o.ms,model:l,tools:Math.max(0,i-l),other:Math.max(0,o.ms-i)}}}const zm=(e,n)=>e.length?e[Math.min(e.length-1,Math.max(0,Math.ceil(n*e.length)-1))]:null;function G7(e,n){const s=new Map;for(const r of e)r.kind==="tool"&&s.set(r.name,[...s.get(r.name)??[],r]);return[...s].map(([r,o])=>{const i=o.map(d=>Vt(d,n)).filter(d=>d!==null).sort((d,u)=>d-u),l=o.filter(d=>d.charged);return{name:r,calls:o.length,failed:o.filter(d=>d.status==="failed").length,totalMs:i.reduce((d,u)=>d+u,0),p50:zm(i,.5),p95:zm(i,.95),maxMs:i.at(-1)??null,charges:pd(l.map(d=>d.usd)),charged:l.length,bytes:o.reduce((d,u)=>d+(u.result_size_bytes??0),0)}}).sort((r,o)=>o.totalMs-r.totalMs||o.calls-r.calls||r.name.localeCompare(o.name))}function K7(e,n=!0){const s=new Map;for(const r of e)r.kind==="model"&&s.set(r.name,[...s.get(r.name)??[],r]);return[...s].map(([r,o])=>{const i=IE(o),l=n?o:o.filter(h=>h.decision),d=o.filter(h=>h.tokens&&(Vt(h)??0)>0),u=o.map(h=>Vt(h)).filter(h=>h!==null).sort((h,v)=>h-v),f=d.reduce((h,v)=>h+Vt(v),0);return{name:r,requests:o.length,failed:o.filter(h=>h.status==="failed").length,tokens:i,cache:pu(i),cost:l.length?pd(l.map(h=>h.usd)):null,totalMs:u.reduce((h,v)=>h+v,0),p50:zm(u,.5),p95:zm(u,.95),perSecond:f>0?d.reduce((h,v)=>h+v.tokens.output,0)/(f/1e3):null}}).sort((r,o)=>o.requests-r.requests||r.name.localeCompare(o.name))}function ux(e,n,s){return(n==="failed"?e.status!=="failed":n!=="all"&&e.kind!==n)?!1:Us(s,e.name,e.agent_label,e.input_preview,e.status)}function V7(e,n,s){const r=[...e].sort((d,u)=>St(d.started_at)-St(u.started_at));if(n==="started")return r;const o=d=>d.tokens?os(d.tokens)+d.tokens.output:d.kind==="tool"?d.result_size_bytes:null,i=d=>n==="duration"?Vt(d,s):n==="cost"?d.usd:o(d),l=d=>n==="tokens"&&d.kind==="tool"?1:0;return r.map(d=>({span:d,n:i(d)})).sort((d,u)=>l(d.span)-l(u.span)||(u.n??-1)-(d.n??-1)).map(({span:d})=>d)}const as=e=>e===0?"$0":e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`;function Y7(e){const n=new Map;let[s,r]=[0,!1];for(const l of e)l.usd!==null&&(r=!0,l.kind==="tool"?s+=l.usd:n.set(l.name,(n.get(l.name)??0)+l.usd));const o=[...[...n].map(([l,d])=>({name:l,kind:"model",usd:d})).sort((l,d)=>d.usd-l.usd),...s>0?[{name:"Tool charges",kind:"tool",usd:s}]:[]],i=o.reduce((l,d)=>l+d.usd,0);return r?{parts:o,total:i}:null}const Q7={vcpu:"vCPU",memory:"memory",gpu:"GPU",disk:"disk"};function PE(e){if(e.meter==="tokens")return e.model??"A model with no name";if(e.meter==="tools")return`${e.charged_by??"An unnamed vendor"} · tools`;if(e.meter==="compute_time"){const n=e.resource==="gpu"&&e.gpu_type?`${e.gpu_type} GPU`:Q7[e.resource??"vcpu"];return`${e.provider??"An unnamed provider"} · ${n}`}return`${e.provider??"An unnamed provider"} · browser time`}function $y(e){return e.usd!==null?e.upper_bound?`at most ${as(e.usd)}`:as(e.usd):e.so_far_usd!==void 0?`Unknown, ${as(e.so_far_usd)} known`:"Unknown"}const J7={token:["token","tokens"],call:["call","calls"],second:["second","seconds"],vcpu_second:["vCPU-second","vCPU-seconds"],gib_second:["GiB-second","GiB-seconds"],gpu_second:["GPU-second","GPU-seconds"],gb_month:["GB-month","GB-months"]};function DE(e,n=e.quantity){if(n===null)return null;const[s,r]=J7[e.unit];return`${n.toLocaleString("en-US",{maximumFractionDigits:e.unit==="gb_month"?6:1})} ${n===1?s:r}`}const X7={reported:"Reported",estimate:"Estimate",unpriced:"No price"};function Z7(e){const n=[];return e.not_metered_calls&&n.push(`${e.not_metered_calls} call${e.not_metered_calls===1?"":"s"} not metered: no price is set, so ${e.not_metered_calls===1?"it is":"they are"} outside the cost`),e.unmetered_requests&&n.push(`${e.unmetered_requests} request${e.unmetered_requests===1?"":"s"} reported no tokens`),e.unheld_quantity&&n.push(`${DE(e,e.unheld_quantity)} no claim held: outside the cost`),e.open_computers&&n.push(`${e.open_computers} computer${e.open_computers===1?"":"s"} still running when read`),n}function zE(e){const n=new Map(e.spans.map(s=>[s.id,s]));return s=>{if(e.model_requests!=="priced")return null;let r=s;for(let o=0;(r==null?void 0:r.kind)==="tool"&&o<8;o++)r=r.parent_id?n.get(r.parent_id):void 0;return(r==null?void 0:r.kind)==="model"&&!r.decision?r.parent_id??"":null}}function eB(e,n){const{spans:s}=e,r=_y(e,n),o=[],i=C=>s.filter(N=>N.kind===C&&Vt(N,n)!==null).sort((N,S)=>Vt(S,n)-Vt(N,n))[0],l=C=>r.time.wall>0?` · ${zs(C/r.time.wall)} of the run's time`:"",d=s.filter(C=>C.status==="failed");if(d.length){const C=[...new Set(d.map(N=>N.name))];o.push({id:"failed",bad:!0,span:d[0].id,title:d.length===1?`1 call failed: ${d[0].name}`:`${d.length} calls failed`,detail:d.length===1?`At ${wo(St(d[0].started_at)-Ld(s,n).from)}.${s.some(N=>St(N.started_at)>St(d[0].started_at))?" The run went on after it.":" Nothing ran after it."}`:C.slice(0,4).join(", ")+(C.length>4?` and ${C.length-4} more`:"")})}const u=i("tool");u&&o.push({id:"slowest-call",span:u.id,title:`Slowest call: ${u.name}`,detail:`${nn(Vt(u,n))}${l(Vt(u,n))}${u.status==="waiting"?" · waiting for a person":""}`});const f=i("model");f&&o.push({id:"slowest-request",span:f.id,title:`Longest request: ${nn(Vt(f,n))}`,detail:`${f.name}${f.tokens?` · wrote ${f.tokens.output.toLocaleString("en-US")} tokens`:""}${l(Vt(f,n))}`});const h=s.filter(C=>C.kind==="model"&&C.usd!==null),v=[...h].sort((C,N)=>N.usd-C.usd)[0],b=h.reduce((C,N)=>C+N.usd,0);v&&h.length>1&&v.usd>0&&o.push({id:"dearest",span:v.id,title:`Most expensive request: ${as(v.usd)}`,detail:`${zs(v.usd/b)} of what the requests cost${v.tokens?` · ${os(v.tokens).toLocaleString("en-US")} tokens in, ${v.tokens.output.toLocaleString("en-US")} out`:""}`});const m=r.tokens?pu(r.tokens):null;if(m!==null){const C=s.filter(N=>N.kind==="model"&&N.tokens&&N.tokens.cache_read===0).length;o.push({id:"cache",title:`${zs(m)} of input was read from cache`,detail:`${r.tokens.cache_read.toLocaleString("en-US")} of ${os(r.tokens).toLocaleString("en-US")} input tokens. ${C===0?"Every request read from cache.":`${C} of ${r.requests} request${r.requests===1?"":"s"} read nothing from cache.`}`})}const x=zE(e),y=[...s].filter(C=>C.kind==="model"&&C.tokens&&x(C)!==null).sort((C,N)=>St(C.started_at)-St(N.started_at)),j=y.find((C,N)=>C.tokens.cache_read===0&&os(C.tokens)>0&&y.slice(0,N).some(S=>S.name===C.name&&x(S)===x(C)&&S.tokens.cache_write+S.tokens.cache_read>0));j&&o.push({id:"cache-reset",span:j.id,title:`A request read nothing from cache at ${wo(St(j.started_at)-Ld(s,n).from)}`,detail:`Earlier requests to ${j.name} wrote to the cache. This one sent its whole input fresh: ${os(j.tokens).toLocaleString("en-US")} tokens.`});const k=s.filter(C=>C.kind==="tool"&&(C.result_size_bytes??0)>=8*1024).sort((C,N)=>N.result_size_bytes-C.result_size_bytes)[0];return k&&o.push({id:"largest",span:k.id,title:`Largest result: ${k.name}`,detail:`${Math.round(k.result_size_bytes/1024).toLocaleString("en-US")} KB, which is input to every request after it.`}),r.time.wall>0&&r.time.other/r.time.wall>=.25&&o.push({id:"between",title:`${zs(r.time.other/r.time.wall)} of the run was between calls`,detail:`${nn(r.time.other)} with no model answering and no tool running: waiting for a person or its turn, or the harness working.`}),r.cost.charges.unknown>0&&o.push({id:"unknown-charges",title:`${r.cost.charges.unknown} charge${r.cost.charges.unknown===1?"":"s"} of an unknown amount`,detail:"The run's cost is unknown until each is priced."}),o}function tB(e,n,s){const{spans:r}=n,o=new Map(r.map(m=>[m.id,m])),i=zE(n),l=i(e),d=m=>l!==null&&i(m)===l,u=St(e.started_at),f=e.ended_at?St(e.ended_at):null,h=m=>m.ended_at?St(m.ended_at):null;let v,b;if(e.kind==="tool"){const m=e.parent_id?o.get(e.parent_id):void 0;v=m&&h(m)!==null&&h(m)<=u?m:void 0,f!==null&&(b=r.filter(x=>x.kind==="model"&&x.id!==e.parent_id&&d(x)&&St(x.started_at)>=f).sort((x,y)=>St(x.started_at)-St(y.started_at))[0])}else v=r.filter(m=>m.id!==e.id&&d(m)&&h(m)!==null&&h(m)<=u).sort((m,x)=>h(x)-h(m))[0],f!==null&&(b=r.filter(m=>m.parent_id===e.id&&St(m.started_at)>=f).sort((m,x)=>St(m.started_at)-St(x.started_at))[0]);return{before:v?{ms:u-h(v),since:v}:null,ran:Vt(e,s),then:b&&f!==null?{ms:St(b.started_at)-f,until:b}:null}}function nB(e,n){const s=Ld(e,n),r=[...e].sort((y,j)=>St(y.started_at)-St(j.started_at)),o=r.filter(y=>y.kind==="model"),i=r.filter(y=>y.kind==="tool"),l=o.filter(y=>y.ended_at&&y.status==="ok").sort((y,j)=>St(y.ended_at)-St(j.ended_at))[0],u=[...o.filter(y=>y.tokens)].sort((y,j)=>os(j.tokens)-os(y.tokens))[0],f=i.flatMap(y=>{const j=Vt(y,n);return j?[[St(y.started_at),1],[St(y.started_at)+j,-1]]:[]}).sort((y,j)=>y[0]-j[0]||y[1]-j[1]);let[h,v,b]=[0,0,0];for(const[y,j]of f)h+=j,h>v&&([v,b]=[h,y]);let m=null,x=null;for(const y of r){const[j,k]=[St(y.started_at),St(y.started_at)+(Vt(y,n)??0)];x&&j-x.end>((m==null?void 0:m.ms)??0)&&(m={ms:j-x.end,at:x.end-s.from,after:x.span}),(!x||k>x.end)&&(x={end:k,span:y})}return{firstAnswer:l?{ms:St(l.ended_at)-s.from,span:l}:null,firstCall:i[0]?{ms:St(i[0].started_at)-s.from,span:i[0]}:null,largestInput:u?{tokens:os(u.tokens),span:u,nth:o.indexOf(u)+1,of:o.length}:null,atOnce:v>0?{calls:v,at:b-s.from}:null,longestPause:m}}function sB(e,n){const{got:s,error:r,retry:o}=FE(e,n);return{trace:s,error:r,retry:o}}function FE(e,n){const[s,r]=g.useState(null),[o,i]=g.useState(null),l=g.useRef(e);l.current=e;const d=g.useRef({mounted:!1,out:!1,again:!1,timer:void 0,seen:null}),u=g.useRef(()=>{});return u.current=()=>{const f=d.current;if(clearTimeout(f.timer),f.timer=void 0,!(!l.current||!f.mounted)){if(f.out){f.again=!0;return}f.out=!0,f.again=!1,Promise.resolve().then(l.current).then(h=>{f.mounted&&(r(h),i(null))},h=>{f.mounted&&i(h)}).finally(()=>{f.out=!1,f.again&&f.mounted&&(f.timer=setTimeout(()=>u.current(),500))})}},g.useEffect(()=>{const f=d.current;return f.mounted=!0,()=>{f.mounted=!1,clearTimeout(f.timer),f.timer=void 0}},[]),g.useEffect(()=>{const f=d.current;f.seen===null?u.current():f.out?f.again=!0:f.timer===void 0&&(f.timer=setTimeout(()=>u.current(),500)),f.seen=n},[n]),{got:s,error:s?null:o,retry:()=>u.current()}}function rB(e,n){const[s,r]=g.useState(()=>Date.now());return g.useEffect(()=>{if(!e||n!==void 0)return;r(Date.now());const o=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(o)},[e,n]),n??s}const yl={ok:{tone:"success",word:"OK"},failed:{tone:"error",word:"Failed"},refused:{tone:"muted",word:"Refused"},interrupted:{tone:"muted",word:"Interrupted"},waiting:{tone:"warning",word:"Waiting"},running:{tone:"active",word:"Running"}},UE="border border-warning bg-warning/20",WE="border border-trace-model bg-trace-model/30",Xl="trace-hatch",Gr={fresh:"bg-muted-foreground",read:WE,write:`bg-trace-model ${Xl}`,output:"bg-trace-model"},Md=e=>e.status==="failed"?`bg-destructive ${Xl}`:e.status==="running"?"bg-run-active":e.status==="waiting"?UE:e.status!=="ok"?"bg-muted-foreground":e.kind==="model"?"bg-trace-model":"bg-trace-tool",f1={model:"Model",tool:"Tool"},gd=e=>e.unknown===0?as(e.usd):e.usd>0?`${as(e.usd)} + ${e.unknown} unknown`:"Unknown";function jb(e,n){return e.kind==="model"?e.usd!==null?as(e.usd):n.model_requests==="tokens_only"&&!e.decision?"–":"Unknown":e.charged?e.usd!==null?as(e.usd):"Unknown":e.not_metered?"Not metered":"–"}const oB=e=>e.tokens?`${Jn(os(e.tokens))} in · ${Jn(e.tokens.output)} out`:e.result_size_bytes!==null?hr(e.result_size_bytes):"–",sr=t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,children:"–"}),t.jsx("span",{className:"sr-only",children:"None"})]}),Id=e=>e===null||e==="–"?sr:e,m1=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),aB=e=>e instanceof Error&&e.message?e.message:"The server gave no reason.";function Zi({label:e,value:n,note:s,tone:r}){return t.jsxs("div",{className:"min-w-0 border-b border-r px-3 py-2.5",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:e}),t.jsx("dd",{className:ee("mt-0.5 break-words font-mono font-semibold leading-7",String(n).length>11?"text-lg":"text-figure",r==="bad"&&"text-destructive-text"),children:typeof n=="string"?Id(n):n}),t.jsx("dd",{className:"mt-0.5 text-small text-muted-foreground",children:s})]})}const rr=({children:e,aside:n,level:s="h3"})=>t.jsxs("div",{className:"mb-2 flex items-baseline justify-between gap-3",children:[t.jsx(s,{className:"caps text-small font-semibold",children:e}),n&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:n})]}),Jr=({className:e})=>t.jsx("span",{"aria-hidden":!0,className:ee("trace-mark inline-block size-2 shrink-0",e)});function h1({title:e,swatch:n,bars:s,rows:r,selected:o,dimmed:i,onPick:l,at:d}){return t.jsxs("div",{className:"mt-2.5 first:mt-0",children:[t.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[t.jsx(Jr,{className:n}),e]}),t.jsx("div",{className:"relative mt-1.5",style:{height:r*12-4},children:s.map(({span:u,left:f,width:h,row:v})=>t.jsx("span",{"data-span":u.id,"data-open":u.id===o?"":void 0,title:d(u),onClick:()=>l(u.id),style:{left:`${f}%`,width:`${h}%`,top:v*12},className:ee("trace-mark absolute h-2 min-w-0.5 cursor-pointer hover:opacity-80",Md(u),i(u)&&"opacity-25",u.id===o&&"ring-2 ring-foreground ring-offset-1 ring-offset-card")},u.id))})]})}function iB({marks:e,view:n,onView:s,children:r}){const o=g.useRef(null),[i,l]=g.useState(null),d=g.useRef(!1),u=v=>{var m;const b=(m=o.current)==null?void 0:m.getBoundingClientRect();return b&&b.width>0?Math.min(1,Math.max(0,(v.clientX-b.left)/b.width)):0},f=v=>{i&&(l(null),d.current&&Math.abs(v-i.from)>.01&&s(q7(i.from,v)))},h=i&&d.current?{from:Math.min(i.from,i.to),to:Math.max(i.from,i.to)}:null;return t.jsxs("div",{ref:o,"data-overview":!0,className:"relative cursor-crosshair touch-pan-y select-none",onPointerDown:v=>{if(v.button!==0)return;d.current=!1;const b=u(v);l({from:b,to:b})},onPointerMove:v=>{if(!i)return;const b=u(v);Math.abs(b-i.from)>.01&&(d.current=!0),l({from:i.from,to:b})},onPointerUp:v=>f(u(v)),onPointerLeave:()=>{i&&f(i.to)},onPointerCancel:()=>l(null),onClickCapture:v=>{d.current&&(v.stopPropagation(),d.current=!1)},children:[e.map(v=>t.jsx("span",{className:"absolute inset-y-0 w-px bg-border",style:{left:`${v.left}%`}},v.left)),r,h?t.jsx("span",{"data-band":!0,className:"pointer-events-none absolute inset-y-0 border-x border-foreground bg-foreground/10",style:{left:`${h.from*100}%`,width:`${(h.to-h.from)*100}%`}}):n!==il&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 bg-background/70",style:{width:`${n.from*100}%`}}),t.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-0 bg-background/70",style:{width:`${(1-n.to)*100}%`}}),t.jsx("span",{"data-band":!0,className:"pointer-events-none absolute inset-y-0 border-x-2 border-foreground",style:{left:`${n.from*100}%`,width:`${(n.to-n.from)*100}%`}})]})]})}function lB({span:e,trace:n,now:s,onPick:r}){const o=g.useMemo(()=>tB(e,n,s),[e,n,s]);if(!o.before&&!o.then)return null;const i=e.kind==="model",l=[...o.before?[{id:"before",word:"Waited to start",ms:o.before.ms,tone:"bg-border-strong",about:i?"since the end of":"since the answer of",to:o.before.since}]:[],...o.ran!==null?[{id:"ran",word:e.ended_at?i?"Answered in":"Ran for":e.status==="waiting"?"Waiting so far":"Running so far",ms:o.ran,tone:Md(e)}]:[],...o.then?[{id:"then",word:i?"Until its first call started":"Until the next request started",ms:o.then.ms,tone:`bg-border-strong ${Xl}`,about:"",to:o.then.until}]:[]],d=l.reduce((u,f)=>u+f.ms,0);return t.jsxs("section",{className:"mt-5","aria-label":"Timing",children:[t.jsx(rr,{aside:nn(d),children:"Timing"}),t.jsx("div",{className:"flex h-2.5 gap-px bg-accent",role:"img","aria-label":l.map(u=>`${u.word} ${nn(u.ms)}`).join(", "),children:l.filter(u=>u.ms>0).map(u=>t.jsx("span",{className:ee("trace-mark min-w-0.5",u.tone),style:{width:`${d>0?u.ms/d*100:0}%`}},u.id))}),t.jsx("dl",{className:"mt-2",children:l.map(u=>t.jsxs("div",{className:"flex items-baseline justify-between gap-4 border-b py-1.5",children:[t.jsxs("dt",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 text-body",children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:u.tone}),u.word]}),u.to&&t.jsxs("button",{type:"button",className:"min-h-6 max-w-full truncate font-mono text-small text-muted-foreground underline underline-offset-2 hover:text-primary-text",onClick:()=>r(u.to.id),children:[u.about?`${u.about} `:"",u.to.name]})]}),t.jsx("dd",{className:"shrink-0 font-mono text-small",children:nn(u.ms)})]},u.id))})]})}function cB({span:e,trace:n,run:s,from:r,now:o,reveal:i,onPick:l,onClose:d}){var O;const[u,f]=g.useState("input"),[h,v]=g.useState(!1);g.useEffect(()=>{if(!h)return;const T=setTimeout(()=>v(!1),1500);return()=>clearTimeout(T)},[h]);const b=T=>{var M;(M=navigator.clipboard)==null||M.writeText(T).then(()=>v(!0),()=>{})},m=g.useRef(null);g.useEffect(()=>{var T,M;i&&m.current&&m.current.getBoundingClientRect().top>globalThis.innerHeight-80&&((M=(T=m.current).scrollIntoView)==null||M.call(T,{block:"start"}))},[]);const x=Vt(e,o),y=u==="input"?e.input_preview:e.result_preview,j=e.parent_id?n.spans.find(T=>T.id===e.parent_id):void 0,k=n.spans.filter(T=>T.parent_id===e.id),C=e.tokens,N=C?pu(C):null,S=(O=s.cost)==null?void 0:O.usd,E=e.usd!==null&&typeof S=="number"&&S>0?`${zs(Math.min(1,e.usd/S))} of the run`:null,$=C&&e.ended_at&&x?Math.round(C.output/(x/1e3)):null,L=C?[["Input, not cached",C.input,Gr.fresh],["Cache read",C.cache_read,Gr.read],["Cache write",C.cache_write,Gr.write],["Output",C.output,Gr.output]]:[],A=C?os(C)+C.output:0,P=[[e.kind==="model"?"Model":"Tool",e.name],...e.agent_label?[["Subagent",e.agent_label]]:[],...e.stop_reason?[["Stop reason",e.stop_reason]]:[],["Started",`${m1(e.started_at)} · ${wo(Date.parse(e.started_at)-r)}`],["Ended",e.ended_at?m1(e.ended_at):e.status==="running"?"Still running":e.status==="waiting"?"Waiting for a person":"Not recorded"],...$!==null&&C&&C.output>0?[["Output speed",`${$.toLocaleString("en-US")} tokens/s`]]:[],...(C==null?void 0:C.reasoning)!==void 0?[["Thinking tokens",`${C.reasoning.toLocaleString("en-US")} of the output`]]:[],...e.tool_use_id?[["Call id",e.tool_use_id]]:[],["Span",e.id]];return t.jsxs("aside",{ref:m,"aria-label":"Call details",onKeyDown:T=>{T.key==="Escape"&&(T.stopPropagation(),d())},className:"relative border-t bg-card p-5 xl:w-2/5 xl:max-w-lg xl:shrink-0 xl:overflow-auto xl:border-l xl:border-t-0",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(ke,{children:[t.jsx(Jr,{className:e.kind==="model"?"bg-trace-model":"bg-trace-tool"}),e.decision?"Decision":e.kind==="model"?"Model request":"Tool call"]}),t.jsx(ke,{tone:yl[e.status].tone,children:yl[e.status].word})]}),t.jsx("h2",{className:"mt-2 break-words font-mono text-lead font-semibold",children:e.name})]}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Close call details",onClick:d,children:t.jsx(Oo,{"aria-hidden":!0})})]}),t.jsx("dl",{className:"mt-4 grid grid-cols-3 border-l border-t",children:[["Duration",x!==null?nn(x):"–",e.ended_at?null:x!==null?"so far":"not recorded"],[e.kind==="model"?"Cost":"Charged",jb(e,n),E],e.kind==="model"?["Tokens",C?Jn(A):"–",C?`${Jn(os(C))} in · ${Jn(C.output)} out`:"none reported"]:["Result",e.result_size_bytes!==null?hr(e.result_size_bytes):"–",null]].map(([T,M,F])=>t.jsxs("div",{className:"min-w-0 border-b border-r p-2.5",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:T}),t.jsx("dd",{className:"mt-0.5 break-words font-mono text-base font-semibold",children:Id(M)}),F&&t.jsx("dd",{className:"text-label text-muted-foreground",children:F})]},T))}),t.jsx(lB,{span:e,trace:n,now:o,onPick:l}),e.kind==="model"&&t.jsxs("section",{className:"mt-5","aria-label":"Tokens",children:[t.jsx(rr,{aside:N!==null?`${zs(N)} of input from cache`:void 0,children:"Tokens"}),C?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-2.5 gap-px bg-accent",role:"img","aria-label":L.map(([T,M])=>`${T}: ${M.toLocaleString("en-US")} tokens`).join(", "),children:L.filter(([,T])=>T>0).map(([T,M,F])=>t.jsx("span",{title:`${T}: ${M.toLocaleString("en-US")}`,className:ee("trace-mark min-w-0.5",F),style:{width:`${M/A*100}%`}},T))}),t.jsxs("table",{className:"mt-2 w-full text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps border-b text-label text-muted-foreground",children:[t.jsx("th",{scope:"col",className:"py-1.5 text-left font-normal",children:"Line"}),t.jsx("th",{scope:"col",className:"py-1.5 text-right font-normal",children:"Tokens"}),t.jsx("th",{scope:"col",className:"py-1.5 pl-3 text-right font-normal",children:"Of input"})]})}),t.jsxs("tbody",{children:[L.map(([T,M,F])=>t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{scope:"row",className:"whitespace-nowrap py-1.5 text-left text-body font-normal",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:F}),T]})}),t.jsx("td",{className:"py-1.5 text-right font-mono",children:M.toLocaleString("en-US")}),t.jsx("td",{className:"py-1.5 pl-3 text-right font-mono text-muted-foreground",children:T!=="Output"&&os(C)>0?zs(M/os(C)):sr})]},T)),t.jsxs("tr",{className:"font-semibold",children:[t.jsx("th",{scope:"row",className:"py-1.5 text-left text-body font-semibold",children:"This request"}),t.jsx("td",{className:"py-1.5 text-right font-mono",children:A.toLocaleString("en-US")}),t.jsx("td",{className:"py-1.5 pl-3 text-right font-mono",children:jb(e,n)})]})]})]})]}):t.jsxs("p",{className:"text-body text-muted-foreground",children:["This request reported no tokens",e.status==="interrupted"?": it was cut before its end":"","."]}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:e.usd!==null?"The cost is what the run recorded for this request: one figure for all its tokens.":n.model_requests==="tokens_only"&&!e.decision?"This run's cost is booked for the whole run, so this request carries tokens only.":e.decision?"This decision's cost is unknown: its receipt keeps none.":"This request's cost is unknown: it was cut before its end, or its model has no price here."})]}),e.kind==="tool"&&t.jsxs("section",{className:"mt-5","aria-label":"Cost",children:[t.jsx(rr,{children:"Cost"}),t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.charged?`${e.usd!==null?as(e.usd):"An unknown amount"} was charged under this call, and is in the run's cost.`:e.not_metered?"This tool has no price set, so the call ran outside the run's cost.":"Nothing was charged under this call.",s.computer?" Time on the run's computer is billed by its provider and is not metered here.":""]})]}),t.jsxs("section",{className:"mt-5","aria-label":"Details",children:[t.jsx(rr,{children:"Details"}),t.jsxs("dl",{children:[j&&t.jsxs("div",{className:"flex items-center justify-between gap-4 border-b py-1.5",children:[t.jsx("dt",{className:"shrink-0 text-body text-muted-foreground",children:e.kind==="model"?"Started by":"Called by"}),t.jsx("dd",{className:"min-w-0",children:t.jsxs("button",{type:"button",className:"-my-1 min-h-6 max-w-full truncate py-1 font-mono text-small underline underline-offset-2 hover:text-primary-text",onClick:()=>l(j.id),children:[j.name," · ",wo(Date.parse(j.started_at)-r)]})})]}),P.map(([T,M])=>t.jsxs("div",{className:"flex justify-between gap-4 border-b py-1.5",children:[t.jsx("dt",{className:"shrink-0 text-body text-muted-foreground",children:T}),t.jsx("dd",{className:"min-w-0 break-words text-right font-mono text-small",children:M})]},T))]})]}),k.length>0&&t.jsxs("section",{className:"mt-5","aria-label":e.kind==="model"?"Calls it made":"What ran under it",children:[t.jsx(rr,{aside:String(k.length),children:e.kind==="model"?"Calls it made":"What ran under it"}),t.jsx("ul",{children:k.slice(0,12).map(T=>t.jsx("li",{className:"border-b",children:t.jsxs("button",{type:"button",className:"flex min-h-6 w-full items-center gap-2 py-1.5 text-left font-mono text-small hover:bg-accent",onClick:()=>l(T.id),children:[t.jsx(Jr,{className:Md(T)}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:Vt(T,o)!==null?nn(Vt(T,o)):yl[T.status].word})]})},T.id))}),k.length>12&&t.jsxs("p",{className:"mt-1.5 text-small text-muted-foreground",children:["And ",k.length-12," more: filter the table by name to find them."]})]}),e.kind==="tool"&&t.jsxs("section",{className:"mt-5","aria-label":"Arguments and result",children:[t.jsx(av,{id:"span-text",label:"Arguments and result",className:"px-0 md:px-0",value:u,onChange:f,tabs:[{id:"input",label:"Arguments"},{id:"output",label:"Result"}]}),t.jsxs("div",{...ld("span-text",u),children:[y?t.jsx("pre",{tabIndex:0,role:"region","aria-label":u==="input"?"The call's arguments":"The head of the call's result",className:"mt-3 max-h-64 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:y}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:u==="input"?"The call took no arguments.":e.status==="running"||e.status==="waiting"?"No result yet.":"The call returned nothing to show."}),t.jsxs("div",{className:"mt-2 flex items-start justify-between gap-3",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:["The Timeline's own cut of the call: its head, with secrets removed.",u==="output"&&e.result_size_bytes!==null?` The whole result was ${hr(e.result_size_bytes)}.`:""]}),y&&t.jsx(W,{size:"xs",variant:"ghost",className:"shrink-0",onClick:()=>b(y),children:h?"Copied":"Copy"})]})]})]})]})}const Fm=["bg-trace-model",`bg-trace-model ${Xl}`,WE],p1=["bg-trace-tool",`bg-trace-tool ${Xl}`,"border border-trace-tool bg-trace-tool/30"],dB="border border-trace-tool bg-card";function uB(e){const n={tokens:0,tools:0};return e.map(s=>{const r=s.meter==="browser_time"||s.meter==="compute_time"?dB:s.meter==="tokens"?Fm[Math.min(n.tokens++,Fm.length-1)]:p1[Math.min(n.tools++,p1.length-1)];return{word:PE(s),tone:r,n:s.usd??s.so_far_usd??0,says:$y(s)}})}const fB={running:"Cost by line appears when the run ends.",not_booked:"This run's cost is its harness's own figure, so it can't be split by line.",reopened:"A follow-up reopened this learning run, so its cost can't be split by round."};function mB({lines:e}){const n="caps whitespace-nowrap py-1.5 pl-3 text-right text-label font-normal text-muted-foreground first:pl-0 first:text-left",s=g.useId();return t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"caps mb-1 text-label font-semibold text-muted-foreground",id:s,children:"Cost by line"}),t.jsx("div",{className:"overflow-x-auto",tabIndex:0,role:"region","aria-labelledby":s,children:t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b",children:["Line","Quantity","Cost","Basis"].map(r=>t.jsx("th",{scope:"col",className:n,children:r},r))})}),t.jsx("tbody",{children:e.map((r,o)=>{const i=Z7(r),l=r.meter==="tokens"?`Tokens${r.provider?` · sent to ${r.provider}`:""}`:r.meter==="tools"?"Tool charges":r.meter==="compute_time"?"Computer time":"Browser time";return t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("th",{scope:"row",className:"py-1.5 text-left font-normal",children:[t.jsx("span",{className:"block font-mono",children:PE(r)}),t.jsx("span",{className:"block text-muted-foreground",children:l}),i.map(d=>t.jsx("span",{className:"block text-muted-foreground",children:d},d))]}),t.jsx("td",{className:"whitespace-nowrap py-1.5 pl-3 text-right align-top font-mono",children:Id(DE(r))}),t.jsx("td",{className:"whitespace-nowrap py-1.5 pl-3 text-right align-top font-mono",children:$y(r)}),t.jsx("td",{className:"whitespace-nowrap py-1.5 pl-3 text-right align-top text-muted-foreground",children:X7[r.basis]})]},o)})})]})})]})}function kb({label:e,parts:n,whole:s,say:r}){const o=n.filter(l=>l.n>0),i=l=>l.says??r(l.n);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-3 gap-px bg-accent",role:"img","aria-label":`${e}: ${o.map(l=>`${l.word} ${i(l)}`).join(", ")}`,children:o.map((l,d)=>t.jsx("span",{className:ee("trace-mark min-w-0.5",l.tone),style:{width:`${l.n/Math.max(s,Number.MIN_VALUE)*100}%`}},`${d}:${l.word}`))}),t.jsx("ul",{className:"mt-3 flex flex-wrap gap-x-6 gap-y-1.5 text-small",children:o.map((l,d)=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:l.tone}),l.word,t.jsxs("span",{className:"font-mono text-muted-foreground",children:[i(l)," · ",zs(s>0?l.n/s:0)]})]},`${d}:${l.word}`))})]})}function HE({usage:e,lines:n}){const s=uB(n),r=s.reduce((i,l)=>i+l.n,0),o=n.length>0&&n.every(i=>i.usd===0);return t.jsxs(t.Fragment,{children:[t.jsx(rr,{level:"h2",aside:e.total?$y(e.total):void 0,children:"Where the cost went"}),n.length===0?t.jsx("p",{className:"text-body text-muted-foreground",children:"This run booked no cost."}):r>0?t.jsx(kb,{label:"Where the cost went",whole:r,say:as,parts:s}):t.jsx("p",{className:"text-body text-muted-foreground",children:o?"Every line of this run's cost was $0.":"No line of this run's cost is known yet."}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:"The run's cost as the server booked it: a line for each model, each vendor that charged for a tool, and each browser provider."}),n.length>0&&t.jsx(mB,{lines:n})]})}function hB({trace:e,usage:n,now:s,onPick:r,selected:o}){var E;const i=g.useMemo(()=>_y(e,s),[e,s]),l=g.useMemo(()=>G7(e.spans,s),[e,s]),d=g.useMemo(()=>K7(e.spans,e.model_requests==="priced"),[e]),u=g.useMemo(()=>eB(e,s),[e,s]),f=g.useMemo(()=>Y7(e.spans),[e]),h=g.useMemo(()=>nB(e.spans,s),[e,s]),v=[...h.firstAnswer?[{label:"First answer",value:nn(h.firstAnswer.ms),note:h.firstAnswer.span.name,span:h.firstAnswer.span.id}]:[],...h.firstCall?[{label:"First tool call",value:nn(h.firstCall.ms),note:h.firstCall.span.name,span:h.firstCall.span.id}]:[],...h.largestInput?[{label:"Largest input",value:`${Jn(h.largestInput.tokens)} tokens`,note:`Request ${h.largestInput.nth} of ${h.largestInput.of}`,span:h.largestInput.span.id}]:[],...h.atOnce?[{label:"Most calls at once",value:String(h.atOnce.calls),note:`First at ${wo(h.atOnce.at)}`}]:[],...h.longestPause?[{label:"Longest pause",value:nn(h.longestPause.ms),note:`After ${h.longestPause.after.name}`,span:h.longestPause.after.id}]:[]],[b,m]=g.useState("input"),x=e.spans.filter($=>$.kind==="model"&&$.tokens),y=x.some($=>$.usd!==null),j=b==="cost"&&y?"cost":"input",k=Math.max(0,...x.map($=>j==="cost"?$.usd??0:os($.tokens))),C=Math.max(1,...l.map($=>$.totalMs)),N="caps whitespace-nowrap px-3 py-2 text-right text-label font-normal text-muted-foreground first:text-left",S="whitespace-nowrap px-3 py-2 text-right font-mono";return t.jsxs("div",{className:"space-y-6",children:[v.length>0&&t.jsxs("section",{"aria-label":"Run vitals",children:[t.jsx(rr,{level:"h2",aside:"from the start of the first request",children:"Run vitals"}),t.jsx("ul",{className:ee("grid grid-cols-2 border-l border-t sm:grid-cols-3",o?"2xl:grid-cols-5":"xl:grid-cols-5"),children:v.map($=>{const L=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"caps block text-label text-muted-foreground",children:$.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-lg font-semibold",children:$.value}),t.jsx("span",{className:"mt-0.5 block break-words text-small text-muted-foreground",children:$.note})]});return t.jsx("li",{className:"min-w-0 border-b border-r bg-card",children:$.span?t.jsx("button",{type:"button","aria-pressed":$.span===o,onClick:()=>r($.span),className:ee("block h-full w-full p-3 text-left -outline-offset-2 hover:bg-accent",$.span===o&&"bg-accent"),children:L}):t.jsx("div",{className:"p-3",children:L})},$.label)})}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:"A pause is a stretch with no model answering and no tool running: the run waiting for a person or its turn, or its harness working."})]}),u.length>0&&t.jsxs("section",{"aria-label":"What stands out",children:[t.jsx(rr,{level:"h2",children:"What stands out"}),t.jsx("ul",{className:"grid border-l border-t sm:grid-cols-2 2xl:grid-cols-3",children:u.map($=>{const L=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ee("block text-body font-semibold",$.bad&&"text-destructive-text"),children:$.title}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:$.detail})]});return t.jsx("li",{className:"border-b border-r bg-card",children:$.span?t.jsx("button",{type:"button","aria-pressed":$.span===o,onClick:()=>r($.span),className:ee("block h-full w-full p-3 text-left -outline-offset-2 hover:bg-accent",$.span===o&&"bg-accent"),children:L}):t.jsx("div",{className:"p-3",children:L})},$.id)})})]}),t.jsxs("div",{className:"grid gap-6 2xl:grid-cols-2",children:[t.jsxs("section",{"aria-label":"Where the time went",className:"border bg-card p-4",children:[t.jsx(rr,{level:"h2",aside:nn(i.time.wall),children:"Where the time went"}),t.jsx(kb,{label:"Where the time went",whole:i.time.wall,say:nn,parts:[{word:"A model answering",tone:"bg-trace-model",n:i.time.model},{word:"A tool running",tone:"bg-trace-tool",n:i.time.tools},{word:"Neither",tone:"bg-border-strong",n:i.time.other}]}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:'Each moment is counted once. "Neither" is the time between calls: the run waiting for a person or its turn, or its harness working.'})]}),t.jsx("section",{"aria-label":"Where the cost went",className:"border bg-card p-4",children:n!=null&&n.lines?t.jsx(HE,{usage:n,lines:n.lines}):t.jsxs(t.Fragment,{children:[t.jsx(rr,{level:"h2",aside:f?as(f.total):void 0,children:"Where the cost went"}),f&&f.total===0?t.jsx("p",{className:"text-body text-muted-foreground",children:"Everything this trace knows the cost of was $0."}):f?t.jsx(kb,{label:"Where the cost went",whole:f.total,say:as,parts:f.parts.map(($,L)=>({word:$.name,tone:$.kind==="tool"?"bg-trace-tool":Fm[Math.min(L,Fm.length-1)],n:$.usd}))}):t.jsx("p",{className:"text-body text-muted-foreground",children:e.model_requests==="priced"?"Nothing in this trace has a known cost yet.":"This run's cost is booked for the run as a whole: its trace carries no cost for each request."}),f&&f.total>0&&t.jsxs("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:["What the trace knows the cost of: each model's requests, and each charge under a call.",(E=i.cost.requests)!=null&&E.unknown?` ${i.cost.requests.unknown} request${i.cost.requests.unknown===1?" has":"s have"} no known cost and ${i.cost.requests.unknown===1?"is":"are"} not in it.`:""]}),(n==null?void 0:n.reason)&&t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:fB[n.reason]})]})})]}),x.length>0&&t.jsxs("section",{"aria-label":"Each request",className:"border bg-card p-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Each request, in the order they ran"}),y&&t.jsx(eo,{name:"trace-chart",label:"What a bar's height is",size:"sm",value:j,onChange:m,options:[{value:"input",label:"Input tokens"},{value:"cost",label:"Cost"}]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsx("div",{className:"flex h-32 min-w-full items-end gap-px border-b",role:"group","aria-label":j==="cost"?"Each request's cost":"Each request's input tokens",children:x.map($=>{const L=$.tokens,A=j==="cost"?$.usd??0:os(L),P=j==="cost"?null:L,O=j==="cost"?`${$.name}: ${$.usd!==null?as($.usd):"cost unknown"}`:`${$.name}: ${A.toLocaleString("en-US")} input tokens, ${zs(pu(L)??0)} from cache`;return t.jsx("button",{type:"button","aria-pressed":$.id===o,onClick:()=>r($.id),title:O,"aria-label":O,className:ee("flex min-w-1 max-w-24 flex-1 flex-col-reverse hover:opacity-80",$.id===o&&"ring-2 ring-foreground ring-offset-1 ring-offset-card"),style:{height:`${k>0?Math.max(2,A/k*100):2}%`},children:P?[[P.cache_read,Gr.read],[P.cache_write,Gr.write],[P.input,Gr.fresh]].map(([T,M])=>T>0&&t.jsx("span",{className:ee("trace-mark",M),style:{flexGrow:T}},M)):t.jsx("span",{className:"trace-mark flex-1 bg-trace-model"})},$.id)})})}),t.jsxs("div",{className:"mt-2 flex justify-between font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:"first request"}),t.jsxs("span",{children:["tallest: ",j==="cost"?as(k):`${Jn(k)} tokens`]}),t.jsx("span",{children:"last request"})]}),j==="input"&&t.jsxs("ul",{className:"mt-3 flex flex-wrap gap-x-6 gap-y-1.5 text-small",children:[t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:Gr.read}),"Read from cache"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:Gr.write}),"Written to cache"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Jr,{className:Gr.fresh}),"Not cached"]})]}),t.jsx("p",{className:"mt-2 max-w-prose text-small text-muted-foreground",children:j==="cost"?"One bar a request: its height is what the run booked for it.":"One bar a request: its height is the input it sent. A run that caches well reads most of each request from cache and writes only what is new."})]}),d.length>0&&t.jsxs("section",{"aria-label":"By model",children:[t.jsx(rr,{level:"h2",children:"By model"}),t.jsx("div",{className:"overflow-x-auto border bg-card",tabIndex:0,role:"region","aria-label":"Requests by model",children:t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b",children:["Model","Requests","Failed","Input","From cache","Output","Tokens/s","Median time","95th","Total time","Cost"].map($=>t.jsx("th",{scope:"col",className:N,children:$},$))})}),t.jsx("tbody",{children:d.map($=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-mono font-normal",children:$.name}),t.jsx("td",{className:S,children:$.requests}),t.jsx("td",{className:ee(S,$.failed>0&&"text-destructive-text"),children:$.failed}),t.jsx("td",{className:S,children:Jn($.tokens.input+$.tokens.cache_read+$.tokens.cache_write)}),t.jsx("td",{className:S,children:$.cache!==null?zs($.cache):sr}),t.jsx("td",{className:S,children:Jn($.tokens.output)}),t.jsx("td",{className:S,children:$.perSecond!==null?Math.round($.perSecond).toLocaleString("en-US"):sr}),t.jsx("td",{className:S,children:$.p50!==null?nn($.p50):sr}),t.jsx("td",{className:S,children:$.p95!==null?nn($.p95):sr}),t.jsx("td",{className:S,children:nn($.totalMs)}),t.jsx("td",{className:S,children:$.cost?gd($.cost):sr})]},$.name))})]})})]}),l.length>0&&t.jsxs("section",{"aria-label":"By tool",children:[t.jsx(rr,{level:"h2",aside:"the tool that took the most time first",children:"By tool"}),t.jsx("div",{className:"overflow-x-auto border bg-card",tabIndex:0,role:"region","aria-label":"Calls by tool",children:t.jsxs("table",{className:"w-full text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b",children:["Tool","Calls","Failed","Total time","Median","95th","Longest","Charged","Returned"].map($=>t.jsx("th",{scope:"col",className:N,children:$},$))})}),t.jsx("tbody",{children:l.map($=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-mono font-normal",children:$.name}),t.jsx("td",{className:S,children:$.calls}),t.jsx("td",{className:ee(S,$.failed>0&&"text-destructive-text"),children:$.failed}),t.jsx("td",{className:S,children:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-16 bg-accent",children:t.jsx("span",{className:"trace-mark block h-full bg-trace-tool",style:{width:`${$.totalMs/C*100}%`}})}),nn($.totalMs)]})}),t.jsx("td",{className:S,children:$.p50!==null?nn($.p50):sr}),t.jsx("td",{className:S,children:$.p95!==null?nn($.p95):sr}),t.jsx("td",{className:S,children:$.maxMs!==null?nn($.maxMs):sr}),t.jsx("td",{className:S,children:$.charged>0?gd($.charges):sr}),t.jsx("td",{className:S,children:hr($.bytes)})]},$.name))})]})})]})]})}const fx=300,pB=[{id:"started",label:"Started"},{id:"duration",label:"Duration",right:!0},{id:"tokens",label:"Size",right:!0},{id:"cost",label:"Cost",right:!0}],qf="relative bg-card px-3 py-2 after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border xl:sticky xl:-top-6 xl:z-raised";function gB({run:e,read:n,readUsage:s,version:r,live:o,panel:i,now:l,open:d=null,view:u="calls"}){var qt,At,Et;const{trace:f,error:h,retry:v}=sB(n,r),b=s&&(()=>s().then(B=>({got:B,at:r}))),{got:m}=FE(b,r),x=m&&m.at===r?m.got:null,y=!Co(e.status)&&!!(f!=null&&f.spans.some(B=>B.status==="running"||B.status==="waiting")),j=rB(y,l),k=l??(Co(e.status)&&e.ended_at?Date.parse(e.ended_at):j),[C,N]=g.useState(d),[S,E]=g.useState(u),[$,L]=g.useState("all"),[A,P]=g.useState(""),[O,T]=g.useState("started"),[M,F]=g.useState(il),[I,V]=g.useState(!1),[G,q]=g.useState(!1),[H,U]=g.useState(null),Q=g.useRef(null),D=g.useRef(new Map),Y=g.useId(),K=(f==null?void 0:f.spans)??[],Z=g.useMemo(()=>Ld(K,k),[K,k]),se=g.useMemo(()=>f?_y(f,k):null,[f,k]),ie=g.useMemo(()=>({model:a1(K.filter(B=>B.kind==="model"),Z,k),tool:a1(K.filter(B=>B.kind==="tool"),Z,k)}),[K,Z,k]),Ne=g.useMemo(()=>i1(Z.ms,8),[Z.ms]),he=(M.to-M.from)*Z.ms,ve=g.useMemo(()=>i1(he,4,M.from*Z.ms),[he,M.from,Z.ms]),Ee=g.useMemo(()=>V7(K.filter(B=>ux(B,$,A)&&(M===il||d1(B,Z,M,k).off===null)),O,k),[K,$,A,O,k,M,Z]),ye=g.useMemo(()=>{const B=new Map(K.map(de=>[de.id,de])),J=(de,_e=0)=>de.parent_id&&B.has(de.parent_id)&&_e<4?1+J(B.get(de.parent_id),_e+1):0;return new Map(K.map(de=>[de.id,J(de)]))},[K]);if(!n)return null;if(!f)return t.jsx("div",{...i,className:"px-5 py-8 md:px-8",children:h?t.jsx(ct,{tone:"error",title:"The trace could not be read",actions:t.jsx(W,{size:"xs",onClick:v,children:"Try again"}),children:t.jsx("p",{className:"font-mono text-small",children:aB(h)})}):t.jsxs("p",{className:"flex items-center gap-3 font-mono text-body text-muted-foreground",children:[t.jsx(ov,{}),"Reading the trace"]})});const pe=C?K.find(B=>B.id===C)??null:null,Pe=I?Ee:Ee.slice(0,fx),ue=(H!==null&&Pe.some(B=>B.id===H)?H:pe&&Pe.some(B=>B.id===pe.id)?pe.id:(qt=Pe[0])==null?void 0:qt.id)??null,ge=B=>{var J;return((J=D.current.get(B))==null?void 0:J.querySelector("button"))??null},Te=()=>{const B=document.activeElement;B instanceof HTMLElement&&B!==document.body&&!B.closest("aside")&&(Q.current=B)},Xe=B=>{Te(),q(!0),N(B)},je=B=>{var J,de;Q.current=ge(B)??Q.current,q(!1),N(B),U(B),(de=(J=D.current.get(B))==null?void 0:J.scrollIntoView)==null||de.call(J,{block:"nearest"})},fe=()=>{var B;N(null),(B=Q.current)!=null&&B.isConnected&&Q.current.focus()},De=B=>`${f1[B.kind]} ${B.name}, ${yl[B.status].word.toLowerCase()}, ${Vt(B,k)!==null?nn(Vt(B,k)):"no duration"}, at ${wo(Date.parse(B.started_at)-Z.from)}`,te=B=>{if(B.key==="Escape"&&pe){B.preventDefault(),Q.current=ge(ue??"")??Q.current,fe();return}const J=B.key==="ArrowDown"?1:B.key==="ArrowUp"?-1:B.key==="PageDown"?10:B.key==="PageUp"?-10:B.key==="Home"?-Pe.length:B.key==="End"?Pe.length:0;if(!J||!Pe.length)return;B.preventDefault();const de=Math.max(0,Pe.findIndex(qe=>qe.id===ue)),_e=Pe[Math.min(Pe.length-1,Math.max(0,de+J))];U(_e.id);const at=ge(_e.id);at==null||at.focus(),pe&&(Q.current=at??Q.current,q(!1),N(_e.id))},Ie=()=>{const B=URL.createObjectURL(new Blob([JSON.stringify(f,null,2)],{type:"application/json"}));Object.assign(document.createElement("a"),{href:B,download:`trace-${e.run_id}.json`}).click(),URL.revokeObjectURL(B)},We=((At=e.cost)==null?void 0:At.usd)??null,rt=vi(e.cost),ot=[...new Set(K.filter(B=>B.kind==="model").map(B=>B.name))],wt=new Set(K.filter(B=>B.kind==="tool").map(B=>B.name)),jt=K.find(B=>B.status==="failed"),we={all:K.length,model:se.requests,tool:se.calls,failed:se.failed},ze=se.tokens?pu(se.tokens):null,st=pe?"md:max-xl:table-cell @4xl:table-cell":"md:table-cell",xe=pe?"hidden max-xl:table-cell @5xl:table-cell":"",Be=pe?"w-full md:max-xl:w-[30%] @4xl:w-[30%]":"w-full md:w-[30%]",$t=se.cost.requests,et=M!==il,dt=$!=="all"||A.trim()!==""||et,Lt=pe&&Z.ms>0?(Date.parse(pe.started_at)+(Vt(pe,k)??0)/2-Z.from)/Z.ms:void 0;return t.jsxs("div",{...i,"data-scroll-pane":!0,className:"relative min-h-0 flex-1 overflow-auto xl:flex xl:overflow-hidden short:flex-none short:overflow-visible",children:[t.jsxs("section",{"aria-label":"Trace",className:"relative min-w-0 space-y-4 px-5 py-6 @container md:px-8 xl:min-h-0 xl:flex-1 xl:overflow-auto",children:[f.model_requests==="not_recorded"&&t.jsx(ct,{tone:"info",title:"This run's harness keeps no record of each model request",children:"The trace shows its tool calls. The run's cost and how many requests it made are on its Timeline's usage line."}),f.dropped>0&&t.jsxs(ct,{tone:"warning",children:["This is the run's first ",K.length.toLocaleString("en-US")," requests and calls. ",f.dropped.toLocaleString("en-US")," later ones are not shown."]}),t.jsxs("dl",{"aria-label":"The run in figures",className:ee("grid grid-cols-2 border-l border-t bg-card sm:grid-cols-3",pe?"2xl:grid-cols-6":"xl:grid-cols-6"),children:[t.jsx(Zi,{label:"Model requests",value:f.model_requests==="not_recorded"?"–":se.requests,note:f.model_requests==="not_recorded"?"Not kept by this harness":ot.length===1?ot[0]:ot.length?`${ot.length} models`:"None yet"}),t.jsx(Zi,{label:"Tool calls",value:se.calls,note:wt.size===1?"1 tool":`${wt.size} tools`}),t.jsx(Zi,{label:"Failed",value:se.failed,tone:se.failed>0?"bad":void 0,note:jt?`First: ${jt.name}`:"Nothing failed"}),t.jsx(Zi,{label:"Tokens",value:se.tokens?Jn(os(se.tokens)+se.tokens.output):"–",note:se.tokens?`${ze!==null?`${zs(ze)} of input read from cache`:"No input reported"}${se.untold?` · ${se.untold} request${se.untold===1?"":"s"} reported none`:""}`:"No request to count"}),t.jsx(Zi,{label:We===null&&rt?"Cost so far":e.cost&&HI(e.cost)?"Cost, estimated":"Cost",value:typeof We=="number"?as(We):rt?as(rt.so_far_usd):"Unknown",note:$t?`requests ${gd($t)}${se.cost.charged?` · tools ${gd(se.cost.charges)}`:""}`:se.cost.charged?`tools ${gd(se.cost.charges)}`:"Booked for the run as a whole"}),t.jsx(Zi,{label:"Time",value:nn(se.time.wall),note:se.time.wall>0?`model ${zs(se.time.model/se.time.wall)} · tools ${zs(se.time.tools/se.time.wall)}`:"Nothing ran yet"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(eo,{name:"trace-view",label:"What the tab shows",size:"sm",value:S,onChange:E,options:[{value:"calls",label:"Calls"},{value:"breakdown",label:"Breakdown"}]}),S==="calls"&&K.length>0&&t.jsx(cu,{value:A,onChange:P,label:"Filter calls",placeholder:"Filter by tool, model or arguments",shown:Ee.length,total:K.length,active:dt,className:"flex-1 gap-2",children:t.jsx(eo,{name:"trace-kind",label:"Kind of call",size:"sm",value:$,onChange:L,options:[["all","All"],["model","Model"],["tool","Tools"],["failed","Failed"]].map(([B,J])=>({value:B,label:t.jsxs(t.Fragment,{children:[J," ",t.jsx("span",{className:"font-normal",children:we[B]})]})}))})}),t.jsxs(W,{size:"sm",className:"ml-auto",onClick:Ie,title:"Save the trace as the server sent it",children:[t.jsx(rm,{"aria-hidden":!0}),"Export JSON"]})]}),K.length===0?(Et=x==null?void 0:x.lines)!=null&&Et.length?t.jsx("section",{"aria-label":"Where the cost went",className:"border bg-card p-4",children:t.jsx(HE,{usage:x,lines:x.lines})}):t.jsx("p",{className:"border bg-card p-4 font-mono text-body text-muted-foreground",children:o?"No model request has answered and no tool has been called yet.":"This run made no model request and called no tool."}):S==="breakdown"?t.jsx(hB,{trace:f,usage:x,now:k,onPick:Xe,selected:(pe==null?void 0:pe.id)??null}):t.jsxs(t.Fragment,{children:[t.jsxs("section",{"aria-label":"Overview of the run",className:"border bg-card",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-1.5",children:[t.jsx("ul",{className:"flex flex-1 flex-wrap gap-x-4 gap-y-1 text-small text-muted-foreground","aria-label":"What a bar's colour says",children:[["bg-trace-model","Model request"],["bg-trace-tool","Tool call"],[`bg-destructive ${Xl}`,"Failed"],...K.some(B=>B.status==="running")?[["bg-run-active","Running"]]:[],...K.some(B=>B.status==="waiting")?[[UE,"Waiting for a person"]]:[],...K.some(B=>B.status==="refused"||B.status==="interrupted")?[["bg-muted-foreground","Refused or interrupted"]]:[]].map(([B,J])=>t.jsxs("li",{className:"flex items-center gap-1.5",children:[t.jsx(Jr,{className:B}),J]},J))}),t.jsxs("div",{role:"group","aria-label":"Zoom the table's time axis",className:"flex items-center gap-1",children:[t.jsx("p",{role:"status",className:"mr-1 font-mono text-small text-muted-foreground",children:et?`${wo(M.from*Z.ms)} to ${wo(M.to*Z.ms)}`:""}),et&&t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Earlier",title:"Earlier",disabled:M.from<=0,onClick:()=>F(B=>c1(B,-.5)),children:t.jsx(B1,{"aria-hidden":!0})}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Later",title:"Later",disabled:M.to>=1,onClick:()=>F(B=>c1(B,.5)),children:t.jsx(Es,{"aria-hidden":!0})})]}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Zoom out",title:"Zoom out",disabled:!et,onClick:()=>F(B=>l1(B,.5)),children:t.jsx(OA,{"aria-hidden":!0})}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Zoom in",title:"Zoom in",disabled:M.to-M.from<=1/64,onClick:()=>F(B=>l1(B,2,Lt)),children:t.jsx(AA,{"aria-hidden":!0})}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Fit the whole run",title:"Fit the whole run",disabled:!et,onClick:()=>F(il),children:t.jsx(J1,{"aria-hidden":!0})})]})]}),t.jsxs("div",{className:"px-4 pb-2 pt-3",role:"img","aria-label":`The run on a time axis: ${se.requests} model request${se.requests===1?"":"s"} and ${se.calls} tool call${se.calls===1?"":"s"} over ${nn(Z.ms)}. The table lists each.`,children:[t.jsxs(iB,{marks:Ne,view:M,onView:F,children:[f.model_requests!=="not_recorded"&&t.jsx(h1,{title:`Model requests (${se.requests})`,swatch:"bg-trace-model",...ie.model,selected:(pe==null?void 0:pe.id)??null,dimmed:B=>!ux(B,$,A),onPick:je,at:De}),t.jsx(h1,{title:`Tool calls (${se.calls})`,swatch:"bg-trace-tool",...ie.tool,selected:(pe==null?void 0:pe.id)??null,dimmed:B=>!ux(B,$,A),onPick:je,at:De})]}),t.jsx("div",{className:"relative mt-1.5 h-5 border-t",children:Ne.map(B=>t.jsx("span",{className:ee("absolute top-1 whitespace-nowrap font-mono text-label text-muted-foreground",B.left>94?"-translate-x-full pr-1":"pl-1"),style:{left:`${B.left}%`},children:B.label},B.left))})]})]}),t.jsxs("div",{className:"relative overflow-x-auto border bg-card xl:overflow-visible",children:[t.jsxs("table",{className:"w-full text-small",children:[t.jsx("caption",{className:"sr-only",children:"The run's model requests and tool calls. The arrow keys move from row to row; Enter opens a row's details."}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",className:ee(qf,"caps text-left text-label font-normal text-muted-foreground"),children:"Call"}),pB.map(B=>t.jsx("th",{scope:"col","aria-sort":O===B.id?B.id==="started"?"ascending":"descending":"none",className:ee(qf,"whitespace-nowrap",B.right?"text-right":"text-left",B.id==="tokens"&&xe),children:t.jsxs("button",{type:"button",onClick:()=>T(O===B.id?"started":B.id),title:B.id==="started"?"In the order they started":`Sort by ${B.label.toLowerCase()}, most first`,className:ee("caps -my-1.5 inline-flex min-h-6 items-center gap-1 py-1.5 text-label hover:text-foreground",O===B.id?"text-foreground":"text-muted-foreground"),children:[B.label,O===B.id&&B.id!=="started"&&t.jsx(eA,{className:"size-3","aria-hidden":!0})]})},B.id)).flatMap((B,J)=>J===0?[B,t.jsxs("th",{scope:"col","data-axis":!0,className:ee(qf,"hidden w-[30%] min-w-56",st),children:[t.jsx("span",{className:"sr-only",children:"On the time axis"}),t.jsx("span",{"aria-hidden":!0,className:"relative block h-4 overflow-hidden",children:ve.map(de=>t.jsx("span",{className:ee("absolute top-0 whitespace-nowrap font-mono text-label font-normal text-muted-foreground",de.left>85?"-translate-x-full pr-1":"pl-1"),style:{left:`${de.left}%`},children:de.label},de.left))})]},"axis")]:[B]),t.jsx("th",{scope:"col",className:ee(qf,"caps text-left text-label font-normal text-muted-foreground"),children:"Status"})]})}),t.jsx("tbody",{onKeyDown:te,children:Pe.map((B,J)=>{const de=Vt(B,k),_e=O==="started"?Math.min(2,ye.get(B.id)??0):0,at=d1(B,Z,M,k);return t.jsxs("tr",{ref:qe=>{qe?D.current.set(B.id,qe):D.current.delete(B.id)},onClick:()=>Xe(B.id),className:ee("cursor-pointer border-b last:border-b-0 hover:bg-accent",B.id===(pe==null?void 0:pe.id)&&"bg-accent"),children:[t.jsx("td",{className:ee("min-w-48 max-w-0 overflow-hidden py-0 pl-1 pr-3",Be),children:t.jsxs("button",{type:"button",tabIndex:B.id===ue?0:-1,"aria-pressed":B.id===(pe==null?void 0:pe.id),"aria-describedby":`${Y}-d${J} ${Y}-s${J}`,onFocus:()=>U(B.id),className:ee("flex h-control-sm w-full min-w-0 items-center gap-2 text-left font-mono -outline-offset-2",_e===1&&"pl-4",_e===2&&"pl-8"),children:[t.jsx("span",{"aria-hidden":!0,className:ee("trace-mark h-4 w-1 shrink-0",Md(B))}),t.jsx("span",{className:"caps w-10 shrink-0 text-label text-muted-foreground",children:f1[B.kind]}),t.jsx("span",{className:"max-w-64 shrink-0 truncate",title:B.name,children:B.name}),(B.input_preview||B.agent_label)&&t.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[B.agent_label?`${B.agent_label} `:"",B.input_preview??""]})]})}),t.jsx("td",{className:"whitespace-nowrap px-3 font-mono text-muted-foreground",children:wo(Date.parse(B.started_at)-Z.from)}),t.jsx("td",{"aria-hidden":!0,"data-axis":!0,className:ee("hidden px-3 py-0",st),children:t.jsxs("span",{className:"relative block h-control-sm overflow-hidden",children:[ve.map(qe=>t.jsx("span",{className:"absolute inset-y-0 w-px bg-border",style:{left:`${qe.left}%`}},qe.left)),at.off===null&&t.jsx("span",{"data-bar":!0,className:ee("trace-mark absolute top-1/2 h-2.5 min-w-0.5 -translate-y-1/2",Md(B)),style:{left:`${at.left}%`,width:`${at.width}%`}})]})}),t.jsx("td",{id:`${Y}-d${J}`,className:"whitespace-nowrap px-3 text-right font-mono",children:de!==null?nn(de):sr}),t.jsx("td",{className:ee("whitespace-nowrap px-3 text-right font-mono text-muted-foreground",xe),children:Id(oB(B))}),t.jsx("td",{className:"whitespace-nowrap px-3 text-right font-mono",children:Id(jb(B,f))}),t.jsx("td",{id:`${Y}-s${J}`,className:"px-3",children:t.jsx(ke,{tone:yl[B.status].tone,children:yl[B.status].word})})]},B.id)})})]}),Ee.length===0&&t.jsx("p",{className:"p-4 text-body text-muted-foreground",children:et&&$==="all"&&A.trim()===""?`No call ran in this part of the run. Fit the whole run to see all ${K.length}.`:`No call matches. Clear the filter to see all ${K.length}.`}),!I&&Ee.length>fx&&t.jsxs("p",{className:"flex flex-wrap items-center gap-3 border-t p-3 text-body text-muted-foreground",children:["The first ",fx," of ",Ee.length.toLocaleString("en-US")," are listed. ",t.jsxs(W,{size:"xs",onClick:()=>V(!0),children:["Show all ",Ee.length.toLocaleString("en-US")]})]})]})]}),t.jsx("p",{role:"status",className:"sr-only",children:pe?`Details shown for ${pe.name}. Escape closes them.`:""})]}),pe&&t.jsx(cB,{span:pe,trace:f,run:e,from:Z.from,now:k,reveal:G,onPick:Xe,onClose:fe},pe.id)]})}function xB({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",Kl(e.runtime)],["Project",e.project],["Selector",Rv(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((l,d)=>t.jsx("td",{className:"px-2 py-2 font-mono",children:l==null?"Unknown":l.toLocaleString("en-US")},d)),t.jsx("td",{className:"px-2 py-2 font-mono",children:(o==null?void 0:o.cost_usd)==null?"Unknown":Qd(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 bB={seeded:"Prepared",reflecting:"Reflecting",merged:"Saved",dropped:"Not saved"};function vB({run:e,read:n,onViewChanges:s}){var x,y,j,k,C,N,S,E;const[r,o]=g.useState({data:void 0,reading:!0}),[i,l]=g.useState(0),d=g.useRef(n);d.current=n;const u=!!n,f=e.run_id,h=(x=e.learning)==null?void 0:x.state,v=(y=e.learning)==null?void 0:y.at;g.useEffect(()=>{let $=!0;if(!u){o({data:void 0,reading:!1});return}return o(L=>({...L,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(L=>{if(L&&L.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");$&&o({data:L,reading:!1})}).catch(L=>{$&&o(A=>({...A,error:L??new Error("The learning result could not be read."),reading:!1}))}),()=>{$=!1}},[f,h,v,u,i]),g.useEffect(()=>{const $=()=>{document.hidden||l(L=>L+1)};return window.addEventListener("focus",$),document.addEventListener("visibilitychange",$),()=>{window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[]);const b=r.data,m=()=>l($=>$+1);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"}),b&&t.jsx(ke,{children:bB[b.state]??b.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(So,{className:"size-3","aria-hidden":!0})]}),u&&t.jsx(W,{size:"icon","aria-label":"Refresh learning result",disabled:r.reading,onClick:m,children:t.jsx(pi,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:b===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[b!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(on,{problem:Yt(r.error,"the learning result"),onRetry:m,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&&b===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),b&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[b.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:b.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[b.at&&t.jsxs("span",{children:["Updated ",ht(b.at)]}),b.reason&&t.jsxs("span",{children:["Reason: ",b.reason]})]})]}),t.jsxs("section",{"aria-label":"What it kept",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"What it kept"}),(j=b.workflows)!=null&&j.length||b.corrections?t.jsxs("ul",{className:"divide-y border",children:[(k=b.workflows)==null?void 0:k.map($=>t.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 p-3",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:$.name}),t.jsx(ke,{tone:$.pending?"warning":"success",children:$.pending?"Waits for your OK":"Workflow"})]},$.file)),b.corrections>0&&t.jsxs("li",{className:"p-3 text-small",children:[zv(b.corrections)," added to corrections.md"]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:$h(b)?"Nothing kept yet.":"Nothing was kept from this run."})]}),t.jsxs("section",{"aria-label":"Learning validation",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Validation"}),(C=b.problems)!=null&&C.length||(N=b.draft_errors)!=null&&N.length?t.jsxs("ul",{className:"space-y-3",children:[(S=b.problems)==null?void 0:S.map(($,L)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:$.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[$.rule,$.path].filter(Boolean).join(" · ")})]},`problem-${L}`)),(E=b.draft_errors)==null?void 0:E.map(($,L)=>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:$})]},`draft-${L}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),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(W,{size:"sm",onClick:s,children:["View changes",t.jsx(So,{"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:b.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:b.merged??"Not merged"})]})]})]})]})]})}const g1=32,yB=360,wB=.7;function jB(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-g1;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-g1}const kB=(e,n)=>Math.round(Math.max(yB,Math.min(e,n*wB)));function NB(e,n,s=3e3,r=Math.min(s,SB),o=!1){const[i,l]=g.useState(null),[d,u]=g.useState(!1),f=g.useRef(e);f.current=e;const h=g.useRef(!1),v=g.useRef(!1),b=g.useRef(0),m=g.useRef(null),x=g.useRef(null),y=g.useRef(o);y.current=o,g.useEffect(()=>{o&&(x.current=null)},[o]);const j=!!e;g.useEffect(()=>{if(!j||d)return;if(n||(x.current=null),!n&&h.current&&!v.current){l(L=>L&&x1(L));return}let C=!0,N;const S=L=>{clearTimeout(N),N=setTimeout(()=>{m.current=null,$()},L),m.current=()=>S(r)};let E=!1;const $=async()=>{try{const L=await f.current();if(!C)return;h.current=!0,L.state==="live"&&!y.current&&(x.current=L.kind);const A=L.state==="none"&&L.session==="opening"&&L.kind!=="browser"&&L.kind===x.current?{...L,session:"closed"}:L;v.current=A.state==="none"&&A.session==="unopened",E=A.state==="none"&&A.session==="opening"||A.state==="live"&&A.hold==="pending",A.state==="off"?l(null):l(n?P=>_B(P,A)?P:A:x1(A))}catch(L){if(!C)return;if(L instanceof Ue&&L.status===401){u(!0),l(A=>A?{state:"signed_out"}:null);return}if(L instanceof Ue&&L.status===403){u(!0),l(null);return}}C&&n&&S(E||Date.now()<b.current?r:s)};return $(),()=>{C=!1,clearTimeout(N),m.current=null}},[j,n,s,r,d]);const k=g.useCallback(C=>{var N;l(S=>S&&S.state==="live"&&S.hold!==C?{...S,hold:C}:S),b.current=Date.now()+CB,(N=m.current)==null||N.call(m)},[]);return{view:i,held:k}}const SB=400,CB=4e3,_B=(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))},x1=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"},$B={browser:V1,desktop:hi,phone:eS,sandbox:TA},EB={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},TB={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function RB({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:l,keptUntil:d,onTake:u,onHand:f,recordings:h=[],fileUrl:v}){const b=g.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==b.current.viewer&&(b.current={viewer:n.viewer,n:b.current.n+1});const m=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",x=(n==null?void 0:n.state)==="live"?IB(n.viewer,e):void 0,y=x&&m!=="browser"?`${x}${x.includes("#")?"&":"#"}hands=page`:x,j=$B[m],k=(n==null?void 0:n.state)==="live"?n:null,[C,N]=g.useState(!1),[S,E]=g.useState(null),$=async he=>{if(!(!he||C)){N(!0),E(null);try{E(await he())}finally{N(!1)}}},L=k&&y&&m!=="browser"?k:null,[A,P]=g.useState(!1),O=g.useRef(null),T=g.useRef(null),M=g.useRef(null),F=g.useRef(!1),I=!!(k&&y);g.useEffect(()=>{I||P(!1)},[I]);const V=h.filter(he=>he.finished),[G,q]=g.useState(0),H=!r&&!k&&(n==null?void 0:n.state)!=="signed_out"&&v?V[Math.min(G,V.length-1)]:void 0,U=g.useRef(null),[Q,D]=g.useState(void 0),Y=I?"frame":H?"player":null;g.useLayoutEffect(()=>{const he=Y==="frame"?O.current:Y==="player"?U.current:null;if(m!=="phone"||A||!he)return;const ve=he.closest("[data-scroll-pane]"),Ee=()=>D(kB(jB(he,ve),window.innerHeight));Ee();const ye=typeof ResizeObserver=="function"&&ve?new ResizeObserver(Ee):void 0;if(ve)for(const pe of[ve,...ve.children])ye==null||ye.observe(pe);return window.addEventListener("resize",Ee),()=>{ye==null||ye.disconnect(),window.removeEventListener("resize",Ee)}},[m,A,Y,S,i,b.current.n]),g.useEffect(()=>{var he,ve,Ee;if(A){F.current=!0,(ve=(he=T.current)==null?void 0:he.querySelector("button"))==null||ve.focus();return}F.current&&(F.current=!1,(Ee=M.current)==null||Ee.focus())},[A]),g.useEffect(()=>{if(!A)return;const he=Pe=>{if(Pe.key==="Escape"){P(!1);return}if(Pe.key!=="Tab"||!T.current)return;const ue=[...T.current.querySelectorAll("button:not([disabled]), iframe")];if(!ue.length)return;const ge=ue[0],Te=ue[ue.length-1],Xe=document.activeElement;T.current.contains(Xe)?Pe.shiftKey&&Xe===ge?(Pe.preventDefault(),Te.focus()):!Pe.shiftKey&&Xe===Te&&(Pe.preventDefault(),ge.focus()):(Pe.preventDefault(),ge.focus())},ve=Pe=>{Pe.key==="Escape"&&P(!1)};document.addEventListener("keydown",he);const Ee=O.current;let ye=null;const pe=()=>{try{ye==null||ye.removeEventListener("keydown",ve,!0)}catch{}try{ye=(Ee==null?void 0:Ee.contentWindow)??null,ye==null||ye.addEventListener("keydown",ve,!0)}catch{ye=null}};return pe(),Ee==null||Ee.addEventListener("load",pe),()=>{document.removeEventListener("keydown",he),Ee==null||Ee.removeEventListener("load",pe);try{ye==null||ye.removeEventListener("keydown",ve,!0)}catch{}}},[A,b.current.n]);const K=m==="phone"?ee("mx-auto block aspect-[9/19] max-w-full bg-background",Q===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",Z=m==="phone"&&Q!==void 0?{height:`${Q}px`}:void 0,se=k?m==="browser"?"browser · take over in the view below":`${TB[k.hold]} · ${m}`:"",ie=L&&(L.hold==="person"?t.jsx(W,{size:"sm",variant:"solid",disabled:C,onClick:()=>void $(f),children:"Hand back"}):t.jsx(W,{size:"sm",variant:"solid",disabled:C||L.hold==="pending",onClick:()=>void $(u),children:L.hold==="pending"?"Taking over":"Take over"})),Ne=I&&t.jsx(W,{ref:A?void 0:M,size:"sm",variant:"ghost",onClick:()=>P(he=>!he),"aria-label":A?"Exit full window (Esc)":"Fill the window",title:A?"Exit full window (Esc)":"Fill the window","aria-pressed":A,children:A?t.jsx(bA,{className:"size-4","aria-hidden":!0}):t.jsx(J1,{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":EB[m]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:se}),h.some(he=>!he.finished)&&t.jsx(ke,{tone:"active",title:"A video of this screen is being recorded",children:"Recording"}),H&&V.length>1&&t.jsx(eo,{size:"sm",label:"Recording to play",name:`recording-${e}`,value:String(V.indexOf(H)),onChange:he=>q(Number(he)),options:V.map((he,ve)=>({value:String(ve),label:String(ve+1),title:he.path}))}),v&&h.filter(he=>he.finished).map((he,ve,Ee)=>t.jsxs("a",{href:`${v(he.path)}?download=1`,download:!0,className:Fs({variant:"ghost",size:"sm"}),"aria-label":`Export ${he.path} (${hr(he.bytes)})`,children:[t.jsx(rm,{"aria-hidden":!0})," Export",Ee.length>1?` ${ve+1}`:""]},he.path)),!A&&Ne,!A&&ie]}),i&&m!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:ry}),!A&&S&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:S}),k&&y?t.jsxs("div",{ref:T,"data-testid":"screen-frame",className:A?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:A?"dialog":void 0,"aria-modal":A?!0:void 0,"aria-label":A?"The run's screen, filling the window":void 0,children:[A&&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:se}),Ne,ie]}),A&&S&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:S}),t.jsx("iframe",{ref:O,src:y,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:A?"block min-h-0 w-full flex-1 bg-background":K,style:A?void 0:Z},b.current.n)]}):H&&v?t.jsx("video",{ref:U,src:v(H.path),controls:!0,muted:!0,playsInline:!0,preload:"metadata","aria-label":`The run's recording, ${H.path}`,className:K,style:Z}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:MB(m,n,s,r,o,l,d)})]})}const AB={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."},OB=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function LB(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=OB.exec(o);if(!i||i[1]!==n)continue;const l=Date.parse(r.timestamp);return Number.isNaN(l)?void 0:new Date(l+Number(i[2])*6e4).toISOString()}}function MB(e,n,s,r,o,i,l){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&&l&&(n==null?void 0:n.state)==="none"&&!n.ended)return`${AB[i]} The ${e} is kept until ${b1(l).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${b1(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 b1(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function IB(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=Rr(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 ll=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},BE=e=>e.kind==="computer"?e.computer:"browser";function Nb(e,n){var s;if(e instanceof Ue&&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 Ue&&e.code==="computer_not_live"?e.message:e instanceof Ue&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Ue&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Gt(e)}`}function qE({ask:e,onAnswer:n,open:s,heading:r,compact:o=!1}){const[i,l]=g.useState(!1),[d,u]=g.useState(null),f=g.useRef(!1),h=async v=>{if(!n||f.current)return;f.current=!0,l(!0),u(null);let b=!1;try{const m=await n(v);b=m===null,u(m)}finally{b||(f.current=!1,l(!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:ee("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(hi,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",BE(e)]}),t.jsxs("div",{"data-agent-request":!0,className:ee("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(W,{size:"sm",variant:"solid",disabled:i,onClick:()=>void h("done"),children:"Done"}),t.jsx(W,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void h("cancelled"),children:"Cancel"})]})]}),d&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:d})]})}function PB(e,n){var d;const s=!!n&&((d=e.learning)==null?void 0:d.state)==="merged",[r,o]=g.useState({state:"reading"}),[i,l]=g.useState(0);return g.useEffect(()=>{if(!s)return;let u=!0;return o({state:"reading"}),Promise.resolve().then(()=>n()).then(f=>{u&&o({state:"read",changes:az(f)})},f=>{u&&o({state:"failed",error:f??new Error("unknown")})}),()=>{u=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>l(u=>u+1)}:null}function DB({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Yt(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(W,{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(zB,{change:r})},r.file))})]})}function zB({change:e}){const[n,s]=g.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:ee("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(v1,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(v1,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function v1({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:ee("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:ee("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},o))})]})}const FB=4e3,UB=e=>!!e.learning&&e.learning.reason!=="use",WB="The agent looks back on your words: what was wrong, and what a right answer does.",HB="A look-back needs words. Without them the grade is still kept.",BB='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',y1='Write it as a JSON object, like {"total": 42}, or leave it empty.';function qB(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:y1}}catch{return{error:y1}}}function GB(e){const n=Yt(e,"the grade");return e instanceof Ue&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const KB="The review could not run.";function VB(e,n){return e.feedback&&e.feedback_status==="not_run"?KB:e.feedback==="correction"?n?"Your words are being added to its corrections.":"Your words were added to its corrections.":"Kept for this agent."}function YB({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,i]=g.useState("auto"),[l,d]=g.useState(""),[u,f]=g.useState(""),[h,v]=g.useState(!1),[b,m]=g.useState(!1),[x,y]=g.useState(null),j=g.useRef(!1),k=Co(e.status),C=n!=null&&n.feedback?n.feedback_status:null,N=C==="running"||C==="ended"&&$h(e.learning??void 0);if(!UB(e)||!k&&!n)return null;const S=o==="auto"?n?"closed":"choose":o,E=k&&!N,$=qB(u),L=n?VB(n,N):null,A=async P=>{if(j.current||!s)return;const O=P?"":l.trim();if(!P&&$.error){v(!0);return}j.current=!0,m(!0),y(null);try{await s({correct:P,...O?{label:O}:{},...!P&&$.value?{expected:$.value}:{}}),i("auto"),d(""),f(""),v(!1)}catch(T){y(GB(T))}j.current=!1,m(!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"]}),N&&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:[L&&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:L}),r&&!!(n!=null&&n.feedback)&&t.jsx(W,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),E&&S==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(W,{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."})]}),E&&S==="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(W,{type:"button",size:"sm",variant:"primary",disabled:b||!s,onClick:()=>void A(!0),children:"Right"}),t.jsx(W,{type:"button",size:"sm",disabled:b||!s,onClick:()=>{i("wrong"),y(null)},children:"Wrong"}),n&&t.jsx(W,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>i("closed"),children:"Cancel"}),b&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),E&&S==="wrong"&&t.jsxs("form",{className:"space-y-4","aria-label":"Grade wrong",onSubmit:P=>{P.preventDefault(),A(!1)},children:[t.jsx(gt,{label:"What was wrong?",note:WB,warning:l.trim()?void 0:HB,children:t.jsx(An,{value:l,onChange:P=>d(P.target.value),maxLength:FB,rows:3,disabled:b,className:"resize-y font-sans text-lead"})}),t.jsx(gt,{label:"Correct answer",optional:!0,note:BB,error:h?$.error:void 0,children:t.jsx(An,{value:u,onChange:P=>{f(P.target.value),v(!1)},rows:2,disabled:b,spellCheck:!1,placeholder:'{"total": 42}',className:"resize-y"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(W,{type:"submit",size:"sm",variant:"solid",disabled:b,children:"Send grade"}),t.jsx(W,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{i(n?"closed":"choose"),v(!1)},children:"Cancel"}),b&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),x&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",x]})]})]})}const QB=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function JB(e,n,s){var j;const r=!!s&&!!e.learning,[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(0),[h,v]=g.useState(0);g.useEffect(()=>{if(!r)return;let k=!0;return Promise.resolve().then(()=>s()).then(C=>{k&&(i(C??null),f(0))},()=>{k&&(i(null),f(C=>C+1))}),()=>{k=!1}},[e.run_id,r,n,e.ended_at,(j=e.learning)==null?void 0:j.state,h]);const b=g.useCallback(({expected:k,...C})=>{d({run:C.run_id,grade:{...C,feedback_status:C.feedback?"running":null}})},[]),m=r?o:null,x=QB((m==null?void 0:m.graded)??null,(l==null?void 0:l.run)===e.run_id?l.grade:null),y=r&&(x==null?void 0:x.feedback_status)==="running";return g.useEffect(()=>{if(!y||u===0||u>XB)return;const k=setTimeout(()=>v(C=>C+1),Wx(u-1));return()=>clearTimeout(k)},[y,u]),{read:m,grade:x,graded:b}}const XB=8,ZB=e=>e===1?"once":e===2?"twice":`${e} times`;function eq({used:e,agentId:n}){return e!=null&&e.workflows.length?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:Wv(n),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),t.jsx("ul",{className:"divide-y",children: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(va,{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 ",ZB(s.calls)]}),s.failed>0&&t.jsxs(ke,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))})]}):null}const el=(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}),to=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),tq={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:to({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},nq=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."}),sq=e=>`Browse and automate websites in the persistent browser. ${nq.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"}]}.`,rq={name:"run",label:"Browser: run",description:sq(),parameters:to({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},el("click"),el("hover"),el("fill",{value:{type:"string"}}),el("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),el("press",{key:{type:"string"}}),el("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},oq={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:to({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:{...to({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"},aq={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:to({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},iq={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:to({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},lq={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:to({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"},cq={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:to({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"},dq={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:to({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},uq={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:to({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"},fq=Object.freeze([tq,rq,oq,aq,iq,lq,cq,dq,uq]),mq=Object.freeze(fq.map(e=>e.name)),hq={"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 pq(e){const n=e.split(".").at(-1)||e;return hq[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const gq=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"]),xq=new Set(["ctrl","alt","super"]);function bq(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=>xq.has(r))||s.every(r=>gq.has(r))?e:void 0}const vq=["press","set","perform","click","type","key","nav","scroll","drag"];function yq(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=vq.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,l=r==="key"?bq(s.key):void 0,d=r==="nav"&&typeof s.nav=="string"?s.nav:void 0;return{do:r,...i?{on:i}:{},...l?{keys:l}:{},...d?{nav:d}:{}}}const wq={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"},jq=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function kq(e){if(!e)return;const n=wq[e.role]??(e.role==="generic"?"element":e.role);return e.name?jq.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const Nq={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"]},Sq={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},mx={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},Cn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function Cq(e){const n=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=n.at(-1)??"",r=n.slice(0,-1).map(l=>l.toLowerCase()),o=n.length===1&&mx[s.toLowerCase()]?mx[s.toLowerCase()]:`${r.map(l=>Sq[l]??`${l}+`).join("")}${mx[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?Nq[s.toLowerCase()]:void 0;return i?Cn(i[0],i[1],` (${o})`):Cn("Pressed","press",` ${o}`)}const _q={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function $q(e){const n=kq(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return Cn("Pressed","press",s("an element"));case"click":return Cn("Clicked","click",n?` ${n}`:" at a point");case"set":return Cn("Set","set",s("an element"));case"perform":return Cn("Acted on","act on",s("an element"));case"type":return n?Cn("Typed into","type into",` ${n}`):Cn("Typed text","type text");case"key":return e.keys?Cq(e.keys):Cn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&_q[e.nav]||["Navigated","navigate",""];return Cn(r,o,i)}case"scroll":return n?Cn("Scrolled","scroll",` ${n}`):Cn("Scrolled","scroll");case"drag":return Cn("Dragged","drag"," across the screen");default:return Cn("Acted","act")}}function w1(e){const n=$q(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const j1=3,Sb=e=>e[0].toLowerCase()+e.slice(1);function Eq(e){const n=e.slice(0,j1).map(w1),s=e.slice(j1),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Sb),...o>0?[`+${o} more`]:[],...r<0?[]:[Sb(w1(s[r]))]].join(", ")}const Tq={"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 Xr(e){const n=e.app?pq(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return Cn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return Cn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return Cn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:Eq(e.steps),tried:""}:e.ok?Cn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):Cn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=Tq[e.method]??[e.method,e.method];return Cn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const Rq=e=>e.map((n,s)=>s===0?Xr(n):Sb(Xr(n))).join(", "),GE='\\s"`<>\\\\',Aq=new RegExp(`https?://[^${GE}|]+`,"gi"),Oq=new RegExp(`https?://[^${GE}]+`,"gi"),Lq=".,;:!?*)]}'",Mq={")":"(","]":"[","}":"{"};function Iq(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&&Lq.includes(e[s-1]);s--){const r=e[s-1],o=Mq[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${Aq.source}`,"gi");const To=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,rn=e=>typeof e=="string"?e:void 0,di=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,KE=e=>e.split(`
|
|
731
|
-
`).map(n=>n.trim()).find(Boolean)??"";function Pd(e){try{return To(JSON.parse(e))}catch{return}}const Pq=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Dd(e){const n=Pq.exec(e.trim());return di(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const Dq="…",zq=/https?:\/\//gi,Fq=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,Uq=/(https?:\/\/)[^@/?#\s]*@/gi,Wq=/[A-Za-z0-9]/;function Ey(e){return e.replace(Oq,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(zq)){if(i.index===0)continue;for(;r<i.index;r++)o||(o=n[r]==="?"||n[r]==="#");if(o)continue;let l=!1;for(let d=i.index-1;d>s.at(-1)&&!Wq.test(n[d]);d--)l||(l=n[d]==="'");l&&s.push(i.index)}return s.map((i,l)=>Hq(n.slice(i,s[l+1]??n.length))).join("")})}function Hq(e){const n=Iq(e).length,s=Fq.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(Uq,"$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}=${Dq}`).join("&")}`:""}${e.slice(n)}`}const Bq=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),qq=new Map,Gq=new Map,VE=new Map,Kq=new Set;function hn(e,n,s,{name:r,saysFailure:o}={}){qq.set(e,n),s&&Gq.set(e,s),r&&VE.set(e,r),o&&Kq.add(e)}const Vq=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,Yq=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,Qq=e=>{const n=Yq.exec(e)??Vq.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},Jq=e=>VE.get(e)??Qq(e)??e,Xq=new Map;function qh(e,n){Xq.set(e,n)}const Zq=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...Zq];const Ty=e=>rn(e.path)??rn(e.file_path),eG=/page\.goto\(\s*["'`]([^"'`]+)/;hn("read",e=>`Read ${Ty(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});hn("write",e=>`Wrote ${Ty(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});hn("edit",e=>`Edited ${Ty(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});hn("bash",e=>`Ran \`${di(Ey(KE(rn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const Ry=e=>{const n=e&&To(Pd(e.text)??Pd(KE(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=rn(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:rn(n.error)??rn(n.message)??"no detail"}},tG=(e,n)=>`${Ry(n)?"Tried to fetch":"Fetched"} ${Dd(rn(e.url)??"a page")}`,nG={many:e=>`Fetched ${e} pages`,subject:e=>e?Dd(e):void 0},YE=e=>{const n=Ry(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};hn("web_fetch",tG,nG,{name:"Fetch web pages"});qh("web_fetch",YE);const sG=(e,n)=>{var o;const s=n&&rn((o=To(Pd(n.text)))==null?void 0:o.path),r=rn(e.path);return s??(r?r.includes("/")?r:`media/${r}`:"a file")},rG=e=>{var s;const n=(s=URL.parse(rn(e.url)??""))==null?void 0:s.host;return n?` from ${n}`:""};hn("web_save",(e,n)=>`${Ry(n)?"Tried to save":"Saved"} ${sG(e,n)}${rG(e)}`,{many:e=>`Saved ${e} files from the web`,subject:e=>e??void 0},{name:"Save files from the web"});qh("web_save",YE);hn("web_search",e=>{const n=rn(e.query);return n?`Searched the web for "${di(Ey(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${di(e,40)}"`:void 0},{name:"Search the web"});qh("web_search",e=>{var s;const n=rn((s=To(Pd(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});hn("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 "${di(Ey(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?Dd(s):void 0}},{name:"Read the browser's page"});hn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});hn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});hn("run",(e,n)=>{var i,l;const s=(i=eG.exec(rn(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${Dd(s)}`;const r=(l=To(n==null?void 0:n.details))==null?void 0:l.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=To(d),[f,h]=[rn(u==null?void 0:u.method),rn(u==null?void 0:u.url)];return f&&h?`${f} ${Dd(h)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${Bq(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});hn("browser_downloads",(e,n)=>{var o;const s=n&&((o=Pd(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var l;return rn((l=To(i))==null?void 0:l.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"});hn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});hn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});hn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});hn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});hn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const oG=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,aG=e=>{if(e!==void 0)try{return rn(JSON.parse(e))}catch{return}};function QE(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
732
|
-
`)){const o=oG.exec(r);if(!o)continue;const i=aG(o[3]),l=(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}:{},...l!==void 0?{refused:l}:{}})}return n}function iG(e,n){return{...yq(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}hn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=To(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...rn(e.app)?{app:rn(e.app)}:{}};if(n!=null&&n.isError)return Xr({...r,ok:!1});const o=n===void 0?void 0:QE(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return Xr({...r,ok:!1});const l=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Xr({...r,ok:!0,steps:i.map((u,f)=>iG(u,o==null?void 0:o.get(f+1))),...l==="met"||l==="unmet"?{expect:l}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});qh("computer_act",e=>{for(const[n,s]of QE(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const k1=/^state \S+ · (\S+)/,lG=/^screen \S+ px · (?:\S+ in front|no app in front)/;hn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!k1.test(n.text)){const o=lG.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),l=o?rn(e.app):void 0;return Rq([...l?[i("apps.launch",l)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=rn(e.app)??(n&&((r=k1.exec(n.text))==null?void 0:r[1]));return Xr({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});hn("computer_screenshot",(e,n)=>Xr({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 N1={"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"};hn("computer_op",(e,n)=>{var i;const s=rn(e.op),r=s!==void 0&&Object.hasOwn(N1,s)?N1[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"?rn((i=To(e.args))==null?void 0:i.id):void 0;return Xr({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});hn("computer_script",(e,n)=>{var r;const s=(r=rn(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${di(s,120)}”`:"Could not run a script on the computer":s?di(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 cG=["schedule","webhook","slack","github","composio","email","feed"];new Set(cG);const dG=":feedback",uG=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(dG))===!0},fG={user_message:sS,thinking:xd,tool_use:vx,tool_result:vx,waiting:Mb,usage:Lb,final_answer:mi,phase:K1,error:wl,decision:CA,text_block:gA,tool_approval_requested:Z1},S1=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},C1=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Ay=e=>e.origin==="server",JE=e=>e.origin==="trigger",XE=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 Cb(e){const n=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`|\[[^\]\n]+\]\((?:[^()\s]|\([^()\s]*\))+\)|<https?:\/\/[^>\s]+>)/);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):s.startsWith("[")?t.jsx(g.Fragment,{children:Cb(s.slice(1,s.indexOf("](")))},r):s.startsWith("<")?s.slice(1,-1):t.jsx("strong",{className:"font-semibold",children:Cb(s.slice(2,-2))},r))}const mG=e=>{var r;const n=JE(e)?XE(e).said:(e.summary??"").replace(Ay(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(`
|
|
733
|
-
`).filter(o=>o.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?XC:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},zd=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,hG=new Set(mq),pG=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 gG(e){const n=pG.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 _1=e=>e&&(Gz(e)??(hG.has(e)?Jq(e):gG(e))),$1=e=>Ay(e)?"AgentRun":JE(e)?XE(e).who??"Trigger":uG(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:_1(e.tool_name)??"Tool",tool_result:_1(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,xG={budget:"Paused at cap"};function bG({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var y,j;const l=e.row,[d,u]=g.useState(!1),h=nP(l)?G1:fG[l.kind]??K1,v=e.above?l.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":mG(l),b=e.above?null:e.detail??$C(l),m=b&&b.trim()!==v.trim()?b:null,x=TC(l);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:ee("mt-3 flex size-7 items-center justify-center border bg-background",(l.kind==="waiting"||C1(l))&&"border-warning/60 text-warning-text",x&&"border-destructive/60 text-destructive-text"),children:t.jsx(h,{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:!m,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:$1(l),children:$1(l)}),(l.kind==="tool_use"||l.kind==="tool_result")&&l.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",YI(l.usage,{ended:s})]}),l.kind==="waiting"&&t.jsx(ke,{tone:"warning",children:r??"Input required"}),C1(l)&&t.jsx(ke,{tone:"warning",children:"Approval required"}),x&&t.jsx(ke,{tone:"error",children:"Error"}),EC(l)&&t.jsx(ke,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),l.agent_label&&t.jsx(ke,{label:!0,title:l.agent_label,children:l.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:zd(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${zd(Math.max(0,Date.parse(e.until)-Date.parse(l.timestamp)))}`:""]})]}),t.jsx("span",{className:ee("mt-0.5 block break-words text-prose leading-snug",Ay(l)&&"text-muted-foreground"),children:Cb(v)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),S1(l)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:S1(l)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:li(l.timestamp)}),m&&t.jsx(Es,{className:ee("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",d&&"rotate-90"),"aria-hidden":!0})]}),d&&m&&l.tool_name&&t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:l.tool_name}),d&&m&&l.kind==="final_answer"&&t.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:xv(k=>{const C=o==null?void 0:o.find(N=>N.path===k);C&&(i==null||i(C))}),dangerouslySetInnerHTML:{__html:Yr(m,i&&o?{paths:o.map(k=>k.path)}:void 0)}}),d&&m&&l.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:m}),(y=l.learned_nodes)!=null&&y.length?t.jsx(wG,{nodes:l.learned_nodes}):null,(j=l.computer_calls)!=null&&j.length?t.jsx(vG,{calls:l.computer_calls,dropped:l.computer_calls_dropped??0}):null]})]})}function vG({calls:e,dropped:n}){const[s,r]=g.useState(!1),o=e.filter(u=>!u.ok).length,i=e.length+n,l=[`${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:ee("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(hi,{className:"size-3","aria-hidden":!0}),l]}),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:["+",zd(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:ee("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:Xr(u),children:Xr(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:zd(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 yG={ok:"success",failed:"error",escalated:"warning"};function wG({nodes:e}){const[n,s]=g.useState(!1),r=Object.entries(e.reduce((i,l)=>({...i,[l.status]:(i[l.status]??0)+1}),{})).filter(([i])=>i!=="ok"),o=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([i,l])=>`${l} ${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:ee("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(va,{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,l)=>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:yG[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:E_(i)||void 0,children:Yv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:zd(i.duration_ms)})]},l))})]})}function jG({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:l,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,[h,v]=g.useState(!1),b=sP(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),m=h?0:Math.max(0,b.length-s),x=b.slice(m);return e.length?t.jsxs("div",{children:[m>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:()=>v(!0),children:[t.jsx(Es,{className:"size-3","aria-hidden":!0})," ",m," earlier ",m===1?"step":"steps"]}),t.jsx("ol",{children:x.map((j,k)=>t.jsx(bG,{step:j,last:k===x.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?xG[o]:void 0,files:i,onOpen:l},j.row.id))}),n&&t.jsx(_b,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(_b,{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 _b({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(ov,{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 kG={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."},NG={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 SG(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:l,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${Tr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof l=="number"?`It has spent ${Tr(l)} of its ${Tr(i)} cap${f}.`:u?`Its ${Tr(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=ll(e);return s?{title:`Waiting for you at the ${BE(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 CG({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:l,readFile:d,fileUrl:u,openFile:f=null,actions:h,onMessage:v,onApprove:b,tab:m,graphView:x,costText:y,readLearningDiff:j,readLearning:k,readLearningResult:C,readComputer:N,computerEvery:S,onTakeOver:E,onHandBack:$,readComputers:L,onGrade:A,readTrace:P,readUsage:O,traceAt:T}){var ft,$n,en,qn,kn,pn,Gn;const M=e.native,F=is(e),I=ml(e),V=((ft=e.pending)==null?void 0:ft.kind)==="budget"?e.pending:null,G=ll(e),q=!F&&!I&&!M&&G?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,H=Nh(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),U=F||I||M||V?{...H,canMessage:!1,messageMode:null}:G?{...H,canMessage:q!==null,messageMode:q}:H,Q=x?"graph":U.final&&e.status==="completed"?"report":"timeline",[D,Y]=g.useState(m??Q),K=D==="graph"&&!x?Q:D,[Z,se]=g.useState(!1),[ie,Ne]=g.useState(f?{file:f,text:null}:null),he=w7(e),ve=he||G?null:KP(e.status,e.state,o),Ee=he?o.findLast(tt=>tt.kind===TE&&tt.tool_use_id===he.call_id):void 0,[ye,pe]=g.useState(null),Pe=async(tt,xt,Rt,gn)=>{const dn=b?await(gn?b(tt,xt,Rt,gn):b(tt,xt,Rt)):"This page can't answer an approval.";return pe(dn?{id:tt,text:dn}:null),dn},ue=g.useRef(ZC()).current,ge=async tt=>{const xt=ue.begin();if(u&&QC(YC(tt)))return Ne({file:tt,text:""});if(Ne({file:tt,text:null}),!d)return;const Rt=await d(tt);ue.current(xt)&&Ne({file:tt,text:Rt})},Te=()=>{ue.cancel(),Ne(null)},Xe=PB(e,j),{read:je,grade:fe,graded:De}=JB(e,U.final,k),te=A&&(async tt=>{const xt=await A(tt);return De(xt),xt}),Ie=U.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",We=e.computer,rt=We?LB(o,We.kind):void 0,{view:ot,held:wt}=NB(N,!U.final,S,void 0,e.status==="queued"||rt!==void 0),jt=!!ot||!!We||!!G,we=g.useRef(!1);g.useEffect(()=>{if(jt){we.current=!0;return}we.current&&K==="screen"&&Y(Q),we.current=!1},[jt,K,Q]);const[ze,st]=g.useState(!1);g.useEffect(()=>{if(!We||!oy.has(We.kind)||!L)return;let tt=!0;return L().then(xt=>{var Rt,gn;tt&&st(!!((gn=(Rt=xt.kinds.find(dn=>dn.kind===We.kind))==null?void 0:Rt.providers.find(dn=>dn.id===We.provider))!=null&&gn.metered))}).catch(()=>{}),()=>{tt=!1}},[We==null?void 0:We.kind,We==null?void 0:We.provider]);const xe=G?`${G.kind}:${G.asked_at}`:null,Be=g.useRef(null);g.useEffect(()=>{!xe||Be.current===xe||!jt||(Be.current=xe,Y("screen"))},[xe,jt]);const $t=async()=>{if(!E)return"This page can't take the computer over.";try{return wt((await E()).hold),null}catch(tt){return Nb(tt,"take")}},et=async tt=>{if(!$)return"This page can't hand the computer back.";try{return wt((await $(tt)).hold),null}catch(xt){return Nb(xt,"hand")}},[dt,Lt]=g.useState(null),qt=async tt=>{const xt=(G==null?void 0:G.asked_at)??"",Rt=await et(tt);return Lt(Rt?{at:xt,text:Rt}:null),Rt};g.useEffect(()=>{f&&d&&ge(f)},[f]);const At=g.useRef({rows:o,times:0});At.current.rows!==o&&(At.current={rows:o,times:At.current.times+1});const Et=!!(U.needsYou&&V&&typeof V.cap_usd=="number"&&(h!=null&&h.onRaiseCap)),B=K!=="graph"&&!(K==="trace"&&P),J=g.useRef(null),[de,_e]=g.useState(0),at=()=>{B||Y("timeline"),_e(tt=>tt+1)};g.useEffect(()=>{var xt;if(!de)return;const tt=J.current;tt==null||tt.scrollIntoView({block:"center"}),(xt=tt==null?void 0:tt.querySelector("input"))==null||xt.focus()},[de]);const qe=[...x?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...P?[["trace","Dev tools"]]:[],...e.learning?[["learning","Learning"]]:[],["files",`Files ${OE(i,Z).length}`],...jt?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(L7,{run:e,agentName:n,actions:h,costText:y,raiseBelow:Et?at:void 0}),t.jsx(av,{id:"run-views",label:"Run views",value:K,onChange:tt=>Y(tt),tabs:qe.map(([tt,xt])=>({id:tt,label:xt}))}),K==="graph"?t.jsx("div",{...ld("run-views",K),className:"min-h-0 flex-1 short:min-h-96",children:x}):K==="trace"&&P?t.jsx(gB,{run:e,read:P,readUsage:O,version:`${At.current.times}:${e.status}:${e.ended_at??""}`,live:U.live,panel:ld("run-views",K),...T}):t.jsx("div",{...ld("run-views",K),"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:[M&&t.jsx(xB,{native:M,agentId:e.agent_id}),I&&t.jsx(y7,{cli:I,ended:U.final}),e.status==="failed"&&e.error&&t.jsx(Mo,{error:e.error,title:t_(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."]})]}),ye&&ye.id!==(he==null?void 0:he.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: ",ye.text]}),dt&&dt.at!==(G==null?void 0:G.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]}),he?t.jsx(AE,{pending:he,onAnswer:(tt,xt,Rt)=>Rt?Pe(he.id,tt,xt,Rt):Pe(he.id,tt,xt)},he.id):G?t.jsx(qE,{ask:G,onAnswer:$?qt:void 0,open:K!=="screen"?t.jsx(W,{size:"sm",variant:"primary",onClick:()=>Y("screen"),children:"Open the screen"}):null},xe):!M&&U.needsYou&&(V?t.jsx(H9,{pending:V}):t.jsx(q9,{waiting:ve})),Et&&t.jsx("div",{ref:J,children:t.jsx(kE,{cap:V.cap_usd,suggested:wE(V),least:jE(V),paused:!0,onRaise:h.onRaiseCap},`${e.run_id}:${V.at}`)}),K==="report"&&t.jsx(H7,{run:e,rows:o,files:i,onOpen:ge,schema:l}),K==="report"&&!e.result&&!U.final&&t.jsx(_b,{...SG(e,U)}),K==="report"&&U.final&&!((en=($n=e.result)==null?void 0:$n.final_answer)!=null&&en.trim())&&!((qn=e.result)!=null&&qn.output)&&!o.some(tt=>{var xt;return tt.kind==="final_answer"&&((xt=tt.text)==null?void 0:xt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[XC,U.canMessage?" Send a follow-up below to ask for one.":""]}),K==="timeline"&&t.jsx(jG,{rows:nz(o,e.learning),live:U.live,ended:Co(e.status),asking:(Ee==null?void 0:Ee.id)??(U.needsYou&&!V?ve==null?void 0:ve.id:void 0),waitingOn:e.status==="input_required"?(kn=e.pending)==null?void 0:kn.kind:void 0,files:i,onOpen:ge}),(K==="report"||K==="timeline")&&t.jsx(YB,{run:e,graded:fe,onGrade:te,onOpenTimeline:K==="timeline"?void 0:()=>Y("timeline")}),(K==="report"||K==="timeline")&&t.jsx(eq,{used:(je==null?void 0:je.used)??null,agentId:e.agent_id}),(K==="report"||K==="timeline")&&Xe&&t.jsx(DB,{got:Xe.got,retry:Xe.retry}),K==="learning"&&t.jsx(vB,{run:e,read:C,onViewChanges:Xe?()=>Y("report"):void 0},e.run_id),K==="files"&&t.jsx(P7,{files:i,onOpen:ge,showHidden:Z,onShowHidden:se}),K==="screen"&&jt&&t.jsx(RB,{runId:e.run_id,screen:ot,machine:We,opens:Ie,followUp:U.canMessage&&U.messageMode==="follow_up",metered:ze,waitsFor:e.status==="input_required"&&((pn=e.pending)==null?void 0:pn.kind)!=="stopped"?(Gn=e.pending)==null?void 0:Gn.kind:void 0,keptUntil:e.status==="input_required"?rt:void 0,onTake:E?$t:void 0,onHand:$?()=>et():void 0,recordings:e.recordings,fileUrl:u})]})}),M&&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."]}),I&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[gh(I.runtime)," runs in your CLI. Continue, interrupt or retry the task in that original session. AgentRun records completed prompt windows and checked learning."]}),F&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Ro(F)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),U.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($7,{mode:U.messageMode,onSend:v,purpose:he?kG:G&&q?NG[q]:void 0})})}),ie&&t.jsx(D7,{file:ie.file,text:ie.text,onClose:Te,files:i,onOpen:ge,src:u==null?void 0:u(ie.file.path)})]})}const ZE=new Set(["chain","parallel","route","map","loop","workflow"]),_G={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},$G=e=>e==="review"?"needs review":e.replace("-"," ");function Oy({state:e}){const n=vm(e)??"pending";return t.jsx(ke,{tone:_G[n]??"plain",className:"whitespace-nowrap",children:$G(n)})}function Ly({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 eT={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},My=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function EG({data:e,selected:n,onSelect:s,onClose:r,fileUrl:o}){var j,k,C,N,S,E;const i=e.graph.nodes.find($=>$.path===n.path),[l,d]=g.useState(null);if(!i)return null;const u=e.nodes[i.path],f=Sv(e.workflow,i.path,i),h=i.kind==="map"?i.path:(j=e.graph.nodes.find($=>$.kind==="map"&&i.path.startsWith(`${$.path}/body/`)))==null?void 0:j.path,v=n.item!=null&&h?(C=(k=e.nodes[h])==null?void 0:k.items)==null?void 0:C.find($=>$.index===n.item):void 0,b=e.decisions.filter($=>$.node===i.path),m=e.effects.filter($=>$.node===i.path),x=!!h&&i.kind!=="map",y=My(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:Yv(i.kind,u),f.tool?` · ${sT(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&su(f.tool)&&t.jsx(rT,{}),v&&t.jsxs(t.Fragment,{children:[t.jsx(Es,{className:"size-3","aria-hidden":!0})," item ",v.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:v?Cd(e,h,v.index)??`Item ${v.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx(Oy,{state:v?v.status:u==null?void 0:u.status}),v&&(()=>{const $=Cv(e,h,v);return $.outcome?t.jsxs("span",{className:"font-mono text-label",title:$.pNote,children:["outcome ",t.jsx("b",{className:eT[$.tone??""],children:$.outcome}),$.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",dr($.p)]})]}):null})(),f.decision&&t.jsx(Ly,{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})]}),!v&&y!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:pl(y)})]})]}),t.jsx(W,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Oo,{"aria-hidden":!0})})]}),v&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:h,item:null}),children:["All ",(S=(N=e.nodes[h])==null?void 0:N.items)==null?void 0:S.length," items of ",(E=e.graph.nodes.find($=>$.path===h))==null?void 0:E.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[v?t.jsx(OG,{data:e,mapPath:h,index:v.index,status:v.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(TG,{data:e,mapPath:i.path,onSelect:s}):x&&(b.length||m.length)?t.jsx(RG,{data:e,path:i.path,mapPath:h,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(AG,{data:e,path:i.path,onSelect:s}),b.map(($,L)=>t.jsx(nT,{d:$,fileUrl:o,zoom:d},$.id??L)),m.map(($,L)=>t.jsx(oT,{e:$,fileUrl:o,zoom:d},L)),!b.length&&!m.length&&i.kind!=="parallel"&&t.jsx(tT,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(DG,{workflow:e.workflow,path:i.path,kind:i.kind})]}),l&&t.jsx(zG,{src:l,onClose:()=>d(null)})]})}function tT({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.":ZE.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 TG({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],o=KC(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(([l,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:l}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},l))}),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(l=>{const d=e.decisions.filter(h=>{var v;return h.item===l.index&&!!((v=h.node)!=null&&v.startsWith(`${n}/body`))}),u=Cv(e,n,l),f=d.length?d.some(h=>h.cost_usd===null)?null:d.reduce((h,v)=>h+(v.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:l.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:l.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Cd(e,n,l.index),children:Cd(e,n,l.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(Oy,{state:l.status})}),t.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[u.pNote,...d.map(h=>El(h))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ee("font-semibold",eT[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:dr(u.p)})]}):d.map(h=>El(h)).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:"—"}):Bl(f)})]},l.index)})})]})]})}function RG({data:e,path:n,mapPath:s,onSelect:r}){var h;const o=e.decisions.filter(v=>v.node===n),i=e.effects.filter(v=>v.node===n),l=(((h=e.nodes[s])==null?void 0:h.items)??[]).map(v=>({it:v,d:o.find(b=>b.item===v.index),e:i.find(b=>b.item===v.index)})).filter(v=>v.d||v.e),d=o.filter(v=>v.cost_usd!==null),u=o.filter(v=>v.latency_ms!==null),f=u.length?u.reduce((v,b)=>v+(b.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 · ",Bl(d.reduce((v,b)=>v+(b.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",pl(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:l.map(({it:v,d:b,e:m})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:v.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:v.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Cd(e,s,v.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:b?El(b):m?t.jsx(Oy,{state:m.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:b?pl(b.latency_ms):m?pl(My(m.startedAt,m.endedAt)):""})]},v.index))})})]})}function AG({data:e,path:n,onSelect:s}){var b,m;const r=`${n}/branches/`,o=e.decisions.filter(x=>{var y;return((y=x.node)==null?void 0:y.startsWith(r))&&/^\d+$/.test(x.node.slice(r.length))&&x.item===null}),i=new Set(o.flatMap(x=>Object.keys(x.answers??{}))),[l]=[...i],d=o.map(x=>{var y;return{d:x,a:(y=x.answers)==null?void 0:y[l]}}).filter(x=>{var y;return((y=x.a)==null?void 0:y.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(tT,{kind:"parallel",meta:{decision:!1}});const u=d.map(x=>x.a.noul),f=u.reduce((x,y)=>x+y,0)/u.length,h=Math.max(...u)-Math.min(...u),v=x=>{var y;return((y=e.graph.nodes.find(j=>j.path===x.node))==null?void 0:y.label)??x.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 · ",l]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((m=(b=o[0].questions)==null?void 0:b[l])==null?void 0:m.instructions)??l})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:x,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:x.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(Ly,{provider:x.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:x.model??"",children:x.model??v(x)}),t.jsx($b,{p:y.noul,strong:!0,tick:.5,tone:y.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:dr(y.noul)})]})},x.id??x.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:dr(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:ee("font-semibold tabular-nums",h>.3&&"text-warning-text"),children:dr(h)})]}),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:Bl(d.some(x=>x.d.cost_usd===null)?null:d.reduce((x,y)=>x+(y.d.cost_usd??0),0))})]})]})]})}function OG({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=>!ZE.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:h})=>f.length||h.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),h.map((v,b)=>t.jsx(oT,{e:v,fileUrl:o,zoom:i,compact:!0},b)),f.map((v,b)=>t.jsx(nT,{d:v,fileUrl:o,zoom:i},v.id??b))]},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 E1=e=>`${Math.round(e*100)}%`,dr=e=>e.toFixed(2);function $b({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:ee("absolute inset-y-0 left-0 transition-[width] duration-slow",n?o:"bg-muted-foreground/45"),style:{width:E1(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:E1(s)},title:`threshold ${dr(s)}`})]})}function LG({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,l=(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:ee("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx($b,{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) ",dr(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:ee("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($b,{p:u,strong:f,tick:f&&l?l.gte:void 0}),t.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:dr(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 MG(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 ${dr(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) ≥ ${dr(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${dr(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function IG(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 l=((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 ${l!==void 0?dr(l):"?"} 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 l=e.rule.options[n.index];return n.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${l!==void 0?`"${qC(e,Object.keys(e.questions??{})[0]??"pick",l)}"`:`option ${n.index}`}.`}return typeof n=="object"?Object.entries(n).map(([l,d])=>`${l} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(n)}function nT({d:e,fileUrl:n,zoom:s}){var i,l,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(Ly,{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:El(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:Bl(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:pl(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:ee("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((l=e.images)!=null&&l.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)||Rr(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,h;return t.jsx(LG,{id:u,q:(f=e.questions)==null?void 0:f[u],a:(h=e.answers)==null?void 0:h[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:MG(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:IG(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(PG,{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(Um,{value:e.state})]})]})}function PG({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=Rr(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(iA,{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,l)=>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},l))]})]},s)})})]})}const sT=e=>{const n=su(e);return n?`${n.tool} on ${n.server}`:e},rT=()=>t.jsx(ke,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function oT({e,fileUrl:n,zoom:s,compact:r=!1}){var h;const o=e.output,i=o!=null,l=o&&typeof o=="object"?o:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(l!=null&&l.error?`${l.error.code?`${l.error.code}: `:""}${l.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:sT(e.tool)}),su(e.tool)&&t.jsx(rT,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?pl(My(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(Um,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((h=l==null?void 0:l.pages)!=null&&h.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:l.pages.map(v=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(v.image)),"aria-label":`Open page ${v.page}`,children:t.jsx("img",{src:n(v.image),alt:`Page ${v.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},v.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(Um,{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 DG({workflow:e,path:n,kind:s}){const r=HC(e,n);if(!r)return null;const o=Object.fromEntries(Object.entries(r).map(([i,l])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(l)?`… ${Rh(l.length)}`:i==="body"?"… its body":i==="branches"&&s==="route"&&l&&typeof l=="object"?Object.fromEntries(Object.entries(l).map(([d,u])=>[d,(u==null?void 0:u.criteria)??"…"])):l]));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(Um,{value:o})]})}function Um({value:e,small:n}){return t.jsx("pre",{className:ee("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 zG({src:e,onClose:n}){return t.jsx(ph,{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 aT=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function FG(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState(0),[h,v]=g.useState(0),b=g.useRef(e);return b.current=e,g.useEffect(()=>{if(!r)return;const m=new AbortController;let x;const y=async()=>{try{const j=Date.now(),k=await b.current(m.signal);if(m.signal.aborted||(i(k),d(null),f(j),Jd(k.run.status)))return}catch(j){if(m.signal.aborted)return;d(j);const k=j;if(k.retryable){x=setTimeout(y,Math.min(n,k.retryAfterMs??500));return}if(aT(j))return}x=setTimeout(y,n)};return y(),()=>{m.abort(),clearTimeout(x)}},[s,n,h,r]),{data:o,error:l,readAt:u,reload:()=>v(m=>m+1)}}function UG({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,l]=g.useState(r),d=g.useMemo(()=>HP(e,i),[e,i]),u=Jd(e.run.status),[f,h]=g.useState(()=>Date.now()),v=g.useMemo(()=>Date.now(),[e]);return g.useEffect(()=>{if(u||e.run.paused)return;const b=setInterval(()=>h(Date.now()),1e3);return()=>clearInterval(b)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(WG,{data:e,readAt:v,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(ou,{graph:e.graph,marks:d,onSelect:b=>l(m=>m&&m.path===b.path&&(m.item??null)===b.item?null:b),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(EG,{data:e,selected:i,onSelect:l,onClose:()=>l(null),fileUrl:s})})]}),t.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:t.jsx(au,{run:!0})})]})}function WG({data:e,readAt:n,now:s,actions:r,stale:o}){const i=Jd(e.run.status),l=e.graph.nodes.find(v=>{var b,m;return v.kind==="map"&&((m=(b=e.nodes[v.path])==null?void 0:b.items)==null?void 0:m.length)}),d=l?KC(e.nodes[l.path].items):null,{usd:u,unknown:f}=VC(e),h=[["Elapsed",Tl(GP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[Bl(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",BG(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&h.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(jl,{className:"size-3","aria-hidden":!0})," Paused"]})}),h.map(([v,b,m],x)=>t.jsxs("div",{className:ee("px-4 py-2",x?"border-l":"pl-5 md:pl-8"),title:m,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:v}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:b})]},v)),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 ",Tl(o)," ago, reading again"]}),!i&&(e.run.paused?t.jsxs(W,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[t.jsx(Ao,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):t.jsxs(W,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[t.jsx(jl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const HG=new Set(["agent","decide","extract","report","artifact"]),BG=e=>e.graph.nodes.filter(n=>{var s;return HG.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function qG({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:ee("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 GG(e,n){return!n||e.state==="loading"?{messages:kh,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:XP(e.id,n.harnesses)}}async function KG(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),o=r.revisions.find(l=>l.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 T1=new Set(["completed","failed","cancelled"]),VG={firstMs:2e3,maxMs:16e3,totalMs:12e4};function YG(e,n,s,r=VG){var h;const o=!!e&&T1.has(e.status)&&$h(e.learning),i=g.useRef(n);i.current=n;const l=g.useRef(s);l.current=s;const d=(h=e==null?void 0:e.learning)==null?void 0:h.state,u=!!e&&T1.has(e.status),f=g.useRef(d);g.useEffect(()=>{var b;const v=f.current;f.current=d,v!==void 0&&v!==d&&u&&((b=l.current)==null||b.call(l))},[d,u]),g.useEffect(()=>{if(!o)return;let v,b=0,m=r.firstMs,x=!1,y=!1;const j=()=>{y||b+m>r.totalMs||(v=setTimeout(k,m))},k=()=>{if(v=void 0,document.visibilityState==="hidden"){x=!0;return}b+=m,m=Math.min(m*2,r.maxMs),i.current(),j()},C=()=>{x&&document.visibilityState!=="hidden"&&(x=!1,k())};return document.addEventListener("visibilitychange",C),j(),()=>{y=!0,v&&clearTimeout(v),document.removeEventListener("visibilitychange",C)}},[o])}const R1=new Set(["completed","failed","cancelled"]),QG=e=>{const n=VC(e);return`${Bl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},JG=e=>e instanceof Ue?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},nl=e=>({api:JG(e),title:NP(e),cause:e}),XG=3e3;function A1({v2:e,runId:n,caps:s,agentName:r}){var K;const[o,i]=g.useState(null),[l,d]=g.useState(null),[u,f]=g.useState([]),[h,v]=g.useState([]),[b,m]=g.useState(null),[x,y]=g.useState(null),[j,k]=g.useState(0),C=g.useRef(""),N=g.useRef(ZC()).current,S=g.useRef(yi()).current,E=g.useRef(0),$=g.useRef(""),[L,A]=g.useState({state:"loading"});g.useEffect(()=>{o&&L.state==="loading"&&KG(e,o).then(A)},[o==null?void 0:o.revision]);const P=GG(L,s);YG(o,()=>O(),()=>k(Z=>Z+1));const O=async()=>{const Z=N.begin();try{const[se,ie]=await Promise.all([e.getRun(n),e.listFiles(n)]);N.current(Z)&&(i(se),v(ie.files))}catch(se){N.current(Z)&&m(nl(se))}};g.useEffect(()=>{O()},[n]),_E(()=>{O()});const T=((K=o==null?void 0:o.recordings)==null?void 0:K.some(Z=>!Z.finished))===!0;g.useEffect(()=>{if(!T)return;const Z=setInterval(()=>{O()},XG);return()=>clearInterval(Z)},[T,n]),g.useEffect(()=>{const Z=new AbortController;return d(null),RC(e,n,{signal:Z.signal,onRows:se=>{f(se);const ie=se.filter(he=>he.kind===TE).map(he=>`${he.id}\0${he.summary}`).join("");ie!==$.current&&($.current=ie,O());const Ne=se.filter(he=>he.kind==="tool_result").length;Ne>E.current&&(E.current=Ne,O())},onPage:se=>{se.cost&&d(se.cost);const ie=`${se.status}/${se.state}`;(ie!==C.current||se.status==="input_required"&&!se.unchanged)&&(C.current=ie,O())}}).catch(se=>{Z.signal.aborted||m(nl(se))}),()=>Z.abort()},[n,j]);const M=async Z=>{y(Z);try{await e[Z](n),m(null)}catch(se){m(nl(se))}y(null),await O(),k(se=>se+1)},F=async()=>{if(o){y("archive");try{const Z=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(se=>se?{...se,archived_at:Z.archived_at}:Z),m(null)}catch(Z){m(nl(Z))}y(null),O()}},I=async Z=>{const se=await Z();return await O(),k(ie=>ie+1),se},V=Z=>I(()=>e.raiseCap(n,Z)),G=Z=>I(()=>e.gradeRun(n,Z)),q=async Z=>{let se=!0;try{await F_(S,n,Z,e.sendMessage),m(null)}catch(ie){m(nl(ie)),se=!1}return await O(),k(ie=>ie+1),se},H=async(Z,se,ie,Ne)=>{let he=null;try{await e.answerApproval(n,Z,se,ie,Ne)}catch(ve){he=RE(ve)}return await O(),k(ve=>ve+1),he},U=async Z=>{try{return await Z()}finally{O(),k(se=>se+1)}},Q=FG(Z=>e.getRunGraph(n,Z),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),D=!Q.data&&aT(Q.error);if(!o)return b?b.cause instanceof Ue&&b.cause.status===404?t.jsx(LC,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(on,{problem:Yt(b.cause,"the run"),onRetry:()=>{m(null),O(),k(Z=>Z+1)}}):t.jsx(vP,{});const Y=l&&!R1.has(o.status)?{...o,cost:l}:o;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[b&&t.jsx("div",{className:"border-b p-3",children:t.jsx(Mo,{title:b.title,error:b.api})}),t.jsx(CG,{run:Y,agentName:r(o.agent_id),messages:P.messages,harnessSteers:P.steers,graphView:o.kind==="workflow"&&!D?t.jsx(ZG,{v2:e,runId:n,graph:Q,onMoved:()=>{O()}}):void 0,costText:o.kind==="workflow"&&!R1.has(o.status)&&Q.data?QG(Q.data):void 0,outputSchema:L.state==="read"?L.outputSchema:void 0,rows:u,files:h,readFile:Z=>e.readFile(n,Z.path),fileUrl:Z=>e.fileUrl(n,Z),readTrace:()=>e.runTrace(n),readUsage:()=>e.runUsage(n),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>U(()=>e.takeOverComputer(n)),onHandBack:Z=>U(()=>e.handBackComputer(n,Z)),readComputers:()=>e.computers(),onMessage:q,onApprove:H,onGrade:G,actions:{onStop:()=>void M("stop"),onCancel:()=>void M("cancel"),onArchive:()=>void F(),onRaiseCap:V,busy:x}},o.run_id)]})}function ZG({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,error:i,readAt:l,reload:d}=s,[u,f]=g.useState(null),[h,v]=g.useState(null),[b,m]=g.useState(null),x=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));m({paused:k.paused,status:k.status,at:Date.now()}),v(null)}catch(k){v(nl(k))}f(null),d(),r()},y=o&&b&&l<b.at?{...o,run:{...o.run,paused:b.paused,...b.status?{status:b.status}:{}}}:o;return y?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h&&t.jsx("div",{className:"border-b p-3",children:t.jsx(Mo,{title:h.title,error:h.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(UG,{data:y,lastRead:l,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void x("pause"),onResume:()=>void x("resume"),busy:u}})})]}):t.jsx(qG,{error:i})}function O1({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:ee(Lr,"flex-wrap justify-between gap-2 px-5 md:px-6"),children:[t.jsxs("h1",{className:ha,children:[t.jsx(Q1,{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 eK({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:l,live:d,startHere:u,actions:f,observed:h,agents:v,agentsError:b}){var L,A,P;const m=l$(v??[],((L=h==null?void 0:h.data)==null?void 0:L.sessions)??[]),y=[...(v===void 0?((e==null?void 0:e.perAgent)??[]).map(O=>({id:O.agentId,name:O.name,href:jn(O.agentId,"runs"),detail:`${O.runs} runs`})):m.agents.map(O=>{var T,M;return{id:O.agent_id,name:O.definition.name??O.agent_id,href:jn(O.agent_id,"runs"),detail:`${((T=e==null?void 0:e.perAgent.find(F=>F.agentId===O.agent_id))==null?void 0:T.runs)??((M=O.runs)==null?void 0:M.count)??0} runs`}})).map(O=>({...O,session:void 0})),...m.sessions.map(O=>({id:O.id,name:O.display_name,href:bv(O.id),detail:wh(O),session:O}))],j=r!=null&&r.agent?y.filter(O=>{var T,M;return O.id===r.agent||((M=(T=O.session)==null?void 0:T.learning)==null?void 0:M.agent_id)===r.agent}):y,k=v===null||!!(h&&(!h.data||h.error)),C=k?null:v===void 0?((e==null?void 0:e.agents)??0)+m.sessions.length:m.count,N=k?h!=null&&h.loading?"Loading connected agents":"Agent count unavailable":void 0,S=t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card","aria-label":"Connected agents",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(xd,{className:"size-4","aria-hidden":!0}),"Connected agents"]}),b&&t.jsxs(ct,{tone:"error",children:["Could not refresh connected agents: ",b]}),(h==null?void 0:h.error)&&t.jsxs(ct,{tone:"error",children:["Could not refresh connected agents: ",h.error]}),((A=h==null?void 0:h.data)==null?void 0:A.connectors.some(O=>O.storage_full))&&t.jsx(ct,{tone:"warning",children:"A connection has reached its activity storage limit. New usage reports may be missing."}),j.length?t.jsx("ul",{children:j.map(O=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:O.href,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:O.name}),O.session?t.jsx(ke,{tone:vv(O.session),children:O.detail}):t.jsx("span",{className:"shrink-0 font-mono text-body text-muted-foreground",children:O.detail})]})},O.href))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:k?"Connected agents are unavailable.":"No connected agents yet."})]});if(!e)return t.jsx(O1,{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(on,{problem:n,onRetry:s}):t.jsx(bP,{}),S]})});const E=O=>{var T;return((T=e.perAgent.find(M=>M.agentId===O))==null?void 0:T.name)??O},$=[["Agents",C===null?"–":String(C),"#/agents",void 0,N],["Runs",String(e.runs.total),"#/runs"],["Active runs",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],l===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,L1(e.runs.needsReview)]:["Failed · last 24 h",l===null?"–":String(l),"#/runs?status=failed",l?"text-destructive-text":void 0,[`See all ${e.runs.failed}`,L1(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(O1,{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(on,{problem:n,onRetry:s,className:""}),u,o,t.jsx("section",{className:"space-y-4","aria-label":"Agents and runs",children:t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:$.map(([O,T,M,F,I])=>{const V=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:O}),t.jsx("p",{className:ee("mt-3 font-mono text-display leading-none",F),children:T}),I&&t.jsx("p",{className:"mt-2 text-label text-muted-foreground",children:I})]});return t.jsx("li",{children:M?t.jsx("a",{href:M,className:"block h-full border bg-card p-5 transition-colors hover:border-border-strong hover:bg-accent",children:V}):t.jsx("div",{className:"h-full border bg-card p-5",children:V})},O)})})}),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:tK(e,(P=y.find(O=>O.id===e.analytics.filter.agent))==null?void 0:P.name)})]}),r&&t.jsx(FC,{range:r.range,onRange:r.onRange,agent:r.agent,agents:y.map(O=>{var T;return{agentId:O.id,name:O.name,runs:((T=e.perAgent.find(M=>M.agentId===O.id))==null?void 0:T.runs)??0}}),onAgent:r.onAgent})]}),t.jsx(UC,{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:[S,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(Hd,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(O=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(O.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(ql,{run:O}),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:Hn(O)}),t.jsx(ty,{run:O,className:"hidden sm:inline-flex"}),dH(O)&&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:E(O.agent_id)}),O.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:Tl(Date.parse(O.ended_at)-Date.parse(O.created_at))}),O.cost&&(O.cost.usd!==null||vi(O.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ua(O.cost,{ended:Co(O.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ht(O.created_at)})]})},O.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const L1=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function tK(e,n,s=Date.now()){var l;const r=e.analytics.filter,o=r.from?Math.round((Math.floor(s/864e5)*864e5-Date.parse(r.from))/864e5)+1:null,i=r.from?jv.some(d=>d.days===o)?`Activity in the last ${o} days`:`Activity since ${r.from.slice(0,10)}`:"All recorded activity";return r.agent?`${i}, of ${n??((l=e.perAgent.find(d=>d.agentId===r.agent))==null?void 0:l.name)??r.agent}`:i}const $s=e=>`#/runs/${encodeURIComponent(e)}`;function nK({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:l,onApprove:d,onHandBack:u,onRunAgain:f,onStop:h,problem:v,now:b=Date.now}){const m=oH(n.filter(T=>!is(T)&&!ml(T))),x=n.filter(T=>!T.imported_from&&(is(T)||ml(T))),[,y]=g.useState(0);g.useEffect(()=>{if(!r.length)return;const T=setInterval(()=>y(M=>M+1),1e3);return()=>clearInterval(T)},[r.length]);const[j,k]=g.useState([]),C=(T,M,F)=>{const I=e.find(G=>G.run_id===T),V=I?Hn(I):T;k(G=>[...G.filter(q=>q.runId!==T),...F?[{runId:T,what:M,title:V,text:F}]:[]])},N=d&&(async(T,M,F,I,V)=>{const G=await(V?d(T,M,F,I,V):d(T,M,F,I));return C(T,M,G),G}),S=u&&(async(T,M,F)=>{const I=await u(T,F);return C(T,`ask:${M.asked_at}`,I),I}),E=T=>{var F;const M=ll(T);return((F=T.pending)==null?void 0:F.kind)==="approval"?T.pending.id:M?`ask:${M.asked_at}`:null},$=NE(n),L=o.filter(T=>T.pending>0),A=L.reduce((T,M)=>T+M.pending,0),P=e.length+$+A;if(!P&&!r.length&&!v&&!j.length)return null;const O=b();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[P>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",P]})]}),v&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:v}),j.filter(T=>!e.some(M=>M.run_id===T.runId&&E(M)===T.what)).map(T=>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:$s(T.runId),className:"underline-offset-4 hover:underline",children:T.title}),": your answer wasn't taken. ",T.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(M=>M.filter(F=>F.runId!==T.runId)),children:"Dismiss"})]},T.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(T=>{var M,F,I;return T.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:$s(T.run_id),className:"text-body underline underline-offset-2",children:Hn(T)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(T.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},T.run_id):((M=T.pending)==null?void 0:M.kind)==="approval"?t.jsx(sK,{run:T,pending:T.pending,agentName:i(T.agent_id),at:O,onApprove:N},`${T.run_id}:${T.pending.id}`):ll(T)?t.jsx(rK,{run:T,ask:ll(T),agentName:i(T.agent_id),at:O,onHandBack:S},`${T.run_id}:${ll(T).asked_at}`):t.jsx(oK,{run:T,agentName:i(T.agent_id),at:O,onAnswer:l},`${T.run_id}:${((F=T.pending)==null?void 0:F.kind)==="question"?T.pending.asked_at:((I=T.pending)==null?void 0:I.kind)==="budget"?T.pending.at??"":""}`)})}),(m.length>0||x.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:[m.map(T=>t.jsx(lK,{message:T.message,runs:T.runs,agentName:i,at:O,onRunAgain:f},T.message)),x.map(T=>t.jsx(M1,{run:T,agentName:i(T.agent_id)},T.run_id))]})]}),L.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",A]}),t.jsx("ul",{children:L.map(T=>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:T.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:Fv(T.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(T.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},T.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(T=>is(T)||ml(T)?t.jsx(M1,{run:T,agentName:i(T.agent_id)},T.run_id):t.jsx(cK,{run:T,agentName:i(T.agent_id),at:O,onStop:h},T.run_id))})]})]})}function sK({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(AE,{compact:!0,pending:n,heading:t.jsx(Iy,{run:e,agentName:s,since:`asked ${Jl(n.requested_at,r)} ago`}),onAnswer:(i,l,d)=>o?d?o(e.run_id,n.id,i,l,d):o(e.run_id,n.id,i,l):Promise.resolve("Open the run to answer it.")})})}function rK({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(qE,{compact:!0,ask:n,heading:t.jsx(Iy,{run:e,agentName:s,since:`asked ${Jl(n.asked_at,r)} ago`}),open:t.jsx("a",{href:$s(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:o&&(i=>o(e.run_id,n,i))})})}function oK(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(aK,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(iK,{...e})}function aK({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:$s(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Hn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:yE(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:$s(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:$s(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Hn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function iK({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)??"",l=rH(i),[d,u]=g.useState(""),[f,h]=g.useState(!1),[v,b]=g.useState(null),[m,x]=g.useState(null),y=async k=>{k.preventDefault();const C=d.trim();if(!C||f)return;h(!0),b(null);const N=await r(e.run_id,C);h(!1),N?b(N):x(C)};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 ${Jl(o.asked_at,s)} ago`:void 0}),t.jsx("p",{className:"mt-2 text-base leading-snug",children:i}),m?t.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",m," · ",t.jsx("a",{href:$s(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:[l.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:ee("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(Fe,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:l.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(W,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),v&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:v})]})]})}function lK({message:e,runs:n,agentName:s,at:r,onRunAgain:o}){const[i,l]=g.useState(!1),[d,u]=g.useState(null),[f,h]=g.useState(new Set),v=n.filter(k=>!f.has(k.run_id)),b=n.length-v.length,m=async()=>{l(!0),u(null);const{started:k,problem:C}=await o(v);l(!1),u(C),h(N=>new Set([...N,...k]))},x=b>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",b===1?"1 run":`${b} runs`]});if(!v.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}),x]});const y=v[0],j=v.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:$s(y.run_id),className:"min-w-0 truncate hover:underline",children:Hn(y)})]}):t.jsxs("p",{className:"text-lead",children:[v.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(v.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:v.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:$s(k.run_id),className:"hover:underline",children:Hn(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:[Jl(y.ended_at??y.created_at,r)," ago"]}),x,t.jsx(W,{type:"button",size:"sm",disabled:i,onClick:()=>void m(),children:j?"Run again":"Run all again"})]})}function M1({run:e,agentName:n}){var r;const s=ml(e);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," · ",s?gh(s.runtime):Ro(is(e))]}),t.jsx("a",{href:$s(e.run_id),className:"text-lead hover:underline",children:Hn(e)}),e.status==="failed"&&t.jsx("p",{className:"mt-1 break-words text-small text-destructive-text",children:((r=e.error)==null?void 0:r.message)||"The run failed."}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Control and retries stay in ",s?"your CLI":"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:$s(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function cK({run:e,agentName:n,at:s,onStop:r}){var h;const[o,i]=g.useState(!1),[l,d]=g.useState(null),u=(h=e.cost)==null?void 0:h.usd,f=_l(e.cost)?`${ua(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${ua(e.cost)} so far`:vi(e.cost)?ua(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:$s(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:Hn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",Tl(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:$s(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),Nh(e.status,e.state,e.kind,kh,!0,e.error,e.review).canStop?t.jsx(W,{type:"button",size:"sm",disabled:o,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:$s(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),l&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:l})]})}const dK=[{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 iT(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 uK(e,n,s){const r=Sh(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 fK(e,n,s,r=yi()){const i=(await Kr(f=>e.listAgents({cursor:f}),f=>f.agents)).find(f=>f.definition.name===n.name&&!f.archived_at),l=(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(l,d,r.keyFor(n.name,d));return r.done(),u.run_id}const lT="agentrun.console.start-here.dismissed",mK={hello:mi,web:V1,plan:fA};function hK(){try{return localStorage.getItem(lT)==="true"}catch{return!1}}function pK({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:l}){const[d,u]=g.useState(hK),[f,h]=g.useState(!1),[v,b]=g.useState(!1),[m,x]=g.useState(null),[y,j]=g.useState(null),k=iT(e),C=async N=>{x(N.id),j(null);try{j(await s(N))}finally{x(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 underline-offset-4 hover:decoration-2",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(lT,"true")}catch{}},children:t.jsx(Oo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Ah,{}),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:()=>{b(!0),h(N=>!N)},children:["Run an agent here ",t.jsx(ui,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),v&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[l,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:dK.map(N=>{const S=uK(N,k,n),E=mK[N.id]??mi;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(E,{className:"size-4 text-primary-text","aria-hidden":!0}),N.name]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:N.shows}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:N.description}),S.ok?t.jsx(W,{type:"button",size:"sm",className:"mt-4 self-start",disabled:m!==null,onClick:()=>void C(N),children:m===N.id?"Starting…":"Try it"}):t.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:S.reason})]},N.id)})}):!l&&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 gK=["system","light","dark"],Eb="agentrun.theme",xK="(prefers-color-scheme: dark)",Gh=()=>{try{return globalThis.localStorage??null}catch{return null}},cT=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(xK):null;let Tb=null;function bK(e=Gh()){try{const n=e==null?void 0:e.getItem(Eb);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Rb=(e=Gh())=>Tb??bK(e);function vK(e,n=Gh()){Tb=null;try{e==="system"?n==null||n.removeItem(Eb):n==null||n.setItem(Eb,e)}catch{Tb=e}}function Ab(e,n=document.documentElement,s=cT()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function yK(e=document.documentElement,n=cT(),s=Gh()){Ab(Rb(s),e,n);const r=()=>{Rb(s)==="system"&&Ab("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const wK={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},jK={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},kK={system:["System",hi],light:["Light",EA],dark:["Dark",vA]};function NK(){const[e,n]=g.useState(()=>Rb()),s=r=>{vK(r),Ab(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:gK.map(r=>{const[o,i]=kK[r];return t.jsx(W,{variant:"ghost",size:"sm","aria-label":o,title:o,"aria-pressed":e===r,onClick:()=>s(r),className:ee("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 I1(){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 SK({active:e,settings:n=!1,triggers:s=!1,banners:r,building:o=!1,onBuild:i,onNavigate:l,onSignOut:d,onSignOutEverywhere:u,children:f}){const[h,v]=g.useState(!1),[b,m]=g.useState(!1),x=g.useRef(null),y=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{var P,O;b?(P=y.current)==null||P.focus():j.current&&((O=x.current)==null||O.focus())},[b]);const k=()=>{j.current=!0,m(!1)},[C,N]=g.useState(!0),S=e==="agents"||e==="runs"||e==="templates";g.useEffect(()=>{(S||o)&&N(!0)},[e,o]);const E=P=>{l?l(P):location.hash=jK[P],v(!1)},$=()=>{i?i():location.hash="#/agents/new",v(!1)},L=wK[e];g.useEffect(()=>{document.title=L?`${L} · AgentRun`:"AgentRun"},[L]);const A=g.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(W,{type:"button",size:"sm",onClick:()=>{var P;return(P=A.current)==null?void 0:P.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:()=>E("mission"),"aria-label":"AgentRun home",children:t.jsx(I1,{})}),t.jsx(W,{size:"icon","aria-label":"Navigation","aria-expanded":h,onClick:()=>v(P=>!P),children:t.jsx(pA,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:ee("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",h?"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:()=>E("mission"),"aria-label":"AgentRun home",children:t.jsx(I1,{})})}),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(Fr,{className:"w-full",active:e==="mission",onClick:()=>E("mission"),children:[t.jsx(Q1,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(Fr,{className:"w-full",active:e==="playground",onClick:()=>E("playground"),children:[t.jsx(Bm,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(Fr,{className:ee("w-full",S&&"text-primary-text"),"aria-expanded":C,"aria-controls":"agent-navigation",onClick:()=>N(P=>!P),children:[t.jsx(xd,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(ui,{className:ee("size-3.5 transition-transform",!C&&"-rotate-90"),"aria-hidden":!0})]}),t.jsxs("div",{id:"agent-navigation",hidden:!C,className:"space-y-0.5",children:[t.jsxs(Fr,{className:"w-full pl-8",active:o,onClick:$,children:[t.jsx(dA,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(Fr,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>E("agents"),children:[t.jsx(xd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(Fr,{className:"w-full pl-8",active:e==="templates",onClick:()=>E("templates"),children:[t.jsx(Km,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(Fr,{className:"w-full pl-8",active:e==="runs",onClick:()=>E("runs"),children:[t.jsx(Hd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(Fr,{className:"w-full",active:e==="triggers",onClick:()=>E("triggers"),children:[t.jsx(Wd,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(Fr,{className:"w-full",active:e==="dojo",onClick:()=>E("dojo"),children:[t.jsx(G_,{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(Fr,{className:"w-full",active:e==="settings",onClick:()=>E("settings"),children:[t.jsx(X1,{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(NK,{}),t.jsxs(W,{onClick:d,className:"w-full justify-start",children:[t.jsx(hA,{"aria-hidden":!0}),"Sign out"]}),u&&(b?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:P=>{P.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(W,{size:"xs",variant:"destructive",onClick:()=>{m(!1),u()},children:"Sign out everywhere"}),t.jsx(W,{size:"xs",ref:y,onClick:k,children:"Cancel"})]})]}):t.jsx(W,{size:"sm",variant:"ghost",ref:x,onClick:()=>m(!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(vH,{}),r,t.jsx("main",{ref:A,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const hx={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},P1={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 CK({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,onNewCode:o,problem:i=null,offer:l=null,host:d=typeof window>"u"?"":window.location.hostname}){const[u,f]=g.useState(""),[h,v]=g.useState([]),[b,m]=g.useState(""),[x,y]=g.useState(n??"");g.useEffect(()=>{n!==null&&y(n)},[n]);const[j,k]=g.useState(i),[C,N]=g.useState(!1),[S,E]=g.useState(null),[$,L]=g.useState(!1),A=async()=>{if(!(!o||$)){L(!0);try{E(await o()),k(null)}catch(I){E(null),k(I instanceof Error?I.message:String(I))}finally{L(!1)}}},P=e==="setup",O=P&&l!==null&&!("sessions"in l&&l.sessions===0),T=P&&(s||n!==null),M=e!=="token_link"&&u.length>0&&(!P||u===b&&u.length>=12)&&(!T||x.trim()!==""),F=async()=>{if(!M||!r)return;N(!0);const I=P&&l&&"candidates"in l?(l.candidates??[]).map(G=>G.id):[],V=await r(u,T&&x.trim()?x.trim():void 0,h.filter(G=>I.includes(G)));N(!1),k(V)};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:P1[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:P1[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:I=>{I.preventDefault(),F()},children:[T&&t.jsx(gt,{label:"Setup code",id:"setup-code",hint:qW(d).map((I,V)=>t.jsx("span",{className:ee("block leading-relaxed",V>0&&"mt-1.5"),children:I},V)),children:t.jsx(Fe,{name:"setup-code",value:x,onChange:I=>y(I.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),T&&o&&t.jsxs("div",{className:"!mt-3",children:[t.jsx(W,{type:"button",size:"sm",disabled:$,"aria-busy":$||void 0,onClick:()=>void A(),children:"Get a new code"}),S&&t.jsx("p",{className:"mt-2 text-small leading-relaxed text-foreground",role:"status",children:S})]}),t.jsx(gt,{label:hx[e].label,note:P?"12 characters or more.":void 0,children:t.jsxs("span",{className:ee(Cl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(ti,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Fe,{bare:!0,type:"password",value:u,onChange:I=>f(I.target.value),autoComplete:hx[e].autocomplete,autoFocus:!0,"aria-label":hx[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),P&&t.jsx(gt,{label:"Again",note:b&&b!==u?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ee(Cl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(ti,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Fe,{bare:!0,type:"password",value:b,onChange:I=>m(I.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),O&&t.jsx($K,{offer:l,chosen:h,onChange:v}),t.jsx(W,{type:"submit",variant:"solid",disabled:!M||C,"aria-busy":C||void 0,className:"w-full text-body",children:C?"Signing in":P?"Set password and continue":"Continue"}),j&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:j}),!P&&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 Xc=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,_K={"claude-code":"Claude Code",codex:"Codex",pi:"pi"},px="Import sessions from this machine";function $K({offer:e,chosen:n,onChange:s}){if("counting"in e)return t.jsx(gt,{group:!0,label:px,children:t.jsxs("p",{className:"flex items-center gap-2 text-small text-muted-foreground",role:"status",children:[t.jsx(ov,{}),"Looking for this machine's Claude Code, Codex and pi sessions…"]})});const r=e.candidates??[];if(e.sessions===null||e.projects===null||!r.length)return t.jsx(gt,{group:!0,label:px,children:t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:"This machine's sessions couldn't be listed, so there is nothing to choose here. To import them later, run agentrun-serve import with the server stopped."})});const o=r.filter(d=>n.includes(d.id)),i=o.length===r.length,l=Date.now();return t.jsx(gt,{group:!0,label:px,aside:t.jsx(W,{type:"button",size:"xs",variant:"ghost",onClick:()=>s(i?[]:r.map(d=>d.id)),children:i?"Clear":"Select all"}),note:`${Xc(e.sessions,"session")} in ${Xc(e.projects,"project")}, from Claude Code, Codex and pi. Tick the projects to import: each becomes an agent, each session a run you can read. Nothing is imported unless you tick it.${e.projects>r.length?` The ${r.length.toLocaleString("en-US")} most recently active are listed.`:""}`,hint:t.jsx("span",{"aria-live":"polite",children:o.length?`${Xc(o.length,"project")}, ${Xc(o.reduce((d,u)=>d+u.sessions,0),"session")} chosen.`:"None chosen: nothing will be imported."}),children:t.jsx("div",{className:"max-h-56 space-y-3 overflow-y-auto border p-3",children:r.map(d=>t.jsx(Y2,{name:"import",value:d.id,checked:n.includes(d.id),onChange:u=>s(u.target.checked?[...n,d.id]:n.filter(f=>f!==d.id)),label:t.jsx("span",{className:"break-all font-mono",children:d.name}),note:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block",children:[Xc(d.sessions,"session"),d.sources.map(u=>_K[u]??u).join(", "),...d.last_active?[`active ${Jl(d.last_active,l)} ago`]:[]].join(" · ")}),t.jsx("span",{className:"block break-all font-mono",children:d.path})]})},d.id))})})}function EK({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(W,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const TK=1e4;function D1(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 l=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...l==="remote"||l==="observe"?{connectionSource:l}:{}}}if(e==="#/agents/new")return{section:"agents",agent:null};if(s=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),s){const l=new URLSearchParams(s[2]).get("tool");return{section:"agents",agent:decodeURIComponent(s[1]),edit:!0,...l?{tool:l}:{}}}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 l=new URLSearchParams(e.split("?")[1]??""),d=l.get("agent"),u=l.get("operation"),f=l.get("draft");if(u==="apply-template"){const h=l.get("template");return{section:"playground",operation:u,...h?{template:h}:{},...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"&&Pm.includes(l.get("status"))?{status:l.get("status")}:{},...u==="list-runs"&&l.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(e==="#/triggers/new-email")return{section:"triggers",trigger:null,kind:"email"};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 l=Fz(s[1]);return{section:"settings",settings:"mcp",signIn:qz(s[1]),...l?{add:l}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const l=kH(s[1]);return{section:"settings",settings:"github",...l?{github:l}:{}}}if(s=e.match(/^#\/settings(?:\/(keys|tools|email|computers|workspace|webhook|slack))?$/),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&&Pm.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function RK({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 gx;function AK(){if(!gx){const{code:e,rest:n}=X$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),gx={code:e}}return gx.code}const OK=e=>Math.min(1e3*2**e,3e4),dT=1e3,LK=30;function MK(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.":e.state==="failed"?"The import of this machine's sessions was given up before it finished. The server's log says why.":`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 IK(){const[e]=g.useState(jP),[n,s]=g.useState(null),[r,o]=g.useState(!1),i=g.useRef(null);i.current=n;const l=g.useRef(!1),d=g.useRef(async()=>{}),u=g.useMemo(()=>oP({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,h]=g.useState(AK);g.useEffect(()=>{if(n!=="setup")return;const $=()=>{const{code:L,rest:A}=X$(location.hash);L!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${A}`),h(L))};return window.addEventListener("hashchange",$),$(),()=>window.removeEventListener("hashchange",$)},[n]);const[v,b]=g.useState(!1),m=async()=>{const $=await u.session(),L=vy($)?await u.listAgents().then(()=>200,A=>A instanceof Ue?A.status:0):void 0;return{mode:HW($,L),codeNeeded:BW($)}},x=async()=>{const $=await m();return b($.codeNeeded),$.mode},y=async()=>s(await x());d.current=async()=>{if(!(i.current!=="signed_in"||l.current)){l.current=!0;try{const $=await x();$!=="signed_in"&&i.current==="signed_in"&&(o(!0),s($))}catch{}finally{l.current=!1}}};const[j,k]=g.useState(null),[C,N]=g.useState(0);g.useEffect(()=>{let $=!0,L;return m().then(A=>{!$||i.current!==null||(b(A.codeNeeded),s(A.mode),k(null))},A=>{if(!$||i.current!==null)return;const P=OK(C),O=A instanceof Ue?A:null,T=(O==null?void 0:O.code)==="http_error",M=T&&[502,503,504].includes(O.status);k({problem:O===null?Gt(A):M?`Its address answered ${O.status}, not the server.`:`GET /v2/auth/session answered ${O.status}${T?", not as this server answers":`: ${O.message}`}`,starting:M}),L=setTimeout(()=>N(F=>F+1),P)}),()=>{$=!1,clearTimeout(L)}},[u,C]);const[S,E]=g.useState(null);return g.useEffect(()=>{if(n!=="setup")return;let $=!0;return(async()=>{for(let L=!1;$;){const A=await u.setupImport().then(P=>P,()=>{});if(!$)return;if(A===void 0&&L)return void E({projects:null,sessions:null});if(A!==void 0&&(!A||!("counting"in A||"sessions"in A)||(E(A),L=!0,!("counting"in A))))return;await new Promise(P=>setTimeout(P,dT))}})(),()=>{$=!1}},[u,n]),n===null&&j!==null?t.jsx(EK,{problem:j.problem,starting:j.starting,onRetry:()=>N($=>$+1)}):n===null?t.jsx(HN,{connection:e,children:t.jsx(PK,{})}):n!=="signed_in"?t.jsx(CK,{mode:n,code:f,codeNeeded:v,offer:S,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async($,L,A)=>{try{return await(n==="setup"?u.setup($,L,A):u.signIn($)),o(!1),s("signed_in"),null}catch(P){return P instanceof Ue&&P.status===403&&n==="setup"&&await y().catch(()=>{}),P instanceof Ue?YW(P):P instanceof Error?P.message:String(P)}},onNewCode:async()=>{try{return GW(window.location.hostname,await u.setupCode())}catch($){throw $ instanceof Ue&&$.status===403&&await y().catch(()=>{}),new Error($ instanceof Ue?VW($):$ instanceof Error?$.message:String($))}}},n):t.jsx(HN,{connection:e,children:t.jsx(DK,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function PK(){return Ny().state==="offline"?t.jsx(yH,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function DK(e){const n=g.useMemo(lu,[e.v2]);return t.jsx(zK,{...e},n)}function zK({v2:e,onSignedOut:n}){var xu,_a,$a,Io,Ea,bu,vu,ki,Zl,Ni,Po,yu,Si,It,ec,tc,Ci,nc,sc,rc,_i,Ta,pr,gr,xr,Do,zo,br,wu,oc,Fo,ju,ac,Ra;const{writable:s,whyNot:r}=Y8(e),[o,i]=g.useState(null),[l,d]=g.useState(()=>D1()),[u,f]=g.useState(null),h=((_a=(xu=u==null?void 0:u.features)==null?void 0:xu.triggers)==null?void 0:_a.routes)===!0,[v,b]=g.useState(new Map);g.useEffect(()=>{if(!h)return;let be=!0;return e.listTriggers().then(Oe=>{be&&b(new Map(Oe.triggers.map(He=>[He.id,{name:He.name,kind:He.source.kind}])))},()=>{}),()=>{be=!1}},[e,h,l.section,l.trigger]);const[m,x]=g.useState(null),[y,j]=g.useState(null),[k,C]=g.useState(0),[N,S]=g.useState("30d"),E=N==="7d"?7:30,$=yv(e,{active:l.section==="mission"||l.section==="runs"&&!l.run&&!l.runsOf&&!l.archived&&!l.status,days:E}),[L,A]=g.useState(null),[P,O]=g.useState(!1),[T,M]=g.useState(!1),F=g.useRef(!1),[I,V]=g.useState(null),[G,q]=g.useState(null),[H,U]=g.useState(null),[Q,D]=g.useState(0),Y=g.useRef(null),[K,Z]=g.useState(!1),[se,ie]=g.useState(!1),[Ne,he]=g.useState(!1),[ve,Ee]=g.useState(null),[ye,pe]=g.useState(null),[Pe,ue]=g.useState(!1),[ge,Te]=g.useState({}),[Xe,je]=g.useState(!1),fe=g.useRef(0),[De,te]=g.useState([]),[Ie,We]=g.useState(null),[rt,ot]=g.useState(null),wt=g.useRef(-1),[jt,we]=g.useState(null),[ze,st]=g.useState(0),xe=g.useRef(0),Be=be=>{Df(be)||(location.hash=be)},[$t,et]=g.useState(null),[dt,Lt]=g.useState(0);g.useEffect(()=>{let be=!0;return(async()=>{let Oe=!1;for(let He=0;be&&He<LK;){const kt=await e.setupImport().then(yt=>yt,()=>{});if(!be)return;if(kt===void 0)He+=1;else{if(He=0,!kt||!("state"in kt))return;if(et(kt),kt.state!=="running")return void(Oe&&Lt(yt=>yt+1));Oe=!0}await new Promise(yt=>setTimeout(yt,dT))}})(),()=>{be=!1}},[e]),g.useEffect(()=>{const be=()=>{const Oe=T7();Df(location.hash,()=>{Oe&&history.go(-Oe)})?Oe&&history.go(Oe):d(D1())};return window.addEventListener("hashchange",be),()=>window.removeEventListener("hashchange",be)},[]),g.useEffect(()=>E7(),[]);const qt=g.useRef(0),At=g.useRef(!1),Et=()=>{const be=++qt.current;return e.capabilities().then(Oe=>(be===qt.current&&f(Oe),!0),()=>!1)};g.useEffect(()=>{Et()},[e]),g.useEffect(()=>{if(fe.current&&l.section!=="runs"&&l.section!=="mission"&&l.section!=="triggers"&&wt.current===dt)return;wt.current=dt;const be=++fe.current;je(!1),Promise.allSettled([!1,!0].map(Oe=>Kr(He=>e.listAgents({archived:Oe,cursor:He}),He=>He.agents))).then(Oe=>{if(be!==fe.current)return;const He=Object.fromEntries(Oe.flatMap(yt=>yt.status==="fulfilled"?yt.value:[]).map(yt=>[yt.agent_id,yt.definition.name??yt.agent_id])),kt=Oe.every(yt=>yt.status==="fulfilled");Te(yt=>kt?He:{...yt,...He}),je(kt)})},[e,l,dt]);const B={status:l.status,archived:l.archived};g.useEffect(()=>{if(l.section!=="runs"||l.run)return;const be=++xe.current;Ee(null),we(null),(l.runsOf?e.listAgentRuns(l.runsOf,50,null,B):e.listRuns(50,null,B)).then(Oe=>{be===xe.current&&(Ee(Oe.runs),pe(Oe.next_cursor))}).catch(Oe=>{be===xe.current&&we(Yt(Oe,"the runs"))})},[e,l,dt,ze]);const J=be=>{var Oe;return ge[be]??((Oe=pn==null?void 0:pn.find(He=>He.agent_id===be))==null?void 0:Oe.definition.name)??(Xe?be:"")},de=u,_e={harnesses:(de==null?void 0:de.harnesses)??[],tools:hD(de==null?void 0:de.tools),thinking:(($a=de==null?void 0:de.features)==null?void 0:$a.thinking)??[],...typeof((Io=u==null?void 0:u.limits)==null?void 0:Io.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},at=y6(de==null?void 0:de.tools),qe=j6(de==null?void 0:de.tools),ft=[...(bu=(Ea=u==null?void 0:u.features)==null?void 0:Ea.tool_keys)!=null&&bu.routes?["keys"]:[],...at.length||qe.length?["tools"]:[],"mcp","github","email","computers","workspace",...(ki=(vu=u==null?void 0:u.features)==null?void 0:vu.webhooks)!=null&&ki.routes?["webhook"]:[],...(Ni=(Zl=u==null?void 0:u.features)==null?void 0:Zl.slack)!=null&&Ni.routes?["slack"]:[]],$n=be=>Be({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${ft[0]??"keys"}`}[be]),en=g.useRef(yi()).current,qn=async be=>{const Oe=iT(_e.harnesses);if(!Oe)return"This server has no model to run it on yet.";try{const He=await fK(e,be,Oe,en);return Be(`#/runs/${encodeURIComponent(He)}`),null}catch(He){return Gt(He)}},kn=((m==null?void 0:m.analytics.by_source)??[]).filter(be=>be.source!=="live").reduce((be,Oe)=>be+Oe.runs,0),[pn,Gn]=g.useState(null),[tt,xt]=g.useState([]),[Rt,gn]=g.useState(null),dn=g.useRef(Rt);dn.current=Rt;const[re,Me]=g.useState(null),[bt,Tt]=g.useState(0),Bt=g.useRef(0);g.useEffect(()=>{Gn(null),Me(null),gn(null),dn.current=null},[e,l.section,l.operation,l.playgroundAgent]),g.useEffect(()=>{if(l.section!=="playground"||l.operation)return;Me(null);const be=++Bt.current;return Kr(Oe=>e.listAgents({cursor:Oe}),Oe=>Oe.agents).then(Oe=>{var yt;if(be!==Bt.current)return;const He=Oe.filter(As=>!As.archived_at),kt=dn.current??l.playgroundAgent;if(kt&&!He.some(As=>As.agent_id===kt)){Gn(null),gn(null),Me("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Gn(Oe),gn(kt??((yt=He[0])==null?void 0:yt.agent_id)??null)}).catch(Oe=>{if(be===Bt.current){const He=Yt(Oe,"the agents");Me(`${He.why} ${He.next}${He.said?` (${He.said})`:""}`)}}),()=>{Bt.current++}},[e,l.section,l.operation,l.playgroundAgent,bt,dt]),g.useEffect(()=>{if(l.section!=="mission")return;let be=!0;F.current=!0,j(null),M(!0);const Oe=bm(N);return Promise.all([e.statsOver({...Oe?{from:Oe}:{},...L?{agent:L}:{}}),P?Promise.resolve({runs:[]}):L?e.listAgentRuns(L,10):e.listRuns(10)]).then(([He,kt])=>{be&&(x(EP(He,kt.runs)),L||U(yt=>yt||iH(kt.runs,He.analytics.by_source)))}).catch(He=>{be&&j(Yt(He,"Mission Control"))}).finally(()=>{be&&(F.current=!1,M(!1))}),()=>{be=!1,F.current=!1}},[e,l.section,k,N,L,P,dt]),_E(()=>C(be=>be+1)),g.useEffect(()=>{if(l.section!=="mission")return;const be=()=>{!document.hidden&&!F.current&&C(He=>He+1)};window.addEventListener("focus",be),document.addEventListener("visibilitychange",be);const Oe=setInterval(be,15e3);return()=>{window.removeEventListener("focus",be),document.removeEventListener("visibilitychange",be),clearInterval(Oe)}},[l.section]),g.useEffect(()=>{if(l.section!=="mission"){Y.current=null,We(null),ot(null);return}let be=!0;const Oe=Y,He=In=>Kr(vs=>e.listRuns(50,vs,{status:In}),vs=>vs.runs,2),kt=()=>Kr(In=>e.listAgents({archived:!1,cursor:In}),In=>In.agents).then(In=>{be&&(te(In.filter(vs=>wm(vs)>0).map(vs=>({agent_id:vs.agent_id,name:vs.definition.name??vs.agent_id,pending:wm(vs)}))),We(In),ot(null))},In=>{be&&ot(Gt(In))}),As=cH(()=>Promise.allSettled([He("input_required"),He("failed"),He("working"),kt()]).then(([In,vs,ic])=>{var cc,yr,$i;if(!be)return;const vr=[In,vs,ic],lc=Date.now()-aH;if(q(DN(null,vr).problem),((cc=vr[0])==null?void 0:cc.status)==="fulfilled"&&Z(!0),((yr=vr[1])==null?void 0:yr.status)==="fulfilled"){ie(!0);const ro=vr[1].value.map(Os=>Os.run_id),oo=Oe.current;oo&&ro.some(Os=>!oo.has(Os))&&C(Os=>Os+1),Oe.current=new Set(ro)}(($i=vr[2])==null?void 0:$i.status)==="fulfilled"&&he(!0),V(ro=>{const{needs:oo}=DN(ro,vr);return{asking:oo.asking.filter(SE),failed:oo.failed.filter(Os=>Date.parse(Os.ended_at??Os.created_at)>lc),live:oo.live}})}),1e4);return()=>{be=!1,As()}},[e,l.section,Q]);const On=g.useRef(g6()).current,Ln=()=>setTimeout(()=>D(be=>be+1),2500),Ge=async(be,Oe)=>{try{return await F_(On(be),be,Oe,e.sendMessage),Ln(),null}catch(He){return Gt(He)}},oe=g.useRef(new Map).current,Re=async be=>{const Oe=[];try{for(const He of be){const kt=lH(He.kind==="workflow"?He:await e.getRun(He.run_id));if("refusal"in kt)throw new Error(kt.refusal);const yt=oe.get(He.run_id)??lu();oe.set(He.run_id,yt),await e.startRun(He.agent_id,kt.body,yt),Oe.push(He.run_id)}return Ln(),{started:Oe,problem:null}}catch(He){return Oe.length&&Ln(),{started:Oe,problem:Gt(He)}}},Ye=async be=>{try{return await e.stop(be),Ln(),null}catch(Oe){return Gt(Oe)}},Mt=async(be,Oe,He,kt,yt)=>{let As=null;try{await e.answerApproval(be,Oe,He,kt,yt)}catch(In){As=RE(In)}return D(In=>In+1),As},Nn=async(be,Oe)=>{let He=null;try{await e.handBackComputer(be,Oe)}catch(kt){He=Nb(kt,"hand")}return D(kt=>kt+1),He},pt=g.useRef(0);g.useEffect(()=>{const be=++pt.current;xt([]),Rt&&Kr(Oe=>e.listRevisions(Rt,Oe),Oe=>Oe.revisions).then(Oe=>{be===pt.current&&xt(Oe)}).catch(()=>{})},[e,Rt]);const Mn=async(be,Oe,He)=>{const kt=performance.now();try{const yt=await e.startRun(be,Oe,He);return{status:yt.status,ms:Math.round(performance.now()-kt),body:yt.run,runId:yt.run.run_id}}catch(yt){return ky(yt,Math.round(performance.now()-kt))}},Kn=((Po=u==null?void 0:u.features)==null?void 0:Po.efforts)??[],Ts=u?((yu=u.features)==null?void 0:yu.learning)??null:void 0;_e.learning=Ts??void 0;const Qt=(Si=u==null?void 0:u.models)==null?void 0:Si.ready;g.useEffect(()=>{var kt;if(Qt!==!1&&((kt=u==null?void 0:u.learning_model)==null?void 0:kt.ready)!==!1)return;const be=()=>{At.current||(At.current=!0,Et().finally(()=>{At.current=!1}))},Oe=()=>Et(),He=setInterval(be,TK);return window.addEventListener("focus",Oe),()=>{clearInterval(He),window.removeEventListener("focus",Oe)}},[e,Qt,(It=u==null?void 0:u.learning_model)==null?void 0:It.ready]);const[Vs,so]=g.useState(null);g.useEffect(()=>{if(Qt!==!1)return;let be=!0;return e.chatGPT().then(Oe=>{be&&so(hm(Oe))},()=>{be&&so(null)}),()=>{be=!1}},[e,Qt]);const[ji,Rs]=g.useState(!1),Kh=be=>{so(be),(be.state==="pending"||be.state==="signed_in")&&Rs(!0),be.state==="signed_in"&&Et()},Zn=(ec=pn==null?void 0:pn.find(be=>be.agent_id===Rt))==null?void 0:ec.definition,Vh=(Zn==null?void 0:Zn.native)||is(Zn),gu=l.operation?l.playgroundAgent:Rt??l.playgroundAgent;return t.jsx(bE.Provider,{value:v,children:t.jsx(SK,{active:l.section,building:l.section==="agents"&&l.agent===null,onBuild:()=>Be("#/agents/new"),settings:ft.length>0,triggers:h,onNavigate:$n,onSignOut:()=>{const be=()=>void e.signOut().then(n,Oe=>i(Oe instanceof Ue?Oe.message:"The sign-out did not reach the server. Try again."));Df(null,be)||be()},onSignOutEverywhere:()=>{const be=()=>void e.signOutEverywhere().then(n,Oe=>i(Oe instanceof Ue?Oe.message:"The sign-out did not reach the server. Try again."));Df(null,be)||be()},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]}),$t&&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:MK($t)}),$t.state!=="running"&&t.jsx(W,{size:"xs",type:"button",onClick:()=>et(null),children:"Dismiss"})]})]}),children:l.section==="settings"?t.jsx(J9,{active:l.settings??"keys",offered:ft,children:l.settings==="tools"?t.jsx(jH,{v2:e,choices:at,gates:qe,harnesses:_e.harnesses,mcp:!!((tc=u==null?void 0:u.features)!=null&&tc.mcp_client),onSaved:Et,onOpen:Et}):l.settings==="mcp"?t.jsx(TH,{v2:e,signIn:l.signIn,add:l.add,writable:s,whyNot:r,choices:at}):l.settings==="github"?t.jsx(_H,{v2:e,returned:l.github}):l.settings==="email"?t.jsx(XH,{v2:e,writable:s,whyNot:r}):l.settings==="computers"?t.jsx(l7,{v2:e,writable:s,whyNot:r}):l.settings==="workspace"?t.jsx(v7,{v2:e,writable:s,whyNot:r}):l.settings==="webhook"?t.jsx(e7,{v2:e}):l.settings==="slack"?t.jsx(s7,{v2:e,writable:s,whyNot:r}):t.jsx(pH,{v2:e,onChange:Et,writable:s,whyNot:r,harnesses:_e.harnesses,plan:t.jsxs(t.Fragment,{children:[t.jsx(Z8,{v2:e,writable:s,whyNot:r,onChange:()=>void Et()}),t.jsx(oU,{v2:e,writable:s,whyNot:r,onChange:()=>void Et()}),t.jsx(dU,{v2:e,writable:s,whyNot:r,onChange:()=>void Et()})]})})}):l.section==="dojo"?t.jsx(W6,{v2:e,server:Ts,modelAccess:u==null?void 0:u.learning_model},dt):l.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(eK,{observed:$,agents:Ie,agentsError:rt,view:m,error:y,onRetry:()=>C(be=>be+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(W,{size:"icon","aria-label":"Refresh Mission Control",disabled:T,onClick:()=>{C(be=>be+1),D(be=>be+1),$.refresh()},children:t.jsx(pi,{className:"size-4","aria-hidden":!0})}),P&&L?t.jsx(Ut,{label:"Query",prompt:h5(location.origin,L,bm(N)),playgroundHref:bv(L),playgroundLabel:"Connected agent"}):t.jsx(Ut,{label:"Query",prompt:bh(location.origin,L??void 0),playgroundHref:wv(L??void 0)}),t.jsx(Ah,{variant:"primary"})]}),scope:{range:N,onRange:S,agent:L,onAgent:be=>{var Oe;O(!!be&&!!((Oe=$.data)!=null&&Oe.sessions.some(He=>He.id===be))),A(be)},refreshing:T&&m!==null},asking:I&&K?I.asking.length:null,failed:I&&se?NE(I.failed):null,live:I&&Ne?I.live.length:null,needsYou:I&&t.jsx(nK,{asking:I.asking,failed:I.failed,failedAll:m==null?void 0:m.runs.failed,live:I.live,learning:De,problem:G,agentName:J,onAnswer:Ge,onApprove:Mt,onHandBack:Nn,onRunAgain:Re,onStop:Ye}),startHere:H===!1&&!((Ci=$.data)!=null&&Ci.sessions.length)?t.jsx(pK,{harnesses:_e.harnesses,tools:_e.tools,onTry:qn,imported:kn,keySettings:((sc=(nc=u==null?void 0:u.features)==null?void 0:nc.tool_keys)==null?void 0:sc.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||ji)?t.jsx(BH,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:Et,writable:s,whyNot:r,plan:Vs,harnesses:_e.harnesses,onPlan:Kh,onDone:()=>Rs(!1)}):void 0}):void 0})})}):l.section==="templates"?t.jsx(RN,{v2:e,name:l.template,install:l.install,go:Be},l.install!==void 0?`install:${l.install}`:l.template??""):l.section==="triggers"?t.jsx(n9,{v2:e,view:{trigger:l.trigger,kind:l.kind,edit:l.edit},go:Be,agentName:J,minEvery:(_i=(rc=u==null?void 0:u.features)==null?void 0:rc.triggers)==null?void 0:_i.min_every_s,failuresToPause:(pr=(Ta=u==null?void 0:u.features)==null?void 0:Ta.triggers)==null?void 0:pr.failures_to_pause,publicUrl:(xr=(gr=u==null?void 0:u.features)==null?void 0:gr.triggers)==null?void 0:xr.public_url}):l.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("header",{className:ee(Lr,"gap-2 px-5"),children:t.jsxs("h1",{className:ha,children:[t.jsx(Bm,{className:"size-4","aria-hidden":!0}),"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(Ft,{id:"api-operation",label:"API operation",steady:!0,value:l.operation??"run",onChange:be=>{const Oe=gu,He=new URLSearchParams;be!=="run"&&He.set("operation",be),be!=="create-agent"&&be!=="apply-template"&&Oe&&He.set("agent",Oe),Be(`#/playground${He.size?`?${He}`:""}`)},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:!gu}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:l.operation==="apply-template"?`/v2/templates/${l.template?encodeURIComponent(l.template):"{template}"}/apply`:l.operation==="list-runs"?l.playgroundAgent?`/v2/agents/${l.playgroundAgent}/runs`:"/v2/runs":l.operation==="create-agent"?"/v2/agents":l.operation==="edit-agent"?`/v2/agents/${l.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),l.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(RN,{v2:e,name:l.template,go:Be,playground:!0,draft:l.draft},l.template??"")}):l.operation==="list-runs"?t.jsx(V9,{v2:e,origin:location.origin,agentId:l.playgroundAgent,filter:{status:l.status,archived:l.archived}},`list:${l.playgroundAgent??""}:${l.status??""}:${l.archived??!1}`):l.operation?t.jsx(Y9,{v2:e,operation:l.operation,origin:location.origin,agentId:l.playgroundAgent,draft:l.draft,harnesses:_e.harnesses,routePrefix:(Do=de==null?void 0:de.models)==null?void 0:Do.route_prefix},`${l.operation}:${l.playgroundAgent??""}:${l.draft??""}`):t.jsxs(t.Fragment,{children:[!Vh&&((zo=u==null?void 0:u.models)==null?void 0:zo.ready)===!1&&t.jsx(qH,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((wu=(br=u.features)==null?void 0:br.tool_keys)==null?void 0:wu.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(Vs==null?void 0:Vs.state)==="signed_out"||(Vs==null?void 0:Vs.state)==="expired"}),re&&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: ",re]}),t.jsx(W,{size:"sm",className:"mt-3",type:"button",onClick:()=>Tt(be=>be+1),children:"Try again"})]}),pn&&t.jsx(G9,{agents:pn.filter(be=>!be.archived_at),revisions:tt,efforts:Kn,origin:location.origin,agentId:Rt??void 0,onAgent:gn,onSend:Mn,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:be=>Be(`#/runs/${encodeURIComponent(be)}`),live:be=>t.jsx(A1,{v2:e,runId:be,caps:u,agentName:J},be)})]})]}):l.section==="agents"?l.observation?t.jsx(cP,{v2:e,sessionId:l.observation,go:Be}):l.nativeConnect?t.jsx(z8,{v2:e,go:Be,initialSource:l.connectionSource}):l.agent===void 0?t.jsx(F8,{v2:e,archived:!!l.archived,go:Be,learning:Ts},dt):l.agent===null?t.jsx(O9,{origin:location.origin,v2:e}):l.agent!==null&&!l.edit?t.jsx(L6,{v2:e,agentId:l.agent,tab:l.tab,learning:Ts,routePrefix:(oc=de==null?void 0:de.models)==null?void 0:oc.route_prefix,harnesses:_e.harnesses,efforts:Kn,limits:u==null?void 0:u.limits,places:L0(u),go:Be},l.agent):t.jsx(U8,{v2:e,choices:at,gates:qe,focusTool:l.tool,caps:{..._e,routePrefix:(Fo=de==null?void 0:de.models)==null?void 0:Fo.route_prefix,decisionProvider:uD(u==null?void 0:u.workflows),places:L0(u),mcp:!!((ju=u==null?void 0:u.features)!=null&&ju.mcp_client),mcpHarnesses:(Ra=(ac=u==null?void 0:u.features)==null?void 0:ac.mcp_client)==null?void 0:Ra.harnesses},agentId:l.agent,go:Be},`${l.agent??"new"}:${l.tool??""}`):l.run?t.jsx(A1,{v2:e,runId:l.run,caps:u,agentName:J},l.run):t.jsx(I9,{observations:!l.runsOf&&!l.archived&&!l.status?$:void 0,runs:ve,agentName:J,agentId:l.runsOf,error:jt,onRetry:()=>st(be=>be+1),onOpen:be=>Be(`#/runs/${encodeURIComponent(be)}`),loadingMore:Pe,filter:B,onFilter:be=>Be(RK({runsOf:l.runsOf,...be})),onMore:ye?()=>{const be=xe.current;ue(!0),(l.runsOf?e.listAgentRuns(l.runsOf,50,ye,B):e.listRuns(50,ye,B)).then(Oe=>{be===xe.current&&(Ee(He=>Zx(He??[],Oe.runs)),pe(Oe.next_cursor),we(null))}).catch(Oe=>we(Yt(Oe,"more runs"))).finally(()=>ue(!1))}:void 0})})})}yK();VR.createRoot(document.getElementById("root")).render(t.jsx(g.StrictMode,{children:t.jsx(i5,{children:t.jsx(IK,{})})}));
|