@burdenoff/microfe-botmanor 2026.1120.19 → 2026.1120.21

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.
@@ -1,838 +1,1005 @@
1
1
  import { useBotlit as e } from "../providers/BotlitProvider.js";
2
- import { isNative as t, nativeCopyText as n, nativeImpact as r, nativeNotify as i, nativeToast as ee } from "../../utils/nativeBridge.js";
3
- import { PageLayout as a } from "../components/PageLayout.js";
4
- import { BOTMANOR_PERMISSIONS as o } from "../permissions/botmanorPermissions.js";
5
- import { BotmanorPermissionGate as s } from "../permissions/useBotmanorPermissions.js";
6
- import { EmptyState as te } from "../components/EmptyState.js";
7
- import { Card as c, CardContent as l, CardDescription as u, CardHeader as d, CardTitle as f } from "../components/Card.js";
8
- import { Button as p } from "../components/Button.js";
9
- import { FormField as m, Input as h, Textarea as g } from "../components/Input.js";
10
- import { Badge as _, StatusBadge as ne } from "../components/Badge.js";
2
+ import { isNative as t, nativeCopyText as n, nativeNotify as r, nativeToast as i } from "../../utils/nativeBridge.js";
3
+ import { useTr as a } from "../../shared/hooks/useTr.js";
4
+ import { PageLayout as o } from "../components/PageLayout.js";
5
+ import { BOTMANOR_PERMISSIONS as s } from "../permissions/botmanorPermissions.js";
6
+ import { BotmanorPermissionGate as c } from "../permissions/useBotmanorPermissions.js";
7
+ import { EmptyState as ee } from "../components/EmptyState.js";
8
+ import { ErrorState as te } from "../components/ErrorState.js";
9
+ import { Card as l, CardContent as u, CardDescription as d, CardHeader as f, CardTitle as p } from "../components/Card.js";
10
+ import { Button as m } from "../components/Button.js";
11
+ import { FormField as h, Input as g, Textarea as ne } from "../components/Input.js";
12
+ import { Badge as _, StatusBadge as re } from "../components/Badge.js";
11
13
  import "../hooks/index.js";
12
- import { promptTemplateExamples as v, promptTemplateVariables as y, useCreatePromptTemplate as re, useDeletePromptTemplate as ie, usePromptTemplate as ae, useRenderPromptTemplate as oe, useUpdatePromptTemplate as se } from "../hooks/usePromptTemplates.js";
13
- import { formatRelativeTime as ce } from "../utils/formatters.js";
14
- import { graphqlErrorMessage as le } from "../utils/errors.js";
14
+ import { promptTemplateExamples as ie, promptTemplateVariables as ae, useCreatePromptTemplate as oe, useDeletePromptTemplate as se, useDuplicatePromptTemplate as ce, useLoadPromptTemplateUsage as le, usePromptTemplate as ue, useRenderPromptTemplate as de, useUpdatePromptTemplate as fe } from "../hooks/usePromptTemplates.js";
15
+ import { confirmAction as pe } from "../utils/confirmAction.js";
16
+ import { useUnsavedChangesGuard as me } from "../utils/leaveGuard.js";
17
+ import { formatRelativeTime as he } from "../utils/formatters.js";
18
+ import { graphqlErrorMessage as v } from "../utils/errors.js";
19
+ import { PROMPT_TEMPLATE_DESCRIPTION_MAX_LENGTH as ge, PROMPT_TEMPLATE_ERROR_MESSAGES as _e, PROMPT_TEMPLATE_TEXT_MAX_LENGTH as ve, PROMPT_VARIABLE_VALUE_MAX_LENGTH as ye, fillTemplateText as be, hasPromptTemplateErrors as xe, promptTemplateDeleteMessage as Se, splitTemplateText as y, suggestTemplateSlug as Ce, templatePlaceholders as we, validatePromptTemplateForm as Te, variableMismatches as Ee } from "../utils/promptTemplateForm.js";
15
20
  import { toUnion as b } from "../utils/unions.js";
16
21
  import "../permissions/index.js";
17
- import { useMemo as ue, useState as x } from "react";
18
- import { PagePurpose as de } from "@burdenoff/fe-libs/ui";
19
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
20
- import { useParams as fe } from "react-router";
21
- import { ArrowLeft as pe, Check as me, Code as T, Copy as he, Edit3 as ge, Eye as E, FileText as D, Play as O, Save as k, Settings as _e, Trash2 as A, Variable as j } from "lucide-react";
22
- import { toast as M } from "sonner";
22
+ import { useMemo as x, useRef as De, useState as S } from "react";
23
+ import { PagePurpose as Oe } from "@burdenoff/fe-libs/ui";
24
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
25
+ import { useParams as ke } from "react-router";
26
+ import { AlertTriangle as E, ArrowLeft as Ae, Check as je, Code as Me, Copy as Ne, CopyPlus as Pe, Edit3 as Fe, Eye as Ie, FileText as Le, Play as Re, Plus as ze, Save as Be, Settings as Ve, Trash2 as He, Variable as D } from "lucide-react";
27
+ import { toast as O } from "sonner";
23
28
  // src/botlit/pages/PromptTemplateDetailPage.tsx
