@xopcai/xopc 0.0.155 → 0.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/action-boundary-settings-panel-zQ_w0sPl.js +1 -0
- package/dist/gateway/static/root/assets/{activity-store-Btmg10yU.js → activity-store-CddlQHam.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-pdlJJov8.js → agent-avatar-dicebear-DOfTopIk.js} +1 -1
- package/dist/gateway/static/root/assets/agents-RZNd9xMI.js +2 -0
- package/dist/gateway/static/root/assets/{api-GGYxPxVF.js → api-NUlcaaV9.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BU9oSmtJ.js → app-management-settings-panel-J0-z_uc1.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B2chSkbj.js → appearance-settings-CMaQOx2C.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BOeTZgdL.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BC83GwY1.js → archive-plugin-BVwE70GV.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DWSH5325.js → attachment-load-aj5U56K9.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Bc25f4wz.js → automation-suggestion-card-CKz8rxAb.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-wYN1N-Il.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Kgu5yX35.js → binary-plugins-Ie6owbEw.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B9gJmzdE.js → block-editor-BaDrd5GJ.js} +31 -31
- package/dist/gateway/static/root/assets/browser-settings-page-DD3djQtX.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-6z36IfIC.js → capability-presets-api-BjO4YD-O.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Bqzl2UZ9.js → capability-presets-settings-panel-bwezWQpF.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-DEkm4HRd.js → channel-recipient-api-BisDU_DH.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bohv9YRy.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-h3VHD5Uq.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-DPriINR1.js → connector-logo-DGjjzBIH.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-LIAkMlN-.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CG91Su8E.js → desktop-pet-CoQ4Edck.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DUzETFxq.js → desktop-pet-settings--sjUYeNX.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-XNbI2wM7.js → directory-picker-path-field-CpmfFDx3.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-BsLa5Nr8.js → dreaming-settings-D7rRROE7.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-C-5Nyrdu.js → extension-debug-page-BzqW3ssG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BEocT43y.js → extension-page-CKDbBzVR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page--XOHrL-O.js → extension-settings-page-DjNMSdRz.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DZrNmiR3.js → gateway-config-api-CUEAZEld.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DfBvlqb2.js → gateway-settings-h1wWBrxD.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Cc5dxiD_.js → gateway-startup-retry-CbMPgpHX.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-xfO0R5Bx.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-CVVKF2hY.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-Cdghd3f3.js → goals-config-api-C-Vq8VR9.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-W666NFIU.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-CvOdikU6.js → goals-settings-DVrTDWYS.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CvaxjdV_.js → heartbeat-settings-Dv8qA4E7.js} +1 -1
- package/dist/gateway/static/root/assets/{index-C4HpPu1y.js → index-DHRxn7Sy.js} +61 -64
- package/dist/gateway/static/root/assets/index-gpwk8Nro.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BVt0deH6.js → keyboard-shortcuts-settings-DEKtMZbg.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-y5WmNSyZ.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-C0HGfwao.js → local-apps-page-DQT2lZk7.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dt0pSudQ.js → locale-store-d9Cylz62.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DMQaC4Jn.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CjVg43Kl.js → markdown-split-Cp6NxQJr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D-LkrsY6.js → media-plugins-Dv1cQK2J.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CqXpNawC.js → messages-Bwu1tG3T.js} +4 -4
- package/dist/gateway/static/root/assets/models-hub-panel-CoYDJvX_.js +2 -0
- package/dist/gateway/static/root/assets/{notes-page-BsoNcBQ3.js → notes-page-CePZ2we1.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-C9B-7EsK.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-C9OfBAT6.js → page-tabs-C1jBfKTZ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BCrigyTS.js → preview-open-alternatives-Cl9anbg0.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DG_P8S7e.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-C1pro-bG.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DDj6t0SQ.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-CnyZMYdJ.js → save-bar-controls-CWu_o1ta.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-Bez97_Ou.js → schedule-field-DuZbqL7X.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DbKY5jSv.js → schema-form-Bixut-2d.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C1aZFTTX.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CwRP1Nsl.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-4f60Dgw-.js → settings-collapsible-section-C_7lCtCp.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CCQ7MjdZ.js → settings-form-section-D0DPTbO0.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CQhjhb0F.js → settings-loading-skeleton-tN-9u8dj.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-C2L9g3kd.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-C7sfPFaM.js → settings-page-layout-CBUOPmx_.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DFjG5i48.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DeErzPeg.js → share-preview-page-BiSh0nLu.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Bh2T05Hp.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-ppRtNzpM.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Dnw1xKKm.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dk1ZhfpM.js → system-settings-panel-h7uqbQ-n.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-Cd_gY2Cb.js → theme-store-DjYRaF0J.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-fe1xAgdw.js → typed-models-lib-BkqBD32C.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-Cbo3s1uh.js → use-channel-catalog-DiWtF12K.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-09T5O8lO.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-C4770AsA.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-D__GQy1R.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CAIgG4im.js +1 -0
- package/dist/gateway/static/root/assets/work-page-CkZvIUpT.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-qqixrSRL.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-THxdPWzb.js +11 -0
- package/dist/gateway/static/root/connector-icons/local-files.svg +6 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +63 -61
- package/dist/src/agent/embedded/xopc-auth-storage.js +1 -1
- package/dist/src/agent/tools/factory.js +2 -2
- package/dist/src/agent/tools/session-search-tool.d.ts +2 -2
- package/dist/src/agent/tools/session-search-tool.js +8 -19
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/config-surface.d.ts +0 -26
- package/dist/src/connectors/builtin-catalog.js +90 -248
- package/dist/src/connectors/composio-catalog.js +28 -1
- package/dist/src/connectors/composio-sessions.js +1 -1
- package/dist/src/connectors/composio.d.ts +1 -0
- package/dist/src/connectors/composio.js +8 -1
- package/dist/src/connectors/connector-memory-sync.d.ts +10 -0
- package/dist/src/connectors/connector-memory-sync.js +184 -38
- package/dist/src/connectors/integration-strategy.js +65 -8
- package/dist/src/connectors/memory-sync-coordinator.d.ts +28 -0
- package/dist/src/connectors/memory-sync-coordinator.js +162 -0
- package/dist/src/connectors/memory-sync-profile.d.ts +13 -0
- package/dist/src/connectors/memory-sync-profile.js +73 -0
- package/dist/src/connectors/runtime-adapter-registry.js +17 -4
- package/dist/src/connectors/runtime-status.d.ts +9 -0
- package/dist/src/connectors/runtime-status.js +68 -0
- package/dist/src/connectors/types.d.ts +2 -0
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +138 -12
- package/dist/src/gateway/hono/routes/public-gateway.js +1 -0
- package/dist/src/gateway/service.d.ts +2 -0
- package/dist/src/gateway/service.js +14 -0
- package/dist/src/knowledge/index.d.ts +2 -0
- package/dist/src/knowledge/index.js +3 -1
- package/dist/src/knowledge/ingestion-service.js +40 -3
- package/dist/src/knowledge/local-folder-adapter.d.ts +7 -0
- package/dist/src/knowledge/local-folder-adapter.js +86 -0
- package/dist/src/knowledge/people-graph.d.ts +28 -0
- package/dist/src/knowledge/people-graph.js +126 -0
- package/dist/src/knowledge/types.d.ts +2 -0
- package/dist/src/user-context/projection.d.ts +2 -0
- package/dist/src/user-context/projection.js +12 -2
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-NDjTqOIb.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-DHvwQknj.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-32U6mfy-.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CTWycuu_.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-DdelF9BQ.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CBgr61Zt.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CO3ASIfE.js +0 -2
- package/dist/gateway/static/root/assets/goal-create-dialog-BRVB5I7f.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Drdz_llY.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-CEh2UTzg.js +0 -2
- package/dist/gateway/static/root/assets/index-DjvInkv6.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Dcmb1Ruc.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-BWdV-HsP.js +0 -7
- package/dist/gateway/static/root/assets/models-hub-panel-Du41WFC6.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-VeU2xG2r.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-B9QsnXWV.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BbplZbzF.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CfbuqKDd.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CSQLpHd4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C25HTTPK.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-BZb-E5vI.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-B1FSxWQ3.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DDg5dL3k.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B-ocgAT-.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CtO4i9ds.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-CqtVqiYz.js +0 -1
- package/dist/gateway/static/root/assets/user-profile-fields-editor-DcnCOHwp.js +0 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-CTWZR6nV.js +0 -1
- package/dist/gateway/static/root/assets/utils-BDzZMJls.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-C9Psto-d.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CNVeagdJ.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DKSNc1SH.js +0 -1
- package/dist/gateway/static/root/assets/work-page-Bwbg1Ht-.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-ZKbrdYmp.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-DBHqpZ76.js +0 -11
- package/dist/gateway/static/root/connector-icons/brave-search.svg +0 -1
- package/dist/gateway/static/root/connector-icons/fetch.svg +0 -6
- package/dist/gateway/static/root/connector-icons/memory.svg +0 -5
- package/dist/gateway/static/root/connector-icons/playwright.svg +0 -9
- package/dist/gateway/static/root/connector-icons/sequential-thinking.svg +0 -8
- package/dist/gateway/static/root/connector-icons/time.svg +0 -6
|
@@ -1 +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{d as i,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-CqXpNawC.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-Dt0pSudQ.js";import{a as m,i as h}from"./vendor-swr-BIWyz7Rc.js";import{$i as g,$s as _,Ac as v,Bo as y,Cs as b,Fo as x,Fs as S,Io as C,Lo as w,Ml as T,No as E,Nt as D,Ps as O,Ro as ee,Uc as te,ac as k,bu as ne,do as A,du as j,fo as M,ho as N,lo as P,mo as F,nu as I,po as L,tc as R,yc as z,ys as B,zo as re,zr as V}from"./index-C4HpPu1y.js";import{t as H}from"./page-tabs-C9OfBAT6.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ie(e){let t=await d(f(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await d(f(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await d(f(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await d(f(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function ae(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function Q({className:e}){let t=c(u(e=>e.language)).extensionsPage,n=l(e=>!!e.token),r=M(),{mutate:i}=m(),[a,s]=(0,U.useReducer)(D,Z),{q:d,debounced:g,detailPkg:_,rowBusy:y,actionError:b,restartHint:x}=a,C=n?`marketplace-${g}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>s({type:`patch`,patch:{debounced:d.trim()}}),300);return()=>window.clearTimeout(e)},[d]);let{data:w,isLoading:T,error:E}=h(C,async()=>p(g.length>0?f(`/api/marketplace?q=${encodeURIComponent(g)}`):f(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,U.useCallback)(()=>{i(`gateway-extensions-list`),V()},[i]),ee=(0,U.useCallback)(async(e,n)=>{s({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});O(),r.requiresGatewayRestart&&s({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw s({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{s({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),ne=(0,U.useCallback)(async e=>{s({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);O(),n.requiresGatewayRestart&&s({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw s({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{s({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),A=w?.extensions??[];return(0,X.jsxs)(`div`,{className:o(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:d,onChange:e=>s({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),E?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E instanceof Error?E.message:t.marketplaceLoadFailed}):null,b?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null,x?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,T&&!w?(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,X.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,X.jsx)(P,{className:`h-5 w-40`}),(0,X.jsx)(P,{className:`h-4 w-full max-w-xl`}),(0,X.jsx)(P,{className:`h-4 w-2/3 max-w-md`})]}),(0,X.jsx)(P,{className:`h-8 w-20`})]})},e))}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:A.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):A.map(e=>{let n=ae(r,e.id),i=y===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>s({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s({type:`patch`,patch:{detailPkg:e.id}}))},className:o(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(I,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(v,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&ne(e.id).catch(()=>{})},className:o(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,X.jsx)(te,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(S,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>s({type:`patch`,patch:{detailPkg:e.id}}),className:o(`inline-flex w-full items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:t.marketplaceReview})})]})},e.id)})}),_?(0,X.jsx)($,{packageName:_,copy:t,extensions:r,onClose:()=>s({type:`patch`,patch:{detailPkg:null}}),onInstall:ee,onUninstall:ne}):null]})}function $(e){let t=(0,W.c)(102),{packageName:n,copy:r,extensions:i,onClose:s,onInstall:c,onUninstall:u}=e,[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),v=l(ue)?`ext-mp-detail-${n}`:null,y;t[0]===n?y=t[1]:(y=async()=>ie(n),t[0]=n,t[1]=y);let C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[2]=C):C=t[2];let{data:T,error:D,isLoading:k}=h(v,y,C),A;t[3]!==i||t[4]!==n?(A=ae(i,n),t[3]=i,t[4]=n,t[5]=A):A=t[5];let j=A,M=j===`user`,N=T?.manifest?.permissions,F,I,L,R,z,B,V,H,G,K,q;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==T||t[29]!==D||t[30]!==j||t[31]!==k||t[32]!==s||t[33]!==N||t[34]!==p){let e=N&&typeof N==`object`&&!Array.isArray(N)?Object.entries(N):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==T?(n=T?.readme?.trim()||(T?.description?.trim()?`### ${T.name}\n\n${T.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=T,t[48]=n):n=t[48];let i=n;L=E,R=!0,t[49]===s?z=t[50]:(z=e=>!e&&s(),t[49]=s,t[50]=z),I=ee,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=q):q=t[51],F=x,H=`fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,G=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(ne,{className:`size-5`}),t[52]=a):a=t[52];let o;t[53]!==r.detailBack||t[54]!==s?(o=(0,X.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:a}),t[53]=r.detailBack,t[54]=s,t[55]=o):o=t[55];let c;t[56]===r.marketplaceDetailTitle?c=t[57]:(c=(0,X.jsx)(re,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=c);let l;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(b,{className:`size-5`}),t[58]=l):l=t[58];let u;t[59]!==r.detailClose||t[60]!==s?(u=(0,X.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:l}),t[59]=r.detailClose,t[60]=s,t[61]=u):u=t[61],t[62]!==o||t[63]!==c||t[64]!==u?(K=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[o,c,u]}),t[62]=o,t[63]=c,t[64]=u,t[65]=K):K=t[65],B=`min-h-0 flex-1 overflow-y-auto p-5`,V=k&&!T?(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,X.jsx)(P,{className:`h-6 w-48`}),(0,X.jsx)(P,{className:`h-4 w-28`}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)(P,{className:`h-12`}),(0,X.jsx)(P,{className:`h-12`})]}),(0,X.jsx)(P,{className:`h-28 w-full`}),(0,X.jsx)(P,{className:`h-36 w-full`})]}):D?(0,X.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,X.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,X.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:D instanceof Error?D.message:r.marketplaceLoadFailed})]}):T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:T.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:T.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:T.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:T.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:T.downloads})]})]}),j===`bundled`?null:(0,X.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[T.installability.available?(0,X.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,X.jsx)(O,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:T.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:T.installability.available?r.marketplaceCodeRisk:T.installability.reason??r.marketplaceUnavailableBody})]})]}),T.installability.available?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,X.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,X.jsx)(`dd`,{children:T.packageSummary?.dependencyCount??0})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,X.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,X.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(T.packageSummary?.lifecycleScripts.length??0)>0?(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,T.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),T.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(g,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=T,t[29]=D,t[30]=j,t[31]=k,t[32]=s,t[33]=N,t[34]=p,t[35]=F,t[36]=I,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=V,t[42]=H,t[43]=G,t[44]=K,t[45]=q}else F=t[35],I=t[36],L=t[37],R=t[38],z=t[39],B=t[40],V=t[41],H=t[42],G=t[43],K=t[44],q=t[45];let J;t[66]!==B||t[67]!==V?(J=(0,X.jsx)(`div`,{className:B,children:V}),t[66]=B,t[67]=V,t[68]=J):J=t[68];let Y;t[69]!==d||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==T||t[78]!==j||t[79]!==s||t[80]!==c||t[81]!==u||t[82]!==n||t[83]!==p||t[84]!==M?(Y=T?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:j===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(a,{to:`/extensions?tab=builtin`,onClick:s,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:d||!T.installability.available||!p,onClick:()=>{M&&!window.confirm(r.marketplaceReinstallConfirm)||(f(!0),c(n,M).catch(se).finally(()=>f(!1)))},className:o(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[d?(0,X.jsx)(te,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,M?r.marketplaceReinstall:r.marketplaceInstall]}),M?(0,X.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(f(!0),u(n).then(()=>s()).catch(oe).finally(()=>f(!1)))},className:o(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(S,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=d,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=T,t[78]=j,t[79]=s,t[80]=c,t[81]=u,t[82]=n,t[83]=p,t[84]=M,t[85]=Y):Y=t[85];let Z;t[86]!==F||t[87]!==J||t[88]!==Y||t[89]!==H||t[90]!==G||t[91]!==K?(Z=(0,X.jsxs)(F,{className:H,onOpenAutoFocus:G,children:[K,J,Y]}),t[86]=F,t[87]=J,t[88]=Y,t[89]=H,t[90]=G,t[91]=K,t[92]=Z):Z=t[92];let Q;t[93]!==I||t[94]!==Z||t[95]!==q?(Q=(0,X.jsxs)(I,{children:[q,Z]}),t[93]=I,t[94]=Z,t[95]=q,t[96]=Q):Q=t[96];let $;return t[97]!==L||t[98]!==R||t[99]!==z||t[100]!==Q?($=(0,X.jsx)(L,{defaultOpen:R,onOpenChange:z,children:Q}),t[97]=L,t[98]=R,t[99]=z,t[100]=Q,t[101]=$):$=t[101],$}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,X.jsxs)(`li`,{className:`break-words`,children:[(0,X.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=u(e=>e.language),t=c(e),n=y(e=>e.setPageHeader),r=y(e=>e.clearPageHeader),o=M(),s=L(),[l,d]=i(),f=G(l.get(`tab`)),p=l.get(`q`)??``,[m,h]=(0,U.useState)(f),[g,_]=(0,U.useState)(p),[v,b]=(0,U.useState)(null),x=l.toString(),S=(0,U.useRef)(x);if(S.current!==x){S.current=x;let e=G(l.get(`tab`)),t=l.get(`q`)??``;h(t=>t===e?t:e),_(e=>e===t?e:t)}(0,U.useEffect)(()=>{d(e=>{let t=new URLSearchParams(e),n=g.trim();return n?t.set(`q`,n):t.delete(`q`),m===`marketplace`?t.delete(`tab`):t.set(`tab`,m),t.toString()===e.toString()?e:t},{replace:!0})},[m,g,d]);let C=(0,U.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),w=(0,U.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=m===`builtin`?C:w,E=(0,U.useMemo)(()=>{let t=g.trim().toLowerCase(),n=T;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[T,g,e]);if((0,U.useEffect)(()=>{b(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(B,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,X.jsx)(j,{className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,X.jsx)(B,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,X.jsxs)(a,{to:`/local-apps/new`,children:[(0,X.jsx)(z,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&m!==`marketplace`)return(0,X.jsx)(ye,{});let D=m!==`marketplace`&&T.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(H,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:C.length},{id:`user`,label:t.extensionsPage.tabUser,count:w.length}],activeTab:m,onChange:h,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),D?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:g,onChange:e=>_(e.target.value),placeholder:t.extensionsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),m===`marketplace`?(0,X.jsx)(Q,{}):m===`builtin`&&C.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):m===`user`&&w.length===0?(0,X.jsx)(xe,{message:t.extensionsPage.emptyUser}):E.length===0?(0,X.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,X.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:m===`user`,onOpen:()=>b(e)},e.id))})]}),v?(0,X.jsx)(_e,{extension:v,copy:t.extensionsPage,onClose:()=>b(null)},v.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,c;t[0]===n?c=t[1]:(c=fe(n),t[0]=n,t[1]=c);let l=c,u=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=d):d=t[2];let f=n.name||n.id,p;t[3]===f?p=t[4]:(p=f.charAt(0).toUpperCase(),t[3]=f,t[4]=p);let m;t[5]===p?m=t[6]:(m=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:p}),t[5]=p,t[6]=m);let h;t[7]===n.name?h=t[8]:(h=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=h);let g;t[9]===n.version?g=t[10]:(g=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=g);let _;t[11]!==h||t[12]!==g?(_=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[h,g]}),t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==r.statusEnabled||t[15]!==l?(v=l?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(s,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(z,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=l,t[16]=v):v=t[16];let y;t[17]!==_||t[18]!==v?(y=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[_,v]}),t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==u?(C=(0,X.jsx)(`span`,{title:u,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=u,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,X.jsx)(`span`,{title:pe(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=w):w=t[31];let T;t[32]!==C||t[33]!==w?(T=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==y||t[36]!==x||t[37]!==T?(E=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,T]}),t[35]=y,t[36]=x,t[37]=T,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==m?(D=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[m,E]}),t[39]=E,t[40]=m,t[41]=D):D=t[41];let O;return t[42]!==a||t[43]!==D?(O=(0,X.jsx)(`button`,{type:`button`,onClick:a,className:d,children:D}),t[42]=a,t[43]=D,t[44]=O):O=t[44],O}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=m(),[i,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),f=e.activationEligible===!0,p=(0,U.useCallback)(async()=>{if(e.source===`bundled`){l(null),d(!1),s(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),V(),d(t)}catch(e){l(e instanceof Error?e.message:t.builtinToggleFailed)}finally{s(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),h=e.ui?.contributions?.pages??[],g=e.ui?.contributions?.settingsPanels??[],_=e.ui?.contributions?.chatWidgets??[],v=e.ui?.contributions?.sidebarPanels??[],y=h.find(e=>e.showInNav)??h[0],S=g[0],D=y?A(e.id,y):null,O=S?`/settings/ext/${e.id}/${S.id}`:e.hasConfigSchema||F(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(E,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(ee,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(ne,{className:`size-5`})}),(0,X.jsx)(re,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(C,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(b,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(B,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void p(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(te,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),c?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:c}):null,u?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(h.length>0||g.length>0||_.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)(ve,{template:t.badgePages,count:h.length,hidden:h.length===0}),(0,X.jsx)(ve,{template:t.badgeSettings,count:g.length,hidden:g.length===0}),(0,X.jsx)(ve,{template:t.badgeWidgets,count:_.length,hidden:_.length===0}),(0,X.jsx)(ve,{template:t.badgeSidebar,count:v.length,hidden:v.length===0})]})]}):null,N(e)&&(D||O)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[D?(0,X.jsxs)(a,{to:D,onClick:n,className:o(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(T,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,O?(0,X.jsxs)(a,{to:O,onClick:n,className:o(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(R,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function ye(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};
|
|
@@ -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{d as i,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./circle-alert-RzVebuX2.js";import{t as c}from"./messages-CqXpNawC.js";import{n as l}from"./locale-store-Dt0pSudQ.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$i as d,$s as f,Bc as p,Bo as m,Cs as h,Dc as g,Di as _,Ei as v,Fo as y,Fs as b,Gc as x,Ho as S,Lo as C,Ml as w,No as T,Oi as E,Po as D,Ro as O,Ss as k,Tc as ee,Tu as te,Vr as A,Yo as j,Ys as ne,Zo as M,ao as re,au as ie,da as ae,fc as N,ji as oe,ki as se,lo as P,ou as ce,ru as le,tu as ue,vl as de,x as F,xc as I,yc as fe,ys as L,yt as pe,zo as me}from"./index-C4HpPu1y.js";import{t as R}from"./format-cron-label-arqgGlVV.js";import{a as he,i as ge,n as z,r as B,t as _e}from"./workflow-run-setup-panel-ZKbrdYmp.js";var V=e(t(),1),H=n(),U=1e3,W=60*U,G=60*W,ve=24*G,ye=7*ve,be=new Intl.ListFormat(`en-US`,{type:`conjunction`}),K=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),xe={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`})},Se={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ce={minute:W,hour:G,day:ve,week:ye};function q(e){return e===`zh`?`zh-CN`:`en-US`}function we(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:K[String(t)].format(e)}function Te(e,t){return t===`zh`?e.join(` `):be.format(e)}function Ee(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(W,Math.round((Number.isFinite(n)&&n>0?n:1)*Ce[t]))}function De(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*Ce[t]/Ce[n]).toFixed(6)))}function Oe(e,t){let n=Math.max(U,Math.round(e)),r=n===ve?[{unit:`hour`,ms:G}]:n>=ye&&n%ye===0?[{unit:`week`,ms:ye}]:n>=ve?[{unit:`day`,ms:ve},{unit:`hour`,ms:G},{unit:`minute`,ms:W},{unit:`second`,ms:U}]:n>=G?[{unit:`hour`,ms:G},{unit:`minute`,ms:W},{unit:`second`,ms:U}]:n>=W?[{unit:`minute`,ms:W},{unit:`second`,ms:U}]:[{unit:`second`,ms:U}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(we(r,e,t)),i%=n)}return Te(a,t)}function ke(e,t){let n=Oe(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ae(e,t){return xe[t].format(new Date(e))}function je(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function J(e,t,n=Date.now()){let r=new Date(e),i=Math.round((je(r)-je(new Date(n)))/ve),a=Se[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}`:Ae(e,t)}function Me(e,t){return e.eventType===`goal.status_changed`&&e.payloadMatch?.status===`blocked`?t.trigger.goalBlockedWhen: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 Ne(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 Me(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,J(Date.parse(i.at),r)):i.kind===`interval`?ke(i.everyMs,r):R(i.expr,q(r),n.scheduleBadge,{timezone:i.tz})}function Y(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?J(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 Pe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=J(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var X={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,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Fe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Ie(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===`goalBlocked`)o={kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`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:Ee(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=B(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.safetyMode===`auto_apply`?e.afterRunMode:`none`,u=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)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:u,safety:{mode:e.safetyMode},afterRun:l===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:l},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function Le(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:X.time,weekday:X.weekday,cronExpr:e}}function Re(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 ze(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 Be(e){let t=e.payloadMatch;return e.eventType===`goal.status_changed`&&e.source===`goals`&&t?.status===`blocked`?{triggerMode:`goalBlocked`}: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 Ve(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function He(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 Ue(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=Be(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=Le(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...Re(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:ze(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?Ve(r.input):{},o=e.afterRun??{kind:`none`},s=r.timeoutSeconds??e.reliability?.timeoutSeconds??300;return{...X,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?z(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 We(e,t,n){let r=Ie(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}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function Ge(e,t,n){return e?Ae(e,n):t.never}function Ke(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function qe(e){return e.safety?.mode??`auto_apply`}function Je(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`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function Ye(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 Xe(e){return e.status===`running`||e.status===`queued`}function Ze(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function Qe(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function $e(e){return!!Qe(e)}function et(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function tt(e){return Xe(e)?0:Ze(e)?1:e.status===`succeeded`?2:3}function nt(e){return[...e].sort((e,t)=>{let n=tt(e)-tt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function rt(e){let t=(0,H.c)(5),n;t[0]===e?n=t[1]:(n=()=>typeof window>`u`?!1:window.matchMedia(e).matches,t[0]=e,t[1]=n);let[r,i]=(0,V.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),n=()=>i(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,V.useEffect)(a,o),r}function it(){let e=(0,H.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)(P,{className:`h-4 w-36`}),(0,Z.jsx)(P,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(P,{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(at)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(P,{className:`h-4 w-32`}),i=(0,Z.jsx)(P,{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)(P,{className:`h-12 rounded-lg`}),(0,Z.jsx)(P,{className:`h-12 rounded-lg`}),(0,Z.jsx)(P,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function at(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)(P,{className:`size-4 rounded-full`}),(0,Z.jsx)(P,{className:`h-4 w-32`}),(0,Z.jsx)(P,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(P,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(P,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(P,{className:`h-8 w-24 rounded-md`})]})},t)}function ot(){let e=l(e=>e.language),t=c(e),n=t.automations,r=t.cron,a=m(e=>e.setPageHeader),s=m(e=>e.clearPageHeader),[d,f]=i(),p=d.get(`run`)?.trim()??``,g=d.get(`automation`)?.trim()??``,b=d.get(`draft`)?.trim()??``,x=d.get(`action`)?.trim()??``,w=d.get(`projectId`)?.trim()??``,k=d.get(`autogenerate`)===`1`,ee=d.get(`insight`)?.trim()??``,te=(0,V.useRef)(``),A=rt(`(min-width: 1280px)`),[j,ne]=(0,V.useState)(`activity`),[M,ie]=(0,V.useState)(!1),[N,P]=(0,V.useState)(`blank`),[ce,le]=(0,V.useState)(null),[ue,de]=(0,V.useState)(!1),[I,R]=(0,V.useState)(X),[he,z]=(0,V.useState)(null),[B,_e]=(0,V.useState)(null),[H,U]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[ve,ye]=(0,V.useState)(``),[be,K]=(0,V.useState)(null),[xe,Se]=(0,V.useState)(!1),[Ce,q]=(0,V.useState)(!1),[we,Te]=(0,V.useState)(null),[Ee,De]=(0,V.useState)(!1),[Oe,ke]=(0,V.useState)(!1),[Ae,je]=(0,V.useState)(!1),[J,Me]=(0,V.useState)(null),Ne=u([`automations`,w],()=>F.list(w?{projectId:w}:void 0),{refreshInterval:15e3}),Y=u([`automation-runs`,w],()=>F.runs(50,void 0,w?{projectId:w}:void 0),{refreshInterval:1e4}),Pe=u(`automation-metrics`,()=>F.metrics(),{refreshInterval:15e3}),Fe=u(B?`automation-run-events:${B}`:null,()=>F.runEvents(B),{refreshInterval:5e3}),Le=u(`automation-workflow-definitions`,pe),Re=u(`automation-chat-agents`,re),ze=Ne.isLoading&&!Ne.data||Y.isLoading&&!Y.data||Pe.isLoading&&!Pe.data,Be=Ne.data?.automations??[],Ve=(0,V.useMemo)(()=>nt(Y.data?.runs??[]),[Y.data?.runs]),Ke=(0,V.useMemo)(()=>Be.filter(e=>!$e(e)),[Be]),qe=(0,V.useMemo)(()=>Be.filter($e),[Be]),Je=(0,V.useMemo)(()=>new Set(qe.map(e=>e.id)),[qe]),Ye=(0,V.useMemo)(()=>Ve.filter(e=>!Je.has(e.automationId)),[Ve,Je]),Xe=(0,V.useMemo)(()=>{let e;for(let t of Ke){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[Ke]),Qe=(0,V.useMemo)(()=>Ve.find(e=>e.id===B)??null,[Ve,B]),et=(0,V.useMemo)(()=>Be.find(e=>e.id===W)??null,[Be,W]),tt=(0,V.useMemo)(()=>Be.find(e=>e.id===ce)??null,[Be,ce]),at=(0,V.useMemo)(()=>Ve.filter(e=>e.automationId===W),[Ve,W]),ot=Fe.data?.events??[],lt=(0,V.useMemo)(()=>Ye.filter(Ze),[Ye]),ut=Ye[0]??null,pt=(0,V.useMemo)(()=>Le.data??[],[Le.data]),mt=Re.data?.items??[],ht=(0,V.useMemo)(()=>pt.find(e=>e.id===I.workflowId.trim())??null,[I.workflowId,pt]),vt=I.actionMode===`workflow`&&(!I.workflowId.trim()||pt.length>0&&!pt.some(e=>e.id===I.workflowId)),yt=I.actionMode===`workflow`&&ht?!ge(ht,I.workflowInput,I.workflowInputValid).valid:!1,bt=!!I.name.trim()&&(I.triggerMode!==`once`||Number.isFinite(new Date(I.onceAt).getTime()))&&(I.triggerMode!==`event`||!!I.eventType.trim()&&He(I.eventPayloadMatch))&&(I.actionMode===`workflow`?!vt&&!yt:!!I.instruction.trim())&&(I.afterRunMode!==`webhook`||!!I.webhookUrl.trim()),xt=(0,V.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...X,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...X,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:pt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...X,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...X,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...X,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,pt]);(0,V.useEffect)(()=>{j!==`activity`||Ye.length===0||B&&Ye.some(e=>e.id===B)||_e(Ye[0].id)},[B,Ye,j]);let St=(0,V.useCallback)(async()=>{await Promise.all([Ne.mutate(),Y.mutate(),Pe.mutate(),Fe.mutate()])},[Ne.mutate,Pe.mutate,Fe.mutate,Y.mutate]),Ct=(0,V.useCallback)(e=>{le(null),de(!1),P(e),ie(!0),e===`blank`&&R(X)},[]),wt=(0,V.useCallback)(e=>{R(Ue(e,pt)),le(e.id),de(!1),G(null),P(`blank`),ie(!0)},[pt]),Tt=(0,V.useCallback)(()=>{be&&(R(Ue(be.automation,pt)),le(null),de(!0),P(`blank`))},[be,pt]),Dt=(0,V.useCallback)(async()=>{je(!0),z(null);try{await St()}catch(e){let t=e instanceof Error?e.message:String(e);z(t),S({type:`error`,title:n.feedback.actionFailed,message:t})}finally{je(!1)}},[n.feedback.actionFailed,St]);(0,V.useEffect)(()=>{p&&(ne(`activity`),_e(p),A||U(!0))},[p,A]),(0,V.useEffect)(()=>{if(!g)return;let e=Be.find(e=>e.id===g);e&&(ne($e(e)?`system`:`automations`),G(e.id),f(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[g,Be,f]),(0,V.useEffect)(()=>{A&&U(!1)},[A]),(0,V.useEffect)(()=>{x===`create`&&(Ct(`blank`),f(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[x,Ct,f]),(0,V.useEffect)(()=>{if(!b)return;let t=`${e}:${k?`auto`:`seed`}:${b}`;te.current!==t&&(te.current=t,ye(b),K(null),q(!1),P(`draft`),ie(!0),f(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t.delete(`insight`),t},{replace:!0}),k&&(z(null),Se(!0),F.draft({prompt:b,language:e}).then(e=>{K(e.draft),q(!1),ee&&F.completeInsightDraft(ee)}).catch(e=>{z(e instanceof Error?e.message:String(e))}).finally(()=>{Se(!1)})))},[k,b,ee,e,f]);let Q=(0,V.useCallback)(e=>{_e(e),A||U(!0),f(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[f,A]);(0,V.useEffect)(()=>{Te(null),ke(!1)},[B]);async function $(){if(z(null),bt){if(ue&&be){Me(`draft:edit`);try{let e=Ie(I,ht),{simulation:t}=await F.simulate(e);K({...be,automation:e,simulation:t}),q(!1),de(!1),P(`draft`)}catch(e){let t=e instanceof Error?e.message:String(e);z(t),S({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Me(null)}return}if(tt){let e=tt.id;await Ot(`automation:${e}:edit`,()=>F.update(e,We(tt,I,ht)))&&(ie(!1),le(null),G(e));return}try{await F.create({...Ie(I,ht),...w?{projectId:w}:{}}),R(X),ie(!1),await St()}catch(e){let t=e instanceof Error?e.message:String(e);z(t),S({type:`error`,title:n.feedback.actionFailed,message:t})}}}async function Ot(e,t){z(null),Me(e);try{return await t(),await St(),!0}catch(e){let t=e instanceof Error?e.message:String(e);return z(t),S({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{Me(null)}}async function kt(){let t=ve.trim();if(t){z(null),Se(!0);try{K((await F.draft({prompt:t,language:e})).draft),q(!1)}catch(e){z(e instanceof Error?e.message:String(e))}finally{Se(!1)}}}async function At(){be&&await Ot(`draft:publish`,async()=>{await F.create({...be.automation,...w?{projectId:w}:{}}),K(null),ye(``),q(!1),ie(!1)})}async function jt(t){z(null),De(!0),Te(null),ke(!1);try{Te((await F.repairDraft(t.id,{language:e})).repair)}catch(e){z(e instanceof Error?e.message:String(e))}finally{De(!1)}}async function Mt(e){we&&await Ot(`run:${e.id}:repair`,async()=>{await F.update(e.automationId,we.patch),Te(null),ke(!1)})}let Nt=(0,V.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`size-9 shrink-0 p-0`,loading:Ae,label:n.refresh,onClick:Dt}),(0,Z.jsxs)(se,{children:[(0,Z.jsx)(oe,{asChild:!0,children:(0,Z.jsxs)(L,{variant:`primary`,children:[(0,Z.jsx)(fe,{className:`size-4`}),n.new]})}),(0,Z.jsx)(E,{children:(0,Z.jsxs)(v,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsx)(_,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`draft`),children:n.createMenu.draft}),(0,Z.jsx)(_,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`template`),children:n.createMenu.template}),(0,Z.jsx)(_,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,Ct,Ae,Dt]);return(0,V.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:Nt}),()=>s()),[s,Nt,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-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,Z.jsx)(st,{label:n.dashboard.needsAttention,value:lt.length,tone:lt.length>0?`danger`:`neutral`}),(0,Z.jsx)(st,{label:n.metrics.running,value:Ye.filter(e=>e.status===`running`).length}),(0,Z.jsx)(st,{label:n.dashboard.latestResult,value:ut?n.status[ut.status]:n.none,tone:ut&&Ze(ut)?`danger`:`neutral`}),(0,Z.jsx)(st,{label:n.metrics.next,value:Xe?Ge(Xe,n,e):n.none})]}),(0,Z.jsx)(`nav`,{className:`inline-flex w-fit rounded-lg border border-edge bg-surface-panel p-1`,children:[{id:`activity`,label:n.dashboard.activity,count:Ye.length},{id:`automations`,label:n.dashboard.manage,count:Ke.length},{id:`system`,label:n.system.title,count:qe.length}].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,j===e.id&&`bg-surface-hover text-fg`),onClick:()=>{ne(e.id),e.id!==`activity`&&U(!1)},children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{className:`rounded-full border border-edge/70 px-1.5 py-0.5 text-[0.6875rem] leading-none text-fg-muted`,children:e.count})]},e.id))}),he?(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:he}):null,ze?(0,Z.jsx)(it,{}):j===`activity`?(0,Z.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(18rem,22rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(ft,{runs:Ye.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:B,busyAction:J,className:`h-auto`,onSelectRun:Q,onAction:Ot})}),(0,Z.jsx)(gt,{className:`hidden xl:sticky xl:top-4 xl:block`,run:Qe,events:ot,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:we,repairLoading:Ee,repairApproved:Oe,busyAction:J,onRepairApprovedChange:ke,onSuggestRepair:jt,onApplyRepair:Mt})]}):j===`automations`?(0,Z.jsx)(`section`,{children:(0,Z.jsx)(dt,{automations:Ke,runs:Ye,labels:n,cronLabels:r,language:e,busyAction:J,onOpenDetails:G,onAction:Ot})}):(0,Z.jsx)(`section`,{children:(0,Z.jsx)(dt,{automations:qe,runs:Ve,labels:n,cronLabels:r,language:e,busyAction:J,readOnly:!0,onOpenDetails:G,onAction:Ot})})]}),(0,Z.jsx)(T,{open:M,onOpenChange:e=>{ie(e),e||(le(null),de(!1))},children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(y,{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)(me,{className:`text-base font-semibold text-fg`,children:N===`draft`?n.draft.title:N===`template`?n.createMenu.templatesTitle:tt?n.editTitle:ue?n.draft.editTitle:n.createTitle}),(0,Z.jsx)(D,{asChild:!0,children:(0,Z.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(h,{className:`size-4`})})})]}),N===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(ct,{labels:n,prompt:ve,draft:be,loading:xe,approved:Ce,publishBusy:J===`draft:publish`,onPromptChange:ye,onGenerate:kt,onEdit:Tt,onPublish:At,onApprovedChange:q,onDiscard:()=>{K(null),q(!1)}})}):N===`template`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:xt.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{R(e.form),P(`blank`)},children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Et,{form:I,labels:n,setForm:R,workflowDefinitions:pt,selectedWorkflow:ht,workflowsLoading:Le.isLoading,agentOptions:mt,agentsLoading:Re.isLoading,language:e}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[ue?(0,Z.jsx)(L,{variant:`ghost`,onClick:()=>{de(!1),P(`draft`)},children:n.cancel}):(0,Z.jsx)(D,{asChild:!0,children:(0,Z.jsx)(L,{variant:`ghost`,children:n.cancel})}),(0,Z.jsx)(L,{variant:`primary`,onClick:$,disabled:!bt||J===`draft:edit`||!!(tt&&J),children:J===`draft:edit`||tt&&J===`automation:${tt.id}:edit`?n.feedback.working:tt||ue?n.save:n.create})]})]})]})]})}),(0,Z.jsx)(_t,{automation:et,runs:at,labels:n,cronLabels:r,language:e,busyAction:J,onClose:()=>G(null),onSelectRun:e=>{Q(e),G(null)},onEdit:wt,onAction:Ot}),(0,Z.jsx)(T,{open:!A&&H&&!!Qe,onOpenChange:U,children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(y,{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)(me,{className:`truncate text-base font-semibold text-fg`,children:Qe?.automationName??n.dashboard.result}),(0,Z.jsx)(D,{asChild:!0,children:(0,Z.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(h,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(gt,{className:`rounded-none border-0`,run:Qe,events:ot,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:we,repairLoading:Ee,repairApproved:Oe,busyAction:J,onRepairApprovedChange:ke,onSuggestRepair:jt,onApplyRepair:Mt})})]})]})})]})}function st(e){let t=(0,H.c)(13),{label:n,value:r,tone:i}=e,a=i===void 0?`neutral`:i,s=a===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=o(`rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=a===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=o(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,Z.jsx)(`div`,{className:d,children:r}),t[6]=d,t[7]=r,t[8]=f):f=t[8];let p;return t[9]!==c||t[10]!==l||t[11]!==f?(p=(0,Z.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function ct(e){let t=(0,H.c)(49),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onEdit:u,onPublish:d,onApprovedChange:f,onDiscard:p}=e,m=s===void 0?!1:s,h=!!(i&&i.simulation.requiredConfirmations.length>0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(ne,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[g,n.draft.title]}),t[1]=n.draft.title,t[2]=_);let v;t[3]===n.draft.subtitle?v=t[4]:(v=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=v);let y;t[5]!==_||t[6]!==v?(y=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[5]=_,t[6]=v,t[7]=y):y=t[7];let b;t[8]!==a||t[9]!==r?(b=a||!r.trim(),t[8]=a,t[9]=r,t[10]=b):b=t[10];let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(ne,{className:`size-4`}),t[11]=x):x=t[11];let S=a?n.draft.generating:n.draft.generate,C;t[12]!==l||t[13]!==b||t[14]!==S?(C=(0,Z.jsxs)(L,{variant:`primary`,onClick:l,disabled:b,children:[x,S]}),t[12]=l,t[13]=b,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==y||t[17]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[y,C]}),t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=e=>c(e.target.value),t[19]=c,t[20]=T);let E;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==T?(E=(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:T,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=T,t[24]=E):E=t[24];let D;t[25]!==o||t[26]!==i||t[27]!==n.draft.approval||t[28]!==n.draft.assumptions||t[29]!==n.draft.discard||t[30]!==n.draft.edit||t[31]!==n.draft.publish||t[32]!==n.draft.review||t[33]!==n.draft.risks||t[34]!==n.draft.safety||t[35]!==n.feedback||t[36]!==n.info||t[37]!==n.none||t[38]!==f||t[39]!==p||t[40]!==u||t[41]!==d||t[42]!==m||t[43]!==h?(D=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)(wt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(wt,{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)(lt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(lt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(lt,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(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=>f(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)(L,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,Z.jsxs)(L,{variant:`secondary`,onClick:u,children:[(0,Z.jsx)(ee,{className:`size-4`}),n.draft.edit]}),(0,Z.jsx)(L,{variant:`primary`,onClick:d,disabled:m||h&&!o,children:m?n.feedback.working:n.draft.publish})]})]})]}):null,t[25]=o,t[26]=i,t[27]=n.draft.approval,t[28]=n.draft.assumptions,t[29]=n.draft.discard,t[30]=n.draft.edit,t[31]=n.draft.publish,t[32]=n.draft.review,t[33]=n.draft.risks,t[34]=n.draft.safety,t[35]=n.feedback,t[36]=n.info,t[37]=n.none,t[38]=f,t[39]=p,t[40]=u,t[41]=d,t[42]=m,t[43]=h,t[44]=D):D=t[44];let O;return t[45]!==w||t[46]!==E||t[47]!==D?(O=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[45]=w,t[46]=E,t[47]=D,t[48]=O):O=t[48],O}function lt(e){let t=(0,H.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(ut):(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 ut(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function dt(e){let t=(0,H.c)(24),{automations:n,runs:r,labels:i,cronLabels:a,language:s,busyAction:c,readOnly:l,onOpenDetails:u,onAction:d}=e,f=l===void 0?!1:l;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.automations?n=t[2]:(n=(0,Z.jsx)(Tt,{icon:e,title:i.empty.automations}),t[1]=i.empty.automations,t[2]=n),n}let p;if(t[3]!==n||t[4]!==c||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==r){let e;t[13]!==c||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==f||t[20]!==r?(e=e=>{let t=et(e),n=r.filter(t=>t.automationId===e.id),l=n.find(Xe),p=n[0],m=c===`automation:${e.id}:run`,h=c===`automation:${e.id}:toggle`,_=c===`automation:${e.id}:delete`;return(0,Z.jsxs)(`article`,{className:`flex min-h-44 cursor-pointer flex-col rounded-lg border border-edge-subtle bg-surface-base p-3.5 shadow-surface outline-none transition-colors hover:bg-surface-hover`,role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),l?(0,Z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?i.enabled:i.paused})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:i.info.when}),(0,Z.jsx)(`span`,{className:`truncate`,children:Ne(e.trigger,i,a,s)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:i.info.run}),(0,Z.jsx)(`span`,{className:`truncate`,children:Ke(e.action,i)})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`span`,{children:[i.last,`: `,Ge(e.state.lastRunAtMs,i,s)]}),(0,Z.jsxs)(`span`,{children:[i.next,`: `,Ge(e.state.nextRunAtMs,i,s)]}),(0,Z.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5`,Je(e.state.lastRunStatus)),children:e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.status.notRun}),p?.error?(0,Z.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:p.error}):null]}),f?null:(0,Z.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>F.runNow(e.id),i.feedback.rerunQueued)},children:(0,Z.jsx)(I,{className:o(`size-4`,m&&`animate-pulse`)})}),(0,Z.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?i.dashboard.pause:i.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?F.pause(e.id):F.resume(e.id),e.enabled?i.feedback.paused:i.dashboard.resumed)},children:h?(0,Z.jsx)(N,{className:`size-4 animate-spin`}):e.enabled?(0,Z.jsx)(g,{className:`size-4`}):(0,Z.jsx)(I,{className:`size-4`})}),(0,Z.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>F.remove(e.id),i.dashboard.deleted)},children:_?(0,Z.jsx)(N,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=a,t[15]=i,t[16]=s,t[17]=d,t[18]=u,t[19]=f,t[20]=r,t[21]=e):e=t[21],p=n.map(e),t[3]=n,t[4]=c,t[5]=a,t[6]=i,t[7]=s,t[8]=d,t[9]=u,t[10]=f,t[11]=r,t[12]=p}else p=t[12];let m;return t[22]===p?m=t[23]:(m=(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:p}),t[22]=p,t[23]=m),m}function ft(e){let t=(0,H.c)(25),{runs:n,labels:r,cronLabels:i,language:a,selectedRunId:s,busyAction:c,className:l,onSelectRun:u,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(te,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,Z.jsx)(Tt,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let f;t[3]===l?f=t[4]:(f=o(`overflow-hidden rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,l),t[3]=l,t[4]=f);let p;if(t[5]!==c||t[6]!==i||t[7]!==r||t[8]!==a||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==i||t[16]!==r||t[17]!==a||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,Z.jsxs)(`div`,{className:o(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,s===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,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`,Je(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,Z.jsx)(`div`,{className:o(`mt-1 line-clamp-2 whitespace-pre-line text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(Xe(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[Ge(e.createdAtMs,r,a),` · `,e.manual?r.trigger.manual:Ne(e.triggerSnapshot,r,i,a)]})]}),e.status===`running`||e.status===`queued`?(0,Z.jsx)(L,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>F.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=i,t[16]=r,t[17]=a,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],p=n.map(e),t[5]=c,t[6]=i,t[7]=r,t[8]=a,t[9]=d,t[10]=u,t[11]=n,t[12]=s,t[13]=p}else p=t[13];let m;return t[22]!==f||t[23]!==p?(m=(0,Z.jsx)(`div`,{className:f,children:p}),t[22]=f,t[23]=p,t[24]=m):m=t[24],m}function pt(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 mt(e){let t=(0,H.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[s,c]=(0,V.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(ht),"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)(ie,{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 ht(e){return!e}function gt(e){let t=(0,H.c)(148),{className:n,run:r,events:i,labels:c,cronLabels:l,language:u,loading:f,repairDraft:m,repairLoading:h,repairApproved:g,busyAction:_,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)(te,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===c.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:c.selectRun}),t[3]=c.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 S=r.error||r.summary,C=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,w=r.sessionKey?c.runDetail.openConversation:c.runDetail.openWorkflow,T=r.sessionKey?p:de,E=Xe(r)?te:Ze(r)?s:ue,D;t[8]===n?D=t[9]:(D=o(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=D);let O;t[10]===r.automationName?O=t[11]:(O=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=O);let k;t[12]===r.id?k=t[13]:(k=r.id.slice(0,8),t[12]=r.id,t[13]=k);let ee;t[14]===k?ee=t[15]:(ee=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:k}),t[14]=k,t[15]=ee);let A;t[16]!==O||t[17]!==ee?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,ee]}),t[16]=O,t[17]=ee,t[18]=A):A=t[18];let j;t[19]===r.status?j=t[20]:(j=o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,Je(r.status)),t[19]=r.status,t[20]=j);let M=c.status[r.status],re;t[21]!==j||t[22]!==M?(re=(0,Z.jsx)(`span`,{className:j,children:M}),t[21]=j,t[22]=M,t[23]=re):re=t[23];let ae;t[24]!==A||t[25]!==re?(ae=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,re]}),t[24]=A,t[25]=re,t[26]=ae):ae=t[26];let N;t[27]!==c||t[28]!==u||t[29]!==r.createdAtMs?(N=Ge(r.createdAtMs,c,u),t[27]=c,t[28]=u,t[29]=r.createdAtMs,t[30]=N):N=t[30];let oe;t[31]===N?oe=t[32]:(oe=(0,Z.jsx)(`span`,{children:N}),t[31]=N,t[32]=oe);let se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=se):se=t[33];let ce=c.details.duration,F;t[34]!==c||t[35]!==r.durationMs?(F=Ye(r.durationMs,c),t[34]=c,t[35]=r.durationMs,t[36]=F):F=t[36];let I;t[37]!==c.details.duration||t[38]!==F?(I=(0,Z.jsxs)(`span`,{children:[ce,` `,F]}),t[37]=c.details.duration,t[38]=F,t[39]=I):I=t[39];let fe;t[40]!==oe||t[41]!==I?(fe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[oe,se,I]}),t[40]=oe,t[41]=I,t[42]=fe):fe=t[42];let pe;t[43]!==c.repair||t[44]!==y||t[45]!==h||t[46]!==r?(pe=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(L,{variant:`secondary`,onClick:()=>y(r),disabled:h,children:[(0,Z.jsx)(ne,{className:`size-4`}),h?c.repair.generating:c.repair.suggest]})}):null,t[43]=c.repair,t[44]=y,t[45]=h,t[46]=r,t[47]=pe):pe=t[47];let me;t[48]!==fe||t[49]!==pe||t[50]!==ae?(me=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[ae,fe,pe]}),t[48]=fe,t[49]=pe,t[50]=ae,t[51]=me):me=t[51];let R;t[52]===r?R=t[53]:(R=Xe(r)?`text-blue-500`:Ze(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=R);let he;t[54]===R?he=t[55]:(he=o(`size-4`,R),t[54]=R,t[55]=he);let ge;t[56]!==E||t[57]!==he?(ge=(0,Z.jsx)(E,{className:he}),t[56]=E,t[57]=he,t[58]=ge):ge=t[58];let z;t[59]!==c.runDetail.resultTitle||t[60]!==ge?(z=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[ge,c.runDetail.resultTitle]}),t[59]=c.runDetail.resultTitle,t[60]=ge,t[61]=z):z=t[61];let B;t[62]!==T||t[63]!==w||t[64]!==C?(B=C?(0,Z.jsx)(L,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:C,children:[(0,Z.jsx)(T,{className:`size-3.5`}),w,(0,Z.jsx)(le,{className:`size-3.5`})]})}):null,t[62]=T,t[63]=w,t[64]=C,t[65]=B):B=t[65];let _e;t[66]!==z||t[67]!==B?(_e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[z,B]}),t[66]=z,t[67]=B,t[68]=_e):_e=t[68];let V=r.error&&`border-red-500/25 bg-red-500/5`,U;t[69]===V?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`,V),t[69]=V,t[70]=U);let W;t[71]!==c.runDetail.noResult||t[72]!==c.runDetail.resultPending||t[73]!==S||t[74]!==r?(W=S?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:S}):(0,Z.jsx)(d,{content:S,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:Xe(r)?c.runDetail.resultPending:c.runDetail.noResult}),t[71]=c.runDetail.noResult,t[72]=c.runDetail.resultPending,t[73]=S,t[74]=r,t[75]=W):W=t[75];let G;t[76]!==U||t[77]!==W?(G=(0,Z.jsx)(`div`,{className:U,children:W}),t[76]=U,t[77]=W,t[78]=G):G=t[78];let ve;t[79]!==_e||t[80]!==G?(ve=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[_e,G]}),t[79]=_e,t[80]=G,t[81]=ve):ve=t[81];let ye;t[82]===c.runDetail.runInfo?ye=t[83]:(ye=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:c.runDetail.runInfo}),t[82]=c.runDetail.runInfo,t[83]=ye);let be;t[84]!==l||t[85]!==c||t[86]!==u||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(be=r.manual?c.trigger.manual:Ne(r.triggerSnapshot,c,l,u),t[84]=l,t[85]=c,t[86]=u,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=be):be=t[89];let K;t[90]!==c.explain.whyRan||t[91]!==be?(K=(0,Z.jsx)(St,{label:c.explain.whyRan,value:be}),t[90]=c.explain.whyRan,t[91]=be,t[92]=K):K=t[92];let xe=c.details.started,Se;t[93]!==c||t[94]!==u||t[95]!==r.startedAtMs?(Se=Ge(r.startedAtMs,c,u),t[93]=c,t[94]=u,t[95]=r.startedAtMs,t[96]=Se):Se=t[96];let Ce;t[97]!==c.details.started||t[98]!==Se?(Ce=(0,Z.jsx)(St,{label:xe,value:Se}),t[97]=c.details.started,t[98]=Se,t[99]=Ce):Ce=t[99];let q;t[100]!==c.details.model||t[101]!==r.model?(q=r.model?(0,Z.jsx)(St,{label:c.details.model,value:r.model}):null,t[100]=c.details.model,t[101]=r.model,t[102]=q):q=t[102];let we;t[103]!==K||t[104]!==Ce||t[105]!==q?(we=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[K,Ce,q]}),t[103]=K,t[104]=Ce,t[105]=q,t[106]=we):we=t[106];let Te;t[107]!==ye||t[108]!==we?(Te=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ye,we]}),t[107]=ye,t[108]=we,t[109]=Te):Te=t[109];let Ee;t[110]!==_||t[111]!==c||t[112]!==b||t[113]!==v||t[114]!==g||t[115]!==m||t[116]!==r?(Ee=m?(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:c.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:m.explanation}),m.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:m.expectedEffect}):null,(0,Z.jsx)(lt,{title:c.repair.risks,items:m.risks,empty:c.none}),(0,Z.jsx)(mt,{value:m.patch,labels:c,title:c.details.repairPatch}),m.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:g,onChange:e=>v(e.target.checked)}),(0,Z.jsx)(`span`,{children:c.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(L,{variant:`primary`,onClick:()=>b(r),disabled:_===`run:${r.id}:repair`||m.requiresApproval&&!g,children:_===`run:${r.id}:repair`?c.feedback.working:c.repair.apply})})]}):null,t[110]=_,t[111]=c,t[112]=b,t[113]=v,t[114]=g,t[115]=m,t[116]=r,t[117]=Ee):Ee=t[117];let De;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(x,{className:`size-4 shrink-0`}),t[118]=De):De=t[118];let Oe;t[119]===c.runDetail.technicalEvents?Oe=t[120]:(Oe=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[De,c.runDetail.technicalEvents]}),t[119]=c.runDetail.technicalEvents,t[120]=Oe);let ke;t[121]!==i.length||t[122]!==c.runDetail.eventCount?(ke=c.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=c.runDetail.eventCount,t[123]=ke):ke=t[123];let Ae;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Z.jsx)(ie,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=Ae):Ae=t[124];let je;t[125]===ke?je=t[126]:(je=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[ke,Ae]}),t[125]=ke,t[126]=je);let J;t[127]!==Oe||t[128]!==je?(J=(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:[Oe,je]}),t[127]=Oe,t[128]=je,t[129]=J):J=t[129];let Me;t[130]===c.runDetail.technicalEventsDescription?Me=t[131]:(Me=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:c.runDetail.technicalEventsDescription}),t[130]=c.runDetail.technicalEventsDescription,t[131]=Me);let Y;t[132]!==i||t[133]!==c||t[134]!==u||t[135]!==f?(Y=(0,Z.jsx)(`div`,{className:`mt-4`,children:f?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":c.loading,children:[(0,Z.jsx)(P,{className:`h-10 w-full`}),(0,Z.jsx)(P,{className:`h-10 w-4/5`}),(0,Z.jsx)(P,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:c.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`,Ct(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:pt(e,c)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[Ge(e.createdAtMs,c,u),` · `,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:[c.details.eventData,(0,Z.jsx)(ie,{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]=c,t[134]=u,t[135]=f,t[136]=Y):Y=t[136];let Pe;t[137]!==J||t[138]!==Me||t[139]!==Y?(Pe=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[J,Me,Y]}),t[137]=J,t[138]=Me,t[139]=Y,t[140]=Pe):Pe=t[140];let X;return t[141]!==D||t[142]!==me||t[143]!==ve||t[144]!==Te||t[145]!==Ee||t[146]!==Pe?(X=(0,Z.jsxs)(`aside`,{className:D,children:[me,ve,Te,Ee,Pe]}),t[141]=D,t[142]=me,t[143]=ve,t[144]=Te,t[145]=Ee,t[146]=Pe,t[147]=X):X=t[147],X}function _t(e){let t=(0,H.c)(23),{automation:n,runs:r,labels:i,cronLabels:s,language:c,busyAction:l,onClose:u,onEdit:d,onSelectRun:f,onAction:p}=e,m=n?l===`automation:${n.id}:run`:!1,_=n?l===`automation:${n.id}:toggle`:!1,v=n?l===`automation:${n.id}:delete`:!1,x=!!n,S;t[0]===u?S=t[1]:(S=e=>!e&&u(),t[0]=u,t[1]=S);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[2]=E):E=t[2];let k;t[3]!==n||t[4]!==l||t[5]!==s||t[6]!==v||t[7]!==i||t[8]!==c||t[9]!==p||t[10]!==u||t[11]!==d||t[12]!==f||t[13]!==m||t[14]!==r||t[15]!==_?(k=n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(me,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:n.enabled?i.enabled:i.paused}),(0,Z.jsx)(D,{asChild:!0,children:(0,Z.jsx)(L,{variant:`ghost`,"aria-label":i.close,children:(0,Z.jsx)(h,{className:`size-4`})})})]})]}),(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 lg:grid-cols-[20rem_1fr]`,children:[(0,Z.jsx)(yt,{automation:n,labels:i,cronLabels:s,language:c}),(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length})]}),r.length===0?(0,Z.jsx)(Tt,{icon:(0,Z.jsx)(te,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 text-left outline-none`,onClick:()=>f(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(ue,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:Ge(e.createdAtMs,i,c)}),(0,Z.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,Je(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||Ke(e.actionSnapshot,i)})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,Z.jsx)(L,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Z.jsxs)(a,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,Z.jsx)(w,{className:`size-3.5`}),i.dashboard.openSession]})}):null,e.workflowRunId?(0,Z.jsx)(L,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Z.jsxs)(a,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,Z.jsx)(de,{className:`size-3.5`}),i.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,Z.jsxs)(L,{variant:`ghost`,disabled:l!==null,onClick:()=>void p(`automation:${n.id}:delete`,()=>F.remove(n.id),i.dashboard.deleted).then(e=>{e&&u()}),children:[v?(0,Z.jsx)(N,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),i.dashboard.delete]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[$e(n)?null:(0,Z.jsxs)(L,{variant:`secondary`,disabled:l!==null,onClick:()=>d(n),children:[(0,Z.jsx)(ee,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(L,{variant:`secondary`,disabled:l!==null,onClick:()=>void p(`automation:${n.id}:toggle`,()=>n.enabled?F.pause(n.id):F.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[_?(0,Z.jsx)(N,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(g,{className:`size-4`}):(0,Z.jsx)(I,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(L,{variant:`primary`,disabled:l!==null,onClick:()=>void p(`automation:${n.id}:run`,()=>F.runNow(n.id),i.feedback.rerunQueued),children:[m?(0,Z.jsx)(N,{className:`size-4 animate-spin`}):(0,Z.jsx)(I,{className:`size-4`}),i.dashboard.runNow]})]})]})]}):null,t[3]=n,t[4]=l,t[5]=s,t[6]=v,t[7]=i,t[8]=c,t[9]=p,t[10]=u,t[11]=d,t[12]=f,t[13]=m,t[14]=r,t[15]=_,t[16]=k):k=t[16];let A;t[17]===k?A=t[18]:(A=(0,Z.jsxs)(O,{children:[E,(0,Z.jsx)(y,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,56rem)] -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:k})]}),t[17]=k,t[18]=A);let j;return t[19]!==x||t[20]!==S||t[21]!==A?(j=(0,Z.jsx)(T,{open:x,onOpenChange:S,children:A}),t[19]=x,t[20]=S,t[21]=A,t[22]=j):j=t[22],j}function vt(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function yt(e){let t=(0,H.c)(127),{automation:n,labels:r,cronLabels:i,language:a}=e,o,s,c,l,u,d,p,m,h,g,_;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=qe(n),v;t[15]!==n||t[16]!==r||t[17]!==a?(v=Y(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=v):v=t[18];let y=v,b;t[19]!==n.state.nextRunAtMs||t[20]!==a?(b=n.state.nextRunAtMs?Ae(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=b):b=t[21];let x=b;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(_=[],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],_.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],_.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=Ae(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],_.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],_.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],_.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],_.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],_.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],_.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],_.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]=_}else _=t[39];h=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?g=t[71]:(g=(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]=g),d=`grid gap-4 p-4`;let S;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),t[72]=S):S=t[72];let C=r.info.schedule,w;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(w=Ne(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=w):w=t[77];let T=n.enabled?`${r.info.nextRun}:${y}`:y;t[78]!==r.info.schedule||t[79]!==x||t[80]!==w||t[81]!==T?(p=(0,Z.jsx)(xt,{icon:S,label:C,value:w,description:T,descriptionTitle:x}),t[78]=r.info.schedule,t[79]=x,t[80]=w,t[81]=T,t[82]=p):p=t[82];let E;t[83]===n.action.kind?E=t[84]:(E=n.action.kind===`workflow`?(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=E);let D=r.info.action,O;t[85]!==n.action||t[86]!==r?(O=Ke(n.action,r),t[85]=n.action,t[86]=r,t[87]=O):O=t[87],t[88]!==r.info.action||t[89]!==E||t[90]!==O?(m=(0,Z.jsx)(xt,{icon:E,label:D,value:O}),t[88]=r.info.action,t[89]=E,t[90]=O,t[91]=m):m=t[91],o=xt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[92]=s):s=t[92],c=r.info.permission,l=r.safety[e],u=vt(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]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];let v;t[93]!==o||t[94]!==s||t[95]!==c||t[96]!==l||t[97]!==u?(v=(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]=v):v=t[98];let y;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[99]=y):y=t[99];let b=r.info.lastRun,x;t[100]!==n||t[101]!==r||t[102]!==a?(x=Pe(n,r,a),t[100]=n,t[101]=r,t[102]=a,t[103]=x):x=t[103];let S=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,C;t[104]!==r.info.lastRun||t[105]!==x||t[106]!==S?(C=(0,Z.jsx)(xt,{icon:y,label:b,value:x,valueTone:S}),t[104]=r.info.lastRun,t[105]=x,t[106]=S,t[107]=C):C=t[107];let w;t[108]!==n.state.consecutiveFailures||t[109]!==n.state.lastError||t[110]!==r.dashboard?(w=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]=w):w=t[111];let T;t[112]!==r.info.technicalDetails||t[113]!==_?(T=_.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)(ie,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_.map(bt)})]}):null,t[112]=r.info.technicalDetails,t[113]=_,t[114]=T):T=t[114];let E;t[115]!==v||t[116]!==C||t[117]!==w||t[118]!==T||t[119]!==d||t[120]!==p||t[121]!==m?(E=(0,Z.jsxs)(`div`,{className:d,children:[p,m,v,C,w,T]}),t[115]=v,t[116]=C,t[117]=w,t[118]=T,t[119]=d,t[120]=p,t[121]=m,t[122]=E):E=t[122];let D;return t[123]!==E||t[124]!==h||t[125]!==g?(D=(0,Z.jsxs)(`aside`,{className:h,children:[g,E]}),t[123]=E,t[124]=h,t[125]=g,t[126]=D):D=t[126],D}function bt(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 xt(e){let t=(0,H.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 St(e){let t=(0,H.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 Ct(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function wt(e){let t=(0,H.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 Tt(e){let t=(0,H.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 Et(e){let t=(0,H.c)(242),{form:n,labels:r,setForm:i,workflowDefinitions:a,selectedWorkflow:s,workflowsLoading:l,agentOptions:u,agentsLoading:d,language:f}=e,p=c(f).agentsSettings,m;t[0]===i?m=t[1]:(m=e=>i(t=>({...t,...e})),t[0]=i,t[1]=m);let h=m,g=Ee(n.intervalValue,n.intervalUnit),_=Date.now(),v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[1,2,3],t[2]=v):v=t[2];let y;t[3]!==g||t[4]!==_||t[5]!==f?(y=v.map(e=>J(_+g*e,f,_)),t[3]=g,t[4]=_,t[5]=f,t[6]=y):y=t[6];let b=y,x,S;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==a?(x=()=>{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}))},S=[n.actionMode,n.workflowId,i,a],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=a,t[11]=x,t[12]=S):(x=t[11],S=t[12]),(0,V.useEffect)(x,S);let C;t[13]===h?C=t[14]:(C=e=>h({name:e.target.value}),t[13]=h,t[14]=C);let w;t[15]!==n.name||t[16]!==C?(w=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:C}),t[15]=n.name,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r.form.name||t[19]!==w?(T=(0,Z.jsx)($,{label:r.form.name,children:w}),t[18]=r.form.name,t[19]=w,t[20]=T):T=t[20];let E;t[21]===h?E=t[22]:(E=e=>h({description:e.target.value}),t[21]=h,t[22]=E);let D;t[23]!==n.description||t[24]!==E?(D=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:E}),t[23]=n.description,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==r.form.description||t[27]!==D?(O=(0,Z.jsx)($,{label:r.form.description,children:D}),t[26]=r.form.description,t[27]=D,t[28]=O):O=t[28];let k;t[29]===r.form.trigger?k=t[30]:(k=(0,Z.jsx)(Ot,{title:r.form.trigger}),t[29]=r.form.trigger,t[30]=k);let ee;t[31]===h?ee=t[32]:(ee=e=>h({triggerMode:e.target.value}),t[31]=h,t[32]=ee);let te;t[33]===r.trigger.manual?te=t[34]:(te=(0,Z.jsx)(M,{value:`manual`,children:r.trigger.manual}),t[33]=r.trigger.manual,t[34]=te);let ne;t[35]===r.trigger.once?ne=t[36]:(ne=(0,Z.jsx)(M,{value:`once`,children:r.trigger.once}),t[35]=r.trigger.once,t[36]=ne);let re;t[37]===r.trigger.daily?re=t[38]:(re=(0,Z.jsx)(M,{value:`daily`,children:r.trigger.daily}),t[37]=r.trigger.daily,t[38]=re);let ie;t[39]===r.trigger.weekly?ie=t[40]:(ie=(0,Z.jsx)(M,{value:`weekly`,children:r.trigger.weekly}),t[39]=r.trigger.weekly,t[40]=ie);let ae;t[41]===r.trigger.interval?ae=t[42]:(ae=(0,Z.jsx)(M,{value:`interval`,children:r.trigger.interval}),t[41]=r.trigger.interval,t[42]=ae);let N;t[43]===r.trigger.customCron?N=t[44]:(N=(0,Z.jsx)(M,{value:`cron`,children:r.trigger.customCron}),t[43]=r.trigger.customCron,t[44]=N);let oe;t[45]===r.trigger.webhook?oe=t[46]:(oe=(0,Z.jsx)(M,{value:`webhook`,children:r.trigger.webhook}),t[45]=r.trigger.webhook,t[46]=oe);let se;t[47]===r.trigger.goalBlocked?se=t[48]:(se=(0,Z.jsx)(M,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[47]=r.trigger.goalBlocked,t[48]=se);let P;t[49]===r.trigger.noteCreated?P=t[50]:(P=(0,Z.jsx)(M,{value:`noteCreated`,children:r.trigger.noteCreated}),t[49]=r.trigger.noteCreated,t[50]=P);let ce;t[51]===r.trigger.workflowFailed?ce=t[52]:(ce=(0,Z.jsx)(M,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[51]=r.trigger.workflowFailed,t[52]=ce);let le;t[53]===r.trigger.sessionUpdated?le=t[54]:(le=(0,Z.jsx)(M,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[53]=r.trigger.sessionUpdated,t[54]=le);let ue;t[55]===r.trigger.customEvent?ue=t[56]:(ue=(0,Z.jsx)(M,{value:`event`,children:r.trigger.customEvent}),t[55]=r.trigger.customEvent,t[56]=ue);let de;t[57]!==n.triggerMode||t[58]!==ee||t[59]!==te||t[60]!==ne||t[61]!==re||t[62]!==ie||t[63]!==ae||t[64]!==N||t[65]!==oe||t[66]!==se||t[67]!==P||t[68]!==ce||t[69]!==le||t[70]!==ue?(de=(0,Z.jsxs)(j,{className:Q,value:n.triggerMode,onChange:ee,children:[te,ne,re,ie,ae,N,oe,se,P,ce,le,ue]}),t[57]=n.triggerMode,t[58]=ee,t[59]=te,t[60]=ne,t[61]=re,t[62]=ie,t[63]=ae,t[64]=N,t[65]=oe,t[66]=se,t[67]=P,t[68]=ce,t[69]=le,t[70]=ue,t[71]=de):de=t[71];let F;t[72]!==n.onceAt||t[73]!==n.triggerMode||t[74]!==r.form.onceAt||t[75]!==h?(F=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=>h({onceAt:e.target.value})})}):null,t[72]=n.onceAt,t[73]=n.triggerMode,t[74]=r.form.onceAt,t[75]=h,t[76]=F):F=t[76];let I;t[77]!==n.time||t[78]!==n.triggerMode||t[79]!==n.weekday||t[80]!==r.form.day||t[81]!==r.form.time||t[82]!==r.weekdays||t[83]!==h?(I=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)(`input`,{className:Q,type:`time`,value:n.time,onChange:e=>h({time:e.target.value})})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(j,{className:Q,value:n.weekday,onChange:e=>h({weekday:e.target.value}),children:[(0,Z.jsx)(M,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(M,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(M,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(M,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(M,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(M,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(M,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[77]=n.time,t[78]=n.triggerMode,t[79]=n.weekday,t[80]=r.form.day,t[81]=r.form.time,t[82]=r.weekdays,t[83]=h,t[84]=I):I=t[84];let fe=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/Ee(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>h({intervalValue:e.target.value})}),(0,Z.jsxs)(j,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;h({intervalValue:De(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(M,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(M,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(M,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(M,{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:Fe.map(e=>{let t=Ee(e.value,e.unit),n=t===g;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:()=>h({intervalValue:e.value,intervalUnit:e.unit}),children:Oe(t,f)},`${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:ke(g,f)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,b.join(f===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,L;t[85]!==n.cronExpr||t[86]!==n.triggerMode||t[87]!==r.form.expression||t[88]!==h?(L=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>h({cronExpr:e.target.value})})}):null,t[85]=n.cronExpr,t[86]=n.triggerMode,t[87]=r.form.expression,t[88]=h,t[89]=L):L=t[89];let pe;t[90]!==n.triggerMode||t[91]!==n.webhookSecretId||t[92]!==r.form.secretId||t[93]!==h?(pe=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>h({webhookSecretId:e.target.value})})}):null,t[90]=n.triggerMode,t[91]=n.webhookSecretId,t[92]=r.form.secretId,t[93]=h,t[94]=pe):pe=t[94];let me;t[95]!==n.eventPayloadMatch||t[96]!==n.eventSource||t[97]!==n.eventType||t[98]!==n.triggerMode||t[99]!==r.form.eventPayloadMatch||t[100]!==r.form.eventSource||t[101]!==r.form.eventType||t[102]!==r.form.invalidJsonObject||t[103]!==h?(me=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=>h({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>h({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=>h({eventPayloadMatch:e.target.value}),placeholder:`{
|
|
5
|
-
"status": "blocked"
|
|
6
|
-
}`}),He(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[95]=n.eventPayloadMatch,t[96]=n.eventSource,t[97]=n.eventType,t[98]=n.triggerMode,t[99]=r.form.eventPayloadMatch,t[100]=r.form.eventSource,t[101]=r.form.eventType,t[102]=r.form.invalidJsonObject,t[103]=h,t[104]=me):me=t[104];let R;t[105]===r.form.action?R=t[106]:(R=(0,Z.jsx)(Ot,{title:r.form.action}),t[105]=r.form.action,t[106]=R);let ge;t[107]!==n.workflowId||t[108]!==h||t[109]!==a?(ge=e=>{let t=e.target.value;h({actionMode:t,...t===`workflow`&&!n.workflowId.trim()&&a[0]?{workflowId:a[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[107]=n.workflowId,t[108]=h,t[109]=a,t[110]=ge):ge=t[110];let z;t[111]===r.action.runAgent?z=t[112]:(z=(0,Z.jsx)(M,{value:`agent`,children:r.action.runAgent}),t[111]=r.action.runAgent,t[112]=z);let B;t[113]===r.action.runWorkflow?B=t[114]:(B=(0,Z.jsx)(M,{value:`workflow`,children:r.action.runWorkflow}),t[113]=r.action.runWorkflow,t[114]=B);let U;t[115]!==n.actionMode||t[116]!==ge||t[117]!==z||t[118]!==B?(U=(0,Z.jsxs)(j,{className:Q,value:n.actionMode,onChange:ge,children:[z,B]}),t[115]=n.actionMode,t[116]=ge,t[117]=z,t[118]=B,t[119]=U):U=t[119];let W=$,G=r.form.agent,ve=j,ye=Q,be=n.agentId,K;t[120]===h?K=t[121]:(K=e=>h({agentId:e.target.value}),t[120]=h,t[121]=K);let xe=d?r.form.loadingAgents:r.form.defaultAgent,Se;t[122]===xe?Se=t[123]:(Se=(0,Z.jsx)(M,{value:``,children:xe}),t[122]=xe,t[123]=Se);let Ce=u.map(e=>(0,Z.jsx)(M,{value:e.id,children:A(e,p)},e.id)),q;t[124]!==ve||t[125]!==n.agentId||t[126]!==ye||t[127]!==K||t[128]!==Se||t[129]!==Ce?(q=(0,Z.jsxs)(ve,{className:ye,value:be,onChange:K,children:[Se,Ce]}),t[124]=ve,t[125]=n.agentId,t[126]=ye,t[127]=K,t[128]=Se,t[129]=Ce,t[130]=q):q=t[130];let we;t[131]!==W||t[132]!==r.form.agent||t[133]!==q?(we=(0,Z.jsx)(W,{label:G,children:q}),t[131]=W,t[132]=r.form.agent,t[133]=q,t[134]=we):we=t[134];let Te;t[135]!==n.actionMode||t[136]!==n.agentId||t[137]!==n.description||t[138]!==n.instruction||t[139]!==n.name||t[140]!==n.triggerMode||t[141]!==n.workflowId||t[142]!==n.workflowInput||t[143]!==r.form.instruction||t[144]!==r.form.loadingWorkflows||t[145]!==r.form.noWorkflows||t[146]!==r.form.triggeredRun||t[147]!==r.form.workflow||t[148]!==f||t[149]!==s||t[150]!==h||t[151]!==a||t[152]!==l?(Te=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(he,{value:n.instruction,onApply:e=>h({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:f,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=>h({instruction:e.target.value})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:r.form.workflow,children:(0,Z.jsxs)(j,{className:Q,value:n.workflowId,onChange:e=>h({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:l||a.length===0,children:[l?(0,Z.jsx)(M,{value:``,children:r.form.loadingWorkflows}):null,!l&&a.length===0?(0,Z.jsx)(M,{value:``,children:r.form.noWorkflows}):null,a.map(Dt)]})}),s?(0,Z.jsx)(_e,{definition:s,language:f,value:n.workflowInput,onChange:e=>h({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>h({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:s.id,workflowTitle:s.title,workflowDescription:s.description}},inputClassName:`rounded-lg`}):null]}),t[135]=n.actionMode,t[136]=n.agentId,t[137]=n.description,t[138]=n.instruction,t[139]=n.name,t[140]=n.triggerMode,t[141]=n.workflowId,t[142]=n.workflowInput,t[143]=r.form.instruction,t[144]=r.form.loadingWorkflows,t[145]=r.form.noWorkflows,t[146]=r.form.triggeredRun,t[147]=r.form.workflow,t[148]=f,t[149]=s,t[150]=h,t[151]=a,t[152]=l,t[153]=Te):Te=t[153];let Ae;t[154]===r.form.safety?Ae=t[155]:(Ae=(0,Z.jsx)(Ot,{title:r.form.safety}),t[154]=r.form.safety,t[155]=Ae);let je;t[156]!==n.afterRunMode||t[157]!==h?(je=e=>{let t=e.target.value;h({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},t[156]=n.afterRunMode,t[157]=h,t[158]=je):je=t[158];let Me;t[159]===r.safety.suggest_only?Me=t[160]:(Me=(0,Z.jsx)(M,{value:`suggest_only`,children:r.safety.suggest_only}),t[159]=r.safety.suggest_only,t[160]=Me);let Ne;t[161]===r.safety.ask_before_apply?Ne=t[162]:(Ne=(0,Z.jsx)(M,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),t[161]=r.safety.ask_before_apply,t[162]=Ne);let Y;t[163]===r.safety.auto_apply?Y=t[164]:(Y=(0,Z.jsx)(M,{value:`auto_apply`,children:r.safety.auto_apply}),t[163]=r.safety.auto_apply,t[164]=Y);let Pe;t[165]!==n.safetyMode||t[166]!==je||t[167]!==Me||t[168]!==Ne||t[169]!==Y?(Pe=(0,Z.jsxs)(j,{className:Q,value:n.safetyMode,onChange:je,children:[Me,Ne,Y]}),t[165]=n.safetyMode,t[166]=je,t[167]=Me,t[168]=Ne,t[169]=Y,t[170]=Pe):Pe=t[170];let X=n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription,Ie;t[171]===X?Ie=t[172]:(Ie=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:X}),t[171]=X,t[172]=Ie);let Le;t[173]!==r.form.safety||t[174]!==Pe||t[175]!==Ie?(Le=(0,Z.jsxs)($,{label:r.form.safety,children:[Pe,Ie]}),t[173]=r.form.safety,t[174]=Pe,t[175]=Ie,t[176]=Le):Le=t[176];let Re;t[177]===r.form.afterRun?Re=t[178]:(Re=(0,Z.jsx)(Ot,{title:r.form.afterRun}),t[177]=r.form.afterRun,t[178]=Re);let ze;t[179]===h?ze=t[180]:(ze=e=>h({afterRunMode:e.target.value}),t[179]=h,t[180]=ze);let Be;t[181]===r.afterRun.none?Be=t[182]:(Be=(0,Z.jsx)(M,{value:`none`,children:r.afterRun.none}),t[181]=r.afterRun.none,t[182]=Be);let Ve;t[183]===r.afterRun.saveToSession?Ve=t[184]:(Ve=(0,Z.jsx)(M,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[183]=r.afterRun.saveToSession,t[184]=Ve);let Ue=n.safetyMode!==`auto_apply`,We;t[185]!==r.afterRun.webhook||t[186]!==Ue?(We=(0,Z.jsx)(M,{value:`webhook`,disabled:Ue,children:r.afterRun.webhook}),t[185]=r.afterRun.webhook,t[186]=Ue,t[187]=We):We=t[187];let Ge;t[188]!==n.afterRunMode||t[189]!==ze||t[190]!==Be||t[191]!==Ve||t[192]!==We?(Ge=(0,Z.jsxs)(j,{className:Q,value:n.afterRunMode,onChange:ze,children:[Be,Ve,We]}),t[188]=n.afterRunMode,t[189]=ze,t[190]=Be,t[191]=Ve,t[192]=We,t[193]=Ge):Ge=t[193];let Ke;t[194]!==n.afterRunMode||t[195]!==n.webhookUrl||t[196]!==r.form.webhookUrl||t[197]!==h?(Ke=n.afterRunMode===`webhook`?(0,Z.jsx)($,{label:r.form.webhookUrl,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>h({webhookUrl:e.target.value})})}):null,t[194]=n.afterRunMode,t[195]=n.webhookUrl,t[196]=r.form.webhookUrl,t[197]=h,t[198]=Ke):Ke=t[198];let qe;t[199]===r.form.reliability?qe=t[200]:(qe=(0,Z.jsx)(Ot,{title:r.form.reliability}),t[199]=r.form.reliability,t[200]=qe);let Je;t[201]===h?Je=t[202]:(Je=e=>h({timeoutSeconds:e.target.value}),t[201]=h,t[202]=Je);let Ye;t[203]!==n.timeoutSeconds||t[204]!==Je?(Ye=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:Je}),t[203]=n.timeoutSeconds,t[204]=Je,t[205]=Ye):Ye=t[205];let Xe;t[206]!==r.form.timeoutSeconds||t[207]!==Ye?(Xe=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:Ye}),t[206]=r.form.timeoutSeconds,t[207]=Ye,t[208]=Xe):Xe=t[208];let Ze;t[209]===h?Ze=t[210]:(Ze=e=>h({disableAfterFailures:e.target.value}),t[209]=h,t[210]=Ze);let Qe;t[211]!==n.disableAfterFailures||t[212]!==Ze?(Qe=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Ze}),t[211]=n.disableAfterFailures,t[212]=Ze,t[213]=Qe):Qe=t[213];let $e;t[214]!==r.form.disableAfterFailures||t[215]!==Qe?($e=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:Qe}),t[214]=r.form.disableAfterFailures,t[215]=Qe,t[216]=$e):$e=t[216];let et;t[217]!==Xe||t[218]!==$e?(et=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,$e]}),t[217]=Xe,t[218]=$e,t[219]=et):et=t[219];let tt;return t[220]!==T||t[221]!==O||t[222]!==k||t[223]!==de||t[224]!==F||t[225]!==I||t[226]!==fe||t[227]!==L||t[228]!==pe||t[229]!==me||t[230]!==R||t[231]!==U||t[232]!==we||t[233]!==Te||t[234]!==Ae||t[235]!==Le||t[236]!==Re||t[237]!==Ge||t[238]!==Ke||t[239]!==qe||t[240]!==et?(tt=(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:[T,O,k,de,F,I,fe,L,pe,me,R,U,we,Te,Ae,Le,Re,Ge,Ke,qe,et]})}),t[220]=T,t[221]=O,t[222]=k,t[223]=de,t[224]=F,t[225]=I,t[226]=fe,t[227]=L,t[228]=pe,t[229]=me,t[230]=R,t[231]=U,t[232]=we,t[233]=Te,t[234]=Ae,t[235]=Le,t[236]=Re,t[237]=Ge,t[238]=Ke,t[239]=qe,t[240]=et,t[241]=tt):tt=t[241],tt}function Dt(e){return(0,Z.jsx)(M,{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,H.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 Ot(e){let t=(0,H.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(de,{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{ot 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{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-CqXpNawC.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Dt0pSudQ.js";import{$s as p,Fl as m,Hl as h,Jl as g,Ks as _,Ll as v,Ml as y,Ms as b,Mt as x,Nt as S,Pc as C,Ps as w,Ql as T,Sc as E,Ts as D,Uc as O,Uo as k,Yo as A,Zo as j,Zs as M,_l as N,ar as P,bc as F,co as I,cs as L,ec as R,fc as z,gc as B,jt as ee,oi as te,ql as V,ru as H,so as U,tu as W,us as ne,xc as G,ys as K}from"./index-C4HpPu1y.js";import{n as re,r as ie,t as ae}from"./settings-page-layout-C7sfPFaM.js";import{n as oe}from"./settings-loading-skeleton-CQhjhb0F.js";import{t as se}from"./settings-advanced-gate-C25HTTPK.js";import{n as ce,t as q}from"./settings-form-section-CCQ7MjdZ.js";import{t as le}from"./page-tabs-C9OfBAT6.js";import{c as ue,r as de,s as J}from"./typed-models-lib-fe1xAgdw.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-DZrNmiR3.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 ge(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 _e(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(ue(),`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(ve),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)(A,{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)(H,{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`,ge(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 ve(e){return(0,Z.jsx)(j,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(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 xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(ce,{icon:M,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=ue(),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)(j,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(j,{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)(j,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(A,{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]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)(Q,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=J(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)(Q,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let N;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(N=ye(`security`),t[53]=N):N=t[53];let P;t[54]===n.browserSecurityShow?P=t[55]:(P=(0,Z.jsx)(ce,{icon:R,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 z;t[63]!==I||t[64]!==L?(z=(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]=z):z=t[65];let B;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==z?(B=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:z}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=z,t[69]=B):B=t[69];let ee=n.label.browserCommandTimeout,te=n.desc.browserCommandTimeout,V;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(V=J(),t[70]=V):V=t[70];let H=r.browserCommandTimeout??``,U;t[71]===i?U=t[72]:(U=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=U);let W;t[73]!==H||t[74]!==U?(W=(0,Z.jsx)(`input`,{type:`number`,className:V,min:5,value:H,placeholder:`30`,onChange:U}),t[73]=H,t[74]=U,t[75]=W):W=t[75];let ne;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==W?(ne=(0,Z.jsx)(Q,{label:ee,description:te,children:W}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=W,t[79]=ne):ne=t[79];let G;t[80]!==B||t[81]!==ne?(G=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[B,ne]}),t[80]=B,t[81]=ne,t[82]=G):G=t[82];let K;t[83]!==P||t[84]!==G?(K=(0,Z.jsx)(`div`,{id:N,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[P,G]})}),t[83]=P,t[84]=G,t[85]=K):K=t[85];let re;return t[86]!==k||t[87]!==K?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,K]}),t[86]=k,t[87]=K,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,o;t[0]===n?o=t[1]:(o=k(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)(y,{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 Ce(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)(H,{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 we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=te(Te),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:B,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:p,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:C,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:h,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(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)(Ce,{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 Te(e){return e.mode}function Ee(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 De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(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 Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(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)(Ie,{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)(Ie,{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 Ie(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:W,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:w,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:O,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:T,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:g,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 p;t[15]===s?p=t[16]:(p=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=p);let m;t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{className:c,children:[f,p]}),t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;t[21]===r?h=t[22]:(h=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]=h);let _;return t[23]!==l||t[24]!==m||t[25]!==h?(_=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=_):_=t[26],_}function Le(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 Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(S,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,g=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{g();let e=setInterval(()=>void g(),8e3);return()=>clearInterval(e)},[g]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await g()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,g]),y=(0,Y.useCallback)(async e=>{await i(e),await g()},[g,i]),b=(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)(Fe,{icon:G,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)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(G,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{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:h,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)(_,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:D,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 b(),children:[p===`pending`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{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}),m?(0,Z.jsx)(Le,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Be(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 Ve(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=Be(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(He)}):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 He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({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)(S,Ue),{confirmOpen:f,installStatus:h,installMessage:g,openStatus:_,openMessage:v,runtime:y}=u,{progress:b,running:x,cancelling:C,run:w,reset:T,cancel:E}=i,D=t.kind===`ok`?t.data:null,k=D?.installed===!0,M=h===`installing`||x,N=(0,Y.useCallback)(async()=>{if(k)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,k]);(0,Y.useEffect)(()=>{if(!k){d({type:`patch`,patch:{runtime:null}});return}N();let e=setInterval(()=>void N(),8e3);return()=>clearInterval(e)},[k,N]);let F=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),T();let t=await w({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}}),T();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 N()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,N,T,w]),I=(0,Y.useCallback)(async()=>{if(_!==`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,_]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:k?`ready`:`not_installed`,R=k&&D?.version?`v${D.version} (${D.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:p,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k?(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:_===`pending`,onClick:()=>void I(),children:[_===`pending`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(G,{className:`size-3.5`}),_===`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:M,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[M?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):k?(0,Z.jsx)(z,{className:`size-3.5`}):h===`installed`?(0,Z.jsx)(W,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(m,{className:`size-3.5`}),M?e.browserCloakInstalling:k?e.browserReinstall:e.browserCloakDownload]})]}),children:[x?(0,Z.jsx)(Ve,{m:e,progress:b,cancelling:C,onCancel:()=>void E()}):null,g?(0,Z.jsx)(Le,{kind:h===`failed`?`error`:`success`,message:g}):null,v?(0,Z.jsx)(Le,{kind:_===`error`?`error`:`success`,message:v}):null,k&&y?(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:y.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(y.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:y.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),y.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)(A,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(j,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(j,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(ce,{icon:p,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:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(P,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,D),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void F(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(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 qe({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=L({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),m=(0,Y.useCallback)(()=>fe().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)(Fe,{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)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{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)(A,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(j,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(j,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(ne,{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)(Le,{kind:a===`error`?`error`:`success`,message:c}):null]})}function Je(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,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&o,h;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?(h=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]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ye),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.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)(W,{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]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl bg-surface-base p-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({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[h,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),C=f.port??Xe,w=f.host||`127.0.0.1`,T=`ws://${w}:${C}/browser-ext`,D=t.kind===`ok`&&t.data.running,k=t.kind===`ok`&&t.data.connected,A=t.kind===`ok`&&t.data.bridgeHeld===!0,j=t.kind===`ok`&&t.data.portConflict===!0,M=D||A,N=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,P=N?.installed===!0,I=N?.extensionDir,L=N?.needsChromeReload===!0,R=t.kind===`ok`?k?{icon:E,color:`text-green-500`,label:e.browserExtensionConnected}:D?{icon:F,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:b,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:b,color:`text-fg-muted`,label:`…`},z=R.icon,ee=(0,Y.useCallback)(async()=>{if(!h){g(`start`),y(null);try{await i({host:w,port:C})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,w,C,i]),te=(0,Y.useCallback)(async()=>{if(!h){g(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),V=(0,Y.useCallback)(async()=>{if(!h){g(`disconnect`),y(null);try{await s()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s]),H=(0,Y.useCallback)(async()=>{if(!h){g(`install`),y(null),S(null);try{let t=await c({force:P});t?.extensionDir?S(`${e.browserExtensionInstalled}: ${t.extensionDir}`):S(e.browserExtensionInstalled),await l()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,c,P,e.browserExtensionInstalled,l]),U=(0,Y.useCallback)(async()=>{if(!h){g(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,u]),W=(0,Y.useCallback)(async()=>{if(!(!I||h)){g(`path`),y(null),S(null);try{await o(I)?S(e.browserExtensionPathCopied):S(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,I,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),ne=(0,Y.useCallback)(async()=>{if(!(!I||h)){g(`folder`),y(null),S(null);try{await d(),S(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,I,e.browserExtensionFolderOpened,d]),K=(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:h!==null,onClick:()=>void H(),children:[h===`install`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(m,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),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:h!==null,onClick:()=>void te(),children:[h===`stop`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(_,{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:h!==null,onClick:()=>void ee(),children:[h===`start`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(G,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),k?(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:h!==null,onClick:()=>void V(),children:[h===`disconnect`?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:B,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:K,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(Xe),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(Ze/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 ${R.color}`,children:[(0,Z.jsx)(z,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:R.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:P,extensionDir:I,connected:k,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void U(),onCopyPath:()=>void W(),onRevealFolder:()=>void ne()}),L?(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,j?(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(C))}):null,x?(0,Z.jsx)(Le,{kind:`success`,message:x}):null,v?(0,Z.jsx)(Le,{kind:`error`,message:v}):null]})})}function $e(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:p,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,S=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,w=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,T=r.kind===`ok`&&r.data.installed,E=l===`installing`||h,D;t[7]===x?D=t[8]:(D=()=>void x(),t[7]=x,t[8]=D);let k;t[9]!==T||t[10]!==E||t[11]!==l?(k=E?(0,Z.jsx)(O,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(z,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(W,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(m,{className:`size-3.5`}),t[9]=T,t[10]=E,t[11]=l,t[12]=k):k=t[12];let A=E?n.browserPlaywrightInstalling:T?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==E||t[14]!==D||t[15]!==k||t[16]!==A?(j=(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:E,onClick:D,children:[k,A]}),t[13]=E,t[14]=D,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(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]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==y||t[24]!==g||t[25]!==n||t[26]!==p||t[27]!==h?(F=h?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:g,onCancel:()=>void y()}):null,t[23]=y,t[24]=g,t[25]=n,t[26]=p,t[27]=h,t[28]=F):F=t[28];let I;t[29]!==d||t[30]!==l?(I=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=I):I=t[31];let L;return t[32]!==c||t[33]!==n||t[34]!==w||t[35]!==S||t[36]!==F||t[37]!==I||t[38]!==j||t[39]!==P?(L=(0,Z.jsxs)(Fe,{icon:C,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:S,statusDetail:w,m:n,embedded:c,primaryAction:j,children:[P,F,I]}),t[32]=c,t[33]=n,t[34]=w,t[35]=S,t[36]=F,t[37]=I,t[38]=j,t[39]=P,t[40]=L):L=t[40],L}async function et(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 tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(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 rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{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 et(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 et(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()=>et(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 et(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 et(d(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
|
|
3
|
-
|
|
4
|
-
`,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(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>ct?r.slice(-8):r}return n}async function dt(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(at,`
|
|
6
|
-
`);let l=a.split(it);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 ft(e){let[t,n]=(0,Y.useState)(lt),[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(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(d(st[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(lt());try{let i=await u(d(ot[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 dt(i.body,e=>{n(t=>ut(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 pt(e){let t=(0,X.c)(150),{a:n,form:r,update:i,activeTab:o,setActiveTab:s}=e,c=l(ht),u=te(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),m=r.browserEnabled&&(o===`overview`||o===`extension`),g=r.browserEnabled&&(o===`overview`||o===`local`),_=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),v;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]!==_||t[7]!==m||t[8]!==g?(v={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:m,probeLocal:g,probeCloak:_,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]=_,t[7]=m,t[8]=g,t[9]=v):v=t[9];let y=rt(v),b;t[10]===y.playwright?b=t[11]:(b=Ee(y.playwright),t[10]=y.playwright,t[11]=b);let x=b,S;t[12]===y.cloak?S=t[13]:(S=Ee(y.cloak),t[12]=y.cloak,t[13]=S);let w=S,T;t[14]===y.extension?T=t[15]:(T=Oe(y.extension),t[14]=y.extension,t[15]=T);let E=T,O;t[16]!==n||t[17]!==y.extension?(O=ke(y.extension,n),t[16]=n,t[17]=y.extension,t[18]=O):O=t[18];let k=O,A;t[19]!==n||t[20]!==w||t[21]!==E||t[22]!==k||t[23]!==x||t[24]!==u?(A=[{value:`extension`,icon:B,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:E,statusLabel:k},{value:`local`,icon:C,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:x,statusLabel:De(x,n)},{value:`cloakbrowser`,icon:p,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:w,statusLabel:De(w,n)},{value:`cdp`,icon:D,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:h,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=w,t[21]=E,t[22]=k,t[23]=x,t[24]=u,t[25]=A):A=t[25];let j=A,M;t[26]!==s||t[27]!==i?(M=e=>{i({browserEnabled:!0,browserBackend:e}),s(e)},t[26]=s,t[27]=i,t[28]=M):M=t[28];let P=M,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]!==y.disconnectExtension||t[34]!==y.extension||t[35]!==y.extensionArtifacts||t[36]!==y.installExtensionArtifacts||t[37]!==y.openExtensionChrome||t[38]!==y.refetchExtensionArtifacts||t[39]!==y.revealExtensionFolder||t[40]!==y.startExtensionBridge||t[41]!==y.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(R=o===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:y.extension,artifacts:y.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:y.startExtensionBridge,stopBridge:y.stopExtensionBridge,disconnectExtension:y.disconnectExtension,installArtifacts:y.installExtensionArtifacts,refetchArtifacts:y.refetchExtensionArtifacts,openExtensionChrome:y.openExtensionChrome,revealExtensionFolder:y.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=y.disconnectExtension,t[34]=y.extension,t[35]=y.extensionArtifacts,t[36]=y.installExtensionArtifacts,t[37]=y.openExtensionChrome,t[38]=y.refetchExtensionArtifacts,t[39]=y.revealExtensionFolder,t[40]=y.startExtensionBridge,t[41]=y.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]!==y.applyPlaywrightDoctor||t[50]!==y.playwright||t[51]!==y.refetchPlaywright||t[52]!==d?(z=o===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:y.playwright,refetch:y.refetchPlaywright,applyDoctor:y.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=y.applyPlaywrightDoctor,t[50]=y.playwright,t[51]=y.refetchPlaywright,t[52]=d,t[53]=z):z=t[53];let ee;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==y.applyCloakDoctor||t[58]!==y.cloak||t[59]!==y.fetchCloakRuntimeStatus||t[60]!==y.launchCloak||t[61]!==y.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?(ee=o===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:y.cloak,refetch:y.refetchCloak,applyDoctor:y.applyCloakDoctor,installStream:f,fetchRuntimeStatus:y.fetchCloakRuntimeStatus,launchCloak:y.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]=y.applyCloakDoctor,t[58]=y.cloak,t[59]=y.fetchCloakRuntimeStatus,t[60]=y.launchCloak,t[61]=y.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]=ee):ee=t[74];let V;t[75]!==n||t[76]!==o||t[77]!==y.launchCdp||t[78]!==y.listCdpInstances||t[79]!==y.pingCdp||t[80]!==y.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(V=o===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:y.launchCdp,stop:y.stopCdp,listInstances:y.listCdpInstances,ping:y.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=y.launchCdp,t[78]=y.listCdpInstances,t[79]=y.pingCdp,t[80]=y.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=V):V=t[83];let H;t[84]!==n||t[85]!==o||t[86]!==y.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)(q,{children:(0,Z.jsx)(qe,{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:y.testCloud})}):null,t[84]=n,t[85]=o,t[86]=y.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]!==ee||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,ee,V,H]}),t[93]=R,t[94]=z,t[95]=ee,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]!==P?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:P}),t[101]=n,t[102]=r.browserEnabled,t[103]=P,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)(N,{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)(Se,{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]!==j||t[130]!==s||t[131]!==i?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:a(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:s,options:j})}):(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]=j,t[130]=s,t[131]=i,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,Z.jsx)(q,{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)(xe,{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)(se,{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 Pe(o)?W:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(54),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,c=o===void 0?!1:o,u=l(_t),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)(v,{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)(ie,{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)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(oe,{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)(K,{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)(ie,{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]!==p.saved||t[24]!==i.dirty||t[25]!==i.saveOk?(_=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:p.saved}):null,t[23]=p.saved,t[24]=i.dirty,t[25]=i.saveOk,t[26]=_):_=t[26];let y=!i.dirty||i.saving,b;t[27]!==p.discard||t[28]!==y||t[29]!==i.discard?(b=(0,Z.jsx)(K,{type:`button`,variant:`secondary`,disabled:y,onClick:i.discard,children:p.discard}),t[27]=p.discard,t[28]=y,t[29]=i.discard,t[30]=b):b=t[30];let x=!i.dirty||i.saving,S;t[31]===i?S=t[32]:(S=()=>void i.save(),t[31]=i,t[32]=S);let C=i.saving?p.saving:p.save,w;t[33]!==x||t[34]!==S||t[35]!==C?(w=(0,Z.jsx)(K,{type:`button`,variant:`primary`,disabled:x,onClick:S,children:C}),t[33]=x,t[34]=S,t[35]=C,t[36]=w):w=t[36];let T;t[37]!==w||t[38]!==_||t[39]!==b?(T=(0,Z.jsxs)(Z.Fragment,{children:[_,b,w]}),t[37]=w,t[38]=_,t[39]=b,t[40]=T):T=t[40];let E;t[41]!==m||t[42]!==T||t[43]!==h||t[44]!==g?(E=(0,Z.jsx)(re,{title:m,subtitle:h,meta:g,actions:T}),t[41]=m,t[42]=T,t[43]=h,t[44]=g,t[45]=E):E=t[45];let D;t[46]===i.error?D=t[47]:(D=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[46]=i.error,t[47]=D);let O;t[48]===a?O=t[49]:(O=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[48]=a,t[49]=O);let k;return t[50]!==E||t[51]!==D||t[52]!==O?(k=(0,Z.jsxs)(ie,{gap:`gap-6`,children:[E,D,O]}),t[50]=E,t[51]=D,t[52]=O,t[53]=k):k=t[53],k}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={model:``,maxLength:void 0};function Ct(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 wt(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 Tt(e){return e===!0||e===`true`||e===1}function Et(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=Tt(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Tt(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 Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Mt(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 Nt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Pt(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 Ft(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 It(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Lt(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:wt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:wt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:wt(t.imageGenerationModel),u=Et((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:Ct(r),modelFallbacks:a,imageModel:Ct(t.imageModel),imageModelFallbacks:s,imageGenerationModel:Ct(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Ft(t),imageGenerationModelAutoProviderFallback:It(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`,compaction:Dt(t.compaction),pruning:Ot(t.pruning),memory:kt(t.memory),sessionSearch:At(t.sessionSearch),webExtract:jt(t.webExtract),delegate:Mt(t.delegate,!1),executeCode:Mt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Nt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Nt(n)})(),typedModels:de(n),paramsJson:Pt(t.params)}}function Rt(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 zt(e){await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Rt(e)})}),U()}var Bt=ee();function Vt(e,t={}){let n=!!c(e=>e.token),[r,i]=(0,Y.useReducer)(Bt,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:v,mutate:y}=I(n);x({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:Lt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),S=_ instanceof Error?_.message:_?String(_):null,C=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:S,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:C,saving:s,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||s)return!1;l(!0),d(null),p(!1);try{return await zt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,s]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Ht(e,t){return e.browserTabs[t]}function Ut(){let e=(0,X.c)(43),t=l(Gt),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=te(Wt),u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={saveScope:`browser`},e[2]=u):u=e[2];let d=Vt(a,u),[f,p]=i(),m;e[3]===c?m=e[4]:(m=he(Ae,c),e[3]=c,e[4]=m);let h=m,g;e[5]===f?g=e[6]:(g=be(f.get(`focus`)),e[5]=f,e[6]=g);let _=g,v;e[7]!==_||e[8]!==f?(v=_?Me[_]??Ne(f.get(`tab`)):Ne(f.get(`tab`)),e[7]=_,e[8]=f,e[9]=v):v=e[9];let y=v,b;bb0:{if(!d.form){b=null;break bb0}let t;e[10]!==a||e[11]!==o||e[12]!==d.form||e[13]!==d.update?(t={form:d.form,update:d.update,a,chat:o},e[10]=a,e[11]=o,e[12]=d.form,e[13]=d.update,e[14]=t):t=e[14],b=t}let x=b,S;e[15]===p?S=e[16]:(S=e=>{p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=p,e[16]=S);let C=S;me(y,C);let w,T;e[17]!==_||e[18]!==f||e[19]!==p?(w=()=>{if(!_)return;let e=Me[_]??Ne(f.get(`tab`));p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=_===`runtime`||_===`security`?ye(_):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},T=[_,f,p],e[17]=_,e[18]=f,e[19]=p,e[20]=w,e[21]=T):(w=e[20],T=e[21]),(0,Y.useEffect)(w,T);let E;if(e[22]!==a||e[23]!==h){let t;e[25]===a?t=e[26]:(t=e=>({id:e,label:Ht(a,e)}),e[25]=a,e[26]=t),E=h.map(t),e[22]=a,e[23]=h,e[24]=E}else E=e[24];let D=E,O;e[27]!==y||e[28]!==a.browserTabsAria||e[29]!==C||e[30]!==D?(O=(0,Z.jsx)(le,{items:D,activeTab:y,onChange:C,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=y,e[28]=a.browserTabsAria,e[29]=C,e[30]=D,e[31]=O):O=e[31];let k;e[32]!==y||e[33]!==x||e[34]!==C?(k=x?(0,Z.jsx)(pt,{...x,activeTab:y,setActiveTab:C}):null,e[32]=y,e[33]=x,e[34]=C,e[35]=k):k=e[35];let A;e[36]!==y||e[37]!==k?(A=(0,Z.jsx)(ae,{id:y,activeTab:y,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:k}),e[36]=y,e[37]=k,e[38]=A):A=e[38];let j;return e[39]!==O||e[40]!==A||e[41]!==d?(j=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:d,tabbed:!0,children:[O,A]}),e[39]=O,e[40]=A,e[41]=d,e[42]=j):j=e[42],j}function Wt(e){return e.mode}function Gt(e){return e.language}export{Ut as AgentBrowserSettingsPage};
|