@xopcai/xopc 0.0.90 → 0.0.91
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/README.md +36 -12
- package/README.zh-CN.md +36 -12
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +41 -0
- package/dist/gateway/static/root/assets/agents-bVWUlrlD.js +222 -0
- package/dist/gateway/static/root/assets/apps-page-CIC8bmvZ.js +1 -0
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-CpyoFbs4.js → attachment-preview-renderer-DBAxQXb-.js} +2 -2
- package/dist/gateway/static/root/assets/{attachment-process-heavy-CqVriadb.js → attachment-process-heavy-Csq3TrrP.js} +4 -4
- package/dist/gateway/static/root/assets/channels-settings-C8G8RAAP.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-BrtH2VzC.js → channels-status-swr-CYWL5DLD.js} +1 -1
- package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +1 -0
- package/dist/gateway/static/root/assets/{cron-api-CyqbgfHM.js → cron-api-TVqLlGAC.js} +1 -1
- package/dist/gateway/static/root/assets/cron-page-BtcFYlvv.js +1 -0
- package/dist/gateway/static/root/assets/dist-CUV1uY5f.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-D6Ak0STa.js → extension-debug-page-mTLHRDp1.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Q0P3d6DW.js → extension-page-iI8BI7WK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CL55LwU_.js → extension-settings-page-ByXcdubM.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Dqa9iTWl.js → fetch-BWtQq_Ys.js} +1 -1
- package/dist/gateway/static/root/assets/{field-primitives-HUR6JElP.js → field-primitives-BsZ-4VT5.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-DusckjUX.js → heartbeat-config-api-WjTsRLCU.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BYcGfwcE.js → index-CKkR-v9U.js} +85 -81
- package/dist/gateway/static/root/assets/index-VlELBY99.css +1 -0
- package/dist/gateway/static/root/assets/logs-page-ClnIpxfd.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-page-B91pLkEI.css +1 -0
- package/dist/gateway/static/root/assets/note-detail-page-DJ2Mb4x7.js +179 -0
- package/dist/gateway/static/root/assets/note-time-JLBPSLzK.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-BE-75qz9.js +1 -0
- package/dist/gateway/static/root/assets/{pdf-BnEvgIXZ.js → pdf-epILhEOn.js} +1 -1
- package/dist/gateway/static/root/assets/preload-helper-zJ_50EbN.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-bJJkWtTl.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-a0qGVOlr.js → settings-form-section-DSYCknxM.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-WcMXLq2U.js +3 -0
- package/dist/gateway/static/root/assets/share-preview-page-awRqs4hV.js +2 -0
- package/dist/gateway/static/root/assets/skills-page-Lu-i1JG7.js +2 -0
- package/dist/gateway/static/root/assets/{theme-store-C0Ehmdo5.js → theme-store-BC-42BoZ.js} +1 -1
- package/dist/gateway/static/root/assets/toast-z0toXu32.js +1 -0
- package/dist/gateway/static/root/assets/url-CY1RQKTU.js +3 -0
- package/dist/gateway/static/root/assets/{utils-DRQryzdn.js → utils-DX3TQuap.js} +1 -1
- package/dist/gateway/static/root/assets/vendor-codemirror-DYoKfS8f.js +45 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-D0viACE2.js → voice-api-key-field-B5uKlDqA.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-DnG8JBhV.js → workflow-page.utils-ClC37yEp.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-C7VhIXtR.js +27 -0
- package/dist/gateway/static/root/index.html +10 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +7 -7
- package/dist/src/agent/agent-scope.js +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/goals/goal-run-store.js +4 -4
- package/dist/src/agent/goals/persistent-goal-service.js +1 -1
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +2 -2
- package/dist/src/agent/service/build-direct-message-content.js +1 -1
- package/dist/src/agent/service.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +3 -3
- package/dist/src/browser/providers/cloakbrowser.js +4 -4
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/attachments/inbound-persist.js +1 -1
- package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +2 -2
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.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-pack.js +1 -1
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +4 -4
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/commands/agents.config.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.js +1 -1
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/cron/run-log-store.js +1 -1
- package/dist/src/daemon/constants.js +1 -1
- package/dist/src/daemon/install-plan.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/schtasks.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +3 -3
- package/dist/src/gateway/file-path-classifier.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
- package/dist/src/gateway/hono/lib/config-payload.js +2 -1
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/middleware/auth.js +1 -2
- package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +12 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +2 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/notes.js +274 -0
- package/dist/src/gateway/hono/routes/notes.js.map +1 -0
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +4 -4
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +11 -1
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/gateway/workspace-ripgrep.d.ts +6 -0
- package/dist/src/gateway/workspace-ripgrep.js +62 -11
- package/dist/src/gateway/workspace-ripgrep.js.map +1 -1
- package/dist/src/infra/brew.js +1 -1
- package/dist/src/infra/package-json.js +1 -1
- package/dist/src/infra/package-update-steps.js +1 -1
- package/dist/src/infra/path-env.js +2 -2
- package/dist/src/infra/restart.js +2 -2
- package/dist/src/infra/stable-node-path.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-global.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/notes/attachment-ref.d.ts +9 -0
- package/dist/src/notes/attachment-ref.js +27 -0
- package/dist/src/notes/attachment-ref.js.map +1 -0
- package/dist/src/notes/index.d.ts +4 -0
- package/dist/src/notes/index.js +4 -0
- package/dist/src/notes/note-attachment-sync.d.ts +7 -0
- package/dist/src/notes/note-attachment-sync.js +46 -0
- package/dist/src/notes/note-attachment-sync.js.map +1 -0
- package/dist/src/notes/note-index-meta.d.ts +14 -0
- package/dist/src/notes/note-index-meta.js +87 -0
- package/dist/src/notes/note-index-meta.js.map +1 -0
- package/dist/src/notes/paths.d.ts +5 -0
- package/dist/src/notes/paths.js +23 -0
- package/dist/src/notes/paths.js.map +1 -0
- package/dist/src/notes/service.d.ts +42 -0
- package/dist/src/notes/service.js +331 -0
- package/dist/src/notes/service.js.map +1 -0
- package/dist/src/notes/store.d.ts +33 -0
- package/dist/src/notes/store.js +317 -0
- package/dist/src/notes/store.js.map +1 -0
- package/dist/src/notes/types.d.ts +162 -0
- package/dist/src/notes/types.js +1 -0
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/config-store.js +2 -2
- package/dist/src/session/init-session-turn.js +2 -2
- package/dist/src/session/parity/jsonl-transcript-io.js +2 -2
- package/dist/src/session/parity/sessions-json-file.js +1 -1
- package/dist/src/session/parity/transcript-file-lock.js +2 -2
- package/dist/src/session/parity/transcript-paths.js +1 -1
- package/dist/src/session/resolve-session.js +4 -4
- package/dist/src/session/search-index-cache.js +1 -1
- package/dist/src/session/search-index.js +1 -1
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store.js +6 -6
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/share/share-thumbnail.js +2 -2
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-share-store.js +3 -3
- package/dist/src/share/site-static-serve.js +1 -1
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +2 -2
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui.js +3 -3
- package/dist/src/tunnel/frpc-binary.js +3 -3
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +2 -2
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-store.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-cPvvYLXo.js +0 -222
- package/dist/gateway/static/root/assets/apps-page-Bk1_P5FJ.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CZoeQwHz.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-BpLdiQN8.js +0 -1
- package/dist/gateway/static/root/assets/dist-BTWC-BTN.js +0 -45
- package/dist/gateway/static/root/assets/dist-BpAiK86n.js +0 -1
- package/dist/gateway/static/root/assets/eye-DAfL1U7M.js +0 -1
- package/dist/gateway/static/root/assets/index-V7MQ7834.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-_HcZ2fgK.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-iezSMjho.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-C9_nYQwM.js +0 -3
- package/dist/gateway/static/root/assets/share-preview-page-DExl7CJy.js +0 -2
- package/dist/gateway/static/root/assets/skills-page-BlgGD93t.js +0 -2
- package/dist/gateway/static/root/assets/url-fxyYANfA.js +0 -3
- package/dist/gateway/static/root/assets/vendor-codemirror-D0yxdRpg.js +0 -58
- package/dist/gateway/static/root/assets/workflows-page-BvMobnJP.js +0 -27
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-fxyYANfA.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,i as u,n as d,o as f,r as p,s as m}from"./dist-BTWC-BTN.js";import{a as h,n as g,t as _}from"./fetch-Dqa9iTWl.js";import{$n as v,Aa as y,Ai as b,Bi as x,Ci as S,Fr as C,Ha as w,Ir as T,Jr as E,La as D,N as O,Qn as k,Rr as A,Xn as j,Yn as M,Zn as N,at as P,fn as F,pi as I,qa as L,sa as R,ui as z,ur as B,wa as V}from"./index-BYcGfwcE.js";var H=e(t(),1),U=n();function W(e){return e===`builtin`||e===`user`?e:`marketplace`}async function G(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ee(e){let t=await _(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await _(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await _(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function J(e){let t=await _(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Y=r();function X(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function te({className:e}){let t=a(i(e=>e.language)).appsPage,n=h(e=>!!e.token),r=j(),{mutate:l}=s(),[u,d]=(0,H.useReducer)(O,Z),{q:f,debounced:p,detailPkg:m,rowBusy:_,actionError:v,restartHint:y}=u,S=n?`marketplace-${p}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>d({type:`patch`,patch:{debounced:f.trim()}}),300);return()=>window.clearTimeout(e)},[f]);let{data:C,isLoading:w,error:D}=c(S,async()=>g(p.length>0?o(`/api/marketplace?q=${encodeURIComponent(p)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),k=(0,H.useCallback)(()=>{l(`gateway-extensions-list`),P()},[l]),A=(0,H.useCallback)(async(e,n)=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});k(),r.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,k]),M=(0,H.useCallback)(async e=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);k(),n.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,k]),N=C?.extensions??[];return(0,Y.jsxs)(`div`,{className:T(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:f,onChange:e=>d({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),D?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,v?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,y?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y}):null,w&&!C?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.map(e=>{let n=X(r,e.id),i=_===e.id;return(0,Y.jsx)(`li`,{className:`list-none`,children:(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>d({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d({type:`patch`,patch:{detailPkg:e.id}}))},className:T(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Y.jsx)(V,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Y.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,Y.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Y.jsx)(b,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Y.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&M(e.id).catch(()=>{})},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(E,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:T(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),m?(0,Y.jsx)(ne,{packageName:m,copy:t,extensions:r,onClose:()=>d({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:M}):null]})}function ne(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[p,g]=(0,H.useState)(!1),_=h(oe)?`ext-mp-detail-${n}`:null,v;t[0]===n?v=t[1]:(v=async()=>ee(n),t[0]=n,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},t[2]=y):y=t[2];let{data:b,error:S,isLoading:C}=c(_,v,y),O;t[3]!==i||t[4]!==n?(O=X(i,n),t[3]=i,t[4]=n,t[5]=O):O=t[5];let k=O,j=k===`user`,M;t[6]!==r.marketplaceNoReadme||t[7]!==b?(M=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=M):M=t[8];let N=M,P;t[9]===a?P=t[10]:(P=e=>!e&&a(),t[9]=a,t[10]=P);let I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=I):I=t[11];let L;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Y.jsx)(D,{className:`size-5`}),t[12]=L):L=t[12];let R;t[13]!==r.detailBack||t[14]!==a?(R=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:L}),t[13]=r.detailBack,t[14]=a,t[15]=R):R=t[15];let z;t[16]===r.marketplaceDetailTitle?z=t[17]:(z=(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=z);let B;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Y.jsx)(A,{className:`size-5`}),t[18]=B):B=t[18];let V;t[19]!==r.detailClose||t[20]!==a?(V=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:B}),t[19]=r.detailClose,t[20]=a,t[21]=V):V=t[21];let W;t[22]!==V||t[23]!==R||t[24]!==z?(W=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[R,z,V]}),t[22]=V,t[23]=R,t[24]=z,t[25]=W):W=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==S||t[33]!==C||t[34]!==N?(G=C&&!b?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):S?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,Y.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Y.jsx)(`dd`,{children:b.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,Y.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Y.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Y.jsx)(F,{content:N})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=S,t[33]=C,t[34]=N,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==p||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==k||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==j?(q=b?(0,Y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:k===`bundled`?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Y.jsx)(w,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{j&&!window.confirm(r.marketplaceReinstallConfirm)||(g(!0),o(n,j).catch(ie).finally(()=>g(!1)))},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[p?(0,Y.jsx)(x,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,j?r.marketplaceReinstall:r.marketplaceInstall]}),j?(0,Y.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(g(!0),s(n).then(()=>a()).catch(re).finally(()=>g(!1)))},className:T(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(E,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=p,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=k,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=j,t[53]=q):q=t[53];let J;t[54]!==W||t[55]!==K||t[56]!==q?(J=(0,Y.jsxs)(l,{children:[I,(0,Y.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:ae,children:[W,K,q]})]}),t[54]=W,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Z;return t[58]!==J||t[59]!==P?(Z=(0,Y.jsx)(f,{defaultOpen:!0,onOpenChange:P,children:J}),t[58]=J,t[59]=P,t[60]=Z):Z=t[60],Z}function re(){}function ie(){}function ae(e){return e.preventDefault()}function oe(e){return!!e.token}function se(){let e=i(e=>e.language),t=a(e),n=B(e=>e.setPageHeader),r=B(e=>e.clearPageHeader),o=j(),s=N(),[c,l]=L(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,h]=(0,H.useState)(d),[g,_]=(0,H.useState)(null),v=c.toString(),y=(0,H.useRef)(v);if(y.current!==v){y.current=v;let e=W(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,H.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,H.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,H.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),S=f===`builtin`?b:x,C=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=S;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[S,m,e]);if((0,H.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[o]),(0,H.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Y.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,Y.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(pe,{});let w=f!==`marketplace`&&S.length>0;return(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,Y.jsxs)(`header`,{className:`mb-6`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(0,Y.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:T(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:T(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:T(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),w?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,Y.jsx)(te,{}):f===`builtin`&&b.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyUser}):C.length===0?(0,Y.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:C.map(e=>(0,Y.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,Y.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Q(e){return e.activationEligible??e.active}function ce(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Q(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=T(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,Y.jsx)(y,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Y.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,Y.jsx)(S,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r.cardNoDescription||t[21]!==n.description?(v=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=v):v=t[22];let b;t[23]===v?b=t[24]:(b=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:v}),t[23]=v,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==x||t[26]!==c?(C=(0,Y.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,Y.jsx)(`span`,{title:ce(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=w):w=t[31];let E;t[32]!==C||t[33]!==w?(E=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=E):E=t[34];let D;t[35]!==_||t[36]!==b||t[37]!==E?(D=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,b,E]}),t[35]=_,t[36]=b,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==f?(O=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[f,D]}),t[39]=D,t[40]=f,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:l,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1),_=e.activationEligible===!0,y=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),g(!1),a(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!_});await r(`gateway-extensions-list`),P(),g(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[_,t.builtinToggleFailed,e.id,e.source,r]),b=e.ui?.contributions?.pages??[],S=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],j=b.find(e=>e.showInNav)??b[0],N=S[0],F=j?M(e.id,j):null,I=N?`/settings/ext/${e.id}/${N.id}`:e.hasConfigSchema||k(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,Y.jsx)(D,{className:`size-5`})}),(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Y.jsxs)(p,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,Y.jsx)(A,{className:`size-5`})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Y.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,ce(e,t)]}),e.version?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Y.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,Y.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Y.jsx)(C,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void y(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):_?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,h?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(b.length>0||S.length>0||E.length>0)?(0,Y.jsxs)(`section`,{className:`mt-8`,children:[(0,Y.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Y.jsx)($,{template:t.badgePages,count:b.length,hidden:b.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:S.length,hidden:S.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:E.length,hidden:E.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,v(e)&&(F||I)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[F?(0,Y.jsxs)(w,{to:F,onClick:n,className:T(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(R,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,I?(0,Y.jsxs)(w,{to:I,onClick:n,className:T(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(z,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Y.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,U.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,U.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Y.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Y.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,Y.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,U.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Y.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{se as AppsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-fxyYANfA.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{n as c,t as l}from"./eye-DAfL1U7M.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BTWC-BTN.js";import{a as _,n as v}from"./fetch-Dqa9iTWl.js";import{Aa as y,B as b,Bn as x,Cr as S,Dr as C,Er as w,Fr as T,Ft as E,Ga as D,Ir as O,It as k,Jn as A,Ka as j,Lt as M,Rr as N,Rt as P,Sr as F,Un as I,bi as L,br as ee,er as R,hr as te,jr as z,ka as ne,oa as re,qa as B,sa as V,st as H,ur as U,z as W}from"./index-BYcGfwcE.js";import{a as G,c as ie,i as K,o as ae,r as q,s as oe,t as J}from"./utils-DRQryzdn.js";import{n as Y,r as se,t as ce}from"./field-primitives-HUR6JElP.js";import{_ as le,a as ue,c as de,d as fe,f as pe,g as me,h as he,i as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as X,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./channels-status-swr-BrtH2VzC.js";var Z=e(t(),1),Q=n(),$=r();function De(e){switch(e){case`running`:return`bg-success-soft text-success`;case`offline`:return`bg-amber-100 text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`;case`disabled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Oe(e,t){switch(t){case`running`:return e.hubStatusRunning;case`offline`:return e.hubStatusOffline;case`disabled`:return e.hubStatusDisabled;default:return e.hubStatusNotConfigured}}function ke(e,t){switch(t){case`setup`:return e.hubSetupButton;case`fix`:return e.hubFixButton;case`pairing`:return e.hubPairingButton;default:return e.hubManageButton}}function Ae(e){let t=(0,Q.c)(62),{channelId:n,title:r,subtitle:i,vm:a,toggleDisabled:o,onOpen:s,onReviewPairing:c,onToggle:l,ch:u}=e,d=a.configured&&a.manageable,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=O(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),t[0]=f):f=t[0];let p=a.status===`running`?`bg-accent-soft`:`bg-surface-base`,m;t[1]===p?m=t[2]:(m=O(`flex size-11 shrink-0 items-center justify-center rounded-xl ring-1 ring-edge-subtle/40`,p),t[1]=p,t[2]=m);let h;t[3]===n?h=t[4]:(h=(0,$.jsx)(A,{sourceChannel:n,className:`size-5`}),t[3]=n,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,$.jsx)(`div`,{className:m,"aria-hidden":!0,children:h}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===r?_=t[9]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[8]=r,t[9]=_);let v;t[10]===a.status?v=t[11]:(v=O(`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium`,De(a.status)),t[10]=a.status,t[11]=v);let y;t[12]!==u||t[13]!==a.status?(y=Oe(u,a.status),t[12]=u,t[13]=a.status,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==u||t[19]!==c||t[20]!==a.pendingPairing?(x=a.pendingPairing>0?(0,$.jsx)(`button`,{type:`button`,className:O(`inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,C.press),onClick:e=>{e.stopPropagation(),c()},children:u.hubPairingPendingBadge.replace(`{{count}}`,String(a.pendingPairing))}):null,t[18]=u,t[19]=c,t[20]=a.pendingPairing,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let w;t[25]!==S||t[26]!==_?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,S]}),t[25]=S,t[26]=_,t[27]=w):w=t[27];let E;t[28]!==u||t[29]!==l||t[30]!==d||t[31]!==r||t[32]!==o||t[33]!==a.enabled?(E=d?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`${r} — ${u.enableChannelAria}`,disabled:o,className:O(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,C.press,a.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:e=>{e.stopPropagation(),l(!a.enabled)},children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,t[28]=u,t[29]=l,t[30]=d,t[31]=r,t[32]=o,t[33]=a.enabled,t[34]=E):E=t[34];let D;t[35]!==w||t[36]!==E||t[37]!==g?(D=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,w,E]}),t[35]=w,t[36]=E,t[37]=g,t[38]=D):D=t[38];let k;t[39]===i?k=t[40]:(k=(0,$.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:i}),t[39]=i,t[40]=k);let j;t[41]===a.summaryLines?j=t[42]:(j=a.summaryLines.length>0?(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5`,children:a.summaryLines.map(je)}):null,t[41]=a.summaryLines,t[42]=j);let M;t[43]!==k||t[44]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,j]}),t[43]=k,t[44]=j,t[45]=M):M=t[45];let N;t[46]!==s||t[47]!==c||t[48]!==a.manageable||t[49]!==a.pendingPairing||t[50]!==a.primaryAction?(N=()=>{if(a.manageable&&(a.primaryAction===`pairing`||a.pendingPairing>0)){c();return}s()},t[46]=s,t[47]=c,t[48]=a.manageable,t[49]=a.pendingPairing,t[50]=a.primaryAction,t[51]=N):N=t[51];let P;t[52]!==u||t[53]!==a.primaryAction?(P=ke(u,a.primaryAction),t[52]=u,t[53]=a.primaryAction,t[54]=P):P=t[54];let F;t[55]!==N||t[56]!==P?(F=(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(T,{type:`button`,variant:`primary`,className:`w-full`,onClick:N,children:P})}),t[55]=N,t[56]=P,t[57]=F):F=t[57];let I;return t[58]!==D||t[59]!==M||t[60]!==F?(I=(0,$.jsxs)(`article`,{className:f,children:[D,M,F]}),t[58]=D,t[59]=M,t[60]=F,t[61]=I):I=t[61],I}function je(e){return(0,$.jsx)(`li`,{className:`text-xs text-fg-muted`,children:e},e)}function Me(e){let t=(0,Q.c)(17),{catalog:n,cards:r,ch:i,saving:a,onOpenChannel:o,onToggleChannel:s}=e,c;t[0]===r?c=t[1]:(c=new Map(r.map(Ne)),t[0]=r,t[1]=c);let l=c,u;if(t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==o||t[6]!==s||t[7]!==a){let e;t[9]!==l||t[10]!==i||t[11]!==o||t[12]!==s||t[13]!==a?(e=e=>{let t=l.get(e.id);return t?(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Ae,{channelId:e.id,title:e.title,subtitle:e.subtitle,vm:t,toggleDisabled:a||!t.manageable,onOpen:()=>o(e.id),onReviewPairing:()=>o(e.id,{scrollToPairing:!0}),onToggle:t=>s(e.id,t),ch:i})},e.id):null},t[9]=l,t[10]=i,t[11]=o,t[12]=s,t[13]=a,t[14]=e):e=t[14],u=n.map(e),t[2]=l,t[3]=n,t[4]=i,t[5]=o,t[6]=s,t[7]=a,t[8]=u}else u=t[8];let d;return t[15]===u?d=t[16]:(d=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,role:`list`,children:u}),t[15]=u,t[16]=d),d}function Ne(e){return[e.id,e]}var Pe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Fe(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:O(`size-11 shrink-0 rounded-xl`,Pe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:O(`h-4 w-2/5`,Pe)}),(0,$.jsx)(`div`,{className:O(`h-5 w-16 rounded-full`,Pe)})]}),(0,$.jsx)(`div`,{className:O(`h-6 w-10 shrink-0 rounded-full`,Pe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:O(`h-3 w-full`,Pe)}),(0,$.jsx)(`div`,{className:O(`h-3 w-[88%]`,Pe)})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-[13.5rem] flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm dark:border-edge-subtle`,"aria-hidden":!0,children:[n,r,(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(`div`,{className:O(`h-10 w-full rounded-lg`,Pe)})})]}),e[3]=i):i=e[3],i}function Ie(e){let t=(0,Q.c)(2),{count:n}=e,r=n===void 0?3:n,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,"aria-busy":!0,children:Array.from({length:r},Le)}),t[0]=r,t[1]=i),i}function Le(e,t){return(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Fe,{})},t)}function Re(e,t=!1){return e===`drawer`?O(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,W):O(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,W,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ze(e){let t=(0,Q.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:_,footer:v,wide:y,headerExtra:x}=e,S=y===void 0?!1:y,C=n===`drawer`,E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(d,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==S?(D=Re(n,S),t[1]=n,t[2]=S,t[3]=D):D=t[3];let k;t[4]===s?k=t[5]:(k=s?(0,$.jsx)(h,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=k);let A;t[6]===c?A=t[7]:(A=c?(0,$.jsx)(m,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=A);let j;t[8]!==l||t[9]!==o||t[10]!==x||t[11]!==C||t[12]!==a?(j=C?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,$.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,$.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(w,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,$.jsx)(N,{className:`size-4`})})}),x]}),t[8]=l,t[9]=o,t[10]=x,t[11]=C,t[12]=a,t[13]=j):j=t[13];let M=C?`px-4 py-4`:`p-6`,P;t[14]===M?P=t[15]:(P=O(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=P);let F;t[16]!==_||t[17]!==P?(F=(0,$.jsx)(`div`,{className:P,children:_}),t[16]=_,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==v||t[20]!==D||t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==F?(I=(0,$.jsxs)(u,{children:[E,(0,$.jsxs)(f,{className:D,onOpenAutoFocus:Be,children:[k,A,j,F,v]})]}),t[19]=v,t[20]=D,t[21]=k,t[22]=A,t[23]=j,t[24]=F,t[25]=I):I=t[25];let L;return t[26]!==i||t[27]!==r||t[28]!==I?(L=(0,$.jsx)(p,{open:r,onOpenChange:i,children:I}),t[26]=i,t[27]=r,t[28]=I,t[29]=L):L=t[29],L}function Be(e){return e.preventDefault()}function Ve(e){let t=(0,Q.c)(52),{open:n,onOpenChange:r,entry:i,vm:a,ch:o,language:s}=e,c=a.status===`running`?o.hubStatusRunning:a.status===`offline`?o.hubStatusOffline:a.status===`disabled`?o.hubStatusDisabled:o.hubStatusNotConfigured,l=i.title,u=i.subtitle,d=o.modalCancel,f;t[0]===i.title?f=t[1]:(f=(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.title}),t[0]=i.title,t[1]=f);let p;t[2]===i.subtitle?p=t[3]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),t[2]=i.subtitle,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===o.hubExtensionManageHint?h=t[8]:(h=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hubExtensionManageHint}),t[7]=o.hubExtensionManageHint,t[8]=h);let g;t[9]===o.hubExtensionStatusLabel?g=t[10]:(g=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionStatusLabel}),t[9]=o.hubExtensionStatusLabel,t[10]=g);let _;t[11]===c?_=t[12]:(_=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:c}),t[11]=c,t[12]=_);let v;t[13]!==g||t[14]!==_?(v=(0,$.jsxs)(`div`,{children:[g,_]}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===o.hubExtensionEnabledLabel?y=t[17]:(y=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionEnabledLabel}),t[16]=o.hubExtensionEnabledLabel,t[17]=y);let b=a.enabled?o.hubExtensionYes:o.hubExtensionNo,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(`div`,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]===o.hubExtensionConnectedLabel?C=t[24]:(C=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionConnectedLabel}),t[23]=o.hubExtensionConnectedLabel,t[24]=C);let w=a.connected?o.hubExtensionYes:o.hubExtensionNo,E;t[25]===w?E=t[26]:(E=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:w}),t[25]=w,t[26]=E);let D;t[27]!==C||t[28]!==E?(D=(0,$.jsxs)(`div`,{children:[C,E]}),t[27]=C,t[28]=E,t[29]=D):D=t[29];let O;t[30]!==v||t[31]!==S||t[32]!==D?(O=(0,$.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[v,S,D]}),t[30]=v,t[31]=S,t[32]=D,t[33]=O):O=t[33];let k;t[34]===s?k=t[35]:(k=te(s,`channels`),t[34]=s,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(V,{className:`ml-2 size-3.5`}),t[36]=A):A=t[36];let j;t[37]!==o.hubViewDocs||t[38]!==k?(j=(0,$.jsx)(T,{type:`button`,variant:`secondary`,asChild:!0,children:(0,$.jsxs)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,children:[o.hubViewDocs,A]})}),t[37]=o.hubViewDocs,t[38]=k,t[39]=j):j=t[39];let M;t[40]!==O||t[41]!==j||t[42]!==h?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,O,j]}),t[40]=O,t[41]=j,t[42]=h,t[43]=M):M=t[43];let N;return t[44]!==o.modalCancel||t[45]!==i.subtitle||t[46]!==i.title||t[47]!==r||t[48]!==n||t[49]!==M||t[50]!==m?(N=(0,$.jsx)(ze,{presentation:`modal`,open:n,onOpenChange:r,srTitle:l,srDescription:u,closeAriaLabel:d,headerExtra:m,children:M}),t[44]=o.modalCancel,t[45]=i.subtitle,t[46]=i.title,t[47]=r,t[48]=n,t[49]=M,t[50]=m,t[51]=N):N=t[51],N}var He=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=O(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(L,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function Ue(e){let t=(0,Q.c)(27),{accountIds:n,routes:r,defaultAgentId:o,agentItems:s,disabled:c,onChange:l,ch:u}=e,d=i(We),f,p,m,h,g;if(t[0]!==n||t[1]!==s||t[2]!==u||t[3]!==o||t[4]!==c||t[5]!==d||t[6]!==l||t[7]!==r){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a(d).agentsSettings;if(n.length===0){g=null;break bb0}let i=s.length>0?s:[{id:o}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let _;t[13]===u.agentRoutingTitle?_=t[14]:(_=(0,$.jsx)(Y,{children:u.agentRoutingTitle}),t[13]=u.agentRoutingTitle,t[14]=_);let v;t[15]===u.agentRoutingHint?v=t[16]:(v=(0,$.jsx)(ce,{children:u.agentRoutingHint}),t[15]=u.agentRoutingHint,t[16]=v),t[17]!==_||t[18]!==v?(h=(0,$.jsxs)(`div`,{children:[_,v]}),t[17]=_,t[18]=v,t[19]=h):h=t[19],f=`space-y-2`,p=n.map(t=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.agentRoutingAccountLabel}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:u.agentRoutingAgentLabel}),(0,$.jsx)(`select`,{id:`agent-route-${t}`,className:O(J(),z),disabled:c,value:(r[t]??o).toLowerCase(),onChange:e=>l(t,e.target.value),children:i.map(t=>(0,$.jsx)(`option`,{value:t.id,children:`${H(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=s,t[2]=u,t[3]=o,t[4]=c,t[5]=d,t[6]=l,t[7]=r,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[20]!==f||t[21]!==p?(_=(0,$.jsx)(`div`,{className:f,children:p}),t[20]=f,t[21]=p,t[22]=_):_=t[22];let v;return t[23]!==m||t[24]!==h||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[23]=m,t[24]=h,t[25]=_,t[26]=v):v=t[26],v}function We(e){return e.language}function Ge(e){return e===`telegram`?`pairing`:`open`}function Ke(e,t,n){return n?.dmPolicy?n.dmPolicy:t??Ge(e)}function qe(e,t){if(e===`telegram`){let e=Te(t);return e.length>0?e:[`default`]}if(e===`weixin`){let e=Ee(t);return e.length>0?e:[`default`]}let n=le(t);return n.length>0?n:[`default`]}function Je(e){return e?.enabled!==!1}function Ye(e,t,n){let r=t.accounts?.[n];return Ke(e,t.dmPolicy,r)}function Xe(e,t){return qe(e,t).some(n=>{let r=t.accounts?.[n];return Je(r)?Ye(e,t,n)===`pairing`:!1})}function Ze(e){return!e.configured||!e.channelEnabled||!e.usesPairing?0:e.summaryPending}function Qe(e){let{channel:t,accountId:n,messages:r,mutate:i,setCodeBySender:a,setBusySender:o,setFeedback:s}=e,c=(0,Z.useCallback)(async(e,t)=>{o(e),s(null);try{let n=await t();a(t=>{let n={...t};return delete n[e],n}),s({kind:`ok`,text:r.pairingApproved.replace(`{{id}}`,n.senderId)}),await i()}catch(e){let t=e instanceof Error?e.message:r.pairingInvalid;s({kind:`err`,text:t.includes(`PAIRING`)?r.pairingInvalid:t})}finally{o(null)}},[r.pairingApproved,r.pairingInvalid,i,o,a,s]);return{approveByCode:(0,Z.useCallback)((e,r)=>{let i=r.trim().toUpperCase();i&&c(e,()=>ue({channel:t,accountId:n,code:i}))},[n,t,c]),quickApprove:(0,Z.useCallback)(e=>{c(e,()=>ge({channel:t,accountId:n,senderId:e}))},[n,t,c])}}var $e=[`channels-pairing-requested`,`channels-pairing-refreshed`,`channels-pairing-approved`,`channels-pairing-revoked`,`channels-pairing-dismissed`],et=`channel-pairing-summary`;function tt(e){let t=()=>e();for(let e of $e)window.addEventListener(e,t);return()=>{for(let e of $e)window.removeEventListener(e,t)}}function nt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return tt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}function rt(e){return`channel-pairing-${e}`}function it(e){requestAnimationFrame(()=>{document.getElementById(rt(e))?.scrollIntoView({behavior:`smooth`,block:`start`})})}function at(e,t){let n=Date.parse(e)-Date.now();if(!Number.isFinite(n))return e;let r=Math.max(1,Math.round(Math.abs(n)/6e4));if(n<=0)return t.startsWith(`zh`)?`已过期`:`expired`;if(r<60)return t.startsWith(`zh`)?`${r} 分钟后`:`in ${r} min`;let i=Math.round(r/60);return t.startsWith(`zh`)?`${i} 小时后`:`in ${i} h`}function ot(e,t){return`channel-pairing-${e}-${t}`}var st={codeBySender:{},busySender:null,dismissingId:null,revokingId:null,feedback:null};function ct(e,t){switch(t.type){case`setCodeBySender`:return{...e,codeBySender:t.updater(e.codeBySender)};case`setBusySender`:return{...e,busySender:t.value};case`setDismissingId`:return{...e,dismissingId:t.value};case`setRevokingId`:return{...e,revokingId:t.value};case`setFeedback`:return{...e,feedback:t.value};case`clearSenderCode`:{let n={...e.codeBySender};return delete n[t.senderId],{...e,codeBySender:n}}}}function lt({channel:e,accountIds:t,channelConfig:n,active:r,ch:i,language:a,onPairedChange:o}){let c=J,l=(0,Z.useMemo)(()=>{let e=(t??[`default`]).filter(Boolean);return e.length>0?e:[`default`]},[t]),u=(0,Z.useMemo)(()=>Xe(e,n),[e,n]),d=(0,Z.useCallback)(t=>Ye(e,n,t),[e,n]),[f,p]=(0,Z.useState)(l[0]??`default`),[m,h]=(0,Z.useState)(l);l!==m&&(h(l),l.includes(f)||p(l[0]??`default`));let[g,_]=(0,Z.useReducer)(ct,st),{codeBySender:v,busySender:y,dismissingId:b,revokingId:x,feedback:S}=g,C=d(f)===`pairing`,w=(0,Z.useRef)(o);w.current=o;let{data:E,error:D,isLoading:k,mutate:A}=s(r&&u&&C?ot(e,f):null,()=>de(e,f),{revalidateOnFocus:!0,onSuccess:e=>{w.current?.(e.paired.fromCredentials.length)}});nt((0,Z.useCallback)(()=>{A()},[A]),r&&u&&C);let j=E?.paired.fromCredentials??[],M=(0,Z.useCallback)(e=>{_({type:`setCodeBySender`,updater:typeof e==`function`?e:()=>e})},[]),P=(0,Z.useCallback)(e=>{_({type:`setBusySender`,value:typeof e==`function`?e(g.busySender):e})},[g.busySender]),F=(0,Z.useCallback)(e=>{_({type:`setFeedback`,value:typeof e==`function`?e(g.feedback):e})},[g.feedback]),{approveByCode:I,quickApprove:ee}=Qe({channel:e,accountId:f,messages:{pairingApproved:i.pairingApproved,pairingInvalid:i.pairingInvalid},mutate:A,setCodeBySender:M,setBusySender:P,setFeedback:F}),R=(0,Z.useCallback)(async t=>{_({type:`setDismissingId`,value:t}),_({type:`setFeedback`,value:null});try{await be({channel:e,accountId:f,senderId:t}),_({type:`clearSenderCode`,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingDismissed.replace(`{{id}}`,t)}}),await A()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingDismissError}})}finally{_({type:`setDismissingId`,value:null})}},[f,e,i.pairingDismissed,i.pairingDismissError,A]),te=(0,Z.useCallback)(async t=>{_({type:`setRevokingId`,value:t}),_({type:`setFeedback`,value:null});try{await me({channel:e,accountId:f,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingRevoked.replace(`{{id}}`,t)}}),await A()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingRevokeError}})}finally{_({type:`setRevokingId`,value:null})}},[f,e,i.pairingRevoked,i.pairingRevokeError,A]);if(!u)return null;if(!C)return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-2 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingAccountNotPairing.replace(`{{account}}`,f)}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]});let z=E?.pending??[],ne=E?.paired.fromConfig??[];return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-3 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.pairingSubtitle})]}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.pairingRefresh,disabled:k,onClick:()=>void A(),children:(0,$.jsx)(L,{className:O(`size-4 text-fg-muted`,k&&`animate-spin`)})})]}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,$.jsx)(ce,{children:i.pairingSetupHint}),D?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:i.pairingLoadError}):null,S?(0,$.jsx)(`p`,{className:O(`text-xs`,S.kind===`ok`?`text-success`:`text-red-600 dark:text-red-400`),children:S.text}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{children:i.pairingPendingTitle}),z.length>0?(0,$.jsx)(ce,{children:i.pairingQuickApproveHint}):null,z.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingPendingEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:z.map(e=>{let t=v[e.senderId]??``,n=y===e.senderId,r=b===e.senderId;return(0,$.jsxs)(`li`,{className:O(`rounded-lg border bg-surface-panel p-3 dark:border-edge`,e.isStale?`border-amber-300/50 dark:border-amber-800/50`:`border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.senderId}),(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e.isStale?(0,$.jsx)(`span`,{className:`text-amber-800 dark:text-amber-200`,children:i.pairingStaleItem}):null,e.isStale?` · `:null,i.pairingExpiresHint.replace(`{{time}}`,at(e.expiresAt,a))]})]}),e.codeLast4?(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:i.pairingCodeHint.replace(`{{suffix}}`,e.codeLast4)}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`shrink-0 text-xs`,disabled:n||r,onClick:()=>void ee(e.senderId),children:n?i.pairingApproving:i.pairingQuickApprove}),(0,$.jsx)(`input`,{className:O(c(),`min-w-0 flex-1 font-mono text-xs uppercase`),value:t,autoComplete:`off`,spellCheck:!1,maxLength:8,placeholder:i.pairingCodePlaceholder,onChange:t=>M(n=>({...n,[e.senderId]:t.target.value.toUpperCase()})),onKeyDown:n=>{n.key===`Enter`&&I(e.senderId,t)}}),(0,$.jsx)(T,{type:`button`,variant:`primary`,className:`shrink-0 text-xs`,disabled:n||r||!t.trim(),onClick:()=>I(e.senderId,t),children:n?i.pairingApproving:i.pairingApprove}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`shrink-0 text-xs text-fg-muted hover:text-danger`,disabled:n||r,onClick:()=>void R(e.senderId),children:r?i.pairingDismissing:i.pairingDismiss})]})]},e.senderId)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3 dark:border-edge-subtle`,children:[(0,$.jsx)(Y,{children:i.pairedTitle}),(0,$.jsxs)(`div`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromConfig}),(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:ne.length?ne.join(`, `):i.pairedEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromCredentials}),j.length===0?(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:i.pairedEmpty}):(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:j.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-fg`,children:e}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-7 shrink-0 p-0 text-fg-muted hover:text-danger`,"aria-label":i.pairingRevokeAria.replace(`{{id}}`,e),disabled:x===e,onClick:()=>void te(e),children:(0,$.jsx)(N,{className:`size-3.5`})})]},e))})]})]})]})]})}function ut(e){let t=(0,Q.c)(347),{ch:n,form:r,baseline:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuWebhookCopied:s,copyFeishuWebhookConfig:u,updateFeishu:d,updateChannelAgentRoute:f,feishuAccountsDraft:p,setFeishuAccountsDraft:m,feishuAccountsError:h,onFeishuAccountsBlur:g,dmOpts:_,groupOpts:v,chatAgents:b,saving:x,language:S,dialogOpen:C,pairingFocus:w}=e,E=w===void 0?!1:w,D=r.feishu,k;t[0]===D?k=t[1]:(k=le(D),t[0]=D,t[1]=k);let A=k,j;t[2]===A?j=t[3]:(j=A.length>0?A:[`default`],t[2]=A,t[3]=j);let M=j,N=i?.feishu?.appSecret??``,P;t[4]!==n.copied||t[5]!==n.copy||t[6]!==n.hide||t[7]!==n.show?(P=ee({show:n.show,hide:n.hide,copy:n.copy,copied:n.copied}),t[4]=n.copied,t[5]=n.copy,t[6]=n.hide,t[7]=n.show,t[8]=P):P=t[8];let I=P,L=(0,Z.useRef)(null),R,te;t[9]===E?(R=t[10],te=t[11]):(R=()=>{if(!E)return;let e=L.current;e&&(e.open=!0);let t=window.setTimeout(pt,80);return()=>window.clearTimeout(t)},te=[E],t[9]=E,t[10]=R,t[11]=te),(0,Z.useEffect)(R,te);let z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[12]=z):z=t[12];let B;t[13]===n.advancedShow?B=t[14]:(B=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[z,n.advancedShow]})}),t[13]=n.advancedShow,t[14]=B);let V;t[15]===n.feishuAdvancedHint?V=t[16]:(V=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[15]=n.feishuAdvancedHint,t[16]=V);let H;t[17]===d?H=t[18]:(H=e=>d({enabled:e.target.checked}),t[17]=d,t[18]=H);let U;t[19]!==D.enabled||t[20]!==H?(U=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:D.enabled,onChange:H}),t[19]=D.enabled,t[20]=H,t[21]=U):U=t[21];let W;t[22]===n.enableFeishuAria?W=t[23]:(W=(0,$.jsx)(`span`,{children:n.enableFeishuAria}),t[22]=n.enableFeishuAria,t[23]=W);let G;t[24]!==U||t[25]!==W?(G=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[U,W]}),t[24]=U,t[25]=W,t[26]=G):G=t[26];let ie;t[27]===d?ie=t[28]:(ie=e=>d({dmPolicy:e}),t[27]=d,t[28]=ie);let K;t[29]!==n.dmPolicy||t[30]!==_||t[31]!==D.dmPolicy||t[32]!==ie?(K=(0,$.jsx)(se,{label:n.dmPolicy,value:D.dmPolicy,onChange:ie,options:_}),t[29]=n.dmPolicy,t[30]=_,t[31]=D.dmPolicy,t[32]=ie,t[33]=K):K=t[33];let q;t[34]!==n||t[35]!==C||t[36]!==D||t[37]!==S||t[38]!==M?(q=(0,$.jsx)(lt,{channel:`feishu`,accountIds:M,channelConfig:D,active:C,ch:n,language:S}),t[34]=n,t[35]=C,t[36]=D,t[37]=S,t[38]=M,t[39]=q):q=t[39];let ue;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ue):ue=t[40];let de;t[41]===n.feishuAppId?de=t[42]:(de=(0,$.jsxs)(Y,{children:[n.feishuAppId,ue]}),t[41]=n.feishuAppId,t[42]=de);let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[43]=fe):fe=t[43];let pe;t[44]===d?pe=t[45]:(pe=e=>d({appId:e.target.value}),t[44]=d,t[45]=pe);let me;t[46]!==D.appId||t[47]!==pe?(me=(0,$.jsx)(`input`,{className:fe,value:D.appId,onChange:pe,placeholder:`cli_xxx`}),t[46]=D.appId,t[47]=pe,t[48]=me):me=t[48];let he;t[49]===n.feishuAppIdDesc?he=t[50]:(he=(0,$.jsx)(ce,{children:n.feishuAppIdDesc}),t[49]=n.feishuAppIdDesc,t[50]=he);let ge;t[51]!==de||t[52]!==me||t[53]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[de,me,he]}),t[51]=de,t[52]=me,t[53]=he,t[54]=ge):ge=t[54];let _e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[55]=_e):_e=t[55];let ve;t[56]===n.feishuAppSecret?ve=t[57]:(ve=(0,$.jsxs)(Y,{children:[n.feishuAppSecret,_e]}),t[56]=n.feishuAppSecret,t[57]=ve);let ye=D.appSecret,be;t[58]===d?be=t[59]:(be=e=>d({appSecret:e}),t[58]=d,t[59]=be);let xe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=O(J(),`text-xs`),t[60]=xe):xe=t[60];let X;t[61]!==N||t[62]!==D.appSecret||t[63]!==I||t[64]!==be?(X=(0,$.jsx)(F,{value:ye,onChange:be,placeholder:`••••••••`,labels:I,baselineValue:N,inputClassName:xe}),t[61]=N,t[62]=D.appSecret,t[63]=I,t[64]=be,t[65]=X):X=t[65];let Se;t[66]===n.feishuAppSecretDesc?Se=t[67]:(Se=(0,$.jsx)(ce,{children:n.feishuAppSecretDesc}),t[66]=n.feishuAppSecretDesc,t[67]=Se);let Ce;t[68]!==ve||t[69]!==X||t[70]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ve,X,Se]}),t[68]=ve,t[69]=X,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]===n.feishuDomain?we=t[73]:(we=(0,$.jsx)(Y,{children:n.feishuDomain}),t[72]=n.feishuDomain,t[73]=we);let Te;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Te=J(),t[74]=Te):Te=t[74];let Ee=String(D.domain||`feishu`),De;t[75]===d?De=t[76]:(De=e=>d({domain:e.target.value}),t[75]=d,t[76]=De);let Oe,ke;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(`option`,{value:`feishu`,children:`feishu`}),ke=(0,$.jsx)(`option`,{value:`lark`,children:`lark`}),t[77]=Oe,t[78]=ke):(Oe=t[77],ke=t[78]);let Ae;t[79]!==Ee||t[80]!==De?(Ae=(0,$.jsxs)(`select`,{className:Te,value:Ee,onChange:De,children:[Oe,ke]}),t[79]=Ee,t[80]=De,t[81]=Ae):Ae=t[81];let je;t[82]!==we||t[83]!==Ae?(je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[we,Ae]}),t[82]=we,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]===n.connectionMode?Me=t[86]:(Me=(0,$.jsx)(Y,{children:n.connectionMode}),t[85]=n.connectionMode,t[86]=Me);let Ne;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=J(),t[87]=Ne):Ne=t[87];let Pe;t[88]===d?Pe=t[89]:(Pe=e=>d({connectionMode:e.target.value}),t[88]=d,t[89]=Pe);let Fe,Ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(`option`,{value:`websocket`,children:`websocket`}),Ie=(0,$.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[90]=Fe,t[91]=Ie):(Fe=t[90],Ie=t[91]);let Le;t[92]!==D.connectionMode||t[93]!==Pe?(Le=(0,$.jsxs)(`select`,{className:Ne,value:D.connectionMode,onChange:Pe,children:[Fe,Ie]}),t[92]=D.connectionMode,t[93]=Pe,t[94]=Le):Le=t[94];let Re;t[95]===n.connectionModeDesc?Re=t[96]:(Re=(0,$.jsx)(ce,{children:n.connectionModeDesc}),t[95]=n.connectionModeDesc,t[96]=Re);let ze;t[97]!==Me||t[98]!==Le||t[99]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Me,Le,Re]}),t[97]=Me,t[98]=Le,t[99]=Re,t[100]=ze):ze=t[100];let Be;t[101]!==je||t[102]!==ze?(Be=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[je,ze]}),t[101]=je,t[102]=ze,t[103]=Be):Be=t[103];let Ve;t[104]!==n.copied||t[105]!==n.copy||t[106]!==n.encryptKey||t[107]!==n.encryptKeyDesc||t[108]!==n.hide||t[109]!==n.show||t[110]!==n.verificationToken||t[111]!==n.verificationTokenDesc||t[112]!==n.webhookHost||t[113]!==n.webhookPath||t[114]!==n.webhookPathDesc||t[115]!==n.webhookPort||t[116]!==n.webhookTitle||t[117]!==u||t[118]!==s||t[119]!==D.connectionMode||t[120]!==D.encryptKey||t[121]!==D.verificationToken||t[122]!==D.webhookHost||t[123]!==D.webhookPath||t[124]!==D.webhookPort||t[125]!==o||t[126]!==a||t[127]!==d?(Ve=D.connectionMode===`webhook`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(ft),children:[a?(0,$.jsx)(re,{className:`size-3.5`}):(0,$.jsx)(l,{className:`size-3.5`}),a?n.hide:n.show]}),(0,$.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void u(),children:[s?(0,$.jsx)(y,{className:`size-3.5`}):(0,$.jsx)(c,{className:`size-3.5`}),s?n.copied:n.copy]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.verificationToken}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.verificationToken??``,onChange:e=>d({verificationToken:e.target.value})}),(0,$.jsx)(ce,{children:n.verificationTokenDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.encryptKey}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.encryptKey??``,onChange:e=>d({encryptKey:e.target.value})}),(0,$.jsx)(ce,{children:n.encryptKeyDesc})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Y,{children:n.webhookHost}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookHost??``,onChange:e=>d({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPort}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.webhookPort??``),onChange:e=>d({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPath}),(0,$.jsx)(`input`,{className:O(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookPath??``,onChange:e=>d({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,$.jsx)(ce,{children:n.webhookPathDesc})]})]}):null,t[104]=n.copied,t[105]=n.copy,t[106]=n.encryptKey,t[107]=n.encryptKeyDesc,t[108]=n.hide,t[109]=n.show,t[110]=n.verificationToken,t[111]=n.verificationTokenDesc,t[112]=n.webhookHost,t[113]=n.webhookPath,t[114]=n.webhookPathDesc,t[115]=n.webhookPort,t[116]=n.webhookTitle,t[117]=u,t[118]=s,t[119]=D.connectionMode,t[120]=D.encryptKey,t[121]=D.verificationToken,t[122]=D.webhookHost,t[123]=D.webhookPath,t[124]=D.webhookPort,t[125]=o,t[126]=a,t[127]=d,t[128]=Ve):Ve=t[128];let He;t[129]===n.renderMode?He=t[130]:(He=(0,$.jsx)(Y,{children:n.renderMode}),t[129]=n.renderMode,t[130]=He);let We;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(We=J(),t[131]=We):We=t[131];let Ge;t[132]===d?Ge=t[133]:(Ge=e=>d({renderMode:e.target.value}),t[132]=d,t[133]=Ge);let Ke,qe,Je;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,$.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,$.jsx)(`option`,{value:`card`,children:`card`}),t[134]=Ke,t[135]=qe,t[136]=Je):(Ke=t[134],qe=t[135],Je=t[136]);let Ye;t[137]!==D.renderMode||t[138]!==Ge?(Ye=(0,$.jsxs)(`select`,{className:We,value:D.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[137]=D.renderMode,t[138]=Ge,t[139]=Ye):Ye=t[139];let Xe;t[140]!==He||t[141]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[He,Ye]}),t[140]=He,t[141]=Ye,t[142]=Xe):Xe=t[142];let Ze;t[143]===n.reactionNotifications?Ze=t[144]:(Ze=(0,$.jsx)(Y,{children:n.reactionNotifications}),t[143]=n.reactionNotifications,t[144]=Ze);let Qe;t[145]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=J(),t[145]=Qe):Qe=t[145];let $e;t[146]===d?$e=t[147]:($e=e=>d({reactionNotifications:e.target.value}),t[146]=d,t[147]=$e);let et,tt,nt;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,$.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,$.jsx)(`option`,{value:`all`,children:`all`}),t[148]=et,t[149]=tt,t[150]=nt):(et=t[148],tt=t[149],nt=t[150]);let rt;t[151]!==D.reactionNotifications||t[152]!==$e?(rt=(0,$.jsxs)(`select`,{className:Qe,value:D.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[151]=D.reactionNotifications,t[152]=$e,t[153]=rt):rt=t[153];let it;t[154]!==Ze||t[155]!==rt?(it=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[154]=Ze,t[155]=rt,t[156]=it):it=t[156];let at;t[157]!==Xe||t[158]!==it?(at=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[157]=Xe,t[158]=it,t[159]=at):at=t[159];let ot;t[160]===d?ot=t[161]:(ot=e=>d({streaming:e.target.checked}),t[160]=d,t[161]=ot);let st;t[162]!==D.streaming||t[163]!==ot?(st=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.streaming,onChange:ot}),t[162]=D.streaming,t[163]=ot,t[164]=st):st=t[164];let ct;t[165]!==n.enableStreaming||t[166]!==st?(ct=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[165]=n.enableStreaming,t[166]=st,t[167]=ct):ct=t[167];let ut;t[168]===n.groupPolicy?ut=t[169]:(ut=(0,$.jsx)(Y,{children:n.groupPolicy}),t[168]=n.groupPolicy,t[169]=ut);let mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(mt=J(),t[170]=mt):mt=t[170];let ht=D.groupPolicy,gt;t[171]===d?gt=t[172]:(gt=e=>d({groupPolicy:e.target.value}),t[171]=d,t[172]=gt);let _t;t[173]===v?_t=t[174]:(_t=v.map(dt),t[173]=v,t[174]=_t);let vt;t[175]!==D.groupPolicy||t[176]!==gt||t[177]!==_t?(vt=(0,$.jsx)(`select`,{className:mt,value:ht,onChange:gt,children:_t}),t[175]=D.groupPolicy,t[176]=gt,t[177]=_t,t[178]=vt):vt=t[178];let yt;t[179]!==ut||t[180]!==vt?(yt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ut,vt]}),t[179]=ut,t[180]=vt,t[181]=yt):yt=t[181];let bt;t[182]===d?bt=t[183]:(bt=e=>d({requireMention:e.target.checked}),t[182]=d,t[183]=bt);let xt;t[184]!==D.requireMention||t[185]!==bt?(xt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.requireMention,onChange:bt}),t[184]=D.requireMention,t[185]=bt,t[186]=xt):xt=t[186];let St;t[187]!==n.requireMention||t[188]!==xt?(St=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[xt,n.requireMention]}),t[187]=n.requireMention,t[188]=xt,t[189]=St):St=t[189];let Ct;t[190]===n.allowFromDm?Ct=t[191]:(Ct=(0,$.jsx)(Y,{children:n.allowFromDm}),t[190]=n.allowFromDm,t[191]=Ct);let wt;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(wt=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[192]=wt):wt=t[192];let Tt;t[193]===D.allowFrom?Tt=t[194]:(Tt=ae(D.allowFrom),t[193]=D.allowFrom,t[194]=Tt);let Et;t[195]===d?Et=t[196]:(Et=e=>d({allowFrom:oe(e.target.value)}),t[195]=d,t[196]=Et);let Dt;t[197]!==Tt||t[198]!==Et?(Dt=(0,$.jsx)(`textarea`,{className:wt,rows:2,placeholder:`ou_xxx, on_xxx`,value:Tt,onChange:Et}),t[197]=Tt,t[198]=Et,t[199]=Dt):Dt=t[199];let Ot;t[200]===n.allowFromDmDesc?Ot=t[201]:(Ot=(0,$.jsx)(ce,{children:n.allowFromDmDesc}),t[200]=n.allowFromDmDesc,t[201]=Ot);let kt;t[202]!==Ct||t[203]!==Dt||t[204]!==Ot?(kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ct,Dt,Ot]}),t[202]=Ct,t[203]=Dt,t[204]=Ot,t[205]=kt):kt=t[205];let At;t[206]===n.allowFromGroups?At=t[207]:(At=(0,$.jsx)(Y,{children:n.allowFromGroups}),t[206]=n.allowFromGroups,t[207]=At);let jt;t[208]===Symbol.for(`react.memo_cache_sentinel`)?(jt=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[208]=jt):jt=t[208];let Mt;t[209]===D.groupAllowFrom?Mt=t[210]:(Mt=ae(D.groupAllowFrom),t[209]=D.groupAllowFrom,t[210]=Mt);let Nt;t[211]===d?Nt=t[212]:(Nt=e=>d({groupAllowFrom:oe(e.target.value)}),t[211]=d,t[212]=Nt);let Pt;t[213]!==Mt||t[214]!==Nt?(Pt=(0,$.jsx)(`textarea`,{className:jt,rows:2,placeholder:`oc_xxx, oc_yyy`,value:Mt,onChange:Nt}),t[213]=Mt,t[214]=Nt,t[215]=Pt):Pt=t[215];let Ft;t[216]===n.allowFromGroupsDesc?Ft=t[217]:(Ft=(0,$.jsx)(ce,{children:n.allowFromGroupsDesc}),t[216]=n.allowFromGroupsDesc,t[217]=Ft);let It;t[218]!==At||t[219]!==Pt||t[220]!==Ft?(It=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[At,Pt,Ft]}),t[218]=At,t[219]=Pt,t[220]=Ft,t[221]=It):It=t[221];let Lt;t[222]===n.historyLimit?Lt=t[223]:(Lt=(0,$.jsx)(Y,{children:n.historyLimit}),t[222]=n.historyLimit,t[223]=Lt);let Rt;t[224]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[224]=Rt):Rt=t[224];let zt=String(D.historyLimit),Bt;t[225]===d?Bt=t[226]:(Bt=e=>d({historyLimit:Number(e.target.value||`0`)||0}),t[225]=d,t[226]=Bt);let Vt;t[227]!==zt||t[228]!==Bt?(Vt=(0,$.jsx)(`input`,{className:Rt,type:`number`,inputMode:`numeric`,value:zt,onChange:Bt}),t[227]=zt,t[228]=Bt,t[229]=Vt):Vt=t[229];let Ht;t[230]!==Lt||t[231]!==Vt?(Ht=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Lt,Vt]}),t[230]=Lt,t[231]=Vt,t[232]=Ht):Ht=t[232];let Ut;t[233]===n.textChunkLimit?Ut=t[234]:(Ut=(0,$.jsx)(Y,{children:n.textChunkLimit}),t[233]=n.textChunkLimit,t[234]=Ut);let Wt;t[235]===Symbol.for(`react.memo_cache_sentinel`)?(Wt=O(J(),`min-w-0 flex-1 font-mono text-xs`),t[235]=Wt):Wt=t[235];let Gt=String(D.textChunkLimit),Kt;t[236]===d?Kt=t[237]:(Kt=e=>d({textChunkLimit:Number(e.target.value||`0`)||0}),t[236]=d,t[237]=Kt);let qt;t[238]!==Gt||t[239]!==Kt?(qt=(0,$.jsx)(`input`,{className:Wt,type:`number`,inputMode:`numeric`,value:Gt,onChange:Kt}),t[238]=Gt,t[239]=Kt,t[240]=qt):qt=t[240];let Jt;t[241]!==Ut||t[242]!==qt?(Jt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ut,qt]}),t[241]=Ut,t[242]=qt,t[243]=Jt):Jt=t[243];let Yt;t[244]!==Jt||t[245]!==Ht?(Yt=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ht,Jt]}),t[244]=Jt,t[245]=Ht,t[246]=Yt):Yt=t[246];let Xt;t[247]===n.feishuToolsTitle?Xt=t[248]:(Xt=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[247]=n.feishuToolsTitle,t[248]=Xt);let Zt;t[249]===n.feishuToolDoc?Zt=t[250]:(Zt=[`doc`,n.feishuToolDoc],t[249]=n.feishuToolDoc,t[250]=Zt);let Qt;t[251]===n.feishuToolWiki?Qt=t[252]:(Qt=[`wiki`,n.feishuToolWiki],t[251]=n.feishuToolWiki,t[252]=Qt);let $t;t[253]===n.feishuToolDrive?$t=t[254]:($t=[`drive`,n.feishuToolDrive],t[253]=n.feishuToolDrive,t[254]=$t);let en;t[255]===n.feishuToolPerm?en=t[256]:(en=[`perm`,n.feishuToolPerm],t[255]=n.feishuToolPerm,t[256]=en);let tn;t[257]===n.feishuToolBitable?tn=t[258]:(tn=[`bitable`,n.feishuToolBitable],t[257]=n.feishuToolBitable,t[258]=tn);let nn;t[259]===n.feishuToolScopes?nn=t[260]:(nn=[`scopes`,n.feishuToolScopes],t[259]=n.feishuToolScopes,t[260]=nn);let rn;t[261]!==Zt||t[262]!==Qt||t[263]!==$t||t[264]!==en||t[265]!==tn||t[266]!==nn?(rn=[Zt,Qt,$t,en,tn,nn],t[261]=Zt,t[262]=Qt,t[263]=$t,t[264]=en,t[265]=tn,t[266]=nn,t[267]=rn):rn=t[267];let an=rn,on;t[268]!==D.tools||t[269]!==an||t[270]!==d?(on=(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:an.map(e=>{let[t,n]=e;return(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!D.tools?.[t],onChange:e=>d({tools:{...D.tools,[t]:e.target.checked}})}),n]},t)})}),t[268]=D.tools,t[269]=an,t[270]=d,t[271]=on):on=t[271];let sn;t[272]===n.feishuToolsDesc?sn=t[273]:(sn=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(ce,{children:n.feishuToolsDesc})}),t[272]=n.feishuToolsDesc,t[273]=sn);let cn;t[274]!==Xt||t[275]!==on||t[276]!==sn?(cn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[Xt,on,sn]}),t[274]=Xt,t[275]=on,t[276]=sn,t[277]=cn):cn=t[277];let ln;t[278]===n.feishuActionsTitle?ln=t[279]:(ln=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[278]=n.feishuActionsTitle,t[279]=ln);let un=!!D.actions?.reactions,dn;t[280]!==D.actions||t[281]!==d?(dn=e=>d({actions:{...D.actions,reactions:e.target.checked}}),t[280]=D.actions,t[281]=d,t[282]=dn):dn=t[282];let fn;t[283]!==un||t[284]!==dn?(fn=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:un,onChange:dn}),t[283]=un,t[284]=dn,t[285]=fn):fn=t[285];let pn;t[286]!==n.feishuActionReactions||t[287]!==fn?(pn=(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fn,n.feishuActionReactions]}),t[286]=n.feishuActionReactions,t[287]=fn,t[288]=pn):pn=t[288];let mn;t[289]!==ln||t[290]!==pn?(mn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[ln,pn]}),t[289]=ln,t[290]=pn,t[291]=mn):mn=t[291];let hn;t[292]===D?hn=t[293]:(hn=le(D),t[292]=D,t[293]=hn);let gn;t[294]===b?.items?gn=t[295]:(gn=b?.items??[],t[294]=b?.items,t[295]=gn);let _n;t[296]===f?_n=t[297]:(_n=(e,t)=>f(`feishu`,e,t),t[296]=f,t[297]=_n);let vn;t[298]!==n||t[299]!==r.channelAgentRoutes.feishu||t[300]!==r.defaultAgentId||t[301]!==x||t[302]!==hn||t[303]!==gn||t[304]!==_n?(vn=(0,$.jsx)(Ue,{accountIds:hn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:gn,disabled:x,onChange:_n,ch:n}),t[298]=n,t[299]=r.channelAgentRoutes.feishu,t[300]=r.defaultAgentId,t[301]=x,t[302]=hn,t[303]=gn,t[304]=_n,t[305]=vn):vn=t[305];let yn;t[306]===n.multiAccountJson?yn=t[307]:(yn=(0,$.jsx)(Y,{children:n.multiAccountJson}),t[306]=n.multiAccountJson,t[307]=yn);let bn;t[308]===Symbol.for(`react.memo_cache_sentinel`)?(bn=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[308]=bn):bn=t[308];let xn;t[309]===m?xn=t[310]:(xn=e=>m(e.target.value),t[309]=m,t[310]=xn);let Sn;t[311]!==p||t[312]!==g||t[313]!==xn?(Sn=(0,$.jsx)(`textarea`,{className:bn,spellCheck:!1,value:p,onChange:xn,onBlur:g,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[311]=p,t[312]=g,t[313]=xn,t[314]=Sn):Sn=t[314];let Cn;t[315]!==n.multiAccountJsonDesc||t[316]!==h?(Cn=h?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:h}):(0,$.jsx)(ce,{children:n.multiAccountJsonDesc}),t[315]=n.multiAccountJsonDesc,t[316]=h,t[317]=Cn):Cn=t[317];let wn;t[318]!==yn||t[319]!==Sn||t[320]!==Cn?(wn=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[yn,Sn,Cn]}),t[318]=yn,t[319]=Sn,t[320]=Cn,t[321]=wn):wn=t[321];let Tn;t[322]!==Yt||t[323]!==cn||t[324]!==mn||t[325]!==vn||t[326]!==wn||t[327]!==ge||t[328]!==Ce||t[329]!==Be||t[330]!==Ve||t[331]!==at||t[332]!==ct||t[333]!==yt||t[334]!==St||t[335]!==kt||t[336]!==It?(Tn=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ge,Ce,Be,Ve,at,ct,yt,St,kt,It,Yt,cn,mn,vn,wn]}),t[322]=Yt,t[323]=cn,t[324]=mn,t[325]=vn,t[326]=wn,t[327]=ge,t[328]=Ce,t[329]=Be,t[330]=Ve,t[331]=at,t[332]=ct,t[333]=yt,t[334]=St,t[335]=kt,t[336]=It,t[337]=Tn):Tn=t[337];let En;t[338]!==G||t[339]!==Tn||t[340]!==K||t[341]!==q||t[342]!==V?(En=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[V,G,K,q,Tn]}),t[338]=G,t[339]=Tn,t[340]=K,t[341]=q,t[342]=V,t[343]=En):En=t[343];let Dn;return t[344]!==En||t[345]!==B?(Dn=(0,$.jsxs)(`details`,{ref:L,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[B,En]}),t[344]=En,t[345]=B,t[346]=Dn):Dn=t[346],Dn}function dt(e){return(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ft(e){return!e}function pt(){return it(`feishu`)}var mt=e(X(),1);function ht(e){let t=(0,Q.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,$.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,$.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,$.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,$.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var gt={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},_t={sessionKey:null,qrUrl:null};function vt({ch:e,onSetupSuccess:t,onOpenChange:n,closeOnSetupSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(`feishu`),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=R(()=>we({domain:a}).then(e=>({sessionKey:e.sessionKey,qrUrl:e.qrUrl})),[s,a],{initial:_t,errorData:_t}),m=p.data.sessionKey,h=p.data.qrUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(e=>{u(null),o(e),c(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let e=!1,t,n=async()=>{try{let n=await fe(m);if(e||n.phase===`polling`)return;if(n.phase===`done`){t!==void 0&&(window.clearInterval(t),t=void 0),p.setData(_t),n.ok?(r&&f.current(!1),d.current({appId:n.appId,domain:n.domain,openId:n.openId})):u(n.message);return}n.phase===`unknown`&&(t!==void 0&&window.clearInterval(t),u(n.message),p.setData(_t))}catch(n){e||(t!==void 0&&window.clearInterval(t),u(n instanceof Error?n.message:`Request failed`),p.setData(_t))}};return t=window.setInterval(()=>void n(),3e3),n(),()=>{e=!0,t!==void 0&&window.clearInterval(t)}},[m,r,p.setData]);let b=R(()=>mt.toDataURL(h,gt),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,w=!!(h&&m),E=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.feishuQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.feishuQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||E)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E?e.feishuQrStarting:e.feishuQrScanHint}),(0,$.jsxs)(`div`,{className:O(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,E&&`bg-surface-muted/40 dark:bg-surface-base`),children:[E?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!x&&!S&&!E?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.feishuQrEncoding}):null,w&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.feishuQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(V,{className:`size-3 shrink-0`}),e.feishuQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":e.feishuRegionSwitchAria,children:(0,$.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:g,className:O(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,C.press,a===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`feishu`),children:e.feishuRegionChina}),(0,$.jsx)(`button`,{type:`button`,disabled:g,className:O(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,C.press,a===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`lark`),children:e.feishuRegionInternational})]})}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:()=>y(a),children:g?e.feishuQrStarting:e.feishuQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function yt(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onSetupSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnSetupSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==r||t[12]!==a||t[13]!==n?(v=n?(0,$.jsx)(vt,{ch:i,onSetupSuccess:a,onOpenChange:r,closeOnSetupSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=r,t[12]=a,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.feishuQrCloseAria||t[16]!==i.feishuQrModalSubtitle||t[17]!==i.feishuQrModalTitle||t[18]!==i.feishuSubtitle||t[19]!==i.feishuTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.feishuTitle,description:i.feishuSubtitle,srTitle:i.feishuQrModalTitle,srDescription:i.feishuQrModalSubtitle,closeAriaLabel:i.feishuQrCloseAria,wide:!0,footer:_,children:v}),t[15]=i.feishuQrCloseAria,t[16]=i.feishuQrModalSubtitle,t[17]=i.feishuQrModalTitle,t[18]=i.feishuSubtitle,t[19]=i.feishuTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function bt(e){let t=(0,Q.c)(25),{ch:n,usesPairing:r,tokenReady:i,pairingComplete:a}=e;if(!r)return null;let o=i,s=a,c=!o,l=o&&!s,u;t[0]!==c||t[1]!==o?(u=(0,$.jsx)(xt,{done:o,current:c,index:1}),t[0]=c,t[1]=o,t[2]=u):u=t[2];let d=o&&`text-fg-muted`,f;t[3]===d?f=t[4]:(f=O(`text-fg`,d),t[3]=d,t[4]=f);let p;t[5]!==n.telegramSetupStepToken||t[6]!==f?(p=(0,$.jsx)(`span`,{className:f,children:n.telegramSetupStepToken}),t[5]=n.telegramSetupStepToken,t[6]=f,t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==p?(m=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[u,p]}),t[8]=u,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==l||t[12]!==s?(h=(0,$.jsx)(xt,{done:s,current:l,index:2}),t[11]=l,t[12]=s,t[13]=h):h=t[13];let g=s&&`text-fg-muted`,_;t[14]===g?_=t[15]:(_=O(`text-fg`,g),t[14]=g,t[15]=_);let v;t[16]!==n.telegramSetupStepPairing||t[17]!==_?(v=(0,$.jsx)(`span`,{className:_,children:n.telegramSetupStepPairing}),t[16]=n.telegramSetupStepPairing,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==h||t[20]!==v?(y=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[h,v]}),t[19]=h,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`ol`,{className:`space-y-2 rounded-xl border border-accent/25 bg-accent-soft/20 px-4 py-3 text-xs`,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function xt(e){let t=(0,Q.c)(7),{done:n,current:r,index:i}=e,a=n&&`border-success bg-success text-white`,o=!n&&r&&`border-accent bg-accent text-white`,s=!n&&!r&&`border-edge text-fg-muted`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c=O(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,a,o,s),t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=n?`✓`:String(i),u;return t[4]!==c||t[5]!==l?(u=(0,$.jsx)(`span`,{className:c,"aria-hidden":!0,children:l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}function St(e){let t=(0,Q.c)(115),{tg:n,updateTelegram:r,ch:i,groupOpts:a,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}=e,f;t[0]===i.apiRoot?f=t[1]:(f=(0,$.jsx)(Y,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(),t[2]=p):p=t[2];let m;t[3]===r?m=t[4]:(m=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=m);let h;t[5]!==m||t[6]!==n.apiRoot?(h=(0,$.jsx)(`input`,{className:p,value:n.apiRoot,onChange:m,placeholder:`https://api.telegram.org`}),t[5]=m,t[6]=n.apiRoot,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,h]}),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===i.proxy?_=t[12]:(_=(0,$.jsx)(Y,{children:i.proxy}),t[11]=i.proxy,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=J(),t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=e=>r({proxy:e.target.value}),t[14]=r,t[15]=y);let b;t[16]!==y||t[17]!==n.proxy?(b=(0,$.jsx)(`input`,{className:v,value:n.proxy,onChange:y,placeholder:`http://proxy.example.com:8080`}),t[16]=y,t[17]=n.proxy,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]===r?S=t[23]:(S=e=>r({groupPolicy:e}),t[22]=r,t[23]=S);let C;t[24]!==i.groupPolicy||t[25]!==a||t[26]!==S||t[27]!==n.groupPolicy?(C=(0,$.jsx)(se,{label:i.groupPolicy,value:n.groupPolicy,onChange:S,options:a}),t[24]=i.groupPolicy,t[25]=a,t[26]=S,t[27]=n.groupPolicy,t[28]=C):C=t[28];let w;t[29]===r?w=t[30]:(w=e=>r({replyToMode:e}),t[29]=r,t[30]=w);let T;t[31]!==i.replyToMode||t[32]!==o||t[33]!==w||t[34]!==n.replyToMode?(T=(0,$.jsx)(se,{label:i.replyToMode,value:n.replyToMode,onChange:w,options:o}),t[31]=i.replyToMode,t[32]=o,t[33]=w,t[34]=n.replyToMode,t[35]=T):T=t[35];let E;t[36]===r?E=t[37]:(E=e=>r({streamMode:e}),t[36]=r,t[37]=E);let D;t[38]!==i.streamMode||t[39]!==s||t[40]!==E||t[41]!==n.streamMode?(D=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:E,options:s}),t[38]=i.streamMode,t[39]=s,t[40]=E,t[41]=n.streamMode,t[42]=D):D=t[42];let k;t[43]===i.allowFromGroups?k=t[44]:(k=(0,$.jsx)(Y,{children:i.allowFromGroups}),t[43]=i.allowFromGroups,t[44]=k);let A;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(A=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[45]=A):A=t[45];let j;t[46]===n.groupAllowFrom?j=t[47]:(j=ae(n.groupAllowFrom),t[46]=n.groupAllowFrom,t[47]=j);let M;t[48]===r?M=t[49]:(M=e=>r({groupAllowFrom:oe(e.target.value)}),t[48]=r,t[49]=M);let N;t[50]!==j||t[51]!==M?(N=(0,$.jsx)(`textarea`,{className:A,rows:2,placeholder:`-1001234567890`,value:j,onChange:M}),t[50]=j,t[51]=M,t[52]=N):N=t[52];let P;t[53]!==k||t[54]!==N?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,N]}),t[53]=k,t[54]=N,t[55]=P):P=t[55];let F;t[56]===i.historyLimit?F=t[57]:(F=(0,$.jsx)(Y,{children:i.historyLimit}),t[56]=i.historyLimit,t[57]=F);let I;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(),t[58]=I):I=t[58];let L;t[59]===r?L=t[60]:(L=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[59]=r,t[60]=L);let ee;t[61]!==L||t[62]!==n.historyLimit?(ee=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:I,value:n.historyLimit,onChange:L}),t[61]=L,t[62]=n.historyLimit,t[63]=ee):ee=t[63];let R;t[64]!==F||t[65]!==ee?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[F,ee]}),t[64]=F,t[65]=ee,t[66]=R):R=t[66];let te;t[67]===i.textChunkLimit?te=t[68]:(te=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[67]=i.textChunkLimit,t[68]=te);let z;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(z=J(),t[69]=z):z=t[69];let ne;t[70]===r?ne=t[71]:(ne=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[70]=r,t[71]=ne);let re;t[72]!==ne||t[73]!==n.textChunkLimit?(re=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:z,value:n.textChunkLimit,onChange:ne}),t[72]=ne,t[73]=n.textChunkLimit,t[74]=re):re=t[74];let B;t[75]!==te||t[76]!==re?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[te,re]}),t[75]=te,t[76]=re,t[77]=B):B=t[77];let V;t[78]!==R||t[79]!==B?(V=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,B]}),t[78]=R,t[79]=B,t[80]=V):V=t[80];let H;t[81]===r?H=t[82]:(H=e=>r({debug:e.target.checked}),t[81]=r,t[82]=H);let U;t[83]!==H||t[84]!==n.debug?(U=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:H}),t[83]=H,t[84]=n.debug,t[85]=U):U=t[85];let W;t[86]!==i.telegramDebug||t[87]!==U?(W=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[U,i.telegramDebug]}),t[86]=i.telegramDebug,t[87]=U,t[88]=W):W=t[88];let G;t[89]===i.multiAccountJson?G=t[90]:(G=(0,$.jsx)(Y,{children:i.multiAccountJson}),t[89]=i.multiAccountJson,t[90]=G);let ie;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(ie=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[91]=ie):ie=t[91];let K;t[92]===l?K=t[93]:(K=e=>l(e.target.value),t[92]=l,t[93]=K);let q;t[94]!==d||t[95]!==K||t[96]!==c?(q=(0,$.jsx)(`textarea`,{className:ie,spellCheck:!1,value:c,onChange:K,onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[94]=d,t[95]=K,t[96]=c,t[97]=q):q=t[97];let le;t[98]!==i.multiAccountJsonDesc||t[99]!==u?(le=u?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,$.jsx)(ce,{children:i.multiAccountJsonDesc}),t[98]=i.multiAccountJsonDesc,t[99]=u,t[100]=le):le=t[100];let ue;t[101]!==G||t[102]!==q||t[103]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,q,le]}),t[101]=G,t[102]=q,t[103]=le,t[104]=ue):ue=t[104];let de;return t[105]!==x||t[106]!==C||t[107]!==T||t[108]!==D||t[109]!==P||t[110]!==V||t[111]!==W||t[112]!==ue||t[113]!==g?(de=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[g,x,C,T,D,P,V,W,ue]}),t[105]=x,t[106]=C,t[107]=T,t[108]=D,t[109]=P,t[110]=V,t[111]=W,t[112]=ue,t[113]=g,t[114]=de):de=t[114],de}function Ct(e){let t=(0,Q.c)(151),{open:n,onOpenChange:r,presentation:i,ch:a,form:o,baseline:s,tgAdvanced:c,setTgAdvanced:l,updateTelegram:u,updateChannelAgentRoute:d,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h,dmOpts:g,groupOpts:_,replyOpts:v,streamOpts:y,chatAgents:b,saving:x,dirty:S,save:C,discard:w,language:E,scrollToPairingOnOpen:D,closeOnSave:k}=e,A=i===void 0?`modal`:i,j=D===void 0?!1:D,M=k===void 0?!0:k,N=o.telegram,P;t[0]===s?P=t[1]:(P=s?ie(s.telegram):``,t[0]=s,t[1]=P);let I=P,L=ie(N),R;t[2]!==a.copied||t[3]!==a.copy||t[4]!==a.hide||t[5]!==a.show?(R=ee({show:a.show,hide:a.hide,copy:a.copy,copied:a.copied}),t[2]=a.copied,t[3]=a.copy,t[4]=a.hide,t[5]=a.show,t[6]=R):R=t[6];let te=R,[z,re]=(0,Z.useState)(0),B=!!L.trim()&&N.enabled,V;t[7]===N?V=t[8]:(V=Te(N),t[7]=N,t[8]=V);let H=V,U,W;t[9]!==n||t[10]!==j?(U=()=>{if(!n||!j)return;let e=window.setTimeout(Tt,80);return()=>window.clearTimeout(e)},W=[n,j],t[9]=n,t[10]=j,t[11]=U,t[12]=W):(U=t[11],W=t[12]),(0,Z.useEffect)(U,W);let G=a.telegramTitle,K=a.telegramSubtitle,q=a.telegramTitle,le=a.telegramSubtitle,ue=a.modalCancel,de;t[13]!==a.telegramSubtitle||t[14]!==a.telegramTitle||t[15]!==A?(de=A===`modal`?(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:a.telegramTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.telegramSubtitle})]}):void 0,t[13]=a.telegramSubtitle,t[14]=a.telegramTitle,t[15]=A,t[16]=de):de=t[16];let fe;t[17]===r?fe=t[18]:(fe=()=>r(!1),t[17]=r,t[18]=fe);let pe;t[19]!==M||t[20]!==r||t[21]!==C?(pe=async()=>{await C()&&M&&r(!1)},t[19]=M,t[20]=r,t[21]=C,t[22]=pe):pe=t[22];let me;t[23]!==a||t[24]!==S||t[25]!==w||t[26]!==x||t[27]!==fe||t[28]!==pe?(me=(0,$.jsx)(ht,{ch:a,dirty:S,saving:x,onCancel:fe,onDiscard:w,onSave:pe}),t[23]=a,t[24]=S,t[25]=w,t[26]=x,t[27]=fe,t[28]=pe,t[29]=me):me=t[29];let he;t[30]===u?he=t[31]:(he=e=>u({enabled:e.target.checked}),t[30]=u,t[31]=he);let ge;t[32]!==he||t[33]!==N.enabled?(ge=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:N.enabled,onChange:he}),t[32]=he,t[33]=N.enabled,t[34]=ge):ge=t[34];let _e;t[35]===a.enableTelegramAria?_e=t[36]:(_e=(0,$.jsx)(`span`,{children:a.enableTelegramAria}),t[35]=a.enableTelegramAria,t[36]=_e);let ve;t[37]!==ge||t[38]!==_e?(ve=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,_e]}),t[37]=ge,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ye):ye=t[40];let be;t[41]===a.telegramToken?be=t[42]:(be=(0,$.jsxs)(Y,{children:[a.telegramToken,ye]}),t[41]=a.telegramToken,t[42]=be);let xe;t[43]!==N.accounts||t[44]!==u?(xe=e=>{let t=N.accounts?.default??Se(`default`);u({accounts:{...N.accounts,default:{...t,accountId:`default`,botToken:e}}})},t[43]=N.accounts,t[44]=u,t[45]=xe):xe=t[45];let X;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(X=O(J(),`text-xs`),t[46]=X):X=t[46];let Ce;t[47]!==te||t[48]!==xe||t[49]!==I||t[50]!==L?(Ce=(0,$.jsx)(F,{value:L,onChange:xe,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,labels:te,baselineValue:I,inputClassName:X}),t[47]=te,t[48]=xe,t[49]=I,t[50]=L,t[51]=Ce):Ce=t[51];let we;t[52]===a.telegramTokenDesc?we=t[53]:(we=(0,$.jsx)(ce,{children:a.telegramTokenDesc}),t[52]=a.telegramTokenDesc,t[53]=we);let Ee;t[54]!==be||t[55]!==Ce||t[56]!==we?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[be,Ce,we]}),t[54]=be,t[55]=Ce,t[56]=we,t[57]=Ee):Ee=t[57];let De;t[58]===N?De=t[59]:(De=Xe(`telegram`,N),t[58]=N,t[59]=De);let Oe=z>0,ke;t[60]!==a||t[61]!==De||t[62]!==Oe||t[63]!==B?(ke=(0,$.jsx)(bt,{ch:a,usesPairing:De,tokenReady:B,pairingComplete:Oe}),t[60]=a,t[61]=De,t[62]=Oe,t[63]=B,t[64]=ke):ke=t[64];let Ae;t[65]===u?Ae=t[66]:(Ae=e=>u({dmPolicy:e}),t[65]=u,t[66]=Ae);let je;t[67]!==a.dmPolicy||t[68]!==g||t[69]!==Ae||t[70]!==N.dmPolicy?(je=(0,$.jsx)(se,{label:a.dmPolicy,value:N.dmPolicy,onChange:Ae,options:g}),t[67]=a.dmPolicy,t[68]=g,t[69]=Ae,t[70]=N.dmPolicy,t[71]=je):je=t[71];let Me;t[72]!==a||t[73]!==E||t[74]!==n||t[75]!==re||t[76]!==N||t[77]!==H?(Me=(0,$.jsx)(lt,{channel:`telegram`,accountIds:H,channelConfig:N,active:n,ch:a,language:E,onPairedChange:re}),t[72]=a,t[73]=E,t[74]=n,t[75]=re,t[76]=N,t[77]=H,t[78]=Me):Me=t[78];let Ne;t[79]===a.allowFromDm?Ne=t[80]:(Ne=(0,$.jsx)(Y,{children:a.allowFromDm}),t[79]=a.allowFromDm,t[80]=Ne);let Pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[81]=Pe):Pe=t[81];let Fe;t[82]===N.allowFrom?Fe=t[83]:(Fe=ae(N.allowFrom),t[82]=N.allowFrom,t[83]=Fe);let Ie;t[84]===u?Ie=t[85]:(Ie=e=>u({allowFrom:oe(e.target.value)}),t[84]=u,t[85]=Ie);let Le;t[86]!==Fe||t[87]!==Ie?(Le=(0,$.jsx)(`textarea`,{className:Pe,rows:2,placeholder:`123456789, 987654321`,value:Fe,onChange:Ie}),t[86]=Fe,t[87]=Ie,t[88]=Le):Le=t[88];let Re;t[89]===a.allowFromDmDesc?Re=t[90]:(Re=(0,$.jsx)(ce,{children:a.allowFromDmDesc}),t[89]=a.allowFromDmDesc,t[90]=Re);let Be;t[91]!==Ne||t[92]!==Le||t[93]!==Re?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Le,Re]}),t[91]=Ne,t[92]=Le,t[93]=Re,t[94]=Be):Be=t[94];let Ve;t[95]===N?Ve=t[96]:(Ve=Te(N),t[95]=N,t[96]=Ve);let He;t[97]===b?.items?He=t[98]:(He=b?.items??[],t[97]=b?.items,t[98]=He);let We;t[99]===d?We=t[100]:(We=(e,t)=>d(`telegram`,e,t),t[99]=d,t[100]=We);let Ge;t[101]!==a||t[102]!==o.channelAgentRoutes.telegram||t[103]!==o.defaultAgentId||t[104]!==x||t[105]!==Ve||t[106]!==He||t[107]!==We?(Ge=(0,$.jsx)(Ue,{accountIds:Ve,routes:o.channelAgentRoutes.telegram,defaultAgentId:o.defaultAgentId,agentItems:He,disabled:x,onChange:We,ch:a}),t[101]=a,t[102]=o.channelAgentRoutes.telegram,t[103]=o.defaultAgentId,t[104]=x,t[105]=Ve,t[106]=He,t[107]=We,t[108]=Ge):Ge=t[108];let Ke;t[109]===l?Ke=t[110]:(Ke=()=>l(wt),t[109]=l,t[110]=Ke);let qe=c&&`rotate-180`,Je;t[111]===qe?Je=t[112]:(Je=O(`mr-1 size-4 transition-transform`,qe),t[111]=qe,t[112]=Je);let Ye;t[113]===Je?Ye=t[114]:(Ye=(0,$.jsx)(ne,{className:Je}),t[113]=Je,t[114]=Ye);let Ze=c?a.advancedHide:a.advancedShow,Qe;t[115]!==Ke||t[116]!==Ye||t[117]!==Ze?(Qe=(0,$.jsxs)(T,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ke,children:[Ye,Ze]}),t[115]=Ke,t[116]=Ye,t[117]=Ze,t[118]=Qe):Qe=t[118];let $e;t[119]!==a||t[120]!==_||t[121]!==h||t[122]!==v||t[123]!==p||t[124]!==y||t[125]!==N||t[126]!==f||t[127]!==m||t[128]!==c||t[129]!==u?($e=c?(0,$.jsx)(St,{tg:N,updateTelegram:u,ch:a,groupOpts:_,replyOpts:v,streamOpts:y,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h}):null,t[119]=a,t[120]=_,t[121]=h,t[122]=v,t[123]=p,t[124]=y,t[125]=N,t[126]=f,t[127]=m,t[128]=c,t[129]=u,t[130]=$e):$e=t[130];let et;t[131]!==Ee||t[132]!==ke||t[133]!==je||t[134]!==Me||t[135]!==Be||t[136]!==Ge||t[137]!==Qe||t[138]!==$e?(et=(0,$.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Ee,ke,je,Me,Be,Ge,Qe,$e]}),t[131]=Ee,t[132]=ke,t[133]=je,t[134]=Me,t[135]=Be,t[136]=Ge,t[137]=Qe,t[138]=$e,t[139]=et):et=t[139];let tt;return t[140]!==a.modalCancel||t[141]!==a.telegramSubtitle||t[142]!==a.telegramTitle||t[143]!==r||t[144]!==n||t[145]!==A||t[146]!==de||t[147]!==me||t[148]!==ve||t[149]!==et?(tt=(0,$.jsxs)(ze,{presentation:A,open:n,onOpenChange:r,title:G,description:K,srTitle:q,srDescription:le,closeAriaLabel:ue,wide:!0,headerExtra:de,footer:me,children:[ve,et]}),t[140]=a.modalCancel,t[141]=a.telegramSubtitle,t[142]=a.telegramTitle,t[143]=r,t[144]=n,t[145]=A,t[146]=de,t[147]=me,t[148]=ve,t[149]=et,t[150]=tt):tt=t[150],tt}function wt(e){return!e}function Tt(){return it(`telegram`)}var Et=[{id:`telegram`,titleKey:`telegramTitle`,subtitleKey:`telegramSubtitle`},{id:`weixin`,titleKey:`weixinTitle`,subtitleKey:`weixinSubtitle`},{id:`feishu`,titleKey:`feishuTitle`,subtitleKey:`feishuSubtitle`}];function Dt(){return o(`/api/channels/meta`)}async function Ot(){return(await v(Dt())).payload?.channels??[]}var kt=new Map(Et.map(e=>[e.id,e])),At=new Map(Et.map((e,t)=>[e.id,t]));function jt(e,t){return{title:t[e.titleKey],subtitle:t[e.subtitleKey]}}function Mt(e,t){let n=new Map;for(let r of e??[]){let e=kt.get(r.id),i=e?jt(e,t):{title:r.label,subtitle:r.description||t.hubExtensionSubtitle};n.set(r.id,{id:r.id,title:i.title,subtitle:i.subtitle,manageable:r.manageable,order:r.order})}if(n.size===0)return Et.map((e,n)=>{let r=jt(e,t);return{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:n}});for(let e of Et){if(n.has(e.id))continue;let r=jt(e,t);n.set(e.id,{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:At.get(e.id)??0})}return Array.from(n.values()).sort((e,t)=>e.order===t.order?e.id.localeCompare(t.id):e.order-t.order)}function Nt(e,t){let n=(0,Q.c)(11),r;n[0]===e?r=n[1]:(r=e?Dt():null,n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},n[2]=i):i=n[2];let{data:a,error:o,isLoading:c,mutate:l}=s(r,Ot,i),u;n[3]!==t||n[4]!==a?(u=Mt(a,t),n[3]=t,n[4]=a,n[5]=u):u=n[5];let d=u,f;return n[6]!==d||n[7]!==o||n[8]!==c||n[9]!==l?(f={entries:d,isLoading:c,error:o,mutate:l},n[6]=d,n[7]=o,n[8]=c,n[9]=l,n[10]=f):f=n[10],f}function Pt(e,t){return e.find(e=>e.name===t)?.connected??!1}function Ft(e,t){return e.find(e=>e.name===t)?.enabled??!1}function It(e,t){let n=e&&typeof e==`object`?e.channels:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n[t]:void 0;return!r||typeof r!=`object`?!1:Object.keys(r).length>0}function Lt(e,t,n){return e?t?n?`running`:`offline`:`disabled`:`not_configured`}function Rt(e,t,n){return n?e===`not_configured`?`setup`:t>0?`pairing`:e===`offline`?`fix`:`manage`:`manage`}function zt(e,t){return e.policy.dm[t]}function Bt(e,t){return e.hubSummaryAccountCount.replace(`{{count}}`,String(t))}function Vt(e,t){let n=t.telegram,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))],i=Te(n).length;return i>0&&r.push(Bt(e,i)),r}function Ht(e,t){let n=t.weixin,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))];r.push(e.hubSummaryStream.replace(`{{mode}}`,e.policy.stream[n.streamMode]));let i=Ee(n).length;return i>0&&r.push(Bt(e,i)),r}function Ut(e,t){let n=t.feishu,r=n.connectionMode===`webhook`?e.hubConnectionWebhook:e.hubConnectionWebsocket,i=[e.hubSummaryConnection.replace(`{{mode}}`,r)],a=le(n).length;return a>0&&i.push(Bt(e,a)),i}function Wt(e,t){return t[e]}function Gt(e){let{id:t,form:n,connected:r,pairingSummary:i,ch:a}=e,o=n.telegram,s=n.weixin,c=n.feishu,l=t===`telegram`?K(o):t===`weixin`?G(s):q(c),u=t===`telegram`?o.enabled:t===`weixin`?s.enabled:c.enabled,d=Ze({configured:l,channelEnabled:u,usesPairing:Xe(t,t===`telegram`?o:t===`weixin`?s:c),summaryPending:Wt(t,i).pending}),f=Lt(l,u,r);return{id:t,manageable:!0,configured:l,enabled:u,connected:r,status:f,summaryLines:l?t===`telegram`?Vt(a,n):t===`weixin`?Ht(a,n):Ut(a,n):[],pendingPairing:d,primaryAction:Rt(f,d,!0)}}function Kt(e){let{id:t,config:n,statuses:r,ch:i}=e,a=It(n,t),o=Ft(r,t),s=Pt(r,t);return{id:t,manageable:!1,configured:a,enabled:o,connected:s,status:Lt(a,o,s),summaryLines:a?[i.hubExtensionConfiguredHint]:[],pendingPairing:0,primaryAction:`manage`}}function qt(e){return M(e.id)?Gt({id:e.id,form:e.form,connected:Pt(e.statuses,e.id),pairingSummary:e.pairingSummary,ch:e.ch}):Kt({id:e.id,config:e.config,statuses:e.statuses,ch:e.ch})}function Jt(e){return e.catalogIds.map(t=>qt({id:t,form:e.form,config:e.config,statuses:e.statuses,pairingSummary:e.pairingSummary,ch:e.ch}))}var Yt=`channels-status`;function Xt(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Zt(e){let t=t=>e(t.detail);return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)}function Qt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Zt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}var $t={telegram:{pending:0,stale:0,atCapacity:!1},feishu:{pending:0,stale:0,atCapacity:!1},weixin:{pending:0,stale:0,atCapacity:!1}};function en(e){let t=(0,Q.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!0},t[0]=n):n=t[0];let{data:r,mutate:i,isLoading:a,error:o}=s(e?et:null,_e,n),c;t[1]===i?c=t[2]:(c=()=>{i()},t[1]=i,t[2]=c);let l=c;nt(l,e);let u=r??$t,d;return t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u?(d={summary:u,isLoading:a,error:o,refresh:l},t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d):d=t[7],d}var tn=3e4;function nn(e){let t=(0,Q.c)(25),{hasToken:n,form:r,ch:i}=e,{data:a,mutate:o}=I(n),{entries:c,mutate:l}=Nt(n,i),u;t[0]===n?u=t[1]:(u=n?Ce():null,t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!0,refreshInterval:tn},t[2]=d):d=t[2];let{data:f,mutate:p}=s(u,ye,d),m;t[3]===f?m=t[4]:(m=f===void 0?[]:f,t[3]=f,t[4]=m);let h=m,g;t[5]===p?g=t[6]:(g=e=>{let t=Xt(e);if(t){p(t,{revalidate:!1});return}p()},t[5]=p,t[6]=g),Qt(g,n);let{summary:_,refresh:v}=en(n),y;t[7]===c?y=t[8]:(y=c.map(rn),t[7]=c,t[8]=y);let b=y,x=a?.payload?.config,S;bb0:{if(!r||b.length===0){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],S=e;break bb0}let e;t[10]!==b||t[11]!==i||t[12]!==x||t[13]!==r||t[14]!==_||t[15]!==h?(e=Jt({catalogIds:b,form:r,config:x,statuses:h,pairingSummary:_,ch:i}),t[10]=b,t[11]=i,t[12]=x,t[13]=r,t[14]=_,t[15]=h,t[16]=e):e=t[16],S=e}let C=S,w;t[17]!==l||t[18]!==o||t[19]!==p||t[20]!==v?(w=()=>{p(),l(),o(),v()},t[17]=l,t[18]=o,t[19]=p,t[20]=v,t[21]=w):w=t[21];let T=w,E;return t[22]!==C||t[23]!==T?(E={cards:C,refreshAll:T},t[22]=C,t[23]=T,t[24]=E):E=t[24],E}function rn(e){return e.id}var an={form:null,baseline:null,tgAccountsDraft:``,tgAccountsError:``,wxAccountsDraft:``,wxAccountsError:``,feishuAccountsDraft:``,feishuAccountsError:``};function on(e){return{tgAccountsDraft:JSON.stringify(e.telegram.accounts??{},null,2),tgAccountsError:``,wxAccountsDraft:JSON.stringify(e.weixin.accounts??{},null,2),wxAccountsError:``,feishuAccountsDraft:JSON.stringify(e.feishu?.accounts??{},null,2),feishuAccountsError:``}}function sn(e,t){switch(t.type){case`reset`:return an;case`load`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`commitSaved`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`discard`:{if(!e.baseline)return e;let t=structuredClone(e.baseline);return{form:t,baseline:e.baseline,...on(t)}}case`updateTelegram`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,...t.patch}}}:e;case`updateWeixin`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,...t.patch}}}:e;case`updateFeishu`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,...t.patch}}}:e;case`updateChannelAgentRoute`:{if(!e.form)return e;let n=t.channel===`telegram`?`telegram`:t.channel===`weixin`?`weixin`:`feishu`;return{...e,form:{...e.form,channelAgentRoutes:{...e.form.channelAgentRoutes,[n]:{...e.form.channelAgentRoutes[n],[t.accountId]:t.agentId.trim().toLowerCase()}}}}}case`setTgAccountsDraft`:return{...e,tgAccountsDraft:t.value};case`setWxAccountsDraft`:return{...e,wxAccountsDraft:t.value};case`setFeishuAccountsDraft`:return{...e,feishuAccountsDraft:t.value};case`setTgAccountsError`:return{...e,tgAccountsError:t.value};case`setWxAccountsError`:return{...e,wxAccountsError:t.value};case`setFeishuAccountsError`:return{...e,feishuAccountsError:t.value};case`applyTgAccounts`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,accounts:t.accounts}},tgAccountsError:``}:e;case`applyWxAccounts`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,accounts:t.accounts}},wxAccountsError:``}:e;case`applyFeishuAccounts`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,accounts:t.accounts}},feishuAccountsError:``}:e;case`restoreForm`:return{...e,form:structuredClone(t.payload)}}}function cn(){let e=i(e=>e.language),t=a(e),n=t.channelsSettings,r=!!_(e=>e.token),o=(0,Z.useRef)(!1),[c,l]=(0,Z.useReducer)(sn,an),[u,d]=(0,Z.useState)({hasToken:r,parsed:null}),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[F,L]=(0,Z.useState)(!1),[ee,R]=(0,Z.useState)(!1),{data:te}=s(r?`gateway-chat-agents-ch`:null,x,{revalidateOnFocus:!1}),{data:z,error:ne,isLoading:re,mutate:B}=I(r),V=(0,Z.useMemo)(()=>z?.payload?.config===void 0?null:ve(z.payload.config),[z]);(r!==u.hasToken||V!==u.parsed)&&(d({hasToken:r,parsed:V}),r?V!==null&&!o.current&&(l({type:`load`,payload:V}),v(!1)):(o.current=!1,l({type:`reset`}),v(!1)));let{form:H,baseline:U,tgAccountsDraft:W,tgAccountsError:G,wxAccountsDraft:K,wxAccountsError:ae,feishuAccountsDraft:q,feishuAccountsError:oe}=c,J=(0,Z.useMemo)(()=>!H||!U?!1:JSON.stringify(H)!==JSON.stringify(U),[H,U]),Y=!!(r&&re&&z===void 0&&!ne),se=ne instanceof Error?ne.message:ne?String(ne):null,ce=(0,Z.useCallback)((e,t,n)=>{o.current=!0,l({type:`updateChannelAgentRoute`,channel:e,accountId:t,agentId:n})},[]),le=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateTelegram`,patch:e})},[]),ue=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateWeixin`,patch:e})},[]),de=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateFeishu`,patch:e})},[]),fe=(0,Z.useCallback)(async()=>{if(!H||f)return!1;p(!0),h(null),v(!1);try{let e=await he(H);return o.current=!1,l({type:`commitSaved`,payload:e}),v(!0),window.setTimeout(()=>v(!1),2500),!0}catch(e){return h(e instanceof Error?e.message:n.saveError),!1}finally{p(!1)}},[H,f,n.saveError]),pe=(0,Z.useCallback)(()=>{U&&(o.current=!1,l({type:`discard`}),h(null),v(!1))},[U]),me=(0,Z.useCallback)(async(e,t)=>{if(!H||f)return;let r=H,i=e===`weixin`?{...H,weixin:{...H.weixin,enabled:t}}:e===`telegram`?{...H,telegram:{...H.telegram,enabled:t}}:{...H,feishu:{...H.feishu,enabled:t}};o.current=!0,l(e===`weixin`?{type:`updateWeixin`,patch:{enabled:t}}:e===`telegram`?{type:`updateTelegram`,patch:{enabled:t}}:{type:`updateFeishu`,patch:{enabled:t}}),p(!0),h(null);try{let e=await he(i);o.current=!1,l({type:`commitSaved`,payload:e})}catch(e){h(e instanceof Error?e.message:n.saveError),o.current=!0,l({type:`restoreForm`,payload:r})}finally{p(!1)}},[H,f,n.saveError]),ge=(0,Z.useCallback)(async()=>{let e=H?ie(H.telegram):``;e&&await S(e)&&(P(!0),window.setTimeout(()=>P(!1),2e3))},[H]),_e=(0,Z.useCallback)(e=>{de({appId:e.appId,domain:e.domain,enabled:!0}),B(),w(n.feishuQrSetupSuccess),window.setTimeout(()=>w(null),4e3)},[de,B,n.feishuQrSetupSuccess]),ye=(0,Z.useCallback)(async()=>{let e=H?.feishu?.appSecret;e&&await S(e)&&(L(!0),window.setTimeout(()=>L(!1),2e3))},[H]),be=(0,Z.useCallback)(async()=>{let e=H?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await S(JSON.stringify(t,null,2))&&(R(!0),window.setTimeout(()=>R(!1),2e3))},[H]);return{language:e,m:t,ch:n,hasToken:r,loading:Y,fetchError:se,mutate:B,form:H,baseline:U,dirty:J,saving:f,error:m,saveOk:g,weixinSuccessBanner:y,setWeixinSuccessBanner:b,feishuSetupSuccessBanner:C,tgAdvanced:T,setTgAdvanced:E,showToken:D,setShowToken:O,showFeishuSecret:k,setShowFeishuSecret:A,showFeishuWebhookSecrets:j,setShowFeishuWebhookSecrets:M,copied:N,feishuCopied:F,feishuWebhookCopied:ee,tgAccountsDraft:W,setTgAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setTgAccountsDraft`,value:e})},[]),tgAccountsError:G,wxAccountsDraft:K,setWxAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setWxAccountsDraft`,value:e})},[]),wxAccountsError:ae,feishuAccountsDraft:q,setFeishuAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setFeishuAccountsDraft`,value:e})},[]),feishuAccountsError:oe,chatAgents:te,updateChannelAgentRoute:ce,updateTelegram:le,updateWeixin:ue,updateFeishu:de,save:fe,discard:pe,toggleChannelEnabled:me,copyToken:ge,handleFeishuQrSetupSuccess:_e,copyFeishuSecret:ye,copyFeishuWebhookConfig:be,onTgAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=W.trim();if(!e){o.current=!0,l({type:`applyTgAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyTgAccounts`,accounts:t})}catch(e){l({type:`setTgAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,W,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=K.trim();if(!e){o.current=!0,l({type:`applyWxAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyWxAccounts`,accounts:t})}catch(e){l({type:`setWxAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,K,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Z.useCallback)(()=>{if(!H)return;let e=q.trim();if(!e){o.current=!0,l({type:`applyFeishuAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyFeishuAccounts`,accounts:t})}catch(e){l({type:`setFeishuAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[H,q,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Z.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Z.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Z.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Z.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}var ln={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},un={sessionKey:null,qrcodeUrl:null};function dn({ch:e,onLoginSuccess:t,onOpenChange:n,closeOnLoginSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=R(()=>pe().then(e=>({sessionKey:e.sessionKey,qrcodeUrl:e.qrcodeUrl})),[a],{initial:un,errorData:un}),m=p.data.sessionKey,h=p.data.qrcodeUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(()=>{u(null),c(null),o(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let t=!1,n,i=async()=>{try{let i=await xe(m);if(t)return;if(i.phase===`polling`){p.setData(e=>({...e,qrcodeUrl:i.qrcodeUrl})),c(i.qrStatus===`scaned`?e.weixinQrLoginScanned:null);return}if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p.setData(un),i.ok?(r&&f.current(!1),await d.current()):u(i.message);return}i.phase===`unknown`&&c(null)}catch(e){t||(n!==void 0&&window.clearInterval(n),u(e instanceof Error?e.message:`Request failed`),p.setData(un))}};return n=window.setInterval(()=>void i(),2e3),i(),()=>{t=!0,n!==void 0&&window.clearInterval(n)}},[m,e.weixinQrLoginScanned,r,p.setData]);let b=R(()=>mt.toDataURL(h,ln),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,C=!!(h&&m),w=!v&&!C;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.weixinQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.weixinQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(C||w)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:O(`min-h-[1.25rem] text-center text-sm`,s&&!w?`text-accent`:`text-fg-muted`),children:w?e.weixinQrLoginBusy:s??`\xA0`}),(0,$.jsxs)(`div`,{className:O(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,w&&`bg-surface-muted/40 dark:bg-surface-base`),children:[w?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,C&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,C&&h&&!v&&!x&&!S&&!w?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.weixinQrEncoding}):null,C&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.weixinQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(V,{className:`size-3 shrink-0`}),e.weixinQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:y,children:g?e.weixinQrLoginBusy:e.weixinQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function fn(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onLoginSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnLoginSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==a||t[12]!==r||t[13]!==n?(v=n?(0,$.jsx)(dn,{ch:i,onLoginSuccess:a,onOpenChange:r,closeOnLoginSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=a,t[12]=r,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.weixinQrModalCloseAria||t[16]!==i.weixinQrModalSubtitle||t[17]!==i.weixinQrModalTitle||t[18]!==i.weixinSubtitle||t[19]!==i.weixinTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.weixinTitle,description:i.weixinSubtitle,srTitle:i.weixinQrModalTitle,srDescription:i.weixinQrModalSubtitle,closeAriaLabel:i.weixinQrModalCloseAria,wide:!0,footer:_,children:v}),t[15]=i.weixinQrModalCloseAria,t[16]=i.weixinQrModalSubtitle,t[17]=i.weixinQrModalTitle,t[18]=i.weixinSubtitle,t[19]=i.weixinTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function pn(e){let t=(0,Q.c)(108),{wx:n,updateWeixin:r,ch:i,streamOpts:a,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}=e,h;t[0]===i.weixinAllowFrom?h=t[1]:(h=(0,$.jsx)(Y,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=O(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=g):g=t[2];let _;t[3]===n.allowFrom?_=t[4]:(_=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=_);let v;t[5]===r?v=t[6]:(v=e=>r({allowFrom:e.target.value.split(/[,\n]/).flatMap(mn)}),t[5]=r,t[6]=v);let y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`textarea`,{className:g,rows:2,placeholder:`wxid_..., openid_...`,value:_,onChange:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===i.weixinAllowFromDesc?b=t[11]:(b=(0,$.jsx)(ce,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=b);let x;t[12]!==h||t[13]!==y||t[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y,b]}),t[12]=h,t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===r?S=t[17]:(S=e=>r({streamMode:e}),t[16]=r,t[17]=S);let C;t[18]!==i.streamMode||t[19]!==a||t[20]!==S||t[21]!==n.streamMode?(C=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:S,options:a}),t[18]=i.streamMode,t[19]=a,t[20]=S,t[21]=n.streamMode,t[22]=C):C=t[22];let w;t[23]===i.historyLimit?w=t[24]:(w=(0,$.jsx)(Y,{children:i.historyLimit}),t[23]=i.historyLimit,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[26]=r,t[27]=E);let D;t[28]!==E||t[29]!==n.historyLimit?(D=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:T,value:n.historyLimit,onChange:E}),t[28]=E,t[29]=n.historyLimit,t[30]=D):D=t[30];let k;t[31]!==w||t[32]!==D?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,D]}),t[31]=w,t[32]=D,t[33]=k):k=t[33];let A;t[34]===i.textChunkLimit?A=t[35]:(A=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[34]=i.textChunkLimit,t[35]=A);let j;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(j=J(),t[36]=j):j=t[36];let M;t[37]===r?M=t[38]:(M=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[37]=r,t[38]=M);let N;t[39]!==M||t[40]!==n.textChunkLimit?(N=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:j,value:n.textChunkLimit,onChange:M}),t[39]=M,t[40]=n.textChunkLimit,t[41]=N):N=t[41];let P;t[42]!==A||t[43]!==N?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,N]}),t[42]=A,t[43]=N,t[44]=P):P=t[44];let F;t[45]!==k||t[46]!==P?(F=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[k,P]}),t[45]=k,t[46]=P,t[47]=F):F=t[47];let I;t[48]===i.weixinRouteTag?I=t[49]:(I=(0,$.jsx)(Y,{children:i.weixinRouteTag}),t[48]=i.weixinRouteTag,t[49]=I);let L;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(L=J(),t[50]=L):L=t[50];let ee;t[51]===r?ee=t[52]:(ee=e=>r({routeTag:e.target.value}),t[51]=r,t[52]=ee);let R;t[53]!==i.routeTagPlaceholder||t[54]!==ee||t[55]!==n.routeTag?(R=(0,$.jsx)(`input`,{className:L,value:n.routeTag,onChange:ee,placeholder:i.routeTagPlaceholder}),t[53]=i.routeTagPlaceholder,t[54]=ee,t[55]=n.routeTag,t[56]=R):R=t[56];let te;t[57]===i.weixinRouteTagDesc?te=t[58]:(te=(0,$.jsx)(ce,{children:i.weixinRouteTagDesc}),t[57]=i.weixinRouteTagDesc,t[58]=te);let z;t[59]!==I||t[60]!==R||t[61]!==te?(z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[I,R,te]}),t[59]=I,t[60]=R,t[61]=te,t[62]=z):z=t[62];let ne;t[63]===r?ne=t[64]:(ne=e=>r({debug:e.target.checked}),t[63]=r,t[64]=ne);let re;t[65]!==ne||t[66]!==n.debug?(re=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:ne}),t[65]=ne,t[66]=n.debug,t[67]=re):re=t[67];let B;t[68]!==i.weixinDebug||t[69]!==re?(B=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[re,i.weixinDebug]}),t[68]=i.weixinDebug,t[69]=re,t[70]=B):B=t[70];let V;t[71]===i.weixinDebugDesc?V=t[72]:(V=(0,$.jsx)(ce,{children:i.weixinDebugDesc}),t[71]=i.weixinDebugDesc,t[72]=V);let H;t[73]===i.weixinAccountsJson?H=t[74]:(H=(0,$.jsx)(Y,{children:i.weixinAccountsJson}),t[73]=i.weixinAccountsJson,t[74]=H);let U;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(U=O(J(),`min-h-[140px] resize-y font-mono text-xs`),t[75]=U):U=t[75];let W;t[76]===s?W=t[77]:(W=e=>s(e.target.value),t[76]=s,t[77]=W);let G;t[78]!==l||t[79]!==W||t[80]!==o?(G=(0,$.jsx)(`textarea`,{className:U,spellCheck:!1,value:o,onChange:W,onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[78]=l,t[79]=W,t[80]=o,t[81]=G):G=t[81];let ie;t[82]!==i.weixinAccountsJsonDesc||t[83]!==c?(ie=c?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,$.jsx)(ce,{children:i.weixinAccountsJsonDesc}),t[82]=i.weixinAccountsJsonDesc,t[83]=c,t[84]=ie):ie=t[84];let K;t[85]!==H||t[86]!==G||t[87]!==ie?(K=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[H,G,ie]}),t[85]=H,t[86]=G,t[87]=ie,t[88]=K):K=t[88];let ae;t[89]===n?ae=t[90]:(ae=Ee(n),t[89]=n,t[90]=ae);let q;t[91]!==f||t[92]!==i||t[93]!==u||t[94]!==d||t[95]!==p||t[96]!==m||t[97]!==ae?(q=(0,$.jsx)(Ue,{accountIds:ae,routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:i}),t[91]=f,t[92]=i,t[93]=u,t[94]=d,t[95]=p,t[96]=m,t[97]=ae,t[98]=q):q=t[98];let oe;return t[99]!==F||t[100]!==z||t[101]!==B||t[102]!==V||t[103]!==K||t[104]!==q||t[105]!==x||t[106]!==C?(oe=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[x,C,F,z,B,V,K,q]}),t[99]=F,t[100]=z,t[101]=B,t[102]=V,t[103]=K,t[104]=q,t[105]=x,t[106]=C,t[107]=oe):oe=t[107],oe}function mn(e){let t=e.trim();return t?[t]:[]}function hn(e){let t=(0,Q.c)(60),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,form:d,chatAgents:f,onAgentRouteChange:p,saving:m,language:h,dialogOpen:g,pairingFocus:_}=e,v=_===void 0?!1:_,y;t[0]===r?y=t[1]:(y=Ee(r),t[0]=r,t[1]=y);let b=y,x;t[2]===b?x=t[3]:(x=b.length>0?b:[`default`],t[2]=b,t[3]=x);let S=x,C=(0,Z.useRef)(null),w,T;t[4]===v?(w=t[5],T=t[6]):(w=()=>{if(!v)return;let e=C.current;e&&(e.open=!0);let t=window.setTimeout(gn,80);return()=>window.clearTimeout(t)},T=[v],t[4]=v,t[5]=w,t[6]=T),(0,Z.useEffect)(w,T);let E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[7]=E):E=t[7];let D;t[8]===n.advancedShow?D=t[9]:(D=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[E,n.advancedShow]})}),t[8]=n.advancedShow,t[9]=D);let O;t[10]===n.weixinAdvancedHint?O=t[11]:(O=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[10]=n.weixinAdvancedHint,t[11]=O);let k;t[12]===i?k=t[13]:(k=e=>i({enabled:e.target.checked}),t[12]=i,t[13]=k);let A;t[14]!==k||t[15]!==r.enabled?(A=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:k}),t[14]=k,t[15]=r.enabled,t[16]=A):A=t[16];let j;t[17]===n.enableWeixinAria?j=t[18]:(j=(0,$.jsx)(`span`,{children:n.enableWeixinAria}),t[17]=n.enableWeixinAria,t[18]=j);let M;t[19]!==A||t[20]!==j?(M=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[A,j]}),t[19]=A,t[20]=j,t[21]=M):M=t[21];let N;t[22]===i?N=t[23]:(N=e=>i({dmPolicy:e}),t[22]=i,t[23]=N);let P;t[24]!==n.dmPolicy||t[25]!==a||t[26]!==N||t[27]!==r.dmPolicy?(P=(0,$.jsx)(se,{label:n.dmPolicy,value:r.dmPolicy,onChange:N,options:a}),t[24]=n.dmPolicy,t[25]=a,t[26]=N,t[27]=r.dmPolicy,t[28]=P):P=t[28];let F;t[29]!==n||t[30]!==g||t[31]!==h||t[32]!==S||t[33]!==r?(F=(0,$.jsx)(lt,{channel:`weixin`,accountIds:S,channelConfig:r,active:g,ch:n,language:h}),t[29]=n,t[30]=g,t[31]=h,t[32]=S,t[33]=r,t[34]=F):F=t[34];let I;t[35]===f?.items?I=t[36]:(I=f?.items??[],t[35]=f?.items,t[36]=I);let L;t[37]!==n||t[38]!==d.channelAgentRoutes.weixin||t[39]!==d.defaultAgentId||t[40]!==p||t[41]!==u||t[42]!==m||t[43]!==c||t[44]!==o||t[45]!==I||t[46]!==i||t[47]!==r||t[48]!==s||t[49]!==l?(L=(0,$.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,$.jsx)(pn,{wx:r,updateWeixin:i,ch:n,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d.channelAgentRoutes.weixin,defaultAgentId:d.defaultAgentId,agentItems:I,onAgentRouteChange:p,routingDisabled:m})}),t[37]=n,t[38]=d.channelAgentRoutes.weixin,t[39]=d.defaultAgentId,t[40]=p,t[41]=u,t[42]=m,t[43]=c,t[44]=o,t[45]=I,t[46]=i,t[47]=r,t[48]=s,t[49]=l,t[50]=L):L=t[50];let ee;t[51]!==M||t[52]!==P||t[53]!==F||t[54]!==L||t[55]!==O?(ee=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[O,M,P,F,L]}),t[51]=M,t[52]=P,t[53]=F,t[54]=L,t[55]=O,t[56]=ee):ee=t[56];let R;return t[57]!==ee||t[58]!==D?(R=(0,$.jsxs)(`details`,{ref:C,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[D,ee]}),t[57]=ee,t[58]=D,t[59]=R):R=t[59],R}function gn(){return it(`weixin`)}function _n(){let e=D(),{channelId:t}=j(),[n]=B(),{language:r,m:i,ch:a,hasToken:o,loading:s,fetchError:c,mutate:l,form:u,baseline:d,dirty:f,saving:p,error:m,saveOk:h,weixinSuccessBanner:g,setWeixinSuccessBanner:_,feishuSetupSuccessBanner:v,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:O,setShowFeishuWebhookSecrets:A,copied:N,feishuCopied:F,feishuWebhookCopied:I,tgAccountsDraft:L,setTgAccountsDraft:ee,tgAccountsError:R,wxAccountsDraft:z,setWxAccountsDraft:ne,wxAccountsError:re,feishuAccountsDraft:H,setFeishuAccountsDraft:U,feishuAccountsError:W,chatAgents:G,updateChannelAgentRoute:ie,updateTelegram:K,updateWeixin:ae,updateFeishu:q,save:oe,discard:J,toggleChannelEnabled:Y,copyToken:se,handleFeishuQrSetupSuccess:ce,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,onTgAccountsBlur:de,onWxAccountsBlur:fe,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e}=cn(),[ve,ye]=(0,Z.useState)(!1),{entries:be}=Nt(o,a),xe=(0,Z.useMemo)(()=>new Map(be.map(e=>[e.id,e])),[be]),X=P(t),Se=n.get(`pairing`)===`1`,Ce=!!(X&&xe.has(X)),{cards:we,refreshAll:Te}=nn({hasToken:o,form:u,ch:a}),Ee=X?xe.get(X):void 0,Q=X?we.find(e=>e.id===X):void 0;(0,Z.useEffect)(()=>{!X||be.length===0||xe.has(X)||e(E,{replace:!0})},[X,xe,be.length,e]);let De=(0,Z.useCallback)((t,n)=>{e(k(t,{pairing:n?.scrollToPairing}))},[e]),Oe=(0,Z.useCallback)(()=>{e(E)},[e]),ke=(0,Z.useCallback)(e=>{e||Oe()},[Oe]),Ae=(0,Z.useCallback)(async()=>{await l(),_(a.weixinQrLoginSuccess),window.setTimeout(()=>_(null),4e3)},[a.weixinQrLoginSuccess,l,_]),je=(0,Z.useCallback)(async()=>{ye(!0);try{Te(),await l()}finally{ye(!1)}},[l,Te]);if(!o)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})]})]});if(s)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-7 w-40 animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`}),(0,$.jsx)(`div`,{className:`h-4 w-full max-w-md animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`})]}),(0,$.jsx)(Ie,{}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading})]})]});if(!u)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??c??a.loadError}),(0,$.jsx)(T,{type:`button`,variant:`secondary`,onClick:()=>void l(),children:a.retry})]})]});let Ne=u.weixin,Pe=Se&&X===`weixin`,Fe=Se&&X===`feishu`,Le=(0,$.jsx)(hn,{ch:a,wx:Ne,updateWeixin:ae,dmOpts:me,streamOpts:_e,wxAccountsDraft:z,setWxAccountsDraft:ne,wxAccountsError:re,onWxAccountsBlur:fe,form:u,chatAgents:G,onAgentRouteChange:(e,t)=>ie(`weixin`,e,t),saving:p,language:r,dialogOpen:Ce&&X===`weixin`,pairingFocus:Pe}),Re=(0,$.jsx)(ut,{ch:a,form:u,baseline:d,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:O,setShowFeishuWebhookSecrets:A,feishuCopied:F,feishuWebhookCopied:I,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,updateFeishu:q,updateChannelAgentRoute:ie,feishuAccountsDraft:H,setFeishuAccountsDraft:U,feishuAccountsError:W,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,chatAgents:G,saving:p,language:r,dialogOpen:Ce&&X===`feishu`,pairingFocus:Fe});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.subtitle}),(0,$.jsxs)(`a`,{href:te(r,`channels`),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[a.docsLink,(0,$.jsx)(V,{className:`size-3.5`})]})]}),m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,g?(0,$.jsx)(`p`,{className:`text-xs text-accent`,children:g}):null,v?(0,$.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:v}):null,ve?(0,$.jsx)(Ie,{count:Math.max(be.length,3)}):(0,$.jsx)(Me,{catalog:be,cards:we,ch:a,saving:p,onOpenChannel:De,onToggleChannel:(e,t)=>{M(e)&&Y(e,t)}}),X===`weixin`?(0,$.jsx)(fn,{open:Ce,onOpenChange:ke,ch:a,onLoginSuccess:Ae,moreSettings:Le,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,X===`telegram`?(0,$.jsx)(Ct,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,form:u,baseline:d,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,copied:N,copyToken:se,updateTelegram:K,updateChannelAgentRoute:ie,tgAccountsDraft:L,setTgAccountsDraft:ee,tgAccountsError:R,onTgAccountsBlur:de,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e,chatAgents:G,saving:p,dirty:f,save:oe,discard:J,language:r,scrollToPairingOnOpen:Se,closeOnSave:!1}):null,X===`feishu`?(0,$.jsx)(yt,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,onSetupSuccess:ce,moreSettings:Re,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,Ee&&Q&&!Ee.manageable?(0,$.jsx)(Ve,{open:Ce,onOpenChange:e=>{e||Oe()},entry:Ee,vm:Q,ch:a,language:r}):null]})]})}function vn(e){let t=(0,Q.c)(11),{hasToken:n,ch:r,refreshing:i,saveOk:a,onRefresh:o}=e,s=U(bn),c=U(yn),l;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==a?(l=(0,$.jsx)(He,{ch:r,refreshing:i,saveOk:a,onRefresh:o}),t[0]=r,t[1]=o,t[2]=i,t[3]=a,t[4]=l):l=t[4];let u=l,d,f;return t[5]!==u||t[6]!==c||t[7]!==n||t[8]!==s?(d=()=>n?(s({startExtra:null,main:null,end:u}),()=>c()):(c(),()=>c()),f=[u,c,n,s],t[5]=u,t[6]=c,t[7]=n,t[8]=s,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useLayoutEffect)(d,f),null}function yn(e){return e.clearPageHeader}function bn(e){return e.setPageHeader}export{_n as ChannelsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a}from"./url-fxyYANfA.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{n as s,t as c}from"./eye-DAfL1U7M.js";import{a as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-BTWC-BTN.js";import{i as g}from"./theme-store-C0Ehmdo5.js";import{a as _}from"./fetch-Dqa9iTWl.js";import{A as v,Aa as y,Ar as b,Bi as x,Bn as S,Ci as C,Cr as w,Da as T,Dr as E,F as D,Fr as O,Ha as k,I as A,Ii as j,Ir as M,Jr as N,Kn as P,N as F,Nr as I,P as L,Rr as R,Ti as z,Vn as B,Wa as V,Wi as H,Xi as U,a as W,bi as G,di as K,ea as q,er as J,fn as Y,fr as X,ga as ee,h as te,ja as ne,jr as re,ka as ie,la as ae,ni as oe,pi as se,pn as ce,qn as le,st as ue,ur as de}from"./index-BYcGfwcE.js";import{a as fe,c as pe,d as me,i as he,l as ge,n as _e,o as ve,s as ye,t as be,u as xe}from"./cron-dreaming-jobs-Ip703-qM.js";import{a as Se,c as Ce,d as we,f as Te,i as Ee,l as De,m as Oe,n as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe,u as Fe}from"./cron-api-CyqbgfHM.js";import{s as Ie,t as Le}from"./heartbeat-config-api-DusckjUX.js";import{m as Re,p as ze,t as Be}from"./workflow-page.utils-DnG8JBhV.js";import{a as Ve,i as He,n as Ue,r as We,t as Ge}from"./dist-BpAiK86n.js";var Z=e(t(),1),Q=n(),$=r();function Ke(e){let t=(0,Q.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:o,onConfirm:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=c):c=t[0];let p=i===`delete`?a.delete:a.runNow,h;t[1]===p?h=t[2]:(h=(0,$.jsx)(m,{className:`text-base font-semibold text-fg`,children:p}),t[1]=p,t[2]=h);let g=i===`delete`?a.confirmDelete:a.confirmRun,_;t[3]===g?_=t[4]:(_=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g}),t[3]=g,t[4]=_);let v;t[5]!==a.cancel||t[6]!==o?(v=(0,$.jsx)(O,{type:`button`,variant:`secondary`,onClick:o,children:a.cancel}),t[5]=a.cancel,t[6]=o,t[7]=v):v=t[7];let y=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,b;t[8]===s?b=t[9]:(b=()=>void s(),t[8]=s,t[9]=b);let x=i===`delete`?a.delete:a.runNow,S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,$.jsx)(O,{type:`button`,variant:`primary`,className:y,onClick:b,children:x}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==S||t[15]!==v?(C=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[v,S]}),t[14]=S,t[15]=v,t[16]=C):C=t[16];let w;t[17]!==C||t[18]!==h||t[19]!==_?(w=(0,$.jsxs)(l,{children:[c,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(d,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[h,_,C]})})]}),t[17]=C,t[18]=h,t[19]=_,t[20]=w):w=t[20];let T;return t[21]!==r||t[22]!==n||t[23]!==w?(T=(0,$.jsx)(f,{open:n,onOpenChange:r,children:w}),t[21]=r,t[22]=n,t[23]=w,t[24]=T):T=t[24],T}var qe=`*/5 * * * *`,Je=2100*1e3;function Ye(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Xe(e){let t=Ye(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function Ze(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function Qe(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function $e(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function et(e){return M(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,b,e&&`cursor-not-allowed opacity-60`)}function tt(){return M(I,re)}var nt=M(I,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),rt=M(I,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function it(e){switch(e){case`success`:return`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`;case`failed`:return`bg-red-500/15 text-red-800 dark:text-red-300`;case`running`:return`bg-accent/15 text-accent`;case`cancelled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function at(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function ot(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function st(e){let t=(0,Q.c)(56),{row:n,expanded:r,onToggle:i,c:a,statusLabels:o}=e,s=n.error||n.summary||n.output||``,c;t[0]===s?c=t[1]:(c=s.trim(),t[0]=s,t[1]=c);let l=c,u=l.length>0,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover`,children:(0,$.jsx)(ee,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0})}),t[2]=d):d=t[2];let f=n.startedAt,p;t[3]===n.startedAt?p=t[4]:(p=xe(n.startedAt),t[3]=n.startedAt,t[4]=p);let m;t[5]!==n.startedAt||t[6]!==p?(m=(0,$.jsx)(`time`,{className:`text-sm font-medium text-fg`,dateTime:f,children:p}),t[5]=n.startedAt,t[6]=p,t[7]=m):m=t[7];let h;t[8]===n.status?h=t[9]:(h=M(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,it(n.status)),t[8]=n.status,t[9]=h);let g;t[10]!==n.status||t[11]!==o?(g=he(n.status,o),t[10]=n.status,t[11]=o,t[12]=g):g=t[12];let _;t[13]!==h||t[14]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===n.duration?v=t[17]:(v=ve(n.duration),t[16]=n.duration,t[17]=v);let y;t[18]===v?y=t[19]:(y=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v}),t[18]=v,t[19]=y);let b;t[20]!==y||t[21]!==m||t[22]!==_?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,_,y]}),t[20]=y,t[21]=m,t[22]=_,t[23]=b):b=t[23];let x;t[24]!==l||t[25]!==r||t[26]!==u?(x=!r&&u?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:l}):null,t[24]=l,t[25]=r,t[26]=u,t[27]=x):x=t[27];let S;t[28]!==l||t[29]!==r||t[30]!==u?(S=r&&u?(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-edge-subtle bg-surface-panel/80 p-2.5 font-mono text-xs leading-relaxed text-fg-muted`,children:l}):null,t[28]=l,t[29]=r,t[30]=u,t[31]=S):S=t[31];let C;t[32]!==b||t[33]!==x||t[34]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[d,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,S]})]}),t[32]=b,t[33]=x,t[34]=S,t[35]=C):C=t[35];let w;t[36]!==a||t[37]!==r||t[38]!==u||t[39]!==i?(w=u?(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:i,children:[(0,$.jsx)(ie,{className:M(`size-3.5 transition-transform`,r&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),r?a.detailCollapseRun:a.detailExpandRun]}):null,t[36]=a,t[37]=r,t[38]=u,t[39]=i,t[40]=w):w=t[40];let T;t[41]!==a||t[42]!==n.workflowRunId?(T=n.workflowRunId?.trim()?(0,$.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openWorkflowTitle,onClick:()=>$e(n.workflowRunId),children:[(0,$.jsx)(q,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openWorkflow]}):null,t[41]=a,t[42]=n.workflowRunId,t[43]=T):T=t[43];let E;t[44]!==a||t[45]!==n.sessionKey?(E=n.sessionKey?.trim()?(0,$.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openChatTitle,onClick:()=>Qe(n.sessionKey),children:[(0,$.jsx)(j,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openChat]}):null,t[44]=a,t[45]=n.sessionKey,t[46]=E):E=t[46];let D;t[47]!==T||t[48]!==E?(D=(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[T,E]}),t[47]=T,t[48]=E,t[49]=D):D=t[49];let k;t[50]!==w||t[51]!==D?(k=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle px-3 py-2 dark:border-edge-subtle`,children:[w,D]}),t[50]=w,t[51]=D,t[52]=k):k=t[52];let A;return t[53]!==C||t[54]!==k?(A=(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[C,k]}),t[53]=C,t[54]=k,t[55]=A):A=t[55],A}function ct(e){let t=(0,Q.c)(13),{icon:n,label:r,value:i,valueClassName:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]!==r||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[o,r]}),t[2]=r,t[3]=o,t[4]=s):s=t[4];let c;t[5]===a?c=t[6]:(c=M(`mt-1 truncate text-sm font-medium text-fg`,a),t[5]=a,t[6]=c);let l;t[7]!==c||t[8]!==i?(l=(0,$.jsx)(`p`,{className:c,children:i}),t[7]=c,t[8]=i,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-2.5 dark:border-edge-subtle`,children:[s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12],u}function lt({open:e,onDismiss:t,detailJob:n,detailLoading:r,detailHistory:i,c:a,localeTag:o,scheduleBadgeLabels:c,chatWorkingDirNotSet:p,statusLabels:g,onEdit:_,onRunNow:v,onToggle:b,onDelete:S}){let[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),j=(0,Z.useMemo)(()=>{let e=0,t=0;for(let n of i)n.status===`success`&&(e+=1),n.status===`failed`&&(t+=1);return{success:e,failed:t}},[i]),P=i[0]??null;(0,Z.useEffect)(()=>{if(!e){T(!1),D(null),A(!1);return}D(ot(i))},[e,n?.id,i]);let F=(0,Z.useCallback)(async()=>{n?.schedule&&await w(n.schedule)&&(A(!0),window.setTimeout(()=>A(!1),1500))},[n?.schedule]),I=n?ge(n,o,c):`—`;return(0,$.jsx)(f,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(l,{children:[(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(d,{className:M(`xopc-dialog-content-pane pointer-events-auto relative flex w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,`max-h-[min(85vh,44rem)]`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(m,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||n?.id||`—`}),n?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:I}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n.enabled,"aria-label":n.enabled?a.enabled:a.disabled,className:M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:()=>b(n,!n.enabled),children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,(0,$.jsx)(h,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:(0,$.jsx)(R,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(x,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.scheduleLabel}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-sm font-medium leading-relaxed text-fg`,children:I}),(0,$.jsx)(O,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:a.detailCopySchedule,"aria-label":a.detailCopySchedule,onClick:()=>void F(),children:k?(0,$.jsx)(y,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75}):(0,$.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-subtle`,children:[a.detailCronTechnical,`: `]}),(0,$.jsx)(`code`,{className:`font-mono`,children:n.schedule})]})]})]}),(0,$.jsxs)(`section`,{"aria-label":a.statsRegion,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(ct,{icon:ne,label:a.nextRun,value:n.next_run?ye(n.next_run,a.timeLabels):`—`}),(0,$.jsx)(ct,{icon:ee,label:a.detailLastRun,value:P?he(P.status,g):a.detailNoRecentRuns,valueClassName:P?.status===`failed`?`text-red-700 dark:text-red-300`:P?.status===`success`?`text-emerald-800 dark:text-emerald-300`:void 0})]}),i.length>0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:a.detailRunCount.replace(`{{success}}`,String(j.success)).replace(`{{failed}}`,String(j.failed))}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailWhatItDoes}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 p-3 dark:border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`mb-2 inline-flex rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:at(n,a)}),(0,$.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,$.jsx)(Y,{content:ke(n),compact:!0,className:`text-sm`})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/35`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left`,"aria-expanded":C,onClick:()=>T(e=>!e),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunSettings})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.detailRunSettingsHint})]}),(0,$.jsx)(ie,{className:M(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,C&&`rotate-180`),"aria-hidden":!0})]}),C?(0,$.jsxs)(`dl`,{className:`grid gap-3 border-t border-edge px-4 py-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.sessionTarget===`isolated`?a.modeAgentOption:a.modeDirectOption})]}),n.sessionTarget===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.agentId?.trim()?n.agentId.trim():a.agentProfileDefault})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:n.workingDirectory?.trim()?n.workingDirectory.trim():p})]})]}):null,n.delivery?.channel===`local`||n.sessionTarget===`isolated`&&!n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.delivery?.channel===`local`?a.deliveryTargetLocalChannel:a.deliveryLocalOnly})]}):n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,$.jsx)(`code`,{className:`text-xs`,children:n.delivery?.channel??``}),` → `,fe(n,a.channelLocal)]})]}):null,n.model?.trim()?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.model.trim()})]}):null]}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunHistory}),i.length>0?(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.length}):null]}),i.length===0?(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-dashed border-edge-subtle px-4 py-8 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(ee,{className:`mx-auto size-8 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:a.noRunsYet})]}):(0,$.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(st,{row:e,expanded:E===e.id,onToggle:()=>D(t=>t===e.id?null:e.id),c:a,statusLabels:g})},e.id))})]})]}):null}),n&&!r?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(O,{type:`button`,className:`gap-1.5`,onClick:()=>v(n),children:[(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.runNow]}),(0,$.jsx)(O,{type:`button`,variant:`secondary`,onClick:()=>_(n),children:a.edit}),(0,$.jsxs)(O,{type:`button`,variant:`secondary`,className:`ml-auto text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:()=>S(n),children:[(0,$.jsx)(N,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.delete]})]})}):null]})})]})})}function ut(e){let t=(0,Q.c)(31),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,title:s,maxWidthClass:c,clearLabel:l,onClear:u}=e,d;t[0]!==r||t[1]!==n?(d={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=d):d=t[2];let f=L(d),p;t[3]===n?p=t[4]:(p=n.trim(),t[3]=n,t[4]=p);let m=p,h=s??(m?`${m}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),g=i||f.picking,_=o??a.notSet,y;t[5]!==c||t[6]!==f.pick||t[7]!==h||t[8]!==g||t[9]!==_||t[10]!==n?(y=(0,$.jsx)(D,{value:n,onPick:f.pick,disabled:g,placeholder:_,title:h,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=h,t[8]=g,t[9]=_,t[10]=n,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==m?(b=l&&m&&u?(0,$.jsx)(`button`,{type:`button`,disabled:i||f.picking,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:u,children:l}):null,t[12]=l,t[13]=i,t[14]=u,t[15]=f.picking,t[16]=m,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y,b]}),t[18]=y,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==m||t[26]!==a?(S=f.hasNativePicker?null:(0,$.jsx)(v,{open:f.modalOpen,onOpenChange:f.setModalOpen,initialAbsolutePath:m||void 0,onConfirm:f.confirmPick,wd:a}),t[21]=f.confirmPick,t[22]=f.hasNativePicker,t[23]=f.modalOpen,t[24]=f.setModalOpen,t[25]=m,t[26]=a,t[27]=S):S=t[27];let C;return t[28]!==x||t[29]!==S?(C=(0,$.jsxs)($.Fragment,{children:[x,S]}),t[28]=x,t[29]=S,t[30]=C):C=t[30],C}function dt(e,t){return e[t]??t}function ft(e,t){let n=W[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function pt(e,t){return(W[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function mt(e){let t=(0,Q.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function ht(e){let t=(0,Q.c)(33),{workflowName:n,language:r,argValues:i,onArgValuesChange:o,goal:s,onGoalChange:c,examplePrompts:l,showGoal:u,inputClassName:d}=e,f;t[0]===l?f=t[1]:(f=l===void 0?[]:l,t[0]=l,t[1]=f);let p=f,m=u===void 0?!0:u,h,g,_,v,y,b,x;if(t[2]!==i||t[3]!==p||t[4]!==s||t[5]!==d||t[6]!==r||t[7]!==o||t[8]!==c||t[9]!==m||t[10]!==n){_=a(r).workflows;let e=W[n]??[];g=e.length>0;let l=M(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,d),u;t[18]!==i||t[19]!==o||t[20]!==c?(u=e=>{ze(e,c,e=>{o(e(i))})},t[18]=i,t[19]=o,t[20]=c,t[21]=u):u=t[21],h=u,v=`flex flex-col gap-3`,y=e.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[dt(_.args,e.labelKey),e.required?` *`:``]}),e.multiline?(0,$.jsx)(`textarea`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:dt(_.args,e.placeholderKey),className:M(l,`min-h-20 resize-y`)}):(0,$.jsx)(`input`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:dt(_.args,e.placeholderKey),className:l})]},e.key)),b=g&&p.length>0?(0,$.jsx)(mt,{examples:p,labels:_,onSelect:h}):null,x=m?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:_.goalLabel}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:_.goalPlaceholder,className:M(l,`min-h-20 resize-y`)})]}):null,t[2]=i,t[3]=p,t[4]=s,t[5]=d,t[6]=r,t[7]=o,t[8]=c,t[9]=m,t[10]=n,t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17];let S;t[22]!==h||t[23]!==p||t[24]!==g||t[25]!==_?(S=!g&&p.length>0?(0,$.jsx)(mt,{examples:p,labels:_,onSelect:h}):null,t[22]=h,t[23]=p,t[24]=g,t[25]=_,t[26]=S):S=t[26];let C;return t[27]!==v||t[28]!==y||t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b,x,S]}),t[27]=v,t[28]=y,t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32],C}function gt(e){let t=(0,Q.c)(190),{open:n,onRequestClose:r,c:a,chatM:o,agentsMessages:s,isDark:p,channels:g,sessionChatIds:_,cronAgentSelectOptions:v,defaultModelResolver:y,formMode:b,formJobId:x,formName:S,onFormNameChange:C,formSchedule:w,onFormScheduleChange:T,formSubmitting:E,formTaskKind:D,onFormTaskKindChange:k,workflowDefinitions:j,workflowDefinitionsLoading:N,formWorkflowDefinitionId:P,onFormWorkflowDefinitionIdChange:F,formWorkflowGoal:I,onFormWorkflowGoalChange:L,formWorkflowArgValues:z,onFormWorkflowArgValuesChange:B,formSessionTarget:V,onFormSessionTargetChange:H,formAgentLocalOnly:U,onFormAgentLocalOnlyChange:W,formModel:K,onFormModelUserChange:q,formAgentId:J,onFormAgentIdChange:X,formWorkingDirectory:ee,onFormWorkingDirectoryChange:te,formChannel:ne,onFormChannelChange:re,formChatId:ie,onFormChatIdChange:ae,formMessage:se,onFormMessageChange:le,formMessageMdMode:de,onSetMessageMdMode:fe,messageEditorNonce:me,needsDeliveryChat:he,showChannelPicker:ge,canSubmit:_e,onSubmit:ve,onRefreshRecipients:ye}=e,be=i(bt),xe,Se;if(t[0]!==P||t[1]!==be||t[2]!==j){let e;t[5]===P?e=t[6]:(e=e=>e.id===P.trim(),t[5]=P,t[6]=e),xe=j.find(e),Se=xe?Re(xe,be):null,t[0]=P,t[1]=be,t[2]=j,t[3]=xe,t[4]=Se}else xe=t[3],Se=t[4];let Ce=Se,we;t[7]===r?we=t[8]:(we=e=>!e&&r(),t[7]=r,t[8]=we);let Te;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=Te):Te=t[9];let Ee=b===`edit`?a.editJob:a.addJob,De;t[10]===Ee?De=t[11]:(De=(0,$.jsx)(m,{className:`text-base font-semibold text-fg`,children:Ee}),t[10]=Ee,t[11]=De);let Oe;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(R,{className:`size-5`,strokeWidth:1.75}),t[12]=Oe):Oe=t[12];let ke;t[13]===a.close?ke=t[14]:(ke=(0,$.jsx)(h,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:Oe})}),t[13]=a.close,t[14]=ke);let Ae;t[15]!==De||t[16]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[De,ke]}),t[15]=De,t[16]=ke,t[17]=Ae):Ae=t[17];let je;t[18]===a.name?je=t[19]:(je=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.name}),t[18]=a.name,t[19]=je);let Me;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Me=et(),t[20]=Me):Me=t[20];let Ne;t[21]===C?Ne=t[22]:(Ne=e=>C(e.target.value),t[21]=C,t[22]=Ne);let Pe;t[23]!==a.namePlaceholder||t[24]!==S||t[25]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`text`,className:Me,value:S,onChange:Ne,placeholder:a.namePlaceholder}),t[23]=a.namePlaceholder,t[24]=S,t[25]=Ne,t[26]=Pe):Pe=t[26];let Fe;t[27]!==Pe||t[28]!==je?(Fe=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[je,Pe]}),t[27]=Pe,t[28]=je,t[29]=Fe):Fe=t[29];let Le;t[30]!==a.schedulePicker||t[31]!==w||t[32]!==E||t[33]!==T?(Le=(0,$.jsx)(Ie,{value:w,onChange:T,disabled:E,labels:a.schedulePicker}),t[30]=a.schedulePicker,t[31]=w,t[32]=E,t[33]=T,t[34]=Le):Le=t[34];let ze;t[35]===a.taskKind?ze=t[36]:(ze=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.taskKind}),t[35]=a.taskKind,t[36]=ze);let Be;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Be=tt(),t[37]=Be):Be=t[37];let Ve;t[38]===k?Ve=t[39]:(Ve=e=>k(e.target.value),t[38]=k,t[39]=Ve);let He;t[40]===a.taskKindMessage?He=t[41]:(He=(0,$.jsx)(`option`,{value:`message`,children:a.taskKindMessage}),t[40]=a.taskKindMessage,t[41]=He);let Ue;t[42]===a.taskKindWorkflowRun?Ue=t[43]:(Ue=(0,$.jsx)(`option`,{value:`workflowRun`,children:a.taskKindWorkflowRun}),t[42]=a.taskKindWorkflowRun,t[43]=Ue);let We;t[44]!==E||t[45]!==D||t[46]!==Ve||t[47]!==He||t[48]!==Ue?(We=(0,$.jsxs)(`select`,{className:Be,value:D,disabled:E,onChange:Ve,children:[He,Ue]}),t[44]=E,t[45]=D,t[46]=Ve,t[47]=He,t[48]=Ue,t[49]=We):We=t[49];let Ge;t[50]!==ze||t[51]!==We?(Ge=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[ze,We]}),t[50]=ze,t[51]=We,t[52]=Ge):Ge=t[52];let Z;t[53]!==s||t[54]!==a.agentProfile||t[55]!==a.agentProfileDefault||t[56]!==a.agentProfileHint||t[57]!==a.channel||t[58]!==a.channelLocal||t[59]!==a.lastActiveLabels||t[60]!==a.noRecentChatsOption||t[61]!==a.recipient||t[62]!==a.recipientPlaceholder||t[63]!==a.refreshList||t[64]!==a.refreshRecipientHint||t[65]!==a.selectRecipient||t[66]!==a.workflowDefinition||t[67]!==a.workflowDefinitionCustom||t[68]!==a.workflowDefinitionMissing||t[69]!==a.workflowDefinitionPlaceholder||t[70]!==a.workflowDefinitionsEmpty||t[71]!==a.workflowDefinitionsLoading||t[72]!==a.workflowDeliveryHint||t[73]!==a.workflowLocalOnly||t[74]!==a.workflowLocalOnlyHint||t[75]!==g||t[76]!==v||t[77]!==J||t[78]!==U||t[79]!==ne||t[80]!==ie||t[81]!==E||t[82]!==D||t[83]!==z||t[84]!==P||t[85]!==I||t[86]!==be||t[87]!==he||t[88]!==X||t[89]!==W||t[90]!==re||t[91]!==ae||t[92]!==B||t[93]!==F||t[94]!==L||t[95]!==ye||t[96]!==xe||t[97]!==Ce||t[98]!==_||t[99]!==ge||t[100]!==j||t[101]!==N?(Z=D===`workflowRun`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workflowDefinition}),(0,$.jsxs)(`select`,{className:tt(),value:P,disabled:E||N,onChange:e=>F(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:N?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),P.trim()&&!j.some(e=>e.id===P.trim())?(0,$.jsx)(`option`,{value:P,children:P}):null,j.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!N&&j.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Ce?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Ce.description}):P.trim()&&!xe?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),P.trim()?(0,$.jsx)(ht,{workflowName:P.trim(),language:be,argValues:z,onArgValuesChange:B,goal:I,onGoalChange:L,examplePrompts:Ce?.examplePrompts??[],inputClassName:et()}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:tt(),value:J,disabled:E,onChange:e=>X(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),v.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${ue(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:M(`ui-checkbox`,`mt-0.5`),checked:U,onChange:e=>W(e.target.checked),"aria-label":a.workflowLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.workflowLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.workflowLocalOnlyHint})]})]}),ge?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:tt(),value:ne,onChange:e=>re(e.target.value),children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),g.map(vt)]})]}),he?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ye(),children:[(0,$.jsx)(G,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:M(et(),`min-w-0 w-full sm:flex-1`),value:ie,onChange:e=>ae(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:nt,value:ie,onChange:e=>{let t=e.target.value;t&&ae(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),_.length>0?_.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:pe(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDeliveryHint})]}):null]}):null]}):null,t[53]=s,t[54]=a.agentProfile,t[55]=a.agentProfileDefault,t[56]=a.agentProfileHint,t[57]=a.channel,t[58]=a.channelLocal,t[59]=a.lastActiveLabels,t[60]=a.noRecentChatsOption,t[61]=a.recipient,t[62]=a.recipientPlaceholder,t[63]=a.refreshList,t[64]=a.refreshRecipientHint,t[65]=a.selectRecipient,t[66]=a.workflowDefinition,t[67]=a.workflowDefinitionCustom,t[68]=a.workflowDefinitionMissing,t[69]=a.workflowDefinitionPlaceholder,t[70]=a.workflowDefinitionsEmpty,t[71]=a.workflowDefinitionsLoading,t[72]=a.workflowDeliveryHint,t[73]=a.workflowLocalOnly,t[74]=a.workflowLocalOnlyHint,t[75]=g,t[76]=v,t[77]=J,t[78]=U,t[79]=ne,t[80]=ie,t[81]=E,t[82]=D,t[83]=z,t[84]=P,t[85]=I,t[86]=be,t[87]=he,t[88]=X,t[89]=W,t[90]=re,t[91]=ae,t[92]=B,t[93]=F,t[94]=L,t[95]=ye,t[96]=xe,t[97]=Ce,t[98]=_,t[99]=ge,t[100]=j,t[101]=N,t[102]=Z):Z=t[102];let Ke;t[103]!==s||t[104]!==a.agentLocalOnly||t[105]!==a.agentLocalOnlyHint||t[106]!==a.agentProfile||t[107]!==a.agentProfileDefault||t[108]!==a.agentProfileHint||t[109]!==a.channel||t[110]!==a.channelLocal||t[111]!==a.enterManuallyOrSelect||t[112]!==a.lastActiveLabels||t[113]!==a.message||t[114]!==a.messageEdit||t[115]!==a.messageMarkdownHint||t[116]!==a.messagePlaceholder||t[117]!==a.messagePreview||t[118]!==a.mode||t[119]!==a.modeAgent||t[120]!==a.modeAgentOption||t[121]!==a.modeDirect||t[122]!==a.modeDirectOption||t[123]!==a.model||t[124]!==a.noRecentChats||t[125]!==a.noRecentChatsOption||t[126]!==a.recipient||t[127]!==a.recipientPlaceholder||t[128]!==a.refreshList||t[129]!==a.refreshRecipientHint||t[130]!==a.selectRecipient||t[131]!==a.workingDirectoryHint||t[132]!==a.workingDirectoryLabel||t[133]!==a.workingDirectoryReset||t[134]!==g||t[135]!==o||t[136]!==v||t[137]!==y||t[138]!==J||t[139]!==U||t[140]!==ne||t[141]!==ie||t[142]!==x||t[143]!==se||t[144]!==de||t[145]!==K||t[146]!==V||t[147]!==E||t[148]!==D||t[149]!==ee||t[150]!==p||t[151]!==me||t[152]!==he||t[153]!==X||t[154]!==W||t[155]!==re||t[156]!==ae||t[157]!==le||t[158]!==q||t[159]!==H||t[160]!==te||t[161]!==ye||t[162]!==fe||t[163]!==_||t[164]!==ge?(Ke=D===`message`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsxs)(`select`,{className:tt(),value:V,onChange:e=>{let t=e.target.value;H(t,y,K.trim())},children:[(0,$.jsx)(`option`,{value:`main`,children:a.modeDirectOption}),(0,$.jsx)(`option`,{value:`isolated`,children:a.modeAgentOption})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:V===`main`?a.modeDirect:a.modeAgent})]}),V===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(A,{value:K,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:q})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:tt(),value:J,disabled:E,onChange:e=>X(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),v.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${ue(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(ut,{value:ee,onChange:te,disabled:E,wd:o.workingDirectory,placeholder:o.workingDirectory.notSet,maxWidthClass:`max-w-[min(16rem,48vw)]`,clearLabel:a.workingDirectoryReset,onClear:()=>te(``)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workingDirectoryHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:M(`ui-checkbox`,`mt-0.5`),checked:U,onChange:e=>W(e.target.checked),"aria-label":a.agentLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.agentLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.agentLocalOnlyHint})]})]})]}):null,ge?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:tt(),value:ne,onChange:e=>{let t=e.target.value;re(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),g.map(_t)]})]}),he?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ye(),children:[(0,$.jsx)(G,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:M(et(),`min-w-0 w-full sm:flex-1`),value:ie,onChange:e=>ae(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:nt,value:ie,onChange:e=>{let t=e.target.value;t&&ae(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),_.length>0?_.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:pe(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_.length>0?a.enterManuallyOrSelect:a.noRecentChats})]}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.message}),(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,$.jsxs)(`button`,{type:`button`,className:M(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,de===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>fe(`edit`),children:[(0,$.jsx)(oe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messageEdit]}),(0,$.jsxs)(`button`,{type:`button`,className:M(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,de===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>fe(`preview`),children:[(0,$.jsx)(c,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messagePreview]})]})]}),(0,$.jsx)(`div`,{className:M(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,E&&`pointer-events-none opacity-60`),children:de===`edit`?(0,$.jsx)(ce,{initialContent:se,onChange:le,isDark:p,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${x??`new`}-${me}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:se.trim()?(0,$.jsx)(Y,{content:se,compact:!0,className:`text-sm`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.messagePlaceholder})})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.messageMarkdownHint})]})]}):null,t[103]=s,t[104]=a.agentLocalOnly,t[105]=a.agentLocalOnlyHint,t[106]=a.agentProfile,t[107]=a.agentProfileDefault,t[108]=a.agentProfileHint,t[109]=a.channel,t[110]=a.channelLocal,t[111]=a.enterManuallyOrSelect,t[112]=a.lastActiveLabels,t[113]=a.message,t[114]=a.messageEdit,t[115]=a.messageMarkdownHint,t[116]=a.messagePlaceholder,t[117]=a.messagePreview,t[118]=a.mode,t[119]=a.modeAgent,t[120]=a.modeAgentOption,t[121]=a.modeDirect,t[122]=a.modeDirectOption,t[123]=a.model,t[124]=a.noRecentChats,t[125]=a.noRecentChatsOption,t[126]=a.recipient,t[127]=a.recipientPlaceholder,t[128]=a.refreshList,t[129]=a.refreshRecipientHint,t[130]=a.selectRecipient,t[131]=a.workingDirectoryHint,t[132]=a.workingDirectoryLabel,t[133]=a.workingDirectoryReset,t[134]=g,t[135]=o,t[136]=v,t[137]=y,t[138]=J,t[139]=U,t[140]=ne,t[141]=ie,t[142]=x,t[143]=se,t[144]=de,t[145]=K,t[146]=V,t[147]=E,t[148]=D,t[149]=ee,t[150]=p,t[151]=me,t[152]=he,t[153]=X,t[154]=W,t[155]=re,t[156]=ae,t[157]=le,t[158]=q,t[159]=H,t[160]=te,t[161]=ye,t[162]=fe,t[163]=_,t[164]=ge,t[165]=Ke):Ke=t[165];let qe;t[166]!==Fe||t[167]!==Le||t[168]!==Ge||t[169]!==Z||t[170]!==Ke?(qe=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Fe,Le,Ge,Z,Ke]})}),t[166]=Fe,t[167]=Le,t[168]=Ge,t[169]=Z,t[170]=Ke,t[171]=qe):qe=t[171];let Je;t[172]!==a.cancel||t[173]!==r?(Je=(0,$.jsx)(O,{type:`button`,variant:`secondary`,onClick:r,children:a.cancel}),t[172]=a.cancel,t[173]=r,t[174]=Je):Je=t[174];let Ye=E||!_e,Xe=E?a.loading:b===`edit`?a.save:a.create,Ze;t[175]!==ve||t[176]!==Ye||t[177]!==Xe?(Ze=(0,$.jsx)(O,{type:`button`,variant:`primary`,disabled:Ye,onClick:ve,children:Xe}),t[175]=ve,t[176]=Ye,t[177]=Xe,t[178]=Ze):Ze=t[178];let Qe;t[179]!==Je||t[180]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Je,Ze]}),t[179]=Je,t[180]=Ze,t[181]=Qe):Qe=t[181];let $e;t[182]!==qe||t[183]!==Qe||t[184]!==Ae?($e=(0,$.jsxs)(l,{children:[Te,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(d,{className:`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,800px)] w-full max-w-md flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-lg lg:max-w-xl dark:border-edge`,onOpenAutoFocus:yt,children:[Ae,qe,Qe]})})]}),t[182]=qe,t[183]=Qe,t[184]=Ae,t[185]=$e):$e=t[185];let rt;return t[186]!==n||t[187]!==we||t[188]!==$e?(rt=(0,$.jsx)($.Fragment,{children:(0,$.jsx)(f,{open:n,onOpenChange:we,children:$e})}),t[186]=n,t[187]=we,t[188]=$e,t[189]=rt):rt=t[189],rt}function _t(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function vt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function yt(e){return e.preventDefault()}function bt(e){return e.language}function xt(e){let t=(0,Q.c)(66),{c:n,mainTab:r,onMainTabChange:i,jobSort:a,onJobSortChange:o,historyRange:s,onHistoryRangeChange:c,historyJobFilter:l,onHistoryJobFilterChange:u,historyStatusFilter:d,onHistoryStatusFilterChange:f,jobs:p}=e,m=n.title,h=r===`myTasks`,g=r===`myTasks`?`text-fg`:`text-fg-muted hover:text-fg`,_;t[0]===g?_=t[1]:(_=M(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,g),t[0]=g,t[1]=_);let v;t[2]===i?v=t[3]:(v=()=>i(`myTasks`),t[2]=i,t[3]=v);let y;t[4]!==n.tabMyTasks||t[5]!==h||t[6]!==_||t[7]!==v?(y=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h,className:_,onClick:v,children:n.tabMyTasks}),t[4]=n.tabMyTasks,t[5]=h,t[6]=_,t[7]=v,t[8]=y):y=t[8];let b=r===`systemTasks`,x=r===`systemTasks`?`text-fg`:`text-fg-muted hover:text-fg`,S;t[9]===x?S=t[10]:(S=M(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,x),t[9]=x,t[10]=S);let C;t[11]===i?C=t[12]:(C=()=>i(`systemTasks`),t[11]=i,t[12]=C);let w;t[13]!==n.tabSystemTasks||t[14]!==C||t[15]!==b||t[16]!==S?(w=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":b,className:S,onClick:C,children:n.tabSystemTasks}),t[13]=n.tabSystemTasks,t[14]=C,t[15]=b,t[16]=S,t[17]=w):w=t[17];let T=r===`history`,E=r===`history`?`text-fg`:`text-fg-muted hover:text-fg`,D;t[18]===E?D=t[19]:(D=M(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,E),t[18]=E,t[19]=D);let O;t[20]===i?O=t[21]:(O=()=>i(`history`),t[20]=i,t[21]=O);let k;t[22]!==n.tabRunHistory||t[23]!==T||t[24]!==D||t[25]!==O?(k=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":T,className:D,onClick:O,children:n.tabRunHistory}),t[22]=n.tabRunHistory,t[23]=T,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==n.title||t[28]!==w||t[29]!==k||t[30]!==y?(A=(0,$.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":m,children:[y,w,k]}),t[27]=n.title,t[28]=w,t[29]=k,t[30]=y,t[31]=A):A=t[31];let j=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,N;t[32]===j?N=t[33]:(N=M(`flex min-w-0 items-center gap-2`,j),t[32]=j,t[33]=N);let F;t[34]!==n.sortCreatedAsc||t[35]!==n.sortCreatedDesc||t[36]!==a||t[37]!==r||t[38]!==o?(F=r===`myTasks`||r===`systemTasks`?(0,$.jsxs)(`select`,{className:rt,value:a,onChange:e=>o(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,$.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,$.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):null,t[34]=n.sortCreatedAsc,t[35]=n.sortCreatedDesc,t[36]=a,t[37]=r,t[38]=o,t[39]=F):F=t[39];let I;t[40]!==n.execStatusCancelled||t[41]!==n.execStatusFailed||t[42]!==n.execStatusRunning||t[43]!==n.execStatusSuccess||t[44]!==n.filterAllStatuses||t[45]!==n.filterAllTasks||t[46]!==n.historyRangeDay||t[47]!==n.historyRangeMonth||t[48]!==n.historyRangeWeek||t[49]!==n.runHistoryTitle||t[50]!==l||t[51]!==s||t[52]!==d||t[53]!==p||t[54]!==r||t[55]!==u||t[56]!==c||t[57]!==f?(I=r===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:M(le,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:M(P,`px-2.5 py-1`,s===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,s===e&&`text-fg`),onClick:()=>c(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,$.jsxs)(`select`,{className:rt,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(St)]}),(0,$.jsxs)(`select`,{className:rt,value:d,onChange:e=>f(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,$.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,$.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,$.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,$.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]}):null,t[40]=n.execStatusCancelled,t[41]=n.execStatusFailed,t[42]=n.execStatusRunning,t[43]=n.execStatusSuccess,t[44]=n.filterAllStatuses,t[45]=n.filterAllTasks,t[46]=n.historyRangeDay,t[47]=n.historyRangeMonth,t[48]=n.historyRangeWeek,t[49]=n.runHistoryTitle,t[50]=l,t[51]=s,t[52]=d,t[53]=p,t[54]=r,t[55]=u,t[56]=c,t[57]=f,t[58]=I):I=t[58];let L;t[59]!==N||t[60]!==F||t[61]!==I?(L=(0,$.jsxs)(`div`,{className:N,children:[F,I]}),t[59]=N,t[60]=F,t[61]=I,t[62]=L):L=t[62];let R;return t[63]!==A||t[64]!==L?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[A,L]}),t[63]=A,t[64]=L,t[65]=R):R=t[65],R}function St(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function Ct(e){let t=(0,Q.c)(23),{c:n,loading:r,runHistoryLoading:i,onRefresh:a,onOpenTemplatePicker:o,onAddJob:s}=e,c=r||i,l=n.refresh,u=n.refresh,d;t[0]===a?d=t[1]:(d=()=>void a(),t[0]=a,t[1]=d);let f=c&&`animate-spin`,p;t[2]===f?p=t[3]:(p=M(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(G,{className:p,strokeWidth:1.75}),t[4]=p,t[5]=m);let h;t[6]!==c||t[7]!==n.refresh||t[8]!==d||t[9]!==m?(h=(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:c,title:l,"aria-label":u,onClick:d,children:m}),t[6]=c,t[7]=n.refresh,t[8]=d,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(H,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let _;t[12]!==n.fromTemplate||t[13]!==o?(_=(0,$.jsxs)(O,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:o,children:[g,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=o,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(C,{className:`size-4`,strokeWidth:1.75}),t[15]=v):v=t[15];let y;t[16]!==n.addJob||t[17]!==s?(y=(0,$.jsxs)(O,{type:`button`,variant:`primary`,className:`gap-2`,onClick:s,children:[v,n.addJob]}),t[16]=n.addJob,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==h||t[21]!==_?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[h,_,y]}),t[19]=y,t[20]=h,t[21]=_,t[22]=b):b=t[22],b}function wt(e){let t=(0,Q.c)(46),{c:n,runHistoryLoading:r,runHistory:i,filteredRunHistory:a,jobs:o,onRefreshHistory:s,onOpenJobDetail:c,statusLabels:l}=e,u;t[0]===n.tabRunHistory?u=t[1]:(u=(0,$.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),t[0]=n.tabRunHistory,t[1]=u);let d;t[2]===n.runHistoryHint?d=t[3]:(d=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint}),t[2]=n.runHistoryHint,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=n.refresh,m=n.refresh,h;t[7]===s?h=t[8]:(h=()=>void s(),t[7]=s,t[8]=h);let g=r&&`animate-spin`,_;t[9]===g?_=t[10]:(_=M(`size-4`,g),t[9]=g,t[10]=_);let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(G,{className:_,strokeWidth:1.75}),t[11]=_,t[12]=v);let y;t[13]!==n.refresh||t[14]!==r||t[15]!==h||t[16]!==v?(y=(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:p,"aria-label":m,onClick:h,children:v}),t[13]=n.refresh,t[14]=r,t[15]=h,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==y||t[19]!==f?(b=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[f,y]}),t[18]=y,t[19]=f,t[20]=b):b=t[20];let S;t[21]!==n.colChat||t[22]!==n.colDetail||t[23]!==n.colDuration||t[24]!==n.colJob||t[25]!==n.colStarted||t[26]!==n.colWorkflow||t[27]!==n.emptyHistoryHint||t[28]!==n.emptyHistoryTitle||t[29]!==n.noRunsYet||t[30]!==n.openChat||t[31]!==n.openChatTitle||t[32]!==n.openWorkflow||t[33]!==n.openWorkflowTitle||t[34]!==n.runHistoryHint||t[35]!==n.status||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==i||t[40]!==r||t[41]!==l?(S=r&&i.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(x,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):a.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(ee,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:i.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:i.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colWorkflow}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,$.jsx)(`tbody`,{children:a.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,$.jsx)(`time`,{dateTime:e.startedAt,children:xe(e.startedAt)})}),(0,$.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:o.some(t=>t.id===e.jobId)?(0,$.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=o.find(t=>t.id===e.jobId);t&&c(t)},children:e.jobName||e.jobId}):(0,$.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,$.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,$.jsx)(`span`,{className:M(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:he(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:ve(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:me(e.summary||e.error,96)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.workflowRunId?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openWorkflowTitle,"aria-label":n.openWorkflowTitle,onClick:()=>$e(e.workflowRunId),children:n.openWorkflow}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>Qe(e.sessionKey),children:n.openChat}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})}),t[21]=n.colChat,t[22]=n.colDetail,t[23]=n.colDuration,t[24]=n.colJob,t[25]=n.colStarted,t[26]=n.colWorkflow,t[27]=n.emptyHistoryHint,t[28]=n.emptyHistoryTitle,t[29]=n.noRunsYet,t[30]=n.openChat,t[31]=n.openChatTitle,t[32]=n.openWorkflow,t[33]=n.openWorkflowTitle,t[34]=n.runHistoryHint,t[35]=n.status,t[36]=a,t[37]=o,t[38]=c,t[39]=i,t[40]=r,t[41]=l,t[42]=S):S=t[42];let C;return t[43]!==b||t[44]!==S?(C=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[b,S]}),t[43]=b,t[44]=S,t[45]=C):C=t[45],C}function Tt(e){let t=(0,Q.c)(77),{job:n,c:r,localeTag:i,scheduleBadgeLabels:a,absorbCardClickJobIdRef:o,scheduleAbsorbNextMenuCardClick:s,onOpenDetail:c,onToggle:l,onEdit:u,onRunNow:d,onDelete:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=M(`flex h-full min-h-0 cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=p):p=t[0];let m,h;t[1]!==o||t[2]!==n||t[3]!==c?(m=()=>{if(o.current===n.id){o.current=null;return}c(n)},h=e=>{if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),o.current===n.id){o.current=null;return}c(n)}},t[1]=o,t[2]=n,t[3]=c,t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=n.enabled,_=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,v;t[6]===_?v=t[7]:(v=M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_),t[6]=_,t[7]=v);let y;t[8]!==n||t[9]!==l?(y=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=y):y=t[10];let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=b):b=t[11];let x;t[12]!==n.enabled||t[13]!==v||t[14]!==y?(x=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:v,onClick:y,children:b}),t[12]=n.enabled,t[13]=v,t[14]=y,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(ae,{className:`size-4`,strokeWidth:1.75}),t[16]=S):S=t[16];let C;t[17]===r.jobCardMenuAria?C=t[18]:(C=(0,$.jsx)(Ve,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:Dt,children:S})}),t[17]=r.jobCardMenuAria,t[18]=C);let w;t[19]!==n||t[20]!==u||t[21]!==s?(w=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=w):w=t[22];let T;t[23]!==r.edit||t[24]!==w?(T=(0,$.jsx)(Ue,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:w,children:r.edit}),t[23]=r.edit,t[24]=w,t[25]=T):T=t[25];let E;t[26]!==n||t[27]!==d||t[28]!==s?(E=()=>{s(n.id),d(n)},t[26]=n,t[27]=d,t[28]=s,t[29]=E):E=t[29];let D;t[30]!==r.runNow||t[31]!==E?(D=(0,$.jsx)(Ue,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:E,children:r.runNow}),t[30]=r.runNow,t[31]=E,t[32]=D):D=t[32];let k;t[33]!==n||t[34]!==f||t[35]!==s?(k=()=>{s(n.id),f(n)},t[33]=n,t[34]=f,t[35]=s,t[36]=k):k=t[36];let A;t[37]!==r.delete||t[38]!==k?(A=(0,$.jsx)(Ue,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:k,children:r.delete}),t[37]=r.delete,t[38]=k,t[39]=A):A=t[39];let j;t[40]!==T||t[41]!==D||t[42]!==A?(j=(0,$.jsx)(We,{children:(0,$.jsxs)(Ge,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:Et,children:[T,D,A]})}),t[40]=T,t[41]=D,t[42]=A,t[43]=j):j=t[43];let N;t[44]!==C||t[45]!==j?(N=(0,$.jsxs)(He,{children:[C,j]}),t[44]=C,t[45]=j,t[46]=N):N=t[46];let P;t[47]!==N||t[48]!==x?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[x,N]}),t[47]=N,t[48]=x,t[49]=P):P=t[49];let F=n.name||n.id,I;t[50]===F?I=t[51]:(I=(0,$.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:F}),t[50]=F,t[51]=I);let L;t[52]===n?L=t[53]:(L=ke(n),t[52]=n,t[53]=L);let R;t[54]===n?R=t[55]:(R=ke(n),t[54]=n,t[55]=R);let z;t[56]===R?z=t[57]:(z=(0,$.jsx)(Y,{content:R,compact:!0}),t[56]=R,t[57]=z);let B;t[58]!==L||t[59]!==z?(B=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:L,children:z}),t[58]=L,t[59]=z,t[60]=B):B=t[60];let V;t[61]!==I||t[62]!==B?(V=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[I,B]}),t[61]=I,t[62]=B,t[63]=V):V=t[63];let H;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(ee,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=H):H=t[64];let U;t[65]!==n||t[66]!==i||t[67]!==a?(U=ge(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=U):U=t[68];let W;t[69]===U?W=t[70]:(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[H,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:U})]}),t[69]=U,t[70]=W);let G;return t[71]!==m||t[72]!==P||t[73]!==V||t[74]!==h||t[75]!==W?(G=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:p,onClick:m,onKeyDown:h,children:[P,V,W]}),t[71]=m,t[72]=P,t[73]=V,t[74]=h,t[75]=W,t[76]=G):G=t[76],G}function Et(e){return e.preventDefault()}function Dt(e){return e.stopPropagation()}function Ot(e){let t=(0,Q.c)(134),{c:n,language:r,localeTag:i,scheduleBadgeLabels:o,loading:s,sortedSystemJobs:c,heartbeat:l,keepAwake:u,wakeSupported:d,onWakeUnsupportedClick:f,onKeepAwakeToggle:p,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:b}=e,S,C,w,E,D,A,j,N,P,F,I,L;if(t[0]!==n.disabled||t[1]!==n.enabled||t[2]!==n.keepAwake||t[3]!==n.systemHeartbeatEvery||t[4]!==n.systemHeartbeatHint||t[5]!==n.systemHeartbeatInterval||t[6]!==n.systemHeartbeatSettingsLink||t[7]!==n.systemHeartbeatStatus||t[8]!==n.systemHeartbeatTitle||t[9]!==n.systemTasksIntro||t[10]!==n.tabSystemTasks||t[11]!==n.wakeBanner||t[12]!==n.wakeLockUnavailable||t[13]!==l.enabled||t[14]!==l.intervalMs||t[15]!==u||t[16]!==r||t[17]!==i||t[18]!==p||t[19]!==f||t[20]!==d){let e=_e(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);I=`cron-system-tasks-panel`,L=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?C=t[34]:(C=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=C),t[35]===n.systemTasksIntro?w=t[36]:(w=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=w);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[37]=o):o=t[37];let s;t[38]===n.wakeBanner?s=t[39]:(s=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[o,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[38]=n.wakeBanner,t[39]=s);let c;t[40]===n.keepAwake?c=t[41]:(c=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[40]=n.keepAwake,t[41]=c);let m=!d,h=d?void 0:n.wakeLockUnavailable,g=u?`justify-end bg-accent`:`justify-start bg-surface-hover`,_=!d&&`cursor-not-allowed opacity-50`,v;t[42]!==g||t[43]!==_?(v=M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,g,_),t[42]=g,t[43]=_,t[44]=v):v=t[44];let y;t[45]!==p||t[46]!==f||t[47]!==d?(y=()=>{d?p():f()},t[45]=p,t[46]=f,t[47]=d,t[48]=y):y=t[48];let b;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=b):b=t[49];let x;t[50]!==u||t[51]!==m||t[52]!==h||t[53]!==v||t[54]!==y?(x=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":u,disabled:m,title:h,className:v,onClick:y,children:b}),t[50]=u,t[51]=m,t[52]=h,t[53]=v,t[54]=y,t[55]=x):x=t[55];let R;t[56]!==c||t[57]!==x?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[c,x]}),t[56]=c,t[57]=x,t[58]=R):R=t[58],t[59]!==s||t[60]!==R?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[s,R]}),t[59]=s,t[60]=R,t[61]=E):E=t[61],P=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let z;t[62]===n.systemHeartbeatTitle?z=t[63]:(z=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=z);let B;t[64]===n.systemHeartbeatHint?B=t[65]:(B=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=B);let V;t[66]!==z||t[67]!==B?(V=(0,$.jsxs)(`div`,{children:[z,B]}),t[66]=z,t[67]=B,t[68]=V):V=t[68];let H;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(T,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=H):H=t[69];let W;t[70]===n.systemHeartbeatSettingsLink?W=t[71]:(W=(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(k,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,H]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=W),t[72]!==V||t[73]!==W?(F=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[V,W]}),t[72]=V,t[73]=W,t[74]=F):F=t[74],j=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let G;t[75]===n.systemHeartbeatStatus?G=t[76]:(G=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=G);let K=l.enabled?n.enabled:n.disabled,q;t[77]===K?q=t[78]:(q=(0,$.jsx)(`dd`,{className:`text-fg`,children:K}),t[77]=K,t[78]=q),t[79]!==G||t[80]!==q?(N=(0,$.jsxs)(`div`,{children:[G,q]}),t[79]=G,t[80]=q,t[81]=N):N=t[81],t[82]===n.systemHeartbeatInterval?A=t[83]:(A=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=A),S=`text-fg`;let J;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(J=/\{\{value\}\}/g,t[84]=J):J=t[84],D=n.systemHeartbeatEvery.replace(J,e),t[0]=n.disabled,t[1]=n.enabled,t[2]=n.keepAwake,t[3]=n.systemHeartbeatEvery,t[4]=n.systemHeartbeatHint,t[5]=n.systemHeartbeatInterval,t[6]=n.systemHeartbeatSettingsLink,t[7]=n.systemHeartbeatStatus,t[8]=n.systemHeartbeatTitle,t[9]=n.systemTasksIntro,t[10]=n.tabSystemTasks,t[11]=n.wakeBanner,t[12]=n.wakeLockUnavailable,t[13]=l.enabled,t[14]=l.intervalMs,t[15]=u,t[16]=r,t[17]=i,t[18]=p,t[19]=f,t[20]=d,t[21]=S,t[22]=C,t[23]=w,t[24]=E,t[25]=D,t[26]=A,t[27]=j,t[28]=N,t[29]=P,t[30]=F,t[31]=I,t[32]=L}else S=t[21],C=t[22],w=t[23],E=t[24],D=t[25],A=t[26],j=t[27],N=t[28],P=t[29],F=t[30],I=t[31],L=t[32];let R;t[85]!==S||t[86]!==D?(R=(0,$.jsx)(`dd`,{className:S,children:D}),t[85]=S,t[86]=D,t[87]=R):R=t[87];let z;t[88]!==R||t[89]!==A?(z=(0,$.jsxs)(`div`,{children:[A,R]}),t[88]=R,t[89]=A,t[90]=z):z=t[90];let B;t[91]!==z||t[92]!==j||t[93]!==N?(B=(0,$.jsxs)(`dl`,{className:j,children:[N,z]}),t[91]=z,t[92]=j,t[93]=N,t[94]=B):B=t[94];let V;t[95]!==B||t[96]!==P||t[97]!==F?(V=(0,$.jsxs)(`div`,{className:P,children:[F,B]}),t[95]=B,t[96]=P,t[97]=F,t[98]=V):V=t[98];let H;t[99]===n.systemDreamingTitle?H=t[100]:(H=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=H);let W;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(T,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=W):W=t[101];let G;t[102]===n.systemDreamingSettingsLink?G=t[103]:(G=(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(k,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,W]})}),t[102]=n.systemDreamingSettingsLink,t[103]=G);let K;t[104]!==H||t[105]!==G?(K=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[H,G]}),t[104]=H,t[105]=G,t[106]=K):K=t[106];let q;t[107]===n.systemDreamingHint?q=t[108]:(q=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=q);let J;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==b||t[114]!==v||t[115]!==g||t[116]!==y||t[117]!==_||t[118]!==h||t[119]!==o||t[120]!==c?(J=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(x,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):c.length===0?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/30 px-3 py-4 text-sm text-fg-muted dark:border-edge-subtle`,children:n.systemDreamingEmpty}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:c.map(e=>(0,$.jsx)(Tt,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:b},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=b,t[114]=v,t[115]=g,t[116]=y,t[117]=_,t[118]=h,t[119]=o,t[120]=c,t[121]=J):J=t[121];let Y;t[122]!==K||t[123]!==q||t[124]!==J?(Y=(0,$.jsxs)(`div`,{children:[K,q,J]}),t[122]=K,t[123]=q,t[124]=J,t[125]=Y):Y=t[125];let X;return t[126]!==C||t[127]!==w||t[128]!==E||t[129]!==V||t[130]!==Y||t[131]!==I||t[132]!==L?(X=(0,$.jsxs)(`section`,{"aria-labelledby":I,className:L,children:[C,w,E,V,Y]}),t[126]=C,t[127]=w,t[128]=E,t[129]=V,t[130]=Y,t[131]=I,t[132]=L,t[133]=X):X=t[133],X}function kt(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var At=[`daily`,`monitoring`,`reports`,`automation`],jt=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`meeting_prep`,category:`daily`,defaultSchedule:`0 9 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`meeting_prep`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`inbox_triage`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`competitor_scan`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`weekly_review`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`content_repurpose`,category:`reports`,defaultSchedule:`0 11 * * 4`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`content_repurpose`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`client_proposal`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`client_proposal`},{templateId:`offer_design`,category:`automation`,defaultSchedule:`0 14 1 * *`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`offer_design`},{templateId:`decision_compare`,category:`automation`,defaultSchedule:`0 15 * * 3`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`decision_compare`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function Mt(e){return jt.find(t=>t.templateId===e)}function Nt(e,t,n){let r=t.trim().toLowerCase();return jt.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=kt(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function Pt(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return At.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function Ft(e){let t=(0,Q.c)(23),{template:n,cron:r,localeTag:i,scheduleBadgeLabels:a,onSelectTemplate:o}=e,s;t[0]!==r||t[1]!==n.templateId?(s=kt(r,n.templateId),t[0]=r,t[1]=n.templateId,t[2]=s):s=t[2];let c=s;if(!c)return null;let l;t[3]!==i||t[4]!==a||t[5]!==n.defaultSchedule?(l=ge({schedule:n.defaultSchedule,timezone:void 0,next_run:void 0},i,a),t[3]=i,t[4]=a,t[5]=n.defaultSchedule,t[6]=l):l=t[6];let u=l,d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=M(`flex h-full flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,E.focusRingPanel),t[7]=d):d=t[7];let f;t[8]!==o||t[9]!==n.templateId?(f=()=>o(n.templateId),t[8]=o,t[9]=n.templateId,t[10]=f):f=t[10];let p=`${r.templateCategories[n.category]} — ${c.title}`,m;t[11]===c.title?m=t[12]:(m=(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:c.title}),t[11]=c.title,t[12]=m);let h;t[13]===c.description?h=t[14]:(h=(0,$.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:c.description}),t[13]=c.description,t[14]=h);let g;t[15]===u?g=t[16]:(g=(0,$.jsx)(`span`,{className:`mt-auto flex items-center gap-1 pt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`span`,{className:`tabular-nums`,children:u})}),t[15]=u,t[16]=g);let _;return t[17]!==f||t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`button`,{type:`button`,className:d,onClick:f,"aria-label":p,children:[m,h,g]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function It(e){let t=(0,Q.c)(49),{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s,variant:c}=e,l=c===void 0?`embedded`:c,[u,d]=(0,Z.useState)(``),f;t[0]!==a||t[1]!==n||t[2]!==u?(f=Nt(n,u,a),t[0]=a,t[1]=n,t[2]=u,t[3]=f):f=t[3];let p=f,m;t[4]===p?m=t[5]:(m=Pt(p),t[4]=p,t[5]=m);let h=m,g;t[6]!==a||t[7]!==u?(g=a===`all`&&!u.trim(),t[6]=a,t[7]=u,t[8]=g):g=t[8];let _=g,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(se,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>d(e.target.value),t[10]=y):y=t[10];let b=n.templateSearchPlaceholder,x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=M(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,E.focusRingPanel),t[11]=x):x=t[11];let S;t[12]!==n.templateSearchPlaceholder||t[13]!==u?(S=(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{value:u,onChange:y,placeholder:b,className:x})]}),t[12]=n.templateSearchPlaceholder,t[13]=u,t[14]=S):S=t[14];let C=n.fromTemplate,w=a===`all`?`secondary`:`ghost`,T;t[15]===o?T=t[16]:(T=()=>o(`all`),t[15]=o,t[16]=T);let D;t[17]!==n.templateFilterAll||t[18]!==w||t[19]!==T?(D=(0,$.jsx)(O,{type:`button`,variant:w,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:T,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=w,t[19]=T,t[20]=D):D=t[20];let k;t[21]!==a||t[22]!==n.templateCategories||t[23]!==o?(k=At.map(e=>(0,$.jsx)(O,{type:`button`,variant:a===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(e),children:n.templateCategories[e]},e)),t[21]=a,t[22]=n.templateCategories,t[23]=o,t[24]=k):k=t[24];let A;t[25]!==n.fromTemplate||t[26]!==D||t[27]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":C,children:[D,k]}),t[25]=n.fromTemplate,t[26]=D,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==A||t[30]!==S?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[S,A]}),t[29]=A,t[30]=S,t[31]=j):j=t[31];let N=j,P;t[32]!==n||t[33]!==p||t[34]!==h||t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==_||t[39]!==l?(P=p.length===0?(0,$.jsx)(`div`,{className:M(`text-center text-sm text-fg-muted`,l===`dialog`&&`flex h-full flex-col items-center justify-center px-4 py-12`),children:n.templatesEmptyHint}):_?(0,$.jsx)(`div`,{className:`flex flex-col gap-6 pb-1`,children:h.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.templateCategories[e.category]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.items.map(e=>(0,$.jsx)(Ft,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))})]},e.category))}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pb-1 sm:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,$.jsx)(Ft,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))}),t[32]=n,t[33]=p,t[34]=h,t[35]=r,t[36]=s,t[37]=i,t[38]=_,t[39]=l,t[40]=P):P=t[40];let F=P;if(l===`dialog`){let e;t[41]===F?e=t[42]:(e=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:F}),t[41]=F,t[42]=e);let n;return t[43]!==N||t[44]!==e?(n=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[N,e]}),t[43]=N,t[44]=e,t[45]=n):n=t[45],n}let I;return t[46]!==N||t[47]!==F?(I=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[N,F]}),t[46]=N,t[47]=F,t[48]=I):I=t[48],I}function Lt(e){let t=(0,Q.c)(49),{c:n,localeTag:r,scheduleBadgeLabels:i,loading:a,jobsCount:o,sortedJobs:s,templateCategoryFilter:c,onTemplateCategoryFilterChange:l,onSelectTemplate:u,keepAwake:d,wakeSupported:f,onWakeUnsupportedClick:p,onKeepAwakeToggle:m,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onAddJob:b,onRunNow:S,onDelete:C}=e,w;t[0]===n.tabMyTasks?w=t[1]:(w=(0,$.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),t[0]=n.tabMyTasks,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=T):T=t[2];let E;t[3]===n.wakeBanner?E=t[4]:(E=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[T,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[3]=n.wakeBanner,t[4]=E);let D;t[5]===n.keepAwake?D=t[6]:(D=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[5]=n.keepAwake,t[6]=D);let k=!f,A=f?void 0:n.wakeLockUnavailable,j=d?`justify-end bg-accent`:`justify-start bg-surface-hover`,N=!f&&`cursor-not-allowed opacity-50`,P;t[7]!==j||t[8]!==N?(P=M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,j,N),t[7]=j,t[8]=N,t[9]=P):P=t[9];let F;t[10]!==m||t[11]!==p||t[12]!==f?(F=()=>{f?m():p()},t[10]=m,t[11]=p,t[12]=f,t[13]=F):F=t[13];let I;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[14]=I):I=t[14];let L;t[15]!==d||t[16]!==F||t[17]!==k||t[18]!==A||t[19]!==P?(L=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":d,disabled:k,title:A,className:P,onClick:F,children:I}),t[15]=d,t[16]=F,t[17]=k,t[18]=A,t[19]=P,t[20]=L):L=t[20];let R;t[21]!==L||t[22]!==D?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[D,L]}),t[21]=L,t[22]=D,t[23]=R):R=t[23];let z;t[24]!==R||t[25]!==E?(z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[E,R]}),t[24]=R,t[25]=E,t[26]=z):z=t[26];let B;t[27]!==h||t[28]!==n||t[29]!==o||t[30]!==a||t[31]!==r||t[32]!==b||t[33]!==C||t[34]!==y||t[35]!==_||t[36]!==S||t[37]!==u||t[38]!==l||t[39]!==v||t[40]!==g||t[41]!==i||t[42]!==s||t[43]!==c?(B=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(x,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):o===0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,$.jsx)(`div`,{className:`w-full max-w-6xl`,children:(0,$.jsx)(It,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(O,{type:`button`,variant:`primary`,onClick:b,children:n.emptyStateCta})})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:s.map(e=>(0,$.jsx)(Tt,{job:e,c:n,localeTag:r,scheduleBadgeLabels:i,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:e=>void _(e),onToggle:(e,t)=>void v(e,t),onEdit:y,onRunNow:S,onDelete:C},e.id))}),t[27]=h,t[28]=n,t[29]=o,t[30]=a,t[31]=r,t[32]=b,t[33]=C,t[34]=y,t[35]=_,t[36]=S,t[37]=u,t[38]=l,t[39]=v,t[40]=g,t[41]=i,t[42]=s,t[43]=c,t[44]=B):B=t[44];let V;return t[45]!==w||t[46]!==z||t[47]!==B?(V=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[w,z,B]}),t[45]=w,t[46]=z,t[47]=B,t[48]=V):V=t[48],V}function Rt(e){let t=(0,Q.c)(29),{open:n,onOpenChange:r,c:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:g}=e,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=_):_=t[0];let v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=M(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,840px)] w-full max-w-5xl flex-col`,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,E.focusRingPanel),t[1]=v):v=t[1];let y;t[2]===i.fromTemplate?y=t[3]:(y=(0,$.jsx)(m,{className:`text-lg font-semibold text-fg`,children:i.fromTemplate}),t[2]=i.fromTemplate,t[3]=y);let b;t[4]===i.templatePickerHint?b=t[5]:(b=(0,$.jsx)(p,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.templatePickerHint}),t[4]=i.templatePickerHint,t[5]=b);let x;t[6]!==y||t[7]!==b?(x=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(R,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=S):S=t[9];let C;t[10]===i.close?C=t[11]:(C=(0,$.jsx)(h,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:S})}),t[10]=i.close,t[11]=C);let w;t[12]!==x||t[13]!==C?(w=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[x,C]}),t[12]=x,t[13]=C,t[14]=w):w=t[14];let T;t[15]!==i||t[16]!==s||t[17]!==a||t[18]!==c||t[19]!==g||t[20]!==o?(T=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,$.jsx)(It,{variant:`dialog`,cron:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:g})}),t[15]=i,t[16]=s,t[17]=a,t[18]=c,t[19]=g,t[20]=o,t[21]=T):T=t[21];let D;t[22]!==w||t[23]!==T?(D=(0,$.jsxs)(l,{children:[_,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(d,{className:v,onOpenAutoFocus:zt,children:[w,T]})})]}),t[22]=w,t[23]=T,t[24]=D):D=t[24];let k;return t[25]!==r||t[26]!==n||t[27]!==D?(k=(0,$.jsx)(f,{open:n,onOpenChange:r,children:D}),t[25]=r,t[26]=n,t[27]=D,t[28]=k):k=t[28],k}function zt(e){return e.preventDefault()}function Bt(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:qe,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function Vt(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`replace`:return t.state;case`setMessageMdMode`:return{...e,formMessageMdMode:t.mode,messageEditorNonce:t.mode===`edit`?e.messageEditorNonce+1:e.messageEditorNonce}}}function Ht(e,t){let n=Bt();if(n.formOpen=!0,n.formMode=e?`edit`:`add`,n.formJobId=e?.id??null,!e)return n.formModel=t(),n;n.formName=e.name||``,n.formSchedule=e.schedule&&String(e.schedule).trim()||`*/5 * * * *`;let r=ke(e);if(n.formMessage=r??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=ft(e.payload.definitionId,e.payload.inputEnvelope?.payload??e.payload.input??{});let t=e.payload.agentId?.trim().toLowerCase();t&&(n.formAgentId=t)}n.formSessionTarget=e.sessionTarget||`main`,n.formAgentId=(e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``,n.formWorkingDirectory=(e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``;let i=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;n.formModel=e.model?.trim()||i||t();let a=e.delivery?.channel===`local`,o=(e.sessionTarget||`main`)===`isolated`&&!a&&(!e.delivery?.to||e.delivery.mode===`none`);if(n.formAgentLocalOnly=o,a)n.formChannel=`local`,n.formChatId=``;else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)n.formChannel=e.delivery.channel||`telegram`,n.formChatId=e.delivery.to||``;else if(o)n.formChannel=`telegram`,n.formChatId=``;else{let e=r.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(n.formChannel=e[0],n.formChatId=e[1],n.formMessage=e.slice(2).join(`:`)):(n.formChannel=`telegram`,n.formChatId=``)}return n.formMessageMdMode=`edit`,n.messageEditorNonce=1,n}function Ut(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(Vt,void 0,Bt),s=(0,Z.useRef)(!1),c=(0,Z.useMemo)(()=>new Set([`local`,...r.map(e=>e.name)]),[r]);if(a.formOpen&&a.formMode===`add`&&!c.has(a.formChannel)&&o({type:`patch`,patch:{formChannel:`local`}}),a.formOpen&&a.formMode===`add`&&!s.current){let e=n();e&&e!==a.formModel&&o({type:`patch`,patch:{formModel:e}})}let l=J(()=>De(a.formChannel),[a.formChannel],{enabled:a.formOpen&&a.formChannel!==`local`,initial:[],errorData:[]}),u=a.formChannel===`local`?[]:l.data,d=(0,Z.useMemo)(()=>{let e=new Set(i.map(e=>e.id)),t=[...i],n=a.formAgentId.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[i,a.formAgentId]),f=a.formChannel!==`local`&&(a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly)||a.formTaskKind===`workflowRun`&&!a.formAgentLocalOnly),p=a.formTaskKind===`workflowRun`?!a.formAgentLocalOnly:a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),m=a.formTaskKind===`workflowRun`?!!a.formWorkflowDefinitionId.trim()&&pt(a.formWorkflowDefinitionId.trim(),a.formWorkflowArgValues):!!a.formMessage.trim(),h=!!a.formName.trim()&&!!a.formSchedule.trim()&&m&&(!f||!!a.formChatId.trim()),g=(0,Z.useCallback)(e=>{s.current=!1,o({type:`replace`,state:Ht(e,n)})},[n]),_=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),v=(0,Z.useCallback)(e=>{let r=Mt(e),i=r?kt(t.cron,e):void 0;if(!r||!i)return!1;let a=r.taskKind===`workflowRun`&&!!r.workflowDefinitionId;return s.current=!1,o({type:`replace`,state:{...Bt(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:r.defaultSchedule,formMessage:a?``:i.prompt,formTaskKind:a?`workflowRun`:`message`,formWorkflowDefinitionId:a?r.workflowDefinitionId:``,formWorkflowGoal:a?i.description:``,formSessionTarget:r.defaultSessionTarget,formModel:n(),formAgentLocalOnly:a,messageEditorNonce:1}}),!0},[n,t.cron]),y=(0,Z.useCallback)(()=>{s.current=!1,o({type:`replace`,state:Bt()})},[]),b=(0,Z.useCallback)((e,t,n)=>{let r={formSessionTarget:e};e===`main`?(r.formAgentLocalOnly=!1,r.formAgentId=``,r.formWorkingDirectory=``):e===`isolated`&&!n&&(r.formModel=t()),o({type:`patch`,patch:r})},[]),x=(0,Z.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),S=(0,Z.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),C=(0,Z.useCallback)(()=>{De(a.formChannel).then(l.setData)},[a.formChannel,l.setData]),w=(0,Z.useCallback)(e=>{o({type:`patch`,patch:e})},[]);return{formOpen:a.formOpen,formMode:a.formMode,formJobId:a.formJobId,formName:a.formName,formSchedule:a.formSchedule,formChannel:a.formChannel,formChatId:a.formChatId,formMessage:a.formMessage,formMessageMdMode:a.formMessageMdMode,formTaskKind:a.formTaskKind,formWorkflowDefinitionId:a.formWorkflowDefinitionId,formWorkflowGoal:a.formWorkflowGoal,formWorkflowArgValues:a.formWorkflowArgValues,messageEditorNonce:a.messageEditorNonce,formSessionTarget:a.formSessionTarget,formAgentId:a.formAgentId,formAgentLocalOnly:a.formAgentLocalOnly,formWorkingDirectory:a.formWorkingDirectory,formModel:a.formModel,formSubmitting:a.formSubmitting,sessionChatIds:u,setFormName:e=>w({formName:e}),setFormSchedule:e=>w({formSchedule:e}),setFormChatId:e=>w({formChatId:e}),setFormMessage:e=>w({formMessage:e}),setFormTaskKind:e=>w(e===`workflowRun`?{formTaskKind:e,formSessionTarget:`isolated`,formAgentLocalOnly:!1}:{formTaskKind:e}),setFormWorkflowDefinitionId:e=>w({formWorkflowDefinitionId:e,formWorkflowArgValues:{}}),setFormWorkflowGoal:e=>w({formWorkflowGoal:e}),setFormWorkflowArgValues:e=>w({formWorkflowArgValues:e}),setFormAgentId:e=>w({formAgentId:e}),setFormAgentLocalOnly:e=>w({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>w({formWorkingDirectory:e}),setFormSubmitting:e=>w({formSubmitting:e}),canSubmit:h,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:g,closeForm:y,applyCronTemplate:v,setMessageMdMode:_,handleFormSessionTargetChange:b,handleFormChannelChange:x,handleFormModelUserChange:S,refreshRecipientsList:C}}function Wt(e){let{onUnavailable:t}=e,[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(`none`),o=(0,Z.useRef)(n),s=typeof navigator<`u`&&`wakeLock`in navigator,c=s||X(),l=(0,Z.useCallback)(async()=>{if(a.current===`electron`){try{await window.electronAPI?.cron?.setDisplaySleepPrevented?.(!1)}catch{}a.current=`none`;return}try{await i.current?.release()}catch{}i.current=null,a.current=`none`},[]),u=(0,Z.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.cron?.setDisplaySleepPrevented:void 0;if(e)try{await e(!0),a.current=`electron`;return}catch{t(),r(!1);return}if(s)try{let e=await navigator.wakeLock.request(`screen`);i.current=e,a.current=`navigator`,e.addEventListener(`release`,()=>{i.current=null,a.current=`none`})}catch{t(),r(!1)}},[t,s]);return o.current=n,(0,Z.useEffect)(()=>{if(!n){l();return}u();let e=()=>{document.visibilityState===`visible`&&o.current&&u()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),l()}},[n,u,l]),{keepAwake:n,setKeepAwake:r,featureAvailable:c}}function Gt(e){let{hasToken:t,failMessages:n,isHistoryTab:r}=e,[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useCallback)(async()=>{x(!0),w(null);try{a(await Fe())}catch(e){w(e instanceof Error?e.message:n.failedToLoadJobs)}finally{x(!1)}},[n.failedToLoadJobs]),E=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([Ee(),Ce(),Se(),B(),S().catch(()=>null)]);s(e),l(t),d(n.model||``),h(r.payload?.config??null),i&&p(i.items)}catch{}},[]),D=(0,Z.useCallback)(async()=>{y(!0);try{_(await Me(400))}catch{}finally{y(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(T(),E())},[t,T,E]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{B().then(e=>{h(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||D()},[t,r,D]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:m,runHistory:g,runHistoryLoading:v,loading:b,error:C,setError:w,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!be(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>be(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>Le(m),[m]),loadJobs:T,loadAux:E,loadRunHistoryOnly:D,refreshAll:(0,Z.useCallback)(()=>{T(),E(),D()},[T,E,D])}}function Kt(e,t){let n=[...e];return n.sort((e,n)=>{let r=new Date(e.created_at).getTime(),i=new Date(n.created_at).getTime();return t===`created_desc`?i-r:r-i}),n}function qt(e,t,n,r){let i=new Date,a=t===`day`?Ye(i):t===`week`?Xe(i):Ze(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var Jt={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function Yt(){let e=i(e=>e.language),t=a(e),n=t.cron,r=t.chat,s=_(e=>e.token),c=!!s,l=g(e=>e.resolved)===`dark`,u=e===`zh`?`zh-CN`:`en-US`,[d,f]=(0,Z.useReducer)(F,Jt),{mainTab:p,jobSort:m,historyRange:h,historyJobFilter:v,historyStatusFilter:y,detailOpen:b,detailJob:x,detailHistory:S,detailLoading:C,confirmOpen:w,templatePickerOpen:T,templateCategoryFilter:E}=d,D=Gt({hasToken:c,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:p===`history`}),{setError:O}=D,k=Wt({onUnavailable:()=>O(n.wakeLockUnavailable)}),A=(0,Z.useCallback)(()=>D.defaultModel||(D.availableModels.length>0?D.availableModels[0].id:``),[D.defaultModel,D.availableModels]),j=Ut({m:t,defaultModelForForm:A,channels:D.channels,chatAgents:D.chatAgents}),M=o(c&&j.formOpen?[`workflow-definitions-cron`,s]:null,te,{revalidateOnFocus:!1}),N=M.data??[],P=(0,Z.useRef)(null),I=(0,Z.useRef)(null),L=(0,Z.useCallback)((e,t)=>{P.current=e,I.current=t,f({type:`patch`,patch:{confirmOpen:!0}})},[]),R=(0,Z.useCallback)(()=>{f({type:`patch`,patch:{confirmOpen:!1}}),I.current=null,P.current=null},[]),z=(0,Z.useRef)(null),B=(0,Z.useCallback)(e=>{z.current=e,window.setTimeout(()=>{z.current===e&&(z.current=null)},400)},[]),H=(0,Z.useCallback)(e=>{j.applyCronTemplate(e)&&f({type:`patch`,patch:{templatePickerOpen:!1}})},[j]),U=async()=>{if(!j.formName.trim()){O(n.nameRequired);return}if(!j.formSchedule.trim()){O(n.scheduleRequired);return}if(j.formTaskKind===`message`&&!j.formMessage.trim()){O(n.scheduleRequired);return}if(j.formTaskKind===`workflowRun`&&!j.formWorkflowDefinitionId.trim()){O(n.workflowDefinitionRequired);return}if(j.formTaskKind===`workflowRun`&&!pt(j.formWorkflowDefinitionId.trim(),j.formWorkflowArgValues)){O(n.workflowArgsRequired);return}if(j.needsDeliveryChat&&!j.formChatId.trim()){O(n.chatIdRequired);return}j.setFormSubmitting(!0),O(null);try{let e=j.formMessage.trim(),t=j.formModel.trim(),n=j.formAgentId.trim().toLowerCase(),r=j.formWorkingDirectory.trim(),i=j.formTaskKind===`workflowRun`,a=j.formTaskKind===`message`&&j.formSessionTarget===`isolated`,o=i?`isolated`:j.formSessionTarget,s;s=i?j.formAgentLocalOnly?{mode:`none`}:j.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:j.formChannel,to:j.formChatId.trim()}:j.formSessionTarget===`isolated`&&j.formAgentLocalOnly?{mode:`none`}:j.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:j.formChannel,to:j.formChatId.trim()};let c;if(i){let e=j.formWorkflowDefinitionId.trim(),t=Be(j.formWorkflowArgValues);c={kind:`workflowRun`,definitionId:e,...t===void 0?{}:{inputEnvelope:{payload:t}},...j.formWorkflowGoal.trim()?{goal:j.formWorkflowGoal.trim()}:{},...n?{agentId:n}:{}}}else c=a?{kind:`agentTurn`,message:e,...t?{model:t}:{}}:{kind:`systemEvent`,text:e};let l=o===`main`?null:n||null,u={name:j.formName.trim(),schedule:j.formSchedule.trim(),sessionTarget:o,model:a&&t?t:void 0,...i?{timeout:Je}:{},delivery:s,payload:c,...j.formMode===`edit`?{agentId:l,workingDirectory:a&&r||null}:{...o===`isolated`&&n?{agentId:n}:{},...a&&r?{workingDirectory:r}:{}}};if(j.formMode===`edit`&&j.formJobId)await Oe(j.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await Pe(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}j.closeForm(),await D.loadJobs()}catch(e){O(e instanceof Error?e.message:j.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{j.setFormSubmitting(!1)}},W=async e=>{f({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await Ne(e.id);t&&f({type:`patch`,patch:{detailJob:t,detailHistory:await Ae(e.id,20)}})}catch{}finally{f({type:`patch`,patch:{detailLoading:!1}})}},G=(0,Z.useCallback)(()=>{f({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),K=(0,Z.useCallback)(()=>{f({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),q=async(e,t)=>{try{await je(e.id,t),x?.id===e.id&&f({type:`patch`,patch:{detailJob:{...x,enabled:t}}}),await Promise.all([D.loadJobs(),D.loadAux()])}catch(e){O(e instanceof Error?e.message:n.failedToToggleJob)}},J=async()=>{let e=I.current,t=P.current;if(!(!e||!t)){R();try{t===`run`?await Te(e):(await we(e),x?.id===e&&f({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([D.loadJobs(),D.loadAux(),D.loadRunHistoryOnly()])}catch(e){O(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(j.formOpen?j.closeForm():b&&f({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[j,b]);let Y=(0,Z.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),X=(0,Z.useMemo)(()=>Kt(D.userCronJobs,m),[D.userCronJobs,m]),ee=(0,Z.useMemo)(()=>Kt(D.systemCronJobs,m),[D.systemCronJobs,m]),ne=(0,Z.useMemo)(()=>qt(D.runHistory,h,v,y),[D.runHistory,h,v,y]),re=n.scheduleBadge,{pathname:ie}=V(),ae=ie.startsWith(`/settings/`);return c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xt,{hasToken:c,c:n,loading:D.loading,runHistoryLoading:D.runHistoryLoading,onRefresh:D.refreshAll,onOpenTemplatePicker:K,onAddJob:()=>j.openForm()}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[D.error?(0,$.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,role:`alert`,children:D.error}):null,(0,$.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle})]})}),ae?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Ct,{c:n,loading:D.loading,runHistoryLoading:D.runHistoryLoading,onRefresh:D.refreshAll,onOpenTemplatePicker:K,onAddJob:()=>j.openForm()})}):null,(0,$.jsx)(xt,{c:n,mainTab:p,onMainTabChange:e=>f({type:`patch`,patch:{mainTab:e}}),jobSort:m,onJobSortChange:e=>f({type:`patch`,patch:{jobSort:e}}),historyRange:h,onHistoryRangeChange:e=>f({type:`patch`,patch:{historyRange:e}}),historyJobFilter:v,onHistoryJobFilterChange:e=>f({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:y,onHistoryStatusFilterChange:e=>f({type:`patch`,patch:{historyStatusFilter:e}}),jobs:D.jobs}),p===`myTasks`?(0,$.jsx)(Lt,{c:n,localeTag:u,scheduleBadgeLabels:re,loading:D.loading,jobsCount:D.userCronJobs.length,sortedJobs:X,templateCategoryFilter:E,onTemplateCategoryFilterChange:e=>f({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:H,keepAwake:k.keepAwake,wakeSupported:k.featureAvailable,onWakeUnsupportedClick:()=>O(n.wakeLockUnavailable),onKeepAwakeToggle:()=>k.setKeepAwake(e=>!e),absorbCardClickJobIdRef:z,scheduleAbsorbNextMenuCardClick:B,onOpenDetail:e=>void W(e),onToggle:(e,t)=>void q(e,t),onEdit:e=>j.openForm(e),onAddJob:()=>j.openForm(),onRunNow:e=>L(`run`,e.id),onDelete:e=>L(`delete`,e.id)}):p===`systemTasks`?(0,$.jsx)(Ot,{c:n,language:e,localeTag:u,scheduleBadgeLabels:re,loading:D.loading,sortedSystemJobs:ee,heartbeat:D.heartbeatFromConfig,keepAwake:k.keepAwake,wakeSupported:k.featureAvailable,onWakeUnsupportedClick:()=>O(n.wakeLockUnavailable),onKeepAwakeToggle:()=>k.setKeepAwake(e=>!e),absorbCardClickJobIdRef:z,scheduleAbsorbNextMenuCardClick:B,onOpenDetail:e=>void W(e),onToggle:(e,t)=>void q(e,t),onEdit:e=>j.openForm(e),onRunNow:e=>L(`run`,e.id),onDelete:e=>L(`delete`,e.id)}):(0,$.jsx)(wt,{c:n,runHistoryLoading:D.runHistoryLoading,runHistory:D.runHistory,filteredRunHistory:ne,jobs:D.jobs,onRefreshHistory:()=>void D.loadRunHistoryOnly(),onOpenJobDetail:e=>void W(e),statusLabels:Y})]}),(0,$.jsx)(gt,{open:j.formOpen,onRequestClose:j.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:l,channels:D.channels,sessionChatIds:j.sessionChatIds,cronAgentSelectOptions:j.cronAgentSelectOptions,defaultModelResolver:A,formMode:j.formMode,formJobId:j.formJobId,formName:j.formName,onFormNameChange:j.setFormName,formSchedule:j.formSchedule,onFormScheduleChange:j.setFormSchedule,formSubmitting:j.formSubmitting,formTaskKind:j.formTaskKind,onFormTaskKindChange:j.setFormTaskKind,workflowDefinitions:N,workflowDefinitionsLoading:M.isLoading,formWorkflowDefinitionId:j.formWorkflowDefinitionId,onFormWorkflowDefinitionIdChange:j.setFormWorkflowDefinitionId,formWorkflowGoal:j.formWorkflowGoal,onFormWorkflowGoalChange:j.setFormWorkflowGoal,formWorkflowArgValues:j.formWorkflowArgValues,onFormWorkflowArgValuesChange:j.setFormWorkflowArgValues,formSessionTarget:j.formSessionTarget,onFormSessionTargetChange:j.handleFormSessionTargetChange,formAgentLocalOnly:j.formAgentLocalOnly,onFormAgentLocalOnlyChange:j.setFormAgentLocalOnly,formModel:j.formModel,onFormModelUserChange:j.handleFormModelUserChange,formAgentId:j.formAgentId,onFormAgentIdChange:j.setFormAgentId,formWorkingDirectory:j.formWorkingDirectory,onFormWorkingDirectoryChange:j.setFormWorkingDirectory,formChannel:j.formChannel,onFormChannelChange:j.handleFormChannelChange,formChatId:j.formChatId,onFormChatIdChange:j.setFormChatId,formMessage:j.formMessage,onFormMessageChange:j.setFormMessage,formMessageMdMode:j.formMessageMdMode,onSetMessageMdMode:j.setMessageMdMode,messageEditorNonce:j.messageEditorNonce,needsDeliveryChat:j.needsDeliveryChat,showChannelPicker:j.showChannelPicker,canSubmit:j.canSubmit,onSubmit:()=>void U(),onRefreshRecipients:j.refreshRecipientsList}),(0,$.jsx)(Rt,{open:T,onOpenChange:e=>{f({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:u,scheduleBadgeLabels:re,categoryFilter:E,onCategoryFilterChange:e=>f({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:H}),(0,$.jsx)(lt,{open:b,onDismiss:G,detailJob:x,detailLoading:C,detailHistory:S,c:n,localeTag:u,scheduleBadgeLabels:re,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:Y,onEdit:e=>{G(),j.openForm(e)},onRunNow:e=>L(`run`,e.id),onToggle:(e,t)=>void q(e,t),onDelete:e=>L(`delete`,e.id)}),(0,$.jsx)(Ke,{open:w,onOpenChange:e=>f({type:`patch`,patch:{confirmOpen:e}}),action:P.current,c:n,onDismiss:R,onConfirm:J})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xt,{hasToken:c,c:n,loading:D.loading,runHistoryLoading:D.runHistoryLoading,onRefresh:D.refreshAll,onOpenTemplatePicker:K,onAddJob:()=>j.openForm()}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})]})}function Xt(e){let t=(0,Q.c)(16),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,{pathname:l}=V(),u;t[0]===l?u=t[1]:(u=l.startsWith(`/settings/`),t[0]=l,t[1]=u);let d=u,f=de(Qt),p=de(Zt),m;t[2]!==r||t[3]!==i||t[4]!==c||t[5]!==s||t[6]!==o||t[7]!==a?(m=(0,$.jsx)(Ct,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[2]=r,t[3]=i,t[4]=c,t[5]=s,t[6]=o,t[7]=a,t[8]=m):m=t[8];let h=m,g,_;return t[9]!==p||t[10]!==h||t[11]!==n||t[12]!==d||t[13]!==f?(g=()=>!n||d?(p(),()=>p()):(f({startExtra:null,main:null,end:h}),()=>p()),_=[p,h,n,d,f],t[9]=p,t[10]=h,t[11]=n,t[12]=d,t[13]=f,t[14]=g,t[15]=_):(g=t[14],_=t[15]),(0,Z.useLayoutEffect)(g,_),null}function Zt(e){return e.clearPageHeader}function Qt(e){return e.setPageHeader}export{Yt as CronPage};
|