@wral/studio.ui.search-filter 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.
@@ -0,0 +1,1603 @@
1
+ const J = globalThis, ct = J.ShadowRoot && (J.ShadyCSS === void 0 || J.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, ht = /* @__PURE__ */ Symbol(), vt = /* @__PURE__ */ new WeakMap();
2
+ let Ft = class {
3
+ constructor(t, e, i) {
4
+ if (this._$cssResult$ = !0, i !== ht) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
5
+ this.cssText = t, this.t = e;
6
+ }
7
+ get styleSheet() {
8
+ let t = this.o;
9
+ const e = this.t;
10
+ if (ct && t === void 0) {
11
+ const i = e !== void 0 && e.length === 1;
12
+ i && (t = vt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && vt.set(e, t));
13
+ }
14
+ return t;
15
+ }
16
+ toString() {
17
+ return this.cssText;
18
+ }
19
+ };
20
+ const te = (n) => new Ft(typeof n == "string" ? n : n + "", void 0, ht), ee = (n, ...t) => {
21
+ const e = n.length === 1 ? n[0] : t.reduce((i, s, o) => i + ((r) => {
22
+ if (r._$cssResult$ === !0) return r.cssText;
23
+ if (typeof r == "number") return r;
24
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + r + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
25
+ })(s) + n[o + 1], n[0]);
26
+ return new Ft(e, n, ht);
27
+ }, ie = (n, t) => {
28
+ if (ct) n.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
29
+ else for (const e of t) {
30
+ const i = document.createElement("style"), s = J.litNonce;
31
+ s !== void 0 && i.setAttribute("nonce", s), i.textContent = e.cssText, n.appendChild(i);
32
+ }
33
+ }, yt = ct ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((t) => {
34
+ let e = "";
35
+ for (const i of t.cssRules) e += i.cssText;
36
+ return te(e);
37
+ })(n) : n;
38
+ const { is: se, defineProperty: ne, getOwnPropertyDescriptor: oe, getOwnPropertyNames: re, getOwnPropertySymbols: le, getPrototypeOf: ae } = Object, it = globalThis, wt = it.trustedTypes, de = wt ? wt.emptyScript : "", ue = it.reactiveElementPolyfillSupport, V = (n, t) => n, dt = { toAttribute(n, t) {
39
+ switch (t) {
40
+ case Boolean:
41
+ n = n ? de : null;
42
+ break;
43
+ case Object:
44
+ case Array:
45
+ n = n == null ? n : JSON.stringify(n);
46
+ }
47
+ return n;
48
+ }, fromAttribute(n, t) {
49
+ let e = n;
50
+ switch (t) {
51
+ case Boolean:
52
+ e = n !== null;
53
+ break;
54
+ case Number:
55
+ e = n === null ? null : Number(n);
56
+ break;
57
+ case Object:
58
+ case Array:
59
+ try {
60
+ e = JSON.parse(n);
61
+ } catch {
62
+ e = null;
63
+ }
64
+ }
65
+ return e;
66
+ } }, jt = (n, t) => !se(n, t), At = { attribute: !0, type: String, converter: dt, reflect: !1, useDefault: !1, hasChanged: jt };
67
+ Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), it.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
68
+ let I = class extends HTMLElement {
69
+ static addInitializer(t) {
70
+ this._$Ei(), (this.l ??= []).push(t);
71
+ }
72
+ static get observedAttributes() {
73
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
74
+ }
75
+ static createProperty(t, e = At) {
76
+ if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
77
+ const i = /* @__PURE__ */ Symbol(), s = this.getPropertyDescriptor(t, i, e);
78
+ s !== void 0 && ne(this.prototype, t, s);
79
+ }
80
+ }
81
+ static getPropertyDescriptor(t, e, i) {
82
+ const { get: s, set: o } = oe(this.prototype, t) ?? { get() {
83
+ return this[e];
84
+ }, set(r) {
85
+ this[e] = r;
86
+ } };
87
+ return { get: s, set(r) {
88
+ const u = s?.call(this);
89
+ o?.call(this, r), this.requestUpdate(t, u, i);
90
+ }, configurable: !0, enumerable: !0 };
91
+ }
92
+ static getPropertyOptions(t) {
93
+ return this.elementProperties.get(t) ?? At;
94
+ }
95
+ static _$Ei() {
96
+ if (this.hasOwnProperty(V("elementProperties"))) return;
97
+ const t = ae(this);
98
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
99
+ }
100
+ static finalize() {
101
+ if (this.hasOwnProperty(V("finalized"))) return;
102
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(V("properties"))) {
103
+ const e = this.properties, i = [...re(e), ...le(e)];
104
+ for (const s of i) this.createProperty(s, e[s]);
105
+ }
106
+ const t = this[Symbol.metadata];
107
+ if (t !== null) {
108
+ const e = litPropertyMetadata.get(t);
109
+ if (e !== void 0) for (const [i, s] of e) this.elementProperties.set(i, s);
110
+ }
111
+ this._$Eh = /* @__PURE__ */ new Map();
112
+ for (const [e, i] of this.elementProperties) {
113
+ const s = this._$Eu(e, i);
114
+ s !== void 0 && this._$Eh.set(s, e);
115
+ }
116
+ this.elementStyles = this.finalizeStyles(this.styles);
117
+ }
118
+ static finalizeStyles(t) {
119
+ const e = [];
120
+ if (Array.isArray(t)) {
121
+ const i = new Set(t.flat(1 / 0).reverse());
122
+ for (const s of i) e.unshift(yt(s));
123
+ } else t !== void 0 && e.push(yt(t));
124
+ return e;
125
+ }
126
+ static _$Eu(t, e) {
127
+ const i = e.attribute;
128
+ return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
129
+ }
130
+ constructor() {
131
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
132
+ }
133
+ _$Ev() {
134
+ this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t) => t(this));
135
+ }
136
+ addController(t) {
137
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
138
+ }
139
+ removeController(t) {
140
+ this._$EO?.delete(t);
141
+ }
142
+ _$E_() {
143
+ const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
144
+ for (const i of e.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
145
+ t.size > 0 && (this._$Ep = t);
146
+ }
147
+ createRenderRoot() {
148
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
149
+ return ie(t, this.constructor.elementStyles), t;
150
+ }
151
+ connectedCallback() {
152
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((t) => t.hostConnected?.());
153
+ }
154
+ enableUpdating(t) {
155
+ }
156
+ disconnectedCallback() {
157
+ this._$EO?.forEach((t) => t.hostDisconnected?.());
158
+ }
159
+ attributeChangedCallback(t, e, i) {
160
+ this._$AK(t, i);
161
+ }
162
+ _$ET(t, e) {
163
+ const i = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, i);
164
+ if (s !== void 0 && i.reflect === !0) {
165
+ const o = (i.converter?.toAttribute !== void 0 ? i.converter : dt).toAttribute(e, i.type);
166
+ this._$Em = t, o == null ? this.removeAttribute(s) : this.setAttribute(s, o), this._$Em = null;
167
+ }
168
+ }
169
+ _$AK(t, e) {
170
+ const i = this.constructor, s = i._$Eh.get(t);
171
+ if (s !== void 0 && this._$Em !== s) {
172
+ const o = i.getPropertyOptions(s), r = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : dt;
173
+ this._$Em = s;
174
+ const u = r.fromAttribute(e, o.type);
175
+ this[s] = u ?? this._$Ej?.get(s) ?? u, this._$Em = null;
176
+ }
177
+ }
178
+ requestUpdate(t, e, i, s = !1, o) {
179
+ if (t !== void 0) {
180
+ const r = this.constructor;
181
+ if (s === !1 && (o = this[t]), i ??= r.getPropertyOptions(t), !((i.hasChanged ?? jt)(o, e) || i.useDefault && i.reflect && o === this._$Ej?.get(t) && !this.hasAttribute(r._$Eu(t, i)))) return;
182
+ this.C(t, e, i);
183
+ }
184
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
185
+ }
186
+ C(t, e, { useDefault: i, reflect: s, wrapped: o }, r) {
187
+ i && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, r ?? e ?? this[t]), o !== !0 || r !== void 0) || (this._$AL.has(t) || (this.hasUpdated || i || (e = void 0), this._$AL.set(t, e)), s === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
188
+ }
189
+ async _$EP() {
190
+ this.isUpdatePending = !0;
191
+ try {
192
+ await this._$ES;
193
+ } catch (e) {
194
+ Promise.reject(e);
195
+ }
196
+ const t = this.scheduleUpdate();
197
+ return t != null && await t, !this.isUpdatePending;
198
+ }
199
+ scheduleUpdate() {
200
+ return this.performUpdate();
201
+ }
202
+ performUpdate() {
203
+ if (!this.isUpdatePending) return;
204
+ if (!this.hasUpdated) {
205
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
206
+ for (const [s, o] of this._$Ep) this[s] = o;
207
+ this._$Ep = void 0;
208
+ }
209
+ const i = this.constructor.elementProperties;
210
+ if (i.size > 0) for (const [s, o] of i) {
211
+ const { wrapped: r } = o, u = this[s];
212
+ r !== !0 || this._$AL.has(s) || u === void 0 || this.C(s, void 0, o, u);
213
+ }
214
+ }
215
+ let t = !1;
216
+ const e = this._$AL;
217
+ try {
218
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), this._$EO?.forEach((i) => i.hostUpdate?.()), this.update(e)) : this._$EM();
219
+ } catch (i) {
220
+ throw t = !1, this._$EM(), i;
221
+ }
222
+ t && this._$AE(e);
223
+ }
224
+ willUpdate(t) {
225
+ }
226
+ _$AE(t) {
227
+ this._$EO?.forEach((e) => e.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
228
+ }
229
+ _$EM() {
230
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
231
+ }
232
+ get updateComplete() {
233
+ return this.getUpdateComplete();
234
+ }
235
+ getUpdateComplete() {
236
+ return this._$ES;
237
+ }
238
+ shouldUpdate(t) {
239
+ return !0;
240
+ }
241
+ update(t) {
242
+ this._$Eq &&= this._$Eq.forEach((e) => this._$ET(e, this[e])), this._$EM();
243
+ }
244
+ updated(t) {
245
+ }
246
+ firstUpdated(t) {
247
+ }
248
+ };
249
+ I.elementStyles = [], I.shadowRootOptions = { mode: "open" }, I[V("elementProperties")] = /* @__PURE__ */ new Map(), I[V("finalized")] = /* @__PURE__ */ new Map(), ue?.({ ReactiveElement: I }), (it.reactiveElementVersions ??= []).push("2.1.2");
250
+ const pt = globalThis, xt = (n) => n, tt = pt.trustedTypes, Et = tt ? tt.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, Vt = "$lit$", O = `lit$${Math.random().toFixed(9).slice(2)}$`, Wt = "?" + O, ce = `<${Wt}>`, R = document, G = () => R.createComment(""), Q = (n) => n === null || typeof n != "object" && typeof n != "function", ft = Array.isArray, he = (n) => ft(n) || typeof n?.[Symbol.iterator] == "function", ot = `[
251
+ \f\r]`, F = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, St = /-->/g, kt = />/g, T = RegExp(`>|${ot}(?:([^\\s"'>=/]+)(${ot}*=${ot}*(?:[^
252
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Ot = /'/g, Tt = /"/g, qt = /^(?:script|style|textarea|title)$/i, pe = (n) => (t, ...e) => ({ _$litType$: n, strings: t, values: e }), g = pe(1), N = /* @__PURE__ */ Symbol.for("lit-noChange"), _ = /* @__PURE__ */ Symbol.for("lit-nothing"), Ct = /* @__PURE__ */ new WeakMap(), P = R.createTreeWalker(R, 129);
253
+ function Gt(n, t) {
254
+ if (!ft(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array");
255
+ return Et !== void 0 ? Et.createHTML(t) : t;
256
+ }
257
+ const fe = (n, t) => {
258
+ const e = n.length - 1, i = [];
259
+ let s, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", r = F;
260
+ for (let u = 0; u < e; u++) {
261
+ const a = n[u];
262
+ let p, d, c = -1, f = 0;
263
+ for (; f < a.length && (r.lastIndex = f, d = r.exec(a), d !== null); ) f = r.lastIndex, r === F ? d[1] === "!--" ? r = St : d[1] !== void 0 ? r = kt : d[2] !== void 0 ? (qt.test(d[2]) && (s = RegExp("</" + d[2], "g")), r = T) : d[3] !== void 0 && (r = T) : r === T ? d[0] === ">" ? (r = s ?? F, c = -1) : d[1] === void 0 ? c = -2 : (c = r.lastIndex - d[2].length, p = d[1], r = d[3] === void 0 ? T : d[3] === '"' ? Tt : Ot) : r === Tt || r === Ot ? r = T : r === St || r === kt ? r = F : (r = T, s = void 0);
264
+ const $ = r === T && n[u + 1].startsWith("/>") ? " " : "";
265
+ o += r === F ? a + ce : c >= 0 ? (i.push(p), a.slice(0, c) + Vt + a.slice(c) + O + $) : a + O + (c === -2 ? u : $);
266
+ }
267
+ return [Gt(n, o + (n[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), i];
268
+ };
269
+ class Z {
270
+ constructor({ strings: t, _$litType$: e }, i) {
271
+ let s;
272
+ this.parts = [];
273
+ let o = 0, r = 0;
274
+ const u = t.length - 1, a = this.parts, [p, d] = fe(t, e);
275
+ if (this.el = Z.createElement(p, i), P.currentNode = this.el.content, e === 2 || e === 3) {
276
+ const c = this.el.content.firstChild;
277
+ c.replaceWith(...c.childNodes);
278
+ }
279
+ for (; (s = P.nextNode()) !== null && a.length < u; ) {
280
+ if (s.nodeType === 1) {
281
+ if (s.hasAttributes()) for (const c of s.getAttributeNames()) if (c.endsWith(Vt)) {
282
+ const f = d[r++], $ = s.getAttribute(c).split(O), y = /([.?@])?(.*)/.exec(f);
283
+ a.push({ type: 1, index: o, name: y[2], strings: $, ctor: y[1] === "." ? ge : y[1] === "?" ? me : y[1] === "@" ? _e : st }), s.removeAttribute(c);
284
+ } else c.startsWith(O) && (a.push({ type: 6, index: o }), s.removeAttribute(c));
285
+ if (qt.test(s.tagName)) {
286
+ const c = s.textContent.split(O), f = c.length - 1;
287
+ if (f > 0) {
288
+ s.textContent = tt ? tt.emptyScript : "";
289
+ for (let $ = 0; $ < f; $++) s.append(c[$], G()), P.nextNode(), a.push({ type: 2, index: ++o });
290
+ s.append(c[f], G());
291
+ }
292
+ }
293
+ } else if (s.nodeType === 8) if (s.data === Wt) a.push({ type: 2, index: o });
294
+ else {
295
+ let c = -1;
296
+ for (; (c = s.data.indexOf(O, c + 1)) !== -1; ) a.push({ type: 7, index: o }), c += O.length - 1;
297
+ }
298
+ o++;
299
+ }
300
+ }
301
+ static createElement(t, e) {
302
+ const i = R.createElement("template");
303
+ return i.innerHTML = t, i;
304
+ }
305
+ }
306
+ function M(n, t, e = n, i) {
307
+ if (t === N) return t;
308
+ let s = i !== void 0 ? e._$Co?.[i] : e._$Cl;
309
+ const o = Q(t) ? void 0 : t._$litDirective$;
310
+ return s?.constructor !== o && (s?._$AO?.(!1), o === void 0 ? s = void 0 : (s = new o(n), s._$AT(n, e, i)), i !== void 0 ? (e._$Co ??= [])[i] = s : e._$Cl = s), s !== void 0 && (t = M(n, s._$AS(n, t.values), s, i)), t;
311
+ }
312
+ class $e {
313
+ constructor(t, e) {
314
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
315
+ }
316
+ get parentNode() {
317
+ return this._$AM.parentNode;
318
+ }
319
+ get _$AU() {
320
+ return this._$AM._$AU;
321
+ }
322
+ u(t) {
323
+ const { el: { content: e }, parts: i } = this._$AD, s = (t?.creationScope ?? R).importNode(e, !0);
324
+ P.currentNode = s;
325
+ let o = P.nextNode(), r = 0, u = 0, a = i[0];
326
+ for (; a !== void 0; ) {
327
+ if (r === a.index) {
328
+ let p;
329
+ a.type === 2 ? p = new B(o, o.nextSibling, this, t) : a.type === 1 ? p = new a.ctor(o, a.name, a.strings, this, t) : a.type === 6 && (p = new be(o, this, t)), this._$AV.push(p), a = i[++u];
330
+ }
331
+ r !== a?.index && (o = P.nextNode(), r++);
332
+ }
333
+ return P.currentNode = R, s;
334
+ }
335
+ p(t) {
336
+ let e = 0;
337
+ for (const i of this._$AV) i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
338
+ }
339
+ }
340
+ class B {
341
+ get _$AU() {
342
+ return this._$AM?._$AU ?? this._$Cv;
343
+ }
344
+ constructor(t, e, i, s) {
345
+ this.type = 2, this._$AH = _, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cv = s?.isConnected ?? !0;
346
+ }
347
+ get parentNode() {
348
+ let t = this._$AA.parentNode;
349
+ const e = this._$AM;
350
+ return e !== void 0 && t?.nodeType === 11 && (t = e.parentNode), t;
351
+ }
352
+ get startNode() {
353
+ return this._$AA;
354
+ }
355
+ get endNode() {
356
+ return this._$AB;
357
+ }
358
+ _$AI(t, e = this) {
359
+ t = M(this, t, e), Q(t) ? t === _ || t == null || t === "" ? (this._$AH !== _ && this._$AR(), this._$AH = _) : t !== this._$AH && t !== N && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : he(t) ? this.k(t) : this._(t);
360
+ }
361
+ O(t) {
362
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
363
+ }
364
+ T(t) {
365
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
366
+ }
367
+ _(t) {
368
+ this._$AH !== _ && Q(this._$AH) ? this._$AA.nextSibling.data = t : this.T(R.createTextNode(t)), this._$AH = t;
369
+ }
370
+ $(t) {
371
+ const { values: e, _$litType$: i } = t, s = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = Z.createElement(Gt(i.h, i.h[0]), this.options)), i);
372
+ if (this._$AH?._$AD === s) this._$AH.p(e);
373
+ else {
374
+ const o = new $e(s, this), r = o.u(this.options);
375
+ o.p(e), this.T(r), this._$AH = o;
376
+ }
377
+ }
378
+ _$AC(t) {
379
+ let e = Ct.get(t.strings);
380
+ return e === void 0 && Ct.set(t.strings, e = new Z(t)), e;
381
+ }
382
+ k(t) {
383
+ ft(this._$AH) || (this._$AH = [], this._$AR());
384
+ const e = this._$AH;
385
+ let i, s = 0;
386
+ for (const o of t) s === e.length ? e.push(i = new B(this.O(G()), this.O(G()), this, this.options)) : i = e[s], i._$AI(o), s++;
387
+ s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
388
+ }
389
+ _$AR(t = this._$AA.nextSibling, e) {
390
+ for (this._$AP?.(!1, !0, e); t !== this._$AB; ) {
391
+ const i = xt(t).nextSibling;
392
+ xt(t).remove(), t = i;
393
+ }
394
+ }
395
+ setConnected(t) {
396
+ this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
397
+ }
398
+ }
399
+ class st {
400
+ get tagName() {
401
+ return this.element.tagName;
402
+ }
403
+ get _$AU() {
404
+ return this._$AM._$AU;
405
+ }
406
+ constructor(t, e, i, s, o) {
407
+ this.type = 1, this._$AH = _, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = o, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = _;
408
+ }
409
+ _$AI(t, e = this, i, s) {
410
+ const o = this.strings;
411
+ let r = !1;
412
+ if (o === void 0) t = M(this, t, e, 0), r = !Q(t) || t !== this._$AH && t !== N, r && (this._$AH = t);
413
+ else {
414
+ const u = t;
415
+ let a, p;
416
+ for (t = o[0], a = 0; a < o.length - 1; a++) p = M(this, u[i + a], e, a), p === N && (p = this._$AH[a]), r ||= !Q(p) || p !== this._$AH[a], p === _ ? t = _ : t !== _ && (t += (p ?? "") + o[a + 1]), this._$AH[a] = p;
417
+ }
418
+ r && !s && this.j(t);
419
+ }
420
+ j(t) {
421
+ t === _ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
422
+ }
423
+ }
424
+ class ge extends st {
425
+ constructor() {
426
+ super(...arguments), this.type = 3;
427
+ }
428
+ j(t) {
429
+ this.element[this.name] = t === _ ? void 0 : t;
430
+ }
431
+ }
432
+ class me extends st {
433
+ constructor() {
434
+ super(...arguments), this.type = 4;
435
+ }
436
+ j(t) {
437
+ this.element.toggleAttribute(this.name, !!t && t !== _);
438
+ }
439
+ }
440
+ class _e extends st {
441
+ constructor(t, e, i, s, o) {
442
+ super(t, e, i, s, o), this.type = 5;
443
+ }
444
+ _$AI(t, e = this) {
445
+ if ((t = M(this, t, e, 0) ?? _) === N) return;
446
+ const i = this._$AH, s = t === _ && i !== _ || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, o = t !== _ && (i === _ || s);
447
+ s && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
448
+ }
449
+ handleEvent(t) {
450
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
451
+ }
452
+ }
453
+ class be {
454
+ constructor(t, e, i) {
455
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
456
+ }
457
+ get _$AU() {
458
+ return this._$AM._$AU;
459
+ }
460
+ _$AI(t) {
461
+ M(this, t);
462
+ }
463
+ }
464
+ const ve = { I: B }, ye = pt.litHtmlPolyfillSupport;
465
+ ye?.(Z, B), (pt.litHtmlVersions ??= []).push("3.3.3");
466
+ const we = (n, t, e) => {
467
+ const i = e?.renderBefore ?? t;
468
+ let s = i._$litPart$;
469
+ if (s === void 0) {
470
+ const o = e?.renderBefore ?? null;
471
+ i._$litPart$ = s = new B(t.insertBefore(G(), o), o, void 0, e ?? {});
472
+ }
473
+ return s._$AI(n), s;
474
+ };
475
+ const $t = globalThis;
476
+ let W = class extends I {
477
+ constructor() {
478
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
479
+ }
480
+ createRenderRoot() {
481
+ const t = super.createRenderRoot();
482
+ return this.renderOptions.renderBefore ??= t.firstChild, t;
483
+ }
484
+ update(t) {
485
+ const e = this.render();
486
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = we(e, this.renderRoot, this.renderOptions);
487
+ }
488
+ connectedCallback() {
489
+ super.connectedCallback(), this._$Do?.setConnected(!0);
490
+ }
491
+ disconnectedCallback() {
492
+ super.disconnectedCallback(), this._$Do?.setConnected(!1);
493
+ }
494
+ render() {
495
+ return N;
496
+ }
497
+ };
498
+ W._$litElement$ = !0, W.finalized = !0, $t.litElementHydrateSupport?.({ LitElement: W });
499
+ const Ae = $t.litElementPolyfillSupport;
500
+ Ae?.({ LitElement: W });
501
+ ($t.litElementVersions ??= []).push("4.2.2");
502
+ const xe = { CHILD: 2 }, Ee = (n) => (...t) => ({ _$litDirective$: n, values: t });
503
+ let Se = class {
504
+ constructor(t) {
505
+ }
506
+ get _$AU() {
507
+ return this._$AM._$AU;
508
+ }
509
+ _$AT(t, e, i) {
510
+ this._$Ct = t, this._$AM = e, this._$Ci = i;
511
+ }
512
+ _$AS(t, e) {
513
+ return this.update(t, e);
514
+ }
515
+ update(t, e) {
516
+ return this.render(...e);
517
+ }
518
+ };
519
+ const { I: ke } = ve, Pt = (n) => n, Rt = () => document.createComment(""), j = (n, t, e) => {
520
+ const i = n._$AA.parentNode, s = t === void 0 ? n._$AB : t._$AA;
521
+ if (e === void 0) {
522
+ const o = i.insertBefore(Rt(), s), r = i.insertBefore(Rt(), s);
523
+ e = new ke(o, r, n, n.options);
524
+ } else {
525
+ const o = e._$AB.nextSibling, r = e._$AM, u = r !== n;
526
+ if (u) {
527
+ let a;
528
+ e._$AQ?.(n), e._$AM = n, e._$AP !== void 0 && (a = n._$AU) !== r._$AU && e._$AP(a);
529
+ }
530
+ if (o !== s || u) {
531
+ let a = e._$AA;
532
+ for (; a !== o; ) {
533
+ const p = Pt(a).nextSibling;
534
+ Pt(i).insertBefore(a, s), a = p;
535
+ }
536
+ }
537
+ }
538
+ return e;
539
+ }, C = (n, t, e = n) => (n._$AI(t, e), n), Oe = {}, Te = (n, t = Oe) => n._$AH = t, Ce = (n) => n._$AH, rt = (n) => {
540
+ n._$AR(), n._$AA.remove();
541
+ };
542
+ const Nt = (n, t, e) => {
543
+ const i = /* @__PURE__ */ new Map();
544
+ for (let s = t; s <= e; s++) i.set(n[s], s);
545
+ return i;
546
+ }, Ut = Ee(class extends Se {
547
+ constructor(n) {
548
+ if (super(n), n.type !== xe.CHILD) throw Error("repeat() can only be used in text expressions");
549
+ }
550
+ dt(n, t, e) {
551
+ let i;
552
+ e === void 0 ? e = t : t !== void 0 && (i = t);
553
+ const s = [], o = [];
554
+ let r = 0;
555
+ for (const u of n) s[r] = i ? i(u, r) : r, o[r] = e(u, r), r++;
556
+ return { values: o, keys: s };
557
+ }
558
+ render(n, t, e) {
559
+ return this.dt(n, t, e).values;
560
+ }
561
+ update(n, [t, e, i]) {
562
+ const s = Ce(n), { values: o, keys: r } = this.dt(t, e, i);
563
+ if (!Array.isArray(s)) return this.ut = r, o;
564
+ const u = this.ut ??= [], a = [];
565
+ let p, d, c = 0, f = s.length - 1, $ = 0, y = o.length - 1;
566
+ for (; c <= f && $ <= y; ) if (s[c] === null) c++;
567
+ else if (s[f] === null) f--;
568
+ else if (u[c] === r[$]) a[$] = C(s[c], o[$]), c++, $++;
569
+ else if (u[f] === r[y]) a[y] = C(s[f], o[y]), f--, y--;
570
+ else if (u[c] === r[y]) a[y] = C(s[c], o[y]), j(n, a[y + 1], s[c]), c++, y--;
571
+ else if (u[f] === r[$]) a[$] = C(s[f], o[$]), j(n, s[c], s[f]), f--, $++;
572
+ else if (p === void 0 && (p = Nt(r, $, y), d = Nt(u, c, f)), p.has(u[c])) if (p.has(u[f])) {
573
+ const E = d.get(r[$]), U = E !== void 0 ? s[E] : null;
574
+ if (U === null) {
575
+ const K = j(n, s[c]);
576
+ C(K, o[$]), a[$] = K;
577
+ } else a[$] = C(U, o[$]), j(n, s[c], U), s[E] = null;
578
+ $++;
579
+ } else rt(s[f]), f--;
580
+ else rt(s[c]), c++;
581
+ for (; $ <= y; ) {
582
+ const E = j(n, a[y + 1]);
583
+ C(E, o[$]), a[$++] = E;
584
+ }
585
+ for (; c <= f; ) {
586
+ const E = s[c++];
587
+ E !== null && rt(E);
588
+ }
589
+ return this.ut = r, Te(n, a), N;
590
+ }
591
+ }), zt = {
592
+ fields: {
593
+ tag: {
594
+ label: "Tag",
595
+ path: "tags.name",
596
+ type: "text",
597
+ hint: "e.g. UNC sports"
598
+ },
599
+ title: {
600
+ label: "Headline",
601
+ path: "metadata.title",
602
+ type: "text",
603
+ hint: "e.g. hurricane"
604
+ },
605
+ body: {
606
+ label: "Summary",
607
+ path: "metadata.description",
608
+ type: "text",
609
+ hint: "e.g. storm damage"
610
+ },
611
+ author: {
612
+ label: "Author",
613
+ path: "metadata.author",
614
+ type: "text",
615
+ hint: "e.g. Brian Murphy"
616
+ },
617
+ uri: {
618
+ label: "Article URL",
619
+ path: "uri",
620
+ type: "url",
621
+ hint: "e.g. https://www.wral.com/sports/"
622
+ },
623
+ site: {
624
+ label: "Site",
625
+ path: "site",
626
+ type: "text",
627
+ hint: "e.g. highschoolot.com"
628
+ },
629
+ date: {
630
+ label: "Published",
631
+ path: "metadata.articlePublishedTime",
632
+ type: "date"
633
+ },
634
+ updated: {
635
+ label: "Updated",
636
+ path: "metadata.articleModifiedTime",
637
+ type: "date"
638
+ },
639
+ // combined hero-video field: "has a video" tests
640
+ // _exists_:metadata.ogVideo, the duration ops filter
641
+ // metadata.ogVideoDuration (seconds).
642
+ video: {
643
+ label: "Has hero video",
644
+ path: "metadata.ogVideo",
645
+ type: "video",
646
+ durationPath: "metadata.ogVideoDuration",
647
+ hint: "duration in seconds, e.g. 60"
648
+ },
649
+ // the default search field: a bare term with no `field:` prefix,
650
+ // matching the backend's full-text default. Used for legacy
651
+ // bare-phrase queries.
652
+ any: {
653
+ label: "Any field",
654
+ path: "",
655
+ type: "text",
656
+ hint: "e.g. hurricane"
657
+ }
658
+ },
659
+ defaults: {
660
+ field: "title",
661
+ conditional: {
662
+ if: { field: "tag", op: "term" },
663
+ then: { field: "uri", op: "under", negate: !0 },
664
+ else: { field: "uri", op: "under" }
665
+ }
666
+ }
667
+ }, Pe = [
668
+ { id: "phrase", label: "contains the phrase" },
669
+ { id: "term", label: "matches the word" },
670
+ { id: "starts", label: "starts with" },
671
+ { id: "fuzzy", label: "sounds like (fuzzy)" },
672
+ { id: "exists", label: "has any value" }
673
+ ], Re = [
674
+ { id: "is", label: "is exactly" },
675
+ { id: "under", label: "is anywhere under" }
676
+ ], Ne = [
677
+ { id: "after", label: "is on or after" },
678
+ { id: "before", label: "is on or before" },
679
+ { id: "between", label: "is between" }
680
+ ], Ue = [
681
+ { id: "gte", label: "is at least" },
682
+ { id: "lte", label: "is at most" },
683
+ { id: "between", label: "is between" }
684
+ ], ze = [
685
+ { id: "exists", label: "has a video" },
686
+ { id: "longer", label: "is longer than (sec)" },
687
+ { id: "shorter", label: "is shorter than (sec)" },
688
+ { id: "between", label: "duration between (sec)" }
689
+ ], X = {
690
+ text: Pe,
691
+ url: Re,
692
+ date: Ne,
693
+ number: Ue,
694
+ video: ze
695
+ }, Dt = [
696
+ { id: "AND", label: "all" },
697
+ { id: "OR", label: "any" }
698
+ ], S = (n) => {
699
+ throw new Error(`search-filter: ${n}`);
700
+ };
701
+ function It(n, t, e) {
702
+ const i = new Set(X[t].map((s) => s.id));
703
+ return (!Array.isArray(n) || !n.length) && S(`${e} must be a non-empty array of { id, label }`), n.map((s) => ((!s || !i.has(s.id)) && S(`${e} has unknown ${t} operator id "${s && s.id}" (known: ${[...i].join(", ")})`), { id: s.id, label: s.label || s.id }));
704
+ }
705
+ function De(n, t = {}) {
706
+ const e = Object.keys(n || {});
707
+ e.length || S("the fields catalog is empty");
708
+ const i = {};
709
+ for (const s of e) {
710
+ const o = n[s] || {}, r = o.type || "text";
711
+ X[r] || S(`field "${s}" has unknown type "${r}" (known: ${Object.keys(X).join(", ")})`), typeof o.path != "string" && S(`field "${s}" needs a string path ('' targets the backend's default field)`), r === "video" && !o.durationPath && S(`field "${s}" is type video and needs a durationPath`);
712
+ const u = o.ops ? It(o.ops, r, `field "${s}" ops`) : t[r] ? It(t[r], r, `operators.${r}`) : X[r];
713
+ i[s] = {
714
+ label: o.label || s,
715
+ path: o.path,
716
+ type: r,
717
+ hint: o.hint || "",
718
+ durationPath: o.durationPath || "",
719
+ ops: u
720
+ };
721
+ }
722
+ return i;
723
+ }
724
+ function Ie(n) {
725
+ if (n == null) return Dt;
726
+ const t = new Set(Dt.map((e) => e.id));
727
+ return (!Array.isArray(n) || !n.length) && S("booleans must be a non-empty array of { id, label }"), n.map((e) => ((!e || !t.has(e.id)) && S(`unknown boolean operator "${e && e.id}" (known: AND, OR)`), { id: e.id, label: e.label || e.id }));
728
+ }
729
+ let Me = 0;
730
+ const q = () => "n" + ++Me, Y = (n) => String(n).replace(/(["\\])/g, "\\$1"), lt = (n) => Y(n).replace(/\s+/g, "\\ ");
731
+ function ut(n) {
732
+ const t = [];
733
+ let e = 0;
734
+ const i = n.length;
735
+ for (; e < i; ) {
736
+ const s = n[e];
737
+ if (s === " " || s === " " || s === `
738
+ `) {
739
+ e++;
740
+ continue;
741
+ }
742
+ if (s === "(" || s === ")") {
743
+ t.push(s), e++;
744
+ continue;
745
+ }
746
+ let o = "";
747
+ for (; e < i; ) {
748
+ const r = n[e];
749
+ if (r === "\\" && e + 1 < i) {
750
+ o += r + n[e + 1], e += 2;
751
+ continue;
752
+ }
753
+ if (r === " " || r === "(" || r === ")") break;
754
+ if (r === '"') {
755
+ for (o += r, e++; e < i; ) {
756
+ if (o += n[e], n[e] === '"' && n[e - 1] !== "\\") {
757
+ e++;
758
+ break;
759
+ }
760
+ e++;
761
+ }
762
+ continue;
763
+ }
764
+ if (r === "[") {
765
+ for (o += r, e++; e < i; ) {
766
+ if (o += n[e], n[e] === "]") {
767
+ e++;
768
+ break;
769
+ }
770
+ e++;
771
+ }
772
+ continue;
773
+ }
774
+ o += r, e++;
775
+ }
776
+ o === "AND" || o === "OR" || o === "NOT" ? t.push(o) : o === "&&" ? t.push("AND") : o === "||" ? t.push("OR") : t.push({ term: o });
777
+ }
778
+ return t;
779
+ }
780
+ function at(n, t) {
781
+ if (n.startsWith("[")) {
782
+ const o = n.match(/^\[(.+) TO (.+)\]$/) || [null, "*", "*"], r = o[1], u = o[2];
783
+ return r === "*" ? { op: t === "number" ? "lte" : "before", value: u } : u === "*" ? { op: t === "number" ? "gte" : "after", value: r } : { op: "between", value: r, value2: u };
784
+ }
785
+ if (n.startsWith('"'))
786
+ return {
787
+ op: t === "url" ? "under" : "phrase",
788
+ value: n.slice(1, -1).replace(/\\(.)/g, "$1")
789
+ };
790
+ let e = n, i = "";
791
+ return e.endsWith("*") ? (i = "*", e = e.slice(0, -1)) : e.endsWith("~") && (i = "~", e = e.slice(0, -1)), e = e.replace(/\\ /g, " ").replace(/\\(.)/g, "$1"), { op: t === "url" ? "under" : i === "*" ? "starts" : i === "~" ? "fuzzy" : "term", value: e };
792
+ }
793
+ function Be(n, t) {
794
+ let e = 0;
795
+ const i = () => n[e], s = () => n[e++];
796
+ function o() {
797
+ let p = !1;
798
+ for (; i() === "NOT"; )
799
+ p = !p, s();
800
+ let d;
801
+ if (i() === "(")
802
+ s(), d = u(), i() === ")" && s();
803
+ else {
804
+ const c = s();
805
+ if (!c || typeof c == "string")
806
+ throw new Error("Unexpected token");
807
+ d = t(c);
808
+ }
809
+ return p && (d.negate = !d.negate), d;
810
+ }
811
+ function r() {
812
+ const p = o(), d = [p];
813
+ for (; ; ) {
814
+ const c = i();
815
+ if (c === "AND")
816
+ s(), d.push(o());
817
+ else if (c !== void 0 && c !== ")" && c !== "OR") d.push(o());
818
+ else break;
819
+ }
820
+ return d.length === 1 ? p : {
821
+ id: q(),
822
+ kind: "group",
823
+ op: "AND",
824
+ negate: !1,
825
+ children: d
826
+ };
827
+ }
828
+ function u() {
829
+ const p = r(), d = [p];
830
+ for (; i() === "OR"; )
831
+ s(), d.push(r());
832
+ return d.length === 1 ? p : {
833
+ id: q(),
834
+ kind: "group",
835
+ op: "OR",
836
+ negate: !1,
837
+ children: d
838
+ };
839
+ }
840
+ const a = u();
841
+ if (e < n.length) throw new Error("Unexpected trailing tokens");
842
+ return a;
843
+ }
844
+ function He(n, t) {
845
+ let e = "", i = n;
846
+ return i.startsWith("-") && (e = "-", i = i.slice(1)), Qt.has(i) || /^[A-Za-z_][\w.$]*:/.test(i) ? n : e + t + ":" + i;
847
+ }
848
+ function et(n) {
849
+ const t = (i) => i && typeof i == "object", e = [];
850
+ for (let i = 0; i < n.length; i++) {
851
+ const s = n[i], o = t(s) && /^(-?)([A-Za-z_][\w.$]*):$/.exec(s.term);
852
+ if (o && n[i + 1] === "(") {
853
+ let r = 0, u = i + 1;
854
+ for (; u < n.length; u++)
855
+ if (n[u] === "(") r++;
856
+ else if (n[u] === ")" && --r === 0) break;
857
+ if (u < n.length) {
858
+ o[1] === "-" && e.push("NOT"), e.push("(");
859
+ for (const a of et(n.slice(i + 2, u)))
860
+ e.push(t(a) ? { term: He(a.term, o[2]) } : a);
861
+ e.push(")"), i = u;
862
+ continue;
863
+ }
864
+ }
865
+ e.push(s);
866
+ }
867
+ return e;
868
+ }
869
+ function Le(n) {
870
+ let t = 0, e = 0;
871
+ for (const i of n)
872
+ if (i === "(" ? t++ : i === ")" ? t-- : i === '"' && e++, t < 0) break;
873
+ return t !== 0 ? "Unbalanced parentheses." : e % 2 !== 0 ? "Unbalanced quotes." : "";
874
+ }
875
+ const Qt = /* @__PURE__ */ new Set(["AND", "OR", "NOT"]);
876
+ function Fe(n) {
877
+ const t = n.indexOf(":");
878
+ return t < 0 ? null : { field: n.slice(0, t), value: n.slice(t + 1) };
879
+ }
880
+ function je(n) {
881
+ const t = Fe(n);
882
+ if (!t) return n;
883
+ let e = t.value;
884
+ if (e.length > 1 && e.startsWith('"') && e.endsWith('"')) {
885
+ const i = e.slice(1, -1);
886
+ i && !/\s/.test(i) && (e = i);
887
+ }
888
+ return t.field + ":" + e;
889
+ }
890
+ function Ve(n) {
891
+ let t = n.slice();
892
+ for (let e = !0; e; ) {
893
+ e = !1;
894
+ for (let i = 0; i + 2 < t.length; i++)
895
+ if (t[i] === "(" && t[i + 2] === ")" && t[i + 1] !== "(" && t[i + 1] !== ")") {
896
+ t.splice(i, 3, t[i + 1]), e = !0;
897
+ break;
898
+ }
899
+ if (!e && t.length >= 2 && t[0] === "(" && t[t.length - 1] === ")") {
900
+ let i = 0, s = !0;
901
+ for (let o = 0; o < t.length; o++)
902
+ if (t[o] === "(") i++;
903
+ else if (t[o] === ")" && --i === 0 && o !== t.length - 1) {
904
+ s = !1;
905
+ break;
906
+ }
907
+ s && (t = t.slice(1, -1), e = !0);
908
+ }
909
+ }
910
+ return t;
911
+ }
912
+ function We(n) {
913
+ return n[0] === "!" ? "-" + n.slice(1) : n;
914
+ }
915
+ function Mt(n) {
916
+ const t = et(ut(n)).map((s) => typeof s == "string" ? s : s.term).map(We), e = [];
917
+ for (let s = 0; s < t.length; s++) {
918
+ const o = t[s];
919
+ if (o === "NOT" && s + 1 < t.length && t[s + 1] !== "(" && !Qt.has(t[s + 1])) {
920
+ const r = t[++s];
921
+ e.push(r.startsWith("-") ? r.slice(1) : "-" + r);
922
+ } else
923
+ e.push(o);
924
+ }
925
+ return Ve(
926
+ e.filter((s) => s !== "AND").map(je)
927
+ ).join(" ");
928
+ }
929
+ function qe(n) {
930
+ const t = (s) => s === "AND" || s === "OR" || s === "NOT", e = (s) => s === ")" || !t(s) && s !== "(", i = (s) => s === "(" || !t(s) && s !== ")" && s[0] !== "-" && s[0] !== "!" && s[0] !== "+";
931
+ for (let s = 0; s + 1 < n.length; s++)
932
+ if (e(n[s]) && i(n[s + 1])) return !0;
933
+ return !1;
934
+ }
935
+ function Bt(n = {}) {
936
+ const t = n.fields == null, e = De(
937
+ n.fields ?? zt.fields,
938
+ n.operators
939
+ ), i = Ie(n.booleans), s = new Set(i.map((l) => l.id)), o = n.defaults ?? (t ? zt.defaults : null), r = Object.keys(e), u = (l) => r.find((h) => e[h].path === l), a = (l, h) => e[l].ops.some((m) => m.id === h), p = (l, h) => {
940
+ l && (e[l.field] || S(`${h} names unknown field "${l.field}"`), l.op && !a(l.field, l.op) && S(`${h} uses operator "${l.op}" not offered for field "${l.field}"`));
941
+ };
942
+ o?.field && !e[o.field] && S(`defaults.field names unknown field "${o.field}"`), p(o?.conditional?.if, "defaults.conditional.if"), p(o?.conditional?.then, "defaults.conditional.then"), p(o?.conditional?.else, "defaults.conditional.else");
943
+ const d = o?.field || r[0], c = (l = d, h = {}) => ({
944
+ id: q(),
945
+ kind: "rule",
946
+ field: l,
947
+ op: e[l].ops[0].id,
948
+ value: "",
949
+ value2: "",
950
+ negate: !1,
951
+ boost: "",
952
+ ...h
953
+ }), f = (l = i[0].id, h = null) => ({
954
+ id: q(),
955
+ kind: "group",
956
+ op: l,
957
+ negate: !1,
958
+ children: h || [c()]
959
+ }), $ = (l) => l ? c(l.field, {
960
+ ...l.op ? { op: l.op } : {},
961
+ ...l.negate ? { negate: !0 } : {}
962
+ }) : c(), y = () => ({
963
+ id: q(),
964
+ kind: "conditional",
965
+ cond: f("AND", [$(o?.conditional?.if)]),
966
+ then: f("AND", [$(o?.conditional?.then)]),
967
+ els: f("AND", [$(o?.conditional?.else)])
968
+ }), E = () => f("AND", [$(o?.conditional?.else)]);
969
+ function U(l) {
970
+ const h = e[l.field], m = h.path;
971
+ if (h.type === "video") {
972
+ let x = "";
973
+ if (l.op === "exists")
974
+ x = `_exists_:${m}`;
975
+ else {
976
+ const k = (l.value || "").trim(), L = (l.value2 || "").trim();
977
+ l.op === "longer" ? x = k && `${h.durationPath}:[${k} TO *]` : l.op === "shorter" ? x = k && `${h.durationPath}:[* TO ${k}]` : l.op === "between" && (x = k && L && `${h.durationPath}:[${k} TO ${L}]`);
978
+ }
979
+ return x ? l.negate ? "-" + x : x : "";
980
+ }
981
+ const b = m ? `${m}:` : "", v = (l.value || "").trim(), D = (l.value2 || "").trim();
982
+ let w = "";
983
+ if (h.type === "url") {
984
+ if (!v) return "";
985
+ w = l.op === "is" ? `${m}.keyword:"${Y(v)}"` : `${b}"${Y(v)}"`;
986
+ } else if (h.type === "date" || h.type === "number")
987
+ if (l.op === "between") {
988
+ if (!v || !D) return "";
989
+ w = `${b}[${v} TO ${D}]`;
990
+ } else if (l.op === "after" || l.op === "gte") {
991
+ if (!v) return "";
992
+ w = `${b}[${v} TO *]`;
993
+ } else {
994
+ if (!v) return "";
995
+ w = `${b}[* TO ${v}]`;
996
+ }
997
+ else if (l.op === "exists") {
998
+ if (!m) return "";
999
+ w = `_exists_:${m}`;
1000
+ } else {
1001
+ if (!v) return "";
1002
+ l.op === "phrase" ? w = `${b}"${Y(v)}"` : l.op === "term" ? w = `${b}${lt(v)}` : l.op === "starts" ? w = `${b}${lt(v)}*` : l.op === "fuzzy" && (w = `${b}${lt(v)}~`);
1003
+ }
1004
+ return w ? (l.boost && Number(l.boost) > 0 && l.op !== "exists" && (w += `^${l.boost}`), l.negate && (w = "-" + w), w) : "";
1005
+ }
1006
+ function K(l) {
1007
+ return l.kind === "rule" ? U(l) : l.kind === "conditional" ? gt(l) : z(l);
1008
+ }
1009
+ function z(l, h = !1) {
1010
+ const m = l.children.map(K).filter(Boolean);
1011
+ if (m.length === 0) return "";
1012
+ const b = m.join(` ${l.op} `);
1013
+ let v = m.length > 1 && !h ? `(${b})` : b;
1014
+ return l.negate && (v = m.length > 1 ? `NOT (${b})` : `NOT ${b}`), v;
1015
+ }
1016
+ function gt(l) {
1017
+ const h = z(l.cond), m = z(l.then), b = l.els ? z(l.els) : "";
1018
+ if (!h) return m || "";
1019
+ const v = m ? `(${h} AND ${m})` : `(${h})`;
1020
+ return b ? `(${v} OR (NOT (${h}) AND ${b}))` : v;
1021
+ }
1022
+ function mt(l) {
1023
+ return z(l, !0) || "";
1024
+ }
1025
+ function H(l, h) {
1026
+ if (h.op && !a(l, h.op))
1027
+ throw new Error(`Unsupported operator for ${l}: ${h.op}`);
1028
+ return c(l, h);
1029
+ }
1030
+ function Kt(l) {
1031
+ let h = l.term, m = !1;
1032
+ h[0] === "-" || h[0] === "!" ? (m = !0, h = h.slice(1)) : h[0] === "+" && (h = h.slice(1));
1033
+ let b = "";
1034
+ const v = h.match(/\^(\d+(?:\.\d+)?)$/);
1035
+ v && (b = v[1], h = h.slice(0, -v[0].length));
1036
+ const D = h.indexOf(":");
1037
+ if (D < 0) {
1038
+ const A = u("");
1039
+ if (!A) throw new Error(`No default field for bare term: ${h}`);
1040
+ return H(A, {
1041
+ ...at(h, e[A].type),
1042
+ negate: m,
1043
+ boost: b
1044
+ });
1045
+ }
1046
+ const w = h.slice(0, D), x = h.slice(D + 1);
1047
+ if (w === "_exists_") {
1048
+ const A = u(x.replace(/^"(.*)"$/, "$1"));
1049
+ if (!A) throw new Error(`Unknown field: ${x}`);
1050
+ return H(A, { op: "exists", negate: m });
1051
+ }
1052
+ const k = r.find((A) => e[A].type === "video" && e[A].durationPath === w);
1053
+ if (k && x.startsWith("[")) {
1054
+ const { op: A, value: Xt, value2: Yt } = at(x, "number");
1055
+ return H(k, { op: A === "gte" ? "longer" : A === "lte" ? "shorter" : "between", value: Xt, value2: Yt || "", negate: m });
1056
+ }
1057
+ const L = r.find((A) => e[A].type === "url" && w === e[A].path + ".keyword");
1058
+ if (L) {
1059
+ const A = x.startsWith('"') ? x.slice(1, -1).replace(/\\(.)/g, "$1") : x;
1060
+ return H(L, { op: "is", value: A, negate: m });
1061
+ }
1062
+ const nt = u(w);
1063
+ if (!nt) throw new Error(`Unknown field: ${w}`);
1064
+ return H(nt, {
1065
+ ...at(x, e[nt].type),
1066
+ negate: m,
1067
+ boost: b
1068
+ });
1069
+ }
1070
+ function _t(l) {
1071
+ if (!l || !l.trim()) return f(void 0, []);
1072
+ const h = Be(et(ut(l)), Kt);
1073
+ return h.kind === "group" ? h : f(void 0, [h]);
1074
+ }
1075
+ const bt = (l) => l.kind !== "group" || s.has(l.op) && l.children.every(bt);
1076
+ function Jt(l) {
1077
+ if (!l || !l.trim()) return !0;
1078
+ try {
1079
+ const h = et(ut(l)).map((b) => typeof b == "string" ? b : b.term);
1080
+ if (qe(h)) return !1;
1081
+ const m = _t(l);
1082
+ return bt(m) ? Mt(mt(m)) === Mt(l) : !1;
1083
+ } catch {
1084
+ return !1;
1085
+ }
1086
+ }
1087
+ return {
1088
+ fields: e,
1089
+ fieldKeys: r,
1090
+ groupOps: i,
1091
+ defaultField: d,
1092
+ // conditionals desugar to OR-of-ANDs, so they're only on offer
1093
+ // when both joiners are
1094
+ supportsConditionals: s.has("AND") && s.has("OR"),
1095
+ newRule: c,
1096
+ newGroup: f,
1097
+ newConditional: y,
1098
+ newElse: E,
1099
+ ruleToLucene: U,
1100
+ groupToLucene: z,
1101
+ condToLucene: gt,
1102
+ toLucene: mt,
1103
+ parseLucene: _t,
1104
+ roundTrips: Jt
1105
+ };
1106
+ }
1107
+ const Ge = (n) => n && n[0].toUpperCase() + n.slice(1);
1108
+ function Ht(n = {}) {
1109
+ const t = n.itemNoun || "story", e = n.itemNounPlural || (n.itemNoun ? n.itemNoun + "s" : "stories");
1110
+ return {
1111
+ itemNoun: t,
1112
+ itemNounPlural: e,
1113
+ intro: `Describe the ${e} you want in plain language — the query writes itself.`,
1114
+ rawUnsupported: "This query uses syntax the visual editor can't represent, so it's shown as raw text.",
1115
+ rawButton: "Raw Query",
1116
+ visualButton: "Query Builder",
1117
+ rawSynced: "Synced.",
1118
+ rawSaved: "Saved as raw text — the visual builder can't represent this query. Adjust it to a supported form to switch back.",
1119
+ matchPrefix: `${Ge(e)} must match`,
1120
+ matchSuffix: "of these rules",
1121
+ empty: `No rules yet, so every ${t} can appear. Add a rule to narrow the collection.`,
1122
+ addRule: "Rule",
1123
+ addRuleTip: 'Add one condition, like Title contains "storm".',
1124
+ addConditional: "If/then",
1125
+ addConditionalTip: `Apply conditions only to ${e} that match a test first.`,
1126
+ actsHelpRule: "adds a single condition",
1127
+ actsHelpConditional: `applies conditions only to certain ${e}`,
1128
+ conditionalTitle: "IF / THEN",
1129
+ conditionalIf: `If a ${t} matches`,
1130
+ conditionalThen: "then include only when",
1131
+ conditionalElse: "otherwise include only when",
1132
+ removeElse: "remove",
1133
+ addElse: "Otherwise branch",
1134
+ addSubRule: "Rule",
1135
+ addSubRuleTip: "Add another condition to this list.",
1136
+ include: "Include",
1137
+ exclude: "Exclude",
1138
+ ruleTag: "Rule",
1139
+ between: "and",
1140
+ // sic: "a values." matches the original builder's rendered string
1141
+ // (`…a value${plural ? 's' : ''}.`) byte-for-byte
1142
+ pendingOne: "Ignored until you enter a value.",
1143
+ pendingBoth: "Ignored until you enter a values.",
1144
+ ...n
1145
+ };
1146
+ }
1147
+ const Qe = ["fields", "operators", "booleans", "defaults"];
1148
+ class Zt extends W {
1149
+ static get properties() {
1150
+ return {
1151
+ value: { type: String },
1152
+ fields: { type: Object },
1153
+ operators: { type: Object },
1154
+ booleans: { type: Array },
1155
+ defaults: { type: Object },
1156
+ labels: { type: Object },
1157
+ advanced: { type: Boolean, state: !0 },
1158
+ rawError: { type: String, state: !0 },
1159
+ configError: { type: String, state: !0 },
1160
+ dragId: { type: String, state: !0 },
1161
+ dropId: { type: String, state: !0 }
1162
+ };
1163
+ }
1164
+ constructor() {
1165
+ super(), this.value = "", this.fields = null, this.operators = null, this.booleans = null, this.defaults = null, this.labels = null, this.configError = "", this._model = Bt(), this._labels = Ht(), this.root = this._model.newGroup(void 0, []), this.advanced = !1, this.canVisual = !0, this.rawError = "", this.dragId = null, this.dropId = null, this._emitted = void 0;
1166
+ }
1167
+ willUpdate(t) {
1168
+ const e = Qe.some((i) => t.has(i));
1169
+ e && this._rebuildModel(), t.has("labels") && (this._labels = Ht(this.labels || {})), (e && !this.configError || t.has("value") && this.value !== this._emitted) && this._syncFromValue();
1170
+ }
1171
+ /**
1172
+ * Rebuild the catalog-bound model from the JSON config. A bad config
1173
+ * (unknown type/operator, missing path, …) keeps the previous model
1174
+ * and surfaces the error instead of crashing the host app.
1175
+ */
1176
+ _rebuildModel() {
1177
+ try {
1178
+ this._model = Bt({
1179
+ fields: this.fields ?? void 0,
1180
+ operators: this.operators ?? void 0,
1181
+ booleans: this.booleans ?? void 0,
1182
+ defaults: this.defaults ?? void 0
1183
+ }), this.configError = "";
1184
+ } catch (t) {
1185
+ this.configError = t.message;
1186
+ }
1187
+ }
1188
+ _syncFromValue() {
1189
+ const t = this.value || "";
1190
+ if (this._model.roundTrips(t)) {
1191
+ this.canVisual = !0;
1192
+ try {
1193
+ this.root = this._model.parseLucene(t);
1194
+ } catch {
1195
+ this.canVisual = !1, this.advanced = !0;
1196
+ }
1197
+ } else
1198
+ this.canVisual = !1, this.advanced = !0;
1199
+ }
1200
+ _commit() {
1201
+ this.root = { ...this.root }, this._emit(this._model.toLucene(this.root));
1202
+ }
1203
+ _emit(t) {
1204
+ this._emitted = t, this.value = t, this.dispatchEvent(new CustomEvent("change", {
1205
+ detail: { value: t }
1206
+ })), this.requestUpdate();
1207
+ }
1208
+ /* ---- tree helpers ---- */
1209
+ _kids(t) {
1210
+ return t.kind === "group" ? t.children : t.kind === "conditional" ? [t.cond, t.then, t.els].filter(Boolean) : [];
1211
+ }
1212
+ _find(t, e) {
1213
+ if (t.id === e) return t;
1214
+ for (const i of this._kids(t)) {
1215
+ const s = this._find(i, e);
1216
+ if (s) return s;
1217
+ }
1218
+ return null;
1219
+ }
1220
+ _parent(t, e, i = null) {
1221
+ if (t.id === e) return i;
1222
+ for (const s of this._kids(t)) {
1223
+ const o = this._parent(s, e, t);
1224
+ if (o !== void 0) return o;
1225
+ }
1226
+ }
1227
+ /* ---- mutations ---- */
1228
+ _addRule(t) {
1229
+ this._find(this.root, t).children.push(this._model.newRule()), this._commit();
1230
+ }
1231
+ _addCond(t) {
1232
+ this._find(this.root, t).children.push(this._model.newConditional()), this._commit();
1233
+ }
1234
+ _remove(t) {
1235
+ const e = this._parent(this.root, t);
1236
+ !e || e.kind !== "group" || (e.children = e.children.filter((i) => i.id !== t), this._commit());
1237
+ }
1238
+ _setOp(t, e) {
1239
+ this._find(this.root, t).op = e, this._commit();
1240
+ }
1241
+ _toggleNeg(t) {
1242
+ const e = this._find(this.root, t);
1243
+ e.negate = !e.negate, this._commit();
1244
+ }
1245
+ _patch(t, e) {
1246
+ const i = this._find(this.root, t);
1247
+ Object.assign(i, e), e.field && (i.op = this._model.fields[e.field].ops[0].id, i.value = "", i.value2 = ""), this._commit();
1248
+ }
1249
+ _dropEls(t) {
1250
+ this._find(this.root, t).els = null, this._commit();
1251
+ }
1252
+ _addEls(t) {
1253
+ this._find(this.root, t).els = this._model.newElse(), this._commit();
1254
+ }
1255
+ /* ---- drag to reorder ---- */
1256
+ _dragStart(t, e) {
1257
+ this.dragId = e, t.dataTransfer.effectAllowed = "move";
1258
+ }
1259
+ /** A drag can only drop onto a sibling in the same group. */
1260
+ _canDrop(t) {
1261
+ const e = this.dragId;
1262
+ if (!e || e === t) return !1;
1263
+ const i = this._parent(this.root, e), s = this._parent(this.root, t);
1264
+ return !!i && i === s && i.kind === "group";
1265
+ }
1266
+ _dragOver(t, e) {
1267
+ t.preventDefault(), e !== this.dropId && this._canDrop(e) && (this.dropId = e);
1268
+ }
1269
+ _dragEnd() {
1270
+ this.dragId = null, this.dropId = null;
1271
+ }
1272
+ _drop(t, e) {
1273
+ t.preventDefault();
1274
+ const i = this.dragId, s = this._canDrop(e);
1275
+ if (this.dragId = null, this.dropId = null, !s) return;
1276
+ const r = this._parent(this.root, i).children, u = r.findIndex((d) => d.id === i), a = r.findIndex((d) => d.id === e);
1277
+ if (u < 0 || a < 0) return;
1278
+ const [p] = r.splice(u, 1);
1279
+ r.splice(a, 0, p), this._commit();
1280
+ }
1281
+ /* ---- raw (advanced) mode ---- */
1282
+ _syncRaw(t) {
1283
+ if (this.rawError = Le(t), !this.rawError) {
1284
+ if (this._model.roundTrips(t)) {
1285
+ this.canVisual = !0;
1286
+ try {
1287
+ this.root = this._model.parseLucene(t);
1288
+ } catch {
1289
+ this.canVisual = !1;
1290
+ }
1291
+ } else
1292
+ this.canVisual = !1;
1293
+ this._emit(t);
1294
+ }
1295
+ }
1296
+ _toggleAdvanced() {
1297
+ this.advanced && !this.canVisual || (this.advanced = !this.advanced);
1298
+ }
1299
+ render() {
1300
+ const t = this._labels;
1301
+ return this.configError ? g`<p class="err">${this.configError}</p>` : g`
1302
+ <div class="qbar">
1303
+ ${this.canVisual ? this.advanced ? _ : g`<span class="intro">
1304
+ ${t.intro}</span>` : g`<span class="note">${t.rawUnsupported}
1305
+ </span>`}
1306
+ <studio-button size="small" style-type="outline"
1307
+ state=${this.advanced && !this.canVisual ? "disabled" : "default"}
1308
+ background-color=${this.advanced ? "var(--studio-primary, #001D68)" : ""}
1309
+ text-color=${this.advanced ? "#FFFFFF" : ""}
1310
+ @click=${this._toggleAdvanced}>
1311
+ ${this.advanced ? t.visualButton : t.rawButton}</studio-button>
1312
+ </div>
1313
+ ${this.advanced ? g`<textarea class="raw" .value=${this.value || ""}
1314
+ @input=${(e) => this._syncRaw(e.target.value)}></textarea>
1315
+ ${this.rawError ? g`<p class="err">${this.rawError}</p>` : this.canVisual ? g`<p class="ok">${t.rawSynced}</p>` : g`<p class="note-raw">${t.rawSaved}</p>`}` : this._group(this.root, !0)}`;
1316
+ }
1317
+ /**
1318
+ * The library button keeps its :focus styling after a click (the
1319
+ * group's focus suppression cannot cross the shadow boundary), so
1320
+ * a just-clicked segment would look selected next to the truly
1321
+ * selected one. Blur the inner button to keep the toggle state
1322
+ * unambiguous.
1323
+ */
1324
+ _blurButton(t) {
1325
+ t.currentTarget?.renderRoot?.querySelector("button")?.blur();
1326
+ }
1327
+ /**
1328
+ * all/any segmented toggle (mutually exclusive). The selected colour is
1329
+ * driven by CSS keyed on aria-pressed (see the `.tog` rules), NOT by
1330
+ * studio-button's background-color attribute. Two traps force this:
1331
+ * studio-button does not inherit the group's style-type (so each child
1332
+ * sets style-type="outline" to get a transparent unselected base), and
1333
+ * changing its background-color through re-renders lags a render behind,
1334
+ * leaving a deselected button still filled. Setting --button-bg-color
1335
+ * from our own stylesheet sidesteps the component's colour pipeline.
1336
+ */
1337
+ _segGroup(t, e) {
1338
+ const i = (s, o) => g`
1339
+ <studio-button class="tog primary" size="small" style-type="outline"
1340
+ aria-pressed=${String(e === s)}
1341
+ @click=${(r) => {
1342
+ this._blurButton(r), this._setOp(t, s);
1343
+ }}>${o}</studio-button>`;
1344
+ return g`<studio-button-group size="small" style-type="outline"
1345
+ role="group" aria-label="Match all or any">
1346
+ ${this._model.groupOps.map((s) => i(s.id, s.label))}
1347
+ </studio-button-group>`;
1348
+ }
1349
+ _group(t, e = !1) {
1350
+ const i = this._labels;
1351
+ return g`
1352
+ <div class="group ${e ? "top" : ""} ${t.negate ? "neg" : ""}">
1353
+ <div class="gbar"><span class="ll">${i.matchPrefix}</span>
1354
+ ${this._segGroup(t.id, t.op)}
1355
+ <span class="ll">${i.matchSuffix}</span>
1356
+ ${e ? _ : g`<studio-button size="tiny" icon-only icon="circle-xmark"
1357
+ style-type="clear" aria-label="Remove group"
1358
+ @click=${() => this._remove(t.id)}></studio-button>`}
1359
+ </div>
1360
+ ${t.children.length ? g`<div class="kids">${this._kidRows(t)}</div>` : g`<p class="empty">${i.empty}</p>`}
1361
+ <div class="acts" role="group" aria-label="Add to this group">
1362
+ <studio-tooltip position="top" size="small"
1363
+ text=${i.addRuleTip}>
1364
+ <studio-button size="small" style-type="outline" icon="filter"
1365
+ @click=${() => this._addRule(t.id)}>${i.addRule}</studio-button>
1366
+ </studio-tooltip>
1367
+ ${this._model.supportsConditionals ? g`
1368
+ <studio-tooltip position="top" size="small"
1369
+ text=${i.addConditionalTip}>
1370
+ <studio-button size="small" style-type="outline"
1371
+ icon="code-compare"
1372
+ @click=${() => this._addCond(t.id)}>
1373
+ ${i.addConditional}</studio-button>
1374
+ </studio-tooltip>` : _}
1375
+ </div>
1376
+ ${e && this._model.supportsConditionals ? g`<p class="acts-help">
1377
+ <strong>${i.addRule}</strong> ${i.actsHelpRule} ·
1378
+ <strong>${i.addConditional}</strong>
1379
+ ${i.actsHelpConditional}</p>` : _}
1380
+ </div>`;
1381
+ }
1382
+ /** Children of a group, numbering its rules "Rule 1", "Rule 2", … */
1383
+ _kidRows(t) {
1384
+ let e = 0;
1385
+ const i = new Map(t.children.map((s) => [s.id, s.kind === "rule" ? ++e : 0]));
1386
+ return Ut(
1387
+ t.children,
1388
+ (s) => s.id,
1389
+ (s) => this._row(s, i.get(s.id))
1390
+ );
1391
+ }
1392
+ _row(t, e = 0) {
1393
+ const i = this.dragId === t.id, s = this.dropId === t.id && this.dragId && this.dragId !== t.id, o = t.kind === "group" ? this._group(t) : t.kind === "conditional" ? this._cond(t) : this._rule(t, e);
1394
+ return g`<div class="rw ${i ? "drag" : ""} ${s ? "ov" : ""}"
1395
+ @dragover=${(r) => this._dragOver(r, t.id)} @drop=${(r) => this._drop(r, t.id)}>
1396
+ <span class="h" draggable="true"
1397
+ @dragstart=${(r) => this._dragStart(r, t.id)}
1398
+ @dragend=${() => this._dragEnd()}>
1399
+ <studio-icon name="grip" size=".9rem"></studio-icon></span>
1400
+ <div class="rb">${o}</div>
1401
+ </div>`;
1402
+ }
1403
+ _cond(t) {
1404
+ const e = this._labels;
1405
+ return g`<div class="cond">
1406
+ <div class="cb"><span class="ct">${e.conditionalTitle}</span>
1407
+ <studio-button size="tiny" icon-only icon="circle-xmark"
1408
+ style-type="clear" aria-label="Remove conditional"
1409
+ @click=${() => this._remove(t.id)}></studio-button></div>
1410
+ <div class="cs"><span class="sl">${e.conditionalIf}</span>
1411
+ ${this._sg(t.cond)}</div>
1412
+ <div class="cs"><span class="sl">${e.conditionalThen}</span>
1413
+ ${this._sg(t.then)}</div>
1414
+ ${t.els ? g`<div class="cs"><span class="sl el">${e.conditionalElse}
1415
+ <studio-button size="tiny" style-type="clear"
1416
+ text-color="var(--wral-red, #D1232A)"
1417
+ @click=${() => this._dropEls(t.id)}>
1418
+ ${e.removeElse}</studio-button>
1419
+ </span>${this._sg(t.els)}</div>` : g`<studio-button size="tiny" style-type="clear" icon="plus"
1420
+ @click=${() => this._addEls(t.id)}>${e.addElse}</studio-button>`}
1421
+ </div>`;
1422
+ }
1423
+ _sg(t) {
1424
+ const e = this._labels;
1425
+ let i = 0;
1426
+ const s = new Map(t.children.map((o) => [o.id, o.kind === "rule" ? ++i : 0]));
1427
+ return g`<div class="sgp">
1428
+ <div class="sgh">${this._segGroup(t.id, t.op)}</div>
1429
+ ${Ut(
1430
+ t.children,
1431
+ (o) => o.id,
1432
+ (o) => o.kind === "rule" ? this._rule(o, s.get(o.id)) : this._row(o, s.get(o.id))
1433
+ )}
1434
+ <studio-tooltip position="top" size="small"
1435
+ text=${e.addSubRuleTip}>
1436
+ <studio-button class="add-rule" size="tiny" style-type="clear"
1437
+ icon="plus"
1438
+ @click=${() => this._addRule(t.id)}>${e.addSubRule}</studio-button>
1439
+ </studio-tooltip>
1440
+ </div>`;
1441
+ }
1442
+ _rule(t, e = 0) {
1443
+ const i = this._labels, s = this._model.fields[t.field], o = s.ops, r = t.op !== "exists", u = t.op === "between", a = s.type === "date" ? "date" : s.type === "number" || s.type === "video" ? "number" : "text", p = r && (!(t.value || "").trim() || u && !(t.value2 || "").trim());
1444
+ return g`<div class="rule ${t.negate ? "exc" : ""}">
1445
+ ${e ? g`<span class="rule-tag">${i.ruleTag} ${e}</span>` : _}
1446
+ <studio-button-group size="small" style-type="outline"
1447
+ role="group" aria-label="Include or exclude">
1448
+ <studio-button class="tog incl" size="small" style-type="outline"
1449
+ aria-pressed=${String(!t.negate)}
1450
+ @click=${(d) => {
1451
+ this._blurButton(d), this._patch(t.id, { negate: !1 });
1452
+ }}>${i.include}</studio-button>
1453
+ <studio-button class="tog excl" size="small" style-type="outline"
1454
+ aria-pressed=${String(!!t.negate)}
1455
+ @click=${(d) => {
1456
+ this._blurButton(d), this._patch(t.id, { negate: !0 });
1457
+ }}>${i.exclude}</studio-button>
1458
+ </studio-button-group>
1459
+ <studio-select class="f-sel" .singleSelect=${!0}
1460
+ .preventNull=${!0} height="small" width="100%"
1461
+ .options=${Object.entries(this._model.fields).map(([d, c]) => ({ value: d, label: c.label }))}
1462
+ .selected=${[t.field]}
1463
+ @change=${(d) => {
1464
+ d.stopPropagation(), this._patch(t.id, { field: d.detail.selected[0] });
1465
+ }}
1466
+ ></studio-select>
1467
+ <studio-select class="op-sel" .singleSelect=${!0}
1468
+ .preventNull=${!0} height="small" width="100%"
1469
+ .options=${o.map((d) => ({ value: d.id, label: d.label }))}
1470
+ .selected=${[t.op]}
1471
+ @change=${(d) => {
1472
+ d.stopPropagation(), this._patch(t.id, { op: d.detail.selected[0] });
1473
+ }}
1474
+ ></studio-select>
1475
+ <studio-button size="tiny" icon-only icon="circle-xmark"
1476
+ style-type="clear" aria-label="Remove rule"
1477
+ @click=${() => this._remove(t.id)}></studio-button>
1478
+ ${r ? g`<div class="val-row">
1479
+ ${a === "date" ? g`<input type="date" .value=${t.value}
1480
+ @input=${(d) => this._patch(t.id, { value: d.target.value })}>` : g`<studio-input class="val" height="small" width="100%" type=${a}
1481
+ placeholder=${s.hint || "value"} .value=${t.value}
1482
+ @input=${(d) => this._patch(t.id, { value: d.target.value })}
1483
+ ></studio-input>`}
1484
+ ${u ? g`<span class="as">${i.between}</span>
1485
+ ${a === "date" ? g`<input type="date" .value=${t.value2}
1486
+ @input=${(d) => this._patch(t.id, { value2: d.target.value })}>` : g`<studio-input class="val" height="small" width="100%" type=${a}
1487
+ placeholder=${s.hint || "value"} .value=${t.value2}
1488
+ @input=${(d) => this._patch(t.id, { value2: d.target.value })}
1489
+ ></studio-input>`}` : _}
1490
+ </div>` : _}
1491
+ ${p ? g`<p class="pending">
1492
+ <studio-icon name="circle-info" size=".7rem"></studio-icon>
1493
+ ${u ? i.pendingBoth : i.pendingOne}</p>` : _}
1494
+ </div>`;
1495
+ }
1496
+ static styles = ee`
1497
+ :host{display:block;font-family:var(--wral-font-body,inherit);font-size:.85rem;}
1498
+ *{box-sizing:border-box;}
1499
+ /* Selected state for the segmented toggles (all/any, include/exclude).
1500
+ Keyed on aria-pressed and exposed as inheritable CSS vars so the
1501
+ studio-button picks up the fill without its colour attributes,
1502
+ which lag a render behind on toggle. Unselected buttons use the
1503
+ outline style-type's transparent default. */
1504
+ .tog[aria-pressed="true"]{--button-text-color:#FFFFFF;}
1505
+ .tog.primary[aria-pressed="true"]{
1506
+ --button-bg-color:var(--studio-primary,#001D68);}
1507
+ .tog.incl[aria-pressed="true"]{--button-bg-color:var(--wral-green,#72B509);}
1508
+ .tog.excl[aria-pressed="true"]{--button-bg-color:var(--wral-red,#D1232A);}
1509
+ /* native styling kept for the controls with no studio-ui
1510
+ counterpart: date inputs and the raw-query textarea */
1511
+ input,textarea{font:inherit;font-size:.8rem;
1512
+ border:1px solid var(--studio-border,#E1E2E4);border-radius:4px;
1513
+ padding:5px 7px;background:var(--studio-surface,#fff);
1514
+ color:var(--studio-fg,#1B1C1E);}
1515
+ .qbar{display:flex;justify-content:flex-end;align-items:center;gap:8px;
1516
+ margin-bottom:10px;}
1517
+ .note{flex:1;font-size:.7rem;color:var(--studio-muted,#6B6F78);
1518
+ font-style:italic;}
1519
+ .intro{flex:1;font-size:.78rem;color:var(--studio-muted,#6B6F78);}
1520
+ .empty{margin:0;padding:14px 12px;border:1px dashed
1521
+ var(--studio-line,#C3C5CA);border-radius:6px;font-size:.8rem;
1522
+ color:var(--studio-muted,#6B6F78);text-align:center;}
1523
+ .group{border-radius:5px;}
1524
+ .group:not(.top){border-left:3px solid var(--studio-secondary,#2594E3);
1525
+ padding:5px;margin:5px 0;
1526
+ background:color-mix(in srgb,var(--studio-secondary,#2594E3) 5%,transparent);}
1527
+ .group.neg:not(.top){border-left-color:var(--wral-red,#D1232A);}
1528
+ .gbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;
1529
+ margin-bottom:10px;}
1530
+ .gbar studio-button[icon-only]{margin-left:auto;}
1531
+ .ll{font-size:.68rem;font-weight:700;letter-spacing:.05em;
1532
+ text-transform:uppercase;color:var(--studio-subtle,#878B94);}
1533
+ .kids{display:flex;flex-direction:column;gap:8px;}
1534
+ .rw{display:flex;align-items:flex-start;gap:3px;}
1535
+ .rw.ov{box-shadow:0 -2px 0 var(--studio-secondary,#2594E3);}
1536
+ .rw.drag{opacity:.4;}
1537
+ .h{cursor:grab;color:var(--studio-subtle,#A5A8AF);padding:6px 1px;
1538
+ user-select:none;}
1539
+ .rb{flex:1;min-width:0;}
1540
+ /* full-width rule rows: label | segment | field | op | remove,
1541
+ with the value(s) on their own full-width line below */
1542
+ .rule{display:grid;
1543
+ grid-template-columns:auto auto minmax(0,1.2fr) minmax(0,1fr) auto;
1544
+ gap:8px;align-items:center;
1545
+ background:var(--studio-surface,#fff);
1546
+ border:1px solid var(--studio-border,#E1E2E4);border-radius:6px;
1547
+ padding:8px 10px;}
1548
+ .rule-tag{font-family:var(--wral-font-ui,inherit);font-size:.64rem;
1549
+ font-weight:700;letter-spacing:.05em;text-transform:uppercase;
1550
+ color:var(--studio-muted,#6B6F78);white-space:nowrap;
1551
+ background:var(--studio-bg,#F4F5F6);border-radius:4px;
1552
+ padding:3px 7px;}
1553
+ .pending{grid-column:1/-1;display:flex;align-items:center;gap:5px;
1554
+ margin:0;font-size:.72rem;font-style:italic;
1555
+ color:var(--studio-subtle,#878B94);}
1556
+ .rule.exc{background:color-mix(in srgb,var(--wral-red,#D1232A) 6%,
1557
+ var(--studio-surface,#fff));}
1558
+ .rule .f-sel,.rule .op-sel{width:100%;min-width:0;}
1559
+ .val-row{grid-column:1/-1;display:flex;align-items:center;gap:6px;}
1560
+ .val-row .val{flex:1;min-width:0;}
1561
+ .val-row input[type="date"]{flex:1;min-width:0;}
1562
+ .as{font-size:.74rem;color:var(--studio-muted,#6B6F78);flex:0 0 auto;}
1563
+ .acts{display:flex;gap:8px;padding-top:10px;flex-wrap:wrap;}
1564
+ .acts-help{font-size:.74rem;color:var(--studio-muted,#6B6F78);
1565
+ line-height:1.5;margin:8px 0 0;padding-top:8px;
1566
+ border-top:1px solid var(--studio-border,#E1E2E4);}
1567
+ .acts-help strong{color:var(--studio-fg,#1B1C1E);font-weight:600;}
1568
+ .add-rule{align-self:flex-start;}
1569
+ .cond{border:1px solid var(--wral-purple,#33109C);
1570
+ border-left:3px solid var(--wral-purple,#33109C);border-radius:5px;
1571
+ background:color-mix(in srgb,var(--wral-purple,#33109C) 5%,transparent);
1572
+ padding:5px;}
1573
+ .cb{display:flex;justify-content:space-between;align-items:center;}
1574
+ .ct{font-family:var(--wral-font-mono,monospace);font-size:.66rem;
1575
+ font-weight:700;color:var(--wral-purple,#33109C);}
1576
+ .cs{margin:5px 0;}
1577
+ .sl{display:block;font-size:.72rem;font-weight:600;
1578
+ color:var(--studio-muted,#6B6F78);margin-bottom:3px;}
1579
+ .sl.el{color:var(--wral-purple,#33109C);}
1580
+ .sgp{background:var(--studio-surface,#fff);
1581
+ border:1px solid var(--studio-border,#E1E2E4);border-radius:4px;padding:5px;
1582
+ display:flex;flex-direction:column;gap:4px;}
1583
+ .sgh{display:flex;justify-content:flex-end;}
1584
+ .raw{width:100%;min-height:90px;
1585
+ font-family:var(--wral-font-mono,monospace);font-size:.78rem;}
1586
+ .err{color:var(--wral-red,#D1232A);font-size:.74rem;margin:4px 0 0;
1587
+ font-weight:600;}
1588
+ .ok{color:var(--wral-green-deep,#66A208);font-size:.74rem;margin:4px 0 0;}
1589
+ .note-raw{color:var(--studio-muted,#6B6F78);font-size:.74rem;margin:4px 0 0;
1590
+ font-style:italic;line-height:1.4;}
1591
+ `;
1592
+ }
1593
+ globalThis?.customElements && !globalThis.customElements.get("studio-search-filter") && globalThis.customElements.define("studio-search-filter", Zt);
1594
+ const Lt = "studio-search-filter";
1595
+ function Ze() {
1596
+ const n = globalThis?.customElements;
1597
+ n && (n.get(Lt) || n.define(Lt, Zt));
1598
+ }
1599
+ typeof window < "u" && globalThis.customElements && Ze();
1600
+ export {
1601
+ Lt as TAG_NAME,
1602
+ Ze as defineAll
1603
+ };