@iblai/iblai-js 2.67.3 → 2.68.1

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 (400) hide show
  1. package/dist/web-containers/source/account-sheet.js +2 -2
  2. package/dist/web-containers/source/account-sheet.js.map +1 -1
  3. package/dist/web-containers/source/account.js +39 -21
  4. package/dist/web-containers/source/account.js.map +1 -1
  5. package/dist/web-containers/source/api/api-field-label.js +14 -0
  6. package/dist/web-containers/source/api/api-field-label.js.map +1 -0
  7. package/dist/web-containers/source/{profile/integration/api-tab → api}/api-key-modal.js +8 -8
  8. package/dist/web-containers/source/api/api-key-modal.js.map +1 -0
  9. package/dist/web-containers/source/api/api-keys-table.js +61 -0
  10. package/dist/web-containers/source/api/api-keys-table.js.map +1 -0
  11. package/dist/web-containers/source/{api-tab → api}/api-token-utils.js +34 -1
  12. package/dist/web-containers/source/api/api-token-utils.js.map +1 -0
  13. package/dist/web-containers/source/{integration/api-tab → api}/constants.js +0 -1
  14. package/dist/web-containers/source/api/constants.js.map +1 -0
  15. package/dist/web-containers/source/{profile/integration/api-tab → api}/create-api-modal.js +19 -26
  16. package/dist/web-containers/source/api/create-api-modal.js.map +1 -0
  17. package/dist/web-containers/source/api/delete-api-modal.js +31 -0
  18. package/dist/web-containers/source/api/delete-api-modal.js.map +1 -0
  19. package/dist/web-containers/source/{api-tab → api}/edit-api-modal.js +34 -28
  20. package/dist/web-containers/source/api/edit-api-modal.js.map +1 -0
  21. package/dist/web-containers/source/api/expiration-date-field.js +35 -0
  22. package/dist/web-containers/source/api/expiration-date-field.js.map +1 -0
  23. package/dist/web-containers/source/api/index.js +30 -0
  24. package/dist/web-containers/source/api/index.js.map +1 -0
  25. package/dist/web-containers/source/{integration/api-tab → api}/token-policy-fields.js +6 -6
  26. package/dist/web-containers/source/api/token-policy-fields.js.map +1 -0
  27. package/dist/web-containers/source/api-field-label.js +14 -0
  28. package/dist/web-containers/source/api-field-label.js.map +1 -0
  29. package/dist/web-containers/source/api-keys-table.js +61 -0
  30. package/dist/web-containers/source/api-keys-table.js.map +1 -0
  31. package/dist/web-containers/source/api-tab/create-api-modal.js +4 -4
  32. package/dist/web-containers/source/api-tab/labels.js +23 -19
  33. package/dist/web-containers/source/api-tab/labels.js.map +1 -1
  34. package/dist/web-containers/source/api-tab.js +15 -20
  35. package/dist/web-containers/source/api-tab.js.map +1 -1
  36. package/dist/web-containers/source/api-token-utils.js +34 -1
  37. package/dist/web-containers/source/api-token-utils.js.map +1 -1
  38. package/dist/web-containers/source/azure-config.js +37 -0
  39. package/dist/web-containers/source/azure-config.js.map +1 -0
  40. package/dist/web-containers/source/azure-model-fields.js +118 -0
  41. package/dist/web-containers/source/azure-model-fields.js.map +1 -0
  42. package/dist/web-containers/source/claw-sandbox/virtual-machine-network-section.js +147 -24
  43. package/dist/web-containers/source/claw-sandbox/virtual-machine-network-section.js.map +1 -1
  44. package/dist/web-containers/source/components/claw-sandbox/virtual-machine-network-section.js +147 -24
  45. package/dist/web-containers/source/components/claw-sandbox/virtual-machine-network-section.js.map +1 -1
  46. package/dist/web-containers/source/components/document-sidebar.js +5 -4
  47. package/dist/web-containers/source/components/document-sidebar.js.map +1 -1
  48. package/dist/web-containers/source/components/field-info.js +18 -0
  49. package/dist/web-containers/source/components/field-info.js.map +1 -0
  50. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/api-tab/create-api-modal.js +4 -4
  51. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/api-tab/labels.js +23 -19
  52. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/api-tab/labels.js.map +1 -1
  53. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/api-tab.js +15 -20
  54. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/api-tab.js.map +1 -1
  55. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js +1 -1
  56. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js +2 -2
  57. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js.map +1 -1
  58. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/skills-tab/index.js +1 -1
  59. package/dist/web-containers/source/components/modals/user-profile-modal.js +4 -4
  60. package/dist/web-containers/source/components/modals/user-profile-modal.js.map +1 -1
  61. package/dist/web-containers/source/components/platform-sidebar/account-sheet.js +2 -2
  62. package/dist/web-containers/source/components/platform-sidebar/account-sheet.js.map +1 -1
  63. package/dist/web-containers/source/components/platform-sidebar/footer.js +15 -14
  64. package/dist/web-containers/source/components/platform-sidebar/footer.js.map +1 -1
  65. package/dist/web-containers/source/components/platform-sidebar/index.js +0 -2
  66. package/dist/web-containers/source/components/platform-sidebar/index.js.map +1 -1
  67. package/dist/web-containers/source/components/profile/account.js +39 -21
  68. package/dist/web-containers/source/components/profile/account.js.map +1 -1
  69. package/dist/web-containers/source/components/profile/api/api-field-label.js +14 -0
  70. package/dist/web-containers/source/components/profile/api/api-field-label.js.map +1 -0
  71. package/dist/web-containers/source/{integration/api-tab → components/profile/api}/api-key-modal.js +8 -8
  72. package/dist/web-containers/source/components/profile/api/api-key-modal.js.map +1 -0
  73. package/dist/web-containers/source/components/profile/api/api-keys-table.js +61 -0
  74. package/dist/web-containers/source/components/profile/api/api-keys-table.js.map +1 -0
  75. package/dist/web-containers/source/{integration/api-tab → components/profile/api}/api-token-utils.js +34 -1
  76. package/dist/web-containers/source/components/profile/api/api-token-utils.js.map +1 -0
  77. package/dist/web-containers/source/components/profile/{integration/api-tab → api}/constants.js +0 -1
  78. package/dist/web-containers/source/components/profile/api/constants.js.map +1 -0
  79. package/dist/web-containers/source/{integration/api-tab → components/profile/api}/create-api-modal.js +19 -26
  80. package/dist/web-containers/source/components/profile/api/create-api-modal.js.map +1 -0
  81. package/dist/web-containers/source/components/profile/api/delete-api-modal.js +31 -0
  82. package/dist/web-containers/source/components/profile/api/delete-api-modal.js.map +1 -0
  83. package/dist/web-containers/source/components/profile/{integration/api-tab → api}/edit-api-modal.js +34 -28
  84. package/dist/web-containers/source/components/profile/api/edit-api-modal.js.map +1 -0
  85. package/dist/web-containers/source/components/profile/api/expiration-date-field.js +35 -0
  86. package/dist/web-containers/source/components/profile/api/expiration-date-field.js.map +1 -0
  87. package/dist/web-containers/source/components/profile/api/index.js +30 -0
  88. package/dist/web-containers/source/components/profile/api/index.js.map +1 -0
  89. package/dist/web-containers/source/{profile/integration/api-tab → components/profile/api}/token-policy-fields.js +6 -6
  90. package/dist/web-containers/source/components/profile/api/token-policy-fields.js.map +1 -0
  91. package/dist/web-containers/source/components/profile/info-banner.js +3 -1
  92. package/dist/web-containers/source/components/profile/info-banner.js.map +1 -1
  93. package/dist/web-containers/source/components/profile/integration/index.js +17 -38
  94. package/dist/web-containers/source/components/profile/integration/index.js.map +1 -1
  95. package/dist/web-containers/source/components/profile/secrets/index.js +106 -0
  96. package/dist/web-containers/source/components/profile/secrets/index.js.map +1 -0
  97. package/dist/web-containers/source/components/profile/secrets/secrets-list.js +237 -0
  98. package/dist/web-containers/source/components/profile/secrets/secrets-list.js.map +1 -0
  99. package/dist/web-containers/source/components/profile/virtual-machine-admin/index.js +12 -18
  100. package/dist/web-containers/source/components/profile/virtual-machine-admin/index.js.map +1 -1
  101. package/dist/web-containers/source/components/profile/virtual-machine-admin/network-policies-section.js +5 -4
  102. package/dist/web-containers/source/components/profile/virtual-machine-admin/network-policies-section.js.map +1 -1
  103. package/dist/web-containers/source/components/tooltip-icon-button.js +15 -0
  104. package/dist/web-containers/source/components/tooltip-icon-button.js.map +1 -0
  105. package/dist/web-containers/source/components/user-profile-dropdown/index.js +2 -0
  106. package/dist/web-containers/source/components/user-profile-dropdown/index.js.map +1 -1
  107. package/dist/web-containers/source/components/virtual-machine/azure-config.js +37 -0
  108. package/dist/web-containers/source/components/virtual-machine/azure-config.js.map +1 -0
  109. package/dist/web-containers/source/components/virtual-machine/azure-model-fields.js +118 -0
  110. package/dist/web-containers/source/components/virtual-machine/azure-model-fields.js.map +1 -0
  111. package/dist/web-containers/source/components/virtual-machine/credential-options.js +268 -22
  112. package/dist/web-containers/source/components/virtual-machine/credential-options.js.map +1 -1
  113. package/dist/web-containers/source/components/virtual-machine/host-port-chip-input.js +14 -8
  114. package/dist/web-containers/source/components/virtual-machine/host-port-chip-input.js.map +1 -1
  115. package/dist/web-containers/source/components/virtual-machine/network-policy-dialog.js +30 -6
  116. package/dist/web-containers/source/components/virtual-machine/network-policy-dialog.js.map +1 -1
  117. package/dist/web-containers/source/components/virtual-machine/secret-rows.js +66 -0
  118. package/dist/web-containers/source/components/virtual-machine/secret-rows.js.map +1 -0
  119. package/dist/web-containers/source/components/virtual-machine/vm-secret-dialog.js +848 -158
  120. package/dist/web-containers/source/components/virtual-machine/vm-secret-dialog.js.map +1 -1
  121. package/dist/web-containers/source/connector-dialogs.js +1 -1
  122. package/dist/web-containers/source/constants.js +55 -22
  123. package/dist/web-containers/source/constants.js.map +1 -1
  124. package/dist/web-containers/source/create-api-modal.js +4 -4
  125. package/dist/web-containers/source/credential-options.js +268 -22
  126. package/dist/web-containers/source/credential-options.js.map +1 -1
  127. package/dist/web-containers/source/document-preview.js +14 -6
  128. package/dist/web-containers/source/document-preview.js.map +1 -1
  129. package/dist/web-containers/source/document-sidebar.js +5 -4
  130. package/dist/web-containers/source/document-sidebar.js.map +1 -1
  131. package/dist/web-containers/source/edit-api-modal.js +34 -28
  132. package/dist/web-containers/source/edit-api-modal.js.map +1 -1
  133. package/dist/web-containers/source/edit-mentor-modal/tabs/api-tab/create-api-modal.js +4 -4
  134. package/dist/web-containers/source/edit-mentor-modal/tabs/api-tab/labels.js +23 -19
  135. package/dist/web-containers/source/edit-mentor-modal/tabs/api-tab/labels.js.map +1 -1
  136. package/dist/web-containers/source/edit-mentor-modal/tabs/api-tab.js +15 -20
  137. package/dist/web-containers/source/edit-mentor-modal/tabs/api-tab.js.map +1 -1
  138. package/dist/web-containers/source/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js +1 -1
  139. package/dist/web-containers/source/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js +2 -2
  140. package/dist/web-containers/source/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js.map +1 -1
  141. package/dist/web-containers/source/edit-mentor-modal/tabs/skills-tab/index.js +1 -1
  142. package/dist/web-containers/source/en.json.js +279 -227
  143. package/dist/web-containers/source/en.json.js.map +1 -1
  144. package/dist/web-containers/source/es.json.js +450 -398
  145. package/dist/web-containers/source/es.json.js.map +1 -1
  146. package/dist/web-containers/source/expiration-date-field.js +16 -10
  147. package/dist/web-containers/source/expiration-date-field.js.map +1 -1
  148. package/dist/web-containers/source/field-info.js +11 -7
  149. package/dist/web-containers/source/field-info.js.map +1 -1
  150. package/dist/web-containers/source/footer.js +15 -14
  151. package/dist/web-containers/source/footer.js.map +1 -1
  152. package/dist/web-containers/source/fr.json.js +458 -406
  153. package/dist/web-containers/source/fr.json.js.map +1 -1
  154. package/dist/web-containers/source/host-port-chip-input.js +14 -8
  155. package/dist/web-containers/source/host-port-chip-input.js.map +1 -1
  156. package/dist/web-containers/source/i18n/messages/en.json.js +279 -227
  157. package/dist/web-containers/source/i18n/messages/en.json.js.map +1 -1
  158. package/dist/web-containers/source/i18n/messages/es.json.js +450 -398
  159. package/dist/web-containers/source/i18n/messages/es.json.js.map +1 -1
  160. package/dist/web-containers/source/i18n/messages/fr.json.js +458 -406
  161. package/dist/web-containers/source/i18n/messages/fr.json.js.map +1 -1
  162. package/dist/web-containers/source/i18n/messages/zh.json.js +457 -405
  163. package/dist/web-containers/source/i18n/messages/zh.json.js.map +1 -1
  164. package/dist/web-containers/source/info-banner.js +3 -1
  165. package/dist/web-containers/source/info-banner.js.map +1 -1
  166. package/dist/web-containers/source/integration/index.js +17 -38
  167. package/dist/web-containers/source/integration/index.js.map +1 -1
  168. package/dist/web-containers/source/lib/document-preview.js +14 -6
  169. package/dist/web-containers/source/lib/document-preview.js.map +1 -1
  170. package/dist/web-containers/source/mcp-tab/connector-dialogs.js +1 -1
  171. package/dist/web-containers/source/mcp-tab/oauth-app-fields.js +2 -2
  172. package/dist/web-containers/source/mcp-tab/oauth-app-fields.js.map +1 -1
  173. package/dist/web-containers/source/messages/en.json.js +279 -227
  174. package/dist/web-containers/source/messages/en.json.js.map +1 -1
  175. package/dist/web-containers/source/messages/es.json.js +450 -398
  176. package/dist/web-containers/source/messages/es.json.js.map +1 -1
  177. package/dist/web-containers/source/messages/fr.json.js +458 -406
  178. package/dist/web-containers/source/messages/fr.json.js.map +1 -1
  179. package/dist/web-containers/source/messages/zh.json.js +457 -405
  180. package/dist/web-containers/source/messages/zh.json.js.map +1 -1
  181. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/api-tab/create-api-modal.js +4 -4
  182. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/api-tab/labels.js +23 -19
  183. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/api-tab/labels.js.map +1 -1
  184. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/api-tab.js +15 -20
  185. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/api-tab.js.map +1 -1
  186. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js +1 -1
  187. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js +2 -2
  188. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js.map +1 -1
  189. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/skills-tab/index.js +1 -1
  190. package/dist/web-containers/source/modals/user-profile-modal.js +4 -4
  191. package/dist/web-containers/source/modals/user-profile-modal.js.map +1 -1
  192. package/dist/web-containers/source/network-policies-section.js +5 -4
  193. package/dist/web-containers/source/network-policies-section.js.map +1 -1
  194. package/dist/web-containers/source/network-policy-dialog.js +30 -6
  195. package/dist/web-containers/source/network-policy-dialog.js.map +1 -1
  196. package/dist/web-containers/source/oauth-app-fields.js +2 -2
  197. package/dist/web-containers/source/oauth-app-fields.js.map +1 -1
  198. package/dist/web-containers/source/platform-sidebar/account-sheet.js +2 -2
  199. package/dist/web-containers/source/platform-sidebar/account-sheet.js.map +1 -1
  200. package/dist/web-containers/source/platform-sidebar/footer.js +15 -14
  201. package/dist/web-containers/source/platform-sidebar/footer.js.map +1 -1
  202. package/dist/web-containers/source/platform-sidebar/index.js +0 -2
  203. package/dist/web-containers/source/platform-sidebar/index.js.map +1 -1
  204. package/dist/web-containers/source/profile/account.js +39 -21
  205. package/dist/web-containers/source/profile/account.js.map +1 -1
  206. package/dist/web-containers/source/profile/api/api-field-label.js +14 -0
  207. package/dist/web-containers/source/profile/api/api-field-label.js.map +1 -0
  208. package/dist/web-containers/source/{components/profile/integration/api-tab → profile/api}/api-key-modal.js +8 -8
  209. package/dist/web-containers/source/profile/api/api-key-modal.js.map +1 -0
  210. package/dist/web-containers/source/profile/api/api-keys-table.js +61 -0
  211. package/dist/web-containers/source/profile/api/api-keys-table.js.map +1 -0
  212. package/dist/web-containers/source/profile/{integration/api-tab → api}/api-token-utils.js +34 -1
  213. package/dist/web-containers/source/profile/api/api-token-utils.js.map +1 -0
  214. package/dist/web-containers/source/{api-tab → profile/api}/constants.js +0 -1
  215. package/dist/web-containers/source/profile/api/constants.js.map +1 -0
  216. package/dist/web-containers/source/{components/profile/integration/api-tab → profile/api}/create-api-modal.js +19 -26
  217. package/dist/web-containers/source/profile/api/create-api-modal.js.map +1 -0
  218. package/dist/web-containers/source/profile/api/delete-api-modal.js +31 -0
  219. package/dist/web-containers/source/profile/api/delete-api-modal.js.map +1 -0
  220. package/dist/web-containers/source/{integration/api-tab → profile/api}/edit-api-modal.js +34 -28
  221. package/dist/web-containers/source/profile/api/edit-api-modal.js.map +1 -0
  222. package/dist/web-containers/source/profile/api/expiration-date-field.js +35 -0
  223. package/dist/web-containers/source/profile/api/expiration-date-field.js.map +1 -0
  224. package/dist/web-containers/source/profile/api/index.js +30 -0
  225. package/dist/web-containers/source/profile/api/index.js.map +1 -0
  226. package/dist/web-containers/source/{api-tab → profile/api}/token-policy-fields.js +6 -6
  227. package/dist/web-containers/source/profile/api/token-policy-fields.js.map +1 -0
  228. package/dist/web-containers/source/profile/info-banner.js +3 -1
  229. package/dist/web-containers/source/profile/info-banner.js.map +1 -1
  230. package/dist/web-containers/source/profile/integration/index.js +17 -38
  231. package/dist/web-containers/source/profile/integration/index.js.map +1 -1
  232. package/dist/web-containers/source/profile/secrets/index.js +106 -0
  233. package/dist/web-containers/source/profile/secrets/index.js.map +1 -0
  234. package/dist/web-containers/source/profile/secrets/secrets-list.js +237 -0
  235. package/dist/web-containers/source/profile/secrets/secrets-list.js.map +1 -0
  236. package/dist/web-containers/source/profile/virtual-machine-admin/index.js +12 -18
  237. package/dist/web-containers/source/profile/virtual-machine-admin/index.js.map +1 -1
  238. package/dist/web-containers/source/profile/virtual-machine-admin/network-policies-section.js +5 -4
  239. package/dist/web-containers/source/profile/virtual-machine-admin/network-policies-section.js.map +1 -1
  240. package/dist/web-containers/source/secret-rows.js +66 -0
  241. package/dist/web-containers/source/secret-rows.js.map +1 -0
  242. package/dist/web-containers/source/secrets/index.js +106 -0
  243. package/dist/web-containers/source/secrets/index.js.map +1 -0
  244. package/dist/web-containers/source/secrets/secrets-list.js +237 -0
  245. package/dist/web-containers/source/secrets/secrets-list.js.map +1 -0
  246. package/dist/web-containers/source/secrets-list.js +237 -0
  247. package/dist/web-containers/source/secrets-list.js.map +1 -0
  248. package/dist/web-containers/source/skills-tab/index.js +1 -1
  249. package/dist/web-containers/source/tabs/api-tab/create-api-modal.js +4 -4
  250. package/dist/web-containers/source/tabs/api-tab/labels.js +23 -19
  251. package/dist/web-containers/source/tabs/api-tab/labels.js.map +1 -1
  252. package/dist/web-containers/source/tabs/api-tab.js +15 -20
  253. package/dist/web-containers/source/tabs/api-tab.js.map +1 -1
  254. package/dist/web-containers/source/tabs/mcp-tab/connector-dialogs.js +1 -1
  255. package/dist/web-containers/source/tabs/mcp-tab/oauth-app-fields.js +2 -2
  256. package/dist/web-containers/source/tabs/mcp-tab/oauth-app-fields.js.map +1 -1
  257. package/dist/web-containers/source/tabs/skills-tab/index.js +1 -1
  258. package/dist/web-containers/source/token-policy-fields.js +6 -6
  259. package/dist/web-containers/source/token-policy-fields.js.map +1 -1
  260. package/dist/web-containers/source/tooltip-icon-button.js +15 -0
  261. package/dist/web-containers/source/tooltip-icon-button.js.map +1 -0
  262. package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
  263. package/dist/web-containers/source/user-profile-dropdown/index.js +2 -0
  264. package/dist/web-containers/source/user-profile-dropdown/index.js.map +1 -1
  265. package/dist/web-containers/source/user-profile-modal.js +4 -4
  266. package/dist/web-containers/source/user-profile-modal.js.map +1 -1
  267. package/dist/web-containers/source/virtual-machine/azure-config.js +37 -0
  268. package/dist/web-containers/source/virtual-machine/azure-config.js.map +1 -0
  269. package/dist/web-containers/source/virtual-machine/azure-model-fields.js +118 -0
  270. package/dist/web-containers/source/virtual-machine/azure-model-fields.js.map +1 -0
  271. package/dist/web-containers/source/virtual-machine/credential-options.js +268 -22
  272. package/dist/web-containers/source/virtual-machine/credential-options.js.map +1 -1
  273. package/dist/web-containers/source/virtual-machine/host-port-chip-input.js +14 -8
  274. package/dist/web-containers/source/virtual-machine/host-port-chip-input.js.map +1 -1
  275. package/dist/web-containers/source/virtual-machine/network-policy-dialog.js +30 -6
  276. package/dist/web-containers/source/virtual-machine/network-policy-dialog.js.map +1 -1
  277. package/dist/web-containers/source/virtual-machine/secret-rows.js +66 -0
  278. package/dist/web-containers/source/virtual-machine/secret-rows.js.map +1 -0
  279. package/dist/web-containers/source/virtual-machine/vm-secret-dialog.js +848 -158
  280. package/dist/web-containers/source/virtual-machine/vm-secret-dialog.js.map +1 -1
  281. package/dist/web-containers/source/virtual-machine-admin/index.js +12 -18
  282. package/dist/web-containers/source/virtual-machine-admin/index.js.map +1 -1
  283. package/dist/web-containers/source/virtual-machine-admin/network-policies-section.js +5 -4
  284. package/dist/web-containers/source/virtual-machine-admin/network-policies-section.js.map +1 -1
  285. package/dist/web-containers/source/virtual-machine-network-section.js +147 -24
  286. package/dist/web-containers/source/virtual-machine-network-section.js.map +1 -1
  287. package/dist/web-containers/source/vm-secret-dialog.js +848 -158
  288. package/dist/web-containers/source/vm-secret-dialog.js.map +1 -1
  289. package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
  290. package/dist/web-containers/source/zh.json.js +457 -405
  291. package/dist/web-containers/source/zh.json.js.map +1 -1
  292. package/package.json +4 -4
  293. package/dist/web-containers/source/api-tab/api-token-utils.js.map +0 -1
  294. package/dist/web-containers/source/api-tab/constants.js.map +0 -1
  295. package/dist/web-containers/source/api-tab/edit-api-modal.js.map +0 -1
  296. package/dist/web-containers/source/api-tab/expiration-date-field.js +0 -29
  297. package/dist/web-containers/source/api-tab/expiration-date-field.js.map +0 -1
  298. package/dist/web-containers/source/api-tab/integration-autogenerated-table.js +0 -42
  299. package/dist/web-containers/source/api-tab/integration-autogenerated-table.js.map +0 -1
  300. package/dist/web-containers/source/api-tab/token-policy-fields.js.map +0 -1
  301. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js +0 -14
  302. package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js.map +0 -1
  303. package/dist/web-containers/source/components/profile/integration/api-tab/api-key-modal.js.map +0 -1
  304. package/dist/web-containers/source/components/profile/integration/api-tab/api-token-utils.js +0 -57
  305. package/dist/web-containers/source/components/profile/integration/api-tab/api-token-utils.js.map +0 -1
  306. package/dist/web-containers/source/components/profile/integration/api-tab/constants.js.map +0 -1
  307. package/dist/web-containers/source/components/profile/integration/api-tab/create-api-modal.js.map +0 -1
  308. package/dist/web-containers/source/components/profile/integration/api-tab/delete-api-modal.js +0 -31
  309. package/dist/web-containers/source/components/profile/integration/api-tab/delete-api-modal.js.map +0 -1
  310. package/dist/web-containers/source/components/profile/integration/api-tab/edit-api-modal.js.map +0 -1
  311. package/dist/web-containers/source/components/profile/integration/api-tab/expiration-date-field.js +0 -29
  312. package/dist/web-containers/source/components/profile/integration/api-tab/expiration-date-field.js.map +0 -1
  313. package/dist/web-containers/source/components/profile/integration/api-tab/integration-autogenerated-table.js +0 -42
  314. package/dist/web-containers/source/components/profile/integration/api-tab/integration-autogenerated-table.js.map +0 -1
  315. package/dist/web-containers/source/components/profile/integration/api-tab/token-policy-fields.js +0 -101
  316. package/dist/web-containers/source/components/profile/integration/api-tab/token-policy-fields.js.map +0 -1
  317. package/dist/web-containers/source/components/profile/integration/data-sources-tab/create-data-source-modal.js +0 -143
  318. package/dist/web-containers/source/components/profile/integration/data-sources-tab/create-data-source-modal.js.map +0 -1
  319. package/dist/web-containers/source/components/profile/integration/data-sources-tab/integration-data-sources-tab.js +0 -46
  320. package/dist/web-containers/source/components/profile/integration/data-sources-tab/integration-data-sources-tab.js.map +0 -1
  321. package/dist/web-containers/source/components/profile/integration/llms-tab/create-llm-modal.js +0 -287
  322. package/dist/web-containers/source/components/profile/integration/llms-tab/create-llm-modal.js.map +0 -1
  323. package/dist/web-containers/source/components/profile/integration/llms-tab/integration-llms-tab.js +0 -83
  324. package/dist/web-containers/source/components/profile/integration/llms-tab/integration-llms-tab.js.map +0 -1
  325. package/dist/web-containers/source/components/profile/virtual-machine-admin/vm-secrets-section.js +0 -109
  326. package/dist/web-containers/source/components/profile/virtual-machine-admin/vm-secrets-section.js.map +0 -1
  327. package/dist/web-containers/source/create-data-source-modal.js +0 -143
  328. package/dist/web-containers/source/create-data-source-modal.js.map +0 -1
  329. package/dist/web-containers/source/create-llm-modal.js +0 -287
  330. package/dist/web-containers/source/create-llm-modal.js.map +0 -1
  331. package/dist/web-containers/source/data-sources-tab/create-data-source-modal.js +0 -143
  332. package/dist/web-containers/source/data-sources-tab/create-data-source-modal.js.map +0 -1
  333. package/dist/web-containers/source/data-sources-tab/integration-data-sources-tab.js +0 -46
  334. package/dist/web-containers/source/data-sources-tab/integration-data-sources-tab.js.map +0 -1
  335. package/dist/web-containers/source/edit-mentor-modal/tabs/mcp-tab/field-info.js +0 -14
  336. package/dist/web-containers/source/edit-mentor-modal/tabs/mcp-tab/field-info.js.map +0 -1
  337. package/dist/web-containers/source/integration/api-tab/api-key-modal.js.map +0 -1
  338. package/dist/web-containers/source/integration/api-tab/api-token-utils.js.map +0 -1
  339. package/dist/web-containers/source/integration/api-tab/constants.js.map +0 -1
  340. package/dist/web-containers/source/integration/api-tab/create-api-modal.js.map +0 -1
  341. package/dist/web-containers/source/integration/api-tab/delete-api-modal.js +0 -31
  342. package/dist/web-containers/source/integration/api-tab/delete-api-modal.js.map +0 -1
  343. package/dist/web-containers/source/integration/api-tab/edit-api-modal.js.map +0 -1
  344. package/dist/web-containers/source/integration/api-tab/expiration-date-field.js +0 -29
  345. package/dist/web-containers/source/integration/api-tab/expiration-date-field.js.map +0 -1
  346. package/dist/web-containers/source/integration/api-tab/integration-autogenerated-table.js +0 -42
  347. package/dist/web-containers/source/integration/api-tab/integration-autogenerated-table.js.map +0 -1
  348. package/dist/web-containers/source/integration/api-tab/token-policy-fields.js.map +0 -1
  349. package/dist/web-containers/source/integration/data-sources-tab/create-data-source-modal.js +0 -143
  350. package/dist/web-containers/source/integration/data-sources-tab/create-data-source-modal.js.map +0 -1
  351. package/dist/web-containers/source/integration/data-sources-tab/integration-data-sources-tab.js +0 -46
  352. package/dist/web-containers/source/integration/data-sources-tab/integration-data-sources-tab.js.map +0 -1
  353. package/dist/web-containers/source/integration/llms-tab/create-llm-modal.js +0 -287
  354. package/dist/web-containers/source/integration/llms-tab/create-llm-modal.js.map +0 -1
  355. package/dist/web-containers/source/integration/llms-tab/integration-llms-tab.js +0 -83
  356. package/dist/web-containers/source/integration/llms-tab/integration-llms-tab.js.map +0 -1
  357. package/dist/web-containers/source/integration-autogenerated-table.js +0 -42
  358. package/dist/web-containers/source/integration-autogenerated-table.js.map +0 -1
  359. package/dist/web-containers/source/integration-data-sources-tab.js +0 -46
  360. package/dist/web-containers/source/integration-data-sources-tab.js.map +0 -1
  361. package/dist/web-containers/source/integration-llms-tab.js +0 -83
  362. package/dist/web-containers/source/integration-llms-tab.js.map +0 -1
  363. package/dist/web-containers/source/llms-tab/create-llm-modal.js +0 -287
  364. package/dist/web-containers/source/llms-tab/create-llm-modal.js.map +0 -1
  365. package/dist/web-containers/source/llms-tab/integration-llms-tab.js +0 -83
  366. package/dist/web-containers/source/llms-tab/integration-llms-tab.js.map +0 -1
  367. package/dist/web-containers/source/mcp-tab/field-info.js +0 -14
  368. package/dist/web-containers/source/mcp-tab/field-info.js.map +0 -1
  369. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js +0 -14
  370. package/dist/web-containers/source/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js.map +0 -1
  371. package/dist/web-containers/source/profile/integration/api-tab/api-key-modal.js.map +0 -1
  372. package/dist/web-containers/source/profile/integration/api-tab/api-token-utils.js.map +0 -1
  373. package/dist/web-containers/source/profile/integration/api-tab/constants.js +0 -24
  374. package/dist/web-containers/source/profile/integration/api-tab/constants.js.map +0 -1
  375. package/dist/web-containers/source/profile/integration/api-tab/create-api-modal.js.map +0 -1
  376. package/dist/web-containers/source/profile/integration/api-tab/delete-api-modal.js +0 -31
  377. package/dist/web-containers/source/profile/integration/api-tab/delete-api-modal.js.map +0 -1
  378. package/dist/web-containers/source/profile/integration/api-tab/edit-api-modal.js +0 -113
  379. package/dist/web-containers/source/profile/integration/api-tab/edit-api-modal.js.map +0 -1
  380. package/dist/web-containers/source/profile/integration/api-tab/expiration-date-field.js +0 -29
  381. package/dist/web-containers/source/profile/integration/api-tab/expiration-date-field.js.map +0 -1
  382. package/dist/web-containers/source/profile/integration/api-tab/integration-autogenerated-table.js +0 -42
  383. package/dist/web-containers/source/profile/integration/api-tab/integration-autogenerated-table.js.map +0 -1
  384. package/dist/web-containers/source/profile/integration/api-tab/token-policy-fields.js.map +0 -1
  385. package/dist/web-containers/source/profile/integration/data-sources-tab/create-data-source-modal.js +0 -143
  386. package/dist/web-containers/source/profile/integration/data-sources-tab/create-data-source-modal.js.map +0 -1
  387. package/dist/web-containers/source/profile/integration/data-sources-tab/integration-data-sources-tab.js +0 -46
  388. package/dist/web-containers/source/profile/integration/data-sources-tab/integration-data-sources-tab.js.map +0 -1
  389. package/dist/web-containers/source/profile/integration/llms-tab/create-llm-modal.js +0 -287
  390. package/dist/web-containers/source/profile/integration/llms-tab/create-llm-modal.js.map +0 -1
  391. package/dist/web-containers/source/profile/integration/llms-tab/integration-llms-tab.js +0 -83
  392. package/dist/web-containers/source/profile/integration/llms-tab/integration-llms-tab.js.map +0 -1
  393. package/dist/web-containers/source/profile/virtual-machine-admin/vm-secrets-section.js +0 -109
  394. package/dist/web-containers/source/profile/virtual-machine-admin/vm-secrets-section.js.map +0 -1
  395. package/dist/web-containers/source/tabs/mcp-tab/field-info.js +0 -14
  396. package/dist/web-containers/source/tabs/mcp-tab/field-info.js.map +0 -1
  397. package/dist/web-containers/source/virtual-machine-admin/vm-secrets-section.js +0 -109
  398. package/dist/web-containers/source/virtual-machine-admin/vm-secrets-section.js.map +0 -1
  399. package/dist/web-containers/source/vm-secrets-section.js +0 -109
  400. package/dist/web-containers/source/vm-secrets-section.js.map +0 -1
