limixbot 0.3.130 → 0.3.131

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 (118) hide show
  1. package/dist/assets/{ActivityPanel-CswemPGx.js → ActivityPanel-DLm-v_Kg.js} +1 -1
  2. package/dist/assets/{App-CeGk9O7P.js → App-Co1EFoza.js} +123 -123
  3. package/dist/assets/{AppEventEditor-lydjfKAA.js → AppEventEditor-BdU7zTya.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-DZbrG3Yu.js +16 -0
  5. package/dist/assets/BrowserPanel-BAmkHZNW.js +3 -0
  6. package/dist/assets/{BrowserProfilesManager-DAI3EyaZ.js → BrowserProfilesManager-DL_IVvlO.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-Lo18f6GE.js → CloudAddDialog-Cs6tRBOu.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-LtL8VMhS.js → ComputerFilesPane-Bl6NnCOe.js} +1 -1
  9. package/dist/assets/{ComputerPanel-mEdoL4Dh.js → ComputerPanel-CzwDPKV_.js} +2 -2
  10. package/dist/assets/{DataPanel-HeNk8eOt.js → DataPanel-FEAZNWku.js} +1 -1
  11. package/dist/assets/{DesktopViewer-DCC-jq_j.js → DesktopViewer-Cb9PL6v1.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-I9x5B1Kv.js → GrokMoveDialog-Bp0mxIE8.js} +1 -1
  13. package/dist/assets/{InspectorPanel-C-ocpaf1.js → InspectorPanel-DJADxXPA.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-D73O8To_.js → KeyboardShortcutsModal-CNiZBEA1.js} +1 -1
  15. package/dist/assets/{LimixResizeHandles-kOyb_U62.js → LimixResizeHandles-nzE7n7jC.js} +1 -1
  16. package/dist/assets/{LiveDesktop-DYg8H5rp.js → LiveDesktop-BvdjlV9Q.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-BsGviUnb.js → LocalVmWorkspace-DmQTSD1_.js} +1 -1
  18. package/dist/assets/{MacLocalControl-Db0f-6Gc.js → MacLocalControl-WWFi-S9U.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-Dj8Z6Mm0.js → MarkdownFilePreview-BsGqiWI2.js} +1 -1
  20. package/dist/assets/{MenuMotion-CgVWckHz.js → MenuMotion-owWIcamS.js} +1 -1
  21. package/dist/assets/{NewBotDialog-Bp8-zb5M.js → NewBotDialog-sr2kfVv6.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-BWtFp9EN.js → PhoneAppDialog-DC4JUrmh.js} +1 -1
  23. package/dist/assets/{PlacesRail-CKR79j8d.js → PlacesRail-BxdV2GDQ.js} +1 -1
  24. package/dist/assets/{PluginsPanel-BZe968J8.js → PluginsPanel-BMHhkTNZ.js} +5 -5
  25. package/dist/assets/{ProIntroduction-CZGUC6Ms.js → ProIntroduction-CLLJ3Vgd.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-CCOe2O1O.js → RemoteAgentSettingsPanel-DWTstMZc.js} +1 -1
  27. package/dist/assets/{RoomPanel-jgyrxLn2.js → RoomPanel-DuE_Gpr5.js} +1 -1
  28. package/dist/assets/{RoutinesPage-D5Z3pmtB.js → RoutinesPage-CPo3eSc1.js} +1 -1
  29. package/dist/assets/{SettingsModal-CeKynb83.js → SettingsModal-BZzK-mss.js} +4 -4
  30. package/dist/assets/{ShareTeamDialog-D7qwIwXJ.js → ShareTeamDialog-CDkcowQz.js} +1 -1
  31. package/dist/assets/{SignedInSites-Dh9imU42.js → SignedInSites-DLDJv-6U.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-nz4rcGmz.js → TeamLibraryPanel-X0NQqbX0.js} +1 -1
  33. package/dist/assets/{TeamMapPage-CLdRh0ZK.js → TeamMapPage-C6K12Ejq.js} +1 -1
  34. package/dist/assets/{TriggersPage-BByyX4CZ.js → TriggersPage-BAXbOt6i.js} +1 -1
  35. package/dist/assets/{VisibilitySection-BNhdo2-L.js → VisibilitySection-CC7rEV8o.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-DxDhbnYz.js → WebhookTrigger-cHV0kIQv.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-CUh8CexO.js → WorksOnGrid-DZ5DXYgb.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-uSJsuKuD.js → abnfDiagram-YUKMZFIV-vvJbRPlq.js} +1 -1
  39. package/dist/assets/{activity-CmQeVvqw.js → activity-D26W1wR5.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-Br4Cv9sO.js → architectureDiagram-47P4ROYG-BxqUvVUX.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-CzcaYs_s.js → blockDiagram-E7TT5TSB-DDe2YxQP.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-CDGjKlxD.js → c4Diagram-CRA5TL53-OdUvGZP-.js} +1 -1
  43. package/dist/assets/{calendar-days-DSUOH-dL.js → calendar-days-OEtSVrLe.js} +1 -1
  44. package/dist/assets/channel-D_nJ6dC4.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-CvuZ4KJD.js → chunk-2Q5K7J3B-DpnJlpzb.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-negAvO9N.js → chunk-5VM5RSS4-C5UgOu8-.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-DA_OVnE1.js → chunk-7TKQ45FW-Dv-gctKP.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-Dbtemotq.js → chunk-AW2ZBBNX-mehzuNgt.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-Cnt25BNn.js → chunk-FVRAUYC3-6bArILty.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-CtrZ11_G.js → chunk-HTAEGDNF-0w6XIlls.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-DKZW0s8n.js → chunk-JWPE2WC7-DaZro178.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-DLg5U6as.js → chunk-KQW6MTUR-CqA51RiN.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-pkGzgUQb.js → chunk-XXDRQBXY-DPZH_wOz.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-BUBR3HPE.js → classDiagram-v2-K4WV4PDN-Dgn2w_U2.js} +1 -1
  55. package/dist/assets/{coins-Dbmac6SO.js → coins-D0EwvaZf.js} +1 -1
  56. package/dist/assets/{core-BA6DGyEo.js → core-Lc3koHof.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-BukDY2ET.js → cose-bilkent-JH36ORCC-B9lVmBnW.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-B3XBpINL.js → cynefin-EF2NZ3EQ-BoirpSv2.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-BV0SrhK6.js → cynefinDiagram-3GCD6N5R-Cdmdj7_K.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-DzXXYwns.js → dagre-W4DXFKR2-BFjlE582.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-BmOG88-j.js → diagram-2UJZ2QOL-OsLSZez_.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-C9zP_sNp.js → diagram-OVF4WLC6-CwDUdKBh.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-UzTTpwh8.js → diagram-PFPMY2P6-BLtFTcT4.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-Bo-9jQh-.js → diagram-UMYRVEAY-BSLF9HqA.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-eNeARjiU.js → diagram-YEKJPTXX-9rCjHXiY.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-Bp8Apm58.js → diagram-ZIFT7M5P-C4BY_KLT.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-CThvAW5-.js → ebnfDiagram-VR2GEFS7-AhQ5NsrM.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-CIAQeuC1.js → elk-IJKZMXRS-UnH28E2R.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-DJc0-QG5.js → erDiagram-O2IAPWRE-CO0nepRl.js} +1 -1
  70. package/dist/assets/{file-up-uBDzou4C.js → file-up-D-jXnd_Y.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-CX1UCZsi.js → flowDiagram-OXPTDLAJ-DdStYfx7.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-CFCWgBLl.js → ganttDiagram-R7TSEDQI-DH8CA0Mt.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-BY59AEfH.js → gitGraphDiagram-XJZIOB7I-Ds4256L4.js} +1 -1
  74. package/dist/assets/{import-name-gQROrWbj.js → import-name-CHPmMQSU.js} +1 -1
  75. package/dist/assets/{index-CkdvX5_R.js → index-CFBg45ji.js} +1 -1
  76. package/dist/assets/{index-a4OBw5ZS.js → index-CGhQDBT_.js} +3 -3
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-CiWYCcE-.js → infoDiagram-5W2HQ5XZ-mNLO1zPg.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-DXZKShaj.js → ishikawaDiagram-K3B6WC7H-Daak_Ht_.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-qrPSJHoF.js → journeyDiagram-COXZFDF6-U58GAPno.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-Ch9e9C4r.js → kanban-definition-P3RFRI5V-CcRE6J9f.js} +1 -1
  81. package/dist/assets/{mermaid.core-DQALiqHr.js → mermaid.core-QHRYQaNt.js} +4 -4
  82. package/dist/assets/{mindmap-definition-LZFPQGKD-BirJD4xj.js → mindmap-definition-LZFPQGKD-CEyDomxS.js} +1 -1
  83. package/dist/assets/{minimize-DlAHYBEI.js → minimize-oQ71ZbVB.js} +1 -1
  84. package/dist/assets/{monitor-B-DfxCLW.js → monitor-BmIglcrr.js} +1 -1
  85. package/dist/assets/{new-bot-CAtQzQF1.js → new-bot-tCPJjkMQ.js} +1 -1
  86. package/dist/assets/{org-library-PVNP5n7J.js → org-library-Dr5sX_Fu.js} +1 -1
  87. package/dist/assets/{package-format-xp0kEF1i.js → package-format-heZrOI7V.js} +1 -1
  88. package/dist/assets/{pegDiagram-BGZESJAR-UzkL237f.js → pegDiagram-BGZESJAR-CTxI-cP8.js} +1 -1
  89. package/dist/assets/{pieDiagram-CAPJLFHJ-CPI42dPn.js → pieDiagram-CAPJLFHJ-B8DCNi6O.js} +1 -1
  90. package/dist/assets/{quadrantDiagram-GDMTTRAM-BEcjaKog.js → quadrantDiagram-GDMTTRAM-CWdpAW4W.js} +1 -1
  91. package/dist/assets/{rail-DzsIoRRT.js → rail-WaxapGbo.js} +1 -1
  92. package/dist/assets/{railroadDiagram-SM67HX2B-B0KHoW-7.js → railroadDiagram-SM67HX2B-BCY8OR1i.js} +1 -1
  93. package/dist/assets/{remote-desktop-panel-BtSv4c6E.js → remote-desktop-panel-CRSqL4w9.js} +1 -1
  94. package/dist/assets/{requirementDiagram-X7JNWC4A-BdBqE5oc.js → requirementDiagram-X7JNWC4A-BcX43ufU.js} +1 -1
  95. package/dist/assets/{sankeyDiagram-UM26HJRW-o-m5UnNV.js → sankeyDiagram-UM26HJRW-C3YBTWo7.js} +1 -1
  96. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-CS89JhnM.js → sequenceDiagram-ZO4K6R2Y-CNLzalKN.js} +1 -1
  97. package/dist/assets/{sizeCapture-INFHLROL-u3jsM9rY.js → sizeCapture-INFHLROL-D55E_ZEd.js} +1 -1
  98. package/dist/assets/{stateDiagram-v2-TBUQTH76-ZR8x5js6.js → stateDiagram-v2-TBUQTH76-CRDCsicX.js} +1 -1
  99. package/dist/assets/styles-Cr4TcnLq.css +1 -0
  100. package/dist/assets/{styles-CE92r4H3.js → styles-D7SaLPZf.js} +2 -2
  101. package/dist/assets/{swimlanes-N4OXWK64-CxHXcQ4B.js → swimlanes-N4OXWK64-Ah7OauuN.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-G_1ilp2C.js +8 -0
  103. package/dist/assets/{team-share-DNj2KZjX.js → team-share-D3Hwdncm.js} +1 -1
  104. package/dist/assets/{timeline-definition-YOQAKGHF-Bhgot_xM.js → timeline-definition-YOQAKGHF-DV-V6CCB.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-C4T3EUA4.js → usecaseDiagram-VIAY4XPW-T9J5Wpir.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-B1Z8NDj7.js → vennDiagram-BLWOH2XV-RqJjHEmQ.js} +1 -1
  107. package/dist/assets/{vi-DltOYiYl.js → vi-Bu86KxVI.js} +1 -1
  108. package/dist/assets/{wardleyDiagram-YMQ3BMBF-D3gNVcd7.js → wardleyDiagram-YMQ3BMBF-xZxQC8Rt.js} +1 -1
  109. package/dist/assets/{xychartDiagram-TAQBALBS-CM-Am2Dc.js → xychartDiagram-TAQBALBS-BgPG2lil.js} +1 -1
  110. package/dist/index.html +3 -3
  111. package/dist/rail.html +5 -5
  112. package/dist-server/package.json +1 -1
  113. package/package.json +1 -1
  114. package/dist/assets/BotSettingsDialog-BGO7s2Sa.js +0 -16
  115. package/dist/assets/BrowserPanel-WFfhXRW4.js +0 -3
  116. package/dist/assets/channel-N74fzi1P.js +0 -1
  117. package/dist/assets/styles-_tGCSCNl.css +0 -1
  118. package/dist/assets/swimlanesDiagram-K3J5GTZL-DJxa56rP.js +0 -8
@@ -1,4 +1,4 @@
1
- import{p as Mt}from"./chunk-JWPE2WC7-DKZW0s8n.js";import{s as Nt,g as Tt,x as zt,v as Lt,a as At,b as Xt,_ as u,V as Et,O as Yt,Q as U,l as K,T as It,d as Bt,D as Ft,c as V}from"./mermaid.core-DQALiqHr.js";import{p as Ot}from"./cynefin-EF2NZ3EQ-B3XBpINL.js";import"./styles-CE92r4H3.js";import"./step-CkmJJ7wq.js";var G=u((o,r)=>{const e=o<=1?o*100:o;if(e<0||e>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${o}`);return e},"toPercent"),A=u((o,r,e)=>({x:G(r,`${e} evolution`),y:G(o,`${e} visibility`)}),"toCoordinates"),J=u(o=>{if(o){if(o==="+<>")return"bidirectional";if(o==="+<")return"backward";if(o==="+>")return"forward"}},"getFlowFromPort"),Rt=u(o=>{if(!o?.startsWith("+"))return{};const e=/^\+'([^']*)'/.exec(o)?.[1];return o.includes("<>")?{flow:"bidirectional",label:e}:o.includes("<")?{flow:"backward",label:e}:o.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Wt=u((o,r)=>{if(Mt(o,r),o.size&&r.setSize(o.size.width,o.size.height),o.evolution){const e=o.evolution.stages.map(a=>a.secondName?`${a.name.trim()} / ${a.secondName.trim()}`:a.name.trim()),h=o.evolution.stages.filter(a=>a.boundary!==void 0).map(a=>a.boundary);r.updateAxes({stages:e,stageBoundaries:h})}if(o.anchors.forEach(e=>{const h=A(e.visibility,e.evolution,`Anchor "${e.name}"`);r.addNode(e.name,e.name,h.x,h.y,"anchor")}),o.components.forEach(e=>{const h=A(e.visibility,e.evolution,`Component "${e.name}"`),a=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,d=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,w=e.decorator?.strategy;r.addNode(e.name,e.name,h.x,h.y,"component",a,d,e.inertia,w)}),o.notes.forEach(e=>{const h=A(e.visibility,e.evolution,`Note "${e.text}"`);r.addNote(e.text,h.x,h.y)}),o.pipelines.forEach(e=>{const h=r.getNode(e.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);const a=h.y;r.startPipeline(e.parent),e.components.forEach(d=>{const w=`${e.parent}_${d.name}`,C=d.label?(d.label.negX?-1:1)*d.label.offsetX:void 0,g=d.label?(d.label.negY?-1:1)*d.label.offsetY:void 0,O=G(d.evolution,`Pipeline component "${d.name}" evolution`);r.addNode(w,d.name,O,a,"pipeline-component",C,g),r.addPipelineComponent(e.parent,w)})}),o.links.forEach(e=>{const h=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-."));let a=J(e.fromPort)??J(e.toPort);const{flow:d,label:w}=Rt(e.arrow);!a&&d&&(a=d);const C=e.linkLabel,g=w??C;r.addLink(r.resolveNodeId(e.from),r.resolveNodeId(e.to),h,g,a)}),o.evolves.forEach(e=>{const h=r.getNode(e.component);if(h?.y!==void 0){const a=G(e.target,`Evolve target for "${e.component}"`);r.addTrend(e.component,a,h.y)}}),o.annotations.length>0){const e=o.annotations[0],h=A(e.x,e.y,"Annotations box");r.setAnnotationsBox(h.x,h.y)}o.annotation.forEach(e=>{const h=A(e.x,e.y,`Annotation ${e.number}`);r.addAnnotation(e.number,[{x:h.x,y:h.y}],e.text)}),o.accelerators.forEach(e=>{const h=A(e.x,e.y,`Accelerator "${e.name}"`);r.addAccelerator(e.name,h.x,h.y)}),o.deaccelerators.forEach(e=>{const h=A(e.x,e.y,`Deaccelerator "${e.name}"`);r.addDeaccelerator(e.name,h.x,h.y)})},"populateDb"),tt={parser:{yy:void 0},parse:u(async o=>{const r=await Ot("wardley",o);K.debug(r);const e=tt.parser?.yy;if(!e||typeof e.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Wt(r,e)},"parse")},E,Dt=(E=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(r){const e=this.nodes.get(r.id)??{id:r.id,label:r.label},h={...e,...r,className:r.className??e.className,labelOffsetX:r.labelOffsetX??e.labelOffsetX,labelOffsetY:r.labelOffsetY??e.labelOffsetY};this.nodes.set(r.id,h)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});const e=this.nodes.get(r);e&&(e.isPipelineParent=!0)}addPipelineComponent(r,e){const h=this.pipelines.get(r);h&&h.componentIds.push(e);const a=this.nodes.get(e);a&&(a.inPipeline=!0)}addAnnotation(r){this.annotations.push(r)}addNote(r){this.notes.push(r)}addAccelerator(r){this.accelerators.push(r)}addDeaccelerator(r){this.deaccelerators.push(r)}setAnnotationsBox(r,e){this.annotationsBox={x:r,y:e}}setAxes(r){this.axes={...this.axes,...r}}setSize(r,e){this.size={width:r,height:e}}getNode(r){return this.nodes.get(r)}resolveNodeId(r){if(this.nodes.has(r))return r;for(const[e,h]of this.nodes)if(h.label===r)return e;return r}build(){const r=[];for(const e of this.nodes.values()){if(typeof e.x!="number"||typeof e.y!="number")throw new Error(`Node "${e.label}" is missing coordinates`);r.push(e)}return{nodes:r,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},u(E,"WardleyBuilder"),E),k=new Dt;function et(){return V()["wardley-beta"]}u(et,"getConfig");function at(o,r,e,h,a,d,w,C,g){k.addNode({id:o,label:r,x:e,y:h,className:a,labelOffsetX:d,labelOffsetY:w,inertia:C,sourceStrategy:g})}u(at,"addNode");function rt(o,r,e=!1,h,a){k.addLink({source:o,target:r,dashed:e,label:h,flow:a})}u(rt,"addLink");function ot(o,r,e){k.addTrend({nodeId:o,targetX:r,targetY:e})}u(ot,"addTrend");function nt(o,r,e){k.addAnnotation({number:o,coordinates:r,text:e})}u(nt,"addAnnotation");function st(o,r,e){k.addNote({text:o,x:r,y:e})}u(st,"addNote");function it(o,r,e){k.addAccelerator({name:o,x:r,y:e})}u(it,"addAccelerator");function dt(o,r,e){k.addDeaccelerator({name:o,x:r,y:e})}u(dt,"addDeaccelerator");function lt(o,r){k.setAnnotationsBox(o,r)}u(lt,"setAnnotationsBox");function ct(o,r){k.setSize(o,r)}u(ct,"setSize");function pt(o){k.startPipeline(o)}u(pt,"startPipeline");function ft(o,r){k.addPipelineComponent(o,r)}u(ft,"addPipelineComponent");function ht(o){k.setAxes(o)}u(ht,"updateAxes");function xt(o){return k.getNode(o)}u(xt,"getNode");function gt(o){return k.resolveNodeId(o)}u(gt,"resolveNodeId");function yt(){return k.build()}u(yt,"getWardleyData");function ut(){k.clear(),Ft()}u(ut,"clear");var Gt={getConfig:et,addNode:at,addLink:rt,addTrend:ot,addAnnotation:nt,addNote:st,addAccelerator:it,addDeaccelerator:dt,setAnnotationsBox:lt,setSize:ct,startPipeline:pt,addPipelineComponent:ft,updateAxes:ht,getNode:xt,resolveNodeId:gt,getWardleyData:yt,clear:ut,setAccTitle:Xt,getAccTitle:At,setDiagramTitle:Lt,getDiagramTitle:zt,getAccDescription:Tt,setAccDescription:Nt},qt=["Genesis","Custom Built","Product","Commodity"],Ht=u(()=>{const{themeVariables:o}=V();return{backgroundColor:o.wardley?.backgroundColor??o.background??"#fff",axisColor:o.wardley?.axisColor??"#000",axisTextColor:o.wardley?.axisTextColor??o.primaryTextColor??"#222",gridColor:o.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:o.wardley?.componentFill??"#fff",componentStroke:o.wardley?.componentStroke??"#000",componentLabelColor:o.wardley?.componentLabelColor??o.primaryTextColor??"#222",linkStroke:o.wardley?.linkStroke??"#000",evolutionStroke:o.wardley?.evolutionStroke??"#dc3545",annotationStroke:o.wardley?.annotationStroke??"#000",annotationTextColor:o.wardley?.annotationTextColor??o.primaryTextColor??"#222",annotationFill:o.wardley?.annotationFill??o.background??"#fff"}},"getTheme"),jt=u(()=>{const o=V()["wardley-beta"];return{width:o?.width??900,height:o?.height??600,padding:o?.padding??48,nodeRadius:o?.nodeRadius??6,nodeLabelOffset:o?.nodeLabelOffset??8,axisFontSize:o?.axisFontSize??12,labelFontSize:o?.labelFontSize??10,showGrid:o?.showGrid??!1,useMaxWidth:o?.useMaxWidth??!0}},"getConfigValues"),Vt=u((o,r,e,h)=>{K.debug(`Rendering Wardley map
1
+ import{p as Mt}from"./chunk-JWPE2WC7-DaZro178.js";import{s as Nt,g as Tt,x as zt,v as Lt,a as At,b as Xt,_ as u,V as Et,O as Yt,Q as U,l as K,T as It,d as Bt,D as Ft,c as V}from"./mermaid.core-QHRYQaNt.js";import{p as Ot}from"./cynefin-EF2NZ3EQ-BoirpSv2.js";import"./styles-D7SaLPZf.js";import"./step-CkmJJ7wq.js";var G=u((o,r)=>{const e=o<=1?o*100:o;if(e<0||e>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${o}`);return e},"toPercent"),A=u((o,r,e)=>({x:G(r,`${e} evolution`),y:G(o,`${e} visibility`)}),"toCoordinates"),J=u(o=>{if(o){if(o==="+<>")return"bidirectional";if(o==="+<")return"backward";if(o==="+>")return"forward"}},"getFlowFromPort"),Rt=u(o=>{if(!o?.startsWith("+"))return{};const e=/^\+'([^']*)'/.exec(o)?.[1];return o.includes("<>")?{flow:"bidirectional",label:e}:o.includes("<")?{flow:"backward",label:e}:o.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Wt=u((o,r)=>{if(Mt(o,r),o.size&&r.setSize(o.size.width,o.size.height),o.evolution){const e=o.evolution.stages.map(a=>a.secondName?`${a.name.trim()} / ${a.secondName.trim()}`:a.name.trim()),h=o.evolution.stages.filter(a=>a.boundary!==void 0).map(a=>a.boundary);r.updateAxes({stages:e,stageBoundaries:h})}if(o.anchors.forEach(e=>{const h=A(e.visibility,e.evolution,`Anchor "${e.name}"`);r.addNode(e.name,e.name,h.x,h.y,"anchor")}),o.components.forEach(e=>{const h=A(e.visibility,e.evolution,`Component "${e.name}"`),a=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,d=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,w=e.decorator?.strategy;r.addNode(e.name,e.name,h.x,h.y,"component",a,d,e.inertia,w)}),o.notes.forEach(e=>{const h=A(e.visibility,e.evolution,`Note "${e.text}"`);r.addNote(e.text,h.x,h.y)}),o.pipelines.forEach(e=>{const h=r.getNode(e.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);const a=h.y;r.startPipeline(e.parent),e.components.forEach(d=>{const w=`${e.parent}_${d.name}`,C=d.label?(d.label.negX?-1:1)*d.label.offsetX:void 0,g=d.label?(d.label.negY?-1:1)*d.label.offsetY:void 0,O=G(d.evolution,`Pipeline component "${d.name}" evolution`);r.addNode(w,d.name,O,a,"pipeline-component",C,g),r.addPipelineComponent(e.parent,w)})}),o.links.forEach(e=>{const h=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-."));let a=J(e.fromPort)??J(e.toPort);const{flow:d,label:w}=Rt(e.arrow);!a&&d&&(a=d);const C=e.linkLabel,g=w??C;r.addLink(r.resolveNodeId(e.from),r.resolveNodeId(e.to),h,g,a)}),o.evolves.forEach(e=>{const h=r.getNode(e.component);if(h?.y!==void 0){const a=G(e.target,`Evolve target for "${e.component}"`);r.addTrend(e.component,a,h.y)}}),o.annotations.length>0){const e=o.annotations[0],h=A(e.x,e.y,"Annotations box");r.setAnnotationsBox(h.x,h.y)}o.annotation.forEach(e=>{const h=A(e.x,e.y,`Annotation ${e.number}`);r.addAnnotation(e.number,[{x:h.x,y:h.y}],e.text)}),o.accelerators.forEach(e=>{const h=A(e.x,e.y,`Accelerator "${e.name}"`);r.addAccelerator(e.name,h.x,h.y)}),o.deaccelerators.forEach(e=>{const h=A(e.x,e.y,`Deaccelerator "${e.name}"`);r.addDeaccelerator(e.name,h.x,h.y)})},"populateDb"),tt={parser:{yy:void 0},parse:u(async o=>{const r=await Ot("wardley",o);K.debug(r);const e=tt.parser?.yy;if(!e||typeof e.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Wt(r,e)},"parse")},E,Dt=(E=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(r){const e=this.nodes.get(r.id)??{id:r.id,label:r.label},h={...e,...r,className:r.className??e.className,labelOffsetX:r.labelOffsetX??e.labelOffsetX,labelOffsetY:r.labelOffsetY??e.labelOffsetY};this.nodes.set(r.id,h)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});const e=this.nodes.get(r);e&&(e.isPipelineParent=!0)}addPipelineComponent(r,e){const h=this.pipelines.get(r);h&&h.componentIds.push(e);const a=this.nodes.get(e);a&&(a.inPipeline=!0)}addAnnotation(r){this.annotations.push(r)}addNote(r){this.notes.push(r)}addAccelerator(r){this.accelerators.push(r)}addDeaccelerator(r){this.deaccelerators.push(r)}setAnnotationsBox(r,e){this.annotationsBox={x:r,y:e}}setAxes(r){this.axes={...this.axes,...r}}setSize(r,e){this.size={width:r,height:e}}getNode(r){return this.nodes.get(r)}resolveNodeId(r){if(this.nodes.has(r))return r;for(const[e,h]of this.nodes)if(h.label===r)return e;return r}build(){const r=[];for(const e of this.nodes.values()){if(typeof e.x!="number"||typeof e.y!="number")throw new Error(`Node "${e.label}" is missing coordinates`);r.push(e)}return{nodes:r,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},u(E,"WardleyBuilder"),E),k=new Dt;function et(){return V()["wardley-beta"]}u(et,"getConfig");function at(o,r,e,h,a,d,w,C,g){k.addNode({id:o,label:r,x:e,y:h,className:a,labelOffsetX:d,labelOffsetY:w,inertia:C,sourceStrategy:g})}u(at,"addNode");function rt(o,r,e=!1,h,a){k.addLink({source:o,target:r,dashed:e,label:h,flow:a})}u(rt,"addLink");function ot(o,r,e){k.addTrend({nodeId:o,targetX:r,targetY:e})}u(ot,"addTrend");function nt(o,r,e){k.addAnnotation({number:o,coordinates:r,text:e})}u(nt,"addAnnotation");function st(o,r,e){k.addNote({text:o,x:r,y:e})}u(st,"addNote");function it(o,r,e){k.addAccelerator({name:o,x:r,y:e})}u(it,"addAccelerator");function dt(o,r,e){k.addDeaccelerator({name:o,x:r,y:e})}u(dt,"addDeaccelerator");function lt(o,r){k.setAnnotationsBox(o,r)}u(lt,"setAnnotationsBox");function ct(o,r){k.setSize(o,r)}u(ct,"setSize");function pt(o){k.startPipeline(o)}u(pt,"startPipeline");function ft(o,r){k.addPipelineComponent(o,r)}u(ft,"addPipelineComponent");function ht(o){k.setAxes(o)}u(ht,"updateAxes");function xt(o){return k.getNode(o)}u(xt,"getNode");function gt(o){return k.resolveNodeId(o)}u(gt,"resolveNodeId");function yt(){return k.build()}u(yt,"getWardleyData");function ut(){k.clear(),Ft()}u(ut,"clear");var Gt={getConfig:et,addNode:at,addLink:rt,addTrend:ot,addAnnotation:nt,addNote:st,addAccelerator:it,addDeaccelerator:dt,setAnnotationsBox:lt,setSize:ct,startPipeline:pt,addPipelineComponent:ft,updateAxes:ht,getNode:xt,resolveNodeId:gt,getWardleyData:yt,clear:ut,setAccTitle:Xt,getAccTitle:At,setDiagramTitle:Lt,getDiagramTitle:zt,getAccDescription:Tt,setAccDescription:Nt},qt=["Genesis","Custom Built","Product","Commodity"],Ht=u(()=>{const{themeVariables:o}=V();return{backgroundColor:o.wardley?.backgroundColor??o.background??"#fff",axisColor:o.wardley?.axisColor??"#000",axisTextColor:o.wardley?.axisTextColor??o.primaryTextColor??"#222",gridColor:o.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:o.wardley?.componentFill??"#fff",componentStroke:o.wardley?.componentStroke??"#000",componentLabelColor:o.wardley?.componentLabelColor??o.primaryTextColor??"#222",linkStroke:o.wardley?.linkStroke??"#000",evolutionStroke:o.wardley?.evolutionStroke??"#dc3545",annotationStroke:o.wardley?.annotationStroke??"#000",annotationTextColor:o.wardley?.annotationTextColor??o.primaryTextColor??"#222",annotationFill:o.wardley?.annotationFill??o.background??"#fff"}},"getTheme"),jt=u(()=>{const o=V()["wardley-beta"];return{width:o?.width??900,height:o?.height??600,padding:o?.padding??48,nodeRadius:o?.nodeRadius??6,nodeLabelOffset:o?.nodeLabelOffset??8,axisFontSize:o?.axisFontSize??12,labelFontSize:o?.labelFontSize??10,showGrid:o?.showGrid??!1,useMaxWidth:o?.useMaxWidth??!0}},"getConfigValues"),Vt=u((o,r,e,h)=>{K.debug(`Rendering Wardley map
2
2
  `+o);const a=jt(),d=Ht(),w=a.nodeRadius*1.6,C=h.db,g=C.getWardleyData(),O=C.getDiagramTitle(),S=g.size?.width??a.width,b=g.size?.height??a.height,Y=It(r);Y.selectAll("*").remove(),Bt(Y,b,S,a.useMaxWidth),Y.attr("viewBox",`0 0 ${S} ${b}`);const v=Y.append("g").attr("class","wardley-map"),q=Y.append("defs");q.append("marker").attr("id",`arrow-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.evolutionStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-end-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.linkStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-start-${r}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",d.linkStroke).attr("stroke","none"),v.append("rect").attr("class","wardley-background").attr("width",S).attr("height",b).attr("fill",d.backgroundColor);const I=S-a.padding*2,B=b-a.padding*2;O&&v.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",a.padding/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(O);const T=u(t=>a.padding+t/100*I,"projectX"),z=u(t=>b-a.padding-t/100*B,"projectY"),R=v.append("g").attr("class","wardley-axes");R.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1),R.append("line").attr("x1",a.padding).attr("x2",a.padding).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1);const wt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";R.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",a.padding+I/2).attr("y",b-a.padding/4).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(wt),R.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",a.padding/3).attr("y",a.padding+B/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${a.padding/3} ${a.padding+B/2})`).text(mt);const F=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:qt;if(F.length>0){const t=v.append("g").attr("class","wardley-stages"),s=g.axes.stageBoundaries,n=[];if(s&&s.length===F.length){let i=0;s.forEach(p=>{n.push({start:i,end:p}),i=p})}else{const i=1/F.length;F.forEach((p,l)=>{n.push({start:l*i,end:(l+1)*i})})}F.forEach((i,p)=>{const l=n[p],f=a.padding+l.start*I,x=a.padding+l.end*I,y=(f+x)/2;p>0&&t.append("line").attr("x1",f).attr("x2",f).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",y).attr("y",b-a.padding/1.5).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(a.showGrid){const t=v.append("g").attr("class","wardley-grid");for(let s=1;s<4;s++){const n=s/4,i=a.padding+I*n;t.append("line").attr("x1",i).attr("x2",i).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding-B*n).attr("y2",b-a.padding-B*n).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6")}}const c=new Map;if(g.nodes.forEach(t=>{c.set(t.id,{x:T(t.x),y:z(t.y),node:t})}),g.pipelines.length>0){const t=v.append("g").attr("class","wardley-pipelines"),s=v.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(n=>{if(n.componentIds.length===0)return;const i=n.componentIds.map(x=>({id:x,pos:c.get(x),node:g.nodes.find(y=>y.id===x)})).filter(x=>x.pos&&x.node).sort((x,y)=>x.node.x-y.node.x);for(let x=0;x<i.length-1;x++){const y=i[x],m=i[x+1];s.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",y.pos.x).attr("y1",y.pos.y).attr("x2",m.pos.x).attr("y2",m.pos.y).attr("stroke",d.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let p=1/0,l=-1/0,f=0;if(n.componentIds.forEach(x=>{const y=c.get(x);y&&(p=Math.min(p,y.x),l=Math.max(l,y.x),f=y.y)}),p!==1/0&&l!==-1/0){const y=a.nodeRadius*4,m=f-y/2,P=c.get(n.nodeId);if(P){const N=(p+l)/2;P.x=N,P.y=m-w/6}t.append("rect").attr("class","wardley-pipeline-box").attr("x",p-15).attr("y",m).attr("width",l-p+30).attr("height",y).attr("fill","none").attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}const _=v.append("g").attr("class","wardley-links"),Z=new Map;g.pipelines.forEach(t=>{Z.set(t.nodeId,new Set(t.componentIds))});const Q=g.links.filter(t=>!(!c.has(t.source)||!c.has(t.target)||Z.get(t.target)?.has(t.source)));_.selectAll("line").data(Q).enter().append("line").attr("class",t=>`wardley-link${t.dashed?" wardley-link--dashed":""}`).attr("x1",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.source).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f);return s.x+l/x*p}).attr("y1",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.source).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f);return s.y+f/x*p}).attr("x2",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.target).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=s.x-n.x,f=s.y-n.y,x=Math.sqrt(l*l+f*f);return n.x+l/x*p}).attr("y2",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.target).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=s.x-n.x,f=s.y-n.y,x=Math.sqrt(l*l+f*f);return n.y+f/x*p}).attr("stroke",d.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",t=>t.dashed?"6 6":null).attr("marker-end",t=>t.flow==="forward"||t.flow==="bidirectional"?`url(#link-arrow-end-${r})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${r})`:null),_.selectAll("text").data(Q.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.x+n.x)/2,p=n.y-s.y,l=n.x-s.x,f=Math.sqrt(l*l+p*p),x=8,y=p/f;return i+y*x}).attr("y",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.y+n.y)/2,p=n.x-s.x,l=n.y-s.y,f=Math.sqrt(p*p+l*l),x=8,y=-p/f;return i+y*x}).attr("fill",d.axisTextColor).attr("font-size",a.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.x+n.x)/2,p=(s.y+n.y)/2,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f),y=8,m=f/x,P=-l/x,N=i+m*y,W=p+P*y;let X=Math.atan2(f,l)*180/Math.PI;return(X>90||X<-90)&&(X+=180),`rotate(${X} ${N} ${W})`}).text(t=>t.label);const kt=v.append("g").attr("class","wardley-trends"),bt=g.trends.map(t=>{const s=c.get(t.nodeId);if(!s)return null;const n=T(t.targetX),i=z(t.targetY),p=n-s.x,l=i-s.y,f=Math.sqrt(p*p+l*l),x=a.nodeRadius+2,y=f>x?n-p/f*x:n,m=f>x?i-l/f*x:i;return{origin:s,targetX:n,targetY:i,adjustedX2:y,adjustedY2:m}}).filter(t=>t!==null);kt.selectAll("line").data(bt).enter().append("line").attr("class","wardley-trend").attr("x1",t=>t.origin.x).attr("y1",t=>t.origin.y).attr("x2",t=>t.adjustedX2).attr("y2",t=>t.adjustedY2).attr("stroke",d.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${r})`);const M=v.append("g").attr("class","wardley-nodes").selectAll("g").data(g.nodes).enter().append("g").attr("class",t=>["wardley-node",t.className?`wardley-node--${t.className}`:""].filter(Boolean).join(" "));M.filter(t=>t.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#666").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#ccc").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);const L=M.filter(t=>t.sourceStrategy==="market");L.append("circle").attr("class","wardley-market-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>!t.isPipelineParent&&t.sourceStrategy!=="market"&&t.className!=="anchor").append("circle").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius).attr("fill",d.componentFill).attr("stroke",d.componentStroke).attr("stroke-width",1);const H=a.nodeRadius*.7,$=a.nodeRadius*1.2;if(L.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x).attr("y1",t=>c.get(t.id).y-$).attr("x2",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",d.componentStroke).attr("stroke-width",1),L.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",d.componentStroke).attr("stroke-width",1),L.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x).attr("y2",t=>c.get(t.id).y-$).attr("stroke",d.componentStroke).attr("stroke-width",1),L.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y-$).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),L.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),L.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),M.filter(t=>t.isPipelineParent===!0).append("rect").attr("x",t=>c.get(t.id).x-w/2).attr("y",t=>c.get(t.id).y-w/2).attr("width",w).attr("height",w).attr("fill",d.componentFill).attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",t=>{const s=c.get(t.id);let n=t.isPipelineParent?w/2+15:a.nodeRadius+15;return t.sourceStrategy&&(n+=a.nodeRadius+10),s.x+n}).attr("y1",t=>{const s=c.get(t.id),n=t.isPipelineParent?w:a.nodeRadius*2;return s.y-n/2}).attr("x2",t=>{const s=c.get(t.id);let n=t.isPipelineParent?w/2+15:a.nodeRadius+15;return t.sourceStrategy&&(n+=a.nodeRadius+10),s.x+n}).attr("y2",t=>{const s=c.get(t.id),n=t.isPipelineParent?w:a.nodeRadius*2;return s.y+n/2}).attr("stroke",d.componentStroke).attr("stroke-width",6),M.append("text").attr("x",t=>{const s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?s.x+t.labelOffsetX:s.x;let n=a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(n+=10);const i=t.labelOffsetX??n;return s.x+i}).attr("y",t=>{const s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?s.y+t.labelOffsetY:s.y-3;let n=-a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(n-=10);const i=t.labelOffsetY??n;return s.y+i}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?d.evolutionStroke:t.className==="anchor"?"#000":d.componentLabelColor).attr("font-size",a.labelFontSize).attr("font-weight",t=>t.className==="anchor"?"bold":"normal").attr("text-anchor",t=>t.className==="anchor"?"middle":"start").attr("dominant-baseline",t=>t.className==="anchor"?"middle":"auto").text(t=>t.label),g.annotations.length>0){const t=v.append("g").attr("class","wardley-annotations");if(g.annotations.forEach(s=>{const n=s.coordinates.map(i=>({x:T(i.x),y:z(i.y)}));if(n.length>1)for(let i=0;i<n.length-1;i++)t.append("line").attr("class","wardley-annotation-line").attr("x1",n[i].x).attr("y1",n[i].y).attr("x2",n[i+1].x).attr("y2",n[i+1].y).attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");n.forEach(i=>{const p=t.append("g").attr("class","wardley-annotation");p.append("circle").attr("cx",i.x).attr("cy",i.y).attr("r",10).attr("fill","white").attr("stroke",d.axisColor).attr("stroke-width",1.5),p.append("text").attr("x",i.x).attr("y",i.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.number)})}),g.annotationsBox){let s=T(g.annotationsBox.x),n=z(g.annotationsBox.y);const i=10,p=16,l=11,f=t.append("g").attr("class","wardley-annotations-box"),x=[...g.annotations].filter(m=>m.text).sort((m,P)=>m.number-P.number),y=[];if(x.forEach((m,P)=>{const N=f.append("text").attr("x",s+i).attr("y",n+i+(P+1)*p).attr("font-size",l).attr("fill",d.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${m.number}. ${m.text}`);y.push(N)}),y.length>0){let m=0,P=0;y.forEach(j=>{const D=j.node(),Ct=D.getComputedTextLength();m=Math.max(m,Ct);const St=D.getBBox();P=Math.max(P,St.height)});const N=m+i*2+105,W=x.length*p+i*2+P/2,X=a.padding,$t=S-a.padding-N,vt=a.padding,Pt=b-a.padding-W;s=Math.max(X,Math.min(s,$t)),n=Math.max(vt,Math.min(n,Pt)),y.forEach((j,D)=>{j.attr("x",s+i).attr("y",n+i+(D+1)*p)}),f.insert("rect","text").attr("x",s).attr("y",n).attr("width",N).attr("height",W).attr("fill","white").attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(g.notes.length>0){const t=v.append("g").attr("class","wardley-notes");g.notes.forEach(s=>{const n=T(s.x),i=z(s.y);t.append("text").attr("x",n).attr("y",i).attr("text-anchor","start").attr("font-size",11).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.text)})}if(g.accelerators.length>0){const t=v.append("g").attr("class","wardley-accelerators");g.accelerators.forEach(s=>{const n=T(s.x),i=z(s.y),p=60,l=30,f=20,x=`
