@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.35

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.
Files changed (227) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +84 -16
  3. package/dist/adapters.d.ts +3 -0
  4. package/dist/adapters.js +7 -0
  5. package/dist/agent-rows.d.ts +1 -0
  6. package/dist/agents-store.js +17 -2
  7. package/dist/archil-settings.d.ts +11 -1
  8. package/dist/archil-settings.js +10 -0
  9. package/dist/bash-read-only.d.ts +13 -0
  10. package/dist/bash-read-only.js +77 -0
  11. package/dist/browser-cost.d.ts +2 -2
  12. package/dist/browser-cost.js +6 -4
  13. package/dist/budget.d.ts +0 -5
  14. package/dist/budget.js +0 -5
  15. package/dist/cap.d.ts +6 -3
  16. package/dist/cap.js +7 -4
  17. package/dist/cli.js +32 -5
  18. package/dist/computer-keys.d.ts +20 -10
  19. package/dist/computer-keys.js +36 -57
  20. package/dist/computer-setting.d.ts +6 -5
  21. package/dist/computer-setting.js +54 -26
  22. package/dist/computers.d.ts +9 -4
  23. package/dist/computers.js +4 -2
  24. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  25. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  26. package/dist/console/index.html +2 -2
  27. package/dist/content-filter.d.ts +7 -0
  28. package/dist/content-filter.js +23 -0
  29. package/dist/decision-cap.d.ts +7 -29
  30. package/dist/decision-cap.js +3 -94
  31. package/dist/errors.d.ts +1 -0
  32. package/dist/errors.js +3 -0
  33. package/dist/explain.js +3 -1
  34. package/dist/github-connection.js +25 -7
  35. package/dist/github-faux.d.ts +26 -0
  36. package/dist/github-faux.js +76 -0
  37. package/dist/github.d.ts +6 -2
  38. package/dist/github.js +5 -3
  39. package/dist/graph-served.d.ts +5 -3
  40. package/dist/graph-served.js +14 -6
  41. package/dist/graph-view.js +5 -2
  42. package/dist/harness-opencode/harness.js +0 -1
  43. package/dist/harness-opencode/host/policy.js +2 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/learn/check.d.ts +3 -1
  47. package/dist/learn/check.js +3 -3
  48. package/dist/learn/folder.d.ts +6 -3
  49. package/dist/learn/folder.js +7 -16
  50. package/dist/learn/grade.d.ts +4 -1
  51. package/dist/learn/grade.js +43 -5
  52. package/dist/learn/index.d.ts +2 -2
  53. package/dist/learn/index.js +2 -2
  54. package/dist/learn/learning.sh +1 -14
  55. package/dist/learn/notes.d.ts +14 -3
  56. package/dist/learn/notes.js +16 -6
  57. package/dist/learn/reflect.js +5 -3
  58. package/dist/learn/skills.d.ts +48 -5
  59. package/dist/learn/skills.js +97 -21
  60. package/dist/learned-nodes.d.ts +14 -0
  61. package/dist/learned-nodes.js +8 -0
  62. package/dist/learned-workflow.d.ts +9 -5
  63. package/dist/learned-workflow.js +53 -9
  64. package/dist/learning-routes.d.ts +41 -0
  65. package/dist/learning-routes.js +94 -26
  66. package/dist/learning-run.d.ts +7 -5
  67. package/dist/learning-run.js +9 -6
  68. package/dist/learning.d.ts +0 -22
  69. package/dist/learning.js +0 -16
  70. package/dist/llm.d.ts +4 -1
  71. package/dist/llm.js +4 -2
  72. package/dist/mcp-gateway.d.ts +6 -0
  73. package/dist/mcp-gateway.js +11 -1
  74. package/dist/mcp-servers-store.d.ts +12 -12
  75. package/dist/model.d.ts +3 -0
  76. package/dist/model.js +8 -0
  77. package/dist/openapi.js +37 -13
  78. package/dist/paid-calls.js +1 -1
  79. package/dist/pause.d.ts +2 -19
  80. package/dist/pause.js +5 -74
  81. package/dist/port-models.d.ts +10 -3
  82. package/dist/port-models.js +26 -6
  83. package/dist/propose.d.ts +2 -0
  84. package/dist/propose.js +1 -10
  85. package/dist/run-launch.d.ts +5 -3
  86. package/dist/run-launch.js +6 -5
  87. package/dist/run-learning-served.d.ts +11 -0
  88. package/dist/run-reads-over-store.d.ts +4 -2
  89. package/dist/run-reads-over-store.js +10 -8
  90. package/dist/run-timeline-served.js +12 -2
  91. package/dist/run-view.d.ts +30 -14
  92. package/dist/run-view.js +60 -32
  93. package/dist/runnable.d.ts +4 -1
  94. package/dist/runnable.js +14 -2
  95. package/dist/runner/adapter-loop.d.ts +30 -4
  96. package/dist/runner/adapter-loop.js +253 -29
  97. package/dist/runner/adapter-run-spec.d.ts +21 -0
  98. package/dist/runner/adapter-run-spec.js +104 -28
  99. package/dist/runner/adapters/pi.d.ts +29 -1
  100. package/dist/runner/adapters/pi.js +95 -23
  101. package/dist/runner/beside.d.ts +8 -0
  102. package/dist/runner/beside.js +18 -0
  103. package/dist/runner/claim-secrets.d.ts +6 -0
  104. package/dist/runner/claim-secrets.js +15 -1
  105. package/dist/runner/cli-run-spec.d.ts +3 -0
  106. package/dist/runner/cli-run-spec.js +123 -34
  107. package/dist/runner/conformance/harness.d.ts +1 -0
  108. package/dist/runner/conformance/harness.js +5 -5
  109. package/dist/runner/github-app.d.ts +7 -2
  110. package/dist/runner/github-app.js +46 -15
  111. package/dist/runner/harness-loops.d.ts +6 -1
  112. package/dist/runner/harness-loops.js +23 -0
  113. package/dist/runner/journal-kinds.d.ts +38 -2
  114. package/dist/runner/journal-kinds.js +23 -0
  115. package/dist/runner/learning-end.js +88 -16
  116. package/dist/runner/learning-loop.d.ts +2 -0
  117. package/dist/runner/learning-loop.js +13 -5
  118. package/dist/runner/learning-seed.d.ts +6 -0
  119. package/dist/runner/learning-seed.js +6 -0
  120. package/dist/runner/loop-contract.d.ts +4 -0
  121. package/dist/runner/main.d.ts +9 -4
  122. package/dist/runner/main.js +26 -11
  123. package/dist/runner/mcp-claim.d.ts +3 -0
  124. package/dist/runner/mcp-claim.js +6 -1
  125. package/dist/runner/mcp-github.d.ts +11 -2
  126. package/dist/runner/mcp-github.js +55 -4
  127. package/dist/runner/mcp-run.js +1 -0
  128. package/dist/runner/metrics.d.ts +14 -1
  129. package/dist/runner/metrics.js +72 -1
  130. package/dist/runner/model-route.d.ts +3 -0
  131. package/dist/runner/model-route.js +1 -1
  132. package/dist/runner/runner.js +90 -8
  133. package/dist/runner/spec-holds.d.ts +7 -2
  134. package/dist/runner/spec-holds.js +4 -3
  135. package/dist/runner/workflow-host.d.ts +7 -2
  136. package/dist/runner/workflow-host.js +3 -1
  137. package/dist/runner/workflow-loop.d.ts +4 -1
  138. package/dist/runner/workflow-loop.js +8 -2
  139. package/dist/runner/workflow-spec.d.ts +3 -0
  140. package/dist/runner/workflow-spec.js +156 -78
  141. package/dist/runs-over-store.d.ts +7 -1
  142. package/dist/runs-over-store.js +42 -11
  143. package/dist/seal-key.d.ts +0 -2
  144. package/dist/seal-key.js +0 -2
  145. package/dist/server-lock.js +4 -5
  146. package/dist/server.d.ts +21 -18
  147. package/dist/server.js +183 -34
  148. package/dist/stop-signals.d.ts +4 -2
  149. package/dist/stop-signals.js +5 -3
  150. package/dist/store/agent-body.d.ts +5 -1
  151. package/dist/store/agent-body.js +11 -5
  152. package/dist/store/deadline.d.ts +18 -0
  153. package/dist/store/deadline.js +45 -0
  154. package/dist/store/postgres/connection.d.ts +4 -0
  155. package/dist/store/postgres/connection.js +55 -9
  156. package/dist/store/sqlite/connection.js +3 -38
  157. package/dist/store-reads/journal.js +39 -4
  158. package/dist/store-reads/learning.d.ts +58 -2
  159. package/dist/store-reads/learning.js +172 -7
  160. package/dist/store-view.d.ts +15 -1
  161. package/dist/store-view.js +45 -12
  162. package/dist/templates.d.ts +9 -4
  163. package/dist/templates.js +14 -9
  164. package/dist/timeline/timeline.d.ts +8 -0
  165. package/dist/tool-budget.d.ts +18 -0
  166. package/dist/tool-budget.js +50 -0
  167. package/dist/tool-gate.d.ts +6 -2
  168. package/dist/tool-gate.js +8 -5
  169. package/dist/tool-plane.d.ts +9 -10
  170. package/dist/tools.d.ts +37 -7
  171. package/dist/tools.js +73 -12
  172. package/dist/uploads.d.ts +28 -5
  173. package/dist/uploads.js +82 -9
  174. package/dist/usage.d.ts +1 -47
  175. package/dist/usage.js +3 -82
  176. package/dist/validate.d.ts +2 -0
  177. package/dist/validate.js +11 -1
  178. package/dist/workspace/archil-claim.d.ts +2 -2
  179. package/dist/workspace/archil-claim.js +4 -3
  180. package/dist/workspace/archil-disk.d.ts +10 -1
  181. package/dist/workspace/archil-disk.js +4 -0
  182. package/dist/workspace/archil-exec.d.ts +12 -2
  183. package/dist/workspace/archil-exec.js +16 -0
  184. package/dist/workspace/archil.d.ts +2 -2
  185. package/dist/workspace/archil.js +25 -5
  186. package/dist/workspace/attach.js +2 -0
  187. package/dist/workspace/computer-deps.d.ts +9 -10
  188. package/dist/workspace/computer-deps.js +53 -40
  189. package/dist/workspace/computer-for-claim.d.ts +5 -3
  190. package/dist/workspace/computer-for-claim.js +28 -16
  191. package/dist/workspace/computer-ledger.d.ts +1 -8
  192. package/dist/workspace/computer-ledger.js +0 -3
  193. package/dist/workspace/computer-providers.d.ts +5 -3
  194. package/dist/workspace/computer-providers.js +11 -9
  195. package/dist/workspace/hands.d.ts +5 -2
  196. package/dist/workspace/hands.js +4 -3
  197. package/dist/workspace/index.d.ts +3 -3
  198. package/dist/workspace/index.js +1 -1
  199. package/dist/workspace/local.d.ts +3 -0
  200. package/dist/workspace/local.js +9 -0
  201. package/dist/workspace/paths.js +3 -2
  202. package/dist/workspace/pi-env.d.ts +4 -0
  203. package/dist/workspace/pi-env.js +3 -2
  204. package/dist/workspace/resolve-computer.d.ts +8 -3
  205. package/dist/workspace/resolve-computer.js +28 -11
  206. package/dist/workspace/run-tools.d.ts +2 -0
  207. package/dist/workspace/run-tools.js +9 -3
  208. package/dist/workspace/workspace.d.ts +5 -0
  209. package/dist/workspace.d.ts +0 -3
  210. package/dist/workspace.js +1 -14
  211. package/package.json +14 -14
  212. package/skills/agentrun-serve/SKILL.md +1 -1
  213. package/templates/README.md +2 -2
  214. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  215. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  216. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  217. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  218. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  219. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  220. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  221. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  222. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  223. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  224. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  225. package/templates/release-notes/agent.md +11 -0
  226. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  227. package/dist/console/assets/index-opTN5Naq.css +0 -1
@@ -0,0 +1,550 @@
1
+ var b2=Object.defineProperty;var w2=(e,t,n)=>t in e?b2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var rt=(e,t,n)=>w2(e,typeof t!="symbol"?t+"":t,n);function k2(e,t){for(var n=0;n<t.length;n++){const o=t[n];if(typeof o!="string"&&!Array.isArray(o)){for(const i in o)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(o,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>o[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function Bw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cm={exports:{}},zi={},Rm={exports:{}},Ye={};/**
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 rv;function j2(){if(rv)return Ye;rv=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),b=Symbol.iterator;function g(L){return L===null||typeof L!="object"?null:(L=b&&L[b]||L["@@iterator"],typeof L=="function"?L:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function j(L,q,ne){this.props=L,this.context=q,this.refs=w,this.updater=ne||m}j.prototype.isReactComponent={},j.prototype.setState=function(L,q){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,q,"setState")},j.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function S(){}S.prototype=j.prototype;function T(L,q,ne){this.props=L,this.context=q,this.refs=w,this.updater=ne||m}var E=T.prototype=new S;E.constructor=T,v(E,j.prototype),E.isPureReactComponent=!0;var _=Array.isArray,$=Object.prototype.hasOwnProperty,R={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function O(L,q,ne){var oe,ae={},ce=null,le=null;if(q!=null)for(oe in q.ref!==void 0&&(le=q.ref),q.key!==void 0&&(ce=""+q.key),q)$.call(q,oe)&&!C.hasOwnProperty(oe)&&(ae[oe]=q[oe]);var ye=arguments.length-2;if(ye===1)ae.children=ne;else if(1<ye){for(var ee=Array(ye),be=0;be<ye;be++)ee[be]=arguments[be+2];ae.children=ee}if(L&&L.defaultProps)for(oe in ye=L.defaultProps,ye)ae[oe]===void 0&&(ae[oe]=ye[oe]);return{$$typeof:e,type:L,key:ce,ref:le,props:ae,_owner:R.current}}function I(L,q){return{$$typeof:e,type:L.type,key:q,ref:L.ref,props:L.props,_owner:L._owner}}function D(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function z(L){var q={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(ne){return q[ne]})}var H=/\/+/g;function F(L,q){return typeof L=="object"&&L!==null&&L.key!=null?z(""+L.key):q.toString(36)}function U(L,q,ne,oe,ae){var ce=typeof L;(ce==="undefined"||ce==="boolean")&&(L=null);var le=!1;if(L===null)le=!0;else switch(ce){case"string":case"number":le=!0;break;case"object":switch(L.$$typeof){case e:case t:le=!0}}if(le)return le=L,ae=ae(le),L=oe===""?"."+F(le,0):oe,_(ae)?(ne="",L!=null&&(ne=L.replace(H,"$&/")+"/"),U(ae,q,ne,"",function(be){return be})):ae!=null&&(D(ae)&&(ae=I(ae,ne+(!ae.key||le&&le.key===ae.key?"":(""+ae.key).replace(H,"$&/")+"/")+L)),q.push(ae)),1;if(le=0,oe=oe===""?".":oe+":",_(L))for(var ye=0;ye<L.length;ye++){ce=L[ye];var ee=oe+F(ce,ye);le+=U(ce,q,ne,ee,ae)}else if(ee=g(L),typeof ee=="function")for(L=ee.call(L),ye=0;!(ce=L.next()).done;)ce=ce.value,ee=oe+F(ce,ye++),le+=U(ce,q,ne,ee,ae);else if(ce==="object")throw q=String(L),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.");return le}function X(L,q,ne){if(L==null)return L;var oe=[],ae=0;return U(L,oe,"","",function(ce){return q.call(ne,ce,ae++)}),oe}function P(L){if(L._status===-1){var q=L._result;q=q(),q.then(function(ne){(L._status===0||L._status===-1)&&(L._status=1,L._result=ne)},function(ne){(L._status===0||L._status===-1)&&(L._status=2,L._result=ne)}),L._status===-1&&(L._status=0,L._result=q)}if(L._status===1)return L._result.default;throw L._result}var K={current:null},M={transition:null},G={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:M,ReactCurrentOwner:R};function B(){throw Error("act(...) is not supported in production builds of React.")}return Ye.Children={map:X,forEach:function(L,q,ne){X(L,function(){q.apply(this,arguments)},ne)},count:function(L){var q=0;return X(L,function(){q++}),q},toArray:function(L){return X(L,function(q){return q})||[]},only:function(L){if(!D(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Ye.Component=j,Ye.Fragment=n,Ye.Profiler=i,Ye.PureComponent=T,Ye.StrictMode=o,Ye.Suspense=f,Ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,Ye.act=B,Ye.cloneElement=function(L,q,ne){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var oe=v({},L.props),ae=L.key,ce=L.ref,le=L._owner;if(q!=null){if(q.ref!==void 0&&(ce=q.ref,le=R.current),q.key!==void 0&&(ae=""+q.key),L.type&&L.type.defaultProps)var ye=L.type.defaultProps;for(ee in q)$.call(q,ee)&&!C.hasOwnProperty(ee)&&(oe[ee]=q[ee]===void 0&&ye!==void 0?ye[ee]:q[ee])}var ee=arguments.length-2;if(ee===1)oe.children=ne;else if(1<ee){ye=Array(ee);for(var be=0;be<ee;be++)ye[be]=arguments[be+2];oe.children=ye}return{$$typeof:e,type:L.type,key:ae,ref:ce,props:oe,_owner:le}},Ye.createContext=function(L){return L={$$typeof:c,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:l,_context:L},L.Consumer=L},Ye.createElement=O,Ye.createFactory=function(L){var q=O.bind(null,L);return q.type=L,q},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(L){return{$$typeof:u,render:L}},Ye.isValidElement=D,Ye.lazy=function(L){return{$$typeof:h,_payload:{_status:-1,_result:L},_init:P}},Ye.memo=function(L,q){return{$$typeof:p,type:L,compare:q===void 0?null:q}},Ye.startTransition=function(L){var q=M.transition;M.transition={};try{L()}finally{M.transition=q}},Ye.unstable_act=B,Ye.useCallback=function(L,q){return K.current.useCallback(L,q)},Ye.useContext=function(L){return K.current.useContext(L)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(L){return K.current.useDeferredValue(L)},Ye.useEffect=function(L,q){return K.current.useEffect(L,q)},Ye.useId=function(){return K.current.useId()},Ye.useImperativeHandle=function(L,q,ne){return K.current.useImperativeHandle(L,q,ne)},Ye.useInsertionEffect=function(L,q){return K.current.useInsertionEffect(L,q)},Ye.useLayoutEffect=function(L,q){return K.current.useLayoutEffect(L,q)},Ye.useMemo=function(L,q){return K.current.useMemo(L,q)},Ye.useReducer=function(L,q,ne){return K.current.useReducer(L,q,ne)},Ye.useRef=function(L){return K.current.useRef(L)},Ye.useState=function(L){return K.current.useState(L)},Ye.useSyncExternalStore=function(L,q,ne){return K.current.useSyncExternalStore(L,q,ne)},Ye.useTransition=function(){return K.current.useTransition()},Ye.version="18.3.1",Ye}var ov;function cd(){return ov||(ov=1,Rm.exports=j2()),Rm.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 av;function N2(){if(av)return zi;av=1;var e=cd(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(u,f,p){var h,b={},g=null,m=null;p!==void 0&&(g=""+p),f.key!==void 0&&(g=""+f.key),f.ref!==void 0&&(m=f.ref);for(h in f)o.call(f,h)&&!l.hasOwnProperty(h)&&(b[h]=f[h]);if(u&&u.defaultProps)for(h in f=u.defaultProps,f)b[h]===void 0&&(b[h]=f[h]);return{$$typeof:t,type:u,key:g,ref:m,props:b,_owner:i.current}}return zi.Fragment=n,zi.jsx=c,zi.jsxs=c,zi}var iv;function S2(){return iv||(iv=1,Cm.exports=N2()),Cm.exports}var s=S2(),y=cd();const je=Bw(y),xp=k2({__proto__:null,default:je},[y]);var eu={},Am={exports:{}},Dn={},Om={exports:{}},Pm={};/**
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 lv;function _2(){return lv||(lv=1,(function(e){function t(M,G){var B=M.length;M.push(G);e:for(;0<B;){var L=B-1>>>1,q=M[L];if(0<i(q,G))M[L]=G,M[B]=q,B=L;else break e}}function n(M){return M.length===0?null:M[0]}function o(M){if(M.length===0)return null;var G=M[0],B=M.pop();if(B!==G){M[0]=B;e:for(var L=0,q=M.length,ne=q>>>1;L<ne;){var oe=2*(L+1)-1,ae=M[oe],ce=oe+1,le=M[ce];if(0>i(ae,B))ce<q&&0>i(le,ae)?(M[L]=le,M[ce]=B,L=ce):(M[L]=ae,M[oe]=B,L=oe);else if(ce<q&&0>i(le,B))M[L]=le,M[ce]=B,L=ce;else break e}}return G}function i(M,G){var B=M.sortIndex-G.sortIndex;return B!==0?B:M.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],p=[],h=1,b=null,g=3,m=!1,v=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(M){for(var G=n(p);G!==null;){if(G.callback===null)o(p);else if(G.startTime<=M)o(p),G.sortIndex=G.expirationTime,t(f,G);else break;G=n(p)}}function _(M){if(w=!1,E(M),!v)if(n(f)!==null)v=!0,P($);else{var G=n(p);G!==null&&K(_,G.startTime-M)}}function $(M,G){v=!1,w&&(w=!1,S(O),O=-1),m=!0;var B=g;try{for(E(G),b=n(f);b!==null&&(!(b.expirationTime>G)||M&&!z());){var L=b.callback;if(typeof L=="function"){b.callback=null,g=b.priorityLevel;var q=L(b.expirationTime<=G);G=e.unstable_now(),typeof q=="function"?b.callback=q:b===n(f)&&o(f),E(G)}else o(f);b=n(f)}if(b!==null)var ne=!0;else{var oe=n(p);oe!==null&&K(_,oe.startTime-G),ne=!1}return ne}finally{b=null,g=B,m=!1}}var R=!1,C=null,O=-1,I=5,D=-1;function z(){return!(e.unstable_now()-D<I)}function H(){if(C!==null){var M=e.unstable_now();D=M;var G=!0;try{G=C(!0,M)}finally{G?F():(R=!1,C=null)}}else R=!1}var F;if(typeof T=="function")F=function(){T(H)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,X=U.port2;U.port1.onmessage=H,F=function(){X.postMessage(null)}}else F=function(){j(H,0)};function P(M){C=M,R||(R=!0,F())}function K(M,G){O=j(function(){M(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){v||m||(v=!0,P($))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(M){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var B=g;g=G;try{return M()}finally{g=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,G){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var B=g;g=M;try{return G()}finally{g=B}},e.unstable_scheduleCallback=function(M,G,B){var L=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?L+B:L):B=L,M){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=B+q,M={id:h++,callback:G,priorityLevel:M,startTime:B,expirationTime:q,sortIndex:-1},B>L?(M.sortIndex=B,t(p,M),n(f)===null&&M===n(p)&&(w?(S(O),O=-1):w=!0,K(_,B-L))):(M.sortIndex=q,t(f,M),v||m||(v=!0,P($))),M},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(M){var G=g;return function(){var B=g;g=G;try{return M.apply(this,arguments)}finally{g=B}}}})(Pm)),Pm}var cv;function E2(){return cv||(cv=1,Om.exports=_2()),Om.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 uv;function $2(){if(uv)return Dn;uv=1;var e=cd(),t=E2();function n(r){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+r,d=1;d<arguments.length;d++)a+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,i={};function l(r,a){c(r,a),c(r+"Capture",a)}function c(r,a){for(i[r]=a,r=0;r<a.length;r++)o.add(a[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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={},b={};function g(r){return f.call(b,r)?!0:f.call(h,r)?!1:p.test(r)?b[r]=!0:(h[r]=!0,!1)}function m(r,a,d,x){if(d!==null&&d.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return x?!1:d!==null?!d.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function v(r,a,d,x){if(a===null||typeof a>"u"||m(r,a,d,x))return!0;if(x)return!1;if(d!==null)switch(d.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(r,a,d,x,k,N,A){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=x,this.attributeNamespace=k,this.mustUseProperty=d,this.propertyName=r,this.type=a,this.sanitizeURL=N,this.removeEmptyString=A}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){j[r]=new w(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var a=r[0];j[a]=new w(a,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){j[r]=new w(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){j[r]=new w(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){j[r]=new w(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){j[r]=new w(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){j[r]=new w(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){j[r]=new w(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){j[r]=new w(r,5,!1,r.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function T(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var a=r.replace(S,T);j[a]=new w(a,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var a=r.replace(S,T);j[a]=new w(a,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var a=r.replace(S,T);j[a]=new w(a,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){j[r]=new w(r,1,!1,r.toLowerCase(),null,!1,!1)}),j.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){j[r]=new w(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,a,d,x){var k=j.hasOwnProperty(a)?j[a]:null;(k!==null?k.type!==0:x||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(v(a,d,k,x)&&(d=null),x||k===null?g(a)&&(d===null?r.removeAttribute(a):r.setAttribute(a,""+d)):k.mustUseProperty?r[k.propertyName]=d===null?k.type===3?!1:"":d:(a=k.attributeName,x=k.attributeNamespace,d===null?r.removeAttribute(a):(k=k.type,d=k===3||k===4&&d===!0?"":""+d,x?r.setAttributeNS(x,a,d):r.setAttribute(a,d))))}var _=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),R=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),z=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),M=Symbol.iterator;function G(r){return r===null||typeof r!="object"?null:(r=M&&r[M]||r["@@iterator"],typeof r=="function"?r:null)}var B=Object.assign,L;function q(r){if(L===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);L=a&&a[1]||""}return`
34
+ `+L+r}var ne=!1;function oe(r,a){if(!r||ne)return"";ne=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(re){var x=re}Reflect.construct(r,[],a)}else{try{a.call()}catch(re){x=re}r.call(a.prototype)}else{try{throw Error()}catch(re){x=re}r()}}catch(re){if(re&&x&&typeof re.stack=="string"){for(var k=re.stack.split(`
35
+ `),N=x.stack.split(`
36
+ `),A=k.length-1,W=N.length-1;1<=A&&0<=W&&k[A]!==N[W];)W--;for(;1<=A&&0<=W;A--,W--)if(k[A]!==N[W]){if(A!==1||W!==1)do if(A--,W--,0>W||k[A]!==N[W]){var V=`
37
+ `+k[A].replace(" at new "," at ");return r.displayName&&V.includes("<anonymous>")&&(V=V.replace("<anonymous>",r.displayName)),V}while(1<=A&&0<=W);break}}}finally{ne=!1,Error.prepareStackTrace=d}return(r=r?r.displayName||r.name:"")?q(r):""}function ae(r){switch(r.tag){case 5:return q(r.type);case 16:return q("Lazy");case 13:return q("Suspense");case 19:return q("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function ce(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case C:return"Fragment";case R:return"Portal";case I:return"Profiler";case O:return"StrictMode";case F:return"Suspense";case U:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case z:return(r.displayName||"Context")+".Consumer";case D:return(r._context.displayName||"Context")+".Provider";case H:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case X:return a=r.displayName||null,a!==null?a:ce(r.type)||"Memo";case P:a=r._payload,r=r._init;try{return ce(r(a))}catch{}}return null}function le(r){var a=r.type;switch(r.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=a.render,r=r.displayName||r.name||"",a.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ce(a);case 8:return a===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function ye(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ee(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function be(r){var a=ee(r)?"checked":"value",d=Object.getOwnPropertyDescriptor(r.constructor.prototype,a),x=""+r[a];if(!r.hasOwnProperty(a)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var k=d.get,N=d.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return k.call(this)},set:function(A){x=""+A,N.call(this,A)}}),Object.defineProperty(r,a,{enumerable:d.enumerable}),{getValue:function(){return x},setValue:function(A){x=""+A},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function Oe(r){r._valueTracker||(r._valueTracker=be(r))}function We(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var d=a.getValue(),x="";return r&&(x=ee(r)?r.checked?"true":"false":r.value),r=x,r!==d?(a.setValue(r),!0):!1}function fe(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Re(r,a){var d=a.checked;return B({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??r._wrapperState.initialChecked})}function Xe(r,a){var d=a.defaultValue==null?"":a.defaultValue,x=a.checked!=null?a.checked:a.defaultChecked;d=ye(a.value!=null?a.value:d),r._wrapperState={initialChecked:x,initialValue:d,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Kt(r,a){a=a.checked,a!=null&&E(r,"checked",a,!1)}function De(r,a){Kt(r,a);var d=ye(a.value),x=a.type;if(d!=null)x==="number"?(d===0&&r.value===""||r.value!=d)&&(r.value=""+d):r.value!==""+d&&(r.value=""+d);else if(x==="submit"||x==="reset"){r.removeAttribute("value");return}a.hasOwnProperty("value")?Ut(r,a.type,d):a.hasOwnProperty("defaultValue")&&Ut(r,a.type,ye(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(r.defaultChecked=!!a.defaultChecked)}function et(r,a,d){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var x=a.type;if(!(x!=="submit"&&x!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+r._wrapperState.initialValue,d||a===r.value||(r.value=a),r.defaultValue=a}d=r.name,d!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,d!==""&&(r.name=d)}function Ut(r,a,d){(a!=="number"||fe(r.ownerDocument)!==r)&&(d==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+d&&(r.defaultValue=""+d))}var Wt=Array.isArray;function jt(r,a,d,x){if(r=r.options,a){a={};for(var k=0;k<d.length;k++)a["$"+d[k]]=!0;for(d=0;d<r.length;d++)k=a.hasOwnProperty("$"+r[d].value),r[d].selected!==k&&(r[d].selected=k),k&&x&&(r[d].defaultSelected=!0)}else{for(d=""+ye(d),a=null,k=0;k<r.length;k++){if(r[k].value===d){r[k].selected=!0,x&&(r[k].defaultSelected=!0);return}a!==null||r[k].disabled||(a=r[k])}a!==null&&(a.selected=!0)}}function ss(r,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return B({},a,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function hn(r,a){var d=a.value;if(d==null){if(d=a.children,a=a.defaultValue,d!=null){if(a!=null)throw Error(n(92));if(Wt(d)){if(1<d.length)throw Error(n(93));d=d[0]}a=d}a==null&&(a=""),d=a}r._wrapperState={initialValue:ye(d)}}function Xt(r,a){var d=ye(a.value),x=ye(a.defaultValue);d!=null&&(d=""+d,d!==r.value&&(r.value=d),a.defaultValue==null&&r.defaultValue!==d&&(r.defaultValue=d)),x!=null&&(r.defaultValue=""+x)}function at(r){var a=r.textContent;a===r._wrapperState.initialValue&&a!==""&&a!==null&&(r.value=a)}function ct(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Me(r,a){return r==null||r==="http://www.w3.org/1999/xhtml"?ct(a):r==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var Le,At=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,d,x,k){MSApp.execUnsafeLocalFunction(function(){return r(a,d,x,k)})}:r})(function(r,a){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=a;else{for(Le=Le||document.createElement("div"),Le.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Le.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;a.firstChild;)r.appendChild(a.firstChild)}});function ut(r,a){if(a){var d=r.firstChild;if(d&&d===r.lastChild&&d.nodeType===3){d.nodeValue=a;return}}r.textContent=a}var Lt={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},En=["Webkit","ms","Moz","O"];Object.keys(Lt).forEach(function(r){En.forEach(function(a){a=a+r.charAt(0).toUpperCase()+r.substring(1),Lt[a]=Lt[r]})});function $n(r,a,d){return a==null||typeof a=="boolean"||a===""?"":d||typeof a!="number"||a===0||Lt.hasOwnProperty(r)&&Lt[r]?(""+a).trim():a+"px"}function Yt(r,a){r=r.style;for(var d in a)if(a.hasOwnProperty(d)){var x=d.indexOf("--")===0,k=$n(d,a[d],x);d==="float"&&(d="cssFloat"),x?r.setProperty(d,k):r[d]=k}}var Wn=B({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 rs(r,a){if(a){if(Wn[r]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function os(r,a){if(r.indexOf("-")===-1)return typeof a.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Tn=null;function Hn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Bn=null,J=null,we=null;function Ge(r){if(r=ji(r)){if(typeof Bn!="function")throw Error(n(280));var a=r.stateNode;a&&(a=hc(a),Bn(r.stateNode,r.type,a))}}function dt(r){J?we?we.push(r):we=[r]:J=r}function Ke(){if(J){var r=J,a=we;if(we=J=null,Ge(r),a)for(r=0;r<a.length;r++)Ge(a[r])}}function Nt(r,a){return r(a)}function nn(){}var yt=!1;function Ws(r,a,d){if(yt)return r(a,d);yt=!0;try{return Nt(r,a,d)}finally{yt=!1,(J!==null||we!==null)&&(nn(),Ke())}}function sn(r,a){var d=r.stateNode;if(d===null)return null;var x=hc(d);if(x===null)return null;d=x[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(r=r.type,x=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!x;break e;default:r=!1}if(r)return null;if(d&&typeof d!="function")throw Error(n(231,a,typeof d));return d}var _s=!1;if(u)try{var Cn={};Object.defineProperty(Cn,"passive",{get:function(){_s=!0}}),window.addEventListener("test",Cn,Cn),window.removeEventListener("test",Cn,Cn)}catch{_s=!1}function Rn(r,a,d,x,k,N,A,W,V){var re=Array.prototype.slice.call(arguments,3);try{a.apply(d,re)}catch(de){this.onError(de)}}var as=!1,sr=null,rr=!1,Hs=null,Ko={onError:function(r){as=!0,sr=r}};function An(r,a,d,x,k,N,A,W,V){as=!1,sr=null,Rn.apply(Ko,arguments)}function lo(r,a,d,x,k,N,A,W,V){if(An.apply(this,arguments),as){if(as){var re=sr;as=!1,sr=null}else throw Error(n(198));rr||(rr=!0,Hs=re)}}function Gn(r){var a=r,d=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(d=a.return),r=a.return;while(r)}return a.tag===3?d:null}function or(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function jr(r){if(Gn(r)!==r)throw Error(n(188))}function Xo(r){var a=r.alternate;if(!a){if(a=Gn(r),a===null)throw Error(n(188));return a!==r?null:r}for(var d=r,x=a;;){var k=d.return;if(k===null)break;var N=k.alternate;if(N===null){if(x=k.return,x!==null){d=x;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===d)return jr(k),r;if(N===x)return jr(k),a;N=N.sibling}throw Error(n(188))}if(d.return!==x.return)d=k,x=N;else{for(var A=!1,W=k.child;W;){if(W===d){A=!0,d=k,x=N;break}if(W===x){A=!0,x=k,d=N;break}W=W.sibling}if(!A){for(W=N.child;W;){if(W===d){A=!0,d=N,x=k;break}if(W===x){A=!0,x=N,d=k;break}W=W.sibling}if(!A)throw Error(n(189))}}if(d.alternate!==x)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?r:a}function Ae(r){return r=Xo(r),r!==null?Y(r):null}function Y(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var a=Y(r);if(a!==null)return a;r=r.sibling}return null}var pe=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,it=t.unstable_shouldYield,Et=t.unstable_requestPaint,Be=t.unstable_now,It=t.unstable_getCurrentPriorityLevel,Qt=t.unstable_ImmediatePriority,Es=t.unstable_UserBlockingPriority,vt=t.unstable_NormalPriority,co=t.unstable_LowPriority,Nr=t.unstable_IdlePriority,uo=null,qn=null;function Ql(r){if(qn&&typeof qn.onCommitFiberRoot=="function")try{qn.onCommitFiberRoot(uo,r,void 0,(r.current.flags&128)===128)}catch{}}var On=Math.clz32?Math.clz32:he,Zl=Math.log,Jl=Math.LN2;function he(r){return r>>>=0,r===0?32:31-(Zl(r)/Jl|0)|0}var xe=64,Ee=4194304;function Qe(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function qe(r,a){var d=r.pendingLanes;if(d===0)return 0;var x=0,k=r.suspendedLanes,N=r.pingedLanes,A=d&268435455;if(A!==0){var W=A&~k;W!==0?x=Qe(W):(N&=A,N!==0&&(x=Qe(N)))}else A=d&~k,A!==0?x=Qe(A):N!==0&&(x=Qe(N));if(x===0)return 0;if(a!==0&&a!==x&&(a&k)===0&&(k=x&-x,N=a&-a,k>=N||k===16&&(N&4194240)!==0))return a;if((x&4)!==0&&(x|=d&16),a=r.entangledLanes,a!==0)for(r=r.entanglements,a&=x;0<a;)d=31-On(a),k=1<<d,x|=r[d],a&=~k;return x}function Ot(r,a){switch(r){case 1:case 2:case 4:return a+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 a+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 rn(r,a){for(var d=r.suspendedLanes,x=r.pingedLanes,k=r.expirationTimes,N=r.pendingLanes;0<N;){var A=31-On(N),W=1<<A,V=k[A];V===-1?((W&d)===0||(W&x)!==0)&&(k[A]=Ot(W,a)):V<=a&&(r.expiredLanes|=W),N&=~W}}function oi(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Yo(){var r=xe;return xe<<=1,(xe&4194240)===0&&(xe=64),r}function ai(r){for(var a=[],d=0;31>d;d++)a.push(r);return a}function Sr(r,a,d){r.pendingLanes|=a,a!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,a=31-On(a),r[a]=d}function Zd(r,a){var d=r.pendingLanes&~a;r.pendingLanes=a,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=a,r.mutableReadLanes&=a,r.entangledLanes&=a,a=r.entanglements;var x=r.eventTimes;for(r=r.expirationTimes;0<d;){var k=31-On(d),N=1<<k;a[k]=0,x[k]=-1,r[k]=-1,d&=~N}}function fo(r,a){var d=r.entangledLanes|=a;for(r=r.entanglements;d;){var x=31-On(d),k=1<<x;k&a|r[x]&a&&(r[x]|=a),d&=~k}}var nt=0;function Lg(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Ig,Jd,zg,Dg,Fg,ef=!1,ec=[],_r=null,Er=null,$r=null,ii=new Map,li=new Map,Tr=[],WN="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 Ug(r,a){switch(r){case"focusin":case"focusout":_r=null;break;case"dragenter":case"dragleave":Er=null;break;case"mouseover":case"mouseout":$r=null;break;case"pointerover":case"pointerout":ii.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":li.delete(a.pointerId)}}function ci(r,a,d,x,k,N){return r===null||r.nativeEvent!==N?(r={blockedOn:a,domEventName:d,eventSystemFlags:x,nativeEvent:N,targetContainers:[k]},a!==null&&(a=ji(a),a!==null&&Jd(a)),r):(r.eventSystemFlags|=x,a=r.targetContainers,k!==null&&a.indexOf(k)===-1&&a.push(k),r)}function HN(r,a,d,x,k){switch(a){case"focusin":return _r=ci(_r,r,a,d,x,k),!0;case"dragenter":return Er=ci(Er,r,a,d,x,k),!0;case"mouseover":return $r=ci($r,r,a,d,x,k),!0;case"pointerover":var N=k.pointerId;return ii.set(N,ci(ii.get(N)||null,r,a,d,x,k)),!0;case"gotpointercapture":return N=k.pointerId,li.set(N,ci(li.get(N)||null,r,a,d,x,k)),!0}return!1}function Wg(r){var a=mo(r.target);if(a!==null){var d=Gn(a);if(d!==null){if(a=d.tag,a===13){if(a=or(d),a!==null){r.blockedOn=a,Fg(r.priority,function(){zg(d)});return}}else if(a===3&&d.stateNode.current.memoizedState.isDehydrated){r.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}r.blockedOn=null}function tc(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var d=nf(r.domEventName,r.eventSystemFlags,a[0],r.nativeEvent);if(d===null){d=r.nativeEvent;var x=new d.constructor(d.type,d);Tn=x,d.target.dispatchEvent(x),Tn=null}else return a=ji(d),a!==null&&Jd(a),r.blockedOn=d,!1;a.shift()}return!0}function Hg(r,a,d){tc(r)&&d.delete(a)}function BN(){ef=!1,_r!==null&&tc(_r)&&(_r=null),Er!==null&&tc(Er)&&(Er=null),$r!==null&&tc($r)&&($r=null),ii.forEach(Hg),li.forEach(Hg)}function ui(r,a){r.blockedOn===a&&(r.blockedOn=null,ef||(ef=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,BN)))}function di(r){function a(k){return ui(k,r)}if(0<ec.length){ui(ec[0],r);for(var d=1;d<ec.length;d++){var x=ec[d];x.blockedOn===r&&(x.blockedOn=null)}}for(_r!==null&&ui(_r,r),Er!==null&&ui(Er,r),$r!==null&&ui($r,r),ii.forEach(a),li.forEach(a),d=0;d<Tr.length;d++)x=Tr[d],x.blockedOn===r&&(x.blockedOn=null);for(;0<Tr.length&&(d=Tr[0],d.blockedOn===null);)Wg(d),d.blockedOn===null&&Tr.shift()}var Qo=_.ReactCurrentBatchConfig,nc=!0;function GN(r,a,d,x){var k=nt,N=Qo.transition;Qo.transition=null;try{nt=1,tf(r,a,d,x)}finally{nt=k,Qo.transition=N}}function qN(r,a,d,x){var k=nt,N=Qo.transition;Qo.transition=null;try{nt=4,tf(r,a,d,x)}finally{nt=k,Qo.transition=N}}function tf(r,a,d,x){if(nc){var k=nf(r,a,d,x);if(k===null)bf(r,a,x,sc,d),Ug(r,x);else if(HN(k,r,a,d,x))x.stopPropagation();else if(Ug(r,x),a&4&&-1<WN.indexOf(r)){for(;k!==null;){var N=ji(k);if(N!==null&&Ig(N),N=nf(r,a,d,x),N===null&&bf(r,a,x,sc,d),N===k)break;k=N}k!==null&&x.stopPropagation()}else bf(r,a,x,null,d)}}var sc=null;function nf(r,a,d,x){if(sc=null,r=Hn(x),r=mo(r),r!==null)if(a=Gn(r),a===null)r=null;else if(d=a.tag,d===13){if(r=or(a),r!==null)return r;r=null}else if(d===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null);return sc=r,null}function Bg(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(It()){case Qt:return 1;case Es:return 4;case vt:case co:return 16;case Nr:return 536870912;default:return 16}default:return 16}}var Cr=null,sf=null,rc=null;function Gg(){if(rc)return rc;var r,a=sf,d=a.length,x,k="value"in Cr?Cr.value:Cr.textContent,N=k.length;for(r=0;r<d&&a[r]===k[r];r++);var A=d-r;for(x=1;x<=A&&a[d-x]===k[N-x];x++);return rc=k.slice(r,1<x?1-x:void 0)}function oc(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function ac(){return!0}function qg(){return!1}function Vn(r){function a(d,x,k,N,A){this._reactName=d,this._targetInst=k,this.type=x,this.nativeEvent=N,this.target=A,this.currentTarget=null;for(var W in r)r.hasOwnProperty(W)&&(d=r[W],this[W]=d?d(N):N[W]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?ac:qg,this.isPropagationStopped=qg,this}return B(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=ac)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=ac)},persist:function(){},isPersistent:ac}),a}var Zo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Vn(Zo),fi=B({},Zo,{view:0,detail:0}),VN=Vn(fi),of,af,mi,ic=B({},fi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cf,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==mi&&(mi&&r.type==="mousemove"?(of=r.screenX-mi.screenX,af=r.screenY-mi.screenY):af=of=0,mi=r),of)},movementY:function(r){return"movementY"in r?r.movementY:af}}),Vg=Vn(ic),KN=B({},ic,{dataTransfer:0}),XN=Vn(KN),YN=B({},fi,{relatedTarget:0}),lf=Vn(YN),QN=B({},Zo,{animationName:0,elapsedTime:0,pseudoElement:0}),ZN=Vn(QN),JN=B({},Zo,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),eS=Vn(JN),tS=B({},Zo,{data:0}),Kg=Vn(tS),nS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sS={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"},rS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function oS(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=rS[r])?!!a[r]:!1}function cf(){return oS}var aS=B({},fi,{key:function(r){if(r.key){var a=nS[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=oc(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?sS[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cf,charCode:function(r){return r.type==="keypress"?oc(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?oc(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),iS=Vn(aS),lS=B({},ic,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xg=Vn(lS),cS=B({},fi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cf}),uS=Vn(cS),dS=B({},Zo,{propertyName:0,elapsedTime:0,pseudoElement:0}),fS=Vn(dS),mS=B({},ic,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),pS=Vn(mS),hS=[9,13,27,32],uf=u&&"CompositionEvent"in window,pi=null;u&&"documentMode"in document&&(pi=document.documentMode);var gS=u&&"TextEvent"in window&&!pi,Yg=u&&(!uf||pi&&8<pi&&11>=pi),Qg=" ",Zg=!1;function Jg(r,a){switch(r){case"keyup":return hS.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ex(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Jo=!1;function xS(r,a){switch(r){case"compositionend":return ex(a);case"keypress":return a.which!==32?null:(Zg=!0,Qg);case"textInput":return r=a.data,r===Qg&&Zg?null:r;default:return null}}function yS(r,a){if(Jo)return r==="compositionend"||!uf&&Jg(r,a)?(r=Gg(),rc=sf=Cr=null,Jo=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Yg&&a.locale!=="ko"?null:a.data;default:return null}}var vS={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 tx(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!vS[r.type]:a==="textarea"}function nx(r,a,d,x){dt(x),a=fc(a,"onChange"),0<a.length&&(d=new rf("onChange","change",null,d,x),r.push({event:d,listeners:a}))}var hi=null,gi=null;function bS(r){bx(r,0)}function lc(r){var a=ra(r);if(We(a))return r}function wS(r,a){if(r==="change")return a}var sx=!1;if(u){var df;if(u){var ff="oninput"in document;if(!ff){var rx=document.createElement("div");rx.setAttribute("oninput","return;"),ff=typeof rx.oninput=="function"}df=ff}else df=!1;sx=df&&(!document.documentMode||9<document.documentMode)}function ox(){hi&&(hi.detachEvent("onpropertychange",ax),gi=hi=null)}function ax(r){if(r.propertyName==="value"&&lc(gi)){var a=[];nx(a,gi,r,Hn(r)),Ws(bS,a)}}function kS(r,a,d){r==="focusin"?(ox(),hi=a,gi=d,hi.attachEvent("onpropertychange",ax)):r==="focusout"&&ox()}function jS(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return lc(gi)}function NS(r,a){if(r==="click")return lc(a)}function SS(r,a){if(r==="input"||r==="change")return lc(a)}function _S(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var $s=typeof Object.is=="function"?Object.is:_S;function xi(r,a){if($s(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var d=Object.keys(r),x=Object.keys(a);if(d.length!==x.length)return!1;for(x=0;x<d.length;x++){var k=d[x];if(!f.call(a,k)||!$s(r[k],a[k]))return!1}return!0}function ix(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function lx(r,a){var d=ix(r);r=0;for(var x;d;){if(d.nodeType===3){if(x=r+d.textContent.length,r<=a&&x>=a)return{node:d,offset:a-r};r=x}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=ix(d)}}function cx(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?cx(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function ux(){for(var r=window,a=fe();a instanceof r.HTMLIFrameElement;){try{var d=typeof a.contentWindow.location.href=="string"}catch{d=!1}if(d)r=a.contentWindow;else break;a=fe(r.document)}return a}function mf(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}function ES(r){var a=ux(),d=r.focusedElem,x=r.selectionRange;if(a!==d&&d&&d.ownerDocument&&cx(d.ownerDocument.documentElement,d)){if(x!==null&&mf(d)){if(a=x.start,r=x.end,r===void 0&&(r=a),"selectionStart"in d)d.selectionStart=a,d.selectionEnd=Math.min(r,d.value.length);else if(r=(a=d.ownerDocument||document)&&a.defaultView||window,r.getSelection){r=r.getSelection();var k=d.textContent.length,N=Math.min(x.start,k);x=x.end===void 0?N:Math.min(x.end,k),!r.extend&&N>x&&(k=x,x=N,N=k),k=lx(d,N);var A=lx(d,x);k&&A&&(r.rangeCount!==1||r.anchorNode!==k.node||r.anchorOffset!==k.offset||r.focusNode!==A.node||r.focusOffset!==A.offset)&&(a=a.createRange(),a.setStart(k.node,k.offset),r.removeAllRanges(),N>x?(r.addRange(a),r.extend(A.node,A.offset)):(a.setEnd(A.node,A.offset),r.addRange(a)))}}for(a=[],r=d;r=r.parentNode;)r.nodeType===1&&a.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<a.length;d++)r=a[d],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var $S=u&&"documentMode"in document&&11>=document.documentMode,ea=null,pf=null,yi=null,hf=!1;function dx(r,a,d){var x=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;hf||ea==null||ea!==fe(x)||(x=ea,"selectionStart"in x&&mf(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),yi&&xi(yi,x)||(yi=x,x=fc(pf,"onSelect"),0<x.length&&(a=new rf("onSelect","select",null,a,d),r.push({event:a,listeners:x}),a.target=ea)))}function cc(r,a){var d={};return d[r.toLowerCase()]=a.toLowerCase(),d["Webkit"+r]="webkit"+a,d["Moz"+r]="moz"+a,d}var ta={animationend:cc("Animation","AnimationEnd"),animationiteration:cc("Animation","AnimationIteration"),animationstart:cc("Animation","AnimationStart"),transitionend:cc("Transition","TransitionEnd")},gf={},fx={};u&&(fx=document.createElement("div").style,"AnimationEvent"in window||(delete ta.animationend.animation,delete ta.animationiteration.animation,delete ta.animationstart.animation),"TransitionEvent"in window||delete ta.transitionend.transition);function uc(r){if(gf[r])return gf[r];if(!ta[r])return r;var a=ta[r],d;for(d in a)if(a.hasOwnProperty(d)&&d in fx)return gf[r]=a[d];return r}var mx=uc("animationend"),px=uc("animationiteration"),hx=uc("animationstart"),gx=uc("transitionend"),xx=new Map,yx="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 Rr(r,a){xx.set(r,a),l(a,[r])}for(var xf=0;xf<yx.length;xf++){var yf=yx[xf],TS=yf.toLowerCase(),CS=yf[0].toUpperCase()+yf.slice(1);Rr(TS,"on"+CS)}Rr(mx,"onAnimationEnd"),Rr(px,"onAnimationIteration"),Rr(hx,"onAnimationStart"),Rr("dblclick","onDoubleClick"),Rr("focusin","onFocus"),Rr("focusout","onBlur"),Rr(gx,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var vi="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(" "),RS=new Set("cancel close invalid load scroll toggle".split(" ").concat(vi));function vx(r,a,d){var x=r.type||"unknown-event";r.currentTarget=d,lo(x,a,void 0,r),r.currentTarget=null}function bx(r,a){a=(a&4)!==0;for(var d=0;d<r.length;d++){var x=r[d],k=x.event;x=x.listeners;e:{var N=void 0;if(a)for(var A=x.length-1;0<=A;A--){var W=x[A],V=W.instance,re=W.currentTarget;if(W=W.listener,V!==N&&k.isPropagationStopped())break e;vx(k,W,re),N=V}else for(A=0;A<x.length;A++){if(W=x[A],V=W.instance,re=W.currentTarget,W=W.listener,V!==N&&k.isPropagationStopped())break e;vx(k,W,re),N=V}}}if(rr)throw r=Hs,rr=!1,Hs=null,r}function mt(r,a){var d=a[_f];d===void 0&&(d=a[_f]=new Set);var x=r+"__bubble";d.has(x)||(wx(a,r,2,!1),d.add(x))}function vf(r,a,d){var x=0;a&&(x|=4),wx(d,r,x,a)}var dc="_reactListening"+Math.random().toString(36).slice(2);function bi(r){if(!r[dc]){r[dc]=!0,o.forEach(function(d){d!=="selectionchange"&&(RS.has(d)||vf(d,!1,r),vf(d,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[dc]||(a[dc]=!0,vf("selectionchange",!1,a))}}function wx(r,a,d,x){switch(Bg(a)){case 1:var k=GN;break;case 4:k=qN;break;default:k=tf}d=k.bind(null,a,d,r),k=void 0,!_s||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(k=!0),x?k!==void 0?r.addEventListener(a,d,{capture:!0,passive:k}):r.addEventListener(a,d,!0):k!==void 0?r.addEventListener(a,d,{passive:k}):r.addEventListener(a,d,!1)}function bf(r,a,d,x,k){var N=x;if((a&1)===0&&(a&2)===0&&x!==null)e:for(;;){if(x===null)return;var A=x.tag;if(A===3||A===4){var W=x.stateNode.containerInfo;if(W===k||W.nodeType===8&&W.parentNode===k)break;if(A===4)for(A=x.return;A!==null;){var V=A.tag;if((V===3||V===4)&&(V=A.stateNode.containerInfo,V===k||V.nodeType===8&&V.parentNode===k))return;A=A.return}for(;W!==null;){if(A=mo(W),A===null)return;if(V=A.tag,V===5||V===6){x=N=A;continue e}W=W.parentNode}}x=x.return}Ws(function(){var re=N,de=Hn(d),me=[];e:{var ue=xx.get(r);if(ue!==void 0){var ke=rf,_e=r;switch(r){case"keypress":if(oc(d)===0)break e;case"keydown":case"keyup":ke=iS;break;case"focusin":_e="focus",ke=lf;break;case"focusout":_e="blur",ke=lf;break;case"beforeblur":case"afterblur":ke=lf;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ke=Vg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=XN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=uS;break;case mx:case px:case hx:ke=ZN;break;case gx:ke=fS;break;case"scroll":ke=VN;break;case"wheel":ke=pS;break;case"copy":case"cut":case"paste":ke=eS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Xg}var $e=(a&4)!==0,$t=!$e&&r==="scroll",te=$e?ue!==null?ue+"Capture":null:ue;$e=[];for(var Q=re,se;Q!==null;){se=Q;var ge=se.stateNode;if(se.tag===5&&ge!==null&&(se=ge,te!==null&&(ge=sn(Q,te),ge!=null&&$e.push(wi(Q,ge,se)))),$t)break;Q=Q.return}0<$e.length&&(ue=new ke(ue,_e,null,d,de),me.push({event:ue,listeners:$e}))}}if((a&7)===0){e:{if(ue=r==="mouseover"||r==="pointerover",ke=r==="mouseout"||r==="pointerout",ue&&d!==Tn&&(_e=d.relatedTarget||d.fromElement)&&(mo(_e)||_e[ar]))break e;if((ke||ue)&&(ue=de.window===de?de:(ue=de.ownerDocument)?ue.defaultView||ue.parentWindow:window,ke?(_e=d.relatedTarget||d.toElement,ke=re,_e=_e?mo(_e):null,_e!==null&&($t=Gn(_e),_e!==$t||_e.tag!==5&&_e.tag!==6)&&(_e=null)):(ke=null,_e=re),ke!==_e)){if($e=Vg,ge="onMouseLeave",te="onMouseEnter",Q="mouse",(r==="pointerout"||r==="pointerover")&&($e=Xg,ge="onPointerLeave",te="onPointerEnter",Q="pointer"),$t=ke==null?ue:ra(ke),se=_e==null?ue:ra(_e),ue=new $e(ge,Q+"leave",ke,d,de),ue.target=$t,ue.relatedTarget=se,ge=null,mo(de)===re&&($e=new $e(te,Q+"enter",_e,d,de),$e.target=se,$e.relatedTarget=$t,ge=$e),$t=ge,ke&&_e)t:{for($e=ke,te=_e,Q=0,se=$e;se;se=na(se))Q++;for(se=0,ge=te;ge;ge=na(ge))se++;for(;0<Q-se;)$e=na($e),Q--;for(;0<se-Q;)te=na(te),se--;for(;Q--;){if($e===te||te!==null&&$e===te.alternate)break t;$e=na($e),te=na(te)}$e=null}else $e=null;ke!==null&&kx(me,ue,ke,$e,!1),_e!==null&&$t!==null&&kx(me,$t,_e,$e,!0)}}e:{if(ue=re?ra(re):window,ke=ue.nodeName&&ue.nodeName.toLowerCase(),ke==="select"||ke==="input"&&ue.type==="file")var Ce=wS;else if(tx(ue))if(sx)Ce=SS;else{Ce=jS;var Ie=kS}else(ke=ue.nodeName)&&ke.toLowerCase()==="input"&&(ue.type==="checkbox"||ue.type==="radio")&&(Ce=NS);if(Ce&&(Ce=Ce(r,re))){nx(me,Ce,d,de);break e}Ie&&Ie(r,ue,re),r==="focusout"&&(Ie=ue._wrapperState)&&Ie.controlled&&ue.type==="number"&&Ut(ue,"number",ue.value)}switch(Ie=re?ra(re):window,r){case"focusin":(tx(Ie)||Ie.contentEditable==="true")&&(ea=Ie,pf=re,yi=null);break;case"focusout":yi=pf=ea=null;break;case"mousedown":hf=!0;break;case"contextmenu":case"mouseup":case"dragend":hf=!1,dx(me,d,de);break;case"selectionchange":if($S)break;case"keydown":case"keyup":dx(me,d,de)}var ze;if(uf)e:{switch(r){case"compositionstart":var Fe="onCompositionStart";break e;case"compositionend":Fe="onCompositionEnd";break e;case"compositionupdate":Fe="onCompositionUpdate";break e}Fe=void 0}else Jo?Jg(r,d)&&(Fe="onCompositionEnd"):r==="keydown"&&d.keyCode===229&&(Fe="onCompositionStart");Fe&&(Yg&&d.locale!=="ko"&&(Jo||Fe!=="onCompositionStart"?Fe==="onCompositionEnd"&&Jo&&(ze=Gg()):(Cr=de,sf="value"in Cr?Cr.value:Cr.textContent,Jo=!0)),Ie=fc(re,Fe),0<Ie.length&&(Fe=new Kg(Fe,r,null,d,de),me.push({event:Fe,listeners:Ie}),ze?Fe.data=ze:(ze=ex(d),ze!==null&&(Fe.data=ze)))),(ze=gS?xS(r,d):yS(r,d))&&(re=fc(re,"onBeforeInput"),0<re.length&&(de=new Kg("onBeforeInput","beforeinput",null,d,de),me.push({event:de,listeners:re}),de.data=ze))}bx(me,a)})}function wi(r,a,d){return{instance:r,listener:a,currentTarget:d}}function fc(r,a){for(var d=a+"Capture",x=[];r!==null;){var k=r,N=k.stateNode;k.tag===5&&N!==null&&(k=N,N=sn(r,d),N!=null&&x.unshift(wi(r,N,k)),N=sn(r,a),N!=null&&x.push(wi(r,N,k))),r=r.return}return x}function na(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function kx(r,a,d,x,k){for(var N=a._reactName,A=[];d!==null&&d!==x;){var W=d,V=W.alternate,re=W.stateNode;if(V!==null&&V===x)break;W.tag===5&&re!==null&&(W=re,k?(V=sn(d,N),V!=null&&A.unshift(wi(d,V,W))):k||(V=sn(d,N),V!=null&&A.push(wi(d,V,W)))),d=d.return}A.length!==0&&r.push({event:a,listeners:A})}var AS=/\r\n?/g,OS=/\u0000|\uFFFD/g;function jx(r){return(typeof r=="string"?r:""+r).replace(AS,`
38
+ `).replace(OS,"")}function mc(r,a,d){if(a=jx(a),jx(r)!==a&&d)throw Error(n(425))}function pc(){}var wf=null,kf=null;function jf(r,a){return r==="textarea"||r==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Nf=typeof setTimeout=="function"?setTimeout:void 0,PS=typeof clearTimeout=="function"?clearTimeout:void 0,Nx=typeof Promise=="function"?Promise:void 0,MS=typeof queueMicrotask=="function"?queueMicrotask:typeof Nx<"u"?function(r){return Nx.resolve(null).then(r).catch(LS)}:Nf;function LS(r){setTimeout(function(){throw r})}function Sf(r,a){var d=a,x=0;do{var k=d.nextSibling;if(r.removeChild(d),k&&k.nodeType===8)if(d=k.data,d==="/$"){if(x===0){r.removeChild(k),di(a);return}x--}else d!=="$"&&d!=="$?"&&d!=="$!"||x++;d=k}while(d);di(a)}function Ar(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return r}function Sx(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var d=r.data;if(d==="$"||d==="$!"||d==="$?"){if(a===0)return r;a--}else d==="/$"&&a++}r=r.previousSibling}return null}var sa=Math.random().toString(36).slice(2),Bs="__reactFiber$"+sa,ki="__reactProps$"+sa,ar="__reactContainer$"+sa,_f="__reactEvents$"+sa,IS="__reactListeners$"+sa,zS="__reactHandles$"+sa;function mo(r){var a=r[Bs];if(a)return a;for(var d=r.parentNode;d;){if(a=d[ar]||d[Bs]){if(d=a.alternate,a.child!==null||d!==null&&d.child!==null)for(r=Sx(r);r!==null;){if(d=r[Bs])return d;r=Sx(r)}return a}r=d,d=r.parentNode}return null}function ji(r){return r=r[Bs]||r[ar],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function ra(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function hc(r){return r[ki]||null}var Ef=[],oa=-1;function Or(r){return{current:r}}function pt(r){0>oa||(r.current=Ef[oa],Ef[oa]=null,oa--)}function ft(r,a){oa++,Ef[oa]=r.current,r.current=a}var Pr={},on=Or(Pr),Pn=Or(!1),po=Pr;function aa(r,a){var d=r.type.contextTypes;if(!d)return Pr;var x=r.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===a)return x.__reactInternalMemoizedMaskedChildContext;var k={},N;for(N in d)k[N]=a[N];return x&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=a,r.__reactInternalMemoizedMaskedChildContext=k),k}function Mn(r){return r=r.childContextTypes,r!=null}function gc(){pt(Pn),pt(on)}function _x(r,a,d){if(on.current!==Pr)throw Error(n(168));ft(on,a),ft(Pn,d)}function Ex(r,a,d){var x=r.stateNode;if(a=a.childContextTypes,typeof x.getChildContext!="function")return d;x=x.getChildContext();for(var k in x)if(!(k in a))throw Error(n(108,le(r)||"Unknown",k));return B({},d,x)}function xc(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Pr,po=on.current,ft(on,r),ft(Pn,Pn.current),!0}function $x(r,a,d){var x=r.stateNode;if(!x)throw Error(n(169));d?(r=Ex(r,a,po),x.__reactInternalMemoizedMergedChildContext=r,pt(Pn),pt(on),ft(on,r)):pt(Pn),ft(Pn,d)}var ir=null,yc=!1,$f=!1;function Tx(r){ir===null?ir=[r]:ir.push(r)}function DS(r){yc=!0,Tx(r)}function Mr(){if(!$f&&ir!==null){$f=!0;var r=0,a=nt;try{var d=ir;for(nt=1;r<d.length;r++){var x=d[r];do x=x(!0);while(x!==null)}ir=null,yc=!1}catch(k){throw ir!==null&&(ir=ir.slice(r+1)),pe(Qt,Mr),k}finally{nt=a,$f=!1}}return null}var ia=[],la=0,vc=null,bc=0,is=[],ls=0,ho=null,lr=1,cr="";function go(r,a){ia[la++]=bc,ia[la++]=vc,vc=r,bc=a}function Cx(r,a,d){is[ls++]=lr,is[ls++]=cr,is[ls++]=ho,ho=r;var x=lr;r=cr;var k=32-On(x)-1;x&=~(1<<k),d+=1;var N=32-On(a)+k;if(30<N){var A=k-k%5;N=(x&(1<<A)-1).toString(32),x>>=A,k-=A,lr=1<<32-On(a)+k|d<<k|x,cr=N+r}else lr=1<<N|d<<k|x,cr=r}function Tf(r){r.return!==null&&(go(r,1),Cx(r,1,0))}function Cf(r){for(;r===vc;)vc=ia[--la],ia[la]=null,bc=ia[--la],ia[la]=null;for(;r===ho;)ho=is[--ls],is[ls]=null,cr=is[--ls],is[ls]=null,lr=is[--ls],is[ls]=null}var Kn=null,Xn=null,gt=!1,Ts=null;function Rx(r,a){var d=fs(5,null,null,0);d.elementType="DELETED",d.stateNode=a,d.return=r,a=r.deletions,a===null?(r.deletions=[d],r.flags|=16):a.push(d)}function Ax(r,a){switch(r.tag){case 5:var d=r.type;return a=a.nodeType!==1||d.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(r.stateNode=a,Kn=r,Xn=Ar(a.firstChild),!0):!1;case 6:return a=r.pendingProps===""||a.nodeType!==3?null:a,a!==null?(r.stateNode=a,Kn=r,Xn=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(d=ho!==null?{id:lr,overflow:cr}:null,r.memoizedState={dehydrated:a,treeContext:d,retryLane:1073741824},d=fs(18,null,null,0),d.stateNode=a,d.return=r,r.child=d,Kn=r,Xn=null,!0):!1;default:return!1}}function Rf(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Af(r){if(gt){var a=Xn;if(a){var d=a;if(!Ax(r,a)){if(Rf(r))throw Error(n(418));a=Ar(d.nextSibling);var x=Kn;a&&Ax(r,a)?Rx(x,d):(r.flags=r.flags&-4097|2,gt=!1,Kn=r)}}else{if(Rf(r))throw Error(n(418));r.flags=r.flags&-4097|2,gt=!1,Kn=r}}}function Ox(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Kn=r}function wc(r){if(r!==Kn)return!1;if(!gt)return Ox(r),gt=!0,!1;var a;if((a=r.tag!==3)&&!(a=r.tag!==5)&&(a=r.type,a=a!=="head"&&a!=="body"&&!jf(r.type,r.memoizedProps)),a&&(a=Xn)){if(Rf(r))throw Px(),Error(n(418));for(;a;)Rx(r,a),a=Ar(a.nextSibling)}if(Ox(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,a=0;r;){if(r.nodeType===8){var d=r.data;if(d==="/$"){if(a===0){Xn=Ar(r.nextSibling);break e}a--}else d!=="$"&&d!=="$!"&&d!=="$?"||a++}r=r.nextSibling}Xn=null}}else Xn=Kn?Ar(r.stateNode.nextSibling):null;return!0}function Px(){for(var r=Xn;r;)r=Ar(r.nextSibling)}function ca(){Xn=Kn=null,gt=!1}function Of(r){Ts===null?Ts=[r]:Ts.push(r)}var FS=_.ReactCurrentBatchConfig;function Ni(r,a,d){if(r=d.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var x=d.stateNode}if(!x)throw Error(n(147,r));var k=x,N=""+r;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===N?a.ref:(a=function(A){var W=k.refs;A===null?delete W[N]:W[N]=A},a._stringRef=N,a)}if(typeof r!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,r))}return r}function kc(r,a){throw r=Object.prototype.toString.call(a),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r))}function Mx(r){var a=r._init;return a(r._payload)}function Lx(r){function a(te,Q){if(r){var se=te.deletions;se===null?(te.deletions=[Q],te.flags|=16):se.push(Q)}}function d(te,Q){if(!r)return null;for(;Q!==null;)a(te,Q),Q=Q.sibling;return null}function x(te,Q){for(te=new Map;Q!==null;)Q.key!==null?te.set(Q.key,Q):te.set(Q.index,Q),Q=Q.sibling;return te}function k(te,Q){return te=Hr(te,Q),te.index=0,te.sibling=null,te}function N(te,Q,se){return te.index=se,r?(se=te.alternate,se!==null?(se=se.index,se<Q?(te.flags|=2,Q):se):(te.flags|=2,Q)):(te.flags|=1048576,Q)}function A(te){return r&&te.alternate===null&&(te.flags|=2),te}function W(te,Q,se,ge){return Q===null||Q.tag!==6?(Q=Nm(se,te.mode,ge),Q.return=te,Q):(Q=k(Q,se),Q.return=te,Q)}function V(te,Q,se,ge){var Ce=se.type;return Ce===C?de(te,Q,se.props.children,ge,se.key):Q!==null&&(Q.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&Mx(Ce)===Q.type)?(ge=k(Q,se.props),ge.ref=Ni(te,Q,se),ge.return=te,ge):(ge=qc(se.type,se.key,se.props,null,te.mode,ge),ge.ref=Ni(te,Q,se),ge.return=te,ge)}function re(te,Q,se,ge){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==se.containerInfo||Q.stateNode.implementation!==se.implementation?(Q=Sm(se,te.mode,ge),Q.return=te,Q):(Q=k(Q,se.children||[]),Q.return=te,Q)}function de(te,Q,se,ge,Ce){return Q===null||Q.tag!==7?(Q=No(se,te.mode,ge,Ce),Q.return=te,Q):(Q=k(Q,se),Q.return=te,Q)}function me(te,Q,se){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=Nm(""+Q,te.mode,se),Q.return=te,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case $:return se=qc(Q.type,Q.key,Q.props,null,te.mode,se),se.ref=Ni(te,null,Q),se.return=te,se;case R:return Q=Sm(Q,te.mode,se),Q.return=te,Q;case P:var ge=Q._init;return me(te,ge(Q._payload),se)}if(Wt(Q)||G(Q))return Q=No(Q,te.mode,se,null),Q.return=te,Q;kc(te,Q)}return null}function ue(te,Q,se,ge){var Ce=Q!==null?Q.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Ce!==null?null:W(te,Q,""+se,ge);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case $:return se.key===Ce?V(te,Q,se,ge):null;case R:return se.key===Ce?re(te,Q,se,ge):null;case P:return Ce=se._init,ue(te,Q,Ce(se._payload),ge)}if(Wt(se)||G(se))return Ce!==null?null:de(te,Q,se,ge,null);kc(te,se)}return null}function ke(te,Q,se,ge,Ce){if(typeof ge=="string"&&ge!==""||typeof ge=="number")return te=te.get(se)||null,W(Q,te,""+ge,Ce);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case $:return te=te.get(ge.key===null?se:ge.key)||null,V(Q,te,ge,Ce);case R:return te=te.get(ge.key===null?se:ge.key)||null,re(Q,te,ge,Ce);case P:var Ie=ge._init;return ke(te,Q,se,Ie(ge._payload),Ce)}if(Wt(ge)||G(ge))return te=te.get(se)||null,de(Q,te,ge,Ce,null);kc(Q,ge)}return null}function _e(te,Q,se,ge){for(var Ce=null,Ie=null,ze=Q,Fe=Q=0,Gt=null;ze!==null&&Fe<se.length;Fe++){ze.index>Fe?(Gt=ze,ze=null):Gt=ze.sibling;var st=ue(te,ze,se[Fe],ge);if(st===null){ze===null&&(ze=Gt);break}r&&ze&&st.alternate===null&&a(te,ze),Q=N(st,Q,Fe),Ie===null?Ce=st:Ie.sibling=st,Ie=st,ze=Gt}if(Fe===se.length)return d(te,ze),gt&&go(te,Fe),Ce;if(ze===null){for(;Fe<se.length;Fe++)ze=me(te,se[Fe],ge),ze!==null&&(Q=N(ze,Q,Fe),Ie===null?Ce=ze:Ie.sibling=ze,Ie=ze);return gt&&go(te,Fe),Ce}for(ze=x(te,ze);Fe<se.length;Fe++)Gt=ke(ze,te,Fe,se[Fe],ge),Gt!==null&&(r&&Gt.alternate!==null&&ze.delete(Gt.key===null?Fe:Gt.key),Q=N(Gt,Q,Fe),Ie===null?Ce=Gt:Ie.sibling=Gt,Ie=Gt);return r&&ze.forEach(function(Br){return a(te,Br)}),gt&&go(te,Fe),Ce}function $e(te,Q,se,ge){var Ce=G(se);if(typeof Ce!="function")throw Error(n(150));if(se=Ce.call(se),se==null)throw Error(n(151));for(var Ie=Ce=null,ze=Q,Fe=Q=0,Gt=null,st=se.next();ze!==null&&!st.done;Fe++,st=se.next()){ze.index>Fe?(Gt=ze,ze=null):Gt=ze.sibling;var Br=ue(te,ze,st.value,ge);if(Br===null){ze===null&&(ze=Gt);break}r&&ze&&Br.alternate===null&&a(te,ze),Q=N(Br,Q,Fe),Ie===null?Ce=Br:Ie.sibling=Br,Ie=Br,ze=Gt}if(st.done)return d(te,ze),gt&&go(te,Fe),Ce;if(ze===null){for(;!st.done;Fe++,st=se.next())st=me(te,st.value,ge),st!==null&&(Q=N(st,Q,Fe),Ie===null?Ce=st:Ie.sibling=st,Ie=st);return gt&&go(te,Fe),Ce}for(ze=x(te,ze);!st.done;Fe++,st=se.next())st=ke(ze,te,Fe,st.value,ge),st!==null&&(r&&st.alternate!==null&&ze.delete(st.key===null?Fe:st.key),Q=N(st,Q,Fe),Ie===null?Ce=st:Ie.sibling=st,Ie=st);return r&&ze.forEach(function(v2){return a(te,v2)}),gt&&go(te,Fe),Ce}function $t(te,Q,se,ge){if(typeof se=="object"&&se!==null&&se.type===C&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case $:e:{for(var Ce=se.key,Ie=Q;Ie!==null;){if(Ie.key===Ce){if(Ce=se.type,Ce===C){if(Ie.tag===7){d(te,Ie.sibling),Q=k(Ie,se.props.children),Q.return=te,te=Q;break e}}else if(Ie.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&Mx(Ce)===Ie.type){d(te,Ie.sibling),Q=k(Ie,se.props),Q.ref=Ni(te,Ie,se),Q.return=te,te=Q;break e}d(te,Ie);break}else a(te,Ie);Ie=Ie.sibling}se.type===C?(Q=No(se.props.children,te.mode,ge,se.key),Q.return=te,te=Q):(ge=qc(se.type,se.key,se.props,null,te.mode,ge),ge.ref=Ni(te,Q,se),ge.return=te,te=ge)}return A(te);case R:e:{for(Ie=se.key;Q!==null;){if(Q.key===Ie)if(Q.tag===4&&Q.stateNode.containerInfo===se.containerInfo&&Q.stateNode.implementation===se.implementation){d(te,Q.sibling),Q=k(Q,se.children||[]),Q.return=te,te=Q;break e}else{d(te,Q);break}else a(te,Q);Q=Q.sibling}Q=Sm(se,te.mode,ge),Q.return=te,te=Q}return A(te);case P:return Ie=se._init,$t(te,Q,Ie(se._payload),ge)}if(Wt(se))return _e(te,Q,se,ge);if(G(se))return $e(te,Q,se,ge);kc(te,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,Q!==null&&Q.tag===6?(d(te,Q.sibling),Q=k(Q,se),Q.return=te,te=Q):(d(te,Q),Q=Nm(se,te.mode,ge),Q.return=te,te=Q),A(te)):d(te,Q)}return $t}var ua=Lx(!0),Ix=Lx(!1),jc=Or(null),Nc=null,da=null,Pf=null;function Mf(){Pf=da=Nc=null}function Lf(r){var a=jc.current;pt(jc),r._currentValue=a}function If(r,a,d){for(;r!==null;){var x=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,x!==null&&(x.childLanes|=a)):x!==null&&(x.childLanes&a)!==a&&(x.childLanes|=a),r===d)break;r=r.return}}function fa(r,a){Nc=r,Pf=da=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&a)!==0&&(Ln=!0),r.firstContext=null)}function cs(r){var a=r._currentValue;if(Pf!==r)if(r={context:r,memoizedValue:a,next:null},da===null){if(Nc===null)throw Error(n(308));da=r,Nc.dependencies={lanes:0,firstContext:r}}else da=da.next=r;return a}var xo=null;function zf(r){xo===null?xo=[r]:xo.push(r)}function zx(r,a,d,x){var k=a.interleaved;return k===null?(d.next=d,zf(a)):(d.next=k.next,k.next=d),a.interleaved=d,ur(r,x)}function ur(r,a){r.lanes|=a;var d=r.alternate;for(d!==null&&(d.lanes|=a),d=r,r=r.return;r!==null;)r.childLanes|=a,d=r.alternate,d!==null&&(d.childLanes|=a),d=r,r=r.return;return d.tag===3?d.stateNode:null}var Lr=!1;function Df(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Dx(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function dr(r,a){return{eventTime:r,lane:a,tag:0,payload:null,callback:null,next:null}}function Ir(r,a,d){var x=r.updateQueue;if(x===null)return null;if(x=x.shared,(tt&2)!==0){var k=x.pending;return k===null?a.next=a:(a.next=k.next,k.next=a),x.pending=a,ur(r,d)}return k=x.interleaved,k===null?(a.next=a,zf(x)):(a.next=k.next,k.next=a),x.interleaved=a,ur(r,d)}function Sc(r,a,d){if(a=a.updateQueue,a!==null&&(a=a.shared,(d&4194240)!==0)){var x=a.lanes;x&=r.pendingLanes,d|=x,a.lanes=d,fo(r,d)}}function Fx(r,a){var d=r.updateQueue,x=r.alternate;if(x!==null&&(x=x.updateQueue,d===x)){var k=null,N=null;if(d=d.firstBaseUpdate,d!==null){do{var A={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};N===null?k=N=A:N=N.next=A,d=d.next}while(d!==null);N===null?k=N=a:N=N.next=a}else k=N=a;d={baseState:x.baseState,firstBaseUpdate:k,lastBaseUpdate:N,shared:x.shared,effects:x.effects},r.updateQueue=d;return}r=d.lastBaseUpdate,r===null?d.firstBaseUpdate=a:r.next=a,d.lastBaseUpdate=a}function _c(r,a,d,x){var k=r.updateQueue;Lr=!1;var N=k.firstBaseUpdate,A=k.lastBaseUpdate,W=k.shared.pending;if(W!==null){k.shared.pending=null;var V=W,re=V.next;V.next=null,A===null?N=re:A.next=re,A=V;var de=r.alternate;de!==null&&(de=de.updateQueue,W=de.lastBaseUpdate,W!==A&&(W===null?de.firstBaseUpdate=re:W.next=re,de.lastBaseUpdate=V))}if(N!==null){var me=k.baseState;A=0,de=re=V=null,W=N;do{var ue=W.lane,ke=W.eventTime;if((x&ue)===ue){de!==null&&(de=de.next={eventTime:ke,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var _e=r,$e=W;switch(ue=a,ke=d,$e.tag){case 1:if(_e=$e.payload,typeof _e=="function"){me=_e.call(ke,me,ue);break e}me=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=$e.payload,ue=typeof _e=="function"?_e.call(ke,me,ue):_e,ue==null)break e;me=B({},me,ue);break e;case 2:Lr=!0}}W.callback!==null&&W.lane!==0&&(r.flags|=64,ue=k.effects,ue===null?k.effects=[W]:ue.push(W))}else ke={eventTime:ke,lane:ue,tag:W.tag,payload:W.payload,callback:W.callback,next:null},de===null?(re=de=ke,V=me):de=de.next=ke,A|=ue;if(W=W.next,W===null){if(W=k.shared.pending,W===null)break;ue=W,W=ue.next,ue.next=null,k.lastBaseUpdate=ue,k.shared.pending=null}}while(!0);if(de===null&&(V=me),k.baseState=V,k.firstBaseUpdate=re,k.lastBaseUpdate=de,a=k.shared.interleaved,a!==null){k=a;do A|=k.lane,k=k.next;while(k!==a)}else N===null&&(k.shared.lanes=0);bo|=A,r.lanes=A,r.memoizedState=me}}function Ux(r,a,d){if(r=a.effects,a.effects=null,r!==null)for(a=0;a<r.length;a++){var x=r[a],k=x.callback;if(k!==null){if(x.callback=null,x=d,typeof k!="function")throw Error(n(191,k));k.call(x)}}}var Si={},Gs=Or(Si),_i=Or(Si),Ei=Or(Si);function yo(r){if(r===Si)throw Error(n(174));return r}function Ff(r,a){switch(ft(Ei,a),ft(_i,r),ft(Gs,Si),r=a.nodeType,r){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:Me(null,"");break;default:r=r===8?a.parentNode:a,a=r.namespaceURI||null,r=r.tagName,a=Me(a,r)}pt(Gs),ft(Gs,a)}function ma(){pt(Gs),pt(_i),pt(Ei)}function Wx(r){yo(Ei.current);var a=yo(Gs.current),d=Me(a,r.type);a!==d&&(ft(_i,r),ft(Gs,d))}function Uf(r){_i.current===r&&(pt(Gs),pt(_i))}var bt=Or(0);function Ec(r){for(var a=r;a!==null;){if(a.tag===13){var d=a.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Wf=[];function Hf(){for(var r=0;r<Wf.length;r++)Wf[r]._workInProgressVersionPrimary=null;Wf.length=0}var $c=_.ReactCurrentDispatcher,Bf=_.ReactCurrentBatchConfig,vo=0,wt=null,zt=null,Ht=null,Tc=!1,$i=!1,Ti=0,US=0;function an(){throw Error(n(321))}function Gf(r,a){if(a===null)return!1;for(var d=0;d<a.length&&d<r.length;d++)if(!$s(r[d],a[d]))return!1;return!0}function qf(r,a,d,x,k,N){if(vo=N,wt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,$c.current=r===null||r.memoizedState===null?GS:qS,r=d(x,k),$i){N=0;do{if($i=!1,Ti=0,25<=N)throw Error(n(301));N+=1,Ht=zt=null,a.updateQueue=null,$c.current=VS,r=d(x,k)}while($i)}if($c.current=Ac,a=zt!==null&&zt.next!==null,vo=0,Ht=zt=wt=null,Tc=!1,a)throw Error(n(300));return r}function Vf(){var r=Ti!==0;return Ti=0,r}function qs(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ht===null?wt.memoizedState=Ht=r:Ht=Ht.next=r,Ht}function us(){if(zt===null){var r=wt.alternate;r=r!==null?r.memoizedState:null}else r=zt.next;var a=Ht===null?wt.memoizedState:Ht.next;if(a!==null)Ht=a,zt=r;else{if(r===null)throw Error(n(310));zt=r,r={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},Ht===null?wt.memoizedState=Ht=r:Ht=Ht.next=r}return Ht}function Ci(r,a){return typeof a=="function"?a(r):a}function Kf(r){var a=us(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var x=zt,k=x.baseQueue,N=d.pending;if(N!==null){if(k!==null){var A=k.next;k.next=N.next,N.next=A}x.baseQueue=k=N,d.pending=null}if(k!==null){N=k.next,x=x.baseState;var W=A=null,V=null,re=N;do{var de=re.lane;if((vo&de)===de)V!==null&&(V=V.next={lane:0,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),x=re.hasEagerState?re.eagerState:r(x,re.action);else{var me={lane:de,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null};V===null?(W=V=me,A=x):V=V.next=me,wt.lanes|=de,bo|=de}re=re.next}while(re!==null&&re!==N);V===null?A=x:V.next=W,$s(x,a.memoizedState)||(Ln=!0),a.memoizedState=x,a.baseState=A,a.baseQueue=V,d.lastRenderedState=x}if(r=d.interleaved,r!==null){k=r;do N=k.lane,wt.lanes|=N,bo|=N,k=k.next;while(k!==r)}else k===null&&(d.lanes=0);return[a.memoizedState,d.dispatch]}function Xf(r){var a=us(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var x=d.dispatch,k=d.pending,N=a.memoizedState;if(k!==null){d.pending=null;var A=k=k.next;do N=r(N,A.action),A=A.next;while(A!==k);$s(N,a.memoizedState)||(Ln=!0),a.memoizedState=N,a.baseQueue===null&&(a.baseState=N),d.lastRenderedState=N}return[N,x]}function Hx(){}function Bx(r,a){var d=wt,x=us(),k=a(),N=!$s(x.memoizedState,k);if(N&&(x.memoizedState=k,Ln=!0),x=x.queue,Yf(Vx.bind(null,d,x,r),[r]),x.getSnapshot!==a||N||Ht!==null&&Ht.memoizedState.tag&1){if(d.flags|=2048,Ri(9,qx.bind(null,d,x,k,a),void 0,null),Bt===null)throw Error(n(349));(vo&30)!==0||Gx(d,a,k)}return k}function Gx(r,a,d){r.flags|=16384,r={getSnapshot:a,value:d},a=wt.updateQueue,a===null?(a={lastEffect:null,stores:null},wt.updateQueue=a,a.stores=[r]):(d=a.stores,d===null?a.stores=[r]:d.push(r))}function qx(r,a,d,x){a.value=d,a.getSnapshot=x,Kx(a)&&Xx(r)}function Vx(r,a,d){return d(function(){Kx(a)&&Xx(r)})}function Kx(r){var a=r.getSnapshot;r=r.value;try{var d=a();return!$s(r,d)}catch{return!0}}function Xx(r){var a=ur(r,1);a!==null&&Os(a,r,1,-1)}function Yx(r){var a=qs();return typeof r=="function"&&(r=r()),a.memoizedState=a.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:r},a.queue=r,r=r.dispatch=BS.bind(null,wt,r),[a.memoizedState,r]}function Ri(r,a,d,x){return r={tag:r,create:a,destroy:d,deps:x,next:null},a=wt.updateQueue,a===null?(a={lastEffect:null,stores:null},wt.updateQueue=a,a.lastEffect=r.next=r):(d=a.lastEffect,d===null?a.lastEffect=r.next=r:(x=d.next,d.next=r,r.next=x,a.lastEffect=r)),r}function Qx(){return us().memoizedState}function Cc(r,a,d,x){var k=qs();wt.flags|=r,k.memoizedState=Ri(1|a,d,void 0,x===void 0?null:x)}function Rc(r,a,d,x){var k=us();x=x===void 0?null:x;var N=void 0;if(zt!==null){var A=zt.memoizedState;if(N=A.destroy,x!==null&&Gf(x,A.deps)){k.memoizedState=Ri(a,d,N,x);return}}wt.flags|=r,k.memoizedState=Ri(1|a,d,N,x)}function Zx(r,a){return Cc(8390656,8,r,a)}function Yf(r,a){return Rc(2048,8,r,a)}function Jx(r,a){return Rc(4,2,r,a)}function ey(r,a){return Rc(4,4,r,a)}function ty(r,a){if(typeof a=="function")return r=r(),a(r),function(){a(null)};if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function ny(r,a,d){return d=d!=null?d.concat([r]):null,Rc(4,4,ty.bind(null,a,r),d)}function Qf(){}function sy(r,a){var d=us();a=a===void 0?null:a;var x=d.memoizedState;return x!==null&&a!==null&&Gf(a,x[1])?x[0]:(d.memoizedState=[r,a],r)}function ry(r,a){var d=us();a=a===void 0?null:a;var x=d.memoizedState;return x!==null&&a!==null&&Gf(a,x[1])?x[0]:(r=r(),d.memoizedState=[r,a],r)}function oy(r,a,d){return(vo&21)===0?(r.baseState&&(r.baseState=!1,Ln=!0),r.memoizedState=d):($s(d,a)||(d=Yo(),wt.lanes|=d,bo|=d,r.baseState=!0),a)}function WS(r,a){var d=nt;nt=d!==0&&4>d?d:4,r(!0);var x=Bf.transition;Bf.transition={};try{r(!1),a()}finally{nt=d,Bf.transition=x}}function ay(){return us().memoizedState}function HS(r,a,d){var x=Ur(r);if(d={lane:x,action:d,hasEagerState:!1,eagerState:null,next:null},iy(r))ly(a,d);else if(d=zx(r,a,d,x),d!==null){var k=xn();Os(d,r,x,k),cy(d,a,x)}}function BS(r,a,d){var x=Ur(r),k={lane:x,action:d,hasEagerState:!1,eagerState:null,next:null};if(iy(r))ly(a,k);else{var N=r.alternate;if(r.lanes===0&&(N===null||N.lanes===0)&&(N=a.lastRenderedReducer,N!==null))try{var A=a.lastRenderedState,W=N(A,d);if(k.hasEagerState=!0,k.eagerState=W,$s(W,A)){var V=a.interleaved;V===null?(k.next=k,zf(a)):(k.next=V.next,V.next=k),a.interleaved=k;return}}catch{}finally{}d=zx(r,a,k,x),d!==null&&(k=xn(),Os(d,r,x,k),cy(d,a,x))}}function iy(r){var a=r.alternate;return r===wt||a!==null&&a===wt}function ly(r,a){$i=Tc=!0;var d=r.pending;d===null?a.next=a:(a.next=d.next,d.next=a),r.pending=a}function cy(r,a,d){if((d&4194240)!==0){var x=a.lanes;x&=r.pendingLanes,d|=x,a.lanes=d,fo(r,d)}}var Ac={readContext:cs,useCallback:an,useContext:an,useEffect:an,useImperativeHandle:an,useInsertionEffect:an,useLayoutEffect:an,useMemo:an,useReducer:an,useRef:an,useState:an,useDebugValue:an,useDeferredValue:an,useTransition:an,useMutableSource:an,useSyncExternalStore:an,useId:an,unstable_isNewReconciler:!1},GS={readContext:cs,useCallback:function(r,a){return qs().memoizedState=[r,a===void 0?null:a],r},useContext:cs,useEffect:Zx,useImperativeHandle:function(r,a,d){return d=d!=null?d.concat([r]):null,Cc(4194308,4,ty.bind(null,a,r),d)},useLayoutEffect:function(r,a){return Cc(4194308,4,r,a)},useInsertionEffect:function(r,a){return Cc(4,2,r,a)},useMemo:function(r,a){var d=qs();return a=a===void 0?null:a,r=r(),d.memoizedState=[r,a],r},useReducer:function(r,a,d){var x=qs();return a=d!==void 0?d(a):a,x.memoizedState=x.baseState=a,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:a},x.queue=r,r=r.dispatch=HS.bind(null,wt,r),[x.memoizedState,r]},useRef:function(r){var a=qs();return r={current:r},a.memoizedState=r},useState:Yx,useDebugValue:Qf,useDeferredValue:function(r){return qs().memoizedState=r},useTransition:function(){var r=Yx(!1),a=r[0];return r=WS.bind(null,r[1]),qs().memoizedState=r,[a,r]},useMutableSource:function(){},useSyncExternalStore:function(r,a,d){var x=wt,k=qs();if(gt){if(d===void 0)throw Error(n(407));d=d()}else{if(d=a(),Bt===null)throw Error(n(349));(vo&30)!==0||Gx(x,a,d)}k.memoizedState=d;var N={value:d,getSnapshot:a};return k.queue=N,Zx(Vx.bind(null,x,N,r),[r]),x.flags|=2048,Ri(9,qx.bind(null,x,N,d,a),void 0,null),d},useId:function(){var r=qs(),a=Bt.identifierPrefix;if(gt){var d=cr,x=lr;d=(x&~(1<<32-On(x)-1)).toString(32)+d,a=":"+a+"R"+d,d=Ti++,0<d&&(a+="H"+d.toString(32)),a+=":"}else d=US++,a=":"+a+"r"+d.toString(32)+":";return r.memoizedState=a},unstable_isNewReconciler:!1},qS={readContext:cs,useCallback:sy,useContext:cs,useEffect:Yf,useImperativeHandle:ny,useInsertionEffect:Jx,useLayoutEffect:ey,useMemo:ry,useReducer:Kf,useRef:Qx,useState:function(){return Kf(Ci)},useDebugValue:Qf,useDeferredValue:function(r){var a=us();return oy(a,zt.memoizedState,r)},useTransition:function(){var r=Kf(Ci)[0],a=us().memoizedState;return[r,a]},useMutableSource:Hx,useSyncExternalStore:Bx,useId:ay,unstable_isNewReconciler:!1},VS={readContext:cs,useCallback:sy,useContext:cs,useEffect:Yf,useImperativeHandle:ny,useInsertionEffect:Jx,useLayoutEffect:ey,useMemo:ry,useReducer:Xf,useRef:Qx,useState:function(){return Xf(Ci)},useDebugValue:Qf,useDeferredValue:function(r){var a=us();return zt===null?a.memoizedState=r:oy(a,zt.memoizedState,r)},useTransition:function(){var r=Xf(Ci)[0],a=us().memoizedState;return[r,a]},useMutableSource:Hx,useSyncExternalStore:Bx,useId:ay,unstable_isNewReconciler:!1};function Cs(r,a){if(r&&r.defaultProps){a=B({},a),r=r.defaultProps;for(var d in r)a[d]===void 0&&(a[d]=r[d]);return a}return a}function Zf(r,a,d,x){a=r.memoizedState,d=d(x,a),d=d==null?a:B({},a,d),r.memoizedState=d,r.lanes===0&&(r.updateQueue.baseState=d)}var Oc={isMounted:function(r){return(r=r._reactInternals)?Gn(r)===r:!1},enqueueSetState:function(r,a,d){r=r._reactInternals;var x=xn(),k=Ur(r),N=dr(x,k);N.payload=a,d!=null&&(N.callback=d),a=Ir(r,N,k),a!==null&&(Os(a,r,k,x),Sc(a,r,k))},enqueueReplaceState:function(r,a,d){r=r._reactInternals;var x=xn(),k=Ur(r),N=dr(x,k);N.tag=1,N.payload=a,d!=null&&(N.callback=d),a=Ir(r,N,k),a!==null&&(Os(a,r,k,x),Sc(a,r,k))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var d=xn(),x=Ur(r),k=dr(d,x);k.tag=2,a!=null&&(k.callback=a),a=Ir(r,k,x),a!==null&&(Os(a,r,x,d),Sc(a,r,x))}};function uy(r,a,d,x,k,N,A){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(x,N,A):a.prototype&&a.prototype.isPureReactComponent?!xi(d,x)||!xi(k,N):!0}function dy(r,a,d){var x=!1,k=Pr,N=a.contextType;return typeof N=="object"&&N!==null?N=cs(N):(k=Mn(a)?po:on.current,x=a.contextTypes,N=(x=x!=null)?aa(r,k):Pr),a=new a(d,N),r.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Oc,r.stateNode=a,a._reactInternals=r,x&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=k,r.__reactInternalMemoizedMaskedChildContext=N),a}function fy(r,a,d,x){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(d,x),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(d,x),a.state!==r&&Oc.enqueueReplaceState(a,a.state,null)}function Jf(r,a,d,x){var k=r.stateNode;k.props=d,k.state=r.memoizedState,k.refs={},Df(r);var N=a.contextType;typeof N=="object"&&N!==null?k.context=cs(N):(N=Mn(a)?po:on.current,k.context=aa(r,N)),k.state=r.memoizedState,N=a.getDerivedStateFromProps,typeof N=="function"&&(Zf(r,a,N,d),k.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof k.getSnapshotBeforeUpdate=="function"||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(a=k.state,typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount(),a!==k.state&&Oc.enqueueReplaceState(k,k.state,null),_c(r,d,k,x),k.state=r.memoizedState),typeof k.componentDidMount=="function"&&(r.flags|=4194308)}function pa(r,a){try{var d="",x=a;do d+=ae(x),x=x.return;while(x);var k=d}catch(N){k=`
39
+ Error generating stack: `+N.message+`
40
+ `+N.stack}return{value:r,source:a,stack:k,digest:null}}function em(r,a,d){return{value:r,source:null,stack:d??null,digest:a??null}}function tm(r,a){try{console.error(a.value)}catch(d){setTimeout(function(){throw d})}}var KS=typeof WeakMap=="function"?WeakMap:Map;function my(r,a,d){d=dr(-1,d),d.tag=3,d.payload={element:null};var x=a.value;return d.callback=function(){Fc||(Fc=!0,gm=x),tm(r,a)},d}function py(r,a,d){d=dr(-1,d),d.tag=3;var x=r.type.getDerivedStateFromError;if(typeof x=="function"){var k=a.value;d.payload=function(){return x(k)},d.callback=function(){tm(r,a)}}var N=r.stateNode;return N!==null&&typeof N.componentDidCatch=="function"&&(d.callback=function(){tm(r,a),typeof x!="function"&&(Dr===null?Dr=new Set([this]):Dr.add(this));var A=a.stack;this.componentDidCatch(a.value,{componentStack:A!==null?A:""})}),d}function hy(r,a,d){var x=r.pingCache;if(x===null){x=r.pingCache=new KS;var k=new Set;x.set(a,k)}else k=x.get(a),k===void 0&&(k=new Set,x.set(a,k));k.has(d)||(k.add(d),r=l2.bind(null,r,a,d),a.then(r,r))}function gy(r){do{var a;if((a=r.tag===13)&&(a=r.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return r;r=r.return}while(r!==null);return null}function xy(r,a,d,x,k){return(r.mode&1)===0?(r===a?r.flags|=65536:(r.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(a=dr(-1,1),a.tag=2,Ir(d,a,1))),d.lanes|=1),r):(r.flags|=65536,r.lanes=k,r)}var XS=_.ReactCurrentOwner,Ln=!1;function gn(r,a,d,x){a.child=r===null?Ix(a,null,d,x):ua(a,r.child,d,x)}function yy(r,a,d,x,k){d=d.render;var N=a.ref;return fa(a,k),x=qf(r,a,d,x,N,k),d=Vf(),r!==null&&!Ln?(a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~k,fr(r,a,k)):(gt&&d&&Tf(a),a.flags|=1,gn(r,a,x,k),a.child)}function vy(r,a,d,x,k){if(r===null){var N=d.type;return typeof N=="function"&&!jm(N)&&N.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(a.tag=15,a.type=N,by(r,a,N,x,k)):(r=qc(d.type,null,x,a,a.mode,k),r.ref=a.ref,r.return=a,a.child=r)}if(N=r.child,(r.lanes&k)===0){var A=N.memoizedProps;if(d=d.compare,d=d!==null?d:xi,d(A,x)&&r.ref===a.ref)return fr(r,a,k)}return a.flags|=1,r=Hr(N,x),r.ref=a.ref,r.return=a,a.child=r}function by(r,a,d,x,k){if(r!==null){var N=r.memoizedProps;if(xi(N,x)&&r.ref===a.ref)if(Ln=!1,a.pendingProps=x=N,(r.lanes&k)!==0)(r.flags&131072)!==0&&(Ln=!0);else return a.lanes=r.lanes,fr(r,a,k)}return nm(r,a,d,x,k)}function wy(r,a,d){var x=a.pendingProps,k=x.children,N=r!==null?r.memoizedState:null;if(x.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},ft(ga,Yn),Yn|=d;else{if((d&1073741824)===0)return r=N!==null?N.baseLanes|d:d,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:r,cachePool:null,transitions:null},a.updateQueue=null,ft(ga,Yn),Yn|=r,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=N!==null?N.baseLanes:d,ft(ga,Yn),Yn|=x}else N!==null?(x=N.baseLanes|d,a.memoizedState=null):x=d,ft(ga,Yn),Yn|=x;return gn(r,a,k,d),a.child}function ky(r,a){var d=a.ref;(r===null&&d!==null||r!==null&&r.ref!==d)&&(a.flags|=512,a.flags|=2097152)}function nm(r,a,d,x,k){var N=Mn(d)?po:on.current;return N=aa(a,N),fa(a,k),d=qf(r,a,d,x,N,k),x=Vf(),r!==null&&!Ln?(a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~k,fr(r,a,k)):(gt&&x&&Tf(a),a.flags|=1,gn(r,a,d,k),a.child)}function jy(r,a,d,x,k){if(Mn(d)){var N=!0;xc(a)}else N=!1;if(fa(a,k),a.stateNode===null)Mc(r,a),dy(a,d,x),Jf(a,d,x,k),x=!0;else if(r===null){var A=a.stateNode,W=a.memoizedProps;A.props=W;var V=A.context,re=d.contextType;typeof re=="object"&&re!==null?re=cs(re):(re=Mn(d)?po:on.current,re=aa(a,re));var de=d.getDerivedStateFromProps,me=typeof de=="function"||typeof A.getSnapshotBeforeUpdate=="function";me||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(W!==x||V!==re)&&fy(a,A,x,re),Lr=!1;var ue=a.memoizedState;A.state=ue,_c(a,x,A,k),V=a.memoizedState,W!==x||ue!==V||Pn.current||Lr?(typeof de=="function"&&(Zf(a,d,de,x),V=a.memoizedState),(W=Lr||uy(a,d,W,x,ue,V,re))?(me||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(a.flags|=4194308)):(typeof A.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=x,a.memoizedState=V),A.props=x,A.state=V,A.context=re,x=W):(typeof A.componentDidMount=="function"&&(a.flags|=4194308),x=!1)}else{A=a.stateNode,Dx(r,a),W=a.memoizedProps,re=a.type===a.elementType?W:Cs(a.type,W),A.props=re,me=a.pendingProps,ue=A.context,V=d.contextType,typeof V=="object"&&V!==null?V=cs(V):(V=Mn(d)?po:on.current,V=aa(a,V));var ke=d.getDerivedStateFromProps;(de=typeof ke=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(W!==me||ue!==V)&&fy(a,A,x,V),Lr=!1,ue=a.memoizedState,A.state=ue,_c(a,x,A,k);var _e=a.memoizedState;W!==me||ue!==_e||Pn.current||Lr?(typeof ke=="function"&&(Zf(a,d,ke,x),_e=a.memoizedState),(re=Lr||uy(a,d,re,x,ue,_e,V)||!1)?(de||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(x,_e,V),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(x,_e,V)),typeof A.componentDidUpdate=="function"&&(a.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof A.componentDidUpdate!="function"||W===r.memoizedProps&&ue===r.memoizedState||(a.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||W===r.memoizedProps&&ue===r.memoizedState||(a.flags|=1024),a.memoizedProps=x,a.memoizedState=_e),A.props=x,A.state=_e,A.context=V,x=re):(typeof A.componentDidUpdate!="function"||W===r.memoizedProps&&ue===r.memoizedState||(a.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||W===r.memoizedProps&&ue===r.memoizedState||(a.flags|=1024),x=!1)}return sm(r,a,d,x,N,k)}function sm(r,a,d,x,k,N){ky(r,a);var A=(a.flags&128)!==0;if(!x&&!A)return k&&$x(a,d,!1),fr(r,a,N);x=a.stateNode,XS.current=a;var W=A&&typeof d.getDerivedStateFromError!="function"?null:x.render();return a.flags|=1,r!==null&&A?(a.child=ua(a,r.child,null,N),a.child=ua(a,null,W,N)):gn(r,a,W,N),a.memoizedState=x.state,k&&$x(a,d,!0),a.child}function Ny(r){var a=r.stateNode;a.pendingContext?_x(r,a.pendingContext,a.pendingContext!==a.context):a.context&&_x(r,a.context,!1),Ff(r,a.containerInfo)}function Sy(r,a,d,x,k){return ca(),Of(k),a.flags|=256,gn(r,a,d,x),a.child}var rm={dehydrated:null,treeContext:null,retryLane:0};function om(r){return{baseLanes:r,cachePool:null,transitions:null}}function _y(r,a,d){var x=a.pendingProps,k=bt.current,N=!1,A=(a.flags&128)!==0,W;if((W=A)||(W=r!==null&&r.memoizedState===null?!1:(k&2)!==0),W?(N=!0,a.flags&=-129):(r===null||r.memoizedState!==null)&&(k|=1),ft(bt,k&1),r===null)return Af(a),r=a.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((a.mode&1)===0?a.lanes=1:r.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(A=x.children,r=x.fallback,N?(x=a.mode,N=a.child,A={mode:"hidden",children:A},(x&1)===0&&N!==null?(N.childLanes=0,N.pendingProps=A):N=Vc(A,x,0,null),r=No(r,x,d,null),N.return=a,r.return=a,N.sibling=r,a.child=N,a.child.memoizedState=om(d),a.memoizedState=rm,r):am(a,A));if(k=r.memoizedState,k!==null&&(W=k.dehydrated,W!==null))return YS(r,a,A,x,W,k,d);if(N){N=x.fallback,A=a.mode,k=r.child,W=k.sibling;var V={mode:"hidden",children:x.children};return(A&1)===0&&a.child!==k?(x=a.child,x.childLanes=0,x.pendingProps=V,a.deletions=null):(x=Hr(k,V),x.subtreeFlags=k.subtreeFlags&14680064),W!==null?N=Hr(W,N):(N=No(N,A,d,null),N.flags|=2),N.return=a,x.return=a,x.sibling=N,a.child=x,x=N,N=a.child,A=r.child.memoizedState,A=A===null?om(d):{baseLanes:A.baseLanes|d,cachePool:null,transitions:A.transitions},N.memoizedState=A,N.childLanes=r.childLanes&~d,a.memoizedState=rm,x}return N=r.child,r=N.sibling,x=Hr(N,{mode:"visible",children:x.children}),(a.mode&1)===0&&(x.lanes=d),x.return=a,x.sibling=null,r!==null&&(d=a.deletions,d===null?(a.deletions=[r],a.flags|=16):d.push(r)),a.child=x,a.memoizedState=null,x}function am(r,a){return a=Vc({mode:"visible",children:a},r.mode,0,null),a.return=r,r.child=a}function Pc(r,a,d,x){return x!==null&&Of(x),ua(a,r.child,null,d),r=am(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function YS(r,a,d,x,k,N,A){if(d)return a.flags&256?(a.flags&=-257,x=em(Error(n(422))),Pc(r,a,A,x)):a.memoizedState!==null?(a.child=r.child,a.flags|=128,null):(N=x.fallback,k=a.mode,x=Vc({mode:"visible",children:x.children},k,0,null),N=No(N,k,A,null),N.flags|=2,x.return=a,N.return=a,x.sibling=N,a.child=x,(a.mode&1)!==0&&ua(a,r.child,null,A),a.child.memoizedState=om(A),a.memoizedState=rm,N);if((a.mode&1)===0)return Pc(r,a,A,null);if(k.data==="$!"){if(x=k.nextSibling&&k.nextSibling.dataset,x)var W=x.dgst;return x=W,N=Error(n(419)),x=em(N,x,void 0),Pc(r,a,A,x)}if(W=(A&r.childLanes)!==0,Ln||W){if(x=Bt,x!==null){switch(A&-A){case 4:k=2;break;case 16:k=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:k=32;break;case 536870912:k=268435456;break;default:k=0}k=(k&(x.suspendedLanes|A))!==0?0:k,k!==0&&k!==N.retryLane&&(N.retryLane=k,ur(r,k),Os(x,r,k,-1))}return km(),x=em(Error(n(421))),Pc(r,a,A,x)}return k.data==="$?"?(a.flags|=128,a.child=r.child,a=c2.bind(null,r),k._reactRetry=a,null):(r=N.treeContext,Xn=Ar(k.nextSibling),Kn=a,gt=!0,Ts=null,r!==null&&(is[ls++]=lr,is[ls++]=cr,is[ls++]=ho,lr=r.id,cr=r.overflow,ho=a),a=am(a,x.children),a.flags|=4096,a)}function Ey(r,a,d){r.lanes|=a;var x=r.alternate;x!==null&&(x.lanes|=a),If(r.return,a,d)}function im(r,a,d,x,k){var N=r.memoizedState;N===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:x,tail:d,tailMode:k}:(N.isBackwards=a,N.rendering=null,N.renderingStartTime=0,N.last=x,N.tail=d,N.tailMode=k)}function $y(r,a,d){var x=a.pendingProps,k=x.revealOrder,N=x.tail;if(gn(r,a,x.children,d),x=bt.current,(x&2)!==0)x=x&1|2,a.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ey(r,d,a);else if(r.tag===19)Ey(r,d,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}x&=1}if(ft(bt,x),(a.mode&1)===0)a.memoizedState=null;else switch(k){case"forwards":for(d=a.child,k=null;d!==null;)r=d.alternate,r!==null&&Ec(r)===null&&(k=d),d=d.sibling;d=k,d===null?(k=a.child,a.child=null):(k=d.sibling,d.sibling=null),im(a,!1,k,d,N);break;case"backwards":for(d=null,k=a.child,a.child=null;k!==null;){if(r=k.alternate,r!==null&&Ec(r)===null){a.child=k;break}r=k.sibling,k.sibling=d,d=k,k=r}im(a,!0,d,null,N);break;case"together":im(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Mc(r,a){(a.mode&1)===0&&r!==null&&(r.alternate=null,a.alternate=null,a.flags|=2)}function fr(r,a,d){if(r!==null&&(a.dependencies=r.dependencies),bo|=a.lanes,(d&a.childLanes)===0)return null;if(r!==null&&a.child!==r.child)throw Error(n(153));if(a.child!==null){for(r=a.child,d=Hr(r,r.pendingProps),a.child=d,d.return=a;r.sibling!==null;)r=r.sibling,d=d.sibling=Hr(r,r.pendingProps),d.return=a;d.sibling=null}return a.child}function QS(r,a,d){switch(a.tag){case 3:Ny(a),ca();break;case 5:Wx(a);break;case 1:Mn(a.type)&&xc(a);break;case 4:Ff(a,a.stateNode.containerInfo);break;case 10:var x=a.type._context,k=a.memoizedProps.value;ft(jc,x._currentValue),x._currentValue=k;break;case 13:if(x=a.memoizedState,x!==null)return x.dehydrated!==null?(ft(bt,bt.current&1),a.flags|=128,null):(d&a.child.childLanes)!==0?_y(r,a,d):(ft(bt,bt.current&1),r=fr(r,a,d),r!==null?r.sibling:null);ft(bt,bt.current&1);break;case 19:if(x=(d&a.childLanes)!==0,(r.flags&128)!==0){if(x)return $y(r,a,d);a.flags|=128}if(k=a.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),ft(bt,bt.current),x)break;return null;case 22:case 23:return a.lanes=0,wy(r,a,d)}return fr(r,a,d)}var Ty,lm,Cy,Ry;Ty=function(r,a){for(var d=a.child;d!==null;){if(d.tag===5||d.tag===6)r.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===a)break;for(;d.sibling===null;){if(d.return===null||d.return===a)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},lm=function(){},Cy=function(r,a,d,x){var k=r.memoizedProps;if(k!==x){r=a.stateNode,yo(Gs.current);var N=null;switch(d){case"input":k=Re(r,k),x=Re(r,x),N=[];break;case"select":k=B({},k,{value:void 0}),x=B({},x,{value:void 0}),N=[];break;case"textarea":k=ss(r,k),x=ss(r,x),N=[];break;default:typeof k.onClick!="function"&&typeof x.onClick=="function"&&(r.onclick=pc)}rs(d,x);var A;d=null;for(re in k)if(!x.hasOwnProperty(re)&&k.hasOwnProperty(re)&&k[re]!=null)if(re==="style"){var W=k[re];for(A in W)W.hasOwnProperty(A)&&(d||(d={}),d[A]="")}else re!=="dangerouslySetInnerHTML"&&re!=="children"&&re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&re!=="autoFocus"&&(i.hasOwnProperty(re)?N||(N=[]):(N=N||[]).push(re,null));for(re in x){var V=x[re];if(W=k!=null?k[re]:void 0,x.hasOwnProperty(re)&&V!==W&&(V!=null||W!=null))if(re==="style")if(W){for(A in W)!W.hasOwnProperty(A)||V&&V.hasOwnProperty(A)||(d||(d={}),d[A]="");for(A in V)V.hasOwnProperty(A)&&W[A]!==V[A]&&(d||(d={}),d[A]=V[A])}else d||(N||(N=[]),N.push(re,d)),d=V;else re==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,W=W?W.__html:void 0,V!=null&&W!==V&&(N=N||[]).push(re,V)):re==="children"?typeof V!="string"&&typeof V!="number"||(N=N||[]).push(re,""+V):re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&(i.hasOwnProperty(re)?(V!=null&&re==="onScroll"&&mt("scroll",r),N||W===V||(N=[])):(N=N||[]).push(re,V))}d&&(N=N||[]).push("style",d);var re=N;(a.updateQueue=re)&&(a.flags|=4)}},Ry=function(r,a,d,x){d!==x&&(a.flags|=4)};function Ai(r,a){if(!gt)switch(r.tailMode){case"hidden":a=r.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?r.tail=null:d.sibling=null;break;case"collapsed":d=r.tail;for(var x=null;d!==null;)d.alternate!==null&&(x=d),d=d.sibling;x===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:x.sibling=null}}function ln(r){var a=r.alternate!==null&&r.alternate.child===r.child,d=0,x=0;if(a)for(var k=r.child;k!==null;)d|=k.lanes|k.childLanes,x|=k.subtreeFlags&14680064,x|=k.flags&14680064,k.return=r,k=k.sibling;else for(k=r.child;k!==null;)d|=k.lanes|k.childLanes,x|=k.subtreeFlags,x|=k.flags,k.return=r,k=k.sibling;return r.subtreeFlags|=x,r.childLanes=d,a}function ZS(r,a,d){var x=a.pendingProps;switch(Cf(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ln(a),null;case 1:return Mn(a.type)&&gc(),ln(a),null;case 3:return x=a.stateNode,ma(),pt(Pn),pt(on),Hf(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(r===null||r.child===null)&&(wc(a)?a.flags|=4:r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Ts!==null&&(vm(Ts),Ts=null))),lm(r,a),ln(a),null;case 5:Uf(a);var k=yo(Ei.current);if(d=a.type,r!==null&&a.stateNode!=null)Cy(r,a,d,x,k),r.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!x){if(a.stateNode===null)throw Error(n(166));return ln(a),null}if(r=yo(Gs.current),wc(a)){x=a.stateNode,d=a.type;var N=a.memoizedProps;switch(x[Bs]=a,x[ki]=N,r=(a.mode&1)!==0,d){case"dialog":mt("cancel",x),mt("close",x);break;case"iframe":case"object":case"embed":mt("load",x);break;case"video":case"audio":for(k=0;k<vi.length;k++)mt(vi[k],x);break;case"source":mt("error",x);break;case"img":case"image":case"link":mt("error",x),mt("load",x);break;case"details":mt("toggle",x);break;case"input":Xe(x,N),mt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!N.multiple},mt("invalid",x);break;case"textarea":hn(x,N),mt("invalid",x)}rs(d,N),k=null;for(var A in N)if(N.hasOwnProperty(A)){var W=N[A];A==="children"?typeof W=="string"?x.textContent!==W&&(N.suppressHydrationWarning!==!0&&mc(x.textContent,W,r),k=["children",W]):typeof W=="number"&&x.textContent!==""+W&&(N.suppressHydrationWarning!==!0&&mc(x.textContent,W,r),k=["children",""+W]):i.hasOwnProperty(A)&&W!=null&&A==="onScroll"&&mt("scroll",x)}switch(d){case"input":Oe(x),et(x,N,!0);break;case"textarea":Oe(x),at(x);break;case"select":case"option":break;default:typeof N.onClick=="function"&&(x.onclick=pc)}x=k,a.updateQueue=x,x!==null&&(a.flags|=4)}else{A=k.nodeType===9?k:k.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=ct(d)),r==="http://www.w3.org/1999/xhtml"?d==="script"?(r=A.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof x.is=="string"?r=A.createElement(d,{is:x.is}):(r=A.createElement(d),d==="select"&&(A=r,x.multiple?A.multiple=!0:x.size&&(A.size=x.size))):r=A.createElementNS(r,d),r[Bs]=a,r[ki]=x,Ty(r,a,!1,!1),a.stateNode=r;e:{switch(A=os(d,x),d){case"dialog":mt("cancel",r),mt("close",r),k=x;break;case"iframe":case"object":case"embed":mt("load",r),k=x;break;case"video":case"audio":for(k=0;k<vi.length;k++)mt(vi[k],r);k=x;break;case"source":mt("error",r),k=x;break;case"img":case"image":case"link":mt("error",r),mt("load",r),k=x;break;case"details":mt("toggle",r),k=x;break;case"input":Xe(r,x),k=Re(r,x),mt("invalid",r);break;case"option":k=x;break;case"select":r._wrapperState={wasMultiple:!!x.multiple},k=B({},x,{value:void 0}),mt("invalid",r);break;case"textarea":hn(r,x),k=ss(r,x),mt("invalid",r);break;default:k=x}rs(d,k),W=k;for(N in W)if(W.hasOwnProperty(N)){var V=W[N];N==="style"?Yt(r,V):N==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,V!=null&&At(r,V)):N==="children"?typeof V=="string"?(d!=="textarea"||V!=="")&&ut(r,V):typeof V=="number"&&ut(r,""+V):N!=="suppressContentEditableWarning"&&N!=="suppressHydrationWarning"&&N!=="autoFocus"&&(i.hasOwnProperty(N)?V!=null&&N==="onScroll"&&mt("scroll",r):V!=null&&E(r,N,V,A))}switch(d){case"input":Oe(r),et(r,x,!1);break;case"textarea":Oe(r),at(r);break;case"option":x.value!=null&&r.setAttribute("value",""+ye(x.value));break;case"select":r.multiple=!!x.multiple,N=x.value,N!=null?jt(r,!!x.multiple,N,!1):x.defaultValue!=null&&jt(r,!!x.multiple,x.defaultValue,!0);break;default:typeof k.onClick=="function"&&(r.onclick=pc)}switch(d){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return ln(a),null;case 6:if(r&&a.stateNode!=null)Ry(r,a,r.memoizedProps,x);else{if(typeof x!="string"&&a.stateNode===null)throw Error(n(166));if(d=yo(Ei.current),yo(Gs.current),wc(a)){if(x=a.stateNode,d=a.memoizedProps,x[Bs]=a,(N=x.nodeValue!==d)&&(r=Kn,r!==null))switch(r.tag){case 3:mc(x.nodeValue,d,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&mc(x.nodeValue,d,(r.mode&1)!==0)}N&&(a.flags|=4)}else x=(d.nodeType===9?d:d.ownerDocument).createTextNode(x),x[Bs]=a,a.stateNode=x}return ln(a),null;case 13:if(pt(bt),x=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(gt&&Xn!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Px(),ca(),a.flags|=98560,N=!1;else if(N=wc(a),x!==null&&x.dehydrated!==null){if(r===null){if(!N)throw Error(n(318));if(N=a.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(n(317));N[Bs]=a}else ca(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;ln(a),N=!1}else Ts!==null&&(vm(Ts),Ts=null),N=!0;if(!N)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=d,a):(x=x!==null,x!==(r!==null&&r.memoizedState!==null)&&x&&(a.child.flags|=8192,(a.mode&1)!==0&&(r===null||(bt.current&1)!==0?Dt===0&&(Dt=3):km())),a.updateQueue!==null&&(a.flags|=4),ln(a),null);case 4:return ma(),lm(r,a),r===null&&bi(a.stateNode.containerInfo),ln(a),null;case 10:return Lf(a.type._context),ln(a),null;case 17:return Mn(a.type)&&gc(),ln(a),null;case 19:if(pt(bt),N=a.memoizedState,N===null)return ln(a),null;if(x=(a.flags&128)!==0,A=N.rendering,A===null)if(x)Ai(N,!1);else{if(Dt!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(A=Ec(r),A!==null){for(a.flags|=128,Ai(N,!1),x=A.updateQueue,x!==null&&(a.updateQueue=x,a.flags|=4),a.subtreeFlags=0,x=d,d=a.child;d!==null;)N=d,r=x,N.flags&=14680066,A=N.alternate,A===null?(N.childLanes=0,N.lanes=r,N.child=null,N.subtreeFlags=0,N.memoizedProps=null,N.memoizedState=null,N.updateQueue=null,N.dependencies=null,N.stateNode=null):(N.childLanes=A.childLanes,N.lanes=A.lanes,N.child=A.child,N.subtreeFlags=0,N.deletions=null,N.memoizedProps=A.memoizedProps,N.memoizedState=A.memoizedState,N.updateQueue=A.updateQueue,N.type=A.type,r=A.dependencies,N.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),d=d.sibling;return ft(bt,bt.current&1|2),a.child}r=r.sibling}N.tail!==null&&Be()>xa&&(a.flags|=128,x=!0,Ai(N,!1),a.lanes=4194304)}else{if(!x)if(r=Ec(A),r!==null){if(a.flags|=128,x=!0,d=r.updateQueue,d!==null&&(a.updateQueue=d,a.flags|=4),Ai(N,!0),N.tail===null&&N.tailMode==="hidden"&&!A.alternate&&!gt)return ln(a),null}else 2*Be()-N.renderingStartTime>xa&&d!==1073741824&&(a.flags|=128,x=!0,Ai(N,!1),a.lanes=4194304);N.isBackwards?(A.sibling=a.child,a.child=A):(d=N.last,d!==null?d.sibling=A:a.child=A,N.last=A)}return N.tail!==null?(a=N.tail,N.rendering=a,N.tail=a.sibling,N.renderingStartTime=Be(),a.sibling=null,d=bt.current,ft(bt,x?d&1|2:d&1),a):(ln(a),null);case 22:case 23:return wm(),x=a.memoizedState!==null,r!==null&&r.memoizedState!==null!==x&&(a.flags|=8192),x&&(a.mode&1)!==0?(Yn&1073741824)!==0&&(ln(a),a.subtreeFlags&6&&(a.flags|=8192)):ln(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function JS(r,a){switch(Cf(a),a.tag){case 1:return Mn(a.type)&&gc(),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return ma(),pt(Pn),pt(on),Hf(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 5:return Uf(a),null;case 13:if(pt(bt),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(n(340));ca()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return pt(bt),null;case 4:return ma(),null;case 10:return Lf(a.type._context),null;case 22:case 23:return wm(),null;case 24:return null;default:return null}}var Lc=!1,cn=!1,e2=typeof WeakSet=="function"?WeakSet:Set,Se=null;function ha(r,a){var d=r.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(x){St(r,a,x)}else d.current=null}function cm(r,a,d){try{d()}catch(x){St(r,a,x)}}var Ay=!1;function t2(r,a){if(wf=nc,r=ux(),mf(r)){if("selectionStart"in r)var d={start:r.selectionStart,end:r.selectionEnd};else e:{d=(d=r.ownerDocument)&&d.defaultView||window;var x=d.getSelection&&d.getSelection();if(x&&x.rangeCount!==0){d=x.anchorNode;var k=x.anchorOffset,N=x.focusNode;x=x.focusOffset;try{d.nodeType,N.nodeType}catch{d=null;break e}var A=0,W=-1,V=-1,re=0,de=0,me=r,ue=null;t:for(;;){for(var ke;me!==d||k!==0&&me.nodeType!==3||(W=A+k),me!==N||x!==0&&me.nodeType!==3||(V=A+x),me.nodeType===3&&(A+=me.nodeValue.length),(ke=me.firstChild)!==null;)ue=me,me=ke;for(;;){if(me===r)break t;if(ue===d&&++re===k&&(W=A),ue===N&&++de===x&&(V=A),(ke=me.nextSibling)!==null)break;me=ue,ue=me.parentNode}me=ke}d=W===-1||V===-1?null:{start:W,end:V}}else d=null}d=d||{start:0,end:0}}else d=null;for(kf={focusedElem:r,selectionRange:d},nc=!1,Se=a;Se!==null;)if(a=Se,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,Se=r;else for(;Se!==null;){a=Se;try{var _e=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(_e!==null){var $e=_e.memoizedProps,$t=_e.memoizedState,te=a.stateNode,Q=te.getSnapshotBeforeUpdate(a.elementType===a.type?$e:Cs(a.type,$e),$t);te.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var se=a.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ge){St(a,a.return,ge)}if(r=a.sibling,r!==null){r.return=a.return,Se=r;break}Se=a.return}return _e=Ay,Ay=!1,_e}function Oi(r,a,d){var x=a.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var k=x=x.next;do{if((k.tag&r)===r){var N=k.destroy;k.destroy=void 0,N!==void 0&&cm(a,d,N)}k=k.next}while(k!==x)}}function Ic(r,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var d=a=a.next;do{if((d.tag&r)===r){var x=d.create;d.destroy=x()}d=d.next}while(d!==a)}}function um(r){var a=r.ref;if(a!==null){var d=r.stateNode;switch(r.tag){case 5:r=d;break;default:r=d}typeof a=="function"?a(r):a.current=r}}function Oy(r){var a=r.alternate;a!==null&&(r.alternate=null,Oy(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&(delete a[Bs],delete a[ki],delete a[_f],delete a[IS],delete a[zS])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Py(r){return r.tag===5||r.tag===3||r.tag===4}function My(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Py(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function dm(r,a,d){var x=r.tag;if(x===5||x===6)r=r.stateNode,a?d.nodeType===8?d.parentNode.insertBefore(r,a):d.insertBefore(r,a):(d.nodeType===8?(a=d.parentNode,a.insertBefore(r,d)):(a=d,a.appendChild(r)),d=d._reactRootContainer,d!=null||a.onclick!==null||(a.onclick=pc));else if(x!==4&&(r=r.child,r!==null))for(dm(r,a,d),r=r.sibling;r!==null;)dm(r,a,d),r=r.sibling}function fm(r,a,d){var x=r.tag;if(x===5||x===6)r=r.stateNode,a?d.insertBefore(r,a):d.appendChild(r);else if(x!==4&&(r=r.child,r!==null))for(fm(r,a,d),r=r.sibling;r!==null;)fm(r,a,d),r=r.sibling}var Zt=null,Rs=!1;function zr(r,a,d){for(d=d.child;d!==null;)Ly(r,a,d),d=d.sibling}function Ly(r,a,d){if(qn&&typeof qn.onCommitFiberUnmount=="function")try{qn.onCommitFiberUnmount(uo,d)}catch{}switch(d.tag){case 5:cn||ha(d,a);case 6:var x=Zt,k=Rs;Zt=null,zr(r,a,d),Zt=x,Rs=k,Zt!==null&&(Rs?(r=Zt,d=d.stateNode,r.nodeType===8?r.parentNode.removeChild(d):r.removeChild(d)):Zt.removeChild(d.stateNode));break;case 18:Zt!==null&&(Rs?(r=Zt,d=d.stateNode,r.nodeType===8?Sf(r.parentNode,d):r.nodeType===1&&Sf(r,d),di(r)):Sf(Zt,d.stateNode));break;case 4:x=Zt,k=Rs,Zt=d.stateNode.containerInfo,Rs=!0,zr(r,a,d),Zt=x,Rs=k;break;case 0:case 11:case 14:case 15:if(!cn&&(x=d.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){k=x=x.next;do{var N=k,A=N.destroy;N=N.tag,A!==void 0&&((N&2)!==0||(N&4)!==0)&&cm(d,a,A),k=k.next}while(k!==x)}zr(r,a,d);break;case 1:if(!cn&&(ha(d,a),x=d.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=d.memoizedProps,x.state=d.memoizedState,x.componentWillUnmount()}catch(W){St(d,a,W)}zr(r,a,d);break;case 21:zr(r,a,d);break;case 22:d.mode&1?(cn=(x=cn)||d.memoizedState!==null,zr(r,a,d),cn=x):zr(r,a,d);break;default:zr(r,a,d)}}function Iy(r){var a=r.updateQueue;if(a!==null){r.updateQueue=null;var d=r.stateNode;d===null&&(d=r.stateNode=new e2),a.forEach(function(x){var k=u2.bind(null,r,x);d.has(x)||(d.add(x),x.then(k,k))})}}function As(r,a){var d=a.deletions;if(d!==null)for(var x=0;x<d.length;x++){var k=d[x];try{var N=r,A=a,W=A;e:for(;W!==null;){switch(W.tag){case 5:Zt=W.stateNode,Rs=!1;break e;case 3:Zt=W.stateNode.containerInfo,Rs=!0;break e;case 4:Zt=W.stateNode.containerInfo,Rs=!0;break e}W=W.return}if(Zt===null)throw Error(n(160));Ly(N,A,k),Zt=null,Rs=!1;var V=k.alternate;V!==null&&(V.return=null),k.return=null}catch(re){St(k,a,re)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)zy(a,r),a=a.sibling}function zy(r,a){var d=r.alternate,x=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(As(a,r),Vs(r),x&4){try{Oi(3,r,r.return),Ic(3,r)}catch($e){St(r,r.return,$e)}try{Oi(5,r,r.return)}catch($e){St(r,r.return,$e)}}break;case 1:As(a,r),Vs(r),x&512&&d!==null&&ha(d,d.return);break;case 5:if(As(a,r),Vs(r),x&512&&d!==null&&ha(d,d.return),r.flags&32){var k=r.stateNode;try{ut(k,"")}catch($e){St(r,r.return,$e)}}if(x&4&&(k=r.stateNode,k!=null)){var N=r.memoizedProps,A=d!==null?d.memoizedProps:N,W=r.type,V=r.updateQueue;if(r.updateQueue=null,V!==null)try{W==="input"&&N.type==="radio"&&N.name!=null&&Kt(k,N),os(W,A);var re=os(W,N);for(A=0;A<V.length;A+=2){var de=V[A],me=V[A+1];de==="style"?Yt(k,me):de==="dangerouslySetInnerHTML"?At(k,me):de==="children"?ut(k,me):E(k,de,me,re)}switch(W){case"input":De(k,N);break;case"textarea":Xt(k,N);break;case"select":var ue=k._wrapperState.wasMultiple;k._wrapperState.wasMultiple=!!N.multiple;var ke=N.value;ke!=null?jt(k,!!N.multiple,ke,!1):ue!==!!N.multiple&&(N.defaultValue!=null?jt(k,!!N.multiple,N.defaultValue,!0):jt(k,!!N.multiple,N.multiple?[]:"",!1))}k[ki]=N}catch($e){St(r,r.return,$e)}}break;case 6:if(As(a,r),Vs(r),x&4){if(r.stateNode===null)throw Error(n(162));k=r.stateNode,N=r.memoizedProps;try{k.nodeValue=N}catch($e){St(r,r.return,$e)}}break;case 3:if(As(a,r),Vs(r),x&4&&d!==null&&d.memoizedState.isDehydrated)try{di(a.containerInfo)}catch($e){St(r,r.return,$e)}break;case 4:As(a,r),Vs(r);break;case 13:As(a,r),Vs(r),k=r.child,k.flags&8192&&(N=k.memoizedState!==null,k.stateNode.isHidden=N,!N||k.alternate!==null&&k.alternate.memoizedState!==null||(hm=Be())),x&4&&Iy(r);break;case 22:if(de=d!==null&&d.memoizedState!==null,r.mode&1?(cn=(re=cn)||de,As(a,r),cn=re):As(a,r),Vs(r),x&8192){if(re=r.memoizedState!==null,(r.stateNode.isHidden=re)&&!de&&(r.mode&1)!==0)for(Se=r,de=r.child;de!==null;){for(me=Se=de;Se!==null;){switch(ue=Se,ke=ue.child,ue.tag){case 0:case 11:case 14:case 15:Oi(4,ue,ue.return);break;case 1:ha(ue,ue.return);var _e=ue.stateNode;if(typeof _e.componentWillUnmount=="function"){x=ue,d=ue.return;try{a=x,_e.props=a.memoizedProps,_e.state=a.memoizedState,_e.componentWillUnmount()}catch($e){St(x,d,$e)}}break;case 5:ha(ue,ue.return);break;case 22:if(ue.memoizedState!==null){Uy(me);continue}}ke!==null?(ke.return=ue,Se=ke):Uy(me)}de=de.sibling}e:for(de=null,me=r;;){if(me.tag===5){if(de===null){de=me;try{k=me.stateNode,re?(N=k.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none"):(W=me.stateNode,V=me.memoizedProps.style,A=V!=null&&V.hasOwnProperty("display")?V.display:null,W.style.display=$n("display",A))}catch($e){St(r,r.return,$e)}}}else if(me.tag===6){if(de===null)try{me.stateNode.nodeValue=re?"":me.memoizedProps}catch($e){St(r,r.return,$e)}}else if((me.tag!==22&&me.tag!==23||me.memoizedState===null||me===r)&&me.child!==null){me.child.return=me,me=me.child;continue}if(me===r)break e;for(;me.sibling===null;){if(me.return===null||me.return===r)break e;de===me&&(de=null),me=me.return}de===me&&(de=null),me.sibling.return=me.return,me=me.sibling}}break;case 19:As(a,r),Vs(r),x&4&&Iy(r);break;case 21:break;default:As(a,r),Vs(r)}}function Vs(r){var a=r.flags;if(a&2){try{e:{for(var d=r.return;d!==null;){if(Py(d)){var x=d;break e}d=d.return}throw Error(n(160))}switch(x.tag){case 5:var k=x.stateNode;x.flags&32&&(ut(k,""),x.flags&=-33);var N=My(r);fm(r,N,k);break;case 3:case 4:var A=x.stateNode.containerInfo,W=My(r);dm(r,W,A);break;default:throw Error(n(161))}}catch(V){St(r,r.return,V)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function n2(r,a,d){Se=r,Dy(r)}function Dy(r,a,d){for(var x=(r.mode&1)!==0;Se!==null;){var k=Se,N=k.child;if(k.tag===22&&x){var A=k.memoizedState!==null||Lc;if(!A){var W=k.alternate,V=W!==null&&W.memoizedState!==null||cn;W=Lc;var re=cn;if(Lc=A,(cn=V)&&!re)for(Se=k;Se!==null;)A=Se,V=A.child,A.tag===22&&A.memoizedState!==null?Wy(k):V!==null?(V.return=A,Se=V):Wy(k);for(;N!==null;)Se=N,Dy(N),N=N.sibling;Se=k,Lc=W,cn=re}Fy(r)}else(k.subtreeFlags&8772)!==0&&N!==null?(N.return=k,Se=N):Fy(r)}}function Fy(r){for(;Se!==null;){var a=Se;if((a.flags&8772)!==0){var d=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:cn||Ic(5,a);break;case 1:var x=a.stateNode;if(a.flags&4&&!cn)if(d===null)x.componentDidMount();else{var k=a.elementType===a.type?d.memoizedProps:Cs(a.type,d.memoizedProps);x.componentDidUpdate(k,d.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var N=a.updateQueue;N!==null&&Ux(a,N,x);break;case 3:var A=a.updateQueue;if(A!==null){if(d=null,a.child!==null)switch(a.child.tag){case 5:d=a.child.stateNode;break;case 1:d=a.child.stateNode}Ux(a,A,d)}break;case 5:var W=a.stateNode;if(d===null&&a.flags&4){d=W;var V=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":V.autoFocus&&d.focus();break;case"img":V.src&&(d.src=V.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var re=a.alternate;if(re!==null){var de=re.memoizedState;if(de!==null){var me=de.dehydrated;me!==null&&di(me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}cn||a.flags&512&&um(a)}catch(ue){St(a,a.return,ue)}}if(a===r){Se=null;break}if(d=a.sibling,d!==null){d.return=a.return,Se=d;break}Se=a.return}}function Uy(r){for(;Se!==null;){var a=Se;if(a===r){Se=null;break}var d=a.sibling;if(d!==null){d.return=a.return,Se=d;break}Se=a.return}}function Wy(r){for(;Se!==null;){var a=Se;try{switch(a.tag){case 0:case 11:case 15:var d=a.return;try{Ic(4,a)}catch(V){St(a,d,V)}break;case 1:var x=a.stateNode;if(typeof x.componentDidMount=="function"){var k=a.return;try{x.componentDidMount()}catch(V){St(a,k,V)}}var N=a.return;try{um(a)}catch(V){St(a,N,V)}break;case 5:var A=a.return;try{um(a)}catch(V){St(a,A,V)}}}catch(V){St(a,a.return,V)}if(a===r){Se=null;break}var W=a.sibling;if(W!==null){W.return=a.return,Se=W;break}Se=a.return}}var s2=Math.ceil,zc=_.ReactCurrentDispatcher,mm=_.ReactCurrentOwner,ds=_.ReactCurrentBatchConfig,tt=0,Bt=null,Pt=null,Jt=0,Yn=0,ga=Or(0),Dt=0,Pi=null,bo=0,Dc=0,pm=0,Mi=null,In=null,hm=0,xa=1/0,mr=null,Fc=!1,gm=null,Dr=null,Uc=!1,Fr=null,Wc=0,Li=0,xm=null,Hc=-1,Bc=0;function xn(){return(tt&6)!==0?Be():Hc!==-1?Hc:Hc=Be()}function Ur(r){return(r.mode&1)===0?1:(tt&2)!==0&&Jt!==0?Jt&-Jt:FS.transition!==null?(Bc===0&&(Bc=Yo()),Bc):(r=nt,r!==0||(r=window.event,r=r===void 0?16:Bg(r.type)),r)}function Os(r,a,d,x){if(50<Li)throw Li=0,xm=null,Error(n(185));Sr(r,d,x),((tt&2)===0||r!==Bt)&&(r===Bt&&((tt&2)===0&&(Dc|=d),Dt===4&&Wr(r,Jt)),zn(r,x),d===1&&tt===0&&(a.mode&1)===0&&(xa=Be()+500,yc&&Mr()))}function zn(r,a){var d=r.callbackNode;rn(r,a);var x=qe(r,r===Bt?Jt:0);if(x===0)d!==null&&Ne(d),r.callbackNode=null,r.callbackPriority=0;else if(a=x&-x,r.callbackPriority!==a){if(d!=null&&Ne(d),a===1)r.tag===0?DS(By.bind(null,r)):Tx(By.bind(null,r)),MS(function(){(tt&6)===0&&Mr()}),d=null;else{switch(Lg(x)){case 1:d=Qt;break;case 4:d=Es;break;case 16:d=vt;break;case 536870912:d=Nr;break;default:d=vt}d=Zy(d,Hy.bind(null,r))}r.callbackPriority=a,r.callbackNode=d}}function Hy(r,a){if(Hc=-1,Bc=0,(tt&6)!==0)throw Error(n(327));var d=r.callbackNode;if(ya()&&r.callbackNode!==d)return null;var x=qe(r,r===Bt?Jt:0);if(x===0)return null;if((x&30)!==0||(x&r.expiredLanes)!==0||a)a=Gc(r,x);else{a=x;var k=tt;tt|=2;var N=qy();(Bt!==r||Jt!==a)&&(mr=null,xa=Be()+500,ko(r,a));do try{a2();break}catch(W){Gy(r,W)}while(!0);Mf(),zc.current=N,tt=k,Pt!==null?a=0:(Bt=null,Jt=0,a=Dt)}if(a!==0){if(a===2&&(k=oi(r),k!==0&&(x=k,a=ym(r,k))),a===1)throw d=Pi,ko(r,0),Wr(r,x),zn(r,Be()),d;if(a===6)Wr(r,x);else{if(k=r.current.alternate,(x&30)===0&&!r2(k)&&(a=Gc(r,x),a===2&&(N=oi(r),N!==0&&(x=N,a=ym(r,N))),a===1))throw d=Pi,ko(r,0),Wr(r,x),zn(r,Be()),d;switch(r.finishedWork=k,r.finishedLanes=x,a){case 0:case 1:throw Error(n(345));case 2:jo(r,In,mr);break;case 3:if(Wr(r,x),(x&130023424)===x&&(a=hm+500-Be(),10<a)){if(qe(r,0)!==0)break;if(k=r.suspendedLanes,(k&x)!==x){xn(),r.pingedLanes|=r.suspendedLanes&k;break}r.timeoutHandle=Nf(jo.bind(null,r,In,mr),a);break}jo(r,In,mr);break;case 4:if(Wr(r,x),(x&4194240)===x)break;for(a=r.eventTimes,k=-1;0<x;){var A=31-On(x);N=1<<A,A=a[A],A>k&&(k=A),x&=~N}if(x=k,x=Be()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*s2(x/1960))-x,10<x){r.timeoutHandle=Nf(jo.bind(null,r,In,mr),x);break}jo(r,In,mr);break;case 5:jo(r,In,mr);break;default:throw Error(n(329))}}}return zn(r,Be()),r.callbackNode===d?Hy.bind(null,r):null}function ym(r,a){var d=Mi;return r.current.memoizedState.isDehydrated&&(ko(r,a).flags|=256),r=Gc(r,a),r!==2&&(a=In,In=d,a!==null&&vm(a)),r}function vm(r){In===null?In=r:In.push.apply(In,r)}function r2(r){for(var a=r;;){if(a.flags&16384){var d=a.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var x=0;x<d.length;x++){var k=d[x],N=k.getSnapshot;k=k.value;try{if(!$s(N(),k))return!1}catch{return!1}}}if(d=a.child,a.subtreeFlags&16384&&d!==null)d.return=a,a=d;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Wr(r,a){for(a&=~pm,a&=~Dc,r.suspendedLanes|=a,r.pingedLanes&=~a,r=r.expirationTimes;0<a;){var d=31-On(a),x=1<<d;r[d]=-1,a&=~x}}function By(r){if((tt&6)!==0)throw Error(n(327));ya();var a=qe(r,0);if((a&1)===0)return zn(r,Be()),null;var d=Gc(r,a);if(r.tag!==0&&d===2){var x=oi(r);x!==0&&(a=x,d=ym(r,x))}if(d===1)throw d=Pi,ko(r,0),Wr(r,a),zn(r,Be()),d;if(d===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=a,jo(r,In,mr),zn(r,Be()),null}function bm(r,a){var d=tt;tt|=1;try{return r(a)}finally{tt=d,tt===0&&(xa=Be()+500,yc&&Mr())}}function wo(r){Fr!==null&&Fr.tag===0&&(tt&6)===0&&ya();var a=tt;tt|=1;var d=ds.transition,x=nt;try{if(ds.transition=null,nt=1,r)return r()}finally{nt=x,ds.transition=d,tt=a,(tt&6)===0&&Mr()}}function wm(){Yn=ga.current,pt(ga)}function ko(r,a){r.finishedWork=null,r.finishedLanes=0;var d=r.timeoutHandle;if(d!==-1&&(r.timeoutHandle=-1,PS(d)),Pt!==null)for(d=Pt.return;d!==null;){var x=d;switch(Cf(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&gc();break;case 3:ma(),pt(Pn),pt(on),Hf();break;case 5:Uf(x);break;case 4:ma();break;case 13:pt(bt);break;case 19:pt(bt);break;case 10:Lf(x.type._context);break;case 22:case 23:wm()}d=d.return}if(Bt=r,Pt=r=Hr(r.current,null),Jt=Yn=a,Dt=0,Pi=null,pm=Dc=bo=0,In=Mi=null,xo!==null){for(a=0;a<xo.length;a++)if(d=xo[a],x=d.interleaved,x!==null){d.interleaved=null;var k=x.next,N=d.pending;if(N!==null){var A=N.next;N.next=k,x.next=A}d.pending=x}xo=null}return r}function Gy(r,a){do{var d=Pt;try{if(Mf(),$c.current=Ac,Tc){for(var x=wt.memoizedState;x!==null;){var k=x.queue;k!==null&&(k.pending=null),x=x.next}Tc=!1}if(vo=0,Ht=zt=wt=null,$i=!1,Ti=0,mm.current=null,d===null||d.return===null){Dt=1,Pi=a,Pt=null;break}e:{var N=r,A=d.return,W=d,V=a;if(a=Jt,W.flags|=32768,V!==null&&typeof V=="object"&&typeof V.then=="function"){var re=V,de=W,me=de.tag;if((de.mode&1)===0&&(me===0||me===11||me===15)){var ue=de.alternate;ue?(de.updateQueue=ue.updateQueue,de.memoizedState=ue.memoizedState,de.lanes=ue.lanes):(de.updateQueue=null,de.memoizedState=null)}var ke=gy(A);if(ke!==null){ke.flags&=-257,xy(ke,A,W,N,a),ke.mode&1&&hy(N,re,a),a=ke,V=re;var _e=a.updateQueue;if(_e===null){var $e=new Set;$e.add(V),a.updateQueue=$e}else _e.add(V);break e}else{if((a&1)===0){hy(N,re,a),km();break e}V=Error(n(426))}}else if(gt&&W.mode&1){var $t=gy(A);if($t!==null){($t.flags&65536)===0&&($t.flags|=256),xy($t,A,W,N,a),Of(pa(V,W));break e}}N=V=pa(V,W),Dt!==4&&(Dt=2),Mi===null?Mi=[N]:Mi.push(N),N=A;do{switch(N.tag){case 3:N.flags|=65536,a&=-a,N.lanes|=a;var te=my(N,V,a);Fx(N,te);break e;case 1:W=V;var Q=N.type,se=N.stateNode;if((N.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(Dr===null||!Dr.has(se)))){N.flags|=65536,a&=-a,N.lanes|=a;var ge=py(N,W,a);Fx(N,ge);break e}}N=N.return}while(N!==null)}Ky(d)}catch(Ce){a=Ce,Pt===d&&d!==null&&(Pt=d=d.return);continue}break}while(!0)}function qy(){var r=zc.current;return zc.current=Ac,r===null?Ac:r}function km(){(Dt===0||Dt===3||Dt===2)&&(Dt=4),Bt===null||(bo&268435455)===0&&(Dc&268435455)===0||Wr(Bt,Jt)}function Gc(r,a){var d=tt;tt|=2;var x=qy();(Bt!==r||Jt!==a)&&(mr=null,ko(r,a));do try{o2();break}catch(k){Gy(r,k)}while(!0);if(Mf(),tt=d,zc.current=x,Pt!==null)throw Error(n(261));return Bt=null,Jt=0,Dt}function o2(){for(;Pt!==null;)Vy(Pt)}function a2(){for(;Pt!==null&&!it();)Vy(Pt)}function Vy(r){var a=Qy(r.alternate,r,Yn);r.memoizedProps=r.pendingProps,a===null?Ky(r):Pt=a,mm.current=null}function Ky(r){var a=r;do{var d=a.alternate;if(r=a.return,(a.flags&32768)===0){if(d=ZS(d,a,Yn),d!==null){Pt=d;return}}else{if(d=JS(d,a),d!==null){d.flags&=32767,Pt=d;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Dt=6,Pt=null;return}}if(a=a.sibling,a!==null){Pt=a;return}Pt=a=r}while(a!==null);Dt===0&&(Dt=5)}function jo(r,a,d){var x=nt,k=ds.transition;try{ds.transition=null,nt=1,i2(r,a,d,x)}finally{ds.transition=k,nt=x}return null}function i2(r,a,d,x){do ya();while(Fr!==null);if((tt&6)!==0)throw Error(n(327));d=r.finishedWork;var k=r.finishedLanes;if(d===null)return null;if(r.finishedWork=null,r.finishedLanes=0,d===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var N=d.lanes|d.childLanes;if(Zd(r,N),r===Bt&&(Pt=Bt=null,Jt=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Uc||(Uc=!0,Zy(vt,function(){return ya(),null})),N=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||N){N=ds.transition,ds.transition=null;var A=nt;nt=1;var W=tt;tt|=4,mm.current=null,t2(r,d),zy(d,r),ES(kf),nc=!!wf,kf=wf=null,r.current=d,n2(d),Et(),tt=W,nt=A,ds.transition=N}else r.current=d;if(Uc&&(Uc=!1,Fr=r,Wc=k),N=r.pendingLanes,N===0&&(Dr=null),Ql(d.stateNode),zn(r,Be()),a!==null)for(x=r.onRecoverableError,d=0;d<a.length;d++)k=a[d],x(k.value,{componentStack:k.stack,digest:k.digest});if(Fc)throw Fc=!1,r=gm,gm=null,r;return(Wc&1)!==0&&r.tag!==0&&ya(),N=r.pendingLanes,(N&1)!==0?r===xm?Li++:(Li=0,xm=r):Li=0,Mr(),null}function ya(){if(Fr!==null){var r=Lg(Wc),a=ds.transition,d=nt;try{if(ds.transition=null,nt=16>r?16:r,Fr===null)var x=!1;else{if(r=Fr,Fr=null,Wc=0,(tt&6)!==0)throw Error(n(331));var k=tt;for(tt|=4,Se=r.current;Se!==null;){var N=Se,A=N.child;if((Se.flags&16)!==0){var W=N.deletions;if(W!==null){for(var V=0;V<W.length;V++){var re=W[V];for(Se=re;Se!==null;){var de=Se;switch(de.tag){case 0:case 11:case 15:Oi(8,de,N)}var me=de.child;if(me!==null)me.return=de,Se=me;else for(;Se!==null;){de=Se;var ue=de.sibling,ke=de.return;if(Oy(de),de===re){Se=null;break}if(ue!==null){ue.return=ke,Se=ue;break}Se=ke}}}var _e=N.alternate;if(_e!==null){var $e=_e.child;if($e!==null){_e.child=null;do{var $t=$e.sibling;$e.sibling=null,$e=$t}while($e!==null)}}Se=N}}if((N.subtreeFlags&2064)!==0&&A!==null)A.return=N,Se=A;else e:for(;Se!==null;){if(N=Se,(N.flags&2048)!==0)switch(N.tag){case 0:case 11:case 15:Oi(9,N,N.return)}var te=N.sibling;if(te!==null){te.return=N.return,Se=te;break e}Se=N.return}}var Q=r.current;for(Se=Q;Se!==null;){A=Se;var se=A.child;if((A.subtreeFlags&2064)!==0&&se!==null)se.return=A,Se=se;else e:for(A=Q;Se!==null;){if(W=Se,(W.flags&2048)!==0)try{switch(W.tag){case 0:case 11:case 15:Ic(9,W)}}catch(Ce){St(W,W.return,Ce)}if(W===A){Se=null;break e}var ge=W.sibling;if(ge!==null){ge.return=W.return,Se=ge;break e}Se=W.return}}if(tt=k,Mr(),qn&&typeof qn.onPostCommitFiberRoot=="function")try{qn.onPostCommitFiberRoot(uo,r)}catch{}x=!0}return x}finally{nt=d,ds.transition=a}}return!1}function Xy(r,a,d){a=pa(d,a),a=my(r,a,1),r=Ir(r,a,1),a=xn(),r!==null&&(Sr(r,1,a),zn(r,a))}function St(r,a,d){if(r.tag===3)Xy(r,r,d);else for(;a!==null;){if(a.tag===3){Xy(a,r,d);break}else if(a.tag===1){var x=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Dr===null||!Dr.has(x))){r=pa(d,r),r=py(a,r,1),a=Ir(a,r,1),r=xn(),a!==null&&(Sr(a,1,r),zn(a,r));break}}a=a.return}}function l2(r,a,d){var x=r.pingCache;x!==null&&x.delete(a),a=xn(),r.pingedLanes|=r.suspendedLanes&d,Bt===r&&(Jt&d)===d&&(Dt===4||Dt===3&&(Jt&130023424)===Jt&&500>Be()-hm?ko(r,0):pm|=d),zn(r,a)}function Yy(r,a){a===0&&((r.mode&1)===0?a=1:(a=Ee,Ee<<=1,(Ee&130023424)===0&&(Ee=4194304)));var d=xn();r=ur(r,a),r!==null&&(Sr(r,a,d),zn(r,d))}function c2(r){var a=r.memoizedState,d=0;a!==null&&(d=a.retryLane),Yy(r,d)}function u2(r,a){var d=0;switch(r.tag){case 13:var x=r.stateNode,k=r.memoizedState;k!==null&&(d=k.retryLane);break;case 19:x=r.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(a),Yy(r,d)}var Qy;Qy=function(r,a,d){if(r!==null)if(r.memoizedProps!==a.pendingProps||Pn.current)Ln=!0;else{if((r.lanes&d)===0&&(a.flags&128)===0)return Ln=!1,QS(r,a,d);Ln=(r.flags&131072)!==0}else Ln=!1,gt&&(a.flags&1048576)!==0&&Cx(a,bc,a.index);switch(a.lanes=0,a.tag){case 2:var x=a.type;Mc(r,a),r=a.pendingProps;var k=aa(a,on.current);fa(a,d),k=qf(null,a,x,r,k,d);var N=Vf();return a.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Mn(x)?(N=!0,xc(a)):N=!1,a.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,Df(a),k.updater=Oc,a.stateNode=k,k._reactInternals=a,Jf(a,x,r,d),a=sm(null,a,x,!0,N,d)):(a.tag=0,gt&&N&&Tf(a),gn(null,a,k,d),a=a.child),a;case 16:x=a.elementType;e:{switch(Mc(r,a),r=a.pendingProps,k=x._init,x=k(x._payload),a.type=x,k=a.tag=f2(x),r=Cs(x,r),k){case 0:a=nm(null,a,x,r,d);break e;case 1:a=jy(null,a,x,r,d);break e;case 11:a=yy(null,a,x,r,d);break e;case 14:a=vy(null,a,x,Cs(x.type,r),d);break e}throw Error(n(306,x,""))}return a;case 0:return x=a.type,k=a.pendingProps,k=a.elementType===x?k:Cs(x,k),nm(r,a,x,k,d);case 1:return x=a.type,k=a.pendingProps,k=a.elementType===x?k:Cs(x,k),jy(r,a,x,k,d);case 3:e:{if(Ny(a),r===null)throw Error(n(387));x=a.pendingProps,N=a.memoizedState,k=N.element,Dx(r,a),_c(a,x,null,d);var A=a.memoizedState;if(x=A.element,N.isDehydrated)if(N={element:x,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},a.updateQueue.baseState=N,a.memoizedState=N,a.flags&256){k=pa(Error(n(423)),a),a=Sy(r,a,x,d,k);break e}else if(x!==k){k=pa(Error(n(424)),a),a=Sy(r,a,x,d,k);break e}else for(Xn=Ar(a.stateNode.containerInfo.firstChild),Kn=a,gt=!0,Ts=null,d=Ix(a,null,x,d),a.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ca(),x===k){a=fr(r,a,d);break e}gn(r,a,x,d)}a=a.child}return a;case 5:return Wx(a),r===null&&Af(a),x=a.type,k=a.pendingProps,N=r!==null?r.memoizedProps:null,A=k.children,jf(x,k)?A=null:N!==null&&jf(x,N)&&(a.flags|=32),ky(r,a),gn(r,a,A,d),a.child;case 6:return r===null&&Af(a),null;case 13:return _y(r,a,d);case 4:return Ff(a,a.stateNode.containerInfo),x=a.pendingProps,r===null?a.child=ua(a,null,x,d):gn(r,a,x,d),a.child;case 11:return x=a.type,k=a.pendingProps,k=a.elementType===x?k:Cs(x,k),yy(r,a,x,k,d);case 7:return gn(r,a,a.pendingProps,d),a.child;case 8:return gn(r,a,a.pendingProps.children,d),a.child;case 12:return gn(r,a,a.pendingProps.children,d),a.child;case 10:e:{if(x=a.type._context,k=a.pendingProps,N=a.memoizedProps,A=k.value,ft(jc,x._currentValue),x._currentValue=A,N!==null)if($s(N.value,A)){if(N.children===k.children&&!Pn.current){a=fr(r,a,d);break e}}else for(N=a.child,N!==null&&(N.return=a);N!==null;){var W=N.dependencies;if(W!==null){A=N.child;for(var V=W.firstContext;V!==null;){if(V.context===x){if(N.tag===1){V=dr(-1,d&-d),V.tag=2;var re=N.updateQueue;if(re!==null){re=re.shared;var de=re.pending;de===null?V.next=V:(V.next=de.next,de.next=V),re.pending=V}}N.lanes|=d,V=N.alternate,V!==null&&(V.lanes|=d),If(N.return,d,a),W.lanes|=d;break}V=V.next}}else if(N.tag===10)A=N.type===a.type?null:N.child;else if(N.tag===18){if(A=N.return,A===null)throw Error(n(341));A.lanes|=d,W=A.alternate,W!==null&&(W.lanes|=d),If(A,d,a),A=N.sibling}else A=N.child;if(A!==null)A.return=N;else for(A=N;A!==null;){if(A===a){A=null;break}if(N=A.sibling,N!==null){N.return=A.return,A=N;break}A=A.return}N=A}gn(r,a,k.children,d),a=a.child}return a;case 9:return k=a.type,x=a.pendingProps.children,fa(a,d),k=cs(k),x=x(k),a.flags|=1,gn(r,a,x,d),a.child;case 14:return x=a.type,k=Cs(x,a.pendingProps),k=Cs(x.type,k),vy(r,a,x,k,d);case 15:return by(r,a,a.type,a.pendingProps,d);case 17:return x=a.type,k=a.pendingProps,k=a.elementType===x?k:Cs(x,k),Mc(r,a),a.tag=1,Mn(x)?(r=!0,xc(a)):r=!1,fa(a,d),dy(a,x,k),Jf(a,x,k,d),sm(null,a,x,!0,r,d);case 19:return $y(r,a,d);case 22:return wy(r,a,d)}throw Error(n(156,a.tag))};function Zy(r,a){return pe(r,a)}function d2(r,a,d,x){this.tag=r,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fs(r,a,d,x){return new d2(r,a,d,x)}function jm(r){return r=r.prototype,!(!r||!r.isReactComponent)}function f2(r){if(typeof r=="function")return jm(r)?1:0;if(r!=null){if(r=r.$$typeof,r===H)return 11;if(r===X)return 14}return 2}function Hr(r,a){var d=r.alternate;return d===null?(d=fs(r.tag,a,r.key,r.mode),d.elementType=r.elementType,d.type=r.type,d.stateNode=r.stateNode,d.alternate=r,r.alternate=d):(d.pendingProps=a,d.type=r.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=r.flags&14680064,d.childLanes=r.childLanes,d.lanes=r.lanes,d.child=r.child,d.memoizedProps=r.memoizedProps,d.memoizedState=r.memoizedState,d.updateQueue=r.updateQueue,a=r.dependencies,d.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},d.sibling=r.sibling,d.index=r.index,d.ref=r.ref,d}function qc(r,a,d,x,k,N){var A=2;if(x=r,typeof r=="function")jm(r)&&(A=1);else if(typeof r=="string")A=5;else e:switch(r){case C:return No(d.children,k,N,a);case O:A=8,k|=8;break;case I:return r=fs(12,d,a,k|2),r.elementType=I,r.lanes=N,r;case F:return r=fs(13,d,a,k),r.elementType=F,r.lanes=N,r;case U:return r=fs(19,d,a,k),r.elementType=U,r.lanes=N,r;case K:return Vc(d,k,N,a);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case D:A=10;break e;case z:A=9;break e;case H:A=11;break e;case X:A=14;break e;case P:A=16,x=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return a=fs(A,d,a,k),a.elementType=r,a.type=x,a.lanes=N,a}function No(r,a,d,x){return r=fs(7,r,x,a),r.lanes=d,r}function Vc(r,a,d,x){return r=fs(22,r,x,a),r.elementType=K,r.lanes=d,r.stateNode={isHidden:!1},r}function Nm(r,a,d){return r=fs(6,r,null,a),r.lanes=d,r}function Sm(r,a,d){return a=fs(4,r.children!==null?r.children:[],r.key,a),a.lanes=d,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}function m2(r,a,d,x,k){this.tag=a,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ai(0),this.expirationTimes=ai(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ai(0),this.identifierPrefix=x,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function _m(r,a,d,x,k,N,A,W,V){return r=new m2(r,a,d,W,V),a===1?(a=1,N===!0&&(a|=8)):a=0,N=fs(3,null,null,a),r.current=N,N.stateNode=r,N.memoizedState={element:x,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Df(N),r}function p2(r,a,d){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:x==null?null:""+x,children:r,containerInfo:a,implementation:d}}function Jy(r){if(!r)return Pr;r=r._reactInternals;e:{if(Gn(r)!==r||r.tag!==1)throw Error(n(170));var a=r;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Mn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(r.tag===1){var d=r.type;if(Mn(d))return Ex(r,d,a)}return a}function ev(r,a,d,x,k,N,A,W,V){return r=_m(d,x,!0,r,k,N,A,W,V),r.context=Jy(null),d=r.current,x=xn(),k=Ur(d),N=dr(x,k),N.callback=a??null,Ir(d,N,k),r.current.lanes=k,Sr(r,k,x),zn(r,x),r}function Kc(r,a,d,x){var k=a.current,N=xn(),A=Ur(k);return d=Jy(d),a.context===null?a.context=d:a.pendingContext=d,a=dr(N,A),a.payload={element:r},x=x===void 0?null:x,x!==null&&(a.callback=x),r=Ir(k,a,A),r!==null&&(Os(r,k,A,N),Sc(r,k,A)),A}function Xc(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function tv(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var d=r.retryLane;r.retryLane=d!==0&&d<a?d:a}}function Em(r,a){tv(r,a),(r=r.alternate)&&tv(r,a)}function h2(){return null}var nv=typeof reportError=="function"?reportError:function(r){console.error(r)};function $m(r){this._internalRoot=r}Yc.prototype.render=$m.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(n(409));Kc(r,a,null,null)},Yc.prototype.unmount=$m.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;wo(function(){Kc(null,r,null,null)}),a[ar]=null}};function Yc(r){this._internalRoot=r}Yc.prototype.unstable_scheduleHydration=function(r){if(r){var a=Dg();r={blockedOn:null,target:r,priority:a};for(var d=0;d<Tr.length&&a!==0&&a<Tr[d].priority;d++);Tr.splice(d,0,r),d===0&&Wg(r)}};function Tm(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Qc(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function sv(){}function g2(r,a,d,x,k){if(k){if(typeof x=="function"){var N=x;x=function(){var re=Xc(A);N.call(re)}}var A=ev(a,x,r,0,null,!1,!1,"",sv);return r._reactRootContainer=A,r[ar]=A.current,bi(r.nodeType===8?r.parentNode:r),wo(),A}for(;k=r.lastChild;)r.removeChild(k);if(typeof x=="function"){var W=x;x=function(){var re=Xc(V);W.call(re)}}var V=_m(r,0,!1,null,null,!1,!1,"",sv);return r._reactRootContainer=V,r[ar]=V.current,bi(r.nodeType===8?r.parentNode:r),wo(function(){Kc(a,V,d,x)}),V}function Zc(r,a,d,x,k){var N=d._reactRootContainer;if(N){var A=N;if(typeof k=="function"){var W=k;k=function(){var V=Xc(A);W.call(V)}}Kc(a,A,r,k)}else A=g2(d,a,r,k,x);return Xc(A)}Ig=function(r){switch(r.tag){case 3:var a=r.stateNode;if(a.current.memoizedState.isDehydrated){var d=Qe(a.pendingLanes);d!==0&&(fo(a,d|1),zn(a,Be()),(tt&6)===0&&(xa=Be()+500,Mr()))}break;case 13:wo(function(){var x=ur(r,1);if(x!==null){var k=xn();Os(x,r,1,k)}}),Em(r,1)}},Jd=function(r){if(r.tag===13){var a=ur(r,134217728);if(a!==null){var d=xn();Os(a,r,134217728,d)}Em(r,134217728)}},zg=function(r){if(r.tag===13){var a=Ur(r),d=ur(r,a);if(d!==null){var x=xn();Os(d,r,a,x)}Em(r,a)}},Dg=function(){return nt},Fg=function(r,a){var d=nt;try{return nt=r,a()}finally{nt=d}},Bn=function(r,a,d){switch(a){case"input":if(De(r,d),a=d.name,d.type==="radio"&&a!=null){for(d=r;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<d.length;a++){var x=d[a];if(x!==r&&x.form===r.form){var k=hc(x);if(!k)throw Error(n(90));We(x),De(x,k)}}}break;case"textarea":Xt(r,d);break;case"select":a=d.value,a!=null&&jt(r,!!d.multiple,a,!1)}},Nt=bm,nn=wo;var x2={usingClientEntryPoint:!1,Events:[ji,ra,hc,dt,Ke,bm]},Ii={findFiberByHostInstance:mo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},y2={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Ae(r),r===null?null:r.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||h2,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 Jc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jc.isDisabled&&Jc.supportsFiber)try{uo=Jc.inject(y2),qn=Jc}catch{}}return Dn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=x2,Dn.createPortal=function(r,a){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Tm(a))throw Error(n(200));return p2(r,a,null,d)},Dn.createRoot=function(r,a){if(!Tm(r))throw Error(n(299));var d=!1,x="",k=nv;return a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(x=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),a=_m(r,1,!1,null,null,d,!1,x,k),r[ar]=a.current,bi(r.nodeType===8?r.parentNode:r),new $m(a)},Dn.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Ae(a),r=r===null?null:r.stateNode,r},Dn.flushSync=function(r){return wo(r)},Dn.hydrate=function(r,a,d){if(!Qc(a))throw Error(n(200));return Zc(null,r,a,!0,d)},Dn.hydrateRoot=function(r,a,d){if(!Tm(r))throw Error(n(405));var x=d!=null&&d.hydratedSources||null,k=!1,N="",A=nv;if(d!=null&&(d.unstable_strictMode===!0&&(k=!0),d.identifierPrefix!==void 0&&(N=d.identifierPrefix),d.onRecoverableError!==void 0&&(A=d.onRecoverableError)),a=ev(a,null,r,1,d??null,k,!1,N,A),r[ar]=a.current,bi(r),x)for(r=0;r<x.length;r++)d=x[r],k=d._getVersion,k=k(d._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[d,k]:a.mutableSourceEagerHydrationData.push(d,k);return new Yc(a)},Dn.render=function(r,a,d){if(!Qc(a))throw Error(n(200));return Zc(null,r,a,!1,d)},Dn.unmountComponentAtNode=function(r){if(!Qc(r))throw Error(n(40));return r._reactRootContainer?(wo(function(){Zc(null,null,r,!1,function(){r._reactRootContainer=null,r[ar]=null})}),!0):!1},Dn.unstable_batchedUpdates=bm,Dn.unstable_renderSubtreeIntoContainer=function(r,a,d,x){if(!Qc(d))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return Zc(r,a,d,!1,x)},Dn.version="18.3.1-next-f1338f8080-20240426",Dn}var dv;function Gw(){if(dv)return Am.exports;dv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Am.exports=$2(),Am.exports}var fv;function T2(){if(fv)return eu;fv=1;var e=Gw();return eu.createRoot=e.createRoot,eu.hydrateRoot=e.hydrateRoot,eu}var C2=T2();const xt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R2=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),yp=128,A2=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},vp=(e,t=0)=>t>yp?'"…"':Array.isArray(e)?`[${e.map(n=>vp(n,t+1)).join(",")}]`:xt(e)?`{${Object.keys(e).filter(n=>e[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${vp(e[n],t+1)}`).join(",")}}`:A2(e),O2=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(16).padStart(8,"0")},Di=(e,t)=>Object.fromEntries(Object.entries(e).filter(([n])=>n!==t)),P2=e=>{switch(e.node){case"chain":return Di(e,"steps");case"parallel":return Di(e,"branches");case"map":case"loop":return Di(e,"body");case"route":return xt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([t,n])=>[t,xt(n)?Di(n,"body"):n]))}:e;case"workflow":return xt(e.workflow)?{...e,workflow:Di(e.workflow,"root")}:e;default:return e}};function cl(e){const t=[],n=[],o=(i,l,c,u)=>{if(!xt(i)||typeof i.node!="string"||c>yp)return;t.push({path:l,kind:i.node,label:typeof i.label=="string"?i.label:i.node,...i.node==="call"&&typeof i.via=="string"?{via:i.via}:{},changeCheck:O2(vp(P2(i))),...L2(i,u)});const f=(p,h,b,g=l,m=u)=>{!xt(p)||typeof p.node!="string"||c+1>yp||(n.push({from:g,to:h,kind:b}),o(p,h,c+1,m))};switch(i.node){case"chain":Array.isArray(i.steps)&&i.steps.forEach((p,h)=>f(p,`${l}/steps/${h}`,"next",h===0?l:`${l}/steps/${h-1}`));break;case"parallel":Array.isArray(i.branches)&&i.branches.forEach((p,h)=>f(p,`${l}/branches/${h}`,"branch"));break;case"map":f(i.body,`${l}/body`,"item");break;case"loop":f(i.body,`${l}/body`,"next");break;case"route":if(xt(i.branches))for(const[p,h]of Object.entries(i.branches))xt(h)&&f(h.body,`${l}/branches/${R2(p)}/body`,"route");break;case"workflow":xt(i.workflow)&&f(i.workflow.root,`${l}/workflow/root`,"child",l,xt(i.workflow.schemas)?i.workflow.schemas:{});break}};return o(xt(e)?e.root:void 0,"/root",0,xt(e)&&xt(e.schemas)?e.schemas:{}),{nodes:t,edges:n}}const M2=(e,t)=>{const n=typeof e=="string"&&Object.hasOwn(t,e)?t[e]:void 0,o=l=>{var c;for(let u=0;xt(l)&&typeof l.$ref=="string"&&u<8;u+=1){const f=(c=/^#\/definitions\/(.+)$/.exec(l.$ref))==null?void 0:c[1],p=xt(n)&&xt(n.definitions)?n.definitions:{};l=f===void 0?void 0:Object.hasOwn(p,f)?p[f]:Object.hasOwn(t,f)?t[f]:void 0}return l},i=o(n);return!xt(i)||!xt(i.properties)?[]:Object.entries(i.properties).map(([l,c])=>{const u=o(c),f=xt(u)&&typeof u.description=="string"?u.description:"",p=xt(u)?(Array.isArray(u.type)?u.type:[u.type]).filter(h=>h!=="null"):[];return xt(u)&&Array.isArray(u.enum)?{id:l,type:"choice",instructions:f,options:u.enum.map(String)}:p.length===1&&p[0]==="boolean"?{id:l,type:"noul",instructions:f}:p.length===1&&p[0]==="integer"?{id:l,type:"score",instructions:f}:{id:l,type:"unknown",instructions:f}})},L2=(e,t)=>{let n=e,o;const i=l=>typeof l=="string"?l:"";switch(e.node){case"judge":case"sift":o=M2(e.out,t);break;case"pick":o=[{id:"pick",type:"choice",instructions:i(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};o=[{id:"branch",type:"choice",instructions:i(e.instructions),options:xt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const l=e.node==="loop"?e.until:e.when;if(!xt(l)||l.predicate!=="ask")return{};n=l,o=[{id:"holds",type:"noul",instructions:i(l.instructions)}];break}default:return{}}return{...typeof n.provider=="string"?{provider:n.provider}:{},...typeof n.model=="string"?{model:n.model}:{},questions:o,...xt(n.images)&&Object.keys(n.images).length?{images:Object.keys(n.images)}:{}}};function I2(e,t){const n=E=>JSON.stringify([E.kind,E.label]),o=E=>{const _=new Map;for(const $ of E.nodes)_.set(n($),(_.get(n($))??0)+1);return _},[i,l]=[o(e),o(t)],c=E=>i.get(n(E))===1&&l.get(n(E))===1,u=new Map,f=new Map,p=(E,_)=>{u.set(_,E),f.set(E,_)},h=new Map(e.nodes.filter(c).map(E=>[n(E),E.path]));for(const E of t.nodes){const _=c(E)?h.get(n(E)):void 0;_!==void 0&&p(_,E.path)}const b=new Map(e.nodes.map(E=>[E.path,E])),g=[];for(const E of t.nodes){const _=b.get(E.path);u.has(E.path)||_===void 0||f.has(_.path)||(p(_.path,E.path),(_.kind!==E.kind||_.label!==E.label)&&g.push({prev:_.path,next:E.path,was:{kind:_.kind,label:_.label},now:{kind:E.kind,label:E.label}}))}const m=[];for(const E of t.nodes){const _=u.get(E.path),$=_===void 0?void 0:b.get(_);$===void 0||$.kind!==E.kind||$.label!==E.label||$.changeCheck!==void 0&&E.changeCheck!==void 0&&$.changeCheck!==E.changeCheck&&m.push({prev:$.path,next:E.path,kind:E.kind,label:E.label})}const v=({path:E,kind:_,label:$})=>({path:E,kind:_,label:$}),w=(E,_,$)=>JSON.stringify([E,_,$]),j=new Set(e.edges.map(E=>w(E.from,E.to,E.kind))),S=new Set(t.edges.map(E=>w(E.from,E.to,E.kind))),T=(E,_,$)=>{const[R,C]=[_.get(E.from),_.get(E.to)];return R!==void 0&&C!==void 0&&$.has(w(R,C,E.kind))};return{added:t.nodes.filter(E=>!u.has(E.path)).map(v),removed:e.nodes.filter(E=>!f.has(E.path)).map(v),changed:g,moved:t.nodes.flatMap(E=>{const _=u.get(E.path);return _!==void 0&&_!==E.path?[{prev:_,next:E.path}]:[]}),rewritten:m,edges:{added:t.edges.filter(E=>!T(E,u,j)).map(({from:E,to:_,kind:$})=>({from:E,to:_,kind:$})),removed:e.edges.filter(E=>!T(E,f,S)).map(({from:E,to:_,kind:$})=>({from:E,to:_,kind:$}))}}}/**
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 z2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qw=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).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 D2={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 F2=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:i="",children:l,iconNode:c,...u},f)=>y.createElement("svg",{ref:f,...D2,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:qw("lucide",i),...u},[...c.map(([p,h])=>y.createElement(p,h)),...Array.isArray(l)?l:[l]]));/**
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 ve=(e,t)=>{const n=y.forwardRef(({className:o,...i},l)=>y.createElement(F2,{ref:l,iconNode:t,className:qw(`lucide-${z2(e)}`,o),...i}));return n.displayName=`${e}`,n};/**
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 Vw=ve("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"}]]);/**
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 $l=ve("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"}]]);/**
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 zs=ve("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
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 fh=ve("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
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 U2=ve("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
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 Kw=ve("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
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 Cu=ve("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
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 mh=ve("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"}]]);/**
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 W2=ve("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"}]]);/**
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=ve("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"}]]);/**
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 dd=ve("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
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 Wo=ve("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
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 Fs=ve("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
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 Da=ve("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"}]]);/**
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 H2=ve("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"}]]);/**
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 Xw=ve("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
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 ph=ve("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"}]]);/**
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 Yw=ve("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"}]]);/**
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 B2=ve("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
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 fd=ve("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"}]]);/**
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 G2=ve("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
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 q2=ve("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"}]]);/**
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 V2=ve("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"}]]);/**
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 Qw=ve("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"}]]);/**
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 Ka=ve("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"}]]);/**
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 Zw=ve("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"}]]);/**
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 K2=ve("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"}]]);/**
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 hh=ve("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"}]]);/**
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 mv=ve("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"}]]);/**
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 Jw=ve("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"}]]);/**
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 X2=ve("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"}]]);/**
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 gh=ve("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"}]]);/**
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 xh=ve("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"}]]);/**
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 bp=ve("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
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 Tl=ve("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"}]]);/**
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 Y2=ve("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
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 Q2=ve("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
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 e0=ve("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"}]]);/**
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 Z2=ve("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"}]]);/**
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 J2=ve("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
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 pv=ve("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"}]]);/**
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 e_=ve("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"}]]);/**
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 t_=ve("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"}]]);/**
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 n_=ve("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"}]]);/**
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 yh=ve("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"}]]);/**
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 s_=ve("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"}]]);/**
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 r_=ve("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"}]]);/**
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 Cl=ve("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"}]]);/**
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 o_=ve("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
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 a_=ve("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"}]]);/**
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 ul=ve("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"}]]);/**
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 Rl=ve("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"}]]);/**
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 Al=ve("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
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 i_=ve("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"}]]);/**
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 dl=ve("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
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 l_=ve("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"}]]);/**
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 t0=ve("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"}]]);/**
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 c_=ve("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"}]]);/**
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 u_=ve("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
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 n0=ve("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"}]]);/**
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 s0=ve("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"}]]);/**
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 d_=ve("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
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 vh=ve("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"}]]);/**
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 f_=ve("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
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 m_=ve("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
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 p_=ve("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"}]]);/**
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 r0=ve("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
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 h_=ve("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"}]]);/**
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 Js=ve("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"}]]);/**
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 bh=ve("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"}]]);/**
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 fl=ve("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"}]]);/**
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 o0=ve("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"}]]);/**
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 Ho=ve("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"}]]);/**
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 Ru=ve("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"}]]);/**
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 Ol=ve("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
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 g_=ve("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function a0(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=a0(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function i0(){for(var e,t,n=0,o="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=a0(e))&&(o&&(o+=" "),o+=t);return o}const wh="-",x_=e=>{const t=v_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:c=>{const u=c.split(wh);return u[0]===""&&u.length!==1&&u.shift(),l0(u,t)||y_(c)},getConflictingClassGroupIds:(c,u)=>{const f=n[c]||[];return u&&o[c]?[...f,...o[c]]:f}}},l0=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),i=o?l0(e.slice(1),o):void 0;if(i)return i;if(t.validators.length===0)return;const l=e.join(wh);return(c=t.validators.find(({validator:u})=>u(l)))==null?void 0:c.classGroupId},hv=/^\[(.+)\]$/,y_=e=>{if(hv.test(e)){const t=hv.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},v_=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return w_(Object.entries(e.classGroups),n).forEach(([l,c])=>{wp(c,o,l,t)}),o},wp=(e,t,n,o)=>{e.forEach(i=>{if(typeof i=="string"){const l=i===""?t:gv(t,i);l.classGroupId=n;return}if(typeof i=="function"){if(b_(i)){wp(i(o),t,n,o);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([l,c])=>{wp(c,gv(t,l),n,o)})})},gv=(e,t)=>{let n=e;return t.split(wh).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},b_=e=>e.isThemeGetter,w_=(e,t)=>t?e.map(([n,o])=>{const i=o.map(l=>typeof l=="string"?t+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([c,u])=>[t+c,u])):l);return[n,i]}):e,k_=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const i=(l,c)=>{n.set(l,c),t++,t>e&&(t=0,o=n,n=new Map)};return{get(l){let c=n.get(l);if(c!==void 0)return c;if((c=o.get(l))!==void 0)return i(l,c),c},set(l,c){n.has(l)?n.set(l,c):i(l,c)}}},c0="!",j_=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,i=t[0],l=t.length,c=u=>{const f=[];let p=0,h=0,b;for(let j=0;j<u.length;j++){let S=u[j];if(p===0){if(S===i&&(o||u.slice(j,j+l)===t)){f.push(u.slice(h,j)),h=j+l;continue}if(S==="/"){b=j;continue}}S==="["?p++:S==="]"&&p--}const g=f.length===0?u:u.substring(h),m=g.startsWith(c0),v=m?g.substring(1):g,w=b&&b>h?b-h:void 0;return{modifiers:f,hasImportantModifier:m,baseClassName:v,maybePostfixModifierPosition:w}};return n?u=>n({className:u,parseClassName:c}):c},N_=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},S_=e=>({cache:k_(e.cacheSize),parseClassName:j_(e),...x_(e)}),__=/\s+/,E_=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=t,l=[],c=e.trim().split(__);let u="";for(let f=c.length-1;f>=0;f-=1){const p=c[f],{modifiers:h,hasImportantModifier:b,baseClassName:g,maybePostfixModifierPosition:m}=n(p);let v=!!m,w=o(v?g.substring(0,m):g);if(!w){if(!v){u=p+(u.length>0?" "+u:u);continue}if(w=o(g),!w){u=p+(u.length>0?" "+u:u);continue}v=!1}const j=N_(h).join(":"),S=b?j+c0:j,T=S+w;if(l.includes(T))continue;l.push(T);const E=i(w,v);for(let _=0;_<E.length;++_){const $=E[_];l.push(S+$)}u=p+(u.length>0?" "+u:u)}return u};function $_(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=u0(t))&&(o&&(o+=" "),o+=n);return o}const u0=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=u0(e[o]))&&(n&&(n+=" "),n+=t);return n};function xv(e,...t){let n,o,i,l=c;function c(f){const p=t.reduce((h,b)=>b(h),e());return n=S_(p),o=n.cache.get,i=n.cache.set,l=u,u(f)}function u(f){const p=o(f);if(p)return p;const h=E_(f,n);return i(f,h),h}return function(){return l($_.apply(null,arguments))}}const ht=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},d0=/^\[(?:([a-z-]+):)?(.+)\]$/i,T_=/^\d+\/\d+$/,C_=new Set(["px","full","screen"]),R_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,A_=/\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$/,O_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,P_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,M_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pr=e=>Ta(e)||C_.has(e)||T_.test(e),Gr=e=>Xa(e,"length",H_),Ta=e=>!!e&&!Number.isNaN(Number(e)),Mm=e=>Xa(e,"number",Ta),Fi=e=>!!e&&Number.isInteger(Number(e)),L_=e=>e.endsWith("%")&&Ta(e.slice(0,-1)),Ve=e=>d0.test(e),qr=e=>R_.test(e),I_=new Set(["length","size","percentage"]),z_=e=>Xa(e,I_,f0),D_=e=>Xa(e,"position",f0),F_=new Set(["image","url"]),U_=e=>Xa(e,F_,G_),W_=e=>Xa(e,"",B_),Ui=()=>!0,Xa=(e,t,n)=>{const o=d0.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},H_=e=>A_.test(e)&&!O_.test(e),f0=()=>!1,B_=e=>P_.test(e),G_=e=>M_.test(e),yv=()=>{const e=ht("colors"),t=ht("spacing"),n=ht("blur"),o=ht("brightness"),i=ht("borderColor"),l=ht("borderRadius"),c=ht("borderSpacing"),u=ht("borderWidth"),f=ht("contrast"),p=ht("grayscale"),h=ht("hueRotate"),b=ht("invert"),g=ht("gap"),m=ht("gradientColorStops"),v=ht("gradientColorStopPositions"),w=ht("inset"),j=ht("margin"),S=ht("opacity"),T=ht("padding"),E=ht("saturate"),_=ht("scale"),$=ht("sepia"),R=ht("skew"),C=ht("space"),O=ht("translate"),I=()=>["auto","contain","none"],D=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto",Ve,t],H=()=>[Ve,t],F=()=>["",pr,Gr],U=()=>["auto",Ta,Ve],X=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],P=()=>["solid","dashed","dotted","double","none"],K=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",Ve],B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>[Ta,Ve];return{cacheSize:500,separator:":",theme:{colors:[Ui],spacing:[pr,Gr],blur:["none","",qr,Ve],brightness:L(),borderColor:[e],borderRadius:["none","","full",qr,Ve],borderSpacing:H(),borderWidth:F(),contrast:L(),grayscale:G(),hueRotate:L(),invert:G(),gap:H(),gradientColorStops:[e],gradientColorStopPositions:[L_,Gr],inset:z(),margin:z(),opacity:L(),padding:H(),saturate:L(),scale:L(),sepia:G(),skew:L(),space:H(),translate:H()},classGroups:{aspect:[{aspect:["auto","square","video",Ve]}],container:["container"],columns:[{columns:[qr]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"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:[...X(),Ve]}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Fi,Ve]}],basis:[{basis:z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ve]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",Fi,Ve]}],"grid-cols":[{"grid-cols":[Ui]}],"col-start-end":[{col:["auto",{span:["full",Fi,Ve]},Ve]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[Ui]}],"row-start-end":[{row:["auto",{span:[Fi,Ve]},Ve]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ve]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ve]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...M()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...M(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...M(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[T]}],px:[{px:[T]}],py:[{py:[T]}],ps:[{ps:[T]}],pe:[{pe:[T]}],pt:[{pt:[T]}],pr:[{pr:[T]}],pb:[{pb:[T]}],pl:[{pl:[T]}],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":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ve,t]}],"min-w":[{"min-w":[Ve,t,"min","max","fit"]}],"max-w":[{"max-w":[Ve,t,"none","full","min","max","fit","prose",{screen:[qr]},qr]}],h:[{h:[Ve,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ve,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ve,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ve,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qr,Gr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Mm]}],"font-family":[{font:[Ui]}],"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",Ve]}],"line-clamp":[{"line-clamp":["none",Ta,Mm]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",pr,Ve]}],"list-image":[{"list-image":["none",Ve]}],"list-style-type":[{list:["none","disc","decimal",Ve]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[S]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[S]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...P(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",pr,Gr]}],"underline-offset":[{"underline-offset":["auto",pr,Ve]}],"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:H()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ve]}],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",Ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[S]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...X(),D_]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",z_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},U_]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"border-w":[{border:[u]}],"border-w-x":[{"border-x":[u]}],"border-w-y":[{"border-y":[u]}],"border-w-s":[{"border-s":[u]}],"border-w-e":[{"border-e":[u]}],"border-w-t":[{"border-t":[u]}],"border-w-r":[{"border-r":[u]}],"border-w-b":[{"border-b":[u]}],"border-w-l":[{"border-l":[u]}],"border-opacity":[{"border-opacity":[S]}],"border-style":[{border:[...P(),"hidden"]}],"divide-x":[{"divide-x":[u]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[u]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[S]}],"divide-style":[{divide:P()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...P()]}],"outline-offset":[{"outline-offset":[pr,Ve]}],"outline-w":[{outline:[pr,Gr]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[S]}],"ring-offset-w":[{"ring-offset":[pr,Gr]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",qr,W_]}],"shadow-color":[{shadow:[Ui]}],opacity:[{opacity:[S]}],"mix-blend":[{"mix-blend":[...K(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":K()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",qr,Ve]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[b]}],saturate:[{saturate:[E]}],sepia:[{sepia:[$]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[b]}],"backdrop-opacity":[{"backdrop-opacity":[S]}],"backdrop-saturate":[{"backdrop-saturate":[E]}],"backdrop-sepia":[{"backdrop-sepia":[$]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ve]}],duration:[{duration:L()}],ease:[{ease:["linear","in","out","in-out",Ve]}],delay:[{delay:L()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ve]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Fi,Ve]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ve]}],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",Ve]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":H()}],"scroll-mx":[{"scroll-mx":H()}],"scroll-my":[{"scroll-my":H()}],"scroll-ms":[{"scroll-ms":H()}],"scroll-me":[{"scroll-me":H()}],"scroll-mt":[{"scroll-mt":H()}],"scroll-mr":[{"scroll-mr":H()}],"scroll-mb":[{"scroll-mb":H()}],"scroll-ml":[{"scroll-ml":H()}],"scroll-p":[{"scroll-p":H()}],"scroll-px":[{"scroll-px":H()}],"scroll-py":[{"scroll-py":H()}],"scroll-ps":[{"scroll-ps":H()}],"scroll-pe":[{"scroll-pe":H()}],"scroll-pt":[{"scroll-pt":H()}],"scroll-pr":[{"scroll-pr":H()}],"scroll-pb":[{"scroll-pb":H()}],"scroll-pl":[{"scroll-pl":H()}],"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",Ve]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[pr,Gr,Mm]}],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"]}}},q_=(e,{cacheSize:t,prefix:n,separator:o,experimentalParseClassName:i,extend:l={},override:c={}})=>{Qi(e,"cacheSize",t),Qi(e,"prefix",n),Qi(e,"separator",o),Qi(e,"experimentalParseClassName",i);for(const u in c)V_(e[u],c[u]);for(const u in l)K_(e[u],l[u]);return e},Qi=(e,t,n)=>{n!==void 0&&(e[t]=n)},V_=(e,t)=>{if(t)for(const n in t)Qi(e,n,t[n])},K_=(e,t)=>{if(t)for(const n in t){const o=t[n];o!==void 0&&(e[n]=(e[n]||[]).concat(o))}},X_=(e,...t)=>typeof e=="function"?xv(yv,e,...t):xv(()=>q_(yv(),e),...t),Y_=X_({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"]},classGroups:{"max-w":[{"max-w":["page","page-wide"]}],"font-size":[{text:["micro","label","small","body","lead","prose","figure","display"]}],z:[{z:["raised","sticky","overlay","dialog","popover","toast"]}],shadow:[{shadow:["float"]}],duration:[{duration:["fast","base","slow"]}],ease:[{ease:["standard"]}],"outline-w":[{outline:["focus"]}],"outline-offset":[{"outline-offset":["focus"]}]}}}),ie=(...e)=>Y_(i0(e));function Q_({value:e,onChange:t,options:n,label:o,name:i,size:l="md",className:c}){return s.jsx("div",{role:"radiogroup","aria-label":o,className:ie("inline-flex",c),children:n.map(u=>s.jsxs("label",{title:u.title,className:ie("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",l==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",u.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===u.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[s.jsx("input",{type:"radio",name:i,value:u.value,checked:e===u.value,disabled:u.disabled,onChange:()=>t(u.value),className:"sr-only"}),u.label]},u.value))})}const bs=e=>Z_(e)?e.document:J_(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),md=e=>{let t=bs(e);return(t==null?void 0:t.defaultView)??(typeof window<"u"?window:void 0)};function m0(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Z_(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function J_(e){return m0(e)&&e.nodeType===9}function eE(e){return m0(e)&&e.nodeType===11&&"host"in e}let tE=!1;function kh(){return tE}function Co(e,t){var o;if(!kh())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!=null;){if(n===e)return!0;typeof n.assignedElements!="function"&&((o=n.assignedSlot)!=null&&o.parentNode)?n=n.assignedSlot.parentNode:eE(n)?n=n.host:n=n.parentNode}return!1}const no=(e=document)=>{var n;if(!kh())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((n=t.shadowRoot)!=null&&n.activeElement);)t=t.shadowRoot.activeElement;return t};function bn(e){if(kh()&&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 nE(e){e.focus({preventScroll:!0})}const sE=typeof document<"u"?je.useLayoutEffect:()=>{};function p0(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function rE(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function h0(e){let t=y.useRef({isFocused:!1,observer:null});return sE(()=>{const n=t.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]),y.useCallback(n=>{let o=bn(n);if(o instanceof HTMLButtonElement||o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||o instanceof HTMLSelectElement){t.current.isFocused=!0;let i=o,l=c=>{if(t.current.isFocused=!1,i.disabled){let u=p0(c);e==null||e(u)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};i.addEventListener("focusout",l,{once:!0}),t.current.observer=new MutationObserver(()=>{var c;if(t.current.isFocused&&i.disabled){(c=t.current.observer)==null||c.disconnect();let u=i===no()?null:no();i.dispatchEvent(new FocusEvent("blur",{relatedTarget:u})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:u}))}}),t.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function jh(e){var n;if(typeof window>"u"||window.navigator==null)return!1;let t=(n=window.navigator.userAgentData)==null?void 0:n.brands;return Array.isArray(t)&&t.some(o=>e.test(o.brand))||e.test(window.navigator.userAgent)}function Nh(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function Bo(e){let t=null;return()=>(t==null&&(t=e()),t)}const Sh=Bo(function(){return Nh(/^Mac/i)}),oE=Bo(function(){return Nh(/^iPhone/i)}),g0=Bo(function(){return Nh(/^iPad/i)||Sh()&&navigator.maxTouchPoints>1}),aE=Bo(function(){return oE()||g0()}),iE=Bo(function(){return jh(/AppleWebKit/i)&&(aE()||!lE())}),lE=Bo(function(){return jh(/Chrome|CriOS|CrMo/i)}),cE=Bo(function(){return jh(/Android/i)});function uE(e){return e.pointerType===""&&e.isTrusted?!0:cE()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function ml(e,t,n=!0){let{metaKey:o,ctrlKey:i,altKey:l,shiftKey:c}=t,u=iE()&&Sh()&&!g0()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:o,ctrlKey:i,altKey:l,shiftKey:c}):new MouseEvent("click",{metaKey:o,ctrlKey:i,altKey:l,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});ml.isOpening=n,nE(e),e.dispatchEvent(u),ml.isOpening=!1}ml.isOpening=!1;let Ya=null;const kp=new Set;let sl=new Map,Po=!1,bu=!1;const dE={Tab:!0,Escape:!0};function pd(e,t){for(let n of kp)n(e,t)}function fE(e){return!(e.metaKey||!Sh()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Au(e){Po=!0,!ml.isOpening&&fE(e)&&(Ya="keyboard",pd("keyboard",e))}function Ca(e){Ya="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Po=!0,pd("pointer",e))}function x0(e){!ml.isOpening&&uE(e)&&(Po=!0,Ya="virtual")}function y0(e){let t=bn(e),n=md(t),o=bs(t);if(t===n){bu=!0;return}t===o||!e.isTrusted||(!Po&&!bu&&(Ya="virtual",pd("virtual",e)),Po=!1,bu=!1)}function v0(){Po=!1,bu=!0}function b0(e){let t=no(bs(bn(e)));queueMicrotask(()=>{no(bs(bn(e)))!==t&&pE("keyboard")})}function jp(e){if(typeof window>"u"||typeof document>"u")return;const t=md(e),n=bs(e);if(sl.get(t))return;let o=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Po=!0,o.apply(this,arguments)}}),n.addEventListener("keydown",Au,!0),n.addEventListener("keyup",Au,!0),n.addEventListener("click",x0,!0),n.addEventListener("invalid",b0,!0),t.addEventListener("focus",y0,!0),t.addEventListener("blur",v0,!1),typeof PointerEvent<"u"&&(n.addEventListener("pointerdown",Ca,!0),n.addEventListener("pointermove",Ca,!0),n.addEventListener("pointerup",Ca,!0)),t.addEventListener("beforeunload",()=>{w0(e)},{once:!0}),sl.set(t,{focus:o})}const w0=(e,t)=>{const n=md(e),o=bs(e);t&&o.removeEventListener("DOMContentLoaded",t),sl.has(n)&&(Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:sl.get(n).focus}),o.removeEventListener("keydown",Au,!0),o.removeEventListener("keyup",Au,!0),o.removeEventListener("click",x0,!0),o.removeEventListener("invalid",b0,!0),n.removeEventListener("focus",y0,!0),n.removeEventListener("blur",v0,!1),typeof PointerEvent<"u"&&(o.removeEventListener("pointerdown",Ca,!0),o.removeEventListener("pointermove",Ca,!0),o.removeEventListener("pointerup",Ca,!0)),sl.delete(n))};function mE(e){const t=bs(e);let n;return t.readyState!=="loading"?jp(e):(n=()=>{jp(e)},t.addEventListener("DOMContentLoaded",n)),()=>w0(e,n)}typeof document<"u"&&mE();function Np(){return Ya!=="pointer"}function pE(e){Ya=e,pd(e,null)}const hE=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function gE(e,t,n){let o=n?bn(n):void 0,i=bs(o),l=md(o);const c=typeof l<"u"?l.HTMLInputElement:HTMLInputElement,u=typeof l<"u"?l.HTMLTextAreaElement:HTMLTextAreaElement,f=typeof l<"u"?l.HTMLElement:HTMLElement,p=typeof l<"u"?l.KeyboardEvent:KeyboardEvent;let h=no(i);return e=e||h instanceof c&&!hE.has(h.type)||h instanceof u||h instanceof f&&h.isContentEditable,!(e&&t==="keyboard"&&n instanceof p&&!dE[n.key])}function xE(e,t,n){jp(),y.useEffect(()=>{if((n==null?void 0:n.enabled)===!1)return;let o=(i,l)=>{gE(!!(n!=null&&n.isTextInput),i,l)&&e(Np())};return kp.add(o),()=>{kp.delete(o)}},t)}function yE(e){let{isDisabled:t,onFocus:n,onBlur:o,onFocusChange:i}=e;const l=y.useCallback(f=>{if(bn(f)===f.currentTarget)return o&&o(f),i&&i(!1),!0},[o,i]),c=h0(l),u=y.useCallback(f=>{let p=bn(f);const h=bs(p),b=h?no(h):no();p===f.currentTarget&&p===b&&(n&&n(f),i&&i(!0),c(f))},[i,n,c]);return{focusProps:{onFocus:!t&&(n||i||o)?u:void 0,onBlur:!t&&(o||i)?l:void 0}}}function k0(){let e=y.useRef(new Map),t=y.useCallback((i,l,c,u)=>{let f=u!=null&&u.once?(...p)=>{e.current.delete(c),c(...p)}:c;e.current.set(c,{type:l,eventTarget:i,fn:f,options:u}),i.addEventListener(l,f,u)},[]),n=y.useCallback((i,l,c,u)=>{var p;let f=((p=e.current.get(c))==null?void 0:p.fn)||c;i.removeEventListener(l,f,u),e.current.delete(c)},[]),o=y.useCallback(()=>{e.current.forEach((i,l)=>{n(i.eventTarget,i.type,l,i.options)})},[n]);return y.useEffect(()=>o,[o]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:o}}function vE(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:o,onFocusWithinChange:i}=e,l=y.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:u}=k0(),f=y.useCallback(b=>{Co(b.currentTarget,bn(b))&&l.current.isFocusWithin&&!Co(b.currentTarget,b.relatedTarget)&&(l.current.isFocusWithin=!1,u(),n&&n(b),i&&i(!1))},[n,i,l,u]),p=h0(f),h=y.useCallback(b=>{if(!Co(b.currentTarget,bn(b)))return;let g=bn(b);const m=bs(g),v=no(m);if(!l.current.isFocusWithin&&v===g){o&&o(b),i&&i(!0),l.current.isFocusWithin=!0,p(b);let w=b.currentTarget;c(m,"focus",j=>{let S=bn(j);if(l.current.isFocusWithin&&!Co(w,S)){let T=new m.defaultView.FocusEvent("blur",{relatedTarget:S});rE(T,w);let E=p0(T);f(E)}},{capture:!0})}},[o,i,p,c,f]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:h,onBlur:f}}}function bE(e={}){let{autoFocus:t=!1,isTextInput:n,within:o}=e,i=y.useRef({isFocused:!1,isFocusVisible:t||Np()}),[l,c]=y.useState(!1),[u,f]=y.useState(()=>i.current.isFocused&&i.current.isFocusVisible),p=y.useCallback(()=>f(i.current.isFocused&&i.current.isFocusVisible),[]),h=y.useCallback(m=>{i.current.isFocused=m,i.current.isFocusVisible=Np(),c(m),p()},[p]);xE(m=>{i.current.isFocusVisible=m,p()},[n,l],{enabled:l,isTextInput:n});let{focusProps:b}=yE({isDisabled:o,onFocusChange:h}),{focusWithinProps:g}=vE({isDisabled:!o,onFocusWithinChange:h});return{isFocused:l,isFocusVisible:u,focusProps:o?g:b}}var er=Gw();let Sp=!1,tu=0;function wE(){Sp=!0,setTimeout(()=>{Sp=!1},500)}function vv(e){e.pointerType==="touch"&&wE()}function kE(){let e=bs(null);if(!(typeof e>"u"))return tu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",vv),tu++,()=>{tu--,!(tu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",vv)}}function jE(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:o,isDisabled:i}=e,[l,c]=y.useState(!1),u=y.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;y.useEffect(kE,[]);let{addGlobalListener:f,removeAllGlobalListeners:p}=k0(),{hoverProps:h,triggerHoverEnd:b}=y.useMemo(()=>{let g=(w,j)=>{if(u.pointerType=j,i||j==="touch"||u.isHovered||!Co(w.currentTarget,bn(w)))return;u.isHovered=!0;let S=w.currentTarget;u.target=S,f(bs(bn(w)),"pointerover",T=>{u.isHovered&&u.target&&!Co(u.target,bn(T))&&m(T,T.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:S,pointerType:j}),n&&n(!0),c(!0)},m=(w,j)=>{let S=u.target;u.pointerType="",u.target=null,!(j==="touch"||!u.isHovered||!S)&&(u.isHovered=!1,p(),o&&o({type:"hoverend",target:S,pointerType:j}),n&&n(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=w=>{Sp&&w.pointerType==="mouse"||g(w,w.pointerType)},v.onPointerLeave=w=>{!i&&Co(w.currentTarget,bn(w))&&m(w,w.pointerType)}),{hoverProps:v,triggerHoverEnd:m}},[t,n,o,i,u,f,p]);return y.useEffect(()=>{i&&b({currentTarget:u.target},u.pointerType)},[i]),{hoverProps:h,isHovered:l}}var NE=Object.defineProperty,SE=(e,t,n)=>t in e?NE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lm=(e,t,n)=>(SE(e,typeof t!="symbol"?t+"":t,n),n);let _E=class{constructor(){Lm(this,"current",this.detect()),Lm(this,"handoffState","pending"),Lm(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}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"}},Qs=new _E;function Qa(e){var t;return Qs.isServer?null:e==null?document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function Ou(e){var t,n;return Qs.isServer?null:e==null?document:(n=(t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))!=null?n:document}function j0(e){var t,n;return(n=(t=Ou(e))==null?void 0:t.activeElement)!=null?n:null}function N0(e){return j0(e)===e}function hd(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function ns(){let e=[],t={addEventListener(n,o,i,l){return n.addEventListener(o,i,l),t.add(()=>n.removeEventListener(o,i,l))},requestAnimationFrame(...n){let o=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(o))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let o=setTimeout(...n);return t.add(()=>clearTimeout(o))},microTask(...n){let o={current:!0};return hd(()=>{o.current&&n[0]()}),t.add(()=>{o.current=!1})},style(n,o,i){let l=n.style.getPropertyValue(o);return Object.assign(n.style,{[o]:i}),this.add(()=>{Object.assign(n.style,{[o]:l})})},group(n){let o=ns();return n(o),this.add(()=>o.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let o=e.indexOf(n);if(o>=0)for(let i of e.splice(o,1))i()}},dispose(){for(let n of e.splice(0))n()}};return t}function oo(){let[e]=y.useState(ns);return y.useEffect(()=>()=>e.dispose(),[e]),e}let kt=(e,t)=>{Qs.isServer?y.useEffect(e,t):y.useLayoutEffect(e,t)};function ao(e){let t=y.useRef(e);return kt(()=>{t.current=e},[e]),t}let Ue=function(e){let t=ao(e);return je.useCallback((...n)=>t.current(...n),[t])};function EE(e){let t=e.width/2,n=e.height/2;return{top:e.clientY-n,right:e.clientX+t,bottom:e.clientY+n,left:e.clientX-t}}function $E(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function TE({disabled:e=!1}={}){let t=y.useRef(null),[n,o]=y.useState(!1),i=oo(),l=Ue(()=>{t.current=null,o(!1),i.dispose()}),c=Ue(u=>{if(i.dispose(),t.current===null){t.current=u.currentTarget,o(!0);{let f=Qa(u.currentTarget);i.addEventListener(f,"pointerup",l,!1),i.addEventListener(f,"pointermove",p=>{if(t.current){let h=EE(p);o($E(h,t.current.getBoundingClientRect()))}},!1),i.addEventListener(f,"pointercancel",l,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:c,onPointerUp:l,onClick:l}}}function ws(e){return y.useMemo(()=>e,Object.values(e))}let CE=y.createContext(void 0);function _h(){return y.useContext(CE)}function _p(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Nn(e,t,...n){if(e in t){let i=t[e];return typeof i=="function"?i(...n):i}let o=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(i=>`"${i}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,Nn),o}var Fa=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Fa||{}),Yr=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Yr||{});function Vt(){let e=AE();return y.useCallback(t=>RE({mergeRefs:e,...t}),[e])}function RE({ourProps:e,theirProps:t,slot:n,defaultTag:o,features:i,visible:l=!0,name:c,mergeRefs:u}){u=u??OE;let f=S0(t,e);if(l)return nu(f,n,o,c,u);let p=i??0;if(p&2){let{static:h=!1,...b}=f;if(h)return nu(b,n,o,c,u)}if(p&1){let{unmount:h=!0,...b}=f;return Nn(h?0:1,{0(){return null},1(){return nu({...b,hidden:!0,style:{display:"none"}},n,o,c,u)}})}return nu(f,n,o,c,u)}function nu(e,t={},n,o,i){let{as:l=n,children:c,refName:u="ref",...f}=Im(e,["unmount","static"]),p=e.ref!==void 0?{[u]:e.ref}:{},h=typeof c=="function"?c(t):c;h=E0(h),"className"in f&&f.className&&typeof f.className=="function"&&(f.className=f.className(t)),f["aria-labelledby"]&&f["aria-labelledby"]===f.id&&(f["aria-labelledby"]=void 0);let b={};if(t){let g=!1,m=[];for(let[v,w]of Object.entries(t))typeof w=="boolean"&&(g=!0),w===!0&&m.push(v.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(g){b["data-headlessui-state"]=m.join(" ");for(let v of m)b[`data-${v}`]=""}}if(rl(l)&&(Object.keys(Vr(f)).length>0||Object.keys(Vr(b)).length>0))if(!y.isValidElement(h)||Array.isArray(h)&&h.length>1||ME(h)){if(Object.keys(Vr(f)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${o} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Vr(f)).concat(Object.keys(Vr(b))).map(g=>` - ${g}`).join(`
441
+ `),"","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(g=>` - ${g}`).join(`
442
+ `)].join(`
443
+ `))}else{let g=h.props,m=g==null?void 0:g.className,v=typeof m=="function"?(...S)=>_p(m(...S),f.className):_p(m,f.className),w=v?{className:v}:{},j=S0(h.props,Vr(Im(f,["ref"])));for(let S in b)S in j&&delete b[S];return y.cloneElement(h,Object.assign({},j,b,p,{ref:i(PE(h),p.ref)},w))}return y.createElement(l,Object.assign({},Im(f,["ref"]),!rl(l)&&p,!rl(l)&&b),h)}function AE(){let e=y.useRef([]),t=y.useCallback(n=>{for(let o of e.current)o!=null&&(typeof o=="function"?o(n):o.current=n)},[]);return(...n)=>{if(!n.every(o=>o==null))return e.current=n,t}}function OE(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function S0(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let o of e)for(let i in o)i.startsWith("on")&&typeof o[i]=="function"?(n[i]!=null||(n[i]=[]),n[i].push(o[i])):t[i]=o[i];if(t.disabled||t["aria-disabled"])for(let o in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(o)&&(n[o]=[i=>{var l;return(l=i==null?void 0:i.preventDefault)==null?void 0:l.call(i)}]);for(let o in n)Object.assign(t,{[o](i,...l){let c=n[o];for(let u of c){if((i instanceof Event||(i==null?void 0:i.nativeEvent)instanceof Event)&&i.defaultPrevented)return;u(i,...l)}}});return t}function _0(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let o of e)for(let i in o)i.startsWith("on")&&typeof o[i]=="function"?(n[i]!=null||(n[i]=[]),n[i].push(o[i])):t[i]=o[i];for(let o in n)Object.assign(t,{[o](...i){let l=n[o];for(let c of l)c==null||c(...i)}});return t}function Mt(e){var t;return Object.assign(y.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function Vr(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Im(e,t=[]){let n=Object.assign({},e);for(let o of t)o in n&&delete n[o];return n}function PE(e){return je.version.split(".")[0]>="19"?e.props.ref:e.ref}function E0(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let t=e._payload;if(t!=null&&t.status==="fulfilled")return E0(t.value)}return e}function rl(e){return e===y.Fragment||e===Symbol.for("react.fragment")}function ME(e){return rl(e.type)}function LE(e,t,n){let[o,i]=y.useState(n),l=e!==void 0,c=y.useRef(l),u=y.useRef(!1),f=y.useRef(!1);return l&&!c.current&&!u.current?(u.current=!0,c.current=l,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.")):!l&&c.current&&!f.current&&(f.current=!0,c.current=l,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.")),[l?e:o,Ue(p=>(l||er.flushSync(()=>i(p)),t==null?void 0:t(p)))]}function IE(e){let[t]=y.useState(e);return t}function $0(e={},t=null,n=[]){for(let[o,i]of Object.entries(e))C0(n,T0(t,o),i);return n}function T0(e,t){return e?e+"["+t+"]":t}function C0(e,t,n){if(Array.isArray(n))for(let[o,i]of n.entries())C0(e,T0(t,o.toString()),i);else n instanceof Date?e.push([t,n.toISOString()]):typeof n=="boolean"?e.push([t,n?"1":"0"]):typeof n=="string"?e.push([t,n]):typeof n=="number"?e.push([t,`${n}`]):n==null?e.push([t,""]):DE(n)&&!y.isValidElement(n)&&$0(n,t,e)}function zE(e){var t,n;let o=(t=e==null?void 0:e.form)!=null?t:e.closest("form");if(o){for(let i of o.elements)if(i!==e&&(i.tagName==="INPUT"&&i.type==="submit"||i.tagName==="BUTTON"&&i.type==="submit"||i.nodeName==="INPUT"&&i.type==="image")){i.click();return}(n=o.requestSubmit)==null||n.call(o)}}function DE(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}let FE="span";var Ua=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Ua||{});function UE(e,t){var n;let{features:o=1,...i}=e,l={ref:t,"aria-hidden":(o&2)===2?!0:(n=i["aria-hidden"])!=null?n:void 0,hidden:(o&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",...(o&4)===4&&(o&2)!==2&&{display:"none"}}};return Vt()({ourProps:l,theirProps:i,slot:{},defaultTag:FE,name:"Hidden"})}let pl=Mt(UE),WE=y.createContext(null);function HE({children:e}){let t=y.useContext(WE);if(!t)return je.createElement(je.Fragment,null,e);let{target:n}=t;return n?er.createPortal(je.createElement(je.Fragment,null,e),n):null}function BE({data:e,form:t,disabled:n,onReset:o,overrides:i}){let[l,c]=y.useState(null),u=oo();return y.useEffect(()=>{if(o&&l)return u.addEventListener(l,"reset",o)},[l,t,o]),je.createElement(HE,null,je.createElement(GE,{setForm:c,formId:t}),$0(e).map(([f,p])=>je.createElement(pl,{features:Ua.Hidden,...Vr({key:f,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:n,name:f,value:p,...i})})))}function GE({setForm:e,formId:t}){return y.useEffect(()=>{if(t){let n=document.getElementById(t);n&&e(n)}},[e,t]),t?null:je.createElement(pl,{features:Ua.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:n=>{if(!n)return;let o=n.closest("form");o&&e(o)}})}let qE=y.createContext(void 0);function R0(){return y.useContext(qE)}function A0(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function vr(e){return A0(e)&&"tagName"in e}function Jn(e){return vr(e)&&"accessKey"in e}function xr(e){return vr(e)&&"tabIndex"in e}function VE(e){return vr(e)&&"style"in e}function KE(e){return Jn(e)&&e.nodeName==="IFRAME"}function O0(e){return Jn(e)&&e.nodeName==="INPUT"}function bv(e){return Jn(e)&&e.nodeName==="LABEL"}function XE(e){return Jn(e)&&e.nodeName==="FIELDSET"}function P0(e){return Jn(e)&&e.nodeName==="LEGEND"}function YE(e){return vr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function wv(e){let t=e.parentElement,n=null;for(;t&&!XE(t);)P0(t)&&(n=t),t=t.parentElement;let o=(t==null?void 0:t.getAttribute("disabled"))==="";return o&&QE(n)?!1:o}function QE(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(P0(t))return!1;t=t.previousElementSibling}return!0}let M0=Symbol();function ZE(e,t=!0){return Object.assign(e,{[M0]:t})}function mn(...e){let t=y.useRef(e);y.useEffect(()=>{t.current=e},[e]);let n=Ue(o=>{for(let i of t.current)i!=null&&(typeof i=="function"?i(o):i.current=o)});return e.every(o=>o==null||(o==null?void 0:o[M0]))?void 0:n}let gd=y.createContext(null);gd.displayName="DescriptionContext";function L0(){let e=y.useContext(gd);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,L0),t}return e}function JE(){var e,t;return(t=(e=y.useContext(gd))==null?void 0:e.value)!=null?t:void 0}function e$(){let[e,t]=y.useState([]);return[e.length>0?e.join(" "):void 0,y.useMemo(()=>function(n){let o=Ue(l=>(t(c=>[...c,l]),()=>t(c=>{let u=c.slice(),f=u.indexOf(l);return f!==-1&&u.splice(f,1),u}))),i=y.useMemo(()=>({register:o,slot:n.slot,name:n.name,props:n.props,value:n.value}),[o,n.slot,n.name,n.props,n.value]);return je.createElement(gd.Provider,{value:i},n.children)},[t])]}let t$="p";function n$(e,t){let n=y.useId(),o=_h(),{id:i=`headlessui-description-${n}`,...l}=e,c=L0(),u=mn(t);kt(()=>c.register(i),[i,c.register]);let f=ws({...c.slot,disabled:o||!1}),p={ref:u,...c.props,id:i};return Vt()({ourProps:p,theirProps:l,slot:f,defaultTag:t$,name:c.name||"Description"})}let s$=Mt(n$),I0=Object.assign(s$,{});var Ft=(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))(Ft||{});let xd=y.createContext(null);xd.displayName="LabelContext";function z0(){let e=y.useContext(xd);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,z0),t}return e}function D0(e){var t,n,o;let i=(n=(t=y.useContext(xd))==null?void 0:t.value)!=null?n:void 0;return((o=e==null?void 0:e.length)!=null?o:0)>0?[i,...e].filter(Boolean).join(" "):i}function r$({inherit:e=!1}={}){let t=D0(),[n,o]=y.useState([]),i=e?[t,...n].filter(Boolean):n;return[i.length>0?i.join(" "):void 0,y.useMemo(()=>function(l){let c=Ue(f=>(o(p=>[...p,f]),()=>o(p=>{let h=p.slice(),b=h.indexOf(f);return b!==-1&&h.splice(b,1),h}))),u=y.useMemo(()=>({register:c,slot:l.slot,name:l.name,props:l.props,value:l.value}),[c,l.slot,l.name,l.props,l.value]);return je.createElement(xd.Provider,{value:u},l.children)},[o])]}let o$="label";function a$(e,t){var n;let o=y.useId(),i=z0(),l=R0(),c=_h(),{id:u=`headlessui-label-${o}`,htmlFor:f=l??((n=i.props)==null?void 0:n.htmlFor),passive:p=!1,...h}=e,b=mn(t);kt(()=>i.register(u),[u,i.register]);let g=Ue(w=>{let j=w.currentTarget;if(!(w.target!==w.currentTarget&&YE(w.target))&&(bv(j)&&w.preventDefault(),i.props&&"onClick"in i.props&&typeof i.props.onClick=="function"&&i.props.onClick(w),bv(j))){let S=document.getElementById(j.htmlFor);if(S){let T=S.getAttribute("disabled");if(T==="true"||T==="")return;let E=S.getAttribute("aria-disabled");if(E==="true"||E==="")return;(O0(S)&&(S.type==="file"||S.type==="radio"||S.type==="checkbox")||S.role==="radio"||S.role==="checkbox"||S.role==="switch")&&S.click(),S.focus({preventScroll:!0})}}}),m=ws({...i.slot,disabled:c||!1}),v={ref:b,...i.props,id:u,htmlFor:f,onClick:g};return p&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in h&&delete h.onClick),Vt()({ourProps:v,theirProps:h,slot:m,defaultTag:f?o$:"div",name:i.name||"Label"})}let i$=Mt(a$),l$=Object.assign(i$,{}),c$=y.createContext(()=>{});function u$({value:e,children:t}){return je.createElement(c$.Provider,{value:e},t)}function d$(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function f$(e=d$){return y.useCallback((t,n)=>{if(typeof e=="string"){let o=e;return(t==null?void 0:t[o])===(n==null?void 0:n[o])}return e(t,n)},[e])}function kv(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function m$(e,t,n=!1){let[o,i]=y.useState(()=>kv(t));return kt(()=>{if(!t||!e)return;let l=ns();return l.requestAnimationFrame(function c(){l.requestAnimationFrame(c),i(u=>{let f=kv(t);return f.width===u.width&&f.height===u.height?u:f})}),()=>{l.dispose()}},[t,e]),n?{width:`${o.width}px`,height:`${o.height}px`}:o}var F0=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(F0||{});function p$(e){let t=y.useRef(null),n=Ue(i=>{t.current=i.pointerType,!wv(i.currentTarget)&&i.pointerType==="mouse"&&i.button===F0.Left&&(i.preventDefault(),e(i))}),o=Ue(i=>{t.current!=="mouse"&&(wv(i.currentTarget)||e(i))});return{onPointerDown:n,onClick:o}}let U0=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};var h$=Object.defineProperty,g$=(e,t,n)=>t in e?h$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x$=(e,t,n)=>(g$(e,t+"",n),n),W0=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},ms=(e,t,n)=>(W0(e,t,"read from private field"),n?n.call(e):t.get(e)),zm=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},jv=(e,t,n,o)=>(W0(e,t,"write to private field"),t.set(e,n),n),Ks,Zi,Ji;let H0=class{constructor(t){zm(this,Ks,{}),zm(this,Zi,new U0(()=>new Set)),zm(this,Ji,new Set),x$(this,"disposables",ns()),jv(this,Ks,t),Qs.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return ms(this,Ks)}subscribe(t,n){if(Qs.isServer)return()=>{};let o={selector:t,callback:n,current:t(ms(this,Ks))};return ms(this,Ji).add(o),this.disposables.add(()=>{ms(this,Ji).delete(o)})}on(t,n){return Qs.isServer?()=>{}:(ms(this,Zi).get(t).add(n),this.disposables.add(()=>{ms(this,Zi).get(t).delete(n)}))}send(t){let n=this.reduce(ms(this,Ks),t);if(n!==ms(this,Ks)){jv(this,Ks,n);for(let o of ms(this,Ji)){let i=o.selector(ms(this,Ks));B0(o.current,i)||(o.current=i,o.callback(i))}for(let o of ms(this,Zi).get(t.type))o(ms(this,Ks),t)}}};Ks=new WeakMap,Zi=new WeakMap,Ji=new WeakMap;function B0(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:Dm(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:Dm(e.entries(),t.entries()):Nv(e)&&Nv(t)?Dm(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function Dm(e,t){do{let n=e.next(),o=t.next();if(n.done&&o.done)return!0;if(n.done||o.done||!Object.is(n.value,o.value))return!1}while(!0)}function Nv(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function Fm(e){let[t,n]=e(),o=ns();return(...i)=>{t(...i),o.dispose(),o.microTask(n)}}var y$=Object.defineProperty,v$=(e,t,n)=>t in e?y$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sv=(e,t,n)=>(v$(e,typeof t!="symbol"?t+"":t,n),n),G0=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(G0||{});let b$={0(e,t){let n=t.id,o=e.stack,i=e.stack.indexOf(n);if(i!==-1){let l=e.stack.slice();return l.splice(i,1),l.push(n),o=l,{...e,stack:o}}return{...e,stack:[...e.stack,n]}},1(e,t){let n=t.id,o=e.stack.indexOf(n);if(o===-1)return e;let i=e.stack.slice();return i.splice(o,1),{...e,stack:i}}},w$=class q0 extends H0{constructor(){super(...arguments),Sv(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),Sv(this,"selectors",{isTop:(t,n)=>t.stack[t.stack.length-1]===n,inStack:(t,n)=>t.stack.includes(n)})}static new(){return new q0({stack:[]})}reduce(t,n){return Nn(n.type,b$,t,n)}};const yd=new U0(()=>w$.new());var Um={exports:{}},Wm={};/**
444
+ * @license React
445
+ * use-sync-external-store-with-selector.production.js
446
+ *
447
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
448
+ *
449
+ * This source code is licensed under the MIT license found in the
450
+ * LICENSE file in the root directory of this source tree.
451
+ */var _v;function k$(){if(_v)return Wm;_v=1;var e=cd();function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,i=e.useRef,l=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Wm.useSyncExternalStoreWithSelector=function(f,p,h,b,g){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=c(function(){function j($){if(!S){if(S=!0,T=$,$=b($),g!==void 0&&v.hasValue){var R=v.value;if(g(R,$))return E=R}return E=$}if(R=E,n(T,$))return R;var C=b($);return g!==void 0&&g(R,C)?(T=$,R):(T=$,E=C)}var S=!1,T,E,_=h===void 0?null:h;return[function(){return j(p())},_===null?void 0:function(){return j(_())}]},[p,h,b,g]);var w=o(f,m[0],m[1]);return l(function(){v.hasValue=!0,v.value=w},[w]),u(w),w},Wm}var Ev;function j$(){return Ev||(Ev=1,Um.exports=k$()),Um.exports}var N$=j$();function vn(e,t,n=B0){return N$.useSyncExternalStoreWithSelector(Ue(o=>e.subscribe(S$,o)),Ue(()=>e.state),Ue(()=>e.state),Ue(t),n)}function S$(e){return e}function Pl(e,t){let n=y.useId(),o=yd.get(t),[i,l]=vn(o,y.useCallback(c=>[o.selectors.isTop(c,n),o.selectors.inStack(c,n)],[o,n]));return kt(()=>{if(e)return o.actions.push(n),()=>o.actions.pop(n)},[o,e,n]),e?l?i:!0:!1}let Ep=new Map,ol=new Map;function $v(e){var t;let n=(t=ol.get(e))!=null?t:0;return ol.set(e,n+1),n!==0?()=>Tv(e):(Ep.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Tv(e))}function Tv(e){var t;let n=(t=ol.get(e))!=null?t:1;if(n===1?ol.delete(e):ol.set(e,n-1),n!==1)return;let o=Ep.get(e);o&&(o["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",o["aria-hidden"]),e.inert=o.inert,Ep.delete(e))}function V0(e,{allowed:t,disallowed:n}={}){let o=Pl(e,"inert-others");kt(()=>{var i,l;if(!o)return;let c=ns();for(let f of(i=n==null?void 0:n())!=null?i:[])f&&c.add($v(f));let u=(l=t==null?void 0:t())!=null?l:[];for(let f of u){if(!f)continue;let p=Qa(f);if(!p)continue;let h=f.parentElement;for(;h&&h!==p.body;){for(let b of h.children)u.some(g=>b.contains(g))||c.add($v(b));h=h.parentElement}}return c.dispose},[o,t,n])}function K0(e,t,n){let o=ao(i=>{let l=i.getBoundingClientRect();l.x===0&&l.y===0&&l.width===0&&l.height===0&&n()});y.useEffect(()=>{if(!e)return;let i=t===null?null:Jn(t)?t:t.current;if(!i)return;let l=ns();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>o.current(i));c.observe(i),l.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>o.current(i));c.observe(i),l.add(()=>c.disconnect())}return()=>l.dispose()},[t,o,e])}let Pu=["[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(","),_$=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var Ls=(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))(Ls||{}),$p=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))($p||{}),E$=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(E$||{});function X0(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Pu)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function $$(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(_$)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Eh=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Eh||{});function Y0(e,t=0){var n;return e===((n=Qa(e))==null?void 0:n.body)?!1:Nn(t,{0(){return e.matches(Pu)},1(){let o=e;for(;o!==null;){if(o.matches(Pu))return!0;o=o.parentElement}return!1}})}var T$=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(T$||{});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 br(e){e==null||e.focus({preventScroll:!0})}let C$=["textarea","input"].join(",");function R$(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,C$))!=null?n:!1}function Q0(e,t=n=>n){return e.slice().sort((n,o)=>{let i=t(n),l=t(o);if(i===null||l===null)return 0;let c=i.compareDocumentPosition(l);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function A$(e,t,n=e===null?document.body:Ou(e)){return Ra(X0(n),t,{relativeTo:e})}function Ra(e,t,{sorted:n=!0,relativeTo:o=null,skipElements:i=[]}={}){let l=Array.isArray(e)?e.length>0?Ou(e[0]):document:Ou(e),c=Array.isArray(e)?n?Q0(e):e:t&64?$$(e):X0(e);i.length>0&&c.length>1&&(c=c.filter(m=>!i.some(v=>v!=null&&"current"in v?(v==null?void 0:v.current)===m:v===m))),o=o??(l==null?void 0:l.activeElement);let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,c.indexOf(o))-1;if(t&4)return Math.max(0,c.indexOf(o))+1;if(t&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=t&32?{preventScroll:!0}:{},h=0,b=c.length,g;do{if(h>=b||h+b<=0)return 0;let m=f+h;if(t&16)m=(m+b)%b;else{if(m<0)return 3;if(m>=b)return 1}g=c[m],g==null||g.focus(p),h+=u}while(g!==j0(g));return t&6&&R$(g)&&g.select(),2}function Z0(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function O$(){return/Android/gi.test(window.navigator.userAgent)}function Cv(){return Z0()||O$()}function Sa(e,t,n,o){let i=ao(n);y.useEffect(()=>{if(!e)return;function l(c){i.current(c)}return document.addEventListener(t,l,o),()=>document.removeEventListener(t,l,o)},[e,t,o])}function J0(e,t,n,o){let i=ao(n);y.useEffect(()=>{if(!e)return;function l(c){i.current(c)}return window.addEventListener(t,l,o),()=>window.removeEventListener(t,l,o)},[e,t,o])}const Rv=30;function ek(e,t,n){let o=ao(n),i=y.useCallback(function(u,f){if(u.defaultPrevented)return;let p=f(u);if(p===null||!p.getRootNode().contains(p)||!p.isConnected)return;let h=(function b(g){return typeof g=="function"?b(g()):Array.isArray(g)||g instanceof Set?g:[g]})(t);for(let b of h)if(b!==null&&(b.contains(p)||u.composed&&u.composedPath().includes(b)))return;return!Y0(p,Eh.Loose)&&p.tabIndex!==-1&&u.preventDefault(),o.current(u,p)},[o,t]),l=y.useRef(null);Sa(e,"pointerdown",u=>{var f,p;Cv()||(l.current=((p=(f=u.composedPath)==null?void 0:f.call(u))==null?void 0:p[0])||u.target)},!0),Sa(e,"pointerup",u=>{if(Cv()||!l.current)return;let f=l.current;return l.current=null,i(u,()=>f)},!0);let c=y.useRef({x:0,y:0});Sa(e,"touchstart",u=>{c.current.x=u.touches[0].clientX,c.current.y=u.touches[0].clientY},!0),Sa(e,"touchend",u=>{let f={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(f.x-c.current.x)>=Rv||Math.abs(f.y-c.current.y)>=Rv))return i(u,()=>xr(u.target)?u.target:null)},!0),J0(e,"blur",u=>i(u,()=>KE(window.document.activeElement)?window.document.activeElement:null),!0)}function hl(...e){return y.useMemo(()=>Qa(...e),[...e])}var P$=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(P$||{});const su={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},M$=200,Av=5;function L$(e,{trigger:t,action:n,close:o,select:i}){let l=y.useRef(null),c=y.useRef(null),u=y.useRef(null);Sa(e&&t!==null,"pointerdown",f=>{A0(f==null?void 0:f.target)&&t!=null&&t.contains(f.target)&&(c.current=f.x,u.current=f.y,l.current=f.timeStamp)}),Sa(e&&t!==null,"pointerup",f=>{var p,h;let b=l.current;if(b===null||(l.current=null,!xr(f.target))||Math.abs(f.x-((p=c.current)!=null?p:f.x))<Av&&Math.abs(f.y-((h=u.current)!=null?h:f.y))<Av)return;let g=n(f);switch(g.kind){case 0:return;case 1:{f.timeStamp-b>M$&&(i(g.target),o());break}case 2:{o();break}}},{capture:!0})}function tk(e,t,n,o){let i=ao(n);y.useEffect(()=>{e=e??window;function l(c){i.current(c)}return e.addEventListener(t,l,o),()=>e.removeEventListener(t,l,o)},[e,t,o])}function I$(e,t){return y.useMemo(()=>{var n;if(e.type)return e.type;let o=(n=e.as)!=null?n:"button";if(typeof o=="string"&&o.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function z$(e){return y.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function D$(e,t){let n=e(),o=new Set;return{getSnapshot(){return n},subscribe(i){return o.add(i),()=>o.delete(i)},dispatch(i,...l){let c=t[i].call(n,...l);c&&(n=c,o.forEach(u=>u()))}}}function F$(){let e;return{before({doc:t}){var n;let o=t.documentElement,i=(n=t.defaultView)!=null?n:window;e=Math.max(0,i.innerWidth-o.clientWidth)},after({doc:t,d:n}){let o=t.documentElement,i=Math.max(0,o.clientWidth-o.offsetWidth),l=Math.max(0,e-i);n.style(o,"paddingRight",`${l}px`)}}}function U$(){return Z0()?{before({doc:e,d:t,meta:n}){function o(i){for(let l of n().containers)for(let c of l())if(c.contains(i))return!0;return!1}t.microTask(()=>{var i;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=ns();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let l=(i=window.scrollY)!=null?i:window.pageYOffset,c=null;t.addEventListener(e,"click",u=>{if(xr(u.target))try{let f=u.target.closest("a");if(!f)return;let{hash:p}=new URL(f.href),h=e.querySelector(p);xr(h)&&!o(h)&&(c=h)}catch{}},!0),t.group(u=>{t.addEventListener(e,"touchstart",f=>{if(u.dispose(),xr(f.target)&&VE(f.target))if(o(f.target)){let p=f.target;for(;p.parentElement&&o(p.parentElement);)p=p.parentElement;u.style(p,"overscrollBehavior","contain")}else u.style(f.target,"touchAction","none")})}),t.addEventListener(e,"touchmove",u=>{if(xr(u.target)){if(O0(u.target))return;if(o(u.target)){let f=u.target;for(;f.parentElement&&f.dataset.headlessuiPortal!==""&&!(f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth);)f=f.parentElement;f.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let f=(u=window.scrollY)!=null?u:window.pageYOffset;l!==f&&window.scrollTo(0,l),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function W$(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Ov(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let Ro=D$(()=>new Map,{PUSH(e,t){var n;let o=(n=this.get(e))!=null?n:{doc:e,count:0,d:ns(),meta:new Set,computedMeta:{}};return o.count++,o.meta.add(t),o.computedMeta=Ov(o.meta),this.set(e,o),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t),n.computedMeta=Ov(n.meta)),this},SCROLL_PREVENT(e){let t={doc:e.doc,d:e.d,meta(){return e.computedMeta}},n=[U$(),F$(),W$()];n.forEach(({before:o})=>o==null?void 0:o(t)),n.forEach(({after:o})=>o==null?void 0:o(t))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Ro.subscribe(()=>{let e=Ro.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let o=t.get(n.doc)==="hidden",i=n.count!==0;(i&&!o||!i&&o)&&Ro.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&Ro.dispatch("TEARDOWN",n)}});function H$(e,t,n=()=>({containers:[]})){let o=z$(Ro),i=t?o.get(t):void 0,l=i?i.count>0:!1;return kt(()=>{if(!(!t||!e))return Ro.dispatch("PUSH",t,n),()=>Ro.dispatch("POP",t,n)},[e,t]),l}function nk(e,t,n=()=>[document.body]){let o=Pl(e,"scroll-lock");H$(o,t,i=>{var l;return{containers:[...(l=i.containers)!=null?l:[],n]}})}function Pv(e){return[e.screenX,e.screenY]}function B$(){let e=y.useRef([-1,-1]);return{wasMoved(t){let n=Pv(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=Pv(t)}}}function G$(e=0){let[t,n]=y.useState(e),o=y.useCallback(f=>n(f),[]),i=y.useCallback(f=>n(p=>p|f),[]),l=y.useCallback(f=>(t&f)===f,[t]),c=y.useCallback(f=>n(p=>p&~f),[]),u=y.useCallback(f=>n(p=>p^f),[]);return{flags:t,setFlag:o,addFlag:i,hasFlag:l,removeFlag:c,toggleFlag:u}}var q$={},Mv,Lv;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Mv=process==null?void 0:q$)==null?void 0:Mv.NODE_ENV)==="test"&&typeof((Lv=Element==null?void 0:Element.prototype)==null?void 0:Lv.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(`
452
+ `)),[]});var V$=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(V$||{});function sk(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function rk(e,t,n,o){let[i,l]=y.useState(n),{hasFlag:c,addFlag:u,removeFlag:f}=G$(e&&i?3:0),p=y.useRef(!1),h=y.useRef(!1),b=oo();return kt(()=>{var g;if(e){if(n&&l(!0),!t){n&&u(3);return}return(g=o==null?void 0:o.start)==null||g.call(o,n),K$(t,{inFlight:p,prepare(){h.current?h.current=!1:h.current=p.current,p.current=!0,!h.current&&(n?(u(3),f(4)):(u(4),f(2)))},run(){h.current?n?(f(3),u(4)):(f(4),u(3)):n?f(1):u(1)},done(){var m;h.current&&Q$(t)||(p.current=!1,f(7),n||l(!1),(m=o==null?void 0:o.end)==null||m.call(o,n))}})}},[e,n,t,b]),e?[i,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function K$(e,{prepare:t,run:n,done:o,inFlight:i}){let l=ns();return Y$(e,{prepare:t,inFlight:i}),l.nextFrame(()=>{n(),l.requestAnimationFrame(()=>{l.add(X$(e,o))})}),l.dispose}function X$(e,t){var n,o;let i=ns();if(!e)return i.dispose;let l=!1;i.add(()=>{l=!0});let c=(o=(n=e.getAnimations)==null?void 0:n.call(e).filter(u=>u instanceof CSSTransition))!=null?o:[];return c.length===0?(t(),i.dispose):(Promise.allSettled(c.map(u=>u.finished)).then(()=>{l||t()}),i.dispose)}function Y$(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let o=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=o}function Q$(e){var t,n;return((n=(t=e.getAnimations)==null?void 0:t.call(e))!=null?n:[]).some(o=>o instanceof CSSTransition&&o.playState!=="finished")}function $h(e,t){let n=y.useRef([]),o=Ue(e);y.useEffect(()=>{let i=[...n.current];for(let[l,c]of t.entries())if(n.current[l]!==c){let u=o(t,i);return n.current=t,u}},[o,...t])}function vd(){return typeof window<"u"}function Za(e){return ok(e)?(e.nodeName||"").toLowerCase():"#document"}function Un(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function kr(e){var t;return(t=(ok(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ok(e){return vd()?e instanceof Node||e instanceof Un(e).Node:!1}function Fn(e){return vd()?e instanceof Element||e instanceof Un(e).Element:!1}function io(e){return vd()?e instanceof HTMLElement||e instanceof Un(e).HTMLElement:!1}function Iv(e){return!vd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Un(e).ShadowRoot}function bd(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=tr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&i!=="inline"&&i!=="contents"}function Z$(e){return/^(table|td|th)$/.test(Za(e))}function wd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const J$=/transform|translate|scale|rotate|perspective|filter/,eT=/paint|layout|strict|content/,So=e=>!!e&&e!=="none";let Hm;function Th(e){const t=Fn(e)?tr(e):e;return So(t.transform)||So(t.translate)||So(t.scale)||So(t.rotate)||So(t.perspective)||!Ch()&&(So(t.backdropFilter)||So(t.filter))||J$.test(t.willChange||"")||eT.test(t.contain||"")}function tT(e){let t=Mo(e);for(;io(t)&&!gl(t);){if(Th(t))return t;if(wd(t))return null;t=Mo(t)}return null}function Ch(){return Hm==null&&(Hm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Hm}function gl(e){return/^(html|body|#document)$/.test(Za(e))}function tr(e){return Un(e).getComputedStyle(e)}function kd(e){return Fn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mo(e){if(Za(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Iv(e)&&e.host||kr(e);return Iv(t)?t.host:t}function ak(e){const t=Mo(e);return gl(t)?(e.ownerDocument||e).body:io(t)&&bd(t)?t:ak(t)}function xl(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=ak(e),l=i===((o=e.ownerDocument)==null?void 0:o.body),c=Un(i);if(l){const u=Tp(c);return t.concat(c,c.visualViewport||[],bd(i)?i:[],u&&n?xl(u):[])}else return t.concat(i,xl(i,[],n))}function Tp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nT(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:o}=t;return n+"/"+o}).join(" "):navigator.userAgent}const Lo=Math.min,ys=Math.max,yl=Math.round,ru=Math.floor,wr=e=>({x:e,y:e}),sT={left:"right",right:"left",bottom:"top",top:"bottom"};function rT(e,t,n){return ys(e,Lo(t,n))}function Ja(e,t){return typeof e=="function"?e(t):e}function Io(e){return e.split("-")[0]}function Ml(e){return e.split("-")[1]}function ik(e){return e==="x"?"y":"x"}function lk(e){return e==="y"?"height":"width"}function yr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ck(e){return ik(yr(e))}function oT(e,t,n){n===void 0&&(n=!1);const o=Ml(e),i=ck(e),l=lk(i);let c=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=Mu(c)),[c,Mu(c)]}function aT(e){const t=Mu(e);return[Cp(e),t,Cp(t)]}function Cp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const zv=["left","right"],Dv=["right","left"],iT=["top","bottom"],lT=["bottom","top"];function cT(e,t,n){switch(e){case"top":case"bottom":return n?t?Dv:zv:t?zv:Dv;case"left":case"right":return t?iT:lT;default:return[]}}function uT(e,t,n,o){const i=Ml(e);let l=cT(Io(e),n==="start",o);return i&&(l=l.map(c=>c+"-"+i),t&&(l=l.concat(l.map(Cp)))),l}function Mu(e){const t=Io(e);return sT[t]+e.slice(t.length)}function dT(e){var t,n,o,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(o=e.bottom)!=null?o:0,left:(i=e.left)!=null?i:0}}function fT(e){return typeof e!="number"?dT(e):{top:e,right:e,bottom:e,left:e}}function Lu(e){const{x:t,y:n,width:o,height:i}=e;return{width:o,height:i,top:n,left:t,right:t+o,bottom:n+i,x:t,y:n}}function Fv(e,t,n){let{reference:o,floating:i}=e;const l=yr(t),c=ck(t),u=lk(c),f=Io(t),p=l==="y",h=o.x+o.width/2-i.width/2,b=o.y+o.height/2-i.height/2,g=o[u]/2-i[u]/2;let m;switch(f){case"top":m={x:h,y:o.y-i.height};break;case"bottom":m={x:h,y:o.y+o.height};break;case"right":m={x:o.x+o.width,y:b};break;case"left":m={x:o.x-i.width,y:b};break;default:m={x:o.x,y:o.y}}const v=Ml(t);return v&&(m[c]+=g*(v==="end"?1:-1)*(n&&p?-1:1)),m}async function uk(e,t){var n;t===void 0&&(t={});const{x:o,y:i,platform:l,rects:c,elements:u,strategy:f}=e,{boundary:p="clippingAncestors",rootBoundary:h="viewport",elementContext:b="floating",altBoundary:g=!1,padding:m=0}=Ja(t,e),v=fT(m),j=u[g?b==="floating"?"reference":"floating":b],S=Lu(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(j)))==null||n?j:j.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:p,rootBoundary:h,strategy:f})),T=b==="floating"?{x:o,y:i,width:c.floating.width,height:c.floating.height}:c.reference,E=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),_=await(l.isElement==null?void 0:l.isElement(E))&&await(l.getScale==null?void 0:l.getScale(E))||{x:1,y:1},$=Lu(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:T,offsetParent:E,strategy:f}):T);return{top:(S.top-$.top+v.top)/_.y,bottom:($.bottom-S.bottom+v.bottom)/_.y,left:(S.left-$.left+v.left)/_.x,right:($.right-S.right+v.right)/_.x}}const mT=50,pT=async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:l=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:uk},f=await(c.isRTL==null?void 0:c.isRTL(t));let p=await c.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:b}=Fv(p,o,f),g=o,m=0;const v={};for(let w=0;w<l.length;w++){const j=l[w];if(!j)continue;const{name:S,fn:T}=j,{x:E,y:_,data:$,reset:R}=await T({x:h,y:b,initialPlacement:o,placement:g,strategy:i,middlewareData:v,rects:p,platform:u,elements:{reference:e,floating:t}});h=E??h,b=_??b,v[S]={...v[S],...$},R&&m<mT&&(m++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(p=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:i}):R.rects),{x:h,y:b}=Fv(p,g,f)),w=-1)}return{x:h,y:b,placement:g,strategy:i,middlewareData:v}},hT=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:i,middlewareData:l,rects:c,initialPlacement:u,platform:f,elements:p}=t,{mainAxis:h=!0,crossAxis:b=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...j}=Ja(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const S=Io(i),T=yr(u),E=Io(u)===u,_=await(f.isRTL==null?void 0:f.isRTL(p.floating)),$=g||(E||!w?[Mu(u)]:aT(u)),R=v!=="none";!g&&R&&$.push(...uT(u,w,v,_));const C=[u,...$],O=await f.detectOverflow(t,j),I=[];let D=((o=l.flip)==null?void 0:o.overflows)||[];if(h&&I.push(O[S]),b){const U=oT(i,c,_);I.push(O[U[0]],O[U[1]])}if(D=[...D,{placement:i,overflows:I}],!I.every(U=>U<=0)){var z,H;const U=(((z=l.flip)==null?void 0:z.index)||0)+1,X=C[U];if(X&&(!(b==="alignment"?T!==yr(X):!1)||D.every(M=>yr(M.placement)===T?M.overflows[0]>0:!0)))return{data:{index:U,overflows:D},reset:{placement:X}};let P=(H=D.filter(K=>K.overflows[0]<=0).sort((K,M)=>K.overflows[1]-M.overflows[1])[0])==null?void 0:H.placement;if(!P)switch(m){case"bestFit":{var F;const K=(F=D.filter(M=>{if(R){const G=yr(M.placement);return G===T||G==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(G=>G>0).reduce((G,B)=>G+B,0)]).sort((M,G)=>M[1]-G[1])[0])==null?void 0:F[0];K&&(P=K);break}case"initialPlacement":P=u;break}if(i!==P)return{reset:{placement:P}}}return{}}}},gT=new Set(["left","top"]);async function xT(e,t){const{placement:n,platform:o,elements:i}=e,l=await(o.isRTL==null?void 0:o.isRTL(i.floating)),c=Io(n),u=Ml(n),f=yr(n)==="y",p=gT.has(c)?-1:1,h=l&&f?-1:1,b=Ja(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:v}=typeof b=="number"?{mainAxis:b,crossAxis:0,alignmentAxis:null}:{mainAxis:b.mainAxis||0,crossAxis:b.crossAxis||0,alignmentAxis:b.alignmentAxis};return u&&typeof v=="number"&&(m=u==="end"?v*-1:v),f?{x:m*h,y:g*p}:{x:g*p,y:m*h}}const yT=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:i,y:l,placement:c,middlewareData:u}=t,f=await xT(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(o=u.arrow)!=null&&o.alignmentOffset?{}:{x:i+f.x,y:l+f.y,data:{...f,placement:c}}}}},vT=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:i,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:f={fn:T=>{let{x:E,y:_}=T;return{x:E,y:_}}},...p}=Ja(e,t),h={x:n,y:o},b=await l.detectOverflow(t,p),g=yr(i),m=ik(g);let v=h[m],w=h[g];const j=(T,E)=>rT(E+b[T==="y"?"top":"left"],E,E-b[T==="y"?"bottom":"right"]);c&&(v=j(m,v)),u&&(w=j(g,w));const S=f.fn({...t,[m]:v,[g]:w});return{...S,data:{x:S.x-n,y:S.y-o,enabled:{[m]:c,[g]:u}}}}}},bT=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:o,platform:i,elements:l}=t,{apply:c=()=>{},...u}=Ja(e,t),f=await i.detectOverflow(t,u),p=Io(n),h=Ml(n),b=yr(n)==="y",{width:g,height:m}=o.floating;let v,w;p==="top"||p==="bottom"?(v=p,w=h===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=p,v=h==="end"?"top":"bottom");const j=m-f.top-f.bottom,S=g-f.left-f.right,T=Lo(m-f[v],j),E=Lo(g-f[w],S),_=t.middlewareData.shift,$=!_;let R=T,C=E;_!=null&&_.enabled.x&&(C=S),_!=null&&_.enabled.y&&(R=j),$&&!h&&(b?C=g-2*ys(f.left,f.right):R=m-2*ys(f.top,f.bottom)),await c({...t,availableWidth:C,availableHeight:R});const O=await i.getDimensions(l.floating);return g!==O.width||m!==O.height?{reset:{rects:!0}}:{}}}};function dk(e){const t=tr(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=io(e),l=i?e.offsetWidth:n,c=i?e.offsetHeight:o,u=yl(n)!==l||yl(o)!==c;return u&&(n=l,o=c),{width:n,height:o,$:u}}function Rh(e){return Fn(e)?e:e.contextElement}function Aa(e){const t=Rh(e);if(!io(t))return wr(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:l}=dk(t);let c=(l?yl(n.width):n.width)/o,u=(l?yl(n.height):n.height)/i;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const wT=wr(0);function fk(e){const t=Un(e);return!Ch()||!t.visualViewport?wT:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kT(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Un(e)}function zo(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),l=Rh(e);let c=wr(1);t&&(o?Fn(o)&&(c=Aa(o)):c=Aa(e));const u=kT(l,n,o)?fk(l):wr(0);let f=(i.left+u.x)/c.x,p=(i.top+u.y)/c.y,h=i.width/c.x,b=i.height/c.y;if(l&&o){const g=Un(l),m=Fn(o)?Un(o):o;let v=g,w=Tp(v);for(;w&&m!==v;){const j=Aa(w),S=w.getBoundingClientRect(),T=tr(w),E=S.left+(w.clientLeft+parseFloat(T.paddingLeft))*j.x,_=S.top+(w.clientTop+parseFloat(T.paddingTop))*j.y;f*=j.x,p*=j.y,h*=j.x,b*=j.y,f+=E,p+=_,v=Un(w),w=Tp(v)}}return Lu({width:h,height:b,x:f,y:p})}function jd(e,t){const n=kd(e).scrollLeft;return t?t.left+n:zo(kr(e)).left+n}function mk(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-jd(e,n),i=n.top+t.scrollTop;return{x:o,y:i}}function jT(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const l=i==="fixed",c=kr(o),u=t?wd(t.floating):!1;if(o===c||u&&l)return n;let f={scrollLeft:0,scrollTop:0},p=wr(1);const h=wr(0),b=io(o);if((b||!l)&&((Za(o)!=="body"||bd(c))&&(f=kd(o)),b)){const m=zo(o);p=Aa(o),h.x=m.x+o.clientLeft,h.y=m.y+o.clientTop}const g=c&&!b&&!l?mk(c,f):wr(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-f.scrollLeft*p.x+h.x+g.x,y:n.y*p.y-f.scrollTop*p.y+h.y+g.y}}function NT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ST(e){const t=kd(e),n=e.ownerDocument.body,o=ys(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ys(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let l=-t.scrollLeft+jd(e);const c=-t.scrollTop;return tr(n).direction==="rtl"&&(l+=ys(e.clientWidth,n.clientWidth)-o),{width:o,height:i,x:l,y:c}}const _T=25;function ET(e,t,n){n===void 0&&(n="viewport");const o=n==="layoutViewport",i=Un(e),l=kr(e),c=i.visualViewport;let u=l.clientWidth,f=l.clientHeight,p=0,h=0;if(c){const g=!Ch()||t==="fixed";o?g||(p=-c.offsetLeft,h=-c.offsetTop):(u=c.width,f=c.height,g&&(p=c.offsetLeft,h=c.offsetTop))}if(jd(l)<=0){const g=l.ownerDocument,m=g.body,v=getComputedStyle(m),w=g.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,j=Math.abs(l.clientWidth-m.clientWidth-w),S=getComputedStyle(l).scrollbarGutter==="stable both-edges"?j/2:j;S<=_T&&(u-=S)}return{width:u,height:f,x:p,y:h}}function $T(e,t){const n=zo(e,!0,t==="fixed"),o=n.top+e.clientTop,i=n.left+e.clientLeft,l=Aa(e),c=e.clientWidth*l.x,u=e.clientHeight*l.y,f=i*l.x,p=o*l.y;return{width:c,height:u,x:f,y:p}}function Uv(e,t,n){let o;if(t==="viewport"||t==="layoutViewport")o=ET(e,n,t);else if(t==="document")o=ST(kr(e));else if(Fn(t))o=$T(t,n);else{const i=fk(e);o={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Lu(o)}function TT(e,t){const n=t.get(e);if(n)return n;let o=xl(e,[],!1).filter(u=>Fn(u)&&Za(u)!=="body"),i=null;const l=tr(e).position==="fixed";let c=l?Mo(e):e;for(;Fn(c)&&!gl(c);){const u=tr(c),f=Th(c),p=i?i.position:l?"fixed":"";!f&&(p==="fixed"||p==="absolute"&&u.position==="static")?o=o.filter(b=>b!==c):i=u,c=Mo(c)}return t.set(e,o),o}function CT(e){let{element:t,boundary:n,rootBoundary:o,strategy:i}=e;const c=[...n==="clippingAncestors"?wd(t)?[]:TT(t,this._c):[].concat(n),o],u=Uv(t,c[0],i);let f=u.top,p=u.right,h=u.bottom,b=u.left;for(let g=1;g<c.length;g++){const m=Uv(t,c[g],i);f=ys(m.top,f),p=Lo(m.right,p),h=Lo(m.bottom,h),b=ys(m.left,b)}return{width:p-b,height:h-f,x:b,y:f}}function RT(e){const{width:t,height:n}=dk(e);return{width:t,height:n}}function AT(e,t,n){const o=io(t),i=kr(t),l=n==="fixed",c=zo(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const f=wr(0);if((o||!l)&&((Za(t)!=="body"||bd(i))&&(u=kd(t)),o)){const g=zo(t,!0,l,t);f.x=g.x+t.clientLeft,f.y=g.y+t.clientTop}!o&&i&&(f.x=jd(i));const p=i&&!o&&!l?mk(i,u):wr(0),h=c.left+u.scrollLeft-f.x-p.x,b=c.top+u.scrollTop-f.y-p.y;return{x:h,y:b,width:c.width,height:c.height}}function Bm(e){return tr(e).position==="static"}function Wv(e,t){if(!io(e)||tr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return kr(e)===n&&(n=n.ownerDocument.body),n}function pk(e,t){const n=Un(e);if(wd(e))return n;if(!io(e)){let i=Mo(e);for(;i&&!gl(i);){if(Fn(i)&&!Bm(i))return i;i=Mo(i)}return n}let o=Wv(e,t);for(;o&&Z$(o)&&Bm(o);)o=Wv(o,t);return o&&gl(o)&&Bm(o)&&!Th(o)?n:o||tT(e)||n}const OT=async function(e){const t=this.getOffsetParent||pk,n=this.getDimensions,o=await n(e.floating);return{reference:AT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function PT(e){return tr(e).direction==="rtl"}const MT={convertOffsetParentRelativeRectToViewportRelativeRect:jT,getDocumentElement:kr,getClippingRect:CT,getOffsetParent:pk,getElementRects:OT,getClientRects:NT,getDimensions:RT,getScale:Aa,isElement:Fn,isRTL:PT};function hk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function LT(e,t,n){let o=null,i;const l=kr(e);function c(){var h;clearTimeout(i),(h=o)==null||h.disconnect(),o=null}function u(h,b){h===void 0&&(h=!1),b===void 0&&(b=1),c();const g=e.getBoundingClientRect(),{left:m,top:v,width:w,height:j}=g;if(h||t(),!w||!j)return;const S=ru(v),T=ru(l.clientWidth-(m+w)),E=ru(l.clientHeight-(v+j)),_=ru(m),R={rootMargin:-S+"px "+-T+"px "+-E+"px "+-_+"px",threshold:ys(0,Lo(1,b))||1};let C=!0;function O(I){const D=I[0].intersectionRatio;if(!hk(g,e.getBoundingClientRect()))return u();if(D!==b){if(!C)return u();D?u(!1,D):i=setTimeout(()=>{u(!1,1e-7)},1e3)}C=!1}try{o=new IntersectionObserver(O,{...R,root:l.ownerDocument})}catch{o=new IntersectionObserver(O,R)}o.observe(e)}const f=Un(e),p=()=>u(n);return f.addEventListener("resize",p),u(!0),()=>{f.removeEventListener("resize",p),c()}}function IT(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:f=!1}=o,p=Rh(e),h=i||l?[...p?xl(p):[],...t?xl(t):[]]:[];h.forEach(S=>{i&&S.addEventListener("scroll",n),l&&S.addEventListener("resize",n)});const b=p&&u?LT(p,n,l):null;let g=-1,m=null;c&&(m=new ResizeObserver(S=>{let[T]=S;T&&T.target===p&&m&&t&&(m.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=m)==null||E.observe(t)})),n()}),p&&!f&&m.observe(p),t&&m.observe(t));let v,w=f?zo(e):null;f&&j();function j(){const S=zo(e);w&&!hk(w,S)&&n(),w=S,v=requestAnimationFrame(j)}return n(),()=>{var S;h.forEach(T=>{i&&T.removeEventListener("scroll",n),l&&T.removeEventListener("resize",n)}),b==null||b(),(S=m)==null||S.disconnect(),m=null,f&&cancelAnimationFrame(v)}}const Gm=uk,zT=yT,DT=vT,FT=hT,UT=bT,WT=(e,t,n)=>{const o=new Map,i=n??{},l={...MT,...i.platform,_c:o};return pT(e,t,{...i,platform:l})};var HT=typeof document<"u",BT=function(){},wu=HT?y.useLayoutEffect:BT;function Iu(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Iu(e[o],t[o]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,i[o]))return!1;for(o=n;o--!==0;){const l=i[o];if(!(l==="_owner"&&e.$$typeof)&&!Iu(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function gk(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hv(e,t){const n=gk(e);return Math.round(t*n)/n}function qm(e){const t=y.useRef(e);return wu(()=>{t.current=e}),t}function GT(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:i,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:f,open:p}=e,[h,b]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,m]=y.useState(o);Iu(g,o)||m(o);const[v,w]=y.useState(null),[j,S]=y.useState(null),T=y.useCallback(M=>{M!==R.current&&(R.current=M,w(M))},[]),E=y.useCallback(M=>{M!==C.current&&(C.current=M,S(M))},[]),_=l||v,$=c||j,R=y.useRef(null),C=y.useRef(null),O=y.useRef(h),I=f!=null,D=qm(f),z=qm(i),H=qm(p),F=y.useCallback(()=>{if(!R.current||!C.current)return;const M={placement:t,strategy:n,middleware:g};z.current&&(M.platform=z.current),WT(R.current,C.current,M).then(G=>{const B={...G,isPositioned:H.current!==!1};U.current&&!Iu(O.current,B)&&(O.current=B,er.flushSync(()=>{b(B)}))})},[g,t,n,z,H]);wu(()=>{p===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,b(M=>({...M,isPositioned:!1})))},[p]);const U=y.useRef(!1);wu(()=>(U.current=!0,()=>{U.current=!1}),[]),wu(()=>{if(_&&(R.current=_),$&&(C.current=$),_&&$){if(D.current)return D.current(_,$,F);F()}},[_,$,F,D,I]);const X=y.useMemo(()=>({reference:R,floating:C,setReference:T,setFloating:E}),[T,E]),P=y.useMemo(()=>({reference:_,floating:$}),[_,$]),K=y.useMemo(()=>{const M={position:n,left:0,top:0};if(!P.floating)return M;const G=Hv(P.floating,h.x),B=Hv(P.floating,h.y);return u?{...M,transform:"translate("+G+"px, "+B+"px)",...gk(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:B}},[n,u,P.floating,h.x,h.y]);return y.useMemo(()=>({...h,update:F,refs:X,elements:P,floatingStyles:K}),[h,F,X,P,K])}const xk=(e,t)=>{const n=zT(e);return{name:n.name,fn:n.fn,options:[e,t]}},qT=(e,t)=>{const n=DT(e);return{name:n.name,fn:n.fn,options:[e,t]}},VT=(e,t)=>{const n=FT(e);return{name:n.name,fn:n.fn,options:[e,t]}},KT=(e,t)=>{const n=UT(e);return{name:n.name,fn:n.fn,options:[e,t]}},yk={...xp},XT=yk.useInsertionEffect,YT=XT||(e=>e());function vk(e){const t=y.useRef(()=>{});return YT(()=>{t.current=e}),y.useCallback(function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return t.current==null?void 0:t.current(...o)},[])}var Rp=typeof document<"u"?y.useLayoutEffect:y.useEffect;let Bv=!1,QT=0;const Gv=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+QT++;function ZT(){const[e,t]=y.useState(()=>Bv?Gv():void 0);return Rp(()=>{e==null&&t(Gv())},[]),y.useEffect(()=>{Bv=!0},[]),e}const JT=yk.useId,eC=JT||ZT;function tC(){const e=new Map;return{emit(t,n){var o;(o=e.get(t))==null||o.forEach(i=>i(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var o;e.set(t,((o=e.get(t))==null?void 0:o.filter(i=>i!==n))||[])}}}const nC=y.createContext(null),sC=y.createContext(null),rC=()=>{var e;return((e=y.useContext(nC))==null?void 0:e.id)||null},oC=()=>y.useContext(sC),aC="data-floating-ui-focusable";function iC(e){const{open:t=!1,onOpenChange:n,elements:o}=e,i=eC(),l=y.useRef({}),[c]=y.useState(()=>tC()),u=rC()!=null,[f,p]=y.useState(o.reference),h=vk((m,v,w)=>{l.current.openEvent=m?v:void 0,c.emit("openchange",{open:m,event:v,reason:w,nested:u}),n==null||n(m,v,w)}),b=y.useMemo(()=>({setPositionReference:p}),[]),g=y.useMemo(()=>({reference:f||o.reference||null,floating:o.floating||null,domReference:o.reference}),[f,o.reference,o.floating]);return y.useMemo(()=>({dataRef:l,open:t,onOpenChange:h,elements:g,events:c,floatingId:i,refs:b}),[t,h,g,c,i,b])}function lC(e){e===void 0&&(e={});const{nodeId:t}=e,n=iC({...e,elements:{reference:null,floating:null,...e.elements}}),o=e.rootContext||n,i=o.elements,[l,c]=y.useState(null),[u,f]=y.useState(null),h=(i==null?void 0:i.domReference)||l,b=y.useRef(null),g=oC();Rp(()=>{h&&(b.current=h)},[h]);const m=GT({...e,elements:{...i,...u&&{reference:u}}}),v=y.useCallback(E=>{const _=Fn(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),contextElement:E}:E;f(_),m.refs.setReference(_)},[m.refs]),w=y.useCallback(E=>{(Fn(E)||E===null)&&(b.current=E,c(E)),(Fn(m.refs.reference.current)||m.refs.reference.current===null||E!==null&&!Fn(E))&&m.refs.setReference(E)},[m.refs]),j=y.useMemo(()=>({...m.refs,setReference:w,setPositionReference:v,domReference:b}),[m.refs,w,v]),S=y.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),T=y.useMemo(()=>({...m,...o,refs:j,elements:S,nodeId:t}),[m,j,S,t,o]);return Rp(()=>{o.dataRef.current.floatingContext=T;const E=g==null?void 0:g.nodesRef.current.find(_=>_.id===t);E&&(E.context=T)}),y.useMemo(()=>({...m,context:T,refs:j,elements:S}),[m,j,S,T])}const qv="active",Vv="selected";function Vm(e,t,n){const o=new Map,i=n==="item";let l=e;if(i&&e){const{[qv]:c,[Vv]:u,...f}=e;l=f}return{...n==="floating"&&{tabIndex:-1,[aC]:""},...l,...t.map(c=>{const u=c?c[n]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((c,u)=>(u&&Object.entries(u).forEach(f=>{let[p,h]=f;if(!(i&&[qv,Vv].includes(p)))if(p.indexOf("on")===0){if(o.has(p)||o.set(p,[]),typeof h=="function"){var b;(b=o.get(p))==null||b.push(h),c[p]=function(){for(var g,m=arguments.length,v=new Array(m),w=0;w<m;w++)v[w]=arguments[w];return(g=o.get(p))==null?void 0:g.map(j=>j(...v)).find(j=>j!==void 0)}}}else c[p]=h}),c),{})}}function cC(e){e===void 0&&(e=[]);const t=e.map(u=>u==null?void 0:u.reference),n=e.map(u=>u==null?void 0:u.floating),o=e.map(u=>u==null?void 0:u.item),i=y.useCallback(u=>Vm(u,e,"reference"),t),l=y.useCallback(u=>Vm(u,e,"floating"),n),c=y.useCallback(u=>Vm(u,e,"item"),o);return y.useMemo(()=>({getReferenceProps:i,getFloatingProps:l,getItemProps:c}),[i,l,c])}function Kv(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const uC=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:o,onFallbackChange:i,offset:l=0,index:c=0,minItemsVisible:u=4,referenceOverflowThreshold:f=0,scrollRef:p,...h}=Ja(e,t),{rects:b,elements:{floating:g}}=t,m=n.current[c],v=(p==null?void 0:p.current)||g,w=g.clientTop||v.clientTop,j=g.clientTop!==0,S=v.clientTop!==0,T=g===v;if(!m)return{};const E={...t,...await xk(-m.offsetTop-g.clientTop-b.reference.height/2-m.offsetHeight/2-l).fn(t)},_=await Gm(Kv(E,v.scrollHeight+w+g.clientTop),h),$=await Gm(E,{...h,elementContext:"reference"}),R=ys(0,_.top),C=E.y+R,D=(v.scrollHeight>v.clientHeight?z=>z:yl)(ys(0,v.scrollHeight+(j&&T||S?w*2:0)-R-ys(0,_.bottom)));if(v.style.maxHeight=D+"px",v.scrollTop=R,i){const z=v.offsetHeight<m.offsetHeight*Lo(u,n.current.length)-1||$.top>=-f||$.bottom>=-f;er.flushSync(()=>i(z))}return o&&(o.current=await Gm(Kv({...E,y:C},v.offsetHeight+w+g.clientTop),h)),{y:C}}});function dC(e,t){const{open:n,elements:o}=e,{enabled:i=!0,overflowRef:l,scrollRef:c,onChange:u}=t,f=vk(u),p=y.useRef(!1),h=y.useRef(null),b=y.useRef(null);y.useEffect(()=>{if(!i)return;function m(w){if(w.ctrlKey||!v||l.current==null)return;const j=w.deltaY,S=l.current.top>=-.5,T=l.current.bottom>=-.5,E=v.scrollHeight-v.clientHeight,_=j<0?-1:1,$=j<0?"max":"min";v.scrollHeight<=v.clientHeight||(!S&&j>0||!T&&j<0?(w.preventDefault(),er.flushSync(()=>{f(R=>R+Math[$](j,E*_))})):/firefox/i.test(nT())&&(v.scrollTop+=j))}const v=(c==null?void 0:c.current)||o.floating;if(n&&v)return v.addEventListener("wheel",m),requestAnimationFrame(()=>{h.current=v.scrollTop,l.current!=null&&(b.current={...l.current})}),()=>{h.current=null,b.current=null,v.removeEventListener("wheel",m)}},[i,n,o.floating,l,c,f]);const g=y.useMemo(()=>({onKeyDown(){p.current=!0},onWheel(){p.current=!1},onPointerMove(){p.current=!1},onScroll(){const m=(c==null?void 0:c.current)||o.floating;if(!(!l.current||!m||!p.current)){if(h.current!==null){const v=m.scrollTop-h.current;(l.current.bottom<-.5&&v<-1||l.current.top<-.5&&v>1)&&er.flushSync(()=>f(w=>w+v))}requestAnimationFrame(()=>{h.current=m.scrollTop})}}}),[o.floating,f,l,c]);return y.useMemo(()=>i?{floating:g}:{},[i,g])}let ei=y.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});ei.displayName="FloatingContext";let Ah=y.createContext(null);Ah.displayName="PlacementContext";function fC(e){return y.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function mC(){return y.useContext(ei).setReference}function pC(){return y.useContext(ei).getReferenceProps}function hC(){let{getFloatingProps:e,slot:t}=y.useContext(ei);return y.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function gC(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=y.useContext(Ah),n=y.useMemo(()=>e,[JSON.stringify(e,(i,l)=>{var c;return(c=l==null?void 0:l.outerHTML)!=null?c:l})]);kt(()=>{t==null||t(n??null)},[t,n]);let o=y.useContext(ei);return y.useMemo(()=>[o.setFloating,e?o.styles:{}],[o.setFloating,e,o.styles])}let Xv=4;function xC({children:e,enabled:t=!0}){let[n,o]=y.useState(null),[i,l]=y.useState(0),c=y.useRef(null),[u,f]=y.useState(null);yC(u);let p=t&&n!==null&&u!==null,{to:h="bottom",gap:b=0,offset:g=0,padding:m=0,inner:v}=vC(n,u),[w,j="center"]=h.split(" ");kt(()=>{p&&l(0)},[p]);let{refs:S,floatingStyles:T,context:E}=lC({open:p,placement:w==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${w}`:`${w}-${j}`,strategy:"absolute",transform:!1,middleware:[xk({mainAxis:w==="selection"?0:b,crossAxis:g}),qT({padding:m}),w!=="selection"&&VT({padding:m}),w==="selection"&&v?uC({...v,padding:m,overflowRef:c,offset:i,minItemsVisible:Xv,referenceOverflowThreshold:m,onFallbackChange(z){var H,F;if(!z)return;let U=E.elements.floating;if(!U)return;let X=parseFloat(getComputedStyle(U).scrollPaddingBottom)||0,P=Math.min(Xv,U.childElementCount),K=0,M=0;for(let G of(F=(H=E.elements.floating)==null?void 0:H.childNodes)!=null?F:[])if(Jn(G)){let B=G.offsetTop,L=B+G.clientHeight+X,q=U.scrollTop,ne=q+U.clientHeight;if(B>=q&&L<=ne)P--;else{M=Math.max(0,Math.min(L,ne)-Math.max(B,q)),K=G.clientHeight;break}}P>=1&&l(G=>{let B=K*P-M+X;return G>=B?G:B})}}):null,KT({padding:m,apply({availableWidth:z,availableHeight:H,elements:F}){Object.assign(F.floating.style,{overflow:"auto",maxWidth:`${z}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${H}px)`})}})].filter(Boolean),whileElementsMounted:IT}),[_=w,$=j]=E.placement.split("-");w==="selection"&&(_="selection");let R=y.useMemo(()=>({anchor:[_,$].filter(Boolean).join(" ")}),[_,$]),C=dC(E,{overflowRef:c,onChange:l}),{getReferenceProps:O,getFloatingProps:I}=cC([C]),D=Ue(z=>{f(z),S.setFloating(z)});return y.createElement(Ah.Provider,{value:o},y.createElement(ei.Provider,{value:{setFloating:D,setReference:S.setReference,styles:T,getReferenceProps:O,getFloatingProps:I,slot:R}},e))}function yC(e){kt(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,o=parseFloat(n);if(isNaN(o))return;let i=parseInt(n);isNaN(i)||o!==i&&(e.style.maxHeight=`${Math.ceil(o)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function vC(e,t){var n,o,i;let l=Km((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),c=Km((o=e==null?void 0:e.offset)!=null?o:"var(--anchor-offset, 0)",t),u=Km((i=e==null?void 0:e.padding)!=null?i:"var(--anchor-padding, 0)",t);return{...e,gap:l,offset:c,padding:u}}function Km(e,t,n=void 0){let o=oo(),i=Ue((f,p)=>{if(f==null)return[n,null];if(typeof f=="number")return[f,null];if(typeof f=="string"){if(!p)return[n,null];let h=Yv(f,p);return[h,b=>{let g=bk(f);{let m=g.map(v=>window.getComputedStyle(p).getPropertyValue(v));o.requestAnimationFrame(function v(){o.nextFrame(v);let w=!1;for(let[S,T]of g.entries()){let E=window.getComputedStyle(p).getPropertyValue(T);if(m[S]!==E){m[S]=E,w=!0;break}}if(!w)return;let j=Yv(f,p);h!==j&&(b(j),h=j)})}return o.dispose}]}return[n,null]}),l=y.useMemo(()=>i(e,t)[0],[e,t]),[c=l,u]=y.useState();return kt(()=>{let[f,p]=i(e,t);if(u(f),!!p)return p(u)},[e,t]),c}function bk(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let o=t[1].slice(0,n).trim(),i=t[1].slice(n+1).trim();return i?[o,...bk(i)]:[o]}return[]}function Yv(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let o=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),o}function bC({children:e,freeze:t},n){let o=wk(t,e);return y.isValidElement(o)?y.cloneElement(o,{ref:n}):je.createElement(je.Fragment,null,o)}je.forwardRef(bC);function wk(e,t){let[n,o]=y.useState(t);return!e&&n!==t&&o(t),e?n:t}let Nd=y.createContext(null);Nd.displayName="OpenClosedContext";var wn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(wn||{});function Ll(){return y.useContext(Nd)}function kk({value:e,children:t}){return je.createElement(Nd.Provider,{value:e},t)}function wC({children:e}){return je.createElement(Nd.Provider,{value:null},e)}function kC(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Kr=[];kC(()=>{function e(t){if(!xr(t.target)||t.target===document.body||Kr[0]===t.target)return;let n=t.target;n=n.closest(Pu),Kr.unshift(n??t.target),Kr=Kr.filter(o=>o!=null&&o.isConnected),Kr.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 jC(e){throw new Error("Unexpected object: "+e)}var _t=(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))(_t||{});function ou(e,t){let n=t.resolveItems();if(n.length<=0)return null;let o=t.resolveActiveIndex(),i=o??-1;switch(e.focus){case 0:{for(let l=0;l<n.length;++l)if(!t.resolveDisabled(n[l],l,n))return l;return o}case 1:{i===-1&&(i=n.length);for(let l=i-1;l>=0;--l)if(!t.resolveDisabled(n[l],l,n))return l;return o}case 2:{for(let l=i+1;l<n.length;++l)if(!t.resolveDisabled(n[l],l,n))return l;return o}case 3:{for(let l=n.length-1;l>=0;--l)if(!t.resolveDisabled(n[l],l,n))return l;return o}case 4:{for(let l=0;l<n.length;++l)if(t.resolveId(n[l],l,n)===e.id)return l;return o}case 5:return null;default:jC(e)}}function Oh(e){let t=Ue(e),n=y.useRef(!1);y.useEffect(()=>(n.current=!1,()=>{n.current=!0,hd(()=>{n.current&&t()})}),[t])}function NC(){let e=typeof document>"u";return"useSyncExternalStore"in xp?(t=>t.useSyncExternalStore)(xp)(()=>()=>{},()=>!1,()=>!e):!1}function Il(){let e=NC(),[t,n]=y.useState(Qs.isHandoffComplete);return t&&Qs.isHandoffComplete===!1&&n(!1),y.useEffect(()=>{t!==!0&&n(!0)},[t]),y.useEffect(()=>Qs.handoff(),[]),e?!1:t}let jk=y.createContext(!1);function SC(){return y.useContext(jk)}function Qv(e){return je.createElement(jk.Provider,{value:e.force},e.children)}function _C(e){let t=SC(),n=y.useContext(Sk),[o,i]=y.useState(()=>{var l;if(!t&&n!==null)return(l=n.current)!=null?l:null;if(Qs.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return y.useEffect(()=>{o!==null&&(e!=null&&e.body.contains(o)||e==null||e.body.appendChild(o))},[o,e]),y.useEffect(()=>{t||n!==null&&i(n.current)},[n,i,t]),o}let Nk=y.Fragment,EC=Mt(function(e,t){let{ownerDocument:n=null,...o}=e,i=y.useRef(null),l=mn(ZE(m=>{i.current=m}),t),c=hl(i.current),u=n??c,f=_C(u),p=y.useContext(Ap),h=oo(),b=Il(),g=Vt();return Oh(()=>{var m;f&&f.childNodes.length<=0&&((m=f.parentElement)==null||m.removeChild(f))}),!f||!b?null:er.createPortal(je.createElement("div",{"data-headlessui-portal":"",ref:m=>{h.dispose(),p&&m&&h.add(p.register(m))}},g({ourProps:{ref:l},theirProps:o,slot:{},defaultTag:Nk,name:"Portal"})),f)});function $C(e,t){let n=mn(t),{enabled:o=!0,ownerDocument:i,...l}=e,c=Vt();return o?je.createElement(EC,{...l,ownerDocument:i,ref:n}):c({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Nk,name:"Portal"})}let TC=y.Fragment,Sk=y.createContext(null);function CC(e,t){let{target:n,...o}=e,i={ref:mn(t)},l=Vt();return je.createElement(Sk.Provider,{value:n},l({ourProps:i,theirProps:o,defaultTag:TC,name:"Popover.Group"}))}let Ap=y.createContext(null);function RC(){let e=y.useContext(Ap),t=y.useRef([]),n=Ue(l=>(t.current.push(l),e&&e.register(l),()=>o(l))),o=Ue(l=>{let c=t.current.indexOf(l);c!==-1&&t.current.splice(c,1),e&&e.unregister(l)}),i=y.useMemo(()=>({register:n,unregister:o,portals:t}),[n,o,t]);return[t,y.useMemo(()=>function({children:l}){return je.createElement(Ap.Provider,{value:i},l)},[i])]}let AC=Mt($C),_k=Mt(CC),Ek=Object.assign(AC,{Group:_k});const ku={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function $k(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function OC(e,t,n){let o=ns();if(t.kind==="Tracked"){let i=function(){l!==$k(e)&&(o.dispose(),n())},{position:l}=t,c=new ResizeObserver(i);c.observe(e),o.add(()=>c.disconnect()),o.addEventListener(window,"scroll",i,{passive:!0}),o.addEventListener(window,"resize",i)}return()=>o.dispose()}function PC(e,t=typeof document<"u"?document.defaultView:null,n){let o=Pl(e,"escape");tk(t,"keydown",i=>{o&&(i.defaultPrevented||i.key===Ft.Escape&&n(i))})}function MC(){var e;let[t]=y.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,o]=y.useState((e=t==null?void 0:t.matches)!=null?e:!1);return kt(()=>{if(!t)return;function i(l){o(l.matches)}return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[t]),n}function LC({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let o=Ue(()=>{var i,l;let c=Qa(n),u=[];for(let f of e)f!==null&&(vr(f)?u.push(f):"current"in f&&vr(f.current)&&u.push(f.current));if(t!=null&&t.current)for(let f of t.current)u.push(f);for(let f of(i=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?i:[])f!==document.body&&f!==document.head&&vr(f)&&f.id!=="headlessui-portal-root"&&(n&&(f.contains(n)||f.contains((l=n==null?void 0:n.getRootNode())==null?void 0:l.host))||u.some(p=>f.contains(p))||u.push(f));return u});return{resolveContainers:o,contains:Ue(i=>o().some(l=>l.contains(i)))}}let Tk=y.createContext(null);function Zv({children:e,node:t}){let[n,o]=y.useState(null),i=Ck(t??n);return je.createElement(Tk.Provider,{value:i},e,i===null&&je.createElement(pl,{features:Ua.Hidden,ref:l=>{var c,u;if(l){for(let f of(u=(c=Qa(l))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?u:[])if(f!==document.body&&f!==document.head&&vr(f)&&f!=null&&f.contains(l)){o(f);break}}}}))}function Ck(e=null){var t;return(t=y.useContext(Tk))!=null?t:e}function Ph(){let e=y.useRef(!1);return kt(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var el=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(el||{});function IC(){let e=y.useRef(0);return J0(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function Rk(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)vr(n.current)&&t.add(n.current);return t}let zC="div";var Eo=(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))(Eo||{});function DC(e,t){let n=y.useRef(null),o=mn(n,t),{initialFocus:i,initialFocusFallback:l,containers:c,features:u=15,...f}=e;Il()||(u=0);let p=hl(n.current);HC(u,{ownerDocument:p});let h=BC(u,{ownerDocument:p,container:n,initialFocus:i,initialFocusFallback:l});GC(u,{ownerDocument:p,container:n,containers:c,previousActiveElement:h});let b=IC(),g=Ue(T=>{if(!Jn(n.current))return;let E=n.current;(_=>_())(()=>{Nn(b.current,{[el.Forwards]:()=>{Ra(E,Ls.First,{skipElements:[T.relatedTarget,l]})},[el.Backwards]:()=>{Ra(E,Ls.Last,{skipElements:[T.relatedTarget,l]})}})})}),m=Pl(!!(u&2),"focus-trap#tab-lock"),v=oo(),w=y.useRef(!1),j={ref:o,onKeyDown(T){T.key=="Tab"&&(w.current=!0,v.requestAnimationFrame(()=>{w.current=!1}))},onBlur(T){if(!(u&4))return;let E=Rk(c);Jn(n.current)&&E.add(n.current);let _=T.relatedTarget;xr(_)&&_.dataset.headlessuiFocusGuard!=="true"&&(Ak(E,_)||(w.current?Ra(n.current,Nn(b.current,{[el.Forwards]:()=>Ls.Next,[el.Backwards]:()=>Ls.Previous})|Ls.WrapAround,{relativeTo:T.target}):xr(T.target)&&br(T.target)))}},S=Vt();return je.createElement(je.Fragment,null,m&&je.createElement(pl,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Ua.Focusable}),S({ourProps:j,theirProps:f,defaultTag:zC,name:"FocusTrap"}),m&&je.createElement(pl,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Ua.Focusable}))}let FC=Mt(DC),UC=Object.assign(FC,{features:Eo});function WC(e=!0){let t=y.useRef(Kr.slice());return $h(([n],[o])=>{o===!0&&n===!1&&hd(()=>{t.current.splice(0)}),o===!1&&n===!0&&(t.current=Kr.slice())},[e,Kr,t]),Ue(()=>{var n;return(n=t.current.find(o=>o!=null&&o.isConnected))!=null?n:null})}function HC(e,{ownerDocument:t}){let n=!!(e&8),o=WC(n);$h(()=>{n||N0(t==null?void 0:t.body)&&br(o())},[n]),Oh(()=>{n&&br(o())})}function BC(e,{ownerDocument:t,container:n,initialFocus:o,initialFocusFallback:i}){let l=y.useRef(null),c=Pl(!!(e&1),"focus-trap#initial-focus"),u=Ph();return $h(()=>{if(e===0)return;if(!c){i!=null&&i.current&&br(i.current);return}let f=n.current;f&&hd(()=>{if(!u.current)return;let p=t==null?void 0:t.activeElement;if(o!=null&&o.current){if((o==null?void 0:o.current)===p){l.current=p;return}}else if(f.contains(p)){l.current=p;return}if(o!=null&&o.current)br(o.current);else{if(e&16){if(Ra(f,Ls.First|Ls.AutoFocus)!==$p.Error)return}else if(Ra(f,Ls.First)!==$p.Error)return;if(i!=null&&i.current&&(br(i.current),(t==null?void 0:t.activeElement)===i.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}l.current=t==null?void 0:t.activeElement})},[i,c,e]),l}function GC(e,{ownerDocument:t,container:n,containers:o,previousActiveElement:i}){let l=Ph(),c=!!(e&4);tk(t==null?void 0:t.defaultView,"focus",u=>{if(!c||!l.current)return;let f=Rk(o);Jn(n.current)&&f.add(n.current);let p=i.current;if(!p)return;let h=u.target;Jn(h)?Ak(f,h)?(i.current=h,br(h)):(u.preventDefault(),u.stopPropagation(),br(p)):br(i.current)},!0)}function Ak(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function Ok(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!rl((t=e.as)!=null?t:Mk)||je.Children.count(e.children)===1}let Sd=y.createContext(null);Sd.displayName="TransitionContext";var qC=(e=>(e.Visible="visible",e.Hidden="hidden",e))(qC||{});function VC(){let e=y.useContext(Sd);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function KC(){let e=y.useContext(_d);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let _d=y.createContext(null);_d.displayName="NestingContext";function Ed(e){return"children"in e?Ed(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function Pk(e,t){let n=ao(e),o=y.useRef([]),i=Ph(),l=oo(),c=Ue((m,v=Yr.Hidden)=>{let w=o.current.findIndex(({el:j})=>j===m);w!==-1&&(Nn(v,{[Yr.Unmount](){o.current.splice(w,1)},[Yr.Hidden](){o.current[w].state="hidden"}}),l.microTask(()=>{var j;!Ed(o)&&i.current&&((j=n.current)==null||j.call(n))}))}),u=Ue(m=>{let v=o.current.find(({el:w})=>w===m);return v?v.state!=="visible"&&(v.state="visible"):o.current.push({el:m,state:"visible"}),()=>c(m,Yr.Unmount)}),f=y.useRef([]),p=y.useRef(Promise.resolve()),h=y.useRef({enter:[],leave:[]}),b=Ue((m,v,w)=>{f.current.splice(0),t&&(t.chains.current[v]=t.chains.current[v].filter(([j])=>j!==m)),t==null||t.chains.current[v].push([m,new Promise(j=>{f.current.push(j)})]),t==null||t.chains.current[v].push([m,new Promise(j=>{Promise.all(h.current[v].map(([S,T])=>T)).then(()=>j())})]),v==="enter"?p.current=p.current.then(()=>t==null?void 0:t.wait.current).then(()=>w(v)):w(v)}),g=Ue((m,v,w)=>{Promise.all(h.current[v].splice(0).map(([j,S])=>S)).then(()=>{var j;(j=f.current.shift())==null||j()}).then(()=>w(v))});return y.useMemo(()=>({children:o,register:u,unregister:c,onStart:b,onStop:g,wait:p,chains:h}),[u,c,o,b,g,h,p])}let Mk=y.Fragment,Lk=Fa.RenderStrategy;function XC(e,t){var n,o;let{transition:i=!0,beforeEnter:l,afterEnter:c,beforeLeave:u,afterLeave:f,enter:p,enterFrom:h,enterTo:b,entered:g,leave:m,leaveFrom:v,leaveTo:w,...j}=e,[S,T]=y.useState(null),E=y.useRef(null),_=Ok(e),$=mn(..._?[E,t,T]:t===null?[]:[t]),R=(n=j.unmount)==null||n?Yr.Unmount:Yr.Hidden,{show:C,appear:O,initial:I}=VC(),[D,z]=y.useState(C?"visible":"hidden"),H=KC(),{register:F,unregister:U}=H;kt(()=>F(E),[F,E]),kt(()=>{if(R===Yr.Hidden&&E.current){if(C&&D!=="visible"){z("visible");return}return Nn(D,{hidden:()=>U(E),visible:()=>F(E)})}},[D,E,F,U,C,R]);let X=Il();kt(()=>{if(_&&X&&D==="visible"&&E.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[E,D,X,_]);let P=I&&!O,K=O&&C&&I,M=y.useRef(!1),G=Pk(()=>{M.current||(z("hidden"),U(E))},H),B=Ue(le=>{M.current=!0;let ye=le?"enter":"leave";G.onStart(E,ye,ee=>{ee==="enter"?l==null||l():ee==="leave"&&(u==null||u())})}),L=Ue(le=>{let ye=le?"enter":"leave";M.current=!1,G.onStop(E,ye,ee=>{ee==="enter"?c==null||c():ee==="leave"&&(f==null||f())}),ye==="leave"&&!Ed(G)&&(z("hidden"),U(E))});y.useEffect(()=>{_&&i||(B(C),L(C))},[C,_,i]);let q=!(!i||!_||!X||P),[,ne]=rk(q,S,C,{start:B,end:L}),oe=Vr({ref:$,className:((o=_p(j.className,K&&p,K&&h,ne.enter&&p,ne.enter&&ne.closed&&h,ne.enter&&!ne.closed&&b,ne.leave&&m,ne.leave&&!ne.closed&&v,ne.leave&&ne.closed&&w,!ne.transition&&C&&g))==null?void 0:o.trim())||void 0,...sk(ne)}),ae=0;D==="visible"&&(ae|=wn.Open),D==="hidden"&&(ae|=wn.Closed),C&&D==="hidden"&&(ae|=wn.Opening),!C&&D==="visible"&&(ae|=wn.Closing);let ce=Vt();return je.createElement(_d.Provider,{value:G},je.createElement(kk,{value:ae},ce({ourProps:oe,theirProps:j,defaultTag:Mk,features:Lk,visible:D==="visible",name:"Transition.Child"})))}function YC(e,t){let{show:n,appear:o=!1,unmount:i=!0,...l}=e,c=y.useRef(null),u=Ok(e),f=mn(...u?[c,t]:t===null?[]:[t]);Il();let p=Ll();if(n===void 0&&p!==null&&(n=(p&wn.Open)===wn.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,b]=y.useState(n?"visible":"hidden"),g=Pk(()=>{n||b("hidden")}),[m,v]=y.useState(!0),w=y.useRef([n]);kt(()=>{m!==!1&&w.current[w.current.length-1]!==n&&(w.current.push(n),v(!1))},[w,n]);let j=y.useMemo(()=>({show:n,appear:o,initial:m}),[n,o,m]);kt(()=>{n?b("visible"):!Ed(g)&&c.current!==null&&b("hidden")},[n,g]);let S={unmount:i},T=Ue(()=>{var $;m&&v(!1),($=e.beforeEnter)==null||$.call(e)}),E=Ue(()=>{var $;m&&v(!1),($=e.beforeLeave)==null||$.call(e)}),_=Vt();return je.createElement(_d.Provider,{value:g},je.createElement(Sd.Provider,{value:j},_({ourProps:{...S,as:y.Fragment,children:je.createElement(Ik,{ref:f,...S,...l,beforeEnter:T,beforeLeave:E})},theirProps:{},defaultTag:y.Fragment,features:Lk,visible:h==="visible",name:"Transition"})))}function QC(e,t){let n=y.useContext(Sd)!==null,o=Ll()!==null;return je.createElement(je.Fragment,null,!n&&o?je.createElement(Op,{ref:t,...e}):je.createElement(Ik,{ref:t,...e}))}let Op=Mt(YC),Ik=Mt(XC),Mh=Mt(QC),ZC=Object.assign(Op,{Child:Mh,Root:Op});var JC=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(JC||{}),eR=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(eR||{});let tR={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},Lh=y.createContext(null);Lh.displayName="DialogContext";function $d(e){let t=y.useContext(Lh);if(t===null){let n=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,$d),n}return t}function nR(e,t){return Nn(t.type,tR,e,t)}let Jv=Mt(function(e,t){let n=y.useId(),{id:o=`headlessui-dialog-${n}`,open:i,onClose:l,initialFocus:c,role:u="dialog",autoFocus:f=!0,__demoMode:p=!1,unmount:h=!1,...b}=e,g=y.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(g.current||(g.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let m=Ll();i===void 0&&m!==null&&(i=(m&wn.Open)===wn.Open);let v=y.useRef(null),w=mn(v,t),j=hl(v.current),S=i?0:1,[T,E]=y.useReducer(nR,{titleId:null,descriptionId:null,panelRef:y.createRef()}),_=Ue(()=>l(!1)),$=Ue(ne=>E({type:0,id:ne})),R=Il()?S===0:!1,[C,O]=RC(),I={get current(){var ne;return(ne=T.panelRef.current)!=null?ne:v.current}},D=Ck(),{resolveContainers:z}=LC({mainTreeNode:D,portals:C,defaultContainers:[I]}),H=m!==null?(m&wn.Closing)===wn.Closing:!1;V0(p||H?!1:R,{allowed:Ue(()=>{var ne,oe;return[(oe=(ne=v.current)==null?void 0:ne.closest("[data-headlessui-portal]"))!=null?oe:null]}),disallowed:Ue(()=>{var ne;return[(ne=D==null?void 0:D.closest("body > *:not(#headlessui-portal-root)"))!=null?ne:null]})});let F=yd.get(null);kt(()=>{if(R)return F.actions.push(o),()=>F.actions.pop(o)},[F,o,R]);let U=vn(F,y.useCallback(ne=>F.selectors.isTop(ne,o),[F,o]));ek(U,z,ne=>{ne.preventDefault(),_()}),PC(U,j==null?void 0:j.defaultView,ne=>{ne.preventDefault(),ne.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),_()}),nk(p||H?!1:R,j,z),K0(R,v,_);let[X,P]=e$(),K=y.useMemo(()=>[{dialogState:S,close:_,setTitleId:$,unmount:h},T],[S,_,$,h,T]),M=ws({open:S===0}),G={ref:w,id:o,role:u,tabIndex:-1,"aria-modal":p?void 0:S===0?!0:void 0,"aria-labelledby":T.titleId,"aria-describedby":X,unmount:h},B=!MC(),L=Eo.None;R&&!p&&(L|=Eo.RestoreFocus,L|=Eo.TabLock,f&&(L|=Eo.AutoFocus),B&&(L|=Eo.InitialFocus));let q=Vt();return je.createElement(wC,null,je.createElement(Qv,{force:!0},je.createElement(Ek,null,je.createElement(Lh.Provider,{value:K},je.createElement(_k,{target:v},je.createElement(Qv,{force:!1},je.createElement(P,{slot:M},je.createElement(O,null,je.createElement(UC,{initialFocus:c,initialFocusFallback:v,containers:z,features:L},je.createElement(u$,{value:_},q({ourProps:G,theirProps:b,slot:M,defaultTag:sR,features:rR,visible:S===0,name:"Dialog"})))))))))))}),sR="div",rR=Fa.RenderStrategy|Fa.Static;function oR(e,t){let{transition:n=!1,open:o,...i}=e,l=Ll(),c=e.hasOwnProperty("open")||l!==null,u=e.hasOwnProperty("onClose");if(!c&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!l&&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(o!==void 0||n)&&!i.static?je.createElement(Zv,null,je.createElement(ZC,{show:o,transition:n,unmount:i.unmount},je.createElement(Jv,{ref:t,...i}))):je.createElement(Zv,null,je.createElement(Jv,{ref:t,open:o,...i}))}let aR="div";function iR(e,t){let n=y.useId(),{id:o=`headlessui-dialog-panel-${n}`,transition:i=!1,...l}=e,[{dialogState:c,unmount:u},f]=$d("Dialog.Panel"),p=mn(t,f.panelRef),h=ws({open:c===0}),b=Ue(j=>{j.stopPropagation()}),g={ref:p,id:o,onClick:b},m=i?Mh:y.Fragment,v=i?{unmount:u}:{},w=Vt();return je.createElement(m,{...v},w({ourProps:g,theirProps:l,slot:h,defaultTag:aR,name:"Dialog.Panel"}))}let lR="div";function cR(e,t){let{transition:n=!1,...o}=e,[{dialogState:i,unmount:l}]=$d("Dialog.Backdrop"),c=ws({open:i===0}),u={ref:t,"aria-hidden":!0},f=n?Mh:y.Fragment,p=n?{unmount:l}:{},h=Vt();return je.createElement(f,{...p},h({ourProps:u,theirProps:o,slot:c,defaultTag:lR,name:"Dialog.Backdrop"}))}let uR="h2";function dR(e,t){let n=y.useId(),{id:o=`headlessui-dialog-title-${n}`,...i}=e,[{dialogState:l,setTitleId:c}]=$d("Dialog.Title"),u=mn(t);y.useEffect(()=>(c(o),()=>c(null)),[o,c]);let f=ws({open:l===0}),p={ref:u,id:o};return Vt()({ourProps:p,theirProps:i,slot:f,defaultTag:uR,name:"Dialog.Title"})}let fR=Mt(oR),zk=Mt(iR),mR=Mt(cR),Dk=Mt(dR),pR=Object.assign(fR,{Panel:zk,Title:Dk,Description:I0}),eb=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function tb(e){var t,n;let o=(t=e.innerText)!=null?t:"",i=e.cloneNode(!0);if(!Jn(i))return o;let l=!1;for(let u of i.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))u.remove(),l=!0;let c=l?(n=i.innerText)!=null?n:"":o;return eb.test(c)&&(c=c.replace(eb,"")),c}function hR(e){let t=e.getAttribute("aria-label");if(typeof t=="string")return t.trim();let n=e.getAttribute("aria-labelledby");if(n){let o=n.split(" ").map(i=>{let l=document.getElementById(i);if(l){let c=l.getAttribute("aria-label");return typeof c=="string"?c.trim():tb(l).trim()}return null}).filter(Boolean);if(o.length>0)return o.join(", ")}return tb(e).trim()}function gR(e){let t=y.useRef(""),n=y.useRef("");return Ue(()=>{let o=e.current;if(!o)return"";let i=o.innerText;if(t.current===i)return n.current;let l=hR(o).trim().toLowerCase();return t.current=i,n.current=l,l})}var xR=Object.defineProperty,yR=(e,t,n)=>t in e?xR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nb=(e,t,n)=>(yR(e,typeof t!="symbol"?t+"":t,n),n),un=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(un||{}),Qr=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Qr||{}),ju=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(ju||{}),Fk=(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))(Fk||{});function sb(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,o=Q0(t(e.options.slice()),l=>l.dataRef.current.domRef.current),i=n?o.indexOf(n):null;return i===-1&&(i=null),{options:o,activeOptionIndex:i}}let vR={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.buttonElement?ku.Tracked($k(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:_t.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:t}},0(e,t){if(e.dataRef.current.disabled||e.listboxState===0)return e;let n=e.activeOptionIndex,{isSelected:o}=e.dataRef.current,i=e.options.findIndex(l=>o(l.dataRef.current.value));return i!==-1&&(n=i),{...e,frozenValue:!1,pendingFocus:t.focus,listboxState:0,activeOptionIndex:n,__demoMode:!1,buttonPositionState:ku.Idle}},2(e,t){var n,o,i,l,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let u={...e,searchQuery:"",activationTrigger:(n=t.trigger)!=null?n:1,__demoMode:!1};if(t.focus===_t.Nothing)return{...u,activeOptionIndex:null};if(t.focus===_t.Specific)return{...u,activeOptionIndex:e.options.findIndex(h=>h.id===t.id)};if(t.focus===_t.Previous){let h=e.activeOptionIndex;if(h!==null){let b=e.options[h].dataRef.current.domRef,g=ou(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(g!==null){let m=e.options[g].dataRef.current.domRef;if(((o=b.current)==null?void 0:o.previousElementSibling)===m.current||((i=m.current)==null?void 0:i.previousElementSibling)===null)return{...u,activeOptionIndex:g}}}}else if(t.focus===_t.Next){let h=e.activeOptionIndex;if(h!==null){let b=e.options[h].dataRef.current.domRef,g=ou(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(g!==null){let m=e.options[g].dataRef.current.domRef;if(((l=b.current)==null?void 0:l.nextElementSibling)===m.current||((c=m.current)==null?void 0:c.nextElementSibling)===null)return{...u,activeOptionIndex:g}}}}let f=sb(e),p=ou(t,{resolveItems:()=>f.options,resolveActiveIndex:()=>f.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});return{...u,...f,activeOptionIndex:p}},3:(e,t)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.searchQuery!==""?0:1,o=e.searchQuery+t.value.toLowerCase(),i=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+n).concat(e.options.slice(0,e.activeOptionIndex+n)):e.options).find(c=>{var u;return!c.dataRef.current.disabled&&((u=c.dataRef.current.textValue)==null?void 0:u.startsWith(o))}),l=i?e.options.indexOf(i):-1;return l===-1||l===e.activeOptionIndex?{...e,searchQuery:o}:{...e,searchQuery:o,activeOptionIndex:l,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,t)=>{let n=e.options.concat(t.options),o=e.activeOptionIndex;if(e.pendingFocus.focus!==_t.Nothing&&(o=ou(e.pendingFocus,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:i=>i.id,resolveDisabled:i=>i.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:i}=e.dataRef.current;if(i){let l=n.findIndex(c=>i==null?void 0:i(c.dataRef.current.value));l!==-1&&(o=l)}}return{...e,options:n,activeOptionIndex:o,pendingFocus:{focus:_t.Nothing},pendingShouldSort:!0}},7:(e,t)=>{let n=e.options,o=[],i=new Set(t.options);for(let[l,c]of n.entries())if(i.has(c.id)&&(o.push(l),i.delete(c.id),i.size===0))break;if(o.length>0){n=n.slice();for(let l of o.reverse())n.splice(l,1)}return{...e,options:n,activationTrigger:1}},8:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},9:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},10:e=>e.pendingShouldSort?{...e,...sb(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:ku.Moved}}};class Ih extends H0{constructor(t){super(t),nb(this,"actions",{onChange:n=>{let{onChange:o,compare:i,mode:l,value:c}=this.state.dataRef.current;return Nn(l,{0:()=>o==null?void 0:o(n),1:()=>{let u=c.slice(),f=u.findIndex(p=>i(p,n));return f===-1?u.push(n):u.splice(f,1),o==null?void 0:o(u)}})},registerOption:Fm(()=>{let n=[],o=new Set;return[(i,l)=>{o.has(l)||(o.add(l),n.push({id:i,dataRef:l}))},()=>(o.clear(),this.send({type:6,options:n.splice(0)}))]}),unregisterOption:Fm(()=>{let n=[];return[o=>n.push(o),()=>{this.send({type:7,options:n.splice(0)})}]}),goToOption:Fm(()=>{let n=null;return[(o,i)=>{n={type:2,...o,trigger:i}},()=>n&&this.send(n)]}),closeListbox:()=>{this.send({type:1})},openListbox:n=>{this.send({type:0,focus:n})},selectActiveOption:()=>{var n;if(this.state.activeOptionIndex!==null){let{dataRef:o}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(o.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(n=this.state.buttonElement)==null||n.focus({preventScroll:!0}))},selectOption:n=>{this.send({type:5,value:n})},search:n=>{this.send({type:3,value:n})},clearSearch:()=>{this.send({type:4})},setButtonElement:n=>{this.send({type:8,element:n})},setOptionsElement:n=>{this.send({type:9,element:n})}}),nb(this,"selectors",{activeDescendantId(n){var o;let i=n.activeOptionIndex,l=n.options;return i===null||(o=l[i])==null?void 0:o.id},isActive(n,o){var i;let l=n.activeOptionIndex,c=n.options;return l!==null?((i=c[l])==null?void 0:i.id)===o:!1},hasFrozenValue(n){return n.frozenValue},shouldScrollIntoView(n,o){return n.__demoMode||n.listboxState!==0||n.activationTrigger===0?!1:this.isActive(n,o)},didButtonMove(n){return n.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let n=this.state.id,o=yd.get(null);this.disposables.add(o.on(G0.Push,i=>{!o.selectors.isTop(i,n)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>o.actions.push(n)),this.on(1,()=>o.actions.pop(n))}this.disposables.group(n=>{this.on(1,o=>{o.buttonElement&&(n.dispose(),n.add(OC(o.buttonElement,o.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(n,o)=>{var i;this.actions.onChange(o.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(i=this.state.buttonElement)==null||i.focus({preventScroll:!0}))})}static new({id:t,__demoMode:n=!1}){return new Ih({id:t,dataRef:{current:{}},listboxState:n?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:_t.Nothing},frozenValue:!1,__demoMode:n,buttonPositionState:ku.Idle})}reduce(t,n){return Nn(n.type,vR,t,n)}}const Uk=y.createContext(null);function zh(e){let t=y.useContext(Uk);if(t===null){let n=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Wk),n}return t}function Wk({id:e,__demoMode:t=!1}){let n=y.useMemo(()=>Ih.new({id:e,__demoMode:t}),[]);return Oh(()=>n.dispose()),n}let Td=y.createContext(null);Td.displayName="ListboxDataContext";function zl(e){let t=y.useContext(Td);if(t===null){let n=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,zl),n}return t}let bR=y.Fragment;function wR(e,t){let n=y.useId(),o=_h(),{value:i,defaultValue:l,form:c,name:u,onChange:f,by:p,invalid:h=!1,disabled:b=o||!1,horizontal:g=!1,multiple:m=!1,__demoMode:v=!1,...w}=e;const j=g?"horizontal":"vertical";let S=mn(t),T=IE(l),[E=m?[]:void 0,_]=LE(i,f,T),$=Wk({id:n,__demoMode:v}),R=y.useRef({static:!1,hold:!1}),C=y.useRef(new Map),O=f$(p),I=y.useCallback(q=>Nn(D.mode,{[Qr.Multi]:()=>E.some(ne=>O(ne,q)),[Qr.Single]:()=>O(E,q)}),[E]),D=ws({value:E,disabled:b,invalid:h,mode:m?Qr.Multi:Qr.Single,orientation:j,onChange:_,compare:O,isSelected:I,optionsPropsRef:R,listRef:C});kt(()=>{$.state.dataRef.current=D},[D]);let z=vn($,q=>q.listboxState),H=yd.get(null),F=vn(H,y.useCallback(q=>H.selectors.isTop(q,n),[H,n])),[U,X]=vn($,q=>[q.buttonElement,q.optionsElement]);ek(F,[U,X],(q,ne)=>{$.send({type:Fk.CloseListbox}),Y0(ne,Eh.Loose)||(q.preventDefault(),U==null||U.focus())});let P=ws({open:z===un.Open,disabled:b,invalid:h,value:E}),[K,M]=r$({inherit:!0}),G={ref:S},B=y.useCallback(()=>{if(T!==void 0)return _==null?void 0:_(T)},[_,T]),L=Vt();return je.createElement(M,{value:K,props:{htmlFor:U==null?void 0:U.id},slot:{open:z===un.Open,disabled:b}},je.createElement(xC,null,je.createElement(Uk.Provider,{value:$},je.createElement(Td.Provider,{value:D},je.createElement(kk,{value:Nn(z,{[un.Open]:wn.Open,[un.Closed]:wn.Closed})},u!=null&&E!=null&&je.createElement(BE,{disabled:b,data:{[u]:E},form:c,onReset:B}),L({ourProps:G,theirProps:w,slot:P,defaultTag:bR,name:"Listbox"}))))))}let kR="button";function jR(e,t){let n=y.useId(),o=R0(),i=zl("Listbox.Button"),l=zh("Listbox.Button"),{id:c=o||`headlessui-listbox-button-${n}`,disabled:u=i.disabled||!1,autoFocus:f=!1,...p}=e,h=mn(t,mC(),l.actions.setButtonElement),b=pC(),[g,m,v]=vn(l,X=>[X.listboxState,X.buttonElement,X.optionsElement]),w=g===un.Open;L$(w,{trigger:m,action:y.useCallback(X=>{if(m!=null&&m.contains(X.target))return su.Ignore;let P=X.target.closest('[role="option"]:not([data-disabled])');return Jn(P)?su.Select(P):v!=null&&v.contains(X.target)?su.Ignore:su.Close},[m,v]),close:l.actions.closeListbox,select:l.actions.selectActiveOption});let j=Ue(X=>{switch(X.key){case Ft.Enter:zE(X.currentTarget);break;case Ft.Space:case Ft.ArrowDown:X.preventDefault(),l.actions.openListbox({focus:i.value?_t.Nothing:_t.First});break;case Ft.ArrowUp:X.preventDefault(),l.actions.openListbox({focus:i.value?_t.Nothing:_t.Last});break}}),S=Ue(X=>{switch(X.key){case Ft.Space:X.preventDefault();break}}),T=p$(X=>{var P;l.state.listboxState===un.Open?(er.flushSync(()=>l.actions.closeListbox()),(P=l.state.buttonElement)==null||P.focus({preventScroll:!0})):(X.preventDefault(),l.actions.openListbox({focus:_t.Nothing}))}),E=Ue(X=>X.preventDefault()),_=D0([c]),$=JE(),{isFocusVisible:R,focusProps:C}=bE({autoFocus:f}),{isHovered:O,hoverProps:I}=jE({isDisabled:u}),{pressed:D,pressProps:z}=TE({disabled:u}),H=ws({open:g===un.Open,active:D||g===un.Open,disabled:u,invalid:i.invalid,value:i.value,hover:O,focus:R,autofocus:f}),F=vn(l,X=>X.listboxState===un.Open),U=_0(b(),{ref:h,id:c,type:I$(e,m),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":F,"aria-labelledby":_,"aria-describedby":$,disabled:u||void 0,autoFocus:f,onKeyDown:j,onKeyUp:S,onKeyPress:E},T,C,I,z);return Vt()({ourProps:U,theirProps:p,slot:H,defaultTag:kR,name:"Listbox.Button"})}let Hk=y.createContext(!1),NR="div",SR=Fa.RenderStrategy|Fa.Static;function _R(e,t){let n=y.useId(),{id:o=`headlessui-listbox-options-${n}`,anchor:i,portal:l=!1,modal:c=!0,transition:u=!1,...f}=e,p=fC(i),[h,b]=y.useState(null);p&&(l=!0);let g=zl("Listbox.Options"),m=zh("Listbox.Options"),[v,w,j,S]=vn(m,ce=>[ce.listboxState,ce.buttonElement,ce.optionsElement,ce.__demoMode]),T=hl(w),E=hl(j),_=Ll(),[$,R]=rk(u,h,_!==null?(_&wn.Open)===wn.Open:v===un.Open);K0($,w,m.actions.closeListbox);let C=S?!1:c&&v===un.Open;nk(C,E);let O=S?!1:c&&v===un.Open;V0(O,{allowed:y.useCallback(()=>[w,j],[w,j])});let I=vn(m,m.selectors.didButtonMove)?!1:$,D=vn(m,m.selectors.hasFrozenValue)&&!e.static,z=wk(D,g.value),H=y.useCallback(ce=>g.compare(z,ce),[g.compare,z]),F=vn(m,ce=>{var le;if(p==null||!((le=p==null?void 0:p.to)!=null&&le.includes("selection")))return null;let ye=ce.options.findIndex(ee=>H(ee.dataRef.current.value));return ye===-1&&(ye=0),ye}),U=(()=>{if(p==null)return;if(F===null)return{...p,inner:void 0};let ce=Array.from(g.listRef.current.values());return{...p,inner:{listRef:{current:ce},index:F}}})(),[X,P]=gC(U),K=hC(),M=mn(t,p?X:null,m.actions.setOptionsElement,b),G=oo();y.useEffect(()=>{let ce=j;ce&&v===un.Open&&(N0(ce)||ce==null||ce.focus({preventScroll:!0}))},[v,j]);let B=Ue(ce=>{var le;switch(G.dispose(),ce.key){case Ft.Space:if(m.state.searchQuery!=="")return ce.preventDefault(),ce.stopPropagation(),m.actions.search(ce.key);case Ft.Enter:ce.preventDefault(),ce.stopPropagation(),m.actions.selectActiveOption();break;case Nn(g.orientation,{vertical:Ft.ArrowDown,horizontal:Ft.ArrowRight}):return ce.preventDefault(),ce.stopPropagation(),m.actions.goToOption({focus:_t.Next});case Nn(g.orientation,{vertical:Ft.ArrowUp,horizontal:Ft.ArrowLeft}):return ce.preventDefault(),ce.stopPropagation(),m.actions.goToOption({focus:_t.Previous});case Ft.Home:case Ft.PageUp:return ce.preventDefault(),ce.stopPropagation(),m.actions.goToOption({focus:_t.First});case Ft.End:case Ft.PageDown:return ce.preventDefault(),ce.stopPropagation(),m.actions.goToOption({focus:_t.Last});case Ft.Escape:ce.preventDefault(),ce.stopPropagation(),er.flushSync(()=>m.actions.closeListbox()),(le=m.state.buttonElement)==null||le.focus({preventScroll:!0});return;case Ft.Tab:ce.preventDefault(),ce.stopPropagation(),er.flushSync(()=>m.actions.closeListbox()),A$(m.state.buttonElement,ce.shiftKey?Ls.Previous:Ls.Next);break;default:ce.key.length===1&&(m.actions.search(ce.key),G.setTimeout(()=>m.actions.clearSearch(),350));break}}),L=vn(m,ce=>{var le;return(le=ce.buttonElement)==null?void 0:le.id}),q=ws({open:v===un.Open}),ne=_0(p?K():{},{id:o,ref:M,"aria-activedescendant":vn(m,m.selectors.activeDescendantId),"aria-multiselectable":g.mode===Qr.Multi?!0:void 0,"aria-labelledby":L,"aria-orientation":g.orientation,onKeyDown:B,role:"listbox",tabIndex:v===un.Open?0:void 0,style:{...f.style,...P,"--button-width":m$($,w,!0).width},...sk(R)}),oe=Vt(),ae=y.useMemo(()=>g.mode===Qr.Multi?g:{...g,isSelected:H},[g,H]);return je.createElement(Ek,{enabled:l?e.static||$:!1,ownerDocument:T},je.createElement(Td.Provider,{value:ae},oe({ourProps:ne,theirProps:f,slot:q,defaultTag:NR,features:SR,visible:I,name:"Listbox.Options"})))}let ER="div";function $R(e,t){let n=y.useId(),{id:o=`headlessui-listbox-option-${n}`,disabled:i=!1,value:l,...c}=e,u=y.useContext(Hk)===!0,f=zl("Listbox.Option"),p=zh("Listbox.Option"),h=vn(p,D=>p.selectors.isActive(D,o)),b=f.isSelected(l),g=y.useRef(null),m=gR(g),v=ao({disabled:i,value:l,domRef:g,get textValue(){return m()}}),w=mn(t,g,D=>{D?f.listRef.current.set(o,D):f.listRef.current.delete(o)}),j=vn(p,D=>p.selectors.shouldScrollIntoView(D,o));kt(()=>{if(j)return ns().requestAnimationFrame(()=>{var D,z;(z=(D=g.current)==null?void 0:D.scrollIntoView)==null||z.call(D,{block:"nearest"})})},[j,g]),kt(()=>{if(!u)return p.actions.registerOption(o,v),()=>p.actions.unregisterOption(o)},[v,o,u]);let S=Ue(D=>{if(i)return D.preventDefault();p.actions.selectOption(l)}),T=Ue(()=>{if(i)return p.actions.goToOption({focus:_t.Nothing});p.actions.goToOption({focus:_t.Specific,id:o})}),E=B$(),_=Ue(D=>E.update(D)),$=Ue(D=>{E.wasMoved(D)&&(i||h&&p.state.activationTrigger===ju.Pointer||p.actions.goToOption({focus:_t.Specific,id:o},ju.Pointer))}),R=Ue(D=>{E.wasMoved(D)&&(i||h&&p.state.activationTrigger===ju.Pointer&&p.actions.goToOption({focus:_t.Nothing}))}),C=ws({active:h,focus:h,selected:b,disabled:i,selectedOption:b&&u}),O=u?{}:{id:o,ref:w,role:"option",tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":b,disabled:void 0,onClick:S,onFocus:T,onPointerEnter:_,onMouseEnter:_,onPointerMove:$,onMouseMove:$,onPointerLeave:R,onMouseLeave:R},I=Vt();return!b&&u?null:I({ourProps:O,theirProps:c,slot:C,defaultTag:ER,name:"Listbox.Option"})}let TR=y.Fragment;function CR(e,t){let{options:n,placeholder:o,...i}=e,l={ref:mn(t)},c=zl("ListboxSelectedOption"),u=ws({}),f=c.value===void 0||c.value===null||c.mode===Qr.Multi&&Array.isArray(c.value)&&c.value.length===0,p=Vt();return je.createElement(Hk.Provider,{value:!0},p({ourProps:l,theirProps:{...i,children:je.createElement(je.Fragment,null,o&&f?o:n)},slot:u,defaultTag:TR,name:"ListboxSelectedOption"}))}let RR=Mt(wR),Bk=Mt(jR),AR=l$,Gk=Mt(_R),qk=Mt($R),OR=Mt(CR),PR=Object.assign(RR,{Button:Bk,Label:AR,Options:Gk,Option:qk,SelectedOption:OR});const Dh=y.createContext(null),MR=()=>y.useContext(Dh);function Fh(e){const t=y.useContext(Dh);return{id:e.id??(t==null?void 0:t.id),"aria-describedby":e["aria-describedby"]??(t==null?void 0:t.describedBy),"aria-invalid":e["aria-invalid"]??((t==null?void 0:t.invalid)||void 0),"aria-required":e["aria-required"]??((t==null?void 0:t.required)&&!e.required||void 0)}}function Ao({label:e,id:t,required:n,optional:o,note:i,hint:l,error:c,warning:u,aside:f,group:p,className:h,children:b}){const g=y.useId(),m=t??`${g}-control`,[v,w,j,S,T]=[`${g}-label`,`${g}-note`,`${g}-hint`,`${g}-error`,`${g}-warning`],E=[i&&w,l&&j,c&&S,u&&T].filter(Boolean).join(" ")||void 0,_=s.jsxs(s.Fragment,{children:[e,n&&s.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),o&&s.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return s.jsxs("div",{className:h,...p===!0?{role:"group","aria-labelledby":v,"aria-describedby":E}:{},children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[p?s.jsx("span",{id:v,className:"caps text-small font-semibold",children:_}):s.jsx("label",{id:v,htmlFor:m,className:"caps text-small font-semibold",children:_}),f]}),i&&s.jsx("p",{id:w,className:"-mt-1 mb-2 text-small text-muted-foreground",children:i}),s.jsx(Dh.Provider,{value:p?null:{id:m,describedBy:E,invalid:!!c,required:!!n},children:b}),l&&s.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:l}),c&&s.jsx("p",{id:S,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&s.jsx("p",{id:T,className:"mt-2 font-mono text-small text-warning-text",children:u})]})}const Vk="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",Kk="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",Xk="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",He=y.forwardRef(({className:e,fieldSize:t="md",bare:n,...o},i)=>s.jsx("input",{ref:i,...o,...Fh(o),className:ie(n?Kk:ie(Vk,t==="sm"?"h-control-sm":"h-control-md"),e)}));He.displayName="Input";const Ns=y.forwardRef(({className:e,bare:t,...n},o)=>s.jsx("textarea",{ref:o,...n,...Fh(n),className:ie(t?Kk:ie(Vk,"py-2.5"),e)}));Ns.displayName="Textarea";const Yk=e=>{const t=y.forwardRef(({label:n,note:o,className:i,disabled:l,...c},u)=>s.jsxs("label",{className:ie("flex items-start gap-2.5 text-body",l?"cursor-not-allowed opacity-45":"cursor-pointer",i),children:[s.jsx("input",{ref:u,type:e,disabled:l,...c,...Fh(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block",children:n}),o&&s.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:o})]})]}));return t.displayName=e==="checkbox"?"Checkbox":"Radio",t};Yk("checkbox");Yk("radio");function qt({value:e,onChange:t,options:n,label:o,id:i,className:l,disabled:c=!1,name:u,small:f=!1,placeholder:p,autoFocus:h}){const b=n.find(m=>m.value===e),g=MR();return s.jsxs(PR,{value:e,onChange:t,disabled:c,name:u,children:[s.jsxs(Bk,{id:i??(g==null?void 0:g.id),autoFocus:h,"aria-label":o,"aria-describedby":g==null?void 0:g.describedBy,"aria-invalid":(g==null?void 0:g.invalid)||void 0,"data-value":e,className:ie("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",f?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",l),children:[s.jsx("span",{className:ie("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??p??""}),s.jsx(Wo,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),s.jsx(Gk,{anchor:"bottom start","data-picker-list":"",className:"z-popover max-h-72 w-[var(--button-width)] min-w-[12rem] overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",children:n.map(m=>s.jsxs(qk,{value:m.value,disabled:m.disabled,title:m.title,"data-value":m.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:[s.jsx(dd,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),s.jsx("span",{className:"min-w-0 break-words",children:m.label})]},m.value))})]})}const Qk=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<t.id?-1:e.id>t.id?1:0),Cd=e=>[...e].sort((t,n)=>Qk({name:t.definition.name||t.agent_id,id:t.agent_id},{name:n.definition.name||n.agent_id,id:n.agent_id}));/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:Zk,setPrototypeOf:rb,isFrozen:LR,getPrototypeOf:IR,getOwnPropertyDescriptor:zR}=Object;let{freeze:Sn,seal:ks,create:Jk}=Object,{apply:Pp,construct:Mp}=typeof Reflect<"u"&&Reflect;Sn||(Sn=function(t){return t});ks||(ks=function(t){return t});Pp||(Pp=function(t,n,o){return t.apply(n,o)});Mp||(Mp=function(t,n){return new t(...n)});const au=es(Array.prototype.forEach),ob=es(Array.prototype.pop),Wi=es(Array.prototype.push),Nu=es(String.prototype.toLowerCase),Xm=es(String.prototype.toString),ab=es(String.prototype.match),Hi=es(String.prototype.replace),DR=es(String.prototype.indexOf),FR=es(String.prototype.trim),Ms=es(Object.prototype.hasOwnProperty),yn=es(RegExp.prototype.test),Bi=UR(TypeError);function es(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return Pp(e,t,o)}}function UR(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return Mp(e,n)}}function Ze(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nu;rb&&rb(e,null);let o=t.length;for(;o--;){let i=t[o];if(typeof i=="string"){const l=n(i);l!==i&&(LR(t)||(t[o]=l),i=l)}e[i]=!0}return e}function WR(e){for(let t=0;t<e.length;t++)Ms(e,t)||(e[t]=null);return e}function _o(e){const t=Jk(null);for(const[n,o]of Zk(e))Ms(e,n)&&(Array.isArray(o)?t[n]=WR(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=_o(o):t[n]=o);return t}function Gi(e,t){for(;e!==null;){const o=zR(e,t);if(o){if(o.get)return es(o.get);if(typeof o.value=="function")return es(o.value)}e=IR(e)}function n(){return null}return n}const ib=Sn(["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"]),Ym=Sn(["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"]),Qm=Sn(["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"]),HR=Sn(["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"]),Zm=Sn(["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"]),BR=Sn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lb=Sn(["#text"]),cb=Sn(["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"]),Jm=Sn(["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"]),ub=Sn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),iu=Sn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),GR=ks(/\{\{[\w\W]*|[\w\W]*\}\}/gm),qR=ks(/<%[\w\W]*|[\w\W]*%>/gm),VR=ks(/\$\{[\w\W]*}/gm),KR=ks(/^data-[\-\w.\u00B7-\uFFFF]+$/),XR=ks(/^aria-[\-\w]+$/),e1=ks(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),YR=ks(/^(?:\w+script|data):/i),QR=ks(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),t1=ks(/^html$/i),ZR=ks(/^[a-z][.\w]*(-[.\w]+)+$/i);var db=Object.freeze({__proto__:null,ARIA_ATTR:XR,ATTR_WHITESPACE:QR,CUSTOM_ELEMENT:ZR,DATA_ATTR:KR,DOCTYPE_NAME:t1,ERB_EXPR:qR,IS_ALLOWED_URI:e1,IS_SCRIPT_OR_DATA:YR,MUSTACHE_EXPR:GR,TMPLIT_EXPR:VR});const qi={element:1,text:3,progressingInstruction:7,comment:8,document:9},JR=function(){return typeof window>"u"?null:window},e3=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(o=n.getAttribute(i));const l="dompurify"+(o?"#"+o:"");try{return t.createPolicy(l,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+l+" could not be created."),null}},fb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function n1(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:JR();const t=Ae=>n1(Ae);if(t.version="3.2.3",t.removed=[],!e||!e.document||e.document.nodeType!==qi.document)return t.isSupported=!1,t;let{document:n}=e;const o=n,i=o.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:u,Element:f,NodeFilter:p,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:b,DOMParser:g,trustedTypes:m}=e,v=f.prototype,w=Gi(v,"cloneNode"),j=Gi(v,"remove"),S=Gi(v,"nextSibling"),T=Gi(v,"childNodes"),E=Gi(v,"parentNode");if(typeof c=="function"){const Ae=n.createElement("template");Ae.content&&Ae.content.ownerDocument&&(n=Ae.content.ownerDocument)}let _,$="";const{implementation:R,createNodeIterator:C,createDocumentFragment:O,getElementsByTagName:I}=n,{importNode:D}=o;let z=fb();t.isSupported=typeof Zk=="function"&&typeof E=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:H,ERB_EXPR:F,TMPLIT_EXPR:U,DATA_ATTR:X,ARIA_ATTR:P,IS_SCRIPT_OR_DATA:K,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:G}=db;let{IS_ALLOWED_URI:B}=db,L=null;const q=Ze({},[...ib,...Ym,...Qm,...Zm,...lb]);let ne=null;const oe=Ze({},[...cb,...Jm,...ub,...iu]);let ae=Object.seal(Jk(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}})),ce=null,le=null,ye=!0,ee=!0,be=!1,Oe=!0,We=!1,fe=!0,Re=!1,Xe=!1,Kt=!1,De=!1,et=!1,Ut=!1,Wt=!0,jt=!1;const ss="user-content-";let hn=!0,Xt=!1,at={},ct=null;const Me=Ze({},["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 Le=null;const At=Ze({},["audio","video","img","source","image","track"]);let ut=null;const Lt=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),En="http://www.w3.org/1998/Math/MathML",$n="http://www.w3.org/2000/svg",Yt="http://www.w3.org/1999/xhtml";let Wn=Yt,rs=!1,os=null;const Tn=Ze({},[En,$n,Yt],Xm);let Hn=Ze({},["mi","mo","mn","ms","mtext"]),Bn=Ze({},["annotation-xml"]);const J=Ze({},["title","style","font","a","script"]);let we=null;const Ge=["application/xhtml+xml","text/html"],dt="text/html";let Ke=null,Nt=null;const nn=n.createElement("form"),yt=function(Y){return Y instanceof RegExp||Y instanceof Function},Ws=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Nt&&Nt===Y)){if((!Y||typeof Y!="object")&&(Y={}),Y=_o(Y),we=Ge.indexOf(Y.PARSER_MEDIA_TYPE)===-1?dt:Y.PARSER_MEDIA_TYPE,Ke=we==="application/xhtml+xml"?Xm:Nu,L=Ms(Y,"ALLOWED_TAGS")?Ze({},Y.ALLOWED_TAGS,Ke):q,ne=Ms(Y,"ALLOWED_ATTR")?Ze({},Y.ALLOWED_ATTR,Ke):oe,os=Ms(Y,"ALLOWED_NAMESPACES")?Ze({},Y.ALLOWED_NAMESPACES,Xm):Tn,ut=Ms(Y,"ADD_URI_SAFE_ATTR")?Ze(_o(Lt),Y.ADD_URI_SAFE_ATTR,Ke):Lt,Le=Ms(Y,"ADD_DATA_URI_TAGS")?Ze(_o(At),Y.ADD_DATA_URI_TAGS,Ke):At,ct=Ms(Y,"FORBID_CONTENTS")?Ze({},Y.FORBID_CONTENTS,Ke):Me,ce=Ms(Y,"FORBID_TAGS")?Ze({},Y.FORBID_TAGS,Ke):{},le=Ms(Y,"FORBID_ATTR")?Ze({},Y.FORBID_ATTR,Ke):{},at=Ms(Y,"USE_PROFILES")?Y.USE_PROFILES:!1,ye=Y.ALLOW_ARIA_ATTR!==!1,ee=Y.ALLOW_DATA_ATTR!==!1,be=Y.ALLOW_UNKNOWN_PROTOCOLS||!1,Oe=Y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,We=Y.SAFE_FOR_TEMPLATES||!1,fe=Y.SAFE_FOR_XML!==!1,Re=Y.WHOLE_DOCUMENT||!1,De=Y.RETURN_DOM||!1,et=Y.RETURN_DOM_FRAGMENT||!1,Ut=Y.RETURN_TRUSTED_TYPE||!1,Kt=Y.FORCE_BODY||!1,Wt=Y.SANITIZE_DOM!==!1,jt=Y.SANITIZE_NAMED_PROPS||!1,hn=Y.KEEP_CONTENT!==!1,Xt=Y.IN_PLACE||!1,B=Y.ALLOWED_URI_REGEXP||e1,Wn=Y.NAMESPACE||Yt,Hn=Y.MATHML_TEXT_INTEGRATION_POINTS||Hn,Bn=Y.HTML_INTEGRATION_POINTS||Bn,ae=Y.CUSTOM_ELEMENT_HANDLING||{},Y.CUSTOM_ELEMENT_HANDLING&&yt(Y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ae.tagNameCheck=Y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Y.CUSTOM_ELEMENT_HANDLING&&yt(Y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ae.attributeNameCheck=Y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Y.CUSTOM_ELEMENT_HANDLING&&typeof Y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ae.allowCustomizedBuiltInElements=Y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),We&&(ee=!1),et&&(De=!0),at&&(L=Ze({},lb),ne=[],at.html===!0&&(Ze(L,ib),Ze(ne,cb)),at.svg===!0&&(Ze(L,Ym),Ze(ne,Jm),Ze(ne,iu)),at.svgFilters===!0&&(Ze(L,Qm),Ze(ne,Jm),Ze(ne,iu)),at.mathMl===!0&&(Ze(L,Zm),Ze(ne,ub),Ze(ne,iu))),Y.ADD_TAGS&&(L===q&&(L=_o(L)),Ze(L,Y.ADD_TAGS,Ke)),Y.ADD_ATTR&&(ne===oe&&(ne=_o(ne)),Ze(ne,Y.ADD_ATTR,Ke)),Y.ADD_URI_SAFE_ATTR&&Ze(ut,Y.ADD_URI_SAFE_ATTR,Ke),Y.FORBID_CONTENTS&&(ct===Me&&(ct=_o(ct)),Ze(ct,Y.FORBID_CONTENTS,Ke)),hn&&(L["#text"]=!0),Re&&Ze(L,["html","head","body"]),L.table&&(Ze(L,["tbody"]),delete ce.tbody),Y.TRUSTED_TYPES_POLICY){if(typeof Y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');_=Y.TRUSTED_TYPES_POLICY,$=_.createHTML("")}else _===void 0&&(_=e3(m,i)),_!==null&&typeof $=="string"&&($=_.createHTML(""));Sn&&Sn(Y),Nt=Y}},sn=Ze({},[...Ym,...Qm,...HR]),_s=Ze({},[...Zm,...BR]),Cn=function(Y){let pe=E(Y);(!pe||!pe.tagName)&&(pe={namespaceURI:Wn,tagName:"template"});const Ne=Nu(Y.tagName),it=Nu(pe.tagName);return os[Y.namespaceURI]?Y.namespaceURI===$n?pe.namespaceURI===Yt?Ne==="svg":pe.namespaceURI===En?Ne==="svg"&&(it==="annotation-xml"||Hn[it]):!!sn[Ne]:Y.namespaceURI===En?pe.namespaceURI===Yt?Ne==="math":pe.namespaceURI===$n?Ne==="math"&&Bn[it]:!!_s[Ne]:Y.namespaceURI===Yt?pe.namespaceURI===$n&&!Bn[it]||pe.namespaceURI===En&&!Hn[it]?!1:!_s[Ne]&&(J[Ne]||!sn[Ne]):!!(we==="application/xhtml+xml"&&os[Y.namespaceURI]):!1},Rn=function(Y){Wi(t.removed,{element:Y});try{E(Y).removeChild(Y)}catch{j(Y)}},as=function(Y,pe){try{Wi(t.removed,{attribute:pe.getAttributeNode(Y),from:pe})}catch{Wi(t.removed,{attribute:null,from:pe})}if(pe.removeAttribute(Y),Y==="is")if(De||et)try{Rn(pe)}catch{}else try{pe.setAttribute(Y,"")}catch{}},sr=function(Y){let pe=null,Ne=null;if(Kt)Y="<remove></remove>"+Y;else{const Be=ab(Y,/^[\r\n\t ]+/);Ne=Be&&Be[0]}we==="application/xhtml+xml"&&Wn===Yt&&(Y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Y+"</body></html>");const it=_?_.createHTML(Y):Y;if(Wn===Yt)try{pe=new g().parseFromString(it,we)}catch{}if(!pe||!pe.documentElement){pe=R.createDocument(Wn,"template",null);try{pe.documentElement.innerHTML=rs?$:it}catch{}}const Et=pe.body||pe.documentElement;return Y&&Ne&&Et.insertBefore(n.createTextNode(Ne),Et.childNodes[0]||null),Wn===Yt?I.call(pe,Re?"html":"body")[0]:Re?pe.documentElement:Et},rr=function(Y){return C.call(Y.ownerDocument||Y,Y,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Hs=function(Y){return Y instanceof b&&(typeof Y.nodeName!="string"||typeof Y.textContent!="string"||typeof Y.removeChild!="function"||!(Y.attributes instanceof h)||typeof Y.removeAttribute!="function"||typeof Y.setAttribute!="function"||typeof Y.namespaceURI!="string"||typeof Y.insertBefore!="function"||typeof Y.hasChildNodes!="function")},Ko=function(Y){return typeof u=="function"&&Y instanceof u};function An(Ae,Y,pe){au(Ae,Ne=>{Ne.call(t,Y,pe,Nt)})}const lo=function(Y){let pe=null;if(An(z.beforeSanitizeElements,Y,null),Hs(Y))return Rn(Y),!0;const Ne=Ke(Y.nodeName);if(An(z.uponSanitizeElement,Y,{tagName:Ne,allowedTags:L}),Y.hasChildNodes()&&!Ko(Y.firstElementChild)&&yn(/<[/\w]/g,Y.innerHTML)&&yn(/<[/\w]/g,Y.textContent)||Y.nodeType===qi.progressingInstruction||fe&&Y.nodeType===qi.comment&&yn(/<[/\w]/g,Y.data))return Rn(Y),!0;if(!L[Ne]||ce[Ne]){if(!ce[Ne]&&or(Ne)&&(ae.tagNameCheck instanceof RegExp&&yn(ae.tagNameCheck,Ne)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(Ne)))return!1;if(hn&&!ct[Ne]){const it=E(Y)||Y.parentNode,Et=T(Y)||Y.childNodes;if(Et&&it){const Be=Et.length;for(let It=Be-1;It>=0;--It){const Qt=w(Et[It],!0);Qt.__removalCount=(Y.__removalCount||0)+1,it.insertBefore(Qt,S(Y))}}}return Rn(Y),!0}return Y instanceof f&&!Cn(Y)||(Ne==="noscript"||Ne==="noembed"||Ne==="noframes")&&yn(/<\/no(script|embed|frames)/i,Y.innerHTML)?(Rn(Y),!0):(We&&Y.nodeType===qi.text&&(pe=Y.textContent,au([H,F,U],it=>{pe=Hi(pe,it," ")}),Y.textContent!==pe&&(Wi(t.removed,{element:Y.cloneNode()}),Y.textContent=pe)),An(z.afterSanitizeElements,Y,null),!1)},Gn=function(Y,pe,Ne){if(Wt&&(pe==="id"||pe==="name")&&(Ne in n||Ne in nn))return!1;if(!(ee&&!le[pe]&&yn(X,pe))){if(!(ye&&yn(P,pe))){if(!ne[pe]||le[pe]){if(!(or(Y)&&(ae.tagNameCheck instanceof RegExp&&yn(ae.tagNameCheck,Y)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(Y))&&(ae.attributeNameCheck instanceof RegExp&&yn(ae.attributeNameCheck,pe)||ae.attributeNameCheck instanceof Function&&ae.attributeNameCheck(pe))||pe==="is"&&ae.allowCustomizedBuiltInElements&&(ae.tagNameCheck instanceof RegExp&&yn(ae.tagNameCheck,Ne)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(Ne))))return!1}else if(!ut[pe]){if(!yn(B,Hi(Ne,M,""))){if(!((pe==="src"||pe==="xlink:href"||pe==="href")&&Y!=="script"&&DR(Ne,"data:")===0&&Le[Y])){if(!(be&&!yn(K,Hi(Ne,M,"")))){if(Ne)return!1}}}}}}return!0},or=function(Y){return Y!=="annotation-xml"&&ab(Y,G)},jr=function(Y){An(z.beforeSanitizeAttributes,Y,null);const{attributes:pe}=Y;if(!pe||Hs(Y))return;const Ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let it=pe.length;for(;it--;){const Et=pe[it],{name:Be,namespaceURI:It,value:Qt}=Et,Es=Ke(Be);let vt=Be==="value"?Qt:FR(Qt);if(Ne.attrName=Es,Ne.attrValue=vt,Ne.keepAttr=!0,Ne.forceKeepAttr=void 0,An(z.uponSanitizeAttribute,Y,Ne),vt=Ne.attrValue,jt&&(Es==="id"||Es==="name")&&(as(Be,Y),vt=ss+vt),fe&&yn(/((--!?|])>)|<\/(style|title)/i,vt)){as(Be,Y);continue}if(Ne.forceKeepAttr||(as(Be,Y),!Ne.keepAttr))continue;if(!Oe&&yn(/\/>/i,vt)){as(Be,Y);continue}We&&au([H,F,U],Nr=>{vt=Hi(vt,Nr," ")});const co=Ke(Y.nodeName);if(Gn(co,Es,vt)){if(_&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!It)switch(m.getAttributeType(co,Es)){case"TrustedHTML":{vt=_.createHTML(vt);break}case"TrustedScriptURL":{vt=_.createScriptURL(vt);break}}try{It?Y.setAttributeNS(It,Be,vt):Y.setAttribute(Be,vt),Hs(Y)?Rn(Y):ob(t.removed)}catch{}}}An(z.afterSanitizeAttributes,Y,null)},Xo=function Ae(Y){let pe=null;const Ne=rr(Y);for(An(z.beforeSanitizeShadowDOM,Y,null);pe=Ne.nextNode();)An(z.uponSanitizeShadowNode,pe,null),lo(pe),jr(pe),pe.content instanceof l&&Ae(pe.content);An(z.afterSanitizeShadowDOM,Y,null)};return t.sanitize=function(Ae){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},pe=null,Ne=null,it=null,Et=null;if(rs=!Ae,rs&&(Ae="<!-->"),typeof Ae!="string"&&!Ko(Ae))if(typeof Ae.toString=="function"){if(Ae=Ae.toString(),typeof Ae!="string")throw Bi("dirty is not a string, aborting")}else throw Bi("toString is not a function");if(!t.isSupported)return Ae;if(Xe||Ws(Y),t.removed=[],typeof Ae=="string"&&(Xt=!1),Xt){if(Ae.nodeName){const Qt=Ke(Ae.nodeName);if(!L[Qt]||ce[Qt])throw Bi("root node is forbidden and cannot be sanitized in-place")}}else if(Ae instanceof u)pe=sr("<!---->"),Ne=pe.ownerDocument.importNode(Ae,!0),Ne.nodeType===qi.element&&Ne.nodeName==="BODY"||Ne.nodeName==="HTML"?pe=Ne:pe.appendChild(Ne);else{if(!De&&!We&&!Re&&Ae.indexOf("<")===-1)return _&&Ut?_.createHTML(Ae):Ae;if(pe=sr(Ae),!pe)return De?null:Ut?$:""}pe&&Kt&&Rn(pe.firstChild);const Be=rr(Xt?Ae:pe);for(;it=Be.nextNode();)lo(it),jr(it),it.content instanceof l&&Xo(it.content);if(Xt)return Ae;if(De){if(et)for(Et=O.call(pe.ownerDocument);pe.firstChild;)Et.appendChild(pe.firstChild);else Et=pe;return(ne.shadowroot||ne.shadowrootmode)&&(Et=D.call(o,Et,!0)),Et}let It=Re?pe.outerHTML:pe.innerHTML;return Re&&L["!doctype"]&&pe.ownerDocument&&pe.ownerDocument.doctype&&pe.ownerDocument.doctype.name&&yn(t1,pe.ownerDocument.doctype.name)&&(It="<!DOCTYPE "+pe.ownerDocument.doctype.name+`>
453
+ `+It),We&&au([H,F,U],Qt=>{It=Hi(It,Qt," ")}),_&&Ut?_.createHTML(It):It},t.setConfig=function(){let Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ws(Ae),Xe=!0},t.clearConfig=function(){Nt=null,Xe=!1},t.isValidAttribute=function(Ae,Y,pe){Nt||Ws({});const Ne=Ke(Ae),it=Ke(Y);return Gn(Ne,it,pe)},t.addHook=function(Ae,Y){typeof Y=="function"&&Wi(z[Ae],Y)},t.removeHook=function(Ae){return ob(z[Ae])},t.removeHooks=function(Ae){z[Ae]=[]},t.removeAllHooks=function(){z=fb()},t}var Su=n1();function Uh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Go=Uh();function s1(e){Go=e}const al={exec:()=>null};function lt(e,t=""){let n=typeof e=="string"?e:e.source;const o={replace:(i,l)=>{let c=typeof l=="string"?l:l.source;return c=c.replace(kn.caret,"$1"),n=n.replace(i,c),o},getRegex:()=>new RegExp(n,t)};return o}const kn={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")},t3=/^(?:[ \t]*(?:\n|$))+/,n3=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,s3=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Dl=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,r3=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,r1=/(?:[*+-]|\d{1,9}[.)])/,o1=lt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,r1).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(),Wh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,o3=/^[^\n]+/,Hh=/(?!\s*\])(?:\\.|[^\[\]\\])+/,a3=lt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Hh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),i3=lt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,r1).getRegex(),Rd="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",Bh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,l3=lt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bh).replace("tag",Rd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),a1=lt(Wh).replace("hr",Dl).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",Rd).getRegex(),c3=lt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",a1).getRegex(),Gh={blockquote:c3,code:n3,def:a3,fences:s3,heading:r3,hr:Dl,html:l3,lheading:o1,list:i3,newline:t3,paragraph:a1,table:al,text:o3},mb=lt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Dl).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",Rd).getRegex(),u3={...Gh,table:mb,paragraph:lt(Wh).replace("hr",Dl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",mb).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",Rd).getRegex()},d3={...Gh,html:lt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bh).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:al,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:lt(Wh).replace("hr",Dl).replace("heading",` *#{1,6} *[^
454
+ ]`).replace("lheading",o1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},f3=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,m3=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,i1=/^( {2,}|\\)\n(?!\s*$)/,p3=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ad=/[\p{P}\p{S}]/u,qh=/[\s\p{P}\p{S}]/u,l1=/[^\s\p{P}\p{S}]/u,h3=lt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,qh).getRegex(),c1=/(?!~)[\p{P}\p{S}]/u,g3=/(?!~)[\s\p{P}\p{S}]/u,x3=/(?:[^\s\p{P}\p{S}]|~)/u,y3=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,u1=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,v3=lt(u1,"u").replace(/punct/g,Ad).getRegex(),b3=lt(u1,"u").replace(/punct/g,c1).getRegex(),d1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",w3=lt(d1,"gu").replace(/notPunctSpace/g,l1).replace(/punctSpace/g,qh).replace(/punct/g,Ad).getRegex(),k3=lt(d1,"gu").replace(/notPunctSpace/g,x3).replace(/punctSpace/g,g3).replace(/punct/g,c1).getRegex(),j3=lt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,l1).replace(/punctSpace/g,qh).replace(/punct/g,Ad).getRegex(),N3=lt(/\\(punct)/,"gu").replace(/punct/g,Ad).getRegex(),S3=lt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),_3=lt(Bh).replace("(?:-->|$)","-->").getRegex(),E3=lt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",_3).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zu=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,$3=lt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",zu).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),f1=lt(/^!?\[(label)\]\[(ref)\]/).replace("label",zu).replace("ref",Hh).getRegex(),m1=lt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Hh).getRegex(),T3=lt("reflink|nolink(?!\\()","g").replace("reflink",f1).replace("nolink",m1).getRegex(),Vh={_backpedal:al,anyPunctuation:N3,autolink:S3,blockSkip:y3,br:i1,code:m3,del:al,emStrongLDelim:v3,emStrongRDelimAst:w3,emStrongRDelimUnd:j3,escape:f3,link:$3,nolink:m1,punctuation:h3,reflink:f1,reflinkSearch:T3,tag:E3,text:p3,url:al},C3={...Vh,link:lt(/^!?\[(label)\]\((.*?)\)/).replace("label",zu).getRegex(),reflink:lt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",zu).getRegex()},Lp={...Vh,emStrongRDelimAst:k3,emStrongLDelim:b3,url:lt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},R3={...Lp,br:lt(i1).replace("{2,}","*").getRegex(),text:lt(Lp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},lu={normal:Gh,gfm:u3,pedantic:d3},Vi={normal:Vh,gfm:Lp,breaks:R3,pedantic:C3},A3={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pb=e=>A3[e];function Xs(e,t){if(t){if(kn.escapeTest.test(e))return e.replace(kn.escapeReplace,pb)}else if(kn.escapeTestNoEncode.test(e))return e.replace(kn.escapeReplaceNoEncode,pb);return e}function hb(e){try{e=encodeURI(e).replace(kn.percentDecode,"%")}catch{return null}return e}function gb(e,t){var l;const n=e.replace(kn.findPipe,(c,u,f)=>{let p=!1,h=u;for(;--h>=0&&f[h]==="\\";)p=!p;return p?"|":" |"}),o=n.split(kn.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!((l=o.at(-1))!=null&&l.trim())&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(kn.slashPipe,"|");return o}function Ki(e,t,n){const o=e.length;if(o===0)return"";let i=0;for(;i<o&&e.charAt(o-i-1)===t;)i++;return e.slice(0,o-i)}function O3(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<e.length;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])n++;else if(e[o]===t[1]&&(n--,n<0))return o;return-1}function xb(e,t,n,o,i){const l=t.href,c=t.title||null,u=e[1].replace(i.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){o.state.inLink=!0;const f={type:"link",raw:n,href:l,title:c,text:u,tokens:o.inlineTokens(u)};return o.state.inLink=!1,f}return{type:"image",raw:n,href:l,title:c,text:u}}function P3(e,t,n){const o=e.match(n.other.indentCodeCompensation);if(o===null)return t;const i=o[1];return t.split(`
455
+ `).map(l=>{const c=l.match(n.other.beginningSpace);if(c===null)return l;const[u]=c;return u.length>=i.length?l.slice(i.length):l}).join(`
456
+ `)}class Du{constructor(t){rt(this,"options");rt(this,"rules");rt(this,"lexer");this.options=t||Go}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const o=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?o:Ki(o,`
457
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const o=n[0],i=P3(o,n[3]||"",this.rules);return{type:"code",raw:o,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:i}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let o=n[2].trim();if(this.rules.other.endingHash.test(o)){const i=Ki(o,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(o=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:Ki(n[0],`
458
+ `)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let o=Ki(n[0],`
459
+ `).split(`
460
+ `),i="",l="";const c=[];for(;o.length>0;){let u=!1;const f=[];let p;for(p=0;p<o.length;p++)if(this.rules.other.blockquoteStart.test(o[p]))f.push(o[p]),u=!0;else if(!u)f.push(o[p]);else break;o=o.slice(p);const h=f.join(`
461
+ `),b=h.replace(this.rules.other.blockquoteSetextReplace,`
462
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
463
+ ${h}`:h,l=l?`${l}
464
+ ${b}`:b;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(b,c,!0),this.lexer.state.top=g,o.length===0)break;const m=c.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const v=m,w=v.raw+`
465
+ `+o.join(`
466
+ `),j=this.blockquote(w);c[c.length-1]=j,i=i.substring(0,i.length-v.raw.length)+j.raw,l=l.substring(0,l.length-v.text.length)+j.text;break}else if((m==null?void 0:m.type)==="list"){const v=m,w=v.raw+`
467
+ `+o.join(`
468
+ `),j=this.list(w);c[c.length-1]=j,i=i.substring(0,i.length-m.raw.length)+j.raw,l=l.substring(0,l.length-v.raw.length)+j.raw,o=w.substring(c.at(-1).raw.length).split(`
469
+ `);continue}}return{type:"blockquote",raw:i,tokens:c,text:l}}}list(t){let n=this.rules.block.list.exec(t);if(n){let o=n[1].trim();const i=o.length>1,l={type:"list",raw:"",ordered:i,start:i?+o.slice(0,-1):"",loose:!1,items:[]};o=i?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=i?o:"[*+-]");const c=this.rules.other.listItemRegex(o);let u=!1;for(;t;){let p=!1,h="",b="";if(!(n=c.exec(t))||this.rules.block.hr.test(t))break;h=n[0],t=t.substring(h.length);let g=n[2].split(`
470
+ `,1)[0].replace(this.rules.other.listReplaceTabs,T=>" ".repeat(3*T.length)),m=t.split(`
471
+ `,1)[0],v=!g.trim(),w=0;if(this.options.pedantic?(w=2,b=g.trimStart()):v?w=n[1].length+1:(w=n[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,b=g.slice(w),w+=n[1].length),v&&this.rules.other.blankLine.test(m)&&(h+=m+`
472
+ `,t=t.substring(m.length+1),p=!0),!p){const T=this.rules.other.nextBulletRegex(w),E=this.rules.other.hrRegex(w),_=this.rules.other.fencesBeginRegex(w),$=this.rules.other.headingBeginRegex(w),R=this.rules.other.htmlBeginRegex(w);for(;t;){const C=t.split(`
473
+ `,1)[0];let O;if(m=C,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),O=m):O=m.replace(this.rules.other.tabCharGlobal," "),_.test(m)||$.test(m)||R.test(m)||T.test(m)||E.test(m))break;if(O.search(this.rules.other.nonSpaceChar)>=w||!m.trim())b+=`
474
+ `+O.slice(w);else{if(v||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(g)||$.test(g)||E.test(g))break;b+=`
475
+ `+m}!v&&!m.trim()&&(v=!0),h+=C+`
476
+ `,t=t.substring(C.length+1),g=O.slice(w)}}l.loose||(u?l.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(u=!0));let j=null,S;this.options.gfm&&(j=this.rules.other.listIsTask.exec(b),j&&(S=j[0]!=="[ ] ",b=b.replace(this.rules.other.listReplaceTask,""))),l.items.push({type:"list_item",raw:h,task:!!j,checked:S,loose:!1,text:b,tokens:[]}),l.raw+=h}const f=l.items.at(-1);if(f)f.raw=f.raw.trimEnd(),f.text=f.text.trimEnd();else return;l.raw=l.raw.trimEnd();for(let p=0;p<l.items.length;p++)if(this.lexer.state.top=!1,l.items[p].tokens=this.lexer.blockTokens(l.items[p].text,[]),!l.loose){const h=l.items[p].tokens.filter(g=>g.type==="space"),b=h.length>0&&h.some(g=>this.rules.other.anyLine.test(g.raw));l.loose=b}if(l.loose)for(let p=0;p<l.items.length;p++)l.items[p].loose=!0;return l}}html(t){const n=this.rules.block.html.exec(t);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(t){const n=this.rules.block.def.exec(t);if(n){const o=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:o,raw:n[0],href:i,title:l}}}table(t){var u;const n=this.rules.block.table.exec(t);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;const o=gb(n[1]),i=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),l=(u=n[3])!=null&&u.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split(`
477
+ `):[],c={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===i.length){for(const f of i)this.rules.other.tableAlignRight.test(f)?c.align.push("right"):this.rules.other.tableAlignCenter.test(f)?c.align.push("center"):this.rules.other.tableAlignLeft.test(f)?c.align.push("left"):c.align.push(null);for(let f=0;f<o.length;f++)c.header.push({text:o[f],tokens:this.lexer.inline(o[f]),header:!0,align:c.align[f]});for(const f of l)c.rows.push(gb(f,c.header.length).map((p,h)=>({text:p,tokens:this.lexer.inline(p),header:!1,align:c.align[h]})));return c}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const o=n[1].charAt(n[1].length-1)===`
478
+ `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:o,tokens:this.lexer.inline(o)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const o=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(o)){if(!this.rules.other.endAngleBracket.test(o))return;const c=Ki(o.slice(0,-1),"\\");if((o.length-c.length)%2===0)return}else{const c=O3(n[2],"()");if(c>-1){const f=(n[0].indexOf("!")===0?5:4)+n[1].length+c;n[2]=n[2].substring(0,c),n[0]=n[0].substring(0,f).trim(),n[3]=""}}let i=n[2],l="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(i);c&&(i=c[1],l=c[3])}else l=n[3]?n[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(o)?i=i.slice(1):i=i.slice(1,-1)),xb(n,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(t,n){let o;if((o=this.rules.inline.reflink.exec(t))||(o=this.rules.inline.nolink.exec(t))){const i=(o[2]||o[1]).replace(this.rules.other.multipleSpaceGlobal," "),l=n[i.toLowerCase()];if(!l){const c=o[0].charAt(0);return{type:"text",raw:c,text:c}}return xb(o,l,o[0],this.lexer,this.rules)}}emStrong(t,n,o=""){let i=this.rules.inline.emStrongLDelim.exec(t);if(!i||i[3]&&o.match(this.rules.other.unicodeAlphaNumeric))return;if(!(i[1]||i[2]||"")||!o||this.rules.inline.punctuation.exec(o)){const c=[...i[0]].length-1;let u,f,p=c,h=0;const b=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,n=n.slice(-1*t.length+c);(i=b.exec(n))!=null;){if(u=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!u)continue;if(f=[...u].length,i[3]||i[4]){p+=f;continue}else if((i[5]||i[6])&&c%3&&!((c+f)%3)){h+=f;continue}if(p-=f,p>0)continue;f=Math.min(f,f+p+h);const g=[...i[0]][0].length,m=t.slice(0,c+i.index+g+f);if(Math.min(c,f)%2){const w=m.slice(1,-1);return{type:"em",raw:m,text:w,tokens:this.lexer.inlineTokens(w)}}const v=m.slice(2,-2);return{type:"strong",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let o=n[2].replace(this.rules.other.newLineCharGlobal," ");const i=this.rules.other.nonSpaceChar.test(o),l=this.rules.other.startingSpaceChar.test(o)&&this.rules.other.endingSpaceChar.test(o);return i&&l&&(o=o.substring(1,o.length-1)),{type:"codespan",raw:n[0],text:o}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t){const n=this.rules.inline.autolink.exec(t);if(n){let o,i;return n[2]==="@"?(o=n[1],i="mailto:"+o):(o=n[1],i=o),{type:"link",raw:n[0],text:o,href:i,tokens:[{type:"text",raw:o,text:o}]}}}url(t){var o;let n;if(n=this.rules.inline.url.exec(t)){let i,l;if(n[2]==="@")i=n[0],l="mailto:"+i;else{let c;do c=n[0],n[0]=((o=this.rules.inline._backpedal.exec(n[0]))==null?void 0:o[0])??"";while(c!==n[0]);i=n[0],n[1]==="www."?l="http://"+n[0]:l=n[0]}return{type:"link",raw:n[0],text:i,href:l,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(t){const n=this.rules.inline.text.exec(t);if(n){const o=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:o}}}}class hs{constructor(t){rt(this,"tokens");rt(this,"options");rt(this,"state");rt(this,"tokenizer");rt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Go,this.options.tokenizer=this.options.tokenizer||new Du,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 n={other:kn,block:lu.normal,inline:Vi.normal};this.options.pedantic?(n.block=lu.pedantic,n.inline=Vi.pedantic):this.options.gfm&&(n.block=lu.gfm,this.options.breaks?n.inline=Vi.breaks:n.inline=Vi.gfm),this.tokenizer.rules=n}static get rules(){return{block:lu,inline:Vi}}static lex(t,n){return new hs(n).lex(t)}static lexInline(t,n){return new hs(n).inlineTokens(t)}lex(t){t=t.replace(kn.carriageReturn,`
479
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],o=!1){var i,l,c;for(this.options.pedantic&&(t=t.replace(kn.tabCharGlobal," ").replace(kn.spaceLine,""));t;){let u;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.some(p=>(u=p.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);const p=n.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
480
+ `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);const p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
481
+ `+u.raw,p.text+=`
482
+ `+u.text,this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);const p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
483
+ `+u.raw,p.text+=`
484
+ `+u.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title});continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let f=t;if((c=this.options.extensions)!=null&&c.startBlock){let p=1/0;const h=t.slice(1);let b;this.options.extensions.startBlock.forEach(g=>{b=g.call({lexer:this},h),typeof b=="number"&&b>=0&&(p=Math.min(p,b))}),p<1/0&&p>=0&&(f=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(f))){const p=n.at(-1);o&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=`
485
+ `+u.raw,p.text+=`
486
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u),o=f.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);const p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=`
487
+ `+u.raw,p.text+=`
488
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,f,p;let o=t,i=null;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)h.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,i.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let l=!1,c="";for(;t;){l||(c=""),l=!1;let h;if((f=(u=this.options.extensions)==null?void 0:u.inline)!=null&&f.some(g=>(h=g.call({lexer:this},t,n))?(t=t.substring(h.raw.length),n.push(h),!0):!1))continue;if(h=this.tokenizer.escape(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.tag(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.link(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(h.raw.length);const g=n.at(-1);h.type==="text"&&(g==null?void 0:g.type)==="text"?(g.raw+=h.raw,g.text+=h.text):n.push(h);continue}if(h=this.tokenizer.emStrong(t,o,c)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.codespan(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.br(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.del(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.autolink(t)){t=t.substring(h.raw.length),n.push(h);continue}if(!this.state.inLink&&(h=this.tokenizer.url(t))){t=t.substring(h.raw.length),n.push(h);continue}let b=t;if((p=this.options.extensions)!=null&&p.startInline){let g=1/0;const m=t.slice(1);let v;this.options.extensions.startInline.forEach(w=>{v=w.call({lexer:this},m),typeof v=="number"&&v>=0&&(g=Math.min(g,v))}),g<1/0&&g>=0&&(b=t.substring(0,g+1))}if(h=this.tokenizer.inlineText(b)){t=t.substring(h.raw.length),h.raw.slice(-1)!=="_"&&(c=h.raw.slice(-1)),l=!0;const g=n.at(-1);(g==null?void 0:g.type)==="text"?(g.raw+=h.raw,g.text+=h.text):n.push(h);continue}if(t){const g="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(g);break}else throw new Error(g)}}return n}}class Fu{constructor(t){rt(this,"options");rt(this,"parser");this.options=t||Go}space(t){return""}code({text:t,lang:n,escaped:o}){var c;const i=(c=(n||"").match(kn.notSpaceStart))==null?void 0:c[0],l=t.replace(kn.endingNewline,"")+`
489
+ `;return i?'<pre><code class="language-'+Xs(i)+'">'+(o?l:Xs(l,!0))+`</code></pre>
490
+ `:"<pre><code>"+(o?l:Xs(l,!0))+`</code></pre>
491
+ `}blockquote({tokens:t}){return`<blockquote>
492
+ ${this.parser.parse(t)}</blockquote>
493
+ `}html({text:t}){return t}heading({tokens:t,depth:n}){return`<h${n}>${this.parser.parseInline(t)}</h${n}>
494
+ `}hr(t){return`<hr>
495
+ `}list(t){const n=t.ordered,o=t.start;let i="";for(let u=0;u<t.items.length;u++){const f=t.items[u];i+=this.listitem(f)}const l=n?"ol":"ul",c=n&&o!==1?' start="'+o+'"':"";return"<"+l+c+`>
496
+ `+i+"</"+l+`>
497
+ `}listitem(t){var o;let n="";if(t.task){const i=this.checkbox({checked:!!t.checked});t.loose?((o=t.tokens[0])==null?void 0:o.type)==="paragraph"?(t.tokens[0].text=i+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=i+" "+Xs(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:i+" ",text:i+" ",escaped:!0}):n+=i+" "}return n+=this.parser.parse(t.tokens,!!t.loose),`<li>${n}</li>
498
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
499
+ `}table(t){let n="",o="";for(let l=0;l<t.header.length;l++)o+=this.tablecell(t.header[l]);n+=this.tablerow({text:o});let i="";for(let l=0;l<t.rows.length;l++){const c=t.rows[l];o="";for(let u=0;u<c.length;u++)o+=this.tablecell(c[u]);i+=this.tablerow({text:o})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
500
+ <thead>
501
+ `+n+`</thead>
502
+ `+i+`</table>
503
+ `}tablerow({text:t}){return`<tr>
504
+ ${t}</tr>
505
+ `}tablecell(t){const n=this.parser.parseInline(t.tokens),o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+n+`</${o}>
506
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Xs(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const i=this.parser.parseInline(o),l=hb(t);if(l===null)return i;t=l;let c='<a href="'+t+'"';return n&&(c+=' title="'+Xs(n)+'"'),c+=">"+i+"</a>",c}image({href:t,title:n,text:o}){const i=hb(t);if(i===null)return Xs(o);t=i;let l=`<img src="${t}" alt="${o}"`;return n&&(l+=` title="${Xs(n)}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Xs(t.text)}}class Kh{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class gs{constructor(t){rt(this,"options");rt(this,"renderer");rt(this,"textRenderer");this.options=t||Go,this.options.renderer=this.options.renderer||new Fu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kh}static parse(t,n){return new gs(n).parse(t)}static parseInline(t,n){return new gs(n).parseInline(t)}parse(t,n=!0){var i,l;let o="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&l[u.type]){const p=u,h=this.options.extensions.renderers[p.type].call({parser:this},p);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type)){o+=h||"";continue}}const f=u;switch(f.type){case"space":{o+=this.renderer.space(f);continue}case"hr":{o+=this.renderer.hr(f);continue}case"heading":{o+=this.renderer.heading(f);continue}case"code":{o+=this.renderer.code(f);continue}case"table":{o+=this.renderer.table(f);continue}case"blockquote":{o+=this.renderer.blockquote(f);continue}case"list":{o+=this.renderer.list(f);continue}case"html":{o+=this.renderer.html(f);continue}case"paragraph":{o+=this.renderer.paragraph(f);continue}case"text":{let p=f,h=this.renderer.text(p);for(;c+1<t.length&&t[c+1].type==="text";)p=t[++c],h+=`
507
+ `+this.renderer.text(p);n?o+=this.renderer.paragraph({type:"paragraph",raw:h,text:h,tokens:[{type:"text",raw:h,text:h,escaped:!0}]}):o+=h;continue}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return o}parseInline(t,n=this.renderer){var i,l;let o="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&l[u.type]){const p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){o+=p||"";continue}}const f=u;switch(f.type){case"escape":{o+=n.text(f);break}case"html":{o+=n.html(f);break}case"link":{o+=n.link(f);break}case"image":{o+=n.image(f);break}case"strong":{o+=n.strong(f);break}case"em":{o+=n.em(f);break}case"codespan":{o+=n.codespan(f);break}case"br":{o+=n.br(f);break}case"del":{o+=n.del(f);break}case"text":{o+=n.text(f);break}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return o}}class il{constructor(t){rt(this,"options");rt(this,"block");this.options=t||Go}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?hs.lex:hs.lexInline}provideParser(){return this.block?gs.parse:gs.parseInline}}rt(il,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class M3{constructor(...t){rt(this,"defaults",Uh());rt(this,"options",this.setOptions);rt(this,"parse",this.parseMarkdown(!0));rt(this,"parseInline",this.parseMarkdown(!1));rt(this,"Parser",gs);rt(this,"Renderer",Fu);rt(this,"TextRenderer",Kh);rt(this,"Lexer",hs);rt(this,"Tokenizer",Du);rt(this,"Hooks",il);this.use(...t)}walkTokens(t,n){var i,l;let o=[];for(const c of t)switch(o=o.concat(n.call(this,c)),c.type){case"table":{const u=c;for(const f of u.header)o=o.concat(this.walkTokens(f.tokens,n));for(const f of u.rows)for(const p of f)o=o.concat(this.walkTokens(p.tokens,n));break}case"list":{const u=c;o=o.concat(this.walkTokens(u.items,n));break}default:{const u=c;(l=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&l[u.type]?this.defaults.extensions.childTokens[u.type].forEach(f=>{const p=u[f].flat(1/0);o=o.concat(this.walkTokens(p,n))}):u.tokens&&(o=o.concat(this.walkTokens(u.tokens,n)))}}return o}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(o=>{const i={...o};if(i.async=this.defaults.async||i.async||!1,o.extensions&&(o.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const c=n.renderers[l.name];c?n.renderers[l.name]=function(...u){let f=l.renderer.apply(this,u);return f===!1&&(f=c.apply(this,u)),f}:n.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=n[l.level];c?c.unshift(l.tokenizer):n[l.level]=[l.tokenizer],l.start&&(l.level==="block"?n.startBlock?n.startBlock.push(l.start):n.startBlock=[l.start]:l.level==="inline"&&(n.startInline?n.startInline.push(l.start):n.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(n.childTokens[l.name]=l.childTokens)}),i.extensions=n),o.renderer){const l=this.defaults.renderer||new Fu(this.defaults);for(const c in o.renderer){if(!(c in l))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const u=c,f=o.renderer[u],p=l[u];l[u]=(...h)=>{let b=f.apply(l,h);return b===!1&&(b=p.apply(l,h)),b||""}}i.renderer=l}if(o.tokenizer){const l=this.defaults.tokenizer||new Du(this.defaults);for(const c in o.tokenizer){if(!(c in l))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const u=c,f=o.tokenizer[u],p=l[u];l[u]=(...h)=>{let b=f.apply(l,h);return b===!1&&(b=p.apply(l,h)),b}}i.tokenizer=l}if(o.hooks){const l=this.defaults.hooks||new il;for(const c in o.hooks){if(!(c in l))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const u=c,f=o.hooks[u],p=l[u];il.passThroughHooks.has(c)?l[u]=h=>{if(this.defaults.async)return Promise.resolve(f.call(l,h)).then(g=>p.call(l,g));const b=f.call(l,h);return p.call(l,b)}:l[u]=(...h)=>{let b=f.apply(l,h);return b===!1&&(b=p.apply(l,h)),b}}i.hooks=l}if(o.walkTokens){const l=this.defaults.walkTokens,c=o.walkTokens;i.walkTokens=function(u){let f=[];return f.push(c.call(this,u)),l&&(f=f.concat(l.call(this,u))),f}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return hs.lex(t,n??this.defaults)}parser(t,n){return gs.parse(t,n??this.defaults)}parseMarkdown(t){return(o,i)=>{const l={...i},c={...this.defaults,...l},u=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&l.async===!1)return u(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 o>"u"||o===null)return u(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return u(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=t);const f=c.hooks?c.hooks.provideLexer():t?hs.lex:hs.lexInline,p=c.hooks?c.hooks.provideParser():t?gs.parse:gs.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(o):o).then(h=>f(h,c)).then(h=>c.hooks?c.hooks.processAllTokens(h):h).then(h=>c.walkTokens?Promise.all(this.walkTokens(h,c.walkTokens)).then(()=>h):h).then(h=>p(h,c)).then(h=>c.hooks?c.hooks.postprocess(h):h).catch(u);try{c.hooks&&(o=c.hooks.preprocess(o));let h=f(o,c);c.hooks&&(h=c.hooks.processAllTokens(h)),c.walkTokens&&this.walkTokens(h,c.walkTokens);let b=p(h,c);return c.hooks&&(b=c.hooks.postprocess(b)),b}catch(h){return u(h)}}}onError(t,n){return o=>{if(o.message+=`
508
+ Please report this to https://github.com/markedjs/marked.`,t){const i="<p>An error occurred:</p><pre>"+Xs(o.message+"",!0)+"</pre>";return n?Promise.resolve(i):i}if(n)return Promise.reject(o);throw o}}}const Do=new M3;function ot(e,t){return Do.parse(e,t)}ot.options=ot.setOptions=function(e){return Do.setOptions(e),ot.defaults=Do.defaults,s1(ot.defaults),ot};ot.getDefaults=Uh;ot.defaults=Go;ot.use=function(...e){return Do.use(...e),ot.defaults=Do.defaults,s1(ot.defaults),ot};ot.walkTokens=function(e,t){return Do.walkTokens(e,t)};ot.parseInline=Do.parseInline;ot.Parser=gs;ot.parser=gs.parse;ot.Renderer=Fu;ot.TextRenderer=Kh;ot.Lexer=hs;ot.lexer=hs.lex;ot.Tokenizer=Du;ot.Hooks=il;ot.parse=ot;ot.options;ot.setOptions;ot.use;ot.walkTokens;ot.parseInline;gs.parse;hs.lex;let Xi;const L3=e=>(Xi||(Su.addHook("uponSanitizeElement",(t,n)=>{Xi??(Xi=n.allowedTags)}),Su.sanitize("<b></b>"),Su.removeHook("uponSanitizeElement")),(Xi==null?void 0:Xi[e.toLowerCase()])===!0),I3=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");ot.use({breaks:!0,renderer:{html:({text:e,block:t})=>{let n=0;const o=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(i,l)=>L3(l)?(n++,i):I3(i));return t&&!n&&o!==e?`<p>${o.trim().replace(/\n/g,`<br>
509
+ `)}</p>
510
+ `:o}}});const Fl=e=>e.slice(-8),Od=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),Rt=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Wa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const p1=e=>e.basis==="estimate",Xh=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,yb=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[t,n=""]=e.toFixed(4).split(".");return`$${t}.${n.replace(/0+$/,"").padEnd(2,"0")}`},ti=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,z3=(e,{ended:t=!1}={})=>`The charges priced${t?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,D3=new Set(["completed","failed","cancelled"]),vl=e=>typeof e=="string"&&D3.has(e);function so(e,{ended:t=!1}={}){const n=ti(e),o=i=>p1(i)?" est.":"";return n?t?`${yb(n.so_far_usd)}${o(n)} known · ${n.unpriced} not priced`:`so far ${yb(n.so_far_usd)}${o(n)} · ${n.unpriced} not priced`:!e||e.usd===null?"Unknown":`${Xh(e.usd)}${o(e)}`}function vb(e,t,{ended:n=!1,text:o}={}){const i=o??so(e,{ended:n});return typeof t!="number"?i:(o!==void 0?F3.test(o):!ti(e)&&!!e&&e.usd!==null)?`${i} of ${bb(t)}`:`${i} · cap ${bb(t)}`}const F3=/^<?\$[\d.,]+( est\.)?$/;function bb(e){for(let t=2;t<8;t++)if(Number(e.toFixed(t))===e)return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}function U3(e,t){if(e.startsWith("/")||e.startsWith("#"))return null;const n=t.from?`${t.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const o=decodeURIComponent(new URL(e,`file:///${n}`).pathname.slice(1));return t.paths.includes(o)?o:null}catch{return null}}function Ha(e,t){const n=Su.sanitize(ot.parse(e,{async:!1}),{RETURN_DOM:!0});for(const o of[...n.querySelectorAll("a[href]")]){const i=o.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(i)){o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(i))continue;const l=t&&U3(i,t);if(l){const c=o.ownerDocument.createElement("button");c.type="button",c.title=`Open ${l}`,c.dataset.runFile=l,c.append(...o.childNodes),o.replaceWith(c)}else o.replaceWith(...o.childNodes)}return n.innerHTML}const h1=e=>t=>{var o,i,l;const n=(l=(i=(o=t.target).closest)==null?void 0:i.call(o,"[data-run-file]"))==null?void 0:l.getAttribute("data-run-file");n&&(t.preventDefault(),e(n))},W3=e=>{const t=n=>{var o;return(o=new RegExp(`\\b${n}="([^"]*)"`).exec(e))==null?void 0:o[1]};return t("scheme")==="github"||t("source")==="github"?"A GitHub event":t("source")==="webhook"?"A webhook request":"A trigger's request"};function tn(e){const{title:t}=e;if(!e.trigger)return t;let n=t.search(/<trigger-payload\b/);if(n<0){const i=/<([a-z-]*)…$/.exec(t);if(!i||!"trigger-payload".startsWith(i[1]))return t;n=i.index}return t.slice(0,n).trim()||W3(t.slice(n))}function H3(e){return e.usd===null?{total:"Unknown"}:{total:so({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Yh=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Oa=864e5,Ip=e=>Math.floor(e/Oa)*Oa;function Qh(e,t=Date.now()){var o;const n=(o=Yh.find(i=>i.id===e))==null?void 0:o.days;return n?new Date(Ip(t)-(n-1)*Oa).toISOString():void 0}const g1=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function B3(e){return[`${e.completed-e.needs_review} completed`,`${e.failed} failed`,e.needs_review?`${e.needs_review} ${e.needs_review===1?"needs":"need"} review`:""].filter(Boolean).join(" · ")}function G3(e){const t=e.input+e.cache_read+e.cache_write;return t?e.cache_read/t:null}const x1=(e,t)=>H3({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Zh=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Fo(e){if(e<1e4)return e.toLocaleString("en-US");const[t,n]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${t<100?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}${n}`}const Uu=e=>e===null?"—":`${Math.round(e*100)}%`;function wb(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function q3(e,t,n=Date.now()){if(!e.length)return[];const o=Ip(n),i=Math.max(o-29*Oa,t?Ip(Date.parse(t)):o-29*Oa),l=new Map(e.map(u=>[u.day,u])),c=[];for(let u=i;u<=o;u+=Oa){const f=new Date(u).toISOString().slice(0,10);c.push(l.get(f)??{day:f,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return c}function V3(e,t){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(n=>({agentId:n.agent_id,name:n.name,runs:n.runs})).sort((n,o)=>Qk({name:n.name,id:n.agentId},{name:o.name,id:o.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:t,analytics:e.analytics}}function y1({range:e,onRange:t,agent:n,agents:o,onAgent:i}){return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(Q_,{label:"Range",name:"mission-range",value:e,onChange:t,options:Yh.map(l=>({value:l.id,label:l.label}))}),i&&o.length>0&&s.jsx(qt,{label:"Agent",value:n??"",onChange:l=>i(l||null),className:"h-[38px] w-56",options:[{value:"",label:"All agents"},...o.map(l=>({value:l.agentId,label:l.name}))]})]})}const _u=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function v1({a:e,basis:t,now:n=Date.now(),refreshing:o=!1}){const i=e.totals,l=G3(i),c=g1(i),u=x1(i),f=[{label:"Tokens",value:Fo(i.tokens),notes:[`${l===null?"":`${Uu(l)} of input cached · `}${Fo(i.output)} output`,Zh(i),i.unmetered?`${_u(i.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:wb(e.time.wall_ms),notes:[`wall time of ${_u(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${wb(e.time.active_ms)} active, over ${_u(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Uu(c),notes:[i.completed+i.failed?B3(i):"No run completed or failed yet"]},{label:"Cost",value:u.total,notes:[u.note]}];return s.jsxs("div",{className:ie("space-y-6 transition-opacity",o&&"opacity-60"),"aria-busy":o,children:[s.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:f.map(p=>s.jsxs("li",{className:"border p-4",children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:p.label}),s.jsx("p",{className:"mt-2 font-mono text-xl font-semibold",children:p.value}),p.notes.filter(Boolean).map(h=>s.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:h},h))]},p.label))}),s.jsx(Q3,{days:q3(e.by_day,e.filter.from,n)}),s.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[s.jsx(K3,{rows:e.by_harness_effort,basis:t}),s.jsx(X3,{tools:e.tools})]}),s.jsx(Y3,{groups:e.by_source})]})}function Wu({title:e,children:t}){return s.jsxs("section",{className:"border",children:[s.jsx("h3",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}const b1="px-4 py-2 text-left font-normal",Ys="px-4 py-2.5 align-top";function K3({rows:e,basis:t}){return s.jsx(Wu,{title:"Success by harness and effort",children:e.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full border-collapse text-body",children:[s.jsx("thead",{children:s.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(n=>s.jsx("th",{className:b1,children:n},n))})}),s.jsx("tbody",{children:e.map(n=>{const o=x1(n),i=Zh(n);return s.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[s.jsx("td",{className:Ys,children:n.harness}),s.jsx("td",{className:ie(Ys,!n.effort&&"text-muted-foreground"),children:n.effort??"unset"}),s.jsx("td",{className:Ys,children:n.runs}),s.jsx("td",{className:Ys,children:Uu(g1(n))}),s.jsxs("td",{className:Ys,children:[s.jsx("span",{className:"whitespace-nowrap",children:Fo(n.tokens)}),i&&s.jsx("span",{className:"block text-label text-muted-foreground",children:i})]}),s.jsxs("td",{className:Ys,children:[s.jsx("span",{className:"whitespace-nowrap",children:o.total}),o.note&&s.jsx("span",{className:"block text-label text-muted-foreground",children:o.note})]})]},`${n.harness}:${n.effort??""}`)})})]})}):s.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function X3({tools:e}){return s.jsx(Wu,{title:"Top tools",children:e.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full border-collapse text-body",children:[s.jsx("thead",{children:s.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(t=>s.jsx("th",{className:b1,children:t},t))})}),s.jsx("tbody",{children:e.map(t=>s.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[s.jsx("td",{className:Ys,title:t.tool,children:t.label}),s.jsx("td",{className:Ys,children:Fo(t.calls)}),s.jsx("td",{className:ie(Ys,t.errors>0&&"text-destructive-text"),children:Fo(t.errors)}),s.jsx("td",{className:Ys,children:Uu(t.calls?t.errors/t.calls:null)})]},t.tool))})]})}):s.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 Y3({groups:e}){return e.some(t=>t.source!=="live"&&t.runs>0)?s.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(t=>`${t.source==="live"?"Run here":`Imported from ${t.source}`}: ${_u(t.runs,"run")}`).join(" · ")}):null}const ep=e=>Math.max(0,e.runs-e.completed-e.failed);function kb(e){if(e<=0)return 1;const t=10**Math.floor(Math.log10(e));return[1,2,5,10].map(n=>n*t).find(n=>n>=e)}const tp=e=>e.slice(5);function Q3({days:e}){if(!e.some(l=>l.runs>0))return s.jsx(Wu,{title:"Per day",children:s.jsxs("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})});const n=kb(Math.max(...e.map(l=>l.runs))),o=kb(Math.max(...e.map(l=>l.tokens))),i=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:l=>l.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:l=>l.failed},{key:"other",label:"Other",className:"bg-border-strong",of:ep}];return s.jsxs(Wu,{title:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`,children:[s.jsxs("div",{className:"grid grid-cols-1 gap-6 p-4 xl:grid-cols-2",children:[s.jsxs("figure",{children:[s.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[s.jsx("span",{className:"font-semibold",children:"Runs"}),i.map(l=>s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx("span",{className:ie("inline-block size-2.5",l.className),"aria-hidden":!0}),l.label]},l.key))]}),s.jsx(jb,{days:e,top:n,label:"Runs per day",stack:l=>i.map(c=>({className:c.className,value:c.of(l)})),readout:l=>[`${l.runs} ${l.runs===1?"run":"runs"}`,`${l.completed} completed · ${l.failed} failed · ${ep(l)} other`]})]}),s.jsxs("figure",{children:[s.jsx("figcaption",{className:"mb-2 text-small font-semibold",children:"Tokens"}),s.jsx(jb,{days:e,top:o,label:"Tokens per day",format:Fo,stack:l=>[{className:"bg-primary",value:l.tokens}],readout:l=>[`${Fo(l.tokens)} tokens`,Zh(l)??`${l.runs} ${l.runs===1?"run":"runs"}`]})]})]}),s.jsxs("details",{className:"border-t px-4 py-2",children:[s.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[s.jsx("thead",{children:s.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(l=>s.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:l},l))})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"py-0.5 pr-4",children:l.day}),s.jsx("td",{className:"pr-4",children:l.runs}),s.jsx("td",{className:"pr-4",children:l.completed}),s.jsx("td",{className:"pr-4",children:l.failed}),s.jsx("td",{className:"pr-4",children:ep(l)}),s.jsx("td",{className:"pr-4",children:l.tokens.toLocaleString("en-US")})]},l.day))})]})})]})]})}function jb({days:e,top:t,label:n,stack:o,readout:i,format:l=c=>c.toLocaleString("en-US")}){return s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx("span",{children:l(t)}),s.jsx("span",{children:l(t/2)}),s.jsx("span",{children:"0"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":n,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map(u=>{const f=o(u).filter(p=>p.value>0);return s.jsxs("div",{role:"listitem",tabIndex:0,"aria-label":`${u.day}: ${i(u).join(", ")}`,className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end outline-none hover:bg-accent/60 focus-visible:bg-accent/60",children:[s.jsx("div",{className:"flex w-full max-w-[24px] flex-col-reverse gap-[2px]",children:f.map((p,h)=>s.jsx("div",{className:ie(p.className,h===f.length-1&&""),style:{height:Math.max(1,Math.round(p.value/t*(140-2*(f.length-1))))}},h))}),s.jsxs("div",{className:"pointer-events-none absolute bottom-full left-1/2 z-raised mb-1 hidden -translate-x-1/2 whitespace-nowrap border bg-card px-2 py-1 text-left font-mono text-label shadow-float group-hover:block group-focus-visible:block",children:[s.jsx("span",{className:"block font-semibold",children:i(u)[0]}),i(u).slice(1).map(p=>s.jsx("span",{className:"block text-muted-foreground",children:p},p)),s.jsx("span",{className:"block text-muted-foreground",children:u.day})]})]},u.day)})]}),s.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[s.jsx("span",{children:tp(e[0].day)}),e.length>2&&s.jsx("span",{children:tp(e[Math.floor(e.length/2)].day)}),s.jsx("span",{children:tp(e.at(-1).day)})]})]})]})}function Z3(e,t){if(t.unchanged&&!t.reset&&!t.drop.length&&!t.rows.length)return e;const n=new Map;if(!t.reset)for(const o of e)n.set(o.id,o);for(const o of t.drop)n.delete(o);for(const o of t.rows)n.set(o.id,o);return[...n.values()].sort((o,i)=>o.seq-i.seq)}const w1=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,k1=e=>e.tool_status==="failed"||e.kind==="error",J3=e=>e.paused===!0;function e4(e){const t=new Map(e.filter(p=>p.kind==="tool_result"&&p.tool_use_id).map(p=>[p.tool_use_id,p])),n=new Set(e.filter(p=>p.kind==="tool_use"&&p.tool_use_id).map(p=>p.tool_use_id)),o=new Set(e.filter(p=>p.kind==="waiting"&&p.id.endsWith(":waiting")).map(p=>p.id.slice(0,-8))),i=p=>{var h;return o.has(p.id)||(p.tool_use_id?o.has(((h=t.get(p.tool_use_id))==null?void 0:h.id)??""):!1)},l=e.findLast(p=>p.kind==="usage"),c=[],u=new Map;let f;for(const p of e){if(p.kind==="usage")continue;if(p.tool_name==="ask_person"&&(p.kind==="tool_use"||p.kind==="tool_result")&&i(p)){f=void 0;continue}if(p.kind==="tool_result"&&p.tool_use_id&&n.has(p.tool_use_id)){f=u.get(p.tool_use_id);continue}if(p.kind==="phase"&&p.path&&f&&(f.row.kind==="tool_result"||f.row.kind==="tool_use")&&!f.saved){f.saved=p.path;continue}const h=c.at(-1);if(p.kind==="error"&&(h==null?void 0:h.row.kind)==="error"&&h.row.summary===p.summary&&h.row.text===p.text&&(h.row.agent_label??null)===(p.agent_label??null)){h.times=(h.times??1)+1,h.until=p.timestamp,f=h;continue}let b;const g=p.kind==="tool_use"&&p.tool_use_id?t.get(p.tool_use_id):void 0;if(g){const m=g.tool_status!=="failed",v=[p.tool_input_preview,g.tool_result_preview].filter(Boolean),w=g.tool_status!==null;b={row:{...g,id:p.id,seq:p.seq,timestamp:p.timestamp,summary:m?(g.summary??"").replace(/:\s*ok$/i,""):g.summary},...w?{ms:Math.max(0,Date.parse(g.timestamp)-Date.parse(p.timestamp))}:{},detail:v.length===2?`${v[0]}
511
+
512
+ → ${v[1]}`:v[0]??null}}else b={row:p};c.push(b),p.kind==="tool_use"&&p.tool_use_id&&u.set(p.tool_use_id,b),f=b}return l&&c.push({row:l}),c}class Te extends Error{constructor(n,o,i,l=!1,c){super(i);rt(this,"fields");rt(this,"retryAfterMs");rt(this,"details");rt(this,"problems");this.status=n,this.code=o,this.retryable=l,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const jn=e=>e instanceof Te?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),Nb=(e,t,{status:n,archived:o}={})=>{const i=new URLSearchParams({limit:String(e)});return t&&i.set("cursor",t),n&&i.set("status",n),o&&i.set("archived","true"),`?${i}`},t4=new Set(["/auth/sign-in","/setup"]);function n4({fetch:e=globalThis.fetch.bind(globalThis),base:t="/v2",onSignedOut:n}={}){async function o(m,v,w={}){return(await i(m,v,w)).body}async function i(m,v,{body:w,headers:j={},signal:S,text:T=!1}={}){var R;const E=w!==void 0||m!=="GET"&&m!=="HEAD",_=await e(`${t}${v}`,{method:m,signal:S,credentials:"same-origin",headers:{accept:"application/json",...E?{"content-type":"application/json"}:{},...j},body:w===void 0?void 0:JSON.stringify(w)});if(!_.ok){_.status===401&&!t4.has(v)&&(n==null||n());const C=(R=await _.json().catch(()=>null))==null?void 0:R.error,O=new Te(_.status,(C==null?void 0:C.code)??"http_error",(C==null?void 0:C.message)??`${m} ${v}: ${_.status}`,(C==null?void 0:C.retryable)??!1,C==null?void 0:C.request_id);throw C!=null&&C.fields&&(O.fields=C.fields),typeof(C==null?void 0:C.retry_after_ms)=="number"&&(O.retryAfterMs=C.retry_after_ms),C!=null&&C.details&&typeof C.details=="object"&&!Array.isArray(C.details)&&(O.details=C.details),Array.isArray(C==null?void 0:C.problems)&&(O.problems=C.problems),O}return{body:!T&&(_.headers.get("content-type")??"").includes("json")?await _.json():await _.text(),etag:_.headers.get("etag"),status:_.status}}const l=m=>`/agents/${encodeURIComponent(m)}`,c=m=>`/runs/${encodeURIComponent(m)}`,u=m=>`/settings/mcp-servers/${encodeURIComponent(m)}`,f=m=>`/triggers/${encodeURIComponent(m)}`,p=new Map,h=(m,v)=>`${l(m)}/learning/files/${encodeURIComponent(v)}`,b=m=>({note:m.body,etag:m.etag}),g={accept:"text/markdown, application/json"};return{capabilities:()=>o("GET","/capabilities"),session:()=>i("GET","/auth/session").then(m=>({status:m.status,body:m.body})),signIn:m=>o("POST","/auth/sign-in",{body:{password:m}}),setup:(m,v,w=!1)=>o("POST","/setup",{body:{password:m,...v?{code:v}:{},...w?{import:!0}:{}}}),setupImport:()=>o("GET","/setup/import").then(m=>(m==null?void 0:m.offer)===!1?null:m,m=>{if(m instanceof Te&&(m.status===404||m.status===403))return null;throw m}),signOut:()=>o("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>o("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>o("GET","/stats"),listRuns:(m=50,v,w)=>o("GET",`/runs${Nb(m,v,w)}`),listAgentRuns:(m,v=50,w,j={})=>o("GET",`${l(m)}/runs${Nb(v,w,typeof j=="boolean"?{archived:j}:j)}`),listAgents:({archived:m=!1,cursor:v}={})=>{const w=new URLSearchParams;return m&&w.set("archived","true"),v&&w.set("cursor",v),o("GET",`/agents${w.size?`?${w}`:""}`)},getAgent:async m=>{const v=await i("GET",l(m)),w=p.get(m);return{agent:w&&w.revision===v.body.revision&&!v.body.warnings?{...v.body,warnings:w.warnings}:v.body,etag:v.etag}},createAgent:async m=>{var w;const v=await o("POST","/agents",{body:m});return(w=v.warnings)!=null&&w.length&&p.set(v.agent_id,{revision:v.revision,warnings:v.warnings}),v},updateDefinition:async(m,v,w)=>{const j=await i("PUT",`${l(m)}/definition`,{body:v,headers:w?{"if-match":w}:{}});return p.delete(m),{agent:j.body,etag:j.etag}},listRevisions:(m,v)=>o("GET",`${l(m)}/revisions${v?`?cursor=${encodeURIComponent(v)}`:""}`),setCurrent:async(m,v)=>{const w=await o("POST",`${l(m)}/current`,{body:{revision:v}});return p.delete(m),w},archiveAgent:m=>o("POST",`${l(m)}/archive`,{body:{}}),unarchiveAgent:m=>o("POST",`${l(m)}/unarchive`,{body:{}}),agentLearning:m=>o("GET",`${l(m)}/learning`),learningNotes:(m,v)=>o("GET",`${l(m)}/learning/notes?cursor=${encodeURIComponent(v)}`),learningLog:(m,v)=>o("GET",`${l(m)}/learning/log?cursor=${encodeURIComponent(v)}`),readNote:async(m,v)=>b(await i("GET",h(m,v),{headers:g,text:!0})),writeNote:async(m,v,w,j)=>b(await i("PUT",h(m,v),{body:{text:w},headers:{...g,..."etag"in j?{"if-match":j.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(m,v,w)=>b(await i("POST",`${h(m,v)}/retire`,{body:{},headers:{...g,"if-match":w},text:!0})),approveNote:async(m,v,w)=>b(await i("POST",`${h(m,v)}/approve`,{body:{},headers:{...g,"if-match":w},text:!0})),restoreNote:async(m,v,w)=>b(await i("POST",`${h(m,v)}/restore`,{body:{},headers:{...g,"if-match":w},text:!0})),promoteWorkflow:async(m,v,w)=>{var S;const j=await o("POST",`${l(m)}/learning/workflows/${encodeURIComponent(v)}/promote`,{body:{},headers:{"idempotency-key":w}});return(S=j.warnings)!=null&&S.length&&p.set(j.agent_id,{revision:j.revision,warnings:j.warnings}),j},getRun:m=>o("GET",c(m)),runLearningDiff:m=>o("GET",`${c(m)}/learning/diff`),runLearning:m=>o("GET",`${c(m)}/learning`),runComputer:m=>o("GET",`${c(m)}/computer`),takeOverComputer:m=>o("POST",`${c(m)}/computer/take-over`,{body:{}}),handBackComputer:(m,v)=>o("POST",`${c(m)}/computer/hand-back`,{body:v?{outcome:v}:{}}),archiveRun:m=>o("POST",`${c(m)}/archive`,{body:{}}),unarchiveRun:m=>o("POST",`${c(m)}/unarchive`,{body:{}}),raiseCap:(m,v)=>o("PATCH",c(m),{body:{max_cost_usd:v}}),startRun:async(m,v,w)=>{const j=await i("POST",`${l(m)}/runs`,{body:v,headers:{"idempotency-key":w}});return{run:j.body,status:j.status}},getTimeline:(m,{after:v,waitMs:w,signal:j}={})=>{const S=new URLSearchParams;return v!==void 0&&S.set("after",String(v)),w!==void 0&&S.set("wait_ms",String(w)),o("GET",`${c(m)}/timeline${S.size?`?${S}`:""}`,{signal:j})},listFiles:m=>o("GET",`${c(m)}/files`),deleteUpload:m=>o("DELETE",`/files/${encodeURIComponent(m)}`),readFile:(m,v)=>o("GET",`${c(m)}/files/${v.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(m,v,w)=>o("POST",`${c(m)}/messages`,{body:{content:v},headers:{"idempotency-key":w}}),getRunGraph:(m,v)=>o("GET",`${c(m)}/graph`,{signal:v}),pauseRun:m=>o("POST",`${c(m)}/pause`,{body:{}}),resumeRun:m=>o("POST",`${c(m)}/resume`,{body:{}}),validateWorkflow:(m,v)=>o("POST","/workflows/validate",{body:m,signal:v}),statsOver:({from:m,agent:v})=>{const w=new URLSearchParams;return m&&w.set("from",m),v&&w.set("agent",v),o("GET",`/stats${w.size?`?${w}`:""}`)},fileUrl:(m,v)=>`${t}${c(m)}/files/${v.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>o("GET","/settings/tool-keys"),saveToolKey:(m,v)=>o("PUT",`/settings/tool-keys/${encodeURIComponent(m)}`,{body:{values:v}}),removeToolKey:m=>o("DELETE",`/settings/tool-keys/${encodeURIComponent(m)}`),computers:()=>o("GET","/computers"),saveComputerKeys:(m,v)=>o("PUT",`/computers/${encodeURIComponent(m)}/keys`,{body:v}),testComputer:m=>o("POST",`/computers/${encodeURIComponent(m)}/test`),archil:()=>o("GET","/workspace/archil"),saveArchil:m=>o("PUT","/workspace/archil",{body:m}),archilOff:()=>o("DELETE","/workspace/archil"),testArchil:()=>o("POST","/workspace/archil/test"),webhook:()=>o("GET","/settings/webhook"),saveWebhook:m=>o("PUT","/settings/webhook",{body:{url:m}}),removeWebhook:()=>o("DELETE","/settings/webhook"),testWebhook:()=>o("POST","/settings/webhook/test",{body:{}}),listTriggers:()=>o("GET","/triggers"),getTrigger:m=>o("GET",f(m)),createTrigger:(m,v)=>o("POST","/triggers",{body:m,headers:{"idempotency-key":v}}),rotateTriggerSecret:m=>o("POST",`${f(m)}/secret`,{body:{}}),updateTrigger:(m,v)=>o("PATCH",f(m),{body:v}),deleteTrigger:m=>o("DELETE",f(m)),fireTrigger:(m,v)=>o("POST",`${f(m)}/fire`,{body:{},headers:{"idempotency-key":v}}),triggerFirings:m=>o("GET",`${f(m)}/firings`),webhookDeliveries:()=>o("GET","/settings/webhook/deliveries"),redeliverWebhook:m=>o("POST",`/settings/webhook/deliveries/${encodeURIComponent(m)}/redeliver`,{body:{}}),listTemplates:()=>o("GET","/templates"),applyTemplate:(m,v,w)=>o("POST",`/templates/${encodeURIComponent(m)}/apply`,{body:v,headers:{"idempotency-key":w}}),listMcpServers:()=>o("GET","/settings/mcp-servers"),previewMcpServer:(m,v)=>o("POST","/settings/mcp-servers/preview",{body:{url:m,auth:v}}),saveMcpServer:(m,v,w)=>o("PUT",u(m),{body:{url:v,auth:w}}),refreshMcpServer:m=>o("POST",`${u(m)}/refresh`,{body:{}}),deleteMcpServer:m=>o("DELETE",u(m)),startMcpSignIn:(m,v)=>o("POST",`${u(m)}/oauth/start`,{body:v}),mcpPrivateHosts:()=>o("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:m=>o("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:m}}),githubConnection:()=>o("GET","/integrations/github"),connectGitHub:m=>o("POST","/integrations/github/connect",{body:m?{org:m}:{}}),disconnectGitHub:()=>o("DELETE","/integrations/github"),toolSettings:()=>o("GET","/settings/tools"),saveToolSettings:m=>o("PUT","/settings/tools",{body:m}),stop:m=>o("POST",`${c(m)}/stop`,{body:{}}),answerApproval:(m,v,w,j)=>o("POST",`${c(m)}/approvals/${encodeURIComponent(v)}`,{body:{decision:w,...j?{note:j}:{}}}),cancel:m=>o("POST",`${c(m)}/cancel`,{body:{}})}}async function Xr(e,t,n=100){const o=[];let i=null;for(let l=0;l<n;l++){const c=await e(i);if(o.push(...t(c)),!c.next_cursor)break;i=c.next_cursor}return o}async function Jh(e,t,{onRows:n,onPage:o,signal:i,waitMs:l=25e3,minDelayMs:c=250}){let u=[],f,p;for(;!(i!=null&&i.aborted);){const h=await e.getTimeline(t,f===void 0?{signal:i}:{after:f,waitMs:l,signal:i}).catch(g=>{if(i!=null&&i.aborted)return null;throw g});if(!h||i!=null&&i.aborted||(p=h,n&&(u=Z3(u,h)),o==null||o(h),n==null||n(u),h.final&&!h.has_more))break;f=h.next_after;const b=Math.max(c,h.unchanged?h.poll_after_ms??0:0);b&&await new Promise(g=>setTimeout(g,b))}return p}const Tt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Eu=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function s4(e){const t=new Map;let n=0;const o=u=>{throw Object.assign(new Error(u),{offset:n})},i=()=>{for(;n<e.length&&`
513
+ \r`.includes(e[n]);)n++},l=()=>{const u=n;for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"?n++:e.charCodeAt(n)<32&&o("a string cannot hold a raw line break or control character"),n++;n>=e.length&&(n=u,o("this string is not closed")),n++;try{return JSON.parse(e.slice(u,n))}catch{return n=u,o("this string has a bad escape")}},c=u=>{i();const f=n;let p;const h=e[n];if(h==="{"){n++;const b={};if(i(),e[n]==="}")n++;else for(;;){i(),e[n]!=='"'&&o(e[n]==="}"?"a trailing comma before }":"expected a key in double quotes");const g=l();if(i(),e[n]!==":"&&o("expected : after the key"),n++,b[g]=c(`${u}/${Eu(g)}`),i(),e[n]===","){n++;continue}if(e[n]==="}"){n++;break}o("expected , or } after the value")}p=b}else if(h==="["){n++;const b=[];if(i(),e[n]==="]")n++;else for(;;){if(b.push(c(`${u}/${b.length}`)),i(),e[n]===","){n++,i(),e[n]==="]"&&o("a trailing comma before ]");continue}if(e[n]==="]"){n++;break}o("expected , or ] after the value")}p=b}else if(h==='"')p=l();else{const b=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(n,n+400));b||o(n>=e.length?"the text ends before the value":"expected a value"),n+=b[0].length,p=JSON.parse(b[0])}return t.set(u,{start:f,end:n}),p};try{const u=c("");return i(),n<e.length&&o("text after the end of the JSON"),{ok:!0,value:u,spans:t}}catch(u){return{ok:!1,error:{message:u.message,offset:u.offset??0}}}}function r4(e,t){let n=1,o=-1;for(let i=0;i<Math.min(t,e.length);i++)e[i]===`
514
+ `&&(n++,o=i);return{line:n,col:t-o}}function j1(e,t){let n=e;for(const o of t.split("/").slice(1)){const i=o.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(n))n=n[Number(i)];else if(Tt(n))n=Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0;else return}return n}const N1=new Set(["judge","pick","sift","route"]),Sb=["jev","parallel","openrouter"];function o4(e){return!Tt(e)||!Tt(e.properties)?[]:Object.entries(e.properties).flatMap(([t,n])=>{if(!Tt(n))return[];const o=typeof n.description=="string"?n.description:t;return Array.isArray(n.enum)?[{id:t,type:"choice",text:o,options:n.enum.map(String)}]:n.type==="boolean"?[{id:t,type:"noul",text:o}]:n.type==="integer"?[{id:t,type:"score",text:o}]:[{id:t,type:"choice",text:o}]})}function eg(e,t,n){const o=j1(e,t);if(!Tt(o))return{decision:!1};const i=o.node,l=n??{},c=i==="route"&&typeof o.valuePath=="string",u=typeof i=="string"&&N1.has(i)&&!c||Array.isArray(l.questions);if(!u)return{decision:!1,...i==="call"&&typeof o.tool=="string"?{tool:o.tool}:{}};const f=typeof l.provider=="string"?l.provider:typeof o.provider=="string"?o.provider:"jev",p=typeof l.model=="string"?l.model:typeof o.model=="string"?o.model:void 0,h=Tt(e)&&Tt(e.schemas)?e.schemas:{};let b=[];Array.isArray(l.questions)?b=l.questions.map(v=>({id:v.id,type:v.type==="choice"||v.type==="score"?v.type:"noul",text:v.instructions||v.id,...v.options?{options:v.options}:{}})):i==="judge"||i==="sift"?b=typeof o.out=="string"?o4(h[o.out]):[]:i==="pick"?b=[{id:"pick",type:"choice",text:typeof o.instructions=="string"?o.instructions:"Pick one"}]:i==="route"&&(b=[{id:"branch",type:"choice",text:typeof o.instructions=="string"?o.instructions:"Which branch?",options:Tt(o.branches)?Object.keys(o.branches):[]}]);const g=Array.isArray(l.images)?l.images.map(String):Tt(o.images)?Object.keys(o.images):[],m=Tt(o.unsure)&&typeof o.unsure.branch=="string"&&typeof o.unsure.gte=="number"?{branch:o.unsure.branch,gte:o.unsure.gte}:void 0;return{decision:u,provider:f,model:p,questions:b,...g.length?{images:g}:{},web:f==="parallel",...m?{unsure:m}:{}}}const a4=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function i4(e){const t=[],n=(u,f)=>t.push({path:u,message:f,severity:"error"}),o=(u,f)=>t.push({path:u,message:f,severity:"warning"});if(!Tt(e))return n("","the workflow is a JSON object"),t;e.v!==2&&n("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&n("/name","the workflow needs a name");const i=Tt(e.schemas)?e.schemas:{};Tt(e.input)&&typeof e.input.schemaId=="string"&&!i[e.input.schemaId]&&n("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),Tt(e.output)?typeof e.output.schemaId=="string"&&!i[e.output.schemaId]&&n("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):n("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const l=new Map,c=(u,f)=>{if(!Tt(u)){n(f,'expected a node (an object with a "node" kind)');return}const p=u.node;if(typeof p!="string"||!a4.has(p)){n(`${f}/node`,typeof p=="string"?`"${p}" is not a node kind`:'a node names its kind in "node"');return}p!=="chain"&&(typeof u.label!="string"||!u.label?n(f,`a ${p} node needs a label`):l.has(u.label)?o(`${f}/label`,`the label "${u.label}" is also used at ${l.get(u.label)}; receipts name nodes by label`):l.set(u.label,f));const h=(g,m)=>{u[g]===void 0&&n(f,`a ${p} node needs ${g} (${m})`)},b=g=>{typeof u[g]=="string"&&!i[u[g]]&&n(`${f}/${g}`,`no schema "${u[g]}" in schemas`)};switch(p){case"chain":!Array.isArray(u.steps)||!u.steps.length?n(f,"a chain needs steps"):u.steps.forEach((g,m)=>c(g,`${f}/steps/${m}`));break;case"parallel":!Array.isArray(u.branches)||!u.branches.length?n(f,"a parallel node needs branches"):u.branches.forEach((g,m)=>c(g,`${f}/branches/${m}`));break;case"map":h("itemsPath","where the items are"),h("as","where the results go"),c(u.body,`${f}/body`);break;case"loop":h("until","when it stops"),h("maxIters","a bound"),c(u.body,`${f}/body`);break;case"workflow":Tt(u.workflow)?c(u.workflow.root,`${f}/workflow/root`):n(f,"a workflow node embeds its workflow");break;case"call":h("via","tool, executor or shell"),u.via==="tool"&&h("tool","the tool's name");break;case"code":typeof u.code!="string"&&n(f,"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"),b("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":b("out");break}if(p==="route"){if(!Tt(u.branches)||!Object.keys(u.branches).length)n(f,"a route needs branches");else for(const[g,m]of Object.entries(u.branches))Tt(m)?c(m.body,`${f}/branches/${Eu(g)}/body`):n(`${f}/branches/${Eu(g)}`,`branch "${g}" is an object with a body`);typeof u.valuePath!="string"&&u.instructions===void 0&&n(f,"a route asks by instructions (and state), or reads a valuePath"),Tt(u.unsure)&&Tt(u.branches)&&typeof u.unsure.branch=="string"&&!(u.unsure.branch in u.branches)&&n(`${f}/unsure/branch`,`the unsure branch "${u.unsure.branch}" is not one of the branches`)}if(N1.has(p)&&!(p==="route"&&typeof u.valuePath=="string")&&(u.provider!==void 0&&!Sb.includes(u.provider)&&o(`${f}/provider`,`provider "${String(u.provider)}" is not one of ${Sb.join(", ")}`),u.provider==="openrouter"&&typeof u.model!="string"&&n(f,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),Tt(u.images))){const g=JSON.stringify(u.state??{})+JSON.stringify(u.instructions??"")+(typeof u.out=="string"?JSON.stringify(i[u.out]??{}):"");for(const m of Object.keys(u.images))g.includes(m)||n(`${f}/images/${Eu(m)}`,`the image token "${m}" must appear in the state or a question, or the model never sees it`)}};return e.root===void 0?n("","the workflow needs a root node"):c(e.root,"/root"),t}function _b(e,t){for(let n=t;;n=n.slice(0,n.lastIndexOf("/"))){const o=e.get(n);if(o)return o;if(!n)return}}function l4(e,t,n){let o=null,i=1/0;for(const l of t){const c=e.get(l);c&&c.start<=n&&n<=c.end&&c.end-c.start<i&&(o=l,i=c.end-c.start)}return o}function c4(e){const t=cl(e),o=t.nodes.map(l=>eg(e,l.path,l)).filter(l=>l.decision),i=[...new Set(o.map(l=>l.provider??"jev"))];return`${t.nodes.length} nodes · ${o.length} ${o.length===1?"decision":"decisions"}${i.length?` · ${i.join(", ")}`:""}`}const Hu=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Eb=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Ul=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function Pd(e,t){return Object.fromEntries(t.nodes.map(n=>[n.path,eg(e,n.path,n)]))}const cu=e=>e>=.995?"1.00":e.toFixed(2);function Ba(e){var u;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const t=e.answers??{},n=e.action;if(((u=e.rule)==null?void 0:u.kind)==="route"&&n&&typeof n=="object"&&(n.taken||n.branch)){const f=t.branch,p=f&&f.type==="choice"?f.confidence:void 0;return n.unsure?`${n.taken} (unsure)`:`${n.taken??n.branch}${p!==void 0?` ${cu(p)}`:""}`}const o=Object.keys(t);if(!o.length)return;const i=f=>{const p=t[f];return p.type==="choice"?`${S1(e,f,p.choice)} ${cu(p.probabilities[p.choice]??p.confidence)}`:p.type==="noul"?`${p.noul>=.5?"yes":"no"} ${cu(p.noul>=.5?p.noul:1-p.noul)}`:p.type==="score"?`${p.score} ${cu(p.confidence)}`:p.type==="refusal"?"refused":"box"};if(o.length===1)return i(o[0]);const l=f=>{const p=t[f];return p.type==="noul"?Math.abs(p.noul-.5)*2:"confidence"in p&&typeof p.confidence=="number"?p.confidence:1},c=o.reduce((f,p)=>l(p)<l(f)?p:f,o[0]);return`${c} ${i(c)}`}function S1(e,t,n){var l,c;const o=(l=e.questions)==null?void 0:l[t],i=e.kind==="pick"&&(o==null?void 0:o.type)==="choice"?(c=o.criteria)==null?void 0:c[n]:null;return typeof i=="string"&&i?i:n}const _1=(e,t)=>e.nodes.filter(n=>n.path.startsWith(`${t}/body`)).map(n=>n.path);function u4(e,t,n){var b,g;const o=(g=(b=e.nodes[t])==null?void 0:b.items)==null?void 0:g.find(m=>m.index===n),i={};if(!o)return i;const l=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(m=>[m.path,m.kind])),u=_1(e.graph,t).filter(m=>!l.has(c.get(m)??""));let f=-1;u.forEach((m,v)=>{const w=e.decisions.filter(S=>S.node===m&&S.item===n),j=e.effects.filter(S=>S.node===m&&S.item===n);!w.length&&!j.length||(f=v,w.some(S=>S.status==="failed")||j.some(S=>S.status==="failed")?i[m]="failed":w.some(S=>S.status==="cancelled")?i[m]="review":j.some(S=>!S.endedAt)?i[m]=j.some(S=>S.status==="stopped")?"stopped":"working":i[m]="done")});const p=Hu(o.status)??"pending";let h=!Object.values(i).includes("working");return u.forEach((m,v)=>{i[m]||(v<f||p==="done"?i[m]="done":p==="working"?(i[m]=h?"working":"pending",h=!1):p==="pending"?i[m]="pending":i[m]="not-run")}),i}function d4(e,t){var p,h,b;const n={},o=[],i={};let l=null;const c=new Map(e.graph.nodes.map(g=>[g.path,g.kind]));for(const[g,m]of Object.entries(e.nodes)){const v=Hu(m.status);v&&(n[g]=v),m.branch&&o.push(`${g}/branches/${Eb(m.branch)}/body`),m.items&&(i[g]=m.items.map(w=>({index:w.index,status:Hu(w.status)??"pending",label:bl(e,g,w.index),...tg(e,g,w)}))),m.status==="escalated"&&c.get(g)==="escalate"&&(l=g)}const u={},f=g=>/\/body(\/|$)/.test(g)&&e.graph.nodes.some(m=>m.kind==="map"&&g.startsWith(`${m.path}/body`));for(const g of e.decisions){if(!g.node||g.item!==null||f(g.node))continue;const m=Ba(g);m&&(u[g.node]=m)}if(t&&t.item!=null&&c.get(t.path)==="map"){Object.assign(n,u4(e,t.path,t.item));const g=((b=(h=(p=e.nodes[t.path])==null?void 0:p.items)==null?void 0:h.find(m=>m.index===t.item))==null?void 0:b.branches)??{};for(const[m,v]of Object.entries(g)){const w=`${m}/branches/`,j=`${w}${Eb(v)}/body`;for(let S=o.length-1;S>=0;S--)o[S].startsWith(w)&&o.splice(S,1);o.push(j);for(const S of e.graph.nodes)S.path.startsWith(w)&&!(S.path===j||S.path.startsWith(`${j}/`))&&(n[S.path]="not-run")}for(const m of e.decisions)if(m.node&&m.item===t.item&&m.node.startsWith(`${t.path}/body`)){const v=Ba(m);v&&(u[m.node]=v)}}if(e.run.paused){for(const[g,m]of Object.entries(n))m==="working"&&(n[g]="held");for(const g of Object.values(i))for(const m of g)m.status==="working"&&(m.status="held")}return{status:n,taken:o,items:i,fired:l,verdict:u,meta:Pd(e.workflow,e.graph),selected:t}}const np={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"},f4=e=>{if(!e)return;const t=e.toLowerCase();return np[t]??np[t.split(/[_\s-]/)[0]]??np[t.split(/[_\s-]/).at(-1)??""]};function m4(e){if(e.status!=="answered"||!e.answers)return;const t=e.action,n=e.answers.branch;if(t&&typeof t=="object"&&t.taken&&(n==null?void 0:n.type)==="choice")return{p:n.confidence,note:`${e.kind} confidence`};let o;for(const[i,l]of Object.entries(e.answers)){const c=l.type==="noul"?{p:Math.max(l.noul,1-l.noul),note:`${i}: ${l.noul>=.5?"yes":"no"}, P(yes) ${l.noul.toFixed(2)}`,sure:Math.abs(l.noul-.5)}:l.type==="choice"||l.type==="score"?{p:l.confidence,note:`${i} confidence`,sure:l.confidence-.5}:void 0;c&&(!o||c.sure<o.sure)&&(o=c)}return o&&{p:o.p,note:`least sure: ${o.note}`}}function tg(e,t,n){const o=_1(e.graph,t),i=g=>g?o.indexOf(g):-1,l=e.decisions.filter(g=>{var m;return g.item===n.index&&!!((m=g.node)!=null&&m.startsWith(`${t}/body`))}).sort((g,m)=>i(g.node)-i(m.node));let c,u;const f=Object.entries(n.branches??{}).sort(([g],[m])=>i(g)-i(m));if(f.length)[u,c]=f[f.length-1];else{const g=l.filter(m=>{var v;return m.status==="answered"&&((v=m.action)==null?void 0:v.taken)}).at(-1);g&&(c=g.action.taken,u=g.node??void 0)}const p=u&&l.filter(g=>g.node===u).at(-1)||l.filter(g=>g.status==="answered").at(-1),h=p?m4(p):void 0,b=n.status==="failed"?"bad":n.status==="needs_review"||n.status==="escalated"?"warn":f4(c);return{...c?{outcome:c}:{},...h?{p:h.p,pNote:h.note}:{},...b?{tone:b}:{}}}function bl(e,t,n){var u,f;const o=(f=(u=e.nodes[t])==null?void 0:u.items)==null?void 0:f.find(p=>p.index===n);if(o!=null&&o.label)return o.label;const i=e.effects.find(p=>{var h;return p.item===n&&!!((h=p.node)!=null&&h.startsWith(`${t}/body`))}),l=i==null?void 0:i.input,c=(l==null?void 0:l.path)??(l==null?void 0:l.url);return typeof c=="string"?c:void 0}function E1(e=[]){const t={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const n of e)n.status==="done"?t.done++:n.status==="working"?t.working++:n.status==="failed"?t.failed++:n.status==="needs_review"||n.status==="escalated"?t.review++:t.pending++;return t}function $1(e){const t=e.decisions.filter(n=>n.cost_usd===null).length;return{usd:e.totals.cost_usd??e.decisions.reduce((n,o)=>n+(o.cost_usd??0),0),unknown:e.totals.cost_usd===null?t:0}}const ni=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Pa=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function Ga(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60);return n?`${n}m ${String(t%60).padStart(2,"0")}s`:`${t}s`}const p4=(e,t,n)=>{const o=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||t)-Date.parse(e.run.startedAt);return Ul(e.run.status)||e.run.paused?o:o+Math.max(0,n-t)};function h4(e,t,n){return e!=="input_required"||t!=="waiting"?null:n.findLast(o=>o.kind==="waiting")??null}function g4(e){const t=e.content_type??"";return t.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":t.startsWith("text/")||t.includes("json")?"text":"download"}const zp=[0,250,1e3],T1=e=>new Promise(t=>setTimeout(t,e));function Bu(){let e=0;return{begin:()=>++e,current:t=>t===e,cancel:()=>{e++}}}const C1="30d",$b=10,x4=["queued","working","input_required","paused"];function y4({agent:e,v2:t,now:n=Date.now,stats:o}){const[i,l]=y.useState(C1),[c,u]=y.useState(o??null),[f,p]=y.useState(null),[h,b]=y.useState(!0),[g,m]=y.useState(0),v=y.useRef(0),w=y.useRef(!0);y.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const j=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{const E=`${i}/${g}`;if(S.current===E)return;const _=++v.current;if(j.current===E){S.current=null,p(null),b(!1);return}S.current=E,b(!0),p(null),(async()=>{for(const[$,R]of zp.entries()){if(R&&await T1(R),_!==v.current||!w.current)return;try{const C=await t.statsOver({from:Qh(i,n()),agent:e.agent_id});if(_!==v.current||!w.current)return;const O=!(C.runs.status_unknown>0);if(u(C),j.current=O||$===zp.length-1?E:null,O)break}catch(C){_===v.current&&p(jn(C));break}}_===v.current&&(S.current=null,b(!1))})()},[t,e.agent_id,i,g]),y.useEffect(()=>{const E=new AbortController,_=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(x4.map($=>t.listAgentRuns(e.agent_id,$b,null,_($)))).then($=>{if(E.signal.aborted)return;const R=$.flatMap(C=>C.status==="fulfilled"?C.value.runs:[]).filter(C=>!Ul(C.status));for(const C of R.slice(0,$b)){let O=`${C.status}/${C.state}`;Jh(t,C.run_id,{signal:E.signal,onPage:I=>{const D=`${I.status}/${I.state}`;D!==O&&(O=D,m(z=>z+1))}}).catch(()=>{})}}),()=>E.abort()},[t,e.agent_id]);const T=c==null?void 0:c.analytics;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(y1,{range:i,onRange:l,agent:null,agents:[]}),f?s.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",f]}):!c||!T?s.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):T.totals.runs?s.jsx(v1,{a:T,basis:c.cost.basis,now:n(),refreshing:h}):s.jsx("div",{className:"border px-4 py-12 text-center",children:s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const v4={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:bp},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:bp},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:Xw},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Js},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:Da}};function ts({tone:e="neutral",title:t,actions:n,bar:o,icon:i,role:l,className:c,children:u,...f}){const p=v4[e],h=i===!1?null:i??p.Icon;return s.jsxs("div",{role:l??(e==="error"?"alert":"status"),...f,className:ie("flex gap-3 text-body",o?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ie("border p-4",p.box),c),children:[h&&s.jsx(h,{className:ie("size-4 shrink-0",!o&&"mt-0.5",p.text),"aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[t&&s.jsx("p",{className:ie("font-semibold",!o&&"caps text-small",!o&&p.text),children:t}),u&&s.jsx("div",{className:ie(t&&!o&&"mt-2"),children:u})]}),n&&s.jsx("div",{className:"flex shrink-0 items-start gap-2",children:n})]})}const Tb=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Cb=i0,b4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return Cb(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:l}=t,c=Object.keys(i).map(p=>{const h=n==null?void 0:n[p],b=l==null?void 0:l[p];if(h===null)return null;const g=Tb(h)||Tb(b);return i[p][g]}),u=n&&Object.entries(n).reduce((p,h)=>{let[b,g]=h;return g===void 0||(p[b]=g),p},{}),f=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((p,h)=>{let{class:b,className:g,...m}=h;return Object.entries(m).every(v=>{let[w,j]=v;return Array.isArray(j)?j.includes({...l,...u}[w]):{...l,...u}[w]===j})?[...p,b,g]:p},[]);return Cb(e,c,f,n==null?void 0:n.class,n==null?void 0:n.className)},qa=b4("caps inline-flex items-center justify-center gap-2 whitespace-nowrap 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-primary text-primary-text hover:bg-primary/10",solid:"border-primary bg-primary text-primary-foreground hover:bg-primary/90",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"}}),Z=y.forwardRef(({className:e,variant:t,size:n,...o},i)=>s.jsx("button",{ref:i,className:ie(qa({variant:t,size:n}),e),...o}));Z.displayName="Button";const w4={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 Pe({tone:e="plain",className:t,title:n,children:o}){return s.jsx("span",{title:n,className:ie("caps inline-flex h-5 items-center gap-1 border px-1.5 text-micro leading-none",w4[e],t),children:o})}const k4={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function ng({open:e,onClose:t,title:n,description:o,footer:i,size:l="md",initialFocus:c,hideClose:u,className:f,children:p}){return s.jsxs(pR,{open:e,onClose:t,initialFocus:c,className:"relative z-dialog",children:[s.jsx(mR,{className:"fixed inset-0 bg-overlay/70"}),s.jsx("div",{className:ie("fixed inset-0 flex justify-center p-4 md:p-8",l==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:s.jsxs(zk,{className:ie("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",k4[l],f),children:[s.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(Dk,{className:"text-lg font-semibold",children:n}),o&&s.jsx(I0,{className:"mt-1 text-body text-muted-foreground",children:o})]}),!u&&s.jsx(Z,{size:"icon",variant:"ghost",onClick:t,"aria-label":"Close",children:s.jsx(Ol,{"aria-hidden":!0})})]}),p&&s.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:p}),i&&s.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:i})]})})]})}function j4({open:e,title:t,confirm:n,cancel:o="Cancel",tone:i="destructive",busy:l,onConfirm:c,onCancel:u,children:f}){const p=y.useRef(null);return s.jsx(ng,{open:e,onClose:l?()=>{}:u,title:t,size:"sm",hideClose:!0,initialFocus:p,footer:s.jsxs(s.Fragment,{children:[s.jsx(Z,{ref:p,size:"sm",onClick:u,disabled:l,children:o}),s.jsx(Z,{size:"sm",variant:i,onClick:c,disabled:l,"aria-busy":l||void 0,children:n})]}),children:f})}function N4({icon:e,active:t,className:n,children:o,...i}){return s.jsxs("button",{type:"button","aria-current":t?"page":void 0,...i,className:ie("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",t&&"relative bg-primary/[0.06] text-primary-text before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-primary",n),children:[e&&s.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",o]})}function S4({label:e,className:t}){return s.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[s.jsx(J2,{className:ie("size-4 animate-spin text-run-active",t),"aria-hidden":!0}),e&&s.jsx("span",{className:"sr-only",children:e})]})}function _4({checked:e,onChange:t,disabled:n,label:o,labelledBy:i,busy:l,className:c}){return s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":o,"aria-labelledby":i,"aria-busy":l||void 0,disabled:n||l,onClick:()=>t(!e),className:ie("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",l&&"motion-safe:animate-pulse",c),children:s.jsx("span",{"aria-hidden":!0,className:ie("absolute top-1/2 size-3 -translate-y-1/2 transition-[left,background-color] duration-fast",e?"left-[calc(100%-16px)] bg-primary":"left-[3px] bg-muted-foreground")})})}function R1({tabs:e,value:t,onChange:n,label:o,id:i,className:l}){var p;const c=e.some(h=>h.id===t)?t:(p=e[0])==null?void 0:p.id,u=y.useRef(null),f=h=>{var m,v;const b=e.findIndex(w=>w.id===t),g=h.key==="ArrowRight"?(b+1)%e.length:h.key==="ArrowLeft"?(b-1+e.length)%e.length:h.key==="Home"?0:h.key==="End"?e.length-1:-1;g<0||g===b||(h.preventDefault(),n(e[g].id),(v=(m=u.current)==null?void 0:m.querySelectorAll('[role="tab"]')[g])==null||v.focus())};return s.jsx("div",{ref:u,role:"tablist","aria-label":o,onKeyDown:f,className:ie("flex border-b px-5 md:px-8",l),children:e.map(h=>s.jsx("button",{type:"button",role:"tab",id:i&&`${i}-tab-${h.id}`,"aria-controls":i&&`${i}-panel-${h.id}`,"aria-selected":t===h.id,tabIndex:c===h.id?0:-1,onClick:()=>n(h.id),className:ie("caps -mb-px whitespace-nowrap border-b-2 px-3 py-3 text-small -outline-offset-2 max-sm:px-2.5 max-sm:py-2",t===h.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:h.label},h.id))})}function E4({tip:e,children:t,className:n,align:o="start"}){const i=y.useId();return s.jsxs("span",{className:ie("group/tip relative inline-flex",n),children:[y.cloneElement(t,{"aria-describedby":i}),s.jsx("span",{role:"tooltip",id:i,className:ie("pointer-events-none absolute top-full z-popover mt-1.5 hidden w-max max-w-[min(20rem,80vw)] border border-border-strong bg-card px-3 py-2 text-left font-sans text-small normal-case leading-snug tracking-normal text-card-foreground shadow-float group-hover/tip:block group-focus-within/tip:block",o==="end"?"right-0":"left-0"),children:e})]})}const $4=y.createContext(null),T4={neutral:[bp,"text-muted-foreground"],success:[Xw,"text-success-text"],warning:[Js,"text-warning-text"],error:[Da,"text-destructive-text"]},C4=5e3;function R4({toast:e,done:t}){const n=y.useCallback(()=>t(e.id),[t,e.id]),o=e.tone??"neutral",i=e.duration??(o==="error"?0:C4),[l,c]=y.useState(!1),[u,f]=y.useState(!1),p=l||u;y.useEffect(()=>{if(!i||p)return;const g=setTimeout(n,i);return()=>clearTimeout(g)},[i,p,n]);const[h,b]=T4[o];return s.jsxs("div",{role:o==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>f(!0),onBlur:()=>f(!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:[s.jsx(h,{className:ie("mt-0.5 size-4 shrink-0",b),"aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-semibold",children:e.title}),e.description&&s.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),s.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:s.jsx(Ol,{className:"size-3.5","aria-hidden":!0})})]})}function A4({children:e}){const[t,n]=y.useState([]),o=y.useRef(0),i=y.useCallback(c=>n(u=>[...u,{...c,id:o.current++}].slice(-3)),[]),l=y.useCallback(c=>n(u=>u.filter(f=>f.id!==c)),[]);return s.jsxs($4.Provider,{value:i,children:[e,s.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:t.map(c=>s.jsx(R4,{toast:c,done:l},c.id))})]})}const Gu=[{id:"claude",label:"Claude Code app",instruction:"Open your project in Claude Code and paste the prompt into a new or existing conversation."},{id:"claude-cli",label:"Claude Code CLI",instruction:"Open your project in a terminal, start Claude Code with claude, and paste the prompt."},{id:"codex",label:"Codex app",instruction:"Open your project in the Codex app and paste the prompt into a new or existing chat."},{id:"codex-cli",label:"Codex CLI",instruction:"Open your project in a terminal, start Codex with codex, and paste the prompt."}],A1="agentrun.coding-agent",O4="https://github.com/Parcha-ai/agentrun/tree/main/packages/serve/skills/agentrun-serve",O1=()=>{try{return globalThis.localStorage??null}catch{return null}};function P4(e=O1()){var t;try{const n=e==null?void 0:e.getItem(A1);return((t=Gu.find(o=>o.id===n))==null?void 0:t.id)??"claude"}catch{return"claude"}}function M4(e,t=O1()){try{t==null||t.setItem(A1,e)}catch{}}const Rb=e=>Gu.find(t=>t.id===e)??Gu[0];function Ab(e,t=(n=>(n=globalThis.location)==null?void 0:n.href)()){const o=new URL(e||"/",t),i=o.pathname.replace(/\/+$/,"");return{origin:o.origin,path:i,api:`${o.origin}${i}`}}const L4={create:"Create an AgentRun agent on this server.",edit:"Review and revise this AgentRun agent.",run:"Run this AgentRun agent on its pinned revision."};function I4(e,t,n){const{origin:o,path:i,api:l}=Ab(t),c=i.endsWith("/v2"),u=e.kind==="create"?"":encodeURIComponent(e.agentId),f=e.kind==="create"?`POST ${i}/agents`:e.kind==="edit"?`PUT ${i}/agents/${u}/definition`:`POST ${i}/agents/${u}/runs`,p=e.kind==="run"?{...e.input!==void 0?{input:e.input}:{},...e.effort?{effort:e.effort}:{},revision:e.revision}:void 0,h={server:l,operation:f,...e.kind==="create"?{}:{agent_id:e.agentId,revision:e.revision},...p?{request:p}:{}},b=n?`${Ab(n).api}/`:void 0,g=e.kind==="create"?[`Create it with POST ${i}/agents and one Idempotency-Key for the request and any unchanged retry.`,"Write a native definition: instructions with the tools the agent needs, or a workflow this server supports. Include every skill file the person supplies in the same request.","Do not submit missing requirements or configuration this server's capabilities do not offer."]:e.kind==="edit"?[`Read the agent first with GET ${i}/agents/${u} and keep its ETag.`,`Send the full definition with PUT ${i}/agents/${u}/definition, a higher version and If-Match set to that ETag. Keep the agent's identity and every field you were not asked to change; skill files do not change through this route.`,"A 412 precondition_failed means another revision was saved first: report it, and do not overwrite that revision."]:[`Read the pinned revision's input contract. Start the run with POST ${i}/agents/${u}/runs, the revision pinned, and one stable Idempotency-Key for this run and any unchanged retry.`,"Do not add a spending cap unless the person asks for one.","Follow the run's actual status, its questions (input_required), its result and its files until it ends."];return[L4[e.kind],"","Install or update the public AgentRun Server skill with your own skill installation workflow:",O4,`Read its SKILL.md, then ${c?`${o}/llms.txt and `:""}${l}/openapi.json. Check ${l}/capabilities before you choose models, tools or workflow features.`,"",`Use this existing server. Authentication is separate from the skill: use the AgentRun API token the owner configured in your environment, as the skill describes. Never print a credential or ask for one in the conversation. The console's browser session does not sign you in.${c?` You can work over the server's MCP endpoint (${l}/mcp), as the skill connects it, or over the HTTP API.`:""}`,"","Task context:","```json",JSON.stringify(h,null,2),"```","","Ask about missing task inputs, required outputs and scope before you submit anything. Keep the answers and any approval already given. Explain the change or the run first when it still needs approval.",...g,`Report the server's actual answer and the ${e.kind==="run"?"run":"revision"} it names${b?`, with its link in the console (${b})`:""}. Keep an unknown cost unknown. Copying this prompt submitted nothing, so do not claim that anything ran before the server says so.`].join(`
515
+ `)}const z4={create:"Build with your coding agent",edit:"Edit with your coding agent",run:"Run with your coding agent"},D4=()=>globalThis.location?`${location.origin}${location.pathname}`:void 0;function F4({open:e,onClose:t,context:n,serverUrl:o="/v2",consoleUrl:i=D4()}){const[l,c]=y.useState(()=>P4()),[u,f]=y.useState(()=>I4(n,o,i)),[p,h]=y.useState("no"),b=y.useRef(null),g=Rb(l),m=async()=>{var v,w,j;try{if(!((v=navigator.clipboard)!=null&&v.writeText))throw new Error("No clipboard");await navigator.clipboard.writeText(u),h("yes")}catch{h("unavailable"),(w=b.current)==null||w.focus(),(j=b.current)==null||j.select()}};return s.jsx(ng,{open:e,onClose:t,size:"lg",title:z4[n.kind],description:"Pick where you work, then review and copy the prompt. Nothing opens or runs from here.",footer:s.jsxs(s.Fragment,{children:[s.jsx(Z,{size:"sm",onClick:t,children:"Close"}),s.jsxs(Z,{size:"sm",variant:"solid",onClick:()=>void m(),disabled:!u.trim(),children:[s.jsx(fd,{"aria-hidden":!0})," Copy prompt"]})]}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(Ao,{label:"Application",hint:g.instruction,children:s.jsx(qt,{label:"Application",autoFocus:!0,value:l,className:"w-full sm:w-72",onChange:v=>{const w=Rb(v).id;M4(w),c(w),h("no")},options:Gu.map(v=>({value:v.id,label:v.label}))})}),s.jsx(Ao,{label:"Prompt",note:"Review it and edit it before you copy it. It holds the task and no credential: your coding agent signs in to the server on its own.",children:s.jsx(Ns,{ref:b,value:u,rows:14,spellCheck:!1,className:"resize-y text-small leading-relaxed",onChange:v=>{f(v.target.value),h("no")}})}),p==="yes"&&s.jsxs(ts,{tone:"success",title:"Copied",children:["Paste it into ",g.label,". Nothing was sent to the server."]}),p==="unavailable"&&s.jsx(ts,{tone:"warning",role:"alert",title:"Clipboard unavailable",children:"The prompt is selected in its field. Copy it with your keyboard (Ctrl+C, or Cmd+C on a Mac)."})]})})}function sg({context:e,label:t,serverUrl:n="/v2",size:o="sm",iconOnPhone:i,unavailable:l,className:c}){const[u,f]=y.useState(null),[p,h]=y.useState(!1),[b,g]=y.useState(0);return s.jsxs(s.Fragment,{children:[s.jsxs(Z,{size:o,onClick:()=>{f(typeof e=="function"?e():e),g(m=>m+1),h(!0)},"aria-haspopup":"dialog",disabled:!!l,title:l??(i?t:void 0),className:ie(i&&"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",c),children:[s.jsx(f_,{"aria-hidden":!0})," ",i?s.jsx("span",{className:"max-sm:sr-only",children:t}):t]}),u&&s.jsx(F4,{open:p,onClose:()=>h(!1),context:u,serverUrl:n},b)]})}const U4={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},P1=(e,t)=>`${U4[e]} by ${t==="person"?"you":"a run"}`,Dp=e=>e.readme??e.file,sp="Can't tell which version this is: reload.",Md="It changed since you opened it.",W4=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.",H4=e=>`It makes a new agent that runs the steps of ${e} on their own, with no agent loop, under this agent's tool settings, approvals and cap. ${e} stays here, unchanged.`,B4="Making an agent from it takes your password sign-in in the console.",G4="Restoring takes your password sign-in in the console.",M1=["feedback","project","reference","user"],q4={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},L1=e=>q4[e]??e,V4={feedback:"How to work: a rule or a correction",project:"Facts about the work itself",reference:"Where to find things",user:"About the person it works for"},K4=["seeded","reflecting","proposed"],I1=e=>!!e&&K4.includes(e.state),Wl=e=>Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&typeof t.file=="string"&&typeof t.name=="string"):[],z1=e=>Wl(e==null?void 0:e.given),D1=e=>Wl(e==null?void 0:e.read),wl=e=>(e==null?void 0:e.state)==="merged"?Wl(e.learned):[],rg=e=>Wl(e==null?void 0:e.pending),F1=e=>Wl(e),Ob=e=>(e==null?void 0:e.state)==="merged"?F1(e.skills):[],Pb=e=>(e==null?void 0:e.state)==="merged"?F1(e.workflows):[],X4=e=>rg(e).length>0,qu=(e,t)=>`${e} ${t}${e===1?"":"s"}`,U1=e=>e.status==="pending",Vu=e=>{var t;return((t=e==null?void 0:e.learning)==null?void 0:t.pending)??0},og=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function Y4(e){const t=e&&typeof e=="object"?e.learning:void 0;return t&&typeof t=="object"&&t.approve===!0?"yes":"password"}const W1="Approving needs your password sign-in. Until then it stays out of every run.",Q4="It changes what this agent trusts or skips, so it waits for you.",Z4="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",H1="[redacted]",B1=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",Ma=e=>`${e} ${e===1?"note":"notes"}`,eo=e=>`${e} ${e===1?"run":"runs"}`,J4={grader:"refused",checker:"refused",screen:"refused",screen_down:"refused",unparsed:"refused",empty:"nothing",no_budget:"skipped",unknown_cost:"skipped",no_write_tool:"skipped",tool_denied:"skipped"},Ku=e=>J4[e??""]??"stopped",eA={empty:"Nothing new to remember from this run.",unparsed:"Not kept: its notes weren't in the expected format.",grader:"Not kept: it wouldn't help later runs enough.",checker:"Not kept: it held something that must not be stored.",screen:"Not kept: it held something that must not be stored.",screen_down:"Not kept: it couldn't be checked for safety.",no_write_tool:"Not kept: this agent can't write notes (give it the write tool).",tool_denied:"Not kept: this agent isn't allowed to write notes.",no_budget:"Skipped: no budget left in this run to look back.",unknown_cost:"Skipped: no budget left in this run to look back.",seed_failed:"Started without its notes: they couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_timeout:"Not kept: learning stopped (it ran out of time).",reflect_failed:"Not kept: learning stopped (an error).",propose_failed:"Not kept: learning stopped (an error).",grade_failed:"Not kept: learning stopped (the check couldn't run)."};function ag(e){return e.detail&&e.detail.trim()?e.detail.trim():eA[e.reason??""]??"Not kept: learning stopped."}const tA=e=>e==="seeded"?"Learns after the run":"Looking back",Xu=e=>Ga(Math.round(e)*1e3),La=e=>so({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),Mb=(e,t)=>e>0?Math.round((t-e)/e*100):null,G1=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",q1=e=>e.after.median_learning_usd;function nA(e){const t=[`answers in ${Xu(e.after.median_duration_s)} instead of ${Xu(e.before.median_duration_s)}`];G1(e)&&t.push(`${La(e.after.median_cost_usd)} instead of ${La(e.before.median_cost_usd)} a run`);const n=q1(e);return n!==null&&t.push(`learning itself ${La(n)} a run`),`Since it learned (on ${eo(e.after.runs)}): ${t.join(" · ")}`}const sA=e=>{const t=n=>!!n&&typeof n=="object"&&typeof n.runs=="number"&&n.runs>=2&&typeof n.median_duration_s=="number";return!!e&&typeof e=="object"&&t(e.before)&&t(e.after)},rA=/^---\n([\s\S]*?)\n?^---$\n?/m,Fp=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Yu(e){const t=e.replace(/\r\n/g,`
516
+ `),n=t.startsWith(`---
517
+ `)?rA.exec(t):null;if(!n||n.index!==0)return{name:"",description:"",type:"project",body:t,rest:[]};const o={},i=[];for(const c of n[1].split(`
518
+ `)){const u=/^(name|description|type):(?:\s+(.*))?$/.exec(c);u&&!(u[1]in o)?o[u[1]]=Fp((u[2]??"").trim()):c.trim()&&i.push(c)}const l=M1.includes(o.type??"")?o.type:"project";return{name:o.name??"",description:o.description??"",type:l,body:t.slice(n[0].length),rest:i}}const Lb=e=>{const t=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(t)?t.includes('"')?`'${t}'`:`"${t}"`:t},oA=e=>`---
519
+ name: ${Lb(e.name)}
520
+ description: ${Lb(e.description)}
521
+ type: ${e.type}
522
+ ${e.rest.map(t=>`${t}
523
+ `).join("")}---
524
+ ${e.body.replace(/^\n*/,`
525
+ `)}`;function aA(e){const t=Yu(e).rest.find(o=>/^supersedes:/.test(o)),n=t?Fp(t.replace(/^supersedes:\s*/,"").trim()).trim():"";return n?(/^\[.*\]$/.test(n)?n.slice(1,-1).split(","):[n]).map(o=>Fp(o.trim())).filter(Boolean):[]}const kl=e=>Yu(e).body.replace(/^\n+/,"");function Ib(e,t=[]){const n=e.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note";let o=`${n}.md`;for(let i=2;t.includes(o);i++)o=`${n}-${i}.md`;return o}const Ld=(e,t=[])=>{const n=t.filter(i=>i!==H1),o=new URLSearchParams(n.map(i=>["note",i]));return`#/agents/${encodeURIComponent(e)}/learning${n.length?`?${o}`:""}`};function V1(e){return e.kind===gr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===gr?{...e,kind:gr,agent_label:null}:e}const gr="learning",iA={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},Up=e=>e?iA[e.state]??0:-1,lA=e=>{const t=e==null?void 0:e.learning;return t&&typeof t=="object"&&typeof t.state=="string"?t:void 0},zb=e=>e.charAt(0).toLowerCase()+e.slice(1);function cA(e){var n,o;if(!e||Up(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${zb(((n=e.detail)==null?void 0:n.trim())||"Checking its new notes…")}`;const t=i=>i.map(l=>l.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const i=wl(e),l=rg(e),c=[...i.length?[`kept ${Ma(i.length)} (${t(i)})`]:[],...l.length?[`${zb(B1(l.length))} (${t(l)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((o=e.detail)==null?void 0:o.trim())||"It kept what it learned."}`}return Ku(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${ag(e)}`}function uA(e){var l;const t=V1(e),n=t.summary??"",o=k1(t)?`${n} (failed)`:n,i=(l=w1(t))==null?void 0:l.trimEnd();return i&&i.trim()!==n.trim()?`${o}
526
+ ${i.replace(/^(?=.)/gm," ")}`:o}function K1(e,t){const n=e.filter(f=>f.agent_label===gr&&f.kind!==gr);if(!n.length)return e.map(V1);const o=e.findLast(f=>f.kind===gr),i=lA(o),l=Up(i)>Up(t??void 0)?i:t&&{...t,detail:t.detail??(i==null?void 0:i.detail)??(o==null?void 0:o.summary)??null},c=n[0],u={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:gr,agent_label:null,tool_name:null,tool_use_id:null,tool_status:null,tool_input_preview:null,tool_result_preview:null,tool_result_size_bytes:null,summary:cA(l??void 0),text:[...n,...o?[o]:[]].map(uA).join(`
527
+ `)};return e.flatMap(f=>f===c?[u]:f.agent_label===gr||f.kind===gr?[]:[f])}const dA={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},Db=["Added","Replaced","Retired","Removed","Changed"];function fA(e){const t=[],n=[];let o=0;for(const i of e.split(`
528
+ `)){const l=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(i);l?((o||Number(l[1])>1)&&t.push({text:"…",mark:"gap"}),(o||Number(l[2])>1)&&n.push({text:"…",mark:"gap"}),o++):o&&i.startsWith(" ")?(t.push({text:i.slice(1),mark:"same"}),n.push({text:i.slice(1),mark:"same"})):o&&i.startsWith("-")?t.push({text:i.slice(1),mark:"removed"}):o&&i.startsWith("+")&&n.push({text:i.slice(1),mark:"added"})}return{before:t,after:n}}function mA(e,t){const n=e.files.filter(u=>u.path!=="MEMORY.md"),o=new Map(n.map(u=>[u.path,u.patch===void 0?null:fA(u.patch)])),i=new Map([...z1(t),...D1(t),...wl(t)].map(u=>[u.file,u.name])),l=u=>{const f=o.get(u),p=[...(f==null?void 0:f.after)??[],...(f==null?void 0:f.before)??[]].find(h=>h.mark!=="gap"&&/^name:\s*\S/.test(h.text));return i.get(u)??(p==null?void 0:p.text.replace(/^name:\s*/,"").trim())??u.replace(/\.md$/,"")};return n.map(u=>{var m,v;const f=o.get(u.path),p=l(u.path),h=((f==null?void 0:f.after)??[]).filter(w=>w.mark==="added").map(w=>w.text.trim()),b=((m=h.find(w=>w.startsWith("superseded_by:")))==null?void 0:m.replace(/^superseded_by:\s*/,""))??((v=wl(t).find(w=>{var j;return(j=w.supersedes)==null?void 0:j.includes(u.path)}))==null?void 0:v.file),g=u.status==="added"?`Added: ${p}`:u.status==="deleted"?`Removed: ${p}`:h.includes("status: superseded")||!f&&b?`Replaced: ${p}${b?` → ${l(b)}`:""}`:h.includes("status: retired")?`Retired: ${p}`:`Changed: ${p}`;return f?{file:u.path,said:g,before:u.status==="added"?null:f.before,after:u.status==="deleted"?null:f.after}:{file:u.path,said:g,before:null,after:null,withheld:dA[u.withheld??""]??"Not shown."}}).sort((u,f)=>Db.indexOf(u.said.split(":")[0])-Db.indexOf(f.said.split(":")[0]))}function pA(e){const t=new Map;for(const n of e)for(const o of n.files){const i=t.get(o)??{};"run"in n.by&&(i.run={id:n.by.run,at:n.at,reason:n.reason}),t.set(o,i)}return t}function Id({run:e,link:t=!1,className:n}){var b;const o=z1(e.learning),i=D1(e.learning),l=wl(e.learning),c=I1(e.learning)&&e.learning.state!=="seeded",u=rg(e.learning),f=X4(e.learning),p=[...Ob(e.learning),...Pb(e.learning)],h=((b=e.learning)==null?void 0:b.state)==="dropped"&&Ku(e.learning.reason)!=="nothing"?ag(e.learning):null;return!o.length&&!i.length&&!l.length&&!c&&!f&&!p.length&&!h?null:s.jsxs("span",{className:ie("inline-flex flex-wrap items-center gap-2",n),"aria-label":"Learning",children:[o.length>0&&s.jsx(uu,{agentId:e.agent_id,refs:o,link:t,kind:"given"}),i.length>0&&s.jsx(uu,{agentId:e.agent_id,refs:i,link:t,kind:"read"}),l.length>0&&s.jsx(uu,{agentId:e.agent_id,refs:l,link:t,kind:"learned",replaces:l.reduce((g,m)=>{var v;return g+(((v=m.supersedes)==null?void 0:v.length)??0)},0)}),f&&s.jsx(uu,{agentId:e.agent_id,refs:u,link:t,kind:"pending"}),h&&s.jsx(hA,{agentId:e.agent_id,said:h,link:t}),["skill","workflow"].flatMap(g=>{const m=(g==="skill"?Ob:Pb)(e.learning);return[!1,!0].map(v=>{const w=m.filter(j=>j.pending===!0===v);return w.length?s.jsx(gA,{agentId:e.agent_id,refs:w,link:t,kind:g,pending:v},`${g}-${v}`):null})}),c&&s.jsxs(Pe,{tone:"active",children:[s.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[s.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),s.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),tA(e.learning.state)]})]})}function hA({agentId:e,said:t,link:n}){const o=s.jsxs(Pe,{tone:"muted",className:ie(n&&"cursor-pointer"),children:[s.jsx(B2,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return n?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[s.jsx("a",{href:Ld(e),"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:o}),s.jsx("span",{className:"text-small text-muted-foreground",children:t})]}):s.jsx("span",{title:`Kept nothing: ${t}`,"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:o})}function gA({agentId:e,refs:t,link:n,kind:o,pending:i}){const l=i?`${qu(t.length,o)} ${t.length===1?"waits":"wait"} for your OK`:`Learned ${qu(t.length,o)}`,c=`${l}: ${t.map(p=>p.name).join(", ")}`,u=i?xh:o==="skill"?Ru:Ho,f=s.jsxs(Pe,{tone:i?"warning":void 0,className:ie(!i&&"border-primary/50 bg-primary/10 text-primary-text",n&&"cursor-pointer"),children:[s.jsx(u,{className:"size-3","aria-hidden":!0}),l]});return n?s.jsx("a",{href:Ld(e),title:c,"aria-label":c,className:"inline-flex",children:f}):s.jsx("span",{title:c,"aria-label":c,className:"inline-flex",children:f})}function uu({agentId:e,refs:t,link:n,kind:o,replaces:i=0}){const l=o==="pending"?B1(t.length):o==="given"?`Started with: ${Ma(t.length)}`:o==="read"?`Read: ${Ma(t.length)}`:`Learned ${Ma(t.length)}`,c=t.map(m=>m.name).join(", "),u=o==="given"||o==="read",f=u?Cu:o==="pending"?xh:vh,p=s.jsxs(Pe,{tone:o==="pending"?"warning":void 0,className:ie(o==="learned"?"border-primary/50 bg-primary/10 text-primary-text":u?"border-border-strong/70 text-foreground/80":"",n&&"cursor-pointer transition-colors group-hover/tip:border-foreground/70"),children:[s.jsx(f,{className:"size-3","aria-hidden":!0}),l]}),h=t.filter(m=>m.file!==H1),b=`${l}${c?`: ${c}`:""}${i?` (replaces ${i===1?"1 older note":`${i} older notes`})`:""}`;if(!n||!h.length&&o!=="pending")return s.jsx("span",{title:b,"aria-label":b,className:"inline-flex",children:p});const g=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"caps block text-micro text-muted-foreground",children:o==="given"?"This run started with":o==="read"?"This run read":o==="learned"?"This run kept":"Waits for your OK before any run reads it"}),t.length>0&&s.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(m=>s.jsx("li",{className:"font-semibold",children:m.name},m.file))}),i>0&&s.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",i===1?"1 older note":`${i} older notes`,"."]}),s.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return s.jsx(E4,{tip:g,children:s.jsx("a",{href:Ld(e,h.map(m=>m.file)),"aria-label":b,className:"inline-flex",children:p})})}function xA({n:e,className:t}){return e<=0?null:s.jsx("span",{"aria-label":og(e),className:ie("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",t),children:e})}function yA(e,t){var i;const n=e??"pi",o=(i=t.find(l=>l.id===n))==null?void 0:i.steer;return typeof o=="boolean"?o:n==="pi"}const Hl={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},vA=new Set(["completed","failed","cancelled"]);function bA(e,t,n,o,i){const c=e==="queued"||e==="working"&&t==="working"?i||n==="workflow"?"steer":"follow_up":e==="input_required"&&t==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!o[c]?null:n==="workflow"?c==="steer"&&o.steer_workflow_runs?c:null:c}const X1=(e,t)=>e==="failed"&&(t==null?void 0:t.code)==="escalated",wA=(e,t)=>e==="completed"&&!!t;function Bl(e,t,n,o,i,l,c){const u=vA.has(e),f=n==="agentic",p=X1(e,l),h=wA(e,c),b=p?"Escalated":h?"Needs review":e==="input_required"?t==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],g=p||h?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",m=bA(e,t,n,o,i);return{label:b,tone:g,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&t==="working",canCancel:!u,canMessage:m!==null,messageMode:m}}const kA={Queued:pv,Working:pv,Completed:dd,Failed:Da,Escalated:H2,"Needs review":Qw,Cancelled:Kw,"Input required":yh,Stopped:ul,Paused:Yw};function Gl({run:e}){const t=Bl(e.status,e.state,e.kind,Hl,!0,e.error,e.review),n=kA[t.label];return s.jsxs(Pe,{tone:t.tone,children:[s.jsx(n,{className:t.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),t.label]})}const va=(e,t={})=>({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".'},...t},required:["op","id",...Object.keys(t).filter(n=>n!=="delay")],additionalProperties:!1}),nr=(e,t=[])=>({type:"object",additionalProperties:!1,properties:e,...t.length?{required:t}:{}}),jA={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:nr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},NA=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."}),SA=e=>`Browse and automate websites in the persistent browser. ${NA.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"}]}.`,_A={name:"run",label:"Browser: run",description:SA(),parameters:nr({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},va("click"),va("hover"),va("fill",{value:{type:"string"}}),va("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),va("press",{key:{type:"string"}}),va("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},EA={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:nr({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:{...nr({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"},$A={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:nr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},TA={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:nr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},CA={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:nr({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"},RA={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:nr({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"},AA={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:nr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},OA={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:nr({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"},PA=Object.freeze([jA,_A,EA,$A,TA,CA,RA,AA,OA]),MA=Object.freeze(PA.map(e=>e.name)),Va=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,Zn=e=>typeof e=="string"?e:void 0,jl=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e,Y1=e=>e.split(`
529
+ `).map(t=>t.trim()).find(Boolean)??"";function Qu(e){try{return Va(JSON.parse(e))}catch{return}}const LA=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Nl(e){const t=LA.exec(e.trim());return jl(t?`${t[1]}${t[2]==="/"?"":t[2]}`:e.split(/[?#]/)[0]??"",80)}const IA="…",zA=/https?:\/\/[^\s"'`<>\\]+/gi,DA=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i;function ig(e){return e.replace(zA,t=>{var l;const n=((l=/[.,;:!?)\]}]+$/.exec(t))==null?void 0:l[0])??"",o=DA.exec(t.slice(0,t.length-n.length));if(!o)return t;const i=[...new Set((o[4]??"").split("&").map(c=>c.split("=")[0]).filter(Boolean))];return`${o[1]}${o[2]}${o[3]}${i.length?`?${i.map(c=>`${c}=${IA}`).join("&")}`:""}${n}`})}const FA=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),UA=new Map,WA=new Map,Q1=new Map;function pn(e,t,n,{name:o}={}){UA.set(e,t),n&&WA.set(e,n),o&&Q1.set(e,o)}const HA=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,BA=e=>{const t=HA.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:void 0},GA=e=>Q1.get(e)??BA(e)??e,qA=new Map;function Z1(e,t){qA.set(e,t)}const VA=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...VA];const lg=e=>Zn(e.path)??Zn(e.file_path),KA=/page\.goto\(\s*["'`]([^"'`]+)/;pn("read",e=>`Read ${lg(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});pn("write",e=>`Wrote ${lg(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});pn("edit",e=>`Edited ${lg(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});pn("bash",e=>`Ran \`${jl(ig(Y1(Zn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const J1=e=>{const t=e&&Va(Qu(e.text)??Qu(Y1(e.text)));if((t==null?void 0:t.ok)!==!1)return;const n=Zn(t.refused);return n!==void 0?{refused:!0,detail:n.replace(/^refused:\s*/,"")}:{refused:!1,detail:Zn(t.error)??Zn(t.message)??"no detail"}},XA=(e,t)=>`${J1(t)?"Tried to fetch":"Fetched"} ${Nl(Zn(e.url)??"a page")}`,YA={many:e=>`Fetched ${e} pages`,subject:e=>e?Nl(e):void 0},QA=e=>{const t=J1(e);return t&&{failed:!0,text:`${t.refused?"refused":"failed"}: ${t.detail}`}};pn("web_fetch",XA,YA,{name:"Fetch web pages"});Z1("web_fetch",QA);pn("web_search",e=>{const t=Zn(e.query);return t?`Searched the web for "${jl(ig(t),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${jl(e,40)}"`:void 0},{name:"Search the web"});Z1("web_search",e=>{var n;const t=Zn((n=Va(Qu(e.text)))==null?void 0:n.error);return t!==void 0?{failed:!0,text:`failed: ${t}`}:void 0});pn("browser_read",(e,t)=>{var o;const n=t&&((o=/^title: (.+)$/m.exec(t.text))==null?void 0:o[1]);return n?`Read the page "${jl(ig(n),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,t)=>{var o;const n=t&&((o=/^url: (\S+)/m.exec(t))==null?void 0:o[1]);return n?Nl(n):void 0}},{name:"Read the browser's page"});pn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});pn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});pn("run",(e,t)=>{var l,c;const n=(l=KA.exec(Zn(e.code)??""))==null?void 0:l[1];if(n)return`Opened ${Nl(n)}`;const o=(c=Va(t==null?void 0:t.details))==null?void 0:c.sent,i=Array.isArray(o)?o.flatMap(u=>{const f=Va(u),[p,h]=[Zn(f==null?void 0:f.method),Zn(f==null?void 0:f.url)];return p&&h?`${p} ${Nl(h)}`:[]}):[];return i.length?`Acted on the page (${i.length} request${i.length===1?"":"s"} sent: ${FA(i)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});pn("browser_downloads",(e,t)=>{var i;const n=t&&((i=Qu(t.text))==null?void 0:i.fetched),o=Array.isArray(n)?n.flatMap(l=>{var c;return Zn((c=Va(l))==null?void 0:c.name)??[]}):[];return o.length===1?`Downloaded ${o[0]}`:o.length?`Downloaded ${o.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});pn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});pn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});pn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});pn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});pn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const ZA=(e,t)=>`mcp:${e}/${t}`;function Zu(e){const t=/^mcp:([^/]+)\/(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const JA=/^[A-Za-z0-9_-]{1,52}$/;function eO(e,t){if(e==="hands")return"hands is the harnesses' own name: save this server under another to grant its tools";const n=`mcp__${e}__${t}`;if(!JA.test(n))return/^[A-Za-z0-9_-]+$/.test(t)?`name too long to grant (${n.length}/52)`:"its name has a character a tool name can't carry"}function tO(e,t,n){const o=t.input_schema,i=n==="claude-agent"&&o&&typeof o=="object"?["anyOf","allOf","oneOf"].find(l=>l in o):void 0;return eO(e,t.name)??(i?`claude-agent drops a tool whose schema's root has ${i}`:void 0)}function nO(e,t){return e.flatMap(n=>{const o=Zu(n);if(!o)return[];const i=t.find(l=>l.name===o.server);return i?i.tools.some(l=>l.name===o.tool)?[]:[{grant:n,why:`${o.server} no longer lists ${o.tool}: refresh it, or untick this.`}]:[{grant:n,why:`The MCP server ${o.server} is not saved here any more, so a run can't call it.`}]})}function Sl(e){var n,o,i,l;if(!(e instanceof Te))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const t=(n=e.fields)==null?void 0:n.find(c=>c.field==="url"&&c.reason==="redirect");return e.code==="auth_required"?((o=e.details)==null?void 0:o.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==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:t?{text:"This address redirects; use the final address.",detail:t.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((i=e.details)==null?void 0:i.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(l=e.fields)!=null&&l.length?{text:e.fields.map(c=>c.message).join(" ")}:{text:`${e.code}: ${e.message}`}}const Fb={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"},sO="the sign-in didn't finish: try again",rO=e=>e&&Object.hasOwn(Fb,e)?Fb[e]:sO;function oO(e){const t=new URLSearchParams(e??""),n=t.get("server"),o=t.get("sign_in");if(!(!n||o!=="ok"&&o!=="failed"))return{server:n,ok:o==="ok",...o==="failed"?{error:t.get("error")??"sign_in_failed"}:{}}}function ql(e){const t=/^mcp:([a-z][a-z0-9-]{0,31})\/(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}function aO(e){const t=/^mcp__([a-z][a-z0-9-]{0,31})__(.+)$/.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:null}const iO={user_message:bh,thinking:W2,tool_use:Ru,tool_result:Ru,waiting:yh,usage:ph,final_answer:Ka,phase:Zw,error:Da,decision:c_,text_block:s_,tool_approval_requested:s0},Ub=e=>{var t;return e.kind==="tool_approval_requested"?(t=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:t[1]:void 0},Wb=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),cg=e=>e.origin==="server",ej=e=>e.origin==="trigger",tj=e=>{var l;const t=e.summary??"",n=(l=e.trigger)==null?void 0:l.name,o=n?t.indexOf(` ${n}: `):-1;if(n&&o>0&&!t.slice(0,o).includes(" "))return{who:t.slice(0,o+1+n.length),said:t.slice(o+n.length+3).trimStart()};const i=/^([^:]+):\s*/.exec(t);return i?{who:i[1],said:t.slice(i[0].length)}:{who:null,said:t}},lO=e=>{const t=ej(e)?tj(e).said:(e.summary??"").replace(cg(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&t.startsWith("{"))try{return Object.entries(JSON.parse(t)).map(([n,o])=>`${n}: ${typeof o=="string"?o:JSON.stringify(o)}`).join(" · ")}catch{}if(e.kind==="final_answer"){const n=(e.text??"").split(`
530
+ `).filter(o=>o.trim()).length>1;return`${t.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"").replace(/(\*\*|__|`)/g,"")}${n?"…":""}`}return t},Wp=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,cO=new Set(MA),Hb=e=>e&&(aO(e)??(cO.has(e)?GA(e):e)),Bb=e=>cg(e)?"AgentRun":ej(e)?tj(e).who??"Trigger":{user_message:"You",thinking:"Thinking",tool_use:Hb(e.tool_name)??"Tool",tool_result:Hb(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,uO={budget:"Paused at cap"};function dO({step:e,last:t,waitingChip:n}){var g;const o=e.row,[i,l]=y.useState(!1),u=J3(o)?Yw:iO[o.kind]??Zw,f=e.above?o.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":lO(o),p=e.above?null:e.detail??w1(o),h=p&&p.trim()!==f.trim()?p:null,b=k1(o);return s.jsxs("li",{className:"relative flex gap-3",children:[s.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[s.jsx("span",{className:ie("mt-3 flex size-7 items-center justify-center border bg-background",(o.kind==="waiting"||Wb(o))&&"border-warning/60 text-warning-text",b&&"border-destructive/60 text-destructive-text"),children:s.jsx(u,{className:"size-3.5","aria-hidden":!0})}),!t&&s.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),s.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[s.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>l(m=>!m),"aria-expanded":i,disabled:!h,children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[s.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:Bb(o),children:Bb(o)}),o.kind==="waiting"&&s.jsx(Pe,{tone:"warning",children:n??"Input required"}),Wb(o)&&s.jsx(Pe,{tone:"warning",children:"Approval required"}),b&&s.jsx(Pe,{tone:"error",children:"Error"}),o.agent_label&&s.jsx(Pe,{children:o.agent_label}),e.ms!==void 0&&s.jsx("span",{className:"font-mono text-label",children:Wp(e.ms)}),e.times&&s.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${Wp(Math.max(0,Date.parse(e.until)-Date.parse(o.timestamp)))}`:""]})]}),s.jsx("span",{className:ie("mt-0.5 block break-words text-prose leading-snug",cg(o)&&"text-muted-foreground"),children:f}),e.saved&&s.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),Ub(o)&&s.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:Ub(o)})]}),s.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:Od(o.timestamp)}),h&&s.jsx(Fs,{className:ie("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),"aria-hidden":!0})]}),i&&h&&s.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(g=o.learned_nodes)!=null&&g.length?s.jsx(mO,{nodes:o.learned_nodes}):null]})]})}const fO={ok:"success",failed:"error",escalated:"warning"};function mO({nodes:e}){const[t,n]=y.useState(!1),o=Object.entries(e.reduce((l,c)=>({...l,[c.status]:(l[c.status]??0)+1}),{})).filter(([l])=>l!=="ok"),i=[`${e.length} ${e.length===1?"node":"nodes"}`,...o.map(([l,c])=>`${c} ${l}`)].join(" · ");return s.jsxs("div",{className:"mt-2",children:[s.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>n(l=>!l),"aria-expanded":t,"aria-label":`${t?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[s.jsx(Fs,{className:ie("size-3 transition-transform",t&&"rotate-90"),"aria-hidden":!0}),s.jsx(Ho,{className:"size-3","aria-hidden":!0}),i]}),t&&s.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((l,c)=>s.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[s.jsx("span",{"data-status":l.status,className:"contents",children:s.jsx(Pe,{tone:fO[l.status]??"muted",className:"w-[5.5rem] justify-center",children:l.status})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:l.label,children:l.label}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:l.kind}),s.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Wp(l.duration_ms)})]},c))})]})}function nj({rows:e,live:t,fold:n=6,asking:o,waitingOn:i}){var g;const l=i==="budget"?e.findLastIndex(m=>m.paused===!0):-1,c=l>=0?(g=e.slice(l+1).findLast(m=>m.kind==="waiting"))==null?void 0:g.id:void 0,[u,f]=y.useState(!1),p=e4(e).map(m=>o&&m.row.id===o?{...m,above:!0}:m),h=u?0:Math.max(0,p.length-n),b=p.slice(h);return e.length?s.jsxs("div",{children:[h>0&&s.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:()=>f(!0),children:[s.jsx(Fs,{className:"size-3","aria-hidden":!0})," ",h," earlier steps"]}),s.jsx("ol",{children:b.map((m,v)=>s.jsx(dO,{step:m,last:v===b.length-1&&!t,waitingChip:m.row.id===c&&i?uO[i]:void 0},m.row.id))}),t&&s.jsx(Hp,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):s.jsx(Hp,{title:t?"The run is starting":"Nothing on the timeline",note:t?"Steps appear here as the agent works.":"This run recorded no steps.",spin:t})}function Hp({title:e,note:t,spin:n=!0}){return s.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[n&&s.jsx(S4,{className:"size-5"}),s.jsx("p",{className:"caps text-label font-semibold",children:e}),s.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:t})]})}const Gb=new Set(["completed","failed","cancelled"]),pO={firstMs:2e3,maxMs:16e3,totalMs:12e4};function sj(e,t,n,o=pO){var h;const i=!!e&&Gb.has(e.status)&&I1(e.learning),l=y.useRef(t);l.current=t;const c=y.useRef(n);c.current=n;const u=(h=e==null?void 0:e.learning)==null?void 0:h.state,f=!!e&&Gb.has(e.status),p=y.useRef(u);y.useEffect(()=>{var g;const b=p.current;p.current=u,b!==void 0&&b!==u&&f&&((g=c.current)==null||g.call(c))},[u,f]),y.useEffect(()=>{if(!i)return;let b,g=0,m=o.firstMs,v=!1,w=!1;const j=()=>{w||g+m>o.totalMs||(b=setTimeout(S,m))},S=()=>{if(b=void 0,document.visibilityState==="hidden"){v=!0;return}g+=m,m=Math.min(m*2,o.maxMs),l.current(),j()},T=()=>{v&&document.visibilityState!=="hidden"&&(v=!1,S())};return document.addEventListener("visibilitychange",T),j(),()=>{w=!0,b&&clearTimeout(b),document.removeEventListener("visibilitychange",T)}},[i])}function hO({v2:e,run:t,onRun:n}){const[o,i]=y.useState(null),[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),[b,g]=y.useState(!1),[m,v]=y.useState(0),w=y.useRef(Bu()).current,j=y.useRef(`${t.status}/${t.state}`),S=y.useRef(null),T=y.useRef(j.current),E=async R=>{const C=w.begin();S.current=R;let O="";for(const I of zp){if(I&&await T1(I),!w.current(C))return;try{const D=await e.getRun(t.run_id);if(!w.current(C))return;j.current=R,S.current=null,h(null),n(D);return}catch(D){O=jn(D)}}w.current(C)&&(S.current=null,h(O))};y.useEffect(()=>{const R=new AbortController;return Jh(e,t.run_id,{signal:R.signal,onRows:i,onPage:C=>{f({status:C.status,state:C.state});const O=`${C.status}/${C.state}`,I=O!==T.current;if(T.current=O,O===j.current){w.cancel(),S.current=null,h(null);return}(I||S.current===null)&&E(O)}}).catch(C=>{R.signal.aborted||c(jn(C))}),()=>{R.abort(),w.cancel(),S.current=null}},[e,t.run_id,m]),sj(t,()=>{const R=j.current;e.getRun(t.run_id).then(C=>{j.current===R&&S.current===null&&n(C)},()=>{})},()=>v(R=>R+1));const _=`#/runs/${encodeURIComponent(t.run_id)}`,$=u??t;return s.jsxs("section",{className:"mb-6 border","aria-label":"Latest run",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-2",children:[s.jsx("span",{className:"caps text-label font-semibold",children:"Latest run"}),p?s.jsx(Pe,{tone:"muted",children:"Not refreshed"}):s.jsx(Gl,{run:t}),s.jsx("a",{href:_,className:"min-w-0 flex-1 truncate text-lead hover:underline",title:tn(t),children:tn(t)}),s.jsx(Id,{run:t,link:!0}),s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Rt(t.created_at)}),s.jsxs("a",{href:_,className:qa({size:"sm"}),children:["Open the run ",s.jsx(fh,{"aria-hidden":!0})]})]}),p&&s.jsxs("p",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2 font-mono text-small text-destructive-text",role:"alert",children:["This run could not be refreshed: ",p,s.jsx(Z,{type:"button",disabled:b,onClick:()=>{g(!0),E(T.current).finally(()=>g(!1))},size:"xs",className:"text-foreground",children:b?"Retrying":"Retry"})]}),s.jsx("div",{className:"px-4 py-3",children:l?s.jsxs("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:["The timeline could not be read: ",l]}):o?s.jsx(nj,{rows:K1(o,t.learning),live:Bl($.status,$.state,t.kind,Hl,!0).live}):s.jsx("p",{className:"py-6 text-center font-mono text-body text-muted-foreground",children:"Reading the timeline..."})})]})}function _n({problem:e,onRetry:t,link:n,className:o="m-8"}){return s.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${o}`,role:"alert",children:[s.jsx(Js,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-prose font-semibold",children:e.title}),s.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&s.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(t||n)&&s.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[t&&s.jsx(Z,{type:"button",onClick:t,size:"sm",children:"Try again"}),n&&s.jsx("a",{href:n.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:n.label})]})]})]})}function rj({what:e,id:t,list:n}){return s.jsx(_n,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${t}.`,next:`Check the address, or find the ${e} in the list.`},link:n})}function gO(e,{base:t="/v2",onProgress:n,signal:o,request:i=()=>new XMLHttpRequest}={}){return new Promise((l,c)=>{if(o!=null&&o.aborted)return c(new Te(0,"aborted","The upload was stopped."));const u=i();u.open("POST",`${t}/files?path=${encodeURIComponent(e.name)}`),u.setRequestHeader("accept","application/json"),e.type&&u.setRequestHeader("content-type",e.type),u.upload.onprogress=f=>{f.lengthComputable&&f.total>0&&(n==null||n(Math.min(1,f.loaded/f.total)))},u.onload=()=>{let f=null;try{f=JSON.parse(u.responseText)}catch{}if(u.status===201||u.status===200){const b=f==null?void 0:f.file;return b!=null&&b.file_id?(n==null||n(1),l(b)):c(new Te(u.status,"bad_answer","The server's answer named no file."))}const p=f==null?void 0:f.error,h=new Te(u.status,(p==null?void 0:p.code)??"http_error",(p==null?void 0:p.message)??`The server answered ${u.status}.`,(p==null?void 0:p.retryable)??!1,p==null?void 0:p.request_id);p!=null&&p.fields&&(h.fields=p.fields),c(h)},u.onerror=()=>c(new Te(0,"network","The upload did not reach the server.")),u.onabort=()=>c(new Te(0,"aborted","The upload was stopped.")),o==null||o.addEventListener("abort",()=>u.abort(),{once:!0}),u.send(e)})}const oj=(e,t,n)=>gO(e,{onProgress:t,signal:n});function rp(e){if(!(e instanceof Te))return e instanceof Error?e.message:String(e);const t=(e.fields??[]).filter(n=>n.message!==e.message).map(n=>n.message);return[e.message,...t].join(" ")}function aj({upload:e,remove:t,limits:n,frozen:o=!1}){const[i,l]=y.useState([]),[c,u]=y.useState([]),f=y.useRef(new Map),p=y.useRef(0),h=y.useRef(0);h.current=i.length;const b=y.useRef({items:i,frozen:o,remove:t});b.current={items:i,frozen:o,remove:t};const g=y.useRef(!0);y.useEffect(()=>{g.current=!0;const S=f.current;return()=>{var $;g.current=!1;for(const R of S.values())R.abort();const{items:T,frozen:E,remove:_}=b.current;if(!E)for(const R of T)R.file&&!R.removing&&(($=_==null?void 0:_(R.file.file_id))==null||$.catch(()=>{}))}},[]);const m=y.useCallback(S=>{if(b.current.frozen)return;const T=[],E=n?n.max_files_per_run-h.current:1/0,_=(n==null?void 0:n.max_upload_bytes)??null,$=[];for(const C of S)_!==null&&C.size>_?T.push({text:`${C.name} is ${Wa(C.size)}: this server takes files up to ${Wa(_)}.`}):$.length>=E?T.push({text:`${C.name} is not added: a run names at most ${n==null?void 0:n.max_files_per_run} files here.`}):$.push(C);u(T);const R=$.map(C=>({key:`f${p.current++}`,name:C.name,size:C.size,progress:0}));h.current+=R.length,l(C=>[...C,...R]),R.forEach((C,O)=>{const I=new AbortController;f.current.set(C.key,I);const D=z=>{g.current&&l(H=>H.map(F=>F.key===C.key?{...F,...z}:F))};e($[O],z=>D({progress:z}),I.signal).then(z=>{var H,F,U;if(f.current.delete(C.key),I.signal.aborted){(U=(F=(H=b.current).remove)==null?void 0:F.call(H,z.file_id))==null||U.catch(X=>{g.current&&u(P=>[...P,{text:`${C.name} was sent before it was stopped, and was not removed: ${rp(X)}`}])});return}D({file:z,progress:1})},z=>{f.current.delete(C.key),!(I.signal.aborted||!g.current)&&(l(H=>H.filter(F=>F.key!==C.key)),u(H=>[...H,{text:`${C.name}: ${rp(z)}`}]))})})},[n==null?void 0:n.max_files_per_run,n==null?void 0:n.max_upload_bytes,e]),v=y.useCallback(S=>{var R;const{items:T,frozen:E,remove:_}=b.current,$=T.find(C=>C.key===S);if(!(E||!$||$.removing)){if(!$.file||!_){(R=f.current.get(S))==null||R.abort(),f.current.delete(S),l(C=>C.filter(O=>O.key!==S));return}l(C=>C.map(O=>O.key===S?{...O,removing:!0}:O)),u(C=>C.filter(O=>O.about!==S)),_($.file.file_id).then(()=>{g.current&&l(C=>C.filter(O=>O.key!==S))},C=>{g.current&&(l(O=>O.map(I=>I.key===S?{...I,removing:!1}:I)),u(O=>[...O,{about:S,text:`${$.name} was not removed: ${rp(C)}`}]))})}},[]),w=y.useCallback(()=>{b.current={...b.current,items:[]},l([]),u([])},[]),j=i.flatMap(S=>S.file&&!S.removing?[S.file.file_id]:[]);return{items:i,refusals:c.map(S=>S.text),add:m,drop:v,clear:w,fileIds:j,frozen:o,busy:i.some(S=>!S.file||S.removing)}}function Bp({attachments:e,limits:t,disabled:n,compact:o=!1}){const i=y.useRef(null),[l,c]=y.useState(!1),{items:u,refusals:f,add:p,drop:h}=e,b=n||e.frozen,g=t?[`up to ${t.max_files_per_run} files`,...t.max_upload_bytes!==null?[`${Wa(t.max_upload_bytes)} each`]:[]].join(", "):"";return s.jsxs("div",{className:ie("border border-dashed px-3 py-2.5",l?"border-primary bg-primary/5":"border-border",o&&"max-sm:border-0 max-sm:p-0"),onDragOver:m=>{b||(m.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:m=>{m.preventDefault(),c(!1),b||p([...m.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Z,{type:"button",size:"sm",onClick:()=>{var m;return(m=i.current)==null?void 0:m.click()},disabled:b,title:o?`Attach files${g?` (${g})`:""}`:void 0,className:ie(o&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[s.jsx(a_,{"aria-hidden":!0})," ",s.jsx("span",{className:ie(o&&"max-sm:sr-only"),children:"Attach files"})]}),s.jsxs("span",{className:ie("text-small text-muted-foreground",o&&"max-sm:hidden"),children:["or drop them here",g?` (${g})`:"",". The run finds them in inputs/."]}),s.jsx("input",{ref:i,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:m=>{p([...m.target.files??[]]),m.target.value=""}})]}),u.length>0&&s.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:u.map(m=>s.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[s.jsx("span",{className:"max-w-[16rem] truncate",title:m.name,children:m.name}),s.jsx("span",{className:"text-muted-foreground",children:Wa(m.size)}),!m.file&&s.jsxs("span",{className:"text-muted-foreground","aria-label":`${m.name} sent ${Math.round(m.progress*100)}%`,children:[Math.round(m.progress*100),"%"]}),m.removing&&s.jsx("span",{className:"text-muted-foreground",children:"removing"}),s.jsx("button",{type:"button",onClick:()=>h(m.key),disabled:b||m.removing,"aria-label":`Remove ${m.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:s.jsx(Ol,{className:"size-3.5","aria-hidden":!0})})]},m.key))}),u.some(m=>!m.file)&&s.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),f.length>0&&s.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:f.map((m,v)=>s.jsx("li",{children:m},`${v}:${m}`))})]})}const xO=["pi","claude-agent","codex","opencode"];function yO(e){const t=new Set,n=o=>{if(Array.isArray(o)){o.forEach(n);return}if(!o||typeof o!="object")return;const i=o;i.node==="call"&&typeof i.tool=="string"&&t.add(i.tool),Object.values(i).forEach(n)};return n(e),[...t].sort()}function vO(e){const t=n=>Array.isArray(n)&&n.every(o=>typeof o=="string")?[...new Set(n)]:[];return{denied:t(e==null?void 0:e.denied),asks:t(e==null?void 0:e.asks)}}function bO(e){return(Array.isArray(e)?e:[]).flatMap(t=>{const n=t;return!n||typeof n.name!="string"||!Array.isArray(n.providers)||!n.providers.length?[]:[{name:n.name,providers:n.providers,provider:n.provider??n.providers[0],default_provider:n.default_provider??n.providers[0],resolves:n.resolves&&typeof n.resolves=="object"?n.resolves:{},available:n.available!==!1,...typeof n.reason=="string"&&n.reason?{reason:n.reason}:{}}]})}const ug="Refused on this server for every agent, whatever the agent's own setting or Never ask.",wO="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.",ij=(e,t,n,o)=>{var u;const i=n==null?void 0:n.find(f=>f.name===e);if(i)return i.permission==="deny"&&i.permission_from==="server";const l=/^mcp:([^/]+)\/(.+)$/.exec(e),c=l?(u=o==null?void 0:o.find(f=>f.name===l[1]))==null?void 0:u.tools.find(f=>f.name===l[2]):void 0;return c?c.permission==="deny":t.some(f=>f.name===e&&f.permission==="deny")};function kO(e){return(e??[]).map(({name:t,permission:n,default_permission:o,permissions:i,ask_needs:l})=>({name:t,permission:n,default_permission:o,permissions:i,...l==="password"?{ask_needs:l}:{}}))}const jO={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},lj={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."}}},Ju=(e,t)=>{var n;return(t&&((n=lj[t])==null?void 0:n.label[e]))??jO[e]??e},NO={auto:"The harness's own search, or the model provider's hosted one, 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."},qb=(e,t)=>{var n;return(t&&((n=lj[t])==null?void 0:n.help[e]))??NO[e]};function cj(e,t){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Ju(e,t),unavailable:!1}:{text:"not known",unavailable:!1}}function uj(e,t,n,o,i){const{[t]:l,...c}=e,{[n]:u,...f}=l??{},p=o===void 0||o===i?f:{...f,[n]:o};return Object.keys(p).length?{...c,[t]:p}:c}const SO=(e,t,n,o)=>uj(e,t,"provider",n,o),_O=(e,t,n,o)=>uj(e,t,"permission",n,o);function Vb(e,t){const n=new Map(t.map(o=>[o.name,o.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([o,i])=>{if(!i||typeof i!="object")return[];const{provider:l,...c}=i,u=l!==void 0&&!(n.has(o)&&l===n.get(o))?{...c,provider:l}:c;return Object.keys(u).length?[[o,u]]:[]}))}function dj(e,t,n){const o={},i=[];for(const[l,c]of Object.entries(e)){if(t&&l!==t&&!l.startsWith(`${t}.`)&&!l.startsWith(`${t}/`))continue;const u=t?l.slice(t.length+1):l,f=[...n].sort((p,h)=>h.length-p.length).find(p=>u===p||u.startsWith(`${p}.`)||u.startsWith(`${p}/`));f?(o[f]??(o[f]=[])).push(c):i.push(c)}return{byTool:o,rest:i}}const EO=e=>{if(!Array.isArray(e))return[e];const t=[...new Set(e.filter(n=>n!==null).map(n=>JSON.stringify(n)))].sort();return[...e.includes(null)?[null]:[],...t.map(n=>JSON.parse(n))]},$O=e=>typeof e=="string"?e:JSON.stringify(e);function TO(e){return Object.keys(e).sort().map(t=>{const n=EO(e[t]),o=n[0]===null,i=(o?n.slice(1):n).map(c=>$O(c));if(!i.length)return`${t} must be left out`;const l=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${t} must be ${o?`left out or ${l}`:l}`}).join("; ")}const CO="Calls outside it are refused before they run or ask.",RO="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.";function fj({agentId:e,details:t}){const{denied:n,asks:o}=vO(t),i=[...new Set([...n,...o])];return i.length?s.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[i.map(l=>s.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(l)}`,className:"underline underline-offset-4",children:["Set ",l," for this agent"]},l)),s.jsxs("span",{children:["or for every agent: ",s.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function zd(){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 t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Us(e=zd){let t=null;return{keyFor(n,o){const i=JSON.stringify([n,o]);return(t==null?void 0:t.request)!==i&&(t={request:i,key:e()}),t.key},done(){t=null}}}async function mj(e,t,n,o){const i=await o(t,n,e.keyFor(t,{content:n}));return e.done(),i}function AO(e=zd){const t=new Map;return n=>{let o=t.get(n);return o||(o=Us(e),t.set(n,o)),o}}function pj(e,t){const n=new Set(e.map(o=>o.run_id));return[...e,...t.filter(o=>!n.has(o.run_id))]}function hj(e,t){var i,l;let n;if(e==="agentic"){if(!t.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};n={content:t.text}}else try{n=JSON.parse(t.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const o={input:n};if(t.revision&&(o.revision=t.revision),t.effort&&(o.effort=t.effort),e==="agentic"&&((i=t.maxCostUsd)!=null&&i.trim())){const c=Number(t.maxCostUsd);if(!Number.isFinite(c)||c<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};o.max_cost_usd=c}return(l=t.fileIds)!=null&&l.length&&(o.file_ids=[...t.fileIds]),{ok:!0,body:o}}function OO(e,t){return n=>{var i,l,c;const o=new Set;for(;n!=null&&n.$ref&&!o.has(n.$ref);){o.add(n.$ref);const u=(l=(i=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(n.$ref))==null?void 0:i[1])==null?void 0:l.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??(Object.hasOwn(t,u)?t[u]:void 0);if(!f)break;n=f}return n}}function gj(e,t){if(e.from==="example")return`The workflow's example input. Edit it, then ${t}.`;const n=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The workflow's input, its required fields empty. Fill them in, then ${t}.${n}`}function xj(e){var p,h,b;const t=e,n=(p=t==null?void 0:t.input)!=null&&p.schemaId?(h=t.schemas)==null?void 0:h[t.input.schemaId]:void 0;if(!n)return null;const o=OO(n,(t==null?void 0:t.schemas)??{}),i=o(n),l=Object.entries(i.properties??{}).map(([g,m])=>{const v=o(m);return{name:g,...v!=null&&v.description?{note:v.description}:{}}}),c=((b=i.examples)==null?void 0:b[0])??i.default;if(c!==void 0)return{text:JSON.stringify(c,null,2),from:"example",fields:l,optional:[]};const u=(g,m=0)=>{var j,S;const v=o(g);if(!v||m>4)return null;if((j=v.examples)!=null&&j.length)return v.examples[0];if(v.default!==void 0)return v.default;if((S=v.enum)!=null&&S.length)return v.enum[0];const w=Array.isArray(v.type)?v.type[0]:v.type;return w==="object"||v.properties?Object.fromEntries(Object.entries(v.properties??{}).filter(([T])=>(v.required??[]).includes(T)).map(([T,E])=>[T,u(E,m+1)])):w==="array"?[]:w==="string"?"":w==="number"||w==="integer"?0:w==="boolean"?!1:null},f=new Set(i.required??[]);return{text:JSON.stringify(u(i),null,2),from:"shape",fields:l,optional:l.map(g=>g.name).filter(g=>!f.has(g))}}const op=e=>`'${e.replace(/'/g,"'\\''")}'`;function PO(e,t,n,o){return[`curl -X POST ${op(`${e}/v2/agents/${t?encodeURIComponent(t):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_TOKEN" \\'," -H 'Content-Type: application/json' \\",` -H ${op(`Idempotency-Key: ${o}`)} \\`,` -d ${op(JSON.stringify(n))}`].join(`
531
+ `)}const MO=e=>e>=200&&e<300;async function yj(e,t,n,o){const i=await o(t,n,e.keyFor(t,n));return MO(i.status)&&e.done(),i}function LO({agent:e,efforts:t,v2:n,go:o,blocked:i,limits:l,upload:c=oj}){const u=e.kind==="workflow",f=y.useMemo(()=>u?xj(e.definition.workflow):null,[u,e.definition.workflow]),[p,h]=y.useState((f==null?void 0:f.text)??""),[b,g]=y.useState(""),[m,v]=y.useState(null),w=y.useMemo(()=>Us(),[]),[j,S]=y.useState(!1),T=aj({upload:c,remove:n.deleteUpload,limits:l,frozen:j}),E=hj(e.kind,{text:p,effort:b,fileIds:T.fileIds}),_=async(O,I,D)=>{var z;try{const H=await n.startRun(O,I,D);return{status:H.status,runId:H.run.run_id}}catch(H){return H instanceof Te?{status:H.status,problem:{message:H.message,fields:H.fields,...H.code==="agent_not_runnable"&&typeof((z=H.details)==null?void 0:z.box)=="string"?{box:H.details.box}:{},...H.code==="agent_not_runnable"&&H.details?{details:H.details}:{}}}:{status:0,problem:{message:H instanceof Error?H.message:String(H)}}}},$=y.useRef(!0);y.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const R=async()=>{if(!E.ok||j||i||T.busy)return;S(!0),v(null);const O=await yj(w,e.agent_id,E.body,_);$.current&&(S(!1),O.runId?(T.clear(),o(`#/runs/${encodeURIComponent(O.runId)}`)):v(O.problem??{message:`The server answered ${O.status}.`}))},C=((m==null?void 0:m.fields)??[]).filter(O=>O.message!==(m==null?void 0:m.message));return s.jsxs("section",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8","aria-label":"Start a run",children:[s.jsxs("div",{"data-phone-row":!0,className:"max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:gap-x-2 max-sm:gap-y-2",children:[s.jsxs("div",{className:"flex flex-col gap-3 max-sm:contents lg:flex-row lg:items-start",children:[s.jsx(Ns,{value:p,onChange:O=>h(O.target.value),rows:u?6:2,spellCheck:!u,"aria-label":u?"The run's input, as JSON":"The run's first message",placeholder:u?"The workflow's input, as JSON":"The run's first message",onKeyDown:O=>{O.key==="Enter"&&(O.metaKey||O.ctrlKey)&&(O.preventDefault(),R())},className:ie("min-w-0 flex-1 resize-y max-sm:order-first max-sm:basis-full",u?"leading-[1.6]":"max-sm:h-10")}),s.jsxs("div",{className:"flex shrink-0 items-center gap-3 max-sm:order-last max-sm:gap-2",children:[t.length>0&&s.jsxs("div",{className:"flex items-center gap-2",title:"How hard the model thinks before it answers. default leaves it to the agent.",children:[s.jsxs("span",{className:"flex flex-col leading-tight",children:[s.jsx("label",{htmlFor:"runbar-effort",className:"caps text-label text-muted-foreground",children:"Effort"}),s.jsx("span",{className:"text-label text-muted-foreground max-sm:hidden",children:"How hard the model thinks"})]}),s.jsx(qt,{id:"runbar-effort",label:"Effort",value:b,onChange:g,className:"w-32",options:["",...t].map(O=>({value:O,label:O||"default"}))})]}),s.jsxs(Z,{variant:"solid",onClick:()=>void R(),disabled:!E.ok||j||!!i||T.busy,title:i??(T.busy?"Waiting for the files to be sent":void 0),children:[s.jsx(Al,{"aria-hidden":!0})," ",j?"Starting":"Run"]})]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-sm:mt-0",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Bp,{attachments:T,limits:l,disabled:!!i,compact:!0})}),s.jsx(sg,{label:"Run with your coding agent",className:"max-sm:hidden",unavailable:T.items.length?"Remove the attached files first: they are for a run started here, and are deleted when you leave this page. Your coding agent uploads its own.":void 0,context:()=>({kind:"run",agentId:e.agent_id,revision:e.revision,...E.ok?{input:E.body.input}:{},...b?{effort:b}:{}})})]})]}),f&&s.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:gj(f,"run")}),!E.ok&&p.trim()&&s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:E.message}),m&&s.jsxs("div",{className:"mt-3 border border-destructive/50 bg-destructive/10 px-3 py-2 font-mono text-small text-destructive-text",role:"alert",children:[s.jsxs("p",{children:["The run did not start: ",m.message]}),m.box&&s.jsxs("p",{className:"mt-1",children:["This server can't run the ",m.box," box this agent runs in: change where it runs in its settings."]}),s.jsx(fj,{agentId:e.agent_id,details:m.details}),C.length>0&&s.jsx("ul",{className:"mt-1",children:C.map(O=>s.jsxs("li",{children:[O.field,": ",O.message]},`${O.field}:${O.message}`))})]})]})}function dn({className:e}){return s.jsx("span",{"aria-hidden":!0,className:ie("block bg-muted motion-safe:animate-pulse",e)})}function Dd({label:e,className:t,children:n}){return s.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:t,children:[n,s.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function IO(){return s.jsxs(Dd,{label:"Loading Mission Control",className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[s.jsx(dn,{className:"h-8 w-56"}),s.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,t)=>s.jsxs("div",{className:"border p-4",children:[s.jsx(dn,{className:"h-3 w-16"}),s.jsx(dn,{className:"mt-3 h-6 w-12"})]},t))}),s.jsx(dn,{className:"h-48 w-full"}),s.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[s.jsx(ed,{n:4}),s.jsx(ed,{n:6})]})]})}function ed({n:e}){return s.jsx("div",{className:"border",children:Array.from({length:e},(t,n)=>s.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[s.jsx(dn,{className:"h-4 w-20"}),s.jsx(dn,{className:"h-4 flex-1"}),s.jsx(dn,{className:"hidden h-4 w-24 sm:block"})]},n))})}function Ss({label:e,rows:t=8}){return s.jsx(Dd,{label:e,children:s.jsx(ed,{n:t})})}function zO(){return s.jsxs(Dd,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[s.jsxs("div",{className:"space-y-3 border-b pb-6",children:[s.jsx(dn,{className:"h-4 w-24"}),s.jsx(dn,{className:"h-7 w-2/3"}),s.jsx(dn,{className:"h-3 w-1/3"})]}),s.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,t)=>s.jsx(dn,{className:"h-4 w-16"},t))}),s.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,t)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsx(dn,{className:"size-4 shrink-0"}),s.jsx(dn,{className:ie("h-4",t%2?"w-1/2":"w-3/4")})]},t))})]})}function DO(){return s.jsxs(Dd,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(dn,{className:"h-7 w-64"}),s.jsx(dn,{className:"h-3 w-80 max-w-full"})]}),s.jsx(dn,{className:"h-12 w-full"}),s.jsx(ed,{n:5})]})}const FO=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),UO=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function Uo(e,t){var c,u;const n=`${FO(t)} could not be read.`;if(UO(e))return{title:n,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Te))return{title:n,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const o=((u=(c=e.fields)==null?void 0:c[0])==null?void 0:u.message)??e.message,i=[e.code,e.requestId].filter(Boolean).join(" · "),l=(f,p)=>({title:n,why:f,next:p,said:o,code:i});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("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?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?l("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function js({problem:e,onRetry:t,className:n="m-8"}){return s.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${n}`,role:"alert",children:[s.jsx(Js,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-prose font-semibold",children:e.title}),s.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&s.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),t&&s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:s.jsx(Z,{type:"button",onClick:t,size:"sm",children:"Try again"})})]})]})}function vj({id:e,checked:t,onChange:n,busy:o,disabled:i,quiet:l,server:c,problem:u,className:f}){return s.jsxs("div",{className:ie("space-y-2",f),children:[s.jsxs("div",{className:ie("flex gap-4",l?"items-center":"items-start"),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!l&&s.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"After each run, it looks back and keeps a short note when something will help next time; later runs read them first."})]}),s.jsx(_4,{checked:t,onChange:n,busy:o,disabled:i,labelledBy:e})]}),c==="off"&&s.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."}),u]})}function WO({fields:e,onFields:t,saved:n,server:o,error:i,warning:l}){const c=(e.learning??n)===!0;return s.jsxs("div",{children:[s.jsx("div",{className:"mb-2",children:s.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),s.jsx(vj,{id:"learning-switch",className:"border px-4 py-3",checked:c,server:o,onChange:u=>t({learning:u?!0:n===void 0?void 0:!1})}),i&&s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:i}),l&&s.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:l})]})}const HO="http://www.w3.org/2000/svg",ba=16,Ct=240,BO=40,GO=58,ap=16,ip=26,du=18,wa=14,Kb=16,qO=26,VO=14,KO=22,ps=14,Xb=16,fu=16,XO=4,YO=10,QO=18,ZO=30,JO=5,tl=124,Gp=34,e5=4,lp=10*.6,t5=12.5*.6,_l=10.5*.6,Yb=11*.6,dg=9*.66,Qb=10.5*.6,n5={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"},fg=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),td={review:"needs review","not-run":"",pending:""};function Je(e,t,...n){const o=document.createElementNS(HO,e);if(t)for(const[i,l]of Object.entries(t))o.setAttribute(i,String(l));for(const i of n)Qn(o,i);return o}function Qn(e,t){if(t!=null){if(Array.isArray(t)){for(const n of t)Qn(e,n);return}e.appendChild(typeof t=="string"?document.createTextNode(t):t)}}const Zs=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,s5=(e,t)=>{const n=/^(.*) (\d\.\d\d)$/.exec(e);return!n||e.length<=t?Zs(e,t):`${Zs(n[1],Math.max(2,t-n[2].length-1))} ${n[2]}`},Zr=(e,t)=>Math.max(2,Math.floor(e/t)),ro=(e,t)=>Math.ceil(e.length*t),xs=(e,t,n,o,i)=>Je("line",{x1:e,y1:t,x2:n,y2:o,class:i?`wire ${i}`:"wire"});function bj(e){const t={},n={};for(const i of e)t[i.path]=i;const o=i=>{var l;return((l=t[i])==null?void 0:l.kind)??""};for(const i of e){let l;const c={node:i,order:0,name:null};let u=null;(l=/^(.*)\/steps\/(\d+)$/.exec(i.path))&&o(l[1])==="chain"?(u=l[1],c.order=Number(l[2])):(l=/^(.*)\/branches\/([^/]*)\/body$/.exec(i.path))&&o(l[1])==="route"?(u=l[1],c.name=l[2].replace(/~1/g,"/").replace(/~0/g,"~")):(l=/^(.*)\/branches\/(\d+)$/.exec(i.path))&&o(l[1])==="parallel"?(u=l[1],c.order=Number(l[2])):((l=/^(.*)\/body$/.exec(i.path))&&(o(l[1])==="map"||o(l[1])==="loop")||(l=/^(.*)\/workflow\/root$/.exec(i.path))&&o(l[1])==="workflow")&&(u=l[1]),u!==null&&(n[u]??(n[u]=[])).push(c)}for(const i of Object.values(n))i.sort((l,c)=>l.order-c.order);return{byPath:t,kids:n}}function mg(e,t){var f,p,h,b;const{diff:n={},status:o={},fired:i}=e.marks,l=t===i?"escalated":o[t],c=l&&fg.has(l)?l:"",u=(f=n.added)!=null&&f.includes(t)?"NEW":(p=n.edited)!=null&&p.includes(t)?"EDITED":(h=n.moved)!=null&&h.includes(t)?"MOVED":"";return{state:c,tag:u,fired:t===i,selected:((b=e.marks.selected)==null?void 0:b.path)===t&&e.marks.selected.item==null}}function Vl(e,t,n){var h,b;const o=mg(e,t.path),i=(h=e.marks.meta)==null?void 0:h[t.path],l=i!=null&&i.tool?ql(i.tool):null;let c=`${t.label} (${t.kind}${l?`: ${l.tool} on ${l.server}, an MCP server's tool`:t.via?` via ${t.via}`:""}${i!=null&&i.provider?`, ${i.provider}${i.model?` ${i.model}`:""}`:""})`;o.state&&(c+=`: ${o.state.replace("-"," ")}`),o.tag&&(c+=`${o.state?", ":": "}${o.tag.toLowerCase()}`),(b=i==null?void 0:i.questions)!=null&&b.length&&(c+=`
532
+ ${i.questions.map(g=>`• ${g.text}`).join(`
533
+ `)}`);const u=i!=null&&i.decision&&i.provider?`who-${i.provider==="parallel"||i.provider==="openrouter"?i.provider:"jev"}`:t.kind==="route"&&i&&!i.decision?"who-control":`who-${n5[t.kind]??"code"}`;let f=`node ${n} ${u}`;o.state&&(f+=` ${o.state}`),o.fired&&(f+=" fired"),o.tag&&(f+=` ${o.tag.toLowerCase()}`),o.selected&&(f+=" selected");const p=Je("g",{class:f,"data-path":t.path},Je("title",null,c));return e.svg.appendChild(p),p}const Ia=e=>ro(e,dg)+10;function $u(e,t,n,o,i="tag"){const l=Ia(o);return Qn(e,[Je("rect",{x:t,y:n,width:l,height:13,class:`${i}-box`}),Je("text",{x:t+l/2,y:n+9.5,class:i,"text-anchor":"middle"},o)]),l}const r5=(e,t)=>{var n,o;return!!((o=(n=e.marks.meta)==null?void 0:n[t.path])!=null&&o.decision)},Fd=(e,t)=>r5(e,t)?GO:BO;function pg(e,t,n,o,i){var j,S,T,E;const l=mg(e,n.path),c=(j=e.marks.meta)==null?void 0:j[n.path],u=Fd(e,n),f=(S=e.marks.verdict)==null?void 0:S[n.path],p=l.state in td?td[l.state]:l.state,h=((T=c==null?void 0:c.questions)==null?void 0:T.length)??0,b=c!=null&&c.tool?ql(c.tool):null,g=n.kind+(b?` · ${b.tool} on ${b.server}`:c!=null&&c.tool?` · ${c.tool}`:n.via?` · ${n.via}`:"")+(c!=null&&c.decision&&h?` · ${h} ${h===1?"question":"questions"}`:""),m=[(E=c==null?void 0:c.images)!=null&&E.length?"IMG":"",c!=null&&c.web?"WEB":"",b?"MCP":""].filter(Boolean),v=m.reduce((_,$)=>_+Ia($)+4,0);l.selected&&t.appendChild(Je("rect",{x:o-4,y:i-4,width:Ct+8,height:u+8,class:"sel"})),Qn(t,[Je("rect",{x:o,y:i,width:Ct,height:u,class:"box"}),Je("rect",{x:o+10,y:i+9,width:8,height:8,class:"swatch"}),Je("text",{x:o+24,y:i+17,class:"label"},Zs(n.label,Zr(Ct-34-v,t5))),Je("text",{x:o+24,y:i+31,class:"kind"},Zs(g,Zr(Ct-34-(p?ro(p,dg)+8:0),_l))),p?Je("text",{x:o+Ct-10,y:i+31,class:"state","text-anchor":"end"},p):null]);let w=o+Ct-8;for(const _ of m.reverse())w-=Ia(_),$u(t,w,i+7,_,"badge"),w-=4;if(c!=null&&c.decision&&c.provider){const _=$u(t,o+24,i+38,c.provider,"chip"),$=f?s5(f,Zr(Ct-44-_-20,Qb)):"",R=Ct-40-_-($?ro($,Qb)+10:0);c.model&&R>24&&t.appendChild(Je("text",{x:o+24+_+6,y:i+47.5,class:"model"},Zs(c.model,Zr(R,_l)))),$&&t.appendChild(Je("text",{x:o+Ct-10,y:i+47.5,class:"verdict","text-anchor":"end"},$))}else f&&t.appendChild(Je("text",{x:o+Ct-10,y:i+17,class:"verdict","text-anchor":"end"},f));l.tag&&$u(t,o+Ct-Ia(l.tag),i-7,l.tag)}function o5(e,t){return{w:Ct,h:Fd(e,t),cx:Ct/2,place:(n,o)=>pg(e,Vl(e,t,"card"),t,n,o)}}function wj(e,t,n){const o=mg(e,t.path),i=o.state==="done"?"passed":o.state in td?td[o.state]:o.state,l=Zs(t.label===t.kind?"exit":`exit: ${t.label}`,40),c=ro(l,_l)+16;return{w:wa+c+(o.tag?6+Ia(o.tag):0)+(i?6+ro(i,dg):0),h:ip,cx:0,exit:!0,place:(u,f)=>{const p=Vl(e,t,"exit"),h=f+ip/2;let b=u+wa+c;n&&p.appendChild(xs(u,f,u,f+ip,"spine")),o.selected&&p.appendChild(Je("rect",{x:u+wa-3,y:h-du/2-3,width:c+6,height:du+6,class:"sel"})),Qn(p,[xs(u,h,u+wa,h,"exit-wire"),Je("rect",{x:u+wa,y:h-du/2,width:c,height:du,class:"exit-box"}),Je("text",{x:u+wa+8,y:h+3.5,class:"exit-text"},l)]),o.tag&&($u(p,b+6,h-6.5,o.tag),b+=6+Ia(o.tag)),i&&p.appendChild(Je("text",{x:b+6,y:h+3.5,class:"state"},i))}}}function a5(e,t,n){const o=n.map(u=>u.node.kind==="escalate"?wj(e,u.node,!1):Ud(e,u.node));let i=Ct/2,l=Ct/2,c=-ap;for(const u of o)i=Math.max(i,u.cx),l=Math.max(l,u.w-u.cx),c+=u.h+ap;return{w:i+l,h:c,cx:i,place:(u,f)=>{const p=Vl(e,t,"chain"),h=u+i;let b=f,g=null;o.forEach((m,v)=>{v&&(b+=ap),m.exit?g===null&&(g=b):g!==null&&p.appendChild(xs(h,g,h,b,"spine")),m.place(m.exit?h:h-m.cx,b),b+=m.h,m.exit||(g=b)}),o[o.length-1].exit&&g!==null&&p.appendChild(xs(h,g,h,b,"spine"))}}}function i5(e,t,n){const o=Fd(e,t),i=n.map(m=>({kid:m,box:Ud(e,m.node),x:0,c:0}));let l=0,c=0;i.forEach((m,v)=>{v&&(l+=KO),m.x=l,m.c=l+m.box.cx,l+=m.box.w,c=Math.max(c,m.box.h)});const u=i.length-1,f=Math.round((i[0].c+i[u].c)/2),p=Math.min(0,f-Ct/2),h=Math.max(l,f+Ct/2),b=o+Kb+qO,g=b+c+VO;return{w:h-p,h:g,cx:f-p,place:(m,v)=>{const w=Vl(e,t,"card"),j=m-p,S=v+o+Kb,T=v+g;pg(e,w,t,j+f-Ct/2,v),w.appendChild(xs(j+f,v+o,j+f,S)),u&&Qn(w,[xs(j+i[0].c,S,j+i[u].c,S),xs(j+i[0].c,T,j+i[u].c,T)]),i.forEach((E,_)=>{const $=j+E.c,R=E.kid.node.path,C=e.taken.has(R);if(w.appendChild(Je("line",{x1:$,y1:S,x2:$,y2:v+b,class:C?"wire branch taken":"wire branch","data-to":R})),E.kid.name!==null){const O=(_<u?i[_+1].c-6:E.x+E.box.w)-E.c-12,I=Zs(E.kid.name,Zr(O,_l)),D=Je("text",{x:$+6,y:S+15,class:C?"branch-name taken":"branch-name"},I);w.appendChild(I===E.kid.name?D:Je("g",null,Je("title",null,E.kid.name),D))}w.appendChild(xs($,v+b+E.box.h,$,T,C?"taken":void 0)),E.box.place(j+E.x,v+b)})}}}const l5=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function c5(e,t,n,o,i,l){const c=fg.has(n.status)?n.status:"pending",u=n.label?l5(n.label):`#${n.index+1}`,f=n.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),p=n.p!==void 0?n.p.toFixed(2):"",h=`#${n.index+1}${n.label?` ${n.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${n.outcome?`, ${n.outcome}`:""}${n.pNote?` (${n.pNote})`:""}`,b=Je("g",{class:`rcell ${c}${n.tone?` tone-${n.tone}`:""}${l?" picked":""}`,"data-path":t.path,"data-item":n.index},Je("title",null,h),Je("rect",{x:o,y:i,width:tl,height:Gp,class:"cell"}),Je("rect",{x:o,y:i,width:3,height:Gp,class:"cell-edge"}),Je("text",{x:o+9,y:i+14,class:"cell-name"},Zs(u,Zr(tl-14,lp))),Je("text",{x:o+9,y:i+27,class:"cell-out"},Zs(f,Zr(tl-18-(p?ro(p,lp)+6:0),lp))),p?Je("text",{x:o+tl-6,y:i+27,class:"cell-p","text-anchor":"end"},p):null);e.appendChild(b)}function u5(e,t){var j;const n=((j=e.marks.items)==null?void 0:j[t.path])??[];if(!n.length)return null;const o=n.length<=ZO,[i,l,c]=o?[tl,Gp,e5]:[fu,fu,XO],u=Math.min(n.length,o?JO:YO),f=Math.ceil(n.length/u),p=u*(i+c)-c,h=f*(l+c)-c+QO+(o?4:0),b={};for(const S of n)b[S.status]=(b[S.status]??0)+1;const g={};for(const S of n)S.outcome&&(g[S.outcome]=(g[S.outcome]??0)+1);const m=Object.entries(g).map(([S,T])=>`${T} ${S}`),w=[`${b.done??0}/${n.length} done`,b.working?`${b.working} working`:"",b.held?`${b.held} held`:"",b.failed?`${b.failed} failed`:"",b.review?`${b.review} review`:"",...m].filter(Boolean).join(" · ");return{w:Math.max(p,ro(w,_l)),h,place:(S,T,E)=>{const _=T-p/2,$=e.marks.selected;n.forEach((R,C)=>{const O=_+C%u*(i+c),I=E+Math.floor(C/u)*(l+c),D=fg.has(R.status)?R.status:"pending",z=($==null?void 0:$.path)===t.path&&$.item===R.index;if(o){c5(S,t,R,O,I,z);return}Qn(S,Je("rect",{x:O,y:I,width:fu,height:fu,class:`cell ${D}${z?" picked":""}`,"data-path":t.path,"data-item":R.index},Je("title",null,`#${R.index+1}${R.label?` ${R.label}`:""}: ${D==="review"?"needs review":D.replace("-"," ")}`)))}),Qn(S,Je("text",{x:T,y:E+h-4,class:"caption","text-anchor":"middle"},w))}}}function d5(e,t,n){const o=Ud(e,n),i=Fd(e,t),l=t.kind==="map"?u5(e,t):null,c=l?l.h+ps:0,u=Math.max(Ct/2,o.cx,l?l.w/2:0)+ps,f=Math.max(Ct/2,o.w-o.cx,l?l.w/2:0)+ps,p=i+ps+c+o.h+ps;return{w:u+f,h:p,cx:u,place:(h,b)=>{const g=Vl(e,t,"card"),m=h+u;if(Qn(g,Je("rect",{x:h,y:b+i/2,width:u+f,height:p-i/2,class:"frame"})),l?(Qn(g,xs(m,b+i,m,b+i+ps)),Qn(g,xs(m,b+i+ps+l.h,m,b+i+ps+c))):Qn(g,xs(m,b+i,m,b+i+ps)),Qn(g,xs(m,b+i+ps+c+o.h,m,b+p)),pg(e,g,t,m-Ct/2,b),l){const v=Je("g",{class:"items"});l.place(v,m,b+i+ps),g.appendChild(v)}o.place(m-o.cx,b+i+ps+c)}}}function kj(e,t){return e.kind==="escalate"?"exit":t.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Ud(e,t){const n=e.kids[t.path]??[],o=kj(t,n);return o==="exit"?wj(e,t,!0):o==="leaf"?o5(e,t):o==="chain"?a5(e,t,n):o==="fan"?i5(e,t,n):d5(e,t,n[0].node)}function jj(e){const{byPath:t,kids:n}=bj(Nj(e)),o=i=>{const l=n[i.path]??[],c=kj(i,l),u=c==="frame"?o(l[0].node):c==="chain"||c==="fan"?l.reduce((f,p)=>f+o(p.node),0):0;return(c==="chain"?0:1)+u};return t["/root"]?o(t["/root"]):0}const hg=e=>`${e} ${e===1?"node":"nodes"}`,Nj=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(t=>t&&typeof t.path=="string"&&typeof t.kind=="string").map(t=>({path:t.path,kind:t.kind,label:String(t.label??t.kind),via:typeof t.via=="string"?t.via:""}));function f5(e,t,n={}){var h;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const o=bj(Nj(t)),i=(b,g)=>(e.setAttribute("viewBox",`0 0 ${b} ${g}`),e.setAttribute("width",String(b)),e.setAttribute("height",String(g)),e.style.setProperty("min-width",`${Math.min(b,480)}px`),{w:b,h:g});if(!o.byPath["/root"])return i(0,0);const l={svg:e,kids:o.kids,marks:n,taken:new Set(n.taken??[])},c=Ud(l,o.byPath["/root"]);c.place(ba,ba);let u=c.w,f=c.h;const p=(((h=n.diff)==null?void 0:h.removed)??[]).map(b=>`${b.label} (${b.kind})`);if(p.length){const b=["Removed:",...p.map(m=>Zs(m,Zr(Math.max(u,300),Yb)))],g=Je("g",{class:"removed-list"},Je("title",null,`Removed: ${p.join(", ")}`));b.forEach((m,v)=>{g.appendChild(Je("text",{x:ba,y:ba+f+33+v*Xb,class:"removed"},m)),u=Math.max(u,ro(m,Yb))}),e.appendChild(g),f+=22+b.length*Xb}return i(u+2*ba,f+2*ba)}function m5(e){var i,l;const t=e,n=(i=t==null?void 0:t.closest)==null?void 0:i.call(t,"[data-item]");if(n)return{path:n.getAttribute("data-path"),item:Number(n.getAttribute("data-item"))};const o=(l=t==null?void 0:t.closest)==null?void 0:l.call(t,"g[data-path]");return!o||o.classList.contains("chain")?null:{path:o.getAttribute("data-path"),item:null}}const p5=1600;function Wd({graph:e,marks:t,onSelect:n,className:o,label:i="Workflow graph",minScale:l=.8,maxScale:c=1.3}){const u=y.useRef(null),[f,p]=y.useState({w:0,h:0}),[h,b]=y.useState(0),g=y.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,t??null]),[e,t]);y.useEffect(()=>{if(!u.current)return;const v=f5(u.current,e,t);p(w=>w.w===v.w&&w.h===v.h?w:v),u.current.style.setProperty("--wf-phase",`-${Date.now()%p5}ms`)},[g]),y.useEffect(()=>{var j;const v=(j=u.current)==null?void 0:j.parentElement;if(!v||typeof ResizeObserver>"u")return;const w=new ResizeObserver(([S])=>b(S.contentRect.width));return w.observe(v),()=>w.disconnect()},[]);const m=f.w&&h?Math.min(c,Math.max(l,h/f.w)):1;return s.jsx("svg",{ref:u,role:"img","aria-label":i,className:ie("wf select-none",o),style:f.w?{width:f.w*m,height:f.h*m,maxWidth:"none",minWidth:0}:void 0,onClick:v=>{const w=m5(v.target);w&&n&&n(w)}})}function Hd({run:e=!1}){const t=[["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"]],n=[["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 s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[t.map(([o,i])=>s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"inline-block size-2",style:{background:o}}),i]},i)),e&&s.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&n.map(([o,i])=>s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:ie("inline-block size-2.5 border",o)}),i]},i))]})}const h5=["ready","preparing","unavailable"],Tu=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Zb=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function Bd(e){if(Tu(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function cp(e){const t=Tu(e)?e.places:void 0;if(!Tu(t)||!Array.isArray(t.modes)||!Array.isArray(t.boxes))return null;const n=t.boxes.filter(Tu).filter(i=>typeof i.id=="string").map(i=>({id:i.id,available:i.available===!0,...typeof i.reason=="string"?{reason:i.reason}:{},...h5.includes(i.state)?{state:i.state}:{}})),o=Bd(t.default_place);return o?{modes:t.modes.filter(i=>typeof i=="string"),boxes:n,defaultPlace:o}:null}const up=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,g5=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",x5=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",y5=e=>e==null?void 0:e.boxes.find(t=>t.available&&t.state==="preparing"),v5={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."}]}},b5=["jev","parallel"];function w5(e="jev"){const t=structuredClone(v5);return e!=="jev"&&Object.assign(t.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),t}const k5={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`."}]}},j5=()=>structuredClone(k5);function gg(e,t,n){const{name:o,description:i,...l}=t,c={...e.definition,...l},u={...e.definition};c.computer!==void 0&&(delete c.place,delete u.place),e.kind==="workflow"&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const p of Object.keys(c))c[p]===void 0&&delete c[p];const f=ll({...c,version:0},{...u,version:0});return c.version=f?e.definition.version:e.revisions+1,{definition:c,...n.trim()?{note:n.trim()}:{},unchanged:f}}function ll(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e).filter(i=>e[i]!==void 0),o=Object.keys(t).filter(i=>t[i]!==void 0);return n.length===o.length&&n.every(i=>ll(e[i],t[i]))}const xg="decision",Sj="workflow",_j={[xg]:w5,[Sj]:j5},Ej=e=>e!==void 0&&Object.hasOwn(_j,e);function N5(e){var n,o;if(!((n=e==null?void 0:e.adapters)!=null&&n.includes("runJudge")))return;const t=(o=e.decisions)==null?void 0:o.providers;return t?b5.find(i=>t.some(l=>l.id===i&&l.available)):"jev"}const S5="You are a helpful agent. Do the task you're given and report what you found.";function _5(e){var t;return Ej(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:_j[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}:{},...(t=e.model)!=null&&t.trim()?{model:e.model.trim()}:{},...e.computer?{computer:e.computer}:{},...e.learning?{learning:!0}:{},...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 Jb(e){const t=(e??"").trim();if(!t)return{ok:!0,value:void 0};const n=t.replace(/^\$\s*/,""),o=Number(n);return n&&Number.isFinite(o)?{ok:!0,value:o}:{ok:!1,message:"A spend cap is a number of dollars, such as 2.50; empty means none."}}function E5(e){return(Array.isArray(e)?e:[]).flatMap(t=>{if(!t||typeof t!="object"||typeof t.name!="string")return[];const{name:n,available:o,summary:i,blurb:l,missing:c,reason:u,harnesses:f,call_only:p,sandbox_only:h,nodes:b}=t;return[{name:n,available:o!==!1,...typeof i=="string"&&i?{summary:i}:{},...typeof l=="string"&&l.trim()?{blurb:l.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof u=="string"&&u?{reason:u}:{},harnesses:Array.isArray(f)?f:[],...p===!0?{call_only:!0}:{},...h===!0?{sandbox_only:!0}:{},...typeof b=="boolean"?{nodes:b}:{}}]})}function Gd(e,t){return t.filter(n=>!n.call_only&&n.harnesses.includes(e))}function qp(e,t,n,{mcpHarnesses:o,workflow:i=!1}={}){if(t.startsWith("mcp:"))return!o||o.includes(e);const l=n.find(c=>c.name===t);return l?l.call_only?i:Gd(e,n).some(c=>c.name===t):!0}const Vp=e=>Tj[e]??e,ew=e=>e.map(Vp).join(" and ");function tw(e,t,n,o){var l;if(t.startsWith("mcp:"))return`${Vp(e)} doesn't run MCP tools here${o!=null&&o.length?`: ${ew(o)} do`:""}`;const i=((l=n.find(c=>c.name===t))==null?void 0:l.harnesses)??[];return i.length?`Runs on ${ew(i)} here, not on ${Vp(e)}`:"No harness runs it here"}function $5(e,t,n,o,i={}){const l=[...t,...n.filter(c=>!t.includes(c))];return{tools:l.filter(c=>qp(e,c,o,i)),held:l.filter(c=>!qp(e,c,o,i))}}const T5=(e,t)=>e.sandbox_only&&(t==null?void 0:t.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,yg=new Set(["browser"]),vg=(e,t,n)=>e||t.some(o=>yg.has(o))||!n?{mode:"runner"}:n.defaultPlace;function $j(e,t){const n=Bd(e.definition.place);if(n)return{place:n,byDefault:!1};const o=e.kind==="workflow",i=e.definition.tools??[];if(!(!o&&!i.some(l=>yg.has(l))&&!t))return{place:vg(o,i,t),byDefault:!0}}const dp=(e,t,n)=>Gd(e,t).filter(o=>o.available&&((n==null?void 0:n.mode)==="sandbox"?!yg.has(o.name):!o.sandbox_only)).map(o=>o.name),C5=["web_fetch","web_search"],nw=e=>e.some(t=>C5.includes(t)),Tj={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},R5=["pi","claude-agent","codex","opencode"];function A5(e,t){const n=R5.flatMap(o=>{const i=e.find(l=>l.id===o);return i?[{id:o,label:Tj[o],available:i.available,reason:i.reason}]:[]});return t&&(n.push({id:xg,label:"Decision",available:t.available,reason:t.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),n.push({id:Sj,label:"Workflow",available:!0,reason:void 0})),n}function O5(e){var t;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((t=e.fields)!=null&&t.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(n=>[n.field,n.message]))}:{kind:"other",message:e.message}}function qd(e,t=!1){var n,o,i;return e.status===412||e.code==="precondition_failed"?t?{kind:"taken"}:{kind:"conflict"}:(n=e.problems)!=null&&n.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((i=(o=e.fields)==null?void 0:o[0])==null?void 0:i.message)??e.message,code:e.code}}function P5(e,t){const n=`definition.${t}`;return(e??[]).filter(o=>o.field===n||o.field.startsWith(`${n}[`)||o.field.startsWith(`${n}.`)||o.field.startsWith(`${n}/`))}const qo=(e,t,n)=>({...Uo(e,t),title:n}),M5=(e,t)=>{const n=e.get(t);return n!=null&&n.title?tn(n):`run ${Fl(t)}`},Cj="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",L5=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),sw=20;function I5({agent:e,v2:t,focus:n=[],server:o,onAgent:i,places:l,onChanged:c}){var ye;const[u,f]=y.useState(null),[p,h]=y.useState(null),[b,g]=y.useState([]),[m,v]=y.useState({items:[],cursor:null,pages:0}),[w,j]=y.useState({items:[],cursor:null,pages:0}),[S,T]=y.useState(!1),E=y.useRef(0),_=y.useRef(!1),$=()=>{const ee=++E.current;_.current=!1,h(null);const be=t.agentLearning(e.agent_id).then(Oe=>{ee===E.current&&(f(Oe),v({items:[],cursor:Oe.notes.next_cursor,pages:0}),j({items:[],cursor:Oe.log.next_cursor,pages:0}))},Oe=>{ee===E.current&&h(Oe??new Error("unknown"))});return t.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Oe=>{ee===E.current&&g(Oe.runs)},()=>{}),be};y.useEffect(()=>{$()},[t,e.agent_id]);const R=()=>(c==null||c(),$()),C=()=>{if(!m.cursor||_.current)return;const ee=E.current;_.current=!0,t.learningNotes(e.agent_id,m.cursor).then(be=>{ee===E.current&&(_.current=!1,v(Oe=>({items:[...Oe.items,...be.items.filter(We=>!Oe.items.some(fe=>fe.file===We.file))],cursor:be.next_cursor,pages:Oe.pages+1})))},be=>{ee===E.current&&(_.current=!1,v(Oe=>({...Oe,error:be??new Error("unknown")})))})},O=e.definition.learning===!0,I=!!e.archived_at,D=y.useMemo(()=>[...(u==null?void 0:u.notes.items)??[],...m.items],[u,m.items]),z=D.filter(ee=>ee.status==="active"),H=D.filter(U1),F=(u==null?void 0:u.skills)??[],U=(u==null?void 0:u.workflows)??[],[X,P]=y.useState(void 0),M=H.length>0||[...F,...U].some(ee=>ee.status==="pending")||U.some(ee=>ee.status==="active");y.useEffect(()=>{if(!M||X!==void 0)return;let ee=!0;return Promise.resolve().then(()=>t.capabilities()).then(be=>{ee&&P(Y4(be))},()=>{ee&&P("password")}),()=>{ee=!1}},[M]);const G=D.filter(ee=>ee.status==="superseded"||ee.status==="retired"),B=y.useMemo(()=>{const ee=new Map(D.map(Oe=>[Oe.file,Oe])),be=new Map;for(const Oe of D){if(Oe.status==="superseded")continue;const fe=[...new Set([...aA(Oe.text),...D.filter(Re=>Re.status==="superseded"&&Re.superseded_by===Oe.file).map(Re=>Re.file)])].flatMap(Re=>{const Xe=ee.get(Re);return Xe?Xe.status==="superseded"&&Xe.superseded_by===Oe.file?[{file:Re,name:Xe.name}]:[]:[{file:Re,name:null}]});fe.length&&be.set(Oe.file,fe)}return be},[D]),L=y.useMemo(()=>new Map(b.map(ee=>[ee.run_id,ee])),[b]),q=y.useMemo(()=>pA([...(u==null?void 0:u.log.items)??[],...w.items]),[u,w.items]),ne=n.filter(ee=>!D.some(be=>be.file===ee)).length>0;y.useEffect(()=>{u&&ne&&m.cursor&&m.error===void 0&&m.pages<sw&&C()},[u,ne,m.cursor,m.pages]);const oe=D.some(ee=>!q.has(ee.file));y.useEffect(()=>{if(!u||!oe||!w.cursor||w.pages>=sw)return;const ee=E.current;t.learningLog(e.agent_id,w.cursor).then(be=>{ee===E.current&&j(Oe=>({items:[...Oe.items,...be.items],cursor:be.next_cursor,pages:Oe.pages+1}))},()=>{ee===E.current&&j(be=>({...be,cursor:null}))})},[u,oe,w.cursor]);const ae=b.filter(ee=>ee.learning&&(ee.learning.state==="merged"||ee.learning.state==="dropped")).length;if(p&&!u)return s.jsx(js,{problem:Uo(p,"what this agent learned"),onRetry:$,className:""});if(!u)return s.jsx(F5,{});const ce=p?s.jsx(z5,{error:p,onRetry:$}):null,le=ee=>s.jsx(W5,{agent:e,v2:t,onAgent:i,server:o,disabled:I,quiet:ee});return!D.length&&!F.length&&!U.length&&!S?s.jsxs("div",{className:"space-y-6",children:[ce,s.jsx(B5,{on:O,lookedBack:ae,switchRow:le(!0),onAdd:I?void 0:()=>T(!0)}),s.jsx(ow,{runs:b})]}):s.jsxs("div",{className:"space-y-6",children:[H.length>0&&s.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[s.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b border-warning/50 px-4 py-3 text-small font-semibold",children:["Waiting for your OK",s.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:H.length})]}),s.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:Q4}),((ye=$j(e,l))==null?void 0:ye.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&s.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:Z4}),s.jsx("ul",{className:"space-y-3 p-4",children:H.map(ee=>s.jsx("li",{children:s.jsx(rw,{note:ee,v2:t,agentId:e.agent_id,readOnly:I,focused:n.includes(ee.file),from:q.get(ee.file),runs:L,onChanged:R,approves:X,replaces:B.get(ee.file)})},ee.file))})]}),sA(u.impact)?s.jsx(U5,{impact:u.impact}):u.impact===null&&O&&s.jsx("p",{className:"font-mono text-small text-muted-foreground",children:D5}),s.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[s.jsxs("div",{className:"min-w-0 space-y-6",children:[s.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Notes",children:[s.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"What it has learned"}),s.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:z.length?`${Ma(z.length)} in use. Every later run reads ${z.length===1?"it":"them"} before it starts.`:[...F,...U].some(ee=>ee.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!I&&!S&&s.jsxs(Z,{size:"sm",onClick:()=>T(!0),children:[s.jsx(dl,{"aria-hidden":!0})," Add a note"]})]}),ce,!O&&s.jsx(H5,{server:o}),S&&s.jsx(Mj,{title:"New note",v2:t,agentId:e.agent_id,taken:D.map(ee=>ee.file),onDone:ee=>{T(!1),ee&&R()}},"new"),s.jsx("ul",{className:"space-y-3",children:z.map(ee=>s.jsx("li",{children:s.jsx(rw,{note:ee,v2:t,agentId:e.agent_id,readOnly:I,focused:n.includes(ee.file),from:q.get(ee.file),runs:L,onChanged:R,replaces:B.get(ee.file)})},ee.file))}),m.error!==void 0&&s.jsx(js,{problem:Uo(m.error,"more notes"),onRetry:C,className:""}),m.cursor&&s.jsx("div",{className:"flex justify-center",children:s.jsx(Z,{size:"sm",onClick:C,children:"Load more notes"})}),G.length>0&&s.jsx(X5,{notes:G,all:D,from:q,focus:n,runs:L,v2:t,agentId:e.agent_id,readOnly:I,onChanged:R})]}),["skill","workflow"].map(ee=>{const be=ee==="skill"?F:U;if(!be.length)return null;const Oe=ee==="skill"?"Skills it learned":"Workflows it learned",We=be.filter(Re=>Re.status!=="retired"),fe=be.filter(Re=>Re.status==="retired");return s.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Oe,children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:Oe}),s.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:We.length?ee==="skill"?`${qu(We.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${qu(We.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${ee} is in use: the next run gets none.`})]}),We.length>0&&s.jsx("ul",{className:"space-y-3",children:We.map(Re=>s.jsx("li",{children:s.jsx(G5,{item:Re,kind:ee,v2:t,agentId:e.agent_id,readOnly:I,runs:L,approves:X,onChanged:R})},Re.file))}),fe.length>0&&s.jsx(Y5,{kind:ee,items:fe,v2:t,agentId:e.agent_id,runs:L,readOnly:I,onChanged:R})]},ee)})]}),s.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[s.jsx(Rj,{title:"Learning",children:le(!1)}),s.jsx(ow,{runs:b}),s.jsx(Z5,{index:u.index,skills:F.filter(ee=>ee.status==="active").map(ee=>ee.name),off:!O||o==="off"})]})]})]})}function z5({error:e,onRetry:t}){const n=Uo(e,"the notes"),o=[n.said,n.code].filter(Boolean).join(" · ");return s.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:o||void 0,children:[s.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",n.why.charAt(0).toLowerCase()+n.why.slice(1)," What's shown may be out of date."]}),s.jsx(Z,{type:"button",onClick:t,size:"sm",children:"Try again"})]})}const D5="After two runs on each side of the first thing it learned (a note, a skill or a workflow), this shows what learning changed.";function Rj({title:e,children:t,label:n}){return s.jsxs("section",{className:"border","aria-label":n??e,children:[s.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}function F5(){const e="block bg-muted motion-safe:animate-pulse";return s.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[s.jsx("span",{"aria-hidden":!0,className:ie(e,"h-6 w-56")}),[0,1,2].map(t=>s.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[s.jsx("span",{className:ie(e,"h-4 w-1/3")}),s.jsx("span",{className:ie(e,"h-3 w-2/3 bg-muted/70")}),s.jsx("span",{className:ie(e,"h-3 w-1/2 bg-muted/70")})]},t)),s.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function U5({impact:e}){const{before:t,after:n}=e,o=[{label:"Answers in",now:Xu(n.median_duration_s),was:Xu(t.median_duration_s),delta:Mb(t.median_duration_s,n.median_duration_s)},...G1(e)?[{label:"A run costs",now:La(n.median_cost_usd),was:La(t.median_cost_usd),delta:Mb(t.median_cost_usd,n.median_cost_usd)}]:[]],i=q1(e),l=[`Medians of ${eo(t.runs)} before it first learned and ${eo(n.runs)} that started from what it learned (a note, a skill or a workflow).`,`Costs are of the ${t.cost_runs} and ${n.cost_runs} runs whose cost is known.`].join(" ");return s.jsx("section",{className:"border","aria-label":nA(e),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[s.jsxs("div",{className:"flex items-baseline gap-2.5",children:[s.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),s.jsxs("span",{className:"font-mono text-label text-muted-foreground",title:l,children:["on ",eo(n.runs)]})]}),s.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[o.map(c=>s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:c.label}),s.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[s.jsx("span",{className:"text-figure font-semibold leading-none",children:c.now}),s.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",c.was]}),c.delta!==null&&c.delta!==0&&s.jsxs("span",{className:ie("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),i!==null&&s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),s.jsxs("dd",{className:"font-mono text-body text-muted-foreground",children:[La(i)," a run"]})]})]})]})})}function W5({agent:e,v2:t,onAgent:n,server:o,disabled:i,quiet:l}){const[c,u]=y.useState(!1),[f,p]=y.useState(null),[h,b]=y.useState(null),g=async m=>{u(!0),p(null),b(m);try{const{agent:v,etag:w}=await t.getAgent(e.agent_id),j=gg(v,{learning:m},m?"Learning on":"Learning off");if(j.unchanged)n==null||n(v);else{const{unchanged:S,...T}=j;n==null||n((await t.updateDefinition(e.agent_id,T,w)).agent)}}catch(v){p(v??new Error("unknown"))}b(null),u(!1)};return s.jsx(vj,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:l,checked:h??e.definition.learning===!0,onChange:m=>void g(m),busy:c,disabled:i,server:o,problem:f?s.jsx(js,{problem:qo(f,"the agent","Learning was not changed."),className:"mt-2"}):null})}function H5({server:e}){return s.jsxs(ts,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs don't read these notes. They're kept for when it's back on."]})}function B5({on:e,lookedBack:t,switchRow:n,onAdd:o}){return s.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[s.jsxs("div",{className:"px-6 py-12 text-center",children:[s.jsx(vh,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),s.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"After each run, it looks back and keeps a note when something will help next time. Its notes show here, and every later run reads them first.":"With learning on, it keeps short notes on what worked after each run, and every later run reads them before it starts."}),e&&t>0&&s.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[eo(t)," looked back: nothing worth keeping yet."]})]}),s.jsx("div",{className:"border-t",children:n}),o&&s.jsx("div",{className:"flex justify-center border-t px-4 py-3",children:s.jsxs(Z,{size:"sm",variant:"ghost",onClick:o,children:[s.jsx(dl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function rw({note:e,v2:t,agentId:n,readOnly:o,focused:i,from:l,runs:c,onChanged:u,approves:f,replaces:p=[]}){const[h,b]=y.useState(!1),[g,m]=y.useState(!1),[v,w]=y.useState(!1),[j,S]=y.useState(i),[T,E]=y.useState(null),[_,$]=y.useState(!1),[R,C]=y.useState(null),O=y.useRef(null),I=U1(e),D=async()=>{const F=U=>s.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:U});$(!0),C(null);try{await t.approveNote(n,e.file,e.etag)}catch(U){$(!1),C(U instanceof Te&&qd(U).kind==="conflict"?F(`${Md} Reload the tab to see the newest version.`):s.jsx(js,{problem:qo(U,"the note","The note was not approved."),className:""}));return}await u(),$(!1)};if(y.useEffect(()=>{var U,X;if(!i)return;S(!0),(X=(U=O.current)==null?void 0:U.scrollIntoView)==null||X.call(U,{block:"center",behavior:"smooth"});const F=setTimeout(()=>S(!1),2600);return()=>clearTimeout(F)},[i]),y.useEffect(()=>{if(!T)return;const F=setTimeout(()=>E(null),2400);return()=>clearTimeout(F)},[T]),h)return s.jsx(Mj,{title:"Edit note",v2:t,agentId:n,file:e.file,seen:e,onDone:F=>{b(!1),F&&(E("Saved"),u())}});const z=kl(e.text),H=Kp(e.last_change);return s.jsxs("article",{ref:O,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:ie("border bg-card/40 outline-none focus-visible:border-primary transition-[border-color,box-shadow] duration-slow",j&&"border-primary ring-1 ring-primary"),children:[s.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 break-words text-prose font-semibold leading-snug",children:e.name}),s.jsx(Pe,{children:L1(e.type)}),e.origin==="you"&&s.jsx(Pe,{tone:"muted",children:"From you"}),T&&s.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:T})]}),s.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),I&&f==="password"&&s.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:W1})]}),!o&&!v&&s.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[I?f==="yes"&&s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>void D(),disabled:_,"aria-label":`Approve ${e.name}`,children:_?"Approving":"Approve"}):s.jsxs(Z,{size:"sm",variant:"ghost",onClick:()=>b(!0),"aria-label":`Edit ${e.name}`,children:[s.jsx(Rl,{"aria-hidden":!0})," Edit"]}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>w(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),R&&s.jsx("div",{className:"px-5 pt-3",children:R}),z.trim()&&s.jsx(Kd,{text:z}),s.jsxs("footer",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[(l==null?void 0:l.run)&&s.jsx(Vd,{run:l.run.id,runs:c,at:l.run.at,reason:l.run.reason}),H&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(bh,{className:"size-3","aria-hidden":!0}),H]}),s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Cu,{className:"size-3","aria-hidden":!0}),"Given to ",eo(e.runs.given)]}),e.runs.read>0&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Cu,{className:"size-3","aria-hidden":!0}),"Read in ",eo(e.runs.read)]}),p.length>0&&s.jsxs("button",{type:"button",onClick:()=>m(F=>!F),"aria-expanded":g,className:"flex items-center gap-1.5 hover:text-foreground",children:[s.jsx(Y2,{className:"size-3","aria-hidden":!0}),"Replaces ",p.length," older ",p.length===1?"note":"notes",s.jsx(Wo,{className:ie("size-3 transition-transform",g&&"rotate-180"),"aria-hidden":!0})]})]}),g&&p.length>0&&s.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:p.map(F=>s.jsx("li",{className:ie("break-words",F.name===null&&"font-mono text-small"),children:F.name??F.file},F.file))}),v&&s.jsx(Oj,{name:e.name,kind:"note",retire:()=>t.retireNote(n,e.file,e.etag),onDone:async F=>{F&&await u(),w(!1)}})]})}function G5({item:e,kind:t,v2:n,agentId:o,readOnly:i,runs:l,approves:c,onChanged:u}){const[f,p]=y.useState(!1),[h,b]=y.useState(null),[g,m]=y.useState(null),[v,w]=y.useState(null),[j,S]=y.useState(!1),[T,E]=y.useState(!1),[_,$]=y.useState(!1),R=y.useRef(Us()).current,[C,O]=y.useState(null),[I,D]=y.useState(null),z=e.status==="pending",H=t==="workflow"&&e.status==="active"&&c==="yes",F=async()=>{w(null),b(null),m(null);try{const M=await n.readNote(o,e.file);b(M.note),m(M.etag)}catch(M){w(M??new Error("unknown"))}},U=async()=>{if(f)return p(!1);p(!0),h===null&&await F()};y.useEffect(()=>{h===null&&g===null||(f?F():(b(null),m(null)))},[e.etag]);const X=t==="skill"&&f&&g?g:e.etag,P=async()=>{S(!0),D(null);try{await n.approveNote(o,Dp(e),X)}catch(M){S(!1),D(M instanceof Te&&qd(M).kind==="conflict"?s.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Md} Reload the tab to see the newest version.`}):s.jsx(js,{problem:qo(M,`the ${t}`,`The ${t} was not approved.`),className:""}));return}await u(),S(!1)},K=`the ${t} ${e.name}`;return s.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[s.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),z&&s.jsxs(Pe,{tone:"warning",children:[s.jsx(xh,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]})]}),e.description&&s.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),z&&c==="password"&&s.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:W1})]}),s.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!i&&!T&&!_&&s.jsxs(s.Fragment,{children:[z&&c==="yes"&&s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>void P(),disabled:j,"aria-label":`Approve ${e.name}`,children:j?"Approving":"Approve"}),H&&s.jsx(Z,{size:"sm",onClick:()=>{O(null),$(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>E(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),s.jsxs(Z,{size:"sm",variant:"ghost",onClick:()=>void U(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${K}`,children:[s.jsx(Wo,{className:ie("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),I&&s.jsx("div",{className:"px-5 pt-3",children:I}),C&&s.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",s.jsx("a",{href:`#/agents/${encodeURIComponent(C.agent_id)}`,className:"font-mono underline underline-offset-2",children:C.definition.name}),". Open it to run it."]}),f&&(v!==null?s.jsx("div",{className:"px-5 pt-3",children:s.jsx(js,{problem:Uo(v,K),onRetry:()=>void F(),className:""})}):h===null?s.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${K}`,children:s.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t==="skill"?s.jsx(Kd,{text:kl(h)}):s.jsx(q5,{name:e.name,text:h})),s.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&&s.jsx(Vd,{run:e.run,runs:l}),Kp(e.last_change)&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(bh,{className:"size-3","aria-hidden":!0}),Kp(e.last_change)]}),s.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),T&&s.jsx(Oj,{name:e.name,kind:t,retire:()=>n.retireNote(o,Dp(e),X),onDone:async M=>{M&&await u(),E(!1)}}),_&&s.jsx(K5,{name:e.name,keys:R,promote:M=>n.promoteWorkflow(o,e.name,M),onDone:M=>{$(!1),M&&O(M)}})]})}function q5({name:e,text:t}){const{doc:n,graph:o}=y.useMemo(()=>{try{const c=JSON.parse(t);return{doc:c,graph:cl(c)}}catch{return{doc:null,graph:null}}},[t]),i=y.useMemo(()=>o?{meta:Pd(n,o)}:void 0,[n,o]),l=s.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:t});return o!=null&&o.nodes.length?s.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[s.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:s.jsx(Wd,{graph:o,marks:i,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),s.jsx(Hd,{}),s.jsxs("details",{children:[s.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),s.jsx("div",{className:"mt-2",children:l})]})]}):s.jsx("div",{className:"mx-5 mt-3",children:l})}function Kp(e){return e&&e.kind!=="learned"?`${P1(e.kind,e.by)} · ${Rt(e.at)}`:null}function Aj(e){return e?`${P1("retired",e.by)} · ${Rt(e.at)}`:"Retired"}function Vd({run:e,runs:t,at:n,reason:o}){return s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",title:o?`Kept because: ${o}`:void 0,children:[s.jsx(vh,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),s.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:M5(t,e),children:Fl(e)}),n&&s.jsxs("span",{className:"shrink-0",children:["· ",Rt(n)]})]})}function Kd({text:e}){const[t,n]=y.useState(!1),o=e.split(`
534
+ `).length>8||e.length>520,i=y.useMemo(()=>Ha(e),[e]);return s.jsxs("div",{className:"px-5 pb-4 pt-3",children:[s.jsxs("div",{className:ie("relative",o&&!t&&"max-h-[9.5rem] overflow-hidden"),children:[s.jsx("div",{className:Cj,dangerouslySetInnerHTML:{__html:i}}),o&&!t&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]}),o&&s.jsxs("button",{type:"button",onClick:()=>n(l=>!l),className:"caps mt-2 flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(Wo,{className:ie("size-3.5 transition-transform",t&&"rotate-180"),"aria-hidden":!0}),t?"Show less":"Show all"]})]})}const V5={note:"Later runs stop reading it. It stays under Earlier notes.",skill:"Later runs stop getting it. It stays under Earlier skills.",workflow:"Later runs stop getting it. It stays under Earlier workflows."};function Oj({name:e,kind:t,retire:n,onDone:o}){const[i,l]=y.useState(!1),[c,u]=y.useState(null),f=y.useRef(null);y.useEffect(()=>{var b;(b=f.current)==null||b.focus()},[]);const p=b=>s.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:b}),h=async()=>{l(!0),u(null);try{await n()}catch(b){l(!1),u(b instanceof Te&&qd(b).kind==="conflict"?p(`${Md} Reload the tab to see the newest version.`):s.jsx(js,{problem:qo(b,`the ${t}`,`The ${t} was not retired.`),className:""}));return}await o(!0)};return s.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:b=>{b.key==="Escape"&&(b.stopPropagation(),o(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[s.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",V5[t]]}),c&&s.jsx("div",{className:"w-full",children:c}),s.jsx(Z,{ref:f,size:"sm",variant:"destructive",onClick:()=>void h(),disabled:i,children:i?"Retiring":"Yes, retire"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>void o(!1),disabled:i,children:"Keep"})]})}function K5({name:e,keys:t,promote:n,onDone:o}){const[i,l]=y.useState(!1),[c,u]=y.useState(null),f=y.useRef(null);y.useEffect(()=>{var h;(h=f.current)==null||h.focus()},[]);const p=async()=>{var b;l(!0),u(null);let h;try{h=await n(t.keyFor("promote",e))}catch(g){return l(!1),g instanceof Te&&g.status<500&&t.done(),g instanceof Te&&g.status===403?void u(s.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:B4})):g instanceof Te&&((b=g.problems)!=null&&b.length)?void u(s.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[s.jsxs("p",{children:["No agent was made: ",g.message]}),s.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:g.problems.map((m,v)=>s.jsx("li",{children:m.detail},v))})]})):void u(s.jsx(js,{problem:qo(g,"the agent","No agent was made."),className:""}))}t.done(),o(h)};return s.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:h=>{h.key==="Escape"&&(h.stopPropagation(),i||o(null))},className:"flex flex-wrap items-center gap-3 border-t px-5 py-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[s.jsx("span",{className:"font-semibold",children:"Make it an agent?"})," ",H4(e)]}),c&&s.jsx("div",{className:"w-full",children:c}),s.jsx(Z,{ref:f,size:"sm",variant:"solid",onClick:()=>void p(),disabled:i,children:i?"Making the agent":"Yes, make the agent"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>o(null),disabled:i,children:"Cancel"})]})}function Pj({name:e,kind:t,from:n,restore:o,onChanged:i,onDone:l}){const[c,u]=y.useState(!1),[f,p]=y.useState(null),h=y.useRef(null);y.useEffect(()=>{var m;(m=h.current)==null||m.focus()},[]);const b=m=>s.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:m}),g=async()=>{var m;u(!0),p(null);try{await o()}catch(v){if(u(!1),v instanceof Te&&(v.status===412||v.code==="precondition_failed")){p(b(Md)),await i();return}if(v instanceof Te&&v.status===403)return void p(b(G4));if(v instanceof Te&&((m=v.problems)!=null&&m.length))return void p(s.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[s.jsxs("p",{children:["Not restored: ",v.message]}),s.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((w,j)=>s.jsx("li",{children:w.detail},j))})]}));if(v instanceof Te&&v.status===400){await i(),l();return}return void p(s.jsx(js,{problem:qo(v,`the ${t}`,`The ${t} was not restored.`),className:""}))}await i(),l()};return s.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:m=>{m.key==="Escape"&&(m.stopPropagation(),l())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[s.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",W4(n)]}),f&&s.jsx("div",{className:"w-full",children:f}),s.jsx(Z,{ref:h,size:"sm",variant:"solid",onClick:()=>void g(),disabled:c,children:c?"Restoring":"Yes, restore"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:l,disabled:c,children:"Keep"})]})}function Mj({title:e,v2:t,agentId:n,file:o,seen:i,taken:l=[],onDone:c}){const[u,f]=y.useState(i?Yu(i.text):{name:"",description:"",type:"feedback",body:`
535
+ `,rest:[]}),[p,h]=y.useState((i==null?void 0:i.etag)??null),[b,g]=y.useState(null),[m,v]=y.useState(!1),[w,j]=y.useState([]),[S,T]=y.useState(null),[E,_]=y.useState(!1),[$,R]=y.useState(null),C=y.useRef(null),O=async()=>{if(o)try{const F=await t.readNote(n,o);f(Yu(F.note)),h(F.etag),g(null)}catch(F){g(F??new Error("unknown"))}};y.useEffect(()=>{var F;(F=C.current)==null||F.focus()},[]);const I=F=>f(U=>({...U,...F})),D=u.name.trim()!==""&&u.description.trim()!==""&&!m,z=async()=>{if(!D)return;if(T(null),j([]),_(!1),o&&!p){T(sp);return}v(!0);const F=oA(u);try{await t.writeNote(n,o??Ib(u.name,l),F,o?{etag:p??""}:{create:!0}),c(!0)}catch(U){v(!1);const X=U instanceof Te?qd(U,!o):null;(X==null?void 0:X.kind)==="conflict"?(R(F),await O()):(X==null?void 0:X.kind)==="refused"?j(X.problems):(X==null?void 0:X.kind)==="taken"?_(!0):T(U??new Error("unknown"))}},H=F=>{F.key==="Escape"?(F.preventDefault(),F.stopPropagation(),c(!1)):F.key==="Enter"&&(F.metaKey||F.ctrlKey||F.target.tagName==="INPUT")&&(F.preventDefault(),z())};return s.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:H,children:[s.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[s.jsx("h3",{className:"caps text-label font-semibold",children:e}),s.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[s.jsxs("kbd",{children:[L5?"⌘":"Ctrl","+Enter"]})," save · ",s.jsx("kbd",{children:"Esc"})," cancel"]})]}),b!==null&&s.jsx(js,{problem:Uo(b,"the note"),onRetry:()=>{g(null),O()},className:"m-5"}),s.jsxs("div",{className:"space-y-4 px-5 py-4",children:[$&&s.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[s.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[s.jsx(Js,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),s.jsxs("details",{className:"mt-2",children:[s.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),s.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:$})]})]}),s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),s.jsx(He,{ref:C,value:u.name,onChange:F=>I({name:F.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),s.jsx("span",{className:"-mt-0.5 mb-1.5 block text-small text-muted-foreground",children:"One line: what the next run sees before it opens the note."}),s.jsx(He,{value:u.description,onChange:F=>I({description:F.target.value}),placeholder:"When it applies, and what to do"})]}),s.jsxs("fieldset",{children:[s.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),s.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:M1.map(F=>s.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-1.5 text-label",u.type===F?"border-foreground":"text-muted-foreground hover:text-foreground"),title:F,children:[s.jsx("input",{type:"radio",name:`type-${o??"new"}`,className:"sr-only",checked:u.type===F,onChange:()=>I({type:F})}),L1(F)]},F))}),s.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:V4[u.type]})]}),s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),s.jsx(Ns,{value:u.body.replace(/^\n/,""),onChange:F=>I({body:`
536
+ ${F.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),w.length>0&&s.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[s.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),s.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:w.map((F,U)=>s.jsx("li",{children:F.detail},U))})]}),E&&s.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),S===sp?s.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",sp]}):S!==null&&s.jsx(js,{problem:qo(S,"the note","The note was not saved."),className:""}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>void z(),disabled:!D,children:m?"Saving":o?"Save":"Add note"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:m,children:"Cancel"}),!o&&u.name.trim()&&s.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:Ib(u.name,l)})]})]})]})}function X5({notes:e,all:t,from:n,focus:o,runs:i,v2:l,agentId:c,readOnly:u,onChanged:f}){const[p,h]=y.useState(null),[b,g]=y.useState(e.some(E=>o.includes(E.file))),[m,v]=y.useState(new Set),w=E=>v(_=>{const $=new Set(_);return $.has(E)?$.delete(E):$.add(E),$}),j=e.some(E=>o.includes(E.file));y.useEffect(()=>{j&&g(!0)},[j]);const S=E=>{var _;return((_=t.find($=>$.file===E))==null?void 0:_.name)??E},T=E=>{var $;const _=document.getElementById(`note-${E}`);($=_==null?void 0:_.scrollIntoView)==null||$.call(_,{block:"center",behavior:"smooth"}),_==null||_.focus({preventScroll:!0})};return s.jsx(Lj,{title:"Earlier notes",count:`${e.length} no longer read`,open:b,onToggle:()=>g(E=>!E),children:e.map(E=>{var C,O;const _=E.status==="retired",$=_&&m.has(E.file),R=(C=n.get(E.file))==null?void 0:C.run;return s.jsxs("li",{id:`note-${E.file}`,className:ie("border-b px-4 py-3 last:border-b-0",o.includes(E.file)&&"bg-primary/5"),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-lead text-muted-foreground line-through decoration-muted-foreground/40",children:E.name}),s.jsx(Pe,{tone:"muted",children:_?"Retired":"Replaced"}),_&&s.jsx(Ij,{open:$,label:`the note ${E.name}`,onClick:()=>w(E.file)}),_&&!u&&E.etag&&p!==E.file&&s.jsxs(Z,{size:"sm",onClick:()=>h(E.file),"aria-label":`Restore ${E.name}`,children:[s.jsx(t0,{"aria-hidden":!0})," Restore"]})]}),s.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:E.status==="superseded"&&E.superseded_by?s.jsxs(s.Fragment,{children:["Replaced by ",s.jsx("button",{type:"button",onClick:()=>T(E.superseded_by),className:"text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",children:S(E.superseded_by)})]}):_?Aj(E.retired):null}),p===E.file&&s.jsx("div",{className:"-mx-4 mt-2",children:s.jsx(Pj,{name:E.name,kind:"note",from:(O=E.retired)==null?void 0:O.from,restore:()=>l.restoreNote(c,E.file,E.etag),onChanged:f,onDone:()=>h(null)})}),$&&s.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[s.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:E.description}),kl(E.text).trim()&&s.jsx(Kd,{text:kl(E.text)}),R&&s.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:s.jsx(Vd,{run:R.id,runs:i,at:R.at,reason:R.reason})})]})]},E.file)})})}function Lj({title:e,count:t,open:n,onToggle:o,children:i}){return s.jsxs("section",{className:"border","aria-label":e,children:[s.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[s.jsx(Wo,{className:ie("size-3.5 text-muted-foreground transition-transform",!n&&"-rotate-90"),"aria-hidden":!0}),s.jsx("span",{className:"caps text-small font-semibold",children:e}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:t})]}),n&&s.jsx("ul",{className:"border-t",children:i})]})}function Y5({kind:e,items:t,v2:n,agentId:o,runs:i,readOnly:l,onChanged:c}){const[u,f]=y.useState(!1),[p,h]=y.useState(null),[b,g]=y.useState(new Set),m=v=>g(w=>{const j=new Set(w);return j.has(v)?j.delete(v):j.add(v),j});return s.jsx(Lj,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${t.length} no longer given`,open:u,onToggle:()=>f(v=>!v),children:t.map(v=>{var w;return s.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:v.name}),s.jsx(Pe,{tone:"muted",children:"Retired"}),s.jsx(Ij,{open:b.has(v.file),label:`the ${e} ${v.name}`,onClick:()=>m(v.file)}),!l&&p!==v.file&&s.jsxs(Z,{size:"sm",onClick:()=>h(v.file),"aria-label":`Restore ${v.name}`,children:[s.jsx(t0,{"aria-hidden":!0})," Restore"]})]}),v.description&&s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:v.description}),s.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:Aj(v.retired)}),p===v.file&&s.jsx("div",{className:"-mx-4 mt-2",children:s.jsx(Pj,{name:v.name,kind:e,from:(w=v.retired)==null?void 0:w.from,restore:()=>n.restoreNote(o,Dp(v),v.etag),onChanged:c,onDone:()=>h(null)})}),b.has(v.file)&&s.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[s.jsx(Q5,{v2:n,agentId:o,file:v.file,etag:v.etag,kind:e,label:`the ${e} ${v.name}`}),v.run&&s.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:s.jsx(Vd,{run:v.run,runs:i})})]})]},v.file)})})}function Ij({open:e,label:t,onClick:n}){return s.jsxs(Z,{size:"sm",variant:"ghost",className:"ml-auto",onClick:n,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${t}`,children:[s.jsx(Wo,{className:ie("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function Q5({v2:e,agentId:t,file:n,etag:o,kind:i,label:l}){const[c,u]=y.useState(null),[f,p]=y.useState(null),h=y.useRef(0),b=async()=>{const g=++h.current;p(null),u(null);try{const m=await e.readNote(t,n);g===h.current&&u(m.note)}catch(m){g===h.current&&p(m??new Error("unknown"))}};return y.useEffect(()=>{b()},[n,o]),f!==null?s.jsx("div",{className:"px-5 pt-3",children:s.jsx(js,{problem:Uo(f,l),onRetry:()=>void b(),className:""})}):c===null?s.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${l}`,children:s.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):i==="skill"?s.jsx(Kd,{text:kl(c)}):s.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:c})}function ow({runs:e}){const t=e.filter(i=>{var l;return((l=i.learning)==null?void 0:l.state)==="dropped"}),n=t.filter(i=>Ku(i.learning.reason)!=="nothing").slice(0,6),o=t.length-t.filter(i=>Ku(i.learning.reason)!=="nothing").length;return t.length?s.jsxs(Rj,{title:"Kept nothing",children:[n.length>0&&s.jsx("ul",{children:n.map(i=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("a",{href:`#/runs/${encodeURIComponent(i.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[s.jsx("span",{className:"block text-body",children:ag(i.learning)}),s.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 truncate",title:tn(i),children:tn(i)}),s.jsxs("span",{className:"shrink-0",children:["· ",Rt(i.created_at)]})]})]})},i.run_id))}),o>0&&s.jsxs("p",{className:ie("px-4 py-3 font-mono text-label text-muted-foreground",n.length>0&&"border-t"),children:[n.length?`${o} more ${o===1?"run":"runs"} had`:`${eo(o)} had`," nothing new to remember."]})]}):null}function Z5({index:e,skills:t,off:n}){const[o,i]=y.useState(!1),l=n?0:e.split(`
537
+ `).filter(p=>p.trim()).length,c=y.useMemo(()=>Ha(e.trim()),[e]),u=n?[]:t,f=u.length?`${u.length} ${u.length===1?"skill":"skills"}`:"";return s.jsxs("section",{className:"border","aria-label":"What the next run reads",children:[s.jsxs("button",{type:"button","aria-expanded":o,onClick:()=>i(p=>!p),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[s.jsx(Wo,{className:ie("size-3.5 text-muted-foreground transition-transform",!o&&"-rotate-90"),"aria-hidden":!0}),s.jsx("span",{className:"caps text-small font-semibold",children:"What the next run reads"}),s.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:[l?Ma(l):"",f].filter(Boolean).join(" · ")||"nothing"})]}),o&&s.jsxs("div",{className:"border-t",children:[n?s.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:"Learning is off: the next run gets no notes or skills."}):l?s.jsx("div",{className:ie(Cj,"max-h-72 overflow-auto break-words px-4 py-3 text-body"),dangerouslySetInnerHTML:{__html:c}}):s.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:u.length?"No note is in use.":"Nothing yet: no note is in use."}),u.length>0&&s.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Active skills: ",u.join(", ")]}),s.jsx("p",{className:"border-t px-4 py-2 text-label text-muted-foreground",children:"Read-only: the notes in use, one line each, and the agent's active skills."})]})]})}function Xp(e,t){return t&&e.startsWith(`${t}/`)&&e.length>t.length+1?{text:e.slice(t.length+1),title:e}:{text:e}}function zj(e,t){var n;return((n=t==null?void 0:t.find(o=>o.id===e))==null?void 0:n.default_model)??void 0}const J5="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",eP="none yet: add a model key in Settings → Model keys";class Yp extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const aw=e=>Math.min(1e4,1e3*2**e),iw=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),tP=e=>(e==null?void 0:e.name)==="AbortError",lw=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function nP({fetch:e=(i,l)=>globalThis.fetch(i,l),probe:t="/v2/health",resumedMs:n=5e3,probeMs:o=5e3}={}){let i={state:"online"};const l=new Set,c=new Set;let u=[],f,p=null,h=null;const b=_=>{i=_;for(const $ of[...l])$()},g=_=>{const $=aw(_);clearTimeout(f),b({state:"offline",attempt:_,retryAt:Date.now()+$}),f=setTimeout(()=>void j(),$)},m=()=>{i.state!=="offline"&&g(0)},v=()=>{if(i.state!=="offline")return;clearTimeout(f),b({state:"resumed"});const _=u;u=[];for(const $ of _)$();for(const $ of[...c])$();f=setTimeout(()=>{i.state==="resumed"&&b({state:"online"})},n)};async function w(_){const $=setTimeout(()=>_.abort(),o);try{return!iw(await e(t,{method:"GET",cache:"no-store",credentials:"same-origin",signal:_.signal}))}catch{return!1}finally{clearTimeout($)}}async function j(){if(i.state!=="offline")return;clearTimeout(f),p==null||p.abort();const _=p=new AbortController,$=await w(_);p===_&&(p=null,i.state==="offline"&&($?v():g(i.attempt+1)))}const S=()=>h??(h=w(new AbortController).finally(()=>{h=null})),T=_=>new Promise(($,R)=>{if(_!=null&&_.aborted)return R(lw(_));const C=()=>{u=u.filter(I=>I!==O),R(lw(_))},O=()=>{_==null||_.removeEventListener("abort",C),$()};u.push(O),_==null||_.addEventListener("abort",C,{once:!0})});return{fetch:async(_,$)=>{var O;const R=(($==null?void 0:$.method)??"GET").toUpperCase(),C=R==="GET"||R==="HEAD";for(let I=0;;I++){let D,z;try{D=await e(_,$)}catch(H){if((O=$==null?void 0:$.signal)!=null&&O.aborted||tP(H))throw H;z=H}if(D&&!iw(D))return v(),D;if(i.state!=="offline"&&await S()){if(D)return D;if(!C)throw new Yp;if(I>=2)throw z;await new Promise(H=>setTimeout(H,aw(I)));continue}if(m(),!C)throw new Yp;await T($==null?void 0:$.signal)}},link:()=>i,subscribe:_=>(l.add(_),()=>{l.delete(_)}),onResume:_=>(c.add(_),()=>{c.delete(_)}),retryNow:()=>void j()}}const sP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),Dj=e=>e instanceof Yp||e instanceof TypeError&&/fetch|network/i.test(e.message);function fn(e,t){const n=`${sP(t)} could not be read.`;if(Dj(e))return{title:n,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Te))return{title:n,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const o=e.message,i=[e.code,e.requestId].filter(Boolean).join(" · "),l=(c,u)=>({title:n,why:c,next:u,said:o,code:i});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("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?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Its words say why: change what they name, then try again.")}function rP(e){return Dj(e)?"Can't reach agentrun-serve":e instanceof Te?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}const oP=[{id:"runs",label:"Runs",shows:()=>!0,Body:iP},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:lP},{id:"learning",label:"Learning",shows:(e,t)=>e.kind==="agentic"&&t.learning!==!1,Body:e=>s.jsx(I5,{agent:e.agent,v2:e.v2,focus:e.focus,server:e.learning,onAgent:e.onAgent,places:e.places,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,t)=>t.analytics,Body:y4}],Is=(e,t)=>`#/agents/${encodeURIComponent(e)}${t?`/${t}`:e==="new"?"/runs":""}`;function aP({v2:e,agentId:t,routePrefix:n,harnesses:o,efforts:i=[],go:l,tab:c,limits:u,learning:f,notes:p,places:h}){var ce;const[b,g]=y.useState(null),[m,v]=y.useState(null),[w,j]=y.useState(0),[S,T]=y.useState(void 0),[E,_]=y.useState(!1);y.useEffect(()=>{let le=!0;return g(null),v(null),T(void 0),e.getAgent(t).then(ye=>{le&&g(ye.agent)},ye=>{le&&v({cause:ye})}),e.statsOver({from:Qh(C1),agent:t}).then(ye=>{le&&T(ye)},()=>{le&&T(null)}),()=>{le=!1}},[e,t,w]);const $=Vu(b),R=y.useRef(0),[C,O]=y.useState(!1),I=()=>{const le=++R.current;e.getAgent(t).then(ye=>{le===R.current&&(g(ee=>ee&&ee.agent_id===ye.agent.agent_id?ye.agent:ee),O(!1))},()=>{le===R.current&&O(!0)})},D=le=>{g(ye=>({...le,tools:(ye==null?void 0:ye.tools)??le.tools})),I()},z=I,H=S===void 0?void 0:S!==null;if(m)return m.cause instanceof Te&&m.cause.status===404?s.jsx(rj,{what:"agent",id:t,list:{href:"#/agents",label:"Open the agents list"}}):s.jsx(_n,{problem:fn(m.cause,"the agent"),onRetry:()=>j(le=>le+1)});if(!b)return s.jsx(DO,{});const F=b.definition,U=b.kind==="workflow",X=U?Ho:mh,P=zj(F.harness??"pi",o),K=F.model?Xp(F.model,n):P?(({text:le,title:ye})=>({text:`${le} (default)`,title:ye}))(Xp(P,n)):{text:eP},M=U||o==null?void 0:o.find(le=>le.id===(F.harness??"pi")&&le.available===!1),G=M?`${M.id} doesn't run on this server${M.reason?`: ${M.reason}`:"."}`:void 0,B=$j(b,h),L=`${g5(B==null?void 0:B.place)}${B!=null&&B.byDefault?" (server default)":""}`,q=[...U?[]:[["Harness",F.harness??"pi"],["Model",K.text,K.title],["Thinking",F.thinking??"default"],["Runs",L]],["Revision",`rev ${F.version} of ${b.revisions}`]],ne=oP.filter(le=>le.shows(b,{analytics:H===!0,learning:f===void 0?c==="learning"?void 0:!1:!!f})),oe=ne.find(le=>le.id===c)??ne[0],ae=c==="analytics"&&H===void 0;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[s.jsxs("div",{"data-phone-row":!0,className:"flex flex-col gap-3 max-sm:flex-row max-sm:items-center",children:[s.jsxs("button",{type:"button",onClick:()=>l(b.archived_at?"#/agents?archived=true":"#/agents"),className:"caps flex items-center gap-2 self-start text-label text-muted-foreground hover:text-foreground max-sm:-m-1 max-sm:self-center max-sm:p-1",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," ",s.jsx("span",{className:"max-sm:sr-only",children:"Agents"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 max-sm:min-w-0 max-sm:flex-1 max-sm:flex-nowrap max-sm:gap-2",children:[s.jsx(X,{className:"size-5 shrink-0 text-muted-foreground max-sm:hidden","aria-hidden":!0}),s.jsx("h1",{className:"min-w-0 truncate font-mono text-xl font-semibold max-sm:text-lg",children:F.name}),s.jsx(Pe,{children:b.kind}),b.archived_at&&s.jsx(Pe,{tone:"muted",children:"Archived"}),F.approvals==="never"&&s.jsx(Pe,{tone:"warning",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"}),s.jsx("span",{className:"flex-1"}),s.jsxs(Z,{size:"sm",onClick:()=>l(Is(b.agent_id,"edit")),title:"Edit",className:"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",children:[s.jsx(Rl,{"aria-hidden":!0})," ",s.jsx("span",{className:"max-sm:sr-only",children:"Edit"})]}),s.jsx(sg,{context:{kind:"edit",agentId:b.agent_id,revision:b.revision},label:"Edit with your coding agent",iconOnPhone:!0})]})]}),F.description&&s.jsx("p",{id:"agent-description",className:ie("mt-2 max-w-3xl text-lead text-muted-foreground",!E&&"max-sm:line-clamp-2"),children:F.description}),s.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":F.description?"agent-description agent-facts":"agent-facts",onClick:()=>_(le=>!le),className:"mt-1.5 flex w-full min-w-0 items-center gap-1.5 text-left font-mono text-small text-muted-foreground sm:hidden",children:[s.jsx(Fs,{className:ie("size-3.5 shrink-0 transition-transform",E&&"rotate-90"),"aria-hidden":!0}),s.jsx("span",{className:"truncate",children:q.map(([,le])=>le).join(" · ")})]}),s.jsxs("dl",{id:"agent-facts",className:ie("mt-3 flex flex-wrap gap-x-6 gap-y-2",!E&&"max-sm:hidden"),"aria-label":"Current revision",children:[q.map(([le,ye,ee])=>s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:le}),s.jsx("dd",{className:"font-mono text-small",title:ee,children:ye})]},le)),!U&&s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Tools"}),s.jsx("dd",{className:"font-mono text-small",children:(ce=b.tools)!=null&&ce.length?s.jsx("ul",{className:"flex flex-wrap gap-x-4 gap-y-1","aria-label":"Tools",children:b.tools.map(le=>s.jsxs("li",{children:[s.jsx("span",{title:le.blurb,children:le.name}),le.provider?` · ${Ju(le.provider,le.name)}`:"",le.permission?` · ${le.permission}`:"",cj(le.resolved,le.name).unavailable&&s.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:le.resolved,children:" · unavailable"})]},le.name))}):"none"})]})]}),C&&s.jsxs("p",{role:"alert",className:"mt-3 flex items-center gap-3 text-body text-warning-text",children:["Couldn't refresh this agent.",s.jsx(Z,{size:"sm",variant:"outline",onClick:I,children:"Retry"})]}),G&&s.jsx("p",{className:"mt-3 font-mono text-small text-warning-text",role:"status","aria-label":"Harness not available",children:G})]}),!b.archived_at&&s.jsx(LO,{agent:b,efforts:i,v2:e,go:l,blocked:G,limits:u}),s.jsx(R1,{tabs:ne.map(le=>le.id==="learning"?{...le,label:s.jsxs(s.Fragment,{children:[le.label,s.jsx(xA,{n:$,className:"ml-1.5"})]})}:le),value:oe.id,onChange:le=>l(Is(b.agent_id,le))}),s.jsx("div",{role:"tabpanel","aria-label":ae?void 0:oe.label,className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-8",children:ae?s.jsx(Ss,{label:"Loading the tab",rows:4}):s.jsx(oe.Body,{agent:b,v2:e,go:l,stats:S,focus:p,learning:f,onAgent:D,onChanged:z,places:h})})]})}function iP({agent:e,v2:t}){const[n,o]=y.useState(null),[i,l]=y.useState(null),[c,u]=y.useState(!1),[f,p]=y.useState(null),h=y.useRef(0),b=g=>{const m=++h.current;p(null),g&&u(!0),t.listAgentRuns(e.agent_id,50,g,!!e.archived_at).then(v=>{m===h.current&&(o(w=>g?pj(w??[],v.runs):v.runs),l(v.next_cursor))}).catch(v=>{m===h.current&&p(fn(v,g?"more runs":"the runs"))}).finally(()=>{m===h.current&&u(!1)})};return y.useEffect(()=>{b(null)},[t,e.agent_id]),f&&!n?s.jsx(_n,{problem:f,onRetry:()=>b(null),className:""}):n?n.length?s.jsxs(s.Fragment,{children:[s.jsx(hO,{v2:t,run:n[0],onRun:g=>o(m=>m&&m.map(v=>v.run_id===g.run_id?g:v))},n[0].run_id),s.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[n.length,i?"+":""," ",n.length===1&&!i?"run":"runs"]}),s.jsx("ul",{className:"border","aria-label":"Runs",children:n.map(g=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("a",{href:`#/runs/${encodeURIComponent(g.run_id)}`,className:"flex flex-wrap items-center gap-x-4 gap-y-1 px-4 py-3 hover:bg-accent",children:[s.jsx(Gl,{run:g}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-lead",title:tn(g),children:tn(g)}),s.jsx(Id,{run:g}),g.effort&&s.jsxs(Pe,{children:["effort ",g.effort]}),s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Rt(g.created_at)}),g.ended_at&&s.jsx("span",{className:"font-mono text-small text-muted-foreground",title:"How long it ran",children:Ga(Date.parse(g.ended_at)-Date.parse(g.created_at))}),g.cost&&(g.cost.usd!==null||ti(g.cost))&&s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:so(g.cost,{ended:vl(g.status)})})]})},g.run_id))}),f&&s.jsx(_n,{problem:f,className:"mt-4"}),i&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(Z,{type:"button",size:"sm",onClick:()=>b(i),disabled:c,children:c?"Loading":"Load more"})})]}):s.jsxs("div",{className:"border px-4 py-12 text-center",children:[s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent yet."}),!e.archived_at&&s.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Start one above: its timeline shows here as the agent works."})]}):s.jsx(Ss,{label:"Loading the runs",rows:5})}function lP({agent:e,go:t}){const n=e.definition.workflow,o=y.useMemo(()=>cl(n),[n]),i=y.useMemo(()=>({meta:Pd(n,o)}),[n,o]);return s.jsxs("section",{className:"border",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[s.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),s.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[hg(jj(o))," · rev ",e.definition.version]}),s.jsx("span",{className:"flex-1"}),s.jsxs(Z,{size:"sm",onClick:()=>t(Is(e.agent_id,"edit")),children:[s.jsx(Rl,{"aria-hidden":!0})," Edit the workflow"]})]}),s.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:o.nodes.length?s.jsx(Wd,{graph:o,marks:i,label:"The workflow's graph",minScale:.55}):s.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."})}),s.jsx("div",{className:"border-t px-4 py-2",children:s.jsx(Hd,{})})]})}const cP=140,uP=32,dP=40,fP=60;function Fj({value:e,name:t,note:n,blurb:o,description:i,tag:l,why:c,alert:u,on:f,disabled:p,warn:h,onToggle:b}){const[g,m]=y.useState(!1),v=y.useRef(null),w=y.useRef(null),j=y.useRef(null),S=y.useRef(null),T=mu(v,"width",g,t),E=mu(w,"height",g,i),_=mu(j,"width",g,l),$=mu(S,"width",g,u),R=T??t.length>uP,C=!!i&&(E??i.length>cP),O=!!l&&(_??l.length>dP),I=!!u&&($??u.length>fP),D=!!c&&(c!==l||O),z=!!i&&(!!o||C)||D||I||R,H=(U,X)=>!g&&U&&X?U:void 0,F=U=>{U.preventDefault(),U.stopPropagation(),m(X=>!X)};return s.jsxs("label",{"data-tool-card":e,className:ie("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",g?"min-h-36":"h-36 overflow-hidden",f&&"border-foreground",h&&"border-warning/60",p?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("input",{type:"checkbox",value:e,checked:f,disabled:p,onChange:b,className:"shrink-0 accent-primary"}),s.jsx("span",{ref:v,title:H(t,R),className:ie("min-w-0",g?"[overflow-wrap:anywhere]":"truncate"),children:t}),n&&s.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:n})]}),o?s.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:o}):i&&!g?s.jsx("span",{ref:w,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:H(i,C),children:i}):null,l&&s.jsx("span",{ref:j,"data-tag":!0,title:H(c,D),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:l}),u&&!g&&s.jsx("span",{ref:S,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:H(u,I),children:u}),g&&s.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[i&&s.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:i}),c&&c!==i&&s.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),u&&s.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:u})]}),z&&s.jsx("button",{type:"button",onClick:F,"aria-expanded":g,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:g?"Less":"More"})]})}function mu(e,t,n,o){const[i,l]=y.useState(null);return y.useLayoutEffect(()=>{const c=e.current;if(n||!c)return;const u=()=>{(t==="width"?c.clientWidth>0:c.clientHeight>0)&&l(t==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};u();const f=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return f==null||f.observe(c),()=>f==null?void 0:f.disconnect()},[e,t,n,o]),i}function mP({servers:e,tools:t,harness:n,harnesses:o,onChange:i,onRetry:l}){const c=m=>i(t.includes(m)?t.filter(v=>v!==m):[...t,m]),u=t.filter(m=>Zu(m)),f=!o||o.includes(n),p=(m,v,w,j,S,T)=>{const E=t.includes(m),_=(!f||!!S)&&!E,$=j??S??(E&&!f?`Won't run on ${n}.`:void 0);return s.jsx("li",{className:"min-w-0",children:s.jsx(Fj,{value:m,name:v,note:T,description:w,alert:$,on:E,disabled:_,warn:!!j,onToggle:()=>c(m)})},m)},h=m=>s.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:m}),b=!f&&s.jsxs("p",{className:"text-small text-warning-text",children:[n," doesn't run MCP tools on this server",o!=null&&o.length?`: ${o.join(" and ")} do`:"","."]});if(e==="failed")return s.jsxs("div",{className:"mt-4 space-y-2",children:[s.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",l&&s.jsx(Z,{type:"button",onClick:l,size:"xs",className:"ml-1",children:"Retry"})]}),u.length>0&&h(u.map(m=>p(m,m,"Can't check right now whether its server still lists it.")))]});if(!e)return u.length?s.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const g=nO(t,e);return!e.length&&!g.length?s.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."}):s.jsxs("div",{className:"mt-4 space-y-4",children:[b,e.map(m=>s.jsxs("section",{"aria-label":`MCP server ${m.name}`,children:[s.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[m.name," · MCP server"]}),h(m.tools.map(v=>{var w;return p(ZA(m.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,tO(m.name,v,n)??(v.permission==="deny"?ug:void 0),(w=m.not_metered)!=null&&w.includes(v.name)?"not metered":void 0)}))]},m.name)),g.length>0&&s.jsxs("section",{"aria-label":"MCP grants that can't run",children:[s.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),h(g.map(m=>p(m.grant,m.grant,void 0,m.why)))]})]})}const pP=e=>e.offered&&(e.kind==="none"||e.providers.some(t=>t.ready)),hP=e=>{var t;return e.why??((t=e.providers.find(n=>!n.ready))==null?void 0:t.why)};function gP(e,t){var i;if(e.kind==="none")return{kind:"none"};const o=((t==null?void 0:t.kind)===e.kind&&e.providers.some(l=>l.ready&&l.id===t.provider)?t.provider:void 0)??((i=e.providers.find(l=>l.ready))==null?void 0:i.id);return o?{kind:e.kind,provider:o}:{kind:e.kind}}const xP=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},bg="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",wg=new Set(["sandbox","desktop","phone"]),yP=e=>e.charAt(0).toUpperCase()+e.slice(1);function vP({kinds:e,value:t,onChange:n,error:o,warning:i}){const l=e.find(c=>c.kind===t.kind);return s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),s.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const u=pP(c),f=u?void 0:hP(c),p=c.providers.filter(h=>h.ready).map(h=>h.name).join(", ");return s.jsxs("div",{"data-kind":c.kind,className:ie("border px-4 py-3",t.kind===c.kind?"border-foreground":"border-border",!u&&"opacity-60"),children:[s.jsxs("label",{className:ie("flex items-start gap-3",u?"cursor-pointer":"cursor-not-allowed"),children:[s.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:t.kind===c.kind,disabled:!u&&t.kind!==c.kind,onChange:()=>n(gP(c,t)),className:"mt-1 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block text-lead font-semibold",children:yP(c.kind)}),s.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:u?c.kind==="none"?"The run's folder only":p:"Not available here"})]})]}),f&&s.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[f," ",s.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),l&&l.kind!=="none"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),s.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:l.providers.map(c=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("label",{className:ie("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[s.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:t.provider===c.id,disabled:!c.ready&&t.provider!==c.id,onChange:()=>n({kind:l.kind,provider:c.id}),className:"mt-1 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[s.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&s.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&wg.has(l.kind)&&s.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:bg}),!c.ready&&c.why&&s.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),l&&l.tools.length>0&&s.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"The loop gets",children:[s.jsx("span",{className:"caps mr-2",children:"The loop gets"}),s.jsx("span",{className:"font-mono",children:l.tools.join(", ")})]}),o&&s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:o}),i&&s.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}function bP({value:e,saved:t,places:n,tools:o,picked:i,onChange:l,error:c,warning:u}){var _;const f=e??Bd(t),p=(f??vg(!1,i,n)).mode,h=(_=n.boxes.find($=>$.available))==null?void 0:_.id,b=(f==null?void 0:f.mode)==="sandbox"?f.box:h,g=!h&&p!=="sandbox",m=new Set(o.filter($=>$.sandbox_only).map($=>$.name)),[v,w]=y.useState([]),j=()=>{const $=i.filter(R=>m.has(R));w($),l({place:{mode:"runner"},...$.length?{tools:i.filter(R=>!m.has(R))}:{}})},S=$=>{w([]),$&&l({place:{mode:"sandbox",box:$}})},T=$=>$.map(R=>R.charAt(0).toUpperCase()+R.slice(1)).join(" and "),E=($,R,C,O,I=!1)=>s.jsxs("label",{className:ie("flex items-start gap-3 border px-4 py-3",p===$?"border-foreground":"border-border",I?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[s.jsx("input",{type:"radio",name:"place",value:$,checked:p===$,disabled:I,onChange:O,className:"mt-1 accent-primary"}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-lead font-semibold",children:R}),s.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:C})]})]});return s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[E("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),E("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>S(b),g)]}),g&&s.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[s.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),s.jsx("ul",{className:"mt-1",children:n.boxes.map($=>s.jsxs("li",{children:[s.jsx("span",{className:"font-mono",children:$.id}),$.reason?`: ${$.reason}`:""]},$.id))})]}),p==="sandbox"&&s.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:n.boxes.map($=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("label",{className:ie("flex items-start gap-3 px-4 py-2.5",$.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[s.jsx("input",{type:"radio",name:"box",value:$.id,checked:b===$.id,disabled:!$.available&&b!==$.id,onChange:()=>S($.id),className:"mt-1 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-mono text-body",children:$.id}),!$.available&&$.reason&&s.jsx("span",{className:"mt-0.5 block text-small",children:$.reason})]})]})},$.id))}),p==="runner"&&v.length>0&&s.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[T(v)," ",v.length===1?"runs":"run"," only in a sandbox, so ",v.length===1?"it's":"they're"," turned off for this agent."]}),c&&s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&s.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:u})]})}function Uj(e,t,n=t.map(o=>o.name)){return[...new Set([...n.filter(i=>e.some(l=>l.name===i)||t.some(l=>l.name===i)),...t.map(i=>i.name),...e.map(i=>i.name)])].map(i=>{const l=e.find(u=>u.name===i),c=t.find(u=>u.name===i);return{name:i,...l?{choice:l}:{},...c?{gate:c}:{}}})}function Qp({setting:e,label:t="Pinned",also:n=!1}){return e!=null&&e.pin_broken?s.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:RO}):e!=null&&e.pin?s.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[s.jsxs("span",{className:"text-foreground",children:[t,":"]})," ",TO(e.pin),". ",CO,n?" This server pins it too; both hold.":""]}):null}const wP="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function Wj({label:e,rows:t,settings:n,fallbackOf:o,permissionFallbackOf:i=m=>m.default_permission,resolvesOf:l,issues:c,busy:u=!1,refused:f=()=>!1,locked:p=!1,unattended:h=!1,noteOf:b,onEdit:g}){const m=t.some(T=>T.choice),v=t.some(T=>T.gate),w=t.some(T=>{var E;return((E=T.gate)==null?void 0:E.ask_needs)==="password"}),j=["Tool",...v?["Permission"]:[],...m?["Provider","Resolves to"]:[]],S=s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return s.jsxs(s.Fragment,{children:[w&&s.jsx("p",{className:"mb-2 text-small text-warning-text",children:wP}),s.jsx("div",{className:"relative overflow-x-auto",children:s.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[j.map(T=>s.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:T},T)),s.jsx("th",{children:s.jsx("span",{className:"sr-only",children:"Reset"})})]})}),s.jsx("tbody",{children:t.map(({name:T,choice:E,gate:_})=>{var K,M,G;const $=E?o(E):"",R=(K=n[T])==null?void 0:K.provider,C=E!==void 0&&R!==void 0&&R!==$,O=C?R:$,I=B=>g(L=>SO(L,T,B,$)),D=_?i(_):"allow",z=(M=n[T])==null?void 0:M.permission,H=_!==void 0&&z!==void 0&&z!==D,F=H?z:D,U=_!==void 0&&f(T,F),X=U&&p,P=X?"deny":F;return s.jsxs(y.Fragment,{children:[s.jsxs("tr",{"data-tool":T,"data-set":C||H?"":void 0,className:"border-b align-top last:border-b-0",children:[s.jsx("td",{className:"px-3 py-2.5 font-mono text-body",children:T}),v&&s.jsx("td",{className:"px-3 py-2",children:_?s.jsxs(s.Fragment,{children:[s.jsx(qt,{small:!0,label:`${T} permission`,value:P,disabled:u||X,onChange:B=>{const L=B;g(q=>_O(q,T,L,D))},className:ie("w-36",H&&"border-primary text-primary"),options:_.permissions.map(B=>({value:B,label:`${B}${B===D?" (default)":""}`,...B==="ask"&&_.ask_needs==="password"&&!h?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),H&&!X&&s.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",D]}),U&&s.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ug}),P==="deny"&&s.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:wO}),P==="ask"&&h&&!U&&s.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),P==="ask"&&_.ask_needs==="password"&&!h&&s.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."})]}):S}),m&&s.jsx("td",{className:"px-3 py-2",children:E?s.jsxs(s.Fragment,{children:[s.jsx(qt,{small:!0,label:`${T} provider`,value:O,disabled:u,onChange:B=>I(B),className:ie("w-56 max-w-full",C&&"border-primary text-primary"),options:E.providers.map(B=>({value:B,label:`${Ju(B,T)}${B===$?" (default)":""}`}))}),qb(O,T)&&s.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:qb(O,T)}),C&&s.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Ju($,T)]})]}):S}),m&&s.jsx("td",{className:"px-3 py-2.5",children:E?l(E,O):S}),s.jsx("td",{className:"px-2 py-2 text-right",children:C&&s.jsx(Z,{size:"sm",variant:"ghost",disabled:u,"aria-label":`Reset ${T} to its default`,onClick:()=>I(void 0),children:"Reset"})})]}),b!=null&&b(T)?s.jsx("tr",{"data-note":T,children:s.jsx("td",{colSpan:j.length+1,className:"px-3 pb-2.5",children:b(T)})}):null,(G=c[T])!=null&&G.length?s.jsx("tr",{children:s.jsx("td",{colSpan:j.length+1,className:"px-3 pb-2.5",children:c[T].map(B=>s.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:B},B))})}):null]},T)})})]})})]})}function Zp({value:e,prefix:t,tool:n}){const o=cj(e,n);return s.jsxs("span",{className:ie("block font-mono text-small",o.unavailable?"text-warning-text":"text-muted-foreground"),children:[t,o.text]})}const kP=({choice:e,harnesses:t=[]})=>s.jsx(s.Fragment,{children:xO.map(n=>{const o=t.find(i=>i.id===n&&!i.available);return o?s.jsxs("span",{title:o.reason,className:"block font-mono text-small text-muted-foreground opacity-60",children:[n,": not offered here"]},n):s.jsx(Zp,{value:e.resolves[n],prefix:`${n}: `,tool:e.name},n)})});function jP({agent:e,harness:t,model:n,tools:o,choices:i,gates:l=[],mcpServers:c,serverSettings:u,focus:f,callTools:p,value:h,issues:b,unattended:g=!1,onChange:m}){const v=new Set(o),w=i.filter(z=>v.has(z.name)||!z.available),j=l.some(z=>z.ask_needs==="password"),S=z=>{var H;return(H=e==null?void 0:e.tools)==null?void 0:H.find(F=>F.name===z)},T=z=>{var F;const H=Zu(z);return H?(F=c==null?void 0:c.find(U=>U.name===H.server))==null?void 0:F.tools.find(U=>U.name===H.tool):void 0},E=z=>{var F;const H=Zu(z);return H?(F=h[`mcp:${H.server}/*`])==null?void 0:F.permission:void 0},_=p?p.flatMap(z=>l.filter(H=>H.name===z)):[...new Set(o)].flatMap(z=>{var U;const H=l.find(X=>X.name===z);if(H)return[H];const F=S(z)??T(z);return!((U=F==null?void 0:F.permissions)!=null&&U.length)||!F.default_permission?[]:[{name:z,permission:F.permission??F.default_permission,default_permission:F.default_permission,permissions:F.permissions,...j&&F.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=Uj(w,_,[...l.map(z=>z.name),...i.map(z=>z.name)]),R=y.useRef(null);if(y.useEffect(()=>{var F,U;if(!f)return;const z=`${f} permission`,H=[...((F=R.current)==null?void 0:F.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(X=>X.getAttribute("aria-label")===z);(U=H==null?void 0:H.scrollIntoView)==null||U.call(H,{block:"center"}),H==null||H.focus()},[]),!$.length)return null;const C=(e==null?void 0:e.definition.tool_settings)??{},O=g!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:I,rest:D}=dj(b,"definition.tool_settings",$.map(z=>z.name));return s.jsxs("section",{"aria-label":"Tool settings",ref:R,children:[s.jsx("div",{className:"mb-2",children:s.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),s.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. ",p?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":g?"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."]}),s.jsx(Wj,{label:"This agent's tool settings",unattended:g,rows:$,settings:h,fallbackOf:z=>z.provider,issues:I,onEdit:z=>m(z(h)),noteOf:z=>{const H=h[z],F=u==null?void 0:u[z],U=!!(H!=null&&H.pin||H!=null&&H.pin_broken);return!U&&!(F!=null&&F.pin)&&!(F!=null&&F.pin_broken)?null:s.jsxs(s.Fragment,{children:[U&&s.jsx(Qp,{setting:H,label:"Pinned for this agent",also:!!(F!=null&&F.pin)}),(!U||(F==null?void 0:F.pin_broken))&&s.jsx(Qp,{setting:F,label:"Pinned on this server"})]})},refused:z=>ij(z,l,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:z=>{var H;return E(z.name)??((H=S(z.name))==null?void 0:H.default_permission)??z.permission},resolvesOf:z=>{var P,K,M,G,B,L;const H=(((P=h[z.name])==null?void 0:P.provider)??null)!==(((K=C[z.name])==null?void 0:K.provider)??null)||(((M=h[z.name])==null?void 0:M.permission)??null)!==(((G=C[z.name])==null?void 0:G.permission)??null)||O,F=(B=e==null?void 0:e.tools)==null?void 0:B.find(q=>q.name===z.name),U=F&&F.provider===(((L=h[z.name])==null?void 0:L.provider)??z.provider)?F.resolved:void 0,X=(n??"")===((e==null?void 0:e.definition.model)??"");return!H&&t===((e==null?void 0:e.definition.harness)??"pi")&&X&&U?s.jsx(Zp,{value:U,prefix:`${t}: `,tool:z.name}):!H&&!C[z.name]&&!n?s.jsx(Zp,{value:z.resolves[t],prefix:`${t}: `,tool:z.name}):s.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),D.map(z=>s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:z},z))]})}const pu=20,NP=400;function SP(e,t,n,o,i){const[l,c]=y.useState(null),[u,f]=y.useState(0),p=(o??[]).join(",");y.useEffect(()=>{if(!i||!n||l==="unsupported")return;const b=new AbortController,g=setTimeout(()=>{i({workflow:t,...o?{tools:o}:{}},b.signal).then(m=>{b.signal.aborted||c({text:e,check:m})},m=>{b.signal.aborted||((m==null?void 0:m.status)===404||(m==null?void 0:m.status)===405?c("unsupported"):c({text:e,failed:(m==null?void 0:m.message)||`the server answered ${(m==null?void 0:m.status)??"nothing"}`}))})},NP);return()=>{clearTimeout(g),b.abort()}},[e,n,p,i,u]);const h=()=>{c(null),f(b=>b+1)};return l==="unsupported"||!i?{mode:"lint",retry:h}:l&&l.text===e?"failed"in l?{mode:"failed",failed:l.failed,retry:h}:{mode:"server",check:l.check,retry:h}:{mode:"pending",retry:h}}function cw({text:e,onText:t,base:n,baseLabel:o,serverIssues:i,readOnly:l=!1,validate:c,tools:u}){var X;const f=y.useRef(null),p=y.useRef(null),[h,b]=y.useState(0),g=y.useMemo(()=>s4(e),[e]),m=y.useRef(null);g.ok&&(m.current={value:g.value,spans:g.spans});const v=(X=m.current)==null?void 0:X.value,w=y.useMemo(()=>cl(v),[v]),j=y.useMemo(()=>n===void 0?null:cl(n),[n]),S=y.useMemo(()=>j?I2(j,w):null,[j,w]),T=SP(e,g.ok?g.value:void 0,g.ok,u,l?void 0:c),E=y.useMemo(()=>g.ok&&!l?i4(g.value):[],[g,l]),_=y.useMemo(()=>T.mode!=="server"?E:[...T.check.issues.map(P=>({path:P.path,message:P.message,severity:"error"})),...T.check.warnings.map(P=>typeof P=="string"?{path:"",message:P,severity:"warning"}:{path:P.path??"",message:P.message,severity:"warning"})],[T.mode,T.mode==="server"?T.check:null,E]),$=g.ok?l4(g.spans,w.nodes.map(P=>P.path),h):null,R=y.useMemo(()=>({meta:Pd(v,w),diff:S?{added:S.added.map(P=>P.path),edited:[...S.changed,...S.rewritten].map(P=>P.next),moved:S.moved.map(P=>P.next),removed:S.removed.map(({label:P,kind:K})=>({label:P,kind:K}))}:void 0,selected:$?{path:$}:null}),[v,w,S,$]),C=e.split(`
538
+ `).length,O=P=>r4(e,P),I=[];g.ok||I.push({...O(g.error.offset),message:`JSON: ${g.error.message}`,severity:"error",offset:g.error.offset});for(const P of _){const K=g.ok?_b(g.spans,P.path):void 0,M=(K==null?void 0:K.start)??0;I.push({...O(M),message:P.message,severity:P.severity,offset:M,path:P.path})}for(const P of[...i??[]].reverse()){const K=P.path&&g.ok?_b(g.spans,P.path):void 0;I.unshift({...K?O(K.start):{line:0,col:0},message:`Server: ${P.message}`,severity:"error",offset:(K==null?void 0:K.start)??-1})}const D=new Map;for(const P of I)P.line&&D.get(P.line)!=="error"&&D.set(P.line,P.severity);const z=(P,K=P)=>{const M=f.current;!M||P<0||(M.focus(),M.setSelectionRange(P,K),M.scrollTop=Math.max(0,(O(P).line-4)*pu),b(P))};y.useEffect(()=>{const P=g.ok?g.spans.get("/root"):void 0;P&&f.current&&(f.current.scrollTop=Math.max(0,(O(P.start).line-2)*pu))},[]);const H=S?S.edges.added.length+S.edges.removed.length:0,F=S?S.added.length+S.changed.length+S.rewritten.length+S.removed.length+S.moved.length+H:0,U=I.filter(P=>P.severity==="error").length;return s.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[s.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[s.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),s.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[C," lines"]}),s.jsx("span",{className:"flex-1"}),l?s.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):s.jsxs(s.Fragment,{children:[T.mode==="failed"&&g.ok?s.jsxs("span",{className:"font-mono text-label text-warning-text",title:T.failed,children:["server check failed, showing local checks ",s.jsx(Z,{type:"button",onClick:T.retry,size:"xs",className:"ml-1",children:"Retry"})]}):T.mode!=="lint"&&g.ok&&s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:T.mode==="pending"?"checking...":"checked by the server"}),U?s.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[s.jsx(Da,{className:"size-3.5","aria-hidden":!0})," ",U," ",U===1?"problem":"problems"]}):s.jsx("span",{className:"caps text-label text-success-text",children:T.mode==="server"?"Valid":"Valid shape"})]})]}),s.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[s.jsx("div",{ref:p,"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:`${pu}px`},children:Array.from({length:C},(P,K)=>s.jsx("div",{className:ie("pr-2",D.get(K+1)==="error"&&"bg-destructive/15 text-destructive-text",D.get(K+1)==="warning"&&"bg-warning/15 text-warning-text"),children:K+1},K))}),s.jsx(Ns,{bare:!0,ref:f,value:e,readOnly:l,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:P=>{l||t(P.target.value),b(P.target.selectionStart)},onSelect:P=>b(P.target.selectionStart),onScroll:P=>{p.current&&(p.current.scrollTop=P.target.scrollTop)},onKeyDown:P=>{if(P.key!=="Tab"||l)return;P.preventDefault();const K=P.currentTarget,M=K.selectionStart,G=K.selectionEnd;t(`${e.slice(0,M)} ${e.slice(G)}`),requestAnimationFrame(()=>K.setSelectionRange(M+2,M+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:`${pu}px`,tabSize:2}})]}),!l&&s.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[I.length===0&&s.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:T.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."}),I.map((P,K)=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>z(P.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[P.severity==="error"?s.jsx(Da,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):s.jsx(Js,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),s.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:P.line?`L${P.line}:${P.col}`:"—"}),s.jsx("span",{className:"min-w-0 flex-1 break-words",children:P.message})]})},K))]})]}),s.jsxs("div",{className:"flex min-h-0 flex-col",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[s.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:hg(jj(w))}),S&&(F?s.jsxs("span",{className:"font-mono text-label",children:[[S.added.length&&`${S.added.length} new`,S.changed.length+S.rewritten.length&&`${S.changed.length+S.rewritten.length} edited`,S.removed.length&&`${S.removed.length} removed`,S.moved.length&&`${S.moved.length} moved`,!S.moved.length&&H&&`${H} ${H===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",s.jsxs("span",{className:"text-muted-foreground",children:["against ",o??"the current revision"]})]}):s.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",o??"the current revision"]})),s.jsx("span",{className:"flex-1"}),!g.ok&&m.current&&s.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),s.jsx("div",{className:ie("min-h-[360px] flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5 xl:h-[calc(100vh-330px)] xl:min-h-[480px]",!g.ok&&"opacity-60"),children:w.nodes.length?s.jsx(Wd,{graph:w,marks:R,label:"The workflow's graph",minScale:.55,onSelect:P=>{const K=g.ok?g.spans.get(`${P.path}/label`)??g.spans.get(P.path):void 0;K&&z(K.start,K.end)}}):s.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),s.jsx("div",{className:"border-t px-4 py-2",children:s.jsx(Hd,{})})]})]})}const _P="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function Hj(){return s.jsxs(s.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",s.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:_P,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let _a=null;function hu(e,t){return _a?_a({to:e,replay:t}):!1}function EP(e){const[t,n]=y.useState(null),o=y.useRef(location.hash);return y.useEffect(()=>{if(!e)return;const i=c=>c.to===o.current?!1:(n(c),!0);_a=i;const l=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",l),()=>{_a===i&&(_a=null),window.removeEventListener("beforeunload",l)}},[e]),{asking:t!==null,stay:()=>n(null),leave:()=>{var i;if(t!==null){if(n(null),t.to===null){(i=t.replay)==null||i.call(t);return}if(_a=null,!t.replay){location.hash=t.to;return}location.hash!==o.current?window.addEventListener("hashchange",t.replay,{once:!0}):t.replay()}}}}const Bj="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",uw=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function $P(e,t){if((e==null?void 0:e.kind)!=="invalid")return null;const n=Object.entries(e.fields).filter(([o])=>o==="definition.workflow"||o.startsWith("definition.workflow/")).map(([o,i])=>({path:o.slice(19),message:i}));return n.length?n:t?[{path:"",message:e.message}]:null}function TP(e){var n;const t=(n=/^definition\.([a-z_]+)/.exec(e))==null?void 0:n[1];if(t){if(["name","description","instructions"].includes(t))return"context";if(["tools","tool_settings","approvals","skills"].includes(t))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(t))return"settings";if(["place","computer"].includes(t))return"computer";if(t==="workflow")return"workflow"}}const CP=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Ka},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:Ho},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:Cl},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Ru},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:n0},{id:"history",label:"History",note:"Revisions and the current one",Icon:gh}];function RP({agent:e,revisions:t=[],caps:n,onSave:o,onMakeCurrent:i,onArchive:l,onReload:c,onBack:u,step:f,problem:p=null,notice:h,draft:b,validate:g,providerChoices:m=[],permissionGates:v=[],focusTool:w,mcpServers:j=null,serverToolSettings:S,onRetryMcp:T}){var Yt,Wn,rs,os,Tn,Hn,Bn;const E=!e,_=e==null?void 0:e.definition,[$,R]=y.useState(f??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),C=E?up(n.places):void 0,[O,I]=y.useState({name:(_==null?void 0:_.name)??"",description:(_==null?void 0:_.description)??"",instructions:(_==null?void 0:_.instructions)??(E?S5:""),harness:(_==null?void 0:_.harness)??"pi",thinking:_==null?void 0:_.thinking,model:_==null?void 0:_.model,tools:E?dp("pi",n.tools,C):(_==null?void 0:_.tools)??[],maxCostText:typeof(_==null?void 0:_.max_cost_usd)=="number"&&_.max_cost_usd>0?String(_.max_cost_usd):"",...C?{place:C}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:b??JSON.stringify(_.workflow,null,2)}:{}}),D=y.useRef(O);D.current=O;const[z,H]=y.useState(O),F=J=>{const{maxCostText:we,workflowText:Ge,...dt}=J,Ke=Jb(we),Nt=uw(Ge),nn={...dt,maxCost:Ke.ok?Ke.value??0:we,...Ge!==void 0?{workflowSent:Nt!==void 0?Nt:Ge}:{}},yt=e?{...gg(e,nn,"").definition}:{...nn};return delete yt.version,yt.tool_settings&&!Object.keys(yt.tool_settings).length&&delete yt.tool_settings,{...yt,tools:[...yt.tools??[]].sort(),approvals:J.approvals??(_==null?void 0:_.approvals)??"ask"}},U=!ll(F(O),F(z)),[X,P]=y.useState([]),[K,M]=y.useState(!1),G=n.tools.map(J=>`${J.name}:${J.available}:${(J.harnesses??[]).join("+")}`).join(","),B=JSON.stringify(up(n.places)??null);y.useEffect(()=>{if(!E)return;const J=we=>{const Ge=we.place??up(n.places);return{...we,...Ge?{place:Ge}:{},...K?{}:{tools:dp(we.harness??"pi",n.tools,Ge)}}};I(J),H(J)},[G,B]);const[L,q]=y.useState(""),[ne,oe]=y.useState(!1),[ae,ce]=y.useState(!1),[le,ye]=y.useState(p),[ee,be]=y.useState(null),Oe=J=>{be(null),R(J)},We=J=>(le==null?void 0:le.kind)==="invalid"&&Object.entries(le.fields).filter(([we])=>we===`definition.${J}`||we.startsWith(`definition.${J}[`)||we.startsWith(`definition.${J}.`)).map(([,we])=>we).join(" ")||void 0,fe=(e==null?void 0:e.warnings)??[],Re=J=>P5(fe,J).map(we=>we.message).join(" ")||void 0,Xe=J=>{E&&ae||I(we=>({...we,...J}))},Kt=y.useRef(null);y.useEffect(()=>{var J;((le==null?void 0:le.kind)==="invalid"||(le==null?void 0:le.kind)==="other")&&((J=Kt.current)==null||J.focus())},[le]);const De=(e==null?void 0:e.kind)==="workflow",et=E&&Ej(O.harness),Ut=[...(Yt=O.name)!=null&&Yt.trim()?[]:["Give the agent a name to create it."],...!De&&!et&&!((Wn=O.instructions)!=null&&Wn.trim())?["Write its instructions to create it."]:[]],Wt=O.approvals??(_==null?void 0:_.approvals)??"ask",jt=A5(n.harnesses,E?{available:!!n.decisionProvider}:void 0),ss={mcpHarnesses:n.mcpHarnesses,workflow:De},hn=J=>{if(J.mode==="sandbox")return;const we=new Set(n.tools.filter(Ge=>Ge.sandbox_only).map(Ge=>Ge.name));P(Ge=>Ge.filter(dt=>!we.has(dt)))},Xt=J=>{if(E&&!K){Xe({harness:J,tools:dp(J,n.tools,O.place)}),P([]);return}const we=$5(J,O.tools??[],X,n.tools,ss);Xe({harness:J,tools:we.tools}),P(we.held)},at=t.find(J=>J.revision===(e==null?void 0:e.revision))??t.find(J=>J.current),ct=CP.filter(J=>!(E&&J.id==="history")&&(J.id!=="workflow"||De)&&!(et&&J.id==="tools")&&(J.id!=="computer"||!De&&!et&&!!(n.computers||n.places))),Me=ct.some(J=>J.id===$)?$:ct[0].id,Le=ct.findIndex(J=>J.id===Me),At=async()=>{if(!o)return;const J=O;ce(!0);let we={...O,workflowText:void 0,maxCostText:void 0};if(!et){const Ke=Jb(O.maxCostText);if(!Ke.ok){ce(!1),ye({kind:"invalid",message:Ke.message,fields:{"definition.max_cost_usd":Ke.message}});return}const Nt=typeof(_==null?void 0:_.max_cost_usd)=="number"&&_.max_cost_usd>0,nn=Ke.value??0;(nn!==0||Nt)&&(we={...we,max_cost_usd:nn})}if(De)try{we={...we,workflow:JSON.parse(O.workflowText??"")}}catch(Ke){ce(!1),ye({kind:"invalid",message:`The workflow is not JSON: ${Ke.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Ke.message}`}});return}const Ge=await o(we,L),dt=ll(D.current.tool_settings??{},we.tool_settings??{});ce(!1),ye(Ge),!Ge&&(q(""),D.current.harness===J.harness&&P([]),H(dt?(({tool_settings:Ke,...Nt})=>Nt)(J):J),dt&&I(({tool_settings:Ke,...Nt})=>Nt))},ut=EP(!ae&&U),Lt=zj(O.harness??"pi",n.harnesses),En=Lt?Xp(Lt,n.routePrefix):void 0,$n=Gd(O.harness??"pi",n.tools).filter(J=>nw([J.name])).map(J=>J.name);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[s.jsx(Z,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:u,children:s.jsx(zs,{"aria-hidden":!0})}),s.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:E?void 0:_.name,children:E?"New agent":_.name}),e&&s.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[s.jsx(Pe,{children:e.kind}),s.jsxs("span",{className:"caps text-label text-muted-foreground",children:[at?`rev ${at.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),l&&s.jsxs(Z,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>l(!e.archived_at),children:[s.jsx($l,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(le==null?void 0:le.kind)==="conflict"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[s.jsx(Js,{className:"size-4 text-warning-text","aria-hidden":!0}),s.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."}),s.jsx(Z,{size:"sm",onClick:c,children:"Reload"})]}),h&&s.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}),fe.length>0&&s.jsxs("div",{className:"border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[s.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[s.jsx(Js,{className:"size-4 shrink-0","aria-hidden":!0})," Saved. A run of this revision is refused until the server has what each line names:"]}),s.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:fe.map((J,we)=>{const Ge=ct.find(dt=>dt.id===TP(J.field));return s.jsxs("li",{children:[Ge?s.jsx("button",{type:"button",title:J.field,onClick:()=>Oe(Ge.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ge.label}):s.jsx("span",{className:"text-muted-foreground",children:J.field})," ",J.message]},`${J.field}:${we}`)})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[s.jsx("ol",{className:ie("relative flex shrink-0 gap-1 overflow-x-auto border-b p-3 md:flex-col md:gap-0 md:border-b-0 md:border-r md:p-4",Me==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:ct.map((J,we)=>s.jsx("li",{className:"shrink-0",children:s.jsxs("button",{type:"button","aria-current":Me===J.id?"step":void 0,onClick:()=>Oe(J.id),className:ie("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",Me===J.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[s.jsx("span",{className:ie("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",Me===J.id?"border-foreground bg-foreground text-background":we<Le?"border-border-strong":"border-border"),children:we<Le?s.jsx(dd,{className:"size-3","aria-hidden":!0}):we+1}),s.jsxs("span",{className:ie("hidden min-w-0",Me!=="workflow"&&"md:block"),title:Me==="workflow"?J.label:void 0,children:[s.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[s.jsx(J.Icon,{className:"size-3.5","aria-hidden":!0})," ",J.label]}),s.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:J.note})]}),s.jsx("span",{className:"sr-only md:hidden",children:J.label})]})},J.id))}),s.jsx("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:s.jsxs("fieldset",{disabled:E&&ae,className:"m-0 min-w-0 border-0 p-0",children:[s.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",Le+1]}),s.jsx("h2",{className:"caps mb-6 border-b pb-4 text-prose font-semibold",children:ct[Le].label}),Me==="context"&&s.jsxs("div",{className:"max-w-3xl space-y-6",children:[s.jsx(Ps,{label:"Name",id:"agent-name",required:E,note:E?void 0:"Set when the agent was created; an edit keeps it.",error:We("name"),warning:Re("name"),children:s.jsx(He,{id:"agent-name",value:O.name,readOnly:!E,onChange:J=>Xe({name:J.target.value}),placeholder:"e.g., Invoice checker"})}),s.jsx(Ps,{label:"Description",id:"agent-description",optional:!0,note:E?void 0:"Set when the agent was created; an edit keeps it.",error:We("description"),warning:Re("description"),children:s.jsx(He,{id:"agent-description",value:O.description,readOnly:!E,onChange:J=>Xe({description:J.target.value}),placeholder:E?"Short summary for the agent list":"No description"})}),et?s.jsx(Ps,{label:"Workflow",children:s.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:O.harness===xg?"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."})}):De?s.jsx(Ps,{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:Re("workflow"),children:s.jsxs(Z,{size:"sm",onClick:()=>R("workflow"),children:[s.jsx(Ho,{"aria-hidden":!0})," Open the workflow"]})}):s.jsxs(Ps,{label:"Instructions",id:ne?void 0:"agent-instructions",required:!0,error:We("instructions"),warning:Re("instructions"),aside:s.jsx("span",{className:"flex",children:["Preview","Edit"].map(J=>s.jsx(Z,{type:"button",size:"xs","aria-pressed":J==="Preview"===ne,onClick:()=>oe(J==="Preview"),className:ie("-ml-px first:ml-0",J==="Preview"===ne?"relative border-foreground bg-foreground text-background hover:bg-foreground":"text-muted-foreground"),children:J},J))}),children:[ne?s.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:Ha(O.instructions||"")}}):s.jsx(Ns,{id:"agent-instructions",value:O.instructions,onChange:J=>Xe({instructions:J.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:"resize-y leading-[1.7]"}),s.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(O.instructions??"").length," characters"]})]})]}),Me==="workflow"&&s.jsx(cw,{text:O.workflowText??"",onText:J=>Xe({workflowText:J}),base:De?_.workflow:void 0,baseLabel:at?`rev ${at.version}`:void 0,validate:g,tools:O.tools,serverIssues:$P(le,De)}),Me==="computer"&&!De&&!et&&n.computers&&s.jsx("div",{className:"max-w-4xl space-y-8",children:s.jsx(vP,{kinds:n.computers,value:O.computer??(_==null?void 0:_.computer)??Zb(O.place??{mode:"runner"}),onChange:J=>{const we=xP(J),Ge=new Set(n.tools.filter(dt=>dt.sandbox_only).map(dt=>dt.name));Xe({computer:J,place:we,...we.mode==="runner"?{tools:(O.tools??[]).filter(dt=>!Ge.has(dt))}:{}}),hn(we)},error:We("computer")??We("place"),warning:Re("computer")??Re("place")})}),Me==="computer"&&!De&&!et&&!n.computers&&n.places&&s.jsx("div",{className:"max-w-3xl space-y-8",children:s.jsx(bP,{value:O.place,saved:_==null?void 0:_.place,places:n.places,tools:n.tools,picked:O.tools??[],onChange:J=>{Xe({...J,...J.place?{computer:Zb(J.place)}:{}}),J.place&&hn(J.place)},error:We("computer")??We("place"),warning:Re("computer")??Re("place")})}),Me==="tools"&&s.jsxs("div",{className:"max-w-3xl space-y-6",children:[s.jsxs(Ps,{label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:We("tools"),warning:Re("tools"),children:[s.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[n.tools.filter(J=>{var we;return De||!J.call_only||((we=O.tools)==null?void 0:we.includes(J.name))}).map(J=>{var sn,_s;const we=qp(O.harness??"pi",J.name,n.tools,ss),Ge=((sn=O.tools)==null?void 0:sn.includes(J.name))??!1,dt=m.find(Cn=>Cn.name===J.name),Ke=(_s=(O.tool_settings??(_==null?void 0:_.tool_settings)??{})[J.name])==null?void 0:_s.provider,Nt=!!dt&&Ke!==void 0&&Ke!==dt.provider,nn=T5(J,O.place??Bd(_==null?void 0:_.place)??vg(De,O.tools??[],n.places)),yt=ij(J.name,v,e==null?void 0:e.tools)?ug:J.call_only&&!De?"Workflow-only: a workflow's call node runs it, not an agent":we?nn??(!J.available&&!Nt?(dt==null?void 0:dt.reason)??J.reason??`Needs ${(J.missing??[]).join(", ")}`:void 0):tw(O.harness??"pi",J.name,n.tools),Ws=yt?J.call_only&&!De?"Workflow only":nn&&we&&yt===nn?"Sandbox-only":yt:void 0;return s.jsx("li",{className:"min-w-0",children:s.jsx(Fj,{value:J.name,name:J.name,blurb:J.blurb,description:J.summary,why:yt,tag:Ws,on:Ge,disabled:!!yt&&!Ge,onToggle:()=>{M(!0),Xe({tools:Ge?O.tools.filter(Cn=>Cn!==J.name):[...O.tools??[],J.name]})}})},J.name)}),n.mcp&&!De&&s.jsx("li",{className:"sm:col-span-2",children:s.jsx(mP,{servers:j,tools:O.tools??[],harness:O.harness??"pi",harnesses:n.mcpHarnesses,onRetry:T,onChange:J=>{M(!0),Xe({tools:J})}})})]}),!De&&!nw(O.tools??[])&&s.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",$n.length?`tick ${$n.join(" or ")} in Tools.`:`${O.harness??"pi"} runs no web tool on this server.`]})]}),s.jsx(jP,{agent:e,unattended:!De&&Wt==="never",harness:O.harness??"pi",model:O.model,tools:O.tools??[],choices:De?[]:m,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:S,focus:w,callTools:De?yO(uw(O.workflowText)??(_==null?void 0:_.workflow)):void 0,value:O.tool_settings??(_==null?void 0:_.tool_settings)??{},issues:(le==null?void 0:le.kind)==="invalid"?le.fields:{},onChange:J=>!ae&&ll(J,(_==null?void 0:_.tool_settings)??{})?I(({tool_settings:we,...Ge})=>Ge):Xe({tool_settings:J})}),!De&&!et&&s.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[s.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(([J,we,Ge])=>s.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",Wt===J&&"border-foreground"),children:[s.jsx("input",{type:"radio",name:"approvals",value:J,className:"mt-1 accent-primary",checked:Wt===J,disabled:ae,onChange:()=>Xe({approvals:J})}),s.jsxs("span",{children:[s.jsx("span",{className:"font-mono text-body",children:we}),s.jsx("span",{className:"block text-small text-muted-foreground",children:Ge})]})]},J)),Wt==="never"&&s.jsx("p",{className:"text-small text-warning-text",children:Bj})]}),s.jsx(Ps,{label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(rs=_==null?void 0:_.skills)!=null&&rs.length?s.jsx("ul",{className:"border",children:_.skills.map(J=>s.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:J},J))}):s.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),Me==="settings"&&s.jsxs("div",{className:"max-w-3xl space-y-8",children:[!De&&s.jsxs(Ps,{named:!0,label:"Harness",note:"What runtime runs this agent.",error:We("harness"),warning:Re("harness"),children:[s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:jt.map(J=>{const we=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"radio",name:"harness",value:J.id,checked:O.harness===J.id,disabled:!J.available&&O.harness!==J.id,onChange:()=>Xt(J.id),className:"mt-1 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:J.label}),s.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:J.available?J.id:"Not available here"})]})]}),Ge=ie("min-w-0 border px-4 py-3",O.harness===J.id?"border-foreground":"border-border");return J.available?s.jsx("label",{className:ie(Ge,"flex cursor-pointer items-start gap-3"),children:we},J.id):s.jsxs("div",{className:ie(Ge,"opacity-60"),children:[s.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:we}),J.reason&&s.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),s.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:J.reason})]})]},J.id)})}),X.length>0&&s.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:[s.jsxs("p",{className:"text-warning-text",children:[((os=jt.find(J=>J.id===O.harness))==null?void 0:os.label)??O.harness," doesn't run ",X.length===1?"this tool":"these tools"," here, so ",X.length===1?"it's":"they're"," unticked. Switching back ticks ",X.length===1?"it":"them"," again."]}),s.jsx("ul",{className:"mt-1 space-y-0.5",children:X.map(J=>s.jsxs("li",{children:[J,": ",s.jsx("span",{className:"text-muted-foreground",children:tw(O.harness??"pi",J,n.tools,n.mcpHarnesses)})]},J))})]})]}),!De&&!et&&s.jsx(Ps,{named:!0,label:"Thinking",note:"How hard the model thinks before it answers.",error:We("thinking"),warning:Re("thinking"),children:s.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:n.thinking.map(J=>s.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-2 text-small",O.thinking===J?"border-foreground":"text-muted-foreground"),children:[s.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:O.thinking===J,onChange:()=>Xe({thinking:J})}),J]},J))})}),!et&&s.jsx(Ps,{label:"Model",id:"agent-model",optional:!0,note:En?s.jsxs(s.Fragment,{children:["Empty uses the server's default (",s.jsx("span",{title:En.title,children:En.text}),")."]}):J5,error:We("model"),warning:Re("model"),children:s.jsx(He,{id:"agent-model",value:O.model??"",onChange:J=>Xe({model:J.target.value||void 0}),placeholder:"provider/model"})}),!et&&s.jsx(Ps,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:"A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",hint:s.jsx(Hj,{}),error:We("max_cost_usd"),warning:Re("max_cost_usd"),children:s.jsx(He,{id:"agent-max-cost",inputMode:"decimal",value:O.maxCostText??"",onChange:J=>Xe({maxCostText:J.target.value}),placeholder:"e.g., 2.50"})}),!De&&!et&&n.learning&&s.jsx(WO,{fields:O,onFields:Xe,saved:_==null?void 0:_.learning,server:n.learning,error:We("learning"),warning:Re("learning")})]}),Me==="history"&&ee&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs(Z,{size:"sm",variant:"ghost",onClick:()=>be(null),children:[s.jsx(zs,{"aria-hidden":!0})," Back to History"]}),s.jsxs("span",{className:"caps text-small",children:["rev ",ee.version]}),s.jsx("span",{className:"min-w-0 flex-1 text-lead",children:ee.note??s.jsx("span",{className:"text-muted-foreground",children:"No note"})}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Rt(ee.created_at)}),s.jsx(Z,{size:"sm",onClick:()=>i==null?void 0:i(ee.revision),disabled:!i,children:"Make current"})]}),s.jsx(cw,{readOnly:!0,text:JSON.stringify((Tn=ee.definition)==null?void 0:Tn.workflow,null,2),onText:()=>{},base:_.workflow,baseLabel:at?`rev ${at.version}, the current one`:"the current revision"})]}),Me==="history"&&!ee&&s.jsx("ul",{className:"max-w-3xl border",children:t.map(J=>{var we;return s.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[s.jsxs("span",{className:"caps w-14 text-small",children:["rev ",J.version]}),s.jsx("span",{className:"min-w-0 flex-[1_1_14rem] break-words text-lead",children:J.note??s.jsx("span",{className:"text-muted-foreground",children:"No note"})}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Rt(J.created_at)}),De&&!J.current&&((we=J.definition)==null?void 0:we.workflow)!==void 0&&s.jsxs(Z,{size:"sm",variant:"ghost",onClick:()=>be(J),"aria-label":`View rev ${J.version}`,children:[s.jsx(Qw,{"aria-hidden":!0})," View"]}),J.current?s.jsx(Pe,{tone:"success",children:"Current"}):s.jsx(Z,{size:"sm",onClick:()=>i==null?void 0:i(J.revision),disabled:!i,children:"Make current"})]},J.revision)})})]})})]}),s.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[s.jsxs(Z,{size:"sm",variant:"ghost",disabled:Le===0,onClick:()=>Oe(ct[Le-1].id),children:[s.jsx(zs,{"aria-hidden":!0})," Previous"]}),Me!=="history"&&s.jsx(He,{value:L,onChange:J=>q(J.target.value),placeholder:E?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ie("h-9 min-w-0 flex-1",E&&"invisible")}),Me==="history"&&s.jsx("span",{className:"flex-1"}),Le<ct.length-1&&s.jsxs(Z,{size:"sm",onClick:()=>Oe(ct[Le+1].id),children:["Next ",s.jsx(fh,{"aria-hidden":!0})]}),!ee&&s.jsx(Z,{ref:Kt,size:"sm",variant:"solid",onClick:At,disabled:!o||ae||!E&&!U||!((Hn=O.name)!=null&&Hn.trim())||!De&&!et&&!((Bn=O.instructions)!=null&&Bn.trim()),children:E?ae?"Creating…":"Create":ae?"Saving…":U?"Save revision":at?`Saved · rev ${at.version}`:"Saved"}),E&&!ae&&!ee&&Ut.map(J=>s.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:J},J)),(le==null?void 0:le.kind)==="invalid"&&s.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",le.message]}),(le==null?void 0:le.kind)==="other"&&s.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:le.message})]}),s.jsxs(j4,{open:ut.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:ut.leave,onCancel:ut.stay,children:[E?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const Ps=({named:e,...t})=>s.jsx(Ao,{...t,group:t.id?!1:e?"heading":!0});function AP({agents:e,archived:t=!1,onArchivedChange:n,actions:o={},error:i,handoff:l}){const[c,u]=y.useState(""),f=(e??[]).filter(p=>`${p.definition.name} ${p.definition.description??""}`.toLowerCase().includes(c.toLowerCase()));return s.jsxs("div",{className:"p-5 md:p-8",children:[s.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[s.jsxs("label",{className:ie("flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3",Xk),children:[s.jsx(u_,{className:"size-4 text-muted-foreground","aria-hidden":!0}),s.jsx(He,{bare:!0,value:c,onChange:p=>u(p.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"flex-1 max-sm:portrait:placeholder:text-transparent"})]}),s.jsxs(Z,{size:"lg",variant:t?"primary":"outline","aria-pressed":t,onClick:()=>n==null?void 0:n(!t),children:[s.jsx($l,{"aria-hidden":!0})," Archived"]}),!t&&l,!t&&s.jsxs(Z,{size:"lg",variant:"primary",onClick:o.onNew,children:[s.jsx(dl,{"aria-hidden":!0})," New agent"]})]}),i?s.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:i}):e?f.length?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),s.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:f.map(p=>s.jsx(OP,{agent:p,actions:o},p.agent_id))})]}):s.jsxs("div",{className:"border px-4 py-12 text-center",children:[s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:c?"No agent matches.":t?"No archived agents.":"No agents yet."}),!c&&!t&&s.jsxs(Z,{className:"mt-4",variant:"primary",onClick:o.onNew,children:[s.jsx(dl,{"aria-hidden":!0})," New agent"]})]}):s.jsx(Ss,{label:"Loading the agents",rows:6})]})}function OP({agent:e,actions:t}){const n=e.kind==="workflow"?Ho:mh,o=!!e.archived_at,i=Vu(e);return s.jsxs("li",{className:ie("flex flex-col border p-4",o&&"opacity-70"),children:[s.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var l;return(l=t.onOpen)==null?void 0:l.call(t,e.agent_id)},children:[s.jsx(n,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"font-mono text-prose font-semibold",children:e.definition.name}),s.jsx(Pe,{children:e.kind}),e.kind==="agentic"&&s.jsx(Pe,{children:e.definition.harness??"pi"}),o&&s.jsx(Pe,{tone:"muted",children:"Archived"})]}),s.jsx("span",{className:"mt-1.5 line-clamp-2 block font-mono text-small leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?c4(e.definition.workflow):"No description.")})]})]}),s.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-4",children:[s.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[s.jsxs(Pe,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&s.jsxs(Pe,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),i>0&&s.jsxs(Z,{size:"xs","aria-label":og(i),onClick:()=>{var l;return(l=t.onLearning)==null?void 0:l.call(t,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 · ",i]})]}),s.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex shrink-0 items-center gap-2",children:[s.jsx(Z,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Edit ${e.definition.name}`,onClick:()=>{var l;return(l=t.onEdit)==null?void 0:l.call(t,e.agent_id)},children:s.jsx(Rl,{"aria-hidden":!0})}),s.jsx(Z,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var l;return(l=t.onRuns)==null?void 0:l.call(t,e.agent_id)},children:s.jsx(gh,{"aria-hidden":!0})}),s.jsx(Z,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`${o?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var l;return(l=t.onArchive)==null?void 0:l.call(t,e.agent_id,!o)},children:o?s.jsx(Vw,{"aria-hidden":!0}):s.jsx($l,{"aria-hidden":!0})})]})]})]})}const $o=e=>e instanceof Te?O5(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function PP({v2:e,archived:t,go:n}){const[o,i]=y.useState(null),[l,c]=y.useState(null),u=y.useRef(0),f=()=>{const p=++u.current;i(null),c(null),Xr(h=>e.listAgents({archived:t,cursor:h}),h=>h.agents).then(h=>{p===u.current&&i(h)}).catch(h=>{p===u.current&&c($o(h).message)})};return y.useEffect(f,[e,t]),s.jsx(AP,{agents:o,archived:t,onArchivedChange:p=>n(p?"#/agents?archived=true":"#/agents"),error:l,handoff:s.jsx(sg,{context:{kind:"create"},label:"Build with your coding agent",size:"lg",iconOnPhone:!0,className:"max-sm:w-11"}),actions:{onOpen:p=>n(Is(p)),onEdit:p=>n(Is(p,"edit")),onNew:()=>n("#/agents/new"),onRuns:p=>n(Is(p,"runs")),onLearning:p=>n(Is(p,"learning")),onArchive:async(p,h)=>{try{await(h?e.archiveAgent(p):e.unarchiveAgent(p)),f()}catch(b){c($o(b).message)}}}})}function MP({v2:e,caps:t,choices:n=[],gates:o=[],focusTool:i,agentId:l,go:c}){const[u,f]=y.useState(null),[p,h]=y.useState(null),[b,g]=y.useState([]),[m,v]=y.useState(null),[w,j]=y.useState(null),[S,T]=y.useState(0),[E,_]=y.useState(null),$=y.useRef(!0);y.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const R=M=>Xr(G=>e.listRevisions(M,G),G=>G.revisions),C=async()=>{if(l)try{const[{agent:M,etag:G},B]=await Promise.all([e.getAgent(l),R(l)]);f(M),h(G),g(B),_(M.revision),T(L=>L+1),j(null),v(null)}catch(M){u?j(`The agent could not be reloaded: ${$o(M).message}`):v($o(M).message)}};y.useEffect(()=>{C()},[l]);const[O,I]=y.useState(null),D=y.useRef(0);y.useEffect(()=>{const M=++D.current;e.computers().then(G=>{M===D.current&&I(G.kinds)},()=>{M===D.current&&I(null)})},[e]);const[z,H]=y.useState(void 0);y.useEffect(()=>{let M=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{M&&H(G)},()=>{}),()=>{M=!1}},[e]);const[F,U]=y.useState(null),X=y.useRef(0),P=()=>{if(!t.mcp)return;const M=++X.current;U(null),e.listMcpServers().then(G=>{M===X.current&&U(G.servers)},()=>{M===X.current&&U("failed")})};y.useEffect(P,[e,t.mcp]);const K=async(M,G)=>{let B;try{B=await G()}catch(L){j(`${M} did not finish: ${$o(L).message}`);return}f(B);try{const{agent:L,etag:q}=await e.getAgent(B.agent_id),ne=await R(B.agent_id).catch(()=>b);f(L),h(q),g(ne),L.revision!==E?(_(L.revision),T(oe=>oe+1),j(M==="Make current"?null:`${M} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(L){j(`${M} done. The page could not be refreshed: ${$o(L).message}. Reload to see the current state.`)}};return l&&m&&!u?s.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:m}):l&&!u?s.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):s.jsx(RP,{agent:u,revisions:b,caps:{...t,computers:O},providerChoices:n,permissionGates:o,mcpServers:F,serverToolSettings:z,onRetryMcp:P,...i?{focusTool:i,step:"tools"}:{},notice:w,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{C(),P()},onSave:async(M,G)=>{let B;try{if(!u){const oe=await e.createAgent(_5({name:M.name??"",description:M.description??"",instructions:M.instructions??"",harness:M.harness??"pi",tools:M.tools??[],approvals:M.approvals,tool_settings:M.tool_settings,thinking:M.thinking,model:M.model,computer:M.computer,learning:M.learning,max_cost_usd:M.max_cost_usd,decisionProvider:t.decisionProvider}));return $.current&&c(Is(oe.agent_id,oe.kind==="workflow"?"workflow":void 0)),null}const L=gg(u,M,G);if(L.unchanged)return{kind:"other",message:"Nothing to save: the definition is the current revision's, and a note alone makes no new revision."};const{unchanged:q,...ne}=L;B=await e.updateDefinition(u.agent_id,ne,p)}catch(L){return $o(L)}return f(B.agent),h(B.etag),_(B.agent.revision),e.getAgent(B.agent.agent_id).then(L=>f(q=>q&&q.revision===L.agent.revision?{...q,tools:L.agent.tools}:q)).catch(()=>{}),R(B.agent.agent_id).then(g).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:M=>{u&&K("Make current",()=>e.setCurrent(u.agent_id,M))},onArchive:M=>{u&&K(M?"Archive":"Unarchive",()=>M?e.archiveAgent(u.agent_id):e.unarchiveAgent(u.agent_id))}},`${(u==null?void 0:u.agent_id)??"new"}:${S}`)}function Vo({error:e,title:t="The run failed"}){return s.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[s.jsx(Js,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"caps text-small font-semibold",children:t}),s.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),s.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 LP={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},IP={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"},zP=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function DP({id:e,className:t}){const[n,o]=y.useState(!1),i=LP[e],l=IP[e];return i&&!n?s.jsx("img",{"data-provider-icon":e,src:zP(i),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>o(!0),className:ie("size-4 shrink-0 object-contain",t)}):l?s.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ie("size-4 shrink-0",t),"aria-hidden":!0,children:s.jsx("path",{d:l})}):s.jsx(Tl,{className:ie("size-4 shrink-0 text-muted-foreground",t),"aria-hidden":!0})}const FP=/^(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,UP=40;function WP(e){const t=e.trim().replace(/\?+$/,""),n=t.lastIndexOf(":"),o=(n>=0?t.slice(n+1):t.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(n<0&&FP.test(o))return[];const i=o.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(i.length<2||i.length>4||!/\bor\b/i.test(o))return[];const l=i.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return l.some(c=>!c||c.length>UP)?[]:l.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function HP(e){var o,i;const t=new Map;for(const l of e){if(l.imported_from)continue;const c=((i=(o=l.error)==null?void 0:o.message)==null?void 0:i.trim())||"The run failed.";t.set(c,[...t.get(c)??[],l])}const n=l=>Date.parse(l.ended_at??l.created_at);return[...t].map(([l,c])=>({message:l,runs:c.sort((u,f)=>n(f)-n(u))})).sort((l,c)=>n(c.runs[0])-n(l.runs[0]))}function BP(e,t){return e.some(n=>!n.imported_from)||t.some(n=>n.source==="live"&&n.runs>0)}function Kl(e,t){const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));return n<60?`${n} s`:n<3600?`${Math.floor(n/60)} min`:n<86400?`${Math.floor(n/3600)} h`:`${Math.floor(n/86400)} days`}const GP=2e3;function qP(e,t){var o;if(e.kind==="workflow")return{refusal:`"${e.title}" is a workflow run: start it again from its agent's page`};if(!t)return{refusal:`"${e.title}": its first message could not be read`};if(t.length>=GP&&t.endsWith("..."))return{refusal:`"${e.title}": its first message is longer than the timeline keeps; start it again from its agent's page`};if(/\n\nFiles for this run: [^\n]*$/.test(t))return{refusal:`"${e.title}" was given files, which a run started again can't take along: start it again from its agent's page with them`};const n=(o=e.cost)==null?void 0:o.cap_usd;return{body:{input:{content:t},...e.effort?{effort:e.effort}:{},...typeof n=="number"?{max_cost_usd:n}:{}}}}function VP(e,t){let n=!1,o;const i=()=>{n||e().catch(()=>{}).finally(()=>{n||(o=setTimeout(i,t))})};return i(),()=>{n=!0,clearTimeout(o)}}const Gj=e=>e.pending!=null,KP=e=>e.status==="input_required"&&e.state!=="waiting"&&!Gj(e),XP=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function dw(e,t){const n={asking:(e==null?void 0:e.asking)??[],failed:(e==null?void 0:e.failed)??[],live:(e==null?void 0:e.live)??[]},o=[];return XP.forEach(([i,l],c)=>{const u=t[c];(u==null?void 0:u.status)==="fulfilled"?n[i]=u.value:u&&o.push(`${l} could not be read: ${u.reason instanceof Error?u.reason.message:String(u.reason)}`)}),{needs:n,problem:o.length?o.join(" · "):null}}const YP={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},QP={tool:1,model:1,mcp:2,computer:2,source:2};function nd(e,t){const n=e.split(":"),o=QP[n[0]];return(o===void 0?"":n.slice(o).join(":"))||t||n.slice(1).join(":")}const ZP="Sign in with your password to change secrets.",JP="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",eM="Open the console from the server's link to change secrets.",Xl={sign_in:ZP,no_accounts:JP,token:eM},qj=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,tM=e=>{var t;return((t=qj(e))==null?void 0:t.secrets_writable)===!0};function nM(e){const t=qj(e);return t!=null&&t.secrets_reason?t.secrets_reason:(t==null?void 0:t.accounts)===!1?"no_accounts":"sign_in"}function sM(e){const[t,n]=y.useState({writable:!1,whyNot:"sign_in"});return y.useEffect(()=>{let o=!0;return e.session().then(i=>{o&&n({writable:tM(i),whyNot:nM(i)})},()=>{}),()=>{o=!1}},[e]),t}function Xd({field:e,label:t,writable:n,required:o=!0,stateSaid:i=!1,now:l=Date.now,note:c,onPaste:u,onRemove:f}){const p=e.source==="env",h=n&&!p;return s.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:ie("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",p&&"opacity-60"),children:[s.jsxs("span",{children:[nd(e.name,t),!o&&s.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),s.jsx("span",{"data-state":e.set?"set":o?"missing":"optional-missing",className:i?"sr-only":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&s.jsx("span",{className:"text-muted-foreground",children:YP[e.source]}),e.changed_at&&s.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Kl(e.changed_at,l())," ago"]}),c&&s.jsx("span",{className:"text-warning-text",children:c}),h&&s.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[u&&s.jsx(Z,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),f&&e.set&&s.jsx(Z,{type:"button",size:"sm",variant:"destructive",onClick:f,children:"Remove"})]})]})}const rM={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."},fw=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function mw(e,t){return t?t.state==="accepted"?`${e} accepted this key · ${Rt(t.at)}`:`Not checked: ${t.reason}${t.at?` · ${Rt(t.at)}`:""}`:null}const oM="can't be opened: paste it again",aM=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Vj="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function iM({v2:e,onChange:t,writable:n,whyNot:o="sign_in"}){const[i,l]=y.useState(null),[c,u]=y.useState(null),[f,p]=y.useState(null),[h,b]=y.useState(null),g=y.useRef(0),m=()=>{const _=++g.current;e.listToolKeys().then($=>{_===g.current&&(l($),u(null))}).catch($=>{_===g.current&&u(fw($))})};y.useEffect(m,[e]);const v=_=>p($=>$===_?null:$),w=_=>{v(_),m(),t==null||t()},j=(_,$,R,C)=>{b({id:_,title:$,error:fw(R)}),R instanceof Te&&R.code==="key_set_by_server"&&(v(C),m())};if(!i)return c?s.jsx(pw,{error:c,onRetry:m}):s.jsx("div",{className:"p-5 md:p-8",children:s.jsx(Ss,{label:"Loading the tool keys",rows:3})});const S=i.reenter,T=aM.map(_=>({..._,keys:i.keys.filter($=>$.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),E=_=>s.jsx(lM,{tool:_,writable:n,again:!!S&&_.fields.some($=>$.stored_unreadable||S.fields.includes($.name)),open:(f==null?void 0:f.id)===_.id?f.mode:null,problem:(h==null?void 0:h.id)===_.id?h:null,onOpen:$=>{p($?{id:_.id,mode:$}:null),b(null)},onSave:async $=>{const R=f;try{await e.saveToolKey(_.id,$)}catch(C){return C instanceof Te&&C.status===422?C:(j(_.id,"The key was not saved",C,R),null)}return w(R),null},onRemove:async()=>{const $=f;try{await e.removeToolKey(_.id)}catch(R){j(_.id,"The key was not removed",R,$);return}w($)}},_.id);return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),s.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."})]}),!n&&s.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Xl[o]}),c&&s.jsx(pw,{inline:!0,error:c,onRetry:m}),S&&s.jsxs(ts,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[s.jsx("p",{children:rM[S.reason]}),s.jsx("p",{className:"mt-2 font-mono",children:S.fields.length?S.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),T.map(_=>s.jsxs("section",{"aria-label":_.label,children:[T.length>1&&s.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:_.label}),_.kind==="model"&&s.jsx("p",{className:"mb-2 text-body text-muted-foreground",children:Vj}),s.jsx("ul",{className:"border",children:_.keys.map(E)})]},_.label))]})})}function pw({error:e,onRetry:t,inline:n=!1}){return s.jsx(ts,{tone:"error",className:n?void 0:"m-8",actions:s.jsx(Z,{type:"button",size:"xs",onClick:t,children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function lM({tool:e,writable:t,again:n,open:o,problem:i,onOpen:l,onSave:c,onRemove:u}){var g;const f=m=>e.secrets.find(v=>nd(v.name)===m.name),p=m=>e.fields.find(v=>v.name===nd(m.name)),h=e.fields.filter(m=>{var v;return((v=f(m))==null?void 0:v.source)!=="env"}),b=e.secrets.filter(m=>m.set).length;return s.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[s.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[s.jsx(DP,{id:e.id,className:"mt-1"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),s.jsx(Pe,{tone:b===e.secrets.length?"success":"plain",children:b===e.secrets.length?"set":b?`${b} of ${e.secrets.length} set`:"not set"}),n&&s.jsx(Pe,{tone:"warning",children:"enter again"})]}),s.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(", ")}`]}),mw(e.label,e.check)&&s.jsx("p",{className:`mt-1.5 text-small ${((g=e.check)==null?void 0:g.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:mw(e.label,e.check)}),s.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(m=>{var v;return s.jsx(Xd,{field:m,stateSaid:e.secrets.length===1,writable:t&&o===null,note:(v=p(m))!=null&&v.stored_unreadable?oM:void 0,onPaste:()=>l("edit"),onRemove:m.source==="console"?()=>l("remove"):void 0},m.name)})}),!h.length&&s.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."})]})]}),o==="edit"&&s.jsx(Kj,{tool:e,fields:h,onSave:c,onCancel:()=>l(null)}),o==="remove"&&s.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(m=>m.source==="env")?" The one set in the environment stays.":""]}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>void u(),children:"Remove"}),s.jsx(Z,{size:"sm",onClick:()=>l(null),children:"Keep"})]}),i&&s.jsx("div",{className:"mt-4 border",children:s.jsx(Vo,{error:i.error,title:i.title})})]})}function Kj({tool:e,fields:t,onSave:n,onCancel:o}){const i=y.useRef(null),[l,c]=y.useState(!1),[u,f]=y.useState(!1),[p,h]=y.useState(null),b=()=>t.some(v=>{var w,j;return(j=(w=i.current)==null?void 0:w.elements.namedItem(v.name))==null?void 0:j.value}),g=()=>{var v;(v=i.current)==null||v.reset(),c(!1)},m=async v=>{var E,_;v.preventDefault();const w={};for(const $ of t){const R=(_=(E=i.current)==null?void 0:E.elements.namedItem($.name))==null?void 0:_.value;R&&(w[$.name]=R)}if(!Object.keys(w).length)return;f(!0),h(null);const j=await n(w);if(f(!1),!j){g();return}const S={},T=[];for(const $ of j.fields??[]){const R=$.field.startsWith("values.")?$.field.slice(7):null;R&&t.some(C=>C.name===R)?S[R]=$.message:T.push($.message)}h({fields:S,message:T.length?T.join(" "):Object.keys(S).length?null:j.message})};return s.jsxs("form",{ref:i,autoComplete:"off",onSubmit:v=>void m(v),onInput:()=>c(!!b()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[t.map(v=>s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:v.name}),v.set&&s.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."}),s.jsx(He,{type:"password",name:v.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(p==null?void 0:p.fields[v.name])&&s.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[v.name]})]},v.name)),(p==null?void 0:p.message)&&s.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:!l||u,children:u?"Saving":"Save"}),s.jsx(Z,{type:"button",size:"sm",onClick:()=>{g(),o()},children:"Cancel"})]})]})}const Yl=y.createContext(null);function hw({connection:e,children:t}){return s.jsx(Yl.Provider,{value:e,children:t})}const cM={state:"online"},uM=()=>()=>{},gw=()=>cM;function kg(){const e=y.useContext(Yl);return y.useSyncExternalStore(e?e.subscribe:uM,e?e.link:gw,gw)}function Xj(e){const t=y.useContext(Yl),n=y.useRef(e);n.current=e,y.useEffect(()=>t==null?void 0:t.onResume(()=>n.current()),[t])}function Yj(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(e===null)return;n(Date.now());const o=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(o)},[e]),e===null?0:Math.max(0,Math.ceil((e-t)/1e3))}function dM(){const e=y.useContext(Yl),t=kg(),n=Yj(t.state==="offline"?t.retryAt:null);return!e||t.state==="online"?null:t.state==="resumed"?s.jsxs(ts,{bar:!0,tone:"success",icon:l_,"data-connection":"resumed",children:[s.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):s.jsxs(ts,{bar:!0,tone:"warning",icon:o0,"data-connection":"offline",actions:s.jsx(Z,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[s.jsxs("span",{className:"font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]})," Reconnecting… next try in ",n," s. The page shows what it had."]})}function fM(){const e=y.useContext(Yl),t=kg(),n=Yj(t.state==="offline"?t.retryAt:null);return s.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[s.jsx(o0,{className:"size-5 text-warning-text","aria-hidden":!0}),s.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),s.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."}),s.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[s.jsx(Z,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),s.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",n," s"]})]})]})}const mM=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}];function pM({active:e,offered:t,children:n}){return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.length>1&&s.jsx("nav",{"aria-label":"Settings",className:"flex shrink-0 gap-1 border-b px-6",children:mM.filter(o=>t.includes(o.id)).map(o=>s.jsx("a",{href:`#/settings/${o.id}`,"aria-current":e===o.id?"page":void 0,className:ie("caps -mb-px border-b-2 px-3 py-3 text-small",e===o.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:o.label},o.id))}),s.jsx("div",{className:"min-h-0 flex-1",children:n})]})}const xw=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function hM({v2:e,choices:t,gates:n=[],harnesses:o,onSaved:i,onOpen:l}){const[c,u]=y.useState(null),[f,p]=y.useState(null),[h,b]=y.useState(null),[g,m]=y.useState(!1),[v,w]=y.useState(null),j=y.useRef(0),S=()=>{const U=++j.current;e.toolSettings().then(X=>{U===j.current&&(u(X),p(null))},X=>{U===j.current&&p(xw(X))})};y.useEffect(S,[e]);const[T,E]=y.useState("reading"),_=()=>{E("reading"),Promise.resolve(l==null?void 0:l()).then(U=>E(U===!1?"failed":"landed"))},$=()=>{S(),_()};if(y.useEffect(_,[]),!c)return f?s.jsx(ts,{tone:"error",className:"m-8",actions:s.jsx(Z,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",f.code,": ",f.message]})}):s.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const R=Vb(c,t),C=v?v(R):R,O=Uj(t,n),I=Object.entries(C).filter(([,U])=>(U==null?void 0:U.pin)||(U==null?void 0:U.pin_broken)),D=U=>{var P;const X=n.find(K=>K.name===U);return!X||(((P=C[U])==null?void 0:P.permission)??X.default_permission)===X.permission},{byTool:z,rest:H}=dj((h==null?void 0:h.fields)??{},"",O.map(U=>U.name)),F=async U=>{var M;const X=v?G=>U(v(G)):U;m(!0),b(null);const P=++j.current;let K;try{K=await e.toolSettings()}catch{w(()=>X),b({fields:{},error:null,unread:!0}),m(!1);return}try{const G=await e.saveToolSettings(X(Vb(K,t)));w(null),P===j.current&&(u(G),p(null)),i()}catch(G){b(G instanceof Te&&G.status===422&&((M=G.fields)!=null&&M.length)?{fields:Object.fromEntries(G.fields.map(B=>[B.field,B.message])),error:null}:{fields:{},error:xw(G)})}m(!1)};return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),s.jsx("p",{className:"mt-2 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."}),n.length>0&&s.jsxs("p",{className:"mt-2 text-lead text-muted-foreground",children:["Each tool's permission: ",s.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",s.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",s.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."]})]}),s.jsxs("section",{"aria-label":"This server's providers",children:[O.length?s.jsx(Wj,{label:"This server's tool settings",rows:O,settings:C,fallbackOf:U=>U.default_provider,issues:z,busy:g,onEdit:U=>void F(U),refused:(U,X)=>X==="deny",resolvesOf:(U,X)=>X===U.provider&&D(U.name)?s.jsx(kP,{choice:U,harnesses:o}):T==="reading"?s.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):s.jsxs("span",{className:"block text-small text-muted-foreground",children:[T==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",s.jsx(Z,{type:"button",onClick:$,disabled:g,size:"xs",className:"ml-1",children:"Retry"})]})}):s.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."}),H.map(U=>s.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:U},U)),(h==null?void 0:h.error)&&s.jsx("div",{className:"mt-3 border",children:s.jsx(Vo,{error:h.error,title:"The change was not saved"})}),(h==null?void 0:h.unread)&&s.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[s.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),s.jsx(Z,{type:"button",size:"xs",className:"mt-2",onClick:()=>void F(U=>U),disabled:g,children:"Try again"})]}),f&&s.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[s.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",f.code,": ",f.message]}),s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),s.jsx(Z,{type:"button",onClick:$,disabled:g,size:"xs",className:"mt-2",children:"Try again"})]})]}),I.length>0&&s.jsxs("section",{"aria-label":"Pinned tools",children:[s.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),s.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."}),s.jsx("ul",{className:"mt-2 border",children:I.map(([U,X])=>s.jsxs("li",{"data-pin":U,className:"border-b px-3 py-2.5 last:border-b-0",children:[s.jsx("p",{className:"font-mono text-body",children:U}),s.jsx(Qp,{setting:X})]},U))})]})]})})}function gM(e){const t=new URLSearchParams(e??""),n=t.get("github");if(n==="connected")return{ok:!0};if(n==="error"){const o=t.get("reason");return o?{ok:!1,reason:o}:{ok:!1}}}const yw={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."},xM=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(yw,e.reason)?yw[e.reason]:"The connection didn't finish. Try again.";function yM(e,t){const n=t(e);if(!n)return;const o=new URL(n);return o.protocol==="https:"&&o.hostname==="github.com"?n:void 0}function Oo(e){if(!(typeof e!="string"||!e))try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function vM({note:e}){const t=e.lastIndexOf(": "),n=t>=0?e.slice(t+2).trim():"",o=n?Oo(n):void 0;return o?s.jsxs(s.Fragment,{children:[e.slice(0,t+2),s.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:n})]}):s.jsx(s.Fragment,{children:e})}function bM({v2:e,returned:t}){const[n,o]=y.useState(void 0),[i,l]=y.useState(null),[c,u]=y.useState(""),[f,p]=y.useState(!1),[h,b]=y.useState(null),[g,m]=y.useState(null),[v,w]=y.useState(null),[j,S]=y.useState(!1),[T,E]=y.useState(null),_=y.useRef(!1),$=y.useRef(null),R=y.useCallback(async()=>{try{const D=await e.githubConnection();o(D.connected?D:null),l(null)}catch(D){l(D instanceof Error?D.message:String(D))}},[e]);y.useEffect(()=>{R()},[R]),y.useEffect(()=>{t&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),y.useEffect(()=>{var D;h&&((D=$.current)==null||D.submit())},[h]);const C=async()=>{var D;if(!_.current){_.current=!0,p(!0),m(null),w(null),E(null);try{const z=await e.connectGitHub(c.trim()||void 0),H=yM(z.action,Oo);if(!H){m("GitHub's address didn't look right, so nothing was sent."),_.current=!1,p(!1);return}b({action:H,manifest:JSON.stringify(z.manifest)})}catch(z){if(_.current=!1,p(!1),m(z instanceof Error?z.message:String(z)),z instanceof Te&&z.code==="github_wrong_origin"){const H=(D=z.details)==null?void 0:D.public_url;w(typeof H=="string"&&Oo(H)||null)}z instanceof Te&&z.code==="github_already_connected"&&R()}}},O=async()=>{S(!1),p(!0),m(null),w(null);try{E(await e.disconnectGitHub()),o(null)}catch(D){D instanceof Te&&(D.status===404||D.code==="github_not_connected")?await R():m(D instanceof Error?D.message:String(D))}finally{p(!1)}},I=n?Oo(`https://github.com/apps/${encodeURIComponent(n.slug)}`):void 0;return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),s.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&&s.jsx("p",{"aria-label":"From GitHub",role:"status",className:ie("border p-4 text-lead",t.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:xM(t)}),(g||v)&&s.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:v?s.jsxs("p",{children:["Open this server at ",s.jsx("a",{href:v,className:"break-all underline underline-offset-2",children:v})," to connect GitHub."]}):s.jsx("p",{children:g})}),T&&s.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[s.jsx("p",{children:s.jsx(vM,{note:T.note})}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:T.triggers_off?`${T.triggers_off} GitHub ${T.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),i&&s.jsx(ts,{tone:"error",actions:s.jsx(Z,{type:"button",size:"xs",onClick:()=>void R(),children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",i]})}),n===void 0&&!i&&s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),n===null&&s.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[s.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),s.jsx(He,{name:"org",value:c,onChange:D=>u(D.target.value),disabled:f,placeholder:"your-org",className:"h-9 w-auto"})]}),s.jsxs(Z,{type:"button",variant:"solid",onClick:()=>void C(),disabled:f,children:[s.jsx(mv,{"aria-hidden":!0}),h?"Opening GitHub…":"Connect GitHub"]})]}),s.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."})]}),n&&s.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[s.jsx(mv,{className:"size-4 text-muted-foreground","aria-hidden":!0}),I?s.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:n.slug}):s.jsx("span",{className:"font-mono",children:n.slug}),s.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",n.app_id]})]}),n.installations.length?s.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:n.installations.map(D=>s.jsx("li",{children:D.account},D.id))}):s.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?s.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[s.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),s.jsx(Z,{type:"button",variant:"destructive",disabled:f,onClick:()=>void O(),children:"Disconnect GitHub"}),s.jsx(Z,{type:"button",variant:"ghost",onClick:()=>S(!1),children:"Cancel"})]}):s.jsx(Z,{type:"button",variant:"outline",className:"mt-4",disabled:f,onClick:()=>S(!0),children:"Disconnect"})]}),h&&s.jsx("form",{"data-github-manifest":!0,ref:$,method:"post",action:h.action,hidden:!0,children:s.jsx("input",{type:"hidden",name:"manifest",defaultValue:h.manifest})})]})})}const wM=8,kM={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function jM({v2:e,signIn:t,writable:n,whyNot:o="sign_in",open:i=l=>location.assign(l)}){var v;const[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),b=y.useRef(0),g=()=>{const w=++b.current;e.listMcpServers().then(j=>{w===b.current&&(c(j.servers),f(null))},j=>{w===b.current&&f(Sl(j))})};y.useEffect(g,[e]),y.useEffect(()=>{t&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[t]);const m=async(w,j)=>i((await e.startMcpSignIn(w,j)).authorization_url);return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),s.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."})]}),!p&&s.jsx(Z,{size:"sm",variant:"primary",onClick:()=>h({}),children:"Add server"})]}),t&&s.jsx("p",{className:`border p-4 text-body ${t.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:t.ok?`Signed in to ${t.server}. Its tools are saved.`:`Signing in to ${t.server} failed: ${rO(t.error)}.`}),!n&&s.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Xl[o]}),u&&s.jsx(ts,{tone:"error",actions:s.jsx(Z,{type:"button",size:"xs",onClick:g,children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",u.text]})}),p&&s.jsx($M,{v2:e,saved:p.saved,writable:n,signIn:m,onCancel:()=>h(null),onSaved:(w=>()=>{h(j=>j===w?null:j),g()})(p)},((v=p.saved)==null?void 0:v.name)??"new"),l&&(l.length?s.jsx("ul",{className:"border",children:l.map(w=>s.jsx(NM,{v2:e,server:w,writable:n&&!p,signIn:m,onChange:()=>h({saved:w}),onChanged:g},w.name))}):s.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."})),s.jsx(SM,{v2:e})]})})}const jg=({problem:e})=>s.jsxs("div",{role:"alert",children:[s.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]});function NM({v2:e,server:t,writable:n,signIn:o,onChange:i,onChanged:l}){var E;const[c,u]=y.useState(!1),[f,p]=y.useState(!1),[h,b]=y.useState(null),[g,m]=y.useState(null),v=async _=>{u(!0),m(null);try{await _()}catch($){m(Sl($))}u(!1)},[w,j]=t.credential?kM[t.credential]??[t.credential,"plain"]:["no credential","plain"],S=t.auth.type==="oauth",T=h&&[["Added",h.added],["Removed",h.removed],["Changed",h.changed]].filter(([,_])=>_.length).map(([_,$])=>`${_} ${$.join(", ")}`);return s.jsxs("li",{"data-server":t.name,className:"border-b p-4 last:border-b-0",children:[s.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[s.jsx(i_,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"font-mono text-prose font-semibold",children:t.name}),s.jsx(Pe,{tone:j,children:w}),!!((E=t.not_metered)!=null&&E.length)&&s.jsx(Pe,{tone:"plain",children:"not metered"})]}),s.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:t.url}),S&&t.oauth&&s.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",t.oauth.scopes.length?` · ${t.oauth.scopes.join(" ")}`:"",t.oauth.client==="pre-registered"&&t.oauth.client_id?` · client ${t.oauth.client_id}`:"",t.credential==="expired"?" · sign-in expired: sign in again":t.oauth.expires_at?` · token until ${Rt(t.oauth.expires_at)}`:""]}),s.jsxs("details",{className:"mt-2",children:[s.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[t.tools.length," tool",t.tools.length===1?"":"s"]}),s.jsx("ul",{className:"mt-1 space-y-0.5",children:t.tools.map(_=>{var $,R;return s.jsxs("li",{className:"font-mono text-small",children:[_.name,(($=t.prices)==null?void 0:$[_.name])!==void 0&&s.jsxs("span",{className:"text-muted-foreground",children:[" · $",t.prices[_.name]," a call"]}),((R=t.not_metered)==null?void 0:R.includes(_.name))&&s.jsx("span",{className:"text-muted-foreground",children:" · not metered"})]},_.name)})})]}),t.secret&&s.jsx("ul",{className:"mt-2",children:s.jsx(Xd,{field:t.secret,label:EM[t.auth.type],writable:n,onPaste:S?void 0:i})}),T&&s.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:T.length?T.join(" · "):"No change: it lists the same tools."})]}),!f&&s.jsxs("div",{className:"flex flex-wrap gap-2",children:[S&&t.credential!=="sealed"&&n&&s.jsx(Z,{size:"sm",variant:"primary",disabled:c,onClick:()=>void v(()=>{var _;return o(t.name,{url:t.url,...(_=t.oauth)!=null&&_.scopes.length?{scopes:t.oauth.scopes}:{}})}),children:"Sign in again"}),s.jsx(Z,{size:"sm",disabled:c,onClick:()=>void v(async()=>{try{b(await e.refreshMcpServer(t.name))}finally{l()}}),children:"Refresh"}),s.jsx(Z,{size:"sm",disabled:c,onClick:i,children:"Change"}),s.jsx(Z,{size:"sm",variant:"destructive",disabled:c,onClick:()=>p(!0),children:"Delete"})]})]}),f&&s.jsxs("div",{role:"alertdialog","aria-label":`Delete ${t.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",t.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),s.jsx(Z,{size:"sm",variant:"destructive",disabled:c,onClick:()=>void v(async()=>{await e.deleteMcpServer(t.name),l()}),children:"Delete"}),s.jsx(Z,{size:"sm",onClick:()=>p(!1),children:"Keep"})]}),g&&s.jsx("div",{className:"mt-3",children:s.jsx(jg,{problem:g})})]})}function SM({v2:e}){const[t,n]=y.useState(null),[o,i]=y.useState(null),[l,c]=y.useState(null),[u,f]=y.useState(!1),[p,h]=y.useState(""),b=()=>void e.mcpPrivateHosts().then(v=>{n(v.hosts),i(null)},v=>i(Sl(v)));y.useEffect(b,[e]);const g=async v=>{f(!0),c(null);try{return n((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(w){return c(Sl(w)),!1}finally{f(!1)}},m=async v=>{v.preventDefault(),t&&p.trim()&&await g([...t,p.trim()])&&h("")};return s.jsxs("section",{"aria-labelledby":"mcp-private-hosts",className:"space-y-3 border bg-card p-4",children:[s.jsx("h2",{id:"mcp-private-hosts",className:"caps text-small font-semibold",children:"Private network hosts"}),s.jsx("p",{className:"text-body text-muted-foreground",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."}),o&&s.jsxs("div",{role:"alert",children:[s.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",o.text]}),s.jsx(Z,{size:"sm",onClick:b,className:"mt-3",children:"Try again"})]}),t&&(t.length?s.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border bg-background",children:t.map(v=>s.jsxs("li",{"data-host":v,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[s.jsx("span",{className:"break-all font-mono text-body",children:v}),s.jsx(Z,{size:"sm",disabled:u,onClick:()=>void g(t.filter(w=>w!==v)),children:"Remove"})]},v))}):s.jsx("p",{className:"border bg-background px-3 py-3 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),t&&s.jsxs("form",{onSubmit:v=>void m(v),"aria-label":"Allow a private network host",className:"flex gap-2",children:[s.jsx(He,{name:"mcp-private-host","aria-label":"Host name or IP address",value:p,onChange:v=>h(v.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:u||!p.trim(),children:"Allow"})]}),l&&s.jsx(jg,{problem:l})]})}const fp={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},_M=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"]],EM={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in"};function $M({v2:e,saved:t,writable:n,signIn:o,onCancel:i,onSaved:l}){var G,B,L,q,ne;const c=y.useRef(null),[u,f]=y.useState((t==null?void 0:t.name)??""),[p,h]=y.useState((t==null?void 0:t.url)??""),[b,g]=y.useState((t==null?void 0:t.auth.type)??"none"),[m,v]=y.useState(Math.max(1,((G=t==null?void 0:t.auth.headers)==null?void 0:G.length)??0)),[w,j]=y.useState(null),[S,T]=y.useState(null),[E,_]=y.useState(!1),$=y.useRef(0),R=()=>{$.current++,j(null)},C=oe=>{var ae,ce;return(((ce=(ae=c.current)==null?void 0:ae.elements.namedItem(oe))==null?void 0:ce.value)??"").trim()},[O,I]=y.useState(!1),D=oe=>{try{return new URL(oe).origin}catch{return oe}},z=(oe=b)=>{var ae;return I(!!t&&oe==="oauth"&&(t.auth.type!=="oauth"||C("mcp-scopes")!==(((ae=t.oauth)==null?void 0:ae.scopes.join(" "))??"")||!!C("mcp-client-id")||!!C("mcp-client-secret")||D(C("mcp-url"))!==D(t.url)))};y.useEffect(()=>z(),[b]);const H=()=>{if(b==="bearer")return C("mcp-token")?{type:b,token:C("mcp-token")}:{type:b};if(b!=="headers")return{type:b};const oe=Object.fromEntries(Array.from({length:m},(ae,ce)=>[C(`mcp-header-name-${ce}`),C(`mcp-header-value-${ce}`)]).filter(([ae,ce])=>ae&&ce));return Object.keys(oe).length?{type:b,headers:oe}:{type:b}},F=async oe=>{_(!0),T(null);try{await oe()}catch(ae){T(Sl(ae))}_(!1)},U=()=>F(()=>{const oe=C("mcp-scopes").split(/\s+/).filter(Boolean),ae=C("mcp-client-id");return o(u.trim(),{url:p.trim(),...oe.length?{scopes:oe}:{},...ae?{client_id:ae,...C("mcp-client-secret")?{client_secret:C("mcp-client-secret")}:{}}:{}})}),X=()=>{const oe=$.current;F(async()=>{try{const ae=await e.previewMcpServer(p.trim(),H());oe===$.current&&j(ae)}catch(ae){if(oe===$.current)throw ae}})},P=oe=>{if(oe.preventDefault(),b==="oauth"&&(!t||O))return void U();F(async()=>{var ae;await e.saveMcpServer(u.trim(),p.trim(),H()),(ae=c.current)==null||ae.reset(),l()})},K=!E&&!!u.trim()&&!!p.trim()&&(!!t||!!w),M=oe=>(t==null?void 0:t.credential)==="sealed"&&t.auth.type===b&&s.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",oe]});return s.jsxs("form",{ref:c,autoComplete:"off",onSubmit:P,"aria-label":t?`Change ${t.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:oe=>{oe.target.name!=="mcp-name"&&R(),z()},children:[s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),s.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:",u.trim()||"<name>","/<tool>."]}),s.jsx(He,{name:"mcp-name",value:u,readOnly:!!t,onChange:oe=>f(oe.target.value),spellCheck:!1})]}),s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),s.jsx(He,{name:"mcp-url",value:p,onChange:oe=>h(oe.target.value),placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),s.jsxs("fieldset",{children:[s.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),s.jsx("div",{className:"flex flex-wrap gap-4",children:_M.map(([oe,ae])=>s.jsxs("label",{className:"flex items-center gap-2 text-body",children:[s.jsx("input",{type:"radio",name:"mcp-auth",value:oe,checked:b===oe,disabled:!n&&oe!=="none",onChange:()=>{g(oe),R()},className:"accent-primary"}),ae]},oe))})]}),b==="bearer"&&s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),M("A new token replaces it; leave this empty to keep it."),s.jsx(He,{name:"mcp-token",...fp})]}),b==="headers"&&s.jsxs("div",{className:"space-y-2",children:[M(`Its headers: ${(B=t==null?void 0:t.auth.headers)==null?void 0:B.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:m},(oe,ae)=>{var ce;return s.jsxs("div",{className:"flex gap-2",children:[s.jsx(He,{name:`mcp-header-name-${ae}`,"aria-label":`Header ${ae+1} name`,placeholder:"X-Api-Key",defaultValue:(ce=t==null?void 0:t.auth.headers)==null?void 0:ce[ae],spellCheck:!1}),s.jsx(He,{name:`mcp-header-value-${ae}`,"aria-label":`Header ${ae+1} value`,...fp})]},ae)}),m<wM&&s.jsx(Z,{type:"button",size:"sm",variant:"ghost",onClick:()=>v(oe=>oe+1),children:"Add header"})]}),b==="oauth"&&s.jsxs("div",{className:"space-y-3",children:[s.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."}),((L=t==null?void 0:t.oauth)==null?void 0:L.client_id)&&s.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",t.oauth.client_id,"); a client ID here replaces it."]}),s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),s.jsx(He,{name:"mcp-scopes",placeholder:"read write",defaultValue:(q=t==null?void 0:t.oauth)==null?void 0:q.scopes.join(" "),spellCheck:!1})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("label",{className:"block flex-1",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Client ID (optional)"}),s.jsx(He,{name:"mcp-client-id",spellCheck:!1})]}),n&&s.jsxs("label",{className:"block flex-1",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Client secret (optional)"}),s.jsx(He,{name:"mcp-client-secret",...fp})]})]})]}),S&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(jg,{problem:S}),S.signIn&&b!=="oauth"&&n&&s.jsx(Z,{type:"button",size:"sm",variant:"primary",disabled:E||!u.trim(),onClick:()=>void U(),children:"Sign in"})]}),w&&s.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[s.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",w.protocol,(ne=w.server_info)!=null&&ne.name?` · ${w.server_info.name}${w.server_info.version?` ${w.server_info.version}`:""}`:""," · ",w.tools.length," tool",w.tools.length===1?"":"s"]}),w.instructions&&s.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:w.instructions}),s.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:w.tools.map(oe=>s.jsxs("li",{className:"px-3 py-2",children:[s.jsx("span",{className:"font-mono text-body",children:oe.name}),oe.title&&s.jsx("span",{className:"ml-2 text-small",children:oe.title}),oe.description&&s.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:oe.description})]},oe.name))})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[b==="oauth"&&!n?null:b==="oauth"&&O?s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:E||!p.trim(),children:"Sign in again with these settings"}):b==="oauth"?s.jsx(Z,{type:"button",size:"sm",variant:"solid",disabled:E||!u.trim()||!p.trim(),onClick:()=>void U(),children:t?"Sign in again":"Sign in"}):s.jsx(Z,{type:"button",size:"sm",disabled:E||!p.trim(),onClick:X,children:"Preview"}),(b!=="oauth"||t&&!O)&&s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:!K,children:E?"Working":"Save"}),s.jsx(Z,{type:"button",size:"sm",onClick:()=>{var oe;(oe=c.current)==null||oe.reset(),i()},children:"Cancel"})]})]})}const vw=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function TM({v2:e,needs:t,model:n,onSaved:o,writable:i,whyNot:l="sign_in"}){const[c,u]=y.useState(null),[f,p]=y.useState(null),[h,b]=y.useState(null),[g,m]=y.useState(null),v=y.useRef(0),w=()=>{const $=++v.current;e.listToolKeys().then(R=>{$===v.current&&(u(R.keys.filter(C=>C.kind==="model")),p(null))}).catch(R=>{$===v.current&&p(vw(R))})};y.useEffect(()=>{t!=="model"&&w()},[e,t]);const j=n!=null&&n.includes("/")?n.slice(0,n.indexOf("/")):void 0,S=c==null?void 0:c.find($=>$.id===j),T=S?[S]:c,E=c==null?void 0:c.find($=>$.id===h),_=(E==null?void 0:E.fields.filter($=>{var R;return((R=E.secrets.find(C=>nd(C.name)===$.name))==null?void 0:R.source)!=="env"}))??[];return s.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:s.jsxs("div",{className:"mx-auto flex max-w-[1600px] gap-3",children:[s.jsx(Tl,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[s.jsx("h2",{className:"text-prose font-semibold",children:t==="model"?"This server's default model doesn't run":"Add a model key to run agents"}),t==="model"?s.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."}):S?s.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",s.jsx("span",{className:"font-mono",children:n}),", and no ",S.label," key is set, so an agent that names no model can't run. Save the ",S.label," key: such an agent then runs on that model."]}):s.jsxs(s.Fragment,{children:[s.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."}),s.jsx("p",{className:"text-body text-muted-foreground",children:Vj})]}),t!=="model"&&f&&s.jsxs("div",{role:"alert",children:[s.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",f.code,": ",f.message]}),s.jsx(Z,{type:"button",onClick:w,size:"sm",className:"mt-2",children:"Try again"})]}),t!=="model"&&c&&!i&&s.jsx("p",{className:"text-body",role:"status",children:Xl[l]}),t!=="model"&&c&&i&&s.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:T.map($=>s.jsx(Z,{size:"sm",variant:h===$.id?"solid":"primary","aria-pressed":h===$.id,onClick:()=>{b(h===$.id?null:$.id),m(null)},children:$.label},$.id))}),E&&i&&(_.length?s.jsx(Kj,{tool:E,fields:_,onCancel:()=>b(null),onSave:async $=>{m(null);try{await e.saveToolKey(E.id,$)}catch(R){return R instanceof Te&&R.status===422?R:(m(vw(R)),null)}return b(null),w(),o==null||o(),null}},E.id):s.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",E.label," key when it starts: change it there."]})),g&&s.jsx("div",{className:"border",children:s.jsx(Vo,{error:g,title:"The key was not saved"})}),s.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",s.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function CM({needs:e,settings:t,model:n,source:o}){return s.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.":s.jsxs(s.Fragment,{children:["No model yet."," ",o==="gateway"?s.jsxs(s.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",t?s.jsxs(s.Fragment,{children:[", or ",s.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):n?`This server's default model is ${n}: set its provider's key where AgentRun starts, and restart.`:t?s.jsxs(s.Fragment,{children:[s.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY or OPENAI_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), or ANTHROPIC_API_KEY or OPENAI_API_KEY, and restart."]})})}function RM({box:e}){const t=e.id==="docker"?"Docker":e.id;return s.jsxs("p",{role:"status","aria-label":`${t} box`,className:"border-b bg-card px-5 py-3 text-body text-muted-foreground md:px-8",children:["Preparing the ",t," box",e.reason?`: ${e.reason}`:"",". A sandbox run waits for it before its first tool call."]})}const bw=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},AM={unreadable:"Its secret can't sign here: it was sealed under another key, or is damaged. Nothing is sent until the webhook is removed and set again."};function OM({v2:e}){const[t,n]=y.useState(null),[o,i]=y.useState([]),[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),[b,g]=y.useState(null),[m,v]=y.useState(!1),[w,j]=y.useState(!1),[S,T]=y.useState(""),E=y.useRef(0),_=()=>{const C=++E.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([O,I])=>{C===E.current&&(n(O),i(I.attempts),c(null),O.configured&&T(D=>D||O.url))}).catch(O=>{C===E.current&&c(bw(O))})};y.useEffect(_,[e]);const $=async(C,O)=>{h(null),j(!0);try{await O()}catch(I){h({title:C,error:bw(I)})}finally{j(!1)}_()},R=C=>{C.preventDefault(),$("The webhook was not saved",async()=>{const O=await e.saveWebhook(S.trim());O.signing_secret&&f(O.signing_secret);const{signing_secret:I,...D}=O;n(D)})};return t?s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),s.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."})]}),p&&s.jsx(Vo,{error:p.error,title:p.title}),l&&s.jsx(ts,{tone:"error",actions:s.jsx(Z,{type:"button",size:"xs",onClick:_,children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message,". What is shown may be out of date."]})}),u&&s.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[s.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),s.jsx("p",{className:"mt-2 break-all font-mono text-body",children:u}),s.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",s.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),s.jsx(Z,{type:"button",variant:"outline",className:"mt-3",onClick:()=>f(null),children:"Done"})]}),s.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fl,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.configured?s.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:t.url}):s.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),t.configured&&(t.disabled?s.jsx(Pe,{tone:"error",children:"off"}):t.signing==="sealed"?s.jsx(Pe,{tone:"success",children:"on"}):s.jsx(Pe,{tone:"warning",children:"not signing"}))]}),t.configured&&t.disabled&&s.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",t.disabled.reason,", ",Rt(t.disabled.at),". Nothing is sent until the URL is saved again."]}),t.configured&&t.signing!=="sealed"&&s.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[s.jsx(Js,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),AM[t.signing]]}),s.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:R,children:[s.jsx(He,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:"https://...",value:S,onChange:C=>T(C.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),s.jsx(Z,{type:"submit",variant:"solid",disabled:w||!S.trim(),children:"Save"}),t.configured&&s.jsx(Z,{type:"button",variant:"outline",disabled:w,onClick:()=>$("The test was not sent",async()=>g(await e.testWebhook())),children:"Send a test"}),t.configured&&!m&&s.jsx(Z,{type:"button",variant:"outline",disabled:w,onClick:()=>v(!0),children:"Remove"})]}),m&&s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[s.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),s.jsx(Z,{type:"button",variant:"destructive",disabled:w,onClick:()=>{v(!1),T(""),g(null),$("The webhook was not removed",async()=>{await e.removeWebhook(),n({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),f(null)})},children:"Remove the webhook"}),s.jsx(Z,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),b&&s.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",ww(b)]})]}),s.jsxs("section",{"aria-label":"Deliveries",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"caps text-small font-semibold text-muted-foreground",children:"Last deliveries"}),s.jsx(Z,{type:"button",variant:"ghost",onClick:_,children:"Refresh"})]}),o.length===0?s.jsx("p",{className:"mt-2 border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):s.jsx("ul",{className:"mt-2 border",children:o.map((C,O)=>s.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:[s.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:Rt(C.at)}),s.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:C.type}),s.jsx("span",{className:C.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:ww(C)}),C.redelivery&&s.jsx(Pe,{children:"redelivery"}),s.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:C.webhook_id,children:[C.webhook_id.slice(0,12),"…"]}),s.jsx(Z,{type:"button",variant:"outline",size:"sm",disabled:w,onClick:()=>$("The message was not sent again",()=>e.redeliverWebhook(C.webhook_id)),children:"Redeliver"})]},`${C.webhook_id}:${C.at}:${O}`))})]})]})}):l?s.jsx(ts,{tone:"error",className:"m-8",actions:s.jsx(Z,{type:"button",size:"xs",onClick:_,children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message]})}):s.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function ww(e){const t=e.error??`${e.status_code}`,n=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${t}${n}${e.retry_at?`; tried again ${Rt(e.retry_at)}`:""}`}const PM={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."}},MM=e=>PM[e]??{label:e,gives:""},LM=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},kw=e=>e.slice(e.lastIndexOf(":")+1);function IM({v2:e,writable:t,whyNot:n="sign_in"}){const[o,i]=y.useState(null),[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),[b,g]=y.useState({}),[m,v]=y.useState(new Set),w=y.useRef(0),j=y.useCallback(()=>{const _=++w.current;c(null),e.computers().then($=>{_===w.current&&i($)},$=>{_===w.current&&c(LM($))})},[e]);if(y.useEffect(j,[j]),!o)return l?s.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[s.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",l.code,": ",l.message]}),s.jsx(Z,{size:"sm",onClick:j,className:"mt-3",children:"Try again"})]}):s.jsx("div",{className:"p-5 md:p-8",children:s.jsx(Ss,{label:"Loading the computers",rows:3})});const S=_=>o.kinds.filter($=>$.providers.some(R=>R.id===_)).map($=>$.kind),T=async(_,$,R)=>{h(null);try{await e.saveComputerKeys($.id,R)}catch(C){return C instanceof Te&&C.status===422?C:(h({at:_,words:jn(C)}),null)}return f(null),j(),null},E=async _=>{v(R=>new Set(R).add(_.id));let $;try{const R=await e.testComputer(_.id);$=R.ok?{ok:!0,words:R.detail,at:new Date().toISOString()}:{ok:!1,words:R.why,at:new Date().toISOString()}}catch(R){$={ok:!1,words:jn(R),at:new Date().toISOString()}}g(R=>({...R,[_.id]:$})),v(R=>{const C=new Set(R);return C.delete(_.id),C})};return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),s.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&&s.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Xl[n]}),o.kinds.map(_=>s.jsx(zM,{kind:_,children:_.providers.map($=>{const R=`${_.kind}/${$.id}`;return s.jsx(DM,{kind:_.kind,provider:$,writable:t,serves:S($.id),tested:b[$.id],testing:m.has($.id),open:(u==null?void 0:u.at)===R?u.mode:null,problem:(p==null?void 0:p.at)===R?p.words:null,onOpen:C=>{f(C?{at:R,mode:C}:null),h(null)},onSave:C=>T(R,$,C),onRemove:async C=>{var I;const O=await T(R,$,{[C]:null});O&&h({at:R,words:((I=O.fields)==null?void 0:I.map(D=>D.message).join(" "))||O.message})},onTest:()=>void E($)},$.id)})},_.kind))]})})}function zM({kind:e,children:t}){const{label:n,gives:o}=MM(e.kind);return s.jsxs("section",{"aria-label":n,children:[s.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"caps text-small font-semibold",children:n}),o&&s.jsx("span",{className:"text-small text-muted-foreground",children:o}),!e.offered&&s.jsx(Pe,{tone:"muted",children:"Not offered here"})]}),!e.offered&&e.why&&s.jsx("p",{className:"mb-2 font-mono text-small text-muted-foreground",children:e.why}),e.providers.length?s.jsx("ul",{className:"border",children:t}):s.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":"No provider serves it on this server."})]})}function DM({kind:e,provider:t,writable:n,serves:o,tested:i,testing:l,open:c,problem:u,onOpen:f,onSave:p,onRemove:h,onTest:b}){const g=c&&"paste"in c?c.paste:null,m=c&&"remove"in c?c.remove:null;return s.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[s.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[s.jsx(Cl,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:t.name}),t.ready?s.jsx(Pe,{tone:"success",children:"Ready"}):s.jsx(Pe,{children:"Not ready"}),t.metered&&s.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!t.ready&&t.why&&s.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:t.why}),t.metered&&wg.has(e)&&s.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:bg}),t.secrets.length>0&&s.jsx("ul",{className:"mt-3 space-y-1.5",children:t.secrets.map(v=>{const w=kw(v.name);return s.jsx(Xd,{field:v,required:t.required.includes(v.name),writable:n&&!c,onPaste:()=>f({paste:w}),onRemove:()=>f({remove:w})},v.name)})}),i&&s.jsx("p",{"data-test":!0,className:`mt-2 text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${Od(i.at)} · ${i.words}`}),s.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[t.secrets.length?"":"No key. ","Serves: ",o.join(", ")]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsx(Z,{size:"sm",onClick:b,disabled:l,children:l?"Testing…":"Test connection"})})]}),n&&g&&s.jsx(FM,{provider:t.name,name:g,set:t.secrets.some(v=>kw(v.name)===g&&v.set),onSave:p,onCancel:()=>f(null)}),n&&m&&s.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",m," saved on this server?"]}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>void h(m),children:"Remove"}),s.jsx(Z,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&s.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 FM({provider:e,name:t,set:n,onSave:o,onCancel:i}){const l=y.useRef(null),[c,u]=y.useState(!1),[f,p]=y.useState(!1),[h,b]=y.useState(null),g=()=>{var w,j;return((j=(w=l.current)==null?void 0:w.elements.namedItem(t))==null?void 0:j.value)??""},m=()=>{var w;(w=l.current)==null||w.reset(),u(!1)},v=async w=>{var _;w.preventDefault();const j=g();if(!j)return;p(!0),b(null);const S=await o({[t]:j});if(p(!1),!S){m();return}const T=(_=S.fields)==null?void 0:_.find($=>$.field===t),E=(S.fields??[]).filter($=>$.field!==t).map($=>$.message);b(T?{field:T.message,message:E.join(" ")}:{field:null,message:E.join(" ")||S.message})};return s.jsxs("form",{ref:l,autoComplete:"off",onSubmit:w=>void v(w),onInput:()=>u(!!g()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${t}`,children:[s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:t}),n&&s.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),s.jsx(He,{type:"password",name:t,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(h==null?void 0:h.field)&&s.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:h.field})]}),(h==null?void 0:h.message)&&s.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:h.message}),s.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:!c||f,children:f?"Saving":"Save"}),s.jsx(Z,{type:"button",size:"sm",onClick:()=>{m(),i()},children:"Cancel"})]})]})}const UM="Runs keep their folders on this Archil disk. The server never mounts it; computers that support it mount a run's folder.",jw=[{name:"diskId",label:"Disk id"},{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)"}],WM=e=>({diskId:e.diskId??"",region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),hr="ARCHIL_API_KEY",HM=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function BM({v2:e,writable:t,whyNot:n="sign_in"}){const[o,i]=y.useState(null),[l,c]=y.useState(null),[u,f]=y.useState({diskId:"",region:"",s3Url:"",image:""}),[p,h]=y.useState(null),[b,g]=y.useState(null),[m,v]=y.useState(!1),[w,j]=y.useState(null),[S,T]=y.useState(!1),[E,_]=y.useState(!1),[$,R]=y.useState(!1),[C,O]=y.useState(!1),I=y.useRef(null),D=y.useRef(0),z=y.useCallback(M=>{i(M),f(WM(M))},[]),H=y.useCallback(()=>{const M=++D.current;c(null),e.archil().then(G=>{M===D.current&&z(G)},G=>{M===D.current&&c(HM(G))})},[e,z]);if(y.useEffect(H,[H]),!o)return l?s.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[s.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",l.code,": ",l.message]}),s.jsx(Z,{size:"sm",onClick:H,className:"mt-3",children:"Try again"})]}):s.jsx("div",{className:"p-5 md:p-8",children:s.jsx(Ss,{label:"Loading Archil's settings",rows:2})});const F=()=>{var M,G;return((G=(M=I.current)==null?void 0:M.elements.namedItem(hr))==null?void 0:G.value)??""},U=async M=>{const G={diskId:u.diskId,region:u.region,s3Url:u.s3Url,...u.image?{image:u.image}:{},...M!==void 0?{keys:{[hr]:M}}:{}};v(!0),h(null),g(null);try{const B=await e.saveArchil(G);R(!1),O(!1),z(B)}catch(B){if(B instanceof Te&&B.status===422){const L={},q=[];for(const ne of B.fields??[]){const oe=ne.field.startsWith("keys.")?ne.field.slice(5):ne.field;jw.some(ae=>ae.name===oe)||oe===hr?L[oe]=ne.message:q.push(ne.message)}h({fields:L,message:q.length?q.join(" "):Object.keys(L).length?null:B.message})}else g(jn(B))}finally{v(!1)}},X=M=>{M.preventDefault(),U($&&F()?F():void 0)},P=async()=>{T(!0);try{const M=await e.testArchil();j(M.ok?{ok:!0,words:M.detail,at:new Date().toISOString()}:{ok:!1,words:M.why,at:new Date().toISOString()})}catch(M){j({ok:!1,words:jn(M),at:new Date().toISOString()})}finally{T(!1)}},K=async()=>{g(null);try{z(await e.archilOff()),_(!1)}catch(M){g(jn(M))}};return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[s.jsxs("div",{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),s.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),s.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:UM})]}),!t&&s.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Xl[n]}),s.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(X2,{className:"size-4 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),s.jsx("span",{"data-archil-state":!0,children:o.on?s.jsx(Pe,{tone:"success",children:"On"}):s.jsx(Pe,{children:"Off"})}),o.on&&s.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:`${o.diskId??""} · ${o.region??""}`}),s.jsx("span",{className:"flex-1"}),s.jsx(Z,{size:"sm",onClick:()=>void P(),disabled:S,children:S?"Testing…":"Test"}),o.on&&s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>_(!0),children:"Turn off"})]}),w&&s.jsx("p",{"data-test":!0,className:`mt-3 text-small ${w.ok?"text-success-text":"text-destructive-text"}`,children:`${w.ok?"Passed":"Failed"} · ${Od(w.at)} · ${w.words}`}),E&&s.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[s.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>void K(),children:"Turn off"}),s.jsx(Z,{size:"sm",onClick:()=>_(!1),children:"Cancel"})]}),b&&s.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:b}),s.jsxs("form",{ref:I,autoComplete:"off",onSubmit:X,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[jw.map(M=>s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:M.label}),s.jsx(He,{name:M.name,value:u[M.name],placeholder:M.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const B=G.currentTarget.value;f(L=>({...L,[M.name]:B}))}}),(p==null?void 0:p.fields[M.name])&&s.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[M.name]})]},M.name)),s.jsx("ul",{children:s.jsx(Xd,{field:o.secret,label:hr,writable:t&&!$&&!C,onPaste:()=>R(!0),onRemove:()=>O(!0)})}),t&&C&&s.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[s.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",hr," saved on this server?"]}),s.jsx(Z,{type:"button",size:"sm",variant:"destructive",onClick:()=>void U(null),children:"Remove"}),s.jsx(Z,{type:"button",size:"sm",onClick:()=>O(!1),children:"Cancel"})]}),t&&$&&s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:hr}),s.jsx(He,{type:"password",name:hr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(p==null?void 0:p.fields[hr])&&s.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[hr]})]}),t&&$&&s.jsx(Z,{type:"button",size:"sm",onClick:()=>R(!1),children:"Cancel"}),(p==null?void 0:p.message)&&s.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:m,children:m?"Saving":o.on?"Save":"Turn on"})]})]})]})})}const Qj=y.createContext(new Map),GM={schedule:"Schedule",webhook:"Webhook",github:"GitHub"};function Zj({run:e}){const t=y.useContext(Qj);if(!e.trigger)return null;const{id:n}=e.trigger,o=t.get(n),i=o?`${GM[o.kind]??"Trigger"}: ${o.name}`:`Trigger: ${n}`;return s.jsx("a",{href:`#/triggers/${encodeURIComponent(n)}`,onClick:l=>l.stopPropagation(),className:"inline-flex max-w-full",title:i,children:s.jsxs(Pe,{className:"max-w-full",children:[s.jsx(ud,{className:"size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:i})]})})}const gu=(e,t,n)=>{if(!/^\d{1,2}$/.test(e))return null;const o=Number(e);return o>=t&&o<=n?o:null};function qM(e){const t=e.trim().split(/\s+/);if(t.length!==5)return null;const[n,o,i,l,c]=t,u=gu(n,0,59);if(u===null||l!=="*")return null;if(o==="*")return i==="*"&&c==="*"?{kind:"hourly",minute:u}:null;const f=gu(o,0,23);if(f===null)return null;const p={hour:f,minute:u};if(i==="*"&&c==="*")return{kind:"daily",at:p};if(i==="*"&&c==="1-5")return{kind:"weekdays",at:p};if(i==="*"){const h=gu(c,0,6);return h===null?null:{kind:"weekly",day:h,at:p}}if(c==="*"){const h=gu(i,1,31);return h===null?null:{kind:"monthly",date:h,at:p}}return null}function VM(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const t=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${t} * * *`:e.kind==="weekdays"?`${t} * * 1-5`:e.kind==="weekly"?`${t} * * ${e.day}`:`${t} ${e.date} * *`}function KM(e,t){const n=t&&"at"in t?t.at:{hour:9,minute:(t==null?void 0:t.kind)==="hourly"?t.minute:0};return e==="hourly"?{kind:e,minute:n.minute}:e==="weekly"?{kind:e,day:(t==null?void 0:t.kind)==="weekly"?t.day:1,at:n}:e==="monthly"?{kind:e,date:(t==null?void 0:t.kind)==="monthly"?t.date:1,at:n}:{kind:e,at:n}}const Nw=e=>String(e).padStart(2,"0"),XM=e=>`${Nw(e.hour)}:${Nw(e.minute)}`;function YM(e){const t=/^(\d{2}):(\d{2})/.exec(e);if(!t)return null;const n=Number(t[1]),o=Number(t[2]);return n<=23&&o<=59?{hour:n,minute:o}:null}var mp={exports:{}},Sw;function QM(){return Sw||(Sw=1,(function(e,t){(function(o,i){e.exports=i()})(globalThis,()=>(()=>{var n={6949(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.CronParser=void 0;var p=f(9515),h=(function(){function b(g,m,v){m===void 0&&(m=!0),v===void 0&&(v=!1),this.expression=g,this.dayOfWeekStartIndexZero=m,this.monthStartIndexZero=v}return b.prototype.parse=function(){var g,m,v=(g=this.expression)!==null&&g!==void 0?g:"";if(v==="@reboot")return m=["@reboot","","","","","",""],m;if(v.startsWith("@")){var w=this.parseSpecial(this.expression);m=this.extractParts(w)}else m=this.extractParts(this.expression);return this.normalize(m),this.validate(m),m},b.prototype.parseSpecial=function(g){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"},v=m[g];if(!v)throw new Error("Unknown special expression.");return v},b.prototype.extractParts=function(g){if(!this.expression)throw new Error("cron expression is empty");for(var m=g.trim().split(/[ ]+/),v=0;v<m.length;v++)if(m[v].includes(",")){var w=m[v].split(",").map(function(S){return S.trim()}).filter(function(S){return S!==""}).map(function(S){return isNaN(Number(S))?S:Number(S)}).filter(function(S){return S!==null&&S!==""});w.length===0&&w.push("*"),w.sort(function(S,T){return S!==null&&T!==null?S-T:0}),m[v]=w.map(function(S){return S!==null?S.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},b.prototype.normalize=function(g){var m=this;g[3]=g[3].replace("?","*"),g[5]=g[5].replace("?","*"),g[2]=g[2].replace("?","*"),g[0].indexOf("0/")==0&&(g[0]=g[0].replace("0/","*/")),g[1].indexOf("0/")==0&&(g[1]=g[1].replace("0/","*/")),g[2].indexOf("0/")==0&&(g[2]=g[2].replace("0/","*/")),g[3].indexOf("1/")==0&&(g[3]=g[3].replace("1/","*/")),!this.monthStartIndexZero&&g[4].indexOf("1/")==0&&(g[4]=g[4].replace("1/","*/")),g[6].indexOf("1/")==0&&(g[6]=g[6].replace("1/","*/")),g[5]=g[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(R){var C=R.replace(/\D/,""),O=C;return m.dayOfWeekStartIndexZero?C=="7"&&(O="0"):O=(parseInt(C)-1).toString(),R.replace(C,O)}),g[5]=="L"&&(g[5]="6"),g[3]=="?"&&(g[3]="*");var v=/^\d{1,2}W[+-]\d{1,2}$/;if(g[3].indexOf("W")>-1&&(g[3].indexOf(",")>-1||/[-+]/.test(g[3]))&&!v.test(g[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 w={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in w)g[5]=g[5].replace(new RegExp(j,"gi"),w[j].toString());g[4]=g[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(R){var C=R.replace(/\D/,""),O=C;return m.monthStartIndexZero&&(O=(parseInt(C)+1).toString()),R.replace(C,O)});var S={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 T in S)g[4]=g[4].replace(new RegExp(T,"gi"),S[T].toString());g[0]=="0"&&(g[0]=""),!/\*|\-|\,|\//.test(g[2])&&(/\*|\//.test(g[1])||/\*|\//.test(g[0]))&&(g[2]+="-".concat(g[2]));for(var E=0;E<g.length;E++)if(g[E].indexOf(",")!=-1&&(g[E]=g[E].split(",").filter(function(R){return R!==""}).join(",")||"*"),g[E]=="*/1"&&(g[E]="*"),g[E].indexOf("/")>-1&&!/^\*|\-|\,/.test(g[E])){var _=null;switch(E){case 4:_="12";break;case 5:_="6";break;case 6:_="9999";break;default:_=null;break}if(_!==null){var $=g[E].split("/");g[E]="".concat($[0],"-").concat(_,"/").concat($[1])}}},b.prototype.validate=function(g){var m="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(g[0],m),this.validateOnlyExpectedCharactersFound(g[1],m),this.validateOnlyExpectedCharactersFound(g[2],m),this.validateOnlyExpectedCharactersFound(g[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(g[4],m),this.validateOnlyExpectedCharactersFound(g[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(g[6],m),this.validateAnyRanges(g)},b.prototype.validateAnyRanges=function(g){g.forEach(function(m){return p.default.stepRange(m)}),p.default.secondRange(g[0]),p.default.minuteRange(g[1]),p.default.hourRange(g[2]),p.default.dayOfMonthRange(g[3]),p.default.monthRange(g[4],this.monthStartIndexZero),p.default.dayOfWeekRange(g[5],this.dayOfWeekStartIndexZero)},b.prototype.validateOnlyExpectedCharactersFound=function(g,m){var v=g.match(new RegExp("[^".concat(m,"]+"),"gi"));if(v&&v.length)throw new Error("Expression contains invalid values: '".concat(v.toString(),"'"))},b})();u.CronParser=h},8333(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.ExpressionDescriptor=void 0;var p=f(1823),h=f(6949),b=(function(){function g(m,v){if(this.expression=m,this.options=v,this.expressionParts=new Array(5),!this.options.locale&&g.defaultLocale&&(this.options.locale=g.defaultLocale),!g.locales[this.options.locale]){var w=Object.keys(g.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=g.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return g.toString=function(m,v){var w=v===void 0?{}:v,j=w.throwExceptionOnParseError,S=j===void 0?!0:j,T=w.verbose,E=T===void 0?!1:T,_=w.dayOfWeekStartIndexZero,$=_===void 0?!0:_,R=w.monthStartIndexZero,C=R===void 0?!1:R,O=w.use24HourTimeFormat,I=w.trimHoursLeadingZero,D=I===void 0?!1:I,z=w.locale,H=z===void 0?null:z,F=w.logicalAndDayFields,U=F===void 0?!1:F,X={throwExceptionOnParseError:S,verbose:E,dayOfWeekStartIndexZero:$,monthStartIndexZero:C,use24HourTimeFormat:O,trimHoursLeadingZero:D,locale:H,logicalAndDayFields:U};X.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var P=new g(m,X);return P.getFullDescription()},g.initialize=function(m,v){v===void 0&&(v="en"),g.specialCharacters=["/","-",",","*"],g.defaultLocale=v,m.load(g.locales)},g.prototype.getFullDescription=function(){var m,v,w="";try{var j=new h.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((v=(m=this.i18n).atReboot)===null||v===void 0?void 0:v.call(m))||"Run once, at startup";var S=this.getTimeOfDayDescription(),T=this.getDayOfMonthDescription(),E=this.getMonthDescription(),_=this.getDayOfWeekDescription(),$=this.getYearDescription();w+=S+T+_+E+$,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(R){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(R)}return w},g.prototype.getTimeOfDayDescription=function(){var m=this.expressionParts[0],v=this.expressionParts[1],w=this.expressionParts[2],j="";if(!p.StringUtilities.containsAny(v,g.specialCharacters)&&!p.StringUtilities.containsAny(w,g.specialCharacters)&&!p.StringUtilities.containsAny(m,g.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(w,v,m);else if(!m&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!p.StringUtilities.containsAny(w,g.specialCharacters)){var S=v.split("-");j+=p.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,S[0],""),this.formatTime(w,S[1],""))}else if(!m&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!p.StringUtilities.containsAny(v,g.specialCharacters)){var T=w.split(",");j+=this.i18n.at();for(var E=0;E<T.length;E++)j&&(j+=" "),j+=this.formatTime(T[E],v,""),E<T.length-2&&(j+=","),E==T.length-2&&(j+=this.i18n.spaceAnd())}else{var _=this.getSecondsDescription(),$=this.getMinutesDescription(),R=this.getHoursDescription();if(j+=_,j&&$&&(j+=", "),j+=$,$===R)return j;j&&R&&(j+=", "),j+=R}return j},g.prototype.getSecondsDescription=function(){var m=this,v=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return p.StringUtilities.format(m.i18n.everyX0Seconds(w),w)},function(w){return m.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?m.i18n.atX0SecondsPastTheMinute(w):m.i18n.atX0SecondsPastTheMinuteGt20()||m.i18n.atX0SecondsPastTheMinute(w)},{min:0,max:59});return v},g.prototype.getMinutesDescription=function(){var m=this,v=this.expressionParts[0],w=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(S){return S},function(S){return p.StringUtilities.format(m.i18n.everyX0Minutes(S),S)},function(S){return m.i18n.minutesX0ThroughX1PastTheHour()},function(S){var T,E;try{return S=="0"&&w.indexOf("/")==-1&&v==""?m.i18n.everyHour():S=="0"?((E=(T=m.i18n).onTheHour)===null||E===void 0?void 0:E.call(T))||m.i18n.atX0MinutesPastTheHour(S):parseInt(S)<20?m.i18n.atX0MinutesPastTheHour(S):m.i18n.atX0MinutesPastTheHourGt20()||m.i18n.atX0MinutesPastTheHour(S)}catch{return m.i18n.atX0MinutesPastTheHour(S)}},{min:0,max:59});return j},g.prototype.getHoursDescription=function(){var m=this,v=this.expressionParts[2],w=0,j=[];v.split("/")[0].split(",").forEach(function(E){var _=E.split("-");_.length===2&&j.push({value:_[1],index:w+1}),w+=_.length});var S=0,T=this.getSegmentDescription(v,this.i18n.everyHour(),function(E){var _=j.find(function(R){return R.value===E&&R.index===S}),$=_&&m.expressionParts[1]!=="0";return S++,$?m.formatTime(E,"59",""):m.formatTime(E,"0","")},function(E){return p.StringUtilities.format(m.i18n.everyX0Hours(E),E)},function(E){return m.i18n.betweenX0AndX1()},function(E){return m.i18n.atX0()},{min:0,max:23});return T},g.prototype.getDayOfWeekDescription=function(){var m=this,v=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,S){var T=j;j.indexOf("#")>-1?T=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(T=T.replace("L",""));var E=parseInt(T),_=m.i18n.daysOfTheWeekInCase?m.i18n.daysOfTheWeekInCase(S)[E]:v[E];if(j.indexOf("#")>-1){var $=null,R=j.substring(j.indexOf("#")+1),C=j.substring(0,j.indexOf("#"));switch(R){case"1":$=m.i18n.first(C);break;case"2":$=m.i18n.second(C);break;case"3":$=m.i18n.third(C);break;case"4":$=m.i18n.fourth(C);break;case"5":$=m.i18n.fifth(C);break}_=$+" "+_}return _},function(j){return parseInt(j)==1?"":p.StringUtilities.format(m.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var S=j.substring(0,j.indexOf("-")),T=m.expressionParts[3]!="*";return T?m.i18n.commaAndX0ThroughX1(S):m.i18n.commaX0ThroughX1(S)},function(j){var S=null;if(j.indexOf("#")>-1){var T=j.substring(j.indexOf("#")+1),E=j.substring(0,j.indexOf("#"));S=m.i18n.commaOnThe(T,E).trim()+m.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)S=m.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var _=m.expressionParts[3]!="*";_?m.options.logicalAndDayFields?S=m.i18n.commaOnlyOnX0(j):S=m.i18n.commaAndOnX0():S=m.i18n.commaOnlyOnX0(j)}return S}),w},g.prototype.getMonthDescription=function(){var m=this,v=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(j,S){return S&&m.i18n.monthsOfTheYearInCase?m.i18n.monthsOfTheYearInCase(S)[parseInt(j)-1]:v[parseInt(j)-1]},function(j){return parseInt(j)==1?"":p.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 w},g.prototype.getDayOfMonthDescription=function(){var m=this,v,w,j,S,T=null,E=this.expressionParts[3];switch(E){case"L":T=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":T=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var _=E.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(_){var $=parseInt(_[1]||_[2]),R=$==1?this.i18n.firstWeekday():p.StringUtilities.format(this.i18n.weekdayNearestDayX0(),$.toString()),C=_[4];C?_[3]=="-"?T=p.StringUtilities.format(((w=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||w===void 0?void 0:w.call(v,C))||", %s days before the %s of the month",C,R):T=p.StringUtilities.format(((S=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||S===void 0?void 0:S.call(j,C))||", %s days after the %s of the month",C,R):T=p.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),R);break}else{var O=E.match(/L-(\d{1,2})/);if(O){var I=O[1];T=p.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(I),I);break}else{if(E=="*"&&this.expressionParts[5]!="*")return"";T=this.getSegmentDescription(E,this.i18n.commaEveryDay(),function(D){return D=="L"?m.i18n.lastDay():m.i18n.dayX0?p.StringUtilities.format(m.i18n.dayX0(),D):D},function(D){return D=="1"?m.i18n.commaEveryDay():m.i18n.commaEveryX0Days(D)},function(D){return m.i18n.commaBetweenDayX0AndX1OfTheMonth(D)},function(D){return m.i18n.commaOnDayX0OfTheMonth(D)})}break}}return T},g.prototype.getYearDescription=function(){var m=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return p.StringUtilities.format(m.i18n.commaEveryX0Years(w),w)},function(w){return m.i18n.commaYearX0ThroughYearX1()||m.i18n.commaX0ThroughX1()},function(w){return m.i18n.commaOnlyInYearX0?m.i18n.commaOnlyInYearX0():m.i18n.commaOnlyInX0()});return v},g.prototype.getSegmentDescription=function(m,v,w,j,S,T,E){var _=null,$=m.indexOf("/")>-1,R=m.indexOf("-")>-1,C=m.indexOf(",")>-1;if(!m)_="";else if(m==="*")_=v;else if(!$&&!R&&!C)_=p.StringUtilities.format(T(m),w(m));else if(C){for(var O=m.split(","),I="",D=this.i18n.spaceAnd(),z=0;z<O.length;z++)if(z>0&&O.length>2&&(I+=",",z<O.length-1&&(I+=" ")),z>0&&O.length>1&&(z==O.length-1||O.length==2)&&(I+=D==","&&O.length>2?" ":"".concat(D," ")),O[z].indexOf("/")>-1||O[z].indexOf("-")>-1){var H=O[z].indexOf("-")>-1&&O[z].indexOf("/")==-1,F=this.getSegmentDescription(O[z],v,w,j,H?this.i18n.commaX0ThroughX1:S,T);H?F=F.replace(", ",""):z>0&&F.startsWith(", ")&&(F=F.substring(2)),I+=F}else if(!$)I+=w(O[z]);else{var U=this.getSegmentDescription(O[z],v,w,j,S,T);z>0&&U&&U.startsWith(", ")&&(U=U.substring(2)),I+=U}$?_=I:_=p.StringUtilities.format(T(m),I)}else if($){var O=m.split("/");if(_=p.StringUtilities.format(j(O[1]),O[1]),O[0].indexOf("-")>-1){var X=this.generateRangeSegmentDescription(O[0],S,w);X.indexOf(", ")!=0&&(_+=", "),_+=X}else if(O[0].indexOf("*")==-1){var P=p.StringUtilities.format(T(O[0]),w(O[0]));P=P.replace(", ",""),_+=p.StringUtilities.format(this.i18n.commaStartingX0(),P)}_+=this.getWrappingIncrementDescription(m,E,v,w,j,S,T)}else R&&(_=this.generateRangeSegmentDescription(m,S,w));return _},g.prototype.getWrappingIncrementDescription=function(m,v,w,j,S,T,E){if(!this.options.verbose||!v)return"";var _=m.split("/"),$=_[0],R=_[1],C=parseInt(R),O=v.max-v.min+1,I=$==="*",D=Number.isInteger(C)&&C>1,z=D&&O%C===0;if(!I||!D||z)return"";for(var H=[],F=v.min;F<=v.max;F+=C)H.push(F);if(H.length<2)return"";var U=this.getSegmentDescription(H.join(","),w,j,S,T,E);return U?", ".concat(U):""},g.prototype.generateRangeSegmentDescription=function(m,v,w){var j="",S=m.split("-"),T=w(S[0],1),E=w(S[1],2),_=v(m);return j+=p.StringUtilities.format(_,T,E),j},g.prototype.formatTime=function(m,v,w){var j=0,S=0,T=parseInt(m)+j,E=parseInt(v)+S;E>=60?(E-=60,T+=1):E<0&&(E+=60,T-=1),T>=24?T=T-24:T<0&&(T=24+T);var _="",$=!1;this.options.use24HourTimeFormat||($=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),_=$?"".concat(this.getPeriod(T)," "):" ".concat(this.getPeriod(T)),T>12&&(T-=12),T===0&&(T=12));var R="";w&&(R=":".concat(("00"+w).substring(w.length)));var C=T.toString(),O=("00"+C).substring(C.length),I=E.toString(),D=("00"+I).substring(I.length),z=this.options.trimHoursLeadingZero?C:O;return"".concat($?_:"").concat(z,":").concat(D).concat(R).concat($?"":_)},g.prototype.transformVerbosity=function(m,v){if(!v&&(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 w=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());w<j.length;w++){var S=j[w],T=S[0],E=S[1];m=m.replace(new RegExp(T,"g"),E)}return m},g.prototype.getPeriod=function(m){return m>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},g.locales={},g})();u.ExpressionDescriptor=b},3747(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.enLocaleLoader=void 0;var p=f(9486),h=(function(){function b(){}return b.prototype.load=function(g){g.en=new p.en},b})();u.enLocaleLoader=h},9486(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.en=void 0;var f=function(h){return Number(h)===1},p=(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(b){return f(b)?"every %s second":"every %s seconds"},h.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},h.prototype.atX0SecondsPastTheMinute=function(b){return f(b)?"at %s second past the minute":"at %s seconds past the minute"},h.prototype.everyX0Minutes=function(b){return f(b)?"every %s minute":"every %s minutes"},h.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},h.prototype.atX0MinutesPastTheHour=function(b){return f(b)?"at %s minute past the hour":"at %s minutes past the hour"},h.prototype.everyX0Hours=function(b){return f(b)?"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(b){return f(b)?", %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(b){return f(b)?", %s day before the %s of the month":", %s days before the %s of the month"},h.prototype.commaDaysAfterTheX0OfTheMonth=function(b){return f(b)?", %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(b){return f(b)?", 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})();u.en=p},9515(c,u){Object.defineProperty(u,"__esModule",{value:!0});function f(b,g){if(!b)throw new Error(g)}function p(b){var g=[];if(!isNaN(parseInt(b,10))){g.push(parseInt(b,10));var m=b.match(/^\d+-(-?\d+)/);m&&g.push(parseInt(m[1],10))}return g}var h=(function(){function b(){}return b.stepRange=function(g){for(var m=g.split(","),v=0;v<m.length;v++){var w=m[v].split("/")[1];f(w===void 0||!/^0+$/.test(w),"step value must be greater than 0")}},b.secondRange=function(g){for(var m=g.split(","),v=0;v<m.length;v++)for(var w=0,j=p(m[v]);w<j.length;w++){var S=j[w];f(S>=0&&S<=59,"seconds part must be >= 0 and <= 59")}},b.minuteRange=function(g){for(var m=g.split(","),v=0;v<m.length;v++)for(var w=0,j=p(m[v]);w<j.length;w++){var S=j[w];f(S>=0&&S<=59,"minutes part must be >= 0 and <= 59")}},b.hourRange=function(g){for(var m=g.split(","),v=0;v<m.length;v++)for(var w=0,j=p(m[v]);w<j.length;w++){var S=j[w];f(S>=0&&S<=23,"hours part must be >= 0 and <= 23")}},b.dayOfMonthRange=function(g){for(var m=g.split(","),v=0;v<m.length;v++)for(var w=0,j=p(m[v]);w<j.length;w++){var S=j[w];f(S>=1&&S<=31,"DOM part must be >= 1 and <= 31")}},b.monthRange=function(g,m){for(var v=g.split(","),w=0;w<v.length;w++)for(var j=0,S=p(v[w]);j<S.length;j++){var T=S[j];f(T>=1&&T<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},b.dayOfWeekRange=function(g,m){for(var v=g.split(","),w=0;w<v.length;w++){if(v[w].indexOf("#")>-1){var j=v[w].substring(v[w].indexOf("#")+1);f(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var S=0,T=p(v[w]);S<T.length;S++){var E=T[S];f(E>=0&&E<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},b})();u.default=h},1823(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringUtilities=void 0;var f=(function(){function p(){}return p.format=function(h){for(var b=[],g=1;g<arguments.length;g++)b[g-1]=arguments[g];return h.replace(/%s/g,function(m){return b.shift()})},p.containsAny=function(h,b){return b.some(function(g){return h.indexOf(g)>-1})},p})();u.StringUtilities=f}},o={};function i(c){var u=o[c];if(u!==void 0)return u.exports;var f=o[c]={exports:{}};return n[c](f,f.exports,i),f.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var u=i(8333),f=i(3747);u.ExpressionDescriptor.initialize(new f.enLocaleLoader),c.default=u.ExpressionDescriptor;var p=u.ExpressionDescriptor.toString;c.toString=p})(),l})())})(mp)),mp.exports}var ZM=QM();const JM=Bw(ZM),Ea=(e,t)=>t&&e===eh(t)?t:dL(e),si=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",Jj=(e="")=>({name:"",kind:"cron",cron:"",timezone:si(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),eN={seconds:1,minutes:60,hours:3600};function tN(e){const[t,n]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return t===1?n:`${t} ${n}s`}function nN(e){try{return JM.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const To=e=>String(e).padStart(2,"0"),sd=(e,t)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:t});function sN(e,t){const n=l=>{var c;return((c=new Intl.DateTimeFormat(l,{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(u=>u.type==="timeZoneName"))==null?void 0:c.value)??t},o=n("en-US");if(!/^GMT[+-]/.test(o))return o;const i=n("en-GB");return/^GMT[+-]/.test(i)?o:i}const _w=(e,t)=>{const n=new Date(e);return`${n.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:t}).replace(",","")}, ${sd(n,t)} ${sN(n,t)}`};function Ew(e,{zone:t=si(),now:n=Date.now()}={}){const o=new Date(e),i=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:t});return`Pick a time in the future: ${i(o)===i(new Date(n))?`${sd(o,t)} today`:`${o.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:t})}, ${sd(o,t)} ${sN(o,t)}`} has already passed.`}function rd(e,t){const n={};for(const{type:o,value:i}of new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))n[o]=i;return Date.UTC(Number(n.year),Number(n.month)-1,Number(n.day),Number(n.hour),Number(n.minute))}function eL(e,t,n,o){const i=new Date(rd(e,t)),l=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),n,o);let c=l;for(let u=0;u<2;u++)c+=l-rd(new Date(c),t);return new Date(c)}const tL=e=>{const t=e.trim().split(/\s+/);return t.length!==5||!/^\d{1,2}$/.test(t[0])||!/^\d{1,2}$/.test(t[1])?null:{minute:Number(t[0]),hour:Number(t[1]),days:t.slice(2).some(n=>n!=="*"&&n!=="?")}};function nL(e,t,n,o,i){const l=nN(e),c=t!==n,u=tL(e),f=u&&`At ${To(u.hour)}:${To(u.minute)}`;if(u&&f&&l.startsWith(f))try{const p=o??eL(i,t,u.hour,u.minute),h=u.days?Math.floor(rd(p,n)/864e5)-Math.floor(rd(p,t)/864e5):0,b=h>0?" the next day":h<0?" the day before":"";return`At ${sd(p,n)} your time${b}${c?` (${f.slice(3)} ${t})`:""}${l.slice(f.length)}`}catch{}return`${l}${c?` (${t})`:""}`}function Ng(e,t,{zone:n=si(),instead:o,now:i=Date.now()}={}){const l=o?` · ${o}`:t?` · next ${_w(t,n)}`:" · no next time";return"cron"in e?`${nL(e.cron,e.timezone,n,t?new Date(t):null,new Date(i))}${l}`:"at"in e?`Once, ${_w(e.at,n)}${!o&&t&&Date.parse(t)===Date.parse(e.at)?"":l}`:`Every ${tN(e.every_s)}${l}`}const ri=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,sL=e=>`${ri(e)} a run`,rL=(e,t)=>typeof e=="number"?sL(e):typeof t=="number"&&t>0?`Agent's default (${ri(t)})`:"Agent's default";function Sg(e,t,n=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const o=Date.parse(e.source.at);if(o>t)return null;const i=[e.last_firing,...n].find(l=>l&&l.status==="started"&&Date.parse(l.nominal_at)===o);return i?{ran:i}:{passed:e.source.at}}const _g=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",oL=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",aL=e=>e.source.kind==="github"&&e.target.kind==="start_run",rN=[{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"}],El=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,Eg="This server's address as this page sees it: behind a proxy, use its public address.",Jp={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},iL=e=>"in"in e?`${e.pointer} is one of ${e.in.map(t=>JSON.stringify(t)).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"is there":"is absent"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,od=(e,t=!0)=>{var n,o;return`${e.event}${(n=e.actions)!=null&&n.length?` (${e.actions.join(", ")})`:""}${t&&((o=e.where)!=null&&o.length)?` where ${e.where.map(iL).join(" and ")}`:""}`},oN=e=>{var t;return(t=e.accept)!=null&&t.length?`Only signed requests for ${e.accept.map(n=>od(n,!1)).join(" or ")}`:"On each signed request"},lL={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event"},aN=e=>`On GitHub ${e.accept.map(t=>od(t,!1)).join(" or ")}`;function iN(e){var n;const t=(o,i)=>i?`${o}: ${i}`:o;switch(e.status){case"started":return"Started";case"skipped":return t("Skipped",e.reason);case"missed":return t(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return t("Failed",((n=e.error)==null?void 0:n.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${Od(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const cL={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},uL=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function dL(e){if(!uL.test(e))return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString().replace(/\.\d{3}Z$/,"Z")}function eh(e){const t=new Date(e);return`${t.getFullYear()}-${To(t.getMonth()+1)}-${To(t.getDate())}T${To(t.getHours())}:${To(t.getMinutes())}${t.getSeconds()?`:${To(t.getSeconds())}`:""}`}const $w=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function fL(e){const t=tN(e);return/^\d/.test(t)?`At least ${t}.`:`At least ${t==="hour"?"an":"a"} ${t}.`}const th="A number is needed.",nh=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function Tw(e,t=!1){var l,c;const n={};let o;if(e.kind==="cron")e.cron.trim()||(n["source.cron"]="Pick when it runs."),o={kind:"schedule",cron:e.cron.trim(),timezone:e.timezone.trim()||si()};else if(e.kind==="at"){const u=Ea(e.at,(l=e.read)==null?void 0:l.at);u===null&&(n["source.at"]="A time is needed."),o={kind:"schedule",at:u??""}}else{const u=nh(e.every);e.every.trim()?u===void 0&&(n["source.every_s"]=th):n["source.every_s"]="A number is needed.";const f=e.startAt?Ea(e.startAt,(c=e.read)==null?void 0:c.startAt):null;o={kind:"schedule",every_s:Math.round((u??0)*eN[e.everyUnit]),...f?{start_at:f}:{}}}e.agentId||(n["target.agent_id"]="Pick an agent."),e.content.trim()||(n["target.input"]="Say what each run is asked.");const i=nh(e.maxCost);return e.maxCost.trim()?i===void 0&&(n["target.max_cost_usd"]=th):t||(n["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(n).length?{issues:n}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:o,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...i!==void 0?{max_cost_usd:i}:{}}}}}const mL=()=>({name:"",signature:"standard",agentId:"",content:"",maxCost:""});function pL(e,t=!1){return lN(e,{kind:"webhook",signature:e.signature},{},t,"a webhook")}const hL=()=>({name:"",events:["pull_request:opened"],agentId:"",content:"",maxCost:""});function gL(e,t=!1){const n=[];for(const{event:o,action:i}of rN.filter(l=>e.events.includes(`${l.event}:${l.action}`))){const l=n.find(c=>c.event===o);l?l.actions.push(i):n.push({event:o,actions:[i]})}return lN(e,{kind:"github",accept:n},n.length?{}:{"source.accept":"Pick at least one event."},t,"a GitHub trigger")}function lN(e,t,n,o,i){e.agentId||(n["target.agent_id"]="Pick an agent."),e.content.trim()||(n["target.input"]="Say what each run is asked.");const l=nh(e.maxCost);return e.maxCost.trim()?l===void 0&&(n["target.max_cost_usd"]=th):o||(n["target.max_cost_usd"]=`A cost cap is needed: every run ${i} starts is capped.`),Object.keys(n).length?{issues:n}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:t,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...l!==void 0?{max_cost_usd:l}:{}}}}}function xL(e){const t=e.source,n="cron"in t?t.timezone:si(),o={...Jj(e.target.agent_id),name:e.name,timezone:n,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 t)return{...o,kind:"cron",cron:t.cron};if("at"in t)return{...o,kind:"at",at:eh(t.at),read:{at:t.at}};const i=t.every_s%3600===0?"hours":t.every_s%60===0?"minutes":"seconds";return{...o,kind:"every",every:String(t.every_s/eN[i]),everyUnit:i,startAt:eh(t.start_at),read:{startAt:t.start_at}}}const sh=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const[n,o]=[Object.keys(e),Object.keys(t)];return n.length===o.length&&n.every(i=>sh(e[i],t[i]))};function Cw(e,t){const n=t.source&&"every_s"in t.source&&!t.source.start_at&&"every_s"in e.source?{...t.source,start_at:e.source.start_at}:t.source,o=t.target&&{...t.target,input:{...e.target.input,...t.target.input},...e.target.effort!==void 0&&t.target.effort===void 0?{effort:e.target.effort}:{}};return{...t.name!==void 0&&t.name!==e.name?{name:t.name}:{},...n&&!sh(n,e.source)?{source:n}:{},...o&&!sh(o,e.target)?{target:o}:{}}}const yL=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function $g(e){var o;if(!(e instanceof Te))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((o=e.fields)!=null&&o.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const t={},n=[];for(const i of e.fields){const l=i.field.startsWith("target.input")?"target.input":i.field;yL.includes(l)&&!t[l]?t[l]=i.message:n.push(i.message)}return{fields:t,rest:n}}const vL=[{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"}],bL=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),wL=Array.from({length:31},(e,t)=>({value:String(t+1),label:String(t+1)})),kL=Array.from({length:60},(e,t)=>({value:String(t),label:`:${String(t).padStart(2,"0")}`}));function cN({value:e,onChange:t,label:n,name:o}){const i=qM(e),[l,c]=y.useState(()=>e.trim()!==""&&!i),u=y.useId(),f=l||e.trim()!==""&&!i,p=g=>t(VM(g)),h=g=>{if(g==="custom"){c(!0);return}c(!1),p(KM(g,i))},b=i&&"at"in i?i.at:null;return s.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(qt,{label:n,className:"min-w-56 flex-1",value:f?"custom":(i==null?void 0:i.kind)??"",onChange:h,placeholder:"Pick when it runs",options:vL}),!f&&(i==null?void 0:i.kind)==="weekly"&&s.jsx(qt,{id:`${u}-day`,label:"Day of the week",className:"w-40",value:String(i.day),onChange:g=>p({...i,day:Number(g)}),options:bL}),!f&&(i==null?void 0:i.kind)==="monthly"&&s.jsx(qt,{id:`${u}-date`,label:"Day of the month",className:"w-24",value:String(i.date),onChange:g=>p({...i,date:Number(g)}),options:wL}),!f&&(i==null?void 0:i.kind)==="hourly"&&s.jsx(qt,{id:`${u}-minute`,label:"Minutes past the hour",className:"w-24",value:String(i.minute),onChange:g=>p({...i,minute:Number(g)}),options:kL}),!f&&i&&b&&s.jsx(He,{id:`${u}-at`,type:"time","aria-label":"At",className:"w-32",value:XM(b),onChange:g=>{const m=YM(g.target.value);m&&p({...i,at:m})}})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx(He,{id:`${u}-line`,name:o,"aria-label":"Custom schedule",value:e,onChange:g=>t(g.target.value),placeholder:"30 1 * * *",spellCheck:!1}),s.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?nN(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const Rw=Intl.supportedValuesOf,xu=typeof Rw=="function"?Rw("timeZone"):[],yu=xu.length&&!xu.includes("UTC")?["UTC",...xu]:xu;function uN({value:e,onChange:t,label:n,name:o,id:i,className:l}){if(!yu.length)return s.jsx(He,{id:i,name:o,"aria-label":n,className:l,value:e,onChange:u=>t(u.target.value),placeholder:"Europe/Madrid"});const c=e&&!yu.includes(e)?[e,...yu]:yu;return s.jsx(qt,{id:i,name:o,label:n,className:l,value:e,onChange:t,placeholder:"Pick a time zone",options:c.map(u=>({value:u,label:u.replace(/_/g," ")}))})}const Jr=e=>`#/triggers/${encodeURIComponent(e)}`,ad=e=>Rt(e),jL={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function NL({v2:e,view:t,go:n,agentName:o,minEvery:i,refreshMs:l=15e3,now:c=Date.now}){return t.trigger===void 0?s.jsx(EL,{v2:e,go:n,agentName:o,every:l*2,now:c}):t.trigger===null?t.kind==="webhook"?s.jsx(PL,{v2:e,go:n}):t.kind==="github"?s.jsx(ML,{v2:e,go:n}):s.jsx(hN,{v2:e,go:n,minEvery:i,now:c}):t.edit?s.jsx(AL,{v2:e,go:n,id:t.trigger,minEvery:i,now:c},t.trigger):s.jsx(RL,{v2:e,go:n,agentName:o,id:t.trigger,every:l,now:c},t.trigger)}function dN(e,t,n){const o=y.useRef(e);o.current=e,y.useEffect(()=>{const i=()=>document.visibilityState!=="hidden",l=setInterval(()=>{i()&&o.current()},t),c=()=>{i()&&o.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(l),document.removeEventListener("visibilitychange",c)}},[t,...n])}const fN=e=>e?"ran"in e?`Done · ran ${ad(e.ran.nominal_at)}`:`Its time passed · ${ad(e.passed)}`:null,SL=/has already passed\.?$/,_L=e=>e.last_firing?`${iN(e.last_firing)} · ${ad(e.last_firing.nominal_at)}`:"Not fired yet";function EL({v2:e,go:t,agentName:n,every:o,now:i}){const[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(0),b=y.useRef(!1),g=y.useRef(!0);y.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);const m=()=>{b.current||(b.current=!0,e.listTriggers().then(v=>{g.current&&(c(v.triggers),f(null))},v=>{g.current&&f(fn(v,"the triggers"))}).finally(()=>{b.current=!1}))};return y.useEffect(m,[e,p]),dN(m,o,[e]),s.jsxs("div",{className:"p-5 md:p-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[s.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:"Triggers"}),!(l&&!l.length)&&s.jsxs(s.Fragment,{children:[s.jsxs(Z,{size:"lg",onClick:()=>t("#/triggers/new-github"),children:[s.jsx(hh,{"aria-hidden":!0})," New GitHub trigger"]}),s.jsxs(Z,{size:"lg",onClick:()=>t("#/triggers/new-webhook"),children:[s.jsx(fl,{"aria-hidden":!0})," New webhook"]}),s.jsxs(Z,{size:"lg",variant:"solid",onClick:()=>t("#/triggers/new"),children:[s.jsx(dl,{"aria-hidden":!0})," New schedule"]})]})]}),u&&!l?s.jsx(_n,{problem:u,onRetry:()=>h(v=>v+1),className:""}):l?l.length?s.jsx("ul",{className:"border",children:l.map(v=>s.jsxs("li",{"data-trigger":v.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("a",{href:Jr(v.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:v.name}),s.jsx(Pe,{children:TL[v.source.kind]}),!v.enabled&&!Sg(v,i())&&s.jsx(Pe,{tone:"muted",children:"Paused"})]}),s.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:mN(v),children:CL(v,n,i())})]}),s.jsx("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:s.jsx("p",{className:"break-words",children:_L(v)})})]},v.id))}):s.jsx($L,{go:t}):s.jsx(Ss,{label:"Loading the triggers",rows:4}),l&&u&&s.jsx(_n,{problem:u,className:"mt-4"})]})}function $L({go:e}){const t=[{Icon:ud,name:"Schedule",what:"At the times you set: every day or week at a time, every few minutes or hours, or once.",action:"New schedule",to:"#/triggers/new"},{Icon:fl,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:hh,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"}];return s.jsxs("section",{"aria-labelledby":"first-trigger",className:"border border-primary/50 bg-primary/5 p-5",children:[s.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),s.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),s.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."}),s.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-3",children:t.map(({Icon:n,name:o,what:i,action:l,to:c})=>s.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[s.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[s.jsx(n,{className:"size-4 text-primary-text","aria-hidden":!0}),o]}),s.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:i}),s.jsx(Z,{size:"sm",variant:c==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",onClick:()=>e(c),children:l})]},o))})]})}const TL={schedule:"Schedule",webhook:"Webhook",github:"GitHub"},mN=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function CL(e,t,n){return`${e.source.kind==="schedule"?Ng(e.source,e.next_at,{instead:fN(Sg(e,n)),now:n}):e.source.kind==="github"?aN(e.source):oN(e.source)} · ${e.target.kind==="start_run"?t(e.target.agent_id)||e.target.agent_id:`messages run ${Fl(e.target.run_id)}`}`}function pN(){return s.jsxs("div",{className:"p-5 md:p-8",children:[s.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),s.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 RL({v2:e,go:t,agentName:n,id:o,every:i,now:l}){var ye;const[c,u]=y.useState(null),[f,p]=y.useState([]),[h,b]=y.useState(null),[g,m]=y.useState(null),[v,w]=y.useState(null),[j,S]=y.useState(!1),[T,E]=y.useState(!1),[_,$]=y.useState(null),R=y.useRef(!1),[C,O]=y.useState(!1),[I,D]=y.useState(0),z=y.useRef(!1),H=y.useRef(!1),F=y.useRef(0),U=()=>{H.current=!0;const ee=F.current;return Promise.all([e.getTrigger(o),e.triggerFirings(o)]).then(([be,Oe])=>{ee===F.current&&(u(be),p(Oe.firings),b(null))}).finally(()=>{H.current=!1})};y.useEffect(()=>{U().catch(ee=>b(fn(ee,"the trigger")))},[e,o,I]),dN(()=>{!H.current&&!z.current&&U().catch(()=>{})},i,[e,o]);const[X,P]=y.useState(void 0),K=c&&c.target.kind==="start_run"&&typeof c.target.max_cost_usd!="number"?c.target.agent_id:null;if(y.useEffect(()=>{if(!K)return;let ee=!0;return e.getAgent(K).then(be=>{ee&&P(typeof be.agent.definition.max_cost_usd=="number"?be.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{ee=!1}},[e,K]),!c)return h?s.jsx(_n,{problem:h,onRetry:()=>D(ee=>ee+1),link:{href:"#/triggers",label:"All triggers"}}):s.jsx(Ss,{label:"Loading the trigger",rows:4});const M=oL(c)?c:null,G=aL(c)?c:null;if(!M&&!G&&!_g(c))return s.jsx(pN,{});const B=c,L=Sg(c,l(),f),q=async(ee,be,Oe)=>{w(ee),m(null);try{await be()}catch(We){m(fn(We,Oe))}finally{w(null)}},ne=()=>q("pause",async()=>{F.current++;const ee=await e.updateTrigger(o,{enabled:!c.enabled});F.current++,u(ee)},c.enabled?"the pause":"the resume"),oe=()=>q("delete",async()=>{await e.deleteTrigger(o),t("#/triggers")},"the delete"),ae=async()=>{if(!R.current){R.current=!0,O(!0),m(null),$(null);try{$((await e.rotateTriggerSecret(o)).signing_secret)}catch(ee){m(fn(ee,"the new secret"))}finally{R.current=!1,O(!1)}}},ce=async()=>{if(!z.current){z.current=!0,w("fire"),m(null),F.current++;try{const ee=await e.fireTrigger(o,zd());F.current++,p(be=>[ee,...be.filter(Oe=>Oe.key!==ee.key)]),await U().catch(()=>{})}catch(ee){m(fn(ee,"the run now"))}finally{z.current=!1,w(null)}}},le=typeof B.target.input.content=="string"?B.target.input.content:null;return s.jsxs("div",{className:"p-5 md:p-8",children:[s.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),s.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[s.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[s.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[c.name,!c.enabled&&!L&&s.jsx(Pe,{tone:"muted",children:"Paused"})]}),s.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:M?`Webhook · ${oN(M.source)}`:G?`GitHub · ${aN(G.source)}`:s.jsx("span",{title:mN(c),children:Ng(B.source,c.next_at,{instead:fN(L),now:l()})})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Z,{size:"sm",variant:"solid",onClick:()=>void ce(),disabled:v==="fire",children:[s.jsx(g_,{"aria-hidden":!0})," ",v==="fire"?"Starting":"Run now"]}),!(L&&"ran"in L)&&s.jsx(Z,{size:"sm",onClick:()=>void ne(),disabled:v!==null,children:c.enabled?s.jsxs(s.Fragment,{children:[s.jsx(ul,{"aria-hidden":!0})," Pause"]}):s.jsxs(s.Fragment,{children:[s.jsx(Al,{"aria-hidden":!0})," Resume"]})}),!M&&!G&&s.jsxs(Z,{size:"sm",onClick:()=>t(`${Jr(o)}/edit`),children:[s.jsx(Rl,{"aria-hidden":!0})," Edit"]}),M&&(T?s.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:[s.jsx("span",{children:"The old secret stops signing at once."}),s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>{E(!1),ae()},children:"Yes, make a new one"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:"Keep"})]}):s.jsxs(Z,{size:"sm",onClick:()=>E(!0),disabled:v!==null||C,children:[s.jsx(Tl,{"aria-hidden":!0})," Rotate secret"]})),j?s.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:[s.jsx("span",{children:"Delete for good? Its runs stay."}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>{S(!1),oe()},children:"Yes, delete"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:"Keep"})]}):s.jsxs(Z,{size:"sm",variant:"destructive",onClick:()=>S(!0),disabled:v!==null,children:[s.jsx(h_,{"aria-hidden":!0})," Delete"]})]})]}),g&&s.jsx(_n,{problem:g,className:"mt-4"}),M&&_&&s.jsx(Rg,{label:"The webhook's new secret",secret:_}),s.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:[s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),s.jsx("dd",{className:"min-w-0 break-words",children:s.jsx("a",{href:`#/agents/${encodeURIComponent(B.target.agent_id)}`,className:"hover:underline",children:n(B.target.agent_id)||B.target.agent_id})}),s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),s.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:le??JSON.stringify(B.target.input)}),s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),s.jsx("dd",{className:"font-mono",children:rL(B.target.max_cost_usd,X)}),M?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),s.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:El(M)}),s.jsx(gN,{text:El(M),label:"Copy URL"}),s.jsx("span",{className:"basis-full text-small text-muted-foreground",children:Eg})]}),s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),s.jsx("dd",{children:Jp[M.source.signature??"standard"]}),s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),s.jsx("dd",{className:"min-w-0 break-words",children:(ye=M.source.accept)!=null&&ye.length?s.jsx("ul",{className:"space-y-1 font-mono text-small",children:M.source.accept.map((ee,be)=>s.jsx("li",{children:od(ee)},be))}):"Every signed request"})]}):G?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),s.jsxs("dd",{className:"min-w-0 break-words",children:[s.jsx("ul",{className:"space-y-1 font-mono text-small",children:G.source.accept.map((ee,be)=>s.jsx("li",{children:od(ee)},be))}),s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),s.jsx("dd",{children:"The next time is skipped."})]})]}),s.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),f.length?s.jsx("ul",{className:"mt-3 border",children:f.map(ee=>s.jsxs("li",{"data-firing":ee.key,className:"flex flex-col gap-1 border-b px-4 py-2.5 text-body last:border-b-0 sm:flex-row sm:items-start sm:gap-4",children:[s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Pe,{tone:jL[ee.status],children:cL[ee.status]}),s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ad(ee.nominal_at)})]}),s.jsx("span",{className:"min-w-0 flex-1 break-words",children:ee.status==="started"?lL[ee.by]:`${iN(ee)}${ee.by==="manual"?" · Run now":""}`}),ee.run_id&&s.jsxs("a",{href:`#/runs/${encodeURIComponent(ee.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",Fl(ee.run_id)]})]},ee.key))}):s.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function AL({v2:e,go:t,id:n,minEvery:o,now:i}){const[l,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(0);return y.useEffect(()=>{e.getTrigger(n).then(c,b=>f(fn(b,"the trigger")))},[e,n,p]),l?_g(l)?s.jsx(hN,{v2:e,go:t,trigger:l,minEvery:o,now:i}):s.jsx(pN,{}):u?s.jsx(_n,{problem:u,onRetry:()=>h(b=>b+1)}):s.jsx(Ss,{label:"Loading the schedule",rows:4})}function en({label:e,field:t,issue:n,hint:o,children:i}){return s.jsx(Ao,{className:"min-w-0",label:e,hint:o,error:n?s.jsx("span",{"data-issue":t,children:n}):void 0,children:i})}const Tg=e=>e!==void 0?`${ri(e)}, the agent's default`:void 0;async function Cg(e){const t=[];let n=null;for(let o=0;o<20;o++){const i=await e.listAgents({cursor:n});if(t.push(...i.agents),n=i.next_cursor,!n)break}return t}function hN({v2:e,go:t,trigger:n,minEvery:o,now:i=Date.now}){var F,U,X;const[l,c]=y.useState(()=>n?xL(n):Jj()),[u,f]=y.useState(null),[p,h]=y.useState({}),[b,g]=y.useState([]),[m,v]=y.useState(!1),w=y.useRef(Us()).current;y.useEffect(()=>{Cg(e).then(f,()=>f([]))},[e]);const j=P=>K=>c(M=>({...M,[P]:K})),S=P=>{var M;j("at")(P);const K=Ea(P,(M=l.read)==null?void 0:M.at);K!==null&&Date.parse(K)>i()?h(({"source.at":G,...B})=>B):K!==null&&h(G=>G["source.at"]?{...G,"source.at":Ew(K,{now:i()})}:G)},T=new Set(["name","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd",...n?[]:["enabled"]]),E=(F=(u??[]).find(P=>P.agent_id===l.agentId))==null?void 0:F.definition.max_cost_usd,_=typeof E=="number"&&E>0?E:void 0,$=_!==void 0||!!n&&typeof n.target.max_cost_usd!="number"&&l.agentId===n.target.agent_id,R=async P=>{var G;P.preventDefault();const{body:K,issues:M}=Tw(l,$);if(g([]),!K){h(M??{});return}h({}),v(!0);try{if(n){const B=Cw(n,K);Object.keys(B).length&&await e.updateTrigger(n.id,B),t(Jr(n.id))}else{const B=await e.createTrigger(K,w.keyFor("createTrigger",K));t(Jr(B.id))}}catch(B){const L=$g(B),q=l.kind==="at"?Ea(l.at,(G=l.read)==null?void 0:G.at):null,ne=L.fields["source.at"];ne&&q!==null&&(Date.parse(q)<=i()||SL.test(ne))&&(L.fields["source.at"]=Ew(q,{now:i()})),h(Object.fromEntries(Object.entries(L.fields).filter(([oe])=>T.has(oe)))),g([...L.rest,...Object.entries(L.fields).filter(([oe])=>!T.has(oe)).map(([,oe])=>oe)]),v(!1)}},C=n?Tw(l,$).body:void 0,O=!!(n&&C&&Cw(n,C).source),I=l.kind==="at"?Ea(l.at,(U=l.read)==null?void 0:U.at):null,D=l.startAt?Ea(l.startAt,(X=l.read)==null?void 0:X.startAt):null,z=Cd((u??[]).filter(P=>!P.archived_at||P.agent_id===l.agentId)),H=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return s.jsxs("form",{onSubmit:P=>void R(P),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[s.jsxs("a",{href:n?Jr(n.id):"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," ",n?n.name:"Triggers"]}),s.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[s.jsx(ud,{className:"size-5 text-primary-text","aria-hidden":!0}),n?"Edit schedule":"New schedule"]}),b.length>0&&s.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:b.map((P,K)=>s.jsx("p",{children:P},K))}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsx(en,{label:"Name",field:"name",issue:p.name,children:s.jsx(He,{name:"name",value:l.name,onChange:P=>j("name")(P.target.value),placeholder:"nightly triage"})}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:H.map(({kind:P,label:K})=>s.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${l.kind===P?"border-primary text-primary-text":""}`,children:[s.jsx("input",{type:"radio",name:"kind",value:P,checked:l.kind===P,onChange:()=>j("kind")(P),className:"accent-primary"}),K]},P))}),s.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[l.kind==="cron"&&s.jsx(en,{label:"Runs",field:"source.cron",issue:p["source.cron"],children:s.jsx(cN,{label:"Runs",name:"cron",value:l.cron,onChange:j("cron")})}),l.kind==="at"&&s.jsx(en,{label:"At, your time",field:"source.at",issue:p["source.at"],hint:I?`= ${$w(I)}`:void 0,children:s.jsx(He,{name:"at",type:"datetime-local",step:60,value:l.at,onChange:P=>S(P.target.value)})}),l.kind==="every"&&s.jsx(en,{label:"Every",field:"source.every_s",issue:p["source.every_s"],hint:o?fL(o):void 0,children:s.jsxs("span",{className:"flex gap-2",children:[s.jsx(He,{name:"every",inputMode:"decimal",value:l.every,onChange:P=>j("every")(P.target.value),placeholder:"5"}),s.jsx(qt,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:l.everyUnit,onChange:P=>j("everyUnit")(P),options:["seconds","minutes","hours"].map(P=>({value:P,label:P}))})]})}),l.kind==="cron"&&s.jsx(en,{label:"Time zone",field:"source.timezone",issue:p["source.timezone"],hint:"The time zone this schedule runs in.",children:s.jsx(uN,{name:"timezone",label:"Time zone",className:"w-full",value:l.timezone,onChange:j("timezone")})}),l.kind==="every"&&s.jsx(en,{label:"Starting, your time (optional)",field:"source.start_at",issue:p["source.start_at"],hint:D?`= ${$w(D)}`:void 0,children:s.jsx(He,{name:"startAt",type:"datetime-local",step:60,value:l.startAt,onChange:P=>j("startAt")(P.target.value)})})]}),O&&s.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),s.jsx(en,{label:"Agent",field:"target.agent_id",issue:p["target.agent_id"],children:s.jsx(qt,{name:"agent",label:"Agent",className:"w-full",value:l.agentId,onChange:P=>j("agentId")(P),options:[{value:"",label:u?"Pick an agent":"Loading the agents"},...z.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`})),...l.agentId&&u&&!z.some(P=>P.agent_id===l.agentId)?[{value:l.agentId,label:l.agentId}]:[]]})}),s.jsx(en,{label:"Each run is asked",field:"target.input",issue:p["target.input"],children:s.jsx(Ns,{name:"content",rows:4,className:"p-3 font-sans",value:l.content,onChange:P=>j("content")(P.target.value)})}),s.jsx(en,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:p["target.max_cost_usd"],hint:_!==void 0?`Uses the agent's default (${ri(_)}) if empty.`:$?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:s.jsx(He,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:l.maxCost,onChange:P=>j("maxCost")(P.target.value),placeholder:Tg(_)})}),!n&&s.jsxs("div",{children:[s.jsxs("label",{className:"flex items-center gap-2 text-body",children:[s.jsx("input",{type:"checkbox",name:"enabled",checked:l.enabled,onChange:P=>j("enabled")(P.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),p.enabled&&s.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:p.enabled})]})]}),s.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[s.jsx(Z,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?"Saving":n?"Save changes":"Create schedule"}),s.jsx(Z,{type:"button",size:"lg",variant:"ghost",onClick:()=>t(n?Jr(n.id):"#/triggers"),children:"Cancel"})]})]})}function gN({text:e,label:t}){const[n,o]=y.useState(null),i="The browser won't copy here. Select it and copy it.",l=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){o(i);return}c.writeText(e).then(()=>o("Copied"),()=>o(i))};return s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[s.jsxs(Z,{type:"button",size:"sm",onClick:l,children:[s.jsx(fd,{"aria-hidden":!0})," ",t]}),n&&s.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:n})]})}function Rg({label:e,secret:t,url:n}){return s.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[n&&s.jsx(rh,{title:"URL",text:n,label:"Copy URL",hint:Eg}),s.jsx(rh,{title:"Signing secret",text:t,label:"Copy secret"}),s.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function rh({title:e,text:t,label:n,hint:o}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:t}),s.jsx(gN,{text:t,label:n})]}),o&&s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:o})]})}const OL=["standard","github"];function PL({v2:e,go:t}){var R;const[n,o]=y.useState(mL),[i,l]=y.useState(null),[c,u]=y.useState({}),[f,p]=y.useState([]),[h,b]=y.useState(!1),[g,m]=y.useState(null),v=y.useRef(Us()).current;y.useEffect(()=>{Cg(e).then(l,()=>l([]))},[e]);const w=C=>O=>o(I=>({...I,[C]:O})),j=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd"]),S=(R=(i??[]).find(C=>C.agent_id===n.agentId))==null?void 0:R.definition.max_cost_usd,T=typeof S=="number"&&S>0?S:void 0,E=async C=>{C.preventDefault();const{body:O,issues:I}=pL(n,T!==void 0);if(p([]),!O){u(I??{});return}u({}),b(!0);try{m(await e.createTrigger(O,v.keyFor("createTrigger",O)))}catch(D){const z=$g(D);u(Object.fromEntries(Object.entries(z.fields).filter(([H])=>j.has(H)))),p([...z.rest,...Object.entries(z.fields).filter(([H])=>!j.has(H)).map(([,H])=>H)])}finally{b(!1)}},_=s.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(g)return s.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[_,s.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[s.jsx(fl,{className:"size-5 text-primary-text","aria-hidden":!0}),g.name]}),s.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Send each request to this URL, signed with this secret (",Jp[g.source.kind==="webhook"?g.source.signature??"standard":"standard"],"). Each one starts a run."]}),g.signing_secret?s.jsx(Rg,{label:"The webhook's URL and secret",url:El(g),secret:g.signing_secret}):s.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[s.jsx(rh,{title:"URL",text:El(g),label:"Copy URL",hint:Eg}),g.note&&s.jsx("p",{role:"note",children:g.note})]}),s.jsx("div",{className:"mt-6",children:s.jsx(Z,{type:"button",size:"lg",variant:"solid",onClick:()=>t(Jr(g.id)),children:"Done"})})]});const $=Cd((i??[]).filter(C=>!C.archived_at));return s.jsxs("form",{onSubmit:C=>void E(C),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[_,s.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[s.jsx(fl,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),s.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."}),f.length>0&&s.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:f.map((C,O)=>s.jsx("p",{children:C},O))}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsx(en,{label:"Name",field:"name",issue:c.name,children:s.jsx(He,{name:"name",value:n.name,onChange:C=>w("name")(C.target.value),placeholder:"on deploy"})}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:OL.map(C=>s.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${n.signature===C?"border-primary text-primary-text":""}`,children:[s.jsx("input",{type:"radio",name:"signature",value:C,checked:n.signature===C,onChange:()=>w("signature")(C),className:"accent-primary"}),Jp[C]]},C))}),c["source.signature"]&&s.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),s.jsx(en,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:s.jsx(qt,{name:"agent",label:"Agent",className:"w-full",value:n.agentId,onChange:C=>w("agentId")(C),options:[{value:"",label:i?"Pick an agent":"Loading the agents"},...$.map(C=>({value:C.agent_id,label:`${C.definition.name||C.agent_id}${C.kind==="workflow"?" (workflow)":""}`}))]})}),s.jsx(en,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:s.jsx(Ns,{name:"content",rows:4,className:"p-3 font-sans",value:n.content,onChange:C=>w("content")(C.target.value)})}),s.jsx(en,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:T!==void 0?`Uses the agent's default (${ri(T)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:s.jsx(He,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:n.maxCost,onChange:C=>w("maxCost")(C.target.value),placeholder:Tg(T)})})]}),s.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[s.jsx(Z,{type:"submit",size:"lg",variant:"solid",disabled:h,children:h?"Creating":"Create webhook"}),s.jsx(Z,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}function ML({v2:e,go:t}){var F;const[n,o]=y.useState(null),[i,l]=y.useState(null),[c,u]=y.useState(0),[f,p]=y.useState(hL),[h,b]=y.useState(null),[g,m]=y.useState({}),[v,w]=y.useState([]),[j,S]=y.useState(!1),T=y.useRef(Us()).current,E=y.useRef(!0);y.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]),y.useEffect(()=>{let U=!0;return l(null),e.githubConnection().then(X=>{U&&o(!!X&&"app_id"in X&&!!X.app_id)},X=>{U&&(X instanceof Te&&X.status===404?o(!1):l(fn(X,"GitHub's connection")))}),()=>{U=!1}},[e,c]),y.useEffect(()=>{Cg(e).then(b,()=>b([]))},[e]);const _=U=>X=>p(P=>({...P,[U]:X})),$=U=>p(X=>({...X,events:X.events.includes(U)?X.events.filter(P=>P!==U):[...X.events,U]})),R=new Set(["name","source.accept","target.agent_id","target.input","target.max_cost_usd"]),C=(F=(h??[]).find(U=>U.agent_id===f.agentId))==null?void 0:F.definition.max_cost_usd,O=typeof C=="number"&&C>0?C:void 0,I=async U=>{U.preventDefault();const{body:X,issues:P}=gL(f,O!==void 0);if(w([]),!X){m(P??{});return}m({}),S(!0);try{const K=await e.createTrigger(X,T.keyFor("createTrigger",X));E.current&&t(Jr(K.id))}catch(K){const M=$g(K);m(Object.fromEntries(Object.entries(M.fields).filter(([G])=>R.has(G)))),w([...M.rest,...Object.entries(M.fields).filter(([G])=>!R.has(G)).map(([,G])=>G)]),S(!1)}},D=s.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),z=s.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[s.jsx(hh,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(i)return s.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[D,z,s.jsx(_n,{problem:i,onRetry:()=>u(U=>U+1),className:"mt-4"})]});if(n===null)return s.jsx(Ss,{label:"Reading GitHub's connection",rows:3});if(!n)return s.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[D,z,s.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",s.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const H=Cd((h??[]).filter(U=>!U.archived_at));return s.jsxs("form",{onSubmit:U=>void I(U),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[D,z,s.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),v.length>0&&s.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((U,X)=>s.jsx("p",{children:U},X))}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsx(en,{label:"Name",field:"name",issue:g.name,children:s.jsx(He,{name:"name",value:f.name,onChange:U=>_("name")(U.target.value),placeholder:"review PRs"})}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),s.jsx("div",{className:"mt-1 space-y-1",children:rN.map(({event:U,action:X,label:P})=>{const K=`${U}:${X}`;return s.jsxs("label",{className:"flex items-center gap-2 text-body",children:[s.jsx("input",{type:"checkbox",name:"event",value:K,checked:f.events.includes(K),onChange:()=>$(K),className:"accent-primary"}),P," ",s.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[U," ",X]})]},K)})}),g["source.accept"]&&s.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:g["source.accept"]})]}),s.jsx(en,{label:"Agent",field:"target.agent_id",issue:g["target.agent_id"],children:s.jsx(qt,{name:"agent",label:"Agent",className:"w-full",value:f.agentId,onChange:U=>_("agentId")(U),options:[{value:"",label:h?"Pick an agent":"Loading the agents"},...H.map(U=>({value:U.agent_id,label:`${U.definition.name||U.agent_id}${U.kind==="workflow"?" (workflow)":""}`}))]})}),s.jsx(en,{label:"Each run is asked",field:"target.input",issue:g["target.input"],hint:"The event's payload comes with it.",children:s.jsx(Ns,{name:"content",rows:4,className:"p-3 font-sans",value:f.content,onChange:U=>_("content")(U.target.value)})}),s.jsx(en,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:g["target.max_cost_usd"],hint:O!==void 0?`Uses the agent's default (${ri(O)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:s.jsx(He,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:f.maxCost,onChange:U=>_("maxCost")(U.target.value),placeholder:Tg(O)})})]}),s.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[s.jsx(Z,{type:"submit",size:"lg",variant:"solid",disabled:j,children:j?"Creating":"Create GitHub trigger"}),s.jsx(Z,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}const id=(e,t={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(n,o)=>(Object.hasOwn(t,o)?t[o].trim():"")||"…"),LL=e=>`#/templates/${encodeURIComponent(e)}`,Aw=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function xN(e,{secrets:t=!0,mcp:n=!0}={}){var i,l,c;const o=[];return t&&e.secrets.length&&o.push(["Keys",e.secrets.join(", ")]),n&&e.mcp.length&&o.push(["MCP",e.mcp.map(u=>`${u.server}${u.required?"":" (optional)"}`).join(", ")]),e.triggers.length&&o.push(["Triggers",Aw(e.triggers.length,"trigger")]),(i=e.budget)!=null&&i.per_run_usd&&o.push(["Budget",`${Xh(e.budget.per_run_usd)} a run`]),(l=e.budget)!=null&&l.tool_calls&&o.push(["Tool calls",`${Aw(e.budget.tool_calls,"call")} a conversation`]),(c=e.harness)!=null&&c.length&&o.push(["Harness",e.harness.join(", ")]),e.model&&o.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),o}function Yd(e){var n;if(e.type==="boolean")return null;if((n=e.enum)!=null&&n.length)return e.enum.map(String);const t=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return t?t[1].split("|"):null}function IL(e,t){const n={};for(const[o,i]of Object.entries(e.parameters)){const l=t[o];if(i.type==="boolean"){n[o]=l==="true";continue}l===void 0||l===""||(i.type==="number"||i.type==="integer"?n[o]=Number.isFinite(Number(l))?Number(l):l:n[o]=l)}return n}function zL(e){return Object.fromEntries(Object.entries(e.parameters).flatMap(([t,n])=>n.type==="boolean"?typeof n.default=="boolean"?[[t,String(n.default)]]:[]:Yd(n)?[]:n.format==="timezone"?[[t,si()]]:n.format==="cron"?typeof n.default=="string"?[[t,n.default]]:[]:[]))}const DL=(e,t)=>e.mcp.flatMap(n=>n.tools.map(o=>o.tool)).filter(n=>t.has(n)),FL=(e,t)=>e.filter(n=>n.field===t),nl=(e,t)=>(t==null?void 0:t.type)==="string"&&t.format==="cron"?"Schedule":(t==null?void 0:t.type)==="string"&&t.format==="timezone"?"Time zone":e;function UL(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const t=e.description.indexOf(": ");return t<0?void 0:e.description.slice(t+2).trim()||void 0}function Ow(e){const t=Yd(e);if(!t)return null;const n=e.default===void 0?void 0:String(e.default),o=!e.required&&n!==void 0&&t.includes(n);return[...o?[]:[{value:"",label:e.required?"Choose one":n!==void 0?`${n} (default)`:"None chosen"}],...t.map(l=>o&&l===n?{value:"",label:`${l} (default)`}:{value:l,label:l})]}function WL(e,t,n){const o=nl(t,n);if(!n)return e.message;switch(e.reason){case"missing":return`${o} is required.`;case"wrong_type":return`${o} takes ${n.type==="integer"?"a whole number":n.type==="number"?"a number":n.type==="boolean"?"yes or no":"text"}.`;case"not_an_option":return`${o} takes one of: ${yN(n).join(", ")}.`;case"bad_format":return`${o} isn't in the form its description asks for.`;default:return e.message}}const yN=e=>{var t;return(t=e.enum)!=null&&t.length?e.enum.map(String):Yd(e)??[]};function HL(e,t){var o;if(t==="")return!e.required;const n=Yd(e);if(n)return n.includes(t);if(e.type==="integer")return t.trim()!==""&&Number.isSafeInteger(Number(t));if(e.type==="number")return t.trim()!==""&&Number.isFinite(Number(t));if(e.type==="boolean")return(t==="true"||t==="false")&&(!((o=e.enum)!=null&&o.length)||yN(e).includes(t));if(e.pattern)try{return new RegExp(e.pattern,"u").test(t)}catch{return!0}return!0}function BL({v2:e,name:t,go:n}){const[o,i]=y.useState(null),[l,c]=y.useState(null),[u,f]=y.useState(0);y.useEffect(()=>{let h=!0;return c(null),e.listTemplates().then(b=>{h&&i(b.templates)},b=>{h&&c(fn(b,"the templates"))}),()=>{h=!1}},[e,u]);const p=t===void 0||o==null?void 0:o.find(h=>h.name===t);return s.jsx("div",{className:"p-5 md:p-8",children:l&&!o?s.jsx(_n,{problem:l,onRetry:()=>f(h=>h+1),className:""}):o?t===void 0?s.jsx(GL,{templates:o,go:n}):p?s.jsx(KL,{v2:e,template:p,go:n},p.name):s.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 ",t,". ",s.jsx("a",{href:"#/templates",className:"underline",children:"See its templates"}),"."]}):s.jsx(Ss,{label:"Loading the templates",rows:3})})}function GL({templates:e,go:t}){return s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"mb-5 font-mono text-2xl font-semibold",children:"Templates"}),e.length?s.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:e.map(n=>s.jsx("li",{children:s.jsxs("article",{"aria-label":id(n),className:"flex h-full flex-col border bg-card px-5 py-4",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[s.jsx(e0,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),s.jsx("h2",{className:"min-w-0 break-words text-prose font-semibold",children:id(n)}),s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:n.version})]}),s.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:n.description}),s.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:xN(n).map(([o,i])=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("dt",{className:"shrink-0",children:o}),s.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:i})]},o))}),s.jsx("div",{className:"mt-auto pt-4",children:s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>t(LL(n.name)),children:"Apply"})})]})},n.name))}):s.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}const qL=3e3;function VL(e,t){let n;const o=new Promise(i=>n=setTimeout(()=>i(void 0),t));return Promise.race([e,o]).finally(()=>clearTimeout(n))}function KL({v2:e,template:t,go:n}){var X;const[o,i]=y.useState(()=>zL(t)),[l,c]=y.useState(new Set),[u,f]=y.useState(t.approvals_default??"ask"),[p,h]=y.useState(null),[b,g]=y.useState(!1),[m,v]=y.useState([]),[w,j]=y.useState(null),[S,T]=y.useState(null),[E,_]=y.useState([]),[$,R]=y.useState({}),C=y.useRef(Us()).current,O=y.useRef(!0);y.useEffect(()=>(O.current=!0,()=>{O.current=!1}),[]),y.useEffect(()=>{let P=!0;return e.listMcpServers().then(K=>{P&&h(new Set(K.servers.map(M=>M.name)))},()=>{}),()=>{P=!1}},[e]);const I=DL(t,l),D=P=>FL(m,P),z=(P,K)=>{i(G=>({...G,[P]:K}));const M=t.parameters[P];M&&HL(M,K)&&v(G=>G.filter(B=>B.field!==`parameters.${P}`))},H=async()=>{var M,G;g(!0),v([]),j(null);const P=o,K={parameters:IL(t,P),...I.length?{grants:I}:{},overrides:{approvals:u}};try{const B=await e.applyTemplate(t.name,K,C.keyFor(t.name,K));C.done();const L=async()=>(await Promise.all(B.trigger_ids.map(oe=>VL(e.getTrigger(oe),qL).catch(()=>null)))).filter(oe=>oe!=null&&_g(oe));if(B.warnings.length||(M=B.webhook_secrets)!=null&&M.length){R(P),T(B),L().then(_,()=>{});return}const q=B.trigger_ids.length?await L():[];if(!O.current)return;if(!q.length){n(`#/agents/${encodeURIComponent(B.agent_id)}`);return}R(P),_(q),T(B)}catch(B){B instanceof Te&&((G=B.fields)!=null&&G.length)?(v(B.fields),j({text:B.message,withIssues:!0})):j({text:B instanceof Error?B.message:String(B),withIssues:!1})}finally{g(!1)}},F=Object.entries(t.parameters),U=P=>/^(parameters|secrets|mcp)\./.test(P.field)||/^grants\.\d+$/.test(P.field);return S?s.jsxs("section",{"aria-label":"Applied",className:"max-w-3xl",children:[s.jsxs("h1",{className:"mb-4 flex items-center gap-2 font-mono text-2xl font-semibold",children:[s.jsx(dd,{className:"size-5 text-success-text","aria-hidden":!0})," ",id(t,$)," applied"]}),S.warnings.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),s.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:S.warnings.map((P,K)=>{var L,q;const M=/^triggers\.(\d+)\.secret$/.exec(P.field),G=M?S.trigger_ids[Number(M[1])]:void 0,B=M?(L=t.triggers[Number(M[1])])==null?void 0:L.name:void 0;return G&&((q=S.webhook_secrets)!=null&&q.some(ne=>ne.trigger_id===G))?s.jsxs("li",{children:[s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:P.field})," ",P.message]},`${P.field}:${K}`):s.jsxs("li",{children:[s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:P.field})," ",P.message,P.fix?s.jsx("span",{className:"block text-muted-foreground",children:P.fix}):null,G&&s.jsxs("a",{href:`#/triggers/${encodeURIComponent(G)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof B=="string"&&B?B:G," to get its signing secret (Rotate)"]})]},`${P.field}:${K}`)})})]}),(X=S.webhook_secrets)==null?void 0:X.map(P=>{var B;const K=S.trigger_ids.indexOf(P.trigger_id),M=K>=0?(B=t.triggers[K])==null?void 0:B.name:void 0,G=typeof M=="string"&&M?M:P.trigger_id;return P.signing_secret?s.jsx(Rg,{label:`The webhook's URL and secret (${G})`,url:El({id:P.trigger_id}),secret:P.signing_secret},P.trigger_id):s.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[P.note&&s.jsx("p",{className:"text-muted-foreground",role:"note",children:P.note}),s.jsxs("a",{href:`#/triggers/${encodeURIComponent(P.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",G," to get its signing secret (Rotate)"]})]},P.trigger_id)}),E.length>0&&s.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:E.map(P=>s.jsxs("li",{"data-trigger":P.id,className:"px-4 py-3",children:[s.jsx("a",{href:`#/triggers/${encodeURIComponent(P.id)}`,className:"break-words text-prose font-semibold hover:underline",children:P.name}),s.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:Ng(P.source,P.next_at)})]},P.id))}),s.jsx("div",{className:"mt-5"}),s.jsx("a",{href:`#/agents/${encodeURIComponent(S.agent_id)}`,className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):s.jsxs("div",{className:"max-w-3xl",children:[s.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[s.jsx(zs,{className:"size-3.5","aria-hidden":!0})," Templates"]}),s.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[id(t,o)," ",s.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:t.version})]}),s.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:t.description}),F.length>0&&s.jsx(vu,{title:"Parameters",children:F.map(([P,K])=>s.jsxs("div",{"data-field":`parameters.${P}`,className:"px-4 py-3",children:[s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"caps text-small font-semibold",children:[nl(P,K),K.required&&s.jsx("span",{className:"text-destructive-text",children:" *"})]}),s.jsx("span",{className:"mb-1.5 block text-small text-muted-foreground",children:UL(K)}),Ow(K)?s.jsx(qt,{label:nl(P,K),className:"w-full",value:o[P]??"",onChange:M=>z(P,M),options:Ow(K)}):K.format==="cron"&&K.type==="string"?s.jsx(cN,{label:nl(P,K),value:o[P]??"",onChange:M=>z(P,M)}):K.format==="timezone"&&K.type==="string"?s.jsx(uN,{label:nl(P,K),className:"w-full",value:o[P]??"",onChange:M=>z(P,M)}):K.type==="boolean"?s.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:o[P]==="true",onChange:M=>z(P,M.target.checked?"true":"false")}):s.jsx(He,{type:K.type==="string"?"text":"number",step:K.type==="integer"?1:"any",value:o[P]??"",required:K.required,placeholder:K.default===void 0?void 0:String(K.default),onChange:M=>z(P,M.target.value)})]}),s.jsx(Yi,{issues:D(`parameters.${P}`),words:M=>WL(M,P,K)})]},P))}),t.mcp.length>0&&s.jsx(vu,{title:"Tools you allow",note:"Nothing is granted until you tick it. A tool you leave unticked stays at your own setting for it.",children:t.mcp.map(P=>s.jsxs("div",{"data-mcp":P.server,className:"px-4 py-3",children:[s.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[s.jsx("span",{className:"font-semibold",children:P.server}),s.jsx(Pe,{tone:P.required?"plain":"muted",children:P.required?"Required":"Optional"}),p&&s.jsx("span",{className:"text-small text-muted-foreground",children:p.has(P.server)?"Set up here":"Not set up here"})]}),s.jsx(Yi,{issues:D(`mcp.${P.server}`)}),s.jsx("ul",{className:"mt-2 space-y-2",children:P.tools.map(K=>{const M=I.indexOf(K.tool);return s.jsxs("li",{"data-tool":K.tool,children:[s.jsxs("label",{className:"flex items-start gap-2.5",children:[s.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:l.has(K.tool),onChange:()=>c(G=>{const B=new Set(G);return B.has(K.tool)?B.delete(K.tool):B.add(K.tool),B})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"font-mono text-body",children:K.name})," ",s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:K.tool}),s.jsx("span",{className:"block text-small",children:"Allow: the agent may call this without asking you."}),s.jsx("span",{className:"block text-small text-muted-foreground",children:K.asks==="allow"?"The template asks you to allow this.":"The template does not ask for this; unticked, it stays at your setting."})]})]}),M>=0&&s.jsx(Yi,{issues:D(`grants.${M}`)})]},K.tool)})})]},P.server))}),t.secrets.length>0&&s.jsx(vu,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:t.secrets.map(P=>s.jsxs("div",{"data-secret":P,className:"px-4 py-3 font-mono text-body",children:[P,s.jsx(Yi,{issues:D(`secrets.${P}`)})]},P))}),s.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[s.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),s.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on its triggers, with no one there to answer."]].map(([P,K,M])=>s.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[s.jsx("input",{type:"radio",name:"approvals",value:P,className:"mt-1 accent-primary",checked:u===P,onChange:()=>f(P)}),s.jsxs("span",{children:[s.jsx("span",{className:"font-mono text-body",children:K}),s.jsx("span",{className:"block text-small text-muted-foreground",children:M})]})]},P))}),u==="never"&&s.jsx("p",{className:"mt-2 text-small text-warning-text",children:Bj})]}),s.jsx(vu,{title:"What it makes",children:s.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:xN(t,{secrets:!1,mcp:!1}).map(([P,K])=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("dt",{className:"shrink-0 text-muted-foreground",children:P}),s.jsx("dd",{className:"min-w-0 break-words",children:K})]},P))})}),s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx(Z,{size:"sm",variant:"solid",onClick:()=>void H(),disabled:b,children:b?"Applying…":"Apply"}),w&&(!w.withIssues||m.length>0)&&s.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:w.text})]}),m.filter(P=>!U(P)).length>0&&s.jsx("div",{className:"mt-2",children:s.jsx(Yi,{issues:m.filter(P=>!U(P)),named:!0})})]})}function vu({title:e,note:t,children:n}){return s.jsxs("section",{"aria-label":e,className:"mt-6",children:[s.jsx("h2",{className:"caps text-small font-semibold",children:e}),t&&s.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:t}),s.jsx("div",{className:"mt-2 divide-y border",children:n})]})}function Yi({issues:e,named:t=!1,words:n=o=>o.message}){return e.length?s.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((o,i)=>s.jsxs("li",{children:[t&&s.jsxs("span",{className:"font-mono",children:[o.field," "]}),n(o),o.fix&&s.jsx("span",{className:"block text-foreground/80",children:o.fix})]},`${o.field}:${i}`))}):null}const vN="tool_approval_requested";function XL(e){var t;return e.status!=="input_required"||e.state!=="waiting"?null:((t=e.pending)==null?void 0:t.kind)==="approval"?e.pending:null}function YL(e){return e==="not metered"?"Not metered":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${Xh(e)} per call`:null}function QL(e){let t;try{t=JSON.parse(e)}catch{return e}return!t||typeof t!="object"||Array.isArray(t)?JSON.stringify(t,null,2):Object.entries(t).map(([n,o])=>`${n}: ${typeof o=="string"?o:JSON.stringify(o)}`).join(`
539
+ `)}const ZL={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 bN(e){var t;if(e instanceof Te){const n=((t=e.details)==null?void 0:t.reason)==="already_answered"&&typeof e.details.decision=="string"?ZL[e.details.decision]:void 0;if(e.status===409&&n)return n;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 jn(e)}const JL=2e3;function wN({pending:e,onAnswer:t,compact:n=!1,heading:o}){const[i,l]=y.useState(""),[c,u]=y.useState(!1),[f,p]=y.useState(null),[h,b]=y.useState(null),g=y.useRef(!1),m=YL(e.price),v=async w=>{if(g.current)return;g.current=!0,u(!0),p(null);const j=i.trim(),S=await t(w,w==="deny"&&j?j:void 0);g.current=!1,u(!1),S?p(S):b(w)};return s.jsxs("section",{"aria-label":"Approval required",className:ie("min-w-0 border border-warning/50 bg-warning/5",n?"p-4":"p-4 md:p-5"),children:[o,s.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",o&&"mt-2"),children:[s.jsx(s0,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),s.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",s.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),"."]}),s.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:ie("mt-2 overflow-auto whitespace-pre-wrap break-all border bg-card p-3 font-mono text-small leading-[1.6]",n?"max-h-28":"max-h-64"),children:QL(e.args_preview)}),m&&s.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:m}),h?s.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."}):s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("label",{className:"block",children:[s.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),s.jsx(Ns,{value:i,onChange:w=>l(w.target.value),maxLength:JL,rows:n?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Z,{type:"button",variant:"solid",size:"sm",disabled:c,onClick:()=>void v("allow"),children:"Allow once"}),s.jsx(Z,{type:"button",size:"sm",disabled:c,onClick:()=>void v("deny"),children:"Deny"}),c&&s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),!n&&s.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),f&&s.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f})]})]})}const eI={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 tI({mode:e,onSend:t,sending:n,sent:o,purpose:i}){const l=i??eI[e],[c,u]=y.useState(""),[f,p]=y.useState(!1),h=n||f,b=async()=>{if(!c.trim()||!t||h)return;p(!0);const g=await t(c.trim());p(!1),g!==!1&&u("")};return s.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:g=>{g.preventDefault(),b()},children:[s.jsx(Ns,{bare:!0,id:"composer",rows:2,value:c,readOnly:h,"aria-busy":h,onChange:g=>u(g.target.value),placeholder:l.placeholder,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),b())},className:"block w-full resize-none px-4 pt-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[s.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[s.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:l.label})," · ",o?"Sent. It appears on the timeline when the run takes it.":l.does]}),s.jsxs(Z,{type:"submit",size:"sm",disabled:!c.trim()||!t||h,children:[h?"Sending":"Send"," ",s.jsx(G2,{"aria-hidden":!0})]})]})]})}function to(e){if(Number.isInteger(e))return`$${e}`;for(let t=2;t<8;t++)if(Number(e.toFixed(t))===Number(e.toFixed(8)))return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}const kN=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${to(e.cap_usd)} `:""}spend cap`;function nI({pending:e}){return s.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[s.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[s.jsx(ph,{className:"size-3.5","aria-hidden":!0})," ",kN(e)]}),typeof e.said=="string"&&s.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),s.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 jN=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,NN=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function sI(e){var t,n;return e instanceof Te?e.status===422?((n=(t=e.fields)==null?void 0:t[0])==null?void 0:n.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 SN({cap:e,suggested:t,least:n=null,paused:o,onRaise:i}){const[l,c]=y.useState(t===null?"":String(t)),[u,f]=y.useState(!1),[p,h]=y.useState(null),[b,g]=y.useState(null),m=y.useRef(!1),v=Number(l),w=l.trim()!==""&&Number.isFinite(v)&&v>0,j=async S=>{if(S==null||S.preventDefault(),!(!w||m.current)){m.current=!0,f(!0),h(null),g(null);try{const T=await i(v);T.note&&g(T.note)}catch(T){h(sI(T))}finally{m.current=!1,f(!1)}}};return s.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:S=>void j(S),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[s.jsx("span",{className:"text-muted-foreground",children:"$"}),s.jsx(He,{"aria-label":"New cap in dollars",inputMode:"decimal",value:l,onChange:S=>c(S.target.value),disabled:u,placeholder:`more than ${to(e)}`,className:"h-9 w-32"})]}),s.jsx(Z,{type:"submit",size:"sm",variant:"solid",disabled:u||!w,children:u?"Raising":o?"Raise the cap and continue":"Raise the cap"})]}),(n!==null||t!==null)&&s.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[n!==null&&s.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",to(n)]}),t!==null&&s.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",to(t)]})]}),t!==null&&s.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),p&&s.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:p}),b&&s.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:b})]})}function rI({waiting:e}){if(e){const t=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return s.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[s.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[s.jsx(yh,{className:"size-3.5","aria-hidden":!0})," Input required"]}),s.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:t})]})}return s.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[s.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[s.jsx(ul,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),s.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The turn was stopped. The run stays open: send a message to continue it."})]})}let za=0;const oh=()=>{var t;const e=(t=history.state)==null?void 0:t.console_at;return typeof e=="number"?e:void 0},Pw=e=>{za=e,history.replaceState({...history.state??{},console_at:e},"")};function oI(){const e=oh();e===void 0?Pw(0):za=e;const t=()=>{const n=oh();n===void 0?Pw(za+1):za=n};return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function aI(){const e=oh();return e===void 0?-1:za-e}function iI(e){za>0?history.back():location.hash=e}const lI=(e,t)=>{const n=ti(e);return n?z3(n,{ended:t}):e&&e.usd!==null&&p1(e)?"A local estimate, not a bill":void 0};function cI({run:e,agentName:t,actions:n={},costText:o}){var w,j;const i=x5(e.place),l=Bl(e.status,e.state,e.kind,Hl,!0,e.error,e.review),[c,u]=y.useState(!1),f=!!e.archived_at,p=(w=e.cost)==null?void 0:w.cap_usd,h=!!e.pending&&e.pending.kind!=="budget",b=!!n.onRaiseCap&&!l.final&&typeof p=="number"&&!h,[g,m]=y.useState(!1),v=((j=e.pending)==null?void 0:j.kind)==="budget"?e.pending:null;return s.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[s.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[s.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>iI(Is(e.agent_id)),className:"-m-1 shrink-0 p-1 hover:text-foreground",children:s.jsx(zs,{className:"size-3.5","aria-hidden":!0})}),s.jsx("a",{href:Is(e.agent_id),className:"truncate hover:text-foreground hover:underline",children:t}),s.jsx("span",{"aria-hidden":!0,children:"/"}),s.jsxs("span",{className:"truncate",children:["Run ",Fl(e.run_id)]})]}),s.jsxs("div",{"data-phone-row":!0,className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row",children:[s.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents",children:[s.jsx("h1",{className:"break-words text-2xl font-semibold leading-tight max-sm:line-clamp-2 max-sm:basis-full max-sm:text-lg",title:tn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?t:tn(e)}),s.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:[s.jsx(Gl,{run:e}),f&&s.jsx(Pe,{tone:"muted",children:"Archived"}),e.approvals==="never"&&s.jsx(Pe,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),s.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),s.jsx("span",{className:"font-mono",children:Rt(e.created_at)}),o!==void 0?s.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:vb(e.cost,p,{text:o})}):s.jsx("span",{className:"font-mono",title:lI(e.cost,vl(e.status)),children:vb(e.cost,p,{ended:vl(e.status)})}),s.jsx(Id,{run:e,link:!0}),s.jsx(Zj,{run:e})]}),e.status==="completed"&&e.review&&s.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(l.canStop||l.canCancel||n.onArchive||b)&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[b&&s.jsxs(Z,{size:"sm",onClick:()=>m(S=>!S),"aria-expanded":g,title:`Raise its ${to(p)} spend cap.`,children:[s.jsx(ph,{"aria-hidden":!0})," Raise the cap"]}),l.canStop&&s.jsxs(Z,{size:"sm",onClick:n.onStop,disabled:!n.onStop||!!n.busy,title:"End this turn. The run stays open and waits for your next message.",children:[s.jsx(m_,{"aria-hidden":!0})," ",n.busy==="stop"?"Stopping":"Stop"]}),l.canCancel&&!c&&s.jsxs(Z,{size:"sm",variant:"destructive",onClick:()=>u(!0),disabled:!n.onCancel||!!n.busy,title:"End the run for good.",children:[s.jsx(Kw,{"aria-hidden":!0})," ",n.busy==="cancel"?"Cancelling":"Cancel run"]}),c&&s.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:[s.jsx("span",{children:"Cancel for good?"}),s.jsx(Z,{size:"sm",variant:"destructive",onClick:()=>{var S;u(!1),(S=n.onCancel)==null||S.call(n)},children:"Yes, cancel"}),s.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>u(!1),children:"Keep"})]}),n.onArchive&&s.jsxs(Z,{size:"sm",onClick:n.onArchive,disabled:!!n.busy,title:f?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[f?s.jsx(Vw,{"aria-hidden":!0}):s.jsx($l,{"aria-hidden":!0})," ",n.busy==="archive"?f?"Unarchiving":"Archiving":f?"Unarchive":"Archive"]})]})]}),b&&g&&s.jsx("div",{className:"mt-3 max-w-xl",children:s.jsx(SN,{cap:p,suggested:jN(v),least:NN(v),paused:!!v,onRaise:n.onRaiseCap},v?`${e.run_id}:${v.at}`:`${e.run_id}:working`)})]})}const uI=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function dI({view:e,onView:t}){return s.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:uI.map(n=>s.jsxs("label",{className:ie("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===n.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[s.jsx("input",{type:"radio",name:"file-view",value:n.id,checked:e===n.id,onChange:()=>t(n.id),className:"sr-only"}),n.label]},n.id))})}function fI({files:e,onOpen:t}){const n=e.reduce((o,i)=>o+i.size_bytes,0);return s.jsxs("section",{children:[s.jsxs("p",{className:"caps mb-2 flex items-center gap-2 text-label text-muted-foreground",children:[s.jsx(K2,{className:"size-3.5","aria-hidden":!0})," Files · ",e.length," ",e.length===1?"file":"files"," (",Wa(n),")"]}),e.length===0?s.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:"This run wrote no files."}):s.jsx("ul",{className:"border",children:e.map(o=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("button",{type:"button",onClick:()=>t(o),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[s.jsx(Ka,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:o.path}),s.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:Rt(o.modified_at)}),s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Wa(o.size_bytes)})]})},o.path))})]})}function mI({file:e,text:t,onClose:n,files:o=[],onOpen:i}){const[l,c]=y.useState(!1),u=y.useRef(null);y.useEffect(()=>{var S;const w=document.activeElement,j=u.current;return j&&!j.open&&((S=j.showModal)==null||S.call(j)),()=>{var T;j!=null&&j.open&&j.close(),(T=w==null?void 0:w.focus)==null||T.call(w)}},[]),y.useEffect(()=>c(!1),[e.path]);const f=y.useRef(!1),p=y.useRef(!1),h=g4(e),[b,g]=y.useState(h==="markdown"?"rendered":"raw");y.useEffect(()=>g(h==="markdown"?"rendered":"raw"),[e.path]);const m=h1(w=>{const j=o.find(S=>S.path===w);j&&(i==null||i(j))}),v=()=>{if(t===null)return;const w=URL.createObjectURL(new Blob([t],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:w,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(w)};return s.jsx("dialog",{ref:u,"aria-label":e.path,onCancel:w=>{w.preventDefault(),n()},onMouseDown:w=>{f.current=w.target===w.currentTarget},onMouseUp:w=>{p.current=w.target===w.currentTarget},onClick:w=>{f.current&&p.current&&w.target===w.currentTarget&&n(),f.current=p.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:s.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[s.jsx(Z,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:s.jsx(Ol,{"aria-hidden":!0})}),s.jsx(Ka,{className:"size-4 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),h!=="download"&&s.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:s.jsx(dI,{view:b,onView:g})}),s.jsxs(Z,{size:"sm",disabled:t===null,onClick:async()=>{var w;t!==null&&(await((w=navigator.clipboard)==null?void 0:w.writeText(t)),c(!0))},children:[s.jsx(fd,{"aria-hidden":!0})," ",l?"Copied":"Copy"]}),s.jsxs(Z,{size:"sm",disabled:t===null,onClick:v,children:[s.jsx(q2,{"aria-hidden":!0})," Download"]})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:t===null?s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):h==="download"?s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):b==="rendered"?s.jsx("article",{className:"report mx-auto max-w-3xl",onClick:m,dangerouslySetInnerHTML:{__html:Ha(t,i&&{paths:o.map(w=>w.path),from:e.path.split("/").slice(0,-1).join("/")})}}):s.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:t})}),s.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",t===null?"...":`${t.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function pI({run:e,rows:t,files:n=[],onOpen:o}){var u,f,p;const i=((u=e.result)==null?void 0:u.final_answer)??((f=t.findLast(h=>h.kind==="final_answer"))==null?void 0:f.text)??null,l=o?{paths:n.map(h=>h.path)}:void 0,c=h1(h=>{const b=n.find(g=>g.path===h);b&&(o==null||o(b))});if(i)return s.jsx("article",{className:"report max-w-none",onClick:c,dangerouslySetInnerHTML:{__html:Ha(i,l)}});if(((p=e.result)==null?void 0:p.output)!==void 0&&e.result.output!==null){const h=e.result.output,b=h&&typeof h=="object"&&!Array.isArray(h)?Object.entries(h).filter(m=>typeof m[1]=="string"&&m[1].includes(`
540
+ `)&&m[1].length>80):[],g=b.length?Object.fromEntries(Object.entries(h).filter(([m])=>!b.some(([v])=>v===m))):h;return s.jsxs("div",{className:"space-y-8",children:[b.map(([m,v])=>s.jsxs("section",{children:[s.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:m.replace(/_/g," ")}),s.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:c,dangerouslySetInnerHTML:{__html:Ha(v,l)}})]},m)),(!b.length||Object.keys(g).length>0)&&s.jsxs("section",{children:[s.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:b.length?"The rest of the output":"Output"}),s.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(g,null,2)})]})]})}return null}function hI(e,t,n=3e3){const[o,i]=y.useState(null),[l,c]=y.useState(!1),u=y.useRef(e);u.current=e;const f=y.useRef(!1),p=!!e;y.useEffect(()=>{if(!p||l)return;if(!t&&f.current){i(v=>v&&Mw(v));return}let b=!0,g;const m=async()=>{try{const v=await u.current();if(!b)return;f.current=!0,v.state==="off"?i(null):i(t?w=>gI(w,v)?w:v:Mw(v))}catch(v){if(!b)return;if(v instanceof Te&&v.status===401){c(!0),i(w=>w?{state:"signed_out"}:null);return}if(v instanceof Te&&v.status===403){c(!0),i(null);return}}b&&t&&(g=setTimeout(()=>void m(),n))};return m(),()=>{b=!1,clearTimeout(g)}},[p,t,n,l]);const h=y.useCallback(b=>i(g=>g&&g.state==="live"&&g.hold!==b?{...g,hold:b}:g),[]);return{view:o,held:h}}const gI=(e,t)=>!!e&&e.state!=="signed_out"&&e.state===t.state&&e.kind===t.kind&&e.hold===t.hold&&(e.state!=="live"||t.state==="live"&&e.viewer===t.viewer),Mw=e=>e.state==="off"?null:e.state==="signed_out"?e:{state:"none",kind:e.kind,hold:"agent"},xI={browser:Jw,desktop:Cl,phone:d_,sandbox:r0},yI={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},vI={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function bI({runId:e,screen:t,machine:n,opens:o,followUp:i,metered:l,onTake:c,onHand:u}){const f=y.useRef({viewer:"",n:0});(t==null?void 0:t.state)==="live"&&t.viewer!==f.current.viewer&&(f.current={viewer:t.viewer,n:f.current.n+1});const p=(t==null?void 0:t.state)==="live"?kI(t.viewer,e):void 0,h=t&&t.state!=="signed_out"?t.kind:(n==null?void 0:n.kind)??"browser",b=xI[h],g=(t==null?void 0:t.state)==="live"?t:null,[m,v]=y.useState(!1),[w,j]=y.useState(null),S=async F=>{if(!(!F||m)){v(!0),j(null);try{j(await F())}finally{v(!1)}}},T=g&&p&&h!=="browser"?g:null,[E,_]=y.useState(!1),$=y.useRef(null),R=y.useRef(null),C=y.useRef(null),O=y.useRef(!1),I=!!(g&&p);y.useEffect(()=>{I||_(!1)},[I]),y.useEffect(()=>{var F,U,X;if(E){O.current=!0,(U=(F=R.current)==null?void 0:F.querySelector("button"))==null||U.focus();return}O.current&&(O.current=!1,(X=C.current)==null||X.focus())},[E]),y.useEffect(()=>{if(!E)return;const F=M=>{if(M.key==="Escape"){_(!1);return}if(M.key!=="Tab"||!R.current)return;const G=[...R.current.querySelectorAll("button:not([disabled]), iframe")];if(!G.length)return;const B=G[0],L=G[G.length-1],q=document.activeElement;R.current.contains(q)?M.shiftKey&&q===B?(M.preventDefault(),L.focus()):!M.shiftKey&&q===L&&(M.preventDefault(),B.focus()):(M.preventDefault(),B.focus())},U=M=>{M.key==="Escape"&&_(!1)};document.addEventListener("keydown",F);const X=$.current;let P=null;const K=()=>{try{P==null||P.removeEventListener("keydown",U,!0)}catch{}try{P=(X==null?void 0:X.contentWindow)??null,P==null||P.addEventListener("keydown",U,!0)}catch{P=null}};return K(),X==null||X.addEventListener("load",K),()=>{document.removeEventListener("keydown",F),X==null||X.removeEventListener("load",K);try{P==null||P.removeEventListener("keydown",U,!0)}catch{}}},[E,f.current.n]);const D=g?h==="browser"?"browser · take over in the view below":`${vI[g.hold]} · ${h}`:"",z=T&&(T.hold==="person"?s.jsx(Z,{size:"sm",variant:"solid",disabled:m,onClick:()=>void S(u),children:"Hand back"}):s.jsx(Z,{size:"sm",variant:"solid",disabled:m||T.hold==="pending",onClick:()=>void S(c),children:T.hold==="pending"?"Taking over":"Take over"})),H=I&&s.jsx(Z,{ref:E?void 0:C,size:"sm",variant:"ghost",onClick:()=>_(F=>!F),"aria-label":E?"Exit full window (Esc)":"Fill the window",title:E?"Exit full window (Esc)":"Fill the window","aria-pressed":E,children:E?s.jsx(r_,{className:"size-4","aria-hidden":!0}):s.jsx(t_,{className:"size-4","aria-hidden":!0})});return s.jsxs("section",{"aria-label":"Screen",className:"border",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[s.jsx(b,{className:"size-4 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"caps text-small font-semibold",children:g?"Live":yI[h]}),s.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:D}),!E&&z,!E&&H]}),l&&h!=="browser"&&s.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:bg}),!E&&w&&s.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:w}),g&&p?s.jsxs("div",{ref:R,"data-testid":"screen-frame",className:E?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:E?"dialog":void 0,"aria-modal":E?!0:void 0,"aria-label":E?"The run's screen, filling the window":void 0,children:[E&&s.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[s.jsx("span",{className:"flex-1 font-mono text-small",children:D}),z,H]}),E&&w&&s.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:w}),s.jsx("iframe",{ref:$,src:p,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:E?"block min-h-0 w-full flex-1 bg-background":h==="phone"?"mx-auto block aspect-[9/19] h-[70vh] max-w-full bg-background":"block aspect-[16/10] w-full bg-background"},f.current.n)]}):s.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:wI(h,t,n,o,i)})]})}function wI(e,t,n,o,i){return(t==null?void 0:t.state)==="live"?"The live view can't be shown here.":(t==null?void 0:t.state)==="signed_out"?"Signed out: sign in to watch.":e==="sandbox"?"A sandbox has no screen. What the agent runs in it is on the timeline.":(n==null?void 0:n.state)==="failed"?`The ${e} didn't start.${n.why?` ${n.why}`:""}`:o?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.${i?" A follow-up opens a new one if the agent needs it.":""}`}function kI(e,t){let n;try{n=new URL(e,location.origin).href}catch{return}const o=Oo(n);if(!o)return;const i=new URL(o);return i.origin===location.origin&&i.pathname.startsWith(`/v2/runs/${encodeURIComponent(t)}/computer/live/`)?o:void 0}const $a=e=>{var t,n;return e.status==="input_required"&&(((t=e.pending)==null?void 0:t.kind)==="browser"||((n=e.pending)==null?void 0:n.kind)==="computer")?e.pending:null},_N=e=>e.kind==="computer"?e.computer:"browser";function ah(e,t){var n;if(e instanceof Te&&e.code==="handoff_answered"){const o=(n=e.details)==null?void 0:n.outcome;return o==="expired"?"The ask expired before your answer: the agent was told.":o==="done"||o==="cancelled"?`It was already answered: ${o}.`:e.message}return e instanceof Te&&e.code==="computer_not_live"?e.message:e instanceof Te&&e.status===404?t==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Te&&e.status===403?"Sign in with your password to do this from here.":`${t==="hand"?"Not answered":"Not taken"}: ${jn(e)}`}function EN({ask:e,onAnswer:t,open:n,heading:o,compact:i=!1}){const[l,c]=y.useState(!1),[u,f]=y.useState(null),p=y.useRef(!1),h=async b=>{if(!(!t||p.current)){p.current=!0,c(!0),f(null);try{f(await t(b))}finally{p.current=!1,c(!1)}}};return s.jsxs("section",{"aria-label":"Waiting for you at the computer",className:i?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[o,s.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",o&&"mt-1"),children:[s.jsx(Cl,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",_N(e)]}),s.jsxs("div",{"data-agent-request":!0,className:ie("border-l-2 border-warning/60 pl-3",i?"mt-1":"mt-2"),children:[s.jsxs("p",{className:i?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),s.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),s.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),s.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",Rt(e.expires_at)," unanswered"]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[n,s.jsx("span",{className:"flex-1"}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Z,{size:"sm",variant:"solid",disabled:l,onClick:()=>void h("done"),children:"Done"}),s.jsx(Z,{size:"sm",variant:"ghost",disabled:l,onClick:()=>void h("cancelled"),children:"Cancel"})]})]}),u&&s.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:u})]})}function jI(e,t){const n=!!t&&wl(e.learning).length>0,[o,i]=y.useState({state:"reading"}),[l,c]=y.useState(0);return y.useEffect(()=>{if(!n)return;let u=!0;return i({state:"reading"}),Promise.resolve().then(()=>t()).then(f=>{u&&i({state:"read",changes:mA(f,e.learning)})},f=>{u&&i({state:"failed",error:f??new Error("unknown")})}),()=>{u=!1}},[e.run_id,n,l]),n?{got:o,retry:()=>c(u=>u+1)}:null}function NI({got:e,retry:t}){if(e.state==="read"&&!e.changes.length)return null;const n=e.state==="failed"?fn(e.error,"what it changed"):null;return s.jsxs("section",{className:"border","aria-label":"What it changed",children:[s.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&s.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),n&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",n.why.charAt(0).toLowerCase()+n.why.slice(1)]}),s.jsx(Z,{type:"button",onClick:t,size:"sm",children:"Try again"})]}),e.state==="read"&&s.jsx("ul",{className:"divide-y",children:e.changes.map(o=>s.jsx("li",{children:s.jsx(SI,{change:o})},o.file))})]})}function SI({change:e}){const[t,n]=y.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":t,onClick:()=>n(o=>!o),children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),s.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),s.jsx(Fs,{className:ie("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",t&&"rotate-90"),"aria-hidden":!0})]}),t&&(e.withheld?s.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):s.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[s.jsx(Lw,{name:"before",lines:e.before,none:"Not there before."}),s.jsx(Lw,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function Lw({name:e,lines:t,none:n}){return s.jsxs("div",{className:"min-w-0 border","data-side":e,children:[s.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),t===null?s.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:n}):s.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:t.map((o,i)=>s.jsxs("span",{className:ie("flex min-h-[1.7em] px-3",o.mark==="added"&&"bg-primary/10",o.mark==="removed"&&"bg-destructive/10"),children:[s.jsx("span",{"aria-hidden":!0,className:"w-4 shrink-0 select-none text-muted-foreground",children:o.mark==="added"?"+":o.mark==="removed"?"−":""}),o.mark==="added"&&s.jsx("span",{className:"sr-only",children:"Added line: "}),o.mark==="removed"&&s.jsx("span",{className:"sr-only",children:"Taken out: "}),s.jsx("span",{"data-mark":o.mark,className:ie("min-w-0 whitespace-pre-wrap break-words",o.mark==="gap"&&"text-muted-foreground"),children:o.text})]},i))})]})}function _I(e,t,n){const o=!!n&&!!e.learning,[i,l]=y.useState(null);return y.useEffect(()=>{if(!o)return;let c=!0;return Promise.resolve().then(()=>n()).then(u=>{c&&l((u==null?void 0:u.used)??null)},()=>{c&&l(null)}),()=>{c=!1}},[e.run_id,o,t]),o?i:null}const EI=e=>e===1?"once":e===2?"twice":`${e} times`;function $I({used:e,agentId:t}){return!e||!e.skills.length&&!e.workflows.length?null:s.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[s.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),s.jsx("span",{className:"flex-1"}),s.jsx("a",{href:Ld(t),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),s.jsxs("ul",{className:"divide-y",children:[e.skills.map(n=>s.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[s.jsx(Cu,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Skill"}),s.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:n.name}),n.read?s.jsx(Pe,{tone:"success",children:"Read"}):s.jsx(Pe,{tone:"muted",children:"Given, not read"})]},`skill:${n.name}`)),e.workflows.map(n=>s.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[s.jsx(Ho,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),s.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:n.name}),s.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",EI(n.calls)]}),n.failed>0&&s.jsxs(Pe,{tone:"error",children:[n.failed," failed"]})]},`workflow:${n.name}`))]})]})}const TI={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."},CI={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 RI(e,t){var o,i;if(e.status==="input_required"&&((o=e.pending)==null?void 0:o.kind)==="budget"){const{cap_usd:l,spent_usd:c}=e.pending,u=typeof l=="number"&&Number.isFinite(l);return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${to(c)} of its ${to(l)} cap.`:u?`Its ${to(l)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((i=e.pending)==null?void 0:i.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${t.canMessage?", or send a message below to decline it":""}.`,spin:!1};const n=$a(e);return n?{title:`Waiting for you at the ${_N(n)}`,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:t.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.${t.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:t.live}}function AI({run:e,agentName:t,messages:n,harnessSteers:o,rows:i,files:l,readFile:c,openFile:u=null,actions:f,onMessage:p,onApprove:h,tab:b,graphView:g,costText:m,readLearningDiff:v,readLearning:w,readComputer:j,computerEvery:S,onTakeOver:T,onHandBack:E,readComputers:_}){var hn,Xt,at,ct;const $=((hn=e.pending)==null?void 0:hn.kind)==="budget"?e.pending:null,R=$a(e),C=R?o&&n.steer?"steer":n.follow_up?"follow_up":null:null,O=Bl(e.status,e.state,e.kind,n,o,e.error,e.review),I=$?{...O,canMessage:!1,messageMode:null}:R?{...O,canMessage:C!==null,messageMode:C}:O,D=g?"graph":I.final&&e.status==="completed"?"report":"timeline",[z,H]=y.useState(b??D),F=z==="graph"&&!g?D:z,[U,X]=y.useState(u?{file:u,text:null}:null),P=XL(e),K=P||R?null:h4(e.status,e.state,i),M=P?i.findLast(Me=>Me.kind===vN&&Me.tool_use_id===P.call_id):void 0,[G,B]=y.useState(null),L=async(Me,Le,At)=>{const ut=h?await h(Me,Le,At):"This page can't answer an approval.";return B(ut?{id:Me,text:ut}:null),ut},q=y.useRef(Bu()).current,ne=async Me=>{const Le=q.begin();if(X({file:Me,text:null}),!c)return;const At=await c(Me);q.current(Le)&&X({file:Me,text:At})},oe=()=>{q.cancel(),X(null)},ae=jI(e,v),ce=_I(e,I.final,w),le=I.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",{view:ye,held:ee}=hI(j,!I.final,S),be=e.computer,Oe=!!ye||!!be||!!R,We=y.useRef(!1);y.useEffect(()=>{if(Oe){We.current=!0;return}We.current&&F==="screen"&&H(D),We.current=!1},[Oe,F,D]);const[fe,Re]=y.useState(!1);y.useEffect(()=>{if(!be||!wg.has(be.kind)||!_)return;let Me=!0;return _().then(Le=>{var At,ut;Me&&Re(!!((ut=(At=Le.kinds.find(Lt=>Lt.kind===be.kind))==null?void 0:At.providers.find(Lt=>Lt.id===be.provider))!=null&&ut.metered))}).catch(()=>{}),()=>{Me=!1}},[be==null?void 0:be.kind,be==null?void 0:be.provider]);const Xe=R?`${R.kind}:${R.asked_at}`:null,Kt=y.useRef(null);y.useEffect(()=>{!Xe||Kt.current===Xe||!Oe||(Kt.current=Xe,H("screen"))},[Xe,Oe]);const De=async()=>{if(!T)return"This page can't take the computer over.";try{return ee((await T()).hold),null}catch(Me){return ah(Me,"take")}},et=async Me=>{if(!E)return"This page can't hand the computer back.";try{return ee((await E(Me)).hold),null}catch(Le){return ah(Le,"hand")}},[Ut,Wt]=y.useState(null),jt=async Me=>{const Le=(R==null?void 0:R.asked_at)??"",At=await et(Me);return Wt(At?{at:Le,text:At}:null),At};y.useEffect(()=>{u&&c&&ne(u)},[u]);const ss=[...g?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],["files",`Files ${l.length}`],...Oe?[["screen","Screen"]]:[]];return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(cI,{run:e,agentName:t,actions:f,costText:m}),s.jsx(R1,{tabs:ss.map(([Me,Le])=>({id:Me,label:Le})),value:F,onChange:H}),F==="graph"?s.jsx("div",{className:"min-h-0 flex-1",children:g}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[e.status==="failed"&&e.error&&s.jsx(Vo,{error:e.error,title:X1(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&s.jsxs("section",{className:"border border-border-strong/60 p-4",children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),s.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&&s.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[s.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),s.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),s.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."]})]}),G&&G.id!==(P==null?void 0:P.id)&&s.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: ",G.text]}),Ut&&Ut.at!==(R==null?void 0:R.asked_at)&&s.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: ",Ut.text]}),P?s.jsx(wN,{pending:P,onAnswer:(Me,Le)=>L(P.id,Me,Le)},P.id):R?s.jsx(EN,{ask:R,onAnswer:E?jt:void 0,open:F!=="screen"?s.jsx(Z,{size:"sm",variant:"primary",onClick:()=>H("screen"),children:"Open the screen"}):null},Xe):I.needsYou&&($?s.jsx(nI,{pending:$}):s.jsx(rI,{waiting:K})),I.needsYou&&$&&typeof $.cap_usd=="number"&&(f==null?void 0:f.onRaiseCap)&&s.jsx(SN,{cap:$.cap_usd,suggested:jN($),least:NN($),paused:!0,onRaise:f.onRaiseCap},`${e.run_id}:${$.at}`),F==="report"&&s.jsx(pI,{run:e,rows:i,files:l,onOpen:ne}),F==="report"&&!e.result&&!I.final&&s.jsx(Hp,{...RI(e,I)}),F==="report"&&I.final&&!((Xt=e.result)!=null&&Xt.final_answer)&&!((at=e.result)!=null&&at.output)&&!i.some(Me=>Me.kind==="final_answer")&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&s.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This run gave no answer."}),F==="timeline"&&s.jsx(nj,{rows:K1(i,e.learning),live:I.live,asking:(M==null?void 0:M.id)??(I.needsYou&&!$?K==null?void 0:K.id:void 0),waitingOn:e.status==="input_required"?(ct=e.pending)==null?void 0:ct.kind:void 0}),(F==="report"||F==="timeline")&&s.jsx($I,{used:ce,agentId:e.agent_id}),(F==="report"||F==="timeline")&&ae&&s.jsx(NI,{got:ae.got,retry:ae.retry}),F==="files"&&s.jsx(fI,{files:l,onOpen:ne}),F==="screen"&&Oe&&s.jsx(bI,{runId:e.run_id,screen:ye,machine:be,opens:le,followUp:I.canMessage&&I.messageMode==="follow_up",metered:fe,onTake:T?De:void 0,onHand:E?()=>et():void 0})]})}),I.canMessage&&s.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:s.jsx("div",{className:"mx-auto max-w-4xl",children:s.jsx(tI,{mode:I.messageMode,onSend:p,purpose:P?TI:R&&C?CI[C]:void 0})})}),U&&s.jsx(mI,{file:U.file,text:U.text,onClose:oe,files:l,onOpen:ne})]})}const $N=new Set(["chain","parallel","route","map","loop","workflow"]),OI={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},PI=e=>e==="review"?"needs review":e.replace("-"," ");function Ag({state:e}){const t=Hu(e)??"pending";return s.jsx(Pe,{tone:OI[t]??"plain",className:"whitespace-nowrap",children:PI(t)})}function Og({provider:e}){if(!e)return null;const t=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return s.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${t}))`,borderColor:`hsl(var(${t}) / .6)`,background:`hsl(var(${t}) / .12)`},children:e})}const TN={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Pg=(e,t)=>e&&t?Date.parse(t)-Date.parse(e):void 0;function MI({data:e,selected:t,onSelect:n,onClose:o,fileUrl:i}){var j,S,T,E,_,$;const l=e.graph.nodes.find(R=>R.path===t.path),[c,u]=y.useState(null);if(!l)return null;const f=e.nodes[l.path],p=eg(e.workflow,l.path,l),h=l.kind==="map"?l.path:(j=e.graph.nodes.find(R=>R.kind==="map"&&l.path.startsWith(`${R.path}/body/`)))==null?void 0:j.path,b=t.item!=null&&h?(T=(S=e.nodes[h])==null?void 0:S.items)==null?void 0:T.find(R=>R.index===t.item):void 0,g=e.decisions.filter(R=>R.node===l.path),m=e.effects.filter(R=>R.node===l.path),v=!!h&&l.kind!=="map",w=Pg(f==null?void 0:f.startedAt,f==null?void 0:f.endedAt);return s.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[s.jsxs("header",{className:"border-b px-5 py-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[l.kind,p.tool?` · ${AN(p.tool)}`:l.via?` · ${l.via}`:"",p.tool&&ql(p.tool)&&s.jsx(ON,{}),b&&s.jsxs(s.Fragment,{children:[s.jsx(Fs,{className:"size-3","aria-hidden":!0})," item ",b.index+1]})]}),s.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:b?bl(e,h,b.index)??`Item ${b.index+1}`:l.label}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[s.jsx(Ag,{state:b?b.status:f==null?void 0:f.status}),b&&(()=>{const R=tg(e,h,b);return R.outcome?s.jsxs("span",{className:"font-mono text-label",title:R.pNote,children:["outcome ",s.jsx("b",{className:TN[R.tone??""],children:R.outcome}),R.p!==void 0&&s.jsxs("span",{className:"text-muted-foreground",children:[" · ",vs(R.p)]})]}):null})(),p.decision&&s.jsx(Og,{provider:p.provider}),p.decision&&p.model&&s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:p.model}),(f==null?void 0:f.branch)&&s.jsxs("span",{className:"font-mono text-label",children:["took ",s.jsx("b",{children:f.branch})]}),!b&&w!==void 0&&s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Pa(w)})]})]}),s.jsx(Z,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:o,children:s.jsx(Ol,{"aria-hidden":!0})})]}),b&&s.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>n({path:h,item:null}),children:["All ",(_=(E=e.nodes[h])==null?void 0:E.items)==null?void 0:_.length," items of ",($=e.graph.nodes.find(R=>R.path===h))==null?void 0:$.label]})]}),s.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[b?s.jsx(DI,{data:e,mapPath:h,index:b.index,status:b.status,fileUrl:i,zoom:u}):l.kind==="map"?s.jsx(LI,{data:e,mapPath:l.path,onSelect:n}):v&&(g.length||m.length)?s.jsx(II,{data:e,path:l.path,mapPath:h,onSelect:n}):s.jsxs(s.Fragment,{children:[l.kind==="parallel"&&s.jsx(zI,{data:e,path:l.path,onSelect:n}),g.map((R,C)=>s.jsx(RN,{d:R,fileUrl:i,zoom:u},R.id??C)),m.map((R,C)=>s.jsx(PN,{e:R,fileUrl:i,zoom:u},C)),!g.length&&!m.length&&l.kind!=="parallel"&&s.jsx(CN,{kind:l.kind,status:f==null?void 0:f.status,meta:p})]}),s.jsx(BI,{workflow:e.workflow,path:l.path,kind:l.kind})]}),c&&s.jsx(GI,{src:c,onClose:()=>u(null)})]})}function CN({kind:e,status:t,meta:n}){const o=n.decision?t==="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.":$N.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return s.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:o})}function LI({data:e,mapPath:t,onSelect:n}){var l;const o=((l=e.nodes[t])==null?void 0:l.items)??[],i=E1(o);return s.jsxs("section",{children:[s.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",i.total],["Done",i.done],["Working",i.working],["Review",i.review],["Failed",i.failed]].map(([c,u])=>s.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[s.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),s.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:u})]},c))}),s.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[s.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),s.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),s.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),s.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),s.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),s.jsx("tbody",{children:o.map(c=>{const u=e.decisions.filter(h=>{var b;return h.item===c.index&&!!((b=h.node)!=null&&b.startsWith(`${t}/body`))}),f=tg(e,t,c),p=u.length?u.some(h=>h.cost_usd===null)?null:u.reduce((h,b)=>h+(b.cost_usd??0),0):void 0;return s.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>n({path:t,item:c.index}),children:[s.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),s.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:bl(e,t,c.index),children:bl(e,t,c.index)??"—"}),s.jsx("td",{className:"border-b py-1.5 pr-2",children:s.jsx(Ag,{state:c.status})}),s.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[f.pNote,...u.map(h=>Ba(h))].filter(Boolean).join(", "),children:f.outcome?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:ie("font-semibold",TN[f.tone??""]),children:f.outcome}),f.p!==void 0&&s.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:vs(f.p)})]}):u.map(h=>Ba(h)).filter(Boolean).join(", ")||s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:p===void 0?s.jsx("span",{className:"text-muted-foreground",children:"—"}):ni(p)})]},c.index)})})]})]})}function II({data:e,path:t,mapPath:n,onSelect:o}){var h;const i=e.decisions.filter(b=>b.node===t),l=e.effects.filter(b=>b.node===t),c=(((h=e.nodes[n])==null?void 0:h.items)??[]).map(b=>({it:b,d:i.find(g=>g.item===b.index),e:l.find(g=>g.item===b.index)})).filter(b=>b.d||b.e),u=i.filter(b=>b.cost_usd!==null),f=i.filter(b=>b.latency_ms!==null),p=f.length?f.reduce((b,g)=>b+(g.latency_ms??0),0)/f.length:void 0;return s.jsxs("section",{children:[i.length>0&&s.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[i.length," asked · ",ni(u.reduce((b,g)=>b+(g.cost_usd??0),0)),u.length<i.length?` + ${i.length-u.length} unknown`:""," · mean ",Pa(p)]}),s.jsx("table",{className:"w-full border-collapse font-mono text-small",children:s.jsx("tbody",{children:c.map(({it:b,d:g,e:m})=>s.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>o({path:n,item:b.index}),children:[s.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:b.index+1}),s.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:bl(e,n,b.index)}),s.jsx("td",{className:"border-b py-1.5 pr-2",children:g?Ba(g):m?s.jsx(Ag,{state:m.status}):null}),s.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:g?Pa(g.latency_ms):m?Pa(Pg(m.startedAt,m.endedAt)):""})]},b.index))})})]})}function zI({data:e,path:t,onSelect:n}){var g,m;const o=`${t}/branches/`,i=e.decisions.filter(v=>{var w;return((w=v.node)==null?void 0:w.startsWith(o))&&/^\d+$/.test(v.node.slice(o.length))&&v.item===null}),l=new Set(i.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...l],u=i.map(v=>{var w;return{d:v,a:(w=v.answers)==null?void 0:w[c]}}).filter(v=>{var w;return((w=v.a)==null?void 0:w.type)==="noul"});if(l.size!==1||u.length<2)return s.jsx(CN,{kind:"parallel",meta:{decision:!1}});const f=u.map(v=>v.a.noul),p=f.reduce((v,w)=>v+w,0)/f.length,h=Math.max(...f)-Math.min(...f),b=v=>{var w;return((w=e.graph.nodes.find(j=>j.path===v.node))==null?void 0:w.label)??v.node};return s.jsxs("section",{className:"border bg-card",children:[s.jsxs("header",{className:"border-b px-4 py-2.5",children:[s.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",u.length," models · ",c]}),s.jsx("p",{className:"mt-1 text-body leading-snug",children:((m=(g=i[0].questions)==null?void 0:g[c])==null?void 0:m.instructions)??c})]}),s.jsx("ul",{className:"divide-y",children:u.map(({d:v,a:w})=>s.jsx("li",{children:s.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:()=>n({path:v.node,item:null}),children:[s.jsx("span",{className:"w-[92px] shrink-0",children:s.jsx(Og,{provider:v.provider})}),s.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??b(v)}),s.jsx(ih,{p:w.noul,strong:!0,tick:.5,tone:w.noul>=.5?"fg":"muted"}),s.jsx("span",{className:"w-10 text-right tabular-nums",children:vs(w.noul)})]})},v.id??v.executionPath))}),s.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[s.jsxs("div",{className:"border-r px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),s.jsx("dd",{className:"font-semibold tabular-nums",children:vs(p)})]}),s.jsxs("div",{className:"border-r px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),s.jsx("dd",{className:ie("font-semibold tabular-nums",h>.3&&"text-warning-text"),children:vs(h)})]}),s.jsxs("div",{className:"px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),s.jsx("dd",{className:"tabular-nums",children:ni(u.some(v=>v.d.cost_usd===null)?null:u.reduce((v,w)=>v+(w.d.cost_usd??0),0))})]})]})]})}function DI({data:e,mapPath:t,index:n,status:o,fileUrl:i,zoom:l}){const u=e.graph.nodes.filter(f=>f.path.startsWith(`${t}/body`)).map(f=>({n:f,ds:e.decisions.filter(p=>p.node===f.path&&p.item===n),es:e.effects.filter(p=>p.node===f.path&&p.item===n)})).filter(f=>!$N.has(f.n.kind)||f.ds.length||f.es.length);return o==="pending"?s.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."}):s.jsxs("div",{className:"space-y-5",children:[u.map(({n:f,ds:p,es:h})=>p.length||h.length?s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:f.label}),h.map((b,g)=>s.jsx(PN,{e:b,fileUrl:i,zoom:l,compact:!0},g)),p.map((b,g)=>s.jsx(RN,{d:b,fileUrl:i,zoom:l},b.id??g))]},f.path):null),o==="working"&&!u.some(f=>f.ds.length)&&s.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 Iw=e=>`${Math.round(e*100)}%`,vs=e=>e.toFixed(2);function ih({p:e,strong:t,tick:n,tone:o="fg"}){const i={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[o];return s.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[s.jsx("span",{className:ie("absolute inset-y-0 left-0 transition-[width] duration-slow",t?i:"bg-muted-foreground/45"),style:{width:Iw(Math.max(0,Math.min(1,e)))}}),n!==void 0&&s.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:Iw(n)},title:`threshold ${vs(n)}`})]})}function FI({id:e,q:t,a:n,rule:o}){const i=u=>{var f;return(o==null?void 0:o.kind)==="pick"&&(t==null?void 0:t.type)==="choice"&&typeof((f=t.criteria)==null?void 0:f[u])=="string"?t.criteria[u]:u},l=(t==null?void 0:t.instructions)??e,c=(o==null?void 0:o.kind)==="route"?o.unsure:null;return s.jsxs("div",{className:"py-2.5",children:[s.jsxs("p",{className:"mb-2 text-body leading-snug",children:[s.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),l]}),n?n.type==="refusal"?s.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):n.type==="noul"?s.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[s.jsx("span",{className:ie("w-8 font-semibold",n.noul>=.5?"text-foreground":"text-muted-foreground"),children:n.noul>=.5?"YES":"NO"}),s.jsx(ih,{p:n.noul,strong:!0,tick:.5,tone:n.noul>=.5?"fg":"muted"}),s.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",vs(n.noul)]})]}):n.type==="box"?s.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(n.box)]}):s.jsxs("div",{className:"space-y-1.5",children:[Object.entries(n.probabilities).sort((u,f)=>f[1]-u[1]).slice(0,(o==null?void 0:o.kind)==="pick"?5:void 0).map(([u,f])=>{const p=(n.type==="choice"?n.choice:String(n.score))===u;return s.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[s.jsx("span",{className:ie("truncate",(o==null?void 0:o.kind)==="pick"?"w-48":"w-28",p?"font-semibold":"text-muted-foreground"),title:i(u),children:n.type==="score"?`${u} ${n.legend[u]??""}`:i(u)}),s.jsx(ih,{p:f,strong:p,tick:p&&c?c.gte:void 0}),s.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:vs(f)})]},u)}),(o==null?void 0:o.kind)==="pick"&&Object.keys(n.probabilities).length>5&&s.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(n.probabilities).length-5," more options, each less likely"]})]}):s.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function UI(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 ${vs(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) ≥ ${vs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${vs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function WI(e){var n,o,i,l;const t=e.action;if(t==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((n=e.rule)==null?void 0:n.kind)==="route"){const c=((i=(o=e.answers)==null?void 0:o.branch)==null?void 0:i.type)==="choice"?e.answers.branch.confidence:void 0;return t.unsure?`Took "${String(t.taken)}": "${String(t.branch)}" at ${c!==void 0?vs(c):"?"} is below the threshold.`:`Took "${String(t.taken??t.branch)}".`}if(((l=e.rule)==null?void 0:l.kind)==="pick"&&typeof t.index=="number"){const c=e.rule.options[t.index];return t.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${S1(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${t.index}`}.`}return typeof t=="object"?Object.entries(t).map(([c,u])=>`${c} = ${typeof u=="object"?JSON.stringify(u):String(u)}`).join(" · "):String(t)}function RN({d:e,fileUrl:t,zoom:n}){var l,c,u;const o=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),i=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return s.jsxs("section",{className:"border bg-card",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[s.jsx(Og,{provider:e.provider}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),s.jsx(Pe,{tone:i,children:e.status==="cancelled"?"outcome unknown":e.status})]}),s.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[s.jsxs("div",{className:"border-r px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((l=e.rule)==null?void 0:l.kind)!=="route"?"Least sure answer":"Verdict"}),s.jsx("dd",{className:"break-words font-semibold",children:Ba(e)??"—"})]}),s.jsxs("div",{className:"border-r px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),s.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:ni(e.cost_usd)})]}),s.jsxs("div",{className:"px-4 py-2",children:[s.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),s.jsx("dd",{className:"tabular-nums",children:Pa(e.latency_ms)})]})]}),e.error&&s.jsx("p",{className:ie("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&s.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(f=>({img:f,src:f.ref&&t(f.ref)||Oo(f.url)})).filter(({src:f})=>f).map(({img:f,src:p})=>s.jsxs("figure",{className:"flex gap-3",children:[s.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>n(p),"aria-label":`Open ${f.ref}`,children:s.jsx("img",{src:p,alt:`The page the model saw as ${f.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),s.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[s.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),s.jsxs("p",{children:[s.jsx("span",{className:"text-muted-foreground",children:"token "}),f.token]}),s.jsxs("p",{className:"break-all",children:[s.jsx("span",{className:"text-muted-foreground",children:"page "}),f.ref]}),f.sha256&&s.jsxs("p",{className:"break-all",title:f.sha256,children:[s.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),f.sha256.slice(0,16),"…"]}),(f.mime||f.bytes)&&s.jsx("p",{className:"text-muted-foreground",children:[f.mime,f.bytes?`${Math.round(f.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},f.token))}),s.jsx("div",{className:"divide-y px-4",children:o.map(f=>{var p,h;return s.jsx(FI,{id:f,q:(p=e.questions)==null?void 0:p[f],a:(h=e.answers)==null?void 0:h[f],rule:e.rule},f)})}),s.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[s.jsxs("div",{className:"flex gap-3",children:[s.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),s.jsx("dd",{children:UI(e.rule)})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),s.jsx("dd",{className:"font-mono text-small",children:WI(e)})]})]}),!!((u=e.evidence)!=null&&u.length)&&s.jsx(HI,{evidence:e.evidence}),e.state!=null&&s.jsxs("details",{className:"group border-t",children:[s.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:[s.jsx(Fs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),s.jsx(ld,{value:e.state})]})]})}function HI({evidence:e}){return s.jsxs("section",{className:"border-t px-4 py-3",children:[s.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),s.jsx("ol",{className:"space-y-3",children:e.map((t,n)=>{let o=t.url;try{o=new URL(t.url).host}catch{}const i=Oo(t.url);return s.jsxs("li",{className:"flex gap-3",children:[s.jsx("span",{className:"font-mono text-label text-muted-foreground",children:n+1}),s.jsxs("div",{className:"min-w-0 flex-1",children:[i?s.jsxs("a",{href:i,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[t.title??o,s.jsx(V2,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):s.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:t.title??o}),s.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[o,t.scope&&s.jsx("span",{className:"border px-1",children:t.scope})]}),t.excerpts.slice(0,2).map((l,c)=>s.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:l},c))]})]},n)})})]})}const AN=e=>{const t=ql(e);return t?`${t.tool} on ${t.server}`:e},ON=()=>s.jsx(Pe,{tone:"muted",title:"An MCP server's tool",children:s.jsx("span",{"data-mcp":!0,children:"MCP"})});function PN({e,fileUrl:t,zoom:n,compact:o=!1}){var h;const i=e.output,l=i!=null,c=i&&typeof i=="object"?i:null,u=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),f=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),p=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return s.jsxs("section",{className:"border bg-card",children:[s.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[s.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"}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:AN(e.tool)}),ql(e.tool)&&s.jsx(ON,{}),s.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Pa(Pg(e.startedAt,e.endedAt)):""}),s.jsx(Pe,{tone:p,children:e.status})]}),s.jsxs("div",{className:"space-y-3 px-4 py-3",children:[o?s.jsxs("p",{className:"break-all font-mono text-label",children:[s.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):s.jsxs("div",{children:[s.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),s.jsx(ld,{value:e.input,small:!0})]}),f&&s.jsx("p",{className:"font-mono text-small text-destructive-text",children:f}),!!((h=c==null?void 0:c.pages)!=null&&h.length)&&s.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(b=>s.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>n(t(b.image)),"aria-label":`Open page ${b.page}`,children:s.jsx("img",{src:t(b.image),alt:`Page ${b.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},b.page))}),l&&!f&&s.jsxs("details",{className:"group",children:[s.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[s.jsx(Fs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),s.jsx(ld,{value:i,small:!0})]}),!l&&!f&&s.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":u?"Running…":"Finished with no output."})]})]})}function BI({workflow:e,path:t,kind:n}){const o=j1(e,t);if(!o)return null;const i=Object.fromEntries(Object.entries(o).map(([l,c])=>[l,(l==="steps"||l==="branches"&&n==="parallel")&&Array.isArray(c)?`… ${hg(c.length)}`:l==="body"?"… its body":l==="branches"&&n==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([u,f])=>[u,(f==null?void 0:f.criteria)??"…"])):c]));return s.jsxs("details",{className:"group border",children:[s.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:[s.jsx(Fs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",s.jsx("span",{className:"normal-case tracking-normal",children:t})]}),s.jsx(ld,{value:i})]})}function ld({value:e,small:t}){return s.jsx("pre",{className:ie("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",t?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function GI({src:e,onClose:t}){return s.jsx(ng,{open:!0,onClose:t,title:"Page image",size:"full",children:s.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const MN=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function qI(e,{everyMs:t=1e3,key:n="",enabled:o=!0}={}){const[i,l]=y.useState(null),[c,u]=y.useState(null),[f,p]=y.useState(0),[h,b]=y.useState(0),g=y.useRef(e);return g.current=e,y.useEffect(()=>{if(!o)return;const m=new AbortController;let v;const w=async()=>{try{const j=Date.now(),S=await g.current(m.signal);if(m.signal.aborted||(l(S),u(null),p(j),Ul(S.run.status)))return}catch(j){if(m.signal.aborted)return;u(j);const S=j;if(S.retryable){v=setTimeout(w,Math.min(t,S.retryAfterMs??500));return}if(MN(j))return}v=setTimeout(w,t)};return w(),()=>{m.abort(),clearTimeout(v)}},[n,t,h,o]),{data:i,error:c,readAt:f,reload:()=>b(m=>m+1)}}function VI({data:e,actions:t={},fileUrl:n,initial:o=null,lastRead:i}){const[l,c]=y.useState(o),u=y.useMemo(()=>d4(e,l),[e,l]),f=Ul(e.run.status),[p,h]=y.useState(()=>Date.now()),b=y.useMemo(()=>Date.now(),[e]);return y.useEffect(()=>{if(f||e.run.paused)return;const g=setInterval(()=>h(Date.now()),1e3);return()=>clearInterval(g)},[f,e.run.paused]),s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(KI,{data:e,readAt:b,now:p,actions:t,stale:!f&&i&&p-i>5e3?Math.max(1e3,p-i):0}),e.run.paused&&s.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."}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[s.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:s.jsx("div",{className:"px-5 py-6 md:px-8",children:s.jsx(Wd,{graph:e.graph,marks:u,onSelect:g=>c(m=>m&&m.path===g.path&&(m.item??null)===g.item?null:g),label:"The run's workflow graph"})})}),l&&s.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:s.jsx(MI,{data:e,selected:l,onSelect:c,onClose:()=>c(null),fileUrl:n})})]}),s.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:s.jsx(Hd,{run:!0})})]})}function KI({data:e,readAt:t,now:n,actions:o,stale:i}){const l=Ul(e.run.status),c=e.graph.nodes.find(b=>{var g,m;return b.kind==="map"&&((m=(g=e.nodes[b.path])==null?void 0:g.items)==null?void 0:m.length)}),u=c?E1(e.nodes[c.path].items):null,{usd:f,unknown:p}=$1(e),h=[["Elapsed",Ga(p4(e,t,n))],["Cost",s.jsxs(s.Fragment,{children:[ni(f),p>0&&s.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",p," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",YI(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return u&&h.push(["Items",s.jsxs(s.Fragment,{children:[s.jsx("span",{children:u.done}),s.jsxs("span",{className:"text-muted-foreground",children:["/",u.total]}),u.failed>0&&s.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[u.failed," failed"]}),u.review>0&&s.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[u.review," review"]})]})]),s.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&s.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:s.jsxs(Pe,{tone:"warning",children:[s.jsx(ul,{className:"size-3","aria-hidden":!0})," Paused"]})}),h.map(([b,g,m],v)=>s.jsxs("div",{className:ie("px-4 py-2",v?"border-l":"pl-5 md:pl-8"),title:m,children:[s.jsx("p",{className:"caps text-micro text-muted-foreground",children:b}),s.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:g})]},b)),s.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[i>0&&s.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",Ga(i)," ago, reading again"]}),!l&&(e.run.paused?s.jsxs(Z,{size:"sm",variant:"solid",onClick:o.onResume,disabled:!o.onResume||!!o.busy,children:[s.jsx(Al,{"aria-hidden":!0})," ",o.busy==="resume"?"Resuming":"Resume"]}):s.jsxs(Z,{size:"sm",onClick:o.onPause,disabled:!o.onPause||!!o.busy,title:"Calls in flight finish; no new node starts.",children:[s.jsx(ul,{"aria-hidden":!0})," ",o.busy==="pause"?"Pausing":"Pause"]}))]})]})}const XI=new Set(["agent","decide","extract","report","artifact"]),YI=e=>e.graph.nodes.filter(t=>{var n;return XI.has(t.kind)&&!["pending","not_run"].includes(((n=e.nodes[t.path])==null?void 0:n.status)??"pending")}).length;function QI({error:e}){const t=e==null?void 0:e.status;return s.jsx("p",{className:ie("m-8 border p-4 font-mono text-body",t===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":t===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 ZI(e,t){return!t||e.state==="loading"?{messages:Hl,steers:!1}:e.state==="failed"?{messages:t.features.messages,steers:!1}:{messages:t.features.messages,steers:yA(e.id,t.harnesses)}}async function JI(e,t){try{let n=null;do{const o=await e.listRevisions(t.agent_id,n),i=o.revisions.find(l=>l.revision===t.revision);if(i)return{state:"read",id:i.definition.harness};n=o.next_cursor}while(n)}catch{}return{state:"failed"}}const zw=new Set(["completed","failed","cancelled"]),ez=e=>{const t=$1(e);return`${ni(t.usd)}${t.unknown?` + ${t.unknown} unknown`:""}`},tz=e=>e instanceof Te?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Na=e=>({api:tz(e),title:rP(e),cause:e});function Dw({v2:e,runId:t,caps:n,agentName:o}){const[i,l]=y.useState(null),[c,u]=y.useState(null),[f,p]=y.useState([]),[h,b]=y.useState([]),[g,m]=y.useState(null),[v,w]=y.useState(null),[j,S]=y.useState(0),T=y.useRef(""),E=y.useRef(Bu()).current,_=y.useRef(Bu()).current,$=y.useRef(Us()).current,R=y.useRef(0),C=y.useRef(""),[O,I]=y.useState({state:"loading"});y.useEffect(()=>{i&&O.state==="loading"&&JI(e,i).then(I)},[i==null?void 0:i.revision]);const D=ZI(O,n);sj(i,()=>z(),()=>S(L=>L+1));const z=async()=>{const L=E.begin();try{const[q,ne]=await Promise.all([e.getRun(t),e.listFiles(t)]);E.current(L)&&(l(q),b(ne.files))}catch(q){E.current(L)&&m(Na(q))}};y.useEffect(()=>{z()},[t]),Xj(()=>{z()}),y.useEffect(()=>{const L=new AbortController;return u(null),Jh(e,t,{signal:L.signal,onRows:q=>{p(q);const ne=q.filter(ae=>ae.kind===vN).map(ae=>`${ae.id}\0${ae.summary}`).join("");ne!==C.current&&(C.current=ne,z());const oe=q.filter(ae=>ae.kind==="tool_result").length;if(oe>R.current){R.current=oe;const ae=_.begin();e.listFiles(t).then(ce=>{_.current(ae)&&b(ce.files)}).catch(()=>{})}},onPage:q=>{q.cost&&u(q.cost);const ne=`${q.status}/${q.state}`;(ne!==T.current||q.status==="input_required"&&!q.unchanged)&&(T.current=ne,z())}}).catch(q=>{L.signal.aborted||m(Na(q))}),()=>L.abort()},[t,j]);const H=async L=>{w(L);try{await e[L](t),m(null)}catch(q){m(Na(q))}w(null),await z(),S(q=>q+1)},F=async()=>{if(i){w("archive");try{const L=await(i.archived_at?e.unarchiveRun(t):e.archiveRun(t));l(q=>q?{...q,archived_at:L.archived_at}:L),m(null)}catch(L){m(Na(L))}w(null),z()}},U=async L=>{const q=await e.raiseCap(t,L);return await z(),S(ne=>ne+1),q},X=async L=>{let q=!0;try{await mj($,t,L,e.sendMessage),m(null)}catch(ne){m(Na(ne)),q=!1}return await z(),S(ne=>ne+1),q},P=async(L,q,ne)=>{let oe=null;try{await e.answerApproval(t,L,q,ne)}catch(ae){oe=bN(ae)}return await z(),S(ae=>ae+1),oe},K=async L=>{try{return await L()}finally{await z(),S(q=>q+1)}},M=qI(L=>e.getRunGraph(t,L),{key:t,enabled:(i==null?void 0:i.kind)==="workflow"}),G=!M.data&&MN(M.error);if(!i)return g?g.cause instanceof Te&&g.cause.status===404?s.jsx(rj,{what:"run",id:t,list:{href:"#/runs",label:"Open the runs list"}}):s.jsx(_n,{problem:fn(g.cause,"the run"),onRetry:()=>{m(null),z(),S(L=>L+1)}}):s.jsx(zO,{});const B=c&&!zw.has(i.status)?{...i,cost:c}:i;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&s.jsx("div",{className:"border-b p-3",children:s.jsx(Vo,{title:g.title,error:g.api})}),s.jsx(AI,{run:B,agentName:o(i.agent_id),messages:D.messages,harnessSteers:D.steers,graphView:i.kind==="workflow"&&!G?s.jsx(nz,{v2:e,runId:t,graph:M,onMoved:()=>{z()}}):void 0,costText:i.kind==="workflow"&&!zw.has(i.status)&&M.data?ez(M.data):void 0,rows:f,files:h,readFile:L=>e.readFile(t,L.path),readLearningDiff:()=>e.runLearningDiff(t),readLearning:()=>e.runLearning(t),readComputer:()=>e.runComputer(t),onTakeOver:()=>K(()=>e.takeOverComputer(t)),onHandBack:L=>K(()=>e.handBackComputer(t,L)),readComputers:()=>e.computers(),onMessage:X,onApprove:P,actions:{onStop:()=>void H("stop"),onCancel:()=>void H("cancel"),onArchive:()=>void F(),onRaiseCap:U,busy:v}},i.run_id)]})}function nz({v2:e,runId:t,graph:n,onMoved:o}){const{data:i,error:l,readAt:c,reload:u}=n,[f,p]=y.useState(null),[h,b]=y.useState(null),[g,m]=y.useState(null),v=async j=>{p(j);try{const S=await(j==="pause"?e.pauseRun(t):e.resumeRun(t));m({paused:S.paused,status:S.status,at:Date.now()}),b(null)}catch(S){b(Na(S))}p(null),u(),o()},w=i&&g&&c<g.at?{...i,run:{...i.run,paused:g.paused,...g.status?{status:g.status}:{}}}:i;return w?s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h&&s.jsx("div",{className:"border-b p-3",children:s.jsx(Vo,{title:h.title,error:h.api})}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(VI,{data:w,lastRead:c,fileUrl:j=>e.fileUrl(t,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:f}})})]}):s.jsx(QI,{error:l})}function sz({view:e,error:t,onRetry:n,scope:o,needsYou:i,asking:l,startHere:c}){if(t)return s.jsx(_n,{problem:t,onRetry:n});if(!e)return s.jsx(IO,{});if(c)return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-6 px-6 py-8",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),c]})});const u=h=>{var b;return((b=e.perAgent.find(g=>g.agentId===h))==null?void 0:b.name)??h},f=o!=null&&o.agent?e.perAgent.filter(h=>h.agentId===o.agent):e.perAgent,p=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:void 0],["Needs input",l===null?"–":String(l??e.runs.needsInput),"#/runs?status=input_required",l??e.runs.needsInput?"text-warning-text":void 0],["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,e.runs.needsReview?`${e.runs.needsReview} ${e.runs.needsReview===1?"needs":"need"} review`:void 0]];return s.jsx("div",{className:"h-full overflow-auto",children:s.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),i,s.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:p.map(([h,b,g,m,v])=>{const w=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"caps text-label text-muted-foreground",children:h}),s.jsx("p",{className:ie("mt-2 font-mono text-xl font-semibold",m),children:b}),v&&s.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:v})]});return s.jsx("li",{children:g?s.jsx("a",{href:g,className:"block h-full border p-4 hover:border-border-strong hover:bg-accent",children:w}):s.jsx("div",{className:"h-full border p-4",children:w})},h)})}),s.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:rz(e)}),o&&s.jsx(y1,{range:o.range,onRange:o.onRange,agent:o.agent,agents:e.perAgent,onAgent:o.onAgent})]}),s.jsx(v1,{a:e.analytics,basis:e.cost.basis,refreshing:o==null?void 0:o.refreshing})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[s.jsxs("section",{className:"border",children:[s.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Runs per agent"}),f.length?s.jsx("ul",{children:f.map(h=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("a",{href:Is(h.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[s.jsx("span",{className:"min-w-0 truncate",children:h.name}),s.jsx("span",{className:"font-mono text-body text-muted-foreground",children:h.runs})]})},h.agentId))}):s.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),s.jsxs("section",{className:"border",children:[s.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Recent runs"}),e.recent.length?s.jsx("ul",{children:e.recent.map(h=>s.jsx("li",{className:"border-b last:border-b-0",children:s.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[s.jsx(Gl,{run:h}),s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"min-w-0 truncate text-lead",children:tn(h)}),s.jsx(Id,{run:h,className:"hidden sm:inline-flex"}),KP(h)&&s.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),s.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:u(h.agent_id)}),h.ended_at&&s.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:Ga(Date.parse(h.ended_at)-Date.parse(h.created_at))}),h.cost&&(h.cost.usd!==null||ti(h.cost))&&s.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:so(h.cost,{ended:vl(h.status)})}),s.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:Rt(h.created_at)})]})},h.run_id))}):s.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}function rz(e,t=Date.now()){var l;const n=e.analytics.filter,o=n.from?Math.round((Math.floor(t/864e5)*864e5-Date.parse(n.from))/864e5)+1:null,i=n.from?Yh.some(c=>c.days===o)?`Runs started in the last ${o} days`:`Runs started since ${n.from.slice(0,10)}`:"All runs";return n.agent?`${i}, of ${((l=e.perAgent.find(c=>c.agentId===n.agent))==null?void 0:l.name)??n.agent}`:i}const Ds=e=>`#/runs/${encodeURIComponent(e)}`;function oz({asking:e,failed:t,live:n,learning:o=[],agentName:i,onAnswer:l,onApprove:c,onHandBack:u,onRunAgain:f,onStop:p,problem:h,now:b=Date.now}){const g=HP(t),[,m]=y.useState(0);y.useEffect(()=>{if(!n.length)return;const I=setInterval(()=>m(D=>D+1),1e3);return()=>clearInterval(I)},[n.length]);const[v,w]=y.useState([]),j=(I,D,z)=>{const H=e.find(U=>U.run_id===I),F=H?tn(H):I;w(U=>[...U.filter(X=>X.runId!==I),...z?[{runId:I,what:D,title:F,text:z}]:[]])},S=c&&(async(I,D,z,H)=>{const F=await c(I,D,z,H);return j(I,D,F),F}),T=u&&(async(I,D,z)=>{const H=await u(I,z);return j(I,`ask:${D.asked_at}`,H),H}),E=I=>{var z;const D=$a(I);return((z=I.pending)==null?void 0:z.kind)==="approval"?I.pending.id:D?`ask:${D.asked_at}`:null},_=g.reduce((I,D)=>I+D.runs.length,0),$=o.filter(I=>I.pending>0),R=$.reduce((I,D)=>I+D.pending,0),C=e.length+_+R;if(!C&&!n.length&&!h&&!v.length)return null;const O=b();return s.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[C>0&&s.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",s.jsxs("span",{className:"text-warning-text",children:["· ",C]})]}),h&&s.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:h}),v.filter(I=>!e.some(D=>D.run_id===I.runId&&E(D)===I.what)).map(I=>s.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:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("a",{href:Ds(I.runId),className:"underline-offset-4 hover:underline",children:I.title}),": your answer wasn't taken. ",I.text]}),s.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>w(D=>D.filter(z=>z.runId!==I.runId)),children:"Dismiss"})]},I.runId)),e.length>0&&s.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(I=>{var D,z,H;return((D=I.pending)==null?void 0:D.kind)==="approval"?s.jsx(az,{run:I,pending:I.pending,agentName:i(I.agent_id),at:O,onApprove:S},`${I.run_id}:${I.pending.id}`):$a(I)?s.jsx(iz,{run:I,ask:$a(I),agentName:i(I.agent_id),at:O,onHandBack:T},`${I.run_id}:${$a(I).asked_at}`):s.jsx(lz,{run:I,agentName:i(I.agent_id),at:O,onAnswer:l},`${I.run_id}:${((z=I.pending)==null?void 0:z.kind)==="question"?I.pending.asked_at:((H=I.pending)==null?void 0:H.kind)==="budget"?I.pending.at??"":""}`)})}),g.length>0&&s.jsxs("div",{className:"border",children:[s.jsxs("p",{className:"caps flex items-center justify-between border-b px-4 py-2.5 text-label text-muted-foreground",children:[s.jsxs("span",{children:["Failed · ",_]}),s.jsx("a",{href:"#/runs?status=failed",className:"normal-case tracking-normal hover:text-foreground",children:"All failed runs →"})]}),s.jsx("ul",{children:g.map(I=>s.jsx(dz,{message:I.message,runs:I.runs,agentName:i,at:O,onRunAgain:f},I.message))})]}),$.length>0&&s.jsxs("div",{className:"border",children:[s.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",R]}),s.jsx("ul",{children:$.map(I=>s.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[s.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),s.jsx("span",{className:"shrink-0 font-mono text-small",children:I.name}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:og(I.pending)}),s.jsx("a",{href:`#/agents/${encodeURIComponent(I.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},I.agent_id))})]}),n.length>0&&s.jsxs("div",{className:"border",children:[s.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",n.length]}),s.jsx("ul",{children:n.map(I=>s.jsx(fz,{run:I,agentName:i(I.agent_id),at:O,onStop:p},I.run_id))})]})]})}function az({run:e,pending:t,agentName:n,at:o,onApprove:i}){return s.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:s.jsx(wN,{compact:!0,pending:t,heading:s.jsx(Mg,{run:e,agentName:n,since:`asked ${Kl(t.requested_at,o)} ago`}),onAnswer:(l,c)=>i?i(e.run_id,t.id,l,c):Promise.resolve("Open the run to answer it.")})})}function iz({run:e,ask:t,agentName:n,at:o,onHandBack:i}){return s.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:s.jsx(EN,{compact:!0,ask:t,heading:s.jsx(Mg,{run:e,agentName:n,since:`asked ${Kl(t.asked_at,o)} ago`}),open:s.jsx("a",{href:Ds(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:i&&(l=>i(e.run_id,t,l))})})}function lz(e){var t;return((t=e.run.pending)==null?void 0:t.kind)==="budget"?s.jsx(cz,{run:e.run,pending:e.run.pending,agentName:e.agentName}):s.jsx(uz,{...e})}function cz({run:e,pending:t,agentName:n}){return s.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[s.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[s.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),s.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),s.jsx("a",{href:Ds(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:tn(e)})]}),s.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:kN(t)}),typeof t.said=="string"&&s.jsx("p",{className:"mt-1 text-prose leading-snug",children:t.said}),s.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:s.jsx("a",{href:Ds(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function Mg({run:e,agentName:t,since:n}){return s.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[s.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),s.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),s.jsx("a",{href:Ds(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:tn(e)}),n&&s.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:n})]})}function uz({run:e,agentName:t,at:n,onAnswer:o}){var j;const i=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,l=(i==null?void 0:i.question)??"",c=WP(l),[u,f]=y.useState(""),[p,h]=y.useState(!1),[b,g]=y.useState(null),[m,v]=y.useState(null),w=async S=>{S.preventDefault();const T=u.trim();if(!T||p)return;h(!0),g(null);const E=await o(e.run_id,T);h(!1),E?g(E):v(T)};return s.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[s.jsx(Mg,{run:e,agentName:t,since:i!=null&&i.asked_at?`asked ${Kl(i.asked_at,n)} ago`:void 0}),s.jsx("p",{className:"mt-2 text-base leading-snug",children:l}),m?s.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",m," · ",s.jsx("a",{href:Ds(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):s.jsxs("form",{onSubmit:S=>void w(S),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(S=>s.jsx("button",{type:"button",onClick:()=>f(S),className:ie("border px-3 py-1.5 text-body hover:border-border-strong",u===S?"border-warning text-warning-text":"border-border"),children:S},S)),s.jsx(He,{value:u,onChange:S=>f(S.target.value),"aria-label":`Answer ${t}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),s.jsx(Z,{type:"submit",variant:"solid",size:"sm",disabled:p||!u.trim(),children:p?"Sending…":"Send"}),b&&s.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}function dz({message:e,runs:t,agentName:n,at:o,onRunAgain:i}){const[l,c]=y.useState(!1),[u,f]=y.useState(null),[p,h]=y.useState(new Set),b=t.filter(S=>!p.has(S.run_id)),g=t.length-b.length,m=async()=>{c(!0),f(null);const{started:S,problem:T}=await i(b);c(!1),f(T),h(E=>new Set([...E,...S]))},v=g>0&&s.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",g===1?"1 run":`${g} runs`]});if(!b.length)return s.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:[s.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),s.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const w=b[0],j=b.length===1;return s.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:[s.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[j?s.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[s.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:n(w.agent_id)}),s.jsx("a",{href:Ds(w.run_id),className:"min-w-0 truncate hover:underline",children:tn(w)})]}):s.jsxs("p",{className:"text-lead",children:[b.length," runs failed ",s.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(b.map(S=>n(S.agent_id)))].join(", ")]})]}),s.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&s.jsxs("details",{className:"mt-1 text-body",children:[s.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),s.jsx("ul",{className:"mt-1 space-y-1",children:b.map(S=>s.jsxs("li",{children:[s.jsx("a",{href:Ds(S.run_id),className:"hover:underline",children:tn(S)})," ",s.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",n(S.agent_id)]})]},S.run_id))})]}),u&&s.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:u})]}),s.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[Kl(w.ended_at??w.created_at,o)," ago"]}),v,s.jsx(Z,{type:"button",size:"sm",disabled:l,onClick:()=>void m(),children:j?"Run again":"Run all again"})]})}function fz({run:e,agentName:t,at:n,onStop:o}){var h;const[i,l]=y.useState(!1),[c,u]=y.useState(null),f=(h=e.cost)==null?void 0:h.usd,p=f===0?"nothing spent yet":typeof f=="number"?`${so(e.cost)} so far`:ti(e.cost)?so(e.cost):"cost not known yet";return s.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:[s.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),s.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),s.jsx("a",{href:Ds(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:tn(e)}),s.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",Ga(n-Date.parse(e.created_at))]}),s.jsx("span",{className:"font-mono text-small text-muted-foreground",children:p}),s.jsx("a",{href:Ds(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),Bl(e.status,e.state,e.kind,Hl,!0,e.error,e.review).canStop?s.jsx(Z,{type:"button",size:"sm",disabled:i,onClick:async()=>{l(!0),u(await o(e.run_id)),l(!1)},children:"Stop"}):s.jsx("a",{href:Ds(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&s.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}function mz({keyCard:e=!1}){const t="font-mono text-small text-foreground";return s.jsxs("div",{className:"border bg-background p-5",children:[s.jsxs("p",{className:"flex items-center gap-2 text-base font-semibold",children:[s.jsx(Tl,{className:"size-4 text-primary-text","aria-hidden":!0}),"Add a model key"]}),s.jsx("p",{className:"mt-2 max-w-prose text-lead leading-relaxed text-muted-foreground",children:e?"Add a model key in the card above, and the templates here run in one click.":s.jsxs(s.Fragment,{children:["This server has no model to run an agent on yet. Start agentrun-serve with the model to run in its environment, ",s.jsx("span",{className:t,children:"AGENT_MODEL"}),"=provider/model-id, and that provider's key (",s.jsx("span",{className:t,children:"ANTHROPIC_API_KEY"}),", ",s.jsx("span",{className:t,children:"OPENAI_API_KEY"})," or ",s.jsx("span",{className:t,children:"OPENROUTER_API_KEY"}),"). Or name a gateway: ",s.jsx("span",{className:t,children:"AGENT_MODEL_BASE_URL"})," and ",s.jsx("span",{className:t,children:"AGENT_MODEL_API_KEY"}),", with the gateway's model in ",s.jsx("span",{className:t,children:"AGENT_MODEL"}),". Then reload this page, and the templates here run in one click."]})})]})}const pz=[{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 LN(e){var o;const t=["pi","claude-agent","codex"],n=e.filter(i=>i.available&&i.default_model);return n.sort((i,l)=>(t.indexOf(i.id)+1||99)-(t.indexOf(l.id)+1||99)),((o=n[0])==null?void 0:o.id)??null}function hz(e,t,n){const o=Gd(t,[...n]).filter(l=>l.available).map(l=>l.name),i=e.tools.find(l=>!o.includes(l));return i?{ok:!1,reason:`${i} can't run on this server yet`}:{ok:!0}}async function gz(e,t,n,o=Us()){const l=(await Xr(p=>e.listAgents({cursor:p}),p=>p.agents)).find(p=>p.definition.name===t.name&&!p.archived_at),c=(l==null?void 0:l.agent_id)??(await e.createAgent({definition:{version:1,name:t.name,description:t.description,instructions:t.instructions,harness:n,tools:t.tools,skills:[]}})).agent_id,u={input:{content:t.input}},{run:f}=await e.startRun(c,u,o.keyFor(t.name,u));return o.done(),f.run_id}const xz={hello:Ka,web:Jw,plan:Z2};function yz({harnesses:e,tools:t,onTry:n,imported:o=0,keyCard:i=!1}){const[l,c]=y.useState(null),[u,f]=y.useState(null),p=LN(e),h=async b=>{c(b.id),f(null);const g=await n(b);c(null),f(g)};return s.jsxs("section",{"aria-label":"Start here",className:"space-y-4",children:[s.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-6",children:[s.jsx("p",{className:"caps text-label text-primary-text",children:"Start here"}),s.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Watch an agent work in about ten seconds"}),s.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:p?"Pick one: it makes the agent, runs it, and opens the run as it happens.":"First a model to run on; then one click makes an agent, runs it, and opens the run as it happens."}),s.jsxs("div",{className:"mt-5",children:[p?s.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:pz.map(b=>{const g=hz(b,p,t),m=xz[b.id]??Ka;return s.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[s.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[s.jsx(m,{className:"size-4 text-primary-text","aria-hidden":!0}),b.name]}),s.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:b.shows}),s.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:b.description}),g.ok?s.jsx(Z,{type:"button",variant:b.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:l!==null,onClick:()=>void h(b),children:l===b.id?"Starting…":"Try it"}):s.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:g.reason})]},b.id)})}):s.jsx(mz,{keyCard:i}),u&&s.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:u})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border px-5 py-4",children:[s.jsxs("p",{className:"text-lead",children:["Or ",s.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."]}),o>0&&s.jsxs("p",{className:"text-lead text-muted-foreground",children:[o," imported sessions to read · ",s.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse them"})]})]})]})}const vz=(e,t)=>e instanceof Te?{status:e.status,ms:t,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:t,body:{error:{code:"network",message:String(e)}}};function bz({agents:e,revisions:t=[],efforts:n,origin:o,agentId:i,onAgent:l,onSend:c,onOpenRun:u,result:f=null,live:p,limits:h,upload:b=oj,removeUpload:g}){var We;const[m,v]=y.useState(i??((We=e[0])==null?void 0:We.agent_id)??"");y.useEffect(()=>{var fe;i&&i!==m&&e.some(Re=>Re.agent_id===i)?v(i):e.some(Re=>Re.agent_id===m)||v(((fe=e[0])==null?void 0:fe.agent_id)??"")},[e,i]);const w=e.find(fe=>fe.agent_id===m),j=(w==null?void 0:w.kind)??"agentic",[S,T]=y.useState(""),E=j==="workflow"?xj(w==null?void 0:w.definition.workflow):null,_=y.useRef("");y.useEffect(()=>{if(S.trim()&&S!==_.current)return;const fe=(E==null?void 0:E.text)??"";_.current=fe,T(fe)},[m,E==null?void 0:E.text]);const[$,R]=y.useState(""),[C,O]=y.useState(""),[I,D]=y.useState(""),[z,H]=y.useState("form"),[F,U]=y.useState(f?"response":"code"),[X,P]=y.useState("curl"),[K,M]=y.useState(!1),[G,B]=y.useState(f),L=y.useMemo(()=>{var Xe,Kt;const fe=G&&G.status>=400?(Xe=G.body)==null?void 0:Xe.error:void 0;if(!fe||typeof fe.message!="string")return;const Re=Array.isArray(fe.fields)?fe.fields.filter(De=>!!De&&typeof De.field=="string"&&typeof De.message=="string"&&De.message!==fe.message):[];return{message:fe.message,more:Re,box:typeof((Kt=fe.details)==null?void 0:Kt.box)=="string"?fe.details.box:void 0,details:fe.code==="agent_not_runnable"?fe.details:void 0}},[G]),[q,ne]=y.useState(!1),oe=y.useMemo(()=>Us(),[]),ae=aj({upload:b,remove:g,limits:h,frozen:q}),ce=hj(j,{text:S,revision:$,effort:C,maxCostUsd:I,fileIds:ae.fileIds}),le=ce.ok?ce.body:{input:j==="agentic"?{content:S}:S,...ae.fileIds.length?{file_ids:ae.fileIds}:{}},ye=m?oe.keyFor(m,le):"",ee=X==="curl"?PO(o,m,le,ye):`const res = await fetch(${JSON.stringify(`${o}/v2/agents/${m||"{agent_id}"}/runs`)}, {
541
+ method: "POST",
542
+ headers: {
543
+ Authorization: \`Bearer \${process.env.AGENTRUN_TOKEN}\`,
544
+ "Content-Type": "application/json",
545
+ "Idempotency-Key": ${JSON.stringify(ye)},
546
+ },
547
+ body: JSON.stringify(${JSON.stringify(le,null,2).replace(/\n/g,`
548
+ `)}),
549
+ });
550
+ console.log(res.status, await res.json());`,be=async()=>{if(!ce.ok||!c||ae.busy)return;ne(!0);const fe=await yj(oe,m,ce.body,c);ne(!1),B(fe),U("response"),M(!0),fe.status>=200&&fe.status<300&&ae.clear()},Oe=j==="agentic"?"The run's first message, e.g. Summarize the standup: we ship Friday.":'{ "subject": "...", "body": "..." }';return s.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.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:[e.length>0&&s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[s.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),s.jsx(qt,{id:"playground-agent",label:"Agent",placeholder:"Pick an agent",value:m,onChange:fe=>{v(fe),R(""),l==null||l(fe)},options:Cd(e).map(fe=>({value:fe.agent_id,label:fe.definition.name})),className:"w-56 max-w-[60vw]"})]}),s.jsxs("span",{className:"font-mono text-small",children:[s.jsx("span",{className:"text-primary-text",children:"POST"})," ",s.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",m||"{agent_id}","/runs"]})]}),s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"caps text-label text-muted-foreground",children:"Live API"}),s.jsx(Z,{type:"button",size:"xs",onClick:()=>M(fe=>!fe),"aria-expanded":K,className:"hidden text-muted-foreground hover:text-foreground short:inline-flex",children:K?"Hide code":"Show code"})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:[@media(min-height:501px)]:grid-cols-2",children:[s.jsx("section",{"aria-label":"Request",className:ie("flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",K&&"short:hidden"),children:e.length===0?s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:s.jsx("span",{className:"pb-1 text-lead font-semibold",children:"Request"})}),s.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[s.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-5",children:[s.jsx("p",{className:"caps text-label text-primary-text",children:"No agents yet"}),s.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Start a run"}),s.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Runs start from an agent. Make one, then send its first request here."}),s.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[s.jsx("a",{href:"#/agents/new",className:qa({variant:"solid",size:"lg"}),children:"Create an agent"}),s.jsx("a",{href:"#/templates",className:qa({variant:"outline",size:"lg"}),children:"Browse templates"})]})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"caps text-label text-muted-foreground",children:"What a request takes"}),s.jsx("dl",{className:"mt-3 divide-y border-y",children:Object.entries(ka).map(([fe,Re])=>s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 py-3",children:[s.jsx("dt",{className:"w-40 font-mono text-body",children:fe}),s.jsx("dd",{className:"text-small text-muted-foreground",children:Re})]},fe))})]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[s.jsx("span",{className:"text-lead font-semibold",children:"Request"}),s.jsx("span",{className:"flex gap-4 text-small",children:["form","json"].map(fe=>s.jsx("button",{type:"button",onClick:()=>H(fe),className:ie("border-b pb-1 capitalize",z===fe?"border-foreground":"border-transparent text-muted-foreground"),children:fe==="json"?"JSON":"Form"},fe))})]}),s.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),s.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[w?`${w.definition.name}: ${j==="agentic"?"an":"a"} ${j} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),z==="json"?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(le,null,2)}),s.jsx(ja,{name:"file_ids",note:ka.file_ids,children:s.jsx(Bp,{attachments:ae,limits:h})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(ja,{name:j==="agentic"?"input.content":"input",required:!0,error:!ce.ok&&ce.field==="input"&&S?ce.message:void 0,children:[s.jsx(Ns,{value:S,onChange:fe=>T(fe.target.value),rows:j==="agentic"?4:7,placeholder:Oe}),E&&s.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[gj(E,"start"),E.fields.length>0&&s.jsxs(s.Fragment,{children:[" Fields: ",E.fields.map((fe,Re)=>s.jsxs("span",{title:fe.note,children:[Re?", ":"",s.jsx("span",{className:"text-foreground",children:fe.name})]},fe.name)),"."]})]})]}),s.jsx(ja,{name:"file_ids",note:ka.file_ids,children:s.jsx(Bp,{attachments:ae,limits:h})}),s.jsx(ja,{name:"revision",note:ka.revision,children:s.jsx(qt,{label:"Revision",value:$,onChange:R,className:"w-full",options:[{value:"",label:"The current revision"},...t.map(fe=>({value:fe.revision,label:`rev ${fe.version}${fe.current?" (current)":""}${fe.note?`: ${fe.note}`:""}`}))]})}),s.jsx(ja,{name:"effort",note:ka.effort,children:s.jsx("div",{className:"flex gap-2",children:["",...n].map(fe=>s.jsx(Z,{type:"button",size:"sm","aria-pressed":C===fe,onClick:()=>O(fe),className:C===fe?"border-foreground hover:border-foreground":"text-muted-foreground",children:fe||"default"},fe||"default"))})}),j==="agentic"&&s.jsxs(ja,{name:"max_cost_usd",note:ka.max_cost_usd,error:!ce.ok&&ce.field==="max_cost_usd"?ce.message:void 0,children:[s.jsx(He,{value:I,onChange:fe=>D(fe.target.value),inputMode:"decimal",placeholder:"e.g. 0.50"}),s.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:s.jsx(Hj,{})})]})]})]}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[s.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),s.jsxs(Z,{variant:"primary",size:"lg",onClick:be,disabled:!ce.ok||!c||q||!m||ae.busy,title:ae.busy?"Waiting for the files to be sent":void 0,children:[s.jsx(Al,{"aria-hidden":!0})," ",q?"Sending":"Send request"]})]})]})}),s.jsxs("section",{"aria-label":"Code and response",className:ie("flex min-h-0 flex-col",!K&&"short:hidden"),children:[s.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[s.jsxs("span",{className:"flex gap-4 text-body",children:[s.jsx("button",{type:"button",onClick:()=>U("code"),className:ie("border-b pb-1",F==="code"?"border-foreground":"border-transparent text-muted-foreground"),children:"Code"}),s.jsxs("button",{type:"button",onClick:()=>U("response"),disabled:!G,className:ie("border-b pb-1 disabled:opacity-45",F==="response"?"border-foreground":"border-transparent text-muted-foreground"),children:["Response",G&&s.jsx("span",{className:ie("ml-2 font-mono",G.status<300?"text-success-text":"text-destructive-text"),children:G.status})]})]}),F==="code"&&s.jsx(Z,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var fe;return void((fe=navigator.clipboard)==null?void 0:fe.writeText(ee))},children:s.jsx(fd,{"aria-hidden":!0})})]}),F==="code"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex gap-5 border-b px-5 text-small md:px-6",children:["curl","fetch"].map(fe=>s.jsx("button",{type:"button",onClick:()=>P(fe),className:ie("-mb-px border-b-2 py-2.5",X===fe?"border-primary":"border-transparent text-muted-foreground"),children:fe==="curl"?"cURL":"JavaScript"},fe))}),s.jsx("pre",{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:ee}),s.jsx("footer",{className:"border-t px-5 py-3 text-small text-muted-foreground md:px-6",children:"The same request from your code: set AGENTRUN_TOKEN in your environment."})]}):G&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[s.jsx("span",{className:G.status<300?"text-success-text":"text-destructive-text",children:G.status})," ",s.jsxs("span",{className:"text-muted-foreground",children:[G.ms," ms"]})]}),L&&s.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: ",L.message,L.box?s.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",L.box,")"]}):null,s.jsx(fj,{agentId:m,details:L.details}),L.more.length>0&&s.jsx("span",{className:"mt-1 block",children:L.more.map(fe=>s.jsxs("span",{className:"block",children:[fe.field,": ",fe.message]},`${fe.field}:${fe.message}`))})]}),G.runId&&p?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b",children:p(G.runId)}),s.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[s.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),s.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(G.body,null,2)})]})]}):s.jsx("pre",{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(G.body,null,2)}),G.runId&&s.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(G.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",s.jsx(fh,{className:"size-4","aria-hidden":!0})]})]})]})]})]})}const ka={"input.content":"Required. The run's first message.",file_ids:"Empty names none.",revision:"Empty runs the current revision.",effort:"How hard the model thinks. Empty uses the agent's own.",max_cost_usd:"A spend cap in dollars; empty means none."};function ja({name:e,required:t,note:n,error:o,children:i}){return s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("span",{className:"font-mono text-body",children:e}),t&&s.jsx("span",{className:"text-label text-muted-foreground",children:"required"})]}),i,n&&s.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:n}),o&&s.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:o})]})}const IN=["queued","working","paused","input_required","completed","failed","cancelled"],wz={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function kz({runs:e,agentName:t,onOpen:n,error:o,onRetry:i,onMore:l,loadingMore:c,filter:u={},onFilter:f}){const p=!!u.archived;return s.jsxs("div",{className:"p-5 md:p-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[s.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:p?"Archived runs":"Runs"}),f&&s.jsxs(s.Fragment,{children:[s.jsx(qt,{label:"Runs in one state",value:u.status??"",onChange:h=>f({...u,status:h||void 0}),className:"h-11 w-48",options:[{value:"",label:"Any state"},...IN.map(h=>({value:h,label:wz[h]}))]}),s.jsxs(Z,{size:"lg",variant:p?"primary":"outline","aria-pressed":p,onClick:()=>f({...u,archived:!p}),children:[s.jsx($l,{"aria-hidden":!0})," Archived"]})]})]}),o&&!e?s.jsx(_n,{problem:o,onRetry:i,className:""}):e?e.length?s.jsx(Nz,{runs:e,agentName:t,onOpen:n}):u.status||p?s.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:u.status?"No run matches.":"No archived runs."}):s.jsx(jz,{}):s.jsx(Ss,{label:"Loading the runs"}),e&&o&&s.jsx(_n,{problem:o,className:"mt-4"}),e&&l&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(Z,{type:"button",onClick:l,disabled:c,size:"sm",children:c?"Loading":"Load more"})})]})}function jz(){return s.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[s.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),s.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),s.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."}),s.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[s.jsxs("a",{href:"#/playground",className:qa({variant:"solid",size:"lg"}),children:[s.jsx(Al,{"aria-hidden":!0})," Start a run"]}),s.jsx("a",{href:"#/templates",className:qa({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function Nz({runs:e,agentName:t,onOpen:n}){return s.jsxs("table",{className:"w-full border-collapse border text-body",children:[s.jsx("thead",{className:"hidden md:table-header-group",children:s.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(o=>s.jsx("th",{className:"border-b px-3 py-2 text-left font-normal",children:o},o))})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>n(o.run_id),children:[s.jsx("td",{className:"px-3 py-2.5 align-top",children:s.jsx(Gl,{run:o})}),s.jsxs("td",{className:"px-3 py-2.5 align-top",children:[s.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:i=>{i.stopPropagation(),n(o.run_id)},children:[s.jsx("span",{className:"line-clamp-2",children:tn(o)}),s.jsx(U2,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),o.status==="completed"&&o.review&&s.jsx("span",{className:"mt-1 block text-small text-warning-text",children:o.review.reason}),o.trigger&&s.jsx("span",{className:"mt-1 flex",children:s.jsx(Zj,{run:o})}),s.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[t(o.agent_id)," · ",Rt(o.created_at)]})]}),s.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:t(o.agent_id)}),s.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:o.kind}),s.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:Rt(o.created_at)}),s.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:so(o.cost,{ended:vl(o.status)})})]},o.run_id))})]})}const Sz=["system","light","dark"],lh="agentrun.theme",_z="(prefers-color-scheme: dark)",Qd=()=>{try{return globalThis.localStorage??null}catch{return null}},zN=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(_z):null;let ch=null;function Ez(e=Qd()){try{const t=e==null?void 0:e.getItem(lh);return t==="light"||t==="dark"?t:"system"}catch{return"system"}}const uh=(e=Qd())=>ch??Ez(e);function $z(e,t=Qd()){ch=null;try{e==="system"?t==null||t.removeItem(lh):t==null||t.setItem(lh,e)}catch{ch=e}}function dh(e,t=document.documentElement,n=zN()){const o=e==="dark"||e==="system"&&!!(n!=null&&n.matches);t.classList.toggle("dark",o),t.classList.toggle("light",!o)}function Tz(e=document.documentElement,t=zN(),n=Qd()){dh(uh(n),e,t);const o=()=>{uh(n)==="system"&&dh("system",e,t)};return t==null||t.addEventListener("change",o),()=>t==null?void 0:t.removeEventListener("change",o)}const Cz=[{id:"mission",label:"Mission Control",Icon:Q2},{id:"playground",label:"Playground",Icon:r0},{id:"agents",label:"Agents",Icon:mh},{id:"templates",label:"Templates",Icon:e0},{id:"runs",label:"Runs",Icon:gh},{id:"triggers",label:"Triggers",Icon:ud},{id:"settings",label:"Settings",Icon:n0}],Rz={system:["System",Cl],light:["Light",p_],dark:["Dark",o_]};function Az(){const[e,t]=y.useState(()=>uh()),n=o=>{$z(o),dh(o),t(o)};return s.jsx("div",{role:"group","aria-label":"Theme",className:"flex border",children:Sz.map(o=>{const[i,l]=Rz[o];return s.jsx("button",{type:"button","aria-label":i,title:i,"aria-pressed":e===o,onClick:()=>n(o),className:ie("flex flex-1 items-center justify-center py-2 hover:bg-accent",e===o&&"bg-primary/[0.06] text-primary-text"),children:s.jsx(l,{className:"size-4","aria-hidden":!0})},o)})})}function Fw(){return s.jsxs("span",{className:"whitespace-nowrap font-mono text-figure font-semibold","aria-label":"AgentRun",children:["agent",s.jsx("span",{className:"text-primary-text",children:".run()"})]})}function Oz({active:e,settings:t=!1,triggers:n=!1,onNavigate:o,onSignOut:i,onSignOutEverywhere:l,banners:c,children:u}){const[f,p]=y.useState(!1),[h,b]=y.useState(!1),g=y.useRef(null),m=y.useRef(null),v=y.useRef(!1);y.useEffect(()=>{var j,S;h?(j=m.current)==null||j.focus():v.current&&((S=g.current)==null||S.focus())},[h]);const w=()=>{v.current=!0,b(!1)};return s.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground md:flex-row",children:[s.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b px-4 py-3 md:hidden",children:[s.jsx(Fw,{}),s.jsx(Z,{size:"icon",className:"size-9 [&_svg]:size-[18px]","aria-label":"Navigation","aria-expanded":f,onClick:()=>p(j=>!j),children:s.jsx(n_,{"aria-hidden":!0})})]}),s.jsxs("aside",{className:ie("shrink-0 flex-col border-r bg-background px-3 pb-4 pt-6 md:flex md:h-dvh md:w-sidebar md:overflow-y-auto",f?"flex max-h-[60dvh] overflow-y-auto border-b md:max-h-none":"hidden"),children:[s.jsx("div",{className:"hidden px-3 pb-[30px] md:block",children:s.jsx(Fw,{})}),s.jsx("nav",{"aria-label":"Navigation",className:"flex flex-col gap-1",children:Cz.filter(j=>(j.id!=="settings"||t)&&(j.id!=="triggers"||n)).map(({id:j,label:S,Icon:T})=>s.jsx(N4,{icon:T,active:e===j,onClick:()=>{o==null||o(j),p(!1)},children:S},j))}),s.jsx("div",{className:"mt-4 md:mt-auto",children:s.jsx(Az,{})}),s.jsxs(Z,{type:"button",onClick:i,className:"mt-2 justify-start gap-2.5 px-3",children:[s.jsx(e_,{"aria-hidden":!0})," Sign out"]}),l&&(h?s.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:j=>{j.key==="Escape"&&w()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[s.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(Z,{type:"button",variant:"destructive",size:"xs",onClick:()=>{b(!1),l()},children:"Sign out everywhere"}),s.jsx(Z,{type:"button",ref:m,onClick:w,size:"xs",children:"Cancel"})]})]}):s.jsx("button",{type:"button",ref:g,onClick:()=>b(!0),className:"mt-1 px-3 py-1.5 text-left text-small text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(dM,{}),c,s.jsx("main",{className:"relative min-h-0 min-w-0 flex-1 overflow-auto",children:u})]})]})}const pp={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},Uw={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 once, and the token leaves the address."}};function Pz({mode:e,code:t=null,codeNeeded:n=!1,onSubmit:o,problem:i=null,offer:l=null}){const[c,u]=y.useState(""),[f,p]=y.useState(!1),[h,b]=y.useState(""),[g,m]=y.useState(t??"");y.useEffect(()=>{t!==null&&m(t)},[t]);const[v,w]=y.useState(i),[j,S]=y.useState(!1),T=e==="setup",E=T&&l!==null&&!("sessions"in l&&l.sessions===0),_=T&&(n||t!==null),$=e!=="token_link"&&c.length>0&&(!T||c===h&&c.length>=12)&&(!_||g.trim()!==""),R=async()=>{if(!$||!o)return;S(!0);const C=await o(c,_&&g.trim()?g.trim():void 0,T&&E&&f);S(!1),w(C)};return s.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:s.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[s.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[s.jsx(Fs,{className:"size-5 text-primary-text","aria-hidden":!0}),s.jsxs("span",{children:["agent",s.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),s.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:Uw[e].title}),s.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:Uw[e].body}),e!=="token_link"&&s.jsxs("form",{className:"space-y-5",onSubmit:C=>{C.preventDefault(),R()},children:[_&&s.jsx(Ao,{label:"Setup code",id:"setup-code",hint:"On Render: paste the server's AGENTRUN_TOKEN from the service's Environment tab. Elsewhere: paste the setup code the server printed in its log, or open the link it prints.",children:s.jsx(He,{name:"setup-code",value:g,onChange:C=>m(C.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),s.jsx(Ao,{label:pp[e].label,hint:T?"12 characters or more.":void 0,children:s.jsxs("span",{className:ie("flex items-center gap-3 px-3",Xk),children:[s.jsx(Tl,{className:"size-4 text-muted-foreground","aria-hidden":!0}),s.jsx(He,{bare:!0,type:"password",value:c,onChange:C=>u(C.target.value),autoComplete:pp[e].autocomplete,autoFocus:!0,"aria-label":pp[e].label,className:"h-control-md flex-1 text-lead"})]})}),T&&s.jsx(Ao,{label:"Again",hint:h&&h!==c?"The two passwords differ.":void 0,children:s.jsx(He,{type:"password",value:h,onChange:C=>b(C.target.value),autoComplete:"new-password","aria-label":"Password again",className:"text-lead"})}),E&&s.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[s.jsx("input",{type:"checkbox",name:"import",checked:f,onChange:C=>p(C.target.checked),className:"mt-1 size-4 accent-primary"}),s.jsxs("span",{children:[s.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),s.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:Mz(l)})]})]}),s.jsx(Z,{type:"submit",variant:"solid",disabled:!$||j,"aria-busy":j||void 0,className:"w-full text-body",children:j?"Signing in":T?"Set password and continue":"Continue"}),v&&s.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:v}),!T&&s.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",s.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",s.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",s.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",s.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const Ww=(e,t)=>`${e.toLocaleString("en-US")} ${t}${e===1?"":"s"}`,hp="Each project becomes an agent, each session a run you can read.";function Mz(e){return"counting"in e?`Counting sessions… ${hp}`:e.sessions===null||e.projects===null?`The count isn't known. ${hp}`:`${Ww(e.sessions,"session")} in ${Ww(e.projects,"project")}. ${hp}`}function Lz({problem:e,starting:t=!1,onRetry:n}){return s.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:s.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[s.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[s.jsx(Fs,{className:"size-5 text-primary-text","aria-hidden":!0}),s.jsxs("span",{children:["agent",s.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),s.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:t?"This server is starting":"Can't read this server's sign-in"}),s.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:t?"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."}),s.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),s.jsx(Z,{type:"button",variant:"solid",onClick:n,className:"w-full text-body",children:"Retry now"})]})})}const DN=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.accounts)===!1};function Iz(e,t){if(DN(e))return t===200?"signed_in":"token_link";const n=e.body??{};return n.signed_in?"signed_in":n.password_set?"sign_in":"setup"}const zz=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.setup_code)===!0};function Dz(e){var t,n;if(e.status===401)return"That is not the password.";if(e.status===429){const o=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Too many sign-ins. Try again in ${o===1?"a second":o>=60?"a minute":`${o} seconds`}.`}return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired or was voided after too many wrong tries: a new one is in the server's log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here.":((n=(t=e.fields)==null?void 0:t[0])==null?void 0:n.message)??e.message}function FN(e){const t=new URLSearchParams(e.startsWith("#")?e.slice(1):e),n=t.get("code");if(n===null)return{code:null,rest:e};t.delete("code");const o=t.toString();return{code:/^[A-Za-z0-9_-]*/.exec(n)[0],rest:o?`#${o}`:""}}const Fz=1e4;function Hw(e=location.hash){let t=e.match(/^#\/runs\/([^/?]+)$/);if(t)return{section:"runs",run:decodeURIComponent(t[1])};if(e==="#/agents/new")return{section:"agents",agent:null};if(t=e.match(/^#\/agents\/([^/?]+)\/learning\?(.*)$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),tab:"learning",notes:new URLSearchParams(t[2]).getAll("note")};if(t=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),t){const l=new URLSearchParams(t[2]).get("tool");return{section:"agents",agent:decodeURIComponent(t[1]),edit:!0,...l?{tool:l}:{}}}if(t=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),...t[2]==="edit"?{edit:!0}:t[2]?{tab:t[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground"))return{section:"playground"};if(t=e.match(/^#\/templates\/([^/?]+)$/),t)return{section:"templates",template:decodeURIComponent(t[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(t=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),t)return{section:"triggers",trigger:decodeURIComponent(t[1]),...t[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(t=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),t)return{section:"settings",settings:"mcp",signIn:oO(t[1])};if(t=e.match(/^#\/settings\/github(?:\?(.*))?$/),t){const l=gM(t[1]);return{section:"settings",settings:"github",...l?{github:l}:{}}}if(t=e.match(/^#\/settings(?:\/(keys|tools|computers|workspace|webhook))?$/),t)return{section:"settings",settings:t[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const n=new URLSearchParams(e.slice(7)),o=n.get("agent"),i=n.get("status");return{section:"runs",...o?{runsOf:o}:{},...i&&IN.includes(i)?{status:i}:{},...n.get("archived")==="true"?{archived:!0}:{}}}function Uz({runsOf:e,status:t,archived:n}){const o=new URLSearchParams;return e&&o.set("agent",e),t&&o.set("status",t),n&&o.set("archived","true"),`#/runs${o.size?`?${o}`:""}`}let gp;function Wz(){if(!gp){const{code:e,rest:t}=FN(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${t}`),gp={code:e}}return gp.code}const Hz=e=>Math.min(1e3*2**e,3e4),UN=1e3,Bz=30;function Gz(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function qz(){const[e]=y.useState(nP),[t,n]=y.useState(null),[o,i]=y.useState(!1),l=y.useRef(null);l.current=t;const c=y.useRef(!1),u=y.useRef(async()=>{}),f=y.useMemo(()=>n4({fetch:e.fetch,onSignedOut:()=>void u.current()}),[e]),[p,h]=y.useState(Wz);y.useEffect(()=>{if(t!=="setup")return;const R=()=>{const{code:C,rest:O}=FN(location.hash);C!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${O}`),h(C))};return window.addEventListener("hashchange",R),R(),()=>window.removeEventListener("hashchange",R)},[t]);const[b,g]=y.useState(!1),m=async()=>{const R=await f.session(),C=DN(R)?await f.listAgents().then(()=>200,O=>O instanceof Te?O.status:0):void 0;return{mode:Iz(R,C),codeNeeded:zz(R)}},v=async()=>{const R=await m();return g(R.codeNeeded),R.mode},w=async()=>n(await v());u.current=async()=>{if(!(l.current!=="signed_in"||c.current)){c.current=!0;try{const R=await v();R!=="signed_in"&&l.current==="signed_in"&&(i(!0),n(R))}catch{}finally{c.current=!1}}};const[j,S]=y.useState(null),[T,E]=y.useState(0);y.useEffect(()=>{let R=!0,C;return m().then(O=>{!R||l.current!==null||(g(O.codeNeeded),n(O.mode),S(null))},O=>{if(!R||l.current!==null)return;const I=Hz(T),D=O instanceof Te?O:null,z=(D==null?void 0:D.code)==="http_error",H=z&&[502,503,504].includes(D.status);S({problem:D===null?jn(O):H?`Its address answered ${D.status}, not the server.`:`GET /v2/auth/session answered ${D.status}${z?", not as this server answers":`: ${D.message}`}`,starting:H}),C=setTimeout(()=>E(F=>F+1),I)}),()=>{R=!1,clearTimeout(C)}},[f,T]);const[_,$]=y.useState(null);return y.useEffect(()=>{if(t!=="setup")return;let R=!0;return(async()=>{for(let C=!1;R;){const O=await f.setupImport().then(I=>I,()=>{});if(!R)return;if(O===void 0&&C)return void $({projects:null,sessions:null});if(O!==void 0&&(!O||!("counting"in O||"sessions"in O)||($(O),C=!0,!("counting"in O))))return;await new Promise(I=>setTimeout(I,UN))}})(),()=>{R=!1}},[f,t]),t===null&&j!==null?s.jsx(Lz,{problem:j.problem,starting:j.starting,onRetry:()=>E(R=>R+1)}):t===null?s.jsx(hw,{connection:e,children:s.jsx(Vz,{})}):t!=="signed_in"?s.jsx(Pz,{mode:t,code:p,codeNeeded:b,offer:_,problem:o&&t==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(R,C,O)=>{try{return await(t==="setup"?f.setup(R,C,O):f.signIn(R)),i(!1),n("signed_in"),null}catch(I){return I instanceof Te&&I.status===403&&t==="setup"&&await w().catch(()=>{}),I instanceof Te?Dz(I):I instanceof Error?I.message:String(I)}}},t):s.jsx(hw,{connection:e,children:s.jsx(Kz,{v2:f,onSignedOut:()=>{i(!1),n("sign_in")}})})}function Vz(){return kg().state==="offline"?s.jsx(fM,{}):s.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function Kz({v2:e,onSignedOut:t}){var Xo,Ae,Y,pe,Ne,it,Et,Be,It,Qt,Es,vt,co,Nr,uo,qn,Ql,On,Zl,Jl;const{writable:n,whyNot:o}=sM(e),[i,l]=y.useState(null),[c,u]=y.useState(()=>Hw()),[f,p]=y.useState(null),h=((Ae=(Xo=f==null?void 0:f.features)==null?void 0:Xo.triggers)==null?void 0:Ae.routes)===!0,[b,g]=y.useState(new Map);y.useEffect(()=>{if(!h)return;let he=!0;return e.listTriggers().then(xe=>{he&&g(new Map(xe.triggers.map(Ee=>[Ee.id,{name:Ee.name,kind:Ee.source.kind}])))},()=>{}),()=>{he=!1}},[e,h,c.section,c.trigger]);const[m,v]=y.useState(null),[w,j]=y.useState(null),[S,T]=y.useState(0),[E,_]=y.useState("30d"),[$,R]=y.useState(null),[C,O]=y.useState(!1),[I,D]=y.useState(null),[z,H]=y.useState(null),[F,U]=y.useState(null),[X,P]=y.useState(0),[K,M]=y.useState(!1),[G,B]=y.useState(null),[L,q]=y.useState(null),[ne,oe]=y.useState(!1),[ae,ce]=y.useState({}),[le,ye]=y.useState(!1),ee=y.useRef(0),[be,Oe]=y.useState([]),We=y.useRef(-1),[fe,Re]=y.useState(null),[Xe,Kt]=y.useState(0),De=y.useRef(0),et=he=>{hu(he)||(location.hash=he)},[Ut,Wt]=y.useState(null),[jt,ss]=y.useState(0);y.useEffect(()=>{let he=!0;return(async()=>{let xe=!1;for(let Ee=0;he&&Ee<Bz;){const Qe=await e.setupImport().then(qe=>qe,()=>{});if(!he)return;if(Qe===void 0)Ee+=1;else{if(Ee=0,!Qe||!("state"in Qe))return;if(Wt(Qe),Qe.state!=="running")return void(xe&&ss(qe=>qe+1));xe=!0}await new Promise(qe=>setTimeout(qe,UN))}})(),()=>{he=!1}},[e]),y.useEffect(()=>{const he=()=>{const xe=aI();hu(location.hash,()=>{xe&&history.go(-xe)})?xe&&history.go(xe):u(Hw())};return window.addEventListener("hashchange",he),()=>window.removeEventListener("hashchange",he)},[]),y.useEffect(()=>oI(),[]);const hn=y.useRef(0),Xt=y.useRef(!1),at=()=>{const he=++hn.current;return e.capabilities().then(xe=>(he===hn.current&&p(xe),!0),()=>!1)};y.useEffect(()=>{at()},[e]),y.useEffect(()=>{if(ee.current&&c.section!=="runs"&&c.section!=="mission"&&We.current===jt)return;We.current=jt;const he=++ee.current;ye(!1),Promise.allSettled([!1,!0].map(xe=>Xr(Ee=>e.listAgents({archived:xe,cursor:Ee}),Ee=>Ee.agents))).then(xe=>{if(he!==ee.current)return;const Ee=Object.fromEntries(xe.flatMap(qe=>qe.status==="fulfilled"?qe.value:[]).map(qe=>[qe.agent_id,qe.definition.name??qe.agent_id])),Qe=xe.every(qe=>qe.status==="fulfilled");ce(qe=>Qe?Ee:{...qe,...Ee}),ye(Qe)})},[e,c,jt]);const ct={status:c.status,archived:c.archived};y.useEffect(()=>{if(c.section!=="runs"||c.run)return;const he=++De.current;B(null),Re(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,ct):e.listRuns(50,null,ct)).then(xe=>{he===De.current&&(B(xe.runs),q(xe.next_cursor))}).catch(xe=>{he===De.current&&Re(fn(xe,"the runs"))})},[e,c,jt,Xe]);const Me=he=>{var xe;return ae[he]??((xe=Tn==null?void 0:Tn.find(Ee=>Ee.agent_id===he))==null?void 0:xe.definition.name)??(le?he:"")},Le=f,At=(f==null?void 0:f.models.ready)===!1&&f.models.needs!=="model"&&!f.models.default&&f.models.source!=="gateway"&&!!((pe=(Y=f.features)==null?void 0:Y.tool_keys)!=null&&pe.routes),ut={harnesses:(Le==null?void 0:Le.harnesses)??[],tools:E5(Le==null?void 0:Le.tools),thinking:((Ne=Le==null?void 0:Le.features)==null?void 0:Ne.thinking)??[]},Lt=bO(Le==null?void 0:Le.tools),En=kO(Le==null?void 0:Le.tools),$n=[...(Et=(it=f==null?void 0:f.features)==null?void 0:it.tool_keys)!=null&&Et.routes?["keys"]:[],...Lt.length||En.length?["tools"]:[],"mcp","github","computers","workspace",...(It=(Be=f==null?void 0:f.features)==null?void 0:Be.webhooks)!=null&&It.routes?["webhook"]:[]],Yt=he=>et({runs:"#/runs",agents:"#/agents",playground:"#/playground",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${$n[0]??"keys"}`}[he]),Wn=y.useRef(Us()).current,rs=async he=>{const xe=LN(ut.harnesses);if(!xe)return"This server has no model to run it on yet.";try{const Ee=await gz(e,he,xe,Wn);return et(`#/runs/${encodeURIComponent(Ee)}`),null}catch(Ee){return jn(Ee)}},os=((m==null?void 0:m.analytics.by_source)??[]).filter(he=>he.source!=="live").reduce((he,xe)=>he+xe.runs,0),[Tn,Hn]=y.useState(null),[Bn,J]=y.useState([]),[we,Ge]=y.useState(null),[dt,Ke]=y.useState(null),[Nt,nn]=y.useState(0),yt=y.useRef(0);y.useEffect(()=>{if(c.section!=="playground")return;Ke(null);const he=++yt.current;Xr(xe=>e.listAgents({cursor:xe}),xe=>xe.agents).then(xe=>{if(he!==yt.current)return;Hn(xe);const Ee=xe.filter(Qe=>!Qe.archived_at);Ge(Qe=>{var qe;return Qe&&Ee.some(Ot=>Ot.agent_id===Qe)?Qe:((qe=Ee[0])==null?void 0:qe.agent_id)??null})}).catch(xe=>{if(he===yt.current){const Ee=fn(xe,"the agents");Ke(`${Ee.why} ${Ee.next}${Ee.said?` (${Ee.said})`:""}`)}})},[e,c.section,Nt,jt]),y.useEffect(()=>{if(c.section!=="mission")return;let he=!0;j(null),O(!0);const xe=Qh(E);return Promise.all([e.statsOver({...xe?{from:xe}:{},...$?{agent:$}:{}}),$?e.listAgentRuns($,10):e.listRuns(10)]).then(([Ee,Qe])=>{he&&(v(V3(Ee,Qe.runs)),$||U(qe=>qe||BP(Qe.runs,Ee.analytics.by_source)))}).catch(Ee=>{he&&j(fn(Ee,"Mission Control"))}).finally(()=>{he&&O(!1)}),()=>{he=!1}},[e,c.section,S,E,$,jt]),Xj(()=>T(he=>he+1)),y.useEffect(()=>{if(c.section!=="mission")return;let he=!0;const xe=Ot=>Xr(rn=>e.listRuns(50,rn,{status:Ot}),rn=>rn.runs,2),Ee=()=>Xr(Ot=>e.listAgents({archived:!1,cursor:Ot}),Ot=>Ot.agents).then(Ot=>{he&&Oe(Ot.filter(rn=>Vu(rn)>0).map(rn=>({agent_id:rn.agent_id,name:rn.definition.name??rn.agent_id,pending:Vu(rn)})))},()=>{}),qe=VP(()=>Promise.allSettled([xe("input_required"),xe("failed"),xe("working"),Ee()]).then(([Ot,rn,oi])=>{var Sr;if(!he)return;const Yo=[Ot,rn,oi],ai=Date.now()-864e5;H(dw(null,Yo).problem),((Sr=Yo[0])==null?void 0:Sr.status)==="fulfilled"&&M(!0),D(Zd=>{const{needs:fo}=dw(Zd,Yo);return{asking:fo.asking.filter(Gj),failed:fo.failed.filter(nt=>Date.parse(nt.ended_at??nt.created_at)>ai),live:fo.live}})}),1e4);return()=>{he=!1,qe()}},[e,c.section,X]);const Ws=y.useRef(AO()).current,sn=()=>setTimeout(()=>P(he=>he+1),2500),_s=async(he,xe)=>{try{return await mj(Ws(he),he,xe,e.sendMessage),sn(),null}catch(Ee){return jn(Ee)}},Cn=y.useRef(new Map).current,Rn=async he=>{const xe=[];try{for(const Ee of he){const Qe=Ee.kind==="workflow"?void 0:(await e.getTimeline(Ee.run_id)).rows.find(rn=>rn.kind==="user_message"),qe=qP(Ee,Qe==null?void 0:Qe.text);if("refusal"in qe)throw new Error(qe.refusal);const Ot=Cn.get(Ee.run_id)??zd();Cn.set(Ee.run_id,Ot),await e.startRun(Ee.agent_id,qe.body,Ot),xe.push(Ee.run_id)}return sn(),{started:xe,problem:null}}catch(Ee){return xe.length&&sn(),{started:xe,problem:jn(Ee)}}},as=async he=>{try{return await e.stop(he),sn(),null}catch(xe){return jn(xe)}},sr=async(he,xe,Ee,Qe)=>{let qe=null;try{await e.answerApproval(he,xe,Ee,Qe)}catch(Ot){qe=bN(Ot)}return P(Ot=>Ot+1),qe},rr=async(he,xe)=>{let Ee=null;try{await e.handBackComputer(he,xe)}catch(Qe){Ee=ah(Qe,"hand")}return P(Qe=>Qe+1),Ee},Hs=y.useRef(0);y.useEffect(()=>{const he=++Hs.current;J([]),we&&Xr(xe=>e.listRevisions(we,xe),xe=>xe.revisions).then(xe=>{he===Hs.current&&J(xe)}).catch(()=>{})},[e,we]);const Ko=async(he,xe,Ee)=>{const Qe=performance.now();try{const qe=await e.startRun(he,xe,Ee);return{status:qe.status,ms:Math.round(performance.now()-Qe),body:qe.run,runId:qe.run.run_id}}catch(qe){return vz(qe,Math.round(performance.now()-Qe))}},An=((Qt=f==null?void 0:f.features)==null?void 0:Qt.efforts)??[],lo=f?((Es=f.features)==null?void 0:Es.learning)??null:void 0;ut.learning=lo??void 0;const Gn=f==null?void 0:f.models.ready,or=y5(cp(f)),jr=!!or;return y.useEffect(()=>{if(Gn!==!1&&!jr)return;const he=()=>{Xt.current||(Xt.current=!0,at().finally(()=>{Xt.current=!1}))},xe=()=>at(),Ee=setInterval(he,Fz);return window.addEventListener("focus",xe),()=>{clearInterval(Ee),window.removeEventListener("focus",xe)}},[e,Gn,jr]),s.jsx(Qj.Provider,{value:b,children:s.jsx(Oz,{active:c.section,settings:$n.length>0,triggers:h,onNavigate:Yt,onSignOut:()=>{const he=()=>void e.signOut().then(t,xe=>l(xe instanceof Te?xe.message:"The sign-out did not reach the server. Try again."));hu(null,he)||he()},onSignOutEverywhere:()=>{const he=()=>void e.signOutEverywhere().then(t,xe=>l(xe instanceof Te?xe.message:"The sign-out did not reach the server. Try again."));hu(null,he)||he()},banners:s.jsxs(s.Fragment,{children:[i&&s.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: ",i]}),Ut&&s.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:[s.jsx("span",{className:"flex-1",children:Gz(Ut)}),Ut.state!=="running"&&s.jsx(Z,{type:"button",size:"xs",onClick:()=>Wt(null),children:"Dismiss"})]}),(f==null?void 0:f.models.ready)===!1&&c.section!=="mission"&&s.jsx(CM,{needs:f.models.needs,source:f.models.source,model:f.models.default,settings:((co=(vt=f.features)==null?void 0:vt.tool_keys)==null?void 0:co.routes)===!0})]}),children:c.section==="playground"&&dt?s.jsx(ts,{tone:"error",className:"m-8",actions:s.jsx(Z,{type:"button",size:"xs",onClick:()=>nn(he=>he+1),children:"Try again"}),children:s.jsxs("p",{className:"font-mono",children:["The agents could not be read: ",dt]})}):c.section==="settings"?s.jsx(pM,{active:c.settings??"keys",offered:$n,children:c.settings==="tools"?s.jsx(hM,{v2:e,choices:Lt,gates:En,harnesses:ut.harnesses,onSaved:at,onOpen:at}):c.settings==="mcp"?s.jsx(jM,{v2:e,signIn:c.signIn,writable:n,whyNot:o}):c.settings==="github"?s.jsx(bM,{v2:e,returned:c.github}):c.settings==="computers"?s.jsx(IM,{v2:e,writable:n,whyNot:o}):c.settings==="workspace"?s.jsx(BM,{v2:e,writable:n,whyNot:o}):c.settings==="webhook"?s.jsx(OM,{v2:e}):s.jsx(iM,{v2:e,onChange:at,writable:n,whyNot:o})}):c.section==="mission"?s.jsxs("div",{className:"flex h-full flex-col",children:[(f==null?void 0:f.models.ready)===!1&&s.jsx(TM,{v2:e,needs:f.models.needs,model:f.models.default,onSaved:at,writable:n,whyNot:o}),or&&s.jsx(RM,{box:or}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(sz,{view:m,error:w,onRetry:()=>T(he=>he+1),scope:{range:E,onRange:_,agent:$,onAgent:R,refreshing:C&&m!==null},asking:I&&K?I.asking.length:null,needsYou:I&&s.jsx(oz,{asking:I.asking,failed:I.failed,live:I.live,learning:be,problem:z,agentName:Me,onAnswer:_s,onApprove:sr,onHandBack:rr,onRunAgain:Rn,onStop:as}),startHere:F===!1?s.jsx(yz,{harnesses:ut.harnesses,tools:ut.tools,onTry:rs,imported:os,keyCard:At}):void 0})})]}):c.section==="templates"?s.jsx(BL,{v2:e,name:c.template,go:et},c.template??""):c.section==="triggers"?s.jsx(NL,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:et,agentName:Me,minEvery:(uo=(Nr=f==null?void 0:f.features)==null?void 0:Nr.triggers)==null?void 0:uo.min_every_s}):c.section==="playground"?Tn&&s.jsx(bz,{agents:Tn.filter(he=>!he.archived_at),revisions:Bn,efforts:An,origin:location.origin,agentId:we??void 0,onAgent:Ge,onSend:Ko,limits:f==null?void 0:f.limits,removeUpload:e.deleteUpload,onOpenRun:he=>et(`#/runs/${encodeURIComponent(he)}`),live:he=>s.jsx(Dw,{v2:e,runId:he,caps:f,agentName:Me},he)}):c.section==="agents"?c.agent===void 0?s.jsx(PP,{v2:e,archived:!!c.archived,go:et},jt):c.agent!==null&&!c.edit?s.jsx(aP,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:lo,routePrefix:(qn=Le==null?void 0:Le.models)==null?void 0:qn.route_prefix,harnesses:ut.harnesses,efforts:An,limits:f==null?void 0:f.limits,places:cp(f),go:et},c.agent):s.jsx(MP,{v2:e,choices:Lt,gates:En,focusTool:c.tool,caps:{...ut,routePrefix:(Ql=Le==null?void 0:Le.models)==null?void 0:Ql.route_prefix,decisionProvider:N5(f==null?void 0:f.workflows),places:cp(f),mcp:!!((On=f==null?void 0:f.features)!=null&&On.mcp_client),mcpHarnesses:(Jl=(Zl=f==null?void 0:f.features)==null?void 0:Zl.mcp_client)==null?void 0:Jl.harnesses},agentId:c.agent,go:et},`${c.agent??"new"}:${c.tool??""}`):c.run?s.jsx(Dw,{v2:e,runId:c.run,caps:f,agentName:Me},c.run):s.jsx(kz,{runs:G,agentName:Me,error:fe,onRetry:()=>Kt(he=>he+1),onOpen:he=>et(`#/runs/${encodeURIComponent(he)}`),loadingMore:ne,filter:ct,onFilter:he=>et(Uz({runsOf:c.runsOf,...he})),onMore:L?()=>{const he=De.current;oe(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,L,ct):e.listRuns(50,L,ct)).then(xe=>{he===De.current&&(B(Ee=>pj(Ee??[],xe.runs)),q(xe.next_cursor),Re(null))}).catch(xe=>Re(fn(xe,"more runs"))).finally(()=>oe(!1))}:void 0})})})}Tz();C2.createRoot(document.getElementById("root")).render(s.jsx(y.StrictMode,{children:s.jsx(A4,{children:s.jsx(qz,{})})}));