24
- var N = [
29
+ var Ue = [
25
30
  "string",
26
31
  "number",
27
32
  "boolean",
28
33
  "array",
29
34
  "object"
30
- ], ve = [
35
+ ], k = [
31
36
  "PRIVATE",
32
37
  "WORKSPACE",
33
38
  "PUBLIC"
34
- ], P = ({ isNew: P }) => {
35
- let { templateId: ye } = fe(), { navigateTo: F } = e(), { data: I, loading: be } = ae(P ? void 0 : ye), { create: xe, loading: Se } = re(), { update: Ce, loading: we } = se(), { remove: Te, loading: Ee } = ie(), { render: De, loading: Oe } = oe(), [L, R] = x("edit"), [z, B] = x(!1), [V, ke] = x({}), [H, U] = x(null), [W, G] = x(null), [K, q] = x(!1), [Ae, je] = x(!1), [J, Y] = x({
36
- name: "",
37
- slug: "",
38
- description: "",
39
- visibility: "PRIVATE",
40
- templateText: "",
41
- variables: [],
42
- exampleInputs: [{}]
43
- }), X = ue(() => {
44
- let e = P ? J.templateText : I?.templateText || "", t = /\{\{(\w+)\}\}/g, n = /* @__PURE__ */ new Set(), r;
45
- for (; (r = t.exec(e)) !== null;) n.add(r[1]);
46
- return Array.from(n);
47
- }, [
48
- P,
49
- J.templateText,
50
- I?.templateText
51
- ]), Me = async () => {
52
- if (J.name && J.slug) {
53
- try {
54
- await xe({
55
- name: J.name,
56
- slug: J.slug,
57
- description: J.description,
58
- visibility: J.visibility,
59
- templateText: J.templateText,
60
- variables: J.variables,
61
- exampleInputs: J.exampleInputs
62
- });
63
- } catch (e) {
64
- M.error(e instanceof Error ? e.message : "Failed to create prompt template");
65
- return;
66
- }
67
- M.success(`Template "${J.name}" created`), F("prompt-templates");
39
+ ], A = [
40
+ "DRAFT",
41
+ "ACTIVE",
42
+ "DEPRECATED",
43
+ "ARCHIVED"
44
+ ], j = "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm text-text-primary", We = {
45
+ name: "",
46
+ slug: "",
47
+ description: "",
48
+ status: "DRAFT",
49
+ visibility: "PRIVATE",
50
+ templateText: "",
51
+ variables: []
52
+ }, M = ({ text: e, emptyText: t }) => e ? /* @__PURE__ */ w(C, { children: y(e).map((e, t) => e.variable ? /* @__PURE__ */ w("span", {
53
+ className: "rounded bg-action-primary-bg/20 px-1 font-mono text-primary",
54
+ "data-variable": e.variable,
55
+ children: e.text
56
+ }, t) : /* @__PURE__ */ w("span", { children: e.text }, t)) }) : /* @__PURE__ */ w("span", {
57
+ className: "text-text-secondary",
58
+ children: t
59
+ });
60
+ function N(e) {
61
+ return e == null ? "" : typeof e == "string" ? e : JSON.stringify(e);
62
+ }
63
+ var P = ({ isNew: y }) => {
64
+ let P = a(), { templateId: Ge } = ke(), { navigateTo: F } = e(), { data: I, loading: Ke, error: qe, refetch: Je } = ue(y ? void 0 : Ge), { create: Ye, loading: Xe } = oe(), { update: Ze, loading: Qe } = fe(), { remove: $e, loading: et } = se(), { render: tt, loading: nt } = de(), { duplicate: rt, loading: it } = ce(), at = le(), [L, ot] = S("edit"), [st, ct] = S(!1), [R, lt] = S({}), [ut, dt] = S(null), [ft, pt] = S(null), [z, B] = S(!1), [mt, ht] = S(!1), [V, H] = S(We), [gt, _t] = S(We), vt = De(!1), [U, W] = S(!1), [yt, G] = S(!1), bt = !!(y || z), xt = x(() => JSON.stringify(V) !== JSON.stringify(gt), [V, gt]), St = bt && !yt && xt, K = x(() => Te(V, !!y), [V, y]), q = xe(K), Ct = x(() => we(V.templateText), [V.templateText]), J = x(() => Ee(V.templateText, V.variables), [V.templateText, V.variables]);
65
+ me(St, P);
66
+ let Y = (e) => U && e ? P(`botlit.promptTemplates.errors.${e}`, _e[e]) : void 0, wt = (e) => U && e ? P(`botlit.promptTemplates.errors.${e}`, _e[e]) : void 0, Tt = async () => !St || pe({
67
+ title: P("botlit.promptTemplates.discard.title", "Discard changes?"),
68
+ message: P("botlit.promptTemplates.discard.message", "You have unsaved changes. If you leave now they will be lost."),
69
+ confirmLabel: P("botlit.promptTemplates.discard.confirm", "Discard"),
70
+ cancelLabel: P("botlit.promptTemplates.discard.keepEditing", "Keep editing")
71
+ }), X = async (e) => {
72
+ await Tt() && (G(!0), F(e));
73
+ }, Et = async () => {
74
+ await Tt() && (B(!1), W(!1));
75
+ }, Dt = (e) => e.map((e) => ({
76
+ name: e.name.trim(),
77
+ type: e.type,
78
+ required: e.required,
79
+ ...e.description?.trim() ? { description: e.description.trim() } : {},
80
+ ...e.defaultValue !== void 0 && e.defaultValue !== "" ? { defaultValue: N(e.defaultValue) } : {}
81
+ })), Ot = async (e) => {
82
+ if (e?.preventDefault(), W(!0), q) return;
83
+ let t = V.name.trim(), n;
84
+ try {
85
+ n = await Ye({
86
+ name: t,
87
+ slug: V.slug.trim(),
88
+ description: V.description.trim() || void 0,
89
+ status: V.status,
90
+ visibility: V.visibility,
91
+ templateText: V.templateText,
92
+ variables: Dt(V.variables),
93
+ exampleInputs: []
94
+ });
95
+ } catch (e) {
96
+ O.error(v(e, P("botlit.promptTemplates.createError", "Failed to create the prompt template")));
97
+ return;
68
98
  }
69
- }, Ne = () => {
70
- Y({
71
- ...J,
72
- variables: [...J.variables, {
73
- name: "",
99
+ G(!0), O.success(P("botlit.promptTemplates.created", "Template \"{{name}}\" created", { name: t })), F(n?.id ? `prompt-templates/${n.id}` : "prompt-templates");
100
+ }, kt = (e) => H((t) => ({
101
+ ...t,
102
+ name: e,
103
+ slug: y && !vt.current ? Ce(e) : t.slug
104
+ })), At = (e = "") => {
105
+ H((t) => ({
106
+ ...t,
107
+ variables: [...t.variables, {
108
+ name: e,
74
109
  type: "string",
75
- required: !0,
76
- defaultValue: void 0
110
+ required: !1
77
111
  }]
78
- });
112
+ }));
113
+ }, jt = () => {
114
+ H((e) => ({
115
+ ...e,
116
+ variables: [...e.variables, ...J.undeclared.map((e) => ({
117
+ name: e,
118
+ type: "string",
119
+ required: !0
120
+ }))]
121
+ }));
79
122
  }, Z = (e, t) => {
80
- let n = [...J.variables];
81
- n[e] = {
82
- ...n[e],
83
- ...t
84
- }, Y({
85
- ...J,
86
- variables: n
123
+ H((n) => {
124
+ let r = [...n.variables];
125
+ return r[e] = {
126
+ ...r[e],
127
+ ...t
128
+ }, {
129
+ ...n,
130
+ variables: r
131
+ };
87
132
  });
88
- }, Pe = (e) => {
89
- Y({
90
- ...J,
91
- variables: J.variables.filter((t, n) => n !== e)
92
- });
93
- }, Fe = async () => {
133
+ }, Mt = (e) => {
134
+ H((t) => ({
135
+ ...t,
136
+ variables: t.variables.filter((t, n) => n !== e)
137
+ }));
138
+ }, Nt = async () => {
94
139
  if (I) {
95
- G(null);
140
+ pt(null);
96
141
  try {
97
- let e = await De({
142
+ let e = await tt({
98
143
  templateId: I.id,
99
- variables: V
144
+ variables: R
100
145
  });
101
- U(e);
146
+ dt(e ?? null);
102
147
  } catch (e) {
103
- let t = le(e, "Failed to render prompt template");
104
- U(null), G(t), M.error(t);
148
+ let t = v(e, P("botlit.promptTemplates.renderError", "Failed to render the prompt template"));
149
+ dt(null), pt(t), O.error(t);
105
150
  }
106
151
  }
107
- }, Ie = async () => {
108
- let e = I?.templateText || J.templateText;
109
- await n(e), B(!0), t() && ee("Copied"), setTimeout(() => B(!1), 2e3);
110
- }, Le = () => {
111
- I && (Y({
152
+ }, Pt = async () => {
153
+ let e = I?.templateText || V.templateText;
154
+ await n(e), ct(!0), t() && i(P("botlit.promptTemplates.copied", "Copied")), setTimeout(() => ct(!1), 2e3);
155
+ }, Ft = () => {
156
+ if (!I) return;
157
+ let e = {
112
158
  name: I.name,
113
159
  slug: I.slug,
114
160
  description: I.description || "",
115
- visibility: b(I.visibility, ve, "PRIVATE"),
161
+ status: b(I.status, A, "DRAFT"),
162
+ visibility: b(I.visibility, k, "PRIVATE"),
116
163
  templateText: I.templateText,
117
- variables: y(I),
118
- exampleInputs: v(I)
119
- }), q(!0));
120
- }, Re = async () => {
121
- if (I && J.name && J.slug) {
164
+ variables: ae(I)
165
+ };
166
+ H(e), _t(e), W(!1), G(!1), B(!0);
167
+ }, It = async (e) => {
168
+ if (e?.preventDefault(), I && (W(!0), !q)) {
122
169
  try {
123
- await Ce({
170
+ await Ze({
124
171
  templateId: I.id,
125
172
  input: {
126
- name: J.name,
127
- slug: J.slug,
128
- description: J.description,
129
- visibility: J.visibility,
130
- templateText: J.templateText,
131
- variables: J.variables,
132
- exampleInputs: J.exampleInputs
173
+ name: V.name.trim(),
174
+ description: V.description.trim(),
175
+ status: V.status,
176
+ visibility: V.visibility,
177
+ templateText: V.templateText,
178
+ variables: Dt(V.variables)
133
179
  }
134
180
  });
135
181
  } catch (e) {
136
- M.error(e instanceof Error ? e.message : "Failed to update prompt template");
182
+ O.error(v(e, P("botlit.promptTemplates.updateError", "Failed to update the prompt template")));
137
183
  return;
138
184
  }
139
- M.success("Template updated"), q(!1);
185
+ O.success(P("botlit.promptTemplates.updated", "Template updated")), B(!1), W(!1), Je();
140
186
  }
141
- }, ze = async () => {
142
- if (I) try {
143
- await Te(I.id), t() && i("success"), F("prompt-templates");
187
+ }, Lt = async () => {
188
+ if (!I) return;
189
+ let e = P("botlit.promptTemplates.duplicate.suffix", " (copy)"), t = Math.max(100 - e.length, 1), n = `${I.name.slice(0, t)}${e}`.slice(0, 100), r;
190
+ try {
191
+ r = await rt({
192
+ templateId: I.id,
193
+ name: n
194
+ });
144
195
  } catch (e) {
145
- throw t() && i("error"), e;
196
+ O.error(v(e, P("botlit.promptTemplates.duplicate.error", "Failed to duplicate the prompt template")));
197
+ return;
146
198
  }
147
- }, Be = (e) => e.replace(/\{\{(\w+)\}\}/g, "<span class=\"bg-action-primary-bg/20 text-primary px-1 rounded font-mono\">{{$1}}</span>");
148
- if (P) return /* @__PURE__ */ C(a, {
149
- title: "Create Prompt Template",
150
- description: "Define a reusable prompt template with variables",
151
- actions: /* @__PURE__ */ w("div", {
152
- className: "flex gap-2",
153
- children: [/* @__PURE__ */ C(p, {
154
- variant: "outline",
155
- onClick: () => F("prompt-templates"),
156
- children: "Cancel"
157
- }), /* @__PURE__ */ C(p, {
158
- leftIcon: /* @__PURE__ */ C(k, { size: 16 }),
159
- onClick: Me,
160
- isLoading: Se,
161
- disabled: !J.name || !J.slug,
162
- children: "Create Template"
199
+ O.success(P("botlit.promptTemplates.duplicate.done", "Created \"{{name}}\" as a draft copy. Rename it and adjust it as needed.", { name: n })), r?.id && F(`prompt-templates/${r.id}`);
200
+ }, Rt = async () => {
201
+ if (!I) return;
202
+ ht(!0);
203
+ let e = null;
204
+ try {
205
+ e = await at(I.id);
206
+ } catch {
207
+ e = null;
208
+ } finally {
209
+ ht(!1);
210
+ }
211
+ if (await pe({
212
+ title: P("botlit.promptTemplates.delete.title", "Delete prompt template?"),
213
+ message: Se(P, I.name, e),
214
+ confirmLabel: P("botlit.promptTemplates.delete.confirmLabel", "Delete"),
215
+ cancelLabel: P("botlit.common.cancel", "Cancel")
216
+ })) {
217
+ try {
218
+ if (await $e(I.id) === !1) {
219
+ O.error(P("botlit.promptTemplates.delete.notDeleted", "The prompt template could not be deleted."));
220
+ return;
221
+ }
222
+ } catch (e) {
223
+ t() && r("error"), O.error(v(e, P("botlit.promptTemplates.delete.error", "Failed to delete the prompt template")));
224
+ return;
225
+ }
226
+ t() && r("success"), O.success(P("botlit.promptTemplates.delete.done", "Template \"{{name}}\" deleted", { name: I.name })), F("prompt-templates");
227
+ }
228
+ }, zt = U && q ? /* @__PURE__ */ T("div", {
229
+ role: "alert",
230
+ className: "flex items-start gap-2 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-3 text-sm text-text-primary",
231
+ children: [/* @__PURE__ */ w(E, {
232
+ size: 16,
233
+ className: "mt-0.5 text-status-error-text",
234
+ "aria-hidden": "true"
235
+ }), /* @__PURE__ */ w("p", { children: P("botlit.promptTemplates.errors.summary", "Fix the highlighted fields before saving.") })]
236
+ }) : null, Bt = /* @__PURE__ */ T(C, { children: [
237
+ /* @__PURE__ */ T("div", {
238
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
239
+ children: [/* @__PURE__ */ w(h, {
240
+ label: P("botlit.promptTemplates.form.name", "Template name"),
241
+ htmlFor: "tpl-name",
242
+ required: !0,
243
+ error: Y(K.name),
244
+ description: P("botlit.promptTemplates.form.nameHelp", "Up to {{max}} characters.", { max: 100 }),
245
+ children: /* @__PURE__ */ w(g, {
246
+ id: "tpl-name",
247
+ maxLength: 100,
248
+ "aria-invalid": !!Y(K.name),
249
+ "aria-describedby": Y(K.name) ? "tpl-name-error" : "tpl-name-description",
250
+ placeholder: P("botlit.promptTemplates.form.namePlaceholder", "e.g., Technical Support Template"),
251
+ value: V.name,
252
+ onChange: (e) => kt(e.target.value)
253
+ })
254
+ }), y ? /* @__PURE__ */ w(h, {
255
+ label: P("botlit.promptTemplates.form.slug", "Slug"),
256
+ htmlFor: "tpl-slug",
257
+ required: !0,
258
+ error: Y(K.slug),
259
+ description: P("botlit.promptTemplates.form.slugHelp", "Suggested from the name. Lowercase letters, numbers and single hyphens, up to {{max}} characters. It cannot change after the template is created.", { max: 64 }),
260
+ children: /* @__PURE__ */ w(g, {
261
+ id: "tpl-slug",
262
+ className: "font-mono",
263
+ maxLength: 64,
264
+ "aria-invalid": !!Y(K.slug),
265
+ "aria-describedby": Y(K.slug) ? "tpl-slug-error" : "tpl-slug-description",
266
+ placeholder: P("botlit.promptTemplates.form.slugPlaceholder", "e.g., technical-support"),
267
+ value: V.slug,
268
+ onChange: (e) => {
269
+ vt.current = !0, H({
270
+ ...V,
271
+ slug: e.target.value.toLowerCase()
272
+ });
273
+ }
274
+ })
275
+ }) : /* @__PURE__ */ w(h, {
276
+ label: P("botlit.promptTemplates.form.slug", "Slug"),
277
+ htmlFor: "tpl-slug",
278
+ description: P("botlit.promptTemplates.form.slugLocked", "The slug cannot change: lookups by slug depend on it."),
279
+ children: /* @__PURE__ */ w(g, {
280
+ id: "tpl-slug",
281
+ className: "font-mono",
282
+ readOnly: !0,
283
+ "aria-describedby": "tpl-slug-description",
284
+ value: V.slug
285
+ })
163
286
  })]
164
287
  }),
165
- children: /* @__PURE__ */ w("div", {
166
- className: "grid grid-cols-1 lg:grid-cols-3 gap-6",
167
- children: [/* @__PURE__ */ w("div", {
168
- className: "lg:col-span-2 space-y-6",
169
- children: [
170
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ C(f, { children: "Basic Information" }) }), /* @__PURE__ */ w(l, {
171
- className: "space-y-4",
172
- children: [
173
- /* @__PURE__ */ w("div", {
174
- className: "grid grid-cols-2 gap-4",
175
- children: [/* @__PURE__ */ C(m, {
176
- label: "Template Name",
288
+ /* @__PURE__ */ w(h, {
289
+ label: P("botlit.promptTemplates.form.description", "Description"),
290
+ htmlFor: "tpl-description",
291
+ error: Y(K.description),
292
+ children: /* @__PURE__ */ w(ne, {
293
+ id: "tpl-description",
294
+ maxLength: ge,
295
+ placeholder: P("botlit.promptTemplates.form.descriptionPlaceholder", "What is this template used for?"),
296
+ value: V.description,
297
+ onChange: (e) => H({
298
+ ...V,
299
+ description: e.target.value
300
+ }),
301
+ rows: 2
302
+ })
303
+ }),
304
+ /* @__PURE__ */ T("div", {
305
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
306
+ children: [/* @__PURE__ */ w(h, {
307
+ label: P("botlit.promptTemplates.form.status", "Status"),
308
+ htmlFor: "tpl-status",
309
+ description: P("botlit.promptTemplates.form.statusHelp", "Archived templates are ignored by agents and skills, as if detached. Draft, active and deprecated templates are all used."),
310
+ children: /* @__PURE__ */ w("select", {
311
+ id: "tpl-status",
312
+ className: j,
313
+ "aria-describedby": "tpl-status-description",
314
+ value: V.status,
315
+ onChange: (e) => H({
316
+ ...V,
317
+ status: b(e.target.value, A, "DRAFT")
318
+ }),
319
+ children: A.map((e) => /* @__PURE__ */ w("option", {
320
+ value: e,
321
+ children: P(`botlit.promptTemplates.status.${e.toLowerCase()}`, e.charAt(0) + e.slice(1).toLowerCase())
322
+ }, e))
323
+ })
324
+ }), /* @__PURE__ */ w(h, {
325
+ label: P("botlit.promptTemplates.form.visibility", "Visibility"),
326
+ htmlFor: "tpl-visibility",
327
+ description: P("botlit.promptTemplates.form.visibilityHelp", "Not enforced yet: every member who can view templates sees this one."),
328
+ children: /* @__PURE__ */ w("select", {
329
+ id: "tpl-visibility",
330
+ className: j,
331
+ "aria-describedby": "tpl-visibility-description",
332
+ value: V.visibility,
333
+ onChange: (e) => H({
334
+ ...V,
335
+ visibility: b(e.target.value, k, "PRIVATE")
336
+ }),
337
+ children: k.map((e) => /* @__PURE__ */ w("option", {
338
+ value: e,
339
+ children: P(`botlit.promptTemplates.visibility.${e.toLowerCase()}`, e.charAt(0) + e.slice(1).toLowerCase())
340
+ }, e))
341
+ })
342
+ })]
343
+ })
344
+ ] }), Vt = /* @__PURE__ */ w(h, {
345
+ label: P("botlit.promptTemplates.form.content", "Template text"),
346
+ htmlFor: "tpl-content",
347
+ required: !0,
348
+ error: Y(K.templateText),
349
+ description: P("botlit.promptTemplates.form.contentHelp", "Write {{name}} (or {{ name }}) where a value goes. Names use letters, numbers and underscores. Up to {{max}} characters; {{count}} used.", {
350
+ name: "{{name}}",
351
+ max: ve,
352
+ count: V.templateText.length
353
+ }),
354
+ children: /* @__PURE__ */ w(ne, {
355
+ id: "tpl-content",
356
+ className: "font-mono text-sm min-h-[240px]",
357
+ maxLength: ve,
358
+ "aria-invalid": !!Y(K.templateText),
359
+ "aria-describedby": Y(K.templateText) ? "tpl-content-error" : "tpl-content-description",
360
+ placeholder: P("botlit.promptTemplates.form.contentPlaceholder", "You are a helpful assistant for {{company_name}}. Help users with {{task_type}}.", {
361
+ company_name: "{{company_name}}",
362
+ task_type: "{{task_type}}"
363
+ }),
364
+ value: V.templateText,
365
+ onChange: (e) => H({
366
+ ...V,
367
+ templateText: e.target.value
368
+ })
369
+ })
370
+ }), Ht = J.undeclared.length > 0 || J.unused.length > 0 ? /* @__PURE__ */ T("div", {
371
+ role: "status",
372
+ className: "space-y-2 rounded-lg border border-status-warning-border bg-status-warning-bg-subtle p-3 text-sm text-text-primary",
373
+ children: [J.undeclared.length > 0 && /* @__PURE__ */ T("div", {
374
+ className: "flex flex-wrap items-center gap-2",
375
+ children: [
376
+ /* @__PURE__ */ w(E, {
377
+ size: 16,
378
+ className: "text-status-warning-text",
379
+ "aria-hidden": "true"
380
+ }),
381
+ /* @__PURE__ */ w("span", { children: P("botlit.promptTemplates.variables.undeclared", "Used in the text but not declared: {{names}}. Rendering fails until they are declared.", { names: J.undeclared.join(", ") }) }),
382
+ /* @__PURE__ */ w(m, {
383
+ type: "button",
384
+ size: "sm",
385
+ variant: "outline",
386
+ onClick: jt,
387
+ children: P("botlit.promptTemplates.variables.addDetected", "Add detected variables")
388
+ })
389
+ ]
390
+ }), J.unused.length > 0 && /* @__PURE__ */ T("div", {
391
+ className: "flex items-center gap-2",
392
+ children: [/* @__PURE__ */ w(E, {
393
+ size: 16,
394
+ className: "text-status-warning-text",
395
+ "aria-hidden": "true"
396
+ }), /* @__PURE__ */ w("span", { children: P("botlit.promptTemplates.variables.unused", "Declared but not used in the text: {{names}}.", { names: J.unused.join(", ") }) })]
397
+ })]
398
+ }) : null, Ut = /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ T(p, {
399
+ className: "flex items-center justify-between",
400
+ children: [/* @__PURE__ */ T("span", {
401
+ className: "flex items-center gap-2",
402
+ children: [/* @__PURE__ */ w(D, {
403
+ size: 18,
404
+ "aria-hidden": "true"
405
+ }), P("botlit.promptTemplates.variables.title", "Variables")]
406
+ }), /* @__PURE__ */ w(m, {
407
+ type: "button",
408
+ variant: "outline",
409
+ size: "sm",
410
+ leftIcon: /* @__PURE__ */ w(ze, { size: 14 }),
411
+ onClick: () => At(),
412
+ children: P("botlit.promptTemplates.variables.add", "Add variable")
413
+ })]
414
+ }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.variables.description", "Declare each variable the text uses. A required variable must be given a value (or have a default) whenever the template is used; an optional one without a value is left out. Types are checked when the template is used.") })] }), /* @__PURE__ */ T(u, {
415
+ className: "space-y-4",
416
+ children: [Ht, V.variables.length > 0 ? /* @__PURE__ */ w("ul", {
417
+ className: "space-y-4",
418
+ children: V.variables.map((e, t) => {
419
+ let n = `tpl-var-${t}`, r = K.variables[t], i = wt(r?.name), a = wt(r?.defaultValue), o = e.type === "array" || e.type === "object";
420
+ return /* @__PURE__ */ T("li", {
421
+ className: "space-y-3 rounded-lg border bg-bg-sunken/30 p-4",
422
+ children: [
423
+ /* @__PURE__ */ T("div", {
424
+ className: "grid grid-cols-1 gap-3 md:grid-cols-3",
425
+ children: [
426
+ /* @__PURE__ */ w(h, {
427
+ label: P("botlit.promptTemplates.variables.name", "Name"),
428
+ htmlFor: `${n}-name`,
177
429
  required: !0,
178
- children: /* @__PURE__ */ C(h, {
179
- placeholder: "e.g., Technical Support Template",
180
- value: J.name,
181
- onChange: (e) => Y({
182
- ...J,
183
- name: e.target.value
184
- })
430
+ error: i,
431
+ children: /* @__PURE__ */ w(g, {
432
+ id: `${n}-name`,
433
+ className: "font-mono",
434
+ "aria-invalid": !!i,
435
+ "aria-describedby": i ? `${n}-name-error` : void 0,
436
+ placeholder: "variable_name",
437
+ value: e.name,
438
+ onChange: (e) => Z(t, { name: e.target.value })
185
439
  })
186
- }), /* @__PURE__ */ C(m, {
187
- label: "Slug",
188
- required: !0,
189
- description: "Unique identifier (lowercase, dashes)",
190
- children: /* @__PURE__ */ C(h, {
191
- placeholder: "e.g., technical-support",
192
- value: J.slug,
193
- onChange: (e) => Y({
194
- ...J,
195
- slug: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, "-")
196
- })
440
+ }),
441
+ /* @__PURE__ */ w(h, {
442
+ label: P("botlit.promptTemplates.variables.type", "Type"),
443
+ htmlFor: `${n}-type`,
444
+ children: /* @__PURE__ */ w("select", {
445
+ id: `${n}-type`,
446
+ className: j,
447
+ value: e.type,
448
+ onChange: (e) => Z(t, { type: b(e.target.value, Ue, "string") }),
449
+ children: Ue.map((e) => /* @__PURE__ */ w("option", {
450
+ value: e,
451
+ children: e
452
+ }, e))
453
+ })
454
+ }),
455
+ /* @__PURE__ */ w(h, {
456
+ label: P("botlit.promptTemplates.variables.default", "Default value"),
457
+ htmlFor: `${n}-default`,
458
+ error: a,
459
+ description: o ? P("botlit.promptTemplates.variables.defaultJsonHelp", "Optional. JSON, for example [\"a\", \"b\"] or {\"key\": \"value\"}.") : P("botlit.promptTemplates.variables.defaultHelp", "Optional. Used when no value is given."),
460
+ children: /* @__PURE__ */ w(g, {
461
+ id: `${n}-default`,
462
+ className: o ? "font-mono" : void 0,
463
+ maxLength: ye,
464
+ "aria-invalid": !!a,
465
+ "aria-describedby": a ? `${n}-default-error` : `${n}-default-description`,
466
+ value: N(e.defaultValue),
467
+ onChange: (e) => Z(t, { defaultValue: e.target.value === "" ? void 0 : e.target.value })
197
468
  })
198
- })]
199
- }),
200
- /* @__PURE__ */ C(m, {
201
- label: "Description",
202
- children: /* @__PURE__ */ C(g, {
203
- placeholder: "What is this template used for?",
204
- value: J.description,
205
- onChange: (e) => Y({
206
- ...J,
207
- description: e.target.value
208
- }),
209
- rows: 2
210
- })
211
- }),
212
- /* @__PURE__ */ C(m, {
213
- label: "Visibility",
214
- children: /* @__PURE__ */ w("select", {
215
- className: "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm",
216
- value: J.visibility,
217
- onChange: (e) => Y({
218
- ...J,
219
- visibility: e.target.value
220
- }),
221
- children: [
222
- /* @__PURE__ */ C("option", {
223
- value: "PRIVATE",
224
- children: "Private"
225
- }),
226
- /* @__PURE__ */ C("option", {
227
- value: "WORKSPACE",
228
- children: "Workspace"
229
- }),
230
- /* @__PURE__ */ C("option", {
231
- value: "PUBLIC",
232
- children: "Public"
233
- })
234
- ]
235
469
  })
470
+ ]
471
+ }),
472
+ /* @__PURE__ */ w(h, {
473
+ label: P("botlit.promptTemplates.variables.descriptionLabel", "Description"),
474
+ htmlFor: `${n}-description`,
475
+ children: /* @__PURE__ */ w(g, {
476
+ id: `${n}-description`,
477
+ placeholder: P("botlit.promptTemplates.variables.descriptionPlaceholder", "What is this variable for?"),
478
+ value: e.description || "",
479
+ onChange: (e) => Z(t, { description: e.target.value })
236
480
  })
237
- ]
238
- })] }),
239
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ w(f, {
240
- className: "flex items-center gap-2",
241
- children: [/* @__PURE__ */ C(T, { size: 18 }), "Template Content"]
242
- }), /* @__PURE__ */ w(u, { children: [
243
- "Use ",
244
- "{{variable_name}}",
245
- " syntax for variables"
246
- ] })] }), /* @__PURE__ */ w(l, { children: [/* @__PURE__ */ C(g, {
247
- className: "font-mono text-sm min-h-[300px]",
248
- placeholder: "You are a helpful assistant for {{company_name}}.\n\nYour role is to help users with {{task_type}}.\n\nGuidelines:\n- Be helpful and friendly\n- Provide accurate information\n- Reference: {{docs_url}}",
249
- value: J.templateText,
250
- onChange: (e) => Y({
251
- ...J,
252
- templateText: e.target.value
481
+ }),
482
+ /* @__PURE__ */ T("div", {
483
+ className: "flex items-center justify-between",
484
+ children: [/* @__PURE__ */ T("label", {
485
+ className: "flex items-center gap-2 text-sm",
486
+ htmlFor: `${n}-required`,
487
+ children: [/* @__PURE__ */ w("input", {
488
+ id: `${n}-required`,
489
+ type: "checkbox",
490
+ checked: e.required,
491
+ onChange: (e) => Z(t, { required: e.target.checked }),
492
+ className: "h-4 w-4"
493
+ }), P("botlit.promptTemplates.variables.required", "Required: a value or default must be given")]
494
+ }), /* @__PURE__ */ w(m, {
495
+ type: "button",
496
+ variant: "ghost",
497
+ size: "sm",
498
+ className: "text-status-error-text",
499
+ "aria-label": P("botlit.promptTemplates.variables.removeNamed", "Remove variable {{name}}", { name: e.name || String(t + 1) }),
500
+ onClick: () => Mt(t),
501
+ children: P("botlit.promptTemplates.variables.remove", "Remove")
502
+ })]
253
503
  })
254
- }), X.length > 0 && /* @__PURE__ */ w("div", {
255
- className: "mt-3 flex items-center gap-2",
256
- children: [/* @__PURE__ */ C("span", {
257
- className: "text-sm text-text-secondary",
258
- children: "Detected variables:"
259
- }), X.map((e) => /* @__PURE__ */ C(_, {
260
- variant: "secondary",
261
- className: "font-mono",
262
- children: e
263
- }, e))]
264
- })] })] }),
265
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ w(f, {
266
- className: "flex items-center justify-between",
267
- children: [/* @__PURE__ */ w("span", {
268
- className: "flex items-center gap-2",
269
- children: [/* @__PURE__ */ C(j, { size: 18 }), "Variables"]
270
- }), /* @__PURE__ */ C(p, {
271
- variant: "outline",
272
- size: "sm",
273
- onClick: Ne,
274
- children: "Add Variable"
275
- })]
276
- }), /* @__PURE__ */ C(u, { children: "Define the variables used in your template" })] }), /* @__PURE__ */ C(l, { children: J.variables.length > 0 ? /* @__PURE__ */ C("div", {
504
+ ]
505
+ }, t);
506
+ })
507
+ }) : /* @__PURE__ */ T("div", {
508
+ className: "py-6 text-center text-text-secondary",
509
+ children: [
510
+ /* @__PURE__ */ w(D, {
511
+ className: "mx-auto mb-2 h-8 w-8 opacity-50",
512
+ "aria-hidden": "true"
513
+ }),
514
+ /* @__PURE__ */ w("p", { children: P("botlit.promptTemplates.variables.empty", "No variables declared yet") }),
515
+ /* @__PURE__ */ w("p", {
516
+ className: "text-sm",
517
+ children: Ct.length > 0 ? P("botlit.promptTemplates.variables.emptyDetected", "The text uses {{count}} variable(s). Use \"Add detected variables\" to declare them.", { count: Ct.length }) : P("botlit.promptTemplates.variables.emptyHelp", "Write {{name}} in the text, then declare it here.", { name: "{{name}}" })
518
+ })
519
+ ]
520
+ })]
521
+ })] }), Wt = /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ T(p, {
522
+ className: "flex items-center gap-2",
523
+ children: [/* @__PURE__ */ w(Ie, {
524
+ size: 18,
525
+ "aria-hidden": "true"
526
+ }), P("botlit.promptTemplates.highlighted.title", "Template with variables highlighted")]
527
+ }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.highlighted.description", "The text as written; values are filled in when an agent, a skill or Prompt Studio uses it.") })] }), /* @__PURE__ */ w(u, { children: /* @__PURE__ */ w("div", {
528
+ className: "whitespace-pre-wrap break-words rounded-lg bg-bg-sunken p-4 font-mono text-sm",
529
+ children: /* @__PURE__ */ w(M, {
530
+ text: V.templateText,
531
+ emptyText: P("botlit.promptTemplates.highlighted.empty", "Enter template text...")
532
+ })
533
+ }) })] });
534
+ if (y) return /* @__PURE__ */ w(o, {
535
+ title: P("botlit.promptTemplates.createTitle", "Create Prompt Template"),
536
+ description: P("botlit.promptTemplates.createDescription", "Define a reusable prompt with variables"),
537
+ leading: /* @__PURE__ */ w(m, {
538
+ variant: "ghost",
539
+ size: "icon",
540
+ "aria-label": P("botlit.promptTemplates.back", "Back to prompt templates"),
541
+ onClick: () => void X("prompt-templates"),
542
+ children: /* @__PURE__ */ w(Ae, {
543
+ size: 20,
544
+ "aria-hidden": "true"
545
+ })
546
+ }),
547
+ actions: /* @__PURE__ */ T("div", {
548
+ className: "flex gap-2",
549
+ children: [/* @__PURE__ */ w(m, {
550
+ variant: "outline",
551
+ onClick: () => void X("prompt-templates"),
552
+ children: P("botlit.common.cancel", "Cancel")
553
+ }), /* @__PURE__ */ w(m, {
554
+ type: "submit",
555
+ form: "tpl-create-form",
556
+ leftIcon: /* @__PURE__ */ w(Be, { size: 16 }),
557
+ isLoading: Xe,
558
+ children: P("botlit.promptTemplates.createSubmit", "Create Template")
559
+ })]
560
+ }),
561
+ children: /* @__PURE__ */ T("form", {
562
+ id: "tpl-create-form",
563
+ noValidate: !0,
564
+ onSubmit: (e) => void Ot(e),
565
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
566
+ children: [/* @__PURE__ */ T("div", {
567
+ className: "space-y-6 lg:col-span-2",
568
+ children: [
569
+ zt,
570
+ /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.form.basics", "Basic information") }) }), /* @__PURE__ */ w(u, {
277
571
  className: "space-y-4",
278
- children: J.variables.map((e, t) => /* @__PURE__ */ w("div", {
279
- className: "p-4 border rounded-lg bg-bg-sunken/30 space-y-3",
280
- children: [/* @__PURE__ */ w("div", {
281
- className: "grid grid-cols-4 gap-3",
282
- children: [
283
- /* @__PURE__ */ C(m, {
284
- label: "Name",
285
- children: /* @__PURE__ */ C(h, {
286
- className: "font-mono",
287
- placeholder: "variable_name",
288
- value: e.name,
289
- onChange: (e) => Z(t, { name: e.target.value })
290
- })
291
- }),
292
- /* @__PURE__ */ C(m, {
293
- label: "Type",
294
- children: /* @__PURE__ */ C("select", {
295
- className: "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm",
296
- value: e.type,
297
- onChange: (e) => Z(t, { type: b(e.target.value, N, "string") }),
298
- children: N.map((e) => /* @__PURE__ */ C("option", {
299
- value: e,
300
- children: e
301
- }, e))
302
- })
303
- }),
304
- /* @__PURE__ */ C(m, {
305
- label: "Default Value",
306
- children: /* @__PURE__ */ C(h, {
307
- placeholder: "Optional",
308
- value: String(e.defaultValue || ""),
309
- onChange: (e) => Z(t, { defaultValue: e.target.value || void 0 })
310
- })
311
- }),
312
- /* @__PURE__ */ w("div", {
313
- className: "flex items-end gap-2",
314
- children: [/* @__PURE__ */ w("label", {
315
- className: "flex items-center gap-2 h-10",
316
- children: [/* @__PURE__ */ C("input", {
317
- type: "checkbox",
318
- checked: e.required,
319
- onChange: (e) => Z(t, { required: e.target.checked }),
320
- className: "h-4 w-4"
321
- }), /* @__PURE__ */ C("span", {
322
- className: "text-sm",
323
- children: "Required"
324
- })]
325
- }), /* @__PURE__ */ C(p, {
326
- variant: "ghost",
327
- size: "sm",
328
- className: "text-status-error-text",
329
- onClick: () => Pe(t),
330
- children: "Remove"
331
- })]
332
- })
333
- ]
334
- }), /* @__PURE__ */ C(m, {
335
- label: "Description",
336
- children: /* @__PURE__ */ C(h, {
337
- placeholder: "What is this variable for?",
338
- value: e.description || "",
339
- onChange: (e) => Z(t, { description: e.target.value })
340
- })
341
- })]
342
- }, t))
343
- }) : /* @__PURE__ */ w("div", {
344
- className: "text-center py-8 text-text-secondary",
345
- children: [
346
- /* @__PURE__ */ C(j, { className: "h-8 w-8 mx-auto mb-2 opacity-50" }),
347
- /* @__PURE__ */ C("p", { children: "No variables defined yet" }),
348
- /* @__PURE__ */ w("p", {
349
- className: "text-sm",
350
- children: [
351
- "Variables are automatically detected from ",
352
- "{{variable}}",
353
- " syntax"
354
- ]
355
- })
356
- ]
357
- }) })] })
572
+ children: Bt
573
+ })] }),
574
+ /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ T(p, {
575
+ className: "flex items-center gap-2",
576
+ children: [/* @__PURE__ */ w(Me, {
577
+ size: 18,
578
+ "aria-hidden": "true"
579
+ }), P("botlit.promptTemplates.form.contentTitle", "Template content")]
580
+ }) }), /* @__PURE__ */ w(u, { children: Vt })] }),
581
+ Ut
358
582
  ]
359
- }), /* @__PURE__ */ w("div", {
583
+ }), /* @__PURE__ */ T("div", {
360
584
  className: "space-y-6",
361
- children: [/* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ w(f, {
362
- className: "flex items-center gap-2",
363
- children: [/* @__PURE__ */ C(E, { size: 18 }), "Preview"]
364
- }) }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ C("div", {
365
- className: "p-4 bg-bg-sunken rounded-lg text-sm whitespace-pre-wrap font-mono",
366
- dangerouslySetInnerHTML: { __html: Be(J.templateText || "Enter template text...") }
367
- }) })] }), /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ C(f, { children: "Quick Tips" }) }), /* @__PURE__ */ w(l, {
368
- className: "text-sm space-y-2",
369
- children: [
370
- /* @__PURE__ */ w("p", { children: [
371
- /* @__PURE__ */ C("strong", { children: "Variables:" }),
372
- " Use ",
373
- "{{name}}",
374
- " syntax"
375
- ] }),
376
- /* @__PURE__ */ C("p", { children: /* @__PURE__ */ C("strong", { children: "Best Practices:" }) }),
377
- /* @__PURE__ */ w("ul", {
378
- className: "list-disc list-inside text-text-secondary space-y-1",
379
- children: [
380
- /* @__PURE__ */ C("li", { children: "Use descriptive variable names" }),
381
- /* @__PURE__ */ C("li", { children: "Provide default values when possible" }),
382
- /* @__PURE__ */ C("li", { children: "Include example inputs for testing" }),
383
- /* @__PURE__ */ C("li", { children: "Version your templates for changes" })
384
- ]
385
- })
386
- ]
585
+ children: [Wt, /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.tips.title", "How templates are used") }) }), /* @__PURE__ */ w(u, {
586
+ className: "space-y-2 text-sm text-text-secondary",
587
+ children: /* @__PURE__ */ T("ul", {
588
+ className: "list-inside list-disc space-y-1",
589
+ children: [
590
+ /* @__PURE__ */ w("li", { children: P("botlit.promptTemplates.tips.bind", "Bind it to an agent on the agent’s Prompt & skills tab, or give it to a skill.") }),
591
+ /* @__PURE__ */ w("li", { children: P("botlit.promptTemplates.tips.edits", "Saving a change updates every agent that uses the template at its next run.") }),
592
+ /* @__PURE__ */ w("li", { children: P("botlit.promptTemplates.tips.versions", "Use Prompt Studio to try a draft against a model and save it as a new version with history.") }),
593
+ /* @__PURE__ */ w("li", { children: P("botlit.promptTemplates.tips.defaults", "Give optional variables a default so the template works without them.") })
594
+ ]
595
+ })
387
596
  })] })]
