hive-am 1.1.0 → 1.2.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 (262) hide show
  1. package/CHANGELOG.md +100 -1
  2. package/README.md +9 -1
  3. package/package.json +13 -2
  4. package/server/dist/api.js +42 -762
  5. package/server/dist/connections/channel-skill.js +13 -1
  6. package/server/dist/connections/files.js +45 -1
  7. package/server/dist/connections/manager.js +41 -3
  8. package/server/dist/connections/outbound.js +2 -1
  9. package/server/dist/connections/prompt.js +4 -0
  10. package/server/dist/connections/router.js +3 -2
  11. package/server/dist/connections/store.js +4 -43
  12. package/server/dist/connections/telegram.js +43 -3
  13. package/server/dist/cron.js +2 -1
  14. package/server/dist/db/json.js +16 -0
  15. package/server/dist/db/migrations.js +199 -0
  16. package/server/dist/db.js +98 -196
  17. package/server/dist/errors.js +11 -0
  18. package/server/dist/git/browse.js +99 -0
  19. package/server/dist/git/ops.js +136 -19
  20. package/server/dist/git/repo.js +2 -1
  21. package/server/dist/history/claude.js +21 -21
  22. package/server/dist/history/index.js +17 -9
  23. package/server/dist/history/kiro.js +17 -12
  24. package/server/dist/history/lines.js +12 -0
  25. package/server/dist/history/opencode.js +18 -1
  26. package/server/dist/http/body.js +46 -0
  27. package/server/dist/http/errors.js +21 -0
  28. package/server/dist/http/guards.js +44 -0
  29. package/server/dist/http/router.js +24 -0
  30. package/server/dist/http/routes/agents.js +124 -0
  31. package/server/dist/http/routes/channel.js +16 -0
  32. package/server/dist/http/routes/colonies.js +9 -0
  33. package/server/dist/http/routes/connections.js +36 -0
  34. package/server/dist/http/routes/fs.js +22 -0
  35. package/server/dist/http/routes/git.js +90 -0
  36. package/server/dist/http/routes/meta.js +11 -0
  37. package/server/dist/http/routes/notebook.js +34 -0
  38. package/server/dist/http/routes/orchestration.js +32 -0
  39. package/server/dist/http/routes/resources.js +68 -0
  40. package/server/dist/http/routes/schedules.js +40 -0
  41. package/server/dist/http/routes/skills.js +47 -0
  42. package/server/dist/http/routes/terminals.js +18 -0
  43. package/server/dist/http/routes/types.js +36 -0
  44. package/server/dist/http/validate.js +65 -0
  45. package/server/dist/index.js +67 -5
  46. package/server/dist/instructions.js +8 -2
  47. package/server/dist/objects/agent.js +49 -0
  48. package/server/dist/objects/database.js +451 -0
  49. package/server/dist/objects/db-history.js +79 -0
  50. package/server/dist/objects/docker-info.js +75 -0
  51. package/server/dist/objects/docker.js +285 -0
  52. package/server/dist/objects/driver-props.js +196 -0
  53. package/server/dist/objects/exec.js +16 -0
  54. package/server/dist/objects/http-history.js +44 -0
  55. package/server/dist/objects/http-script.js +644 -0
  56. package/server/dist/objects/http.js +735 -0
  57. package/server/dist/objects/index.js +445 -0
  58. package/server/dist/objects/model.js +250 -0
  59. package/server/dist/objects/runner.js +211 -0
  60. package/server/dist/objects/stats.js +106 -0
  61. package/server/dist/objects/store.js +115 -0
  62. package/server/dist/objects/supervisor.js +111 -0
  63. package/server/dist/objects/templates.js +67 -0
  64. package/server/dist/providers/claude.js +3 -13
  65. package/server/dist/providers/index.js +7 -1
  66. package/server/dist/providers/kiro.js +2 -5
  67. package/server/dist/providers/opencode-server.js +45 -0
  68. package/server/dist/providers/opencode.js +52 -9
  69. package/server/dist/providers/preamble.js +2 -0
  70. package/server/dist/providers/spawn.js +31 -3
  71. package/server/dist/runtime.js +8 -6
  72. package/server/dist/schedules.js +2 -21
  73. package/server/dist/seed.js +15 -11
  74. package/server/dist/services/agents.js +90 -0
  75. package/server/dist/services/colonies.js +38 -0
  76. package/server/dist/services/connections.js +76 -0
  77. package/server/dist/services/notebook.js +22 -0
  78. package/server/dist/services/providers.js +27 -0
  79. package/server/dist/services/schedules.js +18 -0
  80. package/server/dist/sessions-summary.js +51 -0
  81. package/server/dist/skills/defaults.js +37 -0
  82. package/server/dist/skills/notebook.js +3 -8
  83. package/server/dist/terminals.js +185 -0
  84. package/server/dist/wake.js +13 -16
  85. package/server/dist/watch.js +2 -8
  86. package/server/mcp/dispatch.mjs +70 -1
  87. package/web/.next/BUILD_ID +1 -1
  88. package/web/.next/app-build-manifest.json +146 -94
  89. package/web/.next/app-path-routes-manifest.json +6 -4
  90. package/web/.next/build-manifest.json +14 -14
  91. package/web/.next/prerender-manifest.json +67 -43
  92. package/web/.next/react-loadable-manifest.json +26 -1
  93. package/web/.next/required-server-files.json +13 -1
  94. package/web/.next/routes-manifest.json +26 -0
  95. package/web/.next/server/app/_not-found/page.js +2 -2
  96. package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  97. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  98. package/web/.next/server/app/_not-found.html +1 -1
  99. package/web/.next/server/app/_not-found.rsc +12 -11
  100. package/web/.next/server/app/agents/[id]/page.js +4 -4
  101. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  102. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  103. package/web/.next/server/app/agents/page.js +2 -2
  104. package/web/.next/server/app/agents/page.js.nft.json +1 -1
  105. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  106. package/web/.next/server/app/agents.html +1 -1
  107. package/web/.next/server/app/agents.rsc +14 -13
  108. package/web/.next/server/app/connections/page.js +2 -2
  109. package/web/.next/server/app/connections/page.js.nft.json +1 -1
  110. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  111. package/web/.next/server/app/connections.html +1 -1
  112. package/web/.next/server/app/connections.rsc +14 -13
  113. package/web/.next/server/app/index.html +1 -1
  114. package/web/.next/server/app/index.rsc +14 -13
  115. package/web/.next/server/app/page.js +2 -2
  116. package/web/.next/server/app/page.js.nft.json +1 -1
  117. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  118. package/web/.next/server/app/relations/page.js +2 -2
  119. package/web/.next/server/app/relations/page.js.nft.json +1 -1
  120. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  121. package/web/.next/server/app/relations.html +1 -1
  122. package/web/.next/server/app/relations.rsc +14 -13
  123. package/web/.next/server/app/resources/[id]/page.js +2 -0
  124. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -0
  125. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -0
  126. package/web/.next/server/app/resources/page.js +2 -0
  127. package/web/.next/server/app/resources/page.js.nft.json +1 -0
  128. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -0
  129. package/web/.next/server/app/resources.html +1 -0
  130. package/web/.next/server/app/resources.meta +15 -0
  131. package/web/.next/server/app/resources.rsc +25 -0
  132. package/web/.next/server/app/schedules/page.js +2 -2
  133. package/web/.next/server/app/schedules/page.js.nft.json +1 -1
  134. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  135. package/web/.next/server/app/schedules.html +1 -1
  136. package/web/.next/server/app/schedules.rsc +14 -13
  137. package/web/.next/server/app/sessions/page.js +2 -2
  138. package/web/.next/server/app/sessions/page.js.nft.json +1 -1
  139. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  140. package/web/.next/server/app/sessions.html +1 -1
  141. package/web/.next/server/app/sessions.rsc +14 -13
  142. package/web/.next/server/app/skills/page.js +2 -2
  143. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  144. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  145. package/web/.next/server/app/skills.html +1 -1
  146. package/web/.next/server/app/skills.rsc +14 -13
  147. package/web/.next/server/app/types/page.js +2 -2
  148. package/web/.next/server/app/types/page.js.nft.json +1 -1
  149. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  150. package/web/.next/server/app/types.html +1 -1
  151. package/web/.next/server/app/types.rsc +14 -13
  152. package/web/.next/server/app-paths-manifest.json +6 -4
  153. package/web/.next/server/chunks/143.js +1 -1
  154. package/web/.next/server/chunks/274.js +1 -0
  155. package/web/.next/server/chunks/306.js +1 -0
  156. package/web/.next/server/chunks/423.js +1 -0
  157. package/web/.next/server/chunks/505.js +6 -0
  158. package/web/.next/server/chunks/555.js +1 -0
  159. package/web/.next/server/chunks/612.js +1 -0
  160. package/web/.next/server/chunks/638.js +1 -0
  161. package/web/.next/server/chunks/692.js +18 -0
  162. package/web/.next/server/chunks/716.js +2 -0
  163. package/web/.next/server/chunks/790.js +11 -0
  164. package/web/.next/server/chunks/802.js +1 -0
  165. package/web/.next/server/chunks/890.js +1 -1
  166. package/web/.next/server/chunks/919.js +1 -0
  167. package/web/.next/server/chunks/950.js +6 -0
  168. package/web/.next/server/middleware-build-manifest.js +1 -1
  169. package/web/.next/server/middleware-react-loadable-manifest.js +1 -1
  170. package/web/.next/server/next-font-manifest.js +1 -1
  171. package/web/.next/server/next-font-manifest.json +1 -1
  172. package/web/.next/server/pages/404.html +1 -1
  173. package/web/.next/server/pages/500.html +1 -1
  174. package/web/.next/server/server-reference-manifest.json +1 -1
  175. package/web/.next/static/Bz7onClw1BajMUCwqpU8o/_buildManifest.js +1 -0
  176. package/web/.next/static/chunks/0937d497-114a2a3de515565e.js +1 -0
  177. package/web/.next/static/chunks/176-aeaf907a6ea5627d.js +1 -0
  178. package/web/.next/static/chunks/291-efae53ea5f7ee92d.js +1 -0
  179. package/web/.next/static/chunks/2b9ff8ee-969e65cc354b2150.js +1 -0
  180. package/web/.next/static/chunks/30-9adcbe92b15a6815.js +1 -0
  181. package/web/.next/static/chunks/316-26da9cc233ba7557.js +1 -0
  182. package/web/.next/static/chunks/350-56599dc3bf06066d.js +1 -0
  183. package/web/.next/static/chunks/486-13e08542f3a1cbac.js +1 -0
  184. package/web/.next/static/chunks/491-6b4e6201f5110dff.js +1 -0
  185. package/web/.next/static/chunks/517-ccaf8cc5c733cbd8.js +1 -0
  186. package/web/.next/static/chunks/545.bfbd92b7632c09de.js +1 -0
  187. package/web/.next/static/chunks/{805-d946ebedb7e85f73.js → 562-7c2e33d838e869bf.js} +1 -1
  188. package/web/.next/static/chunks/581-3ad5c4343dad3f50.js +1 -0
  189. package/web/.next/static/chunks/586-f7017d585a84738d.js +1 -0
  190. package/web/.next/static/chunks/657.b4c39e676c3e20dc.js +1 -0
  191. package/web/.next/static/chunks/701.6abcaf5e60463eef.js +6 -0
  192. package/web/.next/static/chunks/705-c7e75806f77b880c.js +1 -0
  193. package/web/.next/static/chunks/706-fa2be0f10ffebe6a.js +1 -0
  194. package/web/.next/static/chunks/837-33c7480524f48577.js +1 -0
  195. package/web/.next/static/chunks/839-4aefe6e71be6e1ef.js +1 -0
  196. package/web/.next/static/chunks/844-fe55292e0701f436.js +1 -0
  197. package/web/.next/static/chunks/89-b194fcffe5120c44.js +1 -0
  198. package/web/.next/static/chunks/97.594543c2196de524.js +1 -0
  199. package/web/.next/static/chunks/app/_not-found/page-238a7b80bda6b4ae.js +1 -0
  200. package/web/.next/static/chunks/app/agents/[id]/page-3faf40800981a736.js +1 -0
  201. package/web/.next/static/chunks/app/agents/page-f4c4c80f955f3967.js +1 -0
  202. package/web/.next/static/chunks/app/connections/page-0936beaf02d863c6.js +1 -0
  203. package/web/.next/static/chunks/app/layout-99620746d028dda8.js +1 -0
  204. package/web/.next/static/chunks/app/page-a7f292117b7d76bf.js +1 -0
  205. package/web/.next/static/chunks/app/relations/page-fba25393c8688714.js +1 -0
  206. package/web/.next/static/chunks/app/resources/[id]/page-d110d89bb8b5fca7.js +1 -0
  207. package/web/.next/static/chunks/app/resources/page-bbd0b450d3f3131d.js +1 -0
  208. package/web/.next/static/chunks/app/schedules/page-a1124397fc760413.js +1 -0
  209. package/web/.next/static/chunks/app/sessions/page-0e322811b0cde724.js +1 -0
  210. package/web/.next/static/chunks/app/skills/page-22ea0ef89d9f7a13.js +1 -0
  211. package/web/.next/static/chunks/app/types/page-18c4e1db2724d41d.js +1 -0
  212. package/web/.next/static/chunks/fcafe1ac.366e4950d3b0d4b7.js +18 -0
  213. package/web/.next/static/chunks/framework-bbac72adbbe2d328.js +1 -0
  214. package/web/.next/static/chunks/main-app-6086068e5fb5eacd.js +1 -0
  215. package/web/.next/static/chunks/main-c15f3fee674e0303.js +1 -0
  216. package/web/.next/static/chunks/pages/_app-d1670a2c6ce392fc.js +1 -0
  217. package/web/.next/static/chunks/pages/_error-95aac014d202fa7a.js +1 -0
  218. package/web/.next/static/chunks/webpack-ef515e41a83a16ac.js +1 -0
  219. package/web/.next/static/css/945795da867f5250.css +1 -0
  220. package/web/.next/static/css/b7a03c62468f4263.css +1 -0
  221. package/web/.next/trace +29 -23
  222. package/web/.next/types/app/resources/[id]/page.ts +84 -0
  223. package/web/.next/types/app/resources/page.ts +84 -0
  224. package/web/.next/types/routes.d.ts +6 -2
  225. package/web/.next/types/validator.ts +18 -0
  226. package/web/next.config.mjs +4 -0
  227. package/web/.next/server/chunks/247.js +0 -1
  228. package/web/.next/server/chunks/484.js +0 -11
  229. package/web/.next/server/chunks/851.js +0 -1
  230. package/web/.next/server/chunks/932.js +0 -2
  231. package/web/.next/static/_z2hBOHhwiR5ytdI_8alh/_buildManifest.js +0 -1
  232. package/web/.next/static/chunks/0937d497-44abb0f9355ace92.js +0 -1
  233. package/web/.next/static/chunks/2b9ff8ee-c3b61ac1e608c57d.js +0 -1
  234. package/web/.next/static/chunks/463-6ae35cdefdc59169.js +0 -1
  235. package/web/.next/static/chunks/493-50d2adf9fd5ec680.js +0 -1
  236. package/web/.next/static/chunks/517-eb26c72f6059aa26.js +0 -1
  237. package/web/.next/static/chunks/589-8bf536f331de4269.js +0 -1
  238. package/web/.next/static/chunks/657.f1e03b7b65eba1d9.js +0 -1
  239. package/web/.next/static/chunks/687-3a4205f51be38602.js +0 -1
  240. package/web/.next/static/chunks/837-fd7623601dc78ed8.js +0 -1
  241. package/web/.next/static/chunks/850-318f32484989dd59.js +0 -1
  242. package/web/.next/static/chunks/89-ace2e1aa63babfdf.js +0 -1
  243. package/web/.next/static/chunks/951-e250b541b67da7ce.js +0 -1
  244. package/web/.next/static/chunks/app/_not-found/page-bbd54d7b9a55d7ae.js +0 -1
  245. package/web/.next/static/chunks/app/agents/[id]/page-a8b7a43d2c18483f.js +0 -1
  246. package/web/.next/static/chunks/app/agents/page-e9b17f1c3439ef98.js +0 -1
  247. package/web/.next/static/chunks/app/connections/page-477f36fcd5b13d78.js +0 -1
  248. package/web/.next/static/chunks/app/layout-a2d38e3de5911b1b.js +0 -1
  249. package/web/.next/static/chunks/app/page-6fc87fc5a128a204.js +0 -1
  250. package/web/.next/static/chunks/app/relations/page-0355a93a8eb67989.js +0 -1
  251. package/web/.next/static/chunks/app/schedules/page-39befd15b3b20586.js +0 -1
  252. package/web/.next/static/chunks/app/sessions/page-beae9a74a07d69e0.js +0 -1
  253. package/web/.next/static/chunks/app/skills/page-4f839ac913e26d32.js +0 -1
  254. package/web/.next/static/chunks/app/types/page-4f6b99af3232f861.js +0 -1
  255. package/web/.next/static/chunks/framework-0e68884e76d9a8d3.js +0 -1
  256. package/web/.next/static/chunks/main-app-d6f73ccd41f325c5.js +0 -1
  257. package/web/.next/static/chunks/main-cd22509db15764e2.js +0 -1
  258. package/web/.next/static/chunks/pages/_app-0f75d689c738a6fc.js +0 -1
  259. package/web/.next/static/chunks/pages/_error-d481f6d49fb4455d.js +0 -1
  260. package/web/.next/static/chunks/webpack-d40de72e52f65f79.js +0 -1
  261. package/web/.next/static/css/da22f0402b1c40ae.css +0 -1
  262. /package/web/.next/static/{_z2hBOHhwiR5ytdI_8alh → Bz7onClw1BajMUCwqpU8o}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[844],{9217:(e,s,t)=>{t.d(s,{Zp:()=>y,Bh:()=>w,Mr:()=>k,QJ:()=>x,qP:()=>f,Te:()=>C});var l=t(94799),a=t(52974),n=t(34023),r=t(89075),o=t(86606),i=t(3749),d=t(84561),c=t(69654);let m=null;function u(e){let{template:s,values:t,onPick:a,onValue:r}=e,{t:d}=(0,c.s9)(),u=function(){let[e,s]=(0,n.useState)(m);return(0,n.useEffect)(()=>{m||i.FH.get("/object-templates").then(e=>{m=e,s(e)}).catch(()=>s([]))},[]),e}(),h=null==u?void 0:u.find(e=>e.id===s);return u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"tpls",children:u.map(e=>(0,l.jsxs)("button",{type:"button",className:"tpl","aria-pressed":s===e.id,onClick:()=>a(e),children:[(0,l.jsx)("b",{children:e.name}),(0,l.jsx)("small",{children:e.description})]},e.id))}),h&&h.fields.map(e=>{var s;return(0,l.jsx)(o.D0,{label:e.label,children:(0,l.jsx)("input",{className:"input ".concat("text"===e.kind&&"version"!==e.key?"":"mono"),value:null!=(s=t[e.key])?s:"",onChange:s=>r(e.key,s.target.value),placeholder:e.default,inputMode:"port"===e.kind?"numeric":void 0})},"".concat(h.id,"-").concat(e.key))}),h&&(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:d("tpl.note")})]}):(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:d("git.loading")})}var h=t(48538),p=t(74988),b=t(13460),j=t(67056);let v=e=>void 0===e?"":String(e),x=(e,s,t)=>{var l,a,n,r,o,i,d,c,m,u,h,b,j,x,g,f,k,y,N,w,C,S,T,D,R,q,z,A,F,E,M,P,$,_,O,H,I,L,U;let K=(null==e?void 0:e.kind)==="server"?e.config:{},Q=(null==e?void 0:e.kind)==="docker"?e.config:{},B=(null==e?void 0:e.kind)==="http"?e.config:{},W=(null==e?void 0:e.kind)==="cluster"?e.config:{},V=(null==e?void 0:e.kind)==="database"?e.config:{};return{manager:null!=(i=null==e?void 0:e.manager_id)?i:"",name:null!=(d=null==e?void 0:e.name)?d:"",colony_id:null!=(m=null!=(c=null==e?void 0:e.colony_id)?c:s)?m:"",kind:null!=(h=null!=(u=null==e?void 0:e.kind)?u:t)?h:"server",cwd:null!=(b=K.cwd)?b:"",start:null!=(j=K.start)?j:"",stop:null!=(x=K.stop)?x:"",port:v(K.port),env:(0,p.M6)((null==e?void 0:e.kind)==="server"?K.env:Q.env),restart:null!=(g=K.restart)?g:"no",maxRestarts:v(K.maxRestarts),healthKind:null!=(f=null==(l=K.health)?void 0:l.kind)?f:"",healthTarget:null!=(k=null==(a=K.health)?void 0:a.target)?k:"",healthInterval:v(null==(n=K.health)?void 0:n.intervalSec),healthRetries:v(null==(r=K.health)?void 0:r.retries),healthRestart:!!(null==(o=K.health)?void 0:o.restartWhenUnhealthy),stopTimeout:v((null==e?void 0:e.kind)==="server"?K.stopTimeoutSec:Q.stopTimeoutSec),logMax:v((null==e?void 0:e.kind)==="server"?K.logMaxMb:Q.logMaxMb),folder:null!=(y=B.folder)?y:"",defEnv:null!=(N=B.env)?N:"",variables:null!=(w=B.variables)?w:{},members:null!=(C=W.members)?C:[],template:"",tplValues:{},mode:null!=(S=Q.mode)?S:e?"container":"template",image:null!=(T=Q.image)?T:"",ports:(null!=(D=Q.ports)?D:[]).join("\n"),volumes:(null!=(R=Q.volumes)?R:[]).join("\n"),dockerRestart:null!=(q=Q.restart)?q:"no",command:null!=(z=Q.command)?z:"",file:null!=(A=Q.file)?A:"",project:null!=(F=Q.project)?F:"",services:(null!=(E=Q.services)?E:[]).join(", "),container:null!=(M=Q.container)?M:"",memory:null!=(P=Q.memory)?P:"",cpus:v(Q.cpus),network:null!=($=Q.network)?$:"",engine:null!=(_=V.engine)?_:"postgresql",dbHost:null!=(O=V.host)?O:"",dbPort:v(V.port),dbUser:null!=(H=V.user)?H:"",dbPassword:"",dbPasswordSet:!!V.passwordSet,dbName:null!=(I=V.database)?I:"",dbFile:null!=(L=V.file)?L:"",dbSsl:!!V.ssl,dbTrust:!!V.trustCert,dbReadOnly:!1!==V.readOnly,dbTimeout:v(V.timeoutSec),dbMaxRows:v(V.maxRows),dbProps:{...null!=(U=V.props)?U:{}}}},g=e=>""===e.trim()?void 0:Number(e);function f(e){return"database"===e.kind?k(e):"http"===e.kind?{folder:e.folder.trim(),env:e.defEnv.trim()||void 0,variables:Object.keys(e.variables).length?e.variables:void 0}:"cluster"===e.kind?{members:e.members}:"server"===e.kind?{cwd:e.cwd.trim(),start:e.start.trim(),stop:e.stop.trim()||void 0,port:g(e.port),env:(0,p.y$)(e.env),restart:"no"===e.restart?void 0:e.restart,maxRestarts:g(e.maxRestarts),stopTimeoutSec:g(e.stopTimeout),logMaxMb:g(e.logMax),health:e.healthKind&&e.healthTarget.trim()?{kind:e.healthKind,target:e.healthTarget.trim(),intervalSec:g(e.healthInterval),retries:g(e.healthRetries),restartWhenUnhealthy:e.healthRestart||void 0}:void 0}:"template"===e.mode?{mode:"compose"}:"existing"===e.mode?{mode:"existing",container:e.container.trim(),stopTimeoutSec:g(e.stopTimeout)}:"compose"===e.mode?{mode:"compose",file:e.file.trim(),project:e.project.trim()||void 0,services:e.services.split(",").map(e=>e.trim()).filter(Boolean),stopTimeoutSec:g(e.stopTimeout)}:{mode:"container",image:e.image.trim(),ports:(0,p.Mn)(e.ports),volumes:(0,p.Mn)(e.volumes),env:(0,p.y$)(e.env),restart:e.dockerRestart||"no",command:e.command.trim()||void 0,memory:e.memory.trim()||void 0,cpus:g(e.cpus),network:e.network.trim()||void 0,stopTimeoutSec:g(e.stopTimeout),logMaxMb:g(e.logMax)}}let k=e=>{let s=Object.entries(e.dbProps).filter(s=>{let[t,l]=s;return""!==l.trim()&&(e.dbSsl||!t.startsWith("ssl."))}),t=s.length?Object.fromEntries(s):void 0;return"sqlite"===e.engine?{engine:"sqlite",file:e.dbFile.trim(),props:t,readOnly:e.dbReadOnly,timeoutSec:g(e.dbTimeout),maxRows:g(e.dbMaxRows)}:{engine:e.engine,host:e.dbHost.trim()||void 0,port:g(e.dbPort),user:e.dbUser.trim()||void 0,password:e.dbPassword,database:e.dbName.trim()||void 0,ssl:e.dbSsl||void 0,trustCert:!!e.dbSsl&&!!e.dbTrust||void 0,props:t,readOnly:e.dbReadOnly,timeoutSec:g(e.dbTimeout),maxRows:g(e.dbMaxRows)}},y=e=>{let{title:s,hint:t,wide:a=!1,children:n}=e;return(0,l.jsxs)("section",{className:"of-card ".concat(a?"wide":""),id:"of-".concat(s.toLowerCase().normalize("NFD").replace(/[^a-z0-9]+/g,"-")),"data-title":s,children:[(0,l.jsxs)("header",{children:[(0,l.jsx)("h4",{children:s}),t&&(0,l.jsx)("p",{className:"muted small",children:t})]}),n]})};function N(e){let{file:s,project:t,services:a,onServices:r,onProject:d}=e,{t:m}=(0,c.s9)(),{info:u,err:h,loading:p}=function(e){let[s,t]=(0,n.useState)(null),[l,a]=(0,n.useState)(""),[r,o]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(a(""),!/^\/.+\.ya?ml$/i.test(e))return void t(null);let s=!1;o(!0);let l=setTimeout(()=>i.FH.get("/docker/compose-services?file=".concat(encodeURIComponent(e))).then(e=>!s&&t(e)).catch(e=>{s||(t(null),a(e instanceof Error?e.message:""))}).finally(()=>!s&&o(!1)),300);return()=>{s=!0,clearTimeout(l)}},[e]),{info:s,err:l,loading:r}}(s),b=new Set(a.split(",").map(e=>e.trim()).filter(Boolean));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.D0,{label:m("obj.f.services"),hint:m("dk.services.hint"),children:s?p?(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.loading")}):h?(0,l.jsx)("p",{className:"gx-note err res-m0",children:h}):u&&0===u.services.length?(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.none")}):u?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"chips",children:u.services.map(e=>(0,l.jsx)("button",{type:"button",className:"chip-pick ".concat(b.has(e)?"on":""),"aria-pressed":b.has(e),onClick:()=>(e=>{let s=new Set(b);s.has(e)?s.delete(e):s.add(e),r([...s].join(", "))})(e),children:e},e))}),"file"===u.source&&(0,l.jsx)("p",{className:"muted small res-mt6",children:m("dk.services.file")})]}):null:(0,l.jsx)("p",{className:"muted small res-m0",children:m("dk.services.pickFile")})}),(0,l.jsx)(o.D0,{label:m("obj.f.project"),hint:m("dk.project.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("input",{className:"input mono",value:t,onChange:e=>d(e.target.value),placeholder:null==u?void 0:u.project}),u&&!t&&(0,l.jsx)("button",{type:"button",className:"btn sm",onClick:()=>d(u.project),children:m("dk.project.use",{name:u.project})})]})})]})}function w(e){var s,t,m;let{d:v,set:x,setD:g,scan:f,showKind:k=!1,error:w,objectId:C}=e,{t:S}=(0,c.s9)(),{colonies:T,objects:D}=(0,h.o0)(),R=function(e){let[s,t]=(0,n.useState)(null),[l,a]=(0,n.useState)(null),[r,o]=(0,n.useState)(""),[d,c]=(0,n.useState)(0);return(0,n.useEffect)(()=>{if(!e)return;let s=!1;return i.FH.get("/docker/containers").then(e=>{var l;s||(t(e.containers),o(e.available?"":null!=(l=e.error)?l:"unavailable"))}).catch(()=>!s&&o("unavailable")),i.FH.get("/docker/images").then(e=>!s&&a(e.images)).catch(()=>void 0),()=>{s=!0}},[e,d]),{containers:s,images:l,error:r,reload:(0,n.useCallback)(()=>c(e=>e+1),[])}}("docker"===v.kind&&("existing"===v.mode||"container"===v.mode)),q=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,l.jsx)("input",{className:"input ".concat(s.mono?"mono":""),type:s.type,value:v[e],placeholder:s.placeholder,onChange:s=>x(e,s.target.value)})},z=R.error?(0,l.jsx)("p",{className:"muted small res-mt4",children:S("dk.unavailable",{error:R.error})}):null,A=(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:R.reload,"aria-label":S("dk.refresh"),title:S("dk.refresh"),children:(0,l.jsx)(r.A,{size:14})}),F=f?Object.keys(f.fileVars).filter(e=>"$shared"!==e):void 0,E=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.dR,{value:v.folder,onChange:e=>x("folder",e),label:S("obj.f.httpFolder"),hint:S("obj.f.httpFolder.hint")}),(0,l.jsx)(o.D0,{label:S("obj.f.defaultEnv"),hint:S("obj.f.defaultEnv.hint"),children:(0,l.jsx)(d.b,{value:v.defEnv,onChange:e=>x("defEnv",e),mono:!0,placeholder:"dev",options:[...new Set([...null!=(s=null==f?void 0:f.environments)?s:[],...Object.keys(v.variables).filter(e=>"$shared"!==e)])].map(e=>({value:e}))})})]});return(0,l.jsxs)("div",{className:"of",children:[k&&(0,l.jsx)(y,{title:S("obj.kind.pick"),wide:!0,children:(0,l.jsx)("div",{className:"okinds",children:["server","docker","http","database","cluster"].map(e=>{let{icon:s,color:t}=p.Nd[e];return(0,l.jsxs)("button",{type:"button",className:"okind","aria-pressed":v.kind===e,style:{"--c":t},onClick:()=>x("kind",e),children:[(0,l.jsx)(s,{size:20}),(0,l.jsx)("b",{children:S("obj.kind.".concat(e))}),(0,l.jsx)("small",{children:S("obj.kind.".concat(e,".hint"))})]},e)})})}),(0,l.jsxs)(y,{title:S("of.general"),children:[(0,l.jsx)(o.D0,{label:S("obj.f.name"),error:w,children:q("name",{placeholder:"database"===v.kind?(0,j.I5)(v):void 0})}),(0,l.jsx)(o.D0,{label:S("obj.colony"),children:(0,l.jsxs)("select",{className:"select",value:v.colony_id,onChange:e=>g(s=>({...s,colony_id:e.target.value,members:[]})),children:[(0,l.jsx)("option",{value:"",children:S("obj.noColony")}),T.map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]})}),a.G.includes(v.kind)&&(0,l.jsx)(a.I,{value:v.manager,onChange:e=>x("manager",e)}),"http"===v.kind&&!k&&E]}),"http"===v.kind?(0,l.jsxs)(l.Fragment,{children:[k&&(0,l.jsx)(y,{title:S("of.files"),children:E}),k&&(0,l.jsx)(y,{title:S("of.vars"),wide:!0,children:(0,l.jsx)(b.W,{value:v.variables,onChange:e=>x("variables",e),fileEnvs:F,fileVars:null==f?void 0:f.fileVars,used:null==f?void 0:f.used,fileDefined:null==f?void 0:f.fileDefined,setBy:null==f?void 0:f.setBy})})]}):"database"===v.kind?(0,l.jsx)(j.dN,{d:v,set:x,setD:g,objectId:C,creating:k}):"cluster"===v.kind?(0,l.jsx)(y,{title:S("of.members"),hint:S("obj.f.members.hint"),children:(()=>{let e=D.filter(e=>{var s;return("server"===e.kind||"docker"===e.kind)&&(null!=(s=e.colony_id)?s:"")===v.colony_id});return e.length?(0,l.jsx)("div",{className:"omembers",children:e.map(e=>{let{icon:s,color:t}=p.Nd[e.kind],a=v.members.indexOf(e.id);return(0,l.jsxs)("label",{className:"omember",children:[(0,l.jsx)("input",{type:"checkbox",checked:a>=0,onChange:()=>{let s;return s=e.id,x("members",v.members.includes(s)?v.members.filter(e=>e!==s):[...v.members,s])}}),(0,l.jsx)(s,{size:15,style:{color:t}}),(0,l.jsx)("span",{className:"nm",children:e.name}),a>=0&&(0,l.jsx)("span",{className:"ord",children:a+1})]},e.id)})}):(0,l.jsx)("p",{className:"muted small res-m0",children:S("obj.f.members.none")})})()}):"server"===v.kind?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(y,{title:S("of.run"),children:[(0,l.jsx)(o.dR,{value:v.cwd,onChange:e=>x("cwd",e),label:S("obj.f.folder"),hint:S("obj.f.folder.hint")}),(0,l.jsx)(o.D0,{label:S("obj.f.start"),hint:S("obj.f.start.hint"),children:q("start",{placeholder:"npm run dev",mono:!0})}),(0,l.jsx)(o.D0,{label:S("obj.f.stop"),hint:S("obj.f.stop.hint"),children:q("stop",{mono:!0})}),(0,l.jsx)(o.D0,{label:S("obj.f.port"),hint:S("obj.f.port.hint"),children:q("port",{placeholder:"3000"})})]}),(0,l.jsx)(y,{title:S("of.env"),children:(0,l.jsx)(o.D0,{label:S("obj.f.env"),hint:S("obj.f.env.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:5,value:v.env,onChange:e=>x("env",e.target.value)})})}),(0,l.jsxs)(y,{title:S("obj.sup.title"),hint:S("obj.sup.note"),children:[(0,l.jsx)(o.D0,{label:S("obj.sup.restart"),hint:S("obj.sup.restart.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("select",{className:"select",value:v.restart,onChange:e=>x("restart",e.target.value),children:[(0,l.jsx)("option",{value:"no",children:S("obj.sup.restart.no")}),(0,l.jsx)("option",{value:"on-failure",children:S("obj.sup.restart.fail")}),(0,l.jsx)("option",{value:"always",children:S("obj.sup.restart.always")})]}),"no"!==v.restart&&(0,l.jsx)("input",{className:"input res-mw130",value:v.maxRestarts,placeholder:S("obj.sup.max"),onChange:e=>x("maxRestarts",e.target.value),title:S("obj.sup.max.hint"),"aria-label":S("obj.sup.max")})]})}),(0,l.jsxs)(o.D0,{label:S("obj.sup.health"),hint:S("obj.sup.health.hint"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("select",{className:"select res-mw170",value:v.healthKind,onChange:e=>x("healthKind",e.target.value),children:[(0,l.jsx)("option",{value:"",children:S("obj.sup.health.none")}),(0,l.jsx)("option",{value:"http",children:"HTTP"}),(0,l.jsx)("option",{value:"tcp",children:S("obj.sup.health.tcp")}),(0,l.jsx)("option",{value:"command",children:S("obj.sup.health.command")})]}),v.healthKind&&(0,l.jsx)("input",{className:"input mono grow",value:v.healthTarget,onChange:e=>x("healthTarget",e.target.value),placeholder:"http"===v.healthKind?"http://127.0.0.1:3000/health":"tcp"===v.healthKind?"3000":"curl -fs localhost:3000","aria-label":S("obj.sup.health")})]}),v.healthKind&&(0,l.jsxs)("div",{className:"row gap-s wrap res-mt8",children:[(0,l.jsx)("input",{className:"input res-mw150",value:v.healthInterval,onChange:e=>x("healthInterval",e.target.value),placeholder:S("obj.sup.interval"),"aria-label":S("obj.sup.interval")}),(0,l.jsx)("input",{className:"input res-mw130",value:v.healthRetries,onChange:e=>x("healthRetries",e.target.value),placeholder:S("obj.sup.retries"),"aria-label":S("obj.sup.retries")}),(0,l.jsx)(o.Tl,{checked:v.healthRestart,onChange:e=>x("healthRestart",e),label:S("obj.sup.healthRestart")})]})]}),(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"8"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.logMax"),hint:S("obj.sup.logMax.hint"),children:q("logMax",{placeholder:"5"})})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(y,{title:S("obj.f.mode"),children:(0,l.jsx)(o.$q,{value:v.mode,onChange:e=>x("mode",e),options:[...k?[{id:"template",label:S("obj.mode.template")}]:[],{id:"container",label:S("obj.mode.container")},{id:"compose",label:S("obj.mode.compose")},{id:"existing",label:S("obj.mode.existing")}]})}),"template"===v.mode&&(0,l.jsx)(y,{title:S("obj.mode.template"),hint:S("tpl.hint"),children:(0,l.jsx)(u,{template:v.template,values:v.tplValues,onPick:e=>g(s=>({...s,template:e.id,tplValues:Object.fromEntries(e.fields.map(e=>[e.key,e.default])),name:s.name.trim()?s.name:e.name})),onValue:(e,s)=>g(t=>({...t,tplValues:{...t.tplValues,[e]:s}}))})}),"container"===v.mode&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(y,{title:S("of.image"),children:[(0,l.jsxs)(o.D0,{label:S("obj.f.image"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(d.b,{value:v.image,onChange:e=>x("image",e),mono:!0,placeholder:S("dk.pickImage"),ariaLabel:S("obj.f.image"),options:(null!=(t=R.images)?t:[]).map(e=>({value:e.ref,hint:"".concat(e.size).concat(e.created?" \xb7 ".concat(e.created):"")}))})}),A]}),z]}),(0,l.jsx)(o.D0,{label:S("obj.f.ports"),hint:S("obj.f.ports.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:2,value:v.ports,onChange:e=>x("ports",e.target.value),placeholder:"8080:80"})}),(0,l.jsxs)(o.D0,{label:S("obj.f.volumes"),hint:S("obj.f.volumes.hint"),children:[(0,l.jsx)("textarea",{className:"textarea mono",rows:2,value:v.volumes,onChange:e=>x("volumes",e.target.value)}),(0,l.jsx)(o.yQ,{bare:!0,value:"",buttonLabel:S("obj.f.volumes.add"),onChange:e=>x("volumes","".concat(v.volumes.trimEnd()).concat(v.volumes.trim()?"\n":"").concat(e,":/data"))})]})]}),(0,l.jsxs)(y,{title:S("of.env"),children:[(0,l.jsx)(o.D0,{label:S("obj.f.env"),hint:S("obj.f.env.hint"),children:(0,l.jsx)("textarea",{className:"textarea mono",rows:4,value:v.env,onChange:e=>x("env",e.target.value)})}),(0,l.jsx)(o.D0,{label:S("obj.f.restart"),children:(0,l.jsx)("select",{className:"select",value:v.dockerRestart,onChange:e=>x("dockerRestart",e.target.value),children:["no","always","unless-stopped","on-failure"].map(e=>(0,l.jsx)("option",{value:e,children:e},e))})}),(0,l.jsx)(o.D0,{label:S("obj.f.command"),children:q("command",{mono:!0})})]}),(0,l.jsx)(y,{title:S("of.limits"),hint:S("obj.dk.limits.hint"),children:(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(o.D0,{label:S("obj.dk.memory"),children:q("memory",{placeholder:"512m"})}),(0,l.jsx)(o.D0,{label:S("obj.dk.cpus"),children:q("cpus",{placeholder:"1.5"})}),(0,l.jsx)(o.D0,{label:S("obj.dk.network"),children:q("network",{placeholder:"bridge"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),children:q("stopTimeout",{placeholder:"10"})}),(0,l.jsx)(o.D0,{label:S("obj.sup.logMax"),children:q("logMax",{placeholder:"10"})})]})})]}),"compose"===v.mode&&(0,l.jsxs)(y,{title:S("obj.mode.compose"),children:[(0,l.jsx)(o.yQ,{mode:"file",exts:["yml","yaml"],value:v.file,onChange:e=>x("file",e),label:S("obj.f.file"),hint:S("obj.f.file.hint"),placeholder:"/home/you/app/docker-compose.yml"}),(0,l.jsx)(N,{file:v.file,project:v.project,services:v.services,onServices:e=>x("services",e),onProject:e=>x("project",e)}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"10"})})]}),"existing"===v.mode&&(0,l.jsxs)(y,{title:S("obj.mode.existing"),children:[(0,l.jsxs)(o.D0,{label:S("obj.f.container"),hint:S("obj.f.container.hint"),children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(d.b,{value:v.container,onChange:e=>x("container",e),mono:!0,placeholder:S("dk.pickContainer"),ariaLabel:S("obj.f.container"),options:(null!=(m=R.containers)?m:[]).map(e=>({value:e.name,hint:"".concat(e.image," \xb7 ").concat(e.state).concat(e.managed?" \xb7 ".concat(S("dk.managed")):"")}))})}),A]}),z]}),(0,l.jsx)(o.D0,{label:S("obj.sup.stopTimeout"),hint:S("obj.sup.stopTimeout.hint"),children:q("stopTimeout",{placeholder:"10"})})]})]})]})}function C(e){let[s,t]=(0,n.useState)(e);return{d:s,setD:t,set:(e,s)=>t(t=>({...t,[e]:s}))}}},13460:(e,s,t)=>{t.d(s,{W:()=>b});var l=t(94799),a=t(34023),n=t(92947),r=t(2432),o=t(58960),i=t(7168),d=t(97356),c=t(70665),m=t(42366),u=t(69654),h=t(84561);let p="$shared";function b(e){var s,t,b;let{value:j,onChange:v,fileEnvs:x=[],fileVars:g={},used:f=[],fileDefined:k=[],setBy:y={}}=e,{t:N}=(0,u.s9)(),w=[p,...[...new Set([...Object.keys(j),...x])].filter(e=>e!==p).sort()],[C,S]=(0,a.useState)(()=>{var e;return null!=(e=w.find(e=>{var s;return e!==p&&Object.keys(null!=(s=j[e])?s:{}).length>0}))?e:w[0]}),[T,D]=(0,a.useState)(""),[R,q]=(0,a.useState)({}),z=null!=(s=j[C])?s:{},A=new Set([...C!==p&&null!=(t=g[p])?t:[],...null!=(b=g[C])?b:[]]),F=f.filter(e=>!(e.name in z)).map(e=>({value:e.name,hint:N("vars.used.count",{count:e.count})})),E=(e,s,t)=>{if(void 0!==t&&t!==e&&t in z)return;let l=Object.entries(z).map(l=>{let[a,n]=l;return a===e?[null!=t?t:a,{...n,...s}]:[a,n]});v({...j,[C]:Object.fromEntries(l)})},M=()=>{let e=T.trim();!/^[\w.$-]{1,60}$/.test(e)||e in j||e===p||(v({...j,[e]:{}}),S(e),D(""))};return(0,l.jsxs)("div",{className:"vars",children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("b",{children:N("ow.tab.vars")}),(0,l.jsxs)(m.B,{size:"sm",label:N("common.help"),title:N("vars.how.title"),children:[(0,l.jsx)("p",{children:N("vars.hint")}),(0,l.jsx)("p",{children:N("vars.how.1")}),(0,l.jsx)("p",{children:N("vars.how.2")}),(0,l.jsx)("p",{children:N("vars.note")})]})]}),(0,l.jsxs)("div",{className:"vars-envs",role:"tablist",children:[w.map(e=>(0,l.jsxs)("button",{type:"button",role:"tab","aria-selected":C===e,className:"vars-env ".concat(C===e?"on":""),onClick:()=>S(e),title:e===p?N("vars.all.hint"):void 0,children:[e===p?N("vars.all"):e,x.includes(e)&&(0,l.jsx)("i",{className:"vars-file",title:N("vars.fromFile"),children:"\xb7"})]},e)),(0,l.jsxs)("span",{className:"vars-add",children:[(0,l.jsx)("input",{className:"input",placeholder:N("vars.newEnv"),value:T,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),M())},"aria-label":N("vars.newEnv")}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:M,disabled:!T.trim(),"aria-label":N("vars.newEnv"),children:(0,l.jsx)(n.A,{size:14})})]})]}),(0,l.jsx)("p",{className:"muted small vars-scope",children:C===p?N("vars.scope.all"):N("vars.scope.env",{env:C})}),(0,l.jsxs)("div",{className:"vars-table",children:[0===Object.keys(z).length&&(0,l.jsx)("p",{className:"muted small",style:{margin:"4px 2px"},children:N("vars.empty")}),Object.entries(z).map((e,s)=>{let[t,a]=e,n="".concat(C,"/").concat(s),c=a.secret&&!R[n];return(0,l.jsxs)("div",{className:"vars-row",children:[(0,l.jsx)(h.b,{value:t,onChange:e=>E(t,{},e.trim()),options:F,mono:!0,placeholder:N("vars.name"),ariaLabel:N("vars.name")}),(0,l.jsx)("input",{className:"input mono",type:c?"password":"text",value:a.value,onChange:e=>E(t,{value:e.target.value}),"aria-label":N("vars.value"),placeholder:a.secret&&a.set&&!a.value?N("vars.saved"):N("vars.value"),autoComplete:"off"}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm ".concat(a.secret?"on":""),"aria-pressed":!!a.secret,onClick:()=>E(t,{secret:!a.secret}),"aria-label":N("vars.secret"),title:N("vars.secret.hint"),children:(0,l.jsx)(r.A,{size:14})}),a.secret?(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>q(e=>({...e,[n]:!e[n]})),"aria-label":N("vars.show"),title:N("vars.show"),children:R[n]?(0,l.jsx)(o.A,{size:14}):(0,l.jsx)(i.A,{size:14})}):(0,l.jsx)("span",{}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>(e=>{let s={...z};delete s[e],v({...j,[C]:s})})(t),"aria-label":N("common.delete"),children:(0,l.jsx)(d.A,{size:14})}),A.has(t)&&(0,l.jsx)("span",{className:"vars-note",children:N("vars.overridden")})]},"".concat(C,":").concat(s))})]}),(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsxs)("button",{type:"button",className:"btn sm",onClick:()=>(e=>{let s=null!=e?e:"name",t=1;for(;s in z;)s="".concat(null!=e?e:"name").concat(++t);v({...j,[C]:{...z,[s]:{value:""}}})})(),children:[(0,l.jsx)(n.A,{size:14}),N("vars.add")]}),C!==p&&!x.includes(C)&&(0,l.jsxs)("button",{type:"button",className:"btn ghost sm",onClick:()=>{let e={...j};delete e[C],v(e),S(p)},children:[(0,l.jsx)(c.A,{size:14}),N("vars.delEnv")]})]})]})}},31606:(e,s,t)=>{t.d(s,{md:()=>E,wl:()=>P});var l=t(94799),a=t(20422),n=t(34023),r=t(41463),o=t.n(r),i=t(66654),d=t(70665),c=t(7991),m=t(66826),u=t(2432),h=t(32335),p=t(59959),b=t(73885),j=t(47405),v=t(83372),x=t(6673),g=t(19431),f=t(33691),k=t(26701),y=t(5372),N=t(3749),w=t(69654),C=t(47890),S=t(86606),T=t(28941),D=t(48538),R=t(42162),q=t(1517),z=t(74988),A=t(75010);let F={mysql:"MySQL / MariaDB",postgresql:"PostgreSQL",sqlite:"SQLite",mssql:"SQL Server"};function E(e){let{status:s,className:t=""}=e;return(0,l.jsx)("i",{className:"odot ".concat(z.Wy[s]," ").concat(t),"aria-hidden":!0})}function M(e){var s,t,l,a;if("server"===e.kind)return e.config.start;if("http"===e.kind)return(0,C._1)(e.config.folder);if("database"===e.kind){let t=e.config;return"sqlite"===t.engine?(0,C._1)(null!=(s=t.file)?s:""):"".concat(t.host||"127.0.0.1").concat(t.port?":".concat(t.port):"").concat(t.database?"/".concat(t.database):"")}if("cluster"===e.kind)return"".concat(e.config.members.length);let n=e.config;return"container"===n.mode?null!=(t=n.image)?t:"":"compose"===n.mode?(0,C._1)(null!=(l=n.file)?l:""):null!=(a=n.container)?a:""}function P(e){let{object:s,target:t,onClose:r,onCreateManager:P}=e,{t:$}=(0,w.s9)(),{agents:_,objects:O,colonies:H}=(0,D.o0)(),I=(0,R.n)(),L="server"===s.kind||"docker"===s.kind&&"compose"!==s.config.mode,U=s.manager_id?_.filter(e=>e.id===s.manager_id):_.filter(e=>{var t,l;return e.skill_ids.includes(q.t)&&(null!=(t=e.colony_id)?t:null)===(null!=(l=s.colony_id)?l:null)}),[K,Q]=(0,n.useState)(!1),{refresh:B}=(0,D.o0)(),W=async e=>{try{await N.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:e}),await B(["objects","agents"]),Q(!1)}catch(e){V(e instanceof Error?e.message:"","err")}},V=(0,S.dj)(),[Z,G]=(0,n.useState)(null),{icon:J,color:X}=z.Nd[s.kind],Y=s.state.status,ee=async e=>{G(e);try{await N.FH.post("/objects/".concat(s.id,"/action"),{action:e})}catch(s){V("".concat($("obj.act.failed",{action:$("obj.act.".concat(e))}),": ").concat(s instanceof Error?s.message:""),"err")}finally{G(null)}},es="running"===Y||"starting"===Y,et=async()=>{G("test");try{let e=await N.FH.post("/object-db/test",{id:s.id,config:s.config});V("".concat($("db.test.ok")," \xb7 ").concat(e.version," \xb7 ").concat(e.ms," ms"))}catch(e){V(e instanceof Error?e.message:"","err")}finally{G(null)}},el="cluster"===s.kind?s.config.members.map(e=>O.find(s=>s.id===e)).filter(e=>!!e):[];return(0,l.jsx)(y.rs,{target:t,pinned:!0,width:380,label:s.name,onClose:r,children:(0,l.jsxs)("div",{className:"col obj-panel res-gap12",children:[(0,l.jsxs)("div",{className:"ap-corner row gap-s",children:[(0,l.jsx)(o(),{className:"btn ghost icon sm",href:"/resources/".concat(s.id,"?tab=config"),"aria-label":$("obj.act.edit"),title:$("obj.act.edit"),children:(0,l.jsx)(i.A,{size:15})}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:r,"aria-label":$("common.close"),title:"".concat($("common.close")," (Esc)"),children:(0,l.jsx)(d.A,{size:16})})]}),(0,l.jsxs)("div",{className:"row gap-l res-pr70",children:[(0,l.jsx)("span",{className:"obj-ico",style:{"--c":X},children:(0,l.jsx)(J,{size:22})}),(0,l.jsxs)("div",{className:"grow res-minw0",children:[(0,l.jsx)("h2",{className:"res-h2",children:s.name}),(0,l.jsxs)("div",{className:"row gap-s wrap res-mt4",children:[(0,l.jsxs)("span",{className:"ostatus ".concat(z.Wy[Y]),children:[(0,l.jsx)(E,{status:Y}),$("obj.status.".concat(Y))]}),(0,l.jsx)("span",{className:"muted small",children:$("obj.kind.".concat(s.kind))})]})]})]}),(s.state.detail||s.state.since)&&(0,l.jsx)("p",{className:"muted small res-m0",children:[(0,z.HS)($,s.state.detail),s.state.since&&es?$("obj.since",{time:(0,C.KN)(s.state.since)}):"",s.state.pid?$("obj.pid",{pid:s.state.pid}):""].filter(Boolean).join(" \xb7 ")}),(0,l.jsxs)(o(),{className:"btn primary",href:"/resources/".concat(s.id),children:[(0,l.jsx)(c.A,{size:15}),$("obj.open")]}),"cluster"!==s.kind&&(0,l.jsx)("div",{className:"mono small obj-cmd",title:M(s),children:M(s)}),"database"===s.kind&&(0,l.jsxs)("div",{className:"row gap-s wrap",children:[(0,l.jsxs)("span",{className:"db-badge",children:[(0,l.jsx)(m.A,{size:12}),F[s.config.engine]]}),!1!==s.config.readOnly?(0,l.jsxs)("span",{className:"db-badge ro",children:[(0,l.jsx)(u.A,{size:12}),$("db.readonly.badge")]}):(0,l.jsxs)("span",{className:"db-badge rw",children:[(0,l.jsx)(h.A,{size:12}),$("db.write.badge")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z,onClick:()=>void et(),children:["test"===Z?(0,l.jsx)(p.A,{size:14,className:"spin"}):(0,l.jsx)(b.A,{size:14}),$("db.test")]})]}),"http"===s.kind||"database"===s.kind?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row gap-s wrap",children:[(0,l.jsxs)("button",{className:"btn primary sm",disabled:!!Z||("cluster"===s.kind?"running"===Y:es),onClick:()=>void ee("start"),children:[(0,l.jsx)(j.A,{size:14}),$("cluster"===s.kind?"obj.act.startAll":"obj.act.start")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z||!es&&"error"!==Y&&!("cluster"===s.kind&&el.some(e=>"running"===e.state.status)),onClick:()=>void ee("stop"),children:[(0,l.jsx)(v.A,{size:14}),$("cluster"===s.kind?"obj.act.stopAll":"obj.act.stop")]}),(0,l.jsxs)("button",{className:"btn sm",disabled:!!Z,onClick:()=>void ee("restart"),children:[(0,l.jsx)(x.A,{size:14}),$("cluster"===s.kind?"obj.act.restartAll":"obj.act.restart")]})]}),"cluster"===s.kind&&(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.members")}),el.length?(0,l.jsx)("div",{className:"col res-gap4",children:el.map((e,s)=>(0,l.jsxs)("div",{className:"row gap-s small",children:[(0,l.jsx)("span",{className:"ord",children:s+1}),(0,l.jsx)(E,{status:e.state.status}),(0,l.jsx)("b",{className:"grow ellipsis",children:e.name}),(0,l.jsx)("span",{className:"muted",children:$("obj.status.".concat(e.state.status))})]},e.id))}):(0,l.jsx)("p",{className:"muted small res-m0",children:$("obj.members.empty")})]}),(0,l.jsxs)("div",{className:"row gap-s wrap",children:[L&&(0,l.jsx)(a.N,{spec:{objectId:s.id},label:"server"===s.kind?$("dock.here"):$("dock.shell")}),(0,l.jsxs)("button",{className:"btn sm",onClick:()=>I.openLogs(s.id,s.name),children:[(0,l.jsx)(g.A,{size:14}),$("dock.logs")]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.logs")}),(0,l.jsx)(A.I,{id:s.id})]})]}),"http"!==s.kind&&"database"!==s.kind&&(0,l.jsxs)("div",{className:"obj-managers",children:[(0,l.jsx)("div",{className:"eyebrow res-mb6",children:$("obj.managers")}),U.length?(0,l.jsx)("div",{className:"row gap-s wrap",children:U.map(e=>(0,l.jsxs)("span",{className:"chip ps-chip",children:[(0,l.jsxs)(o(),{href:"/agents/".concat(e.id),title:"plan"===e.permission?$("obj.managers.readonly"):void 0,children:[e.name,"plan"===e.permission?" \xb7 ".concat($("obj.managers.ro")):""]}),s.manager_id===e.id&&(0,l.jsx)("button",{type:"button",onClick:()=>void W(null),"aria-label":$("obj.managers.remove"),title:$("obj.managers.remove"),children:(0,l.jsx)(d.A,{size:12})})]},e.id))}):(0,l.jsx)("p",{className:"muted small res-m0",children:$("obj.managers.none")}),s.manager_id&&(0,l.jsx)("p",{className:"muted small res-mt6",children:$("obj.managers.only")}),(0,l.jsxs)("div",{className:"row gap-s wrap res-mt8",children:[(0,l.jsxs)("button",{className:"btn sm",onClick:P,children:[(0,l.jsx)(f.A,{size:14}),$("obj.managers.create")]}),(0,l.jsxs)("button",{className:"btn sm","aria-pressed":K,onClick:()=>Q(e=>!e),children:[(0,l.jsx)(k.A,{size:14}),$("obj.managers.add")]})]}),K&&(0,l.jsx)("div",{className:"res-mt8",children:(0,l.jsx)(T.c,{inline:!0,autoFocus:!0,options:_.filter(e=>e.id!==s.manager_id).map(e=>{var s,t;return{id:e.id,label:e.name,hint:null!=(t=null==(s=H.find(s=>s.id===e.colony_id))?void 0:s.name)?t:$("common.noColony")}}),value:[],onChange:e=>e[0]&&void W(e[0]),placeholder:$("obj.manager.placeholder"),empty:$("obj.manager.empty"),ariaLabel:$("obj.managers.add")})})]})]})})}},42366:(e,s,t)=>{t.d(s,{B:()=>o});var l=t(94799),a=t(34023),n=t(34265),r=t(21018);function o(e){let{label:s,title:t,children:o,size:i="md",align:d="start"}=e,[c,m]=(0,a.useState)(!1),u=(0,a.useRef)(null),h=(0,a.useRef)(null),p=(0,a.useId)();return(0,r.s)(c,u,()=>m(!1),()=>{var e;return null==(e=h.current)?void 0:e.focus()}),(0,l.jsxs)("span",{className:"help ".concat("sm"===i?"sm":""," ").concat("end"===d?"end":""),ref:u,children:[(0,l.jsx)("button",{ref:h,type:"button",className:"help-btn","aria-label":s,title:s,"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":c?p:void 0,onClick:()=>m(e=>!e),children:(0,l.jsx)(n.A,{size:"sm"===i?15:18})}),c&&(0,l.jsxs)("div",{id:p,role:"dialog","aria-label":t,className:"help-pop",children:[(0,l.jsx)("div",{className:"eyebrow",children:t}),(0,l.jsx)("div",{className:"muted small help-body",children:o})]})]})}},67056:(e,s,t)=>{t.d(s,{dN:()=>z,I5:()=>q});var l=t(94799),a=t(66843),n=t(34023),r=t(59959),o=t(73885),i=t(3414),d=t(94726),c=t(66826),m=t(55712),u=t(79141),h=t(3749),p=t(86606),b=t(69654);let j=null;function v(){let[e,s]=(0,n.useState)(null);return(0,n.useEffect)(()=>{let e=!0;return null!=j||(j=h.FH.get("/object-db/props").catch(e=>{throw j=null,e})),j.then(t=>{e&&s(t)}).catch(()=>void 0),()=>{e=!1}},[]),e}var x=t(9217),g=t(70665),f=t(92947);let k=["session","network","ssl","advanced"];function y(e){let{def:s,value:t,onChange:a}=e;return"boolean"===s.type?(0,l.jsxs)("select",{className:"select",value:t,onChange:e=>a(e.target.value),"aria-label":s.name,children:[(0,l.jsx)("option",{value:"true",children:"true"}),(0,l.jsx)("option",{value:"false",children:"false"})]}):"choice"===s.type?(0,l.jsxs)("select",{className:"select",value:t,onChange:e=>a(e.target.value),"aria-label":s.name,children:[!t&&(0,l.jsx)("option",{value:""}),s.choices.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]}):(0,l.jsx)("input",{className:"input mono",type:"number"===s.type?"number":"text",min:s.min,max:s.max,value:t,placeholder:s.placeholder,autoComplete:"off",onChange:e=>a(e.target.value),"aria-label":s.name})}function N(e){let{engine:s,value:t,onChange:a,groups:n=k,exclude:r=[],quiet:o=!1}=e,{t:i,locale:d}=(0,b.s9)(),c=v();if(!c)return(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:i("dp.loading")});let m=c[s].filter(e=>n.includes(e.group)&&!r.includes(e.name)),u=m.filter(e=>e.name in t),h=m.filter(e=>!(e.name in t));return(0,l.jsxs)("div",{className:"dprops",children:[0===u.length&&!o&&(0,l.jsx)("p",{className:"muted small",style:{margin:0},children:i("dp.none")}),u.map(e=>(0,l.jsxs)("div",{className:"dprop",children:[(0,l.jsxs)("div",{className:"dprop-row",children:[(0,l.jsx)("code",{className:"dprop-name",children:e.name}),(0,l.jsx)("div",{className:"dprop-val",children:(0,l.jsx)(y,{def:e,value:t[e.name],onChange:s=>a({...t,[e.name]:s})})}),(0,l.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:()=>{let{[e.name]:s,...l}=t;a(l)},"aria-label":i("dp.remove",{name:e.name}),title:i("dp.remove",{name:e.name}),children:(0,l.jsx)(g.A,{size:14})})]}),(0,l.jsx)("p",{className:"muted small dprop-desc",children:"es"===d?e.es:e.desc})]},e.name)),h.length>0&&(0,l.jsxs)("div",{className:"dprop-add",children:[(0,l.jsx)(f.A,{size:14,className:"muted"}),(0,l.jsxs)("select",{className:"select",value:"","aria-label":i("dp.add"),onChange:e=>{let s=m.find(s=>s.name===e.target.value);s&&a({...t,[s.name]:"boolean"===s.type?"true":"choice"===s.type?s.choices[0]:""})},children:[(0,l.jsx)("option",{value:"",children:i("dp.add")}),k.filter(e=>h.some(s=>s.group===e)).map(e=>(0,l.jsx)("optgroup",{label:i("dp.group.".concat(e)),children:h.filter(s=>s.group===e).map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.name))},e))]})]})]})}let w={postgres:"postgresql",postgresql:"postgresql",mysql:"mysql",mariadb:"mysql",mssql:"mssql",sqlserver:"mssql",sqlite:"sqlite",file:"sqlite"};function C(e){let s,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=e.trim(),a=/^(?:jdbc:)?([a-z][a-z0-9+.-]*):/i.exec(l),n=a?w[a[1].toLowerCase()]:void 0;if(!n)return null;let r={engine:n,host:"",port:"",user:"",password:"",database:"",file:"",ssl:!1,trust:!1,props:{}};if("sqlite"===n){let e=l.replace(/^(?:jdbc:)?(?:sqlite|file):(?:\/\/)?/i,"").split("?")[0],s=decodeURIComponent(e.startsWith("/")?e:"/".concat(e));return s.length>1?{...r,file:s}:null}try{s=new URL(l.replace(/^jdbc:/i,"").replace(/^[a-z][a-z0-9+.-]*:/i,"http:"))}catch(e){return null}r.host=s.hostname,r.port=s.port,r.user=decodeURIComponent(s.username),r.password=decodeURIComponent(s.password),r.database=decodeURIComponent(s.pathname.replace(/^\//,""));let o=new Map(t.map(e=>[e.name.toLowerCase(),e]));return s.searchParams.forEach((e,s)=>{let t=s.toLowerCase(),l=e.toLowerCase();if("sslmode"===t||"ssl"===t||"encrypt"===t||"tls"===t)r.ssl=!["disable","disabled","false","no","0","allow","prefer"].includes(l)&&""!==l,r.trust=r.ssl&&["require","required","preferred"].includes(l);else if("trustservercertificate"===t)r.trust="true"===l;else{let s=o.get(t);s&&!s.name.startsWith("ssl.")&&(r.props[s.name]=e)}}),r}let S={mysql:{label:"MySQL / MariaDB",port:3306,color:"#00758f",sample:"mysql://user:password@localhost:3306/app"},postgresql:{label:"PostgreSQL",port:5432,color:"#4a7fb5",sample:"postgresql://user:password@localhost:5432/app?sslmode=require"},sqlite:{label:"SQLite",port:0,color:"#0f80cc",sample:"sqlite:///home/you/app/data.db"},mssql:{label:"SQL Server",port:1433,color:"#cc2927",sample:"mssql://sa:password@localhost:1433/master"}},T=Object.keys(S),D=["ssl.ca","ssl.cert","ssl.key"],R={"ssl.ca":"db.ssl.ca","ssl.cert":"db.ssl.cert","ssl.key":"db.ssl.key"};function q(e){var s;let t="sqlite"===e.engine?null==(s=e.dbFile.split("/").pop())?void 0:s.replace(/\.[^.]+$/,""):e.dbName.trim()||e.dbHost.trim();return t?"".concat(t," \xb7 ").concat(S[e.engine].label.split(" ")[0]):""}function z(e){let{d:s,set:t,setD:j,objectId:g,creating:f=!1}=e,{t:k,locale:y}=(0,b.s9)(),w=v(),[q,z]=(0,n.useState)({state:"idle"}),[A,F]=(0,n.useState)(""),[E,M]=(0,n.useState)(""),P="sqlite"===s.engine,$=function(e){var a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,l.jsx)("input",{className:"input ".concat(n.mono?"mono":""),type:n.type,value:s[e],placeholder:n.placeholder,autoComplete:null!=(a=n.auto)?a:"off",onChange:s=>t(e,s.target.value)})},_=e=>{e!==s.engine&&(j(s=>({...s,engine:e,dbProps:{},dbSsl:!1,dbTrust:!1})),z({state:"idle"}))},O=async()=>{z({state:"busy"});try{let e=await h.FH.post("/object-db/test",{id:g,config:(0,x.Mr)(s)});z({state:"ok",text:"".concat(e.version," \xb7 ").concat(e.ms," ms")})}catch(e){z({state:"err",text:e instanceof Error?e.message:""})}},H=()=>{var e,t;let l=C(A,null==w?void 0:w[null!=(t=null==(e=C(A))?void 0:e.engine)?t:s.engine]);if(!l)return void M(k("db.url.bad"));M(""),z({state:"idle"}),j(e=>({...e,engine:l.engine,dbHost:l.host,dbPort:l.port,dbUser:l.user,dbPassword:l.password,dbName:l.database,dbFile:l.file,dbSsl:l.ssl,dbTrust:l.trust,dbProps:l.props})),F("")},I=(0,l.jsxs)(l.Fragment,{children:[P?(0,l.jsx)(p.yQ,{mode:"file",exts:["db","sqlite","sqlite3","db3"],value:s.dbFile,onChange:e=>t("dbFile",e),label:k("db.file"),hint:k("db.file.hint"),placeholder:"/home/you/app/data.db"}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(p.D0,{label:k("db.host"),children:$("dbHost",{placeholder:"127.0.0.1",mono:!0})}),(0,l.jsx)(p.D0,{label:k("db.port"),children:$("dbPort",{placeholder:String(S[s.engine].port)})}),(0,l.jsx)(p.D0,{label:k("db.user"),children:$("dbUser",{mono:!0})}),(0,l.jsx)(p.D0,{label:k("db.password"),hint:s.dbPasswordSet&&!s.dbPassword?k("db.password.saved"):void 0,children:(0,l.jsx)(a.y,{value:s.dbPassword,autoComplete:"new-password",placeholder:s.dbPasswordSet?"••••••••":"",onChange:e=>t("dbPassword",e.target.value)})})]}),(0,l.jsx)(p.D0,{label:k("db.database"),hint:k("db.database.hint"),children:$("dbName",{mono:!0})})]}),(0,l.jsxs)("div",{className:"row gap-s wrap db-test",children:[(0,l.jsxs)("button",{type:"button",className:"btn sm",onClick:()=>void O(),disabled:"busy"===q.state||!!P&&!s.dbFile.trim(),children:["busy"===q.state?(0,l.jsx)(r.A,{size:14,className:"spin"}):(0,l.jsx)(o.A,{size:14}),k("db.test")]}),"ok"===q.state&&(0,l.jsxs)("span",{className:"db-ok small",children:[(0,l.jsx)(i.A,{size:14}),k("db.test.ok")," \xb7 ",q.text]}),"err"===q.state&&(0,l.jsxs)("span",{className:"db-bad small",children:[(0,l.jsx)(d.A,{size:14}),q.text]})]})]}),L=P?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbSsl,onChange:e=>t("dbSsl",e),label:k("db.ssl")}),s.dbSsl&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbTrust,onChange:e=>t("dbTrust",e),label:k("db.trust"),hint:s.dbTrust?k("db.trust.on"):k("db.trust.off")}),D.filter(e=>null==w?void 0:w[s.engine].some(s=>s.name===e)).map(e=>{var a;let n=w[s.engine].find(s=>s.name===e);return(0,l.jsx)(p.yQ,{mode:"file",exts:["pem","crt","cer","key"],value:null!=(a=s.dbProps[e])?a:"",onChange:l=>t("dbProps",{...s.dbProps,[e]:l}),label:k(R[e]),hint:"es"===y?n.es:n.desc,placeholder:n.placeholder},e)}),(0,l.jsx)(N,{engine:s.engine,value:s.dbProps,onChange:e=>t("dbProps",e),groups:["ssl"],exclude:[...D],quiet:!0})]})]}),U=(0,l.jsx)(N,{engine:s.engine,value:s.dbProps,onChange:e=>t("dbProps",e),groups:["session","network","advanced"]}),K=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Tl,{checked:s.dbReadOnly,onChange:e=>t("dbReadOnly",e),label:k("db.readonly"),hint:s.dbReadOnly?k("db.readonly.on"):k("db.readonly.off")}),(0,l.jsxs)("div",{className:"of-grid2",children:[(0,l.jsx)(p.D0,{label:k("db.timeout"),hint:k("db.timeout.hint"),children:$("dbTimeout",{placeholder:"30"})}),(0,l.jsx)(p.D0,{label:k("db.maxRows"),hint:k("db.maxRows.hint"),children:$("dbMaxRows",{placeholder:"1000"})})]})]}),Q=(0,l.jsx)("div",{className:"dbengines",role:"group","aria-label":k("db.engine"),children:T.map(e=>(0,l.jsxs)("button",{type:"button",className:"dbengine","aria-pressed":s.engine===e,style:{"--c":S[e].color},onClick:()=>_(e),children:[(0,l.jsx)(c.A,{size:18}),(0,l.jsx)("b",{children:S[e].label}),(0,l.jsx)("small",{children:"sqlite"===e?k("db.engine.file"):k("db.engine.port",{port:S[e].port})})]},e))});return f?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.Zp,{title:k("db.engine"),hint:k("db.engine.hint"),children:Q}),(0,l.jsxs)(x.Zp,{title:k("db.conn"),hint:k("db.conn.hint"),children:[(0,l.jsx)(p.D0,{label:k("db.url"),error:E,hint:E?void 0:k("db.url.hint"),children:(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("input",{className:"input mono grow",value:A,placeholder:S[s.engine].sample,autoComplete:"off",spellCheck:!1,onChange:e=>{F(e.target.value),M("")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),H())}}),(0,l.jsxs)("button",{type:"button",className:"btn sm",disabled:!A.trim(),onClick:H,children:[(0,l.jsx)(m.A,{size:14}),k("db.url.use")]})]})}),I]}),(0,l.jsx)(x.Zp,{title:k("db.safety"),hint:k("db.safety.hint"),children:K}),(0,l.jsxs)("details",{className:"of-adv",children:[(0,l.jsxs)("summary",{children:[(0,l.jsx)(u.A,{size:15}),k("db.advanced"),(0,l.jsx)("span",{className:"muted small",children:k("db.advanced.hint")})]}),!P&&(0,l.jsx)(x.Zp,{title:k("db.sslTitle"),hint:k("db.sslTitle.hint"),children:L}),(0,l.jsx)(x.Zp,{title:k("dp.title"),hint:k("dp.hint"),children:U})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(x.Zp,{title:k("db.conn"),hint:k("db.conn.hint"),children:[(0,l.jsx)(p.D0,{label:k("db.engine"),children:(0,l.jsx)(p.$q,{value:s.engine,onChange:_,options:T.map(e=>({id:e,label:S[e].label}))})}),I]}),!P&&(0,l.jsx)(x.Zp,{title:k("db.sslTitle"),hint:k("db.sslTitle.hint"),children:L}),(0,l.jsx)(x.Zp,{title:k("dp.title"),hint:k("dp.hint"),children:U}),(0,l.jsx)(x.Zp,{title:k("db.safety"),hint:k("db.safety.hint"),children:K})]})}},74988:(e,s,t)=>{t.d(s,{HS:()=>b,M6:()=>m,Mn:()=>h,Nd:()=>d,Wy:()=>c,y$:()=>u});var l=t(29416),a=t(34978),n=t(84616),r=t(66826),o=t(73784),i=t(47890);let d={server:{color:"#0f8f9e",icon:l.A},docker:{color:"#2496ed",icon:a.A},http:{color:"#7a4de0",icon:n.A},database:{color:"#d9822b",icon:r.A},cluster:{color:i.Ng,icon:o.A}},c={running:"ok",ready:"ok",starting:"warn",error:"err",stopped:"off",unknown:"off"},m=e=>Object.entries(null!=e?e:{}).map(e=>{let[s,t]=e;return"".concat(s,"=").concat(t)}).join("\n");function u(e){let s={};for(let t of e.split("\n")){let e=t.trim();if(!e||e.startsWith("#"))continue;let l=e.indexOf("=");if(l<=0)throw Error('"'.concat(e,'" is not NAME=value'));s[e.slice(0,l).trim()]=e.slice(l+1)}return s}let h=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),p=[[/^(\d+) requests in (\d+) files$/,"d.requests"],[/^(\d+)\/(\d+) running$/,"d.running"],[/^no members$/,"d.noMembers"],[/^only (\d+)\/(\d+) running · stopped: (.+)$/,"d.onlySome"],[/^(.+) failed · (\d+)\/(\d+) running$/,"d.failed"],[/^waiting for port (\d+)$/,"d.waitPort"],[/^running, but nothing listens on port (\d+)$/,"d.noPort"],[/^exited with code (\d+)$/,"d.exited"],[/^ended by (\w+)$/,"d.signal"],[/^restarted \((\d+)\/(\d+)\)$/,"d.restarted"],[/^was unhealthy: restarting \((\d+)\/(\d+)\)$/,"d.unhealthyRestart"],[/^health check pending$/,"d.healthPending"],[/^restarting$/,"d.restarting"],[/^container not found$/,"d.noContainer"],[/^the compose file is missing$/,"d.noCompose"],[/^(\d+) of (\d+) running$/,"d.running2"],[/^(\d+) services?$/,"d.services"],[/^a service exited with an error$/,"d.serviceFailed"],[/^checking…$/,"d.checking"],[/^unhealthy$/,"d.unhealthy"]];function b(e,s){return s?s.split(" \xb7 ").map(s=>{for(let[t,l]of p){let a=t.exec(s);if(a)return e(l,Object.fromEntries(a.slice(1).map((e,s)=>["a".concat(s+1),e])))}let t=/^(.*)restarting in (\d+) s \((\d+)\/(\d+)\)$/.exec(s);if(t)return e("d.restartIn",{a1:t[2],a2:t[3],a3:t[4]});let l=/^gave up after (\d+) restarts$/.exec(s);if(l)return e("d.gaveUp",{a1:l[1]});let a=/^unhealthy: (.+)$/.exec(s);return a?"".concat(e("d.unhealthy"),": ").concat(a[1]):s}).join(" \xb7 "):""}},75010:(e,s,t)=>{t.d(s,{I:()=>c});var l=t(94799),a=t(34023),n=t(98392),r=t(64883),o=t(3749),i=t(69654);let d=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function c(e){let{id:s,height:t=220}=e,{t:c}=(0,i.s9)(),[m,u]=(0,a.useState)(null),h=(0,a.useRef)(""),p=(0,a.useRef)(null),b=(0,a.useRef)(!0),[j,v]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,t;u(null),h.current="",b.current=!0,v(!1);let l=async()=>{try{let t=h.current?"after=".concat(encodeURIComponent(h.current)):"tail=300",l=await o.FH.get("/objects/".concat(s,"/logs?").concat(t));if(e)return;h.current=l.cursor||h.current;let a=l.text.replace(d,"");u(e=>{let s=l.reset?"":null!=e?e:"";if(!a)return null!=e?e:"";let t=!s||s.endsWith("\n")||a.startsWith("\n")?s+a:"".concat(s,"\n").concat(a);return t.length>2e5?t.slice(t.length-2e5):t})}catch(e){}e||(t=setTimeout(l,1200))};return l(),()=>{e=!0,clearTimeout(t)}},[s]),(0,a.useEffect)(()=>{let e=p.current;e&&b.current&&(e.scrollTop=e.scrollHeight)},[m]),(0,l.jsxs)("div",{className:"logv",children:[(0,l.jsx)("pre",{ref:p,className:"logv-body mono",style:{height:t},onScroll:()=>{let e=p.current;if(!e)return;let s=e.scrollHeight-e.scrollTop-e.clientHeight<24;b.current=s,v(!s)},tabIndex:0,children:null===m?c("git.loading"):m.trim()?m:c("obj.logs.empty")}),(0,l.jsxs)("div",{className:"logv-tools",children:[j&&(0,l.jsxs)("button",{className:"btn sm",onClick:()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight,b.current=!0,v(!1))},children:[(0,l.jsx)(n.A,{size:14}),c("obj.logs.bottom")]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>u(""),"aria-label":c("obj.logs.clear"),title:c("obj.logs.clear"),children:(0,l.jsx)(r.A,{size:14})})]})]})}},84561:(e,s,t)=>{t.d(s,{b:()=>o});var l=t(94799),a=t(34023),n=t(21018),r=t(86606);function o(e){let{value:s,onChange:t,options:o,placeholder:i,mono:d=!1,ariaLabel:c,onOpen:m,empty:u}=e,[h,p]=(0,a.useState)(!1),[b,j]=(0,a.useState)(0),v=(0,a.useRef)(null);(0,n.s)(h,v,()=>p(!1));let x=(0,a.useMemo)(()=>{let e=s.trim().toLowerCase();return(e?o.filter(s=>{var t,l;return"".concat(s.value," ").concat(null!=(t=s.label)?t:""," ").concat(null!=(l=s.hint)?l:"").toLowerCase().includes(e)}):o).slice(0,60)},[o,s]);(0,a.useEffect)(()=>{j(0)},[s,h]);let g=(0,r.Bp)(h&&(x.length>0||!!u),b,x.length),f=e=>{t(e.value),p(!1)};return(0,l.jsxs)("div",{className:"sg",ref:v,children:[(0,l.jsx)("input",{className:"input ".concat(d?"mono":""),value:s,placeholder:i,"aria-label":c,autoComplete:"off",spellCheck:!1,...g.input,onFocus:()=>{h||(p(!0),null==m||m())},onClick:()=>p(!0),onChange:e=>{t(e.target.value),p(!0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),p(!0),j(e=>Math.min(x.length-1,e+1))):"ArrowUp"===e.key?(e.preventDefault(),j(e=>Math.max(0,e-1))):"Enter"===e.key&&h&&x[b]?(e.preventDefault(),f(x[b])):"Escape"===e.key&&h&&(e.stopPropagation(),p(!1))}}),h&&(x.length>0||u)&&(0,l.jsxs)("ul",{className:"sg-list",...g.listProps,children:[0===x.length&&(0,l.jsx)("li",{className:"sg-empty",role:"presentation",children:u}),x.map((e,s)=>{var t;return(0,l.jsx)("li",{...g.optionProps(s),children:(0,l.jsxs)("button",{type:"button",tabIndex:-1,className:"sg-opt ".concat(s===b?"hi":""),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>j(s),onClick:()=>f(e),children:[(0,l.jsx)("span",{className:"nm ".concat(d?"mono":""),children:null!=(t=e.label)?t:e.value}),e.hint&&(0,l.jsx)("span",{className:"hint",children:e.hint})]})},e.value)})]})]})}},95587:(e,s,t)=>{t.d(s,{X:()=>u});var l=t(94799),a=t(34023),n=t(3749),r=t(69654),o=t(48538),i=t(86606),d=t(9217),c=t(52974),m=t(67056);function u(e){let{presetColonyId:s,presetKind:t,onClose:u,onSaved:h}=e,{t:p}=(0,r.s9)(),{refresh:b}=(0,o.o0)(),j=(0,i.dj)(),{d:v,set:x,setD:g}=(0,d.Te)(()=>(0,d.QJ)(void 0,s,t)),[f,k]=(0,a.useState)(""),[y,N]=(0,a.useState)(!1),w=async()=>{let e=v.name.trim()||("database"===v.kind?(0,m.I5)(v):"");if(!e)return void k(p("obj.err.name"));N(!0),k("");try{if("docker"===v.kind&&"template"===v.mode&&!v.template){k(p("tpl.pick")),N(!1);return}let s="docker"===v.kind&&"template"===v.mode?await n.FH.post("/objects/from-template",{name:e,colony_id:v.colony_id||null,template:v.template,values:v.tplValues}):await n.FH.post("/objects",{name:e,colony_id:v.colony_id||null,kind:v.kind,config:(0,d.qP)(v)});v.manager&&c.G.includes(v.kind)&&await n.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:v.manager}).catch(e=>j(e instanceof Error?e.message:"","err")),await b(["objects","agents"]),j(p("obj.created")),null==h||h(s.id),u()}catch(e){k(e instanceof Error?e.message:p("edit.saveFailed")),N(!1)}};return(0,l.jsx)(i._s,{title:p("obj.newTitle"),subtitle:p("obj.subtitle"),onClose:u,footer:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{className:"btn ghost",onClick:u,children:p("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",disabled:y,onClick:()=>void w(),children:p("obj.create")})]}),children:(0,l.jsx)(d.Bh,{d:v,set:x,setD:g,showKind:!0,error:f})})}}}]);