@vostride/agent-qa-dashboard-ui 0.1.13 → 0.1.14

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 (94) hide show
  1. package/dist/assets/{arrow-up-down-DD6yziGv.js → arrow-up-down-D_ErIdrE.js} +1 -1
  2. package/dist/assets/{badge-CC1v3nk4.js → badge-ClWCtaXi.js} +1 -1
  3. package/dist/assets/{batch-action-bar-D1IfTx55.js → batch-action-bar-BoqzHfwU.js} +1 -1
  4. package/dist/assets/{circle-alert-CULfrrqE.js → circle-alert-D7wbtVU2.js} +1 -1
  5. package/dist/assets/{circle-x-B7AOkLOS.js → circle-x-BOV-jCVR.js} +1 -1
  6. package/dist/assets/config-BH2rUSDL.js +10 -0
  7. package/dist/assets/{copy-CEZJVgtu.js → copy-DW4nc-pA.js} +1 -1
  8. package/dist/assets/{display-step-CO4k5dQA.js → display-step-vpHdm2LX.js} +1 -1
  9. package/dist/assets/{dist-DzF0KPMF.js → dist-BABsMbMt.js} +1 -1
  10. package/dist/assets/dist-Bc4r79ls.js +1 -0
  11. package/dist/assets/{dist-wK15YRiu.js → dist-BsGrTrYb.js} +1 -1
  12. package/dist/assets/{empty-state-BfgY0UGA.js → empty-state-BTFWlITi.js} +1 -1
  13. package/dist/assets/{external-link-DC-KkLmq.js → external-link-CnabSkqe.js} +1 -1
  14. package/dist/assets/{eye-YQHiLgt4.js → eye-Cj7s1eMQ.js} +1 -1
  15. package/dist/assets/{file-code-BpwHxsqo.js → file-code-DxVUPin2.js} +1 -1
  16. package/dist/assets/{file-search-LR6NeRNh.js → file-search-BRbGARSr.js} +1 -1
  17. package/dist/assets/filename-validation-wKCpNal3.js +1 -0
  18. package/dist/assets/{grip-vertical-KfzS75WH.js → grip-vertical-C5AW4fiD.js} +1 -1
  19. package/dist/assets/{hook-editor-tcKRn_gP.js → hook-editor-KoqKvv73.js} +1 -1
  20. package/dist/assets/{hook-runtime-CTRviwQE.js → hook-runtime-DZ6bR69q.js} +1 -1
  21. package/dist/assets/{hook-viewer-eGadGjA0.js → hook-viewer-DWsN8RyZ.js} +1 -1
  22. package/dist/assets/hooks-BfUXcuyV.js +1 -0
  23. package/dist/assets/{id-badge-BmmZdbHv.js → id-badge-BpTnHwvn.js} +2 -2
  24. package/dist/assets/{index-B4FdO6Vk.js → index-C3AdCkmj.js} +2 -2
  25. package/dist/assets/{insights-C_tn8W_Q.js → insights-Dtq5Rwby.js} +1 -1
  26. package/dist/assets/{insights-line-grid-DKZyKGcI.js → insights-line-grid-X5lNbmTY.js} +6 -6
  27. package/dist/assets/{lib-B9z0w3j9.js → lib-u_ZEFKZp.js} +1 -1
  28. package/dist/assets/live-run-CfMxOSfk.js +1 -0
  29. package/dist/assets/{memory-CdMqWelO.js → memory-DS-02aNZ.js} +1 -1
  30. package/dist/assets/memory-product-5m-eyxzH.js +2 -0
  31. package/dist/assets/{monaco-editor-DF4W-NC-.js → monaco-editor-BEWq4fzI.js} +2 -2
  32. package/dist/assets/{monaco-editor-inner-I81tD0qz.js → monaco-editor-inner-B6AQm3h7.js} +2 -2
  33. package/dist/assets/{monaco.contribution-CEeipeu9.js → monaco.contribution-Dum2B1vn.js} +2 -2
  34. package/dist/assets/{observation-block-DC5e2IE9.js → observation-block-2qfTbm41.js} +1 -1
  35. package/dist/assets/{observation-markdown-DyWjt-yP.js → observation-markdown-CIs-5TY2.js} +1 -1
  36. package/dist/assets/{pencil-CZF_NGi6.js → pencil-BUQgVaEH.js} +1 -1
  37. package/dist/assets/plus-Bf5Mbita.js +1 -0
  38. package/dist/assets/popover-OAiTzjiL.js +1 -0
  39. package/dist/assets/{refresh-cw-RAow1kax.js → refresh-cw-D0OwRzvm.js} +1 -1
  40. package/dist/assets/{resizable-B2X6KlcC.js → resizable-ugU12HrY.js} +1 -1
  41. package/dist/assets/run-detail-Cr984qgU.js +1 -0
  42. package/dist/assets/runs-CDAIeUbq.js +1 -0
  43. package/dist/assets/{scroll-area-BmkJ1y7Q.js → scroll-area-CX3T8JWh.js} +1 -1
  44. package/dist/assets/{select-D5oFJNaq.js → select-D0GpDfUa.js} +1 -1
  45. package/dist/assets/{shortcut-hints-CtwepXR1.js → shortcut-hints-B8kCurzo.js} +1 -1
  46. package/dist/assets/split-button-CRYV8xU8.js +1 -0
  47. package/dist/assets/square-K8N8Yius.js +1 -0
  48. package/dist/assets/{step-name-pills-VuIw2nNC.js → step-name-pills-BQ8yv40K.js} +1 -1
  49. package/dist/assets/suite-editor-aAjvjp2R.js +5 -0
  50. package/dist/assets/suite-navbar-UATCw4Qb.js +1 -0
  51. package/dist/assets/suite-viewer-CmbLH1G2.js +1 -0
  52. package/dist/assets/{suites-wRKqOnN6.js → suites-BlJfefzt.js} +1 -1
  53. package/dist/assets/{switch-CPd0R3ri.js → switch-Dv7aVqt1.js} +1 -1
  54. package/dist/assets/tab-console-Ciur_Bee.js +1 -0
  55. package/dist/assets/{table-QG2rKYu8.js → table-BOjrxBBL.js} +1 -1
  56. package/dist/assets/{tabs-DzjvuMEX.js → tabs-BEp-p5jh.js} +1 -1
  57. package/dist/assets/test-editor-CFzp3eq1.js +9 -0
  58. package/dist/assets/test-navbar-ChNg-qki.js +7 -0
  59. package/dist/assets/{test-viewer-0SziRmsW.js → test-viewer-DEQQDURn.js} +1 -1
  60. package/dist/assets/tests-Dzlh9Zho.js +1 -0
  61. package/dist/assets/{tests-suites-table-widths-D49Zcf1r.js → tests-suites-table-widths-D2sc1JmR.js} +1 -1
  62. package/dist/assets/{textarea-CVB6Do1_.js → textarea-BFsDx2mB.js} +1 -1
  63. package/dist/assets/{trash-2-BhJSaMLG.js → trash-2-Dv939XWG.js} +1 -1
  64. package/dist/assets/{tsMode-TiV3uQ0t.js → tsMode-CnaplBFQ.js} +1 -1
  65. package/dist/assets/use-hook-run-session-BLSTM6LJ.js +1 -0
  66. package/dist/assets/{use-keyboard-shortcuts-Bal_Cx9w.js → use-keyboard-shortcuts-COnAPsDD.js} +1 -1
  67. package/dist/assets/{use-page-title-B4YPyIzc.js → use-page-title-CsUoFrfG.js} +1 -1
  68. package/dist/assets/use-run-status-favicon-DLOLF3Hx.js +1 -0
  69. package/dist/assets/{use-selection-queue-O7K3NZNK.js → use-selection-queue-BkEWIfvw.js} +1 -1
  70. package/dist/assets/{viewer-url-state-ClEUZJMl.js → viewer-url-state-PwkMc-qK.js} +1 -1
  71. package/dist/assets/{zap-BYpQfhU4.js → zap-Dx2CqraS.js} +1 -1
  72. package/dist/index.html +1 -1
  73. package/package.json +2 -2
  74. package/dist/assets/config-a9DxCBoP.js +0 -10
  75. package/dist/assets/dist-BJdB11cl.js +0 -1
  76. package/dist/assets/filename-validation-S8QXnNdt.js +0 -1
  77. package/dist/assets/hooks-BM--ZgFe.js +0 -1
  78. package/dist/assets/live-run-EmcKA5cK.js +0 -1
  79. package/dist/assets/memory-product-f5AfXXJn.js +0 -2
  80. package/dist/assets/plus-Qf7V331e.js +0 -1
  81. package/dist/assets/popover-DwYq4QYF.js +0 -1
  82. package/dist/assets/run-detail-DZ-1orHT.js +0 -1
  83. package/dist/assets/runs-CTOIdEAQ.js +0 -1
  84. package/dist/assets/split-button-wGcE-JDx.js +0 -1
  85. package/dist/assets/square-CgFZz_zK.js +0 -1
  86. package/dist/assets/suite-editor-DLu7OCZy.js +0 -5
  87. package/dist/assets/suite-navbar-B8gZoPMT.js +0 -1
  88. package/dist/assets/suite-viewer-CPBPmJdG.js +0 -1
  89. package/dist/assets/tab-console-BORDNFzI.js +0 -1
  90. package/dist/assets/test-editor-BoaHOuai.js +0 -9
  91. package/dist/assets/test-navbar-C6-h4kbc.js +0 -7
  92. package/dist/assets/tests-OLyMTO9C.js +0 -1
  93. package/dist/assets/use-hook-run-session-DH_86Jtn.js +0 -1
  94. package/dist/assets/use-run-status-favicon-Rjqwuxhd.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vostride/agent-qa-dashboard-ui",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "description": "Built agent-qa dashboard UI assets served by the local dashboard.",
6
6
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "@fontsource-variable/geist": "5.2.8",
49
49
  "@fontsource-variable/geist-mono": "5.2.7",
50
50
  "@tanstack/react-table": "8.21.3",
51
- "@vostride/agent-qa-ids": "0.1.13",
51
+ "@vostride/agent-qa-ids": "0.1.14",
52
52
  "class-variance-authority": "0.7.1",
53
53
  "clsx": "2.1.1",
54
54
  "cmdk": "1.1.1",