388
597
  })]
389
598
  })
390
599
  });
391
- if (be) return /* @__PURE__ */ C(a, {
392
- title: "Loading...",
393
- children: /* @__PURE__ */ C("div", { className: "h-96 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" })
600
+ if (Ke && !I) return /* @__PURE__ */ w(o, {
601
+ title: P("botlit.common.loading", "Loading"),
602
+ children: /* @__PURE__ */ w("div", {
603
+ role: "status",
604
+ "aria-busy": "true",
605
+ "aria-label": P("botlit.common.loading", "Loading"),
606
+ className: "h-96 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer"
607
+ })
608
+ });
609
+ if (qe && !I) return /* @__PURE__ */ w(o, {
610
+ title: P("botlit.promptTemplates.title", "Prompt Templates"),
611
+ children: /* @__PURE__ */ w(te, {
612
+ resource: P("botlit.promptTemplates.resourceOne", "this prompt template"),
613
+ error: qe,
614
+ onRetry: () => void Je()
615
+ })
394
616
  });
395
- if (!I) return /* @__PURE__ */ C(a, {
396
- title: "Template Not Found",
397
- children: /* @__PURE__ */ C(te, {
617
+ if (!I) return /* @__PURE__ */ w(o, {
618
+ title: P("botlit.promptTemplates.notFound.title", "Template not found"),
619
+ children: /* @__PURE__ */ w(ee, {
398
620
  illustration: "empty-files",
399
- title: "Template Not Found",
400
- description: "This prompt template doesn't exist.",
401
- action: /* @__PURE__ */ C(p, {
621
+ title: P("botlit.promptTemplates.notFound.title", "Template not found"),
622
+ description: P("botlit.promptTemplates.notFound.description", "This prompt template does not exist or was deleted."),
623
+ action: /* @__PURE__ */ w(m, {
402
624
  onClick: () => F("prompt-templates"),
403
- children: "Back to Templates"
625
+ children: P("botlit.promptTemplates.back", "Back to prompt templates")
404
626
  })
405
627
  })
406
628
  });
407
- let Q = y(I), $ = v(I);
408
- return /* @__PURE__ */ C(a, {
409
- title: /* @__PURE__ */ w("div", {
410
- className: "flex items-center gap-3",
411
- children: [
412
- /* @__PURE__ */ C(p, {
413
- variant: "ghost",
414
- size: "icon",
415
- onClick: () => F("prompt-templates"),
416
- children: /* @__PURE__ */ C(pe, { size: 20 })
417
- }),
418
- /* @__PURE__ */ C("div", {
419
- className: "p-2 rounded-lg bg-action-primary-bg/10",
420
- children: /* @__PURE__ */ C(D, { className: "h-6 w-6 text-primary" })
421
- }),
422
- /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ w("div", {
423
- className: "flex items-center gap-2",
424
- children: [
425
- /* @__PURE__ */ C("span", { children: I.name }),
426
- /* @__PURE__ */ C(ne, { status: I.status }),
427
- /* @__PURE__ */ w(_, {
428
- variant: "secondary",
429
- className: "font-mono",
430
- children: ["v", I.version]
431
- })
432
- ]
433
- }), /* @__PURE__ */ w("p", {
434
- className: "text-sm font-normal text-text-secondary",
435
- children: [
436
- I.slug,
437
- " - ",
438
- I.description
439
- ]
440
- })] })
441
- ]
629
+ let Q = ae(I), $ = ie(I);
630
+ return /* @__PURE__ */ w(o, {
631
+ title: I.name,
632
+ leading: /* @__PURE__ */ w(m, {
633
+ variant: "ghost",
634
+ size: "icon",
635
+ "aria-label": P("botlit.promptTemplates.back", "Back to prompt templates"),
636
+ onClick: () => void X("prompt-templates"),
637
+ children: /* @__PURE__ */ w(Ae, {
638
+ size: 20,
639
+ "aria-hidden": "true"
640
+ })
641
+ }),
642
+ meta: /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(re, { status: I.status }), /* @__PURE__ */ T(_, {
643
+ variant: "secondary",
644
+ className: "font-mono",
645
+ children: ["v", I.version]
646
+ })] }),
647
+ description: /* @__PURE__ */ T("span", {
648
+ className: "font-mono",
649
+ children: [I.slug, I.description ? ` · ${I.description}` : ""]
442
650
  }),
443
651
  actions: /* @__PURE__ */ w("div", {
444
- className: "flex gap-2",
445
- children: [/* @__PURE__ */ C(p, {
446
- variant: "outline",
447
- leftIcon: C(z ? me : he, { size: 16 }),
448
- onClick: Ie,
449
- children: z ? "Copied!" : "Copy"
450
- }), K ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(p, {
652
+ className: "flex flex-wrap gap-2",
653
+ children: z ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(m, {
451
654
  variant: "outline",
452
- onClick: () => q(!1),
453
- children: "Cancel"
454
- }), /* @__PURE__ */ C(p, {
455
- leftIcon: /* @__PURE__ */ C(k, { size: 16 }),
456
- onClick: Re,
457
- isLoading: we,
458
- disabled: !J.name || !J.slug,
459
- children: "Save Changes"
460
- })] }) : Ae ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(p, {
461
- variant: "outline",
462
- onClick: () => je(!1),
463
- children: "Cancel"
464
- }), /* @__PURE__ */ C(p, {
465
- variant: "destructive",
466
- leftIcon: /* @__PURE__ */ C(A, { size: 16 }),
467
- onClick: () => {
468
- r("medium"), ze();
469
- },
470
- isLoading: Ee,
471
- children: "Confirm Delete"
472
- })] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(s, {
473
- permission: o.PROMPT_TEMPLATE_UPDATE,
474
- children: /* @__PURE__ */ C(p, {
475
- variant: "outline",
476
- leftIcon: /* @__PURE__ */ C(ge, { size: 16 }),
477
- onClick: Le,
478
- children: "Edit Template"
479
- })
480
- }), /* @__PURE__ */ C(s, {
481
- permission: o.PROMPT_TEMPLATE_DELETE,
482
- children: /* @__PURE__ */ C(p, {
655
+ onClick: () => void Et(),
656
+ children: P("botlit.common.cancel", "Cancel")
657
+ }), /* @__PURE__ */ w(m, {
658
+ type: "submit",
659
+ form: "tpl-edit-form",
660
+ leftIcon: /* @__PURE__ */ w(Be, { size: 16 }),
661
+ isLoading: Qe,
662
+ children: P("botlit.promptTemplates.save", "Save changes")
663
+ })] }) : /* @__PURE__ */ T(C, { children: [
664
+ /* @__PURE__ */ w(m, {
483
665
  variant: "outline",
484
- leftIcon: /* @__PURE__ */ C(A, { size: 16 }),
485
- onClick: () => je(!0),
486
- children: "Delete"
666
+ leftIcon: w(st ? je : Ne, { size: 16 }),
667
+ onClick: () => void Pt(),
668
+ children: st ? P("botlit.promptTemplates.copiedButton", "Copied!") : P("botlit.promptTemplates.copy", "Copy text")
669
+ }),
670
+ /* @__PURE__ */ w(c, {
671
+ permission: s.PROMPT_TEMPLATE_CREATE,
672
+ children: /* @__PURE__ */ w(m, {
673
+ variant: "outline",
674
+ leftIcon: /* @__PURE__ */ w(Pe, { size: 16 }),
675
+ onClick: () => void Lt(),
676
+ isLoading: it,
677
+ children: P("botlit.promptTemplates.duplicate.action", "Duplicate")
678
+ })
679
+ }),
680
+ /* @__PURE__ */ w(c, {
681
+ permission: s.PROMPT_TEMPLATE_UPDATE,
682
+ children: /* @__PURE__ */ w(m, {
683
+ variant: "outline",
684
+ leftIcon: /* @__PURE__ */ w(Fe, { size: 16 }),
685
+ onClick: Ft,
686
+ children: P("botlit.promptTemplates.edit", "Edit Template")
687
+ })
688
+ }),
689
+ /* @__PURE__ */ w(c, {
690
+ permission: s.PROMPT_TEMPLATE_DELETE,
691
+ children: /* @__PURE__ */ w(m, {
692
+ variant: "outline",
693
+ leftIcon: /* @__PURE__ */ w(He, { size: 16 }),
694
+ onClick: () => void Rt(),
695
+ isLoading: et || mt,
696
+ children: P("botlit.promptTemplates.delete.action", "Delete")
697
+ })
487
698
  })
488
- })] })]
699
+ ] })
489
700
  }),
