limixbot 0.3.81 → 0.3.83

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 (124) hide show
  1. package/dist/assets/{ActivityPanel-BXFEtu90.js → ActivityPanel-DHr018lI.js} +1 -1
  2. package/dist/assets/{App-Di_RKfDE.js → App-B87W_53r.js} +122 -122
  3. package/dist/assets/{AppEventEditor-Bxo59GaM.js → AppEventEditor-C3C0vsQs.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-BE1y9Mh4.js +16 -0
  5. package/dist/assets/{BrowserPanel-8mHeGOLP.js → BrowserPanel-B0CcmG3D.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-DNDenex_.js → BrowserProfilesManager-Vq_INgTe.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-B3mItSdo.js → CloudAddDialog-BScZQg6s.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-DUM3BGn5.js → ComputerFilesPane-D1pogAwW.js} +1 -1
  9. package/dist/assets/{ComputerPanel-B1ProOmB.js → ComputerPanel-DuVyjdZU.js} +2 -2
  10. package/dist/assets/{DataPanel-B9dG-xFC.js → DataPanel-CO-it_l5.js} +1 -1
  11. package/dist/assets/{DesktopViewer-CxgTWyru.js → DesktopViewer-CsD0VUUU.js} +1 -1
  12. package/dist/assets/{FilesView-BdErJPbS.js → FilesView-C8iMQMcP.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-DmZmbC5L.js → GrokMoveDialog-CWad1BUn.js} +1 -1
  14. package/dist/assets/{InspectorPanel-B1sIo1J5.js → InspectorPanel-BO7pmDrc.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-C5hjzxvv.js → KeyboardShortcutsModal-yc93OBB1.js} +1 -1
  16. package/dist/assets/{LiveDesktop-CN8YTqUZ.js → LiveDesktop-DoVeYQ0i.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-C3kwGTKa.js → LocalVmWorkspace-DnP0FeUc.js} +1 -1
  18. package/dist/assets/{MacLocalControl-OTlnJ0ZN.js → MacLocalControl-C9lOAQla.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-Da65BUFR.js → MarkdownFilePreview-BgDXx4kS.js} +1 -1
  20. package/dist/assets/{MenuMotion-B5n2ZkGC.js → MenuMotion-VqAEkiFI.js} +1 -1
  21. package/dist/assets/{NewBotDialog-yIDxcMQJ.js → NewBotDialog-B7b_tl0W.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-Bl38QRBo.js → PhoneAppDialog-BK4SkUJ4.js} +1 -1
  23. package/dist/assets/PlacesRail-vM_KJSQM.js +1 -0
  24. package/dist/assets/{PluginsPanel-uBfd1z73.js → PluginsPanel-CC5ORkTx.js} +1 -1
  25. package/dist/assets/{ProIntroduction-CJI7fYhZ.js → ProIntroduction-ZLLkMtoe.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-B5JBGc4J.js → RemoteAgentSettingsPanel-Cn40yids.js} +1 -1
  27. package/dist/assets/{RoomPanel-B8o0-I0t.js → RoomPanel-icIjxB8c.js} +1 -1
  28. package/dist/assets/{RoutinesPage-K_BfBMn8.js → RoutinesPage-nHKPxSZ-.js} +1 -1
  29. package/dist/assets/{SettingsModal-DXSZCYBo.js → SettingsModal-DXa7NglH.js} +4 -4
  30. package/dist/assets/{ShareTeamDialog-DTyuq4lx.js → ShareTeamDialog-DIT8PFEI.js} +1 -1
  31. package/dist/assets/{SignedInSites-C-qamp3R.js → SignedInSites-C55Dmjnk.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-D18289iU.js → TeamLibraryPanel-Cfl4SgFV.js} +1 -1
  33. package/dist/assets/{TeamMapPage-CtEOY0Vl.js → TeamMapPage-BsxTPcV5.js} +1 -1
  34. package/dist/assets/{TriggersPage-Cjpc4tVU.js → TriggersPage-B1b4uS07.js} +1 -1
  35. package/dist/assets/{VisibilitySection-BFDrnzbh.js → VisibilitySection-DhvasLjK.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-YBoFyBq8.js → WebhookTrigger-Dvz6B2CI.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-CAcjXdeB.js → WorksOnGrid-DslGZf0e.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-B5MGbjZP.js → abnfDiagram-YUKMZFIV-DxXITSez.js} +1 -1
  39. package/dist/assets/{activity-i4SOTxBA.js → activity-DZde1m02.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-z1L1R8jr.js → architectureDiagram-47P4ROYG-BegpVo5x.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-BgCJ5XqR.js → blockDiagram-E7TT5TSB-B1AbK2wd.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-BxQ3fhnE.js → c4Diagram-CRA5TL53-_egqWLuQ.js} +1 -1
  43. package/dist/assets/{calendar-days-D81dmGeW.js → calendar-days-DMjgLhUz.js} +1 -1
  44. package/dist/assets/channel-6pMRe_Fb.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-CSVcU4dl.js → chunk-2Q5K7J3B-CJtxaHPe.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-HqrufCgf.js → chunk-5VM5RSS4-Bm6NQEd_.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-D6I-6CLD.js → chunk-7TKQ45FW-q71by55S.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-nl3ozUZV.js → chunk-AW2ZBBNX-DMlXSjM_.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-wr6Np7EE.js → chunk-FVRAUYC3-Bsob3PK1.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-XZGyfK8y.js → chunk-HTAEGDNF-De4EMeYW.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-pVRLXa0H.js → chunk-JWPE2WC7-K2rQQBXP.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-Cb22vGIM.js → chunk-KQW6MTUR-sQodirIW.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-CmETcGZq.js → chunk-XXDRQBXY-oV0DKDc-.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-eKf7q2Qc.js → classDiagram-v2-K4WV4PDN-2Gxoi60_.js} +1 -1
  55. package/dist/assets/{coins-GsXVRnl_.js → coins-DCCwfrcW.js} +1 -1
  56. package/dist/assets/{core-B-k_7y0P.js → core-CWX_nHRS.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-D4VzuikC.js → cose-bilkent-JH36ORCC-CIJZoY4Q.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-CeoYk0bd.js → cynefin-EF2NZ3EQ-ef9lS7GC.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-ru8_qbbj.js → cynefinDiagram-3GCD6N5R-CFFzbLRo.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-wL6sYRlF.js → dagre-W4DXFKR2-Bao1CgNA.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-BbNSoiqa.js → diagram-2UJZ2QOL-DI8Z00Ve.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-k8AAT5zq.js → diagram-OVF4WLC6-B83cEM_l.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-ifjP4RXu.js → diagram-PFPMY2P6-BaG0xDQR.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-Ew2tVPDg.js → diagram-UMYRVEAY-DQteYbOy.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-Dovy7WaK.js → diagram-YEKJPTXX-KvfZg6TE.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-rtKhjRxK.js → diagram-ZIFT7M5P-DEsM8IFL.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-BE67RFVg.js → ebnfDiagram-VR2GEFS7-C1FKsXjd.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-By_AEbig.js → elk-IJKZMXRS-BiTC7j93.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-NMF3USSg.js → erDiagram-O2IAPWRE-BIMFgrMa.js} +1 -1
  70. package/dist/assets/{file-up-CwVtVDwM.js → file-up-ButWWy32.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-7VJ7i6mz.js → flowDiagram-OXPTDLAJ-B9H0KRFf.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-BsGUeaLq.js → ganttDiagram-R7TSEDQI-CslmQ6dq.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-B5SdxDl8.js → gitGraphDiagram-XJZIOB7I-CeeH7iR_.js} +1 -1
  74. package/dist/assets/{import-name-CF2rJETO.js → import-name-BMW8IMu5.js} +1 -1
  75. package/dist/assets/index-3sQyiFZk.js +3 -0
  76. package/dist/assets/{index-BoIJ2PWD.js → index-Dqnw8jxz.js} +1 -1
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-BqpdF76u.js → infoDiagram-5W2HQ5XZ-DiaTKw3C.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-ChPuwoRo.js → ishikawaDiagram-K3B6WC7H-RmdqzAJb.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-AJsQ9Sal.js → journeyDiagram-COXZFDF6-QxGZsV-N.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-Cbf53EMp.js → kanban-definition-P3RFRI5V-HiZl80pb.js} +1 -1
  81. package/dist/assets/{mcp-servers-BjChYca1.js → mcp-servers-C7qDUZg-.js} +1 -1
  82. package/dist/assets/{mermaid.core-5XOzwbA1.js → mermaid.core-CDSTO7q5.js} +4 -4
  83. package/dist/assets/{mindmap-definition-LZFPQGKD-CD-WwEpo.js → mindmap-definition-LZFPQGKD-BVgamkZ1.js} +1 -1
  84. package/dist/assets/{minimize-BBAOsm2F.js → minimize-5RBZSnye.js} +1 -1
  85. package/dist/assets/{monitor-ByVtOtHb.js → monitor-CYH7yk0j.js} +1 -1
  86. package/dist/assets/{new-bot-Brnt-vsQ.js → new-bot-DuQBJa1L.js} +1 -1
  87. package/dist/assets/{org-library-BqPtAtfm.js → org-library-DTcgGL1w.js} +1 -1
  88. package/dist/assets/{package-format-DswU6LQA.js → package-format-B97T2pyg.js} +1 -1
  89. package/dist/assets/{pegDiagram-BGZESJAR-p2NJ2LJo.js → pegDiagram-BGZESJAR-B2gShywE.js} +1 -1
  90. package/dist/assets/{pieDiagram-CAPJLFHJ-BiLTUs2q.js → pieDiagram-CAPJLFHJ-DC_Ao0v8.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-GDMTTRAM-BLtReWzy.js → quadrantDiagram-GDMTTRAM-V5QiTdDj.js} +1 -1
  92. package/dist/assets/{rail-B292SI4O.js → rail-B5HZ46VV.js} +1 -1
  93. package/dist/assets/{railroadDiagram-SM67HX2B-CmU-L8x-.js → railroadDiagram-SM67HX2B-B5JVf86S.js} +1 -1
  94. package/dist/assets/{remote-desktop-panel-C320nXM7.js → remote-desktop-panel-Cdb9gCdG.js} +1 -1
  95. package/dist/assets/{requirementDiagram-X7JNWC4A-C7POybJi.js → requirementDiagram-X7JNWC4A-DGueixXR.js} +1 -1
  96. package/dist/assets/{sankeyDiagram-UM26HJRW-Bh1astOc.js → sankeyDiagram-UM26HJRW-CWhQ9Gkt.js} +1 -1
  97. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-j_M4G1u_.js → sequenceDiagram-ZO4K6R2Y-4Ve3J4hO.js} +1 -1
  98. package/dist/assets/{sizeCapture-INFHLROL-Ca-8iWQF.js → sizeCapture-INFHLROL-ChjcQKOb.js} +1 -1
  99. package/dist/assets/{stateDiagram-v2-TBUQTH76-BEwcaRZx.js → stateDiagram-v2-TBUQTH76-CiQ2XCFs.js} +1 -1
  100. package/dist/assets/{styles-DdM6yn_a.js → styles-C2j6j2OJ.js} +1 -1
  101. package/dist/assets/{swimlanes-N4OXWK64-DmlmxFf2.js → swimlanes-N4OXWK64-CH8vWWGf.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-CJhdbzp5.js +8 -0
  103. package/dist/assets/{team-share-DI90Vqwa.js → team-share-BltEF7sJ.js} +1 -1
  104. package/dist/assets/{timeline-definition-YOQAKGHF-CHX-HOfh.js → timeline-definition-YOQAKGHF-DyylwCgM.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-eeJvKlcE.js → usecaseDiagram-VIAY4XPW-CAABLJPt.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-DylhYeUG.js → vennDiagram-BLWOH2XV-DijQKILS.js} +1 -1
  107. package/dist/assets/vi-7mNxNB4v.js +15 -0
  108. package/dist/assets/{wardleyDiagram-YMQ3BMBF-CUUtluRt.js → wardleyDiagram-YMQ3BMBF-CLXPmbAV.js} +1 -1
  109. package/dist/assets/{xychartDiagram-TAQBALBS-C-gwkNiy.js → xychartDiagram-TAQBALBS-DIsFY1_L.js} +1 -1
  110. package/dist/index.html +2 -2
  111. package/dist/rail.html +4 -4
  112. package/dist-server/index.js +32 -26
  113. package/dist-server/package.json +1 -1
  114. package/dist-server/server/bot-channels/adapters.js +7 -2
  115. package/dist-server/server/bot-channels/engine.js +6 -3
  116. package/dist-server/server/bot-channels/messenger.js +106 -0
  117. package/dist-server/server/index.js +4 -4
  118. package/package.json +1 -1
  119. package/dist/assets/BotSettingsDialog-BtdhqHMV.js +0 -16
  120. package/dist/assets/PlacesRail-PNE_Y9GC.js +0 -1
  121. package/dist/assets/channel-Nvi2Z0SJ.js +0 -1
  122. package/dist/assets/index-BOBBoSRI.js +0 -3
  123. package/dist/assets/swimlanesDiagram-K3J5GTZL-rbSiIYPg.js +0 -8
  124. package/dist/assets/vi-CcmBtVzr.js +0 -15
@@ -1 +1 @@
1
- import{r as l,t as s,j as t,X as $,a as X}from"./styles-DdM6yn_a.js";import{c as ee,B as te,L as G}from"./PlacesRail-PNE_Y9GC.js";import{u as ae,z as F,D as L}from"./App-Di_RKfDE.js";import{suggestedName as H}from"./WebhookTrigger-YBoFyBq8.js";import"./monitor-ByVtOtHb.js";import"./index-BOBBoSRI.js";import"./MenuMotion-B5n2ZkGC.js";import"./remote-desktop-DDRRx8uY.js";const N="w-full rounded-xl border border-hairline/60 bg-panel px-3.5 py-2.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70",m="mb-1.5 block text-[12px] font-medium text-ink-secondary";function de({trigger:a,bots:x,initialBotId:y,onClose:h,onSaved:J}){const{dispatch:K}=ae(),[i,Q]=l.useState(a?.botId??(y&&x.some(e=>e.id===y)?y:x[0]?.id)??""),[r,O]=l.useState(null),[v,B]=l.useState(a?.app??""),[b,k]=l.useState(a?.event??""),[g,U]=l.useState(a?.accountId??""),[D,V]=l.useState(a?.filter??{}),[f,E]=l.useState({}),[u,W]=l.useState(a?.prompt??""),[w,Y]=l.useState(a?.name??""),[I,P]=l.useState(!1),[S,C]=l.useState(""),R=l.useRef(null);ee(R,h),l.useEffect(()=>{if(a||!i)return;let e=!0;return O(null),F.events(i).then(n=>{if(!e)return;O(n);const o=n.apps.find(d=>d.events.length);B(d=>n.apps.some(A=>A.app===d)?d:o?.app??"")}).catch(n=>{e&&C(n instanceof Error?n.message:String(n))}),()=>{e=!1}},[i,a]);const p=r?.apps.find(e=>e.app===v),z=p?.events??[],c=z.find(e=>e.event===b)??(a?void 0:z[0]);l.useEffect(()=>{!a&&c&&c.event!==b&&k(c.event)},[c,b,a]);const q=(c?.configFields??[]).filter(e=>e.required),Z=v==="gmail",M=a?.delivery??c?.delivery,_=async()=>{const e=x.find(o=>o.id===i),n=Object.fromEntries(Object.entries(D).filter(([,o])=>typeof o=="string"&&o.trim()));P(!0),C("");try{const o=a?await F.update(a.id,{name:w.trim()||a.name,prompt:u.trim(),filter:Object.keys(n).length?n:null}):await F.create({botId:i,app:v,event:c?.event??b,prompt:u.trim(),name:w.trim()||H(u,e),...g?{account:g}:{},...Object.keys(n).length?{filter:n}:{},...Object.keys(f).length?{config:f}:{}});J?.(o),h()}catch(o){C(o instanceof Error?o.message:String(o))}finally{P(!1)}},j=(e,n,o)=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:n}),t.jsx("input",{value:D[e]??"",onChange:d=>V(A=>({...A,[e]:d.target.value})),placeholder:o,className:N})]},e),T=a?s("automations.editor.app.editTitle"):s("automations.editor.appEvent.title");return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-5",onMouseDown:e=>e.stopPropagation(),children:t.jsxs("div",{ref:R,role:"dialog","aria-modal":"true","aria-label":T,tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/60 bg-panel shadow-2xl",children:[t.jsxs("div",{className:"flex items-start justify-between border-b border-hairline/40 px-5 py-4",children:[t.jsx("div",{className:"text-[17px] font-semibold text-ink",children:T}),t.jsx("button",{type:"button",onClick:h,"aria-label":s("automations.newBox.cancel"),className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink",children:t.jsx($,{size:18})})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto p-5",children:[!a&&t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:s("automations.editor.app.who")}),t.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:x.map(e=>t.jsxs("button",{type:"button",onClick:()=>Q(e.id),className:X("flex min-w-0 items-center gap-2 rounded-xl border px-3 py-2 text-left",i===e.id?"border-accent/70 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised/60"),children:[t.jsx(te,{bot:e,state:i===e.id?"happy":"idle",size:32,animated:!1}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium text-ink",children:e.name})]},e.id))})]}),!a&&!r&&!S&&t.jsxs("p",{className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[t.jsx(G,{size:14,className:"animate-spin"}),s("automations.editor.appEvent.loading")]}),!a&&r&&(r.unavailable||!r.apps.some(e=>e.events.length))&&t.jsxs("div",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5 text-[13px] text-ink-secondary",children:[t.jsx("p",{children:r.unavailable??s("automations.editor.appEvent.noApps")}),!r.unavailable&&t.jsx("button",{type:"button",onClick:()=>K({type:"togglePlugins",open:!0,surface:"apps"}),className:"mt-2.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:s("automations.editor.appEvent.connect")})]}),!a&&r&&p&&t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.app")}),t.jsx(L,{value:v,onChange:e=>{B(e.target.value),k(""),E({})},"aria-label":s("automations.editor.appEvent.app"),className:"w-full",children:r.apps.filter(e=>e.events.length).map(e=>t.jsx("option",{value:e.app,children:e.name},e.app))})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.event")}),t.jsx(L,{value:c?.event??"",onChange:e=>{k(e.target.value),E({})},"aria-label":s("automations.editor.appEvent.event"),className:"w-full",children:z.map(e=>t.jsx("option",{value:e.event,children:e.name},e.event))})]}),p.accounts.length>1&&t.jsxs("label",{className:"block sm:col-span-2",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.account")}),t.jsxs(L,{value:g,onChange:e=>U(e.target.value),"aria-label":s("automations.editor.appEvent.account"),className:"w-full",children:[t.jsx("option",{value:""}),p.accounts.map(e=>t.jsx("option",{value:e.id,children:e.alias??e.id},e.id))]})]}),q.map(e=>t.jsxs("label",{className:"block sm:col-span-2",children:[t.jsx("span",{className:m,children:e.name}),t.jsx("input",{value:f[e.name]??"",onChange:n=>E(o=>({...o,[e.name]:n.target.value})),placeholder:e.description,className:N})]},e.name))]}),(a||p)&&t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[Z?[j("from",s("automations.editor.appEvent.from"),"acme.com"),j("subject",s("automations.editor.appEvent.subject"),"order"),j("label",s("automations.editor.appEvent.label"),"Customers")]:j("text",s("automations.editor.appEvent.text"),"urgent"),M&&t.jsx("p",{className:"self-end text-[12px] text-ink-secondary sm:col-span-2",children:M==="poll"?s("automations.editor.appEvent.checks"):s("automations.editor.appEvent.instant")})]}),(a||p)&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"mb-2 block text-[13px] font-medium text-ink",children:s("automations.editor.app.what")}),t.jsx("textarea",{value:u,onChange:e=>W(e.target.value),rows:3,placeholder:s("automations.editor.appEvent.whatPlaceholder"),className:X(N,"resize-y py-3 leading-relaxed")})]}),(a||p)&&t.jsxs("details",{className:"rounded-xl border border-hairline/45 bg-inset/45 px-4 py-3",children:[t.jsx("summary",{className:"cursor-pointer text-[13px] font-medium text-ink",children:s("automations.more")}),t.jsxs("label",{className:"mt-4 block",children:[t.jsx("span",{className:m,children:s("automations.editor.app.name")}),t.jsx("input",{value:w,onChange:e=>Y(e.target.value),placeholder:H(u,x.find(e=>e.id===i)),className:N})]})]}),S&&t.jsx("div",{role:"alert",className:"rounded-xl border border-danger/30 bg-danger/10 px-3.5 py-3 text-[12px] text-danger",children:S})]}),t.jsxs("div",{className:"flex justify-end gap-2 border-t border-hairline/40 px-5 py-4",children:[t.jsx("button",{type:"button",onClick:h,className:"rounded-xl px-4 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:s("automations.newBox.cancel")}),t.jsxs("button",{type:"button",disabled:I||!i||!a&&!c||q.some(e=>!f[e.name]?.trim()),onClick:()=>{_()},className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[I&&t.jsx(G,{size:14,className:"animate-spin"}),a?s("automations.editor.app.save"):s("automations.editor.app.create")]})]})]})})}export{de as AppEventEditor};
1
+ import{r as l,t as s,j as t,X as $,a as X}from"./styles-C2j6j2OJ.js";import{c as ee,B as te,L as G}from"./PlacesRail-vM_KJSQM.js";import{u as ae,z as F,D as L}from"./App-B87W_53r.js";import{suggestedName as H}from"./WebhookTrigger-Dvz6B2CI.js";import"./monitor-CYH7yk0j.js";import"./index-3sQyiFZk.js";import"./MenuMotion-VqAEkiFI.js";import"./remote-desktop-DDRRx8uY.js";const N="w-full rounded-xl border border-hairline/60 bg-panel px-3.5 py-2.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70",m="mb-1.5 block text-[12px] font-medium text-ink-secondary";function de({trigger:a,bots:x,initialBotId:y,onClose:h,onSaved:J}){const{dispatch:K}=ae(),[i,Q]=l.useState(a?.botId??(y&&x.some(e=>e.id===y)?y:x[0]?.id)??""),[r,O]=l.useState(null),[v,B]=l.useState(a?.app??""),[b,k]=l.useState(a?.event??""),[g,U]=l.useState(a?.accountId??""),[D,V]=l.useState(a?.filter??{}),[f,E]=l.useState({}),[u,W]=l.useState(a?.prompt??""),[w,Y]=l.useState(a?.name??""),[I,P]=l.useState(!1),[S,C]=l.useState(""),R=l.useRef(null);ee(R,h),l.useEffect(()=>{if(a||!i)return;let e=!0;return O(null),F.events(i).then(n=>{if(!e)return;O(n);const o=n.apps.find(d=>d.events.length);B(d=>n.apps.some(A=>A.app===d)?d:o?.app??"")}).catch(n=>{e&&C(n instanceof Error?n.message:String(n))}),()=>{e=!1}},[i,a]);const p=r?.apps.find(e=>e.app===v),z=p?.events??[],c=z.find(e=>e.event===b)??(a?void 0:z[0]);l.useEffect(()=>{!a&&c&&c.event!==b&&k(c.event)},[c,b,a]);const q=(c?.configFields??[]).filter(e=>e.required),Z=v==="gmail",M=a?.delivery??c?.delivery,_=async()=>{const e=x.find(o=>o.id===i),n=Object.fromEntries(Object.entries(D).filter(([,o])=>typeof o=="string"&&o.trim()));P(!0),C("");try{const o=a?await F.update(a.id,{name:w.trim()||a.name,prompt:u.trim(),filter:Object.keys(n).length?n:null}):await F.create({botId:i,app:v,event:c?.event??b,prompt:u.trim(),name:w.trim()||H(u,e),...g?{account:g}:{},...Object.keys(n).length?{filter:n}:{},...Object.keys(f).length?{config:f}:{}});J?.(o),h()}catch(o){C(o instanceof Error?o.message:String(o))}finally{P(!1)}},j=(e,n,o)=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:n}),t.jsx("input",{value:D[e]??"",onChange:d=>V(A=>({...A,[e]:d.target.value})),placeholder:o,className:N})]},e),T=a?s("automations.editor.app.editTitle"):s("automations.editor.appEvent.title");return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-5",onMouseDown:e=>e.stopPropagation(),children:t.jsxs("div",{ref:R,role:"dialog","aria-modal":"true","aria-label":T,tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/60 bg-panel shadow-2xl",children:[t.jsxs("div",{className:"flex items-start justify-between border-b border-hairline/40 px-5 py-4",children:[t.jsx("div",{className:"text-[17px] font-semibold text-ink",children:T}),t.jsx("button",{type:"button",onClick:h,"aria-label":s("automations.newBox.cancel"),className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink",children:t.jsx($,{size:18})})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto p-5",children:[!a&&t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:s("automations.editor.app.who")}),t.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:x.map(e=>t.jsxs("button",{type:"button",onClick:()=>Q(e.id),className:X("flex min-w-0 items-center gap-2 rounded-xl border px-3 py-2 text-left",i===e.id?"border-accent/70 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised/60"),children:[t.jsx(te,{bot:e,state:i===e.id?"happy":"idle",size:32,animated:!1}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium text-ink",children:e.name})]},e.id))})]}),!a&&!r&&!S&&t.jsxs("p",{className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[t.jsx(G,{size:14,className:"animate-spin"}),s("automations.editor.appEvent.loading")]}),!a&&r&&(r.unavailable||!r.apps.some(e=>e.events.length))&&t.jsxs("div",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5 text-[13px] text-ink-secondary",children:[t.jsx("p",{children:r.unavailable??s("automations.editor.appEvent.noApps")}),!r.unavailable&&t.jsx("button",{type:"button",onClick:()=>K({type:"togglePlugins",open:!0,surface:"apps"}),className:"mt-2.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:s("automations.editor.appEvent.connect")})]}),!a&&r&&p&&t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.app")}),t.jsx(L,{value:v,onChange:e=>{B(e.target.value),k(""),E({})},"aria-label":s("automations.editor.appEvent.app"),className:"w-full",children:r.apps.filter(e=>e.events.length).map(e=>t.jsx("option",{value:e.app,children:e.name},e.app))})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.event")}),t.jsx(L,{value:c?.event??"",onChange:e=>{k(e.target.value),E({})},"aria-label":s("automations.editor.appEvent.event"),className:"w-full",children:z.map(e=>t.jsx("option",{value:e.event,children:e.name},e.event))})]}),p.accounts.length>1&&t.jsxs("label",{className:"block sm:col-span-2",children:[t.jsx("span",{className:m,children:s("automations.editor.appEvent.account")}),t.jsxs(L,{value:g,onChange:e=>U(e.target.value),"aria-label":s("automations.editor.appEvent.account"),className:"w-full",children:[t.jsx("option",{value:""}),p.accounts.map(e=>t.jsx("option",{value:e.id,children:e.alias??e.id},e.id))]})]}),q.map(e=>t.jsxs("label",{className:"block sm:col-span-2",children:[t.jsx("span",{className:m,children:e.name}),t.jsx("input",{value:f[e.name]??"",onChange:n=>E(o=>({...o,[e.name]:n.target.value})),placeholder:e.description,className:N})]},e.name))]}),(a||p)&&t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[Z?[j("from",s("automations.editor.appEvent.from"),"acme.com"),j("subject",s("automations.editor.appEvent.subject"),"order"),j("label",s("automations.editor.appEvent.label"),"Customers")]:j("text",s("automations.editor.appEvent.text"),"urgent"),M&&t.jsx("p",{className:"self-end text-[12px] text-ink-secondary sm:col-span-2",children:M==="poll"?s("automations.editor.appEvent.checks"):s("automations.editor.appEvent.instant")})]}),(a||p)&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"mb-2 block text-[13px] font-medium text-ink",children:s("automations.editor.app.what")}),t.jsx("textarea",{value:u,onChange:e=>W(e.target.value),rows:3,placeholder:s("automations.editor.appEvent.whatPlaceholder"),className:X(N,"resize-y py-3 leading-relaxed")})]}),(a||p)&&t.jsxs("details",{className:"rounded-xl border border-hairline/45 bg-inset/45 px-4 py-3",children:[t.jsx("summary",{className:"cursor-pointer text-[13px] font-medium text-ink",children:s("automations.more")}),t.jsxs("label",{className:"mt-4 block",children:[t.jsx("span",{className:m,children:s("automations.editor.app.name")}),t.jsx("input",{value:w,onChange:e=>Y(e.target.value),placeholder:H(u,x.find(e=>e.id===i)),className:N})]})]}),S&&t.jsx("div",{role:"alert",className:"rounded-xl border border-danger/30 bg-danger/10 px-3.5 py-3 text-[12px] text-danger",children:S})]}),t.jsxs("div",{className:"flex justify-end gap-2 border-t border-hairline/40 px-5 py-4",children:[t.jsx("button",{type:"button",onClick:h,className:"rounded-xl px-4 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:s("automations.newBox.cancel")}),t.jsxs("button",{type:"button",disabled:I||!i||!a&&!c||q.some(e=>!f[e.name]?.trim()),onClick:()=>{_()},className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[I&&t.jsx(G,{size:14,className:"animate-spin"}),a?s("automations.editor.app.save"):s("automations.editor.app.create")]})]})]})})}export{de as AppEventEditor};
@@ -0,0 +1,16 @@
1
+ import{c as Te,t as s,b as se,aF as zs,j as e,i as $e,ae as fe,a as O,r as u,S as Xe,ah as Wt,X as et,f as dt}from"./styles-C2j6j2OJ.js";import{fg as Hs,fh as _s,a2 as tt,bB as Ks,dj as Vt,w as Us,fi as qs,fj as Ws,K as Zt,fk as Vs,R as Gt,eu as Zs,x as Gs,fl as pt,bv as mt,fm as Yt,n as G,u as $,fn as Ys,aj as st,F as Jt,A as Qt,S as Oe,af as Ae,T as Xt,W as Js,fo as Qs,fp as Xs,fq as en,fr as tn,fs as sn,ft as ut,fu as nn,fv as an,fw as rn,fx as on,bb as ln,fy as cn,fz as dn,fA as pn,I as mn,fB as Ce,bR as nt,fC as un,aK as L,aQ as ee,ee as xn,dL as hn,fD as fn,aL as Ve,cq as gn,d_ as yn,d$ as bn,fE as vn,fF as es,fG as ts,fH as kn,fI as jn,fJ as wn,fK as Nn,dO as Ze,at as xt,fL as Fe,fM as Sn,fN as Ee,ax as Cn,fO as ss,fP as ht,am as Ge,fQ as Pn,fR as On,fS as En,fT as ns,fU as Rn,fV as In,fW as Tn,fX as An,fY as X,aZ as ne,a$ as Q,fZ as Ln,f_ as Mn,f$ as Bn,d6 as $n,d as Fn,G as Dn,d4 as as,al as zn,g0 as V,aY as pe,g1 as me,by as C,g2 as Hn,dq as _n,g3 as Le,a_ as oe,g4 as Kn,g5 as Un,g6 as qn,ei as Wn,g7 as ft,g8 as Vn,g9 as Zn,ga as Gn,gb as Yn,gc as Jn,gd as Qn,aE as Xn,ge as is,gf as ea,gg as ta,gh as sa,gi as na,gj as aa,gk as ia,gl as ra,gm as oa,gn as la,go as ca,gp as da,gq as pa,gr as at,k as ma,B as Ye,gs as ua,gt as xa,gu as ha,gv as fa,b_ as ga,gw as rs,J as gt,eY as ya,gx as yt,gy as ba,gz as va,cN as bt,bz as ka,d3 as ja,gA as wa,gB as os,gC as Ne,gD as vt,gE as Na,aO as De,e0 as Sa,gF as Ca,aT as Pa,C as Oa,cr as Ea,gG as Ra,gH as Ia,gI as Ta,aV as Aa}from"./App-B87W_53r.js";import{v as ls,d as ke,a1 as Re,a2 as La,a3 as Ma,a4 as kt,a5 as ze,a6 as Ba,a7 as $a,a8 as Fa,a9 as Da,aa as za,ab as jt,ac as Ha,ad as _a,L as Pe,N as Ka,B as Je,P as je,r as cs,ae as Ua,a0 as qa,u as ds}from"./PlacesRail-vM_KJSQM.js";import{C as Wa}from"./coins-DCCwfrcW.js";import{C as ve,a as Va}from"./MenuMotion-VqAEkiFI.js";import{b as te,m as ps,i as Qe,f as it,c as he,d as wt,e as Ie,o as Za,g as Ga,h as de,n as He,t as ms,s as rt,j as us,k as Ya,l as Ja,p as Qa,r as xs,q as Xa,u as ei,w as ti,x as hs,y as fs,z as Nt,B as si,C as gs,R as St,D as ni,E as ai,F as ii,G as ri,H as oi,J as li,O as ci,K as di,L as ys,N as Ct,V as pi,P as mi,M as ui,A as xi,a as hi,S as fi,I as gi}from"./VisibilitySection-DhvasLjK.js";import{s as yi,r as bi,a as vi,R as ki}from"./ComputerFilesPane-D1pogAwW.js";import{M as Pt}from"./monitor-CYH7yk0j.js";import{a as bs,m as vs,b as ji,c as wi}from"./mcp-servers-C7qDUZg-.js";import{R as Ni}from"./RoutinesPage-nHKPxSZ-.js";import{S as Si}from"./SignedInSites-C55Dmjnk.js";import"./index-3sQyiFZk.js";import"./org-library-DTcgGL1w.js";import"./package-format-B97T2pyg.js";import"./WorksOnGrid-DslGZf0e.js";import"./ProIntroduction-ZLLkMtoe.js";import"./remote-desktop-DDRRx8uY.js";const Ci=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],Pi=Te("calendar-plus",Ci);const Oi=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ei=Te("library",Oi);const Ri=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],ks=Te("slack",Ri);const Ii=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Ti=Te("tag",Ii),Ai=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:Hs,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:_s,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ks,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:tt,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ks,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Vt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Ei,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Us,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:qs,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",labelKey:"botSettings.sections.model",icon:Ws,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Zt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Vs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Gt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Zs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Wa,keywords:["tokens","cost","billing"]}],Ot={completed:"botOverview.routine.last.completed",failed:"botOverview.routine.last.failed",missed:"botOverview.routine.last.missed",cancelled:"botOverview.routine.last.cancelled",running:"botOverview.routine.last.running",queued:"botOverview.routine.last.queued",waiting:"botOverview.routine.last.waiting"};function Li(t,n=se()){if(!t||n==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const a=t.lastRun;if(a&&!Object.hasOwn(Ot,a.status))return null;try{return[s("botOverview.routine.line",{schedule:Gs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:pt(t.nextRunAt)})]:[],...a?[s(Ot[a.status],{time:pt(a.at)})]:[]].join(" ")}catch{return null}}const Et={"Works in its private workspace.":"botOverview.line.privateWorkspace","Has the built-in browser.":"botOverview.line.browser","Has no connected apps.":"botOverview.line.noApps","Won't act on a schedule.":"botOverview.line.noSchedule","Can talk to the other bot.":"botOverview.line.talksToOne","Talks only to the bots chosen for it.":"botOverview.line.talksToChosen","Cannot initiate contact with other bots.":"botOverview.line.noPeerContact","Command approvals use Ask mode; saved permissions and provider rules still apply.":"botOverview.line.askMode","Command approvals follow the provider's custom configuration.":"botOverview.line.customApprovals","Asks before contacting other bots.":"botOverview.line.asksPeers","Can't use a computer.":"botOverview.line.noComputer","Profile proposal cards require your approval.":"botOverview.line.profileApproval","Connected apps could not be checked.":"botOverview.line.appsUnchecked"},Rt={"Auto; availability is checked when a task starts":"botOverview.preference.auto","cloud computer":"botOverview.preference.cloud","Local VM":"botOverview.preference.vm","this computer":"botOverview.preference.local","browser only":"botOverview.preference.browser"};function It(t,n){return!n||n.map(a=>a||"General").join(", ")!==t?t:n.map(a=>a||s("botAccess.teams.general")).join(", ")}const Tt=t=>Object.hasOwn(Rt,t)?s(Rt[t]):t,At=(t,n,a)=>Number(t)===1?n:a,Mi=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],n)=>({departments:It(t,n)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>At(t,"botOverview.line.peersSectionOne","botOverview.line.peersSectionMany"),params:([,t])=>({count:Number(t)})},{line:/^Can talk to (\d+) other bots? in its allowed (?:teams|departments)\.$/,key:([,t])=>At(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],n)=>({teams:It(t,n)})}],Bi=t=>se()!=="en"&&Object.hasOwn(zs[se()]??{},t);function $i(t,n){for(const a of Mi){const l=a.line.exec(t);if(!l)continue;const i=a.key(l);return Bi(i)?s(i,a.params(l,n)):t}return null}function _e(t,n){if(Object.hasOwn(Et,t))return s(Et[t]);const a=$i(t,n);if(a!==null)return a;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const i=se()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(i)return s("botOverview.line.computerNotOnCloud",{preference:Tt(i[1])});const o=/^Computer preference: (.+)\.$/.exec(t);if(o)return s("botOverview.line.computer",{preference:Tt(o[1])});const c=/^Works in (.+)\.$/.exec(t);if(c)return s("botOverview.line.folder",{folder:c[1]});const m=/^Knows how to (.+)\.$/.exec(t);if(m)return s("botOverview.line.skill",{skill:m[1]});const r=/^Listens for “(.+)” webhooks\.$/.exec(t);return r?s("botOverview.line.webhook",{name:r[1]}):t}const Lt={name:"approval.applied.field.name",title:"approval.applied.field.title",description:"approval.applied.field.description",soul:"approval.applied.field.soul",cwd:"approval.applied.field.cwd",notifications:"approval.applied.field.notifications",speakReplies:"approval.applied.field.speakReplies"};function Fi(t,n=se()){const a=/^(\w+): /.exec(t)?.[1];return n==="en"||!a||!Object.hasOwn(Lt,a)?t:`${s(Lt[a])}: ${t.slice(a.length+2)}`}function Di({data:t,error:n,open:a,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":a,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString($e()),tokens:t.approxTokens.toLocaleString($e())}):s("botOverview.promptPreview")}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",a&&"rotate-180")})]}),a&&!t&&n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),a&&!t&&!n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),a&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(i=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:i.bytes.toLocaleString($e())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:i.text})]},i.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function zi({overview:t,refreshError:n,prompt:a,promptError:l,onOpen:i,onSetup:o}){const[c,m]=u.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const d=(t.setup??[]).filter(f=>!f.done),p=(f,k)=>s(`botOverview.setup.${f}`)||k;return e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),d.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:d.map(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>i(f.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:p(f.id,f.label)}),e.jsx(ve,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:p(f.id,f.label)})]})},f.id))}),o&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(tt,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>i("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((f,k)=>e.jsx("li",{children:Li(t.doesRoutines?.[k])??_e(f)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsx(Di,{data:a,error:l,open:c,onToggle:()=>m(f=>!f)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>i("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ve,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((f,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Fi(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Yt(f.at)]})]},k))})]})]})}function Hi({managementUrl:t}){return e.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:s("botSlack.body")}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[s("botSlack.manage")," ",e.jsx(ls,{size:14,"aria-hidden":"true"})]})]})}function _i(t){if(!t||typeof t!="object")return null;const{available:n,managementUrl:a}=t;if(n!==!0||typeof a!="string")return null;try{return new URL(a).protocol==="https:"?a:null}catch{return null}}function js(t){const[n,a]=u.useState(null);return u.useEffect(()=>{const l=new AbortController;return G(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(i=>{l.signal.aborted||a({botId:t,url:_i(i)})}).catch(()=>{l.signal.aborted||a({botId:t,url:null})}),()=>l.abort()},[t]),n?.botId===t?n.url:null}const re="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Ke="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ae=t=>t instanceof Error?t.message:String(t);function ws(t){const n=[],a=(i,o,c)=>{i&&n.push(s(i===1?o:c,{count:i}))};a(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),a(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),a(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),a(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=n.length?n.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Ki(t,n){const a=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?n:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Xa(t.path),i=t.path===te?l:t.path===ei?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),o=c=>s(c===1?"memory.journal.line.one":"memory.journal.line.many",{count:c});return t.kind==="created"?s("memory.journal.created",{who:a,topic:i,detail:t.added?s("memory.journal.withLines",{lines:o(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:a,topic:i}):t.added&&!t.removed?s("memory.journal.added",{who:a,lines:o(t.added),topic:i}):t.removed&&!t.added?s("memory.journal.removed",{who:a,lines:o(t.removed),topic:i}):s("memory.journal.rewrote",{who:a,lines:o(Math.max(t.added,t.removed)),topic:i})}function Ns({changed:t,stale:n,busy:a,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(n?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(i=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:i},i))})]}),e.jsx("button",{type:"button",className:O(re,"mt-3"),disabled:a,onClick:l,children:s("memory.lendingReviewed")})]})}function Ui({bot:t,active:n=!0,onToggle:a}){const{capabilities:l}=ke(),[i,o]=u.useState(null),[c,m]=u.useState(null),[r,d]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(null),[v,j]=u.useState(null),[P,b]=u.useState(null),[w,x]=u.useState(!1),[S,M]=u.useState(null),[D,B]=u.useState(""),[T,H]=u.useState(null),[A,h]=u.useState(!1),[I,F]=u.useState(null),[_,K]=u.useState(!1),[J,Y]=u.useState(!1),{state:U,dispatch:y}=$(),z=Ys(U.config),[le,ue]=u.useState(!1),[ge,E]=u.useState(""),q=async N=>{const[R,Me,Ds]=await Promise.all([it(t.id),he(t.id),wt(t.id).catch(()=>null)]);if(o(R),F(R.lendingReview??null),m(Me),H(Ds),N){const Be=await Ie(t.id,N);d({path:Be.path,text:Be.text,hash:Be.hash,dirty:!1,readOnly:N.startsWith("memory/log/")})}};u.useEffect(()=>{if(!n)return;let N=!1;j(null);const R=r?.dirty===!0;return q(R?void 0:r?.path??te).catch(Me=>{N||j(ae(Me))}),()=>{N=!0}},[n,t.id]);const Z=async N=>{j(null),f(null);try{const R=await Ie(t.id,N);d({path:R.path,text:R.text,hash:R.hash,dirty:!1,readOnly:N.startsWith("memory/log/")})}catch(R){j(ae(R))}},W=async N=>{if(r){x(!0),j(null);try{const R=await rt(t.id,r.path,r.text,N);if(!R.ok){f({path:r.path,current:R.current,currentHash:R.currentHash});return}f(null),g(null),d({...r,text:R.doc.text,hash:R.doc.hash,dirty:!1}),o(R.overview),m(await he(t.id))}catch(R){j(ae(R))}finally{x(!1)}}},ce=()=>{!p||!r||(g(r.text),d({...r,text:p.current,hash:p.currentHash,dirty:!1}),f(null))},we=async N=>{if(window.confirm(s("memory.confirmDelete",{name:N.name}))){j(null);try{const{overview:R}=await us(t.id,N.path);o(R),m(await he(t.id)),r?.path===N.path&&d(null)}catch(R){j(ae(R))}}},lt=async()=>{const N=Ya(D);if(!N){j(s("memory.topicNameError"));return}B(""),await Z(`memory/${N}`),d(R=>R&&{...R,dirty:!0,text:R.text||qi(N)})},Ls=async N=>{M(N.id),j(null);try{const R=await xs(t.id,N.id);o(R.overview),m(await he(t.id)),r?.path===N.path&&!r.dirty&&d({...r,text:R.text,hash:R.hash}),b(s("memory.restored",{path:N.path}))}catch(R){j(ae(R))}finally{M(null)}},ct=async N=>{j(null),b(null);try{await Za(t.id,N)}catch(R){j(ae(R))}},Ms=()=>{const N=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:N}}),H(R=>R&&{...R,enabled:N})},Bs=async()=>{if(!le){ue(!0),E("");try{const N=await G("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:N})}catch(N){E(N instanceof Error?N.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},$s=async()=>{h(!0),j(null),b(null);try{const{report:N,overview:R}=await ms(t.id);o(R),m(await he(t.id)),H(await wt(t.id)),r&&!r.dirty&&await Z(r.path),b(`${ws(N)}.${N.note?` ${N.note}`:""}`)}catch(N){j(ae(N))}finally{h(!1)}},Fs=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:N=>a(N.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),i&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:i.workspacePath,children:st(i.workspacePath,Fs)}),e.jsx("button",{type:"button",className:re,onClick:()=>{ct("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(re,"inline-flex items-center gap-1.5"),onClick:()=>{ct("folder")},children:[e.jsx(Jt,{size:14}),s("memory.showFileManager")]})]})]}),I&&e.jsx(Ns,{changed:I.changed,stale:_,busy:J,onReviewed:()=>{Y(!0),ps(t.id,I.token).then(()=>{F(null),K(!1)}).catch(N=>{if(N instanceof Qt&&N.status===409)return K(!0),q();j(ae(N))}).finally(()=>Y(!1))}}),i&&e.jsx(Vi,{index:i.index}),t.memoryEnabled!==!1&&e.jsx(Wi,{enabled:t.memoryUpkeep!==!1,status:T,tidying:A,onToggle:Ms,onTidy:()=>{$s()},rooms:{enabled:z,saving:le,error:ge,onToggle:()=>{Bs()}}}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:r.path}),r.path!==te&&e.jsx("button",{type:"button",className:Ke,onClick:()=>{Z(te)},children:s("memory.backToIndex")})]}),p&&e.jsx(Ss,{botName:t.name,busy:w,onReload:ce,onOverwrite:()=>{W(p.currentHash)}}),e.jsx("textarea",{className:O(Qe,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:r.text,readOnly:r.readOnly,placeholder:r.path===te?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":r.path===te?s("memory.botMemory"):s("memory.fileLabel",{path:r.path}),onChange:N=>d({...r,text:N.target.value,dirty:!0})}),r.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{W(r.hash)},disabled:w||!r.dirty,className:re,children:w?s("memory.saving"):s("memory.save")}),r.dirty&&e.jsx("button",{type:"button",className:Ke,disabled:w,onClick:()=>{Z(r.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:O(Ke,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),i&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Bt,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:i.topics,selected:r?.path,onOpen:N=>{Z(N.path)},onDelete:N=>{we(N)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(Qe,"py-1.5 text-[13px]"),value:D,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:N=>B(N.target.value),onKeyDown:N=>{N.key==="Enter"&&lt()}}),e.jsx("button",{type:"button",className:re,disabled:!D.trim(),onClick:()=>{lt()},children:s("memory.newTopic")})]}),i.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Bt,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:i.logs,selected:r?.path,onOpen:N=>{Z(N.path)},onDelete:N=>{we(N)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(ot,{rows:c,botName:t.name,reverting:S,onRevert:N=>{Ls(N)}})})]}),P&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:P}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function qi(t){return`---
2
+ title: ${t.replace(/\.md$/,"")}
3
+ description:
4
+ aliases: []
5
+ ---
6
+
7
+ `}function Wi({enabled:t,status:n,tidying:a,onToggle:l,onTidy:i,rooms:o}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(Oe,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&o&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),n&&!n.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),o.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:o.error})]}),e.jsx(Oe,{checked:o.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:o.saving,onClick:o.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&n&&!n.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:re,disabled:a,onClick:i,children:a?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[n?.lastTidy?s("memory.upkeep.lastTidy",{time:Re(n.lastTidy.at,se()),summary:ws(n.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),n?.lastCapture&&He(n.lastCapture)?` ${s(He(n.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:He(n.lastCapture),time:Re(n.lastCapture.at,se())})}`:""]})]})]})}function Vi({index:t}){const n=Ga(t),a=n.level==="over"?"bg-danger":n.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",n.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",n.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes)})})]}),e.jsx(Mt,{label:s("memory.capacity.lines"),share:n.lineShare,fill:a}),e.jsx(Mt,{label:s("memory.capacity.size"),share:n.byteShare,fill:a}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",n.level==="over"?"text-danger":"text-ink-secondary"),children:n.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})}),n.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})})]})}function Mt({label:t,share:n,fill:a}){const l=`${Math.min(100,Math.round(n*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(n*100)),children:e.jsx("div",{className:O("h-full rounded-full",a),style:{width:l}})})]})}function Ss({botName:t,busy:n,onReload:a,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:n,onClick:a,children:s("memory.reload")}),e.jsx("button",{type:"button",className:re,disabled:n,onClick:l,children:s("memory.overwrite")})]})]})}function Bt({title:t,hint:n,files:a,selected:l,onOpen:i,onDelete:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:n}),a.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:a.map(c=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===c.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>i(c),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:c.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[de(c.bytes)," · ",Re(c.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>o(c),"aria-label":s("memory.deleteFile",{name:c.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(Xt,{size:14})})]},c.path))})]})}function ot({rows:t,botName:n,reverting:a,onRevert:l,now:i=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(o=>{const c=Ja(o),m=Qa(o);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Ki(o,n)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Re(o.at,se(),i)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:m?s(m,o.threadTitle?{title:o.threadTitle}:void 0):c})]})]}),o.canRevert?e.jsxs("button",{type:"button",disabled:a!==null,onClick:()=>l(o),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(Js,{size:12}),a===o.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:o.revertUnavailableReason,children:s("memory.cantUndo")})]}),o.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",o.added," −",o.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:o.diff})]})]},o.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Zi({bot:t,rows:n,refreshError:a,onRollback:l,rollingBack:i}){if(!n)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(n.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const o=[...n].sort((c,m)=>m.at-c.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),o.map(c=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:Yt(c.at)})," · ",e.jsxs("span",{children:[c.actor," via ",c.via]})," · ",e.jsx("span",{children:c.summary})]}),c.field==="soul"&&c.canRestore===!0&&e.jsx("button",{type:"button",disabled:i,onClick:()=>l(c.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),c.field==="soul"&&c.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:c.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${c.id}`))]})}function Gi({bot:t,bare:n=!1}){const{state:a,dispatch:l}=$(),i=Qs(t),o=a.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return i.turns===0?e.jsx("div",{className:O(n?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:n?void 0:"rounded-xl bg-card p-4",children:[!n&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ve,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!n&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:i.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Xs(i)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:sn(i),children:en(tn(i))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:ut(i.costUsd)?nn(i.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ut(i.costUsd)?s("usage.costLine",{caption:an(o?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Yi=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Ji=["circle","rounded","square"],Qi={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Xi={idle:"botPanel.face.idle",happy:"botPanel.face.happy",curious:"botPanel.face.curious",drowsy:"botPanel.face.drowsy",working:"botPanel.face.working",thinking:"botPanel.face.thinking",listening:"botPanel.face.listening",sleeping:"botPanel.face.sleeping",suspicious:"botPanel.face.suspicious",proud:"botPanel.face.proud"},er=t=>{const n=Xi[t];return n?s(n):t};function tr({bot:t,activeState:n,onPatch:a,onClose:l}){const i=rn(t,a),{fileRef:o,crop:c,uploading:m,generating:r,busy:d,error:p,upload:f,removeImage:k,generate:g}=i,v=c!=="mascot"&&!!t.avatarUrl,[j,P]=u.useState(v?"upload":"bot"),b=u.useRef(null);u.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>a(c==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",S=La(),M=Ma(t.mascotBody,t.color,S),[D,B]=u.useState(()=>!!S||kt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),T=S&&M!==x&&kt(M)?ze(M):null,H=(h,I)=>e.jsx("button",{type:"button",disabled:d,"aria-pressed":!v&&x===h,"aria-label":s("mascot.useBody",{name:I}),title:I,onClick:()=>w({mascotBody:h}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&x===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Ka,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),A=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,"data-look":"popover",onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Yi.map(([h,I])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>P(h),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(I)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:d,onClick:()=>a(on),className:"ml-auto rounded-lg px-[11px] py-[5px] text-[13px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("botPanel.avatar.reset")})]}),e.jsxs("div",{className:"p-3",children:[j==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Ba.map(h=>H(h,ze(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:ln.map(h=>e.jsx("button",{type:"button",disabled:d,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:Da(h)}),title:s(Fa[h]),onClick:()=>w({color:h}),className:O("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:$a(h)}},h))}),e.jsx(ti,{bot:t,disabled:d,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":D,onClick:()=>B(h=>!h),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(fe,{size:13,"aria-hidden":"true",className:O("transition-transform",D&&"rotate-180")})]}),D&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[za.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:jt(h)}),h===S&&T&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:T,skin:jt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:Ha[h].bodies.map(I=>H(I,ze(I)))})]},h)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),_a.map(h=>e.jsx("button",{type:"button",disabled:d,"data-avatar-face":h,"aria-pressed":n===h,onClick:()=>w({mascotExpression:h}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",n===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:er(h)},h))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(cn,{botLabel:t.title||t.name,disabled:m,generating:r,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(dn,{busy:d,onUpload:h=>{f(h)}}),v&&e.jsx(pn,{bot:t,disabled:d,onPatch:a}),e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:d,onClick:()=>o.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[m?e.jsx(Pe,{size:22,className:"animate-spin"}):e.jsx(mn,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(Ce,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?c:null,onChange:h=>a({avatarCrop:h}),options:Ji.map(h=>({value:h,label:s(Qi[h]),disabled:d||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:d,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(Xt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),p&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:p})]})]})}const sr=()=>s("place.off");function Cs(t){const{dispatch:n}=$();return(a="computer")=>{hn(t.id,a),n({type:"toggleSettings",open:!1}),n({type:"toggleComputer",open:!0})}}function nr(t,n){const[a,l]=u.useState(null);return u.useEffect(()=>{if(!n)return;let i=!1;return G(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(o=>{i||l({botId:t.id,count:o.sites?.length??0})}).catch(()=>{}),()=>{i=!0}},[t.id,n]),a?.botId===t.id?a.count:null}function Ps(t){const{state:n}=$(),{capabilities:a}=ke(),l=a.host?.platform??"other",i=fn(t),o=t.computer??"auto",c=n.config?.browserEngine?.myChrome===!0&&(n.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),m=g=>g==="browser"&&c?s("settings.profiles.myChrome"):bn(g,l),r=g=>{const{view:v,reachable:j}=i[g];return{value:g,label:m(g),disabled:!j,hint:!j||yn(v)?v.line:void 0}},d=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...i.local.policy?[r("local")]:[],...i.browser.policy||o==="browser"?[r("browser")]:[],...i.cloud.policy?[r("cloud")]:[],...i.vm.policy||o==="vm"?[r("vm")]:[],...o==="off"?[{value:o,label:sr(),disabled:!0}]:[]],p=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=p&&p!==o?m(p):null,k=d.find(g=>g.value===o)?.label??(o==="auto"||o==="off"?void 0:m(o));return{options:d,current:o,currentLabel:k,usingNow:f}}function ar({bot:t,derived:n}){const{dispatch:a}=$(),{options:l,current:i,usingNow:o}=Ps(t),[c,m]=u.useState(null),{patch:r,approvalMode:d}=n,p=f=>{if(!(f===i||f==="off")){if(f==="local"&&d==="auto"){m({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}r(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(f=>e.jsx(Ve,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:i===f.value,disabled:f.disabled,onClick:()=>p(f.value)},f.value))})}),o&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:o})}),e.jsx(gn,{open:c!==null,onCancel:()=>m(null),onConfirm:()=>{const f=c;m(null),f&&a({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function ir({bot:t,derived:n,onOpen:a}){const l=Cs(t),i=nt(),{browserEnabled:o}=n,c=nr(t,o&&t.computer!=="off"&&i!==!1),{currentLabel:m,usingNow:r}=Ps(t),d=s("computer.screenOf",{name:t.name}),p=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=p?un({threadId:t.threadId,messageId:p.id},p.mime).src:null;return e.jsxs("div",{"data-panel-tabpanel":"computer",children:[e.jsxs("button",{type:"button","data-panel-action":"open-computer","aria-label":`${s("place.action.watch")}: ${d}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[f?e.jsx("img",{src:f,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(Je,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(Je,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(Pt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:d}),e.jsxs(L,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:Pt,title:s("computer.simple.whereWorks",{name:t.name}),hint:r?s("computer.simple.usingNow",{place:r}):void 0,value:m,onClick:()=>a("where")}),e.jsx(ee,{"data-panel-page":"browser",icon:xn,title:s("settings.sites.title"),value:c??void 0,onClick:()=>a("browser")})]})]})}const rr=3,$t="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",or=8,lr=200,xe=new Map,Ue=new Set,Ft=t=>`${t.threadId}@${ns(t)}`;function cr(t,n){const[,a]=u.useState(0),i=n.filter(m=>m.threadId!==t.threadId).map(Ft).filter(m=>!xe.has(m)&&!Ue.has(m)).join(",");u.useEffect(()=>{if(i)for(const m of i.split(",")){Ue.add(m);const r=m.slice(0,m.lastIndexOf("@"));G(`/api/threads/${encodeURIComponent(r)}/messages?limit=${or}`,{background:!0}).then(d=>{xe.set(m,Ge({messages:d.messages??[],activeLeafId:d.activeLeafId??void 0})),xe.size>lr&&xe.delete(xe.keys().next().value),a(p=>p+1)}).catch(()=>{}).finally(()=>Ue.delete(m))}},[i]);const o=Ge(t),c=new Map(n.map(m=>[m.threadId,Ft(m)]));return m=>m===t.threadId?o:xe.get(c.get(m)??"")}function dr({bot:t}){const{state:n,dispatch:a}=$(),l=vn(),i=!es(ts,!0),[o,c]=u.useState(""),[m,r]=u.useState(!1),[d,p]=u.useState(!1),[f,k]=u.useState(!1),g=kn(n.config),v=u.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}=jn(t.id,a,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}},[t.id,a,g]),j=wn(t),P=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?Nn({...t,tasks:P},j):P).filter(y=>!y.routineRunId).map(y=>{const z=Ze(t,y.threadId);return{...y,busy:z.busy,activity:z.activity,waitingForTeammates:z.waitingForTeammates,turnStartedAt:z.turnStartedAt??void 0,queued:!!n.pendingQueued[y.threadId]?.length}}),w=xt(b.filter(y=>!Fe(y)||y.threadId===t.threadId)),x=xt(b.filter(y=>Fe(y)&&y.threadId!==t.threadId)),S=o.trim(),M=w.filter((y,z)=>z<rr||y.threadId===t.threadId),D=cr(t,[...S||d?w:M,...f?x:[]]),B=y=>{const z=D(y);return z?Pn(Ze(t,y),z,n.instances,!1):void 0},T=Sn(w,S),H=S?[...T,...w.filter(y=>!T.includes(y)&&B(y.threadId)?.toLowerCase().includes(S.toLowerCase()))]:w,A=S?H:d?w:M,h=w.length-M.length,I=t.projects?.find(y=>y.id===t.tasks?.find(z=>z.threadId===t.threadId)?.projectId),F=()=>{i&&a({type:"toggleSettings",open:!1})},_=y=>{y.threadId!==t.threadId&&Rn(a,t,y.threadId,!1),F()},K=()=>{a({type:"newTask",botId:t.id,...I?{projectId:I.id}:{}}),F()},J=()=>{c(""),r(!1)},Y=w.length>=2||m||w.some(y=>y.threadId===t.threadId&&Fe(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(On,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:En(ns(y),l),locale:se(),onSelect:_,...v})},y.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Ee,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":m,onClick:()=>m?J():r(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",m&&"bg-ink/[0.06] text-ink"),children:e.jsx(Xe,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:K,className:O(ss,"flex-1"),children:[e.jsx(Cn,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&m&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:o,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),J())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",$t),children:A.map(U)}),Y&&S&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:S})}),Y&&!S&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":d,onClick:()=>p(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[d?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),d?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!S&&x.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>k(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[f?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:x.length})]}),!S&&f&&x.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:x.length}),className:O("flex flex-col gap-px",$t),children:x.map(U)})]})}function pr({bot:t}){const{dispatch:n}=$();return Wt()||!t.defaultBot?null:e.jsx(L,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:In.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>n({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l))})}const mr=["find","start-fresh","usage","activity","inspector"];function ur({item:t}){const n=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(Q,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!n&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",n?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ve,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function xr({bot:t,derived:n,onOpen:a}){const{items:l}=Tn(t),{dispatch:i}=$(),o=n.botRoutines.filter(m=>m.enabled).length,c=mr.flatMap(m=>l.filter(r=>r.key===m));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(Q,"rounded-[8px]"),children:e.jsx(An,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(X,{icon:tt}),e.jsx(ne,{title:s("model.simple.model")})]})})})}),e.jsx(dr,{bot:t}),e.jsx(pr,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ee,{children:s("botPanel.section.conversation")}),c.map(m=>e.jsx(ur,{item:m},m.key))]}),n.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Ee,{action:e.jsx(Ln,{"data-panel-automations":"",onClick:()=>i({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>a("routines"),className:O(ss,"w-full"),children:[e.jsx(Pi,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(L,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Mn,title:s("botSettings.simple.routines"),value:o>0?s("botPanel.routinesOn",{count:o}):s("botPanel.none"),onClick:()=>a("routines")})})]})}const Os=/^\s*[-*]\s+(.+?)\s*$/;function hr(t){return t.split(`
8
+ `).flatMap((n,a)=>{const l=Os.exec(n)?.[1];return l?[{line:a,text:l}]:[]})}function fr(t,n){const a=t.split(`
9
+ `);return Os.test(a[n]??"")?(a.splice(n,1),a.join(`
10
+ `)):t}function gr(t,n){const a=t.replace(/\s+$/,""),l=`- ${n.trim().replace(/\s*\n\s*/g," ")}`;return a?`${a}
11
+ ${l}
12
+ `:`${l}
13
+ `}function Es(t){return t.flatMap(n=>{const a=hr(n.text).map(i=>({path:n.path,...i}));if(a.length||n.path===te)return a;const l=n.text.split(`
14
+ `).map(i=>i.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:n.path,line:null,text:l}]:[]})}async function yr(t,n){if(!n)return[await Ie(t,te)];const a=await it(t,!0);return Promise.all([te,...a.topics.map(l=>l.path)].map(l=>Ie(t,l,!0)))}function Rs(t){const n=!!$().state.config?.team,[a,l]=u.useState({botId:t.id,docs:null,error:!1}),i=t.memoryEnabled!==!1,o=async(r,d)=>{try{const p=await yr(r,n);d?.()||l({botId:r,docs:p,error:!1})}catch{d?.()||l({botId:r,docs:null,error:!0})}},c=!!t.busy;u.useEffect(()=>{if(!i)return;let r=!1;return o(t.id,()=>r),()=>{r=!0}},[t.id,i,c,n]);const m=a.botId===t.id;return{docs:m?a.docs:null,error:m&&a.error,mine:n,setDoc:r=>l(d=>({botId:t.id,docs:(d.botId===t.id?d.docs??[]:[]).map(p=>p.path===r.path?r:p),error:!1})),reload:()=>o(t.id)}}function br(t,n=Ge(t)){const a=[],l=[],i=new Set;for(const d of[...n].reverse()){const p=d.publishedPage;p?.state==="live"&&p.url&&!i.has(p.url)&&(i.add(p.url),a.push({messageId:d.id,title:p.title||p.url,url:p.url})),d.kind==="app"&&d.app?.doc&&l.push({messageId:d.id,title:d.app.title})}const o=yi(t),c=[],m=new Set;for(const d of o.values())m.has(d.file.path)||(m.add(d.file.path),c.push(d));const r=bi(t).filter(d=>!o.has(d));return{pages:a,apps:l,shared:c,unshared:r}}const vr=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Is({bot:t,onOpen:n}){const{dispatch:a}=$(),{capabilities:l}=ke(),i=Bn(),o=!es(ts,!0),c=hs(t),m=Rs(t),{pages:r,apps:d,shared:p,unshared:f}=u.useMemo(()=>br(t),[t]),k=b=>{a({type:"focusMessage",threadId:t.threadId,messageId:b}),o&&a({type:"toggleSettings",open:!1})},g=c.skills.filter(fs).length,v=m.docs?Es(m.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?m.error?s("botPanel.memory.nothingYet"):void 0:v===0?s("botPanel.memory.nothingYet"):v===1?s("botPanel.memory.note"):s("botPanel.memory.notes",{count:v}),P=e.jsxs(L,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Vt,title:s("botPanel.memoryRow"),value:j,onClick:()=>n("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:$n,title:s("botSettings.simple.skills"),value:c.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>n("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Fn,title:s("computer.files.folder"),value:t.cwd?st(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>n("folder")})]});return r.length+d.length+p.length+f.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),P]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[r.length>0&&e.jsx(L,{label:s("botPanel.library.pages"),anchor:"pages",children:r.map(b=>e.jsx(ee,{"data-panel-row":"page",icon:Dn,title:e.jsx("span",{className:"block truncate",children:b.title}),hint:e.jsx("span",{className:"block truncate",children:b.url}),onClick:()=>i(b.url)},b.url))}),d.length>0&&e.jsx(L,{label:s("botPanel.library.apps"),anchor:"apps",children:d.map(b=>e.jsx(ee,{"data-panel-row":"app",icon:as,title:e.jsx("span",{className:"block truncate",children:b.title}),onClick:()=>k(b.messageId)},b.messageId))}),p.length+f.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(Ee,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[p.map(b=>e.jsx("li",{className:"min-w-0",children:e.jsx(zn,{file:b.file,message:b.message,linked:b.file.linked,className:"w-full max-w-none"})},`${b.message.messageId}:${b.file.path}`)),f.map(b=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:vr(b)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},b))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),P]})}function kr({bot:t,browserEnabled:n,onOpenBrowser:a}){const{state:l}=$(),i=nt(),o=t.browserProfile??"",c=(l.config?.browserProfiles??[]).find(p=>p.id===o),m=o==="guest",r=c?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,d=o&&!m?l.bots.filter(p=>p.browserProfile===o).map(p=>p.name):[t.name];return e.jsx(L,{anchor:"logins",children:n?m?e.jsx(V,{children:s("settings.profiles.temporaryHint")}):r?e.jsx(V,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[i!==!1&&(o===""||c)&&e.jsx(pe,{children:e.jsx(Si,{bare:!0,target:{bot:t.id},sharedBy:d,disabled:!!t.busy},`${t.id}:${o}`)}),e.jsx(V,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(me,{"data-panel-action":"add-login",icon:je,onClick:a,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const jr=[["all",()=>C("Tất cả","All")],["added",()=>C("Bot đang có","On this bot")],["more",()=>C("Chưa thêm","Not added")]],wr=t=>({bundled:C("Có sẵn","Built in"),library:C("Đã tải về","Downloaded"),imported:C("Từ máy tính","From this computer")})[t],qe="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function Dt(t,n){const a=await fetch(t,n===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error(l.error??C(`Lỗi ${a.status}`,`Error ${a.status}`));return l.skills??[]}function Nr({botId:t,botName:n,onClose:a,onOpenSettings:l}){const[i,o]=u.useState(null),[c,m]=u.useState(""),[r,d]=u.useState("all"),[p,f]=u.useState(""),[k,g]=u.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;u.useEffect(()=>{let x=!1;return Dt(v).then(S=>{x||o(S)}).catch(S=>{x||(o([]),g(S.message))}),()=>{x=!0}},[v]),u.useEffect(()=>{const x=S=>{S.key==="Escape"&&a()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a]);const j=u.useMemo(()=>{const x=c.trim().toLowerCase();return(i??[]).filter(S=>(r==="all"||(r==="added"?S.added:!S.added))&&(!x||`${S.name} ${S.description}`.toLowerCase().includes(x)))},[i,c,r]),P=async(x,S)=>{if(!p){f(x.name),g("");try{o(await Dt(v,{name:x.name,kind:x.kind,add:S}))}catch(M){g(M instanceof Error?M.message:C("Không đổi được kĩ năng này.","Couldn't change this skill."))}finally{f("")}}},b=(i??[]).filter(x=>x.added).length,w=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:x=>x.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:C("Kho Kĩ Năng (Skills)","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:C(`Chọn kĩ năng riêng cho ${n}. Chỉ những kĩ năng được thêm mới nằm trong lời nhắc của bot, nên bot không bị quá tải. Gõ /tên-kĩ-năng trong chat để gọi.`,`Pick skills just for ${n}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":C("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(et,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Xe,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:c,onChange:x=>m(x.target.value),placeholder:C("Tìm kĩ năng…","Search skills…"),"aria-label":C("Tìm kĩ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":C("Lọc kĩ năng","Filter skills"),children:jr.map(([x,S])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":r===x,onClick:()=>d(x),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${r===x?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[S(),x==="added"&&i?` ${b}`:""]},x))})]}),k&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:k}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:i===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Pe,{size:14,className:"animate-spin"}),C("Đang tải kho…","Loading the store…")]}):j.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:i.length===0?C("Kho chưa có kĩ năng nào.","The store has no skills yet."):C("Không có kĩ năng khớp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:j.map(x=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:x.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:x.core?C("Kĩ năng gốc","Core skill"):wr(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",C("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:x.description})]}),x.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(dt,{size:14}),C("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:qe,disabled:!!p,onClick:()=>{P(x,!1)},"aria-label":C(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[p===x.name?e.jsx(Pe,{size:14,className:"animate-spin"}):e.jsx(dt,{size:14}),C("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:qe,disabled:!!p||!x.ready,onClick:()=>{P(x,!0)},"aria-label":C(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[p===x.name?e.jsx(Pe,{size:14,className:"animate-spin"}):e.jsx(je,{size:14}),C("Thêm","Add")]})]},`${x.kind}:${x.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:C('Bấm "Đã thêm" để bỏ kĩ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:qe,onClick:l,children:C("Tải thêm kĩ năng","Get more skills")})]})]})});return typeof document>"u"?w:cs.createPortal(w,document.body)}const ye=()=>window.ogb?.limixMessenger,zt=[{kind:"telegram",label:"Telegram",placeholder:"123456789:AA…",howTo:()=>C("Tạo bot với @BotFather (lệnh /newbot), rồi dán token vào đây.","Make a bot with @BotFather (/newbot), then paste its token here."),where:t=>`@${t.username}`,linkFrom:t=>C(`Nhắn cho @${t.username}: `,`Send @${t.username}: `)},{kind:"discord",label:"Discord",placeholder:"MTA…",howTo:()=>C("Vào discord.com/developers → New Application → Bot → Reset Token, dán token vào đây. Mời bot vào server: OAuth2 → URL Generator → chọn bot và quyền Send Messages. Trong server, gọi bot bằng @tên-bot.","At discord.com/developers: New Application → Bot → Reset Token, paste it here. Invite it with OAuth2 → URL Generator (bot, Send Messages). In a server, call it with @its-name."),where:t=>`@${t.username}`,linkFrom:()=>C("Nhắn riêng cho bot trên Discord: ","Send the bot a direct message on Discord: ")},{kind:"zalo",label:"Zalo",howTo:()=>C("Quét mã QR bằng ứng dụng Zalo của tài khoản sẽ làm bot.","Scan the QR code with the Zalo app of the account that will be the bot."),note:()=>C("Nên dùng tài khoản Zalo phụ: đây là cách đăng nhập không chính thức (như Zalo Web), Zalo có thể khoá tài khoản. Mở Zalo Web bằng tài khoản này ở nơi khác sẽ ngắt bot.","Use a spare Zalo account: this sign-in is unofficial (like Zalo Web) and Zalo may lock the account. Opening Zalo Web with it elsewhere disconnects the bot."),where:t=>t.name||t.username||"Zalo",linkFrom:()=>C("Từ Zalo của bạn, nhắn cho tài khoản bot: ","From your own Zalo, message the bot's account: ")},{kind:"facebook",label:"Facebook Page",placeholder:"EAA…",howTo:()=>C("Dán Page Access Token: developers.facebook.com → tạo app → thêm Messenger → Access Tokens → chọn Page → Generate token.","Paste a Page access token: developers.facebook.com → create an app → add Messenger → Access Tokens → pick the Page → Generate token."),note:()=>C("Bot trả lời khách nhắn vào Page sau khoảng 10–20 giây. Muốn trả lời mọi khách, app Meta cần được duyệt quyền pages_messaging.","The bot answers people who message the Page within about 10–20 seconds. To answer everyone, the Meta app needs pages_messaging approved."),where:t=>t.name||"Page",linkFrom:()=>C("Từ Facebook cá nhân, nhắn cho Page: ","From your own Facebook, message the Page: ")},{kind:"messenger",label:"Messenger",howTo:()=>C("Đăng nhập Facebook trong cửa sổ của app (nhập cả mã PIN khôi phục tin nhắn nếu Facebook hỏi), rồi đóng cửa sổ. App giữ một cửa sổ Facebook ẩn, đọc tin mới và gõ câu trả lời.","Sign in to Facebook in the app's window (enter the chat-restore PIN if Facebook asks), then close it. The app keeps a hidden Facebook window that reads new messages and types the replies."),note:()=>C("Thử nghiệm, tài khoản cá nhân. Chỉ chạy khi app đang mở trên máy này. Nên dùng tài khoản phụ: Facebook không có cách chính thức cho tài khoản cá nhân và có thể khoá tài khoản. Ai nhắn cũng được trả lời ở chế độ an toàn.","Beta, personal accounts. Runs only while the app is open on this computer. Use a spare account: Facebook has no official way for personal accounts and may lock it. Everyone is answered in safe mode."),where:()=>C("tài khoản Facebook đã đăng nhập","the signed-in Facebook account"),linkFrom:()=>""}],ie="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50";function Sr({bot:t,className:n}){const[a,l]=u.useState("telegram"),[i,o]=u.useState({});u.useEffect(()=>{let r=!0;o({});for(const d of zt.filter(p=>p.kind!=="messenger"||ye()))G(`/api/bots/${t.id}/${d.kind}`).then(p=>{r&&o(f=>({...f,[d.kind]:p}))}).catch(()=>{});return()=>{r=!1}},[t.id]);const c=zt.filter(r=>r.kind!=="messenger"||ye()),m=c.find(r=>r.kind===a);return e.jsxs("div",{className:O("rounded-xl bg-card p-4",n),"data-testid":"channels-card",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:C("Kênh chat","Chat channels")}),e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:C(`Cho ${t.name} trả lời tin nhắn ngoài app.`,`Let ${t.name} answer messages outside the app.`)}),e.jsx("div",{role:"tablist",className:"mt-3 flex flex-wrap gap-1.5",children:c.map(r=>{const d=i[r.kind];return e.jsxs("button",{type:"button",role:"tab","aria-selected":a===r.kind,onClick:()=>l(r.kind),"data-testid":`channel-tab-${r.kind}`,className:O("flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[13px]",a===r.kind?"bg-control text-ink":"text-ink-secondary hover:bg-raised-hover"),children:[d?.connected&&e.jsx("span",{className:O("size-1.5 rounded-full",d.error?"bg-danger":d.enabled?"bg-success":"bg-ink-tertiary")}),r.label]},r.kind)})}),e.jsx(Cr,{bot:t,channel:m,view:i[a],onView:r=>o(d=>({...d,[a]:r}))},`${t.id}:${a}`)]})}function Cr({bot:t,channel:n,view:a,onView:l}){const i=`/api/bots/${t.id}/${n.kind}`,[o,c]=u.useState(""),[m,r]=u.useState(null),[d,p]=u.useState(!1),[f,k]=u.useState(null),g=!!(a?.login&&!a.login.error&&!a.connected);u.useEffect(()=>{if(!g)return;const P=setInterval(()=>{G(i).then(l).catch(()=>{})},2e3);return()=>clearInterval(P)},[g,i,l]);const v=async P=>{p(!0),k(null);try{const{code:b,...w}=await P();l(w),b&&r(b)}catch(b){k(b instanceof Error?b.message:String(b))}finally{p(!1)}},j=(P,b="")=>v(()=>G(`${i}${b}`,{method:"POST",body:JSON.stringify(P??{})}));return a?e.jsxs("div",{className:"mt-3 text-[13px]","data-testid":`channel-${n.kind}`,children:[!a.connected&&e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[e.jsx("span",{children:n.howTo()}),n.note&&e.jsx("span",{className:"text-[12px]",children:n.note()}),n.placeholder?e.jsxs("form",{className:"flex gap-2",onSubmit:P=>{P.preventDefault(),o.trim()&&j({token:o.trim()}).then(()=>c(""))},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:o,onChange:P=>c(P.target.value),placeholder:n.placeholder,"aria-label":C(`Token ${n.label}`,`${n.label} token`),className:"min-w-0 flex-1 rounded-lg bg-inset px-3 py-1.5 font-mono text-[13px] text-ink outline-none","data-testid":`channel-token-${n.kind}`}),e.jsx("button",{type:"submit",disabled:d||!o.trim(),className:ie,"data-testid":`channel-connect-${n.kind}`,children:C("Kết nối","Connect")})]}):n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:d,onClick:()=>{v(async()=>await ye().signIn(t.id))},"data-testid":"channel-signin-messenger",children:C("Mở cửa sổ đăng nhập Facebook","Open the Facebook sign-in window")}):e.jsx(Pr,{view:a,busy:d,start:()=>{j({},"/login")},cancel:()=>{v(()=>G(`${i}/login`,{method:"DELETE"}))}})]}),a.connected&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsx("span",{children:C(`${t.name} trả lời tin nhắn gửi tới ${n.where(a)}.`,`${t.name} answers messages sent to ${n.where(a)}.`)}),e.jsx(Oe,{"aria-label":C(`Bật ${n.label}`,`${n.label} on`),checked:a.enabled===!0,disabled:d,onClick:()=>{j({enabled:!a.enabled})},"data-testid":`channel-switch-${n.kind}`})]}),n.note&&(n.kind==="facebook"||n.kind==="messenger")&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n.note()}),n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:()=>{ye()?.show(t.id)},children:C("Mở cửa sổ Messenger của bot","Show the bot's Messenger window")}):a.owner?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-ink-secondary",children:[e.jsx("span",{children:C(`Chủ bot: ${a.owner}. Nhắn riêng ở đó như nhắn trong app, toàn quyền.`,`Owner: ${a.owner}. Direct messages there work as in the app, with full access.`)}),e.jsx("button",{type:"button",className:ie,disabled:d,onClick:()=>{j({},"/unlink")},children:C("Bỏ liên kết","Unlink")})]}):e.jsxs("div",{className:"flex flex-col gap-1.5 text-ink-secondary",children:[e.jsx("span",{children:C("Liên kết tài khoản của bạn để nhắn với bot như trong app:","Link your own account to talk to the bot as in the app:")}),m?e.jsxs("span",{className:"text-ink","data-testid":`channel-code-${n.kind}`,children:[n.linkFrom(a),e.jsxs("code",{className:"rounded bg-inset px-1.5 py-0.5 font-mono",children:["/link ",m]}),C(" (hết hạn sau 15 phút)"," (expires in 15 minutes)")]}):e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:d,onClick:()=>{j({},"/link")},"data-testid":`channel-link-${n.kind}`,children:C("Tạo mã liên kết","Make a link code")})]}),e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[C("Trả lời cả người khác","Answer other people too"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:C("Người khác và nhóm nhắn được bot ở chế độ an toàn: không dùng công cụ, không thấy cuộc trò chuyện của bạn.","Others and groups can write to the bot in safe mode: no tools, none of your conversations.")})]}),e.jsx(Oe,{"aria-label":C("Trả lời cả người khác","Answer other people too"),checked:a.access==="everyone",disabled:d,onClick:()=>{j({access:a.access==="everyone"?"owner":"everyone"})},"data-testid":`channel-everyone-${n.kind}`})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",className:ie,disabled:d,onClick:()=>{v(async()=>{const P=await G(i,{method:"DELETE"});return n.kind==="messenger"&&await ye()?.signOut(t.id),P})},"data-testid":`channel-remove-${n.kind}`,children:C("Gỡ kết nối","Disconnect")})})]}),(f||a.error)&&e.jsx("div",{role:"alert",className:"mt-2 text-[13px] text-danger",children:f??a.error})]}):e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"…"})}function Pr({view:t,busy:n,start:a,cancel:l}){const i=t.login;return!i||i.error?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[i?.error&&e.jsx("span",{className:"text-danger",children:i.error}),e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:n,onClick:a,"data-testid":"channel-qr-zalo",children:C("Tạo mã QR đăng nhập","Show a sign-in QR code")})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[i.qr?e.jsx("img",{src:i.qr,alt:C("Mã QR đăng nhập Zalo","Zalo sign-in QR code"),className:"size-44 rounded-lg bg-white p-1.5","data-testid":"channel-qr-image"}):e.jsx("div",{className:"flex size-44 items-center justify-center rounded-lg bg-inset",children:"…"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-ink",children:i.scanned?C(`${i.scanned} đã quét. Xác nhận đăng nhập trong ứng dụng Zalo.`,`${i.scanned} scanned it. Confirm the sign-in in the Zalo app.`):C("Mở Zalo trên điện thoại → biểu tượng quét mã → quét mã này.","Open Zalo on the phone → scan icon → scan this code.")}),e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:l,children:C("Huỷ","Cancel")})]})]})}const Or=5,Er={instanceId:"",model:""},Ts=(t,n)=>`${t}\0${n}`,Rr=new Set;function Ht({bot:t,current:n,exclude:a,onPick:l,label:i,title:o,buttonRef:c,className:m,children:r,...d}){const{state:p,dispatch:f,refreshInstances:k,refreshModels:g}=$(),[v,j]=u.useState(!1),[P,b]=u.useState(""),[w,x]=u.useState(()=>new Set),[S,M]=u.useState(!1),[D,B]=u.useState(null),[T,H]=u.useState(null),A=u.useRef(null),h=c??A,I=u.useRef(null),F=u.useRef(null),_=u.useRef(!1),K=u.useId(),J=Va(v),Y=u.useRef({contains:E=>[h.current,I.current].some(q=>q?.contains(E))});Wn(v,Y,()=>j(!1)),u.useLayoutEffect(()=>{if(!v)return;const E=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&I.current?.contains(q.target))return;const Z=h.current?.getBoundingClientRect(),W=I.current;!Z||!W||H(ce=>Gn(Z,{width:ft,height:W.offsetHeight},{width:window.innerWidth,height:window.innerHeight},ce??void 0))};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[v,h]),u.useEffect(()=>{if(!v||!T||!_.current)return;_.current=!1;const E=I.current;(E?.querySelector("[data-menu-search]")??E?.querySelector("[data-current-model]")??E?.querySelector("[data-menu-row]:not(:disabled)")??E)?.focus({preventScroll:!0})},[v,T]);const U=E=>{j(!1),E&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),x(new Set),H(null),_.current=!0,j(!0),M(!0),k().catch(()=>{}).finally(()=>M(!1))},z=E=>{D||(B(E.instanceId),g(E.instanceId).catch(()=>{}).finally(()=>B(null)))},le=()=>{U(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const E=Jn(p.instances,n?.instanceId).flatMap(W=>{const ce=W.models.options.filter(we=>!a.has(Ts(W.instanceId,we.id)));return ce.length===W.models.options.length?[W]:ce.length?[{...W,models:{...W.models,options:ce}}]:[]}),q=Qn({instances:p.instances,listed:E,selection:n??Er,bot:{name:t.name,selection:t.modelSelection},query:P,expanded:w,probing:Rr,loading:S,refreshing:D}),Z=q.groups.map(W=>W.instance.instanceId===t.modelSelection.instanceId?{...W,note:s("botPanel.backups.sameAccount")}:W);return{...q,groups:Z,...n?{}:{current:null}}},ge=E=>{if(!(E.nativeEvent.isComposing||E.defaultPrevented)){if(E.key!=="Escape")return Yn(E,{query:P,typed:F,close:()=>U(!0)});E.preventDefault(),E.stopPropagation(),P?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...d,"aria-label":i,title:o,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?K:void 0,onClick:()=>v?U(!1):y(),onKeyDown:E=>{E.key==="Escape"&&v?(E.preventDefault(),E.stopPropagation(),U(!1)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&!v&&(E.preventDefault(),y())},className:m,children:r}),J.shown&&cs.createPortal(e.jsx("div",{ref:I,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...J.exitProps,onKeyDown:ge,onPointerMove:Vn,style:{position:"fixed",left:T?.left??0,top:T?.top,bottom:T?.bottom,width:T?.width??ft,maxHeight:T?.maxHeight,transformOrigin:T?.origin,visibility:T?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",J.className),children:e.jsx(Zn,{menu:ue(),query:P,bot:t,botModel:{label:"",title:""},idPrefix:K,onQuery:b,onPick:(E,q)=>{E.policy||(l({instanceId:E.instanceId,model:q}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:E=>x(q=>{const Z=new Set(q);return Z.delete(E.instanceId)||Z.add(E.instanceId),Z}),onSetUp:le,onCheckAgain:z,onManage:le})}),document.body)]})}function Ir({bot:t,onChange:n}){const{state:a}=$(),l=t.fallback??[],i=u.useRef(null),o=m=>new Set([t.modelSelection,...l.filter((r,d)=>d!==m)].map(r=>Ts(r.instanceId,r.model))),c=m=>{const r=a.instances.find(f=>f.instanceId===m.instanceId),d=r?.models.options.find(f=>f.id===m.model),p=Kn(r,m.model);return{instance:r,name:p,short:r&&d?Un(d.label,qn(r)):p}};return e.jsx(L,{anchor:"backups",children:e.jsxs(pe,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Hn}),e.jsx(ne,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((m,r)=>{const{instance:d,name:p,short:f}=c(m);return e.jsxs("li",{"data-backup":m.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:r+1}),e.jsxs(Ht,{bot:t,current:m,exclude:o(r),onPick:k=>n(l.map((g,v)=>v===r?k:g)),label:s("botPanel.backups.row",{position:r+1,model:p}),title:d?`${d.displayName} · ${p}`:p,"data-panel-action":"backup-change",className:"group flex h-8 min-w-0 flex-1 items-center gap-2 rounded-[8px] bg-ink/[0.04] pl-2.5 pr-2 text-left text-[13px] text-ink hover:bg-ink/[0.07] aria-expanded:bg-ink/[0.08]",children:[d?e.jsx(_n,{instance:d,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),!d&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(fe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Le,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:p}),onClick:()=>{n(l.filter((k,g)=>g!==r)),i.current?.focus({preventScroll:!0})}})]},r)})}),l.length<Or&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(Ht,{bot:t,current:null,exclude:o(null),onPick:m=>n([...l,m]),label:s("model.fallback.add"),buttonRef:i,"data-panel-action":"backup-add",className:O(oe,"aria-expanded:bg-raised-hover"),children:[e.jsx(je,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Tr({bot:t}){const{dispatch:n}=$(),[a,l]=u.useState(!1),[i,o]=u.useState(!1),[c,m]=u.useState(0),r=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(u.useEffect(()=>{if(!r)return;let p=!0;return G(`/api/bots/${t.id}/system-prompt`).then(f=>{p&&l(f.heavy===!0)},()=>{}),()=>{p=!1}},[t.id,r,c]),!r||!a)return null;const d=async()=>{o(!0);try{await ms(t.id)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("common.tryAgain")})}finally{o(!1),m(p=>p+1)}};return e.jsx(L,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:Xn}),e.jsx(ne,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:i,onClick:()=>{d()},className:oe,children:i?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Ar=5;function Lr({bot:t}){const{dispatch:n,flushBotPatches:a}=$(),[l,i]=u.useState([]),[o,c]=u.useState(null),m=u.useCallback(()=>Nt(t.id).then(d=>i(d.rows.slice(0,Ar)),()=>{}),[t.id]);if(u.useEffect(()=>{m()},[m,t.soul]),!l.length)return null;const r=async d=>{if(!o){c(d.id);try{await a(t.id);const{revision:p}=await Nt(t.id);await si(t.id,d.id,p)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("botOverview.undoFailed")})}finally{c(null),await m()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(ot,{rows:l,botName:t.name,reverting:o,onRevert:d=>{r(d)}})]})}const We={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function Mr({bot:t,derived:n,onOpen:a,editingInstructions:l=!1,onEditInstructions:i}){const{state:o,dispatch:c,flushBotPatches:m}=$(),{capabilities:r,ready:d}=ke(),p=is(t),{servers:f}=bs(),k=ea(Ze(t)),g=ta(),v=js(t.id),j=gs(),[P,b]=u.useState(null),{patch:w,approvalMode:x,engine:S}=n,M=t.name,D=()=>{P!==null&&P.trim()!==t.title.trim()&&w({title:P.trim()}),b(null)},B=S?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,T=[{value:"ask",label:We.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:We.full(),tooltip:s("botSettings.simple.fullHint")},...B==="ask"||B==="full"?[]:[{value:B,label:We[B](),disabled:!0,tooltip:B==="custom"?s("botPanel.acts.customHint"):void 0}]],H=y=>{y===x||y!=="ask"&&y!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},A=!d||sa(r,o.config),h=xa(g,{turnsHere:A,canLive:!0}),I=A?null:na(r,!!ia()?.speechStart,aa(o.config)),F=ra.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&I!==null,tooltip:y.id==="turns"&&I?`${I.label}. ${I.reason}`:y.id==="live"?s("call.mode.liveHint"):oa("turns")})),_=la.map(y=>({value:y,label:s(St[y][0]),tooltip:s(St[y][1])})),K=()=>{const y=!t.notifications;y&&ha(),w({notifications:y})},J=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...p.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?vs(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(ni,{bot:t}),e.jsx(L,{anchor:"instructions",children:Y?e.jsxs(pe,{"data-panel-row":"soul",children:[e.jsx(ai,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:M})}}),e.jsx(Lr,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{m(t.id),i?.(!1)},className:oe,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>i?.(!0),className:O(Q,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Ae}),e.jsx(ne,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:ii(t.soul??"")||s("botPanel.instructionsHint",{name:M})})}),e.jsx(ve,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Tr,{bot:t}),e.jsx(L,{anchor:"approval",children:e.jsxs(pe,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Zt}),e.jsx(ne,{title:s("botSettings.simple.beforeActs",{name:M}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ce,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:M}),value:B,onChange:H,options:T})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(ca,{choice:k.choice})})]}),J.length>0&&e.jsxs("div",{"data-panel-row":"always-allow",className:"flex min-w-0 flex-col gap-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botAccess.always.title")}),J.map(y=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:y}),e.jsx(Le,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:J.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Ir,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(L,{anchor:"call",children:e.jsxs(pe,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Ua}),e.jsx(ne,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ce,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:da,options:F})})]})}),e.jsxs(L,{anchor:"replies",children:[e.jsxs(pe,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:pa}),e.jsx(ne,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ce,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:y=>w({replyStyle:y}),options:_})})]}),e.jsx(at,{"data-panel-row":"notifications",icon:ma,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(L,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:as,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>a?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(Q,"cursor-text"),children:[e.jsx(X,{icon:Ti}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:P??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ye.title,onChange:y=>b(y.target.value),onBlur:D,onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),y.currentTarget.blur()):y.key==="Escape"&&P!==null&&(y.preventDefault(),y.stopPropagation(),b(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:O(Q,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ks}),e.jsx(ne,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(ls,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(ee,{"data-panel-page":"visibility",icon:Gt,title:s("botSettings.visibility.title"),value:ri(t.visibility),onClick:()=>a?.("visibility")})]}),t.yourAccess!=="view"&&!t.defaultBot&&e.jsx(Sr,{bot:t,className:"mt-3.5"}),e.jsx(oi,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(ua,{bot:t}),k.dialogs]})}const Br=5;function $r({bot:t,onChanged:n}){const{dispatch:a}=$(),[l,i]=u.useState([]),[o,c]=u.useState(null),[m,r]=u.useState(null),d=u.useCallback(async()=>{const[g,v]=await Promise.all([it(t.id),he(t.id)]);c(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),i(v.slice(0,Br))},[t.id]);u.useEffect(()=>{d().catch(()=>{})},[d,t.busy]);const p=g=>a({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{r(g.id);try{await xs(t.id,g.id),await n()}catch(v){p(v)}finally{r(null),await d().catch(()=>{})}},k=async g=>{r("review");try{await ps(t.id,g.value.token),c(null)}catch(v){v instanceof Qt&&v.status===409?(c({...g,stale:!0}),await d().catch(()=>{})):p(v)}finally{r(null)}};return e.jsxs(e.Fragment,{children:[o&&e.jsx(Ns,{changed:o.value.changed,stale:o.stale,busy:m!==null,onReviewed:()=>{k(o)}}),e.jsx(L,{children:e.jsx(at,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>a({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(L,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(ot,{rows:l,botName:t.name,reverting:m,onRevert:g=>{f(g)}})})})]})}const Fr="flex flex-col gap-3",_t="https://www.skills.sh";function be(t,n){return t instanceof Error&&t.message?t.message:n}function Dr({bot:t,derived:n}){const{dispatch:a}=$(),l=is(t),{servers:i,error:o}=bs(),{patch:c,canUseConnectedApps:m}=n,r=i?ji(i,t.id):[],d=new Set(vs(r,t.mcpServers,t.id).map(g=>g.name)),p=g=>{const v=va(t,l.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&c(v)},f=g=>{t.busy||o||c({mcpServers:wi(r,t.mcpServers,g)})},k=m?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[k&&e.jsx(V,{children:k}),m&&l.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(ya,{card:g.card,className:"size-7 shrink-0"},`${g.card.logo}:${g.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:g.label}),e.jsx(yt,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>p(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(r.length>0||o)&&e.jsxs(L,{label:s("connectors.tab.mcp"),children:[o&&e.jsx(V,{children:s("botAccess.mcpRefreshError")}),r.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Q,children:[e.jsx(X,{icon:qa}),e.jsx(ne,{title:e.jsx("span",{className:"block truncate",children:g.name}),hint:g.enabled?g.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(yt,{color:t.color,checked:d.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||o,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(L,{children:e.jsx(me,{"data-panel-link":"add-app",icon:je,onClick:()=>ba(a,t.id),children:s("botPanel.apps.connectAnother")})})]})}function zr({bot:t,derived:n}){const{state:a,dispatch:l}=$(),[i,o]=u.useState(()=>n.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(vi,{routines:n.botRoutines,runs:a.routineRuns,pausedBots:a.config?.pausedBots,heldBots:a.config?.heldBots,loading:a.routinesLoadState==="loading"&&n.botRoutines.length===0,error:a.routinesLoadState==="error",onOpen:o,onLogs:c=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>l({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(L,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:je,onClick:()=>o("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),i&&e.jsx(Ni,{routine:i==="new"?void 0:i,bots:[t],lockedBotId:t.id,onClose:()=>o(null)},t.id)]})}function Hr({bot:t}){const n=Rs(t),[a,l]=u.useState(""),[i,o]=u.useState(null),[c,m]=u.useState(!1),[r,d]=u.useState(null),p=t.memoryEnabled!==!1,f=n.docs?Es(n.docs):null,k=n.docs?.find(b=>b.path===te)??null;u.useEffect(()=>o(null),[t.id,p]);const g=async b=>{if(c)return!1;m(!0),d(null);try{return await b()}catch(w){return d(be(w,s("botPanel.library.memoryError"))),!1}finally{m(!1)}},v=(b,w)=>g(async()=>{const x=await rt(t.id,b.path,w,b.exists?b.hash:void 0,n.mine);return x.ok?(n.setDoc(x.doc),!0):(await n.reload(),d(s("memory.conflict.title",{name:t.name})),!1)}),j=b=>{const w=n.docs?.find(x=>x.path===b.path);w&&(b.line!==null?v(w,fr(w.text,b.line)):g(async()=>(await us(t.id,w.path,n.mine),await n.reload(),!0)))},P=async()=>{!k||!a.trim()||await v(k,gr(k.text,a))&&l("")};return p&&i?.botId===t.id?e.jsx(_r,{bot:t,doc:i.doc,mine:n.mine,onDone:b=>{b&&n.setDoc(b),o(null),d(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[p?n.error?e.jsx(V,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(V,{children:s("common.checking")}):f.length===0?e.jsx(V,{children:s("botPanel.memory.empty")}):f.map(b=>e.jsxs("div",{"data-memory-note":b.line??b.path,className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:b.text}),e.jsx(Le,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>j(b)})]},`${b.path}:${b.line}:${b.text}`)):e.jsx(V,{children:s("botPanel.library.memoryOff",{name:t.name})}),r&&e.jsx(V,{tone:"warn",children:r})]}),p&&e.jsxs(L,{children:[e.jsx(rs,{"data-panel-form":"memory-add",value:a,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:c||k===null,onChange:l,onSubmit:()=>{P()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Ae,onClick:()=>o({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),p&&!n.mine&&e.jsx($r,{bot:t,onChanged:n.reload})]})}function _r({bot:t,doc:n,mine:a,onDone:l}){const[i,o]=u.useState({text:n.text,hash:n.hash}),[c,m]=u.useState(n.text),[r,d]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(!1),[v,j]=u.useState(null),P=u.useRef(!0);u.useEffect(()=>(P.current=!0,()=>{P.current=!1}),[]);const b=async x=>{g(!0),j(null);try{const S=await rt(t.id,n.path,c,x,a);if(!P.current)return;S.ok?l(S.doc):d({current:S.current,currentHash:S.currentHash})}catch(S){j(be(S,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{r&&(f(x=>x===null||x===c?c:`${x}
15
+
16
+ ${c}`),o({text:r.current,hash:r.currentHash}),m(r.current),d(null))};return e.jsx(L,{children:e.jsxs(pe,{"data-panel-row":"memory-text",children:[r&&e.jsx(Ss,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{b(r.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(Qe,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:x=>m(x.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),p!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:p}),e.jsx("button",{type:"button",className:O(oe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:oe,disabled:k,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:oe,disabled:k||c===i.text,onClick:()=>{b(i.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Kr({bot:t}){const{request:n}=fa(),{state:a,dispatch:l}=$(),i=hs(t),[o,c]=u.useState(""),[m,r]=u.useState(!1),[d,p]=u.useState([]),f=ga(a.config),k=async x=>{if(!i.working&&window.confirm(s(x.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:x.name}))){i.setWorking(x.name),i.setError("");try{await n(`/api/bots/${t.id}/skills/${encodeURIComponent(x.name)}`,{method:"DELETE"}),await i.refresh()}catch(S){i.setError(be(S,s("botPanel.skills.removeFailed")))}finally{i.setWorking("")}}},g=async()=>{const x=o.trim();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const S=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});p(Ct(S.imported??[])),c(""),await i.refresh()}catch(S){i.setError(be(S,s("botPanel.skills.importFailed")))}finally{r(!1)}}},v=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const S=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});p(Ct(S.imported??[])),await i.refresh()}catch(S){i.setError(be(S,s("botPanel.skills.importFailed")))}finally{r(!1)}}},[j,P]=u.useState(!1),b=()=>{P(!1),l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){P(!0);return}gt(_t)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[i.loading?e.jsx(V,{children:s("skills.loading")}):i.skills.length===0?e.jsx(V,{children:s("botSettings.simple.noSkills")}):i.skills.map(x=>e.jsx(at,{"data-panel-row":`skill:${x.name}`,title:x.name,hint:x.description||x.source,label:s("botSettings.simple.skillToggle",{name:x.name}),color:t.color,checked:fs(x),disabled:!!i.working||x.core===!0,onChange:()=>{i.toggle(x)},extra:x.origin==="imported"||x.origin==="native"||x.origin==="bundled"?void 0:e.jsx(Le,{"data-panel-action":`remove-skill:${x.name}`,label:s("botPanel.skills.remove",{name:x.name}),disabled:!!i.working,onClick:()=>{k(x)}})},x.name)),i.error&&!i.reviewing&&e.jsx(V,{tone:"warn",children:i.error})]}),e.jsx(ci,{bot:t,onAdded:()=>{i.refresh()}}),e.jsxs(L,{children:[e.jsx(rs,{"data-panel-form":"skill-import",value:o,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:m?s("skills.import.importing"):s("common.add"),disabled:m,onChange:c,onSubmit:()=>{g()}}),d.map(x=>e.jsx(V,{children:x},x)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{gt(_t)},children:s("botPanel.skills.skillsSh")}),e.jsx(me,{"data-panel-link":"browse-skills",onClick:w,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(me,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),j&&e.jsx(Nr,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{P(!1),i.refresh()}}),i.reviewing&&e.jsx(di,{skill:i.reviewing.skill,text:i.reviewing.text,error:i.error,working:i.working===i.reviewing.skill.name,onCancel:()=>i.setReviewing(null),onEnable:()=>{i.enableReviewed()}})]})}function Ur({bot:t}){const{capabilities:n}=ke(),a=n.host?.homeDir,{draft:l,setDraft:i,error:o,saving:c,canPick:m,save:r,pick:d}=li(t),[p,f]=u.useState(!1),k=!!t.cwd||p,g=()=>{if(m){d();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[e.jsx(Ve,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:c,onClick:()=>{f(!1),t.cwd&&r(null)}}),e.jsx(Ve,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:c,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(L,{children:[m?e.jsxs("div",{className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?st(t.cwd,a):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:c,onClick:()=>{d()},className:oe,children:[e.jsx(Jt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Q,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&r(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>i(v.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:c||l===null,className:oe,children:s("botAccess.folder.save")})]}),o&&e.jsx(V,{tone:"warn",children:o})]})]})}function qr({bot:t,derived:n}){const a=Cs(t);return e.jsx(kr,{bot:t,browserEnabled:n.browserEnabled,onOpenBrowser:()=>a("browser")})}function Wr({bot:t}){return gs()?e.jsx(ys,{bot:t}):null}function Vr({page:t,onOpen:n,editingInstructions:a,onEditInstructions:l,...i}){switch(t){case"settings":return e.jsx(Mr,{...i,onOpen:n,editingInstructions:a,onEditInstructions:l});case"where":return e.jsx(ar,{...i});case"apps":return e.jsx(Dr,{...i});case"routines":return e.jsx(zr,{...i});case"visibility":return e.jsx(Wr,{...i});case"memory":return e.jsx(Hr,{...i});case"skills":return e.jsx(Kr,{...i});case"folder":return e.jsx(Ur,{...i});case"browser":return e.jsx(qr,{...i})}}const Kt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Ut(t){const[n,a]=u.useState(null),l=u.useRef(!1),i=u.useRef(!1),o=u.useRef(null);u.useEffect(()=>{n!==null||!i.current||(i.current=!1,o.current?.focus())},[n]);const c=p=>{l.current=!1,a(p)},m=()=>{n!==null&&t(n),a(null)};return{draft:n,setDraft:a,start:c,onKeyDown:p=>{if(ja(p.nativeEvent)){p.stopPropagation();return}p.key==="Enter"?(p.preventDefault(),l.current=!0,i.current=!0,m()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l.current=!0,i.current=!0,a(null))},onBlur:()=>{l.current||m()},buttonRef:o}}function Zr({bot:t,activeState:n,patch:a,editorOpen:l,onToggleEditor:i}){const o=Ut(r=>{const d=r.trim();d&&d!==t.name&&a({name:d})}),c=Ut(r=>{const d=r.trim();d!==t.title.trim()&&a({title:d})}),m=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:i,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Je,{bot:t,size:64,state:n}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(bt,{size:20})}),t.chiefOfStaff&&e.jsxs("span",{"data-panel-chief":!0,title:s("chat.chiefOfStaff"),className:"absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app",children:[e.jsx(ka,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:o.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ye.name,value:o.draft,onChange:r=>o.setDraft(r.target.value),onKeyDown:o.onKeyDown,onBlur:o.onBlur,className:O(Kt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:o.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>o.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(bt,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),c.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ye.title,value:c.draft,onChange:r=>c.setDraft(r.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:O(Kt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):m&&e.jsx("button",{ref:c.buttonRef,type:"button","data-panel-label":!0,onClick:()=>c.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:m})]})}function Se(t,n){return t?os(t,n):{tab:"details"}}function Gr({bot:t,derived:n,linkedSection:a,onClose:l}){const{dragProps:i}=ds(),o=wa(),[c,m]=u.useState(()=>Se(a,o).tab),[r,d]=u.useState(()=>{const h=Se(a,o).page;return h?[h]:[]}),[p,f]=u.useState(()=>Se(a,o).anchor??null),[k,g]=u.useState(!1),[v,j]=u.useState(()=>!!Se(a,o).editInstructions),P=u.useRef(null),b=u.useRef(null),w=r.at(-1)??null,x=()=>P.current?.scrollTo({top:0}),S=h=>{m(h.tab),d(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),x()},M=h=>S({tab:h}),D=h=>{d(I=>[...I,h]),g(!1),x()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},T=()=>{d(h=>h.slice(0,-1)),x()};u.useEffect(()=>{a&&S(os(a,o))},[a,o]),u.useEffect(()=>{p&&(P.current?.querySelector(`[data-panel-card="${p}"]`)?.scrollIntoView({block:"start"}),f(null))},[p,w,c]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const I=h.target,F=typeof I?.closest=="function"?I.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(F&&!F.contains(h.currentTarget)&&F!==b.current&&!b.current?.contains(F))){if(k)B();else if(r.length>0)T();else return;h.preventDefault(),h.stopPropagation()}},A=r.length>1?s(Ne[r[r.length-2]].title,{name:t.name}):s(vt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,children:[e.jsxs("div",{...i,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(Na,{bot:t,className:De}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>S({tab:"details",page:"settings"}),className:De,children:e.jsx(Sa,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:De,children:e.jsx(et,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:P,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:w===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:b,children:[e.jsx(Zr,{bot:t,activeState:n.activeState,patch:n.patch,editorOpen:k,onToggleEditor:()=>g(h=>!h)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:B}),e.jsx(tr,{bot:t,activeState:n.activeState,onPatch:n.patch,onClose:B})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:Ca.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===h,"data-panel-tab":h,onClick:()=>M(h),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(vt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(xr,{bot:t,derived:n,onOpen:D}),c==="library"&&e.jsx(Is,{bot:t,onOpen:D}),c==="computer"&&e.jsx(ir,{bot:t,derived:n,onOpen:D})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Pa,{back:A,title:s(Ne[w].title,{name:t.name}),intro:Ne[w].intro?s(Ne[w].intro,{name:t.name}):void 0,onBack:T}),e.jsx("div",{className:O("mt-4",Fr),children:e.jsx(Vr,{page:w,bot:t,derived:n,onOpen:D,editingInstructions:v,onEditInstructions:j})})]})})]})}function Yr(t,n){const{state:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[c,m]=u.useState(!1),[r,d]=u.useState(null),[p,f]=u.useState(!1),k=u.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),g=n.followEdits??!0,v=g?k:null,j=g?a.routines:null,P=g?a.webhooks:null;return u.useEffect(()=>{if(!n.overview&&!n.prompt)return;let b=!1;return(async()=>(await l(t.id),!b&&(n.overview&&G(`/api/bots/${t.id}/overview`).then(x=>{b||(o(x),m(!1))}).catch(()=>{b||m(!0)}),n.prompt&&G(`/api/bots/${t.id}/system-prompt`).then(x=>{b||(d(x),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,n.overview,n.prompt,v,j,P,l]),{overview:i,overviewError:c,prompt:r,promptError:p}}function Jr(t,n){const{dispatch:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[c,m]=u.useState(!1),[r,d]=u.useState(null),p=u.useRef(0),[f,k]=u.useState(!1),[g,v]=u.useState(null),j=u.useCallback(()=>{const w=++p.current;return m(!1),l(t.id).then(()=>G(`/api/bots/${t.id}/history?limit=100`)).then(x=>{w===p.current&&(o(x.rows),d(x.revision))}).catch(()=>{w===p.current&&m(!0)})},[t.id,l]);return u.useEffect(()=>{if(n)return j(),()=>{p.current++}},[n,j]),{rows:i,error:c,revision:r,rollingBack:f,rollbackTarget:g,setRollbackTarget:v,rollback:async w=>{if(!f){v(null),k(!0);try{await l(t.id),await G(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(x){a({type:"error",message:x instanceof Error?x.message:s("botOverview.undoFailed")})}finally{await j(),k(!1)}}},requestRollback:w=>{r&&v({id:w,expectedRevision:r})}}}function Qr({history:t,returnFocusRef:n}){const{rollbackTarget:a,setRollbackTarget:l,rollback:i}=t;return e.jsx(Oa,{open:a!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:n,onCancel:()=>l(null),onConfirm:()=>{a&&i(a)}})}const Xr={memory:"memory",skills:"skills",folder:"access"},As=t=>t.labelKey?s(t.labelKey):t.label;function qt(t,n){return n?[t.label,As(t),...t.keywords].some(a=>a.toLowerCase().includes(n)):!0}function yo({bot:t,overlay:n=!1}){const{state:a,dispatch:l}=$(),i=a.botSettingsSection,o=Ea(t),c=u.useRef(null),{dragProps:m}=ds(),[r,d]=u.useState(""),p=!a.botSettingsExpandAccordion,f=r.trim().toLowerCase(),g=!Wt(),v=!p&&!a.botSettingsExpandRemembered?i:null,j=js(t.id),P=nt(),b=Ra(),w=Ai.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&P===!0&&!b),x=w.filter(A=>qt(A,f)),{overview:S,overviewError:M,prompt:D,promptError:B}=Yr(t,{overview:i==="overview"&&!g,prompt:i==="overview"&&!g}),T=Jr(t,i==="history"&&!g);u.useEffect(()=>{if(!p){if(f){d("");return}c.current?.querySelector(`[data-bot-settings-section="${i}"]`)?.scrollIntoView({block:"nearest"})}},[p,i,f]),u.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,h=c.current;h?.focus();const I=F=>{const _=h?.querySelector('[role="dialog"], [role="alertdialog"]');_&&_.getClientRects().length>0||h&&F.target instanceof Node&&!h.contains(F.target)||F.key==="Escape"&&!F.defaultPrevented&&(F.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I),A?.focus()}},[l]);const H=A=>{switch(A){case"overview":return S===null&&M?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(zi,{overview:S,refreshError:S!==null&&M,prompt:D,promptError:B,onOpen:h=>l({type:"toggleSettings",open:!0,section:h}),onSetup:o.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(gi,{bot:t,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return e.jsx(fi,{bot:t,patch:o.patch});case"slack":return j?e.jsx(Hi,{managementUrl:j}):null;case"skills":return e.jsx(hi,{bot:t});case"memory":return e.jsx(Ui,{bot:t,active:!p&&i==="memory",onToggle:h=>o.patch({memoryEnabled:h})});case"library":return e.jsx(Is,{bot:t,onOpen:h=>l({type:"toggleSettings",open:!0,section:Xr[h]??"overview"})});case"routines":return e.jsx(ki,{bot:t,routines:o.botRoutines,runs:a.routineRuns});case"access":return e.jsx(xi,{bot:t,derived:o});case"model":return e.jsx(ui,{bot:t});case"permissions":return e.jsx(mi,{bot:t,derived:o});case"voice":return e.jsx(pi,{bot:t,derived:o});case"visibility":return e.jsx(ys,{bot:t});case"history":return T.rows===null&&T.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Zi,{bot:t,rows:T.rows,refreshError:T.rows!==null&&T.error,onRollback:T.requestRollback,rollingBack:T.rollingBack||!T.revision});case"usage":return e.jsx(Gi,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:g?Ia:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Aa(n,g),children:g?e.jsx(Gr,{bot:t,derived:o,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...m,className:"flex shrink-0 items-center justify-between px-4 py-3",children:[e.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:t.name}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Ta,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(et,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Xe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:r,onChange:A=>{d(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),r?d(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[x.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:r.trim()})}),w.map(A=>{const{id:h,icon:I}=A,F=As(A),_=qt(A,f);if(!_&&h!=="memory")return null;const K=!p&&i===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!_,children:[e.jsxs("button",{type:"button",onClick:()=>{if(i===h&&!p){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:h})},"aria-expanded":K,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",K?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(I,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",K&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!K,className:"px-4 pb-4 pt-1",children:H("memory")}):K&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(Qr,{history:T,returnFocusRef:c})]})}export{yo as BotSettingsDialog};