@xopcai/xopc 0.0.299 → 0.0.301

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-C-DSdak3.js → activity-store-sCQ2ErNm.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BnrB5fWD.js → agent-avatar-dicebear-L6Vh9fL1.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-CaA7l5Xv.js → agent-defaults-settings-panel-C22DdeJ6.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agents-DNxSNGao.js → agents-CjwnFadx.js} +1 -1
  7. package/dist/gateway/static/root/assets/api-BjlN9GPQ.js +1 -0
  8. package/dist/gateway/static/root/assets/{api-DS4w0i5N.js → api-pwK0DxZJ.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-Dfrcz-vZ.js → app-management-settings-panel-BPanjQB6.js} +1 -1
  10. package/dist/gateway/static/root/assets/appearance-settings-CUWA2E_f.js +1 -0
  11. package/dist/gateway/static/root/assets/{apps-page-Bg-7fqIS.js → apps-page-D8hP1XhF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-CISHdvCz.js → archive-plugin-BT7OnQyy.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-c0q_Q6IQ.js → attachment-load-CQGhCfVn.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-BOiNdKcv.js → automations-page-CHeFkkKk.js} +1 -1
  15. package/dist/gateway/static/root/assets/automations-workspace-B_-VM4Va.js +6 -0
  16. package/dist/gateway/static/root/assets/{binary-plugins-BO1hALPX.js → binary-plugins-D_8pZaqQ.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-BWzZ4hDH.js → block-editor-m48cnmng.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automation-inputs-DvwCwLOp.js → browser-automation-inputs-jciex8-r.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-automations-page-B8LfUUco.js → browser-automations-page-ct9dHGJF.js} +1 -1
  20. package/dist/gateway/static/root/assets/{browser-settings-page-BtZbX85K.js → browser-settings-page-DNX0BZFM.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-settings-panel-mNpAFqTf.js → capabilities-settings-panel-nvCpR13B.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-BBX7Gp4q.js → channels-settings-BeDwuVtH.js} +1 -1
  23. package/dist/gateway/static/root/assets/{channels-status-swr-CgtFOwNh.js → channels-status-swr-Cz3X8Gfa.js} +1 -1
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-CLYsf1w_.js → chat-terminal-dock-Bn_th7oe.js} +1 -1
  25. package/dist/gateway/static/root/assets/{computer-model-settings-DYWcZu2X.js → computer-model-settings-BOObauzH.js} +1 -1
  26. package/dist/gateway/static/root/assets/{computer-settings-page-B4pC7mRs.js → computer-settings-page-BicG-IvN.js} +1 -1
  27. package/dist/gateway/static/root/assets/{connectors-page-BVUnp0UV.js → connectors-page-D9xCnhbY.js} +1 -1
  28. package/dist/gateway/static/root/assets/{cron-expression-DKSgHs4I.js → cron-expression-C0ogAVG7.js} +1 -1
  29. package/dist/gateway/static/root/assets/{date-picker-DRTglPVS.js → date-picker-HtU776kx.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dependency-picker-_-7WsbTH.js → dependency-picker-DvDdN4Xu.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-CR7n2K67.js → desktop-pet-BWi5FE7D.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-Bu7g83kd.js → desktop-pet-settings-CptAwdZd.js} +1 -1
  33. package/dist/gateway/static/root/assets/{device-pairing-wizard-D5z7BvaO.js → device-pairing-wizard-C8BiZYwP.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-BI8pvu2u.js → extension-debug-page-nRRdMurF.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-EZC07dGv.js → extension-page-DxotmtcG.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DLYC6gVA.js → extension-settings-page-BK2t7aFl.js} +1 -1
  37. package/dist/gateway/static/root/assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
  38. package/dist/gateway/static/root/assets/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-B2xVR9gt.js → gateway-config-swr-COJzzscc.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-settings-C17LDur8.js → gateway-settings-rIGo_jeB.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-c7s8h7px.js → gateway-startup-retry-211-jptU.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-BAMr_vYa.js → heartbeat-settings-DAHqGRKZ.js} +1 -1
  43. package/dist/gateway/static/root/assets/{home-page-DG19Sjrn.js → home-page-BU59mAGQ.js} +1 -1
  44. package/dist/gateway/static/root/assets/{image-generation-api-DUjbV88R.js → image-generation-api-sO31fQr_.js} +1 -1
  45. package/dist/gateway/static/root/assets/{imports-page-BaQmVh_d.js → imports-page-BQ4HTIVc.js} +1 -1
  46. package/dist/gateway/static/root/assets/{index-B7JCOaCc.js → index-54o0AGdj.js} +48 -50
  47. package/dist/gateway/static/root/assets/index-R89i_XYi.css +1 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DfNQK_hR.js → keyboard-shortcuts-settings-BSgsIe7E.js} +1 -1
  49. package/dist/gateway/static/root/assets/{local-app-workbench-page-h48NEuKs.js → local-app-workbench-page-BtEQDQeQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{local-apps-page-DFMrfoGF.js → local-apps-page-BrEO9hz5.js} +1 -1
  51. package/dist/gateway/static/root/assets/{locale-store-CwuCkjo7.js → locale-store-DuG-kbsP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{logs-page-CD9MfQDD.js → logs-page-DhXIIoc0.js} +1 -1
  53. package/dist/gateway/static/root/assets/{management-settings-Dib_yIDQ.js → management-settings-DC67VTpr.js} +1 -1
  54. package/dist/gateway/static/root/assets/{markdown-view-3YQc6QFV.js → markdown-view-B1q2w6W_.js} +1 -1
  55. package/dist/gateway/static/root/assets/{media-plugins-DlZXjN6z.js → media-plugins-DdoSox1I.js} +1 -1
  56. package/dist/gateway/static/root/assets/messages-BYbx4OuI.js +3 -0
  57. package/dist/gateway/static/root/assets/{note-detail-panel-CS0W3ESn.js → note-detail-panel-CCIA4VbP.js} +3 -3
  58. package/dist/gateway/static/root/assets/{notes-page-BNMVGN6Y.js → notes-page-C8JeFMSH.js} +1 -1
  59. package/dist/gateway/static/root/assets/{page-tabs-BLzm5EXm.js → page-tabs-B_I0YuTK.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-B6QLKIZy.js → preview-open-alternatives--5Zt1oSs.js} +1 -1
  61. package/dist/gateway/static/root/assets/{proactive-page-W_uN2_ie.js → proactive-page-BBJZB2RV.js} +1 -1
  62. package/dist/gateway/static/root/assets/{product-open-page-DLm3cUhY.js → product-open-page-CKFPKr0A.js} +1 -1
  63. package/dist/gateway/static/root/assets/{project-detail-page-Gfze4S0P.js → project-detail-page-DeTeDel1.js} +1 -1
  64. package/dist/gateway/static/root/assets/{projects-page-DT7zmH0f.js → projects-page-BUsI5G7U.js} +1 -1
  65. package/dist/gateway/static/root/assets/{registry-api-Cxx1-pCg.js → registry-api-BDgFNu05.js} +1 -1
  66. package/dist/gateway/static/root/assets/{remote-access-hub-CXQkXSU2.js → remote-access-hub-DSGwCc4h.js} +1 -1
  67. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DHkNbhpP.js → runtime-tools-settings-panel-BY9oD7eN.js} +1 -1
  68. package/dist/gateway/static/root/assets/{schema-form-BTLg2fN1.js → schema-form-CuIDQtYN.js} +1 -1
  69. package/dist/gateway/static/root/assets/{sessions-page-CxTLRoxv.js → sessions-page-zAeJa1Ae.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-BG4EILeB.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-form-section-D9rWLTBX.js → settings-form-section-C4D1p0xR.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-page-BR9XJ0j9.js → settings-page-BBG4jliE.js} +1 -1
  73. package/dist/gateway/static/root/assets/{setup-status-panel-BSo76NwE.js → setup-status-panel-DXqDeXNi.js} +1 -1
  74. package/dist/gateway/static/root/assets/{share-preview-page-Dx2IpPEp.js → share-preview-page-DbE7gsDd.js} +1 -1
  75. package/dist/gateway/static/root/assets/{shares-settings-BMF0Bo06.js → shares-settings-BN_O6Dwt.js} +1 -1
  76. package/dist/gateway/static/root/assets/skill-reload-api-Sq-IWawl.js +1 -0
  77. package/dist/gateway/static/root/assets/{skills-page-CaX9EQtn.js → skills-page-Dh33NKoP.js} +1 -1
  78. package/dist/gateway/static/root/assets/{skills-page.utils-CxWdcFKs.js → skills-page.utils-BNz7GQvw.js} +1 -1
  79. package/dist/gateway/static/root/assets/{system-settings-panel-BkiXkDSq.js → system-settings-panel-C3L8_KEq.js} +1 -1
  80. package/dist/gateway/static/root/assets/{task-detail-page-UBuGZQkl.js → task-detail-page-CJ1WpRpN.js} +1 -1
  81. package/dist/gateway/static/root/assets/theme-store-JzZVUvEh.js +1 -0
  82. package/dist/gateway/static/root/assets/{tunnel-api-CEXwG7vJ.js → tunnel-api-GLzwLaUZ.js} +1 -1
  83. package/dist/gateway/static/root/assets/{use-autosave-BHxjmV8l.js → use-autosave-DSrlXbBg.js} +1 -1
  84. package/dist/gateway/static/root/assets/{user-model-page-Dvtr3CPj.js → user-model-page-CX9eizCN.js} +1 -1
  85. package/dist/gateway/static/root/assets/{voice-api-key-field-BCNM-BaQ.js → voice-api-key-field-9P97T0CT.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-config-api-De1DTzxK.js → voice-config-api-DJvwbFbz.js} +1 -1
  87. package/dist/gateway/static/root/assets/{work-discovery-overlay-tig5sF-Q.js → work-discovery-overlay-CoVHgrQY.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-OcS30LVZ.js → workflow-run-setup-panel-BR-S_IGS.js} +1 -1
  89. package/dist/gateway/static/root/assets/{workflows-page-AqlMn0Bx.js → workflows-page-ea-j18xi.js} +1 -1
  90. package/dist/gateway/static/root/index.html +10 -10
  91. package/dist/package.js +1 -1
  92. package/dist/src/agent/service/process-direct-one-shot.js +1 -0
  93. package/dist/src/cli/commands/connectors.js +1 -1
  94. package/dist/src/config/schema.js +1 -1
  95. package/dist/src/connectors/auth-provider-registry.js +1 -1
  96. package/dist/src/connectors/connected-source-ingestion.js +1 -1
  97. package/dist/src/connectors/connection-recovery-service.js +1 -1
  98. package/dist/src/connectors/health.js +1 -1
  99. package/dist/src/gateway/automation-agent-session.js +4 -1
  100. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  101. package/dist/src/gateway/hono/routes/connectors.js +3 -3
  102. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  103. package/dist/src/gateway/service/run-gateway-agent.js +2 -3
  104. package/dist/src/notifications/plain-text.d.ts +1 -0
  105. package/dist/src/notifications/plain-text.js +14 -0
  106. package/dist/src/notifications/planner.js +2 -1
  107. package/dist/src/storage/sqlite/session-repository.js +12 -1
  108. package/dist/src/storage/sqlite/transcript-repository.js +11 -2
  109. package/dist/src/tui/tui-startup-resources.js +1 -1
  110. package/dist/src/workflows/service/workflow-session-bridge.js +5 -1
  111. package/package.json +2 -2
  112. package/dist/gateway/static/root/assets/api-BhJmc8E-.js +0 -1
  113. package/dist/gateway/static/root/assets/appearance-settings-BLB_xmtb.js +0 -1
  114. package/dist/gateway/static/root/assets/automations-workspace-DDdsNbjH.js +0 -6
  115. package/dist/gateway/static/root/assets/index-Bt6a_Yxc.css +0 -2
  116. package/dist/gateway/static/root/assets/messages-D6CRVWtT.js +0 -3
  117. package/dist/gateway/static/root/assets/settings-advanced-gate-BgtDlDZh.js +0 -1
  118. package/dist/gateway/static/root/assets/skill-reload-api-DNBw3BJR.js +0 -1
  119. package/dist/gateway/static/root/assets/theme-store-Dt7ob2wD.js +0 -1
@@ -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{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as a,r as o}from"./popover-select-DldSX8GX.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,n as d,r as f}from"./locale-store-CwuCkjo7.js";import{t as p}from"./messages-D6CRVWtT.js";import{i as m,o as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CGlRPNzi.js";import{n as _,r as v}from"./gateway-config-swr-B2xVR9gt.js";import{Fo as y,Ic as b,Io as x,Lo as S,Po as C,To as w,Ul as T,Wc as E,bu as D,ca as O,ll as k,ru as A,xo as j}from"./index-B7JCOaCc.js";import{n as ee,r as M,t as te}from"./settings-page-layout-CsUQKRq0.js";import{n as ne}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as re,t as ie}from"./use-autosave-BHxjmV8l.js";import{t as ae}from"./page-tabs-BLzm5EXm.js";import{t as oe}from"./settings-advanced-gate-BgtDlDZh.js";import{i as se,n as ce,r as N,t as le}from"./channels-status-swr-CgtFOwNh.js";import{n as P,o as F,t as ue}from"./cron-expression-DKSgHs4I.js";import{t as I}from"./date-picker-DRTglPVS.js";import{n as L,t as de}from"./tab-completion-input-D64VNmiA.js";var R=e(t(),1),z=n();function B(){return f(`/api/workspace/heartbeat-md`)}async function fe(){let e=await l(B());return typeof e.payload?.content==`string`?e.payload.content:``}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(e){let t=V(e)?e:{},n=V(t.gateway)?t.gateway:{},r=V(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=V(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function H(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function me(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:H(e)}})}),_()}async function he(e){await l(f(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),h(B())}async function ge(e){await l(f(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var U=r(),W=Array.from({length:60},(e,t)=>t),G=c(x,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),_e=c(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,C),ve=c(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,C);function K(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function J(e,t){switch(t.type){case`reset`:return K(t.state);case`replace`:return t.state}}function ye({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let s=(0,R.useMemo)(()=>P(e),[e]),[l,u]=(0,R.useReducer)(J,s,K),d=(0,R.useRef)(e);d.current!==e&&(d.current=e,u({type:`reset`,state:s}));let f=(0,R.useCallback)(e=>{let n={...l,...e};u({type:`replace`,state:n});let r=q(n),i=q(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(ue(r))},[t,l]),{mode:p,intervalKind:m,onceDate:h,intervalMinutes:g,intervalHours:_,minute:v,hour:y,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=l,T=`${String(y).padStart(2,`0`)}:${String(v).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||f({minute:n,hour:t})},D=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,U.jsxs)(a,{className:G,disabled:r,value:p,onChange:e=>{let t=e.target.value;f({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,U.jsx)(o,{value:`no_repeat`,children:n.modeNoRepeat}),(0,U.jsx)(o,{value:`interval`,children:n.modeInterval}),(0,U.jsx)(o,{value:`hourly`,children:n.modeHourly}),(0,U.jsx)(o,{value:`daily`,children:n.modeDaily}),(0,U.jsx)(o,{value:`weekly`,children:n.modeWeekly}),(0,U.jsx)(o,{value:`monthly`,children:n.modeMonthly}),(0,U.jsx)(o,{value:`custom`,children:n.modeCustom})]}),p===`no_repeat`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I,{disabled:r,className:`h-9 min-w-[9.5rem] shrink-0 bg-surface-panel px-2`,value:h,onChange:e=>f({onceDate:e}),ariaLabel:n.modeNoRepeat}),(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`interval`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(a,{className:c(G,`w-auto min-w-[5rem]`),disabled:r,value:m,onChange:e=>{let t=e.target.value;f({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,U.jsx)(o,{value:`minutes`,children:n.intervalKindMinutes}),(0,U.jsx)(o,{value:`hours`,children:n.intervalKindHours})]}),m===`minutes`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:_e,value:C??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),f(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);f({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:_e,value:w??String(_),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),f(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);f({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),p===`daily`&&(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`weekly`&&(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`monthly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{f({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,U.jsx)(o,{value:e,children:e},e))}),(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`hourly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=p===`weekly`?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,U.jsx)(`button`,{type:`button`,disabled:r,className:c(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],f({weekDays:e})},children:e},e)})}):null,k=p===`custom`?(0,U.jsxs)(`div`,{className:`pt-1`,children:[(0,U.jsx)(L,{disabled:r,className:ve,rows:2,spellCheck:!1,value:S,suggestion:`*/5 * * * *`,onAcceptSuggestion:e=>f({rawCron:e}),placeholder:`*/5 * * * *`,onChange:e=>{f({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var X=c(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,C),be=c(x,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function xe(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 String(e)}}function Se({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:s=1}){let c=(0,R.useMemo)(()=>new Set(i),[i]),l=(0,R.useMemo)(()=>c.has(e)?String(e):``,[c,e]),[u,d]=(0,R.useState)(null),f=(0,R.useRef)(e);f.current!==e&&(f.current=e,d(null));let p=Math.max(s,Math.round(e/1e3)),m=u===null?String(p):u;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`number`,min:s,step:1,disabled:r,className:X,value:m,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=s&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<s?s*1e3:e*1e3),d(null)}}),(0,U.jsxs)(a,{className:be,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,U.jsx)(o,{value:``,children:n.presets.custom}),i.map(e=>(0,U.jsx)(o,{value:String(e),children:xe(e,n.presets)},e))]})]})]})}var Ce=c(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,C),Z=()=>({start:`09:00`,end:`22:00`,timezone:``});function we(e){let t=(0,z.c)(61),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(Z()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,U.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,U.jsx)(F,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let l;t[16]!==o||t[17]!==c?(l=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=l):l=t[18];let u;t[19]===i.end?u=t[20]:(u=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=u);let d;t[21]!==r||t[22]!==n?(d=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=d):d=t[23];let f;t[24]!==a||t[25]!==i.end||t[26]!==d||t[27]!==n.end?(f=(0,U.jsx)(F,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:d,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=d,t[27]=n.end,t[28]=f):f=t[28];let p;t[29]!==u||t[30]!==f?(p=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[u,f]}),t[29]=u,t[30]=f,t[31]=p):p=t[31];let m;t[32]===i.timezone?m=t[33]:(m=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=m);let h;t[34]!==r||t[35]!==n?(h=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=h):h=t[36];let _;t[37]!==r||t[38]!==n?(_=e=>r({...n,timezone:e}),t[37]=r,t[38]=n,t[39]=_):_=t[39];let v;t[40]!==a||t[41]!==h||t[42]!==_||t[43]!==n.timezone?(v=(0,U.jsx)(de,{type:`text`,disabled:a,className:Ce,value:n.timezone,onChange:h,suggestion:`Asia/Shanghai`,onAcceptSuggestion:_,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[40]=a,t[41]=h,t[42]=_,t[43]=n.timezone,t[44]=v):v=t[44];let y;t[45]!==v||t[46]!==m?(y=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[m,v]}),t[45]=v,t[46]=m,t[47]=y):y=t[47];let b;t[48]!==y||t[49]!==l||t[50]!==p?(b=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[l,p,y]}),t[48]=y,t[49]=l,t[50]=p,t[51]=b):b=t[51];let x;t[52]===r?x=t[53]:(x=()=>r(null),t[52]=r,t[53]=x);let S;t[54]!==a||t[55]!==i.clear||t[56]!==x?(S=(0,U.jsx)(g,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:x,children:i.clear}),t[54]=a,t[55]=i.clear,t[56]=x,t[57]=S):S=t[57];let C;return t[58]!==b||t[59]!==S?(C=(0,U.jsxs)(`div`,{className:`space-y-2`,children:[b,S]}),t[58]=b,t[59]=S,t[60]=C):C=t[60],C}function Q(e){let t=(0,z.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=c(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,U.jsx)(ye,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,U.jsx)(Se,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,U.jsx)(we,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==o||t[28]!==s||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,U.jsxs)(`div`,{className:o,children:[s,l,u,d,f]}),t[27]=o,t[28]=s,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Te(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S,`dark:border-edge`)}function Ee(){return c(x,y)}var De=[`schedule`,`delivery`,`prompt`,`document`],Oe={schedule:D,delivery:k,prompt:T,document:A};function ke(e){return e&&De.includes(e)?e:`schedule`}function Ae(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function je(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function Me(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ne(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function Pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Fe={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ie(){let e=d(e=>e.language),t=p(e),n=t.heartbeatSettings,r=!!u(e=>e.conversationId),[a,o]=i(),l=ke(a.get(`tab`)),f=(0,R.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[h,_]=(0,R.useReducer)(Me,{form:null,baseline:null}),y=h.form,b=h.baseline,[x,S]=(0,R.useReducer)(Ne,{doc:``,baseline:``}),C=x.doc,T=x.baseline,[D,k]=(0,R.useReducer)(O,Fe),{triggerLoading:A,triggerOk:te,triggerError:ae}=D,N=(0,R.useRef)(!1),P=(0,R.useRef)(!1),F=(0,R.useRef)(y),ue=(0,R.useRef)(C);F.current=y,ue.current=C;let{data:I,error:L,isLoading:de,mutate:z}=v(r),{data:V,error:H,isLoading:W,mutate:G}=m(r?B():null,fe,{revalidateOnFocus:!1}),{data:_e=[]}=m(r?le():null,ce,{revalidateOnFocus:!1}),ve=(0,R.useMemo)(()=>Pe(I?.payload?.config),[I]),K=(0,R.useMemo)(()=>pe(I?.payload?.config??{}),[I]),q=(0,R.useMemo)(()=>!y||!b?!1:JSON.stringify(y)!==JSON.stringify(b),[y,b]),J=C!==T;(0,R.useEffect)(()=>{if(!r){_({type:`reset`}),N.current=!1;return}I!==void 0&&(N.current||_({type:`sync`,value:K}))},[r,I,K]),(0,R.useEffect)(()=>{if(!r){S({type:`reset`}),P.current=!1;return}V!==void 0&&(P.current||S({type:`sync`,value:V}))},[r,V]);let ye=L instanceof Error?L.message:L?String(L):H instanceof Error?H.message:H?String(H):null,Y=!!(r&&(I===void 0||V===void 0)&&!ye&&(de||W)),X=y?.target.trim()??``,{data:be,setData:xe}=j(()=>se(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),Se=(0,R.useCallback)(()=>{X&&se(X).then(xe)},[X,xe]),Ce=(0,R.useCallback)(async()=>{k({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await ge(),k({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>k({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){k({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{k({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,R.useCallback)(e=>{N.current=!0,_({type:`patch`,patch:e})},[]),we=q||J,Q=ie({value:(0,R.useMemo)(()=>y?{form:y,doc:C,saveConfig:q,saveDoc:J}:null,[q,J,C,y]),dirty:we,onSave:(0,R.useCallback)(async e=>{try{e.saveConfig&&(await me(e.form),_({type:`saved`,value:e.form}),N.current=!!(F.current&&JSON.stringify(F.current)!==JSON.stringify(e.form))),e.saveDoc&&(await he(e.doc),S({type:`saved`,value:e.doc}),P.current=ue.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:J?900:500});return r?Y?(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(ne,{sections:3})}):y?(0,U.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":b?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat,docsLink:w(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(re,{status:Q.status,error:Q.error}),(0,U.jsxs)(g,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:A,onClick:()=>void Ce(),children:[A?(0,U.jsx)(s,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,U.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),A?n.triggering:n.triggerNow]}),te?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),(0,U.jsx)(oe,{children:ve?(0,U.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,U.jsx)(`span`,{className:`font-mono text-fg-muted`,children:ve})]}):null}),Q.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,ae?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ae}):null,(0,U.jsx)(Le,{h:n,activeTab:l,onChange:f}),(0,U.jsx)($,{h:n,id:`schedule`,activeTab:l,children:(0,U.jsx)(Re,{h:n,form:y,update:Z})}),(0,U.jsx)($,{h:n,id:`delivery`,activeTab:l,children:(0,U.jsx)(ze,{h:n,cron:t.cron,form:y,channels:_e,sessionChatIds:be,onRefreshChatIds:Se,update:Z,inputClassName:Te,selectClassName:Ee})}),(0,U.jsx)($,{h:n,id:`prompt`,activeTab:l,children:(0,U.jsx)(He,{h:n,form:y,update:Z,inputClassName:Te})}),(0,U.jsxs)($,{h:n,id:`document`,activeTab:l,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,U.jsx)(`textarea`,{className:c(Te(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:C,onChange:e=>{P.current=!0,S({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":C===T?`true`:`false`})]})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye??n.loadError}),(0,U.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>{z(),G()},children:n.retry})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Le(e){let t=(0,z.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=De.map(e=>({id:e,label:Ae(n,e),icon:Oe[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,U.jsx)(ae,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,z.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Ae(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=je(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,U.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Re(e){let t=(0,z.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,U.jsx)(Q,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,U.jsx)(Q,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,U.jsxs)(U.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function ze(e){let t=(0,z.c)(51),{h:n,cron:r,form:i,channels:s,sessionChatIds:l,onRefreshChatIds:u,update:d,inputClassName:f,selectClassName:p}=e,m;t[0]===s?m=t[1]:(m=new Set(s.map(Ve)),t[0]=s,t[1]=m);let h=m,_;t[2]===i.target?_=t[3]:(_=i.target.trim(),t[2]=i.target,t[3]=_);let v=_,y=!!(v&&!h.has(v)),x;t[4]===n.deliveryHint?x=t[5]:(x=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=x);let S;t[6]===r.channel?S=t[7]:(S=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=S);let C;t[8]===p?C=t[9]:(C=p(),t[8]=p,t[9]=C);let w;t[10]===d?w=t[11]:(w=e=>{d({target:e.target.value.trim(),targetChatId:``})},t[10]=d,t[11]=w);let T;t[12]===n.channelNone?T=t[13]:(T=(0,U.jsx)(o,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=T);let E;t[14]!==n.customChannelSuffix||t[15]!==y||t[16]!==v?(E=y?(0,U.jsxs)(o,{value:v,children:[v,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=y,t[16]=v,t[17]=E):E=t[17];let D;t[18]===s?D=t[19]:(D=s.map(Be),t[18]=s,t[19]=D);let O;t[20]!==C||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==v?(O=(0,U.jsxs)(a,{className:C,value:v,onChange:w,children:[T,E,D]}),t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=v,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==S?(k=(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[S,O]}),t[27]=O,t[28]=S,t[29]=k):k=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==f||t[41]!==u||t[42]!==p||t[43]!==l||t[44]!==v||t[45]!==d?(A=v?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,U.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:u,children:[(0,U.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:c(f(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>d({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,U.jsxs)(a,{className:c(p(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&d({targetChatId:t})},children:[(0,U.jsx)(o,{value:``,children:r.selectRecipient}),l.length>0?l.map(e=>(0,U.jsx)(o,{value:e.chatId,children:N(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,U.jsx)(o,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=f,t[41]=u,t[42]=p,t[43]=l,t[44]=v,t[45]=d,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==x?(j=(0,U.jsxs)(U.Fragment,{children:[x,k,A]}),t[47]=k,t[48]=A,t[49]=x,t[50]=j):j=t[50],j}function Be(e){return(0,U.jsxs)(o,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Ve(e){return e.name}function He(e){let t=(0,z.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,U.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==s||t[11]!==u?(d=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===a?p=t[16]:(p=c(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,U.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,U.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===a?y=t[33]:(y=a(),t[32]=a,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,U.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,U.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,U.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,U.jsxs)(U.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ie as HeartbeatSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as a,r as o}from"./popover-select-DldSX8GX.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,n as d,r as f}from"./locale-store-DuG-kbsP.js";import{t as p}from"./messages-BYbx4OuI.js";import{i as m,o as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CGlRPNzi.js";import{n as _,r as v}from"./gateway-config-swr-COJzzscc.js";import{Fo as y,Ic as b,Io as x,Lo as S,Po as C,To as w,Ul as T,Wc as E,bu as D,ca as O,ll as k,ru as A,xo as j}from"./index-54o0AGdj.js";import{n as ee,r as M,t as te}from"./settings-page-layout-CsUQKRq0.js";import{n as ne}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as re,t as ie}from"./use-autosave-DSrlXbBg.js";import{t as ae}from"./page-tabs-B_I0YuTK.js";import{t as oe}from"./settings-advanced-gate-BG4EILeB.js";import{i as se,n as ce,r as N,t as le}from"./channels-status-swr-Cz3X8Gfa.js";import{n as P,o as F,t as ue}from"./cron-expression-C0ogAVG7.js";import{t as I}from"./date-picker-HtU776kx.js";import{n as L,t as de}from"./tab-completion-input-D64VNmiA.js";var R=e(t(),1),z=n();function B(){return f(`/api/workspace/heartbeat-md`)}async function fe(){let e=await l(B());return typeof e.payload?.content==`string`?e.payload.content:``}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pe(e){let t=V(e)?e:{},n=V(t.gateway)?t.gateway:{},r=V(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=V(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function H(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function me(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:H(e)}})}),_()}async function he(e){await l(f(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),h(B())}async function ge(e){await l(f(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var U=r(),W=Array.from({length:60},(e,t)=>t),G=c(x,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),_e=c(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,C),ve=c(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,C);function K(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function J(e,t){switch(t.type){case`reset`:return K(t.state);case`replace`:return t.state}}function ye({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let s=(0,R.useMemo)(()=>P(e),[e]),[l,u]=(0,R.useReducer)(J,s,K),d=(0,R.useRef)(e);d.current!==e&&(d.current=e,u({type:`reset`,state:s}));let f=(0,R.useCallback)(e=>{let n={...l,...e};u({type:`replace`,state:n});let r=q(n),i=q(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(ue(r))},[t,l]),{mode:p,intervalKind:m,onceDate:h,intervalMinutes:g,intervalHours:_,minute:v,hour:y,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=l,T=`${String(y).padStart(2,`0`)}:${String(v).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||f({minute:n,hour:t})},D=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,U.jsxs)(a,{className:G,disabled:r,value:p,onChange:e=>{let t=e.target.value;f({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,U.jsx)(o,{value:`no_repeat`,children:n.modeNoRepeat}),(0,U.jsx)(o,{value:`interval`,children:n.modeInterval}),(0,U.jsx)(o,{value:`hourly`,children:n.modeHourly}),(0,U.jsx)(o,{value:`daily`,children:n.modeDaily}),(0,U.jsx)(o,{value:`weekly`,children:n.modeWeekly}),(0,U.jsx)(o,{value:`monthly`,children:n.modeMonthly}),(0,U.jsx)(o,{value:`custom`,children:n.modeCustom})]}),p===`no_repeat`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(I,{disabled:r,className:`h-9 min-w-[9.5rem] shrink-0 bg-surface-panel px-2`,value:h,onChange:e=>f({onceDate:e}),ariaLabel:n.modeNoRepeat}),(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`interval`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(a,{className:c(G,`w-auto min-w-[5rem]`),disabled:r,value:m,onChange:e=>{let t=e.target.value;f({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,U.jsx)(o,{value:`minutes`,children:n.intervalKindMinutes}),(0,U.jsx)(o,{value:`hours`,children:n.intervalKindHours})]}),m===`minutes`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:_e,value:C??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),f(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);f({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:_e,value:w??String(_),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),f(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);f({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),p===`daily`&&(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`weekly`&&(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`monthly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{f({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,U.jsx)(o,{value:e,children:e},e))}),(0,U.jsx)(F,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`hourly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=p===`weekly`?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,U.jsx)(`button`,{type:`button`,disabled:r,className:c(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],f({weekDays:e})},children:e},e)})}):null,k=p===`custom`?(0,U.jsxs)(`div`,{className:`pt-1`,children:[(0,U.jsx)(L,{disabled:r,className:ve,rows:2,spellCheck:!1,value:S,suggestion:`*/5 * * * *`,onAcceptSuggestion:e=>f({rawCron:e}),placeholder:`*/5 * * * *`,onChange:e=>{f({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var X=c(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,C),be=c(x,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function xe(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 String(e)}}function Se({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:s=1}){let c=(0,R.useMemo)(()=>new Set(i),[i]),l=(0,R.useMemo)(()=>c.has(e)?String(e):``,[c,e]),[u,d]=(0,R.useState)(null),f=(0,R.useRef)(e);f.current!==e&&(f.current=e,d(null));let p=Math.max(s,Math.round(e/1e3)),m=u===null?String(p):u;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`number`,min:s,step:1,disabled:r,className:X,value:m,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=s&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<s?s*1e3:e*1e3),d(null)}}),(0,U.jsxs)(a,{className:be,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,U.jsx)(o,{value:``,children:n.presets.custom}),i.map(e=>(0,U.jsx)(o,{value:String(e),children:xe(e,n.presets)},e))]})]})]})}var Ce=c(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,C),Z=()=>({start:`09:00`,end:`22:00`,timezone:``});function we(e){let t=(0,z.c)(61),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(Z()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,U.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,U.jsx)(F,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let l;t[16]!==o||t[17]!==c?(l=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=l):l=t[18];let u;t[19]===i.end?u=t[20]:(u=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=u);let d;t[21]!==r||t[22]!==n?(d=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=d):d=t[23];let f;t[24]!==a||t[25]!==i.end||t[26]!==d||t[27]!==n.end?(f=(0,U.jsx)(F,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:d,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=d,t[27]=n.end,t[28]=f):f=t[28];let p;t[29]!==u||t[30]!==f?(p=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[u,f]}),t[29]=u,t[30]=f,t[31]=p):p=t[31];let m;t[32]===i.timezone?m=t[33]:(m=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=m);let h;t[34]!==r||t[35]!==n?(h=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=h):h=t[36];let _;t[37]!==r||t[38]!==n?(_=e=>r({...n,timezone:e}),t[37]=r,t[38]=n,t[39]=_):_=t[39];let v;t[40]!==a||t[41]!==h||t[42]!==_||t[43]!==n.timezone?(v=(0,U.jsx)(de,{type:`text`,disabled:a,className:Ce,value:n.timezone,onChange:h,suggestion:`Asia/Shanghai`,onAcceptSuggestion:_,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[40]=a,t[41]=h,t[42]=_,t[43]=n.timezone,t[44]=v):v=t[44];let y;t[45]!==v||t[46]!==m?(y=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[m,v]}),t[45]=v,t[46]=m,t[47]=y):y=t[47];let b;t[48]!==y||t[49]!==l||t[50]!==p?(b=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[l,p,y]}),t[48]=y,t[49]=l,t[50]=p,t[51]=b):b=t[51];let x;t[52]===r?x=t[53]:(x=()=>r(null),t[52]=r,t[53]=x);let S;t[54]!==a||t[55]!==i.clear||t[56]!==x?(S=(0,U.jsx)(g,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:x,children:i.clear}),t[54]=a,t[55]=i.clear,t[56]=x,t[57]=S):S=t[57];let C;return t[58]!==b||t[59]!==S?(C=(0,U.jsxs)(`div`,{className:`space-y-2`,children:[b,S]}),t[58]=b,t[59]=S,t[60]=C):C=t[60],C}function Q(e){let t=(0,z.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=c(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,U.jsx)(ye,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,U.jsx)(Se,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,U.jsx)(we,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==o||t[28]!==s||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,U.jsxs)(`div`,{className:o,children:[s,l,u,d,f]}),t[27]=o,t[28]=s,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Te(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S,`dark:border-edge`)}function Ee(){return c(x,y)}var De=[`schedule`,`delivery`,`prompt`,`document`],Oe={schedule:D,delivery:k,prompt:T,document:A};function ke(e){return e&&De.includes(e)?e:`schedule`}function Ae(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function je(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function Me(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ne(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function Pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Fe={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ie(){let e=d(e=>e.language),t=p(e),n=t.heartbeatSettings,r=!!u(e=>e.conversationId),[a,o]=i(),l=ke(a.get(`tab`)),f=(0,R.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[h,_]=(0,R.useReducer)(Me,{form:null,baseline:null}),y=h.form,b=h.baseline,[x,S]=(0,R.useReducer)(Ne,{doc:``,baseline:``}),C=x.doc,T=x.baseline,[D,k]=(0,R.useReducer)(O,Fe),{triggerLoading:A,triggerOk:te,triggerError:ae}=D,N=(0,R.useRef)(!1),P=(0,R.useRef)(!1),F=(0,R.useRef)(y),ue=(0,R.useRef)(C);F.current=y,ue.current=C;let{data:I,error:L,isLoading:de,mutate:z}=v(r),{data:V,error:H,isLoading:W,mutate:G}=m(r?B():null,fe,{revalidateOnFocus:!1}),{data:_e=[]}=m(r?le():null,ce,{revalidateOnFocus:!1}),ve=(0,R.useMemo)(()=>Pe(I?.payload?.config),[I]),K=(0,R.useMemo)(()=>pe(I?.payload?.config??{}),[I]),q=(0,R.useMemo)(()=>!y||!b?!1:JSON.stringify(y)!==JSON.stringify(b),[y,b]),J=C!==T;(0,R.useEffect)(()=>{if(!r){_({type:`reset`}),N.current=!1;return}I!==void 0&&(N.current||_({type:`sync`,value:K}))},[r,I,K]),(0,R.useEffect)(()=>{if(!r){S({type:`reset`}),P.current=!1;return}V!==void 0&&(P.current||S({type:`sync`,value:V}))},[r,V]);let ye=L instanceof Error?L.message:L?String(L):H instanceof Error?H.message:H?String(H):null,Y=!!(r&&(I===void 0||V===void 0)&&!ye&&(de||W)),X=y?.target.trim()??``,{data:be,setData:xe}=j(()=>se(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),Se=(0,R.useCallback)(()=>{X&&se(X).then(xe)},[X,xe]),Ce=(0,R.useCallback)(async()=>{k({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await ge(),k({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>k({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){k({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{k({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,R.useCallback)(e=>{N.current=!0,_({type:`patch`,patch:e})},[]),we=q||J,Q=ie({value:(0,R.useMemo)(()=>y?{form:y,doc:C,saveConfig:q,saveDoc:J}:null,[q,J,C,y]),dirty:we,onSave:(0,R.useCallback)(async e=>{try{e.saveConfig&&(await me(e.form),_({type:`saved`,value:e.form}),N.current=!!(F.current&&JSON.stringify(F.current)!==JSON.stringify(e.form))),e.saveDoc&&(await he(e.doc),S({type:`saved`,value:e.doc}),P.current=ue.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:J?900:500});return r?Y?(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(ne,{sections:3})}):y?(0,U.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":b?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat,docsLink:w(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(re,{status:Q.status,error:Q.error}),(0,U.jsxs)(g,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:A,onClick:()=>void Ce(),children:[A?(0,U.jsx)(s,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,U.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),A?n.triggering:n.triggerNow]}),te?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),(0,U.jsx)(oe,{children:ve?(0,U.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,U.jsx)(`span`,{className:`font-mono text-fg-muted`,children:ve})]}):null}),Q.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,ae?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ae}):null,(0,U.jsx)(Le,{h:n,activeTab:l,onChange:f}),(0,U.jsx)($,{h:n,id:`schedule`,activeTab:l,children:(0,U.jsx)(Re,{h:n,form:y,update:Z})}),(0,U.jsx)($,{h:n,id:`delivery`,activeTab:l,children:(0,U.jsx)(ze,{h:n,cron:t.cron,form:y,channels:_e,sessionChatIds:be,onRefreshChatIds:Se,update:Z,inputClassName:Te,selectClassName:Ee})}),(0,U.jsx)($,{h:n,id:`prompt`,activeTab:l,children:(0,U.jsx)(He,{h:n,form:y,update:Z,inputClassName:Te})}),(0,U.jsxs)($,{h:n,id:`document`,activeTab:l,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,U.jsx)(`textarea`,{className:c(Te(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:C,onChange:e=>{P.current=!0,S({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":C===T?`true`:`false`})]})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye??n.loadError}),(0,U.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>{z(),G()},children:n.retry})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Le(e){let t=(0,z.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=De.map(e=>({id:e,label:Ae(n,e),icon:Oe[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,U.jsx)(ae,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,z.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Ae(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=je(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,U.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Re(e){let t=(0,z.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,U.jsx)(Q,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,U.jsx)(Q,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,U.jsxs)(U.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function ze(e){let t=(0,z.c)(51),{h:n,cron:r,form:i,channels:s,sessionChatIds:l,onRefreshChatIds:u,update:d,inputClassName:f,selectClassName:p}=e,m;t[0]===s?m=t[1]:(m=new Set(s.map(Ve)),t[0]=s,t[1]=m);let h=m,_;t[2]===i.target?_=t[3]:(_=i.target.trim(),t[2]=i.target,t[3]=_);let v=_,y=!!(v&&!h.has(v)),x;t[4]===n.deliveryHint?x=t[5]:(x=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=x);let S;t[6]===r.channel?S=t[7]:(S=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=S);let C;t[8]===p?C=t[9]:(C=p(),t[8]=p,t[9]=C);let w;t[10]===d?w=t[11]:(w=e=>{d({target:e.target.value.trim(),targetChatId:``})},t[10]=d,t[11]=w);let T;t[12]===n.channelNone?T=t[13]:(T=(0,U.jsx)(o,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=T);let E;t[14]!==n.customChannelSuffix||t[15]!==y||t[16]!==v?(E=y?(0,U.jsxs)(o,{value:v,children:[v,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=y,t[16]=v,t[17]=E):E=t[17];let D;t[18]===s?D=t[19]:(D=s.map(Be),t[18]=s,t[19]=D);let O;t[20]!==C||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==v?(O=(0,U.jsxs)(a,{className:C,value:v,onChange:w,children:[T,E,D]}),t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=v,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==S?(k=(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[S,O]}),t[27]=O,t[28]=S,t[29]=k):k=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==f||t[41]!==u||t[42]!==p||t[43]!==l||t[44]!==v||t[45]!==d?(A=v?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,U.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:u,children:[(0,U.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:c(f(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>d({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,U.jsxs)(a,{className:c(p(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&d({targetChatId:t})},children:[(0,U.jsx)(o,{value:``,children:r.selectRecipient}),l.length>0?l.map(e=>(0,U.jsx)(o,{value:e.chatId,children:N(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,U.jsx)(o,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=f,t[41]=u,t[42]=p,t[43]=l,t[44]=v,t[45]=d,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==x?(j=(0,U.jsxs)(U.Fragment,{children:[x,k,A]}),t[47]=k,t[48]=A,t[49]=x,t[50]=j):j=t[50],j}function Be(e){return(0,U.jsxs)(o,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Ve(e){return e.name}function He(e){let t=(0,z.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,U.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==s||t[11]!==u?(d=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===a?p=t[16]:(p=c(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,U.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,U.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===a?y=t[33]:(y=a(),t[32]=a,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,U.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,U.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,U.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,U.jsxs)(U.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ie as HeartbeatSettingsPanel};
@@ -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{d as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l}from"./locale-store-CwuCkjo7.js";import{t as u}from"./messages-D6CRVWtT.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-CGlRPNzi.js";import{t as b}from"./skeleton-BwbyijEw.js";import{$l as x,Ds as S,Hr as C,Is as w,Ls as T,Lu as E,Mu as D,Ns as O,Nu as k,So as A,Vo as j,Ws as M,Zc as ee,bc as N,bi as P,ci as F,cn as te,li as ne,ln as re,ma as ie,on as ae,pl as I,r as oe,sn as L,yi as se}from"./index-B7JCOaCc.js";import{t as ce}from"./api-BhJmc8E-.js";import{n as le}from"./tab-completion-input-D64VNmiA.js";var R=n(),z=r(),B={meeting_preparation:{Icon:E,en:`Next meeting`,zh:`下一场会议`},project_momentum:{Icon:x,en:`Project momentum`,zh:`项目进展`},communication_follow_up:{Icon:I,en:`Waiting on a reply`,zh:`沟通跟进`}},ue={needs_decision:{en:`Needs your decision`,zh:`需要你决定`},prepared:{en:`Ready for you`,zh:`已为你准备好`},changed:{en:`Something changed`,zh:`出现了新变化`},following:{en:`Following quietly`,zh:`正在安静跟进`}};function V(e){let t=(0,R.c)(56),{scene:n,zh:r}=e,i=B[n.kind],o=ue[n.status],s=n.card?`/assistant-work?item=${encodeURIComponent(n.card.id)}`:n.object?.route??n.manageRoute,c=n.status===`needs_decision`?r?`查看并决定`:`Review and decide`:n.status===`prepared`?r?`查看准备结果`:`Open prepared work`:n.status===`changed`?r?`查看变化`:`Review change`:n.object?r?`打开${n.kind===`project_momentum`?`项目`:`相关内容`}`:`Open context`:r?`查看安排`:`View arrangement`,l;t[0]===i.Icon?l=t[1]:(l=(0,z.jsx)(`span`,{className:`mt-0.5 rounded-xl bg-accent-soft p-2 text-accent`,children:(0,z.jsx)(i.Icon,{className:`size-4`,"aria-hidden":!0})}),t[0]=i.Icon,t[1]=l);let u=r?i.zh:i.en,d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:u}),t[2]=u,t[3]=d);let f=n.status===`following`?`text-xs text-fg-subtle`:`text-xs font-medium text-accent`,p=r?o.zh:o.en,m;t[4]!==f||t[5]!==p?(m=(0,z.jsx)(`span`,{className:f,children:p}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==d||t[8]!==m?(h=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[d,m]}),t[7]=d,t[8]=m,t[9]=h):h=t[9];let g;t[10]===n.title?g=t[11]:(g=(0,z.jsx)(`h3`,{className:`mt-1 font-semibold text-fg`,children:n.title}),t[10]=n.title,t[11]=g);let _;t[12]!==h||t[13]!==g?(_=(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==l||t[16]!==_?(v=(0,z.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-5 py-4`,children:[l,_]}),t[15]=l,t[16]=_,t[17]=v):v=t[17];let y=r?`现在`:`Now`,b;t[18]===y?b=t[19]:(b=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:y}),t[18]=y,t[19]=b);let x;t[20]===n.moment?x=t[21]:(x=(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:n.moment}),t[20]=n.moment,t[21]=x);let S;t[22]!==b||t[23]!==x?(S=(0,z.jsxs)(`div`,{children:[b,x]}),t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=n.status===`following`?r?`跟进要求`:`What the assistant remembers`:r?`为什么值得关注`:`Why it matters`,w;t[25]===C?w=t[26]:(w=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:C}),t[25]=C,t[26]=w);let T=n.status===`following`?n.promise:n.relevance,E;t[27]===T?E=t[28]:(E=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,z.jsxs)(`div`,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O=r?`助理已经做了什么`:`What your assistant did`,k;t[32]===O?k=t[33]:(k=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:O}),t[32]=O,t[33]=k);let A;t[34]===n.help?A=t[35]:(A=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:n.help}),t[34]=n.help,t[35]=A);let j;t[36]!==k||t[37]!==A?(j=(0,z.jsxs)(`div`,{className:`rounded-xl bg-surface-hover px-4 py-3`,children:[k,A]}),t[36]=k,t[37]=A,t[38]=j):j=t[38];let M;t[39]!==c||t[40]!==s?(M=(0,z.jsx)(a,{className:`text-sm font-medium text-accent`,to:s,children:c}),t[39]=c,t[40]=s,t[41]=M):M=t[41];let ee=r?`调整助理跟进`:`Adjust arrangement`,N;t[42]!==n.manageRoute||t[43]!==ee?(N=(0,z.jsx)(a,{className:`text-xs text-fg-subtle hover:text-fg`,to:n.manageRoute,children:ee}),t[42]=n.manageRoute,t[43]=ee,t[44]=N):N=t[44];let P;t[45]!==M||t[46]!==N?(P=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[M,N]}),t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;t[48]!==S||t[49]!==D||t[50]!==j||t[51]!==P?(F=(0,z.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[S,D,j,P]}),t[48]=S,t[49]=D,t[50]=j,t[51]=P,t[52]=F):F=t[52];let te;return t[53]!==v||t[54]!==F?(te=(0,z.jsxs)(`article`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[v,F]}),t[53]=v,t[54]=F,t[55]=te):te=t[55],te}function de(e){let t=(0,R.c)(42),{compact:n}=e,r=n===void 0?!1:n,i=l(H)===`zh`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:15e3},t[0]=o):o=t[0];let s=v(`/api/proactive/overview`,ce,o);if(s.isLoading){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(b,{className:`h-44 rounded-2xl`}),t[1]=e):e=t[1],e}if(s.error){let e=String(s.error),n;return t[2]===e?n=t[3]:(n=(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[2]=e,t[3]=n),n}let c;t[4]===s.data?.scenes?c=t[5]:(c=s.data?.scenes??[],t[4]=s.data?.scenes,t[5]=c);let u=c;if(!u.length){let e=r?`px-4 text-center`:`rounded-2xl border border-edge bg-surface-panel p-6`,n=r?`text-sm font-medium text-fg-muted`:`font-medium text-fg`,a=i?`今天没有需要你接手的变化`:`Nothing needs your attention today`,o;t[6]!==n||t[7]!==a?(o=(0,z.jsx)(`h2`,{className:n,children:a}),t[6]=n,t[7]=a,t[8]=o):o=t[8];let s=r?`mx-auto mt-2 max-w-lg text-xs leading-5 text-fg-subtle`:`mt-2 text-sm text-fg-muted`,c=i?`继续工作即可。需要持续关注的事,可以直接在项目或对话里交给助理。`:`Keep working. You can ask the assistant to follow something from its project or conversation.`,l;t[9]!==s||t[10]!==c?(l=(0,z.jsx)(`p`,{className:s,children:c}),t[9]=s,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==l||t[13]!==e||t[14]!==o?(u=(0,z.jsxs)(`section`,{className:e,children:[o,l]}),t[12]=l,t[13]=e,t[14]=o,t[15]=u):u=t[15],u}let d;t[16]!==r||t[17]!==u?(d=r?u.slice(0,3):u,t[16]=r,t[17]=u,t[18]=d):d=t[18];let f=d,p=i?`正在发生的事`:`What is happening`,m;t[19]===p?m=t[20]:(m=(0,z.jsx)(`h2`,{id:`proactive-scenes-title`,className:`text-sm font-semibold text-fg`,children:p}),t[19]=p,t[20]=m);let h=i?`助理跟进`:`Assistant follow-ups`,g;t[21]===h?g=t[22]:(g=(0,z.jsx)(a,{className:`text-xs text-fg-subtle hover:text-accent`,to:`/assistant-work`,children:h}),t[21]=h,t[22]=g);let _;t[23]!==m||t[24]!==g?(_=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3 px-1`,children:[m,g]}),t[23]=m,t[24]=g,t[25]=_):_=t[25];let y;if(t[26]!==f||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>(0,z.jsx)(V,{scene:e,zh:i},e.id),t[29]=i,t[30]=e),y=f.map(e),t[26]=f,t[27]=i,t[28]=y}else y=t[28];let x;t[31]===y?x=t[32]:(x=(0,z.jsx)(`div`,{className:`space-y-3`,children:y}),t[31]=y,t[32]=x);let S;t[33]!==r||t[34]!==u.length||t[35]!==f.length||t[36]!==i?(S=r&&u.length>f.length&&(0,z.jsx)(a,{className:`mt-3 block text-sm text-accent`,to:`/assistant-work`,children:i?`还有 ${u.length-f.length} 个场景`:`${u.length-f.length} more scenes`}),t[33]=r,t[34]=u.length,t[35]=f.length,t[36]=i,t[37]=S):S=t[37];let C;return t[38]!==x||t[39]!==S||t[40]!==_?(C=(0,z.jsxs)(`section`,{"aria-labelledby":`proactive-scenes-title`,children:[_,x,S]}),t[38]=x,t[39]=S,t[40]=_,t[41]=C):C=t[41],C}function H(e){return e.language}var U=e(t(),1),fe=12e3;function W(e){let t=(0,R.c)(106),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:l,attachmentBusy:u,attachmentsFull:d,voice:f,chat:p,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:b,onDragLeave:x,onDrop:S,onSubmit:C}=e,w=n===`inline`,T;t[0]!==s||t[1]!==a?(T=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=T):T=t[2];let E=T,D=f.voiceActive&&f.phase!==`error`,O;t[3]!==C||t[4]!==f.voiceActive?(O=e=>{if(f.voiceActive){e.preventDefault();return}C(e)},t[3]=C,t[4]=f.voiceActive,t[5]=O):O=t[5];let k=w?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,A;t[6]===k?A=t[7]:(A=c(`relative`,k),t[6]=k,t[7]=A);let j;t[8]!==w||t[9]!==l||t[10]!==o.dropFiles?(j=l?(0,z.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,w&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=w,t[9]=l,t[10]=o.dropFiles,t[11]=j):j=t[11];let M=!w&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,P;t[12]===M?P=t[13]:(P=c(M),t[12]=M,t[13]=P);let F=w?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,re;t[14]!==r||t[15]!==o.intentLabel||t[16]!==F?(re=(0,z.jsx)(`label`,{htmlFor:r,className:F,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=F,t[17]=re):re=t[17];let ie;t[18]!==u||t[19]!==p||t[20]!==f.audioLevel||t[21]!==f.cancelVoiceInput||t[22]!==f.confirmVoiceInput||t[23]!==f.elapsedLabel||t[24]!==f.error||t[25]!==f.finalTranscript||t[26]!==f.partialTranscript||t[27]!==f.phase||t[28]!==f.retryVoiceInput||t[29]!==f.settingsRequired||t[30]!==f.voiceActive?(ie=f.voiceActive?(0,z.jsx)(te,{phase:f.phase,elapsedLabel:f.elapsedLabel,audioLevel:f.audioLevel,partialTranscript:f.partialTranscript,finalTranscript:f.finalTranscript,error:f.error,settingsRequired:f.settingsRequired,disabled:u,chat:p,onCancel:f.cancelVoiceInput,onConfirm:f.confirmVoiceInput,onRetry:f.retryVoiceInput}):null,t[18]=u,t[19]=p,t[20]=f.audioLevel,t[21]=f.cancelVoiceInput,t[22]=f.confirmVoiceInput,t[23]=f.elapsedLabel,t[24]=f.error,t[25]=f.finalTranscript,t[26]=f.partialTranscript,t[27]=f.phase,t[28]=f.retryVoiceInput,t[29]=f.settingsRequired,t[30]=f.voiceActive,t[31]=ie):ie=t[31];let ae=D&&`hidden`,I=w?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,oe;t[32]!==ae||t[33]!==I?(oe=c(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,ae,I),t[32]=ae,t[33]=I,t[34]=oe):oe=t[34];let L;t[35]===h?L=t[36]:(L=e=>h(e.target.value),t[35]=h,t[36]=L);let ce=!w,B;t[37]!==r||t[38]!==i||t[39]!==a||t[40]!==o.intentPlaceholder||t[41]!==o.intentSuggestion||t[42]!==h||t[43]!==v||t[44]!==oe||t[45]!==L||t[46]!==ce?(B=(0,z.jsx)(le,{ref:i,id:r,className:oe,value:a,onChange:L,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:pe,placeholder:o.intentPlaceholder,maxLength:fe,autoFocus:ce}),t[37]=r,t[38]=i,t[39]=a,t[40]=o.intentPlaceholder,t[41]=o.intentSuggestion,t[42]=h,t[43]=v,t[44]=oe,t[45]=L,t[46]=ce,t[47]=B):B=t[47];let ue=w?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,V;t[48]!==s||t[49]!==_||t[50]!==ue?(V=(0,z.jsx)(se,{attachments:s,topPadded:!1,onRemove:_,className:ue}),t[48]=s,t[49]=_,t[50]=ue,t[51]=V):V=t[51];let de;t[52]!==w||t[53]!==a.length||t[54]!==o.shortcut?(de=w?null:(0,z.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,z.jsx)(`span`,{children:o.shortcut}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,fe.toLocaleString()]})]}),t[52]=w,t[53]=a.length,t[54]=o.shortcut,t[55]=de):de=t[55];let H;t[56]!==ie||t[57]!==B||t[58]!==V||t[59]!==de||t[60]!==P||t[61]!==re?(H=(0,z.jsxs)(`div`,{className:P,children:[re,ie,B,V,de]}),t[56]=ie,t[57]=B,t[58]=V,t[59]=de,t[60]=P,t[61]=re,t[62]=H):H=t[62];let U=w?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,W;t[63]===U?W=t[64]:(W=c(`flex shrink-0 items-center gap-2 border-t`,U),t[63]=U,t[64]=W);let G=!w&&`mr-auto`,me;t[65]===G?me=t[66]:(me=c(`flex items-center gap-1`,G),t[65]=G,t[66]=me);let he=u||d,ge;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[67]=ge):ge=t[67];let K;t[68]!==o.attachTitle||t[69]!==g||t[70]!==he?(K=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:he,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:ge}),t[68]=o.attachTitle,t[69]=g,t[70]=he,t[71]=K):K=t[71];let q;t[72]!==u||t[73]!==p||t[74]!==f.startVoiceInput||t[75]!==f.voiceActive?(q=f.voiceActive?null:(0,z.jsx)(ne,{disabled:u,chat:p,onStart:f.startVoiceInput}),t[72]=u,t[73]=p,t[74]=f.startVoiceInput,t[75]=f.voiceActive,t[76]=q):q=t[76];let J;t[77]!==me||t[78]!==K||t[79]!==q?(J=(0,z.jsxs)(`div`,{className:me,children:[K,q]}),t[77]=me,t[78]=K,t[79]=q,t[80]=J):J=t[80];let Y;t[81]!==m||t[82]!==w||t[83]!==o.shortcut?(Y=w?(0,z.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[81]=m,t[82]=w,t[83]=o.shortcut,t[84]=Y):Y=t[84];let _e=w?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,X=!E||u||f.voiceActive,Z=w?`size-3.5`:`size-4`,Q;t[85]===Z?Q=t[86]:(Q=(0,z.jsx)(N,{className:Z,"aria-hidden":!0}),t[85]=Z,t[86]=Q);let $;t[87]!==o.submit||t[88]!==_e||t[89]!==X||t[90]!==Q?($=(0,z.jsxs)(y,{type:`submit`,variant:`primary`,className:_e,disabled:X,children:[Q,o.submit]}),t[87]=o.submit,t[88]=_e,t[89]=X,t[90]=Q,t[91]=$):$=t[91];let ve;t[92]!==W||t[93]!==J||t[94]!==Y||t[95]!==$?(ve=(0,z.jsxs)(`div`,{className:W,children:[J,Y,$]}),t[92]=W,t[93]=J,t[94]=Y,t[95]=$,t[96]=ve):ve=t[96];let ye;return t[97]!==x||t[98]!==b||t[99]!==S||t[100]!==O||t[101]!==H||t[102]!==ve||t[103]!==A||t[104]!==j?(ye=(0,z.jsxs)(`form`,{onSubmit:O,onDragOver:b,onDragLeave:x,onDrop:S,className:A,children:[j,H,ve]}),t[97]=x,t[98]=b,t[99]=S,t[100]=O,t[101]=H,t[102]=ve,t[103]=A,t[104]=j,t[105]=ye):ye=t[105],ye}function pe(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function G(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function me(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(b,{className:`h-10 w-3/5 rounded-xl`}),(0,z.jsx)(b,{className:`h-5 w-4/5 rounded-lg`})]}),(0,z.jsx)(b,{className:`h-64 rounded-2xl`}),(0,z.jsx)(b,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function he(e){let t=(0,R.c)(33),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:o,locale:s,onAction:c}=e,l;t[0]!==a||t[1]!==n.dueAt||t[2]!==s?(l=n.dueAt?`${a} ${C(new Date(n.dueAt),s)}`:null,t[0]=a,t[1]=n.dueAt,t[2]=s,t[3]=l):l=t[3];let u=l,d=n.kind===`failure`?o:u,f;t[4]===d?f=t[5]:(f=d?(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:d})]}):null,t[4]=d,t[5]=f);let p=!n.openAction,m;t[6]!==n.id||t[7]!==n.openAction||t[8]!==c?(m=()=>n.openAction&&c(n.openAction,n.id),t[6]=n.id,t[7]=n.openAction,t[8]=c,t[9]=m):m=t[9];let h;t[10]===n.title?h=t[11]:(h=(0,z.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[10]=n.title,t[11]=h);let g;t[12]===n.summary?g=t[13]:(g=(0,z.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[12]=n.summary,t[13]=g);let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,z.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:p,onClick:m,children:[h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n.recommendation||t[20]!==i?(v=n.recommendation?(0,z.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,z.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[19]=n.recommendation,t[20]=i,t[21]=v):v=t[21];let b;t[22]!==r||t[23]!==n.id||t[24]!==n.primaryAction||t[25]!==n.secondaryActions||t[26]!==c?(b=n.primaryAction||n.secondaryActions.length>0?(0,z.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,z.jsx)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,onClick:()=>c(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,z.jsx)(y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>c(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[22]=r,t[23]=n.id,t[24]=n.primaryAction,t[25]=n.secondaryActions,t[26]=c,t[27]=b):b=t[27];let x;return t[28]!==f||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,z.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,children:[f,_,v,b]}),t[28]=f,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32],x}function ge(e){let t=(0,R.c)(26),{item:n,onAction:r}=e,i;t[0]===n.kind?i=t[1]:(i=n.kind===`scheduled`?(0,z.jsx)(E,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`,"aria-hidden":!0}),t[0]=n.kind,t[1]=i);let a=i,o=!n.openAction,s;t[2]!==n.id||t[3]!==n.openAction||t[4]!==r?(s=()=>n.openAction&&r(n.openAction,n.id),t[2]=n.id,t[3]=n.openAction,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,z.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:a}),t[6]=a,t[7]=c);let l;t[8]===n.title?l=t[9]:(l=(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[8]=n.title,t[9]=l);let u;t[10]===n.summary?u=t[11]:(u=(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[10]=n.summary,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===n.statusLabel?f=t[16]:(f=n.statusLabel?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[15]=n.statusLabel,t[16]=f);let p;t[17]===n.openAction?p=t[18]:(p=n.openAction?(0,z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[17]=n.openAction,t[18]=p);let m;return t[19]!==o||t[20]!==s||t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:o,onClick:s,children:[c,d,f,p]}),t[19]=o,t[20]=s,t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function K(){let e=l(e=>e.language),t=u(e),n=t.projectsPage,r=M(e),a=i(),c=A(e=>e.setPageHeader),b=A(e=>e.clearPageHeader),[x,C]=(0,U.useState)(null),[E,k]=(0,U.useState)(!0),[ee,N]=(0,U.useState)(null),[te,ne]=(0,U.useState)(!1),[I,se]=(0,U.useState)(``),[le,R]=(0,U.useState)(null),[B,ue]=(0,U.useState)(!1),V=F({chat:t.chat}),H=(0,U.useRef)(null),fe=j({disabled:B,chat:t.chat,onTranscript:e=>{se(t=>re(t,e)),window.setTimeout(()=>H.current?.focus(),0)}}),{phase:pe,voiceActive:K,startVoiceInput:q,cancelVoiceInput:J,confirmVoiceInput:Y,retryVoiceInput:_e}=fe,X=(0,U.useCallback)(async(t=!1)=>{t&&k(!0),N(null);try{let t=await O(e);C({...t,needsUser:t.needsUser.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`),background:t.background.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`)})}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e]);(0,U.useEffect)(()=>{X(!0)},[X]),(0,U.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,X()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[X]);let Z=(0,U.useCallback)(async e=>{if(!(e.length===0||B)){ue(!0);try{await V.processFiles(e)}finally{ue(!1)}}},[B,V.processFiles]),Q=(0,U.useCallback)(async e=>{let t=P(e.clipboardData);t.length!==0&&(e.preventDefault(),await Z(t))},[Z]),$=(0,U.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,V.setIsDragging(!0))},[V.setIsDragging]),ve=(0,U.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&V.setIsDragging(!1)},[V.setIsDragging]),ye=(0,U.useCallback)(async e=>{e.preventDefault(),V.setIsDragging(!1),await Z(Array.from(e.dataTransfer.files))},[V.setIsDragging,Z]),be=(0,U.useCallback)(e=>{e.preventDefault();let t=V.wireAttachmentsPayload(),n=ie(I,t.length>0?oe(t):void 0,{projectScope:`none`});n&&(ne(!1),se(``),V.clearAttachments(),a(n))},[V.clearAttachments,V.wireAttachmentsPayload,I,a]),xe=V.attachments.length>=10,Se={attachTitle:xe?G(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${V.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},Ce=v(`/api/proactive/overview`,ce,{refreshInterval:15e3}),we=!!Ce.data?.scenes.some(e=>e.status===`prepared`),Te=!!Ce.data?.scenes.some(e=>e.status===`changed`),Ee=!!Ce.data?.scenes.some(e=>e.status===`following`),De=!!Ce.data?.scenes.length,Oe=!!(x&&x.needsUser.length===0&&x.backgroundCount===0&&Ce.data&&!De),ke=Oe||te;(0,U.useEffect)(()=>{!ke&&K&&J()},[J,ke,K]),(0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||B||(e.preventDefault(),pe===`recording`?Y():pe===`idle`?(H.current?.focus(),q()):pe===`error`&&_e())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||!K||(e.preventDefault(),J(),H.current?.focus())};return window.addEventListener(L,e),window.addEventListener(ae,t),()=>{window.removeEventListener(L,e),window.removeEventListener(ae,t)}},[B,J,ke,Y,_e,q,K,pe]);let Ae=(0,U.useCallback)(e=>{e||J(),ne(e)},[J]),je=(0,U.useMemo)(()=>Oe?null:(0,z.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>ne(!0),children:[(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0}),r.newWork]}),[r.newWork,Oe]),Me=(0,U.useCallback)((e,t)=>{if(e.type===`open`){a(e.href);return}if(e.type===`review_judgment`){a(`/assistant-work?item=${encodeURIComponent(e.itemId)}`);return}R(t),N(null),(async()=>{try{e.type===`connector_decision`?await w({kind:`connector_approval`,approvalId:e.approvalId},e.decision):e.type===`retry_run`?await T({kind:e.subjectKind,runId:e.runId}):e.type===`acknowledge_run`&&await S({kind:e.subjectKind,runId:e.runId}),await X()}catch(e){N(e instanceof Error?e.message:String(e))}finally{R(null)}})()},[X,a]);(0,U.useLayoutEffect)(()=>(c({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:je}),()=>b()),[b,je,c,n.title]);let Ne=(x?.needsUser.length??0)+(Ce.data?.scenes.filter(e=>e.status===`needs_decision`).length??0),Pe=x?.backgroundCount??0,Fe=Ne>0?G(n.home.attentionTitle,{count:Ne}):we?e===`zh`?`助理准备好了这些`:`Your assistant prepared these`:Te?e===`zh`?`有一些值得知道的变化`:`A few changes are worth knowing`:Pe>0?n.home.clearTitle:Ee?e===`zh`?`助理在跟进你交代的事`:`Your assistant is following through`:Ce.data?n.home.idleTitle:e===`zh`?`今天的工作`:`Your work today`,Ie=Ne>0?Pe>0?G(n.home.attentionIntroWithBackground,{count:Pe}):n.home.attentionIntro:we?e===`zh`?`成果已经整理好,可以直接查看或继续办理。`:`The results are ready to review or continue.`:Te?e===`zh`?`这里是可能影响你当前工作的最新变化。`:`These changes may affect your current work.`:Pe>0?G(n.home.clearIntro,{count:Pe}):Ee?e===`zh`?`助理记着这些事项,有实质进展时会带回来。`:`Your assistant remembers these items and will bring back useful progress.`:Ce.data?n.home.idleIntro:e===`zh`?`正在核对已交代的事项。`:`Checking your delegated work.`;return(0,z.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 py-8 sm:px-6 lg:px-8 lg:py-12`,children:[(0,z.jsx)(`input`,{ref:V.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Z(Array.from(t)),e.target.value=``}}),(0,z.jsx)(_,{open:te,onOpenChange:Ae,children:(0,z.jsxs)(m,{children:[(0,z.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(g,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,z.jsx)(f,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})})]}),(0,z.jsx)(W,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:H,intent:I,labels:{...Se,submit:r.submit},attachments:V.attachments,isDragging:V.isDragging,attachmentBusy:B,attachmentsFull:xe,voice:fe,chat:t.chat,cancelAction:(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:se,onPickFiles:()=>V.fileInputRef.current?.click(),onRemoveAttachment:V.removeAttachment,onPaste:e=>void Q(e),onDragOver:$,onDragLeave:ve,onDrop:e=>void ye(e),onSubmit:be})]})]})}),ee?(0,z.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,z.jsx)(`span`,{children:ee}),(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void X(),children:n.home.retry})]}):null,E?(0,z.jsx)(me,{}):x?(0,z.jsxs)(`div`,{className:Oe?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,z.jsxs)(`section`,{className:Oe?`w-full text-center`:`max-w-3xl`,children:[(0,z.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:Fe}),(0,z.jsx)(`p`,{className:Oe?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:Ie}),Oe?(0,z.jsx)(W,{variant:`inline`,inputId:`idle-conversation-intent`,inputRef:H,intent:I,labels:Se,attachments:V.attachments,isDragging:V.isDragging,attachmentBusy:B,attachmentsFull:xe,voice:fe,chat:t.chat,onIntentChange:se,onPickFiles:()=>V.fileInputRef.current?.click(),onRemoveAttachment:V.removeAttachment,onPaste:e=>void Q(e),onDragOver:$,onDragLeave:ve,onDrop:e=>void ye(e),onSubmit:be}):null]}),x.needsUser.length>0?(0,z.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,z.jsx)(D,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:x.needsUser.map(t=>(0,z.jsx)(he,{item:t,busy:le===t.id,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:Me},t.id))})]}):null,(0,z.jsx)(`section`,{className:Oe?`mt-6 sm:mt-8`:`mt-10`,children:(0,z.jsx)(de,{compact:!0})}),x.background.length>0?(0,z.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,z.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:G(n.home.backgroundCount,{count:x.backgroundCount})})]}),(0,z.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:x.background.map(e=>(0,z.jsx)(ge,{item:e,onAction:Me},e.id))})]}):null]}):null]})}export{K as HomePage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l}from"./locale-store-DuG-kbsP.js";import{t as u}from"./messages-BYbx4OuI.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-CGlRPNzi.js";import{t as b}from"./skeleton-BwbyijEw.js";import{$l as x,Ds as S,Hr as C,Is as w,Ls as T,Lu as E,Mu as D,Ns as O,Nu as k,So as A,Vo as j,Ws as M,Zc as ee,bc as N,bi as P,ci as F,cn as te,li as ne,ln as re,ma as ie,on as ae,pl as I,r as oe,sn as L,yi as se}from"./index-54o0AGdj.js";import{t as ce}from"./api-BjlN9GPQ.js";import{n as le}from"./tab-completion-input-D64VNmiA.js";var R=n(),z=r(),B={meeting_preparation:{Icon:E,en:`Next meeting`,zh:`下一场会议`},project_momentum:{Icon:x,en:`Project momentum`,zh:`项目进展`},communication_follow_up:{Icon:I,en:`Waiting on a reply`,zh:`沟通跟进`}},ue={needs_decision:{en:`Needs your decision`,zh:`需要你决定`},prepared:{en:`Ready for you`,zh:`已为你准备好`},changed:{en:`Something changed`,zh:`出现了新变化`},following:{en:`Following quietly`,zh:`正在安静跟进`}};function V(e){let t=(0,R.c)(56),{scene:n,zh:r}=e,i=B[n.kind],o=ue[n.status],s=n.card?`/assistant-work?item=${encodeURIComponent(n.card.id)}`:n.object?.route??n.manageRoute,c=n.status===`needs_decision`?r?`查看并决定`:`Review and decide`:n.status===`prepared`?r?`查看准备结果`:`Open prepared work`:n.status===`changed`?r?`查看变化`:`Review change`:n.object?r?`打开${n.kind===`project_momentum`?`项目`:`相关内容`}`:`Open context`:r?`查看安排`:`View arrangement`,l;t[0]===i.Icon?l=t[1]:(l=(0,z.jsx)(`span`,{className:`mt-0.5 rounded-xl bg-accent-soft p-2 text-accent`,children:(0,z.jsx)(i.Icon,{className:`size-4`,"aria-hidden":!0})}),t[0]=i.Icon,t[1]=l);let u=r?i.zh:i.en,d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:u}),t[2]=u,t[3]=d);let f=n.status===`following`?`text-xs text-fg-subtle`:`text-xs font-medium text-accent`,p=r?o.zh:o.en,m;t[4]!==f||t[5]!==p?(m=(0,z.jsx)(`span`,{className:f,children:p}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==d||t[8]!==m?(h=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[d,m]}),t[7]=d,t[8]=m,t[9]=h):h=t[9];let g;t[10]===n.title?g=t[11]:(g=(0,z.jsx)(`h3`,{className:`mt-1 font-semibold text-fg`,children:n.title}),t[10]=n.title,t[11]=g);let _;t[12]!==h||t[13]!==g?(_=(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==l||t[16]!==_?(v=(0,z.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-5 py-4`,children:[l,_]}),t[15]=l,t[16]=_,t[17]=v):v=t[17];let y=r?`现在`:`Now`,b;t[18]===y?b=t[19]:(b=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:y}),t[18]=y,t[19]=b);let x;t[20]===n.moment?x=t[21]:(x=(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:n.moment}),t[20]=n.moment,t[21]=x);let S;t[22]!==b||t[23]!==x?(S=(0,z.jsxs)(`div`,{children:[b,x]}),t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=n.status===`following`?r?`跟进要求`:`What the assistant remembers`:r?`为什么值得关注`:`Why it matters`,w;t[25]===C?w=t[26]:(w=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:C}),t[25]=C,t[26]=w);let T=n.status===`following`?n.promise:n.relevance,E;t[27]===T?E=t[28]:(E=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,z.jsxs)(`div`,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O=r?`助理已经做了什么`:`What your assistant did`,k;t[32]===O?k=t[33]:(k=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:O}),t[32]=O,t[33]=k);let A;t[34]===n.help?A=t[35]:(A=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:n.help}),t[34]=n.help,t[35]=A);let j;t[36]!==k||t[37]!==A?(j=(0,z.jsxs)(`div`,{className:`rounded-xl bg-surface-hover px-4 py-3`,children:[k,A]}),t[36]=k,t[37]=A,t[38]=j):j=t[38];let M;t[39]!==c||t[40]!==s?(M=(0,z.jsx)(a,{className:`text-sm font-medium text-accent`,to:s,children:c}),t[39]=c,t[40]=s,t[41]=M):M=t[41];let ee=r?`调整助理跟进`:`Adjust arrangement`,N;t[42]!==n.manageRoute||t[43]!==ee?(N=(0,z.jsx)(a,{className:`text-xs text-fg-subtle hover:text-fg`,to:n.manageRoute,children:ee}),t[42]=n.manageRoute,t[43]=ee,t[44]=N):N=t[44];let P;t[45]!==M||t[46]!==N?(P=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[M,N]}),t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;t[48]!==S||t[49]!==D||t[50]!==j||t[51]!==P?(F=(0,z.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[S,D,j,P]}),t[48]=S,t[49]=D,t[50]=j,t[51]=P,t[52]=F):F=t[52];let te;return t[53]!==v||t[54]!==F?(te=(0,z.jsxs)(`article`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[v,F]}),t[53]=v,t[54]=F,t[55]=te):te=t[55],te}function de(e){let t=(0,R.c)(42),{compact:n}=e,r=n===void 0?!1:n,i=l(H)===`zh`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:15e3},t[0]=o):o=t[0];let s=v(`/api/proactive/overview`,ce,o);if(s.isLoading){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(b,{className:`h-44 rounded-2xl`}),t[1]=e):e=t[1],e}if(s.error){let e=String(s.error),n;return t[2]===e?n=t[3]:(n=(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[2]=e,t[3]=n),n}let c;t[4]===s.data?.scenes?c=t[5]:(c=s.data?.scenes??[],t[4]=s.data?.scenes,t[5]=c);let u=c;if(!u.length){let e=r?`px-4 text-center`:`rounded-2xl border border-edge bg-surface-panel p-6`,n=r?`text-sm font-medium text-fg-muted`:`font-medium text-fg`,a=i?`今天没有需要你接手的变化`:`Nothing needs your attention today`,o;t[6]!==n||t[7]!==a?(o=(0,z.jsx)(`h2`,{className:n,children:a}),t[6]=n,t[7]=a,t[8]=o):o=t[8];let s=r?`mx-auto mt-2 max-w-lg text-xs leading-5 text-fg-subtle`:`mt-2 text-sm text-fg-muted`,c=i?`继续工作即可。需要持续关注的事,可以直接在项目或对话里交给助理。`:`Keep working. You can ask the assistant to follow something from its project or conversation.`,l;t[9]!==s||t[10]!==c?(l=(0,z.jsx)(`p`,{className:s,children:c}),t[9]=s,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==l||t[13]!==e||t[14]!==o?(u=(0,z.jsxs)(`section`,{className:e,children:[o,l]}),t[12]=l,t[13]=e,t[14]=o,t[15]=u):u=t[15],u}let d;t[16]!==r||t[17]!==u?(d=r?u.slice(0,3):u,t[16]=r,t[17]=u,t[18]=d):d=t[18];let f=d,p=i?`正在发生的事`:`What is happening`,m;t[19]===p?m=t[20]:(m=(0,z.jsx)(`h2`,{id:`proactive-scenes-title`,className:`text-sm font-semibold text-fg`,children:p}),t[19]=p,t[20]=m);let h=i?`助理跟进`:`Assistant follow-ups`,g;t[21]===h?g=t[22]:(g=(0,z.jsx)(a,{className:`text-xs text-fg-subtle hover:text-accent`,to:`/assistant-work`,children:h}),t[21]=h,t[22]=g);let _;t[23]!==m||t[24]!==g?(_=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3 px-1`,children:[m,g]}),t[23]=m,t[24]=g,t[25]=_):_=t[25];let y;if(t[26]!==f||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>(0,z.jsx)(V,{scene:e,zh:i},e.id),t[29]=i,t[30]=e),y=f.map(e),t[26]=f,t[27]=i,t[28]=y}else y=t[28];let x;t[31]===y?x=t[32]:(x=(0,z.jsx)(`div`,{className:`space-y-3`,children:y}),t[31]=y,t[32]=x);let S;t[33]!==r||t[34]!==u.length||t[35]!==f.length||t[36]!==i?(S=r&&u.length>f.length&&(0,z.jsx)(a,{className:`mt-3 block text-sm text-accent`,to:`/assistant-work`,children:i?`还有 ${u.length-f.length} 个场景`:`${u.length-f.length} more scenes`}),t[33]=r,t[34]=u.length,t[35]=f.length,t[36]=i,t[37]=S):S=t[37];let C;return t[38]!==x||t[39]!==S||t[40]!==_?(C=(0,z.jsxs)(`section`,{"aria-labelledby":`proactive-scenes-title`,children:[_,x,S]}),t[38]=x,t[39]=S,t[40]=_,t[41]=C):C=t[41],C}function H(e){return e.language}var U=e(t(),1),fe=12e3;function W(e){let t=(0,R.c)(106),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:l,attachmentBusy:u,attachmentsFull:d,voice:f,chat:p,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:b,onDragLeave:x,onDrop:S,onSubmit:C}=e,w=n===`inline`,T;t[0]!==s||t[1]!==a?(T=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=T):T=t[2];let E=T,D=f.voiceActive&&f.phase!==`error`,O;t[3]!==C||t[4]!==f.voiceActive?(O=e=>{if(f.voiceActive){e.preventDefault();return}C(e)},t[3]=C,t[4]=f.voiceActive,t[5]=O):O=t[5];let k=w?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,A;t[6]===k?A=t[7]:(A=c(`relative`,k),t[6]=k,t[7]=A);let j;t[8]!==w||t[9]!==l||t[10]!==o.dropFiles?(j=l?(0,z.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,w&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=w,t[9]=l,t[10]=o.dropFiles,t[11]=j):j=t[11];let M=!w&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,P;t[12]===M?P=t[13]:(P=c(M),t[12]=M,t[13]=P);let F=w?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,re;t[14]!==r||t[15]!==o.intentLabel||t[16]!==F?(re=(0,z.jsx)(`label`,{htmlFor:r,className:F,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=F,t[17]=re):re=t[17];let ie;t[18]!==u||t[19]!==p||t[20]!==f.audioLevel||t[21]!==f.cancelVoiceInput||t[22]!==f.confirmVoiceInput||t[23]!==f.elapsedLabel||t[24]!==f.error||t[25]!==f.finalTranscript||t[26]!==f.partialTranscript||t[27]!==f.phase||t[28]!==f.retryVoiceInput||t[29]!==f.settingsRequired||t[30]!==f.voiceActive?(ie=f.voiceActive?(0,z.jsx)(te,{phase:f.phase,elapsedLabel:f.elapsedLabel,audioLevel:f.audioLevel,partialTranscript:f.partialTranscript,finalTranscript:f.finalTranscript,error:f.error,settingsRequired:f.settingsRequired,disabled:u,chat:p,onCancel:f.cancelVoiceInput,onConfirm:f.confirmVoiceInput,onRetry:f.retryVoiceInput}):null,t[18]=u,t[19]=p,t[20]=f.audioLevel,t[21]=f.cancelVoiceInput,t[22]=f.confirmVoiceInput,t[23]=f.elapsedLabel,t[24]=f.error,t[25]=f.finalTranscript,t[26]=f.partialTranscript,t[27]=f.phase,t[28]=f.retryVoiceInput,t[29]=f.settingsRequired,t[30]=f.voiceActive,t[31]=ie):ie=t[31];let ae=D&&`hidden`,I=w?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,oe;t[32]!==ae||t[33]!==I?(oe=c(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,ae,I),t[32]=ae,t[33]=I,t[34]=oe):oe=t[34];let L;t[35]===h?L=t[36]:(L=e=>h(e.target.value),t[35]=h,t[36]=L);let ce=!w,B;t[37]!==r||t[38]!==i||t[39]!==a||t[40]!==o.intentPlaceholder||t[41]!==o.intentSuggestion||t[42]!==h||t[43]!==v||t[44]!==oe||t[45]!==L||t[46]!==ce?(B=(0,z.jsx)(le,{ref:i,id:r,className:oe,value:a,onChange:L,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:pe,placeholder:o.intentPlaceholder,maxLength:fe,autoFocus:ce}),t[37]=r,t[38]=i,t[39]=a,t[40]=o.intentPlaceholder,t[41]=o.intentSuggestion,t[42]=h,t[43]=v,t[44]=oe,t[45]=L,t[46]=ce,t[47]=B):B=t[47];let ue=w?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,V;t[48]!==s||t[49]!==_||t[50]!==ue?(V=(0,z.jsx)(se,{attachments:s,topPadded:!1,onRemove:_,className:ue}),t[48]=s,t[49]=_,t[50]=ue,t[51]=V):V=t[51];let de;t[52]!==w||t[53]!==a.length||t[54]!==o.shortcut?(de=w?null:(0,z.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,z.jsx)(`span`,{children:o.shortcut}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,fe.toLocaleString()]})]}),t[52]=w,t[53]=a.length,t[54]=o.shortcut,t[55]=de):de=t[55];let H;t[56]!==ie||t[57]!==B||t[58]!==V||t[59]!==de||t[60]!==P||t[61]!==re?(H=(0,z.jsxs)(`div`,{className:P,children:[re,ie,B,V,de]}),t[56]=ie,t[57]=B,t[58]=V,t[59]=de,t[60]=P,t[61]=re,t[62]=H):H=t[62];let U=w?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,W;t[63]===U?W=t[64]:(W=c(`flex shrink-0 items-center gap-2 border-t`,U),t[63]=U,t[64]=W);let G=!w&&`mr-auto`,me;t[65]===G?me=t[66]:(me=c(`flex items-center gap-1`,G),t[65]=G,t[66]=me);let he=u||d,ge;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[67]=ge):ge=t[67];let K;t[68]!==o.attachTitle||t[69]!==g||t[70]!==he?(K=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:he,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:ge}),t[68]=o.attachTitle,t[69]=g,t[70]=he,t[71]=K):K=t[71];let q;t[72]!==u||t[73]!==p||t[74]!==f.startVoiceInput||t[75]!==f.voiceActive?(q=f.voiceActive?null:(0,z.jsx)(ne,{disabled:u,chat:p,onStart:f.startVoiceInput}),t[72]=u,t[73]=p,t[74]=f.startVoiceInput,t[75]=f.voiceActive,t[76]=q):q=t[76];let J;t[77]!==me||t[78]!==K||t[79]!==q?(J=(0,z.jsxs)(`div`,{className:me,children:[K,q]}),t[77]=me,t[78]=K,t[79]=q,t[80]=J):J=t[80];let Y;t[81]!==m||t[82]!==w||t[83]!==o.shortcut?(Y=w?(0,z.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[81]=m,t[82]=w,t[83]=o.shortcut,t[84]=Y):Y=t[84];let _e=w?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,X=!E||u||f.voiceActive,Z=w?`size-3.5`:`size-4`,Q;t[85]===Z?Q=t[86]:(Q=(0,z.jsx)(N,{className:Z,"aria-hidden":!0}),t[85]=Z,t[86]=Q);let $;t[87]!==o.submit||t[88]!==_e||t[89]!==X||t[90]!==Q?($=(0,z.jsxs)(y,{type:`submit`,variant:`primary`,className:_e,disabled:X,children:[Q,o.submit]}),t[87]=o.submit,t[88]=_e,t[89]=X,t[90]=Q,t[91]=$):$=t[91];let ve;t[92]!==W||t[93]!==J||t[94]!==Y||t[95]!==$?(ve=(0,z.jsxs)(`div`,{className:W,children:[J,Y,$]}),t[92]=W,t[93]=J,t[94]=Y,t[95]=$,t[96]=ve):ve=t[96];let ye;return t[97]!==x||t[98]!==b||t[99]!==S||t[100]!==O||t[101]!==H||t[102]!==ve||t[103]!==A||t[104]!==j?(ye=(0,z.jsxs)(`form`,{onSubmit:O,onDragOver:b,onDragLeave:x,onDrop:S,className:A,children:[j,H,ve]}),t[97]=x,t[98]=b,t[99]=S,t[100]=O,t[101]=H,t[102]=ve,t[103]=A,t[104]=j,t[105]=ye):ye=t[105],ye}function pe(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function G(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function me(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(b,{className:`h-10 w-3/5 rounded-xl`}),(0,z.jsx)(b,{className:`h-5 w-4/5 rounded-lg`})]}),(0,z.jsx)(b,{className:`h-64 rounded-2xl`}),(0,z.jsx)(b,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function he(e){let t=(0,R.c)(33),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:o,locale:s,onAction:c}=e,l;t[0]!==a||t[1]!==n.dueAt||t[2]!==s?(l=n.dueAt?`${a} ${C(new Date(n.dueAt),s)}`:null,t[0]=a,t[1]=n.dueAt,t[2]=s,t[3]=l):l=t[3];let u=l,d=n.kind===`failure`?o:u,f;t[4]===d?f=t[5]:(f=d?(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:d})]}):null,t[4]=d,t[5]=f);let p=!n.openAction,m;t[6]!==n.id||t[7]!==n.openAction||t[8]!==c?(m=()=>n.openAction&&c(n.openAction,n.id),t[6]=n.id,t[7]=n.openAction,t[8]=c,t[9]=m):m=t[9];let h;t[10]===n.title?h=t[11]:(h=(0,z.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[10]=n.title,t[11]=h);let g;t[12]===n.summary?g=t[13]:(g=(0,z.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[12]=n.summary,t[13]=g);let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,z.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:p,onClick:m,children:[h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n.recommendation||t[20]!==i?(v=n.recommendation?(0,z.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,z.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[19]=n.recommendation,t[20]=i,t[21]=v):v=t[21];let b;t[22]!==r||t[23]!==n.id||t[24]!==n.primaryAction||t[25]!==n.secondaryActions||t[26]!==c?(b=n.primaryAction||n.secondaryActions.length>0?(0,z.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,z.jsx)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,onClick:()=>c(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,z.jsx)(y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>c(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[22]=r,t[23]=n.id,t[24]=n.primaryAction,t[25]=n.secondaryActions,t[26]=c,t[27]=b):b=t[27];let x;return t[28]!==f||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,z.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,children:[f,_,v,b]}),t[28]=f,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32],x}function ge(e){let t=(0,R.c)(26),{item:n,onAction:r}=e,i;t[0]===n.kind?i=t[1]:(i=n.kind===`scheduled`?(0,z.jsx)(E,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`,"aria-hidden":!0}),t[0]=n.kind,t[1]=i);let a=i,o=!n.openAction,s;t[2]!==n.id||t[3]!==n.openAction||t[4]!==r?(s=()=>n.openAction&&r(n.openAction,n.id),t[2]=n.id,t[3]=n.openAction,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,z.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:a}),t[6]=a,t[7]=c);let l;t[8]===n.title?l=t[9]:(l=(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[8]=n.title,t[9]=l);let u;t[10]===n.summary?u=t[11]:(u=(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[10]=n.summary,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===n.statusLabel?f=t[16]:(f=n.statusLabel?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[15]=n.statusLabel,t[16]=f);let p;t[17]===n.openAction?p=t[18]:(p=n.openAction?(0,z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[17]=n.openAction,t[18]=p);let m;return t[19]!==o||t[20]!==s||t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:o,onClick:s,children:[c,d,f,p]}),t[19]=o,t[20]=s,t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function K(){let e=l(e=>e.language),t=u(e),n=t.projectsPage,r=M(e),a=i(),c=A(e=>e.setPageHeader),b=A(e=>e.clearPageHeader),[x,C]=(0,U.useState)(null),[E,k]=(0,U.useState)(!0),[ee,N]=(0,U.useState)(null),[te,ne]=(0,U.useState)(!1),[I,se]=(0,U.useState)(``),[le,R]=(0,U.useState)(null),[B,ue]=(0,U.useState)(!1),V=F({chat:t.chat}),H=(0,U.useRef)(null),fe=j({disabled:B,chat:t.chat,onTranscript:e=>{se(t=>re(t,e)),window.setTimeout(()=>H.current?.focus(),0)}}),{phase:pe,voiceActive:K,startVoiceInput:q,cancelVoiceInput:J,confirmVoiceInput:Y,retryVoiceInput:_e}=fe,X=(0,U.useCallback)(async(t=!1)=>{t&&k(!0),N(null);try{let t=await O(e);C({...t,needsUser:t.needsUser.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`),background:t.background.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`)})}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e]);(0,U.useEffect)(()=>{X(!0)},[X]),(0,U.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,X()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[X]);let Z=(0,U.useCallback)(async e=>{if(!(e.length===0||B)){ue(!0);try{await V.processFiles(e)}finally{ue(!1)}}},[B,V.processFiles]),Q=(0,U.useCallback)(async e=>{let t=P(e.clipboardData);t.length!==0&&(e.preventDefault(),await Z(t))},[Z]),$=(0,U.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,V.setIsDragging(!0))},[V.setIsDragging]),ve=(0,U.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&V.setIsDragging(!1)},[V.setIsDragging]),ye=(0,U.useCallback)(async e=>{e.preventDefault(),V.setIsDragging(!1),await Z(Array.from(e.dataTransfer.files))},[V.setIsDragging,Z]),be=(0,U.useCallback)(e=>{e.preventDefault();let t=V.wireAttachmentsPayload(),n=ie(I,t.length>0?oe(t):void 0,{projectScope:`none`});n&&(ne(!1),se(``),V.clearAttachments(),a(n))},[V.clearAttachments,V.wireAttachmentsPayload,I,a]),xe=V.attachments.length>=10,Se={attachTitle:xe?G(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${V.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},Ce=v(`/api/proactive/overview`,ce,{refreshInterval:15e3}),we=!!Ce.data?.scenes.some(e=>e.status===`prepared`),Te=!!Ce.data?.scenes.some(e=>e.status===`changed`),Ee=!!Ce.data?.scenes.some(e=>e.status===`following`),De=!!Ce.data?.scenes.length,Oe=!!(x&&x.needsUser.length===0&&x.backgroundCount===0&&Ce.data&&!De),ke=Oe||te;(0,U.useEffect)(()=>{!ke&&K&&J()},[J,ke,K]),(0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||B||(e.preventDefault(),pe===`recording`?Y():pe===`idle`?(H.current?.focus(),q()):pe===`error`&&_e())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||!K||(e.preventDefault(),J(),H.current?.focus())};return window.addEventListener(L,e),window.addEventListener(ae,t),()=>{window.removeEventListener(L,e),window.removeEventListener(ae,t)}},[B,J,ke,Y,_e,q,K,pe]);let Ae=(0,U.useCallback)(e=>{e||J(),ne(e)},[J]),je=(0,U.useMemo)(()=>Oe?null:(0,z.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>ne(!0),children:[(0,z.jsx)(o,{className:`size-4`,"aria-hidden":!0}),r.newWork]}),[r.newWork,Oe]),Me=(0,U.useCallback)((e,t)=>{if(e.type===`open`){a(e.href);return}if(e.type===`review_judgment`){a(`/assistant-work?item=${encodeURIComponent(e.itemId)}`);return}R(t),N(null),(async()=>{try{e.type===`connector_decision`?await w({kind:`connector_approval`,approvalId:e.approvalId},e.decision):e.type===`retry_run`?await T({kind:e.subjectKind,runId:e.runId}):e.type===`acknowledge_run`&&await S({kind:e.subjectKind,runId:e.runId}),await X()}catch(e){N(e instanceof Error?e.message:String(e))}finally{R(null)}})()},[X,a]);(0,U.useLayoutEffect)(()=>(c({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:je}),()=>b()),[b,je,c,n.title]);let Ne=(x?.needsUser.length??0)+(Ce.data?.scenes.filter(e=>e.status===`needs_decision`).length??0),Pe=x?.backgroundCount??0,Fe=Ne>0?G(n.home.attentionTitle,{count:Ne}):we?e===`zh`?`助理准备好了这些`:`Your assistant prepared these`:Te?e===`zh`?`有一些值得知道的变化`:`A few changes are worth knowing`:Pe>0?n.home.clearTitle:Ee?e===`zh`?`助理在跟进你交代的事`:`Your assistant is following through`:Ce.data?n.home.idleTitle:e===`zh`?`今天的工作`:`Your work today`,Ie=Ne>0?Pe>0?G(n.home.attentionIntroWithBackground,{count:Pe}):n.home.attentionIntro:we?e===`zh`?`成果已经整理好,可以直接查看或继续办理。`:`The results are ready to review or continue.`:Te?e===`zh`?`这里是可能影响你当前工作的最新变化。`:`These changes may affect your current work.`:Pe>0?G(n.home.clearIntro,{count:Pe}):Ee?e===`zh`?`助理记着这些事项,有实质进展时会带回来。`:`Your assistant remembers these items and will bring back useful progress.`:Ce.data?n.home.idleIntro:e===`zh`?`正在核对已交代的事项。`:`Checking your delegated work.`;return(0,z.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 py-8 sm:px-6 lg:px-8 lg:py-12`,children:[(0,z.jsx)(`input`,{ref:V.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Z(Array.from(t)),e.target.value=``}}),(0,z.jsx)(_,{open:te,onOpenChange:Ae,children:(0,z.jsxs)(m,{children:[(0,z.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(g,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,z.jsx)(f,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0})})})]}),(0,z.jsx)(W,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:H,intent:I,labels:{...Se,submit:r.submit},attachments:V.attachments,isDragging:V.isDragging,attachmentBusy:B,attachmentsFull:xe,voice:fe,chat:t.chat,cancelAction:(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:se,onPickFiles:()=>V.fileInputRef.current?.click(),onRemoveAttachment:V.removeAttachment,onPaste:e=>void Q(e),onDragOver:$,onDragLeave:ve,onDrop:e=>void ye(e),onSubmit:be})]})]})}),ee?(0,z.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,z.jsx)(`span`,{children:ee}),(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void X(),children:n.home.retry})]}):null,E?(0,z.jsx)(me,{}):x?(0,z.jsxs)(`div`,{className:Oe?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,z.jsxs)(`section`,{className:Oe?`w-full text-center`:`max-w-3xl`,children:[(0,z.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:Fe}),(0,z.jsx)(`p`,{className:Oe?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:Ie}),Oe?(0,z.jsx)(W,{variant:`inline`,inputId:`idle-conversation-intent`,inputRef:H,intent:I,labels:Se,attachments:V.attachments,isDragging:V.isDragging,attachmentBusy:B,attachmentsFull:xe,voice:fe,chat:t.chat,onIntentChange:se,onPickFiles:()=>V.fileInputRef.current?.click(),onRemoveAttachment:V.removeAttachment,onPaste:e=>void Q(e),onDragOver:$,onDragLeave:ve,onDrop:e=>void ye(e),onSubmit:be}):null]}),x.needsUser.length>0?(0,z.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,z.jsx)(D,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:x.needsUser.map(t=>(0,z.jsx)(he,{item:t,busy:le===t.id,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:Me},t.id))})]}):null,(0,z.jsx)(`section`,{className:Oe?`mt-6 sm:mt-8`:`mt-10`,children:(0,z.jsx)(de,{compact:!0})}),x.background.length>0?(0,z.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,z.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:G(n.home.backgroundCount,{count:x.backgroundCount})})]}),(0,z.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:x.background.map(e=>(0,z.jsx)(ge,{item:e,onAction:Me},e.id))})]}):null]}):null]})}export{K as HomePage};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./locale-store-CwuCkjo7.js";async function n(){let n=await e(t(`/api/image-generation/catalog`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid image provider catalog`);return n.payload.providers}async function r(){let n=await e(t(`/api/image-generation/custom-providers`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid custom image provider list`);return n.payload.providers}async function i(n,r){await e(t(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`PUT`,body:JSON.stringify(r)})}async function a(n){await e(t(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`DELETE`})}async function o(n,r){await e(t(`/api/image-generation/providers/${encodeURIComponent(n)}/credential`),{method:`PUT`,body:JSON.stringify({apiKey:r})})}async function s(n,r){let i=await e(t(`/api/image-generation/providers/${encodeURIComponent(n)}/test`),{method:`POST`,body:JSON.stringify({modelId:r})});if(!Array.isArray(i.payload?.images))throw Error(`Invalid image generation test response`);return{images:i.payload.images}}export{o as a,i,r as n,s as o,n as r,a as t};
1
+ import{a as e,r as t}from"./locale-store-DuG-kbsP.js";async function n(){let n=await e(t(`/api/image-generation/catalog`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid image provider catalog`);return n.payload.providers}async function r(){let n=await e(t(`/api/image-generation/custom-providers`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid custom image provider list`);return n.payload.providers}async function i(n,r){await e(t(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`PUT`,body:JSON.stringify(r)})}async function a(n){await e(t(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`DELETE`})}async function o(n,r){await e(t(`/api/image-generation/providers/${encodeURIComponent(n)}/credential`),{method:`PUT`,body:JSON.stringify({apiKey:r})})}async function s(n,r){let i=await e(t(`/api/image-generation/providers/${encodeURIComponent(n)}/test`),{method:`POST`,body:JSON.stringify({modelId:r})});if(!Array.isArray(i.payload?.images))throw Error(`Invalid image generation test response`);return{images:i.payload.images}}export{o as a,i,r as n,s as o,n as r,a as t};
@@ -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"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./download-Dk-ZjtO6.js";import{t as s}from"./x-B_N4OPjy.js";import{a as c,n as ee,r as l}from"./locale-store-CwuCkjo7.js";import{t as te}from"./messages-D6CRVWtT.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{t as _}from"./button-CGlRPNzi.js";import{i as v,o as y}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as b,r as x}from"./settings-page-layout-CsUQKRq0.js";import{n as ne}from"./settings-loading-skeleton-CAmWMaOT.js";var S=e(t(),1);async function C(e,t,n){return(await c(l(`/api/imports${e}`),{...t===void 0?{}:{method:`POST`,body:JSON.stringify(t)},signal:n})).data}var w=n();function T(e){return e.status===`ready`||e.status===`conflict`||e.kind===`project`&&e.status===`existing`}function E(e,t,n,r){let i=new Set(t);if(!T(n))return i;if(r){if(i.add(n.id),n.parentId&&i.add(n.parentId),n.kind===`project`)for(let t of e.candidates)t.parentId===n.id&&t.kind===`skill`&&t.suggested&&T(t)&&i.add(t.id)}else if(i.delete(n.id),n.kind===`project`)for(let t of e.candidates)t.parentId===n.id&&i.delete(t.id);return i}var D=r();function O(e){let t=(0,w.c)(45),{open:n,sourceName:r,inventory:i,selected:a,onSelected:o,busy:c,locked:l,error:b,onClose:x,onRefresh:C,onSubmit:O}=e,R=te(ee(re)).imports,[z,ae]=(0,S.useState)(``),oe;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>ae(``),t[0]=oe):oe=t[0];let se=i?.id,B;t[1]===se?B=t[2]:(B=[se],t[1]=se,t[2]=B),(0,S.useEffect)(oe,B);let V;t[3]===z?V=t[4]:(V=e=>`${e.name} ${e.description} ${e.displayPath}`.toLowerCase().includes(z.toLowerCase().trim()),t[3]=z,t[4]=V);let H=V,U=i?.candidates.filter(e=>a.has(e.id))??[],ce=R.selected.replace(`{skills}`,String(U.filter(L).length)).replace(`{context}`,String(U.filter(I).length)).replace(`{projects}`,String(U.filter(F).length)),W;t[5]!==i||t[6]!==o||t[7]!==a?(W=(e,t)=>{i&&o(E(i,a,e,t))},t[5]=i,t[6]=o,t[7]=a,t[8]=W):W=t[8];let le=W,ue=e=>{let t=i.candidates.filter(t=>t.kind===e&&!t.parentId);if(!t.length)return null;let n=t.filter(H);return(0,D.jsxs)(`section`,{className:`space-y-2`,"aria-label":R.kinds[e],children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`h3`,{className:`text-sm font-medium text-fg`,children:[R.kinds[e],` · `,t.filter(e=>a.has(e.id)).length,`/`,t.length]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(_,{variant:`ghost`,disabled:l||!n.some(T),onClick:()=>{let e=new Set(a);n.filter(T).forEach(t=>e.add(t.id)),o(e)},children:R.selectVisible}),(0,D.jsx)(_,{variant:`ghost`,disabled:l,onClick:()=>{let e=new Set(a);n.forEach(t=>e.delete(t.id)),o(e)},children:R.clearVisible})]})]}),n.map(e=>(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)},e.id))]})},G;t[9]===x?G=t[10]:(G=e=>{e||x()},t[9]=x,t[10]=G);let K;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,D.jsx)(u,{className:`fixed inset-0 bg-scrim ${y}`}),t[11]=K):K=t[11];let de;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,D.jsx)(s,{className:`h-4 w-4`}),t[12]=de):de=t[12];let fe;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>ae(e.target.value),t[13]=fe):fe=t[13];let pe=b&&(0,D.jsxs)(`div`,{role:`alert`,className:`space-y-2 rounded-lg border border-edge p-3 text-sm text-fg`,children:[(0,D.jsx)(`p`,{children:b}),(0,D.jsx)(_,{variant:`secondary`,disabled:l,onClick:C,children:R.refresh})]}),q;t[14]!==b||t[15]!==i?(q=!i&&!b&&(0,D.jsx)(ne,{sections:2}),t[14]=b,t[15]=i,t[16]=q):q=t[16];let me=i&&(0,D.jsxs)(D.Fragment,{children:[!i.complete&&(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.incomplete}),ue(`skill`),ue(`context`),(0,D.jsxs)(`section`,{"aria-label":R.kinds.project,className:`space-y-2`,children:[(0,D.jsxs)(`h3`,{className:`text-sm font-medium text-fg`,children:[R.kinds.project,` · `,U.filter(P).length,`/`,i.candidates.filter(N).length]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.projectHint}),i.candidates.filter(M).map(e=>{let t=i.candidates.filter(t=>t.parentId===e.id);return!H(e)&&!t.some(H)?null:(0,D.jsxs)(`div`,{className:`rounded-xl border border-edge p-3`,children:[(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)}),t.length?(0,D.jsxs)(`details`,{open:z.trim()?!0:void 0,className:`mt-2 text-sm text-fg-muted`,children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer`,children:[R.projectContents.replace(`{skills}`,String(t.filter(j).length)).replace(`{context}`,String(t.filter(A).length)),` · `,R.chosenCount.replace(`{count}`,String(t.filter(e=>a.has(e.id)).length))]}),(0,D.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-edge pl-3`,children:t.filter(t=>H(e)||H(t)).map(e=>(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)},e.id))})]}):(0,D.jsx)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:R.directoryOnly})]},e.id)})]}),!i.candidates.length&&(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.noContent}),!!i.notices.length&&(0,D.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer`,children:[R.scanNotices,` (`,i.notices.length,`)`]}),(0,D.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.notices.map(k)})]})]}),he;t[17]!==pe||t[18]!==q||t[19]!==me?(he=(0,D.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4 sm:p-5`,children:[pe,q,me]}),t[17]=pe,t[18]=q,t[19]=me,t[20]=he):he=t[20];let J;t[21]===ce?J=t[22]:(J=(0,D.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-fg-muted`,children:ce}),t[21]=ce,t[22]=J);let Y;t[23]!==c||t[24]!==R.runningHint?(Y=c&&(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.runningHint}),t[23]=c,t[24]=R.runningHint,t[25]=Y):Y=t[25];let X;t[26]!==c||t[27]!==l||t[28]!==R.retryHint?(X=l&&!c&&(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.retryHint}),t[26]=c,t[27]=l,t[28]=R.retryHint,t[29]=X):X=t[29];let ge=c?R.close:R.cancel,Z;t[30]!==x||t[31]!==ge?(Z=(0,D.jsx)(_,{variant:`ghost`,onClick:x,children:ge}),t[30]=x,t[31]=ge,t[32]=Z):Z=t[32];let _e=!i||!a.size||c,ve=c?R.importing:l?R.retry:R.importSelected,Q;t[33]!==O||t[34]!==_e||t[35]!==ve?(Q=(0,D.jsx)(_,{disabled:_e,onClick:O,children:ve}),t[33]=O,t[34]=_e,t[35]=ve,t[36]=Q):Q=t[36];let $;t[37]!==Z||t[38]!==Q?($=(0,D.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[Z,Q]}),t[37]=Z,t[38]=Q,t[39]=$):$=t[39];let ye;return t[40]!==J||t[41]!==Y||t[42]!==X||t[43]!==$?(ye=(0,D.jsxs)(`footer`,{className:`shrink-0 space-y-3 border-t border-edge p-4 sm:p-5`,children:[J,Y,X,$]}),t[40]=J,t[41]=Y,t[42]=X,t[43]=$,t[44]=ye):ye=t[44],(0,D.jsx)(g,{open:n,onOpenChange:G,children:(0,D.jsxs)(p,{children:[K,(0,D.jsxs)(m,{className:`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),760px)] w-[min(calc(100%-2rem),760px)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel outline-none ${v}`,children:[(0,D.jsxs)(`header`,{className:`shrink-0 space-y-2 border-b border-edge p-4 sm:p-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(h,{className:`text-lg font-semibold text-fg`,children:R.chooseTitle.replace(`{source}`,r)}),(0,D.jsx)(f,{asChild:!0,children:(0,D.jsx)(_,{variant:`ghost`,"aria-label":R.close,className:`h-8 w-8 shrink-0 p-0`,children:de})})]}),(0,D.jsx)(d,{className:`text-sm text-fg-muted`,children:R.chooseHint}),(0,D.jsx)(`input`,{"aria-label":R.search,placeholder:R.search,value:z,onChange:fe,className:`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`})]}),he,ye]})]})})}function k(e,t){return(0,D.jsx)(`li`,{className:`break-words`,children:e},t)}function A(e){return e.kind===`context`}function j(e){return e.kind===`skill`}function M(e){return e.kind===`project`}function N(e){return e.kind===`project`}function P(e){return e.kind===`project`}function F(e){return e.kind===`project`}function I(e){return e.kind===`context`}function L(e){return e.kind===`skill`}function re(e){return e.language}function ie(e){let t=(0,w.c)(54),{inventoryId:n,item:r,checked:i,disabled:a,onChange:o}=e,s=ee(z),c;t[0]===s?c=t[1]:(c=te(s),t[0]=s,t[1]=c);let l=c.imports,[u,d]=(0,S.useState)(),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(!1),g;t[2]!==n||t[3]!==r.id||t[4]!==u?(g=async function(){if(h(R),!u)try{d(await C(`/inventories/${n}/items/${r.id}/preview`))}catch(e){let t=e;p(t instanceof Error?t.message:String(t))}},t[2]=n,t[3]=r.id,t[4]=u,t[5]=g):g=t[5];let v=g,y;t[6]!==a||t[7]!==r?(y=a||!T(r),t[6]=a,t[7]=r,t[8]=y):y=t[8];let b;t[9]===o?b=t[10]:(b=e=>o(e.target.checked),t[9]=o,t[10]=b);let x;t[11]!==i||t[12]!==y||t[13]!==b?(x=(0,D.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-4 w-4 shrink-0 accent-accent`,checked:i,disabled:y,onChange:b}),t[11]=i,t[12]=y,t[13]=b,t[14]=x):x=t[14];let E;t[15]===r.name?E=t[16]:(E=(0,D.jsx)(`span`,{className:`block break-words text-sm font-medium text-fg`,children:r.name}),t[15]=r.name,t[16]=E);let O;t[17]===r.displayPath?O=t[18]:(O=(0,D.jsx)(`span`,{className:`block break-all text-xs text-fg-muted`,children:r.displayPath}),t[17]=r.displayPath,t[18]=O);let k;t[19]!==E||t[20]!==O?(k=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[E,O]}),t[19]=E,t[20]=O,t[21]=k):k=t[21];let A;t[22]!==x||t[23]!==k?(A=(0,D.jsxs)(`label`,{className:`flex min-w-0 flex-1 cursor-pointer items-start gap-3`,children:[x,k]}),t[22]=x,t[23]=k,t[24]=A):A=t[24];let j;t[25]!==r.kind||t[26]!==r.name||t[27]!==r.status||t[28]!==l||t[29]!==v?(j=r.kind!==`project`&&r.status!==`blocked`&&(0,D.jsx)(_,{variant:`ghost`,"aria-label":`${l.preview}: ${r.name}`,onClick:()=>void v(),children:l.preview}),t[25]=r.kind,t[26]=r.name,t[27]=r.status,t[28]=l,t[29]=v,t[30]=j):j=t[30];let M;t[31]!==A||t[32]!==j?(M=(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[A,j]}),t[31]=A,t[32]=j,t[33]=M):M=t[33];let N;t[34]===r.description?N=t[35]:(N=r.description&&(0,D.jsx)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:r.description}),t[34]=r.description,t[35]=N);let P;t[36]!==r.kind||t[37]!==r.status||t[38]!==r.targetName||t[39]!==l?(P=r.status!==`ready`&&(0,D.jsxs)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:[r.kind===`project`&&r.status===`existing`?l.existingProject:l.statuses[r.status],r.status===`conflict`?` → ${r.targetName}`:``]}),t[36]=r.kind,t[37]=r.status,t[38]=r.targetName,t[39]=l,t[40]=P):P=t[40];let F;t[41]===r.reason?F=t[42]:(F=r.reason&&(0,D.jsx)(`p`,{className:`break-words pl-7 text-xs text-fg-muted`,children:r.reason}),t[41]=r.reason,t[42]=F);let I;t[43]!==u||t[44]!==f||t[45]!==m||t[46]!==l?(I=m&&(0,D.jsx)(`div`,{className:`ml-7 rounded-lg border border-edge p-3`,children:f?(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:f}):u?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`pre`,{className:`max-h-60 overflow-auto whitespace-pre-wrap break-words text-xs text-fg`,children:u.text}),u.truncated&&(0,D.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:l.previewTruncated})]}):(0,D.jsx)(ne,{sections:1})}),t[43]=u,t[44]=f,t[45]=m,t[46]=l,t[47]=I):I=t[47];let L;return t[48]!==M||t[49]!==N||t[50]!==P||t[51]!==F||t[52]!==I?(L=(0,D.jsxs)(`div`,{className:`min-w-0 space-y-1 rounded-lg p-1`,children:[M,N,P,F,I]}),t[48]=M,t[49]=N,t[50]=P,t[51]=F,t[52]=I,t[53]=L):L=t[53],L}function R(e){return!e}function z(e){return e.language}function ae(){let e=te(ee(e=>e.language)).imports,[t,n]=(0,S.useState)(),[r,s]=(0,S.useState)(),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(),[f,p]=(0,S.useState)(new Set),[m,h]=(0,S.useState)(!1),[g,v]=(0,S.useState)(),[y,w]=(0,S.useState)(),[T,E]=(0,S.useState)(``),[k,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(0),N=(0,S.useRef)(null),P=(0,S.useRef)(!1);(0,S.useEffect)(()=>{let e=new AbortController;return E(``),C(`/sources`,void 0,e.signal).then(e=>n(e.sources)).catch(t=>{e.signal.aborted||E(t instanceof Error?t.message:String(t))}),()=>{e.abort(),N.current?.abort()}},[j]);let F=(t?.flatMap(e=>e.lastImport?.status===`running`?[e.lastImport.id]:[])??[]).join(`,`);(0,S.useEffect)(()=>{if(!F)return;let e=new AbortController,t,n=async()=>{for(let t of F.split(`,`))try{let n=await C(`/runs/${t}`,void 0,e.signal);e.signal.aborted||I(n)}catch{}e.signal.aborted||(t=setTimeout(()=>void n(),3e3))};return t=setTimeout(()=>void n(),1500),()=>{e.abort(),clearTimeout(t)}},[F]);function I(e){n(t=>t?.map(t=>t.id===e.source?{...t,lastImport:e}:t)),e.status!==`running`&&v(t=>t?.requestId===e.id?void 0:t)}async function L(e){N.current?.abort();let t=new AbortController;N.current=t,s(e),l(!0),d(void 0),p(new Set),A(``),w(void 0),v(void 0);try{let n=await C(`/sources/${e}/scan`,{},t.signal);t.signal.aborted||(d(n),p(new Set(n.candidates.filter(e=>!e.parentId&&e.suggested).map(e=>e.id))))}catch(e){t.signal.aborted||A(e instanceof Error?e.message:String(e))}}async function re(){if(!u||!f.size||P.current)return;P.current=!0,h(!0),A(``),E(``);let e=g??{inventoryId:u.id,candidateIds:[...f],requestId:crypto.randomUUID(),retryOf:y};v(e);try{I(await C(`/runs`,e)),l(!1)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),E(t);let n=e.body?.code;n&&[`invalid_input`,`inventory_stale`,`invalid_selection`,`missing_parent`,`not_found`,`conflict`].includes(n)&&v(void 0)}finally{P.current=!1,h(!1)}}async function ie(e){s(e.source),l(!0),d(void 0),p(new Set),A(``),v(void 0),w(e.id),N.current?.abort();let t=new AbortController;N.current=t;try{let n=await C(`/inventories/${e.inventoryId}`,void 0,t.signal);if(t.signal.aborted)return;let r=new Set(e.items.filter(e=>e.status===`failed`).map(e=>e.candidateId));n.candidates.forEach(e=>{r.has(e.id)&&e.parentId&&r.add(e.parentId)}),d({...n,candidates:n.candidates.filter(e=>r.has(e.id))}),p(r)}catch(e){t.signal.aborted||A(e instanceof Error?e.message:String(e))}}let R=t?.filter(e=>e.detected||e.lastImport);return(0,D.jsxs)(x,{children:[(0,D.jsx)(b,{title:e.title,subtitle:e.subtitle}),T&&(0,D.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-edge p-4 text-sm text-fg`,children:[(0,D.jsx)(`p`,{children:T}),!t&&(0,D.jsx)(_,{variant:`ghost`,onClick:()=>M(e=>e+1),children:e.retry})]}),!t&&!T&&(0,D.jsx)(ne,{sections:1}),t&&(0,D.jsxs)(`section`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-base font-medium text-fg`,children:e.apps}),(0,D.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.detectedHint})]}),R?.length?(0,D.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-2xl border border-edge`,children:R.map(t=>(0,D.jsxs)(`article`,{className:`space-y-3 p-5 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,D.jsx)(`div`,{"aria-hidden":`true`,className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg`,children:(0,D.jsx)(o,{className:`h-5 w-5`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`h3`,{className:`font-medium text-fg`,children:t.name}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.includes})]}),(0,D.jsx)(_,{variant:`secondary`,disabled:m||!t.detected||!!g&&r!==t.id||t.lastImport?.status===`running`,onClick:()=>{E(``),g&&r===t.id?l(!0):L(t.id)},children:m&&r===t.id?e.importing:g&&r===t.id?e.retry:t.lastImport?e.importAgain:e.import})]}),t.lastImport&&(0,D.jsxs)(`div`,{role:`status`,className:`space-y-2 text-sm text-fg-muted`,children:[(0,D.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(a,{className:`h-4 w-4 shrink-0`}),t.lastImport.status===`running`?e.importing:t.lastImport.issues.length?e.finishedWithIssues:e.finished]}),(0,D.jsxs)(`p`,{children:[e.summary.replace(`{skills}`,String(t.lastImport.skills)).replace(`{context}`,String(t.lastImport.context)).replace(`{projects}`,String(t.lastImport.projects)),t.lastImport.skipped>0&&` · ${e.skipped.replace(`{count}`,String(t.lastImport.skipped))}`]}),!!t.lastImport.issues.length&&(0,D.jsxs)(`details`,{children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer text-fg`,children:[e.details,` (`,t.lastImport.issues.length,`)`]}),(0,D.jsx)(`ul`,{className:`mt-2 space-y-2`,children:t.lastImport.issues.map((e,t)=>(0,D.jsxs)(`li`,{className:`break-words`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.name}),` — `,e.reason]},t))})]}),t.lastImport.status===`partial`&&(0,D.jsx)(_,{variant:`ghost`,disabled:m||!!g,onClick:()=>void ie(t.lastImport),children:e.retryFailed})]})]},t.id))}):(0,D.jsxs)(`div`,{className:`rounded-2xl border border-edge p-6 text-sm text-fg-muted`,children:[(0,D.jsx)(`p`,{children:e.empty}),(0,D.jsx)(_,{variant:`ghost`,className:`mt-3`,onClick:()=>M(e=>e+1),children:e.refresh})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.footnote}),R?.some(e=>e.lastImport)&&(0,D.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,D.jsx)(i,{className:`text-accent`,to:`/skills`,children:e.openSkills}),(0,D.jsx)(i,{className:`text-accent`,to:`/projects`,children:e.openProjects}),(0,D.jsx)(i,{className:`text-accent`,to:`/connectors`,children:e.connections})]})]}),(0,D.jsx)(O,{open:c,sourceName:t?.find(e=>e.id===r)?.name??``,inventory:u,selected:f,onSelected:p,busy:m,locked:m||!!g,error:k,onClose:()=>{N.current?.abort(),l(!1)},onRefresh:()=>{r&&L(r)},onSubmit:()=>void re()})]})}export{ae as ImportsPage};
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"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./download-Dk-ZjtO6.js";import{t as s}from"./x-B_N4OPjy.js";import{a as c,n as ee,r as l}from"./locale-store-DuG-kbsP.js";import{t as te}from"./messages-BYbx4OuI.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{t as _}from"./button-CGlRPNzi.js";import{i as v,o as y}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as b,r as x}from"./settings-page-layout-CsUQKRq0.js";import{n as ne}from"./settings-loading-skeleton-CAmWMaOT.js";var S=e(t(),1);async function C(e,t,n){return(await c(l(`/api/imports${e}`),{...t===void 0?{}:{method:`POST`,body:JSON.stringify(t)},signal:n})).data}var w=n();function T(e){return e.status===`ready`||e.status===`conflict`||e.kind===`project`&&e.status===`existing`}function E(e,t,n,r){let i=new Set(t);if(!T(n))return i;if(r){if(i.add(n.id),n.parentId&&i.add(n.parentId),n.kind===`project`)for(let t of e.candidates)t.parentId===n.id&&t.kind===`skill`&&t.suggested&&T(t)&&i.add(t.id)}else if(i.delete(n.id),n.kind===`project`)for(let t of e.candidates)t.parentId===n.id&&i.delete(t.id);return i}var D=r();function O(e){let t=(0,w.c)(45),{open:n,sourceName:r,inventory:i,selected:a,onSelected:o,busy:c,locked:l,error:b,onClose:x,onRefresh:C,onSubmit:O}=e,R=te(ee(re)).imports,[z,ae]=(0,S.useState)(``),oe;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>ae(``),t[0]=oe):oe=t[0];let se=i?.id,B;t[1]===se?B=t[2]:(B=[se],t[1]=se,t[2]=B),(0,S.useEffect)(oe,B);let V;t[3]===z?V=t[4]:(V=e=>`${e.name} ${e.description} ${e.displayPath}`.toLowerCase().includes(z.toLowerCase().trim()),t[3]=z,t[4]=V);let H=V,U=i?.candidates.filter(e=>a.has(e.id))??[],ce=R.selected.replace(`{skills}`,String(U.filter(L).length)).replace(`{context}`,String(U.filter(I).length)).replace(`{projects}`,String(U.filter(F).length)),W;t[5]!==i||t[6]!==o||t[7]!==a?(W=(e,t)=>{i&&o(E(i,a,e,t))},t[5]=i,t[6]=o,t[7]=a,t[8]=W):W=t[8];let le=W,ue=e=>{let t=i.candidates.filter(t=>t.kind===e&&!t.parentId);if(!t.length)return null;let n=t.filter(H);return(0,D.jsxs)(`section`,{className:`space-y-2`,"aria-label":R.kinds[e],children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`h3`,{className:`text-sm font-medium text-fg`,children:[R.kinds[e],` · `,t.filter(e=>a.has(e.id)).length,`/`,t.length]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(_,{variant:`ghost`,disabled:l||!n.some(T),onClick:()=>{let e=new Set(a);n.filter(T).forEach(t=>e.add(t.id)),o(e)},children:R.selectVisible}),(0,D.jsx)(_,{variant:`ghost`,disabled:l,onClick:()=>{let e=new Set(a);n.forEach(t=>e.delete(t.id)),o(e)},children:R.clearVisible})]})]}),n.map(e=>(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)},e.id))]})},G;t[9]===x?G=t[10]:(G=e=>{e||x()},t[9]=x,t[10]=G);let K;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,D.jsx)(u,{className:`fixed inset-0 bg-scrim ${y}`}),t[11]=K):K=t[11];let de;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,D.jsx)(s,{className:`h-4 w-4`}),t[12]=de):de=t[12];let fe;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>ae(e.target.value),t[13]=fe):fe=t[13];let pe=b&&(0,D.jsxs)(`div`,{role:`alert`,className:`space-y-2 rounded-lg border border-edge p-3 text-sm text-fg`,children:[(0,D.jsx)(`p`,{children:b}),(0,D.jsx)(_,{variant:`secondary`,disabled:l,onClick:C,children:R.refresh})]}),q;t[14]!==b||t[15]!==i?(q=!i&&!b&&(0,D.jsx)(ne,{sections:2}),t[14]=b,t[15]=i,t[16]=q):q=t[16];let me=i&&(0,D.jsxs)(D.Fragment,{children:[!i.complete&&(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.incomplete}),ue(`skill`),ue(`context`),(0,D.jsxs)(`section`,{"aria-label":R.kinds.project,className:`space-y-2`,children:[(0,D.jsxs)(`h3`,{className:`text-sm font-medium text-fg`,children:[R.kinds.project,` · `,U.filter(P).length,`/`,i.candidates.filter(N).length]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.projectHint}),i.candidates.filter(M).map(e=>{let t=i.candidates.filter(t=>t.parentId===e.id);return!H(e)&&!t.some(H)?null:(0,D.jsxs)(`div`,{className:`rounded-xl border border-edge p-3`,children:[(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)}),t.length?(0,D.jsxs)(`details`,{open:z.trim()?!0:void 0,className:`mt-2 text-sm text-fg-muted`,children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer`,children:[R.projectContents.replace(`{skills}`,String(t.filter(j).length)).replace(`{context}`,String(t.filter(A).length)),` · `,R.chosenCount.replace(`{count}`,String(t.filter(e=>a.has(e.id)).length))]}),(0,D.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-edge pl-3`,children:t.filter(t=>H(e)||H(t)).map(e=>(0,D.jsx)(ie,{inventoryId:i.id,item:e,checked:a.has(e.id),disabled:l,onChange:t=>le(e,t)},e.id))})]}):(0,D.jsx)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:R.directoryOnly})]},e.id)})]}),!i.candidates.length&&(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.noContent}),!!i.notices.length&&(0,D.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer`,children:[R.scanNotices,` (`,i.notices.length,`)`]}),(0,D.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.notices.map(k)})]})]}),he;t[17]!==pe||t[18]!==q||t[19]!==me?(he=(0,D.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4 sm:p-5`,children:[pe,q,me]}),t[17]=pe,t[18]=q,t[19]=me,t[20]=he):he=t[20];let J;t[21]===ce?J=t[22]:(J=(0,D.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-fg-muted`,children:ce}),t[21]=ce,t[22]=J);let Y;t[23]!==c||t[24]!==R.runningHint?(Y=c&&(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.runningHint}),t[23]=c,t[24]=R.runningHint,t[25]=Y):Y=t[25];let X;t[26]!==c||t[27]!==l||t[28]!==R.retryHint?(X=l&&!c&&(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R.retryHint}),t[26]=c,t[27]=l,t[28]=R.retryHint,t[29]=X):X=t[29];let ge=c?R.close:R.cancel,Z;t[30]!==x||t[31]!==ge?(Z=(0,D.jsx)(_,{variant:`ghost`,onClick:x,children:ge}),t[30]=x,t[31]=ge,t[32]=Z):Z=t[32];let _e=!i||!a.size||c,ve=c?R.importing:l?R.retry:R.importSelected,Q;t[33]!==O||t[34]!==_e||t[35]!==ve?(Q=(0,D.jsx)(_,{disabled:_e,onClick:O,children:ve}),t[33]=O,t[34]=_e,t[35]=ve,t[36]=Q):Q=t[36];let $;t[37]!==Z||t[38]!==Q?($=(0,D.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[Z,Q]}),t[37]=Z,t[38]=Q,t[39]=$):$=t[39];let ye;return t[40]!==J||t[41]!==Y||t[42]!==X||t[43]!==$?(ye=(0,D.jsxs)(`footer`,{className:`shrink-0 space-y-3 border-t border-edge p-4 sm:p-5`,children:[J,Y,X,$]}),t[40]=J,t[41]=Y,t[42]=X,t[43]=$,t[44]=ye):ye=t[44],(0,D.jsx)(g,{open:n,onOpenChange:G,children:(0,D.jsxs)(p,{children:[K,(0,D.jsxs)(m,{className:`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),760px)] w-[min(calc(100%-2rem),760px)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel outline-none ${v}`,children:[(0,D.jsxs)(`header`,{className:`shrink-0 space-y-2 border-b border-edge p-4 sm:p-5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(h,{className:`text-lg font-semibold text-fg`,children:R.chooseTitle.replace(`{source}`,r)}),(0,D.jsx)(f,{asChild:!0,children:(0,D.jsx)(_,{variant:`ghost`,"aria-label":R.close,className:`h-8 w-8 shrink-0 p-0`,children:de})})]}),(0,D.jsx)(d,{className:`text-sm text-fg-muted`,children:R.chooseHint}),(0,D.jsx)(`input`,{"aria-label":R.search,placeholder:R.search,value:z,onChange:fe,className:`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`})]}),he,ye]})]})})}function k(e,t){return(0,D.jsx)(`li`,{className:`break-words`,children:e},t)}function A(e){return e.kind===`context`}function j(e){return e.kind===`skill`}function M(e){return e.kind===`project`}function N(e){return e.kind===`project`}function P(e){return e.kind===`project`}function F(e){return e.kind===`project`}function I(e){return e.kind===`context`}function L(e){return e.kind===`skill`}function re(e){return e.language}function ie(e){let t=(0,w.c)(54),{inventoryId:n,item:r,checked:i,disabled:a,onChange:o}=e,s=ee(z),c;t[0]===s?c=t[1]:(c=te(s),t[0]=s,t[1]=c);let l=c.imports,[u,d]=(0,S.useState)(),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(!1),g;t[2]!==n||t[3]!==r.id||t[4]!==u?(g=async function(){if(h(R),!u)try{d(await C(`/inventories/${n}/items/${r.id}/preview`))}catch(e){let t=e;p(t instanceof Error?t.message:String(t))}},t[2]=n,t[3]=r.id,t[4]=u,t[5]=g):g=t[5];let v=g,y;t[6]!==a||t[7]!==r?(y=a||!T(r),t[6]=a,t[7]=r,t[8]=y):y=t[8];let b;t[9]===o?b=t[10]:(b=e=>o(e.target.checked),t[9]=o,t[10]=b);let x;t[11]!==i||t[12]!==y||t[13]!==b?(x=(0,D.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-4 w-4 shrink-0 accent-accent`,checked:i,disabled:y,onChange:b}),t[11]=i,t[12]=y,t[13]=b,t[14]=x):x=t[14];let E;t[15]===r.name?E=t[16]:(E=(0,D.jsx)(`span`,{className:`block break-words text-sm font-medium text-fg`,children:r.name}),t[15]=r.name,t[16]=E);let O;t[17]===r.displayPath?O=t[18]:(O=(0,D.jsx)(`span`,{className:`block break-all text-xs text-fg-muted`,children:r.displayPath}),t[17]=r.displayPath,t[18]=O);let k;t[19]!==E||t[20]!==O?(k=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[E,O]}),t[19]=E,t[20]=O,t[21]=k):k=t[21];let A;t[22]!==x||t[23]!==k?(A=(0,D.jsxs)(`label`,{className:`flex min-w-0 flex-1 cursor-pointer items-start gap-3`,children:[x,k]}),t[22]=x,t[23]=k,t[24]=A):A=t[24];let j;t[25]!==r.kind||t[26]!==r.name||t[27]!==r.status||t[28]!==l||t[29]!==v?(j=r.kind!==`project`&&r.status!==`blocked`&&(0,D.jsx)(_,{variant:`ghost`,"aria-label":`${l.preview}: ${r.name}`,onClick:()=>void v(),children:l.preview}),t[25]=r.kind,t[26]=r.name,t[27]=r.status,t[28]=l,t[29]=v,t[30]=j):j=t[30];let M;t[31]!==A||t[32]!==j?(M=(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[A,j]}),t[31]=A,t[32]=j,t[33]=M):M=t[33];let N;t[34]===r.description?N=t[35]:(N=r.description&&(0,D.jsx)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:r.description}),t[34]=r.description,t[35]=N);let P;t[36]!==r.kind||t[37]!==r.status||t[38]!==r.targetName||t[39]!==l?(P=r.status!==`ready`&&(0,D.jsxs)(`p`,{className:`pl-7 text-xs text-fg-muted`,children:[r.kind===`project`&&r.status===`existing`?l.existingProject:l.statuses[r.status],r.status===`conflict`?` → ${r.targetName}`:``]}),t[36]=r.kind,t[37]=r.status,t[38]=r.targetName,t[39]=l,t[40]=P):P=t[40];let F;t[41]===r.reason?F=t[42]:(F=r.reason&&(0,D.jsx)(`p`,{className:`break-words pl-7 text-xs text-fg-muted`,children:r.reason}),t[41]=r.reason,t[42]=F);let I;t[43]!==u||t[44]!==f||t[45]!==m||t[46]!==l?(I=m&&(0,D.jsx)(`div`,{className:`ml-7 rounded-lg border border-edge p-3`,children:f?(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:f}):u?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`pre`,{className:`max-h-60 overflow-auto whitespace-pre-wrap break-words text-xs text-fg`,children:u.text}),u.truncated&&(0,D.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:l.previewTruncated})]}):(0,D.jsx)(ne,{sections:1})}),t[43]=u,t[44]=f,t[45]=m,t[46]=l,t[47]=I):I=t[47];let L;return t[48]!==M||t[49]!==N||t[50]!==P||t[51]!==F||t[52]!==I?(L=(0,D.jsxs)(`div`,{className:`min-w-0 space-y-1 rounded-lg p-1`,children:[M,N,P,F,I]}),t[48]=M,t[49]=N,t[50]=P,t[51]=F,t[52]=I,t[53]=L):L=t[53],L}function R(e){return!e}function z(e){return e.language}function ae(){let e=te(ee(e=>e.language)).imports,[t,n]=(0,S.useState)(),[r,s]=(0,S.useState)(),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(),[f,p]=(0,S.useState)(new Set),[m,h]=(0,S.useState)(!1),[g,v]=(0,S.useState)(),[y,w]=(0,S.useState)(),[T,E]=(0,S.useState)(``),[k,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(0),N=(0,S.useRef)(null),P=(0,S.useRef)(!1);(0,S.useEffect)(()=>{let e=new AbortController;return E(``),C(`/sources`,void 0,e.signal).then(e=>n(e.sources)).catch(t=>{e.signal.aborted||E(t instanceof Error?t.message:String(t))}),()=>{e.abort(),N.current?.abort()}},[j]);let F=(t?.flatMap(e=>e.lastImport?.status===`running`?[e.lastImport.id]:[])??[]).join(`,`);(0,S.useEffect)(()=>{if(!F)return;let e=new AbortController,t,n=async()=>{for(let t of F.split(`,`))try{let n=await C(`/runs/${t}`,void 0,e.signal);e.signal.aborted||I(n)}catch{}e.signal.aborted||(t=setTimeout(()=>void n(),3e3))};return t=setTimeout(()=>void n(),1500),()=>{e.abort(),clearTimeout(t)}},[F]);function I(e){n(t=>t?.map(t=>t.id===e.source?{...t,lastImport:e}:t)),e.status!==`running`&&v(t=>t?.requestId===e.id?void 0:t)}async function L(e){N.current?.abort();let t=new AbortController;N.current=t,s(e),l(!0),d(void 0),p(new Set),A(``),w(void 0),v(void 0);try{let n=await C(`/sources/${e}/scan`,{},t.signal);t.signal.aborted||(d(n),p(new Set(n.candidates.filter(e=>!e.parentId&&e.suggested).map(e=>e.id))))}catch(e){t.signal.aborted||A(e instanceof Error?e.message:String(e))}}async function re(){if(!u||!f.size||P.current)return;P.current=!0,h(!0),A(``),E(``);let e=g??{inventoryId:u.id,candidateIds:[...f],requestId:crypto.randomUUID(),retryOf:y};v(e);try{I(await C(`/runs`,e)),l(!1)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),E(t);let n=e.body?.code;n&&[`invalid_input`,`inventory_stale`,`invalid_selection`,`missing_parent`,`not_found`,`conflict`].includes(n)&&v(void 0)}finally{P.current=!1,h(!1)}}async function ie(e){s(e.source),l(!0),d(void 0),p(new Set),A(``),v(void 0),w(e.id),N.current?.abort();let t=new AbortController;N.current=t;try{let n=await C(`/inventories/${e.inventoryId}`,void 0,t.signal);if(t.signal.aborted)return;let r=new Set(e.items.filter(e=>e.status===`failed`).map(e=>e.candidateId));n.candidates.forEach(e=>{r.has(e.id)&&e.parentId&&r.add(e.parentId)}),d({...n,candidates:n.candidates.filter(e=>r.has(e.id))}),p(r)}catch(e){t.signal.aborted||A(e instanceof Error?e.message:String(e))}}let R=t?.filter(e=>e.detected||e.lastImport);return(0,D.jsxs)(x,{children:[(0,D.jsx)(b,{title:e.title,subtitle:e.subtitle}),T&&(0,D.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-edge p-4 text-sm text-fg`,children:[(0,D.jsx)(`p`,{children:T}),!t&&(0,D.jsx)(_,{variant:`ghost`,onClick:()=>M(e=>e+1),children:e.retry})]}),!t&&!T&&(0,D.jsx)(ne,{sections:1}),t&&(0,D.jsxs)(`section`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-base font-medium text-fg`,children:e.apps}),(0,D.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.detectedHint})]}),R?.length?(0,D.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-2xl border border-edge`,children:R.map(t=>(0,D.jsxs)(`article`,{className:`space-y-3 p-5 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,D.jsx)(`div`,{"aria-hidden":`true`,className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg`,children:(0,D.jsx)(o,{className:`h-5 w-5`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`h3`,{className:`font-medium text-fg`,children:t.name}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.includes})]}),(0,D.jsx)(_,{variant:`secondary`,disabled:m||!t.detected||!!g&&r!==t.id||t.lastImport?.status===`running`,onClick:()=>{E(``),g&&r===t.id?l(!0):L(t.id)},children:m&&r===t.id?e.importing:g&&r===t.id?e.retry:t.lastImport?e.importAgain:e.import})]}),t.lastImport&&(0,D.jsxs)(`div`,{role:`status`,className:`space-y-2 text-sm text-fg-muted`,children:[(0,D.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(a,{className:`h-4 w-4 shrink-0`}),t.lastImport.status===`running`?e.importing:t.lastImport.issues.length?e.finishedWithIssues:e.finished]}),(0,D.jsxs)(`p`,{children:[e.summary.replace(`{skills}`,String(t.lastImport.skills)).replace(`{context}`,String(t.lastImport.context)).replace(`{projects}`,String(t.lastImport.projects)),t.lastImport.skipped>0&&` · ${e.skipped.replace(`{count}`,String(t.lastImport.skipped))}`]}),!!t.lastImport.issues.length&&(0,D.jsxs)(`details`,{children:[(0,D.jsxs)(`summary`,{className:`cursor-pointer text-fg`,children:[e.details,` (`,t.lastImport.issues.length,`)`]}),(0,D.jsx)(`ul`,{className:`mt-2 space-y-2`,children:t.lastImport.issues.map((e,t)=>(0,D.jsxs)(`li`,{className:`break-words`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.name}),` — `,e.reason]},t))})]}),t.lastImport.status===`partial`&&(0,D.jsx)(_,{variant:`ghost`,disabled:m||!!g,onClick:()=>void ie(t.lastImport),children:e.retryFailed})]})]},t.id))}):(0,D.jsxs)(`div`,{className:`rounded-2xl border border-edge p-6 text-sm text-fg-muted`,children:[(0,D.jsx)(`p`,{children:e.empty}),(0,D.jsx)(_,{variant:`ghost`,className:`mt-3`,onClick:()=>M(e=>e+1),children:e.refresh})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.footnote}),R?.some(e=>e.lastImport)&&(0,D.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,D.jsx)(i,{className:`text-accent`,to:`/skills`,children:e.openSkills}),(0,D.jsx)(i,{className:`text-accent`,to:`/projects`,children:e.openProjects}),(0,D.jsx)(i,{className:`text-accent`,to:`/connectors`,children:e.connections})]})]}),(0,D.jsx)(O,{open:c,sourceName:t?.find(e=>e.id===r)?.name??``,inventory:u,selected:f,onSelected:p,busy:m,locked:m||!!g,error:k,onClose:()=>{N.current?.abort(),l(!1)},onRefresh:()=>{r&&L(r)},onSubmit:()=>void re()})]})}export{ae as ImportsPage};