@w6w/embed 0.2.1 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +22 -5
  2. package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
  3. package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
  4. package/dist/{CreateFunctionModal-DRsFx-FB.js → CreateFunctionModal-DScxp_LN.js} +25 -25
  5. package/dist/{CreateFunctionModal-DRsFx-FB.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
  6. package/dist/{DocumentFormModal-BExK1V-B.js → DocumentFormModal-Br4s8wmi.js} +5 -5
  7. package/dist/{DocumentFormModal-BExK1V-B.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
  8. package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
  9. package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
  10. package/dist/ModelRoutesManager-1Ac5wcas.js +345 -0
  11. package/dist/ModelRoutesManager-1Ac5wcas.js.map +1 -0
  12. package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
  13. package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
  14. package/dist/apps-ItBvnWX3.js +92 -0
  15. package/dist/apps-ItBvnWX3.js.map +1 -0
  16. package/dist/{callables-3mFrMVG_.js → callables-tOlflvbl.js} +11 -11
  17. package/dist/{callables-3mFrMVG_.js.map → callables-tOlflvbl.js.map} +1 -1
  18. package/dist/chrome/ConfirmModal.d.ts +4 -1
  19. package/dist/chrome/DangerZone.d.ts +4 -3
  20. package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
  21. package/dist/chrome/JsonToggle.d.ts +29 -20
  22. package/dist/chrome/Modal.d.ts +3 -1
  23. package/dist/chrome/RightRail.d.ts +6 -1
  24. package/dist/chrome/VersionHistoryModal.d.ts +2 -0
  25. package/dist/chrome/index.d.ts +1 -0
  26. package/dist/chrome/workspace.d.ts +36 -1
  27. package/dist/coerce-input-DFJ4n_wc.js +150 -0
  28. package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
  29. package/dist/connections-CzsCyIxY.js +119 -0
  30. package/dist/connections-CzsCyIxY.js.map +1 -0
  31. package/dist/credentials-Cn92LGhJ.js +171 -0
  32. package/dist/credentials-Cn92LGhJ.js.map +1 -0
  33. package/dist/data-stores-UeQvwVCa.js +170 -0
  34. package/dist/data-stores-UeQvwVCa.js.map +1 -0
  35. package/dist/document-sources-DNmBojx6.js +169 -0
  36. package/dist/document-sources-DNmBojx6.js.map +1 -0
  37. package/dist/draft/use-workflow-draft.d.ts +2 -0
  38. package/dist/draft.mjs +2 -2
  39. package/dist/editor/BindingBanner.d.ts +13 -0
  40. package/dist/editor/CallableEditorFrame.d.ts +7 -0
  41. package/dist/editor/EndpointCards.d.ts +4 -1
  42. package/dist/editor/PublishControl.d.ts +19 -0
  43. package/dist/editor/PublishTooltip.d.ts +7 -0
  44. package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
  45. package/dist/editor/StartingStateModal.d.ts +14 -0
  46. package/dist/editor/TargetSelector.d.ts +15 -0
  47. package/dist/editor/TargetSelector.types.d.ts +2 -0
  48. package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
  49. package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
  50. package/dist/editor/definition.d.ts +6 -0
  51. package/dist/editor/json-apply.d.ts +29 -0
  52. package/dist/editor/step-problems-feed.d.ts +5 -0
  53. package/dist/editor/types.d.ts +2 -2
  54. package/dist/editor-apps-DkkC7wOQ.js +152 -0
  55. package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
  56. package/dist/editor-tools-BR27RGto.js +1683 -0
  57. package/dist/editor-tools-BR27RGto.js.map +1 -0
  58. package/dist/editor.mjs +1 -1
  59. package/dist/editors.mjs +855 -650
  60. package/dist/editors.mjs.map +1 -1
  61. package/dist/{endpoints-B2ynbZo-.js → endpoints-DSRo1Lc5.js} +113 -107
  62. package/dist/endpoints-DSRo1Lc5.js.map +1 -0
  63. package/dist/fields-DvS8XZFc.js +21 -0
  64. package/dist/fields-DvS8XZFc.js.map +1 -0
  65. package/dist/forms/ModelBudgetsManager.d.ts +9 -0
  66. package/dist/forms/ModelRoutesManager.d.ts +14 -0
  67. package/dist/forms.d.ts +4 -0
  68. package/dist/forms.mjs +611 -212
  69. package/dist/forms.mjs.map +1 -1
  70. package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
  71. package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
  72. package/dist/index.mjs +154 -117
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/lib/binding-problems.d.ts +42 -0
  75. package/dist/lib/code-rail.d.ts +4 -2
  76. package/dist/lib/history-query.d.ts +45 -0
  77. package/dist/lib/import-bindings.d.ts +89 -0
  78. package/dist/lib/index.d.ts +4 -0
  79. package/dist/lib/invoke-error.d.ts +1 -0
  80. package/dist/lib/rail-settings.d.ts +1 -1
  81. package/dist/lib/sdk-snippets.d.ts +1 -1
  82. package/dist/lib/setup-incomplete.d.ts +22 -0
  83. package/dist/lib/starting-data.d.ts +31 -0
  84. package/dist/lib/state-panel.d.ts +29 -0
  85. package/dist/lib/target-fields.d.ts +11 -15
  86. package/dist/lib/trigger-preview.d.ts +1 -0
  87. package/dist/lib/workflow-live-run.d.ts +93 -8
  88. package/dist/lib/workflow-nodes.d.ts +5 -0
  89. package/dist/lib/workflow-validity.d.ts +65 -16
  90. package/dist/lib/workflow-variables.d.ts +1 -1
  91. package/dist/lib/workflow-version.d.ts +2 -0
  92. package/dist/lib.mjs +86 -69
  93. package/dist/lists/ConnectionDependents.d.ts +31 -0
  94. package/dist/lists/ConnectionDetail.d.ts +4 -1
  95. package/dist/lists/ConnectionList.d.ts +4 -1
  96. package/dist/lists/CredentialDetail.d.ts +15 -0
  97. package/dist/lists/CredentialList.d.ts +14 -0
  98. package/dist/lists/DataStoreList.d.ts +17 -0
  99. package/dist/lists/DataStoreView.d.ts +19 -0
  100. package/dist/lists/Logs.d.ts +19 -0
  101. package/dist/lists/ModelCatalog.d.ts +12 -0
  102. package/dist/lists/ModelUsage.d.ts +12 -0
  103. package/dist/lists.d.ts +14 -0
  104. package/dist/lists.mjs +1766 -609
  105. package/dist/lists.mjs.map +1 -1
  106. package/dist/models-bAayQPJ_.js +270 -0
  107. package/dist/models-bAayQPJ_.js.map +1 -0
  108. package/dist/{project-context-BiCjv_E3.js → project-context-Tvp-La7A.js} +3 -3
  109. package/dist/{project-context-BiCjv_E3.js.map → project-context-Tvp-La7A.js.map} +1 -1
  110. package/dist/rail/ConnectionsTool.d.ts +2 -0
  111. package/dist/rail/HistoryTool.d.ts +2 -0
  112. package/dist/rail/StartingStateTool.d.ts +2 -0
  113. package/dist/rail/settings-sections.d.ts +4 -1
  114. package/dist/rail.mjs +4 -4
  115. package/dist/repos/agents-studio-agents.d.ts +52 -0
  116. package/dist/repos/agents-studio-assets.d.ts +68 -0
  117. package/dist/repos/connections.d.ts +30 -12
  118. package/dist/repos/constants.d.ts +12 -0
  119. package/dist/repos/credentials.d.ts +83 -0
  120. package/dist/repos/data-stores.d.ts +84 -0
  121. package/dist/repos/endpoints.d.ts +9 -3
  122. package/dist/repos/fields.d.ts +34 -0
  123. package/dist/repos/functions.d.ts +7 -5
  124. package/dist/repos/history.d.ts +9 -0
  125. package/dist/repos/index.d.ts +7 -0
  126. package/dist/repos/models.d.ts +289 -0
  127. package/dist/repos/spec-export.d.ts +3 -3
  128. package/dist/repos/spec-import.d.ts +30 -1
  129. package/dist/repos/step-tests.d.ts +2 -0
  130. package/dist/repos/webhook-listen.d.ts +35 -0
  131. package/dist/repos/workflows.d.ts +105 -2
  132. package/dist/repos.mjs +655 -176
  133. package/dist/repos.mjs.map +1 -1
  134. package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
  135. package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
  136. package/dist/{slug-C4ktDPdy.js → slug-BVdgiP_L.js} +64 -60
  137. package/dist/slug-BVdgiP_L.js.map +1 -0
  138. package/dist/{spec-export-Cf3VQSQS.js → spec-export-DGy5ijps.js} +73 -60
  139. package/dist/spec-export-DGy5ijps.js.map +1 -0
  140. package/dist/spec-import-SWOonsNr.js +116 -0
  141. package/dist/spec-import-SWOonsNr.js.map +1 -0
  142. package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
  143. package/dist/step-tests-B4E4W3ly.js.map +1 -0
  144. package/dist/theme-context-E2ZhlXDX.js +6 -0
  145. package/dist/theme-context-E2ZhlXDX.js.map +1 -0
  146. package/dist/theme-context.d.ts +2 -0
  147. package/dist/{use-callable-draft-zHLpcr-b.js → use-callable-draft-DCauHt5o.js} +23 -23
  148. package/dist/{use-callable-draft-zHLpcr-b.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
  149. package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
  150. package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
  151. package/dist/{workflow-blank-DyL3_RUA.js → workflow-blank-DFpGObrn.js} +6 -6
  152. package/dist/{workflow-blank-DyL3_RUA.js.map → workflow-blank-DFpGObrn.js.map} +1 -1
  153. package/dist/workflows-BZN4Hyz1.js +623 -0
  154. package/dist/workflows-BZN4Hyz1.js.map +1 -0
  155. package/package.json +3 -2
  156. package/src/styles.css +155 -7
  157. package/dist/ConfirmModal-RLbZT5_k.js +0 -181
  158. package/dist/ConfirmModal-RLbZT5_k.js.map +0 -1
  159. package/dist/ImportSpecModal-BDQIf6rg.js +0 -136
  160. package/dist/ImportSpecModal-BDQIf6rg.js.map +0 -1
  161. package/dist/WorkflowEditor-DlbVv6Fs.js +0 -854
  162. package/dist/WorkflowEditor-DlbVv6Fs.js.map +0 -1
  163. package/dist/apps-1FNUwbGv.js +0 -77
  164. package/dist/apps-1FNUwbGv.js.map +0 -1
  165. package/dist/coerce-input-BicYr7nc.js +0 -139
  166. package/dist/coerce-input-BicYr7nc.js.map +0 -1
  167. package/dist/connections-CjjYeRqb.js +0 -78
  168. package/dist/connections-CjjYeRqb.js.map +0 -1
  169. package/dist/document-sources-C0grrtdq.js +0 -86
  170. package/dist/document-sources-C0grrtdq.js.map +0 -1
  171. package/dist/editor-apps-BdenSV1o.js +0 -95
  172. package/dist/editor-apps-BdenSV1o.js.map +0 -1
  173. package/dist/editor-tools-RxmY5iyi.js +0 -1279
  174. package/dist/editor-tools-RxmY5iyi.js.map +0 -1
  175. package/dist/endpoints-B2ynbZo-.js.map +0 -1
  176. package/dist/rail-settings-XYGToh00.js.map +0 -1
  177. package/dist/slug-C4ktDPdy.js.map +0 -1
  178. package/dist/spec-export-Cf3VQSQS.js.map +0 -1
  179. package/dist/spec-import-CjmxyZDR.js +0 -465
  180. package/dist/spec-import-CjmxyZDR.js.map +0 -1
  181. package/dist/step-tests-CivICmTq.js.map +0 -1
  182. package/dist/trigger-preview-VPkrryDl.js +0 -120
  183. package/dist/trigger-preview-VPkrryDl.js.map +0 -1
  184. package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
  185. package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
package/dist/forms.mjs CHANGED
@@ -1,186 +1,198 @@
1
1
  "use client";
2
- import { C as re, a as se } from "./CreateFunctionModal-DRsFx-FB.js";
3
- import { jsxs as n, jsx as e, Fragment as V } from "react/jsx-runtime";
4
- import { ApiError as x } from "@w6w/sdk";
5
- import { Copyable as A, EditButton as L, DeleteButton as j, useEnterSubmit as P } from "@w6w/ui";
6
- import { useState as h } from "react";
7
- import { C as F, a as $, M as O } from "./ConfirmModal-RLbZT5_k.js";
8
- import { u as T } from "./project-context-BiCjv_E3.js";
9
- import { i as J, d as Q, b as U, h as _, f as B, c as R, u as I, g as W } from "./vault-BSEWhMYC.js";
10
- const q = ["string", "number", "boolean", "json"];
11
- function M(t) {
2
+ import { C as He, a as Ye } from "./CreateFunctionModal-DScxp_LN.js";
3
+ import { jsxs as a, jsx as e, Fragment as ne } from "react/jsx-runtime";
4
+ import { ApiError as L } from "@w6w/sdk";
5
+ import { EmptyState as U, DataTable as T, Copyable as se, EditButton as A, DeleteButton as O, useEnterSubmit as V, BudgetMeter as re } from "@w6w/ui";
6
+ import { useState as m } from "react";
7
+ import { C as W, a as oe, M as R } from "./ConfirmModal-Pv2-A_3U.js";
8
+ import { u as ae } from "./project-context-Tvp-La7A.js";
9
+ import { i as de, d as ce, b as ue, h as me, f as he, c as ge, u as ve, g as be } from "./vault-BSEWhMYC.js";
10
+ import { M as Ge } from "./ModelRoutesManager-1Ac5wcas.js";
11
+ import { F as pe, D as fe, C as ye, I as Ne, E as Ce } from "./models-bAayQPJ_.js";
12
+ const Se = ["string", "number", "boolean", "json"];
13
+ function q(t) {
12
14
  if (t.type === "boolean" || t.type === "number" || t.type === "string") return String(t.value);
13
- const a = JSON.stringify(t.value);
14
- return a.length > 80 ? `${a.slice(0, 80)}…` : a;
15
+ const n = JSON.stringify(t.value);
16
+ return n.length > 80 ? `${n.slice(0, 80)}…` : n;
15
17
  }
16
- function ae(t) {
17
- var d, S;
18
- const a = t.slots, s = T(t.project), [v, i] = h(null), [f, o] = h(null), u = J(s ?? void 0, s != null), g = Q(), p = s != null, m = () => {
19
- s != null && i({ mode: "create" });
20
- }, b = (a == null ? void 0 : a.header) === void 0 ? /* @__PURE__ */ n("div", { children: [
18
+ function Fe(t) {
19
+ var k;
20
+ const n = t.slots, l = ae(t.project), [h, i] = m(null), [f, o] = m(null), g = de(l ?? void 0, l != null), b = ce(), y = l != null, p = () => {
21
+ l != null && i({ mode: "create" });
22
+ }, N = (n == null ? void 0 : n.header) === void 0 ? /* @__PURE__ */ a("div", { children: [
21
23
  /* @__PURE__ */ e("h3", { children: "Variables" }),
22
- /* @__PURE__ */ n("p", { className: "muted small", children: [
24
+ /* @__PURE__ */ a("p", { className: "muted small", children: [
23
25
  "User-defined typed values addressable by name. Plaintext — use ",
24
26
  /* @__PURE__ */ e("strong", { children: "Secrets" }),
25
27
  " ",
26
28
  "for sensitive values."
27
29
  ] })
28
- ] }) : a.header, N = a == null ? void 0 : a.actions, y = N === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !p, onClick: m, children: "+ Add variable" }) : typeof N == "function" ? N({ openCreate: m, canCreate: p }) : N, C = (a == null ? void 0 : a.empty) === void 0 ? /* @__PURE__ */ e("p", { className: "muted", children: "No variables yet." }) : a.empty;
29
- return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ n("section", { className: "section", children: [
30
- (b != null || y != null) && /* @__PURE__ */ n("div", { className: "section-head", children: [
31
- b,
32
- y
33
- ] }),
34
- /* @__PURE__ */ n("div", { className: "card", children: [
35
- u.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
36
- ((d = u.data) == null ? void 0 : d.length) === 0 && C,
37
- /* @__PURE__ */ e("ul", { className: "list", children: (S = u.data) == null ? void 0 : S.map((r) => /* @__PURE__ */ n("li", { children: [
38
- /* @__PURE__ */ n("div", { className: "list-main", children: [
39
- /* @__PURE__ */ e("strong", { className: "list-name", title: r.name, children: r.name }),
40
- " ",
41
- /* @__PURE__ */ e("span", { className: "tag", children: r.type }),
42
- /* @__PURE__ */ n("div", { className: "muted small list-preview", title: M(r), children: [
43
- /* @__PURE__ */ e(A, { value: M(r), readOnly: !0, children: /* @__PURE__ */ e(
44
- "code",
45
- {
46
- style: {
47
- overflowWrap: "anywhere",
48
- display: "block",
49
- minWidth: 0,
50
- overflow: "hidden",
51
- textOverflow: "ellipsis",
52
- flex: 1
53
- },
54
- children: M(r)
55
- }
56
- ) }),
57
- r.description && /* @__PURE__ */ n(V, { children: [
58
- " · ",
59
- r.description
60
- ] })
61
- ] })
62
- ] }),
63
- /* @__PURE__ */ n("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
64
- /* @__PURE__ */ e(F, { resource: { kind: "var", name: r.name } }),
65
- /* @__PURE__ */ e(
66
- L,
67
- {
68
- label: "Edit",
69
- onClick: () => i({ mode: "edit", v: r }),
70
- "data-testid": `var-edit-${r.id}`
71
- }
72
- ),
73
- /* @__PURE__ */ e(
74
- j,
30
+ ] }) : n.header, C = n == null ? void 0 : n.actions, S = C === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !y, onClick: p, children: "+ Add variable" }) : typeof C == "function" ? C({ openCreate: p, canCreate: y }) : C, s = (n == null ? void 0 : n.empty) === void 0 ? /* @__PURE__ */ e(U, { testId: "vars-manager-empty", children: "No variables yet." }) : n.empty, u = [
31
+ {
32
+ key: "name",
33
+ header: "Variable",
34
+ render: (c) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
35
+ /* @__PURE__ */ e("strong", { className: "list-name", title: c.name, children: c.name }),
36
+ " ",
37
+ /* @__PURE__ */ e("span", { className: "tag", children: c.type }),
38
+ /* @__PURE__ */ a("div", { className: "muted small list-preview", title: q(c), children: [
39
+ /* @__PURE__ */ e(se, { value: q(c), readOnly: !0, children: /* @__PURE__ */ e(
40
+ "code",
75
41
  {
76
- label: "Delete",
77
- onClick: () => o(r),
78
- disabled: g.isPending,
79
- "data-testid": `var-delete-${r.id}`
42
+ style: {
43
+ overflowWrap: "anywhere",
44
+ display: "block",
45
+ minWidth: 0,
46
+ overflow: "hidden",
47
+ textOverflow: "ellipsis",
48
+ flex: 1
49
+ },
50
+ children: q(c)
80
51
  }
81
- )
52
+ ) }),
53
+ c.description && /* @__PURE__ */ a(ne, { children: [
54
+ " · ",
55
+ c.description
56
+ ] })
82
57
  ] })
83
- ] }, r.id)) })
58
+ ] })
59
+ },
60
+ {
61
+ key: "actions",
62
+ header: "",
63
+ align: "right",
64
+ link: !1,
65
+ render: (c) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
66
+ /* @__PURE__ */ e(oe, { resource: { kind: "var", name: c.name } }),
67
+ /* @__PURE__ */ e(
68
+ A,
69
+ {
70
+ label: "Edit",
71
+ onClick: () => i({ mode: "edit", v: c }),
72
+ "data-testid": `var-edit-${c.id}`
73
+ }
74
+ ),
75
+ /* @__PURE__ */ e(
76
+ O,
77
+ {
78
+ label: "Delete",
79
+ onClick: () => o(c),
80
+ disabled: b.isPending,
81
+ "data-testid": `var-delete-${c.id}`
82
+ }
83
+ )
84
+ ] })
85
+ }
86
+ ];
87
+ return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
88
+ (N != null || S != null) && /* @__PURE__ */ a("div", { className: "section-head", children: [
89
+ N,
90
+ S
84
91
  ] }),
85
- v && s != null && /* @__PURE__ */ e(
86
- Y,
92
+ /* @__PURE__ */ a("div", { className: "card", children: [
93
+ g.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
94
+ ((k = g.data) == null ? void 0 : k.length) === 0 && s,
95
+ g.data != null && g.data.length > 0 && /* @__PURE__ */ e(T, { columns: u, rows: g.data, rowKey: (c) => c.id })
96
+ ] }),
97
+ h && l != null && /* @__PURE__ */ e(
98
+ ke,
87
99
  {
88
- project: s,
89
- initial: v.mode === "edit" ? v.v : void 0,
100
+ project: l,
101
+ initial: h.mode === "edit" ? h.v : void 0,
90
102
  onClose: () => i(null),
91
103
  onSaved: () => i(null)
92
104
  }
93
105
  ),
94
- f && s != null && /* @__PURE__ */ e(
95
- $,
106
+ f && l != null && /* @__PURE__ */ e(
107
+ W,
96
108
  {
97
109
  title: "Delete variable",
98
110
  message: `Delete the variable "${f.name}"? This cannot be undone.`,
99
111
  confirmLabel: "Delete",
100
112
  onConfirm: () => {
101
- g.mutate({ id: f.id, project: s }), o(null);
113
+ b.mutate({ id: f.id, project: l }), o(null);
102
114
  },
103
115
  onClose: () => o(null)
104
116
  }
105
117
  )
106
118
  ] }) });
107
119
  }
108
- function Y(t) {
109
- var k, c, D;
110
- const a = !!t.initial, [s, v] = h(((k = t.initial) == null ? void 0 : k.name) ?? ""), [i, f] = h(((c = t.initial) == null ? void 0 : c.type) ?? "string"), [o, u] = h(() => t.initial ? t.initial.type === "string" ? String(t.initial.value ?? "") : JSON.stringify(t.initial.value, null, 2) : ""), [g, p] = h(((D = t.initial) == null ? void 0 : D.description) ?? ""), [m, b] = h(null);
111
- function N() {
120
+ function ke(t) {
121
+ var M, v, E;
122
+ const n = !!t.initial, [l, h] = m(((M = t.initial) == null ? void 0 : M.name) ?? ""), [i, f] = m(((v = t.initial) == null ? void 0 : v.type) ?? "string"), [o, g] = m(() => t.initial ? t.initial.type === "string" ? String(t.initial.value ?? "") : JSON.stringify(t.initial.value, null, 2) : ""), [b, y] = m(((E = t.initial) == null ? void 0 : E.description) ?? ""), [p, N] = m(null);
123
+ function C() {
112
124
  if (i === "string") return { ok: !0, value: o };
113
125
  if (i === "boolean")
114
126
  return o === "true" ? { ok: !0, value: !0 } : o === "false" ? { ok: !0, value: !1 } : { ok: !1, error: "Value must be `true` or `false`." };
115
127
  if (i === "number") {
116
- const l = Number(o);
117
- return Number.isFinite(l) ? { ok: !0, value: l } : { ok: !1, error: "Value must be a finite number." };
128
+ const d = Number(o);
129
+ return Number.isFinite(d) ? { ok: !0, value: d } : { ok: !1, error: "Value must be a finite number." };
118
130
  }
119
131
  try {
120
132
  return { ok: !0, value: JSON.parse(o) };
121
- } catch (l) {
122
- return { ok: !1, error: `Invalid JSON: ${l.message}` };
133
+ } catch (d) {
134
+ return { ok: !1, error: `Invalid JSON: ${d.message}` };
123
135
  }
124
136
  }
125
- const y = U(), C = _(), d = y.isPending || C.isPending;
126
- function S() {
127
- const l = N();
128
- if (!l.ok) {
129
- b(l.error);
137
+ const S = ue(), s = me(), u = S.isPending || s.isPending;
138
+ function k() {
139
+ const d = C();
140
+ if (!d.ok) {
141
+ N(d.error);
130
142
  return;
131
143
  }
132
- b(null);
133
- const E = {
144
+ N(null);
145
+ const x = {
134
146
  onSuccess: () => t.onSaved(),
135
- onError: (w) => b((w instanceof x, w.message))
147
+ onError: (w) => N((w instanceof L, w.message))
136
148
  };
137
149
  if (t.initial) {
138
- C.mutate(
150
+ s.mutate(
139
151
  {
140
152
  id: t.initial.id,
141
- patch: { type: i, value: l.value, description: g },
153
+ patch: { type: i, value: d.value, description: b },
142
154
  project: t.project
143
155
  },
144
- E
156
+ x
145
157
  );
146
158
  return;
147
159
  }
148
- y.mutate(
149
- { input: { name: s, type: i, value: l.value, description: g }, project: t.project },
150
- E
160
+ S.mutate(
161
+ { input: { name: l, type: i, value: d.value, description: b }, project: t.project },
162
+ x
151
163
  );
152
164
  }
153
- const r = P(S, { enabled: !!s && !d });
154
- return /* @__PURE__ */ n(
155
- O,
165
+ const c = V(k, { enabled: !!l && !u });
166
+ return /* @__PURE__ */ a(
167
+ R,
156
168
  {
157
169
  title: t.initial ? `Edit ${t.initial.name}` : "Add variable",
158
170
  onClose: t.onClose,
159
171
  children: [
160
- /* @__PURE__ */ n("div", { className: "modal-body", children: [
161
- /* @__PURE__ */ n("label", { className: "field", children: [
172
+ /* @__PURE__ */ a("div", { className: "modal-body", children: [
173
+ /* @__PURE__ */ a("label", { className: "field", children: [
162
174
  /* @__PURE__ */ e("span", { children: "Name" }),
163
175
  /* @__PURE__ */ e(
164
176
  "input",
165
177
  {
166
178
  type: "text",
167
- value: s,
168
- disabled: a,
169
- onChange: (l) => v(l.target.value),
179
+ value: l,
180
+ disabled: n,
181
+ onChange: (d) => h(d.target.value),
170
182
  placeholder: "e.g. api_base_url",
171
183
  maxLength: 64,
172
- ...r
184
+ ...c
173
185
  }
174
186
  ),
175
- !a && /* @__PURE__ */ e("span", { className: "hint", children: "Lowercase letters, digits, and underscores. Must start with a letter or underscore." })
187
+ !n && /* @__PURE__ */ e("span", { className: "hint", children: "Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive." })
176
188
  ] }),
177
- /* @__PURE__ */ n("label", { className: "field", children: [
189
+ /* @__PURE__ */ a("label", { className: "field", children: [
178
190
  /* @__PURE__ */ e("span", { children: "Type" }),
179
- /* @__PURE__ */ e("select", { value: i, onChange: (l) => f(l.target.value), children: q.map((l) => /* @__PURE__ */ e("option", { value: l, children: l }, l)) })
191
+ /* @__PURE__ */ e("select", { value: i, onChange: (d) => f(d.target.value), children: Se.map((d) => /* @__PURE__ */ e("option", { value: d, children: d }, d)) })
180
192
  ] }),
181
- /* @__PURE__ */ n("label", { className: "field", htmlFor: "var-value", children: [
193
+ /* @__PURE__ */ a("label", { className: "field", htmlFor: "var-value", children: [
182
194
  /* @__PURE__ */ e("span", { children: "Value" }),
183
- i === "boolean" ? /* @__PURE__ */ n("select", { id: "var-value", value: o || "true", onChange: (l) => u(l.target.value), children: [
195
+ i === "boolean" ? /* @__PURE__ */ a("select", { id: "var-value", value: o || "true", onChange: (d) => g(d.target.value), children: [
184
196
  /* @__PURE__ */ e("option", { value: "true", children: "true" }),
185
197
  /* @__PURE__ */ e("option", { value: "false", children: "false" })
186
198
  ] }) : i === "number" ? /* @__PURE__ */ e(
@@ -189,9 +201,9 @@ function Y(t) {
189
201
  id: "var-value",
190
202
  type: "number",
191
203
  value: o,
192
- onChange: (l) => u(l.target.value),
204
+ onChange: (d) => g(d.target.value),
193
205
  placeholder: "0",
194
- ...r
206
+ ...c
195
207
  }
196
208
  ) : i === "json" ? /* @__PURE__ */ e(
197
209
  "textarea",
@@ -200,7 +212,7 @@ function Y(t) {
200
212
  className: "code",
201
213
  rows: 6,
202
214
  value: o,
203
- onChange: (l) => u(l.target.value),
215
+ onChange: (d) => g(d.target.value),
204
216
  placeholder: '{"key": "value"}'
205
217
  }
206
218
  ) : /* @__PURE__ */ e(
@@ -209,199 +221,586 @@ function Y(t) {
209
221
  id: "var-value",
210
222
  type: "text",
211
223
  value: o,
212
- onChange: (l) => u(l.target.value),
224
+ onChange: (d) => g(d.target.value),
213
225
  placeholder: "",
214
- ...r
226
+ ...c
215
227
  }
216
228
  )
217
229
  ] }),
218
- /* @__PURE__ */ n("label", { className: "field", children: [
230
+ /* @__PURE__ */ a("label", { className: "field", children: [
219
231
  /* @__PURE__ */ e("span", { children: "Description" }),
220
232
  /* @__PURE__ */ e(
221
233
  "input",
222
234
  {
223
235
  type: "text",
224
- value: g,
225
- onChange: (l) => p(l.target.value),
236
+ value: b,
237
+ onChange: (d) => y(d.target.value),
226
238
  placeholder: "Optional",
227
- ...r
239
+ ...c
228
240
  }
229
241
  )
230
242
  ] }),
231
- m && /* @__PURE__ */ e("div", { className: "result error", children: m })
243
+ p && /* @__PURE__ */ e("div", { className: "result error", children: p })
232
244
  ] }),
233
- /* @__PURE__ */ n("div", { className: "modal-actions", children: [
245
+ /* @__PURE__ */ a("div", { className: "modal-actions", children: [
234
246
  /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
235
- /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !s || d, onClick: S, children: d ? "Saving…" : a ? "Save changes" : "Save variable" })
247
+ /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !l || u, onClick: k, children: u ? "Saving…" : n ? "Save changes" : "Save variable" })
236
248
  ] })
237
249
  ]
238
250
  }
239
251
  );
240
252
  }
241
- function ne(t) {
242
- var y, C;
243
- const a = t.slots, [s, v] = h(null), [i, f] = h(null), o = B(), u = R(), g = () => v({ mode: "create" }), p = (a == null ? void 0 : a.header) === void 0 ? /* @__PURE__ */ n("div", { children: [
253
+ function Ke(t) {
254
+ var s;
255
+ const n = t.slots, [l, h] = m(null), [i, f] = m(null), o = he(), g = ge(), b = () => h({ mode: "create" }), y = (n == null ? void 0 : n.header) === void 0 ? /* @__PURE__ */ a("div", { children: [
244
256
  /* @__PURE__ */ e("h3", { children: "Secrets" }),
245
257
  /* @__PURE__ */ e("p", { className: "muted small", children: "Secrets addressable by name. Stored encrypted at rest and never returned from the server — to change a secret, overwrite it." })
246
- ] }) : a.header, m = a == null ? void 0 : a.actions, b = m === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", onClick: g, children: "+ Add secret" }) : typeof m == "function" ? m({ openCreate: g, canCreate: !0 }) : m, N = (a == null ? void 0 : a.empty) === void 0 ? /* @__PURE__ */ e("p", { className: "muted", children: "No secrets yet." }) : a.empty;
247
- return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ n("section", { className: "section", children: [
248
- (p != null || b != null) && /* @__PURE__ */ n("div", { className: "section-head", children: [
249
- p,
250
- b
258
+ ] }) : n.header, p = n == null ? void 0 : n.actions, N = p === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", onClick: b, children: "+ Add secret" }) : typeof p == "function" ? p({ openCreate: b, canCreate: !0 }) : p, C = (n == null ? void 0 : n.empty) === void 0 ? /* @__PURE__ */ e(U, { testId: "secrets-manager-empty", children: "No secrets yet." }) : n.empty, S = [
259
+ {
260
+ key: "name",
261
+ header: "Secret",
262
+ render: (u) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
263
+ /* @__PURE__ */ e("strong", { className: "list-name", title: u.name, children: u.name }),
264
+ " ",
265
+ /* @__PURE__ */ e("code", { className: "muted small", children: "••••••••" }),
266
+ /* @__PURE__ */ a("div", { className: "muted small list-preview", children: [
267
+ u.description && /* @__PURE__ */ a(ne, { children: [
268
+ u.description,
269
+ " · "
270
+ ] }),
271
+ "updated ",
272
+ new Date(u.updatedAt).toLocaleString()
273
+ ] })
274
+ ] })
275
+ },
276
+ {
277
+ key: "actions",
278
+ header: "",
279
+ align: "right",
280
+ link: !1,
281
+ render: (u) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
282
+ /* @__PURE__ */ e(
283
+ A,
284
+ {
285
+ label: "Rotate",
286
+ onClick: () => h({ mode: "edit", s: u }),
287
+ "data-testid": `secret-rotate-${u.id}`
288
+ }
289
+ ),
290
+ /* @__PURE__ */ e(
291
+ O,
292
+ {
293
+ label: "Delete",
294
+ onClick: () => f(u),
295
+ disabled: g.isPending,
296
+ "data-testid": `secret-delete-${u.id}`
297
+ }
298
+ )
299
+ ] })
300
+ }
301
+ ];
302
+ return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
303
+ (y != null || N != null) && /* @__PURE__ */ a("div", { className: "section-head", children: [
304
+ y,
305
+ N
251
306
  ] }),
252
- /* @__PURE__ */ n("div", { className: "card", children: [
307
+ /* @__PURE__ */ a("div", { className: "card", children: [
253
308
  o.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
254
- ((y = o.data) == null ? void 0 : y.length) === 0 && N,
255
- /* @__PURE__ */ e("ul", { className: "list", children: (C = o.data) == null ? void 0 : C.map((d) => /* @__PURE__ */ n("li", { children: [
256
- /* @__PURE__ */ n("div", { className: "list-main", children: [
257
- /* @__PURE__ */ e("strong", { className: "list-name", title: d.name, children: d.name }),
258
- " ",
259
- /* @__PURE__ */ e("code", { className: "muted small", children: "••••••••" }),
260
- /* @__PURE__ */ n("div", { className: "muted small list-preview", children: [
261
- d.description && /* @__PURE__ */ n(V, { children: [
262
- d.description,
263
- " · "
264
- ] }),
265
- "updated ",
266
- new Date(d.updatedAt).toLocaleString()
267
- ] })
268
- ] }),
269
- /* @__PURE__ */ n("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
270
- /* @__PURE__ */ e(
271
- L,
272
- {
273
- label: "Rotate",
274
- onClick: () => v({ mode: "edit", s: d }),
275
- "data-testid": `secret-rotate-${d.id}`
276
- }
277
- ),
278
- /* @__PURE__ */ e(
279
- j,
280
- {
281
- label: "Delete",
282
- onClick: () => f(d),
283
- disabled: u.isPending,
284
- "data-testid": `secret-delete-${d.id}`
285
- }
286
- )
287
- ] })
288
- ] }, d.id)) })
309
+ ((s = o.data) == null ? void 0 : s.length) === 0 && C,
310
+ o.data != null && o.data.length > 0 && /* @__PURE__ */ e(T, { columns: S, rows: o.data, rowKey: (u) => u.id })
289
311
  ] }),
290
- s && /* @__PURE__ */ e(
291
- z,
312
+ l && /* @__PURE__ */ e(
313
+ Me,
292
314
  {
293
- initial: s.mode === "edit" ? s.s : void 0,
294
- onClose: () => v(null),
295
- onSaved: () => v(null)
315
+ initial: l.mode === "edit" ? l.s : void 0,
316
+ onClose: () => h(null),
317
+ onSaved: () => h(null)
296
318
  }
297
319
  ),
298
320
  i && /* @__PURE__ */ e(
299
- $,
321
+ W,
300
322
  {
301
323
  title: "Delete secret",
302
324
  message: `Delete the secret "${i.name}"? This cannot be undone.`,
303
325
  confirmLabel: "Delete",
304
326
  onConfirm: () => {
305
- u.mutate(i.id), f(null);
327
+ g.mutate(i.id), f(null);
306
328
  },
307
329
  onClose: () => f(null)
308
330
  }
309
331
  )
310
332
  ] }) });
311
333
  }
312
- function z(t) {
313
- var S, r, k;
314
- const a = !!t.initial, [s, v] = h(((S = t.initial) == null ? void 0 : S.name) ?? ""), [i, f] = h(""), [o, u] = h(((r = t.initial) == null ? void 0 : r.description) ?? ""), [g, p] = h(null), m = I(), b = W(((k = t.initial) == null ? void 0 : k.id) ?? ""), N = a ? b : m, y = !!s && (a || !!i) && !N.isPending;
315
- function C() {
316
- if (p(null), a) {
317
- b.mutate(
334
+ function Me(t) {
335
+ var k, c, M;
336
+ const n = !!t.initial, [l, h] = m(((k = t.initial) == null ? void 0 : k.name) ?? ""), [i, f] = m(""), [o, g] = m(((c = t.initial) == null ? void 0 : c.description) ?? ""), [b, y] = m(null), p = ve(), N = be(((M = t.initial) == null ? void 0 : M.id) ?? ""), C = n ? N : p, S = !!l && (n || !!i) && !C.isPending;
337
+ function s() {
338
+ if (y(null), n) {
339
+ N.mutate(
318
340
  { value: i === "" ? void 0 : i, description: o },
319
341
  {
320
342
  onSuccess: () => t.onSaved(),
321
- onError: (c) => p((c instanceof x, c.message))
343
+ onError: (v) => y((v instanceof L, v.message))
322
344
  }
323
345
  );
324
346
  return;
325
347
  }
326
348
  if (i === "") {
327
- p("A secret value is required.");
349
+ y("A secret value is required.");
328
350
  return;
329
351
  }
330
- m.mutate(
331
- { name: s, value: i, description: o },
352
+ p.mutate(
353
+ { name: l, value: i, description: o },
332
354
  {
333
355
  onSuccess: () => t.onSaved(),
334
- onError: (c) => p((c instanceof x, c.message))
356
+ onError: (v) => y((v instanceof L, v.message))
335
357
  }
336
358
  );
337
359
  }
338
- const d = P(C, { enabled: y });
339
- return /* @__PURE__ */ n(
340
- O,
360
+ const u = V(s, { enabled: S });
361
+ return /* @__PURE__ */ a(
362
+ R,
341
363
  {
342
364
  title: t.initial ? `Rotate ${t.initial.name}` : "Add secret",
343
365
  onClose: t.onClose,
344
366
  children: [
345
- /* @__PURE__ */ n("div", { className: "modal-body", children: [
346
- /* @__PURE__ */ n("label", { className: "field", children: [
367
+ /* @__PURE__ */ a("div", { className: "modal-body", children: [
368
+ /* @__PURE__ */ a("label", { className: "field", children: [
347
369
  /* @__PURE__ */ e("span", { children: "Name" }),
348
370
  /* @__PURE__ */ e(
349
371
  "input",
350
372
  {
351
373
  type: "text",
352
- value: s,
353
- disabled: a,
354
- onChange: (c) => v(c.target.value),
374
+ value: l,
375
+ disabled: n,
376
+ onChange: (v) => h(v.target.value),
355
377
  placeholder: "e.g. openai_api_key",
356
378
  maxLength: 64,
357
- ...d
379
+ ...u
358
380
  }
359
381
  ),
360
- !a && /* @__PURE__ */ e("span", { className: "hint", children: "Lowercase letters, digits, and underscores. Must start with a letter or underscore." })
382
+ !n && /* @__PURE__ */ e("span", { className: "hint", children: "Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive." })
361
383
  ] }),
362
- /* @__PURE__ */ n("label", { className: "field", children: [
363
- /* @__PURE__ */ e("span", { children: a ? "New value" : "Value" }),
384
+ /* @__PURE__ */ a("label", { className: "field", children: [
385
+ /* @__PURE__ */ e("span", { children: n ? "New value" : "Value" }),
364
386
  /* @__PURE__ */ e(
365
387
  "textarea",
366
388
  {
367
389
  className: "code",
368
390
  rows: 3,
369
391
  value: i,
370
- onChange: (c) => f(c.target.value),
371
- placeholder: a ? "Leave blank to keep the current value" : "sk-…",
392
+ onChange: (v) => f(v.target.value),
393
+ placeholder: n ? "Leave blank to keep the current value" : "sk-…",
372
394
  autoComplete: "off",
373
395
  spellCheck: !1
374
396
  }
375
397
  ),
376
398
  /* @__PURE__ */ e("span", { className: "hint", children: "Stored encrypted at rest. Once saved, it is not readable through the UI." })
377
399
  ] }),
378
- /* @__PURE__ */ n("label", { className: "field", children: [
400
+ /* @__PURE__ */ a("label", { className: "field", children: [
379
401
  /* @__PURE__ */ e("span", { children: "Description" }),
380
402
  /* @__PURE__ */ e(
381
403
  "input",
382
404
  {
383
405
  type: "text",
384
406
  value: o,
385
- onChange: (c) => u(c.target.value),
407
+ onChange: (v) => g(v.target.value),
386
408
  placeholder: "Optional",
387
- ...d
409
+ ...u
388
410
  }
389
411
  )
390
412
  ] }),
391
- g && /* @__PURE__ */ e("div", { className: "result error", children: g })
413
+ b && /* @__PURE__ */ e("div", { className: "result error", children: b })
392
414
  ] }),
393
- /* @__PURE__ */ n("div", { className: "modal-actions", children: [
415
+ /* @__PURE__ */ a("div", { className: "modal-actions", children: [
394
416
  /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
395
- /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !y, onClick: C, children: N.isPending ? "Saving…" : a ? "Save changes" : "Save secret" })
417
+ /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !S, onClick: s, children: C.isPending ? "Saving…" : n ? "Save changes" : "Save secret" })
396
418
  ] })
397
419
  ]
398
420
  }
399
421
  );
400
422
  }
423
+ const we = {
424
+ costMinor: "Cost",
425
+ tokens: "Tokens",
426
+ requests: "Requests"
427
+ }, Ee = ["block", "warn"], ee = ["tenant", "account", "project", "route", "connection"], xe = {
428
+ tenant: "Tenant",
429
+ account: "Account",
430
+ project: "Project",
431
+ route: "Model route",
432
+ connection: "Connection"
433
+ }, De = (t) => t === "route" || t === "connection", te = ["day", "month"];
434
+ function P(t) {
435
+ return String(t).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
436
+ }
437
+ function je(t, n) {
438
+ return t === "costMinor" ? (l) => `${n} ${(l / 100).toFixed(2)}` : P;
439
+ }
440
+ function $e(t) {
441
+ return t.costMinor != null ? "costMinor" : t.tokens != null ? "tokens" : t.requests != null ? "requests" : null;
442
+ }
443
+ function Ie(t) {
444
+ return t.costMinor == null ? null : `${t.currency ?? "USD"} ${(t.costMinor / 100).toFixed(2)}`;
445
+ }
446
+ function Le(t) {
447
+ const n = [];
448
+ t.requests != null && n.push(`${P(t.requests)} requests`), t.tokens != null && n.push(`${P(t.tokens)} tokens`);
449
+ const l = Ie(t);
450
+ return l != null && n.push(l), n.length === 0 ? "no limit" : n.join(" · ");
451
+ }
452
+ function I(t) {
453
+ return t.scopeId == null ? `this ${t.scopeKind}` : `${t.scopeKind} ${t.scopeId}`;
454
+ }
455
+ function le(t) {
456
+ return t instanceof L || t instanceof Error ? t.message : String(t);
457
+ }
458
+ function B(t) {
459
+ const n = t.trim();
460
+ if (n === "") return null;
461
+ const l = Number(n);
462
+ return Number.isFinite(l) ? l : null;
463
+ }
464
+ function Qe(t) {
465
+ var S;
466
+ const n = ae(t.projectId), [l, h] = m(null), [i, f] = m(null), [o, g] = m(null), b = pe(n ?? void 0), y = fe(), p = b.data ?? [], N = n != null, C = [
467
+ {
468
+ key: "scope",
469
+ header: "Scope",
470
+ render: (s) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
471
+ /* @__PURE__ */ e("strong", { className: "list-name", title: I(s), children: s.scopeKind }),
472
+ " ",
473
+ /* @__PURE__ */ e("span", { className: s.onBreach === "warn" ? "tag warn" : "tag", children: s.onBreach }),
474
+ /* @__PURE__ */ e("div", { className: "muted small list-preview", title: I(s), children: s.scopeId == null ? `the whole ${s.scopeKind}` : s.scopeId })
475
+ ] })
476
+ },
477
+ {
478
+ key: "window",
479
+ header: "Window",
480
+ render: (s) => s.window
481
+ },
482
+ {
483
+ key: "limits",
484
+ header: "Limit",
485
+ render: (s) => /* @__PURE__ */ e("span", { className: "muted small", children: Le(s.limits) })
486
+ },
487
+ {
488
+ key: "usage",
489
+ header: "Used",
490
+ // Rows only exist once the project-scoped query ran, so `project` is set here.
491
+ render: (s) => n == null ? null : /* @__PURE__ */ e(qe, { budget: s, projectId: n })
492
+ },
493
+ {
494
+ key: "actions",
495
+ header: "",
496
+ align: "right",
497
+ link: !1,
498
+ render: (s) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
499
+ /* @__PURE__ */ e(
500
+ A,
501
+ {
502
+ label: "Edit",
503
+ onClick: () => h({ budget: s }),
504
+ "data-testid": `model-budget-edit-${s.id}`
505
+ }
506
+ ),
507
+ /* @__PURE__ */ e(
508
+ O,
509
+ {
510
+ label: "Delete",
511
+ onClick: () => f(s),
512
+ disabled: y.isPending,
513
+ "data-testid": `model-budget-delete-${s.id}`
514
+ }
515
+ )
516
+ ] })
517
+ }
518
+ ];
519
+ return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
520
+ /* @__PURE__ */ a("div", { className: "section-head", children: [
521
+ /* @__PURE__ */ a("div", { children: [
522
+ /* @__PURE__ */ e("h3", { children: "Model budgets" }),
523
+ /* @__PURE__ */ e("p", { className: "muted small", children: "Caps on what a tenant, account, project, route or connection may spend. A breached budget either warns or blocks the call, per its own setting." })
524
+ ] }),
525
+ /* @__PURE__ */ e(
526
+ "button",
527
+ {
528
+ type: "button",
529
+ className: "btn",
530
+ disabled: !N,
531
+ onClick: () => h({}),
532
+ "data-testid": "model-budget-add",
533
+ children: "+ Add budget"
534
+ }
535
+ )
536
+ ] }),
537
+ o && /* @__PURE__ */ e("div", { className: "result error", role: "alert", "data-testid": "model-budget-delete-error", children: o }),
538
+ /* @__PURE__ */ a("div", { className: "card", children: [
539
+ b.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
540
+ ((S = b.data) == null ? void 0 : S.length) === 0 && /* @__PURE__ */ e(U, { testId: "model-budgets-empty", children: "No model budgets yet. Add one to cap spend or request volume." }),
541
+ p.length > 0 && /* @__PURE__ */ e(
542
+ T,
543
+ {
544
+ columns: C,
545
+ rows: p,
546
+ rowKey: (s) => s.id,
547
+ testId: "model-budgets-table"
548
+ }
549
+ )
550
+ ] }),
551
+ l != null && n != null && /* @__PURE__ */ e(
552
+ Be,
553
+ {
554
+ project: n,
555
+ initial: l.budget,
556
+ onClose: () => h(null),
557
+ onSaved: () => h(null)
558
+ }
559
+ ),
560
+ i != null && n != null && /* @__PURE__ */ e(
561
+ W,
562
+ {
563
+ title: "Delete model budget",
564
+ message: `Delete the budget on ${I(i)}? Calls stop being capped by it immediately.`,
565
+ confirmLabel: "Delete",
566
+ onConfirm: () => {
567
+ const s = i;
568
+ g(null), y.mutate(
569
+ { project: n, id: s.id },
570
+ {
571
+ onError: (u) => g(
572
+ `Could not delete the budget on ${I(s)}: ${le(u)}`
573
+ )
574
+ }
575
+ ), f(null);
576
+ },
577
+ onClose: () => f(null)
578
+ }
579
+ )
580
+ ] }) });
581
+ }
582
+ function qe(t) {
583
+ const n = Ce(t.budget.id, t.projectId);
584
+ if (n.isLoading) return /* @__PURE__ */ e("span", { className: "muted small", children: "Loading…" });
585
+ const l = n.data;
586
+ if (l == null) return /* @__PURE__ */ e("span", { className: "muted small", children: "—" });
587
+ const h = l.limits ?? t.budget.limits, i = $e(h);
588
+ return i == null ? /* @__PURE__ */ e("span", { className: "muted small", children: "no limit" }) : /* @__PURE__ */ e(
589
+ re,
590
+ {
591
+ label: we[i],
592
+ used: l.used[i],
593
+ limit: h[i] ?? 0,
594
+ reserved: l.reserved[i],
595
+ format: je(i, h.currency ?? "USD"),
596
+ testId: `model-budget-meter-${t.budget.id}`
597
+ }
598
+ );
599
+ }
600
+ function Be(t) {
601
+ var Q, _, J, H, Y, z, G, X;
602
+ const n = !!t.initial, [l, h] = m(((Q = t.initial) == null ? void 0 : Q.scopeKind) ?? "project"), [i, f] = m(((_ = t.initial) == null ? void 0 : _.scopeId) ?? ""), [o, g] = m(((J = t.initial) == null ? void 0 : J.window) ?? "day"), [b, y] = m(
603
+ ((H = t.initial) == null ? void 0 : H.limits.requests) != null ? String(t.initial.limits.requests) : ""
604
+ ), [p, N] = m(
605
+ ((Y = t.initial) == null ? void 0 : Y.limits.tokens) != null ? String(t.initial.limits.tokens) : ""
606
+ ), [C, S] = m(
607
+ ((z = t.initial) == null ? void 0 : z.limits.costMinor) != null ? String(t.initial.limits.costMinor / 100) : ""
608
+ ), [s, u] = m(((G = t.initial) == null ? void 0 : G.limits.currency) ?? ""), [k, c] = m(((X = t.initial) == null ? void 0 : X.onBreach) ?? "warn"), [M, v] = m(null), E = ye(), d = Ne(), x = E.isPending || d.isPending, w = De(l), F = !!l && !!o && (!w || n || i.trim() !== "") && !x;
609
+ function ie() {
610
+ const r = {}, j = B(b);
611
+ j != null && (r.requests = j);
612
+ const $ = B(p);
613
+ $ != null && (r.tokens = $);
614
+ const Z = B(C);
615
+ return Z != null && (r.costMinor = Math.round(Z * 100)), r.costMinor != null && s.trim() !== "" && (r.currency = s.trim()), Object.keys(r).length === 0 ? null : r;
616
+ }
617
+ function K() {
618
+ const r = ie();
619
+ if (r == null) {
620
+ v("Set at least one limit: requests, tokens or cost.");
621
+ return;
622
+ }
623
+ v(null);
624
+ const j = {
625
+ onSuccess: () => t.onSaved(),
626
+ onError: ($) => v(le($))
627
+ };
628
+ if (t.initial) {
629
+ d.mutate(
630
+ { project: t.project, id: t.initial.id, patch: { window: o, limits: r, onBreach: k } },
631
+ j
632
+ );
633
+ return;
634
+ }
635
+ E.mutate(
636
+ {
637
+ project: t.project,
638
+ input: {
639
+ scopeKind: l,
640
+ // Only route/connection budgets carry a scope id; the server refuses one elsewhere.
641
+ ...w ? { scopeId: i.trim() } : {},
642
+ window: o,
643
+ limits: r,
644
+ onBreach: k
645
+ }
646
+ },
647
+ j
648
+ );
649
+ }
650
+ const D = V(K, { enabled: F });
651
+ return /* @__PURE__ */ a(R, { title: t.initial ? "Edit model budget" : "Add model budget", onClose: t.onClose, children: [
652
+ /* @__PURE__ */ a("div", { className: "modal-body", children: [
653
+ /* @__PURE__ */ a("label", { className: "field", children: [
654
+ /* @__PURE__ */ e("span", { children: "Scope" }),
655
+ /* @__PURE__ */ a(
656
+ "select",
657
+ {
658
+ value: l,
659
+ disabled: n,
660
+ onChange: (r) => h(r.target.value),
661
+ "data-testid": "model-budget-scope-kind",
662
+ children: [
663
+ !ee.includes(l) && /* @__PURE__ */ e("option", { value: l, children: l }),
664
+ ee.map((r) => /* @__PURE__ */ e("option", { value: r, children: xe[r] }, r))
665
+ ]
666
+ }
667
+ ),
668
+ !n && /* @__PURE__ */ e("span", { className: "hint", children: "What the budget caps — this tenant, account or project as a whole, or one model route or connection. Fixed once created." })
669
+ ] }),
670
+ w && /* @__PURE__ */ a("label", { className: "field", children: [
671
+ /* @__PURE__ */ a("span", { children: [
672
+ l === "route" ? "Route" : "Connection id",
673
+ " *"
674
+ ] }),
675
+ /* @__PURE__ */ e(
676
+ "input",
677
+ {
678
+ type: "text",
679
+ value: i,
680
+ disabled: n,
681
+ onChange: (r) => f(r.target.value),
682
+ placeholder: l === "route" ? "e.g. fast" : "e.g. conn_…",
683
+ "data-testid": "model-budget-scope-id",
684
+ ...D
685
+ }
686
+ ),
687
+ !n && /* @__PURE__ */ e("span", { className: "hint", children: l === "route" ? "The route's name or id. Required for a route budget." : "The model-provider connection's id. Required for a connection budget." })
688
+ ] }),
689
+ /* @__PURE__ */ a("label", { className: "field", children: [
690
+ /* @__PURE__ */ e("span", { children: "Window" }),
691
+ /* @__PURE__ */ a(
692
+ "select",
693
+ {
694
+ value: o,
695
+ onChange: (r) => g(r.target.value),
696
+ "data-testid": "model-budget-window",
697
+ children: [
698
+ !te.includes(o) && /* @__PURE__ */ e("option", { value: o, children: o }),
699
+ te.map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
700
+ ]
701
+ }
702
+ ),
703
+ /* @__PURE__ */ e("span", { className: "hint", children: "The period the limits reset over, in UTC." })
704
+ ] }),
705
+ /* @__PURE__ */ a("label", { className: "field", children: [
706
+ /* @__PURE__ */ e("span", { children: "Requests" }),
707
+ /* @__PURE__ */ e(
708
+ "input",
709
+ {
710
+ type: "number",
711
+ min: 0,
712
+ value: b,
713
+ onChange: (r) => y(r.target.value),
714
+ placeholder: "Unlimited",
715
+ "data-testid": "model-budget-requests",
716
+ ...D
717
+ }
718
+ )
719
+ ] }),
720
+ /* @__PURE__ */ a("label", { className: "field", children: [
721
+ /* @__PURE__ */ e("span", { children: "Tokens" }),
722
+ /* @__PURE__ */ e(
723
+ "input",
724
+ {
725
+ type: "number",
726
+ min: 0,
727
+ value: p,
728
+ onChange: (r) => N(r.target.value),
729
+ placeholder: "Unlimited",
730
+ "data-testid": "model-budget-tokens",
731
+ ...D
732
+ }
733
+ )
734
+ ] }),
735
+ /* @__PURE__ */ a("label", { className: "field", children: [
736
+ /* @__PURE__ */ e("span", { children: "Cost" }),
737
+ /* @__PURE__ */ e(
738
+ "input",
739
+ {
740
+ type: "number",
741
+ min: 0,
742
+ step: "0.01",
743
+ value: C,
744
+ onChange: (r) => S(r.target.value),
745
+ placeholder: "Unlimited",
746
+ "data-testid": "model-budget-cost",
747
+ ...D
748
+ }
749
+ ),
750
+ /* @__PURE__ */ e("span", { className: "hint", children: "In major units of the currency below (12.50 = 12.50 USD)." })
751
+ ] }),
752
+ /* @__PURE__ */ a("label", { className: "field", children: [
753
+ /* @__PURE__ */ e("span", { children: "Currency" }),
754
+ /* @__PURE__ */ e(
755
+ "input",
756
+ {
757
+ type: "text",
758
+ value: s,
759
+ onChange: (r) => u(r.target.value),
760
+ placeholder: "USD",
761
+ maxLength: 8,
762
+ "data-testid": "model-budget-currency",
763
+ ...D
764
+ }
765
+ )
766
+ ] }),
767
+ /* @__PURE__ */ a("label", { className: "field", children: [
768
+ /* @__PURE__ */ e("span", { children: "On breach" }),
769
+ /* @__PURE__ */ e(
770
+ "select",
771
+ {
772
+ value: k,
773
+ onChange: (r) => c(r.target.value),
774
+ "data-testid": "model-budget-on-breach",
775
+ children: Ee.map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
776
+ }
777
+ ),
778
+ /* @__PURE__ */ e("span", { className: "hint", children: "`block` refuses calls past the limit; `warn` lets them through and flags them." })
779
+ ] }),
780
+ M && /* @__PURE__ */ e("div", { className: "result error", "data-testid": "model-budget-error", children: M })
781
+ ] }),
782
+ /* @__PURE__ */ a("div", { className: "modal-actions", children: [
783
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
784
+ /* @__PURE__ */ e(
785
+ "button",
786
+ {
787
+ type: "button",
788
+ className: "btn",
789
+ disabled: !F,
790
+ onClick: K,
791
+ "data-testid": "model-budget-save",
792
+ children: x ? "Saving…" : n ? "Save changes" : "Save budget"
793
+ }
794
+ )
795
+ ] })
796
+ ] });
797
+ }
401
798
  export {
402
- re as CreateEndpointModal,
403
- se as CreateFunctionModal,
404
- ne as SecretsManager,
405
- ae as VarsManager
799
+ He as CreateEndpointModal,
800
+ Ye as CreateFunctionModal,
801
+ Qe as ModelBudgetsManager,
802
+ Ge as ModelRoutesManager,
803
+ Ke as SecretsManager,
804
+ Fe as VarsManager
406
805
  };
407
806
  //# sourceMappingURL=forms.mjs.map