@xopcai/xopc 0.0.140 → 0.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DtONoxBN.js → agent-avatar-dicebear-BawPxiu5.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CyvCIHnB.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BRBxLECY.js → app-management-settings-panel-81xd1p9R.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-ChvyuSEt.js → appearance-settings-DYeQsYU8.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DgHWTnjs.js → apps-page-DK_Vx6nl.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CdIoagem.js → archive-plugin-D_oa7oti.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Ch411Kht.js → attachment-load-Cd-bwI2N.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-SVq27yw2.js → automation-suggestion-card-B1LV3YYv.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-fzrovqhv.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D8cV-emn.js → binary-plugins-O8svLKWw.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CXDkby6y.js → block-editor-Dhj5f4Bx.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-BDn-n-UB.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-DLxI--Ge.js → capability-presets-api-dJy1Eqgx.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DKyRbnlH.js → capability-presets-settings-panel-Co5ipo_Q.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-DllrPmp-.js → channel-recipient-api-Bfuhp2ty.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BWlpaxg9.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-D_jkIZLV.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BcekbW4q.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-Bz9ommjr.js → desktop-pet-DFMfIb5F.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BnLgxgoR.js → desktop-pet-settings-BJCUuL8Y.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DLsCwFaf.js → directory-picker-path-field-BrYt1gAr.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-BzkF1-XT.js → dreaming-settings-BN1Z2mIo.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-CdERvf3L.js → extension-debug-page-Bh630pLD.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D1fz474Z.js → extension-page-B-1KxvVy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DoQMkNOK.js → extension-settings-page-BF9NACI3.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-BID89uCH.js → fetch-B1WtuprY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Rygo8UAs.js → gateway-config-api-De2N821l.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-kb8KIeQL.js → gateway-settings-DN9sNREz.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BkrLLlpE.js → gateway-startup-retry-nEujFSDj.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BpoQW8cD.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-CBRSPd0b.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-BuY6-l0a.js → goals-config-api-DUy3eEse.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BCcBi407.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-DoH5fZWo.js → goals-settings-pkTXzXkh.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BqDs48B-.js → heartbeat-settings-ezsufgLQ.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CrPRlGMg.js → index-DcUaXYeb.js} +65 -65
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CVIwwM15.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-DQtTRXtj.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CSt32FWE.js → markdown-split-B_6us9j7.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-ByItHxBj.js → media-plugins-D_fryIyj.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BXNELNBa.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BP2M9n6Q.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-CspveYaO.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-BHwzJ0OC.js +2 -0
- package/dist/gateway/static/root/assets/{page-tabs-DOfMaq_L.js → page-tabs-D_8jGlqx.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BArxASu7.js → preview-open-alternatives-BBLMK8Mp.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Dy3rsobs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CWKpPE0L.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CqNRyXEo.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BRxlkhG8.js → save-bar-controls-DVS3FR5r.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BzM1iyOc.js → schedule-field-D6vKd6-T.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-ChVcm0DX.js → schema-form-BPy4lbIh.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-MEME7ivF.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-JVd0qaSF.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BcD9xrvY.js → settings-collapsible-section-WzdikxPt.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Cu30CXVl.js → settings-form-section-CvfzhBV-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-Cfd37IYb.js → settings-loading-skeleton-BxR-Ulhi.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-EINHyzLo.js → settings-page-DYEbB1EV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-C15zixct.js → settings-page-layout-CKefvbYi.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Bu7SdpD4.js → setup-status-panel-dWN8BJ3z.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CjjAFV-v.js → share-preview-page-D8foINzP.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Tgbv1s7G.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D_YK0b_Z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DGytfoZK.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DlQMtzPf.js → system-settings-panel-BokgAgf7.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BS1BwExE.js → typed-models-lib-BwHlNL3L.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-EA4hfbsP.js → use-channel-catalog-DR11ap3A.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-B7RCdmSp.js → user-profile-settings-panel-8YtygcJp.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-BrhEgVaa.js → utils-BKUWB-TT.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-BVH71EFf.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-JeTE7XNM.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CL_rnAUB.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BZCY7N42.js → workflow-start-dialog-_u8Uc1ze.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-ixgk_y1l.js +18 -0
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +13 -21
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -0
- package/dist/src/agent/background-review/run-background-review.js.map +1 -1
- package/dist/src/agent/embedded/session-runner.js +5 -5
- package/dist/src/agent/embedded/session-runner.js.map +1 -1
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +4 -3
- package/dist/src/agent/embedded/xopc-auth-storage.js +6 -6
- package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -1
- package/dist/src/agent/embedded/xopc-stream-bridge.js +1 -0
- package/dist/src/agent/embedded/xopc-stream-bridge.js.map +1 -1
- package/dist/src/agent/goals/checklist-judge.js +3 -3
- package/dist/src/agent/goals/checklist-judge.js.map +1 -1
- package/dist/src/agent/goals/judge.js +2 -2
- package/dist/src/agent/goals/judge.js.map +1 -1
- package/dist/src/agent/image/understanding/pi-ai-provider.js +2 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
- package/dist/src/agent/memory/access-policy.d.ts +12 -0
- package/dist/src/agent/memory/access-policy.js +44 -0
- package/dist/src/agent/memory/access-policy.js.map +1 -0
- package/dist/src/agent/memory/builtin-provider.d.ts +4 -1
- package/dist/src/agent/memory/builtin-provider.js +51 -16
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/compaction.js +2 -2
- package/dist/src/agent/memory/compaction.js.map +1 -1
- package/dist/src/agent/memory/context/planner.d.ts +1 -0
- package/dist/src/agent/memory/context/planner.js +9 -5
- package/dist/src/agent/memory/context/planner.js.map +1 -1
- package/dist/src/agent/memory/create-memory-manager.d.ts +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +8 -5
- package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
- package/dist/src/agent/memory/dreaming/config.d.ts +2 -0
- package/dist/src/agent/memory/dreaming/config.js +13 -1
- package/dist/src/agent/memory/dreaming/config.js.map +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +2 -0
- package/dist/src/agent/memory/dreaming/deep-promotion.js +24 -3
- package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +1 -0
- package/dist/src/agent/memory/dreaming/light-sweep.js +184 -16
- package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.d.ts +30 -0
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +85 -0
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -0
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +4 -0
- package/dist/src/agent/memory/dreaming/rem-patterns.js +76 -53
- package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.d.ts +10 -0
- package/dist/src/agent/memory/dreaming/short-term-store.js +157 -79
- package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
- package/dist/src/agent/memory/manager.d.ts +7 -0
- package/dist/src/agent/memory/manager.js +31 -6
- package/dist/src/agent/memory/manager.js.map +1 -1
- package/dist/src/agent/memory/memory-config.d.ts +1 -1
- package/dist/src/agent/memory/memory-config.js +3 -3
- package/dist/src/agent/memory/memory-config.js.map +1 -1
- package/dist/src/agent/memory/sensitivity.d.ts +3 -0
- package/dist/src/agent/memory/sensitivity.js +13 -0
- package/dist/src/agent/memory/sensitivity.js.map +1 -0
- package/dist/src/agent/memory/understanding/service.js +10 -14
- package/dist/src/agent/memory/understanding/service.js.map +1 -1
- package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -0
- package/dist/src/agent/memory/user-context-coordinator.js +2 -0
- package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +8 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/service/btw-query.d.ts +4 -0
- package/dist/src/agent/service/btw-query.js +94 -13
- package/dist/src/agent/service/btw-query.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +9 -1
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +3 -12
- package/dist/src/agent/tools/dreaming-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.js +14 -2
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/memory-tool.d.ts +3 -0
- package/dist/src/agent/tools/memory-tool.js +6 -3
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/agent/tools/session-search-tool.js +2 -2
- package/dist/src/agent/tools/session-search-tool.js.map +1 -1
- package/dist/src/agent/tools/web-extract.js +2 -2
- package/dist/src/agent/tools/web-extract.js.map +1 -1
- package/dist/src/agent/workspace-runtime/registry.d.ts +6 -6
- package/dist/src/agent/workspace-runtime/registry.js +19 -12
- package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
- package/dist/src/agent-manifest/schema.d.ts +4 -0
- package/dist/src/agent-manifest/schema.js +2 -1
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +2 -1
- package/dist/src/ai-assist/text-assist.js +10 -23
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/auth/credentials.js +5 -2
- package/dist/src/auth/credentials.js.map +1 -1
- package/dist/src/auth/oauth/github-copilot.d.ts +3 -4
- package/dist/src/auth/oauth/github-copilot.js +66 -2
- package/dist/src/auth/oauth/github-copilot.js.map +1 -0
- package/dist/src/auth/oauth/index.js +2 -2
- package/dist/src/automations/draft/automation-draft-service.js +3 -3
- package/dist/src/automations/draft/automation-draft-service.js.map +1 -1
- package/dist/src/chat-commands/builtins/review.js +22 -5
- package/dist/src/chat-commands/builtins/review.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +4 -0
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -0
- package/dist/src/gateway/hono/routes/dreaming.js +28 -21
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +16 -4
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -0
- package/dist/src/gateway/hono/routes/models.js.map +1 -1
- package/dist/src/gateway/hono/routes/voice.js +2 -2
- package/dist/src/gateway/hono/routes/voice.js.map +1 -1
- package/dist/src/goals/goal-contract-draft.js +2 -2
- package/dist/src/goals/goal-contract-draft.js.map +1 -1
- package/dist/src/goals/goal-evidence-review.js +2 -2
- package/dist/src/goals/goal-evidence-review.js.map +1 -1
- package/dist/src/notes/service.js +2 -2
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/providers/constants.d.ts +2 -0
- package/dist/src/providers/constants.js +11 -0
- package/dist/src/providers/constants.js.map +1 -0
- package/dist/src/providers/extension-stream-bridge.js +1 -0
- package/dist/src/providers/extension-stream-bridge.js.map +1 -1
- package/dist/src/providers/index.d.ts +3 -3
- package/dist/src/providers/index.js +5 -4
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-call.d.ts +17 -0
- package/dist/src/providers/model-call.js +60 -0
- package/dist/src/providers/model-call.js.map +1 -0
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/session-title.js.map +1 -1
- package/dist/src/storage/sqlite/fts.d.ts +6 -0
- package/dist/src/storage/sqlite/fts.js +70 -1
- package/dist/src/storage/sqlite/fts.js.map +1 -1
- package/dist/src/storage/sqlite/memory-index-repository.js +16 -7
- package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +55 -8
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/dist/src/voice/tts/summarize.js +2 -2
- package/dist/src/voice/tts/summarize.js.map +1 -1
- package/dist/src/workflows/draft/workflow-draft-service.js +2 -2
- package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agents-Dl9EWnUh.js +0 -2
- package/dist/gateway/static/root/assets/automations-page-CFt5Ik4q.js +0 -4
- package/dist/gateway/static/root/assets/browser-settings-page-ColJPwer.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-BDLHV3Jx.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-EUwWYx8l.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CA752gY8.js +0 -2
- package/dist/gateway/static/root/assets/goal-create-dialog-DVAHnifk.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-BuOEQZn_.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-WV4cHvD-.js +0 -2
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-D51yogNZ.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CL22jleU.js +0 -7
- package/dist/gateway/static/root/assets/messages-DbNQuFdA.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BkV9hDc-.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-BK9yydrL.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-Dd0v-hK2.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-DSPhB3do.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-C-fZk1f7.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BGaVc3t7.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DbnzgQOP.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CuDBoz5k.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-06IYvwDt.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-0ODH0DXl.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-3W2-wDyO.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-BPn1ZEga.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-BQGTTsz1.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-na-N4jZ6.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-CjeVDs4h.js +0 -18
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{a as o,n as s,o as c}from"./fetch-B1WtuprY.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{Br as d,Cc as f,Co as p,Ds as m,Es as h,Ga as g,Hr as _,Ja as v,Ka as y,Lc as b,Lr as x,Ml as S,Mo as C,No as w,Oo as T,Rr as E,Rs as D,Si as O,Ua as k,Wa as A,Wo as j,Xa as M,Ya as ee,Ys as N,ai as P,bo as F,cc as I,co as L,ds as R,gs as te,ii as ne,io as z,kc as re,ko as B,ks as V,lo as ie,ni as ae,nl as oe,oi as se,oo as H,ps as ce,qa as U,qc as le,ri as ue,sl as de,ss as fe,va as pe,vo as me,ya as he,zr as ge}from"./index-DcUaXYeb.js";import{n as _e,t as ve}from"./settings-form-section-CvfzhBV-.js";import{t as ye}from"./page-tabs-D_8jGlqx.js";var W=e(t(),1),G=n(),K=r(),q=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,be=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function xe(e,t){return t.some(t=>t.connectorId===e.id)}function J(e,t){return t[e]??e}function Y(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,J(e,t.connectorCategoryLabels))}function Se(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,q)}),(0,K.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,q)})]}),(0,K.jsx)(`div`,{className:i(`h-3 w-full`,q)}),(0,K.jsx)(`div`,{className:i(`h-3 w-[88%]`,q)})]})})}),e[0]=t):t=e[0],t}function Ce(){let e=(0,G.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,K.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,q)}),(0,K.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,q)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,K.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,q)}),(0,K.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,q)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,K.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,K.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,q)}),(0,K.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,q)}),(0,K.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,q)})]}),(0,K.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,q)})]}),e[2]=r):r=e[2],r}function we(e){let t=(0,G.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=Y(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,v,y;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),b;t[20]!==n||t[21]!==a||t[22]!==s.install?(b=e=>(0,K.jsxs)(B,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,K.jsx)(D,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=b):b=t[23],u=b;let x;t[24]!==n||t[25]!==o?(x=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=x):x=t[26];let S=x,C=o?`cursor-pointer`:null;t[27]===C?g=t[28]:(g=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,C),t[27]=C,t[28]=g),_=o?`button`:void 0,v=o?0:void 0,t[29]!==n||t[30]!==o?(y=()=>o?.(n),t[29]=n,t[30]=o,t[31]=y):y=t[31],d=S,f=`flex min-w-0 flex-1 flex-col`;let w;t[32]===n.displayName?w=t[33]:(w=(0,K.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=w);let T;t[34]===l?T=t[35]:(T=(0,K.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=T);let E;t[36]!==w||t[37]!==T?(E=(0,K.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,K.jsxs)(`div`,{className:`min-w-0`,children:[w,T]})}),t[36]=w,t[37]=T,t[38]=E):E=t[38];let O;t[39]!==r||t[40]!==u?(O=r?null:(0,K.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==s.installedBadge?(k=r?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(oe,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=k):k=t[44];let A;t[45]!==O||t[46]!==k?(A=(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[45]=O,t[46]=k,t[47]=A):A=t[47],t[48]!==E||t[49]!==A?(p=(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[48]=E,t[49]=A,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,K.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(X),c>0?(0,K.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(b=(0,K.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=b):b=t[57];let x;t[58]!==r||t[59]!==u?(x=r?null:(0,K.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=x):x=t[60];let S;return t[61]!==d||t[62]!==b||t[63]!==x||t[64]!==g||t[65]!==_||t[66]!==v||t[67]!==y?(S=(0,K.jsxs)(`div`,{className:g,role:_,tabIndex:v,onClick:y,onKeyDown:d,children:[b,x]}),t[61]=d,t[62]=b,t[63]=x,t[64]=g,t[65]=_,t[66]=v,t[67]=y,t[68]=S):S=t[68],S}function X(e){return(0,K.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Te(){return Z(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Ee(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Z(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function De(e,t){return Z(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Oe(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return pe(),Z(r,`Could not install Store connector.`).instance}async function ke(){return Z(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Ae(){return Z(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var je=new Map,Me=300*1e3;async function Ne(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=je.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Z(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});je.set(u,{expiresAt:d+Me,promise:m});try{return await m}catch(e){throw je.delete(u),e}}async function Pe(e){return Z(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Fe(e,t){return Z(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Ie(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return pe(),Z(n,`Could not install connector.`).instance}async function Le(e,t={}){return Z(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Re(e,t){return Z(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function ze(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),pe()}async function Be(e){return Z(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ve(){return Z(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function He(e){return Z(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ue(e){return Z(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function We(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return pe(),Z(n,`Could not update Composio scope.`).scope}async function Ge(e){return Z(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Ke(e=50){return Z(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function Q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function qe(e,t){return t.connectorCapabilityLabels[e]??e}function Je(e,t){if(e.runtime.type===`mcp`)return Q(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return Q(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ye(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Xe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function Ze(e){let t=(0,G.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,K.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(Qe),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,K.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,K.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,K.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Qe(e){return(0,K.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,K.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,K.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function $e({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),f=Xe(e),m=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-m.length),_=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],x=async()=>{s(!0),d(null);try{l(await Le(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,K.jsx)(v,{open:!0,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(U,{children:[(0,K.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,K.jsxs)(A,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,K.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(oe,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,K.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,K.jsx)(g,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,p.focusRingPanel),"aria-label":a.modalClose,children:[(0,K.jsx)(C,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,K.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?Q(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,K.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ye(e,a)})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,K.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Q(a.connectorRequiredInputsCount,{count:f})})]})]}),(0,K.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,K.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:qe(e,a)},e)),h>0?(0,K.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]}),(0,K.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,K.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,K.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,K.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,K.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,K.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,K.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(Ze,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,K.jsx)(Ze,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,K.jsx)(Ze,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Q(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,K.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,K.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,K.jsxs)(`aside`,{className:`space-y-3`,children:[(0,K.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,K.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,K.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ye(e,a)})]}),(0,K.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,K.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),_.length>0?(0,K.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:_.map(e=>(0,K.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,K.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,K.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,K.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,K.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,K.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Je(e,a)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsx)(B,{variant:`secondary`,children:a.modalClose})}),(0,K.jsxs)(B,{variant:`secondary`,disabled:o,onClick:()=>void x(),children:[o?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(w,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,K.jsxs)(B,{variant:`secondary`,disabled:!0,children:[(0,K.jsx)(V,{className:`size-4`}),a.installedBadge]}):(0,K.jsxs)(B,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,K.jsx)(D,{className:`size-4`}),a.install]})]})]})]})})}var et=(0,W.memo)(function(e){let t=(0,G.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,K.jsx)(O,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(ce,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,K.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,K.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,K.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let g;t[12]!==c||t[13]!==o?(g=(0,K.jsxs)(B,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=g):g=t[14];let _;return t[15]!==u||t[16]!==p||t[17]!==g?(_=(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,g]}),t[15]=u,t[16]=p,t[17]=g,t[18]=_):_=t[18],_}),tt=/^([^:=]+)[:=](.*)$/;function nt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=tt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function rt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function it(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function at(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function ot(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||at(t)&&(r[e]=t);return r}function st(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ct(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function lt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=st(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ct(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=rt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ut(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:it(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function dt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function ft(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||at(t)?[]:[ut(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function pt(e){return lt(e)}async function mt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=lt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),pe()}function ht(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function gt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function _t(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function vt(e,t){let n=await s(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=ht(n.payload.tools),i=gt(n.payload.resources),a=_t(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function yt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function bt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function xt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function St({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),p=xt(e),m=(0,W.useCallback)(async()=>{o(!0),f(null);try{let t=await vt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,W.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,K.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,K.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,K.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,K.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,K.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,K.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,K.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(B,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),t.testConnection]}),(0,K.jsxs)(B,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(j,{className:`size-4`}),t.removeServer]})]})]})]})}function Ct(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function wt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Ct(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase().includes(r)}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e){let t=(0,G.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,W.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>wt(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,K.jsx)(ce,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,T),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,K.jsxs)(`div`,{className:`relative`,children:[p,(0,K.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,K.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,K.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==o||t[24]!==r?(y=(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Tt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,K.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,K.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Dt(e){let t=(0,G.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,K.jsx)(y,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ie)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,L,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,K.jsx)(w,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let b;t[3]===o?b=t[4]:(b=(0,K.jsxs)(ee,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,o]}),t[3]=o,t[4]=b);let x;t[5]!==a||t[6]!==s||t[7]!==f.length?(x=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=x):x=t[8];let S;t[9]===x?S=t[10]:(S=(0,K.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[9]=x,t[10]=S);let T;t[11]!==b||t[12]!==S?(T=(0,K.jsxs)(`div`,{className:`min-w-0`,children:[b,S]}),t[11]=b,t[12]=S,t[13]=T):T=t[13];let E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,K.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[14]=E):E=t[14];let D;t[15]===d?D=t[16]:(D=(0,K.jsx)(k,{asChild:!0,children:(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:E})}),t[15]=d,t[16]=D);let O;t[17]!==T||t[18]!==D?(O=(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[T,D]}),t[17]=T,t[18]=D,t[19]=O):O=t[19];let j;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==p||t[26]!==f?(j=f.length>0?(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,K.jsx)(Et,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=p,t[26]=f,t[27]=j):j=t[27];let M;t[28]===d?M=t[29]:(M=(0,K.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,K.jsx)(k,{asChild:!0,children:(0,K.jsx)(B,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=M);let N;t[30]!==O||t[31]!==j||t[32]!==M?(N=(0,K.jsxs)(U,{children:[m,(0,K.jsxs)(A,{className:h,children:[O,j,M]})]}),t[30]=O,t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;return t[34]!==r||t[35]!==n||t[36]!==N?(P=(0,K.jsx)(v,{open:n,onOpenChange:r,children:N}),t[34]=r,t[35]=n,t[36]=N,t[37]=P):P=t[37],P}var Ot=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T);function kt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function At(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function jt({instance:e,t}){let n=kt(e),[r,a]=(0,W.useState)([]),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)([]),[u,d]=(0,W.useState)(`read`),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),g=(0,W.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([Ve().catch(()=>[]),Ge(n).catch(()=>[]),Ke(20).catch(()=>[]),Ue(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,W.useEffect)(()=>{g()},[g]);let _=(0,W.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await He(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),v=(0,W.useCallback)(async e=>{if(n){d(e);try{await We(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,K.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,K.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:n})}),(0,K.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsxs)(z,{className:i(Ot,`h-9 w-28 py-1`),value:u,onChange:e=>void v(e.currentTarget.value),children:[(0,K.jsx)(H,{value:`read`,children:t.composioScopeRead}),(0,K.jsx)(H,{value:`write`,children:t.composioScopeWrite}),(0,K.jsx)(H,{value:`admin`,children:t.composioScopeAdmin})]}),(0,K.jsxs)(B,{variant:`secondary`,disabled:f,onClick:()=>void _(),children:[f?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(I,{className:`size-4`}),t.connectOAuth]}),(0,K.jsx)(B,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,K.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,K.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,K.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,K.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,K.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[At(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,K.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,K.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Mt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T);function Nt(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function Pt(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Ft(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function It(e){let t=(0,G.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,K.jsx)(ne,{delayDuration:300,skipDelayDuration:100,children:(0,K.jsxs)(P,{children:[(0,K.jsx)(se,{asChild:!0,children:(0,K.jsx)(`p`,{tabIndex:0,title:r,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,K.jsx)(ue,{children:(0,K.jsx)(ae,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,K.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,K.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===a?l=t[5]:(l=a?(0,K.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function Lt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),[_,x]=(0,W.useState)(`health`),[S,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(()=>Pt(t,e)),[O,M]=(0,W.useState)(null),P=t?.setup.config??[],F=e.materialized.type===`mcp`&&P.length>0&&(t?.setup.secrets??[]).length===0,L=m?m.toolCount:e.usage.lastToolCount,R=(0,W.useMemo)(()=>{let t=[[`health`,fe,a.detailHealth],[`tools`,w,`${a.detailTools} ${m?m.toolCount:e.usage.lastToolCount??``}`],[`resources`,b,`${a.detailResources} ${m?m.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,re,`${a.detailPrompts} ${m?m.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,I,a.detailPermissions]];return F?[...t,[`config`,b,a.tabConfig]]:t},[m,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,F,a]),ne=(0,W.useCallback)(async()=>{c(!0),M(null);try{let t=await Be(e.instanceId);h(t),t.toolCount>0&&x(`tools`),r()}catch(e){M(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),z=(0,W.useCallback)(async()=>{u(!0),M(null);try{await ze(e.instanceId),await r(),n()}catch(e){M(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ie=(0,W.useCallback)(async()=>{if(!(!t||!F)){f(!0),M(null);try{let n={};for(let e of t.setup.config??[]){let t=Ft(e.type,E[e.key]??``);t!==void 0&&(n[e.key]=t)}await Re(e.instanceId,{config:n}),await r(),x(`health`)}catch(e){M(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[E,t,e.instanceId,r,F]);return(0,K.jsxs)(v,{open:!0,onOpenChange:e=>{e||n()},children:[(0,K.jsxs)(U,{children:[(0,K.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,K.jsxs)(A,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,K.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?$(a.mcpServerRuntime,{serverId:e.materialized.serverId}):$(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,p.focusRingPanel),"aria-label":a.modalClose,children:[(0,K.jsx)(C,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[O?(0,K.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:O}):null,(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:R.map(([e,t,n])=>(0,K.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,_===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>x(e),children:[(0,K.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,K.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[_===`health`?(0,K.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,K.jsxs)(`p`,{children:[a.statusLabel,` `,(0,K.jsx)(`span`,{className:m?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Nt(m?.status??e.usage.lastHealthStatus,a)})]}),(0,K.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),m?.action?(0,K.jsx)(`p`,{children:m.action}):null]}):null,_===`tools`?m?.tools.length?(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(a.toolsAvailable,{count:String(m.tools.length)})}),(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>T(!0),children:o.viewAllTools})]}),(0,K.jsx)(`div`,{className:`grid gap-2`,children:m.tools.slice(0,8).map(e=>(0,K.jsx)(It,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-fg-muted`,children:L?$(a.toolsLastCheckSummary,{count:String(L)}):a.toolsRunTestHint}),(0,K.jsxs)(B,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void ne(),children:[s?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),a.test]})]}):null,_===`resources`?m?.resources.length?(0,K.jsx)(`div`,{className:`grid gap-2`,children:m.resources.slice(0,8).map(e=>(0,K.jsx)(It,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,K.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,_===`prompts`?m?.prompts.length?(0,K.jsx)(`div`,{className:`grid gap-2`,children:m.prompts.slice(0,8).map(e=>(0,K.jsx)(It,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,K.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,_===`permissions`?(0,K.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,K.jsx)(`p`,{children:$(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,K.jsx)(`p`,{children:e.materialized.type===`mcp`?$(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,K.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,_===`config`&&F?(0,K.jsx)(`div`,{className:`grid gap-3`,children:P.map(e=>(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,K.jsx)(`input`,{className:Mt,value:E[e.key]??``,placeholder:e.placeholder,onChange:t=>D(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,K.jsx)(jt,{instance:e,t:a}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,K.jsx)(B,{variant:`secondary`,onClick:n,children:a.modalClose}),_===`config`&&F?(0,K.jsxs)(B,{variant:`primary`,disabled:d,onClick:()=>void ie(),children:[d?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(te,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,K.jsxs)(B,{variant:`secondary`,disabled:s,onClick:()=>void ne(),children:[s?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),a.test]}):null,(0,K.jsxs)(B,{variant:`ghost`,disabled:l,onClick:()=>void z(),children:[l?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(j,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,K.jsx)(Dt,{open:S,onOpenChange:T,serverId:e.materialized.serverId,title:$(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:m?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Rt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),d=(0,W.useCallback)(async()=>{o(!0),u(null);try{await Be(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),f=(0,W.useCallback)(async()=>{c(!0),u(null);try{await ze(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),p=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,m=e.usage.lastToolCount??0,h=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,K.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:()=>n(e),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(oe,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),h?(0,K.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,K.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type})}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,K.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,p]}),(0,K.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(i.toolsAvailable,{count:String(m)})})]}),l?(0,K.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,K.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,K.jsxs)(B,{variant:`secondary`,disabled:a,onClick:()=>void d(),children:[a?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),i.test]}):null,(0,K.jsxs)(B,{variant:`ghost`,disabled:s,onClick:()=>void f(),children:[s?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(j,{className:`size-4`}),i.remove]})]})]})]})}var zt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T),Bt=i(zt,`min-h-28 font-mono`);function Vt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Ht(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Ut(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`},...t?{store:t}:{}}}function Wt(e){let t=(0,G.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,K.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(Gt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,K.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,K.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Gt(e){return(0,K.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,K.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,K.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Kt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,W.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Pe(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,W.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Fe(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),d=(0,W.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Ht(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await Oe(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Ie(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await Be(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,K.jsx)(v,{open:!0,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(U,{children:[(0,K.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,K.jsxs)(A,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(ee,{className:`text-base font-semibold text-fg`,children:$(a.installDialogTitle,{name:o.displayName})}),(0,K.jsx)(g,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,p.focusRingPanel),"aria-label":a.modalClose,children:[(0,K.jsx)(C,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,K.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,K.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,K.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,K.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,K.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`p`,{children:$(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,K.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,K.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(B,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),a.oauthConnectButton]}),(0,K.jsxs)(B,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(oe,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,e.store?(0,K.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,K.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,K.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,K.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:a.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,K.jsx)(me,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,K.jsx)(`textarea`,{className:Bt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,K.jsx)(`input`,{className:zt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,K.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,K.jsx)(N,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,K.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,K.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium text-fg`,children:$(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:$(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,K.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Vt(e.health?.status,a)})]}),e.health?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,K.jsx)(`div`,{children:a.toolsMetric})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,K.jsx)(`div`,{children:a.resourcesMetric})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,K.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,K.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,K.jsx)(Wt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,K.jsx)(Wt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,K.jsx)(Wt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,K.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,K.jsxs)(B,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void d(),children:[e.installing?(0,K.jsx)(N,{className:`size-4 animate-spin`}):e.result?(0,K.jsx)(oe,{className:`size-4`}):(0,K.jsx)(D,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function qt(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return dt(r)}function Jt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Yt(e,t,n){return e.filter(e=>Jt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Xt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Zt(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Qt(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function $t(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T)}function en({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},m=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await F();if(!e){window.alert(o);return}let t=nt(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,K.jsx)(`span`,{children:e}),t?(0,K.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,K.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,K.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{className:i($t(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,K.jsx)(`input`,{className:i($t(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,K.jsx)(j,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Qt(e,t,l)))}),(0,K.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,p.press),onClick:f,children:[`+ `,n]})]})}var tn=[`stdio`,`sse`,`streamable-http`];function nn(e){let t=(0,G.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,K.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,K.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function rn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T)}function an(e){let t=(0,G.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nn,{label:r.transportLabel,required:!0,children:(0,K.jsx)(z,{className:rn(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:tn.map(e=>(0,K.jsx)(H,{value:e,children:r.transportLabels[e]},e))})}),(0,K.jsxs)(nn,{label:r.serverIdLabel,required:!0,children:[(0,K.jsx)(`input`,{className:rn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,K.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,K.jsxs)(K.Fragment,{children:[l?(0,K.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,K.jsx)(nn,{label:r.commandLabel,required:!0,children:(0,K.jsx)(`input`,{className:rn(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nn,{label:r.argsLabel,description:r.argsHint,children:(0,K.jsx)(`input`,{className:rn(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,K.jsx)(nn,{label:r.cwdLabel,children:(0,K.jsx)(`input`,{className:rn(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,K.jsx)(nn,{label:r.envLabel,description:r.envHint,children:(0,K.jsx)(`textarea`,{className:i(rn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,K.jsxs)(K.Fragment,{children:[l?(0,K.jsx)(`div`,{className:`md:col-span-2`,children:(0,K.jsx)(nn,{label:r.urlLabel,required:!0,children:(0,K.jsx)(`input`,{className:i(rn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,K.jsx)(en,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,K.jsx)(nn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,K.jsx)(`input`,{type:`number`,min:1,max:600,className:rn(),value:yt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:bt(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,K.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function on(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function sn(e){let t=(0,G.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=on(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,K.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,K.jsx)(ne,{delayDuration:300,skipDelayDuration:100,children:(0,K.jsxs)(P,{children:[(0,K.jsx)(se,{asChild:!0,children:(0,K.jsx)(`p`,{tabIndex:0,title:l,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,K.jsx)(ue,{children:(0,K.jsx)(ae,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,K.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,K.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function cn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,m]=(0,W.useState)(n),[h,_]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(!1),[O,j]=(0,W.useState)({status:`idle`}),[M,P]=(0,W.useState)(null),F=n.id.trim(),I=f.id.trim()!==F&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,L=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,te=f.id.trim().length>0&&!I&&!L&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),ne=xt(f),z=(0,W.useCallback)(async()=>{if(f.id.trim()){x(!0),T(null),j({status:`loading`});try{j({status:`ok`,tools:(await vt(f.id.trim(),pt(f))).tools})}catch(e){j({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},[f]),re=(0,W.useCallback)(async()=>{if(!(!te||h)){_(!0),T(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await mt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ot(o)),await d(),u()}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[te,o,r,n.clientKey,t,u,d,F,f,h,a]);return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(v,{open:e,onOpenChange:e=>{e||u()},children:(0,K.jsxs)(U,{children:[(0,K.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,K.jsxs)(A,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,K.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,p.focusRingPanel),"aria-label":l.modalClose,children:[(0,K.jsx)(C,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,K.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,K.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ne||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,K.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,K.jsx)(an,{row:f,t:c,variant:`basic`,onUpdate:e=>{m(t=>({...t,...e})),T(null)},idConflictMessage:I??L})]}),O.status===`ok`?(0,K.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,K.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),O.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(O.tools.length))]}),O.tools.length>0?(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>P(O.tools),children:c.viewAllTools}):null]}),O.tools.length>0?(0,K.jsx)(`div`,{className:`mt-3 grid gap-2`,children:O.tools.slice(0,6).map((e,t)=>(0,K.jsx)(sn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,O.status===`error`?(0,K.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:O.message}):null,S?(0,K.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,K.jsxs)(`details`,{open:E,onToggle:e=>D(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(de,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,K.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,K.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,K.jsx)(an,{row:f,t:c,variant:`advanced`,onUpdate:e=>{m(t=>({...t,...e})),T(null)}})})]})]})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,K.jsxs)(B,{variant:`secondary`,disabled:!f.id.trim()||b,onClick:()=>void z(),children:[b?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(V,{className:`size-4`}),c.testConnection]}),(0,K.jsx)(k,{asChild:!0,children:(0,K.jsx)(B,{variant:`secondary`,children:l.modalCancel})}),(0,K.jsxs)(B,{variant:`primary`,disabled:!te||h,onClick:()=>void re(),children:[h?(0,K.jsx)(N,{className:`size-4 animate-spin`}):(0,K.jsx)(oe,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),M?(0,K.jsx)(Dt,{open:!0,onOpenChange:e=>{e||P(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:M,stripPrefix:`${f.id.trim()}__`}):null]}):null}var ln=`mprov`,un=`xopc-store`,dn=un,fn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T);function pn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function mn(){let e=a(l(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=o(e=>e.token),s=!!r,[c,h]=S(),g=c.get(ln)?.trim()||dn,[v,y]=(0,W.useState)(`marketplace`),[b,C]=(0,W.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[w,T]=(0,W.useState)(!1),[D,O]=(0,W.useState)(!1),[k,A]=(0,W.useState)(1),[j,ee]=(0,W.useState)(void 0),[P,F]=(0,W.useState)(``),[I,L]=(0,W.useState)(g),[R,te]=(0,W.useState)(`name`),[ne,z]=(0,W.useState)(null),[re,V]=(0,W.useState)(null),[ie,ae]=(0,W.useState)(null),[oe,se]=(0,W.useState)(null),[H,ce]=(0,W.useState)(null),[U,le]=(0,W.useState)(void 0),[ue,fe]=(0,W.useState)(!1),[pe,me]=(0,W.useState)(!1),{data:G,mutate:q}=he(s),J=G?.payload?.config,Y=(0,W.useMemo)(()=>J===void 0?null:ft(J),[J]),X=Y?.servers??[];(0,W.useEffect)(()=>{Y&&le(Y.sessionIdleTtlMinutes)},[Y]);let Z=(0,W.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Te(),Ae(),ke()]);C(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,W.useEffect)(()=>{Z()},[Z]);let Oe=c.toString(),je=(0,W.useRef)(Oe);(0,W.useEffect)(()=>{je.current!==Oe&&(je.current=Oe,L(c.get(ln)?.trim()||dn))},[c,Oe]);let Me=(0,W.useMemo)(()=>[{id:un,displayName:t.storeSourceName},...b.registries],[t.storeSourceName,b.registries]);(0,W.useEffect)(()=>{if(Me.length===0||Me.some(e=>e.id===I))return;let e=Me.some(e=>e.id===dn)?dn:Me[0]?.id;e&&L(e)},[Me,I]),(0,W.useEffect)(()=>{if(!I||I===c.get(ln))return;let e=new URLSearchParams(c);e.set(ln,I),je.current=e.toString(),h(e,{replace:!0})},[I,c,h]);let Pe=(0,W.useCallback)(async e=>{let t=P.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!s||I!==un&&!t&&!n)){T(!0),i?C(e=>({...e,error:null})):(A(1),ee(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=I===un?await Ee({q:t||void 0,page:r,pageSize:24,sort:R===`source`?`newest`:`downloads`}).then(e=>({connectors:e.items.map(pn),totalPages:e.meta.totalPages})):await Ne(t,I,{browse:n,page:r});A(r),ee(e.totalPages),C(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[R,s,P,I]);(0,W.useEffect)(()=>{if(v!==`marketplace`)return;let e=window.setTimeout(()=>{P.trim()?Pe():I&&Pe({browse:!0})},P.trim()?350:0);return()=>window.clearTimeout(e)},[I,P,Pe,b.loading,v]);let Fe=(0,W.useMemo)(()=>new Set(b.instances.map(e=>e.connectorId)),[b.instances]),Ie=(0,W.useMemo)(()=>new Map([...b.catalog,...b.registryCatalog].map(e=>[e.id,e])),[b.catalog,b.registryCatalog]),Le=(0,W.useCallback)(async e=>{O(!0),C(e=>({...e,error:null}));try{let n=await De(e);if(n.requiresOAuth&&n.definition.id!==`github`)throw Error(t.storeOAuthUnsupported);z(Ut(n.definition,{packageName:n.packageName,version:n.version,permissions:n.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}},[t.storeOAuthUnsupported]),Re=(0,W.useMemo)(()=>new Set(b.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[b.instances]),ze=(0,W.useCallback)(async e=>{if(!Y||J===void 0)return;let t=X.filter(t=>t.clientKey!==e.clientKey);await mt({sessionIdleTtlMinutes:Y.sessionIdleTtlMinutes,servers:t},ot(J)),await q(),await Z()},[J,X,Z,Y,q]),Be=(0,W.useCallback)(()=>{ce({mode:`add`,row:qt(X,Re)})},[X,Re]),Ve=(0,W.useCallback)(async()=>{if(!(!Y||J===void 0||ue)){fe(!0),me(!1);try{await mt({sessionIdleTtlMinutes:U,servers:X},ot(J)),await q(),me(!0),u({type:`success`,title:n.saved})}finally{fe(!1)}}},[J,X,Y,q,U,ue]),He=M(e=>e.setPageHeader),Ue=M(e=>e.clearPageHeader),We=(0,W.useMemo)(()=>(0,K.jsx)(et,{loading:b.loading||w||D,searchQuery:P,setSearchQuery:F,onReloadClick:Z,onAddCustomServer:Be,searchPlaceholder:v===`marketplace`?t.marketplaceSearchPlaceholder:v===`builtin`?t.builtinSearchPlaceholder:v===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,Z,Be,w,P,b.loading,D,v]);(0,W.useLayoutEffect)(()=>(He({startExtra:null,main:(0,K.jsx)(`div`,{className:`min-w-0`,children:(0,K.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:We}),()=>Ue()),[Ue,t.title,We,He]);let Ge=b.instances.length+X.length,Ke=(0,W.useMemo)(()=>Yt(b.catalog.filter(e=>e.source===`builtin`),P,R),[R,P,b.catalog]),Q=(0,W.useMemo)(()=>Yt(b.registryCatalog,P,R),[R,P,b.registryCatalog]),qe=v===`marketplace`&&!!(j&&k<j),Je=(0,W.useMemo)(()=>b.instances.filter(e=>Xt(e,P)),[P,b.instances]),Ye=(0,W.useMemo)(()=>X.filter(e=>Zt(e,P)),[X,P]),Xe=(0,W.useMemo)(()=>b.instances.find(e=>e.instanceId===ie)??oe,[ie,oe,b.instances]),Ze=Je.length+Ye.length,Qe=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Ke.length},{id:`user`,label:t.tabUser,count:Ge},{id:`config`,label:t.tabConfig}];return(0,K.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[s?null:(0,K.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,K.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,K.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:[(0,K.jsx)(ye,{items:Qe,activeTab:v,onChange:y,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,K.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[v===`marketplace`?(0,K.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:Me.map(e=>(0,K.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,p.focusRingPanel,I===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":I===e.id,onClick:()=>L(e.id),children:e.displayName},e.id))}):null,v!==`user`&&v!==`config`?(0,K.jsxs)(d,{children:[(0,K.jsx)(_,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,p.transition,p.focusRingPanel),children:[(0,K.jsx)(f,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,K.jsx)(`span`,{children:R===`name`?t.sortName:t.sortSource}),(0,K.jsx)(de,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,K.jsx)(ge,{children:(0,K.jsxs)(x,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,K.jsx)(E,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>te(`name`),children:t.sortName}),(0,K.jsx)(E,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>te(`source`),children:t.sortSource})]})})]}):null]})]}),b.error?(0,K.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b.error}):null,v===`user`&&s?(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),b.loading?(0,K.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:be.slice(0,3).map(e=>(0,K.jsx)(Ce,{},e))}):Ge===0||Ze===0?(0,K.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:Ge===0?t.installedEmpty:t.userEmpty}):(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Je.map(e=>(0,K.jsx)(Rt,{instance:e,definition:Ie.get(e.connectorId),onOpenDetails:e=>{ae(e.instanceId),se(e)},onChanged:Z,t},e.instanceId)),Ye.map(e=>(0,K.jsx)(St,{row:e,t:n,cs:t,onEdit:()=>ce({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ze(e)},e.clientKey))]}),(0,K.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,v===`config`&&s?(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,K.jsxs)(ve,{children:[(0,K.jsx)(_e,{icon:m,title:n.globalTitle,subtitle:n.globalHint}),(0,K.jsx)(`div`,{className:`max-w-xl`,children:(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:0,className:i(fn,`w-40 flex-none`),value:U??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();le(t===``?void 0:Number.parseInt(t,10)),me(!1)}}),(0,K.jsxs)(B,{variant:`secondary`,disabled:ue,onClick:()=>void Ve(),children:[ue?(0,K.jsx)(N,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,v===`marketplace`&&s?(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:w&&Q.length===0?(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:be.map(e=>(0,K.jsx)(Se,{},e))}):P.trim()&&Q.length===0?(0,K.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!P.trim()&&Q.length===0?(0,K.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,K.jsxs)(`div`,{className:`relative`,children:[w?(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,K.jsx)(N,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Q.map(e=>(0,K.jsx)(we,{connector:e,installed:Fe.has(e.id)||xe(e,b.instances),onInstall:e=>{if(e.source===`store`){Le(e.id);return}z(Ut(e))},onOpenDetails:e.source===`store`?void 0:V,t},e.id))}),qe?(0,K.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,K.jsxs)(B,{type:`button`,variant:`secondary`,disabled:w||D,onClick:()=>void Pe({browse:!P.trim(),page:k+1,append:!0}),children:[w?(0,K.jsx)(N,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,v===`builtin`&&s?(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:b.loading?(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:be.map(e=>(0,K.jsx)(Se,{},e))}):Ke.length===0?(0,K.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ke.map(e=>(0,K.jsx)(we,{connector:e,installed:Fe.has(e.id)||xe(e,b.instances),onInstall:e=>z(Ut(e)),onOpenDetails:V,t},e.id))})}):null]}),ne?(0,K.jsx)(Kt,{draft:ne,onChange:z,onClose:()=>z(null),t,onInstalled:async()=>{await Z(),await q(),y(`user`)}}):null,re?(0,K.jsx)($e,{connector:re,installed:Fe.has(re.id)||xe(re,b.instances),onClose:()=>V(null),onInstall:e=>z(Ut(e)),t}):null,Xe?(0,K.jsx)(Lt,{instance:Xe,definition:Ie.get(Xe.connectorId),onClose:()=>{ae(null),se(null)},onChanged:Z,t,mcp:n}):null,H?(0,K.jsx)(cn,{open:!0,mode:H.mode,initialRow:H.row,existingCustomServers:X,sessionIdleTtlMinutes:U,config:J,managedServerIds:Re,t:n,cs:t,onClose:()=>ce(null),onSaved:async()=>{await q(),await Z(),y(`user`)}},`${H.mode}-${H.row.clientKey}`):null]})})}export{mn as ConnectorsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-BXNELNBa.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Mo as o,sl as s,t as c}from"./index-DcUaXYeb.js";import{t as l}from"./desktop-pet-sprite-DqZ6fbIj.js";var u=e(t(),1),d=n();function f(e){return e?`/chat/${e.sessionKey}`:void 0}var p=r(),m=8e3,h=9e4,g=3e4,_=20*6e4,v=45*6e4,y=58;function b(e){let t={error:0,waiting:1,running:2,success:3};return e.sort((e,n)=>t[e.state]-t[n.state]||n.timestamp-e.timestamp).slice(0,3)}function x(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=h}function S(e,t){return e.state===`running`&&t-e.timestamp>=g}function C(e,t,n){return S(e,n)||t===`chatty`||x(e,n)&&t===`normal`?!0:t===`quiet`?e.priority===`high`||e.state===`waiting`||e.state===`error`:e.priority!==`low`}function w(e){return e?e.state===`error`?`error`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function T(e,t){return e.replace(/\{\{detail\}\}/g,t)}function E(e){return e.replace(/\s+/g,` `).trim()}function D(e){let t=E(e);return t.length>y?`${t.slice(0,y-1)}…`:t}function O(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.outputLines?.length?T(n,e.outputLines[Math.floor((t-e.timestamp)/1800)%e.outputLines.length]):e.outputTail?T(n,e.outputTail):e.detail&&!e.action.includes(e.detail)?T(n,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function k(e,t){if(e.state!==`success`)return;let n=e.outputLines?.map(E).filter(Boolean).at(-1)??e.outputTail;if(n)return t.replace(/\{\{summary\}\}/g,D(n))}function A(e,t,n){if(S(e,t))return n.stale;if(x(e,t))return n.longRunning}function j(e,t){if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function M(e){let t=e.now-e.lastActivityAt;return e.bubbleEnabled&&e.feedbackLevel!==`quiet`&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&t>=_&&t<=1245e3&&e.now>=e.dismissedUntil}function N(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function P(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(N),[r,c]=(0,u.useState)({}),[d,h]=(0,u.useState)(()=>new Set),[g,_]=(0,u.useState)(Date.now()),[y,x]=(0,u.useState)(()=>Date.now()),[S,T]=(0,u.useState)(0),E=(0,u.useRef)(null),D=(0,u.useRef)(!1),P=(0,u.useRef)(null),F=(0,u.useRef)(null),I=(0,u.useRef)(null),L=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),R=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),z=(0,u.useMemo)(()=>b(Object.values(r).filter(e=>!e.expiresAt||e.expiresAt>g)),[r,g]),B=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>!d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)):[],[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),V=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)).length:0,[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),H=B[0]??z[0],U=w(H),W=M({bubbleEnabled:t.prefs.bubbleEnabled,feedbackLevel:t.prefs.feedbackLevel,collapsed:t.prefs.collapsed,queuedCount:B.length,activeCount:z.length,now:g,lastActivityAt:y,dismissedUntil:S});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;e.getState().then(n).catch(()=>{});let t=e.onStateChanged(n),r=e.onEvent(e=>c(t=>{x(Date.now());let n=t[e.sessionKey];return n&&e.sequence<=n.sequence?t:{...t,[e.sessionKey]:{...n,...e,startedAt:n?.startedAt??e.timestamp,outputLines:e.outputLines??n?.outputLines,expiresAt:e.state===`success`?Date.now()+m:void 0}}})),i=window.setInterval(()=>_(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,t(),r(),window.clearInterval(i)}},[]),(0,u.useLayoutEffect)(()=>{let e=P.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[F.current,I.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),F.current&&r.observe(F.current),I.current&&r.observe(I.current),n(),()=>r.disconnect()},[W,B.length,t.prefs.collapsed,R]);let G=(e=H)=>{e?.state===`success`&&c(t=>{let{[e.sessionKey]:n,...r}=t;return r}),window.electronAPI?.pet?.openMainWindow(f(e))},K=async()=>{if(d.size>0&&(h(new Set),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},q=(0,u.useCallback)(e=>{e.button===0&&(E.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),J=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Y=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(D.current=!0,window.setTimeout(()=>{D.current=!1},0)))},[]),X=()=>{D.current||G()},Z=()=>{window.electronAPI?.pet?.hide()};if(!L)return null;let Q={"--desktop-pet-stage-size":`${Math.round(132*R)}px`,"--desktop-pet-menu-size":`${Math.round(28*R)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*R)}px`},$=t.prefs.collapsed?B.length:V;return(0,p.jsxs)(`div`,{ref:P,className:`desktop-pet-window`,style:Q,children:[!t.prefs.collapsed&&B.length>0?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue`,children:B.map(t=>{let n=A(t,g,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=k(t,e.tipCompleteSummary),i=j(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(t),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:t.sessionLabel}),(0,p.jsxs)(`span`,{children:[r??n??t.action,r||n?``:O(t,g,e.tipTargetSuffix)]})]}),i?(0,p.jsx)(`span`,{className:`desktop-pet-session-cta`,children:i}):null]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>h(e=>new Set(e).add(t.sessionKey)),children:(0,p.jsx)(o,{size:12})})]},t.sessionKey)})}):null,W?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:e.idleTipTitle}),(0,p.jsx)(`span`,{children:e.idleTipBody})]})]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>T(Date.now()+v),children:(0,p.jsx)(o,{size:12})})]})}):null,(0,p.jsxs)(`div`,{ref:I,className:`desktop-pet-stage`,children:[(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void K(),"aria-label":e.menu,children:$>0?(0,p.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,p.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-close-button`,onClick:Z,"aria-label":e.hide,title:e.hide,children:(0,p.jsx)(o,{size:14})}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:X,onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,title:e.openApp,children:(0,p.jsx)(l,{pet:L,action:U,displayHeight:Math.round(112*R)})})]})]})}function F(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,p.jsx)(P,{}),e[0]=t):t=e[0],t}export{F as DesktopPetPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Ac as s,As as c,Dl as l,Hs as u,Ja as d,Mo as f,_s as p,bo as m,hs as h,ro as g,tl as _,to as v}from"./index-CrPRlGMg.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-C15zixct.js";var S=n(),C=e(t(),1),w=r();function T(e){let t=(0,S.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,w.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,w.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function E(){let e=a(o(e=>e.language)).desktopPetSettings,t=l(),[n,r]=(0,C.useState)(null),[S,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),k=typeof window<`u`?window.electronAPI?.pet:void 0,A=(0,C.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),j=(0,C.useCallback)(async()=>{if(k){E(!0);try{r(await k.getState())}finally{E(!1)}}},[k]);if((0,C.useEffect)(()=>{if(k)return j(),k.onStateChanged(r)},[k,j]),!d()||!k)return null;if(!n)return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle}),(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:e.loading})]});let M=async e=>{E(!0);try{r(await k.setPrefs(e))}finally{E(!1)}},N=async e=>{e?(await k.show(),r(await k.getState())):r(await k.setPrefs({enabled:!1}))},P=e=>{M({selectedPetId:e})},F=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},I=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},L=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=F(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},R=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),z=()=>{I(e.createChatDraft)},B=t=>{I(R(e.optimizeChatDraft,{id:t.id,name:F(t).name,description:F(t).description,sourcePrompt:L(t)}))},V=t=>{I(R(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},H=D??n.prefs.sizePercent,U=async(e=H)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));O(null),t!==n.prefs.sizePercent&&await M({sizePercent:t})};return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(p,{className:i(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,w.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(T,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:S,onChange:e=>void N(e)}),(0,w.jsx)(T,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:S,onChange:e=>void M({showOnStartup:e})})]}),(0,w.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,w.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,w.jsx)(f,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,m.press),onClick:z,children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),A?(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:F(A).name}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,a=F(t);return(0,w.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3`,children:[(0,w.jsx)(y,{pet:t,action:`idle`,size:`tiny`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:a.name}),t.builtin?null:(0,w.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,w.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:a.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>B(t),children:[(0,w.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,m.press),disabled:r||S,onClick:()=>P(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,w.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,w.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void k.openCustomPetsDir(),children:[e.openFolder,(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,w.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,w.jsx)(_,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,w.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,w.jsx)(`p`,{children:t.reason}),t.details?.length?(0,w.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,m.press),onClick:()=>V(t),children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,w.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,w.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[H,`%`]})]}),(0,w.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:H,onChange:e=>O(Number(e.target.value)),onBlur:()=>void U(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&U()},onPointerUp:()=>void U()})]}),(0,w.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,w.jsx)(T,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:S,onChange:e=>void M({alwaysOnTop:e})}),(0,w.jsx)(T,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:S,onChange:e=>void M({bubbleEnabled:e})})]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,w.jsxs)(v,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void M({feedbackLevel:e.target.value}),children:[(0,w.jsx)(g,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(g,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(g,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{E as DesktopPetSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Al as s,Co as c,Fo as l,Gs as u,Nc as d,Ns as f,Za as p,bs as m,il as h,io as g,oo as _,vs as v}from"./index-DcUaXYeb.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-CKefvbYi.js";var S=n(),C=e(t(),1),w=r();function T(e){let t=(0,S.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,w.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,w.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function E(){let e=a(o(e=>e.language)).desktopPetSettings,t=s(),[n,r]=(0,C.useState)(null),[S,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),k=typeof window<`u`?window.electronAPI?.pet:void 0,A=(0,C.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),j=(0,C.useCallback)(async()=>{if(k){E(!0);try{r(await k.getState())}finally{E(!1)}}},[k]);if((0,C.useEffect)(()=>{if(k)return j(),k.onStateChanged(r)},[k,j]),!p()||!k)return null;if(!n)return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle}),(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:e.loading})]});let M=async e=>{E(!0);try{r(await k.setPrefs(e))}finally{E(!1)}},N=async e=>{e?(await k.show(),r(await k.getState())):r(await k.setPrefs({enabled:!1}))},P=e=>{M({selectedPetId:e})},F=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},I=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},L=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=F(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},R=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),z=()=>{I(e.createChatDraft)},B=t=>{I(R(e.optimizeChatDraft,{id:t.id,name:F(t).name,description:F(t).description,sourcePrompt:L(t)}))},V=t=>{I(R(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},H=D??n.prefs.sizePercent,U=async(e=H)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));O(null),t!==n.prefs.sizePercent&&await M({sizePercent:t})};return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,c.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(m,{className:i(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,c.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,w.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(T,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:S,onChange:e=>void N(e)}),(0,w.jsx)(T,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:S,onChange:e=>void M({showOnStartup:e})})]}),(0,w.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,w.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,w.jsx)(l,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,c.press),onClick:z,children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),A?(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:F(A).name}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,a=F(t);return(0,w.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3`,children:[(0,w.jsx)(y,{pet:t,action:`idle`,size:`tiny`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:a.name}),t.builtin?null:(0,w.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,w.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:a.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,c.press),onClick:()=>B(t),children:[(0,w.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,c.press),disabled:r||S,onClick:()=>P(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,w.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,w.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void k.openCustomPetsDir(),children:[e.openFolder,(0,w.jsx)(d,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,w.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,w.jsx)(h,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,w.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,w.jsx)(`p`,{children:t.reason}),t.details?.length?(0,w.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,c.press),onClick:()=>V(t),children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,w.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,w.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[H,`%`]})]}),(0,w.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:H,onChange:e=>O(Number(e.target.value)),onBlur:()=>void U(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&U()},onPointerUp:()=>void U()})]}),(0,w.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,w.jsx)(T,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:S,onChange:e=>void M({alwaysOnTop:e})}),(0,w.jsx)(T,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:S,onChange:e=>void M({bubbleEnabled:e})})]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,w.jsxs)(g,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void M({feedbackLevel:e.target.value}),children:[(0,w.jsx)(_,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(_,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(_,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,c.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(v,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{E as DesktopPetSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ot as r,kt as i,wt as a}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ot as r,kt as i,wt as a}from"./index-DcUaXYeb.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=r(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(a,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{a as o,n as s,o as c}from"./fetch-BID89uCH.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,Cl as f,Dt as p,Eo as m,Gs as h,Ko as g,Ks as _,Ls as v,So as y,Ts as b,Vo as x,Yn as S,_s as C,es as w,fs as T,ha as E,kl as D,nr as O,ro as k,sc as A,ss as j,to as M}from"./index-CrPRlGMg.js";import{n as ee,r as N,t as P}from"./settings-page-layout-C15zixct.js";import{n as F,t as te}from"./settings-form-section-Cu30CXVl.js";import{t as I}from"./page-tabs-DOfMaq_L.js";import{n as L,t as R}from"./schedule-field-BzM1iyOc.js";import{t as z}from"./format-cron-label-arqgGlVV.js";var B=e(t(),1),V=n();function H(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ne(e){return c(`/api/dreaming${H(e)}`)}async function re(e){let t=await s(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ne(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await s(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await s(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await s(c(`/api/dreaming/preview${H(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await s(c(`/api/dreaming/events${H(t,{limit:e})}`))).payload?.events??[]}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var W={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},G={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},K={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},q={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:W,deep:G,rem:K};function J(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function ce(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=U(e)?e:{},n=U(t.memory)?t.memory:{},r=U(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||U(t.phases)?t:{},a=U(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=U(a.phases)?a.phases:{},s=U(o.light)?o.light:{},c=U(o.deep)?o.deep:{},l=U(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():q.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:J(typeof c.minScore==`number`?c.minScore:Number(c.minScore),q.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,q.minRecallCount)),limit:Y(c.limit,q.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():W.cron,lookbackDays:Math.max(1,Y(s.lookbackDays,W.lookbackDays)),limit:Y(s.limit,W.limit),dedupeSimilarity:J(ce(s.dedupeSimilarity,W.dedupeSimilarity),W.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():G.cron,minScore:J(ce(c.minScore,G.minScore),G.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,G.minRecallCount)),minUniqueQueries:Math.max(1,Y(c.minUniqueQueries,G.minUniqueQueries)),limit:Y(c.limit,G.limit),recencyHalfLifeDays:Math.max(1,ce(c.recencyHalfLifeDays,G.recencyHalfLifeDays)),maxAgeDays:Math.max(1,ce(c.maxAgeDays,G.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():K.cron,lookbackDays:Math.max(1,Y(l.lookbackDays,K.lookbackDays)),limit:Y(l.limit,K.limit),minPatternStrength:J(ce(l.minPatternStrength,K.minPatternStrength),K.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await s(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:U(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:J(t.light.dedupeSimilarity,W.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:J(t.deep.minScore,G.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:J(t.rem.minPatternStrength,K.minPatternStrength)}}}}})}),E()}var de=`p-4 sm:px-5`,fe=`mb-3`,pe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,y);function me(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function he(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ge(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),_e=`text-xs font-medium text-fg-muted`,ve=`text-sm font-medium text-fg`;function Q(e){let t=(0,V.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:_e,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,V.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:_e,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(ve,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ye(e){let t=(0,V.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function be(e){let t=(0,V.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(R,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:pe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function xe(e){let t=(0,V.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(pe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function Se(e){let t=(0,V.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ye,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Ce(e){let t=(0,V.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=he(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function we(e){let t=(0,V.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:f,doRunNow:p}=e,m;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==p||t[4]!==a||t[5]!==d||t[6]!==u||t[7]!==n?(m=(e,t)=>o?.enabled?(0,Z.jsx)(De,{t:n,busy:d&&u===e,disabled:!a||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{p(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=p,t[4]=a,t[5]=d,t[6]=u,t[7]=n,t[8]=m):m=t[8];let h=m,_;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(_=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=_):_=t[14];let y=_,b;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==y||t[20]!==h||t[21]!==r||t[22]!==f||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(b=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(pe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>f(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(A,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:pe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(R,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.phasesTitle}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(g,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:h(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Ee,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(v,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:h(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Ee,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(w,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:h(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Ee,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=y,t[20]=h,t[21]=r,t[22]=f,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=b):b=t[55],b}function Te(e){let t=(0,V.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,V.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function De(e){let t=(0,V.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(_,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(m,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Oe(e){let t=(0,V.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(_,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(m,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:f,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let p;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(p=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ke)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=p):p=t[16];let h;return t[17]!==d||t[18]!==p?(h=(0,Z.jsxs)(te,{className:de,children:[d,p]}),t[17]=d,t[18]=p,t[19]=h):h=t[19],h}function ke(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:he(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:me(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Ae(e){let t=(0,V.c)(41),{t:n,agentsMessages:r,hasToken:i,agents:a,selectedAgentId:o,onAgentChange:s,cfgForm:c,cfgSaving:l,enableAllBusy:u,cfgDirty:d,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:h}=e,g;t[0]!==a||t[1]!==r||t[2]!==l||t[3]!==i||t[4]!==s||t[5]!==o?(g=a.length>0?(0,Z.jsx)(M,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:o,disabled:!i||l,onChange:e=>s(e.currentTarget.value),"aria-label":`Agent`,children:a.map(e=>(0,Z.jsx)(k,{value:e.id,children:S(e,r)},e.id))}):null,t[0]=a,t[1]=r,t[2]=l,t[3]=i,t[4]=s,t[5]=o,t[6]=g):g=t[6];let v=!i||l||u||a.length===0,y;t[7]===p?y=t[8]:(y=()=>void p(),t[7]=p,t[8]=y);let b;t[9]===u?b=t[10]:(b=u?(0,Z.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[9]=u,t[10]=b);let x;t[11]!==n.enableAllAgentsDreaming||t[12]!==v||t[13]!==y||t[14]!==b?(x=(0,Z.jsxs)(m,{type:`button`,variant:`secondary`,disabled:v,onClick:y,children:[b,n.enableAllAgentsDreaming]}),t[11]=n.enableAllAgentsDreaming,t[12]=v,t[13]=y,t[14]=b,t[15]=x):x=t[15];let w=!i||!c||l||u||!d,T;t[16]===f?T=t[17]:(T=()=>void f(),t[16]=f,t[17]=T);let E;t[18]===l?E=t[19]:(E=l?(0,Z.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[18]=l,t[19]=E);let D;t[20]!==n.saveConfig||t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,Z.jsxs)(m,{type:`button`,variant:`primary`,disabled:w,onClick:T,children:[E,n.saveConfig]}),t[20]=n.saveConfig,t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O=!i,A;t[25]===h?A=t[26]:(A=()=>void h(),t[25]=h,t[26]=A);let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(C,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=j):j=t[27];let N;t[28]!==n.refresh||t[29]!==O||t[30]!==A?(N=(0,Z.jsx)(m,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:O,title:n.refresh,"aria-label":n.refresh,onClick:A,children:j}),t[28]=n.refresh,t[29]=O,t[30]=A,t[31]=N):N=t[31];let P;t[32]!==g||t[33]!==N||t[34]!==x||t[35]!==D?(P=(0,Z.jsxs)(Z.Fragment,{children:[g,x,D,N]}),t[32]=g,t[33]=N,t[34]=x,t[35]=D,t[36]=P):P=t[36];let F;return t[37]!==n.subtitle||t[38]!==n.title||t[39]!==P?(F=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:P}),t[37]=n.subtitle,t[38]=n.title,t[39]=P,t[40]=F):F=t[40],F}function je(e){let t=(0,V.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(F,{className:fe,icon:d,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(_,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(x,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let f;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(f=(0,Z.jsxs)(m,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==n.confirmClearLock?(p=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=p):p=t[16];let g;t[17]===a?g=t[18]:(g=a===`clear_lock`?(0,Z.jsx)(_,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(h,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=g);let v;t[19]!==r||t[20]!==n.clearLock||t[21]!==p||t[22]!==g?(v=(0,Z.jsxs)(m,{variant:`secondary`,disabled:r,onClick:p,children:[g,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=p,t[22]=g,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[f,v]}),t[24]=f,t[25]=v,t[26]=y):y=t[26];let b;return t[27]!==c||t[28]!==y?(b=(0,Z.jsxs)(te,{className:s,children:[c,y]}),t[27]=c,t[28]=y,t[29]=b):b=t[29],b}function Me(e){let t=(0,V.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(_,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(m,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:T,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&L.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,V.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?z(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,V.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?ge(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,de),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(_,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(F,{className:fe,icon:f,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(ye,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let h=r?r.config.enabled?n.on:n.off:`—`,y;t[12]!==n.enabled||t[13]!==h?(y=(0,Z.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=y):y=t[14];let b=l?.className,x=l?l.text:`—`,S;t[15]!==b||t[16]!==x?(S=(0,Z.jsx)(`span`,{className:b,children:x}),t[15]=b,t[16]=x,t[17]=S):S=t[17];let C;t[18]!==n.lock||t[19]!==S?(C=(0,Z.jsx)($,{label:n.lock,children:S}),t[18]=n.lock,t[19]=S,t[20]=C):C=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==C||t[35]!==E||t[36]!==k||t[37]!==y?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[y,C,E,k]}),t[34]=C,t[35]=E,t[36]=k,t[37]=y,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==m?(j=(0,Z.jsxs)(`div`,{className:pe,children:[m,A]}),t[39]=A,t[40]=m,t[41]=j):j=t[41];let M;t[42]===n.subsectionStore?M=t[43]:(M=(0,Z.jsx)(ye,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=M);let ee=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ee?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ee}),t[44]=n.storeEntries,t[45]=ee,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let L;t[50]===r?L=t[51]:(L=r?me(r.store.updatedAt):`—`,t[50]=r,t[51]=L);let R;t[52]!==n.storeUpdatedAt||t[53]!==L?(R=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:L}),t[52]=n.storeUpdatedAt,t[53]=L,t[54]=R):R=t[54];let B;t[55]===r?B=t[56]:(B=r?me(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=B);let H;t[57]!==n.storeLastPromotedAt||t[58]!==B?(H=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:B}),t[57]=n.storeLastPromotedAt,t[58]=B,t[59]=H):H=t[59];let ne;t[60]!==N||t[61]!==I||t[62]!==R||t[63]!==H?(ne=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,R,H]}),t[60]=N,t[61]=I,t[62]=R,t[63]=H,t[64]=ne):ne=t[64];let re;t[65]!==M||t[66]!==ne?(re=(0,Z.jsxs)(`div`,{className:pe,children:[M,ne]}),t[65]=M,t[66]=ne,t[67]=re):re=t[67];let ie;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ie=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ye,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(xe,{icon:(0,Z.jsx)(g,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:z(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(v,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:z(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(w,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:z(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ie):ie=t[72];let ae;t[73]===n.subsectionLastRun?ae=t[74]:(ae=(0,Z.jsx)(ye,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=ae);let oe;t[75]===n.lastRunBlockHint?oe=t[76]:(oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=oe);let se;t[77]!==r||t[78]!==n?(se=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Ce,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=se):se=t[79];let U;t[80]!==ae||t[81]!==oe||t[82]!==se?(U=(0,Z.jsxs)(`div`,{className:pe,children:[ae,oe,se]}),t[80]=ae,t[81]=oe,t[82]=se,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(Se,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(Se,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==re||t[92]!==ie||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,re,ie,U,G,q]}),t[90]=j,t[91]=re,t[92]=ie,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==p?(Y=(0,Z.jsxs)(te,{className:u,children:[p,J]}),t[97]=J,t[98]=p,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:j,runtime:f,insights:T,maintenance:d};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=l(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,s=e===`zh`?`zh-CN`:`en-US`,c=!!o(e=>e.token),[d,f]=D(),m=He(d.get(`tab`)),h=d.get(`agentId`)?.trim()||``,g=(0,B.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[_,v]=(0,B.useReducer)(p,Ke),{actionBusy:y,actionError:b,runBusy:x,runError:C,runPhase:w,cfgSaving:T,cfgError:E,enableAllBusy:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:ee,eventsError:N,events:F}=_,[te,I]=(0,B.useReducer)(Ge,{form:null,baseline:null}),L=te.form,R=te.baseline,z=(0,B.useRef)(!1),V=u(c?`dreaming-settings-agents`:null,O,{revalidateOnFocus:!1}),H=V.data?.agents??[],U=h||V.data?.defaultId||``,W=(0,B.useMemo)(()=>H.find(e=>e.id===U),[H,U]),G=(0,B.useCallback)(e=>{z.current=!1,I({type:`reset`}),f(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[f]),{data:K,error:q,isLoading:J,mutate:Y}=u(c&&U?ne(U):null,re,{revalidateOnFocus:!1}),ce=(0,B.useMemo)(()=>{let e=[];return q&&e.push(q instanceof Error?q.message:String(q)),b&&e.push(b),C&&e.push(C),j&&e.push(j),N&&e.push(N),E&&e.push(E),e},[q,b,C,j,N,E]),de=(0,B.useCallback)(async()=>{v({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await Y()},[Y]),fe=(0,B.useCallback)(async()=>{v({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{v({type:`patch`,patch:{previewItems:(await oe(20,U)).items??[]}})}catch(e){v({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{previewLoading:!1}})}},[U]),pe=(0,B.useCallback)(async()=>{v({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{v({type:`patch`,patch:{events:await se(50,U)}})}catch(e){v({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{eventsLoading:!1}})}},[U]),X=(0,B.useCallback)(async(e=`deep`)=>{let n=Date.now(),r=H.length>0?H.map(e=>({id:e.id,name:S(e,t.agentsSettings),avatar:e.avatar})):[{id:U,name:W?S(W,t.agentsSettings):void 0,avatar:W?.avatar}].filter(e=>e.id),i=r.length>0?r:[{id:U}],a=[];v({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=i.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||U)}catch(e){let n=t.name||t.id||U||`default`,r=e instanceof Error?e.message:String(e);a.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),v({type:`patch`,patch:a.length>0?{runError:a.join(`
|
|
2
|
-
`)}:{runOk:!0}}),await Y()}catch(e){
|
|
3
|
-
`)}}):
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{a as o,n as s,o as c}from"./fetch-B1WtuprY.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Bs as d,Dt as f,El as p,Js as m,Ml as h,No as g,Os as _,Qn as v,To as y,Wo as b,Yo as x,Ys as S,ar as C,bs as w,hs as T,io as E,ko as D,oo as O,rs as k,uc as A,us as j,va as M}from"./index-DcUaXYeb.js";import{n as ee,r as N,t as P}from"./settings-page-layout-CKefvbYi.js";import{n as F,t as te}from"./settings-form-section-CvfzhBV-.js";import{t as I}from"./page-tabs-D_8jGlqx.js";import{n as L,t as R}from"./schedule-field-D6vKd6-T.js";import{t as z}from"./format-cron-label-arqgGlVV.js";var B=e(t(),1),V=n();function H(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ne(e){return c(`/api/dreaming${H(e)}`)}async function re(e){let t=await s(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ne(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await s(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await s(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await s(c(`/api/dreaming/preview${H(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await s(c(`/api/dreaming/events${H(t,{limit:e})}`))).payload?.events??[]}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var W={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},G={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},K={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},q={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:W,deep:G,rem:K};function J(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function ce(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=U(e)?e:{},n=U(t.memory)?t.memory:{},r=U(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||U(t.phases)?t:{},a=U(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=U(a.phases)?a.phases:{},s=U(o.light)?o.light:{},c=U(o.deep)?o.deep:{},l=U(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():q.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:J(typeof c.minScore==`number`?c.minScore:Number(c.minScore),q.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,q.minRecallCount)),limit:Y(c.limit,q.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():W.cron,lookbackDays:Math.max(1,Y(s.lookbackDays,W.lookbackDays)),limit:Y(s.limit,W.limit),dedupeSimilarity:J(ce(s.dedupeSimilarity,W.dedupeSimilarity),W.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():G.cron,minScore:J(ce(c.minScore,G.minScore),G.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,G.minRecallCount)),minUniqueQueries:Math.max(1,Y(c.minUniqueQueries,G.minUniqueQueries)),limit:Y(c.limit,G.limit),recencyHalfLifeDays:Math.max(1,ce(c.recencyHalfLifeDays,G.recencyHalfLifeDays)),maxAgeDays:Math.max(1,ce(c.maxAgeDays,G.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():K.cron,lookbackDays:Math.max(1,Y(l.lookbackDays,K.lookbackDays)),limit:Y(l.limit,K.limit),minPatternStrength:J(ce(l.minPatternStrength,K.minPatternStrength),K.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await s(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:U(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:J(t.light.dedupeSimilarity,W.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:J(t.deep.minScore,G.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:J(t.rem.minPatternStrength,K.minPatternStrength)}}}}})}),M()}var de=`p-4 sm:px-5`,fe=`mb-3`,pe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,y);function me(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function he(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ge(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),_e=`text-xs font-medium text-fg-muted`,ve=`text-sm font-medium text-fg`;function Q(e){let t=(0,V.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:_e,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,V.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:_e,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(ve,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ye(e){let t=(0,V.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function be(e){let t=(0,V.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(R,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:pe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function xe(e){let t=(0,V.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(pe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function Se(e){let t=(0,V.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ye,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Ce(e){let t=(0,V.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=he(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function we(e){let t=(0,V.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:f,setCfgForm:p,doRunNow:m}=e,h;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==a||t[5]!==f||t[6]!==u||t[7]!==n?(h=(e,t)=>o?.enabled?(0,Z.jsx)(De,{t:n,busy:f&&u===e,disabled:!a||l||f||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=a,t[5]=f,t[6]=u,t[7]=n,t[8]=h):h=t[8];let g=h,_;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(_=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=_):_=t[14];let v=_,y;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==v||t[20]!==g||t[21]!==r||t[22]!==p||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(y=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(pe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>p(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(A,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:pe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(R,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>p(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>p(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.phasesTitle}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(x,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>p(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>p(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`light`,o.light.enabled),status:v(`light`)?(0,Z.jsx)(Ee,{label:v(`light`)??``}):null,enabledLabel:v(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(d,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>p(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>p(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`deep`,o.deep.enabled),status:v(`deep`)?(0,Z.jsx)(Ee,{label:v(`deep`)??``}):null,enabledLabel:v(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(k,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>p(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>p(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`rem`,o.rem.enabled),status:v(`rem`)?(0,Z.jsx)(Ee,{label:v(`rem`)??``}):null,enabledLabel:v(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=v,t[20]=g,t[21]=r,t[22]=p,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=y):y=t[55],y}function Te(e){let t=(0,V.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,V.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function De(e){let t=(0,V.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Oe(e){let t=(0,V.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(S,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(D,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:p,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ke)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let m;return t[17]!==d||t[18]!==f?(m=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[17]=d,t[18]=f,t[19]=m):m=t[19],m}function ke(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:he(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:me(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Ae(e){let t=(0,V.c)(41),{t:n,agentsMessages:r,hasToken:i,agents:a,selectedAgentId:o,onAgentChange:s,cfgForm:c,cfgSaving:l,enableAllBusy:u,cfgDirty:d,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:m}=e,h;t[0]!==a||t[1]!==r||t[2]!==l||t[3]!==i||t[4]!==s||t[5]!==o?(h=a.length>0?(0,Z.jsx)(E,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:o,disabled:!i||l,onChange:e=>s(e.currentTarget.value),"aria-label":`Agent`,children:a.map(e=>(0,Z.jsx)(O,{value:e.id,children:v(e,r)},e.id))}):null,t[0]=a,t[1]=r,t[2]=l,t[3]=i,t[4]=s,t[5]=o,t[6]=h):h=t[6];let g=!i||l||u||a.length===0,_;t[7]===p?_=t[8]:(_=()=>void p(),t[7]=p,t[8]=_);let y;t[9]===u?y=t[10]:(y=u?(0,Z.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[9]=u,t[10]=y);let b;t[11]!==n.enableAllAgentsDreaming||t[12]!==g||t[13]!==_||t[14]!==y?(b=(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,disabled:g,onClick:_,children:[y,n.enableAllAgentsDreaming]}),t[11]=n.enableAllAgentsDreaming,t[12]=g,t[13]=_,t[14]=y,t[15]=b):b=t[15];let x=!i||!c||l||u||!d,C;t[16]===f?C=t[17]:(C=()=>void f(),t[16]=f,t[17]=C);let T;t[18]===l?T=t[19]:(T=l?(0,Z.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[18]=l,t[19]=T);let k;t[20]!==n.saveConfig||t[21]!==x||t[22]!==C||t[23]!==T?(k=(0,Z.jsxs)(D,{type:`button`,variant:`primary`,disabled:x,onClick:C,children:[T,n.saveConfig]}),t[20]=n.saveConfig,t[21]=x,t[22]=C,t[23]=T,t[24]=k):k=t[24];let A=!i,j;t[25]===m?j=t[26]:(j=()=>void m(),t[25]=m,t[26]=j);let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(w,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=M):M=t[27];let N;t[28]!==n.refresh||t[29]!==A||t[30]!==j?(N=(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:A,title:n.refresh,"aria-label":n.refresh,onClick:j,children:M}),t[28]=n.refresh,t[29]=A,t[30]=j,t[31]=N):N=t[31];let P;t[32]!==h||t[33]!==N||t[34]!==b||t[35]!==k?(P=(0,Z.jsxs)(Z.Fragment,{children:[h,b,k,N]}),t[32]=h,t[33]=N,t[34]=b,t[35]=k,t[36]=P):P=t[36];let F;return t[37]!==n.subtitle||t[38]!==n.title||t[39]!==P?(F=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:P}),t[37]=n.subtitle,t[38]=n.title,t[39]=P,t[40]=F):F=t[40],F}function je(e){let t=(0,V.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(F,{className:fe,icon:g,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(S,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(b,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(D,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let p;t[17]===a?p=t[18]:(p=a===`clear_lock`?(0,Z.jsx)(S,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(m,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=p);let h;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==p?(h=(0,Z.jsxs)(D,{variant:`secondary`,disabled:r,onClick:f,children:[p,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=p,t[23]=h):h=t[23];let _;t[24]!==d||t[25]!==h?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,h]}),t[24]=d,t[25]=h,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(te,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function Me(e){let t=(0,V.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(S,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(D,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:T,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&L.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,V.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?z(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,V.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?ge(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,de),t[3]=u):u=t[3];let f;t[4]===a?f=t[5]:(f=a?(0,Z.jsx)(S,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=f);let m;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==f?(m=(0,Z.jsx)(F,{className:fe,icon:p,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:f}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=f,t[9]=m):m=t[9];let h;t[10]===n.subsectionSchedule?h=t[11]:(h=(0,Z.jsx)(ye,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=h);let g=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==g?(_=(0,Z.jsx)($,{label:n.enabled,children:g}),t[12]=n.enabled,t[13]=g,t[14]=_):_=t[14];let v=l?.className,y=l?l.text:`—`,b;t[15]!==v||t[16]!==y?(b=(0,Z.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let C;t[18]!==n.lock||t[19]!==b?(C=(0,Z.jsx)($,{label:n.lock,children:b}),t[18]=n.lock,t[19]=b,t[20]=C):C=t[20];let w=r&&r.config.timezone||`—`,T;t[21]!==n.timezone||t[22]!==w?(T=(0,Z.jsx)($,{label:n.timezone,children:w}),t[21]=n.timezone,t[22]=w,t[23]=T):T=t[23];let E;t[24]!==r||t[25]!==o||t[26]!==s?(E=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=E):E=t[27];let D;t[28]===r?D=t[29]:(D=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=D);let O;t[30]!==n.schedule||t[31]!==E||t[32]!==D?(O=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[E,D]}),t[30]=n.schedule,t[31]=E,t[32]=D,t[33]=O):O=t[33];let A;t[34]!==C||t[35]!==T||t[36]!==O||t[37]!==_?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,C,T,O]}),t[34]=C,t[35]=T,t[36]=O,t[37]=_,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==h?(j=(0,Z.jsxs)(`div`,{className:pe,children:[h,A]}),t[39]=A,t[40]=h,t[41]=j):j=t[41];let M;t[42]===n.subsectionStore?M=t[43]:(M=(0,Z.jsx)(ye,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=M);let ee=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ee?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ee}),t[44]=n.storeEntries,t[45]=ee,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let L;t[50]===r?L=t[51]:(L=r?me(r.store.updatedAt):`—`,t[50]=r,t[51]=L);let R;t[52]!==n.storeUpdatedAt||t[53]!==L?(R=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:L}),t[52]=n.storeUpdatedAt,t[53]=L,t[54]=R):R=t[54];let B;t[55]===r?B=t[56]:(B=r?me(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=B);let H;t[57]!==n.storeLastPromotedAt||t[58]!==B?(H=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:B}),t[57]=n.storeLastPromotedAt,t[58]=B,t[59]=H):H=t[59];let ne;t[60]!==N||t[61]!==I||t[62]!==R||t[63]!==H?(ne=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,R,H]}),t[60]=N,t[61]=I,t[62]=R,t[63]=H,t[64]=ne):ne=t[64];let re;t[65]!==M||t[66]!==ne?(re=(0,Z.jsxs)(`div`,{className:pe,children:[M,ne]}),t[65]=M,t[66]=ne,t[67]=re):re=t[67];let ie;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ie=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ye,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(xe,{icon:(0,Z.jsx)(x,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:z(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(d,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:z(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(k,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:z(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ie):ie=t[72];let ae;t[73]===n.subsectionLastRun?ae=t[74]:(ae=(0,Z.jsx)(ye,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=ae);let oe;t[75]===n.lastRunBlockHint?oe=t[76]:(oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=oe);let se;t[77]!==r||t[78]!==n?(se=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Ce,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=se):se=t[79];let U;t[80]!==ae||t[81]!==oe||t[82]!==se?(U=(0,Z.jsxs)(`div`,{className:pe,children:[ae,oe,se]}),t[80]=ae,t[81]=oe,t[82]=se,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(Se,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(Se,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==re||t[92]!==ie||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,re,ie,U,G,q]}),t[90]=j,t[91]=re,t[92]=ie,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==m?(Y=(0,Z.jsxs)(te,{className:u,children:[m,J]}),t[97]=J,t[98]=m,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:j,runtime:p,insights:T,maintenance:g};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=l(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,s=e===`zh`?`zh-CN`:`en-US`,c=!!o(e=>e.token),[d,p]=h(),m=He(d.get(`tab`)),g=d.get(`agentId`)?.trim()||``,_=(0,B.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[y,b]=(0,B.useReducer)(f,Ke),{actionBusy:x,actionError:S,runBusy:w,runError:T,runPhase:E,cfgSaving:D,cfgError:O,enableAllBusy:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:ee,eventsError:N,events:F}=y,[te,I]=(0,B.useReducer)(Ge,{form:null,baseline:null}),L=te.form,R=te.baseline,z=(0,B.useRef)(!1),V=u(c?`dreaming-settings-agents`:null,C,{revalidateOnFocus:!1}),H=V.data?.agents??[],U=g||V.data?.defaultId||``,W=(0,B.useMemo)(()=>H.find(e=>e.id===U),[H,U]),G=(0,B.useCallback)(e=>{z.current=!1,I({type:`reset`}),p(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[p]),{data:K,error:q,isLoading:J,mutate:Y}=u(c&&U?ne(U):null,re,{revalidateOnFocus:!1}),ce=(0,B.useMemo)(()=>{let e=[];return q&&e.push(q instanceof Error?q.message:String(q)),S&&e.push(S),T&&e.push(T),j&&e.push(j),N&&e.push(N),O&&e.push(O),e},[q,S,T,j,N,O]),de=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await Y()},[Y]),fe=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{b({type:`patch`,patch:{previewItems:(await oe(20,U)).items??[]}})}catch(e){b({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{previewLoading:!1}})}},[U]),pe=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{b({type:`patch`,patch:{events:await se(50,U)}})}catch(e){b({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{eventsLoading:!1}})}},[U]),X=(0,B.useCallback)(async(e=`deep`)=>{let n=Date.now(),r=H.length>0?H.map(e=>({id:e.id,name:v(e,t.agentsSettings),avatar:e.avatar})):[{id:U,name:W?v(W,t.agentsSettings):void 0,avatar:W?.avatar}].filter(e=>e.id),i=r.length>0?r:[{id:U}],a=[];b({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=i.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||U)}catch(e){let n=t.name||t.id||U||`default`,r=e instanceof Error?e.message:String(e);a.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),b({type:`patch`,patch:a.length>0?{runError:a.join(`
|
|
2
|
+
`)}:{runOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=qe-(Date.now()-n);e>0&&await new Promise(t=>setTimeout(t,e)),b({type:`patch`,patch:{runBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]),me=(0,B.useCallback)(async e=>{b({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ie(e,U),b({type:`patch`,patch:{actionOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{actionBusy:null}})}},[Y,U]),he=!c||J||!!x,ge=(0,B.useMemo)(()=>{let e=K?.config;return le(e??{})},[K]),_e=K?.agentId||U||`main`,ve=K?.memory;(0,B.useEffect)(()=>{if(!c){I({type:`reset`}),z.current=!1;return}z.current||I({type:`sync`,value:ge})},[ge,c]);let Q=(0,B.useMemo)(()=>!L||!R?!1:JSON.stringify(L)!==JSON.stringify(R),[L,R]),$=(0,B.useCallback)(async()=>{if(L){b({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await ue(_e,L,ve),I({type:`saved`,value:L}),z.current=!1,b({type:`patch`,patch:{cfgOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{cfgSaving:!1}})}}},[_e,ve,L,Y]),ye=(0,B.useCallback)(async()=>{let e=H.length>0?H:U?[{id:U,name:W?.name,avatar:W?.avatar}]:[];if(e.length===0)return;b({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let n=[];try{for(let r of e)try{let e=await re(r.id),t=le(e.config);await ue(r.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let i=v(r,t.agentsSettings);n.push(`${i}: ${e instanceof Error?e.message:String(e)}`)}n.length>0?b({type:`patch`,patch:{cfgError:n.join(`
|
|
3
|
+
`)}}):b({type:`patch`,patch:{cfgOk:!0}}),await Y()}finally{b({type:`patch`,patch:{enableAllBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]);return(0,Z.jsxs)(P,{children:[(0,Z.jsx)(Ae,{t:n,agentsMessages:t.agentsSettings,hasToken:c,agents:H,selectedAgentId:U,onAgentChange:G,cfgForm:L,cfgSaving:D,enableAllBusy:k,cfgDirty:Q,saveConfig:$,enableAllAgentsDreaming:ye,doRefresh:de}),ce.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:ce.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ze,{t:n,activeTab:m,onChange:_}),(0,Z.jsx)(Qe,{t:n,id:`config`,activeTab:m,children:(0,Z.jsx)(we,{t:n,schedulePickerLabels:r,hasToken:c,cfgForm:L,cfgBaseline:R,cfgDirty:Q,cfgSaving:D,runPhase:E,runBusy:w,setCfgForm:e=>{z.current=!0;let t=typeof e==`function`?e(L):e;t&&I({type:`set`,value:t})},doRunNow:X})}),(0,Z.jsx)(Qe,{t:n,id:`runtime`,activeTab:m,children:(0,Z.jsx)(ze,{t:n,data:K,isLoading:J,localeTag:s,scheduleBadgeLabels:i})}),(0,Z.jsx)(Qe,{t:n,id:`insights`,activeTab:m,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Me,{t:n,hasToken:c,previewLoading:A,previewItems:M,loadPreview:fe}),(0,Z.jsx)(Oe,{t:n,hasToken:c,eventsLoading:ee,events:F,loadEvents:pe})]})}),(0,Z.jsx)(Qe,{t:n,id:`maintenance`,activeTab:m,children:(0,Z.jsx)(je,{t:n,disabled:he,actionBusy:x,doAction:me})})]})}function Ze(e){let t=(0,V.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Be.map(e=>({id:e,label:Ue(n,e),icon:Ve[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(I,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Qe(e){let t=(0,V.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ue(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=We(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(N,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Xe as DreamingSettingsPanel};
|