490
- children: /* @__PURE__ */ w("div", {
701
+ children: /* @__PURE__ */ T("div", {
491
702
  className: "space-y-6",
492
703
  children: [
493
- /* @__PURE__ */ w(de, {
494
- icon: /* @__PURE__ */ C(D, { size: 18 }),
704
+ /* @__PURE__ */ w(Oe, {
705
+ icon: /* @__PURE__ */ w(Le, { size: 18 }),
706
+ children: P("botlit.promptTemplates.detailPurpose", "This is one reusable prompt template: its text with {{variables}}, its declared variables and example inputs. Agents bound to it and skills that carry it use the current text at their next run. To try a draft against a model or keep version history, open it in Prompt Studio.", { variables: "{{variables}}" })
707
+ }),
708
+ z && /* @__PURE__ */ T("form", {
709
+ id: "tpl-edit-form",
710
+ noValidate: !0,
711
+ onSubmit: (e) => void It(e),
712
+ className: "space-y-6",
495
713
  children: [
496
- "This is a single reusable prompt template — its content with",
497
- " ",
498
- /* @__PURE__ */ C("code", { children: "{{variables}}" }),
499
- ", its declared variables and example inputs, and its version history. Edit and preview it here to perfect the instructions, then reuse it across agents so they share consistent, version-controlled behaviour."
714
+ zt,
715
+ /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.editTitle", "Edit template") }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.editDescription", "Saving updates the template in place for every agent and skill that uses it. Prompt Studio saves a new version instead and keeps the old one.") })] }), /* @__PURE__ */ T(u, {
716
+ className: "space-y-4",
717
+ children: [Bt, Vt]
718
+ })] }),
719
+ Ut,
720
+ Wt
500
721
  ]
