@xopcai/xopc 0.0.192 → 0.0.193

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 (121) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-B-tzXpDD.js → activity-store-BwmdJ5pv.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-xOu0qNwc.js → agent-avatar-dicebear-DmNq0t2n.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-BOo1rVn9.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-fMItZb-h.js → api-BM1hNzjw.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-D6Rv3OWI.js → app-management-settings-panel-B3xStqSX.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CKoNCwco.js → appearance-settings-DglyenDq.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-DC9qPFTx.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BokNQBwH.js → archive-plugin-DvtcrBss.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dx1HglsM.js → attachment-load-CALdq4xM.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BIGGKb0T.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-CPYAflIG.js → binary-plugins-GaVuvrDI.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BFLgl8SS.js → block-editor-C2KrMYa_.js} +47 -47
  15. package/dist/gateway/static/root/assets/browser-settings-page-CPW_E-xj.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CqLnqA9z.js → browser-workflow-inputs-FfEEjhIS.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-Db5v3HtE.js → browser-workflows-page-DFP9_UQk.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-CsD8aGHU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-lov0J9A2.js → capability-presets-api-BoOzFotX.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-NCeyWH6Z.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-DSJznouK.js → channel-recipient-api-_8IiTxRB.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-CknzwxNC.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-3ccRyS3L.js → connectors-api-vaSrhPF8.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-DEGE7xp_.js +2 -0
  26. package/dist/gateway/static/root/assets/{cron-expression-C9hhCiuo.js → cron-expression-BjFuXlGY.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-CTtZFZug.js → dependency-picker-DOdkHdPv.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-DOUeNVmC.js → desktop-pet-Dz-Yf8Uu.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-D4704vtl.js → desktop-pet-settings-C8EHFEtd.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-DJDXeA1B.js → directory-picker-path-field-DKbfmZlZ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-C0n2NMF1.js → extension-debug-page-Dq0xsr_e.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-vG-xxRNs.js → extension-page-IgSLUyWP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-CtuY2THd.js → extension-settings-page-VC-8Pjn2.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-CZra7GuI.js → gateway-config-api-CH2R7yqo.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Cz33jRkR.js → gateway-settings-DLQJWaBQ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-BbVV0udv.js → gateway-startup-retry--2njcDpC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-D2XMlA_U.js → heartbeat-settings-43loWoGb.js} +1 -1
  38. package/dist/gateway/static/root/assets/home-page-DqvpI6LC.js +3 -0
  39. package/dist/gateway/static/root/assets/{image-generation-api-BgrOvhaJ.js → image-generation-api-Cki7jfEV.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-DzmbmOGA.js → index-BpkdvHH0.js} +61 -61
  41. package/dist/gateway/static/root/assets/index-CFVjH-EK.css +1 -0
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BfyAEG1G.js → keyboard-shortcuts-settings-DJDZes_8.js} +1 -1
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-CvNQM6qm.js +2 -0
  44. package/dist/gateway/static/root/assets/{local-apps-page-BYalcRSY.js → local-apps-page-C2ajOn1D.js} +1 -1
  45. package/dist/gateway/static/root/assets/{locale-store-VOY1wMO9.js → locale-store-Bjvw7jtg.js} +1 -1
  46. package/dist/gateway/static/root/assets/logs-page-BLm5yWqQ.js +2 -0
  47. package/dist/gateway/static/root/assets/{management-settings-BQf-6s32.js → management-settings--_eXnFVr.js} +1 -1
  48. package/dist/gateway/static/root/assets/{markdown-split-Cy_2SN1Q.js → markdown-split-iL2oi-x2.js} +1 -1
  49. package/dist/gateway/static/root/assets/{media-plugins-CkDupqb2.js → media-plugins-BIbkLVpQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{messages-DMJ-6-1m.js → messages-DQ5X6cXp.js} +2 -2
  51. package/dist/gateway/static/root/assets/{notes-page-kiGRR9jo.js → notes-page-xFxaZ6gT.js} +1 -1
  52. package/dist/gateway/static/root/assets/notes-workbench-PAftxL3V.js +4 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-CvzSdYVj.js → page-tabs-CROi9zm1.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-kZ0nco7e.js → preview-open-alternatives-BwYcPjOM.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DgoieqQC.js → product-open-page-BezeuVFd.js} +1 -1
  56. package/dist/gateway/static/root/assets/project-detail-page-CCdfZcw-.js +1 -0
  57. package/dist/gateway/static/root/assets/projects-page-DOG9zm5e.js +1 -0
  58. package/dist/gateway/static/root/assets/remote-access-hub-DQBFgveI.js +1 -0
  59. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bud_NTEZ.js → runtime-tools-settings-panel-Bs6tpSyX.js} +2 -2
  60. package/dist/gateway/static/root/assets/{schema-form-GlbsCBmv.js → schema-form-CWoSjz9s.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-Db6L6M2H.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-CcO2bd6q.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-form-section-CKLns16d.js → settings-form-section-BJaMEHsX.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BDzpxgk0.js → settings-loading-skeleton-sn4k17x7.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-BH0pF7QB.js → settings-page-D2hfeFPX.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-J793iqfm.js → settings-page-layout-CLtUsWsu.js} +1 -1
  67. package/dist/gateway/static/root/assets/setup-status-panel-UmQC_uZ1.js +1 -0
  68. package/dist/gateway/static/root/assets/{share-preview-page-UTm_7r0l.js → share-preview-page-BJ58AluH.js} +1 -1
  69. package/dist/gateway/static/root/assets/shares-settings-BZKn6Fdc.js +1 -0
  70. package/dist/gateway/static/root/assets/skill-reload-api-Cx3i24w_.js +1 -0
  71. package/dist/gateway/static/root/assets/skills-page-DjUllGtk.js +2 -0
  72. package/dist/gateway/static/root/assets/{skills-page.utils-Bwid1TGB.js → skills-page.utils-CZYIuE26.js} +1 -1
  73. package/dist/gateway/static/root/assets/system-settings-panel-DUrgdQMk.js +1 -0
  74. package/dist/gateway/static/root/assets/task-detail-page-BGG2cFe9.js +1 -0
  75. package/dist/gateway/static/root/assets/{theme-store-GVZOImyb.js → theme-store-DtxpMC5S.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-CT2c85Ju.js → typed-models-lib-CRNMvvFX.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-autosave-CcvY7DTh.js → use-autosave-Dle3-zdQ.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-context-page-BLLmw5S1.js +1 -0
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-Ricc3QGo.js → voice-api-key-field-BrWH0dCl.js} +1 -1
  80. package/dist/gateway/static/root/assets/{work-discovery-overlay-BoomfqhX.js → work-discovery-overlay-BZ1l9CFM.js} +1 -1
  81. package/dist/gateway/static/root/assets/work-discovery-page-BnPF2vx7.js +1 -0
  82. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BK6e9yzK.js +3 -0
  83. package/dist/gateway/static/root/assets/workflows-page-Bp5JxQJa.js +5 -0
  84. package/dist/gateway/static/root/index.html +7 -7
  85. package/dist/gateway/static/root/notification-sw.js +15 -0
  86. package/dist/package.js +1 -1
  87. package/dist/src/auth/oauth/xopc-cloud.js +163 -7
  88. package/dist/src/gateway/heartbeat/service.js +1 -1
  89. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  90. package/dist/src/gateway/service/run-gateway-agent.js +21 -8
  91. package/dist/src/heartbeat/index.js +1 -1
  92. package/package.json +3 -3
  93. package/dist/gateway/static/root/assets/agents-CxuwvDk0.js +0 -68
  94. package/dist/gateway/static/root/assets/apps-page-wAb5dnHZ.js +0 -1
  95. package/dist/gateway/static/root/assets/automations-page-Drgazevs.js +0 -6
  96. package/dist/gateway/static/root/assets/browser-settings-page-DmYlFJW7.js +0 -8
  97. package/dist/gateway/static/root/assets/capabilities-settings-panel-D7Z8T0o5.js +0 -7
  98. package/dist/gateway/static/root/assets/capability-presets-settings-panel-COjnwO0U.js +0 -3
  99. package/dist/gateway/static/root/assets/channels-settings-DcRYBNN7.js +0 -1
  100. package/dist/gateway/static/root/assets/channels-status-swr-C2UYdebT.js +0 -1
  101. package/dist/gateway/static/root/assets/connectors-page-FVmvBG9H.js +0 -2
  102. package/dist/gateway/static/root/assets/home-page-CPrHkPN6.js +0 -3
  103. package/dist/gateway/static/root/assets/index-Cg7Xnlu3.css +0 -1
  104. package/dist/gateway/static/root/assets/local-app-workbench-page-Clz47vSr.js +0 -2
  105. package/dist/gateway/static/root/assets/logs-page-Cxq9WMf5.js +0 -2
  106. package/dist/gateway/static/root/assets/notes-workbench-DkYkPGyB.js +0 -4
  107. package/dist/gateway/static/root/assets/project-detail-page-CeSjJd-N.js +0 -1
  108. package/dist/gateway/static/root/assets/projects-page-fZ1rm4b9.js +0 -1
  109. package/dist/gateway/static/root/assets/remote-access-hub-CbYI6KC8.js +0 -1
  110. package/dist/gateway/static/root/assets/sessions-page-sOJ_TnLm.js +0 -1
  111. package/dist/gateway/static/root/assets/settings-advanced-gate-BI0u77dt.js +0 -1
  112. package/dist/gateway/static/root/assets/setup-status-panel-CGsml89P.js +0 -1
  113. package/dist/gateway/static/root/assets/shares-settings-BM--lgUS.js +0 -1
  114. package/dist/gateway/static/root/assets/skill-reload-api-CGCOC-rV.js +0 -1
  115. package/dist/gateway/static/root/assets/skills-page-iLyaOl48.js +0 -2
  116. package/dist/gateway/static/root/assets/system-settings-panel-BcB3p1e3.js +0 -1
  117. package/dist/gateway/static/root/assets/task-detail-page-DQYEf08v.js +0 -1
  118. package/dist/gateway/static/root/assets/user-context-page-CGI41bfO.js +0 -1
  119. package/dist/gateway/static/root/assets/work-discovery-page-mbnepbQk.js +0 -1
  120. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DSWG2xqL.js +0 -3
  121. package/dist/gateway/static/root/assets/workflows-page-DtV0ruyk.js +0 -5
