@xopcai/xopc 0.0.270 → 0.0.272
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/dist/assets/{auth-cwEj8rFb.js → auth-C1QI-uMG.js} +65 -14
- package/dist/browser-ext/dist/background.js +23 -2
- package/dist/browser-ext/dist/pairing-handoff.js +51 -0
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +39 -27
- package/dist/browser-ext/manifest.json +12 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-D_0FmdRj.js → activity-store-DffqjeqQ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-IZvEXak_.js → agent-avatar-dicebear-Cwj4HCYY.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-6CLfLxVc.js +1 -0
- package/dist/gateway/static/root/assets/agents-B6mu64fY.js +1 -0
- package/dist/gateway/static/root/assets/{api-O3TTQ4qN.js → api-CGLdye4i.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Cqqsbzri.js → app-management-settings-panel-BLujSbaw.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DaJyf32s.js → appearance-settings-BXMcueb8.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BEgy4hY3.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-kDPnDTJI.js → archive-plugin-D4bUampf.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CJ3VceKS.js → attachment-load-CBGNA2Ys.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-JwMtU8XB.js → automations-page-dQyolNmy.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DxRFrmrV.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DzyZXLBX.js → binary-plugins-bbvp81h2.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-kTt3gYIJ.js → block-editor-C8e6Wri4.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BKohPYR4.js → browser-automation-inputs-oJWJtQa6.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-ktQfFPk-.js → browser-automations-page-CAcJQSjN.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-TLAlqcPo.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-z-K_jrZz.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-Dzrk33aB.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-DrqzYmDr.js → channels-status-swr-CfOPNnVr.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CIFGGLGa.js → chat-terminal-dock-9ZOl92kh.js} +2 -2
- package/dist/gateway/static/root/assets/clock-3-DnrAnuyZ.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-B1dIoRNi.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-C26e13YU.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-Dj6FRLF9.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-D3vNIjRI.js → dependency-picker-D1q89tVc.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-fQwRb_3p.js → desktop-pet-DfqZBvhp.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DfOJ-GvT.js → desktop-pet-settings-HCEh2MOm.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CPth92s6.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Cn53jB5-.js → extension-debug-page-C8cAWVoK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-IDpLCxpC.js → extension-page-5N87Vaym.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-D85SAUFP.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-B7dcmP7Q.js → gateway-config-swr-BjsDnB_n.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-Dqx8PmcT.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-JGhGMhVZ.js → gateway-startup-retry-BIf0eLWX.js} +1 -1
- package/dist/gateway/static/root/assets/git-branch-Dh9uxTot.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-BpDWGE1a.js +1 -0
- package/dist/gateway/static/root/assets/home-page-DJaqpC8-.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BJLX7Qrh.js → image-generation-api-1m8xTVS_.js} +1 -1
- package/dist/gateway/static/root/assets/index-C6PmD0cK.js +74 -0
- package/dist/gateway/static/root/assets/index-DKy1Qn1_.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CBvMTFFx.js → keyboard-shortcuts-settings-Byy8mCSq.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-l2AEiG2C.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-APCMNDvU.js → local-apps-page-BPo0wBgM.js} +1 -1
- package/dist/gateway/static/root/assets/locale-store-CRNble2Z.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-X5FdLlXK.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-DT6NoIjm.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-BwjpJVPs.js → markdown-view-AglreSOj.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C10byeaa.js → media-plugins-Bzka9qXu.js} +1 -1
- package/dist/gateway/static/root/assets/message-circle-Badhj-4D.js +1 -0
- package/dist/gateway/static/root/assets/message-square-fVE7Ghj1.js +1 -0
- package/dist/gateway/static/root/assets/{messages-D0V_bgRP.js → messages-DH_HCgmw.js} +3 -3
- package/dist/gateway/static/root/assets/note-detail-panel-BUJPoaGZ.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BwFpWRuo.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-qQ36zncF.js → page-tabs-Ys0p65Lt.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-Dz_Qis2R.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BiAJvvCo.js → preview-open-alternatives-iknB5xEp.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-card-CcNBqHoH.js → proactive-card-BPZDgNNR.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-C3K61jve.js → proactive-page-CxdZR-p2.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CunnDP4w.js → product-open-page-W1o3f-kz.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BU1RKAcy.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-z0X0tL8G.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-0JSegbNl.js → registry-api-DmYFpjsH.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-NNTut2I8.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-bu_mwBTr.js → runtime-tools-settings-panel-DP1XyYO8.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-BE0sgZyz.js → schema-form-BMYKdzsH.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B6SsHlz5.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BQu8bAcN.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CBo517lV.js → settings-form-section-2LGjz7bu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DBPimx93.js → settings-page-7DjpC9_C.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Dj9jFWJt.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DdV75VTe.js → share-preview-page-BxYdSi8c.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CMqE0KuK.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BXqSJymN.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Cn_-nvRo.js → skills-page-DNEScMZH.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page.utils-q88l65YU.js +1 -0
- package/dist/gateway/static/root/assets/system-settings-panel-8NIssGKj.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-L6dp9v2y.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-1wryLgBQ.js → theme-store-BXZG3S25.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-CWsRPM84.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-N_lm4FdD.js → use-autosave-BwQuoTQU.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-D4BucMrZ.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DMsyVfri.js → voice-api-key-field-Bd03Ic0s.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-QWVmiAp3.js → voice-config-api-gggUp3u9.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BC0vAxp1.js → work-discovery-overlay-DF8PR_pK.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cz9jQIlP.js → workflow-run-setup-panel-BiAAWlir.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DryKUMfA.js +6 -0
- package/dist/gateway/static/root/index.html +15 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/device-pairing.js +2 -1
- package/dist/packages/gateway-contract/src/session-identity.js +37 -0
- package/dist/src/agent/memory/compaction-chunks.d.ts +18 -0
- package/dist/src/agent/memory/compaction-chunks.js +53 -0
- package/dist/src/agent/memory/compaction-request.d.ts +12 -0
- package/dist/src/agent/memory/compaction-request.js +72 -0
- package/dist/src/agent/memory/compaction.d.ts +3 -0
- package/dist/src/agent/memory/compaction.js +166 -118
- package/dist/src/agent/service.js +1 -0
- package/dist/src/browser/native-messaging-host.js +3 -1
- package/dist/src/cli/bin.js +2 -2
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/gateway-ssh-tunnel.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/platform.js +1 -1
- package/dist/src/cli/commands/profile.js +1 -1
- package/dist/src/cli/commands/tunnel.js +6 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/app.js +1 -0
- package/dist/src/gateway/hono/middleware/auth.d.ts +1 -2
- package/dist/src/gateway/hono/middleware/auth.js +49 -31
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +11 -15
- package/dist/src/gateway/hono/routes/browser-session.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-session.js +43 -0
- package/dist/src/gateway/hono/routes/devices.js +61 -96
- package/dist/src/gateway/hono/routes/exposure.js +3 -7
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/models.js +60 -1
- package/dist/src/gateway/hono/routes/notes.js +3 -7
- package/dist/src/gateway/hono/routes/sessions.js +11 -0
- package/dist/src/gateway/hono/routes/shares.js +8 -20
- package/dist/src/gateway/hono/routes/site-shares.js +4 -8
- package/dist/src/gateway/hono/routes/tunnel.js +13 -13
- package/dist/src/gateway/image-generation-setup.d.ts +17 -0
- package/dist/src/gateway/image-generation-setup.js +30 -21
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +10 -0
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/runtime-config.js +2 -0
- package/dist/src/gateway/security/browser-session.d.ts +5 -0
- package/dist/src/gateway/security/browser-session.js +45 -0
- package/dist/src/gateway/security/gateway-principal.d.ts +1 -0
- package/dist/src/gateway/server.js +1 -1
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +11 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/rate-limit/keyed-store.d.ts +3 -0
- package/dist/src/infra/rate-limit/keyed-store.js +9 -2
- package/dist/src/proactive/policy/service.d.ts +1 -1
- package/dist/src/realtime/runtime.d.ts +2 -1
- package/dist/src/realtime/runtime.js +9 -3
- package/dist/src/realtime/tickets.d.ts +1 -0
- package/dist/src/realtime/tickets.js +3 -0
- package/dist/src/session/store.d.ts +2 -0
- package/dist/src/session/store.js +17 -2
- package/dist/src/session/types.d.ts +2 -1
- package/dist/src/storage/sqlite/browser-session-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/browser-session-repository.js +54 -0
- package/dist/src/storage/sqlite/device-pairing-approval.js +2 -1
- package/dist/src/storage/sqlite/device-pairing-repository.d.ts +4 -10
- package/dist/src/storage/sqlite/device-pairing-repository.js +10 -62
- package/dist/src/storage/sqlite/index.d.ts +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/164_browser_sessions.sql +8 -0
- package/dist/src/storage/sqlite/migrations/165_device_pairing_target.sql +40 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-identity-sql.d.ts +2 -0
- package/dist/src/storage/sqlite/session-identity-sql.js +18 -0
- package/dist/src/storage/sqlite/session-repository.js +26 -22
- package/dist/src/tunnel/auth-policy.d.ts +3 -0
- package/dist/src/tunnel/auth-policy.js +8 -0
- package/dist/src/tunnel/broker-client.d.ts +5 -15
- package/dist/src/tunnel/broker-client.js +37 -49
- package/dist/src/tunnel/frpc-binary.d.ts +8 -6
- package/dist/src/tunnel/frpc-binary.js +76 -88
- package/dist/src/tunnel/frpc-config.d.ts +2 -1
- package/dist/src/tunnel/frpc-config.js +29 -12
- package/dist/src/tunnel/frpc-release.d.ts +27 -0
- package/dist/src/tunnel/frpc-release.js +30 -0
- package/dist/src/tunnel/gateway-lifecycle.js +8 -2
- package/dist/src/tunnel/index.js +2 -1
- package/dist/src/tunnel/registration-proof.d.ts +19 -0
- package/dist/src/tunnel/registration-proof.js +37 -0
- package/dist/src/tunnel/tunnel-persist.js +3 -1
- package/dist/src/tunnel/tunnel-service.d.ts +1 -0
- package/dist/src/tunnel/tunnel-service.js +35 -8
- package/dist/src/tunnel/tunnel-state.js +11 -5
- package/dist/src/tunnel/tunnel-types.d.ts +2 -0
- package/dist/src/tunnel/well-known.js +5 -1
- package/dist/src/user-context/config.js +2 -2
- package/dist/src/utils/logger/redact.js +4 -0
- package/dist/src/voice/realtime/runtime.d.ts +1 -0
- package/dist/src/voice/realtime/runtime.js +17 -1
- package/dist/src/voice/realtime/runtime.types.d.ts +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +2 -0
- package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +1 -0
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CE3ygr3l.js +0 -1
- package/dist/gateway/static/root/assets/agents-DzG2qw-c.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-B4lX6yoT.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BiNBewg0.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-Dgdt5uVL.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BpDW-R9f.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-DU4EQnR0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CfJqy284.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-BNwbnrEb.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-DKyirU4K.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-B1dds2bP.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-pp9jN0wl.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-B8_zTyev.js +0 -1
- package/dist/gateway/static/root/assets/home-page-g1KdAdLb.js +0 -1
- package/dist/gateway/static/root/assets/index-1zRt56Zt.css +0 -2
- package/dist/gateway/static/root/assets/index-OMnem2nr.js +0 -74
- package/dist/gateway/static/root/assets/local-app-workbench-page-bj75v2ZE.js +0 -2
- package/dist/gateway/static/root/assets/locale-store-BThkG0W5.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-BX7n39zV.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-CM62j8ZX.js +0 -1
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-BCWfwVx3.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-koOqb0gX.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BH54rY3B.js +0 -8
- package/dist/gateway/static/root/assets/popover-select-CKBYnT3c.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-SL2g8MZY.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BtxazT5J.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BSb7b67A.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-ljcS2KVz.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CR9Y9LQm.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-J3AnooPW.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-AAm4Iwcp.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-pRCjP5sm.js +0 -1
- package/dist/gateway/static/root/assets/skills-page.utils-CfVAc_lu.js +0 -1
- package/dist/gateway/static/root/assets/system-settings-panel-B-pzalp-.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CmrLy3PO.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-Cgpnm2fL.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-u3QLDX6L.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DA6OOK6X.js +0 -6
|
@@ -1,2 +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{u as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,r as h}from"./popover-select-CKBYnT3c.js";import{t as g}from"./circle-check-C23XjkUj.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./x-B_N4OPjy.js";import{n as y}from"./locale-store-BThkG0W5.js";import{t as b}from"./cn-JdwAhgNB.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{t as S}from"./button-B11EPpor.js";import{t as C}from"./skeleton-BwbyijEw.js";import{$ as w,Ac as T,Gc as E,Il as D,Is as O,Jr as ee,Kc as k,Kl as A,Ls as te,Mu as j,Q as M,Qc as N,Ql as P,Su as F,Tl as I,Ul as L,Ys as R,Z as z,et as B,fu as ne,gu as V,hu as H,kl as U,nc as W,nt as G,pc as re,pu as K,q,qc as J,qr as Y,rt as ie,so as ae,tt as oe,ul as se,vc as ce,wl as le,wo as ue}from"./index-OMnem2nr.js";import{t as de}from"./page-tabs-qQ36zncF.js";var X=n(),Z=e(t(),1),Q=r(),fe=new Set([`candidate`,`needs_review`,`conflicted`,`stale`]),pe={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`每个渠道只贡献有依据的候选内容。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条待确认`,noUnderstanding:`尚未从这个渠道形成可使用的全局理解`,pending:`需要你确认`,pendingHint:`确认后才会用于其他项目和之后的对话。`,nothingPending:`目前没有需要确认的全局理解。`,source:`来源`,remember:`确认`,discard:`不是这样`,edit:`修正`,save:`保存修正`,cancel:`取消`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`},categories:{identity:`关于你是谁`,preference:`偏好`,value:`价值取向`,routine:`工作习惯`,capability:`能力与职责`,relationship:`协作关系`,current_state:`当前状态`,derived_insight:`综合判断`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`Each channel contributes only evidence-backed candidates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} to review`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Needs your confirmation`,pendingHint:`Only confirmed items may be used across projects and future conversations.`,nothingPending:`There is no global understanding to review right now.`,source:`Source`,remember:`Confirm`,discard:`Not true`,edit:`Correct`,save:`Save correction`,cancel:`Cancel`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`},categories:{identity:`Who you are`,preference:`Preference`,value:`Values`,routine:`Routine`,capability:`Capabilities and responsibilities`,relationship:`Collaboration`,current_state:`Current state`,derived_insight:`Synthesis`}}},me={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},he={user:O,conversation:E,connector:L,work_folder:U,local_source:D,inference:L},$={files:U,recent_documents:D,calendar:K,tasks:N,notes:R,mail:J,messages:E,code_activity:I};function ge(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function _e(e,t){return e.kind===`local_source`&&e.label?me[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:pe[t].sourceKinds[e.kind]}function ve(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function ye(e){let t=(0,X.c)(82),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:o,error:s,onReviewAssertion:c,onCompleted:l}=e,u=pe[a],[d,f]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[y,x]=(0,Z.useState)(``),C;t[0]===n?C=t[1]:(C=n.filter(Ee),t[0]=n,t[1]=C);let w=C,E;t[2]===w?E=t[3]:(E=w.filter(Te),t[2]=w,t[3]=E);let D=E,O;if(t[4]!==r||t[5]!==w||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?me[t.adapterId]?.[a]??t.displayName:t.displayName,r=ve(t);e.set(r,{key:r,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of w)for(let n of t.sources?.length?t.sources:[ge(t)]){let r=_e(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}O=[...e.values()].sort(we),t[4]=r,t[5]=w,t[6]=a,t[7]=O}else O=t[7];let ee=O,k;t[8]===c?k=t[9]:(k=async(e,t,n)=>{await c(e,t,n)&&h(null)},t[8]=c,t[9]=k);let A=k,te;t[10]!==D||t[11]!==d?(te=d?D:D.slice(0,5),t[10]=D,t[11]=d,t[12]=te):te=t[12];let j=te,M;t[13]===u.eyebrow?M=t[14]:(M=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:u.eyebrow}),t[13]=u.eyebrow,t[14]=M);let N;t[15]===u.title?N=t[16]:(N=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:u.title}),t[15]=u.title,t[16]=N);let P;t[17]===u.subtitle?P=t[18]:(P=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:u.subtitle}),t[17]=u.subtitle,t[18]=P);let F;t[19]!==M||t[20]!==N||t[21]!==P?(F=(0,Q.jsxs)(`div`,{className:`text-center`,children:[M,N,P]}),t[19]=M,t[20]=N,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==i||t[24]!==u.updating?(I=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-2xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(_,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:u.updating})]}):null,t[23]=i,t[24]=u.updating,t[25]=I):I=t[25];let L;t[26]===u.channels?L=t[27]:(L=(0,Q.jsx)(`h3`,{id:`understanding-channels-title`,className:`text-sm font-semibold text-fg`,children:u.channels}),t[26]=u.channels,t[27]=L);let R;t[28]===u.channelHint?R=t[29]:(R=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.channelHint}),t[28]=u.channelHint,t[29]=R);let z;t[30]!==ee||t[31]!==u.activeCount||t[32]!==u.noChannels||t[33]!==u.noUnderstanding||t[34]!==u.pendingCount?(z=ee.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:ee.map(e=>{let t=e.category?$[e.category]??he[e.kind]:he[e.kind],n=e.assertions.filter(Ce).length,r=e.assertions.filter(Se).length;return(0,Q.jsxs)(`article`,{className:`rounded-2xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-muted text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?u.activeCount.replace(`{{count}}`,String(n)):``,r?u.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.noUnderstanding})]})]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(xe)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-2xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:u.noChannels}),t[30]=ee,t[31]=u.activeCount,t[32]=u.noChannels,t[33]=u.noUnderstanding,t[34]=u.pendingCount,t[35]=z):z=t[35];let B;t[36]!==L||t[37]!==R||t[38]!==z?(B=(0,Q.jsxs)(`section`,{className:`mt-8`,"aria-labelledby":`understanding-channels-title`,children:[L,R,z]}),t[36]=L,t[37]=R,t[38]=z,t[39]=B):B=t[39];let V=D.length?` · ${D.length}`:``,H;t[40]!==u.pending||t[41]!==V?(H=(0,Q.jsxs)(`h3`,{id:`understanding-pending-title`,className:`text-sm font-semibold text-fg`,children:[u.pending,V]}),t[40]=u.pending,t[41]=V,t[42]=H):H=t[42];let U;t[43]===u.pendingHint?U=t[44]:(U=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.pendingHint}),t[43]=u.pendingHint,t[44]=U);let W;t[45]!==o||t[46]!==y||t[47]!==m||t[48]!==a||t[49]!==D.length||t[50]!==A||t[51]!==d||t[52]!==u.cancel||t[53]!==u.categories||t[54]!==u.discard||t[55]!==u.edit||t[56]!==u.nothingPending||t[57]!==u.remember||t[58]!==u.save||t[59]!==u.showAll||t[60]!==u.showLess||t[61]!==u.source||t[62]!==j?(W=D.length?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[j.map(e=>{let t=m===e.id,n=(e.sources?.length?e.sources:[ge(e)]).map(e=>_e(e,a));return(0,Q.jsxs)(`article`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface sm:p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 font-medium text-accent-fg`,children:u.categories[e.kind]}),(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[u.source,`: `,n.join(` · `)]})]}),t?(0,Q.jsx)(`textarea`,{autoFocus:!0,value:y,onChange:e=>x(e.target.value),className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`}):(0,Q.jsx)(`p`,{className:`mt-3 text-[0.95rem] font-medium leading-7 text-fg`,children:e.statement}),t?(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,disabled:o,onClick:()=>h(null),children:u.cancel}),(0,Q.jsxs)(S,{variant:`primary`,disabled:o||!y.trim(),onClick:()=>void A(e,`edited`,y.trim()),children:[o?(0,Q.jsx)(_,{className:`size-4 animate-spin`}):(0,Q.jsx)(p,{className:`size-4`}),u.save]})]}):(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-2`,children:[(0,Q.jsxs)(S,{variant:`ghost`,disabled:o,onClick:()=>{h(e.id),x(e.statement)},children:[(0,Q.jsx)(T,{className:`size-3.5`}),u.edit]}),(0,Q.jsxs)(S,{variant:`secondary`,disabled:o,onClick:()=>void A(e,`rejected`),children:[(0,Q.jsx)(v,{className:`size-3.5`}),u.discard]}),(0,Q.jsxs)(S,{variant:`primary`,disabled:o,onClick:()=>void A(e,`accepted`),children:[o?(0,Q.jsx)(_,{className:`size-4 animate-spin`}):(0,Q.jsx)(p,{className:`size-4`}),u.remember]})]})]},e.id)}),D.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>f(be),children:[d?u.showLess:u.showAll.replace(`{{count}}`,String(D.length)),(0,Q.jsx)(ne,{className:b(`size-3.5 transition-transform`,d&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-2xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(g,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:u.nothingPending})]}),t[45]=o,t[46]=y,t[47]=m,t[48]=a,t[49]=D.length,t[50]=A,t[51]=d,t[52]=u.cancel,t[53]=u.categories,t[54]=u.discard,t[55]=u.edit,t[56]=u.nothingPending,t[57]=u.remember,t[58]=u.save,t[59]=u.showAll,t[60]=u.showLess,t[61]=u.source,t[62]=j,t[63]=W):W=t[63];let G;t[64]!==H||t[65]!==U||t[66]!==W?(G=(0,Q.jsxs)(`section`,{className:`mt-8`,"aria-labelledby":`understanding-pending-title`,children:[H,U,W]}),t[64]=H,t[65]=U,t[66]=W,t[67]=G):G=t[67];let re;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(p,{className:`size-4`}),t[68]=re):re=t[68];let K;t[69]!==o||t[70]!==l||t[71]!==u.done?(K=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(S,{variant:`primary`,disabled:o,onClick:l,children:[re,u.done]})}),t[69]=o,t[70]=l,t[71]=u.done,t[72]=K):K=t[72];let q;t[73]===s?q=t[74]:(q=s?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:s}):null,t[73]=s,t[74]=q);let J;return t[75]!==I||t[76]!==B||t[77]!==G||t[78]!==K||t[79]!==q||t[80]!==F?(J=(0,Q.jsxs)(`section`,{className:`mx-auto w-full max-w-[42rem] pb-2`,"aria-live":`polite`,children:[F,I,B,G,K,q]}),t[75]=I,t[76]=B,t[77]=G,t[78]=K,t[79]=q,t[80]=F,t[81]=J):J=t[81],J}function be(e){return!e}function xe(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function Se(e){return fe.has(e.status)}function Ce(e){return e.status===`active`}function we(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function Te(e){return fe.has(e.status)}function Ee(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function De(){let{pathname:e,search:t}=i(),n=y(e=>e.language),r=q(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),C=e===`/user-model`,{data:T,mutate:E}=x(C?`/api/user-model`:null,w),D=n===`zh`,O=T?.assertions.filter(e=>e.scope.type===`global`&&[`candidate`,`needs_review`,`conflicted`,`stale`].includes(e.status)).length??0;if((0,Z.useEffect)(()=>{if(!C)return;let e=new URLSearchParams(t);if(e.get(`workDiscovery`)!==`review`)return;let n=e.get(`run`),r=!1;return(async()=>{if(n&&q.getState().directoryRun?.id!==n)try{let e=await Y(n);if(r)return;q.getState().updateDirectoryRun(e)}catch{return}r||q.getState().setDrawerOpen(!0)})(),()=>{r=!0}},[C,t]),(0,Z.useEffect)(()=>{C&&r.status!==`running`&&E()},[E,C,r.directoryRun?.id,r.status]),!C)return null;let k=r.status===`running`,A=async(e,t,n)=>{let i=q.getState().directoryRun,a=i?.result?.profileCandidates?.find(t=>t.id===e.id||!!(t.assertionId&&t.assertionId===e.assertionId)),o=r.memories.find(t=>t.id===e.id||!!(t.assertionId&&t.assertionId===e.assertionId));if(!a&&!o?.assertionId)return!1;m(!0),g(null);try{if(i&&a){let e=await ee(i.id,[{id:a.id,status:t,...n?{statement:n}:{}}]);q.getState().updateDirectoryRun(e)}return o?.assertionId&&await q.getState().reviewMemory(o.assertionId,t===`accepted`,n),await E(),!0}catch(e){return g(e instanceof Error?e.message:String(e)),!1}finally{m(!1)}},te=async(e,t,n)=>{let r=[...q.getState().directoryRun?.result?.profileCandidates??[],...q.getState().memories].find(t=>t.assertionId===e.id);if(r)return A(r,t,n);m(!0),g(null);try{return t===`edited`&&n?await z(e.id,n):await B(e.id,t===`accepted`?`active`:`rejected`),await E(),!0}catch(e){return g(e instanceof Error?e.message:String(e)),!1}finally{m(!1)}},j=e=>{if(!e&&T&&O===0&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(f,{open:r.drawerOpen,onOpenChange:j,children:[(0,Q.jsx)(o,{asChild:!0,children:(0,Q.jsxs)(S,{type:`button`,variant:`ghost`,className:b(`relative size-8 rounded-xl p-0`,ue),title:D?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":D?`查看 xopc 对你的理解`:`Review what xopc understands`,children:[k?(0,Q.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(W,{className:`size-4 text-accent-fg`}),O?(0,Q.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-2 rounded-full bg-accent ring-2 ring-surface-panel`}):null]})}),(0,Q.jsxs)(l,{children:[(0,Q.jsx)(a,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(u,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-[1.75rem] border border-edge bg-surface-panel shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(d,{className:`text-sm font-semibold text-fg`,children:k?D?`正在更新用户理解`:`Updating user understanding`:D?`用户理解`:`User understanding`}),(0,Q.jsx)(s,{className:`mt-0.5 text-xs text-fg-muted`,children:k?D?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:O?D?`${O} 条全局理解待确认`:`${O} global item(s) to review`:D?`查看理解来自哪些渠道`:`See which channels shaped it`})]}),(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":D?`关闭`:`Close`,children:(0,Q.jsx)(v,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:T?(0,Q.jsx)(ye,{assertions:T.assertions,configuredSources:T.sources??[],activityRunning:k,language:n,busy:p,error:h,onReviewAssertion:te,onCompleted:()=>{j(!1)}}):(0,Q.jsx)(`section`,{className:`flex min-h-full items-center justify-center`,"aria-label":D?`正在加载用户理解`:`Loading user understanding`,children:(0,Q.jsx)(_,{className:`size-5 animate-spin text-fg-muted motion-reduce:animate-none`})})})]})})]})]})}var Oe={en:{pageTitle:`You`,pageSubtitle:`A living portrait shaped by you and xopc.`,overview:`Your portrait`,understanding:`Shared understanding`,knowledge:`Work memory`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`Your explicit profile stays clear and editable. xopc builds a separate shared understanding through conversations and work.`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,pending:`To confirm together`,pendingHint:`Items that need your judgment`,confirmTogether:`Confirm together`,confirmHint:`These may affect future behavior. Confirm them, correct the wording, or tell me not to use them.`,nothingToConfirm:`Nothing needs your confirmation right now.`,importantNow:`What matters now`,noPriority:`No current priority has been set.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,howWeWorkHint:`Your standing instructions for how I should communicate and act.`,noRules:`No collaboration preferences yet.`,recent:`Recently formed understanding`,recentHint:`The most useful current facts, with their origin and time horizon.`,seeAll:`See all`,workMemory:`What I remember from the work`,workMemoryHint:`Project facts, decisions, lessons, and open questions stay separate from facts about you.`,items:`items`,maintenanceReady:`Memory upkeep is enabled and waiting for its first run.`,maintenanceComplete:`Memory was last organized`,maintenanceFailed:`The latest memory upkeep needs attention`,refresh:`Refresh`,aboutYouTitle:`A view you can correct`,aboutYouHint:`This is working context, not a fixed profile. Every item can be corrected or retired.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No understanding has formed here yet.`,correct:`Correct`,stopUsing:`Stop using`,confirm:`Confirm`,notTrue:`Not true`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,archive:`Archive`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`你`,pageSubtitle:`一份由你和 xopc 共同塑造、持续生长的画像。`,overview:`你的画像`,understanding:`共同理解`,knowledge:`工作记忆`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`你明确提供的基本信息会被清晰呈现并由你直接编辑;xopc 在对话与共事中形成的理解则单独维护。`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,pending:`等待一起确认`,pendingHint:`需要由你判断的内容`,confirmTogether:`一起确认`,confirmHint:`这些理解可能影响之后的行为。你可以确认、修正,或告诉我以后不要使用。`,nothingToConfirm:`目前没有需要你确认的理解。`,importantNow:`此刻重要`,noPriority:`还没有设置当前优先事项。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,howWeWorkHint:`你对沟通方式和执行行为的长期约定。`,noRules:`还没有形成协作偏好。`,recent:`最近形成的理解`,recentHint:`最值得使用的当前认识,同时说明它来自哪里、适用多久。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,workMemoryHint:`项目事实、决定、经验和待解问题,与“关于你”的理解分别管理。`,items:`条`,maintenanceReady:`记忆整理已经启用,正在等待首次运行。`,maintenanceComplete:`最近一次记忆整理于`,maintenanceFailed:`最近一次记忆整理需要处理`,refresh:`刷新`,aboutYouTitle:`一份可以共同修正的理解`,aboutYouHint:`它是协作中的工作认知,不是给你定型的档案。每一条都能修正或停止使用。`,identity:`关于你是谁`,preferences:`偏好与工作节奏`,relationships:`重要的人与关系`,currentState:`当前状态`,insights:`我形成的判断`,emptyGroup:`这里还没有形成理解。`,correct:`修正`,stopUsing:`不再使用`,confirm:`确认`,notTrue:`不是这样`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,archive:`归档`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},ke=[`candidate`,`needs_review`,`conflicted`,`stale`],Ae=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),je=[`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`];function Me(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function Ne(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Pe(e){return{callName:Ne(e.profile.callName)??``,role:Ne(e.profile.role)??``,pronouns:Ne(e.profile.pronouns)??``,timezone:Ne(e.profile.timezone)??``,locale:Ne(e.profile.locale)??``}}function Fe(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function Ie(e){return Array.from(e.trim()).slice(0,2).join(``).toLocaleUpperCase()}function Le(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`我形成的判断`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`My current read`,external_untrusted:`From connected information`})[e.authority]}function Re(e,t){if(e.validTo){let n=Me(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`长期有效`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Long-term`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function ze(e,t){let n=Me(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function Be(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`仍需确认`:`Needs confirmation`}function Ve(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function He(e,t){return(t===`zh`?{project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function Ue(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function We(e){let t=(0,X.c)(14),{title:n,hint:r,action:i,children:a,className:o}=e,s=`rounded-xl border border-edge bg-surface-panel shadow-surface ${o===void 0?``:o}`,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-start justify-between gap-4 border-b border-edge-subtle px-5 py-4`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==s||t[12]!==d?(f=(0,Q.jsxs)(`section`,{className:s,children:[d,a]}),t[10]=a,t[11]=s,t[12]=d,t[13]=f):f=t[13],f}function Ge(e){let t=(0,X.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex min-h-32 flex-col items-center justify-center gap-2 px-5 py-8 text-center text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ke({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:o}){let p=Oe[n],[g,y]=(0,Z.useState)(t);(0,Z.useEffect)(()=>{e&&y(t)},[e,t]);let b=e=>{e.preventDefault(),o({callName:g.callName.trim(),role:g.role.trim(),pronouns:g.pronouns.trim(),timezone:g.timezone.trim(),locale:g.locale.trim()})},x=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:g[e],onChange:t=>y(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),C=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];return g.locale&&!C.includes(g.locale)&&C.push(g.locale),(0,Q.jsx)(f,{open:e,onOpenChange:i,children:(0,Q.jsxs)(l,{children:[(0,Q.jsx)(a,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(u,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col`,onSubmit:b,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(d,{className:`font-semibold text-fg`,children:p.editProfile}),(0,Q.jsx)(s,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:p.editProfileHint})]}),(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":p.cancel,children:(0,Q.jsx)(v,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[x(`callName`,p.callName,p.callNamePlaceholder),x(`role`,p.role,p.rolePlaceholder),x(`pronouns`,p.pronouns,p.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:p.locale}),(0,Q.jsxs)(m,{value:g.locale,onChange:e=>y(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(h,{value:``,children:p.notProvided}),C.map(e=>(0,Q.jsx)(h,{value:e,children:Fe(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:p.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`input`,{value:g.timezone,onChange:e=>y(t=>({...t,timezone:e.target.value})),placeholder:M(),className:`h-10 min-w-0 flex-1 rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsx)(S,{className:`shrink-0 whitespace-nowrap`,onClick:()=>y(e=>({...e,timezone:M()})),children:p.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(S,{disabled:r,children:p.cancel})}),(0,Q.jsxs)(S,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(_,{className:`size-4 animate-spin`}):null,r?p.saving:p.saveProfile]})]})]})})]})})}function qe(e){let t=(0,X.c)(28),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onAction:u,onCorrect:d}=e,f=Oe[r],m;t[0]===n.status?m=t[1]:(m=ke.includes(n.status),t[0]=n.status,t[1]=m);let h=m,g;t[2]!==n||t[3]!==r?(g=Be(n,r),t[2]=n,t[3]=r,t[4]=g):g=t[4];let _=g,y=`rounded-xl border p-4 ${h?`border-edge-strong bg-surface-base`:`border-edge bg-surface-panel`}`,b;t[5]!==i||t[6]!==_||t[7]!==o||t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==h||t[12]!==u||t[13]!==l||t[14]!==d||t[15]!==s||t[16]!==c||t[17]!==f.cancel||t[18]!==f.confirm||t[19]!==f.correct||t[20]!==f.correctionPlaceholder||t[21]!==f.notTrue||t[22]!==f.save||t[23]!==f.stopUsing?(b=a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`sr-only`,htmlFor:`assertion-${n.id}`,children:f.correctionPlaceholder}),(0,Q.jsx)(`textarea`,{id:`assertion-${n.id}`,value:o,onChange:e=>s(e.target.value),placeholder:f.correctionPlaceholder,className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,className:`h-8`,onClick:l,children:f.cancel}),(0,Q.jsx)(S,{variant:`primary`,className:`h-8`,disabled:!o.trim()||i,onClick:d,children:f.save})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(E,{className:`size-3.5`}),Le(n,r)]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(P,{className:`size-3.5`}),Re(n,r)]}),n.scope.type===`global`?null:(0,Q.jsx)(`span`,{children:Ve(n.scope,r)}),_?(0,Q.jsx)(`span`,{children:_}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-1.5`,children:h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S,{variant:`secondary`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`active`),children:[(0,Q.jsx)(p,{className:`size-3.5`}),f.confirm]}),(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:c,children:[(0,Q.jsx)(T,{className:`size-3.5`}),f.correct]}),(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`rejected`),children:[(0,Q.jsx)(v,{className:`size-3.5`}),f.notTrue]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:c,children:[(0,Q.jsx)(T,{className:`size-3.5`}),f.correct]}),(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,disabled:i,onClick:()=>u(`archived`),children:[(0,Q.jsx)(j,{className:`size-3.5`}),f.stopUsing]})]})})]}),t[5]=i,t[6]=_,t[7]=o,t[8]=a,t[9]=n,t[10]=r,t[11]=h,t[12]=u,t[13]=l,t[14]=d,t[15]=s,t[16]=c,t[17]=f.cancel,t[18]=f.confirm,t[19]=f.correct,t[20]=f.correctionPlaceholder,t[21]=f.notTrue,t[22]=f.save,t[23]=f.stopUsing,t[24]=b):b=t[24];let x;return t[25]!==y||t[26]!==b?(x=(0,Q.jsx)(`article`,{className:y,children:b}),t[25]=y,t[26]=b,t[27]=x):x=t[27],x}function Je(e){let t=(0,X.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=Oe[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(S,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function Ye(e){let t=(0,X.c)(39),{item:n,language:r,busy:i,expanded:a,onToggle:o,onArchive:s}=e,c=Oe[r],l=n.updatedAt??n.createdAt,u;t[0]!==r||t[1]!==l?(u=Me(l,r),t[0]=r,t[1]=l,t[2]=u):u=t[2];let d=u,f;t[3]===n.content?f=t[4]:(f=n.content.length>96||n.content.includes(`
|
|
2
|
-
`),t[3]=n.content,t[4]=f);let p=f,m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(F,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),t[5]=m):m=t[5];let h=`whitespace-pre-wrap text-sm leading-6 text-fg ${a?``:`line-clamp-2`}`,g;t[6]!==n.content||t[7]!==h?(g=(0,Q.jsx)(`p`,{className:h,children:n.content}),t[6]=n.content,t[7]=h,t[8]=g):g=t[8];let _;t[9]!==n.scope||t[10]!==r?(_=Ve(n.scope,r),t[9]=n.scope,t[10]=r,t[11]=_):_=t[11];let v;t[12]===_?v=t[13]:(v=(0,Q.jsx)(`span`,{children:_}),t[12]=_,t[13]=v);let y;t[14]===d?y=t[15]:(y=d?(0,Q.jsx)(`span`,{children:d}):null,t[14]=d,t[15]=y);let b;t[16]!==v||t[17]!==y?(b=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;t[19]!==b||t[20]!==g?(x=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g,b]}),t[19]=b,t[20]=g,t[21]=x):x=t[21];let C;t[22]!==p||t[23]!==a||t[24]!==o||t[25]!==c.collapse||t[26]!==c.expand?(C=p?(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1 px-2`,onClick:o,children:[(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:a?c.collapse:c.expand}),(0,Q.jsx)(ne,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})]}):null,t[22]=p,t[23]=a,t[24]=o,t[25]=c.collapse,t[26]=c.expand,t[27]=C):C=t[27];let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(j,{className:`size-3.5`}),t[28]=w):w=t[28];let T;t[29]!==i||t[30]!==s||t[31]!==c.archive?(T=(0,Q.jsx)(S,{variant:`ghost`,className:`size-8 shrink-0 p-0`,disabled:i,onClick:s,"aria-label":c.archive,title:c.archive,children:w}),t[29]=i,t[30]=s,t[31]=c.archive,t[32]=T):T=t[32];let E;t[33]!==C||t[34]!==T?(E=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[C,T]}),t[33]=C,t[34]=T,t[35]=E):E=t[35];let D;return t[36]!==x||t[37]!==E?(D=(0,Q.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[m,x,E]})}),t[36]=x,t[37]=E,t[38]=D):D=t[38],D}function Xe(){let e=y(e=>e.language),t=Oe[e],n=ae(e=>e.setPageHeader),r=ae(e=>e.clearPageHeader),{data:i,error:a,isLoading:o,mutate:s}=x(`/api/user-model`,w),[c,l]=(0,Z.useState)(`overview`),[u,d]=(0,Z.useState)(),[f,m]=(0,Z.useState)(),[h,g]=(0,Z.useState)(),[_,b]=(0,Z.useState)(``),[T,D]=(0,Z.useState)(``),[ee,j]=(0,Z.useState)(24),[M,N]=(0,Z.useState)(),[I,R]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>(n({startExtra:null,main:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),(0,Q.jsx)(`p`,{className:`hidden text-xs text-fg-muted sm:block`,children:t.pageSubtitle})]}),end:(0,Q.jsx)(De,{})}),r),[r,n,t]);let ne=async(e,n)=>{d(e),m(void 0);try{await n(),await s()}catch{m(t.actionFailed)}finally{d(void 0)}},U=(e,t)=>{ne(e.id,()=>B(e.id,t))},K=e=>{ne(e.id,async()=>{await z(e.id,_.trim()),g(void 0),b(``)})},q=async e=>{d(`profile`),m(void 0);try{await ie(e),await s(),R(!1)}catch{m(t.actionFailed)}finally{d(void 0)}};if(o)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-5 p-4 sm:p-6 lg:py-8`,children:[(0,Q.jsx)(C,{className:`h-10 w-72 rounded-xl`}),(0,Q.jsx)(C,{className:`h-72 rounded-xl`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,Q.jsx)(C,{className:`h-80 rounded-xl`}),(0,Q.jsx)(C,{className:`h-80 rounded-xl`})]})]});if(a||!i)return(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(V,{className:`size-6 text-fg-subtle`}),(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,Q.jsx)(S,{onClick:()=>void s(),children:t.tryAgain})]});let J=[...i.assertions].sort((e,t)=>{let n=Number(ke.includes(t.status))-Number(ke.includes(e.status));if(n)return n;let r=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-r||t.recordedAt-e.recordedAt}).filter(e=>e.scope.type===`global`&&!Ae.has(e.predicate)),Y=Pe(i),ue=Y.callName||(e===`zh`?`你`:`You`),X=J.filter(e=>ke.includes(e.status)),fe=J.filter(e=>e.status===`active`),pe=fe.filter(e=>e.authority===`user_explicit`).length,me=fe.length-pe,he=i.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),$=he.find(e=>e.rank===`primary`)??he[0],ge=Ue($,i.goals,e),_e=$?.targetType===`goal`?i.goals.find(e=>e.id===$.targetId):void 0,ve=i.goals.filter(e=>e.status===`active`||e.status===`paused`).filter(e=>$?.targetType!==`goal`||e.id!==$.targetId),ye=i.rules.filter(e=>e.status!==`archived`),be=[...fe].sort((e,t)=>t.recordedAt-e.recordedAt),xe=i.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),Se=T.trim().toLocaleLowerCase(),Ce=xe.filter(t=>!Se||t.content.toLocaleLowerCase().includes(Se)||He(t.kind,e).toLocaleLowerCase().includes(Se)),we=[{key:`identity`,title:t.identity,icon:O,items:J.filter(e=>e.kind===`identity`)},{key:`preferences`,title:t.preferences,icon:A,items:J.filter(e=>[`preference`,`value`,`routine`,`capability`].includes(e.kind))},{key:`relationships`,title:t.relationships,icon:le,items:J.filter(e=>e.kind===`relationship`)},{key:`current`,title:t.currentState,icon:P,items:J.filter(e=>e.kind===`current_state`)},{key:`insights`,title:t.insights,icon:W,items:J.filter(e=>e.kind===`derived_insight`)}].filter(e=>e.items.length>0),Te=je.map(e=>({kind:e,count:xe.filter(t=>t.kind===e).length})).filter(e=>e.count>0),Ee=Ce.slice(0,ee),Ne=je.map(e=>({kind:e,items:Ee.filter(t=>t.kind===e),totalCount:Ce.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),Le=t=>(0,Q.jsx)(qe,{item:t,language:e,busy:u===t.id,editing:h===t.id,draft:h===t.id?_:``,onDraftChange:b,onEdit:()=>{g(t.id),b(t.statement)},onCancel:()=>{g(void 0),b(``)},onAction:e=>U(t,e),onCorrect:()=>K(t)},t.id),Re=i.maintenance.lastRun?Me(i.maintenance.lastRun.finishedAt??i.maintenance.lastRun.startedAt,e,!0):null,Be=i.maintenance.lastRun?i.maintenance.lastRun.status===`completed`?`${t.maintenanceComplete} ${Re}`:t.maintenanceFailed:t.maintenanceReady;return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-5 p-4 sm:p-6 lg:py-8`,children:[(0,Q.jsx)(de,{items:[{id:`overview`,label:t.overview,icon:W},{id:`understanding`,label:t.understanding,icon:O,count:J.length},{id:`knowledge`,label:t.knowledge,icon:F,count:xe.length}],activeTab:c,onChange:l,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`}),f?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:f}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>m(void 0),"aria-label":t.cancel,children:(0,Q.jsx)(v,{className:`size-4`})})]}):null,c===`overview`?(0,Q.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`space-y-5`,children:[(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-8 px-5 py-7 sm:px-8 sm:py-9 lg:grid-cols-[minmax(0,1fr)_21rem] lg:gap-10`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold tracking-[0.16em] text-accent-fg`,children:[(0,Q.jsx)(W,{className:`size-3.5`}),(0,Q.jsx)(`span`,{children:t.portraitEyebrow})]}),(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl border border-edge bg-surface-active text-lg font-semibold text-fg sm:size-20 sm:text-xl`,children:Ie(ue)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:ue}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-fg-muted`,children:Y.role||t.notProvided})]}),(0,Q.jsxs)(S,{className:`shrink-0`,onClick:()=>R(!0),children:[(0,Q.jsx)(te,{className:`size-4`}),t.editProfile]})]}),(0,Q.jsx)(`p`,{className:`mt-6 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.portraitIntro}),(0,Q.jsx)(`div`,{className:`mt-6 overflow-hidden rounded-xl border border-edge bg-edge-subtle`,children:(0,Q.jsx)(`div`,{className:`grid gap-px sm:grid-cols-3`,children:[{icon:se,label:t.locale,value:Y.locale?Fe(Y.locale,e):t.notProvided},{icon:k,label:t.timezone,value:Y.timezone||t.notProvided},{icon:O,label:t.pronouns,value:Y.pronouns||t.notProvided}].map(({icon:e,label:t,value:n})=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-4 py-3.5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]}),(0,Q.jsx)(`p`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-52 flex-col rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-fg-subtle`,children:t.importantNow}),ge?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`mt-4 text-xl font-semibold leading-7 tracking-tight text-fg`,children:ge}),_e?.desiredOutcome?(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:_e.desiredOutcome}):null,$?(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-fg-subtle`,children:ze($.validTo,e)}):null]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 py-6 text-center text-sm text-fg-muted`,children:[(0,Q.jsx)(H,{className:`size-5 text-fg-subtle`}),(0,Q.jsx)(`span`,{children:t.noPriority})]}),ve.length?(0,Q.jsxs)(`div`,{className:`mt-5 border-t border-edge pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:ve.slice(0,3).map(e=>(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]})]}),(0,Q.jsx)(`div`,{className:`grid border-t border-edge-subtle sm:grid-cols-3`,children:[{icon:E,label:t.explicit,hint:t.explicitHint,count:pe},{icon:V,label:t.learned,hint:t.learnedHint,count:me},{icon:p,label:t.pending,hint:t.pendingHint,count:X.length}].map(({icon:e,label:t,hint:n,count:r},i)=>(0,Q.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`border-t border-edge-subtle sm:border-l sm:border-t-0`:``}`,children:[(0,Q.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{className:`mr-1.5 text-lg tabular-nums`,children:r}),t]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:n})]})]},t))})]}),X.length?(0,Q.jsx)(We,{title:t.confirmTogether,hint:t.confirmHint,children:(0,Q.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:X.map(Le)})}):null,(0,Q.jsx)(We,{title:t.howWeWork,hint:t.howWeWorkHint,children:ye.length?ye.map(t=>(0,Q.jsx)(Je,{rule:t,language:e,busy:u===t.id,onToggle:()=>void ne(t.id,()=>G(t.id,t.status===`active`?`disabled`:`active`))},t.id)):(0,Q.jsx)(Ge,{icon:(0,Q.jsx)(le,{className:`size-5`}),children:t.noRules})}),(0,Q.jsx)(We,{title:t.recent,hint:t.recentHint,action:(0,Q.jsx)(S,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>l(`understanding`),children:t.seeAll}),children:be.length?(0,Q.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:be.slice(0,6).map(Le)}):(0,Q.jsx)(Ge,{icon:(0,Q.jsx)(V,{className:`size-5`}),children:t.emptyGroup})}),(0,Q.jsx)(We,{title:t.workMemory,hint:t.workMemoryHint,action:(0,Q.jsx)(S,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>l(`knowledge`),children:t.seeAll}),children:Te.length?(0,Q.jsx)(`div`,{className:`grid gap-px bg-edge-subtle sm:grid-cols-2 lg:grid-cols-4`,children:Te.slice(0,4).map(({kind:t,count:n})=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-5 py-4`,children:[(0,Q.jsx)(`p`,{className:`text-2xl font-semibold tabular-nums text-fg`,children:n}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:He(t,e)})]},t))}):(0,Q.jsx)(Ge,{icon:(0,Q.jsx)(L,{className:`size-5`}),children:t.noKnowledge})}),(0,Q.jsxs)(`footer`,{className:`flex items-center justify-between gap-4 px-1 pb-2 text-xs text-fg-subtle`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(ce,{className:`size-3.5`}),Be]}),(0,Q.jsxs)(S,{variant:`ghost`,className:`h-8 gap-1.5 px-2.5`,onClick:()=>void s(),children:[(0,Q.jsx)(ce,{className:`size-3.5`}),t.refresh]})]})]}):null,c===`understanding`?(0,Q.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`space-y-5`,children:[(0,Q.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-5 py-5 shadow-surface sm:px-6`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(V,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:t.aboutYouHint})]})]})}),we.length?we.map(({key:e,title:t,icon:n,items:r})=>(0,Q.jsx)(We,{title:t,action:(0,Q.jsx)(n,{className:`size-4 text-fg-subtle`}),children:(0,Q.jsx)(`div`,{className:`grid gap-3 p-4 lg:grid-cols-2`,children:r.map(Le)})},e)):(0,Q.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel shadow-surface`,children:(0,Q.jsx)(Ge,{icon:(0,Q.jsx)(V,{className:`size-5`}),children:t.emptyGroup})})]}):null,c===`knowledge`?(0,Q.jsxs)(`div`,{id:`understanding-panel-knowledge`,role:`tabpanel`,"aria-labelledby":`understanding-tab-knowledge`,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge bg-surface-panel p-4 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.allMemory}),(0,Q.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[xe.length,` `,t.items,` · `,t.memoryLibraryHint]})]}),(0,Q.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,Q.jsx)(re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,Q.jsx)(`input`,{type:`search`,value:T,onChange:e=>{D(e.target.value),j(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),Ce.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`space-y-4`,children:Ne.map(({kind:t,items:n,totalCount:r})=>(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:He(t,e)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,Q.jsx)(`div`,{children:n.map(t=>(0,Q.jsx)(Ye,{item:t,language:e,busy:u===t.id,expanded:M===t.id,onToggle:()=>N(e=>e===t.id?void 0:t.id),onArchive:()=>void ne(t.id,()=>oe(t.id,`archived`))},t.id))})]},t))}),Ce.length>ee?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(S,{onClick:()=>j(e=>e+24),children:t.showMore})}):null]}):(0,Q.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel shadow-surface`,children:(0,Q.jsx)(Ge,{icon:(0,Q.jsx)(re,{className:`size-5`}),children:T.trim()?t.noKnowledgeMatch:t.noKnowledge})})]}):null,(0,Q.jsx)(Ke,{open:I,profile:Y,language:e,saving:u===`profile`,onOpenChange:R,onSave:e=>void q(e)})]})}export{Xe as UserModelPage};
|
|
@@ -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{c as i,d as a,h as o,l as s,p as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CpzYSoz7.js";import{t as v}from"./check-DUBLcKHA.js";import{n as y,r as b,t as x}from"./popover-select-CKBYnT3c.js";import{t as S}from"./copy-Dv6d4Dvw.js";import{t as C}from"./download-Dk-ZjtO6.js";import{t as w}from"./markdown-view-BwjpJVPs.js";import{t as T}from"./plus-Q2yW6OE7.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./copy-to-clipboard-HOJ79TWv.js";import{t as O}from"./messages-D0V_bgRP.js";import{n as k,s as A}from"./locale-store-BThkG0W5.js";import{t as j}from"./cn-JdwAhgNB.js";import{i as M}from"./vendor-swr-BIWyz7Rc.js";import{t as N}from"./button-B11EPpor.js";import{i as P}from"./theme-store-1wryLgBQ.js";import{t as F}from"./skeleton-BwbyijEw.js";import{$l as I,A as L,Ac as R,Al as z,Ar as B,Au as V,Bl as H,Br as U,C as W,D as G,Dr as K,E as q,Ec as ee,Er as te,Fr as ne,Fs as re,Gl as ie,Hc as ae,Hr as J,Hs as oe,Ir as se,Ki as Y,Ll as ce,Ln as le,Nr as ue,Ns as de,O as fe,Or as X,Pl as pe,Rr as me,Rs as he,S as ge,Sr as _e,T as ve,Tl as ye,Tr as be,Vr as xe,Vs as Se,Xc as Ce,_ as we,_c as Te,_r as Ee,_u as De,al as Oe,b as ke,br as Ae,cr as je,d as Me,dr as Ne,f as Pe,fa as Fe,fr as Ie,fu as Le,g as Re,gr as ze,h as Be,ha as Ve,hc as He,hr as Ue,i as We,in as Ge,iu as Ke,jr as qe,k as Je,kr as Ye,ll as Xe,ls as Ze,m as Qe,ml as $e,mr as et,nc as tt,nl as nt,p as rt,pc as it,pr as at,sl as ot,sn as st,so as ct,u as lt,ur as ut,uu as dt,v as ft,vr as pt,w as mt,wr as ht,x as gt,xr as _t,xu as vt,y as yt,yl as bt,yr as xt,yu as St,zr as Ct}from"./index-OMnem2nr.js";import{l as wt}from"./vendor-codemirror-DFxP3B9T.js";import{t as Tt}from"./code-editor-CXIH8jQw.js";import{t as Et}from"./page-tabs-qQ36zncF.js";import{n as Dt,t as Ot}from"./tab-completion-input-D64VNmiA.js";import{i as kt,r as At,t as jt}from"./workflow-run-setup-panel-Cz9jQIlP.js";import{t as Mt}from"./tab-completion-input.utils-BP3NH_du.js";import{a as Nt,c as Pt,i as Ft,l as It,n as Lt,o as Rt,r as zt,s as Bt,t as Vt}from"./style-TIDOdKy0.js";var Z=e(t(),1),Q=n(),Ht=[`queued`,`running`,`succeeded`,`attention`],Ut=new Set([`failed`,`timeout`,`cancelled`]);function Wt(e){return e.metadata?.sessionKey?.trim()||null}function Gt(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Kt(e,t){if(!e||typeof e!=`object`)return null;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}function qt(e,t=90){let n=e.metadata?.input?.goal?.trim()||(typeof e.metadata?.input?.payload==`string`?e.metadata.input.payload.trim():null)||Kt(e.metadata?.input?.payload,[`query`,`goal`,`prompt`,`input`,`message`])||Kt(e.metadata?.input?.variables,[`query`,`goal`,`prompt`,`input`,`message`]);return n?Gt(n,t):null}function Jt(e,t=90){return qt(e,t)??Gt(e.title?.trim()||e.definitionId,t)}function Yt(e,t=44){return Gt(e.title?.trim()||e.definitionId,t)}function Xt(e,t){let n=t.trim().toLowerCase();return n?[qt(e,500),e.title,e.definitionId,e.id].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function Zt(e,t){let n=t.workflowFilterId.trim();return e.filter(e=>n&&e.definitionId!==n||!Ee(e,t.triggerFilter??`all`)?!1:Xt(e,t.searchQuery))}function Qt(e){return e.completedAtMs??e.createdAtMs}function $t(e,t){return e.status===`queued`?`queued`:e.status===`running`?`running`:e.status===`succeeded`?`succeeded`:Ut.has(e.status)?`attention`:null}function en(e,t){let n=[...t];return e===`queued`?n.sort((e,t)=>e.createdAtMs-t.createdAtMs):e===`running`?n.sort((e,t)=>(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)):n.sort((e,t)=>Qt(t)-Qt(e))}function tn(e,t){let n={queued:[],running:[],succeeded:[],attention:[]};for(let r of e){let e=$t(r,t);e&&n[e].push(r)}return Ht.map(e=>{if(e===`succeeded`){let t=en(`succeeded`,n.succeeded);return{id:e,runs:t,totalInWindow:t.length}}return{id:e,runs:en(e,n[e])}})}function nn(e,t,n){let r=Math.round((t-e)/1e3);if(r<60)return se(-r,`second`,n);let i=Math.round(r/60);if(i<60)return se(-i,`minute`,n);let a=Math.round(i/60);return a<48?se(-a,`hour`,n):se(-Math.round(a/24),`day`,n)}function rn(e){return e.status===`queued`||e.status===`running`}function an(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}var $=r(),on=(0,Z.memo)(function(e){let t=(0,Q.c)(76),{run:n,language:r,localeTag:i,nowMs:a,selected:o,onOpen:s,onOpenChat:c,onCancel:l,onRetry:u}=e,d=O(r).workflows,[f,p]=(0,Z.useState)(!1),m;t[0]===n?m=t[1]:(m=Wt(n),t[0]=n,t[1]=m);let h=!m,g;t[2]===n?g=t[3]:(g=rn(n),t[2]=n,t[3]=g);let _=g,v=n.status===`running`||n.status===`queued`,y;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(y=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[4]=n.metrics.agentCount,t[5]=n.metrics.doneAgentCount,t[6]=y):y=t[6];let b=y,x=n.metrics.errorAgentCount>0,S=n.startedAtMs??n.createdAtMs,C=Ie(_?a-S:n.metrics.durationMs),w=et(d.taskArtifacts,{count:n.metrics.artifactCount}),T;t[7]===n?T=t[8]:(T=Jt(n),t[7]=n,t[8]=T);let E=T,D;t[9]===n?D=t[10]:(D=Yt(n),t[9]=n,t[10]=D);let k=D,A;t[11]!==s||t[12]!==n?(A=()=>{s(n)},t[11]=s,t[12]=n,t[13]=A):A=t[13];let M=A,P;t[14]!==h||t[15]!==c||t[16]!==n?(P=()=>{h||c(n)},t[14]=h,t[15]=c,t[16]=n,t[17]=P):P=t[17];let F=P,I=o&&`ring-1 ring-accent/30`,L;t[18]===I?L=t[19]:(L=j(`group relative min-h-24 overflow-hidden rounded-lg bg-surface-panel p-3 shadow-surface transition-colors`,I,`hover:bg-surface-hover`),t[18]=I,t[19]=L);let R;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(R=j(`w-full text-left`,Ze.focusRingPanel),t[20]=R):R=t[20];let z;t[21]===E?z=t[22]:(z=(0,$.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5 text-fg`,children:E}),t[21]=E,t[22]=z);let B;t[23]===k?B=t[24]:(B=(0,$.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:k}),t[23]=k,t[24]=B);let V;t[25]!==z||t[26]!==B?(V=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[z,B]}),t[25]=z,t[26]=B,t[27]=V):V=t[27];let U;t[28]===n.status?U=t[29]:(U=j(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,pt(n.status)),t[28]=n.status,t[29]=U);let W;t[30]!==i||t[31]!==a||t[32]!==S?(W=nn(S,a,i),t[30]=i,t[31]=a,t[32]=S,t[33]=W):W=t[33];let G;t[34]===W?G=t[35]:(G=(0,$.jsx)(`span`,{children:W}),t[34]=W,t[35]=G);let K=C===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:et(d.taskElapsed,{duration:C})})]}),q;t[36]!==G||t[37]!==K?(q=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[G,K]}),t[36]=G,t[37]=K,t[38]=q):q=t[38];let ee=n.metrics.artifactCount>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:w}):null,te=o?(0,$.jsx)(`span`,{className:`font-medium text-accent-fg`,children:d.taskOpenDetails}):null,ne;t[39]!==ee||t[40]!==te?(ne=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[ee,te]}),t[39]=ee,t[40]=te,t[41]=ne):ne=t[41];let re=h&&`cursor-not-allowed text-fg-disabled hover:bg-transparent`,ie;t[42]===re?ie=t[43]:(ie=j(`rounded-md px-2 py-1 text-xs font-medium`,`text-accent-fg hover:bg-accent-soft`,Ze.focusRingPanel,re),t[42]=re,t[43]=ie);let ae;t[44]!==h||t[45]!==F||t[46]!==d.continueInChat||t[47]!==ie?(ae=(0,$.jsx)(`button`,{type:`button`,className:ie,disabled:h,onClick:F,children:d.continueInChat}),t[44]=h,t[45]=F,t[46]=d.continueInChat,t[47]=ie,t[48]=ae):ae=t[48];let J;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(J=j(`rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),t[49]=J):J=t[49];let oe;t[50]!==M||t[51]!==d.taskOpenDetails?(oe=(0,$.jsx)(`button`,{type:`button`,className:J,onClick:M,children:d.taskOpenDetails}),t[50]=M,t[51]=d.taskOpenDetails,t[52]=oe):oe=t[52];let se;t[53]!==ae||t[54]!==oe?(se=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-2`,children:[ae,oe]}),t[53]=ae,t[54]=oe,t[55]=se):se=t[55];let Y;t[56]===p?Y=t[57]:(Y=()=>p(cn),t[56]=p,t[57]=Y);let ce;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(H,{className:`size-4`,"aria-hidden":!0}),t[58]=ce):ce=t[58];let le;t[59]!==d.taskActionsAria||t[60]!==f||t[61]!==Y?(le=(0,$.jsx)(N,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":d.taskActionsAria,"aria-expanded":f,onClick:Y,children:ce}),t[59]=d.taskActionsAria,t[60]=f,t[61]=Y,t[62]=le):le=t[62];let ue;t[63]!==_||t[64]!==d.cancel||t[65]!==d.rerun||t[66]!==d.taskCloseMenu||t[67]!==f||t[68]!==l||t[69]!==u||t[70]!==n||t[71]!==p?(ue=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":d.taskCloseMenu,onClick:()=>p(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 min-w-36 rounded-lg border border-edge bg-surface-panel py-1 shadow-surface`,children:[_?(0,$.jsx)(sn,{label:d.cancel,tone:`danger`,onClick:()=>{p(!1),l(n.id)}}):null,an(n)?(0,$.jsx)(sn,{label:d.rerun,onClick:()=>{p(!1),u(n.id)}}):null]})]}):null,t[63]=_,t[64]=d.cancel,t[65]=d.rerun,t[66]=d.taskCloseMenu,t[67]=f,t[68]=l,t[69]=u,t[70]=n,t[71]=p,t[72]=ue):ue=t[72];let de;return t[73]!==le||t[74]!==ue?(de=(0,$.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[le,ue]}),t[73]=le,t[74]=ue,t[75]=de):de=t[75],(0,$.jsxs)(`div`,{className:L,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:M,"aria-label":`${d.taskOpenDetails}: ${E}`,"aria-current":o?`true`:void 0,className:R,children:[(0,$.jsxs)(`div`,{className:`pr-7`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[V,(0,$.jsx)(`span`,{className:U,children:d.status[n.status]??n.status})]}),q]}),v?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{children:et(d.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{children:[b,`%`]})]}),(0,$.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${b}%`}})})]}):null,ne,x?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(Se,{className:`size-3 shrink-0`,"aria-hidden":!0}),et(d.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),se,de]})});function sn(e){let t=(0,Q.c)(8),{label:n,disabled:r,tone:i,onClick:a}=e,o=r?`cursor-not-allowed text-fg-subtle`:`text-fg hover:bg-surface-hover`,s=i===`danger`&&!r&&`text-red-600 dark:text-red-300`,c;t[0]!==o||t[1]!==s?(c=j(`block w-full px-3 py-1.5 text-left text-xs`,o,s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;return t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c?(l=(0,$.jsx)(`button`,{type:`button`,disabled:r,onClick:a,className:c,children:n}),t[3]=r,t[4]=n,t[5]=a,t[6]=c,t[7]=l):l=t[7],l}function cn(e){return!e}function ln(e,t){return t.boardColumns[e]}var un=(0,Z.memo)(function(e){let t=(0,Q.c)(17),{column:n,language:r,localeTag:i,nowMs:a,selectedRunId:o,loading:s,onOpenRun:c,onOpenRunChat:l,onCancelRun:u,onRetryRun:d}=e,f=O(r).workflows,[p,m]=(0,Z.useState)(!1),h=n.id===`succeeded`,g=h?5:n.runs.length,_;t[0]!==g||t[1]!==n.runs||t[2]!==p||t[3]!==h?(_=h&&!p?n.runs.slice(0,g):n.runs,t[0]=g,t[1]=n.runs,t[2]=p,t[3]=h,t[4]=_):_=t[4];let v=_,y=h&&n.runs.length>5&&!p,b=h&&p,x;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=j(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`),t[5]=x):x=t[5];let S;t[6]===n.runs.length?S=t[7]:(S=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.runs.length}),t[6]=n.runs.length,t[7]=S);let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(H,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=C):C=t[8];let w=s&&v.length===0?(0,$.jsx)(dn,{}):v.length===0?(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:f.boardColumnEmpty}):v.map(e=>(0,$.jsx)(on,{run:e,language:r,localeTag:i,nowMs:a,selected:e.id===o,onOpen:c,onOpenChat:l,onCancel:u,onRetry:d},e.id)),T=y?(0,$.jsx)(N,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>m(!0),children:et(f.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,E;t[9]!==b||t[10]!==f||t[11]!==m?(E=b?(0,$.jsx)(N,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>m(!1),children:f.boardCollapseSucceeded}):null,t[9]=b,t[10]=f,t[11]=m,t[12]=E):E=t[12];let D;return t[13]!==w||t[14]!==T||t[15]!==E?(D=(0,$.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[w,T,E]}),t[13]=w,t[14]=T,t[15]=E,t[16]=D):D=t[16],(0,$.jsxs)(`section`,{className:x,"aria-label":ln(n.id,f),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:ln(n.id,f)}),S]}),C]}),D]})});function dn(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`article`,{className:`min-h-24 rounded-lg bg-surface-panel p-3 shadow-surface`,"aria-hidden":`true`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(F,{className:`size-4/5`}),(0,$.jsx)(F,{className:`mt-2 h-3 w-24`})]}),(0,$.jsx)(F,{className:`h-5 w-14 rounded-full`})]}),(0,$.jsx)(F,{className:`mt-3 h-3 w-2/3`}),(0,$.jsx)(F,{className:`mt-4 h-5 w-20 rounded-full`})]}),e[0]=t):t=e[0],t}function fn(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var pn=(0,Z.memo)(function(e){let t=(0,Q.c)(54),{runs:n,language:r,localeTag:i,labels:a,searchQuery:o,workflowFilterId:s,triggerFilter:c,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m,onStart:h}=e,g;t[0]===n?g=t[1]:(g=n.some(mn),t[0]=n,t[1]=g);let _=g,v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),[b,x]=(0,Z.useState)(hn),[S,C]=(0,Z.useState)(!1),w,T;t[2]===_?(w=t[3],T=t[4]):(w=()=>{if(!_)return;let e=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(e)},T=[_],t[2]=_,t[3]=w,t[4]=T),(0,Z.useEffect)(w,T);let E;t[5]!==b||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(E=tn(Zt(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),b),t[5]=b,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=E):E=t[10];let D=E,O=D.reduce(gn,0),k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{let t=y.current;!t||t.pointerId!==e.pointerId||(y.current=null,C(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},t[11]=k):k=t[11];let A=k,j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{if(e.button!==0||fn(e.target))return;let t=v.current;t&&(y.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},t[12]=j):j=t[12];let M=j,P;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{let t=y.current,n=v.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,C(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},t[13]=P):P=t[13];let F=P;if(!u&&O===0){let e;t[14]===a.boardEmptyTitle?e=t[15]:(e=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:a.boardEmptyTitle}),t[14]=a.boardEmptyTitle,t[15]=e);let n;t[16]===a.boardEmptyHint?n=t[17]:(n=(0,$.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.boardEmptyHint}),t[16]=a.boardEmptyHint,t[17]=n);let r;t[18]!==a.boardStart||t[19]!==h?(r=(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsx)(N,{variant:`primary`,onClick:h,children:a.boardStart})}),t[18]=a.boardStart,t[19]=h,t[20]=r):r=t[20];let i;return t[21]!==r||t[22]!==e||t[23]!==n?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center rounded-2xl border border-dashed border-edge bg-surface-panel/40 px-6 py-12 text-center`,children:[e,n,r]}),t[21]=r,t[22]=e,t[23]=n,t[24]=i):i=t[24],i}let I=S?`cursor-grabbing select-none`:`cursor-grab`,L;t[25]===I?L=t[26]:(L=[`min-h-0 h-full min-w-0 overflow-x-auto rounded-lg p-2`,I],t[25]=I,t[26]=L);let R=L.join(` `),z;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{y.current?.pointerId===e.pointerId&&(y.current=null,C(!1))},t[27]=z):z=t[27];let B;if(t[28]!==D||t[29]!==r||t[30]!==u||t[31]!==i||t[32]!==b||t[33]!==p||t[34]!==d||t[35]!==f||t[36]!==m||t[37]!==l){let e;t[39]!==r||t[40]!==u||t[41]!==i||t[42]!==b||t[43]!==p||t[44]!==d||t[45]!==f||t[46]!==m||t[47]!==l?(e=e=>(0,$.jsx)(un,{column:e,language:r,localeTag:i,nowMs:b,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m},e.id),t[39]=r,t[40]=u,t[41]=i,t[42]=b,t[43]=p,t[44]=d,t[45]=f,t[46]=m,t[47]=l,t[48]=e):e=t[48],B=D.map(e),t[28]=D,t[29]=r,t[30]=u,t[31]=i,t[32]=b,t[33]=p,t[34]=d,t[35]=f,t[36]=m,t[37]=l,t[38]=B}else B=t[38];let V;t[49]===B?V=t[50]:(V=(0,$.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:B}),t[49]=B,t[50]=V);let H;return t[51]!==R||t[52]!==V?(H=(0,$.jsx)(`div`,{ref:v,className:R,onPointerDown:M,onPointerMove:F,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:z,children:V}),t[51]=R,t[52]=V,t[53]=H):H=t[53],H});function mn(e){return e.status===`queued`||e.status===`running`}function hn(){return Date.now()}function gn(e,t){return e+t.runs.length}function _n(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?et(t.agentScaleExact,{count:n.min}):et(t.agentScaleRange,{min:n.min,max:n.max}):null}function vn(e){let t=(0,Q.c)(77),{definition:n,language:r,labels:i,onPick:a,onDetail:o,onEdit:s,savedForProject:c}=e,l;t[0]!==n||t[1]!==r?(l=ue(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d;t[3]!==n||t[4]!==i?(d=_n(n,i),t[3]=n,t[4]=i,t[5]=d):d=t[5];let f=d,p=n.metadata.source===`user`,m=p?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-muted`,h;t[6]===m?h=t[7]:(h=j(`rounded-full px-2 py-0.5 text-[10px] font-medium`,m),t[6]=m,t[7]=h);let g=p?i.badgeUser:i.badgeBuiltin,_;t[8]!==h||t[9]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[8]=h,t[9]=g,t[10]=_):_=t[10];let v;t[11]!==n.inputSchema||t[12]!==i.inputSchemaBadge?(v=n.inputSchema?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[10px] text-fg-subtle`,children:[(0,$.jsx)(De,{className:`size-2.5`,"aria-hidden":!0}),i.inputSchemaBadge]}):null,t[11]=n.inputSchema,t[12]=i.inputSchemaBadge,t[13]=v):v=t[13];let y;t[14]!==i.projectWorkflowBadge||t[15]!==c?(y=c?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success-soft px-2 py-0.5 text-[10px] text-success`,children:[(0,$.jsx)(vt,{className:`size-2.5`,"aria-hidden":!0}),i.projectWorkflowBadge]}):null,t[14]=i.projectWorkflowBadge,t[15]=c,t[16]=y):y=t[16];let b;t[17]!==_||t[18]!==v||t[19]!==y?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[_,v,y]}),t[17]=_,t[18]=v,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=j(`mt-2 line-clamp-2 text-left text-sm font-semibold leading-5 text-fg hover:text-accent-fg`,Ze.focusRingPanel),t[21]=x):x=t[21];let S;t[22]!==n||t[23]!==o?(S=()=>o(n),t[22]=n,t[23]=o,t[24]=S):S=t[24];let C;t[25]!==n.title||t[26]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:x,onClick:S,children:n.title}),t[25]=n.title,t[26]=S,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T=`${p?i.editWorkflow:i.copyAndEditWorkflow}: ${n.title}`,E;t[31]!==n||t[32]!==s?(E=()=>s(n),t[31]=n,t[32]=s,t[33]=E):E=t[33];let D;t[34]===p?D=t[35]:(D=p?(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0}),t[34]=p,t[35]=D);let O;t[36]!==T||t[37]!==E||t[38]!==D?(O=(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":T,onClick:E,children:D}),t[36]=T,t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==w||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[w,O]}),t[40]=w,t[41]=O,t[42]=k):k=t[42];let A=u.whenToUse||u.description||n.description,M;t[43]===A?M=t[44]:(M=(0,$.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:A}),t[43]=A,t[44]=M);let P;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(Xe,{className:`size-3`,"aria-hidden":!0}),t[45]=P):P=t[45];let F;t[46]!==n.phases.length||t[47]!==i.phaseCount?(F=et(i.phaseCount,{count:n.phases.length}),t[46]=n.phases.length,t[47]=i.phaseCount,t[48]=F):F=t[48];let I;t[49]===F?I=t[50]:(I=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[P,F]}),t[49]=F,t[50]=I);let L;t[51]===f?L=t[52]:(L=f?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(re,{className:`size-3`,"aria-hidden":!0}),f]}):null,t[51]=f,t[52]=L);let z;t[53]!==I||t[54]!==L?(z=(0,$.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-3 pt-4 text-[11px] text-fg-subtle`,children:[I,L]}),t[53]=I,t[54]=L,t[55]=z):z=t[55];let B;t[56]!==n||t[57]!==a?(B=()=>a(n),t[56]=n,t[57]=a,t[58]=B):B=t[58];let V;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),t[59]=V):V=t[59];let H;t[60]!==i.configureAndRun||t[61]!==B?(H=(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`h-8 flex-1 rounded-lg text-xs`,onClick:B,children:[V,i.configureAndRun]}),t[60]=i.configureAndRun,t[61]=B,t[62]=H):H=t[62];let U;t[63]!==n||t[64]!==o?(U=()=>o(n),t[63]=n,t[64]=o,t[65]=U):U=t[65];let W;t[66]!==i.viewDetails||t[67]!==U?(W=(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:U,children:i.viewDetails}),t[66]=i.viewDetails,t[67]=U,t[68]=W):W=t[68];let G;t[69]!==H||t[70]!==W?(G=(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[H,W]}),t[69]=H,t[70]=W,t[71]=G):G=t[71];let K;return t[72]!==k||t[73]!==M||t[74]!==z||t[75]!==G?(K=(0,$.jsxs)(`article`,{className:`flex min-h-48 flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 transition-colors hover:border-edge hover:bg-surface-hover/35`,children:[k,M,z,G]}),t[72]=k,t[73]=M,t[74]=z,t[75]=G,t[76]=K):K=t[76],K}function yn(e){let t=(0,Q.c)(45),{definitions:n,runs:r,language:i,projectPresetDefinitionIds:a,onPick:o,onDetail:s,onEdit:c}=e,[l]=(0,Z.useState)(Sn),u=O(i).workflows,d=i===`zh`?`zh-CN`:`en-US`,[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(`all`),[g,_]=(0,Z.useState)(`all`),v;t[0]!==m||t[1]!==n||t[2]!==f||t[3]!==g?(v=Ne(n,f,m,g),t[0]=m,t[1]=n,t[2]=f,t[3]=g,t[4]=v):v=t[4];let x=v,S;if(t[5]!==n||t[6]!==r){let e=new Map(n.map(xn)),i=new Set;S=[...r].sort(bn).flatMap(t=>{if(i.has(t.definitionId))return[];let n=e.get(t.definitionId);return n?(i.add(t.definitionId),[{definition:n,lastRunAtMs:t.startedAtMs??t.createdAtMs}]):[]}).slice(0,3),t[5]=n,t[6]=r,t[7]=S}else S=t[7];let C=S,w=et(u.workflowCount,{count:x.length}),T;t[8]===w?T=t[9]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:w}),t[8]=w,t[9]=T);let E=u.sourceFilterAria,D;t[10]!==u.sources||t[11]!==_||t[12]!==g?(D=X.map(e=>(0,$.jsx)(`button`,{type:`button`,className:j(`h-8 rounded-md px-2.5 text-xs font-medium transition-colors`,g===e?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ze.focusRingPanel),"aria-pressed":g===e,onClick:()=>_(e),children:u.sources[e]},e)),t[10]=u.sources,t[11]=_,t[12]=g,t[13]=D):D=t[13];let k;t[14]!==u.sourceFilterAria||t[15]!==D?(k=(0,$.jsx)(`div`,{className:`flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":E,children:D}),t[14]=u.sourceFilterAria,t[15]=D,t[16]=k):k=t[16];let A=u.categoryFilterAria,M;t[17]===h?M=t[18]:(M=e=>h(e.target.value),t[17]=h,t[18]=M);let N;t[19]===u.categories?N=t[20]:(N=ht.map(e=>(0,$.jsx)(b,{value:e,children:u.categories[e]},e)),t[19]=u.categories,t[20]=N);let P;t[21]!==m||t[22]!==u.categoryFilterAria||t[23]!==M||t[24]!==N?(P=(0,$.jsx)(y,{value:m,"aria-label":A,onChange:M,className:`h-9 min-w-36 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg shadow-surface`,children:N}),t[21]=m,t[22]=u.categoryFilterAria,t[23]=M,t[24]=N,t[25]=P):P=t[25];let F;t[26]!==P||t[27]!==k?(F=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k,P]}),t[26]=P,t[27]=k,t[28]=F):F=t[28];let I;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(it,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[29]=I):I=t[29];let L;t[30]===p?L=t[31]:(L=e=>p(e.target.value),t[30]=p,t[31]=L);let R=u.librarySearchPlaceholder,z;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(z=j(`h-10 w-full rounded-lg border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-muted`,Ze.focusRingPanel),t[32]=z):z=t[32];let B;t[33]!==u.librarySearchPlaceholder||t[34]!==f||t[35]!==L?(B=(0,$.jsxs)(`div`,{className:`relative max-w-xl`,children:[I,(0,$.jsx)(`input`,{value:f,onChange:L,placeholder:R,className:z})]}),t[33]=u.librarySearchPlaceholder,t[34]=f,t[35]=L,t[36]=B):B=t[36];let V;return t[37]!==x||t[38]!==u||t[39]!==i||t[40]!==s||t[41]!==c||t[42]!==o||t[43]!==a?(V=x.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:u.noDefinitions}),(0,$.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-5 text-fg-muted`,children:u.noDefinitionsHint})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pt-4 sm:grid-cols-2 xl:grid-cols-3`,children:x.map(e=>(0,$.jsx)(vn,{definition:e,language:i,labels:u,savedForProject:a?.has(e.id)??!1,onPick:o,onDetail:s,onEdit:c},e.id))}),t[37]=x,t[38]=u,t[39]=i,t[40]=s,t[41]=c,t[42]=o,t[43]=a,t[44]=V):V=t[44],(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5`,children:[C.length>0&&!f&&m===`all`&&g===`all`?(0,$.jsxs)(`section`,{"aria-labelledby":`recent-workflows-heading`,children:[(0,$.jsx)(`h2`,{id:`recent-workflows-heading`,className:`text-sm font-semibold text-fg`,children:u.recentlyUsed}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:C.map(e=>{let{definition:t,lastRunAtMs:n}=e;return(0,$.jsxs)(`button`,{type:`button`,className:j(`flex min-w-52 flex-1 items-center justify-between gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-left hover:bg-surface-hover`,`sm:max-w-sm`,Ze.focusRingPanel),onClick:()=>o(t),children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:t.title}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-fg-subtle`,children:nn(n,l,d)})]}),(0,$.jsx)(ee,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0})]},t.id)})})]}):null,(0,$.jsxs)(`section`,{"aria-labelledby":`all-workflows-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{id:`all-workflows-heading`,className:`text-sm font-semibold text-fg`,children:u.allWorkflows}),T]}),F]}),B]}),V]})]})}function bn(e,t){return(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)}function xn(e){return[e.id,e]}function Sn(){return Date.now()}var Cn=(0,Z.memo)(function(e){let t=(0,Q.c)(108),{run:n,language:r,localeTag:i,nowMs:a,onOpen:o,onOpenChat:s,onCancel:c,onRetry:l}=e,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;if(t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==n){f=O(r).workflows;let e;t[22]===n?e=t[23]:(e=rn(n),t[22]=n,t[23]=e),u=e;let s;t[24]===n?s=t[25]:(s=an(n),t[24]=n,t[25]=s),p=s;let c;t[26]===n?c=t[27]:(c=Wt(n),t[26]=n,t[27]=c),d=!!c;let l=n.startedAtMs??n.createdAtMs,D=Ie(u?a-l:n.metrics.durationMs),k;t[28]!==n.metrics.agentCount||t[29]!==n.metrics.doneAgentCount?(k=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[28]=n.metrics.agentCount,t[29]=n.metrics.doneAgentCount,t[30]=k):k=t[30];let A=k;v=`group border-b border-edge-subtle last:border-b-0`,_=`flex min-w-0 flex-col gap-3 p-3 transition-colors hover:bg-surface-hover/55 sm:px-4 lg:flex-row lg:items-center`,T=`button`,t[31]!==o||t[32]!==n?(E=()=>o(n),t[31]=o,t[32]=n,t[33]=E):E=t[33],t[34]===Symbol.for(`react.memo_cache_sentinel`)?(h=j(`min-w-0 flex-1 text-left`,Ze.focusRingPanel),t[34]=h):h=t[34];let M=f.taskOpenDetails,N;t[35]===n?N=t[36]:(N=Jt(n),t[35]=n,t[36]=N),g=`${M}: ${N}`,C=`flex min-w-0 items-start gap-3`;let P;t[37]===n.status?P=t[38]:(P=j(`mt-0.5 shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,pt(n.status)),t[37]=n.status,t[38]=P),w=(0,$.jsx)(`span`,{className:P,children:f.status[n.status]??n.status}),m=`min-w-0 flex-1`;let F;t[39]===n?F=t[40]:(F=Jt(n),t[39]=n,t[40]=F),t[41]===F?y=t[42]:(y=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:F}),t[41]=F,t[42]=y);let I;t[43]===n?I=t[44]:(I=Yt(n),t[43]=n,t[44]=I);let L;t[45]===I?L=t[46]:(L=(0,$.jsx)(`span`,{className:`truncate font-medium`,children:I}),t[45]=I,t[46]=L);let R;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[47]=R):R=t[47];let z;t[48]!==i||t[49]!==a||t[50]!==l?(z=nn(l,a,i),t[48]=i,t[49]=a,t[50]=l,t[51]=z):z=t[51];let B;t[52]===z?B=t[53]:(B=(0,$.jsx)(`span`,{children:z}),t[52]=z,t[53]=B);let V=D===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:et(f.taskElapsed,{duration:D})})]});t[54]!==L||t[55]!==B||t[56]!==V?(b=(0,$.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[L,R,B,V]}),t[54]=L,t[55]=B,t[56]=V,t[57]=b):b=t[57],x=u&&n.metrics.agentCount>0?(0,$.jsxs)(`span`,{className:`mt-2 block max-w-md`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:et(f.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[A,`%`]})]}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 overflow-hidden rounded-full bg-surface-muted`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-accent transition-[width] duration-200 motion-reduce:transition-none`,style:{width:`${A}%`}})})]}):null,S=n.metrics.errorAgentCount>0?(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(Se,{className:`size-3 shrink-0`,"aria-hidden":!0}),et(f.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null,t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=n,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w,t[20]=T,t[21]=E}else u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19],T=t[20],E=t[21];let D;t[58]!==m||t[59]!==y||t[60]!==b||t[61]!==x||t[62]!==S?(D=(0,$.jsxs)(`span`,{className:m,children:[y,b,x,S]}),t[58]=m,t[59]=y,t[60]=b,t[61]=x,t[62]=S,t[63]=D):D=t[63];let k;t[64]!==D||t[65]!==C||t[66]!==w?(k=(0,$.jsxs)(`div`,{className:C,children:[w,D]}),t[64]=D,t[65]=C,t[66]=w,t[67]=k):k=t[67];let A;t[68]!==h||t[69]!==g||t[70]!==k||t[71]!==T||t[72]!==E?(A=(0,$.jsx)(`button`,{type:T,onClick:E,className:h,"aria-label":g,children:k}),t[68]=h,t[69]=g,t[70]=k,t[71]=T,t[72]=E,t[73]=A):A=t[73];let M;t[74]!==f.rerun||t[75]!==l||t[76]!==p||t[77]!==n.id?(M=p?(0,$.jsx)(N,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>l(n.id),children:f.rerun}):null,t[74]=f.rerun,t[75]=l,t[76]=p,t[77]=n.id,t[78]=M):M=t[78];let P;t[79]!==d||t[80]!==f.continueInChat||t[81]!==s||t[82]!==n?(P=n.status===`succeeded`&&d?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>s(n),children:f.continueInChat}):null,t[79]=d,t[80]=f.continueInChat,t[81]=s,t[82]=n,t[83]=P):P=t[83];let F;t[84]!==u||t[85]!==f.cancel||t[86]!==c||t[87]!==n.id?(F=u?(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg text-xs text-red-600 dark:text-red-300`,onClick:()=>c(n.id),children:f.cancel}):null,t[84]=u,t[85]=f.cancel,t[86]=c,t[87]=n.id,t[88]=F):F=t[88];let I;t[89]!==o||t[90]!==n?(I=()=>o(n),t[89]=o,t[90]=n,t[91]=I):I=t[91];let L;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),t[92]=L):L=t[92];let R;t[93]!==f.taskOpenDetails||t[94]!==I?(R=(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":f.taskOpenDetails,onClick:I,children:L}),t[93]=f.taskOpenDetails,t[94]=I,t[95]=R):R=t[95];let z;t[96]!==M||t[97]!==P||t[98]!==F||t[99]!==R?(z=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 pl-7 lg:pl-0`,children:[M,P,F,R]}),t[96]=M,t[97]=P,t[98]=F,t[99]=R,t[100]=z):z=t[100];let B;t[101]!==_||t[102]!==A||t[103]!==z?(B=(0,$.jsxs)(`div`,{className:_,children:[A,z]}),t[101]=_,t[102]=A,t[103]=z,t[104]=B):B=t[104];let V;return t[105]!==v||t[106]!==B?(V=(0,$.jsx)(`article`,{className:v,children:B}),t[105]=v,t[106]=B,t[107]=V):V=t[107],V});function wn(e){let t=(0,Q.c)(17),{vm:n}=e,{labels:r,language:i,loading:a,ownerAgentId:o,agentOptions:s,setOwnerAgentId:c,refreshAll:u}=n,d;t[0]!==s||t[1]!==r.agentFilterAria||t[2]!==i||t[3]!==o||t[4]!==c?(d=s.length>1?(0,$.jsx)(y,{value:o??``,"aria-label":r.agentFilterAria,onChange:e=>c(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:s.map(e=>(0,$.jsx)(b,{value:e.id,children:Ge(e,O(i).agentsSettings)},e.id))}):null,t[0]=s,t[1]=r.agentFilterAria,t[2]=i,t[3]=o,t[4]=c,t[5]=d):d=t[5];let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[6]=f):f=t[6];let p;t[7]===r.addWorkflow?p=t[8]:(p=(0,$.jsx)(N,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(l,{to:`/workflows/new`,children:[f,r.addWorkflow]})}),t[7]=r.addWorkflow,t[8]=p);let m;t[9]!==r.refresh||t[10]!==a||t[11]!==u?(m=(0,$.jsx)(Y,{className:`size-9 shrink-0 p-0`,loading:a,label:r.refresh,onClick:u}),t[9]=r.refresh,t[10]=a,t[11]=u,t[12]=m):m=t[12];let h;return t[13]!==d||t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[d,p,m]}),t[13]=d,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var Tn=new Set([`failed`,`timeout`,`cancelled`]),En=[{id:`runs`,icon:nt},{id:`library`,icon:Oe}],Dn={failed:0,timeout:0,cancelled:0,running:1,queued:2,succeeded:3};function On(e){return Tn.has(e.status)}function kn(e,t){return t===`all`?!0:t===`attention`?On(e):e.status===t}function An(e){return[...e].sort((e,t)=>{let n=(Dn[e.status]??4)-(Dn[t.status]??4);if(n!==0)return n;if(e.status===`queued`&&t.status===`queued`)return e.createdAtMs-t.createdAtMs;let r=e.completedAtMs??e.startedAtMs??e.createdAtMs;return(t.completedAtMs??t.startedAtMs??t.createdAtMs)-r})}function jn(e,t){return e===`Home`?`runs`:e===`End`?`library`:e===`ArrowLeft`||e===`ArrowRight`?t===`runs`?`library`:`runs`:null}function Mn(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(F,{className:`h-5 w-16 rounded-full`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle p-4 last:border-b-0`,"aria-hidden":`true`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(F,{className:`h-4 w-52 max-w-full`}),(0,$.jsx)(F,{className:`mt-2 h-3 w-36 max-w-full`})]}),(0,$.jsx)(F,{className:`hidden h-8 w-20 rounded-lg sm:block`})]}),e[1]=n):n=e[1],n}function Nn(e){let t=(0,Q.c)(27),{vm:n}=e,{language:r,localeTag:i,labels:a,hasToken:o,definitions:s,projectPresetDefinitionIds:c,runs:l,searchQuery:u,setSearchQuery:d,workflowFilterId:f,setWorkflowFilterId:p,triggerFilter:m,setTriggerFilter:h,statusFilter:g,setStatusFilter:_,clearRunFilters:v,pageTab:x,setPageTab:S,runLayout:C,setRunLayout:w,openRunDetails:T,openRunInChat:D,openDefinitionDetails:O,openWorkflowEditor:k,startWorkflow:A,actionError:M,loading:P,error:F,cancelRun:I,retryRun:L}=n,R=ct(Ln),z=ct(In),B=Date.now(),V=An(l.filter(On)),H;t[0]===g?H=t[1]:(H=e=>kn(e,g),t[0]=g,t[1]=H);let U=An(Zt(l,{searchQuery:u,workflowFilterId:f,triggerFilter:m}).filter(H)),W=!!(u||f||m!==`all`||g!==`all`),G,K;if(t[2]!==z||t[3]!==o||t[4]!==a.title||t[5]!==R||t[6]!==n?(G=()=>{if(!o){z();return}return R({startExtra:null,main:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:a.title}),end:(0,$.jsx)(wn,{vm:n})}),()=>z()},K=[z,o,a.title,R,n],t[2]=z,t[3]=o,t[4]=a.title,t[5]=R,t[6]=n,t[7]=G,t[8]=K):(G=t[7],K=t[8]),(0,Z.useLayoutEffect)(G,K),!o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ye,{className:`size-10 text-accent-fg`,"aria-hidden":!0}),t[9]=e):e=t[9];let n;t[10]===a.title?n=t[11]:(n=(0,$.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:a.title}),t[10]=a.title,t[11]=n);let r;t[12]===a.needToken?r=t[13]:(r=(0,$.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.needToken}),t[12]=a.needToken,t[13]=r);let i;return t[14]!==n||t[15]!==r?(i=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center px-3 py-16 text-center sm:px-5 xl:px-6`,children:[e,n,r]})}),t[14]=n,t[15]=r,t[16]=i):i=t[16],i}let q=a.pageTabsAria,ee=En.map(e=>{let{id:t,icon:n}=e;return(0,$.jsxs)(`button`,{id:`workflow-tab-${t}`,type:`button`,role:`tab`,"aria-selected":x===t,"aria-controls":`workflow-panel-${t}`,tabIndex:x===t?0:-1,draggable:!1,className:j(`relative inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`transition-transform duration-150 ease-out active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:scale-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,x===t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>S(t),onKeyDown:e=>{let n=jn(e.key,t);n&&(e.preventDefault(),S(n),window.requestAnimationFrame(()=>{document.getElementById(`workflow-tab-${n}`)?.focus()}))},children:[(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a.pageTabs[t]}),t===`runs`&&V.length>0?(0,$.jsx)(`span`,{className:`rounded-full bg-red-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-red-700 dark:text-red-300`,children:V.length}):null]},t)}),te;t[17]!==a.pageTabsAria||t[18]!==ee?(te=(0,$.jsx)(`nav`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,"aria-label":q,role:`tablist`,children:ee}),t[17]=a.pageTabsAria,t[18]=ee,t[19]=te):te=t[19];let ne;t[20]!==M||t[21]!==F?(ne=M??F?(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-red-500/25 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,role:`alert`,children:M??F}):null,t[20]=M,t[21]=F,t[22]=ne):ne=t[22];let re=x===`runs`?(0,$.jsxs)(`div`,{id:`workflow-panel-runs`,role:`tabpanel`,"aria-labelledby":`workflow-tab-runs`,className:`flex flex-col gap-4 py-4`,children:[V.length>0?(0,$.jsx)(`section`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/8 px-4 py-3`,"aria-labelledby":`workflow-attention-heading`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(Se,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{id:`workflow-attention-heading`,className:`text-sm font-semibold text-fg`,children:a.attentionTitle}),(0,$.jsx)(`span`,{className:`rounded-full bg-amber-500/15 px-2 py-0.5 text-[10px] font-semibold text-amber-800 dark:text-amber-200`,children:V.length})]}),(0,$.jsxs)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:[Jt(V[0]),` · `,nn(V[0].completedAtMs??V[0].createdAtMs,B,i)]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pl-7 lg:pl-0`,children:[(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>T(V[0]),children:a.attentionView}),(0,$.jsx)(N,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void L(V[0].id),children:a.rerun})]})]})}):null,(0,$.jsx)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3`,"aria-label":a.runFiltersAria,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-52 flex-1 sm:max-w-sm`,children:[(0,$.jsx)(it,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:a.runsSearchPlaceholder,className:j(`h-9 w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg shadow-surface`,`placeholder:text-fg-muted`,Ze.focusRingPanel)})]}),(0,$.jsx)(y,{value:g,"aria-label":a.statusFilterAria,onChange:e=>_(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[`all`,`attention`,`running`,`queued`,`succeeded`].map(e=>(0,$.jsx)(b,{value:e,children:a.runStatuses[e]},e))}),(0,$.jsxs)(y,{value:m,"aria-label":a.boardTriggerFilterAria,onChange:e=>h(e.target.value),className:`h-9 min-w-[7.5rem] rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,$.jsx)(b,{value:`all`,children:a.boardTriggerFilterAll}),(0,$.jsx)(b,{value:`automation`,children:a.boardTriggerFilterAutomation}),(0,$.jsx)(b,{value:`webui`,children:a.boardTriggerFilterWebui}),(0,$.jsx)(b,{value:`chat`,children:a.boardTriggerFilterChat}),(0,$.jsx)(b,{value:`api`,children:a.boardTriggerFilterApi})]}),(0,$.jsxs)(y,{value:f,"aria-label":a.boardWorkflowFilterAria,onChange:e=>p(e.target.value),className:`h-9 min-w-40 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,$.jsx)(b,{value:``,children:a.boardWorkflowFilterAll}),s.map(Fn)]}),W?(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:v,children:[(0,$.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),a.clearFilters]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":a.layoutAria,children:[(0,$.jsxs)(`button`,{type:`button`,className:j(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,C===`list`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ze.focusRingPanel),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:[(0,$.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.list]}),(0,$.jsxs)(`button`,{type:`button`,className:j(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,C===`board`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ze.focusRingPanel),"aria-pressed":C===`board`,onClick:()=>w(`board`),children:[(0,$.jsx)(ot,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.board]})]})]})}),C===`list`?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,"aria-labelledby":`workflow-runs-heading`,children:[(0,$.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(`h2`,{id:`workflow-runs-heading`,className:`text-sm font-semibold text-fg`,children:a.allRuns}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-semibold tabular-nums text-fg-muted`,children:U.length})]}),P&&U.length===0?Array.from({length:4}).map(Pn):U.length>0?U.map(e=>(0,$.jsx)(Cn,{run:e,language:r,localeTag:i,nowMs:B,onOpen:T,onOpenChat:D,onCancel:e=>void I(e),onRetry:e=>void L(e)},e.id)):(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,$.jsx)(ye,{className:`size-8 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`mt-3 text-sm font-semibold text-fg`,children:W?a.noRunResultsTitle:a.noRunsTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-5 text-fg-muted`,children:W?a.noRunResultsHint:a.noRunsStartHint}),(0,$.jsx)(N,{type:`button`,variant:W?`secondary`:`primary`,className:`mt-4 h-9 rounded-lg text-xs`,onClick:W?v:()=>S(`library`),children:W?a.clearFilters:a.chooseWorkflow})]})]}):(0,$.jsx)(`div`,{className:`h-[min(72vh,48rem)] min-h-[24rem] w-full sm:min-h-[28rem]`,children:(0,$.jsx)(pn,{runs:U,language:r,localeTag:i,labels:{boardEmptyTitle:a.boardEmptyTitle,boardEmptyHint:a.boardEmptyHint,boardStart:a.chooseWorkflow,loading:a.loading},searchQuery:``,workflowFilterId:``,triggerFilter:`all`,selectedRunId:null,loading:P,onOpenRun:T,onOpenRunChat:D,onCancelRun:e=>void I(e),onRetryRun:e=>void L(e),onStart:()=>S(`library`)})})]}):(0,$.jsx)(`section`,{id:`workflow-panel-library`,role:`tabpanel`,"aria-labelledby":`workflow-tab-library`,className:`py-5`,children:(0,$.jsx)(yn,{definitions:s,runs:l,language:r,projectPresetDefinitionIds:c,onPick:A,onDetail:O,onEdit:k})}),ie;return t[23]!==ne||t[24]!==re||t[25]!==te?(ie=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[96rem] flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[te,ne,re]})}),t[23]=ne,t[24]=re,t[25]=te,t[26]=ie):ie=t[26],ie}function Pn(e,t){return(0,$.jsx)(Mn,{},t)}function Fn(e){return(0,$.jsx)(b,{value:e.id,children:e.title},e.id)}function In(e){return e.clearPageHeader}function Ln(e){return e.setPageHeader}function Rn(){let e=(0,Q.c)(131),t=k(Wn),n;e[0]===t?n=e[1]:(n=O(t),e[0]=t,e[1]=n);let r=n.workflows,i=t===`zh`?`zh-CN`:`en-US`,s=A(Un),c=!!s,l=a(),[u,d]=o(),f;e[2]===u?f=e[3]:(f=u.get(`q`)??``,e[2]=u,e[3]=f);let p=f,m;e[4]===u?m=e[5]:(m=u.get(`wf`)?.trim()??``,e[4]=u,e[5]=m);let h=m,g;e[6]===u?g=e[7]:(g=u.get(`trigger`)?.trim()||`all`,e[6]=u,e[7]=g);let _=g,v,y,b,x,S;if(e[8]!==u){let t=u.get(`status`)?.trim()??``,n=u.get(`tab`)?.trim()??``,r=u.get(`layout`)?.trim()??``;v=u.get(`agent`)?.trim()??``,b=u.get(`projectId`)?.trim()||void 0,y=be.has(n)?n:`runs`,x=K.has(r)?r:`list`,S=B.has(t)?t:`all`,e[8]=u,e[9]=v,e[10]=y,e[11]=b,e[12]=x,e[13]=S}else v=e[9],y=e[10],b=e[11],x=e[12],S=e[13];let C=S,[w,T]=(0,Z.useState)(null),E;e[14]!==c||e[15]!==s?(E=c?[`workflow-agents`,s]:null,e[14]=c,e[15]=s,e[16]=E):E=e[16];let D;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[17]=D):D=e[17];let j=M(E,st,D),N;bb0:{let e=j.data?.agents??[];if(v&&(e.length===0||e.some(e=>e.id===v))){N=v;break bb0}N=j.data?.defaultId}let P=N,F;e[18]!==c||e[19]!==s?(F=c?[`workflow-definitions`,s]:null,e[18]=c,e[19]=s,e[20]=F):F=e[20];let I;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(I={revalidateOnFocus:!1},e[21]=I):I=e[21];let L=M(F,yt,I),R;e[22]!==c||e[23]!==b||e[24]!==s?(R=c&&b?[`workflow-project-presets`,s,b]:null,e[22]=c,e[23]=b,e[24]=s,e[25]=R):R=e[25];let z;e[26]===b?z=e[27]:(z=()=>ft(b),e[26]=b,e[27]=z);let V;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(V={revalidateOnFocus:!1},e[28]=V):V=e[28];let H=M(R,z,V),U;e[29]!==c||e[30]!==P||e[31]!==b||e[32]!==s?(U=c&&P?[`workflow-runs`,s,P,b??``]:null,e[29]=c,e[30]=P,e[31]=b,e[32]=s,e[33]=U):U=e[33];let W;e[34]!==P||e[35]!==b?(W=()=>gt(100,{ownerAgentId:P,projectId:b}),e[34]=P,e[35]=b,e[36]=W):W=e[36];let G;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1,refreshInterval:Vn},e[37]=G):G=e[37];let q=M(U,W,G),ee;e[38]===L.data?ee=e[39]:(ee=L.data??[],e[38]=L.data,e[39]=ee);let ne=ee,re;e[40]===q.data?re=e[41]:(re=q.data??[],e[40]=q.data,e[41]=re);let ie=re,ae;e[42]===d?ae=e[43]:(ae=e=>{d(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},e[42]=d,e[43]=ae);let J=ae,oe;e[44]===J?oe=e[45]:(oe=e=>J(t=>{let n=e.trim();n?t.set(`q`,n):t.delete(`q`)}),e[44]=J,e[45]=oe);let se=oe,Y;e[46]===J?Y=e[47]:(Y=e=>J(t=>{let n=e.trim();n?t.set(_e,n):t.delete(_e)}),e[46]=J,e[47]=Y);let ce=Y,le;e[48]===J?le=e[49]:(le=e=>J(t=>{let n=e.trim();n?t.set(`wf`,n):t.delete(`wf`)}),e[48]=J,e[49]=le);let ue=le,de;e[50]===J?de=e[51]:(de=e=>J(t=>{e&&e!==`all`?t.set(qe,e):t.delete(qe)}),e[50]=J,e[51]=de);let fe=de,X;e[52]===J?X=e[53]:(X=e=>J(t=>{e===`runs`?t.delete(`tab`):t.set(`tab`,e)}),e[52]=J,e[53]=X);let pe=X,me;e[54]===J?me=e[55]:(me=e=>J(t=>{e===`list`?t.delete(te):t.set(te,e)}),e[54]=J,e[55]=me);let he=me,ge;e[56]===J?ge=e[57]:(ge=e=>J(t=>{e===`all`?t.delete(Ye):t.set(Ye,e)}),e[56]=J,e[57]=ge);let ye=ge,xe;e[58]===J?xe=e[59]:(xe=()=>J(Bn),e[58]=J,e[59]=xe);let Se=xe,Ce;if(e[60]!==P||e[61]!==b){let t=new URLSearchParams;P&&t.set(`agentId`,P),b&&t.set(`projectId`,b),Ce=t.size?`?${t.toString()}`:``,e[60]=P,e[61]=b,e[62]=Ce}else Ce=e[62];let we=Ce,Te;e[63]!==l||e[64]!==we?(Te=e=>l(`/workflows/${e.id}${we}`),e[63]=l,e[64]=we,e[65]=Te):Te=e[65];let Ee=Te,De=Ee,Oe;e[66]!==l||e[67]!==we?(Oe=e=>{let t=new URLSearchParams(we.slice(1));e.metadata.source!==`user`&&t.set(`copy`,e.id),l(e.metadata.source===`user`?`/workflows/${e.id}/edit${we}`:`/workflows/new${t.size?`?${t.toString()}`:``}`)},e[66]=l,e[67]=we,e[68]=Oe):Oe=e[68];let ke=Oe,Ae;e[69]!==l||e[70]!==we?(Ae=e=>l(`/workflows/runs/${e.id}${we}`),e[69]=l,e[70]=we,e[71]=Ae):Ae=e[71];let je=Ae,Ne;e[72]===l?Ne=e[73]:(Ne=e=>{let t=Wt(e);t&&l(xt(t))},e[72]=l,e[73]=Ne);let Pe=Ne,Fe;e[74]!==r.cancelFailed||e[75]!==P||e[76]!==q?(Fe=async e=>{try{await Me(e,{ownerAgentId:P}),await q.mutate()}catch(e){let t=e;T(t instanceof Error?t.message:r.cancelFailed)}},e[74]=r.cancelFailed,e[75]=P,e[76]=q,e[77]=Fe):Fe=e[77];let Ie=Fe,Le;e[78]!==r.retryFailed||e[79]!==l||e[80]!==P||e[81]!==we?(Le=async e=>{try{l(`/workflows/runs/${(await ve(e,{ownerAgentId:P})).runId}${we}`)}catch(e){let t=e;T(t instanceof Error?t.message:r.retryFailed)}},e[78]=r.retryFailed,e[79]=l,e[80]=P,e[81]=we,e[82]=Le):Le=e[82];let Re=Le,ze,Be;e[83]===q?(ze=e[84],Be=e[85]):(ze=()=>{let e=()=>void q.mutate();return window.addEventListener(`workflow-run-updated`,e),window.addEventListener(`workflow-run-error`,e),()=>{window.removeEventListener(`workflow-run-updated`,e),window.removeEventListener(`workflow-run-error`,e)}},Be=[q],e[83]=q,e[84]=ze,e[85]=Be),(0,Z.useEffect)(ze,Be);let Ve;e[86]!==j||e[87]!==L||e[88]!==H||e[89]!==q?(Ve=()=>{Promise.all([j.mutate(),L.mutate(),H.mutate(),q.mutate()])},e[86]=j,e[87]=L,e[88]=H,e[89]=q,e[90]=Ve):Ve=e[90];let He=Ve,Ue=j.isLoading||L.isLoading||q.isLoading||H.isLoading,We=j.error?.message??L.error?.message??q.error?.message??H.error?.message??null,Ge;e[91]===j.data?.agents?Ge=e[92]:(Ge=j.data?.agents??[],e[91]=j.data?.agents,e[92]=Ge);let Ke;e[93]===H.data?Ke=e[94]:(Ke=new Set((H.data??[]).map(zn)),e[93]=H.data,e[94]=Ke);let Je;return e[95]!==w||e[96]!==Ie||e[97]!==Se||e[98]!==ne||e[99]!==We||e[100]!==c||e[101]!==r||e[102]!==t||e[103]!==Ue||e[104]!==i||e[105]!==Ee||e[106]!==je||e[107]!==Pe||e[108]!==ke||e[109]!==P||e[110]!==y||e[111]!==b||e[112]!==He||e[113]!==Re||e[114]!==x||e[115]!==ie||e[116]!==p||e[117]!==ce||e[118]!==pe||e[119]!==he||e[120]!==se||e[121]!==ye||e[122]!==fe||e[123]!==ue||e[124]!==De||e[125]!==C||e[126]!==Ge||e[127]!==Ke||e[128]!==_||e[129]!==h?(Je={language:t,localeTag:i,labels:r,hasToken:c,searchQuery:p,setSearchQuery:se,ownerAgentId:P,projectId:b,agentOptions:Ge,setOwnerAgentId:ce,workflowFilterId:h,setWorkflowFilterId:ue,triggerFilter:_,setTriggerFilter:fe,statusFilter:C,setStatusFilter:ye,clearRunFilters:Se,pageTab:y,setPageTab:pe,runLayout:x,setRunLayout:he,definitions:ne,projectPresetDefinitionIds:Ke,runs:ie,openDefinitionDetails:Ee,startWorkflow:De,openWorkflowEditor:ke,openRunDetails:je,openRunInChat:Pe,actionError:w,loading:Ue,error:We,refreshAll:He,cancelRun:Ie,retryRun:Re},e[95]=w,e[96]=Ie,e[97]=Se,e[98]=ne,e[99]=We,e[100]=c,e[101]=r,e[102]=t,e[103]=Ue,e[104]=i,e[105]=Ee,e[106]=je,e[107]=Pe,e[108]=ke,e[109]=P,e[110]=y,e[111]=b,e[112]=He,e[113]=Re,e[114]=x,e[115]=ie,e[116]=p,e[117]=ce,e[118]=pe,e[119]=he,e[120]=se,e[121]=ye,e[122]=fe,e[123]=ue,e[124]=De,e[125]=C,e[126]=Ge,e[127]=Ke,e[128]=_,e[129]=h,e[130]=Je):Je=e[130],Je}function zn(e){return e.definitionId}function Bn(e){e.delete(`q`),e.delete(`wf`),e.delete(qe),e.delete(Ye)}function Vn(e){return e?.some(Hn)?3e3:0}function Hn(e){return e.status===`queued`||e.status===`running`}function Un(e){return e.token}function Wn(e){return e.language}function Gn(){let e=(0,Q.c)(2),t=Rn(),n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(Nn,{vm:t}),e[0]=t,e[1]=n),n}function Kn(e){return{title:e.title,description:e.description,version:e.version,inputSchema:e.inputSchema,outputSchema:e.outputSchema,defaults:e.defaults,tags:e.metadata.tags,whenToUse:e.metadata.whenToUse,estimatedAgents:e.metadata.estimatedAgents,examplePrompts:e.metadata.examplePrompts,i18n:e.metadata.i18n,permissions:e.permissions,resources:e.resources,connectors:e.connectors}}function qn(e){let t=(0,Q.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=wt(),t[0]=n):n=t[0];let r=n,i;return t[1]===e?i=t[2]:(i=(0,$.jsx)(Tt,{...e,language:r}),t[1]=e,t[2]=i),i}function Jn({initialSource:e,resetKey:t,fileName:n,language:r,readOnly:i=!0,error:a,onChange:o,allowImport:s=!1,className:c=`h-[28rem]`}){let l=Yn(r),u=P(e=>e.resolved)===`dark`,[d,f]=(0,Z.useState)(e),[p,m]=(0,Z.useState)(0),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),w=(0,Z.useRef)(e);w.current=e,(0,Z.useEffect)(()=>{f(w.current),m(e=>e+1)},[t]),(0,Z.useEffect)(()=>{let e=e=>{let t=S.current;t&&y(Xn(t.startHeight+e.clientY-t.startY))},t=()=>{S.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t),t()}},[]);let T=e=>{b.current&&(e.preventDefault(),S.current={startY:e.clientY,startHeight:b.current.getBoundingClientRect().height},document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`)},E=e=>{e.key!==`ArrowUp`&&e.key!==`ArrowDown`||(e.preventDefault(),y(Xn((_??b.current?.getBoundingClientRect().height??448)+(e.key===`ArrowDown`?24:-24))))},O=e=>{f(e),o?.(e)};return(0,$.jsxs)(`section`,{ref:b,className:`relative flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge bg-surface-base ${c}`,style:_===null?void 0:{height:_,minHeight:280,flex:`none`},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-auto flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:l.title}),(0,$.jsx)(`span`,{className:a?`text-danger`:`text-success`,children:a?l.invalid:l.valid})]}),i?null:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:!!a,onClick:()=>{try{O(`${JSON.stringify(JSON.parse(d),null,2)}\n`),m(e=>e+1)}catch{}},children:l.format}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{ref:x,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&t.text().then(e=>{O(e),m(e=>e+1)})}}),(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>x.current?.click(),children:[(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),l.import]})]}):null,(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void D(d).then(e=>{e&&(g(!0),window.setTimeout(()=>g(!1),1500))}),children:[h?(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),h?l.copied:l.copy]}),(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>{let e=URL.createObjectURL(new Blob([d],{type:`application/json;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=n,t.click(),URL.revokeObjectURL(e)},children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),l.download]})]}),a?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-danger/25 bg-danger/5 px-4 py-2 text-xs text-danger`,children:a}):null,(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(qn,{initialContent:d,onChange:O,isDark:u,readOnly:i,lineWrap:!1},`${t}:${p}`)}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":l.resize,title:l.resize,tabIndex:0,className:`group absolute inset-x-0 bottom-0 z-10 flex h-3 touch-none cursor-row-resize items-end justify-center border-t border-transparent outline-none hover:border-accent/40 focus:border-accent/40`,onPointerDown:T,onKeyDown:E,onDoubleClick:()=>y(null),children:(0,$.jsx)(`span`,{className:`mb-1 h-0.5 w-10 rounded-full bg-edge-strong transition-colors group-hover:bg-accent group-focus:bg-accent`})})]})}function Yn(e){return e===`zh`?{title:`工作流定义 · JSON`,valid:`有效`,invalid:`需要修复`,format:`格式化`,copy:`复制`,copied:`已复制`,download:`下载`,import:`导入`,resize:`上下拖动调整源码区域高度`}:{title:`Workflow definition · JSON`,valid:`Valid`,invalid:`Needs attention`,format:`Format`,copy:`Copy`,copied:`Copied`,download:`Download`,import:`Import`,resize:`Drag vertically to resize the source area`}}function Xn(e){let t=typeof window>`u`?960:Math.max(280,window.innerHeight-96);return Math.min(t,Math.max(280,Math.round(e)))}function Zn(e){return Qn(e.name,e.graph,Kn(e))}function Qn(e,t,n){return{formatVersion:1,name:e,manifest:structuredClone(n),graph:structuredClone(t)}}function $n(e){return Qn(e.name,e.graph,{title:e.title,description:e.description,version:e.version,defaults:e.defaults,tags:e.tags,estimatedAgents:e.estimatedAgents,permissions:e.permissions,resources:e.resources,connectors:e.connectors,inputSchema:e.inputSchema,outputSchema:e.outputSchema,whenToUse:e.whenToUse,examplePrompts:e.examplePrompts,i18n:e.i18n})}function er(e,t){let n=lr(e),r=lr(t);if(n.length*r.length>25e4)return ur(n,r);let i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({kind:`same`,beforeLine:o+1,afterLine:s+1,text:n[o]}),o+=1,s+=1):i[o+1][s]>=i[o][s+1]?(a.push({kind:`removed`,beforeLine:o+1,text:n[o]}),o+=1):(a.push({kind:`added`,afterLine:s+1,text:r[s]}),s+=1);for(;o<n.length;)a.push({kind:`removed`,beforeLine:++o,text:n[o-1]});for(;s<r.length;)a.push({kind:`added`,afterLine:++s,text:r[s-1]});return a}function tr(e){return`${JSON.stringify(e,null,2)}\n`}function nr(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Invalid JSON.`}}if(!or(t))return cr(`The source root must be a JSON object.`);if(t.formatVersion!==1)return cr(`formatVersion must be 1.`);if(typeof t.name!=`string`||!/^[a-z][a-z0-9_-]*$/.test(t.name))return cr(`name must use lowercase letters, numbers, underscores, or hyphens.`);if(!or(t.manifest))return cr(`manifest must be an object.`);let n=rr(t.manifest);if(n)return cr(n);if(!or(t.graph))return cr(`graph must be an object.`);if(t.graph.schemaVersion!==1)return cr(`graph.schemaVersion must be 1.`);if(!Array.isArray(t.graph.nodes))return cr(`graph.nodes must be an array.`);if(!Array.isArray(t.graph.edges))return cr(`graph.edges must be an array.`);for(let[e,n]of t.graph.nodes.entries()){let t=ir(n,e);if(t)return cr(t)}for(let[e,n]of t.graph.edges.entries()){let t=ar(n,e);if(t)return cr(t)}return{ok:!0,document:t}}function rr(e){for(let t of[`title`,`description`,`version`,`whenToUse`])if(e[t]!==void 0&&typeof e[t]!=`string`)return`manifest.${t} must be a string.`;return e.tags!==void 0&&(!Array.isArray(e.tags)||e.tags.some(e=>typeof e!=`string`))?`manifest.tags must be an array of strings.`:e.defaults!==void 0&&!or(e.defaults)?`manifest.defaults must be an object.`:null}function ir(e,t){return or(e)?typeof e.id!=`string`||!e.id?`graph.nodes[${t}].id must be a non-empty string.`:[`input`,`agent`,`decision`,`merge`,`output`].includes(String(e.kind))?typeof e.title==`string`?!or(e.position)||!sr(e.position.x)||!sr(e.position.y)?`graph.nodes[${t}].position must contain finite x and y values.`:or(e.config)?null:`graph.nodes[${t}].config must be an object.`:`graph.nodes[${t}].title must be a string.`:`graph.nodes[${t}].kind is invalid.`:`graph.nodes[${t}] must be an object.`}function ar(e,t){if(!or(e))return`graph.edges[${t}] must be an object.`;for(let n of[`id`,`source`,`target`])if(typeof e[n]!=`string`||!e[n])return`graph.edges[${t}].${n} must be a non-empty string.`;return e.sourcePort!==void 0&&![`true`,`false`,`default`].includes(String(e.sourcePort))?`graph.edges[${t}].sourcePort is invalid.`:null}function or(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function sr(e){return typeof e==`number`&&Number.isFinite(e)}function cr(e){return{ok:!1,error:e}}function lr(e){let t=e.split(`
|
|
2
|
-
`);return t.at(-1)===``&&t.pop(),t}function ur(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-r-1]===t[t.length-r-1];)r+=1;return[...e.slice(0,n).map((e,t)=>({kind:`same`,beforeLine:t+1,afterLine:t+1,text:e})),...e.slice(n,e.length-r).map((e,t)=>({kind:`removed`,beforeLine:n+t+1,text:e})),...t.slice(n,t.length-r).map((e,t)=>({kind:`added`,afterLine:n+t+1,text:e})),...e.slice(e.length-r).map((n,i)=>({kind:`same`,beforeLine:e.length-r+i+1,afterLine:t.length-r+i+1,text:n}))]}function dr(e){let t=(0,Q.c)(31),{comparison:n,language:r,onClose:i}=e,a;t[0]===n?a=t[1]:(a=n?er(n.before,n.after):[],t[0]=n,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=o.filter(pr),t[2]=o,t[3]=s);let c=s.length,l=!!n,d;t[4]===i?d=t[5]:(d=e=>{e||i()},t[4]=i,t[5]=d);let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),t[6]=v):v=t[6];let y=r===`zh`?`源码变更`:`Source changes`,b;t[7]===y?b=t[8]:(b=(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:y}),t[7]=y,t[8]=b);let x=n?`${n.beforeLabel} → ${n.afterLabel} · ${r===`zh`?`${c} 行变更`:`${c} changed lines`}`:``,S;t[9]===x?S=t[10]:(S=(0,$.jsx)(f,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[9]=x,t[10]=S);let C;t[11]!==b||t[12]!==S?(C=(0,$.jsxs)(`div`,{children:[b,S]}),t[11]=b,t[12]=S,t[13]=C):C=t[13];let w=r===`zh`?`关闭`:`Close`,T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(E,{className:`size-4`}),t[14]=T):T=t[14];let D;t[15]===w?D=t[16]:(D=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":w,children:T})}),t[15]=w,t[16]=D);let O;t[17]!==C||t[18]!==D?(O=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[C,D]}),t[17]=C,t[18]=D,t[19]=O):O=t[19];let k;t[20]===o?k=t[21]:(k=o.map(fr),t[20]=o,t[21]=k);let A;t[22]===k?A=t[23]:(A=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-surface-base py-3 font-mono text-xs leading-5`,children:k}),t[22]=k,t[23]=A);let j;t[24]!==O||t[25]!==A?(j=(0,$.jsxs)(m,{children:[v,(0,$.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(46rem,calc(100vh-2rem))] w-[min(64rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-float`,children:[O,A]})]}),t[24]=O,t[25]=A,t[26]=j):j=t[26];let M;return t[27]!==j||t[28]!==l||t[29]!==d?(M=(0,$.jsx)(_,{open:l,onOpenChange:d,children:j}),t[27]=j,t[28]=l,t[29]=d,t[30]=M):M=t[30],M}function fr(e,t){return(0,$.jsxs)(`div`,{className:e.kind===`added`?`grid min-w-max grid-cols-[3rem_3rem_1.5rem_minmax(40rem,1fr)] bg-success/10 text-success`:e.kind===`removed`?`grid min-w-max grid-cols-[3rem_3rem_1.5rem_minmax(40rem,1fr)] bg-danger/10 text-danger`:`grid min-w-max grid-cols-[3rem_3rem_1.5rem_minmax(40rem,1fr)] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`select-none border-r border-edge-subtle pr-2 text-right text-fg-subtle`,children:e.beforeLine??``}),(0,$.jsx)(`span`,{className:`select-none border-r border-edge-subtle pr-2 text-right text-fg-subtle`,children:e.afterLine??``}),(0,$.jsx)(`span`,{className:`select-none text-center`,children:e.kind===`added`?`+`:e.kind===`removed`?`−`:` `}),(0,$.jsx)(`span`,{className:`whitespace-pre pr-5`,children:e.text||` `})]},`${t}:${e.kind}`)}function pr(e){return e.kind!==`same`}function mr(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;t<1e3;t+=1){let r=`${e}_${t}`;if(!n.has(r))return r}return`${e}_${Date.now()}`}function hr(e){if(!(e instanceof Error))return null;let t=e;if(t.status!==409||!t.body||typeof t.body!=`object`)return null;let n=t.body,r=typeof n.currentRevision==`number`?n.currentRevision:0;return n.code===`WORKFLOW_NAME_EXISTS`&&typeof n.name==`string`&&typeof n.suggestedName==`string`?{code:`WORKFLOW_NAME_EXISTS`,name:n.name,currentRevision:r,suggestedName:n.suggestedName}:n.code===`WORKFLOW_REVISION_CONFLICT`?{code:`WORKFLOW_REVISION_CONFLICT`,currentRevision:r}:null}var gr={padding:.24,minZoom:.45,maxZoom:1};function _r({language:e,ownerAgentId:t,saving:n,initialDraft:r,initialName:a,existingNames:o,saveConflict:c,onSave:u,onSaveAndStart:d,onClearSaveConflict:f,onReloadLatest:p}){let m=Ir(e),[h,g]=(0,Z.useState)(`my_workflow`),[_,v]=(0,Z.useState)(()=>kr()),[y,b]=(0,Z.useState)(()=>({title:m.untitled,description:``,tags:[`custom`]})),[x,S]=(0,Z.useState)(`agent-1`),[C,w,T]=Bt(_.nodes.map(e=>Dr(e,e.id===`agent-1`))),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[A,M]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),[I,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(!!r),[H,U]=(0,Z.useState)(null),[W,K]=(0,Z.useState)(`idle`),[q,te]=(0,Z.useState)(0),[re,ie]=(0,Z.useState)([]),[ae,J]=(0,Z.useState)(null),oe=(0,Z.useRef)(``),se=(0,Z.useRef)(``),Y=(0,Z.useRef)(void 0),ce=(0,Z.useRef)(void 0),le=(0,Z.useRef)(``),ue=(0,Z.useRef)(!1),de=(0,Z.useRef)(null),[fe,X]=(0,Z.useState)(0),[pe,me]=(0,Z.useState)(`canvas`),[he,ge]=(0,Z.useState)(``),[_e,ve]=(0,Z.useState)(0),[be,xe]=(0,Z.useState)(null),[Se,Ce]=(0,Z.useState)(null),[we,Ee]=(0,Z.useState)(null),De=s(!!be);i((0,Z.useCallback)(e=>{be&&(e.preventDefault(),e.returnValue=``)},[be])),(0,Z.useEffect)(()=>{De.state===`blocked`&&(window.confirm(e===`zh`?`源码仍有错误。要放弃这些修改吗?`:`The source still has errors. Discard these changes?`)?De.proceed():De.reset())},[De,e]),(0,Z.useEffect)(()=>{let e=`${r?.mode??`new`}:${r?.name??a}:${r?.baseRevision??0}:${r?.repairPrompt??``}`;if(oe.current===e)return;oe.current=e,g(r?.name??a),v(structuredClone(r?.graph??kr())),X(e=>e+1),b(structuredClone(r?.manifest??{title:m.untitled,description:``,tags:[`custom`]})),S(r?.graph.nodes.find(e=>e.kind===`agent`)?.id??`agent-1`),D(r?.repairPrompt??``),F(null),R(null),B(!!r),k(``),U(null),te(r?.baseRevision??0),ie([]),J(null),Y.current=void 0,ce.current=void 0,K(`idle`),me(`canvas`);let t=tr(Qn(r?.name??a,r?.graph??kr(),r?.manifest??{title:m.untitled,description:``,tags:[`custom`]}));le.current=t,ge(t),ve(e=>e+1),xe(null),Ce(null),Ee(null)},[m.untitled,r,a]),(0,Z.useEffect)(()=>{r?.mode===`edit`&&ke(r.name).then(ie).catch(()=>ie([]))},[r?.mode,r?.name]),(0,Z.useEffect)(()=>{if(!h.trim())return;let e=!0,t=window.setTimeout(()=>{L(h,_,y).then(t=>{e&&U(t)}).catch(()=>{e&&U(null)})},350);return()=>{e=!1,window.clearTimeout(t)}},[_,y,h]),(0,Z.useEffect)(()=>{if(!h.trim())return;K(`saving`);let e=window.setTimeout(()=>{G({id:Y.current,workflowName:h,graph:_,manifest:y,baseRevision:q,expectedUpdatedAtMs:ce.current}).then(e=>{Y.current=e.id,ce.current=e.updatedAtMs,K(`saved`)}).catch(()=>K(`error`))},900);return()=>window.clearTimeout(e)},[q,_,y,h]);let Oe=(0,Z.useMemo)(()=>jr(_,P?.graph??null),[_,P?.graph]),Ae=(0,Z.useMemo)(()=>{if(!P)return _;let e=new Set(P.graph.nodes.map(e=>e.id)),t=_.nodes.filter(t=>!e.has(t.id));return{...P.graph,nodes:[...P.graph.nodes,...t]}},[_,P]);(0,Z.useLayoutEffect)(()=>{w(e=>{let t=new Map(e.map(e=>[e.id,e]));return Ae.nodes.map(e=>({...t.get(e.id),...Dr(e,e.id===x,Oe.nodeStates.get(e.id))}))})},[Ae.nodes,Oe.nodeStates,x,w]),(0,Z.useEffect)(()=>{let e=de.current;if(!e||Ae.nodes.length===0)return;let t=window.requestAnimationFrame(()=>{e.fitView(gr)});return()=>window.cancelAnimationFrame(t)},[Ae.nodes.length,fe]);let je=(0,Z.useMemo)(()=>Ae.edges.map(Or),[Ae.edges]),Me=_.nodes.find(e=>e.id===x)??null,Ne=(0,Z.useMemo)(()=>new Set(o),[o]),Fe=r?.mode!==`edit`&&Ne.has(h),Ie=Fe?mr(h,Ne):h,Le=H?.valid===!0&&!Fe&&!n&&!A&&be===null,Re=e=>{if(!(e===pe||P)&&!(e===`canvas`&&be)){if(e===`source`){let e=tr(Qn(h,_,y));le.current=e,ge(e),ve(e=>e+1),xe(null)}me(e)}},ze=t=>{le.current=t;let n=nr(t);if(!n.ok){xe(n.error);return}if(r?.mode===`edit`&&n.document.name!==r.name){xe(e===`zh`?`已发布工作流的内部名称不能修改。`:`The internal name of a published workflow cannot be changed.`);return}xe(null),U(null),g(n.document.name),v(structuredClone(n.document.graph)),b(structuredClone(n.document.manifest)),S(e=>n.document.graph.nodes.some(t=>t.id===e)?e:n.document.graph.nodes.find(e=>e.kind===`agent`)?.id??``),X(e=>e+1)},Ve=e=>{if(g(e),pe!==`source`)return;let t=nr(le.current);if(!t.ok)return;let n=tr({...t.document,name:e});le.current=n,ge(n),ve(e=>e+1),ze(n)},Ue=e=>{let t=Kn(e);if(g(e.name),v(structuredClone(e.graph)),b(t),te(e.revision),xe(null),pe===`source`){let n=tr(Qn(e.name,e.graph,t));le.current=n,ge(n),ve(e=>e+1)}},We=(0,Z.useCallback)(e=>{v(t=>{let n=t.nodes.map(t=>t.id!==e.id||t.position.x===e.position.x&&t.position.y===e.position.y?t:{...t,position:e.position});return n.some((e,n)=>e!==t.nodes[n])?{...t,nodes:n}:t})},[]),Ge=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&v(e=>({...e,edges:Nt(t,e.edges.map(Or)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),Ke=(0,Z.useCallback)(e=>{!e.source||!e.target||v(t=>({...t,edges:Ft({...e,id:`edge-${crypto.randomUUID()}`},t.edges.map(Or)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),qe=(0,Z.useCallback)((e,t)=>{v(n=>({...n,nodes:n.nodes.map(n=>n.id===e?t(n):n)}))},[]),Je=e=>{let t=`${e}-${crypto.randomUUID().slice(0,8)}`,n=Ar(e,t,_.nodes.length);v(e=>{let r=e.nodes.find(e=>e.id===x&&e.kind!==`output`),i=r?[{id:`edge-${crypto.randomUUID()}`,source:r.id,target:t}]:[];return{...e,nodes:[...e.nodes,n],edges:[...e.edges,...i]}}),X(e=>e+1),S(t)},Ye=()=>{!Me||Me.kind===`input`||Me.kind===`output`||(v(e=>({...e,nodes:e.nodes.filter(e=>e.id!==Me.id),edges:e.edges.filter(e=>e.source!==Me.id&&e.target!==Me.id)})),X(e=>e+1),S(``))},Qe=(0,Z.useCallback)(async()=>{if(E.trim()){M(!0);try{let n=await Pe({prompt:E,agentId:t,language:e===`zh`?`zh`:`en`,mode:r||_.nodes.length>3?`improve`:`create`,existingGraph:_}),i=r?.mode===`edit`?r.name:mr(n.name,Ne);R(i===n.name?null:n.name),F(i===n.name?n:{...n,name:i}),B(!0),X(e=>e+1),S(n.graph.nodes.find(e=>e.kind===`agent`)?.id??``)}finally{M(!1)}}},[E,Ne,_,r,e,t]);(0,Z.useEffect)(()=>{let e=r?.repairPrompt?.trim();!e||E.trim()!==e||A||P||se.current===e||(se.current=e,Qe())},[E,Qe,A,r?.repairPrompt,P]);let $e=()=>{F(null),R(null),S(_.nodes.find(e=>e.kind===`agent`)?.id??``),X(e=>e+1)},et=async()=>{if(!(!P||n||ue.current)){ue.current=!0;try{let e=await u({name:P.name,graph:P.graph,manifest:P.manifest,expectedRevision:q});if(!e)return;Ue(e),U(P.validation),F(null),R(null),D(``),S(e.graph.nodes.find(e=>e.kind===`agent`)?.id??``),Y.current&&await rt(Y.current).catch(()=>void 0)}catch{}finally{ue.current=!1}}},nt=async e=>{if(!Le||ue.current)return;ue.current=!0;let t={name:h,graph:_,manifest:y,expectedRevision:q};try{if(e)await d({...t,goal:O.trim()||y.description||h});else{let e=await u(t);if(!e)return;Ue(e)}Y.current&&await rt(Y.current).catch(()=>void 0)}catch{return}finally{ue.current=!1}},it=async e=>{if(!(ae!==null||r?.mode!==`edit`)){J(e);try{let t=await mt(r.name,e,q);Ue(t),X(e=>e+1),S(t.graph.nodes.find(e=>e.kind===`agent`)?.id??``),ie(await ke(r.name))}finally{J(null)}}},at=async t=>{if(!(Se!==null||r?.mode!==`edit`)){Ce(t);try{Ee({before:tr(Zn(await Be(r.name,t))),after:tr(Qn(h,_,y)),beforeLabel:`v${t}`,afterLabel:e===`zh`?`当前草稿 · v${q}`:`Current draft · v${q}`})}finally{Ce(null)}}};return(0,$.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(l,{to:`/workflows`,className:j(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),"aria-label":e===`zh`?`返回工作流`:`Back to workflows`,children:(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:r?.mode===`edit`?m.editTitle:m.createTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:m.subtitle})]}),z?(0,$.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,role:`tablist`,"aria-label":e===`zh`?`工作流编辑视图`:`Workflow editor view`,children:[`canvas`,`source`].map(t=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":pe===t,disabled:!!P||t===`canvas`&&!!be,className:j(`rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,pe===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),onClick:()=>Re(t),children:t===`canvas`?e===`zh`?`画布`:`Canvas`:e===`zh`?`源码`:`Source`},t))}):null,(0,$.jsx)(`span`,{className:j(`text-xs`,W===`error`?`text-danger`:`text-fg-subtle`),children:W===`saving`?m.savingDraft:W===`saved`?m.savedDraft:W===`error`?m.draftError:``})]}),c?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:c.code===`WORKFLOW_NAME_EXISTS`?e===`zh`?`内部名称“${c.name}”已被使用。`:`The internal name “${c.name}” is already in use.`:e===`zh`?`这个工作流已更新到版本 ${c.currentRevision}。`:`This workflow has changed to revision ${c.currentRevision}.`}),c.code===`WORKFLOW_NAME_EXISTS`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{variant:`secondary`,className:`h-8`,onClick:()=>{Ve(c.suggestedName),f()},children:e===`zh`?`使用 ${c.suggestedName}`:`Use ${c.suggestedName}`}),(0,$.jsx)(l,{className:`text-sm font-medium text-accent-fg hover:underline`,to:`/workflows/${encodeURIComponent(c.name)}`,children:e===`zh`?`打开已有工作流`:`Open existing`})]}):(0,$.jsx)(N,{variant:`secondary`,className:`h-8`,onClick:p,children:e===`zh`?`加载最新版本`:`Load latest`})]}):null,!c&&Fe?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e===`zh`?`内部名称“${h}”已被使用。`:`The internal name “${h}” is already in use.`}),(0,$.jsx)(N,{variant:`secondary`,className:`h-8`,onClick:()=>Ve(Ie),children:e===`zh`?`使用 ${Ie}`:`Use ${Ie}`})]}):null,!c&&!Fe&&I&&P?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-accent/20 bg-accent/5 px-4 py-2 text-sm text-fg-muted`,children:e===`zh`?`“${I}”已存在,方案将保存为“${P.name}”。`:`“${I}” already exists. This proposal will be saved as “${P.name}”.`}):null,z?(0,$.jsxs)($.Fragment,{children:[pe===`source`?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto bg-surface-base p-4`,children:(0,$.jsx)(Jn,{initialSource:he,resetKey:_e,fileName:`${h||`workflow`}.workflow.json`,language:e,readOnly:!1,error:be,onChange:ze,allowImport:!0,className:`min-h-[32rem] flex-1`})}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,$.jsxs)(`section`,{className:`flex min-h-[32rem] min-w-0 flex-1 flex-col bg-surface-base lg:min-h-0`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-2 min-w-36`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.flowTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:m.stepCount(_.nodes.length)})]}),(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Je(`agent`),children:[(0,$.jsx)(St,{className:`size-3.5`}),m.addAgent]}),(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Je(`decision`),children:[(0,$.jsx)(ye,{className:`size-3.5`}),m.addDecision]}),(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Je(`merge`),children:[(0,$.jsx)(Xe,{className:`size-3.5`}),m.addMerge]}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-subtle`,children:m.canvasHint})]}),(0,$.jsx)(`div`,{className:`relative min-h-72 flex-1`,children:_.nodes.length>0?(0,$.jsxs)(Rt,{"aria-label":m.flowAria,nodes:C,edges:je,nodeTypes:wr,onNodesChange:T,onEdgesChange:Ge,onConnect:Ke,nodesDraggable:!P,nodesConnectable:!P,onNodeClick:(e,t)=>S(t.id),onNodeDragStart:(e,t)=>S(t.id),onNodeDragStop:(e,t)=>We(t),onInit:e=>{de.current=e,window.requestAnimationFrame(()=>{e.fitView(gr)})},fitView:!0,fitViewOptions:gr,minZoom:.25,maxZoom:1.5,deleteKeyCode:null,proOptions:{hideAttribution:!0},children:[(0,$.jsx)(Vt,{color:`var(--color-edge)`,gap:22,size:1}),(0,$.jsx)(Lt,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-fg-muted`,children:m.emptyFlow})})]}),(0,$.jsx)(`aside`,{className:`flex w-full shrink-0 flex-col border-t border-edge bg-surface-panel lg:w-[22rem] lg:border-l lg:border-t-0`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:P?(0,$.jsx)(yr,{proposal:P,diff:Oe,copy:m,saving:n,onAccept:()=>void et(),onReject:$e}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`label`,{className:`block text-xs font-medium text-fg`,htmlFor:`workflow-title`,children:m.humanTitle}),(0,$.jsx)(`input`,{id:`workflow-title`,value:y.title??``,onChange:e=>b(t=>({...t,title:e.target.value})),className:Er}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-description`,children:m.task}),(0,$.jsx)(`textarea`,{id:`workflow-description`,value:y.description??``,onChange:e=>b(t=>({...t,description:e.target.value})),className:`${Er} min-h-20 resize-y`}),(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:m.advanced}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-name`,children:m.workflowName}),(0,$.jsx)(`input`,{id:`workflow-name`,value:h,disabled:r?.mode===`edit`,onChange:e=>g(Pr(e.target.value)),className:`${Er} disabled:cursor-not-allowed disabled:opacity-60`}),Fe?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e===`zh`?`该内部名称已被使用,请换一个名称。`:`This internal name is already in use.`}):null,r?.mode===`edit`&&re.length>0?(0,$.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(bt,{className:`size-3.5`}),m.versions,` · v`,q]}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:re.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 hover:bg-surface-hover`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 text-xs text-fg-muted`,children:[`v`,t.revision,` · `,ne(t.createdAtMs,e)]}),t.revision===q?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:m.currentVersion}):(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(N,{variant:`ghost`,className:`h-7 px-2 text-xs`,disabled:Se!==null,onClick:()=>void at(t.revision),children:Se===t.revision?e===`zh`?`加载中…`:`Loading…`:e===`zh`?`对比`:`Compare`}),(0,$.jsxs)(N,{variant:`ghost`,className:`h-7 px-2 text-xs`,disabled:ae!==null,onClick:()=>void it(t.revision),children:[(0,$.jsx)(Te,{className:`size-3`}),ae===t.revision?m.restoring:m.restore]})]})]},t.revision))})]}):null]})]}),(0,$.jsx)(`div`,{className:`my-4 border-t border-edge`}),Me?(0,$.jsx)(Tr,{node:Me,copy:m,updateNode:qe,onDelete:Ye}):(0,$.jsx)(`div`,{className:`py-8 text-center text-sm text-fg-muted`,children:m.selectNode}),H&&!H.valid?(0,$.jsxs)(`section`,{className:`mt-4 rounded-lg border border-danger/30 bg-danger/5 p-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-danger`,children:m.needsAttention}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-danger`,children:H.errors.slice(0,5).map((e,t)=>(0,$.jsxs)(`li`,{children:[`• `,e.message]},`${e.code}-${t}`))})]}):null]})})})]}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge bg-surface-panel p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[pe===`canvas`?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(tt,{className:`size-4 shrink-0 text-accent-fg`}),(0,$.jsx)(Ot,{value:E,onChange:e=>D(e.target.value),suggestion:Mt(m.aiPlaceholder),onAcceptSuggestion:D,onKeyDown:e=>{e.key===`Enter`&&Qe()},placeholder:m.aiPlaceholder,className:`${Er} mt-0 flex-1`}),(0,$.jsx)(N,{variant:`secondary`,className:`h-10 shrink-0`,disabled:!!P||A||!E.trim(),onClick:()=>void Qe(),children:A?m.designing:m.applyWithAi})]}):(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-fg-muted`,children:be?e===`zh`?`修复源码错误后才能切换画布或保存。`:`Fix source errors before switching to the canvas or saving.`:e===`zh`?`源码与画布使用同一个草稿。`:`Source and canvas share the same draft.`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:m.testGoal,className:`${Er} mt-0 w-52`}),(0,$.jsxs)(N,{variant:`secondary`,disabled:!Le,onClick:()=>void nt(!1),children:[(0,$.jsx)(He,{className:`size-4`}),m.publish]}),(0,$.jsxs)(N,{variant:`primary`,disabled:!Le,onClick:()=>void nt(!0),children:[(0,$.jsx)(ee,{className:`size-4`}),m.publishAndRun]})]})]})})]}):(0,$.jsx)(vr,{copy:m,prompt:E,generating:A,onPromptChange:D,onGenerate:()=>void Qe(),onManual:()=>B(!0)}),(0,$.jsx)(dr,{comparison:we,language:e,onClose:()=>Ee(null)})]})}function vr(e){let t=(0,Q.c)(42),{copy:n,prompt:r,generating:i,onPromptChange:a,onGenerate:o,onManual:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(tt,{className:`size-5`})}),t[0]=c):c=t[0];let l;t[1]===n.introTitle?l=t[2]:(l=(0,$.jsx)(`h2`,{className:`mt-5 text-2xl font-semibold text-fg`,children:n.introTitle}),t[1]=n.introTitle,t[2]=l);let u;t[3]===n.introDescription?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.introDescription}),t[3]=n.introDescription,t[4]=u);let d;t[5]===a?d=t[6]:(d=e=>a(e.target.value),t[5]=a,t[6]=d);let f;t[7]===n.introPlaceholder?f=t[8]:(f=Mt(n.introPlaceholder),t[7]=n.introPlaceholder,t[8]=f);let p;t[9]!==n.introPlaceholder||t[10]!==a||t[11]!==r||t[12]!==d||t[13]!==f?(p=(0,$.jsx)(Dt,{value:r,onChange:d,suggestion:f,onAcceptSuggestion:a,placeholder:n.introPlaceholder,className:`${Er} mt-6 h-auto min-h-32 resize-y py-3 text-base leading-6`}),t[9]=n.introPlaceholder,t[10]=a,t[11]=r,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;if(t[15]!==n.examples||t[16]!==a){let e;t[18]===a?e=t[19]:(e=e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-full border border-edge bg-surface-panel px-3 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>a(e),children:e},e),t[18]=a,t[19]=e),m=n.examples.map(e),t[15]=n.examples,t[16]=a,t[17]=m}else m=t[17];let h;t[20]===m?h=t[21]:(h=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:m}),t[20]=m,t[21]=h);let g;t[22]!==i||t[23]!==r?(g=!r.trim()||i,t[22]=i,t[23]=r,t[24]=g):g=t[24];let _;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(tt,{className:`size-4`}),t[25]=_):_=t[25];let v=i?n.designing:n.designWorkflow,y;t[26]!==o||t[27]!==v||t[28]!==g?(y=(0,$.jsxs)(N,{variant:`primary`,disabled:g,onClick:o,children:[_,v]}),t[26]=o,t[27]=v,t[28]=g,t[29]=y):y=t[29];let b;t[30]!==n.manualStart||t[31]!==s?(b=(0,$.jsx)(N,{variant:`ghost`,onClick:s,children:n.manualStart}),t[30]=n.manualStart,t[31]=s,t[32]=b):b=t[32];let x;t[33]!==y||t[34]!==b?(x=(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3`,children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35];let S;return t[36]!==x||t[37]!==l||t[38]!==u||t[39]!==p||t[40]!==h?(S=(0,$.jsx)(`section`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto bg-surface-base px-5 py-10`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[c,l,u,p,h,x]})}),t[36]=x,t[37]=l,t[38]=u,t[39]=p,t[40]=h,t[41]=S):S=t[41],S}function yr(e){let t=(0,Q.c)(74),{proposal:n,diff:r,copy:i,saving:a,onAccept:o,onReject:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(tt,{className:`size-4`})}),t[0]=c):c=t[0];let l;t[1]===i.proposalTitle?l=t[2]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i.proposalTitle}),t[1]=i.proposalTitle,t[2]=l);let u;t[3]===i.proposalHint?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.proposalHint}),t[3]=i.proposalHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[c,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[l,u]})]}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f=n.manifest.title||n.name,p;t[8]===f?p=t[9]:(p=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:f}),t[8]=f,t[9]=p);let m=n.explanation||n.manifest.description,h;t[10]===m?h=t[11]:(h=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:m}),t[10]=m,t[11]=h);let g;t[12]===i.added?g=t[13]:(g=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.added}),t[12]=i.added,t[13]=g);let _;t[14]===r.addedIds.length?_=t[15]:(_=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-success`,children:r.addedIds.length}),t[14]=r.addedIds.length,t[15]=_);let y;t[16]!==_||t[17]!==g?(y=(0,$.jsxs)(`div`,{className:`rounded-lg bg-success-soft p-2`,children:[g,_]}),t[16]=_,t[17]=g,t[18]=y):y=t[18];let b;t[19]===i.changed?b=t[20]:(b=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.changed}),t[19]=i.changed,t[20]=b);let x=r.changedIds.length+r.connectionChanges,S;t[21]===x?S=t[22]:(S=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-accent-fg`,children:x}),t[21]=x,t[22]=S);let C;t[23]!==b||t[24]!==S?(C=(0,$.jsxs)(`div`,{className:`rounded-lg bg-accent-soft p-2`,children:[b,S]}),t[23]=b,t[24]=S,t[25]=C):C=t[25];let w;t[26]===i.removed?w=t[27]:(w=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.removed}),t[26]=i.removed,t[27]=w);let T;t[28]===r.removedIds.length?T=t[29]:(T=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-danger`,children:r.removedIds.length}),t[28]=r.removedIds.length,t[29]=T);let D;t[30]!==w||t[31]!==T?(D=(0,$.jsxs)(`div`,{className:`rounded-lg bg-danger/5 p-2`,children:[w,T]}),t[30]=w,t[31]=T,t[32]=D):D=t[32];let O;t[33]!==y||t[34]!==C||t[35]!==D?(O=(0,$.jsxs)(`dl`,{className:`mt-3 grid grid-cols-3 gap-2 text-center text-xs`,children:[y,C,D]}),t[33]=y,t[34]=C,t[35]=D,t[36]=O):O=t[36];let k;t[37]!==O||t[38]!==p||t[39]!==h?(k=(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base/50 p-3`,children:[p,h,O]}),t[37]=O,t[38]=p,t[39]=h,t[40]=k):k=t[40];let A;t[41]!==i.assumptions||t[42]!==n.assumptions?(A=n.assumptions.length?(0,$.jsx)(xr,{title:i.assumptions,items:n.assumptions}):null,t[41]=i.assumptions,t[42]=n.assumptions,t[43]=A):A=t[43];let j;t[44]!==i.risks||t[45]!==n.risks?(j=n.risks.length?(0,$.jsx)(xr,{title:i.risks,items:n.risks}):null,t[44]=i.risks,t[45]=n.risks,t[46]=j):j=t[46];let M;t[47]!==i.permissions||t[48]!==n.permissionsSummary?(M=n.permissionsSummary.length?(0,$.jsx)(xr,{title:i.permissions,items:n.permissionsSummary}):null,t[47]=i.permissions,t[48]=n.permissionsSummary,t[49]=M):M=t[49];let P;t[50]!==n.validation.errors||t[51]!==n.validation.valid?(P=n.validation.valid?null:(0,$.jsx)(`div`,{className:`mt-4 rounded-xl border border-danger/30 bg-danger/5 p-3 text-xs text-danger`,children:n.validation.errors.slice(0,4).map(br)}),t[50]=n.validation.errors,t[51]=n.validation.valid,t[52]=P):P=t[52];let F=a||!n.validation.valid,I;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(v,{className:`size-4`}),t[53]=I):I=t[53];let L=a?i.savingProposal:i.acceptAndSave,R;t[54]!==o||t[55]!==F||t[56]!==L?(R=(0,$.jsxs)(N,{variant:`primary`,disabled:F,onClick:o,children:[I,L]}),t[54]=o,t[55]=F,t[56]=L,t[57]=R):R=t[57];let z;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(E,{className:`size-4`}),t[58]=z):z=t[58];let B;t[59]!==i.rejectProposal||t[60]!==s||t[61]!==a?(B=(0,$.jsxs)(N,{variant:`ghost`,disabled:a,onClick:s,children:[z,i.rejectProposal]}),t[59]=i.rejectProposal,t[60]=s,t[61]=a,t[62]=B):B=t[62];let V;t[63]!==R||t[64]!==B?(V=(0,$.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[R,B]}),t[63]=R,t[64]=B,t[65]=V):V=t[65];let H;return t[66]!==k||t[67]!==A||t[68]!==j||t[69]!==M||t[70]!==P||t[71]!==V||t[72]!==d?(H=(0,$.jsxs)(`section`,{children:[d,k,A,j,M,P,V]}),t[66]=k,t[67]=A,t[68]=j,t[69]=M,t[70]=P,t[71]=V,t[72]=d,t[73]=H):H=t[73],H}function br(e){return(0,$.jsxs)(`p`,{children:[`• `,e.message]},`${e.code}:${e.message}`)}function xr(e){let t=(0,Q.c)(9),{title:n,items:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,4).map(Sr),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{className:`mt-4`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function Sr(e){return(0,$.jsxs)(`li`,{children:[`• `,e]},e)}function Cr(e){let t=(0,Q.c)(34),{data:n,selected:r}=e,i=n.workflowNode,a=n.diffState,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,$.jsx)($e,{}):i.kind===`agent`?(0,$.jsx)(St,{}):i.kind===`decision`?(0,$.jsx)(ye,{}):i.kind===`merge`?(0,$.jsx)(Xe,{}):(0,$.jsx)(ee,{}),t[0]=i.kind,t[1]=o);let s=o,c=r?`border-accent ring-2 ring-accent/20`:`border-edge`,l=a===`added`&&`border-success ring-2 ring-success/15`,u=a===`changed`&&`border-accent ring-2 ring-accent/15`,d=a===`removed`&&`border-dashed border-danger opacity-55`,f;t[2]!==c||t[3]!==l||t[4]!==u||t[5]!==d?(f=j(`w-52 rounded-xl border bg-surface-panel p-3 shadow-surface transition-colors`,c,l,u,d),t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f):f=t[6];let p;t[7]===i.kind?p=t[8]:(p=i.kind===`input`?null:(0,$.jsx)(zt,{type:`target`,position:It.Left,className:`!size-2.5 !border-2 !border-surface-panel !bg-fg-subtle`}),t[7]=i.kind,t[8]=p);let m;t[9]===s?m=t[10]:(m=(0,$.jsx)(`span`,{className:`mt-0.5 [&>svg]:size-4 text-accent-fg`,children:s}),t[9]=s,t[10]=m);let h;t[11]===i.title?h=t[12]:(h=(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[11]=i.title,t[12]=h);let g;t[13]!==i.description||t[14]!==i.kind?(g=i.description||Fr(i.kind),t[13]=i.description,t[14]=i.kind,t[15]=g):g=t[15];let _;t[16]===g?_=t[17]:(_=(0,$.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-4 text-fg-muted`,children:g}),t[16]=g,t[17]=_);let v;t[18]!==_||t[19]!==h?(v=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[h,_]}),t[18]=_,t[19]=h,t[20]=v):v=t[20];let y;t[21]===a?y=t[22]:(y=a?(0,$.jsx)(`span`,{className:j(`rounded-full px-1.5 py-0.5 text-[10px] font-medium`,a===`added`?`bg-success-soft text-success`:a===`removed`?`bg-danger/10 text-danger`:`bg-accent-soft text-accent-fg`),children:a===`added`?`+`:a===`removed`?`−`:`Δ`}):null,t[21]=a,t[22]=y);let b;t[23]!==v||t[24]!==y||t[25]!==m?(b=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[m,v,y]}),t[23]=v,t[24]=y,t[25]=m,t[26]=b):b=t[26];let x;t[27]===i.kind?x=t[28]:(x=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zt,{id:`true`,type:`source`,position:It.Right,style:{top:`38%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-success`}),(0,$.jsx)(zt,{id:`false`,type:`source`,position:It.Right,style:{top:`70%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-danger`})]}):i.kind===`output`?null:(0,$.jsx)(zt,{type:`source`,position:It.Right,className:`!size-2.5 !border-2 !border-surface-panel !bg-accent`}),t[27]=i.kind,t[28]=x);let S;return t[29]!==b||t[30]!==x||t[31]!==f||t[32]!==p?(S=(0,$.jsxs)(`div`,{className:f,children:[p,b,x]}),t[29]=b,t[30]=x,t[31]=f,t[32]=p,t[33]=S):S=t[33],S}var wr={workflow:Cr};function Tr(e){let t=(0,Q.c)(71),{node:n,copy:r,updateNode:i,onDelete:a}=e,o;t[0]!==n.id||t[1]!==i?(o=e=>i(n.id,t=>({...t,...e})),t[0]=n.id,t[1]=i,t[2]=o):o=t[2];let s=o,c;t[3]!==n.id||t[4]!==i?(c=e=>i(n.id,t=>({...t,config:{...t.config,...e}})),t[3]=n.id,t[4]=i,t[5]=c):c=t[5];let l=c,u;t[6]===r.stepSettings?u=t[7]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.stepSettings}),t[6]=r.stepSettings,t[7]=u);let d;t[8]!==r.remove||t[9]!==n.kind||t[10]!==a?(d=n.kind!==`input`&&n.kind!==`output`?(0,$.jsxs)(N,{variant:`ghost`,className:`h-8 px-2 text-danger`,onClick:a,children:[(0,$.jsx)(oe,{className:`size-3.5`}),r.remove]}):null,t[8]=r.remove,t[9]=n.kind,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.stepName?p=t[16]:(p=(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-title`,children:r.stepName}),t[15]=r.stepName,t[16]=p);let m;t[17]===s?m=t[18]:(m=e=>s({title:e.target.value}),t[17]=s,t[18]=m);let h;t[19]!==n.title||t[20]!==m?(h=(0,$.jsx)(`input`,{id:`node-title`,value:n.title,onChange:m,className:Er}),t[19]=n.title,t[20]=m,t[21]=h):h=t[21];let g;t[22]===r.stepPurpose?g=t[23]:(g=(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-description`,children:r.stepPurpose}),t[22]=r.stepPurpose,t[23]=g);let _=n.description??``,v;t[24]===s?v=t[25]:(v=e=>s({description:e.target.value}),t[24]=s,t[25]=v);let y;t[26]!==_||t[27]!==v?(y=(0,$.jsx)(`textarea`,{id:`node-description`,value:_,onChange:v,className:`${Er} min-h-16 resize-y`}),t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;t[29]!==r.advanced||t[30]!==r.defaultModel||t[31]!==r.instructions||t[32]!==r.model||t[33]!==n.config||t[34]!==n.kind||t[35]!==l?(b=n.kind===`agent`?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:r.advanced}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-prompt`,children:r.instructions}),(0,$.jsx)(`textarea`,{id:`node-prompt`,value:String(n.config.prompt??``),onChange:e=>l({prompt:e.target.value}),className:`${Er} min-h-36 resize-y`}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-model`,children:r.model}),(0,$.jsx)(`input`,{id:`node-model`,value:String(n.config.model??``),onChange:e=>l({model:e.target.value||void 0}),placeholder:r.defaultModel,className:Er})]})}):null,t[29]=r.advanced,t[30]=r.defaultModel,t[31]=r.instructions,t[32]=r.model,t[33]=n.config,t[34]=n.kind,t[35]=l,t[36]=b):b=t[36];let S;t[37]!==r.compareValue||t[38]!==r.condition||t[39]!==r.contains||t[40]!==r.equals||t[41]!==r.exists||t[42]!==r.notEquals||t[43]!==r.valuePath||t[44]!==n.config||t[45]!==n.kind||t[46]!==l?(S=n.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-path`,children:r.valuePath}),(0,$.jsx)(`input`,{id:`decision-path`,value:n.config.rule?.path??``,onChange:e=>l({rule:{...n.config.rule??{operator:`exists`},path:e.target.value}}),placeholder:`result.approved`,className:Er}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`decision-operator-label`,children:r.condition}),(0,$.jsx)(x,{value:n.config.rule?.operator??`exists`,placeholder:r.condition,allowEmpty:!1,ariaLabelledBy:`decision-operator-label`,options:[{value:`exists`,label:r.exists},{value:`equals`,label:r.equals},{value:`not_equals`,label:r.notEquals},{value:`contains`,label:r.contains}],onChange:e=>l({rule:{...n.config.rule??{path:``},operator:e}})}),n.config.rule?.operator===`exists`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-value`,children:r.compareValue}),(0,$.jsx)(`input`,{id:`decision-value`,value:String(n.config.rule?.value??``),onChange:e=>l({rule:{...n.config.rule,value:e.target.value}}),className:Er})]})]}):null,t[37]=r.compareValue,t[38]=r.condition,t[39]=r.contains,t[40]=r.equals,t[41]=r.exists,t[42]=r.notEquals,t[43]=r.valuePath,t[44]=n.config,t[45]=n.kind,t[46]=l,t[47]=S):S=t[47];let C;t[48]!==r.combineAs||t[49]!==r.listResults||t[50]!==r.namedResults||t[51]!==n.config||t[52]!==n.kind||t[53]!==l?(C=n.kind===`merge`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`merge-mode-label`,children:r.combineAs}),(0,$.jsx)(x,{value:String(n.config.mode??`object`),placeholder:r.combineAs,allowEmpty:!1,ariaLabelledBy:`merge-mode-label`,options:[{value:`object`,label:r.namedResults},{value:`array`,label:r.listResults}],onChange:e=>l({mode:e})})]}):null,t[48]=r.combineAs,t[49]=r.listResults,t[50]=r.namedResults,t[51]=n.config,t[52]=n.kind,t[53]=l,t[54]=C):C=t[54];let w;t[55]!==r.autoSummary||t[56]!==r.summaryTemplate||t[57]!==n.config||t[58]!==n.kind||t[59]!==l?(w=n.kind===`output`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`output-summary`,children:r.summaryTemplate}),(0,$.jsx)(`textarea`,{id:`output-summary`,value:String(n.config.summary??``),onChange:e=>l({summary:e.target.value||void 0}),placeholder:r.autoSummary,className:`${Er} min-h-20 resize-y`})]}):null,t[55]=r.autoSummary,t[56]=r.summaryTemplate,t[57]=n.config,t[58]=n.kind,t[59]=l,t[60]=w):w=t[60];let T;return t[61]!==y||t[62]!==b||t[63]!==S||t[64]!==C||t[65]!==w||t[66]!==f||t[67]!==p||t[68]!==h||t[69]!==g?(T=(0,$.jsxs)(`section`,{children:[f,p,h,g,y,b,S,C,w]}),t[61]=y,t[62]=b,t[63]=S,t[64]=C,t[65]=w,t[66]=f,t[67]=p,t[68]=h,t[69]=g,t[70]=T):T=t[70],T}var Er=`mt-1 block h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-edge-strong`;function Dr(e,t=!1,n){return{id:e.id,type:`workflow`,position:e.position,selected:t,data:{workflowNode:e,diffState:n}}}function Or(e){return{id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:Pt.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}}function kr(){return{schemaVersion:1,nodes:[{id:`input`,kind:`input`,title:`Input`,description:`What the user provides`,position:{x:0,y:120},config:{}},{id:`agent-1`,kind:`agent`,title:`Do the work`,description:`Understand and complete the request`,phaseId:`work`,position:{x:300,y:120},config:{prompt:`Complete this goal: {{goal}}
|
|
3
|
-
|
|
4
|
-
User input:
|
|
5
|
-
{{input}}`,maxIterations:12}},{id:`output`,kind:`output`,title:`Result`,description:`A clear answer for the user`,position:{x:620,y:120},config:{}}],edges:[{id:`input-agent`,source:`input`,target:`agent-1`},{id:`agent-output`,source:`agent-1`,target:`output`}]}}function Ar(e,t,n){let r={x:280+n%3*280,y:80+Math.floor(n/3)*180};return e===`agent`?{id:t,kind:e,title:`New AI step`,description:`Describe what this step should accomplish`,phaseId:`work`,position:r,config:{prompt:`Use the previous results to complete this step:
|
|
6
|
-
{{predecessors}}`,maxIterations:12}}:e===`decision`?{id:t,kind:e,title:`Check a condition`,description:`Choose what happens next`,position:r,config:{rule:{path:``,operator:`exists`}}}:{id:t,kind:e,title:`Combine results`,description:`Bring parallel work together`,position:r,config:{mode:`object`}}}function jr(e,t){let n=new Map;if(!t)return{addedIds:[],changedIds:[],removedIds:[],connectionChanges:0,nodeStates:n};let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map(t.nodes.map(e=>[e.id,e])),a=t.nodes.filter(e=>!r.has(e.id)).map(e=>e.id),o=e.nodes.filter(e=>!i.has(e.id)).map(e=>e.id),s=t.nodes.filter(e=>{let t=r.get(e.id);return t?Mr(t)!==Mr(e):!1}).map(e=>e.id);a.forEach(e=>n.set(e,`added`)),s.forEach(e=>n.set(e,`changed`)),o.forEach(e=>n.set(e,`removed`));let c=new Set(e.edges.map(Nr)),l=new Set(t.edges.map(Nr));return{addedIds:a,changedIds:s,removedIds:o,connectionChanges:e.edges.filter(e=>!l.has(Nr(e))).length+t.edges.filter(e=>!c.has(Nr(e))).length,nodeStates:n}}function Mr(e){let{position:t,...n}=e;return JSON.stringify(n)}function Nr(e){return`${e.source}:${e.sourcePort??``}->${e.target}`}function Pr(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`_`).replace(/^_+/,``)}function Fr(e){return{input:`User input`,agent:`AI step`,decision:`Decision`,merge:`Combine`,output:`User result`}[e]}function Ir(e){return e===`zh`?{untitled:`未命名工作流`,editTitle:`编辑工作流`,createTitle:`创建工作流`,subtitle:`描述目标、确认方案,然后用示例测试。无需编写代码。`,close:`关闭`,savingDraft:`正在保存草稿…`,savedDraft:`草稿已保存`,draftError:`草稿保存失败`,flowTitle:`工作流步骤图`,flowAria:`可编辑的工作流步骤图`,stepCount:e=>`${e} 个步骤 · 点击步骤可编辑`,emptyFlow:`还没有步骤。添加一个 AI 步骤开始设计。`,addAgent:`添加 AI 步骤`,addDecision:`添加判断`,addMerge:`合并结果`,canvasHint:`拖动步骤并连接圆点`,workflowName:`内部名称`,humanTitle:`用户看到的名称`,task:`这个工作流最终帮用户得到什么?`,versions:`版本记录`,currentVersion:`当前`,restore:`恢复为新版本`,restoring:`恢复中…`,selectNode:`选择一个步骤来编辑`,needsAttention:`发布前需要处理`,stepSettings:`步骤设置`,remove:`删除`,stepName:`步骤名称`,stepPurpose:`这一步的作用`,instructions:`告诉 AI 要做什么`,advanced:`高级设置`,model:`模型(可选)`,defaultModel:`使用智能默认值`,valuePath:`要检查的值`,condition:`判断条件`,exists:`存在`,equals:`等于`,notEquals:`不等于`,contains:`包含`,compareValue:`比较值`,combineAs:`合并方式`,namedResults:`按步骤名称组织`,listResults:`按列表组织`,summaryTemplate:`结果摘要(可选)`,autoSummary:`留空则自动生成`,aiPlaceholder:`例如:增加一个风险评审步骤,并与方案分析并行`,designing:`正在设计…`,applyWithAi:`让 AI 提出修改`,testGoal:`用什么例子测试?`,publish:`保存`,publishAndRun:`保存并测试`,introTitle:`你希望这个工作流持续帮你完成什么?`,introDescription:`直接描述最终目标。AI 会先给出一份可理解的步骤方案,只有你确认后才会保存。`,introPlaceholder:`例如:每周整理项目进展,识别风险,并生成一份可以发给团队的周报。`,examples:[`研究一个主题并给出可靠结论`,`评审需求并生成实现计划`,`分析问题、定位原因并给出修复建议`],designWorkflow:`生成方案`,manualStart:`高级:手动搭建`,proposalTitle:`AI 提出的方案`,proposalHint:`绿色是新增,蓝色是修改,红色虚线是删除。确认前不会改变现有工作流。`,added:`新增`,changed:`修改`,removed:`删除`,assumptions:`方案假设`,risks:`需要留意`,permissions:`需要的权限`,acceptAndSave:`采用并保存`,savingProposal:`正在保存…`,rejectProposal:`不采用,返回修改`}:{untitled:`Untitled workflow`,editTitle:`Edit workflow`,createTitle:`Create workflow`,subtitle:`Describe the task, review the plan, then test it with an example. No code required.`,close:`Close`,savingDraft:`Saving draft…`,savedDraft:`Draft saved`,draftError:`Draft could not be saved`,flowTitle:`Workflow map`,flowAria:`Editable workflow step map`,stepCount:e=>`${e} steps · select a step to edit`,emptyFlow:`No steps yet. Add an AI step to start designing.`,addAgent:`Add AI step`,addDecision:`Add decision`,addMerge:`Combine results`,canvasHint:`Drag steps and connect the dots`,workflowName:`Internal name`,humanTitle:`Name users see`,task:`What will this workflow help the user achieve?`,versions:`Version history`,currentVersion:`Current`,restore:`Restore as new`,restoring:`Restoring…`,selectNode:`Select a step to edit it`,needsAttention:`Needs attention before publishing`,stepSettings:`Step settings`,remove:`Remove`,stepName:`Step name`,stepPurpose:`Purpose of this step`,instructions:`Tell the AI what to do`,advanced:`Advanced settings`,model:`Model (optional)`,defaultModel:`Use smart default`,valuePath:`Value to check`,condition:`Condition`,exists:`Exists`,equals:`Equals`,notEquals:`Does not equal`,contains:`Contains`,compareValue:`Compare with`,combineAs:`Combine as`,namedResults:`Named results`,listResults:`List of results`,summaryTemplate:`Result summary (optional)`,autoSummary:`Leave blank to generate automatically`,aiPlaceholder:`For example: add a risk review in parallel with solution analysis`,designing:`Designing…`,applyWithAi:`Ask AI to propose changes`,testGoal:`What example should we test?`,publish:`Save`,publishAndRun:`Save & test`,introTitle:`What should this workflow keep doing for you?`,introDescription:`Describe the task in plain language. AI will propose an understandable plan and will not save anything until you approve it.`,introPlaceholder:`For example: summarize project progress every week, identify risks, and produce a team-ready update.`,examples:[`Research a topic and deliver a reliable conclusion`,`Review a request and produce an implementation plan`,`Analyze an issue, find the cause, and recommend a fix`],designWorkflow:`Generate plan`,manualStart:`Advanced: build manually`,proposalTitle:`AI proposal`,proposalHint:`Green is added, blue is changed, and dashed red is removed. Nothing changes until you approve.`,added:`Added`,changed:`Changed`,removed:`Removed`,assumptions:`Assumptions`,risks:`Things to check`,permissions:`Required access`,acceptAndSave:`Accept & save`,savingProposal:`Saving…`,rejectProposal:`Reject and revise`}}function Lr(e){let t=(0,Q.c)(25),{projectId:n,language:r,value:i,onChange:a}=e,o=O(r).workflows,s=O(r).projectDetailPage.board.operationalStates,c;t[0]===n?c=t[1]:(c=n?[`workflow-context-project`,n]:null,t[0]=n,t[1]=c);let l;t[2]===n?l=t[3]:(l=()=>Fe(n),t[2]=n,t[3]=l);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},t[4]=v):v=t[4];let y=M(c,l,v),b;t[5]===n?b=t[6]:(b=n?[`workflow-context-notes`,n]:null,t[5]=n,t[6]=b);let x;t[7]===n?x=t[8]:(x=()=>le({projectId:n,limit:100,sortBy:`updatedAt`,sortOrder:`desc`}),t[7]=n,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[9]=S):S=t[9];let C=M(b,x,S),w;t[10]!==a||t[11]!==i?(w=e=>{a(i.some(t=>t.kind===e.kind&&t.id===e.id)?i.filter(t=>t.kind!==e.kind||t.id!==e.id):[...i,e])},t[10]=a,t[11]=i,t[12]=w):w=t[12];let D=w,k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[13]=k):k=t[13];let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),t[14]=A):A=t[14];let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(E,{className:`size-4`}),t[15]=j):j=t[15];let P=y.isLoading||C.isLoading?(0,$.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:6},Rr)}):y.error||C.error?(0,$.jsx)(`p`,{className:`rounded-xl border border-danger/30 bg-danger/5 p-4 text-sm text-danger`,children:o.contextPickerLoadFailed}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(zr,{title:o.contextTasks,icon:nt,empty:o.contextTasksEmpty,items:(y.data?.tasks??[]).map(e=>({id:e.id,title:e.title,subtitle:s[e.operationalState]})),selected:i,kind:`task`,onToggle:D}),(0,$.jsx)(zr,{title:o.contextNotes,icon:pe,empty:o.contextNotesEmpty,items:(C.data?.items??[]).map(e=>({id:e.id,title:e.title||o.contextUntitled,subtitle:e.snippet})),selected:i,kind:`note`,onToggle:D})]}),F;t[16]===P?F=t[17]:(F=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:P}),t[16]=P,t[17]=F);let I=o.contextPickerCount.replace(`{{count}}`,String(i.length)),L;t[18]===I?L=t[19]:(L=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I}),t[18]=I,t[19]=L);let R;t[20]===o.contextPickerDone?R=t[21]:(R=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`primary`,className:`h-9`,children:o.contextPickerDone})}),t[20]=o.contextPickerDone,t[21]=R);let z;return t[22]!==L||t[23]!==R?(z=(0,$.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between border-t border-edge px-5 py-3`,children:[L,R]}),t[22]=L,t[23]=R,t[24]=z):z=t[24],(0,$.jsxs)(_,{children:[(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`h-9 w-full justify-between rounded-lg px-3 text-xs`,disabled:!n,children:[(0,$.jsx)(`span`,{children:o.contextPickerLabel}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-fg-muted`,children:[i.length?o.contextPickerCount.replace(`{{count}}`,String(i.length)):o.contextPickerEmpty,k]})]})}),(0,$.jsxs)(m,{children:[A,(0,$.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(42rem,calc(100vh-2rem))] w-[min(44rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-xl`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:o.contextPickerTitle}),(0,$.jsx)(f,{className:`mt-1 text-xs text-fg-muted`,children:o.contextPickerDescription})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":o.pickStartClose,children:j})})]}),F,z]})]})]})}function Rr(e,t){return(0,$.jsx)(F,{className:`h-14 rounded-xl`},t)}function zr(e){let t=(0,Q.c)(14),{title:n,icon:r,empty:i,items:a,selected:o,kind:s,onToggle:c}=e,l;t[0]===r?l=t[1]:(l=(0,$.jsx)(r,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),t[0]=r,t[1]=l);let u;t[2]!==l||t[3]!==n?(u=(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[l,n]}),t[2]=l,t[3]=n,t[4]=u):u=t[4];let d;t[5]!==i||t[6]!==a||t[7]!==s||t[8]!==c||t[9]!==o?(d=a.length?(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:a.map(e=>{let t=o.some(t=>t.kind===s&&t.id===e.id);return(0,$.jsxs)(`button`,{type:`button`,className:j(`flex min-w-0 items-start gap-3 rounded-xl border p-3 text-left`,t?`border-accent bg-accent-soft`:`border-edge-subtle hover:bg-surface-hover`),"aria-pressed":t,onClick:()=>c({kind:s,id:e.id,role:s===`task`?`objective`:`reference`,title:e.title}),children:[(0,$.jsx)(`span`,{className:j(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border`,t?`border-accent bg-accent text-white`:`border-edge`),children:t?(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}):null}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),e.subtitle?(0,$.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-xs text-fg-muted`,children:e.subtitle}):null]})]},e.id)})}):(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=a,t[7]=s,t[8]=c,t[9]=o,t[10]=d):d=t[10];let f;return t[11]!==u||t[12]!==d?(f=(0,$.jsxs)(`section`,{children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Br(e){let t=(0,Q.c)(54),{graph:n,language:r,className:i}=e,a;t[0]===r?a=t[1]:(a=Gr(r),t[0]=r,t[1]=a);let o=a,[s,c]=(0,Z.useState)(n.nodes.find(Vr)?.id??n.nodes[0]?.id),l;if(t[2]!==o.kind||t[3]!==n.nodes){let e;t[5]===o.kind?e=t[6]:(e=e=>({id:e.id,type:`definitionNode`,position:e.position,data:{definitionNode:e,kindLabel:o.kind[e.kind]}}),t[5]=o.kind,t[6]=e),l=n.nodes.map(e),t[2]=o.kind,t[3]=n.nodes,t[4]=l}else l=t[4];let u=l,d;if(t[7]!==o.no||t[8]!==o.yes||t[9]!==n.edges){let e;t[11]!==o.no||t[12]!==o.yes?(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,label:e.sourcePort===`true`?o.yes:e.sourcePort===`false`?o.no:void 0,labelStyle:{fill:`var(--color-fg-subtle)`,fontSize:10},labelBgStyle:{fill:`var(--color-surface-panel)`,fillOpacity:.9},markerEnd:{type:Pt.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[11]=o.no,t[12]=o.yes,t[13]=e):e=t[13],d=n.edges.map(e),t[7]=o.no,t[8]=o.yes,t[9]=n.edges,t[10]=d}else d=t[10];let f=d,p=n.nodes,m,h,g,_,v,y;if(t[14]!==i||t[15]!==o.ariaLabel||t[16]!==o.empty||t[17]!==o.kind||t[18]!==o.selectHint||t[19]!==f||t[20]!==n.nodes||t[21]!==u||t[22]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[29]===s?e=t[30]:(e=e=>e.id===s,t[29]=s,t[30]=e);let r=p.find(e);if(n.nodes.length===0){let e;t[31]===i?e=t[32]:(e=j(`flex min-h-72 items-center justify-center bg-surface-base/40 px-6 text-center text-sm text-fg-muted`,i),t[31]=i,t[32]=e);let n;t[33]!==o.empty||t[34]!==e?(n=(0,$.jsx)(`div`,{className:e,children:o.empty}),t[33]=o.empty,t[34]=e,t[35]=n):n=t[35],m=n;break bb0}t[36]===i?_=t[37]:(_=j(`overflow-hidden bg-surface-base/45`,i),t[36]=i,t[37]=_),v=o.ariaLabel;let a;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(a=(e,t)=>c(t.id),t[38]=a):a=t[38];let l;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(l={padding:.24,minZoom:.45,maxZoom:1},t[39]=l):l=t[39];let d,b,x;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(d={hideAttribution:!0},b=(0,$.jsx)(Vt,{color:`var(--color-edge)`,gap:22,size:1}),x=(0,$.jsx)(Lt,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`}),t[40]=d,t[41]=b,t[42]=x):(d=t[40],b=t[41],x=t[42]),t[43]!==f||t[44]!==u?(y=(0,$.jsx)(`div`,{className:`h-[22rem] min-h-72`,children:(0,$.jsxs)(Rt,{nodes:u,edges:f,nodeTypes:Wr,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:a,fitView:!0,fitViewOptions:l,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:d,children:[b,x]})}),t[43]=f,t[44]=u,t[45]=y):y=t[45],h=`flex min-h-16 items-start gap-3 border-t border-edge bg-surface-panel px-4 py-3`,g=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:Ur(r.kind)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{className:`block text-sm font-medium text-fg`,children:r.title}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:r.description||o.kind[r.kind]})]})]}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:o.selectHint})}t[14]=i,t[15]=o.ariaLabel,t[16]=o.empty,t[17]=o.kind,t[18]=o.selectHint,t[19]=f,t[20]=n.nodes,t[21]=u,t[22]=s,t[23]=m,t[24]=h,t[25]=g,t[26]=_,t[27]=v,t[28]=y}else m=t[23],h=t[24],g=t[25],_=t[26],v=t[27],y=t[28];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let b;t[46]!==h||t[47]!==g?(b=(0,$.jsx)(`div`,{className:h,children:g}),t[46]=h,t[47]=g,t[48]=b):b=t[48];let x;return t[49]!==b||t[50]!==_||t[51]!==v||t[52]!==y?(x=(0,$.jsxs)(`section`,{className:_,"aria-label":v,children:[y,b]}),t[49]=b,t[50]=_,t[51]=v,t[52]=y,t[53]=x):x=t[53],x}function Vr(e){return e.kind===`agent`}function Hr(e){let t=(0,Q.c)(25),{data:n,selected:r}=e,i=n.definitionNode,a=r?`border-accent ring-2 ring-accent/20`:`border-edge`,o;t[0]===a?o=t[1]:(o=j(`w-48 rounded-xl border bg-surface-panel p-3 shadow-surface transition-colors`,a),t[0]=a,t[1]=o);let s;t[2]===i.kind?s=t[3]:(s=i.kind===`input`?null:(0,$.jsx)(zt,{type:`target`,position:It.Left,className:`!invisible`}),t[2]=i.kind,t[3]=s);let c;t[4]===i.kind?c=t[5]:(c=Ur(i.kind),t[4]=i.kind,t[5]=c);let l;t[6]===c?l=t[7]:(l=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:c}),t[6]=c,t[7]=l);let u;t[8]===i.title?u=t[9]:(u=(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[8]=i.title,t[9]=u);let d;t[10]===n.kindLabel?d=t[11]:(d=(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.kindLabel}),t[10]=n.kindLabel,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17];let m;t[18]===i.kind?m=t[19]:(m=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zt,{id:`true`,type:`source`,position:It.Right,style:{top:`38%`},className:`!invisible`}),(0,$.jsx)(zt,{id:`false`,type:`source`,position:It.Right,style:{top:`70%`},className:`!invisible`})]}):i.kind===`output`?null:(0,$.jsx)(zt,{type:`source`,position:It.Right,className:`!invisible`}),t[18]=i.kind,t[19]=m);let h;return t[20]!==m||t[21]!==o||t[22]!==s||t[23]!==p?(h=(0,$.jsxs)(`div`,{className:o,children:[s,p,m]}),t[20]=m,t[21]=o,t[22]=s,t[23]=p,t[24]=h):h=t[24],h}function Ur(e){return e===`input`?(0,$.jsx)($e,{className:`size-4`,"aria-hidden":!0}):e===`agent`?(0,$.jsx)(St,{className:`size-4`,"aria-hidden":!0}):e===`decision`?(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}):e===`merge`?(0,$.jsx)(Xe,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0})}var Wr={definitionNode:Hr};function Gr(e){return e===`zh`?{ariaLabel:`工作流步骤图`,empty:`这个工作流还没有可展示的步骤。`,selectHint:`点击步骤查看它的作用。`,yes:`是`,no:`否`,kind:{input:`任务输入`,agent:`AI 执行`,decision:`条件判断`,merge:`汇总结果`,output:`最终结果`}}:{ariaLabel:`Workflow step map`,empty:`This workflow has no steps to display yet.`,selectHint:`Select a step to see what it does.`,yes:`Yes`,no:`No`,kind:{input:`Task input`,agent:`AI work`,decision:`Decision`,merge:`Combine results`,output:`Deliverable`}}}function Kr(e){let t=(0,Q.c)(54),{graph:n,view:r,language:i,onRepair:a}=e,[o,s]=(0,Z.useState)(),c=(0,Z.useRef)(null),l=(0,Z.useRef)(void 0),u;t[0]===i?u=t[1]:(u=ti(i),t[0]=i,t[1]=u);let d=u,f;t[2]===r.nodes?f=t[3]:(f=new Map(r.nodes.map(Zr)),t[2]=r.nodes,t[3]=f);let p=f,m;if(t[4]!==n.nodes||t[5]!==p){let e;t[7]===p?e=t[8]:(e=e=>({id:e.id,type:`runNode`,position:e.position,data:{definitionNode:e,runNode:p.get(e.id)}}),t[7]=p,t[8]=e),m=n.nodes.map(e),t[4]=n.nodes,t[5]=p,t[6]=m}else m=t[6];let h=m,g;if(t[9]!==n.edges||t[10]!==p){let e;t[12]===p?e=t[13]:(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:Pt.ArrowClosed},animated:p.get(e.source)?.status===`running`,style:{stroke:p.get(e.source)?.status===`done`?`var(--color-success)`:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[12]=p,t[13]=e),g=n.edges.map(e),t[9]=n.edges,t[10]=p,t[11]=g}else g=t[11];let _=g,y;t[14]!==o||t[15]!==p?(y=o?p.get(o):void 0,t[14]=o,t[15]=p,t[16]=y):y=t[16];let b=y,x;t[17]!==n.nodes||t[18]!==o?(x=o?n.nodes.find(e=>e.id===o):void 0,t[17]=n.nodes,t[18]=o,t[19]=x):x=t[19];let S=x,C;t[20]===r.nodes?C=t[21]:(C=r.nodes.some(Xr),t[20]=r.nodes,t[21]=C);let w=C,T,E;t[22]===r.nodes?(T=t[23],E=t[24]):(T=()=>{let e=r.nodes.find(Yr)??r.nodes.find(Jr)??[...r.nodes].reverse().find(qr);if(!e||l.current===e.id)return;l.current=e.id,s(e.id);let t=window.requestAnimationFrame(()=>{c.current?.fitView({nodes:[{id:e.id}],padding:1.4,minZoom:.65,maxZoom:1,duration:300})});return()=>window.cancelAnimationFrame(t)},E=[r.nodes],t[22]=r.nodes,t[23]=T,t[24]=E),(0,Z.useEffect)(T,E);let D;t[25]===d.title?D=t[26]:(D=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.title}),t[25]=d.title,t[26]=D);let O;t[27]===d.hint?O=t[28]:(O=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:d.hint}),t[27]=d.hint,t[28]=O);let k;t[29]!==D||t[30]!==O?(k=(0,$.jsxs)(`div`,{children:[D,O]}),t[29]=D,t[30]=O,t[31]=k):k=t[31];let A;t[32]!==d.repair||t[33]!==w||t[34]!==a?(A=w&&a?(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 text-xs`,onClick:a,children:[(0,$.jsx)(Te,{className:`size-3.5`}),d.repair]}):null,t[32]=d.repair,t[33]=w,t[34]=a,t[35]=A):A=t[35];let M;t[36]!==k||t[37]!==A?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[k,A]}),t[36]=k,t[37]=A,t[38]=M):M=t[38];let P,F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>s(t.id),F=e=>{c.current=e},t[39]=P,t[40]=F):(P=t[39],F=t[40]);let I,L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I={hideAttribution:!0},L=(0,$.jsx)(Vt,{color:`var(--color-edge)`,gap:22,size:1}),t[41]=I,t[42]=L):(I=t[41],L=t[42]);let R;t[43]!==_||t[44]!==h?(R=(0,$.jsx)(`div`,{className:`h-[28rem]`,children:(0,$.jsx)(Rt,{nodes:h,edges:_,nodeTypes:ei,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:P,onInit:F,fitView:!0,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:I,children:L})}),t[43]=_,t[44]=h,t[45]=R):R=t[45];let z;t[46]!==d.status||t[47]!==b||t[48]!==S?(z=b?(0,$.jsxs)(`div`,{className:j(`flex items-start gap-2 border-t border-edge px-4 py-3 text-xs`,b.status===`error`?`text-danger`:`text-fg-muted`),children:[b.status===`error`?(0,$.jsx)(Se,{className:`mt-0.5 size-3.5 shrink-0`}):b.status===`done`?(0,$.jsx)(v,{className:`mt-0.5 size-3.5 shrink-0 text-success`}):null,(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{className:`font-medium text-fg`,children:b.title}),S?.description?(0,$.jsx)(`span`,{className:`block pt-0.5 text-fg-subtle`,children:S.description}):null,(0,$.jsx)(`span`,{className:`block pt-1`,children:b.error||b.resultPreview||d.status[b.status]})]})]}):null,t[46]=d.status,t[47]=b,t[48]=S,t[49]=z):z=t[49];let B;return t[50]!==M||t[51]!==R||t[52]!==z?(B=(0,$.jsxs)(`section`,{className:`mt-5 overflow-hidden rounded-2xl border border-edge bg-surface-base/35`,children:[M,R,z]}),t[50]=M,t[51]=R,t[52]=z,t[53]=B):B=t[53],B}function qr(e){return e.status===`done`}function Jr(e){return e.status===`error`}function Yr(e){return e.status===`running`}function Xr(e){return e.status===`error`}function Zr(e){return[e.id,e]}function Qr(e){let t=(0,Q.c)(30),{data:n,selected:r}=e,i=n.definitionNode,a=n.runNode?.status??`pending`,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,$.jsx)($e,{}):i.kind===`agent`?(0,$.jsx)(St,{}):i.kind===`decision`?(0,$.jsx)(ye,{}):i.kind===`merge`?(0,$.jsx)(Xe,{}):(0,$.jsx)(ee,{}),t[0]=i.kind,t[1]=o);let s=o,c=a===`running`&&`border-accent ring-2 ring-accent/20`,l=a===`done`&&`border-success/50`,u=a===`error`&&`border-danger ring-2 ring-danger/15`,d=(a===`pending`||a===`skipped`)&&`border-edge opacity-70`,f=r&&`ring-2 ring-accent/25`,p;t[2]!==c||t[3]!==l||t[4]!==u||t[5]!==d||t[6]!==f?(p=j(`w-48 rounded-xl border bg-surface-panel px-3 py-2.5 shadow-surface`,c,l,u,d,f),t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f,t[7]=p):p=t[7];let m;t[8]===i.kind?m=t[9]:(m=i.kind===`input`?null:(0,$.jsx)(zt,{type:`target`,position:It.Left,className:`!invisible`}),t[8]=i.kind,t[9]=m);let h;t[10]===s?h=t[11]:(h=(0,$.jsx)(`span`,{className:`[&>svg]:size-4 text-fg-subtle`,children:s}),t[10]=s,t[11]=h);let g;t[12]===i.title?g=t[13]:(g=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:i.title}),t[12]=i.title,t[13]=g);let _;t[14]===a?_=t[15]:(_=(0,$.jsx)($r,{status:a}),t[14]=a,t[15]=_);let v;t[16]!==g||t[17]!==_||t[18]!==h?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g,_]}),t[16]=g,t[17]=_,t[18]=h,t[19]=v):v=t[19];let y;t[20]===i.description?y=t[21]:(y=i.description?(0,$.jsx)(`p`,{className:`mt-1.5 line-clamp-2 text-xs leading-4 text-fg-muted`,children:i.description}):null,t[20]=i.description,t[21]=y);let b;t[22]===i.kind?b=t[23]:(b=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zt,{id:`true`,type:`source`,position:It.Right,className:`!invisible`}),(0,$.jsx)(zt,{id:`false`,type:`source`,position:It.Right,className:`!invisible`})]}):i.kind===`output`?null:(0,$.jsx)(zt,{type:`source`,position:It.Right,className:`!invisible`}),t[22]=i.kind,t[23]=b);let x;return t[24]!==v||t[25]!==y||t[26]!==b||t[27]!==p||t[28]!==m?(x=(0,$.jsxs)(`div`,{className:p,children:[m,v,y,b]}),t[24]=v,t[25]=y,t[26]=b,t[27]=p,t[28]=m,t[29]=x):x=t[29],x}function $r(e){let t=(0,Q.c)(4),{status:n}=e;if(n===`done`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-success`,children:(0,$.jsx)(v,{className:`size-3`})}),t[0]=e):e=t[0],e}if(n===`error`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-danger/10 text-danger`,children:(0,$.jsx)(Se,{className:`size-3`})}),t[1]=e):e=t[1],e}if(n===`running`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`size-2.5 animate-pulse rounded-full bg-accent motion-reduce:animate-none`}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-edge-strong`}),t[3]=r):r=t[3],r}var ei={runNode:Qr};function ti(e){return e===`zh`?{title:`运行过程`,hint:`点选步骤查看当前结果;画布会随着执行自动更新。`,repair:`修复这个工作流`,status:{pending:`等待中`,running:`执行中`,done:`已完成`,error:`失败`,skipped:`已跳过`}}:{title:`Live workflow`,hint:`Select a step to inspect it. The canvas updates as work progresses.`,repair:`Repair workflow`,status:{pending:`Waiting`,running:`Running`,done:`Completed`,error:`Failed`,skipped:`Skipped`}}}function ni(e,t){return t.status[e]??e}function ri(e,t){return t.phaseStatus[e]??e}function ii(e,t){let{run:n}=e;return n.status===`succeeded`?et(t.runSummarySucceeded,{agents:n.metrics.doneAgentCount,artifacts:n.metrics.artifactCount}):n.status===`failed`||n.status===`timeout`?n.error?.message??t.runSummaryFailedFallback:n.status===`cancelled`?t.runSummaryCancelled:et(t.runSummaryActive,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}function ai(e,t){let{run:n}=e;return n.status===`failed`?t.diagnosticFailedHint:n.status===`timeout`?t.diagnosticTimeoutHint:n.status===`cancelled`?t.diagnosticCancelledHint:n.status===`succeeded`&&n.metrics.errorAgentCount>0?t.diagnosticPartialHint:null}function oi(e){return ze(e)}function si({view:e,comparison:t,loading:n,language:r,localeTag:i,activeTab:o,onTabChange:s,onCancel:c,onRetry:l,onReplay:u,onOpenRunId:d,ownerAgentId:f,onRepairWorkflow:p}){let m=O(r).workflows,h=je(r),g=a(),[_,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[M,P]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[,R]=(0,Z.useState)(0),z=e?.run.status,B=z?_t.has(z):!1;(0,Z.useEffect)(()=>{e?.run.id&&(y(!1),P(null))},[e?.run.id,B,z,e?.run.metrics.errorAgentCount]),(0,Z.useEffect)(()=>{if(!B)return;let e=window.setInterval(()=>R(e=>e+1),1e3);return()=>window.clearInterval(e)},[B]);let V=(0,Z.useMemo)(()=>e?lt(e):null,[e]),H=(0,Z.useMemo)(()=>V?J(V):{phases:[],unphased:null},[V]),U=(0,Z.useMemo)(()=>T==null||!V?null:V.agents.find(e=>e.id===T)??null,[T,V]);(0,Z.useEffect)(()=>{V?.runId&&E((V.agents.find(e=>e.status===`error`||e.status===`skipped`)??V.agents.find(e=>e.status===`running`)??null)?.id??null)},[V?.runId]);let W=(0,Z.useCallback)(e=>{E(e.id)},[]),G=(0,Z.useMemo)(()=>e?ut(e):[],[e]),K=e?Ue(e.run.result):void 0,q=K?ki(K):null,ee=K?Ae(K):``,te=!!K,ne=(0,Z.useCallback)(async()=>{te&&await D(ee)&&(A(!0),window.setTimeout(()=>A(!1),1500))},[te,ee]),re=(0,Z.useCallback)(()=>{if(!te||!e)return;let t=new Blob([ee],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.run.definitionId}-${e.run.id.slice(0,8)}.md`,r.click(),URL.revokeObjectURL(n)},[te,ee,e]),ie=(0,Z.useCallback)(()=>{if(!e)return;let t=oi(e);t&&g(xt(t))},[g,e]),oe=(0,Z.useCallback)(async t=>{if(e){P(null),L(t.id);try{Di(await Qe(e.run.id,t.id,{ownerAgentId:f}),t.name||t.id)}catch(e){P(e instanceof Error?e.message:String(e))}finally{L(null)}}},[f,e]),se=(0,Z.useCallback)(t=>{if(!e||!t.prompt)return;let n=oi(e);if(!n){D(t.prompt);return}g(xt(n,t.prompt))},[g,e]),Y=(0,Z.useCallback)(e=>{if(e.kind===`copy_result`){ne();return}if(e.kind===`open_artifact`){let t=ji(e.payload),n=q?.artifacts.find(e=>e.id===t||e.name===t);n&&oe(n);return}let t=ji(e.payload),n=q?.followUps.find(e=>e.id===t);if(n?.prompt){se(n);return}let r=Mi(e.payload);r&&se({id:e.id,title:e.label,prompt:r})},[ne,oe,se,q?.artifacts,q?.followUps]),ce=(0,Z.useCallback)(t=>{if(!e||t==null)return;let n=String(t),r=e.agents.findIndex(e=>String(e.id)===n);if(r<0)return;let i=Number.parseInt(n,10);E(Number.isFinite(i)?i:r+1)},[e]),le=e?oi(e):null,ue=q?.actions.filter(e=>Ni(e,q))??[],fe=ue.some(e=>e.kind===`copy_result`);if(n)return(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel p-5`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,"aria-busy":!0,children:[(0,$.jsx)(F,{className:`h-8 w-72 max-w-full`}),(0,$.jsx)(F,{className:`mt-4 h-28 rounded-2xl`}),(0,$.jsx)(F,{className:`mt-5 h-[28rem] rounded-2xl`})]})});if(!e||!V)return null;let{run:X}=e,pe=e.controls.canCancel&&B,he=B&&X.startedAtMs!=null?Ie(Date.now()-X.startedAtMs):Ie(X.metrics.durationMs??void 0),ge=ii(e,m),_e=ai(e,m),ve=e.controls.canRetry&&e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.prompt?.trim()),ye=e.controls.canRetry&&(e.phases.some(t=>t.status===`failed`&&e.agents.some(e=>e.phaseId===t.id&&e.prompt?.trim()))||e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.phaseId&&e.prompt?.trim())),be=X.goal?.trim()||X.title,xe=e.nodes.find(e=>e.status===`running`)??e.nodes.find(e=>e.status===`error`)??[...e.nodes].reverse().find(e=>e.status===`done`),Se=xe?.kind===`output`&&!xe.error?K?.summary??xe.resultPreview:null,Ce=Se??(xe?xe.error||(r===`zh`?`${xe.status===`running`?`正在执行`:xe.status===`done`?`刚刚完成`:`需要处理`}:${xe.title}`:`${xe.status===`running`?`Working on`:xe.status===`done`?`Just completed`:`Needs attention`}: ${xe.title}`):ge),we=G.length>0||!!_e,Ee=(X.status===`failed`||X.status===`timeout`)&&!!p;return(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`section`,{className:`mx-auto w-full max-w-6xl p-5`,children:[(0,$.jsxs)(`header`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold leading-7 text-fg`,children:be}),(0,$.jsx)(`span`,{className:j(`rounded-full px-2 py-0.5 text-xs font-medium`,pt(X.status)),children:ni(X.status,m)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[X.title,` · `,X.definitionId]}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:ge}),_e?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:_e}):null,(0,$.jsxs)(`div`,{className:j(`mt-4 rounded-xl border px-3 py-2.5`,xe?.status===`error`?`border-danger/30 bg-danger/5`:`border-accent/20 bg-accent-soft/50`),children:[(0,$.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:r===`zh`?`当前状态`:`Current status`}),Se?(0,$.jsx)(`div`,{className:`mt-2 max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_calc(100%-1.5rem),transparent)]`,children:(0,$.jsx)(w,{content:Ce,compact:!0,className:`workflow-status-markdown`,codeCopy:!1,renderMermaid:!1})}):(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:Ce})]})]})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsx)(Ri,{label:m.metrics.startedAt,value:at(X.startedAtMs??X.createdAtMs,i)}),(0,$.jsx)(Ri,{label:m.metrics.duration,value:he}),(0,$.jsx)(Ri,{label:m.metrics.agents,value:et(m.agentProgress,{done:X.metrics.doneAgentCount,total:X.metrics.agentCount})}),(0,$.jsx)(Ri,{label:m.metrics.artifacts,value:String(X.metrics.artifactCount)})]})]}),(0,$.jsx)(li,{activeTab:o,onChange:s,labels:m,artifactCount:q?.artifacts.length??e.artifacts.length,language:r,showSource:!!X.metadata?.definition}),o===`result`?(0,$.jsxs)(`section`,{className:`mt-5 space-y-4`,children:[te?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-3 border-b border-edge-subtle bg-surface-panel/45 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.resultTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:m.resultReadyHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[le?(0,$.jsxs)(N,{variant:`primary`,className:`h-8 text-xs`,onClick:ie,children:[(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),m.continueInChat]}):null,ue.map(e=>(0,$.jsx)(N,{variant:`secondary`,className:`h-8 text-xs`,onClick:()=>Y(e),children:e.label},e.id)),fe?null:(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 text-xs`,onClick:ne,children:[k?(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),k?m.copied:m.copyResult]}),(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 text-xs`,onClick:re,children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),m.exportResult]})]})]}),(0,$.jsx)(`div`,{className:`px-5 py-6 sm:px-8 sm:py-8`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl`,children:(0,$.jsx)(me,{result:K,labels:h.result})})})]}):X.status!==`failed`&&X.status!==`timeout`?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:m.noResult}):null,X.status===`failed`||X.status===`timeout`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-2xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.recoveryActionsTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_e})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,$.jsxs)(N,{variant:`primary`,onClick:p,children:[(0,$.jsx)(de,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`让 AI 修复`:`Fix with AI`]}):null,ve?(0,$.jsxs)(N,{variant:`secondary`,onClick:()=>u(`failed_agents`),children:[(0,$.jsx)(Te,{className:`size-4`,"aria-hidden":!0}),m.replayFailedAgents]}):null,ye?(0,$.jsxs)(N,{variant:`secondary`,onClick:()=>u(`failed_phases`),children:[(0,$.jsx)(Te,{className:`size-4`,"aria-hidden":!0}),m.replayFailedPhases]}):null,e.controls.canRetry?(0,$.jsxs)(N,{variant:`secondary`,onClick:l,children:[(0,$.jsx)(Te,{className:`size-4`,"aria-hidden":!0}),m.rerun]}):null]})]}),(0,$.jsx)(bi,{view:e,language:r})]}):null,q?(0,$.jsx)(Ei,{task:q,labels:m,downloadingArtifactId:I,downloadError:M,onCopyText:e=>void D(e),onDownloadArtifact:e=>void oe(e),onStartFollowUp:se,compact:!0}):null,pe?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(N,{variant:`secondary`,onClick:c,className:`text-red-600 dark:text-red-300`,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),m.cancel]})}):null]}):null,o===`process`?(0,$.jsxs)($.Fragment,{children:[e.run.metadata?.definition.graph?(0,$.jsx)(Kr,{graph:e.run.metadata.definition.graph,view:e,language:r,onRepair:p}):null,we?(0,$.jsx)(ci,{diagnostics:G,labels:m,hint:_e,onOpenAgent:ce}):null,(0,$.jsx)(ui,{snapshot:V,rollup:H,view:e,labels:m,cardLabels:h,isActive:B,processExpanded:_,logsExpanded:b,selectedAgentId:T,selectedAgent:U,durationText:he,onToggleProcess:()=>y(e=>!e),onToggleLogs:()=>x(e=>!e),onSelectAgent:W}),(0,$.jsx)(gi,{view:e,comparison:t,labels:m,onOpenRunId:d}),(0,$.jsx)(_i,{view:e,labels:m})]}):null,o===`artifacts`?(0,$.jsx)(Ei,{task:q,labels:m,downloadingArtifactId:I,downloadError:M,onCopyText:e=>void D(e),onDownloadArtifact:e=>void oe(e),onStartFollowUp:se}):null,o===`source`&&X.metadata?.definition?(0,$.jsx)(Jn,{initialSource:tr($n(X.metadata.definition)),resetKey:`${X.id}:${X.metadata.definition.revision}`,fileName:`${X.definitionId}-${X.id.slice(0,8)}.workflow.json`,language:r,className:`mt-5 h-[36rem]`}):null]})})}function ci(e){let t=(0,Q.c)(13),{diagnostics:n,labels:r,hint:i,onOpenAgent:a}=e;if(n.length===0&&!i)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`rounded-xl bg-rose-500/10 p-2 text-rose-700 dark:text-rose-300`,children:(0,$.jsx)(Se,{className:`size-4`,"aria-hidden":!0})}),t[0]=o):o=t[0];let s;t[1]===r.reliabilityTitle?s=t[2]:(s=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.reliabilityTitle}),t[1]=r.reliabilityTitle,t[2]=s);let c=i??r.reliabilityHint,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r||t[7]!==a?(u=n.length>0?(0,$.jsx)(`ul`,{className:`mt-3 space-y-2`,children:n.slice(0,5).map(e=>(0,$.jsx)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:hi(e,r)}),e.message?(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:e.message}):null,e.detail?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-subtle`,children:e.detail}):null]}),e.agentId==null?null:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,onClick:()=>a(e.agentId),children:r.openAgentDetails})]})},e.key))}):null,t[5]=n,t[6]=r,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==l||t[11]!==u?(d=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-rose-500/20 bg-rose-500/5 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,l,u]})]})}),t[9]=s,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function li(e){let t=(0,Q.c)(20),{activeTab:n,onChange:r,labels:i,artifactCount:a,language:o,showSource:s}=e,c;t[0]===i.resultTitle?c=t[1]:(c={id:`result`,label:i.resultTitle},t[0]=i.resultTitle,t[1]=c);let l;t[2]===i.process?l=t[3]:(l={id:`process`,label:i.process},t[2]=i.process,t[3]=l);let u=a||void 0,d;t[4]!==i.taskArtifacts||t[5]!==u?(d={id:`artifacts`,label:i.taskArtifacts,count:u},t[4]=i.taskArtifacts,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==o||t[8]!==s?(f=s?[{id:`source`,label:o===`zh`?`执行定义`:`Run definition`}]:[],t[7]=o,t[8]=s,t[9]=f):f=t[9];let p;t[10]!==c||t[11]!==l||t[12]!==d||t[13]!==f?(p=[c,l,d,...f],t[10]=c,t[11]=l,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=p,h;return t[15]!==n||t[16]!==i.taskActionsAria||t[17]!==r||t[18]!==m?(h=(0,$.jsx)(`div`,{className:`mt-5 flex overflow-x-auto border-b border-edge pb-2`,children:(0,$.jsx)(Et,{items:m,activeTab:n,onChange:r,ariaLabel:i.taskActionsAria})}),t[15]=n,t[16]=i.taskActionsAria,t[17]=r,t[18]=m,t[19]=h):h=t[19],h}function ui(e){let t=(0,Q.c)(37),{snapshot:n,rollup:r,view:i,labels:a,cardLabels:o,isActive:s,processExpanded:c,logsExpanded:l,selectedAgentId:u,selectedAgent:d,durationText:f,onToggleProcess:p,onToggleLogs:m,onSelectAgent:h}=e,g;t[0]===a.process?g=t[1]:(g=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.process}),t[0]=a.process,t[1]=g);let _;t[2]!==a.agentProgress||t[3]!==i.run.metrics.agentCount||t[4]!==i.run.metrics.doneAgentCount?(_=et(a.agentProgress,{done:i.run.metrics.doneAgentCount,total:i.run.metrics.agentCount}),t[2]=a.agentProgress,t[3]=i.run.metrics.agentCount,t[4]=i.run.metrics.doneAgentCount,t[5]=_):_=t[5];let v;t[6]!==f||t[7]!==_?(v=(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[_,` · `,f]}),t[6]=f,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==g||t[10]!==v?(y=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[g,v]}),t[9]=g,t[10]=v,t[11]=y):y=t[11];let b=c?`rotate-180`:null,x;t[12]===b?x=t[13]:(x=j(`size-4 shrink-0 text-fg-subtle transition-transform`,b),t[12]=b,t[13]=x);let S;t[14]===x?S=t[15]:(S=(0,$.jsx)(Le,{className:x,"aria-hidden":!0}),t[14]=x,t[15]=S);let C;t[16]!==p||t[17]!==c||t[18]!==y||t[19]!==S?(C=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-4 px-4 py-3 text-left`,onClick:p,"aria-expanded":c,children:[y,S]}),t[16]=p,t[17]=c,t[18]=y,t[19]=S,t[20]=C):C=t[20];let w;t[21]!==o||t[22]!==s||t[23]!==a||t[24]!==l||t[25]!==h||t[26]!==m||t[27]!==c||t[28]!==r||t[29]!==d||t[30]!==u||t[31]!==n||t[32]!==i.phases?(w=c?(0,$.jsx)(`div`,{className:`border-t border-edge px-4 pb-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(20rem,26rem)]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s?(0,$.jsx)(U,{snapshot:n,labels:o,logsExpanded:l,onToggleLogs:m,selectedAgentId:u,onSelectAgent:h}):(0,$.jsx)(Ct,{rollup:r,currentPhase:n.currentPhase,labels:o.phase,recentLogs:n.logs,recentLogsHeading:o.recentLogsHeading,showAllLogsLabel:o.showAllLogs,logsExpanded:l,onToggleLogs:m,selectedAgentId:u,onSelectAgent:h}),i.phases.length>0?(0,$.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:i.phases.map(e=>(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:ri(e.status,a)})]})},e.id))}):null]}),(0,$.jsx)(di,{agent:d,snapshot:n,labels:a,cardLabels:o})]})}):null,t[21]=o,t[22]=s,t[23]=a,t[24]=l,t[25]=h,t[26]=m,t[27]=c,t[28]=r,t[29]=d,t[30]=u,t[31]=n,t[32]=i.phases,t[33]=w):w=t[33];let T;return t[34]!==C||t[35]!==w?(T=(0,$.jsxs)(`div`,{className:`mt-5 rounded-2xl border border-edge bg-surface-base/35`,children:[C,w]}),t[34]=C,t[35]=w,t[36]=T):T=t[36],T}function di(e){let t=(0,Q.c)(57),{agent:n,snapshot:r,labels:i,cardLabels:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s(!1)},t[0]=c):c=t[0];let l=n?.id,u;if(t[1]===l?u=t[2]:(u=[l],t[1]=l,t[2]=u),(0,Z.useEffect)(c,u),!n){let e;return t[3]===i.noSubagents?e=t[4]:(e=(0,$.jsx)(`aside`,{className:`min-w-0 rounded-2xl border border-dashed border-edge bg-surface-panel/45 p-4 text-sm text-fg-muted`,children:i.noSubagents}),t[3]=i.noSubagents,t[4]=e),e}let d;t[5]===n?d=t[6]:(d=xe(n),t[5]=n,t[6]=d);let f=d,p=n.error||n.resultPreview||n.currentStep||a.checkDetail.runningPlaceholder,m;t[7]===n.label?m=t[8]:(m=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.label}),t[7]=n.label,t[8]=m);let h=n.phase||i.process,g;t[9]!==f||t[10]!==h?(g=[h,f].filter(Boolean),t[9]=f,t[10]=h,t[11]=g):g=t[11];let _=g.join(` · `),v;t[12]===_?v=t[13]:(v=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_}),t[12]=_,t[13]=v);let y;t[14]!==m||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[m,v]}),t[14]=m,t[15]=v,t[16]=y):y=t[16];let b;t[17]===n.status?b=t[18]:(b=j(`rounded-full px-2 py-0.5 text-xs font-medium`,Li(n.status)),t[17]=n.status,t[18]=b);let x=i.agentStatus[n.status]??n.status,S;t[19]!==b||t[20]!==x?(S=(0,$.jsx)(`span`,{className:b,children:x}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]===i.agentOutputHeading?w=t[26]:(w=(0,$.jsx)(`h4`,{className:`text-xs font-semibold text-fg`,children:i.agentOutputHeading}),t[25]=i.agentOutputHeading,t[26]=w);let T=n.error?`font-mono text-rose-600 dark:text-rose-400`:`text-fg-muted`,E;t[27]===T?E=t[28]:(E=j(`mt-2 max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-6`,T),t[27]=T,t[28]=E);let D;t[29]!==p||t[30]!==E?(D=(0,$.jsx)(`div`,{className:E,children:p}),t[29]=p,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==w||t[33]!==D?(O=(0,$.jsxs)(`section`,{className:`mt-4 rounded-xl border border-edge-subtle bg-surface-base/60 p-3`,children:[w,D]}),t[32]=w,t[33]=D,t[34]=O):O=t[34];let k;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>s(mi),t[35]=k):k=t[35];let A=i.debugDetailsTitle,M=o&&`rotate-180`,N;t[36]===M?N=t[37]:(N=j(`size-4 shrink-0 text-fg-subtle transition-transform`,M),t[36]=M,t[37]=N);let P;t[38]===N?P=t[39]:(P=(0,$.jsx)(Le,{className:N,"aria-hidden":!0}),t[38]=N,t[39]=P);let F;t[40]!==o||t[41]!==i.debugDetailsTitle||t[42]!==P?(F=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-xs font-semibold text-fg`,onClick:k,"aria-expanded":o,children:[A,P]}),t[40]=o,t[41]=i.debugDetailsTitle,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==o||t[45]!==n||t[46]!==a||t[47]!==i||t[48]!==r?(I=o?(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle p-3`,children:[n.steps?.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.checkDetail.stepsHeading}),(0,$.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.steps.slice(0,8).map(pi)})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.agentInputHeading}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-44 overflow-auto whitespace-pre-wrap wrap-break-word rounded-lg bg-surface-panel p-2 font-mono text-xs leading-5 text-fg-muted`,children:n.prompt||`—`})]}),(0,$.jsx)(Pi,{agent:n,labels:i}),r.logs.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.recentLogsHeading}),(0,$.jsx)(`div`,{className:`mt-1 max-h-36 space-y-0.5 overflow-auto rounded-lg bg-surface-panel p-2 font-mono text-xs text-fg-subtle`,children:r.logs.map(fi)})]}):null]}):null,t[44]=o,t[45]=n,t[46]=a,t[47]=i,t[48]=r,t[49]=I):I=t[49];let L;t[50]!==F||t[51]!==I?(L=(0,$.jsxs)(`section`,{className:`mt-3 rounded-xl border border-edge-subtle bg-surface-base/40`,children:[F,I]}),t[50]=F,t[51]=I,t[52]=L):L=t[52];let R;return t[53]!==C||t[54]!==O||t[55]!==L?(R=(0,$.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-edge bg-surface-panel p-4`,children:[C,O,L]}),t[53]=C,t[54]=O,t[55]=L,t[56]=R):R=t[56],R}function fi(e){return(0,$.jsx)(`div`,{className:`wrap-break-word`,children:e},e)}function pi(e){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-subtle`,children:e.status})]}),e.detail||e.resultPreview||e.error?(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.error||e.resultPreview||e.detail}):null]},e.id)}function mi(e){return!e}function hi(e,t){return e.kind===`run_error`?e.code?et(t.diagnosticsRunErrorWithCode,{code:e.code}):t.diagnosticsRunError:e.kind===`agent_error`?et(t.diagnosticsAgentError,{agent:e.agentLabel??String(e.agentId??`—`)}):e.kind===`step_error`?et(t.diagnosticsStepError,{agent:e.agentLabel??String(e.agentId??`—`),step:e.stepLabel??e.stepId??`—`}):et(t.diagnosticsAgentSkipped,{agent:e.agentLabel??String(e.agentId??`—`)})}function gi(e){let t=(0,Q.c)(36),{view:n,comparison:r,labels:i,onOpenRunId:a}=e,o=n.run.metadata?.replay;if(!o)return null;let s;t[0]===i.replayLineageTitle?s=t[1]:(s=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.replayLineageTitle}),t[0]=i.replayLineageTitle,t[1]=s);let c;t[2]!==i||t[3]!==o.scope||t[4]!==o.targetCount?(c=et(i.replayLineageSummary,{scope:yi(o.scope,i),count:o.targetCount}),t[2]=i,t[3]=o.scope,t[4]=o.targetCount,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[6]=c,t[7]=l);let u;t[8]!==i.replaySourceRun||t[9]!==o.sourceRunId?(u=(0,$.jsx)(zi,{label:i.replaySourceRun,value:o.sourceRunId}),t[8]=i.replaySourceRun,t[9]=o.sourceRunId,t[10]=u):u=t[10];let d=i.replayTargetAgents,f;t[11]===o.agentIds?f=t[12]:(f=o.agentIds.join(`, `),t[11]=o.agentIds,t[12]=f);let p;t[13]!==i.replayTargetAgents||t[14]!==f?(p=(0,$.jsx)(zi,{label:d,value:f}),t[13]=i.replayTargetAgents,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18];let h;t[19]!==r||t[20]!==i.replayDurationDelta||t[21]!==i.replayFixedAgents||t[22]!==i.replayStillFailingAgents?(h=r?(0,$.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-3`,children:[(0,$.jsx)(Ri,{label:i.replayFixedAgents,value:String(r.fixedAgentIds.length)}),(0,$.jsx)(Ri,{label:i.replayStillFailingAgents,value:String(r.stillFailingAgentIds.length)}),(0,$.jsx)(Ri,{label:i.replayDurationDelta,value:vi(r.durationDeltaMs)})]}):null,t[19]=r,t[20]=i.replayDurationDelta,t[21]=i.replayFixedAgents,t[22]=i.replayStillFailingAgents,t[23]=h):h=t[23];let g;t[24]!==s||t[25]!==l||t[26]!==m||t[27]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s,l,m,h]}),t[24]=s,t[25]=l,t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==i.replayOpenSource||t[30]!==a||t[31]!==o.sourceRunId?(_=a?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>a(o.sourceRunId),children:i.replayOpenSource}):null,t[29]=i.replayOpenSource,t[30]=a,t[31]=o.sourceRunId,t[32]=_):_=t[32];let v;return t[33]!==g||t[34]!==_?(v=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[g,_]})}),t[33]=g,t[34]=_,t[35]=v):v=t[35],v}function _i(e){let t=(0,Q.c)(40),{view:n,labels:r}=e,i;t[0]===n.run.metadata?.contextRefs?i=t[1]:(i=n.run.metadata?.contextRefs??[],t[0]=n.run.metadata?.contextRefs,t[1]=i);let a=i,o=n.run.metadata?.contextSnapshot,s;t[2]===n.run.metadata?.writebackPolicy?.targets?s=t[3]:(s=n.run.metadata?.writebackPolicy?.targets??[],t[2]=n.run.metadata?.writebackPolicy?.targets,t[3]=s);let c=s;if(!a.length&&!c.length)return null;let l;t[4]===r.contextRefsTitle?l=t[5]:(l=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.contextRefsTitle}),t[4]=r.contextRefsTitle,t[5]=l);let u;t[6]!==r.contextRefsHint||t[7]!==r.contextSnapshotSummary||t[8]!==o?(u=o?r.contextSnapshotSummary.replace(`{{count}}`,String(o.totalTokens)):r.contextRefsHint,t[6]=r.contextRefsHint,t[7]=r.contextSnapshotSummary,t[8]=o,t[9]=u):u=t[9];let d;t[10]===u?d=t[11]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:u}),t[10]=u,t[11]=d);let f;t[12]!==r.contextRefKinds||t[13]!==r.noContextRefs||t[14]!==a?(f=a.length?a.map(e=>(0,$.jsx)(zi,{label:r.contextRefKinds[e.kind]??e.kind,value:[e.title||e.id,e.role].filter(Boolean).join(` · `)},`${e.kind}:${e.id}:${e.role??``}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noContextRefs}),t[12]=r.contextRefKinds,t[13]=r.noContextRefs,t[14]=a,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:f}),t[16]=f,t[17]=p);let m;t[18]!==l||t[19]!==d||t[20]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[l,d,p]}),t[18]=l,t[19]=d,t[20]=p,t[21]=m):m=t[21];let h;t[22]===r.writebackTitle?h=t[23]:(h=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.writebackTitle}),t[22]=r.writebackTitle,t[23]=h);let g;t[24]===r.writebackHint?g=t[25]:(g=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.writebackHint}),t[24]=r.writebackHint,t[25]=g);let _;t[26]!==r.noWritebackTargets||t[27]!==r.writebackModes||t[28]!==r.writebackTargetKinds||t[29]!==c?(_=c.length?c.map(e=>(0,$.jsx)(zi,{label:r.writebackTargetKinds[e.kind]??e.kind,value:`${e.id} · ${r.writebackModes[e.mode]??e.mode}`},`${e.kind}:${e.id}:${e.mode}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noWritebackTargets}),t[26]=r.noWritebackTargets,t[27]=r.writebackModes,t[28]=r.writebackTargetKinds,t[29]=c,t[30]=_):_=t[30];let v;t[31]===_?v=t[32]:(v=(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_}),t[31]=_,t[32]=v);let y;t[33]!==g||t[34]!==v||t[35]!==h?(y=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[h,g,v]}),t[33]=g,t[34]=v,t[35]=h,t[36]=y):y=t[36];let b;return t[37]!==y||t[38]!==m?(b=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[m,y]})}),t[37]=y,t[38]=m,t[39]=b):b=t[39],b}function vi(e){return e==null?`—`:`${e>0?`+`:e<0?`-`:``}${Ie(Math.abs(e))}`}function yi(e,t){return e===`failed_phases`?t.replayScopeFailedPhases:t.replayScopeFailedAgents}function bi(e){let t=(0,Q.c)(8),{view:n,language:r}=e,i=n.nodes,a,o;if(t[0]!==r||t[1]!==n.nodes){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.filter(Ti),s=n.nodes.filter(wi);if(e.length===0&&s.length===0){o=null;break bb0}let c=r===`zh`?`已保留的阶段结果`:`Work completed before the failure`,l;t[4]===c?l=t[5]:(l=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c}),t[4]=c,t[5]=l);let u=r===`zh`?`失败不会清空已经完成的工作。你可以先使用这些结果,再让 AI 修复剩余步骤。`:`Completed work is preserved. You can use it now and ask AI to repair the remaining steps.`,d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u}),t[6]=u,t[7]=d),a=(0,$.jsxs)(`section`,{className:`rounded-2xl border border-amber-500/25 bg-amber-500/5 p-4`,children:[l,d,e.length>0?(0,$.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(Ci)}):null,s.length>0?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:r===`zh`?`待修复:${s.map(Si).join(`、`)}`:`Needs repair: ${s.map(xi).join(`, `)}`}):null]})}t[0]=r,t[1]=n.nodes,t[2]=a,t[3]=o}else a=t[2],o=t[3];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function xi(e){return e.title}function Si(e){return e.title}function Ci(e){return(0,$.jsxs)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-base/60 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-fg-muted`,children:e.resultPreview})]},e.id)}function wi(e){return e.status===`error`}function Ti(e){return e.status===`done`&&e.resultPreview?.trim()}function Ei(e){let t=(0,Q.c)(19),{task:n,labels:r,downloadingArtifactId:i,downloadError:a,onCopyText:o,onDownloadArtifact:s,onStartFollowUp:c,compact:l}=e,u=l===void 0?!1:l;if(!n||!n.artifacts.length&&!n.followUps.length){if(u)return null;let e;return t[0]===r.noArtifacts?e=t[1]:(e=(0,$.jsx)(`section`,{className:`mt-5 rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:r.noArtifacts}),t[0]=r.noArtifacts,t[1]=e),e}let d=!u&&`mt-5`,f;t[2]===d?f=t[3]:(f=j(`grid gap-3 lg:grid-cols-3`,d),t[2]=d,t[3]=f);let p;t[4]!==a||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.artifacts?(p=n.artifacts.length>0?(0,$.jsxs)(Oi,{title:r.taskArtifacts,children:[(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.artifacts.map(e=>(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,title:e.title??e.name,children:e.title??e.name}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.mimeType}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline disabled:cursor-wait disabled:opacity-60`,disabled:i===e.id,onClick:()=>s(e),children:[(0,$.jsx)(C,{className:`size-3`,"aria-hidden":!0}),i===e.id?r.downloadingArtifact:r.downloadArtifact]})]},e.id))}),a?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-rose-600 dark:text-rose-400`,children:a}):null]}):null,t[4]=a,t[5]=i,t[6]=r,t[7]=s,t[8]=n.artifacts,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==o||t[12]!==c||t[13]!==n.followUps?(m=n.followUps.length>0?(0,$.jsx)(Oi,{title:r.taskFollowUps,children:(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.followUps.map(e=>(0,$.jsxs)(`li`,{className:`rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),e.prompt?(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>c(e),children:r.startFollowUp}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-subtle hover:text-fg`,onClick:()=>o(e.prompt??``),children:r.copyPrompt})]}):null]},e.id))})}):null,t[10]=r,t[11]=o,t[12]=c,t[13]=n.followUps,t[14]=m):m=t[14];let h;return t[15]!==f||t[16]!==p||t[17]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[15]=f,t[16]=p,t[17]=m,t[18]=h):h=t[18],h}function Di(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function Oi(e){let t=(0,Q.c)(10),{title:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=j(`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/35 p-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,$.jsx)(`div`,{className:`mt-2`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`section`,{className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function ki(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Array.isArray(t.actions)?t.actions:[],r=Array.isArray(t.artifacts)?t.artifacts:[],i=Array.isArray(t.followUps)?t.followUps:[];return n.length===0&&r.length===0&&i.length===0?null:{actions:n,artifacts:r,followUps:i}}function Ai(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function ji(e){if(typeof e==`string`)return e.trim()||null;let t=Ai(e);if(!t)return null;for(let e of[`artifactId`,`followUpId`,`id`,`name`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Mi(e){let t=Ai(e);if(!t)return null;for(let e of[`prompt`,`message`,`text`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Ni(e,t){if(e.kind===`copy_result`)return!0;let n=ji(e.payload);return e.kind===`open_artifact`?!!(n&&t.artifacts.some(e=>e.id===n||e.name===n)):e.kind===`start_followup`?!!(Mi(e.payload)||n&&t.followUps.some(e=>e.id===n&&e.prompt)):!!Mi(e.payload)}function Pi(e){let t=(0,Q.c)(21),{agent:n,labels:r}=e,i=n.invocation;if(!i)return null;let a=i.resolvedModelRef??i.modelRef,o;t[0]!==r.agentInvocationModel||t[1]!==a?(o={label:r.agentInvocationModel,value:a},t[0]=r.agentInvocationModel,t[1]=a,t[2]=o):o=t[2];let s;t[3]===i.toolset?s=t[4]:(s=i.toolset?.join(`, `),t[3]=i.toolset,t[4]=s);let c;t[5]!==r.agentInvocationTools||t[6]!==s?(c={label:r.agentInvocationTools,value:s},t[5]=r.agentInvocationTools,t[6]=s,t[7]=c):c=t[7];let l=i.maxIterations==null?void 0:String(i.maxIterations),u;t[8]!==r.agentInvocationIterations||t[9]!==l?(u={label:r.agentInvocationIterations,value:l},t[8]=r.agentInvocationIterations,t[9]=l,t[10]=u):u=t[10];let d=i.schema?r.agentInvocationSchemaPresent:void 0,f;t[11]!==r.agentInvocationSchema||t[12]!==d?(f={label:r.agentInvocationSchema,value:d},t[11]=r.agentInvocationSchema,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==c||t[16]!==u||t[17]!==f?(p=[o,c,u,f].filter(Ii),t[14]=o,t[15]=c,t[16]=u,t[17]=f,t[18]=p):p=t[18];let m=p;if(m.length===0)return null;let h;return t[19]===m?h=t[20]:(h=(0,$.jsx)(`dl`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 text-xs sm:grid-cols-2 lg:grid-cols-4`,children:m.map(Fi)}),t[19]=m,t[20]=h),h}function Fi(e){return(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:e.label}),(0,$.jsx)(`dd`,{className:`mt-0.5 truncate font-medium text-fg-muted`,title:e.value,children:e.value})]},e.label)}function Ii(e){return!!e.value}function Li(e){return e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-rose-500/10 text-rose-700 dark:text-rose-300`:e===`running`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-subtle`}function Ri(e){let t=(0,Q.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`dd`,{className:`mt-1 text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base/40 p-3`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function zi(e){let t=(0,Q.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`div`,{className:`mt-1 truncate text-sm font-medium text-fg`,title:r,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Bi(){let e=(0,Q.c)(8),t=A(Vi),[n]=o(),r;e[0]===n?r=e[1]:(r=n.get(`agentId`)?.trim()||void 0,e[0]=n,e[1]=r);let i=r,a;e[2]===t?a=e[3]:(a=t?[`workflow-route-agents`,t]:null,e[2]=t,e[3]=a);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let c=M(a,st,s),l=i??c.data?.defaultId,u;return e[5]!==c.isLoading||e[6]!==l?(u={ownerAgentId:l,loading:c.isLoading},e[5]=c.isLoading,e[6]=l,e[7]=u):u=e[7],u}function Vi(e){return e.token}function Hi(e){let t=(0,Q.c)(19),n=A(Ui),r;t[0]===n?r=t[1]:(r=n?[`workflow-route-definitions`,n]:null,t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=M(r,yt,i),o;t[3]!==e||t[4]!==a.data?(o=a.data?.find(t=>t.id===e||t.name===e),t[3]=e,t[4]=a.data,t[5]=o):o=t[5];let s=o,c;t[6]===a?c=t[7]:(c=async e=>{await a.mutate(t=>[...(t??[]).filter(t=>t.id!==e.id&&t.name!==e.name),e],{revalidate:!1})},t[6]=a,t[7]=c);let l=c,u;t[8]===a?u=t[9]:(u=async()=>{await a.mutate()},t[8]=a,t[9]=u);let d=u,f;t[10]===a.data?f=t[11]:(f=a.data??[],t[10]=a.data,t[11]=f);let p;return t[12]!==s||t[13]!==a.error||t[14]!==a.isLoading||t[15]!==d||t[16]!==f||t[17]!==l?(p={definition:s,definitions:f,loading:a.isLoading,error:a.error,upsertDefinition:l,refreshDefinitions:d},t[12]=s,t[13]=a.error,t[14]=a.isLoading,t[15]=d,t[16]=f,t[17]=l,t[18]=p):p=t[18],p}function Ui(e){return e.token}var Wi=()=>({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``});function Gi(){let{definitionId:e}=c(),[t,n]=o(),r=a(),i=k(e=>e.language),s=O(i).workflows,u=i===`zh`?`zh-CN`:`en-US`,d=ct(e=>e.setPageHeader),f=ct(e=>e.clearPageHeader),{ownerAgentId:p}=Bi(),m=t.get(`projectId`)?.trim()||void 0,h=t.get(`view`)===`source`?`source`:`canvas`,{definition:g,loading:_,error:v}=Hi(e),x=M(`workflow-project-options`,()=>Ve({limit:100,sortBy:`updatedAt`,sortOrder:`desc`}),{revalidateOnFocus:!1}),S=M(m?[`workflow-project-presets`,m]:null,()=>ft(m),{revalidateOnFocus:!1}),C=M(p?[`workflow-detail-runs`,p,e,m??``]:null,()=>gt(100,{ownerAgentId:p,projectId:m}),{revalidateOnFocus:!1}),[w,T]=(0,Z.useState)(Wi),[E,D]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),B=(0,Z.useRef)(void 0),H=(0,Z.useMemo)(()=>(C.data??[]).filter(e=>e.definitionId===g?.id).slice(0,6),[g?.id,C.data]),U=kt(g,w),W=g?ue(g,i):null,G=S.data?.find(e=>e.definitionId===g?.id),K=!!G&&JSON.stringify(G?.contextRefs)===JSON.stringify(E);(0,Z.useEffect)(()=>{if(!m||!g||!S.data)return;let e=`${m}:${g.id}`;B.current!==e&&(B.current=e,D(G?.contextRefs??[]))},[g,m,G?.contextRefs,S.data]);let te=(0,Z.useCallback)(e=>{B.current=void 0,D([]),n(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n},{replace:!0})},[n]),re=(0,Z.useCallback)(async()=>{if(!(!m||!g||P)){F(!0),L(null);try{let e=await q(m,g.id,E);await S.mutate(t=>[e,...(t??[]).filter(t=>t.definitionId!==e.definitionId)],{revalidate:!1})}catch(e){L(e instanceof Error?e.message:s.projectWorkflowSaveFailed)}finally{F(!1)}}},[E,g,s.projectWorkflowSaveFailed,m,S,P]),ae=(0,Z.useCallback)(async()=>{if(!(!m||!g||P)){F(!0),L(null);try{await ge(m,g.id),await S.mutate(e=>(e??[]).filter(e=>e.definitionId!==g.id),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:s.projectWorkflowRemoveFailed)}finally{F(!1)}}},[g,s.projectWorkflowRemoveFailed,m,S,P]),J=new URLSearchParams({tab:`library`});p&&J.set(`agentId`,p),m&&J.set(`projectId`,m);let se=`/workflows?${J.toString()}`,Y=new URLSearchParams;p&&Y.set(`agentId`,p),m&&Y.set(`projectId`,m);let ce=Y.size?`?${Y.toString()}`:``,le=e=>{n(t=>{let n=new URLSearchParams(t);return e===`source`?n.set(`view`,`source`):n.delete(`view`),n},{replace:!0})},de=null;if(g){let e=new URLSearchParams;p&&e.set(`agentId`,p),m&&e.set(`projectId`,m),g.metadata.source!==`user`&&e.set(`copy`,g.id),de=`${g.metadata.source===`user`?`/workflows/${g.id}/edit`:`/workflows/new`}${e.size?`?${e.toString()}`:``}`}(0,Z.useLayoutEffect)(()=>(d({startExtra:(0,$.jsx)(l,{to:se,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":i===`zh`?`返回工作流库`:`Back to workflow library`,children:(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})}),main:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:g?.title??(i===`zh`?`工作流详情`:`Workflow details`)}),g?(0,$.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[g.metadata.source===`user`?s.badgeUser:s.badgeBuiltin,` · `,i===`zh`?`版本 ${g.revision}`:`Version ${g.revision}`]}):null]}),end:g&&de?(0,$.jsx)(N,{asChild:!0,variant:`secondary`,className:`h-9 shrink-0`,children:(0,$.jsxs)(l,{to:de,children:[g.metadata.source===`user`?(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),g.metadata.source===`user`?s.editWorkflow:s.copyAndEditWorkflow]})}):null}),()=>f()),[f,g,de,s.badgeBuiltin,s.badgeUser,s.copyAndEditWorkflow,s.editWorkflow,i,se,d]);let fe=(0,Z.useCallback)(async()=>{if(!(!g||!U.valid||A)){j(!0),L(null);try{r(`/workflows/runs/${(await Je({definitionId:g.id,goal:w.goal.trim()||W?.description||g.title,input:At(g,w),agentId:p,projectId:m,contextRefs:E,concurrency:w.concurrency.trim()?Number(w.concurrency):void 0,maxSubagents:w.maxSubagents.trim()?Number(w.maxSubagents):void 0})).runId}${ce}`)}catch(e){L(e instanceof Error?e.message:s.startFailed)}finally{j(!1)}}},[E,g,U.valid,s.startFailed,W?.description,r,p,m,ce,w,A]);return _?(0,$.jsx)(Xi,{}):!g||!W?(0,$.jsx)(Zi,{message:v?.message??(i===`zh`?`没有找到这个工作流`:`Workflow not found`)}):(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 py-5 sm:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`max-w-3xl text-sm leading-6 text-fg-muted`,children:W.description}),(0,$.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,role:`tablist`,"aria-label":i===`zh`?`工作流视图`:`Workflow view`,children:[`canvas`,`source`].map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===e,className:`rounded-md px-3 py-1.5 text-xs font-medium ${h===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,onClick:()=>le(e),children:e===`canvas`?i===`zh`?`画布`:`Canvas`:i===`zh`?`源码`:`Source`},e))})]}),(0,$.jsxs)(`div`,{className:`mt-5 grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:h===`source`?(0,$.jsx)(Jn,{initialSource:tr(Zn(g)),resetKey:`${g.id}:${g.revision}`,fileName:`${g.name}.workflow.json`,language:i}):(0,$.jsx)(Br,{graph:g.graph,language:i,className:`h-[28rem] rounded-xl border border-edge`})}),(0,$.jsxs)(`aside`,{className:`rounded-xl border border-edge bg-surface-base/45 p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i===`zh`?`开始一次运行`:`Start a run`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:W.whenToUse||W.description}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`mb-1.5 flex items-center gap-1.5`,children:[(0,$.jsx)(z,{className:`size-3.5 text-fg-subtle`,"aria-hidden":!0}),s.runProject]}),(0,$.jsxs)(y,{value:m??``,"aria-label":s.runProject,onChange:e=>te(e.target.value),className:`h-9 w-full rounded-lg border border-edge bg-surface-panel px-2.5 text-sm text-fg shadow-surface`,children:[(0,$.jsx)(b,{value:``,children:s.runProjectNone}),(x.data?.items??[]).filter(e=>e.status!==`archived`&&e.status!==`cancelled`).map(e=>(0,$.jsx)(b,{value:e.id,children:e.name},e.id))]})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(Lr,{projectId:m,language:i,value:E,onChange:D})}),m?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-8 flex-1 justify-start px-2 text-xs`,disabled:P||K,onClick:()=>void re(),children:[(0,$.jsx)(vt,{className:`size-3.5`,"aria-hidden":!0}),K?s.projectWorkflowSaved:G?s.updateProjectWorkflow:s.saveProjectWorkflow]}),G?(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-fg-muted`,disabled:P,"aria-label":s.removeProjectWorkflow,onClick:()=>void ae(),children:(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(jt,{definition:g,language:i,value:w,onChange:T,mode:`manual`,badgeLabel:s.readyToStart,aiAssist:{context:{surface:`workflow-start`,workflowId:g.id,workflowName:g.name,workflowTitle:g.title,workflowDescription:W.description}}})}),I?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:I}):null,(0,$.jsxs)(N,{variant:`primary`,className:`mt-4 w-full`,disabled:!U.valid||A,onClick:()=>void fe(),children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),A?s.starting:s.runWorkflow]})]})]}),(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i===`zh`?`最近运行`:`Recent runs`}),H.length?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:H.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base/40 p-3 text-left hover:bg-surface-hover`,onClick:()=>r(`/workflows/runs/${e.id}${ce}`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:s.status[e.status]})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ne(e.createdAtMs,u)})]},e.id))}):(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:i===`zh`?`还没有运行记录。`:`No runs yet.`})]})]})})}function Ki(){let{definitionId:e}=c(),[t]=o(),n=a(),r=k(e=>e.language),{ownerAgentId:i}=Bi(),s=t.get(`copy`)?.trim()||void 0,l=t.get(`repairRun`)?.trim()||void 0,u=t.get(`projectId`)?.trim()||void 0,d=new URLSearchParams;i&&d.set(`agentId`,i),u&&d.set(`projectId`,u);let f=d.size?`?${d.toString()}`:``,{definition:p,definitions:m,loading:h,upsertDefinition:g,refreshDefinitions:_}=Hi(e??s),v=M(l&&i?[`workflow-repair-run`,l,i]:null,()=>Re(l,{ownerAgentId:i}),{revalidateOnFocus:!1}),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=(0,Z.useMemo)(()=>m.map(e=>e.name),[m]),E=(0,Z.useMemo)(()=>mr(`my_workflow`,T),[T]),D=(0,Z.useMemo)(()=>{if(!p)return null;let t=e&&p.metadata.source===`user`?`edit`:`copy`,n=(v.data?.nodes.filter(e=>e.status===`error`)??[]).map(e=>r===`zh`?`${e.title}:${e.error??`执行失败`}`:`${e.title}: ${e.error??`execution failed`}`).join(r===`zh`?`;`:`; `)||v.data?.run.error?.message||void 0,i=l&&v.data?r===`zh`?`修复这次运行中的失败步骤,并保持原始目标不变:${n??`请根据运行记录定位失败原因`}`:`Repair the failed steps from this run while preserving the original goal: ${n??`use the run record to identify the failure`}`:void 0;return{mode:t,name:t===`edit`?p.name:Yi(p.name,m),graph:structuredClone(p.graph),manifest:Kn(p),baseRevision:t===`edit`?p.revision:0,sourceTitle:p.title,repairPrompt:i}},[p,e,m,r,v.data?.nodes,l]),O=(0,Z.useCallback)(async e=>{b(!0),S(null),w(null);try{let t=await fe(e.name,e.graph,e.manifest,e.expectedRevision);return await g(t),n(`/workflows/${t.id}/edit${f}`,{replace:!0}),t}catch(e){let t=hr(e);w(t),t||S(e instanceof Error?e.message:String(e))}finally{b(!1)}},[f,n,g]),A=(0,Z.useCallback)(async e=>{b(!0),S(null),w(null);try{let t=await fe(e.name,e.graph,e.manifest,e.expectedRevision);await g(t),n(`/workflows/runs/${(await Je({definitionId:t.id,goal:e.goal,input:{goal:e.goal},agentId:i,projectId:u})).runId}${f}`)}catch(e){let t=hr(e);throw w(t),t||S(e instanceof Error?e.message:String(e)),e}finally{b(!1)}},[f,n,i,u,g]);return h?(0,$.jsx)(Xi,{}):e&&!p?(0,$.jsx)(Zi,{message:r===`zh`?`没有找到这个工作流`:`Workflow not found`}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[x?(0,$.jsx)(`div`,{className:`border-b border-danger/30 bg-danger/5 px-4 py-2 text-sm text-danger`,children:x}):null,(0,$.jsx)(_r,{language:r,ownerAgentId:i,saving:y,initialDraft:D,initialName:E,existingNames:T,saveConflict:C,onSave:O,onSaveAndStart:A,onClearSaveConflict:()=>w(null),onReloadLatest:()=>{w(null),S(null),_()}})]})}function qi(){let e=(0,Q.c)(53),{runId:t}=c(),n=a(),r=k(Ji),i=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:o}=Bi(),s;e[0]===o?s=e[1]:(s={ownerAgentId:o},e[0]=o,e[1]=s);let l=We(t,s),[u,d]=(0,Z.useState)(`process`),f=(0,Z.useRef)(!0),p;e[2]!==l.view?.run.metadata?.replay||e[3]!==o||e[4]!==t?(p=l.view?.run.metadata?.replay&&t?[`workflow-run-page-comparison`,t,o]:null,e[2]=l.view?.run.metadata?.replay,e[3]=o,e[4]=t,e[5]=p):p=e[5];let m;e[6]!==o||e[7]!==t?(m=()=>we(t,{ownerAgentId:o}),e[6]=o,e[7]=t,e[8]=m):m=e[8];let h;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},e[9]=h):h=e[9];let g=M(p,m,h),_;e[10]===l.view?_=e[11]:(_=l.view?_t.has(l.view.run.status):!0,e[10]=l.view,e[11]=_);let v=_,y,b;e[12]===v?(y=e[13],b=e[14]):(y=()=>{f.current&&!v&&d(`result`),f.current=v},b=[v],e[12]=v,e[13]=y,e[14]=b),(0,Z.useEffect)(y,b);let x;e[15]!==n||e[16]!==o?(x=e=>{n(`/workflows/runs/${e}${o?`?agentId=${encodeURIComponent(o)}`:``}`)},e[15]=n,e[16]=o,e[17]=x):x=e[17];let S=x,C;e[18]!==S||e[19]!==o||e[20]!==t?(C=async()=>{t&&S((await ve(t,{ownerAgentId:o})).runId)},e[18]=S,e[19]=o,e[20]=t,e[21]=C):C=e[21];let w=C,T;e[22]!==S||e[23]!==o||e[24]!==t?(T=async e=>{t&&S((await W(t,e,{ownerAgentId:o})).runId)},e[22]=S,e[23]=o,e[24]=t,e[25]=T):T=e[25];let E=T;if(!l.loading&&!l.view){let t=l.error instanceof Error?l.error.message:r===`zh`?`没有找到这次运行`:`Workflow run not found`,n;return e[26]===t?n=e[27]:(n=(0,$.jsx)(Zi,{message:t}),e[26]=t,e[27]=n),n}let D;e[28]!==l||e[29]!==o||e[30]!==t?(D=()=>t&&void Me(t,{ownerAgentId:o}).then(()=>l.mutate()),e[28]=l,e[29]=o,e[30]=t,e[31]=D):D=e[31];let O;e[32]===w?O=e[33]:(O=()=>void w(),e[32]=w,e[33]=O);let A;e[34]===E?A=e[35]:(A=e=>void E(e),e[34]=E,e[35]=A);let j;e[36]!==l.view||e[37]!==n||e[38]!==o?(j=l.view?()=>n(`/workflows/${l.view.run.definitionId}/edit?repairRun=${encodeURIComponent(l.view.run.id)}${o?`&agentId=${encodeURIComponent(o)}`:``}`):void 0,e[36]=l.view,e[37]=n,e[38]=o,e[39]=j):j=e[39];let N;return e[40]!==u||e[41]!==g.data||e[42]!==r||e[43]!==l.loading||e[44]!==l.view||e[45]!==i||e[46]!==S||e[47]!==o||e[48]!==D||e[49]!==O||e[50]!==A||e[51]!==j?(N=(0,$.jsx)(si,{view:l.view,comparison:g.data,loading:l.loading,language:r,localeTag:i,activeTab:u,onTabChange:d,onCancel:D,onRetry:O,onReplay:A,onOpenRunId:S,ownerAgentId:o,onRepairWorkflow:j}),e[40]=u,e[41]=g.data,e[42]=r,e[43]=l.loading,e[44]=l.view,e[45]=i,e[46]=S,e[47]=o,e[48]=D,e[49]=O,e[50]=A,e[51]=j,e[52]=N):N=e[52],N}function Ji(e){return e.language}function Yi(e,t){let n=new Set(t.map(e=>e.name)),r=`${e}_copy`;if(!n.has(r))return r;for(let e=2;e<100;e+=1){let t=`${r}_${e}`;if(!n.has(t))return t}return`${r}_${Date.now()}`}function Xi(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel p-5`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,children:[(0,$.jsx)(F,{className:`h-5 w-36`}),(0,$.jsx)(F,{className:`mt-5 h-9 w-80 max-w-full`}),(0,$.jsx)(F,{className:`mt-4 h-[28rem] rounded-xl`})]})}),e[0]=t):t=e[0],t}function Zi(e){let t=(0,Q.c)(5),{message:n}=e,r;t[0]===n?r=t[1]:(r=(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(N,{asChild:!0,variant:`secondary`,className:`mt-4`,children:(0,$.jsxs)(l,{to:`/workflows`,children:[(0,$.jsx)(V,{className:`size-4`}),`Back`]})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,$.jsx)(`main`,{className:`flex min-h-0 flex-1 items-center justify-center bg-surface-panel p-6 text-center`,children:(0,$.jsxs)(`div`,{children:[r,i]})}),t[3]=r,t[4]=a),a}export{Gi as WorkflowDetailPage,Ki as WorkflowEditorPage,qi as WorkflowRunPage,Gn as WorkflowsPage};
|