limixbot 0.2.6 → 0.2.8

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 (185) hide show
  1. package/dist/assets/{ActivityPanel--I8ZbzPP.js → ActivityPanel-peFEa8hc.js} +1 -1
  2. package/dist/assets/{App-BV7lfvAV.js → App-DqXMyMLs.js} +100 -100
  3. package/dist/assets/{AppEventEditor-8B4LbsP2.js → AppEventEditor-7pfjIt50.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-3inJTZDU.js → BotSettingsDialog-D3hAY6mk.js} +1 -1
  5. package/dist/assets/{BrowserPanel-DCL1ihdL.js → BrowserPanel-h3psJrX9.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-BsJcpUXn.js → BrowserProfilesManager-tU88r2vZ.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-ByLX1_cO.js → CloudAddDialog-DWfi8tOM.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-DfBb3jpl.js → ComputerFilesPane-BkDyk0uk.js} +1 -1
  9. package/dist/assets/{ComputerPanel-I4wmIpih.js → ComputerPanel-C7jTOFiO.js} +2 -2
  10. package/dist/assets/{DataPanel-CtUMgjeI.js → DataPanel-BCfRj7d6.js} +1 -1
  11. package/dist/assets/{DesktopViewer-D-mh4Mvc.js → DesktopViewer-jeI22vIi.js} +1 -1
  12. package/dist/assets/{FilesView-JI5NRvg4.js → FilesView-B-gpIIvL.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-9lKJlUqW.js → GrokMoveDialog-BzDSBiBl.js} +1 -1
  14. package/dist/assets/{InspectorPanel-DYjIHQn_.js → InspectorPanel-2I3CFtPj.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-F6vm4Ee4.js → KeyboardShortcutsModal-DdrvmhWG.js} +1 -1
  16. package/dist/assets/{LiveDesktop-CI9S1x-U.js → LiveDesktop-D3KDasUO.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-BVs4kGG8.js → LocalVmWorkspace-UWvcjjYE.js} +1 -1
  18. package/dist/assets/{MacLocalControl-Dnpb-1A_.js → MacLocalControl-H2OhSRFA.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-gVi-3dXl.js → MarkdownFilePreview-CLaBnIvb.js} +1 -1
  20. package/dist/assets/{MenuMotion-DQYRi6n6.js → MenuMotion-nTkCdPNb.js} +1 -1
  21. package/dist/assets/{NewBotDialog-KtFHQMb_.js → NewBotDialog-UUKIGmIQ.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-Dnn_AW4P.js → PhoneAppDialog-CtUtHZIh.js} +1 -1
  23. package/dist/assets/{PlacesRail-Bpjyw4Vm.js → PlacesRail-BJBF_akb.js} +1 -1
  24. package/dist/assets/{PluginsPanel-D5f_fUBQ.js → PluginsPanel-DhRV2Z1H.js} +1 -1
  25. package/dist/assets/{ProIntroduction-BPNgfh6z.js → ProIntroduction-kN19JQ-Y.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-3RAtLnAr.js → RemoteAgentSettingsPanel-BjIqRepm.js} +1 -1
  27. package/dist/assets/{RoomPanel-xMkLuBHe.js → RoomPanel-CgoVFvjy.js} +1 -1
  28. package/dist/assets/{RoutinesPage-M0vKACB8.js → RoutinesPage-C2O4AgJB.js} +1 -1
  29. package/dist/assets/SettingsModal-DOYrfxNQ.js +11 -0
  30. package/dist/assets/{ShareTeamDialog-CeEhxIZd.js → ShareTeamDialog-DNKIsuNU.js} +1 -1
  31. package/dist/assets/{SignedInSites-BldnQjjC.js → SignedInSites-DkQMWpRc.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-BY_Ycbbf.js → TeamLibraryPanel-CnhMRwup.js} +1 -1
  33. package/dist/assets/{TeamMapPage-Da5W5s-4.js → TeamMapPage-7eoMAyZs.js} +1 -1
  34. package/dist/assets/{TriggersPage-D1EMwLwJ.js → TriggersPage-CvtwSgIq.js} +1 -1
  35. package/dist/assets/{VisibilitySection-Bg_6NbUb.js → VisibilitySection-CrMCXcM_.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-DsKXQ3Cd.js → WebhookTrigger-DxnvfaPZ.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-CfkpIePV.js → WorksOnGrid-CtcuFETm.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-Ckoz_CzF.js → abnfDiagram-YUKMZFIV-Bz6GT9ki.js} +1 -1
  39. package/dist/assets/{activity-CQ1e-FGE.js → activity-BTE6SMHx.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-CgPs1VuD.js → architectureDiagram-47P4ROYG-CVJfbFnd.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-Cmb2ImyI.js → blockDiagram-E7TT5TSB-CMJZ058G.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-FdJmz2JG.js → c4Diagram-CRA5TL53-Bcpf92Q7.js} +1 -1
  43. package/dist/assets/{calendar-days-BUipnvhW.js → calendar-days-DFNHSca_.js} +1 -1
  44. package/dist/assets/channel-SsqFZfUs.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-BzwXKae0.js → chunk-2Q5K7J3B-rROdH8y1.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-BYWM6mWC.js → chunk-5VM5RSS4-Gd9w73XJ.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-BIriaw9d.js → chunk-7TKQ45FW-BRSSIX0r.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-6yQL8NET.js → chunk-AW2ZBBNX-fA_30rhU.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-B4pej_b0.js → chunk-FVRAUYC3-DPf3B5cF.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-CyK4QAOD.js → chunk-HTAEGDNF-Kzp8IlCO.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-DRvsvO9Z.js → chunk-JWPE2WC7-BGJbQcUH.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-FEwgYelx.js → chunk-KQW6MTUR-D67e6u2B.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-BYleWq1o.js → chunk-XXDRQBXY-Ca87Y8ja.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-BNjClALP.js → classDiagram-v2-K4WV4PDN-TEXCwmKE.js} +1 -1
  55. package/dist/assets/{coins-CxF7VbZf.js → coins-D-qZ-kBF.js} +1 -1
  56. package/dist/assets/{core-C8K-KBYk.js → core-DVf7JTOd.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-DmY2f5QM.js → cose-bilkent-JH36ORCC-CNNKFtUt.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-D4pCl3aZ.js → cynefin-EF2NZ3EQ-DgCTQdJB.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-jS7kDRoE.js → cynefinDiagram-3GCD6N5R-5JZrPpp0.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-Dd5ELGuw.js → dagre-W4DXFKR2-DfB1U7Ig.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-B-tizYMz.js → diagram-2UJZ2QOL-CUnhXNqi.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-D3xpMTHl.js → diagram-OVF4WLC6-Cvq5rGDL.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-DUf0EYR1.js → diagram-PFPMY2P6-B-7f57WA.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-CfhFy4fo.js → diagram-UMYRVEAY-BxLx7qVG.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-pKD2IJJ7.js → diagram-YEKJPTXX-DP950rJu.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-BxunPXAX.js → diagram-ZIFT7M5P-BhtOX3wi.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-DPyW7BZH.js → ebnfDiagram-VR2GEFS7-C6hk9Jmp.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-XJxkJxok.js → elk-IJKZMXRS-Bag6l1-J.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-CUES7W0a.js → erDiagram-O2IAPWRE-BRX-fn6a.js} +1 -1
  70. package/dist/assets/{file-up-BDUXq-vg.js → file-up-Bkktf2Wj.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-B5acRFQe.js → flowDiagram-OXPTDLAJ-CkjzLOJE.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-CQp0rp67.js → ganttDiagram-R7TSEDQI-4CAOJpRz.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-Chl_xMxf.js → gitGraphDiagram-XJZIOB7I-CskAy2ZD.js} +1 -1
  74. package/dist/assets/{import-name-fDjyR5kx.js → import-name-D4tI24_q.js} +1 -1
  75. package/dist/assets/{index-3mZteHSQ.js → index-5OuBrk-s.js} +1 -1
  76. package/dist/assets/{index-BUpSDhKQ.js → index-BfvuKok1.js} +2 -2
  77. package/dist/assets/{index-CZgKLcUm.js → index-DYquK9TF.js} +1 -1
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-DDJYDjQ5.js → infoDiagram-5W2HQ5XZ-DwRSrZJz.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-Bxd_dhZZ.js → ishikawaDiagram-K3B6WC7H-D4AYxiIn.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-BYF-sQSD.js → journeyDiagram-COXZFDF6-Cy64QkAf.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-B0wBqOFH.js → kanban-definition-P3RFRI5V-BJPaLHmy.js} +1 -1
  82. package/dist/assets/{mcp-servers-xsYOIrTE.js → mcp-servers-1TpToatr.js} +1 -1
  83. package/dist/assets/{mermaid.core-C6PKoMQA.js → mermaid.core-BdIBhisy.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-BlN8ZHNR.js → mindmap-definition-LZFPQGKD-di98H0Xi.js} +1 -1
  85. package/dist/assets/{minimize-BPbapdk9.js → minimize-BZwJDZD1.js} +1 -1
  86. package/dist/assets/{monitor-Xr0SgoUO.js → monitor-Chdrm5wS.js} +1 -1
  87. package/dist/assets/{new-bot-DZ8WGB0A.js → new-bot-K3vr9SqG.js} +1 -1
  88. package/dist/assets/{org-library-jgASeM26.js → org-library-B5ne7DWA.js} +1 -1
  89. package/dist/assets/{package-format-HQ4GXg3u.js → package-format-CibzDzgo.js} +1 -1
  90. package/dist/assets/{pegDiagram-BGZESJAR-Dts1Xq7B.js → pegDiagram-BGZESJAR-DHf_ETMP.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-D6BLN9z8.js → pieDiagram-CAPJLFHJ-D26EUC2Q.js} +1 -1
  92. package/dist/assets/{quadrantDiagram-GDMTTRAM-BNXscncZ.js → quadrantDiagram-GDMTTRAM-CXd_WAYg.js} +1 -1
  93. package/dist/assets/{rail-KIYXnvmP.js → rail-DnNaCE3b.js} +1 -1
  94. package/dist/assets/{railroadDiagram-SM67HX2B-BcriwGaw.js → railroadDiagram-SM67HX2B-CCLyjg6m.js} +1 -1
  95. package/dist/assets/{remote-desktop-panel-D-AMCL3e.js → remote-desktop-panel-zURkbtzE.js} +1 -1
  96. package/dist/assets/{requirementDiagram-X7JNWC4A-DFVmx-Hz.js → requirementDiagram-X7JNWC4A-DfIjRZlK.js} +1 -1
  97. package/dist/assets/{sankeyDiagram-UM26HJRW-fySjdOut.js → sankeyDiagram-UM26HJRW-a192NXbb.js} +1 -1
  98. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-CXrhKe3C.js → sequenceDiagram-ZO4K6R2Y-BN8CB3xi.js} +1 -1
  99. package/dist/assets/{sizeCapture-INFHLROL-D7uoCaYO.js → sizeCapture-INFHLROL-vA44CP_C.js} +1 -1
  100. package/dist/assets/{stateDiagram-v2-TBUQTH76-BcNwr-uw.js → stateDiagram-v2-TBUQTH76-BNZvoQfc.js} +1 -1
  101. package/dist/assets/{styles-DSEcltf1.js → styles-GmtHzqPG.js} +1 -1
  102. package/dist/assets/styles-m-GdEmxH.css +1 -0
  103. package/dist/assets/{swimlanes-N4OXWK64-BXzCyVrs.js → swimlanes-N4OXWK64-BoC9nCsP.js} +1 -1
  104. package/dist/assets/swimlanesDiagram-K3J5GTZL-pZjwzZmz.js +8 -0
  105. package/dist/assets/{team-share-BrQ2rI3n.js → team-share-n1TGl5ex.js} +1 -1
  106. package/dist/assets/{timeline-definition-YOQAKGHF-BdAlbPSb.js → timeline-definition-YOQAKGHF-C8Qj9CXc.js} +1 -1
  107. package/dist/assets/{usecaseDiagram-VIAY4XPW-CIBiINMq.js → usecaseDiagram-VIAY4XPW-vabAoQKz.js} +1 -1
  108. package/dist/assets/{vennDiagram-BLWOH2XV-Ctrb2l50.js → vennDiagram-BLWOH2XV-BMQyc0xY.js} +1 -1
  109. package/dist/assets/{wardleyDiagram-YMQ3BMBF-kLbK1beS.js → wardleyDiagram-YMQ3BMBF-B5DEfy_2.js} +1 -1
  110. package/dist/assets/{xychartDiagram-TAQBALBS-C5baNmCt.js → xychartDiagram-TAQBALBS-J0E9Gsc_.js} +1 -1
  111. package/dist/index.html +3 -3
  112. package/dist/rail.html +5 -5
  113. package/dist-server/package.json +1 -1
  114. package/package.json +1 -1
  115. package/skills/agent-reach/LICENSE +21 -0
  116. package/skills/agent-reach/SKILL.md +117 -0
  117. package/skills/agent-reach/manifest.json +41 -0
  118. package/skills/agent-reach/references/capabilities.md +31 -0
  119. package/skills/agent-reach/references/maintenance.md +13 -0
  120. package/skills/agent-reach/references/sessions.md +41 -0
  121. package/skills/rea-video/LICENSE +202 -0
  122. package/skills/rea-video/NOTICE +4 -0
  123. package/skills/rea-video/SKILL.md +124 -0
  124. package/skills/rea-video/manifest.json +32 -0
  125. package/skills/rea-video/references/audio.md +97 -0
  126. package/skills/rea-video/references/materials.md +34 -0
  127. package/skills/rea-video/references/memory.md +7 -0
  128. package/skills/rea-video/references/output-template.md +46 -0
  129. package/skills/rea-video/references/remake.md +41 -0
  130. package/skills/rea-video/references/review.md +42 -0
  131. package/skills/rea-video/references/setup.md +51 -0
  132. package/skills/rea-video/references/taxonomy.md +139 -0
  133. package/skills/ui-ux-pro-max/LICENSE +21 -0
  134. package/skills/ui-ux-pro-max/SKILL.md +221 -0
  135. package/skills/ui-ux-pro-max/data/app-interface.csv +33 -0
  136. package/skills/ui-ux-pro-max/data/catalog-summary.json +78 -0
  137. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  138. package/skills/ui-ux-pro-max/data/colors.csv +193 -0
  139. package/skills/ui-ux-pro-max/data/data-provenance.json +1396 -0
  140. package/skills/ui-ux-pro-max/data/google-font-licenses.json +20185 -0
  141. package/skills/ui-ux-pro-max/data/google-fonts.csv +1935 -0
  142. package/skills/ui-ux-pro-max/data/icons.csv +106 -0
  143. package/skills/ui-ux-pro-max/data/landing.csv +35 -0
  144. package/skills/ui-ux-pro-max/data/motion.csv +18 -0
  145. package/skills/ui-ux-pro-max/data/phosphor-icons-upstream.json +32582 -0
  146. package/skills/ui-ux-pro-max/data/products.csv +193 -0
  147. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  148. package/skills/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  149. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  150. package/skills/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  151. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  152. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +60 -0
  153. package/skills/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  154. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  155. package/skills/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  156. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +62 -0
  157. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +84 -0
  158. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +68 -0
  159. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  160. package/skills/ui-ux-pro-max/data/stacks/react.csv +67 -0
  161. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +69 -0
  162. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +56 -0
  163. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  164. package/skills/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  165. package/skills/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  166. package/skills/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  167. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  168. package/skills/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  169. package/skills/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  170. package/skills/ui-ux-pro-max/data/styles.csv +90 -0
  171. package/skills/ui-ux-pro-max/data/typography.csv +75 -0
  172. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +193 -0
  173. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +121 -0
  174. package/skills/ui-ux-pro-max/manifest.json +34 -0
  175. package/skills/ui-ux-pro-max/references/pro-rules.md +117 -0
  176. package/skills/ui-ux-pro-max/references/quick-reference.md +257 -0
  177. package/skills/ui-ux-pro-max/scripts/core.py +1053 -0
  178. package/skills/ui-ux-pro-max/scripts/design_system.py +1668 -0
  179. package/skills/ui-ux-pro-max/scripts/reasoning_contract.py +123 -0
  180. package/skills/ui-ux-pro-max/scripts/search.py +201 -0
  181. package/skills/ui-ux-pro-max/scripts/validate_data.py +1095 -0
  182. package/dist/assets/SettingsModal-Dcmk7Ghv.js +0 -11
  183. package/dist/assets/channel-BzoyEHOy.js +0 -1
  184. package/dist/assets/styles-D8FmJr6X.css +0 -1
  185. package/dist/assets/swimlanesDiagram-K3J5GTZL-kYQoltjc.js +0 -8
@@ -1,4 +1,4 @@
1
- import{t as c,r as y,j as a,X as ke,a as G,f as xe,D as ye}from"./styles-DSEcltf1.js";import{L as be,x as ve,C as we}from"./PlacesRail-Bpjyw4Vm.js";import{t as je,a as Me}from"./import-name-fDjyR5kx.js";import{b9 as ue,ba as Ne,bb as ee,bc as Ee,bd as Ae,be as Se,B as _e,n as q,u as Oe,bf as $e}from"./App-BV7lfvAV.js";import{A as Ce,u as T,S as te,b as Le,a as Re,P as Ie,c as Te}from"./package-format-HQ4GXg3u.js";import{F as Fe}from"./file-up-BDUXq-vg.js";import"./monitor-Xr0SgoUO.js";import"./index-BUpSDhKQ.js";import"./MenuMotion-DQYRi6n6.js";const de="grok-bot-export",Pe="openmaus.grok/1",me=4*1024*1024,Be=50,ne=["green","blue","red","orange","purple","cyan","pink","yellow","teal","coral"],Ge=50,ze=`I'm moving to another assistant and need a complete, machine-readable copy of your setup. Do not change, pause or delete anything.
1
+ import{t as c,r as y,j as a,X as ke,a as G,f as xe,D as ye}from"./styles-GmtHzqPG.js";import{L as be,x as ve,C as we}from"./PlacesRail-BJBF_akb.js";import{t as je,a as Me}from"./import-name-D4tI24_q.js";import{b9 as ue,ba as Ne,bb as ee,bc as Ee,bd as Ae,be as Se,B as _e,n as q,u as Oe,bf as $e}from"./App-DqXMyMLs.js";import{A as Ce,u as T,S as te,b as Le,a as Re,P as Ie,c as Te}from"./package-format-CibzDzgo.js";import{F as Fe}from"./file-up-Bkktf2Wj.js";import"./monitor-Chdrm5wS.js";import"./index-BfvuKok1.js";import"./MenuMotion-nTkCdPNb.js";const de="grok-bot-export",Pe="openmaus.grok/1",me=4*1024*1024,Be=50,ne=["green","blue","red","orange","purple","cyan","pink","yellow","teal","coral"],Ge=50,ze=`I'm moving to another assistant and need a complete, machine-readable copy of your setup. Do not change, pause or delete anything.
2
2
 