501
722
  }),
502
- K && /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ C(f, { children: "Edit Template" }), /* @__PURE__ */ C(u, { children: "Update template details and content" })] }), /* @__PURE__ */ w(l, {
503
- className: "space-y-4",
723
+ /* @__PURE__ */ T("div", {
724
+ className: "grid grid-cols-2 gap-4 md:grid-cols-4",
504
725
  children: [
505
- /* @__PURE__ */ w("div", {
506
- className: "grid grid-cols-2 gap-4",
507
- children: [/* @__PURE__ */ C(m, {
508
- label: "Template Name",
509
- required: !0,
510
- children: /* @__PURE__ */ C(h, {
511
- placeholder: "e.g., Technical Support Template",
512
- value: J.name,
513
- onChange: (e) => Y({
514
- ...J,
515
- name: e.target.value
516
- })
517
- })
518
- }), /* @__PURE__ */ C(m, {
519
- label: "Slug",
520
- required: !0,
521
- description: "Unique identifier (lowercase, dashes)",
522
- children: /* @__PURE__ */ C(h, {
523
- placeholder: "e.g., technical-support",
524
- value: J.slug,
525
- onChange: (e) => Y({
526
- ...J,
527
- slug: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, "-")
528
- })
529
- })
530
- })]
531
- }),
532
- /* @__PURE__ */ C(m, {
533
- label: "Description",
534
- children: /* @__PURE__ */ C(g, {
535
- placeholder: "What is this template used for?",
536
- value: J.description,
537
- onChange: (e) => Y({
538
- ...J,
539
- description: e.target.value
540
- }),
541
- rows: 2
542
- })
543
- }),
544
- /* @__PURE__ */ C(m, {
545
- label: "Visibility",
546
- children: /* @__PURE__ */ w("select", {
547
- className: "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm",
548
- value: J.visibility,
549
- onChange: (e) => Y({
550
- ...J,
551
- visibility: e.target.value
552
- }),
553
- children: [
554
- /* @__PURE__ */ C("option", {
555
- value: "PRIVATE",
556
- children: "Private"
557
- }),
558
- /* @__PURE__ */ C("option", {
559
- value: "WORKSPACE",
560
- children: "Workspace"
561
- }),
562
- /* @__PURE__ */ C("option", {
563
- value: "PUBLIC",
564
- children: "Public"
565
- })
566
- ]
567
- })
568
- }),
569
- /* @__PURE__ */ C(m, {
570
- label: "Template Content",
571
- description: "Use {{variable_name}} syntax for variables",
572
- children: /* @__PURE__ */ C(g, {
573
- className: "font-mono text-sm min-h-[200px]",
574
- value: J.templateText,
575
- onChange: (e) => Y({
576
- ...J,
577
- templateText: e.target.value
578
- })
579
- })
580
- }),
581
- X.length > 0 && /* @__PURE__ */ w("div", {
582
- className: "flex items-center gap-2",
583
- children: [/* @__PURE__ */ C("span", {
726
+ /* @__PURE__ */ w(l, { children: /* @__PURE__ */ T(u, {
727
+ className: "pt-6 text-center",
728
+ children: [/* @__PURE__ */ w("p", {
729
+ className: "text-3xl font-bold text-text-primary",
730
+ children: Q.length
731
+ }), /* @__PURE__ */ w("p", {
584
732
  className: "text-sm text-text-secondary",
585
- children: "Detected variables:"
586
- }), X.map((e) => /* @__PURE__ */ C(_, {
587
- variant: "secondary",
588
- className: "font-mono",
589
- children: e
590
- }, e))]
591
- })
592
- ]
593
- })] }),
594
- /* @__PURE__ */ w("div", {
595
- className: "grid grid-cols-2 md:grid-cols-4 gap-4",
596
- children: [
597
- /* @__PURE__ */ C(c, {
598
- treatment: "glass",
599
- glow: !0,
600
- children: /* @__PURE__ */ w(l, {
601
- className: "pt-6 text-center",
602
- children: [/* @__PURE__ */ C("p", {
603
- className: "text-3xl font-bold text-text-primary",
604
- children: Q.length
605
- }), /* @__PURE__ */ C("p", {
606
- className: "text-sm text-text-secondary",
607
- children: "Variables"
608
- })]
609
- })
610
- }),
611
- /* @__PURE__ */ C(c, { children: /* @__PURE__ */ w(l, {
733
+ children: P("botlit.promptTemplates.stats.variables", "Variables")
734
+ })]
735
+ }) }),
736
+ /* @__PURE__ */ w(l, { children: /* @__PURE__ */ T(u, {
612
737
  className: "pt-6 text-center",
613
- children: [/* @__PURE__ */ C("p", {
738
+ children: [/* @__PURE__ */ T("p", {
614
739
  className: "text-3xl font-bold text-text-primary",
615
- children: $.length
616
- }), /* @__PURE__ */ C("p", {
740
+ children: ["v", I.version]
741
+ }), /* @__PURE__ */ w("p", {
617
742
  className: "text-sm text-text-secondary",
618
- children: "Examples"
743
+ children: P("botlit.promptTemplates.stats.version", "Version (saved in Prompt Studio)")
619
744
  })]
620
745
  }) }),
621
- /* @__PURE__ */ C(c, { children: /* @__PURE__ */ w(l, {
746
+ /* @__PURE__ */ w(l, { children: /* @__PURE__ */ T(u, {
622
747
  className: "pt-6 text-center",
623
- children: [/* @__PURE__ */ C("p", {
748
+ children: [/* @__PURE__ */ w("p", {
624
749
  className: "text-3xl font-bold text-text-primary",
625
750
  children: I.revision
626
- }), /* @__PURE__ */ C("p", {
751
+ }), /* @__PURE__ */ w("p", {
627
752
  className: "text-sm text-text-secondary",
628
- children: "Revision"
753
+ children: P("botlit.promptTemplates.stats.revision", "Revision (every save)")
629
754
  })]
630
755
  }) }),
631
- /* @__PURE__ */ C(c, { children: /* @__PURE__ */ w(l, {
756
+ /* @__PURE__ */ w(l, { children: /* @__PURE__ */ T(u, {
632
757
  className: "pt-6 text-center",
633
- children: [/* @__PURE__ */ C("p", {
634
- className: "text-lg font-bold text-text-primary capitalize",
635
- children: I.visibility.toLowerCase()
636
- }), /* @__PURE__ */ C("p", {
758
+ children: [/* @__PURE__ */ w("p", {
759
+ className: "text-lg font-bold text-text-primary",
760
+ children: P(`botlit.promptTemplates.visibility.${I.visibility.toLowerCase()}`, I.visibility.charAt(0) + I.visibility.slice(1).toLowerCase())
761
+ }), /* @__PURE__ */ w("p", {
637
762
  className: "text-sm text-text-secondary",
638
- children: "Visibility"
763
+ children: P("botlit.promptTemplates.stats.visibility", "Visibility (not enforced yet)")
639
764
  })]
640
765
  }) })
641
766
  ]
642
767
  }),
643
768
  /* @__PURE__ */ w("div", {
644
769
  className: "flex gap-2 border-b",
770
+ role: "tablist",
771
+ "aria-label": P("botlit.promptTemplates.tabs.label", "Template views"),
645
772
  children: [
646
- /* @__PURE__ */ w(p, {
647
- variant: L === "edit" ? "default" : "ghost",
648
- onClick: () => R("edit"),
649
- children: [/* @__PURE__ */ C(T, { className: "h-4 w-4 mr-2" }), "Template"]
650
- }),
651
- /* @__PURE__ */ w(p, {
652
- variant: L === "preview" ? "default" : "ghost",
653
- onClick: () => R("preview"),
654
- children: [/* @__PURE__ */ C(E, { className: "h-4 w-4 mr-2" }), "Preview"]
655
- }),
656
- /* @__PURE__ */ w(p, {
657
- variant: L === "test" ? "default" : "ghost",
658
- onClick: () => R("test"),
659
- children: [/* @__PURE__ */ C(O, { className: "h-4 w-4 mr-2" }), "Test"]
660
- })
661
- ]
773
+ [
774
+ "edit",
775
+ /* @__PURE__ */ w(Me, {
776
+ className: "mr-2 h-4 w-4",
777
+ "aria-hidden": "true"
778
+ }, "i"),
779
+ P("botlit.promptTemplates.tabs.template", "Template")
780
+ ],
781
+ [
782
+ "preview",
783
+ /* @__PURE__ */ w(Ie, {
784
+ className: "mr-2 h-4 w-4",
785
+ "aria-hidden": "true"
786
+ }, "i"),
787
+ P("botlit.promptTemplates.tabs.preview", "Example values")
788
+ ],
789
+ [
790
+ "test",
791
+ /* @__PURE__ */ w(Re, {
792
+ className: "mr-2 h-4 w-4",
793
+ "aria-hidden": "true"
794
+ }, "i"),
795
+ P("botlit.promptTemplates.tabs.test", "Test render")
796
+ ]
797
+ ].map(([e, t, n]) => /* @__PURE__ */ T(m, {
798
+ id: `prompt-template-tab-${e}`,
799
+ role: "tab",
800
+ "aria-selected": L === e,
801
+ "aria-controls": `prompt-template-panel-${e}`,
802
+ variant: L === e ? "default" : "ghost",
803
+ onClick: () => ot(e),
804
+ children: [t, n]
805
+ }, e))
662
806
  }),
663
- L === "edit" && /* @__PURE__ */ w("div", {
664
- className: "grid grid-cols-1 lg:grid-cols-3 gap-6",
665
- children: [/* @__PURE__ */ C("div", {
807
+ L === "edit" && /* @__PURE__ */ T("div", {
808
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
809
+ role: "tabpanel",
810
+ id: "prompt-template-panel-edit",
811
+ "aria-labelledby": "prompt-template-tab-edit",
812
+ children: [/* @__PURE__ */ w("div", {
666
813
  className: "lg:col-span-2",
667
- children: /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ C(f, { children: "Template Content" }) }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ C("div", {
668
- className: "p-4 bg-bg-sunken rounded-lg font-mono text-sm whitespace-pre-wrap",
669
- children: /* @__PURE__ */ C("div", { dangerouslySetInnerHTML: { __html: Be(I.templateText) } })
814
+ children: /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.form.contentTitle", "Template content") }) }), /* @__PURE__ */ w(u, { children: /* @__PURE__ */ w("div", {
815
+ className: "whitespace-pre-wrap break-words rounded-lg bg-bg-sunken p-4 font-mono text-sm",
816
+ children: /* @__PURE__ */ w(M, { text: I.templateText })
670
817
  }) })] })
671
- }), /* @__PURE__ */ C("div", { children: /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ w(f, {
818
+ }), /* @__PURE__ */ w("div", { children: /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ T(p, {
672
819
  className: "flex items-center gap-2",
673
- children: [
674
- /* @__PURE__ */ C(j, { size: 18 }),
675
- "Variables (",
676
- Q.length,
677
- ")"
678
- ]
679
- }) }), /* @__PURE__ */ C(l, { children: Q.length > 0 ? /* @__PURE__ */ C("div", {
820
+ children: [/* @__PURE__ */ w(D, {
821
+ size: 18,
822
+ "aria-hidden": "true"
823
+ }), P("botlit.promptTemplates.variables.titleCount", "Variables ({{count}})", { count: Q.length })]
824
+ }) }), /* @__PURE__ */ w(u, { children: Q.length > 0 ? /* @__PURE__ */ w("ul", {
680
825
  className: "space-y-3",
681
- children: Q.map((e, t) => /* @__PURE__ */ w("div", {
682
- className: "p-3 border rounded-lg",
826
+ children: Q.map((e) => /* @__PURE__ */ T("li", {
827
+ className: "rounded-lg border p-3",
683
828
  children: [
684
- /* @__PURE__ */ w("div", {
685
- className: "flex items-center justify-between mb-1",
686
- children: [/* @__PURE__ */ C("span", {
829
+ /* @__PURE__ */ T("div", {
830
+ className: "mb-1 flex items-center justify-between",
831
+ children: [/* @__PURE__ */ w("span", {
687
832
  className: "font-mono font-medium",
688
833
  children: e.name
689
- }), /* @__PURE__ */ w("div", {
834
+ }), /* @__PURE__ */ T("div", {
690
835
  className: "flex gap-1",
691
- children: [/* @__PURE__ */ C(_, {
836
+ children: [/* @__PURE__ */ w(_, {
692
837
  variant: "outline",
693
838
  className: "text-xs",
694
839
  children: e.type
695
- }), e.required && /* @__PURE__ */ C(_, {
840
+ }), e.required && /* @__PURE__ */ w(_, {
696
841
  variant: "destructive",
697
842
  className: "text-xs",
698
- children: "required"
843
+ children: P("botlit.promptTemplates.variables.requiredBadge", "required")
699
844
  })]
700
845
  })]
701
846
  }),
702
- e.description && /* @__PURE__ */ C("p", {
847
+ e.description && /* @__PURE__ */ w("p", {
703
848
  className: "text-sm text-text-secondary",
704
849
  children: e.description
705
850
  }),
706
- e.defaultValue !== void 0 && /* @__PURE__ */ w("p", {
707
- className: "text-xs text-text-secondary mt-1",
851
+ e.defaultValue !== void 0 && /* @__PURE__ */ T("p", {
852
+ className: "mt-1 text-xs text-text-secondary",
708
853
  children: [
709
- "Default:",
854
+ P("botlit.promptTemplates.variables.defaultShown", "Default:"),
710
855
  " ",
711
- /* @__PURE__ */ C("code", {
856
+ /* @__PURE__ */ w("code", {
712
857
  className: "bg-bg-sunken px-1",
713
- children: String(e.defaultValue)
858
+ children: N(e.defaultValue)
714
859
  })
715
860
  ]
716
861
  })
717
862
  ]
718
- }, t))
719
- }) : /* @__PURE__ */ C("p", {
720
- className: "text-text-secondary text-center py-4",
721
- children: "No variables defined"
863
+ }, e.name))
864
+ }) : /* @__PURE__ */ w("p", {
865
+ className: "py-4 text-center text-text-secondary",
866
+ children: P("botlit.promptTemplates.variables.none", "No variables declared")
722
867
  }) })] }) })]
723
868
  }),
724
- L === "preview" && /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ C(f, { children: "Rendered Preview" }), /* @__PURE__ */ C(u, { children: "Preview with example inputs (first example set)" })] }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ C("div", {
725
- className: "p-4 bg-bg-sunken rounded-lg font-mono text-sm whitespace-pre-wrap",
726
- children: $[0] ? I.templateText.replace(/\{\{(\w+)\}\}/g, (e, t) => {
727
- let n = $[0][t];
728
- return n === void 0 ? `{{${t}}}` : String(n);
729
- }) : /* @__PURE__ */ C("span", {
730
- className: "text-text-secondary",
731
- children: "No example inputs defined. Add examples to preview rendered output."
732
- })
733
- }) })] }),
734
- L === "test" && /* @__PURE__ */ w("div", {
735
- className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
736
- children: [/* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ C(f, { children: "Test Inputs" }), /* @__PURE__ */ C(u, { children: "Enter values to test the template" })] }), /* @__PURE__ */ w(l, {
869
+ L === "preview" && /* @__PURE__ */ T(l, {
870
+ role: "tabpanel",
871
+ id: "prompt-template-panel-preview",
872
+ "aria-labelledby": "prompt-template-tab-preview",
873
+ children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.preview.title", "Filled with the first example input") }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.preview.description", "Placeholders without an example value stay as written. Use Test render to check required values and types.") })] }), /* @__PURE__ */ w(u, { children: /* @__PURE__ */ w("div", {
874
+ className: "whitespace-pre-wrap break-words rounded-lg bg-bg-sunken p-4 font-mono text-sm",
875
+ children: $[0] ? be(I.templateText, $[0]) : /* @__PURE__ */ w("span", {
876
+ className: "text-text-secondary",
877
+ children: P("botlit.promptTemplates.preview.none", "This template has no example inputs. Use Test render to fill it with your own values.")
878
+ })
879
+ }) })]
880
+ }),
881
+ L === "test" && /* @__PURE__ */ T("div", {
882
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-2",
883
+ role: "tabpanel",
884
+ id: "prompt-template-panel-test",
885
+ "aria-labelledby": "prompt-template-tab-test",
886
+ children: [/* @__PURE__ */ T(l, { children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.test.inputs", "Test inputs") }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.test.description", "Fill in values to see the prompt exactly as the server builds it. Nothing is sent to a model; Prompt Studio does that.") })] }), /* @__PURE__ */ T(u, {
737
887
  className: "space-y-4",
738
- children: [Q.map((e) => /* @__PURE__ */ w(m, {
888
+ children: [Q.map((e) => /* @__PURE__ */ w(h, {
739
889
  label: e.name,
890
+ htmlFor: `tpl-test-${e.name}`,
740
891
  required: e.required,
741
- children: [/* @__PURE__ */ C(h, {
742
- placeholder: e.defaultValue ? String(e.defaultValue) : `Enter ${e.name}`,
743
- value: V[e.name] || "",
744
- onChange: (t) => ke({
745
- ...V,
892
+ description: e.description,
893
+ children: /* @__PURE__ */ w(g, {
894
+ id: `tpl-test-${e.name}`,
895
+ maxLength: 1e4,
896
+ placeholder: e.defaultValue === void 0 ? P("botlit.promptTemplates.test.enter", "Enter {{name}}", { name: e.name }) : N(e.defaultValue),
897
+ value: R[e.name] || "",
898
+ onChange: (t) => lt({
899
+ ...R,
746
900
  [e.name]: t.target.value
747
901
  })
748
- }), e.description && /* @__PURE__ */ C("p", {
749
- className: "text-xs text-text-secondary mt-1",
750
- children: e.description
751
- })]
752
- }, e.name)), /* @__PURE__ */ C(s, {
753
- permission: o.PROMPT_TEMPLATE_EXECUTE,
754
- children: /* @__PURE__ */ C(p, {
902
+ })
903
+ }, e.name)), /* @__PURE__ */ w(c, {
904
+ permission: s.PROMPT_TEMPLATE_EXECUTE,
905
+ children: /* @__PURE__ */ w(m, {
755
906
  className: "w-full",
756
- leftIcon: /* @__PURE__ */ C(O, { size: 16 }),
757
- onClick: Fe,
758
- isLoading: Oe,
759
- children: "Render Template"
907
+ leftIcon: /* @__PURE__ */ w(Re, { size: 16 }),
908
+ onClick: () => void Nt(),
909
+ isLoading: nt,
910
+ children: P("botlit.promptTemplates.test.render", "Render template")
760
911
  })
761
912
  })]
762
- })] }), /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ C(f, { children: "Output" }) }), /* @__PURE__ */ C(l, { children: W ? /* @__PURE__ */ C("div", {
913
+ })] }), /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.test.output", "Output") }) }), /* @__PURE__ */ w(u, { children: ft ? /* @__PURE__ */ w("div", {
763
914
  role: "alert",
764
915
  className: "flex items-start gap-2 rounded-lg border border-status-error-border/40 bg-status-error-bg/10 px-3 py-2 text-sm text-status-error-text",
765
- children: /* @__PURE__ */ C("p", { children: W })
766
- }) : H ? /* @__PURE__ */ C("div", {
767
- className: "p-4 bg-bg-sunken rounded-lg font-mono text-sm whitespace-pre-wrap",
768
- children: H
769
- }) : /* @__PURE__ */ w("div", {
916
+ children: /* @__PURE__ */ w("p", { children: ft })
917
+ }) : ut === null ? /* @__PURE__ */ T("div", {
770
918
  className: "p-8 text-center text-text-secondary",
771
- children: [/* @__PURE__ */ C(O, { className: "h-8 w-8 mx-auto mb-2 opacity-50" }), /* @__PURE__ */ C("p", { children: "Enter inputs and click \"Render Template\" to see output" })]
919
+ children: [/* @__PURE__ */ w(Re, {
920
+ className: "mx-auto mb-2 h-8 w-8 opacity-50",
921
+ "aria-hidden": "true"
922
+ }), /* @__PURE__ */ w("p", { children: P("botlit.promptTemplates.test.empty", "Enter values and choose Render template to see the output.") })]
923
+ }) : /* @__PURE__ */ w("div", {
924
+ className: "whitespace-pre-wrap break-words rounded-lg bg-bg-sunken p-4 font-mono text-sm",
925
+ children: ut
772
926
  }) })] })]
773
927
  }),
774
- $.length > 0 && L === "edit" && /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(d, { children: [/* @__PURE__ */ C(f, { children: "Example Inputs" }), /* @__PURE__ */ C(u, { children: "Pre-defined inputs for testing and documentation" })] }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ C("div", {
775
- className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",
776
- children: $.map((e, t) => /* @__PURE__ */ w("div", {
777
- className: "p-4 border rounded-lg bg-bg-sunken/30",
928
+ $.length > 0 && L === "edit" && /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ T(f, { children: [/* @__PURE__ */ w(p, { children: P("botlit.promptTemplates.examples.title", "Example inputs") }), /* @__PURE__ */ w(d, { children: P("botlit.promptTemplates.examples.description", "Sample values for documentation and the Example values tab") })] }), /* @__PURE__ */ w(u, { children: /* @__PURE__ */ w("div", {
929
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",
930
+ children: $.map((e, t) => /* @__PURE__ */ T("div", {
931
+ className: "rounded-lg border bg-bg-sunken/30 p-4",
778
932
  children: [/* @__PURE__ */ w("p", {
779
- className: "text-sm font-medium mb-2",
780
- children: ["Example ", t + 1]
781
- }), /* @__PURE__ */ C("div", {
933
+ className: "mb-2 text-sm font-medium",
934
+ children: P("botlit.promptTemplates.examples.item", "Example {{number}}", { number: t + 1 })
935
+ }), /* @__PURE__ */ w("div", {
782
936
  className: "space-y-1 text-sm",
783
- children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ w("div", {
937
+ children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ T("div", {
784
938
  className: "flex justify-between",
785
- children: [/* @__PURE__ */ w("span", {
939
+ children: [/* @__PURE__ */ T("span", {
786
940
  className: "font-mono text-text-secondary",
787
941
  children: [e, ":"]
788
- }), /* @__PURE__ */ C("span", {
789
- className: "font-mono truncate max-w-[60%]",
790
- children: String(t)
942
+ }), /* @__PURE__ */ w("span", {
943
+ className: "max-w-[60%] truncate font-mono",
944
+ children: N(t)
791
945
  })]
792
946
  }, e))
793
947
  })]
794
948
  }, t))
795
949
  }) })] }),
796
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(d, { children: /* @__PURE__ */ w(f, {
950
+ /* @__PURE__ */ T(l, { children: [/* @__PURE__ */ w(f, { children: /* @__PURE__ */ T(p, {
797
951
  className: "flex items-center gap-2",
798
- children: [/* @__PURE__ */ C(_e, { size: 18 }), "Metadata"]
799
- }) }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ w("div", {
800
- className: "grid grid-cols-2 md:grid-cols-4 gap-6 text-sm",
952
+ children: [/* @__PURE__ */ w(Ve, {
953
+ size: 18,
954
+ "aria-hidden": "true"
955
+ }), P("botlit.promptTemplates.metadata.title", "Details")]
956
+ }) }), /* @__PURE__ */ w(u, { children: /* @__PURE__ */ T("dl", {
957
+ className: "grid grid-cols-2 gap-6 text-sm md:grid-cols-4",
801
958
  children: [
802
- /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
959
+ /* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("dt", {
803
960
  className: "text-text-secondary",
804
- children: "Created"
805
- }), /* @__PURE__ */ C("p", {
961
+ children: P("botlit.promptTemplates.metadata.created", "Created")
962
+ }), /* @__PURE__ */ w("dd", {
806
963
  className: "font-medium",
807
- children: ce(I.createdAt)
964
+ children: he(I.createdAt)
808
965
  })] }),
809
- /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
966
+ /* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("dt", {
810
967
  className: "text-text-secondary",
811
- children: "Updated"
812
- }), /* @__PURE__ */ C("p", {
968
+ children: P("botlit.promptTemplates.metadata.updated", "Updated")
969
+ }), /* @__PURE__ */ w("dd", {
813
970
  className: "font-medium",
814
- children: ce(I.updatedAt)
971
+ children: he(I.updatedAt)
815
972
  })] }),
816
- /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
973
+ /* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("dt", {
817
974
  className: "text-text-secondary",
818
- children: "Tags"
819
- }), /* @__PURE__ */ C("div", {
820
- className: "flex gap-1",
821
- children: I.tags.length > 0 ? I.tags.map((e) => /* @__PURE__ */ C(_, {
975
+ children: P("botlit.promptTemplates.metadata.tags", "Tags")
976
+ }), /* @__PURE__ */ w("dd", {
977
+ className: "flex flex-wrap gap-1",
978
+ children: I.tags.length > 0 ? I.tags.map((e) => /* @__PURE__ */ w(_, {
822
979
  variant: "secondary",
823
980
  className: "text-xs",
824
981
  children: e
825
- }, e)) : /* @__PURE__ */ C("span", {
982
+ }, e)) : /* @__PURE__ */ w("span", {
826
983
  className: "text-text-secondary",
827
- children: "None"
984
+ children: P("botlit.promptTemplates.metadata.noTags", "None")
828
985
  })
829
- })] })
986
+ })] }),
987
+ /* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("dt", {
988
+ className: "text-text-secondary",
989
+ children: P("botlit.promptTemplates.metadata.studio", "Versions")
990
+ }), /* @__PURE__ */ w("dd", { children: /* @__PURE__ */ w(m, {
991
+ variant: "ghost",
992
+ size: "sm",
993
+ className: "px-0",
994
+ onClick: () => void X("prompts"),
995
+ children: P("botlit.promptTemplates.metadata.openStudio", "Open Prompt Studio")
996
+ }) })] })
830
997
  ]
831
998
  }) })] })
832
999
  ]
833
1000
  })
834
1001
  });
835
1002
  };
836
- export { P as PromptTemplateDetailPage };
1003
+ export { M as HighlightedTemplate, P as PromptTemplateDetailPage };
837
1004
 
838
1005
  //# sourceMappingURL=PromptTemplateDetailPage.js.map