@@ -1,6 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DMJ-6-1m.js";import{n as c}from"./locale-store-VOY1wMO9.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$l as u,Ao as d,Do as f,Eo as p,Fa as m,Fc as h,Gr as g,Gs as _,Ho as v,Kr as y,Mo as b,Ms as x,Oo as S,Ta as C,Uo as w,Wr as T,Xs as ee,Yr as E,_ as D,_i as te,_s as O,au as k,hc as A,hs as j,iu as ne,ji as re,jo as ie,kl as M,l as N,nc as P,nu as ae,oc as F,pc as oe,pl as se,qr as ce,sr as le,tu as I,vs as L,wa as ue,wu as de,xc as R,yc as z,zc as fe}from"./index-DzmbmOGA.js";import{a as B,i as V,o as pe,r as H}from"./cron-expression-C9hhCiuo.js";import{a as me,i as he,n as ge,r as U,t as _e}from"./workflow-run-setup-panel-DSWG2xqL.js";import{i as ve,n as ye,r as be,t as xe}from"./browser-workflow-inputs-CqLnqA9z.js";var W=e(t(),1),G=n(),Se=B();function Ce(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function we(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function K(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Te(e){return e.length===5&&e.every((e,t)=>e===t+1)}function Ee(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function De(e,t,n,r){try{let i=Se.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=H(i.minute.values),o=H(i.hour.values),s=H(i.dayOfWeek.values),c=H(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=V(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=V(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?Ce(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Te(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=we(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=K(s.map(e=>we(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function Oe(e,t,n,r){let i=e.trim();return i?De(i,t,n,r)||ke(r?.nextRun,t)||n.customSchedule:ke(r?.nextRun,t)||`—`}function ke(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var q=1e3,Ae=60*q,J=60*Ae,Y=24*J,X=7*Y,je=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Me=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Ne={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Pe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Fe={minute:Ae,hour:J,day:Y,week:X};function Ie(e){return e===`zh`?`zh-CN`:`en-US`}function Le(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Me[String(t)].format(e)}function Re(e,t){return t===`zh`?e.join(` `):je.format(e)}function ze(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(Ae,Math.round((Number.isFinite(n)&&n>0?n:1)*Fe[t]))}function Be(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Fe[t]/Fe[n]).toFixed(6)))}function Ve(e,t){let n=Math.max(q,Math.round(e)),r=n===Y?[{unit:`hour`,ms:J}]:n>=X&&n%X===0?[{unit:`week`,ms:X}]:n>=Y?[{unit:`day`,ms:Y},{unit:`hour`,ms:J},{unit:`minute`,ms:Ae},{unit:`second`,ms:q}]:n>=J?[{unit:`hour`,ms:J},{unit:`minute`,ms:Ae},{unit:`second`,ms:q}]:n>=Ae?[{unit:`minute`,ms:Ae},{unit:`second`,ms:q}]:[{unit:`second`,ms:q}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Le(r,e,t)),i%=n)}return Re(a,t)}function He(e,t){let n=Ve(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ue(e,t){return Ne[t].format(new Date(e))}function We(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ge(e,t,n=Date.now()){let r=new Date(e),i=Math.round((We(r)-We(new Date(n)))/Y),a=Pe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:Ue(e,t)}function Ke(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function qe(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return Ke(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ge(Date.parse(i.at),r)):i.kind===`interval`?He(i.everyMs,r):Oe(i.expr,Ie(r),n.scheduleBadge,{timezone:i.tz})}function Je(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ge(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Ye(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ge(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Xe={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Ze=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Qe(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:ze(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=U(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u=l===`auto_apply`?e.afterRunMode:`none`,d;return d=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:d,safety:{mode:l},afterRun:u===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:u},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function $e(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Xe.time,weekday:Xe.weekday,cronExpr:e}}function et(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function tt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function nt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function rt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function it(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function at(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=nt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=$e(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...et(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:tt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?rt(r.input):{},o=e.afterRun??{kind:`none`},s=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Xe,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?ge(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(s),afterRunMode:o.kind,webhookUrl:o.kind===`webhook`?o.url:``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function ot(e,t,n){let r=Qe(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function st(e,t,n){return e?Ue(e,n):t.never}function ct(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function lt(e){return e.safety?.mode??`auto_apply`}function ut(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function dt(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function ft(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function pt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function mt(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?pt(n):!1}function ht(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||ct(e.action,t)}function gt(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function _t(e){return!!gt(e)}function vt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function yt(e){return ft(e)?0:pt(e)?1:e.status===`succeeded`?2:3}function bt(e){return[...e].sort((e,t)=>{let n=yt(e)-yt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function xt(){let e=(0,G.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(C,{className:`h-4 w-36`}),(0,Z.jsx)(C,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(C,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(St)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(C,{className:`h-4 w-32`}),i=(0,Z.jsx)(C,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Z.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Z.jsx)(C,{className:`h-12 rounded-lg`}),(0,Z.jsx)(C,{className:`h-12 rounded-lg`}),(0,Z.jsx)(C,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function St(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(C,{className:`size-4 rounded-full`}),(0,Z.jsx)(C,{className:`h-4 w-32`}),(0,Z.jsx)(C,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(C,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(C,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(C,{className:`h-8 w-24 rounded-md`})]})},t)}function Ct(){let e=c(e=>e.language),t=s(e),n=t.automations,r=t.cron,a=m(e=>e.setPageHeader),u=m(e=>e.clearPageHeader),[h,g]=i(),_=h.get(`run`)?.trim()??``,v=h.get(`view`)===`runs`,y=h.get(`automation`)?.trim()??``,x=h.get(`draft`)?.trim()??``,C=h.get(`action`)?.trim()??``,w=h.get(`projectId`)?.trim()??``,T=h.get(`autogenerate`)===`1`,ee=(0,W.useRef)(``),[E,te]=(0,W.useState)(`all`),[k,A]=(0,W.useState)(``),[ne,M]=(0,W.useState)(!1),[ae,F]=(0,W.useState)(`blank`),[se,ce]=(0,W.useState)(null),[le,I]=(0,W.useState)(!1),[R,z]=(0,W.useState)(Xe),[fe,B]=(0,W.useState)(null),[V,pe]=(0,W.useState)(null),[H,me]=(0,W.useState)(!1),[ge,U]=(0,W.useState)(null),[_e,be]=(0,W.useState)(``),[xe,G]=(0,W.useState)(null),[Se,Ce]=(0,W.useState)(!1),[we,K]=(0,W.useState)(!1),[Te,Ee]=(0,W.useState)(null),[De,Oe]=(0,W.useState)(!1),[ke,q]=(0,W.useState)(!1),[Ae,J]=(0,W.useState)(!1),[Y,X]=(0,W.useState)(null),je=l([`automations`,w],()=>N.list(w?{projectId:w}:void 0),{refreshInterval:15e3}),Me=l([`automation-runs`,w],()=>N.runs(50,void 0,w?{projectId:w}:void 0),{refreshInterval:1e4}),Ne=l(V?`automation-run-events:${V}`:null,()=>N.runEvents(V),{refreshInterval:5e3}),Pe=l(`automation-workflow-definitions`,D),Fe=l(`automation-browser-workflows`,()=>ve.list()),Ie=l(`automation-chat-agents`,ue),Le=je.isLoading&&!je.data||Me.isLoading&&!Me.data,Re=je.data?.automations??[],ze=(0,W.useMemo)(()=>bt(Me.data?.runs??[]),[Me.data?.runs]),Be=(0,W.useMemo)(()=>Re.filter(e=>!_t(e)),[Re]),Ve=(0,W.useMemo)(()=>Re.filter(_t),[Re]),He=(0,W.useMemo)(()=>new Set(Ve.map(e=>e.id)),[Ve]),Ue=(0,W.useMemo)(()=>ze.filter(e=>!He.has(e.automationId)),[ze,He]),We=(0,W.useMemo)(()=>ze.find(e=>e.id===V)??null,[ze,V]),Ge=(0,W.useMemo)(()=>Re.find(e=>e.id===ge)??null,[Re,ge]),Ke=(0,W.useMemo)(()=>Re.find(e=>e.id===se)??null,[Re,se]),Je=(0,W.useMemo)(()=>ze.filter(e=>e.automationId===ge).sort((e,t)=>t.createdAtMs-e.createdAtMs),[ze,ge]),Ye=Ne.data?.events??[],Ze=(0,W.useMemo)(()=>Be.filter(e=>mt(e,Ue)).length,[Be,Ue]),$e=k.trim().toLocaleLowerCase(),et=(0,W.useMemo)(()=>(E===`system`?Ve:Be).filter(t=>E===`active`&&!t.enabled||E===`paused`&&t.enabled||E===`attention`&&!mt(t,Ue)?!1:$e?[t.name,vt(t),ht(t,n),qe(t.trigger,n,r,e)].some(e=>e.toLocaleLowerCase().includes($e)):!0),[r,E,n,e,$e,Ve,Be,Ue]),tt=(0,W.useMemo)(()=>Pe.data??[],[Pe.data]),nt=(0,W.useMemo)(()=>(Fe.data?.workflows??[]).filter(e=>e.enabled),[Fe.data]),rt=Ie.data?.items??[],st=(0,W.useMemo)(()=>tt.find(e=>e.id===R.workflowId.trim())??null,[R.workflowId,tt]),ct=(0,W.useMemo)(()=>nt.find(e=>e.id===R.browserWorkflowId.trim())??null,[nt,R.browserWorkflowId]),lt=R.actionMode===`workflow`&&(!R.workflowId.trim()||tt.length>0&&!tt.some(e=>e.id===R.workflowId)),ut=R.actionMode===`workflow`&&st?!he(st,R.workflowInput,R.workflowInputValid).valid:!1,dt=!!R.name.trim()&&(R.triggerMode!==`once`||Number.isFinite(new Date(R.onceAt).getTime()))&&(R.triggerMode!==`event`||!!R.eventType.trim()&&it(R.eventPayloadMatch))&&(R.actionMode===`workflow`?!lt&&!ut:R.actionMode===`browser_recipe`?ct!==null&&ye(ct,R.browserWorkflowInputs):!!R.instruction.trim())&&(R.afterRunMode!==`webhook`||!!R.webhookUrl.trim()),ft=(0,W.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...Xe,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...Xe,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:tt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...Xe,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedTask.name,description:n.templates.blockedTask.description,form:{...Xe,name:n.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:n.templates.blockedTask.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...Xe,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,tt]);(0,W.useEffect)(()=>{if(et.length===0){U(null);return}ge&&et.some(e=>e.id===ge)||U(et[0].id)},[et,ge]);let pt=(0,W.useCallback)(async()=>{await Promise.all([je.mutate(),Me.mutate(),Ne.mutate()])},[je.mutate,Ne.mutate,Me.mutate]),gt=(0,W.useCallback)(e=>{if(ce(null),I(!1),F(e),M(!0),e===`blank`){z(Xe);return}be(``),G(null),K(!1)},[]),yt=(0,W.useCallback)(e=>{z(at(e,tt)),ce(e.id),I(!1),U(null),F(`blank`),M(!0)},[tt]),St=(0,W.useCallback)(()=>{xe&&(z(at(xe.automation,tt)),ce(null),I(!0),F(`blank`))},[xe,tt]),Ct=(0,W.useCallback)(async()=>{J(!0),B(null);try{await pt()}catch(e){B(e instanceof Error?e.message:String(e))}finally{J(!1)}},[n.feedback.actionFailed,pt]);(0,W.useEffect)(()=>{_&&(pe(_),me(!0))},[_]),(0,W.useEffect)(()=>{if(!y)return;let e=Re.find(e=>e.id===y);e&&(te(_t(e)?`system`:`all`),U(e.id),g(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[y,Re,g]),(0,W.useEffect)(()=>{C===`create`&&(gt(`blank`),g(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[C,gt,g]),(0,W.useEffect)(()=>{if(!x)return;let t=`${e}:${T?`auto`:`seed`}:${x}`;ee.current!==t&&(ee.current=t,be(x),G(null),K(!1),F(`draft`),M(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),T&&(B(null),Ce(!0),N.draft({prompt:x,language:e}).then(e=>{G(e.draft),K(!1)}).catch(e=>{B(e instanceof Error?e.message:String(e))}).finally(()=>{Ce(!1)})))},[T,x,e,g]);let Tt=(0,W.useCallback)(e=>{pe(e),me(!0),g(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[g]);(0,W.useEffect)(()=>{Ee(null),q(!1)},[V]);async function Et(){if(B(null),dt){if(le&&xe){X(`draft:edit`);try{let e=Qe(R,st),{simulation:t}=await N.simulate(e);G({...xe,automation:e,simulation:t}),K(!1),I(!1),F(`draft`)}catch(e){B(e instanceof Error?e.message:String(e))}finally{X(null)}return}if(Ke){let e=Ke.id;await Ot(`automation:${e}:edit`,()=>N.update(e,ot(Ke,R,st)))&&(M(!1),ce(null),U(e));return}try{let{automation:e}=await N.create({...Qe(R,st),...w?{projectId:w}:{}});z(Xe),M(!1),te(`all`),A(``),await pt(),U(e.id)}catch(e){B(e instanceof Error?e.message:String(e))}}}async function Ot(e,t){B(null),X(e);try{return await t(),await pt(),!0}catch(e){return B(e instanceof Error?e.message:String(e)),!1}finally{X(null)}}async function At(){let t=_e.trim();if(t){B(null),Ce(!0);try{G((await N.draft({prompt:t,language:e})).draft),K(!1)}catch(e){B(e instanceof Error?e.message:String(e))}finally{Ce(!1)}}}async function jt(){if(!xe)return;let e=``;await Ot(`draft:publish`,async()=>{let{automation:t}=await N.create({...xe.automation,...w?{projectId:w}:{}});G(null),be(``),K(!1),M(!1),te(`all`),A(``),e=t.id})&&e&&U(e)}async function Mt(t){B(null),Oe(!0),Ee(null),q(!1);try{Ee((await N.repairDraft(t.id,{language:e})).repair)}catch(e){B(e instanceof Error?e.message:String(e))}finally{Oe(!1)}}async function Ft(e){Te&&await Ot(`run:${e.id}:repair`,async()=>{await N.update(e.automationId,Te.patch),Ee(null),q(!1)})}let It=(0,W.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(re,{className:`size-9 shrink-0 p-0`,loading:Ae,label:n.refresh,onClick:Ct}),(0,Z.jsxs)(j,{variant:`secondary`,onClick:()=>g(e=>{let t=new URLSearchParams(e);return v?t.delete(`view`):t.set(`view`,`runs`),t}),children:[(0,Z.jsx)(de,{className:`size-4`}),v?n.dashboard.backToAutomations:n.dashboard.allRuns]}),(0,Z.jsxs)(j,{variant:`primary`,onClick:()=>gt(`draft`),children:[(0,Z.jsx)(oe,{className:`size-4`}),n.new]})]}),[n.dashboard.allRuns,n.dashboard.backToAutomations,n.new,n.refresh,gt,Ae,Ct,v,g]);return(0,W.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:It}),()=>u()),[u,It,n.subtitle,n.title,a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[fe?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:fe}):null,Le?(0,Z.jsx)(xt,{}):v?(0,Z.jsx)(kt,{runs:ze,labels:n,cronLabels:r,language:e,busyAction:Y,onSelectRun:Tt,onAction:Ot}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,children:[(0,Z.jsx)(P,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:k,onChange:e=>A(e.target.value),placeholder:n.filters.search})]}),(0,Z.jsx)(`nav`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":n.filters.status,children:[{id:`all`,label:n.filters.all},{id:`active`,label:n.filters.active},{id:`paused`,label:n.paused},{id:`attention`,label:n.dashboard.needsAttention,count:Ze},{id:`system`,label:n.system.title,count:Ve.length}].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,E===e.id&&`bg-surface-hover text-fg`),onClick:()=>te(e.id),children:[e.label,e.count?` ${e.count}`:``]},e.id))})]}),(0,Z.jsx)(Dt,{automations:et,runs:E===`system`?ze:Ue,labels:n,cronLabels:r,language:e,selectedAutomationId:ge,onOpenDetails:U})]}),Ge?(0,Z.jsx)(Pt,{automation:Ge,runs:Je,labels:n,cronLabels:r,language:e,busyAction:Y,onEdit:yt,onSelectRun:Tt,onAction:Ot}):(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(O,{className:`size-5`}),title:n.empty.filtered})]})]}),(0,Z.jsx)(p,{open:ne,onOpenChange:e=>{M(e),e||(ce(null),I(!1))},children:(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(S,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(b,{className:`text-base font-semibold text-fg`,children:ae===`draft`?n.draft.title:Ke?n.editTitle:le?n.draft.editTitle:n.createTitle}),(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsx)(j,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(L,{className:`size-4`})})})]}),ae===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(wt,{labels:n,prompt:_e,draft:xe,loading:Se,approved:we,publishBusy:Y===`draft:publish`,templates:ft,onPromptChange:be,onGenerate:At,onEdit:St,onPublish:jt,onApprovedChange:K,onDiscard:()=>{G(null),K(!1)},onTemplateSelect:e=>{z(e),F(`blank`)},onOpenAdvanced:()=>{z(Xe),F(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ut,{form:R,labels:n,setForm:z,workflowDefinitions:tt,selectedWorkflow:st,workflowsLoading:Pe.isLoading,browserWorkflows:nt,selectedBrowserWorkflow:ct,browserWorkflowsLoading:Fe.isLoading,agentOptions:rt,agentsLoading:Ie.isLoading,language:e}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[le?(0,Z.jsx)(j,{variant:`ghost`,onClick:()=>{I(!1),F(`draft`)},children:n.cancel}):(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsx)(j,{variant:`ghost`,children:n.cancel})}),(0,Z.jsx)(j,{variant:`primary`,onClick:Et,disabled:!dt||Y===`draft:edit`||!!(Ke&&Y),children:Y===`draft:edit`||Ke&&Y===`automation:${Ke.id}:edit`?n.feedback.working:Ke||le?n.save:n.create})]})]})]})]})}),(0,Z.jsx)(p,{open:H&&!!We,onOpenChange:e=>{me(e),!e&&g(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(S,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(b,{className:`truncate text-base font-semibold text-fg`,children:We?.automationName??n.dashboard.result}),(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsx)(j,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(L,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Nt,{className:`rounded-none border-0`,run:We,events:Ye,labels:n,cronLabels:r,language:e,loading:Ne.isLoading,repairDraft:Te,repairLoading:De,repairApproved:ke,busyAction:Y,onRepairApprovedChange:q,onSuggestRepair:Mt,onApplyRepair:Ft})})]})]})})]})}function wt(e){let t=(0,G.c)(58),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,templates:c,onPromptChange:l,onGenerate:u,onEdit:d,onPublish:f,onApprovedChange:p,onDiscard:m,onTemplateSelect:h,onOpenAdvanced:g}=e,v=s===void 0?!1:s,y=!!(i&&i.simulation.requiredConfirmations.length>0),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(_,{className:`size-4 text-accent`}),t[0]=b):b=t[0];let x;t[1]===n.draft.title?x=t[2]:(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[b,n.draft.title]}),t[1]=n.draft.title,t[2]=x);let S;t[3]===n.draft.subtitle?S=t[4]:(S=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=S);let C;t[5]!==x||t[6]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[5]=x,t[6]=S,t[7]=C):C=t[7];let w;t[8]!==a||t[9]!==r?(w=a||!r.trim(),t[8]=a,t[9]=r,t[10]=w):w=t[10];let T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(_,{className:`size-4`}),t[11]=T):T=t[11];let ee=a?n.draft.generating:n.draft.generate,E;t[12]!==u||t[13]!==w||t[14]!==ee?(E=(0,Z.jsxs)(j,{variant:`primary`,onClick:u,disabled:w,children:[T,ee]}),t[12]=u,t[13]=w,t[14]=ee,t[15]=E):E=t[15];let D;t[16]!==C||t[17]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[C,E]}),t[16]=C,t[17]=E,t[18]=D):D=t[18];let te;t[19]===l?te=t[20]:(te=e=>l(e.target.value),t[19]=l,t[20]=te);let O;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==te?(O=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:te,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=te,t[24]=O):O=t[24];let k;t[25]!==i||t[26]!==n.draft.advancedCreate||t[27]!==n.draft.suggestions||t[28]!==n.draft.suggestionsDescription||t[29]!==g||t[30]!==h||t[31]!==c?(k=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(j,{variant:`ghost`,onClick:g,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:c.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>h(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[25]=i,t[26]=n.draft.advancedCreate,t[27]=n.draft.suggestions,t[28]=n.draft.suggestionsDescription,t[29]=g,t[30]=h,t[31]=c,t[32]=k):k=t[32];let A;t[33]!==o||t[34]!==i||t[35]!==n.draft.approval||t[36]!==n.draft.assumptions||t[37]!==n.draft.discard||t[38]!==n.draft.edit||t[39]!==n.draft.publish||t[40]!==n.draft.review||t[41]!==n.draft.risks||t[42]!==n.draft.safety||t[43]!==n.feedback||t[44]!==n.info||t[45]!==n.none||t[46]!==p||t[47]!==m||t[48]!==d||t[49]!==f||t[50]!==v||t[51]!==y?(A=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(Vt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Vt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(Tt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Tt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Tt,{title:n.draft.risks,items:i.risks,empty:n.none}),y?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>p(e.target.checked)}),(0,Z.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(j,{variant:`ghost`,onClick:m,children:n.draft.discard}),(0,Z.jsxs)(j,{variant:`secondary`,onClick:d,children:[(0,Z.jsx)(z,{className:`size-4`}),n.draft.edit]}),(0,Z.jsx)(j,{variant:`primary`,onClick:f,disabled:v||y&&!o,children:v?n.feedback.working:n.draft.publish})]})]})]}):null,t[33]=o,t[34]=i,t[35]=n.draft.approval,t[36]=n.draft.assumptions,t[37]=n.draft.discard,t[38]=n.draft.edit,t[39]=n.draft.publish,t[40]=n.draft.review,t[41]=n.draft.risks,t[42]=n.draft.safety,t[43]=n.feedback,t[44]=n.info,t[45]=n.none,t[46]=p,t[47]=m,t[48]=d,t[49]=f,t[50]=v,t[51]=y,t[52]=A):A=t[52];let ne;return t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==A?(ne=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[D,O,k,A]}),t[53]=D,t[54]=O,t[55]=k,t[56]=A,t[57]=ne):ne=t[57],ne}function Tt(e){let t=(0,G.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(Et):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Et(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function Dt(e){let t=(0,G.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:s,selectedAutomationId:c,onOpenDetails:l}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(O,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ht,{icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let u;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s||t[7]!==l||t[8]!==r||t[9]!==c){let e;t[11]!==a||t[12]!==i||t[13]!==s||t[14]!==l||t[15]!==r||t[16]!==c?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(Ot),n=t.find(ft),u=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:o(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,c===e.id&&`bg-surface-hover`),onClick:()=>l(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:o(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:mt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:qe(e.trigger,i,a,s)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.enabled?`${i.next}: ${st(e.state.nextRunAtMs,i,s)}`:i.paused}),u?.status?(0,Z.jsx)(`span`,{className:o(`shrink-0 rounded-full px-1.5 py-0.5`,ut(u.status)),children:i.status[u.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=s,t[14]=l,t[15]=r,t[16]=c,t[17]=e):e=t[17],u=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=l,t[8]=r,t[9]=c,t[10]=u}else u=t[10];let d;return t[18]===u?d=t[19]:(d=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:u}),t[18]=u,t[19]=d),d}function Ot(e,t){return t.createdAtMs-e.createdAtMs}function kt(e){let t=(0,G.c)(23),{runs:n,labels:r,cronLabels:i,language:a,busyAction:s,onSelectRun:c,onAction:l}=e,u;t[0]===r.dashboard.allRuns?u=t[1]:(u=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.dashboard.allRuns}),t[0]=r.dashboard.allRuns,t[1]=u);let d;t[2]===r.dashboard.runCenterDescription?d=t[3]:(d=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.dashboard.runCenterDescription}),t[2]=r.dashboard.runCenterDescription,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,Z.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p;t[7]===n.length?p=t[8]:(p=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:n.length}),t[7]=n.length,t[8]=p);let m;t[9]!==f||t[10]!==p?(m=(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[f,p]}),t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==s||t[13]!==i||t[14]!==r||t[15]!==a||t[16]!==l||t[17]!==c||t[18]!==n?(h=n.length===0?(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(de,{className:`size-5`}),title:r.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-3 hover:bg-surface-hover`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left outline-none`,onClick:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,Z.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,ut(e.status)),children:r.status[e.status]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:st(e.createdAtMs,r,a)})]}),(0,Z.jsx)(`p`,{className:o(`mt-1 line-clamp-2 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(ft(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.manual?r.trigger.manual:qe(e.triggerSnapshot,r,i,a)})]}),ft(e)?(0,Z.jsx)(j,{variant:`ghost`,disabled:s!==null,onClick:()=>void l(`run:${e.id}:cancel`,()=>N.cancelRun(e.id),r.dashboard.cancelled),children:s===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id))}),t[12]=s,t[13]=i,t[14]=r,t[15]=a,t[16]=l,t[17]=c,t[18]=n,t[19]=h):h=t[19];let g;return t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[m,h]}),t[20]=m,t[21]=h,t[22]=g):g=t[22],g}function At(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`after_run.started`:return n.afterRunStarted;case`after_run.completed`:return n.afterRunCompleted;case`after_run.failed`:return n.afterRunFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function jt(e){let t=(0,G.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[s,c]=(0,W.useState)(a===void 0?!1:a),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
2
- `),t[2]=u,t[3]=d);let f=d.length,p=u.length>720||f>18,m;t[4]!==p||t[5]!==u?(m=p?`${u.split(`
3
- `).slice(0,10).join(`
4
- `).trimEnd()}...`:u,t[4]=p,t[5]=u,t[6]=m):m=t[6];let h=m,g;t[7]!==s||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(Mt),"aria-expanded":s,children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[s?r.details.hideDetails:r.details.showDetails,(0,Z.jsx)(ne,{className:o(`size-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Z.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=s,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=s||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let y;return t[14]!==g||t[15]!==v?(y=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=y):y=t[16],y}function Mt(e){return!e}function Nt(e){let t=(0,G.c)(148),{className:n,run:r,events:i,labels:s,cronLabels:c,language:l,loading:d,repairDraft:f,repairLoading:p,repairApproved:m,busyAction:g,onRepairApprovedChange:v,onSuggestRepair:y,onApplyRepair:b}=e;if(!r){let e;t[0]===n?e=t[1]:(e=o(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(de,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===s.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:s.selectRun}),t[3]=s.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Z.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let x=r.error||r.summary,S=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,w=r.sessionKey?s.runDetail.openConversation:s.runDetail.openWorkflow,T=r.sessionKey?h:se,ee=ft(r)?de:pt(r)?I:u,E;t[8]===n?E=t[9]:(E=o(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=E);let D;t[10]===r.automationName?D=t[11]:(D=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=D);let O;t[12]===r.id?O=t[13]:(O=r.id.slice(0,8),t[12]=r.id,t[13]=O);let k;t[14]===O?k=t[15]:(k=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:O}),t[14]=O,t[15]=k);let A;t[16]!==D||t[17]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,k]}),t[16]=D,t[17]=k,t[18]=A):A=t[18];let re;t[19]===r.status?re=t[20]:(re=o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ut(r.status)),t[19]=r.status,t[20]=re);let ie=s.status[r.status],M;t[21]!==re||t[22]!==ie?(M=(0,Z.jsx)(`span`,{className:re,children:ie}),t[21]=re,t[22]=ie,t[23]=M):M=t[23];let N;t[24]!==A||t[25]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,M]}),t[24]=A,t[25]=M,t[26]=N):N=t[26];let P;t[27]!==s||t[28]!==l||t[29]!==r.createdAtMs?(P=st(r.createdAtMs,s,l),t[27]=s,t[28]=l,t[29]=r.createdAtMs,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,Z.jsx)(`span`,{children:P}),t[31]=P,t[32]=F);let oe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=oe):oe=t[33];let ce=s.details.duration,le;t[34]!==s||t[35]!==r.durationMs?(le=dt(r.durationMs,s),t[34]=s,t[35]=r.durationMs,t[36]=le):le=t[36];let L;t[37]!==s.details.duration||t[38]!==le?(L=(0,Z.jsxs)(`span`,{children:[ce,` `,le]}),t[37]=s.details.duration,t[38]=le,t[39]=L):L=t[39];let ue;t[40]!==F||t[41]!==L?(ue=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[F,oe,L]}),t[40]=F,t[41]=L,t[42]=ue):ue=t[42];let R;t[43]!==s.repair||t[44]!==y||t[45]!==p||t[46]!==r?(R=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(j,{variant:`secondary`,onClick:()=>y(r),disabled:p,children:[(0,Z.jsx)(_,{className:`size-4`}),p?s.repair.generating:s.repair.suggest]})}):null,t[43]=s.repair,t[44]=y,t[45]=p,t[46]=r,t[47]=R):R=t[47];let z;t[48]!==ue||t[49]!==R||t[50]!==N?(z=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[N,ue,R]}),t[48]=ue,t[49]=R,t[50]=N,t[51]=z):z=t[51];let B;t[52]===r?B=t[53]:(B=ft(r)?`text-blue-500`:pt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=B);let V;t[54]===B?V=t[55]:(V=o(`size-4`,B),t[54]=B,t[55]=V);let pe;t[56]!==ee||t[57]!==V?(pe=(0,Z.jsx)(ee,{className:V}),t[56]=ee,t[57]=V,t[58]=pe):pe=t[58];let H;t[59]!==s.runDetail.resultTitle||t[60]!==pe?(H=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[pe,s.runDetail.resultTitle]}),t[59]=s.runDetail.resultTitle,t[60]=pe,t[61]=H):H=t[61];let me;t[62]!==T||t[63]!==w||t[64]!==S?(me=S?(0,Z.jsx)(j,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:S,children:[(0,Z.jsx)(T,{className:`size-3.5`}),w,(0,Z.jsx)(ae,{className:`size-3.5`})]})}):null,t[62]=T,t[63]=w,t[64]=S,t[65]=me):me=t[65];let he;t[66]!==H||t[67]!==me?(he=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[H,me]}),t[66]=H,t[67]=me,t[68]=he):he=t[68];let ge=r.error&&`border-red-500/25 bg-red-500/5`,U;t[69]===ge?U=t[70]:(U=o(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,ge),t[69]=ge,t[70]=U);let _e;t[71]!==s.runDetail.noResult||t[72]!==s.runDetail.resultPending||t[73]!==x||t[74]!==r?(_e=x?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:x}):(0,Z.jsx)(te,{content:x,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:ft(r)?s.runDetail.resultPending:s.runDetail.noResult}),t[71]=s.runDetail.noResult,t[72]=s.runDetail.resultPending,t[73]=x,t[74]=r,t[75]=_e):_e=t[75];let ve;t[76]!==U||t[77]!==_e?(ve=(0,Z.jsx)(`div`,{className:U,children:_e}),t[76]=U,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==he||t[80]!==ve?(ye=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[he,ve]}),t[79]=he,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]===s.runDetail.runInfo?be=t[83]:(be=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:s.runDetail.runInfo}),t[82]=s.runDetail.runInfo,t[83]=be);let xe;t[84]!==c||t[85]!==s||t[86]!==l||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(xe=r.manual?s.trigger.manual:qe(r.triggerSnapshot,s,c,l),t[84]=c,t[85]=s,t[86]=l,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=xe):xe=t[89];let W;t[90]!==s.explain.whyRan||t[91]!==xe?(W=(0,Z.jsx)(zt,{label:s.explain.whyRan,value:xe}),t[90]=s.explain.whyRan,t[91]=xe,t[92]=W):W=t[92];let Se=s.details.started,Ce;t[93]!==s||t[94]!==l||t[95]!==r.startedAtMs?(Ce=st(r.startedAtMs,s,l),t[93]=s,t[94]=l,t[95]=r.startedAtMs,t[96]=Ce):Ce=t[96];let we;t[97]!==s.details.started||t[98]!==Ce?(we=(0,Z.jsx)(zt,{label:Se,value:Ce}),t[97]=s.details.started,t[98]=Ce,t[99]=we):we=t[99];let K;t[100]!==s.details.model||t[101]!==r.model?(K=r.model?(0,Z.jsx)(zt,{label:s.details.model,value:r.model}):null,t[100]=s.details.model,t[101]=r.model,t[102]=K):K=t[102];let Te;t[103]!==W||t[104]!==we||t[105]!==K?(Te=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[W,we,K]}),t[103]=W,t[104]=we,t[105]=K,t[106]=Te):Te=t[106];let Ee;t[107]!==be||t[108]!==Te?(Ee=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[be,Te]}),t[107]=be,t[108]=Te,t[109]=Ee):Ee=t[109];let De;t[110]!==g||t[111]!==s||t[112]!==b||t[113]!==v||t[114]!==m||t[115]!==f||t[116]!==r?(De=f?(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:s.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:f.explanation}),f.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:f.expectedEffect}):null,(0,Z.jsx)(Tt,{title:s.repair.risks,items:f.risks,empty:s.none}),(0,Z.jsx)(jt,{value:f.patch,labels:s,title:s.details.repairPatch}),f.requiresApproval?(0,Z.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:m,onChange:e=>v(e.target.checked)}),(0,Z.jsx)(`span`,{children:s.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(j,{variant:`primary`,onClick:()=>b(r),disabled:g===`run:${r.id}:repair`||f.requiresApproval&&!m,children:g===`run:${r.id}:repair`?s.feedback.working:s.repair.apply})})]}):null,t[110]=g,t[111]=s,t[112]=b,t[113]=v,t[114]=m,t[115]=f,t[116]=r,t[117]=De):De=t[117];let Oe;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(fe,{className:`size-4 shrink-0`}),t[118]=Oe):Oe=t[118];let ke;t[119]===s.runDetail.technicalEvents?ke=t[120]:(ke=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[Oe,s.runDetail.technicalEvents]}),t[119]=s.runDetail.technicalEvents,t[120]=ke);let q;t[121]!==i.length||t[122]!==s.runDetail.eventCount?(q=s.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=s.runDetail.eventCount,t[123]=q):q=t[123];let Ae;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Z.jsx)(ne,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=Ae):Ae=t[124];let J;t[125]===q?J=t[126]:(J=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[q,Ae]}),t[125]=q,t[126]=J);let Y;t[127]!==ke||t[128]!==J?(Y=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[ke,J]}),t[127]=ke,t[128]=J,t[129]=Y):Y=t[129];let X;t[130]===s.runDetail.technicalEventsDescription?X=t[131]:(X=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:s.runDetail.technicalEventsDescription}),t[130]=s.runDetail.technicalEventsDescription,t[131]=X);let je;t[132]!==i||t[133]!==s||t[134]!==l||t[135]!==d?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:d?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":s.loading,children:[(0,Z.jsx)(C,{className:`h-10 w-full`}),(0,Z.jsx)(C,{className:`h-10 w-4/5`}),(0,Z.jsx)(C,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:s.empty.events}):(0,Z.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Z.jsx)(`span`,{className:o(`mt-1 size-2 rounded-full`,Bt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:At(e,s)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[st(e.createdAtMs,s,l),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Z.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[s.details.eventData,(0,Z.jsx)(ne,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=s,t[134]=l,t[135]=d,t[136]=je):je=t[136];let Me;t[137]!==Y||t[138]!==X||t[139]!==je?(Me=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[Y,X,je]}),t[137]=Y,t[138]=X,t[139]=je,t[140]=Me):Me=t[140];let Ne;return t[141]!==E||t[142]!==z||t[143]!==ye||t[144]!==Ee||t[145]!==De||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:E,children:[z,ye,Ee,De,Me]}),t[141]=E,t[142]=z,t[143]=ye,t[144]=Ee,t[145]=De,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Pt(e){let t=(0,G.c)(82),{automation:n,runs:r,labels:i,cronLabels:a,language:s,busyAction:c,onEdit:l,onSelectRun:d,onAction:f}=e,p=c===`automation:${n.id}:run`,m=c===`automation:${n.id}:toggle`,h=c===`automation:${n.id}:delete`,_;t[0]===n?_=t[1]:(_=_t(n),t[0]=n,t[1]=_);let v=_,b;t[2]===n.name?b=t[3]:(b=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=b);let S=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,C;t[4]===S?C=t[5]:(C=o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,S),t[4]=S,t[5]=C);let w=n.enabled?i.enabled:i.paused,ee;t[6]!==C||t[7]!==w?(ee=(0,Z.jsx)(`span`,{className:C,children:w}),t[6]=C,t[7]=w,t[8]=ee):ee=t[8];let D;t[9]!==b||t[10]!==ee?(D=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b,ee]}),t[9]=b,t[10]=ee,t[11]=D):D=t[11];let O;t[12]===n?O=t[13]:(O=vt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:vt(n)}):null,t[12]=n,t[13]=O);let k;t[14]!==D||t[15]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[14]=D,t[15]=O,t[16]=k):k=t[16];let ne;t[17]!==n||t[18]!==c||t[19]!==h||t[20]!==i.dashboard.delete||t[21]!==i.dashboard.deleted||t[22]!==i.dashboard.pause||t[23]!==i.dashboard.resume||t[24]!==i.dashboard.resumed||t[25]!==i.dashboard.runNow||t[26]!==i.details||t[27]!==i.edit||t[28]!==i.feedback||t[29]!==f||t[30]!==l||t[31]!==v||t[32]!==p||t[33]!==m?(ne=v?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(j,{variant:`secondary`,disabled:c!==null,onClick:()=>void f(`automation:${n.id}:toggle`,()=>n.enabled?N.pause(n.id):N.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[m?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(R,{className:`size-4`}):(0,Z.jsx)(A,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(j,{variant:`primary`,disabled:c!==null,onClick:()=>void f(`automation:${n.id}:run`,()=>N.runNow(n.id),i.feedback.rerunQueued),children:[p?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):(0,Z.jsx)(A,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(ce,{children:[(0,Z.jsx)(E,{asChild:!0,children:(0,Z.jsx)(j,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(M,{className:`size-4`})})}),(0,Z.jsx)(y,{children:(0,Z.jsxs)(T,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(g,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>l(n),children:[(0,Z.jsx)(z,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(g,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:c!==null,onSelect:()=>void f(`automation:${n.id}:delete`,()=>N.remove(n.id),i.dashboard.deleted),children:[h?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):(0,Z.jsx)(x,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=c,t[19]=h,t[20]=i.dashboard.delete,t[21]=i.dashboard.deleted,t[22]=i.dashboard.pause,t[23]=i.dashboard.resume,t[24]=i.dashboard.resumed,t[25]=i.dashboard.runNow,t[26]=i.details,t[27]=i.edit,t[28]=i.feedback,t[29]=f,t[30]=l,t[31]=v,t[32]=p,t[33]=m,t[34]=ne):ne=t[34];let re;t[35]!==ne||t[36]!==k?(re=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[k,ne]}),t[35]=ne,t[36]=k,t[37]=re):re=t[37];let ie;t[38]===i.info.task?ie=t[39]:(ie=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=ie);let P;t[40]!==n||t[41]!==i?(P=ht(n,i),t[40]=n,t[41]=i,t[42]=P):P=t[42];let ae;t[43]===P?ae=t[44]:(ae=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(te,{content:P,compact:!0,openHttpLinksInNewTab:!0})}),t[43]=P,t[44]=ae);let oe;t[45]!==ie||t[46]!==ae?(oe=(0,Z.jsxs)(`section`,{children:[ie,ae]}),t[45]=ie,t[46]=ae,t[47]=oe):oe=t[47];let se;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==s?(se=(0,Z.jsx)(It,{automation:n,labels:i,cronLabels:a,language:s}),t[48]=n,t[49]=a,t[50]=i,t[51]=s,t[52]=se):se=t[52];let le;t[53]===i.dashboard.runHistory?le=t[54]:(le=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[53]=i.dashboard.runHistory,t[54]=le);let I;t[55]===i.dashboard.runHistoryDescription?I=t[56]:(I=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[55]=i.dashboard.runHistoryDescription,t[56]=I);let L;t[57]!==le||t[58]!==I?(L=(0,Z.jsxs)(`div`,{children:[le,I]}),t[57]=le,t[58]=I,t[59]=L):L=t[59];let ue;t[60]===r.length?ue=t[61]:(ue=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[60]=r.length,t[61]=ue);let fe;t[62]!==L||t[63]!==ue?(fe=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[L,ue]}),t[62]=L,t[63]=ue,t[64]=fe):fe=t[64];let B;t[65]!==i||t[66]!==s||t[67]!==d||t[68]!==r?(B=r.length===0?(0,Z.jsx)(Ht,{icon:(0,Z.jsx)(de,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>d(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(u,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(de,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:st(e.createdAtMs,i,s)})]}),(0,Z.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ut(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:o(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||ct(e.actionSnapshot,i)})]},e.id))}),t[65]=i,t[66]=s,t[67]=d,t[68]=r,t[69]=B):B=t[69];let V;t[70]!==fe||t[71]!==B?(V=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[fe,B]}),t[70]=fe,t[71]=B,t[72]=V):V=t[72];let pe;t[73]!==se||t[74]!==V?(pe=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[se,V]}),t[73]=se,t[74]=V,t[75]=pe):pe=t[75];let H;t[76]!==oe||t[77]!==pe?(H=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[oe,pe]}),t[76]=oe,t[77]=pe,t[78]=H):H=t[78];let me;return t[79]!==re||t[80]!==H?(me=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[re,H]}),t[79]=re,t[80]=H,t[81]=me):me=t[81],me}function Ft(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function It(e){let t=(0,G.c)(127),{automation:n,labels:r,cronLabels:i,language:a}=e,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=lt(n),_;t[15]!==n||t[16]!==r||t[17]!==a?(_=Je(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=_):_=t[18];let v=_,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?Ue(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(g=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],g.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],g.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=Ue(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],g.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],g.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],g.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],g.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],g.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],g.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],g.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=g}else g=t[39];m=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?h=t[71]:(h=(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=h),d=`grid gap-4 p-4`;let x;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[72]=x):x=t[72];let S=r.info.schedule,C;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(C=qe(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=C):C=t[77];let w=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==C||t[81]!==w?(f=(0,Z.jsx)(Rt,{icon:x,label:S,value:C,description:w,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=C,t[81]=w,t[82]=f):f=t[82];let T;t[83]===n.action.kind?T=t[84]:(T=n.action.kind===`workflow`?(0,Z.jsx)(se,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(fe,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=T);let E=r.info.action,D;t[85]!==n.action||t[86]!==r?(D=ct(n.action,r),t[85]=n.action,t[86]=r,t[87]=D):D=t[87],t[88]!==r.info.action||t[89]!==T||t[90]!==D?(p=(0,Z.jsx)(Rt,{icon:T,label:E,value:D}),t[88]=r.info.action,t[89]=T,t[90]=D,t[91]=p):p=t[91],o=Rt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[92]=s):s=t[92],c=r.info.permission,l=r.safety[e],u=Ft(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[93]!==o||t[94]!==s||t[95]!==c||t[96]!==l||t[97]!==u?(_=(0,Z.jsx)(o,{icon:s,label:c,value:l,description:u}),t[93]=o,t[94]=s,t[95]=c,t[96]=l,t[97]=u,t[98]=_):_=t[98];let v;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[99]=v):v=t[99];let y=r.info.lastRun,b;t[100]!==n||t[101]!==r||t[102]!==a?(b=Ye(n,r,a),t[100]=n,t[101]=r,t[102]=a,t[103]=b):b=t[103];let x=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,S;t[104]!==r.info.lastRun||t[105]!==b||t[106]!==x?(S=(0,Z.jsx)(Rt,{icon:v,label:y,value:b,valueTone:x}),t[104]=r.info.lastRun,t[105]=b,t[106]=x,t[107]=S):S=t[107];let C;t[108]!==n.state.consecutiveFailures||t[109]!==n.state.lastError||t[110]!==r.dashboard?(C=n.state.consecutiveFailures?(0,Z.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Z.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Z.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[108]=n.state.consecutiveFailures,t[109]=n.state.lastError,t[110]=r.dashboard,t[111]=C):C=t[111];let w;t[112]!==r.info.technicalDetails||t[113]!==g?(w=g.length>0?(0,Z.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:r.info.technicalDetails}),(0,Z.jsx)(ne,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:g.map(Lt)})]}):null,t[112]=r.info.technicalDetails,t[113]=g,t[114]=w):w=t[114];let T;t[115]!==_||t[116]!==S||t[117]!==C||t[118]!==w||t[119]!==d||t[120]!==f||t[121]!==p?(T=(0,Z.jsxs)(`div`,{className:d,children:[f,p,_,S,C,w]}),t[115]=_,t[116]=S,t[117]=C,t[118]=w,t[119]=d,t[120]=f,t[121]=p,t[122]=T):T=t[122];let E;return t[123]!==T||t[124]!==m||t[125]!==h?(E=(0,Z.jsxs)(`aside`,{className:m,children:[h,T]}),t[123]=T,t[124]=m,t[125]=h,t[126]=E):E=t[126],E}function Lt(e){return(0,Z.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function Rt(e){let t=(0,G.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:s,valueTone:c}=e,l=c===void 0?`default`:c,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=d);let f=l===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===f?p=t[5]:(p=o(`mt-1 text-sm font-medium leading-5`,f),t[4]=f,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Z.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==s?(h=a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:s,children:a}):null,t[9]=a,t[10]=s,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[d,m,h]}),t[12]=d,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==u||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[u,g]}),t[16]=u,t[17]=g,t[18]=_):_=t[18],_}function zt(e){let t=(0,G.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Bt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Vt(e){let t=(0,G.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ht(e){let t=(0,G.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ut(e){let t=(0,G.c)(250),{form:n,labels:r,setForm:i,workflowDefinitions:a,selectedWorkflow:c,workflowsLoading:l,browserWorkflows:u,selectedBrowserWorkflow:d,browserWorkflowsLoading:f,agentOptions:p,agentsLoading:m,language:h}=e,g=s(h).agentsSettings,_;t[0]===i?_=t[1]:(_=e=>i(t=>({...t,...e})),t[0]=i,t[1]=_);let y=_,b=ze(n.intervalValue,n.intervalUnit),x=Date.now(),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=[1,2,3],t[2]=S):S=t[2];let C;t[3]!==b||t[4]!==x||t[5]!==h?(C=S.map(e=>Ge(x+b*e,h,x)),t[3]=b,t[4]=x,t[5]=h,t[6]=C):C=t[6];let T=C,ee,E;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==a?(ee=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=a[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},E=[n.actionMode,n.workflowId,i,a],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=a,t[11]=ee,t[12]=E):(ee=t[11],E=t[12]),(0,W.useEffect)(ee,E);let D,te;t[13]!==u||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(D=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=u[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:be(e)}))},te=[u,n.actionMode,n.browserWorkflowId,i],t[13]=u,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=D,t[18]=te):(D=t[17],te=t[18]),(0,W.useEffect)(D,te);let O;t[19]===y?O=t[20]:(O=e=>y({name:e.target.value}),t[19]=y,t[20]=O);let k;t[21]!==n.name||t[22]!==O?(k=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:O}),t[21]=n.name,t[22]=O,t[23]=k):k=t[23];let A;t[24]!==r.form.name||t[25]!==k?(A=(0,Z.jsx)($,{label:r.form.name,children:k}),t[24]=r.form.name,t[25]=k,t[26]=A):A=t[26];let j;t[27]===y?j=t[28]:(j=e=>y({description:e.target.value}),t[27]=y,t[28]=j);let re;t[29]!==n.description||t[30]!==j?(re=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:j}),t[29]=n.description,t[30]=j,t[31]=re):re=t[31];let ie;t[32]!==r.form.description||t[33]!==re?(ie=(0,Z.jsx)($,{label:r.form.description,children:re}),t[32]=r.form.description,t[33]=re,t[34]=ie):ie=t[34];let M;t[35]===r.form.trigger?M=t[36]:(M=(0,Z.jsx)(Kt,{title:r.form.trigger}),t[35]=r.form.trigger,t[36]=M);let N;t[37]===y?N=t[38]:(N=e=>y({triggerMode:e.target.value}),t[37]=y,t[38]=N);let P;t[39]===r.trigger.manual?P=t[40]:(P=(0,Z.jsx)(w,{value:`manual`,children:r.trigger.manual}),t[39]=r.trigger.manual,t[40]=P);let ae;t[41]===r.trigger.once?ae=t[42]:(ae=(0,Z.jsx)(w,{value:`once`,children:r.trigger.once}),t[41]=r.trigger.once,t[42]=ae);let F;t[43]===r.trigger.daily?F=t[44]:(F=(0,Z.jsx)(w,{value:`daily`,children:r.trigger.daily}),t[43]=r.trigger.daily,t[44]=F);let oe;t[45]===r.trigger.weekly?oe=t[46]:(oe=(0,Z.jsx)(w,{value:`weekly`,children:r.trigger.weekly}),t[45]=r.trigger.weekly,t[46]=oe);let se;t[47]===r.trigger.interval?se=t[48]:(se=(0,Z.jsx)(w,{value:`interval`,children:r.trigger.interval}),t[47]=r.trigger.interval,t[48]=se);let ce;t[49]===r.trigger.customCron?ce=t[50]:(ce=(0,Z.jsx)(w,{value:`cron`,children:r.trigger.customCron}),t[49]=r.trigger.customCron,t[50]=ce);let I;t[51]===r.trigger.webhook?I=t[52]:(I=(0,Z.jsx)(w,{value:`webhook`,children:r.trigger.webhook}),t[51]=r.trigger.webhook,t[52]=I);let L;t[53]===r.trigger.taskBlocked?L=t[54]:(L=(0,Z.jsx)(w,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[53]=r.trigger.taskBlocked,t[54]=L);let ue;t[55]===r.trigger.noteCreated?ue=t[56]:(ue=(0,Z.jsx)(w,{value:`noteCreated`,children:r.trigger.noteCreated}),t[55]=r.trigger.noteCreated,t[56]=ue);let de;t[57]===r.trigger.workflowFailed?de=t[58]:(de=(0,Z.jsx)(w,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[57]=r.trigger.workflowFailed,t[58]=de);let R;t[59]===r.trigger.sessionUpdated?R=t[60]:(R=(0,Z.jsx)(w,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[59]=r.trigger.sessionUpdated,t[60]=R);let z;t[61]===r.trigger.customEvent?z=t[62]:(z=(0,Z.jsx)(w,{value:`event`,children:r.trigger.customEvent}),t[61]=r.trigger.customEvent,t[62]=z);let fe;t[63]!==n.triggerMode||t[64]!==N||t[65]!==P||t[66]!==ae||t[67]!==F||t[68]!==oe||t[69]!==se||t[70]!==ce||t[71]!==I||t[72]!==L||t[73]!==ue||t[74]!==de||t[75]!==R||t[76]!==z?(fe=(0,Z.jsxs)(v,{className:Q,value:n.triggerMode,onChange:N,children:[P,ae,F,oe,se,ce,I,L,ue,de,R,z]}),t[63]=n.triggerMode,t[64]=N,t[65]=P,t[66]=ae,t[67]=F,t[68]=oe,t[69]=se,t[70]=ce,t[71]=I,t[72]=L,t[73]=ue,t[74]=de,t[75]=R,t[76]=z,t[77]=fe):fe=t[77];let B;t[78]!==n.onceAt||t[79]!==n.triggerMode||t[80]!==r.form.onceAt||t[81]!==y?(B=n.triggerMode===`once`?(0,Z.jsx)($,{label:r.form.onceAt,children:(0,Z.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>y({onceAt:e.target.value})})}):null,t[78]=n.onceAt,t[79]=n.triggerMode,t[80]=r.form.onceAt,t[81]=y,t[82]=B):B=t[82];let V;t[83]!==n.time||t[84]!==n.triggerMode||t[85]!==n.weekday||t[86]!==r.form.day||t[87]!==r.form.time||t[88]!==r.weekdays||t[89]!==y?(V=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.time,children:(0,Z.jsx)(pe,{value:n.time,onChange:e=>y({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(v,{className:Q,value:n.weekday,onChange:e=>y({weekday:e.target.value}),children:[(0,Z.jsx)(w,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(w,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(w,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(w,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(w,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(w,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(w,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[83]=n.time,t[84]=n.triggerMode,t[85]=n.weekday,t[86]=r.form.day,t[87]=r.form.time,t[88]=r.weekdays,t[89]=y,t[90]=V):V=t[90];let H=n.triggerMode===`interval`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsx)($,{label:r.form.intervalEvery,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Z.jsx)(`input`,{className:Q,type:`number`,min:6e4/ze(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>y({intervalValue:e.target.value})}),(0,Z.jsxs)(v,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;y({intervalValue:Be(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(w,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(w,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(w,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(w,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Ze.map(e=>{let t=ze(e.value,e.unit),n=t===b;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:o(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>y({intervalValue:e.value,intervalUnit:e.unit}),children:Ve(t,h)},`${e.value}:${e.unit}`)})})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:He(b,h)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,T.join(h===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,he;t[91]!==n.cronExpr||t[92]!==n.triggerMode||t[93]!==r.form.expression||t[94]!==y?(he=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>y({cronExpr:e.target.value})})}):null,t[91]=n.cronExpr,t[92]=n.triggerMode,t[93]=r.form.expression,t[94]=y,t[95]=he):he=t[95];let ge;t[96]!==n.triggerMode||t[97]!==n.webhookSecretId||t[98]!==r.form.secretId||t[99]!==y?(ge=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>y({webhookSecretId:e.target.value})})}):null,t[96]=n.triggerMode,t[97]=n.webhookSecretId,t[98]=r.form.secretId,t[99]=y,t[100]=ge):ge=t[100];let U;t[101]!==n.eventPayloadMatch||t[102]!==n.eventSource||t[103]!==n.eventType||t[104]!==n.triggerMode||t[105]!==r.form.eventPayloadMatch||t[106]!==r.form.eventSource||t[107]!==r.form.eventType||t[108]!==r.form.invalidJsonObject||t[109]!==y?(U=n.triggerMode===`event`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.eventType,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>y({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>y({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:o(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>y({eventPayloadMatch:e.target.value}),placeholder:`{
5
- "status": "blocked"
6
- }`}),it(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[101]=n.eventPayloadMatch,t[102]=n.eventSource,t[103]=n.eventType,t[104]=n.triggerMode,t[105]=r.form.eventPayloadMatch,t[106]=r.form.eventSource,t[107]=r.form.eventType,t[108]=r.form.invalidJsonObject,t[109]=y,t[110]=U):U=t[110];let ve;t[111]===r.form.action?ve=t[112]:(ve=(0,Z.jsx)(Kt,{title:r.form.action}),t[111]=r.form.action,t[112]=ve);let ye;t[113]!==n.timeoutSeconds||t[114]!==n.workflowId||t[115]!==y||t[116]!==a?(ye=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);y({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_recipe`?`600`:`1800`}:{},...t===`browser_recipe`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&a[0]?{workflowId:a[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[113]=n.timeoutSeconds,t[114]=n.workflowId,t[115]=y,t[116]=a,t[117]=ye):ye=t[117];let Se;t[118]===r.action.runAgent?Se=t[119]:(Se=(0,Z.jsx)(w,{value:`agent`,children:r.action.runAgent}),t[118]=r.action.runAgent,t[119]=Se);let Ce;t[120]===r.action.runWorkflow?Ce=t[121]:(Ce=(0,Z.jsx)(w,{value:`workflow`,children:r.action.runWorkflow}),t[120]=r.action.runWorkflow,t[121]=Ce);let we=h===`zh`?`浏览器自动化`:`Browser automation`,K;t[122]===we?K=t[123]:(K=(0,Z.jsx)(w,{value:`browser_recipe`,children:we}),t[122]=we,t[123]=K);let Te;t[124]!==n.actionMode||t[125]!==ye||t[126]!==Se||t[127]!==Ce||t[128]!==K?(Te=(0,Z.jsxs)(v,{className:Q,value:n.actionMode,onChange:ye,children:[Se,Ce,K]}),t[124]=n.actionMode,t[125]=ye,t[126]=Se,t[127]=Ce,t[128]=K,t[129]=Te):Te=t[129];let Ee=n.actionMode===`browser_recipe`?null:(0,Z.jsx)($,{label:r.form.agent,children:(0,Z.jsxs)(v,{className:Q,value:n.agentId,onChange:e=>y({agentId:e.target.value}),children:[(0,Z.jsx)(w,{value:``,children:m?r.form.loadingAgents:r.form.defaultAgent}),p.map(e=>(0,Z.jsx)(w,{value:e.id,children:le(e,g)},e.id))]})}),De;t[130]!==u||t[131]!==f||t[132]!==n.actionMode||t[133]!==n.agentId||t[134]!==n.browserWorkflowId||t[135]!==n.browserWorkflowInputs||t[136]!==n.description||t[137]!==n.instruction||t[138]!==n.name||t[139]!==n.triggerMode||t[140]!==n.workflowId||t[141]!==n.workflowInput||t[142]!==r.form.instruction||t[143]!==r.form.loadingWorkflows||t[144]!==r.form.noWorkflows||t[145]!==r.form.triggeredRun||t[146]!==r.form.workflow||t[147]!==h||t[148]!==d||t[149]!==c||t[150]!==y||t[151]!==a||t[152]!==l?(De=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(me,{value:n.instruction,onApply:e=>y({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:h,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:o(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>y({instruction:e.target.value})})]}):n.actionMode===`workflow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:r.form.workflow,children:(0,Z.jsxs)(v,{className:Q,value:n.workflowId,onChange:e=>y({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:l||a.length===0,children:[l?(0,Z.jsx)(w,{value:``,children:r.form.loadingWorkflows}):null,!l&&a.length===0?(0,Z.jsx)(w,{value:``,children:r.form.noWorkflows}):null,a.map(Gt)]})}),c?(0,Z.jsx)(_e,{definition:c,language:h,value:n.workflowInput,onChange:e=>y({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>y({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:c.id,workflowTitle:c.title,workflowDescription:c.description}},inputClassName:`rounded-lg`}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:h===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(v,{className:Q,value:n.browserWorkflowId,onChange:e=>{let t=u.find(t=>t.id===e.target.value);y({browserWorkflowId:e.target.value,browserWorkflowInputs:t?be(t):{}})},disabled:f||u.length===0,children:[u.length===0?(0,Z.jsx)(w,{value:``,children:h===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,u.map(Wt)]})}),d&&Object.keys(d.inputs).length>0?(0,Z.jsx)($,{label:h===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(xe,{workflow:d,values:n.browserWorkflowInputs,language:h,onChange:e=>y({browserWorkflowInputs:e})})}):null]}),t[130]=u,t[131]=f,t[132]=n.actionMode,t[133]=n.agentId,t[134]=n.browserWorkflowId,t[135]=n.browserWorkflowInputs,t[136]=n.description,t[137]=n.instruction,t[138]=n.name,t[139]=n.triggerMode,t[140]=n.workflowId,t[141]=n.workflowInput,t[142]=r.form.instruction,t[143]=r.form.loadingWorkflows,t[144]=r.form.noWorkflows,t[145]=r.form.triggeredRun,t[146]=r.form.workflow,t[147]=h,t[148]=d,t[149]=c,t[150]=y,t[151]=a,t[152]=l,t[153]=De):De=t[153];let Oe;t[154]===r.form.advancedDescription?Oe=t[155]:(Oe=(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[154]=r.form.advancedDescription,t[155]=Oe);let ke;t[156]!==r.form.advanced||t[157]!==Oe?(ke=(0,Z.jsxs)(`span`,{children:[r.form.advanced,Oe]}),t[156]=r.form.advanced,t[157]=Oe,t[158]=ke):ke=t[158];let q;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(ne,{className:`size-4 transition-transform group-open:rotate-180`}),t[159]=q):q=t[159];let Ae;t[160]===ke?Ae=t[161]:(Ae=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[ke,q]}),t[160]=ke,t[161]=Ae);let J;t[162]!==n.actionMode||t[163]!==n.afterRunMode||t[164]!==n.safetyMode||t[165]!==r.form.safety||t[166]!==r.safety||t[167]!==y?(J=n.actionMode===`browser_recipe`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Kt,{title:r.form.safety}),(0,Z.jsxs)($,{label:r.form.safety,children:[(0,Z.jsxs)(v,{className:Q,value:n.safetyMode,onChange:e=>{let t=e.target.value;y({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},children:[(0,Z.jsx)(w,{value:`suggest_only`,children:r.safety.suggest_only}),(0,Z.jsx)(w,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,Z.jsx)(w,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}),t[162]=n.actionMode,t[163]=n.afterRunMode,t[164]=n.safetyMode,t[165]=r.form.safety,t[166]=r.safety,t[167]=y,t[168]=J):J=t[168];let Y;t[169]===r.form.afterRun?Y=t[170]:(Y=(0,Z.jsx)(Kt,{title:r.form.afterRun}),t[169]=r.form.afterRun,t[170]=Y);let X;t[171]===y?X=t[172]:(X=e=>y({afterRunMode:e.target.value}),t[171]=y,t[172]=X);let je;t[173]===r.afterRun.none?je=t[174]:(je=(0,Z.jsx)(w,{value:`none`,children:r.afterRun.none}),t[173]=r.afterRun.none,t[174]=je);let Me;t[175]===r.afterRun.saveToSession?Me=t[176]:(Me=(0,Z.jsx)(w,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[175]=r.afterRun.saveToSession,t[176]=Me);let Ne=n.safetyMode!==`auto_apply`,Pe;t[177]!==r.afterRun.webhook||t[178]!==Ne?(Pe=(0,Z.jsx)(w,{value:`webhook`,disabled:Ne,children:r.afterRun.webhook}),t[177]=r.afterRun.webhook,t[178]=Ne,t[179]=Pe):Pe=t[179];let Fe;t[180]!==n.afterRunMode||t[181]!==X||t[182]!==je||t[183]!==Me||t[184]!==Pe?(Fe=(0,Z.jsxs)(v,{className:Q,value:n.afterRunMode,onChange:X,children:[je,Me,Pe]}),t[180]=n.afterRunMode,t[181]=X,t[182]=je,t[183]=Me,t[184]=Pe,t[185]=Fe):Fe=t[185];let Ie;t[186]!==n.afterRunMode||t[187]!==n.webhookUrl||t[188]!==r.form.webhookUrl||t[189]!==y?(Ie=n.afterRunMode===`webhook`?(0,Z.jsx)($,{label:r.form.webhookUrl,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>y({webhookUrl:e.target.value})})}):null,t[186]=n.afterRunMode,t[187]=n.webhookUrl,t[188]=r.form.webhookUrl,t[189]=y,t[190]=Ie):Ie=t[190];let Le;t[191]===r.form.reliability?Le=t[192]:(Le=(0,Z.jsx)(Kt,{title:r.form.reliability}),t[191]=r.form.reliability,t[192]=Le);let Re;t[193]===y?Re=t[194]:(Re=e=>y({timeoutSeconds:e.target.value}),t[193]=y,t[194]=Re);let Ue;t[195]!==n.timeoutSeconds||t[196]!==Re?(Ue=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:Re}),t[195]=n.timeoutSeconds,t[196]=Re,t[197]=Ue):Ue=t[197];let We;t[198]!==r.form.timeoutSeconds||t[199]!==Ue?(We=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:Ue}),t[198]=r.form.timeoutSeconds,t[199]=Ue,t[200]=We):We=t[200];let Ke;t[201]===y?Ke=t[202]:(Ke=e=>y({disableAfterFailures:e.target.value}),t[201]=y,t[202]=Ke);let qe;t[203]!==n.disableAfterFailures||t[204]!==Ke?(qe=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Ke}),t[203]=n.disableAfterFailures,t[204]=Ke,t[205]=qe):qe=t[205];let Je;t[206]!==r.form.disableAfterFailures||t[207]!==qe?(Je=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:qe}),t[206]=r.form.disableAfterFailures,t[207]=qe,t[208]=Je):Je=t[208];let Ye;t[209]!==We||t[210]!==Je?(Ye=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[We,Je]}),t[209]=We,t[210]=Je,t[211]=Ye):Ye=t[211];let Xe;t[212]===r.form.effectivePolicy?Xe=t[213]:(Xe=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[212]=r.form.effectivePolicy,t[213]=Xe);let Qe=n.timeoutSeconds||`—`,$e;t[214]!==r.form.executionDeadline||t[215]!==Qe?($e=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,Qe,`s`]}),t[214]=r.form.executionDeadline,t[215]=Qe,t[216]=$e):$e=t[216];let et;t[217]===r.form.downstreamTimeoutHint?et=t[218]:(et=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[217]=r.form.downstreamTimeoutHint,t[218]=et);let tt;t[219]!==Xe||t[220]!==$e||t[221]!==et?(tt=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[Xe,$e,et]}),t[219]=Xe,t[220]=$e,t[221]=et,t[222]=tt):tt=t[222];let nt;t[223]!==J||t[224]!==Y||t[225]!==Fe||t[226]!==Ie||t[227]!==Le||t[228]!==Ye||t[229]!==tt?(nt=(0,Z.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[J,Y,Fe,Ie,Le,Ye,tt]}),t[223]=J,t[224]=Y,t[225]=Fe,t[226]=Ie,t[227]=Le,t[228]=Ye,t[229]=tt,t[230]=nt):nt=t[230];let rt;t[231]!==Ae||t[232]!==nt?(rt=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[Ae,nt]}),t[231]=Ae,t[232]=nt,t[233]=rt):rt=t[233];let at;return t[234]!==A||t[235]!==ie||t[236]!==M||t[237]!==fe||t[238]!==B||t[239]!==V||t[240]!==H||t[241]!==he||t[242]!==ge||t[243]!==U||t[244]!==ve||t[245]!==Te||t[246]!==Ee||t[247]!==De||t[248]!==rt?(at=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[A,ie,M,fe,B,V,H,he,ge,U,ve,Te,Ee,De,rt]})}),t[234]=A,t[235]=ie,t[236]=M,t[237]=fe,t[238]=B,t[239]=V,t[240]=H,t[241]=he,t[242]=ge,t[243]=U,t[244]=ve,t[245]=Te,t[246]=Ee,t[247]=De,t[248]=rt,t[249]=at):at=t[249],at}function Wt(e){return(0,Z.jsx)(w,{value:e.id,children:e.name},e.id)}function Gt(e){return(0,Z.jsx)(w,{value:e.id,children:e.title||e.name},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,G.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Kt(e){let t=(0,G.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(se,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{Ct as AutomationsPage};
@@ -1,8 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-DMJ-6-1m.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-VOY1wMO9.js";import{$l as p,At as m,Bl as h,En as g,Fo as _,Gl as v,Ho as y,Hs as b,Kl as x,Lc as S,Ml as C,Oc as w,Ol as T,Ot as E,Pl as D,Uo as O,Xs as k,Yl as A,Zs as j,bs as M,do as N,fl as P,fo as F,gc as I,hc as L,hs as R,is as z,js as B,ks as V,kt as H,mc as U,nu as W,oc as G,os as ee,qs as te,uc as K,wr as q}from"./index-DzmbmOGA.js";import{n as ne,r as re,t as ie}from"./settings-page-layout-J793iqfm.js";import{n as ae}from"./settings-loading-skeleton-BDzpxgk0.js";import{n as oe,t as se}from"./use-autosave-CcvY7DTh.js";import{t as ce}from"./settings-advanced-gate-BI0u77dt.js";import{n as le,t as ue}from"./settings-form-section-CKLns16d.js";import{t as de}from"./page-tabs-CvzSdYVj.js";import{c as fe,r as pe,s as J}from"./typed-models-lib-CT2c85Ju.js";import{i as me,l as he,s as ge,u as _e}from"./gateway-config-api-CZra7GuI.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function ve(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function ye(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=a(fe(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(be),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,Z.jsx)(y,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=i?(0,Z.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(W,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:a(`inline-block size-1.5 rounded-full`,ve(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function be(e){return(0,Z.jsx)(O,{value:e.value,children:e.name},e.value)}function xe(e){return`browser-focus-${e}`}function Se(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Ce(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=xe(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(le,{icon:te,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=fe(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(O,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(O,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(O,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let b;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(b=(0,Z.jsxs)(y,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=b):b=t[31];let x;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==b?(x=(0,Z.jsx)(Q,{label:f,description:p,children:b}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=b,t[35]=x):x=t[35];let S=n.label.browserDialogTimeout,C=n.desc.browserDialogTimeout,w;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(w=J(),t[36]=w):w=t[36];let T=r.browserDialogTimeout??``,E;t[37]===i?E=t[38]:(E=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=E);let D;t[39]!==T||t[40]!==E?(D=(0,Z.jsx)(`input`,{type:`number`,className:w,min:1,value:T,placeholder:`300`,onChange:E}),t[39]=T,t[40]=E,t[41]=D):D=t[41];let k;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==D?(k=(0,Z.jsx)(Q,{label:S,description:C,children:D}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=D,t[45]=k):k=t[45];let A;t[46]!==x||t[47]!==k||t[48]!==d?(A=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,x,k]}),t[46]=x,t[47]=k,t[48]=d,t[49]=A):A=t[49];let M;t[50]!==o||t[51]!==A?(M=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(ue,{children:[o,A]})}),t[50]=o,t[51]=A,t[52]=M):M=t[52];let N;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(N=xe(`security`),t[53]=N):N=t[53];let P;t[54]===n.browserSecurityShow?P=t[55]:(P=(0,Z.jsx)(le,{icon:j,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=P);let F;t[56]===i?F=t[57]:(F=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=F);let I;t[58]!==r.browserAllowPrivateUrls||t[59]!==F?(I=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:F}),t[58]=r.browserAllowPrivateUrls,t[59]=F,t[60]=I):I=t[60];let L;t[61]===n.browserAllowPrivateOn?L=t[62]:(L=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=L);let R;t[63]!==I||t[64]!==L?(R=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,L]}),t[63]=I,t[64]=L,t[65]=R):R=t[65];let z;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==R?(z=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:R}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=R,t[69]=z):z=t[69];let B=n.label.browserCommandTimeout,V=n.desc.browserCommandTimeout,H;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(H=J(),t[70]=H):H=t[70];let U=r.browserCommandTimeout??``,W;t[71]===i?W=t[72]:(W=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=W);let G;t[73]!==U||t[74]!==W?(G=(0,Z.jsx)(`input`,{type:`number`,className:H,min:5,value:U,placeholder:`30`,onChange:W}),t[73]=U,t[74]=W,t[75]=G):G=t[75];let ee;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==G?(ee=(0,Z.jsx)(Q,{label:B,description:V,children:G}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=G,t[79]=ee):ee=t[79];let K;t[80]!==z||t[81]!==ee?(K=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[z,ee]}),t[80]=z,t[81]=ee,t[82]=K):K=t[82];let q;t[83]!==P||t[84]!==K?(q=(0,Z.jsx)(`div`,{id:N,className:`scroll-mt-24`,children:(0,Z.jsxs)(ue,{className:`border border-amber-500/20`,children:[P,K]})}),t[83]=P,t[84]=K,t[85]=q):q=t[85];let ne;return t[86]!==M||t[87]!==q?(ne=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[M,q]}),t[86]=M,t[87]=q,t[88]=ne):ne=t[88],ne}function we(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,o;t[0]===n?o=t[1]:(o=_(n),t[0]=n,t[1]=o);let s;t[2]===i?s=t[3]:(s=a(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(T,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function Te(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=a(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==i||t[6]!==o?(m=i&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(W,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function Ee(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=q(De),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:K,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:k,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:w,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:h,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>he(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Te,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function De(e){return e.mode}function Oe(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function ke(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ae(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function je(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Me=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ne=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Pe={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Fe(e){let t=(e??``).trim();return t===`behavior`?`overview`:Me.includes(t)?t:`overview`}function Ie(e){return Ne.includes(e)}function Le(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Re,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Re,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Re(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,o,s,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:p,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:B,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:S,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:A,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:x,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=a(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=a(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let f;t[12]!==o||t[13]!==d?(f=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=f):f=t[14];let m;t[15]===s?m=t[16]:(m=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=m);let h;t[17]!==c||t[18]!==f||t[19]!==m?(h=(0,Z.jsxs)(`span`,{className:c,children:[f,m]}),t[17]=c,t[18]=f,t[19]=m,t[20]=h):h=t[20];let g;t[21]===r?g=t[22]:(g=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=g);let _;return t[23]!==l||t[24]!==h||t[25]!==g?(_=(0,Z.jsxs)(`span`,{className:l,children:[h,g]}),t[23]=l,t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function ze(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===i?o=t[1]:(o=a(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var Be={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function Ve({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(m,Be),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:h,executablePath:g}=c,_=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,Y.useCallback)(async e=>{await i(e),await _()},[_,i]),x=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Le,{icon:L,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(L,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(ze,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(b,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Le,{icon:M,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void x(),children:[p===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(U,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,Z.jsx)(ze,{kind:p===`error`?`error`:`success`,message:h}):null]})]})}function He(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ue(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=He(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(We)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function We(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ge={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ke({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(m,Ge),{confirmOpen:f,installStatus:h,installMessage:_,openStatus:v,openMessage:b,runtime:x}=u,{progress:w,running:T,cancelling:E,run:D,reset:A,cancel:j}=i,M=t.kind===`ok`?t.data:null,N=M?.installed===!0,P=h===`installing`||T,F=(0,Y.useCallback)(async()=>{if(N)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,N]);(0,Y.useEffect)(()=>{if(!N){d({type:`patch`,patch:{runtime:null}});return}F();let e=setInterval(()=>void F(),8e3);return()=>clearInterval(e)},[N,F]);let I=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),A();let t=await D({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),A();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await F()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,F,A,D]),R=(0,Y.useCallback)(async()=>{if(v!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,v]),z=t.kind===`loading`?`checking`:t.kind===`error`?`error`:N?`ready`:`not_installed`,B=N&&M?.version?`v${M.version} (${M.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Le,{icon:k,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:z,statusDetail:B,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[N?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:v===`pending`,onClick:()=>void R(),children:[v===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(L,{className:`size-3.5`}),v===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:P,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[P?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):N?(0,Z.jsx)(G,{className:`size-3.5`}):h===`installed`?(0,Z.jsx)(p,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(C,{className:`size-3.5`}),P?e.browserCloakInstalling:N?e.browserReinstall:e.browserCloakDownload]})]}),children:[T?(0,Z.jsx)(Ue,{m:e,progress:w,cancelling:E,onCancel:()=>void j()}):null,_?(0,Z.jsx)(ze,{kind:h===`failed`?`error`:`success`,message:_}):null,b?(0,Z.jsx)(ze,{kind:v===`error`?`error`:`success`,message:b}):null,N&&x?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:x.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(x.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:x.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),x.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(y,{className:fe(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(O,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(O,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(ue,{className:`mt-4`,children:[(0,Z.jsx)(le,{icon:k,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:qe(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(g,{open:f,title:e.browserConfirmDownloadTitle,description:Je(e,M),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void I(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function qe(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Je(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
- `)}function Ye({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[a,o]=(0,Y.useState)(`idle`),[c,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=s(l(e=>e.language)).providersSettings,p=z({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),m=(0,Y.useCallback)(()=>me().then(e=>e.apiKey??null),[]),g=(0,Y.useCallback)(async()=>{o(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(o(`ok`),u(e.browserCloudTestOk)):(o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Le,{icon:h,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:a===`pending`,onClick:()=>void g(),children:[a===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(U,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(y,{className:fe(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(O,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(O,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(ee,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:p,reveal:m,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),c?(0,Z.jsx)(ze,{kind:a===`error`?`error`:`success`,message:c}):null]})}function Xe(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:i,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,m;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(m={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=m):m=t[2];let h=!!i&&o,g;t[3]!==s||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(g=i?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=g):g=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==h||t[18]!==g?(_={id:`load`,label:n.browserExtensionInstallStep2,done:h,detail:g},t[16]=n.browserExtensionInstallStep2,t[17]=h,t[18]=g,t[19]=_):_=t[19];let y;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(y={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=y):y=t[22];let b;t[23]!==m||t[24]!==_||t[25]!==y?(b=[m,_,y],t[23]=m,t[24]=_,t[25]=y,t[26]=b):b=t[26];let x=b,S;t[27]===x?S=t[28]:(S=x.filter(Ze),t[27]=x,t[28]=S);let C=S.length,w=n.browserExtensionInstallGuideTitle,T;t[29]===n.browserExtensionInstallGuideTitle?T=t[30]:(T=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=T);let E;t[31]!==C||t[32]!==n.browserExtensionChecklistProgress||t[33]!==x.length?(E=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(C)).replace(`{{total}}`,String(x.length)),t[31]=C,t[32]=n.browserExtensionChecklistProgress,t[33]=x.length,t[34]=E):E=t[34];let D;t[35]===E?D=t[36]:(D=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:E}),t[35]=E,t[36]=D);let O;t[37]!==D||t[38]!==T?(O=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[T,D]}),t[37]=D,t[38]=T,t[39]=O):O=t[39];let k;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==x?(k=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:x.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(p,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(v,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:a(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=x,t[43]=k):k=t[43];let A;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==O||t[46]!==k?(A=(0,Z.jsxs)(`div`,{"aria-label":w,className:`rounded-xl bg-surface-base p-3`,children:[O,k]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=O,t[46]=k,t[47]=A):A=t[47],A}function Ze(e){return e.done}var Qe=19820,$e=3e4;function et({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:s,installArtifacts:c,refetchArtifacts:l,openExtensionChrome:u,revealExtensionFolder:d,form:f,embedded:p=!1}){let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),x=f.port??Qe,w=f.host||`127.0.0.1`,T=`ws://${w}:${x}/browser-ext`,E=t.kind===`ok`&&t.data.running,D=t.kind===`ok`&&t.data.connected,O=t.kind===`ok`&&t.data.bridgeHeld===!0,k=t.kind===`ok`&&t.data.portConflict===!0,A=E||O,j=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,M=j?.installed===!0,N=j?.extensionDir,P=j?.needsChromeReload===!0,F=t.kind===`ok`?D?{icon:I,color:`text-green-500`,label:e.browserExtensionConnected}:E?{icon:U,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:V,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:V,color:`text-fg-muted`,label:`…`},R=F.icon,z=(0,Y.useCallback)(async()=>{if(!m){h(`start`),_(null);try{await i({host:w,port:x})}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,w,x,i]),B=(0,Y.useCallback)(async()=>{if(!m){h(`stop`),_(null);try{await a()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,a]),H=(0,Y.useCallback)(async()=>{if(!m){h(`disconnect`),_(null);try{await s()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,s]),W=(0,Y.useCallback)(async()=>{if(!m){h(`install`),_(null),y(null);try{let t=await c({force:M});t?.extensionDir?y(`${e.browserExtensionInstalled}: ${t.extensionDir}`):y(e.browserExtensionInstalled),await l()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,c,M,e.browserExtensionInstalled,l]),G=(0,Y.useCallback)(async()=>{if(!m){h(`open`),_(null);try{await u()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,u]),ee=(0,Y.useCallback)(async()=>{if(!(!N||m)){h(`path`),_(null),y(null);try{await o(N)?y(e.browserExtensionPathCopied):y(e.browserExtensionPathCopyFailed)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,N,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),te=(0,Y.useCallback)(async()=>{if(!(!N||m)){h(`folder`),_(null),y(null);try{await d(),y(e.browserExtensionFolderOpened)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,N,e.browserExtensionFolderOpened,d]),q=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void W(),children:[m===`install`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(C,{className:`size-3.5`}),m===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),A?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void B(),children:[m===`stop`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void z(),children:[m===`start`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(L,{className:`size-3.5`}),m===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),D?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void H(),children:[m===`disconnect`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(V,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Le,{icon:K,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:q,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:f.port??``,placeholder:String(Qe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:f.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:f.connectionTimeoutMs==null?``:Math.round(f.connectionTimeoutMs/1e3),placeholder:String($e/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:T}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${F.color}`,children:[(0,Z.jsx)(R,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:F.label})]})]}),(0,Z.jsx)(Xe,{m:e,installed:M,extensionDir:N,connected:D,busy:m!==null,pathBusy:m===`path`,folderBusy:m===`folder`,onOpenChrome:()=>void G(),onCopyPath:()=>void ee(),onRevealFolder:()=>void te()}),P?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,k?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(x))}):null,v?(0,Z.jsx)(ze,{kind:`success`,message:v}):null,g?(0,Z.jsx)(ze,{kind:`error`,message:g}):null]})})}function tt(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),{progress:m,running:h,cancelling:g,run:_,reset:v,cancel:y}=o,b;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==v||t[5]!==_?(b=async()=>{u(`installing`),f(null),v();let e=await _({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),v();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=v,t[5]=_,t[6]=b):b=t[6];let x=b,T=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,E=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,D=r.kind===`ok`&&r.data.installed,O=l===`installing`||h,k;t[7]===x?k=t[8]:(k=()=>void x(),t[7]=x,t[8]=k);let A;t[9]!==D||t[10]!==O||t[11]!==l?(A=O?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):D?(0,Z.jsx)(G,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(p,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(C,{className:`size-3.5`}),t[9]=D,t[10]=O,t[11]=l,t[12]=A):A=t[12];let j=O?n.browserPlaywrightInstalling:D?n.browserReinstall:n.browserPlaywrightInstall,M;t[13]!==O||t[14]!==k||t[15]!==A||t[16]!==j?(M=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:O,onClick:k,children:[A,j]}),t[13]=O,t[14]=k,t[15]=A,t[16]=j,t[17]=M):M=t[17];let N;t[18]===n.browserPlaywrightManualInstall?N=t[19]:(N=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=N);let P;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=P):P=t[20];let F;t[21]===N?F=t[22]:(F=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[N,P]}),t[21]=N,t[22]=F);let I;t[23]!==y||t[24]!==g||t[25]!==n||t[26]!==m||t[27]!==h?(I=h?(0,Z.jsx)(Ue,{m:n,progress:m,showLogs:!0,cancelling:g,onCancel:()=>void y()}):null,t[23]=y,t[24]=g,t[25]=n,t[26]=m,t[27]=h,t[28]=I):I=t[28];let L;t[29]!==d||t[30]!==l?(L=d?(0,Z.jsx)(ze,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=L):L=t[31];let R;return t[32]!==c||t[33]!==n||t[34]!==E||t[35]!==T||t[36]!==I||t[37]!==L||t[38]!==M||t[39]!==F?(R=(0,Z.jsxs)(Le,{icon:w,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:T,statusDetail:E,m:n,embedded:c,primaryAction:M,children:[F,I,L]}),t[32]=c,t[33]=n,t[34]=E,t[35]=T,t[36]=I,t[37]=L,t[38]=M,t[39]=F,t[40]=R):R=t[40],R}async function nt(e){let t=await u(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await u(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var rt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function it(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function at(e){let[t,n]=(0,Y.useReducer)(it,rt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await nt(d(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await nt(d(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>nt(d(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(d(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await u(d(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await nt(d(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(d(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}c()},[_,c]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(d(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(d(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(d(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await nt(d(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var ot=`
3
-
4
- `,st=/\r\n/g,ct={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},lt={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ut=8;function dt(){return{phase:null,message:null,percent:null,lines:[]}}function ft(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ut?r.slice(-8):r}return n}async function pt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
- `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(st,`
6
- `);let l=a.split(ot);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function mt(e){let[t,n]=(0,Y.useState)(dt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.useCallback)(()=>{s.current||n(dt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(d(lt[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;c.current=r,s.current=!0,i(!0),n(dt());try{let i=await u(d(ct[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await pt(i.body,e=>{n(t=>ft(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{c.current===r&&(c.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:l,cancel:f}}function ht(e){let t=(0,X.c)(150),{a:n,form:r,update:i,activeTab:o,setActiveTab:s}=e,c=l(_t),u=q(gt),d=mt(`playwright`),f=mt(`cloakbrowser`),p=r.browserEnabled&&(o===`overview`||o===`extension`),m=r.browserEnabled&&(o===`overview`||o===`local`),g=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==g||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:g,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=g,t[7]=p,t[8]=m,t[9]=_):_=t[9];let v=at(_),y;t[10]===v.playwright?y=t[11]:(y=Oe(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,x;t[12]===v.cloak?x=t[13]:(x=Oe(v.cloak),t[12]=v.cloak,t[13]=x);let S=x,C;t[14]===v.extension?C=t[15]:(C=Ae(v.extension),t[14]=v.extension,t[15]=C);let T=C,E;t[16]!==n||t[17]!==v.extension?(E=je(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=E):E=t[18];let D=E,O;t[19]!==n||t[20]!==S||t[21]!==T||t[22]!==D||t[23]!==b||t[24]!==u?(O=[{value:`extension`,icon:K,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:T,statusLabel:D},{value:`local`,icon:w,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:ke(b,n)},{value:`cloakbrowser`,icon:k,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:S,statusLabel:ke(S,n)},{value:`cdp`,icon:M,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:h,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>he(e.value,u)),t[19]=n,t[20]=S,t[21]=T,t[22]=D,t[23]=b,t[24]=u,t[25]=O):O=t[25];let A=O,j;t[26]!==s||t[27]!==i?(j=e=>{i({browserEnabled:!0,browserBackend:e}),s(e)},t[26]=s,t[27]=i,t[28]=j):j=t[28];let N=j,F=!r.browserEnabled&&`pointer-events-none opacity-40`,I;t[29]===F?I=t[30]:(I=a(`flex flex-col gap-5 transition-opacity`,F),t[29]=F,t[30]=I);let L=!r.browserEnabled,R;t[31]!==n||t[32]!==o||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(R=o===`extension`?(0,Z.jsx)(ue,{children:(0,Z.jsx)(et,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>i({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=R):R=t[46];let z;t[47]!==n||t[48]!==o||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(z=o===`local`?(0,Z.jsx)(ue,{children:(0,Z.jsx)(tt,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=z):z=t[53];let B;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==i?(B=o===`cloakbrowser`?(0,Z.jsx)(ue,{children:(0,Z.jsx)(Ke,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>i({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=o,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=i,t[74]=B):B=t[74];let V;t[75]!==n||t[76]!==o||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(V=o===`cdp`?(0,Z.jsx)(ue,{children:(0,Z.jsx)(Ve,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=V):V=t[83];let H;t[84]!==n||t[85]!==o||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(H=o===`cloud`?(0,Z.jsx)(ue,{children:(0,Z.jsx)(Ye,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>i({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=o,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=H):H=t[92];let U;t[93]!==R||t[94]!==z||t[95]!==B||t[96]!==V||t[97]!==H||t[98]!==I||t[99]!==L?(U=(0,Z.jsxs)(`div`,{className:I,"aria-hidden":L,children:[R,z,B,V,H]}),t[93]=R,t[94]=z,t[95]=B,t[96]=V,t[97]=H,t[98]=I,t[99]=L,t[100]=U):U=t[100];let W=U;if(o===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==N?(e=r.browserEnabled?null:(0,Z.jsx)(Ee,{m:n,onStart:N}),t[101]=n,t[102]=r.browserEnabled,t[103]=N,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(P,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let l;t[106]===i?l=t[107]:(l=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=l);let u;t[108]!==r.browserEnabled||t[109]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:l}),t[108]=r.browserEnabled,t[109]=l,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==c?(m=(0,Z.jsx)(we,{language:c,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=c,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let g;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==A||t[130]!==s||t[131]!==i?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:xe(`connection`),className:a(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(ye,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:s,options:A})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=A,t[130]=s,t[131]=i,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,Z.jsx)(ue,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,g]})}),t[133]=h,t[134]=g,t[135]=_):_=t[135];let v=!r.browserEnabled&&`pointer-events-none opacity-40`,y;t[136]===v?y=t[137]:(y=a(`transition-opacity`,v),t[136]=v,t[137]=y);let b=!r.browserEnabled,x;t[138]!==n||t[139]!==r||t[140]!==i?(x=(0,Z.jsx)(Ce,{a:n,form:r,update:i}),t[138]=n,t[139]=r,t[140]=i,t[141]=x):x=t[141];let S;t[142]!==y||t[143]!==b||t[144]!==x?(S=(0,Z.jsx)(ce,{children:(0,Z.jsx)(`div`,{className:y,"aria-hidden":b,children:x})}),t[142]=y,t[143]=b,t[144]=x,t[145]=S):S=t[145];let C;return t[146]!==e||t[147]!==_||t[148]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,S]}),t[146]=e,t[147]=_,t[148]=S,t[149]=C):C=t[149],C}return Ie(o)?W:null}function gt(e){return e.mode}function _t(e){return e.language}function vt(e){let t=(0,X.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,c=o===void 0?!1:o,u=l(yt),d;t[0]===u?d=t[1]:(d=s(u),t[0]=u,t[1]=d);let f=d,p=f.agentSettings,m=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(D,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===p.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p.needToken}),t[5]=p.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(re,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(re,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(ae,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??p.loadError,n;t[11]===e?n=t[12]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==f.logs.refresh||t[16]!==r?(a=(0,Z.jsx)(R,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[15]=f.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,Z.jsxs)(re,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let h=c?void 0:r,g;t[21]===p.sectionDesc?g=t[22]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:p.sectionDesc}),t[21]=p.sectionDesc,t[22]=g);let _;t[23]!==i.autosaveStatus||t[24]!==i.error?(_=(0,Z.jsx)(oe,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=_):_=t[25];let v;t[26]!==m||t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,Z.jsx)(ne,{title:m,subtitle:h,meta:g,actions:_}),t[26]=m,t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;t[31]===i.error?y=t[32]:(y=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[31]=i.error,t[32]=y);let b;t[33]===a?b=t[34]:(b=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=b);let x;return t[35]!==v||t[36]!==y||t[37]!==b||t[38]!==i.onBlurCapture?(x=(0,Z.jsxs)(re,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[v,y,b]}),t[35]=v,t[36]=y,t[37]=b,t[38]=i.onBlurCapture,t[39]=x):x=t[39],x}function yt(e){return e.language}var bt={summaryModel:``},xt={model:``,maxLength:void 0};function St(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function Ct(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function wt(e){return e===!0||e===`true`||e===1}function Tt(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=wt(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=wt(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
- `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Et(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Ot(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function kt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function At(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function jt(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Mt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Nt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:Ct(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:Ct(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:Ct(t.imageGenerationModel),u=Tt((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:St(r),modelFallbacks:a,imageModel:St(t.imageModel),imageModelFallbacks:s,imageGenerationModel:St(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:jt(t),imageGenerationModelAutoProviderFallback:Mt(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,sessionSearch:Et(t.sessionSearch),webExtract:Dt(t.webExtract),delegate:Ot(t.delegate,!1),executeCode:Ot(t.executeCode,!1),skillsAllowlist:kt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return kt(n)})(),typedModels:pe(n),paramsJson:At(t.params)}}function Pt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
- `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Ft(e){await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Pt(e)})}),N()}var It=E();function Lt(e){let t=!!c(e=>e.token),[n,r]=(0,Y.useReducer)(It,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,Y.useRef)(!1),s=(0,Y.useRef)(i);s.current=i;let l=(0,Y.useRef)(null),{data:u,error:d,isLoading:f,mutate:p}=F(t);H({enabled:t,parsed:(0,Y.useMemo)(()=>u?.payload?.config===void 0?null:Nt(u.payload.config),[u]),dirty:o.current,trackedParsedRef:l,dispatch:r,onResetDirty:()=>{o.current=!1}});let m=!!(t&&f&&u===void 0&&!d),h=d instanceof Error?d.message:d?String(d):null,g=(0,Y.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,Y.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=se({value:i,dirty:g,onSave:(0,Y.useCallback)(async t=>{try{await Ft(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError])});return{hasToken:t,loading:m,fetchError:h,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:p}}function Rt(e,t){return e.browserTabs[t]}function zt(){let e=(0,X.c)(42),t=l(Vt),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,c=q(Bt),u=Lt(a),[d,f]=i(),p;e[2]===c?p=e[3]:(p=_e(Me,c),e[2]=c,e[3]=p);let m=p,h;e[4]===d?h=e[5]:(h=Se(d.get(`focus`)),e[4]=d,e[5]=h);let g=h,_;e[6]!==g||e[7]!==d?(_=g?Pe[g]??Fe(d.get(`tab`)):Fe(d.get(`tab`)),e[6]=g,e[7]=d,e[8]=_):_=e[8];let v=_,y;bb0:{if(!u.form){y=null;break bb0}let t;e[9]!==a||e[10]!==o||e[11]!==u.form||e[12]!==u.update?(t={form:u.form,update:u.update,a,chat:o},e[9]=a,e[10]=o,e[11]=u.form,e[12]=u.update,e[13]=t):t=e[13],y=t}let b=y,x;e[14]===f?x=e[15]:(x=e=>{f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[14]=f,e[15]=x);let S=x;ge(v,S);let C,w;e[16]!==g||e[17]!==d||e[18]!==f?(C=()=>{if(!g)return;let e=Pe[g]??Fe(d.get(`tab`));f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=g===`runtime`||g===`security`?xe(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},w=[g,d,f],e[16]=g,e[17]=d,e[18]=f,e[19]=C,e[20]=w):(C=e[19],w=e[20]),(0,Y.useEffect)(C,w);let T;if(e[21]!==a||e[22]!==m){let t;e[24]===a?t=e[25]:(t=e=>({id:e,label:Rt(a,e)}),e[24]=a,e[25]=t),T=m.map(t),e[21]=a,e[22]=m,e[23]=T}else T=e[23];let E=T,D;e[26]!==v||e[27]!==a.browserTabsAria||e[28]!==S||e[29]!==E?(D=(0,Z.jsx)(de,{items:E,activeTab:v,onChange:S,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[26]=v,e[27]=a.browserTabsAria,e[28]=S,e[29]=E,e[30]=D):D=e[30];let O;e[31]!==v||e[32]!==b||e[33]!==S?(O=b?(0,Z.jsx)(ht,{...b,activeTab:v,setActiveTab:S}):null,e[31]=v,e[32]=b,e[33]=S,e[34]=O):O=e[34];let k;e[35]!==v||e[36]!==O?(k=(0,Z.jsx)(ie,{id:v,activeTab:v,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:O}),e[35]=v,e[36]=O,e[37]=k):k=e[37];let A;return e[38]!==k||e[39]!==D||e[40]!==u?(A=(0,Z.jsxs)(vt,{sectionId:`agent-browser`,intro:``,vm:u,tabbed:!0,children:[D,k]}),e[38]=k,e[39]=D,e[40]=u,e[41]=A):A=e[41],A}function Bt(e){return e.mode}function Vt(e){return e.language}export{zt as AgentBrowserSettingsPage};