3
3
  M ${n} ${i-l/2}
4
4
  L ${n+p-f} ${i-l/2}
@@ -1,4 +1,4 @@
1
- import{s as pi,g as mi,x as $t,v as yi,a as bi,b as wi,_ as a,l as Ut,T as Ai,d as Ci,D as Si,O as Dt,j as Ri,Q as Gt,R as _i,V as ki,au as Ti}from"./mermaid.core-DQALiqHr.js";import{i as Di}from"./init-Dmth1JHB.js";import{o as Pi}from"./ordinal-BeghXfj9.js";import{r as vi}from"./range-OtVwhkKS.js";import{l as Xt}from"./linear-ChbPfC31.js";import{l as Yt}from"./step-CkmJJ7wq.js";import"./styles-CE92r4H3.js";import"./defaultLocale-CzDG__Ur.js";function St(){var e=Pi().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,l,p=!1,d=0,u=0,b=.5;delete e.unknown;function A(){var m=t().length,E=n<s,v=E?n:s,L=E?s:n;o=(L-v)/Math.max(1,m-d+u*2),p&&(o=Math.floor(o)),v+=(L-v-o*(m-d))*b,l=o*(1-d),p&&(v=Math.round(v),l=Math.round(l));var M=vi(m).map(function(w){return v+o*w});return i(E?M.reverse():M)}return e.domain=function(m){return arguments.length?(t(m),A()):t()},e.range=function(m){return arguments.length?([s,n]=m,s=+s,n=+n,A()):[s,n]},e.rangeRound=function(m){return[s,n]=m,s=+s,n=+n,p=!0,A()},e.bandwidth=function(){return l},e.step=function(){return o},e.round=function(m){return arguments.length?(p=!!m,A()):p},e.padding=function(m){return arguments.length?(d=Math.min(1,u=+m),A()):d},e.paddingInner=function(m){return arguments.length?(d=Math.min(1,m),A()):d},e.paddingOuter=function(m){return arguments.length?(u=+m,A()):u},e.align=function(m){return arguments.length?(b=Math.max(0,Math.min(1,m)),A()):b},e.copy=function(){return St(t(),[s,n]).round(p).paddingInner(d).paddingOuter(u).align(b)},Di.apply(A(),arguments)}var Rt=(function(){var e=a(function(F,h,g,x){for(g=g||{},x=F.length;x--;g[F[x]]=h);return g},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],l=[1,7],p=[1,5,10,12,14,16,18,19,21,23,36,37,38],d=[1,25],u=[1,26],b=[1,28],A=[1,29],m=[1,30],E=[1,31],v=[1,32],L=[1,33],M=[1,34],w=[1,35],D=[1,36],c=[1,37],B=[1,43],W=[1,42],X=[1,47],Y=[1,50],k=[1,10,12,14,16,18,19,21,23,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],S=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],R=[1,65],O=[26,28],T={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:a(function(h,g,x,f,_,r,lt){var y=r.length-1;switch(_){case 5:f.setOrientation(r[y]);break;case 9:f.setDiagramTitle(r[y].text.trim());break;case 12:f.setLineData({text:"",type:"text"},r[y]);break;case 13:f.setLineData(r[y-1],r[y]);break;case 14:f.setBarData({text:"",type:"text"},r[y]);break;case 15:f.setBarData(r[y-1],r[y]);break;case 16:this.$=r[y].trim(),f.setAccTitle(this.$);break;case 17:case 18:this.$=r[y].trim(),f.setAccDescription(this.$);break;case 19:this.$=r[y-1];break;case 20:case 30:this.$=[r[y-2],...r[y]];break;case 21:case 31:this.$=[r[y]];break;case 22:this.$={value:Number(r[y-1]),label:r[y]};break;case 23:this.$={value:Number(r[y]),label:""};break;case 24:f.setXAxisTitle(r[y]);break;case 25:f.setXAxisTitle(r[y-1]);break;case 26:f.setXAxisTitle({type:"text",text:""});break;case 27:f.setXAxisBand(r[y]);break;case 28:f.setXAxisRangeData(Number(r[y-2]),Number(r[y]));break;case 29:this.$=r[y-1];break;case 32:f.setYAxisTitle(r[y]);break;case 33:f.setYAxisTitle(r[y-1]);break;case 34:f.setYAxisTitle({type:"text",text:""});break;case 35:f.setYAxisRangeData(Number(r[y-2]),Number(r[y]));break;case 39:this.$={text:r[y],type:"text"};break;case 40:this.$={text:r[y],type:"text"};break;case 41:this.$={text:r[y],type:"markdown"};break;case 42:this.$=r[y];break;case 43:this.$=r[y-1]+""+r[y];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:n,37:o,38:l}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:n,37:o,38:l}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:n,37:o,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,36]),e(p,[2,37]),e(p,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:n,37:o,38:l}),{1:[2,3]},e(p,[2,5]),e(t,[2,7],{4:22,36:n,37:o,38:l}),{11:23,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:39,13:38,24:B,29:W,30:d,31:40,32:41,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:45,15:44,29:X,30:d,35:46,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:49,17:48,24:Y,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:52,17:51,24:Y,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{20:[1,53]},{22:[1,54]},e(k,[2,18]),{1:[2,2]},e(k,[2,8]),e(k,[2,9]),e(H,[2,39],{41:55,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c}),e(H,[2,40]),e(H,[2,41]),e(S,[2,42]),e(S,[2,44]),e(S,[2,45]),e(S,[2,46]),e(S,[2,47]),e(S,[2,48]),e(S,[2,49]),e(S,[2,50]),e(S,[2,51]),e(S,[2,52]),e(S,[2,53]),e(k,[2,10]),e(k,[2,24],{32:41,31:56,24:B,29:W}),e(k,[2,26]),e(k,[2,27]),{33:[1,57]},{11:59,30:d,34:58,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},e(k,[2,11]),e(k,[2,32],{35:60,29:X}),e(k,[2,34]),{33:[1,61]},e(k,[2,12]),{17:62,24:Y},{25:63,27:64,29:R},e(k,[2,14]),{17:66,24:Y},e(k,[2,16]),e(k,[2,17]),e(S,[2,43]),e(k,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(k,[2,33]),{29:[1,70]},e(k,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(O,[2,23],{30:[1,73]}),e(k,[2,15]),e(k,[2,28]),e(k,[2,29]),{11:59,30:d,34:74,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},e(k,[2,35]),e(k,[2,19]),{25:75,27:64,29:R},e(O,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:a(function(h,g){if(g.recoverable)this.trace(h);else{var x=new Error(h);throw x.hash=g,x}},"parseError"),parse:a(function(h){var g=this,x=[0],f=[],_=[null],r=[],lt=this.table,y="",dt=0,Ot=0,ui=2,Vt=1,di=r.slice.call(arguments,1),P=Object.create(this.lexer),$={yy:{}};for(var bt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,bt)&&($.yy[bt]=this.yy[bt]);P.setInput(h,$.yy),$.yy.lexer=P,$.yy.parser=this,typeof P.yylloc>"u"&&(P.yylloc={});var wt=P.yylloc;r.push(wt);var xi=P.options&&P.options.ranges;typeof $.yy.parseError=="function"?this.parseError=$.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function fi(z){x.length=x.length-2*z,_.length=_.length-z,r.length=r.length-z}a(fi,"popStack");function Wt(){var z;return z=f.pop()||P.lex()||Vt,typeof z!="number"&&(z instanceof Array&&(f=z,z=f.pop()),z=g.symbols_[z]||z),z}a(Wt,"lex");for(var I,U,V,At,j={},xt,N,Ft,ft;;){if(U=x[x.length-1],this.defaultActions[U]?V=this.defaultActions[U]:((I===null||typeof I>"u")&&(I=Wt()),V=lt[U]&&lt[U][I]),typeof V>"u"||!V.length||!V[0]){var Ct="";ft=[];for(xt in lt[U])this.terminals_[xt]&&xt>ui&&ft.push("'"+this.terminals_[xt]+"'");P.showPosition?Ct="Parse error on line "+(dt+1)+`:
1
+ import{s as pi,g as mi,x as $t,v as yi,a as bi,b as wi,_ as a,l as Ut,T as Ai,d as Ci,D as Si,O as Dt,j as Ri,Q as Gt,R as _i,V as ki,au as Ti}from"./mermaid.core-QHRYQaNt.js";import{i as Di}from"./init-Dmth1JHB.js";import{o as Pi}from"./ordinal-BeghXfj9.js";import{r as vi}from"./range-OtVwhkKS.js";import{l as Xt}from"./linear-ChbPfC31.js";import{l as Yt}from"./step-CkmJJ7wq.js";import"./styles-D7SaLPZf.js";import"./defaultLocale-CzDG__Ur.js";function St(){var e=Pi().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,l,p=!1,d=0,u=0,b=.5;delete e.unknown;function A(){var m=t().length,E=n<s,v=E?n:s,L=E?s:n;o=(L-v)/Math.max(1,m-d+u*2),p&&(o=Math.floor(o)),v+=(L-v-o*(m-d))*b,l=o*(1-d),p&&(v=Math.round(v),l=Math.round(l));var M=vi(m).map(function(w){return v+o*w});return i(E?M.reverse():M)}return e.domain=function(m){return arguments.length?(t(m),A()):t()},e.range=function(m){return arguments.length?([s,n]=m,s=+s,n=+n,A()):[s,n]},e.rangeRound=function(m){return[s,n]=m,s=+s,n=+n,p=!0,A()},e.bandwidth=function(){return l},e.step=function(){return o},e.round=function(m){return arguments.length?(p=!!m,A()):p},e.padding=function(m){return arguments.length?(d=Math.min(1,u=+m),A()):d},e.paddingInner=function(m){return arguments.length?(d=Math.min(1,m),A()):d},e.paddingOuter=function(m){return arguments.length?(u=+m,A()):u},e.align=function(m){return arguments.length?(b=Math.max(0,Math.min(1,m)),A()):b},e.copy=function(){return St(t(),[s,n]).round(p).paddingInner(d).paddingOuter(u).align(b)},Di.apply(A(),arguments)}var Rt=(function(){var e=a(function(F,h,g,x){for(g=g||{},x=F.length;x--;g[F[x]]=h);return g},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],l=[1,7],p=[1,5,10,12,14,16,18,19,21,23,36,37,38],d=[1,25],u=[1,26],b=[1,28],A=[1,29],m=[1,30],E=[1,31],v=[1,32],L=[1,33],M=[1,34],w=[1,35],D=[1,36],c=[1,37],B=[1,43],W=[1,42],X=[1,47],Y=[1,50],k=[1,10,12,14,16,18,19,21,23,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],S=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],R=[1,65],O=[26,28],T={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:a(function(h,g,x,f,_,r,lt){var y=r.length-1;switch(_){case 5:f.setOrientation(r[y]);break;case 9:f.setDiagramTitle(r[y].text.trim());break;case 12:f.setLineData({text:"",type:"text"},r[y]);break;case 13:f.setLineData(r[y-1],r[y]);break;case 14:f.setBarData({text:"",type:"text"},r[y]);break;case 15:f.setBarData(r[y-1],r[y]);break;case 16:this.$=r[y].trim(),f.setAccTitle(this.$);break;case 17:case 18:this.$=r[y].trim(),f.setAccDescription(this.$);break;case 19:this.$=r[y-1];break;case 20:case 30:this.$=[r[y-2],...r[y]];break;case 21:case 31:this.$=[r[y]];break;case 22:this.$={value:Number(r[y-1]),label:r[y]};break;case 23:this.$={value:Number(r[y]),label:""};break;case 24:f.setXAxisTitle(r[y]);break;case 25:f.setXAxisTitle(r[y-1]);break;case 26:f.setXAxisTitle({type:"text",text:""});break;case 27:f.setXAxisBand(r[y]);break;case 28:f.setXAxisRangeData(Number(r[y-2]),Number(r[y]));break;case 29:this.$=r[y-1];break;case 32:f.setYAxisTitle(r[y]);break;case 33:f.setYAxisTitle(r[y-1]);break;case 34:f.setYAxisTitle({type:"text",text:""});break;case 35:f.setYAxisRangeData(Number(r[y-2]),Number(r[y]));break;case 39:this.$={text:r[y],type:"text"};break;case 40:this.$={text:r[y],type:"text"};break;case 41:this.$={text:r[y],type:"markdown"};break;case 42:this.$=r[y];break;case 43:this.$=r[y-1]+""+r[y];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:n,37:o,38:l}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:n,37:o,38:l}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:n,37:o,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,36]),e(p,[2,37]),e(p,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:n,37:o,38:l}),{1:[2,3]},e(p,[2,5]),e(t,[2,7],{4:22,36:n,37:o,38:l}),{11:23,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:39,13:38,24:B,29:W,30:d,31:40,32:41,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:45,15:44,29:X,30:d,35:46,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:49,17:48,24:Y,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{11:52,17:51,24:Y,30:d,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},{20:[1,53]},{22:[1,54]},e(k,[2,18]),{1:[2,2]},e(k,[2,8]),e(k,[2,9]),e(H,[2,39],{41:55,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c}),e(H,[2,40]),e(H,[2,41]),e(S,[2,42]),e(S,[2,44]),e(S,[2,45]),e(S,[2,46]),e(S,[2,47]),e(S,[2,48]),e(S,[2,49]),e(S,[2,50]),e(S,[2,51]),e(S,[2,52]),e(S,[2,53]),e(k,[2,10]),e(k,[2,24],{32:41,31:56,24:B,29:W}),e(k,[2,26]),e(k,[2,27]),{33:[1,57]},{11:59,30:d,34:58,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},e(k,[2,11]),e(k,[2,32],{35:60,29:X}),e(k,[2,34]),{33:[1,61]},e(k,[2,12]),{17:62,24:Y},{25:63,27:64,29:R},e(k,[2,14]),{17:66,24:Y},e(k,[2,16]),e(k,[2,17]),e(S,[2,43]),e(k,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(k,[2,33]),{29:[1,70]},e(k,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(O,[2,23],{30:[1,73]}),e(k,[2,15]),e(k,[2,28]),e(k,[2,29]),{11:59,30:d,34:74,39:24,40:u,41:27,42:b,43:A,44:m,45:E,46:v,47:L,48:M,49:w,50:D,51:c},e(k,[2,35]),e(k,[2,19]),{25:75,27:64,29:R},e(O,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:a(function(h,g){if(g.recoverable)this.trace(h);else{var x=new Error(h);throw x.hash=g,x}},"parseError"),parse:a(function(h){var g=this,x=[0],f=[],_=[null],r=[],lt=this.table,y="",dt=0,Ot=0,ui=2,Vt=1,di=r.slice.call(arguments,1),P=Object.create(this.lexer),$={yy:{}};for(var bt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,bt)&&($.yy[bt]=this.yy[bt]);P.setInput(h,$.yy),$.yy.lexer=P,$.yy.parser=this,typeof P.yylloc>"u"&&(P.yylloc={});var wt=P.yylloc;r.push(wt);var xi=P.options&&P.options.ranges;typeof $.yy.parseError=="function"?this.parseError=$.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function fi(z){x.length=x.length-2*z,_.length=_.length-z,r.length=r.length-z}a(fi,"popStack");function Wt(){var z;return z=f.pop()||P.lex()||Vt,typeof z!="number"&&(z instanceof Array&&(f=z,z=f.pop()),z=g.symbols_[z]||z),z}a(Wt,"lex");for(var I,U,V,At,j={},xt,N,Ft,ft;;){if(U=x[x.length-1],this.defaultActions[U]?V=this.defaultActions[U]:((I===null||typeof I>"u")&&(I=Wt()),V=lt[U]&&lt[U][I]),typeof V>"u"||!V.length||!V[0]){var Ct="";ft=[];for(xt in lt[U])this.terminals_[xt]&&xt>ui&&ft.push("'"+this.terminals_[xt]+"'");P.showPosition?Ct="Parse error on line "+(dt+1)+`:
2
2
  `+P.showPosition()+`
3
3
  Expecting `+ft.join(", ")+", got '"+(this.terminals_[I]||I)+"'":Ct="Parse error on line "+(dt+1)+": Unexpected "+(I==Vt?"end of input":"'"+(this.terminals_[I]||I)+"'"),this.parseError(Ct,{text:P.match,token:this.terminals_[I]||I,line:P.yylineno,loc:wt,expected:ft})}if(V[0]instanceof Array&&V.length>1)throw new Error("Parse Error: multiple actions possible at state: "+U+", token: "+I);switch(V[0]){case 1:x.push(I),_.push(P.yytext),r.push(P.yylloc),x.push(V[1]),I=null,Ot=P.yyleng,y=P.yytext,dt=P.yylineno,wt=P.yylloc;break;case 2:if(N=this.productions_[V[1]][1],j.$=_[_.length-N],j._$={first_line:r[r.length-(N||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(N||1)].first_column,last_column:r[r.length-1].last_column},xi&&(j._$.range=[r[r.length-(N||1)].range[0],r[r.length-1].range[1]]),At=this.performAction.apply(j,[y,Ot,dt,$.yy,V[1],_,r].concat(di)),typeof At<"u")return At;N&&(x=x.slice(0,-1*N*2),_=_.slice(0,-1*N),r=r.slice(0,-1*N)),x.push(this.productions_[V[1]][0]),_.push(j.$),r.push(j._$),Ft=lt[x[x.length-2]][x[x.length-1]],x.push(Ft);break;case 3:return!0}}return!0},"parse")},ht=(function(){var F={EOF:1,parseError:a(function(g,x){if(this.yy.parser)this.yy.parser.parseError(g,x);else throw new Error(g)},"parseError"),setInput:a(function(h,g){return this.yy=g||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var g=h.match(/(?:\r\n?|\n).*/g);return g?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:a(function(h){var g=h.length,x=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-g),this.offset-=g;var f=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),x.length-1&&(this.yylineno-=x.length-1);var _=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:x?(x.length===f.length?this.yylloc.first_column:0)+f[f.length-x.length].length-x[0].length:this.yylloc.first_column-g},this.options.ranges&&(this.yylloc.range=[_[0],_[0]+this.yyleng-g]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(h){this.unput(this.match.slice(h))},"less"),pastInput:a(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var h=this.pastInput(),g=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
package/dist/index.html CHANGED
@@ -25,9 +25,9 @@
25
25
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
26
26
  <link rel="manifest" href="/manifest.webmanifest" />
27
27
  <title>Limix Bot</title>
28
- <script type="module" crossorigin src="/assets/index-a4OBw5ZS.js"></script>
29
- <link rel="modulepreload" crossorigin href="/assets/styles-CE92r4H3.js">
30
- <link rel="stylesheet" crossorigin href="/assets/styles-_tGCSCNl.css">
28
+ <script type="module" crossorigin src="/assets/index-CGhQDBT_.js"></script>
29
+ <link rel="modulepreload" crossorigin href="/assets/styles-D7SaLPZf.js">
30
+ <link rel="stylesheet" crossorigin href="/assets/styles-Cr4TcnLq.css">
31
31
  </head>
32
32
  <body>
33
33
  <div id="root"></div>
package/dist/rail.html CHANGED
@@ -4,11 +4,11 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Limix Bot</title>
7
- <script type="module" crossorigin src="/assets/rail-DzsIoRRT.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/styles-CE92r4H3.js">
9
- <link rel="modulepreload" crossorigin href="/assets/monitor-B-DfxCLW.js">
10
- <link rel="modulepreload" crossorigin href="/assets/PlacesRail-CKR79j8d.js">
11
- <link rel="stylesheet" crossorigin href="/assets/styles-_tGCSCNl.css">
7
+ <script type="module" crossorigin src="/assets/rail-WaxapGbo.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/styles-D7SaLPZf.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/monitor-BmIglcrr.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/PlacesRail-BxdV2GDQ.js">
11
+ <link rel="stylesheet" crossorigin href="/assets/styles-Cr4TcnLq.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
@@ -1 +1 @@
1
- {"type":"module","version":"0.3.130"}
1
+ {"type":"module","version":"0.3.131"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.130",
3
+ "version": "0.3.131",
4
4
  "description": "Run the Limix Bot server anywhere and pair your devices to it (Leox ৹ Limix AI)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,16 +0,0 @@
1
- import{c as Ie,t as s,l as se,aF as Hs,j as e,i as $e,ae as fe,a as O,r as u,S as Xe,ah as Vt,X as et,d as dt}from"./styles-CE92r4H3.js";import{fo as _s,fp as Ks,_ as tt,bE as Us,dq as Zt,C as qs,fq as Ws,fr as Vs,E as Gt,fs as Zs,M as Yt,eB as Gs,p as Ys,ft as pt,bu as mt,fu as Jt,j as G,u as $,fv as Js,ag as st,af as Qt,A as Xt,S as ye,ab as Ae,T as es,R as Qs,fw as Xs,fx as en,fy as tn,fz as sn,fA as nn,fB as ut,fC as an,fD as rn,fE as on,fF as ln,a$ as cn,fG as dn,fH as pn,fI as mn,I as un,fJ as Pe,bY as nt,fK as xn,aH as M,aN as ee,el as hn,dS as fn,fL as gn,aI as Ve,cw as yn,e5 as bn,e6 as vn,fM as kn,fN as ts,fO as ss,fP as jn,fQ as wn,fR as Nn,fS as Sn,dV as Ze,aq as xt,fT as Fe,fU as Cn,fV as Ee,au as Pn,fW as ns,fX as ht,aj as Ge,fY as On,fZ as En,f_ as Rn,f$ as as,g0 as Tn,g1 as ft,g2 as In,g3 as An,g4 as Mn,g5 as X,aX as ae,aZ as Q,g6 as Ln,g7 as Bn,g8 as $n,dc as Fn,aP as Dn,G as zn,da as is,ai as Hn,g9 as V,aW as pe,ga as me,x as N,gb as _n,dw as Kn,gc as Me,aY as oe,gd as Un,ge as qn,gf as Wn,ep as Vn,gg as gt,gh as Zn,gi as Gn,gj as Yn,gk as Jn,gl as Qn,gm as Xn,az as ea,gn as rs,go as os,gp as ta,gq as sa,gr as na,gs as aa,gt as ia,gu as ra,gv as oa,gw as la,gx as ca,gy as ls,gz as da,gA as pa,gB as ma,gC as at,g as ua,B as Ye,gD as xa,gE as ha,gF as fa,gG as ga,gH as ya,gI as ba,c5 as va,gJ as cs,D as yt,gK as ka,f4 as ja,gL as bt,gM as wa,gN as Na,gO as Sa,cT as vt,bC as Ca,d9 as Pa,gP as Oa,gQ as ds,gR as Se,gS as kt,gT as Ea,aL as De,e7 as Ra,gU as Ta,aR as Ia,dA as Aa,cx as Ma,gV as La,gW as Ba,gX as $a,aT as Fa}from"./App-CeGk9O7P.js";import{v as ps,d as je,a0 as Re,a1 as Da,a2 as za,a3 as jt,a4 as ze,a5 as Ha,a6 as _a,a7 as Ka,a8 as Ua,a9 as qa,aa as wt,ab as Wa,ac as Va,L as Oe,M as Za,B as Je,P as we,r as ms,ad as Ga,$ as Ya,u as us}from"./PlacesRail-CKR79j8d.js";import{C as Ja}from"./coins-Dbmac6SO.js";import{C as ke,a as Qa}from"./MenuMotion-CgVWckHz.js";import{b as te,m as xs,i as Qe,f as it,c as he,d as Nt,e as Te,o as Xa,g as ei,h as de,n as He,t as hs,s as rt,j as fs,k as ti,l as si,p as ni,r as gs,q as ai,u as ii,w as ri,x as ys,y as bs,z as St,B as oi,C as vs,R as Ct,D as li,E as ci,F as di,G as pi,H as mi,J as ui,O as xi,K as hi,L as ks,N as Pt,V as fi,P as gi,M as yi,A as bi,a as vi,S as ki,I as ji}from"./VisibilitySection-BNhdo2-L.js";import{s as wi,r as Ni,a as Si,R as Ci}from"./ComputerFilesPane-LtL8VMhS.js";import{M as Ot}from"./monitor-B-DfxCLW.js";import{R as Pi}from"./RoutinesPage-D5Z3pmtB.js";import{S as Oi}from"./SignedInSites-Dh9imU42.js";import"./index-a4OBw5ZS.js";import"./org-library-PVNP5n7J.js";import"./package-format-xp0kEF1i.js";import"./WorksOnGrid-CUh8CexO.js";import"./ProIntroduction-CZGUC6Ms.js";import"./remote-desktop-DDRRx8uY.js";const Ei=[["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"}]],Ri=Ie("calendar-plus",Ei);const Ti=[["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"}]],Ii=Ie("library",Ti);const Ai=[["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"}]],js=Ie("slack",Ai);const Mi=[["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"}]],Li=Ie("tag",Mi),Bi=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:_s,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Ks,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:js,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:Us,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Zt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Ii,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:qs,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Ws,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:Vs,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Gt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Zs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Yt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Gs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Ja,keywords:["tokens","cost","billing"]}],Et={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 $i(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(Et,a.status))return null;try{return[s("botOverview.routine.line",{schedule:Ys(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:pt(t.nextRunAt)})]:[],...a?[s(Et[a.status],{time:pt(a.at)})]:[]].join(" ")}catch{return null}}const Rt={"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"},Tt={"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 At=t=>Object.hasOwn(Tt,t)?s(Tt[t]):t,Mt=(t,n,a)=>Number(t)===1?n:a,Fi=[{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])=>Mt(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])=>Mt(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)})}],Di=t=>se()!=="en"&&Object.hasOwn(Hs[se()]??{},t);function zi(t,n){for(const a of Fi){const l=a.line.exec(t);if(!l)continue;const i=a.key(l);return Di(i)?s(i,a.params(l,n)):t}return null}function _e(t,n){if(Object.hasOwn(Rt,t))return s(Rt[t]);const a=zi(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:At(i[1])});const o=/^Computer preference: (.+)\.$/.exec(t);if(o)return s("botOverview.line.computer",{preference:At(o[1])});const d=/^Works in (.+)\.$/.exec(t);if(d)return s("botOverview.line.folder",{folder:d[1]});const p=/^Knows how to (.+)\.$/.exec(t);if(p)return s("botOverview.line.skill",{skill:p[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 Hi(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 _i({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 Ki({overview:t,refreshError:n,prompt:a,promptError:l,onOpen:i,onSetup:o}){const[d,p]=u.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const c=(t.setup??[]).filter(f=>!f.done),m=(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")}),c.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:c.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:m(f.id,f.label)}),e.jsx(ke,{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:m(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:$i(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(_i,{data:a,error:l,open:d,onToggle:()=>p(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(ke,{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:Hi(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Jt(f.at)]})]},k))})]})]})}function Ui({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(ps,{size:14,"aria-hidden":"true"})]})]})}function qi(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 ws(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:qi(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",ie=t=>t instanceof Error?t.message:String(t);function Ns(t){const n=[],a=(i,o,d)=>{i&&n.push(s(i===1?o:d,{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 Wi(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=ai(t.path),i=t.path===te?l:t.path===ii?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),o=d=>s(d===1?"memory.journal.line.one":"memory.journal.line.many",{count:d});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 Ss({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 Vi({bot:t,active:n=!0,onToggle:a}){const{capabilities:l}=je(),[i,o]=u.useState(null),[d,p]=u.useState(null),[r,c]=u.useState(null),[m,f]=u.useState(null),[k,g]=u.useState(null),[v,j]=u.useState(null),[S,b]=u.useState(null),[w,x]=u.useState(!1),[P,L]=u.useState(null),[D,B]=u.useState(""),[I,H]=u.useState(null),[A,h]=u.useState(!1),[T,F]=u.useState(null),[_,K]=u.useState(!1),[J,Y]=u.useState(!1),{state:U,dispatch:y}=$(),z=Js(U.config),[le,ue]=u.useState(!1),[ge,E]=u.useState(""),q=async C=>{const[R,Le,zs]=await Promise.all([it(t.id),he(t.id),Nt(t.id).catch(()=>null)]);if(o(R),F(R.lendingReview??null),p(Le),H(zs),C){const Be=await Te(t.id,C);c({path:Be.path,text:Be.text,hash:Be.hash,dirty:!1,readOnly:C.startsWith("memory/log/")})}};u.useEffect(()=>{if(!n)return;let C=!1;j(null);const R=r?.dirty===!0;return q(R?void 0:r?.path??te).catch(Le=>{C||j(ie(Le))}),()=>{C=!0}},[n,t.id]);const Z=async C=>{j(null),f(null);try{const R=await Te(t.id,C);c({path:R.path,text:R.text,hash:R.hash,dirty:!1,readOnly:C.startsWith("memory/log/")})}catch(R){j(ie(R))}},W=async C=>{if(r){x(!0),j(null);try{const R=await rt(t.id,r.path,r.text,C);if(!R.ok){f({path:r.path,current:R.current,currentHash:R.currentHash});return}f(null),g(null),c({...r,text:R.doc.text,hash:R.doc.hash,dirty:!1}),o(R.overview),p(await he(t.id))}catch(R){j(ie(R))}finally{x(!1)}}},ce=()=>{!m||!r||(g(r.text),c({...r,text:m.current,hash:m.currentHash,dirty:!1}),f(null))},Ne=async C=>{if(window.confirm(s("memory.confirmDelete",{name:C.name}))){j(null);try{const{overview:R}=await fs(t.id,C.path);o(R),p(await he(t.id)),r?.path===C.path&&c(null)}catch(R){j(ie(R))}}},lt=async()=>{const C=ti(D);if(!C){j(s("memory.topicNameError"));return}B(""),await Z(`memory/${C}`),c(R=>R&&{...R,dirty:!0,text:R.text||Zi(C)})},Ls=async C=>{L(C.id),j(null);try{const R=await gs(t.id,C.id);o(R.overview),p(await he(t.id)),r?.path===C.path&&!r.dirty&&c({...r,text:R.text,hash:R.hash}),b(s("memory.restored",{path:C.path}))}catch(R){j(ie(R))}finally{L(null)}},ct=async C=>{j(null),b(null);try{await Xa(t.id,C)}catch(R){j(ie(R))}},Bs=()=>{const C=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:C}}),H(R=>R&&{...R,enabled:C})},$s=async()=>{if(!le){ue(!0),E("");try{const C=await G("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:C})}catch(C){E(C instanceof Error?C.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},Fs=async()=>{h(!0),j(null),b(null);try{const{report:C,overview:R}=await hs(t.id);o(R),p(await he(t.id)),H(await Nt(t.id)),r&&!r.dirty&&await Z(r.path),b(`${Ns(C)}.${C.note?` ${C.note}`:""}`)}catch(C){j(ie(C))}finally{h(!1)}},Ds=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:C=>a(C.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,Ds)}),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(Qt,{size:14}),s("memory.showFileManager")]})]})]}),T&&e.jsx(Ss,{changed:T.changed,stale:_,busy:J,onReviewed:()=>{Y(!0),xs(t.id,T.token).then(()=>{F(null),K(!1)}).catch(C=>{if(C instanceof Xt&&C.status===409)return K(!0),q();j(ie(C))}).finally(()=>Y(!1))}}),i&&e.jsx(Yi,{index:i.index}),t.memoryEnabled!==!1&&e.jsx(Gi,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Bs,onTidy:()=>{Fs()},rooms:{enabled:z,saving:le,error:ge,onToggle:()=>{$s()}}}),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")})]}),m&&e.jsx(Cs,{botName:t.name,busy:w,onReload:ce,onOverwrite:()=>{W(m.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:C=>c({...r,text:C.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($t,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:i.topics,selected:r?.path,onOpen:C=>{Z(C.path)},onDelete:C=>{Ne(C)}}),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:C=>B(C.target.value),onKeyDown:C=>{C.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($t,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:i.logs,selected:r?.path,onOpen:C=>{Z(C.path)},onDelete:C=>{Ne(C)}})})]}),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:d,botName:t.name,reverting:P,onRevert:C=>{Ls(C)}})})]}),S&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:S}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Zi(t){return`---
2
- title: ${t.replace(/\.md$/,"")}
3
- description:
4
- aliases: []
5
- ---
6
-
7
- `}function Gi({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(ye,{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(ye,{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:Ns(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 Yi({index:t}){const n=ei(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(Bt,{label:s("memory.capacity.lines"),share:n.lineShare,fill:a}),e.jsx(Bt,{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 Bt({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 Cs({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 $t({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(d=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===d.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>i(d),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:d.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[de(d.bytes)," · ",Re(d.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>o(d),"aria-label":s("memory.deleteFile",{name:d.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(es,{size:14})})]},d.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 d=si(o),p=ni(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:Wi(o,n)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Re(o.at,se(),i)}),d&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:p?s(p,o.threadTitle?{title:o.threadTitle}:void 0):d})]})]}),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(Qs,{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 Ji({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((d,p)=>p.at-d.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(d=>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:Jt(d.at)})," · ",e.jsxs("span",{children:[d.actor," via ",d.via]})," · ",e.jsx("span",{children:d.summary})]}),d.field==="soul"&&d.canRestore===!0&&e.jsx("button",{type:"button",disabled:i,onClick:()=>l(d.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")})]}),d.field==="soul"&&d.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:d.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${d.id}`))]})}function Qi({bot:t,bare:n=!1}){const{state:a,dispatch:l}=$(),i=Xs(t),o=a.instances.find(d=>d.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(ke,{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:en(i)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:nn(i),children:tn(sn(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)?an(i.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ut(i.costUsd)?s("usage.costLine",{caption:rn(o?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Xi=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],er=["circle","rounded","square"],tr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},sr={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"},nr=t=>{const n=sr[t];return n?s(n):t};function ar({bot:t,activeState:n,onPatch:a,onClose:l}){const i=on(t,a),{fileRef:o,crop:d,uploading:p,generating:r,busy:c,error:m,upload:f,removeImage:k,generate:g}=i,v=d!=="mascot"&&!!t.avatarUrl,[j,S]=u.useState(v?"upload":"bot"),b=u.useRef(null);u.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>a(d==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",P=Da(),L=za(t.mascotBody,t.color,P),[D,B]=u.useState(()=>!!P||jt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=P&&L!==x&&jt(L)?ze(L):null,H=(h,T)=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":!v&&x===h,"aria-label":s("mascot.useBody",{name:T}),title:T,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(Za,{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:[Xi.map(([h,T])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>S(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(T)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:c,onClick:()=>a(ln),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:Ha.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:cn.map(h=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:Ua(h)}),title:s(Ka[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(ri,{bot:t,disabled:c,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:[qa.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:wt(h)}),h===P&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:wt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:Wa[h].bodies.map(T=>H(T,ze(T)))})]},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")}),Va.map(h=>e.jsx("button",{type:"button",disabled:c,"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:nr(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(dn,{botLabel:t.title||t.name,disabled:p,generating:r,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(pn,{busy:c,onUpload:h=>{f(h)}}),v&&e.jsx(mn,{bot:t,disabled:c,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:c,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:[p?e.jsx(Oe,{size:22,className:"animate-spin"}):e.jsx(un,{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(Pe,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?d:null,onChange:h=>a({avatarCrop:h}),options:er.map(h=>({value:h,label:s(tr[h]),disabled:c||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:c,"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(es,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),m&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:m})]})]})}const ir=()=>s("place.off");function Ps(t){const{dispatch:n}=$();return(a="computer")=>{fn(t.id,a),n({type:"toggleSettings",open:!1}),n({type:"toggleComputer",open:!0})}}function rr(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 Os(t){const{state:n}=$(),{capabilities:a}=je(),l=a.host?.platform??"other",i=gn(t),o=t.computer??"auto",d=n.config?.browserEngine?.myChrome===!0&&(n.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),p=g=>g==="browser"&&d?s("settings.profiles.myChrome"):vn(g,l),r=g=>{const{view:v,reachable:j}=i[g];return{value:g,label:p(g),disabled:!j,hint:!j||bn(v)?v.line:void 0}},c=[{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:ir(),disabled:!0}]:[]],m=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=m&&m!==o?p(m):null,k=c.find(g=>g.value===o)?.label??(o==="auto"||o==="off"?void 0:p(o));return{options:c,current:o,currentLabel:k,usingNow:f}}function or({bot:t,derived:n}){const{dispatch:a}=$(),{options:l,current:i,usingNow:o}=Os(t),[d,p]=u.useState(null),{patch:r,approvalMode:c}=n,m=f=>{if(!(f===i||f==="off")){if(f==="local"&&c==="auto"){p({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(M,{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:()=>m(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(yn,{open:d!==null,onCancel:()=>p(null),onConfirm:()=>{const f=d;p(null),f&&a({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function lr({bot:t,derived:n,onOpen:a}){const l=Ps(t),i=nt(),{browserEnabled:o}=n,d=rr(t,o&&t.computer!=="off"&&i!==!1),{currentLabel:p,usingNow:r}=Os(t),c=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=m?xn({threadId:t.threadId,messageId:m.id},m.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")}: ${c}`,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(Ot,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:c}),e.jsxs(M,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:Ot,title:s("computer.simple.whereWorks",{name:t.name}),hint:r?s("computer.simple.usingNow",{place:r}):void 0,value:p,onClick:()=>a("where")}),e.jsx(ee,{"data-panel-page":"browser",icon:hn,title:s("settings.sites.title"),value:d??void 0,onClick:()=>a("browser")})]})]})}const cr=3,Ft="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",dr=8,pr=200,xe=new Map,Ue=new Set,Dt=t=>`${t.threadId}@${as(t)}`;function mr(t,n){const[,a]=u.useState(0),i=n.filter(p=>p.threadId!==t.threadId).map(Dt).filter(p=>!xe.has(p)&&!Ue.has(p)).join(",");u.useEffect(()=>{if(i)for(const p of i.split(",")){Ue.add(p);const r=p.slice(0,p.lastIndexOf("@"));G(`/api/threads/${encodeURIComponent(r)}/messages?limit=${dr}`,{background:!0}).then(c=>{xe.set(p,Ge({messages:c.messages??[],activeLeafId:c.activeLeafId??void 0})),xe.size>pr&&xe.delete(xe.keys().next().value),a(m=>m+1)}).catch(()=>{}).finally(()=>Ue.delete(p))}},[i]);const o=Ge(t),d=new Map(n.map(p=>[p.threadId,Dt(p)]));return p=>p===t.threadId?o:xe.get(d.get(p)??"")}function ur({bot:t}){const{state:n,dispatch:a}=$(),l=kn(),i=!ts(ss,!0),[o,d]=u.useState(""),[p,r]=u.useState(!1),[c,m]=u.useState(!1),[f,k]=u.useState(!1),g=jn(n.config),v=u.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}=wn(t.id,a,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}},[t.id,a,g]),j=Nn(t),S=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?Sn({...t,tasks:S},j):S).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)),P=o.trim(),L=w.filter((y,z)=>z<cr||y.threadId===t.threadId),D=mr(t,[...P||c?w:L,...f?x:[]]),B=y=>{const z=D(y);return z?On(Ze(t,y),z,n.instances,!1):void 0},I=Cn(w,P),H=P?[...I,...w.filter(y=>!I.includes(y)&&B(y.threadId)?.toLowerCase().includes(P.toLowerCase()))]:w,A=P?H:c?w:L,h=w.length-L.length,T=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&&Tn(a,t,y.threadId,!1),F()},K=()=>{a({type:"newTask",botId:t.id,...T?{projectId:T.id}:{}}),F()},J=()=>{d(""),r(!1)},Y=w.length>=2||p||w.some(y=>y.threadId===t.threadId&&Fe(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(En,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:Rn(as(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":p,onClick:()=>p?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",p&&"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(ns,"flex-1"),children:[e.jsx(Pn,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&p&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:o,onChange:y=>d(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",Ft),children:A.map(U)}),Y&&P&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:P})}),Y&&!P&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":c,onClick:()=>m(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:[c?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),c?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!P&&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})]}),!P&&f&&x.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:x.length}),className:O("flex flex-col gap-px",Ft),children:x.map(U)})]})}function xr({bot:t}){const{dispatch:n}=$(),a=Vt();return t.defaultBot?a?e.jsx(ft,{placement:"panel-card"}):e.jsxs(M,{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)),e.jsx(ft,{placement:"panel"})]}):null}const hr=["find","start-fresh","usage","activity","inspector"];function fr({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(ke,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function gr({bot:t,derived:n,onOpen:a}){const{items:l}=An(t),{dispatch:i}=$(),o=n.botRoutines.filter(p=>p.enabled).length,d=hr.flatMap(p=>l.filter(r=>r.key===p));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(Mn,{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(ae,{title:s("model.simple.model")})]})})})}),e.jsx(ur,{bot:t}),e.jsx(xr,{bot:t}),d.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ee,{children:s("botPanel.section.conversation")}),d.map(p=>e.jsx(fr,{item:p},p.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(ns,"w-full"),children:[e.jsx(Ri,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(M,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Bn,title:s("botSettings.simple.routines"),value:o>0?s("botPanel.routinesOn",{count:o}):s("botPanel.none"),onClick:()=>a("routines")})})]})}const Es=/^\s*[-*]\s+(.+?)\s*$/;function yr(t){return t.split(`
8
- `).flatMap((n,a)=>{const l=Es.exec(n)?.[1];return l?[{line:a,text:l}]:[]})}function br(t,n){const a=t.split(`
9
- `);return Es.test(a[n]??"")?(a.splice(n,1),a.join(`
10
- `)):t}function vr(t,n){const a=t.replace(/\s+$/,""),l=`- ${n.trim().replace(/\s*\n\s*/g," ")}`;return a?`${a}
11
- ${l}
12
- `:`${l}
13
- `}function Rs(t){return t.flatMap(n=>{const a=yr(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 kr(t,n){if(!n)return[await Te(t,te)];const a=await it(t,!0);return Promise.all([te,...a.topics.map(l=>l.path)].map(l=>Te(t,l,!0)))}function Ts(t){const n=!!$().state.config?.team,[a,l]=u.useState({botId:t.id,docs:null,error:!1}),i=t.memoryEnabled!==!1,o=async(r,c)=>{try{const m=await kr(r,n);c?.()||l({botId:r,docs:m,error:!1})}catch{c?.()||l({botId:r,docs:null,error:!0})}},d=!!t.busy;u.useEffect(()=>{if(!i)return;let r=!1;return o(t.id,()=>r),()=>{r=!0}},[t.id,i,d,n]);const p=a.botId===t.id;return{docs:p?a.docs:null,error:p&&a.error,mine:n,setDoc:r=>l(c=>({botId:t.id,docs:(c.botId===t.id?c.docs??[]:[]).map(m=>m.path===r.path?r:m),error:!1})),reload:()=>o(t.id)}}function jr(t,n=Ge(t)){const a=[],l=[],i=new Set;for(const c of[...n].reverse()){const m=c.publishedPage;m?.state==="live"&&m.url&&!i.has(m.url)&&(i.add(m.url),a.push({messageId:c.id,title:m.title||m.url,url:m.url})),c.kind==="app"&&c.app?.doc&&l.push({messageId:c.id,title:c.app.title})}const o=wi(t),d=[],p=new Set;for(const c of o.values())p.has(c.file.path)||(p.add(c.file.path),d.push(c));const r=Ni(t).filter(c=>!o.has(c));return{pages:a,apps:l,shared:d,unshared:r}}const wr=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Is({bot:t,onOpen:n}){const{dispatch:a}=$(),{capabilities:l}=je(),i=$n(),o=!ts(ss,!0),d=ys(t),p=Ts(t),{pages:r,apps:c,shared:m,unshared:f}=u.useMemo(()=>jr(t),[t]),k=b=>{a({type:"focusMessage",threadId:t.threadId,messageId:b}),o&&a({type:"toggleSettings",open:!1})},g=d.skills.filter(bs).length,v=p.docs?Rs(p.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?p.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}),S=e.jsxs(M,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Zt,title:s("botPanel.memoryRow"),value:j,onClick:()=>n("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:Fn,title:s("botSettings.simple.skills"),value:d.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>n("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Dn,title:s("computer.files.folder"),value:t.cwd?st(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>n("folder")})]});return r.length+c.length+m.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")}),S]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[r.length>0&&e.jsx(M,{label:s("botPanel.library.pages"),anchor:"pages",children:r.map(b=>e.jsx(ee,{"data-panel-row":"page",icon:zn,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))}),c.length>0&&e.jsx(M,{label:s("botPanel.library.apps"),anchor:"apps",children:c.map(b=>e.jsx(ee,{"data-panel-row":"app",icon:is,title:e.jsx("span",{className:"block truncate",children:b.title}),onClick:()=>k(b.messageId)},b.messageId))}),m.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:[m.map(b=>e.jsx("li",{className:"min-w-0",children:e.jsx(Hn,{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:wr(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")}),S]})}function Nr({bot:t,browserEnabled:n,onOpenBrowser:a}){const{state:l}=$(),i=nt(),o=t.browserProfile??"",d=(l.config?.browserProfiles??[]).find(m=>m.id===o),p=o==="guest",r=d?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,c=o&&!p?l.bots.filter(m=>m.browserProfile===o).map(m=>m.name):[t.name];return e.jsx(M,{anchor:"logins",children:n?p?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===""||d)&&e.jsx(pe,{children:e.jsx(Oi,{bare:!0,target:{bot:t.id},sharedBy:c,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:we,onClick:a,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const Sr=[["all",()=>N("Tất cả","All")],["added",()=>N("Bot đang có","On this bot")],["more",()=>N("Chưa thêm","Not added")]],Cr=t=>({bundled:N("Có sẵn","Built in"),library:N("Đã tải về","Downloaded"),imported:N("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 zt(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??N(`Lỗi ${a.status}`,`Error ${a.status}`));return l.skills??[]}function Pr({botId:t,botName:n,onClose:a,onOpenSettings:l}){const[i,o]=u.useState(null),[d,p]=u.useState(""),[r,c]=u.useState("all"),[m,f]=u.useState(""),[k,g]=u.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;u.useEffect(()=>{let x=!1;return zt(v).then(P=>{x||o(P)}).catch(P=>{x||(o([]),g(P.message))}),()=>{x=!0}},[v]),u.useEffect(()=>{const x=P=>{P.key==="Escape"&&a()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a]);const j=u.useMemo(()=>{const x=d.trim().toLowerCase();return(i??[]).filter(P=>(r==="all"||(r==="added"?P.added:!P.added))&&(!x||`${P.name} ${P.description}`.toLowerCase().includes(x)))},[i,d,r]),S=async(x,P)=>{if(!m){f(x.name),g("");try{o(await zt(v,{name:x.name,kind:x.kind,add:P}))}catch(L){g(L instanceof Error?L.message:N("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:N("Kho kỹ năng","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:N(`Chọn kỹ năng cho ${n}. Bot sẽ nhận hướng dẫn của những kỹ năng bạn thêm. Để dùng một kỹ năng, gõ dấu / rồi nhập tên kỹ năng trong khung chat.`,`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":N("Đó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:d,onChange:x=>p(x.target.value),placeholder:N("Tìm kỹ năng…","Search skills…"),"aria-label":N("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":N("Lọc kỹ năng","Filter skills"),children:Sr.map(([x,P])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":r===x,onClick:()=>c(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:[P(),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(Oe,{size:14,className:"animate-spin"}),N("Đ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?N("Kho chưa có kỹ năng nào.","The store has no skills yet."):N("Không tìm thấy kỹ năng phù hợ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?N("Kỹ năng gốc","Core skill"):Cr(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",N("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}),N("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:qe,disabled:!!m,onClick:()=>{S(x,!1)},"aria-label":N(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[m===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(dt,{size:14}),N("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:qe,disabled:!!m||!x.ready,onClick:()=>{S(x,!0)},"aria-label":N(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[m===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(we,{size:14}),N("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:N('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:N("Tải thêm kỹ năng","Get more skills")})]})]})});return typeof document>"u"?w:ms.createPortal(w,document.body)}const be=()=>window.ogb?.limixMessenger,Ht=[{kind:"telegram",label:"Telegram",placeholder:"123456789:AA…",howTo:()=>N("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=>N(`Nhắn cho @${t.username}: `,`Send @${t.username}: `)},{kind:"discord",label:"Discord",placeholder:"MTA…",howTo:()=>N("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:()=>N("Nhắn riêng cho bot trên Discord: ","Send the bot a direct message on Discord: ")},{kind:"zalo",label:"Zalo",howTo:()=>N("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:()=>N("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:()=>N("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:()=>N("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:()=>N("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:()=>N("Từ Facebook cá nhân, nhắn cho Page: ","From your own Facebook, message the Page: ")},{kind:"messenger",label:"Messenger",howTo:()=>N("Đă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:()=>N("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:()=>N("tài khoản Facebook đã đăng nhập","the signed-in Facebook account"),linkFrom:()=>""}],ne="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 Or({bot:t,className:n}){const[a,l]=u.useState("telegram"),[i,o]=u.useState({});u.useEffect(()=>{let r=!0;o({});for(const c of Ht.filter(m=>m.kind!=="messenger"||be()))G(`/api/bots/${t.id}/${c.kind}`).then(m=>{r&&o(f=>({...f,[c.kind]:m}))}).catch(()=>{});return()=>{r=!1}},[t.id]);const d=Ht.filter(r=>r.kind!=="messenger"||be()),p=d.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:N("Kênh chat","Chat channels")}),e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:N(`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:d.map(r=>{const c=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:[c?.connected&&e.jsx("span",{className:O("size-1.5 rounded-full",c.error?"bg-danger":c.enabled?"bg-success":"bg-ink-tertiary")}),r.label]},r.kind)})}),e.jsx(Er,{bot:t,channel:p,view:i[a],onView:r=>o(c=>({...c,[a]:r}))},`${t.id}:${a}`)]})}function Er({bot:t,channel:n,view:a,onView:l}){const i=`/api/bots/${t.id}/${n.kind}`,[o,d]=u.useState(""),[p,r]=u.useState(null),[c,m]=u.useState(!1),[f,k]=u.useState(null),g=!!(a?.login&&!a.login.error&&!a.connected);u.useEffect(()=>{if(!g&&!p)return;let S=!0;const b=setInterval(()=>{G(i).then(w=>{S&&(l(w),w.linkExpiresAt||r(null))}).catch(()=>{})},2e3);return()=>{S=!1,clearInterval(b)}},[g,p,i,l]);const v=async S=>{m(!0),k(null);try{const{code:b,...w}=await S();l(w),b&&r(b)}catch(b){k(b instanceof Error?b.message:String(b))}finally{m(!1)}},j=(S,b="")=>v(()=>G(`${i}${b}`,{method:"POST",body:JSON.stringify(S??{})}));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:S=>{S.preventDefault(),o.trim()&&j({token:o.trim()}).then(()=>d(""))},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:o,onChange:S=>d(S.target.value),placeholder:n.placeholder,"aria-label":N(`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:c||!o.trim(),className:ne,"data-testid":`channel-connect-${n.kind}`,children:N("Kết nối","Connect")})]}):n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ne,"self-start"),disabled:c,onClick:()=>{v(async()=>await be().signIn(t.id))},"data-testid":"channel-signin-messenger",children:N("Mở cửa sổ đăng nhập Facebook","Open the Facebook sign-in window")}):e.jsx(Rr,{view:a,busy:c,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:N(`${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(ye,{"aria-label":N(`Bật ${n.label}`,`${n.label} on`),checked:a.enabled===!0,disabled:c,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(ne,"self-start"),onClick:()=>{be()?.show(t.id)},children:N("Mở cửa sổ Messenger của bot","Show the bot's Messenger window")}):e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[a.owner&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:N(`Chủ bot: ${a.owner}`,`Owner: ${a.owner}`)}),e.jsx("button",{type:"button",className:ne,disabled:c,onClick:()=>{j({},"/unlink")},children:N("Bỏ liên kết","Unlink")})]}),a.admins?.map(S=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:s("channels.admin.account",{name:S.name,id:S.id})}),e.jsx("button",{type:"button",className:ne,disabled:c,"aria-label":s("channels.admin.removeNamed",{name:S.name,id:S.id}),onClick:()=>{j({id:S.id},"/remove-admin")},children:s("channels.admin.remove")})]},S.id)),e.jsx("span",{children:s("channels.admin.explain")}),p&&a.linkExpiresAt?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 ",p]}),N(" (hết hạn sau 15 phút)"," (expires in 15 minutes)")]}):e.jsx("button",{type:"button",className:O(ne,"self-start"),disabled:c,onClick:()=>{j({},"/link")},"data-testid":`channel-link-${n.kind}`,children:a.owner?s("channels.admin.invite"):N("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:[N("Trả lời cả người khác","Answer other people too"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:n.kind==="zalo"?N("Người khác có thể nhắn riêng cho bot với quyền khách.","Other people can message the bot privately as guests."):N("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(ye,{"aria-label":N("Trả lời cả người khác","Answer other people too"),checked:a.access==="everyone",disabled:c,onClick:()=>{j({access:a.access==="everyone"?"owner":"everyone",...a.groupMentions!==void 0?{groupMentions:a.groupMentions}:{}})},"data-testid":`channel-everyone-${n.kind}`})]}),n.kind==="zalo"&&e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:N("Chủ bot đã liên kết luôn có toàn quyền khi gọi bot trong nhóm. Bật tùy chọn này để các thành viên khác cũng có thể gọi bot với quyền khách.","The linked owner always has full access when mentioning the bot in a group. Turn this on to let other members mention it with guest access.")})]}),e.jsx(ye,{"aria-label":N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),checked:a.groupMentions??a.access==="everyone",disabled:c,onClick:()=>{j({groupMentions:!(a.groupMentions??a.access==="everyone")})},"data-testid":"channel-zalo-group-mentions"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",className:ne,disabled:c,onClick:()=>{v(async()=>{const S=await G(i,{method:"DELETE"});return n.kind==="messenger"&&await be()?.signOut(t.id),S})},"data-testid":`channel-remove-${n.kind}`,children:N("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 Rr({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(ne,"self-start"),disabled:n,onClick:a,"data-testid":"channel-qr-zalo",children:N("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:N("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?N(`${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.`):N("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(ne,"self-start"),onClick:l,children:N("Huỷ","Cancel")})]})]})}const Tr=5,Ir={instanceId:"",model:""},As=(t,n)=>`${t}\0${n}`,Ar=new Set;function _t({bot:t,current:n,exclude:a,onPick:l,label:i,title:o,buttonRef:d,className:p,children:r,...c}){const{state:m,dispatch:f,refreshInstances:k,refreshModels:g}=$(),[v,j]=u.useState(!1),[S,b]=u.useState(""),[w,x]=u.useState(()=>new Set),[P,L]=u.useState(!1),[D,B]=u.useState(null),[I,H]=u.useState(null),A=u.useRef(null),h=d??A,T=u.useRef(null),F=u.useRef(null),_=u.useRef(!1),K=u.useId(),J=Qa(v),Y=u.useRef({contains:E=>[h.current,T.current].some(q=>q?.contains(E))});Vn(v,Y,()=>j(!1)),u.useLayoutEffect(()=>{if(!v)return;const E=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&T.current?.contains(q.target))return;const Z=h.current?.getBoundingClientRect(),W=T.current;!Z||!W||H(ce=>Yn(Z,{width:gt,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||!I||!_.current)return;_.current=!1;const E=T.current;(E?.querySelector("[data-menu-search]")??E?.querySelector("[data-current-model]")??E?.querySelector("[data-menu-row]:not(:disabled)")??E)?.focus({preventScroll:!0})},[v,I]);const U=E=>{j(!1),E&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),x(new Set),H(null),_.current=!0,j(!0),L(!0),k().catch(()=>{}).finally(()=>L(!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=Qn(m.instances,n?.instanceId).flatMap(W=>{const ce=W.models.options.filter(Ne=>!a.has(As(W.instanceId,Ne.id)));return ce.length===W.models.options.length?[W]:ce.length?[{...W,models:{...W.models,options:ce}}]:[]}),q=Xn({instances:m.instances,listed:E,selection:n??Ir,bot:{name:t.name,selection:t.modelSelection},query:S,expanded:w,probing:Ar,loading:P,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 Jn(E,{query:S,typed:F,close:()=>U(!0)});E.preventDefault(),E.stopPropagation(),S?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...c,"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:p,children:r}),J.shown&&ms.createPortal(e.jsx("div",{ref:T,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...J.exitProps,onKeyDown:ge,onPointerMove:Zn,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??gt,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",J.className),children:e.jsx(Gn,{menu:ue(),query:S,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 Mr({bot:t,onChange:n}){const{state:a}=$(),l=t.fallback??[],i=u.useRef(null),o=p=>new Set([t.modelSelection,...l.filter((r,c)=>c!==p)].map(r=>As(r.instanceId,r.model))),d=p=>{const r=a.instances.find(f=>f.instanceId===p.instanceId),c=r?.models.options.find(f=>f.id===p.model),m=Un(r,p.model);return{instance:r,name:m,short:r&&c?qn(c.label,Wn(r)):m}};return e.jsx(M,{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:_n}),e.jsx(ae,{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((p,r)=>{const{instance:c,name:m,short:f}=d(p);return e.jsxs("li",{"data-backup":p.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(_t,{bot:t,current:p,exclude:o(r),onPick:k=>n(l.map((g,v)=>v===r?k:g)),label:s("botPanel.backups.row",{position:r+1,model:m}),title:c?`${c.displayName} · ${m}`:m,"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:[c?e.jsx(Kn,{instance:c,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}),!c&&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(Me,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{n(l.filter((k,g)=>g!==r)),i.current?.focus({preventScroll:!0})}})]},r)})}),l.length<Tr&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(_t,{bot:t,current:null,exclude:o(null),onPick:p=>n([...l,p]),label:s("model.fallback.add"),buttonRef:i,"data-panel-action":"backup-add",className:O(oe,"aria-expanded:bg-raised-hover"),children:[e.jsx(we,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Lr({bot:t}){const{dispatch:n}=$(),[a,l]=u.useState(!1),[i,o]=u.useState(!1),[d,p]=u.useState(0),r=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(u.useEffect(()=>{if(!r)return;let m=!0;return G(`/api/bots/${t.id}/system-prompt`).then(f=>{m&&l(f.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,r,d]),!r||!a)return null;const c=async()=>{o(!0);try{await hs(t.id)}catch(m){n({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{o(!1),p(m=>m+1)}};return e.jsx(M,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:ea}),e.jsx(ae,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:i,onClick:()=>{c()},className:oe,children:i?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Br=5;function $r({bot:t}){const{dispatch:n,flushBotPatches:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),p=u.useCallback(()=>St(t.id).then(c=>i(c.rows.slice(0,Br)),()=>{}),[t.id]);if(u.useEffect(()=>{p()},[p,t.soul]),!l.length)return null;const r=async c=>{if(!o){d(c.id);try{await a(t.id);const{revision:m}=await St(t.id);await oi(t.id,c.id,m)}catch(m){n({type:"error",message:m instanceof Error&&m.message?m.message:s("botOverview.undoFailed")})}finally{d(null),await p()}}};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:c=>{r(c)}})]})}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 Fr({bot:t,derived:n,onOpen:a,editingInstructions:l=!1,onEditInstructions:i}){const{state:o,dispatch:d,flushBotPatches:p}=$(),{capabilities:r,ready:c}=je(),m=rs(t),{servers:f}=os(),k=ta(Ze(t)),g=sa(),v=ws(t.id),j=vs(),[S,b]=u.useState(null),{patch:w,approvalMode:x,engine:P}=n,L=t.name,D=()=>{S!==null&&S.trim()!==t.title.trim()&&w({title:S.trim()}),b(null)},B=P?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,I=[{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"||d({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},A=!c||na(r,o.config),h=ha(g,{turnsHere:A,canLive:!0}),T=A?null:aa(r,!!ra()?.speechStart,ia(o.config)),F=oa.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&T!==null,tooltip:y.id==="turns"&&T?`${T.label}. ${T.reason}`:y.id==="live"?s("call.mode.liveHint"):la("turns")})),_=ca.map(y=>({value:y,label:s(Ct[y][0]),tooltip:s(Ct[y][1])})),K=()=>{const y=!t.notifications;y&&fa(),w({notifications:y})},J=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...m.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?ls(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(li,{bot:t}),e.jsx(M,{anchor:"instructions",children:Y?e.jsxs(pe,{"data-panel-row":"soul",children:[e.jsx(ci,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:L})}}),e.jsx($r,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{p(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(ae,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:di(t.soul??"")||s("botPanel.instructionsHint",{name:L})})}),e.jsx(ke,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Lr,{bot:t}),e.jsx(M,{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:Gt}),e.jsx(ae,{title:s("botSettings.simple.beforeActs",{name:L}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:L}),value:B,onChange:H,options:I})}),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(da,{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(Me,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:J.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Mr,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(M,{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:Ga}),e.jsx(ae,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:pa,options:F})})]})}),e.jsxs(M,{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:ma}),e.jsx(ae,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{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:ua,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(M,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:is,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:Li}),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:S??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"&&S!==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:js}),e.jsx(ae,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(ps,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(ee,{"data-panel-page":"visibility",icon:Yt,title:s("botSettings.visibility.title"),value:pi(t.visibility),onClick:()=>a?.("visibility")})]}),t.yourAccess!=="view"&&!t.defaultBot&&e.jsx(Or,{bot:t,className:"mt-3.5"}),e.jsx(mi,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(xa,{bot:t}),k.dialogs]})}const Dr=5;function zr({bot:t,onChanged:n}){const{dispatch:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),[p,r]=u.useState(null),c=u.useCallback(async()=>{const[g,v]=await Promise.all([it(t.id),he(t.id)]);d(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),i(v.slice(0,Dr))},[t.id]);u.useEffect(()=>{c().catch(()=>{})},[c,t.busy]);const m=g=>a({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{r(g.id);try{await gs(t.id,g.id),await n()}catch(v){m(v)}finally{r(null),await c().catch(()=>{})}},k=async g=>{r("review");try{await xs(t.id,g.value.token),d(null)}catch(v){v instanceof Xt&&v.status===409?(d({...g,stale:!0}),await c().catch(()=>{})):m(v)}finally{r(null)}};return e.jsxs(e.Fragment,{children:[o&&e.jsx(Ss,{changed:o.value.changed,stale:o.stale,busy:p!==null,onReviewed:()=>{k(o)}}),e.jsx(M,{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(M,{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:p,onRevert:g=>{f(g)}})})})]})}const Hr="flex flex-col gap-3",Kt="https://www.skills.sh";function ve(t,n){return t instanceof Error&&t.message?t.message:n}function _r({bot:t,derived:n}){const{dispatch:a}=$(),l=rs(t),{servers:i,error:o}=os(),{patch:d,canUseConnectedApps:p}=n,r=i?ka(i,t.id):[],c=new Set(ls(r,t.mcpServers,t.id).map(g=>g.name)),m=g=>{const v=Na(t,l.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&d(v)},f=g=>{t.busy||o||d({mcpServers:Sa(r,t.mcpServers,g)})},k=p?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(M,{children:[k&&e.jsx(V,{children:k}),p&&l.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(ja,{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(bt,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>m(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(r.length>0||o)&&e.jsxs(M,{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:Ya}),e.jsx(ae,{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(bt,{color:t.color,checked:c.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(M,{children:e.jsx(me,{"data-panel-link":"add-app",icon:we,onClick:()=>wa(a,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Kr({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(Si,{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:d=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:d.id}),onToggle:d=>l({type:"updateRoutine",routineId:d.id,patch:{enabled:!d.enabled}})}),e.jsx(M,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:we,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(Pi,{routine:i==="new"?void 0:i,bots:[t],lockedBotId:t.id,onClose:()=>o(null)},t.id)]})}function Ur({bot:t}){const n=Ts(t),[a,l]=u.useState(""),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),m=t.memoryEnabled!==!1,f=n.docs?Rs(n.docs):null,k=n.docs?.find(b=>b.path===te)??null;u.useEffect(()=>o(null),[t.id,m]);const g=async b=>{if(d)return!1;p(!0),c(null);try{return await b()}catch(w){return c(ve(w,s("botPanel.library.memoryError"))),!1}finally{p(!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(),c(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,br(w.text,b.line)):g(async()=>(await fs(t.id,w.path,n.mine),await n.reload(),!0)))},S=async()=>{!k||!a.trim()||await v(k,vr(k.text,a))&&l("")};return m&&i?.botId===t.id?e.jsx(qr,{bot:t,doc:i.doc,mine:n.mine,onDone:b=>{b&&n.setDoc(b),o(null),c(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[m?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(Me,{label:s("botPanel.memory.forget"),disabled:d,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})]}),m&&e.jsxs(M,{children:[e.jsx(cs,{"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:d||k===null,onChange:l,onSubmit:()=>{S()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Ae,onClick:()=>o({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),m&&!n.mine&&e.jsx(zr,{bot:t,onChanged:n.reload})]})}function qr({bot:t,doc:n,mine:a,onDone:l}){const[i,o]=u.useState({text:n.text,hash:n.hash}),[d,p]=u.useState(n.text),[r,c]=u.useState(null),[m,f]=u.useState(null),[k,g]=u.useState(!1),[v,j]=u.useState(null),S=u.useRef(!0);u.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);const b=async x=>{g(!0),j(null);try{const P=await rt(t.id,n.path,d,x,a);if(!S.current)return;P.ok?l(P.doc):c({current:P.current,currentHash:P.currentHash})}catch(P){j(ve(P,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{r&&(f(x=>x===null||x===d?d:`${x}
15
-
16
- ${d}`),o({text:r.current,hash:r.currentHash}),p(r.current),c(null))};return e.jsx(M,{children:e.jsxs(pe,{"data-panel-row":"memory-text",children:[r&&e.jsx(Cs,{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:d,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:x=>p(x.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),m!==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:m}),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||d===i.text,onClick:()=>{b(i.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Wr({bot:t}){const{request:n}=ba(),{state:a,dispatch:l}=$(),i=ys(t),[o,d]=u.useState(""),[p,r]=u.useState(!1),[c,m]=u.useState([]),f=va(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(P){i.setError(ve(P,s("botPanel.skills.removeFailed")))}finally{i.setWorking("")}}},g=async()=>{const x=o.trim();if(!(!x||p)){r(!0),i.setError(""),m([]);try{const P=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});m(Pt(P.imported??[])),d(""),await i.refresh()}catch(P){i.setError(ve(P,s("botPanel.skills.importFailed")))}finally{r(!1)}}},v=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||p)){r(!0),i.setError(""),m([]);try{const P=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});m(Pt(P.imported??[])),await i.refresh()}catch(P){i.setError(ve(P,s("botPanel.skills.importFailed")))}finally{r(!1)}}},[j,S]=u.useState(!1),b=()=>{S(!1),l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){S(!0);return}yt(Kt)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{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:bs(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(Me,{"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(xi,{bot:t,onAdded:()=>{i.refresh()}}),e.jsxs(M,{children:[e.jsx(cs,{"data-panel-form":"skill-import",value:o,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:p?s("skills.import.importing"):s("common.add"),disabled:p,onChange:d,onSubmit:()=>{g()}}),c.map(x=>e.jsx(V,{children:x},x)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{yt(Kt)},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(Pr,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{S(!1),i.refresh()}}),i.reviewing&&e.jsx(hi,{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 Vr({bot:t}){const{capabilities:n}=je(),a=n.host?.homeDir,{draft:l,setDraft:i,error:o,saving:d,canPick:p,save:r,pick:c}=ui(t),[m,f]=u.useState(!1),k=!!t.cwd||m,g=()=>{if(p){c();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx(Ve,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:d,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:d,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(M,{children:[p?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:d,onClick:()=>{c()},className:oe,children:[e.jsx(Qt,{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:d||l===null,className:oe,children:s("botAccess.folder.save")})]}),o&&e.jsx(V,{tone:"warn",children:o})]}),e.jsx(ga,{value:t.cwd,disabled:d,onChoose:r}),e.jsx(ya,{kind:"bots",id:t.id,folder:t.cwd})]})}function Zr({bot:t,derived:n}){const a=Ps(t);return e.jsx(Nr,{bot:t,browserEnabled:n.browserEnabled,onOpenBrowser:()=>a("browser")})}function Gr({bot:t}){return vs()?e.jsx(ks,{bot:t}):null}function Yr({page:t,onOpen:n,editingInstructions:a,onEditInstructions:l,...i}){switch(t){case"settings":return e.jsx(Fr,{...i,onOpen:n,editingInstructions:a,onEditInstructions:l});case"where":return e.jsx(or,{...i});case"apps":return e.jsx(_r,{...i});case"routines":return e.jsx(Kr,{...i});case"visibility":return e.jsx(Gr,{...i});case"memory":return e.jsx(Ur,{...i});case"skills":return e.jsx(Wr,{...i});case"folder":return e.jsx(Vr,{...i});case"browser":return e.jsx(Zr,{...i})}}const Ut="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function qt(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 d=m=>{l.current=!1,a(m)},p=()=>{n!==null&&t(n),a(null)};return{draft:n,setDraft:a,start:d,onKeyDown:m=>{if(Pa(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),l.current=!0,i.current=!0,p()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l.current=!0,i.current=!0,a(null))},onBlur:()=>{l.current||p()},buttonRef:o}}function Jr({bot:t,activeState:n,patch:a,editorOpen:l,onToggleEditor:i}){const o=qt(r=>{const c=r.trim();c&&c!==t.name&&a({name:c})}),d=qt(r=>{const c=r.trim();c!==t.title.trim()&&a({title:c})}),p=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(vt,{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(Ca,{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(Ut,"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(vt,{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"})]})})}),d.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:d.draft,onChange:r=>d.setDraft(r.target.value),onKeyDown:d.onKeyDown,onBlur:d.onBlur,className:O(Ut,"mt-[3px] w-[200px] max-w-full text-[13px]")}):p&&e.jsx("button",{ref:d.buttonRef,type:"button","data-panel-label":!0,onClick:()=>d.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:p})]})}function Ce(t,n){return t?ds(t,n):{tab:"details"}}function Qr({bot:t,derived:n,linkedSection:a,onClose:l}){const{dragProps:i}=us(),o=Oa(),[d,p]=u.useState(()=>Ce(a,o).tab),[r,c]=u.useState(()=>{const h=Ce(a,o).page;return h?[h]:[]}),[m,f]=u.useState(()=>Ce(a,o).anchor??null),[k,g]=u.useState(!1),[v,j]=u.useState(()=>!!Ce(a,o).editInstructions),S=u.useRef(null),b=u.useRef(null),w=r.at(-1)??null,x=()=>S.current?.scrollTo({top:0}),P=h=>{p(h.tab),c(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),x()},L=h=>P({tab:h}),D=h=>{c(T=>[...T,h]),g(!1),x()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{c(h=>h.slice(0,-1)),x()};u.useEffect(()=>{a&&P(ds(a,o))},[a,o]),u.useEffect(()=>{m&&(S.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),f(null))},[m,w,d]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const T=h.target,F=typeof T?.closest=="function"?T.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)I();else return;h.preventDefault(),h.stopPropagation()}},A=r.length>1?s(Se[r[r.length-2]].title,{name:t.name}):s(kt[d]);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(Ea,{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:()=>P({tab:"details",page:"settings"}),className:De,children:e.jsx(Ra,{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:S,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(Jr,{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(ar,{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:Ta.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":d===h,"data-panel-tab":h,onClick:()=>L(h),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",d===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(kt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[d==="details"&&e.jsx(gr,{bot:t,derived:n,onOpen:D}),d==="library"&&e.jsx(Is,{bot:t,onOpen:D}),d==="computer"&&e.jsx(lr,{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(Ia,{back:A,title:s(Se[w].title,{name:t.name}),intro:Se[w].intro?s(Se[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Hr),children:e.jsx(Yr,{page:w,bot:t,derived:n,onOpen:D,editingInstructions:v,onEditInstructions:j})})]})})]})}function Xr(t,n){const{state:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),[m,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,S=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),p(!1))}).catch(()=>{b||p(!0)}),n.prompt&&G(`/api/bots/${t.id}/system-prompt`).then(x=>{b||(c(x),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,n.overview,n.prompt,v,j,S,l]),{overview:i,overviewError:d,prompt:r,promptError:m}}function eo(t,n){const{dispatch:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),m=u.useRef(0),[f,k]=u.useState(!1),[g,v]=u.useState(null),j=u.useCallback(()=>{const w=++m.current;return p(!1),l(t.id).then(()=>G(`/api/bots/${t.id}/history?limit=100`)).then(x=>{w===m.current&&(o(x.rows),c(x.revision))}).catch(()=>{w===m.current&&p(!0)})},[t.id,l]);return u.useEffect(()=>{if(n)return j(),()=>{m.current++}},[n,j]),{rows:i,error:d,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 to({history:t,returnFocusRef:n}){const{rollbackTarget:a,setRollbackTarget:l,rollback:i}=t;return e.jsx(Aa,{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 so={memory:"memory",skills:"skills",folder:"access"},Ms=t=>t.labelKey?s(t.labelKey):t.label;function Wt(t,n){return n?[t.label,Ms(t),...t.keywords].some(a=>a.toLowerCase().includes(n)):!0}function vo({bot:t,overlay:n=!1}){const{state:a,dispatch:l}=$(),i=a.botSettingsSection,o=Ma(t),d=u.useRef(null),{dragProps:p}=us(),[r,c]=u.useState(""),m=!a.botSettingsExpandAccordion,f=r.trim().toLowerCase(),g=!Vt(),v=!m&&!a.botSettingsExpandRemembered?i:null,j=ws(t.id),S=nt(),b=La(),w=Bi.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&S===!0&&!b),x=w.filter(A=>Wt(A,f)),{overview:P,overviewError:L,prompt:D,promptError:B}=Xr(t,{overview:i==="overview"&&!g,prompt:i==="overview"&&!g}),I=eo(t,i==="history"&&!g);u.useEffect(()=>{if(!m){if(f){c("");return}d.current?.querySelector(`[data-bot-settings-section="${i}"]`)?.scrollIntoView({block:"nearest"})}},[m,i,f]),u.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,h=d.current;h?.focus();const T=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",T),()=>{window.removeEventListener("keydown",T),A?.focus()}},[l]);const H=A=>{switch(A){case"overview":return P===null&&L?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Ki,{overview:P,refreshError:P!==null&&L,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(ji,{bot:t,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return e.jsx(ki,{bot:t,patch:o.patch});case"slack":return j?e.jsx(Ui,{managementUrl:j}):null;case"skills":return e.jsx(vi,{bot:t});case"memory":return e.jsx(Vi,{bot:t,active:!m&&i==="memory",onToggle:h=>o.patch({memoryEnabled:h})});case"library":return e.jsx(Is,{bot:t,onOpen:h=>l({type:"toggleSettings",open:!0,section:so[h]??"overview"})});case"routines":return e.jsx(Ci,{bot:t,routines:o.botRoutines,runs:a.routineRuns});case"access":return e.jsx(bi,{bot:t,derived:o});case"model":return e.jsx(yi,{bot:t});case"permissions":return e.jsx(gi,{bot:t,derived:o});case"voice":return e.jsx(fi,{bot:t,derived:o});case"visibility":return e.jsx(ks,{bot:t});case"history":return I.rows===null&&I.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Ji,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Qi,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:d,id:g?Ba:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Fa(n,g),children:g?e.jsx(Qr,{bot:t,derived:o,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...p,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($a,{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=>{c(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),r?c(""):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:T}=A,F=Ms(A),_=Wt(A,f);if(!_&&h!=="memory")return null;const K=!m&&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&&!m){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(T,{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(to,{history:I,returnFocusRef:d})]})}export{vo as BotSettingsDialog};