elastic-input 0.1.0 → 0.2.0

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.
@@ -4,7 +4,7 @@ var q = (n, e, t) => Vr(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import * as p from "react";
5
5
  import * as mr from "react-dom";
6
6
  var l = /* @__PURE__ */ ((n) => (n.FIELD_NAME = "FIELD_NAME", n.COLON = "COLON", n.VALUE = "VALUE", n.QUOTED_VALUE = "QUOTED_VALUE", n.AND = "AND", n.OR = "OR", n.NOT = "NOT", n.COMPARISON_OP = "COMPARISON_OP", n.LPAREN = "LPAREN", n.RPAREN = "RPAREN", n.SAVED_SEARCH = "SAVED_SEARCH", n.HISTORY_REF = "HISTORY_REF", n.PREFIX_OP = "PREFIX_OP", n.WILDCARD = "WILDCARD", n.REGEX = "REGEX", n.RANGE = "RANGE", n.TILDE = "TILDE", n.BOOST = "BOOST", n.WHITESPACE = "WHITESPACE", n.UNKNOWN = "UNKNOWN", n))(l || {});
7
- class ct {
7
+ class lt {
8
8
  constructor(e, t) {
9
9
  q(this, "input");
10
10
  q(this, "pos");
@@ -277,7 +277,7 @@ class ct {
277
277
  });
278
278
  }
279
279
  }
280
- class We {
280
+ class Ue {
281
281
  constructor(e) {
282
282
  q(this, "tokens");
283
283
  q(this, "pos");
@@ -480,34 +480,34 @@ class We {
480
480
  start: e.start,
481
481
  end: e.end
482
482
  });
483
- const H = this.parseRangeBound(c, f);
483
+ const U = this.parseRangeBound(c, f);
484
484
  return {
485
485
  type: "Range",
486
- lower: H.value,
486
+ lower: U.value,
487
487
  upper: "",
488
488
  lowerInclusive: s,
489
489
  upperInclusive: a ? u : !0,
490
- lowerQuoted: H.quoted,
490
+ lowerQuoted: U.quoted,
491
491
  upperQuoted: !1,
492
- lowerStart: H.valueStart,
493
- lowerEnd: H.valueEnd,
492
+ lowerStart: U.valueStart,
493
+ lowerEnd: U.valueEnd,
494
494
  upperStart: e.end,
495
495
  upperEnd: e.end,
496
496
  start: e.start,
497
497
  end: e.end
498
498
  };
499
499
  }
500
- const m = this.parseRangeBound(g[1], f), I = f + g[1].length + (c.length - g[1].length - g[2].length), P = this.parseRangeBound(g[2], I);
500
+ const E = this.parseRangeBound(g[1], f), F = f + g[1].length + (c.length - g[1].length - g[2].length), P = this.parseRangeBound(g[2], F);
501
501
  return {
502
502
  type: "Range",
503
- lower: m.value,
503
+ lower: E.value,
504
504
  upper: P.value,
505
505
  lowerInclusive: s,
506
506
  upperInclusive: a ? u : !0,
507
- lowerQuoted: m.quoted,
507
+ lowerQuoted: E.quoted,
508
508
  upperQuoted: P.quoted,
509
- lowerStart: m.valueStart,
510
- lowerEnd: m.valueEnd,
509
+ lowerStart: E.valueStart,
510
+ lowerEnd: E.valueEnd,
511
511
  upperStart: P.valueStart,
512
512
  upperEnd: P.valueEnd,
513
513
  start: e.start,
@@ -565,13 +565,13 @@ class We {
565
565
  start: a.start,
566
566
  end: a.end
567
567
  });
568
- const m = {
568
+ const E = {
569
569
  type: "Group",
570
570
  expression: { type: "BareTerm", value: "", quoted: !1, start: a.end, end: a.end },
571
571
  start: a.start,
572
572
  end: f ? f.end : a.end
573
573
  };
574
- return this.applyGroupBoost(m);
574
+ return this.applyGroupBoost(E);
575
575
  }
576
576
  const u = this.parseOr(), c = this.match(l.RPAREN);
577
577
  c || this.errors.push({
@@ -615,68 +615,68 @@ class We {
615
615
  let c = ":";
616
616
  const g = this.match(l.COMPARISON_OP);
617
617
  if (g && (c = g.value), ((r = this.peek()) == null ? void 0 : r.type) === l.LPAREN) {
618
- const m = this.advance();
618
+ const E = this.advance();
619
619
  if (!this.peek() || this.peek().type === l.RPAREN) {
620
620
  const x = this.match(l.RPAREN);
621
621
  x || this.errors.push({
622
622
  type: "Error",
623
- value: m.value,
623
+ value: E.value,
624
624
  message: "Unclosed parenthesis",
625
- start: m.start,
626
- end: m.end
625
+ start: E.start,
626
+ end: E.end
627
627
  });
628
- const R = {
628
+ const A = {
629
629
  type: "FieldGroup",
630
630
  field: a.value,
631
- expression: { type: "BareTerm", value: "", quoted: !1, start: m.end, end: m.end },
631
+ expression: { type: "BareTerm", value: "", quoted: !1, start: E.end, end: E.end },
632
632
  start: a.start,
633
- end: x ? x.end : m.end
633
+ end: x ? x.end : E.end
634
634
  };
635
- return this.applyGroupBoost(R);
635
+ return this.applyGroupBoost(A);
636
636
  }
637
- const I = this.parseOr(), P = this.match(l.RPAREN);
637
+ const F = this.parseOr(), P = this.match(l.RPAREN);
638
638
  P || this.errors.push({
639
639
  type: "Error",
640
- value: m.value,
640
+ value: E.value,
641
641
  message: "Missing closing parenthesis",
642
- start: m.start,
643
- end: m.end
642
+ start: E.start,
643
+ end: E.end
644
644
  });
645
- const H = {
645
+ const U = {
646
646
  type: "FieldGroup",
647
647
  field: a.value,
648
- expression: I,
648
+ expression: F,
649
649
  start: a.start,
650
- end: P ? P.end : I.end
650
+ end: P ? P.end : F.end
651
651
  };
652
- return this.applyGroupBoost(H);
652
+ return this.applyGroupBoost(U);
653
653
  }
654
654
  if (((s = this.peek()) == null ? void 0 : s.type) === l.RANGE) {
655
- const m = this.advance(), I = this.parseRange(m);
656
- return I.field = a.value, I.start = a.start, I;
655
+ const E = this.advance(), F = this.parseRange(E);
656
+ return F.field = a.value, F.start = a.start, F;
657
657
  }
658
658
  if (((i = this.peek()) == null ? void 0 : i.type) === l.REGEX) {
659
- const m = this.advance();
659
+ const E = this.advance();
660
660
  return {
661
661
  type: "Regex",
662
- pattern: m.value.slice(1, -1),
662
+ pattern: E.value.slice(1, -1),
663
663
  start: a.start,
664
- end: m.end
664
+ end: E.end
665
665
  };
666
666
  }
667
667
  const f = this.peek();
668
668
  if (f && (f.type === l.VALUE || f.type === l.QUOTED_VALUE || f.type === l.WILDCARD)) {
669
- const m = this.advance(), I = m.type === l.QUOTED_VALUE;
670
- I && this.checkUnclosedQuote(m);
671
- const P = I ? this.stripQuotes(m) : m.value;
669
+ const E = this.advance(), F = E.type === l.QUOTED_VALUE;
670
+ F && this.checkUnclosedQuote(E);
671
+ const P = F ? this.stripQuotes(E) : E.value;
672
672
  return this.applyModifiers({
673
673
  type: "FieldValue",
674
674
  field: a.value,
675
675
  operator: c,
676
676
  value: P,
677
- quoted: I,
677
+ quoted: F,
678
678
  start: a.start,
679
- end: m.end
679
+ end: E.end
680
680
  });
681
681
  }
682
682
  return {
@@ -813,9 +813,9 @@ class We {
813
813
  for (let f = c - 1; f >= 0; f--)
814
814
  if (e[f].type !== l.WHITESPACE) {
815
815
  if (e[f].type === l.COLON) {
816
- for (let m = f - 1; m >= 0; m--)
817
- if (e[m].type !== l.WHITESPACE) {
818
- if (e[m].type === l.FIELD_NAME) return e[m].value;
816
+ for (let E = f - 1; E >= 0; E--)
817
+ if (e[E].type !== l.WHITESPACE) {
818
+ if (e[E].type === l.FIELD_NAME) return e[E].value;
819
819
  break;
820
820
  }
821
821
  }
@@ -1026,13 +1026,13 @@ const zr = {
1026
1026
  dropdownShadow: "0 8px 24px rgba(0, 0, 0, 0.4)",
1027
1027
  typeBadgeBg: "#21262d",
1028
1028
  typeBadgeColor: "#8b949e"
1029
- }, qr = ["AND", "OR", "NOT"], Gr = 200, Gt = 10;
1030
- function nr(n) {
1029
+ }, Gr = ["AND", "OR", "NOT"], qr = 200, Gt = 10;
1030
+ function sr(n) {
1031
1031
  return n.replace(/\r\n/g, `
1032
1032
  `).replace(/\r/g, `
1033
1033
  `).replace(/[\u201C\u201D\u201E\u201F\u2033\u2036\u00AB\u00BB]/g, '"').replace(/[\u2018\u2019\u201A\u201B\u2032\u2035]/g, "'").replace(/[\u2013\u2014]/g, "-").replace(/\u2026/g, "...").replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\uFF01-\uFF5E]/g, (e) => String.fromCharCode(e.charCodeAt(0) - 65248));
1034
1034
  }
1035
- const sr = { "(": ")", "[": "]", '"': '"', "'": "'" };
1035
+ const ar = { "(": ")", "[": "]", '"': '"', "'": "'" };
1036
1036
  function Yr(n, e, t, r, s) {
1037
1037
  const i = n.slice(0, e), a = n.slice(e, t), u = n.slice(t);
1038
1038
  return {
@@ -1044,7 +1044,7 @@ function Yr(n, e, t, r, s) {
1044
1044
  // before closing char
1045
1045
  };
1046
1046
  }
1047
- function Kr(n) {
1047
+ function Qr(n) {
1048
1048
  if (!n.textContent)
1049
1049
  return "";
1050
1050
  const e = [];
@@ -1060,7 +1060,7 @@ function Kr(n) {
1060
1060
  }
1061
1061
  return t(n), e.join("");
1062
1062
  }
1063
- function ar(n, e, t) {
1063
+ function ir(n, e, t) {
1064
1064
  let r = -1, s = -1;
1065
1065
  for (let i = 0; i < n.length; i++) {
1066
1066
  const a = n[i];
@@ -1068,7 +1068,7 @@ function ar(n, e, t) {
1068
1068
  }
1069
1069
  return [r, s];
1070
1070
  }
1071
- function Qr(n, e, t) {
1071
+ function Kr(n, e, t) {
1072
1072
  if (n) {
1073
1073
  let r = n.end;
1074
1074
  if (n.type === l.FIELD_NAME && t) {
@@ -1085,7 +1085,7 @@ function Qr(n, e, t) {
1085
1085
  }
1086
1086
  return { start: e, end: e };
1087
1087
  }
1088
- class ir {
1088
+ class ut {
1089
1089
  constructor(e, t = [], r = [], s = Gt, i = {}) {
1090
1090
  q(this, "fields");
1091
1091
  q(this, "fieldMap");
@@ -1114,7 +1114,7 @@ class ir {
1114
1114
  this.searchHistory = e;
1115
1115
  }
1116
1116
  getSuggestions(e, t) {
1117
- const r = We.getCursorContext(e, t), s = Qr(r.token, t, e);
1117
+ const r = Ue.getCursorContext(e, t), s = Kr(r.token, t, e);
1118
1118
  switch (r.type) {
1119
1119
  case "FIELD_NAME":
1120
1120
  case "EMPTY": {
@@ -1169,9 +1169,9 @@ class ir {
1169
1169
  getFieldSuggestions(e, t, r) {
1170
1170
  const s = e.toLowerCase();
1171
1171
  return this.fields.map((a) => {
1172
- const u = a.name.toLowerCase(), c = (a.label || "").toLowerCase(), g = (a.aliases || []).map((m) => m.toLowerCase());
1172
+ const u = a.name.toLowerCase(), c = (a.label || "").toLowerCase(), g = (a.aliases || []).map((E) => E.toLowerCase());
1173
1173
  let f = 0;
1174
- return u.startsWith(s) ? f = 4 : c.startsWith(s) || g.some((m) => m.startsWith(s)) ? f = 3 : u.includes(s) ? f = 2 : (c.includes(s) || g.some((m) => m.includes(s))) && (f = 1), { field: a, score: f };
1174
+ return u.startsWith(s) ? f = 4 : c.startsWith(s) || g.some((E) => E.startsWith(s)) ? f = 3 : u.includes(s) ? f = 2 : (c.includes(s) || g.some((E) => E.includes(s))) && (f = 1), { field: a, score: f };
1175
1175
  }).filter((a) => a.score > 0).sort((a, u) => u.score - a.score).slice(0, this.maxSuggestions).map((a) => ({
1176
1176
  text: a.field.name + ":",
1177
1177
  label: a.field.label || a.field.name,
@@ -1194,21 +1194,6 @@ class ir {
1194
1194
  replaceEnd: s,
1195
1195
  matchPartial: t
1196
1196
  }));
1197
- if (e.suggestions && !e.asyncSearch) {
1198
- const i = t.toLowerCase();
1199
- return e.suggestions.map((u) => {
1200
- const c = u.toLowerCase();
1201
- let g = 0;
1202
- return c.startsWith(i) ? g = 2 : c.includes(i) && (g = 1), { value: u, score: g };
1203
- }).filter((u) => u.score > 0).sort((u, c) => c.score - u.score).slice(0, this.maxSuggestions).map((u) => ({
1204
- text: u.value,
1205
- label: u.value,
1206
- type: e.type,
1207
- replaceStart: r,
1208
- replaceEnd: s,
1209
- matchPartial: t
1210
- }));
1211
- }
1212
1197
  if (e.placeholder !== !1) {
1213
1198
  const i = {
1214
1199
  number: "Enter a number",
@@ -1227,7 +1212,7 @@ class ir {
1227
1212
  }
1228
1213
  getOperatorSuggestions(e, t, r) {
1229
1214
  const s = e.toLowerCase();
1230
- return qr.filter((i) => i.toLowerCase().startsWith(s)).map((i) => ({
1215
+ return Gr.filter((i) => i.toLowerCase().startsWith(s)).map((i) => ({
1231
1216
  text: i + " ",
1232
1217
  label: i,
1233
1218
  description: i === "AND" ? "Both conditions must match" : i === "OR" ? "Either condition must match" : "Negate the following condition",
@@ -1242,8 +1227,8 @@ class ir {
1242
1227
  return e.sort((t, r) => (r.priority ?? 0) - (t.priority ?? 0));
1243
1228
  }
1244
1229
  getSpecialHints(e, t) {
1245
- const r = [];
1246
- return this.options.showSavedSearchHint && this.savedSearches.length > 0 && r.push({
1230
+ const r = [], s = this.savedSearches.length > 0 || this.options.hasSavedSearchProvider, i = this.searchHistory.length > 0 || this.options.hasHistoryProvider;
1231
+ return this.options.showSavedSearchHint && s && r.push({
1247
1232
  text: "#",
1248
1233
  label: "#saved-search",
1249
1234
  description: "Type # to use a saved search",
@@ -1251,7 +1236,7 @@ class ir {
1251
1236
  replaceStart: e,
1252
1237
  replaceEnd: t,
1253
1238
  priority: 20
1254
- }), this.options.showHistoryHint && this.searchHistory.length > 0 && r.push({
1239
+ }), this.options.showHistoryHint && i && r.push({
1255
1240
  text: "!",
1256
1241
  label: "!history",
1257
1242
  description: "Type ! to search history",
@@ -1262,41 +1247,45 @@ class ir {
1262
1247
  }), r;
1263
1248
  }
1264
1249
  getSavedSearchSuggestions(e, t, r) {
1265
- const s = e.toLowerCase();
1266
- return this.savedSearches.filter((i) => i.name.toLowerCase().startsWith(s)).slice(0, this.maxSuggestions).map((i) => ({
1267
- text: "#" + i.name,
1268
- label: i.name,
1269
- description: i.description || i.query,
1250
+ return this.savedSearches.slice(0, this.maxSuggestions).map((s) => ({
1251
+ text: "#" + s.name,
1252
+ label: s.name,
1253
+ description: s.description || s.query,
1270
1254
  type: "savedSearch",
1271
1255
  replaceStart: t,
1272
1256
  replaceEnd: r,
1273
1257
  matchPartial: e,
1274
- sourceData: i
1258
+ sourceData: s
1275
1259
  }));
1276
1260
  }
1277
1261
  getHistorySuggestions(e, t, r) {
1278
- const s = e.toLowerCase();
1279
- return this.searchHistory.filter((i) => (i.label || i.query).toLowerCase().includes(s)).slice(0, this.maxSuggestions).map((i) => {
1280
- let a = i.query;
1281
- try {
1282
- const u = new ct(i.query).tokenize(), c = new We(u).parse();
1283
- c && c.type === "BooleanExpr" && (a = "(" + i.query + ")");
1284
- } catch {
1285
- }
1286
- return {
1287
- text: a,
1288
- label: i.label || i.query,
1289
- description: i.timestamp ? new Date(i.timestamp).toLocaleDateString() : void 0,
1290
- type: "history",
1291
- replaceStart: t,
1292
- replaceEnd: r,
1293
- matchPartial: e,
1294
- sourceData: i
1295
- };
1296
- });
1262
+ return this.searchHistory.slice(0, this.maxSuggestions).map((s) => ({
1263
+ text: ut.wrapHistoryQuery(s.query),
1264
+ label: s.label || s.query,
1265
+ description: s.timestamp ? new Date(s.timestamp).toLocaleDateString() : void 0,
1266
+ type: "history",
1267
+ replaceStart: t,
1268
+ replaceEnd: r,
1269
+ matchPartial: e,
1270
+ sourceData: s
1271
+ }));
1272
+ }
1273
+ /**
1274
+ * Wraps a history query in parens if the top-level AST node is a BooleanExpr
1275
+ * (explicit AND/OR or implicit adjacency). Already-grouped expressions
1276
+ * like -(a AND b) or (a OR b)^2 don't need extra wrapping.
1277
+ */
1278
+ static wrapHistoryQuery(e) {
1279
+ try {
1280
+ const t = new lt(e).tokenize(), r = new Ue(t).parse();
1281
+ if (r && r.type === "BooleanExpr")
1282
+ return "(" + e + ")";
1283
+ } catch {
1284
+ }
1285
+ return e;
1297
1286
  }
1298
1287
  }
1299
- function _t(n) {
1288
+ function It(n) {
1300
1289
  if (n === "") return null;
1301
1290
  const e = Number(n);
1302
1291
  return isNaN(e) ? `"${n}" is not a valid number` : null;
@@ -1321,11 +1310,11 @@ function jr(n) {
1321
1310
  const e = Date.parse(n);
1322
1311
  return !isNaN(e);
1323
1312
  }
1324
- function Bt(n) {
1313
+ function _t(n) {
1325
1314
  const e = n.getFullYear(), t = String(n.getMonth() + 1).padStart(2, "0"), r = String(n.getDate()).padStart(2, "0");
1326
1315
  return `${e}-${t}-${r}`;
1327
1316
  }
1328
- function Ht(n) {
1317
+ function Bt(n) {
1329
1318
  if (/^now$/i.test(n)) return /* @__PURE__ */ new Date();
1330
1319
  const e = n.match(/^now([+-])(\d+)([dhms])$/i);
1331
1320
  if (e) {
@@ -1358,7 +1347,7 @@ function Zr(n, e) {
1358
1347
  function Jr(n, e) {
1359
1348
  return new Date(n, e, 1).getDay();
1360
1349
  }
1361
- function it(n, e) {
1350
+ function at(n, e) {
1362
1351
  return n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate();
1363
1352
  }
1364
1353
  function or(n, e, t) {
@@ -1383,21 +1372,21 @@ const en = [
1383
1372
  function tn(n) {
1384
1373
  return en[n];
1385
1374
  }
1386
- function Ut(n) {
1375
+ function Ht(n) {
1387
1376
  if (n === "") return null;
1388
1377
  const e = n.match(/^[\[{](.+)\s+TO\s+(.+)[\]}]$/i);
1389
1378
  if (e) {
1390
- const t = Wt(e[1].trim());
1379
+ const t = Ut(e[1].trim());
1391
1380
  if (t) return `Range start: ${t}`;
1392
- const r = Wt(e[2].trim());
1381
+ const r = Ut(e[2].trim());
1393
1382
  return r ? `Range end: ${r}` : null;
1394
1383
  }
1395
- return Wt(n);
1384
+ return Ut(n);
1396
1385
  }
1397
- function Wt(n) {
1386
+ function Ut(n) {
1398
1387
  return /^now(\/[dhms])?$/i.test(n) || /^now[+-]\d+[dhms](\/[dhms])?$/i.test(n) || jr(n) ? null : `"${n}" is not a valid date. Use YYYY-MM-DD, relative (now-7d), or ISO 8601.`;
1399
1388
  }
1400
- function St(n) {
1389
+ function vt(n) {
1401
1390
  return n == null ? null : typeof n == "string" ? { message: n, severity: "error" } : n;
1402
1391
  }
1403
1392
  class lr {
@@ -1430,7 +1419,7 @@ class lr {
1430
1419
  start: e.start,
1431
1420
  end: e.end
1432
1421
  }), r && e.value !== "") {
1433
- const s = St(r({
1422
+ const s = vt(r({
1434
1423
  value: e.value,
1435
1424
  position: "bare_term",
1436
1425
  quoted: e.quoted
@@ -1494,10 +1483,10 @@ class lr {
1494
1483
  let i = null;
1495
1484
  switch (s.type) {
1496
1485
  case "number":
1497
- i = _t(e.value);
1486
+ i = It(e.value);
1498
1487
  break;
1499
1488
  case "date":
1500
- i = Ut(e.value);
1489
+ i = Ht(e.value);
1501
1490
  break;
1502
1491
  case "boolean":
1503
1492
  e.value !== "true" && e.value !== "false" && (i = `Expected "true" or "false", got "${e.value}"`);
@@ -1507,7 +1496,7 @@ class lr {
1507
1496
  break;
1508
1497
  }
1509
1498
  if (e.operator !== ":" && s.type !== "number" && s.type !== "date" && (i = `Comparison operator "${e.operator}" is not valid for ${s.type} fields`), !i && r) {
1510
- const a = St(r({
1499
+ const a = vt(r({
1511
1500
  value: e.value,
1512
1501
  position: "field_value",
1513
1502
  fieldName: s.name,
@@ -1613,10 +1602,10 @@ class lr {
1613
1602
  let g = null;
1614
1603
  switch (e.type) {
1615
1604
  case "number":
1616
- g = _t(t);
1605
+ g = It(t);
1617
1606
  break;
1618
1607
  case "date":
1619
- g = Ut(t);
1608
+ g = Ht(t);
1620
1609
  break;
1621
1610
  case "boolean":
1622
1611
  t !== "true" && t !== "false" && (g = `Expected "true" or "false", got "${t}"`);
@@ -1626,7 +1615,7 @@ class lr {
1626
1615
  break;
1627
1616
  }
1628
1617
  if (s !== ":" && e.type !== "number" && e.type !== "date" && (g = `Comparison operator "${s}" is not valid for ${e.type} fields`), !g && c) {
1629
- const f = St(c({
1618
+ const f = vt(c({
1630
1619
  value: t,
1631
1620
  position: "field_group_term",
1632
1621
  fieldName: e.name,
@@ -1673,17 +1662,17 @@ class lr {
1673
1662
  let u = null;
1674
1663
  switch (e.type) {
1675
1664
  case "number":
1676
- u = _t(a.value), u && (u = `${a.label}: ${u}`);
1665
+ u = It(a.value), u && (u = `${a.label}: ${u}`);
1677
1666
  break;
1678
1667
  case "date":
1679
- u = Ut(a.value), u && (u = `${a.label}: ${u}`);
1668
+ u = Ht(a.value), u && (u = `${a.label}: ${u}`);
1680
1669
  break;
1681
1670
  case "boolean":
1682
1671
  u = "Range queries are not supported for boolean fields";
1683
1672
  break;
1684
1673
  }
1685
1674
  if (!u && s) {
1686
- const c = St(s({
1675
+ const c = vt(s({
1687
1676
  value: a.value,
1688
1677
  position: a.position,
1689
1678
  fieldName: e.name,
@@ -1816,13 +1805,13 @@ function cr(n, e, t) {
1816
1805
  lineHeight: "1.4"
1817
1806
  };
1818
1807
  }
1819
- function Be(n) {
1808
+ function _e(n) {
1820
1809
  return {
1821
1810
  flex: 1,
1822
1811
  fontWeight: 500
1823
1812
  };
1824
1813
  }
1825
- function $t(n) {
1814
+ function Wt(n) {
1826
1815
  return {
1827
1816
  fontSize: "11px",
1828
1817
  opacity: 0.7,
@@ -2158,7 +2147,7 @@ const gn = {
2158
2147
  [l.WHITESPACE]: "text",
2159
2148
  [l.UNKNOWN]: "error"
2160
2149
  };
2161
- function ot(n, e, t) {
2150
+ function it(n, e, t) {
2162
2151
  const r = pt(e);
2163
2152
  if (n.length === 0) return "";
2164
2153
  const s = (t == null ? void 0 : t.cursorOffset) !== void 0 ? Sr(n, t.cursorOffset) : null;
@@ -2210,79 +2199,79 @@ function mn({
2210
2199
  renderHistoryItem: c,
2211
2200
  renderSavedSearchItem: g,
2212
2201
  renderDropdownHeader: f,
2213
- cursorContext: m
2202
+ cursorContext: E
2214
2203
  }) {
2215
- const I = p.useRef(null), P = p.useRef(null);
2204
+ const F = p.useRef(null), P = p.useRef(null);
2216
2205
  p.useEffect(() => {
2217
2206
  const v = document.createElement("div");
2218
- return document.body.appendChild(v), I.current = v, () => {
2219
- document.body.removeChild(v), I.current = null;
2207
+ return document.body.appendChild(v), F.current = v, () => {
2208
+ document.body.removeChild(v), F.current = null;
2220
2209
  };
2221
2210
  }, []);
2222
- const H = f && m ? f(m) : null, x = H != null;
2211
+ const U = f && E ? f(E) : null, x = U != null;
2223
2212
  if (p.useEffect(() => {
2224
2213
  if (P.current) {
2225
- const v = x ? e + 1 : e, _ = P.current.children[v];
2226
- _ && _.scrollIntoView({ block: "nearest" });
2214
+ const v = x ? e + 1 : e, H = P.current.children[v];
2215
+ H && H.scrollIntoView({ block: "nearest" });
2227
2216
  }
2228
- }, [e, x]), !I.current || !a || n.length === 0 || !r)
2217
+ }, [e, x]), !F.current || !a || n.length === 0 || !r)
2229
2218
  return null;
2230
- const R = pt(s), L = dt(i), F = {
2231
- ...vr(R, L),
2219
+ const A = pt(s), T = dt(i), B = {
2220
+ ...vr(A, T),
2232
2221
  top: `${r.top}px`,
2233
2222
  left: `${r.left}px`,
2234
2223
  ...u != null ? { width: `${u}px`, minWidth: "unset", maxWidth: "unset" } : {}
2235
- }, U = /* @__PURE__ */ p.createElement("div", { style: F, ref: P, onMouseDown: (v) => v.preventDefault() }, x && /* @__PURE__ */ p.createElement("div", { style: {
2236
- padding: L.dropdownItemPadding || "4px 10px",
2224
+ }, W = /* @__PURE__ */ p.createElement("div", { style: B, ref: P, onMouseDown: (v) => v.preventDefault() }, x && /* @__PURE__ */ p.createElement("div", { style: {
2225
+ padding: T.dropdownItemPadding || "4px 10px",
2237
2226
  fontSize: "11px",
2238
- color: R.placeholder,
2239
- borderBottom: `1px solid ${R.dropdownHover}`,
2227
+ color: A.placeholder,
2228
+ borderBottom: `1px solid ${A.dropdownHover}`,
2240
2229
  userSelect: "none"
2241
- } }, H), n.map((v, _) => {
2242
- const T = _ === e, z = cr(T, R, L);
2230
+ } }, U), n.map((v, H) => {
2231
+ const L = H === e, G = cr(L, A, T);
2243
2232
  if (v.type === "hint" && (v.text === "#" || v.text === "!"))
2244
2233
  return /* @__PURE__ */ p.createElement(
2245
2234
  "div",
2246
2235
  {
2247
- key: _,
2248
- style: { ...z, opacity: T ? 1 : 0.7 },
2236
+ key: H,
2237
+ style: { ...G, opacity: L ? 1 : 0.7 },
2249
2238
  onClick: () => t(v),
2250
2239
  onMouseEnter: (M) => {
2251
- M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover, M.currentTarget.style.opacity = "1";
2240
+ M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover, M.currentTarget.style.opacity = "1";
2252
2241
  },
2253
2242
  onMouseLeave: (M) => {
2254
- M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent", M.currentTarget.style.opacity = T ? "1" : "0.7";
2243
+ M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent", M.currentTarget.style.opacity = L ? "1" : "0.7";
2255
2244
  }
2256
2245
  },
2257
- /* @__PURE__ */ p.createElement("span", { style: Be() }, v.label),
2258
- v.description && /* @__PURE__ */ p.createElement("span", { style: $t() }, v.description)
2246
+ /* @__PURE__ */ p.createElement("span", { style: _e() }, v.label),
2247
+ v.description && /* @__PURE__ */ p.createElement("span", { style: Wt() }, v.description)
2259
2248
  );
2260
2249
  if (v.type === "error")
2261
- return /* @__PURE__ */ p.createElement("div", { key: _, style: { ...z, cursor: "default", opacity: 0.8 } }, /* @__PURE__ */ p.createElement("span", { style: { ...Be(), color: R.error } }, v.label || "Error loading suggestions"));
2250
+ return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...G, cursor: "default", opacity: 0.8 } }, /* @__PURE__ */ p.createElement("span", { style: { ..._e(), color: A.error } }, v.label || "Error loading suggestions"));
2262
2251
  if (v.type === "loading")
2263
- return /* @__PURE__ */ p.createElement("div", { key: _, style: { ...z, cursor: "default", opacity: 0.6, justifyContent: "center" } }, /* @__PURE__ */ p.createElement("span", { style: { ...Be(), fontStyle: "italic" } }, v.label || "Searching..."), /* @__PURE__ */ p.createElement("span", { style: { marginLeft: "6px", display: "inline-block", animation: "elastic-input-spin 1s linear infinite", width: "14px", height: "14px", border: "2px solid", borderColor: `${R.placeholder} transparent ${R.placeholder} transparent`, borderRadius: "50%" } }));
2252
+ return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...G, cursor: "default", opacity: 0.6, justifyContent: "center" } }, /* @__PURE__ */ p.createElement("span", { style: { ..._e(), fontStyle: "italic" } }, v.label || "Searching..."), /* @__PURE__ */ p.createElement("span", { style: { marginLeft: "6px", display: "inline-block", animation: "elastic-input-spin 1s linear infinite", width: "14px", height: "14px", border: "2px solid", borderColor: `${A.placeholder} transparent ${A.placeholder} transparent`, borderRadius: "50%" } }));
2264
2253
  if (v.type === "hint") {
2265
- const M = cr(!1, R, L);
2266
- return /* @__PURE__ */ p.createElement("div", { key: _, style: { ...M, cursor: "default", opacity: v.customContent ? 1 : 0.6 } }, v.customContent ? v.customContent : /* @__PURE__ */ p.createElement("span", { style: Be() }, v.label));
2254
+ const M = cr(!1, A, T);
2255
+ return /* @__PURE__ */ p.createElement("div", { key: H, style: { ...M, cursor: "default", opacity: v.customContent ? 1 : 0.6 } }, v.customContent ? v.customContent : /* @__PURE__ */ p.createElement("span", { style: _e() }, v.label));
2267
2256
  }
2268
2257
  if (v.type === "history") {
2269
- const M = c && v.sourceData ? c(v.sourceData, T) : null, D = v.text.startsWith("(") && v.text.endsWith(")") ? v.text.slice(1, -1) : v.text, ie = v.label !== D;
2258
+ const M = c && v.sourceData ? c(v.sourceData, L) : null, D = v.text.startsWith("(") && v.text.endsWith(")") ? v.text.slice(1, -1) : v.text, ce = v.label !== D;
2270
2259
  return /* @__PURE__ */ p.createElement(
2271
2260
  "div",
2272
2261
  {
2273
- key: _,
2274
- style: { ...z, flexDirection: "column", alignItems: "flex-start" },
2275
- title: ie ? v.text : void 0,
2262
+ key: H,
2263
+ style: { ...G, flexDirection: "column", alignItems: "flex-start" },
2264
+ title: ce ? v.text : void 0,
2276
2265
  onClick: () => t(v),
2277
- onMouseEnter: (J) => {
2278
- J.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
2266
+ onMouseEnter: (re) => {
2267
+ re.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
2279
2268
  },
2280
- onMouseLeave: (J) => {
2281
- J.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
2269
+ onMouseLeave: (re) => {
2270
+ re.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
2282
2271
  }
2283
2272
  },
2284
2273
  M ?? /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("span", { style: {
2285
- ...Be(),
2274
+ ..._e(),
2286
2275
  display: "-webkit-box",
2287
2276
  WebkitLineClamp: 2,
2288
2277
  WebkitBoxOrient: "vertical",
@@ -2290,23 +2279,23 @@ function mn({
2290
2279
  whiteSpace: "normal",
2291
2280
  wordBreak: "break-all",
2292
2281
  width: "100%"
2293
- } }, fr(v.label, v.matchPartial, T)), /* @__PURE__ */ p.createElement("span", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } }, v.description && /* @__PURE__ */ p.createElement("span", { style: { ...$t(), flex: 1 } }, v.description), /* @__PURE__ */ p.createElement("span", { style: { ...ur(T, L), marginLeft: "auto" } }, "history")))
2282
+ } }, fr(v.label, v.matchPartial, L)), /* @__PURE__ */ p.createElement("span", { style: { display: "flex", alignItems: "center", gap: "8px", width: "100%" } }, v.description && /* @__PURE__ */ p.createElement("span", { style: { ...Wt(), flex: 1 } }, v.description), /* @__PURE__ */ p.createElement("span", { style: { ...ur(L, T), marginLeft: "auto" } }, "history")))
2294
2283
  );
2295
2284
  }
2296
2285
  if (v.type === "savedSearch" && g && v.sourceData) {
2297
- const M = g(v.sourceData, T);
2286
+ const M = g(v.sourceData, L);
2298
2287
  if (M != null)
2299
2288
  return /* @__PURE__ */ p.createElement(
2300
2289
  "div",
2301
2290
  {
2302
- key: _,
2303
- style: z,
2291
+ key: H,
2292
+ style: G,
2304
2293
  onClick: () => t(v),
2305
2294
  onMouseEnter: (D) => {
2306
- D.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
2295
+ D.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
2307
2296
  },
2308
2297
  onMouseLeave: (D) => {
2309
- D.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
2298
+ D.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
2310
2299
  }
2311
2300
  },
2312
2301
  M
@@ -2315,74 +2304,74 @@ function mn({
2315
2304
  return /* @__PURE__ */ p.createElement(
2316
2305
  "div",
2317
2306
  {
2318
- key: _,
2319
- style: z,
2307
+ key: H,
2308
+ style: G,
2320
2309
  onClick: () => t(v),
2321
2310
  onMouseEnter: (M) => {
2322
- M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
2311
+ M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : A.dropdownHover;
2323
2312
  },
2324
2313
  onMouseLeave: (M) => {
2325
- M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
2314
+ M.currentTarget.style.backgroundColor = L ? A.dropdownSelected : "transparent";
2326
2315
  }
2327
2316
  },
2328
- /* @__PURE__ */ p.createElement("span", { style: Be() }, fr(v.label, v.matchPartial, T)),
2329
- v.description && /* @__PURE__ */ p.createElement("span", { style: $t() }, v.description),
2330
- v.type && v.type !== "hint" && /* @__PURE__ */ p.createElement("span", { style: ur(T, L) }, v.type)
2317
+ /* @__PURE__ */ p.createElement("span", { style: _e() }, fr(v.label, v.matchPartial, L)),
2318
+ v.description && /* @__PURE__ */ p.createElement("span", { style: Wt() }, v.description),
2319
+ v.type && v.type !== "hint" && /* @__PURE__ */ p.createElement("span", { style: ur(L, T) }, v.type)
2331
2320
  );
2332
2321
  }));
2333
- return mr.createPortal(U, I.current);
2322
+ return mr.createPortal(W, F.current);
2334
2323
  }
2335
2324
  const En = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2336
- function Vt(n) {
2325
+ function $t(n) {
2337
2326
  return Math.floor(n / 10) * 10;
2338
2327
  }
2339
2328
  function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s, initialEnd: i, presets: a }) {
2340
- const c = r === "range" && i ? i : s ?? /* @__PURE__ */ new Date(), [g, f] = p.useState(r ?? "single"), [m, I] = p.useState("days"), [P, H] = p.useState(c.getFullYear()), [x, R] = p.useState(c.getMonth()), [L, F] = p.useState(s ?? null), [U, v] = p.useState(i ?? null), [_, T] = p.useState(null), z = pt(e), M = dt(t), D = on(z, M), ie = () => {
2341
- m === "days" ? x === 0 ? (R(11), H((w) => w - 1)) : R((w) => w - 1) : H(m === "months" ? (w) => w - 1 : (w) => w - 10);
2342
- }, J = () => {
2343
- m === "days" ? x === 11 ? (R(0), H((w) => w + 1)) : R((w) => w + 1) : H(m === "months" ? (w) => w + 1 : (w) => w + 10);
2344
- }, ne = () => {
2345
- m === "days" ? I("months") : m === "months" && I("years");
2329
+ const c = r === "range" && i ? i : s ?? /* @__PURE__ */ new Date(), [g, f] = p.useState(r ?? "single"), [E, F] = p.useState("days"), [P, U] = p.useState(c.getFullYear()), [x, A] = p.useState(c.getMonth()), [T, B] = p.useState(s ?? null), [W, v] = p.useState(i ?? null), [H, L] = p.useState(null), G = pt(e), M = dt(t), D = on(G, M), ce = () => {
2330
+ E === "days" ? x === 0 ? (A(11), U((w) => w - 1)) : A((w) => w - 1) : U(E === "months" ? (w) => w - 1 : (w) => w - 10);
2331
+ }, re = () => {
2332
+ E === "days" ? x === 11 ? (A(0), U((w) => w + 1)) : A((w) => w + 1) : U(E === "months" ? (w) => w + 1 : (w) => w + 10);
2333
+ }, ie = () => {
2334
+ E === "days" ? F("months") : E === "months" && F("years");
2335
+ }, We = (w) => {
2336
+ A(w), F("days");
2346
2337
  }, $e = (w) => {
2347
- R(w), I("days");
2338
+ U(w), F("months");
2348
2339
  }, Ve = (w) => {
2349
- H(w), I("months");
2350
- }, ze = (w) => {
2351
2340
  const h = new Date(P, x, w);
2352
2341
  if (g === "single") {
2353
- n(Bt(h));
2342
+ n(_t(h));
2354
2343
  return;
2355
2344
  }
2356
- if (!L || U)
2357
- F(h), v(null), T(null);
2345
+ if (!T || W)
2346
+ B(h), v(null), L(null);
2358
2347
  else {
2359
- const [V, oe] = L <= h ? [L, h] : [h, L];
2360
- F(V), v(oe), T(null), n(`[${Bt(V)} TO ${Bt(oe)}]`);
2361
- }
2362
- }, K = L && !U ? _ : U, ft = (w) => {
2363
- f(w), F(null), v(null), T(null);
2364
- }, qe = m === "days" ? `${tn(x)} ${P}` : m === "months" ? `${P}` : `${Vt(P)}–${Vt(P) + 9}`, ke = m !== "years", Le = /* @__PURE__ */ new Date(), wt = Zr(P, x), bt = Jr(P, x), ht = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], Te = [];
2365
- for (let w = 0; w < bt; w++)
2366
- Te.push(/* @__PURE__ */ p.createElement("div", { key: `e${w}` }));
2367
- for (let w = 1; w <= wt; w++) {
2368
- const h = new Date(P, x, w), V = it(h, Le), oe = L && it(h, L), ye = K && it(h, K), Q = or(h, L, K), N = oe || ye, W = {
2348
+ const [V, ue] = T <= h ? [T, h] : [h, T];
2349
+ B(V), v(ue), L(null), n(`[${_t(V)} TO ${_t(ue)}]`);
2350
+ }
2351
+ }, X = T && !W ? H : W, ft = (w) => {
2352
+ f(w), B(null), v(null), L(null);
2353
+ }, ze = E === "days" ? `${tn(x)} ${P}` : E === "months" ? `${P}` : `${$t(P)}–${$t(P) + 9}`, Re = E !== "years", Te = /* @__PURE__ */ new Date(), xt = Zr(P, x), wt = Jr(P, x), ht = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], Le = [];
2354
+ for (let w = 0; w < wt; w++)
2355
+ Le.push(/* @__PURE__ */ p.createElement("div", { key: `e${w}` }));
2356
+ for (let w = 1; w <= xt; w++) {
2357
+ const h = new Date(P, x, w), V = at(h, Te), ue = T && at(h, T), he = X && at(h, X), j = or(h, T, X), N = ue || he, $ = {
2369
2358
  ...D.day,
2370
2359
  ...V ? D.dayToday : {},
2371
- ...Q ? D.dayInRange : {},
2360
+ ...j ? D.dayInRange : {},
2372
2361
  ...N ? D.daySelected : {}
2373
- }, me = g === "range" && L && !U;
2374
- Te.push(
2362
+ }, ge = g === "range" && T && !W;
2363
+ Le.push(
2375
2364
  /* @__PURE__ */ p.createElement(
2376
2365
  "button",
2377
2366
  {
2378
2367
  key: w,
2379
- style: W,
2380
- onClick: () => ze(w),
2381
- onMouseEnter: (X) => {
2382
- me ? T(h) : N || (X.currentTarget.style.backgroundColor = z.dropdownHover);
2368
+ style: $,
2369
+ onClick: () => Ve(w),
2370
+ onMouseEnter: (J) => {
2371
+ ge ? L(h) : N || (J.currentTarget.style.backgroundColor = G.dropdownHover);
2383
2372
  },
2384
- onMouseLeave: (X) => {
2385
- !me && !N && (X.currentTarget.style.backgroundColor = Q ? "rgba(9, 105, 218, 0.1)" : "transparent");
2373
+ onMouseLeave: (J) => {
2374
+ !ge && !N && (J.currentTarget.style.backgroundColor = j ? "rgba(9, 105, 218, 0.1)" : "transparent");
2386
2375
  }
2387
2376
  },
2388
2377
  w
@@ -2396,19 +2385,19 @@ function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s
2396
2385
  }, gt = {
2397
2386
  ...Pe,
2398
2387
  ...D.dayToday
2399
- }, Ye = a ?? [
2388
+ }, qe = a ?? [
2400
2389
  { label: "Today", value: "[now/d TO now]" },
2401
2390
  { label: "Yesterday", value: "[now-1d/d TO now/d]" },
2402
2391
  { label: "Last 7 days", value: "[now-7d TO now]" },
2403
2392
  { label: "Last 30 days", value: "[now-30d TO now]" },
2404
2393
  { label: "Last 90 days", value: "[now-90d TO now]" },
2405
2394
  { label: "Last 1 year", value: "[now-365d TO now]" }
2406
- ], Ke = {
2395
+ ], Ye = {
2407
2396
  display: "grid",
2408
2397
  gridTemplateColumns: "1fr 1fr",
2409
2398
  gap: "2px"
2410
2399
  };
2411
- return /* @__PURE__ */ p.createElement("div", { style: D.container, onMouseDown: (w) => w.preventDefault(), onMouseLeave: () => T(null) }, /* @__PURE__ */ p.createElement("div", { style: D.rangeToggle }, ["single", "range"].map((w) => /* @__PURE__ */ p.createElement(
2400
+ return /* @__PURE__ */ p.createElement("div", { style: D.container, onMouseDown: (w) => w.preventDefault(), onMouseLeave: () => L(null) }, /* @__PURE__ */ p.createElement("div", { style: D.rangeToggle }, ["single", "range"].map((w) => /* @__PURE__ */ p.createElement(
2412
2401
  "button",
2413
2402
  {
2414
2403
  key: w,
@@ -2419,79 +2408,79 @@ function vn({ onSelect: n, colors: e, styles: t, initialMode: r, initialStart: s
2419
2408
  onClick: () => ft(w)
2420
2409
  },
2421
2410
  w.charAt(0).toUpperCase() + w.slice(1)
2422
- ))), /* @__PURE__ */ p.createElement("div", { style: D.header }, /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: ie }, "‹"), /* @__PURE__ */ p.createElement(
2411
+ ))), /* @__PURE__ */ p.createElement("div", { style: D.header }, /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: ce }, "‹"), /* @__PURE__ */ p.createElement(
2423
2412
  "button",
2424
2413
  {
2425
2414
  style: {
2426
2415
  ...D.monthLabel,
2427
2416
  backgroundColor: "transparent",
2428
2417
  border: "none",
2429
- cursor: ke ? "pointer" : "default",
2418
+ cursor: Re ? "pointer" : "default",
2430
2419
  padding: "2px 8px",
2431
2420
  borderRadius: "4px"
2432
2421
  },
2433
- onClick: ke ? ne : void 0,
2422
+ onClick: Re ? ie : void 0,
2434
2423
  onMouseEnter: (w) => {
2435
- ke && (w.currentTarget.style.backgroundColor = "#eef1f5");
2424
+ Re && (w.currentTarget.style.backgroundColor = "#eef1f5");
2436
2425
  },
2437
2426
  onMouseLeave: (w) => {
2438
2427
  w.currentTarget.style.backgroundColor = "transparent";
2439
2428
  }
2440
2429
  },
2441
- qe
2442
- ), /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: J }, "›")), m === "days" && /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("div", { style: D.weekDays }, ht.map((w) => /* @__PURE__ */ p.createElement("div", { key: w, style: D.weekDay }, w))), /* @__PURE__ */ p.createElement("div", { style: D.days }, Te)), m === "months" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, En.map((w, h) => {
2443
- const V = new Date(P, h, 1), oe = or(V, L, K), ye = L && it(
2444
- new Date(L.getFullYear(), L.getMonth(), 1),
2430
+ ze
2431
+ ), /* @__PURE__ */ p.createElement("button", { style: D.navButton, onClick: re }, "›")), E === "days" && /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("div", { style: D.weekDays }, ht.map((w) => /* @__PURE__ */ p.createElement("div", { key: w, style: D.weekDay }, w))), /* @__PURE__ */ p.createElement("div", { style: D.days }, Le)), E === "months" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, En.map((w, h) => {
2432
+ const V = new Date(P, h, 1), ue = or(V, T, X), he = T && at(
2433
+ new Date(T.getFullYear(), T.getMonth(), 1),
2445
2434
  V
2446
- ) || K && it(
2447
- new Date(K.getFullYear(), K.getMonth(), 1),
2435
+ ) || X && at(
2436
+ new Date(X.getFullYear(), X.getMonth(), 1),
2448
2437
  V
2449
- ), Q = h === Le.getMonth() && P === Le.getFullYear(), N = g === "range" && L && !U;
2438
+ ), j = h === Te.getMonth() && P === Te.getFullYear(), N = g === "range" && T && !W;
2450
2439
  return /* @__PURE__ */ p.createElement(
2451
2440
  "button",
2452
2441
  {
2453
2442
  key: w,
2454
2443
  style: {
2455
- ...Q ? gt : Pe,
2456
- ...oe ? D.dayInRange : {},
2457
- ...ye ? D.daySelected : {}
2444
+ ...j ? gt : Pe,
2445
+ ...ue ? D.dayInRange : {},
2446
+ ...he ? D.daySelected : {}
2458
2447
  },
2459
- onClick: () => $e(h),
2460
- onMouseEnter: (W) => {
2461
- N ? T(V) : ye || (W.currentTarget.style.backgroundColor = z.dropdownHover);
2448
+ onClick: () => We(h),
2449
+ onMouseEnter: ($) => {
2450
+ N ? L(V) : he || ($.currentTarget.style.backgroundColor = G.dropdownHover);
2462
2451
  },
2463
- onMouseLeave: (W) => {
2464
- !N && !ye && (W.currentTarget.style.backgroundColor = oe ? "rgba(9, 105, 218, 0.1)" : "transparent");
2452
+ onMouseLeave: ($) => {
2453
+ !N && !he && ($.currentTarget.style.backgroundColor = ue ? "rgba(9, 105, 218, 0.1)" : "transparent");
2465
2454
  }
2466
2455
  },
2467
2456
  w
2468
2457
  );
2469
- })), m === "years" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, Array.from({ length: 12 }, (w, h) => {
2470
- const V = Vt(P) - 1 + h, oe = h === 0 || h === 11, ye = V === Le.getFullYear(), Q = new Date(V, 0, 1), N = L && K && V >= Math.min(L.getFullYear(), K.getFullYear()) && V <= Math.max(L.getFullYear(), K.getFullYear()), W = L && L.getFullYear() === V || K && K.getFullYear() === V, me = g === "range" && L && !U;
2458
+ })), E === "years" && /* @__PURE__ */ p.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "2px" } }, Array.from({ length: 12 }, (w, h) => {
2459
+ const V = $t(P) - 1 + h, ue = h === 0 || h === 11, he = V === Te.getFullYear(), j = new Date(V, 0, 1), N = T && X && V >= Math.min(T.getFullYear(), X.getFullYear()) && V <= Math.max(T.getFullYear(), X.getFullYear()), $ = T && T.getFullYear() === V || X && X.getFullYear() === V, ge = g === "range" && T && !W;
2471
2460
  return /* @__PURE__ */ p.createElement(
2472
2461
  "button",
2473
2462
  {
2474
2463
  key: V,
2475
2464
  style: {
2476
- ...ye ? gt : Pe,
2477
- ...oe ? D.dayOtherMonth : {},
2465
+ ...he ? gt : Pe,
2466
+ ...ue ? D.dayOtherMonth : {},
2478
2467
  ...N ? D.dayInRange : {},
2479
- ...W ? D.daySelected : {}
2468
+ ...$ ? D.daySelected : {}
2480
2469
  },
2481
- onClick: () => Ve(V),
2482
- onMouseEnter: (X) => {
2483
- me ? T(Q) : W || (X.currentTarget.style.backgroundColor = z.dropdownHover);
2470
+ onClick: () => $e(V),
2471
+ onMouseEnter: (J) => {
2472
+ ge ? L(j) : $ || (J.currentTarget.style.backgroundColor = G.dropdownHover);
2484
2473
  },
2485
- onMouseLeave: (X) => {
2486
- !me && !W && (X.currentTarget.style.backgroundColor = N ? "rgba(9, 105, 218, 0.1)" : "transparent");
2474
+ onMouseLeave: (J) => {
2475
+ !ge && !$ && (J.currentTarget.style.backgroundColor = N ? "rgba(9, 105, 218, 0.1)" : "transparent");
2487
2476
  }
2488
2477
  },
2489
2478
  V
2490
2479
  );
2491
2480
  })), g === "range" && /* @__PURE__ */ p.createElement("div", { style: {
2492
2481
  ...D.quickOptions,
2493
- ...Ke
2494
- } }, Ye.map((w) => /* @__PURE__ */ p.createElement("button", { key: w.value, style: D.quickOption, onClick: () => n(w.value) }, w.label))));
2482
+ ...Ye
2483
+ } }, qe.map((w) => /* @__PURE__ */ p.createElement("button", { key: w.value, style: D.quickOption, onClick: () => n(w.value) }, w.label))));
2495
2484
  }
2496
2485
  const Sn = 30, xn = 150;
2497
2486
  function hr(n, e) {
@@ -2564,61 +2553,61 @@ function Rn(n) {
2564
2553
  return `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4' viewBox='0 0 8 4'%3E%3Cpath d='M0 2 Q2 0 4 2 Q6 4 8 2' stroke='${n.replace("#", "%23")}' fill='none' stroke-width='0.8'/%3E%3C/svg%3E")`;
2565
2554
  }
2566
2555
  function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, containerRef: i }) {
2567
- const [a, u] = p.useState(null), [c, g] = p.useState({ x: 0, clientY: 0 }), [f, m] = p.useState([]), I = p.useRef([]), P = p.useRef(null), H = p.useRef(null);
2556
+ const [a, u] = p.useState(null), [c, g] = p.useState({ x: 0, clientY: 0 }), [f, E] = p.useState([]), F = p.useRef([]), P = p.useRef(null), U = p.useRef(null);
2568
2557
  if (p.useEffect(() => {
2569
- if (H.current && clearTimeout(H.current), n.length === 0) {
2570
- m([]), I.current = [], u(null);
2558
+ if (U.current && clearTimeout(U.current), n.length === 0) {
2559
+ E([]), F.current = [], u(null);
2571
2560
  return;
2572
2561
  }
2573
- return H.current = setTimeout(() => {
2574
- const F = bn(n, e, t);
2575
- m(F), I.current = F;
2562
+ return U.current = setTimeout(() => {
2563
+ const B = bn(n, e, t);
2564
+ E(B), F.current = B;
2576
2565
  }, xn), () => {
2577
- H.current && clearTimeout(H.current);
2566
+ U.current && clearTimeout(U.current);
2578
2567
  };
2579
2568
  }, [n, e, t]), p.useEffect(() => {
2580
- const F = i;
2581
- if (!F || !e) return;
2582
- const U = (T) => {
2583
- const z = e.getBoundingClientRect(), M = T.clientX - z.left, D = T.clientY - z.top;
2584
- let ie = -1;
2585
- for (let J = 0; J < I.current.length; J++) {
2586
- const ne = I.current[J];
2587
- if (M >= ne.left && M <= ne.left + ne.width && D >= ne.top && D <= ne.top + ne.height + 6) {
2588
- ie = J;
2569
+ const B = i;
2570
+ if (!B || !e) return;
2571
+ const W = (L) => {
2572
+ const G = e.getBoundingClientRect(), M = L.clientX - G.left, D = L.clientY - G.top;
2573
+ let ce = -1;
2574
+ for (let re = 0; re < F.current.length; re++) {
2575
+ const ie = F.current[re];
2576
+ if (M >= ie.left && M <= ie.left + ie.width && D >= ie.top && D <= ie.top + ie.height + 6) {
2577
+ ce = re;
2589
2578
  break;
2590
2579
  }
2591
2580
  }
2592
- ie >= 0 ? (u(ie), g({ x: M, clientY: T.clientY })) : u(null);
2581
+ ce >= 0 ? (u(ce), g({ x: M, clientY: L.clientY })) : u(null);
2593
2582
  }, v = () => {
2594
2583
  u(null);
2595
- }, _ = new AbortController();
2596
- return F.addEventListener("mousemove", U, { signal: _.signal }), F.addEventListener("mouseleave", v, { signal: _.signal }), () => _.abort();
2584
+ }, H = new AbortController();
2585
+ return B.addEventListener("mousemove", W, { signal: H.signal }), B.addEventListener("mouseleave", v, { signal: H.signal }), () => H.abort();
2597
2586
  }, [i, e]), p.useEffect(() => {
2598
- const F = P.current;
2599
- if (!F || a == null) return;
2600
- const U = F.getBoundingClientRect();
2601
- if (U.right > window.innerWidth - 8) {
2602
- const v = U.right - window.innerWidth + 8;
2603
- F.style.transform = `translateX(-${v}px)`;
2587
+ const B = P.current;
2588
+ if (!B || a == null) return;
2589
+ const W = B.getBoundingClientRect();
2590
+ if (W.right > window.innerWidth - 8) {
2591
+ const v = W.right - window.innerWidth + 8;
2592
+ B.style.transform = `translateX(-${v}px)`;
2604
2593
  } else
2605
- F.style.transform = "";
2594
+ B.style.transform = "";
2606
2595
  }), f.length === 0) return null;
2607
- const x = pt(r), R = dt(s), L = a != null ? f[a] : null;
2608
- return /* @__PURE__ */ p.createElement(p.Fragment, null, f.map((F, U) => {
2609
- const _ = F.error.severity === "warning" ? x.warning : x.error, T = Rn(_), z = F.top + F.height - 2;
2596
+ const x = pt(r), A = dt(s), T = a != null ? f[a] : null;
2597
+ return /* @__PURE__ */ p.createElement(p.Fragment, null, f.map((B, W) => {
2598
+ const H = B.error.severity === "warning" ? x.warning : x.error, L = Rn(H), G = B.top + B.height - 2;
2610
2599
  return /* @__PURE__ */ p.createElement(
2611
2600
  "div",
2612
2601
  {
2613
- key: `wave-${U}`,
2602
+ key: `wave-${W}`,
2614
2603
  style: {
2615
2604
  position: "absolute",
2616
- left: `${F.left}px`,
2617
- top: `${z}px`,
2618
- width: `${F.width}px`,
2605
+ left: `${B.left}px`,
2606
+ top: `${G}px`,
2607
+ width: `${B.width}px`,
2619
2608
  height: "4px",
2620
2609
  zIndex: 1,
2621
- backgroundImage: T,
2610
+ backgroundImage: L,
2622
2611
  backgroundRepeat: "repeat-x",
2623
2612
  backgroundPosition: "left top",
2624
2613
  backgroundSize: "auto 4px",
@@ -2626,8 +2615,8 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
2626
2615
  }
2627
2616
  }
2628
2617
  );
2629
- }), L != null && (() => {
2630
- const U = L.error.severity === "warning" ? x.warning : x.error, v = L.top + L.height + 2, _ = L.top, M = window.innerHeight - c.clientY < gr + 20 ? _ - gr - yr : v + yr;
2618
+ }), T != null && (() => {
2619
+ const W = T.error.severity === "warning" ? x.warning : x.error, v = T.top + T.height + 2, H = T.top, M = window.innerHeight - c.clientY < gr + 20 ? H - gr - yr : v + yr;
2631
2620
  return /* @__PURE__ */ p.createElement(
2632
2621
  "div",
2633
2622
  {
@@ -2636,14 +2625,14 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
2636
2625
  position: "absolute",
2637
2626
  top: `${M}px`,
2638
2627
  left: `${c.x}px`,
2639
- zIndex: R.dropdownZIndex,
2628
+ zIndex: A.dropdownZIndex,
2640
2629
  backgroundColor: x.background,
2641
- color: U,
2642
- border: `1px solid ${U}`,
2630
+ color: W,
2631
+ border: `1px solid ${W}`,
2643
2632
  borderRadius: "4px",
2644
2633
  padding: "4px 8px",
2645
2634
  fontSize: "12px",
2646
- fontFamily: R.fontFamily,
2635
+ fontFamily: A.fontFamily,
2647
2636
  lineHeight: "1.4",
2648
2637
  whiteSpace: "nowrap",
2649
2638
  pointerEvents: "none",
@@ -2652,11 +2641,11 @@ function An({ errors: n, editorRef: e, cursorOffset: t, colors: r, styles: s, co
2652
2641
  maxWidth: "90vw"
2653
2642
  }
2654
2643
  },
2655
- L.error.message
2644
+ T.error.message
2656
2645
  );
2657
2646
  })());
2658
2647
  }
2659
- function Yt(n, e, t) {
2648
+ function qt(n, e, t) {
2660
2649
  let r = 0, s = !1;
2661
2650
  function i(a) {
2662
2651
  if (s) return !0;
@@ -2678,39 +2667,39 @@ function Yt(n, e, t) {
2678
2667
  }
2679
2668
  return i(n), r;
2680
2669
  }
2681
- function lt(n) {
2670
+ function ot(n) {
2682
2671
  const e = window.getSelection();
2683
2672
  if (!e || e.rangeCount === 0) return 0;
2684
2673
  const t = e.getRangeAt(0);
2685
- return Yt(n, t.startContainer, t.startOffset);
2674
+ return qt(n, t.startContainer, t.startOffset);
2686
2675
  }
2687
- function Ae(n) {
2676
+ function be(n) {
2688
2677
  const e = window.getSelection();
2689
2678
  if (!e || e.rangeCount === 0) return { start: 0, end: 0 };
2690
- const t = e.getRangeAt(0), r = Yt(n, t.startContainer, t.startOffset), s = Yt(n, t.endContainer, t.endOffset);
2679
+ const t = e.getRangeAt(0), r = qt(n, t.startContainer, t.startOffset), s = qt(n, t.endContainer, t.endOffset);
2691
2680
  return { start: r, end: s };
2692
2681
  }
2693
- function Ue(n, e) {
2682
+ function He(n, e) {
2694
2683
  const t = window.getSelection();
2695
2684
  if (!t) return;
2696
- const r = Kt(n, e);
2685
+ const r = Yt(n, e);
2697
2686
  if (!r) return;
2698
2687
  const s = document.createRange();
2699
2688
  s.setStart(r.node, r.offset), s.collapse(!0), t.removeAllRanges(), t.addRange(s);
2700
2689
  }
2701
- function He(n, e, t) {
2690
+ function Be(n, e, t) {
2702
2691
  if (e === t) {
2703
- Ue(n, e);
2692
+ He(n, e);
2704
2693
  return;
2705
2694
  }
2706
2695
  const r = window.getSelection();
2707
2696
  if (!r) return;
2708
- const s = Kt(n, e), i = Kt(n, t);
2697
+ const s = Yt(n, e), i = Yt(n, t);
2709
2698
  if (!s || !i) return;
2710
2699
  const a = document.createRange();
2711
2700
  a.setStart(s.node, s.offset), a.setEnd(i.node, i.offset), r.removeAllRanges(), r.addRange(a);
2712
2701
  }
2713
- function Kt(n, e) {
2702
+ function Yt(n, e) {
2714
2703
  let t = 0;
2715
2704
  function r(a) {
2716
2705
  if (a.nodeType === Node.TEXT_NODE) {
@@ -2762,7 +2751,7 @@ function Cn() {
2762
2751
  const t = document.createElement("br");
2763
2752
  e.insertNode(t), e.setStartAfter(t), e.collapse(!0), n.removeAllRanges(), n.addRange(e);
2764
2753
  }
2765
- function zt() {
2754
+ function Vt() {
2766
2755
  var r;
2767
2756
  const n = window.getSelection();
2768
2757
  if (!n || n.rangeCount === 0) return null;
@@ -2775,7 +2764,7 @@ function zt() {
2775
2764
  }
2776
2765
  return t;
2777
2766
  }
2778
- function qt(n, e, t) {
2767
+ function zt(n, e, t) {
2779
2768
  const r = window.innerHeight, s = window.innerWidth;
2780
2769
  let i = n.bottom + window.scrollY + 4, a = n.left + window.scrollX;
2781
2770
  return n.bottom + e + 4 > r && (i = n.top + window.scrollY - e - 4), a + t > s && (a = s - t - 8), a < 8 && (a = 8), { top: i, left: a };
@@ -2801,31 +2790,31 @@ const Nn = /* @__PURE__ */ new Set([
2801
2790
  l.HISTORY_REF,
2802
2791
  l.REGEX
2803
2792
  ]);
2804
- function Ln(n, e, t) {
2793
+ function Tn(n, e, t) {
2805
2794
  const r = [];
2806
2795
  for (const s of e)
2807
2796
  if (t >= s.start && t <= s.end && Nn.has(s.type)) {
2808
2797
  r.push({ start: s.start, end: s.end });
2809
2798
  break;
2810
2799
  }
2811
- return n && xt(n, t, r), Tn(r);
2800
+ return n && St(n, t, r), Ln(r);
2812
2801
  }
2813
- function xt(n, e, t) {
2802
+ function St(n, e, t) {
2814
2803
  if (e < n.start || e > n.end) return !1;
2815
2804
  let r = !1;
2816
2805
  switch (n.type) {
2817
2806
  case "BooleanExpr":
2818
- r = xt(n.left, e, t) || r, r = xt(n.right, e, t) || r;
2807
+ r = St(n.left, e, t) || r, r = St(n.right, e, t) || r;
2819
2808
  break;
2820
2809
  case "Group":
2821
2810
  case "Not":
2822
2811
  case "FieldGroup":
2823
- r = xt(n.expression, e, t) || r;
2812
+ r = St(n.expression, e, t) || r;
2824
2813
  break;
2825
2814
  }
2826
2815
  return t.push({ start: n.start, end: n.end }), !0;
2827
2816
  }
2828
- function Tn(n) {
2817
+ function Ln(n) {
2829
2818
  n.sort((t, r) => {
2830
2819
  const s = t.end - t.start, i = r.end - r.start;
2831
2820
  return s - i || t.start - r.start;
@@ -2882,27 +2871,27 @@ function Mn(n) {
2882
2871
  if (n.type === "RANGE" && n.token) {
2883
2872
  const e = n.token.value, s = (e.endsWith("]") || e.endsWith("}") ? e.slice(1, -1) : e.slice(1)).match(/^(.*?)\s+[Tt][Oo]\s+(.*)$/);
2884
2873
  if (s) {
2885
- const i = Ht(s[1].trim()), a = Ht(s[2].trim());
2874
+ const i = Bt(s[1].trim()), a = Bt(s[2].trim());
2886
2875
  return { mode: "range", start: i, end: a };
2887
2876
  }
2888
2877
  }
2889
2878
  if (n.type === "FIELD_VALUE" && n.partial) {
2890
- const e = Ht(n.partial);
2879
+ const e = Bt(n.partial);
2891
2880
  if (e)
2892
2881
  return { mode: "single", start: e, end: null };
2893
2882
  }
2894
2883
  return null;
2895
2884
  }
2896
- function In(n, e) {
2897
- var c, g, f, m;
2885
+ function Fn(n, e) {
2886
+ var c, g, f, E;
2898
2887
  const t = (n == null ? void 0 : n.mode) ?? "single", r = (e == null ? void 0 : e.mode) ?? "single";
2899
2888
  if (t !== r) return !0;
2900
2889
  const s = ((c = n == null ? void 0 : n.start) == null ? void 0 : c.getTime()) ?? 0, i = ((g = e == null ? void 0 : e.start) == null ? void 0 : g.getTime()) ?? 0;
2901
2890
  if (s !== i) return !0;
2902
- const a = ((f = n == null ? void 0 : n.end) == null ? void 0 : f.getTime()) ?? 0, u = ((m = e == null ? void 0 : e.end) == null ? void 0 : m.getTime()) ?? 0;
2891
+ const a = ((f = n == null ? void 0 : n.end) == null ? void 0 : f.getTime()) ?? 0, u = ((E = e == null ? void 0 : e.end) == null ? void 0 : E.getTime()) ?? 0;
2903
2892
  return a !== u;
2904
2893
  }
2905
- function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig: s, datePickerInit: i, fixedWidth: a, datePresets: u }) {
2894
+ function In({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig: s, datePickerInit: i, fixedWidth: a, datePresets: u }) {
2906
2895
  const c = p.useRef(null), [g, f] = p.useState(!1);
2907
2896
  if (p.useEffect(() => {
2908
2897
  const P = document.createElement("div");
@@ -2910,10 +2899,10 @@ function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig:
2910
2899
  document.body.removeChild(P), c.current = null;
2911
2900
  };
2912
2901
  }, []), !g || !c.current) return null;
2913
- const m = dt(s), I = {
2902
+ const E = dt(s), F = {
2914
2903
  position: "absolute",
2915
- zIndex: m.dropdownZIndex,
2916
- ...vr(e, m),
2904
+ zIndex: E.dropdownZIndex,
2905
+ ...vr(e, E),
2917
2906
  top: `${n.top}px`,
2918
2907
  left: `${n.left}px`,
2919
2908
  maxHeight: "none",
@@ -2921,7 +2910,7 @@ function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig:
2921
2910
  ...a != null ? { width: `${a}px`, minWidth: "unset", maxWidth: "unset" } : {}
2922
2911
  };
2923
2912
  return mr.createPortal(
2924
- /* @__PURE__ */ p.createElement("div", { style: I, onMouseDown: (P) => P.preventDefault() }, /* @__PURE__ */ p.createElement(
2913
+ /* @__PURE__ */ p.createElement("div", { style: F, onMouseDown: (P) => P.preventDefault() }, /* @__PURE__ */ p.createElement(
2925
2914
  vn,
2926
2915
  {
2927
2916
  onSelect: t,
@@ -2948,23 +2937,23 @@ function Un(n) {
2948
2937
  searchHistory: c,
2949
2938
  fetchSuggestions: g,
2950
2939
  colors: f,
2951
- styles: m,
2952
- placeholder: I,
2940
+ styles: E,
2941
+ placeholder: F,
2953
2942
  className: P,
2954
- style: H,
2943
+ style: U,
2955
2944
  dropdown: x,
2956
- features: R,
2957
- inputRef: L,
2958
- datePresets: F,
2959
- onKeyDown: U,
2945
+ features: A,
2946
+ inputRef: T,
2947
+ datePresets: B,
2948
+ onKeyDown: W,
2960
2949
  onFocus: v,
2961
- onBlur: _,
2962
- onTab: T,
2963
- validateValue: z
2964
- } = n, M = (x == null ? void 0 : x.mode) ?? "always", D = (x == null ? void 0 : x.alignToInput) ?? !1, ie = x == null ? void 0 : x.maxSuggestions, J = x == null ? void 0 : x.suggestDebounceMs, ne = (R == null ? void 0 : R.savedSearches) ?? !1, $e = (R == null ? void 0 : R.historySearch) ?? !1, Ve = (x == null ? void 0 : x.showSavedSearchHint) ?? ne, ze = (x == null ? void 0 : x.showHistoryHint) ?? $e, K = (x == null ? void 0 : x.showOperators) !== !1, ft = M !== "input" && (x == null ? void 0 : x.onNavigation) !== !1, qe = (x == null ? void 0 : x.navigationDelay) ?? 0, ke = x == null ? void 0 : x.renderFieldHint, Le = x == null ? void 0 : x.renderHistoryItem, wt = x == null ? void 0 : x.renderSavedSearchItem, bt = x == null ? void 0 : x.renderHeader, ht = (R == null ? void 0 : R.multiline) !== !1, Te = (R == null ? void 0 : R.smartSelectAll) ?? !1, Pe = (R == null ? void 0 : R.expandSelection) ?? !1, gt = (R == null ? void 0 : R.wildcardWrap) ?? !1, Ge = p.useMemo(() => ({
2965
- savedSearches: ne,
2966
- historySearch: $e
2967
- }), [ne, $e]), Ye = Array.isArray(e) ? e : [], [Ke, w] = p.useState(Ye);
2950
+ onBlur: H,
2951
+ onTab: L,
2952
+ validateValue: G
2953
+ } = n, M = (x == null ? void 0 : x.mode) ?? "always", D = (x == null ? void 0 : x.alignToInput) ?? !1, ce = x == null ? void 0 : x.maxSuggestions, re = x == null ? void 0 : x.suggestDebounceMs, ie = (A == null ? void 0 : A.savedSearches) ?? !1, We = (A == null ? void 0 : A.historySearch) ?? !1, $e = (x == null ? void 0 : x.showSavedSearchHint) ?? ie, Ve = (x == null ? void 0 : x.showHistoryHint) ?? We, X = (x == null ? void 0 : x.showOperators) !== !1, ft = M !== "input" && (x == null ? void 0 : x.onNavigation) !== !1, ze = (x == null ? void 0 : x.navigationDelay) ?? 0, Re = x == null ? void 0 : x.renderFieldHint, Te = x == null ? void 0 : x.renderHistoryItem, xt = x == null ? void 0 : x.renderSavedSearchItem, wt = x == null ? void 0 : x.renderHeader, ht = (A == null ? void 0 : A.multiline) !== !1, Le = (A == null ? void 0 : A.smartSelectAll) ?? !1, Pe = (A == null ? void 0 : A.expandSelection) ?? !1, gt = (A == null ? void 0 : A.wildcardWrap) ?? !1, Ge = p.useMemo(() => ({
2954
+ savedSearches: ie,
2955
+ historySearch: We
2956
+ }), [ie, We]), qe = Array.isArray(e) ? e : [], [Ye, w] = p.useState(qe);
2968
2957
  p.useEffect(() => {
2969
2958
  if (Array.isArray(e)) {
2970
2959
  w(e);
@@ -2977,251 +2966,262 @@ function Un(n) {
2977
2966
  o = !0;
2978
2967
  };
2979
2968
  }, [e]);
2980
- const h = p.useRef(null), [V, oe] = p.useState(null), ye = p.useCallback((o) => {
2981
- h.current = o, oe(o);
2982
- }, []), Q = p.useRef(null), N = p.useRef(i || a || ""), W = p.useRef(null), me = p.useRef(!1), X = p.useRef(new Pn()), j = p.useRef(null), Me = p.useRef(null), Ee = p.useRef(null), ee = p.useRef(null), Ie = p.useRef(!1), Rt = p.useRef(null), Qe = p.useRef(null), Ce = p.useRef(null), Xe = p.useRef(null), Qt = p.useRef(() => {
2983
- }), le = p.useRef(
2984
- new ir(
2985
- Ye,
2969
+ const h = p.useRef(null), [V, ue] = p.useState(null), he = p.useCallback((o) => {
2970
+ h.current = o, ue(o);
2971
+ }, []), j = p.useRef(null), N = p.useRef(i || a || ""), $ = p.useRef(null), ge = p.useRef(!1), J = p.useRef(new Pn()), ee = p.useRef(null), Me = p.useRef(null), ye = p.useRef(null), ne = p.useRef(null), Fe = p.useRef(!1), bt = p.useRef(null), Qe = p.useRef(null), Ae = p.useRef(null), Ke = p.useRef(null), Qt = p.useRef(() => {
2972
+ }), pe = p.useRef(
2973
+ new ut(
2974
+ qe,
2986
2975
  [],
2987
2976
  [],
2988
- ie || Gt,
2989
- { showSavedSearchHint: Ve, showHistoryHint: ze }
2977
+ ce || Gt,
2978
+ { showSavedSearchHint: $e, showHistoryHint: Ve, hasSavedSearchProvider: typeof u == "function", hasHistoryProvider: typeof c == "function" }
2990
2979
  )
2991
- ), je = p.useRef(new lr(Ye)), Ze = p.useRef(z);
2992
- Ze.current = z;
2993
- const [Xt, Je] = p.useState([]), [jt, et] = p.useState(null), [At, te] = p.useState([]), [kt, xe] = p.useState(-1), [Ct, Z] = p.useState(!1), [Dt, se] = p.useState(!1), [Ot, yt] = p.useState(null), [Nt, tt] = p.useState([]), [rt, Zt] = p.useState(!1), [wr, nt] = p.useState(!N.current), [Fe, de] = p.useState(0), [mt, ve] = p.useState(0), [Jt, st] = p.useState(""), [Lt, br] = p.useState(null), [Rr, er] = p.useState(null), G = p.useRef({
2994
- tokens: Xt,
2995
- ast: jt,
2996
- suggestions: At,
2997
- selectedSuggestionIndex: kt,
2998
- showDropdown: Ct,
2999
- showDatePicker: Dt,
3000
- cursorOffset: Fe,
2980
+ ), Xe = p.useRef(new lr(qe)), je = p.useRef(G);
2981
+ je.current = G;
2982
+ const [Kt, Ze] = p.useState([]), [Xt, Je] = p.useState(null), [Rt, se] = p.useState([]), [At, Se] = p.useState(-1), [kt, te] = p.useState(!1), [Ct, oe] = p.useState(!1), [Dt, yt] = p.useState(null), [Ot, et] = p.useState([]), [tt, jt] = p.useState(!1), [wr, rt] = p.useState(!N.current), [Ie, de] = p.useState(0), [mt, me] = p.useState(0), [Zt, nt] = p.useState(""), [Nt, br] = p.useState(null), [Rr, Jt] = p.useState(null), Y = p.useRef({
2983
+ tokens: Kt,
2984
+ ast: Xt,
2985
+ suggestions: Rt,
2986
+ selectedSuggestionIndex: At,
2987
+ showDropdown: kt,
2988
+ showDatePicker: Ct,
2989
+ cursorOffset: Ie,
3001
2990
  selectionEnd: mt,
3002
- autocompleteContext: Jt,
3003
- validationErrors: Nt,
3004
- cursorContext: Lt
2991
+ autocompleteContext: Zt,
2992
+ validationErrors: Ot,
2993
+ cursorContext: Nt
3005
2994
  });
3006
- G.current = {
3007
- tokens: Xt,
3008
- ast: jt,
3009
- suggestions: At,
3010
- selectedSuggestionIndex: kt,
3011
- showDropdown: Ct,
3012
- showDatePicker: Dt,
3013
- cursorOffset: Fe,
2995
+ Y.current = {
2996
+ tokens: Kt,
2997
+ ast: Xt,
2998
+ suggestions: Rt,
2999
+ selectedSuggestionIndex: At,
3000
+ showDropdown: kt,
3001
+ showDatePicker: Ct,
3002
+ cursorOffset: Ie,
3014
3003
  selectionEnd: mt,
3015
- autocompleteContext: Jt,
3016
- validationErrors: Nt,
3017
- cursorContext: Lt
3004
+ autocompleteContext: Zt,
3005
+ validationErrors: Ot,
3006
+ cursorContext: Nt
3018
3007
  };
3019
3008
  const Tt = p.useCallback((o, d) => {
3020
- if (D && Q.current) {
3021
- const A = Q.current.getBoundingClientRect();
3009
+ if (D && j.current) {
3010
+ const k = j.current.getBoundingClientRect();
3022
3011
  return {
3023
- top: A.bottom + window.scrollY + 4,
3024
- left: A.left + window.scrollX
3012
+ top: k.bottom + window.scrollY + 4,
3013
+ left: k.left + window.scrollX
3025
3014
  };
3026
3015
  }
3027
- const E = zt();
3028
- return E ? qt(E, o, d) : null;
3016
+ const y = Vt();
3017
+ return y ? zt(y, o, d) : null;
3029
3018
  }, [D]), Ar = p.useCallback(() => {
3030
- if (!(!D || !Q.current))
3031
- return Q.current.getBoundingClientRect().width;
3032
- }, [D]), De = p.useCallback((o, d, E = "dropdown") => {
3033
- if (D && E !== "datePicker") {
3034
- Z(!0), yt(Tt(o, d));
3019
+ if (!(!D || !j.current))
3020
+ return j.current.getBoundingClientRect().width;
3021
+ }, [D]), ke = p.useCallback((o, d, y = "dropdown") => {
3022
+ if (D && y !== "datePicker") {
3023
+ te(!0), yt(Tt(o, d));
3035
3024
  return;
3036
3025
  }
3037
3026
  requestAnimationFrame(() => {
3038
- E === "datePicker" ? se(!0) : Z(!0);
3039
- const y = zt(), S = y ? qt(y, o, d) : null;
3027
+ y === "datePicker" ? oe(!0) : te(!0);
3028
+ const m = Vt(), S = m ? zt(m, o, d) : null;
3040
3029
  yt(S);
3041
3030
  });
3042
- }, [D, Tt]), kr = 80, Cr = 60, Pt = p.useCallback((o, d) => {
3031
+ }, [D, Tt]), kr = 80, Cr = 60, Lt = p.useCallback((o, d) => {
3043
3032
  if (!h.current) return;
3044
- const E = ot(o, f, { cursorOffset: d });
3045
- h.current.innerHTML = E, Ue(h.current, d);
3046
- }, [f]), Se = p.useCallback((o, d) => {
3047
- const A = new ct(o, Ge).tokenize(), y = new We(A), S = y.parse(), C = [...y.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...je.current.validate(S, Ze.current)];
3033
+ const y = it(o, f, { cursorOffset: d });
3034
+ h.current.innerHTML = y, He(h.current, d);
3035
+ }, [f]), Ee = p.useCallback((o, d) => {
3036
+ const k = new lt(o, Ge).tokenize(), m = new Ue(k), S = m.parse(), C = [...m.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...Xe.current.validate(S, je.current)];
3048
3037
  if (h.current) {
3049
- const O = lt(h.current);
3050
- d && A.length > kr ? (Ee.current && clearTimeout(Ee.current), Ee.current = setTimeout(() => {
3051
- if (Ee.current = null, h.current) {
3052
- const k = lt(h.current);
3053
- Pt(A, k);
3038
+ const O = ot(h.current);
3039
+ d && k.length > kr ? (ye.current && clearTimeout(ye.current), ye.current = setTimeout(() => {
3040
+ if (ye.current = null, h.current) {
3041
+ const R = ot(h.current);
3042
+ Lt(k, R);
3054
3043
  }
3055
- }, Cr)) : (Ee.current && (clearTimeout(Ee.current), Ee.current = null), Pt(A, O)), Je(A), et(S), tt(C), nt(o.length === 0), de(O), ve(O), d && Qt.current(A, O);
3044
+ }, Cr)) : (ye.current && (clearTimeout(ye.current), ye.current = null), Lt(k, O)), Ze(k), Je(S), et(C), rt(o.length === 0), de(O), me(O), d && Qt.current(k, O);
3056
3045
  } else
3057
- Je(A), et(S), tt(C), nt(o.length === 0);
3046
+ Ze(k), Je(S), et(C), rt(o.length === 0);
3058
3047
  r && r(o, S), s && s(C);
3059
- }, [f, r, s, Pt]), Mt = p.useCallback((o, d) => {
3060
- if (!ke || d.type !== "FIELD_VALUE" || !d.fieldName) return o;
3061
- const E = le.current.resolveField(d.fieldName);
3062
- return E ? o.map((A) => {
3063
- if (A.type !== "hint") return A;
3064
- const y = ke(E, d.partial);
3065
- return y == null ? A : { ...A, customContent: y };
3048
+ }, [f, r, s, Lt]), Pt = p.useCallback((o, d) => {
3049
+ if (!Re || d.type !== "FIELD_VALUE" || !d.fieldName) return o;
3050
+ const y = pe.current.resolveField(d.fieldName);
3051
+ return y ? o.map((k) => {
3052
+ if (k.type !== "hint") return k;
3053
+ const m = Re(y, d.partial);
3054
+ return m == null ? k : { ...k, customContent: m };
3066
3055
  }) : o;
3067
- }, [ke]), ae = p.useCallback((o, d) => {
3056
+ }, [Re]), le = p.useCallback((o, d) => {
3068
3057
  var b, C, O;
3069
- const E = le.current.getSuggestions(o, d);
3070
- K || (E.suggestions = E.suggestions.filter((k) => k.type !== "operator"));
3071
- const A = E.context.type;
3072
- if (br(E.context), M === "never") {
3073
- Z(!1), se(!1), te([]);
3058
+ const y = pe.current.getSuggestions(o, d);
3059
+ X || (y.suggestions = y.suggestions.filter((R) => R.type !== "operator"));
3060
+ const k = y.context.type;
3061
+ if (br(y.context), M === "never") {
3062
+ te(!1), oe(!1), se([]);
3074
3063
  return;
3075
3064
  }
3076
3065
  if (M === "manual") {
3077
- if (Ce.current && Ce.current !== A) {
3078
- Ce.current = null, Z(!1), se(!1), te([]);
3066
+ if (Ae.current && Ae.current !== k) {
3067
+ Ae.current = null, te(!1), oe(!1), se([]);
3079
3068
  return;
3080
3069
  }
3081
- if (!Ce.current) {
3082
- Z(!1), se(!1), te([]);
3070
+ if (!Ae.current) {
3071
+ te(!1), oe(!1), se([]);
3083
3072
  return;
3084
3073
  }
3085
3074
  }
3086
- const y = E.context.fieldName ? le.current.resolveField(E.context.fieldName) : void 0, S = !!(g && E.context.type === "FIELD_VALUE" && E.context.fieldName && (y != null && y.asyncSearch));
3087
- if (E.showDatePicker) {
3088
- Ie.current = !1, (b = Me.current) == null || b.abort(), W.current && clearTimeout(W.current);
3089
- const k = Mn(E.context), $ = Rt.current;
3090
- Rt.current = k, er(k);
3091
- const B = E.context.token;
3092
- B && (B.type === "COLON" || B.type === "COMPARISON_OP") ? Qe.current = { start: B.end, end: B.end } : B ? Qe.current = { start: B.start, end: B.end } : Qe.current = { start: d, end: d }, G.current.showDatePicker && In($, k) && se(!1), te([]), D || Z(!1), st(A), De(350, 300, "datePicker");
3075
+ const m = y.context.fieldName ? pe.current.resolveField(y.context.fieldName) : void 0, S = !!(g && y.context.type === "FIELD_VALUE" && y.context.fieldName && (m == null ? void 0 : m.type) !== "boolean") || typeof u == "function" && y.context.type === "SAVED_SEARCH" || typeof c == "function" && y.context.type === "HISTORY_REF";
3076
+ if (y.showDatePicker) {
3077
+ Fe.current = !1, (b = Me.current) == null || b.abort(), $.current && clearTimeout($.current);
3078
+ const R = Mn(y.context), z = bt.current;
3079
+ bt.current = R, Jt(R);
3080
+ const I = y.context.token;
3081
+ I && (I.type === "COLON" || I.type === "COMPARISON_OP") ? Qe.current = { start: I.end, end: I.end } : I ? Qe.current = { start: I.start, end: I.end } : Qe.current = { start: d, end: d }, Y.current.showDatePicker && Fn(z, R) && oe(!1), se([]), D || te(!1), nt(k), ke(350, 300, "datePicker");
3093
3082
  return;
3094
3083
  }
3095
- if (S && Ie.current)
3096
- st(A);
3084
+ if (S && Fe.current)
3085
+ nt(k);
3097
3086
  else if (S) {
3098
- const k = E.context.token, $ = k ? k.start : d, B = k ? k.end : d, ce = y == null ? void 0 : y.asyncSearchLabel, ue = {
3087
+ const R = y.context.token, z = R ? R.start : d, I = R ? R.end : d;
3088
+ se([{
3099
3089
  text: "",
3100
- label: typeof ce == "function" ? ce(E.context.partial) : ce || "Searching...",
3090
+ label: "Searching...",
3101
3091
  type: "loading",
3102
- replaceStart: $,
3103
- replaceEnd: B
3104
- };
3105
- te([ue]), D || Z(!1), se(!1), xe(-1), st(A), De(32, 300);
3092
+ replaceStart: z,
3093
+ replaceEnd: I
3094
+ }]), D || te(!1), oe(!1), Se(-1), nt(k), ke(32, 300);
3106
3095
  } else {
3107
- Ie.current = !1, (C = Me.current) == null || C.abort(), W.current && clearTimeout(W.current);
3108
- const k = Mt(E.suggestions, E.context);
3109
- k.length > 0 ? (te(k), D || Z(!1), se(!1), xe(E.context.partial ? 0 : -1), st(A), De(k.length * 32, 300)) : (Z(!1), se(!1), te([]), st(A));
3096
+ Fe.current = !1, (C = Me.current) == null || C.abort(), $.current && clearTimeout($.current);
3097
+ const R = Pt(y.suggestions, y.context);
3098
+ R.length > 0 ? (se(R), D || te(!1), oe(!1), Se(y.context.partial ? 0 : -1), nt(k), ke(R.length * 32, 300)) : (te(!1), oe(!1), se([]), nt(k));
3110
3099
  }
3111
3100
  if (S) {
3112
- const k = E.context.fieldName, $ = le.current.resolveField(k), B = $ ? $.name : k, ce = E.context.partial, fe = J || Gr;
3113
- Ie.current = !0, W.current && clearTimeout(W.current), (O = Me.current) == null || O.abort();
3114
- const ue = new AbortController();
3115
- Me.current = ue, W.current = setTimeout(async () => {
3116
- const he = E.context.token, be = he ? he.start : d, ge = he ? he.end : d;
3101
+ const R = y.context.partial, z = re || qr;
3102
+ Fe.current = !0, $.current && clearTimeout($.current), (O = Me.current) == null || O.abort();
3103
+ const I = new AbortController();
3104
+ Me.current = I, $.current = setTimeout(async () => {
3105
+ const ve = y.context.token, ae = ve ? ve.start : d, fe = ve ? ve.end : d;
3117
3106
  try {
3118
- const Re = await g(B, ce);
3119
- if (ue.signal.aborted) return;
3120
- const pe = Re.map((re) => ({
3121
- text: re.text,
3122
- label: re.label || re.text,
3123
- description: re.description,
3124
- type: re.type,
3125
- replaceStart: be,
3126
- replaceEnd: ge,
3127
- matchPartial: ce
3128
- }));
3129
- if (pe.length > 0)
3130
- te(pe), xe(ce ? 0 : -1), De(pe.length * 32, 300);
3107
+ let Z;
3108
+ if (y.context.type === "SAVED_SEARCH" && typeof u == "function") {
3109
+ const Q = await u(R);
3110
+ if (I.signal.aborted) return;
3111
+ Z = Q.map((_) => ({
3112
+ text: "#" + _.name,
3113
+ label: _.name,
3114
+ description: _.description || _.query,
3115
+ type: "savedSearch",
3116
+ replaceStart: ae,
3117
+ replaceEnd: fe,
3118
+ matchPartial: R,
3119
+ sourceData: _
3120
+ }));
3121
+ } else if (y.context.type === "HISTORY_REF" && typeof c == "function") {
3122
+ const Q = await c(R);
3123
+ if (I.signal.aborted) return;
3124
+ Z = Q.map((_) => ({
3125
+ text: ut.wrapHistoryQuery(_.query),
3126
+ label: _.label || _.query,
3127
+ description: _.timestamp ? new Date(_.timestamp).toLocaleDateString() : void 0,
3128
+ type: "history",
3129
+ replaceStart: ae,
3130
+ replaceEnd: fe,
3131
+ matchPartial: R,
3132
+ sourceData: _
3133
+ }));
3134
+ } else {
3135
+ const Q = y.context.fieldName, _ = pe.current.resolveField(Q), Oe = _ ? _.name : Q, we = await g(Oe, R);
3136
+ if (I.signal.aborted) return;
3137
+ Z = we.map((Ne) => ({
3138
+ text: Ne.text,
3139
+ label: Ne.label || Ne.text,
3140
+ description: Ne.description,
3141
+ type: Ne.type,
3142
+ replaceStart: ae,
3143
+ replaceEnd: fe,
3144
+ matchPartial: R
3145
+ }));
3146
+ }
3147
+ if (Z.length > 0)
3148
+ se(Z), Se(R ? 0 : -1), ke(Z.length * 32, 300);
3131
3149
  else {
3132
- const re = le.current.getSuggestions(G.current.tokens, G.current.cursorOffset), _e = Mt(
3133
- re.suggestions.filter((vt) => vt.type === "hint"),
3134
- re.context
3150
+ const Q = pe.current.getSuggestions(Y.current.tokens, Y.current.cursorOffset), _ = Pt(
3151
+ Q.suggestions.filter((Oe) => Oe.type === "hint"),
3152
+ Q.context
3135
3153
  );
3136
- _e.length > 0 ? (te(_e), xe(re.context.partial ? 0 : -1), De(_e.length * 32, 300)) : (Z(!1), te([]));
3154
+ _.length > 0 ? (se(_), Se(Q.context.partial ? 0 : -1), ke(_.length * 32, 300)) : (te(!1), se([]));
3137
3155
  }
3138
- } catch (Re) {
3139
- if (!ue.signal.aborted) {
3140
- const re = {
3156
+ } catch (Z) {
3157
+ if (!I.signal.aborted) {
3158
+ const _ = {
3141
3159
  text: "",
3142
- label: Re instanceof Error ? Re.message : "Error loading suggestions",
3160
+ label: Z instanceof Error ? Z.message : "Error loading suggestions",
3143
3161
  type: "error",
3144
- replaceStart: be,
3145
- replaceEnd: ge
3162
+ replaceStart: ae,
3163
+ replaceEnd: fe
3146
3164
  };
3147
- te([re]), xe(-1), De(32, 300), Ie.current = !1;
3165
+ se([_]), Se(-1), ke(32, 300), Fe.current = !1;
3148
3166
  }
3149
3167
  }
3150
- }, fe);
3168
+ }, z);
3151
3169
  }
3152
- }, [g, J, Mt, Tt, De, D, M, K]);
3153
- Qt.current = ae;
3154
- const Y = p.useCallback(() => {
3170
+ }, [g, u, c, re, Pt, Tt, ke, D, M, X]);
3171
+ Qt.current = le;
3172
+ const K = p.useCallback(() => {
3155
3173
  var o;
3156
- Z(!1), se(!1), er(null), Rt.current = null, Qe.current = null, te([]), xe(-1), Ie.current = !1, (o = Me.current) == null || o.abort(), W.current && (clearTimeout(W.current), W.current = null), ee.current && (clearTimeout(ee.current), ee.current = null), Ce.current = null;
3157
- }, []), Oe = p.useCallback((o, d) => {
3158
- if (ee.current && (clearTimeout(ee.current), ee.current = null), !ft) {
3159
- (G.current.showDropdown || G.current.showDatePicker) && Y();
3174
+ te(!1), oe(!1), Jt(null), bt.current = null, Qe.current = null, se([]), Se(-1), Fe.current = !1, (o = Me.current) == null || o.abort(), $.current && (clearTimeout($.current), $.current = null), ne.current && (clearTimeout(ne.current), ne.current = null), Ae.current = null;
3175
+ }, []), Ce = p.useCallback((o, d) => {
3176
+ if (ne.current && (clearTimeout(ne.current), ne.current = null), !ft) {
3177
+ (Y.current.showDropdown || Y.current.showDatePicker) && K();
3160
3178
  return;
3161
3179
  }
3162
- qe > 0 ? ee.current = setTimeout(() => {
3163
- ee.current = null, ae(o, d);
3164
- }, qe) : ae(o, d);
3165
- }, [ft, qe, ae, Y]), we = p.useCallback((o, d, E) => {
3166
- N.current = o, j.current && (clearTimeout(j.current), j.current = null), X.current.push({ value: o, cursorPos: d });
3167
- const y = new ct(o, Ge).tokenize(), S = new We(y), b = S.parse(), O = [...S.getErrors().map((k) => ({ message: k.message, start: k.start, end: k.end })), ...je.current.validate(b, Ze.current)];
3180
+ ze > 0 ? ne.current = setTimeout(() => {
3181
+ ne.current = null, le(o, d);
3182
+ }, ze) : le(o, d);
3183
+ }, [ft, ze, le, K]), xe = p.useCallback((o, d, y) => {
3184
+ N.current = o, ee.current && (clearTimeout(ee.current), ee.current = null), J.current.push({ value: o, cursorPos: d });
3185
+ const m = new lt(o, Ge).tokenize(), S = new Ue(m), b = S.parse(), O = [...S.getErrors().map((R) => ({ message: R.message, start: R.start, end: R.end })), ...Xe.current.validate(b, je.current)];
3168
3186
  if (h.current) {
3169
- const k = ot(y, f, { cursorOffset: d });
3170
- h.current.innerHTML = k, Ue(h.current, d);
3187
+ const R = it(m, f, { cursorOffset: d });
3188
+ h.current.innerHTML = R, He(h.current, d);
3171
3189
  }
3172
- Je(y), et(b), tt(O), nt(o.length === 0), de(d), ve(d), Z(!1), se(!1), r && r(o, b), s && s(O), E && requestAnimationFrame(() => E(y, b));
3173
- }, [f, r, s]), at = p.useCallback((o, d = "Enter", E) => {
3190
+ Ze(m), Je(b), et(O), rt(o.length === 0), de(d), me(d), te(!1), oe(!1), r && r(o, b), s && s(O), y && requestAnimationFrame(() => y(m, b));
3191
+ }, [f, r, s]), st = p.useCallback((o, d = "Enter", y) => {
3174
3192
  if (!o) return;
3175
- const A = G.current;
3193
+ const k = Y.current;
3176
3194
  if (o.type === "hint" && (o.text === "#" || o.text === "!")) {
3177
- const be = o.text, ge = o.replaceStart, Re = Math.max(o.replaceEnd, A.selectionEnd), pe = N.current.slice(0, ge), re = N.current.slice(Re), _e = pe + be + re, vt = pe.length + be.length;
3178
- we(_e, vt, (Ur, Wr) => {
3179
- E ? E(_e, Wr) : ae(Ur, vt);
3195
+ const Q = o.text, _ = o.replaceStart, Oe = Math.max(o.replaceEnd, k.selectionEnd), we = N.current.slice(0, _), Ne = N.current.slice(Oe), rr = we + Q + Ne, nr = we.length + Q.length;
3196
+ xe(rr, nr, (Ur, Wr) => {
3197
+ y ? y(rr, Wr) : le(Ur, nr);
3180
3198
  });
3181
3199
  return;
3182
3200
  }
3183
3201
  if (o.type === "hint") return;
3184
- const y = A.autocompleteContext === "FIELD_VALUE", S = Math.min(o.replaceStart, A.cursorOffset), b = Math.max(o.replaceEnd, A.selectionEnd), C = N.current.slice(0, S), O = N.current.slice(b), k = A.autocompleteContext, $ = k === "FIELD_VALUE" || k === "SAVED_SEARCH" || k === "HISTORY_REF";
3185
- let B = "", ce = O;
3186
- $ && (O.length === 0 ? B = " " : /^[ \t\r\n]+$/.test(O) && !O.startsWith("\\ ") && (B = " ", ce = ""));
3187
- const fe = C + o.text + B + ce, ue = C.length + o.text.length + B.length, he = d === "Enter" && y;
3188
- we(fe, ue, (be, ge) => {
3189
- E ? E(fe, ge) : he ? t && t(fe, ge) : ae(be, ue);
3202
+ const m = k.autocompleteContext === "FIELD_VALUE", S = Math.min(o.replaceStart, k.cursorOffset), b = Math.max(o.replaceEnd, k.selectionEnd), C = N.current.slice(0, S), O = N.current.slice(b), R = k.autocompleteContext, z = R === "FIELD_VALUE" || R === "SAVED_SEARCH" || R === "HISTORY_REF";
3203
+ let I = "", ve = O;
3204
+ z && (O.length === 0 ? I = " " : /^[ \t\r\n]+$/.test(O) && !O.startsWith("\\ ") && (I = " ", ve = ""));
3205
+ const ae = C + o.text + I + ve, fe = C.length + o.text.length + I.length, Z = d === "Enter" && m;
3206
+ xe(ae, fe, (Q, _) => {
3207
+ y ? y(ae, _) : Z ? t && t(ae, _) : le(Q, fe);
3190
3208
  });
3191
- }, [we, ae, t]);
3209
+ }, [xe, le, t]);
3192
3210
  p.useEffect(() => {
3193
- (async () => {
3194
- if (u) {
3195
- const d = typeof u == "function" ? await u() : u;
3196
- le.current.updateSavedSearches(d);
3197
- }
3198
- if (c) {
3199
- const d = typeof c == "function" ? await c() : c;
3200
- le.current.updateSearchHistory(d);
3201
- }
3202
- })();
3211
+ Array.isArray(u) && pe.current.updateSavedSearches(u), Array.isArray(c) && pe.current.updateSearchHistory(c);
3203
3212
  }, [u, c]), p.useEffect(() => {
3204
- le.current = new ir(
3205
- Ke,
3213
+ pe.current = new ut(
3214
+ Ye,
3206
3215
  [],
3207
3216
  [],
3208
- ie || Gt,
3209
- { showSavedSearchHint: Ve, showHistoryHint: ze }
3210
- ), je.current = new lr(Ke), (async () => {
3211
- if (u) {
3212
- const d = typeof u == "function" ? await u() : u;
3213
- le.current.updateSavedSearches(d);
3214
- }
3215
- if (c) {
3216
- const d = typeof c == "function" ? await c() : c;
3217
- le.current.updateSearchHistory(d);
3218
- }
3219
- })(), N.current && Se(N.current, !1);
3220
- }, [Ke, ie, Ve, ze]), p.useEffect(() => {
3221
- L && L({
3217
+ ce || Gt,
3218
+ { showSavedSearchHint: $e, showHistoryHint: Ve, hasSavedSearchProvider: typeof u == "function", hasHistoryProvider: typeof c == "function" }
3219
+ ), Xe.current = new lr(Ye), Array.isArray(u) && pe.current.updateSavedSearches(u), Array.isArray(c) && pe.current.updateSearchHistory(c), N.current && Ee(N.current, !1);
3220
+ }, [Ye, ce, $e, Ve]), p.useEffect(() => {
3221
+ T && T({
3222
3222
  getValue: () => N.current,
3223
3223
  setValue: (o) => {
3224
- N.current = o, Se(o, !1);
3224
+ N.current = o, Ee(o, !1);
3225
3225
  },
3226
3226
  focus: () => {
3227
3227
  var o;
@@ -3231,37 +3231,37 @@ function Un(n) {
3231
3231
  var o;
3232
3232
  return (o = h.current) == null ? void 0 : o.blur();
3233
3233
  },
3234
- getAST: () => G.current.ast,
3235
- getValidationErrors: () => G.current.validationErrors,
3234
+ getAST: () => Y.current.ast,
3235
+ getValidationErrors: () => Y.current.validationErrors,
3236
3236
  setSelection: (o, d) => {
3237
- h.current && (h.current.focus(), He(h.current, o, d), de(o), ve(d));
3237
+ h.current && (h.current.focus(), Be(h.current, o, d), de(o), me(d));
3238
3238
  }
3239
3239
  });
3240
- }, [L, Se]), p.useEffect(() => {
3240
+ }, [T, Ee]), p.useEffect(() => {
3241
3241
  const o = N.current;
3242
- X.current.push({ value: o, cursorPos: o.length }), o && Se(o, !1);
3242
+ J.current.push({ value: o, cursorPos: o.length }), o && Ee(o, !1);
3243
3243
  }, []), p.useEffect(() => {
3244
- i !== void 0 && i !== N.current && (N.current = i, Se(i, !1));
3245
- }, [i, Se]), p.useEffect(() => () => {
3244
+ i !== void 0 && i !== N.current && (N.current = i, Ee(i, !1));
3245
+ }, [i, Ee]), p.useEffect(() => () => {
3246
3246
  var o;
3247
- W.current && clearTimeout(W.current), Ee.current && clearTimeout(Ee.current), ee.current && clearTimeout(ee.current), (o = Me.current) == null || o.abort();
3247
+ $.current && clearTimeout($.current), ye.current && clearTimeout(ye.current), ne.current && clearTimeout(ne.current), (o = Me.current) == null || o.abort();
3248
3248
  }, []), p.useEffect(() => {
3249
- M === "never" && (Z(!1), se(!1), te([])), Ce.current = null;
3249
+ M === "never" && (te(!1), oe(!1), se([])), Ae.current = null;
3250
3250
  }, [M]), p.useEffect(() => {
3251
3251
  const o = () => {
3252
- const d = G.current;
3252
+ const d = Y.current;
3253
3253
  if (!(!d.showDropdown && !d.showDatePicker))
3254
- if (d.showDropdown && D && Q.current) {
3255
- const E = Q.current.getBoundingClientRect();
3254
+ if (d.showDropdown && D && j.current) {
3255
+ const y = j.current.getBoundingClientRect();
3256
3256
  yt({
3257
- top: E.bottom + window.scrollY + 4,
3258
- left: E.left + window.scrollX
3257
+ top: y.bottom + window.scrollY + 4,
3258
+ left: y.left + window.scrollX
3259
3259
  });
3260
3260
  } else {
3261
- const E = zt();
3262
- if (E) {
3263
- const A = d.showDatePicker ? 350 : d.suggestions.length * 32;
3264
- yt(qt(E, A, 300));
3261
+ const y = Vt();
3262
+ if (y) {
3263
+ const k = d.showDatePicker ? 350 : d.suggestions.length * 32;
3264
+ yt(zt(y, k, 300));
3265
3265
  }
3266
3266
  }
3267
3267
  };
@@ -3269,331 +3269,331 @@ function Un(n) {
3269
3269
  window.removeEventListener("resize", o), window.removeEventListener("scroll", o, !0);
3270
3270
  };
3271
3271
  }, [D]);
3272
- const tr = p.useRef(null), rr = p.useRef(f);
3272
+ const er = p.useRef(null), tr = p.useRef(f);
3273
3273
  p.useEffect(() => {
3274
3274
  if (!h.current) return;
3275
- const o = G.current.tokens;
3276
- if (o.length === 0 || rt && mt !== Fe) return;
3277
- const d = rt ? Fe : -1, E = f !== rr.current;
3278
- rr.current = f;
3279
- const A = Sr(o, d), y = A ? `${A.openStart},${A.closeStart}` : null;
3280
- if (y === tr.current && !E) return;
3281
- tr.current = y;
3282
- const S = lt(h.current), b = ot(o, f, { cursorOffset: d });
3283
- h.current.innerHTML = b, Ue(h.current, S);
3284
- }, [Fe, mt, rt, f]);
3285
- const Ne = p.useCallback(() => {
3286
- if (me.current || !h.current) return;
3287
- Xe.current = null, ee.current && (clearTimeout(ee.current), ee.current = null);
3288
- let o = Kr(h.current);
3275
+ const o = Y.current.tokens;
3276
+ if (o.length === 0 || tt && mt !== Ie) return;
3277
+ const d = tt ? Ie : -1, y = f !== tr.current;
3278
+ tr.current = f;
3279
+ const k = Sr(o, d), m = k ? `${k.openStart},${k.closeStart}` : null;
3280
+ if (m === er.current && !y) return;
3281
+ er.current = m;
3282
+ const S = ot(h.current), b = it(o, f, { cursorOffset: d });
3283
+ h.current.innerHTML = b, He(h.current, S);
3284
+ }, [Ie, mt, tt, f]);
3285
+ const De = p.useCallback(() => {
3286
+ if (ge.current || !h.current) return;
3287
+ Ke.current = null, ne.current && (clearTimeout(ne.current), ne.current = null);
3288
+ let o = Qr(h.current);
3289
3289
  if (o === N.current) return;
3290
- let d = lt(h.current);
3291
- const E = nr(o);
3292
- E !== o && (o = E, d = Math.min(d, o.length)), N.current = o;
3293
- const A = X.current, y = A.current();
3294
- if (y && Math.abs(o.length - y.value.length) <= 2 && j.current ? A.replaceCurrent({ value: o, cursorPos: d }) : A.push({ value: o, cursorPos: d }), j.current && clearTimeout(j.current), j.current = setTimeout(() => {
3295
- j.current = null;
3290
+ let d = ot(h.current);
3291
+ const y = sr(o);
3292
+ y !== o && (o = y, d = Math.min(d, o.length)), N.current = o;
3293
+ const k = J.current, m = k.current();
3294
+ if (m && Math.abs(o.length - m.value.length) <= 2 && ee.current ? k.replaceCurrent({ value: o, cursorPos: d }) : k.push({ value: o, cursorPos: d }), ee.current && clearTimeout(ee.current), ee.current = setTimeout(() => {
3295
+ ee.current = null;
3296
3296
  }, 300), M === "input") {
3297
3297
  const b = d > 0 ? o[d - 1] : "";
3298
3298
  if (!b || b.trim() === "") {
3299
- Se(o, !1), Y();
3299
+ Ee(o, !1), K();
3300
3300
  return;
3301
3301
  }
3302
3302
  }
3303
- Se(o, !0);
3304
- }, [Se, M, Y]), Dr = p.useCallback(() => {
3305
- me.current = !0;
3303
+ Ee(o, !0);
3304
+ }, [Ee, M, K]), Dr = p.useCallback(() => {
3305
+ ge.current = !0;
3306
3306
  }, []), Or = p.useCallback(() => {
3307
- me.current = !1, Ne();
3308
- }, [Ne]), It = p.useCallback((o) => {
3307
+ ge.current = !1, De();
3308
+ }, [De]), Mt = p.useCallback((o) => {
3309
3309
  if (!o) return;
3310
3310
  N.current = o.value;
3311
- const E = new ct(o.value, Ge).tokenize(), A = new We(E), y = A.parse(), b = [...A.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...je.current.validate(y, Ze.current)], C = o.selStart != null && o.selStart !== o.cursorPos;
3311
+ const y = new lt(o.value, Ge).tokenize(), k = new Ue(y), m = k.parse(), b = [...k.getErrors().map((O) => ({ message: O.message, start: O.start, end: O.end })), ...Xe.current.validate(m, je.current)], C = o.selStart != null && o.selStart !== o.cursorPos;
3312
3312
  if (h.current) {
3313
- const O = ot(E, f, { cursorOffset: o.cursorPos });
3314
- h.current.innerHTML = O, C ? He(h.current, o.selStart, o.cursorPos) : Ue(h.current, o.cursorPos);
3315
- }
3316
- Je(E), et(y), tt(b), nt(o.value.length === 0), de(C ? o.selStart : o.cursorPos), ve(o.cursorPos), Y(), r && r(o.value, y), s && s(b);
3317
- }, [f, r, s, Y]), Nr = p.useCallback((o) => {
3318
- var E, A;
3319
- if (U && U(o), o.defaultPrevented) return;
3320
- const d = G.current;
3313
+ const O = it(y, f, { cursorOffset: o.cursorPos });
3314
+ h.current.innerHTML = O, C ? Be(h.current, o.selStart, o.cursorPos) : He(h.current, o.cursorPos);
3315
+ }
3316
+ Ze(y), Je(m), et(b), rt(o.value.length === 0), de(C ? o.selStart : o.cursorPos), me(o.cursorPos), K(), r && r(o.value, m), s && s(b);
3317
+ }, [f, r, s, K]), Nr = p.useCallback((o) => {
3318
+ var y, k;
3319
+ if (W && W(o), o.defaultPrevented) return;
3320
+ const d = Y.current;
3321
3321
  if (h.current && h.current.childNodes.length > 40) {
3322
- const y = window.getSelection();
3323
- if (y != null && !y.isCollapsed) {
3324
- const b = Ae(h.current);
3322
+ const m = window.getSelection();
3323
+ if (m != null && !m.isCollapsed) {
3324
+ const b = be(h.current);
3325
3325
  if (b.end - b.start > 20) {
3326
- const O = o.key === "Backspace" || o.key === "Delete" || o.key === "x" && (o.ctrlKey || o.metaKey), k = !o.ctrlKey && !o.metaKey && !o.altKey && o.key.length === 1;
3327
- (O || k) && (h.current.textContent = N.current, He(h.current, b.start, b.end));
3326
+ const O = o.key === "Backspace" || o.key === "Delete" || o.key === "x" && (o.ctrlKey || o.metaKey), R = !o.ctrlKey && !o.metaKey && !o.altKey && o.key.length === 1;
3327
+ (O || R) && (h.current.textContent = N.current, Be(h.current, b.start, b.end));
3328
3328
  }
3329
3329
  }
3330
3330
  }
3331
3331
  {
3332
- let y = null, S = null;
3333
- if (sr[o.key])
3334
- y = o.key, S = sr[o.key];
3332
+ let m = null, S = null;
3333
+ if (ar[o.key])
3334
+ m = o.key, S = ar[o.key];
3335
3335
  else if (gt && o.key === "*" && h.current) {
3336
- const b = Ae(h.current);
3336
+ const b = be(h.current);
3337
3337
  if (b.start !== b.end) {
3338
- const [C, O] = ar(d.tokens, b.start, b.end);
3338
+ const [C, O] = ir(d.tokens, b.start, b.end);
3339
3339
  if (C >= 0 && C === O) {
3340
- const k = d.tokens[C];
3341
- (k.type === l.VALUE || k.type === l.WILDCARD) && (y = "*", S = "*");
3340
+ const R = d.tokens[C];
3341
+ (R.type === l.VALUE || R.type === l.WILDCARD) && (m = "*", S = "*");
3342
3342
  }
3343
3343
  }
3344
3344
  }
3345
- if (y && S && h.current) {
3346
- const b = Ae(h.current);
3345
+ if (m && S && h.current) {
3346
+ const b = be(h.current);
3347
3347
  if (b.start !== b.end) {
3348
3348
  o.preventDefault();
3349
- const { newValue: C, newSelStart: O, newSelEnd: k } = Yr(
3349
+ const { newValue: C, newSelStart: O, newSelEnd: R } = Yr(
3350
3350
  N.current,
3351
3351
  b.start,
3352
3352
  b.end,
3353
- y,
3353
+ m,
3354
3354
  S
3355
- ), $ = X.current, B = $.current();
3356
- B && B.value === N.current && (B.selStart = b.start, B.cursorPos = b.end), N.current = C, j.current && (clearTimeout(j.current), j.current = null), $.push({ value: C, cursorPos: k, selStart: O });
3357
- const fe = new ct(C, Ge).tokenize(), ue = new We(fe), he = ue.parse(), ge = [...ue.getErrors().map((pe) => ({ message: pe.message, start: pe.start, end: pe.end })), ...je.current.validate(he, Ze.current)], Re = ot(fe, f, { cursorOffset: k });
3358
- h.current.innerHTML = Re, He(h.current, O, k), Je(fe), et(he), tt(ge), nt(!1), de(O), ve(k), Y(), r && r(C, he), s && s(ge);
3355
+ ), z = J.current, I = z.current();
3356
+ I && I.value === N.current && (I.selStart = b.start, I.cursorPos = b.end), N.current = C, ee.current && (clearTimeout(ee.current), ee.current = null), z.push({ value: C, cursorPos: R, selStart: O });
3357
+ const ae = new lt(C, Ge).tokenize(), fe = new Ue(ae), Z = fe.parse(), _ = [...fe.getErrors().map((we) => ({ message: we.message, start: we.start, end: we.end })), ...Xe.current.validate(Z, je.current)], Oe = it(ae, f, { cursorOffset: R });
3358
+ h.current.innerHTML = Oe, Be(h.current, O, R), Ze(ae), Je(Z), et(_), rt(!1), de(O), me(R), K(), r && r(C, Z), s && s(_);
3359
3359
  return;
3360
3360
  }
3361
3361
  }
3362
3362
  }
3363
3363
  if (o.key === "z" && (o.ctrlKey || o.metaKey) && !o.shiftKey) {
3364
- o.preventDefault(), It(X.current.undo());
3364
+ o.preventDefault(), Mt(J.current.undo());
3365
3365
  return;
3366
3366
  }
3367
3367
  if (o.key === "y" && (o.ctrlKey || o.metaKey) || o.key === "z" && (o.ctrlKey || o.metaKey) && o.shiftKey) {
3368
- o.preventDefault(), It(X.current.redo());
3368
+ o.preventDefault(), Mt(J.current.redo());
3369
3369
  return;
3370
3370
  }
3371
- if (o.key === "a" && (o.ctrlKey || o.metaKey) && Te && h.current) {
3372
- const y = Ae(h.current), S = On(d.tokens, y.start, y.end);
3371
+ if (o.key === "a" && (o.ctrlKey || o.metaKey) && Le && h.current) {
3372
+ const m = be(h.current), S = On(d.tokens, m.start, m.end);
3373
3373
  if (S) {
3374
- o.preventDefault(), He(h.current, S.start, S.end), de(S.start), ve(S.end);
3374
+ o.preventDefault(), Be(h.current, S.start, S.end), de(S.start), me(S.end);
3375
3375
  return;
3376
3376
  }
3377
3377
  }
3378
3378
  if (Pe && o.altKey && o.shiftKey && (o.key === "ArrowRight" || o.key === "ArrowLeft") && h.current) {
3379
- const y = o.key === "ArrowRight";
3380
- let S = Xe.current;
3379
+ const m = o.key === "ArrowRight";
3380
+ let S = Ke.current;
3381
3381
  if (!S) {
3382
- const C = Ae(h.current), O = Ln(d.ast, d.tokens, C.start);
3382
+ const C = be(h.current), O = Tn(d.ast, d.tokens, C.start);
3383
3383
  if (O.length === 0) return;
3384
- S = { ranges: O, level: -1 }, Xe.current = S;
3384
+ S = { ranges: O, level: -1 }, Ke.current = S;
3385
3385
  }
3386
- const b = y ? Math.min(S.level + 1, S.ranges.length - 1) : Math.max(S.level - 1, -1);
3386
+ const b = m ? Math.min(S.level + 1, S.ranges.length - 1) : Math.max(S.level - 1, -1);
3387
3387
  if (b === S.level) return;
3388
3388
  if (S.level = b, b < 0) {
3389
- const C = Ae(h.current);
3390
- Ue(h.current, C.start), Xe.current = null;
3389
+ const C = be(h.current);
3390
+ He(h.current, C.start), Ke.current = null;
3391
3391
  } else {
3392
3392
  o.preventDefault();
3393
3393
  const C = S.ranges[b];
3394
- He(h.current, C.start, C.end), de(C.start), ve(C.end);
3394
+ Be(h.current, C.start, C.end), de(C.start), me(C.end);
3395
3395
  }
3396
3396
  return;
3397
3397
  }
3398
- if (Xe.current = null, o.key === " " && (o.ctrlKey || o.metaKey)) {
3398
+ if (Ke.current = null, o.key === " " && (o.ctrlKey || o.metaKey)) {
3399
3399
  if (o.preventDefault(), M === "manual") {
3400
- const y = le.current.getSuggestions(d.tokens, d.cursorOffset);
3401
- Ce.current = y.context.type;
3400
+ const m = pe.current.getSuggestions(d.tokens, d.cursorOffset);
3401
+ Ae.current = m.context.type;
3402
3402
  }
3403
- ae(d.tokens, d.cursorOffset);
3403
+ le(d.tokens, d.cursorOffset);
3404
3404
  return;
3405
3405
  }
3406
3406
  if (o.key === "Enter" && (o.ctrlKey || o.metaKey)) {
3407
- o.preventDefault(), Y(), t && t(N.current, d.ast);
3407
+ o.preventDefault(), K(), t && t(N.current, d.ast);
3408
3408
  return;
3409
3409
  }
3410
3410
  if (o.key === "Enter" && o.shiftKey && ht) {
3411
- o.preventDefault(), Cn(), Ne();
3411
+ o.preventDefault(), Cn(), De();
3412
3412
  return;
3413
3413
  }
3414
3414
  if (d.showDropdown && d.suggestions.length > 0)
3415
3415
  switch (o.key) {
3416
3416
  case "ArrowDown":
3417
- o.preventDefault(), xe((y) => Math.min(y + 1, d.suggestions.length - 1));
3417
+ o.preventDefault(), Se((m) => Math.min(m + 1, d.suggestions.length - 1));
3418
3418
  return;
3419
3419
  case "ArrowUp":
3420
- o.preventDefault(), xe((y) => Math.max(y - 1, -1));
3420
+ o.preventDefault(), Se((m) => Math.max(m - 1, -1));
3421
3421
  return;
3422
3422
  case "Enter":
3423
3423
  if (d.selectedSuggestionIndex >= 0) {
3424
- const y = d.suggestions[d.selectedSuggestionIndex];
3425
- if (y.type === "hint" && y.text !== "#" && y.text !== "!") {
3426
- o.preventDefault(), Y();
3424
+ const m = d.suggestions[d.selectedSuggestionIndex];
3425
+ if (m.type === "hint" && m.text !== "#" && m.text !== "!") {
3426
+ o.preventDefault(), K();
3427
3427
  const S = N.current, b = d.cursorOffset;
3428
3428
  if (b <= S.length && S[b] !== " ") {
3429
- const C = S.slice(0, b), O = S.slice(b), k = C + " " + O, $ = b + 1;
3430
- we(k, $, () => {
3431
- t && t(k, d.ast);
3429
+ const C = S.slice(0, b), O = S.slice(b), R = C + " " + O, z = b + 1;
3430
+ xe(R, z, () => {
3431
+ t && t(R, d.ast);
3432
3432
  });
3433
3433
  } else
3434
3434
  t && t(S, d.ast);
3435
3435
  return;
3436
3436
  }
3437
- o.preventDefault(), at(y, "Enter");
3437
+ o.preventDefault(), st(m, "Enter");
3438
3438
  return;
3439
3439
  }
3440
3440
  break;
3441
3441
  case "Tab": {
3442
- if (T) {
3442
+ if (L) {
3443
3443
  o.preventDefault();
3444
- const y = d.selectedSuggestionIndex >= 0 ? d.suggestions[d.selectedSuggestionIndex] : null, S = y && y.type !== "loading" && y.type !== "error" && !(y.type === "hint" && y.text !== "#" && y.text !== "!") ? y : null, b = d.cursorContext || { type: "EMPTY", partial: "" }, C = T({ suggestion: S, cursorContext: b, query: N.current });
3445
- C.accept && S ? at(S, "Tab", (O, k) => {
3446
- var $;
3447
- C.submit && t && t(O, k), C.blur && (($ = h.current) == null || $.blur());
3448
- }) : (Y(), C.submit && t && t(N.current, d.ast), C.blur && ((E = h.current) == null || E.blur()));
3444
+ const m = d.selectedSuggestionIndex >= 0 ? d.suggestions[d.selectedSuggestionIndex] : null, S = m && m.type !== "loading" && m.type !== "error" && !(m.type === "hint" && m.text !== "#" && m.text !== "!") ? m : null, b = d.cursorContext || { type: "EMPTY", partial: "" }, C = L({ suggestion: S, cursorContext: b, query: N.current });
3445
+ C.accept && S ? st(S, "Tab", (O, R) => {
3446
+ var z;
3447
+ C.submit && t && t(O, R), C.blur && ((z = h.current) == null || z.blur());
3448
+ }) : (K(), C.submit && t && t(N.current, d.ast), C.blur && ((y = h.current) == null || y.blur()));
3449
3449
  return;
3450
3450
  }
3451
3451
  if (d.selectedSuggestionIndex >= 0) {
3452
- const y = d.suggestions[d.selectedSuggestionIndex];
3453
- if (y.type === "hint" && y.text !== "#" && y.text !== "!") {
3454
- o.preventDefault(), Y();
3452
+ const m = d.suggestions[d.selectedSuggestionIndex];
3453
+ if (m.type === "hint" && m.text !== "#" && m.text !== "!") {
3454
+ o.preventDefault(), K();
3455
3455
  const S = N.current, b = d.cursorOffset;
3456
3456
  if (b <= S.length && S[b] !== " ") {
3457
- const C = S.slice(0, b), O = S.slice(b), k = C + " " + O, $ = b + 1;
3458
- we(k, $, (B) => {
3459
- ae(B, $);
3457
+ const C = S.slice(0, b), O = S.slice(b), R = C + " " + O, z = b + 1;
3458
+ xe(R, z, (I) => {
3459
+ le(I, z);
3460
3460
  });
3461
3461
  }
3462
3462
  return;
3463
3463
  }
3464
- o.preventDefault(), at(y, "Tab");
3464
+ o.preventDefault(), st(m, "Tab");
3465
3465
  return;
3466
3466
  }
3467
3467
  break;
3468
3468
  }
3469
3469
  case "Escape":
3470
- o.preventDefault(), Y();
3470
+ o.preventDefault(), K();
3471
3471
  return;
3472
3472
  }
3473
- if (o.key === "Tab" && T) {
3473
+ if (o.key === "Tab" && L) {
3474
3474
  o.preventDefault();
3475
- const y = d.cursorContext || { type: "EMPTY", partial: "" }, S = T({ suggestion: null, cursorContext: y, query: N.current });
3476
- S.submit && t && t(N.current, d.ast), S.blur && ((A = h.current) == null || A.blur());
3475
+ const m = d.cursorContext || { type: "EMPTY", partial: "" }, S = L({ suggestion: null, cursorContext: m, query: N.current });
3476
+ S.submit && t && t(N.current, d.ast), S.blur && ((k = h.current) == null || k.blur());
3477
3477
  return;
3478
3478
  }
3479
3479
  if (d.showDatePicker && o.key === "Escape") {
3480
- o.preventDefault(), Y();
3480
+ o.preventDefault(), K();
3481
3481
  return;
3482
3482
  }
3483
3483
  if (o.key === "Enter" && !d.showDropdown && !d.showDatePicker) {
3484
3484
  o.preventDefault(), t && t(N.current, d.ast);
3485
3485
  return;
3486
3486
  }
3487
- }, [t, Y, at, we, It, ht, M, ae, U, T, Te, Pe]), Lr = p.useCallback((o) => {
3487
+ }, [t, K, st, xe, Mt, ht, M, le, W, L, Le, Pe]), Tr = p.useCallback((o) => {
3488
3488
  if (["ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown"].includes(o.key)) {
3489
3489
  if (!h.current) return;
3490
- const E = Ae(h.current);
3491
- de(E.start), ve(E.end), Oe(G.current.tokens, E.start);
3490
+ const y = be(h.current);
3491
+ de(y.start), me(y.end), Ce(Y.current.tokens, y.start);
3492
3492
  }
3493
- }, [Oe]), Tr = p.useCallback(() => {
3494
- Zt(!0), v == null || v(), requestAnimationFrame(() => {
3493
+ }, [Ce]), Lr = p.useCallback(() => {
3494
+ jt(!0), v == null || v(), requestAnimationFrame(() => {
3495
3495
  if (h.current) {
3496
- const o = G.current.tokens;
3496
+ const o = Y.current.tokens;
3497
3497
  if (o.length > 0) {
3498
- const d = lt(h.current);
3499
- Oe(o, d);
3498
+ const d = ot(h.current);
3499
+ Ce(o, d);
3500
3500
  } else
3501
- Oe([], 0);
3501
+ Ce([], 0);
3502
3502
  }
3503
3503
  });
3504
- }, [Ne, Oe, v]), Pr = p.useCallback(() => {
3505
- Zt(!1), Z(!1), se(!1), de(-1), _ == null || _();
3506
- }, [_]), Mr = p.useCallback(() => {
3504
+ }, [De, Ce, v]), Pr = p.useCallback(() => {
3505
+ jt(!1), te(!1), oe(!1), de(-1), H == null || H();
3506
+ }, [H]), Mr = p.useCallback(() => {
3507
3507
  if (!h.current) return;
3508
- const o = Ae(h.current);
3509
- if (de(o.start), ve(o.end), o.start !== o.end) {
3510
- const [d, E] = ar(G.current.tokens, o.start, o.end);
3511
- if (d !== E) {
3512
- Y();
3508
+ const o = be(h.current);
3509
+ if (de(o.start), me(o.end), o.start !== o.end) {
3510
+ const [d, y] = ir(Y.current.tokens, o.start, o.end);
3511
+ if (d !== y) {
3512
+ K();
3513
3513
  return;
3514
3514
  }
3515
3515
  }
3516
- Oe(G.current.tokens, o.start);
3517
- }, [Oe, Y]), Ir = p.useCallback((o) => {
3516
+ Ce(Y.current.tokens, o.start);
3517
+ }, [Ce, K]), Fr = p.useCallback((o) => {
3518
3518
  o.preventDefault();
3519
- const d = nr(o.clipboardData.getData("text/plain"));
3520
- j.current && (clearTimeout(j.current), j.current = null), kn(d), Ne();
3521
- }, [Ne]), Fr = p.useCallback((o) => {
3522
- const d = G.current, E = Qe.current, A = E ? E.start : d.cursorOffset, y = E ? E.end : d.cursorOffset, S = N.current.slice(0, A), b = N.current.slice(y);
3519
+ const d = sr(o.clipboardData.getData("text/plain"));
3520
+ ee.current && (clearTimeout(ee.current), ee.current = null), kn(d), De();
3521
+ }, [De]), Ir = p.useCallback((o) => {
3522
+ const d = Y.current, y = Qe.current, k = y ? y.start : d.cursorOffset, m = y ? y.end : d.cursorOffset, S = N.current.slice(0, k), b = N.current.slice(m);
3523
3523
  let C = "", O = b;
3524
3524
  b.length === 0 ? C = " " : /^[ \t\r\n]+$/.test(b) && !b.startsWith("\\ ") && (C = " ", O = "");
3525
- const k = S + o + C + O, $ = S.length + o.length + C.length;
3526
- we(k, $, (B) => {
3527
- h.current && h.current.focus(), ae(B, $);
3525
+ const R = S + o + C + O, z = S.length + o.length + C.length;
3526
+ xe(R, z, (I) => {
3527
+ h.current && h.current.focus(), le(I, z);
3528
3528
  });
3529
- }, [we, ae]), Et = pt(f), Ft = dt(m), _r = rn(Et, H), Br = {
3529
+ }, [xe, le]), Et = pt(f), Ft = dt(E), _r = rn(Et, U), Br = {
3530
3530
  ...nn(Et, Ft),
3531
- ...rt ? sn(Ft) : {}
3531
+ ...tt ? sn(Ft) : {}
3532
3532
  }, Hr = an(Et, Ft);
3533
- return /* @__PURE__ */ p.createElement("div", { ref: Q, style: _r, className: P }, /* @__PURE__ */ p.createElement(
3533
+ return /* @__PURE__ */ p.createElement("div", { ref: j, style: _r, className: P }, /* @__PURE__ */ p.createElement(
3534
3534
  "div",
3535
3535
  {
3536
- ref: ye,
3536
+ ref: he,
3537
3537
  contentEditable: !0,
3538
3538
  suppressContentEditableWarning: !0,
3539
3539
  style: Br,
3540
- onInput: Ne,
3540
+ onInput: De,
3541
3541
  onKeyDown: Nr,
3542
- onKeyUp: Lr,
3543
- onFocus: Tr,
3542
+ onKeyUp: Tr,
3543
+ onFocus: Lr,
3544
3544
  onBlur: Pr,
3545
3545
  onClick: Mr,
3546
- onPaste: Ir,
3546
+ onPaste: Fr,
3547
3547
  onCompositionStart: Dr,
3548
3548
  onCompositionEnd: Or,
3549
3549
  spellCheck: !1
3550
3550
  }
3551
- ), wr && !rt ? /* @__PURE__ */ p.createElement("div", { style: Hr }, I || "Search...") : null, /* @__PURE__ */ p.createElement(
3551
+ ), wr && !tt ? /* @__PURE__ */ p.createElement("div", { style: Hr }, F || "Search...") : null, /* @__PURE__ */ p.createElement(
3552
3552
  An,
3553
3553
  {
3554
- errors: Nt,
3554
+ errors: Ot,
3555
3555
  editorRef: V,
3556
- cursorOffset: Fe,
3556
+ cursorOffset: Ie,
3557
3557
  colors: f,
3558
- styles: m,
3559
- containerRef: Q.current
3558
+ styles: E,
3559
+ containerRef: j.current
3560
3560
  }
3561
3561
  ), /* @__PURE__ */ p.createElement(
3562
3562
  mn,
3563
3563
  {
3564
- suggestions: At,
3565
- selectedIndex: kt,
3566
- onSelect: (o) => at(o, "Tab"),
3567
- position: Ot,
3564
+ suggestions: Rt,
3565
+ selectedIndex: At,
3566
+ onSelect: (o) => st(o, "Tab"),
3567
+ position: Dt,
3568
3568
  colors: f,
3569
- styles: m,
3570
- visible: Ct,
3569
+ styles: E,
3570
+ visible: kt,
3571
3571
  fixedWidth: Ar(),
3572
- renderHistoryItem: Le,
3573
- renderSavedSearchItem: wt,
3574
- renderDropdownHeader: bt,
3575
- cursorContext: Lt
3572
+ renderHistoryItem: Te,
3573
+ renderSavedSearchItem: xt,
3574
+ renderDropdownHeader: wt,
3575
+ cursorContext: Nt
3576
3576
  }
3577
- ), Dt && Ot ? /* @__PURE__ */ p.createElement(
3578
- Fn,
3577
+ ), Ct && Dt ? /* @__PURE__ */ p.createElement(
3578
+ In,
3579
3579
  {
3580
- position: Ot,
3580
+ position: Dt,
3581
3581
  colors: Et,
3582
- onSelect: Fr,
3582
+ onSelect: Ir,
3583
3583
  colorConfig: f,
3584
- styleConfig: m,
3584
+ styleConfig: E,
3585
3585
  datePickerInit: Rr,
3586
3586
  fixedWidth: void 0,
3587
- datePresets: F
3587
+ datePresets: B
3588
3588
  }
3589
3589
  ) : null);
3590
3590
  }
3591
3591
  function Wn(n) {
3592
3592
  if (!n) return [];
3593
3593
  const e = [];
3594
- return ut(n, void 0, e), e;
3594
+ return ct(n, void 0, e), e;
3595
3595
  }
3596
- function ut(n, e, t) {
3596
+ function ct(n, e, t) {
3597
3597
  switch (n.type) {
3598
3598
  case "BareTerm":
3599
3599
  t.push({
@@ -3644,27 +3644,27 @@ function ut(n, e, t) {
3644
3644
  });
3645
3645
  break;
3646
3646
  case "FieldGroup":
3647
- ut(n.expression, n.field, t);
3647
+ ct(n.expression, n.field, t);
3648
3648
  break;
3649
3649
  case "BooleanExpr":
3650
- ut(n.left, e, t), ut(n.right, e, t);
3650
+ ct(n.left, e, t), ct(n.right, e, t);
3651
3651
  break;
3652
3652
  case "Group":
3653
3653
  case "Not":
3654
- ut(n.expression, e, t);
3654
+ ct(n.expression, e, t);
3655
3655
  break;
3656
3656
  }
3657
3657
  }
3658
3658
  export {
3659
- ir as AutocompleteEngine,
3659
+ ut as AutocompleteEngine,
3660
3660
  Bn as DARK_COLORS,
3661
3661
  Hn as DARK_STYLES,
3662
3662
  zr as DEFAULT_COLORS,
3663
3663
  Er as DEFAULT_STYLES,
3664
3664
  Un as ElasticInput,
3665
- ct as Lexer,
3666
- We as Parser,
3665
+ lt as Lexer,
3666
+ Ue as Parser,
3667
3667
  lr as Validator,
3668
- ot as buildHighlightedHTML,
3668
+ it as buildHighlightedHTML,
3669
3669
  Wn as extractValues
3670
3670
  };