elastic-input 0.1.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.
- package/LICENSE +21 -0
- package/README.md +461 -0
- package/dist/autocomplete/AutocompleteEngine.d.ts +36 -0
- package/dist/autocomplete/suggestionTypes.d.ts +16 -0
- package/dist/components/AutocompleteDropdown.d.ts +24 -0
- package/dist/components/DatePicker.d.ts +9 -0
- package/dist/components/DateRangePicker.d.ts +16 -0
- package/dist/components/ElasticInput.d.ts +39 -0
- package/dist/components/HighlightedContent.d.ts +7 -0
- package/dist/components/ValidationSquiggles.d.ts +13 -0
- package/dist/constants.d.ts +18 -0
- package/dist/elastic-input.es.js +3670 -0
- package/dist/highlighting/parenMatch.d.ts +17 -0
- package/dist/highlighting/rangeHighlight.d.ts +10 -0
- package/dist/highlighting/regexHighlight.d.ts +10 -0
- package/dist/index.d.ts +18 -0
- package/dist/lexer/Lexer.d.ts +32 -0
- package/dist/lexer/tokens.d.ts +28 -0
- package/dist/parser/Parser.d.ts +37 -0
- package/dist/parser/ast.d.ts +97 -0
- package/dist/styles/inlineStyles.d.ts +19 -0
- package/dist/types.d.ts +383 -0
- package/dist/utils/cursorUtils.d.ts +16 -0
- package/dist/utils/dateUtils.d.ts +8 -0
- package/dist/utils/domUtils.d.ts +19 -0
- package/dist/utils/expandSelection.d.ts +20 -0
- package/dist/utils/extractValues.d.ts +26 -0
- package/dist/utils/smartSelect.d.ts +13 -0
- package/dist/utils/textUtils.d.ts +57 -0
- package/dist/utils/undoStack.d.ts +23 -0
- package/dist/validation/Validator.d.ts +39 -0
- package/dist/validation/dateValidator.d.ts +1 -0
- package/dist/validation/numberValidator.d.ts +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,3670 @@
|
|
|
1
|
+
var $r = Object.defineProperty;
|
|
2
|
+
var Vr = (n, e, t) => e in n ? $r(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var q = (n, e, t) => Vr(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import * as p from "react";
|
|
5
|
+
import * as mr from "react-dom";
|
|
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 {
|
|
8
|
+
constructor(e, t) {
|
|
9
|
+
q(this, "input");
|
|
10
|
+
q(this, "pos");
|
|
11
|
+
q(this, "state");
|
|
12
|
+
q(this, "tokens");
|
|
13
|
+
q(this, "options");
|
|
14
|
+
this.input = e, this.pos = 0, this.state = 0, this.tokens = [], this.options = t || {};
|
|
15
|
+
}
|
|
16
|
+
tokenize() {
|
|
17
|
+
for (this.tokens = [], this.pos = 0, this.state = 0; this.pos < this.input.length; )
|
|
18
|
+
this.state === 1 ? this.readValue() : this.readTerm();
|
|
19
|
+
return this.tokens;
|
|
20
|
+
}
|
|
21
|
+
peek() {
|
|
22
|
+
return this.input[this.pos];
|
|
23
|
+
}
|
|
24
|
+
peekAt(e) {
|
|
25
|
+
return this.input[this.pos + e];
|
|
26
|
+
}
|
|
27
|
+
advance() {
|
|
28
|
+
return this.input[this.pos++];
|
|
29
|
+
}
|
|
30
|
+
isWhitespace(e) {
|
|
31
|
+
return e === " " || e === " " || e === `
|
|
32
|
+
` || e === "\r";
|
|
33
|
+
}
|
|
34
|
+
isAlpha(e) {
|
|
35
|
+
return /[a-zA-Z_]/.test(e);
|
|
36
|
+
}
|
|
37
|
+
isAlphaNumeric(e) {
|
|
38
|
+
return /[a-zA-Z0-9_.\-]/.test(e);
|
|
39
|
+
}
|
|
40
|
+
readWhitespace() {
|
|
41
|
+
const e = this.pos;
|
|
42
|
+
for (; this.pos < this.input.length && this.isWhitespace(this.peek()); )
|
|
43
|
+
this.advance();
|
|
44
|
+
this.tokens.push({
|
|
45
|
+
type: l.WHITESPACE,
|
|
46
|
+
value: this.input.slice(e, this.pos),
|
|
47
|
+
start: e,
|
|
48
|
+
end: this.pos
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
readQuotedString() {
|
|
52
|
+
const e = this.pos, t = this.advance();
|
|
53
|
+
for (; this.pos < this.input.length; ) {
|
|
54
|
+
const r = this.advance();
|
|
55
|
+
if (r === "\\" && this.pos < this.input.length)
|
|
56
|
+
this.advance();
|
|
57
|
+
else if (r === t)
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
this.tokens.push({
|
|
61
|
+
type: l.QUOTED_VALUE,
|
|
62
|
+
value: this.input.slice(e, this.pos),
|
|
63
|
+
start: e,
|
|
64
|
+
end: this.pos
|
|
65
|
+
}), this.tryReadModifier(), this.state = 0;
|
|
66
|
+
}
|
|
67
|
+
readTerm() {
|
|
68
|
+
const e = this.peek();
|
|
69
|
+
if (this.isWhitespace(e)) {
|
|
70
|
+
this.readWhitespace();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (e === '"') {
|
|
74
|
+
this.readQuotedString();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (e === "(") {
|
|
78
|
+
this.tokens.push({ type: l.LPAREN, value: "(", start: this.pos, end: this.pos + 1 }), this.advance();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (e === ")") {
|
|
82
|
+
this.tokens.push({ type: l.RPAREN, value: ")", start: this.pos, end: this.pos + 1 }), this.advance();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (e === "~" || e === "^") {
|
|
86
|
+
const r = this.pos, s = e === "~" ? l.TILDE : l.BOOST;
|
|
87
|
+
for (this.advance(); this.pos < this.input.length && /[0-9.]/.test(this.peek()); )
|
|
88
|
+
this.advance();
|
|
89
|
+
this.tokens.push({ type: s, value: this.input.slice(r, this.pos), start: r, end: this.pos });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (e === "[" || e === "{") {
|
|
93
|
+
this.readRangeValue();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (e === "#" && this.options.savedSearches) {
|
|
97
|
+
this.readSavedSearch();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (e === "!" && this.options.historySearch) {
|
|
101
|
+
this.readHistoryRef();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (e === "-" || e === "+") {
|
|
105
|
+
const r = this.peekAt(1);
|
|
106
|
+
if (r && (this.isAlpha(r) || r === '"' || r === "(" || r === "#" || r === "!" || r === "[" || r === "{") || (!r || r === ")" || r === " " || r === " " || r === `
|
|
107
|
+
` || r === "\r")) {
|
|
108
|
+
this.tokens.push({
|
|
109
|
+
type: l.PREFIX_OP,
|
|
110
|
+
value: e,
|
|
111
|
+
start: this.pos,
|
|
112
|
+
end: this.pos + 1
|
|
113
|
+
}), this.advance();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (e === "&" && this.peekAt(1) === "&") {
|
|
118
|
+
this.tokens.push({ type: l.AND, value: "&&", start: this.pos, end: this.pos + 2 }), this.advance(), this.advance();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (e === "|" && this.peekAt(1) === "|") {
|
|
122
|
+
this.tokens.push({ type: l.OR, value: "||", start: this.pos, end: this.pos + 2 }), this.advance(), this.advance();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if ((e === ">" || e === "<") && this.state === 0) {
|
|
126
|
+
const r = this.pos;
|
|
127
|
+
this.advance(), this.pos < this.input.length && this.peek() === "=" && this.advance(), this.tokens.push({
|
|
128
|
+
type: l.COMPARISON_OP,
|
|
129
|
+
value: this.input.slice(r, this.pos),
|
|
130
|
+
start: r,
|
|
131
|
+
end: this.pos
|
|
132
|
+
}), this.state = 1;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (e === "/") {
|
|
136
|
+
this.readRegex();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const t = this.pos;
|
|
140
|
+
for (; this.pos < this.input.length && !this.isWhitespace(this.peek()) && this.peek() !== "(" && this.peek() !== ")" && this.peek() !== '"' && this.peek() !== "~" && this.peek() !== "^" && !(this.peek() === "&" && this.peekAt(1) === "&") && !(this.peek() === "|" && this.peekAt(1) === "|"); ) {
|
|
141
|
+
if (this.peek() === "\\" && this.pos + 1 < this.input.length) {
|
|
142
|
+
this.advance(), this.advance();
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (this.peek() === ":") {
|
|
146
|
+
this.pos > t && this.tokens.push({
|
|
147
|
+
type: l.FIELD_NAME,
|
|
148
|
+
value: this.input.slice(t, this.pos),
|
|
149
|
+
start: t,
|
|
150
|
+
end: this.pos
|
|
151
|
+
}), this.tokens.push({ type: l.COLON, value: ":", start: this.pos, end: this.pos + 1 }), this.advance(), this.state = 1;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.advance();
|
|
155
|
+
}
|
|
156
|
+
if (this.pos > t) {
|
|
157
|
+
const r = this.input.slice(t, this.pos), s = r.toUpperCase();
|
|
158
|
+
s === "AND" ? this.tokens.push({ type: l.AND, value: r, start: t, end: this.pos }) : s === "OR" ? this.tokens.push({ type: l.OR, value: r, start: t, end: this.pos }) : s === "NOT" ? this.tokens.push({ type: l.NOT, value: r, start: t, end: this.pos }) : r.includes("*") || r.includes("?") ? this.tokens.push({ type: l.WILDCARD, value: r, start: t, end: this.pos }) : this.tokens.push({ type: l.VALUE, value: r, start: t, end: this.pos }), this.tryReadModifier();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
readValue() {
|
|
162
|
+
const e = this.peek();
|
|
163
|
+
if (this.isWhitespace(e)) {
|
|
164
|
+
this.readWhitespace(), this.state = 0;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (e === '"') {
|
|
168
|
+
this.readQuotedString(), this.state = 0;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (e === "(" || e === ")") {
|
|
172
|
+
this.state = 0, this.readTerm();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (e === ">" || e === "<") {
|
|
176
|
+
const r = this.pos;
|
|
177
|
+
this.advance(), this.pos < this.input.length && this.peek() === "=" && this.advance(), this.tokens.push({
|
|
178
|
+
type: l.COMPARISON_OP,
|
|
179
|
+
value: this.input.slice(r, this.pos),
|
|
180
|
+
start: r,
|
|
181
|
+
end: this.pos
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (e === "[" || e === "{") {
|
|
186
|
+
this.readRangeValue();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (e === "/") {
|
|
190
|
+
this.readRegex(), this.state = 0;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const t = this.pos;
|
|
194
|
+
for (; this.pos < this.input.length && !this.isWhitespace(this.peek()) && this.peek() !== ")" && this.peek() !== "(" && this.peek() !== '"' && this.peek() !== "~" && this.peek() !== "^"; ) {
|
|
195
|
+
if (this.peek() === "\\" && this.pos + 1 < this.input.length) {
|
|
196
|
+
this.advance(), this.advance();
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
this.advance();
|
|
200
|
+
}
|
|
201
|
+
if (this.pos > t) {
|
|
202
|
+
const r = this.input.slice(t, this.pos);
|
|
203
|
+
r.includes("*") || r.includes("?") ? this.tokens.push({ type: l.WILDCARD, value: r, start: t, end: this.pos }) : this.tokens.push({ type: l.VALUE, value: r, start: t, end: this.pos }), this.tryReadModifier();
|
|
204
|
+
}
|
|
205
|
+
this.state = 0;
|
|
206
|
+
}
|
|
207
|
+
readRangeValue() {
|
|
208
|
+
const e = this.pos;
|
|
209
|
+
for (this.advance(); this.pos < this.input.length && this.peek() !== "]" && this.peek() !== "}"; )
|
|
210
|
+
this.advance();
|
|
211
|
+
this.pos < this.input.length && (this.peek() === "]" || this.peek() === "}") && this.advance(), this.tokens.push({
|
|
212
|
+
type: l.RANGE,
|
|
213
|
+
value: this.input.slice(e, this.pos),
|
|
214
|
+
start: e,
|
|
215
|
+
end: this.pos
|
|
216
|
+
}), this.state = 0;
|
|
217
|
+
}
|
|
218
|
+
tryReadModifier() {
|
|
219
|
+
for (; this.pos < this.input.length && (this.peek() === "~" || this.peek() === "^"); ) {
|
|
220
|
+
const e = this.pos, r = this.advance() === "~" ? l.TILDE : l.BOOST;
|
|
221
|
+
for (; this.pos < this.input.length && /[0-9.]/.test(this.peek()); )
|
|
222
|
+
this.advance();
|
|
223
|
+
this.tokens.push({
|
|
224
|
+
type: r,
|
|
225
|
+
value: this.input.slice(e, this.pos),
|
|
226
|
+
start: e,
|
|
227
|
+
end: this.pos
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
readRegex() {
|
|
232
|
+
const e = this.pos;
|
|
233
|
+
for (this.advance(); this.pos < this.input.length; ) {
|
|
234
|
+
const t = this.peek();
|
|
235
|
+
if (t === "\\" && this.pos + 1 < this.input.length) {
|
|
236
|
+
this.advance(), this.advance();
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (t === "/") {
|
|
240
|
+
this.advance(), this.tokens.push({
|
|
241
|
+
type: l.REGEX,
|
|
242
|
+
value: this.input.slice(e, this.pos),
|
|
243
|
+
start: e,
|
|
244
|
+
end: this.pos
|
|
245
|
+
}), this.tryReadModifier(), this.state = 0;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.advance();
|
|
249
|
+
}
|
|
250
|
+
this.tokens.push({
|
|
251
|
+
type: l.VALUE,
|
|
252
|
+
value: this.input.slice(e, this.pos),
|
|
253
|
+
start: e,
|
|
254
|
+
end: this.pos
|
|
255
|
+
}), this.state = 0;
|
|
256
|
+
}
|
|
257
|
+
readSavedSearch() {
|
|
258
|
+
const e = this.pos;
|
|
259
|
+
for (this.advance(); this.pos < this.input.length && this.isAlphaNumeric(this.peek()); )
|
|
260
|
+
this.advance();
|
|
261
|
+
this.tokens.push({
|
|
262
|
+
type: l.SAVED_SEARCH,
|
|
263
|
+
value: this.input.slice(e, this.pos),
|
|
264
|
+
start: e,
|
|
265
|
+
end: this.pos
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
readHistoryRef() {
|
|
269
|
+
const e = this.pos;
|
|
270
|
+
for (this.advance(); this.pos < this.input.length && this.isAlphaNumeric(this.peek()); )
|
|
271
|
+
this.advance();
|
|
272
|
+
this.tokens.push({
|
|
273
|
+
type: l.HISTORY_REF,
|
|
274
|
+
value: this.input.slice(e, this.pos),
|
|
275
|
+
start: e,
|
|
276
|
+
end: this.pos
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
class We {
|
|
281
|
+
constructor(e) {
|
|
282
|
+
q(this, "tokens");
|
|
283
|
+
q(this, "pos");
|
|
284
|
+
q(this, "nonWsTokens");
|
|
285
|
+
q(this, "errors", []);
|
|
286
|
+
this.tokens = e, this.nonWsTokens = e.filter((t) => t.type !== l.WHITESPACE), this.pos = 0;
|
|
287
|
+
}
|
|
288
|
+
getErrors() {
|
|
289
|
+
return this.errors;
|
|
290
|
+
}
|
|
291
|
+
/** Check if a QUOTED_VALUE token is missing its closing quote. */
|
|
292
|
+
isUnclosedQuote(e) {
|
|
293
|
+
if (e.type !== l.QUOTED_VALUE) return !1;
|
|
294
|
+
const t = e.value;
|
|
295
|
+
if (t.length < 2) return !0;
|
|
296
|
+
const r = t[0];
|
|
297
|
+
return t[t.length - 1] !== r;
|
|
298
|
+
}
|
|
299
|
+
/** Strip quotes from a QUOTED_VALUE token, handling unclosed quotes correctly. */
|
|
300
|
+
stripQuotes(e) {
|
|
301
|
+
const t = e.value;
|
|
302
|
+
return this.isUnclosedQuote(e) ? t.slice(1) : t.slice(1, -1);
|
|
303
|
+
}
|
|
304
|
+
/** If the token is an unclosed quote, push an error. */
|
|
305
|
+
checkUnclosedQuote(e) {
|
|
306
|
+
this.isUnclosedQuote(e) && this.errors.push({
|
|
307
|
+
type: "Error",
|
|
308
|
+
value: e.value[0],
|
|
309
|
+
message: "Missing closing quote",
|
|
310
|
+
start: e.start,
|
|
311
|
+
end: e.start + 1
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
parse() {
|
|
315
|
+
if (this.nonWsTokens.length === 0) return null;
|
|
316
|
+
let e = this.parseOr();
|
|
317
|
+
for (; this.peek(); ) {
|
|
318
|
+
const t = this.peek();
|
|
319
|
+
if (t.type === l.RPAREN)
|
|
320
|
+
this.advance(), this.errors.push({
|
|
321
|
+
type: "Error",
|
|
322
|
+
value: t.value,
|
|
323
|
+
message: "Unexpected closing parenthesis",
|
|
324
|
+
start: t.start,
|
|
325
|
+
end: t.end
|
|
326
|
+
});
|
|
327
|
+
else {
|
|
328
|
+
const r = this.parseOr();
|
|
329
|
+
e = {
|
|
330
|
+
type: "BooleanExpr",
|
|
331
|
+
operator: "AND",
|
|
332
|
+
left: e,
|
|
333
|
+
right: r,
|
|
334
|
+
start: e.start,
|
|
335
|
+
end: r.end
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return e;
|
|
340
|
+
}
|
|
341
|
+
peek() {
|
|
342
|
+
return this.nonWsTokens[this.pos];
|
|
343
|
+
}
|
|
344
|
+
advance() {
|
|
345
|
+
return this.nonWsTokens[this.pos++];
|
|
346
|
+
}
|
|
347
|
+
match(e) {
|
|
348
|
+
var t;
|
|
349
|
+
if (((t = this.peek()) == null ? void 0 : t.type) === e)
|
|
350
|
+
return this.advance();
|
|
351
|
+
}
|
|
352
|
+
parseOr() {
|
|
353
|
+
var t;
|
|
354
|
+
let e = this.parseAnd();
|
|
355
|
+
for (; ((t = this.peek()) == null ? void 0 : t.type) === l.OR; ) {
|
|
356
|
+
const r = this.advance(), s = this.parseAnd();
|
|
357
|
+
if (s.type === "Error" && s.value === "") {
|
|
358
|
+
this.errors.push({
|
|
359
|
+
type: "Error",
|
|
360
|
+
value: r.value,
|
|
361
|
+
message: "Missing search term after OR",
|
|
362
|
+
start: r.start,
|
|
363
|
+
end: r.end
|
|
364
|
+
});
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
e = {
|
|
368
|
+
type: "BooleanExpr",
|
|
369
|
+
operator: "OR",
|
|
370
|
+
left: e,
|
|
371
|
+
right: s,
|
|
372
|
+
start: e.start,
|
|
373
|
+
end: s.end
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return e;
|
|
377
|
+
}
|
|
378
|
+
parseAnd() {
|
|
379
|
+
let e = this.parseNot();
|
|
380
|
+
for (; ; ) {
|
|
381
|
+
const t = this.peek();
|
|
382
|
+
if (!t) break;
|
|
383
|
+
if (t.type === l.AND) {
|
|
384
|
+
const r = this.advance(), s = this.parseNot();
|
|
385
|
+
if (s.type === "Error" && s.value === "") {
|
|
386
|
+
this.errors.push({
|
|
387
|
+
type: "Error",
|
|
388
|
+
value: r.value,
|
|
389
|
+
message: "Missing search term after AND",
|
|
390
|
+
start: r.start,
|
|
391
|
+
end: r.end
|
|
392
|
+
});
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
e = {
|
|
396
|
+
type: "BooleanExpr",
|
|
397
|
+
operator: "AND",
|
|
398
|
+
left: e,
|
|
399
|
+
right: s,
|
|
400
|
+
start: e.start,
|
|
401
|
+
end: s.end
|
|
402
|
+
};
|
|
403
|
+
} else {
|
|
404
|
+
if (t.type === l.OR || t.type === l.RPAREN)
|
|
405
|
+
break;
|
|
406
|
+
{
|
|
407
|
+
const r = this.parseNot();
|
|
408
|
+
e = {
|
|
409
|
+
type: "BooleanExpr",
|
|
410
|
+
operator: "AND",
|
|
411
|
+
left: e,
|
|
412
|
+
right: r,
|
|
413
|
+
start: e.start,
|
|
414
|
+
end: r.end
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return e;
|
|
420
|
+
}
|
|
421
|
+
parseNot() {
|
|
422
|
+
var e;
|
|
423
|
+
if (((e = this.peek()) == null ? void 0 : e.type) === l.NOT) {
|
|
424
|
+
const t = this.advance(), r = this.parsePrimary();
|
|
425
|
+
return r.type === "Error" && r.value === "" ? (this.errors.push({
|
|
426
|
+
type: "Error",
|
|
427
|
+
value: t.value,
|
|
428
|
+
message: "Missing search term after NOT",
|
|
429
|
+
start: t.start,
|
|
430
|
+
end: t.end
|
|
431
|
+
}), r) : {
|
|
432
|
+
type: "Not",
|
|
433
|
+
expression: r,
|
|
434
|
+
start: t.start,
|
|
435
|
+
end: r.end
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
return this.parsePrimary();
|
|
439
|
+
}
|
|
440
|
+
applyGroupBoost(e) {
|
|
441
|
+
var t;
|
|
442
|
+
if (((t = this.peek()) == null ? void 0 : t.type) === l.BOOST) {
|
|
443
|
+
const r = this.advance(), s = r.value.slice(1), i = parseFloat(s);
|
|
444
|
+
e.boost = isNaN(i) ? 1 : i, e.end = r.end;
|
|
445
|
+
}
|
|
446
|
+
return e;
|
|
447
|
+
}
|
|
448
|
+
applyModifiers(e) {
|
|
449
|
+
var t, r;
|
|
450
|
+
if (e.type !== "BareTerm" && e.type !== "FieldValue") return e;
|
|
451
|
+
if (((t = this.peek()) == null ? void 0 : t.type) === l.TILDE) {
|
|
452
|
+
const s = this.advance(), i = s.value.slice(1), a = parseInt(i, 10);
|
|
453
|
+
e.quoted ? e.proximity = isNaN(a) ? 0 : a : e.fuzzy = isNaN(a) ? 0 : a, e.end = s.end;
|
|
454
|
+
}
|
|
455
|
+
if (((r = this.peek()) == null ? void 0 : r.type) === l.BOOST) {
|
|
456
|
+
const s = this.advance(), i = s.value.slice(1), a = parseFloat(i);
|
|
457
|
+
e.boost = isNaN(a) ? 1 : a, e.end = s.end;
|
|
458
|
+
}
|
|
459
|
+
return e;
|
|
460
|
+
}
|
|
461
|
+
parseRangeBound(e, t) {
|
|
462
|
+
const r = e.length - e.trimStart().length, s = e.trim();
|
|
463
|
+
return s.startsWith('"') && s.endsWith('"') && s.length >= 2 ? { value: s.slice(1, -1), quoted: !0, valueStart: t + r, valueEnd: t + r + s.length } : s.startsWith('"') ? { value: s.slice(1), quoted: !0, valueStart: t + r, valueEnd: t + r + s.length } : { value: s, quoted: !1, valueStart: t + r, valueEnd: t + r + s.length };
|
|
464
|
+
}
|
|
465
|
+
parseRange(e) {
|
|
466
|
+
const t = e.value, r = t[0], s = r === "[", i = t[t.length - 1], a = i === "]" || i === "}", u = i === "]";
|
|
467
|
+
a || this.errors.push({
|
|
468
|
+
type: "Error",
|
|
469
|
+
value: r,
|
|
470
|
+
message: "Unclosed range expression",
|
|
471
|
+
start: e.start,
|
|
472
|
+
end: e.start + 1
|
|
473
|
+
});
|
|
474
|
+
const c = a ? t.slice(1, -1) : t.slice(1), g = c.match(/^(.*?)\s+[Tt][Oo]\s+(.*)$/), f = e.start + 1;
|
|
475
|
+
if (!g) {
|
|
476
|
+
this.errors.push({
|
|
477
|
+
type: "Error",
|
|
478
|
+
value: t,
|
|
479
|
+
message: "Range expression missing TO keyword",
|
|
480
|
+
start: e.start,
|
|
481
|
+
end: e.end
|
|
482
|
+
});
|
|
483
|
+
const H = this.parseRangeBound(c, f);
|
|
484
|
+
return {
|
|
485
|
+
type: "Range",
|
|
486
|
+
lower: H.value,
|
|
487
|
+
upper: "",
|
|
488
|
+
lowerInclusive: s,
|
|
489
|
+
upperInclusive: a ? u : !0,
|
|
490
|
+
lowerQuoted: H.quoted,
|
|
491
|
+
upperQuoted: !1,
|
|
492
|
+
lowerStart: H.valueStart,
|
|
493
|
+
lowerEnd: H.valueEnd,
|
|
494
|
+
upperStart: e.end,
|
|
495
|
+
upperEnd: e.end,
|
|
496
|
+
start: e.start,
|
|
497
|
+
end: e.end
|
|
498
|
+
};
|
|
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);
|
|
501
|
+
return {
|
|
502
|
+
type: "Range",
|
|
503
|
+
lower: m.value,
|
|
504
|
+
upper: P.value,
|
|
505
|
+
lowerInclusive: s,
|
|
506
|
+
upperInclusive: a ? u : !0,
|
|
507
|
+
lowerQuoted: m.quoted,
|
|
508
|
+
upperQuoted: P.quoted,
|
|
509
|
+
lowerStart: m.valueStart,
|
|
510
|
+
lowerEnd: m.valueEnd,
|
|
511
|
+
upperStart: P.valueStart,
|
|
512
|
+
upperEnd: P.valueEnd,
|
|
513
|
+
start: e.start,
|
|
514
|
+
end: e.end
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
parsePrimary() {
|
|
518
|
+
var r, s, i;
|
|
519
|
+
const e = this.peek();
|
|
520
|
+
if (!e)
|
|
521
|
+
return {
|
|
522
|
+
type: "Error",
|
|
523
|
+
value: "",
|
|
524
|
+
message: "Unexpected end of input",
|
|
525
|
+
start: this.nonWsTokens.length > 0 ? this.nonWsTokens[this.nonWsTokens.length - 1].end : 0,
|
|
526
|
+
end: this.nonWsTokens.length > 0 ? this.nonWsTokens[this.nonWsTokens.length - 1].end : 0
|
|
527
|
+
};
|
|
528
|
+
if (e.type === l.AND) {
|
|
529
|
+
const a = this.advance();
|
|
530
|
+
return this.errors.push({
|
|
531
|
+
type: "Error",
|
|
532
|
+
value: a.value,
|
|
533
|
+
message: "Unexpected AND",
|
|
534
|
+
start: a.start,
|
|
535
|
+
end: a.end
|
|
536
|
+
}), this.parsePrimary();
|
|
537
|
+
}
|
|
538
|
+
if (e.type === l.OR) {
|
|
539
|
+
const a = this.advance();
|
|
540
|
+
return this.errors.push({
|
|
541
|
+
type: "Error",
|
|
542
|
+
value: a.value,
|
|
543
|
+
message: "Unexpected OR",
|
|
544
|
+
start: a.start,
|
|
545
|
+
end: a.end
|
|
546
|
+
}), this.parsePrimary();
|
|
547
|
+
}
|
|
548
|
+
if (e.type === l.PREFIX_OP) {
|
|
549
|
+
const a = this.advance(), u = this.parsePrimary();
|
|
550
|
+
return a.value === "-" ? {
|
|
551
|
+
type: "Not",
|
|
552
|
+
expression: u,
|
|
553
|
+
start: a.start,
|
|
554
|
+
end: u.end
|
|
555
|
+
} : { ...u, start: a.start };
|
|
556
|
+
}
|
|
557
|
+
if (e.type === l.LPAREN) {
|
|
558
|
+
const a = this.advance();
|
|
559
|
+
if (!this.peek() || this.peek().type === l.RPAREN) {
|
|
560
|
+
const f = this.match(l.RPAREN);
|
|
561
|
+
f || this.errors.push({
|
|
562
|
+
type: "Error",
|
|
563
|
+
value: a.value,
|
|
564
|
+
message: "Unclosed parenthesis",
|
|
565
|
+
start: a.start,
|
|
566
|
+
end: a.end
|
|
567
|
+
});
|
|
568
|
+
const m = {
|
|
569
|
+
type: "Group",
|
|
570
|
+
expression: { type: "BareTerm", value: "", quoted: !1, start: a.end, end: a.end },
|
|
571
|
+
start: a.start,
|
|
572
|
+
end: f ? f.end : a.end
|
|
573
|
+
};
|
|
574
|
+
return this.applyGroupBoost(m);
|
|
575
|
+
}
|
|
576
|
+
const u = this.parseOr(), c = this.match(l.RPAREN);
|
|
577
|
+
c || this.errors.push({
|
|
578
|
+
type: "Error",
|
|
579
|
+
value: a.value,
|
|
580
|
+
message: "Missing closing parenthesis",
|
|
581
|
+
start: a.start,
|
|
582
|
+
end: a.end
|
|
583
|
+
});
|
|
584
|
+
const g = {
|
|
585
|
+
type: "Group",
|
|
586
|
+
expression: u,
|
|
587
|
+
start: a.start,
|
|
588
|
+
end: c ? c.end : u.end
|
|
589
|
+
};
|
|
590
|
+
return this.applyGroupBoost(g);
|
|
591
|
+
}
|
|
592
|
+
if (e.type === l.SAVED_SEARCH) {
|
|
593
|
+
const a = this.advance();
|
|
594
|
+
return {
|
|
595
|
+
type: "SavedSearch",
|
|
596
|
+
name: a.value.slice(1),
|
|
597
|
+
// remove #
|
|
598
|
+
start: a.start,
|
|
599
|
+
end: a.end
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
if (e.type === l.HISTORY_REF) {
|
|
603
|
+
const a = this.advance();
|
|
604
|
+
return {
|
|
605
|
+
type: "HistoryRef",
|
|
606
|
+
ref: a.value.slice(1),
|
|
607
|
+
// remove !
|
|
608
|
+
start: a.start,
|
|
609
|
+
end: a.end
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
if (e.type === l.FIELD_NAME) {
|
|
613
|
+
const a = this.advance(), u = this.match(l.COLON);
|
|
614
|
+
if (u) {
|
|
615
|
+
let c = ":";
|
|
616
|
+
const g = this.match(l.COMPARISON_OP);
|
|
617
|
+
if (g && (c = g.value), ((r = this.peek()) == null ? void 0 : r.type) === l.LPAREN) {
|
|
618
|
+
const m = this.advance();
|
|
619
|
+
if (!this.peek() || this.peek().type === l.RPAREN) {
|
|
620
|
+
const x = this.match(l.RPAREN);
|
|
621
|
+
x || this.errors.push({
|
|
622
|
+
type: "Error",
|
|
623
|
+
value: m.value,
|
|
624
|
+
message: "Unclosed parenthesis",
|
|
625
|
+
start: m.start,
|
|
626
|
+
end: m.end
|
|
627
|
+
});
|
|
628
|
+
const R = {
|
|
629
|
+
type: "FieldGroup",
|
|
630
|
+
field: a.value,
|
|
631
|
+
expression: { type: "BareTerm", value: "", quoted: !1, start: m.end, end: m.end },
|
|
632
|
+
start: a.start,
|
|
633
|
+
end: x ? x.end : m.end
|
|
634
|
+
};
|
|
635
|
+
return this.applyGroupBoost(R);
|
|
636
|
+
}
|
|
637
|
+
const I = this.parseOr(), P = this.match(l.RPAREN);
|
|
638
|
+
P || this.errors.push({
|
|
639
|
+
type: "Error",
|
|
640
|
+
value: m.value,
|
|
641
|
+
message: "Missing closing parenthesis",
|
|
642
|
+
start: m.start,
|
|
643
|
+
end: m.end
|
|
644
|
+
});
|
|
645
|
+
const H = {
|
|
646
|
+
type: "FieldGroup",
|
|
647
|
+
field: a.value,
|
|
648
|
+
expression: I,
|
|
649
|
+
start: a.start,
|
|
650
|
+
end: P ? P.end : I.end
|
|
651
|
+
};
|
|
652
|
+
return this.applyGroupBoost(H);
|
|
653
|
+
}
|
|
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;
|
|
657
|
+
}
|
|
658
|
+
if (((i = this.peek()) == null ? void 0 : i.type) === l.REGEX) {
|
|
659
|
+
const m = this.advance();
|
|
660
|
+
return {
|
|
661
|
+
type: "Regex",
|
|
662
|
+
pattern: m.value.slice(1, -1),
|
|
663
|
+
start: a.start,
|
|
664
|
+
end: m.end
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
const f = this.peek();
|
|
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;
|
|
672
|
+
return this.applyModifiers({
|
|
673
|
+
type: "FieldValue",
|
|
674
|
+
field: a.value,
|
|
675
|
+
operator: c,
|
|
676
|
+
value: P,
|
|
677
|
+
quoted: I,
|
|
678
|
+
start: a.start,
|
|
679
|
+
end: m.end
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
type: "FieldValue",
|
|
684
|
+
field: a.value,
|
|
685
|
+
operator: c,
|
|
686
|
+
value: "",
|
|
687
|
+
quoted: !1,
|
|
688
|
+
start: a.start,
|
|
689
|
+
end: g ? g.end : u.end
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
return {
|
|
693
|
+
type: "BareTerm",
|
|
694
|
+
value: a.value,
|
|
695
|
+
quoted: !1,
|
|
696
|
+
start: a.start,
|
|
697
|
+
end: a.end
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
if (e.type === l.COMPARISON_OP) {
|
|
701
|
+
const a = this.advance(), u = this.peek();
|
|
702
|
+
if (u && (u.type === l.VALUE || u.type === l.QUOTED_VALUE)) {
|
|
703
|
+
const c = this.advance();
|
|
704
|
+
return {
|
|
705
|
+
type: "BareTerm",
|
|
706
|
+
value: a.value + c.value,
|
|
707
|
+
quoted: !1,
|
|
708
|
+
start: a.start,
|
|
709
|
+
end: c.end
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
type: "Error",
|
|
714
|
+
value: a.value,
|
|
715
|
+
message: "Comparison operator without value",
|
|
716
|
+
start: a.start,
|
|
717
|
+
end: a.end
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
if (e.type === l.QUOTED_VALUE) {
|
|
721
|
+
const a = this.advance();
|
|
722
|
+
return this.checkUnclosedQuote(a), this.applyModifiers({
|
|
723
|
+
type: "BareTerm",
|
|
724
|
+
value: this.stripQuotes(a),
|
|
725
|
+
quoted: !0,
|
|
726
|
+
start: a.start,
|
|
727
|
+
end: a.end
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
if (e.type === l.WILDCARD) {
|
|
731
|
+
const a = this.advance();
|
|
732
|
+
return this.applyModifiers({
|
|
733
|
+
type: "BareTerm",
|
|
734
|
+
value: a.value,
|
|
735
|
+
quoted: !1,
|
|
736
|
+
start: a.start,
|
|
737
|
+
end: a.end
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
if (e.type === l.RANGE) {
|
|
741
|
+
const a = this.advance();
|
|
742
|
+
return this.parseRange(a);
|
|
743
|
+
}
|
|
744
|
+
if (e.type === l.REGEX) {
|
|
745
|
+
const a = this.advance();
|
|
746
|
+
return {
|
|
747
|
+
type: "Regex",
|
|
748
|
+
pattern: a.value.slice(1, -1),
|
|
749
|
+
// remove surrounding /
|
|
750
|
+
start: a.start,
|
|
751
|
+
end: a.end
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
if (e.type === l.VALUE) {
|
|
755
|
+
const a = this.advance();
|
|
756
|
+
return this.applyModifiers({
|
|
757
|
+
type: "BareTerm",
|
|
758
|
+
value: a.value,
|
|
759
|
+
quoted: !1,
|
|
760
|
+
start: a.start,
|
|
761
|
+
end: a.end
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
if (e.type === l.RPAREN) {
|
|
765
|
+
const a = this.advance();
|
|
766
|
+
return this.errors.push({
|
|
767
|
+
type: "Error",
|
|
768
|
+
value: a.value,
|
|
769
|
+
message: "Unexpected closing parenthesis",
|
|
770
|
+
start: a.start,
|
|
771
|
+
end: a.end
|
|
772
|
+
}), {
|
|
773
|
+
type: "Error",
|
|
774
|
+
value: a.value,
|
|
775
|
+
message: "Unexpected closing parenthesis",
|
|
776
|
+
start: a.start,
|
|
777
|
+
end: a.end
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
const t = this.advance();
|
|
781
|
+
return {
|
|
782
|
+
type: "Error",
|
|
783
|
+
value: t.value,
|
|
784
|
+
message: `Unexpected token: ${t.value}`,
|
|
785
|
+
start: t.start,
|
|
786
|
+
end: t.end
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
static getCursorContext(e, t) {
|
|
790
|
+
let r, s;
|
|
791
|
+
for (const a of e)
|
|
792
|
+
if (a.type !== l.WHITESPACE) {
|
|
793
|
+
if (t >= a.start && t <= a.end) {
|
|
794
|
+
r = a;
|
|
795
|
+
break;
|
|
796
|
+
}
|
|
797
|
+
a.end <= t && (s = a);
|
|
798
|
+
}
|
|
799
|
+
const i = (a) => {
|
|
800
|
+
let u = 0;
|
|
801
|
+
for (let c = a; c >= 0; c--) {
|
|
802
|
+
const g = e[c];
|
|
803
|
+
if (g.type !== l.WHITESPACE) {
|
|
804
|
+
if (g.type === l.RPAREN) {
|
|
805
|
+
u++;
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if (g.type === l.LPAREN) {
|
|
809
|
+
if (u > 0) {
|
|
810
|
+
u--;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
for (let f = c - 1; f >= 0; f--)
|
|
814
|
+
if (e[f].type !== l.WHITESPACE) {
|
|
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;
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return "";
|
|
828
|
+
};
|
|
829
|
+
if ((r == null ? void 0 : r.type) === l.COLON) {
|
|
830
|
+
let a = "";
|
|
831
|
+
const u = e.indexOf(r);
|
|
832
|
+
for (let c = u - 1; c >= 0; c--) {
|
|
833
|
+
if (e[c].type === l.FIELD_NAME) {
|
|
834
|
+
a = e[c].value;
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
if (e[c].type !== l.WHITESPACE) break;
|
|
838
|
+
}
|
|
839
|
+
if (!a && t === r.start)
|
|
840
|
+
return { type: "FIELD_NAME", partial: "", token: r };
|
|
841
|
+
if (t === r.end) {
|
|
842
|
+
for (let c = u + 1; c < e.length; c++)
|
|
843
|
+
if (e[c].type !== l.WHITESPACE) {
|
|
844
|
+
if (e[c].type === l.VALUE || e[c].type === l.QUOTED_VALUE || e[c].type === l.WILDCARD || e[c].type === l.RANGE)
|
|
845
|
+
return { type: "FIELD_VALUE", partial: e[c].type === l.QUOTED_VALUE ? e[c].value.slice(1, e[c].value.endsWith('"') || e[c].value.endsWith("'") ? -1 : void 0) : e[c].value, fieldName: a, token: e[c] };
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return { type: "FIELD_VALUE", partial: "", fieldName: a, token: void 0 };
|
|
850
|
+
}
|
|
851
|
+
if ((r == null ? void 0 : r.type) === l.SAVED_SEARCH)
|
|
852
|
+
return {
|
|
853
|
+
type: "SAVED_SEARCH",
|
|
854
|
+
partial: r.value.slice(1),
|
|
855
|
+
// remove #
|
|
856
|
+
token: r
|
|
857
|
+
};
|
|
858
|
+
if ((r == null ? void 0 : r.type) === l.HISTORY_REF)
|
|
859
|
+
return {
|
|
860
|
+
type: "HISTORY_REF",
|
|
861
|
+
partial: r.value.slice(1),
|
|
862
|
+
// remove !
|
|
863
|
+
token: r
|
|
864
|
+
};
|
|
865
|
+
if ((r == null ? void 0 : r.type) === l.RANGE) {
|
|
866
|
+
const a = e.indexOf(r);
|
|
867
|
+
let u = "";
|
|
868
|
+
for (let c = a - 1; c >= 0; c--) {
|
|
869
|
+
if (e[c].type === l.FIELD_NAME) {
|
|
870
|
+
u = e[c].value;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
if (!(e[c].type === l.WHITESPACE || e[c].type === l.COLON))
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
return { type: "RANGE", partial: "", fieldName: u, token: r };
|
|
877
|
+
}
|
|
878
|
+
if ((s == null ? void 0 : s.type) === l.COLON || (s == null ? void 0 : s.type) === l.COMPARISON_OP) {
|
|
879
|
+
const a = e.indexOf(s);
|
|
880
|
+
let u = "";
|
|
881
|
+
for (let c = a - 1; c >= 0; c--) {
|
|
882
|
+
if (e[c].type === l.FIELD_NAME) {
|
|
883
|
+
u = e[c].value;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
if (!(e[c].type === l.WHITESPACE || e[c].type === l.COLON || e[c].type === l.COMPARISON_OP))
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
return r && (r.type === l.VALUE || r.type === l.QUOTED_VALUE) ? { type: "FIELD_VALUE", partial: r.type === l.QUOTED_VALUE ? r.value.slice(1, r.value.endsWith('"') || r.value.endsWith("'") ? -1 : void 0) : r.value, fieldName: u, token: r } : { type: "FIELD_VALUE", partial: "", fieldName: u, token: s };
|
|
890
|
+
}
|
|
891
|
+
if ((r == null ? void 0 : r.type) === l.VALUE || (r == null ? void 0 : r.type) === l.QUOTED_VALUE) {
|
|
892
|
+
const a = e.indexOf(r);
|
|
893
|
+
for (let u = a - 1; u >= 0; u--)
|
|
894
|
+
if (e[u].type !== l.WHITESPACE) {
|
|
895
|
+
if (e[u].type === l.COLON || e[u].type === l.COMPARISON_OP) {
|
|
896
|
+
let c = "";
|
|
897
|
+
for (let f = u - 1; f >= 0; f--) {
|
|
898
|
+
if (e[f].type === l.FIELD_NAME) {
|
|
899
|
+
c = e[f].value;
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
if (!(e[f].type === l.WHITESPACE || e[f].type === l.COLON || e[f].type === l.COMPARISON_OP))
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
return { type: "FIELD_VALUE", partial: r.type === l.QUOTED_VALUE ? r.value.slice(1, r.value.endsWith('"') || r.value.endsWith("'") ? -1 : void 0) : r.value, fieldName: c, token: r };
|
|
906
|
+
}
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
if ((r == null ? void 0 : r.type) === l.QUOTED_VALUE)
|
|
911
|
+
return { type: "FIELD_NAME", partial: r.value, token: r };
|
|
912
|
+
if ((r == null ? void 0 : r.type) === l.FIELD_NAME || (r == null ? void 0 : r.type) === l.VALUE) {
|
|
913
|
+
const a = i(e.indexOf(r));
|
|
914
|
+
return a ? { type: "FIELD_VALUE", partial: r.value, fieldName: a, token: r } : {
|
|
915
|
+
type: "FIELD_NAME",
|
|
916
|
+
partial: r.value,
|
|
917
|
+
token: r
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
if ((s == null ? void 0 : s.type) === l.PREFIX_OP) {
|
|
921
|
+
const a = i(e.indexOf(s));
|
|
922
|
+
return a ? { type: "FIELD_VALUE", partial: "", fieldName: a, token: void 0 } : { type: "FIELD_NAME", partial: "", token: void 0 };
|
|
923
|
+
}
|
|
924
|
+
if (s && (s.type === l.AND || s.type === l.OR || s.type === l.NOT)) {
|
|
925
|
+
const a = i(e.indexOf(s));
|
|
926
|
+
return a ? { type: "FIELD_VALUE", partial: "", fieldName: a, token: void 0 } : { type: "FIELD_NAME", partial: "", token: void 0 };
|
|
927
|
+
}
|
|
928
|
+
if (e.length === 0 || e.every((a) => a.type === l.WHITESPACE))
|
|
929
|
+
return { type: "EMPTY", partial: "" };
|
|
930
|
+
if ((r == null ? void 0 : r.type) === l.LPAREN || (s == null ? void 0 : s.type) === l.LPAREN) {
|
|
931
|
+
const a = (r == null ? void 0 : r.type) === l.LPAREN ? r : s, u = i(e.indexOf(a));
|
|
932
|
+
return u ? { type: "FIELD_VALUE", partial: "", fieldName: u, token: void 0 } : { type: "FIELD_NAME", partial: "", token: void 0 };
|
|
933
|
+
}
|
|
934
|
+
if ((r == null ? void 0 : r.type) === l.TILDE || (r == null ? void 0 : r.type) === l.BOOST)
|
|
935
|
+
return { type: "OPERATOR", partial: "" };
|
|
936
|
+
if (s && (s.type === l.VALUE || s.type === l.QUOTED_VALUE || s.type === l.RPAREN || s.type === l.RANGE || s.type === l.TILDE || s.type === l.BOOST)) {
|
|
937
|
+
const a = i(e.indexOf(s));
|
|
938
|
+
return a ? { type: "FIELD_VALUE", partial: "", fieldName: a, token: void 0 } : { type: "OPERATOR", partial: "" };
|
|
939
|
+
}
|
|
940
|
+
return { type: "FIELD_NAME", partial: "", token: void 0 };
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const zr = {
|
|
944
|
+
fieldName: "#0550ae",
|
|
945
|
+
fieldValue: "#1a7f37",
|
|
946
|
+
operator: "#cf222e",
|
|
947
|
+
booleanOp: "#8250df",
|
|
948
|
+
quoted: "#0a3069",
|
|
949
|
+
paren: "#656d76",
|
|
950
|
+
savedSearch: "#bf8700",
|
|
951
|
+
historyRef: "#6639ba",
|
|
952
|
+
wildcard: "#953800",
|
|
953
|
+
error: "#cf222e",
|
|
954
|
+
background: "#ffffff",
|
|
955
|
+
text: "#1f2328",
|
|
956
|
+
placeholder: "#656d76",
|
|
957
|
+
cursor: "#1f2328",
|
|
958
|
+
dropdownSelected: "#0969da",
|
|
959
|
+
dropdownHover: "#f6f8fa",
|
|
960
|
+
regexDelimiter: "#cf222e",
|
|
961
|
+
regexCharClass: "#0550ae",
|
|
962
|
+
regexGroup: "#656d76",
|
|
963
|
+
regexEscape: "#953800",
|
|
964
|
+
regexQuantifier: "#8250df",
|
|
965
|
+
regexAnchor: "#cf222e",
|
|
966
|
+
regexAlternation: "#8250df",
|
|
967
|
+
regexText: "#0a3069",
|
|
968
|
+
matchedParenBg: "#fff3cd",
|
|
969
|
+
warning: "#d4a72c"
|
|
970
|
+
}, Bn = {
|
|
971
|
+
fieldName: "#79c0ff",
|
|
972
|
+
fieldValue: "#7ee787",
|
|
973
|
+
operator: "#ff7b72",
|
|
974
|
+
booleanOp: "#d2a8ff",
|
|
975
|
+
quoted: "#a5d6ff",
|
|
976
|
+
paren: "#8b949e",
|
|
977
|
+
savedSearch: "#e3b341",
|
|
978
|
+
historyRef: "#bc8cff",
|
|
979
|
+
wildcard: "#ffa657",
|
|
980
|
+
error: "#f85149",
|
|
981
|
+
background: "#0d1117",
|
|
982
|
+
text: "#c9d1d9",
|
|
983
|
+
placeholder: "#484f58",
|
|
984
|
+
cursor: "#c9d1d9",
|
|
985
|
+
dropdownSelected: "#1f6feb",
|
|
986
|
+
dropdownHover: "#161b22",
|
|
987
|
+
regexDelimiter: "#ff7b72",
|
|
988
|
+
regexCharClass: "#79c0ff",
|
|
989
|
+
regexGroup: "#8b949e",
|
|
990
|
+
regexEscape: "#ffa657",
|
|
991
|
+
regexQuantifier: "#d2a8ff",
|
|
992
|
+
regexAnchor: "#ff7b72",
|
|
993
|
+
regexAlternation: "#d2a8ff",
|
|
994
|
+
regexText: "#a5d6ff",
|
|
995
|
+
matchedParenBg: "#3d3222",
|
|
996
|
+
warning: "#e3b341"
|
|
997
|
+
}, Er = {
|
|
998
|
+
fontFamily: "'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace",
|
|
999
|
+
fontSize: "14px",
|
|
1000
|
+
inputMinHeight: "40px",
|
|
1001
|
+
inputPadding: "8px 12px",
|
|
1002
|
+
inputBorderWidth: "2px",
|
|
1003
|
+
inputBorderColor: "#d0d7de",
|
|
1004
|
+
inputBorderRadius: "8px",
|
|
1005
|
+
inputFocusBorderColor: "#0969da",
|
|
1006
|
+
inputFocusShadow: "0 0 0 3px rgba(9, 105, 218, 0.3)",
|
|
1007
|
+
dropdownBorderColor: "#d0d7de",
|
|
1008
|
+
dropdownBorderRadius: "8px",
|
|
1009
|
+
dropdownShadow: "0 8px 24px rgba(0, 0, 0, 0.12)",
|
|
1010
|
+
dropdownMaxHeight: "300px",
|
|
1011
|
+
dropdownMinWidth: "200px",
|
|
1012
|
+
dropdownMaxWidth: "400px",
|
|
1013
|
+
dropdownZIndex: 99999,
|
|
1014
|
+
dropdownItemPadding: "6px 12px",
|
|
1015
|
+
dropdownItemFontSize: "13px",
|
|
1016
|
+
typeBadgeBg: "#eef1f5",
|
|
1017
|
+
typeBadgeSelectedBg: "rgba(255,255,255,0.2)",
|
|
1018
|
+
typeBadgeColor: "#656d76",
|
|
1019
|
+
typeBadgeSelectedColor: "#ffffff"
|
|
1020
|
+
}, Hn = {
|
|
1021
|
+
...Er,
|
|
1022
|
+
inputBorderColor: "#30363d",
|
|
1023
|
+
inputFocusBorderColor: "#1f6feb",
|
|
1024
|
+
inputFocusShadow: "0 0 0 3px rgba(31, 111, 235, 0.3)",
|
|
1025
|
+
dropdownBorderColor: "#30363d",
|
|
1026
|
+
dropdownShadow: "0 8px 24px rgba(0, 0, 0, 0.4)",
|
|
1027
|
+
typeBadgeBg: "#21262d",
|
|
1028
|
+
typeBadgeColor: "#8b949e"
|
|
1029
|
+
}, qr = ["AND", "OR", "NOT"], Gr = 200, Gt = 10;
|
|
1030
|
+
function nr(n) {
|
|
1031
|
+
return n.replace(/\r\n/g, `
|
|
1032
|
+
`).replace(/\r/g, `
|
|
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
|
+
}
|
|
1035
|
+
const sr = { "(": ")", "[": "]", '"': '"', "'": "'" };
|
|
1036
|
+
function Yr(n, e, t, r, s) {
|
|
1037
|
+
const i = n.slice(0, e), a = n.slice(e, t), u = n.slice(t);
|
|
1038
|
+
return {
|
|
1039
|
+
newValue: i + r + a + s + u,
|
|
1040
|
+
newCursorPos: t + 2,
|
|
1041
|
+
newSelStart: e + 1,
|
|
1042
|
+
// after opening char
|
|
1043
|
+
newSelEnd: t + 1
|
|
1044
|
+
// before closing char
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
function Kr(n) {
|
|
1048
|
+
if (!n.textContent)
|
|
1049
|
+
return "";
|
|
1050
|
+
const e = [];
|
|
1051
|
+
function t(r) {
|
|
1052
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
1053
|
+
e.push(r.textContent || "");
|
|
1054
|
+
else if (r.nodeName === "BR")
|
|
1055
|
+
e.push(`
|
|
1056
|
+
`);
|
|
1057
|
+
else
|
|
1058
|
+
for (let s = 0; s < r.childNodes.length; s++)
|
|
1059
|
+
t(r.childNodes[s]);
|
|
1060
|
+
}
|
|
1061
|
+
return t(n), e.join("");
|
|
1062
|
+
}
|
|
1063
|
+
function ar(n, e, t) {
|
|
1064
|
+
let r = -1, s = -1;
|
|
1065
|
+
for (let i = 0; i < n.length; i++) {
|
|
1066
|
+
const a = n[i];
|
|
1067
|
+
e >= a.start && e <= a.end && (r = i), s === -1 && t >= a.start && t <= a.end && (s = i);
|
|
1068
|
+
}
|
|
1069
|
+
return [r, s];
|
|
1070
|
+
}
|
|
1071
|
+
function Qr(n, e, t) {
|
|
1072
|
+
if (n) {
|
|
1073
|
+
let r = n.end;
|
|
1074
|
+
if (n.type === l.FIELD_NAME && t) {
|
|
1075
|
+
const s = t.indexOf(n);
|
|
1076
|
+
if (s >= 0) {
|
|
1077
|
+
for (let i = s + 1; i < t.length; i++)
|
|
1078
|
+
if (t[i].type !== l.WHITESPACE) {
|
|
1079
|
+
t[i].type === l.COLON && (r = t[i].end);
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return { start: n.start, end: r };
|
|
1085
|
+
}
|
|
1086
|
+
return { start: e, end: e };
|
|
1087
|
+
}
|
|
1088
|
+
class ir {
|
|
1089
|
+
constructor(e, t = [], r = [], s = Gt, i = {}) {
|
|
1090
|
+
q(this, "fields");
|
|
1091
|
+
q(this, "fieldMap");
|
|
1092
|
+
q(this, "savedSearches");
|
|
1093
|
+
q(this, "searchHistory");
|
|
1094
|
+
q(this, "maxSuggestions");
|
|
1095
|
+
q(this, "options");
|
|
1096
|
+
this.fields = e, this.fieldMap = new Map(e.map((a) => [a.name, a]));
|
|
1097
|
+
for (const a of e)
|
|
1098
|
+
if (a.aliases)
|
|
1099
|
+
for (const u of a.aliases)
|
|
1100
|
+
this.fieldMap.set(u, a);
|
|
1101
|
+
this.savedSearches = t, this.searchHistory = r, this.maxSuggestions = s, this.options = {
|
|
1102
|
+
showSavedSearchHint: i.showSavedSearchHint ?? !1,
|
|
1103
|
+
showHistoryHint: i.showHistoryHint ?? !1
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
/** Resolve a field name (or alias) to its FieldConfig. */
|
|
1107
|
+
resolveField(e) {
|
|
1108
|
+
return this.fieldMap.get(e);
|
|
1109
|
+
}
|
|
1110
|
+
updateSavedSearches(e) {
|
|
1111
|
+
this.savedSearches = e;
|
|
1112
|
+
}
|
|
1113
|
+
updateSearchHistory(e) {
|
|
1114
|
+
this.searchHistory = e;
|
|
1115
|
+
}
|
|
1116
|
+
getSuggestions(e, t) {
|
|
1117
|
+
const r = We.getCursorContext(e, t), s = Qr(r.token, t, e);
|
|
1118
|
+
switch (r.type) {
|
|
1119
|
+
case "FIELD_NAME":
|
|
1120
|
+
case "EMPTY": {
|
|
1121
|
+
const i = this.getFieldSuggestions(r.partial, s.start, s.end), a = !r.partial && i.length > 0 ? this.getSpecialHints(s.start, s.end) : [];
|
|
1122
|
+
return {
|
|
1123
|
+
suggestions: this.sortByPriority([...i, ...a]),
|
|
1124
|
+
showDatePicker: !1,
|
|
1125
|
+
context: r
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
case "FIELD_VALUE": {
|
|
1129
|
+
const i = r.fieldName ? this.resolveField(r.fieldName) : void 0;
|
|
1130
|
+
return (i == null ? void 0 : i.type) === "date" ? {
|
|
1131
|
+
suggestions: [],
|
|
1132
|
+
showDatePicker: !0,
|
|
1133
|
+
dateFieldName: i.name,
|
|
1134
|
+
context: r
|
|
1135
|
+
} : {
|
|
1136
|
+
suggestions: this.getValueSuggestions(i, r.partial, s.start, s.end),
|
|
1137
|
+
showDatePicker: !1,
|
|
1138
|
+
context: r
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
case "OPERATOR": {
|
|
1142
|
+
const i = this.getOperatorSuggestions(r.partial, s.start, s.end), a = this.getFieldSuggestions("", s.start, s.end), u = this.getSpecialHints(s.start, s.end);
|
|
1143
|
+
return {
|
|
1144
|
+
suggestions: this.sortByPriority([...i, ...a, ...u]),
|
|
1145
|
+
showDatePicker: !1,
|
|
1146
|
+
context: r
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
case "SAVED_SEARCH":
|
|
1150
|
+
return {
|
|
1151
|
+
suggestions: this.getSavedSearchSuggestions(r.partial, s.start, s.end),
|
|
1152
|
+
showDatePicker: !1,
|
|
1153
|
+
context: r
|
|
1154
|
+
};
|
|
1155
|
+
case "HISTORY_REF":
|
|
1156
|
+
return {
|
|
1157
|
+
suggestions: this.getHistorySuggestions(r.partial, s.start, s.end),
|
|
1158
|
+
showDatePicker: !1,
|
|
1159
|
+
context: r
|
|
1160
|
+
};
|
|
1161
|
+
case "RANGE": {
|
|
1162
|
+
const i = r.fieldName ? this.resolveField(r.fieldName) : void 0;
|
|
1163
|
+
return (i == null ? void 0 : i.type) === "date" ? { suggestions: [], showDatePicker: !0, dateFieldName: i.name, context: r } : { suggestions: [], showDatePicker: !1, context: r };
|
|
1164
|
+
}
|
|
1165
|
+
default:
|
|
1166
|
+
return { suggestions: [], showDatePicker: !1, context: r };
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
getFieldSuggestions(e, t, r) {
|
|
1170
|
+
const s = e.toLowerCase();
|
|
1171
|
+
return this.fields.map((a) => {
|
|
1172
|
+
const u = a.name.toLowerCase(), c = (a.label || "").toLowerCase(), g = (a.aliases || []).map((m) => m.toLowerCase());
|
|
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 };
|
|
1175
|
+
}).filter((a) => a.score > 0).sort((a, u) => u.score - a.score).slice(0, this.maxSuggestions).map((a) => ({
|
|
1176
|
+
text: a.field.name + ":",
|
|
1177
|
+
label: a.field.label || a.field.name,
|
|
1178
|
+
description: a.field.description,
|
|
1179
|
+
type: a.field.type,
|
|
1180
|
+
replaceStart: t,
|
|
1181
|
+
replaceEnd: r,
|
|
1182
|
+
matchPartial: e,
|
|
1183
|
+
priority: 10
|
|
1184
|
+
}));
|
|
1185
|
+
}
|
|
1186
|
+
getValueSuggestions(e, t, r, s) {
|
|
1187
|
+
if (!e) return [];
|
|
1188
|
+
if (e.type === "boolean")
|
|
1189
|
+
return ["true", "false"].filter((i) => i.startsWith(t.toLowerCase())).map((i) => ({
|
|
1190
|
+
text: i,
|
|
1191
|
+
label: i,
|
|
1192
|
+
type: "boolean",
|
|
1193
|
+
replaceStart: r,
|
|
1194
|
+
replaceEnd: s,
|
|
1195
|
+
matchPartial: t
|
|
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
|
+
if (e.placeholder !== !1) {
|
|
1213
|
+
const i = {
|
|
1214
|
+
number: "Enter a number",
|
|
1215
|
+
ip: "Enter an IP address"
|
|
1216
|
+
}, a = e.placeholder || i[e.type];
|
|
1217
|
+
if (a)
|
|
1218
|
+
return [{
|
|
1219
|
+
text: "",
|
|
1220
|
+
label: a,
|
|
1221
|
+
type: "hint",
|
|
1222
|
+
replaceStart: r,
|
|
1223
|
+
replaceEnd: s
|
|
1224
|
+
}];
|
|
1225
|
+
}
|
|
1226
|
+
return [];
|
|
1227
|
+
}
|
|
1228
|
+
getOperatorSuggestions(e, t, r) {
|
|
1229
|
+
const s = e.toLowerCase();
|
|
1230
|
+
return qr.filter((i) => i.toLowerCase().startsWith(s)).map((i) => ({
|
|
1231
|
+
text: i + " ",
|
|
1232
|
+
label: i,
|
|
1233
|
+
description: i === "AND" ? "Both conditions must match" : i === "OR" ? "Either condition must match" : "Negate the following condition",
|
|
1234
|
+
type: "operator",
|
|
1235
|
+
replaceStart: t,
|
|
1236
|
+
replaceEnd: r,
|
|
1237
|
+
matchPartial: e,
|
|
1238
|
+
priority: 30
|
|
1239
|
+
}));
|
|
1240
|
+
}
|
|
1241
|
+
sortByPriority(e) {
|
|
1242
|
+
return e.sort((t, r) => (r.priority ?? 0) - (t.priority ?? 0));
|
|
1243
|
+
}
|
|
1244
|
+
getSpecialHints(e, t) {
|
|
1245
|
+
const r = [];
|
|
1246
|
+
return this.options.showSavedSearchHint && this.savedSearches.length > 0 && r.push({
|
|
1247
|
+
text: "#",
|
|
1248
|
+
label: "#saved-search",
|
|
1249
|
+
description: "Type # to use a saved search",
|
|
1250
|
+
type: "hint",
|
|
1251
|
+
replaceStart: e,
|
|
1252
|
+
replaceEnd: t,
|
|
1253
|
+
priority: 20
|
|
1254
|
+
}), this.options.showHistoryHint && this.searchHistory.length > 0 && r.push({
|
|
1255
|
+
text: "!",
|
|
1256
|
+
label: "!history",
|
|
1257
|
+
description: "Type ! to search history",
|
|
1258
|
+
type: "hint",
|
|
1259
|
+
replaceStart: e,
|
|
1260
|
+
replaceEnd: t,
|
|
1261
|
+
priority: 20
|
|
1262
|
+
}), r;
|
|
1263
|
+
}
|
|
1264
|
+
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,
|
|
1270
|
+
type: "savedSearch",
|
|
1271
|
+
replaceStart: t,
|
|
1272
|
+
replaceEnd: r,
|
|
1273
|
+
matchPartial: e,
|
|
1274
|
+
sourceData: i
|
|
1275
|
+
}));
|
|
1276
|
+
}
|
|
1277
|
+
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
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
function _t(n) {
|
|
1300
|
+
if (n === "") return null;
|
|
1301
|
+
const e = Number(n);
|
|
1302
|
+
return isNaN(e) ? `"${n}" is not a valid number` : null;
|
|
1303
|
+
}
|
|
1304
|
+
const Xr = [
|
|
1305
|
+
/^\d{4}-\d{2}-\d{2}$/,
|
|
1306
|
+
// 2024-01-15
|
|
1307
|
+
/^\d{4}\/\d{2}\/\d{2}$/,
|
|
1308
|
+
// 2024/01/15
|
|
1309
|
+
/^\d{2}\/\d{2}\/\d{4}$/,
|
|
1310
|
+
// 01/15/2024
|
|
1311
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
|
|
1312
|
+
// ISO 8601
|
|
1313
|
+
/^now$/i,
|
|
1314
|
+
// Relative
|
|
1315
|
+
/^now[+-]\d+[dhms]$/i
|
|
1316
|
+
// now-7d, now+1h
|
|
1317
|
+
];
|
|
1318
|
+
function jr(n) {
|
|
1319
|
+
for (const t of Xr)
|
|
1320
|
+
if (t.test(n)) return !0;
|
|
1321
|
+
const e = Date.parse(n);
|
|
1322
|
+
return !isNaN(e);
|
|
1323
|
+
}
|
|
1324
|
+
function Bt(n) {
|
|
1325
|
+
const e = n.getFullYear(), t = String(n.getMonth() + 1).padStart(2, "0"), r = String(n.getDate()).padStart(2, "0");
|
|
1326
|
+
return `${e}-${t}-${r}`;
|
|
1327
|
+
}
|
|
1328
|
+
function Ht(n) {
|
|
1329
|
+
if (/^now$/i.test(n)) return /* @__PURE__ */ new Date();
|
|
1330
|
+
const e = n.match(/^now([+-])(\d+)([dhms])$/i);
|
|
1331
|
+
if (e) {
|
|
1332
|
+
const s = /* @__PURE__ */ new Date(), i = e[1] === "+" ? 1 : -1, a = parseInt(e[2], 10);
|
|
1333
|
+
switch (e[3].toLowerCase()) {
|
|
1334
|
+
case "d":
|
|
1335
|
+
s.setDate(s.getDate() + i * a);
|
|
1336
|
+
break;
|
|
1337
|
+
case "h":
|
|
1338
|
+
s.setHours(s.getHours() + i * a);
|
|
1339
|
+
break;
|
|
1340
|
+
case "m":
|
|
1341
|
+
s.setMinutes(s.getMinutes() + i * a);
|
|
1342
|
+
break;
|
|
1343
|
+
case "s":
|
|
1344
|
+
s.setSeconds(s.getSeconds() + i * a);
|
|
1345
|
+
break;
|
|
1346
|
+
}
|
|
1347
|
+
return s;
|
|
1348
|
+
}
|
|
1349
|
+
const t = n.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);
|
|
1350
|
+
if (t)
|
|
1351
|
+
return new Date(parseInt(t[1], 10), parseInt(t[2], 10) - 1, parseInt(t[3], 10));
|
|
1352
|
+
const r = new Date(n);
|
|
1353
|
+
return isNaN(r.getTime()) ? null : r;
|
|
1354
|
+
}
|
|
1355
|
+
function Zr(n, e) {
|
|
1356
|
+
return new Date(n, e + 1, 0).getDate();
|
|
1357
|
+
}
|
|
1358
|
+
function Jr(n, e) {
|
|
1359
|
+
return new Date(n, e, 1).getDay();
|
|
1360
|
+
}
|
|
1361
|
+
function it(n, e) {
|
|
1362
|
+
return n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate();
|
|
1363
|
+
}
|
|
1364
|
+
function or(n, e, t) {
|
|
1365
|
+
if (!e || !t) return !1;
|
|
1366
|
+
const r = n.getTime(), s = e.getTime(), i = t.getTime();
|
|
1367
|
+
return r >= Math.min(s, i) && r <= Math.max(s, i);
|
|
1368
|
+
}
|
|
1369
|
+
const en = [
|
|
1370
|
+
"January",
|
|
1371
|
+
"February",
|
|
1372
|
+
"March",
|
|
1373
|
+
"April",
|
|
1374
|
+
"May",
|
|
1375
|
+
"June",
|
|
1376
|
+
"July",
|
|
1377
|
+
"August",
|
|
1378
|
+
"September",
|
|
1379
|
+
"October",
|
|
1380
|
+
"November",
|
|
1381
|
+
"December"
|
|
1382
|
+
];
|
|
1383
|
+
function tn(n) {
|
|
1384
|
+
return en[n];
|
|
1385
|
+
}
|
|
1386
|
+
function Ut(n) {
|
|
1387
|
+
if (n === "") return null;
|
|
1388
|
+
const e = n.match(/^[\[{](.+)\s+TO\s+(.+)[\]}]$/i);
|
|
1389
|
+
if (e) {
|
|
1390
|
+
const t = Wt(e[1].trim());
|
|
1391
|
+
if (t) return `Range start: ${t}`;
|
|
1392
|
+
const r = Wt(e[2].trim());
|
|
1393
|
+
return r ? `Range end: ${r}` : null;
|
|
1394
|
+
}
|
|
1395
|
+
return Wt(n);
|
|
1396
|
+
}
|
|
1397
|
+
function Wt(n) {
|
|
1398
|
+
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
|
+
}
|
|
1400
|
+
function St(n) {
|
|
1401
|
+
return n == null ? null : typeof n == "string" ? { message: n, severity: "error" } : n;
|
|
1402
|
+
}
|
|
1403
|
+
class lr {
|
|
1404
|
+
constructor(e) {
|
|
1405
|
+
q(this, "fields");
|
|
1406
|
+
this.fields = new Map(e.map((t) => [t.name, t]));
|
|
1407
|
+
for (const t of e)
|
|
1408
|
+
if (t.aliases)
|
|
1409
|
+
for (const r of t.aliases)
|
|
1410
|
+
this.fields.set(r, t);
|
|
1411
|
+
}
|
|
1412
|
+
validate(e, t) {
|
|
1413
|
+
if (!e) return [];
|
|
1414
|
+
const r = [];
|
|
1415
|
+
return this.walkNode(e, r, t), this.checkAmbiguousPrecedence(e, r), r;
|
|
1416
|
+
}
|
|
1417
|
+
walkNode(e, t, r) {
|
|
1418
|
+
switch (e.type) {
|
|
1419
|
+
case "BareTerm": {
|
|
1420
|
+
if (e.fuzzy !== void 0 && e.fuzzy > 2 && t.push({
|
|
1421
|
+
message: `Fuzzy edit distance must be 0, 1, or 2 (got ${e.fuzzy})`,
|
|
1422
|
+
start: e.start,
|
|
1423
|
+
end: e.end
|
|
1424
|
+
}), e.proximity !== void 0 && e.proximity < 0 && t.push({
|
|
1425
|
+
message: `Proximity value must be non-negative (got ${e.proximity})`,
|
|
1426
|
+
start: e.start,
|
|
1427
|
+
end: e.end
|
|
1428
|
+
}), e.boost !== void 0 && e.boost <= 0 && t.push({
|
|
1429
|
+
message: `Boost value must be positive (got ${e.boost})`,
|
|
1430
|
+
start: e.start,
|
|
1431
|
+
end: e.end
|
|
1432
|
+
}), r && e.value !== "") {
|
|
1433
|
+
const s = St(r({
|
|
1434
|
+
value: e.value,
|
|
1435
|
+
position: "bare_term",
|
|
1436
|
+
quoted: e.quoted
|
|
1437
|
+
}));
|
|
1438
|
+
s && t.push({
|
|
1439
|
+
message: s.message,
|
|
1440
|
+
start: e.start,
|
|
1441
|
+
end: e.end,
|
|
1442
|
+
severity: s.severity
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
case "Regex":
|
|
1448
|
+
break;
|
|
1449
|
+
case "Range": {
|
|
1450
|
+
if (this.validateEmptyRangeBounds(e, t), e.field && e.field !== "*") {
|
|
1451
|
+
const s = this.fields.get(e.field);
|
|
1452
|
+
s ? this.validateRangeBounds(s, e, t, r) : t.push({
|
|
1453
|
+
message: `Unknown field: "${e.field}"`,
|
|
1454
|
+
start: e.start,
|
|
1455
|
+
end: e.start + e.field.length,
|
|
1456
|
+
field: e.field
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
case "FieldValue": {
|
|
1462
|
+
if (e.field === "*") return;
|
|
1463
|
+
const s = this.fields.get(e.field);
|
|
1464
|
+
if (!s) {
|
|
1465
|
+
t.push({
|
|
1466
|
+
message: `Unknown field: "${e.field}"`,
|
|
1467
|
+
start: e.start,
|
|
1468
|
+
end: e.start + e.field.length,
|
|
1469
|
+
field: e.field
|
|
1470
|
+
});
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
if (e.value === "") {
|
|
1474
|
+
const a = e.operator === ":" ? ":" : e.operator;
|
|
1475
|
+
t.push({
|
|
1476
|
+
message: `Missing value after "${e.field}${a}"`,
|
|
1477
|
+
start: e.start,
|
|
1478
|
+
end: e.end,
|
|
1479
|
+
field: e.field
|
|
1480
|
+
});
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
e.fuzzy !== void 0 && e.fuzzy > 2 && t.push({
|
|
1484
|
+
message: `Fuzzy edit distance must be 0, 1, or 2 (got ${e.fuzzy})`,
|
|
1485
|
+
start: e.start,
|
|
1486
|
+
end: e.end,
|
|
1487
|
+
field: e.field
|
|
1488
|
+
}), e.boost !== void 0 && e.boost <= 0 && t.push({
|
|
1489
|
+
message: `Boost value must be positive (got ${e.boost})`,
|
|
1490
|
+
start: e.start,
|
|
1491
|
+
end: e.end,
|
|
1492
|
+
field: e.field
|
|
1493
|
+
});
|
|
1494
|
+
let i = null;
|
|
1495
|
+
switch (s.type) {
|
|
1496
|
+
case "number":
|
|
1497
|
+
i = _t(e.value);
|
|
1498
|
+
break;
|
|
1499
|
+
case "date":
|
|
1500
|
+
i = Ut(e.value);
|
|
1501
|
+
break;
|
|
1502
|
+
case "boolean":
|
|
1503
|
+
e.value !== "true" && e.value !== "false" && (i = `Expected "true" or "false", got "${e.value}"`);
|
|
1504
|
+
break;
|
|
1505
|
+
case "ip":
|
|
1506
|
+
!/^\d{1,3}(\.\d{1,3}){3}(\/\d{1,2})?$/.test(e.value) && !e.value.includes("*") && (i = `"${e.value}" is not a valid IP address`);
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
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({
|
|
1511
|
+
value: e.value,
|
|
1512
|
+
position: "field_value",
|
|
1513
|
+
fieldName: s.name,
|
|
1514
|
+
fieldConfig: s,
|
|
1515
|
+
quoted: e.quoted,
|
|
1516
|
+
operator: e.operator !== ":" ? e.operator : void 0
|
|
1517
|
+
}));
|
|
1518
|
+
if (a) {
|
|
1519
|
+
const u = e.end - e.value.length;
|
|
1520
|
+
t.push({
|
|
1521
|
+
message: a.message,
|
|
1522
|
+
start: u,
|
|
1523
|
+
end: e.end,
|
|
1524
|
+
field: e.field,
|
|
1525
|
+
severity: a.severity
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
if (i) {
|
|
1530
|
+
const a = e.end - e.value.length;
|
|
1531
|
+
t.push({
|
|
1532
|
+
message: i,
|
|
1533
|
+
start: a,
|
|
1534
|
+
end: e.end,
|
|
1535
|
+
field: e.field
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
case "FieldGroup": {
|
|
1541
|
+
if (e.field === "*")
|
|
1542
|
+
this.walkNode(e.expression, t, r);
|
|
1543
|
+
else {
|
|
1544
|
+
const s = this.fields.get(e.field);
|
|
1545
|
+
s ? this.walkFieldGroup(e.expression, s, t, r) : t.push({
|
|
1546
|
+
message: `Unknown field: "${e.field}"`,
|
|
1547
|
+
start: e.start,
|
|
1548
|
+
end: e.start + e.field.length,
|
|
1549
|
+
field: e.field
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
e.boost !== void 0 && e.boost <= 0 && t.push({
|
|
1553
|
+
message: `Boost value must be positive (got ${e.boost})`,
|
|
1554
|
+
start: e.start,
|
|
1555
|
+
end: e.end
|
|
1556
|
+
});
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
case "BooleanExpr":
|
|
1560
|
+
this.walkNode(e.left, t, r), this.walkNode(e.right, t, r);
|
|
1561
|
+
break;
|
|
1562
|
+
case "Group":
|
|
1563
|
+
this.walkNode(e.expression, t, r), e.boost !== void 0 && e.boost <= 0 && t.push({
|
|
1564
|
+
message: `Boost value must be positive (got ${e.boost})`,
|
|
1565
|
+
start: e.start,
|
|
1566
|
+
end: e.end
|
|
1567
|
+
});
|
|
1568
|
+
break;
|
|
1569
|
+
case "Not":
|
|
1570
|
+
this.walkNode(e.expression, t, r);
|
|
1571
|
+
break;
|
|
1572
|
+
case "Error":
|
|
1573
|
+
t.push({
|
|
1574
|
+
message: e.message,
|
|
1575
|
+
start: e.start,
|
|
1576
|
+
end: e.end
|
|
1577
|
+
});
|
|
1578
|
+
break;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
/** Walk inside a FieldGroup, validating bare terms / field values against the group's field config. */
|
|
1582
|
+
walkFieldGroup(e, t, r, s) {
|
|
1583
|
+
switch (e.type) {
|
|
1584
|
+
case "BareTerm": {
|
|
1585
|
+
if (e.value === "") return;
|
|
1586
|
+
this.validateFieldValue(t, e.value, e.quoted, ":", e.start, e.end, r, s);
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
case "FieldValue": {
|
|
1590
|
+
this.walkNode(e, r, s);
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
case "Range": {
|
|
1594
|
+
this.validateRangeBounds(t, e, r, s);
|
|
1595
|
+
break;
|
|
1596
|
+
}
|
|
1597
|
+
case "BooleanExpr":
|
|
1598
|
+
this.walkFieldGroup(e.left, t, r, s), this.walkFieldGroup(e.right, t, r, s);
|
|
1599
|
+
break;
|
|
1600
|
+
case "Group":
|
|
1601
|
+
this.walkFieldGroup(e.expression, t, r, s);
|
|
1602
|
+
break;
|
|
1603
|
+
case "Not":
|
|
1604
|
+
this.walkFieldGroup(e.expression, t, r, s);
|
|
1605
|
+
break;
|
|
1606
|
+
default:
|
|
1607
|
+
this.walkNode(e, r, s);
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
/** Validate a value against a field config (shared between FieldValue and FieldGroup terms). */
|
|
1612
|
+
validateFieldValue(e, t, r, s, i, a, u, c) {
|
|
1613
|
+
let g = null;
|
|
1614
|
+
switch (e.type) {
|
|
1615
|
+
case "number":
|
|
1616
|
+
g = _t(t);
|
|
1617
|
+
break;
|
|
1618
|
+
case "date":
|
|
1619
|
+
g = Ut(t);
|
|
1620
|
+
break;
|
|
1621
|
+
case "boolean":
|
|
1622
|
+
t !== "true" && t !== "false" && (g = `Expected "true" or "false", got "${t}"`);
|
|
1623
|
+
break;
|
|
1624
|
+
case "ip":
|
|
1625
|
+
!/^\d{1,3}(\.\d{1,3}){3}(\/\d{1,2})?$/.test(t) && !t.includes("*") && (g = `"${t}" is not a valid IP address`);
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
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({
|
|
1630
|
+
value: t,
|
|
1631
|
+
position: "field_group_term",
|
|
1632
|
+
fieldName: e.name,
|
|
1633
|
+
fieldConfig: e,
|
|
1634
|
+
quoted: r,
|
|
1635
|
+
operator: s !== ":" ? s : void 0
|
|
1636
|
+
}));
|
|
1637
|
+
f && u.push({
|
|
1638
|
+
message: f.message,
|
|
1639
|
+
start: i,
|
|
1640
|
+
end: a,
|
|
1641
|
+
field: e.name,
|
|
1642
|
+
severity: f.severity
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
g && u.push({
|
|
1646
|
+
message: g,
|
|
1647
|
+
start: i,
|
|
1648
|
+
end: a,
|
|
1649
|
+
field: e.name
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
/** Flag empty range bounds (e.g. `[TO]`, `[ TO ]`). */
|
|
1653
|
+
validateEmptyRangeBounds(e, t) {
|
|
1654
|
+
e.lower !== "*" && e.lower.trim() === "" && t.push({
|
|
1655
|
+
message: "Missing lower bound in range",
|
|
1656
|
+
start: e.start,
|
|
1657
|
+
end: e.start + 1,
|
|
1658
|
+
// highlight the opening bracket
|
|
1659
|
+
field: e.field
|
|
1660
|
+
}), e.upper !== "*" && e.upper.trim() === "" && t.push({
|
|
1661
|
+
message: "Missing upper bound in range",
|
|
1662
|
+
start: e.end - 1,
|
|
1663
|
+
// highlight the closing bracket
|
|
1664
|
+
end: e.end,
|
|
1665
|
+
field: e.field
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
/** Validate range bounds against a field config. */
|
|
1669
|
+
validateRangeBounds(e, t, r, s) {
|
|
1670
|
+
const i = [];
|
|
1671
|
+
t.lower !== "*" && t.lower.trim() !== "" && i.push({ value: t.lower, label: "Range start", start: t.lowerStart, end: t.lowerEnd, position: "range_start", inclusive: t.lowerInclusive }), t.upper !== "*" && t.upper.trim() !== "" && i.push({ value: t.upper, label: "Range end", start: t.upperStart, end: t.upperEnd, position: "range_end", inclusive: t.upperInclusive });
|
|
1672
|
+
for (const a of i) {
|
|
1673
|
+
let u = null;
|
|
1674
|
+
switch (e.type) {
|
|
1675
|
+
case "number":
|
|
1676
|
+
u = _t(a.value), u && (u = `${a.label}: ${u}`);
|
|
1677
|
+
break;
|
|
1678
|
+
case "date":
|
|
1679
|
+
u = Ut(a.value), u && (u = `${a.label}: ${u}`);
|
|
1680
|
+
break;
|
|
1681
|
+
case "boolean":
|
|
1682
|
+
u = "Range queries are not supported for boolean fields";
|
|
1683
|
+
break;
|
|
1684
|
+
}
|
|
1685
|
+
if (!u && s) {
|
|
1686
|
+
const c = St(s({
|
|
1687
|
+
value: a.value,
|
|
1688
|
+
position: a.position,
|
|
1689
|
+
fieldName: e.name,
|
|
1690
|
+
fieldConfig: e,
|
|
1691
|
+
quoted: !1,
|
|
1692
|
+
inclusive: a.inclusive
|
|
1693
|
+
}));
|
|
1694
|
+
c && r.push({
|
|
1695
|
+
message: c.message,
|
|
1696
|
+
start: a.start,
|
|
1697
|
+
end: a.end,
|
|
1698
|
+
field: e.name,
|
|
1699
|
+
severity: c.severity
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
u && r.push({
|
|
1703
|
+
message: u,
|
|
1704
|
+
start: a.start,
|
|
1705
|
+
end: a.end,
|
|
1706
|
+
field: e.name
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
/** Post-validation pass: detect mixed AND/OR without parentheses. */
|
|
1711
|
+
checkAmbiguousPrecedence(e, t) {
|
|
1712
|
+
const r = /* @__PURE__ */ new Set();
|
|
1713
|
+
this.findAndFlagAmbiguity(e, t, r);
|
|
1714
|
+
}
|
|
1715
|
+
findAndFlagAmbiguity(e, t, r) {
|
|
1716
|
+
if (e.type === "BooleanExpr" && !r.has(e)) {
|
|
1717
|
+
const s = /* @__PURE__ */ new Set(), i = [];
|
|
1718
|
+
this.collectBoolOps(e, s, i), s.size > 1 && (t.push({
|
|
1719
|
+
message: "Ambiguous precedence: mix of AND and OR without parentheses. Add parentheses to clarify.",
|
|
1720
|
+
start: e.start,
|
|
1721
|
+
end: e.end,
|
|
1722
|
+
severity: "warning"
|
|
1723
|
+
}), i.forEach((a) => r.add(a))), this.collectLeaves(e).forEach((a) => this.findAndFlagAmbiguity(a, t, r));
|
|
1724
|
+
} else e.type === "Group" || e.type === "FieldGroup" ? this.findAndFlagAmbiguity(e.expression, t, r) : e.type === "Not" ? this.findAndFlagAmbiguity(e.expression, t, r) : e.type === "BooleanExpr" && this.collectLeaves(e).forEach((s) => this.findAndFlagAmbiguity(s, t, r));
|
|
1725
|
+
}
|
|
1726
|
+
/** Collect all BooleanExpr operators at the same group level (stop at Group boundaries). */
|
|
1727
|
+
collectBoolOps(e, t, r) {
|
|
1728
|
+
e.type === "BooleanExpr" && (t.add(e.operator), r.push(e), this.collectBoolOps(e.left, t, r), this.collectBoolOps(e.right, t, r));
|
|
1729
|
+
}
|
|
1730
|
+
/** Collect non-BooleanExpr children from a BooleanExpr chain. */
|
|
1731
|
+
collectLeaves(e) {
|
|
1732
|
+
return e.type !== "BooleanExpr" ? [e] : [...this.collectLeaves(e.left), ...this.collectLeaves(e.right)];
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
function pt(n) {
|
|
1736
|
+
return { ...zr, ...n };
|
|
1737
|
+
}
|
|
1738
|
+
function dt(n) {
|
|
1739
|
+
return { ...Er, ...n };
|
|
1740
|
+
}
|
|
1741
|
+
function rn(n, e) {
|
|
1742
|
+
return {
|
|
1743
|
+
position: "relative",
|
|
1744
|
+
display: "inline-block",
|
|
1745
|
+
width: "100%",
|
|
1746
|
+
...e
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
function nn(n, e) {
|
|
1750
|
+
return {
|
|
1751
|
+
minHeight: e.inputMinHeight,
|
|
1752
|
+
padding: e.inputPadding,
|
|
1753
|
+
borderWidth: e.inputBorderWidth,
|
|
1754
|
+
borderStyle: "solid",
|
|
1755
|
+
borderColor: e.inputBorderColor,
|
|
1756
|
+
borderRadius: e.inputBorderRadius,
|
|
1757
|
+
outline: "none",
|
|
1758
|
+
fontSize: e.fontSize,
|
|
1759
|
+
fontFamily: e.fontFamily,
|
|
1760
|
+
lineHeight: "1.5",
|
|
1761
|
+
backgroundColor: n.background,
|
|
1762
|
+
color: n.text,
|
|
1763
|
+
caretColor: n.cursor,
|
|
1764
|
+
whiteSpace: "pre-wrap",
|
|
1765
|
+
wordWrap: "break-word",
|
|
1766
|
+
overflowWrap: "break-word",
|
|
1767
|
+
cursor: "text"
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
function sn(n) {
|
|
1771
|
+
return {
|
|
1772
|
+
borderColor: n.inputFocusBorderColor,
|
|
1773
|
+
boxShadow: n.inputFocusShadow
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
function an(n, e) {
|
|
1777
|
+
const t = e.inputPadding.split(/\s+/), r = t[0] || "8px", s = t.length >= 4 ? t[3] : t.length >= 2 ? t[1] : r;
|
|
1778
|
+
return {
|
|
1779
|
+
position: "absolute",
|
|
1780
|
+
top: r,
|
|
1781
|
+
left: s,
|
|
1782
|
+
color: n.placeholder,
|
|
1783
|
+
pointerEvents: "none",
|
|
1784
|
+
fontSize: e.fontSize,
|
|
1785
|
+
fontFamily: e.fontFamily,
|
|
1786
|
+
lineHeight: "1.5",
|
|
1787
|
+
userSelect: "none"
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
function vr(n, e) {
|
|
1791
|
+
return {
|
|
1792
|
+
position: "absolute",
|
|
1793
|
+
zIndex: e.dropdownZIndex,
|
|
1794
|
+
backgroundColor: n.background,
|
|
1795
|
+
border: `1px solid ${e.dropdownBorderColor}`,
|
|
1796
|
+
borderRadius: e.dropdownBorderRadius,
|
|
1797
|
+
boxShadow: e.dropdownShadow,
|
|
1798
|
+
maxHeight: e.dropdownMaxHeight,
|
|
1799
|
+
overflowY: "auto",
|
|
1800
|
+
minWidth: e.dropdownMinWidth,
|
|
1801
|
+
maxWidth: e.dropdownMaxWidth,
|
|
1802
|
+
padding: "4px 0"
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
function cr(n, e, t) {
|
|
1806
|
+
return {
|
|
1807
|
+
padding: t.dropdownItemPadding,
|
|
1808
|
+
cursor: "pointer",
|
|
1809
|
+
fontSize: t.dropdownItemFontSize,
|
|
1810
|
+
fontFamily: t.fontFamily,
|
|
1811
|
+
backgroundColor: n ? e.dropdownSelected : "transparent",
|
|
1812
|
+
color: n ? "#ffffff" : e.text,
|
|
1813
|
+
display: "flex",
|
|
1814
|
+
alignItems: "center",
|
|
1815
|
+
gap: "8px",
|
|
1816
|
+
lineHeight: "1.4"
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
function Be(n) {
|
|
1820
|
+
return {
|
|
1821
|
+
flex: 1,
|
|
1822
|
+
fontWeight: 500
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
function $t(n) {
|
|
1826
|
+
return {
|
|
1827
|
+
fontSize: "11px",
|
|
1828
|
+
opacity: 0.7,
|
|
1829
|
+
whiteSpace: "nowrap",
|
|
1830
|
+
overflow: "hidden",
|
|
1831
|
+
textOverflow: "ellipsis",
|
|
1832
|
+
maxWidth: "200px"
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
function ur(n, e) {
|
|
1836
|
+
return {
|
|
1837
|
+
fontSize: "10px",
|
|
1838
|
+
padding: "1px 4px",
|
|
1839
|
+
borderRadius: "3px",
|
|
1840
|
+
backgroundColor: n ? e.typeBadgeSelectedBg : e.typeBadgeBg,
|
|
1841
|
+
color: n ? e.typeBadgeSelectedColor : e.typeBadgeColor,
|
|
1842
|
+
flexShrink: 0
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
function on(n, e) {
|
|
1846
|
+
return {
|
|
1847
|
+
container: {
|
|
1848
|
+
padding: "12px",
|
|
1849
|
+
backgroundColor: n.background,
|
|
1850
|
+
minWidth: "280px",
|
|
1851
|
+
fontFamily: e.fontFamily
|
|
1852
|
+
},
|
|
1853
|
+
header: {
|
|
1854
|
+
display: "flex",
|
|
1855
|
+
justifyContent: "space-between",
|
|
1856
|
+
alignItems: "center",
|
|
1857
|
+
marginBottom: "8px"
|
|
1858
|
+
},
|
|
1859
|
+
navButton: {
|
|
1860
|
+
backgroundColor: "transparent",
|
|
1861
|
+
border: "none",
|
|
1862
|
+
cursor: "pointer",
|
|
1863
|
+
fontSize: "16px",
|
|
1864
|
+
padding: "4px 8px",
|
|
1865
|
+
color: n.text,
|
|
1866
|
+
borderRadius: "4px"
|
|
1867
|
+
},
|
|
1868
|
+
monthLabel: {
|
|
1869
|
+
fontWeight: 600,
|
|
1870
|
+
fontSize: e.fontSize,
|
|
1871
|
+
color: n.text
|
|
1872
|
+
},
|
|
1873
|
+
weekDays: {
|
|
1874
|
+
display: "grid",
|
|
1875
|
+
gridTemplateColumns: "repeat(7, 1fr)",
|
|
1876
|
+
gap: "2px",
|
|
1877
|
+
marginBottom: "4px"
|
|
1878
|
+
},
|
|
1879
|
+
weekDay: {
|
|
1880
|
+
textAlign: "center",
|
|
1881
|
+
fontSize: "11px",
|
|
1882
|
+
color: n.placeholder,
|
|
1883
|
+
padding: "4px",
|
|
1884
|
+
fontWeight: 600
|
|
1885
|
+
},
|
|
1886
|
+
days: {
|
|
1887
|
+
display: "grid",
|
|
1888
|
+
gridTemplateColumns: "repeat(7, 1fr)",
|
|
1889
|
+
gap: "2px"
|
|
1890
|
+
},
|
|
1891
|
+
day: {
|
|
1892
|
+
textAlign: "center",
|
|
1893
|
+
padding: "6px",
|
|
1894
|
+
cursor: "pointer",
|
|
1895
|
+
fontSize: e.dropdownItemFontSize,
|
|
1896
|
+
borderRadius: "4px",
|
|
1897
|
+
color: n.text,
|
|
1898
|
+
border: "none",
|
|
1899
|
+
backgroundColor: "transparent"
|
|
1900
|
+
},
|
|
1901
|
+
dayHover: {
|
|
1902
|
+
backgroundColor: n.dropdownHover
|
|
1903
|
+
},
|
|
1904
|
+
daySelected: {
|
|
1905
|
+
backgroundColor: n.dropdownSelected,
|
|
1906
|
+
color: "#ffffff"
|
|
1907
|
+
},
|
|
1908
|
+
dayInRange: {
|
|
1909
|
+
backgroundColor: "rgba(9, 105, 218, 0.1)"
|
|
1910
|
+
},
|
|
1911
|
+
dayOtherMonth: {
|
|
1912
|
+
opacity: 0.3
|
|
1913
|
+
},
|
|
1914
|
+
dayToday: {
|
|
1915
|
+
fontWeight: 700,
|
|
1916
|
+
textDecoration: "underline"
|
|
1917
|
+
},
|
|
1918
|
+
rangeToggle: {
|
|
1919
|
+
display: "flex",
|
|
1920
|
+
gap: "4px",
|
|
1921
|
+
marginBottom: "8px",
|
|
1922
|
+
padding: "2px",
|
|
1923
|
+
backgroundColor: e.typeBadgeBg,
|
|
1924
|
+
borderRadius: "6px"
|
|
1925
|
+
},
|
|
1926
|
+
rangeToggleButton: {
|
|
1927
|
+
flex: 1,
|
|
1928
|
+
padding: "4px 8px",
|
|
1929
|
+
border: "none",
|
|
1930
|
+
borderRadius: "4px",
|
|
1931
|
+
cursor: "pointer",
|
|
1932
|
+
fontSize: "12px",
|
|
1933
|
+
fontWeight: 500,
|
|
1934
|
+
backgroundColor: "transparent",
|
|
1935
|
+
color: n.text
|
|
1936
|
+
},
|
|
1937
|
+
rangeToggleButtonActive: {
|
|
1938
|
+
backgroundColor: n.background,
|
|
1939
|
+
boxShadow: "0 1px 2px rgba(0,0,0,0.1)"
|
|
1940
|
+
},
|
|
1941
|
+
quickOptions: {
|
|
1942
|
+
borderTop: `1px solid ${e.dropdownBorderColor}`,
|
|
1943
|
+
marginTop: "8px",
|
|
1944
|
+
paddingTop: "8px"
|
|
1945
|
+
},
|
|
1946
|
+
quickOption: {
|
|
1947
|
+
display: "block",
|
|
1948
|
+
width: "100%",
|
|
1949
|
+
textAlign: "left",
|
|
1950
|
+
padding: "4px 8px",
|
|
1951
|
+
border: "none",
|
|
1952
|
+
backgroundColor: "transparent",
|
|
1953
|
+
cursor: "pointer",
|
|
1954
|
+
fontSize: "12px",
|
|
1955
|
+
color: n.dropdownSelected,
|
|
1956
|
+
borderRadius: "4px"
|
|
1957
|
+
}
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
const ln = {
|
|
1961
|
+
delimiter: "regexDelimiter",
|
|
1962
|
+
charClass: "regexCharClass",
|
|
1963
|
+
groupOpen: "regexGroup",
|
|
1964
|
+
groupClose: "regexGroup",
|
|
1965
|
+
escape: "regexEscape",
|
|
1966
|
+
quantifier: "regexQuantifier",
|
|
1967
|
+
anchor: "regexAnchor",
|
|
1968
|
+
alternation: "regexAlternation",
|
|
1969
|
+
text: "regexText"
|
|
1970
|
+
};
|
|
1971
|
+
function cn(n) {
|
|
1972
|
+
const e = [];
|
|
1973
|
+
let t = 0, r = "";
|
|
1974
|
+
function s() {
|
|
1975
|
+
r && (e.push({ type: "text", text: r }), r = "");
|
|
1976
|
+
}
|
|
1977
|
+
n.startsWith("/") && (e.push({ type: "delimiter", text: "/" }), t = 1);
|
|
1978
|
+
const i = n.lastIndexOf("/"), a = i > 0 ? i : n.length;
|
|
1979
|
+
for (; t < a; ) {
|
|
1980
|
+
const u = n[t];
|
|
1981
|
+
if (u === "\\" && t + 1 < a) {
|
|
1982
|
+
s(), e.push({ type: "escape", text: n.slice(t, t + 2) }), t += 2;
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
if (u === "[") {
|
|
1986
|
+
s();
|
|
1987
|
+
let c = t + 1;
|
|
1988
|
+
for (c < a && n[c] === "^" && c++, c < a && n[c] === "]" && c++; c < a && n[c] !== "]"; )
|
|
1989
|
+
n[c] === "\\" && c + 1 < a && c++, c++;
|
|
1990
|
+
c < a && c++, e.push({ type: "charClass", text: n.slice(t, c) }), t = c;
|
|
1991
|
+
continue;
|
|
1992
|
+
}
|
|
1993
|
+
if (u === "(") {
|
|
1994
|
+
s();
|
|
1995
|
+
let c = "(";
|
|
1996
|
+
if (t + 1 < a && n[t + 1] === "?") {
|
|
1997
|
+
let g = t + 2;
|
|
1998
|
+
for (; g < a && g < t + 4 && /[:<>=!]/.test(n[g]); ) g++;
|
|
1999
|
+
c = n.slice(t, g);
|
|
2000
|
+
}
|
|
2001
|
+
e.push({ type: "groupOpen", text: c }), t += c.length;
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
2004
|
+
if (u === ")") {
|
|
2005
|
+
s(), e.push({ type: "groupClose", text: ")" }), t++;
|
|
2006
|
+
continue;
|
|
2007
|
+
}
|
|
2008
|
+
if (u === "+" || u === "*" || u === "?") {
|
|
2009
|
+
s();
|
|
2010
|
+
let c = u;
|
|
2011
|
+
t + 1 < a && n[t + 1] === "?" && (c += "?"), e.push({ type: "quantifier", text: c }), t += c.length;
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
if (u === "{") {
|
|
2015
|
+
s();
|
|
2016
|
+
let c = t + 1;
|
|
2017
|
+
for (; c < a && n[c] !== "}"; ) c++;
|
|
2018
|
+
c < a && c++, e.push({ type: "quantifier", text: n.slice(t, c) }), t = c;
|
|
2019
|
+
continue;
|
|
2020
|
+
}
|
|
2021
|
+
if (u === "^" || u === "$") {
|
|
2022
|
+
s(), e.push({ type: "anchor", text: u }), t++;
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
if (u === "|") {
|
|
2026
|
+
s(), e.push({ type: "alternation", text: "|" }), t++;
|
|
2027
|
+
continue;
|
|
2028
|
+
}
|
|
2029
|
+
r += u, t++;
|
|
2030
|
+
}
|
|
2031
|
+
return s(), i > 0 && i < n.length && e.push({ type: "delimiter", text: "/" }), e;
|
|
2032
|
+
}
|
|
2033
|
+
function un(n) {
|
|
2034
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2035
|
+
}
|
|
2036
|
+
function pn(n, e) {
|
|
2037
|
+
const r = cn(n.value).map((s) => {
|
|
2038
|
+
const i = ln[s.type], a = e[i] || e.regexText, u = s.type === "delimiter" ? "600" : "normal";
|
|
2039
|
+
return `<span style="color:${a};font-weight:${u}">${un(s.text)}</span>`;
|
|
2040
|
+
}).join("");
|
|
2041
|
+
return `<span data-token-start="${n.start}" data-token-end="${n.end}">${r}</span>`;
|
|
2042
|
+
}
|
|
2043
|
+
const dn = {
|
|
2044
|
+
bracket: "paren",
|
|
2045
|
+
toKeyword: "booleanOp",
|
|
2046
|
+
bareValue: "fieldValue",
|
|
2047
|
+
quotedValue: "quoted",
|
|
2048
|
+
wildcard: "wildcard",
|
|
2049
|
+
whitespace: "text"
|
|
2050
|
+
};
|
|
2051
|
+
function fn(n) {
|
|
2052
|
+
const e = [];
|
|
2053
|
+
let t = 0;
|
|
2054
|
+
t < n.length && (n[t] === "[" || n[t] === "{") && (e.push({ type: "bracket", text: n[t] }), t++);
|
|
2055
|
+
const r = n.length - 1, s = r >= 0 && (n[r] === "]" || n[r] === "}"), i = s ? r : n.length;
|
|
2056
|
+
for (; t < i; ) {
|
|
2057
|
+
const a = n[t];
|
|
2058
|
+
if (a === " " || a === " ") {
|
|
2059
|
+
let c = t;
|
|
2060
|
+
for (; c < i && (n[c] === " " || n[c] === " "); ) c++;
|
|
2061
|
+
e.push({ type: "whitespace", text: n.slice(t, c) }), t = c;
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
if ((a === "T" || a === "t") && t + 1 < i && (n[t + 1] === "O" || n[t + 1] === "o")) {
|
|
2065
|
+
const c = t === 0 || n[t - 1] === " " || n[t - 1] === " " || n[t - 1] === "[" || n[t - 1] === "{", g = t + 2 >= i || n[t + 2] === " " || n[t + 2] === " ";
|
|
2066
|
+
if (c && g) {
|
|
2067
|
+
e.push({ type: "toKeyword", text: n.slice(t, t + 2) }), t += 2;
|
|
2068
|
+
continue;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (a === '"') {
|
|
2072
|
+
let c = t + 1;
|
|
2073
|
+
for (; c < i && n[c] !== '"'; )
|
|
2074
|
+
n[c] === "\\" && c + 1 < i && c++, c++;
|
|
2075
|
+
c < i && c++, e.push({ type: "quotedValue", text: n.slice(t, c) }), t = c;
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
if (a === "*") {
|
|
2079
|
+
e.push({ type: "wildcard", text: "*" }), t++;
|
|
2080
|
+
continue;
|
|
2081
|
+
}
|
|
2082
|
+
let u = t;
|
|
2083
|
+
for (; u < i && n[u] !== " " && n[u] !== " " && n[u] !== '"'; )
|
|
2084
|
+
u++;
|
|
2085
|
+
if (u > t) {
|
|
2086
|
+
const c = n.slice(t, u);
|
|
2087
|
+
e.push({ type: "bareValue", text: c }), t = u;
|
|
2088
|
+
} else
|
|
2089
|
+
e.push({ type: "bareValue", text: a }), t++;
|
|
2090
|
+
}
|
|
2091
|
+
return s && e.push({ type: "bracket", text: n[r] }), e;
|
|
2092
|
+
}
|
|
2093
|
+
function pr(n) {
|
|
2094
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2095
|
+
}
|
|
2096
|
+
function hn(n, e) {
|
|
2097
|
+
const r = fn(n.value).map((s) => {
|
|
2098
|
+
if (s.type === "whitespace")
|
|
2099
|
+
return pr(s.text);
|
|
2100
|
+
const i = dn[s.type], a = e[i] || e.fieldValue, u = s.type === "toKeyword" || s.type === "bracket" ? "600" : "normal";
|
|
2101
|
+
return `<span style="color:${a};font-weight:${u}">${pr(s.text)}</span>`;
|
|
2102
|
+
}).join("");
|
|
2103
|
+
return `<span data-token-start="${n.start}" data-token-end="${n.end}">${r}</span>`;
|
|
2104
|
+
}
|
|
2105
|
+
function Sr(n, e) {
|
|
2106
|
+
if (e < 0) return null;
|
|
2107
|
+
const t = n.filter(
|
|
2108
|
+
(i) => i.type === l.LPAREN || i.type === l.RPAREN
|
|
2109
|
+
);
|
|
2110
|
+
if (t.length === 0) return null;
|
|
2111
|
+
const r = t.find((i) => i.end === e);
|
|
2112
|
+
if (r) {
|
|
2113
|
+
const i = dr(t, r);
|
|
2114
|
+
if (i) return i;
|
|
2115
|
+
}
|
|
2116
|
+
const s = t.find((i) => i.start === e);
|
|
2117
|
+
if (s) {
|
|
2118
|
+
const i = dr(t, s);
|
|
2119
|
+
if (i) return i;
|
|
2120
|
+
}
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
function dr(n, e) {
|
|
2124
|
+
if (e.type === l.LPAREN) {
|
|
2125
|
+
const t = n.indexOf(e);
|
|
2126
|
+
let r = 0;
|
|
2127
|
+
for (let s = t; s < n.length; s++)
|
|
2128
|
+
if (n[s].type === l.LPAREN ? r++ : n[s].type === l.RPAREN && r--, r === 0)
|
|
2129
|
+
return { openStart: e.start, closeStart: n[s].start };
|
|
2130
|
+
} else {
|
|
2131
|
+
const t = n.indexOf(e);
|
|
2132
|
+
let r = 0;
|
|
2133
|
+
for (let s = t; s >= 0; s--)
|
|
2134
|
+
if (n[s].type === l.RPAREN ? r++ : n[s].type === l.LPAREN && r--, r === 0)
|
|
2135
|
+
return { openStart: n[s].start, closeStart: e.start };
|
|
2136
|
+
}
|
|
2137
|
+
return null;
|
|
2138
|
+
}
|
|
2139
|
+
const gn = {
|
|
2140
|
+
[l.FIELD_NAME]: "fieldName",
|
|
2141
|
+
[l.COLON]: "operator",
|
|
2142
|
+
[l.VALUE]: "fieldValue",
|
|
2143
|
+
[l.QUOTED_VALUE]: "quoted",
|
|
2144
|
+
[l.AND]: "booleanOp",
|
|
2145
|
+
[l.OR]: "booleanOp",
|
|
2146
|
+
[l.NOT]: "booleanOp",
|
|
2147
|
+
[l.COMPARISON_OP]: "operator",
|
|
2148
|
+
[l.LPAREN]: "paren",
|
|
2149
|
+
[l.RPAREN]: "paren",
|
|
2150
|
+
[l.SAVED_SEARCH]: "savedSearch",
|
|
2151
|
+
[l.HISTORY_REF]: "historyRef",
|
|
2152
|
+
[l.PREFIX_OP]: "operator",
|
|
2153
|
+
[l.WILDCARD]: "wildcard",
|
|
2154
|
+
[l.REGEX]: "quoted",
|
|
2155
|
+
[l.RANGE]: "fieldValue",
|
|
2156
|
+
[l.TILDE]: "operator",
|
|
2157
|
+
[l.BOOST]: "operator",
|
|
2158
|
+
[l.WHITESPACE]: "text",
|
|
2159
|
+
[l.UNKNOWN]: "error"
|
|
2160
|
+
};
|
|
2161
|
+
function ot(n, e, t) {
|
|
2162
|
+
const r = pt(e);
|
|
2163
|
+
if (n.length === 0) return "";
|
|
2164
|
+
const s = (t == null ? void 0 : t.cursorOffset) !== void 0 ? Sr(n, t.cursorOffset) : null;
|
|
2165
|
+
return n.map((i) => {
|
|
2166
|
+
const a = gn[i.type] || "text", u = r[a] || r.text, c = yn(i.value);
|
|
2167
|
+
if (i.type === l.WHITESPACE)
|
|
2168
|
+
return c.replace(/\n/g, "<br>");
|
|
2169
|
+
if (i.type === l.REGEX)
|
|
2170
|
+
return pn(i, r);
|
|
2171
|
+
if (i.type === l.RANGE)
|
|
2172
|
+
return hn(i, r);
|
|
2173
|
+
let g = "normal";
|
|
2174
|
+
(i.type === l.AND || i.type === l.OR || i.type === l.NOT) && (g = "600"), i.type === l.FIELD_NAME && (g = "500");
|
|
2175
|
+
let f = "";
|
|
2176
|
+
return s && (i.type === l.LPAREN || i.type === l.RPAREN) && (i.start === s.openStart || i.start === s.closeStart) && (g = "700", f = `background-color:${r.matchedParenBg};border-radius:2px;`), `<span style="color:${u};font-weight:${g};${f}" data-token-start="${i.start}" data-token-end="${i.end}">${c}</span>`;
|
|
2177
|
+
}).join("");
|
|
2178
|
+
}
|
|
2179
|
+
function yn(n) {
|
|
2180
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2181
|
+
}
|
|
2182
|
+
if (typeof document < "u") {
|
|
2183
|
+
const n = "elastic-input-keyframes";
|
|
2184
|
+
if (!document.getElementById(n)) {
|
|
2185
|
+
const e = document.createElement("style");
|
|
2186
|
+
e.id = n, e.textContent = "@keyframes elastic-input-spin { to { transform: rotate(360deg); } }", document.head.appendChild(e);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function fr(n, e, t) {
|
|
2190
|
+
if (!e || e.length === 0) return n;
|
|
2191
|
+
const r = n.toLowerCase(), s = e.toLowerCase(), i = r.indexOf(s);
|
|
2192
|
+
if (i === -1) return n;
|
|
2193
|
+
const a = n.slice(0, i), u = n.slice(i, i + e.length), c = n.slice(i + e.length), g = {
|
|
2194
|
+
fontWeight: 700,
|
|
2195
|
+
textDecoration: "underline",
|
|
2196
|
+
textDecorationColor: t ? "rgba(255,255,255,0.6)" : "#0969da",
|
|
2197
|
+
textUnderlineOffset: "2px"
|
|
2198
|
+
};
|
|
2199
|
+
return /* @__PURE__ */ p.createElement(p.Fragment, null, a, /* @__PURE__ */ p.createElement("span", { style: g }, u), c);
|
|
2200
|
+
}
|
|
2201
|
+
function mn({
|
|
2202
|
+
suggestions: n,
|
|
2203
|
+
selectedIndex: e,
|
|
2204
|
+
onSelect: t,
|
|
2205
|
+
position: r,
|
|
2206
|
+
colors: s,
|
|
2207
|
+
styles: i,
|
|
2208
|
+
visible: a,
|
|
2209
|
+
fixedWidth: u,
|
|
2210
|
+
renderHistoryItem: c,
|
|
2211
|
+
renderSavedSearchItem: g,
|
|
2212
|
+
renderDropdownHeader: f,
|
|
2213
|
+
cursorContext: m
|
|
2214
|
+
}) {
|
|
2215
|
+
const I = p.useRef(null), P = p.useRef(null);
|
|
2216
|
+
p.useEffect(() => {
|
|
2217
|
+
const v = document.createElement("div");
|
|
2218
|
+
return document.body.appendChild(v), I.current = v, () => {
|
|
2219
|
+
document.body.removeChild(v), I.current = null;
|
|
2220
|
+
};
|
|
2221
|
+
}, []);
|
|
2222
|
+
const H = f && m ? f(m) : null, x = H != null;
|
|
2223
|
+
if (p.useEffect(() => {
|
|
2224
|
+
if (P.current) {
|
|
2225
|
+
const v = x ? e + 1 : e, _ = P.current.children[v];
|
|
2226
|
+
_ && _.scrollIntoView({ block: "nearest" });
|
|
2227
|
+
}
|
|
2228
|
+
}, [e, x]), !I.current || !a || n.length === 0 || !r)
|
|
2229
|
+
return null;
|
|
2230
|
+
const R = pt(s), L = dt(i), F = {
|
|
2231
|
+
...vr(R, L),
|
|
2232
|
+
top: `${r.top}px`,
|
|
2233
|
+
left: `${r.left}px`,
|
|
2234
|
+
...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",
|
|
2237
|
+
fontSize: "11px",
|
|
2238
|
+
color: R.placeholder,
|
|
2239
|
+
borderBottom: `1px solid ${R.dropdownHover}`,
|
|
2240
|
+
userSelect: "none"
|
|
2241
|
+
} }, H), n.map((v, _) => {
|
|
2242
|
+
const T = _ === e, z = cr(T, R, L);
|
|
2243
|
+
if (v.type === "hint" && (v.text === "#" || v.text === "!"))
|
|
2244
|
+
return /* @__PURE__ */ p.createElement(
|
|
2245
|
+
"div",
|
|
2246
|
+
{
|
|
2247
|
+
key: _,
|
|
2248
|
+
style: { ...z, opacity: T ? 1 : 0.7 },
|
|
2249
|
+
onClick: () => t(v),
|
|
2250
|
+
onMouseEnter: (M) => {
|
|
2251
|
+
M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover, M.currentTarget.style.opacity = "1";
|
|
2252
|
+
},
|
|
2253
|
+
onMouseLeave: (M) => {
|
|
2254
|
+
M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent", M.currentTarget.style.opacity = T ? "1" : "0.7";
|
|
2255
|
+
}
|
|
2256
|
+
},
|
|
2257
|
+
/* @__PURE__ */ p.createElement("span", { style: Be() }, v.label),
|
|
2258
|
+
v.description && /* @__PURE__ */ p.createElement("span", { style: $t() }, v.description)
|
|
2259
|
+
);
|
|
2260
|
+
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"));
|
|
2262
|
+
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%" } }));
|
|
2264
|
+
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));
|
|
2267
|
+
}
|
|
2268
|
+
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;
|
|
2270
|
+
return /* @__PURE__ */ p.createElement(
|
|
2271
|
+
"div",
|
|
2272
|
+
{
|
|
2273
|
+
key: _,
|
|
2274
|
+
style: { ...z, flexDirection: "column", alignItems: "flex-start" },
|
|
2275
|
+
title: ie ? v.text : void 0,
|
|
2276
|
+
onClick: () => t(v),
|
|
2277
|
+
onMouseEnter: (J) => {
|
|
2278
|
+
J.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
|
|
2279
|
+
},
|
|
2280
|
+
onMouseLeave: (J) => {
|
|
2281
|
+
J.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
|
|
2282
|
+
}
|
|
2283
|
+
},
|
|
2284
|
+
M ?? /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement("span", { style: {
|
|
2285
|
+
...Be(),
|
|
2286
|
+
display: "-webkit-box",
|
|
2287
|
+
WebkitLineClamp: 2,
|
|
2288
|
+
WebkitBoxOrient: "vertical",
|
|
2289
|
+
overflow: "hidden",
|
|
2290
|
+
whiteSpace: "normal",
|
|
2291
|
+
wordBreak: "break-all",
|
|
2292
|
+
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")))
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
if (v.type === "savedSearch" && g && v.sourceData) {
|
|
2297
|
+
const M = g(v.sourceData, T);
|
|
2298
|
+
if (M != null)
|
|
2299
|
+
return /* @__PURE__ */ p.createElement(
|
|
2300
|
+
"div",
|
|
2301
|
+
{
|
|
2302
|
+
key: _,
|
|
2303
|
+
style: z,
|
|
2304
|
+
onClick: () => t(v),
|
|
2305
|
+
onMouseEnter: (D) => {
|
|
2306
|
+
D.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
|
|
2307
|
+
},
|
|
2308
|
+
onMouseLeave: (D) => {
|
|
2309
|
+
D.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
|
|
2310
|
+
}
|
|
2311
|
+
},
|
|
2312
|
+
M
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
return /* @__PURE__ */ p.createElement(
|
|
2316
|
+
"div",
|
|
2317
|
+
{
|
|
2318
|
+
key: _,
|
|
2319
|
+
style: z,
|
|
2320
|
+
onClick: () => t(v),
|
|
2321
|
+
onMouseEnter: (M) => {
|
|
2322
|
+
M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : R.dropdownHover;
|
|
2323
|
+
},
|
|
2324
|
+
onMouseLeave: (M) => {
|
|
2325
|
+
M.currentTarget.style.backgroundColor = T ? R.dropdownSelected : "transparent";
|
|
2326
|
+
}
|
|
2327
|
+
},
|
|
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)
|
|
2331
|
+
);
|
|
2332
|
+
}));
|
|
2333
|
+
return mr.createPortal(U, I.current);
|
|
2334
|
+
}
|
|
2335
|
+
const En = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
2336
|
+
function Vt(n) {
|
|
2337
|
+
return Math.floor(n / 10) * 10;
|
|
2338
|
+
}
|
|
2339
|
+
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");
|
|
2346
|
+
}, $e = (w) => {
|
|
2347
|
+
R(w), I("days");
|
|
2348
|
+
}, Ve = (w) => {
|
|
2349
|
+
H(w), I("months");
|
|
2350
|
+
}, ze = (w) => {
|
|
2351
|
+
const h = new Date(P, x, w);
|
|
2352
|
+
if (g === "single") {
|
|
2353
|
+
n(Bt(h));
|
|
2354
|
+
return;
|
|
2355
|
+
}
|
|
2356
|
+
if (!L || U)
|
|
2357
|
+
F(h), v(null), T(null);
|
|
2358
|
+
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 = {
|
|
2369
|
+
...D.day,
|
|
2370
|
+
...V ? D.dayToday : {},
|
|
2371
|
+
...Q ? D.dayInRange : {},
|
|
2372
|
+
...N ? D.daySelected : {}
|
|
2373
|
+
}, me = g === "range" && L && !U;
|
|
2374
|
+
Te.push(
|
|
2375
|
+
/* @__PURE__ */ p.createElement(
|
|
2376
|
+
"button",
|
|
2377
|
+
{
|
|
2378
|
+
key: w,
|
|
2379
|
+
style: W,
|
|
2380
|
+
onClick: () => ze(w),
|
|
2381
|
+
onMouseEnter: (X) => {
|
|
2382
|
+
me ? T(h) : N || (X.currentTarget.style.backgroundColor = z.dropdownHover);
|
|
2383
|
+
},
|
|
2384
|
+
onMouseLeave: (X) => {
|
|
2385
|
+
!me && !N && (X.currentTarget.style.backgroundColor = Q ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2386
|
+
}
|
|
2387
|
+
},
|
|
2388
|
+
w
|
|
2389
|
+
)
|
|
2390
|
+
);
|
|
2391
|
+
}
|
|
2392
|
+
const Pe = {
|
|
2393
|
+
...D.day,
|
|
2394
|
+
padding: "10px 4px",
|
|
2395
|
+
fontSize: "13px"
|
|
2396
|
+
}, gt = {
|
|
2397
|
+
...Pe,
|
|
2398
|
+
...D.dayToday
|
|
2399
|
+
}, Ye = a ?? [
|
|
2400
|
+
{ label: "Today", value: "[now/d TO now]" },
|
|
2401
|
+
{ label: "Yesterday", value: "[now-1d/d TO now/d]" },
|
|
2402
|
+
{ label: "Last 7 days", value: "[now-7d TO now]" },
|
|
2403
|
+
{ label: "Last 30 days", value: "[now-30d TO now]" },
|
|
2404
|
+
{ label: "Last 90 days", value: "[now-90d TO now]" },
|
|
2405
|
+
{ label: "Last 1 year", value: "[now-365d TO now]" }
|
|
2406
|
+
], Ke = {
|
|
2407
|
+
display: "grid",
|
|
2408
|
+
gridTemplateColumns: "1fr 1fr",
|
|
2409
|
+
gap: "2px"
|
|
2410
|
+
};
|
|
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(
|
|
2412
|
+
"button",
|
|
2413
|
+
{
|
|
2414
|
+
key: w,
|
|
2415
|
+
style: {
|
|
2416
|
+
...D.rangeToggleButton,
|
|
2417
|
+
...g === w ? D.rangeToggleButtonActive : {}
|
|
2418
|
+
},
|
|
2419
|
+
onClick: () => ft(w)
|
|
2420
|
+
},
|
|
2421
|
+
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(
|
|
2423
|
+
"button",
|
|
2424
|
+
{
|
|
2425
|
+
style: {
|
|
2426
|
+
...D.monthLabel,
|
|
2427
|
+
backgroundColor: "transparent",
|
|
2428
|
+
border: "none",
|
|
2429
|
+
cursor: ke ? "pointer" : "default",
|
|
2430
|
+
padding: "2px 8px",
|
|
2431
|
+
borderRadius: "4px"
|
|
2432
|
+
},
|
|
2433
|
+
onClick: ke ? ne : void 0,
|
|
2434
|
+
onMouseEnter: (w) => {
|
|
2435
|
+
ke && (w.currentTarget.style.backgroundColor = "#eef1f5");
|
|
2436
|
+
},
|
|
2437
|
+
onMouseLeave: (w) => {
|
|
2438
|
+
w.currentTarget.style.backgroundColor = "transparent";
|
|
2439
|
+
}
|
|
2440
|
+
},
|
|
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),
|
|
2445
|
+
V
|
|
2446
|
+
) || K && it(
|
|
2447
|
+
new Date(K.getFullYear(), K.getMonth(), 1),
|
|
2448
|
+
V
|
|
2449
|
+
), Q = h === Le.getMonth() && P === Le.getFullYear(), N = g === "range" && L && !U;
|
|
2450
|
+
return /* @__PURE__ */ p.createElement(
|
|
2451
|
+
"button",
|
|
2452
|
+
{
|
|
2453
|
+
key: w,
|
|
2454
|
+
style: {
|
|
2455
|
+
...Q ? gt : Pe,
|
|
2456
|
+
...oe ? D.dayInRange : {},
|
|
2457
|
+
...ye ? D.daySelected : {}
|
|
2458
|
+
},
|
|
2459
|
+
onClick: () => $e(h),
|
|
2460
|
+
onMouseEnter: (W) => {
|
|
2461
|
+
N ? T(V) : ye || (W.currentTarget.style.backgroundColor = z.dropdownHover);
|
|
2462
|
+
},
|
|
2463
|
+
onMouseLeave: (W) => {
|
|
2464
|
+
!N && !ye && (W.currentTarget.style.backgroundColor = oe ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2465
|
+
}
|
|
2466
|
+
},
|
|
2467
|
+
w
|
|
2468
|
+
);
|
|
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;
|
|
2471
|
+
return /* @__PURE__ */ p.createElement(
|
|
2472
|
+
"button",
|
|
2473
|
+
{
|
|
2474
|
+
key: V,
|
|
2475
|
+
style: {
|
|
2476
|
+
...ye ? gt : Pe,
|
|
2477
|
+
...oe ? D.dayOtherMonth : {},
|
|
2478
|
+
...N ? D.dayInRange : {},
|
|
2479
|
+
...W ? D.daySelected : {}
|
|
2480
|
+
},
|
|
2481
|
+
onClick: () => Ve(V),
|
|
2482
|
+
onMouseEnter: (X) => {
|
|
2483
|
+
me ? T(Q) : W || (X.currentTarget.style.backgroundColor = z.dropdownHover);
|
|
2484
|
+
},
|
|
2485
|
+
onMouseLeave: (X) => {
|
|
2486
|
+
!me && !W && (X.currentTarget.style.backgroundColor = N ? "rgba(9, 105, 218, 0.1)" : "transparent");
|
|
2487
|
+
}
|
|
2488
|
+
},
|
|
2489
|
+
V
|
|
2490
|
+
);
|
|
2491
|
+
})), g === "range" && /* @__PURE__ */ p.createElement("div", { style: {
|
|
2492
|
+
...D.quickOptions,
|
|
2493
|
+
...Ke
|
|
2494
|
+
} }, Ye.map((w) => /* @__PURE__ */ p.createElement("button", { key: w.value, style: D.quickOption, onClick: () => n(w.value) }, w.label))));
|
|
2495
|
+
}
|
|
2496
|
+
const Sn = 30, xn = 150;
|
|
2497
|
+
function hr(n, e) {
|
|
2498
|
+
let t = 0;
|
|
2499
|
+
const r = (s) => {
|
|
2500
|
+
if (s.nodeType === Node.TEXT_NODE) {
|
|
2501
|
+
const i = (s.textContent || "").length;
|
|
2502
|
+
return t + i >= e ? { node: s, offset: e - t } : (t += i, null);
|
|
2503
|
+
}
|
|
2504
|
+
if (s.nodeName === "BR") {
|
|
2505
|
+
if (t + 1 >= e) {
|
|
2506
|
+
const i = s.parentNode;
|
|
2507
|
+
if (i) {
|
|
2508
|
+
const a = Array.from(i.childNodes).indexOf(s);
|
|
2509
|
+
return { node: i, offset: a + 1 };
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return t += 1, null;
|
|
2513
|
+
}
|
|
2514
|
+
for (let i = 0; i < s.childNodes.length; i++) {
|
|
2515
|
+
const a = r(s.childNodes[i]);
|
|
2516
|
+
if (a) return a;
|
|
2517
|
+
}
|
|
2518
|
+
return null;
|
|
2519
|
+
};
|
|
2520
|
+
return r(n);
|
|
2521
|
+
}
|
|
2522
|
+
function wn(n, e, t) {
|
|
2523
|
+
const r = hr(n, e), s = hr(n, t);
|
|
2524
|
+
if (!r || !s) return [];
|
|
2525
|
+
const i = document.createRange();
|
|
2526
|
+
i.setStart(r.node, r.offset), i.setEnd(s.node, s.offset);
|
|
2527
|
+
const a = n.getBoundingClientRect(), u = i.getClientRects();
|
|
2528
|
+
if (u.length === 0) return [];
|
|
2529
|
+
const c = [];
|
|
2530
|
+
for (let g = 0; g < u.length; g++) {
|
|
2531
|
+
const f = u[g];
|
|
2532
|
+
f.width < 1 || c.push({
|
|
2533
|
+
left: f.left - a.left,
|
|
2534
|
+
top: f.top - a.top,
|
|
2535
|
+
width: Math.max(f.width, 6),
|
|
2536
|
+
height: f.height
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
return c;
|
|
2540
|
+
}
|
|
2541
|
+
function bn(n, e, t) {
|
|
2542
|
+
if (!e || n.length === 0) return [];
|
|
2543
|
+
const r = [];
|
|
2544
|
+
let s = 0;
|
|
2545
|
+
for (const i of n) {
|
|
2546
|
+
if (s >= Sn) break;
|
|
2547
|
+
if (t >= i.start && t <= i.end)
|
|
2548
|
+
continue;
|
|
2549
|
+
const a = wn(e, i.start, i.end);
|
|
2550
|
+
for (const u of a)
|
|
2551
|
+
r.push({
|
|
2552
|
+
left: u.left,
|
|
2553
|
+
top: u.top,
|
|
2554
|
+
width: u.width,
|
|
2555
|
+
height: u.height,
|
|
2556
|
+
error: i
|
|
2557
|
+
});
|
|
2558
|
+
s++;
|
|
2559
|
+
}
|
|
2560
|
+
return r;
|
|
2561
|
+
}
|
|
2562
|
+
const gr = 28, yr = 4;
|
|
2563
|
+
function Rn(n) {
|
|
2564
|
+
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
|
+
}
|
|
2566
|
+
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);
|
|
2568
|
+
if (p.useEffect(() => {
|
|
2569
|
+
if (H.current && clearTimeout(H.current), n.length === 0) {
|
|
2570
|
+
m([]), I.current = [], u(null);
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
return H.current = setTimeout(() => {
|
|
2574
|
+
const F = bn(n, e, t);
|
|
2575
|
+
m(F), I.current = F;
|
|
2576
|
+
}, xn), () => {
|
|
2577
|
+
H.current && clearTimeout(H.current);
|
|
2578
|
+
};
|
|
2579
|
+
}, [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;
|
|
2589
|
+
break;
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
ie >= 0 ? (u(ie), g({ x: M, clientY: T.clientY })) : u(null);
|
|
2593
|
+
}, v = () => {
|
|
2594
|
+
u(null);
|
|
2595
|
+
}, _ = new AbortController();
|
|
2596
|
+
return F.addEventListener("mousemove", U, { signal: _.signal }), F.addEventListener("mouseleave", v, { signal: _.signal }), () => _.abort();
|
|
2597
|
+
}, [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)`;
|
|
2604
|
+
} else
|
|
2605
|
+
F.style.transform = "";
|
|
2606
|
+
}), 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;
|
|
2610
|
+
return /* @__PURE__ */ p.createElement(
|
|
2611
|
+
"div",
|
|
2612
|
+
{
|
|
2613
|
+
key: `wave-${U}`,
|
|
2614
|
+
style: {
|
|
2615
|
+
position: "absolute",
|
|
2616
|
+
left: `${F.left}px`,
|
|
2617
|
+
top: `${z}px`,
|
|
2618
|
+
width: `${F.width}px`,
|
|
2619
|
+
height: "4px",
|
|
2620
|
+
zIndex: 1,
|
|
2621
|
+
backgroundImage: T,
|
|
2622
|
+
backgroundRepeat: "repeat-x",
|
|
2623
|
+
backgroundPosition: "left top",
|
|
2624
|
+
backgroundSize: "auto 4px",
|
|
2625
|
+
pointerEvents: "none"
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
);
|
|
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;
|
|
2631
|
+
return /* @__PURE__ */ p.createElement(
|
|
2632
|
+
"div",
|
|
2633
|
+
{
|
|
2634
|
+
ref: P,
|
|
2635
|
+
style: {
|
|
2636
|
+
position: "absolute",
|
|
2637
|
+
top: `${M}px`,
|
|
2638
|
+
left: `${c.x}px`,
|
|
2639
|
+
zIndex: R.dropdownZIndex,
|
|
2640
|
+
backgroundColor: x.background,
|
|
2641
|
+
color: U,
|
|
2642
|
+
border: `1px solid ${U}`,
|
|
2643
|
+
borderRadius: "4px",
|
|
2644
|
+
padding: "4px 8px",
|
|
2645
|
+
fontSize: "12px",
|
|
2646
|
+
fontFamily: R.fontFamily,
|
|
2647
|
+
lineHeight: "1.4",
|
|
2648
|
+
whiteSpace: "nowrap",
|
|
2649
|
+
pointerEvents: "none",
|
|
2650
|
+
userSelect: "none",
|
|
2651
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
2652
|
+
maxWidth: "90vw"
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
L.error.message
|
|
2656
|
+
);
|
|
2657
|
+
})());
|
|
2658
|
+
}
|
|
2659
|
+
function Yt(n, e, t) {
|
|
2660
|
+
let r = 0, s = !1;
|
|
2661
|
+
function i(a) {
|
|
2662
|
+
if (s) return !0;
|
|
2663
|
+
if (a === e) {
|
|
2664
|
+
if (a.nodeType === Node.TEXT_NODE)
|
|
2665
|
+
r += t;
|
|
2666
|
+
else
|
|
2667
|
+
for (let u = 0; u < t && u < a.childNodes.length; u++)
|
|
2668
|
+
if (i(a.childNodes[u])) return !0;
|
|
2669
|
+
return s = !0, !0;
|
|
2670
|
+
}
|
|
2671
|
+
if (a.nodeType === Node.TEXT_NODE)
|
|
2672
|
+
return r += (a.textContent || "").length, !1;
|
|
2673
|
+
if (a.nodeName === "BR")
|
|
2674
|
+
return r += 1, !1;
|
|
2675
|
+
for (let u = 0; u < a.childNodes.length; u++)
|
|
2676
|
+
if (i(a.childNodes[u])) return !0;
|
|
2677
|
+
return !1;
|
|
2678
|
+
}
|
|
2679
|
+
return i(n), r;
|
|
2680
|
+
}
|
|
2681
|
+
function lt(n) {
|
|
2682
|
+
const e = window.getSelection();
|
|
2683
|
+
if (!e || e.rangeCount === 0) return 0;
|
|
2684
|
+
const t = e.getRangeAt(0);
|
|
2685
|
+
return Yt(n, t.startContainer, t.startOffset);
|
|
2686
|
+
}
|
|
2687
|
+
function Ae(n) {
|
|
2688
|
+
const e = window.getSelection();
|
|
2689
|
+
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);
|
|
2691
|
+
return { start: r, end: s };
|
|
2692
|
+
}
|
|
2693
|
+
function Ue(n, e) {
|
|
2694
|
+
const t = window.getSelection();
|
|
2695
|
+
if (!t) return;
|
|
2696
|
+
const r = Kt(n, e);
|
|
2697
|
+
if (!r) return;
|
|
2698
|
+
const s = document.createRange();
|
|
2699
|
+
s.setStart(r.node, r.offset), s.collapse(!0), t.removeAllRanges(), t.addRange(s);
|
|
2700
|
+
}
|
|
2701
|
+
function He(n, e, t) {
|
|
2702
|
+
if (e === t) {
|
|
2703
|
+
Ue(n, e);
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
const r = window.getSelection();
|
|
2707
|
+
if (!r) return;
|
|
2708
|
+
const s = Kt(n, e), i = Kt(n, t);
|
|
2709
|
+
if (!s || !i) return;
|
|
2710
|
+
const a = document.createRange();
|
|
2711
|
+
a.setStart(s.node, s.offset), a.setEnd(i.node, i.offset), r.removeAllRanges(), r.addRange(a);
|
|
2712
|
+
}
|
|
2713
|
+
function Kt(n, e) {
|
|
2714
|
+
let t = 0;
|
|
2715
|
+
function r(a) {
|
|
2716
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
2717
|
+
const u = (a.textContent || "").length;
|
|
2718
|
+
return t + u >= e ? { node: a, offset: e - t } : (t += u, null);
|
|
2719
|
+
}
|
|
2720
|
+
if (a.nodeName === "BR") {
|
|
2721
|
+
if (t + 1 >= e) {
|
|
2722
|
+
const u = a.parentNode;
|
|
2723
|
+
if (u) {
|
|
2724
|
+
const c = Array.from(u.childNodes).indexOf(a);
|
|
2725
|
+
return { node: u, offset: c + 1 };
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
return t += 1, null;
|
|
2729
|
+
}
|
|
2730
|
+
for (let u = 0; u < a.childNodes.length; u++) {
|
|
2731
|
+
const c = r(a.childNodes[u]);
|
|
2732
|
+
if (c) return c;
|
|
2733
|
+
}
|
|
2734
|
+
return null;
|
|
2735
|
+
}
|
|
2736
|
+
const s = r(n);
|
|
2737
|
+
if (s) return s;
|
|
2738
|
+
const i = xr(n);
|
|
2739
|
+
return i ? { node: i, offset: (i.textContent || "").length } : { node: n, offset: 0 };
|
|
2740
|
+
}
|
|
2741
|
+
function xr(n) {
|
|
2742
|
+
if (n.nodeType === Node.TEXT_NODE) return n;
|
|
2743
|
+
for (let e = n.childNodes.length - 1; e >= 0; e--) {
|
|
2744
|
+
const t = xr(n.childNodes[e]);
|
|
2745
|
+
if (t) return t;
|
|
2746
|
+
}
|
|
2747
|
+
return null;
|
|
2748
|
+
}
|
|
2749
|
+
function kn(n) {
|
|
2750
|
+
const e = window.getSelection();
|
|
2751
|
+
if (!e || e.rangeCount === 0) return;
|
|
2752
|
+
const t = e.getRangeAt(0);
|
|
2753
|
+
t.deleteContents();
|
|
2754
|
+
const r = document.createTextNode(n);
|
|
2755
|
+
t.insertNode(r), t.setStartAfter(r), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
|
|
2756
|
+
}
|
|
2757
|
+
function Cn() {
|
|
2758
|
+
const n = window.getSelection();
|
|
2759
|
+
if (!n || n.rangeCount === 0) return;
|
|
2760
|
+
const e = n.getRangeAt(0);
|
|
2761
|
+
e.deleteContents();
|
|
2762
|
+
const t = document.createElement("br");
|
|
2763
|
+
e.insertNode(t), e.setStartAfter(t), e.collapse(!0), n.removeAllRanges(), n.addRange(e);
|
|
2764
|
+
}
|
|
2765
|
+
function zt() {
|
|
2766
|
+
var r;
|
|
2767
|
+
const n = window.getSelection();
|
|
2768
|
+
if (!n || n.rangeCount === 0) return null;
|
|
2769
|
+
const e = n.getRangeAt(0), t = e.getBoundingClientRect();
|
|
2770
|
+
if (t.width === 0 && t.height === 0) {
|
|
2771
|
+
const s = document.createElement("span");
|
|
2772
|
+
s.textContent = "", e.insertNode(s);
|
|
2773
|
+
const i = s.getBoundingClientRect();
|
|
2774
|
+
return (r = s.parentNode) == null || r.removeChild(s), n.removeAllRanges(), n.addRange(e), i;
|
|
2775
|
+
}
|
|
2776
|
+
return t;
|
|
2777
|
+
}
|
|
2778
|
+
function qt(n, e, t) {
|
|
2779
|
+
const r = window.innerHeight, s = window.innerWidth;
|
|
2780
|
+
let i = n.bottom + window.scrollY + 4, a = n.left + window.scrollX;
|
|
2781
|
+
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 };
|
|
2782
|
+
}
|
|
2783
|
+
const Dn = /* @__PURE__ */ new Set([
|
|
2784
|
+
l.VALUE,
|
|
2785
|
+
l.QUOTED_VALUE,
|
|
2786
|
+
l.WILDCARD
|
|
2787
|
+
]);
|
|
2788
|
+
function On(n, e, t) {
|
|
2789
|
+
for (const r of n)
|
|
2790
|
+
if (e >= r.start && e <= r.end && Dn.has(r.type))
|
|
2791
|
+
return e === r.start && t === r.end ? null : { start: r.start, end: r.end };
|
|
2792
|
+
return null;
|
|
2793
|
+
}
|
|
2794
|
+
const Nn = /* @__PURE__ */ new Set([
|
|
2795
|
+
l.VALUE,
|
|
2796
|
+
l.QUOTED_VALUE,
|
|
2797
|
+
l.WILDCARD,
|
|
2798
|
+
l.FIELD_NAME,
|
|
2799
|
+
l.RANGE,
|
|
2800
|
+
l.SAVED_SEARCH,
|
|
2801
|
+
l.HISTORY_REF,
|
|
2802
|
+
l.REGEX
|
|
2803
|
+
]);
|
|
2804
|
+
function Ln(n, e, t) {
|
|
2805
|
+
const r = [];
|
|
2806
|
+
for (const s of e)
|
|
2807
|
+
if (t >= s.start && t <= s.end && Nn.has(s.type)) {
|
|
2808
|
+
r.push({ start: s.start, end: s.end });
|
|
2809
|
+
break;
|
|
2810
|
+
}
|
|
2811
|
+
return n && xt(n, t, r), Tn(r);
|
|
2812
|
+
}
|
|
2813
|
+
function xt(n, e, t) {
|
|
2814
|
+
if (e < n.start || e > n.end) return !1;
|
|
2815
|
+
let r = !1;
|
|
2816
|
+
switch (n.type) {
|
|
2817
|
+
case "BooleanExpr":
|
|
2818
|
+
r = xt(n.left, e, t) || r, r = xt(n.right, e, t) || r;
|
|
2819
|
+
break;
|
|
2820
|
+
case "Group":
|
|
2821
|
+
case "Not":
|
|
2822
|
+
case "FieldGroup":
|
|
2823
|
+
r = xt(n.expression, e, t) || r;
|
|
2824
|
+
break;
|
|
2825
|
+
}
|
|
2826
|
+
return t.push({ start: n.start, end: n.end }), !0;
|
|
2827
|
+
}
|
|
2828
|
+
function Tn(n) {
|
|
2829
|
+
n.sort((t, r) => {
|
|
2830
|
+
const s = t.end - t.start, i = r.end - r.start;
|
|
2831
|
+
return s - i || t.start - r.start;
|
|
2832
|
+
});
|
|
2833
|
+
const e = [];
|
|
2834
|
+
for (const t of n) {
|
|
2835
|
+
const r = e[e.length - 1];
|
|
2836
|
+
r && r.start === t.start && r.end === t.end || e.push(t);
|
|
2837
|
+
}
|
|
2838
|
+
return e;
|
|
2839
|
+
}
|
|
2840
|
+
class Pn {
|
|
2841
|
+
constructor(e = 100) {
|
|
2842
|
+
q(this, "stack", []);
|
|
2843
|
+
q(this, "index", -1);
|
|
2844
|
+
q(this, "maxSize");
|
|
2845
|
+
this.maxSize = e;
|
|
2846
|
+
}
|
|
2847
|
+
/** Push a new state. Clears any redo entries ahead of current position. */
|
|
2848
|
+
push(e) {
|
|
2849
|
+
if (this.index >= 0 && this.stack[this.index].value === e.value) {
|
|
2850
|
+
this.stack[this.index].cursorPos = e.cursorPos;
|
|
2851
|
+
return;
|
|
2852
|
+
}
|
|
2853
|
+
this.stack = this.stack.slice(0, this.index + 1), this.stack.push(e), this.stack.length > this.maxSize && this.stack.shift(), this.index = this.stack.length - 1;
|
|
2854
|
+
}
|
|
2855
|
+
/** Replace the current entry (used for grouping consecutive typing). */
|
|
2856
|
+
replaceCurrent(e) {
|
|
2857
|
+
this.index >= 0 ? this.stack[this.index] = e : this.push(e);
|
|
2858
|
+
}
|
|
2859
|
+
undo() {
|
|
2860
|
+
return this.index <= 0 ? null : (this.index--, this.stack[this.index]);
|
|
2861
|
+
}
|
|
2862
|
+
redo() {
|
|
2863
|
+
return this.index >= this.stack.length - 1 ? null : (this.index++, this.stack[this.index]);
|
|
2864
|
+
}
|
|
2865
|
+
canUndo() {
|
|
2866
|
+
return this.index > 0;
|
|
2867
|
+
}
|
|
2868
|
+
canRedo() {
|
|
2869
|
+
return this.index < this.stack.length - 1;
|
|
2870
|
+
}
|
|
2871
|
+
current() {
|
|
2872
|
+
return this.index >= 0 ? this.stack[this.index] : null;
|
|
2873
|
+
}
|
|
2874
|
+
clear() {
|
|
2875
|
+
this.stack = [], this.index = -1;
|
|
2876
|
+
}
|
|
2877
|
+
get length() {
|
|
2878
|
+
return this.stack.length;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
function Mn(n) {
|
|
2882
|
+
if (n.type === "RANGE" && n.token) {
|
|
2883
|
+
const e = n.token.value, s = (e.endsWith("]") || e.endsWith("}") ? e.slice(1, -1) : e.slice(1)).match(/^(.*?)\s+[Tt][Oo]\s+(.*)$/);
|
|
2884
|
+
if (s) {
|
|
2885
|
+
const i = Ht(s[1].trim()), a = Ht(s[2].trim());
|
|
2886
|
+
return { mode: "range", start: i, end: a };
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
if (n.type === "FIELD_VALUE" && n.partial) {
|
|
2890
|
+
const e = Ht(n.partial);
|
|
2891
|
+
if (e)
|
|
2892
|
+
return { mode: "single", start: e, end: null };
|
|
2893
|
+
}
|
|
2894
|
+
return null;
|
|
2895
|
+
}
|
|
2896
|
+
function In(n, e) {
|
|
2897
|
+
var c, g, f, m;
|
|
2898
|
+
const t = (n == null ? void 0 : n.mode) ?? "single", r = (e == null ? void 0 : e.mode) ?? "single";
|
|
2899
|
+
if (t !== r) return !0;
|
|
2900
|
+
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
|
+
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;
|
|
2903
|
+
return a !== u;
|
|
2904
|
+
}
|
|
2905
|
+
function Fn({ position: n, colors: e, onSelect: t, colorConfig: r, styleConfig: s, datePickerInit: i, fixedWidth: a, datePresets: u }) {
|
|
2906
|
+
const c = p.useRef(null), [g, f] = p.useState(!1);
|
|
2907
|
+
if (p.useEffect(() => {
|
|
2908
|
+
const P = document.createElement("div");
|
|
2909
|
+
return document.body.appendChild(P), c.current = P, f(!0), () => {
|
|
2910
|
+
document.body.removeChild(P), c.current = null;
|
|
2911
|
+
};
|
|
2912
|
+
}, []), !g || !c.current) return null;
|
|
2913
|
+
const m = dt(s), I = {
|
|
2914
|
+
position: "absolute",
|
|
2915
|
+
zIndex: m.dropdownZIndex,
|
|
2916
|
+
...vr(e, m),
|
|
2917
|
+
top: `${n.top}px`,
|
|
2918
|
+
left: `${n.left}px`,
|
|
2919
|
+
maxHeight: "none",
|
|
2920
|
+
overflowY: "visible",
|
|
2921
|
+
...a != null ? { width: `${a}px`, minWidth: "unset", maxWidth: "unset" } : {}
|
|
2922
|
+
};
|
|
2923
|
+
return mr.createPortal(
|
|
2924
|
+
/* @__PURE__ */ p.createElement("div", { style: I, onMouseDown: (P) => P.preventDefault() }, /* @__PURE__ */ p.createElement(
|
|
2925
|
+
vn,
|
|
2926
|
+
{
|
|
2927
|
+
onSelect: t,
|
|
2928
|
+
colors: r,
|
|
2929
|
+
styles: s,
|
|
2930
|
+
initialMode: i == null ? void 0 : i.mode,
|
|
2931
|
+
initialStart: i == null ? void 0 : i.start,
|
|
2932
|
+
initialEnd: i == null ? void 0 : i.end,
|
|
2933
|
+
presets: u
|
|
2934
|
+
}
|
|
2935
|
+
)),
|
|
2936
|
+
c.current
|
|
2937
|
+
);
|
|
2938
|
+
}
|
|
2939
|
+
function Un(n) {
|
|
2940
|
+
const {
|
|
2941
|
+
fields: e,
|
|
2942
|
+
onSearch: t,
|
|
2943
|
+
onChange: r,
|
|
2944
|
+
onValidationChange: s,
|
|
2945
|
+
value: i,
|
|
2946
|
+
defaultValue: a,
|
|
2947
|
+
savedSearches: u,
|
|
2948
|
+
searchHistory: c,
|
|
2949
|
+
fetchSuggestions: g,
|
|
2950
|
+
colors: f,
|
|
2951
|
+
styles: m,
|
|
2952
|
+
placeholder: I,
|
|
2953
|
+
className: P,
|
|
2954
|
+
style: H,
|
|
2955
|
+
dropdown: x,
|
|
2956
|
+
features: R,
|
|
2957
|
+
inputRef: L,
|
|
2958
|
+
datePresets: F,
|
|
2959
|
+
onKeyDown: U,
|
|
2960
|
+
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);
|
|
2968
|
+
p.useEffect(() => {
|
|
2969
|
+
if (Array.isArray(e)) {
|
|
2970
|
+
w(e);
|
|
2971
|
+
return;
|
|
2972
|
+
}
|
|
2973
|
+
let o = !1;
|
|
2974
|
+
return e().then((d) => {
|
|
2975
|
+
o || w(d);
|
|
2976
|
+
}), () => {
|
|
2977
|
+
o = !0;
|
|
2978
|
+
};
|
|
2979
|
+
}, [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,
|
|
2986
|
+
[],
|
|
2987
|
+
[],
|
|
2988
|
+
ie || Gt,
|
|
2989
|
+
{ showSavedSearchHint: Ve, showHistoryHint: ze }
|
|
2990
|
+
)
|
|
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,
|
|
3001
|
+
selectionEnd: mt,
|
|
3002
|
+
autocompleteContext: Jt,
|
|
3003
|
+
validationErrors: Nt,
|
|
3004
|
+
cursorContext: Lt
|
|
3005
|
+
});
|
|
3006
|
+
G.current = {
|
|
3007
|
+
tokens: Xt,
|
|
3008
|
+
ast: jt,
|
|
3009
|
+
suggestions: At,
|
|
3010
|
+
selectedSuggestionIndex: kt,
|
|
3011
|
+
showDropdown: Ct,
|
|
3012
|
+
showDatePicker: Dt,
|
|
3013
|
+
cursorOffset: Fe,
|
|
3014
|
+
selectionEnd: mt,
|
|
3015
|
+
autocompleteContext: Jt,
|
|
3016
|
+
validationErrors: Nt,
|
|
3017
|
+
cursorContext: Lt
|
|
3018
|
+
};
|
|
3019
|
+
const Tt = p.useCallback((o, d) => {
|
|
3020
|
+
if (D && Q.current) {
|
|
3021
|
+
const A = Q.current.getBoundingClientRect();
|
|
3022
|
+
return {
|
|
3023
|
+
top: A.bottom + window.scrollY + 4,
|
|
3024
|
+
left: A.left + window.scrollX
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
const E = zt();
|
|
3028
|
+
return E ? qt(E, o, d) : null;
|
|
3029
|
+
}, [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));
|
|
3035
|
+
return;
|
|
3036
|
+
}
|
|
3037
|
+
requestAnimationFrame(() => {
|
|
3038
|
+
E === "datePicker" ? se(!0) : Z(!0);
|
|
3039
|
+
const y = zt(), S = y ? qt(y, o, d) : null;
|
|
3040
|
+
yt(S);
|
|
3041
|
+
});
|
|
3042
|
+
}, [D, Tt]), kr = 80, Cr = 60, Pt = p.useCallback((o, d) => {
|
|
3043
|
+
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)];
|
|
3048
|
+
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);
|
|
3054
|
+
}
|
|
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);
|
|
3056
|
+
} else
|
|
3057
|
+
Je(A), et(S), tt(C), nt(o.length === 0);
|
|
3058
|
+
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 };
|
|
3066
|
+
}) : o;
|
|
3067
|
+
}, [ke]), ae = p.useCallback((o, d) => {
|
|
3068
|
+
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([]);
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
if (M === "manual") {
|
|
3077
|
+
if (Ce.current && Ce.current !== A) {
|
|
3078
|
+
Ce.current = null, Z(!1), se(!1), te([]);
|
|
3079
|
+
return;
|
|
3080
|
+
}
|
|
3081
|
+
if (!Ce.current) {
|
|
3082
|
+
Z(!1), se(!1), te([]);
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
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");
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
if (S && Ie.current)
|
|
3096
|
+
st(A);
|
|
3097
|
+
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 = {
|
|
3099
|
+
text: "",
|
|
3100
|
+
label: typeof ce == "function" ? ce(E.context.partial) : ce || "Searching...",
|
|
3101
|
+
type: "loading",
|
|
3102
|
+
replaceStart: $,
|
|
3103
|
+
replaceEnd: B
|
|
3104
|
+
};
|
|
3105
|
+
te([ue]), D || Z(!1), se(!1), xe(-1), st(A), De(32, 300);
|
|
3106
|
+
} 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));
|
|
3110
|
+
}
|
|
3111
|
+
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;
|
|
3117
|
+
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);
|
|
3131
|
+
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
|
|
3135
|
+
);
|
|
3136
|
+
_e.length > 0 ? (te(_e), xe(re.context.partial ? 0 : -1), De(_e.length * 32, 300)) : (Z(!1), te([]));
|
|
3137
|
+
}
|
|
3138
|
+
} catch (Re) {
|
|
3139
|
+
if (!ue.signal.aborted) {
|
|
3140
|
+
const re = {
|
|
3141
|
+
text: "",
|
|
3142
|
+
label: Re instanceof Error ? Re.message : "Error loading suggestions",
|
|
3143
|
+
type: "error",
|
|
3144
|
+
replaceStart: be,
|
|
3145
|
+
replaceEnd: ge
|
|
3146
|
+
};
|
|
3147
|
+
te([re]), xe(-1), De(32, 300), Ie.current = !1;
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
}, fe);
|
|
3151
|
+
}
|
|
3152
|
+
}, [g, J, Mt, Tt, De, D, M, K]);
|
|
3153
|
+
Qt.current = ae;
|
|
3154
|
+
const Y = p.useCallback(() => {
|
|
3155
|
+
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();
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
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)];
|
|
3168
|
+
if (h.current) {
|
|
3169
|
+
const k = ot(y, f, { cursorOffset: d });
|
|
3170
|
+
h.current.innerHTML = k, Ue(h.current, d);
|
|
3171
|
+
}
|
|
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) => {
|
|
3174
|
+
if (!o) return;
|
|
3175
|
+
const A = G.current;
|
|
3176
|
+
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);
|
|
3180
|
+
});
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
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);
|
|
3190
|
+
});
|
|
3191
|
+
}, [we, ae, t]);
|
|
3192
|
+
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
|
+
})();
|
|
3203
|
+
}, [u, c]), p.useEffect(() => {
|
|
3204
|
+
le.current = new ir(
|
|
3205
|
+
Ke,
|
|
3206
|
+
[],
|
|
3207
|
+
[],
|
|
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({
|
|
3222
|
+
getValue: () => N.current,
|
|
3223
|
+
setValue: (o) => {
|
|
3224
|
+
N.current = o, Se(o, !1);
|
|
3225
|
+
},
|
|
3226
|
+
focus: () => {
|
|
3227
|
+
var o;
|
|
3228
|
+
return (o = h.current) == null ? void 0 : o.focus();
|
|
3229
|
+
},
|
|
3230
|
+
blur: () => {
|
|
3231
|
+
var o;
|
|
3232
|
+
return (o = h.current) == null ? void 0 : o.blur();
|
|
3233
|
+
},
|
|
3234
|
+
getAST: () => G.current.ast,
|
|
3235
|
+
getValidationErrors: () => G.current.validationErrors,
|
|
3236
|
+
setSelection: (o, d) => {
|
|
3237
|
+
h.current && (h.current.focus(), He(h.current, o, d), de(o), ve(d));
|
|
3238
|
+
}
|
|
3239
|
+
});
|
|
3240
|
+
}, [L, Se]), p.useEffect(() => {
|
|
3241
|
+
const o = N.current;
|
|
3242
|
+
X.current.push({ value: o, cursorPos: o.length }), o && Se(o, !1);
|
|
3243
|
+
}, []), p.useEffect(() => {
|
|
3244
|
+
i !== void 0 && i !== N.current && (N.current = i, Se(i, !1));
|
|
3245
|
+
}, [i, Se]), p.useEffect(() => () => {
|
|
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();
|
|
3248
|
+
}, []), p.useEffect(() => {
|
|
3249
|
+
M === "never" && (Z(!1), se(!1), te([])), Ce.current = null;
|
|
3250
|
+
}, [M]), p.useEffect(() => {
|
|
3251
|
+
const o = () => {
|
|
3252
|
+
const d = G.current;
|
|
3253
|
+
if (!(!d.showDropdown && !d.showDatePicker))
|
|
3254
|
+
if (d.showDropdown && D && Q.current) {
|
|
3255
|
+
const E = Q.current.getBoundingClientRect();
|
|
3256
|
+
yt({
|
|
3257
|
+
top: E.bottom + window.scrollY + 4,
|
|
3258
|
+
left: E.left + window.scrollX
|
|
3259
|
+
});
|
|
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));
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
return window.addEventListener("resize", o), window.addEventListener("scroll", o, !0), () => {
|
|
3269
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", o, !0);
|
|
3270
|
+
};
|
|
3271
|
+
}, [D]);
|
|
3272
|
+
const tr = p.useRef(null), rr = p.useRef(f);
|
|
3273
|
+
p.useEffect(() => {
|
|
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);
|
|
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;
|
|
3296
|
+
}, 300), M === "input") {
|
|
3297
|
+
const b = d > 0 ? o[d - 1] : "";
|
|
3298
|
+
if (!b || b.trim() === "") {
|
|
3299
|
+
Se(o, !1), Y();
|
|
3300
|
+
return;
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
Se(o, !0);
|
|
3304
|
+
}, [Se, M, Y]), Dr = p.useCallback(() => {
|
|
3305
|
+
me.current = !0;
|
|
3306
|
+
}, []), Or = p.useCallback(() => {
|
|
3307
|
+
me.current = !1, Ne();
|
|
3308
|
+
}, [Ne]), It = p.useCallback((o) => {
|
|
3309
|
+
if (!o) return;
|
|
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;
|
|
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;
|
|
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);
|
|
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));
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
{
|
|
3332
|
+
let y = null, S = null;
|
|
3333
|
+
if (sr[o.key])
|
|
3334
|
+
y = o.key, S = sr[o.key];
|
|
3335
|
+
else if (gt && o.key === "*" && h.current) {
|
|
3336
|
+
const b = Ae(h.current);
|
|
3337
|
+
if (b.start !== b.end) {
|
|
3338
|
+
const [C, O] = ar(d.tokens, b.start, b.end);
|
|
3339
|
+
if (C >= 0 && C === O) {
|
|
3340
|
+
const k = d.tokens[C];
|
|
3341
|
+
(k.type === l.VALUE || k.type === l.WILDCARD) && (y = "*", S = "*");
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
if (y && S && h.current) {
|
|
3346
|
+
const b = Ae(h.current);
|
|
3347
|
+
if (b.start !== b.end) {
|
|
3348
|
+
o.preventDefault();
|
|
3349
|
+
const { newValue: C, newSelStart: O, newSelEnd: k } = Yr(
|
|
3350
|
+
N.current,
|
|
3351
|
+
b.start,
|
|
3352
|
+
b.end,
|
|
3353
|
+
y,
|
|
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);
|
|
3359
|
+
return;
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
if (o.key === "z" && (o.ctrlKey || o.metaKey) && !o.shiftKey) {
|
|
3364
|
+
o.preventDefault(), It(X.current.undo());
|
|
3365
|
+
return;
|
|
3366
|
+
}
|
|
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());
|
|
3369
|
+
return;
|
|
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);
|
|
3373
|
+
if (S) {
|
|
3374
|
+
o.preventDefault(), He(h.current, S.start, S.end), de(S.start), ve(S.end);
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
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;
|
|
3381
|
+
if (!S) {
|
|
3382
|
+
const C = Ae(h.current), O = Ln(d.ast, d.tokens, C.start);
|
|
3383
|
+
if (O.length === 0) return;
|
|
3384
|
+
S = { ranges: O, level: -1 }, Xe.current = S;
|
|
3385
|
+
}
|
|
3386
|
+
const b = y ? Math.min(S.level + 1, S.ranges.length - 1) : Math.max(S.level - 1, -1);
|
|
3387
|
+
if (b === S.level) return;
|
|
3388
|
+
if (S.level = b, b < 0) {
|
|
3389
|
+
const C = Ae(h.current);
|
|
3390
|
+
Ue(h.current, C.start), Xe.current = null;
|
|
3391
|
+
} else {
|
|
3392
|
+
o.preventDefault();
|
|
3393
|
+
const C = S.ranges[b];
|
|
3394
|
+
He(h.current, C.start, C.end), de(C.start), ve(C.end);
|
|
3395
|
+
}
|
|
3396
|
+
return;
|
|
3397
|
+
}
|
|
3398
|
+
if (Xe.current = null, o.key === " " && (o.ctrlKey || o.metaKey)) {
|
|
3399
|
+
if (o.preventDefault(), M === "manual") {
|
|
3400
|
+
const y = le.current.getSuggestions(d.tokens, d.cursorOffset);
|
|
3401
|
+
Ce.current = y.context.type;
|
|
3402
|
+
}
|
|
3403
|
+
ae(d.tokens, d.cursorOffset);
|
|
3404
|
+
return;
|
|
3405
|
+
}
|
|
3406
|
+
if (o.key === "Enter" && (o.ctrlKey || o.metaKey)) {
|
|
3407
|
+
o.preventDefault(), Y(), t && t(N.current, d.ast);
|
|
3408
|
+
return;
|
|
3409
|
+
}
|
|
3410
|
+
if (o.key === "Enter" && o.shiftKey && ht) {
|
|
3411
|
+
o.preventDefault(), Cn(), Ne();
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3414
|
+
if (d.showDropdown && d.suggestions.length > 0)
|
|
3415
|
+
switch (o.key) {
|
|
3416
|
+
case "ArrowDown":
|
|
3417
|
+
o.preventDefault(), xe((y) => Math.min(y + 1, d.suggestions.length - 1));
|
|
3418
|
+
return;
|
|
3419
|
+
case "ArrowUp":
|
|
3420
|
+
o.preventDefault(), xe((y) => Math.max(y - 1, -1));
|
|
3421
|
+
return;
|
|
3422
|
+
case "Enter":
|
|
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();
|
|
3427
|
+
const S = N.current, b = d.cursorOffset;
|
|
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);
|
|
3432
|
+
});
|
|
3433
|
+
} else
|
|
3434
|
+
t && t(S, d.ast);
|
|
3435
|
+
return;
|
|
3436
|
+
}
|
|
3437
|
+
o.preventDefault(), at(y, "Enter");
|
|
3438
|
+
return;
|
|
3439
|
+
}
|
|
3440
|
+
break;
|
|
3441
|
+
case "Tab": {
|
|
3442
|
+
if (T) {
|
|
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()));
|
|
3449
|
+
return;
|
|
3450
|
+
}
|
|
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();
|
|
3455
|
+
const S = N.current, b = d.cursorOffset;
|
|
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, $);
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
return;
|
|
3463
|
+
}
|
|
3464
|
+
o.preventDefault(), at(y, "Tab");
|
|
3465
|
+
return;
|
|
3466
|
+
}
|
|
3467
|
+
break;
|
|
3468
|
+
}
|
|
3469
|
+
case "Escape":
|
|
3470
|
+
o.preventDefault(), Y();
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
if (o.key === "Tab" && T) {
|
|
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());
|
|
3477
|
+
return;
|
|
3478
|
+
}
|
|
3479
|
+
if (d.showDatePicker && o.key === "Escape") {
|
|
3480
|
+
o.preventDefault(), Y();
|
|
3481
|
+
return;
|
|
3482
|
+
}
|
|
3483
|
+
if (o.key === "Enter" && !d.showDropdown && !d.showDatePicker) {
|
|
3484
|
+
o.preventDefault(), t && t(N.current, d.ast);
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
}, [t, Y, at, we, It, ht, M, ae, U, T, Te, Pe]), Lr = p.useCallback((o) => {
|
|
3488
|
+
if (["ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown"].includes(o.key)) {
|
|
3489
|
+
if (!h.current) return;
|
|
3490
|
+
const E = Ae(h.current);
|
|
3491
|
+
de(E.start), ve(E.end), Oe(G.current.tokens, E.start);
|
|
3492
|
+
}
|
|
3493
|
+
}, [Oe]), Tr = p.useCallback(() => {
|
|
3494
|
+
Zt(!0), v == null || v(), requestAnimationFrame(() => {
|
|
3495
|
+
if (h.current) {
|
|
3496
|
+
const o = G.current.tokens;
|
|
3497
|
+
if (o.length > 0) {
|
|
3498
|
+
const d = lt(h.current);
|
|
3499
|
+
Oe(o, d);
|
|
3500
|
+
} else
|
|
3501
|
+
Oe([], 0);
|
|
3502
|
+
}
|
|
3503
|
+
});
|
|
3504
|
+
}, [Ne, Oe, v]), Pr = p.useCallback(() => {
|
|
3505
|
+
Zt(!1), Z(!1), se(!1), de(-1), _ == null || _();
|
|
3506
|
+
}, [_]), Mr = p.useCallback(() => {
|
|
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();
|
|
3513
|
+
return;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
Oe(G.current.tokens, o.start);
|
|
3517
|
+
}, [Oe, Y]), Ir = p.useCallback((o) => {
|
|
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);
|
|
3523
|
+
let C = "", O = b;
|
|
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, $);
|
|
3528
|
+
});
|
|
3529
|
+
}, [we, ae]), Et = pt(f), Ft = dt(m), _r = rn(Et, H), Br = {
|
|
3530
|
+
...nn(Et, Ft),
|
|
3531
|
+
...rt ? sn(Ft) : {}
|
|
3532
|
+
}, Hr = an(Et, Ft);
|
|
3533
|
+
return /* @__PURE__ */ p.createElement("div", { ref: Q, style: _r, className: P }, /* @__PURE__ */ p.createElement(
|
|
3534
|
+
"div",
|
|
3535
|
+
{
|
|
3536
|
+
ref: ye,
|
|
3537
|
+
contentEditable: !0,
|
|
3538
|
+
suppressContentEditableWarning: !0,
|
|
3539
|
+
style: Br,
|
|
3540
|
+
onInput: Ne,
|
|
3541
|
+
onKeyDown: Nr,
|
|
3542
|
+
onKeyUp: Lr,
|
|
3543
|
+
onFocus: Tr,
|
|
3544
|
+
onBlur: Pr,
|
|
3545
|
+
onClick: Mr,
|
|
3546
|
+
onPaste: Ir,
|
|
3547
|
+
onCompositionStart: Dr,
|
|
3548
|
+
onCompositionEnd: Or,
|
|
3549
|
+
spellCheck: !1
|
|
3550
|
+
}
|
|
3551
|
+
), wr && !rt ? /* @__PURE__ */ p.createElement("div", { style: Hr }, I || "Search...") : null, /* @__PURE__ */ p.createElement(
|
|
3552
|
+
An,
|
|
3553
|
+
{
|
|
3554
|
+
errors: Nt,
|
|
3555
|
+
editorRef: V,
|
|
3556
|
+
cursorOffset: Fe,
|
|
3557
|
+
colors: f,
|
|
3558
|
+
styles: m,
|
|
3559
|
+
containerRef: Q.current
|
|
3560
|
+
}
|
|
3561
|
+
), /* @__PURE__ */ p.createElement(
|
|
3562
|
+
mn,
|
|
3563
|
+
{
|
|
3564
|
+
suggestions: At,
|
|
3565
|
+
selectedIndex: kt,
|
|
3566
|
+
onSelect: (o) => at(o, "Tab"),
|
|
3567
|
+
position: Ot,
|
|
3568
|
+
colors: f,
|
|
3569
|
+
styles: m,
|
|
3570
|
+
visible: Ct,
|
|
3571
|
+
fixedWidth: Ar(),
|
|
3572
|
+
renderHistoryItem: Le,
|
|
3573
|
+
renderSavedSearchItem: wt,
|
|
3574
|
+
renderDropdownHeader: bt,
|
|
3575
|
+
cursorContext: Lt
|
|
3576
|
+
}
|
|
3577
|
+
), Dt && Ot ? /* @__PURE__ */ p.createElement(
|
|
3578
|
+
Fn,
|
|
3579
|
+
{
|
|
3580
|
+
position: Ot,
|
|
3581
|
+
colors: Et,
|
|
3582
|
+
onSelect: Fr,
|
|
3583
|
+
colorConfig: f,
|
|
3584
|
+
styleConfig: m,
|
|
3585
|
+
datePickerInit: Rr,
|
|
3586
|
+
fixedWidth: void 0,
|
|
3587
|
+
datePresets: F
|
|
3588
|
+
}
|
|
3589
|
+
) : null);
|
|
3590
|
+
}
|
|
3591
|
+
function Wn(n) {
|
|
3592
|
+
if (!n) return [];
|
|
3593
|
+
const e = [];
|
|
3594
|
+
return ut(n, void 0, e), e;
|
|
3595
|
+
}
|
|
3596
|
+
function ut(n, e, t) {
|
|
3597
|
+
switch (n.type) {
|
|
3598
|
+
case "BareTerm":
|
|
3599
|
+
t.push({
|
|
3600
|
+
kind: e ? "group_term" : "term",
|
|
3601
|
+
value: n.value,
|
|
3602
|
+
quoted: n.quoted,
|
|
3603
|
+
fieldName: e,
|
|
3604
|
+
start: n.start,
|
|
3605
|
+
end: n.end
|
|
3606
|
+
});
|
|
3607
|
+
break;
|
|
3608
|
+
case "FieldValue":
|
|
3609
|
+
t.push({
|
|
3610
|
+
kind: "field_value",
|
|
3611
|
+
value: n.value,
|
|
3612
|
+
quoted: n.quoted,
|
|
3613
|
+
fieldName: n.field,
|
|
3614
|
+
start: n.start,
|
|
3615
|
+
end: n.end
|
|
3616
|
+
});
|
|
3617
|
+
break;
|
|
3618
|
+
case "Range": {
|
|
3619
|
+
const r = n.field || e;
|
|
3620
|
+
n.lower !== "*" && t.push({
|
|
3621
|
+
kind: "range_lower",
|
|
3622
|
+
value: n.lower,
|
|
3623
|
+
quoted: n.lowerQuoted,
|
|
3624
|
+
fieldName: r,
|
|
3625
|
+
start: n.lowerStart,
|
|
3626
|
+
end: n.lowerEnd
|
|
3627
|
+
}), n.upper !== "*" && t.push({
|
|
3628
|
+
kind: "range_upper",
|
|
3629
|
+
value: n.upper,
|
|
3630
|
+
quoted: n.upperQuoted,
|
|
3631
|
+
fieldName: r,
|
|
3632
|
+
start: n.upperStart,
|
|
3633
|
+
end: n.upperEnd
|
|
3634
|
+
});
|
|
3635
|
+
break;
|
|
3636
|
+
}
|
|
3637
|
+
case "Regex":
|
|
3638
|
+
t.push({
|
|
3639
|
+
kind: "regex",
|
|
3640
|
+
value: n.pattern,
|
|
3641
|
+
quoted: !1,
|
|
3642
|
+
start: n.start,
|
|
3643
|
+
end: n.end
|
|
3644
|
+
});
|
|
3645
|
+
break;
|
|
3646
|
+
case "FieldGroup":
|
|
3647
|
+
ut(n.expression, n.field, t);
|
|
3648
|
+
break;
|
|
3649
|
+
case "BooleanExpr":
|
|
3650
|
+
ut(n.left, e, t), ut(n.right, e, t);
|
|
3651
|
+
break;
|
|
3652
|
+
case "Group":
|
|
3653
|
+
case "Not":
|
|
3654
|
+
ut(n.expression, e, t);
|
|
3655
|
+
break;
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
export {
|
|
3659
|
+
ir as AutocompleteEngine,
|
|
3660
|
+
Bn as DARK_COLORS,
|
|
3661
|
+
Hn as DARK_STYLES,
|
|
3662
|
+
zr as DEFAULT_COLORS,
|
|
3663
|
+
Er as DEFAULT_STYLES,
|
|
3664
|
+
Un as ElasticInput,
|
|
3665
|
+
ct as Lexer,
|
|
3666
|
+
We as Parser,
|
|
3667
|
+
lr as Validator,
|
|
3668
|
+
ot as buildHighlightedHTML,
|
|
3669
|
+
Wn as extractValues
|
|
3670
|
+
};
|