@aintela/chat 0.2.59 → 0.3.1

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 (109) hide show
  1. package/README.md +77 -0
  2. package/dist/{ClientMessage-EKgfuTp8.js → ClientMessage-DUby3KyC.js} +16 -22
  3. package/dist/{ClientMessage-EKgfuTp8.js.map → ClientMessage-DUby3KyC.js.map} +1 -1
  4. package/dist/Memory-CjrYSkzB.js +47 -0
  5. package/dist/Memory-CjrYSkzB.js.map +1 -0
  6. package/dist/atMentions-CnHuJKhX.js +959 -0
  7. package/dist/atMentions-CnHuJKhX.js.map +1 -0
  8. package/dist/components.js +10161 -11344
  9. package/dist/components.js.map +1 -1
  10. package/dist/environmentUtils-VZNTCzEE.js +88 -0
  11. package/dist/environmentUtils-VZNTCzEE.js.map +1 -0
  12. package/dist/hooks.js +4 -5
  13. package/dist/{httpArtifactService-CpbRpTHb.js → httpArtifactService-Ba9xFy1E.js} +537 -646
  14. package/dist/httpArtifactService-Ba9xFy1E.js.map +1 -0
  15. package/dist/{httpSessionService-BEQMIKfv.js → httpSessionService-DXlT2vxT.js} +34 -24
  16. package/dist/httpSessionService-DXlT2vxT.js.map +1 -0
  17. package/dist/index.js +242 -243
  18. package/dist/models.js +48 -51
  19. package/dist/models.js.map +1 -1
  20. package/dist/serializer-D2W42bdT.js +1730 -0
  21. package/dist/serializer-D2W42bdT.js.map +1 -0
  22. package/dist/services.js +2 -2
  23. package/dist/src/components/AiChat/AiChatContext.d.ts +0 -3
  24. package/dist/src/components/AiChat/AiChatProvider.agent.test.d.ts +1 -0
  25. package/dist/src/components/AiChat/AiChatProvider.d.ts +2 -2
  26. package/dist/src/components/AiChat/AiChatTypes.d.ts +45 -27
  27. package/dist/src/components/AiChat/ChatPane/ChatPane.test.d.ts +1 -0
  28. package/dist/src/components/AiChat/ChatPane/MessageAgent.d.ts +0 -1
  29. package/dist/src/components/AiChat/ChatPane/MessagePart.d.ts +5 -3
  30. package/dist/src/components/AiChat/ChatPane/MessagePart.test.d.ts +1 -0
  31. package/dist/src/components/AiChat/ChatPane/friendlyToolConfig.test.d.ts +1 -0
  32. package/dist/src/components/AiChat/ChatPane/messageAgentThoughts.test.d.ts +1 -0
  33. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRun.d.ts +28 -0
  34. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  35. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +5 -1
  36. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  37. package/dist/src/components/AiChat/ChatPane/parts/uiToolDispatcher.test.d.ts +1 -0
  38. package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.test.d.ts +1 -0
  39. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  40. package/dist/src/components/AiChat/index.d.ts +1 -3
  41. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  42. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  43. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  44. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  45. package/dist/src/components/index.d.ts +4 -7
  46. package/dist/src/components/v2/AiChatFloating.d.ts +3 -0
  47. package/dist/src/components/v2/PromptV2.d.ts +21 -6
  48. package/dist/src/components/v2/PromptV2.test.d.ts +1 -0
  49. package/dist/src/components/v2/icons.d.ts +1 -0
  50. package/dist/src/components/v2/index.d.ts +25 -25
  51. package/dist/src/hooks/index.d.ts +1 -1
  52. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  53. package/dist/src/models/ArtifactData.d.ts +0 -7
  54. package/dist/src/models/ChatSession.d.ts +0 -32
  55. package/dist/src/models/ClientMessage.d.ts +0 -4
  56. package/dist/src/models/ServerEvent.d.ts +0 -36
  57. package/dist/src/models/enums.d.ts +0 -1
  58. package/dist/src/models/index.d.ts +1 -2
  59. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  60. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  61. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  62. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  63. package/dist/src/services/interactionService.d.ts +11 -0
  64. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  65. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  66. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  67. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  68. package/dist/src/services/storageService.d.ts +34 -59
  69. package/dist/src/services/storageService.test.d.ts +1 -0
  70. package/dist/src/utils/index.d.ts +2 -6
  71. package/dist/src/utils/urlParser.d.ts +0 -1
  72. package/dist/src/utils/urlParser.test.d.ts +1 -0
  73. package/dist/tests/fakes/fakeChatServices.d.ts +42 -0
  74. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  75. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  76. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  77. package/dist/{useChatSessions-BQP7DhY1.js → useChatSessions-1AAvAdPW.js} +2 -2
  78. package/dist/{useChatSessions-BQP7DhY1.js.map → useChatSessions-1AAvAdPW.js.map} +1 -1
  79. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  80. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  81. package/dist/utils.js +340 -57
  82. package/dist/utils.js.map +1 -1
  83. package/package.json +1 -1
  84. package/dist/Memory-DjLZqgbF.js +0 -84
  85. package/dist/Memory-DjLZqgbF.js.map +0 -1
  86. package/dist/atMentions-C0dza8DD.js +0 -1000
  87. package/dist/atMentions-C0dza8DD.js.map +0 -1
  88. package/dist/auth-lluJZyQO.js +0 -524
  89. package/dist/auth-lluJZyQO.js.map +0 -1
  90. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  91. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  92. package/dist/httpArtifactService-CpbRpTHb.js.map +0 -1
  93. package/dist/httpSessionService-BEQMIKfv.js.map +0 -1
  94. package/dist/serializer-BXSH9aYQ.js +0 -1360
  95. package/dist/serializer-BXSH9aYQ.js.map +0 -1
  96. package/dist/src/components/AiChat/AiChatFloating.d.ts +0 -3
  97. package/dist/src/components/AiChat/ChatPane/LastPrompts.d.ts +0 -9
  98. package/dist/src/components/AiChat/ChatPane/Prompt.d.ts +0 -9
  99. package/dist/src/components/AiChat/ChatPane/SubAgentBox.d.ts +0 -9
  100. package/dist/src/components/AiChat/ChatPane/TaskList.d.ts +0 -6
  101. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  102. package/dist/src/components/v2/AiChatFloatingV2.d.ts +0 -3
  103. package/dist/src/utils/jsonDetector.d.ts +0 -50
  104. package/dist/src/utils/jsonUtils.d.ts +0 -1
  105. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  106. package/dist/src/utils/objectUtils.d.ts +0 -31
  107. package/dist/src/utils/parseArtifact.d.ts +0 -3
  108. package/dist/src/utils/uriUtils.d.ts +0 -39
  109. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -1,1000 +0,0 @@
