bazilion 0.53.0 → 0.54.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 (177) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +296 -232
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-CkwSq3C7.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-CEn_4qVs.js +1 -0
  7. package/dist/web/client/assets/Button-UiegBKOK.js +1 -0
  8. package/dist/web/client/assets/{ConfigPage-DiQiJXP6.js → ConfigPage-CUbHBhzx.js} +1 -1
  9. package/dist/web/client/assets/ConfirmDialog-VqBOFZEp.js +1 -0
  10. package/dist/web/client/assets/ConnectionsView-ByARMcWP.js +1 -0
  11. package/dist/web/client/assets/{ManagePage-xlePXXx5.js → ManagePage-BJWZd1ts.js} +1 -1
  12. package/dist/web/client/assets/{SectionTabs-BMiRKFfb.js → SectionTabs-ViZKm3-B.js} +1 -1
  13. package/dist/web/client/assets/{Segmented-Co4n2C5X.js → Segmented-MYKKTuZO.js} +1 -1
  14. package/dist/web/client/assets/SkillsParts-UvNK5SYP.js +1 -0
  15. package/dist/web/client/assets/SpawnTeamModal-DG5UbJNK.js +1 -0
  16. package/dist/web/client/assets/TeamForm-DGlxWv4e.js +1 -0
  17. package/dist/web/client/assets/TeamThread-mkwODO0S.js +1 -0
  18. package/dist/web/client/assets/{UnsavedChangesGuard-DmT4nBQU.js → UnsavedChangesGuard-BmdwLH99.js} +1 -1
  19. package/dist/web/client/assets/_id-CvcxNmBH.js +1 -0
  20. package/dist/web/client/assets/_id-UyBk7gRl.js +1 -0
  21. package/dist/web/client/assets/access-C8d8vaQ6.js +1 -0
  22. package/dist/web/client/assets/agent-actions-BgE9fKHH.js +1 -0
  23. package/dist/web/client/assets/agents-CgtzqBpD.js +1 -0
  24. package/dist/web/client/assets/agents-D7W4BT8r.js +1 -0
  25. package/dist/web/client/assets/arrow-right-D0HKRb7U.js +1 -0
  26. package/dist/web/client/assets/attention-D9mQWoKt.js +1 -0
  27. package/dist/web/client/assets/bot-Bb--PFVU.js +1 -0
  28. package/dist/web/client/assets/chevron-right-bs0TUSl2.js +1 -0
  29. package/dist/web/client/assets/config-Dw6GWf38.js +1 -0
  30. package/dist/web/client/assets/createLucideIcon-DkniuEtD.js +1 -0
  31. package/dist/web/client/assets/{download-Dj-1ltZb.js → download-C4t9l5wR.js} +1 -1
  32. package/dist/web/client/assets/{file-text-DiP-LaEg.js → file-text-DzbjpYrV.js} +1 -1
  33. package/dist/web/client/assets/{images-BKjyhYUc.js → images-DSYgPKM7.js} +1 -1
  34. package/dist/web/client/assets/index-YW0gXPfk.js +14 -0
  35. package/dist/web/client/assets/{key-round-QpqZklz6.js → key-round-BpK4-E3T.js} +1 -1
  36. package/dist/web/client/assets/{list-checks-BeyG5SVQ.js → list-checks-JNXcmws9.js} +1 -1
  37. package/dist/web/client/assets/login-DcQJk5-U.js +1 -0
  38. package/dist/web/client/assets/manage-SRGSx8n2.js +1 -0
  39. package/dist/web/client/assets/mcp-BUWu4TvS.js +1 -0
  40. package/dist/web/client/assets/{message-square-DnpSOYv4.js → message-square-DM2MP9vF.js} +1 -1
  41. package/dist/web/client/assets/{network-BC7rNaOC.js → network-BJ4iPjQO.js} +1 -1
  42. package/dist/web/client/assets/parts-LZxl9Gvc.js +41 -0
  43. package/dist/web/client/assets/plus-CLGNN5QX.js +1 -0
  44. package/dist/web/client/assets/routes-BxIIyGho.js +85 -0
  45. package/dist/web/client/assets/skills-C7DzIwFJ.js +1 -0
  46. package/dist/web/client/assets/{square-terminal-hQZ6pexU.js → square-terminal-Dmm6cV-G.js} +1 -1
  47. package/dist/web/client/assets/style-CA2GAk9b.js +7 -0
  48. package/dist/web/client/assets/styles-C3CDSGAr.css +2 -0
  49. package/dist/web/client/assets/system-zQ0NnQML.js +1 -0
  50. package/dist/web/client/assets/teams-BEIJHObN.js +1 -0
  51. package/dist/web/client/assets/teams-DlOc7Ods.js +1 -0
  52. package/dist/web/client/assets/telegram-DKHq5DpE.js +1 -0
  53. package/dist/web/client/assets/tools-BKIpLaiC.js +1 -0
  54. package/dist/web/client/assets/use-resource-CQaIZbpy.js +1 -0
  55. package/dist/web/client/assets/users-round-BJrym3FG.js +1 -0
  56. package/dist/web/client/assets/welcome-CyS4Hrd-.js +1 -0
  57. package/dist/web/client/assets/wrench-GbE1M1RJ.js +1 -0
  58. package/dist/web/server/assets/{AddProviderDialog-Di5crZUB.js → AddProviderDialog-Nc5mc_P6.js} +7 -10
  59. package/dist/web/server/assets/{AgentTemplateParts-Cqy7kSzx.js → AgentTemplateParts-DZK_r3nQ.js} +3 -6
  60. package/dist/web/server/assets/{ConfigPage-oXM3wyOU.js → ConfigPage-CxzL-gTm.js} +1 -1
  61. package/dist/web/server/assets/{ConfirmDialog-DfaJ--A6.js → ConfirmDialog-4xeCXKHe.js} +1 -2
  62. package/dist/web/server/assets/{ConnectionsView-DZrLoNoW.js → ConnectionsView-B02FjNsM.js} +9 -9
  63. package/dist/web/server/assets/{ManagePage-0LKHEcT_.js → ManagePage-BfCWE8Lj.js} +1 -1
  64. package/dist/web/server/assets/ModelMenu-D-hTgYOO.js +278 -0
  65. package/dist/web/server/assets/{Rail-7JU6ly2O.js → Rail-3gbidhyv.js} +9 -12
  66. package/dist/web/server/assets/SkillsParts-D58l8voo.js +199 -0
  67. package/dist/web/server/assets/SpawnDialog-MJWwppgC.js +1648 -0
  68. package/dist/web/server/assets/{SpawnTeamModal-CCe6P82H.js → SpawnTeamModal-RjzAeX_Q.js} +3 -6
  69. package/dist/web/server/assets/{TeamForm-BzQmdhVi.js → TeamForm-DdOgIMiV.js} +2 -5
  70. package/dist/web/server/assets/{TeamThread-SyQpUvz5.js → TeamThread-D-PvO3fu.js} +9 -9
  71. package/dist/web/server/assets/{UnsavedChangesGuard-DrOvPV14.js → UnsavedChangesGuard-Bb5frygQ.js} +1 -1
  72. package/dist/web/server/assets/{_id-AcyGvFrE.js → _id-BPjVkcNb.js} +10 -14
  73. package/dist/web/server/assets/{_id-DXm9W55C.js → _id-BUfy-GwH.js} +2 -2
  74. package/dist/web/server/assets/{_id-DPGzfmjG.js → _id-C1_l6oSR.js} +9 -11
  75. package/dist/web/server/assets/{_id-BGTgqsWm.js → _id-CHvYQhWt.js} +2 -2
  76. package/dist/web/server/assets/{_id-DojvxRZn.js → _id-De3Bm0SG.js} +1 -1
  77. package/dist/web/server/assets/_tanstack-start-manifest_v-CR3jm1nY.js +256 -0
  78. package/dist/web/server/assets/{access-CKSW7MFH.js → access-CNfvQ3NB.js} +4 -6
  79. package/dist/web/server/assets/{access-BJe-NduL.js → access-Cm_izIIC.js} +2 -2
  80. package/dist/web/server/assets/{agent-actions-CUDMCG0F.js → agent-actions-COnfW5AU.js} +1 -1
  81. package/dist/web/server/assets/{agents-DUI4Yjtg.js → agents-C7UmTjfO.js} +2 -2
  82. package/dist/web/server/assets/{agents-6d9WxbYF.js → agents-CRtMfKqX.js} +1 -1
  83. package/dist/web/server/assets/{agents-DtLDoZ_u.js → agents-D0hfGIMK.js} +6 -8
  84. package/dist/web/server/assets/{agents-DKVGUwD1.js → agents-DQowl6Ly.js} +1 -1
  85. package/dist/web/server/assets/{agents-1sjSvp5p.js → agents-DzpqlIuJ.js} +2 -2
  86. package/dist/web/server/assets/{agents-DsHeRaLq.js → agents-NOkh61dV.js} +6 -10
  87. package/dist/web/server/assets/{attention-johfkM0_.js → attention-CRvxt22X.js} +40 -11
  88. package/dist/web/server/assets/{attention-B6sSDR_4.js → attention-CgWhXjX7.js} +2 -0
  89. package/dist/web/server/assets/{attention-DefKwvgm.js → attention-Cx9ZWPOO.js} +4 -2
  90. package/dist/web/server/assets/{config-DYAaaE9Z.js → config-B5CS8juO.js} +2 -2
  91. package/dist/web/server/assets/{config-Clz57LuN.js → config-D117117T.js} +24 -26
  92. package/dist/web/server/assets/{createSsrRpc-BijMHgqE.js → createSsrRpc-CwTd0zrB.js} +4 -57
  93. package/dist/web/server/assets/{login-VV10kZBl.js → login-IF0Gbsuq.js} +36 -2
  94. package/dist/web/server/assets/{login-JoIjlcmu.js → login-va4EtvA8.js} +34 -45
  95. package/dist/web/server/assets/{manage-Ppyi3Y5y.js → manage-Ce6cI4eW.js} +14 -4
  96. package/dist/web/server/assets/{mcp-DB38leWS.js → mcp-Bm9U6x7N.js} +2 -2
  97. package/dist/web/server/assets/{mcp-Ce6O8Qs2.js → mcp-C96PBxpb.js} +4 -6
  98. package/dist/web/server/assets/page-title-CwcbXMhx.js +95 -0
  99. package/dist/web/server/assets/{router-C97bwlXi.js → router-8Iq19GOz.js} +354 -196
  100. package/dist/web/server/assets/{routes-C4aGqXfr.js → routes-BLo-fWbQ.js} +2680 -1710
  101. package/dist/web/server/assets/{routes-DuOShl4q.js → routes-BXvYYFrN.js} +2 -2
  102. package/dist/web/server/assets/routes-Kwam6JmS.js +89 -0
  103. package/dist/web/server/assets/{skills-B7sg0QKS.js → skills-BqCnA-74.js} +2 -2
  104. package/dist/web/server/assets/skills-DSezIdDc.js +157 -0
  105. package/dist/web/server/assets/{style-BR7ufS6Z.js → style-C2hIPY_Y.js} +1 -1
  106. package/dist/web/server/assets/{system-DaP0ol67.js → system-CcLCmkIC.js} +2 -2
  107. package/dist/web/server/assets/{system-CNQpt3JB.js → system-E0VePdzO.js} +4 -4
  108. package/dist/web/server/assets/{teams-C3xwTz8-.js → teams-CQVV18D3.js} +6 -9
  109. package/dist/web/server/assets/{teams-BKHe67f3.js → teams-CdCmBJIj.js} +7 -9
  110. package/dist/web/server/assets/{teams-CuKE5iAK.js → teams-DScFp8mK.js} +2 -2
  111. package/dist/web/server/assets/{teams-4cEZ4_rw.js → teams-DxA-vnzY.js} +2 -2
  112. package/dist/web/server/assets/{telegram-BpmK-HHV.js → telegram-DJ8s_91Y.js} +7 -9
  113. package/dist/web/server/assets/{telegram-BnQADwnj.js → telegram-DR7xijeS.js} +2 -2
  114. package/dist/web/server/assets/{tools-BQeWn7Tj.js → tools-CsH9DI-4.js} +2 -2
  115. package/dist/web/server/assets/{tools-CURTfG2q.js → tools-V6kezUpL.js} +4 -6
  116. package/dist/web/server/assets/{use-resource-DVzK0toP.js → use-resource-CjcJwn7F.js} +1 -1
  117. package/dist/web/server/assets/{welcome-SNsE49JO.js → welcome-BpmcD-ia.js} +2 -2
  118. package/dist/web/server/assets/{welcome-OiZCAIHZ.js → welcome-Ya8TkL4v.js} +10 -9
  119. package/dist/web/server/server.js +8 -8
  120. package/dist/worker.js +17 -0
  121. package/dist/worker.js.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/web/client/assets/AddProviderDialog-CO_uijWF.js +0 -1
  124. package/dist/web/client/assets/AgentTemplateParts-Dl35c-Ux.js +0 -1
  125. package/dist/web/client/assets/ConfirmDialog-BVytx3kN.js +0 -1
  126. package/dist/web/client/assets/ConnectionsView-DDrBaiLg.js +0 -1
  127. package/dist/web/client/assets/Dialog-BTDzv3J5.js +0 -1
  128. package/dist/web/client/assets/SpawnDialog-ejwXnyxy.js +0 -1
  129. package/dist/web/client/assets/SpawnTeamModal-Cp-nAvIC.js +0 -1
  130. package/dist/web/client/assets/TeamForm-Cz9uDVvb.js +0 -1
  131. package/dist/web/client/assets/TeamThread-D8xqE_gb.js +0 -1
  132. package/dist/web/client/assets/_id-DEQxwq2v.js +0 -1
  133. package/dist/web/client/assets/_id-DSRgpxEc.js +0 -1
  134. package/dist/web/client/assets/access-34_ShgHU.js +0 -1
  135. package/dist/web/client/assets/agent-actions--EO4yJ4Q.js +0 -1
  136. package/dist/web/client/assets/agents-C87yBHaR.js +0 -1
  137. package/dist/web/client/assets/agents-DvCSl1Ro.js +0 -1
  138. package/dist/web/client/assets/api-CoLs57oO.js +0 -1
  139. package/dist/web/client/assets/arrow-right-BhTWtC9z.js +0 -1
  140. package/dist/web/client/assets/attention-CteEeRvX.js +0 -1
  141. package/dist/web/client/assets/chevron-right-BqOIX9UM.js +0 -1
  142. package/dist/web/client/assets/config-XJuQeEP4.js +0 -1
  143. package/dist/web/client/assets/createLucideIcon-dN8ooBD1.js +0 -1
  144. package/dist/web/client/assets/entities-xVoB-p2j.js +0 -1
  145. package/dist/web/client/assets/form-Bvr_f9lR.js +0 -1
  146. package/dist/web/client/assets/index-J_Uqj4md.js +0 -54
  147. package/dist/web/client/assets/login-076Bc601.js +0 -1
  148. package/dist/web/client/assets/manage-CsrV2hhK.js +0 -1
  149. package/dist/web/client/assets/mcp-8N0BqZ0G.js +0 -1
  150. package/dist/web/client/assets/model-facts-DoB6QD5y.js +0 -1
  151. package/dist/web/client/assets/parts-B0JBolvG.js +0 -1
  152. package/dist/web/client/assets/plus-DZ3KVo7E.js +0 -1
  153. package/dist/web/client/assets/routes-3HkZZOOe.js +0 -76
  154. package/dist/web/client/assets/skills-DiaqZRXT.js +0 -1
  155. package/dist/web/client/assets/style-BtcFIkOS.js +0 -7
  156. package/dist/web/client/assets/styles-C7Ztw15K.css +0 -2
  157. package/dist/web/client/assets/system-YWlJ8ogO.js +0 -1
  158. package/dist/web/client/assets/teams-DQwceMvk.js +0 -1
  159. package/dist/web/client/assets/teams-DTC3plIH.js +0 -1
  160. package/dist/web/client/assets/telegram-D4wINntt.js +0 -1
  161. package/dist/web/client/assets/tools-CZeQ9pDx.js +0 -1
  162. package/dist/web/client/assets/use-resource-BaTkTGvG.js +0 -1
  163. package/dist/web/client/assets/welcome-CnxP_RCk.js +0 -1
  164. package/dist/web/client/assets/wrench-BrwBswfo.js +0 -1
  165. package/dist/web/server/assets/Dialog-aup_yJv5.js +0 -85
  166. package/dist/web/server/assets/ModelMenu-BAZeARx6.js +0 -138
  167. package/dist/web/server/assets/SpawnDialog-CYkwzETs.js +0 -124
  168. package/dist/web/server/assets/_tanstack-start-manifest_v-D7RvKGRH.js +0 -285
  169. package/dist/web/server/assets/entities-Dn2xzKIw.js +0 -16
  170. package/dist/web/server/assets/form-BRQAsKKq.js +0 -319
  171. package/dist/web/server/assets/model-facts-mrfrWQne.js +0 -136
  172. package/dist/web/server/assets/parts-mabERIJZ.js +0 -380
  173. package/dist/web/server/assets/routes-IHMVKpDK.js +0 -16
  174. package/dist/web/server/assets/skills-hfTSwqsG.js +0 -353
  175. package/dist/web/server/assets/utils-C_uf36nf.js +0 -8
  176. package/dist/web/server/assets/workspace-DaitCM0t.js +0 -651
  177. /package/dist/web/server/assets/{telegram-CGol0CKX.js → telegram-CGol0CKX2.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bazilion",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Multi-agent runtime CLI — spawn LLM agents, manage profiles/teams/skills, and run the local daemon.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{a as r,i,n as a}from"./api-CoLs57oO.js";import{n as o,t as s}from"./images-BKjyhYUc.js";import{C as c,S as l,T as u,d,v as f,x as p}from"./parts-B0JBolvG.js";import{t as ee}from"./chevron-right-BqOIX9UM.js";import{It as m}from"./index-J_Uqj4md.js";import{r as te}from"./use-resource-BaTkTGvG.js";import{n as h,t as g}from"./Dialog-BTDzv3J5.js";import{a as _,d as v,i as y,l as b,n as ne,o as re,u as x}from"./model-facts-DoB6QD5y.js";var S=e(t(),1),C=n();function w({name:e,tone:t=`neutral`,className:n}){return(0,C.jsx)(`span`,{"aria-hidden":`true`,className:m(`flex size-9 shrink-0 items-center justify-center rounded-xl text-[0.95rem] font-bold`,t===`success`&&`bg-success/10 text-success`,t===`warning`&&`bg-warning/10 text-warning`,t===`accent`&&`bg-accent text-accent-foreground`,t===`neutral`&&`bg-muted text-muted-foreground`,n),children:e.replace(/[^\p{L}\p{N}]/gu,``).slice(0,1)||`?`})}function T({provider:e,now:t}){let n=v(e,t);return(0,C.jsx)(d,{tone:n.tone,children:n.label})}function E({failure:e,children:t}){return(0,C.jsxs)(`div`,{role:`alert`,className:`rounded-2xl border border-warning/35 bg-warning/10 p-4 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,C.jsx)(c,{className:`mt-0.5 size-5 shrink-0 text-warning`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`font-semibold text-foreground`,children:e.title}),(0,C.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:e.hint}),e.detail&&(0,C.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Details`}),(0,C.jsx)(`div`,{className:`mt-1 break-words font-mono`,children:e.detail})]})]})]}),t&&(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:t})]})}function ie({model:e,connect:t,checked:n,disabled:r,onToggle:i,className:a}){return(0,C.jsxs)(`label`,{className:m(`m-0 grid cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 gap-y-0.5 border-b border-border py-2.5 sm:grid-cols-[auto_minmax(0,1.5fr)_minmax(0,1.2fr)_9.5rem]`,a),children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:n,disabled:r,onChange:i,className:`m-0 size-[18px]`}),(0,C.jsxs)(`span`,{className:`min-w-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:b(e)}),e.suggested&&(0,C.jsx)(`span`,{className:`ml-2 rounded-full bg-accent px-2 py-0.5 text-[0.7rem] font-semibold text-accent-foreground`,children:`Suggested`}),e.name&&(0,C.jsx)(`span`,{className:`block break-all font-mono text-[0.72rem] text-muted-foreground`,children:e.id})]}),(0,C.jsx)(`span`,{className:`col-start-2 text-xs text-muted-foreground sm:col-start-auto`,children:y(e,t)}),(0,C.jsx)(`span`,{className:`col-start-2 text-xs text-foreground sm:col-start-auto sm:text-right`,children:x(e,t)})]})}var ae=60;function oe(e){let t={};for(let n of e.fields)t[n.envVar]=n.kind===`config`?n.value??``:``;let n=e.fields.find(e=>e.kind===`config`&&!e.advanced);return e.connect===`local`&&n&&!n.set&&(t[n.envVar]=e.address??``),t}function D(e,t){let n={};for(let r of e.fields){let i=(t[r.envVar]??``).trim();if(r.kind===`secret`)i&&(n[r.envVar]=i);else if(i!==(r.value??``)){if(!r.set&&e.connect===`local`&&i===e.address)continue;n[r.envVar]=i}}return n}function O({provider:e,imageRoutes:t=[],onConnected:n}){let[o,c]=(0,S.useState)(()=>oe(e)),[u,d]=(0,S.useState)(()=>k(e,oe(e))),[m,h]=(0,S.useState)(null),[g,v]=(0,S.useState)([]),[y,x]=(0,S.useState)(``),[w,T]=(0,S.useState)(null),[O,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)(``),[N,P]=(0,S.useState)(`idle`),[F,ce]=(0,S.useState)(e.configured),[I,le]=(0,S.useState)(null),[L,ue]=(0,S.useState)(null),R=(0,S.useRef)(null);(0,S.useEffect)(()=>()=>R.current?.abort(),[]);let z=(0,S.useRef)(null);(0,S.useEffect)(()=>{(I||L)&&z.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[I,L]);let B=te(t=>a(`/api/config/providers/${encodeURIComponent(e.id)}/catalog`,{body:{fields:u},signal:t}),[e.id,JSON.stringify(u)]),V=(0,S.useMemo)(()=>{let t=t=>{let n=e.suggested.indexOf(t.id);return n===-1?e.suggested.length:n},n=[...B.data?.models??[]].sort((e,n)=>t(e)-t(n)),r=new Set(n.map(e=>e.id));return[...n,...g.filter(e=>!r.has(e)).map(e=>({id:e,selected:!1,suggested:!1}))]},[B.data,g,e.suggested]);(0,S.useEffect)(()=>{let e=B.data?.models;e&&(h(t=>t&&[...t].some(t=>e.some(e=>e.id===t))?t:new Set(_(e))),T(t=>t??(e.length<=6||_(e).length===0)))},[B.data]);let H=m??new Set,U=V.filter(e=>H.has(e.id)),W=ne(U),G=N!==`idle`,K=e.connect===`local`,q=e.connect===`signin`,J=e.fields.filter(e=>!e.advanced),de=e.fields.filter(e=>e.advanced),fe=q||e.configured||J.every(e=>e.set||(o[e.envVar]??``).trim().length>0),Y=V.filter(e=>e.suggested||e.selected||H.has(e.id)),X=w===!0,Z=X?V.filter(e=>j?re(e,j):!e.dated||H.has(e.id)):Y,Q=Z.slice(0,ae);function pe(e){h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function me(){let e=y.trim();e&&(v(t=>t.includes(e)?t:[...t,e]),h(t=>new Set(t).add(e)),x(``))}async function he(t){R.current?.abort();let r=new AbortController;R.current=r,le(null),ue(null);try{q&&!F&&(P(`signin`),await a(`/api/auth/openai/login`,{method:`POST`,signal:r.signal}),ce(!0)),P(`connecting`);let i={fields:D(e,o),models:U.map(e=>e.id),...t&&U.length>0?{}:{test:!1}},s=await a(`/api/config/providers/${encodeURIComponent(e.id)}/connect`,{body:i,signal:r.signal});if(r.signal.aborted)return;s.connected?await n(s):le(s.failure)}catch(e){r.signal.aborted||ue(i(e))}finally{R.current===r&&P(`idle`)}}let $=`No chat model is ticked, so nothing is tested.`;if(U.length>0){let e=W?b(W):`a model`,t=W?.price?`cheapest`:`first`,n=U.length>1?`${e}, the ${t} one ticked`:e;$=q&&!F?`After the sign-in, one short message goes to ${n}.`:`The test sends one short message to ${n}.`,W?.price&&!q&&($+=` It costs a fraction of a cent.`)}return(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),he(!0)},className:`grid gap-4`,children:[e.hint&&(0,C.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.hint}),q&&(0,C.jsx)(`p`,{className:`m-0 rounded-xl border border-border bg-muted/40 p-3 text-sm text-muted-foreground`,children:F?`You are signed in with ChatGPT. Bazilion renews the sign-in by itself.`:`A browser tab opens on the machine Bazilion runs on, and you sign in with your ChatGPT account there. On another machine, run bazilion auth openai login --device-code on it instead.`}),J.map((t,n)=>(0,C.jsx)(se,{field:t,value:o[t.envVar]??``,disabled:G,autoFocus:n===0&&!K,onChange:e=>c(n=>({...n,[t.envVar]:e})),onCommit:K?()=>d(k(e,o)):void 0},t.envVar)),de.length>0&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`button`,{type:`button`,"aria-expanded":O,onClick:()=>A(e=>!e),className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[(0,C.jsx)(ee,{className:`size-4 text-muted-foreground transition-transform ${O?`rotate-90`:``}`,"aria-hidden":`true`}),`More settings`]}),O&&(0,C.jsx)(`div`,{className:`mt-2 grid gap-3 rounded-xl border border-border bg-muted/40 p-3`,children:de.map(e=>(0,C.jsx)(se,{field:e,value:o[e.envVar]??``,disabled:G,onChange:t=>c(n=>({...n,[e.envVar]:t}))},e.envVar))})]}),(0,C.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,children:[(0,C.jsxs)(`legend`,{className:`mb-2 flex w-full flex-wrap items-baseline gap-x-2 p-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`Models your Agents can use`}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:K?`What the server reports. You can change this later.`:`${V.length} available. You can change this later.`})]}),K&&B.data?.listError&&(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3 rounded-xl border border-warning/35 bg-warning/10 px-3 py-2 text-sm`,children:[(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Nothing answers at `,o[J[0]?.envVar??``]||`that address`,`. Start`,` `,e.displayName,` and switch its server on.`]}),(0,C.jsx)(r,{variant:`ghost`,disabled:B.loading,onClick:()=>{d(k(e,o)),B.reload()},children:B.loading?`Looking…`:`Look again`})]}),X&&V.length>8&&(0,C.jsx)(f,{label:`Search ${e.displayName} models`,placeholder:`Search by name`,value:j,onChange:M,className:`mb-2`}),X&&V.length>8&&U.length>0&&(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Ticked:`}),U.map(e=>(0,C.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>pe(e.id),"aria-label":`Untick ${b(e)}`,className:`inline-flex items-center gap-1 rounded-full bg-accent px-2.5 py-1 font-semibold text-accent-foreground`,children:[b(e),(0,C.jsx)(l,{className:`size-3`,"aria-hidden":`true`})]},e.id))]}),(0,C.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-xl border border-border`,children:[B.loading&&!B.data&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`Reading the model list…`}),B.error&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-danger`,children:B.error}),B.data&&Q.length===0&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:j?`No model matches.`:K?`The server lists no model yet.`:`No models are listed for this provider. Add one by its id below.`}),Q.map(t=>(0,C.jsx)(ie,{model:t,connect:e.connect,checked:H.has(t.id),disabled:G,onToggle:()=>pe(t.id),className:`px-3 last:border-b-0`},t.id)),Z.length>Q.length&&(0,C.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[Z.length-Q.length,` more: search to narrow them down.`]})]}),(0,C.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-2`,children:[!X&&V.length>Y.length&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>T(!0),className:`text-sm font-semibold text-primary`,children:[`See all `,V.length]}),X&&!K&&(0,C.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-64 items-center gap-2`,children:[(0,C.jsx)(`input`,{type:`text`,"aria-label":`A model id that is not listed`,placeholder:`A model id that is not listed`,value:y,disabled:G,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},className:`min-h-10 font-mono text-sm`}),(0,C.jsx)(r,{variant:`ghost`,disabled:G||!y.trim(),onClick:me,children:`Add`})]})]})]}),t.length>0&&(0,C.jsxs)(`p`,{className:`m-0 flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`span`,{children:[q?`The same sign-in`:`The same key`,` makes`,` `,[...new Set(t.map(e=>e.model))].join(` and `),` available under Images.`]})]}),(0,C.jsxs)(`div`,{ref:z,className:`grid gap-3 empty:hidden`,children:[I&&(0,C.jsx)(E,{failure:I}),L&&(0,C.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:L})]}),G?(0,C.jsx)(p,{children:N===`signin`?`Waiting for the ChatGPT sign-in in the browser…`:W?`Asking ${b(W)} for a short reply…`:`Saving…`}):(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,C.jsx)(r,{variant:`primary`,type:`submit`,disabled:!fe||K&&U.length===0,children:q&&!F?`Sign in with ChatGPT`:U.length===0?`Connect`:`Connect and test`}),U.length>0&&!(q&&!F)&&(0,C.jsx)(`button`,{type:`button`,disabled:!fe,onClick:()=>void he(!1),className:`text-sm font-semibold text-primary disabled:opacity-50`,children:`Save without testing`})]}),(0,C.jsx)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:$})]})]})}function k(e,t){if(e.connect!==`local`)return{};let n=D(e,t);return Object.fromEntries(Object.entries(n).filter(([t])=>e.fields.some(e=>e.envVar===t&&e.kind===`config`)))}function se({field:e,value:t,disabled:n,autoFocus:r=!1,onChange:i,onCommit:a}){let o=e.kind===`secret`;return(0,C.jsxs)(`label`,{className:`m-0 text-sm font-semibold text-foreground`,children:[e.label,(0,C.jsx)(`input`,{type:o?`password`:`text`,value:t,disabled:n,autoFocus:r,autoComplete:`off`,spellCheck:!1,placeholder:o&&e.set?`Saved. Paste another to replace it.`:e.placeholder??``,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a&&(e.preventDefault(),a())},className:`mt-1.5 font-mono font-normal`}),(e.description||o)&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs font-normal text-muted-foreground`,children:e.description??`Stored encrypted on the machine Bazilion runs on. It is never shown again.`})]})}function A(e){try{return new URL(e).host}catch{return e}}function j(e,t){if(!e)return t?`Looking…`:`A model server on this computer`;if(!e.found)return`Nothing at ${A(e.address)}`;let n=e.models.length;return`Running at ${A(e.address)}, ${n===1?`1 model`:`${n} models`}`}function M(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.id,e.hint??``].some(e=>e.toLowerCase().includes(n)):!0}function N({providers:e,expanded:t=!1,onPick:n}){let[r,i]=(0,S.useState)(``),[o,s]=(0,S.useState)(t),c=te(e=>a(`/api/config/providers/local`,{signal:e}),[]),l=(0,S.useMemo)(()=>Date.now(),[]),d=e.filter(e=>M(e,r)),p=e=>d.filter(t=>t.group===e),m=p(`more`),h=r.trim().length>0,g=e=>{let t=c.data?.servers.find(t=>t.id===e.id),r=e.group===`local`&&t?.found,i=e.listed?v(e,l).label:e.group===`local`?j(t,c.loading):e.hint??e.id;return(0,C.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`flex min-h-16 min-w-0 items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-2.5 text-left transition-colors hover:border-primary/40 hover:bg-accent/40`,children:[(0,C.jsx)(w,{name:e.displayName,tone:e.listed||r?`success`:`neutral`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,C.jsx)(`span`,{className:`line-clamp-2 text-xs leading-snug ${e.listed||r?`text-success`:`text-muted-foreground`}`,children:i})]}),e.listed?(0,C.jsx)(u,{className:`size-4 shrink-0 text-success`,"aria-hidden":`true`}):(0,C.jsx)(ee,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)},_=(e,t)=>t.length>0&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`m-0 mb-2 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:e}),(0,C.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:t.map(g)})]});return(0,C.jsxs)(`div`,{className:`grid gap-4`,children:[(0,C.jsx)(f,{label:`Search providers`,placeholder:`Search ${e.length} providers`,value:r,onChange:i}),_(`Most used`,p(`popular`)),_(`On this computer`,p(`local`)),(h||o)&&_(`More`,m),d.length===0&&(0,C.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`No provider matches “`,r,`”.`]}),!h&&!o&&m.length>0&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`justify-self-start text-sm font-semibold text-primary`,children:[`Show `,m.length,` more:`,` `,m.slice(0,4).map(e=>e.displayName).join(`, `),`…`]})]})}function P({result:e,imageRoutes:t}){let{provider:n,check:r,dropped:i,movedTemplates:a}=e,o=n.models.length,s=[...new Set(t.map(e=>e.model))];return(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-4`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-11 shrink-0 items-center justify-center rounded-full ${r?`bg-success/10 text-success`:`bg-muted text-muted-foreground`}`,children:(0,C.jsx)(u,{className:`size-6`})}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm`,children:[(0,C.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:r?`${n.displayName} is connected`:`${n.displayName} is saved, not tested`}),(0,C.jsxs)(`ul`,{className:`m-0 mt-1 list-none space-y-0.5 p-0 text-muted-foreground`,children:[r&&(0,C.jsxs)(`li`,{children:[r.modelName??r.model,` answered in `,((r.ms??0)/1e3).toFixed(1),` s.`]}),(0,C.jsxs)(`li`,{children:[o===0?`No chat model is in use from it.`:o===1?`1 model is in Chat.`:`${o} models are in Chat.`,!r&&o>0&&` Test it from its row before you rely on it.`]}),i.map(e=>(0,C.jsxs)(`li`,{className:`text-warning`,children:[e.model,` was left out: this account cannot use it.`]},e.model)),s.length>0&&(0,C.jsxs)(`li`,{children:[s.join(` and `),` can now be chosen under Images.`]}),a.map(e=>(0,C.jsxs)(`li`,{children:[`The `,e.name,` template now uses `,e.model,`.`]},e.id))]})]})]})}function F({providers:e,imageRoutes:t,start:n,onClose:i,onConnected:a,onOpenProvider:s}){let[c,l]=(0,S.useState)(n&&e.some(e=>e.id===n)?n:null),[u,d]=(0,S.useState)(null),f=e.find(e=>e.id===c)??null,p=e=>t.filter(t=>t.provider===e);return u?(0,C.jsxs)(g,{title:u.provider.displayName,onClose:i,className:`max-w-xl`,children:[(0,C.jsx)(P,{result:u,imageRoutes:p(u.provider.id)}),(0,C.jsx)(h,{children:(0,C.jsx)(r,{variant:`primary`,onClick:i,children:`Done`})})]}):f?(0,C.jsxs)(g,{title:`Connect ${f.displayName}`,onClose:i,className:`top-[6dvh] max-h-[88dvh] max-w-2xl translate-y-0 content-start`,children:[!n&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>l(null),className:`-mt-1 flex items-center gap-1 justify-self-start text-sm font-semibold text-primary`,children:[(0,C.jsx)(o,{className:`size-4`,"aria-hidden":`true`}),`All providers`]}),(0,C.jsx)(O,{provider:f,imageRoutes:p(f.id).filter(e=>!e.ready),onConnected:async e=>{await a(),d(e)}},f.id)]}):(0,C.jsx)(g,{title:`Add a provider`,onClose:i,className:`top-[6dvh] max-h-[88dvh] max-w-2xl translate-y-0 content-start`,children:(0,C.jsx)(N,{providers:e,onPick:e=>e.listed?s(e.id):l(e.id)})})}export{O as a,w as c,A as i,T as l,P as n,E as o,N as r,ie as s,F as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,r as n,u as r}from"./createLucideIcon-dN8ooBD1.js";import{a as i,i as a,n as o}from"./api-CoLs57oO.js";import{g as s}from"./parts-B0JBolvG.js";import{r as c}from"./SpawnDialog-ejwXnyxy.js";import{n as l,t as u}from"./Dialog-BTDzv3J5.js";import{l as d,n as f,t as p}from"./form-Bvr_f9lR.js";import{S as m,x as h}from"./manage-CsrV2hhK.js";var g=e(t(),1),_=r(),v=[{key:`soul`,name:`SOUL.md`,hint:`Persona, values and operating principles. Part of every session.`,optional:!1},{key:`identity`,name:`IDENTITY.md`,hint:`Name, creature, vibe, emoji and avatar: filled in during the first conversation.`,optional:!1},{key:`bootstrap`,name:`BOOTSTRAP.md`,hint:`The first-run ritual in which the Agent introduces itself; it retires the file once done.`,optional:!0},{key:`agents`,name:`AGENTS.md`,hint:`How the Agent works in its workspace: memory, red lines, who it hands work to.`,optional:!0},{key:`tools`,name:`TOOLS.md`,hint:`Notes on its tools and environment beyond the tool descriptions.`,optional:!0}],y=[{value:`all`,label:`All skills`,hint:`Every installed skill, including ones imported later.`},{value:`selected`,label:`Chosen skills`,hint:`Only the ones ticked below.`}];function b({mode:e,picked:t,skills:n,disabled:r,onModeChange:i,onPickedChange:a}){return(0,_.jsxs)(`div`,{className:`grid gap-3`,children:[(0,_.jsx)(f,{legend:`Skills at spawn`,name:`template-skills`,value:e,options:y,disabled:r,onChange:i}),e===`selected`&&(n.length===0?(0,_.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`No skills are installed yet. Import some under `,(0,_.jsx)(`a`,{href:`/skills`,children:`Skills`}),`.`]}):(0,_.jsxs)(`fieldset`,{className:`m-0 grid max-h-64 min-w-0 gap-2.5 overflow-y-auto rounded-xl border border-border bg-muted/30 p-3.5`,children:[(0,_.jsx)(`legend`,{className:`sr-only`,children:`Chosen skills`}),n.map(e=>(0,_.jsx)(p,{checked:t.has(e.name),disabled:r,label:(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-mono text-[0.9em] font-semibold`,children:e.name}),e.description&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.description]})]}),onChange:n=>{let r=new Set(t);n?r.add(e.name):r.delete(e.name),a(r)}},e.name))]})),(0,_.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:`Each Agent can still attach or detach skills after it is spawned.`})]})}function x({chat:e,skills:t,starter:r,onClose:f}){let y=n(),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(``),[k,A]=(0,g.useState)(`all`),[j,M]=(0,g.useState)(new Set),[N,P]=(0,g.useState)({soul:!0,identity:!0,bootstrap:!0,agents:!0,tools:!0}),[F,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(null),z=T?C:m(x),B=h(z),V=z!==``&&!B&&D!==``;async function H(e){if(e.preventDefault(),!(!V||F)){I(!0),R(null);try{await o(`/api/profiles`,{body:{id:z,name:x.trim()||void 0,defaultModel:D,skillsMode:k,defaultSkills:k===`selected`?[...j]:[],soul:r.soul,identity:r.identity,bootstrap:N.bootstrap?r.bootstrap:null,agents:N.agents?r.agents:null,tools:N.tools?r.tools:null}}),await y({to:`/templates/agents/$id`,params:{id:z}})}catch(e){R(a(e)),I(!1)}}}return(0,_.jsx)(u,{title:`New Agent template`,description:`It starts from the built-in files, which you can edit next. Agents spawned from it get their own copies.`,busy:F,onClose:f,className:`max-w-xl`,children:(0,_.jsxs)(`form`,{onSubmit:e=>void H(e),className:`grid gap-4`,children:[(0,_.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,_.jsx)(d,{label:`Name`,value:x,disabled:F,placeholder:`Writer`,className:`max-w-none`,onChange:S}),(0,_.jsx)(d,{label:`ID`,value:z,disabled:F,placeholder:`writer`,mono:!0,className:`max-w-none`,problem:B,onChange:e=>{E(!0),w(e)}})]}),(0,_.jsx)(c,{kit:!0,label:`Default model`,value:D,onChange:O,models:e,required:!0}),e.length===0&&(0,_.jsxs)(s,{tone:`warning`,children:[`No chat model is in use yet. Add one under `,(0,_.jsx)(`a`,{href:`/config`,children:`Setup → Models`}),` first.`]}),(0,_.jsx)(b,{mode:k,picked:j,skills:t,disabled:F,onModeChange:A,onPickedChange:M}),(0,_.jsxs)(`fieldset`,{className:`m-0 grid min-w-0 gap-2.5 border-0 p-0`,children:[(0,_.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`Files`}),(0,_.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:`SOUL.md and IDENTITY.md are always there. These three can be left out:`}),v.filter(e=>e.optional).map(e=>(0,_.jsx)(p,{checked:N[e.key],disabled:F,label:(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-mono text-[0.9em] font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.hint]})]}),onChange:t=>P(n=>({...n,[e.key]:t}))},e.key))]}),L&&(0,_.jsx)(s,{tone:`warning`,role:`alert`,title:`The template was not created.`,children:L}),(0,_.jsxs)(l,{children:[(0,_.jsx)(i,{variant:`ghost`,disabled:F,onClick:f,children:`Cancel`}),(0,_.jsx)(i,{variant:`primary`,type:`submit`,disabled:F||!V,children:F?`Creating…`:`Create and edit its files`})]})]})})}export{b as n,v as r,x as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{a as r,i}from"./api-CoLs57oO.js";import{n as a,t as o}from"./Dialog-BTDzv3J5.js";var s=e(t(),1),c=n();function l({open:e,title:t,description:n,confirmLabel:l,confirmVariant:u=`danger`,onConfirm:d,onOpenChange:f}){let[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null);(0,s.useEffect)(()=>{e||(m(!1),g(null))},[e]);async function _(){m(!0),g(null);try{await d(),f(!1)}catch(e){g(i(e)),m(!1)}}return(0,c.jsxs)(o,{open:e,busy:p,onClose:()=>f(!1),title:t,description:n,className:`max-w-md`,children:[h&&(0,c.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger/10 px-3 py-2 text-sm text-danger`,children:h}),(0,c.jsxs)(a,{children:[(0,c.jsx)(r,{variant:`ghost`,disabled:p,onClick:()=>f(!1),children:`Cancel`}),(0,c.jsx)(r,{variant:u,disabled:p,onClick:()=>void _(),children:p?`Working…`:l})]})]})}export{l as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,n,o as r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{t as a}from"./UnsavedChangesGuard-DmT4nBQU.js";import{a as o,i as s,n as c}from"./api-CoLs57oO.js";import{t as l}from"./arrow-right-BhTWtC9z.js";import{c as u,f as d,h as f,i as p,n as m,t as h,u as g}from"./TeamThread-D8xqE_gb.js";import{C as _,_ as v,b as ee,c as y,d as te,f as b,g as x,h as S,i as C,l as w,n as T,o as E,r as D,s as O,t as k,u as A,v as ne,y as re}from"./style-BtcFIkOS.js";import{t as j}from"./message-square-DnpSOYv4.js";import{A as M,b as N}from"./index-J_Uqj4md.js";import{r as P}from"./use-resource-BaTkTGvG.js";import{t as ie}from"./ConfirmDialog-BVytx3kN.js";import{t as F}from"./Segmented-Co4n2C5X.js";var I=e(t(),1),L=i(),ae=`!size-2.5 !border-2 !border-snow !bg-sapphire`,R=[{id:`t`,position:A.Top},{id:`r`,position:A.Right},{id:`b`,position:A.Bottom},{id:`l`,position:A.Left}];function z(){return(0,L.jsx)(L.Fragment,{children:R.map(e=>(0,L.jsx)(C,{id:e.id,type:`source`,position:e.position,className:ae},e.id))})}function oe({data:e,selected:t}){let{member:n}=e;return(0,L.jsxs)(`div`,{className:`w-[210px] rounded-2xl border bg-snow px-3 py-2.5 shadow-baziu-sm transition-shadow ${t?`border-sapphire shadow-baziu-md`:`border-frost`}`,children:[(0,L.jsx)(z,{}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,L.jsx)(N,{identity:n.identity,size:34}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:n.name}),(0,L.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[0.7rem] ${n.isolated?`font-semibold text-warning`:`text-mocha`}`,children:[(0,L.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${u[n.state.kind]}`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:n.isolated?`No connections`:n.state.text})]})]})]})]})}function B({selected:e}){return(0,L.jsxs)(`div`,{className:`w-[160px] rounded-2xl border border-dashed bg-ivory px-3 py-2.5 ${e?`border-sapphire`:`border-fawn`}`,children:[(0,L.jsx)(z,{}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(_,{className:`size-4 shrink-0 text-rose-baziu`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:`Other teams`})]})]})}var V={member:oe,outside:B},H=(e,t)=>`pair:${p(e,t)}`;function se(e){if(!e?.startsWith(`pair:`))return null;let[t,n]=e.slice(5).split(`|`);return t&&n?[t,n]:null}var U={member:{w:210,h:62},outside:{w:160,h:46}};function W(e,t){let n=e=>U[e.type===`outside`?`outside`:`member`],r=t.position.x+n(t).w/2-(e.position.x+n(e).w/2),i=t.position.y+n(t).h/2-(e.position.y+n(e).h/2);return Math.abs(r)>=Math.abs(i)*1.4?r>0?{from:`r`,to:`l`}:{from:`l`,to:`r`}:i>0?{from:`b`,to:`t`}:{from:`t`,to:`b`}}function ce({document:e,members:t,traffic:n,selectedId:r,onSelect:i,onConnect:a,onMove:o,onOpenMember:s}){let c=(0,I.useMemo)(()=>{let e=Math.max(520,...t.map(e=>e.position.x+270)),n=t.length===0?120:t.reduce((e,t)=>e+t.position.y,0)/t.length;return[...t.map(e=>({id:e.id,type:`member`,position:e.position,data:{member:e},ariaLabel:`${e.name}: ${e.isolated?`no connections`:e.state.text}`,selected:r===e.id,deletable:!1})),{id:b,type:`outside`,position:{x:e,y:n},data:{},ariaLabel:`Agents in other teams`,selected:r===b,draggable:!1,deletable:!1}]},[t,r]),[l,u,d]=O(c);(0,I.useEffect)(()=>{u(e=>{let t=new Map(e.map(e=>[e.id,e]));return c.map(e=>{let n=t.get(e.id);return n?.dragging?{...e,position:n.position}:e})})},[c,u]);let f=(0,I.useMemo)(()=>{let t=[],i=new Map(l.map(e=>[e.id,e])),a=[...i.keys()];for(let o=0;o<a.length;o++)for(let s=o+1;s<a.length;s++){let[c,l]=[a[o],a[s]].sort(),u=x(e,c,l),d=x(e,l,c),f=H(c,l),p=n.get(f)??0;if(!u&&!d&&p===0)continue;let m=W(i.get(c),i.get(l)),h=u||d,g=r===f,_=g?`var(--color-sapphire-deep)`:h?`var(--color-sapphire)`:`var(--color-fawn)`,v={type:w.ArrowClosed,width:16,height:16,color:_};t.push({id:f,source:c,target:l,sourceHandle:m.from,targetHandle:m.to,selected:g,...u?{markerEnd:v}:{},...d?{markerStart:v}:{},style:{stroke:_,strokeWidth:g?2.6:1.8,...h?{}:{strokeDasharray:`5 5`}},...p>0?{label:`${p} message${p===1?``:`s`}`,labelStyle:{fontSize:11,fontWeight:600,fill:`var(--color-mocha)`},labelBgStyle:{fill:`var(--color-snow)`,stroke:`var(--color-frost)`},labelBgPadding:[6,3],labelBgBorderRadius:8}:{},interactionWidth:24})}return t},[l,e,n,r]);return(0,L.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,L.jsxs)(E,{nodes:l,edges:f,nodeTypes:V,connectionMode:y.Loose,onConnect:e=>{e.source&&e.target&&e.source!==e.target&&a(e.source,e.target)},onNodesChange:d,onNodeClick:(e,t)=>i(t.id),onNodeDoubleClick:(e,t)=>{t.type===`member`&&s(t.id)},onEdgeClick:(e,t)=>i(t.id),onPaneClick:()=>i(null),onNodeDragStop:(e,t)=>{t.type===`member`&&o(t.id,t.position)},deleteKeyCode:null,minZoom:.35,maxZoom:1.6,edgesReconnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1},proOptions:{hideAttribution:!0},className:`policy-flow`,children:[(0,L.jsx)(k,{variant:T.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,L.jsx)(D,{position:`bottom-left`,showInteractive:!1,className:`!overflow-hidden !rounded-md !border !border-frost !bg-snow !shadow-baziu-sm [&_button]:!border-frost [&_button]:!bg-snow [&_button]:!fill-chocolate`})]})})}var le={open:`Members message each other freely. A connection only matters for reaching other Teams.`,restricted:`A member can message a teammate only along a connection.`};function ue(e,t){if(t===1)return{x:220,y:140};let n=Math.max(135,t*38),r=e/t*2*Math.PI-Math.PI/2;return{x:Math.round(40+n*1.3*(1+Math.cos(r))),y:Math.round(40+n*(1+Math.sin(r)))}}var G=(e,t)=>e.has(t)?t:b,K=e=>`bz_map_${e}`;function de(e){try{let t=JSON.parse(window.localStorage.getItem(K(e))??`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function q({team:e}){let t=P(t=>c(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:t}),[e.id]);return t.error?(0,L.jsx)(g,{view:`connections`,children:(0,L.jsx)(`p`,{role:`alert`,className:`err m-4`,children:t.error})}):t.data?(0,L.jsx)(J,{team:e,policy:t.data},e.id):(0,L.jsx)(g,{view:`connections`,children:(0,L.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the connections…`})})}function J({team:e,policy:t}){let{agentById:n,search:i}=d(),l=M(),u=r(),p=m(e.id,300),[_,y]=(0,I.useState)(()=>v(t)),[x,C]=(0,I.useState)(_),[w,T]=(0,I.useState)(`map`),[E,D]=(0,I.useState)(null),[O,k]=(0,I.useState)({}),[A,j]=(0,I.useState)(!1),[N,P]=(0,I.useState)(null),[ae,R]=(0,I.useState)(!1),z=!re(_,x);(0,I.useEffect)(()=>k(de(e.id)),[e.id]);let oe=(t,n)=>{k(r=>{let i={...r,[t]:n};try{window.localStorage.setItem(K(e.id),JSON.stringify(i))}catch{}return i})},B=(0,I.useMemo)(()=>x.members.filter(e=>e.status!==`archived`),[x.members]),V=(0,I.useMemo)(()=>new Set(B.map(e=>e.key)),[B]),U=B.map((e,t)=>({id:e.key,name:e.name,identity:n(e.key)?.identity,state:l.stateOf(e.key),isolated:x.mode===`restricted`&&!x.edges.some(t=>t.from===e.key||t.to===e.key),position:O[e.key]??ue(t,B.length)})),W=e=>G(V,e),q=p.data,J=(0,I.useMemo)(()=>{let e=new Map;for(let t of q??[]){let n=G(V,t.fromAgentId),r=G(V,t.toAgentId);if(n===r)continue;let i=H(n,r);e.set(i,(e.get(i)??0)+1)}return e},[q,V]),Y=(e,t,n)=>{P(null),C(r=>ee(r,e,t,n))};async function me(){j(!0),P(null);try{let t=v(await c(`/api/teams/${encodeURIComponent(e.id)}/policy`,{method:`PATCH`,body:{mode:x.mode,edges:ne(x)}}));y(t),C(t),P({error:!1,text:`Saved. It applies to the next message an Agent sends.`}),await u.invalidate()}catch(e){P({error:!0,text:s(e)})}finally{j(!1)}}let X=se(E),Z=E&&(V.has(E)||E===b)?E:null,Q=(e,t)=>W(e.fromAgentId)===t||W(e.toAgentId)===t,$=q??[],he=X?$.filter(e=>Q(e,X[0])&&Q(e,X[1])):Z?$.filter(e=>Q(e,Z)):$;return(0,L.jsxs)(g,{view:`connections`,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{label:`How members reach each other`,value:x.mode,options:[{id:`open`,label:`Open`},{id:`restricted`,label:`Restricted`}],onChange:e=>{P(null),C(t=>({...t,mode:e}))}}),(0,L.jsx)(F,{label:`Show as`,value:w,options:[{id:`map`,label:`Map`},{id:`matrix`,label:`Table`}],onChange:T}),(0,L.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!z||A,onClick:()=>R(!0),children:`Discard`}),(0,L.jsxs)(o,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!z||A,onClick:()=>void me(),children:[(0,L.jsx)(f,{className:`size-3.5`,"aria-hidden":`true`}),A?`Saving…`:`Save`]})]}),children:[(0,L.jsx)(a,{when:z,subject:`connection changes`}),(0,L.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_23rem]`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col max-lg:h-[52vh]`,children:[(0,L.jsx)(`p`,{className:`m-0 border-b border-border px-3 py-1.5 text-xs ${N?.error?`text-danger`:z?`text-warning`:`text-mocha`}`,role:N?.error?`alert`:`status`,children:N?.text??(z?`Unsaved changes. `:``)+le[x.mode]+(w===`map`?` Drag from one Agent to another to connect them.`:``)}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:B.length===0?(0,L.jsx)(`p`,{className:`m-0 p-6 text-center text-sm text-muted-foreground`,children:`This Team has no members to connect yet.`}):w===`map`?(0,L.jsx)(ce,{document:x,members:U,traffic:J,selectedId:E,onSelect:D,onConnect:(e,t)=>{Y(e,t,!0),D(H(e,t))},onMove:oe,onOpenMember:e=>void u.navigate({to:`/`,search:{agent:e,panel:`connections`}})}):(0,L.jsx)(te,{document:{...x,members:B},selectedId:E,onSelect:D,onToggle:Y})})]}),(0,L.jsxs)(`aside`,{"aria-label":`About the selection`,className:`min-h-0 overflow-y-auto border-border p-3.5 max-lg:border-t lg:border-l`,children:[X?(0,L.jsx)(fe,{document:x,pair:X,onToggle:Y,onClear:()=>D(null)}):Z?(0,L.jsx)(pe,{document:x,actor:Z,others:[...B.map(e=>e.key),b].filter(e=>e!==Z),panel:i.panel,onToggle:Y,onSelectPair:e=>D(H(Z,e))}):(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[B.length,` member`,B.length===1?``:`s`,` ·`,` `,x.mode===`open`?`open Team`:`restricted Team`]}),(0,L.jsx)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:`Select an Agent to choose who it can message, or a line to see what two Agents said to each other. You can always talk to every Agent, and every Agent can always reach you.`})]}),(0,L.jsx)(`h2`,{className:`m-0 mb-1.5 mt-5 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:X?`Messages between them`:Z?`Messages of ${S(x,Z)}`:`Recent messages`}),p.error?(0,L.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:p.error}):(0,L.jsx)(h,{messages:he,limit:30,empty:X||Z?`None among the Team’s recent messages.`:`No messages between Agents yet.`})]})]}),(0,L.jsx)(ie,{open:ae,title:`Discard the connection changes?`,description:(0,L.jsx)(`p`,{children:`Every unsaved change is dropped. The saved connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{C(_),D(null),P(null)},onOpenChange:R})]})}function Y({document:e,from:t,to:n,onToggle:r}){let i=x(e,t,n),a=e.mode===`open`&&t!==b&&n!==b;return(0,L.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,onClick:()=>r(t,n,!i),className:`unstyled flex min-h-10 w-full items-center gap-2 rounded-[10px] border px-2.5 py-1.5 text-left text-sm ${i?`border-primary/30 bg-accent/60`:`border-border bg-card hover:bg-muted`}`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:S(e,t)}),(0,L.jsx)(l,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:S(e,n)})]}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs font-semibold ${i?`text-accent-foreground`:`text-muted-foreground`}`,children:i?`Connected`:a?`Open anyway`:`Not connected`})]})}function fe({document:e,pair:[t,n],onToggle:r,onClear:i}){let a=x(e,t,n)||x(e,n,t);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[S(e,t),` and `,S(e,n)]}),(0,L.jsxs)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:[`Each direction is its own connection.`,t===b||n===b?` Reaching another Team also needs that Team to connect its Agent to “Other teams”.`:``]}),(0,L.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,L.jsx)(Y,{document:e,from:t,to:n,onToggle:r}),(0,L.jsx)(Y,{document:e,from:n,to:t,onToggle:r})]}),a&&(0,L.jsx)(`div`,{className:`mt-2.5`,children:(0,L.jsx)(o,{variant:`danger`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>{r(t,n,!1),r(n,t,!1),i()},children:`Disconnect both ways`})})]})}function pe({document:e,actor:t,others:r,panel:i,onToggle:a,onSelectPair:o}){let{agentById:s}=d(),c=M(),l=t===b?void 0:s(t),f=l?c.stateOf(l.id):null;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[t!==b&&(0,L.jsx)(N,{identity:l?.identity,size:34}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`h2`,{className:`m-0 truncate font-body text-sm font-semibold text-foreground`,children:S(e,t)}),f?(0,L.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,L.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${u[f.kind]}`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:f.text})]}):(0,L.jsx)(`p`,{className:`m-0 text-xs text-mocha`,children:`Every Agent that is not in this Team.`})]}),l&&(0,L.jsxs)(n,{to:`/`,search:{agent:l.id,...i?{panel:i}:{panel:`connections`}},className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,L.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`}),`Open`]})]}),(0,L.jsx)(`div`,{className:`mt-3 space-y-3`,children:r.map(n=>(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(n),className:`unstyled mb-1 text-xs font-semibold text-mocha hover:text-sapphire`,children:[`With `,S(e,n)]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(Y,{document:e,from:t,to:n,onToggle:a}),(0,L.jsx)(Y,{document:e,from:n,to:t,onToggle:a})]})]},n))})]})}export{q as ConnectionsView};
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{S as r}from"./parts-B0JBolvG.js";import{$ as i,It as a,J as o,Q as s,X as c,Y as l,Z as u,et as d}from"./index-J_Uqj4md.js";var f=e(t(),1),p=n(),m=typeof document>`u`?f.useEffect:f.useLayoutEffect;function h(e){let t=e.activeElement;return!t||t===e.body||t===e.documentElement||!(`focus`in t)||typeof t.focus!=`function`?null:t}function g(e,t){!e?.isConnected||e.ownerDocument!==t||e.focus({preventScroll:!0})}function _({open:e=!0,onClose:t,busy:n=!1,title:_,description:v,className:y,children:b}){let x=(0,f.useRef)(null),S=(0,f.useRef)(!1);return m(()=>{e&&!S.current&&(x.current=h(document)),S.current=e},[e]),(0,p.jsx)(o,{open:e,onOpenChange:e=>{!e&&!n&&t()},children:(0,p.jsxs)(i,{children:[(0,p.jsx)(s,{className:`fixed inset-0 z-50 bg-chocolate/35 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=open]:fade-in-0`}),(0,p.jsxs)(c,{className:a(`fixed left-1/2 top-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-[16px] border border-frost bg-snow p-5 text-chocolate shadow-baziu-lg outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:p-6`,y),onCloseAutoFocus:e=>{e.preventDefault(),g(x.current,document),x.current=null},onEscapeKeyDown:e=>{n&&e.preventDefault()},onPointerDownOutside:e=>{n&&e.preventDefault()},children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 pr-6`,children:[(0,p.jsx)(d,{className:`font-serif text-xl text-chocolate`,children:_}),v?(0,p.jsx)(u,{asChild:!0,children:(0,p.jsx)(`div`,{className:`text-sm leading-6 text-mocha`,children:v})}):(0,p.jsx)(u,{className:`sr-only`,children:_})]}),b,!n&&(0,p.jsx)(l,{"aria-label":`Close`,className:`absolute right-3 top-3 inline-flex size-8 items-center justify-center rounded-lg text-mocha hover:bg-ivory hover:text-sapphire`,children:(0,p.jsx)(r,{className:`size-4`,"aria-hidden":`true`})})]})]})})}function v({children:e}){return(0,p.jsx)(`div`,{className:`flex flex-col-reverse gap-2 border-t border-frost pt-4 sm:flex-row sm:justify-end`,children:e})}export{v as n,_ as t};
@@ -1 +0,0 @@
1
- import{G as e,J as t,K as n,r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{a,i as o,n as s}from"./api-CoLs57oO.js";import{T as c,g as l}from"./parts-B0JBolvG.js";import{G as u,It as d,K as f,Tt as p,U as m,W as h,_t as g,at as _,ct as v,dt as y,ft as b,gt as x,ht as S,it as C,lt as w,mt as T,nt as E,ot as D,pt as O,q as k,rt as A,st as j,tt as ee,ut as te,vt as M}from"./index-J_Uqj4md.js";import"./entities-xVoB-p2j.js";import{n as N,t as P}from"./Dialog-BTDzv3J5.js";import{c as ne,l as F,s as I}from"./model-facts-DoB6QD5y.js";import{l as L,s as R}from"./form-Bvr_f9lR.js";var z=t(e(),1),B=t(n(),1),V=i(),re=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),ie=`VisuallyHidden`,ae=B.forwardRef((e,t)=>(0,V.jsx)(x.span,{...e,ref:t,style:{...re,...e.style}}));ae.displayName=ie;function oe(e){let t=B.useRef({value:e,previous:e});return B.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function se(e,[t,n]){return Math.min(n,Math.max(t,e))}var ce=[` `,`Enter`,`ArrowUp`,`ArrowDown`],le=[` `,`Enter`],H=`Select`,[U,W,ue]=T(H),[G,de]=S(H,[ue,k]),K=k(),[fe,q]=G(H),[pe,me]=G(H),he=`SelectProvider`;function ge(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[b,x]=B.useState(null),[S,C]=B.useState(null),[T,E]=B.useState(!1),D=v(l),[O,k]=y({prop:r,defaultProp:i??!1,onChange:a,caller:H}),[A,j]=y({prop:o,defaultProp:s,onChange:c,caller:H}),ee=B.useRef(null),te=b?!!h||!!b.closest(`form`):!0,[M,N]=B.useState(new Set),P=w(),ne=Array.from(M).map(e=>e.props.value).join(`;`),F=B.useCallback(e=>{N(t=>new Set(t).add(e))},[]),I=B.useCallback(e=>{N(t=>{let n=new Set(t);return n.delete(e),n})},[]),L={required:m,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:P,value:A,onValueChange:j,open:O,onOpenChange:k,dir:D,triggerPointerDownPosRef:ee,disabled:p,name:u,autoComplete:d,form:h,nativeOptions:M,nativeSelectKey:ne,isFormControl:te};return(0,V.jsx)(f,{..._,children:(0,V.jsx)(fe,{scope:t,...L,children:(0,V.jsx)(U.Provider,{scope:t,children:(0,V.jsx)(pe,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:I,children:dt(g)?g(L):n})})})})}ge.displayName=he;var _e=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,V.jsx)(ge,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,V.jsxs)(V.Fragment,{children:[n,e?(0,V.jsx)(ut,{__scopeSelect:t}):null]})})};_e.displayName=H;var ve=`SelectTrigger`,ye=B.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=K(n),o=q(ve,n),s=o.disabled||r,c=M(t,o.onTriggerChange),l=W(n),u=B.useRef(`touch`),[d,f,p]=ft(e=>{let t=l().filter(e=>!e.disabled),n=pt(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,V.jsx)(m,{asChild:!0,...a,children:(0,V.jsx)(x.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$(o.value)?``:void 0,...i,ref:c,onClick:O(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&h(e)}),onPointerDown:O(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:O(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&ce.includes(e.key)&&(h(),e.preventDefault())})})})});ye.displayName=ve;var be=`SelectValue`,xe=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=q(be,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=M(t,c.onValueNodeChange);b(()=>{l(u)},[l,u]);let f=$(c.value);return(0,V.jsx)(x.span,{...s,asChild:f?!1:s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,V.jsx)(B.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});xe.displayName=be;var Se=`SelectIcon`,Ce=B.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,V.jsx)(x.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Ce.displayName=Se;var we=`SelectPortal`,[Te,Ee]=G(we,{forceMount:void 0}),De=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,V.jsx)(Te,{scope:e.__scopeSelect,forceMount:n,children:(0,V.jsx)(C,{asChild:!0,...r})})};De.displayName=we;var J=`SelectContent`,Oe=B.forwardRef((e,t)=>{let n=Ee(J,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(J,e.__scopeSelect),[o,s]=B.useState();return b(()=>{s(new DocumentFragment)},[]),(0,V.jsx)(te,{present:r||a.open,children:({present:e})=>e?(0,V.jsx)(Ne,{...i,ref:t}):(0,V.jsx)(ke,{...i,fragment:o})})});Oe.displayName=J;var ke=B.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?z.createPortal((0,V.jsx)(Ae,{scope:n,children:(0,V.jsx)(U.Slot,{scope:n,children:(0,V.jsx)(`div`,{ref:t,children:r})})}),i):null});ke.displayName=`SelectContentFragment`;var Y=10,[Ae,X]=G(J),je=`SelectContentImpl`,Me=g(`SelectContent.RemoveScroll`),Ne=B.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,...v}=e,y=q(J,n),[b,x]=B.useState(null),[S,C]=B.useState(null),w=M(t,e=>x(e)),[T,k]=B.useState(null),[j,te]=B.useState(null),N=W(n),[P,ne]=B.useState(!1),F=B.useRef(!1);B.useEffect(()=>{if(b)return ee(b)},[b]),A();let I=B.useCallback(e=>{let[t,...n]=N().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[N,S]),L=B.useCallback(()=>I([T,b]),[I,T,b]);B.useEffect(()=>{P&&L()},[P,L]);let{onOpenChange:R,triggerPointerDownPosRef:z}=y;B.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(z.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(z.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||R(!1),document.removeEventListener(`pointermove`,t),z.current=null};return z.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,R,z]),B.useEffect(()=>{let e=()=>R(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[R]);let[re,ie]=ft(e=>{let t=N().filter(e=>!e.disabled),n=pt(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ae=B.useCallback((e,t,n)=>{let r=!F.current&&!n;(y.value!==void 0&&y.value===t||r)&&(k(e),r&&(F.current=!0))},[y.value]),oe=B.useCallback(()=>b?.focus(),[b]),se=B.useCallback((e,t,n)=>{let r=!F.current&&!n;(y.value!==void 0&&y.value===t||r)&&te(e)},[y.value]),ce=r===`popper`?Le:Fe,le=ce===Le?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,V.jsx)(Ae,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:ae,selectedItem:T,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:L,selectedItemText:j,position:r,isPositioned:P,searchRef:re,children:(0,V.jsx)(E,{as:Me,allowPinchZoom:!0,children:(0,V.jsx)(_,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:O(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,V.jsx)(D,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,V.jsx)(ce,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...le,onPlaced:()=>ne(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:O(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ie(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=N().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>I(t)),e.preventDefault()}})})})})})})});Ne.displayName=je;var Pe=`SelectItemAlignedPosition`,Fe=B.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=q(J,n),o=X(J,n),[s,c]=B.useState(null),[l,u]=B.useState(null),d=M(t,e=>u(e)),f=W(n),p=B.useRef(!1),m=B.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=B.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=se(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=se(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Y*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Y,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Y}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);b(()=>y(),[y]);let[S,C]=B.useState();return b(()=>{l&&C(window.getComputedStyle(l).zIndex)},[l]),(0,V.jsx)(Re,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:B.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,V.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,V.jsx)(x.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Fe.displayName=Pe;var Ie=`SelectPopperPosition`,Le=B.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Y,...a}=e,o=K(n);return(0,V.jsx)(u,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Le.displayName=Ie;var[Re,ze]=G(J,{}),Be=`SelectViewport`,Ve=B.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=X(Be,n),o=ze(Be,n),s=M(t,a.onViewportChange),c=B.useRef(0);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,V.jsx)(U.Slot,{scope:n,children:(0,V.jsx)(x.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:O(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Y*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Ve.displayName=Be;var He=`SelectGroup`,[Ue,We]=G(He),Ge=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=w();return(0,V.jsx)(Ue,{scope:n,id:i,children:(0,V.jsx)(x.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Ge.displayName=He;var Ke=`SelectLabel`,qe=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=We(Ke,n);return(0,V.jsx)(x.div,{id:i.id,...r,ref:t})});qe.displayName=Ke;var Z=`SelectItem`,[Je,Ye]=G(Z),Xe=B.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=q(Z,n),c=X(Z,n),l=s.value===r,[u,d]=B.useState(a??``),[f,p]=B.useState(!1),m=M(t,e=>c.itemRefCallback?.(e,r,i)),h=w(),g=B.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,V.jsx)(Je,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:B.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,V.jsx)(U.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,V.jsx)(x.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:O(o.onFocus,()=>p(!0)),onBlur:O(o.onBlur,()=>p(!1)),onClick:O(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:O(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:O(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:O(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:O(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:O(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(le.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Xe.displayName=Z;var Q=`SelectItemText`,Ze=B.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=q(Q,n),s=X(Q,n),c=Ye(Q,n),l=me(Q,n),[u,d]=B.useState(null),f=M(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=B.useMemo(()=>(0,V.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return b(()=>(h(m),()=>g(m)),[h,g,m]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(x.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?z.createPortal(a.children,o.valueNode):null]})});Ze.displayName=Q;var Qe=`SelectItemIndicator`,$e=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Ye(Qe,n).isSelected?(0,V.jsx)(x.span,{"aria-hidden":!0,...r,ref:t}):null});$e.displayName=Qe;var et=`SelectScrollUpButton`,tt=B.forwardRef((e,t)=>{let n=X(et,e.__scopeSelect),r=ze(et,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return b(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(it,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});tt.displayName=et;var nt=`SelectScrollDownButton`,rt=B.forwardRef((e,t)=>{let n=X(nt,e.__scopeSelect),r=ze(nt,e.__scopeSelect),[i,a]=B.useState(!1),o=M(t,r.onScrollButtonChange);return b(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(it,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});rt.displayName=nt;var it=B.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=X(`SelectScrollButton`,n),o=B.useRef(null),s=W(n),c=B.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return B.useEffect(()=>()=>c(),[c]),b(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,V.jsx)(x.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:O(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:O(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:O(i.onPointerLeave,()=>{c()})})}),at=`SelectSeparator`,ot=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,V.jsx)(x.div,{"aria-hidden":!0,...r,ref:t})});ot.displayName=at;var st=`SelectArrow`,ct=B.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=K(n);return X(st,n).position===`popper`?(0,V.jsx)(h,{...i,...r,ref:t}):null});ct.displayName=st;var lt=`SelectBubbleInput`,ut=B.forwardRef(({__scopeSelect:e,...t},n)=>{let r=q(lt,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=B.useRef(null),m=M(n,p),h=i??``,g=oe(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return B.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,V.jsxs)(x.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...re,...t.style},ref:m,defaultValue:h,children:[$(i)&&!_?(0,V.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});ut.displayName=lt;function dt(e){return typeof e==`function`}function $(e){return e===``||e===void 0}function ft(e){let t=j(e),n=B.useRef(``),r=B.useRef(0),i=B.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=B.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return B.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function pt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=mt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function mt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ht=`/api/config/models`,gt=`:inherited`,_t=`relative flex cursor-pointer select-none items-baseline gap-x-3 rounded-lg py-2 pl-8 pr-3 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground`;function vt({label:e,value:t,onChange:n,models:r,inherited:i,required:a,kit:o=!1}){let s=(0,B.useId)(),c=e=>r.find(t=>t.value===e),l=e=>{let t=c(e);return t?F(t):e},u=c(t),d=t!==``&&!u,f=ne(r),m=r.length===0&&!i;return(0,V.jsxs)(`div`,{className:o?`min-w-0`:`my-[0.6rem]`,children:[(0,V.jsx)(`span`,{id:`${s}-label`,className:o?`mb-1.5 block text-sm font-semibold text-foreground`:`block text-[0.9em] text-mocha`,children:e}),(0,V.jsxs)(_e,{value:t===``?i?gt:``:t,onValueChange:e=>n(e===gt?``:e),required:a,disabled:m,children:[(0,V.jsxs)(ye,{"aria-labelledby":`${s}-label ${s}-value`,className:`flex min-h-[2.65rem] w-full items-center justify-between gap-2 rounded-[var(--radius-md)] border border-frost bg-[color-mix(in_srgb,var(--color-snow)_82%,var(--color-ivory))] px-[0.8rem] py-[0.5rem] text-left text-[0.95em] text-chocolate transition-all focus-visible:border-sapphire focus-visible:bg-snow focus-visible:shadow-[0_0_0_3px_var(--color-sapphire-glow)] disabled:opacity-60 data-[state=open]:border-sapphire`,style:{outline:`none`},children:[(0,V.jsx)(`span`,{id:`${s}-value`,className:`min-w-0 flex-1 truncate`,children:t===``?i?(0,V.jsxs)(V.Fragment,{children:[i.model?l(i.model):i.label,` `,i.model&&(0,V.jsx)(`span`,{className:`ml-1 text-[0.9em] text-mocha-light`,children:i.label.toLowerCase()})]}):(0,V.jsx)(`span`,{className:`text-mocha-light`,children:m?`No chat model yet`:`Pick a model`}):(0,V.jsxs)(V.Fragment,{children:[l(t),` `,(0,V.jsx)(`span`,{className:`ml-1 text-[0.9em] text-mocha-light`,children:u?u.providerName:`not in Chat`})]})}),(0,V.jsx)(Ce,{asChild:!0,children:(0,V.jsx)(p,{className:`size-4 shrink-0 text-mocha-light`,"aria-hidden":`true`})})]}),(0,V.jsx)(De,{children:(0,V.jsxs)(Oe,{position:`popper`,sideOffset:6,className:`z-50 max-h-[min(26rem,var(--radix-select-content-available-height))] w-[max(var(--radix-select-trigger-width),18rem)] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-baziu-lg`,children:[(0,V.jsxs)(Ve,{className:`p-1.5`,children:[i&&(0,V.jsx)(yt,{value:gt,name:i.label,children:i.model?l(i.model):``}),d&&(0,V.jsx)(yt,{value:t,name:t,mono:!0,children:`not in Chat`}),f.map(e=>(0,V.jsxs)(Ge,{children:[(0,V.jsxs)(qe,{className:`flex items-baseline gap-2 px-3 pb-1 pt-2.5 text-[0.68rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:[e.name,e.trouble&&(0,V.jsx)(`span`,{className:`font-semibold normal-case tracking-normal text-warning`,children:e.trouble})]}),e.models.map(e=>(0,V.jsx)(yt,{value:e.value,name:F(e),mono:!e.name,children:I(e)},e.value))]},e.provider)),r.length===0&&(0,V.jsx)(`p`,{className:`m-0 px-3 py-2 text-sm text-muted-foreground`,children:`No chat model is in use yet.`})]}),(0,V.jsx)(`a`,{href:`/config?pick=true`,className:`block border-t border-border px-4 py-2.5 text-sm font-semibold text-primary hover:bg-muted/50`,children:`Add models in Setup`})]})})]})]})}function yt({value:e,name:t,mono:n=!1,children:r}){return(0,V.jsxs)(Xe,{value:e,className:_t,style:{outline:`none`},children:[(0,V.jsx)($e,{className:`absolute left-2.5 top-1/2 -translate-y-1/2`,children:(0,V.jsx)(c,{className:`size-4 text-primary`,"aria-hidden":`true`})}),(0,V.jsx)(Ze,{asChild:!0,children:(0,V.jsx)(`span`,{className:d(`min-w-0 flex-1 break-words`,n?`font-mono text-[0.85em] font-medium`:`font-semibold`),children:t})}),r&&(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r})]})}function bt({profiles:e,teams:t,profileId:n,teamId:i,onClose:c}){let u=r(),[d,f]=(0,B.useState)(n??e.find(e=>e.id==="default")?.id??e[0]?.id??``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(``),[_,v]=(0,B.useState)([]),[y,b]=(0,B.useState)(t.find(e=>e.id===i)?.id??t.find(e=>e.id==="default")?.id??t[0]?.id??``),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),T=t.find(e=>e.id===y)?.policyMode===`restricted`;(0,B.useEffect)(()=>{let e=new AbortController;return s(ht,{signal:e.signal}).then(e=>v(e.chat)).catch(()=>{}),()=>e.abort()},[]);async function E(e){e.preventDefault(),w(null),S(!0);try{let e={profileId:d,teamId:y};p.trim()&&(e.name=p.trim()),h&&(e.model=h);let{agent:t}=await s(`/api/agents`,{body:e});c(),await u({to:`/`,search:{agent:t.id}})}catch(e){w(o(e)),S(!1)}}let D=e.find(e=>e.id===d);return(0,V.jsx)(P,{title:`Spawn an agent`,description:`It starts with its template's files, model and skills, in the Team you choose.`,busy:x,onClose:c,children:(0,V.jsxs)(`form`,{onSubmit:e=>void E(e),className:`grid gap-4`,children:[(0,V.jsx)(R,{label:`Agent template`,value:d,options:e.map(e=>({value:e.id,label:e.name||e.id})),disabled:x,className:`max-w-none`,onChange:f}),(0,V.jsx)(L,{label:`Name`,value:p,disabled:x,placeholder:D?.name||D?.id||`The template’s name`,hint:`Leave it empty to use the template’s name.`,className:`max-w-none`,onChange:m}),(0,V.jsx)(vt,{kit:!0,label:`Model`,value:h,onChange:g,models:_,inherited:{label:`The template’s model`,model:D?.defaultModel}}),(0,V.jsx)(R,{label:`Team`,value:y,options:t.map(e=>({value:e.id,label:e.id==="default"?`${e.name} (default)`:e.name})),disabled:x,className:`max-w-none`,hint:T?`This Team is restricted: the new Agent starts with no connections. Add them under Connections.`:void 0,onChange:b}),C&&(0,V.jsx)(l,{tone:`warning`,role:`alert`,title:`It was not spawned.`,children:C}),(0,V.jsxs)(N,{children:[(0,V.jsx)(a,{variant:`ghost`,disabled:x,onClick:c,children:`Cancel`}),(0,V.jsx)(a,{variant:`primary`,type:`submit`,disabled:x||!d||!y,children:x?`Spawning…`:`Spawn agent`})]})]})})}export{ht as n,vt as r,bt as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{a as r,i,n as a}from"./api-CoLs57oO.js";import{g as o}from"./parts-B0JBolvG.js";import{n as s,t as c}from"./Dialog-BTDzv3J5.js";import{l,n as u,s as d}from"./form-Bvr_f9lR.js";import{S as f,s as p,x as m}from"./manage-CsrV2hhK.js";var h=e(t(),1),g=n();function _({template:e,teams:t,initialTeamId:n=``,onClose:_,onSpawned:v}){let y=t.some(e=>e.id===n),[b,x]=(0,h.useState)(y?`existing`:`new`),[S,C]=(0,h.useState)(y?n:t[0]?.id??``),[w,T]=(0,h.useState)(y?``:n||f(e.name)),[E,D]=(0,h.useState)(e.userMd??``),[O,k]=(0,h.useState)(null),[A,j]=(0,h.useState)(!1),M=b===`existing`?S:w.trim(),N=b===`new`?m(M)??(t.some(e=>e.id===M)?`A Team with this ID exists: choose it under “A Team that exists”.`:void 0):void 0,P=M!==``&&!N&&e.slots.length>0;async function F(t){if(t.preventDefault(),!(!P||A)){j(!0),k(null);try{await a(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{body:{teamId:M,...b===`new`&&E!==(e.userMd??``)?{userMd:E}:{}}}),v(M)}catch(e){k(i(e)),j(!1)}}}return(0,g.jsx)(c,{title:`Spawn ${e.name}`,description:`Creates ${p(e.slots.length,`Agent`)} and ${p(e.edges.length,`connection`)} between them.`,busy:A,onClose:_,className:`max-w-xl`,children:(0,g.jsxs)(`form`,{onSubmit:e=>void F(e),className:`grid gap-4`,children:[(0,g.jsx)(u,{legend:`Into`,name:`spawn-team-target`,value:b,disabled:A,options:[{value:`new`,label:`A new Team`,hint:`It is ${e.policyMode===`restricted`?`restricted: members message each other along connections`:`open: members message each other freely`}, as the template is.`},{value:`existing`,label:`A Team that exists`,hint:`The Agents join it; it keeps its own messaging rules.`}],onChange:x}),b===`new`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l,{label:`ID of the new Team`,value:w,disabled:A,placeholder:`launch`,mono:!0,className:`max-w-none`,problem:N,onChange:T}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{htmlFor:`spawn-team-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,g.jsx)(`textarea`,{id:`spawn-team-user-md`,rows:4,value:E,disabled:A,onChange:e=>D(e.target.value),className:`mt-1.5 font-mono text-[0.85rem] leading-[1.55]`}),(0,g.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`What every Agent of the new Team knows about you. It starts from the template’s.`})]})]}):(0,g.jsx)(d,{label:`Team`,value:S,options:t.map(e=>({value:e.id,label:e.name})),disabled:A,className:`max-w-none`,onChange:C}),e.slots.length===0&&(0,g.jsx)(o,{tone:`warning`,children:`This template has no Agents yet: add some to it first.`}),O&&(0,g.jsx)(o,{tone:`warning`,role:`alert`,title:`The Team was not spawned.`,children:O}),(0,g.jsxs)(s,{children:[(0,g.jsx)(r,{variant:`ghost`,disabled:A,onClick:_,children:`Cancel`}),(0,g.jsx)(r,{variant:`primary`,type:`submit`,disabled:A||!P,children:A?`Spawning…`:`Spawn ${p(e.slots.length,`Agent`)}`})]})]})})}export{_ as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{a as r,i,n as a}from"./api-CoLs57oO.js";import{g as o}from"./parts-B0JBolvG.js";import{n as s}from"./Dialog-BTDzv3J5.js";import{l as c,n as l}from"./form-Bvr_f9lR.js";import{S as u,x as d}from"./manage-CsrV2hhK.js";var f=e(t(),1),p=n();function m(e){let t=e.id.trim(),n=e.folder.trim(),r={},i=d(t);return i&&(r.id=i),e.place===`link`&&n&&!n.startsWith(`/`)&&(r.folder=`The full path of the folder, starting with /.`),!(t!==``&&(e.place===`new`||n!==``))||r.id||r.folder?{body:null,problems:r}:{body:{id:t,...e.name.trim()?{name:e.name.trim()}:{},...e.place===`link`?{link:n}:{}},problems:r}}function h({onCreated:e,onBusyChange:t,extraActions:n}){let[d,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(`new`),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),O=v?g:u(d),k=m({name:d,id:O,place:b,folder:S});function A(e){T(e),t?.(e)}async function j(t){if(t.preventDefault(),!(!k.body||w)){D(null),A(!0);try{await e(await a(`/api/teams`,{body:k.body}))}catch(e){D(i(e))}finally{A(!1)}}}return(0,p.jsxs)(`form`,{onSubmit:e=>void j(e),className:`grid gap-4`,children:[(0,p.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,p.jsx)(c,{label:`Name`,value:d,disabled:w,placeholder:`My project`,className:`max-w-none`,onChange:e=>{h(e),D(null)}}),(0,p.jsx)(c,{label:`ID`,value:O,disabled:w,placeholder:`my-project`,mono:!0,className:`max-w-none`,hint:`Used in commands and addresses; it cannot change later.`,problem:k.problems.id,onChange:e=>{y(!0),_(e),D(null)}})]}),(0,p.jsx)(l,{legend:`Where its files are`,name:`team-place`,value:b,disabled:w,options:[{value:`new`,label:`A new folder`,hint:`Bazilion makes one for it in its home.`},{value:`link`,label:`A project folder`,hint:`Its Agents work in a folder that already exists, such as a code repository.`}],onChange:x}),b===`link`&&(0,p.jsx)(c,{label:`Folder`,value:S,disabled:w,placeholder:`/home/you/projects/my-project`,mono:!0,className:`max-w-none`,hint:`The Team links to it; removing the Team later removes only the link, never the folder.`,problem:k.problems.folder,onChange:C}),E&&(0,p.jsx)(o,{tone:`warning`,role:`alert`,title:`The Team was not created.`,children:E}),(0,p.jsxs)(s,{children:[n?.(w),(0,p.jsx)(r,{variant:`primary`,type:`submit`,disabled:w||!k.body,children:w?`Creating…`:`Create Team`})]})]})}export{h as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,n,o as r,t as i,u as a}from"./createLucideIcon-dN8ooBD1.js";import{a as o,i as s,n as c}from"./api-CoLs57oO.js";import{n as l}from"./download-Dj-1ltZb.js";import{n as u,t as d}from"./images-BKjyhYUc.js";import{t as f}from"./arrow-right-BhTWtC9z.js";import{w as p}from"./parts-B0JBolvG.js";import{t as ee}from"./chevron-right-BqOIX9UM.js";import{t as m}from"./network-BC7rNaOC.js";import{t as h}from"./plus-DZ3KVo7E.js";import{t as te}from"./SpawnDialog-ejwXnyxy.js";import{A as g,B as _,Et as ne,H as v,I as y,L as b,O as x,R as S,St as C,Tt as re,V as w,b as T,k as ie,x as E,yt as D,z as O}from"./index-J_Uqj4md.js";import{n as k,t as ae}from"./entities-xVoB-p2j.js";import{r as A,t as j}from"./use-resource-BaTkTGvG.js";import{n as M,t as N}from"./Dialog-BTDzv3J5.js";import{t as oe}from"./ConfirmDialog-BVytx3kN.js";import{r as P,t as se}from"./agent-actions--EO4yJ4Q.js";import{t as ce}from"./SpawnTeamModal-Cp-nAvIC.js";import{t as le}from"./TeamForm-Cz9uDVvb.js";var F=i(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),I=i(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),L=i(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),R=i(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),z=i(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),B=i(`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`}]]),V=e(t(),1),H=a(),U=(0,V.createContext)(null);function W({value:e,children:t}){let n=(0,V.useMemo)(()=>{let t=new Map(e.agents.map(e=>[e.id,e]));return{...e,agentById:e=>t.get(e),to:t=>({...e.search,...t})}},[e]);return(0,H.jsx)(U.Provider,{value:n,children:t})}function G(){let e=(0,V.useContext)(U);if(!e)throw Error(`useWorkspace needs a WorkspaceProvider`);return e}function K(){return(0,V.useContext)(U)}var q={connections:{label:`Connections`,icon:m},changes:{label:`Changes`,icon:F},files:{label:`Files`,icon:d}};function J({view:e,actions:t,children:r}){let{team:i,agent:a,to:o}=G();return(0,H.jsxs)(`section`,{"aria-label":`${q[e].label} of ${i?.name??`the Team`}`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-[16px] border border-border bg-card shadow-baziu-sm`,children:[(0,H.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-muted/60 px-3 py-2`,children:[(0,H.jsxs)(n,{to:`/`,search:o({view:void 0,result:void 0,panel:e}),className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-[0.82rem] font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,H.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`}),a?a.agent.name:`Back`]}),(0,H.jsx)(`h1`,{className:`m-0 min-w-0 truncate font-display text-[1.2rem] leading-tight text-charcoal`,children:i?.name}),(0,H.jsx)(`nav`,{"aria-label":`Team views`,className:`flex rounded-[12px] border border-border bg-card p-0.5`,children:E.map(t=>{let r=q[t].icon,i=t===e;return(0,H.jsxs)(n,{to:`/`,search:o({view:t}),"aria-current":i?`page`:void 0,className:`inline-flex h-7 items-center gap-1.5 rounded-[9px] px-2.5 text-[0.8rem] font-semibold ${i?`bg-accent text-accent-foreground`:`text-mocha hover:bg-muted hover:text-foreground`}`,children:[(0,H.jsx)(r,{className:`size-3.5`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:i?``:`hidden sm:inline`,children:q[t].label})]},t)})}),t&&(0,H.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:t})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1`,children:r})]})}var Y=`bz_sidebar_open_groups`;function ue(e){document.cookie=`${Y}=${encodeURIComponent(JSON.stringify(e))}; Path=/; Max-Age=31536000; SameSite=Lax`}var X=`flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,Z=`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground`,de={needs:`text-warning`,working:`text-success`,paused:`text-warning`,fresh:`text-accent-foreground`,idle:`text-muted-foreground`},Q={needs:`bg-warning`,working:`bg-success animate-pulse`,paused:`bg-fawn`,fresh:`bg-primary`,idle:`bg-fawn`};function $(e){return[...e].sort((e,t)=>Number(t.id===k)-Number(e.id===k))}function fe({initialOpenGroups:e}){let{agents:t,teams:i,profiles:a,teamTemplates:s,agent:c,team:l,search:u}=G(),d=g(),f=r(),[p,m]=(0,V.useState)(null),[x,C]=(0,V.useState)(void 0),[T,E]=(0,V.useState)(null),[k,A]=(0,V.useState)(!1),[j,M]=(0,V.useState)(!1),[P,F]=(0,V.useState)(null),[I,R]=(0,V.useState)(null),[z,B]=(0,V.useState)(e),U=(0,V.useRef)(null),W=()=>window.requestAnimationFrame(()=>U.current?.focus()),K=[...a].sort((e,t)=>Number(t.id===ae)-Number(e.id===ae)),q=$(i),J=s.find(e=>e.id===T),Y=c?.agent.id??null;return(0,H.jsxs)(`aside`,{className:`flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,H.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border bg-muted/60 px-3 py-2.5`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-[10px] bg-accent text-accent-foreground`,children:(0,H.jsx)(D,{className:`size-4`,"aria-hidden":`true`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold leading-tight text-foreground`,children:`Teams`}),(0,H.jsxs)(`p`,{className:`m-0 truncate text-xs leading-snug text-muted-foreground`,children:[t.length,` agent`,t.length===1?``:`s`,` in `,i.length,` team`,i.length===1?``:`s`]})]})]}),(0,H.jsxs)(_,{modal:!1,children:[(0,H.jsx)(v,{asChild:!0,children:(0,H.jsxs)(`button`,{ref:U,type:`button`,"aria-label":`Create a new Agent or Team`,className:`unstyled group inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground`,children:[(0,H.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`}),`New`,(0,H.jsx)(re,{className:`size-3.5 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":`true`})]})}),(0,H.jsx)(O,{children:(0,H.jsxs)(y,{align:`end`,sideOffset:6,className:`z-50 w-60 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none`,children:[(0,H.jsxs)(S,{className:Z,children:[(0,H.jsx)(ne,{className:`size-3`,"aria-hidden":`true`}),`Agent templates`]}),K.length===0?(0,H.jsx)(b,{asChild:!0,className:X,children:(0,H.jsx)(`a`,{href:`/templates/agents?new=1`,children:`Create an Agent template`})}):K.map(e=>(0,H.jsxs)(b,{className:X,onSelect:()=>{C(l?.id),m(e.id)},children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),e.id==="default"&&(0,H.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-1.5 py-0.5 text-xs font-semibold text-muted-foreground`,children:`Default`})]},e.id)),(0,H.jsx)(w,{className:`my-1.5 h-px bg-border`}),(0,H.jsxs)(S,{className:Z,children:[(0,H.jsx)(D,{className:`size-3`,"aria-hidden":`true`}),`Team templates`]}),s.length===0?(0,H.jsx)(b,{asChild:!0,className:X,children:(0,H.jsx)(`a`,{href:`/templates/teams?new=1`,children:`Create a Team template`})}):s.map(e=>(0,H.jsxs)(b,{className:X,disabled:e.slots.length===0,title:e.slots.length===0?`Add at least one member before spawning`:void 0,onSelect:()=>E(e.id),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,H.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-xs text-muted-foreground`,children:e.slots.length})]},e.id)),(0,H.jsx)(w,{className:`my-1.5 h-px bg-border`}),(0,H.jsxs)(b,{className:X,onSelect:()=>A(!0),children:[(0,H.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`}),`Create a Team`]})]})})]})]}),(0,H.jsxs)(`nav`,{className:`flex-1 overflow-y-auto p-1.5`,"aria-label":`Teams and agents`,children:[t.length===0&&(0,H.jsxs)(`div`,{className:`m-1 mb-2 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center`,children:[(0,H.jsx)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:`No agents yet`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Your default Team is ready. Spawn the first agent to start a conversation.`}),K[0]?(0,H.jsx)(o,{variant:`primary`,className:`mt-3`,onClick:()=>m(K[0]?.id??`default`),children:`Spawn first agent`}):(0,H.jsx)(`a`,{href:`/templates/agents?new=1`,className:`mt-3 text-xs font-semibold`,children:`Create an Agent template`})]}),q.map(e=>{let r=t.filter(t=>t.teamId===e.id),i=l?.id===e.id,a=z[e.id]??(i||e.id==="default"),o=ie(r.map(e=>d.stateOf(e.id)));return(0,H.jsxs)(`details`,{open:a,onToggle:t=>{let n=t.currentTarget.open;if(n===a)return;let r={...z,[e.id]:n};ue(r),B(r)},className:`group/details mb-1 last:mb-0`,children:[(0,H.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 rounded-lg py-1 pl-2 pr-1 text-sm transition-colors hover:bg-accent/60 [&::-webkit-details-marker]:hidden ${i?`bg-muted text-foreground`:`text-mocha`}`,children:[(0,H.jsx)(ee,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-open/details:rotate-90`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold`,children:e.name}),(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:o||r.length}),(0,H.jsx)(n,{to:`/`,search:{...c?.team.id===e.id?{agent:c.agent.id}:{},team:e.id,panel:`team`},"aria-label":`Open ${e.name}: members, USER.md, memory`,title:`Open the Team`,className:`flex size-7 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-card hover:text-primary`,children:(0,H.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`})})]}),r.length===0?(0,H.jsx)(`div`,{className:`py-2 pl-7 pr-2 text-xs text-muted-foreground`,children:`No agents in this team`}):(0,H.jsx)(`div`,{className:`space-y-0.5 py-1 pl-1.5`,children:r.map(e=>(0,H.jsx)(pe,{agent:e,selected:e.id===Y,state:d.stateOf(e.id),lastActivityAt:d.byAgent.get(e.id)?.lastActivityAt??null,panel:u.panel,onRename:()=>F(e),onArchive:()=>R(e)},e.id))})]},e.id)})]}),p&&(0,H.jsx)(te,{profiles:K,teams:q,profileId:p,teamId:x,onClose:()=>{m(null),W()}}),J&&(0,H.jsx)(ce,{template:J,teams:q,onClose:()=>{E(null),W()},onSpawned:e=>{E(null),f.navigate({to:`/`,search:{team:e,panel:`team`}})}}),k&&(0,H.jsx)(N,{title:`Create a Team`,description:`A Team is one workspace: its folder, its Agents, its USER.md and shared memory, and who may message whom.`,busy:j,onClose:()=>{A(!1),W()},children:(0,H.jsx)(le,{onBusyChange:M,onCreated:async e=>{A(!1),await f.navigate({to:`/`,search:{team:e.id,panel:`team`}})},extraActions:e=>(0,H.jsx)(o,{variant:`ghost`,disabled:e,onClick:()=>A(!1),children:`Cancel`})})}),P&&(0,H.jsx)(he,{agent:P,onClose:()=>F(null),onRenamed:()=>f.invalidate()}),(0,H.jsx)(oe,{open:I!==null,onOpenChange:e=>{e||R(null)},title:`Archive ${I?.name??`agent`}?`,description:(0,H.jsx)(`p`,{children:`The Agent leaves this list and receives no work. Restore it later under Manage → Agents, in Archived.`}),confirmLabel:`Archive agent`,confirmVariant:`primary`,onConfirm:async()=>{I&&(await se(I.id),I.id===Y?await f.navigate({to:`/`,search:{}}):await f.invalidate())}})]})}function pe({agent:e,selected:t,state:r,lastActivityAt:i,panel:a,onRename:o,onArchive:s}){let c=j();return(0,H.jsxs)(`div`,{className:`group/row relative rounded-2xl`,children:[(0,H.jsxs)(n,{to:`/`,search:{agent:e.id,...a?{panel:a}:{}},"aria-current":t?`page`:void 0,className:`flex min-h-[3.1rem] items-center gap-2.5 rounded-2xl border py-1.5 pl-2 pr-9 transition-colors hover:bg-accent/60 ${t?`border-primary/20 bg-accent shadow-baziu-sm`:`border-transparent`}`,children:[(0,H.jsx)(T,{identity:e.identity,size:30}),(0,H.jsxs)(`span`,{className:`block min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold leading-tight ${t?`text-accent-foreground`:`text-foreground`}`,children:e.name}),e.telegramTopicId!==null&&(0,H.jsx)(`span`,{className:`shrink-0 text-primary`,title:`Telegram topic #${e.telegramTopicId}`,role:`img`,"aria-label":`Bound to Telegram topic ${e.telegramTopicId}`,children:(0,H.jsx)(B,{className:`size-3`,"aria-hidden":`true`})}),c&&i!==null&&(0,H.jsx)(`time`,{dateTime:new Date(i).toISOString(),className:`ml-auto shrink-0 text-[0.7rem] font-normal text-muted-foreground`,children:x(i)})]}),(0,H.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-xs leading-snug ${de[r.kind]}`,children:[(0,H.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${Q[r.kind]}`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:r.text})]})]})]}),(0,H.jsxs)(_,{modal:!1,children:[(0,H.jsx)(v,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":`More for ${e.name}`,className:`unstyled absolute right-1 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-lg text-muted-foreground opacity-0 transition-opacity hover:bg-card hover:text-primary focus-visible:opacity-100 group-hover/row:opacity-100 data-[state=open]:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,H.jsx)(p,{className:`size-4`,"aria-hidden":`true`})})}),(0,H.jsx)(O,{children:(0,H.jsxs)(y,{align:`start`,sideOffset:4,className:`z-50 w-48 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none`,children:[(0,H.jsx)(b,{asChild:!0,className:X,children:(0,H.jsxs)(n,{to:`/`,search:{agent:e.id,panel:`agent`},children:[(0,H.jsx)(C,{className:`size-3.5`,"aria-hidden":`true`}),`Agent settings`]})}),(0,H.jsxs)(b,{className:X,onSelect:o,children:[(0,H.jsx)(R,{className:`size-3.5`,"aria-hidden":`true`}),`Rename`]}),(0,H.jsxs)(b,{className:X,onSelect:s,children:[(0,H.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`}),`Archive`]})]})})]})]})}function me(){let{agents:e,teams:t,agent:r,team:i,search:a}=G(),o=g(),s=$(t).filter(t=>e.some(e=>e.teamId===t.id));return s.sort((e,t)=>Number(t.id===i?.id)-Number(e.id===i?.id)),(0,H.jsxs)(`nav`,{"aria-label":`Agents`,className:`flex h-full w-16 flex-col items-center gap-2 overflow-y-auto rounded-xl border border-border bg-card py-2.5 shadow-baziu-sm`,children:[(0,H.jsx)(n,{to:`/`,search:{...a,view:void 0,file:void 0,result:void 0},"aria-label":`Back to the conversation and the full list`,title:`Back to the conversation`,className:`flex size-10 shrink-0 items-center justify-center rounded-xl text-mocha hover:bg-accent hover:text-accent-foreground`,children:(0,H.jsx)(I,{className:`size-[18px]`,"aria-hidden":`true`})}),s.map(t=>(0,H.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`h-px w-8 bg-border`}),(0,H.jsx)(`span`,{className:`max-w-14 truncate text-[0.65rem] font-bold uppercase tracking-[0.06em] ${t.id===i?.id?`text-accent-foreground`:`text-muted-foreground`}`,title:t.name,children:t.name}),e.filter(e=>e.teamId===t.id).map(e=>{let t=o.stateOf(e.id);return(0,H.jsxs)(n,{to:`/`,search:{agent:e.id,...a.panel?{panel:a.panel}:{}},"aria-label":`${e.name}: ${t.text}`,title:`${e.name}: ${t.text}`,className:`relative flex size-10 shrink-0 items-center justify-center rounded-full ${e.id===r?.agent.id?`ring-2 ring-primary ring-offset-2 ring-offset-card`:``}`,children:[(0,H.jsx)(T,{identity:e.identity,size:40}),(0,H.jsx)(`span`,{className:`absolute -bottom-px -right-px size-3 rounded-full border-2 border-card ${Q[t.kind]}`,"aria-hidden":`true`})]},e.id)})]},t.id))]})}function he({agent:e,onClose:t,onRenamed:n}){let[r,i]=(0,V.useState)(e.name),[a,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),d=!r.trim()||r.trim()===e.name;async function f(i){if(i.preventDefault(),!d){c(!0),u(null);try{await P(e.id,r.trim()),await n(),t()}catch(e){u(s(e)),c(!1)}}}return(0,H.jsx)(N,{title:`Rename ${e.name}`,description:`This changes the display name only; the Agent ID and history stay the same.`,busy:a,onClose:t,className:`max-w-md`,children:(0,H.jsxs)(`form`,{onSubmit:e=>void f(e),children:[(0,H.jsxs)(`label`,{children:[`Agent name`,(0,H.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),maxLength:120})]}),l&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:l}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsxs)(M,{children:[(0,H.jsx)(o,{variant:`ghost`,disabled:a,onClick:t,children:`Cancel`}),(0,H.jsx)(o,{variant:`primary`,type:`submit`,disabled:a||d,children:a?`Renaming…`:`Rename agent`})]})})]})})}function ge(e){try{let t=JSON.parse(e);if(typeof t.text==`string`)return t.text}catch{}return e}var _e=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function ve(e){let t=new Map;for(let n of e){let e=_e(n.fromAgentId,n.toAgentId),r=t.get(e)??{forward:0,back:0,lastAt:0};n.fromAgentId<n.toAgentId?r.forward++:r.back++,r.lastAt=Math.max(r.lastAt,n.createdAt),t.set(e,r)}return t}function ye(e,t=100){let{turnsEnded:n}=g();return A(n=>c(`/api/teams/${encodeURIComponent(e)}/messages?limit=${t}`,{signal:n}).then(e=>e.messages),[e,t,n])}function be({messages:e,limit:t=20,empty:n=`No messages between Agents yet.`}){let{agentById:r}=G(),i=j();if(e.length===0)return(0,H.jsx)(`p`,{className:`m-0 py-3 text-sm text-muted-foreground`,children:n});let a=e=>r(e)?.name??e.slice(0,8);return(0,H.jsxs)(`ol`,{className:`m-0 list-none space-y-1.5 p-0`,children:[e.slice(0,t).map(e=>{let t=ge(e.payload);return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{className:`group rounded-[10px] border border-border bg-card`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-0.5 px-2.5 py-2 [&::-webkit-details-marker]:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,H.jsx)(T,{identity:r(e.fromAgentId)?.identity,size:18}),(0,H.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:a(e.fromAgentId)}),(0,H.jsx)(f,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,H.jsx)(T,{identity:r(e.toAgentId)?.identity,size:18}),(0,H.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:a(e.toAgentId)}),e.readAt===null&&(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-warning/15 px-1.5 text-[0.68rem] font-semibold text-warning`,children:`unread`}),i&&(0,H.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),className:`ml-auto shrink-0 text-muted-foreground`,children:x(e.createdAt)})]}),(0,H.jsx)(`span`,{className:`line-clamp-2 break-words text-[0.82rem] leading-snug text-mocha group-open:hidden`,children:t})]}),(0,H.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words border-t border-frost/70 px-2.5 py-2 text-[0.82rem] leading-snug text-chocolate`,children:t})]})},e.id)}),e.length>t&&(0,H.jsxs)(`li`,{className:`px-1 text-xs text-muted-foreground`,children:[`The newest `,t,` of `,e.length,` loaded.`]})]})}export{L as _,ve as a,Q as c,W as d,G as f,R as g,z as h,_e as i,me as l,B as m,ye as n,fe as o,K as p,ge as r,he as s,be as t,J as u,F as v};
@@ -1 +0,0 @@
1
- import{J as e,K as t,o as n,r,t as i,u as a}from"./createLucideIcon-dN8ooBD1.js";import{t as o}from"./UnsavedChangesGuard-DmT4nBQU.js";import{a as s,i as c,n as l}from"./api-CoLs57oO.js";import{_ as u,a as d,c as f,t as p,y as m}from"./parts-B0JBolvG.js";import{r as h,t as g}from"./SpawnDialog-ejwXnyxy.js";import{It as _,t as v,xt as y}from"./index-J_Uqj4md.js";import{t as b}from"./ConfirmDialog-BVytx3kN.js";import{a as x,l as S,u as C}from"./form-Bvr_f9lR.js";import{E as w,T,d as E,w as D}from"./manage-CsrV2hhK.js";import{t as O}from"./ManagePage-xlePXXx5.js";import{n as k,r as A}from"./AgentTemplateParts-Dl35c-Ux.js";var j=i(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),M=e(t(),1),N=a(),P=e=>`/api/profiles/${encodeURIComponent(e)}`;function F(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function I({loaded:e,chat:t,skills:n,onDirtyChange:r,onSaved:i}){let{profile:a}=e,[o,s]=(0,M.useState)(()=>({name:a.name,model:a.defaultModel,mode:a.skillsMode,picked:new Set(e.defaultSkills)})),[u,f]=(0,M.useState)(o.name),[p,g]=(0,M.useState)(o.model),[_,v]=(0,M.useState)(o.mode),[b,w]=(0,M.useState)(()=>new Set(o.picked)),[T,E]=(0,M.useState)(!1),[D,O]=(0,M.useState)(null),[A,j]=(0,M.useState)(!1),I=u.trim()!==o.name||p!==o.model||_!==o.mode||_===`selected`&&!F(b,o.picked);(0,M.useEffect)(()=>r(I),[I,r]);let L=()=>{j(!1),O(null)};async function R(e){if(e.preventDefault(),!(!I||T||!p)){E(!0),O(null);try{let e={name:u.trim(),model:p,mode:_,picked:_===`selected`?new Set(b):o.picked},t=e.mode!==o.mode||e.mode===`selected`&&!F(e.picked,o.picked);await l(P(a.id),{method:`PATCH`,body:{...e.name===o.name?{}:{name:e.name},...e.model===o.model?{}:{defaultModel:e.model},...t?{skillsMode:e.mode,...e.mode===`selected`?{defaultSkills:[...e.picked]}:{}}:{}}}),s(e),f(e.name),w(new Set(e.picked)),j(!0),await i()}catch(e){O(c(e))}finally{E(!1)}}}return(0,N.jsx)(m,{labelledBy:`template-settings`,icon:(0,N.jsx)(y,{className:`size-5`}),title:`Settings`,description:`What it is called, the model its Agents answer with, and the skills they start with.`,children:(0,N.jsxs)(d,{onSubmit:R,children:[(0,N.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,N.jsx)(S,{label:`Name`,value:u,disabled:T,placeholder:a.id,className:`max-w-none`,onChange:e=>{L(),f(e)}}),(0,N.jsx)(h,{kit:!0,label:`Default model`,value:p,models:t,required:!0,onChange:e=>{L(),g(e)}})]}),(0,N.jsx)(k,{mode:_,picked:b,skills:n,disabled:T,onModeChange:e=>{L(),v(e)},onPickedChange:e=>{L(),w(e)}}),(0,N.jsx)(x,{busy:T,disabled:!I||!p,status:C({error:D,dirty:I,saved:A,savedText:`Saved. Agents spawned from now on get these.`,footnote:`Agents already spawned keep their own model and skills.`})})]})})}function L(e){return{soul:e.soul,identity:e.identity,bootstrap:e.bootstrap,agents:e.agents,tools:e.tools}}function R({loaded:e,starter:t,onDirtyChange:n}){let r=e.profile.id,[i,a]=(0,M.useState)(()=>L(e.files)),[o,u]=(0,M.useState)(()=>L(e.files)),[p,h]=(0,M.useState)(`soul`),[g,v]=(0,M.useState)(!1),[y,b]=(0,M.useState)(null),[S,w]=(0,M.useState)(!1),T=A.filter(e=>o[e.key]!==i[e.key]),E=T.length>0;(0,M.useEffect)(()=>n(E),[E,n]);let D=A.find(e=>e.key===p)??A[0],O=D?o[D.key]:null;function k(e,t){w(!1),b(null),u(n=>({...n,[e]:t}))}let F=(0,M.useRef)({});function I(e){h(e),F.current[e]?.focus()}function R(e,t){let n=A.length-1,r=e.key===`ArrowRight`?t===n?0:t+1:e.key===`ArrowLeft`?t===0?n:t-1:e.key===`Home`?0:e.key===`End`?n:null,i=r===null?void 0:A[r];i&&(e.preventDefault(),I(i.key))}let[z,B]=(0,M.useState)(null);async function V(e){if(e.preventDefault(),!E||g)return;v(!0),b(null);let t={};try{for(let e of T){let n=o[e.key];n!==null&&(await l(`${P(r)}/files/${encodeURIComponent(e.name)}`,{method:`PUT`,body:{content:n}}),t[e.key]=n)}w(!0)}catch(e){b(c(e))}finally{a(e=>({...e,...t})),v(!1)}}return(0,N.jsxs)(m,{labelledBy:`template-files`,icon:(0,N.jsx)(j,{className:`size-5`}),title:`Files`,description:`Each Agent spawned from this template gets its own copy of these, and may change it.`,children:[(0,N.jsx)(f,{children:(0,N.jsx)(`div`,{role:`tablist`,"aria-label":`Template files`,className:`flex max-w-full gap-1 overflow-x-auto rounded-xl border border-border bg-muted/50 p-1`,children:A.map((e,t)=>{let n=e.key===p,r=o[e.key]===null,a=o[e.key]!==i[e.key];return(0,N.jsxs)(`button`,{type:`button`,role:`tab`,id:`template-file-${e.key}`,ref:t=>{F.current[e.key]=t},"aria-selected":n,"aria-controls":`template-file-panel`,tabIndex:n?0:-1,onClick:()=>h(e.key),onKeyDown:e=>R(e,t),className:_(`unstyled inline-flex items-center gap-1.5 whitespace-nowrap rounded-lg border px-2.5 py-1.5 font-mono text-xs font-semibold transition-colors sm:px-3`,n?`border-border bg-card text-foreground shadow-baziu-sm`:`border-transparent hover:bg-card/70 hover:text-foreground`,!n&&(r?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.name,a&&(0,N.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,role:`img`,"aria-label":`not saved`})]},e.key)})})}),(0,N.jsx)(`div`,{id:`template-file-panel`,role:`tabpanel`,"aria-labelledby":`template-file-${p}`,children:(0,N.jsxs)(d,{onSubmit:V,children:[D&&O===null?(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-xl border border-dashed border-border bg-muted/30 px-4 py-8 text-center`,children:[(0,N.jsxs)(`p`,{className:`m-0 text-[0.95rem] font-semibold text-foreground`,children:[`This template has no `,D.name]}),(0,N.jsxs)(`p`,{className:`m-0 max-w-md text-sm text-muted-foreground`,children:[D.hint,` It starts from the built-in text and is saved with the other files.`]}),(0,N.jsxs)(s,{variant:`ghost`,className:`mt-2`,disabled:g,onClick:()=>{B(D.key),k(D.key,t[D.key])},children:[`Add `,D.name]})]}):D&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:D.hint}),(0,N.jsx)(`textarea`,{autoFocus:z===D.key,"aria-label":`${D.name} contents`,value:O??``,disabled:g,spellCheck:!1,rows:22,onChange:e=>k(D.key,e.target.value),className:`min-h-[18rem] resize-y font-mono text-[0.85rem] leading-[1.6]`},D.key)]}),(0,N.jsx)(x,{busy:g,disabled:!E,label:T.length>1?`Save ${T.length} files`:`Save`,status:C({error:y,dirty:E,saved:S,savedText:`Saved. Agents spawned from now on get these files.`,footnote:`Saving keeps every file you changed, not only the one in view.`}),extra:E&&(0,N.jsx)(s,{variant:`ghost`,disabled:g,onClick:()=>{u(i),b(null),F.current[p]?.focus()},children:`Discard changes`})})]})})]})}function z(){let{loaded:e,chat:t,skills:i,starter:a,templates:c,teamTemplates:d,teams:f}=v.useLoaderData(),{profile:m}=e,h=n(),_=r(),[y,x]=(0,M.useState)(!1),[S,C]=(0,M.useState)(!1),[k,A]=(0,M.useState)(!1),[j,P]=(0,M.useState)(!1),F=(0,M.useCallback)(e=>x(e),[]),L=(0,M.useCallback)(e=>C(e),[]),z=c.find(e=>e.id===m.id),B=z?D(z,d):null,V=E(m.defaultModel,t),H=T(m);return(0,N.jsxs)(O,{title:H,description:(0,N.jsxs)(N.Fragment,{children:[`What every Agent spawned from this template starts with.`,` `,z?`${w(z,d)}.`:``,` Agents already spawned keep their own copies.`]}),actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(s,{variant:`primary`,onClick:()=>A(!0),children:`Spawn an agent`}),(0,N.jsx)(u,{label:`More for ${H}`,items:[{label:`Delete template…`,danger:!0,disabledReason:B,onSelect:()=>P(!0)}]})]}),children:[(0,N.jsx)(o,{when:y||S,subject:`template changes`}),V.missing&&(0,N.jsx)(p,{tone:`warning`,lead:`Its default model, ${V.name}, is not in Chat.`,action:(0,N.jsx)(`a`,{href:`/config`,className:`ghost-btn no-underline`,children:`Open Setup → Models`}),children:`Agents spawned from it are refused until it is. Choose another model below, or add it in Setup.`}),(0,N.jsx)(I,{loaded:e,chat:t,skills:i,onDirtyChange:F,onSaved:()=>h.invalidate({sync:!0})}),(0,N.jsx)(R,{loaded:e,starter:a,onDirtyChange:L}),k&&(0,N.jsx)(g,{profiles:c,teams:f,profileId:m.id,onClose:()=>A(!1)}),(0,N.jsx)(b,{open:j,onOpenChange:P,title:`Delete the ${H} template?`,description:(0,N.jsx)(`p`,{className:`m-0`,children:`This deletes the template and its files. No Agent and no Team template uses it.`}),confirmLabel:`Delete template`,onConfirm:async()=>{await l(`/api/profiles/${encodeURIComponent(m.id)}`,{method:`DELETE`}),await _({to:`/templates/agents`})}})]})}export{z as component};
@@ -1 +0,0 @@
1
- import{J as e,K as t,o as n,r,t as i,u as a}from"./createLucideIcon-dN8ooBD1.js";import{t as o}from"./UnsavedChangesGuard-DmT4nBQU.js";import{a as s,i as c,n as l}from"./api-CoLs57oO.js";import{_ as u,g as d}from"./parts-B0JBolvG.js";import{C as f,S as p,a as m,b as h,d as g,f as _,g as v,h as y,i as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,x as A,y as j}from"./style-BtcFIkOS.js";import{t as M}from"./plus-DZ3KVo7E.js";import{Et as N,n as P}from"./index-J_Uqj4md.js";import{t as F}from"./ConfirmDialog-BVytx3kN.js";import{t as I}from"./Segmented-Co4n2C5X.js";import{c as L,l as R,s as z}from"./form-Bvr_f9lR.js";import{s as B}from"./manage-CsrV2hhK.js";import{t as V}from"./SpawnTeamModal-Cp-nAvIC.js";import{t as H}from"./ManagePage-xlePXXx5.js";var U=i(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),W=i(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),G=e(t(),1),K=a();function q({data:e,selected:t}){return(0,K.jsxs)(`div`,{className:`relative w-[190px] rounded-md border bg-snow px-3 py-2.5 shadow-baziu-sm transition-shadow ${t?`border-sapphire shadow-baziu-md`:`border-frost`}`,children:[(0,K.jsx)(b,{type:`target`,position:k.Left,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,K.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-md bg-sapphire-glow text-sapphire`,children:(0,K.jsx)(N,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:e.member.name}),(0,K.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1.5 truncate text-[0.68rem] text-mocha-light`,children:e.subtitle})]}),e.isolated&&(0,K.jsx)(W,{className:`h-4 w-4 flex-none text-[#a56568]`,"aria-label":`No connections`}),e.incomplete&&(0,K.jsx)(U,{className:`h-4 w-4 flex-none text-warning`,"aria-label":`No template`})]}),(0,K.jsx)(b,{type:`source`,position:k.Right,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`})]})}function J({data:e,selected:t}){return(0,K.jsxs)(`div`,{className:`w-[150px] rounded-md border bg-ivory px-3 py-2.5 shadow-baziu-sm ${t?`border-sapphire`:`border-fawn`}`,children:[(0,K.jsx)(b,{type:`target`,position:k.Left,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(f,{className:`h-4 w-4 flex-none text-rose-baziu`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:e.label})]}),(0,K.jsx)(b,{type:`source`,position:k.Right,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`})]})}var Y={agent:q,outside:J},X={};function Z({document:e,selectedId:t,incompleteKeys:n,templateNames:r=X,onSelect:i,onConnect:a,onRemoveEdge:o,onMoveMember:s,onOpenMember:c}){let l=(0,G.useMemo)(()=>[{id:_,type:`outside`,position:{x:Math.max(800,...e.members.map(e=>e.position.x+280)),y:110},data:{label:`Other teams`},ariaLabel:`Agents in other teams`,selected:t===_,draggable:!1,deletable:!1},...e.members.map(i=>{let a=e.mode===`restricted`&&!e.edges.some(e=>e.from===i.key||e.to===i.key),o=n.has(i.key);return{id:i.key,type:`agent`,position:i.position,data:{member:i,subtitle:r[i.profileId]??`No template`,isolated:a,incomplete:o},ariaLabel:`${i.name}${a?`, no connections`:``}${o?`, no template`:``}`,selected:t===i.key,deletable:!1}})],[e,n,t,r]),[u,d,f]=D(l);(0,G.useEffect)(()=>{d(e=>{let t=new Map(e.map(e=>[e.id,e]));return l.map(e=>({...t.get(e.id),...e}))})},[l,d]);let p=(0,G.useMemo)(()=>e.edges.map(e=>{let n=S(e.from,e.to);return{id:n,source:e.from,target:e.to,selected:t===n,markerEnd:{type:x.ArrowClosed,width:16,height:16},style:{stroke:`var(--color-sapphire)`,strokeWidth:1.7}}}),[e.edges,t]),h=e=>{e.source&&e.target&&a(e.source,e.target)},g=t=>e.members.find(e=>e.key===t);return(0,K.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,K.jsxs)(w,{nodes:u,edges:p,nodeTypes:Y,onConnect:h,onNodesChange:f,onNodeClick:(e,t)=>i(t.id),onNodeDoubleClick:(e,t)=>{let n=g(t.id);n&&c(n)},onEdgeClick:(e,t)=>i(t.id),onPaneClick:()=>i(null),onEdgesDelete:e=>{for(let t of e)o(t.source,t.target)},onNodeDragStop:(e,t)=>{g(t.id)&&s(t.id,t.position)},minZoom:.35,maxZoom:1.8,edgesReconnectable:!1,fitView:!0,fitViewOptions:{padding:.22,maxZoom:1},proOptions:{hideAttribution:!0},className:`policy-flow`,children:[(0,K.jsx)(O,{variant:C.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,K.jsx)(E,{position:`bottom-left`,showInteractive:!1,className:`!overflow-hidden !rounded-md !border !border-frost !bg-snow !shadow-baziu-sm [&_button]:!border-frost [&_button]:!bg-snow [&_button]:!fill-chocolate`}),(0,K.jsx)(m,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!hidden !rounded-md !border !border-frost !bg-snow sm:!block`,nodeColor:e=>e.type===`outside`?`var(--color-rose-baziu)`:`var(--color-sapphire)`,maskColor:`color-mix(in srgb, var(--color-cream) 70%, transparent)`})]})})}var Q={open:`Members message each other freely; connections only matter for messages to and from other Teams.`,restricted:`Members message each other only along connections.`};function $({template:e,profiles:t,onSaved:n,onDirtyChange:r}){let[i,a]=(0,G.useState)(()=>A(e)),[u,d]=(0,G.useState)(i),[f,m]=(0,G.useState)(`flow`),[_,v]=(0,G.useState)(null),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(!1),T=!j(i,u);(0,G.useEffect)(()=>r?.(T),[T,r]);let E=(0,G.useMemo)(()=>new Set(u.members.filter(e=>!t.some(t=>t.id===e.profileId)).map(e=>e.key)),[u.members,t]),D=(0,G.useMemo)(()=>Object.fromEntries(t.map(e=>[e.id,`${e.name||e.id} template`])),[t]),O=(e,t,n)=>d(r=>h(r,e,t,n)),k=async()=>{b(!0),S(null);try{let r=A(await l(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`PUT`,body:p(u,t)}));a(r),d(r),v(null),S({text:`Saved.`,ok:!0}),await n?.()}catch(e){S({text:c(e),ok:!1})}finally{b(!1)}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(o,{when:T,subject:`Team template draft`}),(0,K.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,"aria-label":`Roster and connections`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-end gap-x-3 gap-y-3 border-b border-border px-4 py-4 sm:px-5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1 basis-60`,children:(0,K.jsx)(R,{label:`Name`,value:u.name,disabled:y,className:`max-w-none`,onChange:e=>d(t=>({...t,name:e}))})}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`Messaging`}),(0,K.jsx)(I,{label:`Messaging`,value:u.mode,onChange:e=>d(t=>({...t,mode:e})),options:[{id:`open`,label:`Open`},{id:`restricted`,label:`Restricted`}]})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`View`}),(0,K.jsx)(I,{label:`View`,value:f,onChange:m,options:[{id:`flow`,label:`Flow`},{id:`matrix`,label:`Matrix`}]})]}),(0,K.jsx)(`p`,{className:`m-0 basis-full text-sm text-muted-foreground`,children:Q[u.mode]})]}),(0,K.jsxs)(`div`,{className:`grid min-h-[620px] grid-cols-1 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,K.jsx)(`div`,{className:`min-h-[480px] overflow-hidden`,children:f===`flow`?(0,K.jsx)(Z,{document:u,templateNames:D,selectedId:_,incompleteKeys:E,onSelect:v,onConnect:(e,t)=>O(e,t,!0),onRemoveEdge:(e,t)=>O(e,t,!1),onMoveMember:(e,t)=>d(n=>({...n,members:n.members.map(n=>n.key===e?{...n,position:t}:n)})),onOpenMember:e=>v(e.key)}):(0,K.jsx)(g,{document:u,selectedId:_,onSelect:v,onToggle:O})}),(0,K.jsx)(`aside`,{className:`border-t border-border p-4 lg:border-l lg:border-t-0`,children:(0,K.jsx)(ee,{document:u,selectedId:_,profiles:t,onDraft:d,onSelect:v,onToggle:O})})]}),(0,K.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-border px-4 py-4 sm:px-5`,children:[(0,K.jsx)(s,{variant:`primary`,disabled:!T||y,onClick:()=>void k(),children:y?`Saving…`:`Save`}),T&&(0,K.jsx)(s,{variant:`ghost`,disabled:y,onClick:()=>w(!0),children:`Discard changes`}),(0,K.jsx)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium ${x&&!x.ok||T?`text-warning`:x?`text-success`:`text-muted-foreground`}`,children:x&&!x.ok?`Nothing was saved: ${x.text}`:T?`Not saved yet.`:x?`Saved. Teams spawned from now on get this roster.`:`Teams already spawned keep their own Agents and connections.`})]})]}),(0,K.jsx)(F,{open:C,title:`Discard your changes to this template?`,description:(0,K.jsx)(`p`,{children:`The saved roster and connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{d(i),v(null),S(null)},onOpenChange:w})]})}function ee({document:e,selectedId:t,profiles:n,onDraft:r,onSelect:i,onToggle:a}){let o=[...e.members.map(e=>e.key),_],c=e.edges.find(e=>S(e.from,e.to)===t),l=t&&o.includes(t)?t:null,u=e.members.find(e=>e.key===l),f=e=>r(t=>({...t,members:t.members.map(t=>t.key===u?.key?{...t,...e}:t)}));if(c)return(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Connection`}),(0,K.jsxs)(`p`,{className:`m-0 text-sm`,children:[y(e,c.from),` may message `,y(e,c.to),`.`]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(s,{variant:`danger`,onClick:()=>{a(c.from,c.to,!1),i(null)},children:`Remove connection`})})]});if(!l)return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsxs)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[e.members.length===1?`1 Agent`:`${e.members.length} Agents`,` ·`,` `,e.edges.length===1?`1 connection`:`${e.edges.length} connections`]}),(0,K.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`Select an Agent to choose who it may message, or drag from one Agent's dot to another. A message to another Team needs a connection to Other teams here, and one from Other teams in that Team.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`team-template-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,K.jsx)(`textarea`,{id:`team-template-user-md`,rows:6,value:e.userMd??``,onChange:e=>{let t=e.target.value;r(e=>({...e,userMd:t||null}))},className:`mt-1.5 font-mono text-[0.85em]`}),(0,K.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`What every Agent of a Team spawned from it knows about you.`})]}),(0,K.jsx)(`div`,{children:(0,K.jsxs)(s,{variant:`ghost`,onClick:()=>r(e=>({...e,members:[...e.members,{key:`draft:${crypto.randomUUID()}`,profileId:n[0]?.id??``,name:`Agent ${e.members.length+1}`,position:T(e.members.length)}]})),children:[(0,K.jsx)(M,{className:`size-4`,"aria-hidden":`true`}),` Add an Agent`]})})]});let p=u&&n.some(e=>e.id===u.profileId);return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:u?u.name||`Agent`:`Other teams`}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(R,{label:`Name`,value:u.name,className:`max-w-none`,onChange:e=>f({name:e})}),(0,K.jsx)(z,{label:`Template`,value:u.profileId,className:`max-w-none`,options:[...p?[]:[{value:u.profileId,label:u.profileId||`Choose a template`}],...n.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>f({profileId:e})}),!p&&(0,K.jsx)(d,{tone:`warning`,children:`Choose a template: an Agent cannot be spawned without one.`})]}),(0,K.jsxs)(`fieldset`,{className:`m-0 grid min-w-0 gap-3 border-0 p-0`,children:[(0,K.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`May message`}),o.filter(e=>e!==l).map(t=>(0,K.jsx)(L,{label:y(e,t),checked:v(e,l,t),onChange:e=>a(l,t,e)},t))]}),u&&(0,K.jsx)(`div`,{children:(0,K.jsx)(s,{variant:`danger`,onClick:()=>{r(e=>({...e,members:e.members.filter(e=>e.key!==u.key),edges:e.edges.filter(e=>e.from!==u.key&&e.to!==u.key)})),i(null)},children:`Remove this Agent`})})]})}function te(){let{template:e,profiles:t,teams:i}=P.useLoaderData(),a=r(),o=n(),[c,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1);return(0,K.jsxs)(H,{title:e.name,description:`A roster of ${B(e.slots.length,`Agent`)} and ${B(e.edges.length,`connection`)}. Spawning it creates them in a new Team or one that exists; Teams already spawned keep their own.`,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(s,{variant:`primary`,disabled:e.slots.length===0||m,"aria-describedby":m?`spawn-needs-save`:void 0,onClick:()=>d(!0),children:`Spawn this Team`}),(0,K.jsx)(u,{label:`More for ${e.name}`,items:[{label:`Delete template…`,danger:!0,onSelect:()=>p(!0)}]})]}),children:[m&&(0,K.jsx)(`p`,{id:`spawn-needs-save`,className:`m-0 text-sm font-medium text-warning`,children:`Save the roster to spawn it as it is on screen.`}),(0,K.jsx)($,{template:e,profiles:t,onSaved:()=>o.invalidate({sync:!0}),onDirtyChange:h}),c&&(0,K.jsx)(V,{template:e,teams:i,onClose:()=>d(!1),onSpawned:e=>{d(!1),a({to:`/`,search:{team:e,panel:`team`}})}}),(0,K.jsx)(F,{open:f,onOpenChange:p,title:`Delete the ${e.name} Team template?`,description:(0,K.jsx)(`p`,{className:`m-0`,children:`Teams already spawned from it keep their Agents and connections.`}),confirmLabel:`Delete template`,onConfirm:async()=>{await l(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await a({to:`/templates/teams`})}})]})}export{te as component};
@@ -1 +0,0 @@
1
- import{J as e,K as t,o as n,t as r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{a,i as o,n as s}from"./api-CoLs57oO.js";import{a as c,d as l,g as u,h as d,o as f,s as p,y as m}from"./parts-B0JBolvG.js";import{t as h}from"./key-round-QpqZklz6.js";import{t as g}from"./plus-DZ3KVo7E.js";import{a as _}from"./index-J_Uqj4md.js";import{t as v}from"./ConfirmDialog-BVytx3kN.js";import{l as y}from"./form-Bvr_f9lR.js";import{t as b}from"./ConfigPage-DiQiJXP6.js";var x=r(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),S=e(t(),1);function C(e){let t=e.label.trim(),n=e.days.trim(),r={};n!==``&&(!/^\d+$/.test(n)||Number(n)<1)&&(r.days=`A whole number of days, 1 or more. Empty means it never expires.`);let i=t===``&&n!==``?`A token needs a label to tell it from the others.`:null;return t===``||r.days?{problems:r,missing:i,body:null}:{problems:r,missing:i,body:{label:t,...n?{expiresInDays:Number(n)}:{}}}}function w(e,t){return e.revokedAt?{label:`Revoked`,tone:`neutral`}:e.expiresAt!==null&&e.expiresAt<=t?{label:`Expired`,tone:`neutral`}:{label:`Active`,tone:`success`}}function T(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)}var E=i();function D({onMinted:e}){let[t,n]=(0,S.useState)({label:``,days:``}),[r,i]=(0,S.useState)(null),[l,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(null),h=C(t),_=e=>{p(null),n(t=>({...t,...e}))};async function v(t){if(t.preventDefault(),!(!h.body||l)){d(!0),p(null);try{let{token:t}=await s(`/api/tokens`,{body:h.body});i(t),n({label:``,days:``}),await e()}catch(e){p(o(e))}finally{d(!1)}}}return(0,E.jsx)(m,{labelledBy:`access-mint`,icon:(0,E.jsx)(g,{className:`size-5`}),title:`Mint a new token`,description:`One for each other device or script, so that each can be revoked on its own.`,children:(0,E.jsxs)(c,{onSubmit:v,children:[(0,E.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[minmax(0,18rem)_minmax(0,11rem)]`,children:[(0,E.jsx)(y,{label:`Label`,value:t.label,disabled:l,placeholder:`e.g. laptop-tailscale`,onChange:e=>_({label:e})}),(0,E.jsx)(y,{label:`Expires in days`,value:t.days,disabled:l,placeholder:`never`,inputMode:`numeric`,problem:h.problems.days,onChange:e=>_({days:e})})]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,E.jsx)(a,{variant:`primary`,type:`submit`,disabled:l||!h.body,children:l?`Creating…`:`Create`}),f?(0,E.jsxs)(`p`,{role:`alert`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium text-warning`,children:[`Nothing was created: `,f]}):h.missing&&(0,E.jsx)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium text-warning`,children:h.missing})]}),r&&(0,E.jsx)(u,{tone:`warning`,title:`Copy this token now; it cannot be shown again.`,children:(0,E.jsx)(`code`,{className:`mt-1 block break-all bg-transparent p-0 text-[0.85em] text-foreground`,children:r})})]})})}function O({tokens:e,sessions:t,includeRevoked:n,now:r,onRevoked:i}){let[o,c]=(0,S.useState)(null),u=e=>t.some(t=>t.current&&t.tokenId===e?.id);return(0,E.jsxs)(m,{labelledBy:`access-tokens`,icon:(0,E.jsx)(h,{className:`size-5`}),title:`Tokens`,description:`Each signs in to the HTTP API, the CLI and the web UI, with full access.`,action:(0,E.jsx)(`a`,{className:`ghost-btn`,href:n?`/config/access`:`/config/access?all=1`,children:n?`Hide revoked`:`Show revoked`}),children:[e.length===0?(0,E.jsx)(p,{className:`py-4 text-sm text-muted-foreground`,children:`No tokens yet; mint one above.`}):(0,E.jsx)(f,{children:e.map(e=>{let t=e.kind===`bootstrap`,n=w(e,r);return(0,E.jsx)(d,{title:e.label,chip:(0,E.jsx)(l,{tone:n.tone,children:n.label}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{children:t?`bootstrap (auth.json)`:e.kind}),(0,E.jsxs)(`span`,{children:[`created `,T(e.createdAt)]}),(0,E.jsxs)(`span`,{children:[`last used `,e.lastUsedAt?T(e.lastUsedAt):`never`]}),(0,E.jsxs)(`span`,{children:[`expires `,e.expiresAt?T(e.expiresAt):`never`]}),(0,E.jsx)(`code`,{children:e.id})]}),actions:!e.revokedAt&&!t&&(0,E.jsx)(a,{variant:`danger`,"aria-label":`Revoke ${e.label}`,onClick:()=>c(e),children:`Revoke`})},e.id)})}),(0,E.jsx)(v,{open:o!==null,onOpenChange:e=>{e||c(null)},title:`Revoke ${o?.label??``}?`,description:(0,E.jsxs)(`p`,{className:`m-0`,children:[`This permanently revokes token `,(0,E.jsx)(`code`,{children:o?.id}),` and ends every browser session opened with it.`,u(o)&&` This includes the session you are using now.`]}),confirmLabel:`Revoke token and sessions`,onConfirm:async()=>{o&&(await s(`/api/tokens/${encodeURIComponent(o.id)}`,{method:`DELETE`}),await i(u(o)))}})]})}function k({sessions:e,onRevoked:t}){let[n,r]=(0,S.useState)(null);return(0,E.jsxs)(m,{labelledBy:`access-sessions`,icon:(0,E.jsx)(x,{className:`size-5`}),title:`Browser sessions`,description:`A session ends after 30 days without use. Revoking a token also ends every session opened with it.`,children:[e.length===0?(0,E.jsx)(p,{className:`py-4 text-sm text-muted-foreground`,children:`No active browser sessions.`}):(0,E.jsx)(f,{children:e.map(e=>(0,E.jsx)(d,{title:e.tokenLabel,chip:e.current&&(0,E.jsx)(l,{tone:`success`,children:`This browser`}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{children:[`last seen `,T(e.lastSeenAt)]}),(0,E.jsxs)(`span`,{children:[`expires `,T(e.expiresAt)]}),(0,E.jsx)(`code`,{children:e.id})]}),actions:(0,E.jsx)(a,{variant:`danger`,"aria-label":e.current?`Revoke the session of this browser`:`Revoke the ${e.tokenLabel} session last seen ${T(e.lastSeenAt)}`,onClick:()=>r(e),children:`Revoke`})},e.id))}),(0,E.jsx)(v,{open:n!==null,onOpenChange:e=>{e||r(null)},title:`Revoke the ${n?.tokenLabel??``} browser session?`,description:(0,E.jsxs)(`p`,{className:`m-0`,children:[`This ends browser session `,(0,E.jsx)(`code`,{children:n?.id}),n?.current?` and signs this browser out.`:`. The token stays active for later logins.`]}),confirmLabel:n?.current?`Sign out this browser`:`Revoke session`,onConfirm:async()=>{n&&(await s(`/api/sessions/${encodeURIComponent(n.id)}`,{method:`DELETE`}),await t(n.current))}})]})}function A(){let{tokens:e,sessions:t,now:r}=_.useLoaderData(),i=_.useSearch().all===1,a=n();async function o(e){e?window.location.assign(`/login`):await a.invalidate({sync:!0})}return(0,E.jsxs)(b,{title:`Access`,description:(0,E.jsxs)(E.Fragment,{children:[`Every token has full access to the HTTP API, the CLI and browser login. The`,` `,(0,E.jsx)(`code`,{children:`bootstrap`}),` token from `,(0,E.jsx)(`code`,{children:`~/.bazilion/auth.json`}),` cannot be revoked; mint a separate, revocable token for each other device.`]}),children:[(0,E.jsx)(D,{onMinted:()=>a.invalidate({sync:!0})}),(0,E.jsx)(O,{tokens:e,sessions:t,includeRevoked:i,now:r,onRevoked:o}),(0,E.jsx)(k,{sessions:t,onRevoked:o})]})}export{A as component};
@@ -1 +0,0 @@
1
- import{n as e}from"./api-CoLs57oO.js";var t=e=>`/api/agents/${encodeURIComponent(e)}`;function n(n){return e(`${t(n)}/archive`,{method:`POST`})}function r(n){return e(`${t(n)}/unarchive`,{method:`POST`})}function i(n){return e(t(n),{method:`DELETE`})}function a(n,r){return e(t(n),{method:`PATCH`,body:{name:r}})}export{r as i,i as n,a as r,n as t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,n,o as r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{a,i as o,n as s}from"./api-CoLs57oO.js";import{_ as c,c as l,d as u,g as d,h as f,i as p,m,o as h,r as g,v as _,y as v}from"./parts-B0JBolvG.js";import{t as y}from"./SpawnDialog-ejwXnyxy.js";import{Et as b,b as x,u as S}from"./index-J_Uqj4md.js";import{n as C,t as w}from"./Dialog-BTDzv3J5.js";import{t as T}from"./ConfirmDialog-BVytx3kN.js";import{t as ee}from"./Segmented-Co4n2C5X.js";import{i as te,n as ne,t as E}from"./agent-actions--EO4yJ4Q.js";import{s as D}from"./form-Bvr_f9lR.js";import{T as O,c as k,n as A,r as j,s as M}from"./manage-CsrV2hhK.js";import{t as N}from"./ManagePage-xlePXXx5.js";var P=e(t(),1),F=i();function I({agent:e,teams:t,onClose:n,onMoved:r}){let i=t.filter(t=>t.id!==e.teamId),[c,l]=(0,P.useState)(i[0]?.id??``),[u,f]=(0,P.useState)(!1),[p,m]=(0,P.useState)(null),h=t.find(t=>t.id===e.teamId)?.name??e.teamId;async function g(t){if(t.preventDefault(),!(!c||u)){f(!0),m(null);try{await s(`/api/agents/${encodeURIComponent(e.id)}/team`,{method:`PATCH`,body:{teamId:c}}),await r()}catch(e){m(o(e)),f(!1)}}}return(0,F.jsx)(w,{title:`Move ${e.name}`,description:`From ${h} to another Team. Its conversations and files go with it; its connections stay behind, so it joins the other Team with none.`,busy:u,onClose:n,children:(0,F.jsxs)(`form`,{onSubmit:e=>void g(e),className:`grid gap-4`,children:[(0,F.jsx)(D,{label:`Team`,value:c,options:i.map(e=>({value:e.id,label:e.name})),disabled:u,className:`max-w-none`,onChange:l}),p&&(0,F.jsx)(d,{tone:`warning`,role:`alert`,title:`It was not moved.`,children:p}),(0,F.jsxs)(C,{children:[(0,F.jsx)(a,{variant:`ghost`,disabled:u,onClick:n,children:`Cancel`}),(0,F.jsx)(a,{variant:`primary`,type:`submit`,disabled:u||!c,children:u?`Moving…`:`Move to ${t.find(e=>e.id===c)?.name??`Team`}`})]})]})})}function L({agents:e,teams:t,templates:r,chat:i,onSpawn:s,onChanged:y}){let[S,C]=(0,P.useState)(``),[w,D]=(0,P.useState)(`current`),[N,L]=(0,P.useState)(null),[z,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(null),[G,K]=(0,P.useState)(null),q=A(e),J=(0,P.useRef)(null),[Y,X]=(0,P.useState)(!1);(0,P.useEffect)(()=>{!Y||N!==null||(J.current?.focus(),X(!1))},[Y,N]);let Z=k(e,t,w,S);async function Q(e,t){L(e.id),B(null);try{await t(),await y()}catch(e){B(o(e))}finally{L(null)}}let re=e=>Q(e,async()=>{await E(e.id),H(e),X(!0)}),$=e=>Q(e,async()=>{await te(e.id),H(null)});return(0,F.jsxs)(v,{labelledBy:`manage-agents`,icon:(0,F.jsx)(b,{className:`size-5`}),title:`Agents`,description:`Grouped by Team. An archived Agent keeps its files and conversations, takes no work, and can be restored.`,children:[(0,F.jsxs)(l,{children:[(0,F.jsx)(_,{label:`Find an Agent`,placeholder:`Find by name, creature or vibe`,value:S,onChange:C,className:`min-w-0 flex-1 basis-60`}),(0,F.jsx)(ee,{label:`Which Agents`,value:w,onChange:D,options:[{id:`current`,label:`Current ${q.current}`},{id:`archived`,label:`Archived ${q.archived}`},{id:`all`,label:`All`}]})]}),V&&(0,F.jsx)(g,{className:`py-3`,children:(0,F.jsxs)(d,{tone:`neutral`,actions:(0,F.jsxs)(a,{ref:J,variant:`ghost`,disabled:N!==null,onClick:()=>void $(V),children:[`Restore `,V.name]}),children:[V.name,` is archived. It keeps its files and conversations and takes no work until it is restored.`]})}),z&&(0,F.jsx)(g,{className:`py-3`,children:(0,F.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:z})}),e.length===0?(0,F.jsx)(p,{icon:(0,F.jsx)(b,{className:`size-5`}),title:`No Agents yet`,action:(0,F.jsx)(a,{variant:`primary`,disabled:r.length===0||t.length===0,onClick:s,children:`Spawn an agent`}),children:`An Agent is spawned from a template into a Team, and starts talking as soon as it is.`}):Z.length===0?(0,F.jsx)(p,{title:S.trim()?`No Agent matches “${S.trim()}”`:R(w),children:S.trim()?`Try another name, or look in all of them.`:`Archived Agents appear here when there are any.`}):Z.map(({team:e,agents:o})=>(0,F.jsxs)(`section`,{"aria-label":e.name,children:[(0,F.jsx)(m,{title:e.name,meta:`${M(o.length,`Agent`)} · ${e.policyMode===`restricted`?`Restricted`:`Open`}`,action:(0,F.jsx)(n,{to:`/`,search:{team:e.id,panel:`team`},children:`Open Team`})}),(0,F.jsx)(h,{children:o.map(e=>{let o=r.find(t=>t.id===e.profileId),s=j(e,r,i),l=e.status===`archived`,d=[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `);return(0,F.jsx)(f,{inline:!0,leading:(0,F.jsx)(x,{identity:e.identity,size:32}),title:(0,F.jsx)(n,{to:`/`,search:{agent:e.id},className:`text-foreground hover:text-primary`,children:e.name}),chip:l&&(0,F.jsx)(u,{tone:`neutral`,children:`Archived`}),meta:(0,F.jsxs)(F.Fragment,{children:[d&&(0,F.jsx)(`span`,{children:d}),(0,F.jsxs)(`span`,{children:[o?(0,F.jsx)(`a`,{href:`/templates/agents/${encodeURIComponent(o.id)}`,children:O(o)}):e.profileId,` `,`template`]}),s&&(0,F.jsxs)(`span`,{className:s.missing?`font-semibold text-warning`:``,children:[s.name,s.missing?`, not in Chat`:s.inherited?``:`, its own`]})]}),actions:(0,F.jsxs)(F.Fragment,{children:[l&&(0,F.jsx)(a,{variant:`ghost`,disabled:N===e.id,onClick:()=>void $(e),children:`Restore`}),(0,F.jsx)(c,{label:`More for ${e.name}`,disabled:N===e.id,items:[t.length>1&&{label:`Move to another Team…`,onSelect:()=>W(e)},!l&&{label:`Archive`,onSelect:()=>void re(e)},{label:`Delete permanently…`,danger:!0,onSelect:()=>K(e)}]})]})},e.id)})})]},e.id)),U&&(0,F.jsx)(I,{agent:U,teams:t,onClose:()=>W(null),onMoved:async()=>{W(null),await y()}}),(0,F.jsx)(T,{open:G!==null,onOpenChange:e=>{e||K(null)},title:`Delete ${G?.name??`this Agent`} permanently?`,description:(0,F.jsx)(`p`,{className:`m-0`,children:`This removes the Agent, its conversations, messages, schedules, skill attachments and its folder. It cannot be undone. To keep them, archive it instead.`}),confirmLabel:`Delete permanently`,onConfirm:async()=>{G&&(await ne(G.id),V?.id===G.id&&H(null),await y())}})]})}function R(e){return e===`archived`?`No archived Agents`:`No current Agents`}function z(){let{agents:e,templates:t,teams:n,chat:i}=S.useLoaderData(),o=r(),[s,c]=(0,P.useState)(!1);return(0,F.jsxs)(N,{title:`Agents`,description:`Every Agent in every Team. Open one to talk to it; its model, skills and schedules are in its side panel.`,actions:(0,F.jsx)(a,{variant:`primary`,disabled:t.length===0||n.length===0,onClick:()=>c(!0),children:`Spawn an agent`}),children:[(0,F.jsx)(L,{agents:e,teams:n,templates:t,chat:i,onSpawn:()=>c(!0),onChanged:()=>o.invalidate({sync:!0})}),s&&(0,F.jsx)(y,{profiles:t,teams:n,onClose:()=>c(!1)})]})}export{z as component};
@@ -1 +0,0 @@
1
- import{J as e,K as t,o as n,r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{a,n as o}from"./api-CoLs57oO.js";import{_ as s,d as c,h as l,i as u,o as d,y as f}from"./parts-B0JBolvG.js";import{t as p}from"./file-text-DiP-LaEg.js";import{t as m}from"./SpawnDialog-ejwXnyxy.js";import{r as h}from"./index-J_Uqj4md.js";import{t as g}from"./ConfirmDialog-BVytx3kN.js";import{E as _,T as v,d as y,s as b,w as x,y as S}from"./manage-CsrV2hhK.js";import{t as C}from"./ManagePage-xlePXXx5.js";import{t as w}from"./AgentTemplateParts-Dl35c-Ux.js";var T=e(t()),E=i();function D(){let{templates:e,teamTemplates:t,chat:i,skills:D,starter:O,teams:k}=h.useLoaderData(),A=h.useSearch(),j=r(),M=n(),[N,P]=(0,T.useState)(A.new===1),[F,I]=(0,T.useState)(null),[L,R]=(0,T.useState)(null);return(0,E.jsxs)(C,{title:`Agent templates`,description:`What a new Agent starts with: its files, its model and its skills. Agents already spawned keep their own copies.`,actions:(0,E.jsx)(a,{variant:`primary`,onClick:()=>P(!0),children:`New Agent template`}),children:[(0,E.jsx)(f,{labelledBy:`manage-agent-templates`,icon:(0,E.jsx)(p,{className:`size-5`}),title:`Agent templates`,description:`Open one to edit its files, model and skills.`,action:(0,E.jsx)(c,{tone:`neutral`,children:b(e.length,`template`)}),children:e.length===0?(0,E.jsx)(u,{icon:(0,E.jsx)(p,{className:`size-5`}),title:`No Agent templates yet`,action:(0,E.jsx)(a,{variant:`primary`,onClick:()=>P(!0),children:`New Agent template`}),children:`Every Agent is spawned from a template.`}):(0,E.jsx)(d,{children:e.map(e=>{let n=y(e.defaultModel,i),r=x(e,t),o=`/templates/agents/${encodeURIComponent(e.id)}`;return(0,E.jsx)(l,{inline:!0,title:(0,E.jsx)(`a`,{href:o,className:`text-foreground hover:text-primary`,children:v(e)}),chip:n.missing&&(0,E.jsx)(c,{tone:`warning`,children:`Model not in Chat`}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:n.missing?`font-semibold text-warning`:``,children:n.name}),(0,E.jsx)(`span`,{children:S(e)}),(0,E.jsx)(`span`,{children:_(e,t)}),(0,E.jsx)(`code`,{children:e.id})]}),actions:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(a,{variant:`ghost`,"aria-label":`Spawn an agent from ${v(e)}`,onClick:()=>I(e.id),children:`Spawn`}),(0,E.jsx)(s,{label:`More for ${v(e)}`,items:[{label:`Edit files and settings`,onSelect:()=>{window.location.assign(o)}},{label:`Delete…`,danger:!0,disabledReason:r,onSelect:()=>R(e)}]})]})},e.id)})})}),N&&(0,E.jsx)(w,{chat:i,skills:D,starter:O,onClose:()=>{P(!1),A.new&&j({to:`/templates/agents`,search:{},replace:!0})}}),F&&(0,E.jsx)(m,{profiles:e,teams:k,profileId:F,onClose:()=>I(null)}),(0,E.jsx)(g,{open:L!==null,onOpenChange:e=>{e||R(null)},title:`Delete the ${L?v(L):``} template?`,description:(0,E.jsx)(`p`,{className:`m-0`,children:`This deletes the template and its files. No Agent and no Team template uses it.`}),confirmLabel:`Delete template`,onConfirm:async()=>{L&&(await o(`/api/profiles/${encodeURIComponent(L.id)}`,{method:`DELETE`}),await M.invalidate({sync:!0}))}})]})}export{D as component};
@@ -1 +0,0 @@
1
- import{u as e}from"./createLucideIcon-dN8ooBD1.js";var t=e(),n={primary:`btn-primary`,ghost:`ghost-btn`,danger:`danger-btn`};function r({variant:e,type:r,className:i,...a}){let o=i?`${n[e]} ${i}`:n[e];return(0,t.jsx)(`button`,{type:r??`button`,className:o,...a})}var i=[`__Host-bz_csrf`,`bz_csrf_dev`];function a(e,t){let n=[];for(let r of e?.split(`;`)??[]){let e=r.indexOf(`=`);e>0&&r.slice(0,e).trim()===t&&n.push(r.slice(e+1).trim())}return n}function o(e,t){return a(e,t)[0]}var s=class extends Error{status;code;body;constructor(e,t,n,r){super(e),this.status=t,this.code=n,this.body=r}};function c(){for(let e of i){let t=o(document.cookie,e);if(t)return{"x-bazilion-csrf":t}}return{}}async function l(e){let t=await e.text().catch(()=>``),n={};try{let e=JSON.parse(t);e&&typeof e==`object`&&(n=e)}catch{}let r=typeof n.error==`string`?n.error:t.slice(0,300)||`HTTP ${e.status}`,i=typeof n.code==`string`?n.code:void 0;return new s(r,e.status,i,n)}async function u(e,t={}){let n=t.method??(t.body===void 0?`GET`:`POST`),r=n===`GET`?{}:c(),i;t.body instanceof FormData?i=t.body:t.body!==void 0&&(r[`content-type`]=`application/json`,i=JSON.stringify(t.body));let a=await fetch(e,{method:n,headers:r,body:i,signal:t.signal});if(!a.ok)throw await l(a);return a}async function d(e,t={}){let n=await(await u(e,t)).text();return n?JSON.parse(n):void 0}function f(e){return e instanceof Error?e.message:String(e)}export{r as a,f as i,d as n,u as r,s as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-dN8ooBD1.js";var t=e(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]);export{t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,n,u as r}from"./createLucideIcon-dN8ooBD1.js";import{a as i,i as a,n as o}from"./api-CoLs57oO.js";import{c as s,d as c,g as l,h as u,i as d,o as f,r as p,t as m,y as h}from"./parts-B0JBolvG.js";import{Dt as g,Mt as _,Nt as v,d as y}from"./index-J_Uqj4md.js";import{t as b}from"./Segmented-Co4n2C5X.js";import{t as x}from"./model-facts-DoB6QD5y.js";import{r as S}from"./form-Bvr_f9lR.js";import{a as C,m as w,o as T,t as E}from"./manage-CsrV2hhK.js";var D=e(t()),O=r(),k=`/api/attention?state=all&limit=200`,A=`/api/attention/summary`;function j(){let e=y.useLoaderData(),[t,r]=(0,D.useState)(e.list),[j,M]=(0,D.useState)(e.summary),[N,P]=(0,D.useState)(e.now),[F,I]=(0,D.useState)(`open`),[L,R]=(0,D.useState)(`all`),[z,B]=(0,D.useState)(`all`),[V,H]=(0,D.useState)(null),[U,W]=(0,D.useState)(null),G=t.items.filter(e=>(F===`all`||(F===`open`?e.acknowledgedAt===null:e.acknowledgedAt!==null))&&(L===`all`||e.kind===L)&&(z===`all`||e.severity===z)),K=t.items.filter(e=>e.acknowledgedAt===null).length,q=t.items.filter(e=>e.acknowledgeable&&e.acknowledgedAt===null).length,J=[...new Set([...t.degraded,...j.degraded].map(e=>e.kind))],Y=T(j);async function X(){let[e,t]=await Promise.all([o(k),o(A)]);r(e),M(t),P(Date.now())}async function Z(e,t){H(e),W(null);try{let e=await t();e&&W({text:e,failed:!1})}catch(e){W({text:a(e),failed:!0})}finally{await X().catch(()=>{}),H(null)}}let Q=(e,t)=>Z(e.key,async()=>{let n=`/api/attention/${encodeURIComponent(e.key)}`;return await o(t?`${n}/acknowledge`:`${n}/acknowledgement`,{method:t?`POST`:`DELETE`}),null}),$=()=>Z(`all`,async()=>{let{acknowledged:e}=await o(`/api/attention/acknowledge-all`,{method:`POST`});return`Acknowledged ${e===1?`1 item`:`${e} items`}. Lesson proposals and paused queues stay open until they are dealt with.`});return(0,O.jsxs)(v,{children:[(0,O.jsx)(_,{title:`Attention`,description:`Decisions waiting for you and failures worth a look, from every Agent. Act on an item where it comes from; acknowledge the ones that only inform.`}),(0,O.jsx)(m,{tone:Y.tone,lead:Y.lead,children:Y.rest}),J.length>0&&(0,O.jsxs)(m,{tone:`warning`,role:`alert`,lead:`Some items could not be loaded.`,children:[J.map(e=>E[e]).join(`, `),` are missing from the list.`]}),(0,O.jsxs)(h,{labelledBy:`attention-items`,icon:(0,O.jsx)(g,{className:`size-5`}),title:`Items`,description:`Open items need you; history keeps the ones you acknowledged.`,action:q>0&&(0,O.jsxs)(i,{variant:`ghost`,disabled:V!==null,onClick:()=>void $(),children:[`Acknowledge `,q===1?`the informational one`:`informational ones`]}),children:[(0,O.jsxs)(s,{children:[(0,O.jsx)(b,{label:`Which items`,value:F,onChange:I,options:[{id:`open`,label:`Open ${K}`},{id:`acknowledged`,label:`History`},{id:`all`,label:`All`}]}),(0,O.jsx)(S,{label:`Kind`,value:L,onChange:R,options:[{value:`all`,label:`All kinds`},...Object.entries(E).map(([e,t])=>({value:e,label:t}))]}),(0,O.jsx)(S,{label:`Severity`,value:z,onChange:B,options:[{value:`all`,label:`Any severity`},{value:`action_required`,label:`Needs you`},{value:`error`,label:`Errors`},{value:`warning`,label:`Warnings`}]})]}),U&&(0,O.jsx)(p,{className:`py-3`,children:(0,O.jsx)(l,{tone:U.failed?`warning`:`success`,role:U.failed?`alert`:`status`,children:U.text})}),G.length===0?(0,O.jsx)(d,{icon:(0,O.jsx)(g,{className:`size-5`}),title:F===`open`&&L===`all`&&z===`all`?`Nothing needs you`:`No item matches`,children:`Items come from learning reviews, schedules, follow-up queues and message loops.`}):(0,O.jsx)(f,{children:G.map(e=>{let t=w(e.severity),r=e.acknowledgedAt!==null;return(0,O.jsx)(u,{title:e.title,chip:r?(0,O.jsx)(c,{tone:`neutral`,children:`Acknowledged`}):(0,O.jsx)(c,{tone:t.tone,children:t.label}),meta:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{children:E[e.kind]}),(0,O.jsx)(`span`,{children:C(e)}),(0,O.jsx)(`time`,{dateTime:new Date(e.occurredAt).toISOString(),title:new Date(e.occurredAt).toISOString().slice(0,16).replace(`T`,` `),children:x(e.occurredAt,N)})]}),actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(n,{to:e.href,className:`ghost-btn no-underline`,children:e.kind===`lesson_proposal`?`Review lesson`:`Open`}),e.acknowledgeable&&(0,O.jsx)(i,{variant:`ghost`,disabled:V!==null,onClick:()=>void Q(e,!r),children:r?`Back to open`:`Acknowledge`})]}),children:(0,O.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.diagnostic})},e.key)})})]})]})}export{j as component};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-dN8ooBD1.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,o as n,t as r,u as i}from"./createLucideIcon-dN8ooBD1.js";import{a,i as o,n as s}from"./api-CoLs57oO.js";import{t as c}from"./images-BKjyhYUc.js";import{S as l,T as u,b as d,d as f,n as p,t as m,v as h,x as g,y as _}from"./parts-B0JBolvG.js";import{t as v}from"./chevron-right-BqOIX9UM.js";import{t as y}from"./message-square-DnpSOYv4.js";import{t as b}from"./plus-DZ3KVo7E.js";import{f as x}from"./index-J_Uqj4md.js";import{r as S}from"./use-resource-BaTkTGvG.js";import{t as C}from"./Dialog-BTDzv3J5.js";import{t as w}from"./ConfirmDialog-BVytx3kN.js";import{t as T}from"./Segmented-Co4n2C5X.js";import{d as E,f as D,i as O,l as k,o as A,r as j,t as M,u as N}from"./model-facts-DoB6QD5y.js";import{t as P}from"./ConfigPage-DiQiJXP6.js";import{c as F,l as I,o as L,s as R,t as z}from"./AddProviderDialog-CO_uijWF.js";var B=r(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),V=e(t(),1),H=i(),U=[{id:`all`,label:`All`},{id:`images`,label:`Sees images`},{id:`reasoning`,label:`Reasoning`}],W=80;function G({providers:e,chat:t,onClose:n,onSaved:r,onAddProvider:i}){let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(`all`),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),x=S(async t=>{let n=await Promise.all(e.map(async e=>({provider:e,catalog:await s(`/api/config/providers/${encodeURIComponent(e.id)}/catalog`,{signal:t})})));return g(Object.fromEntries(n.map(({provider:e,catalog:t})=>[e.id,t.models.filter(e=>e.selected).map(e=>e.id)]))),n},[e.map(e=>e.id).join(`,`)]),w=m??{},E=(e,t)=>w[e]?.includes(t)??!1,D=(e,t)=>g(n=>{let r=n?.[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}),O=(e,t)=>c?A(e,c):e.dated&&!f&&!E(t.id,e.id)?!1:u===`images`?e.images===!0:u===`reasoning`?e.reasoning===!0:!0,j=(0,V.useMemo)(()=>(x.data??[]).filter(({provider:e,catalog:t})=>{let n=t.models.filter(e=>e.selected).map(e=>e.id),r=w[e.id]??[];return n.length!==r.length||n.some(e=>!r.includes(e))}),[x.data,w]),M=t.filter(e=>e.usedBy.agents>0&&j.some(({provider:t})=>t.id===e.provider)&&!E(e.provider,e.id)),N=Object.values(w).reduce((e,t)=>e+t.length,0);async function P(){v(!0),b(null);try{for(let{provider:e}of j)await s(`/api/config/providers/${encodeURIComponent(e.id)}/models`,{method:`PUT`,body:{models:w[e.id]??[]}});await r(),n()}catch(e){b(o(e)),v(!1)}}return(0,H.jsxs)(C,{title:`Chat models`,description:`Tick the models your Agents may use. Each Agent and each template picks one of them.`,onClose:n,busy:_,className:`top-[4dvh] max-h-[92dvh] max-w-3xl translate-y-0 content-start`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(h,{label:`Search models`,placeholder:`Search by name, for example haiku`,value:c,onChange:l,className:`flex-1 basis-60`}),(0,H.jsx)(T,{label:`Show`,value:u,options:U,onChange:d})]}),(0,H.jsxs)(`div`,{className:`max-h-[min(58dvh,36rem)] min-h-40 overflow-y-auto rounded-xl border border-border`,children:[x.loading&&!x.data&&(0,H.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Reading the model lists…`}),x.error&&(0,H.jsx)(`div`,{role:`alert`,className:`p-4 text-sm text-danger`,children:x.error}),x.data?.length===0&&(0,H.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No provider is connected yet. Add one to see its models here.`}),(x.data??[]).map(({provider:e,catalog:t})=>{let n=t.models.filter(t=>O(t,e)),r=n.slice(0,W),i=t.models.filter(t=>t.dated&&!E(e.id,t.id)).length;return c&&n.length===0?null:(0,H.jsxs)(`section`,{"aria-label":e.displayName,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 border-b border-border bg-muted/50 px-4 py-2`,children:[(0,H.jsx)(`h3`,{className:`m-0 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:e.displayName}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(w[e.id]??[]).length,` of `,t.models.length,` in use`]}),t.listError&&(0,H.jsxs)(`span`,{className:`text-xs text-warning`,children:[`Its own list could not be read: `,t.listError]})]}),r.length===0&&(0,H.jsx)(`div`,{className:`border-b border-border px-4 py-3 text-sm text-muted-foreground`,children:t.models.length===0?`It lists no model.`:`Nothing matches.`}),r.map(t=>(0,H.jsx)(R,{model:{...t,suggested:!1},connect:e.connect,checked:E(e.id,t.id),disabled:_,onToggle:()=>D(e.id,t.id),className:`px-4 hover:bg-accent/30`},t.id)),n.length>r.length&&(0,H.jsxs)(`div`,{className:`border-b border-border px-4 py-2 text-xs text-muted-foreground`,children:[n.length-r.length,` more: search to narrow them down.`]}),!c&&i>0&&(0,H.jsx)(`div`,{className:`border-b border-border px-4 py-1.5`,children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`text-xs font-semibold text-primary`,children:f?`Hide dated versions`:`Show ${i} dated ${i===1?`version`:`versions`} of the same models`})})]},e.id)})]}),M.length>0&&(0,H.jsxs)(`p`,{role:`status`,className:`m-0 rounded-xl bg-warning/10 px-3 py-2 text-sm text-warning`,children:[M.map(e=>k(e)).join(`, `),` `,M.length===1?`is`:`are`,` in use by Agents. They are refused until you give them another model in their Agent tab.`]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:y}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-frost pt-4`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm text-muted-foreground`,children:N===1?`1 model in Chat`:`${N} models in Chat`}),(0,H.jsx)(`button`,{type:`button`,onClick:i,className:`text-sm font-semibold text-primary`,children:`A model from another provider?`}),(0,H.jsx)(a,{variant:`ghost`,disabled:_,onClick:n,children:`Cancel`}),(0,H.jsx)(a,{variant:`primary`,disabled:_||j.length===0,onClick:()=>void P(),children:_?`Saving…`:`Save`})]})]})}function K({providers:e,chat:t,now:n,onOpen:r,onTestAll:i,testing:o}){let s=e.filter(e=>e.enabled);if(s.length===0)return null;let c=s.filter(e=>e.state===`failing`||e.state===`incomplete`),l=s.filter(e=>e.state===`untested`&&e.models.length>0);if(c.length>0)return(0,H.jsx)(`div`,{className:`grid gap-2`,children:c.map(e=>{let i=t.filter(t=>t.provider===e.id),o=i.reduce((e,t)=>e+t.usedBy.agents,0);return(0,H.jsx)(m,{tone:`warning`,lead:(0,H.jsxs)(H.Fragment,{children:[e.check?.failure?.title??`${e.displayName}: ${E(e,n).label.toLowerCase()}`,`.`]}),action:(0,H.jsxs)(a,{variant:`ghost`,onClick:()=>r(e.id),children:[`Open `,e.displayName]}),children:i.length===0?`No chat model runs on it.`:`${i.length===1?`1 chat model runs`:`${i.length} chat models run`} on it${o===0?``:`, used by ${o===1?`1 Agent`:`${o} Agents`}`}.`},e.id)})});if(l.length>0)return(0,H.jsx)(m,{tone:`neutral`,lead:l.length===1?`${l[0]?.displayName} has not been tested.`:`${l.length} providers have not been tested.`,action:(0,H.jsx)(a,{variant:`ghost`,disabled:o,onClick:i,children:o?`Testing…`:l.length===1?`Test it`:`Test them`}),children:`A test sends one short message to the cheapest model of each.`});let u=s.filter(e=>e.state===`working`);return u.length===0?null:(0,H.jsxs)(m,{tone:`success`,lead:u.length===1?`Your provider answers.`:`Every provider answers.`,action:(0,H.jsx)(a,{variant:`ghost`,disabled:o,onClick:i,children:o?`Testing…`:`Test again`}),children:[t.length===1?`1 chat model`:`${t.length} chat models`,` for your Agents.`]})}function q({chat:e,hasProviders:t,onPick:n,onChanged:r}){let[i,c]=(0,V.useState)(null),[u,d]=(0,V.useState)(null);async function f(t){let n=e.filter(e=>e.provider===t.provider&&e.id!==t.id).map(e=>e.id);await s(`/api/config/providers/${encodeURIComponent(t.provider)}/models`,{method:`PUT`,body:{models:n}}),await r()}function m(e){d(null),e.usedBy.agents>0||e.usedBy.templates.length>0?c(e):f(e).catch(e=>d(o(e)))}return(0,H.jsxs)(_,{labelledBy:`setup-chat`,icon:(0,H.jsx)(y,{className:`size-5`}),title:`Chat`,description:`The models Agents think with. Each Agent and each template uses one of them.`,action:(0,H.jsxs)(a,{variant:`primary`,disabled:!t,onClick:n,children:[(0,H.jsx)(b,{className:`size-4`,"aria-hidden":`true`}),`Add models`]}),children:[e.length>0&&(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 hidden bg-muted/50 py-2 text-[0.7rem] font-bold uppercase tracking-[0.08em] text-muted-foreground lg:flex`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-[2.2] basis-52`,children:`Model`}),(0,H.jsx)(`span`,{className:`w-28 shrink-0`,children:`Provider`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-[2] basis-48`,children:`Can do`}),(0,H.jsx)(`span`,{className:`w-40 shrink-0`,children:`Price per 1M tokens`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-[1.4] basis-36`,children:`Used by`}),(0,H.jsx)(`span`,{className:`w-8 shrink-0`})]}),e.map(e=>{let t=e.providerState===`failing`||e.providerState===`incomplete`;return(0,H.jsxs)(`div`,{className:`${p} min-h-16 py-2.5`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-[2.2] basis-52`,children:[(0,H.jsx)(`div`,{className:`text-[0.95rem] font-semibold text-foreground`,children:k(e)}),e.name&&(0,H.jsx)(`div`,{className:`break-all font-mono text-[0.72rem] text-muted-foreground`,children:e.id})]}),(0,H.jsx)(`div`,{className:`w-28 shrink-0 text-sm`,children:e.providerName}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[2] basis-48 text-[0.82rem] ${t?`font-semibold text-warning`:`text-muted-foreground`}`,children:t?`${e.providerName} is not working`:O(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`w-40 shrink-0 text-[0.82rem]`,children:N(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[1.4] basis-36 text-[0.82rem] text-muted-foreground`,children:D(e.usedBy)}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${k(e)} from Chat`,onClick:()=>m(e),className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-danger`,children:(0,H.jsx)(l,{className:`size-4`,"aria-hidden":`true`})})]},e.value)}),e.length===0&&(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-5 text-sm text-muted-foreground`,children:t?`No chat model yet. Agents cannot answer until one is added.`:`No chat model yet. Add a provider below, and its models appear here.`}),u&&(0,H.jsx)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-danger`,children:u}),(0,H.jsx)(w,{open:i!==null,onOpenChange:e=>{e||c(null)},title:`Remove ${i?k(i):``} from Chat?`,description:i&&(0,H.jsxs)(`p`,{className:`m-0`,children:[`It is used by `,D(i.usedBy),`.`,` `,i.usedBy.agents>0&&`Those Agents are refused until you give them another model in their Agent tab. `,i.usedBy.templates.length>0&&`An Agent template on it moves to another model by itself.`]}),confirmLabel:`Remove from Chat`,onConfirm:async()=>{i&&await f(i)}})]})}function J({images:e,onConnect:t,onChanged:n}){let[r,i]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=e.routes.find(t=>t.id===e.selected),m=d?.ready===!0,h=r??e.selected;async function g(e){i(e),u(null);try{await s(`/api/config/fields/BAZILION_IMAGE_MODEL`,{method:`PUT`,body:{value:e}}),await n()}catch(e){u(o(e))}finally{i(null)}}let v=(e,t,n,i)=>(0,H.jsxs)(`label`,{className:`${p} m-0 min-h-[3.25rem] py-2 ${n?`cursor-pointer`:``} ${h===e?`bg-accent/40`:``}`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`image-model`,checked:h===e,disabled:!n||r!==null,onChange:()=>void g(e),className:`m-0 size-[18px] shrink-0 accent-[var(--color-sapphire)]`}),t,(0,H.jsx)(`span`,{className:`ml-auto flex shrink-0 justify-end sm:w-44`,children:i})]},e);return(0,H.jsxs)(_,{labelledBy:`setup-images`,icon:(0,H.jsx)(c,{className:`size-5`}),title:`Images`,description:`What Agents draw with. One model for every Agent, up to four images a turn.`,action:(0,H.jsx)(f,{tone:m?`success`:d?`warning`:`neutral`,children:m?`On: ${d.model}`:d?`Needs ${d.needs}`:`Off`}),children:[e.routes.map(e=>v(e.id,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-[1.6] basis-60 text-[0.95rem]`,children:[(0,H.jsx)(`span`,{className:`font-semibold ${e.ready?`text-foreground`:`text-muted-foreground`}`,children:e.model}),` `,(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`through `,e.providerName]})]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-44 text-[0.82rem] text-muted-foreground`,children:e.billing})]}),e.ready,e.ready?(0,H.jsx)(`span`,{className:`text-[0.82rem] font-semibold text-success`,children:`Ready`}):(0,H.jsx)(a,{variant:`ghost`,onClick:()=>t(e.provider),children:e.provider===`openai-codex`?`Sign in`:`Connect ${e.providerName}`}))),v(`off`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-[1.6] basis-60 text-[0.95rem] font-semibold text-foreground`,children:`Off`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-44 text-[0.82rem] text-muted-foreground`,children:`Agents have no image tool`})]}),!0,null),e.selected!==`off`&&!d&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-warning`,children:[`BAZILION_IMAGE_MODEL is set to “`,e.selected,`”, which is not an image route. Choose one above.`]}),l&&(0,H.jsx)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-danger`,children:l})]})}function Y({providers:e,total:t,images:n,now:r,onOpen:i,onAdd:o}){let s=n.routes.find(e=>e.id===n.selected&&e.ready);return(0,H.jsxs)(_,{labelledBy:`setup-providers`,icon:(0,H.jsx)(B,{className:`size-5`}),title:`Providers`,description:`The accounts and local servers your models run on.`,action:(0,H.jsxs)(a,{variant:`primary`,onClick:o,children:[(0,H.jsx)(b,{className:`size-4`,"aria-hidden":`true`}),`Add a provider`]}),children:[e.map(e=>{let t=e.enabled?e.models.length:0,n=[t>0?`Chat: ${t===1?`1 model`:`${t} models`}`:null,s?.provider===e.id?`Images`:null].filter(Boolean),a=E(e,r);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`${p} min-h-[4.25rem] w-full py-3 text-left transition-colors hover:bg-accent/30`,children:[(0,H.jsx)(F,{name:e.displayName,tone:a.tone}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-[1.6] basis-56`,children:[(0,H.jsx)(`span`,{className:`block text-[0.95rem] font-semibold text-foreground`,children:e.displayName}),(0,H.jsx)(`span`,{className:`block truncate text-[0.82rem] text-muted-foreground`,children:j(e)})]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-[0.82rem] text-muted-foreground`,children:n.length>0?n.join(` · `):`Not used yet`}),(0,H.jsx)(I,{provider:e,now:r}),(0,H.jsx)(v,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)}),e.length===0&&(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-5 text-sm text-muted-foreground`,children:`No provider yet. Add one to give your Agents a model.`}),(0,H.jsxs)(`div`,{className:`${p} bg-muted/50 py-3 text-[0.82rem] text-muted-foreground`,children:[t-e.length,` more can be added: a ChatGPT plan, API keys from OpenAI, Anthropic, Google and many others, or a model server on this computer.`]})]})}function X({field:e}){let t=n(),r=`/api/config/fields/${encodeURIComponent(e.envVar)}`,i=(0,V.useId)(),c=`${i}-description`,[l,u]=(0,V.useState)(e.kind===`config`?e.value??``:``),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),y=e.kind===`secret`&&l.trim().length===0;async function b(n){if(n.preventDefault(),y){m(e.set?`Paste a replacement value, or use remove credential to explicitly clear the stored secret.`:`A secret value is required.`);return}f(!0),m(null);try{await s(r,{method:`PUT`,body:{value:l}}),g(Date.now()),e.kind===`secret`&&u(``),await t.invalidate()}catch(e){m(o(e))}finally{f(!1)}}async function x(){await s(r,{method:`DELETE`}),u(``),m(null),g(Date.now()),await t.invalidate()}return(0,H.jsxs)(`form`,{onSubmit:b,className:`grid grid-cols-1 gap-2 border-b py-3 last:border-0 md:grid-cols-[12rem_minmax(0,1fr)_auto_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e.label}),e.description&&(0,H.jsx)(`div`,{id:c,className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),(0,H.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer`,children:`Advanced identifier`}),(0,H.jsx)(`code`,{className:`mt-1 inline-block break-all font-mono`,children:e.envVar})]})]}),(0,H.jsx)(`div`,{className:`min-w-0`,children:e.kind===`config`?(0,H.jsx)(`input`,{id:i,type:`text`,"aria-describedby":e.description?c:void 0,value:l,onChange:e=>u(e.target.value),placeholder:e.placeholder??``,className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`input`,{id:i,type:`password`,"aria-describedby":e.description?c:void 0,value:l,onChange:e=>u(e.target.value),placeholder:e.set?`(paste to replace stored value)`:e.placeholder??`paste key…`,autoComplete:`off`,className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30`}),e.set&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Blank keeps the current credential. Removal is a separate explicit action.`})]})}),(0,H.jsxs)(`span`,{className:`text-xs`,children:[e.kind===`secret`&&e.set&&(0,H.jsx)(`span`,{className:`rounded-full bg-success/10 text-success px-1.5 py-0.5`,title:`preview: ${e.preview??``}`,children:`set`}),h&&Date.now()-h<2e3&&(0,H.jsx)(`span`,{role:`status`,className:`text-success ml-2`,children:`saved ✓`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-self-end`,children:[(0,H.jsx)(a,{variant:`ghost`,type:`submit`,disabled:d||y,className:`text-xs`,children:`save`}),e.kind===`secret`&&e.set&&(0,H.jsx)(a,{variant:`danger`,className:`text-xs`,onClick:()=>v(!0),children:`remove`})]}),p&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-danger md:col-span-4`,children:p}),(0,H.jsx)(w,{open:_,title:`Remove ${e.label}?`,description:(0,H.jsxs)(`p`,{children:[`This permanently deletes the stored `,(0,H.jsx)(`code`,{className:`font-mono`,children:e.envVar}),` `,`credential. Features that use it will fail until you save a replacement.`]}),confirmLabel:`remove stored credential`,onConfirm:x,onOpenChange:v})]})}var Z=`m-0 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`;function Q({provider:e,chat:t,imageRoutes:n,imageSelected:r,onClose:i,onChanged:c,onPickModels:l,onReconnect:f}){let p=(0,V.useMemo)(()=>Date.now(),[]),[m,h]=(0,V.useState)(null),[_,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(!1),[S,T]=(0,V.useState)(!1),E=`/api/config/providers/${encodeURIComponent(e.id)}`,{state:O,check:A}=e,j=e.connect===`signin`,N=e.fields.filter(e=>!e.advanced),P=e.fields.filter(e=>e.advanced),F=t.reduce((e,t)=>e+t.usedBy.agents,0),I=n.find(e=>e.id===r);async function R(e,t){h(e),y(null);try{await t(),await c()}catch(e){y(o(e))}finally{h(null)}}let z=()=>R(`test`,()=>s(`${E}/test`,{method:`POST`})),B=e=>R(`switch`,()=>s(`${E}/enabled`,{method:`PUT`,body:{enabled:e}})),U=()=>R(`signin`,()=>s(`/api/auth/openai/login`,{method:`POST`}));async function W(){await s(E,{method:`DELETE`}),await c(),i()}let G=e.models.length>0,K=(e,t=!1)=>(0,H.jsx)(a,{variant:t?`primary`:`ghost`,disabled:m!==null,onClick:()=>void z(),children:e});return(0,H.jsxs)(C,{title:e.displayName,description:e.hint,onClose:i,busy:m===`signin`,className:`top-[4dvh] max-h-[92dvh] max-w-2xl translate-y-0 content-start gap-5`,children:[m===`test`?(0,H.jsx)(`div`,{className:`rounded-2xl border border-border bg-muted/40 p-4`,children:(0,H.jsx)(g,{children:`Asking for a short reply…`})}):m===`signin`?(0,H.jsx)(`div`,{className:`rounded-2xl border border-border bg-muted/40 p-4`,children:(0,H.jsx)(g,{children:`Waiting for the ChatGPT sign-in in the browser…`})}):O===`working`&&A?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-success/30 bg-success/10 p-4 text-sm`,children:[(0,H.jsx)(u,{className:`size-5 shrink-0 text-success`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsxs)(`div`,{className:`font-semibold text-foreground`,children:[A.modelName??A.model,` answered in `,((A.ms??0)/1e3).toFixed(1),` s`]}),(0,H.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Tested `,M(A.at,p)]})]}),K(`Test again`)]}):O===`failing`&&A?.failure?(0,H.jsxs)(L,{failure:A.failure,children:[(0,H.jsxs)(`span`,{className:`mr-auto self-center text-xs text-muted-foreground`,children:[`Tried `,M(A.at,p)]}),A.failure.kind===`credentials`&&(0,H.jsx)(a,{variant:`ghost`,onClick:j?()=>void U():f,children:j?`Sign in again`:`Replace the key`}),K(`Try again`,!0)]}):O===`incomplete`?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-warning/35 bg-warning/10 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:j?`Not signed in`:`Switched on, but its credentials are missing`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Agents on its models are refused until it is connected again.`})]}),(0,H.jsx)(a,{variant:`primary`,onClick:j?()=>void U():f,children:j?`Sign in with ChatGPT`:`Connect`})]}):O===`off`?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:e.models.length===0?`Saved, not in use`:`Turned off`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:e.models.length===0?`Connect it to choose its models and test it.`:`Its models are out of Chat until you turn it on again. What is saved stays saved.`})]}),e.models.length===0?(0,H.jsx)(a,{variant:`primary`,disabled:m!==null,onClick:f,children:`Connect`}):(0,H.jsx)(a,{variant:`primary`,disabled:m!==null||!e.configured,onClick:()=>void B(!0),children:`Turn on`})]}):(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Not tested yet`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:G?`A test sends one short message to its cheapest model in Chat.`:`It has no model in Chat, so there is nothing to ask.`})]}),G&&K(`Test now`,!0)]}),_&&(0,H.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:_}),(0,H.jsxs)(`section`,{"aria-label":`Credentials`,children:[(0,H.jsx)(`h3`,{className:Z,children:j?`Sign-in`:e.connect===`local`?`Address`:`Credentials`}),(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 basis-56 text-sm`,children:j?e.configured?(0,H.jsxs)(H.Fragment,{children:[`Signed in with your ChatGPT account`,e.account&&(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.account,`)`]}),`. Bazilion renews the sign-in by itself.`]}):`Not signed in.`:N.length===0?(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:e.configured?`Read from the environment of the machine Bazilion runs on.`:`Not found in the environment of the machine Bazilion runs on.`}):(0,H.jsx)(`dl`,{className:`m-0 grid gap-1`,children:N.map(t=>(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-2`,children:[(0,H.jsx)(`dt`,{className:`text-muted-foreground`,children:t.label}),(0,H.jsx)(`dd`,{className:`m-0 min-w-0 break-all font-mono text-[0.85em]`,children:t.kind===`secret`?t.set?`${t.preview??`saved`}, stored encrypted`:`not saved`:t.value||(e.address??`not set`)})]},t.envVar))})}),j?(0,H.jsx)(a,{variant:`ghost`,disabled:m!==null,onClick:()=>void U(),children:e.configured?`Sign in again`:`Sign in with ChatGPT`}):N.length>0&&(0,H.jsx)(a,{variant:`ghost`,disabled:m!==null,onClick:f,children:e.connect===`local`?`Change the address`:N.some(e=>e.kind===`secret`&&!e.set)?`Add the key`:`Replace the key`})]})]}),(0,H.jsxs)(`section`,{"aria-label":`Its models in Chat`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`h3`,{className:`${Z} flex-1`,children:`Its models in Chat`}),(0,H.jsx)(`button`,{type:`button`,onClick:l,className:`text-sm font-semibold text-primary`,children:`Choose models`})]}),(0,H.jsxs)(`ul`,{className:`m-0 mt-2 list-none divide-y divide-border overflow-hidden rounded-xl border border-border p-0`,children:[e.models.length===0&&(0,H.jsx)(`li`,{className:`px-3 py-2.5 text-sm text-muted-foreground`,children:`None of its models is in Chat.`}),e.models.map(e=>{let n=t.find(t=>t.id===e);return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 px-3 py-2.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 font-semibold text-foreground`,children:n?k(n):e}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n?D(n.usedBy):`Out of Chat while this is turned off`})]},e)})]}),n.length>0&&(0,H.jsx)(`p`,{className:`m-0 mt-2 text-sm text-muted-foreground`,children:I?`Images are drawn by ${I.model} through this provider.`:`Can also draw images: ${[...new Set(n.map(e=>e.model))].join(`, `)}.`})]}),(0,H.jsxs)(`section`,{"aria-label":`More settings`,children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":b,onClick:()=>x(e=>!e),className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[(0,H.jsx)(v,{className:`size-4 text-muted-foreground transition-transform ${b?`rotate-90`:``}`,"aria-hidden":`true`}),`More settings`]}),b&&(0,H.jsxs)(`div`,{className:`mt-2 grid gap-3 rounded-xl border border-border bg-muted/40 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Agents may use this provider`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Turn off to pause it without removing what is saved.`})]}),(0,H.jsx)(d,{checked:e.enabled,label:`Agents may use this provider`,disabled:m!==null||!e.enabled&&!e.configured,onChange:e=>void B(e)})]}),P.map(e=>(0,H.jsx)(X,{field:e},e.envVar)),e.fields.length>0&&(0,H.jsxs)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:[`Setting names, for `,(0,H.jsx)(`code`,{children:`bazilion config set`}),` and the daemon’s environment:`,` `,e.fields.map(e=>e.envVar).join(`, `),`. A value set in the environment wins over the one saved here.`]})]})]}),(0,H.jsxs)(`section`,{"aria-label":`Disconnect`,className:`border-t border-frost pt-4`,children:[(0,H.jsxs)(a,{variant:`danger`,disabled:m!==null,onClick:()=>T(!0),children:[`Disconnect `,e.displayName]}),(0,H.jsxs)(`p`,{className:`m-0 mt-2 text-sm text-muted-foreground`,children:[`Removes`,` `,j?`the sign-in`:e.connect===`local`?`the address`:`the key`,`, its models from Chat and its test.`]})]}),(0,H.jsx)(w,{open:S,onOpenChange:T,title:`Disconnect ${e.displayName}?`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:`m-0`,children:[`This removes`,` `,j?`the saved ChatGPT sign-in`:e.connect===`local`?`the saved address`:`the saved credentials`,` `,`and takes its `,e.models.length===1?`model`:`models`,` out of Chat.`]}),F>0&&(0,H.jsxs)(`p`,{className:`m-0 mt-2`,children:[F===1?`1 Agent runs`:`${F} Agents run`,` on its models and will be refused until given another model. Agent templates move to another model by themselves.`]}),I&&(0,H.jsx)(`p`,{className:`m-0 mt-2`,children:`Image generation stops until another route is chosen.`})]}),confirmLabel:`Disconnect ${e.displayName}`,onConfirm:W})]})}function $(){let{providers:e,models:t,now:r}=x.useLoaderData(),i=x.useSearch(),a=x.useNavigate(),o=n(),[c,l]=(0,V.useState)(!1),u=e.filter(e=>e.listed),d=u.filter(e=>e.enabled),f=e=>void a({search:e}),p=()=>f({}),m=()=>o.invalidate({sync:!0}),h=e.find(e=>e.id===i.provider&&e.listed);async function g(){l(!0);try{await Promise.all(d.filter(e=>e.models.length>0).map(e=>s(`/api/config/providers/${encodeURIComponent(e.id)}/test`,{method:`POST`}).catch(()=>void 0))),await m()}finally{l(!1)}}return(0,H.jsxs)(P,{title:`Models`,description:`What your Agents think and draw with, and the accounts behind it.`,children:[(0,H.jsx)(K,{providers:u,chat:t.chat,now:r,testing:c,onOpen:e=>f({provider:e}),onTestAll:()=>void g()}),(0,H.jsx)(q,{chat:t.chat,hasProviders:d.length>0,onPick:()=>f({pick:!0}),onChanged:m}),(0,H.jsx)(J,{images:t.images,onConnect:e=>f({add:e}),onChanged:m}),(0,H.jsx)(Y,{providers:u,total:e.length,images:t.images,now:r,onOpen:e=>f({provider:e}),onAdd:()=>f({add:`new`})}),i.add&&(0,H.jsx)(z,{providers:e,imageRoutes:t.images.routes,start:i.add===`new`?void 0:i.add,onClose:p,onConnected:m,onOpenProvider:e=>f({provider:e})},i.add),i.pick&&(0,H.jsx)(G,{providers:d,chat:t.chat,onClose:p,onSaved:m,onAddProvider:()=>f({add:`new`})}),h&&(0,H.jsx)(Q,{provider:h,chat:t.chat.filter(e=>e.provider===h.id),imageRoutes:t.images.routes.filter(e=>e.provider===h.id),imageSelected:t.images.selected,onClose:p,onChanged:m,onPickModels:()=>f({pick:!0}),onReconnect:()=>f({add:h.id})},h.id)]})}export{$ as component};
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function k(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+k(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+k(a,u),c+=A(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+k(a,u++),c+=A(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return A(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function j(e,t,n){if(e==null)return e;var r=[],i=0;return A(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var M=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ie={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ie,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:re}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,M)}catch(e){M(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),f=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=d()}));function p(e){return e[e.length-1]}function m(e){return typeof e==`function`}function h(e,t){return m(e)?e(t):e}var g=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;function v(e){for(let t in e)if(g.call(e,t))return!0;return!1}var y=()=>Object.create(null),b=(e,t)=>x(e,t,y);function x(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=T(e)&&T(i);if(!a&&!(C(e)&&C(i)))return i;let o=a?e:S(e);if(!o)return i;let s=a?i:S(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:g.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=x(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function S(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!_.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!_.call(e,t))return!1;r.push(t)}return r}function C(e){if(!w(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!w(n)||!n.hasOwnProperty(`isPrototypeOf`))}function w(e){return Object.prototype.toString.call(e)===`[object Object]`}function T(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function E(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!E(e[r],t[r],n))return!1;return!0}if(C(e)&&C(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!E(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!E(e[o],t[o],n)))return!1;return i===a}return!1}function D(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function O(e){return typeof e?.message==`string`?e.message.startsWith(`Failed to fetch dynamically imported module`)||e.message.startsWith(`error loading dynamically imported module`)||e.message.startsWith(`Importing a module script failed`):!1}function ee(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}var te=/[\x00-\x1f\x7f"<>`{}]/g;function k(e){return e.replace(te,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function ne(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return k(t)}var A=[`http:`,`https:`,`mailto:`,`tel:`];function j(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}var re={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},M=/[&><\u2028\u2029]/g;function ie(e){return e.replace(M,e=>re[e])}function ae(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=ne(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=ne(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function oe(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function N(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function P(){throw Error(`Invariant failed`)}function F(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var I=4,L=5;function se(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function R(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=se(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function z(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=n.options?.params?.parse??n.options?.parseParams;for(;s<o;){let e=R(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=H(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=H(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=U(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=U(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=U(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=H(n.fullPath??n.from);e.kind=L,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=H(n.fullPath??n.from);e.kind=I,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=l??null,i.priority=n.options?.params?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)z(e,t,r,s,i,a,o)}function B(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function V(e){if(e.pathless)for(let t of e.pathless)V(t);if(e.static)for(let t of e.static.values())V(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())V(t);if(e.dynamic?.length){e.dynamic.sort(B);for(let t of e.dynamic)V(t)}if(e.optional?.length){e.optional.sort(B);for(let t of e.optional)V(t)}if(e.wildcard?.length){e.wildcard.sort(B);for(let t of e.wildcard)V(t)}}function H(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function U(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function W(e,t){let n=H(`/`),r=new Uint16Array(6);for(let t of e)z(!1,r,t,1,n,0);V(n),t.masksTree=n,t.flatCache=F(1e3)}function ce(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=K(e,t.masksTree);return t.flatCache.set(e,r),r}function le(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=H(`/`),z(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),K(r,o,n)}function ue(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=K(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=fe(a.route)),t.matchCache.set(r,a),a}function de(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function G(e,t=!1,n){let r=H(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return z(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&P(),a[e.id]=e,s!==0&&e.path){let t=de(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),V(r),{processedTree:{segmentTree:r,singleCache:F(1e3),matchCache:F(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function K(e,t,n=!1){let r=e.split(`/`),i=me(e,r,t,n);if(!i)return null;let[a]=q(e,r,i);return{route:i.node.route,rawParams:a}}function q(e,t,n){let r=pe(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===I)break;if(u.kind===L){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function fe(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function pe(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function me(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!p(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=n,{extract:g,rawParams:_}=n;if(i.kind===2&&i.route&&!Y(l,n))continue;if(i.parse){if(!ge(e,t,n))continue;_=n.rawParams,g=n.extract}r&&i.route&&i.kind!==I&&Y(c,n)&&(c=n);let v=u===o;if(v&&(i.route&&(!a||i.kind===I||i.kind===2)&&Y(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let y=v?void 0:t[u],b;if(v&&i.index){let n={node:i.index,index:u,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_},r=!0;if(i.index.parse&&(ge(e,t,n)||(r=!1)),r){if(!m&&!h&&!d&&he(p,o))return n;Y(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(v||!(n.caseSensitive?y:b??=y.toLowerCase()).startsWith(r)))){if(a){if(v)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}if(i.optional){let e=d|1<<f,t=f+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:u,skipped:e,depth:t,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?y:b??=y.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:u+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+J(o,u),extract:g,rawParams:_})}}if(!v&&i.dynamic&&y)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?y:b??=y.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,depth:f+1,statics:p,dynamics:m+J(o,u),optionals:h,extract:g,rawParams:_})}if(!v&&i.staticInsensitive){let e=i.staticInsensitive.get(b??=y.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+J(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v&&i.static){let e=i.static.get(y);e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+J(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(i.pathless){let e=f+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:u,skipped:d,depth:e,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function J(e,t){return 2**(e-t-1)}function he(e,t){return e===2**(t-1)-1}function ge(e,t,n){let r,i;try{[r,i]=q(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function Y(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===I)>(e.node.kind===I)||t.node.kind===I==(e.node.kind===I)&&t.depth>e.depth))):!0}function _e(e){return ve(e.filter(e=>e!==void 0).join(`/`))}function ve(e){return e.replace(/\/{2,}/g,`/`)}function ye(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function be(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function xe(e){return be(ye(e))}function X(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Se(e,t,n){return X(e,n)===X(t,n)}function Ce({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&p(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(p(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=ve(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function we(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function Te(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>De(e,n)).join(`/`):De(r,n):r}function Ee({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=R(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=Te(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Te(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Te(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function De(e,t){let n=encodeURIComponent(e);return t?.(n)??n}var Oe=`Error preloading route! ☝️`,Z=c(u(),1),ke=Z.use,Ae=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function je(e){let t=Z.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function Me(e,t,n={},r={}){Z.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function Ne(e){let t=Z.useRef(null);return Z.useImperativeHandle(e,()=>t.current,[]),t}var Pe=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Fe=o(((e,t)=>{t.exports=Pe()})),Ie=Fe();function Le({children:e,fallback:t=null}){return Re()?(0,Ie.jsx)(Z.Fragment,{children:e}):(0,Ie.jsx)(Z.Fragment,{children:t})}function Re(){return Z.useSyncExternalStore(ze,()=>!0,()=>!1)}function ze(){return()=>{}}var Be=Z.createContext(null);function Ve(e){return Z.useContext(Be)}var He=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ue=o(((e,t)=>{t.exports=He()})),We=o((e=>{var t=u(),n=Ue();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Ge=o(((e,t)=>{t.exports=We()})),Ke=c(Ge(),1);function qe(e,t){return e===t}function Je(e,t,n=qe){let r=(0,Z.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,Z.useCallback)(()=>e?.get(),[e]);return(0,Ke.useSyncExternalStoreWithSelector)(r,i,i,t,n)}function Ye(e){let t=Ve();return Z.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}var Xe=c(f(),1);function Ze(e,t){let n=Ve(),r=Ne(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:g,children:_,target:v,disabled:y,style:b,className:x,onClick:S,onBlur:C,onFocus:w,onMouseEnter:T,onMouseLeave:D,onTouchStart:O,ignoreBlocker:ee,params:te,search:k,hash:ne,state:A,mask:re,reloadDocument:M,unsafeRelative:ie,from:ae,_fromLocation:oe,...N}=e,P=Re(),F=Z.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),I=Je(n.stores.location,e=>e,(e,t)=>e.href===t.href),L=Z.useMemo(()=>{let e={_fromLocation:I,...F};return n.buildLocation(e)},[n,I,F]),se=L.maskedLocation?L.maskedLocation.publicHref:L.publicHref,R=L.maskedLocation?L.maskedLocation.external:L.external,z=Z.useMemo(()=>it(se,R,n.history,y),[y,R,se,n.history]),B=Z.useMemo(()=>{if(z?.external)return j(z.href,n.protocolAllowlist)?void 0:z.href;if(!at(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),j(s,n.protocolAllowlist)?void 0:s}catch{}},[s,z,n.protocolAllowlist]),V=Z.useMemo(()=>{if(B)return!1;if(o?.exact){if(!Se(I.pathname,L.pathname,n.basepath))return!1}else{let e=X(I.pathname,n.basepath),t=X(L.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!E(I.search,L.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:o?.includeHash?P&&I.hash===L.hash:!0},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,I,B,P,L.hash,L.pathname,L.search,n.basepath]),H=V?h(i,{})??$e:Qe,U=V?Qe:h(a,{})??Qe,W=[x,H.className,U.className].filter(Boolean).join(` `),ce=(b||H.style||U.style)&&{...b,...H.style,...U.style},[le,ue]=Z.useState(!1),de=Z.useRef(!1),G=e.reloadDocument||B?!1:c??n.options.defaultPreload,K=l??n.options.defaultPreloadDelay??0,q=Z.useCallback(()=>{n.preloadRoute({...F,_builtLocation:L}).catch(e=>{console.warn(e),console.warn(Oe)})},[n,F,L]);Me(r,Z.useCallback(e=>{e?.isIntersecting&&q()},[q]),rt,{disabled:!!y||G!==`viewport`}),Z.useEffect(()=>{de.current||!y&&G===`render`&&(q(),de.current=!0)},[y,q,G]);let fe=e=>{let t=e.currentTarget.getAttribute(`target`),r=v===void 0?t:v;if(!y&&!st(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Xe.flushSync)(()=>{ue(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ue(!1)});n.navigate({...F,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:g,ignoreBlocker:ee})}};if(B)return{...N,ref:r,href:B,..._&&{children:_},...v&&{target:v},...y&&{disabled:y},...b&&{style:b},...x&&{className:x},...S&&{onClick:S},...C&&{onBlur:C},...w&&{onFocus:w},...T&&{onMouseEnter:T},...D&&{onMouseLeave:D},...O&&{onTouchStart:O}};let pe=e=>{if(y||G!==`intent`)return;if(!K){q();return}let t=e.currentTarget;if(Q.has(t))return;let n=setTimeout(()=>{Q.delete(t),q()},K);Q.set(t,n)},me=e=>{y||G!==`intent`||q()},J=e=>{if(y||!G||!K)return;let t=e.currentTarget,n=Q.get(t);n&&(clearTimeout(n),Q.delete(t))};return{...N,...H,...U,href:z?.href,ref:r,onClick:$([S,fe]),onBlur:$([C,J]),onFocus:$([w,pe]),onMouseEnter:$([T,pe]),onMouseLeave:$([D,J]),onTouchStart:$([O,me]),disabled:!!y,target:v,...ce&&{style:ce},...W&&{className:W},...y&&et,...V&&tt,...P&&le&&nt}}var Qe={},$e={className:`active`},et={role:`link`,"aria-disabled":!0},tt={"data-status":`active`,"aria-current":`page`},nt={"data-transitioning":`transitioning`},Q=new WeakMap,rt={rootMargin:`100px`},$=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function it(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function at(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var ot=Z.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Ze(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return Z.createElement(`a`,t,o)}return Z.createElement(n,a,o)});function st(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var ct=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),lt=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),ut=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),dt=e=>{let t=ut(e);return t.charAt(0).toUpperCase()+t.slice(1)},ft={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},pt=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},mt=(0,Z.createContext)({}),ht=()=>(0,Z.useContext)(mt),gt=(0,Z.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=ht()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,Z.createElement)(`svg`,{ref:c,...ft,width:t??l??ft.width,height:t??l??ft.height,stroke:e??f,strokeWidth:m,className:ct(`lucide`,p,i),...!a&&!pt(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,Z.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),_t=(e,t)=>{let n=(0,Z.forwardRef)(({className:n,...r},i)=>(0,Z.createElement)(gt,{ref:i,iconNode:t,className:ct(`lucide-${lt(dt(e))}`,`lucide-${e}`,n),...r}));return n.displayName=dt(e),n};export{A,O as B,ce as C,G as D,W as E,oe as F,f as G,p as H,ie as I,c as J,u as K,h as L,D as M,ae as N,F as O,E as P,v as R,fe as S,le as T,b as U,ee as V,x as W,_e as _,Ge as a,ye as b,Le as c,ke as d,Ae as f,Ee as g,we as h,Je as i,N as j,P as k,Re as l,ve as m,ot as n,Ve as o,je as p,o as q,Ye as r,Be as s,_t as t,Fe as u,Ce as v,ue as w,be as x,xe as y,j as z};
@@ -1 +0,0 @@
1
- var e=`default`,t=`default`,n=`outside`,r=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];export{r as i,e as n,n as r,t};
@@ -1 +0,0 @@
1
- import{J as e,K as t,u as n}from"./createLucideIcon-dN8ooBD1.js";import{a as r}from"./api-CoLs57oO.js";import{b as i}from"./parts-B0JBolvG.js";import{It as a}from"./index-J_Uqj4md.js";var o=e(t(),1),s=n(),c=`m-0 text-sm font-semibold text-foreground`,l=`mt-1 block text-xs text-muted-foreground`;function u({children:e}){return(0,s.jsx)(`span`,{role:`alert`,className:`mt-1 block text-xs font-semibold text-warning`,children:e})}function d({label:e,value:t,onChange:n,type:r=`text`,placeholder:i,hint:d,problem:f,notes:p,invalid:m,disabled:h,required:g,mono:_=!1,inputMode:v,className:y}){let b=(0,o.useId)();return(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{htmlFor:b,className:c,children:e}),(0,s.jsx)(`input`,{id:b,type:r,value:t,disabled:h,required:g,inputMode:v,autoComplete:`off`,spellCheck:!1,placeholder:i??``,"aria-invalid":f||m?!0:void 0,onChange:e=>n(e.target.value),className:a(`mt-1.5 max-w-xl`,_&&`font-mono`,y)}),d&&(0,s.jsx)(`span`,{className:l,children:d}),p,f&&(0,s.jsx)(u,{children:f})]})}function f({legend:e,name:t,value:n,options:r,onChange:i,disabled:c=!1,notes:l,columns:u=2}){let d=(0,o.useId)();return(0,s.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,disabled:c,children:[(0,s.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:e}),(0,s.jsx)(`div`,{className:a(`grid gap-2`,u===3?`md:grid-cols-3`:`md:grid-cols-2`),children:r.map((e,r)=>{let o=e.value===n,l=`${d}-${r}`;return(0,s.jsxs)(`label`,{className:a(`m-0 flex items-start gap-3 rounded-xl border px-3.5 py-3 transition-colors`,c?`cursor-default opacity-70`:`cursor-pointer`,o?`border-primary/50 bg-accent/40`:`border-border bg-card hover:bg-muted/40`),children:[(0,s.jsx)(`input`,{type:`radio`,name:t,value:e.value,checked:o,onChange:()=>i(e.value),"aria-labelledby":l,"aria-describedby":`${l}-about`,className:`mt-[3px] size-[18px] shrink-0 accent-[var(--color-sapphire)]`}),(0,s.jsxs)(`span`,{className:`min-w-0`,children:[(0,s.jsx)(`span`,{id:l,className:`block text-sm font-semibold text-foreground`,children:e.label}),(0,s.jsxs)(`span`,{id:`${l}-about`,className:`block`,children:[e.hint&&(0,s.jsx)(`span`,{className:`block break-words text-sm text-muted-foreground`,children:e.hint}),o&&e.note&&(0,s.jsx)(`span`,{className:a(`mt-1 block break-words text-sm font-medium`,e.note.tone===`ok`?`text-success`:`text-warning`),children:e.note.text})]})]})]},e.value)})}),l]})}function p({label:e,value:t,options:n,onChange:r,hint:i,disabled:u,className:d}){let f=(0,o.useId)();return(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{htmlFor:f,className:c,children:e}),(0,s.jsx)(`select`,{id:f,value:t,disabled:u,onChange:e=>r(e.target.value),className:a(`mt-1.5 max-w-xl`,d),children:n.map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))}),i&&(0,s.jsx)(`span`,{className:l,children:i})]})}function m({label:e,value:t,options:n,onChange:r}){return(0,s.jsx)(`select`,{"aria-label":e,value:t,onChange:e=>r(e.target.value),className:`min-h-9 w-auto max-w-full rounded-[12px] py-1 pl-2.5 pr-8 text-xs font-semibold`,children:n.map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function h({label:e,saved:t,preview:n,value:i,onChange:a,removed:u=!1,onRemove:d,open:f=!1,placeholder:p,hint:m,notes:h,disabled:g}){let _=(0,o.useId)(),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(null),w=!t||v||f;return(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{id:`${_}-label`,htmlFor:w?_:void 0,className:c,children:e}),w?(0,s.jsxs)(`div`,{className:`mt-1.5 flex max-w-xl flex-wrap items-center gap-2`,children:[(0,s.jsx)(`input`,{id:_,type:`password`,value:i,disabled:g,autoComplete:`off`,spellCheck:!1,placeholder:p??``,autoFocus:v,onChange:e=>a(e.target.value),className:`min-w-0 flex-1 basis-56 font-mono`}),t&&!f&&(0,s.jsx)(r,{variant:`ghost`,disabled:g,onClick:()=>{a(``),y(!1),x(!0)},children:`Keep the saved one`})]}):(0,s.jsxs)(`div`,{role:`group`,"aria-labelledby":`${_}-label`,className:`mt-1.5 flex min-h-[2.65rem] max-w-xl flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border bg-muted/40 px-3.5 py-1.5 text-sm`,children:[(0,s.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-foreground`,children:u?`Will be removed when you save.`:(0,s.jsxs)(s.Fragment,{children:[`Saved: `,(0,s.jsx)(`span`,{className:`font-mono`,children:n||`•••`}),`, stored encrypted`]})}),u?(0,s.jsx)(r,{variant:`ghost`,disabled:g,autoFocus:S===`keep`,onClick:()=>{C(`remove`),d?.(!1)},children:`Keep it`}):(0,s.jsxs)(`span`,{className:`flex gap-2`,children:[(0,s.jsx)(r,{variant:`ghost`,disabled:g,autoFocus:b,onClick:()=>y(!0),children:`Replace`}),d&&(0,s.jsx)(r,{variant:`ghost`,disabled:g,autoFocus:S===`remove`,onClick:()=>{C(`keep`),d(!0)},children:`Remove`})]})]}),m&&(0,s.jsx)(`span`,{className:l,children:m}),h]})}function g({label:e,description:t,notes:n,checked:r,disabled:a,onChange:o}){return(0,s.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),t&&(0,s.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:t}),n]}),(0,s.jsx)(i,{label:e,checked:r,disabled:a,onChange:o})]})}function _({label:e,checked:t,disabled:n,onChange:r}){return(0,s.jsxs)(`label`,{className:`m-0 flex items-center gap-2.5 text-sm text-foreground`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:e=>r(e.target.checked),className:`m-0 size-[18px] shrink-0`}),e]})}function v({refused:e=!1,error:t,dirty:n,saved:r,savedText:i=`Saved.`,footnote:a=``}){return e?{text:`Nothing was saved: see above.`,tone:`warning`}:t?{text:`Nothing was saved: ${t}`,tone:`warning`}:n?{text:`Not saved yet.`,tone:`warning`}:r?{text:i,tone:`success`}:{text:a,tone:`neutral`}}var y={success:`text-success`,warning:`text-warning`,neutral:`text-muted-foreground`};function b({busy:e,disabled:t,status:n,label:i=`Save`,busyLabel:o=`Saving…`,extra:c}){return(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,s.jsx)(r,{variant:`primary`,type:`submit`,disabled:t||e,children:e?o:i}),c,(0,s.jsx)(`p`,{role:`status`,className:a(`m-0 min-w-0 flex-1 basis-56 text-sm font-medium`,y[n.tone]),children:n.text})]})}export{b as a,g as c,u as i,d as l,f as n,h as o,m as r,p as s,_ as t,v as u};