@epam/ai-dial-skills 1.2.0-dev.141 → 1.2.0-dev.142

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,25 +1,25 @@
1
1
  import { DeploymentIcon as e, buildCssVars as t, isSkillSelectionUnsupported as n, mergeClasses as r } from "@epam/ai-dial-chat-shared";
2
- import { BASE_ICON_SIZE as i, Button as a, ButtonAppearance as o, ButtonVariant as s, DIAL_ICON_SIZE as c, DIAL_KIT_ICON_STROKE as l, Dropdown as u, FileDropzone as d, GhostButton as f, Highlight as p, Input as m, InteractiveTooltip as h, Popup as g, PopupSize as _, Search as v, ToggleIconButton as y, TooltipPlacement as b } from "@epam/ai-dial-ui-kit";
3
- import { Suspense as x, useCallback as S, useEffect as ee, useId as C, useLayoutEffect as w, useMemo as T, useRef as E, useState as D } from "react";
4
- import { IconBlocks as O, IconChevronDown as k, IconEye as A, IconStarFilled as j, IconX as M } from "@tabler/icons-react";
5
- import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
6
- import { DetailsPanel as I } from "@epam/ai-dial-catalog";
2
+ import { BASE_ICON_SIZE as i, Button as a, ButtonAppearance as o, ButtonVariant as s, DIAL_ICON_SIZE as c, DIAL_KIT_ICON_STROKE as l, Dropdown as u, FileDropzone as d, GhostButton as f, Highlight as p, Input as m, InteractiveTooltip as h, Popup as g, PopupSize as _, Search as v, ToggleIconButton as ee, TooltipPlacement as y } from "@epam/ai-dial-ui-kit";
3
+ import { Suspense as b, useCallback as x, useEffect as te, useId as S, useLayoutEffect as C, useMemo as w, useRef as T, useState as E } from "react";
4
+ import { IconBlocks as D, IconChevronDown as ne, IconEye as O, IconStarFilled as k, IconX as A } from "@tabler/icons-react";
5
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
6
+ import { DetailsPanel as P } from "@epam/ai-dial-catalog";
7
7
  //#region src/constants/public-class-names.ts
