@aintela/chat 0.4.32 → 0.4.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.js +4419 -4403
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.js +87 -86
- package/dist/{predictionRows-CZORCShm.js → predictionRows-Damfwthh.js} +286 -283
- package/dist/{predictionRows-CZORCShm.js.map → predictionRows-Damfwthh.js.map} +1 -1
- package/dist/src/components/v2/PromptGhostHint.d.ts +3 -1
- package/dist/src/components/v2/PromptV2.d.ts +6 -0
- package/dist/src/hooks/usePromptAssist.d.ts +7 -1
- package/dist/src/utils/atMentions.d.ts +9 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/useContainerWidth-C7u70yDY.js +410 -0
- package/dist/useContainerWidth-C7u70yDY.js.map +1 -0
- package/dist/utils.js +44 -43
- package/package.json +1 -1
- package/dist/useContainerWidth-hY7QntU9.js +0 -409
- package/dist/useContainerWidth-hY7QntU9.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (n,
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var z = (n, t, e) => t in n ? R(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var d = (n, t) => R(n, "name", { value: t, configurable: !0 });
|
|
4
|
+
var q = (n, t, e) => z(n, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
+
const F = /^[a-z][a-z0-9+.-]*:\/\//i, K = /* @__PURE__ */ d((n, t, e) => {
|
|
6
6
|
let o = "URL", r = null, i = null, s = null;
|
|
7
7
|
if (n[0] == "#") {
|
|
8
8
|
const a = n.indexOf("-"), l = n.slice(1, a);
|
|
@@ -11,71 +11,71 @@ const R = /^[a-z][a-z0-9+.-]*:\/\//i, U = /* @__PURE__ */ d((n, e, t) => {
|
|
|
11
11
|
o = "OpenDashboard";
|
|
12
12
|
break;
|
|
13
13
|
case "ask":
|
|
14
|
-
o = "Question", r =
|
|
14
|
+
o = "Question", r = e;
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
|
-
} else
|
|
17
|
+
} else F.test(n) ? (o = "URL", i = n) : n[0] === "/" ? (o = "Navigate", i = n) : (n = n.replaceAll("exported/", `exported/${t}/`), o = "Export");
|
|
18
18
|
return { action: o, url: i, question: r, parameter: s };
|
|
19
|
-
}, "extractLinkAction"),
|
|
20
|
-
{ length: Math.ceil(n.length /
|
|
21
|
-
(
|
|
22
|
-
), "chunkArray"),
|
|
19
|
+
}, "extractLinkAction"), I = /* @__PURE__ */ d((n, t) => Array.from(
|
|
20
|
+
{ length: Math.ceil(n.length / t) },
|
|
21
|
+
(e, o) => n.slice(o * t, o * t + t)
|
|
22
|
+
), "chunkArray"), Z = /* @__PURE__ */ d((n) => {
|
|
23
23
|
n = n.replaceAll("\\n", `
|
|
24
24
|
`);
|
|
25
|
-
const
|
|
25
|
+
const t = 90, e = n.split(" "), o = [];
|
|
26
26
|
let r = !1;
|
|
27
|
-
for (const i of
|
|
28
|
-
if (i.length >
|
|
27
|
+
for (const i of e)
|
|
28
|
+
if (i.length > t) {
|
|
29
29
|
r = !0;
|
|
30
|
-
const s = [...i], l =
|
|
30
|
+
const s = [...i], l = I(s, t).map((c) => c.join("")).join(`
|
|
31
31
|
`);
|
|
32
32
|
o.push(l);
|
|
33
33
|
} else
|
|
34
34
|
o.push(i);
|
|
35
35
|
return r ? o.join(" ") : n;
|
|
36
36
|
}, "splitBigLinesWithSpaces");
|
|
37
|
-
function
|
|
38
|
-
let
|
|
39
|
-
if (!isNaN(
|
|
37
|
+
function B(n) {
|
|
38
|
+
let t = parseFloat(n);
|
|
39
|
+
if (!isNaN(t))
|
|
40
40
|
return n = n.replaceAll(/[,\.]/g, ""), parseInt(n);
|
|
41
|
-
var
|
|
41
|
+
var e = "";
|
|
42
42
|
for (const r of n)
|
|
43
|
-
r.match(/[0-9]/) && (
|
|
44
|
-
const o =
|
|
45
|
-
return
|
|
43
|
+
r.match(/[0-9]/) && (e += r);
|
|
44
|
+
const o = e.length / n.length;
|
|
45
|
+
return t = parseInt(e), !isNaN(t) && o > 0.5 ? t : NaN;
|
|
46
46
|
}
|
|
47
|
-
d(
|
|
48
|
-
const
|
|
49
|
-
function
|
|
47
|
+
d(B, "parseRawNumber");
|
|
48
|
+
const V = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i, P = /^[0-9a-f]{32}/i;
|
|
49
|
+
function J(n) {
|
|
50
50
|
if (!n || typeof n != "string")
|
|
51
51
|
return !1;
|
|
52
|
-
const
|
|
53
|
-
return
|
|
52
|
+
const t = U(n);
|
|
53
|
+
return t === null ? !1 : n.startsWith(t);
|
|
54
54
|
}
|
|
55
|
-
d(
|
|
56
|
-
function
|
|
55
|
+
d(J, "startsWithInteractionId");
|
|
56
|
+
function U(n) {
|
|
57
57
|
if (!n || typeof n != "string")
|
|
58
58
|
return null;
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
62
|
-
const
|
|
63
|
-
return
|
|
59
|
+
const t = n.match(V);
|
|
60
|
+
if (t)
|
|
61
|
+
return t[0];
|
|
62
|
+
const e = n.match(P);
|
|
63
|
+
return e ? e[0] : null;
|
|
64
64
|
}
|
|
65
|
-
d(
|
|
66
|
-
function
|
|
65
|
+
d(U, "extractInteractionId");
|
|
66
|
+
function Y(n) {
|
|
67
67
|
if (n.length == 0)
|
|
68
68
|
return n;
|
|
69
|
-
const
|
|
70
|
-
return
|
|
69
|
+
const t = n.replaceAll("_", " ").replaceAll("-", " ");
|
|
70
|
+
return t[0].toUpperCase() + t.slice(1);
|
|
71
71
|
}
|
|
72
|
-
d(
|
|
73
|
-
function
|
|
72
|
+
d(Y, "prettiffyPythonFunctionName");
|
|
73
|
+
function Q(n) {
|
|
74
74
|
return !n || typeof n != "string" ? !1 : !!(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n) || /^[0-9a-f]{32}$/i.test(n));
|
|
75
75
|
}
|
|
76
|
-
d(
|
|
77
|
-
const
|
|
78
|
-
constructor(
|
|
76
|
+
d(Q, "isValidInteractionId");
|
|
77
|
+
const M = /* @__PURE__ */ new Set(), E = class E {
|
|
78
|
+
constructor(t = {}) {
|
|
79
79
|
this.options = {
|
|
80
80
|
// CSS class for sortable headers
|
|
81
81
|
sortableClass: "sortable-header",
|
|
@@ -142,63 +142,63 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
142
142
|
radiusLg: 10
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
...
|
|
145
|
+
...t
|
|
146
146
|
}, this.tables = [], this.sortStates = /* @__PURE__ */ new Map(), this.originalColumnOrder = /* @__PURE__ */ new Map(), this.isDragging = !1, this.dragSource = null, this.dragTarget = null, this.charWidth = 0;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Initialize the library - scan document for tables and make them sortable
|
|
150
150
|
* @param {HTMLElement} container - Optional container element to limit search scope
|
|
151
151
|
*/
|
|
152
|
-
init(
|
|
153
|
-
this.charWidth == 0 && (this.charWidth = this.getCharWidth(this.options.theme.typography.fontFamily, this.options.theme.typography.fontMono)), this.scanTables(
|
|
152
|
+
init(t = null) {
|
|
153
|
+
this.charWidth == 0 && (this.charWidth = this.getCharWidth(this.options.theme.typography.fontFamily, this.options.theme.typography.fontMono)), this.scanTables(t), this.makeTablesSortable(), this.addStyles();
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Scan for tables in the document or within a specific container
|
|
157
157
|
* @param {HTMLElement} container - Optional container element to limit search scope
|
|
158
158
|
*/
|
|
159
|
-
scanTables(
|
|
160
|
-
const o = (
|
|
159
|
+
scanTables(t = null) {
|
|
160
|
+
const o = (t || document).querySelectorAll("table");
|
|
161
161
|
this.tables = Array.from(o);
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Make all found tables sortable
|
|
165
165
|
*/
|
|
166
166
|
makeTablesSortable() {
|
|
167
|
-
this.tables.forEach((
|
|
168
|
-
this.makeTableSortable(
|
|
167
|
+
this.tables.forEach((t, e) => {
|
|
168
|
+
this.makeTableSortable(t, e);
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Make a specific table sortable
|
|
173
173
|
*/
|
|
174
|
-
makeTableSortable(
|
|
175
|
-
let o =
|
|
174
|
+
makeTableSortable(t, e) {
|
|
175
|
+
let o = t.querySelector("thead"), r = null, i = [];
|
|
176
176
|
if (o && (r = o.querySelector("tr"), r && (i = r.querySelectorAll("th"))), i.length === 0) {
|
|
177
177
|
console.warn("Table has no sortable columns, skipping");
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
|
-
const s = !
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, 400)), this.sortStates.set(
|
|
180
|
+
const s = !t.hasAttribute("data-sortable-arrived");
|
|
181
|
+
t.classList.add("sortable-table"), s && (t.setAttribute("data-sortable-arrived", "true"), t.classList.add("sortable-table-arriving"), setTimeout(() => {
|
|
182
|
+
t.classList.remove("sortable-table-arriving");
|
|
183
|
+
}, 400)), this.sortStates.set(e, {
|
|
184
184
|
currentColumn: -1,
|
|
185
185
|
direction: "none"
|
|
186
|
-
}),
|
|
187
|
-
this.options.excludeColumns.includes(l) || this.makeHeaderSortable(a,
|
|
188
|
-
}), this.replaceExponentialValues(
|
|
186
|
+
}), t.hasAttribute("data-original-width") || t.setAttribute("data-original-width", t.getBoundingClientRect().width), this.applyTableStyles(t), this.originalColumnOrder.set(e, Array.from(i).map((a, l) => l)), i.forEach((a, l) => {
|
|
187
|
+
this.options.excludeColumns.includes(l) || this.makeHeaderSortable(a, t, e, l);
|
|
188
|
+
}), this.replaceExponentialValues(t), M.add(t);
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Replace exponential values in table cells with full numbers
|
|
192
192
|
* @param {HTMLElement} table - The table to process
|
|
193
193
|
*/
|
|
194
|
-
replaceExponentialValues(
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
|
|
194
|
+
replaceExponentialValues(t) {
|
|
195
|
+
const e = t.querySelector("tbody");
|
|
196
|
+
if (!e) return;
|
|
197
|
+
e.querySelectorAll("tr").forEach((r) => {
|
|
198
198
|
r.querySelectorAll("td, th").forEach((s) => {
|
|
199
199
|
const l = s.textContent.trim().match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
|
|
200
200
|
if (l) {
|
|
201
|
-
const c = parseFloat(l[1].replace(/,/g, "")), u = parseInt(l[2]),
|
|
201
|
+
const c = parseFloat(l[1].replace(/,/g, "")), u = parseInt(l[2]), f = c * Math.pow(10, u), h = this.formatNumber(f);
|
|
202
202
|
s.textContent = h;
|
|
203
203
|
}
|
|
204
204
|
});
|
|
@@ -209,8 +209,8 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
209
209
|
* @param {number} num - The number to format
|
|
210
210
|
* @returns {string} The formatted number
|
|
211
211
|
*/
|
|
212
|
-
formatNumber(
|
|
213
|
-
return
|
|
212
|
+
formatNumber(t) {
|
|
213
|
+
return t === 0 ? "0" : Math.abs(t) >= 1e12 ? (t / 1e12).toFixed(2) + "T" : Math.abs(t) >= 1e9 ? (t / 1e9).toFixed(2) + "B" : Math.abs(t) >= 1e6 ? (t / 1e6).toFixed(2) + "M" : Math.abs(t) >= 1e3 ? (t / 1e3).toFixed(2) + "K" : Math.abs(t) < 0.01 && t !== 0 ? t.toExponential(2) : t.toLocaleString();
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
216
|
* Convert the first row to a header row
|
|
@@ -219,15 +219,15 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
219
219
|
* @param {HTMLElement} tbody - The tbody element to remove from
|
|
220
220
|
* @returns {HTMLElement} The converted header row
|
|
221
221
|
*/
|
|
222
|
-
convertRowToHeader(
|
|
222
|
+
convertRowToHeader(t, e, o) {
|
|
223
223
|
try {
|
|
224
|
-
const r =
|
|
224
|
+
const r = t.cloneNode(!0);
|
|
225
225
|
return r.querySelectorAll("td").forEach((s) => {
|
|
226
226
|
const a = document.createElement("th");
|
|
227
227
|
Array.from(s.attributes).forEach((l) => {
|
|
228
228
|
a.setAttribute(l.name, l.value);
|
|
229
229
|
}), a.innerHTML = s.innerHTML, a.style.cssText = s.style.cssText, s.parentNode.replaceChild(a, s);
|
|
230
|
-
}), o && o.contains(
|
|
230
|
+
}), o && o.contains(t) ? o.removeChild(t) : t.parentNode && t.parentNode.removeChild(t), e.appendChild(r), r;
|
|
231
231
|
} catch (r) {
|
|
232
232
|
return console.error("Error converting row to header:", r), null;
|
|
233
233
|
}
|
|
@@ -235,35 +235,35 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
235
235
|
/**
|
|
236
236
|
* Make a specific header sortable
|
|
237
237
|
*/
|
|
238
|
-
makeHeaderSortable(
|
|
239
|
-
|
|
238
|
+
makeHeaderSortable(t, e, o, r) {
|
|
239
|
+
t.classList.add(this.options.sortableClass), t.style.cursor = "pointer", (!this.options.preserveExistingIcons || !t.querySelector(".material-icons")) && this.addSortIcon(t), this.options.enableResizing && this.addResizing(t, e, o, r), this.options.enableReordering && this.addDragAndDrop(t, e, o, r);
|
|
240
240
|
const i = /* @__PURE__ */ d((l) => {
|
|
241
|
-
l.preventDefault(), this.sortTable(
|
|
241
|
+
l.preventDefault(), this.sortTable(e, o, r);
|
|
242
242
|
}, "clickListener"), s = /* @__PURE__ */ d((l) => {
|
|
243
|
-
|
|
243
|
+
t.classList.contains(this.options.activeSortClass) || (t.style.background = this.options.theme.palette.surface.hover);
|
|
244
244
|
}, "mouseEnterListener"), a = /* @__PURE__ */ d((l) => {
|
|
245
|
-
|
|
245
|
+
t.classList.contains(this.options.activeSortClass) || (t.style.background = "");
|
|
246
246
|
}, "mouseLeaveListener");
|
|
247
|
-
|
|
247
|
+
t.removeEventListener("click", i), t.addEventListener("click", i), t.removeEventListener("mouseenter", s), t.addEventListener("mouseenter", s), t.removeEventListener("mouseleave", a), t.addEventListener("mouseleave", a);
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
250
|
* Add sort icon to header
|
|
251
251
|
*/
|
|
252
|
-
addSortIcon(
|
|
253
|
-
if (
|
|
252
|
+
addSortIcon(t) {
|
|
253
|
+
if (t.querySelector(".sortable-table-icon"))
|
|
254
254
|
return;
|
|
255
|
-
const
|
|
256
|
-
|
|
255
|
+
const e = document.createElement("i");
|
|
256
|
+
e.id = "sortable-table-icon", e.className = "material-icons", e.textContent = this.options.unsortedIcon, e.style.marginRight = "2px", e.style.fontSize = "12px", e.style.verticalAlign = "middle", e.style.opacity = "0", t.querySelector(".material-icons") || (t.insertBefore(e, t.firstChild), requestAnimationFrame(() => {
|
|
257
257
|
requestAnimationFrame(() => {
|
|
258
|
-
|
|
258
|
+
e.style.opacity = "0.6";
|
|
259
259
|
});
|
|
260
260
|
}));
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
263
|
* Sort table by column
|
|
264
264
|
*/
|
|
265
|
-
sortTable(
|
|
266
|
-
const r =
|
|
265
|
+
sortTable(t, e, o) {
|
|
266
|
+
const r = t.querySelector("tbody");
|
|
267
267
|
if (!r) {
|
|
268
268
|
console.warn("Table has no tbody element");
|
|
269
269
|
return;
|
|
@@ -273,11 +273,11 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
273
273
|
console.warn("Table has no data rows");
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
const s = this.sortStates.get(
|
|
277
|
-
|
|
276
|
+
const s = this.sortStates.get(e);
|
|
277
|
+
t.querySelector(`thead tr th:nth-child(${o + 1})`);
|
|
278
278
|
let a;
|
|
279
|
-
if (this.options.sortOnFirstClick ? a = s.currentColumn === o && s.direction === "asc" ? "desc" : "asc" : s.currentColumn !== o ? a = "asc" : a = s.direction === "none" ? "asc" : s.direction === "asc" ? "desc" : "none", s.currentColumn = o, s.direction = a, this.sortStates.set(
|
|
280
|
-
this.restoreOriginalOrder(
|
|
279
|
+
if (this.options.sortOnFirstClick ? a = s.currentColumn === o && s.direction === "asc" ? "desc" : "asc" : s.currentColumn !== o ? a = "asc" : a = s.direction === "none" ? "asc" : s.direction === "asc" ? "desc" : "none", s.currentColumn = o, s.direction = a, this.sortStates.set(e, s), this.updateSortIndicators(t, e, o, a), a === "none") {
|
|
280
|
+
this.restoreOriginalOrder(t, i);
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
this.sortRows(i, o, a).forEach((c) => r.appendChild(c));
|
|
@@ -285,13 +285,13 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
285
285
|
/**
|
|
286
286
|
* Sort rows based on column data
|
|
287
287
|
*/
|
|
288
|
-
sortRows(
|
|
289
|
-
return
|
|
290
|
-
const s = r.cells[
|
|
288
|
+
sortRows(t, e, o) {
|
|
289
|
+
return t.sort((r, i) => {
|
|
290
|
+
const s = r.cells[e], a = i.cells[e];
|
|
291
291
|
if (!s || !a) return 0;
|
|
292
292
|
const l = this.extractValue(s), c = this.extractValue(a);
|
|
293
|
-
if (this.options.customSorters[
|
|
294
|
-
return this.options.customSorters[
|
|
293
|
+
if (this.options.customSorters[e])
|
|
294
|
+
return this.options.customSorters[e](l, c, o);
|
|
295
295
|
const u = this.compareValues(l, c);
|
|
296
296
|
return o === "asc" ? u : -u;
|
|
297
297
|
});
|
|
@@ -299,39 +299,39 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
299
299
|
/**
|
|
300
300
|
* Extract sortable value from cell
|
|
301
301
|
*/
|
|
302
|
-
extractValue(
|
|
303
|
-
let
|
|
302
|
+
extractValue(t) {
|
|
303
|
+
let e = t.textContent.trim(), o = B(e);
|
|
304
304
|
if (!isNaN(o))
|
|
305
305
|
return console.log(o), o;
|
|
306
|
-
if (
|
|
306
|
+
if (e = e.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(e))
|
|
307
307
|
return -1;
|
|
308
|
-
const i =
|
|
308
|
+
const i = e.match(/^([\d,]+\.?\d*)\s*%$/);
|
|
309
309
|
if (i)
|
|
310
310
|
return parseFloat(i[1].replace(/,/g, ""));
|
|
311
|
-
const s =
|
|
311
|
+
const s = e.match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
|
|
312
312
|
if (s) {
|
|
313
|
-
const u = parseFloat(s[1].replace(/,/g, "")),
|
|
314
|
-
return u * Math.pow(10,
|
|
313
|
+
const u = parseFloat(s[1].replace(/,/g, "")), f = parseInt(s[2]);
|
|
314
|
+
return u * Math.pow(10, f);
|
|
315
315
|
}
|
|
316
|
-
if (
|
|
317
|
-
return this.parseNumber(
|
|
318
|
-
const l =
|
|
316
|
+
if (e.match(/^[\d,]+\.?\d*[KMB]?$/))
|
|
317
|
+
return this.parseNumber(e);
|
|
318
|
+
const l = e.match(/^R\$\s*([\d,]+\.?\d*)$/);
|
|
319
319
|
if (l)
|
|
320
320
|
return this.parseNumber(l[1]);
|
|
321
|
-
const c = new Date(
|
|
322
|
-
return isNaN(c.getTime()) ?
|
|
321
|
+
const c = new Date(e);
|
|
322
|
+
return isNaN(c.getTime()) ? e.toLowerCase() : c.getTime();
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
325
325
|
* Compare two values for sorting
|
|
326
326
|
*/
|
|
327
|
-
compareValues(
|
|
328
|
-
return
|
|
327
|
+
compareValues(t, e) {
|
|
328
|
+
return t == null && e == null ? 0 : t == null ? -1 : e == null ? 1 : typeof t != typeof e ? String(t).localeCompare(String(e)) : typeof t == "number" ? t - e : t instanceof Date ? t.getTime() - e.getTime() : t.localeCompare(e);
|
|
329
329
|
}
|
|
330
330
|
/**
|
|
331
331
|
* Update visual indicators for sort state
|
|
332
332
|
*/
|
|
333
|
-
updateSortIndicators(
|
|
334
|
-
const i =
|
|
333
|
+
updateSortIndicators(t, e, o, r) {
|
|
334
|
+
const i = t.querySelectorAll("thead tr th");
|
|
335
335
|
if (i.forEach((s, a) => {
|
|
336
336
|
s.classList.remove(this.options.activeSortClass, this.options.ascendingClass, this.options.descendingClass);
|
|
337
337
|
const l = s.querySelector(".material-icons");
|
|
@@ -346,15 +346,15 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
346
346
|
/**
|
|
347
347
|
* Restore original order (when sort direction is 'none')
|
|
348
348
|
*/
|
|
349
|
-
restoreOriginalOrder(
|
|
350
|
-
const o =
|
|
351
|
-
|
|
349
|
+
restoreOriginalOrder(t, e) {
|
|
350
|
+
const o = t.querySelector("tbody");
|
|
351
|
+
e.forEach((r) => o.appendChild(r));
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* Add resizing functionality to a header
|
|
355
355
|
*/
|
|
356
|
-
addResizing(
|
|
357
|
-
if (
|
|
356
|
+
addResizing(t, e, o, r) {
|
|
357
|
+
if (t.classList.add(this.options.resizableClass), t.style.position = "relative", t.querySelector(".resize-handle"))
|
|
358
358
|
return;
|
|
359
359
|
const i = document.createElement("div");
|
|
360
360
|
i.className = "resize-handle", i.style.cssText = `
|
|
@@ -366,66 +366,66 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
366
366
|
background: transparent;
|
|
367
367
|
cursor: col-resize;
|
|
368
368
|
z-index: 10;
|
|
369
|
-
`,
|
|
369
|
+
`, t.appendChild(i);
|
|
370
370
|
let s = !1, a = 0, l = 0;
|
|
371
|
-
i.addEventListener("mousedown", (
|
|
372
|
-
|
|
371
|
+
i.addEventListener("mousedown", (f) => {
|
|
372
|
+
f.preventDefault(), f.stopPropagation(), f.stopImmediatePropagation(), s = !0, a = f.clientX, l = t.offsetWidth, t.style.borderRight = "2px solid var(--primary-main, #2196F3)", t.style.background = "var(--background-active, rgba(255, 255, 255, 0.1))", document.addEventListener("mousemove", c), document.addEventListener("mouseup", u), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
373
373
|
});
|
|
374
|
-
const c = /* @__PURE__ */ d((
|
|
374
|
+
const c = /* @__PURE__ */ d((f) => {
|
|
375
375
|
if (!s) return;
|
|
376
|
-
const h = l + (
|
|
376
|
+
const h = l + (f.clientX - a);
|
|
377
377
|
if (h > 30) {
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
const b = v.children[
|
|
378
|
+
t.style.width = h + "px";
|
|
379
|
+
const m = Array.from(t.parentNode.children).indexOf(t), p = e.querySelector("tbody");
|
|
380
|
+
p && p.querySelectorAll("tr").forEach((v) => {
|
|
381
|
+
const b = v.children[m];
|
|
382
382
|
b && (b.style.width = h + "px");
|
|
383
|
-
}), this.updateTableWidth(
|
|
383
|
+
}), this.updateTableWidth(e);
|
|
384
384
|
}
|
|
385
385
|
}, "handleResize"), u = /* @__PURE__ */ d(() => {
|
|
386
|
-
s = !1,
|
|
386
|
+
s = !1, t.style.borderRight = "", t.style.background = "", document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", u), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
387
387
|
}, "stopResize");
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
390
390
|
* Add drag and drop functionality to a header
|
|
391
391
|
*/
|
|
392
|
-
addDragAndDrop(
|
|
393
|
-
if (
|
|
392
|
+
addDragAndDrop(t, e, o, r) {
|
|
393
|
+
if (t.querySelector(".drag-handle"))
|
|
394
394
|
return;
|
|
395
|
-
|
|
396
|
-
const i =
|
|
397
|
-
|
|
395
|
+
t.classList.add(this.options.draggableClass), t.draggable = !0;
|
|
396
|
+
const i = e.querySelector("thead tr");
|
|
397
|
+
t.addEventListener("dragstart", (s) => {
|
|
398
398
|
this.isDragging = !0;
|
|
399
|
-
const a = Array.from(i.children).indexOf(
|
|
400
|
-
this.dragSource = { table:
|
|
401
|
-
const l =
|
|
402
|
-
|
|
403
|
-
}),
|
|
404
|
-
this.isDragging = !1, this.dragSource = null,
|
|
405
|
-
}),
|
|
399
|
+
const a = Array.from(i.children).indexOf(t);
|
|
400
|
+
this.dragSource = { table: e, tableIndex: o, columnIndex: a }, s.dataTransfer.effectAllowed = "move", s.dataTransfer.setData("text/html", t.outerHTML);
|
|
401
|
+
const l = t.outerHTML;
|
|
402
|
+
t.style.opacity = "0.5", this.createCustomDragImage(s, t, l);
|
|
403
|
+
}), t.addEventListener("dragend", (s) => {
|
|
404
|
+
this.isDragging = !1, this.dragSource = null, t.style.opacity = "", this.clearAllColumnHighlights(e);
|
|
405
|
+
}), t.addEventListener("dragover", (s) => {
|
|
406
406
|
s.preventDefault(), s.dataTransfer.dropEffect = "move";
|
|
407
|
-
}),
|
|
407
|
+
}), t.addEventListener("dragenter", (s) => {
|
|
408
408
|
if (s.preventDefault(), this.dragSource && this.dragSource.tableIndex === o) {
|
|
409
|
-
const a = Array.from(i.children).indexOf(
|
|
410
|
-
this.dragSource.columnIndex !== a && this.highlightColumn(
|
|
409
|
+
const a = Array.from(i.children).indexOf(t);
|
|
410
|
+
this.dragSource.columnIndex !== a && this.highlightColumn(e, a, !0);
|
|
411
411
|
}
|
|
412
|
-
}),
|
|
413
|
-
if (!
|
|
414
|
-
const a = Array.from(i.children).indexOf(
|
|
415
|
-
this.highlightColumn(
|
|
412
|
+
}), t.addEventListener("dragleave", (s) => {
|
|
413
|
+
if (!t.contains(s.relatedTarget)) {
|
|
414
|
+
const a = Array.from(i.children).indexOf(t);
|
|
415
|
+
this.highlightColumn(e, a, !1);
|
|
416
416
|
}
|
|
417
|
-
}),
|
|
417
|
+
}), t.addEventListener("drop", (s) => {
|
|
418
418
|
if (s.preventDefault(), this.dragSource && this.dragSource.tableIndex === o) {
|
|
419
|
-
const a = Array.from(i.children).indexOf(
|
|
420
|
-
this.dragSource.columnIndex !== a && this.reorderColumns(
|
|
419
|
+
const a = Array.from(i.children).indexOf(t);
|
|
420
|
+
this.dragSource.columnIndex !== a && this.reorderColumns(e, o, this.dragSource.columnIndex, a);
|
|
421
421
|
}
|
|
422
|
-
this.clearAllColumnHighlights(
|
|
422
|
+
this.clearAllColumnHighlights(e);
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Create a custom drag image for better UX
|
|
427
427
|
*/
|
|
428
|
-
createCustomDragImage(
|
|
428
|
+
createCustomDragImage(t, e, o) {
|
|
429
429
|
const r = document.createElement("div");
|
|
430
430
|
r.style.cssText = `
|
|
431
431
|
position: absolute;
|
|
@@ -456,30 +456,30 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
456
456
|
<span style="overflow: hidden; text-overflow: ellipsis">${i}</span>
|
|
457
457
|
<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>
|
|
458
458
|
</div>
|
|
459
|
-
`, document.body.appendChild(r),
|
|
459
|
+
`, document.body.appendChild(r), t.dataTransfer.setDragImage(r, 50, 12), setTimeout(() => {
|
|
460
460
|
document.body.contains(r) && document.body.removeChild(r);
|
|
461
461
|
}, 100);
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
464
464
|
* Highlight an entire column during drag operations
|
|
465
465
|
*/
|
|
466
|
-
highlightColumn(
|
|
467
|
-
const r =
|
|
466
|
+
highlightColumn(t, e, o) {
|
|
467
|
+
const r = t.querySelector("thead tr"), i = t.querySelector("tbody");
|
|
468
468
|
if (!r || !i) return;
|
|
469
|
-
const s = r.children[
|
|
469
|
+
const s = r.children[e];
|
|
470
470
|
if (s)
|
|
471
471
|
if (o) {
|
|
472
472
|
s.classList.add(this.options.dragOverClass);
|
|
473
473
|
const a = i.children;
|
|
474
474
|
for (let l = 0; l < a.length; l++) {
|
|
475
|
-
const c = a[l].children[
|
|
475
|
+
const c = a[l].children[e];
|
|
476
476
|
c && c.classList.add(this.options.dragOverClass);
|
|
477
477
|
}
|
|
478
478
|
} else {
|
|
479
479
|
s.classList.remove(this.options.dragOverClass);
|
|
480
480
|
const a = i.children;
|
|
481
481
|
for (let l = 0; l < a.length; l++) {
|
|
482
|
-
const c = a[l].children[
|
|
482
|
+
const c = a[l].children[e];
|
|
483
483
|
c && c.classList.remove(this.options.dragOverClass);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
@@ -487,10 +487,10 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
487
487
|
/**
|
|
488
488
|
* Clear all column highlights
|
|
489
489
|
*/
|
|
490
|
-
clearAllColumnHighlights(
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
493
|
-
const r =
|
|
490
|
+
clearAllColumnHighlights(t) {
|
|
491
|
+
const e = t.querySelector("thead tr"), o = t.querySelector("tbody");
|
|
492
|
+
if (!e || !o) return;
|
|
493
|
+
const r = e.children;
|
|
494
494
|
for (let s = 0; s < r.length; s++)
|
|
495
495
|
r[s].classList.remove(this.options.dragOverClass);
|
|
496
496
|
const i = o.children;
|
|
@@ -503,8 +503,8 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
503
503
|
/**
|
|
504
504
|
* Reorder columns in a table
|
|
505
505
|
*/
|
|
506
|
-
reorderColumns(
|
|
507
|
-
const i =
|
|
506
|
+
reorderColumns(t, e, o, r) {
|
|
507
|
+
const i = t.querySelector("thead tr"), s = t.querySelector("tbody");
|
|
508
508
|
if (!i || !s) return;
|
|
509
509
|
const a = Array.from(i.children), l = Array.from(s.children);
|
|
510
510
|
if (o < 0 || o >= a.length || r < 0 || r >= a.length) {
|
|
@@ -514,38 +514,38 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
514
514
|
if (o === r)
|
|
515
515
|
return;
|
|
516
516
|
const c = a[o], u = a[r];
|
|
517
|
-
o < r ? i.insertBefore(c, u.nextSibling) : i.insertBefore(c, u), l.forEach((h,
|
|
518
|
-
const
|
|
517
|
+
o < r ? i.insertBefore(c, u.nextSibling) : i.insertBefore(c, u), l.forEach((h, m) => {
|
|
518
|
+
const p = Array.from(h.children), y = p[o], v = p[r];
|
|
519
519
|
o < r ? h.insertBefore(y, v.nextSibling) : h.insertBefore(y, v);
|
|
520
520
|
});
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const h = [...
|
|
524
|
-
h.splice(o, 1), h.splice(r, 0,
|
|
521
|
+
const f = this.originalColumnOrder.get(e);
|
|
522
|
+
if (f) {
|
|
523
|
+
const h = [...f], m = h[o];
|
|
524
|
+
h.splice(o, 1), h.splice(r, 0, m), this.originalColumnOrder.set(e, h);
|
|
525
525
|
}
|
|
526
|
-
this.applyTableStyles(
|
|
526
|
+
this.applyTableStyles(t), this.refreshDragAndDropListeners(t, e);
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
529
529
|
* Refresh drag and drop listeners after column reordering
|
|
530
530
|
*/
|
|
531
|
-
refreshDragAndDropListeners(
|
|
532
|
-
const o =
|
|
531
|
+
refreshDragAndDropListeners(t, e) {
|
|
532
|
+
const o = t.querySelector("thead tr");
|
|
533
533
|
if (!o) return;
|
|
534
534
|
Array.from(o.children).forEach((i, s) => {
|
|
535
535
|
if (i.classList.contains(this.options.draggableClass)) {
|
|
536
536
|
i.style.opacity = "", i.style.background = "", i.style.borderRight = "";
|
|
537
537
|
const a = i.cloneNode(!0);
|
|
538
|
-
i.parentNode.replaceChild(a, i), this.makeHeaderSortable(a,
|
|
538
|
+
i.parentNode.replaceChild(a, i), this.makeHeaderSortable(a, t, e, s);
|
|
539
539
|
}
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
/**
|
|
543
543
|
* Update table width based on current column widths
|
|
544
544
|
*/
|
|
545
|
-
updateTableWidth(
|
|
546
|
-
const
|
|
545
|
+
updateTableWidth(t) {
|
|
546
|
+
const e = t.querySelectorAll("th");
|
|
547
547
|
let o = 0;
|
|
548
|
-
|
|
548
|
+
e.forEach((r) => {
|
|
549
549
|
const i = r.style.width;
|
|
550
550
|
if (i) {
|
|
551
551
|
const s = parseInt(i.replace("px", ""));
|
|
@@ -554,34 +554,34 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
554
554
|
const s = r.textContent.replace(/[📊🔍]/g, "").trim();
|
|
555
555
|
o += s.length;
|
|
556
556
|
}
|
|
557
|
-
}),
|
|
557
|
+
}), t.style.width = `${o}px`;
|
|
558
558
|
}
|
|
559
559
|
/**
|
|
560
560
|
* Calculate intelligent table width based on header text length
|
|
561
561
|
*/
|
|
562
|
-
calculateTableWidth(
|
|
563
|
-
var
|
|
564
|
-
const
|
|
562
|
+
calculateTableWidth(t) {
|
|
563
|
+
var f;
|
|
564
|
+
const e = t.getAttribute("data-original-width"), o = e ? parseFloat(e) : 0, r = t.querySelectorAll("th");
|
|
565
565
|
let i = 0;
|
|
566
|
-
|
|
566
|
+
t.parentElement.clientWidth;
|
|
567
567
|
const s = [];
|
|
568
568
|
r.forEach((h) => {
|
|
569
|
-
let
|
|
570
|
-
s.push(
|
|
569
|
+
let p = h.textContent.replace(/[📊🔍]/g, "").trim().length * this.charWidth + 15;
|
|
570
|
+
s.push(p), i += p;
|
|
571
571
|
});
|
|
572
|
-
const a =
|
|
572
|
+
const a = t.querySelectorAll("tr"), l = ((f = t.parentElement) == null ? void 0 : f.getBoundingClientRect().width) ?? i;
|
|
573
573
|
var c = 0;
|
|
574
574
|
for (const h of a)
|
|
575
|
-
h.querySelectorAll("td").forEach((
|
|
576
|
-
const b =
|
|
575
|
+
h.querySelectorAll("td").forEach((p, y) => {
|
|
576
|
+
const b = p.textContent.length * this.charWidth + 15;
|
|
577
577
|
b > s[y] && y < s.length && (s[y] = b);
|
|
578
578
|
});
|
|
579
|
-
c = s.reduce((h,
|
|
579
|
+
c = s.reduce((h, m) => h += m, 0), r.forEach((h, m) => {
|
|
580
580
|
if (c > l) {
|
|
581
|
-
const
|
|
582
|
-
h.style.width = `${l *
|
|
581
|
+
const p = s[m] / c;
|
|
582
|
+
h.style.width = `${l * p}px`;
|
|
583
583
|
} else
|
|
584
|
-
h.style.width = `${s[
|
|
584
|
+
h.style.width = `${s[m]}px`;
|
|
585
585
|
});
|
|
586
586
|
let u = 0;
|
|
587
587
|
return c > l ? u = "100%" : u = `${Math.max(c, o)}px`, u;
|
|
@@ -589,15 +589,15 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
589
589
|
/**
|
|
590
590
|
* Apply inline styles to ensure text clipping and horizontal scroll work
|
|
591
591
|
*/
|
|
592
|
-
applyTableStyles(
|
|
593
|
-
const
|
|
594
|
-
|
|
592
|
+
applyTableStyles(t) {
|
|
593
|
+
const e = this.calculateTableWidth(t);
|
|
594
|
+
t.style.width = e, t.style.maxWidth = "100%";
|
|
595
595
|
}
|
|
596
596
|
// Signature matches the single call site — `init()` passes (fontFamily,
|
|
597
597
|
// fontMono), which used to land on a leading `char` parameter nothing read.
|
|
598
|
-
getCharWidth(
|
|
598
|
+
getCharWidth(t, e) {
|
|
599
599
|
const o = document.createElement("canvas").getContext("2d");
|
|
600
|
-
return o ? (o.fontFamily =
|
|
600
|
+
return o ? (o.fontFamily = t, o.fontMono = e, o.measureText("A ").width) : E.DEFAULT_CHAR_WIDTH;
|
|
601
601
|
}
|
|
602
602
|
/**
|
|
603
603
|
* Add CSS styles for sortable tables
|
|
@@ -605,8 +605,8 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
605
605
|
addStyles() {
|
|
606
606
|
if (document.getElementById("sortable-table-styles"))
|
|
607
607
|
return;
|
|
608
|
-
const
|
|
609
|
-
|
|
608
|
+
const t = document.createElement("style");
|
|
609
|
+
t.id = "sortable-table-styles", t.textContent = `
|
|
610
610
|
.${this.options.sortableClass} {
|
|
611
611
|
position: relative;
|
|
612
612
|
user-select: none;
|
|
@@ -732,14 +732,14 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
732
732
|
overflow-x: auto !important;
|
|
733
733
|
overflow-y: auto !important;
|
|
734
734
|
}
|
|
735
|
-
`, document.getElementById("sortable-table-styles") || document.head.appendChild(
|
|
735
|
+
`, document.getElementById("sortable-table-styles") || document.head.appendChild(t);
|
|
736
736
|
}
|
|
737
737
|
/**
|
|
738
738
|
* Destroy the sortable functionality
|
|
739
739
|
*/
|
|
740
740
|
destroy() {
|
|
741
|
-
this.tables.forEach((
|
|
742
|
-
|
|
741
|
+
this.tables.forEach((e) => {
|
|
742
|
+
e.querySelectorAll(`.${this.options.sortableClass}`).forEach((r) => {
|
|
743
743
|
r.classList.remove(
|
|
744
744
|
this.options.sortableClass,
|
|
745
745
|
this.options.activeSortClass,
|
|
@@ -750,8 +750,8 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
750
750
|
r.parentNode.replaceChild(i, r);
|
|
751
751
|
});
|
|
752
752
|
});
|
|
753
|
-
const
|
|
754
|
-
|
|
753
|
+
const t = document.getElementById("sortable-table-styles");
|
|
754
|
+
t && t.remove(), this.tables = [], this.sortStates.clear(), M.clear();
|
|
755
755
|
}
|
|
756
756
|
/**
|
|
757
757
|
* Refresh the library (useful after DOM changes)
|
|
@@ -760,42 +760,42 @@ const $ = /* @__PURE__ */ new Set(), C = class C {
|
|
|
760
760
|
this.destroy(), this.init();
|
|
761
761
|
}
|
|
762
762
|
};
|
|
763
|
-
d(
|
|
764
|
-
|
|
765
|
-
let A =
|
|
763
|
+
d(E, "SortableTable"), /** Fallback advance width, in px, for one character of the body font. */
|
|
764
|
+
q(E, "DEFAULT_CHAR_WIDTH", 8);
|
|
765
|
+
let A = E;
|
|
766
766
|
typeof window < "u" && (window.SortableTable = A);
|
|
767
|
-
const
|
|
767
|
+
const H = /* @__PURE__ */ new Set(["/", "@", "#"]), X = /* @__PURE__ */ d((n) => n === "/" ? "slash" : n === "@" ? "at" : "hash", "triggerTypeFor"), T = /[ \t\r\n\f\v]/, G = /\[[^\]\n]+\]/g, _ = /* @__PURE__ */ d((n, t, e) => {
|
|
768
768
|
let o = 0;
|
|
769
769
|
const r = /* @__PURE__ */ d((i) => {
|
|
770
|
-
const s = i === 0 ?
|
|
770
|
+
const s = i === 0 ? t : n[i - 1];
|
|
771
771
|
return s === void 0 || T.test(s);
|
|
772
772
|
}, "boundaryBefore");
|
|
773
773
|
for (; o < n.length; ) {
|
|
774
774
|
const i = n[o];
|
|
775
|
-
if (r(o) &&
|
|
775
|
+
if (r(o) && H.has(i)) {
|
|
776
776
|
let s = o + 1;
|
|
777
777
|
for (; s < n.length && !T.test(n[s]); ) s += 1;
|
|
778
|
-
|
|
778
|
+
e.push({ type: X(i), text: n.slice(o, s) }), o = s;
|
|
779
779
|
} else {
|
|
780
780
|
let s = o + 1;
|
|
781
781
|
for (; s < n.length; ) {
|
|
782
782
|
const a = n[s];
|
|
783
|
-
if (
|
|
783
|
+
if (H.has(a) && T.test(n[s - 1])) break;
|
|
784
784
|
s += 1;
|
|
785
785
|
}
|
|
786
|
-
|
|
786
|
+
e.push({ type: "plain", text: n.slice(o, s) }), o = s;
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
|
-
}, "tokenizeSegment"),
|
|
789
|
+
}, "tokenizeSegment"), tt = /* @__PURE__ */ d((n) => {
|
|
790
790
|
if (!n) return [];
|
|
791
|
-
const
|
|
791
|
+
const t = [], e = new RegExp(G.source, "g");
|
|
792
792
|
let o = 0;
|
|
793
|
-
for (let r =
|
|
794
|
-
r.index > o &&
|
|
795
|
-
return o < n.length &&
|
|
796
|
-
}, "tokenizeForHighlight"),
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
793
|
+
for (let r = e.exec(n); r; r = e.exec(n))
|
|
794
|
+
r.index > o && _(n.slice(o, r.index), o === 0 ? void 0 : n[o - 1], t), t.push({ type: "placeholder", text: r[0] }), o = r.index + r[0].length;
|
|
795
|
+
return o < n.length && _(n.slice(o), o === 0 ? void 0 : n[o - 1], t), t;
|
|
796
|
+
}, "tokenizeForHighlight"), et = /* @__PURE__ */ d((n, t) => {
|
|
797
|
+
const e = t.filter((r) => r.trim().length > 0).sort((r, i) => i.length - r.length);
|
|
798
|
+
if (e.length === 0) return n;
|
|
799
799
|
const o = [];
|
|
800
800
|
for (const r of n) {
|
|
801
801
|
if (r.type !== "plain") {
|
|
@@ -805,7 +805,7 @@ const q = /* @__PURE__ */ new Set(["/", "@", "#"]), I = /* @__PURE__ */ d((n) =>
|
|
|
805
805
|
let i = r.text;
|
|
806
806
|
for (; i.length > 0; ) {
|
|
807
807
|
let s = -1, a = 0;
|
|
808
|
-
for (const l of
|
|
808
|
+
for (const l of e) {
|
|
809
809
|
const c = i.indexOf(l);
|
|
810
810
|
c >= 0 && (s === -1 || c < s) && (s = c, a = l.length);
|
|
811
811
|
}
|
|
@@ -818,7 +818,7 @@ const q = /* @__PURE__ */ new Set(["/", "@", "#"]), I = /* @__PURE__ */ d((n) =>
|
|
|
818
818
|
}
|
|
819
819
|
return o;
|
|
820
820
|
}, "chipLocations");
|
|
821
|
-
function
|
|
821
|
+
function st(n, t, e = t, o = 600) {
|
|
822
822
|
const r = n.value;
|
|
823
823
|
let i = !1;
|
|
824
824
|
const s = /* @__PURE__ */ d(() => {
|
|
@@ -828,7 +828,7 @@ function Y(n, e, t = e, o = 600) {
|
|
|
828
828
|
s();
|
|
829
829
|
return;
|
|
830
830
|
}
|
|
831
|
-
n.selectionStart ===
|
|
831
|
+
n.selectionStart === t && n.selectionEnd === e || n.setSelectionRange(t, e);
|
|
832
832
|
}, "apply"), l = /* @__PURE__ */ d(() => {
|
|
833
833
|
document.activeElement === n && a();
|
|
834
834
|
}, "onSelectionChange");
|
|
@@ -836,20 +836,21 @@ function Y(n, e, t = e, o = 600) {
|
|
|
836
836
|
const c = window.setTimeout(s, o), u = window.setInterval(a, 50);
|
|
837
837
|
return document.addEventListener("selectionchange", l), n.addEventListener("keydown", s), n.addEventListener("input", s), n.addEventListener("pointerdown", s), s;
|
|
838
838
|
}
|
|
839
|
-
d(
|
|
840
|
-
function
|
|
839
|
+
d(st, "placeCaret");
|
|
840
|
+
function ot(n = {}) {
|
|
841
841
|
if (typeof document > "u") return;
|
|
842
|
-
const
|
|
842
|
+
const t = /* @__PURE__ */ d((i) => {
|
|
843
843
|
i.stopPropagation(), i.preventDefault(), o();
|
|
844
|
-
}, "onClick"),
|
|
845
|
-
i.stopPropagation(), i.preventDefault(), document.removeEventListener("mousedown",
|
|
844
|
+
}, "onClick"), e = /* @__PURE__ */ d((i) => {
|
|
845
|
+
i.stopPropagation(), i.preventDefault(), document.removeEventListener("mousedown", e, !0);
|
|
846
846
|
}, "onMouseDown"), o = /* @__PURE__ */ d(() => {
|
|
847
|
-
document.removeEventListener("click",
|
|
847
|
+
document.removeEventListener("click", t, !0), document.removeEventListener("mousedown", e, !0), document.removeEventListener("pointerdown", o, !0), window.clearTimeout(r);
|
|
848
848
|
}, "cleanup"), r = window.setTimeout(o, 500);
|
|
849
|
-
document.addEventListener("click",
|
|
849
|
+
document.addEventListener("click", t, !0), n.mousedown && (document.addEventListener("mousedown", e, !0), document.addEventListener("pointerdown", o, !0));
|
|
850
850
|
}
|
|
851
|
-
d(
|
|
852
|
-
|
|
851
|
+
d(ot, "swallowNextClick");
|
|
852
|
+
const rt = 3;
|
|
853
|
+
async function nt(n, { onAtQuery: t, onAtPersonQuery: e }, {
|
|
853
854
|
personConfidence: o = 0,
|
|
854
855
|
locationConfidence: r = 0,
|
|
855
856
|
personFirstThreshold: i = 0.5,
|
|
@@ -858,83 +859,85 @@ async function ee(n, { onAtQuery: e, onAtPersonQuery: t }, {
|
|
|
858
859
|
hotelNameConfidence: l = 0,
|
|
859
860
|
signal: c,
|
|
860
861
|
onUpdate: u,
|
|
861
|
-
byPriority:
|
|
862
|
+
byPriority: f = !1,
|
|
863
|
+
capLeading: h
|
|
862
864
|
} = {}) {
|
|
863
|
-
const
|
|
864
|
-
let
|
|
865
|
-
const
|
|
866
|
-
const
|
|
867
|
-
if (
|
|
868
|
-
const
|
|
869
|
-
return
|
|
865
|
+
const m = o >= i && o >= r;
|
|
866
|
+
let p = [], y = [], v = !t, b = !e, D = null;
|
|
867
|
+
const N = /* @__PURE__ */ d((g, w, C, W) => w && h !== void 0 && t && e && !(W && C.length === 0) ? g.slice(0, h) : g, "cap"), L = /* @__PURE__ */ d((g, w) => {
|
|
868
|
+
const C = N(g, !m, w, b), $ = N(w, m, g, v).map((S) => S.kind ? S : { ...S, kind: "person" });
|
|
869
|
+
if (t && e) {
|
|
870
|
+
const S = $.map((k) => ({ ...k, group: "person" })), O = C.map((k) => ({ ...k, group: "location" }));
|
|
871
|
+
return m ? [...S, ...O] : [...O, ...S];
|
|
870
872
|
}
|
|
871
|
-
return [
|
|
872
|
-
}, "merge"),
|
|
873
|
+
return [...$, ...C];
|
|
874
|
+
}, "merge"), x = /* @__PURE__ */ d(() => {
|
|
873
875
|
if (!u || c != null && c.aborted) return;
|
|
874
|
-
if (!
|
|
875
|
-
u(
|
|
876
|
+
if (!f) {
|
|
877
|
+
u(L(p, y));
|
|
876
878
|
return;
|
|
877
879
|
}
|
|
878
|
-
const g =
|
|
879
|
-
if (g.length === 0 && !(
|
|
880
|
-
const
|
|
880
|
+
const g = m ? L(b ? p : [], y) : L(p, v ? y : []);
|
|
881
|
+
if (g.length === 0 && !(v && b)) return;
|
|
882
|
+
const w = g.map((C) => C.id).join(`
|
|
881
883
|
`);
|
|
882
|
-
|
|
884
|
+
w !== D && (D = w, u(g));
|
|
883
885
|
}, "publish");
|
|
884
886
|
return await Promise.all([
|
|
885
|
-
|
|
887
|
+
t ? t(n, {
|
|
886
888
|
vertical: s,
|
|
887
889
|
hotelConfidence: a,
|
|
888
890
|
hotelNameConfidence: l,
|
|
889
891
|
signal: c,
|
|
890
|
-
byPriority:
|
|
892
|
+
byPriority: f,
|
|
891
893
|
onPartial: /* @__PURE__ */ d((g) => {
|
|
892
|
-
|
|
894
|
+
p = g, x();
|
|
893
895
|
}, "onPartial")
|
|
894
|
-
}).catch(() =>
|
|
895
|
-
|
|
896
|
+
}).catch(() => p).then((g) => {
|
|
897
|
+
p = g, v = !0, x();
|
|
896
898
|
}) : void 0,
|
|
897
|
-
|
|
898
|
-
|
|
899
|
+
e ? e(n, { leading: m, signal: c }).catch(() => []).then((g) => {
|
|
900
|
+
y = g, b = !0, x();
|
|
899
901
|
}) : void 0
|
|
900
|
-
]),
|
|
902
|
+
]), L(p, y);
|
|
901
903
|
}
|
|
902
|
-
d(
|
|
903
|
-
function
|
|
904
|
+
d(nt, "fetchAtMentions");
|
|
905
|
+
function it(n, t) {
|
|
904
906
|
var o, r;
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
+
const e = (o = n[t]) == null ? void 0 : o.group;
|
|
908
|
+
return e !== void 0 && (t === 0 || ((r = n[t - 1]) == null ? void 0 : r.group) !== e);
|
|
907
909
|
}
|
|
908
|
-
d(
|
|
909
|
-
function
|
|
910
|
-
return (n ?? []).map((
|
|
911
|
-
id:
|
|
912
|
-
label:
|
|
913
|
-
value:
|
|
914
|
-
hint:
|
|
915
|
-
kind:
|
|
916
|
-
section:
|
|
917
|
-
disabled:
|
|
918
|
-
disabledNote:
|
|
919
|
-
pred:
|
|
910
|
+
d(it, "isSectionStart");
|
|
911
|
+
function at(n) {
|
|
912
|
+
return (n ?? []).map((t) => ({
|
|
913
|
+
id: t.key,
|
|
914
|
+
label: t.label,
|
|
915
|
+
value: t.insert ?? t.label,
|
|
916
|
+
hint: t.hint,
|
|
917
|
+
kind: t.icon,
|
|
918
|
+
section: t.section,
|
|
919
|
+
disabled: t.disabled,
|
|
920
|
+
disabledNote: t.disabled ? "igual à origem" : void 0,
|
|
921
|
+
pred: t
|
|
920
922
|
}));
|
|
921
923
|
}
|
|
922
|
-
d(
|
|
924
|
+
d(at, "toPredictionRows");
|
|
923
925
|
export {
|
|
926
|
+
rt as P,
|
|
924
927
|
A as S,
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
928
|
+
I as a,
|
|
929
|
+
K as b,
|
|
930
|
+
et as c,
|
|
931
|
+
Q as d,
|
|
932
|
+
U as e,
|
|
933
|
+
nt as f,
|
|
934
|
+
Y as g,
|
|
935
|
+
J as h,
|
|
936
|
+
it as i,
|
|
937
|
+
ot as j,
|
|
938
|
+
tt as k,
|
|
939
|
+
st as p,
|
|
940
|
+
Z as s,
|
|
941
|
+
at as t
|
|
939
942
|
};
|
|
940
|
-
//# sourceMappingURL=predictionRows-
|
|
943
|
+
//# sourceMappingURL=predictionRows-Damfwthh.js.map
|