@@ -1,222 +1,912 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useId, useState, useEffect } from 'react';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { useId, useRef, useState, useMemo, useEffect } from 'react';
3
3
  import { toast } from 'sonner';
4
- import { useCreateVirtualMachineSecretMutation, useUpdateVirtualMachineSecretMutation, VIRTUAL_MACHINE_SECRET_VALUE_MIN_LENGTH, VIRTUAL_MACHINE_ENV_VAR_PATTERN, getVirtualMachineApiError } from '@iblai/data-layer';
4
+ import { useCreateVirtualMachineSecretMutation, useUpdateVirtualMachineSecretMutation, useCreateIntegrationCredentialMutation, useUpdateIntegrationCredentialMutation, useCreateLLMCredentialMutation, useUpdateLLMCredentialMutation, useLazyGetIntegrationCredentialsQuery, useGetLlmsQuery, deriveSecretEnvVar, VIRTUAL_MACHINE_DEFAULT_HOST_PORT, VIRTUAL_MACHINE_ENV_VAR_MAX_LENGTH, validateSecretEnvVar, getVirtualMachineApiError, isSecretEnvVarTakenMessage } from '@iblai/data-layer';
5
+ import { FieldInfo } from '../field-info.js';
5
6
  import { Button } from '../ui/button.js';