1
- var $ = Object.defineProperty;
2
- var d = (o, e) => $(o, "name", { value: e, configurable: !0 });
3
- const F = /* @__PURE__ */ d((o) => {
4
- if (o[0] == "#")
5
- return null;
6
- const e = o.split("/");
7
- let t = e[e.length - 1];
8
- if (t == "" && e.length > 1 && (t = e[e.length - 2]), t == "")
9
- return null;
10
- const r = t.split("?")[0];
11
- return r.startsWith("#") ? r : r.split("#")[0];
12
- }, "parseAndValidateArtifactUrl"), _ = /* @__PURE__ */ d((o, e, t) => {
13
- let r = "URL", n = null, i = null, s = null;
14
- if (o[0] == "#") {
15
- const a = o.indexOf("-"), l = o.slice(1, a);
16
- switch (s = o.slice(a + 1), l.toLowerCase()) {
17
- case "opendashboard":
18
- r = "OpenDashboard";
19
- break;
20
- case "ask":
21
- r = "Question", n = t;
22
- break;
23
- }
24
- } else
25
- o.indexOf("http") > -1 ? (r = "URL", i = o) : (o = o.replaceAll("exported/", `exported/${e}/`), r = "Export");
26
- return { action: r, url: i, question: n, parameter: s };
27
- }, "extractLinkAction"), N = /* @__PURE__ */ d((o, e) => Array.from(
28
- { length: Math.ceil(o.length / e) },
29
- (t, r) => o.slice(r * e, r * e + e)
30
- ), "chunkArray"), z = /* @__PURE__ */ d((o) => {
31
- o = o.replaceAll("\\n", `
32
- `);
33
- const e = 90, t = o.split(" "), r = [];
34
- let n = !1;
35
- for (const i of t)
36
- if (i.length > e) {
37
- n = !0;
38
- const s = [...i], l = N(s, e).map((c) => c.join("")).join(`
39
- `);
40
- r.push(l);
41
- } else
42
- r.push(i);
43
- return n ? r.join(" ") : o;
44
- }, "splitBigLinesWithSpaces");
45
- function I(o) {
46
- let e = parseFloat(o);
47
- if (!isNaN(e))
48
- return o = o.replaceAll(/[,\.]/g, ""), parseInt(o);
49
- var t = "";
50
- for (const n of o)
51
- n.match(/[0-9]/) && (t += n);
52
- const r = t.length / o.length;
53
- return e = parseInt(t), !isNaN(e) && r > 0.5 ? e : NaN;
54
- }
55
- d(I, "parseRawNumber");
56
- function B(o) {
57
- if (!o) return { prefix: void 0, suffix: void 0, number: void 0 };
58
- const e = /[$%(\w?\$)]/gi, t = /[a-z]?\$/gi;
59
- let r = "", n = "";
60
- if (o.match(e)) {
61
- o.indexOf("%") > -1 && (n = " %");
62
- const a = o.match(t);
63
- a && (r = a[0] + " ");
64
- }
65
- let i = parseFloat(o);
66
- if (!isNaN(i))
67
- return o = o.replaceAll(".", "").replaceAll(",", "."), { prefix: r, suffix: n, number: parseFloat(o) };
68
- var s = "";
69
- for (const a of o)
70
- if (a.match(/[0-9.,]/)) {
71
- let l = a;
72
- l == "." ? l = "" : l == "," && (l = "."), s += l;
73
- }
74
- return i = parseFloat(s), isNaN(i) ? { prefix: void 0, suffix: void 0, number: void 0 } : { prefix: r, suffix: n, number: i };
75
- }
76
- d(B, "parseKnownNumbers");
77
- const A = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i, T = /^[0-9a-f]{32}/i;
78
- function P(o) {
79
- if (!o || typeof o != "string")
80
- return !1;
81
- const e = W(o);
82
- return e === null ? !1 : o.startsWith(e);
83
- }
84
- d(P, "startsWithInteractionId");
85
- function W(o) {
86
- if (!o || typeof o != "string")
87
- return null;
88
- const e = o.match(A);
89
- if (e)
90
- return e[0];
91
- const t = o.match(T);
92
- return t ? t[0] : null;
93
- }
94
- d(W, "extractInteractionId");
95
- function V(o) {
96
- const r = o.replaceAll("_", " ").replaceAll("-", " ").replaceAll("user:", "").replace(/\.[^/.]+$/, ""), n = q(r).trim();
97
- return n.length > 1 ? n[0].toUpperCase() + n.slice(1) : n;
98
- }
99
- d(V, "prettiffyFileName");
100
- function U(o) {
101
- if (o.length == 0)
102
- return o;
103
- const e = o.replaceAll("_", " ").replaceAll("-", " ");
104
- return e[0].toUpperCase() + e.slice(1);
105
- }
106
- d(U, "prettiffyPythonFunctionName");
107
- function q(o) {
108
- const e = o.match(A);
109
- if (e)
110
- return o.replace(e[0], "");
111
- const t = o.match(T);
112
- return t ? o.replace(t[0], "") : o;
113
- }
114
- d(q, "extractNameFromStringWithInteractionId");
115
- function X(o) {
116
- return !o || typeof o != "string" ? !1 : !!(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o) || /^[0-9a-f]{32}$/i.test(o));
117
- }
118
- d(X, "isValidInteractionId");
119
- const x = /* @__PURE__ */ new Set(), C = class C {
120
- constructor(e = {}) {
121
- this.options = {
122
- // CSS class for sortable headers
123
- sortableClass: "sortable-header",
124
- // CSS class for active sort
125
- activeSortClass: "active-sort",
126
- // CSS class for ascending sort
127
- ascendingClass: "sort-asc",
128
- // CSS class for descending sort
129
- descendingClass: "sort-desc",
130
- // Icon for unsorted state
131
- unsortedIcon: "unfold_more",
132
- // Icon for ascending sort
133
- ascendingIcon: "keyboard_arrow_up",
134
- // Icon for descending sort
135
- descendingIcon: "keyboard_arrow_down",
136
- // Whether to sort on first click (true) or cycle through states (false)
137
- sortOnFirstClick: !0,
138
- // Custom sort functions for specific columns
139
- customSorters: {},
140
- // Columns to exclude from sorting (0-based index)
141
- excludeColumns: [],
142
- // Whether to preserve existing icons in headers
143
- preserveExistingIcons: !1,
144
- // Enable column resizing
145
- enableResizing: !0,
146
- // Enable column reordering
147
- enableReordering: !0,
148
- // CSS class for resizable columns
149
- resizableClass: "resizable-column",
150
- // CSS class for draggable columns
151
- draggableClass: "draggable-column",
152
- // CSS class for drag placeholder
153
- dragPlaceholderClass: "drag-placeholder",
154
- // CSS class for drag over state
155
- dragOverClass: "drag-over",
156
- theme: {
157
- palette: {
158
- primary: {
159
- main: "#999"
160
- },
161
- background: {
162
- default: "#fff",
163
- paper: "#555"
164
- },
165
- text: {
166
- primary: "#000",
167
- secondary: "#999",
168
- disabled: "#BBB"
169
- },
170
- surface: {
171
- panel: "#999",
172
- raised: "#999",
173
- hover: "#444"
174
- },
175
- divider: "#999",
176
- border: {
177
- default: "#999",
178
- soft: "#BBB"
179
- }
180
- },
181
- shape: {
182
- borderRadius: 7,
183
- radiusSm: 1,
184
- radiusLg: 10
185
- }
186
- },
187
- ...e
188
- }, this.tables = [], this.sortStates = /* @__PURE__ */ new Map(), this.originalColumnOrder = /* @__PURE__ */ new Map(), this.isDragging = !1, this.dragSource = null, this.dragTarget = null, this.charWidth = 0;
189
- }
190
- /**
191
- * Initialize the library - scan document for tables and make them sortable
192
- * @param {HTMLElement} container - Optional container element to limit search scope
193
- */
194
- init(e = null) {
195
- this.charWidth == 0 && (this.charWidth = this.getCharWidth(this.options.theme.typography.fontFamily, this.options.theme.typography.fontMono)), this.scanTables(e), this.makeTablesSortable(), this.addStyles();
196
- }
197
- /**
198
- * Scan for tables in the document or within a specific container
199
- * @param {HTMLElement} container - Optional container element to limit search scope
200
- */
201
- scanTables(e = null) {
202
- const r = (e || document).querySelectorAll("table");
203
- this.tables = Array.from(r);
204
- }
205
- /**
206
- * Make all found tables sortable
207
- */
208
- makeTablesSortable() {
209
- this.tables.forEach((e, t) => {
210
- this.makeTableSortable(e, t);
211
- });
212
- }
213
- /**
214
- * Make a specific table sortable
215
- */
216
- makeTableSortable(e, t) {
217
- let r = e.querySelector("thead"), n = null, i = [];
218
- if (r && (n = r.querySelector("tr"), n && (i = n.querySelectorAll("th"))), i.length === 0) {
219
- console.warn("Table has no sortable columns, skipping");
220
- return;
221
- }
222
- const s = !e.hasAttribute("data-sortable-arrived");
223
- e.classList.add("sortable-table"), s && (e.setAttribute("data-sortable-arrived", "true"), e.classList.add("sortable-table-arriving"), setTimeout(() => {
224
- e.classList.remove("sortable-table-arriving");
225
- }, 400)), this.sortStates.set(t, {
226
- currentColumn: -1,
227
- direction: "none"
228
- }), e.hasAttribute("data-original-width") || e.setAttribute("data-original-width", e.getBoundingClientRect().width), this.applyTableStyles(e), this.originalColumnOrder.set(t, Array.from(i).map((a, l) => l)), i.forEach((a, l) => {
229
- this.options.excludeColumns.includes(l) || this.makeHeaderSortable(a, e, t, l);
230
- }), this.replaceExponentialValues(e), x.add(e);
231
- }
232
- /**
233
- * Replace exponential values in table cells with full numbers
234
- * @param {HTMLElement} table - The table to process
235
- */
236
- replaceExponentialValues(e) {
237
- const t = e.querySelector("tbody");
238
- if (!t) return;
239
- t.querySelectorAll("tr").forEach((n) => {
240
- n.querySelectorAll("td, th").forEach((s) => {
241
- const l = s.textContent.trim().match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
242
- if (l) {
243
- const c = parseFloat(l[1].replace(/,/g, "")), p = parseInt(l[2]), u = c * Math.pow(10, p), h = this.formatNumber(u);
244
- s.textContent = h;
245
- }
246
- });
247
- });
248
- }
249
- /**
250
- * Format a number with commas for readability
251
- * @param {number} num - The number to format
252
- * @returns {string} The formatted number
253
- */
254
- formatNumber(e) {
255
- return e === 0 ? "0" : Math.abs(e) >= 1e12 ? (e / 1e12).toFixed(2) + "T" : Math.abs(e) >= 1e9 ? (e / 1e9).toFixed(2) + "B" : Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(2) + "K" : Math.abs(e) < 0.01 && e !== 0 ? e.toExponential(2) : e.toLocaleString();
256
- }
257
- /**
258
- * Convert the first row to a header row
259
- * @param {HTMLElement} firstRow - The first row to convert
260
- * @param {HTMLElement} thead - The thead element to append to
261
- * @param {HTMLElement} tbody - The tbody element to remove from
262
- * @returns {HTMLElement} The converted header row
263
- */
264
- convertRowToHeader(e, t, r) {
265
- try {
266
- const n = e.cloneNode(!0);
267
- return n.querySelectorAll("td").forEach((s) => {
268
- const a = document.createElement("th");
269
- Array.from(s.attributes).forEach((l) => {
270
- a.setAttribute(l.name, l.value);
271
- }), a.innerHTML = s.innerHTML, a.style.cssText = s.style.cssText, s.parentNode.replaceChild(a, s);
272
- }), r && r.contains(e) ? r.removeChild(e) : e.parentNode && e.parentNode.removeChild(e), t.appendChild(n), n;
273
- } catch (n) {
274
- return console.error("Error converting row to header:", n), null;
275
- }
276
- }
277
- /**
278
- * Make a specific header sortable
279
- */
280
- makeHeaderSortable(e, t, r, n) {
281
- e.classList.add(this.options.sortableClass), e.style.cursor = "pointer", (!this.options.preserveExistingIcons || !e.querySelector(".material-icons")) && this.addSortIcon(e), this.options.enableResizing && this.addResizing(e, t, r, n), this.options.enableReordering && this.addDragAndDrop(e, t, r, n);
282
- const i = /* @__PURE__ */ d((l) => {
283
- l.preventDefault(), this.sortTable(t, r, n);
284
- }, "clickListener"), s = /* @__PURE__ */ d((l) => {
285
- e.classList.contains(this.options.activeSortClass) || (e.style.background = this.options.theme.palette.surface.hover);
286
- }, "mouseEnterListener"), a = /* @__PURE__ */ d((l) => {
287
- e.classList.contains(this.options.activeSortClass) || (e.style.background = "");
288
- }, "mouseLeaveListener");
289
- e.removeEventListener("click", i), e.addEventListener("click", i), e.removeEventListener("mouseenter", s), e.addEventListener("mouseenter", s), e.removeEventListener("mouseleave", a), e.addEventListener("mouseleave", a);
290
- }
291
- /**
292
- * Add sort icon to header
293
- */
294
- addSortIcon(e) {
295
- if (e.querySelector(".sortable-table-icon"))
296
- return;
297
- const t = document.createElement("i");
298
- t.id = "sortable-table-icon", t.className = "material-icons", t.textContent = this.options.unsortedIcon, t.style.marginRight = "2px", t.style.fontSize = "12px", t.style.verticalAlign = "middle", t.style.opacity = "0", e.querySelector(".material-icons") || (e.insertBefore(t, e.firstChild), requestAnimationFrame(() => {
299
- requestAnimationFrame(() => {
300
- t.style.opacity = "0.6";
301
- });
302
- }));
303
- }
304
- /**
305
- * Sort table by column
306
- */
307
- sortTable(e, t, r) {
308
- const n = e.querySelector("tbody");
309
- if (!n) {
310
- console.warn("Table has no tbody element");
311
- return;
312
- }
313
- const i = Array.from(n.querySelectorAll("tr"));
314
- if (i.length === 0) {
315
- console.warn("Table has no data rows");
316
- return;
317
- }
318
- const s = this.sortStates.get(t);
319
- e.querySelector(`thead tr th:nth-child(${r + 1})`);
320
- let a;
321
- if (this.options.sortOnFirstClick ? a = s.currentColumn === r && s.direction === "asc" ? "desc" : "asc" : s.currentColumn !== r ? a = "asc" : a = s.direction === "none" ? "asc" : s.direction === "asc" ? "desc" : "none", s.currentColumn = r, s.direction = a, this.sortStates.set(t, s), this.updateSortIndicators(e, t, r, a), a === "none") {
322
- this.restoreOriginalOrder(e, i);
323
- return;
324
- }
325
- this.sortRows(i, r, a).forEach((c) => n.appendChild(c));
326
- }
327
- /**
328
- * Sort rows based on column data
329
- */
330
- sortRows(e, t, r) {
331
- return e.sort((n, i) => {
332
- const s = n.cells[t], a = i.cells[t];
333
- if (!s || !a) return 0;
334
- const l = this.extractValue(s), c = this.extractValue(a);
335
- if (this.options.customSorters[t])
336
- return this.options.customSorters[t](l, c, r);
337
- const p = this.compareValues(l, c);
338
- return r === "asc" ? p : -p;
339
- });
340
- }
341
- /**
342
- * Extract sortable value from cell
343
- */
344
- extractValue(e) {
345
- let t = e.textContent.trim(), r = I(t);
346
- if (!isNaN(r))
347
- return console.log(r), r;
348
- if (t = t.replace(/arrow_upward|arrow_downward|remove|keyboard_arrow_up|keyboard_arrow_down|unfold_more|expand_more|expand_less|trending_up|trending_down|↗|↘|↑|↓|→|←/g, "").trim(), /^(N\/A|N\/D|ND|N\/A|n\/a|n\/d|nd|N\/A|N\/D|ND|\s*)$/i.test(t))
349
- return -1;
350
- const i = t.match(/^([\d,]+\.?\d*)\s*%$/);
351
- if (i)
352
- return parseFloat(i[1].replace(/,/g, ""));
353
- const s = t.match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
354
- if (s) {
355
- const p = parseFloat(s[1].replace(/,/g, "")), u = parseInt(s[2]);
356
- return p * Math.pow(10, u);
357
- }
358
- if (t.match(/^[\d,]+\.?\d*[KMB]?$/))
359
- return this.parseNumber(t);
360
- const l = t.match(/^R\$\s*([\d,]+\.?\d*)$/);
361
- if (l)
362
- return this.parseNumber(l[1]);
363
- const c = new Date(t);
364
- return isNaN(c.getTime()) ? t.toLowerCase() : c.getTime();
365
- }
366
- /**
367
- * Compare two values for sorting
368
- */
369
- compareValues(e, t) {
370
- return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : typeof e != typeof t ? String(e).localeCompare(String(t)) : typeof e == "number" ? e - t : e instanceof Date ? e.getTime() - t.getTime() : e.localeCompare(t);
371
- }
372
- /**
373
- * Update visual indicators for sort state
374
- */
375
- updateSortIndicators(e, t, r, n) {
376
- const i = e.querySelectorAll("thead tr th");
377
- if (i.forEach((s, a) => {
378
- s.classList.remove(this.options.activeSortClass, this.options.ascendingClass, this.options.descendingClass);
379
- const l = s.querySelector(".material-icons");
380
- l && (l.textContent = this.options.unsortedIcon, l.style.opacity = "0.6");
381
- }), n !== "none") {
382
- const s = i[r];
383
- s.classList.add(this.options.activeSortClass);
384
- const a = s.querySelector(".material-icons");
385
- a && (n === "asc" ? (s.classList.add(this.options.ascendingClass), a.textContent = this.options.ascendingIcon) : (s.classList.add(this.options.descendingClass), a.textContent = this.options.descendingIcon), a.style.opacity = "1");
386
- }
387
- }
388
- /**
389
- * Restore original order (when sort direction is 'none')
390
- */
391
- restoreOriginalOrder(e, t) {
392
- const r = e.querySelector("tbody");
393
- t.forEach((n) => r.appendChild(n));
394
- }
395
- /**
396
- * Add resizing functionality to a header
397
- */
398
- addResizing(e, t, r, n) {
399
- if (e.classList.add(this.options.resizableClass), e.style.position = "relative", e.querySelector(".resize-handle"))
400
- return;
401
- const i = document.createElement("div");
402
- i.className = "resize-handle", i.style.cssText = `
403
- position: absolute;
404
- top: 0;
405
- right: 0;
406
- width: 4px;
407
- height: 100%;
408
- background: transparent;
409
- cursor: col-resize;
410
- z-index: 10;
411
- `, e.appendChild(i);
412
- let s = !1, a = 0, l = 0;
413
- i.addEventListener("mousedown", (u) => {
414
- u.preventDefault(), u.stopPropagation(), u.stopImmediatePropagation(), s = !0, a = u.clientX, l = e.offsetWidth, e.style.borderRight = "2px solid var(--primary-main, #2196F3)", e.style.background = "var(--background-active, rgba(255, 255, 255, 0.1))", document.addEventListener("mousemove", c), document.addEventListener("mouseup", p), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
415
- });
416
- const c = /* @__PURE__ */ d((u) => {
417
- if (!s) return;
418
- const h = l + (u.clientX - a);
419
- if (h > 30) {
420
- e.style.width = h + "px";
421
- const g = Array.from(e.parentNode.children).indexOf(e), f = t.querySelector("tbody");
422
- f && f.querySelectorAll("tr").forEach((y) => {
423
- const b = y.children[g];
424
- b && (b.style.width = h + "px");
425
- }), this.updateTableWidth(t);
426
- }
427
- }, "handleResize"), p = /* @__PURE__ */ d(() => {
428
- s = !1, e.style.borderRight = "", e.style.background = "", document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", p), document.body.style.cursor = "", document.body.style.userSelect = "";
429
- }, "stopResize");
430
- }
431
- /**
432
- * Add drag and drop functionality to a header
433
- */
434
- addDragAndDrop(e, t, r, n) {
435
- if (e.querySelector(".drag-handle"))
436
- return;
437
- e.classList.add(this.options.draggableClass), e.draggable = !0;
438
- const i = t.querySelector("thead tr");
439
- e.addEventListener("dragstart", (s) => {
440
- this.isDragging = !0;
441
- const a = Array.from(i.children).indexOf(e);
442
- this.dragSource = { table: t, tableIndex: r, columnIndex: a }, s.dataTransfer.effectAllowed = "move", s.dataTransfer.setData("text/html", e.outerHTML);
443
- const l = e.outerHTML;
444
- e.style.opacity = "0.5", this.createCustomDragImage(s, e, l);
445
- }), e.addEventListener("dragend", (s) => {
446
- this.isDragging = !1, this.dragSource = null, e.style.opacity = "", this.clearAllColumnHighlights(t);
447
- }), e.addEventListener("dragover", (s) => {
448
- s.preventDefault(), s.dataTransfer.dropEffect = "move";
449
- }), e.addEventListener("dragenter", (s) => {
450
- if (s.preventDefault(), this.dragSource && this.dragSource.tableIndex === r) {
451
- const a = Array.from(i.children).indexOf(e);
452
- this.dragSource.columnIndex !== a && this.highlightColumn(t, a, !0);
453
- }
454
- }), e.addEventListener("dragleave", (s) => {
455
- if (!e.contains(s.relatedTarget)) {
456
- const a = Array.from(i.children).indexOf(e);
457
- this.highlightColumn(t, a, !1);
458
- }
459
- }), e.addEventListener("drop", (s) => {
460
- if (s.preventDefault(), this.dragSource && this.dragSource.tableIndex === r) {
461
- const a = Array.from(i.children).indexOf(e);
462
- this.dragSource.columnIndex !== a && this.reorderColumns(t, r, this.dragSource.columnIndex, a);
463
- }
464
- this.clearAllColumnHighlights(t);
465
- });
466
- }
467
- /**
468
- * Create a custom drag image for better UX
469
- */
470
- createCustomDragImage(e, t, r) {
471
- const n = document.createElement("div");
472
- n.style.cssText = `
473
- position: absolute;
474
- top: -1000px;
475
- left: -1000px;
476
- background: var(--background-elevated, #333);
477
- border: 2px solid var(--primary-main, #2196F3);
478
- border-radius: 4px;
479
- padding: 8px 12px;
480
- font-size: 12px;
481
- font-weight: bold;
482
- color: var(--text-primary, #fff);
483
- white-space: nowrap;
484
- max-width: 150px;
485
- min-width: 60px;
486
- overflow: hidden;
487
- text-overflow: ellipsis;
488
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
489
- z-index: 10000;
490
- pointer-events: none;
491
- min-height: 50px;
492
- display: flex;
493
- align-items: center;
494
- `;
495
- const i = r;
496
- n.innerHTML = `
497
- <div style="display: flex; align-items: center; gap: 5px; align-content: center;color:white;">
498
- <span style="overflow: hidden; text-overflow: ellipsis">${i}</span>
499
- <svg style="fill: grey; font-size: 10px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" ><defs><path id="a" d="M0 0h24v24H0V0z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" d="M9.01 14H2v2h7.01v3L13 15l-3.99-4v3zm5.98-1v-3H22V8h-7.01V5L11 9l3.99 4z"/></svg>
500
- </div>
501
- `, document.body.appendChild(n), e.dataTransfer.setDragImage(n, 50, 12), setTimeout(() => {
502
- document.body.contains(n) && document.body.removeChild(n);
503
- }, 100);
504
- }
505
- /**
506
- * Highlight an entire column during drag operations
507
- */
508
- highlightColumn(e, t, r) {
509
- const n = e.querySelector("thead tr"), i = e.querySelector("tbody");
510
- if (!n || !i) return;
511
- const s = n.children[t];
512
- if (s)
513
- if (r) {
514
- s.classList.add(this.options.dragOverClass);
515
- const a = i.children;
516
- for (let l = 0; l < a.length; l++) {
517
- const c = a[l].children[t];
518
- c && c.classList.add(this.options.dragOverClass);
519
- }
520
- } else {
521
- s.classList.remove(this.options.dragOverClass);
522
- const a = i.children;
523
- for (let l = 0; l < a.length; l++) {
524
- const c = a[l].children[t];
525
- c && c.classList.remove(this.options.dragOverClass);
526
- }
527
- }
528
- }
529
- /**
530
- * Clear all column highlights
531
- */
532
- clearAllColumnHighlights(e) {
533
- const t = e.querySelector("thead tr"), r = e.querySelector("tbody");
534
- if (!t || !r) return;
535
- const n = t.children;
536
- for (let s = 0; s < n.length; s++)
537
- n[s].classList.remove(this.options.dragOverClass);
538
- const i = r.children;
539
- for (let s = 0; s < i.length; s++) {
540
- const a = i[s].children;
541
- for (let l = 0; l < a.length; l++)
542
- a[l].classList.remove(this.options.dragOverClass);
543
- }
544
- }
545
- /**
546
- * Reorder columns in a table
547
- */
548
- reorderColumns(e, t, r, n) {
549
- const i = e.querySelector("thead tr"), s = e.querySelector("tbody");
550
- if (!i || !s) return;
551
- const a = Array.from(i.children), l = Array.from(s.children);
552
- if (r < 0 || r >= a.length || n < 0 || n >= a.length) {
553
- console.warn("Invalid column indices for reordering");
554
- return;
555
- }
556
- if (r === n)
557
- return;
558
- const c = a[r], p = a[n];
559
- r < n ? i.insertBefore(c, p.nextSibling) : i.insertBefore(c, p), l.forEach((h, g) => {
560
- const f = Array.from(h.children), m = f[r], y = f[n];
561
- r < n ? h.insertBefore(m, y.nextSibling) : h.insertBefore(m, y);
562
- });
563
- const u = this.originalColumnOrder.get(t);
564
- if (u) {
565
- const h = [...u], g = h[r];
566
- h.splice(r, 1), h.splice(n, 0, g), this.originalColumnOrder.set(t, h);
567
- }
568
- this.applyTableStyles(e), this.refreshDragAndDropListeners(e, t);
569
- }
570
- /**
571
- * Refresh drag and drop listeners after column reordering
572
- */
573
- refreshDragAndDropListeners(e, t) {
574
- const r = e.querySelector("thead tr");
575
- if (!r) return;
576
- Array.from(r.children).forEach((i, s) => {
577
- if (i.classList.contains(this.options.draggableClass)) {
578
- i.style.opacity = "", i.style.background = "", i.style.borderRight = "";
579
- const a = i.cloneNode(!0);
580
- i.parentNode.replaceChild(a, i), this.makeHeaderSortable(a, e, t, s);
581
- }
582
- });
583
- }
584
- /**
585
- * Update table width based on current column widths
586
- */
587
- updateTableWidth(e) {
588
- const t = e.querySelectorAll("th");
589
- let r = 0;
590
- t.forEach((n) => {
591
- const i = n.style.width;
592
- if (i) {
593
- const s = parseInt(i.replace("px", ""));
594
- r += s;
595
- } else {
596
- const s = n.textContent.replace(/[📊🔍]/g, "").trim();
597
- r += s.length;
598
- }
599
- }), e.style.width = `${r}px`;
600
- }
601
- /**
602
- * Calculate intelligent table width based on header text length
603
- */
604
- calculateTableWidth(e) {
605
- var u;
606
- const t = e.getAttribute("data-original-width"), r = t ? parseFloat(t) : 0, n = e.querySelectorAll("th");
607
- let i = 0;
608
- e.parentElement.clientWidth;
609
- const s = [];
610
- n.forEach((h) => {
611
- let f = h.textContent.replace(/[📊🔍]/g, "").trim().length * this.charWidth + 15;
612
- s.push(f), i += f;
613
- });
614
- const a = e.querySelectorAll("tr"), l = ((u = e.parentElement) == null ? void 0 : u.getBoundingClientRect().width) ?? i;
615
- var c = 0;
616
- for (const h of a)
617
- h.querySelectorAll("td").forEach((f, m) => {
618
- const b = f.textContent.length * this.charWidth + 15;
619
- b > s[m] && m < s.length && (s[m] = b);
620
- });
621
- c = s.reduce((h, g) => h += g, 0), n.forEach((h, g) => {
622
- if (c > l) {
623
- const f = s[g] / c;
624
- h.style.width = `${l * f}px`;
625
- } else
626
- h.style.width = `${s[g]}px`;
627
- });
628
- let p = 0;
629
- return c > l ? p = "100%" : p = `${Math.max(c, r)}px`, p;
630
- }
631
- /**
632
- * Apply inline styles to ensure text clipping and horizontal scroll work
633
- */
634
- applyTableStyles(e) {
635
- const t = this.calculateTableWidth(e);
636
- e.style.width = t, e.style.maxWidth = "100%";
637
- }
638
- getCharWidth(e, t, r) {
639
- const i = document.createElement("canvas").getContext("2d");
640
- return i.fontFamily = t, i.fontMono = r, i.measureText("A ").width;
641
- }
642
- /**
643
- * Add CSS styles for sortable tables
644
- */
645
- addStyles() {
646
- if (document.getElementById("sortable-table-styles"))
647
- return;
648
- const e = document.createElement("style");
649
- e.id = "sortable-table-styles", e.textContent = `
650
- .${this.options.sortableClass} {
651
- position: relative;
652
- user-select: none;
653
- transition: background-color 0.2s ease;
654
- }
655
-
656
- .${this.options.sortableClass}:hover {
657
- background-color: ${this.options.theme.palette.surface.hover} !important;
658
- }
659
-
660
- .${this.options.activeSortClass} {
661
- background-color: ${this.options.theme.palette.surface.raised} !important;
662
- font-weight: bold;
663
- }
664
-
665
- .${this.options.ascendingClass} {
666
- border-bottom: 2px solid var(${this.options.theme.palette.primary.main}, #3a3a3a);
667
- }
668
-
669
- .${this.options.descendingClass} {
670
- border-bottom: 2px solid var(${this.options.theme.palette.primary.main}, #3a3a3a);
671
- }
672
-
673
- .${this.options.sortableClass} .material-icons {
674
- transition: opacity 0.2s ease, transform 0.2s ease;
675
- }
676
-
677
- .${this.options.activeSortClass} .material-icons {
678
- color: var(${this.options.theme.palette.primary.main}, #3a3a3a);
679
- }
680
-
681
- .${this.options.resizableClass} .resize-handle:hover {
682
- background-color: var(${this.options.theme.palette.primary.light}, #64B5F6);
683
- }
684
-
685
- .${this.options.draggableClass} {
686
- cursor: move;
687
- position: relative;
688
- }
689
-
690
- .${this.options.draggableClass}::before {
691
- content: '';
692
- position: absolute;
693
- top: 0;
694
- left: -5px;
695
- right: -5px;
696
- bottom: 0;
697
- z-index: 1;
698
- pointer-events: none;
699
- }
700
-
701
- .${this.options.dragOverClass} {
702
- background-color: rgba(128, 128, 128, 0.2) !important;
703
- border: 2px dashed rgba(128, 128, 128, 0.8);
704
- }
705
-
706
- .${this.options.draggableClass}:hover {
707
- background-color: var(${this.options.theme.palette.surface.raised}, rgba(100, 181, 246, 0.1)) !important;
708
- }
709
-
710
- .sortable-table tbody td {
711
- width: auto
712
- }
713
-
714
- .sortable-table {
715
- /* Cross-fade bg/row stripes when the .sortable-table
716
- * class flip lands on a freshly-streamed markdown
717
- * table. Width is NOT animated: column widths set
718
- * by calculateTableWidth can be narrower than the
719
- * content currently fills, so animating them down
720
- * causes mid-transition cell wrap. Snap widths,
721
- * animate only colours. */
722
- transition: background-color 280ms ease-out;
723
- }
724
-
725
- .sortable-table th {
726
- transition: background-color 280ms ease-out;
727
- }
728
-
729
- /* Zebra striping for table rows */
730
- .sortable-table tbody tr:nth-child(odd) {
731
- background-color: ${this.options.theme.palette.background.defalt};
732
- color: ${this.options.theme.palette.text.primary};
733
- }
734
-
735
- .sortable-table tbody tr:nth-child(even) {
736
- background-color: ${this.options.theme.palette.background.defalt};
737
- color: ${this.options.theme.palette.text.primary};
738
- }
739
-
740
- /* One-shot arrival animation. Applied via a transient
741
- * class (added by makeTableSortable on first mount only)
742
- * so it does NOT re-fire on every destroy/init cycle.
743
- * scaleX with origin top-left gives the "right edge
744
- * grows outward" feel the user asked for; the 0.96
745
- * start is subtle enough that text compression isn't
746
- * obvious. */
747
- @keyframes sortable-table-arrive {
748
- from {
749
- opacity: 0.35;
750
- transform: scaleX(0.96);
751
- transform-origin: top left;
752
- }
753
- to {
754
- opacity: 1;
755
- transform: scaleX(1);
756
- }
757
- }
758
-
759
- .sortable-table-arriving {
760
- animation: sortable-table-arrive 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
761
- }
762
-
763
- /* Ensure hover effects work with zebra striping */
764
- .sortable-table tbody tr:hover {
765
- background-color: ${this.options.theme.palette.surface.hover} !important;
766
- }
767
-
768
-
769
- /* Fix table-container overflow issue */
770
- .table-container {
771
- overflow: auto !important;
772
- overflow-x: auto !important;
773
- overflow-y: auto !important;
774
- }
775
- `, document.getElementById("sortable-table-styles") || document.head.appendChild(e);
776
- }
777
- /**
778
- * Destroy the sortable functionality
779
- */
780
- destroy() {
781
- this.tables.forEach((t) => {
782
- t.querySelectorAll(`.${this.options.sortableClass}`).forEach((n) => {
783
- n.classList.remove(
784
- this.options.sortableClass,
785
- this.options.activeSortClass,
786
- this.options.ascendingClass,
787
- this.options.descendingClass
788
- ), n.style.cursor = "", n.style.background = "";
789
- const i = n.cloneNode(!0);
790
- n.parentNode.replaceChild(i, n);
791
- });
792
- });
793
- const e = document.getElementById("sortable-table-styles");
794
- e && e.remove(), this.tables = [], this.sortStates.clear(), x.clear();
795
- }
796
- /**
797
- * Refresh the library (useful after DOM changes)
798
- */
799
- refresh() {
800
- this.destroy(), this.init();
801
- }
802
- };
803
- d(C, "SortableTable");
804
- let S = C;
805
- typeof window < "u" && (window.SortableTable = S);
806
- const E = /* @__PURE__ */ new Set(["/", "@", "#"]), D = /* @__PURE__ */ d((o) => o === "/" ? "slash" : o === "@" ? "at" : "hash", "triggerTypeFor"), w = /[ \t\r\n\f\v]/, M = /\[[^\]\n]+\]/g, L = /* @__PURE__ */ d((o, e, t) => {
807
- let r = 0;
808
- const n = /* @__PURE__ */ d((i) => {
809
- const s = i === 0 ? e : o[i - 1];
810
- return s === void 0 || w.test(s);
811
- }, "boundaryBefore");
812
- for (; r < o.length; ) {
813
- const i = o[r];
814
- if (n(r) && E.has(i)) {
815
- let s = r + 1;
816
- for (; s < o.length && !w.test(o[s]); ) s += 1;
817
- t.push({ type: D(i), text: o.slice(r, s) }), r = s;
818
- } else {
819
- let s = r + 1;
820
- for (; s < o.length; ) {
821
- const a = o[s];
822
- if (E.has(a) && w.test(o[s - 1])) break;
823
- s += 1;
824
- }
825
- t.push({ type: "plain", text: o.slice(r, s) }), r = s;
826
- }
827
- }
828
- }, "tokenizeSegment"), G = /* @__PURE__ */ d((o) => {
829
- if (!o) return [];
830
- const e = [], t = new RegExp(M.source, "g");
831
- let r = 0;
832
- for (let n = t.exec(o); n; n = t.exec(o))
833
- n.index > r && L(o.slice(r, n.index), r === 0 ? void 0 : o[r - 1], e), e.push({ type: "placeholder", text: n[0] }), r = n.index + n[0].length;
834
- return r < o.length && L(o.slice(r), r === 0 ? void 0 : o[r - 1], e), e;
835
- }, "tokenizeForHighlight"), j = /* @__PURE__ */ d((o, e) => {
836
- const t = e.filter((n) => n.trim().length > 0).sort((n, i) => i.length - n.length);
837
- if (t.length === 0) return o;
838
- const r = [];
839
- for (const n of o) {
840
- if (n.type !== "plain") {
841
- r.push(n);
842
- continue;
843
- }
844
- let i = n.text;
845
- for (; i.length > 0; ) {
846
- let s = -1, a = 0;
847
- for (const l of t) {
848
- const c = i.indexOf(l);
849
- c >= 0 && (s === -1 || c < s) && (s = c, a = l.length);
850
- }
851
- if (s === -1) {
852
- r.push({ type: "plain", text: i });
853
- break;
854
- }
855
- s > 0 && r.push({ type: "plain", text: i.slice(0, s) }), r.push({ type: "at", text: i.slice(s, s + a) }), i = i.slice(s + a);
856
- }
857
- }
858
- return r;
859
- }, "chipLocations");
860
- function K(o, e, t = e, r = 600) {
861
- const n = o.value;
862
- let i = !1;
863
- const s = /* @__PURE__ */ d(() => {
864
- i || (i = !0, document.removeEventListener("selectionchange", l), o.removeEventListener("keydown", s), o.removeEventListener("input", s), o.removeEventListener("pointerdown", s), window.clearTimeout(c), window.clearInterval(p));
865
- }, "stop"), a = /* @__PURE__ */ d(() => {
866
- if (o.value !== n) {
867
- s();
868
- return;
869
- }
870
- o.selectionStart === e && o.selectionEnd === t || o.setSelectionRange(e, t);
871
- }, "apply"), l = /* @__PURE__ */ d(() => {
872
- document.activeElement === o && a();
873
- }, "onSelectionChange");
874
- a();
875
- const c = window.setTimeout(s, r), p = window.setInterval(a, 50);
876
- return document.addEventListener("selectionchange", l), o.addEventListener("keydown", s), o.addEventListener("input", s), o.addEventListener("pointerdown", s), s;
877
- }
878
- d(K, "placeCaret");
879
- const O = 2;
880
- function Z(o, e) {
881
- let t = 0;
882
- for (let r = e - 1; r >= 0; r -= 1) {
883
- const n = o[r];
884
- if (n === "/" || n === "@" || n === "#")
885
- return !(r === 0 || /\s/.test(o[r - 1])) || n !== "@" && t > 0 ? null : {
886
- trigger: n,
887
- query: o.slice(r + 1, e),
888
- startIdx: r,
889
- endIdx: e
890
- };
891
- if (n === " ") return null;
892
- if (n === " " || n === " ") {
893
- if (t += 1, t > O) return null;
894
- continue;
895
- }
896
- if (/\s/.test(n)) return null;
897
- }
898
- return null;
899
- }
900
- d(Z, "detectTrigger");
901
- const R = /\[[^\]\n]+\]/g;
902
- function v(o, e = 0) {
903
- const t = new RegExp(R.source, "g");
904
- t.lastIndex = e;
905
- const r = t.exec(o);
906
- if (!r) return null;
907
- const n = r[0].slice(1, -1), i = n[0], s = i === "@" || i === "#" || i === "/";
908
- return {
909
- trigger: s ? i : null,
910
- label: (s ? n.slice(1) : n).trim(),
911
- startIdx: r.index,
912
- endIdx: r.index + r[0].length
913
- };
914
- }
915
- d(v, "findPlaceholder");
916
- function J(o, e) {
917
- for (let t = 0; ; ) {
918
- const r = v(o, t);
919
- if (!r || r.startIdx > e) return null;
920
- if (e <= r.endIdx) return r;
921
- t = r.endIdx;
922
- }
923
- }
924
- d(J, "placeholderAt");
925
- function k(o, e) {
926
- if (e.trigger) {
927
- const t = o.slice(0, e.startIdx) + e.trigger + o.slice(e.endIdx), r = e.startIdx + 1;
928
- return { next: t, selectionStart: r, selectionEnd: r, reopenTrigger: !0 };
929
- }
930
- return { next: o, selectionStart: e.startIdx, selectionEnd: e.endIdx, reopenTrigger: !1 };
931
- }
932
- d(k, "activatePlaceholder");
933
- function Y(o, e) {
934
- const t = v(o, e) ?? v(o, 0);
935
- return t ? k(o, t) : null;
936
- }
937
- d(Y, "advanceToPlaceholder");
938
- function Q(o, e, t) {
939
- const r = o.slice(0, e.startIdx), n = o.slice(e.endIdx), i = v(t);
940
- if (i) {
941
- const c = k(t, i);
942
- return {
943
- next: `${r}${c.next}${n}`,
944
- selectionStart: r.length + c.selectionStart,
945
- selectionEnd: r.length + c.selectionEnd,
946
- reopenTrigger: c.reopenTrigger
947
- };
948
- }
949
- const s = t[t.length - 1];
950
- if (s === "@" || s === "#" || s === "/") {
951
- const c = r.length + t.length;
952
- return { next: `${r}${t}${n}`, selectionStart: c, selectionEnd: c, reopenTrigger: !0 };
953
- }
954
- const a = `${t} `, l = r.length + a.length;
955
- return { next: `${r}${a}${n}`, selectionStart: l, selectionEnd: l, reopenTrigger: !1 };
956
- }
957
- d(Q, "applyTriggerInsertion");
958
- async function ee(o, { onAtQuery: e, onAtPersonQuery: t }, { personConfidence: r = 0, locationConfidence: n = 0, personFirstThreshold: i = 0.5 } = {}) {
959
- const [s, a] = await Promise.all([
960
- e ? e(o).catch(() => []) : Promise.resolve([]),
961
- t ? t(o).catch(() => []) : Promise.resolve([])
962
- ]);
963
- if (e && t) {
964
- const l = a.map((u) => ({ ...u, group: "person" })), c = s.map((u) => ({ ...u, group: "location" }));
965
- return r >= i && r >= n ? [...l, ...c] : [...c, ...l];
966
- }
967
- return [...a, ...s];
968
- }
969
- d(ee, "fetchAtMentions");
970
- function te(o, e) {
971
- var r, n;
972
- const t = (r = o[e]) == null ? void 0 : r.group;
973
- return t !== void 0 && (e === 0 || ((n = o[e - 1]) == null ? void 0 : n.group) !== t);
974
- }
975
- d(te, "isSectionStart");
976
- export {
977
- S,
978
- k as a,
979
- Y as b,
980
- Q as c,
981
- j as d,
982
- N as e,
983
- Z as f,
984
- W as g,
985
- _ as h,
986
- ee as i,
987
- v as j,
988
- te as k,
989
- X as l,
990
- B as m,
991
- K as n,
992
- J as o,
993
- F as p,
994
- V as q,
995
- U as r,
996
- z as s,
997
- P as t,
998
- G as u
999
- };
1000
- //# sourceMappingURL=atMentions-C0dza8DD.js.map