8
- var L = {
8
+ var F = {
9
9
  selectorField: "dial-skills-selector-field",
10
10
  favoritesPanel: "dial-skills-favorites-panel",
11
11
  chip: "dial-skills-chip"
12
- }, R = ({ description: e, unsupportedMessage: t, viewDetailsLabel: n = "View details", onViewDetails: r, viewDetailsTabIndex: i }) => t == null ? /* @__PURE__ */ F("div", {
12
+ }, I = ({ description: e, unsupportedMessage: t, viewDetailsLabel: n = "View details", onViewDetails: r, viewDetailsTabIndex: i }) => t == null ? /* @__PURE__ */ N("div", {
13
13
  className: "flex flex-col gap-3",
14
- children: [e != null && e !== "" && /* @__PURE__ */ P("p", {
14
+ children: [e != null && e !== "" && /* @__PURE__ */ M("p", {
15
15
  className: "text-start",
16
16
  children: e
17
- }), /* @__PURE__ */ P(a, {
17
+ }), /* @__PURE__ */ M(a, {
18
18
  variant: s.Primary,
19
19
  appearance: o.Link,
20
20
  className: "h-[24px] self-start",
21
21
  label: n,
22
- iconBefore: /* @__PURE__ */ P(A, {
22
+ iconBefore: /* @__PURE__ */ M(O, {
23
23
  size: c.SM,
24
24
  stroke: l,
25
25
  "aria-hidden": !0
@@ -27,32 +27,42 @@ var L = {
27
27
  onClick: r,
28
28
  tabIndex: i
29
29
  })]
30
- }) : /* @__PURE__ */ P("p", {
30
+ }) : /* @__PURE__ */ M("p", {
31
31
  className: "text-start",
32
32
  children: t
33
- }), z = ({ name: e, path: t, description: n, isUnsupported: i = !1, labelClassName: a = "dial-body-paragraph-text", unsupportedLabelClassName: o = "text-error", unsupportedClassName: s = "bg-error", onViewDetails: c, labels: l = {} }) => {
34
- let { viewDetailsLabel: u = "View details", unsupportedTooltipLabel: d = "Selected model does not support skills. Remove the skill or select different model to proceed." } = l, [p, m] = D(0);
35
- return /* @__PURE__ */ P(h, {
33
+ }), L = ({ name: e, path: t, description: n, isUnsupported: i = !1, labelClassName: a = "dial-body-paragraph-text text-accent", unsupportedLabelClassName: o = "text-error", unsupportedClassName: s = "bg-error", onViewDetails: c, labels: l = {} }) => {
34
+ let { viewDetailsLabel: u = "View details", unsupportedTooltipLabel: d = "Selected model does not support skills. Remove the skill or select different model to proceed." } = l, [f, p] = E(0), m = () => {
35
+ p((e) => e + 1), c(t);
36
+ }, g = T(null), [_, v] = E(null);
37
+ return C(() => {
38
+ v(g.current?.getBoundingClientRect().width ?? null);
39
+ }, [a]), /* @__PURE__ */ M(h, {
36
40
  asChild: !0,
37
- placement: b.Top,
41
+ placement: y.Top,
38
42
  contentClassName: "max-w-[550px]",
39
- content: i ? /* @__PURE__ */ P(R, { unsupportedMessage: d }) : /* @__PURE__ */ P(R, {
43
+ content: i ? /* @__PURE__ */ M(I, { unsupportedMessage: d }) : /* @__PURE__ */ M(I, {
40
44
  description: n,
41
45
  viewDetailsLabel: u,
42
- onViewDetails: () => {
43
- m((e) => e + 1), c(t);
44
- }
46
+ onViewDetails: m
45
47
  }),
46
- children: /* @__PURE__ */ P("span", {
47
- className: "inline-flex items-center",
48
- children: /* @__PURE__ */ P(f, {
49
- label: `/${e}`,
50
- textClassName: i ? r(a, o) : a,
51
- className: r("h-auto px-2 py-0", i && s, L.chip)
52
- })
48
+ children: /* @__PURE__ */ N("span", {
49
+ tabIndex: 0,
50
+ className: r("relative -me-1 -ms-1 inline-block cursor-pointer select-text rounded-full pe-1 ps-1", i ? s : "hover:bg-info focus-visible:bg-info active:bg-info", i ? r(a, o) : a, F.chip),
51
+ "aria-label": `/${e}`,
52
+ children: [/* @__PURE__ */ M("span", {
53
+ ref: g,
54
+ "aria-hidden": !0,
55
+ className: "inset-inline-start-0 pointer-events-none absolute top-0 select-none",
56
+ children: "/"
57
+ }), /* @__PURE__ */ M("span", {
58
+ "aria-hidden": !0,
59
+ className: "select-none",
60
+ style: { paddingInlineStart: _ ?? void 0 },
61
+ children: e
62
+ })]
53
63
  })
54
- }, p);
55
- }, B = {
64
+ }, f);
65
+ }, R = {
56
66
  row: "_row_1v431_1",
57
67
  header: "_header_1v431_8",
58
68
  emptyHint: "_emptyHint_1v431_12",
@@ -63,105 +73,105 @@ var L = {
63
73
  rowLeaving: "_rowLeaving_1v431_32",
64
74
  rowFadeOut: "_rowFadeOut_1v431_1",
65
75
  listContent: "_listContent_1v431_60"
66
- }, V = "px-3 pb-0.5 pt-2", te = 180, H = 288, U = ({ favorites: n, onSelect: i, onToggleFavorite: a, onBrowse: o, onViewDetails: s, className: l, rowClassName: u, searchQuery: d, listboxId: m, activeOptionId: g, isMenu: _ = !1, labels: v = {}, colors: b, nameClassName: x = "dial-small-text", headerClassName: S = "dial-tiny-lead-semi-text", emptyHintClassName: T = "dial-small-text" }) => {
67
- let { myCollectionLabel: O = "My Collection", emptyHintLabel: k = "Star a skill to pin it here", browseLabel: A = "Browse", removeFromFavoritesLabel: M = "Remove from favorites", viewDetailsLabel: N = "View details", noMatchingSkillsLabel: I = "No matching skills" } = v, z = t({
68
- "--fs-row-hover-bg": b?.rowHoverBackground,
69
- "--fs-header-text": b?.headerText,
70
- "--fs-empty-hint-text": b?.emptyHintText,
71
- "--fs-star-color": b?.starColor,
72
- "--fs-footer-border": b?.footerBorder
73
- }), [U, W] = D(/* @__PURE__ */ new Set()), G = E(/* @__PURE__ */ new Map());
74
- ee(() => {
75
- let e = G.current;
76
+ }, z = "px-3 pb-0.5 pt-2", B = 180, V = 288, H = ({ favorites: n, onSelect: i, onToggleFavorite: a, onBrowse: o, onViewDetails: s, className: l, rowClassName: u, searchQuery: d, listboxId: m, activeOptionId: g, isMenu: _ = !1, labels: v = {}, colors: y, nameClassName: b = "dial-small-text", headerClassName: x = "dial-tiny-lead-semi-text", emptyHintClassName: w = "dial-small-text" }) => {
77
+ let { myCollectionLabel: D = "My Collection", emptyHintLabel: ne = "Star a skill to pin it here", browseLabel: O = "Browse", removeFromFavoritesLabel: A = "Remove from favorites", viewDetailsLabel: j = "View details", noMatchingSkillsLabel: P = "No matching skills" } = v, L = t({
78
+ "--fs-row-hover-bg": y?.rowHoverBackground,
79
+ "--fs-header-text": y?.headerText,
80
+ "--fs-empty-hint-text": y?.emptyHintText,
81
+ "--fs-star-color": y?.starColor,
82
+ "--fs-footer-border": y?.footerBorder
83
+ }), [H, U] = E(/* @__PURE__ */ new Set()), W = T(/* @__PURE__ */ new Map());
84
+ te(() => {
85
+ let e = W.current;
76
86
  return () => {
77
87
  e.forEach((e) => clearTimeout(e)), e.clear();
78
88
  };
79
89
  }, []);
80
- let K = m != null, q = _ && !K, J = K || q ? "none" : void 0, Y = "button";
81
- K ? Y = "option" : q && (Y = "menuitem");
82
- let X = C(), Z = d != null, ne = d?.toLowerCase() ?? "", Q = Z ? n.filter((e) => e.name.toLowerCase().includes(ne)) : n, $ = E(null), [re, ie] = D();
83
- w(() => {
84
- $.current && ie(Math.min($.current.scrollHeight, H));
90
+ let G = m != null, K = _ && !G, q = G || K ? "none" : void 0, J = "button";
91
+ G ? J = "option" : K && (J = "menuitem");
92
+ let Y = S(), X = d != null, Z = d?.toLowerCase() ?? "", Q = X ? n.filter((e) => e.name.toLowerCase().includes(Z)) : n, re = T(null), [ie, ae] = E();
93
+ C(() => {
94
+ re.current && ae(Math.min(re.current.scrollHeight, V));
85
95
  }, [n, d]);
86
- let ae = (e, t) => {
96
+ let oe = (e, t) => {
87
97
  e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), i(t));
88
- }, oe = (e) => {
89
- W((t) => new Set(t).add(e));
98
+ }, $ = (e) => {
99
+ U((t) => new Set(t).add(e));
90
100
  let t = setTimeout(() => {
91
- a?.(e), W((t) => {
101
+ a?.(e), U((t) => {
92
102
  let n = new Set(t);
93
103
  return n.delete(e), n;
94
- }), G.current.delete(e);
95
- }, te);
96
- G.current.set(e, t);
104
+ }), W.current.delete(e);
105
+ }, B);
106
+ W.current.set(e, t);
97
107
  };
98
- return /* @__PURE__ */ F("div", {
99
- className: r("flex w-full flex-col desktop:w-[280px]", l, L.favoritesPanel),
100
- style: z,
108
+ return /* @__PURE__ */ N("div", {
109
+ className: r("flex w-full flex-col desktop:w-[280px]", l, F.favoritesPanel),
110
+ style: L,
101
111
  children: [
102
- /* @__PURE__ */ P("p", {
103
- id: X,
104
- className: r(S, V, B.header),
105
- children: O
112
+ /* @__PURE__ */ M("p", {
113
+ id: Y,
114
+ className: r(x, z, R.header),
115
+ children: D
106
116
  }),
107
- /* @__PURE__ */ P("div", {
108
- className: r("max-h-72 min-h-0 flex-1 overflow-y-auto", B.listContent),
109
- style: { maxHeight: re },
110
- children: /* @__PURE__ */ P("div", {
111
- ref: $,
112
- children: Q.length > 0 ? /* @__PURE__ */ P("ul", {
117
+ /* @__PURE__ */ M("div", {
118
+ className: r("max-h-72 min-h-0 flex-1 overflow-y-auto", R.listContent),
119
+ style: { maxHeight: ie },
120
+ children: /* @__PURE__ */ M("div", {
121
+ ref: re,
122
+ children: Q.length > 0 ? /* @__PURE__ */ M("ul", {
113
123
  id: m,
114
- role: K ? "listbox" : J,
115
- "aria-labelledby": K ? X : void 0,
124
+ role: G ? "listbox" : q,
125
+ "aria-labelledby": G ? Y : void 0,
116
126
  className: "flex flex-col gap-1 px-1 pb-1",
117
127
  children: Q.map((t) => {
118
- let n = K ? `${m}-${encodeURIComponent(t.id)}` : void 0, o = K ? -1 : void 0, l = /* @__PURE__ */ F("div", {
119
- role: Y,
128
+ let n = G ? `${m}-${encodeURIComponent(t.id)}` : void 0, o = G ? -1 : void 0, l = /* @__PURE__ */ N("div", {
129
+ role: J,
120
130
  id: n,
121
- "aria-selected": K ? n === g : void 0,
131
+ "aria-selected": G ? n === g : void 0,
122
132
  "aria-label": t.name,
123
133
  tabIndex: 0,
124
- className: r("flex cursor-pointer items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 transition-colors", B.row, u),
134
+ className: r("flex cursor-pointer items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 transition-colors", R.row, u),
125
135
  onClick: () => i(t),
126
- onKeyDown: (e) => ae(e, t),
136
+ onKeyDown: (e) => oe(e, t),
127
137
  children: [
128
- /* @__PURE__ */ P(e, {
138
+ /* @__PURE__ */ M(e, {
129
139
  size: c.MD,
130
140
  initialsName: t.name
131
141
  }),
132
- d == null ? /* @__PURE__ */ P("span", {
133
- className: r(x, "min-w-0 flex-1 truncate text-start"),
142
+ d == null ? /* @__PURE__ */ M("span", {
143
+ className: r(b, "min-w-0 flex-1 truncate text-start"),
134
144
  children: t.name
135
- }) : /* @__PURE__ */ P(p, {
145
+ }) : /* @__PURE__ */ M(p, {
136
146
  text: t.name,
137
147
  query: d,
138
148
  maxLines: 1,
139
- className: r(x, "min-w-0 flex-1 text-start")
149
+ className: r(b, "min-w-0 flex-1 text-start")
140
150
  }),
141
- a && /* @__PURE__ */ P(y, {
142
- icon: /* @__PURE__ */ P(j, {
151
+ a && /* @__PURE__ */ M(ee, {
152
+ icon: /* @__PURE__ */ M(k, {
143
153
  size: c.SM,
144
- className: B.star,
154
+ className: R.star,
145
155
  "aria-hidden": !0
146
156
  }),
147
- "aria-label": M,
157
+ "aria-label": A,
148
158
  isSelected: !0,
149
159
  tabIndex: o,
150
160
  onClick: (e) => {
151
- e.stopPropagation(), oe(t.id);
161
+ e.stopPropagation(), $(t.id);
152
162
  }
153
163
  })
154
164
  ]
155
165
  });
156
- return /* @__PURE__ */ P("li", {
157
- role: J,
158
- className: U.has(t.id) ? B.rowLeaving : B.rowEnter,
159
- children: s ? /* @__PURE__ */ P(h, {
166
+ return /* @__PURE__ */ M("li", {
167
+ role: q,
168
+ className: H.has(t.id) ? R.rowLeaving : R.rowEnter,
169
+ children: s ? /* @__PURE__ */ M(h, {
160
170
  asChild: !0,
161
171
  contentClassName: "max-w-[550px]",
162
- content: /* @__PURE__ */ P(R, {
172
+ content: /* @__PURE__ */ M(I, {
163
173
  description: t.description,
164
- viewDetailsLabel: N,
174
+ viewDetailsLabel: j,
165
175
  onViewDetails: () => s(t),
166
176
  viewDetailsTabIndex: o
167
177
  }),
@@ -169,43 +179,43 @@ var L = {
169
179
  }) : l
170
180
  }, t.id);
171
181
  })
172
- }) : Z && ne !== "" ? /* @__PURE__ */ P("p", {
182
+ }) : X && Z !== "" ? /* @__PURE__ */ M("p", {
173
183
  role: "status",
174
184
  "aria-live": "polite",
175
- className: r(T, "px-4 py-4 text-start", B.emptyHint),
176
- children: I
177
- }) : /* @__PURE__ */ P("p", {
178
- className: r(T, "px-4 py-4 text-start", B.emptyHint),
179
- children: k
185
+ className: r(w, "px-4 py-4 text-start", R.emptyHint),
186
+ children: P
187
+ }) : /* @__PURE__ */ M("p", {
188
+ className: r(w, "px-4 py-4 text-start", R.emptyHint),
189
+ children: ne
180
190
  })
181
191
  })
182
192
  }),
183
- /* @__PURE__ */ P("div", {
184
- className: r("border-t px-2 py-3", B.footer),
185
- children: /* @__PURE__ */ P(f, {
186
- role: q ? "menuitem" : void 0,
187
- label: A,
193
+ /* @__PURE__ */ M("div", {
194
+ className: r("border-t px-2 py-3", R.footer),
195
+ children: /* @__PURE__ */ M(f, {
196
+ role: K ? "menuitem" : void 0,
197
+ label: O,
188
198
  className: "w-full justify-center",
189
199
  onClick: o
190
200
  })
191
201
  })
192
202
  ]
193
203
  });
194
- }, W = ".zip,.md", G = ({ isOpen: e, errorText: t, accept: n = W, labels: r, onClose: i, onFilesSelected: a, onFilesRejected: o }) => {
204
+ }, U = ".zip,.md", W = ({ isOpen: e, errorText: t, accept: n = U, labels: r, onClose: i, onFilesSelected: a, onFilesRejected: o }) => {
195
205
  let { dialogTitle: s = "Upload skill", dropZoneLabel: c = "Drag and drop it or click here to upload", dropZoneMobileLabel: l = "Click here to upload", formatsLabel: u = "File formats .zip and SKILL.md", fileInputAriaLabel: f = "Upload a skill ZIP archive or a SKILL.md file", closeAriaLabel: p = "Close" } = r ?? {};
196
- return /* @__PURE__ */ P(g, {
206
+ return /* @__PURE__ */ M(g, {
197
207
  open: e,
198
208
  size: _.Sm,
199
209
  header: s,
200
210
  closeAriaLabel: p,
201
211
  onClose: i,
202
- children: /* @__PURE__ */ P("div", {
212
+ children: /* @__PURE__ */ M("div", {
203
213
  className: "px-6 py-4",
204
- children: /* @__PURE__ */ P(d, {
205
- label: /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P("span", {
214
+ children: /* @__PURE__ */ M(d, {
215
+ label: /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("span", {
206
216
  className: "desktop:hidden",
207
217
  children: l
208
- }), /* @__PURE__ */ P("span", {
218
+ }), /* @__PURE__ */ M("span", {
209
219
  className: "hidden desktop:inline",
210
220
  children: c
211
221
  })] }),
@@ -218,307 +228,422 @@ var L = {
218
228
  })
219
229
  })
220
230
  });
221
- }, K = ({ isOpen: e, onClose: t, onSelect: n, title: r, renderContent: i }) => /* @__PURE__ */ P(g, {
231
+ }, G = ({ isOpen: e, onClose: t, onSelect: n, title: r, renderContent: i }) => /* @__PURE__ */ M(g, {
222
232
  open: e,
223
233
  header: r,
224
234
  size: _.Lg,
225
235
  className: "h-[min(90vh,860px)] !max-w-[min(95vw,1200px)] overflow-hidden",
226
236
  onClose: t,
227
- children: /* @__PURE__ */ P("div", {
237
+ children: /* @__PURE__ */ M("div", {
228
238
  className: "h-[min(80vh,840px)] overflow-auto",
229
- children: /* @__PURE__ */ P(x, {
239
+ children: /* @__PURE__ */ M(b, {
230
240
  fallback: null,
231
241
  children: e && i(n, t)
232
242
  })
233
243
  })
234
- }), q = (e) => /* @__PURE__ */ P(I, { ...e }), J = (e) => ({
244
+ }), K = (e) => /* @__PURE__ */ M(P, { ...e }), q = (e) => e == null || /[\s/]/.test(e), J = (e, t, n) => {
245
+ let r = [], i = 0;
246
+ return t.forEach((t, a) => {
247
+ let o = `/${n(t.url)}`, s = i;
248
+ for (; s <= e.length;) {
249
+ let t = e.indexOf(o, s);
250
+ if (t === -1) return;
251
+ let n = t + o.length;
252
+ if (q(e[n])) {
253
+ r.push({
254
+ skillIndex: a,
255
+ start: t,
256
+ length: o.length
257
+ }), i = n;
258
+ return;
259
+ }
260
+ s = t + 1;
261
+ }
262
+ }), r;
263
+ }, Y = (e, t) => {
264
+ let n = Math.min(e.length, t.length), r = 0;
265
+ for (; r < n && e[r] === t[r];) r += 1;
266
+ let i = n - r, a = 0;
267
+ for (; a < i && e[e.length - 1 - a] === t[t.length - 1 - a];) a += 1;
268
+ return {
269
+ start: r,
270
+ deletedLength: e.length - r - a,
271
+ insertedLength: t.length - r - a
272
+ };
273
+ }, X = (e, t) => {
274
+ let n = t.start + t.deletedLength, r = t.insertedLength - t.deletedLength;
275
+ return e.reduce((e, i) => i.start + i.length <= t.start ? (e.push(i), e) : (i.start >= n && e.push({
276
+ ...i,
277
+ start: i.start + r
278
+ }), e), []);
279
+ }, Z = (e, t, n, r, i) => {
280
+ let a = r.length + 1, o = a + +!!i, s = e.map((e) => e.start >= t ? {
281
+ ...e,
282
+ start: e.start + o
283
+ } : e), c = {
284
+ url: n,
285
+ name: r,
286
+ start: t,
287
+ length: a
288
+ };
289
+ return [...s, c].sort((e, t) => e.start - t.start);
290
+ }, Q = (e, t) => e.find((e) => e.start + e.length === t), re = () => {
291
+ let [e, t] = E(""), [n, r] = E([]), i = T(e);
292
+ i.current = e;
293
+ let a = T(n);
294
+ return a.current = n, {
295
+ draft: e,
296
+ anchors: n,
297
+ onDraftChange: x((e) => {
298
+ let n = Y(i.current, e);
299
+ r((e) => X(e, n)), i.current = e, t(e);
300
+ }, []),
301
+ insertMention: x((e, n, a) => {
302
+ let o = i.current, s = !/^\s/.test(o.slice(a)), c = `/${n}${s ? " " : ""}`, l = o.slice(0, a) + c + o.slice(a);
303
+ return i.current = l, t(l), r((t) => Z(t, a, e, n, s)), s;
304
+ }, []),
305
+ onBackspaceAtCaret: x((e) => Q(a.current, e), []),
306
+ orderedSkills: w(() => {
307
+ if (n.length !== 0) return n.map((e) => ({ url: e.url }));
308
+ }, [n]),
309
+ reset: x(() => {
310
+ t(""), r([]);
311
+ }, []),
312
+ seedFromMessage: x((e, n, i) => {
313
+ let a = n ?? [], o = J(e, a, i);
314
+ t(e), r(o.map((e) => {
315
+ let t = a[e.skillIndex];
316
+ return {
317
+ url: t.url,
318
+ name: i(t.url),
319
+ start: e.start,
320
+ length: e.length
321
+ };
322
+ }));
323
+ }, [])
324
+ };
325
+ }, ie = (e) => ({
235
326
  id: e.url,
236
327
  name: e.name,
237
328
  description: e.description
238
- }), Y = (e) => {
329
+ }), ae = (e) => {
239
330
  let t = e.split("/").filter((e) => e.length > 0);
240
331
  return t[t.length - 1] ?? e;
241
- }, X = ({ isEnabled: e, isSkillsSupported: t, skills: r, sharedWithMe: a, publicSkills: o, favoriteIds: s, onToggleFavorite: c, labels: u, historyChipLabelClassName: d, renderCatalogContent: f, detailsPanelComponent: p }) => {
242
- let { addMenuLabel: m = "Skills", backLabel: h = "Back", catalogModalTitleLabel: g = "Use skill", emptyQueryHintLabel: _ = "Type to filter", unsupportedTooltipLabel: v = "Selected model does not support skills. Remove the skill or select different model to proceed.", panelLabels: y } = u ?? {}, b = e && t, [ee, C] = D(!1), [w, E] = D(null), [k, A] = D(null), j = T(() => [
243
- ...r,
244
- ...a ?? [],
245
- ...o ?? []
332
+ }, oe = ({ isEnabled: e, isSkillsSupported: t, skills: n, sharedWithMe: r, publicSkills: a, favoriteIds: o, onToggleFavorite: s, labels: c, historyChipLabelClassName: u, renderCatalogContent: d, detailsPanelComponent: f }) => {
333
+ let { addMenuLabel: p = "Skills", backLabel: m = "Back", catalogModalTitleLabel: h = "Use skill", emptyQueryHintLabel: g = "Type to filter", panelLabels: _ } = c ?? {}, v = e && t, [ee, y] = E(!1), [te, S] = E(null), [C, T] = E(0), [ne, O] = E(0), [k, A] = E(void 0), j = re(), N = w(() => [
334
+ ...n,
335
+ ...r ?? [],
336
+ ...a ?? []
246
337
  ], [
338
+ n,
247
339
  r,
248
- a,
249
- o
250
- ]), M = T(() => new Map(j.map((e) => [e.url, e])), [j]), N = T(() => j.filter((e) => s.has(e.url)).map((e) => J(e)), [j, s]), F = T(() => k == null ? null : M.get(k) ?? {
251
- url: k,
252
- name: k
253
- }, [M, k]), I = n(k, t), L = S((e) => {
254
- A(e);
255
- }, []), R = S(() => {
256
- A(null);
257
- }, []), B = k, V = T(() => k == null ? void 0 : [{ url: k }], [k]), te = T(() => F == null ? null : /* @__PURE__ */ P(z, {
258
- name: F.name,
259
- path: F.url,
260
- description: F.description,
261
- isUnsupported: I,
262
- onViewDetails: E,
263
- labels: {
264
- viewDetailsLabel: y?.viewDetailsLabel,
265
- unsupportedTooltipLabel: v
266
- }
267
- }), [
340
+ a
341
+ ]), P = w(() => new Map(N.map((e) => [e.url, e])), [N]), F = x((e) => P.get(e)?.name ?? ae(e), [P]), I = w(() => N.filter((e) => o.has(e.url)).map((e) => ie(e)), [N, o]), R = j.anchors.length > 0 && !t, z = w(() => j.anchors.map((e) => ({
342
+ start: e.start,
343
+ length: e.length,
344
+ isUnsupported: !t,
345
+ render: () => /* @__PURE__ */ M(L, {
346
+ name: e.name,
347
+ path: e.url,
348
+ labelClassName: u,
349
+ description: P.get(e.url)?.description,
350
+ isUnsupported: !t,
351
+ onViewDetails: S,
352
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
353
+ })
354
+ })), [
355
+ j.anchors,
356
+ t,
357
+ P,
358
+ u,
359
+ _
360
+ ]), B = x((e, t, n) => {
361
+ let r = j.insertMention(e, t, n);
362
+ O((e) => e + 1), A(n + 1 + t.length + +!!r);
363
+ }, [j]), V = x(() => {
364
+ j.reset(), O((e) => e + 1), A(void 0);
365
+ }, [j]), U = x((e, t) => {
366
+ j.seedFromMessage(e, t, F), O((e) => e + 1), A(void 0);
367
+ }, [j, F]), W = x((e, t) => {
368
+ if (t == null || t.length === 0) return null;
369
+ let n = J(e, t, F), r = [], i = 0;
370
+ return n.forEach((n) => {
371
+ n.start > i && r.push(e.slice(i, n.start));
372
+ let a = t[n.skillIndex], o = P.get(a.url), s = o?.name ?? ae(a.url);
373
+ r.push(/* @__PURE__ */ M(L, {
374
+ name: s,
375
+ path: a.url,
376
+ labelClassName: u,
377
+ description: o?.description,
378
+ onViewDetails: S,
379
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
380
+ }, `${a.url}-${n.start}`)), i = n.start + n.length;
381
+ }), i < e.length && r.push(e.slice(i)), r;
382
+ }, [
268
383
  F,
269
- I,
270
- y,
271
- v
272
- ]), H = S((e) => e == null || e.length === 0 ? null : e.map((e) => {
273
- let t = M.get(e.url);
274
- return /* @__PURE__ */ P(z, {
275
- name: t?.name ?? Y(e.url),
384
+ P,
385
+ u,
386
+ _
387
+ ]), K = x((e) => e == null || e.length === 0 ? null : e.map((e) => {
388
+ let t = P.get(e.url);
389
+ return /* @__PURE__ */ M(L, {
390
+ name: t?.name ?? ae(e.url),
276
391
  path: e.url,
277
- labelClassName: d,
392
+ labelClassName: u,
278
393
  description: t?.description,
279
- onViewDetails: E,
280
- labels: { viewDetailsLabel: y?.viewDetailsLabel }
394
+ onViewDetails: S,
395
+ labels: { viewDetailsLabel: _?.viewDetailsLabel }
281
396
  }, e.url);
282
397
  }), [
283
- M,
284
- d,
285
- y
286
- ]), W = S((e) => /* @__PURE__ */ P(U, {
287
- favorites: N,
398
+ P,
399
+ u,
400
+ _
401
+ ]), q = x((e, t) => /* @__PURE__ */ M(H, {
402
+ favorites: I,
288
403
  isMenu: !0,
289
- onSelect: (t) => {
290
- L(t.id), e();
404
+ onSelect: (n) => {
405
+ B(n.id, n.name, t), e();
291
406
  },
292
- onToggleFavorite: c,
407
+ onToggleFavorite: s,
293
408
  onBrowse: () => {
294
- e(), C(!0);
409
+ T(t), e(), y(!0);
295
410
  },
296
411
  onViewDetails: (t) => {
297
- e(), E(t.id);
412
+ e(), S(t.id);
298
413
  },
299
- labels: y
414
+ labels: _
300
415
  }), [
301
- N,
302
- L,
303
- c,
304
- y
305
- ]), G = T(() => b ? {
416
+ I,
417
+ B,
418
+ s,
419
+ _
420
+ ]), Y = w(() => v ? {
306
421
  key: "skills",
307
- title: m,
308
- icon: /* @__PURE__ */ P(O, {
422
+ title: p,
423
+ icon: /* @__PURE__ */ M(D, {
309
424
  size: i,
310
425
  "aria-hidden": !0,
311
426
  stroke: l
312
427
  }),
313
- renderOverlay: W,
314
- backLabel: h
428
+ renderOverlay: q,
429
+ backLabel: m
315
430
  } : void 0, [
316
- b,
431
+ v,
432
+ p,
317
433
  m,
318
- h,
319
- W
320
- ]), q = T(() => b ? {
434
+ q
435
+ ]), X = w(() => v ? {
321
436
  triggerPrefix: "/",
322
- menuLabel: m,
323
- emptyQueryHint: _,
324
- renderMenu: ({ query: e, close: t, listboxId: n, activeOptionId: r }) => /* @__PURE__ */ P(U, {
325
- favorites: N,
437
+ menuLabel: p,
438
+ emptyQueryHint: g,
439
+ renderMenu: ({ query: e, caretPosition: t, close: n, listboxId: r, activeOptionId: i }) => /* @__PURE__ */ M(H, {
440
+ favorites: I,
326
441
  searchQuery: e,
327
- listboxId: n,
328
- activeOptionId: r,
442
+ listboxId: r,
443
+ activeOptionId: i,
329
444
  onSelect: (e) => {
330
- t({ consumeQuery: !0 }), L(e.id);
445
+ n({ consumeQuery: !0 }), B(e.id, e.name, t);
331
446
  },
332
- onToggleFavorite: c,
447
+ onToggleFavorite: s,
333
448
  onBrowse: () => {
334
- t({ consumeQuery: !0 }), C(!0);
449
+ n({ consumeQuery: !0 }), T(t), y(!0);
335
450
  },
336
451
  onViewDetails: (e) => {
337
- t({ consumeQuery: !0 }), E(e.id);
452
+ n({ consumeQuery: !0 }), S(e.id);
338
453
  },
339
- labels: y
454
+ labels: _
340
455
  })
341
456
  } : void 0, [
342
- b,
343
- m,
344
- _,
345
- N,
346
- L,
347
- c,
348
- y
457
+ v,
458
+ p,
459
+ g,
460
+ I,
461
+ B,
462
+ s,
463
+ _
349
464
  ]);
350
465
  return e ? {
351
- skillMenuOverlay: G,
352
- commandMenu: q,
353
- skillCatalogModal: /* @__PURE__ */ P(K, {
466
+ skillMenuOverlay: Y,
467
+ commandMenu: X,
468
+ skillCatalogModal: /* @__PURE__ */ M(G, {
354
469
  isOpen: ee,
355
- onClose: () => C(!1),
470
+ onClose: () => y(!1),
356
471
  onSelect: (e) => {
357
- L(e), C(!1);
472
+ B(e, F(e), C), y(!1);
358
473
  },
359
- title: g,
360
- renderContent: f
474
+ title: h,
475
+ renderContent: d
361
476
  }),
362
- skillDetailsPanel: /* @__PURE__ */ P(x, {
477
+ skillDetailsPanel: /* @__PURE__ */ M(b, {
363
478
  fallback: null,
364
- children: /* @__PURE__ */ P(p, {
365
- skillId: w,
366
- onClose: () => E(null)
479
+ children: /* @__PURE__ */ M(f, {
480
+ skillId: te,
481
+ onClose: () => S(null)
367
482
  })
368
483
  }),
369
- selectedSkillElement: te,
370
- selectedSkillPath: B,
371
- selectedSkills: V,
372
- isSkillUnsupported: I,
373
- selectSkill: L,
374
- removeSelectedSkill: R,
375
- renderHistorySkills: H
484
+ message: j.draft,
485
+ messageRevision: ne,
486
+ activeMentions: z,
487
+ onDraftChange: j.onDraftChange,
488
+ onBackspaceAtCaret: j.onBackspaceAtCaret,
489
+ caretPositionOverride: k,
490
+ isSkillUnsupported: R,
491
+ selectedSkills: j.orderedSkills,
492
+ resetSkillMentions: V,
493
+ seedSkillMentions: U,
494
+ renderHistorySkillSegments: W,
495
+ renderHistorySkills: K
376
496
  } : {
377
497
  skillMenuOverlay: void 0,
378
498
  commandMenu: void 0,
379
499
  skillCatalogModal: null,
380
500
  skillDetailsPanel: null,
381
- selectedSkillElement: null,
382
- selectedSkillPath: null,
383
- selectedSkills: void 0,
501
+ message: "",
502
+ messageRevision: 0,
503
+ activeMentions: [],
504
+ onDraftChange: () => void 0,
505
+ onBackspaceAtCaret: () => void 0,
506
+ caretPositionOverride: void 0,
384
507
  isSkillUnsupported: !1,
385
- selectSkill: () => void 0,
386
- removeSelectedSkill: () => void 0,
508
+ selectedSkills: void 0,
509
+ resetSkillMentions: () => void 0,
510
+ seedSkillMentions: () => void 0,
511
+ renderHistorySkillSegments: () => null,
387
512
  renderHistorySkills: () => null
388
513
  };
389
- }, Z = {
514
+ }, $ = {
390
515
  background: "_background_14zdf_1",
391
516
  border: "_border_14zdf_5",
392
517
  value: "_value_14zdf_9",
393
518
  clear: "_clear_14zdf_13",
394
519
  invalid: "_invalid_14zdf_17"
395
- }, ne = [], Q = ({ value: e, onChange: i, displayName: a, favorites: o = ne, onToggleFavorite: s, onViewDetails: c, renderOverlay: d, isSkillsSupported: p, isDisabled: h = !1, isInvalid: g = !1, labelledById: _, describedById: y, labels: b, renderCatalogContent: x, className: S, styles: w }) => {
396
- let [T, O] = D(!1), [A, j] = D(!1), [I, R] = D(""), z = E(null), B = C(), V = E(null), te = E(!1), H = n(e, p), W = p && !h, G = T && W, q = A && W, J = () => {
397
- V.current && !V.current.disabled ? V.current.focus() : z.current?.querySelector("button:not(:disabled)")?.focus();
520
+ }, se = [], ce = ({ value: e, onChange: i, displayName: a, favorites: o = se, onToggleFavorite: s, onViewDetails: c, renderOverlay: d, isSkillsSupported: p, isDisabled: h = !1, isInvalid: g = !1, labelledById: _, describedById: ee, labels: y, renderCatalogContent: b, className: x, styles: C }) => {
521
+ let [w, D] = E(!1), [O, k] = E(!1), [P, I] = E(""), L = T(null), R = S(), z = T(null), B = T(!1), V = n(e, p), U = p && !h, W = w && U, K = O && U, q = () => {
522
+ z.current && !z.current.disabled ? z.current.focus() : L.current?.querySelector("button:not(:disabled)")?.focus();
398
523
  };
399
- ee(() => {
400
- te.current && !G && !q && ((document.activeElement === document.body || z.current?.contains(document.activeElement)) && J(), O(!1), j(!1)), te.current = G || q;
401
- }, [G, q]);
402
- let Y = (e) => {
403
- e && !W || (R(""), O(e));
404
- }, X = (e) => {
405
- W && i(e), O(!1), j(!1);
406
- }, Q = {
524
+ te(() => {
525
+ B.current && !W && !K && ((document.activeElement === document.body || L.current?.contains(document.activeElement)) && q(), D(!1), k(!1)), B.current = W || K;
526
+ }, [W, K]);
527
+ let J = (e) => {
528
+ e && !U || (I(""), D(e));
529
+ }, Y = (e) => {
530
+ U && i(e), D(!1), k(!1);
531
+ }, X = {
407
532
  ...t({
408
- "--ssf-text": w?.colors?.text,
409
- "--ssf-bg": w?.colors?.background,
410
- "--ssf-border": w?.colors?.border,
411
- "--ssf-error": w?.colors?.error
533
+ "--ssf-text": C?.colors?.text,
534
+ "--ssf-bg": C?.colors?.background,
535
+ "--ssf-border": C?.colors?.border,
536
+ "--ssf-error": C?.colors?.error
412
537
  }),
413
- ...w?.cssVars
414
- }, $ = /* @__PURE__ */ F("div", {
415
- id: B,
538
+ ...C?.cssVars
539
+ }, Z = /* @__PURE__ */ N("div", {
540
+ id: R,
416
541
  className: "w-full min-w-0",
417
- children: [/* @__PURE__ */ P("div", {
542
+ children: [/* @__PURE__ */ M("div", {
418
543
  className: "p-2",
419
- children: /* @__PURE__ */ P(v, {
420
- value: I,
421
- onChange: (e) => R(e ?? ""),
422
- placeholder: b.searchPlaceholder ?? "Search skills",
423
- "aria-label": b.searchPlaceholder ?? "Search skills",
424
- clearLabel: b.clearSearchLabel ?? "Clear search"
544
+ children: /* @__PURE__ */ M(v, {
545
+ value: P,
546
+ onChange: (e) => I(e ?? ""),
547
+ placeholder: y.searchPlaceholder ?? "Search skills",
548
+ "aria-label": y.searchPlaceholder ?? "Search skills",
549
+ clearLabel: y.clearSearchLabel ?? "Clear search"
425
550
  })
426
- }), /* @__PURE__ */ P(U, {
551
+ }), /* @__PURE__ */ M(H, {
427
552
  className: "min-w-0 desktop:w-full",
428
553
  rowClassName: "min-h-11",
429
554
  favorites: o,
430
- searchQuery: I,
431
- labels: b.panelLabels,
432
- onSelect: (e) => X(e.id),
555
+ searchQuery: P,
556
+ labels: y.panelLabels,
557
+ onSelect: (e) => Y(e.id),
433
558
  onToggleFavorite: s,
434
559
  onViewDetails: c ? (e) => {
435
- O(!1), c(e);
560
+ D(!1), c(e);
436
561
  } : void 0,
437
562
  onBrowse: () => {
438
- O(!1), j(!0);
563
+ D(!1), k(!0);
439
564
  }
440
565
  })]
441
- }), re = /* @__PURE__ */ P(m, {
442
- inputRef: V,
566
+ }), Q = /* @__PURE__ */ M(m, {
567
+ inputRef: z,
443
568
  readOnly: !0,
444
569
  role: "combobox",
445
570
  "aria-haspopup": "dialog",
446
- "aria-expanded": G,
447
- "aria-controls": G ? B : void 0,
571
+ "aria-expanded": W,
572
+ "aria-controls": W ? R : void 0,
448
573
  "aria-labelledby": _,
449
- "aria-describedby": y,
450
- "aria-invalid": g || H,
451
- disabled: !W,
452
- invalid: g || H,
574
+ "aria-describedby": ee,
575
+ "aria-invalid": g || V,
576
+ disabled: !U,
577
+ invalid: g || V,
453
578
  value: e ? a || e : "",
454
- placeholder: b.placeholder,
455
- title: p ? e ? a || e : void 0 : b.unsupportedTooltipLabel,
579
+ placeholder: y.placeholder,
580
+ title: p ? e ? a || e : void 0 : y.unsupportedTooltipLabel,
456
581
  containerClassName: "w-full min-w-0",
457
- wrapperClassName: r("cursor-pointer", "--ssf-bg" in Q && Z.background, "--ssf-border" in Q && Z.border, (g || H) && Z.invalid, w?.triggerClassName),
458
- className: r("min-w-0 cursor-pointer text-ellipsis", "--ssf-text" in Q && Z.value, w?.typography?.fontClassName ?? "dial-small-text"),
582
+ wrapperClassName: r("cursor-pointer", "--ssf-bg" in X && $.background, "--ssf-border" in X && $.border, (g || V) && $.invalid, C?.triggerClassName),
583
+ className: r("min-w-0 cursor-pointer text-ellipsis", "--ssf-text" in X && $.value, C?.typography?.fontClassName ?? "dial-small-text"),
459
584
  onKeyDown: (e) => {
460
585
  [
461
586
  "Enter",
462
587
  " ",
463
588
  "ArrowDown"
464
- ].includes(e.key) ? (e.preventDefault(), e.stopPropagation(), Y(e.key === "ArrowDown" || !G)) : e.key === "Escape" && Y(!1);
589
+ ].includes(e.key) ? (e.preventDefault(), e.stopPropagation(), J(e.key === "ArrowDown" || !W)) : e.key === "Escape" && J(!1);
465
590
  },
466
- iconAfter: /* @__PURE__ */ F("span", {
591
+ iconAfter: /* @__PURE__ */ N("span", {
467
592
  className: "flex shrink-0 items-center",
468
- children: [e && /* @__PURE__ */ P(f, {
593
+ children: [e && /* @__PURE__ */ M(f, {
469
594
  type: "button",
470
- className: r("size-11 shrink-0", Z.clear),
595
+ className: r("size-11 shrink-0", $.clear),
471
596
  disabled: h,
472
- "aria-label": b.removeSkillLabel,
597
+ "aria-label": y.removeSkillLabel,
473
598
  onKeyDown: (e) => e.stopPropagation(),
474
599
  onClick: (e) => {
475
- e.stopPropagation(), i(void 0), O(!1), W ? V.current?.focus() : z.current?.focus();
600
+ e.stopPropagation(), i(void 0), D(!1), U ? z.current?.focus() : L.current?.focus();
476
601
  },
477
- iconBefore: /* @__PURE__ */ P(M, {
602
+ iconBefore: /* @__PURE__ */ M(A, {
478
603
  "aria-hidden": !0,
479
604
  size: 18,
480
605
  stroke: l
481
606
  })
482
- }), /* @__PURE__ */ P(k, {
607
+ }), /* @__PURE__ */ M(ne, {
483
608
  "aria-hidden": !0,
484
609
  size: 20,
485
610
  stroke: l,
486
- className: r("transition-transform", G && "rotate-180")
611
+ className: r("transition-transform", W && "rotate-180")
487
612
  })]
488
613
  })
489
614
  });
490
- return /* @__PURE__ */ F("div", {
491
- ref: z,
615
+ return /* @__PURE__ */ N("div", {
616
+ ref: L,
492
617
  role: "group",
493
618
  "aria-labelledby": _,
494
619
  tabIndex: -1,
495
- className: r("min-w-0", S, L.selectorField),
496
- style: Q,
497
- children: [d ? /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P("div", {
620
+ className: r("min-w-0", x, F.selectorField),
621
+ style: X,
622
+ children: [d ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("div", {
498
623
  className: "w-full min-w-0",
499
- onClick: () => Y(!G),
500
- children: re
501
- }), d($, G, () => Y(!1))] }) : /* @__PURE__ */ P(u, {
502
- open: G,
503
- onOpenChange: Y,
504
- disabled: !W,
624
+ onClick: () => J(!W),
625
+ children: Q
626
+ }), d(Z, W, () => J(!1))] }) : /* @__PURE__ */ M(u, {
627
+ open: W,
628
+ onOpenChange: J,
629
+ disabled: !U,
505
630
  className: "w-full min-w-0",
506
631
  listClassName: "w-[min(var(--reference-width),calc(100vw-2rem))] max-w-full",
507
- renderOverlay: () => /* @__PURE__ */ P("div", {
632
+ renderOverlay: () => /* @__PURE__ */ M("div", {
508
633
  role: "dialog",
509
634
  "aria-labelledby": _,
510
- children: $
635
+ children: Z
511
636
  }),
512
637
  initialFocus: 0,
513
- children: re
514
- }), q && /* @__PURE__ */ P(K, {
638
+ children: Q
639
+ }), K && /* @__PURE__ */ M(G, {
515
640
  isOpen: !0,
516
- onClose: () => j(!1),
517
- title: b.modalTitle,
518
- onSelect: X,
519
- renderContent: x
641
+ onClose: () => k(!1),
642
+ title: y.modalTitle,
643
+ onSelect: Y,
644
+ renderContent: b
520
645
  })]
521
646
  });
522
647
  };
523
648
  //#endregion
524
- export { z as ChatSkill, U as FavoriteSkillsPanel, L as SKILLS_CLASS, G as SkillArchiveUploadDialog, K as SkillCatalogModal, q as SkillDetailsSidePanel, R as SkillInfoTooltipContent, Q as SkillSelectorField, J as buildFavoriteSkillItem, X as useSkillSelectorOverlay };
649
+ export { L as ChatSkill, H as FavoriteSkillsPanel, F as SKILLS_CLASS, W as SkillArchiveUploadDialog, G as SkillCatalogModal, K as SkillDetailsSidePanel, I as SkillInfoTooltipContent, ce as SkillSelectorField, ie as buildFavoriteSkillItem, Y as diffTextChange, Q as findMentionAtCaret, ae as getSkillFallbackName, Z as insertAnchor, J as matchSkillMentions, X as reconcileAnchors, re as useSkillMentions, oe as useSkillSelectorOverlay };