@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.
@@ -0,0 +1,12 @@
1
+ /** A skill mention's location within the current plain-text draft. */
2
+ export interface SkillMentionAnchor {
3
+ /** The mentioned skill's resource URL — the value sent as this entry's `{ url }`. */
4
+ url: string;
5
+ /** Display name at the time of insertion (`/${name}` is what actually sits in the text). */
6
+ name: string;
7
+ /** Character offset of the leading `/` in the current draft string. */
8
+ start: number;
9
+ /** Length of the `/{name}` run, `1 + name.length`. */
10
+ length: number;
11
+ }
12
+ //# sourceMappingURL=skill-mention-anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-mention-anchor.d.ts","sourceRoot":"","sources":["../../src/models/skill-mention-anchor.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -1,5 +1,5 @@
1
1
  import { RequestSkill } from '@epam/ai-dial-chat-shared';
2
- import { CommandMenuConfig, MenuOverlayConfig } from '@epam/ai-dial-conversation-input';
2
+ import { CommandMenuConfig, HighlightedTextRange, MenuOverlayConfig } from '@epam/ai-dial-conversation-input';
3
3
  import { ComponentType, ReactNode } from 'react';
4
4
  import { SkillListingEntry } from './favorite-skill-item';
5
5
  import { FavoriteSkillsPanelLabels } from './favorite-skills-panel-props';
@@ -28,11 +28,6 @@ export interface SkillSelectorOverlayLabels {
28
28
  * is open with an empty query. Defaults to `'Type to filter'`.
29
29
  */
30
30
  emptyQueryHintLabel?: string;
31
- /**
32
- * Message shown alone in the selected skill chip's error-state tooltip
33
- * while the current deployment does not support skills.
34
- */
35
- unsupportedTooltipLabel?: string;
36
31
  /** Labels forwarded to the favorites panel rendered as the overlay. */
37
32
  panelLabels?: FavoriteSkillsPanelLabels;
38
33
  }