7
+ import { Command, CommandInput, CommandList, CommandEmpty, CommandItem } from '../ui/command.js';
6
8
  import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '../ui/dialog.js';
7
9
  import { Input } from '../ui/input.js';
8
10
  import { Label } from '../ui/label.js';
9
- import { RadioGroup, RadioGroupItem } from '../ui/radio-group.js';
10
- import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../ui/select.js';
11
11
  import { useT } from '../../i18n/context.js';
12
12
  import '../../packages/i18n/dist/index.esm.js';
13
+ import { cn } from '../../lib/utils.js';
14
+ import { availableAzureModels, touchedAzureConfigs, AZURE_MODEL_FIELDS } from './azure-config.js';
15
+ import { AzureModelFields } from './azure-model-fields.js';
16
+ import { AI_PROVIDER_FORMS, agentKeyField, defaultHostsFor, deriveServiceEnvVar, SERVICE_PURPOSE, toIntegrationCredentialOptions, humanizeCredentialField, isAiKeyEditable } from './credential-options.js';
13
17
  import { HostPortChipInput } from './host-port-chip-input.js';
14
- import { BLUE_RADIO_ITEM_CLASS } from './styles.js';
18
+ import { fieldsOfCredential, MASKED_VALUE_PATTERN } from './secret-rows.js';
19
+ import KeyRound from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/key-round.js';
15
20
  import LoaderCircle from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/loader-circle.js';
16
21
 
17
- const FIELD_NAMES = [
18
- 'name',
19
- 'env_var',
20
- 'allow_hosts',
21
- 'value',
22
- 'source_credential_id',
23
- 'source_field',
24
- ];
22
+ // Stable defaults: the reset effect depends on these, so a fresh array per render would re-run it.
23
+ const NO_SERVICES = [];
24
+ const NO_CREDENTIALS = [];
25
+ const NO_ENV_VARS = [];
26
+ const NO_AI_PROVIDERS = [];
27
+ const NO_AI_KEYS = [];
28
+ const NO_FIELDS = [];
29
+ const AI_PICK_PREFIX = 'ai:';
30
+ const AZURE_OPENAI_SLUG = 'azure_openai';
31
+ const AZURE_FIELD_LABELS = {
32
+ key: 'secrets.azureKeyLabel',
33
+ host: 'secrets.azureHostLabel',
34
+ version: 'secrets.azureVersionLabel',
35
+ deployment: 'secrets.azureDeploymentLabel',
36
+ };
37
+ /**
38
+ * Read the first box's value. AI providers carry a prefix, so an AI slug
39
+ * can never collide with a service of the same name.
40
+ */
41
+ function parsePick(value) {
42
+ if (value.startsWith(AI_PICK_PREFIX)) {
43
+ return { kind: 'ai', slug: value.slice(AI_PICK_PREFIX.length) };
44
+ }
45
+ return { kind: 'service', slug: value };
46
+ }
25
47
  const NAME_MAX_LENGTH = 255;