3
3
  Write one JSON document with exactly this shape, then save it as grok-bot-export-<your name>.json (your name in lowercase, spaces as hyphens): in my Downloads folder if you can write to my computer, otherwise in your workspace, and attach it to your reply. If you cannot attach files, put the whole document in a single \`\`\`json code block instead.
4
4
 
@@ -1,3 +1,3 @@
1
- import{r as f,j as o,t as d,f as te,a as j,ad as ne,X as se,b as U,ae as re}from"./styles-DSEcltf1.js";import{bk as ae,bl as ie,bm as oe,b9 as D,bn as ce,bo as le,bp as ue,u as de,ag as pe,l as me,bq as fe,br as xe}from"./App-BV7lfvAV.js";import{C as he,L as ge,J as ye,u as be}from"./PlacesRail-Bpjyw4Vm.js";import{R as ke,C as $e}from"./MenuMotion-DQYRi6n6.js";import"./index-BUpSDhKQ.js";import"./monitor-Xr0SgoUO.js";const $=(e,n=120)=>e.length>n?`${e.slice(0,n-1)}…`:e,v=e=>e.replace(/\s+/g," ").trim(),F=119;function H(e,n){const a=e?{...e}:{text:"",pendingSpace:!1,overflow:!1};if(a.overflow)return a;for(const i of n){if(/\s/.test(i)){a.text&&(a.pendingSpace=!0);continue}if(a.pendingSpace){if(a.text.length>=F){a.overflow=!0;break}a.text+=" ",a.pendingSpace=!1}if(a.text.length>=F){a.overflow=!0;break}a.text+=i}return a}const B=e=>`${e.text}${e.overflow?"…":""}`;function ve(e){switch(e.type){case"session.started":return{summary:`session ${e.sessionId??"(none)"}${e.model?` · ${e.model}`:""}`,tone:"plain"};case"session.exited":return{summary:`session exited${e.reason?` · ${e.reason}`:""}`,tone:"plain"};case"turn.started":return{summary:`turn started${e.turnId?` · ${e.turnId.slice(0,8)}`:""}`,tone:"boundary"};case"turn.retrying":return{summary:`retrying (${e.reason}) · attempt ${e.attempt} · ${Math.round(e.delayMs/1e3)}s`,tone:"plain"};case"turn.completed":{const n=[e.ok?"turn ok":"turn failed"];return e.stopReason&&n.push(e.stopReason),typeof e.cost=="number"&&n.push(ae(e.cost,4)),e.denials?.length&&n.push(`${e.denials.length} denied`),{summary:n.join(" · "),tone:e.ok?"boundary":"error"}}case"turn.wait_started":return{summary:`waiting for ${e.resource.startsWith("browser:")?"browser":"computer"} — ${e.holder?`${e.holder.name}${e.holder.task?` (${e.holder.task})`:""}`:"holder unknown"}`,tone:"plain"};case"turn.wait_ended":{const n=Math.round(e.waitedMs/1e3),a=e.waitedMs<1e3?"under a second":`${n}s`;return e.outcome==="acquired"?{summary:`${e.resource.startsWith("browser:")?"browser":"computer"} acquired after ${a}`,tone:"boundary"}:e.outcome==="parked"?{summary:`computer wait parked after ${a}`,tone:"plain"}:e.outcome==="gave_up"?{summary:`computer wait gave up after ${a}`,tone:"error"}:{summary:`computer wait stopped after ${a}`,tone:"plain"}}case"item.started":return{summary:`${e.itemType}${e.title?`: ${$(v(e.title))}`:" started"}`,tone:"plain"};case"item.updated":return{summary:`${e.itemType} updated${typeof e.tokens=="number"?` · ${e.tokens} tok`:""}`,tone:"plain"};case"turn.progress":return{summary:`live: ${[e.activity,e.tool,e.file,typeof e.bytes=="number"?`${e.bytes} bytes`:void 0].filter(Boolean).join(" · ")}`,tone:"plain"};case"item.completed":return e.itemType==="assistant_text"?{summary:`assistant: ${$(v(e.text))}`,tone:"plain"}:e.itemType==="assistant_image"?{summary:"assistant image generated",tone:"plain"}:{summary:`tool ${e.ok?"ok":"failed"}`,tone:e.ok?"plain":"error"};case"content.delta":return{summary:`${e.streamKind}: ${$(v(e.delta))}`,tone:"plain"};case"request.opened":return{summary:`${e.requestType}${e.origin==="output"?" (agent-composed)":""}: ${e.tool} — ${$(v(e.summary))}`,tone:"plain"};case"request.resolved":return{summary:`resolved ${e.behavior} · ${e.source}`,tone:"plain"};case"thread.token-usage.updated":return{summary:`tokens in ${e.input} · out ${e.output}`,tone:"plain"};case"runtime.error":return{summary:`${e.setup?"setup: ":""}${$(v(e.message))}`,tone:"error"};case"runtime.notice":return{summary:`notice: ${$(v(e.message))}`,tone:"plain"};default:return{summary:e.type,tone:"plain"}}}function we(e){const n=e.msg;if(!n||typeof n!="object")return String(e.msg);const a=typeof n.method=="string"?n.method:void 0,i=typeof n.type=="string"?n.type:void 0,s=n.id!==void 0?` #${String(n.id)}`:"";if(a)return`${a}${s}`;if(typeof n.event=="string"){const t=n.result?.status;return typeof t=="string"?`${n.event} · ${t}`:n.event}if(i){const t=n.message,x=typeof t?.role=="string"?` · ${t.role}`:"",l=typeof n.subtype=="string"?` · ${n.subtype}`:"";return`${i}${l}${x}`}return n.result!==void 0?`result${s}`:n.error!==void 0?`error${s}`:$(v(JSON.stringify(n)))}function J(e){const n=[];for(const[a,i]of e.entries()){if(i.kind==="native"){n.push({key:`n${a}`,kind:"native",at:i.at,tag:i.data.dir==="out"?"→ out":"← in",summary:`${i.data.source} · ${we(i.data)}`,tone:"plain",data:i.data,count:1});continue}const s=i.data,t=n.at(-1);if(s.type==="content.delta"&&t?.kind==="runtime"&&t.tag==="content.delta"&&t.data[0]?.type==="content.delta"&&t.data[0].streamKind===s.streamKind){const y=t.data;y.push(s),t.count=y.length,t.preview=H(t.preview,s.delta),t.summary=`${s.streamKind}: ${B(t.preview)}`;continue}const{summary:x,tone:l}=ve(s),u=s.type==="content.delta"?H(void 0,s.delta):void 0,b=s.type==="content.delta"?s.streamKind:void 0;n.push({key:s.eventId||`r${a}`,kind:"runtime",at:i.at,tag:s.type,summary:u&&b?`${b}: ${B(u)}`:x,tone:l,data:s.type==="content.delta"?[s]:s,count:1,preview:u})}return n}function je(e){const n=new Date(e);if(Number.isNaN(n.getTime()))return"--:--:--";const a=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0"),s=String(n.getSeconds()).padStart(2,"0"),t=String(n.getMilliseconds()).padStart(3,"0");return`${a}:${i}:${s}.${t}`}function Se(e,n){const a=ie(e,n),i=[];let s=!1;for(const t of e)if(t.kind==="text"&&t.role==="user"&&t.text?.trim())i.push({id:t.id,at:t.at,label:s?"User input":"Task started",state:"observed",kind:"task"}),s=!0;else if(t.kind==="activity"&&t.tool){const x=oe(t.tool.name),l=t.tool.ok===!1||x!==null;i.push({id:t.id,at:t.at,label:D(x??t.tool.name),...t.tool.summary?{command:D(t.tool.summary)}:{},state:l?"failed":t.tool.ok===!0?"complete":a.has(t.id)?"running":"unverified",kind:"tool"})}else t.kind==="screen"?i.push({id:t.id,at:t.at,label:"Screen observed",state:"observed",kind:"screen"}):t.kind==="text"&&t.role==="bot"&&t.text?.trim()&&i.push({id:t.id,at:t.at,label:"Response recorded",state:"complete",kind:"result"});return i}function Ne(e){return D(e.map(n=>`[${new Date(n.at).toISOString()}] ${n.state} · ${n.label}${n.command?`
1
+ import{r as f,j as o,t as d,f as te,a as j,ad as ne,X as se,b as U,ae as re}from"./styles-GmtHzqPG.js";import{bk as ae,bl as ie,bm as oe,b9 as D,bn as ce,bo as le,bp as ue,u as de,ag as pe,l as me,bq as fe,br as xe}from"./App-DqXMyMLs.js";import{C as he,L as ge,J as ye,u as be}from"./PlacesRail-BJBF_akb.js";import{R as ke,C as $e}from"./MenuMotion-nTkCdPNb.js";import"./index-BfvuKok1.js";import"./monitor-Chdrm5wS.js";const $=(e,n=120)=>e.length>n?`${e.slice(0,n-1)}…`:e,v=e=>e.replace(/\s+/g," ").trim(),F=119;function H(e,n){const a=e?{...e}:{text:"",pendingSpace:!1,overflow:!1};if(a.overflow)return a;for(const i of n){if(/\s/.test(i)){a.text&&(a.pendingSpace=!0);continue}if(a.pendingSpace){if(a.text.length>=F){a.overflow=!0;break}a.text+=" ",a.pendingSpace=!1}if(a.text.length>=F){a.overflow=!0;break}a.text+=i}return a}const B=e=>`${e.text}${e.overflow?"…":""}`;function ve(e){switch(e.type){case"session.started":return{summary:`session ${e.sessionId??"(none)"}${e.model?` · ${e.model}`:""}`,tone:"plain"};case"session.exited":return{summary:`session exited${e.reason?` · ${e.reason}`:""}`,tone:"plain"};case"turn.started":return{summary:`turn started${e.turnId?` · ${e.turnId.slice(0,8)}`:""}`,tone:"boundary"};case"turn.retrying":return{summary:`retrying (${e.reason}) · attempt ${e.attempt} · ${Math.round(e.delayMs/1e3)}s`,tone:"plain"};case"turn.completed":{const n=[e.ok?"turn ok":"turn failed"];return e.stopReason&&n.push(e.stopReason),typeof e.cost=="number"&&n.push(ae(e.cost,4)),e.denials?.length&&n.push(`${e.denials.length} denied`),{summary:n.join(" · "),tone:e.ok?"boundary":"error"}}case"turn.wait_started":return{summary:`waiting for ${e.resource.startsWith("browser:")?"browser":"computer"} — ${e.holder?`${e.holder.name}${e.holder.task?` (${e.holder.task})`:""}`:"holder unknown"}`,tone:"plain"};case"turn.wait_ended":{const n=Math.round(e.waitedMs/1e3),a=e.waitedMs<1e3?"under a second":`${n}s`;return e.outcome==="acquired"?{summary:`${e.resource.startsWith("browser:")?"browser":"computer"} acquired after ${a}`,tone:"boundary"}:e.outcome==="parked"?{summary:`computer wait parked after ${a}`,tone:"plain"}:e.outcome==="gave_up"?{summary:`computer wait gave up after ${a}`,tone:"error"}:{summary:`computer wait stopped after ${a}`,tone:"plain"}}case"item.started":return{summary:`${e.itemType}${e.title?`: ${$(v(e.title))}`:" started"}`,tone:"plain"};case"item.updated":return{summary:`${e.itemType} updated${typeof e.tokens=="number"?` · ${e.tokens} tok`:""}`,tone:"plain"};case"turn.progress":return{summary:`live: ${[e.activity,e.tool,e.file,typeof e.bytes=="number"?`${e.bytes} bytes`:void 0].filter(Boolean).join(" · ")}`,tone:"plain"};case"item.completed":return e.itemType==="assistant_text"?{summary:`assistant: ${$(v(e.text))}`,tone:"plain"}:e.itemType==="assistant_image"?{summary:"assistant image generated",tone:"plain"}:{summary:`tool ${e.ok?"ok":"failed"}`,tone:e.ok?"plain":"error"};case"content.delta":return{summary:`${e.streamKind}: ${$(v(e.delta))}`,tone:"plain"};case"request.opened":return{summary:`${e.requestType}${e.origin==="output"?" (agent-composed)":""}: ${e.tool} — ${$(v(e.summary))}`,tone:"plain"};case"request.resolved":return{summary:`resolved ${e.behavior} · ${e.source}`,tone:"plain"};case"thread.token-usage.updated":return{summary:`tokens in ${e.input} · out ${e.output}`,tone:"plain"};case"runtime.error":return{summary:`${e.setup?"setup: ":""}${$(v(e.message))}`,tone:"error"};case"runtime.notice":return{summary:`notice: ${$(v(e.message))}`,tone:"plain"};default:return{summary:e.type,tone:"plain"}}}function we(e){const n=e.msg;if(!n||typeof n!="object")return String(e.msg);const a=typeof n.method=="string"?n.method:void 0,i=typeof n.type=="string"?n.type:void 0,s=n.id!==void 0?` #${String(n.id)}`:"";if(a)return`${a}${s}`;if(typeof n.event=="string"){const t=n.result?.status;return typeof t=="string"?`${n.event} · ${t}`:n.event}if(i){const t=n.message,x=typeof t?.role=="string"?` · ${t.role}`:"",l=typeof n.subtype=="string"?` · ${n.subtype}`:"";return`${i}${l}${x}`}return n.result!==void 0?`result${s}`:n.error!==void 0?`error${s}`:$(v(JSON.stringify(n)))}function J(e){const n=[];for(const[a,i]of e.entries()){if(i.kind==="native"){n.push({key:`n${a}`,kind:"native",at:i.at,tag:i.data.dir==="out"?"→ out":"← in",summary:`${i.data.source} · ${we(i.data)}`,tone:"plain",data:i.data,count:1});continue}const s=i.data,t=n.at(-1);if(s.type==="content.delta"&&t?.kind==="runtime"&&t.tag==="content.delta"&&t.data[0]?.type==="content.delta"&&t.data[0].streamKind===s.streamKind){const y=t.data;y.push(s),t.count=y.length,t.preview=H(t.preview,s.delta),t.summary=`${s.streamKind}: ${B(t.preview)}`;continue}const{summary:x,tone:l}=ve(s),u=s.type==="content.delta"?H(void 0,s.delta):void 0,b=s.type==="content.delta"?s.streamKind:void 0;n.push({key:s.eventId||`r${a}`,kind:"runtime",at:i.at,tag:s.type,summary:u&&b?`${b}: ${B(u)}`:x,tone:l,data:s.type==="content.delta"?[s]:s,count:1,preview:u})}return n}function je(e){const n=new Date(e);if(Number.isNaN(n.getTime()))return"--:--:--";const a=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0"),s=String(n.getSeconds()).padStart(2,"0"),t=String(n.getMilliseconds()).padStart(3,"0");return`${a}:${i}:${s}.${t}`}function Se(e,n){const a=ie(e,n),i=[];let s=!1;for(const t of e)if(t.kind==="text"&&t.role==="user"&&t.text?.trim())i.push({id:t.id,at:t.at,label:s?"User input":"Task started",state:"observed",kind:"task"}),s=!0;else if(t.kind==="activity"&&t.tool){const x=oe(t.tool.name),l=t.tool.ok===!1||x!==null;i.push({id:t.id,at:t.at,label:D(x??t.tool.name),...t.tool.summary?{command:D(t.tool.summary)}:{},state:l?"failed":t.tool.ok===!0?"complete":a.has(t.id)?"running":"unverified",kind:"tool"})}else t.kind==="screen"?i.push({id:t.id,at:t.at,label:"Screen observed",state:"observed",kind:"screen"}):t.kind==="text"&&t.role==="bot"&&t.text?.trim()&&i.push({id:t.id,at:t.at,label:"Response recorded",state:"complete",kind:"result"});return i}function Ne(e){return D(e.map(n=>`[${new Date(n.at).toISOString()}] ${n.state} · ${n.label}${n.command?`
2
2
  ${n.command}`:""}`).join(`
3
3
  `))}const Ie={running:"inspector.run.running",complete:"inspector.run.complete",failed:"inspector.run.failed",observed:"inspector.run.observed",unverified:"inspector.run.unverified"};function Te({events:e}){const[n,a]=f.useState("idle"),i=e.slice(-200),s=async()=>{const t=await ye(Ne(i));t!=="empty"&&a(t)};return o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[o.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[o.jsx("p",{className:"min-w-0 flex-1 text-[12px] leading-relaxed text-ink-secondary",children:d("inspector.run.hint")}),i.length>0&&o.jsx("button",{type:"button",onClick:()=>{s()},"aria-label":d("inspector.run.copy"),title:d("inspector.run.copy"),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink focus-visible:outline-2 focus-visible:outline-accent",children:n==="copied"?o.jsx(te,{size:14}):o.jsx(he,{size:14})})]}),n!=="idle"&&o.jsx("p",{role:"status",className:"px-4 pb-2 text-[12px] text-ink-secondary",children:d(n==="copied"?"inspector.run.copied":"inspector.run.copyFailed")}),e.length>i.length&&o.jsx("p",{className:"px-4 pb-2 text-[12px] text-ink-secondary",children:d("inspector.run.recent",{count:i.length})}),i.length===0?o.jsx("p",{className:"px-4 py-6 text-[13px] text-ink-secondary",children:d("inspector.run.empty")}):o.jsx("ol",{"aria-label":d("inspector.run.title"),className:"px-4 pb-4",children:i.map(t=>{const x=t.state==="failed"?ce:t.state==="complete"?le:t.state==="running"?ge:ue,l=t.kind==="task"?d("inspector.run.userInput"):t.kind==="screen"?d("inspector.run.screen"):t.kind==="result"?d("inspector.run.response"):t.label;return o.jsxs("li",{className:"border-t border-hairline/30 py-3",children:[o.jsxs("div",{className:"flex items-start gap-2 text-[12px]",children:[o.jsx(x,{size:14,"aria-hidden":"true",className:j("mt-0.5 shrink-0",t.state==="failed"?"text-danger":t.state==="running"?"animate-spin text-accent":"text-ink-secondary")}),o.jsx("span",{className:"min-w-0 flex-1 break-words font-medium text-ink",children:l}),o.jsx("time",{dateTime:new Date(t.at).toISOString(),className:"shrink-0 tabular-nums text-ink-secondary",children:ne(t.at)})]}),t.command&&o.jsx("pre",{className:"mt-2 whitespace-pre-wrap break-all rounded-lg bg-inset p-2 font-mono text-[12px] leading-relaxed text-ink",children:t.command}),t.kind==="tool"&&o.jsx("p",{className:j("mt-1 pl-[22px] text-[11px]",t.state==="failed"?"text-danger":"text-ink-secondary"),children:d(Ie[t.state])})]},t.id)})})]})}const K=400,T=new WeakMap;function X(e){const n={runtime:0,native:0},a=[];for(let i=e.length-1;i>=0;i--){const s=e[i];++n[s.kind]<=K&&a.push(s)}return a.length===e.length?e:a.reverse()}function G(e,n){if(!n.length)return e;const a=e??{entries:[],total:{runtime:0,native:0}},i=new Set(a.entries.flatMap(u=>u.kind==="runtime"?[u.data.eventId]:[])),s=[];for(const u of n)i.has(u.eventId)||(i.add(u.eventId),s.push({kind:"runtime",at:u.createdAt,data:u}));if(!s.length)return e;const t=X([...a.entries,...s]),x=new Set([...T.get(a)??[],...s.map(u=>u.data.eventId)]),l={entries:t,total:{...a.total,runtime:a.total.runtime+s.length}};return T.set(l,new Set(t.flatMap(u=>u.kind==="runtime"&&x.has(u.data.eventId)?[u.data.eventId]:[]))),l}function Re(e,n){const a={...n,entries:X(n.entries)};if(!e)return a;const i=e.entries.flatMap(m=>m.kind==="runtime"?[m.data]:[]),s=T.get(e)??new Set,t=a.entries.filter(m=>m.kind==="runtime"),x=new Set(t.map(m=>m.data.eventId)),l=i.findLastIndex(m=>x.has(m.eventId)),u=t.at(-1)?.at,b=(l>=0?i.slice(l+1):i.filter(m=>u===void 0||m.createdAt>=u)).filter(m=>s.has(m.eventId)),y=G(a,b),R={...y,total:{...y.total,runtime:Math.max(e.total.runtime,y.total.runtime)}};return T.set(R,T.get(y)??new Set),R}const Ce=e=>U()==="en"?d(e):xe(d(e));function qe({bot:e}){const{dispatch:n}=de(),{dragProps:a}=be(),i=e.threadId,[s,t]=f.useState("run"),x=f.useMemo(()=>Se(pe(e),e),[e]),[l,u]=f.useState(null),[b,y]=f.useState(null),[R,m]=f.useState(()=>new Set),E=f.useRef(null),z=f.useRef(!0),S=f.useRef(null),C=f.useRef(()=>{}),L=f.useCallback(async()=>{S.current?.abort();const r=new AbortController;S.current=r;try{const c=await fetch(`/api/threads/${i}/events?limit=${K}`,{signal:r.signal});if(!c.ok)throw new Error(`${c.status}`);const p=await c.json();if(r.signal.aborted)return;u(h=>Re(h,p)),m(h=>new Set([...h].filter(M=>M.startsWith("runtime:")))),y(null)}catch(c){if(r.signal.aborted)return;y(c instanceof Error?c.message:String(c))}finally{S.current===r&&(S.current=null)}},[i]);f.useEffect(()=>(u(null),m(new Set),z.current=!0,()=>S.current?.abort()),[L]),f.useEffect(()=>{let r=!0,c=null,p=0,h=!1;const M=[];let N=[],w=null;const q=()=>{w&&clearTimeout(w),w=null;const g=N;N=[],g.length&&u(k=>G(k,g))},W=g=>{N.push(g),N.length>=K?q():w??=setTimeout(q,16)},Y=()=>{for(const g of M.splice(0))W(g)},Z=async()=>{q();const g=++p;h=!0,await L(),!(!r||g!==p)&&(h=!1,Y())},I=()=>{Z()};C.current=I;const ee=me({onMissedFrames:I,onFrame:g=>{if(g.kind!=="runtime")return;const k=g.event;k.threadId===i&&(h?M.push(k):W(k),(k.type==="turn.completed"||k.type==="runtime.error")&&(c&&clearTimeout(c),c=setTimeout(I,400)))}});return I(),()=>{r=!1,C.current===I&&(C.current=()=>{}),ee(),c&&clearTimeout(c),w&&clearTimeout(w),N=[]}},[i,L]);const A=f.useMemo(()=>l?l.entries.filter(r=>s==="raw"?r.kind==="native":r.kind==="runtime"):[],[l,s]),O=f.useMemo(()=>J(A),[A]);f.useEffect(()=>{const r=new Set(["runtime","native"].flatMap(c=>J(l?.entries.filter(p=>p.kind===c)??[]).map(p=>`${p.kind}:${p.key}`)));m(c=>{const p=new Set([...c].filter(h=>r.has(h)));return p.size===c.size?c:p})},[l]),f.useEffect(()=>{const r=E.current;r&&z.current&&(r.scrollTop=r.scrollHeight)},[l,O.length,s]);const V=()=>{const r=E.current;r&&(z.current=r.scrollHeight-r.scrollTop-r.clientHeight<40)},Q=r=>m(c=>{const p=new Set(c);return p.has(r)?p.delete(r):p.add(r),p}),_=A.length,P=s==="raw"?l?.total.native??0:l?.total.runtime??0;return o.jsxs("aside",{"aria-label":d("inspector.title"),className:"animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel md:static md:z-auto md:w-[min(460px,45vw)] md:shrink-0",children:[o.jsxs("div",{...a,className:"flex items-center justify-between px-4 py-3",children:[o.jsxs("span",{className:"flex items-center gap-2 text-[15px] font-semibold text-ink",children:[o.jsx(fe,{size:16,className:"text-ink-secondary"})," ",d("inspector.title")]}),o.jsx("button",{onClick:()=>n({type:"toggleInspector",open:!1}),"aria-label":d("inspector.close"),title:d("inspector.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-raised hover:text-ink",children:o.jsx(se,{size:18})})]}),o.jsxs("div",{className:"flex items-center gap-2 border-b border-hairline/40 px-4 pb-3",children:[o.jsx("div",{role:"tablist","aria-label":d("inspector.views"),className:"flex rounded-lg bg-inset p-0.5",onKeyDown:r=>{const c=Array.from(r.currentTarget.querySelectorAll('[role="tab"]')),p=c.indexOf(document.activeElement),h=r.key==="ArrowRight"?(p+1)%c.length:r.key==="ArrowLeft"?(p+c.length-1)%c.length:r.key==="Home"?0:r.key==="End"?c.length-1:-1;h<0||(r.preventDefault(),c[h].focus(),c[h].click())},children:["run","events","raw"].map(r=>o.jsx("button",{type:"button",role:"tab",id:`inspector-tab-${r}`,"aria-selected":s===r,"aria-controls":`inspector-panel-${r}`,tabIndex:s===r?0:-1,onClick:()=>t(r),className:j("rounded-md px-2.5 py-1 text-[12px] font-medium",U()==="en"&&"capitalize",s===r?"bg-raised text-ink":"text-ink-secondary hover:text-ink"),children:Ce(r==="run"?"inspector.run.title":r==="events"?"inspector.tab.events":"inspector.tab.raw")},r))}),s!=="run"&&o.jsx("span",{className:"ml-auto text-[11px] text-ink-secondary",children:l?_<P?d("inspector.entries.lastOf",{shown:_,total:P}):d("inspector.entries.count",{count:_}):d("inspector.entries.loading")}),s!=="run"&&o.jsx("button",{onClick:()=>C.current(),className:"rounded-md p-1 text-ink-secondary hover:bg-raised hover:text-ink",title:d("inspector.reload"),children:o.jsx(ke,{size:14})})]}),o.jsx("div",{role:"tabpanel",id:`inspector-panel-${s}`,"aria-labelledby":`inspector-tab-${s}`,tabIndex:0,className:"flex min-h-0 flex-1 flex-col outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60",children:s==="run"?o.jsx(Te,{events:x},i):o.jsxs("div",{ref:E,onScroll:V,className:"min-h-0 flex-1 overflow-y-auto font-mono text-[12px]",children:[b&&o.jsx("div",{className:"px-4 py-3 text-danger",children:d("inspector.loadFailed",{error:b})}),l&&O.length===0&&!b&&o.jsx("div",{className:"px-4 py-6 text-ink-secondary",children:d(s==="raw"?"inspector.emptyRaw":"inspector.emptyEvents")}),O.map(r=>o.jsx(Me,{row:r,open:R.has(`${r.kind}:${r.key}`),onToggle:()=>Q(`${r.kind}:${r.key}`)},r.key))]})})]})}function Me({row:e,open:n,onToggle:a}){return o.jsxs("div",{className:j("border-b border-hairline/20",e.tone==="boundary"&&"bg-raised/40",e.tone==="error"&&"bg-danger/10"),children:[o.jsxs("button",{onClick:a,className:"flex w-full items-start gap-2 px-3 py-1.5 text-left hover:bg-raised/60",children:[o.jsx("span",{className:"mt-[1px] shrink-0 text-ink-secondary",children:n?o.jsx(re,{size:12}):o.jsx($e,{size:12})}),o.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:je(e.at)}),o.jsxs("span",{className:j("shrink-0 rounded px-1 text-[11px]",e.kind==="native"?"bg-accent/15 text-accent":e.tone==="error"?"bg-danger/20 text-danger":"bg-inset text-ink-secondary"),children:[e.tag,e.count>1?` ×${e.count}`:""]}),o.jsx("span",{className:j("min-w-0 flex-1 truncate",e.tone==="error"?"text-danger":"text-ink"),children:e.summary})]}),n&&o.jsx("pre",{className:"max-h-[50vh] overflow-auto whitespace-pre-wrap break-all border-t border-hairline/20 bg-app px-3 py-2 text-[11px] leading-relaxed text-ink",children:JSON.stringify(e.data,null,2)})]})}export{qe as InspectorPanel};
@@ -1 +1 @@
1
- import{r as c,j as e,t as s,X as p,S as m}from"./styles-DSEcltf1.js";import{i as b,e as f,f as y,s as j,g,h as k,j as v}from"./App-BV7lfvAV.js";import{K as N}from"./MenuMotion-DQYRi6n6.js";import"./index-BUpSDhKQ.js";import"./PlacesRail-Bpjyw4Vm.js";import"./monitor-Xr0SgoUO.js";function w({item:r,isMac:n}){const a=k(r,n);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:v(r)}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a.map((i,o)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[12px] font-semibold text-ink shadow-xs",children:i},o))})]})}function P({open:r,onClose:n}){const[a,i]=c.useState(""),o=c.useRef(null),l=c.useRef(null),d=b(),h=f();if(c.useLayoutEffect(()=>{const t=o.current;if(!(!r||!t))return i(""),t.showModal(),l.current?.focus(),()=>t.close()},[r]),!r)return null;const x=y(j(h),a,d);return e.jsx("dialog",{ref:o,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:t=>{t.preventDefault(),n()},onKeyDown:t=>t.stopPropagation(),onMouseDown:t=>t.target===t.currentTarget&&n(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(N,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:s("shortcuts.title")}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("shortcuts.subtitle")})]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("shortcuts.close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(p,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:l,value:a,onChange:t=>i(t.target.value),placeholder:s("shortcuts.searchPlaceholder"),"aria-label":s("shortcuts.search"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:x.length===0?e.jsx("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:s("shortcuts.noMatch",{query:a})}):x.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:g(t)}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:t.items.map(u=>e.jsx(w,{item:u,isMac:d},u.id))})]},t.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[s("shortcuts.openHintBefore")," ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[11px]",children:"?"})," ",s("shortcuts.openHintAfter")]}),e.jsx("button",{type:"button",onClick:n,className:"ui-button ui-button-md",children:s("common.done")})]})]})})}export{P as KeyboardShortcutsModal};
1
+ import{r as c,j as e,t as s,X as p,S as m}from"./styles-GmtHzqPG.js";import{i as b,e as f,f as y,s as j,g,h as k,j as v}from"./App-DqXMyMLs.js";import{K as N}from"./MenuMotion-nTkCdPNb.js";import"./index-BfvuKok1.js";import"./PlacesRail-BJBF_akb.js";import"./monitor-Chdrm5wS.js";function w({item:r,isMac:n}){const a=k(r,n);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:v(r)}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a.map((i,o)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[12px] font-semibold text-ink shadow-xs",children:i},o))})]})}function P({open:r,onClose:n}){const[a,i]=c.useState(""),o=c.useRef(null),l=c.useRef(null),d=b(),h=f();if(c.useLayoutEffect(()=>{const t=o.current;if(!(!r||!t))return i(""),t.showModal(),l.current?.focus(),()=>t.close()},[r]),!r)return null;const x=y(j(h),a,d);return e.jsx("dialog",{ref:o,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:t=>{t.preventDefault(),n()},onKeyDown:t=>t.stopPropagation(),onMouseDown:t=>t.target===t.currentTarget&&n(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(N,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:s("shortcuts.title")}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("shortcuts.subtitle")})]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("shortcuts.close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(p,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:l,value:a,onChange:t=>i(t.target.value),placeholder:s("shortcuts.searchPlaceholder"),"aria-label":s("shortcuts.search"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:x.length===0?e.jsx("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:s("shortcuts.noMatch",{query:a})}):x.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:g(t)}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:t.items.map(u=>e.jsx(w,{item:u,isMac:d},u.id))})]},t.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[s("shortcuts.openHintBefore")," ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[11px]",children:"?"})," ",s("shortcuts.openHintAfter")]}),e.jsx("button",{type:"button",onClick:n,className:"ui-button ui-button-md",children:s("common.done")})]})]})})}export{P as KeyboardShortcutsModal};
@@ -1 +1 @@
1
- import{r as n,t as s,j as e,a as o}from"./styles-DSEcltf1.js";import{c as H,t as M}from"./desktop-connection-Dfaq6k5a.js";import{u as B,d as F,L as D}from"./PlacesRail-Bpjyw4Vm.js";import{S as K,R as O}from"./MenuMotion-DQYRi6n6.js";import{Q as P,U as Q}from"./App-BV7lfvAV.js";import"./desktop-viewer-CF-OpSo0.js";import"./monitor-Xr0SgoUO.js";import"./index-BUpSDhKQ.js";function Z({target:x,threadId:f,name:R,poster:b,expanded:r,onExpandedChange:h,onHandBack:E,handingBack:g,onUnreachable:v}){const j=n.useRef(null),a=n.useRef(null),[i,c]=n.useState("connecting"),[k,w]=n.useState(0),[l,y]=n.useState(""),N=n.useRef(!1),{dragProps:L,noDragStyle:u}=B(),T=F().capabilities.windowChrome==="mac-inset",C=n.useRef(v);C.current=v,n.useEffect(()=>{const t=new AbortController;let p,S;const V=()=>{c("disconnected"),N.current?k===0&&(S=setTimeout(()=>w(1),1e3)):C.current()};return c("connecting"),H(j.current,x,{threadId:f,signal:t.signal,events:{connected:()=>{N.current=!0,c("connected")},disconnected:V}}).then(m=>{if(t.signal.aborted)return m.disconnect();p=m,a.current=m},()=>{t.signal.aborted||V()}),()=>{t.abort(),clearTimeout(S),p?.disconnect(),a.current===p&&(a.current=null)}},[x,f,k]),n.useEffect(()=>{i==="connected"&&a.current?.focus({preventScroll:!0})},[r,i]);const z=s("computer.viewerTitle",{name:R}),A=e.jsxs("span",{className:"pointer-events-none flex items-center gap-1.5 rounded-full bg-black/70 px-2.5 py-1 text-[11px] font-medium text-white shadow-sm",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-success","aria-hidden":"true"}),s("computer.inControl")]}),d="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-50";return e.jsxs("div",{"data-live-desktop":!0,"data-state":i,"data-expanded":r?"true":void 0,className:o(r?"fixed inset-0 z-[65] flex flex-col bg-app":"relative h-full w-full"),onKeyDown:t=>{r&&t.key==="Escape"&&!(t.target instanceof HTMLCanvasElement)&&h(!1)},children:[r&&e.jsxs("header",{...L,className:o("flex shrink-0 flex-wrap items-center gap-2 border-b border-hairline/40 bg-panel px-3 py-2",T&&"pl-[86px]"),children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-medium text-ink",children:z}),A,e.jsxs("form",{style:u,className:"ml-auto flex min-w-0 items-center gap-1",onSubmit:t=>{t.preventDefault(),!(!a.current||i!=="connected"||!l)&&(M(a.current,l),y(""))},children:[e.jsx("input",{value:l,onChange:t=>y(t.target.value),maxLength:4096,autoComplete:"off",autoCapitalize:"off",spellCheck:!1,placeholder:s("desktopViewer.text"),"aria-label":s("desktopViewer.text"),className:"w-44 min-w-0 rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[12px] text-ink outline-none focus:border-focus max-sm:w-28"}),e.jsx("button",{type:"submit",disabled:i!=="connected"||!l,title:s("desktopViewer.send"),"aria-label":s("desktopViewer.send"),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:e.jsx(K,{size:14,"aria-hidden":"true"})})]}),e.jsxs("button",{type:"button",style:u,onClick:()=>h(!1),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:[e.jsx(P,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-sm:hidden",children:s("desktopViewer.exitFullscreen")})]}),e.jsxs("button",{type:"button",style:u,onClick:E,disabled:g,className:o(d,"bg-accent font-medium text-accent-ink hover:brightness-110"),children:[g?e.jsx(D,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(Q,{size:14,"aria-hidden":"true"}),s("computer.handBack")]})]}),e.jsxs("div",{className:o("relative overflow-hidden bg-inset",r?"min-h-0 flex-1":"h-full w-full"),children:[b&&i!=="connected"&&e.jsx("img",{src:b,alt:"","aria-hidden":"true",className:"absolute inset-0 h-full w-full object-contain opacity-50"}),e.jsx("div",{ref:j,role:"application","aria-label":z,className:"absolute inset-0"}),i==="connecting"&&e.jsxs("div",{role:"status",className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx(D,{size:16,className:"animate-spin","aria-hidden":"true"}),s("desktopViewer.connecting")]}),i==="disconnected"&&e.jsxs("div",{role:"alert",className:"absolute inset-x-0 bottom-0 flex flex-col items-center gap-2 bg-card/95 p-3 text-center text-[12px] text-ink-secondary",children:[e.jsx("span",{children:s("desktopViewer.disconnected")}),e.jsxs("button",{type:"button",onClick:()=>w(t=>t+1),className:"flex items-center gap-1.5 rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:[e.jsx(O,{size:13,"aria-hidden":"true"}),s("desktopViewer.reconnect")]})]})]})]})}export{Z as LiveDesktop};
1
+ import{r as n,t as s,j as e,a as o}from"./styles-GmtHzqPG.js";import{c as H,t as M}from"./desktop-connection-Dfaq6k5a.js";import{u as B,d as F,L as D}from"./PlacesRail-BJBF_akb.js";import{S as K,R as O}from"./MenuMotion-nTkCdPNb.js";import{Q as P,U as Q}from"./App-DqXMyMLs.js";import"./desktop-viewer-CF-OpSo0.js";import"./monitor-Chdrm5wS.js";import"./index-BfvuKok1.js";function Z({target:x,threadId:f,name:R,poster:b,expanded:r,onExpandedChange:h,onHandBack:E,handingBack:g,onUnreachable:v}){const j=n.useRef(null),a=n.useRef(null),[i,c]=n.useState("connecting"),[k,w]=n.useState(0),[l,y]=n.useState(""),N=n.useRef(!1),{dragProps:L,noDragStyle:u}=B(),T=F().capabilities.windowChrome==="mac-inset",C=n.useRef(v);C.current=v,n.useEffect(()=>{const t=new AbortController;let p,S;const V=()=>{c("disconnected"),N.current?k===0&&(S=setTimeout(()=>w(1),1e3)):C.current()};return c("connecting"),H(j.current,x,{threadId:f,signal:t.signal,events:{connected:()=>{N.current=!0,c("connected")},disconnected:V}}).then(m=>{if(t.signal.aborted)return m.disconnect();p=m,a.current=m},()=>{t.signal.aborted||V()}),()=>{t.abort(),clearTimeout(S),p?.disconnect(),a.current===p&&(a.current=null)}},[x,f,k]),n.useEffect(()=>{i==="connected"&&a.current?.focus({preventScroll:!0})},[r,i]);const z=s("computer.viewerTitle",{name:R}),A=e.jsxs("span",{className:"pointer-events-none flex items-center gap-1.5 rounded-full bg-black/70 px-2.5 py-1 text-[11px] font-medium text-white shadow-sm",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-success","aria-hidden":"true"}),s("computer.inControl")]}),d="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-50";return e.jsxs("div",{"data-live-desktop":!0,"data-state":i,"data-expanded":r?"true":void 0,className:o(r?"fixed inset-0 z-[65] flex flex-col bg-app":"relative h-full w-full"),onKeyDown:t=>{r&&t.key==="Escape"&&!(t.target instanceof HTMLCanvasElement)&&h(!1)},children:[r&&e.jsxs("header",{...L,className:o("flex shrink-0 flex-wrap items-center gap-2 border-b border-hairline/40 bg-panel px-3 py-2",T&&"pl-[86px]"),children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-medium text-ink",children:z}),A,e.jsxs("form",{style:u,className:"ml-auto flex min-w-0 items-center gap-1",onSubmit:t=>{t.preventDefault(),!(!a.current||i!=="connected"||!l)&&(M(a.current,l),y(""))},children:[e.jsx("input",{value:l,onChange:t=>y(t.target.value),maxLength:4096,autoComplete:"off",autoCapitalize:"off",spellCheck:!1,placeholder:s("desktopViewer.text"),"aria-label":s("desktopViewer.text"),className:"w-44 min-w-0 rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[12px] text-ink outline-none focus:border-focus max-sm:w-28"}),e.jsx("button",{type:"submit",disabled:i!=="connected"||!l,title:s("desktopViewer.send"),"aria-label":s("desktopViewer.send"),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:e.jsx(K,{size:14,"aria-hidden":"true"})})]}),e.jsxs("button",{type:"button",style:u,onClick:()=>h(!1),className:o(d,"bg-control text-ink hover:bg-raised-hover"),children:[e.jsx(P,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-sm:hidden",children:s("desktopViewer.exitFullscreen")})]}),e.jsxs("button",{type:"button",style:u,onClick:E,disabled:g,className:o(d,"bg-accent font-medium text-accent-ink hover:brightness-110"),children:[g?e.jsx(D,{size:14,className:"animate-spin","aria-hidden":"true"}):e.jsx(Q,{size:14,"aria-hidden":"true"}),s("computer.handBack")]})]}),e.jsxs("div",{className:o("relative overflow-hidden bg-inset",r?"min-h-0 flex-1":"h-full w-full"),children:[b&&i!=="connected"&&e.jsx("img",{src:b,alt:"","aria-hidden":"true",className:"absolute inset-0 h-full w-full object-contain opacity-50"}),e.jsx("div",{ref:j,role:"application","aria-label":z,className:"absolute inset-0"}),i==="connecting"&&e.jsxs("div",{role:"status",className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx(D,{size:16,className:"animate-spin","aria-hidden":"true"}),s("desktopViewer.connecting")]}),i==="disconnected"&&e.jsxs("div",{role:"alert",className:"absolute inset-x-0 bottom-0 flex flex-col items-center gap-2 bg-card/95 p-3 text-center text-[12px] text-ink-secondary",children:[e.jsx("span",{children:s("desktopViewer.disconnected")}),e.jsxs("button",{type:"button",onClick:()=>w(t=>t+1),className:"flex items-center gap-1.5 rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:[e.jsx(O,{size:13,"aria-hidden":"true"}),s("desktopViewer.reconnect")]})]})]})]})}export{Z as LiveDesktop};
@@ -1 +1 @@
1
- import{t as l,r as i,p as ve,j as c,X as he,a as Q}from"./styles-DSEcltf1.js";import{u as we,W as xe,X as ee,Y as ae,n as q,D as be,U as te,Z as ke}from"./App-BV7lfvAV.js";import{o as ce,s as ie,e as O,_ as W,n as ye,u as ge,L as T,f as Ne}from"./PlacesRail-Bpjyw4Vm.js";import{M as le}from"./monitor-Xr0SgoUO.js";import{R as Ce}from"./MenuMotion-DQYRi6n6.js";import"./index-BUpSDhKQ.js";function je(s,e){const u=(n,o)=>n.left<o.right&&n.right>o.left&&n.top<o.bottom&&n.bottom>o.top;return e.some(n=>n.visible&&n.rect.width>0&&n.rect.height>0&&(n.explicit||n.zIndex!==null&&n.zIndex>=10)&&s.some(o=>u(n.rect,o)))}async function Se(s,e,u,n){e&&e!==u&&(await s.setInteractive(null),await s.release(e));const o=await s.take(u);if(!o.held)throw new Error(l("vm.workspace.holdNotAcquired"));if(o.owned!==!0)return{status:"held-elsewhere",botId:u,snapshot:o};try{await s.setInteractive(n)}catch(d){throw await s.setInteractive(null).catch(()=>{}),await s.release(u).catch(()=>{}),d}return{status:"controlled",botId:u,snapshot:o}}async function $(s,e){return e?(await s.setInteractive(null).catch(()=>{}),s.release(e)):null}function ue(s){return s.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function Ee(s,e){const u=ue(s),n=u.includes(e)?e:u[0]??null;return[n,u.find(o=>o!==n)??null]}function Re(s,e,u){const n=[...s],o=e===0?1:0;return u&&n[o]===u&&(n[o]=n[e]),n[e]=u,n}function Le(s,e){const u=ue(e),n=new Set(u),o=[null,null];for(const d of[0,1]){const m=s[d];m&&n.delete(m)&&(o[d]=m)}for(const d of[0,1]){if(o[d])continue;const m=[...n][0];m&&(o[d]=m,n.delete(m))}return o}const ze=ce({mode:W(["shared","per-bot","pool"]).optional(),max_instances:ye().int().positive().optional(),container:W(["running","stopped","missing"]).optional(),network:W(["loopback","unsafe","unknown"]).optional(),security:W(["hardened","unsafe","unknown"]).optional(),persistence:W(["durable","unsafe","unknown"]).optional(),desktopReady:O().optional(),ready:O().optional(),viewer_url:ie().min(1).optional()});function de(s){const e=ze.safeParse(s);return e.success?e.data:null}function H(s){const e=de(s),u=e?.mode??"unknown",n=e?.container??"unknown",o=e?.network??"unknown",d=e?.security??"unknown",m=e?.persistence??"unknown",w=e?.max_instances??0,h=e?.desktopReady===!0,x=!!(e?.ready===!0&&n==="running"&&o==="loopback"&&d==="hardened"&&m==="durable"&&h);return{mode:u,maxInstances:w,container:n,network:o,security:d,persistence:m,desktopReady:h,ready:x}}function Ve(s){const e=de(s);return!e||!H(s).ready?null:e.viewer_url??null}const X=["local-vm-workspace:left","local-vm-workspace:right"],pe=ce({held:O(),helpReason:ie().nullable(),help:Ne().optional().transform(ke),owned:O().optional(),acquired:O().optional(),released:O().optional()});async function ne(s,e,u){const n=await q(`/api/bots/${s}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:u})}),o=pe.safeParse(n);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function Oe(s){const e=pe.safeParse(await q(`/api/bots/${s}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function re(s,e){fetch(`/api/bots/${s}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async u=>{u.ok}).catch(()=>{})}async function se(s,e){return!0}function D(s,e,u){s({type:"computerControl",botId:e,held:u.held,helpReason:u.helpReason,help:u.help??null})}function oe(s){const e=s.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Be=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Ie(){const s=[...document.querySelectorAll("[data-native-view-host]")],e=s.map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0);if(e.length===0)return!1;const u=[...document.querySelectorAll(Be)].filter(n=>!s.some(o=>n===o||n.contains(o)||o.contains(n))).map(n=>{const o=window.getComputedStyle(n),d=n.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),m=Number.parseInt(o.zIndex,10);return{rect:n.getBoundingClientRect(),explicit:d,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(m)?m:null}});return je(e,u)}function We(s){const[e,u]=i.useState(!1);return i.useEffect(()=>{let n=0;const o=()=>u(Ie()),d=()=>{n||(n=requestAnimationFrame(()=>{n=0,o()}))};o();const m=new MutationObserver(d);m.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const w=new ResizeObserver(d);w.observe(document.body);for(const x of document.querySelectorAll("[data-native-view-host]"))w.observe(x);const h=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const x of h)document.addEventListener(x,d,!0);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{n&&cancelAnimationFrame(n),m.disconnect(),w.disconnect();for(const x of h)document.removeEventListener(x,d,!0);window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[]),s||e}function _e(s,e){return s?s.container==="missing"?l("vm.workspace.status.missing"):s.container==="stopped"?l("vm.workspace.status.stopped"):s.ready?e==="error"?l("vm.workspace.status.viewerUnavailable"):e!=="ready"?l("vm.workspace.status.connecting"):l("vm.workspace.status.live"):l("vm.workspace.status.unavailable"):l("vm.workspace.status.checking")}function Ae({index:s,bot:e,bots:u,otherBotId:n,obscured:o,active:d,heldElsewhere:m,controlPending:w,onSelect:h,onTake:x,onRelease:B,onOpenComputer:_}){const v=X[s],p=e?.id??null,I=e?.name??l("vm.workspace.localVm"),b=i.useRef(null),k=i.useRef(Promise.resolve()),z=i.useRef(o),[A,V]=i.useState(0),[j,N]=i.useState(null),[C,y]=i.useState({contextId:v,open:!1,status:"closed",interactive:!1}),[E,g]=i.useState(null),R=i.useCallback(async t=>{if(p)try{const a=await q(`/api/bots/${p}/local-computer`,{signal:t});t?.aborted||N(H(a))}catch{}},[p]),F=i.useRef(R);i.useEffect(()=>{F.current=R},[R]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(a=>{a.contextId===v&&(y(a),(a.status==="error"||a.status==="closed")&&F.current())}),[v]),i.useEffect(()=>{const t=window.ogb?.desktopWorkspace;let a=!0;const f=new AbortController;N(null),g(null),y({contextId:v,open:!1,status:"closed",interactive:!1});const M=async()=>{if(t&&await t.close(v).catch(()=>{}),!(!a||!p)){if(!t){g(l("vm.workspace.desktopRequired"));return}try{const S=await q(`/api/bots/${p}/local-computer`,{signal:f.signal});if(!a)return;const J=H(S);N(J);const Y=Ve(S);if(!J.ready||!Y||(await new Promise(me=>{let G=!1;const K=()=>{G||(G=!0,me())},fe=setTimeout(K,100);requestAnimationFrame(()=>{clearTimeout(fe),K()})}),!a))return;const U=oe(b);if(!U)throw new Error("layout-unavailable");const Z=await t.open({contextId:v,url:Y,title:l("vm.workspace.windowTitle",{name:I}),bounds:U});if(!a){await t.close(v).catch(()=>{});return}y(Z),await t.layout([{contextId:v,bounds:U,visible:!z.current&&Z.open}])}catch(S){if(!a||f.signal.aborted)return;g(S instanceof Error&&S.message==="layout-unavailable"?l("vm.workspace.layoutUnavailable"):l("vm.workspace.connectFailed"))}}};return k.current=k.current.catch(()=>{}).then(M),()=>{a=!1,f.abort(),t&&(k.current=k.current.catch(()=>{}).then(()=>t.close(v).then(()=>{}).catch(()=>{})))}},[p,I,v,A]),i.useEffect(()=>{if(!p)return;const t=new AbortController,a=window.setInterval(()=>{R(t.signal)},3e4);return()=>{t.abort(),window.clearInterval(a)}},[p,R]);const L=i.useCallback(()=>{const t=window.ogb?.desktopWorkspace,a=oe(b);!t||!a||!C.open||t.layout([{contextId:v,bounds:a,visible:!o}]).catch(()=>g(l("vm.workspace.positionFailed")))},[v,C.open,o]);i.useEffect(()=>{const t=b.current;if(!t)return;const a=new ResizeObserver(L);a.observe(t),window.addEventListener("resize",L);const f=requestAnimationFrame(L);return()=>{cancelAnimationFrame(f),a.disconnect(),window.removeEventListener("resize",L)}},[L]);const P=_e(j,C.status),r=!!(e&&j?.ready&&C.status==="ready"&&C.open);return c.jsxs("section",{className:Q("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",d?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[c.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("label",{className:"sr-only",htmlFor:`local-vm-slot-${s}`,children:l("vm.workspace.paneLabel",{number:s+1})}),c.jsxs(be,{size:"sm",className:"w-full",id:`local-vm-slot-${s}`,value:e?.id??"",onChange:t=>h(t.target.value||null),disabled:w,children:[c.jsx("option",{value:"",children:l("vm.workspace.chooseBot")}),u.map(t=>c.jsx("option",{value:t.id,disabled:t.id===n,children:t.name},t.id))]}),c.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[c.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",d?"bg-accent":C.status==="ready"?"bg-success":C.status==="error"?"bg-danger":"bg-ink-secondary/50")}),d?l("vm.workspace.youHaveControl"):m?l("vm.workspace.controlElsewhere"):P]})]}),e&&d?c.jsxs("button",{type:"button",onClick:B,disabled:w,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),l("vm.workspace.handBack")]}):e?c.jsxs("button",{type:"button",onClick:()=>x(e.id),disabled:!r||w||m,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:l("vm.workspace.takeControlTitle"),children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),m?l("vm.workspace.heldElsewhere"):l("vm.workspace.takeControl")]}):null]}),c.jsx("div",{ref:b,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:c.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!j&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.checking",{name:e.name})]}):j?.ready&&C.status!=="error"&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.connecting")]}):c.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[c.jsx(ae,{size:21,className:"text-warning"}),c.jsx("div",{className:"text-[12px] leading-relaxed",children:E??(j?.container==="missing"?l("vm.workspace.notCreated",{name:e.name}):j?.container==="stopped"?l("vm.workspace.stopped",{name:e.name}):l("vm.workspace.notReady",{name:e.name}))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:()=>V(t=>t+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[c.jsx(Ce,{size:13})," ",l("vm.workspace.retryStatus")]}),c.jsx("button",{type:"button",onClick:()=>_(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:l("vm.workspace.openComputer")})]})]}):c.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[c.jsx(le,{size:22}),c.jsx("span",{className:"text-[12px]",children:l("vm.workspace.chooseAnother")})]})})})]})}function $e({primaryBotId:s,overlayOpen:e,onClose:u,onOpenComputer:n}){const{state:o,dispatch:d}=we(),{dragProps:m}=ge(),w=i.useMemo(()=>o.bots.filter(r=>r.computer==="vm"&&!r.hidden),[o.bots]),[h,x]=i.useState(()=>Ee(o.bots,s)),B=i.useRef(h),[_,v]=i.useState(null),p=i.useRef(null),I=i.useRef(null),b=I.current??xe();I.current=b;const k=i.useRef(!1),z=i.useRef(!0),[A,V]=i.useState(!1),[j,N]=i.useState(null),C=We(e);i.useEffect(()=>{B.current=h},[h]);const y=i.useMemo(()=>({async take(r){const t=await ee({action:"take",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return D(d,r,t),t.held&&t.owned===!0?p.current=r:p.current===r&&(p.current=null),t},async release(r){const t=await ee({action:"release",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return D(d,r,t),p.current===r&&(p.current=null),t},async setInteractive(r){const t=window.ogb?.desktopWorkspace;if(!t)throw new Error(l("vm.workspace.bridgeUnavailable"));return t.setInteractive(r)}}),[b,d]);i.useEffect(()=>{x(r=>{const t=Le(r,o.bots);return t[0]===r[0]&&t[1]===r[1]?r:t})},[o.bots]),i.useEffect(()=>{let r=!0;return(async()=>{for(const a of h)if(a)try{const f=await Oe(a);r&&D(d,a,f)}catch{}})(),()=>{r=!1}},[d,h]),i.useEffect(()=>{const r=p.current;!r||h.includes(r)||$(y,r).then(()=>{v(null)}).catch(()=>{N(l("vm.workspace.handoffFailed"))})},[y,h]),i.useEffect(()=>(z.current=!0,()=>{z.current=!1;const r=p.current,t=window.ogb?.desktopWorkspace;if(!t){r&&re(r,b);return}t.setInteractive(null).catch(()=>{}).then(()=>(r&&re(r,b),t.close())).catch(()=>{})}),[b]);const E=i.useCallback(r=>{const t=B.current.indexOf(r);return t<0?null:X[t]},[]),g=i.useCallback(async()=>{const r=p.current;if(!r)return!0;if(k.current)return!1;k.current=!0,V(!0),N(null);try{return await $(y,r),v(null),!0}catch{return N(l("vm.workspace.handBackFailed",{app:ve()})),!1}finally{k.current=!1,V(!1)}},[y]),R=i.useCallback(async r=>{if(k.current||p.current===r)return;const t=window.ogb?.desktopWorkspace,a=E(r);if(!(!t||!a)){k.current=!0,V(!0),N(null);try{const f={...y,async setInteractive(S){if(S&&E(r)!==S)throw new Error(l("vm.workspace.paneChanged"));return y.setInteractive(S)}},M=await Se(f,p.current,r,a);if(v(null),M.status==="held-elsewhere"){N(l("vm.workspace.alreadyControlled"));return}if(!z.current){await $(y,r).catch(()=>{});return}v(r)}catch{v(p.current),N(l("vm.workspace.switchFailed"))}finally{k.current=!1,V(!1)}}},[E,y]),F=i.useCallback(async(r,t)=>{if(k.current)return;const a=B.current[r];a!==t&&(a&&p.current===a&&!await g()||x(f=>Re(f,r,t)))},[g]),L=i.useCallback(async()=>{p.current&&!await g()||u()},[g,u]),P=i.useCallback(async r=>{p.current&&!await g()||n(r)},[g,n]);return c.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[c.jsxs("header",{...m,className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:c.jsx(le,{size:18})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:l("vm.workspace.viewTitle")}),c.jsx("p",{className:"truncate text-[12px] text-ink-secondary",children:l("vm.workspace.viewSubtitle")})]}),c.jsx("button",{type:"button",onClick:()=>{L()},disabled:A,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":l("vm.workspace.closeView"),children:c.jsx(he,{size:18})})]}),j&&c.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[c.jsx(ae,{size:14,className:"shrink-0"})," ",j]}),c.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(r=>{const t=h[r],a=w.find(f=>f.id===t)??null;return c.jsx(Ae,{index:r,bot:a,bots:w,otherBotId:h[r===0?1:0],obscured:C,active:!!(a&&_===a.id),heldElsewhere:!!(a&&o.computerControl[a.id]?.held&&_!==a.id),controlPending:A,onSelect:f=>{F(r,f)},onTake:f=>{R(f)},onRelease:()=>{g()},onOpenComputer:f=>{P(f)}},X[r])})})]})}export{$e as LocalVmWorkspace};
1
+ import{t as l,r as i,p as ve,j as c,X as he,a as Q}from"./styles-GmtHzqPG.js";import{u as we,W as xe,X as ee,Y as ae,n as q,D as be,U as te,Z as ke}from"./App-DqXMyMLs.js";import{o as ce,s as ie,e as O,_ as W,n as ye,u as ge,L as T,f as Ne}from"./PlacesRail-BJBF_akb.js";import{M as le}from"./monitor-Chdrm5wS.js";import{R as Ce}from"./MenuMotion-nTkCdPNb.js";import"./index-BfvuKok1.js";function je(s,e){const u=(n,o)=>n.left<o.right&&n.right>o.left&&n.top<o.bottom&&n.bottom>o.top;return e.some(n=>n.visible&&n.rect.width>0&&n.rect.height>0&&(n.explicit||n.zIndex!==null&&n.zIndex>=10)&&s.some(o=>u(n.rect,o)))}async function Se(s,e,u,n){e&&e!==u&&(await s.setInteractive(null),await s.release(e));const o=await s.take(u);if(!o.held)throw new Error(l("vm.workspace.holdNotAcquired"));if(o.owned!==!0)return{status:"held-elsewhere",botId:u,snapshot:o};try{await s.setInteractive(n)}catch(d){throw await s.setInteractive(null).catch(()=>{}),await s.release(u).catch(()=>{}),d}return{status:"controlled",botId:u,snapshot:o}}async function $(s,e){return e?(await s.setInteractive(null).catch(()=>{}),s.release(e)):null}function ue(s){return s.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function Ee(s,e){const u=ue(s),n=u.includes(e)?e:u[0]??null;return[n,u.find(o=>o!==n)??null]}function Re(s,e,u){const n=[...s],o=e===0?1:0;return u&&n[o]===u&&(n[o]=n[e]),n[e]=u,n}function Le(s,e){const u=ue(e),n=new Set(u),o=[null,null];for(const d of[0,1]){const m=s[d];m&&n.delete(m)&&(o[d]=m)}for(const d of[0,1]){if(o[d])continue;const m=[...n][0];m&&(o[d]=m,n.delete(m))}return o}const ze=ce({mode:W(["shared","per-bot","pool"]).optional(),max_instances:ye().int().positive().optional(),container:W(["running","stopped","missing"]).optional(),network:W(["loopback","unsafe","unknown"]).optional(),security:W(["hardened","unsafe","unknown"]).optional(),persistence:W(["durable","unsafe","unknown"]).optional(),desktopReady:O().optional(),ready:O().optional(),viewer_url:ie().min(1).optional()});function de(s){const e=ze.safeParse(s);return e.success?e.data:null}function H(s){const e=de(s),u=e?.mode??"unknown",n=e?.container??"unknown",o=e?.network??"unknown",d=e?.security??"unknown",m=e?.persistence??"unknown",w=e?.max_instances??0,h=e?.desktopReady===!0,x=!!(e?.ready===!0&&n==="running"&&o==="loopback"&&d==="hardened"&&m==="durable"&&h);return{mode:u,maxInstances:w,container:n,network:o,security:d,persistence:m,desktopReady:h,ready:x}}function Ve(s){const e=de(s);return!e||!H(s).ready?null:e.viewer_url??null}const X=["local-vm-workspace:left","local-vm-workspace:right"],pe=ce({held:O(),helpReason:ie().nullable(),help:Ne().optional().transform(ke),owned:O().optional(),acquired:O().optional(),released:O().optional()});async function ne(s,e,u){const n=await q(`/api/bots/${s}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:u})}),o=pe.safeParse(n);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function Oe(s){const e=pe.safeParse(await q(`/api/bots/${s}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function re(s,e){fetch(`/api/bots/${s}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async u=>{u.ok}).catch(()=>{})}async function se(s,e){return!0}function D(s,e,u){s({type:"computerControl",botId:e,held:u.held,helpReason:u.helpReason,help:u.help??null})}function oe(s){const e=s.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Be=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Ie(){const s=[...document.querySelectorAll("[data-native-view-host]")],e=s.map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0);if(e.length===0)return!1;const u=[...document.querySelectorAll(Be)].filter(n=>!s.some(o=>n===o||n.contains(o)||o.contains(n))).map(n=>{const o=window.getComputedStyle(n),d=n.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),m=Number.parseInt(o.zIndex,10);return{rect:n.getBoundingClientRect(),explicit:d,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(m)?m:null}});return je(e,u)}function We(s){const[e,u]=i.useState(!1);return i.useEffect(()=>{let n=0;const o=()=>u(Ie()),d=()=>{n||(n=requestAnimationFrame(()=>{n=0,o()}))};o();const m=new MutationObserver(d);m.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const w=new ResizeObserver(d);w.observe(document.body);for(const x of document.querySelectorAll("[data-native-view-host]"))w.observe(x);const h=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const x of h)document.addEventListener(x,d,!0);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{n&&cancelAnimationFrame(n),m.disconnect(),w.disconnect();for(const x of h)document.removeEventListener(x,d,!0);window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[]),s||e}function _e(s,e){return s?s.container==="missing"?l("vm.workspace.status.missing"):s.container==="stopped"?l("vm.workspace.status.stopped"):s.ready?e==="error"?l("vm.workspace.status.viewerUnavailable"):e!=="ready"?l("vm.workspace.status.connecting"):l("vm.workspace.status.live"):l("vm.workspace.status.unavailable"):l("vm.workspace.status.checking")}function Ae({index:s,bot:e,bots:u,otherBotId:n,obscured:o,active:d,heldElsewhere:m,controlPending:w,onSelect:h,onTake:x,onRelease:B,onOpenComputer:_}){const v=X[s],p=e?.id??null,I=e?.name??l("vm.workspace.localVm"),b=i.useRef(null),k=i.useRef(Promise.resolve()),z=i.useRef(o),[A,V]=i.useState(0),[j,N]=i.useState(null),[C,y]=i.useState({contextId:v,open:!1,status:"closed",interactive:!1}),[E,g]=i.useState(null),R=i.useCallback(async t=>{if(p)try{const a=await q(`/api/bots/${p}/local-computer`,{signal:t});t?.aborted||N(H(a))}catch{}},[p]),F=i.useRef(R);i.useEffect(()=>{F.current=R},[R]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(a=>{a.contextId===v&&(y(a),(a.status==="error"||a.status==="closed")&&F.current())}),[v]),i.useEffect(()=>{const t=window.ogb?.desktopWorkspace;let a=!0;const f=new AbortController;N(null),g(null),y({contextId:v,open:!1,status:"closed",interactive:!1});const M=async()=>{if(t&&await t.close(v).catch(()=>{}),!(!a||!p)){if(!t){g(l("vm.workspace.desktopRequired"));return}try{const S=await q(`/api/bots/${p}/local-computer`,{signal:f.signal});if(!a)return;const J=H(S);N(J);const Y=Ve(S);if(!J.ready||!Y||(await new Promise(me=>{let G=!1;const K=()=>{G||(G=!0,me())},fe=setTimeout(K,100);requestAnimationFrame(()=>{clearTimeout(fe),K()})}),!a))return;const U=oe(b);if(!U)throw new Error("layout-unavailable");const Z=await t.open({contextId:v,url:Y,title:l("vm.workspace.windowTitle",{name:I}),bounds:U});if(!a){await t.close(v).catch(()=>{});return}y(Z),await t.layout([{contextId:v,bounds:U,visible:!z.current&&Z.open}])}catch(S){if(!a||f.signal.aborted)return;g(S instanceof Error&&S.message==="layout-unavailable"?l("vm.workspace.layoutUnavailable"):l("vm.workspace.connectFailed"))}}};return k.current=k.current.catch(()=>{}).then(M),()=>{a=!1,f.abort(),t&&(k.current=k.current.catch(()=>{}).then(()=>t.close(v).then(()=>{}).catch(()=>{})))}},[p,I,v,A]),i.useEffect(()=>{if(!p)return;const t=new AbortController,a=window.setInterval(()=>{R(t.signal)},3e4);return()=>{t.abort(),window.clearInterval(a)}},[p,R]);const L=i.useCallback(()=>{const t=window.ogb?.desktopWorkspace,a=oe(b);!t||!a||!C.open||t.layout([{contextId:v,bounds:a,visible:!o}]).catch(()=>g(l("vm.workspace.positionFailed")))},[v,C.open,o]);i.useEffect(()=>{const t=b.current;if(!t)return;const a=new ResizeObserver(L);a.observe(t),window.addEventListener("resize",L);const f=requestAnimationFrame(L);return()=>{cancelAnimationFrame(f),a.disconnect(),window.removeEventListener("resize",L)}},[L]);const P=_e(j,C.status),r=!!(e&&j?.ready&&C.status==="ready"&&C.open);return c.jsxs("section",{className:Q("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",d?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[c.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("label",{className:"sr-only",htmlFor:`local-vm-slot-${s}`,children:l("vm.workspace.paneLabel",{number:s+1})}),c.jsxs(be,{size:"sm",className:"w-full",id:`local-vm-slot-${s}`,value:e?.id??"",onChange:t=>h(t.target.value||null),disabled:w,children:[c.jsx("option",{value:"",children:l("vm.workspace.chooseBot")}),u.map(t=>c.jsx("option",{value:t.id,disabled:t.id===n,children:t.name},t.id))]}),c.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[c.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",d?"bg-accent":C.status==="ready"?"bg-success":C.status==="error"?"bg-danger":"bg-ink-secondary/50")}),d?l("vm.workspace.youHaveControl"):m?l("vm.workspace.controlElsewhere"):P]})]}),e&&d?c.jsxs("button",{type:"button",onClick:B,disabled:w,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),l("vm.workspace.handBack")]}):e?c.jsxs("button",{type:"button",onClick:()=>x(e.id),disabled:!r||w||m,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:l("vm.workspace.takeControlTitle"),children:[w?c.jsx(T,{size:13,className:"animate-spin"}):c.jsx(te,{size:13}),m?l("vm.workspace.heldElsewhere"):l("vm.workspace.takeControl")]}):null]}),c.jsx("div",{ref:b,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:c.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!j&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.checking",{name:e.name})]}):j?.ready&&C.status!=="error"&&!E?c.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[c.jsx(T,{size:15,className:"animate-spin"})," ",l("vm.workspace.connecting")]}):c.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[c.jsx(ae,{size:21,className:"text-warning"}),c.jsx("div",{className:"text-[12px] leading-relaxed",children:E??(j?.container==="missing"?l("vm.workspace.notCreated",{name:e.name}):j?.container==="stopped"?l("vm.workspace.stopped",{name:e.name}):l("vm.workspace.notReady",{name:e.name}))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:()=>V(t=>t+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[c.jsx(Ce,{size:13})," ",l("vm.workspace.retryStatus")]}),c.jsx("button",{type:"button",onClick:()=>_(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:l("vm.workspace.openComputer")})]})]}):c.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[c.jsx(le,{size:22}),c.jsx("span",{className:"text-[12px]",children:l("vm.workspace.chooseAnother")})]})})})]})}function $e({primaryBotId:s,overlayOpen:e,onClose:u,onOpenComputer:n}){const{state:o,dispatch:d}=we(),{dragProps:m}=ge(),w=i.useMemo(()=>o.bots.filter(r=>r.computer==="vm"&&!r.hidden),[o.bots]),[h,x]=i.useState(()=>Ee(o.bots,s)),B=i.useRef(h),[_,v]=i.useState(null),p=i.useRef(null),I=i.useRef(null),b=I.current??xe();I.current=b;const k=i.useRef(!1),z=i.useRef(!0),[A,V]=i.useState(!1),[j,N]=i.useState(null),C=We(e);i.useEffect(()=>{B.current=h},[h]);const y=i.useMemo(()=>({async take(r){const t=await ee({action:"take",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return D(d,r,t),t.held&&t.owned===!0?p.current=r:p.current===r&&(p.current=null),t},async release(r){const t=await ee({action:"release",syncNativeBrowser:!0,requestControl:a=>ne(r,a,b),setNativeBrowserControl:a=>se()});return D(d,r,t),p.current===r&&(p.current=null),t},async setInteractive(r){const t=window.ogb?.desktopWorkspace;if(!t)throw new Error(l("vm.workspace.bridgeUnavailable"));return t.setInteractive(r)}}),[b,d]);i.useEffect(()=>{x(r=>{const t=Le(r,o.bots);return t[0]===r[0]&&t[1]===r[1]?r:t})},[o.bots]),i.useEffect(()=>{let r=!0;return(async()=>{for(const a of h)if(a)try{const f=await Oe(a);r&&D(d,a,f)}catch{}})(),()=>{r=!1}},[d,h]),i.useEffect(()=>{const r=p.current;!r||h.includes(r)||$(y,r).then(()=>{v(null)}).catch(()=>{N(l("vm.workspace.handoffFailed"))})},[y,h]),i.useEffect(()=>(z.current=!0,()=>{z.current=!1;const r=p.current,t=window.ogb?.desktopWorkspace;if(!t){r&&re(r,b);return}t.setInteractive(null).catch(()=>{}).then(()=>(r&&re(r,b),t.close())).catch(()=>{})}),[b]);const E=i.useCallback(r=>{const t=B.current.indexOf(r);return t<0?null:X[t]},[]),g=i.useCallback(async()=>{const r=p.current;if(!r)return!0;if(k.current)return!1;k.current=!0,V(!0),N(null);try{return await $(y,r),v(null),!0}catch{return N(l("vm.workspace.handBackFailed",{app:ve()})),!1}finally{k.current=!1,V(!1)}},[y]),R=i.useCallback(async r=>{if(k.current||p.current===r)return;const t=window.ogb?.desktopWorkspace,a=E(r);if(!(!t||!a)){k.current=!0,V(!0),N(null);try{const f={...y,async setInteractive(S){if(S&&E(r)!==S)throw new Error(l("vm.workspace.paneChanged"));return y.setInteractive(S)}},M=await Se(f,p.current,r,a);if(v(null),M.status==="held-elsewhere"){N(l("vm.workspace.alreadyControlled"));return}if(!z.current){await $(y,r).catch(()=>{});return}v(r)}catch{v(p.current),N(l("vm.workspace.switchFailed"))}finally{k.current=!1,V(!1)}}},[E,y]),F=i.useCallback(async(r,t)=>{if(k.current)return;const a=B.current[r];a!==t&&(a&&p.current===a&&!await g()||x(f=>Re(f,r,t)))},[g]),L=i.useCallback(async()=>{p.current&&!await g()||u()},[g,u]),P=i.useCallback(async r=>{p.current&&!await g()||n(r)},[g,n]);return c.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[c.jsxs("header",{...m,className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:c.jsx(le,{size:18})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:l("vm.workspace.viewTitle")}),c.jsx("p",{className:"truncate text-[12px] text-ink-secondary",children:l("vm.workspace.viewSubtitle")})]}),c.jsx("button",{type:"button",onClick:()=>{L()},disabled:A,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":l("vm.workspace.closeView"),children:c.jsx(he,{size:18})})]}),j&&c.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[c.jsx(ae,{size:14,className:"shrink-0"})," ",j]}),c.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(r=>{const t=h[r],a=w.find(f=>f.id===t)??null;return c.jsx(Ae,{index:r,bot:a,bots:w,otherBotId:h[r===0?1:0],obscured:C,active:!!(a&&_===a.id),heldElsewhere:!!(a&&o.computerControl[a.id]?.held&&_!==a.id),controlPending:A,onSelect:f=>{F(r,f)},onTake:f=>{R(f)},onRelease:()=>{g()},onOpenComputer:f=>{P(f)}},X[r])})})]})}export{$e as LocalVmWorkspace};
@@ -1 +1 @@
1
- import{c as v,t as n,r as u,j as t}from"./styles-DSEcltf1.js";import{d as L,L as k}from"./PlacesRail-Bpjyw4Vm.js";import{bg as C,bh as j,Y as N,bi as M,bj as S}from"./App-BV7lfvAV.js";const E=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],T=v("shield",E);async function I(e,r,s,i=6e4){const o=Date.now()+i;let c=e;for(;!c.ready&&c.container==="running"&&Date.now()<o;)s.throwIfAborted(),await new Promise((p,d)=>{const m=()=>{window.clearTimeout(l),d(s.reason)},l=window.setTimeout(()=>{s.removeEventListener("abort",m),p()},2e3);s.addEventListener("abort",m,{once:!0})}),c=await r();return s.throwIfAborted(),c}function g(e){if(!e)return e??null;const s={"Create the Local VM":"computer.problem.createVm","The Local VM is stopped; start it to continue":"computer.problem.vmStopped","The Local VM started, but Cua Driver is not ready yet":"computer.problem.cuaNotReady","The existing Local VM uses an older desktop or Cua Driver; recreate it":"computer.problem.oldImage","The existing container was not created by Limix Bot; recreate it":"computer.problem.unmanaged","The existing Local VM exposes its viewer publicly; recreate it":"computer.problem.publicViewer","The existing Local VM is missing safety limits; recreate it":"computer.problem.missingLimits","The existing Local VM is missing its durable folder; recreate it":"computer.problem.missingDurableFolder","Per-bot Local VMs require Docker or Podman because Apple container requires a fixed host port":"computer.problem.perBotRuntime","Install a supported container runtime first":"computer.problem.noRuntime"}[e];if(s)return n(s);const i=/^Start (\S+) first$/.exec(e);if(i)return n("computer.problem.startRuntime",{runtime:i[1]});const o=/^The Local VM desktop failed to start: (.+)$/.exec(e);return o?n("computer.problem.desktopFailed",{detail:o[1]}):e}class V extends Error{constructor(r,s,i){super(r),this.key=r,this.problem=s,this.fallbackKey=i}key;problem;fallbackKey}function K(e){return e instanceof V?n(e.key,e.fallbackKey?{problem:g(e.problem)??n(e.fallbackKey)}:void 0):g(e instanceof Error?e.message:e)}let f=!1;const b=new Set,R=e=>(b.add(e),()=>{b.delete(e)}),w=()=>f;function D(){f=!0;for(const e of b)e()}async function P(e=r=>window.ogb?.permOpenSettings?.(r)){await e("accessibility"),!f&&await e("screen")}function B(){const{capabilities:e}=L(),r=u.useSyncExternalStore(R,w,w),s=e.localComputer.available?null:e.localComputer.message,i=C(j(s)),[o,c]=u.useState(!1),[p,d]=u.useState(!1),[m,l]=u.useState(null),h=async()=>{c(!0),l(null);try{await window.ogb?.localControl?.retry()}catch(a){l(a instanceof Error?a.message:String(a))}finally{c(!1)}},y=async()=>{l(null),d(!0);try{await P()}catch(a){d(!1),l(a instanceof Error?a.message:String(a))}};return u.useEffect(()=>{if(!p||r)return;let a=!1;const x=()=>{a||document.visibilityState==="visible"&&(a=!0,d(!1),h())};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[p,r]),e.host.platform!=="darwin"||e.localComputer.reasonCode==="remote-server"||e.localComputer.available||r?null:t.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(T,{size:16,className:"mt-0.5 shrink-0 text-warning"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n("computer.mac.allowTitle")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:i??n("computer.mac.permission.generic")}),s&&t.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[t.jsx("summary",{className:"cursor-pointer",children:n("computer.mac.permission.driverDetail")}),t.jsx("p",{className:"mt-1 break-words",children:s})]}),m&&t.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[t.jsx(N,{size:13,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:m})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i&&s&&t.jsx(M,{reason:s}),!i&&t.jsx("button",{type:"button",onClick:()=>{y()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:n("computer.mac.openSystemSettings")}),t.jsxs("button",{type:"button",onClick:()=>{h()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[13px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[o&&t.jsx(k,{size:13,className:"animate-spin"}),n("commandAllowlist.retry")]}),!o&&t.jsx(S,{onClick:D})]})]})]})})}export{V as L,B as M,g as l,K as p,I as w};
1
+ import{c as v,t as n,r as u,j as t}from"./styles-GmtHzqPG.js";import{d as L,L as k}from"./PlacesRail-BJBF_akb.js";import{bg as C,bh as j,Y as N,bi as M,bj as S}from"./App-DqXMyMLs.js";const E=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],T=v("shield",E);async function I(e,r,s,i=6e4){const o=Date.now()+i;let c=e;for(;!c.ready&&c.container==="running"&&Date.now()<o;)s.throwIfAborted(),await new Promise((p,d)=>{const m=()=>{window.clearTimeout(l),d(s.reason)},l=window.setTimeout(()=>{s.removeEventListener("abort",m),p()},2e3);s.addEventListener("abort",m,{once:!0})}),c=await r();return s.throwIfAborted(),c}function g(e){if(!e)return e??null;const s={"Create the Local VM":"computer.problem.createVm","The Local VM is stopped; start it to continue":"computer.problem.vmStopped","The Local VM started, but Cua Driver is not ready yet":"computer.problem.cuaNotReady","The existing Local VM uses an older desktop or Cua Driver; recreate it":"computer.problem.oldImage","The existing container was not created by Limix Bot; recreate it":"computer.problem.unmanaged","The existing Local VM exposes its viewer publicly; recreate it":"computer.problem.publicViewer","The existing Local VM is missing safety limits; recreate it":"computer.problem.missingLimits","The existing Local VM is missing its durable folder; recreate it":"computer.problem.missingDurableFolder","Per-bot Local VMs require Docker or Podman because Apple container requires a fixed host port":"computer.problem.perBotRuntime","Install a supported container runtime first":"computer.problem.noRuntime"}[e];if(s)return n(s);const i=/^Start (\S+) first$/.exec(e);if(i)return n("computer.problem.startRuntime",{runtime:i[1]});const o=/^The Local VM desktop failed to start: (.+)$/.exec(e);return o?n("computer.problem.desktopFailed",{detail:o[1]}):e}class V extends Error{constructor(r,s,i){super(r),this.key=r,this.problem=s,this.fallbackKey=i}key;problem;fallbackKey}function K(e){return e instanceof V?n(e.key,e.fallbackKey?{problem:g(e.problem)??n(e.fallbackKey)}:void 0):g(e instanceof Error?e.message:e)}let f=!1;const b=new Set,R=e=>(b.add(e),()=>{b.delete(e)}),w=()=>f;function D(){f=!0;for(const e of b)e()}async function P(e=r=>window.ogb?.permOpenSettings?.(r)){await e("accessibility"),!f&&await e("screen")}function B(){const{capabilities:e}=L(),r=u.useSyncExternalStore(R,w,w),s=e.localComputer.available?null:e.localComputer.message,i=C(j(s)),[o,c]=u.useState(!1),[p,d]=u.useState(!1),[m,l]=u.useState(null),h=async()=>{c(!0),l(null);try{await window.ogb?.localControl?.retry()}catch(a){l(a instanceof Error?a.message:String(a))}finally{c(!1)}},y=async()=>{l(null),d(!0);try{await P()}catch(a){d(!1),l(a instanceof Error?a.message:String(a))}};return u.useEffect(()=>{if(!p||r)return;let a=!1;const x=()=>{a||document.visibilityState==="visible"&&(a=!0,d(!1),h())};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[p,r]),e.host.platform!=="darwin"||e.localComputer.reasonCode==="remote-server"||e.localComputer.available||r?null:t.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(T,{size:16,className:"mt-0.5 shrink-0 text-warning"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n("computer.mac.allowTitle")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:i??n("computer.mac.permission.generic")}),s&&t.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[t.jsx("summary",{className:"cursor-pointer",children:n("computer.mac.permission.driverDetail")}),t.jsx("p",{className:"mt-1 break-words",children:s})]}),m&&t.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[t.jsx(N,{size:13,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:m})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i&&s&&t.jsx(M,{reason:s}),!i&&t.jsx("button",{type:"button",onClick:()=>{y()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:n("computer.mac.openSystemSettings")}),t.jsxs("button",{type:"button",onClick:()=>{h()},disabled:o,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[13px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[o&&t.jsx(k,{size:13,className:"animate-spin"}),n("commandAllowlist.retry")]}),!o&&t.jsx(S,{onClick:D})]})]})]})})}export{V as L,B as M,g as l,K as p,I as w};
@@ -1 +1 @@
1
- import{r as i,j as e,t}from"./styles-DSEcltf1.js";import{H as w,J as v,K as k,M as j,N,O as y,R as C,P as S}from"./App-BV7lfvAV.js";import{L as z}from"./PlacesRail-Bpjyw4Vm.js";import"./index-BUpSDhKQ.js";import"./monitor-Xr0SgoUO.js";import"./MenuMotion-DQYRi6n6.js";const E=2*1024*1024;function D({path:s,name:r,message:o}){const[c,x]=i.useState(0),[m,p]=i.useState(null),[u,h]=i.useState(null),[l,f]=i.useState(!1),a=w(s,r,o);i.useEffect(()=>{const n=new AbortController;return h(null),p(null),(async()=>{try{const d=await v(s,o,n.signal),g=await k(d,n.signal,E);n.signal.aborted||p(g)}catch(d){n.signal.aborted||h(d instanceof Error&&d.message==="size"?"size":"load")}})(),()=>n.abort()},[s,o.threadId,o.messageId,c]);const b=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-lg border border-hairline px-3 py-2 hover:bg-raised",disabled:a.state==="saving",onClick:()=>{a.save()},children:[e.jsx(j,{size:14,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 break-all",children:t("attach.saveAria",{name:r})})]}),e.jsx("button",{type:"button",className:"rounded-lg border border-hairline px-3 py-2 hover:bg-raised",onClick:()=>x(c+1),children:t("chat.retry")})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:a.reason})]});return u?e.jsxs("div",{className:"p-8 text-center text-sm",children:[e.jsx("p",{role:"alert",className:"text-ink-secondary",children:t(u==="size"?"markdown.tooLarge":"markdown.loadFailed")}),b]}):m===null?e.jsxs("div",{className:"p-12 text-center text-sm text-ink-secondary",children:[e.jsxs("span",{role:"status",className:"inline-flex items-center gap-2",children:[e.jsx(z,{size:16,className:"animate-spin"}),t("markdown.loading")]}),b]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",className:"table-action","aria-pressed":l,"aria-label":t(l?"markdown.rendered":"html.source"),title:t(l?"markdown.rendered":"html.source"),onClick:()=>f(!l),children:l?e.jsx(N,{size:14}):e.jsx(y,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("html.reload"),title:t("html.reload"),onClick:()=>x(c+1),children:e.jsx(C,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("attach.saveAria",{name:r}),title:t("attach.saveAria",{name:r}),disabled:a.state==="saving",onClick:()=>{a.save()},children:e.jsx(j,{size:14})})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"text-end text-[12px] text-danger",children:a.reason}),e.jsx(A,{source:m,showSource:l})]})}function A({source:s,showSource:r}){return r?e.jsx("pre",{className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-inset p-3 text-[12px] leading-5 whitespace-pre-wrap break-words text-ink",children:s}):e.jsx("div",{"data-markdown-file":!0,className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-panel px-5 py-4 text-[14px] leading-6 text-ink",children:e.jsx(S,{text:s})})}export{E as MARKDOWN_PREVIEW_MAX_BYTES,A as MarkdownFileView,D as default};
1
+ import{r as i,j as e,t}from"./styles-GmtHzqPG.js";import{H as w,J as v,K as k,M as j,N,O as y,R as C,P as S}from"./App-DqXMyMLs.js";import{L as z}from"./PlacesRail-BJBF_akb.js";import"./index-BfvuKok1.js";import"./monitor-Chdrm5wS.js";import"./MenuMotion-nTkCdPNb.js";const E=2*1024*1024;function D({path:s,name:r,message:o}){const[c,x]=i.useState(0),[m,p]=i.useState(null),[u,h]=i.useState(null),[l,f]=i.useState(!1),a=w(s,r,o);i.useEffect(()=>{const n=new AbortController;return h(null),p(null),(async()=>{try{const d=await v(s,o,n.signal),g=await k(d,n.signal,E);n.signal.aborted||p(g)}catch(d){n.signal.aborted||h(d instanceof Error&&d.message==="size"?"size":"load")}})(),()=>n.abort()},[s,o.threadId,o.messageId,c]);const b=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-lg border border-hairline px-3 py-2 hover:bg-raised",disabled:a.state==="saving",onClick:()=>{a.save()},children:[e.jsx(j,{size:14,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 break-all",children:t("attach.saveAria",{name:r})})]}),e.jsx("button",{type:"button",className:"rounded-lg border border-hairline px-3 py-2 hover:bg-raised",onClick:()=>x(c+1),children:t("chat.retry")})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:a.reason})]});return u?e.jsxs("div",{className:"p-8 text-center text-sm",children:[e.jsx("p",{role:"alert",className:"text-ink-secondary",children:t(u==="size"?"markdown.tooLarge":"markdown.loadFailed")}),b]}):m===null?e.jsxs("div",{className:"p-12 text-center text-sm text-ink-secondary",children:[e.jsxs("span",{role:"status",className:"inline-flex items-center gap-2",children:[e.jsx(z,{size:16,className:"animate-spin"}),t("markdown.loading")]}),b]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",className:"table-action","aria-pressed":l,"aria-label":t(l?"markdown.rendered":"html.source"),title:t(l?"markdown.rendered":"html.source"),onClick:()=>f(!l),children:l?e.jsx(N,{size:14}):e.jsx(y,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("html.reload"),title:t("html.reload"),onClick:()=>x(c+1),children:e.jsx(C,{size:14})}),e.jsx("button",{type:"button",className:"table-action","aria-label":t("attach.saveAria",{name:r}),title:t("attach.saveAria",{name:r}),disabled:a.state==="saving",onClick:()=>{a.save()},children:e.jsx(j,{size:14})})]}),a.state==="failed"&&e.jsx("p",{role:"alert",className:"text-end text-[12px] text-danger",children:a.reason}),e.jsx(A,{source:m,showSource:l})]})}function A({source:s,showSource:r}){return r?e.jsx("pre",{className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-inset p-3 text-[12px] leading-5 whitespace-pre-wrap break-words text-ink",children:s}):e.jsx("div",{"data-markdown-file":!0,className:"h-[72dvh] overflow-auto rounded-lg border border-hairline/40 bg-panel px-5 py-4 text-[14px] leading-6 text-ink",children:e.jsx(S,{text:s})})}export{E as MARKDOWN_PREVIEW_MAX_BYTES,A as MarkdownFileView,D as default};
@@ -1 +1 @@
1
- import{c as o,r as a}from"./styles-DSEcltf1.js";const d=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],M=o("chevron-right",d);const i=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],y=o("keyboard",i);const s=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],k=o("refresh-cw",s);const u=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],l=o("send",u),h=200;function p(){return typeof document>"u"?!1:document.documentElement.dataset.reducedMotion==="true"?!0:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function f(e){const[t,n]=a.useState(e);a.useLayoutEffect(()=>{if(e){n(!0);return}if(!t)return;if(p()){n(!1);return}const c=window.setTimeout(()=>n(!1),h);return()=>window.clearTimeout(c)},[e,t]);const r=!e&&t;return{shown:e||t,closing:r,className:r?"animate-pop-out pointer-events-none":"animate-pop-in",exitProps:r?{inert:!0,"aria-hidden":!0}:{}}}function w(e){const t=f(e!=null),n=a.useRef(e);return e!=null&&(n.current=e),{...t,value:e??n.current}}export{M as C,y as K,k as R,l as S,f as a,w as u};
1
+ import{c as o,r as a}from"./styles-GmtHzqPG.js";const d=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],M=o("chevron-right",d);const i=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],y=o("keyboard",i);const s=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],k=o("refresh-cw",s);const u=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],l=o("send",u),h=200;function p(){return typeof document>"u"?!1:document.documentElement.dataset.reducedMotion==="true"?!0:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function f(e){const[t,n]=a.useState(e);a.useLayoutEffect(()=>{if(e){n(!0);return}if(!t)return;if(p()){n(!1);return}const c=window.setTimeout(()=>n(!1),h);return()=>window.clearTimeout(c)},[e,t]);const r=!e&&t;return{shown:e||t,closing:r,className:r?"animate-pop-out pointer-events-none":"animate-pop-in",exitProps:r?{inert:!0,"aria-hidden":!0}:{}}}function w(e){const t=f(e!=null),n=a.useRef(e);return e!=null&&(n.current=e),{...t,value:e??n.current}}export{M as C,y as K,k as R,l as S,f as a,w as u};
@@ -1 +1 @@
1
- import{t as s,r as o,d as Te,j as e,X as ve,f as Ae,a as G,ah as ye,ai as Le,h as De,k as Oe,aj as Me,ak as Ue,al as Fe,b as ze,am as Ie,an as Ke,ao as _e,ap as $e,p as le,B as He}from"./styles-DSEcltf1.js";import{n as B,E as Je,u as k,bH as ee,bI as Ve,bJ as w,S as T,bK as We,bL as we,bM as te,bN as Ye,bO as qe,bP as Xe,bQ as oe,bR as ce,bS as Qe,bT as Ze,bU as Ge,bV as je,D as O,bW as et,bX as tt,e as Se,bY as st,bZ as de,b_ as nt,b$ as at,c0 as it,c1 as rt,c2 as lt,c3 as ot,c4 as ct,c5 as dt,c6 as ut,c7 as pt,c8 as mt,c9 as xt,ca as ue,cb as gt,cc as ht,cd as ft,ce as bt,cf as ke,cg as Ne,ch as vt,ci as yt,cj as wt,ck as jt,cl as St,cm as pe,T as Ce,cn as kt}from"./App-BV7lfvAV.js";import{B as me,E as Nt,s as Ct,r as xe,p as Et,c as Bt,a as Rt}from"./new-bot-DZ8WGB0A.js";import{o as Pt}from"./index-BUpSDhKQ.js";import{I as Tt,S as At,a as Lt,A as Dt,M as Ot,P as Mt,V as Ut,v as Ft,i as ge}from"./VisibilitySection-Bg_6NbUb.js";import{R as zt}from"./RoutinesPage-M0vKACB8.js";import{r as It,L as X,Q as Kt,R as _t,U as $t,P as Ht}from"./PlacesRail-Bpjyw4Vm.js";import{p as Jt,d as Vt,e as Wt,f as Yt}from"./team-share-BrQ2rI3n.js";import{B as qt}from"./BrowserProfilesManager-BsJcpUXn.js";function Xt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(l=>l.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Qt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function Zt(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function Gt(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function es(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function he(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function fe({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],l=[...n,...t.skipped.map(d=>Vt(d,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:r.map(([d,c])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:d}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:c,children:c})]},d))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Je,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(d=>e.jsx("li",{children:Wt(d,t.document)},d))})]}),l.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.map((d,c)=>e.jsx("li",{children:d},`${d}-${c}`))})]})]})}function ts({onClose:t}){const n=o.useRef(null),[a,i]=o.useState(""),[r,l]=o.useState(""),[d,c]=o.useState(""),[p,g]=o.useState(""),[j,A]=o.useState(!0),[N,x]=o.useState(!0),[h,y]=o.useState(null),[b,v]=o.useState(null),[f,M]=o.useState(!1),[I,$]=o.useState(null),[U,K]=o.useState(""),_=o.useRef(0);o.useEffect(()=>{let u=!1;return B("/api/bot-defaults").then(async({defaults:R})=>{!u&&R.profile.name?.trim()&&i(L=>L||R.profile.name.trim());const C=await Jt([{id:"defaults",avatarUrl:R.profile.avatarUrl,avatarCrop:R.profile.avatarCrop}]);u||y({dataUrl:C.avatars.defaults,skipped:C.skipped.map(L=>`${s("teamShare.field.picture")} — ${Te(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||y({skipped:[]})}),()=>{u=!0}},[]);const V=u=>({name:a,description:r,release:d,notes:p,includeNotes:j,dryRun:u,...N&&h?.dataUrl?{picture:h.dataUrl}:{}});o.useEffect(()=>{if(!h)return;const u=++_.current,R=window.setTimeout(()=>{B("/api/teams/export",{method:"POST",body:JSON.stringify(he({...V(!0),release:void 0}))}).then(C=>{u===_.current&&(v(C),K(""),c(L=>L||C.document.package.release))}).catch(C=>{u===_.current&&(v(null),K(C instanceof Error?C.message:String(C)))})},250);return()=>window.clearTimeout(R)},[h,j,N]);const F=async()=>{if(!f){M(!0),K("");try{const u=await B("/api/teams/export",{method:"POST",body:JSON.stringify(he(V(!1)))});Yt(u.filename,u.document),$(u)}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(!1)}}};o.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const H=N?h?.skipped??[]:[],z="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return It.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>{u.target===u.currentTarget&&!f&&t()},children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const R=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!R?.length)return;const C=R[0],L=R[R.length-1];u.shiftKey&&document.activeElement===C?(u.preventDefault(),L.focus()):!u.shiftKey&&document.activeElement===L&&(u.preventDefault(),C.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ve,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:I?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Ae,{size:16,className:"text-success"}),s("teamShare.saved",{filename:I.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(fe,{preview:I,localSkips:H})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(fe,{preview:b,localSkips:H}):!U&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:N,onChange:u=>x(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:j,onChange:u=>A(u.target.checked)}),s("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:z})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:d,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>c(u.target.value),className:z})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>l(u.target.value),className:z})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:p,maxLength:4e3,rows:2,disabled:f,onChange:u=>g(u.target.value),className:z})]})]})}),U&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:U}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:I?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{F()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(X,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function se(){const{dispatch:t}=k(),[n,a]=o.useState(!1),[i,r]=o.useState("");return{saving:n,error:i,save:async d=>{if(!n){a(!0),r("");try{const c=await B("/api/config",{method:"PATCH",body:JSON.stringify(d)});t({type:"configStatus",config:c})}catch(c){r(c instanceof Error?c.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Es(){const{state:t}=k(),n=ee(t.config),a=Ve(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:l,error:d,save:c}=se();return e.jsx(w,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):We(t.config),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(T,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:l||!n&&!a&&!i,onClick:()=>{c({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Bs(){const{state:t}=k(),n=we(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:l}=se();return a===void 0||n!==!0||!ee(t.config)?null:e.jsx(w,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{l({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function ss(){const{state:t}=k(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=se();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(T,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function ns(){const{state:t,dispatch:n}=k(),a=te(t.config),i=Ye(t.config),r=qe(t.config),l=Xe(t.bots,t.instances),[d,c]=o.useState(String(r)),[p,g]=o.useState(!1),[j,A]=o.useState(!1),[N,x]=o.useState(""),h=o.useRef(!1);o.useEffect(()=>{p||c(String(r))},[r,p]);const y=async v=>{if(h.current)return!1;h.current=!0,A(!0),x("");try{const f=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:v})});return n({type:"configStatus",config:f}),!0}catch(f){return x(f instanceof Error?f.message:s("settings.experimental.error")),!1}finally{h.current=!1,A(!1)}},b=async()=>{if(!p)return;const v=Qe(d);if(v===null){x(s("settings.experimental.skillReviewStepsRange",{min:ce,max:oe}));return}await y({skillReviewSteps:v})&&g(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(T,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:j||!a,onClick:()=>{y({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(as,{engines:l}),i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${N?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ce,max:oe,step:1,inputMode:"numeric",value:d,disabled:j,"aria-invalid":!!N,onChange:v=>{c(v.target.value),g(!0),x("")},onBlur:()=>{b()},onKeyDown:v=>{v.key==="Enter"&&v.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,N?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:N}):null]})}function as({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const is=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function rs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState("");if(!Ze(t.config))return null;const d=te(t.config),c=Ge(t.config),p=async g=>{if(!(a||g===c)){i(!0),l("");try{const j=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:g}})});n({type:"configStatus",config:j})}catch(j){l(j instanceof Error?j.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(d?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:is.map(g=>e.jsx("button",{type:"button",role:"radio","aria-checked":c===g.value,disabled:a||!d,onClick:()=>{p(g.value)},className:G("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",c===g.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(g.label)},g.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function ls(){return e.jsxs(e.Fragment,{children:[e.jsx(ns,{}),e.jsx(rs,{})]})}function Rs({title:t=s("settings.updates.title")}){const n=xt(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:le(),version:n.version??""}):s("settings.updates.ready",{app:le(),version:n.version??""}):n.status==="installing"?ue(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:ue(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(w,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Ee(){const{state:t,dispatch:n}=k(),a=t.config?.newBots?.effort??"",[i,r]=o.useState(!1),[l,d]=o.useState("");return{current:a,saving:i,error:l,save:async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:bt(p)?p:null}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Be({effort:t,className:n}){return e.jsxs(O,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),gt.map(a=>e.jsx("option",{value:a,children:ht(a)},a))]})}function Ps(){const t=Ee();return e.jsx(w,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Be,{effort:t,className:"w-full max-w-[240px]"})})}function os({onEdit:t,onShare:n}){const a=Ee();return e.jsx(w,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function cs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),l(!1),B("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:Kt().onboarding,hintsSeen:ft(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(d=>{n({type:"configStatus",config:d}),n({type:"toggleTour",open:!0})}).catch(()=>l(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ts(){const{dispatch:t}=k();return e.jsx(w,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(cs,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function As({simple:t=!1}){const{state:n}=k(),a=De(Oe(),n.config?.language);return e.jsx(w,{title:s("settings.language.title"),subtitle:Fe()?s("settings.language.subtitleComplete"):t?ze()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>Ue(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Me.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Ls({simple:t=!1}){const n=Se();return e.jsx(w,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:de("mod-enter")}),children:e.jsx(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>nt(at(a.target.value)),children:st.map(a=>e.jsx("option",{value:a,children:de(a)},a))})})}function Ds({simple:t=!1}){const n=it(),a=rt(Se());return e.jsx(w,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>lt(ot(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Os({simple:t=!1}){const n=et();return e.jsx(w,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>tt(!n)})})}function Ms({simple:t=!1}){const n=ye();return e.jsx(w,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Le(!n)})})}function Us(){const t=Ie();return e.jsx(w,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>Ke(!t)})})}function Fs(){const t=ct();return e.jsx(w,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>dt(!t)})})}function zs(){const t=_e();return e.jsx(w,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>$e(!t)})})}function Is(){const t=ut();return e.jsx(w,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>pt(!t)})})}function Ks(){const{state:t,dispatch:n}=k(),a=mt(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async()=>{if(!i){r(!0),d("");try{const p=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:p})}catch(p){d(p instanceof Error?p.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(w,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:l?e.jsx("p",{role:"alert",className:"text-danger",children:l}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{c()},className:"disabled:cursor-wait disabled:opacity-50"})})}function _s(){const{state:t,dispatch:n}=k(),a=te(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:p}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(je,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(T,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{c(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),l?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:l}):null,e.jsx(ls,{}),e.jsx(ss,{})]})}function $s(){const{state:t}=k(),n=t.config?.browserProfiles??[];return!ee(t.config)&&n.length===0?null:e.jsx(je,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(qt,{})})}const be=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],ds={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Re(t){return e.jsx(_t,{modal:!0,children:e.jsx(us,{...t})})}function us({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i}){const r=$t(),l=k(),[,d]=o.useState(0),[c,p]=o.useState(()=>new me(Nt,()=>d(m=>m+1))),[g,j]=o.useState("Identity"),[A,N]=o.useState(!1),[x,h]=o.useState(!1),y=x||l.state.botCreationPending,b=o.useRef(!1),v=o.useRef(!0),[f,M]=o.useState(""),[I,$]=o.useState(null),[U,K]=o.useState("everyone"),[_,V]=o.useState(""),F=ke(),H=l.state.config?.team?.name,[z,u]=o.useState(null),R=we(),C=He(),L=ye()?be:be.filter(m=>m!=="Model"),ne=!t&&typeof window<"u"&&!window.ogb&&R===!0,W=o.useRef(null),J=o.useRef(n);J.current=n,o.useEffect(()=>{let m=!1;return B("/api/bot-defaults").then(P=>{if(m)return;const S=Ct(P,!t),E=t||!i?void 0:Ne(i),D=new me(E?vt(S,E):S,()=>d(q=>q+1));E&&(D.role=E.id),p(D),N(!0)}).catch(P=>{m||M(String(P))}),()=>{m=!0}},[t,i]),o.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),o.useEffect(()=>()=>c.dispose(),[c]),o.useEffect(()=>{y&&W.current?.focus()},[y]),o.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;W.current?.focus();const P=S=>{if(!r())return;const E=W.current;if(!E||S.target instanceof Node&&!E.contains(S.target))return;const D=E.querySelector('[role="dialog"], [role="alertdialog"]');if(D&&D.getClientRects().length||(S.key==="Escape"&&(S.preventDefault(),J.current()),S.key!=="Tab"))return;const q=[...E.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(re=>re.getClientRects().length&&!re.closest("[hidden],fieldset:disabled")),Q=q[0],Z=q.at(-1);if(!Q||!Z){S.preventDefault(),E.focus();return}S.shiftKey&&(document.activeElement===Q||document.activeElement===E)?(S.preventDefault(),Z.focus()):!S.shiftKey&&(document.activeElement===Z||document.activeElement===E)&&(S.preventDefault(),Q.focus())};return window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P),m?.isConnected&&m.focus()}},[r]);const ae=async()=>{if(!A||b.current||l.state.botCreationPending)return;if(!t&&c.bot.approvalMode==="auto"&&c.bot.computer==="local"&&!c.consent.acknowledgeLocalAuto){$("local");return}const m=ne?Ft(U,_):null;if(m&&!m.ok){M(s("botSettings.visibility.needPeople"));return}b.current=!0,h(!0),M(""),l.dispatch({type:"botCreationPending",on:!0});try{if(t)await B("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Et(c)})});else{const{bot:P,warnings:S,paused:E}=await Bt(c,void 0,void 0,void 0,m?.ok?m.visibility:void 0,F?xe(z,c.bot.section,l.state.bots,F)??void 0:void 0);Rt(l.dispatch,P,S,{showThreads:C,source:c.preset?"preset":c.role?"template":"blank",role:c.role,paused:E});try{await a?.(P)}catch(D){l.dispatch({type:"error",message:D instanceof Error?D.message:String(D)})}}b.current=!1,v.current&&J.current()}catch(P){v.current&&M(P instanceof Error?P.message:String(P))}finally{b.current=!1,l.dispatch({type:"botCreationPending",on:!1}),v.current&&h(!1)}},Y=c.bot,Pe={...l,state:{...l.state,bots:[Y,...l.state.bots],routines:c.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>Y,dispatch:m=>{m.type==="updateBot"&&m.botId===c.id?c.patch(m.patch):m.type==="setModel"&&m.botId===c.id?(c.setModel(m.selection),m.resetApprovalToAsk&&c.patch({approvalMode:"ask"})):m.type==="routinePatched"||m.type==="toggleSettings"||l.dispatch(m)}},ie=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&l.state.appSettingsOpen,children:e.jsxs("div",{ref:W,role:"dialog","aria-modal":"true","aria-label":ie,"aria-busy":y,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:ie}),e.jsx("button",{type:"button",onClick:()=>J.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ve,{size:18,className:"pointer-events-none"})})]}),F&&!t&&H&&e.jsx(ps,{team:H}),ne&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(O,{size:"sm",value:U,disabled:y,onChange:m=>K(m.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),U==="people"&&e.jsx("input",{value:_,disabled:y,onChange:m=>V(m.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:L.map(m=>e.jsx("button",{type:"button",onClick:()=>j(m),"aria-current":g===m?"page":void 0,className:G("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",g===m?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(ds[m])},m))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!A&&!f&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:16,className:"animate-spin"}),s("newBot.loading")]}),A&&e.jsx("fieldset",{disabled:y,className:"min-w-0",children:e.jsx(yt,{value:Pe,children:e.jsx(wt.Provider,{value:{request:c.request,draft:!0,uploadAvatar:c.uploadAvatar},children:e.jsx(ms,{active:g,draft:c,defaultsMode:t,owner:F&&!t?{value:xe(z,Y.section,l.state.bots,F),choose:u}:void 0})})})})]})]}),f&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:f}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>J.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!A||y||!t&&!Y.name.trim(),onClick:()=>{ae()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[y&&e.jsx(X,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(jt,{open:I==="local",onCancel:()=>$(null),onConfirm:()=>{c.consent.acknowledgeLocalAuto=!0,$(null),ae()}})]})})}function ps({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{Pt(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function ms({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:l}=k(),d=ke(),c=St(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{draft:n,defaultsMode:a}),e.jsx(Tt,{bot:r,patch:c.patch,activeState:c.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:p=>n.patch({section:p.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...l.sections??[],...l.bots.map(p=>p.section??"")])].filter(Boolean).map(p=>e.jsx("option",{children:p},p))]})]}),i&&d&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(O,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:p=>i.choose(p.target.value),children:d.people.map(p=>e.jsx("option",{value:p.email,children:p.you?s("owner.you",{name:p.name}):p.name},p.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(At,{bot:r,patch:c.patch}):t==="Skills"?e.jsx(Lt,{bot:r}):t==="Memory"?e.jsx(gs,{draft:n}):t==="Routines"?e.jsx(hs,{draft:n}):t==="Access"?e.jsx(Dt,{bot:r,derived:c}):t==="Model"?e.jsx(Ot,{bot:r}):t==="Permissions"?e.jsx(Mt,{bot:r,derived:c}):e.jsx(Ut,{bot:r,derived:c})}function xs({draft:t,defaultsMode:n}){const[a,i]=o.useState([]),[r,l]=o.useState(0),[d,c]=o.useState(""),p=o.useRef(!1);o.useEffect(()=>{if(n)return;let x=!1;return B("/api/bot-presets").then(h=>{x||i(h.presets)}).catch(()=>{x||i([])}),()=>{x=!0}},[n,r]);const g=t.preset?a.find(x=>x.id===t.preset.id):void 0,j=async x=>{c("");const h=x.startsWith("preset:")?a.find(b=>b.id===x.slice(7)):void 0;if(!h){t.choosePreset(void 0);const b=pe.find(f=>f.id===x);t.chooseRole(b?.id);const v=b&&Ne(b.id)?.look;b&&t.patch({...kt(b),...v});return}t.patch(Qt(h)),t.choosePreset(es(h));const y=Zt(h);try{y?(t.patch({avatarUrl:await t.uploadAvatar(y),avatarCrop:h.bot.appearance.avatar.crop}),p.current=!0):p.current&&(t.patch({avatarUrl:""}),p.current=!1)}catch(b){c(b instanceof Error?b.message:String(b))}},A=async x=>{c("");try{await B(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),l(h=>h+1)}catch(h){c(h instanceof Error?h.message:String(h))}},N=pe.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{j(x.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Xt(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(h=>e.jsx("option",{value:`preset:${h.id}`,children:h.name},h.id))},x.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:N}):N]})]}),g&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[Gt(g).map((x,h)=>e.jsx("p",{className:"break-words",children:x},h)),g.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{A(g)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),d&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:d})]})}function gs({draft:t}){const[n,a]=o.useState("MEMORY.md"),[i,r]=o.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(O,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:l=>a(l.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(l=>e.jsx("option",{children:l},l))}),e.jsx("textarea",{className:G(ge,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:l=>t.setMemory(n,l.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:ge,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:l=>r(l.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const l=`memory/${i}.md`;l in t.template.memory||t.setMemory(l,""),a(l),r("")},children:e.jsx(Ht,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ce,{size:16})})]})]})}function hs({draft:t}){const[n,a]=o.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ce,{size:15})})]},i.id)),n&&e.jsx(zt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function fs({simple:t=!1}){const[n,a]=o.useState(!1),[i,r]=o.useState(!1),l=e.jsxs(e.Fragment,{children:[n&&e.jsx(Re,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ts,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(os,{onEdit:()=>a(!0),onShare:()=>r(!0)}),l]});const d=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),l]});return e.jsx(w,{title:s("newBot.defaults"),children:d})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:fs,NewBotDialog:Re},Symbol.toStringTag,{value:"Module"}));export{Ms as A,Es as B,Os as C,fs as D,_s as E,Ds as F,As as L,Ps as N,Fs as P,Ts as R,Bs as S,Ks as T,Rs as U,$s as a,Ls as b,Us as c,Is as d,zs as e,Hs as f};
1
+ import{t as s,r as o,d as Te,j as e,X as ve,f as Ae,a as G,ah as ye,ai as Le,h as De,k as Oe,aj as Me,ak as Ue,al as Fe,b as ze,am as Ie,an as Ke,ao as _e,ap as $e,p as le,B as He}from"./styles-GmtHzqPG.js";import{n as B,E as Je,u as k,bH as ee,bI as Ve,bJ as w,S as T,bK as We,bL as we,bM as te,bN as Ye,bO as qe,bP as Xe,bQ as oe,bR as ce,bS as Qe,bT as Ze,bU as Ge,bV as je,D as O,bW as et,bX as tt,e as Se,bY as st,bZ as de,b_ as nt,b$ as at,c0 as it,c1 as rt,c2 as lt,c3 as ot,c4 as ct,c5 as dt,c6 as ut,c7 as pt,c8 as mt,c9 as xt,ca as ue,cb as gt,cc as ht,cd as ft,ce as bt,cf as ke,cg as Ne,ch as vt,ci as yt,cj as wt,ck as jt,cl as St,cm as pe,T as Ce,cn as kt}from"./App-DqXMyMLs.js";import{B as me,E as Nt,s as Ct,r as xe,p as Et,c as Bt,a as Rt}from"./new-bot-K3vr9SqG.js";import{o as Pt}from"./index-BfvuKok1.js";import{I as Tt,S as At,a as Lt,A as Dt,M as Ot,P as Mt,V as Ut,v as Ft,i as ge}from"./VisibilitySection-CrMCXcM_.js";import{R as zt}from"./RoutinesPage-C2O4AgJB.js";import{r as It,L as X,Q as Kt,R as _t,U as $t,P as Ht}from"./PlacesRail-BJBF_akb.js";import{p as Jt,d as Vt,e as Wt,f as Yt}from"./team-share-n1TGl5ex.js";import{B as qt}from"./BrowserProfilesManager-tU88r2vZ.js";function Xt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(l=>l.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Qt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function Zt(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function Gt(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function es(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function he(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function fe({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],l=[...n,...t.skipped.map(d=>Vt(d,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:r.map(([d,c])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:d}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:c,children:c})]},d))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Je,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(d=>e.jsx("li",{children:Wt(d,t.document)},d))})]}),l.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.map((d,c)=>e.jsx("li",{children:d},`${d}-${c}`))})]})]})}function ts({onClose:t}){const n=o.useRef(null),[a,i]=o.useState(""),[r,l]=o.useState(""),[d,c]=o.useState(""),[p,g]=o.useState(""),[j,A]=o.useState(!0),[N,x]=o.useState(!0),[h,y]=o.useState(null),[b,v]=o.useState(null),[f,M]=o.useState(!1),[I,$]=o.useState(null),[U,K]=o.useState(""),_=o.useRef(0);o.useEffect(()=>{let u=!1;return B("/api/bot-defaults").then(async({defaults:R})=>{!u&&R.profile.name?.trim()&&i(L=>L||R.profile.name.trim());const C=await Jt([{id:"defaults",avatarUrl:R.profile.avatarUrl,avatarCrop:R.profile.avatarCrop}]);u||y({dataUrl:C.avatars.defaults,skipped:C.skipped.map(L=>`${s("teamShare.field.picture")} — ${Te(`teamShare.skip.${L.reason}`,L.reason)}`)})}).catch(()=>{u||y({skipped:[]})}),()=>{u=!0}},[]);const V=u=>({name:a,description:r,release:d,notes:p,includeNotes:j,dryRun:u,...N&&h?.dataUrl?{picture:h.dataUrl}:{}});o.useEffect(()=>{if(!h)return;const u=++_.current,R=window.setTimeout(()=>{B("/api/teams/export",{method:"POST",body:JSON.stringify(he({...V(!0),release:void 0}))}).then(C=>{u===_.current&&(v(C),K(""),c(L=>L||C.document.package.release))}).catch(C=>{u===_.current&&(v(null),K(C instanceof Error?C.message:String(C)))})},250);return()=>window.clearTimeout(R)},[h,j,N]);const F=async()=>{if(!f){M(!0),K("");try{const u=await B("/api/teams/export",{method:"POST",body:JSON.stringify(he(V(!1)))});Yt(u.filename,u.document),$(u)}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(!1)}}};o.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const H=N?h?.skipped??[]:[],z="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return It.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>{u.target===u.currentTarget&&!f&&t()},children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const R=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!R?.length)return;const C=R[0],L=R[R.length-1];u.shiftKey&&document.activeElement===C?(u.preventDefault(),L.focus()):!u.shiftKey&&document.activeElement===L&&(u.preventDefault(),C.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ve,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:I?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Ae,{size:16,className:"text-success"}),s("teamShare.saved",{filename:I.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(fe,{preview:I,localSkips:H})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(fe,{preview:b,localSkips:H}):!U&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:N,onChange:u=>x(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:j,onChange:u=>A(u.target.checked)}),s("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:z})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:d,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>c(u.target.value),className:z})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>l(u.target.value),className:z})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:p,maxLength:4e3,rows:2,disabled:f,onChange:u=>g(u.target.value),className:z})]})]})}),U&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:U}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:I?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{F()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(X,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function se(){const{dispatch:t}=k(),[n,a]=o.useState(!1),[i,r]=o.useState("");return{saving:n,error:i,save:async d=>{if(!n){a(!0),r("");try{const c=await B("/api/config",{method:"PATCH",body:JSON.stringify(d)});t({type:"configStatus",config:c})}catch(c){r(c instanceof Error?c.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Es(){const{state:t}=k(),n=ee(t.config),a=Ve(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:l,error:d,save:c}=se();return e.jsx(w,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):We(t.config),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(T,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:l||!n&&!a&&!i,onClick:()=>{c({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Bs(){const{state:t}=k(),n=we(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:l}=se();return a===void 0||n!==!0||!ee(t.config)?null:e.jsx(w,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{l({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function ss(){const{state:t}=k(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=se();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(T,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function ns(){const{state:t,dispatch:n}=k(),a=te(t.config),i=Ye(t.config),r=qe(t.config),l=Xe(t.bots,t.instances),[d,c]=o.useState(String(r)),[p,g]=o.useState(!1),[j,A]=o.useState(!1),[N,x]=o.useState(""),h=o.useRef(!1);o.useEffect(()=>{p||c(String(r))},[r,p]);const y=async v=>{if(h.current)return!1;h.current=!0,A(!0),x("");try{const f=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:v})});return n({type:"configStatus",config:f}),!0}catch(f){return x(f instanceof Error?f.message:s("settings.experimental.error")),!1}finally{h.current=!1,A(!1)}},b=async()=>{if(!p)return;const v=Qe(d);if(v===null){x(s("settings.experimental.skillReviewStepsRange",{min:ce,max:oe}));return}await y({skillReviewSteps:v})&&g(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(T,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:j||!a,onClick:()=>{y({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(as,{engines:l}),i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${N?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ce,max:oe,step:1,inputMode:"numeric",value:d,disabled:j,"aria-invalid":!!N,onChange:v=>{c(v.target.value),g(!0),x("")},onBlur:()=>{b()},onKeyDown:v=>{v.key==="Enter"&&v.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,N?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:N}):null]})}function as({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const is=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function rs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState("");if(!Ze(t.config))return null;const d=te(t.config),c=Ge(t.config),p=async g=>{if(!(a||g===c)){i(!0),l("");try{const j=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:g}})});n({type:"configStatus",config:j})}catch(j){l(j instanceof Error?j.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(d?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:is.map(g=>e.jsx("button",{type:"button",role:"radio","aria-checked":c===g.value,disabled:a||!d,onClick:()=>{p(g.value)},className:G("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",c===g.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(g.label)},g.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function ls(){return e.jsxs(e.Fragment,{children:[e.jsx(ns,{}),e.jsx(rs,{})]})}function Rs({title:t=s("settings.updates.title")}){const n=xt(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:le(),version:n.version??""}):s("settings.updates.ready",{app:le(),version:n.version??""}):n.status==="installing"?ue(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:ue(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(w,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Ee(){const{state:t,dispatch:n}=k(),a=t.config?.newBots?.effort??"",[i,r]=o.useState(!1),[l,d]=o.useState("");return{current:a,saving:i,error:l,save:async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:bt(p)?p:null}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Be({effort:t,className:n}){return e.jsxs(O,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),gt.map(a=>e.jsx("option",{value:a,children:ht(a)},a))]})}function Ps(){const t=Ee();return e.jsx(w,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Be,{effort:t,className:"w-full max-w-[240px]"})})}function os({onEdit:t,onShare:n}){const a=Ee();return e.jsx(w,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function cs(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),l(!1),B("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:Kt().onboarding,hintsSeen:ft(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(d=>{n({type:"configStatus",config:d}),n({type:"toggleTour",open:!0})}).catch(()=>l(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ts(){const{dispatch:t}=k();return e.jsx(w,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(cs,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function As({simple:t=!1}){const{state:n}=k(),a=De(Oe(),n.config?.language);return e.jsx(w,{title:s("settings.language.title"),subtitle:Fe()?s("settings.language.subtitleComplete"):t?ze()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>Ue(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Me.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Ls({simple:t=!1}){const n=Se();return e.jsx(w,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:de("mod-enter")}),children:e.jsx(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>nt(at(a.target.value)),children:st.map(a=>e.jsx("option",{value:a,children:de(a)},a))})})}function Ds({simple:t=!1}){const n=it(),a=rt(Se());return e.jsx(w,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(O,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>lt(ot(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Os({simple:t=!1}){const n=et();return e.jsx(w,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>tt(!n)})})}function Ms({simple:t=!1}){const n=ye();return e.jsx(w,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(T,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Le(!n)})})}function Us(){const t=Ie();return e.jsx(w,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>Ke(!t)})})}function Fs(){const t=ct();return e.jsx(w,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>dt(!t)})})}function zs(){const t=_e();return e.jsx(w,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>$e(!t)})})}function Is(){const t=ut();return e.jsx(w,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(T,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>pt(!t)})})}function Ks(){const{state:t,dispatch:n}=k(),a=mt(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async()=>{if(!i){r(!0),d("");try{const p=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:p})}catch(p){d(p instanceof Error?p.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(w,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:l?e.jsx("p",{role:"alert",className:"text-danger",children:l}):null,children:e.jsx(T,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{c()},className:"disabled:cursor-wait disabled:opacity-50"})})}function _s(){const{state:t,dispatch:n}=k(),a=te(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async p=>{if(!i){r(!0),d("");try{const g=await B("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:p}})});n({type:"configStatus",config:g})}catch(g){d(g instanceof Error?g.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(je,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(T,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{c(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),l?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:l}):null,e.jsx(ls,{}),e.jsx(ss,{})]})}function $s(){const{state:t}=k(),n=t.config?.browserProfiles??[];return!ee(t.config)&&n.length===0?null:e.jsx(je,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(qt,{})})}const be=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],ds={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Re(t){return e.jsx(_t,{modal:!0,children:e.jsx(us,{...t})})}function us({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i}){const r=$t(),l=k(),[,d]=o.useState(0),[c,p]=o.useState(()=>new me(Nt,()=>d(m=>m+1))),[g,j]=o.useState("Identity"),[A,N]=o.useState(!1),[x,h]=o.useState(!1),y=x||l.state.botCreationPending,b=o.useRef(!1),v=o.useRef(!0),[f,M]=o.useState(""),[I,$]=o.useState(null),[U,K]=o.useState("everyone"),[_,V]=o.useState(""),F=ke(),H=l.state.config?.team?.name,[z,u]=o.useState(null),R=we(),C=He(),L=ye()?be:be.filter(m=>m!=="Model"),ne=!t&&typeof window<"u"&&!window.ogb&&R===!0,W=o.useRef(null),J=o.useRef(n);J.current=n,o.useEffect(()=>{let m=!1;return B("/api/bot-defaults").then(P=>{if(m)return;const S=Ct(P,!t),E=t||!i?void 0:Ne(i),D=new me(E?vt(S,E):S,()=>d(q=>q+1));E&&(D.role=E.id),p(D),N(!0)}).catch(P=>{m||M(String(P))}),()=>{m=!0}},[t,i]),o.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),o.useEffect(()=>()=>c.dispose(),[c]),o.useEffect(()=>{y&&W.current?.focus()},[y]),o.useEffect(()=>{const m=document.activeElement instanceof HTMLElement?document.activeElement:null;W.current?.focus();const P=S=>{if(!r())return;const E=W.current;if(!E||S.target instanceof Node&&!E.contains(S.target))return;const D=E.querySelector('[role="dialog"], [role="alertdialog"]');if(D&&D.getClientRects().length||(S.key==="Escape"&&(S.preventDefault(),J.current()),S.key!=="Tab"))return;const q=[...E.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(re=>re.getClientRects().length&&!re.closest("[hidden],fieldset:disabled")),Q=q[0],Z=q.at(-1);if(!Q||!Z){S.preventDefault(),E.focus();return}S.shiftKey&&(document.activeElement===Q||document.activeElement===E)?(S.preventDefault(),Z.focus()):!S.shiftKey&&(document.activeElement===Z||document.activeElement===E)&&(S.preventDefault(),Q.focus())};return window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P),m?.isConnected&&m.focus()}},[r]);const ae=async()=>{if(!A||b.current||l.state.botCreationPending)return;if(!t&&c.bot.approvalMode==="auto"&&c.bot.computer==="local"&&!c.consent.acknowledgeLocalAuto){$("local");return}const m=ne?Ft(U,_):null;if(m&&!m.ok){M(s("botSettings.visibility.needPeople"));return}b.current=!0,h(!0),M(""),l.dispatch({type:"botCreationPending",on:!0});try{if(t)await B("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Et(c)})});else{const{bot:P,warnings:S,paused:E}=await Bt(c,void 0,void 0,void 0,m?.ok?m.visibility:void 0,F?xe(z,c.bot.section,l.state.bots,F)??void 0:void 0);Rt(l.dispatch,P,S,{showThreads:C,source:c.preset?"preset":c.role?"template":"blank",role:c.role,paused:E});try{await a?.(P)}catch(D){l.dispatch({type:"error",message:D instanceof Error?D.message:String(D)})}}b.current=!1,v.current&&J.current()}catch(P){v.current&&M(P instanceof Error?P.message:String(P))}finally{b.current=!1,l.dispatch({type:"botCreationPending",on:!1}),v.current&&h(!1)}},Y=c.bot,Pe={...l,state:{...l.state,bots:[Y,...l.state.bots],routines:c.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>Y,dispatch:m=>{m.type==="updateBot"&&m.botId===c.id?c.patch(m.patch):m.type==="setModel"&&m.botId===c.id?(c.setModel(m.selection),m.resetApprovalToAsk&&c.patch({approvalMode:"ask"})):m.type==="routinePatched"||m.type==="toggleSettings"||l.dispatch(m)}},ie=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&l.state.appSettingsOpen,children:e.jsxs("div",{ref:W,role:"dialog","aria-modal":"true","aria-label":ie,"aria-busy":y,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:ie}),e.jsx("button",{type:"button",onClick:()=>J.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ve,{size:18,className:"pointer-events-none"})})]}),F&&!t&&H&&e.jsx(ps,{team:H}),ne&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(O,{size:"sm",value:U,disabled:y,onChange:m=>K(m.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),U==="people"&&e.jsx("input",{value:_,disabled:y,onChange:m=>V(m.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:L.map(m=>e.jsx("button",{type:"button",onClick:()=>j(m),"aria-current":g===m?"page":void 0,className:G("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",g===m?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(ds[m])},m))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!A&&!f&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:16,className:"animate-spin"}),s("newBot.loading")]}),A&&e.jsx("fieldset",{disabled:y,className:"min-w-0",children:e.jsx(yt,{value:Pe,children:e.jsx(wt.Provider,{value:{request:c.request,draft:!0,uploadAvatar:c.uploadAvatar},children:e.jsx(ms,{active:g,draft:c,defaultsMode:t,owner:F&&!t?{value:xe(z,Y.section,l.state.bots,F),choose:u}:void 0})})})})]})]}),f&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:f}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>J.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!A||y||!t&&!Y.name.trim(),onClick:()=>{ae()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[y&&e.jsx(X,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(jt,{open:I==="local",onCancel:()=>$(null),onConfirm:()=>{c.consent.acknowledgeLocalAuto=!0,$(null),ae()}})]})})}function ps({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{Pt(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function ms({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:l}=k(),d=ke(),c=St(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{draft:n,defaultsMode:a}),e.jsx(Tt,{bot:r,patch:c.patch,activeState:c.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:p=>n.patch({section:p.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...l.sections??[],...l.bots.map(p=>p.section??"")])].filter(Boolean).map(p=>e.jsx("option",{children:p},p))]})]}),i&&d&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(O,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:p=>i.choose(p.target.value),children:d.people.map(p=>e.jsx("option",{value:p.email,children:p.you?s("owner.you",{name:p.name}):p.name},p.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(At,{bot:r,patch:c.patch}):t==="Skills"?e.jsx(Lt,{bot:r}):t==="Memory"?e.jsx(gs,{draft:n}):t==="Routines"?e.jsx(hs,{draft:n}):t==="Access"?e.jsx(Dt,{bot:r,derived:c}):t==="Model"?e.jsx(Ot,{bot:r}):t==="Permissions"?e.jsx(Mt,{bot:r,derived:c}):e.jsx(Ut,{bot:r,derived:c})}function xs({draft:t,defaultsMode:n}){const[a,i]=o.useState([]),[r,l]=o.useState(0),[d,c]=o.useState(""),p=o.useRef(!1);o.useEffect(()=>{if(n)return;let x=!1;return B("/api/bot-presets").then(h=>{x||i(h.presets)}).catch(()=>{x||i([])}),()=>{x=!0}},[n,r]);const g=t.preset?a.find(x=>x.id===t.preset.id):void 0,j=async x=>{c("");const h=x.startsWith("preset:")?a.find(b=>b.id===x.slice(7)):void 0;if(!h){t.choosePreset(void 0);const b=pe.find(f=>f.id===x);t.chooseRole(b?.id);const v=b&&Ne(b.id)?.look;b&&t.patch({...kt(b),...v});return}t.patch(Qt(h)),t.choosePreset(es(h));const y=Zt(h);try{y?(t.patch({avatarUrl:await t.uploadAvatar(y),avatarCrop:h.bot.appearance.avatar.crop}),p.current=!0):p.current&&(t.patch({avatarUrl:""}),p.current=!1)}catch(b){c(b instanceof Error?b.message:String(b))}},A=async x=>{c("");try{await B(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),l(h=>h+1)}catch(h){c(h instanceof Error?h.message:String(h))}},N=pe.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(O,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{j(x.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Xt(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(h=>e.jsx("option",{value:`preset:${h.id}`,children:h.name},h.id))},x.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:N}):N]})]}),g&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[Gt(g).map((x,h)=>e.jsx("p",{className:"break-words",children:x},h)),g.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{A(g)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),d&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:d})]})}function gs({draft:t}){const[n,a]=o.useState("MEMORY.md"),[i,r]=o.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(O,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:l=>a(l.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(l=>e.jsx("option",{children:l},l))}),e.jsx("textarea",{className:G(ge,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:l=>t.setMemory(n,l.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:ge,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:l=>r(l.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const l=`memory/${i}.md`;l in t.template.memory||t.setMemory(l,""),a(l),r("")},children:e.jsx(Ht,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ce,{size:16})})]})]})}function hs({draft:t}){const[n,a]=o.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ce,{size:15})})]},i.id)),n&&e.jsx(zt,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function fs({simple:t=!1}){const[n,a]=o.useState(!1),[i,r]=o.useState(!1),l=e.jsxs(e.Fragment,{children:[n&&e.jsx(Re,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ts,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(os,{onEdit:()=>a(!0),onShare:()=>r(!0)}),l]});const d=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),l]});return e.jsx(w,{title:s("newBot.defaults"),children:d})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:fs,NewBotDialog:Re},Symbol.toStringTag,{value:"Module"}));export{Ms as A,Es as B,Os as C,fs as D,_s as E,Ds as F,As as L,Ps as N,Fs as P,Ts as R,Bs as S,Ks as T,Rs as U,$s as a,Ls as b,Us as c,Is as d,zs as e,Hs as f};
@@ -1 +1 @@
1
- import{r as d,j as t,t as n,I as c,A as x,o as p}from"./styles-DSEcltf1.js";import{r as m}from"./PlacesRail-Bpjyw4Vm.js";import{Q as u}from"./index-3mZteHSQ.js";import"./monitor-Xr0SgoUO.js";const f=[{id:"ios",nameKey:"phoneApp.ios",actionKey:"phoneApp.iosAction",url:c},{id:"android",nameKey:"phoneApp.android",actionKey:"phoneApp.androidAction",url:x}];function j({open:r,onClose:l,connect:i=[]}){const a=d.useRef(null);if(d.useEffect(()=>{if(!r)return;a.current?.focus();const e=o=>{o.key==="Escape"&&(o.preventDefault(),l())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l]),!r)return null;const s=t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:e=>e.target===e.currentTarget&&l(),children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"phone-app-dialog-title",className:"max-h-full w-full max-w-[460px] overflow-y-auto rounded-2xl border border-hairline/50 bg-panel p-6 shadow-2xl",children:[t.jsx("h2",{id:"phone-app-dialog-title",className:"text-[17px] font-semibold text-ink",children:n("phoneApp.title")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.subtitle")}),t.jsx("ul",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:f.map(e=>t.jsxs("li",{"data-phone-app":e.id,className:"flex flex-col items-center gap-3 rounded-xl bg-card p-4 text-center",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(e.nameKey)}),t.jsx("div",{className:"rounded-md bg-white p-2",children:t.jsx(u,{value:e.url,size:132,level:"M",bgColor:"#ffffff",fgColor:"#111111",title:n(e.actionKey)})}),t.jsx("button",{type:"button",onClick:()=>{p(e.url)},className:"text-[13px] text-accent hover:underline",children:n(e.actionKey)})]},e.id))}),i.length?t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.next")}),i.map((e,o)=>t.jsxs("button",{type:"button","data-phone-app-connect":e.key,onClick:()=>{l(),e.onSelect()},className:o===0?"flex w-full flex-col items-center rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:opacity-90":"flex w-full flex-col items-center rounded-xl border border-hairline/50 px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:[t.jsx("span",{children:n("sidebar.menu.connectPhone")}),t.jsx("span",{className:"text-[12px] font-normal opacity-80",children:e.subtitle})]},e.key))]}):null,t.jsx("button",{ref:a,type:"button",onClick:l,className:"mt-3 w-full rounded-xl bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:brightness-110",children:n("common.close")})]})});return typeof document>"u"?s:m.createPortal(s,document.body)}export{f as PHONE_APPS,j as PhoneAppDialog};
1
+ import{r as d,j as t,t as n,I as c,A as x,o as p}from"./styles-GmtHzqPG.js";import{r as m}from"./PlacesRail-BJBF_akb.js";import{Q as u}from"./index-5OuBrk-s.js";import"./monitor-Chdrm5wS.js";const f=[{id:"ios",nameKey:"phoneApp.ios",actionKey:"phoneApp.iosAction",url:c},{id:"android",nameKey:"phoneApp.android",actionKey:"phoneApp.androidAction",url:x}];function j({open:r,onClose:l,connect:i=[]}){const a=d.useRef(null);if(d.useEffect(()=>{if(!r)return;a.current?.focus();const e=o=>{o.key==="Escape"&&(o.preventDefault(),l())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l]),!r)return null;const s=t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:e=>e.target===e.currentTarget&&l(),children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"phone-app-dialog-title",className:"max-h-full w-full max-w-[460px] overflow-y-auto rounded-2xl border border-hairline/50 bg-panel p-6 shadow-2xl",children:[t.jsx("h2",{id:"phone-app-dialog-title",className:"text-[17px] font-semibold text-ink",children:n("phoneApp.title")}),t.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.subtitle")}),t.jsx("ul",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:f.map(e=>t.jsxs("li",{"data-phone-app":e.id,className:"flex flex-col items-center gap-3 rounded-xl bg-card p-4 text-center",children:[t.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(e.nameKey)}),t.jsx("div",{className:"rounded-md bg-white p-2",children:t.jsx(u,{value:e.url,size:132,level:"M",bgColor:"#ffffff",fgColor:"#111111",title:n(e.actionKey)})}),t.jsx("button",{type:"button",onClick:()=>{p(e.url)},className:"text-[13px] text-accent hover:underline",children:n(e.actionKey)})]},e.id))}),i.length?t.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[t.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:n("phoneApp.next")}),i.map((e,o)=>t.jsxs("button",{type:"button","data-phone-app-connect":e.key,onClick:()=>{l(),e.onSelect()},className:o===0?"flex w-full flex-col items-center rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:opacity-90":"flex w-full flex-col items-center rounded-xl border border-hairline/50 px-4 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:[t.jsx("span",{children:n("sidebar.menu.connectPhone")}),t.jsx("span",{className:"text-[12px] font-normal opacity-80",children:e.subtitle})]},e.key))]}):null,t.jsx("button",{ref:a,type:"button",onClick:l,className:"mt-3 w-full rounded-xl bg-raised px-4 py-2 text-[13px] font-medium text-ink hover:brightness-110",children:n("common.close")})]})});return typeof document>"u"?s:m.createPortal(s,document.body)}export{f as PHONE_APPS,j as PhoneAppDialog};