@epam/ai-dial-skills 1.2.0-dev.15 → 1.2.0-dev.153

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