26
- const ENV_VAR_MAX_LENGTH = 128;
27
- /** Values that look masked (`sk-****`) are rejected by the backend too. */
28
- const MASKED_VALUE_PATTERN = /\*{3,}/;
48
+ const ENV_VAR_ISSUE_KEYS = {
49
+ required: 'secrets.errorEnvVarRequired',
50
+ format: 'secrets.errorEnvVarFormat',
51
+ too_long: 'secrets.errorEnvVarTooLong',
52
+ reserved: 'secrets.errorEnvVarReserved',
53
+ taken: 'secrets.errorEnvVarTaken',
54
+ };
55
+ const fieldErrorKey = (field) => `field:${field}`;
56
+ /** A repeated AI add answers a unique-together 400 with a top-level `non_field_errors`, not a 409. */
57
+ const isUniqueTogetherError = (error) => { var _a; return Boolean((_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.non_field_errors); };
58
+ const sameHosts = (a, b) => a.length === b.length && a.every((host, index) => host === b[index]);
29
59
  /**
30
- * Create / edit form for a VM secret. A secret gets its value in one of two
31
- * ways, offered as a choice: the admin pastes a key (stored, min 8
32
- * characters), or the secret points at one field of an integration
33
- * credential the org already saved and reads it at run time. No endpoint ever
34
- * returns the value, so the field is never prefilled — on edit it stays blank
35
- * to keep the current value — and `env_var` is read-only once created (delete
36
- * and recreate to rename). Backend 400s land next to the matching field or as
37
- * a form-level message.
60
+ * Add / Edit a key of another service, one form for every key. The lists the
61
+ * caller gives decide what opens, so nobody is ever asked whether a key is "a
62
+ * secret or a data source": AI providers give a type-to-search LLM box, whose
63
+ * pick shows its own form and is saved as its LLM credential; services give the
64
+ * same box as Service, whose pick shows that service's own fields and is saved as its
65
+ * integration credential; no list at all opens straight on a name, the key and
66
+ * the addresses it is sent to, saved as a VM secret. Lists that failed or have
67
+ * not answered never read as "only a custom key is possible": see `choices`.
68
+ * From an agent's Sandbox tab a known service's key is also bound to agents (one
69
+ * VM secret reading its key field), and `link` does only that binding for a key
70
+ * the organization already holds. The variable agents use is derived from the
71
+ * name and can be changed until saved; no key is ever shown back.
38
72
  */
39
- function VmSecretDialog({ open, onOpenChange, tenantKey, secret = null, credentials, onSaved, }) {
40
- var _a;
73
+ function VmSecretDialog({ open, onOpenChange, tenantKey, services = NO_SERVICES, credentials = NO_CREDENTIALS, aiProviders = NO_AI_PROVIDERS, aiKeys = NO_AI_KEYS, aiKeysSettled = true, aiKey = null, username, azureModels, takenEnvVars = NO_ENV_VARS, secret = null, credential = null, link = false, fromSandbox = false, fromServicesTab = false, customAllowed = true, choices = 'ready', onRetryChoices, onListOutOfDate, onSaved, toastOnSave = true, }) {
74
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
41
75
  const t = useT();
42
76
  const baseId = useId();
43
77
  const ids = {
78
+ service: `${baseId}-service`,
44
79
  name: `${baseId}-name`,
45
- envVar: `${baseId}-env-var`,
46
- envVarHelp: `${baseId}-env-var-help`,
47
- hosts: `${baseId}-hosts`,
48
- source: `${baseId}-source`,
49
- sourceValue: `${baseId}-source-value`,
50
- sourceCredential: `${baseId}-source-credential`,
51
80
  value: `${baseId}-value`,
52
81
  valueHelp: `${baseId}-value-help`,
53
- credential: `${baseId}-credential`,
54
- credentialLabel: `${baseId}-credential-label`,
55
- field: `${baseId}-field`,
56
- fieldLabel: `${baseId}-field-label`,
82
+ hosts: `${baseId}-hosts`,
83
+ envVar: `${baseId}-env-var`,
84
+ envVarHelp: `${baseId}-env-var-help`,
85
+ field: (field) => `${baseId}-field-${field}`,
57
86
  };
58
- const [createSecret, { isLoading: isCreating }] = useCreateVirtualMachineSecretMutation();
59
- const [updateSecret, { isLoading: isUpdating }] = useUpdateVirtualMachineSecretMutation();
60
- const isSaving = isCreating || isUpdating;
87
+ const firstInputRef = useRef(null);
88
+ const boxInputRef = useRef(null);
89
+ const changeButtonRef = useRef(null);
90
+ const moveFocusAfterSwap = useRef(false);
91
+ const [createSecret, { isLoading: isCreatingSecret }] = useCreateVirtualMachineSecretMutation();
92
+ const [updateSecret, { isLoading: isUpdatingSecret }] = useUpdateVirtualMachineSecretMutation();
93
+ const [createCredential, { isLoading: isCreatingCredential }] = useCreateIntegrationCredentialMutation();
94
+ const [updateCredential, { isLoading: isUpdatingCredential }] = useUpdateIntegrationCredentialMutation();
95
+ const [createLlmCredential, { isLoading: isCreatingLlmCredential }] = useCreateLLMCredentialMutation();
96
+ const [updateLlmCredential, { isLoading: isUpdatingLlmCredential }] = useUpdateLLMCredentialMutation();
97
+ const [fetchCredentials, { isFetching: isFetchingCredentials }] = useLazyGetIntegrationCredentialsQuery();
98
+ const isSaving = isCreatingSecret ||
99
+ isUpdatingSecret ||
100
+ isCreatingCredential ||
101
+ isUpdatingCredential ||
102
+ isCreatingLlmCredential ||
103
+ isUpdatingLlmCredential ||
104
+ isFetchingCredentials;
105
+ const isLink = credential !== null && link;
106
+ const isEditService = credential !== null && !link;
107
+ const isEditCustom = secret !== null && credential === null;
108
+ // A secret that reads a known service's key opens without its credential when
109
+ // that list is refused or has not answered. Typing a key here would cut it off
110
+ // from the service's key for good, so the form never offers to.
111
+ const readsServiceKey = isEditCustom && (secret === null || secret === void 0 ? void 0 : secret.source_credential_id) != null;
112
+ const isEditAi = aiKey !== null;
113
+ const isCreate = credential === null && secret === null && !isEditAi;
114
+ const hasAi = aiProviders.length > 0;
115
+ const hasServices = services.length > 0;
116
+ const customOnly = customAllowed && choices === 'ready' && !hasAi && !hasServices;
117
+ const isLlmBox = isCreate ? hasAi : isEditAi;
118
+ const boxLabel = t(isLlmBox ? 'secrets.fieldLlm' : 'secrets.fieldService');
119
+ const boxDisabled = choices === 'loading' || (!hasAi && !hasServices);
120
+ const bound = credential !== null && secret !== null;
121
+ const [serviceSlug, setServiceSlug] = useState('');
122
+ const [boxSearch, setBoxSearch] = useState('');
123
+ const [boxFocused, setBoxFocused] = useState(false);
124
+ const [fieldValues, setFieldValues] = useState({});
61
125
  const [name, setName] = useState('');
62
- const [envVar, setEnvVar] = useState('');
63
- const [hosts, setHosts] = useState([]);
64
- const [source, setSource] = useState('value');
65
126
  const [value, setValue] = useState('');
66
- const [credentialId, setCredentialId] = useState('');
67
- const [field, setField] = useState('');
127
+ const [hosts, setHosts] = useState([]);
128
+ const [envVar, setEnvVar] = useState('');
129
+ // Once the person types a variable, their text wins over the derived one.
130
+ const [envVarTouched, setEnvVarTouched] = useState(false);
131
+ // The service's key was saved but its sandbox binding failed: the main button retries only the binding.
132
+ const [credentialSaved, setCredentialSaved] = useState(false);
133
+ const [sourceFieldRefused, setSourceFieldRefused] = useState(false);
134
+ const [credentialReadFailed, setCredentialReadFailed] = useState(false);
135
+ const [azureSelected, setAzureSelected] = useState([]);
136
+ const [azureConfigs, setAzureConfigs] = useState({});
137
+ const [azureErrors, setAzureErrors] = useState({});
68
138
  const [fieldErrors, setFieldErrors] = useState({});
69
139
  const [formError, setFormError] = useState(null);
70
- // Start from the secret being edited (or blank) every time the dialog
71
- // opens. The value is deliberately never prefilled.
140
+ const pick = parsePick(serviceSlug);
141
+ const aiSlug = (_a = aiKey === null || aiKey === void 0 ? void 0 : aiKey.name) !== null && _a !== void 0 ? _a : (isCreate && pick.kind === 'ai' ? pick.slug : null);
142
+ const isAi = aiSlug !== null;
143
+ const aiProvider = aiSlug
144
+ ? ((_b = aiProviders.find((provider) => provider.slug === aiSlug)) !== null && _b !== void 0 ? _b : null)
145
+ : null;
146
+ const aiForm = (_d = (_c = aiProvider === null || aiProvider === void 0 ? void 0 : aiProvider.form) !== null && _c !== void 0 ? _c : AI_PROVIDER_FORMS[aiSlug !== null && aiSlug !== void 0 ? aiSlug : '']) !== null && _d !== void 0 ? _d : 'fields';
147
+ const aiFields = (_e = aiProvider === null || aiProvider === void 0 ? void 0 : aiProvider.fields) !== null && _e !== void 0 ? _e : NO_FIELDS;
148
+ const heldAiSlugs = useMemo(() => new Set(aiKeys.map((key) => key.name)), [aiKeys]);
149
+ const heldAzure = (_f = aiKeys.find((key) => key.name === AZURE_OPENAI_SLUG)) !== null && _f !== void 0 ? _f : null;
150
+ const heldAzureModels = useMemo(() => { var _a; return ((_a = heldAzure === null || heldAzure === void 0 ? void 0 : heldAzure.models) !== null && _a !== void 0 ? _a : []).map((model) => model.name); }, [heldAzure]);
151
+ // A held Azure OpenAI needs the list before it is picked too: it greys out only with no model left to add.
152
+ const needsAzureModels = open &&
153
+ isCreate &&
154
+ aiProviders.some((provider) => provider.form === 'azure') &&
155
+ (aiForm === 'azure' || heldAzure !== null);
156
+ const { data: llmProviders, isLoading: isLoadingLlmProviders, isError: isLlmProvidersError, refetch: refetchLlmProviders, } = useGetLlmsQuery({
157
+ org: tenantKey,
158
+ // @ts-expect-error - userId is not in the generated query args but the endpoint scopes by it
159
+ userId: username !== null && username !== void 0 ? username : '',
160
+ }, { skip: !needsAzureModels || !username || azureModels !== undefined });
161
+ const allAzureModels = useMemo(() => {
162
+ var _a;
163
+ if (azureModels)
164
+ return azureModels;
165
+ if (!llmProviders)
166
+ return null;
167
+ const azure = llmProviders.find((provider) => provider.name === AZURE_OPENAI_SLUG);
168
+ // Typed as strings by the generated client; the endpoint answers { llm_name, display_name }.
169
+ return ((_a = azure === null || azure === void 0 ? void 0 : azure.chat_models) !== null && _a !== void 0 ? _a : []);
170
+ }, [azureModels, llmProviders]);
171
+ const pickableAzureModels = useMemo(() => availableAzureModels(allAzureModels !== null && allAzureModels !== void 0 ? allAzureModels : [], heldAzureModels), [allAzureModels, heldAzureModels]);
172
+ const azureFullyHeld = heldAzure !== null && allAzureModels !== null && pickableAzureModels.length === 0;
173
+ const azureListFailed = needsAzureModels && azureModels === undefined && (!username || Boolean(isLlmProvidersError));
174
+ const azureModelsNotice = azureListFailed
175
+ ? t('secrets.azureModelsFailed')
176
+ : allAzureModels !== null && pickableAzureModels.length === 0
177
+ ? t('secrets.azureModelsNone')
178
+ : undefined;
179
+ const selectedService = useMemo(() => {
180
+ var _a, _b;
181
+ if (isCreate)
182
+ return (_a = services.find((service) => service.slug === serviceSlug)) !== null && _a !== void 0 ? _a : null;
183
+ if (credential)
184
+ return (_b = services.find((service) => service.slug === credential.name)) !== null && _b !== void 0 ? _b : null;
185
+ return null;
186
+ }, [isCreate, services, serviceSlug, credential]);
187
+ const allServiceFields = useMemo(() => selectedService
188
+ ? selectedService.fields
189
+ : credential
190
+ ? fieldsOfCredential(credential, services)
191
+ : [], [selectedService, credential, services]);
192
+ const serviceFields = useMemo(() => allServiceFields.filter((field) => !field.systemManaged), [allServiceFields]);
193
+ const knownSlug = (_h = (_g = selectedService === null || selectedService === void 0 ? void 0 : selectedService.slug) !== null && _g !== void 0 ? _g : credential === null || credential === void 0 ? void 0 : credential.name) !== null && _h !== void 0 ? _h : null;
194
+ const serviceDisplayName = (_m = (_l = (_k = (_j = selectedService === null || selectedService === void 0 ? void 0 : selectedService.displayName) !== null && _j !== void 0 ? _j : credential === null || credential === void 0 ? void 0 : credential.displayName) !== null && _k !== void 0 ? _k : aiProvider === null || aiProvider === void 0 ? void 0 : aiProvider.displayName) !== null && _l !== void 0 ? _l : aiKey === null || aiKey === void 0 ? void 0 : aiKey.displayName) !== null && _m !== void 0 ? _m : '';
195
+ const serviceLogo = (_r = (_q = (_p = (_o = selectedService === null || selectedService === void 0 ? void 0 : selectedService.logo) !== null && _o !== void 0 ? _o : credential === null || credential === void 0 ? void 0 : credential.logo) !== null && _p !== void 0 ? _p : aiKey === null || aiKey === void 0 ? void 0 : aiKey.logo) !== null && _q !== void 0 ? _q : aiProvider === null || aiProvider === void 0 ? void 0 : aiProvider.logo) !== null && _r !== void 0 ? _r : null;
196
+ const agentField = knownSlug ? agentKeyField(knownSlug, allServiceFields) : null;
197
+ const isCustom = isEditCustom || (isCreate && customOnly);
198
+ const isKnown = isLink || isEditService || (isCreate && selectedService !== null);
199
+ const bindsOnCreate = isCreate && isKnown && fromSandbox && agentField !== null;
200
+ // A sign-in style key (Client ID / Client Secret) only ibl.ai can use.
201
+ const platformOnly = isCreate && isKnown && agentField === null;
202
+ const isFilePicker = knownSlug !== null && SERVICE_PURPOSE[knownSlug] === 'filePicker';
203
+ const showServiceSelect = isCreate && !customOnly;
204
+ const showServiceFields = (isCreate && isKnown && !credentialSaved) || isEditService;
205
+ const asksHosts = isCustom || isLink || bindsOnCreate || (isEditService && bound);
206
+ const showEnvVar = asksHosts;
207
+ const envVarReadOnly = isEditCustom || (isEditService && bound);
208
+ const showSuggestions = !boxDisabled && boxFocused;
209
+ const addedSlugs = useMemo(() => new Set(credentials.map((c) => c.name)), [credentials]);
210
+ // The org's other variables; the edited secret's own is not a clash.
211
+ const taken = useMemo(() => takenEnvVars.filter((entry) => entry !== (secret === null || secret === void 0 ? void 0 : secret.env_var)), [takenEnvVars, secret === null || secret === void 0 ? void 0 : secret.env_var]);
212
+ // Start from what is being edited (or blank) every time the dialog opens.
213
+ // A key is deliberately never prefilled. A list answering while the dialog is
214
+ // open must not reset it, or it wipes what the person typed.
72
215
  useEffect(() => {
73
- var _a, _b, _c, _d;
216
+ var _a, _b, _c, _d, _e, _f;
74
217
  if (!open)
75
218
  return;
76
- setName((_a = secret === null || secret === void 0 ? void 0 : secret.name) !== null && _a !== void 0 ? _a : '');
77
- setEnvVar((_b = secret === null || secret === void 0 ? void 0 : secret.env_var) !== null && _b !== void 0 ? _b : '');
78
- setHosts((_c = secret === null || secret === void 0 ? void 0 : secret.allow_hosts) !== null && _c !== void 0 ? _c : []);
79
- const linked = (secret === null || secret === void 0 ? void 0 : secret.source_credential_id) != null;
80
- setSource(linked ? 'credential' : 'value');
219
+ setServiceSlug(credential ? credential.name : '');
220
+ setBoxSearch('');
221
+ setBoxFocused(false);
222
+ const prefilled = {};
223
+ if (credential && !link) {
224
+ for (const field of fieldsOfCredential(credential, services)) {
225
+ if (!field.isSensitive)
226
+ prefilled[field.name] = (_a = credential.values[field.name]) !== null && _a !== void 0 ? _a : '';
227
+ }
228
+ }
229
+ setFieldValues(prefilled);
230
+ setName((_b = secret === null || secret === void 0 ? void 0 : secret.name) !== null && _b !== void 0 ? _b : '');
81
231
  setValue('');
82
- setCredentialId(linked ? String(secret.source_credential_id) : '');
83
- setField(linked ? ((_d = secret.source_field) !== null && _d !== void 0 ? _d : '') : '');
232
+ setHosts((_c = secret === null || secret === void 0 ? void 0 : secret.allow_hosts) !== null && _c !== void 0 ? _c : (credential && link ? defaultHostsFor(credential.name) : []));
233
+ setEnvVar((_d = secret === null || secret === void 0 ? void 0 : secret.env_var) !== null && _d !== void 0 ? _d : '');
234
+ setEnvVarTouched(false);
235
+ setCredentialSaved(false);
236
+ setSourceFieldRefused(false);
237
+ setCredentialReadFailed(false);
238
+ setAzureSelected((_f = (_e = aiKey === null || aiKey === void 0 ? void 0 : aiKey.models) === null || _e === void 0 ? void 0 : _e.map((model) => model.name)) !== null && _f !== void 0 ? _f : []);
239
+ setAzureConfigs({});
240
+ setAzureErrors({});
241
+ setFieldErrors({});
242
+ setFormError(null);
243
+ // eslint-disable-next-line react-hooks/exhaustive-deps
244
+ }, [open, secret, credential, aiKey, link]);
245
+ // The schema can answer after an edit opened: fill in the visible values it
246
+ // adds without touching what was typed.
247
+ useEffect(() => {
248
+ if (!open || !credential || link)
249
+ return;
250
+ setFieldValues((current) => {
251
+ var _a;
252
+ const next = { ...current };
253
+ for (const field of fieldsOfCredential(credential, services)) {
254
+ if (!field.isSensitive && !(field.name in next)) {
255
+ next[field.name] = (_a = credential.values[field.name]) !== null && _a !== void 0 ? _a : '';
256
+ }
257
+ }
258
+ return next;
259
+ });
260
+ }, [open, credential, link, services]);
261
+ // The variable agents use, worked out from the name (or the service and its
262
+ // key field) until the person types one of their own.
263
+ useEffect(() => {
264
+ if (envVarReadOnly || envVarTouched)
265
+ return;
266
+ if (isCustom) {
267
+ setEnvVar(name.trim() ? deriveSecretEnvVar(name, { taken }) : '');
268
+ }
269
+ else if (isKnown && agentField) {
270
+ setEnvVar(deriveServiceEnvVar(serviceDisplayName, agentField, taken));
271
+ }
272
+ else {
273
+ setEnvVar('');
274
+ }
275
+ }, [
276
+ name,
277
+ isCustom,
278
+ isKnown,
279
+ agentField,
280
+ serviceDisplayName,
281
+ envVarReadOnly,
282
+ envVarTouched,
283
+ taken,
284
+ ]);
285
+ // The suggestions sit in the dialog's flow, so closing them on blur would move the
286
+ // button under the pointer mid-press and lose its click. They close once the press
287
+ // or key that took focus away is over.
288
+ useEffect(() => {
289
+ if (!boxFocused)
290
+ return;
291
+ const closeIfLeft = () => {
292
+ if (document.activeElement !== boxInputRef.current)
293
+ setBoxFocused(false);
294
+ };
295
+ document.addEventListener('click', closeIfLeft, true);
296
+ document.addEventListener('keyup', closeIfLeft, true);
297
+ return () => {
298
+ document.removeEventListener('click', closeIfLeft, true);
299
+ document.removeEventListener('keyup', closeIfLeft, true);
300
+ };
301
+ }, [boxFocused]);
302
+ // A pick swaps the box for the chosen row and Change swaps it back, removing the control that had focus.
303
+ useEffect(() => {
304
+ var _a;
305
+ if (!moveFocusAfterSwap.current)
306
+ return;
307
+ moveFocusAfterSwap.current = false;
308
+ const next = serviceSlug
309
+ ? ((_a = firstInputRef.current) !== null && _a !== void 0 ? _a : changeButtonRef.current)
310
+ : boxInputRef.current;
311
+ next === null || next === void 0 ? void 0 : next.focus();
312
+ }, [serviceSlug]);
313
+ const handleServiceChange = (next) => {
314
+ setServiceSlug(next);
315
+ setFieldValues({});
316
+ setAzureSelected([]);
317
+ setAzureConfigs({});
318
+ setAzureErrors({});
84
319
  setFieldErrors({});
85
320
  setFormError(null);
86
- }, [open, secret]);
87
- const isEdit = secret !== null;
88
- const selectedCredential = credentials.find((option) => String(option.id) === credentialId);
89
- const credentialFields = (_a = selectedCredential === null || selectedCredential === void 0 ? void 0 : selectedCredential.fields) !== null && _a !== void 0 ? _a : [];
321
+ setHosts(parsePick(next).kind === 'service' && fromSandbox ? defaultHostsFor(next) : []);
322
+ };
323
+ const pickFromBox = (next) => {
324
+ moveFocusAfterSwap.current = true;
325
+ setBoxSearch('');
326
+ setBoxFocused(false);
327
+ handleServiceChange(next);
328
+ };
329
+ const reopenBox = () => {
330
+ moveFocusAfterSwap.current = true;
331
+ setEnvVarTouched(false);
332
+ handleServiceChange('');
333
+ };
334
+ const closeAfterSave = (saved) => {
335
+ onSaved === null || onSaved === void 0 ? void 0 : onSaved(saved);
336
+ onOpenChange(false);
337
+ };
338
+ /** Put a VM-secret refusal under its field; anything else becomes one generic line. */
339
+ const showSecretFailure = (error) => {
340
+ const parsed = getVirtualMachineApiError(error);
341
+ if (parsed.status === 403) {
342
+ setFormError(t('secrets.forbiddenWrite'));
343
+ return;
344
+ }
345
+ if (parsed.fieldErrors.source_field) {
346
+ setSourceFieldRefused(true);
347
+ setFormError(t('secrets.errorSourceField', { name: serviceDisplayName }));
348
+ return;
349
+ }
350
+ const nextErrors = {};
351
+ for (const [key, messages] of Object.entries(parsed.fieldErrors)) {
352
+ if (['name', 'env_var', 'allow_hosts', 'value'].includes(key)) {
353
+ nextErrors[key] = messages.join(' ');
354
+ }
355
+ }
356
+ if (isSecretEnvVarTakenMessage(parsed.message)) {
357
+ // The person never typed a derived variable, so the clash is about the name.
358
+ if (envVarTouched || !isCustom) {
359
+ nextErrors.env_var = t('secrets.errorEnvVarTaken', { envVar: envVar.trim() });
360
+ }
361
+ else {
362
+ nextErrors.name = t('secrets.errorNameTaken');
363
+ }
364
+ }
365
+ setFieldErrors(nextErrors);
366
+ if (Object.keys(nextErrors).length === 0)
367
+ setFormError(t('secrets.saveFailed'));
368
+ };
369
+ const typedValue = (field) => { var _a, _b; return (_b = (_a = fieldValues[field]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''; };
370
+ const fieldText = (field) => field === 'key' ? t('secrets.fieldKey') : humanizeCredentialField(field);
371
+ const aiNothingTyped = () => aiForm === 'azure'
372
+ ? Object.keys(touchedAzureConfigs(azureConfigs)).length === 0
373
+ : Object.values(fieldValues).every((text) => !text.trim());
374
+ const aiFieldRequiredError = (field) => field === 'key'
375
+ ? t('secrets.errorKeyRequired')
376
+ : t('secrets.errorServiceFieldRequired', { label: fieldText(field) });
377
+ const aiClientErrors = () => {
378
+ const errors = {};
379
+ if (aiForm === 'azure')
380
+ return errors;
381
+ for (const field of aiFields) {
382
+ if (field.required && !typedValue(field.name)) {
383
+ errors[fieldErrorKey(field.name)] = aiFieldRequiredError(field.name);
384
+ }
385
+ }
386
+ // The LLM PATCH stores what it is sent, so pasting the row's own `sk-***`
387
+ // would replace the real key and agents would stop answering.
388
+ for (const field of aiFields) {
389
+ if (field.isSensitive && MASKED_VALUE_PATTERN.test(typedValue(field.name))) {
390
+ errors[fieldErrorKey(field.name)] = t('secrets.errorKeyMasked');
391
+ }
392
+ }
393
+ return errors;
394
+ };
395
+ const azureClientErrors = () => {
396
+ var _a, _b, _c, _d;
397
+ const errors = {};
398
+ if (aiForm !== 'azure')
399
+ return errors;
400
+ for (const model of azureSelected) {
401
+ if (MASKED_VALUE_PATTERN.test((_b = (_a = azureConfigs[model]) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : '')) {
402
+ errors[`${model}.key`] = t('secrets.errorKeyMasked');
403
+ }
404
+ }
405
+ if (isEditAi)
406
+ return errors;
407
+ if (azureSelected.length === 0) {
408
+ errors.model = azureModelsNotice !== null && azureModelsNotice !== void 0 ? azureModelsNotice : t('secrets.errorAzureModelRequired');
409
+ }
410
+ for (const model of azureSelected) {
411
+ for (const field of AZURE_MODEL_FIELDS) {
412
+ if (!((_d = (_c = azureConfigs[model]) === null || _c === void 0 ? void 0 : _c[field]) === null || _d === void 0 ? void 0 : _d.trim())) {
413
+ errors[`${model}.${field}`] = t('secrets.errorAzureFieldRequired', {
414
+ label: t(AZURE_FIELD_LABELS[field]),
415
+ model,
416
+ });
417
+ }
418
+ }
419
+ }
420
+ return errors;
421
+ };
422
+ const aiRequestValue = () => {
423
+ if (aiForm === 'azure')
424
+ return touchedAzureConfigs(azureConfigs);
425
+ const value = {};
426
+ for (const field of aiFields) {
427
+ const typed = typedValue(field.name);
428
+ if (typed)
429
+ value[field.name] = typed;
430
+ }
431
+ return value;
432
+ };
433
+ const showAiFailure = (error) => {
434
+ const parsed = getVirtualMachineApiError(error);
435
+ if (parsed.status === 403) {
436
+ setFormError(t('secrets.forbiddenWrite'));
437
+ return;
438
+ }
439
+ if ((parsed.status === 409 || isUniqueTogetherError(error)) && isCreate) {
440
+ onListOutOfDate === null || onListOutOfDate === void 0 ? void 0 : onListOutOfDate();
441
+ setFieldErrors({
442
+ service: t(isAiKeyEditable(aiProvider)
443
+ ? 'secrets.serviceAlreadyAdded'
444
+ : 'secrets.serviceAlreadyAddedNoEdit', { name: serviceDisplayName }),
445
+ });
446
+ return;
447
+ }
448
+ const nextErrors = {};
449
+ for (const field of aiFields) {
450
+ if (!parsed.fieldErrors[field.name])
451
+ continue;
452
+ nextErrors[fieldErrorKey(field.name)] =
453
+ field.isSensitive && typedValue(field.name)
454
+ ? t('secrets.keyPasteFull')
455
+ : t('secrets.errorServiceFieldRequired', { label: fieldText(field.name) });
456
+ }
457
+ setFieldErrors(nextErrors);
458
+ if (Object.keys(nextErrors).length === 0)
459
+ setFormError(t('secrets.saveFailed'));
460
+ };
461
+ const submitAi = async (slug) => {
462
+ if (isEditAi && aiNothingTyped()) {
463
+ onOpenChange(false);
464
+ return;
465
+ }
466
+ const clientErrors = aiClientErrors();
467
+ const clientAzureErrors = azureClientErrors();
468
+ setFieldErrors(clientErrors);
469
+ setAzureErrors(clientAzureErrors);
470
+ setFormError(null);
471
+ if (Object.keys(clientErrors).length > 0 || Object.keys(clientAzureErrors).length > 0)
472
+ return;
473
+ const request = {
474
+ org: tenantKey,
475
+ requestBody: { name: slug, value: aiRequestValue(), platform: tenantKey },
476
+ };
477
+ try {
478
+ if (isEditAi)
479
+ await updateLlmCredential(request).unwrap();
480
+ else
481
+ await createLlmCredential(request).unwrap();
482
+ }
483
+ catch (error) {
484
+ showAiFailure(error);
485
+ return;
486
+ }
487
+ if (toastOnSave) {
488
+ if (isEditAi) {
489
+ toast.success(t('secrets.updated', { name: serviceDisplayName }));
490
+ }
491
+ else if (aiForm === 'azure' && heldAzure) {
492
+ toast.success(t('secrets.azureModelsAdded', { count: azureSelected.length, name: serviceDisplayName }));
493
+ }
494
+ else {
495
+ toast.success(t('secrets.aiProviderAdded', { name: serviceDisplayName }));
496
+ }
497
+ }
498
+ closeAfterSave(null);
499
+ };
90
500
  const handleSubmit = async (event) => {
501
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
91
502
  event.preventDefault();
503
+ if (aiSlug) {
504
+ await submitAi(aiSlug);
505
+ return;
506
+ }
92
507
  const trimmedName = name.trim();
93
508
  const trimmedEnvVar = envVar.trim();
509
+ const trimmedValue = value.trim();
94
510
  const clientErrors = {};
95
- if (!trimmedName)
96
- clientErrors.name = t('virtualMachineSecrets.errorNameRequired');
97
- if (!isEdit) {
98
- if (!trimmedEnvVar) {
99
- clientErrors.env_var = t('virtualMachineSecrets.errorEnvVarRequired');
511
+ setSourceFieldRefused(false);
512
+ setCredentialReadFailed(false);
513
+ if (showServiceSelect && !serviceSlug) {
514
+ clientErrors.service = t(isLlmBox ? 'secrets.errorLlmRequired' : 'secrets.errorServiceRequired');
515
+ }
516
+ if (isCustom) {
517
+ if (!trimmedName)
518
+ clientErrors.name = t('secrets.errorNameRequired');
519
+ if (!isEditCustom && !trimmedValue) {
520
+ clientErrors.value = t('secrets.errorKeyRequired');
100
521
  }
101
- else if (!VIRTUAL_MACHINE_ENV_VAR_PATTERN.test(trimmedEnvVar)) {
102
- clientErrors.env_var = t('virtualMachineSecrets.errorEnvVarFormat');
522
+ else if (MASKED_VALUE_PATTERN.test(trimmedValue)) {
523
+ clientErrors.value = t('secrets.errorKeyMasked');
103
524
  }
104
525
  }
105
- if (hosts.length === 0)
106
- clientErrors.allow_hosts = t('virtualMachineSecrets.errorHostsRequired');
107
- if (source === 'value') {
108
- if (!isEdit && !value) {
109
- clientErrors.value = t('virtualMachineSecrets.errorValueRequired');
110
- }
111
- else if (value && value.length < VIRTUAL_MACHINE_SECRET_VALUE_MIN_LENGTH) {
112
- clientErrors.value = t('virtualMachineSecrets.errorValueTooShort', {
113
- min: VIRTUAL_MACHINE_SECRET_VALUE_MIN_LENGTH,
114
- });
526
+ if (isCreate && isKnown && !credentialSaved) {
527
+ for (const field of serviceFields) {
528
+ if (field.required && !((_a = fieldValues[field.name]) === null || _a === void 0 ? void 0 : _a.trim())) {
529
+ clientErrors[fieldErrorKey(field.name)] = t('secrets.errorServiceFieldRequired', {
530
+ label: fieldText(field.name),
531
+ });
532
+ }
115
533
  }
116
- else if (value && MASKED_VALUE_PATTERN.test(value)) {
117
- clientErrors.value = t('virtualMachineSecrets.errorValueMasked');
534
+ }
535
+ if ((isCreate && isKnown && !credentialSaved) || isEditService) {
536
+ for (const field of serviceFields) {
537
+ const typedText = (_c = (_b = fieldValues[field.name]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
538
+ const storedText = ((_d = credential === null || credential === void 0 ? void 0 : credential.values[field.name]) !== null && _d !== void 0 ? _d : '').trim();
539
+ if (field.isSensitive && typedText !== storedText && MASKED_VALUE_PATTERN.test(typedText)) {
540
+ clientErrors[fieldErrorKey(field.name)] = t('secrets.errorKeyMasked');
541
+ }
118
542
  }
119
543
  }
120
- else {
121
- if (!credentialId) {
122
- clientErrors.source_credential_id = t('virtualMachineSecrets.errorCredentialRequired');
544
+ if (asksHosts && hosts.length === 0)
545
+ clientErrors.allow_hosts = t('secrets.errorHostsRequired');
546
+ if (showEnvVar && !envVarReadOnly && (!isCustom || trimmedName)) {
547
+ const issue = validateSecretEnvVar(trimmedEnvVar, { taken });
548
+ if (issue) {
549
+ clientErrors.env_var = t(ENV_VAR_ISSUE_KEYS[issue], {
550
+ envVar: trimmedEnvVar,
551
+ max: VIRTUAL_MACHINE_ENV_VAR_MAX_LENGTH,
552
+ });
123
553
  }
124
- if (!field)
125
- clientErrors.source_field = t('virtualMachineSecrets.errorFieldRequired');
126
554
  }
127
555
  setFieldErrors(clientErrors);
128
556
  setFormError(null);
129
- if (Object.keys(clientErrors).length > 0)
557
+ if (Object.values(clientErrors).some(Boolean))
130
558
  return;
131
- try {
132
- let saved;
133
- if (isEdit) {
134
- const body = { env_var: secret.env_var };
135
- if (trimmedName !== secret.name)
136
- body.name = trimmedName;
137
- if (hosts.length !== secret.allow_hosts.length ||
138
- hosts.some((host, index) => host !== secret.allow_hosts[index])) {
139
- body.allow_hosts = hosts;
140
- }
141
- if (source === 'value') {
142
- // A blank value keeps the stored one; a new value replaces it (and
143
- // drops any credential link on the backend).
144
- if (value)
145
- body.value = value;
146
- }
147
- else if (Number(credentialId) !== secret.source_credential_id ||
148
- field !== secret.source_field) {
149
- body.source_credential_id = Number(credentialId);
150
- body.source_field = field;
559
+ if (isEditCustom && secret) {
560
+ const body = { env_var: secret.env_var };
561
+ if (trimmedName !== secret.name)
562
+ body.name = trimmedName;
563
+ if (!sameHosts(hosts, secret.allow_hosts))
564
+ body.allow_hosts = hosts;
565
+ if (trimmedValue && !readsServiceKey)
566
+ body.value = trimmedValue;
567
+ if (Object.keys(body).length === 1) {
568
+ onOpenChange(false);
569
+ return;
570
+ }
571
+ try {
572
+ const saved = await updateSecret({ org: tenantKey, body }).unwrap();
573
+ if (toastOnSave)
574
+ toast.success(t('secrets.envVarUpdated'));
575
+ closeAfterSave(saved);
576
+ }
577
+ catch (error) {
578
+ showSecretFailure(error);
579
+ }
580
+ return;
581
+ }
582
+ if (isEditService && credential) {
583
+ const typed = {};
584
+ for (const field of serviceFields) {
585
+ const next = (_f = (_e = fieldValues[field.name]) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : '';
586
+ const changed = next !== ((_g = credential.values[field.name]) !== null && _g !== void 0 ? _g : '').trim();
587
+ // A blank secret box keeps the key, and its masked copy is never a new key.
588
+ if (changed && (next !== '' || !field.isSensitive))
589
+ typed[field.name] = next;
590
+ }
591
+ const hostsChanged = bound && secret !== null && !sameHosts(hosts, secret.allow_hosts);
592
+ if (Object.keys(typed).length === 0 && !hostsChanged) {
593
+ onOpenChange(false);
594
+ return;
595
+ }
596
+ if (Object.keys(typed).length > 0) {
597
+ try {
598
+ await updateCredential({
599
+ org: tenantKey,
600
+ requestBody: {
601
+ name: credential.name,
602
+ platform: (_h = credential.platform) !== null && _h !== void 0 ? _h : tenantKey,
603
+ value: typed,
604
+ },
605
+ }).unwrap();
151
606
  }
152
- if (Object.keys(body).length === 1) {
153
- onOpenChange(false);
607
+ catch (error) {
608
+ const parsed = getVirtualMachineApiError(error);
609
+ const firstSecretField = serviceFields.find((field) => field.isSensitive);
610
+ if (parsed.status === 403)
611
+ setFormError(t('secrets.forbiddenWrite'));
612
+ else if (firstSecretField) {
613
+ setFieldErrors({ [fieldErrorKey(firstSecretField.name)]: t('secrets.keyPasteFull') });
614
+ }
615
+ else
616
+ setFormError(t('secrets.saveFailed'));
154
617
  return;
155
618
  }
156
- saved = await updateSecret({ org: tenantKey, body }).unwrap();
157
- toast.success(t('virtualMachineSecrets.updated'));
158
619
  }
159
- else {
160
- const body = {
161
- name: trimmedName,
162
- env_var: trimmedEnvVar,
163
- allow_hosts: hosts,
164
- ...(source === 'value'
165
- ? { value }
166
- : { source_credential_id: Number(credentialId), source_field: field }),
167
- };
168
- saved = await createSecret({ org: tenantKey, body }).unwrap();
169
- toast.success(t('virtualMachineSecrets.created'));
170
- }
171
- onSaved === null || onSaved === void 0 ? void 0 : onSaved(saved);
172
- onOpenChange(false);
620
+ try {
621
+ let saved = secret;
622
+ if (hostsChanged && secret) {
623
+ saved = await updateSecret({
624
+ org: tenantKey,
625
+ body: { env_var: secret.env_var, allow_hosts: hosts },
626
+ }).unwrap();
627
+ }
628
+ if (toastOnSave)
629
+ toast.success(t('secrets.updated', { name: serviceDisplayName }));
630
+ closeAfterSave(saved);
631
+ }
632
+ catch (error) {
633
+ showSecretFailure(error);
634
+ }
635
+ return;
173
636
  }
174
- catch (error) {
175
- const parsed = getVirtualMachineApiError(error);
176
- if (parsed.status === 403) {
177
- setFormError(t('virtualMachineSecrets.forbiddenWrite'));
178
- return;
637
+ if (isLink && credential && agentField) {
638
+ try {
639
+ const saved = await createSecret({
640
+ org: tenantKey,
641
+ body: {
642
+ name: credential.displayName,
643
+ env_var: trimmedEnvVar,
644
+ allow_hosts: hosts,
645
+ source_credential_id: credential.id,
646
+ source_field: agentField,
647
+ },
648
+ }).unwrap();
649
+ if (toastOnSave) {
650
+ toast.success(t('secrets.serviceLinked', { name: credential.displayName, envVar: saved.env_var }));
651
+ }
652
+ closeAfterSave(saved);
653
+ }
654
+ catch (error) {
655
+ showSecretFailure(error);
179
656
  }
180
- const nextErrors = {};
181
- let unmatched = [];
182
- for (const [key, messages] of Object.entries(parsed.fieldErrors)) {
183
- if (FIELD_NAMES.includes(key)) {
184
- nextErrors[key] = messages.join(' ');
657
+ return;
658
+ }
659
+ if (isCreate && isKnown && knownSlug) {
660
+ if (!credentialSaved) {
661
+ // A blank optional field still goes out: the backend wants every key of the schema on a new credential.
662
+ const valueToSave = {};
663
+ for (const field of serviceFields)
664
+ valueToSave[field.name] = typedValue(field.name);
665
+ try {
666
+ await createCredential({
667
+ org: tenantKey,
668
+ requestBody: { name: knownSlug, value: valueToSave, platform: tenantKey },
669
+ }).unwrap();
185
670
  }
186
- else {
187
- unmatched = unmatched.concat(messages);
671
+ catch (error) {
672
+ const parsed = getVirtualMachineApiError(error);
673
+ if (parsed.status === 403)
674
+ setFormError(t('secrets.forbiddenWrite'));
675
+ else if (parsed.status === 409 || addedSlugs.has(knownSlug)) {
676
+ setFieldErrors({
677
+ service: t('secrets.serviceAlreadyAdded', { name: serviceDisplayName }),
678
+ });
679
+ }
680
+ else {
681
+ const refused = serviceFields.filter((field) => parsed.fieldErrors[field.name]);
682
+ if (refused.length > 0) {
683
+ setFieldErrors(Object.fromEntries(refused.map((field) => [
684
+ fieldErrorKey(field.name),
685
+ t('secrets.errorServiceFieldRequired', { label: fieldText(field.name) }),
686
+ ])));
687
+ }
688
+ else
689
+ setFormError(t('secrets.saveFailed'));
690
+ }
691
+ return;
692
+ }
693
+ if (!bindsOnCreate) {
694
+ if (toastOnSave) {
695
+ toast.success(t(agentField === null ? 'secrets.platformOnlyAdded' : 'secrets.serviceAdded', {
696
+ name: serviceDisplayName,
697
+ }));
698
+ }
699
+ closeAfterSave(null);
700
+ return;
188
701
  }
702
+ setCredentialSaved(true);
703
+ }
704
+ // The create response carries no id, so read the saved key back from the list.
705
+ let createdId = null;
706
+ try {
707
+ const list = await fetchCredentials({ org: tenantKey }).unwrap();
708
+ createdId =
709
+ (_k = (_j = toIntegrationCredentialOptions(list, tenantKey).find((option) => option.name === knownSlug)) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : null;
189
710
  }
190
- setFieldErrors(nextErrors);
191
- const message = [parsed.message, ...unmatched].filter(Boolean).join(' ');
192
- if (message) {
193
- setFormError(message);
711
+ catch (_l) {
712
+ createdId = null;
194
713
  }
195
- else if (Object.keys(nextErrors).length === 0) {
196
- setFormError(t('virtualMachineSecrets.saveFailed'));
714
+ if (createdId === null || !agentField) {
715
+ setCredentialReadFailed(true);
716
+ return;
717
+ }
718
+ try {
719
+ const saved = await createSecret({
720
+ org: tenantKey,
721
+ body: {
722
+ name: serviceDisplayName,
723
+ env_var: trimmedEnvVar,
724
+ allow_hosts: hosts,
725
+ source_credential_id: createdId,
726
+ source_field: agentField,
727
+ },
728
+ }).unwrap();
729
+ closeAfterSave(saved);
197
730
  }
731
+ catch (error) {
732
+ showSecretFailure(error);
733
+ }
734
+ return;
735
+ }
736
+ const body = {
737
+ name: trimmedName,
738
+ env_var: trimmedEnvVar,
739
+ allow_hosts: hosts,
740
+ value: trimmedValue,
741
+ };
742
+ try {
743
+ const saved = await createSecret({ org: tenantKey, body }).unwrap();
744
+ if (toastOnSave)
745
+ toast.success(t('secrets.customAdded', { name: trimmedName }));
746
+ closeAfterSave(saved);
747
+ }
748
+ catch (error) {
749
+ showSecretFailure(error);
198
750
  }
199
751
  };
200
752
  const fieldError = (key, id) => fieldErrors[key] ? (jsx("p", { id: `${id}-error`, role: "alert", className: "text-xs text-red-600", children: fieldErrors[key] })) : null;
201
- return (jsx(Dialog, { open: open, onOpenChange: (next) => !isSaving && onOpenChange(next), children: jsxs(DialogContent, { className: "max-h-[90vh] w-full max-w-lg overflow-y-auto", "data-testid": "vm-secret-dialog", children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { className: "ibl-dialog-title", children: isEdit ? t('virtualMachineSecrets.editTitle') : t('virtualMachineSecrets.createTitle') }), jsx(DialogDescription, { children: t('virtualMachineSecrets.dialogDescription') })] }), jsxs("form", { onSubmit: handleSubmit, noValidate: true, className: "mt-1 grid gap-5", children: [formError && (jsx("div", { role: "alert", "data-testid": "vm-secret-form-error", className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700", children: formError })), jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { htmlFor: ids.name, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldName') }), jsx(Input, { id: ids.name, value: name, maxLength: NAME_MAX_LENGTH, onChange: (event) => setName(event.target.value), placeholder: t('virtualMachineSecrets.namePlaceholder'), "aria-invalid": fieldErrors.name ? true : undefined, "aria-describedby": fieldErrors.name ? `${ids.name}-error` : undefined, required: true }), fieldError('name', ids.name)] }), jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { htmlFor: ids.envVar, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldEnvVar') }), jsx(Input, { id: ids.envVar, value: envVar, maxLength: ENV_VAR_MAX_LENGTH, readOnly: isEdit, disabled: isEdit, onChange: (event) => setEnvVar(event.target.value), placeholder: t('virtualMachineSecrets.envVarPlaceholder'), autoCapitalize: "characters", autoComplete: "off", spellCheck: false, className: "font-mono", "aria-invalid": fieldErrors.env_var ? true : undefined, "aria-describedby": [ids.envVarHelp, fieldErrors.env_var ? `${ids.envVar}-error` : '']
202
- .filter(Boolean)
203
- .join(' '), required: !isEdit }), jsx("p", { id: ids.envVarHelp, className: "text-xs text-gray-500", children: isEdit
204
- ? t('virtualMachineSecrets.envVarReadOnlyHelp')
205
- : t('virtualMachineSecrets.envVarHelp') }), fieldError('env_var', ids.envVar)] }), jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { htmlFor: ids.hosts, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldHosts') }), jsx(HostPortChipInput, { id: ids.hosts, value: hosts, onChange: setHosts, hint: t('virtualMachineSecrets.hostsHint'), error: fieldErrors.allow_hosts, testId: "vm-secret-hosts" })] }), jsxs("fieldset", { className: "space-y-3", children: [jsx("legend", { id: ids.source, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldSource') }), jsxs(RadioGroup, { value: source, onValueChange: (next) => setSource(next), "aria-labelledby": ids.source, className: "gap-3", children: [jsxs("div", { className: "flex items-start gap-3", children: [jsx(RadioGroupItem, { value: "value", id: ids.sourceValue, "data-testid": "vm-secret-source-value", className: BLUE_RADIO_ITEM_CLASS }), jsxs(Label, { htmlFor: ids.sourceValue, className: "flex flex-col gap-1 font-normal", children: [jsx("span", { className: "text-[13px] font-medium text-[#646464]", children: t('virtualMachineSecrets.sourceValue') }), jsx("span", { className: "text-xs text-gray-500", children: t('virtualMachineSecrets.sourceValueDescription') })] })] }), jsxs("div", { className: "flex items-start gap-3", children: [jsx(RadioGroupItem, { value: "credential", id: ids.sourceCredential, "data-testid": "vm-secret-source-credential", className: BLUE_RADIO_ITEM_CLASS }), jsxs(Label, { htmlFor: ids.sourceCredential, className: "flex flex-col gap-1 font-normal", children: [jsx("span", { className: "text-[13px] font-medium text-[#646464]", children: t('virtualMachineSecrets.sourceCredential') }), jsx("span", { className: "text-xs text-gray-500", children: t('virtualMachineSecrets.sourceCredentialDescription') })] })] })] })] }), source === 'value' ? (jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { htmlFor: ids.value, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldValue') }), jsx(Input, { id: ids.value, type: "password", value: value, onChange: (event) => setValue(event.target.value), placeholder: isEdit
206
- ? t('virtualMachineSecrets.valueKeepPlaceholder')
207
- : t('virtualMachineSecrets.valuePlaceholder'), autoComplete: "new-password", spellCheck: false, "aria-invalid": fieldErrors.value ? true : undefined, "aria-describedby": [ids.valueHelp, fieldErrors.value ? `${ids.value}-error` : '']
753
+ const labelClass = 'flex items-center gap-2 text-sm font-medium text-[#646464]';
754
+ // A label row: the label itself (the input's accessible name), the red mark
755
+ // of a required field, and the info icon.
756
+ const fieldLabel = ({ htmlFor, onClick, text, info, required = false, }) => (jsxs("div", { className: "flex items-center gap-2", children: [jsx(Label, { htmlFor: htmlFor, onClick: onClick, className: "text-sm font-medium text-[#646464]", children: text }), required && (jsx("span", { className: "-ml-1 text-red-500", "aria-hidden": "true", children: "*" })), jsx(FieldInfo, { label: text, text: info })] }));
757
+ const credentialFieldBox = ({ field, required, placeholder, inputRef, }) => {
758
+ var _a;
759
+ const label = fieldText(field.name);
760
+ const id = ids.field(field.name);
761
+ const errorKey = fieldErrorKey(field.name);
762
+ return (jsxs("div", { className: "space-y-1.5", children: [fieldLabel({ htmlFor: id, text: label, info: t('secrets.serviceFieldInfo'), required }), jsx(Input, { ref: inputRef, id: id, type: field.isSensitive ? 'password' : 'text', value: (_a = fieldValues[field.name]) !== null && _a !== void 0 ? _a : '', onChange: (event) => setFieldValues((current) => ({
763
+ ...current,
764
+ [field.name]: event.target.value,
765
+ })), placeholder: placeholder(label), autoComplete: field.isSensitive ? 'new-password' : 'off', spellCheck: false, "aria-invalid": fieldErrors[errorKey] ? true : undefined, "aria-describedby": fieldErrors[errorKey] ? `${id}-error` : undefined, "data-testid": `vm-secret-field-${field.name}` }), fieldError(errorKey, id)] }, field.name));
766
+ };
767
+ const aiFieldBox = (field, required, first = false) => credentialFieldBox({
768
+ field,
769
+ required,
770
+ placeholder: (label) => isEditAi
771
+ ? t('secrets.keyKeepPlaceholder')
772
+ : field.name === 'key'
773
+ ? t('secrets.keyPlaceholder')
774
+ : t('secrets.serviceFieldPlaceholder', { label }),
775
+ inputRef: first ? firstInputRef : undefined,
776
+ });
777
+ const aiEditHint = isEditAi && aiForm !== 'azure' ? t('secrets.keyKeepHelp') : null;
778
+ const isAiProviderHeld = (provider) => provider.form === 'azure' ? azureFullyHeld : heldAiSlugs.has(provider.slug);
779
+ const aiEntries = aiProviders
780
+ .map((provider) => ({
781
+ value: `${AI_PICK_PREFIX}${provider.slug}`,
782
+ testId: `vm-secret-service-ai-${provider.slug}`,
783
+ displayName: provider.displayName,
784
+ logo: provider.logo,
785
+ marker: !aiKeysSettled
786
+ ? t('secrets.serviceNotLoadedMarker')
787
+ : isAiProviderHeld(provider)
788
+ ? t('secrets.serviceAddedMarker')
789
+ : null,
790
+ }))
791
+ .sort((a, b) => a.displayName.localeCompare(b.displayName));
792
+ const serviceEntries = services
793
+ .map((service) => ({
794
+ value: service.slug,
795
+ testId: `vm-secret-service-${service.slug}`,
796
+ displayName: service.displayName,
797
+ logo: service.logo,
798
+ marker: addedSlugs.has(service.slug)
799
+ ? t(fromSandbox ? 'secrets.serviceAddedMarkerSandbox' : 'secrets.serviceAddedMarker')
800
+ : null,
801
+ }))
802
+ .sort((a, b) => a.displayName.localeCompare(b.displayName));
803
+ const pickItem = (entry) => (jsxs(CommandItem, { value: entry.displayName, disabled: entry.marker !== null, onSelect: () => pickFromBox(entry.value), className: "cursor-pointer", "data-testid": entry.testId, children: [entry.logo ? (jsx("img", { src: entry.logo, alt: "", className: "h-4 w-4 rounded-sm object-contain" })) : (jsx(KeyRound, { className: "h-4 w-4 text-gray-400", "aria-hidden": "true" })), entry.displayName, entry.marker && jsx("span", { className: "text-xs text-gray-400", children: entry.marker })] }, entry.value));
804
+ const pickHint = isAi
805
+ ? { text: t('secrets.aiProviderHint'), testId: 'vm-secret-ai-hint' }
806
+ : platformOnly
807
+ ? isFilePicker
808
+ ? {
809
+ text: t('secrets.filePickerPurpose', { name: serviceDisplayName }),
810
+ testId: 'vm-secret-file-picker-purpose',
811
+ }
812
+ : {
813
+ text: t('secrets.platformOnlyHint', { name: serviceDisplayName }),
814
+ testId: 'vm-secret-platform-only',
815
+ }
816
+ : isKnown && !fromSandbox
817
+ ? { text: t('secrets.serviceAgentHint'), testId: 'vm-secret-service-agent-hint' }
818
+ : null;
819
+ const addLabel = t(isCustom
820
+ ? 'secrets.addEnvVarTitle'
821
+ : isLlmBox
822
+ ? 'secrets.addLlmTitle'
823
+ : 'secrets.addServiceTitle');
824
+ // Listed as an environment variable, a bound key keeps that title even when its credential did not answer.
825
+ const editLabel = t(isEditCustom || (bound && !fromServicesTab)
826
+ ? 'secrets.editEnvVarTitle'
827
+ : isEditAi
828
+ ? 'secrets.editLlmTitle'
829
+ : 'secrets.editServiceTitle');
830
+ const title = isLink
831
+ ? t('secrets.linkTitle', { name: serviceDisplayName })
832
+ : isCreate
833
+ ? addLabel
834
+ : editLabel;
835
+ const primaryLabel = isLink ? t('secrets.save') : isCreate ? addLabel : t('secrets.saveChanges');
836
+ const keyHelpText = isEditCustom && !readsServiceKey ? t('secrets.keyKeepHelp') : null;
837
+ const keyReadFromLine = (name) => (jsxs("div", { className: "space-y-1.5", children: [jsx("span", { className: labelClass, children: t('secrets.fieldKey') }), jsx("p", { className: "rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700", "data-testid": "vm-secret-key-read-from", children: t('secrets.keyReadFromService', { name }) })] }));
838
+ const serviceLine = (jsxs("div", { className: "flex items-center gap-2 text-sm text-gray-900", "data-testid": "vm-secret-service", children: [serviceLogo ? (jsx("img", { src: serviceLogo, alt: "", className: "h-5 w-5 rounded-sm object-contain" })) : (jsx(KeyRound, { className: "h-5 w-5 text-gray-400", "aria-hidden": "true" })), jsx("span", { className: "font-medium", children: serviceDisplayName })] }));
839
+ return (jsx(Dialog, { open: open, onOpenChange: (next) => !isSaving && onOpenChange(next), children: jsxs(DialogContent, { className: "max-h-[90vh] w-full max-w-lg overflow-y-auto", "data-testid": "vm-secret-dialog",
840
+ // Land in the first box, not on its info icon (whose tooltip would open).
841
+ onOpenAutoFocus: (event) => {
842
+ var _a, _b;
843
+ event.preventDefault();
844
+ // A greyed-out box refuses focus, which would leave it behind the dialog.
845
+ const box = boxInputRef.current;
846
+ ((_b = (_a = (box && !box.disabled ? box : null)) !== null && _a !== void 0 ? _a : firstInputRef.current) !== null && _b !== void 0 ? _b : event.currentTarget).focus();
847
+ }, children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { className: "ibl-dialog-title", children: title }), jsx(DialogDescription, { children: t('secrets.dialogDescription') })] }), jsxs("form", { onSubmit: handleSubmit, noValidate: true, className: "mt-1 grid gap-5", children: [showServiceSelect && (jsxs("div", { className: "space-y-1.5", children: [fieldLabel({
848
+ // cmdk puts its own id on the input, so a `for` could not reach it.
849
+ onClick: () => { var _a; return (_a = boxInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
850
+ text: boxLabel,
851
+ info: t(isLlmBox ? 'secrets.llmInfo' : 'secrets.serviceInfo'),
852
+ required: true,
853
+ }), serviceSlug ? (jsxs("div", { className: "border-input flex min-h-9 items-center justify-between gap-2 rounded-md border px-3 py-1", "data-testid": "vm-secret-service-picked", children: [serviceLine, !credentialSaved && (jsx(Button, { ref: changeButtonRef, type: "button", variant: "ghost", size: "sm", className: "h-7 cursor-pointer px-2 text-xs", disabled: isSaving, onClick: reopenBox, "data-testid": "vm-secret-service-change", children: t('secrets.changeService') }))] })) : (jsxs(Command, { label: boxLabel, className: cn('border-input focus-within:ring-ring h-auto rounded-md border bg-transparent focus-within:ring-1', !showSuggestions && '[&_[cmdk-input-wrapper]]:border-b-0'),
854
+ // A press on a suggestion must not take focus from the box, or the list closes before its click lands.
855
+ onMouseDown: (event) => {
856
+ var _a;
857
+ if (event.target === boxInputRef.current)
858
+ return;
859
+ event.preventDefault();
860
+ (_a = boxInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
861
+ }, children: [jsx(CommandInput, { ref: boxInputRef, value: boxSearch, onValueChange: setBoxSearch, onFocus: () => setBoxFocused(true), disabled: boxDisabled, placeholder: t(choices === 'loading'
862
+ ? 'secrets.loading'
863
+ : isLlmBox
864
+ ? 'secrets.llmPlaceholder'
865
+ : 'secrets.servicePlaceholder'), className: "h-9 py-1", "aria-invalid": fieldErrors.service ? true : undefined, "aria-describedby": fieldErrors.service ? `${ids.service}-error` : undefined, "data-testid": "vm-secret-service-select" }), showSuggestions && (jsxs(CommandList, { label: boxLabel, className: "max-h-56 p-1", children: [jsx(CommandEmpty, { className: "px-3 py-4 text-center text-sm text-gray-500", "data-testid": "vm-secret-service-no-match", children: t(isLlmBox ? 'secrets.noMatchLlm' : 'secrets.noMatchService') }), [...aiEntries, ...serviceEntries].map(pickItem)] }))] })), pickHint && (jsx("p", { className: "text-xs text-gray-500", "data-testid": pickHint.testId, children: pickHint.text })), fieldError('service', ids.service), choices === 'failed' && (jsxs("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "vm-secret-choices-failed", children: [jsx("p", { role: "alert", className: "text-xs text-red-600", children: t('secrets.choicesFailed') }), onRetryChoices && (jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onRetryChoices, "data-testid": "vm-secret-choices-retry", children: t('secrets.tryAgain') }))] }))] })), !isCreate && !isEditCustom && (jsxs("div", { className: "space-y-1.5", children: [jsx("span", { className: labelClass, children: boxLabel }), serviceLine] })), credentialSaved && !sourceFieldRefused && (jsx("p", { role: "status", className: "text-sm text-gray-700", "data-testid": "vm-secret-second-write", children: t(credentialReadFailed ? 'secrets.secondWriteRetry' : 'secrets.secondWriteFailed', {
866
+ name: serviceDisplayName,
867
+ }) })), showServiceFields &&
868
+ serviceFields.map((field, index) => credentialFieldBox({
869
+ field,
870
+ required: !isEditService && field.required,
871
+ placeholder: (label) => isEditService && field.isSensitive
872
+ ? t('secrets.keyKeepPlaceholder')
873
+ : t('secrets.serviceFieldPlaceholder', { label }),
874
+ inputRef: index === 0 ? firstInputRef : undefined,
875
+ })), isAi &&
876
+ aiForm === 'fields' &&
877
+ aiFields.map((field, index) => aiFieldBox(field, field.required && !isEditAi, index === 0)), isAi && aiForm === 'azure' && (jsx(AzureModelFields, { models: pickableAzureModels, selected: azureSelected, configs: azureConfigs, onSelectedChange: setAzureSelected, onConfigsChange: setAzureConfigs, mode: isEditAi ? 'edit' : 'add', errors: azureErrors, loading: Boolean(isLoadingLlmProviders), modelsNotice: azureModelsNotice, onRetryModels: isLlmProvidersError && username ? () => void refetchLlmProviders() : undefined })), aiEditHint && (jsx("p", { className: "text-xs text-gray-500", "data-testid": "vm-secret-ai-hint", children: aiEditHint })), isCustom && (jsxs(Fragment, { children: [jsxs("div", { className: "space-y-1.5", children: [fieldLabel({
878
+ htmlFor: ids.name,
879
+ text: t('secrets.fieldName'),
880
+ info: t('secrets.nameInfo'),
881
+ required: true,
882
+ }), jsx(Input, { ref: firstInputRef, id: ids.name, value: name, maxLength: NAME_MAX_LENGTH, onChange: (event) => setName(event.target.value), placeholder: t('secrets.namePlaceholder'), "aria-invalid": fieldErrors.name ? true : undefined, "aria-describedby": fieldErrors.name ? `${ids.name}-error` : undefined, required: true }), fieldError('name', ids.name)] }), secret && readsServiceKey ? (keyReadFromLine(secret.name)) : (jsxs("div", { className: "space-y-1.5", children: [fieldLabel({
883
+ htmlFor: ids.value,
884
+ text: t('secrets.fieldKey'),
885
+ info: t('secrets.keyInfo'),
886
+ required: !isEditCustom,
887
+ }), jsx(Input, { id: ids.value, type: "password", value: value, onChange: (event) => setValue(event.target.value), placeholder: isEditCustom ? t('secrets.keyKeepPlaceholder') : t('secrets.keyPlaceholder'), autoComplete: "new-password", spellCheck: false, "aria-invalid": fieldErrors.value ? true : undefined, "aria-describedby": [
888
+ keyHelpText ? ids.valueHelp : '',
889
+ fieldErrors.value ? `${ids.value}-error` : '',
890
+ ]
891
+ .filter(Boolean)
892
+ .join(' '), required: !isEditCustom, "data-testid": "vm-secret-value" }), keyHelpText && (jsx("p", { id: ids.valueHelp, className: "text-xs text-gray-500", children: keyHelpText })), fieldError('value', ids.value)] }))] })), isLink && keyReadFromLine(serviceDisplayName), asksHosts && (jsxs("div", { className: "space-y-1.5", children: [fieldLabel({
893
+ htmlFor: ids.hosts,
894
+ text: t('secrets.fieldHosts'),
895
+ info: t('secrets.hostsInfo'),
896
+ required: true,
897
+ }), jsx(HostPortChipInput, { id: ids.hosts, value: hosts, onChange: setHosts, defaultPort: VIRTUAL_MACHINE_DEFAULT_HOST_PORT, placeholder: t('secrets.hostsPlaceholder'), hint: isKnown ? t('secrets.serviceHostsHint') : t('secrets.hostsHint'), listLabel: t('secrets.fieldHosts'), error: fieldErrors.allow_hosts, testId: "vm-secret-hosts" })] })), showEnvVar && (jsxs("div", { className: "space-y-1.5", children: [fieldLabel({
898
+ htmlFor: ids.envVar,
899
+ text: t('secrets.fieldEnvVar'),
900
+ info: t('secrets.envVarInfo'),
901
+ required: !envVarReadOnly,
902
+ }), jsx(Input, { id: ids.envVar, value: envVar, maxLength: VIRTUAL_MACHINE_ENV_VAR_MAX_LENGTH, readOnly: envVarReadOnly, disabled: envVarReadOnly, onChange: (event) => {
903
+ setEnvVar(event.target.value);
904
+ // Emptying the box hands the variable back to the name.
905
+ setEnvVarTouched(event.target.value.length > 0);
906
+ }, placeholder: t('secrets.envVarPlaceholder'), autoCapitalize: "characters", autoComplete: "off", spellCheck: false, className: "font-mono", "aria-invalid": fieldErrors.env_var ? true : undefined, "aria-describedby": [ids.envVarHelp, fieldErrors.env_var ? `${ids.envVar}-error` : '']
208
907
  .filter(Boolean)
209
- .join(' '), required: !isEdit, "data-testid": "vm-secret-value" }), jsx("p", { id: ids.valueHelp, className: "text-xs text-gray-500", children: isEdit
210
- ? t('virtualMachineSecrets.valueKeepHelp')
211
- : t('virtualMachineSecrets.valueHelp', {
212
- min: VIRTUAL_MACHINE_SECRET_VALUE_MIN_LENGTH,
213
- }) }), fieldError('value', ids.value)] })) : (jsxs("div", { className: "space-y-4", children: [jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { id: ids.credentialLabel, htmlFor: ids.credential, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldCredential') }), credentials.length === 0 ? (jsx("p", { className: "text-xs text-gray-500", "data-testid": "vm-secret-no-credentials", children: t('virtualMachineSecrets.noCredentials') })) : (jsxs(Select, { value: credentialId, onValueChange: (next) => {
214
- setCredentialId(next);
215
- setField('');
216
- }, children: [jsx(SelectTrigger, { id: ids.credential, "aria-labelledby": ids.credentialLabel, "aria-invalid": fieldErrors.source_credential_id ? true : undefined, "data-testid": "vm-secret-credential-select", children: jsx(SelectValue, { placeholder: t('virtualMachineSecrets.credentialPlaceholder') }) }), jsx(SelectContent, { children: credentials.map((option) => (jsx(SelectItem, { value: String(option.id), children: option.name }, option.id))) })] })), fieldError('source_credential_id', ids.credential)] }), jsxs("div", { className: "space-y-1.5", children: [jsx(Label, { id: ids.fieldLabel, htmlFor: ids.field, className: "flex items-center text-sm font-medium text-[#646464]", children: t('virtualMachineSecrets.fieldCredentialField') }), jsxs(Select, { value: field, onValueChange: setField, disabled: !selectedCredential || credentialFields.length === 0, children: [jsx(SelectTrigger, { id: ids.field, "aria-labelledby": ids.fieldLabel, "aria-invalid": fieldErrors.source_field ? true : undefined, "data-testid": "vm-secret-field-select", children: jsx(SelectValue, { placeholder: t('virtualMachineSecrets.credentialFieldPlaceholder') }) }), jsx(SelectContent, { children: credentialFields.map((key) => (jsx(SelectItem, { value: key, children: key }, key))) })] }), selectedCredential && credentialFields.length === 0 && (jsx("p", { className: "text-xs text-gray-500", children: t('virtualMachineSecrets.credentialNoFields') })), fieldError('source_field', ids.field)] })] })), jsxs(DialogFooter, { children: [jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSaving, children: t('virtualMachineSecrets.cancel') }), jsxs(Button, { type: "submit", disabled: isSaving, "data-testid": "vm-secret-save", className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] text-white hover:opacity-90", children: [isSaving && jsx(LoaderCircle, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }), isEdit
217
- ? t('virtualMachineSecrets.saveChanges')
218
- : t('virtualMachineSecrets.createSecret')] })] })] })] }) }));
908
+ .join(' '), "data-testid": "vm-secret-env-var" }), jsx("p", { id: ids.envVarHelp, className: "text-xs text-gray-500", children: envVarReadOnly ? t('secrets.envVarReadOnlyHelp') : t('secrets.envVarHelp') }), fieldError('env_var', ids.envVar)] })), formError && (jsx("p", { role: "alert", "data-testid": "vm-secret-form-error", className: "text-sm text-red-600", children: formError })), jsxs(DialogFooter, { children: [jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSaving, children: t('secrets.cancel') }), jsxs(Button, { type: "submit", disabled: isSaving, "data-testid": "vm-secret-save", className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] text-white hover:opacity-90", children: [isSaving && jsx(LoaderCircle, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }), primaryLabel] })] })] })] }) }));
219
909
  }
220
910
 
221
- export { VmSecretDialog };
911
+ export { VmSecretDialog, parsePick };
222
912
  //# sourceMappingURL=vm-secret-dialog.js.map