@epam/ai-dial-skill-editor 1.2.0-dev.14 → 1.2.0-dev.141

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.
package/index.js CHANGED
@@ -1,84 +1,97 @@
1
- import { MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME as e, MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME as t, buildCssVars as n, formatFileSize as r, mergeClasses as i, useAvailableHeightCap as a } from "@epam/ai-dial-chat-shared";
2
- import { Accordion as o, CaptionText as s, DIAL_ICON_SIZE as c, DIAL_KIT_ICON_STROKE as l, EditorThemes as u, ErrorText as d, FileDropzone as f, GhostButton as ee, GhostIconButton as te, Input as p, NeutralButton as m, Popup as ne, PopupSize as re, PrimaryButton as ie, Spinner as h, Textarea as g } from "@epam/ai-dial-ui-kit";
3
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
4
- import { IconArrowNarrowLeft as b, IconFileText as ae, IconPlus as oe, IconTrashX as se, IconUpload as x } from "@tabler/icons-react";
5
- import { Suspense as S, lazy as C, useCallback as w, useEffect as T, useId as E, useMemo as D, useRef as O, useState as k } from "react";
6
- import { DialFileNodeType as A, DialFoldersTree as ce } from "@epam/ai-dial-react-file-manager";
7
- import { LazyMarkdownEditor as j } from "@epam/ai-dial-ui-kit/editors";
8
- var M = {
1
+ import { MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME as e, MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME as t, TextRefinementField as n, buildCssVars as r, formatFileSize as i, mergeClasses as a, useAvailableHeightCap as o, useTextRefinement as s } from "@epam/ai-dial-chat-shared";
2
+ import { Accordion as c, CaptionText as l, DIAL_ICON_SIZE as u, DIAL_KIT_ICON_STROKE as d, EditorThemes as f, ErrorText as p, FileDropzone as m, GhostButton as h, GhostIconButton as ee, Input as g, Label as te, NeutralButton as _, Popup as ne, PopupSize as re, PrimaryButton as ie, Spinner as v, Textarea as ae } from "@epam/ai-dial-ui-kit";
3
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
4
+ import { IconArrowNarrowLeft as S, IconFileText as C, IconPlus as oe, IconTrashX as se, IconUpload as w } from "@tabler/icons-react";
5
+ import { Suspense as ce, lazy as T, useCallback as E, useEffect as D, useId as O, useMemo as k, useRef as A, useState as j } from "react";
6
+ import { DialFileNodeType as M, DialFoldersTree as le } from "@epam/ai-dial-react-file-manager";
7
+ import { LazyMarkdownEditor as ue } from "@epam/ai-dial-ui-kit/editors";
8
+ a("flex flex-col", {
9
+ body: "_body_m2y60_2",
10
+ sideColumn: "_sideColumn_m2y60_6",
11
+ reservedColumn: "_reservedColumn_m2y60_10"
12
+ }.sideColumn);
13
+ //#endregion
14
+ //#region ../builder-form/src/constants/public-class-names.ts
15
+ var de = {
16
+ layout: "dial-builder-form-layout",
17
+ section: "dial-builder-form-section"
18
+ }, N = {
9
19
  headerBorder: "_headerBorder_1kidu_1",
10
20
  footerBorder: "_footerBorder_1kidu_5",
11
21
  sidebarBorder: "_sidebarBorder_1kidu_9"
12
- }, N = ({ title: e, onBack: t, backAriaLabel: r = "Back", actions: a, leftContent: o, rightContent: s, isSaving: u = !1, labels: d, styles: f, dir: ee }) => {
13
- let p = E(), m = u ? d?.savingStatusLabel ?? "Saving" : "";
14
- return /* @__PURE__ */ y("div", {
15
- dir: ee,
16
- className: "flex min-h-0 flex-1 flex-col",
17
- style: n({
18
- "--el-header-border-color": f?.colors?.headerBorderColor,
19
- "--el-sidebar-border-color": f?.colors?.sidebarBorderColor
20
- }),
22
+ }, fe = ({ title: e, onBack: t, backAriaLabel: n = "Back", actions: i, leftContent: o, rightContent: s, isSaving: c = !1, labels: l, styles: f, dir: p }) => {
23
+ let m = O(), h = c ? l?.savingStatusLabel ?? "Saving" : "", g = r({
24
+ "--el-header-border-color": f?.colors?.headerBorderColor,
25
+ "--el-sidebar-border-color": f?.colors?.sidebarBorderColor
26
+ });
27
+ return /* @__PURE__ */ x("div", {
28
+ dir: p,
29
+ className: a("flex min-h-0 flex-1 flex-col", de.layout),
30
+ style: g,
21
31
  children: [
22
- /* @__PURE__ */ v("span", {
32
+ /* @__PURE__ */ b("span", {
23
33
  role: "status",
24
34
  "aria-live": "polite",
25
35
  className: "sr-only",
26
- id: p,
27
- children: m
36
+ id: m,
37
+ children: h
28
38
  }),
29
- /* @__PURE__ */ y("div", {
30
- className: i("flex items-center justify-between gap-2 border-b px-4 py-2 desktop:px-8 desktop:pb-3 desktop:pt-3", M.headerBorder),
31
- children: [/* @__PURE__ */ y("div", {
39
+ /* @__PURE__ */ x("div", {
40
+ className: a("flex items-center justify-between gap-2 border-b px-4 py-2 desktop:px-8 desktop:pb-3 desktop:pt-3", N.headerBorder),
41
+ children: [/* @__PURE__ */ x("div", {
32
42
  className: "flex min-w-0 flex-1 items-center gap-2",
33
- children: [/* @__PURE__ */ v(te, {
34
- icon: /* @__PURE__ */ v(b, {
35
- size: c.LG,
36
- stroke: l,
43
+ children: [/* @__PURE__ */ b(ee, {
44
+ icon: /* @__PURE__ */ b(S, {
45
+ size: u.LG,
46
+ stroke: d,
37
47
  "aria-hidden": !0,
38
48
  className: "rtl:scale-x-[-1]"
39
49
  }),
40
- "aria-label": r,
50
+ "aria-label": n,
41
51
  onClick: t
42
- }), /* @__PURE__ */ v("h1", {
52
+ }), /* @__PURE__ */ b("h1", {
43
53
  className: "dial-h2-text min-w-0 truncate",
44
54
  children: e
45
55
  })]
46
- }), a != null && /* @__PURE__ */ v("div", {
56
+ }), i != null && /* @__PURE__ */ b("div", {
47
57
  className: "hidden shrink-0 items-center gap-2 desktop:flex",
48
- children: a
58
+ children: i
49
59
  })]
50
60
  }),
51
- /* @__PURE__ */ y("div", {
61
+ /* @__PURE__ */ x("div", {
52
62
  className: "flex flex-1 flex-col overflow-y-auto desktop:flex-row desktop:overflow-hidden",
53
- children: [/* @__PURE__ */ v("div", {
54
- className: i(s == null ? "desktop:flex-1" : "desktop:w-[360px] desktop:shrink-0 desktop:overflow-y-auto desktop:border-e", "desktop:overflow-y-auto", s == null ? void 0 : M.sidebarBorder),
63
+ children: [/* @__PURE__ */ b("div", {
64
+ className: a(s == null ? "desktop:flex-1" : "desktop:w-[360px] desktop:shrink-0 desktop:overflow-y-auto desktop:border-e", "desktop:overflow-y-auto", s == null ? void 0 : N.sidebarBorder),
55
65
  children: o
56
- }), s != null && /* @__PURE__ */ v("div", {
66
+ }), s != null && /* @__PURE__ */ b("div", {
57
67
  className: "desktop:flex-1 desktop:overflow-y-auto",
58
68
  children: s
59
69
  })]
60
70
  }),
61
- a != null && /* @__PURE__ */ v("div", {
62
- className: i("flex shrink-0 flex-row-reverse items-center gap-2 border-t px-4 py-2 desktop:hidden [&>*]:flex-1", M.footerBorder),
63
- children: a
71
+ i != null && /* @__PURE__ */ b("div", {
72
+ className: a("flex shrink-0 flex-row-reverse items-center gap-2 border-t px-4 py-2 desktop:hidden [&>*]:flex-1", N.footerBorder),
73
+ children: i
64
74
  })
65
75
  ]
66
76
  });
67
- }, P = (e) => !!e.dataTransfer?.types.includes("Files"), le = (e) => {
68
- let [t, n] = k(!1), r = O(0);
77
+ }, pe = {
78
+ root: "dial-skill-editor-root",
79
+ refineFeedback: "dial-skill-editor-refine-feedback"
80
+ }, P = (e) => !!e.dataTransfer?.types.includes("Files"), me = (e) => {
81
+ let [t, n] = j(!1), r = A(0);
69
82
  return {
70
83
  isDragActive: t,
71
84
  dropZoneHandlers: {
72
- onDragEnter: w((e) => {
85
+ onDragEnter: E((e) => {
73
86
  P(e) && (e.preventDefault(), r.current += 1, n(!0));
74
87
  }, []),
75
- onDragLeave: w((e) => {
88
+ onDragLeave: E((e) => {
76
89
  P(e) && (--r.current, r.current <= 0 && (r.current = 0, n(!1)));
77
90
  }, []),
78
- onDragOver: w((e) => {
91
+ onDragOver: E((e) => {
79
92
  P(e) && e.preventDefault();
80
93
  }, []),
81
- onDrop: w((t) => {
94
+ onDrop: E((t) => {
82
95
  if (!P(t)) return;
83
96
  t.preventDefault(), r.current = 0, n(!1);
84
97
  let i = Array.from(t.dataTransfer?.files ?? []);
@@ -91,17 +104,17 @@ var M = {
91
104
  }({}), L = (e) => {
92
105
  let t = e.lastIndexOf("/");
93
106
  return t === -1 ? null : e.slice(0, t);
94
- }, R = (e) => {
107
+ }, he = (e) => {
95
108
  let t = e.lastIndexOf("/");
96
109
  return t === -1 ? e : e.slice(t + 1);
97
- }, ue = (e) => {
110
+ }, ge = (e) => {
98
111
  let t = /* @__PURE__ */ new Map(), n = (e) => {
99
112
  let n = t.get(e);
100
113
  if (n) return n;
101
114
  let r = {
102
115
  path: e,
103
- name: R(e),
104
- nodeType: A.FOLDER,
116
+ name: he(e),
117
+ nodeType: M.FOLDER,
105
118
  parentPath: L(e),
106
119
  folderId: e,
107
120
  items: []
@@ -116,7 +129,7 @@ var M = {
116
129
  t.set(r.path, {
117
130
  path: r.path,
118
131
  name: r.name,
119
- nodeType: A.ITEM,
132
+ nodeType: M.ITEM,
120
133
  parentPath: L(r.path),
121
134
  folderId: L(r.path) ?? ""
122
135
  });
@@ -135,74 +148,74 @@ var M = {
135
148
  n ? n.items = [...n.items ?? [], e] : r.push(e);
136
149
  }
137
150
  return r;
138
- }, de = ({ isVisible: e, labels: t }) => {
151
+ }, _e = ({ isVisible: e, labels: t }) => {
139
152
  if (!e) return null;
140
153
  let n = t ?? {};
141
- return /* @__PURE__ */ v("div", {
154
+ return /* @__PURE__ */ b("div", {
142
155
  role: "status",
143
156
  "aria-live": "polite",
144
- className: i("pointer-events-none absolute inset-0 z-[100] flex items-center justify-center backdrop-blur-sm"),
145
- children: /* @__PURE__ */ y("div", {
157
+ className: a("pointer-events-none absolute inset-0 z-[100] flex items-center justify-center backdrop-blur-sm"),
158
+ children: /* @__PURE__ */ x("div", {
146
159
  className: "flex flex-col items-center text-center",
147
160
  children: [
148
- /* @__PURE__ */ v(x, {
161
+ /* @__PURE__ */ b(w, {
149
162
  size: 100,
150
163
  className: "text-accent-primary",
151
164
  "aria-hidden": !0,
152
- stroke: l
165
+ stroke: d
153
166
  }),
154
- /* @__PURE__ */ v("span", {
167
+ /* @__PURE__ */ b("span", {
155
168
  className: "dial-h3-text mt-5",
156
169
  children: n.dropOverlayTitle ?? "Upload files"
157
170
  }),
158
- /* @__PURE__ */ v("span", {
171
+ /* @__PURE__ */ b("span", {
159
172
  className: "dial-small-text mt-4",
160
173
  children: n.dropOverlaySubtitle ?? "Drop files here to add them to this skill"
161
174
  })
162
175
  ]
163
176
  })
164
177
  });
165
- }, fe = /* @__PURE__ */ function(e) {
178
+ }, R = /* @__PURE__ */ function(e) {
166
179
  return e.SupportingFile = "supporting-file", e.Manifest = "manifest", e;
167
180
  }({}), z = /* @__PURE__ */ function(e) {
168
181
  return e.Valid = "valid", e.Invalid = "invalid", e;
169
- }({}), B = (e) => (e.webkitRelativePath || e.name).replace(/\\/g, "/"), V = 0, H = () => `skill-file-candidate-${++V}`, pe = ({ isOpen: e, onClose: t, fileActions: n, initialFiles: i, labels: a }) => {
170
- let o = a ?? {}, [s, c] = k([]), [u, p] = k(/* @__PURE__ */ new Map()), [m, g] = k([]), [b, oe] = k(!1), [x, S] = k(), [C, w] = k(!1), D = E(), O = (e) => {
182
+ }({}), B = (e) => (e.webkitRelativePath || e.name).replace(/\\/g, "/"), ve = 0, ye = () => `skill-file-candidate-${++ve}`, be = ({ isOpen: e, onClose: t, fileActions: n, initialFiles: r, labels: a }) => {
183
+ let o = a ?? {}, [s, c] = j([]), [l, u] = j(/* @__PURE__ */ new Map()), [f, g] = j([]), [te, _] = j(!1), [ae, S] = j(), [oe, w] = j(!1), ce = O(), T = (e) => {
171
184
  let t = e.map((e) => ({
172
- id: H(),
185
+ id: ye(),
173
186
  file: e,
174
187
  path: B(e)
175
188
  }));
176
189
  S(void 0), c((e) => [...e, ...t]);
177
- }, A = (e) => {
190
+ }, E = (e) => {
178
191
  c((t) => t.filter((t) => t.id !== e));
179
192
  };
180
- T(() => {
181
- e && (c((i ?? []).map((e) => ({
182
- id: H(),
193
+ D(() => {
194
+ e && (c((r ?? []).map((e) => ({
195
+ id: ye(),
183
196
  file: e,
184
197
  path: B(e)
185
- }))), p(/* @__PURE__ */ new Map()), g([]), S(void 0));
186
- }, [e]), T(() => {
198
+ }))), u(/* @__PURE__ */ new Map()), g([]), S(void 0));
199
+ }, [e]), D(() => {
187
200
  if (!e) return;
188
201
  let t = !1;
189
202
  if (s.length === 0) {
190
- p(/* @__PURE__ */ new Map()), g([]);
203
+ u(/* @__PURE__ */ new Map()), g([]);
191
204
  return;
192
205
  }
193
- return oe(!0), n.validateBatch(s).then(({ results: e, batchErrors: n }) => {
194
- t || (p(new Map(e.map((e) => [e.candidateId, e]))), g(n.map((e) => e.message)));
206
+ return _(!0), n.validateBatch(s).then(({ results: e, batchErrors: n }) => {
207
+ t || (u(new Map(e.map((e) => [e.candidateId, e]))), g(n.map((e) => e.message)));
195
208
  }).finally(() => {
196
- t || oe(!1);
209
+ t || _(!1);
197
210
  }), () => {
198
211
  t = !0;
199
212
  };
200
213
  }, [s, e]);
201
- let ce = s.some((e) => u.get(e.id)?.status === z.Invalid), j = s.length > 0 && s.every((e) => u.get(e.id)?.status === z.Invalid), M = s.length > 0 && !ce && m.length === 0 && !b && !C, N = async () => {
214
+ let k = s.some((e) => l.get(e.id)?.status === z.Invalid), A = s.length > 0 && s.every((e) => l.get(e.id)?.status === z.Invalid), M = s.length > 0 && !k && f.length === 0 && !te && !oe, le = async () => {
202
215
  w(!0), S(void 0);
203
216
  try {
204
217
  let { results: e, batchErrors: r } = await n.validateBatch(s), i = new Map(e.map((e) => [e.candidateId, e]));
205
- if (p(i), g(r.map((e) => e.message)), s.some((e) => i.get(e.id)?.status === z.Invalid) || r.length > 0) return;
218
+ if (u(i), g(r.map((e) => e.message)), s.some((e) => i.get(e.id)?.status === z.Invalid) || r.length > 0) return;
206
219
  let a = await n.commitBatch(s);
207
220
  if (a.error) {
208
221
  S(a.error);
@@ -213,384 +226,447 @@ var M = {
213
226
  w(!1);
214
227
  }
215
228
  };
216
- return /* @__PURE__ */ v(ne, {
229
+ return /* @__PURE__ */ b(ne, {
217
230
  open: e,
218
231
  header: o.uploadDialogTitle ?? "Upload files from device",
219
232
  size: re.Sm,
220
233
  closeAriaLabel: o.uploadDialogCloseAriaLabel ?? "Close",
221
234
  onClose: t,
222
- footer: /* @__PURE__ */ y("div", {
235
+ footer: /* @__PURE__ */ x("div", {
223
236
  className: "flex min-h-[44px] items-center justify-end gap-2 px-6 py-4",
224
- children: [/* @__PURE__ */ v(ee, {
237
+ children: [/* @__PURE__ */ b(h, {
225
238
  label: o.uploadCancelLabel ?? "Cancel",
226
239
  onClick: t
227
- }), /* @__PURE__ */ v(ie, {
240
+ }), /* @__PURE__ */ b(ie, {
228
241
  label: o.uploadConfirmLabel ?? "Add",
229
- iconBefore: C ? /* @__PURE__ */ v(h, {
242
+ iconBefore: oe ? /* @__PURE__ */ b(v, {
230
243
  size: 16,
231
244
  ariaLabel: ""
232
245
  }) : void 0,
233
- onClick: () => void N(),
246
+ onClick: () => void le(),
234
247
  disabled: !M
235
248
  })]
236
249
  }),
237
- children: /* @__PURE__ */ y("div", {
250
+ children: /* @__PURE__ */ x("div", {
238
251
  className: "flex flex-col gap-4 px-6 py-4",
239
252
  children: [
240
- /* @__PURE__ */ v(f, {
241
- label: /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("span", {
253
+ /* @__PURE__ */ b(m, {
254
+ label: /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("span", {
242
255
  className: "desktop:hidden",
243
256
  children: o.uploadDropZoneMobileLabel ?? "Click here to upload"
244
- }), /* @__PURE__ */ v("span", {
257
+ }), /* @__PURE__ */ b("span", {
245
258
  className: "hidden desktop:inline",
246
259
  children: o.uploadDropZoneLabel ?? "Drag and drop it or click here to upload"
247
260
  })] }),
248
261
  ariaLabel: o.uploadDropZoneAriaLabel ?? "Upload files",
249
262
  multiple: !0,
250
- className: j ? "border-error hover:border-error" : void 0,
251
- onChange: O
263
+ className: A ? "border-error hover:border-error" : void 0,
264
+ onChange: T
252
265
  }),
253
- /* @__PURE__ */ v("span", {
266
+ /* @__PURE__ */ b("span", {
254
267
  role: "status",
255
268
  "aria-live": "polite",
256
269
  className: "sr-only",
257
- id: D,
258
- children: m.map((e) => `${o.uploadBatchErrorAriaPrefix ?? "Upload error: "}${e}`).join(" ")
270
+ id: ce,
271
+ children: f.map((e) => `${o.uploadBatchErrorAriaPrefix ?? "Upload error: "}${e}`).join(" ")
259
272
  }),
260
- m.map((e) => /* @__PURE__ */ v(d, { text: e }, e)),
261
- s.length > 0 && /* @__PURE__ */ v("ul", {
273
+ f.map((e) => /* @__PURE__ */ b(p, { text: e }, e)),
274
+ s.length > 0 && /* @__PURE__ */ b("ul", {
262
275
  className: "flex flex-col gap-2",
263
276
  children: s.map((e) => {
264
- let t = u.get(e.id), n = t?.kind === fe.Manifest, i = t?.status === z.Invalid;
265
- return /* @__PURE__ */ y("li", {
277
+ let t = l.get(e.id), n = t?.kind === R.Manifest, r = t?.status === z.Invalid;
278
+ return /* @__PURE__ */ x("li", {
266
279
  className: "flex items-center gap-2 rounded-lg border border-tertiary p-2",
267
280
  children: [
268
- /* @__PURE__ */ v(ae, {
281
+ /* @__PURE__ */ b(C, {
269
282
  size: 20,
270
283
  "aria-hidden": !0,
271
- stroke: l
284
+ stroke: d
272
285
  }),
273
- /* @__PURE__ */ y("div", {
286
+ /* @__PURE__ */ x("div", {
274
287
  className: "flex min-w-0 flex-1 flex-col",
275
288
  children: [
276
- /* @__PURE__ */ v("span", {
289
+ /* @__PURE__ */ b("span", {
277
290
  className: "dial-small-text truncate",
278
291
  children: e.path
279
292
  }),
280
- /* @__PURE__ */ v("span", {
293
+ /* @__PURE__ */ b("span", {
281
294
  className: "dial-tiny-text text-secondary",
282
- children: r(e.file.size)
295
+ children: i(e.file.size)
283
296
  }),
284
- i && t?.error && /* @__PURE__ */ v(d, { text: t.error }),
285
- n && !i && /* @__PURE__ */ v("span", {
297
+ r && t?.error && /* @__PURE__ */ b(p, { text: t.error }),
298
+ n && !r && /* @__PURE__ */ b("span", {
286
299
  className: "dial-tiny-text text-secondary",
287
300
  children: o.uploadManifestRowNote ?? "Will replace this Skill's name, description, and instructions"
288
301
  })
289
302
  ]
290
303
  }),
291
- /* @__PURE__ */ v(te, {
292
- icon: /* @__PURE__ */ v(se, {
304
+ /* @__PURE__ */ b(ee, {
305
+ icon: /* @__PURE__ */ b(se, {
293
306
  size: 16,
294
307
  "aria-hidden": !0,
295
- stroke: l
308
+ stroke: d
296
309
  }),
297
310
  "aria-label": o.uploadRemoveCandidateLabel?.(e.path) ?? `Remove ${e.path}`,
298
- onClick: () => A(e.id)
311
+ onClick: () => E(e.id)
299
312
  })
300
313
  ]
301
314
  }, e.id);
302
315
  })
303
316
  }),
304
- x && /* @__PURE__ */ v(d, { text: x })
317
+ ae && /* @__PURE__ */ b(p, { text: ae })
305
318
  ]
306
319
  })
307
320
  });
308
- }, U = {
309
- title: "_title_65glc_1",
310
- helperText: "_helperText_65glc_5"
311
- }, me = C(async () => {
312
- let { MarkdownEditor: e } = await j();
321
+ }, V = {
322
+ title: "_title_1cnn4_1",
323
+ helperText: "_helperText_1cnn4_5",
324
+ refineFeedback: "_refineFeedback_1cnn4_9",
325
+ refineError: "_refineError_1cnn4_13"
326
+ }, xe = T(async () => {
327
+ let { MarkdownEditor: e } = await ue();
313
328
  return { default: e };
314
- }), W = ({ initialValues: r, files: f, selectedPath: te, onSelectedPathChange: ne, expandedPaths: re, onExpandedPathsChange: b, isLoading: ae = !1, hasLoadError: x = !1, isSubmitting: C = !1, errors: E, submitError: A, conflict: j, onReloadLatest: M, isNameReadOnly: P = !1, onDirtyChange: L, fileActions: R, supportingFileContent: fe, onSubmit: z, onCancel: B, onBack: V, backAriaLabel: H, title: W, onRetry: he, labels: ge, styles: _e, dir: ve, instructionsEditorTheme: ye = u.light }) => {
315
- let [G, K] = k({
316
- name: r?.name ?? "",
317
- description: r?.description ?? "",
318
- instructions: r?.instructions ?? ""
319
- }), be = a(), xe = O(r), Se = xe.current !== r, Ce = O(f);
320
- T(() => {
321
- xe.current = r, K({
322
- name: r?.name ?? "",
323
- description: r?.description ?? "",
324
- instructions: r?.instructions ?? ""
325
- }), Ce.current = f;
326
- }, [r]);
327
- let we = (e) => JSON.stringify([...e].sort((e, t) => e.path.localeCompare(t.path))), Te = O(!1);
328
- T(() => {
329
- if (Se) return;
329
+ }), Se = ({ initialValues: i, files: m, selectedPath: ee, onSelectedPathChange: ne, expandedPaths: re, onExpandedPathsChange: S, isLoading: C = !1, hasLoadError: w = !1, isSubmitting: T = !1, errors: M, submitError: ue, conflict: de, onReloadLatest: N, isNameReadOnly: P = !1, onDirtyChange: L, onValuesChange: he, onRefineDescription: R, onRefineInstructions: z, fileActions: B, supportingFileContent: ve, onSubmit: ye, onCancel: Se, onBack: Ce, backAriaLabel: we, title: Te, onRetry: Ee, onRetrySubmit: De, labels: Oe, styles: ke, dir: Ae, instructionsEditorTheme: je = f.light }) => {
330
+ let [H, Me] = j({
331
+ name: i?.name ?? "",
332
+ description: i?.description ?? "",
333
+ instructions: i?.instructions ?? ""
334
+ }), Ne = O(), Pe = O(), U = A(void 0), Fe = o(), Ie = A(H), W = (e) => {
335
+ let t = {
336
+ ...Ie.current,
337
+ ...e
338
+ };
339
+ Ie.current = t, Me(t), he?.(t);
340
+ }, Le = (e) => e ? async (t, n) => {
341
+ if (U.current && !U.current.aborted) throw new DOMException("Busy", "AbortError");
342
+ U.current = n;
343
+ try {
344
+ return await e(t, n);
345
+ } finally {
346
+ U.current === n && (U.current = void 0);
347
+ }
348
+ } : void 0, G = s({
349
+ value: H.description,
350
+ onChange: (e) => W({ description: e }),
351
+ onRefine: Le(R),
352
+ disabled: T || C || w,
353
+ resetKey: i
354
+ }), K = s({
355
+ value: H.instructions,
356
+ onChange: (e) => W({ instructions: e }),
357
+ onRefine: Le(z),
358
+ disabled: T || C || w,
359
+ resetKey: i
360
+ }), Re = G.isPending || K.isPending, ze = () => {
361
+ G.reset(), K.reset();
362
+ }, Be = () => {
363
+ ze(), Se();
364
+ }, Ve = () => {
365
+ ze(), Ce();
366
+ }, He = () => {
367
+ T || C || w || U.current && !U.current.aborted || ye(H);
368
+ }, Ue = A(i), We = Ue.current !== i, Ge = A(m);
369
+ D(() => {
370
+ Ue.current = i;
371
+ let e = {
372
+ name: i?.name ?? "",
373
+ description: i?.description ?? "",
374
+ instructions: i?.instructions ?? ""
375
+ };
376
+ Ie.current = e, Me(e), Ge.current = m;
377
+ }, [i]);
378
+ let Ke = (e) => JSON.stringify([...e].sort((e, t) => e.path.localeCompare(t.path))), qe = A(!1);
379
+ D(() => {
380
+ if (We) return;
330
381
  let e = {
331
- name: r?.name ?? "",
332
- description: r?.description ?? "",
333
- instructions: r?.instructions ?? ""
334
- }, t = JSON.stringify(G) !== JSON.stringify(e) || we(f) !== we(Ce.current);
335
- t !== Te.current && (Te.current = t, L?.(t));
382
+ name: i?.name ?? "",
383
+ description: i?.description ?? "",
384
+ instructions: i?.instructions ?? ""
385
+ }, t = JSON.stringify(H) !== JSON.stringify(e) || Ke(m) !== Ke(Ge.current);
386
+ t !== qe.current && (qe.current = t, L?.(t));
336
387
  }, [
337
- G,
338
- f,
339
- r,
340
- Se,
388
+ H,
389
+ m,
390
+ i,
391
+ We,
341
392
  L
342
393
  ]);
343
- let [Ee, De] = k(F), q = te ?? Ee, J = w((e) => {
344
- De(e), ne?.(e);
345
- }, [ne]), [Oe, ke] = k([]), Ae = re ?? Oe, je = D(() => new Set(Ae), [Ae]), Me = w((e) => {
394
+ let [Je, Ye] = j(F), q = ee ?? Je, J = E((e) => {
395
+ Ye(e), ne?.(e);
396
+ }, [ne]), [Xe, Ze] = j([]), Qe = re ?? Xe, $e = k(() => new Set(Qe), [Qe]), et = E((e) => {
346
397
  let t = [...e];
347
- ke(t), b?.(t);
348
- }, [b]), [Y, Ne] = k(!1), [Pe, Fe] = k(), [Ie, Le] = k(!1), { isDragActive: Re, dropZoneHandlers: ze } = le(w((e) => {
349
- Y || (Fe(e), Ne(!0));
350
- }, [Y])), X = ge ?? {}, Z = _e?.colors, Q = _e?.typography ?? {}, Be = Q.titleClassName ?? "dial-body-semi-text", Ve = Q.helperTextClassName ?? "dial-tiny-semi-text", He = Q.removeIconClassName ?? "text-secondary", Ue = n({
398
+ Ze(t), S?.(t);
399
+ }, [S]), [Y, tt] = j(!1), [nt, rt] = j(), [it, at] = j(!1), { isDragActive: ot, dropZoneHandlers: st } = me(E((e) => {
400
+ Y || (rt(e), tt(!0));
401
+ }, [Y])), X = Oe ?? {}, Z = ke?.colors, Q = ke?.typography ?? {}, ct = Q.titleClassName ?? "dial-body-semi-text", lt = Q.helperTextClassName ?? "dial-tiny-semi-text", ut = Q.removeIconClassName ?? "text-secondary", dt = r({
351
402
  "--se-title-color": Z?.title,
352
- "--se-helper-text-color": Z?.helperText
353
- }), We = Z?.border ? { colors: {
403
+ "--se-helper-text-color": Z?.helperText,
404
+ "--se-refine-action-text": Z?.refineActionText,
405
+ "--se-refine-error-text": Z?.refineErrorText
406
+ }), ft = {
407
+ feedbackClassName: a(V.refineFeedback, Q.refineFeedbackClassName ?? "dial-small-text", pe.refineFeedback),
408
+ errorClassName: V.refineError
409
+ }, pt = Z?.border ? { colors: {
354
410
  headerBorderColor: Z.border,
355
411
  sidebarBorderColor: Z.border
356
- } } : void 0, Ge = D(() => ue([{
412
+ } } : void 0, mt = k(() => ge([{
357
413
  path: F,
358
414
  name: F,
359
415
  kind: I.File
360
- }, ...f]), [f]), $ = D(() => f.find((e) => e.path === q), [f, q]), Ke = w((e) => {
416
+ }, ...m]), [m]), $ = k(() => m.find((e) => e.path === q), [m, q]), ht = E((e) => {
361
417
  J(e.path);
362
- }, [J]), qe = w((e) => {
363
- R.onRemoveNode(e), q === e && J(F);
418
+ }, [J]), gt = E((e) => {
419
+ B.onRemoveNode(e), q === e && J(F);
364
420
  }, [
365
- R,
421
+ B,
366
422
  q,
367
423
  J
368
- ]), Je = w((e) => e.path === "SKILL.md" ? [] : [{
424
+ ]), _t = E((e) => e.path === "SKILL.md" ? [] : [{
369
425
  key: "remove",
370
426
  label: X.removeLabel ?? "Remove",
371
- icon: /* @__PURE__ */ v(se, {
372
- size: c.SM,
373
- className: He,
427
+ icon: /* @__PURE__ */ b(se, {
428
+ size: u.SM,
429
+ className: ut,
374
430
  "aria-hidden": !0,
375
- stroke: l
431
+ stroke: d
376
432
  }),
377
- onClick: () => qe(e.path)
433
+ onClick: () => gt(e.path)
378
434
  }], [
379
435
  X.removeLabel,
380
- He,
381
- qe
382
- ]), Ye = /* @__PURE__ */ y("div", {
436
+ ut,
437
+ gt
438
+ ]), vt = /* @__PURE__ */ x("div", {
383
439
  className: "flex flex-col gap-2 desktop:gap-5",
384
- children: [/* @__PURE__ */ y("div", {
440
+ children: [/* @__PURE__ */ x("div", {
385
441
  className: "flex items-center justify-between",
386
- children: [/* @__PURE__ */ v("span", {
387
- className: i(U.title, Be),
442
+ children: [/* @__PURE__ */ b("span", {
443
+ className: a(V.title, ct),
388
444
  children: X.filesHeading ?? "Files"
389
- }), /* @__PURE__ */ v(m, {
445
+ }), /* @__PURE__ */ b(_, {
390
446
  label: X.addUploadLabel ?? "Upload from device",
391
- iconBefore: /* @__PURE__ */ v(oe, {
447
+ iconBefore: /* @__PURE__ */ b(oe, {
392
448
  size: 16,
393
449
  "aria-hidden": !0,
394
- stroke: l
450
+ stroke: d
395
451
  }),
396
452
  onClick: () => {
397
- Fe(void 0), Ne(!0);
453
+ rt(void 0), tt(!0);
398
454
  }
399
455
  })]
400
- }), /* @__PURE__ */ v("div", {
456
+ }), /* @__PURE__ */ b("div", {
401
457
  role: "tree",
402
458
  "aria-label": X.filesTreeAriaLabel ?? "Skill files",
403
- children: /* @__PURE__ */ v(ce, {
404
- items: Ge,
459
+ children: /* @__PURE__ */ b(le, {
460
+ items: mt,
405
461
  showFiles: !0,
406
462
  selectedPath: q,
407
- expandedPaths: je,
408
- onExpandedPathsChange: Me,
409
- onItemClick: Ke,
410
- getContextMenuItems: Je,
463
+ expandedPaths: $e,
464
+ onExpandedPathsChange: et,
465
+ onItemClick: ht,
466
+ getContextMenuItems: _t,
411
467
  rootItemPath: ""
412
468
  })
413
469
  })]
414
- }), Xe = /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(m, {
470
+ }), yt = /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(_, {
415
471
  label: X.cancelLabel ?? "Cancel",
416
- onClick: B,
417
- disabled: C
418
- }), /* @__PURE__ */ v(ie, {
472
+ onClick: Be,
473
+ disabled: T
474
+ }), /* @__PURE__ */ b(ie, {
419
475
  label: X.createLabel ?? "Create",
420
- iconBefore: C ? /* @__PURE__ */ v(h, {
476
+ iconBefore: T ? /* @__PURE__ */ b(v, {
421
477
  size: 16,
422
478
  ariaLabel: ""
423
479
  }) : void 0,
424
- onClick: () => z(G),
425
- disabled: C
480
+ onClick: He,
481
+ disabled: T || Re || C || w
426
482
  })] });
427
- return ae ? /* @__PURE__ */ v("div", {
428
- dir: ve,
483
+ return C ? /* @__PURE__ */ b("div", {
484
+ dir: Ae,
429
485
  className: "relative flex min-h-0 flex-1 flex-col",
430
- children: /* @__PURE__ */ v(N, {
431
- title: W,
432
- onBack: V,
433
- backAriaLabel: H,
434
- actions: Xe,
486
+ children: /* @__PURE__ */ b(fe, {
487
+ title: Te,
488
+ onBack: Ve,
489
+ backAriaLabel: we,
490
+ actions: yt,
435
491
  isSaving: !1,
436
492
  labels: { savingStatusLabel: X.savingStatusLabel },
437
- styles: We,
438
- leftContent: /* @__PURE__ */ v("div", {
493
+ styles: pt,
494
+ leftContent: /* @__PURE__ */ b("div", {
439
495
  role: "status",
440
496
  "aria-label": X.loadingAriaLabel ?? "Loading skill",
441
497
  className: "flex flex-1 items-center justify-center p-8",
442
- children: /* @__PURE__ */ v(h, {})
498
+ children: /* @__PURE__ */ b(v, {})
443
499
  })
444
500
  })
445
- }) : x ? /* @__PURE__ */ v("div", {
446
- dir: ve,
501
+ }) : w ? /* @__PURE__ */ b("div", {
502
+ dir: Ae,
447
503
  className: "relative flex min-h-0 flex-1 flex-col",
448
- children: /* @__PURE__ */ v(N, {
449
- title: W,
450
- onBack: V,
451
- backAriaLabel: H,
452
- actions: Xe,
504
+ children: /* @__PURE__ */ b(fe, {
505
+ title: Te,
506
+ onBack: Ve,
507
+ backAriaLabel: we,
508
+ actions: yt,
453
509
  isSaving: !1,
454
510
  labels: { savingStatusLabel: X.savingStatusLabel },
455
- styles: We,
456
- leftContent: /* @__PURE__ */ y("div", {
511
+ styles: pt,
512
+ leftContent: /* @__PURE__ */ x("div", {
457
513
  role: "alert",
458
514
  className: "flex flex-col items-center gap-4 p-8",
459
- children: [/* @__PURE__ */ v(d, { text: X.loadErrorMessage ?? "Couldn't load this skill. Please try again." }), /* @__PURE__ */ v(ie, {
515
+ children: [/* @__PURE__ */ b(p, { text: X.loadErrorMessage ?? "Couldn't load this skill. Please try again." }), /* @__PURE__ */ b(ie, {
460
516
  label: X.retryLabel ?? "Retry",
461
- onClick: he
517
+ onClick: Ee
462
518
  })]
463
519
  })
464
520
  })
465
- }) : /* @__PURE__ */ y("div", {
466
- dir: ve,
467
- className: "relative flex min-h-0 flex-1 flex-col",
468
- style: Ue,
469
- ...ze,
521
+ }) : /* @__PURE__ */ x("div", {
522
+ dir: Ae,
523
+ className: a("relative flex min-h-0 flex-1 flex-col", pe.root),
524
+ style: dt,
525
+ ...st,
470
526
  children: [
471
- /* @__PURE__ */ v(de, {
472
- isVisible: Re && !Y,
473
- labels: ge
527
+ /* @__PURE__ */ b(_e, {
528
+ isVisible: ot && !Y,
529
+ labels: Oe
474
530
  }),
475
- /* @__PURE__ */ v(N, {
476
- title: W,
477
- onBack: V,
478
- backAriaLabel: H,
479
- actions: Xe,
480
- isSaving: C,
531
+ /* @__PURE__ */ b(fe, {
532
+ title: Te,
533
+ onBack: Ve,
534
+ backAriaLabel: we,
535
+ actions: yt,
536
+ isSaving: T,
481
537
  labels: { savingStatusLabel: X.savingStatusLabel },
482
- styles: We,
483
- leftContent: /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
538
+ styles: pt,
539
+ leftContent: /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("div", {
484
540
  className: "px-4 py-4 desktop:hidden",
485
- children: /* @__PURE__ */ v(o, {
541
+ children: /* @__PURE__ */ b(c, {
486
542
  title: X.editingFileLabel ?? "Editing file",
487
543
  description: $?.name ?? "SKILL.md",
488
- expanded: Ie,
489
- onToggle: Le,
544
+ expanded: it,
545
+ onToggle: at,
490
546
  ariaLabel: X.editingFileLabel ?? "Editing file",
491
- children: Ye
547
+ children: vt
492
548
  })
493
- }), /* @__PURE__ */ v("div", {
549
+ }), /* @__PURE__ */ b("div", {
494
550
  className: "hidden px-8 py-6 desktop:block",
495
- children: Ye
551
+ children: vt
496
552
  })] }),
497
- rightContent: /* @__PURE__ */ y("div", {
553
+ rightContent: /* @__PURE__ */ x("div", {
498
554
  className: "flex flex-1 flex-col gap-4 px-4 py-6 desktop:gap-5 desktop:px-8",
499
555
  children: [
500
- A != null && /* @__PURE__ */ v("div", {
556
+ ue != null && /* @__PURE__ */ x("div", {
501
557
  role: "alert",
502
- children: /* @__PURE__ */ v(d, { text: A })
558
+ className: "flex items-center gap-2",
559
+ children: [/* @__PURE__ */ b(p, { text: ue }), De != null && /* @__PURE__ */ b(h, {
560
+ label: X.retryLabel ?? "Retry",
561
+ onClick: De
562
+ })]
503
563
  }),
504
- j != null && /* @__PURE__ */ y("div", {
564
+ de != null && /* @__PURE__ */ x("div", {
505
565
  role: "alert",
506
566
  className: "flex items-center gap-2",
507
- children: [/* @__PURE__ */ v(d, { text: j.message }), /* @__PURE__ */ v(ee, {
567
+ children: [/* @__PURE__ */ b(p, { text: de.message }), /* @__PURE__ */ b(h, {
508
568
  label: X.reloadLatestLabel ?? "Reload latest",
509
- onClick: M
569
+ onClick: N
510
570
  })]
511
571
  }),
512
- /* @__PURE__ */ v("h2", {
513
- className: i(U.title, Be),
572
+ /* @__PURE__ */ b("h2", {
573
+ className: a(V.title, ct),
514
574
  children: q === "SKILL.md" ? F : X.selectedFileHeading?.($?.name ?? q) ?? $?.name ?? q
515
575
  }),
516
- q === "SKILL.md" ? /* @__PURE__ */ y(_, { children: [
517
- /* @__PURE__ */ v(p, {
576
+ q === "SKILL.md" ? /* @__PURE__ */ x(y, { children: [
577
+ /* @__PURE__ */ b(g, {
518
578
  labelProps: {
519
579
  label: X.nameLabel ?? "Name",
520
580
  required: !0
521
581
  },
522
- value: G.name,
523
- onChange: (e) => K((t) => ({
524
- ...t,
525
- name: e ?? ""
526
- })),
582
+ value: H.name,
583
+ onChange: (e) => W({ name: e ?? "" }),
527
584
  placeholder: X.namePlaceholder ?? "good-morning-breakfast",
528
- caption: E?.name ? void 0 : X.nameCaption ?? "Lowercase letters and hyphens only, no spaces. We'll reformat automatically if needed.",
529
- error: E?.name,
530
- invalid: !!E?.name,
585
+ caption: M?.name ? void 0 : X.nameCaption ?? "Lowercase letters and hyphens only, no spaces. We'll reformat automatically if needed.",
586
+ error: M?.name,
587
+ invalid: !!M?.name,
531
588
  disabled: P
532
589
  }),
533
- /* @__PURE__ */ v(g, {
534
- labelProps: {
535
- label: X.descriptionLabel ?? "Description",
536
- required: !0
537
- },
538
- value: G.description,
539
- placeholder: X.descriptionPlaceholder ?? "What this skill does and when to use it",
540
- onChange: (e) => K((t) => ({
541
- ...t,
542
- description: e
543
- })),
544
- error: E?.description,
545
- invalid: !!E?.description
590
+ /* @__PURE__ */ b(n, {
591
+ isEnabled: !!R,
592
+ fieldId: Ne,
593
+ required: !0,
594
+ label: X.descriptionLabel ?? "Description",
595
+ labels: X,
596
+ refinement: G,
597
+ disabled: Re || T,
598
+ ...ft,
599
+ children: /* @__PURE__ */ b(ae, {
600
+ id: Ne,
601
+ "aria-required": !0,
602
+ labelProps: R ? void 0 : {
603
+ label: X.descriptionLabel ?? "Description",
604
+ required: !0
605
+ },
606
+ value: H.description,
607
+ placeholder: X.descriptionPlaceholder ?? "What this skill does and when to use it",
608
+ onChange: (e) => {
609
+ G.reset(), W({ description: e });
610
+ },
611
+ error: M?.description,
612
+ invalid: !!M?.description
613
+ })
546
614
  }),
547
- /* @__PURE__ */ y("div", {
548
- className: "flex flex-1 flex-col gap-2",
549
- children: [
550
- /* @__PURE__ */ y("span", {
551
- className: "flex items-center gap-0.5",
552
- children: [/* @__PURE__ */ v("span", {
553
- className: i(U.helperText, Ve),
554
- children: X.instructionsLabel ?? "Instructions"
555
- }), /* @__PURE__ */ v("span", {
556
- className: "dial-tiny-text text-error",
557
- children: "*"
558
- })]
559
- }),
560
- /* @__PURE__ */ v("div", {
561
- ref: be,
562
- className: i(e, t),
563
- children: /* @__PURE__ */ v(S, {
564
- fallback: /* @__PURE__ */ v(h, { ariaLabel: X.instructionsLoadingAriaLabel ?? "Loading" }),
565
- children: /* @__PURE__ */ v(me, {
566
- value: G.instructions,
567
- onChange: (e) => K((t) => ({
568
- ...t,
569
- instructions: e
570
- })),
571
- theme: ye,
572
- placeholder: X.instructionsPlaceholder ?? "Write the skill instructions in Markdown"
615
+ /* @__PURE__ */ b(n, {
616
+ isEnabled: !!z,
617
+ fieldId: Pe,
618
+ required: !0,
619
+ labelClassName: a(V.helperText, lt),
620
+ label: X.instructionsLabel ?? "Instructions",
621
+ labels: X,
622
+ refinement: K,
623
+ disabled: Re || T,
624
+ ...ft,
625
+ children: /* @__PURE__ */ x("div", {
626
+ className: "flex flex-1 flex-col gap-2",
627
+ children: [
628
+ !z && /* @__PURE__ */ b(te, {
629
+ htmlFor: Pe,
630
+ className: a(V.helperText, lt),
631
+ label: X.instructionsLabel ?? "Instructions",
632
+ required: !0
633
+ }),
634
+ /* @__PURE__ */ b("div", {
635
+ ref: Fe,
636
+ className: a(e, t),
637
+ children: /* @__PURE__ */ b(ce, {
638
+ fallback: /* @__PURE__ */ b(v, { ariaLabel: X.instructionsLoadingAriaLabel ?? "Loading" }),
639
+ children: /* @__PURE__ */ b(xe, {
640
+ id: Pe,
641
+ ariaLabel: X.instructionsLabel ?? "Instructions",
642
+ value: H.instructions,
643
+ onChange: (e) => {
644
+ K.reset(), W({ instructions: e });
645
+ },
646
+ theme: je,
647
+ placeholder: X.instructionsPlaceholder ?? "Write the skill instructions in Markdown"
648
+ })
573
649
  })
574
- })
575
- }),
576
- E?.instructions != null && /* @__PURE__ */ v(d, { text: E.instructions })
577
- ]
650
+ }),
651
+ M?.instructions != null && /* @__PURE__ */ b(p, { text: M.instructions })
652
+ ]
653
+ })
578
654
  })
579
- ] }) : $?.kind === I.File && (fe ?? /* @__PURE__ */ v(s, { text: X.supportingFileNote ?? "This supporting file is included in the skill package as-is. Remove it from the Files panel to replace its content." }))
655
+ ] }) : $?.kind === I.File && (ve ?? /* @__PURE__ */ b(l, { text: X.supportingFileNote ?? "This supporting file is included in the skill package as-is. Remove it from the Files panel to replace its content." }))
580
656
  ]
581
657
  })
582
658
  }),
583
- /* @__PURE__ */ v(pe, {
659
+ /* @__PURE__ */ b(be, {
584
660
  isOpen: Y,
585
661
  onClose: () => {
586
- Ne(!1), Fe(void 0);
662
+ tt(!1), rt(void 0);
587
663
  },
588
- fileActions: R,
589
- initialFiles: Pe,
590
- labels: ge
664
+ fileActions: B,
665
+ initialFiles: nt,
666
+ labels: Oe
591
667
  })
592
668
  ]
593
669
  });
594
670
  };
595
671
  //#endregion
596
- export { W as SkillEditor, fe as SkillFileCandidateKind, I as SkillFileNodeKind, z as SkillFileValidationStatus };
672
+ export { pe as SKILL_EDITOR_CLASS, Se as SkillEditor, R as SkillFileCandidateKind, I as SkillFileNodeKind, z as SkillFileValidationStatus };