@@ -1,10 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{a as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./select-D5oFJNaq.js";import{t as c}from"./circle-x-B7AOkLOS.js";import{t as l}from"./external-link-DC-KkLmq.js";import{t as u}from"./eye-YQHiLgt4.js";import{t as d}from"./pencil-CZF_NGi6.js";import{t as f}from"./plus-Qf7V331e.js";import{n as p,t as m}from"./textarea-CVB6Do1_.js";import{t as h}from"./trash-2-BhJSaMLG.js";import{t as g}from"./use-page-title-B4YPyIzc.js";import{a as _,i as v}from"./dist-wK15YRiu.js";import{t as y}from"./switch-CPd0R3ri.js";import{i as b,n as x,r as S,t as C}from"./tabs-DzjvuMEX.js";import{$n as w,At as T,Bn as E,Ct as D,F as ee,Ft as O,Ht as k,Jn as te,Mt as ne,Nt as re,Pt as ie,Qn as ae,R as oe,Tt as A,Un as se,Ut as j,V as ce,Vn as M,Vt as le,Wt as ue,_ as N,b as de,cr as fe,f as pe,g as me,h as P,ht as he,i as ge,jt as _e,k as ve,m as ye,p as be,pr as xe,q as Se,ur as Ce,v as we,vt as Te,w as Ee,x as F,xt as De,y as Oe,yt as ke,z as Ae,zn as I}from"./index-B4FdO6Vk.js";import{t as L}from"./badge-CC1v3nk4.js";import{n as je,r as Me,t as R}from"./lib-B9z0w3j9.js";import{a as Ne,i as z,n as Pe,o as Fe,r as Ie,t as Le}from"./table-QG2rKYu8.js";import{t as Re}from"./marked.esm-Ba5AUJng.js";var ze=te(`book-open-text`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M16 12h2`,key:`7q9ll5`}],[`path`,{d:`M16 8h2`,key:`msurwy`}],[`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`}],[`path`,{d:`M6 12h2`,key:`32wvfc`}],[`path`,{d:`M6 8h2`,key:`30oboj`}]]),Be=te(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),B=e(xe(),1),V=ae();function H({className:e,...t}){return(0,V.jsx)(`section`,{"data-config-section-shell":!0,className:ue(`border border-border bg-transparent rounded-none shadow-none`,e),...t})}function U({className:e,...t}){return(0,V.jsx)(`header`,{className:ue(`border-b border-border px-5 py-4`,e),...t})}function W({className:e,...t}){return(0,V.jsx)(`div`,{"data-config-section-body":!0,className:ue(`space-y-6 px-5 py-5`,e),...t})}function Ve({className:e,...t}){return(0,V.jsx)(`div`,{"data-config-line-notice":!0,className:ue(`border border-border bg-transparent rounded-none px-4 py-3 text-sm text-muted-foreground`,e),...t})}function G(e,t){let n=e.trim(),r=t.errorMessage??He(t);if(n===``)return t.allowEmpty?{value:void 0,error:null}:{value:void 0,error:r};if(!(t.integer?/^-?\d+$/:/^-?(?:\d+|\d*\.\d+)$/).test(n))return{value:void 0,error:r};let i=Number(n);return!Number.isFinite(i)||t.integer&&!Number.isSafeInteger(i)||t.min!==void 0&&i<t.min||t.max!==void 0&&i>t.max?{value:void 0,error:r}:{value:i,error:null}}function He(e){let t=e.integer?`an integer`:`a number`;return e.min!==void 0&&e.max!==void 0?`${e.label} must be ${t} between ${e.min} and ${e.max}`:e.min===void 0?e.max===void 0?`${e.label} must be ${t}`:`${e.label} must be ${t} less than or equal to ${e.max}`:`${e.label} must be ${t} greater than or equal to ${e.min}`}var Ue=Object.fromEntries([{value:`openai-compatible`,label:`OpenAI-compatible`},{value:`anthropic-compatible`,label:`Anthropic-compatible`},{value:`gemini`,label:`Gemini`}].map(e=>[e.value,e.label])),We=new Set([`openai-compatible`,`anthropic-compatible`]),Ge=`Enter the exact endpoint base URL. agent-qa will not append paths.`,Ke=`Testing without a saved credential.`,qe=`Save a Gemini API key for this config before testing.`;function Je(){return[{id:`openai-compatible`,label:`OpenAI-compatible`,auth:{kind:`api-key`,credentialTypes:[`api-key`],optional:!0},modelAdapter:`openai-responses`},{id:`anthropic-compatible`,label:`Anthropic-compatible`,auth:{kind:`api-key`,credentialTypes:[`api-key`,`bearer-token`],optional:!0},modelAdapter:`anthropic-messages`},{id:`gemini`,label:`Gemini`,auth:{kind:`api-key`,credentialTypes:[`api-key`]}}]}function K(e=``,t=``){return{id:crypto.randomUUID(),key:e,value:t}}function Ye(e,t=[]){return t.find(t=>t.id===e)?.label??Ue[e]??e}function Xe(e){if(e===null)return null;let t=Date.now();if(e<t)return`Expired`;let n=e-t,r=Math.floor(n/(1e3*60*60)),i=Math.floor(n%(1e3*60*60)/(1e3*60));return r>24?`Expires in ${Math.floor(r/24)}d`:r>0?`Expires in ${r}h ${i}m`:`Expires in ${i}m`}function Ze(e){return e.type===`oauth`?`OAuth connected`:e.type===`bearer`||e.type===`bearer-token`?`Saved bearer token`:`Saved API key`}function Qe(e,t,n){return e.configName===t?e.type===`oauth`?e.provider===n:e.type===`bearer`||e.type===`bearer-token`?n===`anthropic-compatible`&&e.provider===`anthropic-compatible`:e.provider===n:!1}function $e(e,t){return e.find(e=>Qe(e,t.name,t.provider))}function et(e){return We.has(e.provider)?`No credential`:`Missing credential`}function tt(e){let t={};for(let n of e){let e=n.key.trim(),r=n.value.trim();!e&&!r||e&&(t[e]=r)}return Object.keys(t).length>0?t:void 0}function nt(e){let t=new Map;for(let n of e){let e=n.key.trim().toLowerCase();e&&t.set(e,(t.get(e)??0)+1)}return new Set([...t.entries()].filter(([,e])=>e>1).map(([e])=>e))}function rt(e){return e.error===`missing_credential`&&e.message?e.message:e.error===`auth_error`?`Authentication failed. Check the saved credential for this config.`:e.error===`model_not_found`?`Model not found. Check the model name.`:e.error===`network_error`?`Network error. Check the exact base URL and try again.`:e.error===`invalid_request`&&e.message?`Connection failed. ${e.message}`:e.message?e.message.startsWith(`Connection failed.`)?e.message:`Connection failed. ${e.message}`:`Connection failed. Provider returned an error.`}function it({config:e,onConfigChange:t}){let n=e.use?.llm??null,[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(Je()),[l,u]=(0,B.useState)(!0),[m,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null);(0,B.useEffect)(()=>{async function t(){try{u(!0),i((e?.registry??{}).llms??[]);let[t,n]=await Promise.all([Ae(),Se().catch(()=>({providers:Je()}))]);o(t.credentials??[]),c(n.providers.length?n.providers:Je())}catch{T.error(`Failed to load LLM configuration. Refresh and try again.`)}finally{u(!1)}}t()},[e]);async function x(){o((await Ae()).credentials??[])}async function S(e){if(e===n){T.error(`Cannot delete the active default configuration. Switch the default in Execution Defaults first.`);return}let a=r.filter(t=>t.name!==e),o=r;i(a);try{await A({"registry.llms":a}),T.success(`Configuration ${e} deleted`),t()}catch{i(o),T.error(`Failed to delete configuration`)}}async function C(e){let n=_===null?[...r,e]:r.map(t=>t.name===e.name?e:t);try{await A({"registry.llms":n}),i(n),T.success(`Changes saved`),g(!1),v(null),t(),await x()}catch{T.error(`Failed to save configuration. Check the fields and try again.`)}}function w(e){let t=$e(a,e);if(!t)return(0,V.jsx)(L,{variant:`secondary`,children:et(e)});let n=Xe(t.expires),r=t.expires!==null&&t.expires<Date.now();return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,V.jsx)(L,{variant:`secondary`,children:Ze(t)}),n&&(0,V.jsx)(L,{variant:r?`destructive`:`outline`,className:`text-xs`,children:n})]})}let E=je({data:r,columns:(0,B.useMemo)(()=>[{accessorKey:`name`,header:`Name`,size:140,cell:({row:e})=>(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`max-w-[220px] truncate font-mono`,children:e.original.name}),e.original.name===n?(0,V.jsx)(L,{variant:`outline`,className:`text-[11px]`,children:`Default`}):null]})},{accessorKey:`provider`,header:`Provider`,size:160,cell:({row:e})=>(0,V.jsx)(`span`,{className:`block min-w-0 max-w-[220px] truncate`,children:Ye(e.original.provider,s)})},{accessorKey:`model`,header:`Model`,cell:({row:e})=>(0,V.jsx)(`span`,{className:`block min-w-0 max-w-[280px] truncate`,children:e.original.model})},{id:`credential`,header:`Credential`,cell:({row:e})=>w(e.original)},{id:`actions`,header:``,size:80,cell:({row:e})=>(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,V.jsx)(j,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-foreground`,onClick:t=>{t.stopPropagation(),v(e.original),g(!0)},title:`Edit configuration`,"aria-label":`Edit configuration`,children:(0,V.jsx)(d,{className:`size-4`})}),(0,V.jsx)(j,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,onClick:t=>{t.stopPropagation(),e.original.name!==n&&b(e.original.name)},title:e.original.name===n?`Switch the default in Execution Defaults before deleting`:`Delete configuration`,"aria-label":`Delete configuration`,disabled:e.original.name===n,children:(0,V.jsx)(h,{className:`size-4`})})]})}],[n,a,s]),getCoreRowModel:Me()});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`LLM Configurations`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Named model configurations for test runs. Choose the active default in Use / Execution Defaults.`})]}),(0,V.jsx)(W,{children:l?(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(O,{className:`h-10 w-full rounded-none bg-muted`}),(0,V.jsx)(O,{className:`h-10 w-full rounded-none bg-muted`}),(0,V.jsx)(O,{className:`h-10 w-full rounded-none bg-muted`})]}):r.length===0?(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,V.jsx)(p,{className:`size-10 text-muted-foreground`}),(0,V.jsx)(`h3`,{className:`mt-4 text-lg font-semibold`,children:`No LLM configurations`}),(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Add an LLM configuration to start running tests.`}),(0,V.jsxs)(j,{className:`mt-4`,onClick:()=>{v(null),g(!0)},children:[(0,V.jsx)(f,{className:`size-4`}),`Add Configuration`]})]}):(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsxs)(j,{size:`sm`,onClick:()=>{v(null),g(!0)},children:[(0,V.jsx)(f,{className:`size-4`}),`Add Configuration`]})}),(0,V.jsxs)(Le,{children:[(0,V.jsx)(Ne,{children:E.getHeaderGroups().map(e=>(0,V.jsx)(Fe,{children:e.headers.map(e=>(0,V.jsx)(z,{style:e.column.getSize()===150?void 0:{width:e.column.getSize()},className:`min-w-0`,children:e.isPlaceholder?null:R(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,V.jsx)(Pe,{children:E.getRowModel().rows.map(e=>(0,V.jsx)(Fe,{children:e.getVisibleCells().map(e=>(0,V.jsx)(Ie,{className:`min-w-0`,children:R(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})]})})]}),(0,V.jsx)(at,{open:m,onOpenChange:e=>{g(e),e||v(null)},config:_,existingNames:r.map(e=>e.name),onSave:C,onAuthChange:x,authCredentials:a,providerMetadata:s}),(0,V.jsx)(pe,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,V.jsxs)(be,{children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:`Delete Configuration`}),(0,V.jsxs)(ye,{children:[`Delete `,(0,V.jsx)(`span`,{className:`font-mono font-semibold`,children:y}),`? This action cannot be undone.`]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:()=>b(null),children:`Keep Configuration`}),(0,V.jsx)(j,{variant:`destructive`,onClick:()=>{y&&(S(y),b(null))},children:`Delete Configuration`})]})]})})]})}function at({open:e,onOpenChange:t,config:a,existingNames:u,onSave:d,onAuthChange:p,authCredentials:m,providerMetadata:g}){let v=a!==null,[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)(`openai-compatible`),[C,w]=(0,B.useState)(``),[D,O]=(0,B.useState)(``),[te,ae]=(0,B.useState)([]),[oe,A]=(0,B.useState)(`api-key`),[ce,M]=(0,B.useState)(``),[ue,de]=(0,B.useState)(``),[fe,ge]=(0,B.useState)(``),[xe,Se]=(0,B.useState)(``),[Ce,we]=(0,B.useState)(!1),[Ee,F]=(0,B.useState)(!1),[Oe,Ae]=(0,B.useState)(null),[je,Me]=(0,B.useState)(!1),[R,Ne]=(0,B.useState)(!1),[z,Pe]=(0,B.useState)(null),[Fe,Ie]=(0,B.useState)(``),[Le,Re]=(0,B.useState)(``),[ze,Be]=(0,B.useState)(!1),[H,U]=(0,B.useState)(null),W=g.length?g:Je(),Ve=(0,B.useMemo)(()=>{let e=W.map(e=>({value:e.id,label:e.label}));return x&&!e.some(e=>e.value===x)&&e.push({value:x,label:Ye(x,W)}),e},[W,x]),He=W.find(e=>e.id===x),Ue=m.some(e=>Qe(e,y,x)),$e=We.has(x),et=x===`anthropic-compatible`,it=$e,at=He?.auth.kind===`api-key`,ot=nt(te),st=ot.size>0;(0,B.useEffect)(()=>{if(e)if(Pe(null),Ie(``),Re(``),M(``),Se(``),Ae(null),U(null),a){let e=a.provider||`openai-compatible`;b(a.name),S(e),w(a.model),O(a.baseURL??``),ae(e===`anthropic-compatible`?Object.entries(a.providerHeaders??{}).map(([e,t])=>K(e,t)).concat(Object.keys(a.providerHeaders??{}).length===0?[K()]:[]):[]),A(e===`anthropic-compatible`?`bearer-token`:`api-key`),de(a.screenshotSize??``),ge(a.effectiveResolution==null?``:String(a.effectiveResolution))}else{let e=g.find(e=>e.id===`openai-compatible`)?.id??g[0]?.id??`openai-compatible`;b(``),S(e),w(``),O(``),ae([]),A(`api-key`),de(``),ge(``)}},[e,a,g]);function ct(e){return e?/^[a-z0-9][a-z0-9-]*$/.test(e)?u.filter(e=>e!==a?.name).includes(e)?`A configuration with this name already exists`:``:`Name must be lowercase letters, numbers, and hyphens, starting with a letter or number`:``}function lt(e){S(e),Pe(null),Re(``),Ae(null),M(``),Se(``),A(e===`anthropic-compatible`?`bearer-token`:`api-key`),O(``),ae(e===`anthropic-compatible`?[K()]:[])}function ut(e,t,n){ae(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))}async function dt(){if(st){T.error(`Duplicate provider header names are not allowed`);return}Ne(!0),Pe(null);try{let e=et?tt(te):void 0;Pe(await De({provider:x,model:C,...D.trim()?{baseURL:D.trim()}:{},...e?{providerHeaders:e}:{},configName:y||void 0}))}catch{Pe({success:!1,error:`network_error`,message:`Network error. Check the exact base URL and try again.`})}finally{Ne(!1)}}async function ft(){let e=ct(y);if(e){Ie(e);return}if(!y||!x||!C)return;if(it&&D.trim()===``){Re(`Base URL is required for compatible providers.`);return}if(st){T.error(`Duplicate provider header names are not allowed`);return}let t=G(fe,{label:`Effective resolution`,min:1,integer:!0,allowEmpty:!0,errorMessage:`Effective resolution must be a positive integer`});if(t.error){T.error(t.error);return}Me(!0);try{let e=et?tt(te):void 0;await d({name:y,provider:x,model:C,baseURL:D.trim()||void 0,...e?{providerHeaders:e}:{},screenshotSize:ue||void 0,effectiveResolution:t.value})}catch(e){T.error(e instanceof Error?e.message:`Failed to save configuration`)}finally{Me(!1)}}async function pt(){if(!(!ce.trim()||!y||!at)){Be(!0);try{let e=et?oe:`api-key`;await Te(y,x,e,ce.trim()),T.success(e===`bearer-token`?`Bearer token saved`:`API key saved`),M(``),await p()}catch{T.error(`Failed to save credential`)}finally{Be(!1)}}}async function mt(){if(H)try{await ve(H),await p(),T.success(`Credential deleted`)}catch{T.error(`Failed to delete credential`)}finally{U(null)}}let ht=y.trim()!==``&&C.trim()!==``&&!Fe;function gt(){return at?(0,V.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Credentials are optional for this config. Unauthenticated endpoints can still be tested.`}),x===`gemini`&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:qe}),et&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{children:`Credential Type`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save an API key or Bearer token for this config.`}),(0,V.jsxs)(s,{value:oe,onValueChange:e=>A(e),children:[(0,V.jsx)(i,{className:`w-full`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`api-key`,children:`API key`}),(0,V.jsx)(n,{value:`bearer-token`,children:`Bearer token`})]})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(k,{type:`password`,placeholder:`secret-value`,value:ce,onChange:e=>M(e.target.value),className:`min-w-[180px] flex-1`}),(0,V.jsxs)(j,{size:`sm`,onClick:pt,disabled:ze||!ce.trim()||!y||!!Fe,children:[ze?(0,V.jsx)(I,{className:`size-4 animate-spin`}):null,`Save Credential`]})]})]}):null}function _t(){if(He?.auth.kind!==`oauth-plugin`)return null;let e=Oe?.provider===x?Oe:null,t=He.label,n=He.auth.buttonLabel??`Login with ${t}`;async function r(){F(!0),Se(``);try{let e=await ke(x,y);if(Ae({provider:x,sessionId:e.sessionId,mode:e.mode}),window.open(e.authorizeUrl,`_blank`),e.mode===`browser-poll`){let n=window.setInterval(async()=>{try{let r=await he(x,e.sessionId);r.status===`completed`?(window.clearInterval(n),T.success(`${t} authenticated`),F(!1),Ae(null),await p()):r.status===`error`&&(window.clearInterval(n),T.error(r.error||`${t} authentication failed`),F(!1))}catch{}},2e3);window.setTimeout(()=>{window.clearInterval(n),F(!1)},300*1e3)}else F(!1)}catch{T.error(`Failed to start ${t} authentication`),F(!1)}}return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Login with `,t,` for this config before testing.`]}),He.auth.mode===`manual-code`?(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(_,{className:`text-sm`,children:`Open authorization page`}),(0,V.jsxs)(j,{variant:`outline`,size:`sm`,disabled:Ee||!y||!!Fe,onClick:r,children:[(0,V.jsx)(l,{className:`size-4`}),n]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(_,{className:`text-sm`,children:`Paste authorization code`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(k,{type:`password`,placeholder:`authorization-code`,value:xe,onChange:e=>Se(e.target.value),disabled:!e,className:`min-w-[180px] flex-1`}),(0,V.jsxs)(j,{size:`sm`,disabled:!xe.trim()||!e||Ce,onClick:async()=>{if(e){we(!0);try{await ee(x,e.sessionId,xe.trim()),T.success(`${t} authenticated`),Se(``),Ae(null),await p()}catch{T.error(`Failed to exchange code`)}finally{we(!1)}}},children:[Ce?(0,V.jsx)(I,{className:`size-4 animate-spin`}):null,`Connect`]})]})]})]}):(0,V.jsx)(`div`,{className:`space-y-3`,children:(0,V.jsxs)(j,{variant:`outline`,size:`sm`,disabled:Ee||!y||!!Fe,onClick:r,children:[Ee?(0,V.jsx)(I,{className:`size-4 animate-spin`}):(0,V.jsx)(l,{className:`size-4`}),Ee?`Authenticating...`:n]})})]})}function vt(){let e=m.filter(e=>e.configName===y);return e.length===0?null:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let t=Xe(e.expires),n=e.expires!==null&&e.expires<Date.now();return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3 rounded-none border border-border bg-transparent p-3 text-sm`,children:[(0,V.jsx)(L,{variant:`secondary`,className:`text-xs`,children:Ze(e)}),(0,V.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:Ye(e.provider,W)}),t&&(0,V.jsx)(L,{variant:n?`destructive`:`outline`,className:`text-xs`,children:t}),(0,V.jsx)(j,{variant:`ghost`,size:`sm`,className:`ml-auto h-8 w-8 p-0 text-destructive hover:text-destructive`,onClick:()=>U(e.configName),"aria-label":`Delete credential`,title:`Delete credential`,children:(0,V.jsx)(h,{className:`size-4`})})]},`${e.configName}-${e.type}-${e.provider}`)})})}function q(){return R?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,children:[(0,V.jsx)(I,{className:`size-4 animate-spin`}),(0,V.jsx)(`span`,{children:`Testing connection...`})]}):z?z.success?z.unauthenticated?(0,V.jsx)(`div`,{className:`text-sm text-muted-foreground`,role:`status`,children:z.authMessage||z.message||Ke}):(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-success`,role:`status`,children:[(0,V.jsx)(se,{className:`size-4`}),(0,V.jsx)(`span`,{children:`Connection successful`}),z.responseTime!=null&&(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[z.responseTime,`ms`]})]}):(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive`,role:`alert`,children:[(0,V.jsx)(c,{className:`size-4`}),(0,V.jsx)(`span`,{children:rt(z)})]}):null}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(pe,{open:e,onOpenChange:t,children:(0,V.jsxs)(be,{className:`sm:max-w-2xl max-h-[85vh] overflow-y-auto`,children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:v?`Edit ${a.name}`:`Add Configuration`}),(0,V.jsx)(ye,{children:v?`Update provider, model, and credentials for this configuration.`:`Create a named LLM configuration with its own provider, model, and credentials.`})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`config-name`,children:`Name`}),(0,V.jsx)(k,{id:`config-name`,placeholder:`e.g., claude-fast, gpt-cheap`,value:y,onChange:e=>{b(e.target.value),Fe&&Ie(``)},onBlur:()=>{y&&Ie(ct(y))},disabled:v,className:v?`bg-muted`:``,"aria-describedby":Fe?`name-error`:void 0}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase alphanumeric and hyphens (e.g., claude-fast, gpt-cheap)`}),Fe&&(0,V.jsx)(`p`,{id:`name-error`,className:`text-sm text-destructive`,children:Fe})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{children:`Provider`}),(0,V.jsxs)(s,{value:x,onValueChange:lt,children:[(0,V.jsx)(i,{className:`w-full`,children:(0,V.jsx)(o,{})}),(0,V.jsx)(r,{children:Ve.map(e=>(0,V.jsx)(n,{value:e.value,children:e.label},e.value))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`config-model`,children:`Model`}),(0,V.jsx)(k,{id:`config-model`,placeholder:`model-name`,value:C,onChange:e=>w(e.target.value)})]}),it&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(_,{htmlFor:`config-base-url`,children:`Base URL`}),(0,V.jsx)(re,{children:(0,V.jsxs)(_e,{children:[(0,V.jsx)(ie,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":`Compatible endpoint help`,className:`inline-flex size-5 items-center justify-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring cursor-help`,children:(0,V.jsx)(E,{className:`size-3.5`})})}),(0,V.jsx)(ne,{className:`max-w-[250px]`,children:Ge})]})})]}),(0,V.jsx)(k,{id:`config-base-url`,placeholder:x===`openai-compatible`?`https://openrouter.ai/api/v1`:`https://anthropic-proxy.example/messages`,value:D,onChange:e=>{O(e.target.value),Le&&Re(``)},"aria-invalid":Le?!0:void 0,"aria-describedby":Le?`base-url-error`:void 0}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Ge}),Le&&(0,V.jsx)(`p`,{id:`base-url-error`,className:`text-sm text-destructive`,children:Le})]}),et&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(_,{children:`Provider Headers`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Optional non-secret headers sent with this Anthropic-compatible endpoint.`})]}),(0,V.jsx)(`div`,{className:`space-y-2`,children:te.map(e=>{let t=e.key.trim().toLowerCase(),n=t!==``&&ot.has(t);return(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(k,{placeholder:`header-name`,value:e.key,onChange:t=>ut(e.id,`key`,t.target.value),className:`min-w-[160px] flex-1`}),(0,V.jsx)(k,{placeholder:`header-value`,value:e.value,onChange:t=>ut(e.id,`value`,t.target.value),className:`min-w-[180px] flex-1`}),(0,V.jsx)(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,"aria-label":`Remove header`,title:`Remove header`,onClick:()=>ae(t=>t.filter(t=>t.id!==e.id)),disabled:te.length===1&&!e.key&&!e.value,children:(0,V.jsx)(h,{className:`size-4`})})]}),n&&(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:`Duplicate header names are not allowed.`})]},e.id)})}),(0,V.jsxs)(j,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>ae(e=>[...e,K()]),children:[(0,V.jsx)(f,{className:`size-4`}),`Add Header`]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{children:`Screenshot Size`}),(0,V.jsx)(k,{placeholder:`e.g., "1m", "512k" (empty = no compression)`,value:ue,onChange:e=>de(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum screenshot size for this model (e.g., "1m", "512k"). Empty = no compression.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`config-effective-resolution`,children:`Effective Resolution`}),(0,V.jsx)(k,{id:`config-effective-resolution`,type:`number`,min:1,step:1,placeholder:`e.g., 1568`,value:fe,onChange:e=>ge(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum effective screenshot edge sent to the model. Use this with screenshot compression to control token cost.`})]}),(0,V.jsx)(le,{}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-base font-semibold`,children:`Credentials`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Saved credentials are keyed by this named configuration.`})]}),gt(),_t(),vt()]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:dt,disabled:R||!x||!C||st,children:`Test Connection`}),(0,V.jsxs)(j,{onClick:ft,disabled:je||!ht||st,children:[je&&(0,V.jsx)(I,{className:`size-4 animate-spin`}),`Save Changes`]})]}),$e&&!Ue&&!R&&!z&&(0,V.jsx)(`div`,{className:`text-sm text-muted-foreground`,role:`status`,children:Ke}),q()]})}),(0,V.jsx)(pe,{open:H!==null,onOpenChange:e=>{e||U(null)},children:(0,V.jsxs)(be,{children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:`Delete Credential`}),(0,V.jsxs)(ye,{children:[`Delete saved credential for `,H,`? Tests using this config may fail until a new credential is saved.`]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:()=>U(null),children:`Keep Credential`}),(0,V.jsx)(j,{variant:`destructive`,onClick:mt,children:`Delete Credential`})]})]})})]})}function ot({config:e,onConfigChange:t}){let n=e.use?.timeout??{},[r,i]=(0,B.useState)(n.step??`30s`),[a,o]=(0,B.useState)(n.test??`10m`),[s,c]=(0,B.useState)(n.navigation??`10s`),[l,u]=(0,B.useState)(!1);async function d(){u(!0);try{await A({"use.timeout":{step:r,test:a,navigation:s}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{u(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Timeout`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure timeout limits for test execution`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`timeout-step`,children:`Step Timeout`}),(0,V.jsx)(k,{id:`timeout-step`,type:`text`,placeholder:`e.g., "30s", "5m"`,value:r,onChange:e=>i(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Max time for a single test step (e.g., "30s", "5m")`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`timeout-test`,children:`Test Timeout`}),(0,V.jsx)(k,{id:`timeout-test`,type:`text`,placeholder:`e.g., "10m", "1h"`,value:a,onChange:e=>o(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Max time for an entire test (e.g., "10m", "1h")`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`timeout-navigation`,children:`Navigation Timeout`}),(0,V.jsx)(k,{id:`timeout-navigation`,type:`text`,placeholder:`e.g., "10s", "30s"`,value:s,onChange:e=>c(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Max time for page navigation (e.g., "10s", "30s")`})]}),(0,V.jsx)(j,{size:`sm`,onClick:d,disabled:l,children:l?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function st({config:e,onConfigChange:t}){let n=e.use?.healing??{},[r,i]=(0,B.useState)(String(n.maxAttempts??3)),[a,o]=(0,B.useState)(!1);async function s(){let e=G(r,{label:`Max healing attempts`,min:1,integer:!0});if(e.error){T.error(e.error);return}o(!0);try{await A({"use.healing":{maxAttempts:e.value}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{o(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Healing`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure self-healing behavior for failing test steps`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`healing-max-attempts`,children:`Max Healing Attempts`}),(0,V.jsx)(k,{id:`healing-max-attempts`,type:`number`,min:1,step:1,value:r,onChange:e=>i(e.target.value)})]}),(0,V.jsx)(j,{size:`sm`,onClick:s,disabled:a,children:a?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function ct({config:e,onConfigChange:t}){let n=e.services?.cache??{},[r,i]=(0,B.useState)(n.dir??``),[a,o]=(0,B.useState)(n.ttl??``),[s,c]=(0,B.useState)(!1);async function l(){c(!0);try{await A({"services.cache":{dir:r,ttl:a}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{c(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Cache`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure action cache directory and expiration`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`cache-dir`,children:`Cache Directory`}),(0,V.jsx)(k,{id:`cache-dir`,placeholder:`.agent-qa/cache`,value:r,onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`cache-ttl`,children:`TTL`}),(0,V.jsx)(k,{id:`cache-ttl`,placeholder:`7d`,value:a,onChange:e=>o(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Cache time-to-live — human-readable duration (e.g., "7d", "24h", "30m")`})]}),(0,V.jsx)(j,{size:`sm`,onClick:l,disabled:s,children:s?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function lt({config:e,onConfigChange:t}){let[a,c]=(0,B.useState)((e.services?.logging??{}).level??`info`),[l,u]=(0,B.useState)(!1);async function d(){u(!0);try{await A({"services.logging":{level:a}}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{u(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Logging`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure service log verbosity.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`logging-level`,children:`Log Level`}),(0,V.jsxs)(s,{value:a,onValueChange:c,children:[(0,V.jsx)(i,{id:`logging-level`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`silent`,children:`Silent`}),(0,V.jsx)(n,{value:`error`,children:`Error`}),(0,V.jsx)(n,{value:`warn`,children:`Warn`}),(0,V.jsx)(n,{value:`info`,children:`Info`}),(0,V.jsx)(n,{value:`debug`,children:`Debug`})]})]})]}),(0,V.jsx)(j,{size:`sm`,onClick:d,disabled:l,children:l?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function ut({config:e,onConfigChange:t}){let a=e.use?.browser??{},[c,l]=(0,B.useState)(a.name??`chromium`),[u,d]=(0,B.useState)(a.headless??!0),f=a.viewport??{width:1280,height:720},[p,m]=(0,B.useState)(String(f.width)),[h,g]=(0,B.useState)(String(f.height)),[v,b]=(0,B.useState)(!1);async function x(){let e=G(p,{label:`Viewport width`,min:1,integer:!0});if(e.error){T.error(e.error);return}let n=G(h,{label:`Viewport height`,min:1,integer:!0});if(n.error){T.error(n.error);return}b(!0);try{await A({"use.browser":{name:c,headless:u,viewport:{width:e.value,height:n.value}}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{b(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Browser`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure default browser settings for web test execution`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`browser-name`,children:`Browser`}),(0,V.jsxs)(s,{value:c,onValueChange:l,children:[(0,V.jsx)(i,{id:`browser-name`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`chromium`,children:`Chromium`}),(0,V.jsx)(n,{value:`firefox`,children:`Firefox`}),(0,V.jsx)(n,{value:`webkit`,children:`WebKit`})]})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`browser-headless`,children:`Headless`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run web browsers without a visible window.`})]}),(0,V.jsx)(y,{id:`browser-headless`,checked:u,onCheckedChange:d})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`browser-vw`,children:`Viewport Width`}),(0,V.jsx)(k,{id:`browser-vw`,type:`number`,min:1,step:1,value:p,onChange:e=>m(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`browser-vh`,children:`Viewport Height`}),(0,V.jsx)(k,{id:`browser-vh`,type:`number`,min:1,step:1,value:h,onChange:e=>g(e.target.value)})]})]}),(0,V.jsx)(j,{size:`sm`,onClick:x,disabled:v,children:v?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function dt({config:e,onConfigChange:t}){let[n,r]=(0,B.useState)((e.services?.recording??{}).enabled??!1),[i,a]=(0,B.useState)(!1);async function o(){a(!0);try{await A({"services.recording":{enabled:n}}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{a(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Recording`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure whether runtime recording is enabled by default.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`recording-enabled`,children:`Enabled`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Record video of test execution`})]}),(0,V.jsx)(y,{id:`recording-enabled`,checked:n,onCheckedChange:r})]}),(0,V.jsx)(j,{size:`sm`,onClick:o,disabled:i,children:i?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function ft({config:e,onConfigChange:t}){let a=e.services?.accessibility??{},[c,l]=(0,B.useState)(a.enabled??!1),[u,d]=(0,B.useState)(a.standard??`wcag2aa`),[f,p]=(0,B.useState)(a.runAfter??`test-end`),[m,h]=(0,B.useState)(a.failOnViolation??!1),[g,v]=(0,B.useState)(!1);async function b(){v(!0);try{await A({"services.accessibility":{enabled:c,standard:u,runAfter:f,failOnViolation:m}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{v(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Accessibility`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure accessibility audit settings`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`a11y-enabled`,children:`Enabled`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run accessibility checks during tests`})]}),(0,V.jsx)(y,{id:`a11y-enabled`,checked:c,onCheckedChange:l})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`a11y-standard`,children:`Standard`}),(0,V.jsxs)(s,{value:u,onValueChange:d,children:[(0,V.jsx)(i,{id:`a11y-standard`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`wcag2a`,children:`WCAG 2.0 A`}),(0,V.jsx)(n,{value:`wcag2aa`,children:`WCAG 2.0 AA`}),(0,V.jsx)(n,{value:`wcag2aaa`,children:`WCAG 2.0 AAA`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`a11y-run-after`,children:`Run After`}),(0,V.jsxs)(s,{value:f,onValueChange:p,children:[(0,V.jsx)(i,{id:`a11y-run-after`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`every-step`,children:`Every Step`}),(0,V.jsx)(n,{value:`navigation`,children:`Navigation`}),(0,V.jsx)(n,{value:`test-end`,children:`Test End`})]})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`a11y-fail`,children:`Fail on Violation`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Fail the test if violations are found`})]}),(0,V.jsx)(y,{id:`a11y-fail`,checked:m,onCheckedChange:h})]}),(0,V.jsx)(j,{size:`sm`,onClick:b,disabled:g,children:g?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function pt({config:e,onConfigChange:t}){let n=e.use?.planner??{},[r,i]=(0,B.useState)(String(n.maxSubActions??20)),[a,o]=(0,B.useState)(String(n.previousStepCount??5)),[s,c]=(0,B.useState)(!1);async function l(){let e=G(r,{label:`Max sub-actions`,min:1,integer:!0});if(e.error){T.error(e.error);return}let n=G(a,{label:`Previous step count`,min:0,integer:!0});if(n.error){T.error(n.error);return}c(!0);try{await A({"use.planner":{maxSubActions:e.value,previousStepCount:n.value}}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{c(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Planner`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure the AI planner observation and planning settings`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`planner-max-sub-actions`,children:`Max Sub-Actions`}),(0,V.jsx)(k,{id:`planner-max-sub-actions`,type:`number`,min:1,step:1,value:r,onChange:e=>i(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum sub-actions per step`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`planner-prev-steps`,children:`Previous Step Count`}),(0,V.jsx)(k,{id:`planner-prev-steps`,type:`number`,min:0,step:1,value:a,onChange:e=>o(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Number of previous steps included in planner context`})]}),(0,V.jsx)(j,{size:`sm`,onClick:l,disabled:s,children:s?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}var{entries:mt,setPrototypeOf:ht,isFrozen:gt,getPrototypeOf:_t,getOwnPropertyDescriptor:vt}=Object,{freeze:q,seal:yt,create:bt}=Object,{apply:xt,construct:St}=typeof Reflect<`u`&&Reflect;q||=function(e){return e},yt||=function(e){return e},xt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},St||=function(e){return new e(...[...arguments].slice(1))};var Ct=Z(Array.prototype.forEach),wt=Z(Array.prototype.lastIndexOf),Tt=Z(Array.prototype.pop),Et=Z(Array.prototype.push),Dt=Z(Array.prototype.splice),J=Array.isArray,Ot=Z(String.prototype.toLowerCase),kt=Z(String.prototype.toString),At=Z(String.prototype.match),jt=Z(String.prototype.replace),Mt=Z(String.prototype.indexOf),Nt=Z(String.prototype.trim),Pt=Z(Number.prototype.toString),Ft=Z(Boolean.prototype.toString),It=typeof BigInt>`u`?null:Z(BigInt.prototype.toString),Lt=typeof Symbol>`u`?null:Z(Symbol.prototype.toString),Y=Z(Object.prototype.hasOwnProperty),Rt=Z(Object.prototype.toString),X=Z(RegExp.prototype.test),zt=Bt(TypeError);function Z(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return xt(e,t,n)}}function Bt(e){return function(){return St(e,[...arguments])}}function Q(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ot;if(ht&&ht(e,null),!J(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(gt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Vt(e){for(let t=0;t<e.length;t++)Y(e,t)||(e[t]=null);return e}function $(e){let t=bt(null);for(let[n,r]of mt(e))Y(e,n)&&(J(r)?t[n]=Vt(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=$(r):t[n]=r);return t}function Ht(e){switch(typeof e){case`string`:return e;case`number`:return Pt(e);case`boolean`:return Ft(e);case`bigint`:return It?It(e):`0`;case`symbol`:return Lt?Lt(e):`Symbol()`;case`undefined`:return Rt(e);case`function`:case`object`:{if(e===null)return Rt(e);let t=e,n=Ut(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Rt(e)}return Rt(e)}default:return Rt(e)}}function Ut(e,t){for(;e!==null;){let n=vt(e,t);if(n){if(n.get)return Z(n.get);if(typeof n.value==`function`)return Z(n.value)}e=_t(e)}function n(){return null}return n}function Wt(e){try{return X(e,``),!0}catch{return!1}}var Gt=q(`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.search.section.select.shadow.slot.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`.split(`.`)),Kt=q(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qt=q([`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`]),Jt=q([`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`]),Yt=q(`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`.split(`.`)),Xt=q([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Zt=q([`#text`]),Qt=q(`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.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.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.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),$t=q(`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.mask-type.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`.split(`.`)),en=q(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.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`.split(`.`)),tn=q([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nn=yt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),rn=yt(/<%[\w\W]*|[\w\W]*%>/gm),an=yt(/\$\{[\w\W]*/gm),on=yt(/^data-[\-\w.\u00B7-\uFFFF]+$/),sn=yt(/^aria-[\-\w]+$/),cn=yt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ln=yt(/^(?:\w+script|data):/i),un=yt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dn=yt(/^html$/i),fn=yt(/^[a-z][.\w]*(-[.\w]+)+$/i),pn=Object.freeze({__proto__:null,ARIA_ATTR:sn,ATTR_WHITESPACE:un,CUSTOM_ELEMENT:fn,DATA_ATTR:on,DOCTYPE_NAME:dn,ERB_EXPR:rn,IS_ALLOWED_URI:cn,IS_SCRIPT_OR_DATA:ln,MUSTACHE_EXPR:nn,TMPLIT_EXPR:an}),mn={element:1,text:3,progressingInstruction:7,comment:8,document:9},hn=function(){return typeof window>`u`?null:window},gn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},_n=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function vn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:hn(),t=e=>vn(e);if(t.version=`3.4.2`,t.removed=[],!e||!e.document||e.document.nodeType!==mn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=Ut(m,`cloneNode`),g=Ut(m,`remove`),_=Ut(m,`nextSibling`),v=Ut(m,`childNodes`),y=Ut(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=_n();t.isSupported=typeof mt==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:ee,ERB_EXPR:O,TMPLIT_EXPR:k,DATA_ATTR:te,ARIA_ATTR:ne,IS_SCRIPT_OR_DATA:re,ATTR_WHITESPACE:ie,CUSTOM_ELEMENT:ae}=pn,{IS_ALLOWED_URI:oe}=pn,A=null,se=Q({},[...Gt,...Kt,...qt,...Yt,...Zt]),j=null,ce=Q({},[...Qt,...$t,...en,...tn]),M=Object.seal(bt(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}})),le=null,ue=null,N=Object.seal(bt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),de=!0,fe=!0,pe=!1,me=!0,P=!1,he=!0,ge=!1,_e=!1,ve=!1,ye=!1,be=!1,xe=!1,Se=!0,Ce=!1,we=`user-content-`,Te=!0,Ee=!1,F={},De=null,Oe=Q({},[`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`]),ke=null,Ae=Q({},[`audio`,`video`,`img`,`source`,`image`,`track`]),I=null,L=Q({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),je=`http://www.w3.org/1998/Math/MathML`,Me=`http://www.w3.org/2000/svg`,R=`http://www.w3.org/1999/xhtml`,Ne=R,z=!1,Pe=null,Fe=Q({},[je,Me,R],kt),Ie=Q({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Le=Q({},[`annotation-xml`]),Re=Q({},[`title`,`style`,`font`,`a`,`script`]),ze=null,Be=[`application/xhtml+xml`,`text/html`],B=null,V=null,H=n.createElement(`form`),U=function(e){return e instanceof RegExp||e instanceof Function},W=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(V&&V===e)return;(!e||typeof e!=`object`)&&(e={}),e=$(e),ze=Be.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,B=ze===`application/xhtml+xml`?kt:Ot,A=Y(e,`ALLOWED_TAGS`)&&J(e.ALLOWED_TAGS)?Q({},e.ALLOWED_TAGS,B):se,j=Y(e,`ALLOWED_ATTR`)&&J(e.ALLOWED_ATTR)?Q({},e.ALLOWED_ATTR,B):ce,Pe=Y(e,`ALLOWED_NAMESPACES`)&&J(e.ALLOWED_NAMESPACES)?Q({},e.ALLOWED_NAMESPACES,kt):Fe,I=Y(e,`ADD_URI_SAFE_ATTR`)&&J(e.ADD_URI_SAFE_ATTR)?Q($(L),e.ADD_URI_SAFE_ATTR,B):L,ke=Y(e,`ADD_DATA_URI_TAGS`)&&J(e.ADD_DATA_URI_TAGS)?Q($(Ae),e.ADD_DATA_URI_TAGS,B):Ae,De=Y(e,`FORBID_CONTENTS`)&&J(e.FORBID_CONTENTS)?Q({},e.FORBID_CONTENTS,B):Oe,le=Y(e,`FORBID_TAGS`)&&J(e.FORBID_TAGS)?Q({},e.FORBID_TAGS,B):$({}),ue=Y(e,`FORBID_ATTR`)&&J(e.FORBID_ATTR)?Q({},e.FORBID_ATTR,B):$({}),F=Y(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?$(e.USE_PROFILES):e.USE_PROFILES:!1,de=e.ALLOW_ARIA_ATTR!==!1,fe=e.ALLOW_DATA_ATTR!==!1,pe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,me=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,P=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,ge=e.WHOLE_DOCUMENT||!1,ye=e.RETURN_DOM||!1,be=e.RETURN_DOM_FRAGMENT||!1,xe=e.RETURN_TRUSTED_TYPE||!1,ve=e.FORCE_BODY||!1,Se=e.SANITIZE_DOM!==!1,Ce=e.SANITIZE_NAMED_PROPS||!1,Te=e.KEEP_CONTENT!==!1,Ee=e.IN_PLACE||!1,oe=Wt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:cn,Ne=typeof e.NAMESPACE==`string`?e.NAMESPACE:R,Ie=Y(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?$(e.MATHML_TEXT_INTEGRATION_POINTS):Q({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Le=Y(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?$(e.HTML_INTEGRATION_POINTS):Q({},[`annotation-xml`]);let t=Y(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?$(e.CUSTOM_ELEMENT_HANDLING):bt(null);if(M=bt(null),Y(t,`tagNameCheck`)&&U(t.tagNameCheck)&&(M.tagNameCheck=t.tagNameCheck),Y(t,`attributeNameCheck`)&&U(t.attributeNameCheck)&&(M.attributeNameCheck=t.attributeNameCheck),Y(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(M.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),P&&(fe=!1),be&&(ye=!0),F&&(A=Q({},Zt),j=bt(null),F.html===!0&&(Q(A,Gt),Q(j,Qt)),F.svg===!0&&(Q(A,Kt),Q(j,$t),Q(j,tn)),F.svgFilters===!0&&(Q(A,qt),Q(j,$t),Q(j,tn)),F.mathMl===!0&&(Q(A,Yt),Q(j,en),Q(j,tn))),N.tagCheck=null,N.attributeCheck=null,Y(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?N.tagCheck=e.ADD_TAGS:J(e.ADD_TAGS)&&(A===se&&(A=$(A)),Q(A,e.ADD_TAGS,B))),Y(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?N.attributeCheck=e.ADD_ATTR:J(e.ADD_ATTR)&&(j===ce&&(j=$(j)),Q(j,e.ADD_ATTR,B))),Y(e,`ADD_URI_SAFE_ATTR`)&&J(e.ADD_URI_SAFE_ATTR)&&Q(I,e.ADD_URI_SAFE_ATTR,B),Y(e,`FORBID_CONTENTS`)&&J(e.FORBID_CONTENTS)&&(De===Oe&&(De=$(De)),Q(De,e.FORBID_CONTENTS,B)),Y(e,`ADD_FORBID_CONTENTS`)&&J(e.ADD_FORBID_CONTENTS)&&(De===Oe&&(De=$(De)),Q(De,e.ADD_FORBID_CONTENTS,B)),Te&&(A[`#text`]=!0),ge&&Q(A,[`html`,`head`,`body`]),A.table&&(Q(A,[`tbody`]),delete le.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw zt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw zt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=gn(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));q&&q(e),V=e},Ve=Q({},[...Kt,...qt,...Jt]),G=Q({},[...Yt,...Xt]),He=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Ne,tagName:`template`});let n=Ot(e.tagName),r=Ot(t.tagName);return Pe[e.namespaceURI]?e.namespaceURI===Me?t.namespaceURI===R?n===`svg`:t.namespaceURI===je?n===`svg`&&(r===`annotation-xml`||Ie[r]):!!Ve[n]:e.namespaceURI===je?t.namespaceURI===R?n===`math`:t.namespaceURI===Me?n===`math`&&Le[r]:!!G[n]:e.namespaceURI===R?t.namespaceURI===Me&&!Le[r]||t.namespaceURI===je&&!Ie[r]?!1:!G[n]&&(Re[n]||!Ve[n]):!!(ze===`application/xhtml+xml`&&Pe[e.namespaceURI]):!1},Ue=function(e){Et(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},We=function(e,n){try{Et(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Et(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(ye||be)try{Ue(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ge=function(e){let t=null,r=null;if(ve)e=`<remove></remove>`+e;else{let t=At(e,/^[\r\n\t ]+/);r=t&&t[0]}ze===`application/xhtml+xml`&&Ne===R&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Ne===R)try{t=new f().parseFromString(i,ze)}catch{}if(!t||!t.documentElement){t=S.createDocument(Ne,`template`,null);try{t.documentElement.innerHTML=z?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ne===R?T.call(t,ge?`html`:`body`)[0]:ge?t.documentElement:a},Ke=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},qe=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Je=function(e){return typeof s==`function`&&e instanceof s};function K(e,n,r){Ct(e,e=>{e.call(t,n,r,V)})}let Ye=function(e){let n=null;if(K(D.beforeSanitizeElements,e,null),qe(e))return Ue(e),!0;let r=B(e.nodeName);if(K(D.uponSanitizeElement,e,{tagName:r,allowedTags:A}),he&&e.hasChildNodes()&&!Je(e.firstElementChild)&&X(/<[/\w!]/g,e.innerHTML)&&X(/<[/\w!]/g,e.textContent)||he&&e.namespaceURI===R&&r===`style`&&Je(e.firstElementChild)||e.nodeType===mn.progressingInstruction||he&&e.nodeType===mn.comment&&X(/<[/\w]/g,e.data))return Ue(e),!0;if(le[r]||!(N.tagCheck instanceof Function&&N.tagCheck(r))&&!A[r]){if(!le[r]&&Qe(r)&&(M.tagNameCheck instanceof RegExp&&X(M.tagNameCheck,r)||M.tagNameCheck instanceof Function&&M.tagNameCheck(r)))return!1;if(Te&&!De[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);t.insertBefore(r,_(e))}}}return Ue(e),!0}return e instanceof c&&!He(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&X(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ue(e),!0):(P&&e.nodeType===mn.text&&(n=e.textContent,Ct([ee,O,k],e=>{n=jt(n,e,` `)}),e.textContent!==n&&(Et(t.removed,{element:e.cloneNode()}),e.textContent=n)),K(D.afterSanitizeElements,e,null),!1)},Xe=function(e,t,r){if(ue[t]||Se&&(t===`id`||t===`name`)&&(r in n||r in H))return!1;let i=j[t]||N.attributeCheck instanceof Function&&N.attributeCheck(t,e);if(!(fe&&!ue[t]&&X(te,t))&&!(de&&X(ne,t))){if(!i||ue[t]){if(!(Qe(e)&&(M.tagNameCheck instanceof RegExp&&X(M.tagNameCheck,e)||M.tagNameCheck instanceof Function&&M.tagNameCheck(e))&&(M.attributeNameCheck instanceof RegExp&&X(M.attributeNameCheck,t)||M.attributeNameCheck instanceof Function&&M.attributeNameCheck(t,e))||t===`is`&&M.allowCustomizedBuiltInElements&&(M.tagNameCheck instanceof RegExp&&X(M.tagNameCheck,r)||M.tagNameCheck instanceof Function&&M.tagNameCheck(r))))return!1}else if(!I[t]&&!X(oe,jt(r,ie,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Mt(r,`data:`)===0&&ke[e])&&!(pe&&!X(re,jt(r,ie,``)))&&r)return!1}return!0},Ze=Q({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Qe=function(e){return!Ze[Ot(e)]&&X(ae,e)},$e=function(e){K(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||qe(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=B(a),l=s,u=a===`value`?l:Nt(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,K(D.uponSanitizeAttribute,e,r),u=r.attrValue,Ce&&(c===`id`||c===`name`)&&Mt(u,we)!==0&&(We(a,e),u=we+u),he&&X(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){We(a,e);continue}if(c===`attributename`&&At(u,`href`)){We(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){We(a,e);continue}if(!me&&X(/\/>/i,u)){We(a,e);continue}P&&Ct([ee,O,k],e=>{u=jt(u,e,` `)});let d=B(e.nodeName);if(!Xe(d,c,u)){We(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),qe(e)?Ue(e):Tt(t.removed)}catch{We(a,e)}}K(D.afterSanitizeAttributes,e,null)},et=function(e){let t=null,n=Ke(e);for(K(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)K(D.uponSanitizeShadowNode,t,null),Ye(t),$e(t),t.content instanceof a&&et(t.content);K(D.afterSanitizeShadowDOM,e,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(z=!e,z&&(e=`<!-->`),typeof e!=`string`&&!Je(e)&&(e=Ht(e),typeof e!=`string`))throw zt(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(_e||W(n),t.removed=[],typeof e==`string`&&(Ee=!1),Ee){let t=e.nodeName;if(typeof t==`string`){let e=B(t);if(!A[e]||le[e])throw zt(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=Ge(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===mn.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!ye&&!P&&!ge&&e.indexOf(`<`)===-1)return b&&xe?b.createHTML(e):e;if(i=Ge(e),!i)return ye?null:xe?x:``}i&&ve&&Ue(i.firstChild);let u=Ke(Ee?e:i);for(;c=u.nextNode();)Ye(c),$e(c),c.content instanceof a&&et(c.content);if(Ee)return e;if(ye){if(P){i.normalize();let e=i.innerHTML;Ct([ee,O,k],t=>{e=jt(e,t,` `)}),i.innerHTML=e}if(be)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(j.shadowroot||j.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=ge?i.outerHTML:i.innerHTML;return ge&&A[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&X(dn,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
2
- `+d),P&&Ct([ee,O,k],e=>{d=jt(d,e,` `)}),b&&xe?b.createHTML(d):d},t.setConfig=function(){W(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),_e=!0},t.clearConfig=function(){V=null,_e=!1},t.isValidAttribute=function(e,t,n){return V||W({}),Xe(B(e),B(t),n)},t.addHook=function(e,t){typeof t==`function`&&Et(D[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=wt(D[e],t);return n===-1?void 0:Dt(D[e],n,1)[0]}return Tt(D[e])},t.removeHooks=function(e){D[e]=[]},t.removeAllHooks=function(){D=_n()},t}var yn=vn();function bn({config:e,onConfigChange:t}){let[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,w]=(0,B.useState)(``),E=(0,B.useRef)(``),ee=i!==E.current;async function O(){r(!0);try{let e=await oe();if(e.error===`no_config`)l(!1),s(null),a(``),E.current=``;else{l(!0),s(e.filePath);let t=e.content??``;a(t),E.current=t}}catch{T.error(`Failed to load agent rules`)}finally{r(!1)}}(0,B.useEffect)(()=>{O()},[]);async function te(){p(!0);try{await D(i),E.current=i,t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save agent rules`)}finally{p(!1)}}function ne(){a(E.current)}async function re(){g(!0);try{let e=await Ee();l(!0),s(e.filePath),a(``),E.current=``,t(),T.success(`Agent rules file created`)}catch{T.error(`Failed to create rules file`)}finally{g(!1)}}async function ie(e){if(v(!1),e!==o)try{await A({"workspace.agentRules":e}),t(),await O()}catch{T.error(`Failed to update file path`)}}function ae(e){e.key===`Enter`?ie(y):e.key===`Escape`&&v(!1)}function se(){if(!i.trim())return(0,V.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-12`,children:`Nothing to preview. Switch to the Edit tab to write your rules.`});let e=Re.parse(i,{async:!1});return(0,V.jsx)(`div`,{className:`markdown-preview`,role:`document`,dangerouslySetInnerHTML:{__html:yn.sanitize(e,{USE_PROFILES:{html:!0}})}})}return n?(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,V.jsx)(ze,{className:`size-5`}),`Agent Rules`]}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Custom instructions appended to the AI agent's system prompt`})]}),(0,V.jsx)(W,{children:(0,V.jsx)(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:(0,V.jsx)(I,{className:`size-5 animate-spin`})})})]}):c?(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,V.jsx)(ze,{className:`size-5`}),`Agent Rules`]}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Custom instructions appended to the AI agent's system prompt`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(M,{className:`size-4 text-muted-foreground shrink-0`}),_?(0,V.jsx)(k,{className:`font-mono text-sm`,value:y,onChange:e=>w(e.target.value),onKeyDown:ae,onBlur:()=>ie(y),placeholder:`./path-to-rules.md`,"aria-label":`Agent rules file path`,autoFocus:!0}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground truncate`,children:o}),(0,V.jsx)(j,{variant:`ghost`,size:`sm`,className:`ml-auto shrink-0`,onClick:()=>{w(o??``),v(!0)},children:`Change Path`})]})]}),(0,V.jsxs)(C,{defaultValue:`edit`,children:[(0,V.jsxs)(S,{children:[(0,V.jsxs)(b,{value:`edit`,className:`gap-1.5`,children:[(0,V.jsx)(d,{className:`size-3.5`}),`Edit`]}),(0,V.jsxs)(b,{value:`preview`,className:`gap-1.5`,children:[(0,V.jsx)(u,{className:`size-3.5`}),`Preview`]})]}),(0,V.jsx)(x,{value:`edit`,children:(0,V.jsx)(m,{className:`min-h-[300px] font-mono text-sm leading-relaxed resize-y w-full`,value:i,onChange:e=>a(e.target.value),placeholder:`Write your custom agent rules in markdown...`,"aria-label":`Agent rules markdown editor`})}),(0,V.jsx)(x,{value:`preview`,children:(0,V.jsx)(`div`,{className:`min-h-[300px] p-4 border border-border rounded-none overflow-y-auto`,children:se()})})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(j,{size:`sm`,onClick:te,disabled:f||!ee,children:f?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`}),(0,V.jsx)(j,{variant:`outline`,size:`sm`,onClick:ne,disabled:!ee,children:`Reset Changes`})]})]})]}):(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,V.jsx)(ze,{className:`size-5`}),`Agent Rules`]}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Custom instructions appended to the AI agent's system prompt`})]}),(0,V.jsx)(W,{children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center gap-4`,children:[(0,V.jsx)(ze,{className:`size-8 text-muted-foreground`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-semibold`,children:`No agent rules file configured`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Create a markdown file with custom instructions for the AI agent. Rules are appended to the system prompt after the built-in rules.`})]}),(0,V.jsx)(j,{variant:`outline`,size:`sm`,onClick:re,disabled:h,children:h?(0,V.jsx)(I,{className:`size-4 animate-spin`}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Be,{className:`size-4 mr-1`}),`Create Rules File`]})})]})})]})}function xn({config:e,onConfigChange:t}){let n=e.services?.dashboard??{},[r,i]=(0,B.useState)(String(n.port??4173)),[a,o]=(0,B.useState)(n.dbPath??``),[s,c]=(0,B.useState)(n.artifactsDir??``),[l,u]=(0,B.useState)(!1);async function d(){let e=G(r,{label:`Port`,min:1,max:65535,integer:!0});if(e.error){T.error(e.error);return}u(!0);try{await A({"services.dashboard":{port:e.value,dbPath:a,artifactsDir:s}}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{u(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Dashboard`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure dashboard server and storage paths`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`dashboard-port`,children:`Port`}),(0,V.jsx)(k,{id:`dashboard-port`,type:`number`,min:1,max:65535,step:1,value:r,onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`dashboard-db-path`,children:`Database Path`}),(0,V.jsx)(k,{id:`dashboard-db-path`,placeholder:`.agent-qa/runs.db`,value:a,onChange:e=>o(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`dashboard-artifacts-dir`,children:`Artifacts Directory`}),(0,V.jsx)(k,{id:`dashboard-artifacts-dir`,placeholder:`.agent-qa/artifacts`,value:s,onChange:e=>c(e.target.value)})]}),(0,V.jsx)(j,{size:`sm`,onClick:d,disabled:l,children:l?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function Sn({config:e,onConfigChange:t}){let n=e.workspace??{},r=n.testMatch??[],i=n.testPathIgnore??[],a=n.suiteMatch??[],[o,s]=(0,B.useState)(r.join(`
3
- `)),[c,l]=(0,B.useState)(i.join(`
4
- `)),[u,d]=(0,B.useState)(a.join(`
5
- `)),[f,p]=(0,B.useState)({}),[h,g]=(0,B.useState)(!1);async function v(){let e=o.split(`
6
- `).map(e=>e.trim()).filter(Boolean),n=c.split(`
7
- `).map(e=>e.trim()).filter(Boolean),r=u.split(`
8
- `).map(e=>e.trim()).filter(Boolean),i={};if(e.length===0&&(i.testMatch=`workspace.testMatch must contain at least one pattern.`),r.length===0&&(i.suiteMatch=`workspace.suiteMatch must contain at least one pattern.`),Object.keys(i).length>0){p(i);return}p({}),g(!0);try{await A({"workspace.testMatch":e,"workspace.suiteMatch":r,"workspace.testPathIgnore":n}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{g(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Discovery`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure test and suite discovery patterns`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`test-match`,children:`Test Match Patterns`}),(0,V.jsx)(m,{id:`test-match`,placeholder:`**/*.yaml`,value:o,"aria-invalid":f.testMatch?!0:void 0,onChange:e=>{s(e.target.value),f.testMatch&&e.target.value.split(`
9
- `).some(e=>e.trim())&&p(e=>({...e,testMatch:``}))},className:`min-h-[120px] font-mono text-sm`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One glob pattern per line`}),f.testMatch?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:f.testMatch}):null]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`suite-match`,children:`Suite Match Patterns`}),(0,V.jsx)(m,{id:`suite-match`,placeholder:`**/*.suite.yaml`,value:u,"aria-invalid":f.suiteMatch?!0:void 0,onChange:e=>{d(e.target.value),f.suiteMatch&&e.target.value.split(`
10
- `).some(e=>e.trim())&&p(e=>({...e,suiteMatch:``}))},className:`min-h-[120px] font-mono text-sm`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One glob pattern per line`}),f.suiteMatch?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:f.suiteMatch}):null]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`test-path-ignore`,children:`Test Path Ignore Patterns`}),(0,V.jsx)(m,{id:`test-path-ignore`,placeholder:`**/node_modules/**`,value:c,onChange:e=>l(e.target.value),className:`min-h-[120px] font-mono text-sm`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One glob pattern per line`})]}),(0,V.jsx)(j,{size:`sm`,onClick:v,disabled:h,children:h?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function Cn({config:e,onConfigChange:t}){let n=e.workspace??{},[r,i]=(0,B.useState)(n.hooksFile??``),[a,o]=(0,B.useState)(n.agentRules??``),[s,c]=(0,B.useState)(n.envFile??``),[l,u]=(0,B.useState)(n.secretsFile??``),[d,f]=(0,B.useState)({}),[p,m]=(0,B.useState)(!1);async function h(){let e={};if(r.trim().length===0&&(e.hooksFile=`Hooks file is required.`),a.trim().length===0&&(e.agentRules=`Agent rules file is required.`),s.trim().length===0&&(e.envFile=`Environment file is required.`),l.trim().length===0&&(e.secretsFile=`Secrets file is required.`),Object.keys(e).length>0){f(e);return}f({}),m(!0);try{await A({"workspace.hooksFile":r.trim(),"workspace.agentRules":a.trim(),"workspace.envFile":s.trim(),"workspace.secretsFile":l.trim()}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{m(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Files`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Set shared workspace file paths for hooks, environment loading, and runtime-only secrets.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`workspace-hooks-file`,children:`Hooks File`}),(0,V.jsx)(k,{id:`workspace-hooks-file`,placeholder:`tests/hooks.ts`,value:r,"aria-invalid":d.hooksFile?!0:void 0,onChange:e=>{i(e.target.value),d.hooksFile&&e.target.value.trim().length>0&&f(e=>({...e,hooksFile:``}))}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Path to the shared hooks module used across tests and suites.`}),d.hooksFile?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:d.hooksFile}):null]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`workspace-agent-rules`,children:`Agent Rules File`}),(0,V.jsx)(k,{id:`workspace-agent-rules`,placeholder:`agent-rules.md`,value:a,"aria-invalid":d.agentRules?!0:void 0,onChange:e=>{o(e.target.value),d.agentRules&&e.target.value.trim().length>0&&f(e=>({...e,agentRules:``}))}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required instructions file loaded for agent runs.`}),d.agentRules?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:d.agentRules}):null]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`workspace-env-file`,children:`Environment File`}),(0,V.jsx)(k,{id:`workspace-env-file`,placeholder:`.env.local`,value:s,"aria-invalid":d.envFile?!0:void 0,onChange:e=>{c(e.target.value),d.envFile&&e.target.value.trim().length>0&&f(e=>({...e,envFile:``}))}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required dotenv file loaded before runs start.`}),d.envFile?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:d.envFile}):null]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`workspace-secrets-file`,children:`Secrets File`}),(0,V.jsx)(k,{id:`workspace-secrets-file`,placeholder:`.secrets.local`,value:l,"aria-invalid":d.secretsFile?!0:void 0,onChange:e=>{u(e.target.value),d.secretsFile&&e.target.value.trim().length>0&&f(e=>({...e,secretsFile:``}))}}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required dotenv-style file for runtime-only secrets.`}),d.secretsFile?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:d.secretsFile}):null]}),(0,V.jsx)(j,{size:`sm`,onClick:h,disabled:p,children:p?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function wn({config:e,onConfigChange:t}){let n=(e.use??{}).logCapture??{},[r,i]=(0,B.useState)(n.console??!0),[a,o]=(0,B.useState)(n.network??!0),[s,c]=(0,B.useState)(!1);async function l(){c(!0);try{await A({"use.logCapture":{console:r,network:a}}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{c(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Log Capture`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Control the default runtime capture of console and network events.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`use-log-capture-console`,children:`Capture console logs`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Record browser console output during runs by default.`})]}),(0,V.jsx)(y,{id:`use-log-capture-console`,checked:r,onCheckedChange:i})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`use-log-capture-network`,children:`Capture network logs`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Record request and response metadata during runs by default.`})]}),(0,V.jsx)(y,{id:`use-log-capture-network`,checked:a,onCheckedChange:o})]}),(0,V.jsx)(j,{size:`sm`,onClick:l,disabled:s,children:s?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function Tn({config:e,onConfigChange:t}){let a=e.registry??{},c=e.use??{},l=(Array.isArray(a.llms)?a.llms:[]).map(e=>e.name).filter(e=>typeof e==`string`),[u,d]=(0,B.useState)(c.llm??``),[f,p]=(0,B.useState)(c.parallel??!1),[m,h]=(0,B.useState)(!1);async function g(){let e={"use.parallel":f};u&&(e[`use.llm`]=u),h(!0);try{await A(e),t(),T.success(`Runtime defaults saved`)}catch{T.error(`Runtime defaults were not saved. Fix the setting and try again.`)}finally{h(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Execution Defaults`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Set shared runtime defaults used by tests and suites.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(L,{variant:`secondary`,children:`Registry-backed`}),(0,V.jsx)(L,{variant:`outline`,className:`font-mono text-[11px]`,children:`use.llm`}),(0,V.jsx)(L,{variant:`outline`,className:`font-mono text-[11px]`,children:`use.parallel`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`use-default-llm`,children:`Default LLM`}),l.length>0?(0,V.jsxs)(s,{value:u||void 0,onValueChange:d,children:[(0,V.jsx)(i,{id:`use-default-llm`,children:(0,V.jsx)(o,{placeholder:`Select an LLM from Registry / LLMs`})}),(0,V.jsx)(r,{children:l.map(e=>(0,V.jsx)(n,{value:e,children:e},e))})]}):(0,V.jsxs)(Ve,{className:`border-dashed px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`font-medium text-foreground`,children:`No LLMs configured yet.`}),(0,V.jsx)(`div`,{children:`Add an LLM in Registry / LLMs before selecting a default.`})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This value selects from entries defined in Registry.`})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:`use-parallel`,children:`Parallel Execution`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Allow eligible web runs and suite parent jobs to share available queue slots by default.`})]}),(0,V.jsx)(y,{id:`use-parallel`,checked:f,onCheckedChange:p})]}),(0,V.jsx)(j,{size:`sm`,onClick:g,disabled:m,children:m?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Runtime Defaults`})]})]})}function En(e){let t=e.use?.mobile?.appState;return t===`preserve`||t===`reset`?t:void 0}function Dn({config:e,onConfigChange:t}){let a=En(e),[c,l]=(0,B.useState)(a??`preserve`),[u,d]=(0,B.useState)(!1);async function f(){d(!0);try{await A({"use.mobile.appState":c}),t(),T.success(`Mobile defaults saved`)}catch{T.error(`Mobile defaults were not saved. Fix the setting and try again.`)}finally{d(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Mobile`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Set native mobile app-state behavior for mobile runs.`})]}),(0,V.jsxs)(W,{children:[a?null:(0,V.jsxs)(Ve,{className:`border-dashed`,children:[(0,V.jsx)(`div`,{className:`font-medium text-foreground`,children:`Mobile app state is required.`}),(0,V.jsx)(`div`,{children:`Add use.mobile.appState to run mobile tests.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`use-mobile-app-state`,children:`App state`}),(0,V.jsxs)(s,{value:c,onValueChange:e=>l(e),children:[(0,V.jsx)(i,{id:`use-mobile-app-state`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`preserve`,children:`Preserve app data`}),(0,V.jsx)(n,{value:`reset`,children:`Reset app data`})]})]})]}),(0,V.jsx)(j,{size:`sm`,onClick:f,disabled:u,children:u?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Mobile Defaults`})]})]})}function On({config:e,onConfigChange:t}){let a=(e.services??{}).memory??{},[c,l]=(0,B.useState)(a.enabled??!0),[u,d]=(0,B.useState)(a.provider??`local`),[f,p]=(0,B.useState)(a.dir??`agent-qa-memory`),[m,h]=(0,B.useState)(String(a.minTrust??.3)),[g,v]=(0,B.useState)(String(a.maxInjections??3)),[y,b]=(0,B.useState)(a.curatorEnabled??!0),[x,S]=(0,B.useState)(String(a.curatorLockTimeout??12e4)),[C,w]=(0,B.useState)(String(a.trustConfirmDelta??.05)),[E,D]=(0,B.useState)(String(a.trustContradictDelta??.1)),[ee,O]=(0,B.useState)(a.ablationEnabled??!0),[te,ne]=(0,B.useState)(a.circuitBreakerEnabled??!0),[re,ie]=(0,B.useState)(String(a.circuitBreakerWindowSize??20)),[ae,oe]=(0,B.useState)(String(a.circuitBreakerBaselineSize??3)),[se,ce]=(0,B.useState)(String(a.circuitBreakerThreshold??.15)),[M,le]=(0,B.useState)(!1);async function ue(){let e=f.trim();if(!e){T.error(`Memory directory is required`);return}let n=G(m,{label:`Min trust`,min:0,max:1});if(n.error){T.error(n.error);return}let r=G(g,{label:`Max injections`,min:0,integer:!0});if(r.error){T.error(r.error);return}let i=G(x,{label:`Curator lock timeout`,min:1e3,integer:!0});if(i.error){T.error(i.error);return}let a=G(C,{label:`Trust confirm delta`,min:0,max:1});if(a.error){T.error(a.error);return}let o=G(E,{label:`Trust contradict delta`,min:0,max:1});if(o.error){T.error(o.error);return}let s=G(re,{label:`Circuit breaker window size`,min:5,integer:!0});if(s.error){T.error(s.error);return}let l=G(ae,{label:`Circuit breaker baseline size`,min:2,integer:!0});if(l.error){T.error(l.error);return}let d=G(se,{label:`Circuit breaker threshold`,min:0,max:1});if(d.error){T.error(d.error);return}le(!0);try{await A({"services.memory":{enabled:c,provider:u,dir:e,minTrust:n.value,maxInjections:r.value,curatorEnabled:y,curatorLockTimeout:i.value,trustConfirmDelta:a.value,trustContradictDelta:o.value,ablationEnabled:ee,circuitBreakerEnabled:te,circuitBreakerWindowSize:s.value,circuitBreakerBaselineSize:l.value,circuitBreakerThreshold:d.value}}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{le(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Memory`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Configure runtime memory injection thresholds, curator behavior, and safety guards.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-provider`,children:`Provider`}),(0,V.jsxs)(s,{value:u,onValueChange:d,children:[(0,V.jsx)(i,{id:`memory-provider`,children:(0,V.jsx)(o,{})}),(0,V.jsx)(r,{children:(0,V.jsx)(n,{value:`local`,children:`Local`})})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-dir`,children:`Memory Directory`}),(0,V.jsx)(k,{id:`memory-dir`,placeholder:`agent-qa-memory`,value:f,onChange:e=>p(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-min-trust`,children:`Min Trust`}),(0,V.jsx)(k,{id:`memory-min-trust`,type:`number`,min:`0`,max:`1`,step:`0.01`,value:m,onChange:e=>h(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-max-injections`,children:`Max Injections`}),(0,V.jsx)(k,{id:`memory-max-injections`,type:`number`,min:`0`,value:g,onChange:e=>v(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-curator-lock-timeout`,children:`Curator Lock Timeout (ms)`}),(0,V.jsx)(k,{id:`memory-curator-lock-timeout`,type:`number`,min:`1000`,step:`1000`,value:x,onChange:e=>S(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-confirm-delta`,children:`Trust Confirm Delta`}),(0,V.jsx)(k,{id:`memory-confirm-delta`,type:`number`,min:`0`,max:`1`,step:`0.01`,value:C,onChange:e=>w(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-contradict-delta`,children:`Trust Contradict Delta`}),(0,V.jsx)(k,{id:`memory-contradict-delta`,type:`number`,min:`0`,max:`1`,step:`0.01`,value:E,onChange:e=>D(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-circuit-window`,children:`Circuit Breaker Window Size`}),(0,V.jsx)(k,{id:`memory-circuit-window`,type:`number`,min:`5`,value:re,onChange:e=>ie(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-circuit-baseline`,children:`Circuit Breaker Baseline Size`}),(0,V.jsx)(k,{id:`memory-circuit-baseline`,type:`number`,min:`2`,value:ae,onChange:e=>oe(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`memory-circuit-threshold`,children:`Circuit Breaker Threshold`}),(0,V.jsx)(k,{id:`memory-circuit-threshold`,type:`number`,min:`0`,max:`1`,step:`0.01`,value:se,onChange:e=>ce(e.target.value)})]})]}),(0,V.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,V.jsx)(kn,{id:`memory-enabled`,label:`Enabled`,description:`Allow runtime memory retrieval and injection during execution.`,checked:c,onCheckedChange:l}),(0,V.jsx)(kn,{id:`memory-curator-enabled`,label:`Curator Enabled`,description:`Allow the curator to confirm, reject, and refine candidate memories.`,checked:y,onCheckedChange:b}),(0,V.jsx)(kn,{id:`memory-ablation-enabled`,label:`Ablation Enabled`,description:`Permit ablation passes that measure whether injected memories help or hurt.`,checked:ee,onCheckedChange:O}),(0,V.jsx)(kn,{id:`memory-circuit-enabled`,label:`Circuit Breaker Enabled`,description:`Temporarily suppress memory injection when observed quality regresses.`,checked:te,onCheckedChange:ne})]}),(0,V.jsx)(j,{size:`sm`,onClick:ue,disabled:M,children:M?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})}function kn({id:e,label:t,description:n,checked:r,onCheckedChange:i}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border border-border bg-transparent rounded-none px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(_,{htmlFor:e,children:t}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),(0,V.jsx)(y,{id:e,checked:r,onCheckedChange:i})]})}var An={platform:`web`,product:``,bundleId:``,appPackage:``,appActivity:``,app:{path:``,browserstack:``},url:``},jn=v(`dashboard.config.targets.product`);function Mn({config:e,onConfigChange:t}){let a=(0,B.useMemo)(()=>(e.registry??{}).targets??{},[e]),[c,l]=(0,B.useState)(a),[u,p]=(0,B.useState)(null),[m,g]=(0,B.useState)(``),[v,y]=(0,B.useState)(An),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(!1);(0,B.useEffect)(()=>{l(a)},[a]);function w(){p(null),g(``),y(An)}function E(){w(),x(!0)}function D(){return m.trim()?v.platform===`web`&&!v.url?.trim()?(T.error(`Web targets must include a URL`),!1):!0:(T.error(`Target name is required`),!1)}function ee(){if(!D())return;let e=m.trim(),t={...c};u&&u!==e&&delete t[u];let n=v.app?.path?.trim(),r=v.app?.browserstack?.trim(),i=v.platform!==`web`&&(n||r)?{...n?{path:n}:{},...r?{browserstack:r}:{}}:void 0;t[e]={platform:v.platform,...v.product?.trim()?{product:v.product.trim()}:{},...v.url?.trim()?{url:v.url.trim()}:{},...v.bundleId?.trim()?{bundleId:v.bundleId.trim()}:{},...v.appPackage?.trim()?{appPackage:v.appPackage.trim()}:{},...v.appActivity?.trim()?{appActivity:v.appActivity.trim()}:{},...i?{app:i}:{}},l(t),x(!1),w()}function O(e){let t=c[e];t&&(p(e),g(e),y({platform:t.platform,product:t.product??``,url:t.url??``,bundleId:t.bundleId??``,appPackage:t.appPackage??``,appActivity:t.appActivity??``,app:{path:t.app?.path??``,browserstack:t.app?.browserstack??``}}),x(!0))}async function te(){C(!0);try{await A({"registry.targets":c}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{C(!1)}}let ne=Object.keys(c).sort();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Targets`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage reusable named web and mobile targets referenced elsewhere in agent-qa.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border border-border bg-transparent rounded-none px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:`Reusable target entries`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use the target editor to define a named URL, bundle ID, or app package once and reference it across tests and suites.`})]}),(0,V.jsxs)(j,{size:`sm`,onClick:E,children:[(0,V.jsx)(f,{className:`size-4`}),`Add Target`]})]}),(0,V.jsx)(`div`,{className:`space-y-3`,children:ne.length===0?(0,V.jsx)(`div`,{className:`border border-dashed border-border bg-transparent rounded-none p-6 text-sm text-muted-foreground`,children:`No targets configured. Add a named target to make it selectable across tests and suites.`}):ne.map(e=>{let t=c[e];return(0,V.jsx)(`div`,{className:`border border-border bg-transparent rounded-none px-4 py-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:e}),(0,V.jsx)(L,{variant:`secondary`,children:t.platform})]}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Nn(t)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>O(e),children:[(0,V.jsx)(d,{className:`size-4`}),`Edit`]}),(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>l(t=>{let n={...t};return delete n[e],n}),children:[(0,V.jsx)(h,{className:`size-4`}),`Delete`]})]})]})},e)})}),(0,V.jsx)(j,{size:`sm`,onClick:te,disabled:S,children:S?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]}),(0,V.jsx)(pe,{open:b,onOpenChange:e=>{x(e),e||w()},children:(0,V.jsxs)(be,{className:`sm:max-w-xl`,children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:u?`Edit ${u}`:`Add Target`}),(0,V.jsx)(ye,{children:`Update the target entry in this section draft. Use Save Changes in the section to persist it to config.`})]}),(0,V.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`target-name`,children:`Target Name`}),(0,V.jsx)(k,{id:`target-name`,placeholder:`staging-web`,value:m,onChange:e=>g(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`target-platform`,children:`Platform`}),(0,V.jsxs)(s,{value:v.platform,onValueChange:e=>y(t=>({...t,platform:e})),children:[(0,V.jsx)(i,{id:`target-platform`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`web`,children:`Web`}),(0,V.jsx)(n,{value:`android`,children:`Android`}),(0,V.jsx)(n,{value:`ios`,children:`iOS`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`target-product`,children:`Product`}),(0,V.jsx)(k,{id:`target-product`,placeholder:jn,value:v.product??``,onChange:e=>y(t=>({...t,product:e.target.value}))})]}),v.platform===`web`?(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`target-url`,children:`URL`}),(0,V.jsx)(k,{id:`target-url`,placeholder:`https://staging.example.com`,value:v.url??``,onChange:e=>y(t=>({...t,url:e.target.value}))})]}):(0,V.jsxs)(V.Fragment,{children:[v.platform===`ios`?(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`target-bundle-id`,children:`Bundle ID`}),(0,V.jsx)(k,{id:`target-bundle-id`,placeholder:`com.example.ios`,value:v.bundleId??``,onChange:e=>y(t=>({...t,bundleId:e.target.value}))})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`target-app-package`,children:`App Package`}),(0,V.jsx)(k,{id:`target-app-package`,placeholder:`com.example.android`,value:v.appPackage??``,onChange:e=>y(t=>({...t,appPackage:e.target.value}))})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`target-app-activity`,children:`App Activity`}),(0,V.jsx)(k,{id:`target-app-activity`,placeholder:`.MainActivity`,value:v.appActivity??``,onChange:e=>y(t=>({...t,appActivity:e.target.value}))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`target-app-path`,children:`App Path`}),(0,V.jsx)(k,{id:`target-app-path`,placeholder:`apps/wikipedia-alpha.apk`,value:v.app?.path??``,onChange:e=>y(t=>({...t,app:{...t.app??{},path:e.target.value}}))})]}),(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`target-browserstack-app`,children:`BrowserStack App`}),(0,V.jsx)(k,{id:`target-browserstack-app`,placeholder:`bs://... or custom_id`,value:v.app?.browserstack??``,onChange:e=>y(t=>({...t,app:{...t.app??{},browserstack:e.target.value}}))})]})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:()=>x(!1),children:`Cancel`}),(0,V.jsx)(j,{onClick:ee,children:u?`Apply Target Changes`:`Add Target to Section`})]})]})})]})}function Nn(e){let t=Pn(e),n=e=>t?`${e} | App: ${t}`:e;if(e.platform===`web`)return e.url??`Web target without URL`;if(e.platform===`ios`)return n(e.bundleId??`iOS target`);let r=[e.appPackage,e.appActivity].filter(Boolean);return n(r.length>0?r.join(` / `):`Android target`)}function Pn(e){if(e.platform===`web`)return null;let t=[e.app?.path,e.app?.browserstack].filter(Boolean);return t.length>0?t.join(` / `):null}var Fn=[{value:`local`,label:`Local`},{value:`browserstack`,label:`BrowserStack`}],In={android:[`avd`,`serial`,`appPackage`,`appActivity`,`automationName`,`browserName`,`platformVersion`],ios:[`udid`,`bundleId`,`automationName`,`platformVersion`]},Ln={platform:`android`,transport:`local`,match:{}};function Rn({config:e,onConfigChange:t}){let a=(0,B.useMemo)(()=>(e.registry??{}).devices??{},[e]),[c,l]=(0,B.useState)(a),[u,p]=(0,B.useState)(null),[g,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(Ln),[x,S]=(0,B.useState)(`{}`),[C,w]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1);(0,B.useEffect)(()=>{l(a)},[a]);function ee(){p(null),v(``),b(Ln),S(`{}`)}function O(){ee(),w(!0)}function te(){try{let e=JSON.parse(x||`{}`);if(!e||typeof e!=`object`||Array.isArray(e))return T.error(`Device match must be a JSON object`),null;let t=e;if(y.transport===`local`){let e=In[y.platform],n=Object.keys(t).filter(t=>!e.includes(t));if(n.length>0)return T.error(`Invalid local match fields: ${n.join(`, `)}`),null}return t}catch{return T.error(`Device match must be valid JSON`),null}}function ne(){if(!g.trim()){T.error(`Device name is required`);return}let e=te();if(!e)return;let t=g.trim(),n={...c};u&&u!==t&&delete n[u],n[t]={platform:y.platform,transport:y.transport,match:e},l(n),w(!1),ee()}function re(e){let t=c[e];t&&(p(e),v(e),b({platform:t.platform,transport:t.transport,match:t.match??{}}),S(JSON.stringify(t.match??{},null,2)),w(!0))}async function ie(){D(!0);try{await A({"registry.devices":c}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{D(!1)}}let ae=Object.keys(c).sort();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Devices`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage reusable named device profiles and transport matching rules.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border border-border bg-transparent rounded-none px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:`Reusable device profiles`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Store a platform, transport, and match contract once, then reference it from execution defaults or per-test overrides.`})]}),(0,V.jsxs)(j,{size:`sm`,onClick:O,children:[(0,V.jsx)(f,{className:`size-4`}),`Add Device`]})]}),(0,V.jsx)(`div`,{className:`space-y-3`,children:ae.length===0?(0,V.jsx)(`div`,{className:`border border-dashed border-border bg-transparent rounded-none p-6 text-sm text-muted-foreground`,children:`No devices configured. Add a named device profile to make it selectable in runtime defaults.`}):ae.map(e=>{let t=c[e];return(0,V.jsx)(`div`,{className:`border border-border bg-transparent rounded-none px-4 py-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:e}),(0,V.jsx)(L,{variant:`secondary`,children:t.platform}),(0,V.jsx)(L,{variant:`outline`,children:t.transport})]}),(0,V.jsx)(`pre`,{className:`overflow-auto rounded-none bg-muted/40 p-3 text-xs text-muted-foreground`,children:JSON.stringify(t.match??{},null,2)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>re(e),children:[(0,V.jsx)(d,{className:`size-4`}),`Edit`]}),(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>l(t=>{let n={...t};return delete n[e],n}),children:[(0,V.jsx)(h,{className:`size-4`}),`Delete`]})]})]})},e)})}),(0,V.jsx)(j,{size:`sm`,onClick:ie,disabled:E,children:E?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]}),(0,V.jsx)(pe,{open:C,onOpenChange:e=>{w(e),e||ee()},children:(0,V.jsxs)(be,{className:`sm:max-w-xl`,children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:u?`Edit ${u}`:`Add Device`}),(0,V.jsx)(ye,{children:`Update the device entry in this section draft. Use Save Changes in the section to persist it to config.`})]}),(0,V.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`device-name`,children:`Device Name`}),(0,V.jsx)(k,{id:`device-name`,placeholder:`ios-local`,value:g,onChange:e=>v(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`device-platform`,children:`Platform`}),(0,V.jsxs)(s,{value:y.platform,onValueChange:e=>b(t=>({...t,platform:e})),children:[(0,V.jsx)(i,{id:`device-platform`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`android`,children:`Android`}),(0,V.jsx)(n,{value:`ios`,children:`iOS`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`device-transport`,children:`Transport`}),(0,V.jsxs)(s,{value:y.transport,onValueChange:e=>b(t=>({...t,transport:e})),children:[(0,V.jsx)(i,{id:`device-transport`,children:(0,V.jsx)(o,{})}),(0,V.jsx)(r,{children:Fn.map(e=>(0,V.jsx)(n,{value:e.value,children:e.label},e.value))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,V.jsx)(_,{htmlFor:`device-match`,children:`Match JSON`}),(0,V.jsx)(m,{id:`device-match`,className:`min-h-[160px] font-mono text-sm`,value:x,onChange:e=>S(e.target.value)}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Local transport fields for `,y.platform,`:`,` `,(0,V.jsx)(`span`,{className:`font-mono`,children:In[y.platform].join(`, `)})]})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:()=>w(!1),children:`Cancel`}),(0,V.jsx)(j,{onClick:ne,children:u?`Apply Device Changes`:`Add Device to Section`})]})]})})]})}function zn({config:e,onConfigChange:t}){let n=(0,B.useMemo)(()=>(e.registry??{}).providers??{},[e]),[r,i]=(0,B.useState)(n),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(`{}`),[p,g]=(0,B.useState)(!1),[v,y]=(0,B.useState)(!1);(0,B.useEffect)(()=>{i(n)},[n]);function b(){o(null),c(``),u(`{}`)}function x(){b(),g(!0)}function S(){try{let e=JSON.parse(l||`{}`);return!e||typeof e!=`object`||Array.isArray(e)?(T.error(`Provider config must be a JSON object`),null):e}catch{return T.error(`Provider config must be valid JSON`),null}}function C(){if(!s.trim()){T.error(`Provider key is required`);return}let e=S();if(!e)return;let t=s.trim(),n={...r};a&&a!==t&&delete n[a],n[t]=e,i(n),g(!1),b()}function w(e){o(e),c(e),u(JSON.stringify(r[e]??{},null,2)),g(!0)}async function E(){y(!0);try{await A({"registry.providers":r}),t(),T.success(`Changes saved`)}catch{T.error(`Failed to save configuration`)}finally{y(!1)}}let D=Object.keys(r).sort();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Providers`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Store provider-keyed integration config for BrowserStack and other supported remote services.`})]}),(0,V.jsxs)(W,{children:[(0,V.jsxs)(`div`,{className:`space-y-3 border border-border bg-transparent rounded-none px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:`Provider integration registry`}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use this when a transport or integration expects provider-specific JSON keyed by provider name.`})]}),(0,V.jsxs)(j,{size:`sm`,onClick:x,children:[(0,V.jsx)(f,{className:`size-4`}),`Add Provider`]})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The schema is intentionally open-ended. The dashboard keeps the editor as raw JSON, parses it locally, and the config backend validates the final object again on save.`})]}),(0,V.jsx)(`div`,{className:`space-y-3`,children:D.length===0?(0,V.jsx)(`div`,{className:`border border-dashed border-border bg-transparent rounded-none p-6 text-sm text-muted-foreground`,children:`No providers configured. Add provider JSON when a remote integration needs named credentials or settings.`}):D.map(e=>(0,V.jsx)(`div`,{className:`border border-border bg-transparent rounded-none px-4 py-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:e}),(0,V.jsx)(L,{variant:`secondary`,children:`Integration JSON`})]}),(0,V.jsx)(`pre`,{className:`overflow-auto rounded-none bg-muted/40 p-3 text-xs text-muted-foreground`,children:JSON.stringify(r[e]??{},null,2)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>w(e),children:[(0,V.jsx)(d,{className:`size-4`}),`Edit`]}),(0,V.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>i(t=>{let n={...t};return delete n[e],n}),children:[(0,V.jsx)(h,{className:`size-4`}),`Delete`]})]})]})},e))}),(0,V.jsx)(j,{size:`sm`,onClick:E,disabled:v,children:v?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]}),(0,V.jsx)(pe,{open:p,onOpenChange:e=>{g(e),e||b()},children:(0,V.jsxs)(be,{className:`sm:max-w-xl`,children:[(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{children:a?`Edit ${a}`:`Add Provider`}),(0,V.jsx)(ye,{children:`Update the provider entry in this section draft. Use Save Changes in the section to persist it to config.`})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`provider-key`,children:`Provider Key`}),(0,V.jsx)(k,{id:`provider-key`,placeholder:`browserstack`,value:s,onChange:e=>c(e.target.value)})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`provider-json`,children:`Provider JSON`}),(0,V.jsx)(m,{id:`provider-json`,className:`min-h-[200px] font-mono text-sm`,value:l,onChange:e=>u(e.target.value)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Keep provider payloads honest to the integration contract. This surface does not invent provider-specific forms.`})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(j,{variant:`outline`,onClick:()=>g(!1),children:`Cancel`}),(0,V.jsx)(j,{onClick:C,children:a?`Apply Provider Changes`:`Add Provider to Section`})]})]})})]})}function Bn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vn(e){let t=Bn(e.analytics)?e.analytics:{},n=Bn(t.passRateScope)?t.passRateScope:{},r=Bn(n.attributes)?n.attributes:{},i=[];for(let[e,[t,n]]of Object.entries(r).entries()){if(typeof n==`string`){i.push({id:`existing-${e}`,key:t,mode:`exact`,value:n});continue}Bn(n)&&typeof n.regex==`string`&&i.push({id:`existing-${e}`,key:t,mode:`regex`,value:n.regex})}return i}function Hn(e){let t={},n=new Set;for(let r of e){let e=r.key.trim(),i=r.value.trim();if(e.length>0||i.length>0){if(!e)return{error:`Attribute key is required.`};if(!i)return{error:`Value is required for ${e}.`};if(n.has(e))return{error:`Duplicate attribute key: ${e}`};if(r.mode===`regex`){try{new RegExp(i)}catch{return{error:`Invalid regex for ${e}.`}}t[e]={regex:i}}else t[e]=i;n.add(e)}}return{value:{attributes:t}}}function Un({config:e,onConfigChange:t}){let[a,c]=(0,B.useState)(()=>Vn(e)),[l,u]=(0,B.useState)(!1);function d(e,t){c(n=>n.map(n=>n.id===e?{...n,...t}:n))}function p(){c(e=>[...e,{id:`new-${Date.now()}-${e.length}`,key:``,mode:`exact`,value:``}])}function m(e){c(t=>t.filter(t=>t.id!==e))}async function g(){let e=Hn(a);if(`error`in e){T.error(e.error);return}u(!0);try{await A({"analytics.passRateScope":e.value}),t(),T.success(`Configuration saved`)}catch{T.error(`Failed to save configuration`)}finally{u(!1)}}return(0,V.jsxs)(H,{children:[(0,V.jsxs)(U,{children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:`Pass Rate Scope`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose run attributes for scoped pass rate, flaky score, and test/suite analytics values.`})]}),(0,V.jsxs)(W,{children:[a.length===0?(0,V.jsx)(Ve,{className:`border-dashed`,children:`No scoped attributes configured. Add at least one attribute to enable scoped analytics.`}):(0,V.jsxs)(`div`,{className:`overflow-hidden border border-border`,children:[(0,V.jsxs)(`div`,{className:`hidden grid-cols-[minmax(160px,1fr)_120px_minmax(160px,1fr)_44px] gap-3 border-b border-border px-3 py-2 text-xs text-muted-foreground md:grid`,children:[(0,V.jsx)(`span`,{children:`Key`}),(0,V.jsx)(`span`,{children:`Match`}),(0,V.jsx)(`span`,{children:`Value`}),(0,V.jsx)(`span`,{})]}),(0,V.jsx)(`div`,{className:`divide-y divide-border`,children:a.map(e=>(0,V.jsxs)(`div`,{className:`grid grid-cols-1 items-end gap-3 px-3 py-3 md:grid-cols-[minmax(160px,1fr)_120px_minmax(160px,1fr)_44px]`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`analytics-scope-key-${e.id}`,className:`sr-only`,children:`Attribute key`}),(0,V.jsx)(k,{id:`analytics-scope-key-${e.id}`,"data-testid":`analytics-scope-key`,value:e.key,placeholder:`git.branch`,onChange:t=>d(e.id,{key:t.target.value})})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`analytics-scope-mode-${e.id}`,className:`sr-only`,children:`Attribute match mode`}),(0,V.jsxs)(s,{value:e.mode,onValueChange:t=>d(e.id,{mode:t}),children:[(0,V.jsx)(i,{id:`analytics-scope-mode-${e.id}`,children:(0,V.jsx)(o,{})}),(0,V.jsxs)(r,{children:[(0,V.jsx)(n,{value:`exact`,children:`Exact`}),(0,V.jsx)(n,{value:`regex`,children:`Regex`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(_,{htmlFor:`analytics-scope-value-${e.id}`,className:`sr-only`,children:`Attribute value`}),(0,V.jsx)(k,{id:`analytics-scope-value-${e.id}`,"data-testid":`analytics-scope-value`,value:e.value,placeholder:e.mode===`regex`?`^(main|master)$`:`master`,onChange:t=>d(e.id,{value:t.target.value})})]}),(0,V.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>m(e.id),"aria-label":`Remove ${e.key||`attribute`}`,children:(0,V.jsx)(h,{className:`size-4`})})]},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsxs)(j,{type:`button`,variant:`outline`,size:`sm`,onClick:p,children:[(0,V.jsx)(f,{className:`size-4`}),`Add Attribute`]}),(0,V.jsx)(j,{type:`button`,size:`sm`,onClick:g,disabled:l,children:l?(0,V.jsx)(I,{className:`size-4 animate-spin`}):`Save Changes`})]})]})]})}var Wn={"workspace:discovery":Sn,"workspace:files":Cn,"workspace:agent-rules":bn,"services:dashboard":xn,"services:cache":ct,"services:logging":lt,"services:recording":dt,"services:accessibility":ft,"services:memory":On,"registry:llms":it,"registry:targets":Mn,"registry:devices":Rn,"registry:providers":zn,"use:browser":ut,"use:timeouts":ot,"use:healing":st,"use:planner":pt,"use:log-capture":wn,"use:mobile":Dn,"use:execution-defaults":Tn,"analytics:pass-rate-scope":Un};function Gn(){g(`Config`);let e=fe(),[c]=Ce(),[l,u]=(0,B.useState)({}),[d,f]=(0,B.useState)(!0),[p,m]=(0,B.useState)(!1),h=(0,B.useMemo)(()=>de(c),[c]),_=(0,B.useMemo)(()=>F(h,c),[c,h]),v=`?${_.toString()}`,y=c.toString(),b=y===_.toString(),x=Oe(h.bucket).find(e=>e.item===h.item),S=Wn[`${h.bucket}:${h.item}`];(0,B.useEffect)(()=>{b||(y.length>0&&m(!0),e(`${w.config}?${_.toString()}`,{replace:!0}))},[_,e,y,b]);async function C(){try{u((await ce()).config)}catch{T.error(`Failed to load configuration`)}finally{f(!1)}}(0,B.useEffect)(()=>{C()},[]);function E(t,n){m(!1);let r=F({bucket:t,item:n},c);e(`${w.config}?${r.toString()}`)}return d?(0,V.jsx)(ge,{}):(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:`Configuration`}),(0,V.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage workspace, services, registry, and runtime defaults.`})]}),(0,V.jsxs)(`div`,{className:`grid gap-0 lg:grid-cols-[minmax(240px,256px)_minmax(0,1fr)] lg:items-start`,children:[(0,V.jsx)(`aside`,{"data-config-rail":!0,className:`hidden border-r border-border pr-4 lg:block`,children:(0,V.jsx)(`div`,{className:`space-y-5 py-1`,children:we.map(e=>(0,V.jsx)(Kn,{bucket:e,selectedItem:h.item,onSelect:E},e))})}),(0,V.jsxs)(`main`,{"data-config-main":!0,className:`min-w-0 lg:pl-6`,children:[(0,V.jsxs)(`div`,{"data-config-page-root":!0,className:`grid gap-0`,children:[(0,V.jsx)(`section`,{"data-config-mobile-selector":!0,className:`border-b border-border pb-4 lg:hidden`,children:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Select Setting`}),(0,V.jsxs)(s,{value:`${h.bucket}:${h.item}`,onValueChange:e=>{let[t,n]=e.split(`:`);E(t,n)},children:[(0,V.jsx)(i,{"aria-label":`Select config setting`,children:(0,V.jsx)(o,{})}),(0,V.jsx)(r,{children:we.map(e=>(0,V.jsxs)(a,{children:[(0,V.jsx)(t,{children:Oe(e)[0]?.bucketLabel??e}),Oe(e).map(e=>(0,V.jsx)(n,{value:`${e.bucket}:${e.item}`,children:e.itemLabel},`${e.bucket}:${e.item}`))]},e))})]})]})}),(0,V.jsxs)(`section`,{className:`space-y-4 pt-4 lg:pt-0`,children:[p&&(0,V.jsx)(`div`,{"data-config-invalid-notice":!0,className:`border-b border-border py-3 text-sm text-muted-foreground`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{children:`Setting not found.`}),(0,V.jsx)(`span`,{children:`Showing the closest valid config section instead.`}),(0,V.jsx)(L,{variant:`secondary`,className:`font-mono text-[11px]`,children:v})]})}),(0,V.jsxs)(`header`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(L,{variant:`secondary`,children:x.bucketLabel}),(0,V.jsx)(L,{variant:`outline`,children:x.itemLabel})]}),(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`h3`,{className:`text-xl font-semibold tracking-tight`,children:x.title}),(0,V.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:x.description})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:x.fieldPaths.map(e=>(0,V.jsx)(L,{variant:`outline`,className:`font-mono text-[11px]`,children:e},e))})]})]})]}),(0,V.jsx)(`div`,{className:`mt-4`,children:S?(0,V.jsx)(S,{config:l,onConfigChange:C}):(0,V.jsx)(qn,{item:x})})]})]})]})}function Kn({bucket:e,selectedItem:t,onSelect:n}){let r=Oe(e);return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:r[0]?.bucketLabel??e}),(0,V.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>n(e.bucket,e.item),className:ue(`relative w-full border-l-2 border-transparent px-3 py-2 text-left text-sm transition-colors`,e.item===t?`border-primary text-foreground font-medium`:`text-muted-foreground hover:border-border hover:text-foreground`),children:e.itemLabel},`${e.bucket}:${e.item}`))})]})}function qn({item:e}){return(0,V.jsxs)(Ve,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-base font-medium text-foreground`,children:`Missing config surface`}),(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No editor is registered for `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[e.bucket,`/`,e.item]}),`.`]})]})}export{Gn as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Mn as t,Qn as n,kn as r,pr as i,wn as a}from"./index-B4FdO6Vk.js";var o=e(i(),1),s=n();function c(e){let n=e+`CollectionProvider`,[i,c]=a(n),[l,u]=i(n,{collectionRef:{current:null},itemMap:new Map}),d=e=>{let{scope:t,children:n}=e,r=o.useRef(null),i=o.useRef(new Map).current;return(0,s.jsx)(l,{scope:t,itemMap:i,collectionRef:r,children:n})};d.displayName=n;let f=e+`CollectionSlot`,p=r(f),m=o.forwardRef((e,n)=>{let{scope:r,children:i}=e;return(0,s.jsx)(p,{ref:t(n,u(f,r).collectionRef),children:i})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=o.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,c=o.useRef(null),l=t(n,c),d=u(h,r);return o.useEffect(()=>(d.itemMap.set(c,{ref:c,...a}),()=>void d.itemMap.delete(c))),(0,s.jsx)(_,{[g]:``,ref:l,children:i})});v.displayName=h;function y(t){let n=u(e+`CollectionConsumer`,t);return o.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:d,Slot:m,ItemSlot:v},y,c]}export{c as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{d as t,f as n,i as r,n as i,o as a,r as o,t as s,u as c}from"./tab-console-BORDNFzI.js";import{i as ee,n as l,o as u,s as d,t as te,u as ne}from"./select-D5oFJNaq.js";import{C as f,c as re,i as p,n as m,r as h,w as g}from"./id-badge-BmmZdbHv.js";import{r as ie}from"./monaco-editor-DF4W-NC-.js";import{t as _}from"./circle-x-B7AOkLOS.js";import{t as ae}from"./copy-CEZJVgtu.js";import{t as v}from"./eye-YQHiLgt4.js";import{t as oe}from"./file-search-LR6NeRNh.js";import{c as se}from"./split-button-wGcE-JDx.js";import{t as y}from"./refresh-cw-RAow1kax.js";import{t as ce}from"./square-CgFZz_zK.js";import{a as b}from"./dist-wK15YRiu.js";import{t as x}from"./scroll-area-BmkJ1y7Q.js";import{t as S}from"./switch-CPd0R3ri.js";import{i as C,n as le,r as ue,t as de}from"./tabs-DzjvuMEX.js";import{B as w,Fn as fe,Gn as pe,H as T,Ht as E,Jn as me,Nn as he,Pn as D,Qn as O,Rn as ge,Un as _e,Ut as k,Vt as A,W as j,Wn as ve,Wt as M,bt as N,er as ye,or as be,pr as P,qt as xe,tr as F,zn as I}from"./index-B4FdO6Vk.js";import{t as L}from"./badge-CC1v3nk4.js";import{n as Se,r as Ce,t as we}from"./resizable-B2X6KlcC.js";import{t as R}from"./empty-state-BfgY0UGA.js";import{t as z}from"./display-step-CO4k5dQA.js";var B=me(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Te=me(`wifi-off`,[[`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`}]]),V=e(P(),1);function H(e){function t(e){if(h(e)){e.flow=!1;for(let n of e.items)t(n.value)}if(p(e)){e.flow=!1;for(let n of e.items)t(n)}}t(e.contents)}function Ee(e){function t(e){return h(e)?(e.items=e.items.filter(e=>!t(e.value)),e.items.length===0):!1}t(e.contents)}var De=[`name`,`test-id`,`target`,`use`,`meta`,`context`,`steps`];function Oe(e){function t(e,n){if(h(e)){n?e.items.sort((e,t)=>{let n=De.indexOf(String(e.key)),r=De.indexOf(String(t.key));return(n===-1?De.length:n)-(r===-1?De.length:r)}):e.items.sort((e,t)=>String(e.key).localeCompare(String(t.key)));for(let n of e.items)t(n.value,!1)}}t(e.contents,!0)}function ke(e){return Ee(e),H(e),Oe(e),e.toString()}function Ae(e){let t=(0,V.useRef)(null),{doc:n,error:r}=(0,V.useMemo)(()=>{if(!e)return{doc:null,error:null};try{let n=m(e);return t.current=n,{doc:n,error:null}}catch(e){return{doc:t.current,error:e instanceof Error?e.message:`Invalid YAML`}}},[e]);return{doc:n,error:r,getIn:(0,V.useCallback)(e=>{if(n)return n.getIn(e)},[n]),setIn:(0,V.useCallback)((t,n)=>{let r=m(e);return r.setIn(t,n),ke(r)},[e]),deleteIn:(0,V.useCallback)(t=>{let n=m(e);return n.deleteIn(t),ke(n)},[e])}}var U=O(),je=[{value:`chromium`,label:`Chromium`},{value:`firefox`,label:`Firefox`},{value:`webkit`,label:`WebKit`}];function W(e){return e==null?``:`${e} (inherited)`}function Me(e){return e===!0?`(inherited: on)`:e===!1?`(inherited: off)`:`(inherited)`}function G(e){return e===`preserve`?`Preserve app data (inherited)`:e===`reset`?`Reset app data (inherited)`:`Select app state`}function Ne({content:e,onChange:t,selectedTarget:n,showMeta:r=!0}){let{getIn:i,setIn:a,deleteIn:o}=Ae(e);function s(e,n){t(n===``||n==null?o(e):a(e,n))}function c(e,n,r){t(n===(r??!1)?o(e):a(e,n))}let{targets:ne,globalUse:f}=re(),p=n?ne[n]?.platform:void 0,m=p===`android`||p===`ios`,h=i([`use`,`browser`,`name`]),g=i([`use`,`browser`,`headless`]),ie=i([`use`,`browser`,`viewport`,`width`]),_=i([`use`,`browser`,`viewport`,`height`]),ae=i([`use`,`timeout`,`step`]),v=i([`use`,`timeout`,`test`]),oe=i([`use`,`timeout`,`navigation`]),se=i([`use`,`healing`,`maxAttempts`]),y=i([`use`,`planner`,`maxSubActions`]),ce=i([`use`,`planner`,`previousStepCount`]),x=i([`use`,`logCapture`,`console`]),C=i([`use`,`logCapture`,`network`]),le=i([`use`,`llm`]),ue=i([`use`,`parallel`]),de=i([`use`,`device`]),w=i([`use`,`mobile`,`appState`]),fe=i([`meta`,`retries`]),pe=i([`meta`,`record`]),T=f?.browser?.headless,me=f?.logCapture?.console,he=f?.logCapture?.network,D=f?.parallel,O=f?.mobile?.appState,ge=r?`Select a device for this mobile test.`:`Select a device for this mobile suite.`;function _e(e){t(e===O?o([`use`,`mobile`,`appState`]):a([`use`,`mobile`,`appState`],e))}return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-1 opacity-50`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Browser`}),(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Not applicable to mobile targets`})]}),(0,U.jsx)(A,{})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Browser`}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Engine`}),(0,U.jsxs)(te,{value:h??``,onValueChange:e=>s([`use`,`browser`,`name`],e||void 0),children:[(0,U.jsx)(u,{className:`w-full h-7 text-xs`,children:(0,U.jsx)(d,{placeholder:W(f?.browser?.name??`chromium`)})}),(0,U.jsx)(l,{children:je.map(e=>(0,U.jsx)(ee,{value:e.value,children:e.label},e.value))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(b,{className:`text-[11px] text-muted-foreground`,children:[`Headless `,g===void 0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:Me(T)})]}),(0,U.jsx)(S,{checked:g??T??!0,onCheckedChange:e=>c([`use`,`browser`,`headless`],e,T)})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Viewport W`}),(0,U.jsx)(E,{type:`number`,value:ie??``,onChange:e=>s([`use`,`browser`,`viewport`,`width`],e.target.value?Number(e.target.value):void 0),placeholder:W(f?.browser?.viewport?.width??1280),className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Viewport H`}),(0,U.jsx)(E,{type:`number`,value:_??``,onChange:e=>s([`use`,`browser`,`viewport`,`height`],e.target.value?Number(e.target.value):void 0),placeholder:W(f?.browser?.viewport?.height??720),className:`h-7 text-xs`})]})]})]}),(0,U.jsx)(A,{})]}),m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Mobile`}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Device`}),(0,U.jsx)(E,{value:de??``,onChange:e=>s([`use`,`device`],e.target.value||void 0),placeholder:ge,className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`App state`}),(0,U.jsxs)(te,{value:w??``,onValueChange:e=>_e(e),children:[(0,U.jsx)(u,{className:`w-full h-7 text-xs`,children:(0,U.jsx)(d,{placeholder:G(O)})}),(0,U.jsxs)(l,{children:[(0,U.jsx)(ee,{value:`preserve`,children:`Preserve app data`}),(0,U.jsx)(ee,{value:`reset`,children:`Reset app data`})]})]})]})]}),(0,U.jsx)(A,{})]}):null,(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Timeouts`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Step`}),(0,U.jsx)(E,{value:ae??``,onChange:e=>s([`use`,`timeout`,`step`],e.target.value||void 0),placeholder:W(f?.timeout?.step??`30s`),className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Test`}),(0,U.jsx)(E,{value:v??``,onChange:e=>s([`use`,`timeout`,`test`],e.target.value||void 0),placeholder:W(f?.timeout?.test??`5m`),className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Navigation`}),(0,U.jsx)(E,{value:oe??``,onChange:e=>s([`use`,`timeout`,`navigation`],e.target.value||void 0),placeholder:W(f?.timeout?.navigation??`15s`),className:`h-7 text-xs`})]})]})]}),(0,U.jsx)(A,{}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Agent`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Heal Attempts`}),(0,U.jsx)(E,{type:`number`,min:0,value:se??``,onChange:e=>s([`use`,`healing`,`maxAttempts`],e.target.value?Number(e.target.value):void 0),placeholder:W(f?.healing?.maxAttempts??3),className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Sub-Actions`}),(0,U.jsx)(E,{type:`number`,min:1,value:y??``,onChange:e=>s([`use`,`planner`,`maxSubActions`],e.target.value?Number(e.target.value):void 0),placeholder:W(f?.planner?.maxSubActions??5),className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Prev Steps`}),(0,U.jsx)(E,{type:`number`,min:0,value:ce??``,onChange:e=>s([`use`,`planner`,`previousStepCount`],e.target.value?Number(e.target.value):void 0),placeholder:W(f?.planner?.previousStepCount??3),className:`h-7 text-xs`})]})]})]}),(0,U.jsx)(A,{}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Log Capture`}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(b,{className:`text-[11px] text-muted-foreground`,children:[`Console `,x===void 0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:Me(me)})]}),(0,U.jsx)(S,{checked:x??me??!1,onCheckedChange:e=>c([`use`,`logCapture`,`console`],e,me)})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(b,{className:`text-[11px] text-muted-foreground`,children:[`Network `,C===void 0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:Me(he)})]}),(0,U.jsx)(S,{checked:C??he??!1,onCheckedChange:e=>c([`use`,`logCapture`,`network`],e,he)})]})]}),(0,U.jsx)(A,{}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`LLM`}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`LLM Config`}),(0,U.jsx)(E,{value:le??``,onChange:e=>s([`use`,`llm`],e.target.value||void 0),placeholder:W(f?.llm??`default`),className:`h-7 text-xs`})]})]}),(0,U.jsx)(A,{}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:`Execution`}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(b,{className:`text-[11px] text-muted-foreground`,children:[`Parallel `,ue===void 0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:Me(D)})]}),(0,U.jsx)(S,{checked:ue??D??!1,onCheckedChange:e=>c([`use`,`parallel`],e,D)})]}),r&&(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(b,{className:`text-[11px] text-muted-foreground`,children:`Retries`}),(0,U.jsx)(E,{type:`number`,min:0,value:fe??``,onChange:e=>s([`meta`,`retries`],e.target.value?Number(e.target.value):void 0),placeholder:`0 (inherited)`,className:`h-7 text-xs`})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsxs)(b,{className:`text-[11px] text-muted-foreground`,children:[`Record `,pe===void 0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:`(inherited: off)`})]}),(0,U.jsx)(`div`,{className:`flex items-center h-7`,children:(0,U.jsx)(S,{checked:pe??!1,onCheckedChange:e=>c([`meta`,`record`],e,!1)})})]})]})]})]})}function Pe({runId:e,onClose:n}){let[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(`connecting`),[s,c]=(0,V.useState)(),[ee,l]=(0,V.useState)(0),u=(0,V.useRef)(null);if((0,V.useEffect)(()=>{if(!e)return;let t=!1;i([]),o(`connecting`),c(void 0),l(0);let n=Date.now();u.current=setInterval(()=>{t||l(Date.now()-n)},200);let r=N(e,{onRunStart:()=>{t||o(`running`)},onStepStart:e=>{t||(o(`running`),i(t=>[...t,{name:e.stepName,status:`running`}]))},onStepComplete:e=>{t||i(t=>{let n=!1;return t.map(t=>n||t.name!==e.stepName||t.status!==`running`?t:(n=!0,{...t,status:be(e.status),duration:e.duration,error:e.error??void 0}))})},onRunComplete:e=>{if(t)return;let n=F(e.status);c(n.normalized),o(n.normalized===`passed`?`complete`:`error`),i(t=>t.map(t=>t.status===`running`?{...t,status:ye(e.status)}:t)),u.current&&clearInterval(u.current)},onRunError:e=>{t||(o(`error`),i(t=>[...t,{name:`Run Error`,status:`failed`,error:e.error}]),u.current&&clearInterval(u.current))}});return()=>{t=!0,u.current&&clearInterval(u.current),r.close()}},[e]),!e)return null;let d=s?F(s):null,te=a===`connecting`?`Connecting...`:a===`running`?`Running`:d?.label??(a===`complete`?`Passed`:`Failed`);return(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a===`running`||a===`connecting`?(0,U.jsx)(g,{className:`size-4 text-primary`}):d?.normalized===`passed`||a===`complete`?(0,U.jsx)(_e,{className:`size-4 text-emerald-500`}):d?.normalized===`cancelled`?(0,U.jsx)(ce,{className:`size-4 text-muted-foreground`}):d?.normalized===`flaky`||d?.normalized===`healed`?(0,U.jsx)(y,{className:`size-4 text-amber-500`}):(0,U.jsx)(_,{className:`size-4 text-red-500`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:te}),(a===`running`||a===`connecting`)&&(0,U.jsxs)(L,{variant:`outline`,className:`text-xs gap-1`,children:[(0,U.jsx)(t,{className:`size-3`}),xe(ee)]})]}),(0,U.jsx)(k,{variant:`ghost`,size:`icon-xs`,onClick:n,children:(0,U.jsx)(he,{className:`size-3.5`})})]}),(0,U.jsx)(x,{className:`flex-1 [&>[data-slot=scroll-area-viewport]>div]:!block`,children:(0,U.jsxs)(`div`,{className:`p-3 space-y-1.5`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:M(`relative overflow-hidden flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,e.status===`running`&&`live-running-surface border-border/60 bg-primary/5`,e.status===`passed`&&`border-emerald-500/20 bg-emerald-500/5`,e.status===`failed`&&`border-destructive/20 bg-destructive/5`,e.status===`cancelled`&&`border-border/60 bg-muted/30`,e.status===`flaky`&&`border-amber-500/20 bg-amber-500/5`,e.status!==`running`&&e.status!==`passed`&&e.status!==`failed`&&e.status!==`cancelled`&&e.status!==`flaky`&&`border-border/60 bg-card/40`),children:[e.status===`running`?(0,U.jsx)(g,{className:`size-3.5 mt-0.5 shrink-0 text-primary`}):e.status===`passed`||e.status===`completed`?(0,U.jsx)(_e,{className:`size-3.5 mt-0.5 text-emerald-500 shrink-0`}):e.status===`cancelled`?(0,U.jsx)(ce,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}):e.status===`flaky`?(0,U.jsx)(y,{className:`size-3.5 mt-0.5 text-amber-500 shrink-0`}):(0,U.jsx)(_,{className:`size-3.5 mt-0.5 text-red-500 shrink-0`}),(0,U.jsx)(`span`,{className:`flex-1 min-w-0 break-words`,children:e.name}),e.duration!==void 0&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:xe(e.duration)})]},`${e.name}-${t}`)),r.length===0&&a===`connecting`&&(0,U.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Waiting for events...`})]})})]})}function Fe({ariaTree:e,onRefresh:t,isExecuting:n}){return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center justify-end px-3 py-1 border-b border-border/50`,children:t&&(0,U.jsxs)(`button`,{type:`button`,onClick:t,disabled:n,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,"aria-label":`Refresh ARIA tree`,children:[(0,U.jsx)(y,{className:`size-3`}),`Refresh`]})}),(0,U.jsx)(x,{className:`flex-1`,children:(0,U.jsx)(`pre`,{className:`font-mono text-xs p-3 whitespace-pre-wrap`,children:e})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Run a step or click Fetch to capture the accessibility tree`}),t&&(0,U.jsxs)(`button`,{type:`button`,onClick:t,disabled:n,className:`flex items-center gap-1.5 text-xs px-2.5 py-1 rounded border border-border hover:bg-muted transition-colors disabled:opacity-50`,children:[(0,U.jsx)(y,{className:`size-3`}),`Fetch`]})]})}function K(e){let t=[];return e.observation&&t.push({key:`observation`,label:`Observation`,icon:v,content:e.observation,duration:e.phaseDurations?.observe??null}),e.reasoning&&t.push({key:`reasoning`,label:`Reasoning`,icon:n,content:e.reasoning,duration:e.phaseDurations?.plan??null}),e.plannedAction!=null&&t.push({key:`plannedAction`,label:`Planned Action`,icon:ge,content:null,duration:e.phaseDurations?.execute??null,children:(0,U.jsx)(`pre`,{className:`max-w-full min-w-0 text-[10px] font-mono bg-muted/30 rounded-sm p-2 overflow-x-auto whitespace-pre-wrap break-words`,children:typeof e.plannedAction==`string`?e.plannedAction:JSON.stringify(e.plannedAction,null,2)})}),e.verifierReasoning&&t.push({key:`verifier`,label:`Verifier`,icon:c,content:e.verifierReasoning,duration:e.phaseDurations?.verify??null}),t}function Ie(e){let t=[];return e.observation&&t.push({key:`observation`,label:`Observation`,icon:v,content:e.observation,duration:null}),e.reasoning&&t.push({key:`reasoning`,label:`Reasoning`,icon:n,content:e.reasoning,duration:null}),e.plannedAction!=null&&t.push({key:`plannedAction`,label:`Planned Action`,icon:ge,content:null,duration:null,children:(0,U.jsx)(`pre`,{className:`max-w-full min-w-0 text-[10px] font-mono bg-muted/30 rounded-sm p-2 overflow-x-auto whitespace-pre-wrap break-words`,children:typeof e.plannedAction==`string`?e.plannedAction:JSON.stringify(e.plannedAction,null,2)})}),t}function Le({step:e,subAction:t}){if(t){let e=K(t);return(0,U.jsxs)(`div`,{className:`p-3 space-y-3 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsxs)(`span`,{className:`font-medium`,children:[`Sub-action #`,t.index+1]}),(0,U.jsx)(`span`,{className:`text-xs font-medium ${t.result===`success`?`text-emerald-500`:`text-red-500`}`,children:t.result}),t.confidence!=null&&(0,U.jsx)(a,{confidence:t.confidence})]}),(0,U.jsx)(r,{mode:`static`,sections:e}),t.error&&(0,U.jsx)(`div`,{className:`bg-destructive/10 text-destructive rounded-sm p-2 text-xs break-words [overflow-wrap:anywhere]`,children:t.error})]})}let n=Ie(e);return(0,U.jsxs)(`div`,{className:`p-3 space-y-3 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsxs)(`span`,{className:`font-medium`,children:[`Step #`,e.stepOrder+1]}),e.confidence!=null&&(0,U.jsx)(a,{confidence:e.confidence})]}),n.length>0?(0,U.jsx)(r,{mode:`static`,sections:n}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No reasoning data yet.`}),e.error&&(0,U.jsx)(`div`,{className:`bg-destructive/10 text-destructive rounded-sm p-2 text-xs break-words [overflow-wrap:anywhere]`,children:e.error})]})}function Re({screenshot:e,connectionState:t,onReconnect:n}){return(0,U.jsx)(`div`,{className:`relative flex h-full w-full items-center justify-center overflow-hidden bg-background`,children:e?(0,U.jsx)(`img`,{src:e,alt:`Browser preview`,className:`max-w-full max-h-full object-contain`}):t===`connecting`||t===`connected`&&!e?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,U.jsx)(I,{className:`h-6 w-6 animate-spin`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Connecting to browser...`})]}):t===`disconnected`||t===`error`?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,U.jsx)(Te,{className:`h-6 w-6`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Browser disconnected`}),n&&(0,U.jsx)(k,{variant:`outline`,size:`sm`,onClick:n,children:`Reconnect`})]}):null})}var ze={idle:{label:`Ready`,tone:`bg-muted-foreground/35`},connecting:{label:`Connecting`,tone:`bg-primary animate-pulse`},connected:{label:`Connected`,tone:`bg-emerald-500`},executing:{label:`Executing`,tone:`bg-primary animate-pulse`},disconnected:{label:`Disconnected`,tone:`bg-amber-500`},error:{label:`Error`,tone:`bg-destructive`}};function Be(e){switch(e){case`invalid`:return{label:`Draft invalid`,className:`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`};case`saved`:return{label:`Saved draft`,className:`border-border/70 bg-background text-muted-foreground`};default:return{label:`Using unsaved draft`,className:`border-primary/25 bg-primary/10 text-primary`}}}function Ve(e,t){let n=e.trim();if(!n)return``;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n))return n;if(n.startsWith(`/`))try{return new URL(n,t??`https://example.com`).toString()}catch{return n}return/^[\w.-]+(?::\d+)?(?:[/?#]|$)/.test(n)?`https://${n}`:n}function He({hook:e}){return e.status===`passed`?(0,U.jsxs)(L,{className:`border-emerald-500/20 bg-emerald-500/15 text-emerald-500`,children:[(0,U.jsx)(_e,{className:`size-3`}),`Passed`]}):e.status===`failed`?(0,U.jsxs)(L,{variant:`destructive`,children:[(0,U.jsx)(fe,{className:`size-3`}),`Failed`]}):e.status===`running`?(0,U.jsxs)(L,{className:`border-primary/20 bg-primary/15 text-primary`,children:[(0,U.jsx)(I,{className:`size-3 animate-spin`}),`Running`]}):(0,U.jsx)(L,{variant:`outline`,children:`Pending`})}function Ue({hook:e}){return!e.variables||Object.keys(e.variables).length===0?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`This hook did not emit any variables`}):(0,U.jsx)(`div`,{className:`space-y-2 p-4`,children:Object.entries(e.variables).map(([e,t])=>(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/80 px-3 py-2`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),(0,U.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-all font-mono text-xs`,children:t})]},e))})}function We({hook:e}){return(0,U.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(D,{className:`size-4 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.name})]}),(0,U.jsx)(L,{variant:`outline`,className:`font-mono text-[10px]`,children:e.id}),(0,U.jsx)(L,{variant:`outline`,className:`text-[10px] uppercase tracking-wide`,children:e.phase}),(0,U.jsx)(He,{hook:e}),e.duration!=null&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.duration<1e3?`${e.duration}ms`:`${(e.duration/1e3).toFixed(1)}s`})]}),e.error&&(0,U.jsx)(`div`,{className:`min-w-0 max-w-full rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-sm text-destructive [overflow-wrap:anywhere]`,children:e.error}),e.stdout&&(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`stdout`}),(0,U.jsx)(`pre`,{className:`rounded-md border bg-background/80 p-3 text-xs whitespace-pre-wrap break-all`,children:e.stdout})]}),e.stderr&&(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`stderr`}),(0,U.jsx)(`pre`,{className:`rounded-md border border-destructive/20 bg-destructive/5 p-3 text-xs whitespace-pre-wrap break-all text-destructive`,children:e.stderr})]}),e.variables&&Object.keys(e.variables).length>0&&(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Emitted Variables`}),(0,U.jsx)(Ue,{hook:e})]}),!e.stdout&&!e.stderr&&(!e.variables||Object.keys(e.variables).length===0)&&!e.error&&(0,U.jsx)(R,{icon:D,title:`No hook output yet`,description:`Connect a live session, run a teardown hook, or end the current session to capture hook output.`})]})}function Ge(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.status!==`idle`||n.phases.length>0||n.executionHistory.length>0||n.consoleLogs.length>0||n.networkLogs.length>0)return n}return null}function Ke(e){switch(e){case`running`:return`border-primary/20 bg-primary/10 text-primary`;case`passed`:return`border-emerald-500/20 bg-emerald-500/10 text-emerald-500`;case`failed`:return`border-destructive/20 bg-destructive/10 text-destructive`;case`cancelled`:return`border-amber-500/20 bg-amber-500/10 text-amber-600 dark:text-amber-400`;default:return`border-border/70 bg-background text-muted-foreground`}}function qe(e){switch(e){case`running`:return`border-primary/20 bg-primary/10 text-primary`;case`passed`:case`healed`:case`flaky`:return`border-emerald-500/20 bg-emerald-500/10 text-emerald-500`;case`failed`:case`cancelled`:case`skipped`:return`border-destructive/20 bg-destructive/10 text-destructive`;default:return`border-border/70 bg-background text-muted-foreground`}}function Je({test:e,selectedStep:t,subAction:n}){let r=e.liveSteps.map(e=>z(e,e.stepIndex));return(0,U.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.path})]}),(0,U.jsx)(L,{variant:`outline`,className:M(`text-[10px] uppercase tracking-wide`,Ke(e.status)),children:e.status}),typeof e.duration==`number`&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.duration<1e3?`${e.duration}ms`:`${(e.duration/1e3).toFixed(1)}s`})]}),e.error&&(0,U.jsx)(`div`,{className:`min-w-0 max-w-full rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-sm text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/80 px-3 py-2`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Setup Hooks`}),(0,U.jsx)(`div`,{className:`mt-2 text-sm`,children:e.perTestSetupHooks.length>0?e.perTestSetupHooks.map(e=>`${e.name} (${e.status})`).join(`, `):`No per-test setup hooks`})]}),(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/80 px-3 py-2`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Teardown Hooks`}),(0,U.jsx)(`div`,{className:`mt-2 text-sm`,children:e.perTestTeardownHooks.length>0?e.perTestTeardownHooks.map(e=>`${e.name} (${e.status})`).join(`, `):`No per-test teardown hooks`})]})]}),r.length>0?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Steps`}),(0,U.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>{let r=t?.id===e.id,i=e.subActionsData??[];return(0,U.jsxs)(`div`,{className:M(`overflow-hidden rounded-md border bg-background/80`,r&&`border-primary/30 ring-1 ring-primary/20`),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b px-3 py-2`,children:[(0,U.jsxs)(`span`,{className:`shrink-0 text-sm font-medium`,children:[`Step #`,e.stepOrder+1]}),(0,U.jsx)(L,{variant:`outline`,className:M(`text-[10px] uppercase tracking-wide`,qe(e.status)),children:e.status}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.name}),e.duration>0&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.duration<1e3?`${e.duration}ms`:`${(e.duration/1e3).toFixed(1)}s`})]}),i.length>0?(0,U.jsx)(`div`,{className:`divide-y divide-border/60`,children:i.map(t=>(0,U.jsx)(`div`,{className:M(r&&n?.index===t.index&&`bg-primary/5`),children:(0,U.jsx)(Le,{step:e,subAction:t})},`${e.id}-sub-${t.index}`))}):(0,U.jsx)(Le,{step:e,subAction:r?n:null})]},e.id)})})]}):(0,U.jsx)(`div`,{className:`rounded-md border border-dashed px-4 py-6 text-sm text-muted-foreground`,children:`This test has not produced any live step detail yet. Run it from the queue to inspect reasoning, console, network, and hook output.`})]})}function q({connectionState:e,isLaunching:t,targetName:n,targetLabel:r,platform:a,screenshot:c,currentUrl:ee,pendingNavigation:l,steps:u,setupHooks:d,teardownHooks:te,tests:re=[],selection:p,runningStepId:m,terminalState:h,draftState:g,ariaTree:_,errorMessage:v,devtoolsTab:b,canRunAll:S,isRunningAll:w,isStoppingRunAll:T,setupHooksStale:E=!1,onDevtoolsTabChange:me,onRunAll:he,onStopAll:D,onEndSession:O,onRestartSession:ge,showEndSessionAction:_e=!1,onCloseLiveMode:A,onStartFreshSession:j,onBack:N,onForward:ye,onRefresh:be,onNavigate:P,onRequestAriaTree:xe,executionUnit:F=`step`,runAllLabel:Te,stopAllLabel:H,liveSessionNumber:Ee=null,unitRowsSlot:De}){let[Oe,ke]=(0,V.useState)(!1),[Ae,je]=(0,V.useState)(``),[W,Me]=(0,V.useState)(!1),G=t?`connecting`:e,Ne=h?{label:h.reason===`ended`?`Ended`:`Disconnected`,tone:h.reason===`ended`?`bg-muted-foreground/45`:`bg-amber-500`}:ze[G],Pe=(0,V.useMemo)(()=>u.map((e,t)=>z(e,t)),[u]),K=F===`test`,Ie=!K,He=(0,V.useMemo)(()=>[...d,...te],[d,te]),Ke=(0,V.useMemo)(()=>m||(Ge(u)?.id??null),[m,u]),qe=p&&`stepId`in p?p.stepId:Ke,q=(0,V.useMemo)(()=>Pe.find(e=>e.id===qe)??null,[Pe,qe]),Ye=(0,V.useMemo)(()=>p?.type!==`subaction`||!q?null:q.subActionsData?.[p.subIndex]??null,[p,q]),Xe=(0,V.useMemo)(()=>u.find(e=>e.id===q?.id)??null,[q,u]),J=(0,V.useMemo)(()=>p?.type===`hook`?He.find(e=>e.id===p.hookId)??null:null,[p,He]),Y=(0,V.useMemo)(()=>!K||!p?null:p.type===`test`||p.type===`test-hook`?re[p.testIndex]??null:`stepId`in p?re.find(e=>e.liveSteps.some(e=>e.id===p.stepId))??null:null,[p,K,re]),Ze=(0,V.useMemo)(()=>!K||p?.type!==`suite-hook`?null:(p.phase===`setup`?d:te).find(e=>e.id===p.hookId)??null,[p,d,K,te]),Qe=(0,V.useMemo)(()=>{if(!K||p?.type!==`test-hook`)return null;let e=re[p.testIndex];return e?(p.phase===`setup`?e.perTestSetupHooks:e.perTestTeardownHooks).find(e=>e.id===p.hookId)??null:null},[p,K,re]),X=(0,V.useMemo)(()=>{if(!K||!Y)return null;if(p&&`stepId`in p){let e=Y.liveSteps.find(e=>e.id===p.stepId);if(e)return e}if(Y.runningStepIndex!==null){let e=Y.liveSteps.find(e=>e.stepIndex===Y.runningStepIndex);if(e)return e}return Ge(Y.liveSteps)},[p,Y,K]),Z=(0,V.useMemo)(()=>X?z(X,X.stepIndex):null,[X]),$e=(0,V.useMemo)(()=>p?.type!==`subaction`||!Z?null:Z.subActionsData?.[p.subIndex]??null,[p,Z]),et=(0,V.useMemo)(()=>Y?.liveSteps.map(e=>z(e,e.stepIndex))??[],[Y]),tt=X?.executionLogs??[],nt=Xe?.executionLogs??[],Q=Be(g),$=a===`web`?ee||r||`Configured start URL`:r||(a===`android`?`Android device`:`iOS device`);(0,V.useEffect)(()=>{W||je($)},[$,W]);let rt=(0,V.useMemo)(()=>{if(K){let e=re.find(e=>e.status===`running`);return e?`Running ${e.name}`:null}if(!m)return null;let e=Pe.find(e=>e.id===m);return e?`Running step ${e.stepOrder+1}`:`Running current step`},[Pe,m,K,re]),it=async()=>{$&&(await navigator.clipboard.writeText($),ke(!0),window.setTimeout(()=>ke(!1),1500))},at=()=>{let e=Ve(Ae,ee);if(!e){je($);return}je(e),Me(!1),P(e)},ot=!K&&!!(p&&p.type!==`hook`&&!q);return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card/30`,children:[(0,U.jsxs)(`div`,{className:`border-b px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:n||`Live Session`}),(0,U.jsx)(L,{variant:`outline`,className:`text-[10px] uppercase tracking-wide`,children:Ne.label}),(e===`connected`||e===`executing`)&&typeof Ee==`number`&&(0,U.jsxs)(L,{variant:`outline`,"aria-live":`polite`,className:`text-[10px] tracking-wider font-medium text-muted-foreground bg-muted/50 border-border/50`,children:[`Session #`,Ee]}),rt&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:rt})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a===`web`?(0,U.jsx)(se,{className:`size-3.5 shrink-0`}):(0,U.jsx)(f,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,title:$,children:$})]}),v&&!h&&(0,U.jsx)(`div`,{className:`min-w-0 max-w-2xl text-xs text-destructive [overflow-wrap:anywhere]`,children:v})]}),!h&&(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,U.jsx)(L,{variant:`outline`,className:M(`text-[10px]`,Q.className),children:Q.label}),E&&(0,U.jsx)(L,{className:`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:`Restart required`}),Ie&&(w?(0,U.jsxs)(k,{variant:`outline`,size:`sm`,onClick:D,disabled:T,children:[T?(0,U.jsx)(I,{className:`size-3.5 animate-spin`}):(0,U.jsx)(ce,{className:`size-3.5`}),T?`Stopping...`:H??`Stop All Steps`]}):(0,U.jsxs)(k,{variant:`outline`,size:`sm`,onClick:he,disabled:!S,children:[(0,U.jsx)(ie,{className:`size-3.5`}),Te??`Run All Steps`]})),_e&&(0,U.jsxs)(k,{variant:`destructive`,size:`sm`,onClick:O,children:[(0,U.jsx)(ce,{className:`size-3.5`}),`End Live Session`]})]})]}),E&&!h&&(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-start justify-between gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,U.jsx)(fe,{className:`mt-0.5 size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Hook order or names changed after this live session started. Continue using the current disposable session, or restart to apply the latest setup and teardown hooks.`})]}),ge&&(0,U.jsx)(k,{type:`button`,size:`sm`,className:`shrink-0`,onClick:ge,children:`Restart Live Session`})]}),!h&&(a===`web`?(0,U.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,U.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:N,disabled:G===`executing`||G===`idle`,"aria-label":`Go back`,children:(0,U.jsx)(pe,{className:`size-3.5`})}),(0,U.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:ye,disabled:G===`executing`||G===`idle`,"aria-label":`Go forward`,children:(0,U.jsx)(ve,{className:`size-3.5`})}),(0,U.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:be,disabled:G===`executing`||G===`idle`,"aria-label":`Refresh page`,children:(0,U.jsx)(y,{className:`size-3.5`})})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 rounded-full border bg-background px-3 py-2`,children:[l?(0,U.jsx)(I,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,U.jsx)(se,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`input`,{value:Ae,title:$,onFocus:()=>Me(!0),onBlur:()=>{Me(!1),je($)},onChange:e=>je(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),at()),e.key===`Escape`&&(e.preventDefault(),Me(!1),je($))},disabled:G===`executing`||G===`idle`,className:M(`min-w-0 flex-1 bg-transparent text-sm outline-none`,W?`text-left`:`text-center`)})]}),(0,U.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:(0,U.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:it,disabled:!$,"aria-label":Oe?`URL copied`:`Copy URL`,title:Oe?`URL copied`:`Copy URL`,children:Oe?(0,U.jsx)(ne,{className:`size-3.5`}):(0,U.jsx)(ae,{className:`size-3.5`})})})]}):(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:_e&&(0,U.jsxs)(k,{variant:`destructive`,size:`sm`,onClick:O,children:[(0,U.jsx)(ce,{className:`size-3.5`}),`End Live Session`]})}))]}),F===`test`&&De,(0,U.jsxs)(Ce,{orientation:`vertical`,className:`min-h-0 flex-1`,children:[(0,U.jsx)(Se,{defaultSize:62,minSize:32,children:h?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-8`,children:(0,U.jsxs)(`div`,{className:`flex max-w-lg flex-col items-center gap-4 rounded-lg border bg-background/80 px-6 py-8 text-center`,children:[(0,U.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,U.jsx)(B,{className:`size-6 text-muted-foreground`})}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold`,children:h.title}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h.description})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[A&&(0,U.jsx)(k,{variant:`outline`,size:`sm`,onClick:A,children:`Close Live Mode`}),j&&(0,U.jsx)(k,{size:`sm`,onClick:j,children:`Start Fresh Session`})]})]})}):G===`idle`?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-8`,children:(0,U.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 rounded-lg border bg-background/70 px-6 py-8 text-center`,children:[(0,U.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,U.jsx)(B,{className:`size-6 text-muted-foreground`})}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold`,children:`Live mode is target-scoped`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This workspace runs the current builder draft against the selected target. Sessions are disposable and draft changes only persist when you save the test.`})]})]})}):(0,U.jsx)(Re,{screenshot:c,connectionState:G})}),(0,U.jsx)(we,{withHandle:!0}),(0,U.jsx)(Se,{defaultSize:38,minSize:20,children:(0,U.jsxs)(de,{value:b,onValueChange:e=>me(e),className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(ue,{variant:`line`,className:`h-9 justify-start rounded-none border-b px-3`,children:[(0,U.jsx)(C,{value:`reasoning`,className:`rounded-none text-xs`,children:`Reasoning`}),(0,U.jsx)(C,{value:`env`,className:`rounded-none text-xs`,children:`Env`}),(0,U.jsx)(C,{value:`network`,className:`rounded-none text-xs`,children:`Network`}),(0,U.jsx)(C,{value:`console`,className:`rounded-none text-xs`,children:`Console`}),(0,U.jsx)(C,{value:`aria`,className:`rounded-none text-xs`,children:`ARIA Tree`})]}),(0,U.jsx)(le,{value:`reasoning`,className:`m-0 flex-1 overflow-hidden`,children:(0,U.jsx)(x,{className:`h-full`,children:K?Ze?(0,U.jsx)(We,{hook:Ze}):Qe?(0,U.jsx)(We,{hook:Qe}):Y?(0,U.jsx)(Je,{test:Y,selectedStep:Z,subAction:$e}):(0,U.jsx)(R,{icon:oe,title:`Select a test to inspect it`,description:`Choose a test in the live queue to see its reasoning, logs, hooks, and network activity.`}):J?(0,U.jsx)(We,{hook:J}):q?(0,U.jsx)(Le,{step:q,subAction:Ye}):ot?(0,U.jsx)(R,{icon:oe,title:`Selection is no longer available`,description:`Pick another step in the builder to inspect its reasoning.`}):(0,U.jsx)(R,{icon:oe,title:`No reasoning yet`,description:`Run a step from the builder or use Run All Steps to populate the live reasoning trace.`})})}),(0,U.jsx)(le,{value:`env`,className:`m-0 flex-1 overflow-hidden`,children:K?Ze?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(Ue,{hook:Ze})}):Qe?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(Ue,{hook:Qe})}):X?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(o,{step:X,executionLogs:tt})}):Y?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a test-owned hook or run a step to inspect variables and runJS output`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a test to inspect it`}):J?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(Ue,{hook:J})}):Xe?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(o,{step:Xe,executionLogs:nt})}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a step to inspect variables and runJS output`})}),(0,U.jsx)(le,{value:`network`,className:`m-0 flex-1 overflow-hidden`,children:K?Ze||Qe?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:`Hooks do not capture browser network activity. Select a test step to inspect requests.`}):X?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(i,{step:Z,allSteps:et,platform:a})}):Y?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Run this test to inspect its network activity`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a test to inspect it`}):J?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:`Hooks do not capture browser network activity. Select a step to inspect requests.`}):q?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(i,{step:q,allSteps:Pe,platform:a})}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a step to inspect network activity`})}),(0,U.jsx)(le,{value:`console`,className:`m-0 flex-1 overflow-hidden`,children:K?Ze?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(We,{hook:Ze})}):Qe?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(We,{hook:Qe})}):X?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(s,{step:Z,allSteps:et,executionLogs:tt,isHookStep:tt.length>0})}):Y?(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Run this test to inspect console output`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a test to inspect it`}):J?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(We,{hook:J})}):q?(0,U.jsx)(x,{className:`h-full`,children:(0,U.jsx)(s,{step:q,allSteps:Pe,executionLogs:nt,isHookStep:nt.length>0})}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Select a step to inspect console output`})}),(0,U.jsx)(le,{value:`aria`,className:`m-0 flex-1 overflow-hidden`,children:(0,U.jsx)(Fe,{ariaTree:_,onRefresh:xe,isExecuting:G===`executing`})})]})})]})]})}function Ye(){return typeof window<`u`&&window.localStorage!==void 0}function Xe(){if(!Ye())return!1;try{return window.localStorage.getItem(`agent-qa:live-debug`)===`1`}catch{return!1}}function J(e,t,n){if(!Xe())return;let r=`[agent-qa live:${e}] ${t}`;if(n){console.info(r,n);return}console.info(r)}function Y(e,t){let n=typeof e==`string`?{instruction:e}:e;return{id:t?.id??n.draftId??crypto.randomUUID(),draftId:n.draftId??t?.draftId??null,instruction:n.instruction,status:t?.status??`idle`,duration:t?.duration,error:t?.error,phases:t?.phases??[],executionHistory:t?.executionHistory??[],capturedVariables:t?.capturedVariables,consoleLogs:t?.consoleLogs??[],networkLogs:t?.networkLogs??[],variableSnapshot:t?.variableSnapshot??null,originalStepName:t?.originalStepName??null,subActionsData:t?.subActionsData??null,executionLogs:t?.executionLogs??[],executionGeneration:t?.executionGeneration??0}}function Ze(e,t){return{id:e.hookId,executionId:t?.executionId??null,name:e.name??t?.name??e.hookId,phase:e.phase,status:t?.status??`pending`,duration:t?.duration,stdout:t?.stdout??null,stderr:t?.stderr??null,variables:t?.variables??null,error:t?.error,createdAt:t?.createdAt}}function Qe(e,t){return{...Y({draftId:t?.draftId,instruction:e.instruction},t),id:t?.id??crypto.randomUUID(),stepIndex:e.stepIndex}}function X(e,t){let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?{...e,...t}:e)}function Z(e,t,n){let r=e.find(e=>e.stepIndex===t.stepIndex),i={...Qe(t,r),...n};return[...r?e.map(e=>e.stepIndex===t.stepIndex?i:e):[...e,i]].sort((e,t)=>e.stepIndex-t.stepIndex)}function $e(e,t){let n=t.map(e=>({draftId:e.draftId,instruction:e.instruction}));if(e.length===n.length&&e.every((e,t)=>e.instruction===n[t].instruction&&e.draftId===n[t].draftId))return e;let r=new Map(e.filter(e=>!!e.draftId).map(e=>[e.draftId,e]));return n.map((t,n)=>Y(t,t.draftId?r.get(t.draftId):e[n]))}function et(e,t,n){if(e.length===t.length&&e.every((e,r)=>e.id===t[r]&&e.phase===n))return e;let r=new Map(e.map(e=>[e.id,e]));return t.map(e=>Ze({hookId:e,phase:n},r.get(e)))}function tt(e,t,n){return{id:n?.id??`${e.testId}:${e.path}:${t}`,draftId:e.draftId??n?.draftId??null,testId:e.testId,path:e.path,name:e.name,status:n?.status??`idle`,duration:n?.duration,error:n?.error,testExecutionId:n?.testExecutionId??null,liveSteps:n?.liveSteps??[],runningStepIndex:n?.runningStepIndex??null,perTestSetupHooks:n?.perTestSetupHooks??[],perTestTeardownHooks:n?.perTestTeardownHooks??[],lastRunAt:n?.lastRunAt}}function nt(e,t){let n=e.findIndex(e=>e.testExecutionId===t.testExecutionId);if(n!==-1)return n;let r=e.findIndex(e=>e.testId===t.testId&&e.name===t.testName);return r===-1?t.testIndex>=0&&t.testIndex<e.length?t.testIndex:-1:r}function Q(e,t,n){let r=nt(e,t);return r===-1?e:e.map((e,t)=>t===r?n(e):e)}function $(e){return e.scope===`test`}function rt(e,t={}){let n=t.steps,r=t.tests,i=t.setupHooks??[],a=t.teardownHooks??[],o=t.allowReconnect??!n,[s,c]=(0,V.useState)(`idle`),[ee,l]=(0,V.useState)([]),[u,d]=(0,V.useState)(()=>et([],i,`setup`)),[te,ne]=(0,V.useState)(()=>et([],a,`teardown`)),[f,re]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[ie,_]=(0,V.useState)(null),[ae,v]=(0,V.useState)(null),[oe,se]=(0,V.useState)([]),[y,ce]=(0,V.useState)(`web`),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(!1),[le,ue]=(0,V.useState)(!1),[de,w]=(0,V.useState)([]),[fe,pe]=(0,V.useState)(null),[T,E]=(0,V.useState)(!1),[me,he]=(0,V.useState)(!1),D=(0,V.useRef)(null),O=(0,V.useRef)(0),ge=(0,V.useRef)(null),_e=(0,V.useRef)(null),k=(0,V.useRef)(`idle`),A=(0,V.useRef)([]),j=(0,V.useRef)(null),ve=(0,V.useRef)(!1),M=(0,V.useRef)(null),N=(0,V.useRef)(null),ye=(0,V.useRef)(!1),be=(0,V.useRef)(0),P=(0,V.useRef)(`web`),xe=(0,V.useRef)(null),F=(0,V.useRef)(!!n),I=(0,V.useRef)(null),L=(0,V.useRef)([]),Se=(0,V.useRef)(null),Ce=(0,V.useRef)(!1),we=(0,V.useRef)(null);k.current=s,A.current=ee,j.current=ae,P.current=y,F.current=!!n,L.current=de,Se.current=fe;let R=(0,V.useCallback)(()=>{_e.current&&=(clearInterval(_e.current),null)},[]),z=(0,V.useCallback)(e=>{let t=D.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),B=(0,V.useCallback)(e=>{R(),_e.current=setInterval(()=>{document.hidden||z({type:`get-screenshot`})},e)},[R,z]),Te=(0,V.useCallback)(()=>new Promise(e=>{N.current=e,setTimeout(()=>{N.current===e&&(N.current=null,e())},5e3)}),[]),H=(0,V.useCallback)(()=>{let e=xe.current;e&&(xe.current=null,l(t=>$e(t,e)))},[]),Ee=(0,V.useCallback)(e=>{D.current&&=(J(`hook`,`closing previous websocket before reconnect`,{sessionId:e}),D.current.close(),null),c(`connecting`),ve.current=!1,J(`hook`,`connecting websocket`,{sessionId:e});let t=`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/live-editor/ws?sessionId=${e}`,n=new WebSocket(t);D.current=n,n.onopen=()=>{O.current=0,J(`hook`,`websocket opened`,{sessionId:e})},n.onmessage=t=>{let n;try{n=JSON.parse(t.data)}catch{return}switch(n.type){case`session-ready`:{let t=n.platform??`web`;ce(t),P.current=t;let r=n.interactive!==!1;c(r?`connected`:`error`),_(n.error??null),J(`hook`,`session ready`,{sessionId:e,platform:t,interactive:r}),r&&B(t===`web`?1e3:2e3);break}case`hook-start`:{let e=n.hook,t={id:e.hookId,executionId:e.executionId,name:e.hookName,phase:e.phase,status:`running`,duration:void 0,stdout:null,stderr:null,variables:null,error:void 0,createdAt:e.createdAt};if(e.owner.scope===`suite`)(e.phase===`setup`?d:ne)(e=>X(e,t)),I.current&&I.current.phase===e.phase&&I.current.hookId===e.hookId&&(I.current={...I.current,executionId:e.executionId});else if($(e.owner)){let n=e.owner;w(r=>Q(r,n,n=>({...n,perTestSetupHooks:e.phase===`setup`?X(n.perTestSetupHooks,t):n.perTestSetupHooks,perTestTeardownHooks:e.phase===`teardown`?X(n.perTestTeardownHooks,t):n.perTestTeardownHooks})))}break}case`hook-complete`:{let e=n.hook,t={id:e.hookId,executionId:e.executionId,name:e.hookName,phase:e.phase,status:e.status,duration:e.duration,stdout:e.stdout??null,stderr:e.stderr??null,variables:e.variables??null,error:e.error,createdAt:e.createdAt};if(e.owner.scope===`suite`)(t.phase===`setup`?d:ne)(e=>X(e,t)),I.current&&I.current.phase===t.phase&&I.current.hookId===t.id&&(!I.current.executionId||I.current.executionId===t.executionId)&&(I.current=null,c(`connected`),B(P.current===`web`?1e3:2e3),H());else if($(e.owner)){let n=e.owner;w(e=>Q(e,n,e=>({...e,perTestSetupHooks:t.phase===`setup`?X(e.perTestSetupHooks,t):e.perTestSetupHooks,perTestTeardownHooks:t.phase===`teardown`?X(e.perTestTeardownHooks,t):e.perTestTeardownHooks})))}break}case`step-phase`:l(e=>e.map((e,t)=>t===j.current&&e.status===`running`&&e.executionGeneration===be.current?{...e,phases:[...e.phases,{phase:n.phase,text:n.data?.text,confidence:n.data?.confidence,action:n.data?.action,success:n.data?.success,duration:n.data?.duration,timestamp:new Date().toISOString()}]}:e));break;case`step-complete`:{let t=n.result,r=j.current,i=t?.status===`passed`?`passed`:`failed`;l(e=>e.map((e,n)=>n===r&&e.status===`running`?{...e,status:i,duration:t?.duration,error:t?.error,capturedVariables:t?.capturedVariables,consoleLogs:t?.consoleLogs??[],networkLogs:t?.networkLogs??[],variableSnapshot:t?.variableSnapshot??null,originalStepName:t?.originalStepName??null,subActionsData:t?.subActionsData??null,executionLogs:t?.executionLogs??[]}:e)),v(null),c(`connected`),J(`hook`,`step completed`,{sessionId:e,stepIndex:r??void 0,status:i}),B(P.current===`web`?1e3:2e3),M.current?.({status:i}),M.current=null,N.current?.(),N.current=null,H();break}case`test-start`:{let e=n.test;Se.current=e.testIndex,pe(e.testIndex),w(t=>Q(t,e,t=>({...t,status:`running`,duration:void 0,error:void 0,testExecutionId:e.testExecutionId,runningStepIndex:null,liveSteps:[],perTestSetupHooks:[],perTestTeardownHooks:[]})));break}case`test-step-start`:{let e=n.step;w(t=>Q(t,e,t=>({...t,status:`running`,testExecutionId:e.testExecutionId,runningStepIndex:e.stepIndex,liveSteps:Z(t.liveSteps,{stepIndex:e.stepIndex,instruction:e.stepInstruction},{status:`running`,duration:void 0,error:void 0,phases:[],consoleLogs:[],networkLogs:[],variableSnapshot:null,originalStepName:null,subActionsData:null,executionLogs:[]})})));break}case`test-step-phase`:{let e=n.step;w(t=>Q(t,e,t=>({...t,liveSteps:Z(t.liveSteps,{stepIndex:e.stepIndex,instruction:e.stepInstruction},{status:`running`,phases:[...t.liveSteps.find(t=>t.stepIndex===e.stepIndex)?.phases??[],{phase:n.phase,text:n.data?.text,confidence:n.data?.confidence,action:n.data?.action,success:n.data?.success,duration:n.data?.duration,timestamp:new Date().toISOString()}]})})));break}case`test-step-complete`:{let e=n.step,t=n.result;w(n=>Q(n,e,n=>({...n,runningStepIndex:n.runningStepIndex===e.stepIndex?null:n.runningStepIndex,liveSteps:Z(n.liveSteps,{stepIndex:e.stepIndex,instruction:e.stepInstruction},{status:t?.status??`failed`,duration:t?.duration,error:t?.error,capturedVariables:t?.capturedVariables,consoleLogs:t?.consoleLogs??[],networkLogs:t?.networkLogs??[],variableSnapshot:t?.variableSnapshot??null,originalStepName:t?.originalStepName??null,subActionsData:t?.subActionsData??null,executionLogs:t?.executionLogs??[]})})));break}case`test-step-cancelled`:{let e=n.step;w(t=>Q(t,e,t=>({...t,runningStepIndex:t.runningStepIndex===e.stepIndex?null:t.runningStepIndex,liveSteps:Z(t.liveSteps,{stepIndex:e.stepIndex,instruction:e.stepInstruction},{status:`cancelled`})})));break}case`test-step-error`:{let e=n.step;w(t=>Q(t,e,t=>({...t,runningStepIndex:t.runningStepIndex===e.stepIndex?null:t.runningStepIndex,liveSteps:Z(t.liveSteps,{stepIndex:e.stepIndex,instruction:e.stepInstruction},{status:`failed`,error:n.error})})));break}case`test-complete`:{let e=n.test,t=n.result,r=t?.status??`failed`,i=t?.error;if(!i&&r===`failed`&&Array.isArray(t?.stepResults)){let e=t.stepResults.find(e=>e?.status===`failed`);e?.error&&(i=`Step ${t.stepResults.indexOf(e)+1} failed: ${e.error}`)}w(n=>Q(n,e,n=>({...n,status:r,duration:t?.duration,error:i,testExecutionId:e.testExecutionId,runningStepIndex:null,lastRunAt:new Date().toISOString(),liveSteps:Array.isArray(t?.stepResults)?t.stepResults.reduce((e,t,r)=>{let i=n.liveSteps.find(e=>e.stepIndex===r);return i?Z(e,{stepIndex:r,instruction:i.instruction},{status:t?.status??i.status,duration:t?.duration,error:t?.error,capturedVariables:t?.capturedVariables,consoleLogs:t?.consoleLogs??i.consoleLogs,networkLogs:t?.networkLogs??i.networkLogs,variableSnapshot:t?.variableSnapshot??i.variableSnapshot,originalStepName:t?.originalStepName??i.originalStepName,subActionsData:t?.subActionsData??i.subActionsData,executionLogs:t?.executionLogs??i.executionLogs}):e},n.liveSteps):n.liveSteps,perTestSetupHooks:Array.isArray(t?.setupHookExecutions)?t.setupHookExecutions.map(e=>({id:e.hookId,executionId:e.executionId??null,name:e.hookName,phase:e.phase,status:e.status,duration:e.duration,stdout:e.stdout??null,stderr:e.stderr??null,variables:e.variables??null,error:e.error,createdAt:e.createdAt})):n.perTestSetupHooks,perTestTeardownHooks:Array.isArray(t?.teardownHookExecutions)?t.teardownHookExecutions.map(e=>({id:e.hookId,executionId:e.executionId??null,name:e.hookName,phase:e.phase,status:e.status,duration:e.duration,stdout:e.stdout??null,stderr:e.stderr??null,variables:e.variables??null,error:e.error,createdAt:e.createdAt})):n.perTestTeardownHooks}))),Se.current=null,pe(null),c(`connected`),B(P.current===`web`?1e3:2e3);let a=we.current;we.current=null,a?.({status:r});break}case`test-error`:{let e=n.test;w(t=>Q(t,e,t=>({...t,status:`failed`,error:n.error,testExecutionId:e.testExecutionId,runningStepIndex:null,lastRunAt:new Date().toISOString()}))),Se.current=null,pe(null),c(`connected`),B(P.current===`web`?1e3:2e3);let t=we.current;we.current=null,t?.({status:`failed`});break}case`step-error`:J(`hook`,`step failed`,{sessionId:e,stepIndex:j.current??void 0,error:n.error}),l(e=>e.map((e,t)=>t===j.current?e.status===`cancelling`?{...e,status:`cancelled`}:e.status===`running`?{...e,status:`failed`,error:n.error}:e:e)),v(null),c(`connected`),B(P.current===`web`?1e3:2e3),M.current?.({status:`failed`}),M.current=null,N.current?.(),N.current=null,H();break;case`step-cancelled`:l(e=>e.map((e,t)=>t===j.current&&(e.status===`running`||e.status===`cancelling`)?{...e,status:`cancelled`}:e)),v(null),c(`connected`),J(`hook`,`step cancelled`,{sessionId:e,stepIndex:j.current??void 0}),B(P.current===`web`?1e3:2e3),M.current?.({status:`cancelled`}),M.current=null,N.current?.(),N.current=null,H();break;case`step-busy`:g(null),I.current&&(I.current=null,c(`connected`),B(P.current===`web`?1e3:2e3)),_(`Step already in progress: ${n.currentStep}`);break;case`screenshot`:re(`data:image/jpeg;base64,${n.data}`);break;case`navigate-complete`:m(n.url??null),g(null);break;case`session-state`:n.state&&`currentUrl`in n.state&&m(n.state.currentUrl??null),n.state?.interactive===!1&&(c(`error`),_(n.state.terminalError??`Live session is not ready`));break;case`device-logs`:se(e=>[...e,...n.entries]);break;case`aria-tree`:x(n.tree);break;case`session-terminated`:c(`disconnected`),g(null),I.current=null,R(),H(),J(`hook`,`session terminated by server`,{sessionId:e});break;case`error`:g(null),I.current&&(I.current=null,c(`connected`),B(P.current===`web`?1e3:2e3),H()),_(n.message),J(`hook`,`server reported error`,{sessionId:e,message:n.message});break}},n.onclose=()=>{if(D.current=null,R(),ve.current){J(`hook`,`websocket closed after local termination`,{sessionId:e});return}if(J(`hook`,`websocket closed unexpectedly`,{sessionId:e,allowReconnect:o,reconnectCount:O.current}),c(`disconnected`),g(null),I.current=null,l(e=>e.map(e=>e.status===`running`||e.status===`cancelling`?{...e,status:`cancelled`}:e)),j.current=null,v(null),M.current?.({status:`cancelled`}),M.current=null,N.current?.(),N.current=null,H(),o&&O.current<3){let t=2**O.current*1e3;O.current++,J(`hook`,`scheduling reconnect`,{sessionId:e,delay:t,reconnectCount:O.current}),ge.current=setTimeout(()=>Ee(e),t)}},n.onerror=()=>{J(`hook`,`websocket error event`,{sessionId:e})}},[o,H,R,B]);(0,V.useEffect)(()=>{if(n){if(k.current===`executing`){xe.current=n,J(`hook`,`queued external step sync while executing`,{stepCount:n.length});return}xe.current=null,J(`hook`,`syncing external steps`,{stepCount:n.length}),l(e=>$e(e,n))}},[n]),(0,V.useEffect)(()=>{d(e=>et(e,i,`setup`))},[i]),(0,V.useEffect)(()=>{ne(e=>et(e,a,`teardown`))},[a]),(0,V.useEffect)(()=>{r&&w(e=>{let t=new Map(e.map(e=>[`${e.testId}::${e.path}`,e]));return r.map((e,n)=>tt(e,n,t.get(`${e.testId}::${e.path}`)))})},[r]),(0,V.useEffect)(()=>{if(!e){c(`idle`),l(n?$e([],n):[]),d(et([],i,`setup`)),ne(et([],a,`teardown`)),re(null),m(null),g(null),_(null),I.current=null,se([]),ce(`web`),x(null),C(!1),ue(!1),w(r?.map((e,t)=>tt(e,t))??[]),pe(null),E(!1),he(!1);return}return Ee(e),()=>{R(),ge.current&&=(clearTimeout(ge.current),null),D.current&&=(J(`hook`,`cleaning up websocket for session effect`,{sessionId:e}),D.current.close(),null)}},[R,Ee,e]),(0,V.useEffect)(()=>{s===`executing`?B(y===`web`?500:1e3):s===`connected`?B(y===`web`?1e3:2e3):R()},[s,y,B,R]),(0,V.useEffect)(()=>{let e=()=>{if(document.hidden)R();else{let e=k.current,t=P.current;e===`executing`?B(t===`web`?500:1e3):e===`connected`&&B(t===`web`?1e3:2e3)}};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[R,B]);let De=(0,V.useCallback)(e=>{if(F.current)return;let t=A.current.length;l(t=>[...t,{id:crypto.randomUUID(),draftId:null,instruction:e,status:`running`,phases:[],executionHistory:[],consoleLogs:[],networkLogs:[],variableSnapshot:null,originalStepName:null,subActionsData:null,executionLogs:[],executionGeneration:0}]),v(t),c(`executing`),_(null),z({type:`execute-step`,stepInstruction:e,stepIndex:t})},[z]),Oe=(0,V.useCallback)(async(t,n)=>{let r=A.current[t];if(!r||!r.instruction.trim())return;if(j.current!==null){let e=j.current;ye.current=!0,l(t=>t.map((t,n)=>n===e&&t.status===`running`?{...t,status:`cancelling`}:t)),z({type:`cancel-step`}),await Te()}be.current++;let i=be.current;j.current=t,v(t),l(e=>e.map((e,n)=>n===t?{...e,status:`running`,phases:[],executionHistory:e.phases.length>0?[...e.executionHistory,{phases:e.phases,status:e.status,duration:e.duration,error:e.error,timestamp:new Date().toISOString()}]:e.executionHistory,error:void 0,duration:void 0,consoleLogs:[],networkLogs:[],variableSnapshot:null,originalStepName:null,subActionsData:null,executionLogs:[],executionGeneration:i}:e)),c(`executing`),_(null),J(`hook`,`executing step`,{sessionId:e,stepIndex:t,instruction:r.instruction,testName:n?.testName}),z({type:`execute-step`,stepInstruction:r.instruction,stepIndex:t,draft:n})},[z,e,Te]),ke=(0,V.useCallback)(async(t,n)=>{if(k.current!==`connected`){_(`Live session is busy or not ready`);return}I.current={phase:t,hookId:n},(t===`setup`?d:ne)(e=>e.map(e=>e.id===n?{...e,status:`running`,duration:void 0,stdout:null,stderr:null,variables:null,error:void 0}:e)),c(`executing`),_(null),J(`hook`,`executing hook`,{sessionId:e,phase:t,hookId:n}),z({type:`execute-hook`,phase:t,hookId:n})},[z,e]),Ae=(0,V.useCallback)(()=>{F.current||l(e=>[...e,Y(``)])},[]),U=(0,V.useCallback)(e=>{F.current||l(t=>t.filter((t,n)=>n!==e))},[]),je=(0,V.useCallback)((e,t)=>{F.current||l(n=>n.map((n,r)=>r===e?{...n,instruction:t}:n))},[]),W=(0,V.useCallback)((e,t)=>{if(F.current)return;l(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r});let n=j.current;if(n!==null){let r=n;n===e?r=t:e<n&&t>=n?r=n-1:e>n&&t<=n&&(r=n+1),r!==n&&(j.current=r,v(r))}},[]),Me=(0,V.useCallback)(()=>{S&&(ye.current=!0,ue(!0)),l(e=>e.map((e,t)=>t===j.current&&e.status===`running`?{...e,status:`cancelling`}:e)),J(`hook`,`cancelling active step`,{sessionId:e}),z({type:`cancel-step`})},[S,z,e]),G=(0,V.useCallback)(()=>{z({type:`get-screenshot`})},[z]),Ne=(0,V.useCallback)(()=>{g({action:`refresh`}),z({type:`refresh-page`})},[z]),Pe=(0,V.useCallback)(()=>{g({action:`back`}),z({type:`go-back`})},[z]),Fe=(0,V.useCallback)(()=>{g({action:`forward`}),z({type:`go-forward`})},[z]),K=(0,V.useCallback)(()=>{z({type:`get-aria-tree`})},[z]),Ie=(0,V.useCallback)(e=>{g({action:`navigate`,targetUrl:e}),z({type:`navigate`,url:e})},[z]),Le=(0,V.useCallback)((e,t)=>new Promise(n=>{M.current=n;let r=A.current[e];if(!r||!r.instruction.trim()){M.current=null,n({status:`skipped`});return}be.current++;let i=be.current;j.current=e,v(e),l(t=>t.map((t,n)=>n===e?{...t,status:`running`,phases:[],executionHistory:t.phases.length>0?[...t.executionHistory,{phases:t.phases,status:t.status,duration:t.duration,error:t.error,timestamp:new Date().toISOString()}]:t.executionHistory,error:void 0,duration:void 0,consoleLogs:[],networkLogs:[],variableSnapshot:null,originalStepName:null,subActionsData:null,executionLogs:[],executionGeneration:i}:t)),c(`executing`),_(null),z({type:`execute-step`,stepInstruction:r.instruction,stepIndex:e,draft:t})}),[z]),Re=(0,V.useCallback)(async t=>{if(S)return;ye.current=!1;let n=A.current.length;C(!0),ue(!1),J(`hook`,`running all steps`,{sessionId:e,stepCount:n});try{for(let e=0;e<n&&!ye.current;e++){if(!A.current[e].instruction.trim())continue;let n=await Le(e,t);if(n.status===`failed`||n.status===`cancelled`)break}}finally{ye.current=!1,C(!1),ue(!1)}},[Le,S,e]),ze=(0,V.useCallback)(()=>{S&&(ye.current=!0,ue(!0),l(e=>e.map((e,t)=>t===j.current&&e.status===`running`?{...e,status:`cancelling`}:e)),j.current!==null&&z({type:`cancel-step`}))},[S,z]),Be=(0,V.useCallback)((e,t)=>new Promise(n=>{we.current=n;let r=L.current[e];if(!r){we.current=null,n({status:`skipped`});return}let i=crypto.randomUUID();Se.current=e,pe(e),w(t=>t.map((t,n)=>n===e?{...t,status:`running`,duration:void 0,error:void 0,testExecutionId:i,runningStepIndex:null,liveSteps:[],perTestSetupHooks:[],perTestTeardownHooks:[]}:t)),c(`executing`),_(null),z({type:`execute-test`,testExecutionId:i,testId:r.testId,path:r.path,testIndex:e,draft:t})}),[z]),Ve=(0,V.useCallback)(async(e,t)=>{L.current[e]&&await Be(e,t)},[Be]),He=(0,V.useCallback)(async e=>{if(T)return;Ce.current=!1;let t=L.current.length;E(!0),he(!1);try{for(let n=0;n<t&&!Ce.current;n++){let t=await Be(n,e);if(t.status===`failed`||t.status===`cancelled`)break}}finally{Ce.current=!1,E(!1),he(!1)}},[Be,T]),Ue=(0,V.useCallback)(()=>{T&&(Ce.current=!0,he(!0),Se.current!==null&&z({type:`cancel-step`}))},[T,z]);return{connectionState:s,steps:ee,setupHooks:u,teardownHooks:te,screenshot:f,currentUrl:p,pendingNavigation:h,error:ie,executeStep:De,executeStepByIndex:Oe,executeHookById:ke,cancelStep:Me,requestScreenshot:G,refreshPage:Ne,goBack:Pe,goForward:Fe,navigate:Ie,runAll:Re,cancelRunAll:ze,terminateSession:(0,V.useCallback)(()=>{ye.current=!0,C(!1),ue(!1),ve.current=!0,J(`hook`,`terminating session`,{sessionId:e}),z({type:`terminate-session`})},[z,e]),addStep:Ae,removeStep:U,updateStepInstruction:je,reorderSteps:W,runningStepIndex:ae,runningStepId:ae===null?null:ee[ae]?.id??null,sessionId:e,isTerminated:ve.current,deviceLogs:oe,platform:y,ariaTree:b,requestAriaTree:K,isRunningAll:S,isStoppingRunAll:le,tests:de,executeTestByIndex:Ve,runAllTests:He,cancelRunAllTests:Ue,runningTestIndex:fe,isRunningAllTests:T,isStoppingRunAllTests:me}}function it(e){try{let t=m(e);if(t.errors.length>0)return{};let n=t.toJSON(),r=n?.use?.mobile?.appState;return{headless:n?.use?.browser?.headless,device:typeof n?.use?.device==`string`?n.use.device:void 0,appState:r===`preserve`||r===`reset`?r:void 0}}catch{return{}}}function at(e){let t=e.targets[e.targetName];if(!t)throw Error(`Selected target "${e.targetName}" was not found in workspace config`);let n=it(e.content),r=n.headless??e.globalUse?.browser?.headless;if(t.platform===`web`){if(!t.url)throw Error(`Selected web target "${e.targetName}" is missing a URL`);return{platform:`web`,url:t.url,headless:r}}return{platform:t.platform,targetName:e.targetName,useDeviceName:n.device,appState:n.appState??e.globalUse?.mobile?.appState,bundleId:t.bundleId,appPackage:t.appPackage,appActivity:t.appActivity,headless:r}}var ot=[{namespace:`runJS`,name:`document.title`,label:`Page title`},{namespace:`runJS`,name:`Date.now()`,label:`Current timestamp`},{namespace:`runJS`,name:`window.location.href`,label:`Current URL`},{namespace:`runJS`,name:`document.querySelector('...').textContent`,label:`Extract element text`}];function st(e){let[t,n]=(0,V.useState)([]),[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let t=!1;c(!0);let r=[T().then(e=>{t||n(e.keys)}).catch(()=>{t||n([])}),j().then(e=>{t||i(e.hooks.map(e=>({id:e.id,name:e.name})))}).catch(()=>{t||i([])})];return e&&r.push(w(e).then(e=>{t||o(e.names)}).catch(()=>{t||o([])})),Promise.allSettled(r).then(()=>{t||c(!1)}),()=>{t=!0}},[e]),{suggestions:(0,V.useMemo)(()=>{let e=[];for(let n of t)e.push({namespace:`env`,name:n,label:`env`});for(let t of r)e.push({namespace:`runHook`,name:t.name,label:`hook`,insertValue:t.id,description:t.id});for(let t of a)e.push({namespace:`capture`,name:t,label:`captured`});return e.push(...ot),e},[t,r,a]),isLoading:s}}var ct=/^[a-zA-Z0-9._-]+$/,lt=/\.(yaml|yml)$/;function ut(e){return e.trim().replace(/\\/g,`/`).replace(/^\.\//,``)}function dt(e){let t=ut(e).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\?/g,`.`).replace(/\*\*\//g,`__DIRSTAR__`).replace(/\*\*/g,`__DIRSTAR__`).replace(/\*/g,`[^/]*`).replace(/__DIRSTAR__/g,`(?:.*/)?`);return RegExp(`^${t}$`)}function ft(e,t){let n=ut(e);return t.some(e=>dt(e).test(n))}function pt(e){let t=e.trim();if(!t)return`Filename is required`;if(t.includes(`..`))return`Path must not contain '..' segments`;if(t.startsWith(`/`))return`Path must be relative, not absolute`;let n=t.split(`/`);for(let e of n){if(!e)return`Path contains empty segment (double slash)`;if(!ct.test(e))return`Path must contain only letters, numbers, hyphens, dots, underscores, and forward slashes, ending with .yaml or .yml`}let r=n[n.length-1];return lt.test(r)?null:`File must end with .yaml or .yml`}function mt(e,t,n){let r=pt(e);if(r)return r;let i=(t??[]).map(e=>e.trim()).filter(Boolean);return i.length===0?`workspace.${n} must contain at least one pattern`:ft(e.trim(),i)?null:`File path must match one of your workspace's ${n} patterns (${i.join(`, `)})`}export{J as a,Ne as c,rt as i,st as n,q as o,at as r,Pe as s,mt as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./arrow-up-down-DD6yziGv.js";import{i as n,n as r,o as i,s as a,t as o}from"./select-D5oFJNaq.js";import{t as s}from"./file-code-BpwHxsqo.js";import{n as c,r as l}from"./shortcut-hints-CtwepXR1.js";import{t as u}from"./plus-Qf7V331e.js";import{t as d}from"./use-page-title-B4YPyIzc.js";import{n as ee,t as te}from"./scroll-area-BmkJ1y7Q.js";import{$n as f,Ht as ne,Mt as re,Nt as ie,Pt as ae,Qn as p,Ut as m,W as oe,Wt as h,a as se,cr as ce,jt as le,pr as g,qt as _,ur as v}from"./index-B4FdO6Vk.js";import{t as y}from"./badge-CC1v3nk4.js";import{a as ue,i as b,n as de,o as x,r as S,t as C}from"./table-QG2rKYu8.js";import{r as w,t as fe}from"./hook-runtime-CTRviwQE.js";import{t as pe}from"./empty-state-BfgY0UGA.js";import{t as me}from"./use-keyboard-shortcuts-Bal_Cx9w.js";var T=e(g(),1),E=new Set([`asc`,`desc`]);function D(e){let t=new URLSearchParams;return e.search&&t.set(`search`,e.search),e.runtime&&t.set(`runtime`,e.runtime),e.health&&t.set(`health`,e.health),e.sort&&(t.set(`sort`,e.sort),t.set(`order`,e.order)),t}function he(){let[e,t]=v(),n=e.get(`search`)??``,r=e.get(`runtime`)??``,i=e.get(`health`)??``,a=e.get(`sort`)??``,o=e.get(`order`)??`asc`,s=E.has(o)?o:`asc`,c=(0,T.useMemo)(()=>a?[{id:a,desc:s===`desc`}]:[],[a,s]),l=(0,T.useRef)(c);l.current=c;let u=(0,T.useMemo)(()=>({search:n,runtime:r,health:i,sort:a,order:s}),[n,r,i,a,s]);(0,T.useEffect)(()=>{let n=D(u);n.toString()!==e.toString()&&t(n,{replace:!0})},[e,t,u]);let d=(0,T.useCallback)(e=>{t(D({...u,...e}),{replace:!0})},[t,u]);return{search:n,runtime:r,health:i,sort:a,order:s,sorting:c,onSortingChange:(0,T.useCallback)(e=>{let t=typeof e==`function`?e(l.current):e;t.length>0?d({sort:t[0].id,order:t[0].desc?`desc`:`asc`}):d({sort:``,order:`asc`})},[d]),setSearch:(0,T.useCallback)(e=>d({search:e}),[d]),setRuntime:(0,T.useCallback)(e=>d({runtime:e}),[d]),setHealth:(0,T.useCallback)(e=>d({health:e}),[d])}}var O=p(),k={hooks:[],filePath:null,errors:[],missing:!1},A=50;function j(e){return e.fileMissing?`file-missing`:`ready`}function M(e){return e===`file-missing`?`File missing`:`Ready`}function ge({hook:e}){return j(e)===`file-missing`?(0,O.jsx)(y,{variant:`outline`,className:`border-amber-500/30 text-amber-600`,children:`File missing`}):(0,O.jsx)(y,{variant:`outline`,className:`border-emerald-500/30 text-emerald-600`,children:`Ready`})}function _e({runtime:e}){let t=w(e),n=t.icon;return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,O.jsx)(`span`,{children:t.label})]})}function ve({title:e,body:t}){return(0,O.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm`,children:[(0,O.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,O.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}function ye({isActive:e}){return h(`cursor-pointer outline-none hover:bg-muted/20 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary/60`,e&&`bg-primary/10 ring-1 ring-inset ring-primary/60`)}function N(){d(`Hooks`);let e=ce(),[p,h]=(0,T.useState)(k),[g,v]=(0,T.useState)(null),[y,E]=(0,T.useState)(!0),[D,N]=(0,T.useState)(-1),[P,F]=(0,T.useState)(0),I=(0,T.useRef)([]),{search:L,runtime:R,health:z,sorting:B,onSortingChange:be,setSearch:V,setRuntime:H,setHealth:U}=he();(0,T.useEffect)(()=>{let e=!1;return oe().then(t=>{e||(h(t),v(null))}).catch(t=>{e||(h(k),v(t instanceof Error?t.message:`Failed to load hooks`))}).finally(()=>{e||E(!1)}),()=>{e=!0}},[]);let W=(0,T.useMemo)(()=>g?{title:`Hooks could not be loaded`,body:g}:p.missing?{title:`${p.filePath??`configured hooks file`} not found`,body:`Create the first hook to generate the configured hooks file for this workspace.`}:p.errors.length>0?{title:`Hooks could not be loaded from ${p.filePath??`configured hooks file`}`,body:p.errors[0]??`Unknown registry error`}:null,[p.errors,p.filePath,p.missing,g]),G=(0,T.useMemo)(()=>{let e=L.trim().toLowerCase(),t=B[0],n=p.hooks.filter(t=>R&&t.runtime!==R||z&&j(t)!==z?!1:e?t.name.toLowerCase().includes(e)||t.file.toLowerCase().includes(e)||t.id.toLowerCase().includes(e):!0);return t?[...n].sort((e,n)=>{let r=0;switch(t.id){case`runtime`:r=w(e.runtime).label.localeCompare(w(n.runtime).label);break;case`timeout`:r=e.timeout-n.timeout;break;case`health`:r=M(j(e)).localeCompare(M(j(n)));break;default:r=e.name.localeCompare(n.name);break}return t.desc?r*-1:r}):n},[p.hooks,z,R,L,B]),K=G.length,q=Math.ceil(K/A),J=q>0?Math.min(P,q-1):0,Y=J*A,X=G.slice(Y,Y+A),xe=K>0?Y+1:0,Se=Math.min(Y+A,K);(0,T.useEffect)(()=>{P!==J&&F(J)},[P,J]);let Ce=(0,T.useCallback)(e=>{N(-1),F(0),V(e)},[V]),we=(0,T.useCallback)(e=>{N(-1),F(0),H(e===`all`?``:e)},[H]),Te=(0,T.useCallback)(e=>{N(-1),F(0),U(e===`all`?``:e)},[U]),Z=(0,T.useCallback)((t,n=!1)=>{let r=f.hookView(t.id);if(n){window.open(r,`_blank`);return}e(r)},[e]);me((0,T.useMemo)(()=>{let e=()=>N(e=>Math.min(e+1,X.length-1)),t=()=>N(e=>Math.max(e-1,0));return{j:e,arrowdown:e,k:t,arrowup:t,enter:e=>{D<0||!X[D]||Z(X[D],e.metaKey||e.ctrlKey)}}},[Z,D,X])),(0,T.useEffect)(()=>{if(X.length===0){D!==-1&&N(-1);return}D>=X.length&&N(X.length-1)},[D,X.length]),(0,T.useEffect)(()=>{if(D<0)return;let e=I.current[D];e&&document.activeElement!==e&&e.focus()},[D,X.length]);let Ee=(0,T.useCallback)((e,t)=>{t&&t.preventDefault(),Z(e,!!(t&&(t.metaKey||t.ctrlKey)))},[Z]);function Q(e){N(-1),F(0),be(t=>{let n=t[0];return!n||n.id!==e?[{id:e,desc:!1}]:n.desc?[]:[{id:e,desc:!0}]})}if(y)return(0,O.jsx)(se,{});let De=K===0,$=!p.errors.length&&!g;return(0,O.jsx)(ie,{children:(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Hooks`}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage reusable setup, teardown, and inline hook scripts for this workspace.`})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(le,{children:[(0,O.jsx)(ae,{asChild:!0,children:(0,O.jsx)(m,{variant:`ghost`,size:`icon-sm`,type:`button`,"aria-label":`Keyboard shortcuts`,children:(0,O.jsx)(l,{className:`h-4 w-4`})})}),(0,O.jsx)(re,{side:`bottom`,className:`p-3`,children:(0,O.jsx)(c,{hints:[{key:`J / ↓`,label:`Next row`},{key:`K / ↑`,label:`Previous row`},{key:`Enter`,label:`Open hook`},{key:`⌘+Enter`,label:`Open in new tab`}]})})]}),(0,O.jsxs)(m,{type:`button`,onClick:()=>e(f.hookNew),children:[(0,O.jsx)(u,{className:`h-4 w-4`}),`Create Hook`]})]})]}),W&&(0,O.jsx)(ve,{title:W.title,body:W.body}),(0,O.jsx)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,O.jsx)(ne,{value:L,onChange:e=>Ce(e.currentTarget.value),placeholder:`Search hooks`,className:`lg:max-w-sm`,"aria-label":`Search hooks`}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,O.jsxs)(o,{value:R||`all`,onValueChange:we,children:[(0,O.jsx)(i,{className:`w-full sm:w-44`,"aria-label":`Runtime filter`,children:(0,O.jsx)(a,{placeholder:`Runtime`})}),(0,O.jsxs)(r,{children:[(0,O.jsx)(n,{value:`all`,children:`All runtimes`}),fe.map(e=>(0,O.jsx)(n,{value:e,children:w(e).label},e))]})]}),(0,O.jsxs)(o,{value:z||`all`,onValueChange:Te,children:[(0,O.jsx)(i,{className:`w-full sm:w-44`,"aria-label":`Health filter`,children:(0,O.jsx)(a,{placeholder:`Health`})}),(0,O.jsxs)(r,{children:[(0,O.jsx)(n,{value:`all`,children:`All health`}),(0,O.jsx)(n,{value:`ready`,children:`Ready`}),(0,O.jsx)(n,{value:`file-missing`,children:`File missing`})]})]})]})]})}),De?(0,O.jsx)(pe,{icon:s,title:p.hooks.length===0?`No hooks yet`:`No hooks match your filters`,description:p.hooks.length===0?`Create a hook to add reusable setup, teardown, or inline automation to this workspace.`:`Adjust your search or filters to see more hook records.`,actionLabel:$?`Create Hook`:void 0,onAction:$?()=>e(f.hookNew):void 0}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(te,{className:`rounded-md border`,children:[(0,O.jsxs)(C,{className:`min-w-full`,children:[(0,O.jsx)(ue,{children:(0,O.jsxs)(x,{children:[(0,O.jsx)(b,{className:`w-[40%]`,children:(0,O.jsxs)(m,{type:`button`,variant:`ghost`,className:`-ml-3`,onClick:()=>Q(`name`),children:[`Hook`,(0,O.jsx)(t,{className:`h-4 w-4`})]})}),(0,O.jsx)(b,{children:(0,O.jsxs)(m,{type:`button`,variant:`ghost`,className:`-ml-3`,onClick:()=>Q(`runtime`),children:[`Runtime`,(0,O.jsx)(t,{className:`h-4 w-4`})]})}),(0,O.jsx)(b,{children:(0,O.jsxs)(m,{type:`button`,variant:`ghost`,className:`-ml-3`,onClick:()=>Q(`timeout`),children:[`Timeout / Network`,(0,O.jsx)(t,{className:`h-4 w-4`})]})}),(0,O.jsx)(b,{children:(0,O.jsxs)(m,{type:`button`,variant:`ghost`,className:`-ml-3`,onClick:()=>Q(`health`),children:[`Health`,(0,O.jsx)(t,{className:`h-4 w-4`})]})})]})}),(0,O.jsx)(de,{children:X.map((e,t)=>{let n=t===D;return(0,O.jsxs)(x,{ref:e=>{I.current[t]=e},"data-hooks-row-surface":e.id,tabIndex:n?0:-1,"aria-selected":n,className:ye({isActive:n}),onClick:()=>{N(t),Z(e)},onFocus:()=>N(t),onKeyDown:t=>{t.key===`Enter`&&Ee(e,t)},children:[(0,O.jsx)(S,{className:`max-w-0`,children:(0,O.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,O.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.file})]})}),(0,O.jsx)(S,{children:(0,O.jsx)(_e,{runtime:e.runtime})}),(0,O.jsx)(S,{children:(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-sm text-foreground`,children:_(e.timeout)}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.network?`Network on`:`Network off`})]})}),(0,O.jsx)(S,{children:(0,O.jsx)(ge,{hook:e})})]},e.id)})})]}),(0,O.jsx)(ee,{orientation:`horizontal`})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-2`,children:[(0,O.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Showing `,xe,`-`,Se,` of `,K]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(-1),F(e=>Math.max(e-1,0))},disabled:J===0,children:`Previous`}),(0,O.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(-1),F(e=>Math.min(e+1,Math.max(q-1,0)))},disabled:J>=q-1,children:`Next`})]})]})]})]})})}export{N as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{a as t,c as n,n as r,o as i,r as a,s as o,t as s}from"./use-run-status-favicon-Rjqwuxhd.js";import{d as c}from"./tab-console-BORDNFzI.js";import{t as l}from"./circle-x-B7AOkLOS.js";import{t as u}from"./square-CgFZz_zK.js";import{t as d}from"./use-page-title-B4YPyIzc.js";import{$n as ee,At as f,C as te,Fn as ne,Jn as p,Nt as re,Q as m,Qn as h,U as ie,Un as ae,Ut as g,Wt as _,bt as v,cr as oe,er as se,ir as ce,lr as le,n as ue,nr as de,or as y,pr as fe,rr as pe,tr as b}from"./index-B4FdO6Vk.js";import{t as x}from"./badge-CC1v3nk4.js";import{n as me,r as he,t as ge}from"./resizable-B2X6KlcC.js";import{t as _e}from"./empty-state-BfgY0UGA.js";import{i as S,n as C,r as w}from"./display-step-CO4k5dQA.js";var ve=p(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ye=p(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),T=e(fe(),1);function E(e=null){return L({runId:e,testInfo:null,steps:[],displaySteps:[],setupHooks:[],teardownHooks:[],inlineLogs:[],suiteTests:[],completedSteps:0,passedSteps:0,failedSteps:0,totalSteps:0,processedEventIds:[],stepNodes:[]})}function D(e){let t=e.runId??null,n=e.parentRunId??null,r=H(e);return t&&e.stepId?`step:${t}:${e.stepId}`:t&&typeof e.stepIndex==`number`?`step:${t}:index:${e.stepIndex}`:n&&r!==null&&e.stepId?`step:${n}:suite:${r}:step:${e.stepId}`:n&&r!==null&&typeof e.stepIndex==`number`?`step:${n}:suite:${r}:index:${e.stepIndex}`:n&&e.stepId?`step:${n}:${e.stepId}`:n&&typeof e.stepIndex==`number`?`step:${n}:index:${e.stepIndex}`:null}function be(e){return`hook:${e.runId??e.parentRunId??`unknown-run`}:${e.hookExecutionId}`}function O(e,t){if(t.eventId&&e.processedEventIds.includes(t.eventId))return e;let n=t.eventId?{...e,processedEventIds:[...e.processedEventIds,t.eventId]}:e;switch(t.type){case`run-start`:return L({...n,runId:t.runId});case`test-start`:return k(n,t);case`test-complete`:return A(n,t);case`step-start`:return j(n,t);case`step-phase`:return M(n,t);case`step-complete`:return N(n,t);case`hook-start`:return P(n,t);case`hook-end`:return F(n,t);case`run-complete`:return I(n,t);case`run-error`:return I(n,{type:`run-complete`,runId:t.runId,status:`failed`,duration:0});default:return n}}function xe(e,t){let n={...e},r=Ee(t,e.suiteTests),i=t.run?.id??e.runId??null,a=[...t.steps??[],...(t.childRuns??[]).flatMap(e=>e.steps)];t.run&&(n={...n,runId:n.runId??t.run.id,finalStatus:t.run.status}),t.suiteTests&&(n={...n,suiteTests:t.suiteTests});for(let e of a){let t=r.get(e.runId)??null,a=n.stepNodes.findIndex(n=>n.runId&&n.runId!==e.runId?!1:n.runId===e.runId&&n.stepId&&n.stepId===e.id||n.runId===e.runId&&typeof n.stepIndex==`number`&&n.stepIndex===e.stepOrder||!n.runId&&i&&n.parentRunId===i&&t!==null&&H(n)===t&&(n.stepId&&n.stepId===e.id||typeof n.stepIndex==`number`&&n.stepIndex===e.stepOrder)?!0:!n.runId&&!n.parentRunId&&n.name===e.name&&n.status!==`running`),o=a>=0?n.stepNodes[a]:null,s=K(C(e),o),c=a>=0?n.stepNodes[a].key:`step:${e.runId}:index:${e.stepOrder}`,l={...a>=0?n.stepNodes[a]:{key:c,phases:[],phaseGroups:{},status:y(e.status)},key:c,runId:e.runId,stepId:e.id,stepIndex:e.stepOrder,name:e.name,status:y(e.status),duration:e.duration,error:e.error??void 0,display:s},u=[...n.stepNodes];a>=0?u[a]=l:u.push(l),n={...n,stepNodes:u}}let o=[...t.logs??[],...(t.childRuns??[]).flatMap(e=>e.logs??[])];if(o.length>0){let e=Y(n.setupHooks,o.filter(e=>e.phase===`setup`)),t=Y(n.teardownHooks,o.filter(e=>e.phase===`teardown`)),r=Y(n.inlineLogs,o.filter(e=>e.phase===`inline`));n={...n,setupHooks:e,teardownHooks:t,inlineLogs:r}}return L(n)}function k(e,t){let n={name:t.testName,filePath:t.filePath,totalSteps:t.totalSteps},r=e.suiteTests;if(t.parentRunId&&typeof t.suiteIndex==`number`){let e=ke(t),n=[...r];n[t.suiteIndex]=e,r=n.filter(Boolean)}return L({...e,runId:e.runId??t.parentRunId??t.runId,testInfo:n,suiteTests:r})}function A(e,t){if(!t.parentRunId||typeof t.suiteIndex!=`number`)return e;let n=[...e.suiteTests],r=n[t.suiteIndex];return r&&(n[t.suiteIndex]={...r,status:t.status,duration:t.duration,endedAt:new Date().toISOString()}),L({...e,suiteTests:n})}function j(e,t){let n=V(e,t),r=e.stepNodes.findIndex(e=>e.key===n),i={...r>=0?e.stepNodes[r]:{key:n,phases:[],phaseGroups:{}},key:n,runId:t.runId,parentRunId:t.parentRunId,suiteIndex:t.suiteIndex,testIndex:t.testIndex,stepIndex:t.stepIndex,stepId:t.stepId,testName:t.testName,name:t.stepName,status:`running`};return L({...e,stepNodes:q(e.stepNodes,r,i)})}function M(e,t){let n=B(e,t);if(n<0)return M(j(e,{...t,type:`step-start`,timestamp:t.timestamp}),t);let r=e.stepNodes[n],i={phase:t.phase,subActionIndex:t.subActionIndex,phaseOrdinal:t.phaseOrdinal,text:t.text,confidence:t.confidence,action:t.action,success:t.success,duration:t.duration,timestamp:t.timestamp},a=[...r.phases,i],o={...r.phaseGroups};typeof t.subActionIndex==`number`&&(o[t.subActionIndex]=[...o[t.subActionIndex]??[],i]);let s={...r,phases:a,phaseGroups:o,observation:t.phase===`observe`?t.text:r.observation,reasoning:t.phase===`plan`?t.text:r.reasoning,plannedAction:t.phase===`execute`?t.action:r.plannedAction,action:t.phase===`execute`?t.action:r.action,confidence:t.phase===`plan`?t.confidence??null:r.confidence};return L({...e,stepNodes:q(e.stepNodes,n,s)})}function N(e,t){let n=B(e,t),r=n>=0?e.stepNodes[n].key:V(e,t),i={...n>=0?e.stepNodes[n]:{key:r,phases:[],phaseGroups:{}},key:r,runId:t.runId,parentRunId:t.parentRunId,suiteIndex:t.suiteIndex,testIndex:t.testIndex,stepIndex:t.stepIndex,stepId:t.stepId,name:t.stepName,testName:t.testName,status:y(t.status),duration:t.duration,error:t.error,screenshot:t.screenshot,screenshotBefore:t.screenshotBefore,observation:t.observation,reasoning:t.reasoning,plannedAction:t.plannedAction,result:t.result,annotation:t.annotation??null};return L({...e,stepNodes:q(e.stepNodes,n,i)})}function P(e,t){return L(De(e,J(t,`running`),t.phase))}function F(e,t){return L(De(e,J(t,t.status),t.phase))}function I(e,t){let n=se(t.status);return L({...e,finalStatus:t.status,stepNodes:e.stepNodes.map(e=>e.status===`running`?{...e,status:n}:e)})}function L(e){let t=S(e.stepNodes.map(Ce)),n=[...e.setupHooks.map(R),...e.stepNodes.map(Se),...e.teardownHooks.map(R)],r=t.filter(e=>![`pending`,`running`].includes(e.status)).length,i=t.filter(e=>[`passed`,`healed`,`flaky`].includes(e.status)).length,a=t.filter(e=>[`failed`,`cancelled`,`skipped`].includes(e.status)).length,o=e.testInfo?.totalSteps??t.length;return{...e,displaySteps:t,steps:n,completedSteps:r,passedSteps:i,failedSteps:a,totalSteps:o}}function R(e){return{id:e.id,kind:`hook`,hookPhase:e.phase,hookExecutionId:e.id,name:e.name,status:e.status,duration:e.duration,error:e.stderr??void 0}}function Se(e){return{id:e.key,kind:`step`,name:e.name,status:e.status,duration:e.duration,error:e.error,screenshot:e.screenshot,reasoning:e.reasoning,observation:e.observation,result:e.result,plannedAction:e.plannedAction,annotation:e.annotation??void 0,phases:e.phases}}function Ce(e){if(e.display)return{...e.display,id:e.key,rawRunId:e.display.rawRunId??e.runId??null,runId:e.display.runId??e.runId??null};let t=z(e),n=t?.find(e=>!!(e.observation||e.reasoning||e.plannedAction!=null));return{id:e.key,name:e.name,status:e.status,duration:e.duration??0,subActionsData:t,originalStepName:null,variableSnapshot:null,screenshotPath:Oe(e.screenshot),screenshotBeforePath:Oe(e.screenshotBefore),annotationData:e.annotation??null,observation:e.observation??n?.observation??null,reasoning:e.reasoning??n?.reasoning??null,plannedAction:e.plannedAction??n?.plannedAction??null,action:e.action??e.plannedAction??n?.plannedAction??null,error:e.error??null,confidence:e.confidence??n?.confidence??null,runId:e.runId??null,stepOrder:e.stepIndex??0,consoleLogs:null,networkLogs:null,healingAttempts:null,screenContextBefore:null,screenContextAfter:null,rawRunId:e.runId??null,rawStepOrder:e.stepIndex??0,displayStepOrder:(e.stepIndex??0)+1,displayStepTotal:null}}function z(e){let t=Object.entries(e.phaseGroups);return t.length===0?w(e.phases):t.sort(([e],[t])=>Number(e)-Number(t)).map(([e,t])=>we(Number(e),t))}function we(e,t){let n=t.find(e=>e.phase===`observe`),r=t.find(e=>e.phase===`plan`),i=t.find(e=>e.phase===`execute`),a=t.find(e=>e.phase===`verify`);return{index:e,observation:n?.text??``,reasoning:r?.text??``,plannedAction:i?.action??null,result:a?a.success?`success`:`failure`:`in-progress`,error:void 0,screenStateBefore:``,cached:!1,confidence:r?.confidence,verifierReasoning:a?.text,phaseDurations:{observe:n?.duration,plan:r?.duration,execute:i?.duration,verify:a?.duration}}}function B(e,t){let n=D(t);if(n){let t=e.stepNodes.findIndex(e=>e.key===n);if(t>=0)return t}if(t.runId&&typeof t.stepIndex==`number`){let n=e.stepNodes.findIndex(e=>e.runId===t.runId&&e.stepIndex===t.stepIndex);if(n>=0)return n}let r=Te(e.stepNodes,t);if(r>=0)return r;if(t.stepId){let n=e.stepNodes.findIndex(e=>e.stepId===t.stepId&&U(e,t));if(n>=0)return n}return e.stepNodes.findIndex(e=>e.name===t.stepName&&e.status===`running`&&U(e,t))}function V(e,t){let n=H(t),r=t.parentRunId&&n!==null?`${t.parentRunId}:suite:${n}`:t.runId??t.parentRunId??e.runId??`legacy`;return D(t)??`step:${r}:${t.stepName}:${e.stepNodes.length}`}function H(e){return typeof e.suiteIndex==`number`?e.suiteIndex:typeof e.testIndex==`number`?e.testIndex:null}function Te(e,t){let n=H(t);return!t.parentRunId||n===null||typeof t.stepIndex!=`number`?-1:e.findIndex(e=>e.parentRunId===t.parentRunId&&H(e)===n&&e.stepIndex===t.stepIndex)}function U(e,t){if(t.runId&&e.runId&&e.runId!==t.runId||t.parentRunId&&e.parentRunId&&e.parentRunId!==t.parentRunId)return!1;let n=H(t),r=H(e);return!(n!==null&&r!==null&&n!==r)}function Ee(e,t){let n=new Map;return t.forEach((e,t)=>W(n,e,t)),e.suiteTests?.forEach((e,t)=>W(n,e,t)),e.childRuns?.forEach((e,t)=>W(n,e.run,t)),n}function W(e,t,n){e.set(t.id,G(t)??e.get(t.id)??n)}function G(e){let t=e.metadata?.suiteIndex;if(typeof t==`number`)return t;if(typeof t==`string`&&t.trim()!==``){let e=Number(t);if(Number.isInteger(e))return e}return null}function K(e,t){if(!t||e.subActionsData)return e;let n=z(t);if(!n)return e;let r=n.find(e=>!!(e.observation||e.reasoning||e.plannedAction!=null));return{...e,subActionsData:n,observation:e.observation??t.observation??r?.observation??null,reasoning:e.reasoning??t.reasoning??r?.reasoning??null,plannedAction:e.plannedAction??t.plannedAction??r?.plannedAction??null,action:e.action??t.action??t.plannedAction??r?.plannedAction??null,confidence:e.confidence??t.confidence??r?.confidence??null}}function q(e,t,n){let r=[...e];return t>=0?r[t]=n:r.push(n),r}function J(e,t){return{id:be(e),runId:e.runId??e.parentRunId??``,stepId:e.stepId??null,type:`logType`in e&&e.logType?e.logType:`hook`,name:e.hookName,hookId:e.hookId??null,phase:e.phase,status:t,duration:`duration`in e?e.duration:0,stdout:`stdout`in e?e.stdout??null:null,stderr:`stderr`in e?e.stderr??null:null,returnData:null,variables:`variables`in e?e.variables??null:null,createdAt:e.timestamp}}function De(e,t,n){return n===`setup`?{...e,setupHooks:Y(e.setupHooks,[t])}:n===`teardown`?{...e,teardownHooks:Y(e.teardownHooks,[t])}:{...e,inlineLogs:Y(e.inlineLogs,[t])}}function Y(e,t){let n=[...e];for(let e of t){let t=n.findIndex(t=>t.id===e.id||t.id.endsWith(`:${e.id}`));t>=0?n[t]={...n[t],...e,id:n[t].id}:n.push(e)}return n}function Oe(e){return e?e.startsWith(`data:image/`)||e.startsWith(`blob:`)||e.startsWith(`http://`)||e.startsWith(`https://`)?e:`data:image/png;base64,${e}`:null}function ke(e){let t=e.timestamp??new Date().toISOString();return{id:e.runId,name:e.testName,filePath:e.filePath,status:`running`,duration:0,attributes:{},environment:null,metadata:{suiteIndex:e.suiteIndex},startedAt:t,endedAt:null,videoPath:null,failureSummary:null,errorLog:null,memoryLog:null,testId:null,suiteId:e.parentRunId??null,platform:`unknown`,testFileContent:null,modelName:null,llmProvider:null,parentRunId:e.parentRunId??null,attemptNumber:1,retryCount:0,maxRetries:0,createdAt:t}}function Ae(e,t){let[n,r]=(0,T.useState)(()=>E(e)),[i,a]=(0,T.useState)(`idle`),[o,s]=(0,T.useState)(),[c,l]=(0,T.useState)(0),[u,d]=(0,T.useState)(),ee=(0,T.useRef)(null),f=(0,T.useCallback)(e=>{r(t=>xe(t,e))},[]);return(0,T.useEffect)(()=>{if(!e){a(`idle`);return}let n=!1;r(E(e)),s(void 0),d(void 0),l(0),a(`connecting`);let i=t?new Date(t).getTime():Date.now();l(Math.max(0,Math.floor((Date.now()-i)/1e3)));let o=setInterval(()=>{n||l(Math.max(0,Math.floor((Date.now()-i)/1e3)))},1e3),c=v(e,{onRunStart:e=>{n||(a(`running`),r(t=>O(t,{type:`run-start`,runId:e.runId,status:e.status,eventId:e.eventId})))},onTestStart:e=>{n||r(t=>O(t,e))},onHookStart:e=>{n||r(t=>O(t,e))},onHookEnd:e=>{n||r(t=>O(t,e))},onStepStart:e=>{n||r(t=>O(t,e))},onStepComplete:e=>{n||r(t=>O(t,e))},onStepPhase:e=>{n||r(t=>O(t,e))},onRunComplete:e=>{if(!n){let t=b(e.status);a(`complete`),s(t.normalized),clearInterval(o),r(t=>O(t,e))}},onRunError:e=>{n||(a(`error`),d(e.error),clearInterval(o),r(t=>O(t,{type:`run-error`,...e})))}});return ee.current=c,()=>{n=!0,clearInterval(o),c.close(),ee.current=null}},[e,t]),{steps:n.steps,displaySteps:n.displaySteps,setupHooks:n.setupHooks,teardownHooks:n.teardownHooks,inlineLogs:n.inlineLogs,suiteTests:n.suiteTests,testInfo:n.testInfo,runStatus:i,finalStatus:o,elapsed:c,error:u,completedSteps:n.completedSteps,passedSteps:n.passedSteps,failedSteps:n.failedSteps,totalSteps:n.totalSteps,mergeFinalArtifacts:f}}var X=h();function je(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Me({status:e,finalStatus:t}){if(e===`complete`&&t){let e=b(t);return(0,X.jsx)(x,{className:de(e.tone),children:e.label})}switch(e){case`connecting`:return(0,X.jsx)(x,{className:`border-amber-500/20 bg-amber-500/15 text-amber-500`,children:`Connecting...`});case`running`:return(0,X.jsx)(x,{className:`border-blue-500/20 bg-blue-500/15 text-blue-500`,children:`Running`});case`complete`:return(0,X.jsx)(x,{className:`border-emerald-500/20 bg-emerald-500/15 text-emerald-500`,children:`Complete`});case`error`:return(0,X.jsx)(x,{variant:`destructive`,children:`Error`});default:return(0,X.jsx)(x,{variant:`outline`,children:`Idle`})}}function Ne(e){return e?e.type===`step`?`step:${e.stepId}`:e.type===`subaction`?`sub:${e.stepId}:${e.subIndex}`:e.type===`execution`?`exec:${e.stepId}:${e.logId}`:e.type===`hook`?`hook:${e.hookId}`:e.type===`suite-hook`?`suite-hook:${e.phase}:${e.hookId}`:e.type===`test-hook`?`test-hook:${e.testIndex}:${e.phase}:${e.hookId}`:`test:${e.testIndex}`:null}function Pe(e,t){return e.stepId?e.stepId===t.id||t.id.endsWith(`:${e.stepId}`)?!0:t.rawRunId&&e.runId&&t.rawRunId!==e.runId?!1:Number.parseInt(e.stepId,10)===t.rawStepOrder:!1}function Fe(e,t,n,r){if(!e)return!1;if(e.type===`hook`)return n.some(t=>t.id===e.hookId);if(e.type===`execution`)return r.some(t=>t.id===e.logId);if(i(e)){let n=t.find(t=>t.id===e.stepId);return n?e.type===`subaction`?!!n.subActionsData?.[e.subIndex]:!0:!1}return!1}function Ie(e,t,n,r){let i=[...e].reverse().find(e=>e.status===`running`)??e.at(-1);if(i){let e=r.filter(e=>Pe(e,i)),t=[...e].reverse().find(e=>e.status===`running`)??e.at(-1);if(t)return{type:`execution`,stepId:i.id,logId:t.id};let n=i.subActionsData??[];return n.length>0?{type:`subaction`,stepId:i.id,subIndex:n.length-1}:{type:`step`,stepId:i.id}}let a=[...t,...n].at(-1);return a?{type:`hook`,hookId:a.id}:null}function Le(){d(`Live Run`);let{id:e}=le(),p=oe(),[h,v]=(0,T.useState)(null),[se,de]=(0,T.useState)(!1),[y,fe]=(0,T.useState)(!1),[x,S]=(0,T.useState)(null),[C,w]=(0,T.useState)(!0),[E,D]=(0,T.useState)(`overview`),[be,O]=(0,T.useState)(),xe=(0,T.useRef)(null),{displaySteps:k,setupHooks:A,teardownHooks:j,inlineLogs:M,suiteTests:N,testInfo:P,runStatus:F,finalStatus:I,elapsed:L,error:R,completedSteps:Se,passedSteps:Ce,failedSteps:z,totalSteps:we,mergeFinalArtifacts:B}=Ae(e??null,h?.startedAt),[V,H]=(0,T.useState)(!1);async function Te(){if(!(y||!e)){fe(!0);try{await te(e),f.success(`Run cancelled`)}catch{f.error(`Failed to cancel run`)}finally{fe(!1)}}}(0,T.useEffect)(()=>{if(!e)return;let t=!1;return v(null),H(!1),de(!0),m(e).then(e=>{t||v(e.run)}).catch(e=>{let n=e instanceof Error&&e.message.includes(`404`);!t&&!n&&f.error(`Failed to load run details`)}).finally(()=>{t||de(!1)}),()=>{t=!0}},[e]);let U=!!(h&&ce(h.status));(0,T.useEffect)(()=>{if(!e||V||!(F===`complete`||F===`error`||U))return;let t=!1;async function n(){try{let[n,r]=await Promise.all([m(e),ie(e).catch(()=>({logs:[]}))]);if(t)return;let i=[];if(n.tests&&n.tests.length>0)for(let e of n.tests)try{let n=await m(e.id);if(t)return;i.push({run:n.run,steps:n.steps})}catch{i.push({run:e,steps:[]})}B({run:n.run,steps:n.steps,logs:r.logs,suiteTests:n.tests,childRuns:i}),v(n.run),H(!0)}catch{t||H(!0)}}return n(),()=>{t=!0}},[U,V,e,B,F]);let Ee=I?s(I):h&&U?s(h.status):F===`error`?`failed`:F===`connecting`||F===`running`?`running`:`default`;r(e?Ee:`default`);let W=(0,T.useMemo)(()=>[...A,...j],[A,j]),G=(0,T.useMemo)(()=>Ie(k,A,j,M),[k,M,A,j]),K=Ne(G),q=Ne(x);(0,T.useEffect)(()=>{if(!G){x&&S(null);return}if(C||!x){q!==K&&S(G);return}if(!Fe(x,k,W,M)){let e=i(x)?k.find(e=>e.id===x.stepId):null;S(e?{type:`step`,stepId:e.id}:G)}},[W,q,k,M,C,K,G,x]);let J=(0,T.useCallback)(e=>{w(!1),S(e)},[]),De=(0,T.useCallback)(()=>{w(!0),G&&S(G)},[G]),Y=(0,T.useMemo)(()=>i(x)?k.find(e=>e.id===x.stepId)??null:null,[k,x]),Oe=(0,T.useMemo)(()=>!o(x)||!Y?null:Y.subActionsData?.[x.subIndex]??null,[x,Y]),ke=(0,T.useMemo)(()=>Y?M.filter(e=>Pe(e,Y)):[],[M,Y]),Le=(0,T.useMemo)(()=>x?.type===`hook`?W.find(e=>e.id===x.hookId)??null:null,[W,x]),Re=(0,T.useMemo)(()=>x?.type===`execution`?M.find(e=>e.id===x.logId)??null:null,[M,x]);if(!e)return(0,X.jsx)(_e,{icon:ye,title:`No run selected`,description:`Select a test run to watch live execution`});if(F===`idle`&&se)return(0,X.jsx)(ue,{});let Z=!!(U&&!I&&F!==`running`),ze=P?.name??h?.name??`Test Run`,Be=P?.filePath??h?.filePath??void 0,Q=we||k.length,Ve=Se||k.filter(e=>![`pending`,`running`].includes(e.status)).length,He=Q>0?Math.round(Ve/Q*100):0,Ue=(F===`running`||F===`connecting`)&&!Z,We=F===`complete`||F===`error`||Z,$=b(I??h?.status),Ge=!!(I||Z),Ke=k.length>0||A.length>0||j.length>0,qe=N.length>0?`all`:void 0;return(0,X.jsx)(re,{children:(0,X.jsxs)(`div`,{className:`flex h-screen min-w-0 flex-col overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center justify-between border-b px-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(ye,{className:_(`h-4 w-4 shrink-0`,Ue&&`animate-pulse text-blue-500`,We&&`text-muted-foreground`)}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold leading-tight`,children:`Live Execution`}),(0,X.jsx)(Me,{status:Z?`complete`:F,finalStatus:I??h?.status})]}),(0,X.jsxs)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:ze}),Be&&(0,X.jsx)(`span`,{className:`ml-2`,children:Be})]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.jsx)(g,{variant:`ghost`,size:`sm`,onClick:De,disabled:!G||C,className:`h-7 px-2 text-xs`,children:`Latest`}),Ue&&(0,X.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:Te,disabled:y,className:`h-7 px-2 text-xs text-muted-foreground transition-colors hover:bg-red-500/10 hover:text-red-400`,children:[(0,X.jsx)(l,{className:`size-3.5`}),y?`Cancelling...`:`Cancel`]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-sm text-muted-foreground`,children:[(0,X.jsx)(c,{className:`h-3.5 w-3.5`}),je(L)]}),(0,X.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>p(ee.runDetail(e)),className:`h-7 px-2 text-xs`,children:[`View Full Results`,(0,X.jsx)(ve,{className:`ml-1 h-3.5 w-3.5`})]})]})]}),(0,X.jsxs)(`div`,{className:`shrink-0 border-b px-3 py-2`,children:[Q>0?(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[`Step `,Ve,` of `,Q]}),(0,X.jsxs)(`span`,{children:[He,`%`]})]}),(0,X.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:_(`h-full rounded-full transition-all duration-300`,F===`error`||Ge&&$.tone===`danger`?`bg-destructive`:Ge&&$.tone===`muted`?`bg-muted-foreground`:`bg-emerald-500`),style:{width:`${He}%`}})})]}):null,F===`error`&&R?(0,X.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 rounded-[2px] bg-destructive/10 p-2 text-destructive`,children:[(0,X.jsx)(ne,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,X.jsxs)(`div`,{className:`text-sm`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`Run Error`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs`,children:R})]})]}):Ge?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-4 text-sm`,children:[(0,X.jsxs)(`span`,{className:_(`flex items-center gap-1.5 font-medium`,pe($.tone)),children:[$.normalized===`passed`?(0,X.jsx)(ae,{className:`h-4 w-4`}):$.normalized===`cancelled`?(0,X.jsx)(u,{className:`h-4 w-4`}):$.normalized===`flaky`||$.normalized===`healed`?(0,X.jsx)(ne,{className:`h-4 w-4`}):(0,X.jsx)(l,{className:`h-4 w-4`}),$.label]}),k.length>0&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[Ce,` passed, `,z,` failed`]})]}):null]}),(0,X.jsxs)(he,{orientation:`horizontal`,className:`min-h-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(me,{defaultSize:35,minSize:20,children:(0,X.jsx)(`div`,{className:`flex h-full min-h-0 min-w-[280px] flex-col overflow-y-auto`,children:Ke?(0,X.jsx)(t,{steps:k,selection:x,onSelect:J,suiteTests:N.length>0?N:void 0,suiteSelectedView:qe,setupHooks:A,teardownHooks:j,inlineLogs:M}):(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Waiting for live events...`})})}),(0,X.jsx)(ge,{withHandle:!0}),(0,X.jsx)(me,{defaultSize:65,minSize:30,children:(0,X.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:x?.type===`hook`&&Le?(0,X.jsx)(n,{log:Le}):x?.type===`execution`&&Re?(0,X.jsx)(n,{log:Re}):(0,X.jsx)(a,{activeTab:E,onTabChange:D,step:Y,subAction:Oe,runId:Y?.rawRunId??e,allSteps:k,executionLogs:ke,platform:h?.platform,screenshotSide:be,onScreenshotSideChange:e=>O(e),pipelineRef:xe})})})]})]})})}export{Le as default};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{i as t,n,o as r,s as i,t as a}from"./select-D5oFJNaq.js";import{t as o}from"./copy-CEZJVgtu.js";import{t as s}from"./observation-block-DC5e2IE9.js";import{n as c,r as l}from"./shortcut-hints-CtwepXR1.js";import{t as u}from"./use-page-title-B4YPyIzc.js";import{n as d,r as f,t as p}from"./popover-DwYq4QYF.js";import{$n as m,At as h,Ft as g,Mt as _,Nt as v,Pt as y,Qn as b,S as ee,Ut as x,Wn as S,Wt as C,Y as w,Yt as T,cr as E,jt as D,lr as O,pr as k,qn as A,sr as j}from"./index-B4FdO6Vk.js";import{t as M}from"./empty-state-BfgY0UGA.js";import{t as te}from"./use-keyboard-shortcuts-Bal_Cx9w.js";var N=e(k(),1),P=b(),F={any:`Any (0.00 - 1.00)`,high:`High (0.75 - 1.00)`,medium:`Medium (0.50 - 0.74)`,low:`Low (0.00 - 0.49)`},I={last_confirmed:`Last confirmed`,updated:`Updated`,created:`Created`},L=[`all`,`7d`,`30d`,`90d`];function R({filters:e,onConfidenceChange:o,onDateBasisChange:s,onDateWindowChange:c,showHeading:l=!0}){return(0,P.jsxs)(`aside`,{"data-workspace-filter-rail":`true`,className:`space-y-4`,children:[l?(0,P.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Filters`}):null,(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Confidence`}),(0,P.jsxs)(a,{onValueChange:e=>o(e),children:[(0,P.jsx)(r,{className:`w-full justify-between bg-background/70`,children:(0,P.jsx)(i,{placeholder:F[e.confidence]})}),(0,P.jsxs)(n,{children:[(0,P.jsx)(t,{value:`any`,children:F.any}),(0,P.jsx)(t,{value:`high`,children:F.high}),(0,P.jsx)(t,{value:`medium`,children:F.medium}),(0,P.jsx)(t,{value:`low`,children:F.low})]})]})]}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Date`}),(0,P.jsxs)(a,{onValueChange:e=>s(e),children:[(0,P.jsx)(r,{className:`w-full justify-between bg-background/70`,children:(0,P.jsx)(i,{placeholder:I[e.dateBasis]})}),(0,P.jsxs)(n,{children:[(0,P.jsx)(t,{value:`last_confirmed`,children:`Last confirmed`}),(0,P.jsx)(t,{value:`updated`,children:`Updated`}),(0,P.jsx)(t,{value:`created`,children:`Created`})]})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(t=>(0,P.jsx)(x,{type:`button`,variant:e.dateWindow===t?`default`:`outline`,size:`xs`,"aria-pressed":e.dateWindow===t,onClick:()=>c(t),children:t===`all`?`All time`:t},t))})]})]})]})}function ne({onCopyPage:e,onShortcutsOpenChange:t,productKey:n,shortcutsOpen:r}){return(0,P.jsxs)(`div`,{"data-workspace-navbar":`true`,className:`flex h-14 min-w-0 shrink-0 items-center justify-between border-b bg-background px-4`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(j,{to:m.memory,className:`shrink-0 text-sm text-muted-foreground transition-colors hover:text-foreground`,children:`Memory`}),(0,P.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,P.jsxs)(x,{"data-workspace-copy-button":`true`,type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 rounded-sm px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3.5`,onClick:()=>{e()},children:[(0,P.jsx)(o,{className:`size-4`}),`Copy page`]}),(0,P.jsxs)(p,{open:r,onOpenChange:t,children:[(0,P.jsxs)(D,{children:[(0,P.jsx)(y,{asChild:!0,children:(0,P.jsx)(f,{asChild:!0,children:(0,P.jsx)(x,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Keyboard shortcuts`,onClick:()=>t(!r),children:(0,P.jsx)(l,{className:`size-4`})})})}),(0,P.jsx)(_,{children:`Shortcuts`})]}),(0,P.jsx)(d,{align:`end`,sideOffset:8,className:`w-72 p-4`,children:(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`mb-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Navigation`}),(0,P.jsx)(c,{hints:[{key:`J / ↓`,label:`Next entry`},{key:`K / ↑`,label:`Previous entry`}]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`mb-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Actions`}),(0,P.jsx)(c,{hints:[{key:`C`,label:`Copy page`},{key:`Shift+?`,label:`Toggle shortcuts`},{key:`Esc`,label:`Close`}]})]})]})})]})]})]})}function z({activeAnchorId:e=null,document:t,onNavigate:n,showHeading:r=!0}){let i=(0,N.useRef)(null);return(0,N.useEffect)(()=>{i.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[e]),(0,P.jsxs)(`aside`,{"data-workspace-outline":`true`,className:`space-y-3`,children:[r?(0,P.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`On this page`}):null,(0,P.jsx)(`nav`,{"aria-label":`Page outline`,children:(0,P.jsx)(`ul`,{className:`space-y-1`,children:t.outline.map(t=>B(t,0,e,n,i))})})]})}function B(e,t,n,r,i){let a=n===e.anchorId;return(0,P.jsxs)(`li`,{className:`space-y-1`,children:[(0,P.jsx)(`button`,{type:`button`,ref:a?i:null,"data-workspace-outline-item":e.anchorId,"data-active":a?`true`:void 0,"aria-current":a?`location`:void 0,className:C(`block w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-accent hover:text-foreground`,t===0?`font-medium text-foreground`:`text-muted-foreground`,t===1?`pl-4`:``,t>=2?`pl-6 text-[13px]`:``,a?`bg-accent text-foreground`:``),onClick:()=>r(e.anchorId),children:e.title}),e.children.length>0?(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.children.map(e=>B(e,t+1,n,r,i))}):null]},e.anchorId)}var V=[{id:`product`,title:`Product`},{id:`suite`,title:`Suite`},{id:`test`,title:`Test`}],H={confidence:`any`,dateBasis:`last_confirmed`,dateWindow:`all`};function U(e,t){let n=V.map(({id:n,title:r})=>({anchorId:`memory-section-${n}`,groups:K(n,e,t.filter(e=>e.scope===n)),id:n,title:r}));return{outline:q(n),productKey:e,sections:n}}function re(e,t,n){return e.filter(e=>ie(e,t.confidence)&&ae(e,t.dateBasis,t.dateWindow,n))}function W(e){return e.flatMap(e=>[e.anchorId,...W(e.children)])}function G(e,t=[]){let n=[`# Memory: ${e.productKey}`,``];t.length>0&&n.push(`> ${t.length} invalid memory file${t.length===1?``:`s`} hidden from this workspace.`,`> ${t.map(e=>e.filename).join(`, `)}`,``);for(let t of e.sections){if(n.push(`## ${t.title}`,``),t.id===`product`){for(let e of t.groups[0]?.observations??[])n.push(`### ${e.observation.title}`,``,e.observation.content,``);continue}for(let e of t.groups){e.title&&n.push(`### ${e.title}`,``);for(let t of e.observations)n.push(`#### ${t.observation.title}`,``,t.observation.content,``)}}return n.join(`
2
- `).trim()}function K(e,t,n){let r=[...n].sort(Y);if(e===`product`)return r.length>0?[{anchorId:`memory-group-product-${Q(t)}`,id:t,title:null,observations:r.map(Z)}]:[];let i=new Map;for(let e of r){let t=e.scopeRef?.id??e.scopeId,n=i.get(t);if(n){n.observations.push(e);continue}i.set(t,{title:e.scopeRef?.label??e.scopeId,observations:[e]})}return[...i.entries()].map(([t,n])=>({anchorId:`memory-group-${e}-${Q(t)}`,id:t,title:n.title,observations:n.observations.sort(Y).map(Z)})).sort(J)}function q(e){return e.map(e=>({anchorId:e.anchorId,children:e.id===`product`?(e.groups[0]?.observations??[]).map(e=>({anchorId:e.anchorId,children:[],id:e.observation.id,title:e.observation.title})):e.groups.map(t=>({anchorId:t.anchorId,children:t.observations.map(e=>({anchorId:e.anchorId,children:[],id:e.observation.id,title:e.observation.title})),id:t.id,title:t.title??e.title})),id:e.id,title:e.title}))}function J(e,t){let n=e.observations[0]?.observation,r=t.observations[0]?.observation;if(n&&r){let e=Y(n,r);if(e!==0)return e}return(e.title??``).localeCompare(t.title??``)}function Y(e,t){return X(e.last_confirmed,t.last_confirmed)||X(e.updated,t.updated)||e.title.localeCompare(t.title)}function X(e,t){return t.localeCompare(e)}function ie(e,t){switch(t){case`any`:return!0;case`high`:return e.trust>=.75;case`medium`:return e.trust>=.5&&e.trust<.75;case`low`:return e.trust<.5}}function ae(e,t,n,r){if(n===`all`)return!0;let i=e[t],a=new Date(i).getTime();if(Number.isNaN(a))return!1;let o=new Date(r),s=oe(n);return o.setDate(o.getDate()-s),a>=o.getTime()}function oe(e){switch(e){case`7d`:return 7;case`30d`:return 30;case`90d`:return 90}}function Z(e){return{anchorId:`memory-observation-${Q(e.id)}`,id:e.id,observation:e}}function Q(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function se(){let{product:e}=O();u(e?`Memory · ${e}`:`Memory`);let t=E(),[n,r]=(0,N.useState)(null),[i,a]=(0,N.useState)(!0),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(!1),[d,f]=(0,N.useState)(H),[p,_]=(0,N.useState)(null),[y,b]=(0,N.useState)(!1),x=T(),S=(0,N.useCallback)(()=>{if(!e)return a(!1),s(!0),()=>{};let t=!1;return a(!0),l(!1),s(!1),w(e).then(e=>{t||r(e.product)}).catch(e=>{if(!t){if(r(null),e instanceof ee&&e.status===404){s(!0);return}l(!0)}}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e]);(0,N.useEffect)(()=>S(),[S]),(0,N.useEffect)(()=>{f(H)},[e]),(0,N.useEffect)(()=>{b(!1)},[e]);let C=(0,N.useMemo)(()=>new Date,[e]),D=(0,N.useMemo)(()=>n?U(n.productKey,n.observations):null,[n]),k=(0,N.useMemo)(()=>n?re(n.observations,d,C):[],[n,d,C]),j=(0,N.useMemo)(()=>n?U(n.productKey,k):null,[n,k]),F=(0,N.useMemo)(()=>D&&n?G(D,n.invalidFiles):null,[n,D]),I=(0,N.useMemo)(()=>j?W(j.outline):[],[j]);(0,N.useEffect)(()=>{if(!j){_(null);return}let e=W(j.outline);if(_(t=>t&&e.includes(t)?t:e[0]??null),typeof IntersectionObserver>`u`)return;let t=new Map(e.map((e,t)=>[e,t])),n=new IntersectionObserver(e=>{let n=e.filter(e=>e.isIntersecting).sort((e,n)=>{let r=n.intersectionRatio-e.intersectionRatio;return r===0?(t.get(e.target.id)??2**53-1)-(t.get(n.target.id)??2**53-1):r})[0];n&&_(n.target.id)},{rootMargin:`-72px 0px -55% 0px`,threshold:[.2,.6,1]});for(let t of e){let e=document.getElementById(t);e&&n.observe(e)}return()=>n.disconnect()},[j]);let L=(0,N.useCallback)(e=>{_(e),document.getElementById(e)?.scrollIntoView({block:`start`})},[]),B=(0,N.useCallback)(async()=>{if(F)try{await navigator.clipboard.writeText(F),h.success(`Copied page as Markdown`)}catch{h.error(`Couldn't copy page`)}},[F]),V=(0,N.useCallback)(e=>{if(I.length===0)return;let t=p?I.indexOf(p):-1,n=I[t<0?0:Math.min(I.length-1,Math.max(0,t+e))];n&&L(n)},[p,L,I]),K=(0,N.useCallback)(e=>{f(t=>({...t,confidence:e}))},[]),q=(0,N.useCallback)(e=>{f(t=>({...t,dateBasis:e}))},[]),J=(0,N.useCallback)(e=>{f(t=>({...t,dateWindow:e}))},[]);return te((0,N.useMemo)(()=>({j:()=>V(1),arrowdown:()=>V(1),k:()=>V(-1),arrowup:()=>V(-1),c:()=>{B()},"shift+?":()=>b(e=>!e),escape:()=>b(!1)}),[B,V])),i?(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(g,{className:`h-8 w-32`}),(0,P.jsx)(g,{className:`h-9 w-72 max-w-full`}),(0,P.jsx)(g,{className:`h-4 w-64 max-w-full`})]}),(0,P.jsx)(g,{className:`h-28 w-full rounded-md`}),(0,P.jsx)(g,{className:`h-56 w-full rounded-md`})]}):o?(0,P.jsx)(M,{icon:A,title:`Memory not found for this product`,description:`This product doesn't currently have cataloged memory in this workspace, or the product key changed.`,actionLabel:`Back to Memory`,onAction:()=>t(m.memory)}):c||!n?(0,P.jsx)(`div`,{className:`rounded-md border bg-card p-4`,children:(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Couldn't load this memory workspace. Refresh the page. If it continues, verify the dashboard server can read the workspace memory directory.`})}):(0,P.jsx)(v,{children:(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,P.jsx)(ne,{onCopyPage:B,onShortcutsOpenChange:b,productKey:n.productKey,shortcutsOpen:y}),x?(0,P.jsx)(`div`,{className:`workspace-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-3 py-3`,children:(0,P.jsx)(ce,{activeAnchorId:p,detail:n,document:j,filters:d,onConfidenceChange:K,onDateBasisChange:q,onDateWindowChange:J,onNavigate:L})}):(0,P.jsxs)(`div`,{"data-workspace-shell":`true`,className:`grid min-h-0 flex-1 grid-cols-[15rem_minmax(0,1fr)_14rem] overflow-hidden`,children:[(0,P.jsx)(`aside`,{className:`workspace-scrollbar min-h-0 overflow-y-auto overscroll-y-contain border-r border-border bg-background`,children:(0,P.jsx)(`div`,{className:`min-h-full px-3 py-3`,children:j?(0,P.jsx)(z,{activeAnchorId:p,document:j,onNavigate:L}):null})}),(0,P.jsx)(`div`,{className:`workspace-scrollbar min-h-0 min-w-0 overflow-y-auto overscroll-y-contain bg-muted/[0.04]`,children:(0,P.jsx)($,{detail:n,document:j})}),(0,P.jsx)(`aside`,{className:`workspace-scrollbar min-h-0 overflow-y-auto overscroll-y-contain border-l border-border bg-background`,children:(0,P.jsx)(`div`,{className:`min-h-full px-3 py-3`,children:(0,P.jsx)(R,{filters:d,onConfidenceChange:K,onDateBasisChange:q,onDateWindowChange:J})})})]})]})})}function ce({activeAnchorId:e,detail:t,document:n,filters:r,onConfidenceChange:i,onDateBasisChange:a,onDateWindowChange:o,onNavigate:s}){return(0,P.jsxs)(`div`,{className:`space-y-4`,children:[n?(0,P.jsxs)(`details`,{className:`border bg-card px-3 py-2.5`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-foreground`,children:`On this page`}),(0,P.jsx)(`div`,{className:`mt-3`,children:(0,P.jsx)(z,{activeAnchorId:e,document:n,onNavigate:s,showHeading:!1})})]}):null,(0,P.jsxs)(`details`,{className:`border bg-card px-3 py-2.5`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-foreground`,children:`Filters`}),(0,P.jsx)(`div`,{className:`mt-3`,children:(0,P.jsx)(R,{filters:r,onConfidenceChange:i,onDateBasisChange:a,onDateWindowChange:o,showHeading:!1})})]}),(0,P.jsx)($,{detail:t,document:n})]})}function $({detail:e,document:t}){return(0,P.jsx)(`div`,{"data-workspace-reader-page":`true`,className:`min-h-full w-full bg-card/55`,children:(0,P.jsxs)(`div`,{className:`px-4 py-4 sm:px-5`,children:[e.invalidFiles.length>0?(0,P.jsxs)(`div`,{className:`mb-4 border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-950 dark:text-amber-200`,children:[(0,P.jsxs)(`p`,{className:`font-medium`,children:[e.invalidFiles.length,` invalid memory file`,e.invalidFiles.length===1?``:`s`,` hidden from this workspace.`]}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-amber-900/80 dark:text-amber-200/80`,children:e.invalidFiles.map(e=>e.filename).join(`, `)})]}):null,e.observations.length===0?(0,P.jsx)(M,{icon:A,title:`No memory in this product yet`,description:`This product doesn't have cataloged observations in this workspace yet. Run tests or suites with memory enabled, then reopen this workspace.`}):t&&le(t)?(0,P.jsx)(`article`,{className:`w-full space-y-10`,children:t.sections.map(e=>(0,P.jsxs)(`section`,{id:e.anchorId,"data-workspace-section":e.id,className:`scroll-mt-20 space-y-5`,children:[(0,P.jsx)(`header`,{className:`border-b pb-3`,children:(0,P.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground`,children:e.title})}),e.groups.length>0?(0,P.jsx)(`div`,{className:`space-y-8`,children:e.groups.map(e=>(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsx)(`div`,{id:e.anchorId,className:`scroll-mt-20`,children:e.title?(0,P.jsx)(`h3`,{className:`text-base font-medium tracking-tight text-foreground`,children:e.title}):(0,P.jsx)(`span`,{className:`sr-only`,children:`Product observations`})}),(0,P.jsx)(`div`,{className:`space-y-8`,children:e.observations.map(e=>(0,P.jsx)(`div`,{id:e.anchorId,className:`scroll-mt-24`,children:(0,P.jsx)(s,{observation:e.observation,query:``})},e.observation.id))})]},e.anchorId))}):(0,P.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No `,e.title.toLowerCase(),` observations in this workspace yet.`]})]},e.id))}):(0,P.jsx)(M,{icon:A,title:`No observations match these filters`,description:`Clear one or more filters to return to the full document.`})]})})}function le(e){return e.sections.some(e=>e.groups.some(e=>e.observations.length>0))}export{se as default};
@@ -1 +0,0 @@
1
- import{Jn as e}from"./index-B4FdO6Vk.js";var t=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};