hive-am 1.2.2 → 1.3.0

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 (110) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/package.json +1 -1
  3. package/server/dist/context.js +62 -0
  4. package/server/dist/db/migrations.js +7 -0
  5. package/server/dist/db.js +4 -4
  6. package/server/dist/history/claude.js +8 -2
  7. package/server/dist/http/routes/agents.js +1 -1
  8. package/server/dist/http/validate.js +2 -0
  9. package/server/dist/instructions.js +4 -0
  10. package/server/dist/models.js +2 -0
  11. package/server/dist/providers/claude.js +13 -1
  12. package/server/dist/providers/opencode-server.js +59 -0
  13. package/server/dist/providers/opencode.js +4 -1
  14. package/server/dist/stats.js +15 -3
  15. package/web/.next/BUILD_ID +1 -1
  16. package/web/.next/app-build-manifest.json +70 -70
  17. package/web/.next/app-path-routes-manifest.json +7 -7
  18. package/web/.next/build-manifest.json +2 -2
  19. package/web/.next/prerender-manifest.json +49 -49
  20. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/web/.next/server/app/_not-found.html +1 -1
  22. package/web/.next/server/app/_not-found.rsc +3 -3
  23. package/web/.next/server/app/agents/[id]/page.js +3 -3
  24. package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  25. package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  26. package/web/.next/server/app/agents/page.js +1 -1
  27. package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  28. package/web/.next/server/app/agents.html +1 -1
  29. package/web/.next/server/app/agents.rsc +4 -4
  30. package/web/.next/server/app/connections/page.js +1 -1
  31. package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  32. package/web/.next/server/app/connections.html +1 -1
  33. package/web/.next/server/app/connections.rsc +4 -4
  34. package/web/.next/server/app/index.html +1 -1
  35. package/web/.next/server/app/index.rsc +4 -4
  36. package/web/.next/server/app/page.js +1 -1
  37. package/web/.next/server/app/page.js.nft.json +1 -1
  38. package/web/.next/server/app/page_client-reference-manifest.js +1 -1
  39. package/web/.next/server/app/relations/page.js +1 -1
  40. package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
  41. package/web/.next/server/app/relations.html +1 -1
  42. package/web/.next/server/app/relations.rsc +4 -4
  43. package/web/.next/server/app/resources/[id]/page.js +1 -1
  44. package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
  45. package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
  46. package/web/.next/server/app/resources/page.js +1 -1
  47. package/web/.next/server/app/resources/page.js.nft.json +1 -1
  48. package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
  49. package/web/.next/server/app/resources.html +1 -1
  50. package/web/.next/server/app/resources.rsc +4 -4
  51. package/web/.next/server/app/schedules/page.js +1 -1
  52. package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
  53. package/web/.next/server/app/schedules.html +1 -1
  54. package/web/.next/server/app/schedules.rsc +4 -4
  55. package/web/.next/server/app/sessions/page.js +1 -1
  56. package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  57. package/web/.next/server/app/sessions.html +1 -1
  58. package/web/.next/server/app/sessions.rsc +4 -4
  59. package/web/.next/server/app/skills/page.js +1 -1
  60. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  61. package/web/.next/server/app/skills.html +1 -1
  62. package/web/.next/server/app/skills.rsc +4 -4
  63. package/web/.next/server/app/types/page.js +1 -1
  64. package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
  65. package/web/.next/server/app/types.html +1 -1
  66. package/web/.next/server/app/types.rsc +4 -4
  67. package/web/.next/server/app-paths-manifest.json +7 -7
  68. package/web/.next/server/chunks/143.js +1 -1
  69. package/web/.next/server/chunks/274.js +1 -1
  70. package/web/.next/server/chunks/306.js +1 -1
  71. package/web/.next/server/chunks/451.js +1 -0
  72. package/web/.next/server/chunks/505.js +1 -1
  73. package/web/.next/server/chunks/612.js +1 -1
  74. package/web/.next/server/chunks/716.js +2 -2
  75. package/web/.next/server/pages/404.html +1 -1
  76. package/web/.next/server/pages/500.html +1 -1
  77. package/web/.next/server/server-reference-manifest.json +1 -1
  78. package/web/.next/static/chunks/281-d8a0dcfaa6d064e4.js +1 -0
  79. package/web/.next/static/chunks/{291-efae53ea5f7ee92d.js → 291-23f314877fa39054.js} +1 -1
  80. package/web/.next/static/chunks/304-681348099f874a30.js +1 -0
  81. package/web/.next/static/chunks/350-0fe82e622e7a670f.js +1 -0
  82. package/web/.next/static/chunks/{491-6b4e6201f5110dff.js → 491-28f093772bd460ac.js} +1 -1
  83. package/web/.next/static/chunks/517-373a80c8ba432bdc.js +1 -0
  84. package/web/.next/static/chunks/654-92a63b3c4b412666.js +1 -0
  85. package/web/.next/static/chunks/705-780e48e55b0346bd.js +1 -0
  86. package/web/.next/static/chunks/{844-fe55292e0701f436.js → 844-519177e6198ca84f.js} +1 -1
  87. package/web/.next/static/chunks/app/agents/[id]/page-c005161cec5527d8.js +1 -0
  88. package/web/.next/static/chunks/app/agents/{page-f4c4c80f955f3967.js → page-9bb8cba69776c719.js} +1 -1
  89. package/web/.next/static/chunks/app/connections/{page-0936beaf02d863c6.js → page-eb11cfb1ffeab3ca.js} +1 -1
  90. package/web/.next/static/chunks/app/{layout-99620746d028dda8.js → layout-49b46c9b5aa512a8.js} +1 -1
  91. package/web/.next/static/chunks/app/{page-a7f292117b7d76bf.js → page-da042d146caeeab6.js} +1 -1
  92. package/web/.next/static/chunks/app/relations/{page-fba25393c8688714.js → page-a44fd515a3b0525e.js} +1 -1
  93. package/web/.next/static/chunks/app/resources/[id]/{page-d110d89bb8b5fca7.js → page-bf05836f97248ca7.js} +1 -1
  94. package/web/.next/static/chunks/app/resources/{page-bbd0b450d3f3131d.js → page-800f774e5cacf4c9.js} +1 -1
  95. package/web/.next/static/chunks/app/schedules/{page-a1124397fc760413.js → page-96976fff4ee23538.js} +1 -1
  96. package/web/.next/static/chunks/app/sessions/{page-0e322811b0cde724.js → page-a7534ebd90e982d6.js} +1 -1
  97. package/web/.next/static/chunks/app/skills/{page-22ea0ef89d9f7a13.js → page-bc1acd0663f36129.js} +1 -1
  98. package/web/.next/static/chunks/app/types/{page-18c4e1db2724d41d.js → page-ebd37e220f77c1f3.js} +1 -1
  99. package/web/.next/static/css/{b7a03c62468f4263.css → d42799b7e6a0e8a2.css} +1 -1
  100. package/web/.next/trace +29 -29
  101. package/web/.next/server/chunks/555.js +0 -1
  102. package/web/.next/static/chunks/176-aeaf907a6ea5627d.js +0 -1
  103. package/web/.next/static/chunks/350-56599dc3bf06066d.js +0 -1
  104. package/web/.next/static/chunks/486-13e08542f3a1cbac.js +0 -1
  105. package/web/.next/static/chunks/517-ccaf8cc5c733cbd8.js +0 -1
  106. package/web/.next/static/chunks/705-c7e75806f77b880c.js +0 -1
  107. package/web/.next/static/chunks/839-4aefe6e71be6e1ef.js +0 -1
  108. package/web/.next/static/chunks/app/agents/[id]/page-3faf40800981a736.js +0 -1
  109. /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_buildManifest.js +0 -0
  110. /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[517],{1517:(e,l,n)=>{n.d(l,{b:()=>h,t:()=>p});var s=n(94799),r=n(34023),t=n(43624),i=n(10804),o=n(5300),a=n(48538),c=n(73506),d=n(3749),m=n(47890),u=n(69654);let p="default-objects";function h(e){var l,n;let{onClose:h,onCreated:f,presetTypeId:v,presetColonyId:b,presetObjectId:g,manager:j=!1}=e,{t:x}=(0,u.s9)(),{types:k,agents:y,refresh:w,colonies:_}=(0,a.q5)(),N=(0,i.dj)(),C=(0,t.useRouter)(),[A,D]=(0,r.useState)(v||j?"form":"type"),[S,E]=(0,r.useState)(()=>{let e={...(0,o.WU)(k.find(e=>e.id===v)),colony_id:null!=b?b:null,object_ids:g?[g]:[]};return j?{...e,description:x("obj.manager.description"),permission:"acceptEdits",skill_ids:[...new Set([...e.skill_ids,p])],skill_loads:{...e.skill_loads,[p]:"always"}}:e}),[q,z]=(0,r.useState)(()=>JSON.stringify(S)),F=e=>{E(e),z(JSON.stringify(e)),D("form")},L=(0,r.useRef)(!1),M=JSON.stringify(S)!==q;(0,c.h)(M&&!L.current);let[O,T]=(0,r.useState)(!1),[P,R]=(0,r.useState)(!1),[K,U]=(0,r.useState)(!1),H=(0,o.tf)(S,y,void 0,_),B=async()=>{if(U(!0),!Object.keys(H).length){R(!0);try{let{object_ids:e,...l}=S,n=await d.FH.post("/agents",l);e.length&&await d.FH.put("/agents/".concat(n.id,"/resources"),{object_ids:e}).catch(e=>N(e instanceof Error?e.message:"","err")),await w(["agents","colonies","objects"]),N(x("newAgent.created",{name:n.name})),L.current=!0,null==f||f(n.id),h(),C.push("/agents/".concat(n.id))}catch(e){N(e instanceof Error?e.message:x("newAgent.failed"),"err"),R(!1)}}};return"type"===A?(0,s.jsx)(i._s,{title:x("newAgent.title"),subtitle:x("newAgent.pickType"),onClose:h,children:(0,s.jsxs)("div",{className:"col gap-m",children:[k.map(e=>(0,s.jsxs)("button",{className:"card card-pad row gap-l cx-typecard",onClick:()=>{F({...(0,o.WU)(e),colony_id:null!=b?b:null,object_ids:g?[g]:[]})},children:[(0,s.jsx)(i._h,{color:m.xq[e.provider].color,queen:"orchestrator"===e.role,label:e.name.slice(0,2).toUpperCase()}),(0,s.jsxs)("div",{className:"grow",children:[(0,s.jsx)("b",{className:"cx-pick-title",children:e.name}),(0,s.jsx)("div",{className:"muted small",children:e.description||x("newAgent.typeFallback",{role:x("role.".concat(e.role)),provider:m.xq[e.provider].label})})]}),(0,s.jsx)("span",{className:"chip",children:m.xq[e.provider].short})]},e.id)),(0,s.jsxs)("button",{className:"card card-pad row gap-l cx-typecard blank",onClick:()=>{F({...(0,o.WU)(),colony_id:null!=b?b:null,object_ids:g?[g]:[]})},children:[(0,s.jsx)(i._h,{color:"var(--muted)",label:"+"}),(0,s.jsxs)("div",{className:"grow",children:[(0,s.jsx)("b",{className:"cx-pick-title",children:x("newAgent.blank")}),(0,s.jsx)("div",{className:"muted small",children:x("newAgent.blankHint")})]})]})]})},"type"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i._s,{title:x("newAgent.title"),subtitle:j?x("obj.manager.subtitle"):S.type_id?x("newAgent.fromType",{name:null!=(n=null==(l=k.find(e=>e.id===S.type_id))?void 0:l.name)?n:""}):x("newAgent.blank"),onClose:()=>{!M||L.current?h():T(!0)},footer:(0,s.jsxs)(s.Fragment,{children:[!v&&!j&&(0,s.jsx)("button",{className:"btn ghost",onClick:()=>D("type"),children:x("common.back")}),(0,s.jsx)("button",{className:"btn primary",disabled:P,onClick:B,children:P?x("newAgent.creating"):x("newAgent.create")})]}),children:(0,s.jsx)(o.SU,{draft:S,onChange:E,errors:K?H:{},focusName:!0})},"form"),O&&(0,s.jsx)(i.TM,{danger:!0,title:x("fa.unsaved.title"),body:x("fa.unsaved.body"),confirmLabel:x("fa.unsaved.discard"),cancelLabel:x("fa.unsaved.keep"),onClose:()=>T(!1),onConfirm:h})]})}},5300:(e,l,n)=>{n.d(l,{SU:()=>j,TN:()=>v,WU:()=>f,tf:()=>g});var s=n(94799),r=n(34023),t=n(12646),i=n(69654),o=n(56072),a=n(10804),c=n(48538),d=n(22214),m=n(47890),u=n(28941),p=n(7708),h=n(52974);let f=e=>{var l,n,s,r,t,i,o,a,c;return{name:"",description:null!=(l=null==e?void 0:e.description)?l:"",role:null!=(n=null==e?void 0:e.role)?n:"worker",provider:null!=(s=null==e?void 0:e.provider)?s:"claude",model:null!=(r=null==e?void 0:e.model)?r:"",system_prompt:null!=(t=null==e?void 0:e.system_prompt)?t:"",permission:null!=(i=null==e?void 0:e.permission)?i:"acceptEdits",cwd:"",skill_ids:null!=(o=null==e?void 0:e.skill_ids)?o:[],skill_loads:null!=(a=null==e?void 0:e.skill_loads)?a:{},worker_ids:[],type_id:null!=(c=null==e?void 0:e.id)?c:null,colony_id:null,overrides:[],browser:!1,object_ids:[]}},v=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{name:e.name,description:e.description,role:e.role,provider:e.provider,model:e.model,system_prompt:e.system_prompt,permission:e.permission,cwd:e.cwd,skill_ids:e.skill_ids,skill_loads:e.skill_loads,worker_ids:e.worker_ids,type_id:e.type_id,colony_id:e.colony_id,overrides:e.overrides,browser:e.browser,object_ids:l}},b=(e,l,n)=>!!l&&l.inherit[n]&&!e.overrides.includes(n);function g(e,l,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r={};e.name.trim()?l.some(l=>l.id!==n&&l.name.toLowerCase()===e.name.trim().toLowerCase())&&(r.name=(0,i.Tl)("form.err.nameTaken")):r.name=(0,i.Tl)("form.err.name");let t=s.find(l=>l.id===e.colony_id);return e.cwd.trim()||b(e,t,"cwd")&&(null==t?void 0:t.cwd)||(r.cwd=(0,i.Tl)("form.err.folder")),r}function j(e){var l;let{draft:n,onChange:f,errors:v,selfId:g,showType:j=!0,focusName:k=!1}=e,{t:y}=(0,i.s9)(),{skills:w,providers:_,agents:N,types:C,colonies:A,connections:D,objects:S}=(0,c.q5)(),E=(0,r.useMemo)(()=>S.filter(e=>h.G.includes(e.kind)).map(e=>{var l,n,s,r;return{id:e.id,label:e.name,hint:e.manager_id&&e.manager_id!==g?y("form.resources.taken",{name:null!=(s=null==(l=N.find(l=>l.id===e.manager_id))?void 0:l.name)?s:""}):null!=(r=null==(n=A.find(l=>l.id===e.colony_id))?void 0:n.name)?r:y("common.noColony")}}),[S,N,A,g,y]),q=(0,r.useMemo)(()=>D.filter(e=>e.agent_id===g&&e.enabled),[D,g]),z=A.find(e=>e.id===n.colony_id),F=e=>b(n,z,e),L=(e,l)=>f({...n,overrides:l?n.overrides.filter(l=>l!==e):[...new Set([...n.overrides,e])]}),M=(e,l)=>f({...n,[e]:l}),O=(0,r.useMemo)(()=>N.filter(e=>e.id!==g&&"worker"===e.role),[N,g]),T=C.find(e=>e.id===n.type_id);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.D0,{label:y("form.name"),error:v.name,hint:y("form.name.hint"),children:(0,s.jsx)("input",{className:"input",value:n.name,onChange:e=>M("name",e.target.value),placeholder:y("form.name.placeholder"),"data-autofocus":k?"":void 0})}),(0,s.jsx)(a.D0,{label:y("form.purpose"),hint:y("form.purpose.hint"),children:(0,s.jsx)("input",{className:"input",value:n.description,onChange:e=>M("description",e.target.value),placeholder:y("form.purpose.placeholder")})}),(0,s.jsxs)(a.D0,{label:y("form.role"),children:[(0,s.jsx)(a.$q,{value:n.role,onChange:e=>M("role",e),options:[{id:"worker",label:y("role.worker")},{id:"orchestrator",label:y("role.orchestrator")}]}),(0,s.jsx)("span",{className:"hint",children:"orchestrator"===n.role?y("form.role.orchestratorHint"):y("form.role.workerHint")})]}),j&&T&&(0,s.jsx)("p",{className:"hint m0",children:y("form.basedOn",{name:T.name})}),(0,s.jsx)(a.D0,{label:y("form.colony"),hint:y("form.colony.hint"),children:(0,s.jsxs)("select",{className:"select",value:null!=(l=n.colony_id)?l:"",onChange:e=>f({...n,colony_id:e.target.value||null,overrides:[]}),children:[(0,s.jsx)("option",{value:"",children:y("common.noColony")}),A.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,s.jsx)(a.D0,{label:y("form.provider"),children:(0,s.jsx)(a.YO,{value:n.provider,onChange:e=>f({...n,provider:e,model:"",browser:"claude"===e&&n.browser}),providers:_})}),(0,s.jsx)(a.CD,{provider:n.provider,value:n.model,onChange:e=>M("model",e)}),"claude"===n.provider&&(0,s.jsx)(p.Tl,{checked:n.browser,onChange:e=>M("browser",e),label:y("form.browser"),hint:y("form.browser.hint")}),z&&z.inherit.permission&&(0,s.jsx)(x,{colony:z,on:F("permission"),onChange:e=>L("permission",e),label:y("inherit.permissions"),value:(0,m.Ck)(z.permission)}),!F("permission")&&(0,s.jsx)(a.en,{value:n.permission,onChange:e=>M("permission",e),locked:q.length?["plan"]:[]}),q.length>0&&(0,s.jsxs)("p",{className:"hint m0",children:[(0,s.jsxs)("b",{children:[y("form.connections"),":"]})," ",y("form.connections.hint",{names:q.map(e=>e.name).join(", ")})]}),z&&z.inherit.cwd&&z.cwd&&(0,s.jsx)(x,{colony:z,on:F("cwd"),onChange:e=>L("cwd",e),label:y("field.folder"),value:(0,m._1)(z.cwd),mono:!0}),!(F("cwd")&&(null==z?void 0:z.cwd))&&(0,s.jsx)(a.dR,{value:n.cwd,onChange:e=>M("cwd",e),error:v.cwd}),z&&z.inherit.prompt&&z.system_prompt.trim()&&(0,s.jsx)(x,{colony:z,on:F("prompt"),onChange:e=>L("prompt",e),label:y("inherit.context"),value:"".concat(z.system_prompt.trim().slice(0,90)).concat(z.system_prompt.trim().length>90?"…":""),note:y("inherit.context.note")}),(0,s.jsx)(a.D0,{label:F("prompt")||(null==z?void 0:z.system_prompt)?y("form.ownPrompt"):y("form.systemPrompt"),hint:y("form.promptHint",{count:n.system_prompt.length,n:(0,o._E)(n.system_prompt.length)}),children:(0,s.jsx)(t.n,{value:n.system_prompt,onChange:e=>M("system_prompt",e),placeholder:y("form.prompt.placeholder"),defaultView:"write",minHeight:220})}),z&&z.inherit.skills&&z.skill_ids.length>0&&(0,s.jsx)(x,{colony:z,on:F("skills"),onChange:e=>L("skills",e),label:y("inherit.skills"),value:z.skill_ids.map(e=>{var l;return null==(l=w.find(l=>l.id===e))?void 0:l.name}).filter(Boolean).join(", "),note:y("inherit.skills.note")}),(0,s.jsx)(a.D0,{label:y("form.skills"),hint:y("form.skills.hint"),children:(0,s.jsx)(a.kV,{skills:w,value:n.skill_ids,loads:n.skill_loads,onChange:(e,l)=>f({...n,skill_ids:e,skill_loads:l})})}),E.length>0&&(0,s.jsx)(a.D0,{label:y("form.resources"),hint:y("form.resources.hint"),children:(0,s.jsx)(u.c,{multi:!0,options:E,value:n.object_ids,onChange:e=>f({...n,object_ids:e}),placeholder:y("form.resources.placeholder"),empty:y("form.resources.empty"),ariaLabel:y("form.resources")})}),"orchestrator"===n.role&&(0,s.jsx)(a.D0,{label:y("form.team"),hint:y("form.team.hint"),children:O.length?(0,s.jsx)(d.C,{items:O.map(e=>({id:e.id,name:e.name,note:e.description||e.provider})),value:n.worker_ids,onChange:e=>M("worker_ids",e)}):(0,s.jsx)("p",{className:"hint",children:y("form.team.empty")})})]})}function x(e){let{colony:l,on:n,onChange:r,label:t,value:o,note:a,mono:c}=e,{t:d}=(0,i.s9)();return(0,s.jsxs)("label",{className:"inherit-row ".concat(n?"on":""),children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:e=>r(e.target.checked)}),(0,s.jsxs)("span",{className:"grow",children:[(0,s.jsxs)("b",{children:[t," ",(0,s.jsx)("span",{className:"muted fw-500",children:d("inherit.from")})," ",(0,s.jsx)("i",{className:"cdot",style:{background:l.color||"var(--honey)"}}),l.name]}),(0,s.jsx)("span",{className:"inh-val ".concat(c?"mono":""),children:o||"—"}),a&&(0,s.jsx)("span",{className:"hint",children:a})]}),(0,s.jsx)("span",{className:"inh-state",children:d(n?"inherit.following":"inherit.own")})]})}},12646:(e,l,n)=>{n.d(l,{n:()=>_});var s=n(94799),r=n(34023),t=n(6458),i=n(53983),o=n(3492),a=n(98148),c=n(99579),d=n(55838),m=n(98938),u=n(52263),p=n(20555),h=n(91833),f=n(55712),v=n(71529),b=n(69654);function g(e,l,n,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:s,t=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",i=e.slice(l,n)||t;return e.slice(l-s.length,l)===s&&e.slice(n,n+r.length)===r&&l!==n?{value:e.slice(0,l-s.length)+i+e.slice(n+r.length),start:l-s.length,end:n-s.length}:{value:e.slice(0,l)+s+i+r+e.slice(n),start:l+s.length,end:l+s.length+i.length}}function j(e,l,n,s,r){let t=e.lastIndexOf("\n",l-1)+1,i=e.indexOf("\n",n),o=-1===i?e.length:i,a=e.slice(t,o).split("\n"),c=a.every(e=>r.test(e)),d=a.map((e,l)=>c?e.replace(r,""):s(l)+e.replace(r,"")).join("\n");return{value:e.slice(0,t)+d+e.slice(o),start:t,end:t+d.length}}let x=/^\s*[-*+] (\[[ x]\] )?/,k=/^\s*\d+\. /,y=/^#{1,6} /,w=/^> ?/;function _(e){let{value:l,onChange:n,placeholder:_,defaultView:N="split",minHeight:C=340,fill:A=!1}=e,{t:D}=(0,b.s9)(),S=(0,r.useRef)(null),[E,q]=(0,r.useState)(N),z=e=>{let l=S.current;if(!l)return;let s=e(l.value,l.selectionStart,l.selectionEnd);n(s.value),requestAnimationFrame(()=>{l.focus(),l.setSelectionRange(s.start,s.end)})},F=[{id:"h",icon:(0,s.jsx)(o.A,{size:15}),label:D("md.heading"),run:()=>z((e,l,n)=>j(e,l,n,()=>"## ",y))},{id:"b",icon:(0,s.jsx)(a.A,{size:15}),label:D("md.bold"),keys:"B",run:()=>z((e,l,n)=>g(e,l,n,"**","**",D("md.boldPh")))},{id:"i",icon:(0,s.jsx)(c.A,{size:15}),label:D("md.italic"),keys:"I",run:()=>z((e,l,n)=>g(e,l,n,"*","*",D("md.italicPh")))},{id:"c",icon:(0,s.jsx)(d.A,{size:15}),label:D("md.code"),run:()=>z((e,l,n)=>g(e,l,n,"`","`","code"))},{id:"cb",icon:(0,s.jsx)(m.A,{size:15}),label:D("md.codeBlock"),run:()=>z((e,l,n)=>g(e,l,n,"\n```\n","\n```\n","code"))},{id:"ul",icon:(0,s.jsx)(u.A,{size:15}),label:D("md.bullets"),run:()=>z((e,l,n)=>j(e,l,n,()=>"- ",x))},{id:"ol",icon:(0,s.jsx)(p.A,{size:15}),label:D("md.numbered"),run:()=>z((e,l,n)=>j(e,l,n,e=>"".concat(e+1,". "),k))},{id:"q",icon:(0,s.jsx)(h.A,{size:15}),label:D("md.quote"),run:()=>z((e,l,n)=>j(e,l,n,()=>"> ",w))},{id:"l",icon:(0,s.jsx)(f.A,{size:15}),label:D("md.link"),keys:"K",run:()=>z((e,l,n)=>{let s=e.slice(l,n)||D("md.linkPh"),r="[".concat(s,"](https://)");return{value:e.slice(0,l)+r+e.slice(n),start:l+s.length+3,end:l+s.length+11}})},{id:"hr",icon:(0,s.jsx)(v.A,{size:15}),label:D("md.rule"),run:()=>z((e,l,n)=>({value:e.slice(0,l)+"\n\n---\n\n"+e.slice(n),start:l+7,end:l+7}))}],L=l.trim()?l.trim().split(/\s+/).length:0;return(0,s.jsxs)("div",{className:"mde".concat(A?" fill":""),children:[(0,s.jsxs)("div",{className:"mde-bar",role:"toolbar","aria-label":D("md.toolbar"),children:[F.map(e=>(0,s.jsx)("button",{type:"button",className:"mde-btn",title:e.keys?"".concat(e.label," (Ctrl+").concat(e.keys,")"):e.label,"aria-label":e.label,onMouseDown:e=>e.preventDefault(),onClick:e.run,disabled:"preview"===E,children:e.icon},e.id)),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("div",{className:"mde-views",role:"group",children:["write","split","preview"].map(e=>(0,s.jsx)("button",{type:"button",className:E===e?"on":"","aria-pressed":E===e,onClick:()=>q(e),children:D("md.view.".concat(e))},e))})]}),(0,s.jsxs)("div",{className:"mde-body v-".concat(E),style:{minHeight:C},children:["preview"!==E&&(0,s.jsx)("textarea",{ref:S,className:"mde-text mono",style:{minHeight:C},value:l,onChange:e=>n(e.target.value),onKeyDown:e=>{let l=e.currentTarget;if(e.ctrlKey||e.metaKey){let l=F.find(l=>l.keys&&l.keys.toLowerCase()===e.key.toLowerCase());if(l){e.preventDefault(),l.run();return}}if("Tab"===e.key){e.preventDefault(),z((l,n,s)=>{if(n===s&&!e.shiftKey)return{value:l.slice(0,n)+" "+l.slice(s),start:n+2,end:n+2};let r=l.lastIndexOf("\n",n-1)+1,t=l.indexOf("\n",s),i=-1===t?l.length:t,o=l.slice(r,i).split("\n").map(l=>e.shiftKey?l.replace(/^ {1,2}/,""):" "+l).join("\n");return{value:l.slice(0,r)+o+l.slice(i),start:r,end:r+o.length}});return}if("Enter"===e.key&&!e.shiftKey&&l.selectionStart===l.selectionEnd){let s=l.value,r=l.selectionStart,t=s.lastIndexOf("\n",r-1)+1,i=s.slice(t,r),o=/^(\s*)([-*+] (?:\[[ x]\] )?|(\d+)\. )(.*)$/.exec(i);if(!o)return;if(e.preventDefault(),!o[4]){n(s.slice(0,t)+s.slice(r)),requestAnimationFrame(()=>l.setSelectionRange(t,t));return}let a=o[3]?"".concat(o[1]).concat(Number(o[3])+1,". "):o[1]+o[2].replace("[x]","[ ]");n(s.slice(0,r)+"\n"+a+s.slice(r)),requestAnimationFrame(()=>{let e=r+1+a.length;l.setSelectionRange(e,e)})}},placeholder:_,spellCheck:!1}),"write"!==E&&(0,s.jsx)("div",{className:"mde-prev md",children:(0,s.jsx)(t.oz,{remarkPlugins:[i.A],children:l||D("skills.previewEmpty")})})]}),(0,s.jsxs)("div",{className:"mde-foot muted",children:[D("md.stats",{words:L,chars:l.length})," \xb7 ",D("md.tips")]})]})}},22214:(e,l,n)=>{n.d(l,{C:()=>t});var s=n(94799),r=n(72705);function t(e){let{items:l,value:n,onChange:t}=e;return(0,s.jsx)("div",{className:"skillpick",children:l.map(e=>{let l=n.includes(e.id);return(0,s.jsxs)("button",{type:"button",className:"skillrow","aria-pressed":l,onClick:()=>t(l?n.filter(l=>l!==e.id):[...n,e.id]),children:[(0,s.jsx)("span",{className:"check",children:l&&(0,s.jsx)(r.A,{size:13,strokeWidth:3})}),(0,s.jsxs)("span",{children:[(0,s.jsx)("b",{className:"fw-600",children:e.name}),(0,s.jsx)("span",{className:"hint hint-block",children:e.note})]})]},e.id)})})}},28941:(e,l,n)=>{n.d(l,{c:()=>a});var s=n(94799),r=n(34023),t=n(70665),i=n(21018),o=n(48539);function a(e){let{options:l,value:n,onChange:a,multi:c=!1,inline:d=!1,placeholder:m,empty:u,ariaLabel:p,autoFocus:h=!1}=e,[f,v]=(0,r.useState)(""),[b,g]=(0,r.useState)(!1),[j,x]=(0,r.useState)(0),k=(0,r.useRef)(null),y=(0,r.useRef)(null);(0,i.s)(b,k,()=>g(!1));let w=n.map(e=>l.find(l=>l.id===e)).filter(e=>!!e),_=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return l.filter(l=>{var s;return!n.includes(l.id)&&(!e||"".concat(l.label," ").concat(null!=(s=l.hint)?s:"").toLowerCase().includes(e))}).slice(0,50)},[l,n,f]);(0,r.useEffect)(()=>{x(0)},[f,b]);let N=e=>{var l;a(c?[...n,e.id]:[e.id]),v(""),g(c),c&&(null==(l=y.current)||l.focus())},C=e=>{a(n.filter(l=>l!==e)),requestAnimationFrame(()=>{var e;return null==(e=y.current)?void 0:e.focus()})},A=!c&&w.length>0,D=b&&!A&&(_.length>0||!!u),S=(0,o.B)(D,j,_.length);return(0,s.jsxs)("div",{className:"sg ps ".concat(d?"ps-inline":""),ref:k,children:[(0,s.jsxs)("div",{className:"ps-box input ".concat(b?"open":""),onClick:()=>{if(!A){var e;g(!0),null==(e=y.current)||e.focus()}},children:[w.map(e=>(0,s.jsxs)("span",{className:"chip ps-chip",children:[e.label,(0,s.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),C(e.id)},"aria-label":"\xd7 ".concat(e.label),children:(0,s.jsx)(t.A,{size:12})})]},e.id)),!A&&(0,s.jsx)("input",{ref:y,className:"ps-input",value:f,placeholder:w.length?"":m,"aria-label":p,autoComplete:"off",spellCheck:!1,autoFocus:h,...S.input,onFocus:()=>g(!0),onChange:e=>{v(e.target.value),g(!0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),g(!0),x(e=>Math.min(_.length-1,e+1))):"ArrowUp"===e.key?(e.preventDefault(),x(e=>Math.max(0,e-1))):"Enter"===e.key&&b&&_[j]?(e.preventDefault(),N(_[j])):"Escape"===e.key&&b?(e.stopPropagation(),g(!1)):"Backspace"===e.key&&!f&&w.length&&C(w[w.length-1].id)}})]}),D&&(0,s.jsxs)("ul",{className:"sg-list",...S.listProps,children:[0===_.length&&(0,s.jsx)("li",{className:"sg-empty",children:u}),_.map((e,l)=>(0,s.jsx)("li",{...S.optionProps(l),children:(0,s.jsxs)("button",{type:"button",className:"sg-opt ".concat(l===j?"hi":""),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>x(l),onClick:()=>N(e),children:[(0,s.jsx)("span",{className:"nm",children:e.label}),e.hint&&(0,s.jsx)("span",{className:"hint",children:e.hint})]})},e.id))]})]})}},52974:(e,l,n)=>{n.d(l,{G:()=>c,I:()=>d});var s=n(94799),r=n(34023),t=n(69654),i=n(48538),o=n(10804),a=n(28941);let c=["server","docker","cluster"];function d(e){let{value:l,onChange:n}=e,{t:c}=(0,t.s9)(),{agents:d,colonies:m}=(0,i.o0)(),u=(0,r.useMemo)(()=>d.map(e=>{var l,n;return{id:e.id,label:e.name,hint:null!=(n=null==(l=m.find(l=>l.id===e.colony_id))?void 0:l.name)?n:c("common.noColony")}}),[d,m,c]);return(0,s.jsx)(o.D0,{label:c("obj.manager.label"),hint:l?c("obj.manager.hint.set"):c("obj.manager.hint.none"),children:(0,s.jsx)(a.c,{options:u,value:l?[l]:[],onChange:e=>{var l;return n(null!=(l=e[0])?l:"")},placeholder:c("obj.manager.placeholder"),empty:c("obj.manager.empty"),ariaLabel:c("obj.manager.label")})})}},73506:(e,l,n)=>{n.d(l,{h:()=>r});var s=n(34023);function r(e){(0,s.useEffect)(()=>{if(!e)return;let l=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[e])}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[654],{494:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},4713:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]])},5503:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]])},7697:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},8089:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]])},14214:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]])},18853:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]])},19431:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},32219:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]])},38950:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]])},46325:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},49731:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},50352:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]])},50703:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]])},52687:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},55267:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]])},62716:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},66477:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]])},75014:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]])},79141:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},79278:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]])},83372:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]])},84611:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]])},84616:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},87454:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},90124:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]])},92720:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]])},97541:(e,a,y)=>{y.d(a,{A:()=>t});let t=(0,y(74955).A)("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]])}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[705],{51705:(e,t,s)=>{s.d(t,{ry:()=>K,BZ:()=>O});var a=s(94799),n=s(34023),l=s(6458),r=s(53983),i=s(14214),c=s(84611),o=s(8089),d=s(50352),u=s(46325),h=s(79141),m=s(4713),p=s(70665),x=s(83372),g=s(75014),j=s(97541),f=s(50703),v=s(3749),b=s(48538),y=s(77021),N=s(47890),k=s(10804),z=s(10969),A=s(49731),w=s(7697),C=s(18853);let F=/^\[hive:channel\] (.+?) · Place: (.+?) · Thread: (.+?) · From: (.+?)((?: · (?:Addressed|Muted): \w+| · To: [^·\n]+)*)(?: · Now: [^\n]*)?\nMessage:\n([\s\S]*)$/,R="\n\n[hive:context]\n",T="\n\n[hive:files]\n";var E=s(69654);function D(e){let{text:t,badge:s,agentId:n}=e,{t:l}=(0,E.s9)(),r=function(e){let t=F.exec(e);if(!t)return null;let[s,...a]=t[6].split(R),[n,...l]=s.split(T),r=l.join(T).split("\n").flatMap(e=>{let t=/^- (.+) \(([^()]*)\)$/.exec(e);return t?[{path:t[1],name:t[1].replace(/^.*[\\/]/,"").replace(/^\d+-\d+-/,""),detail:t[2]}]:[]});return{platform:t[1],place:t[2],thread:t[3],from:t[4],body:n,files:r,overheard:/Addressed: no/.test(t[5]),muted:/Muted: yes/.test(t[5]),context:a.join(R)}}(t),i=r?null:function(e){let t=e.indexOf(T);if(t<0)return null;let s=e.slice(t+T.length).split("\n").flatMap(e=>{let t=/^- (.+) \(([^()]*)\)$/.exec(e);return t?[{path:t[1],name:t[1].replace(/^.*[\\/]/,"").replace(/^web-\d+-\d+-/,""),detail:t[2]}]:[]});return s.length?{body:e.slice(0,t),files:s}:null}(t);return i?(0,a.jsxs)("div",{className:"msg user".concat(s?" queued":""),children:[(0,a.jsxs)("div",{className:"bubble",children:[i.body.trim()&&"(no text)"!==i.body.trim()&&(0,a.jsx)("div",{children:i.body.trim()}),(0,a.jsx)("div",{className:"bubble-imgs",children:i.files.map(e=>{let t=n?"/api/agents/".concat(n,"/inbox?path=").concat(encodeURIComponent(e.path)):void 0;return n&&/\.(png|jpe?g|gif|webp)$/i.test(e.path)?(0,a.jsx)("a",{href:t,target:"_blank",rel:"noreferrer",title:e.name,children:(0,a.jsx)("img",{src:t,alt:e.name,loading:"lazy"})},e.path):(0,a.jsxs)("a",{className:"chfile",href:t,download:e.name,title:e.path,children:[(0,a.jsx)(m.A,{size:11,"aria-hidden":!0}),e.name,(0,a.jsx)("i",{children:e.detail.split(", ").pop()})]},e.path)})})]}),s&&(0,a.jsxs)("span",{className:"queued-tag",children:[(0,a.jsx)(A.A,{size:11,"aria-hidden":!0}),s]})]}):r?(0,a.jsx)("div",{className:"msg user",children:(0,a.jsxs)("div",{className:"bubble channel",children:[(0,a.jsxs)("div",{className:"chhead",children:[(0,a.jsx)(w.A,{size:12,"aria-hidden":!0}),(0,a.jsx)("b",{children:r.platform}),(0,a.jsx)("span",{children:r.place}),r.overheard&&(0,a.jsxs)("span",{className:"chtag",title:l("chat.channel.overheard.hint"),children:[(0,a.jsx)(C.A,{size:11,"aria-hidden":!0}),l("chat.channel.overheard")]}),(0,a.jsx)("span",{className:"chfrom",children:r.from.replace(/\s*\(.*\)$/,"")})]}),(0,a.jsx)("div",{className:"chbody",children:r.body}),r.files.length>0&&(0,a.jsx)("div",{className:"chfiles",children:r.files.map(e=>(0,a.jsxs)("span",{className:"chfile",title:e.path,children:[(0,a.jsx)(m.A,{size:11,"aria-hidden":!0}),e.name,(0,a.jsx)("i",{children:e.detail.split(", ").pop()})]},e.path))}),r.context&&(0,a.jsxs)("details",{className:"chctx",children:[(0,a.jsx)("summary",{children:l("chat.channel.context",{n:r.context.split("\n").filter(e=>e.startsWith("- ")).length})}),(0,a.jsx)("pre",{children:r.context.replace(/^[^\n]*\n/,"")})]})]})}):(0,a.jsxs)("div",{className:"msg user".concat(s?" queued":""),children:[(0,a.jsx)("div",{className:"bubble",children:t}),s&&(0,a.jsxs)("span",{className:"queued-tag",children:[(0,a.jsx)(A.A,{size:11,"aria-hidden":!0}),s]})]})}var M=s(56072);function S(e){var t,s,n;let{m:l}=e,{t:r}=(0,E.s9)(),u=null==(t=l.meta)?void 0:t.usage,h=l.blocks.filter(e=>"tool"===e.type).length;if(!u&&!l.durationMs&&!h)return null;let m=(0,M.RP)(u);return(0,a.jsxs)("div",{className:"replymeta",children:[(null==(s=l.meta)?void 0:s.model)&&(0,a.jsx)("span",{className:"mono",children:l.meta.model.replace(/^claude-/,"").replace(/-\d{8}$/,"")}),m>0&&(0,a.jsxs)("span",{title:u?r("chat.tokenDetail",{input:u.input,output:u.output,cacheRead:u.cacheRead,cacheWrite:u.cacheWrite}):"",children:[(0,a.jsx)(i.A,{size:12}),r("chat.inOut",{in:(0,M.yj)(u.input+u.cacheRead+u.cacheWrite),out:(0,M.yj)(u.output)})]}),(null==u?void 0:u.credits)?(0,a.jsxs)("span",{children:[(0,a.jsx)(c.A,{size:12}),r("chat.credits",{value:u.credits.toFixed(2)})]}):null,(null==(n=l.meta)?void 0:n.cost)!==void 0&&(0,a.jsxs)("span",{title:r(l.meta.costEstimated?"stats.costEstimated":"stats.costReported"),children:[(0,a.jsx)(c.A,{size:12}),l.meta.costEstimated?"≈ ":"",(0,M.F0)(l.meta.cost)]}),h>0&&(0,a.jsxs)("span",{children:[(0,a.jsx)(o.A,{size:12}),r("chat.tools",{count:h})]}),l.durationMs?(0,a.jsxs)("span",{children:[(0,a.jsx)(d.A,{size:12}),(0,M.nc)(l.durationMs)]}):null]})}let P=/usage limit|quota|insufficient|rate.?limit|too many requests|credits/i;function H(e){let{agent:t,error:s,onDone:l}=e,{t:r}=(0,E.s9)(),i=(0,k.dj)(),[c,o]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if("opencode"!==t.provider)return;let e=!0;return v.FH.get("/agents/".concat(t.id,"/compact")).then(t=>{e&&o(t.supported)}).catch(()=>{}),()=>{e=!1}},[t.id,t.provider]);let h=async()=>{u(!0);try{await v.FH.post("/agents/".concat(t.id,"/compact")),i(r("chat.compacted"),"ok"),l()}catch(e){i(r("chat.compactFailed",{reason:e instanceof Error?e.message:String(e)}),"err")}finally{u(!1)}},m=P.test(s);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),(0,a.jsx)("span",{className:"muted",children:r(m?"chat.failedHintLimit":c?"chat.failedHintCompact":"chat.failedHint")}),c&&!m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),(0,a.jsx)("button",{type:"button",className:"btn sm",disabled:d,onClick:()=>void h(),children:d?r("chat.compacting"):r("chat.compact")})]})]})}function q(e){var t,s,l,r,c;let{turn:u}=e,{t:h}=(0,E.s9)(),[,m]=(0,n.useState)(0),p=!!u.error;(0,n.useEffect)(()=>{if(p)return;let e=setInterval(()=>m(e=>e+1),500);return()=>clearInterval(e)},[p]);let x=(0,n.useRef)(0);p&&!x.current&&(x.current=Date.now());let g=u.usage,j=u.blocks.filter(e=>"tool"===e.type).length;return(0,a.jsxs)("div",{className:"replymeta live",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(d.A,{size:12}),(0,M.nc)((p?x.current:Date.now())-u.startedAt)]}),j>0&&(0,a.jsxs)("span",{children:[(0,a.jsx)(o.A,{size:12}),h("chat.tools",{count:j})]}),g&&(null!=(t=g.output)?t:0)>0&&(0,a.jsxs)("span",{children:[(0,a.jsx)(i.A,{size:12}),h("chat.inOut",{in:(0,M.yj)((null!=(s=g.input)?s:0)+(null!=(l=g.cacheRead)?l:0)+(null!=(r=g.cacheWrite)?r:0)),out:(0,M.yj)(null!=(c=g.output)?c:0)})]}),(null==g?void 0:g.contextPct)!==void 0&&(0,a.jsx)("span",{children:h("chat.contextPct",{pct:g.contextPct.toFixed(1)})})]})}let _=(0,n.memo)(function(e){let{text:t}=e;return(0,a.jsx)("div",{className:"md",children:(0,a.jsx)(l.oz,{remarkPlugins:[r.A],children:t})})}),I=(0,n.memo)(function(e){let{blocks:t,streaming:s}=e,{t:n}=(0,E.s9)();return(0,a.jsxs)(a.Fragment,{children:[t.map((e,l)=>"text"===e.type?(0,a.jsx)(_,{text:e.text},l):"thinking"===e.type?(0,a.jsxs)("details",{className:"fold think",children:[(0,a.jsxs)("summary",{children:[(0,a.jsx)(u.A,{size:14}),s&&l===t.length-1?n("activity.thinking"):n("chat.thought"),(0,a.jsx)(h.A,{size:14,className:"chev"})]}),(0,a.jsx)("pre",{children:e.text})]},l):(0,a.jsx)(z.Dm,{tool:e,streaming:s},l)),(0,a.jsx)(z.Kt,{blocks:t})]})}),O=(0,n.memo)(function(e){let{msgs:t,agent:s}=e,{t:l}=(0,E.s9)(),r=(0,n.useMemo)(()=>(function(e){let t=[],s=null;for(let n of e){var a;let e;if("user"===n.role){s=n.ts,t.push(n);continue}if(n.compact){t.push(n);continue}let l=t[t.length-1],r=(e,t)=>{var s,a,n,l,r,i,c;if(!e)return t;if(!t)return e;let o=e.usage,d=t.usage;return{model:null!=(s=t.model)?s:e.model,endTs:null!=(a=t.endTs)?a:e.endTs,cost:void 0!==e.cost||void 0!==t.cost?(null!=(n=e.cost)?n:0)+(null!=(l=t.cost)?l:0):void 0,costEstimated:e.costEstimated||t.costEstimated,usage:o&&d?{input:o.input+d.input,output:o.output+d.output,cacheRead:o.cacheRead+d.cacheRead,cacheWrite:o.cacheWrite+d.cacheWrite,reasoning:o.reasoning+d.reasoning,credits:(null!=(r=o.credits)?r:0)+(null!=(i=d.credits)?i:0)||void 0,contextPct:null!=(c=d.contextPct)?c:o.contextPct}:null!=o?o:d}};(null==l?void 0:l.role)!=="assistant"||l.compact?(e={...n},t.push(e)):(e={...l,blocks:[...l.blocks,...n.blocks],meta:r(l.meta,n.meta)},t[t.length-1]=e);let i=null==(a=e.meta)?void 0:a.endTs;e.durationMs=s&&i?Math.max(0,i-s):void 0}return t})(t),[t]);return(0,a.jsx)(a.Fragment,{children:r.map(e=>e.compact?(0,a.jsx)("div",{className:"compact-mark",role:"separator",children:(0,a.jsx)("span",{children:l("chat.compactMark",{pre:(0,M.yj)(e.compact.pre),post:(0,M.yj)(e.compact.post)})})},e.id):"user"===e.role?(0,a.jsx)(D,{agentId:s.id,text:e.blocks.map(e=>"text"===e.type?e.text:"").join("")},e.id):(0,a.jsxs)("div",{className:"msg assistant",children:[(0,a.jsxs)("div",{className:"who",children:[(0,a.jsx)(k._h,{agent:s,size:"sm"}),s.name,(0,a.jsx)("span",{className:"stamp",children:e.ts?(0,N.KN)(e.ts):""})]}),(0,a.jsx)(I,{blocks:e.blocks}),(0,a.jsx)(S,{m:e})]},e.id))})},(e,t)=>e.msgs===t.msgs&&e.agent.id===t.agent.id&&e.agent.name===t.agent.name&&e.agent.provider===t.agent.provider&&e.agent.role===t.agent.role),W=(0,n.memo)(function(e){let{agentId:t,name:s,running:l,queued:r,readOnly:i,onSend:c,onStop:o,toolsOpen:d,onToggleTools:u}=e,{t:h}=(0,E.s9)(),[j,f]=(0,y.ud)("hive-am.draft.".concat(t),""),[v,b]=(0,n.useState)([]),[N,z]=(0,n.useState)(!1),A=(0,k.dj)(),w=(0,n.useRef)(null),C=(0,n.useRef)(null),F=()=>{let e=w.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")},R=async e=>{let t=e.slice(0,Math.max(0,5-v.length));t.length<e.length&&A(h("chat.img.max",{n:5}),"err");let s=t.filter(e=>e.size<=0x1400000&&e.size>0);s.length<t.length&&A(h("chat.img.big",{mb:20}),"err");let a=await Promise.all(s.map((e,t)=>new Promise((s,a)=>{let n=new FileReader;n.onload=()=>s({id:"".concat(Date.now(),"-").concat(t),name:e.name&&"image.png"!==e.name?e.name:"pasted-".concat(t+1,".png"),data:String(n.result),type:e.type,size:e.size}),n.onerror=()=>a(n.error),n.readAsDataURL(e)})));b(e=>[...e,...a])},T=async()=>{let e=j.trim();(e||v.length)&&(f(""),b([]),requestAnimationFrame(F),await c(e,v.map(e=>{let{name:t,data:s,type:a}=e;return{name:t,data:s,type:a}}))||(f(e),b(v),requestAnimationFrame(F)))};return(0,a.jsxs)("div",{className:"composer",children:[i?(0,a.jsx)("div",{className:"composer-box chat-readonly",children:(0,a.jsx)("span",{className:"muted",children:h("chat.readOnly")})}):(0,a.jsxs)("div",{className:"composer-box ".concat(N?"over":""),onDragOver:e=>{[...e.dataTransfer.types].includes("Files")&&(e.preventDefault(),z(!0))},onDragLeave:()=>z(!1),onDrop:e=>{z(!1);let t=[...e.dataTransfer.files];t.length&&(e.preventDefault(),R(t))},children:[v.length>0&&(0,a.jsx)("div",{className:"cmp-imgs",children:v.map(e=>{let t;return(0,a.jsxs)("span",{className:"cmp-img".concat(e.type.startsWith("image/")?"":" file"),title:e.name,children:[e.type.startsWith("image/")?(0,a.jsx)("img",{src:e.data,alt:e.name}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{size:14,"aria-hidden":!0}),(0,a.jsx)("b",{children:e.name}),(0,a.jsx)("i",{children:(t=e.size)<1024?"".concat(t," B"):t<1048576?"".concat(Math.round(t/1024)," KB"):"".concat((t/1024/1024).toFixed(1)," MB")})]}),(0,a.jsx)("button",{type:"button",onClick:()=>b(t=>t.filter(t=>t.id!==e.id)),"aria-label":h("chat.img.remove",{name:e.name}),title:h("chat.img.remove",{name:e.name}),children:(0,a.jsx)(p.A,{size:12})})]},e.id)})}),(0,a.jsx)("input",{ref:C,type:"file",multiple:!0,hidden:!0,onChange:e=>{var t;R([...null!=(t=e.target.files)?t:[]]),e.target.value=""}}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon",onClick:()=>{var e;return null==(e=C.current)?void 0:e.click()},"aria-label":h("chat.img.attach"),title:h("chat.img.attach"),children:(0,a.jsx)(m.A,{size:18})}),(0,a.jsx)("textarea",{ref:w,rows:1,onPaste:e=>{let t=[...e.clipboardData.files];!t.length||e.clipboardData.getData("text/plain").trim()||(e.preventDefault(),R(t))},value:j,placeholder:l?h("chat.queuePlaceholder"):h("chat.placeholder",{name:s}),"aria-label":h("chat.messageLabel"),onChange:e=>{f(e.target.value),F()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),T())}}),l&&(0,a.jsxs)("button",{className:"btn",onClick:o,"aria-label":h("chat.stop"),children:[(0,a.jsx)(x.A,{size:14,fill:"currentColor"}),h("chat.stop")]}),(0,a.jsx)("button",{className:"btn primary icon",onClick:()=>void T(),disabled:!j.trim()&&!v.length,"aria-label":h("chat.send"),children:(0,a.jsx)(g.A,{size:18})})]}),(0,a.jsxs)("div",{className:"composer-meta",children:[(0,a.jsx)("span",{children:h("chat.keys")}),(0,a.jsx)("button",{type:"button",className:"linkbtn",onClick:u,children:d?h("chat.collapseTools"):h("chat.expandTools")}),r>0&&(0,a.jsx)("span",{children:h("queue.count",{count:r})})]})]})});function K(e){var t,s,l,r;let{agent:i,sessionOverride:c}=e,{t:o}=(0,E.s9)(),{agents:d}=(0,b.q5)(),{clearLive:u}=(0,b.zd)(),h=(0,k.dj)(),[m,p]=(0,n.useState)([]),[x,g]=(0,n.useState)(!1),[y,N]=(0,n.useState)(60),[A,w]=(0,n.useState)(0),C=(0,n.useRef)(null),[F,R]=(0,n.useState)([]),[T,M]=(0,n.useState)(null),S=(0,n.useRef)(null),P=(0,n.useRef)(!0),_=(0,n.useRef)(0),K=(0,n.useRef)(0),L=(0,n.useCallback)(()=>{K.current=performance.now()},[]),[$,B]=(0,n.useState)(!1),U=(0,n.useCallback)(()=>{P.current=!1,B(!0)},[]),Y=(0,n.useCallback)(()=>{let e=S.current;P.current=!0,B(!1),e&&(e.scrollTop=e.scrollHeight)},[]),Z=(0,b.M_)(i.id),Q="running"===i.status||!!Z&&!Z.error,V=void 0!==c&&c!==i.session_id,G=(0,n.useCallback)(()=>{let e=V?c:i.session_id;return e?v.FH.get("/agents/".concat(i.id,"/history?session=").concat(encodeURIComponent(e),"&limit=").concat(y)).then(e=>{var t;p(e.messages),w(null!=(t=e.total)?t:e.messages.length),g(!0)}).catch(e=>{h(e.message,"err"),g(!0)}):(p([]),w(0),g(!0),Promise.resolve())},[i.id,i.session_id,V,c,h,y]);(0,n.useEffect)(()=>{g(!1),N(60)},[i.id,i.session_id,c]),(0,n.useEffect)(()=>{G()},[G]),(0,n.useLayoutEffect)(()=>{let e=S.current;e&&null!==C.current&&(e.scrollTop+=e.scrollHeight-C.current,C.current=null)},[m]);let J=(0,n.useCallback)(()=>{var e,t;C.current=null!=(t=null==(e=S.current)?void 0:e.scrollHeight)?t:null,U(),N(e=>e+120)},[U]),X=(0,b.SV)(i.id),ee=(0,n.useRef)(!0);ee.current=!Z&&"running"!==i.status&&!(null!=(s=i.queued)?s:0),(0,n.useEffect)(()=>{X&&G().then(()=>{ee.current&&R(e=>e.length?[]:e)})},[X]),(0,n.useEffect)(()=>{R(e=>{let t=e.filter(e=>!m.some(t=>"user"===t.role&&t.blocks.some(t=>"text"===t.type&&t.text.trim()===e.trim())));return t.length===e.length?e:t})},[m]),(0,n.useEffect)(()=>{let e=S.current,t=null==e?void 0:e.firstElementChild;if(!e||!t)return;let s=()=>{P.current&&(e.scrollTop=e.scrollHeight)},a=new ResizeObserver(s);return a.observe(t),s(),()=>a.disconnect()},[x,i.id]);let et=(0,n.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(V)return!1;R(t=>[...t,e]),Y();try{let s=await v.FH.post("/agents/".concat(i.id,"/messages"),{prompt:e,...t.length?{files:t}:{}});return s.prompt&&s.prompt!==e&&R(t=>{let a=t.lastIndexOf(e);return a<0?t:t.map((e,t)=>t===a?s.prompt:e)}),!0}catch(t){return R(t=>{let s=t.lastIndexOf(e);return s<0?t:t.filter((e,t)=>t!==s)}),h(t instanceof Error?t.message:o("chat.sendFailed"),"err"),!1}},[i.id,V,h,o,Y]),es=(0,n.useCallback)(()=>{v.FH.post("/agents/".concat(i.id,"/stop")).catch(()=>void 0)},[i.id]),ea=(0,n.useCallback)(()=>M(e=>!e),[]),en=F.filter((e,t)=>!(Z&&t===F.findIndex(e=>e.trim()===Z.prompt.trim()))),el=x&&!m.length&&!Z&&!F.length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.Qh.Provider,{value:T,children:(0,a.jsxs)("div",{className:"thread-wrap",children:[(0,a.jsx)("div",{className:"thread",ref:S,role:"log","aria-label":o("fa.chat.log",{name:i.name}),"aria-live":Z?"off":"polite","aria-relevant":"additions",tabIndex:-1,onWheel:e=>{e.deltaY<0&&U()},onTouchStart:L,onTouchMove:L,onPointerDown:L,onPointerMove:e=>{e.buttons&&L()},onKeyDown:e=>{!["PageUp","ArrowUp","Home"].includes(e.key)||e.target instanceof HTMLTextAreaElement||U()},onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<40?(P.current=!0,B(!1)):t.scrollTop<_.current-1&&performance.now()-K.current<700&&U(),_.current=t.scrollTop},children:(0,a.jsxs)("div",{className:"thread-inner",children:[el&&(0,a.jsx)("div",{className:"mt-l",children:(0,a.jsx)(k.pp,{icon:(0,a.jsx)(k._h,{agent:i,size:"lg"}),title:o("chat.empty.title",{name:i.name}),body:"orchestrator"===i.role?o("chat.empty.orchestrator"):o("chat.empty.worker")})}),A>m.length&&(0,a.jsx)("button",{type:"button",className:"btn sm chat-earlier",onClick:J,children:o("chat.earlier",{n:A-m.length})}),(0,a.jsx)(O,{msgs:m,agent:i}),Z&&(0,a.jsxs)(a.Fragment,{children:["dispatch"===Z.source?(0,a.jsxs)("div",{className:"delegation-card",children:[(0,a.jsxs)("div",{className:"head",children:[(0,a.jsx)(j.A,{size:14}),o("chat.delegatedFrom",{name:null!=(l=null==(t=d.find(e=>e.id===Z.from))?void 0:t.name)?l:o("chat.anOrchestrator")})]}),(0,a.jsx)("p",{children:Z.prompt}),(0,a.jsx)("span",{className:"hint",children:o("chat.delegatedNote")})]}):!m.some(e=>"user"===e.role&&e.blocks.some(e=>"text"===e.type&&e.text.trim()===Z.prompt.trim()))&&(0,a.jsx)(D,{text:Z.prompt,agentId:i.id}),(0,a.jsxs)("div",{className:"msg assistant",children:[(0,a.jsxs)("div",{className:"who",children:[(0,a.jsx)(k._h,{agent:i,size:"sm"}),i.name]}),(0,a.jsx)(I,{blocks:Z.blocks,streaming:!0}),!Z.error&&(0,a.jsxs)("span",{className:"typing","aria-label":o("common.working"),children:[(0,a.jsx)("i",{}),(0,a.jsx)("i",{}),(0,a.jsx)("i",{})]}),(0,a.jsx)(q,{turn:Z}),Z.error&&(0,a.jsxs)(k.lZ,{kind:"err",onDismiss:()=>u(i.id),children:[(0,E.YF)(Z.error),(0,a.jsx)(H,{agent:i,error:Z.error,onDone:()=>u(i.id)})]})]})]}),en.map((e,t)=>(0,a.jsx)(D,{agentId:i.id,text:e,badge:Z?o("chat.queuedBadge"):void 0},"".concat(t,":").concat(e)))]})}),$&&(0,a.jsxs)("button",{type:"button",className:"btn sm chat-jump",onClick:Y,children:[(0,a.jsx)(f.A,{size:14,"aria-hidden":!0}),o("fa.chat.jump")]})]})}),(0,a.jsx)("span",{className:"chat-sr",role:"status",children:Z?o("fa.chat.working",{name:i.name}):X?o("fa.chat.done",{name:i.name}):""}),(0,a.jsx)(W,{agentId:i.id,name:i.name,running:Q,queued:null!=(r=i.queued)?r:0,readOnly:V,onSend:et,onStop:es,toolsOpen:T,onToggleTools:ea})]})}}}]);
@@ -1 +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})})}}}]);
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(10804),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(10804),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(10804),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(10804);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(10804),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})})}}}]);