@@ -46,9 +41,13 @@ export interface UseSkillSelectorOverlayOptions {
46
41
  /**
47
42
  * Whether the input's current deployment supports skills. While `false`
48
43
  * (with the flow enabled) the entry points are omitted — no Add-menu item
49
- * and no slash menu — but an already-selected skill chip stays rendered in
50
- * its error state with its removal gesture and "View details" panel
51
- * available. The host resolves this from its own deployment data.
44
+ * and no slash menu — but a tracked mention stays in the draft text and
45
+ * folds into `isSkillUnsupported` for the host's own send-disabled
46
+ * condition. The host resolves this from its own deployment data. Note: a
47
+ * live-composing mention has no per-mention error styling of its own (it
48
+ * renders as a plain highlighted run, not a `ChatSkill`); only the sent
49
+ * `custom_content.skills`/history rendering, and this boolean fold, reflect
50
+ * the unsupported state.
52
51
  */
53
52
  isSkillsSupported: boolean;
54
53
  /** The user's own skills. */
@@ -84,18 +83,18 @@ export interface UseSkillSelectorOverlayOptions {
84
83
  export interface UseSkillSelectorOverlayResult {
85
84
  /**
86
85
  * The Skills entry for the `menuOverlays` prop of
87
- * `ConversationInput`/`Input`. `undefined` while the flow is disabled or the
88
- * current deployment does not support skills: the host omits the entry
89
- * entirely when this is `undefined`, so a stub renderer would leave the
90
- * menu item in place with nothing behind it.
86
+ * `ConversationInput`/`EditMessageInput`/`Input`. `undefined` while the flow
87
+ * is disabled or the current deployment does not support skills: the host
88
+ * omits the entry entirely when this is `undefined`, so a stub renderer
89
+ * would leave the menu item in place with nothing behind it.
91
90
  */
92
91
  skillMenuOverlay?: MenuOverlayConfig;
93
92
  /**
94
93
  * The Skills entry for the `commandMenu` prop of
95
- * `ConversationInput`/`Input`: typing `/` into an empty textarea opens the
96
- * favorites panel in search mode above the input. `undefined` while the
97
- * flow is disabled or the current deployment does not support skills,
98
- * disabling the slash menu entirely.
94
+ * `ConversationInput`/`EditMessageInput`/`Input`: typing `/` into an empty
95
+ * textarea opens the favorites panel in search mode above the input.
96
+ * `undefined` while the flow is disabled or the current deployment does not
97
+ * support skills, disabling the slash menu entirely.
99
98
  */
100
99
  commandMenu?: CommandMenuConfig;
101
100
  /**
@@ -109,55 +108,102 @@ export interface UseSkillSelectorOverlayResult {
109
108
  */
110
109
  skillDetailsPanel: ReactNode;
111
110
  /**
112
- * The selected skill as a `ChatSkill` element for the conversation input's
113
- * `inlineStartSlot` — at most one, replaced on every selection, carrying
114
- * the shared tooltip (the listing-sourced description, same as the favorite
115
- * rows), or the error state while the current deployment does not support
116
- * skills. The element has no remove control of its own; removal is the
117
- * input's Backspace-at-start gesture, wired through `removeSelectedSkill`.
118
- * `null` while `isEnabled` is `false` or nothing is selected.
111
+ * The composer's message text after the most recent skill selection, with
112
+ * every `/{name}` mention spliced in. Pass straight through to
113
+ * `ConversationInput`/`EditMessageInput`'s own `message` prop alongside
114
+ * `messageRevision` — like that prop's existing "populated by a starter
115
+ * selection" use, this is a one-shot push applied on a `messageRevision`
116
+ * bump, not a value the host feeds back on every keystroke (ordinary typing
117
+ * is tracked separately through `onDraftChange`).
119
118
  */
120
- selectedSkillElement: ReactNode;
119
+ message: string;
121
120
  /**
122
- * Whether a skill is selected while the current deployment does not
123
- * support skills — the chip renders in its error state and hosts must fold
124
- * this into their send-disabled conditions. Always `false` while
125
- * `isEnabled` is `false`.
121
+ * Token that forces `message` to re-apply even when its string value is
122
+ * unchanged from the last push (e.g. the same skill selected again).
123
+ * Bumped on every call to the selection handlers backing `skillMenuOverlay`
124
+ * and `commandMenu`. Pass straight through to the composer's own
125
+ * `messageRevision` prop.
126
126
  */
127
- isSkillUnsupported: boolean;
127
+ messageRevision: number;
128
128
  /**
129
- * The selected skill's resource URL (`skills/{bucket}/{path}`) — the value
130
- * the host sends as a `{ url }` entry in the outgoing message's
131
- * `custom_content.skills`. `null` while nothing is selected or the flow is
132
- * disabled.
129
+ * Every currently-tracked skill mention's character range within the
130
+ * composer's live draft text, for `ConversationInput`/`EditMessageInput`/
131
+ * `Input`'s `activeMentions` prop (the live-composing highlighted-run
132
+ * render). Empty while nothing is mentioned or the flow is disabled.
133
133
  */
134
- selectedSkillPath: string | null;
134
+ activeMentions: HighlightedTextRange[];
135
135
  /**
136
- * The selected skill as the send-time `custom_content.skills` payload —
137
- * `[{ url: selectedSkillPath }]`, or `undefined` while nothing is selected
138
- * or the flow is disabled, so `custom_content.skills` is omitted entirely.
136
+ * Reconciles tracked mentions against an external edit to the composer's
137
+ * draft text (ordinary typing, deleting, pasting, undo/redo). Wire to the
138
+ * composer's own `onChange` callback, in addition to whatever the host
139
+ * already does with that value — this keeps `activeMentions`/
140
+ * `selectedSkills` in sync with live edits between selections.
139
141
  */
140
- selectedSkills: RequestSkill[] | undefined;
142
+ onDraftChange: (nextValue: string) => void;
143
+ /**
144
+ * Looks up the mention whose run ends exactly at `caretPosition`, without
145
+ * mutating any state. Pass straight through to the composer's
146
+ * `onBackspaceAtCaret` prop, which performs the actual whole-mention
147
+ * deletion through the textarea's native editing pipeline and reports the
148
+ * result back through `onDraftChange`. Returns `undefined` when the caret
149
+ * isn't at a mention boundary.
150
+ */
151
+ onBackspaceAtCaret: (caretPosition: number) => HighlightedTextRange | undefined;
141
152
  /**
142
- * Selects a skill by its resource URL (`skills/{bucket}/{path}`), replacing
143
- * any prior selection.
153
+ * Caret offset to place the cursor at immediately after the most recent
154
+ * skill selection applies `message`/`messageRevision` — the position right
155
+ * after the inserted mention's text. Pass straight through to the
156
+ * composer's `caretPositionOverride` prop. `undefined` before any selection
157
+ * has been made this session.
144
158
  */
145
- selectSkill: (skillId: string) => void;
159
+ caretPositionOverride: number | undefined;
146
160
  /**
147
- * Clears the selected skill. Wire to the input's `onInlineStartRemove` —
148
- * Backspace with the caret collapsed at position 0 while the selected
149
- * skill's element is shown.
161
+ * Whether at least one skill is mentioned while the current deployment does
162
+ * not support skills — hosts must fold this into their send-disabled
163
+ * conditions. Always `false` while `isEnabled` is `false`.
150
164
  */
151
- removeSelectedSkill: () => void;
165
+ isSkillUnsupported: boolean;
166
+ /**
167
+ * Every currently-tracked mention as the send-time `custom_content.skills`
168
+ * payload, in left-to-right text order — `undefined` while nothing is
169
+ * mentioned or the flow is disabled, so `custom_content.skills` is omitted
170
+ * entirely. Cleared to `undefined` by `resetSkillMentions` after a
171
+ * successful send.
172
+ */
173
+ selectedSkills: RequestSkill[] | undefined;
152
174
  /**
153
- * Renders a message's `custom_content.skills` entries as `ChatSkill`
154
- * elements beside the message bubble's first text line, with the text
155
- * word-flowing after them — one per entry, sharing the "View details"
156
- * details panel with the favorite rows and the input chip. Each entry's
157
- * name comes from the listing pools matched on its url, falling back to
158
- * the url's last non-empty segment, and its description from the same
159
- * match (absent when no pool carries the url). Returns `null` while
160
- * `isEnabled` is `false` or the array is empty.
175
+ * Clears every tracked mention and the draft text alongside it. Call after
176
+ * a successful send, matching the per-message selection-clears semantics of
177
+ * `custom_content.skills`.
178
+ */
179
+ resetSkillMentions: () => void;
180
+ /**
181
+ * Seeds the draft and its tracked mentions from a persisted message — runs
182
+ * `matchSkillMentions` once against `content`/`skills` and initializes
183
+ * `message`/`activeMentions` from the result (bumping `messageRevision`).
184
+ * Call once when entering edit mode on a message that carries
185
+ * `custom_content.skills`.
186
+ */
187
+ seedSkillMentions: (content: string, skills: RequestSkill[] | undefined) => void;
188
+ /**
189
+ * Renders a user message's `content` and `custom_content.skills` as an
190
+ * ordered array interleaving plain-text runs and `ChatSkill` elements at
191
+ * each mention's actual text position — for `UserMessageBubble`'s
192
+ * `textSegments` prop. Resolves each entry's name from the listing pools
193
+ * matched on its url, falling back to the url's last non-empty segment,
194
+ * sharing the "View details" panel with the favorite rows. Returns `null`
195
+ * while `isEnabled` is `false` or `skills` is empty/absent; a mention
196
+ * `matchSkillMentions` cannot locate in `content` is simply omitted from
197
+ * the render (see `matchSkillMentions`'s own doc for that heuristic).
198
+ */
199
+ renderHistorySkillSegments: (content: string, skills: RequestSkill[] | undefined) => ReactNode[] | null;
200
+ /**
201
+ * Renders every entry of `skills` as a flat list of `ChatSkill` elements,
202
+ * ignoring text position — for `AssistantMessageBubble`'s `beforeContent`
203
+ * slot, since assistant text is model-generated markdown and never
204
+ * authors positioned mentions. Each entry's name/description resolve the
205
+ * same way as `renderHistorySkillSegments`. Returns `null` while
206
+ * `isEnabled` is `false` or the array is empty/absent.
161
207
  */
162
208
  renderHistorySkills: (skills: RequestSkill[] | undefined) => ReactNode;
163
209
  }
@@ -1 +1 @@
1
- {"version":3,"file":"skill-selector-overlay.d.ts","sourceRoot":"","sources":["../../src/models/skill-selector-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uEAAuE;IACvE,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,qDAAqD;AACrD,MAA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G;IACH,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC;;;;;;;;;OASG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAAK,SAAS,CAAC;CACxE"}
1
+ {"version":3,"file":"skill-selector-overlay.d.ts","sourceRoot":"","sources":["../../src/models/skill-selector-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,qDAAqD;AACrD,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;OAUG;IACH,iBAAiB,EAA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;;OAMG;IACH,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,cAAc,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IAC3C;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAC/B,IAAI,CAAC;IACV;;;;;;;;;;OAUG;IACH,0BAA0B,EAAE,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAC/B,SAAS,EAAE,GAAG,IAAI,CAAC;IACxB;;;;;;;OAOG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAAK,SAAS,CAAC;CACxE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-skills",
3
3
  "description": "Host-agnostic UI for picking a favorite skill to attach to a chat input",
4
- "version": "1.2.0-dev.141",
4
+ "version": "1.2.0-dev.142",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@tabler/icons-react": "^3.44.0",
21
- "@epam/ai-dial-catalog": "1.2.0-dev.141",
22
- "@epam/ai-dial-conversation-input": "1.2.0-dev.141"
21
+ "@epam/ai-dial-catalog": "1.2.0-dev.142",
22
+ "@epam/ai-dial-conversation-input": "1.2.0-dev.142"
23
23
  },
24
24
  "peerDependencies": {
25
- "@epam/ai-dial-chat-shared": "1.2.0-dev.141",
25
+ "@epam/ai-dial-chat-shared": "1.2.0-dev.142",
26
26
  "@epam/ai-dial-ui-kit": "^0.15.0-dev.18",
27
27
  "react": "^19.2.8"
28
28
  },
@@ -0,0 +1,25 @@
1
+ import { RequestSkill } from '@epam/ai-dial-chat-shared';
2
+ /** One resolved mention location, or omitted for a skill whose text mention could not be found. */
3
+ export interface ResolvedSkillMention {
4
+ /** Index into the input `skills` array this location resolves. */
5
+ skillIndex: number;
6
+ /** Character offset of the leading `/` in `text`. */
7
+ start: number;
8
+ /** Length of the matched `/{name}` run. */
9
+ length: number;
10
+ }
11
+ /**
12
+ * Matches each entry of `skills` (in array order) to the next available
13
+ * `/{name}` occurrence in `text`, where `name` is that entry's display name
14
+ * resolved via `resolveName(url)` — the current listing name, falling back to
15
+ * the url's last path segment (`getSkillFallbackName`). Scans left to right,
16
+ * consuming text as it goes, so two skills with the same resolved name are
17
+ * still matched to distinct, successive occurrences in the text. A skill
18
+ * whose exact `/{name}` cannot be found at or after the current scan position
19
+ * (e.g. the user's later edit broke the mention) is omitted from the result —
20
+ * it still counts as a real `custom_content.skills` entry for sending, it
21
+ * simply renders nowhere in particular, and later entries still get their own
22
+ * independent forward search from the same unmoved cursor.
23
+ */
24
+ export declare const matchSkillMentions: (text: string, skills: RequestSkill[], resolveName: (url: string) => string) => ResolvedSkillMention[];
25
+ //# sourceMappingURL=skill-mention-matching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-mention-matching.d.ts","sourceRoot":"","sources":["../../src/utils/skill-mention-matching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,mGAAmG;AACnG,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,QAAQ,YAAY,EAAE,EACtB,aAAa,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KACnC,oBAAoB,EA0BtB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { SkillMentionAnchor } from '../models/skill-mention-anchor';
2
+ /** A single-region text edit, expressed as the replaced range in the previous string. */
3
+ export interface TextChange {
4
+ /** Character offset where the previous and next strings first diverge. */
5
+ start: number;
6
+ /** Number of characters removed from the previous string at `start`. */
7
+ deletedLength: number;
8
+ /** Number of characters inserted at `start` in the next string. */
9
+ insertedLength: number;
10
+ }
11
+ /**
12
+ * Diffs two strings produced by a single-cursor edit (typing, deleting,
13
+ * pasting, cutting, undo/redo) via their common prefix and common suffix —
14
+ * cheap (O(n)) and exact for that class of edit, which is everything a
15
+ * textarea actually produces.
16
+ */
17
+ export declare const diffTextChange: (previous: string, next: string) => TextChange;
18
+ /**
19
+ * Applies a text change to a set of tracked mention anchors: an anchor
20
+ * entirely before the edited region is untouched, one entirely after is
21
+ * shifted by the edit's length delta, and one that overlaps the edited region
22
+ * is dropped — the user edited into the middle of a mention, so it reverts to
23
+ * plain text and no longer contributes a `custom_content.skills` entry.
24
+ */
25
+ export declare const reconcileAnchors: (anchors: SkillMentionAnchor[], change: TextChange) => SkillMentionAnchor[];
26
+ /**
27
+ * Inserts a new mention anchor at `atIndex` and shifts every anchor at or
28
+ * after that index by the inserted `/{name}` run's length — plus one more
29
+ * when `hasTrailingSpace` — keeping the result ordered by `start`
30
+ * (left-to-right reading order).
31
+ */
32
+ export declare const insertAnchor: (anchors: SkillMentionAnchor[], atIndex: number, url: string, name: string, hasTrailingSpace: boolean) => SkillMentionAnchor[];
33
+ /**
34
+ * Finds the anchor whose mention run ends exactly at `caretPosition` — the
35
+ * caret sitting immediately after that mention — or `undefined` if none does.
36
+ * Used to detect the whole-mention Backspace gesture.
37
+ */
38
+ export declare const findMentionAtCaret: (anchors: SkillMentionAnchor[], caretPosition: number) => SkillMentionAnchor | undefined;
39
+ //# sourceMappingURL=skill-mention-tracking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-mention-tracking.d.ts","sourceRoot":"","sources":["../../src/utils/skill-mention-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,MAAM,MAAM,KAAG,UAyB/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,kBAAkB,EAAE,EAC7B,QAAQ,UAAU,KACjB,kBAAkB,EAmBpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,kBAAkB,EAAE,EAC7B,SAAS,MAAM,EACf,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,kBAAkB,OAAO,KACxB,kBAAkB,EAkBpB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,kBAAkB,EAAE,EAC7B,eAAe,MAAM,KACpB,kBAAkB,GAAG,SACkD,CAAC"}