@mintplayer/web-components 2.16.0 → 2.18.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.
Files changed (120) hide show
  1. package/accordion/index.mjs +5 -5
  2. package/calendar/index.mjs +1 -1
  3. package/carousel/index.mjs +57 -143
  4. package/charts/core/index.mjs +30 -20
  5. package/charts/core/src/attributes.d.ts +18 -0
  6. package/charts/core/src/index.d.ts +2 -0
  7. package/charts/core/src/view-window.d.ts +46 -0
  8. package/charts/hierarchy/index.mjs +245 -256
  9. package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
  10. package/charts/sparkline/index.mjs +27 -26
  11. package/charts/trend/index.mjs +21 -20
  12. package/checkbox/index.mjs +1 -1
  13. package/checkbox/src/components/mp-checkbox.d.ts +1 -0
  14. package/chunks/attributes-L3eKsbdy.mjs +16 -0
  15. package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
  16. package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
  17. package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
  18. package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
  19. package/chunks/{mp-datatable-B7st6G-I.mjs → mp-datatable-CEpSxlkd.mjs} +660 -357
  20. package/chunks/{mp-datetime-picker.element-DsWA1AFs.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
  21. package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
  22. package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
  23. package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
  24. package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
  25. package/chunks/{mp-timepicker.element-CwaAAOcm.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
  26. package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
  27. package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
  28. package/chunks/{overlay-controller-DifgO6jT.mjs → overlay-controller-BHDagokg.mjs} +96 -92
  29. package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
  30. package/chunks/view-window-DGvFiDnW.mjs +263 -0
  31. package/code-snippet/index.mjs +70 -66
  32. package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
  33. package/custom-elements.json +66193 -0
  34. package/datatable/index.mjs +1 -1
  35. package/datatable/src/components/column-resize.d.ts +11 -0
  36. package/datatable/src/components/index.d.ts +1 -1
  37. package/datatable/src/components/mp-datatable.d.ts +264 -20
  38. package/datatable/src/index.d.ts +1 -1
  39. package/datatable/src/types/labels.d.ts +11 -0
  40. package/datepicker/index.mjs +10 -9
  41. package/datetime-picker/index.mjs +1 -1
  42. package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
  43. package/dock/index.mjs +430 -463
  44. package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
  45. package/dock/src/core/resize.d.ts +60 -0
  46. package/dropdown-menu/index.mjs +4 -2
  47. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
  48. package/dropdown-menu/src/index.d.ts +1 -1
  49. package/dropdown-menu/src/types/dropdown.d.ts +14 -1
  50. package/dropdown-menu/src/types/index.d.ts +1 -1
  51. package/file-manager/index.mjs +63 -61
  52. package/file-manager/src/components/mp-file-manager.d.ts +4 -3
  53. package/multi-range/index.mjs +56 -50
  54. package/multi-range/src/mint-multi-range.element.d.ts +4 -10
  55. package/multi-range/src/pointer-geometry.d.ts +31 -0
  56. package/navbar/index.mjs +89 -439
  57. package/overlay/index.mjs +1 -1
  58. package/overlay/src/overlay-controller.d.ts +0 -14
  59. package/overlay/src/placement.d.ts +48 -0
  60. package/package.json +7 -1
  61. package/pagination/index.mjs +1 -1
  62. package/phone-input/index.mjs +44 -40
  63. package/phone-input/src/components/stack.d.ts +8 -0
  64. package/query-builder/index.mjs +418 -466
  65. package/query-builder/src/dnd/drag-controller.d.ts +12 -8
  66. package/query-builder/src/mp-query-builder.element.d.ts +5 -1
  67. package/query-builder/src/mp-query-condition.element.d.ts +1 -0
  68. package/radio/index.mjs +1 -1
  69. package/radio-group/index.mjs +1 -1
  70. package/ribbon/index.mjs +477 -498
  71. package/ribbon/src/core/band-text-color.d.ts +10 -0
  72. package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
  73. package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
  74. package/ribbon/src/mp-ribbon.element.d.ts +0 -27
  75. package/scheduler/index.mjs +726 -711
  76. package/scheduler/src/components/mp-scheduler.d.ts +19 -3
  77. package/scheduler/src/drag/drag-manager.d.ts +1 -9
  78. package/scheduler/src/input/input-handler.d.ts +12 -2
  79. package/scheduler/src/utils/geometry.d.ts +39 -0
  80. package/scheduler/src/views/timeline-view.d.ts +0 -1
  81. package/scheduler-core/index.mjs +84 -71
  82. package/scheduler-core/src/services/resource.service.d.ts +0 -12
  83. package/scheduler-core/src/services/timeline.service.d.ts +0 -9
  84. package/select/index.mjs +1 -1
  85. package/select/src/components/mp-select.d.ts +1 -0
  86. package/signature-pad/index.mjs +21 -23
  87. package/signature-pad/src/canvas-point.d.ts +26 -0
  88. package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
  89. package/splitter/index.mjs +1 -1
  90. package/splitter/src/components/mp-splitter.d.ts +16 -0
  91. package/splitter/src/managers/index.d.ts +1 -0
  92. package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
  93. package/swiper-core/index.mjs +2 -2
  94. package/theming/bs-theme-preboot.js +1 -0
  95. package/theming/color-mode.css +36 -0
  96. package/theming/index.d.ts +1 -0
  97. package/theming/index.mjs +327 -0
  98. package/theming/src/components/mp-theme-toggle.d.ts +71 -0
  99. package/theming/src/cookie.d.ts +31 -0
  100. package/theming/src/index.d.ts +5 -0
  101. package/theming/src/preboot.d.ts +1 -0
  102. package/theming/src/resolve.d.ts +36 -0
  103. package/theming/src/store.d.ts +27 -0
  104. package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
  105. package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
  106. package/theming/src/toggle-modes.d.ts +23 -0
  107. package/tile-manager/index.mjs +252 -211
  108. package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
  109. package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
  110. package/timeline/index.mjs +156 -164
  111. package/timeline/src/components/mp-timeline.d.ts +41 -7
  112. package/timepicker/index.mjs +7 -4
  113. package/timepicker/src/mp-time-list.element.d.ts +26 -0
  114. package/timepicker/src/mp-timepicker.element.d.ts +3 -0
  115. package/toggle-button/index.mjs +1 -1
  116. package/tree-select/index.mjs +21 -9
  117. package/treeview/index.mjs +1 -1
  118. package/treeview/src/components/mp-treeview.d.ts +6 -4
  119. package/chunks/color-DIeST-IS.mjs +0 -224
  120. package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
@@ -1,10 +1,11 @@
1
- import { unsafeCSS as A, LitElement as L, nothing as c } from "lit";
2
- import { s as M, i as T } from "../chunks/install-light-styles-DbCAGFOC.mjs";
3
- import { createContext as P, ContextConsumer as f, ContextProvider as x } from "@lit/context";
4
- import { createRef as ie, ref as se } from "lit/directives/ref.js";
5
- import "../chunks/mp-select-BNrbPwN4.mjs";
6
- import "../chunks/mp-checkbox-CzwS7Y_t.mjs";
7
- const W = {
1
+ import { unsafeCSS as T, LitElement as M, nothing as m } from "lit";
2
+ import { d as W, s as I, i as L } from "../chunks/install-light-styles-DbCAGFOC.mjs";
3
+ import { createContext as P, ContextConsumer as h, ContextProvider as x } from "@lit/context";
4
+ import { createRef as me, ref as pe } from "lit/directives/ref.js";
5
+ import { w as be } from "../chunks/color-mode-warning-71FmlzWX.mjs";
6
+ import "../chunks/mp-select-CgqYFvUj.mjs";
7
+ import "../chunks/mp-checkbox-zV83gILn.mjs";
8
+ const J = {
8
9
  string: [
9
10
  "equals",
10
11
  "not-equals",
@@ -101,7 +102,7 @@ const W = {
101
102
  enum: ["equals", "not-equals", "in", "not-in", "is-null", "is-not-null"],
102
103
  relation: ["in", "not-in"],
103
104
  array: ["any-of", "all-of", "none-of", "is-empty", "is-not-empty"]
104
- }, ae = /* @__PURE__ */ new Set([
105
+ }, he = /* @__PURE__ */ new Set([
105
106
  "is-null",
106
107
  "is-not-null",
107
108
  "is-true",
@@ -120,18 +121,18 @@ const W = {
120
121
  "last-year",
121
122
  "next-year",
122
123
  "year-to-date"
123
- ]), de = /* @__PURE__ */ new Set(["between", "not-between"]), le = /* @__PURE__ */ new Set([
124
+ ]), fe = /* @__PURE__ */ new Set(["between", "not-between"]), ye = /* @__PURE__ */ new Set([
124
125
  "in",
125
126
  "not-in",
126
127
  "any-of",
127
128
  "all-of",
128
129
  "none-of"
129
- ]), ue = /* @__PURE__ */ new Set(["last-n-days", "next-n-days"]);
130
- function h(o) {
131
- return ae.has(o) ? "null" : de.has(o) ? "tuple" : le.has(o) ? "array" : ue.has(o) ? "n-input" : "scalar";
130
+ ]), ge = /* @__PURE__ */ new Set(["last-n-days", "next-n-days"]);
131
+ function q(o) {
132
+ return he.has(o) ? "null" : fe.has(o) ? "tuple" : ye.has(o) ? "array" : ge.has(o) ? "n-input" : "scalar";
132
133
  }
133
- function $(o) {
134
- switch (h(o)) {
134
+ function N(o) {
135
+ switch (q(o)) {
135
136
  case "null":
136
137
  return null;
137
138
  case "tuple":
@@ -144,10 +145,10 @@ function $(o) {
144
145
  return null;
145
146
  }
146
147
  }
147
- function w(o, e = W) {
148
+ function k(o, e = J) {
148
149
  return e[o] ?? [];
149
150
  }
150
- function We(o, e, t = W) {
151
+ function lt(o, e, t = J) {
151
152
  const r = {
152
153
  sanitized: {},
153
154
  warnings: []
@@ -158,63 +159,59 @@ function We(o, e, t = W) {
158
159
  for (const s of i.fields)
159
160
  n.has(s.name) || n.set(s.name, { entity: i.name, type: s.type });
160
161
  for (const [i, s] of Object.entries(e)) {
161
- const a = s ?? [], d = n.get(i);
162
- if (!d) {
162
+ const d = s ?? [], a = n.get(i);
163
+ if (!a) {
163
164
  r.warnings.push(
164
165
  `[operatorOverrides] Unknown field "${i}" — no entity in schema declares it. Override ignored.`
165
166
  );
166
167
  continue;
167
168
  }
168
- const l = new Set(w(d.type, t)), u = [], p = [];
169
- for (const m of a)
170
- l.has(m) ? u.push(m) : p.push(m);
171
- p.length > 0 && r.warnings.push(
172
- `[operatorOverrides] Field "${i}" (${d.entity}.${i}, type=${d.type}) has operator(s) [${p.join(", ")}] not in the catalog for that type. Stripping.`
173
- ), u.length === 0 && a.length > 0 && r.warnings.push(
169
+ const u = new Set(k(a.type, t)), l = [], c = [];
170
+ for (const b of d)
171
+ u.has(b) ? l.push(b) : c.push(b);
172
+ c.length > 0 && r.warnings.push(
173
+ `[operatorOverrides] Field "${i}" (${a.entity}.${i}, type=${a.type}) has operator(s) [${c.join(", ")}] not in the catalog for that type. Stripping.`
174
+ ), l.length === 0 && d.length > 0 && r.warnings.push(
174
175
  `[operatorOverrides] Field "${i}" has no valid operators after intersection — empty operator dropdown.`
175
- ), r.sanitized[i] = u;
176
+ ), r.sanitized[i] = l;
176
177
  }
177
178
  return r;
178
179
  }
179
- function ce() {
180
+ function ve() {
180
181
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
181
182
  return crypto.randomUUID();
182
- const o = new Uint8Array(16);
183
- if (typeof crypto < "u" && typeof crypto.getRandomValues == "function")
184
- crypto.getRandomValues(o);
185
- else
186
- for (let t = 0; t < 16; t++) o[t] = Math.floor(Math.random() * 256);
183
+ const o = typeof crypto < "u" && typeof crypto.getRandomValues == "function" ? crypto.getRandomValues(new Uint8Array(16)) : Uint8Array.from({ length: 16 }, () => Math.floor(Math.random() * 256));
187
184
  o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128;
188
185
  const e = Array.from(o, (t) => t.toString(16).padStart(2, "0"));
189
186
  return `${e.slice(0, 4).join("")}-${e.slice(4, 6).join("")}-${e.slice(6, 8).join("")}-${e.slice(8, 10).join("")}-${e.slice(10, 16).join("")}`;
190
187
  }
191
188
  function C() {
192
- return ce();
189
+ return ve();
193
190
  }
194
- function Q(o = "and") {
191
+ function H(o = "and") {
195
192
  return { kind: "group", id: C(), logic: o, children: [] };
196
193
  }
197
- function me(o) {
194
+ function qe(o) {
198
195
  const e = o.fields.find((r) => r.type !== "relation") ?? o.fields[0];
199
196
  if (!e)
200
197
  return { kind: "condition", id: C(), field: "", operator: "equals", value: null };
201
- const t = w(e.type)[0] ?? "equals";
198
+ const t = k(e.type)[0] ?? "equals";
202
199
  return {
203
200
  kind: "condition",
204
201
  id: C(),
205
202
  field: e.name,
206
203
  operator: t,
207
- value: $(t)
204
+ value: N(t)
208
205
  };
209
206
  }
210
- function pe(o) {
207
+ function we(o) {
211
208
  const e = o.fields.find((t) => t.type === "relation" && t.targetEntity);
212
209
  return e ? {
213
210
  kind: "subquery",
214
211
  id: C(),
215
212
  field: e.name,
216
213
  operator: "in",
217
- subQuery: Q("and")
214
+ subQuery: H("and")
218
215
  } : null;
219
216
  }
220
217
  function G(o) {
@@ -227,7 +224,7 @@ function G(o) {
227
224
  case "condition":
228
225
  return {
229
226
  ...o,
230
- value: N(o.value)
227
+ value: O(o.value)
231
228
  };
232
229
  case "subquery":
233
230
  return {
@@ -236,80 +233,65 @@ function G(o) {
236
233
  };
237
234
  }
238
235
  }
239
- function N(o) {
240
- if (o == null) return o;
241
- if (Array.isArray(o)) return o.map(N);
242
- if (typeof o == "object") {
243
- const e = {};
244
- for (const [t, r] of Object.entries(o))
245
- e[t] = N(r);
246
- return e;
247
- }
248
- return o;
236
+ function O(o) {
237
+ return o == null ? o : Array.isArray(o) ? o.map(O) : typeof o == "object" ? Object.fromEntries(
238
+ Object.entries(o).map(([e, t]) => [e, O(t)])
239
+ ) : o;
249
240
  }
250
- function v(o, e) {
241
+ function S(o, e) {
251
242
  const t = e(o);
252
243
  if (t === null) return null;
253
244
  if (t.kind === "group") {
254
- const r = t.children.map((n) => v(n, e)).filter((n) => n !== null);
245
+ const r = t.children.map((n) => S(n, e)).filter((n) => n !== null);
255
246
  return { ...t, children: r };
256
247
  }
257
248
  if (t.kind === "subquery") {
258
- const r = v(t.subQuery, e);
259
- return r !== null && r.kind === "group" ? { ...t, subQuery: r } : { ...t, subQuery: Q("and") };
249
+ const r = S(t.subQuery, e);
250
+ return r !== null && r.kind === "group" ? { ...t, subQuery: r } : { ...t, subQuery: H("and") };
260
251
  }
261
252
  return t;
262
253
  }
263
- function E(o, e) {
264
- if (o.id === e) return o;
265
- if (o.kind === "group")
266
- for (const t of o.children) {
267
- const r = E(t, e);
268
- if (r) return r;
269
- }
270
- else if (o.kind === "subquery")
271
- return E(o.subQuery, e);
272
- return null;
254
+ function w(o, e) {
255
+ return S(o, e);
256
+ }
257
+ function $(o, e) {
258
+ return o.id === e ? o : o.kind === "group" ? Z(o.children, (t) => $(t, e)) : o.kind === "subquery" ? $(o.subQuery, e) : null;
259
+ }
260
+ function Z(o, e) {
261
+ return o.reduce((t, r) => t ?? e(r), null);
273
262
  }
274
263
  function D(o, e) {
275
264
  if (o.kind === "group") {
276
265
  const t = o.children.findIndex((r) => r.id === e);
277
- if (t >= 0) return { parent: o, index: t };
278
- for (const r of o.children) {
279
- const n = D(r, e);
280
- if (n) return n;
281
- }
282
- } else if (o.kind === "subquery")
283
- return D(o.subQuery, e);
284
- return null;
266
+ return t >= 0 ? { parent: o, index: t } : Z(o.children, (r) => D(r, e));
267
+ }
268
+ return o.kind === "subquery" ? D(o.subQuery, e) : null;
285
269
  }
286
- function J(o) {
287
- const e = /* @__PURE__ */ new Set(), t = (r) => {
288
- e.add(r.id), r.kind === "group" ? r.children.forEach(t) : r.kind === "subquery" && t(r.subQuery);
289
- };
290
- return t(o), e;
270
+ function ee(o) {
271
+ const e = (t) => t.kind === "group" ? [t.id, ...t.children.flatMap(e)] : t.kind === "subquery" ? [t.id, ...e(t.subQuery)] : [t.id];
272
+ return new Set(e(o));
291
273
  }
292
- function H(o, e, t) {
293
- return v(o, (r) => r.kind === "group" && r.id === e ? { ...r, children: [...r.children, t] } : r) ?? o;
274
+ function B(o, e, t) {
275
+ return w(o, (r) => r.kind === "group" && r.id === e ? { ...r, children: [...r.children, t] } : r);
294
276
  }
295
- function be(o, e, t) {
296
- return H(o, e, me(t));
277
+ function _e(o, e, t) {
278
+ return B(o, e, qe(t));
297
279
  }
298
- function he(o, e, t = "and") {
299
- return H(o, e, Q(t));
280
+ function $e(o, e, t = "and") {
281
+ return B(o, e, H(t));
300
282
  }
301
- function fe(o, e, t) {
302
- const r = pe(t);
303
- return r ? H(o, e, r) : o;
283
+ function Ee(o, e, t) {
284
+ const r = we(t);
285
+ return r ? B(o, e, r) : o;
304
286
  }
305
- function Z(o, e) {
306
- return v(o, (r) => r.id === e ? null : r) ?? o;
287
+ function te(o, e) {
288
+ return S(o, (r) => r.id === e ? null : r) ?? o;
307
289
  }
308
- function ye(o, e, t) {
309
- return v(o, (r) => r.kind === "group" && r.id === e ? { ...r, logic: t } : r) ?? o;
290
+ function ke(o, e, t) {
291
+ return w(o, (r) => r.kind === "group" && r.id === e ? { ...r, logic: t } : r);
310
292
  }
311
- function ge(o, e, t) {
312
- return v(o, (r) => {
293
+ function xe(o, e, t) {
294
+ return w(o, (r) => {
313
295
  if ((r.kind === "condition" || r.kind === "subquery") && r.id === e) {
314
296
  if (r.kind === "subquery") {
315
297
  const i = { ...r };
@@ -319,66 +301,63 @@ function ge(o, e, t) {
319
301
  return t.field !== void 0 && (n.field = t.field), t.operator !== void 0 && (n.operator = t.operator), t.value !== void 0 && (n.value = t.value), n;
320
302
  }
321
303
  return r;
322
- }) ?? o;
304
+ });
323
305
  }
324
- function ve(o, e, t) {
325
- return v(o, (r) => {
326
- if (r.kind === "condition" && r.id === e) {
327
- const n = w(t.type), i = n.includes(r.operator) ? r.operator : n[0] ?? "equals", s = n.includes(r.operator) && h(r.operator) === h(i) ? r.value : $(i);
328
- return { ...r, field: t.name, operator: i, value: s };
329
- }
330
- return r;
331
- }) ?? o;
306
+ function Ce(o, e, t) {
307
+ return w(o, (r) => r.kind === "condition" && r.id === e ? re(r, t) : r);
332
308
  }
333
- function qe(o, e, t) {
334
- return v(o, (r) => {
309
+ function re(o, e) {
310
+ const t = k(e.type);
311
+ if (t.includes(o.operator)) return { ...o, field: e.name };
312
+ const r = t[0] ?? "equals";
313
+ return { ...o, field: e.name, operator: r, value: N(r) };
314
+ }
315
+ function Se(o, e, t) {
316
+ return w(o, (r) => {
335
317
  if (r.kind === "condition" && r.id === e) {
336
- const i = h(r.operator) === h(t) ? r.value : $(t);
318
+ const i = q(r.operator) === q(t) ? r.value : N(t);
337
319
  return { ...r, operator: t, value: i };
338
320
  }
339
321
  return r;
340
- }) ?? o;
322
+ });
341
323
  }
342
324
  function j(o, e, t, r, n) {
343
325
  if (e === t) return o;
344
- const i = E(o, e);
326
+ const i = $(o, e);
345
327
  if (!i) return o;
346
- const s = E(o, t);
347
- if (!s || s.kind !== "group" || J(i).has(t)) return o;
348
- const d = n ? ee(i, n) : i, l = Z(o, e);
349
- return v(l, (u) => {
350
- if (u.kind === "group" && u.id === t) {
351
- const p = [...u.children], m = Math.max(0, Math.min(r, p.length));
352
- return p.splice(m, 0, d), { ...u, children: p };
328
+ const s = $(o, t);
329
+ if (!s || s.kind !== "group" || ee(i).has(t)) return o;
330
+ const a = n ? oe(i, n) : i, u = te(o, e);
331
+ return w(u, (l) => {
332
+ if (l.kind === "group" && l.id === t) {
333
+ const c = [...l.children], b = Math.max(0, Math.min(r, c.length));
334
+ return c.splice(b, 0, a), { ...l, children: c };
353
335
  }
354
- return u;
355
- }) ?? l;
336
+ return l;
337
+ });
356
338
  }
357
- function ee(o, e) {
339
+ function oe(o, e) {
358
340
  const t = e.fields.find((r) => r.type !== "relation");
359
341
  if (o.kind === "condition") {
360
342
  const r = e.fields.find((i) => i.name === o.field);
361
- if (r && r.type !== "relation") {
362
- const i = w(r.type), s = i.includes(o.operator) ? o.operator : i[0] ?? "equals", a = i.includes(o.operator) && h(o.operator) === h(s) ? o.value : $(s);
363
- return { ...o, operator: s, value: a };
364
- }
343
+ if (r && r.type !== "relation") return re(o, r);
365
344
  if (!t) return o;
366
- const n = w(t.type)[0] ?? "equals";
345
+ const n = k(t.type)[0] ?? "equals";
367
346
  return {
368
347
  ...o,
369
348
  field: t.name,
370
349
  operator: n,
371
- value: $(n)
350
+ value: N(n)
372
351
  };
373
352
  }
374
- return o.kind === "group" ? { ...o, children: o.children.map((r) => ee(r, e)) } : o;
353
+ return o.kind === "group" ? { ...o, children: o.children.map((r) => oe(r, e)) } : o;
375
354
  }
376
- class te extends Error {
355
+ class ne extends Error {
377
356
  constructor(e, t) {
378
357
  super(`Query tree depth ${e} exceeds maxDepth ${t}.`), this.depth = e, this.maxDepth = t, this.name = "MaxDepthExceededError";
379
358
  }
380
359
  }
381
- const y = {
360
+ const f = {
382
361
  addCondition: "Add condition",
383
362
  addGroup: "Add group",
384
363
  addSubquery: "Add sub-query",
@@ -439,9 +418,9 @@ const y = {
439
418
  "is-empty": "is empty",
440
419
  "is-not-empty": "is not empty"
441
420
  }
442
- }, we = 32;
443
- function Je(o, e, t, r = {}) {
444
- const n = r.maxDepth ?? we, i = {
421
+ }, De = 32;
422
+ function ut(o, e, t, r = {}) {
423
+ const n = r.maxDepth ?? De, i = {
445
424
  schema: t.schema,
446
425
  currentEntity: t.rootEntity,
447
426
  depth: 0
@@ -449,7 +428,7 @@ function Je(o, e, t, r = {}) {
449
428
  return z(o, e, i, n);
450
429
  }
451
430
  function z(o, e, t, r) {
452
- if (t.depth > r) throw new te(t.depth, r);
431
+ if (t.depth > r) throw new ne(t.depth, r);
453
432
  switch (o.kind) {
454
433
  case "condition":
455
434
  return e.condition(o, t);
@@ -458,81 +437,81 @@ function z(o, e, t, r) {
458
437
  return e.group(o, i, t);
459
438
  }
460
439
  case "subquery": {
461
- const n = t.schema.find((l) => l.name === t.currentEntity);
440
+ const n = t.schema.find((u) => u.name === t.currentEntity);
462
441
  if (!n) throw new Error(`visitTree: schema has no entity "${t.currentEntity}".`);
463
- const i = n.fields.find((l) => l.name === o.field);
442
+ const i = n.fields.find((u) => u.name === o.field);
464
443
  if (!i) throw new Error(`visitTree: entity "${t.currentEntity}" has no field "${o.field}".`);
465
444
  if (i.type !== "relation" || !i.targetEntity)
466
445
  throw new Error(`visitTree: field "${o.field}" is not a relation.`);
467
446
  const s = i.targetEntity;
468
- if (!t.schema.some((l) => l.name === s))
447
+ if (!t.schema.some((u) => u.name === s))
469
448
  throw new Error(`visitTree: relation target "${s}" missing from schema.`);
470
- const a = {
449
+ const d = {
471
450
  ...t,
472
451
  currentEntity: s,
473
452
  depth: t.depth + 1
474
- }, d = () => z(o.subQuery, e, a, r);
475
- return e.subquery(o, t, d);
453
+ }, a = () => z(o.subQuery, e, d, r);
454
+ return e.subquery(o, t, a);
476
455
  }
477
456
  }
478
457
  }
479
- const _e = 32;
480
- function $e(o, e, t = {}) {
481
- const r = Ee(t.messages), n = t.maxDepth ?? _e, i = t.rootEntity ?? e[0]?.name ?? "";
482
- return B(o, e, i, r, 0, n);
458
+ const Re = 32;
459
+ function Ae(o, e, t = {}) {
460
+ const r = Te(t.messages), n = t.maxDepth ?? Re, i = t.rootEntity ?? e[0]?.name ?? "";
461
+ return U(o, e, i, r, 0, n);
483
462
  }
484
- function Ee(o) {
463
+ function Te(o) {
485
464
  return {
486
- ...y,
465
+ ...f,
487
466
  ...o ?? {},
488
- operators: { ...y.operators, ...o?.operators ?? {} }
467
+ operators: { ...f.operators, ...o?.operators ?? {} }
489
468
  };
490
469
  }
491
- function B(o, e, t, r, n, i) {
492
- if (n > i) throw new te(n, i);
470
+ function U(o, e, t, r, n, i) {
471
+ if (n > i) throw new ne(n, i);
493
472
  switch (o.kind) {
494
473
  case "group":
495
- return ke(o, e, t, r, n, i);
474
+ return Me(o, e, t, r, n, i);
496
475
  case "condition":
497
- return xe(o, e, t, r);
476
+ return Ie(o, e, t, r);
498
477
  case "subquery":
499
- return Ce(o, e, t, r, n, i);
478
+ return Le(o, e, t, r, n, i);
500
479
  }
501
480
  }
502
- function ke(o, e, t, r, n, i) {
481
+ function Me(o, e, t, r, n, i) {
503
482
  if (o.children.length === 0)
504
483
  return o.logic === "and" ? "TRUE" : "FALSE";
505
484
  const s = o.logic === "and" ? ` ${r.logicAnd} ` : ` ${r.logicOr} `;
506
- return `(${o.children.map((d) => B(d, e, t, r, n + 1, i)).join(s)})`;
485
+ return `(${o.children.map((a) => U(a, e, t, r, n + 1, i)).join(s)})`;
507
486
  }
508
- function xe(o, e, t, r) {
509
- const i = re(e, t, o.field)?.label ?? o.field, s = r.operators[o.operator] ?? o.operator, a = De(o.operator, o.value);
510
- return a === "" ? `${i} ${s}` : `${i} ${s} ${a}`;
487
+ function Ie(o, e, t, r) {
488
+ const i = ie(e, t, o.field)?.label ?? o.field, s = r.operators[o.operator] ?? o.operator, d = Pe(o.operator, o.value);
489
+ return d === "" ? `${i} ${s}` : `${i} ${s} ${d}`;
511
490
  }
512
- function Ce(o, e, t, r, n, i) {
513
- const s = re(e, t, o.field), a = s?.label ?? o.field, d = r.operators[o.operator] ?? o.operator, l = s?.targetEntity ?? "", u = B(o.subQuery, e, l, r, n + 1, i);
514
- return `${a} ${d} ${u}`;
491
+ function Le(o, e, t, r, n, i) {
492
+ const s = ie(e, t, o.field), d = s?.label ?? o.field, a = r.operators[o.operator] ?? o.operator, u = s?.targetEntity ?? "", l = U(o.subQuery, e, u, r, n + 1, i);
493
+ return `${d} ${a} ${l}`;
515
494
  }
516
- function De(o, e) {
517
- const t = h(o);
495
+ function Pe(o, e) {
496
+ const t = q(o);
518
497
  if (t === "null") return "";
519
498
  if (t === "tuple" && Array.isArray(e))
520
- return `[${e.map(I).join(", ")}]`;
499
+ return `[${e.map(F).join(", ")}]`;
521
500
  if (t === "array" && Array.isArray(e))
522
- return `[${e.map(I).join(", ")}]`;
501
+ return `[${e.map(F).join(", ")}]`;
523
502
  if (t === "n-input" && typeof e == "object" && e !== null) {
524
503
  const r = e.n;
525
504
  return typeof r == "number" ? String(r) : JSON.stringify(e);
526
505
  }
527
- return I(e);
506
+ return F(e);
528
507
  }
529
- function I(o) {
508
+ function F(o) {
530
509
  return o == null ? "?" : typeof o == "string" ? `"${o}"` : o instanceof Date ? o.toISOString() : String(o);
531
510
  }
532
- function re(o, e, t) {
511
+ function ie(o, e, t) {
533
512
  return o.find((r) => r.name === e)?.fields.find((r) => r.name === t);
534
513
  }
535
- const Se = A(`.form-control[data-mps=query-builder] {
514
+ const Ne = T(`.form-control[data-mps=query-builder] {
536
515
  display: block;
537
516
  width: 100%;
538
517
  padding: 0.375rem 0.75rem;
@@ -764,7 +743,7 @@ mp-query-builder {
764
743
  }
765
744
 
766
745
  .qb-sort-add[data-mps=query-builder] {
767
- --bs-btn-color: #646b72;
746
+ --bs-btn-color: var(--bs-secondary-color);
768
747
  }
769
748
 
770
749
  .qb-too-deep[data-mps=query-builder] {
@@ -824,7 +803,7 @@ mp-query-builder {
824
803
  color: var(--bs-body-color, currentColor);
825
804
  white-space: pre-wrap;
826
805
  word-break: break-word;
827
- }`), Re = A(`.form-control[data-mps=query-condition] {
806
+ }`), Fe = T(`.form-control[data-mps=query-condition] {
828
807
  display: block;
829
808
  width: 100%;
830
809
  padding: 0.375rem 0.75rem;
@@ -1030,10 +1009,17 @@ textarea.form-control-lg[data-mps=query-condition] {
1030
1009
  border-radius: var(--bs-border-radius-lg);
1031
1010
  }
1032
1011
 
1033
- [data-bs-theme=dark][data-mps=query-condition] .form-select[data-mps=query-condition] {
1034
- --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
1012
+ @container style(--mp-color-mode: dark) {
1013
+ .form-select[data-mps=query-condition] {
1014
+ --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
1015
+ }
1016
+ }
1017
+ @media (forced-colors: active) {
1018
+ .form-select[data-mps=query-condition] {
1019
+ appearance: auto;
1020
+ background-image: none;
1021
+ }
1035
1022
  }
1036
-
1037
1023
  mp-query-condition {
1038
1024
  display: block;
1039
1025
  }
@@ -1202,7 +1188,7 @@ mp-query-condition {
1202
1188
  .qb-editor-chip-add:focus[data-mps=query-condition] {
1203
1189
  outline: none;
1204
1190
  box-shadow: none;
1205
- }`), Ae = A(`mp-query-group {
1191
+ }`), Oe = T(`mp-query-group {
1206
1192
  display: block;
1207
1193
  margin: 0.25rem 0;
1208
1194
  }
@@ -1284,7 +1270,7 @@ mp-query-condition {
1284
1270
  [data-mps=query-group] {
1285
1271
  transition-duration: 0.01ms !important;
1286
1272
  }
1287
- }`), Le = A(`mp-query-subquery {
1273
+ }`), ze = T(`mp-query-subquery {
1288
1274
  display: block;
1289
1275
  margin: 0.25rem 0;
1290
1276
  }
@@ -1316,8 +1302,8 @@ mp-query-condition {
1316
1302
  .qb-subquery-target[data-mps=query-subquery] {
1317
1303
  font-style: italic;
1318
1304
  color: var(--bs-secondary-color, #6c757d);
1319
- }`), Me = 99999;
1320
- class Te {
1305
+ }`), Qe = 99999;
1306
+ class He {
1321
1307
  constructor() {
1322
1308
  this._source = null, this._ghost = null, this._lastTarget = null, this._offsetX = 0, this._offsetY = 0;
1323
1309
  }
@@ -1336,7 +1322,7 @@ class Te {
1336
1322
  const r = e.rowElement.getBoundingClientRect();
1337
1323
  this._offsetX = t.clientX - r.left, this._offsetY = t.clientY - r.top;
1338
1324
  const n = e.rowElement.cloneNode(!0);
1339
- n.style.position = "fixed", n.style.top = `${r.top}px`, n.style.left = `${r.left}px`, n.style.width = `${r.width}px`, n.style.pointerEvents = "none", n.style.zIndex = String(Me), n.style.opacity = "0.85", n.classList.add("qb-drag-ghost"), document.body.appendChild(n), this._ghost = n;
1325
+ n.style.position = "fixed", n.style.top = `${r.top}px`, n.style.left = `${r.left}px`, n.style.width = `${r.width}px`, n.style.pointerEvents = "none", n.style.zIndex = String(Qe), n.style.opacity = "0.85", n.classList.add("qb-drag-ghost"), document.body.appendChild(n), this._ghost = n;
1340
1326
  }
1341
1327
  move(e) {
1342
1328
  if (!this._source || !this._ghost) return;
@@ -1355,70 +1341,63 @@ class Te {
1355
1341
  this._ghost && typeof document < "u" && this._ghost.remove(), this._ghost = null, this._source = null, this._lastTarget = null, this._offsetX = 0, this._offsetY = 0;
1356
1342
  }
1357
1343
  /**
1358
- * Walks `document.elementsFromPoint(x, y)` (composed path; cross-browser
1359
- * supported in Chromium / Firefox / modern WebKit) and returns the first
1360
- * `[data-drop-slot]` ancestor whose data-parent-id is NOT in the source's
1361
- * descendant set.
1362
- *
1363
- * For older WebKit which doesn't implement `elementsFromPoint`, callers
1364
- * can extend the resolver with a shadow-DOM walker (FR-38 fallback) —
1365
- * not implemented here since we target evergreen browsers.
1344
+ * The one hit-test seam: every element under (x, y), topmost first.
1345
+ * `document.elementsFromPoint` (evergreen: Chromium, Firefox, WebKit 11.1+)
1346
+ * stops at a shadow host, so the chain is extended one level into the
1347
+ * shadow root of any host it contains — the builder may itself live inside
1348
+ * another component's shadow root. Specs stub this method to say which
1349
+ * element is under the pointer; they never fake geometry.
1350
+ */
1351
+ elementsAt(e, t) {
1352
+ return Be(document.elementsFromPoint(e, t), e, t);
1353
+ }
1354
+ /**
1355
+ * Returns the first `[data-drop-slot]` under the pointer (or its ancestor)
1356
+ * that carries a complete target and whose data-parent-id is NOT in the
1357
+ * source's descendant set (cycle prevention).
1366
1358
  */
1367
1359
  resolveDropTarget(e, t) {
1368
- if (typeof document > "u") return null;
1369
1360
  const r = this._source;
1370
1361
  if (!r) return null;
1371
- const n = document.elementsFromPoint;
1372
- let i = [];
1373
- if (typeof n == "function")
1374
- i = n.call(document, e, t) ?? [];
1375
- else {
1376
- const a = document.elementFromPoint(e, t);
1377
- a && (i = [a]);
1378
- }
1379
- const s = Pe(i, e, t);
1380
- for (const a of s) {
1381
- const d = a.closest("[data-drop-slot]");
1382
- if (!d) continue;
1383
- const l = d.dataset.parentId, u = d.dataset.index, p = d.dataset.qbRoot;
1384
- if (!(!l || !u || !p) && !r.descendantIds.has(l))
1385
- return { parentId: l, index: Number(u), qbRoot: p };
1386
- }
1387
- return null;
1362
+ const i = this.elementsAt(e, t).map((s) => s.closest("[data-drop-slot]")).map((s) => s && {
1363
+ parentId: s.dataset.parentId,
1364
+ index: s.dataset.index,
1365
+ qbRoot: s.dataset.qbRoot
1366
+ }).find((s) => !!s && !!s.parentId && !!s.index && !!s.qbRoot && !r.descendantIds.has(s.parentId));
1367
+ return i ? { parentId: i.parentId, index: Number(i.index), qbRoot: i.qbRoot } : null;
1388
1368
  }
1389
1369
  }
1390
- function Pe(o, e, t) {
1391
- const r = [...o], n = /* @__PURE__ */ new Set();
1392
- for (const i of o) {
1393
- const s = i.shadowRoot;
1394
- if (!s || n.has(s)) continue;
1395
- n.add(s);
1396
- const a = s.elementFromPoint(e, t);
1397
- a && r.push(a);
1398
- }
1399
- return r;
1370
+ function Be(o, e, t) {
1371
+ const r = [...new Set(o.map((n) => n.shadowRoot).filter((n) => !!n))].map((n) => n.elementFromPoint(e, t)).filter((n) => !!n);
1372
+ return [...o, ...r];
1400
1373
  }
1401
- const O = P(
1374
+ const Q = P(
1402
1375
  Symbol("mp-query-builder.editorRegistry")
1403
- ), S = P(
1376
+ ), R = P(
1404
1377
  Symbol("mp-query-builder.disabled")
1405
- ), k = P(
1378
+ ), E = P(
1406
1379
  Symbol("mp-query-builder.messages")
1407
1380
  ), V = P(
1408
1381
  Symbol("mp-query-builder.maxDepth")
1409
- );
1410
- function R(o, e, t, r, n = {}) {
1382
+ ), se = "query-condition";
1383
+ function Ue(o) {
1384
+ return (e) => {
1385
+ const t = o(e);
1386
+ return W(t.element, se), t;
1387
+ };
1388
+ }
1389
+ function A(o, e, t, r, n = {}) {
1411
1390
  const i = document.createElement("input");
1412
1391
  i.type = o, i.className = "form-control form-control-sm qb-editor-input", i.value = e, r && (i.disabled = !0);
1413
- for (const [a, d] of Object.entries(n))
1414
- d !== void 0 && i.setAttribute(a, d);
1392
+ for (const [d, a] of Object.entries(n))
1393
+ a !== void 0 && i.setAttribute(d, a);
1415
1394
  const s = () => t(i.value);
1416
1395
  return i.addEventListener("input", s), i.addEventListener("change", s), i;
1417
1396
  }
1418
- function oe(o, e) {
1397
+ function ae(o, e) {
1419
1398
  return o == null ? "" : e === "date" && o instanceof Date ? o.toISOString().slice(0, 10) : e === "datetime" && o instanceof Date ? o.toISOString().slice(0, 16) : typeof o == "string" && (e === "date" || e === "datetime") ? e === "date" ? o.slice(0, 10) : o.slice(0, 16) : String(o);
1420
1399
  }
1421
- function ne(o, e) {
1400
+ function de(o, e) {
1422
1401
  if (o === "") return null;
1423
1402
  switch (e) {
1424
1403
  case "number":
@@ -1437,10 +1416,10 @@ function _(o) {
1437
1416
  return (e) => {
1438
1417
  const t = o === "string" ? "text" : o === "date" ? "date" : o === "datetime" ? "datetime-local" : "number", r = {};
1439
1418
  o === "integer" && (r.step = "1"), o === "number" && (r.step = "any");
1440
- const n = oe(e.value, o), i = R(
1419
+ const n = ae(e.value, o), i = A(
1441
1420
  t,
1442
1421
  n,
1443
- (s) => e.onChange(ne(s, o)),
1422
+ (s) => e.onChange(de(s, o)),
1444
1423
  e.disabled,
1445
1424
  r
1446
1425
  );
@@ -1451,20 +1430,20 @@ function X(o) {
1451
1430
  return (e) => {
1452
1431
  const t = document.createElement("span");
1453
1432
  t.className = "qb-editor-tuple";
1454
- const [r, n] = Array.isArray(e.value) ? [e.value[0] ?? null, e.value[1] ?? null] : [null, null], i = (m, F) => {
1455
- const U = Array.isArray(e.value) ? [e.value[0] ?? null, e.value[1] ?? null] : [null, null];
1456
- U[m] = ne(F, o), e.onChange(U);
1457
- }, s = (m) => oe(m, o), a = o === "date" ? "date" : o === "datetime" ? "datetime-local" : "number", d = {};
1458
- o === "integer" && (d.step = "1"), o === "number" && (d.step = "any");
1459
- const l = R(a, s(r), (m) => i(0, m), e.disabled, d), u = R(a, s(n), (m) => i(1, m), e.disabled, d);
1460
- l.setAttribute("aria-label", `${e.field.label} (from)`), u.setAttribute("aria-label", `${e.field.label} (to)`);
1461
- const p = document.createElement("span");
1462
- return p.textContent = " … ", p.className = "qb-editor-tuple-sep", t.append(l, p, u), { element: t };
1433
+ let r = Array.isArray(e.value) ? [e.value[0] ?? null, e.value[1] ?? null] : [null, null];
1434
+ const [n, i] = r, s = (y, le) => {
1435
+ r = r.map((ue, ce) => ce === y ? de(le, o) : ue), e.onChange(r);
1436
+ }, d = (y) => ae(y, o), a = o === "date" ? "date" : o === "datetime" ? "datetime-local" : "number", u = {};
1437
+ o === "integer" && (u.step = "1"), o === "number" && (u.step = "any");
1438
+ const l = A(a, d(n), (y) => s(0, y), e.disabled, u), c = A(a, d(i), (y) => s(1, y), e.disabled, u);
1439
+ l.setAttribute("aria-label", `${e.field.label} (from)`), c.setAttribute("aria-label", `${e.field.label} (to)`);
1440
+ const b = document.createElement("span");
1441
+ return b.textContent = " … ", b.className = "qb-editor-tuple-sep", t.append(l, b, c), { element: t };
1463
1442
  };
1464
1443
  }
1465
- function Fe() {
1444
+ function Ge() {
1466
1445
  return (o) => {
1467
- const e = typeof o.value == "object" && o.value !== null ? String(o.value.n ?? 1) : "1", t = R(
1446
+ const e = typeof o.value == "object" && o.value !== null ? String(o.value.n ?? 1) : "1", t = A(
1468
1447
  "number",
1469
1448
  e,
1470
1449
  (r) => {
@@ -1477,7 +1456,7 @@ function Fe() {
1477
1456
  return t.classList.add("qb-editor-n-input"), t.setAttribute("aria-label", `${o.field.label} — number of days`), { element: t };
1478
1457
  };
1479
1458
  }
1480
- function Ie(o) {
1459
+ function je(o) {
1481
1460
  return (e) => {
1482
1461
  const t = document.createElement("select");
1483
1462
  t.className = "form-select form-select-sm qb-editor-select", t.setAttribute("aria-label", e.field.label), e.disabled && (t.disabled = !0);
@@ -1497,7 +1476,7 @@ function Ie(o) {
1497
1476
  }), { element: t };
1498
1477
  };
1499
1478
  }
1500
- function Ne(o) {
1479
+ function Ve(o) {
1501
1480
  return (e) => {
1502
1481
  const t = document.createElement("select");
1503
1482
  t.className = "form-select form-select-sm qb-editor-multiselect", t.multiple = !0, t.setAttribute("aria-label", e.field.label), e.disabled && (t.disabled = !0);
@@ -1507,7 +1486,7 @@ function Ne(o) {
1507
1486
  i.value = String(n.value), i.textContent = n.label, r.includes(n.value) && (i.selected = !0), t.appendChild(i);
1508
1487
  }
1509
1488
  return t.addEventListener("change", () => {
1510
- const n = Array.from(t.selectedOptions).map((i) => o.find((a) => String(a.value) === i.value)?.value ?? i.value);
1489
+ const n = Array.from(t.selectedOptions).map((i) => o.find((d) => String(d.value) === i.value)?.value ?? i.value);
1511
1490
  e.onChange(n);
1512
1491
  }), { element: t };
1513
1492
  };
@@ -1515,58 +1494,63 @@ function Ne(o) {
1515
1494
  function Y(o) {
1516
1495
  return (e) => {
1517
1496
  const t = document.createElement("span");
1518
- return t.className = "qb-editor-chip-input", (() => {
1519
- t.innerHTML = "";
1520
- const n = Array.isArray(e.value) ? e.value : [];
1521
- for (let s = 0; s < n.length; s++) {
1522
- const a = n[s], d = document.createElement("span");
1523
- d.className = "qb-editor-chip", d.textContent = String(a);
1524
- const l = document.createElement("button");
1525
- l.type = "button", l.className = "qb-editor-chip-remove", l.setAttribute("aria-label", `Remove ${String(a)}`), l.textContent = "×", e.disabled && (l.disabled = !0), l.addEventListener("click", () => {
1526
- const u = (Array.isArray(e.value) ? e.value : []).filter((p, m) => m !== s);
1527
- e.onChange(u);
1528
- }), d.appendChild(l), t.appendChild(d);
1497
+ t.className = "qb-editor-chip-input";
1498
+ let r = Array.isArray(e.value) ? [...e.value] : [];
1499
+ const n = document.createElement("input");
1500
+ n.type = "text", n.className = "form-control form-control-sm qb-editor-chip-add", n.placeholder = "+ add", n.size = 8, n.setAttribute("aria-label", `${e.field.label} — add value`), e.disabled && (n.disabled = !0);
1501
+ const i = (a) => {
1502
+ r = a, d(), e.onChange(a);
1503
+ }, s = (a, u) => {
1504
+ const l = document.createElement("span");
1505
+ l.className = "qb-editor-chip", l.textContent = String(a);
1506
+ const c = document.createElement("button");
1507
+ return c.type = "button", c.className = "qb-editor-chip-remove", c.setAttribute("aria-label", `Remove ${String(a)}`), c.textContent = "×", e.disabled && (c.disabled = !0), c.addEventListener("click", () => i(r.filter((b, y) => y !== u))), l.appendChild(c), W(l, se), l;
1508
+ }, d = () => {
1509
+ const a = document.createRange();
1510
+ a.selectNodeContents(t), a.setEndBefore(n), a.deleteContents(), n.before(...r.map(s));
1511
+ };
1512
+ return t.appendChild(n), n.addEventListener("keydown", (a) => {
1513
+ if (a.key === "Enter" && n.value.trim() !== "") {
1514
+ a.preventDefault();
1515
+ const u = o(n.value.trim());
1516
+ n.value = "", i([...r, u]);
1529
1517
  }
1530
- const i = document.createElement("input");
1531
- i.type = "text", i.className = "form-control form-control-sm qb-editor-chip-add", i.placeholder = "+ add", i.size = 8, i.setAttribute("aria-label", `${e.field.label} — add value`), e.disabled && (i.disabled = !0), i.addEventListener("keydown", (s) => {
1532
- if (s.key === "Enter" && i.value.trim() !== "") {
1533
- s.preventDefault();
1534
- const a = o(i.value.trim()), d = [...Array.isArray(e.value) ? e.value : [], a];
1535
- i.value = "", e.onChange(d);
1536
- }
1537
- }), t.appendChild(i);
1538
- })(), {
1518
+ }), d(), {
1539
1519
  element: t,
1540
1520
  dispose: () => {
1541
1521
  }
1542
1522
  };
1543
1523
  };
1544
1524
  }
1545
- function ze(o, e) {
1546
- const t = h(e);
1525
+ function Xe(o, e) {
1526
+ const t = Ye(o, e);
1527
+ return t ? Ue(t) : null;
1528
+ }
1529
+ function Ye(o, e) {
1530
+ const t = q(e);
1547
1531
  if (t === "null") return null;
1548
- if (t === "n-input") return Fe();
1532
+ if (t === "n-input") return Ge();
1549
1533
  if (t === "tuple") {
1550
1534
  const r = o.type;
1551
1535
  return X(r === "number" || r === "integer" || r === "date" || r === "datetime" ? r : "number");
1552
1536
  }
1553
- return t === "array" ? o.options && o.options.length > 0 ? Ne(o.options) : o.type === "number" || o.type === "integer" ? Y(
1537
+ return t === "array" ? o.options && o.options.length > 0 ? Ve(o.options) : o.type === "number" || o.type === "integer" ? Y(
1554
1538
  (r) => o.type === "integer" ? Number.parseInt(r, 10) : Number(r)
1555
- ) : Y((r) => r) : o.type === "enum" && o.options && o.options.length > 0 ? Ie(o.options) : o.type === "string" ? _("string") : o.type === "number" ? _("number") : o.type === "integer" ? _("integer") : o.type === "date" ? _("date") : o.type === "datetime" ? _("datetime") : null;
1539
+ ) : Y((r) => r) : o.type === "enum" && o.options && o.options.length > 0 ? je(o.options) : o.type === "string" ? _("string") : o.type === "number" ? _("number") : o.type === "integer" ? _("integer") : o.type === "date" ? _("date") : o.type === "datetime" ? _("datetime") : null;
1556
1540
  }
1557
- const q = M("query-condition");
1558
- class Oe extends L {
1541
+ const v = I("query-condition");
1542
+ class Ke extends M {
1559
1543
  constructor() {
1560
- super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this._messagesConsumer = new f(this, {
1561
- context: k,
1544
+ super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this._messagesConsumer = new h(this, {
1545
+ context: E,
1562
1546
  subscribe: !0
1563
- }), this._disabledConsumer = new f(this, {
1564
- context: S,
1547
+ }), this._disabledConsumer = new h(this, {
1548
+ context: R,
1565
1549
  subscribe: !0
1566
- }), this._registryConsumer = new f(this, {
1567
- context: O,
1550
+ }), this._registryConsumer = new h(this, {
1551
+ context: Q,
1568
1552
  subscribe: !0
1569
- }), this._editorMount = ie(), this._currentHandle = null, this._editorKey = "", this._registryTokens = /* @__PURE__ */ new WeakMap(), this._nextRegistryToken = 1, this._onFieldChange = (e) => {
1553
+ }), this._editorMount = me(), this._currentHandle = null, this._editorKey = "", this._registryTokens = /* @__PURE__ */ new WeakMap(), this._nextRegistryToken = 1, this._onFieldChange = (e) => {
1570
1554
  const t = e.target, r = this.node;
1571
1555
  r && this.dispatchEvent(new CustomEvent("condition-field-change", {
1572
1556
  detail: { id: r.id, field: t.value },
@@ -1632,6 +1616,9 @@ class Oe extends L {
1632
1616
  const r = this._nextRegistryToken++;
1633
1617
  return this._registryTokens.set(e, r), r;
1634
1618
  }
1619
+ connectedCallback() {
1620
+ super.connectedCallback(), be();
1621
+ }
1635
1622
  disconnectedCallback() {
1636
1623
  super.disconnectedCallback(), this._disposeEditor();
1637
1624
  }
@@ -1651,9 +1638,9 @@ class Oe extends L {
1651
1638
  messages() {
1652
1639
  const e = this._messagesConsumer.value ?? {};
1653
1640
  return {
1654
- ...y,
1641
+ ...f,
1655
1642
  ...e,
1656
- operators: { ...y.operators, ...e.operators ?? {} }
1643
+ operators: { ...f.operators, ...e.operators ?? {} }
1657
1644
  };
1658
1645
  }
1659
1646
  isDisabled() {
@@ -1663,10 +1650,8 @@ class Oe extends L {
1663
1650
  this._refreshEditor();
1664
1651
  }
1665
1652
  _refreshEditor() {
1666
- const e = this._editorMount.value;
1667
- if (!e) return;
1668
- const t = this.node;
1669
- if (!t) {
1653
+ const e = this._editorMount.value, t = this.node;
1654
+ if (!e || !t) {
1670
1655
  this._disposeEditor();
1671
1656
  return;
1672
1657
  }
@@ -1675,41 +1660,37 @@ class Oe extends L {
1675
1660
  this._disposeEditor();
1676
1661
  return;
1677
1662
  }
1678
- if (h(t.operator) === "null") {
1679
- this._disposeEditor();
1680
- return;
1681
- }
1682
- const i = this.isDisabled(), s = this._registryConsumer.value, a = s?.[r.name], d = a ? `r${this._registryIdentityToken(s)}` : "b", l = `${r.name}|${t.operator}|${i ? "1" : "0"}|${d}`;
1683
- if (this._currentHandle && l === this._editorKey) return;
1663
+ const n = this.isDisabled(), i = this._registryConsumer.value, s = i?.[r.name], d = s ? `r${this._registryIdentityToken(i)}` : "b", a = `${r.name}|${t.operator}|${n ? "1" : "0"}|${d}`;
1664
+ if (this._currentHandle && a === this._editorKey) return;
1684
1665
  this._disposeEditor();
1685
- const u = a ?? ze(r, t.operator);
1666
+ const u = s ?? Xe(r, t.operator);
1686
1667
  if (!u) return;
1687
- const p = {
1668
+ const l = {
1688
1669
  field: r,
1689
1670
  operator: t.operator,
1690
1671
  value: t.value,
1691
- disabled: i,
1692
- onChange: (F) => {
1672
+ disabled: n,
1673
+ onChange: (b) => {
1693
1674
  this.dispatchEvent(new CustomEvent("condition-value-change", {
1694
- detail: { id: t.id, value: F },
1675
+ detail: { id: t.id, value: b },
1695
1676
  bubbles: !0,
1696
1677
  composed: !0
1697
1678
  }));
1698
1679
  }
1699
- }, m = u(p);
1700
- e.appendChild(m.element), this._currentHandle = m, this._editorKey = l;
1680
+ }, c = u(l);
1681
+ e.appendChild(c.element), this._currentHandle = c, this._editorKey = a;
1701
1682
  }
1702
1683
  _availableFields() {
1703
1684
  return this.schema.find((e) => e.name === this.currentEntity)?.fields.filter((e) => e.type !== "relation") ?? [];
1704
1685
  }
1705
1686
  _availableOperators(e) {
1706
- return e ? w(e.type) : [];
1687
+ return e ? k(e.type) : [];
1707
1688
  }
1708
1689
  render() {
1709
1690
  const e = this.node;
1710
- if (!e) return c;
1711
- const t = this.resolveField(e.field), r = this.messages(), n = h(e.operator), i = this.isDisabled(), s = this._availableFields(), a = this._availableOperators(t);
1712
- return q`
1691
+ if (!e) return m;
1692
+ const t = this.resolveField(e.field), r = this.messages(), n = q(e.operator), i = this.isDisabled(), s = this._availableFields(), d = this._availableOperators(t);
1693
+ return v`
1713
1694
  <div
1714
1695
  class="qb-condition"
1715
1696
  tabindex="0"
@@ -1737,8 +1718,8 @@ class Oe extends L {
1737
1718
  @change=${this._onFieldChange}
1738
1719
  aria-label=${r.field}
1739
1720
  >
1740
- ${s.map((d) => q`<option value=${d.name}>${d.label}</option>`)}
1741
- ${t ? c : q`<option value=${e.field}>(${e.field})</option>`}
1721
+ ${s.map((a) => v`<option value=${a.name}>${a.label}</option>`)}
1722
+ ${t ? m : v`<option value=${e.field}>(${e.field})</option>`}
1742
1723
  </mp-select>
1743
1724
  <mp-select
1744
1725
  class="qb-operator-select"
@@ -1748,12 +1729,12 @@ class Oe extends L {
1748
1729
  @change=${this._onOperatorChange}
1749
1730
  aria-label=${r.operator}
1750
1731
  >
1751
- ${a.map((d) => q`
1752
- <option value=${d}>${r.operators[d] ?? d}</option>
1732
+ ${d.map((a) => v`
1733
+ <option value=${a}>${r.operators[a] ?? a}</option>
1753
1734
  `)}
1754
- ${a.includes(e.operator) ? c : q`<option value=${e.operator}>${e.operator}</option>`}
1735
+ ${d.includes(e.operator) ? m : v`<option value=${e.operator}>${e.operator}</option>`}
1755
1736
  </mp-select>
1756
- ${n === "null" ? c : q`<span class="qb-value" ${se(this._editorMount)}></span>`}
1737
+ ${n === "null" ? m : v`<span class="qb-value" ${pe(this._editorMount)}></span>`}
1757
1738
  <button
1758
1739
  type="button"
1759
1740
  class="btn btn-sm btn-link qb-remove"
@@ -1766,13 +1747,13 @@ class Oe extends L {
1766
1747
  `;
1767
1748
  }
1768
1749
  }
1769
- T("query-condition", Re);
1770
- typeof customElements < "u" && !customElements.get("mp-query-condition") && customElements.define("mp-query-condition", Oe);
1771
- const K = M("query-subquery");
1772
- class Qe extends L {
1750
+ L("query-condition", Fe);
1751
+ typeof customElements < "u" && !customElements.get("mp-query-condition") && customElements.define("mp-query-condition", Ke);
1752
+ const K = I("query-subquery");
1753
+ class We extends M {
1773
1754
  constructor() {
1774
- super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this.depth = 0, this.qbRoot = "", this.isDragging = !1, this._messagesConsumer = new f(this, {
1775
- context: k,
1755
+ super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this.depth = 0, this.qbRoot = "", this.isDragging = !1, this._messagesConsumer = new h(this, {
1756
+ context: E,
1776
1757
  subscribe: !0
1777
1758
  }), this._onHeaderKeyDown = (e) => {
1778
1759
  if (!e.altKey || e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
@@ -1805,14 +1786,14 @@ class Qe extends L {
1805
1786
  messages() {
1806
1787
  const e = this._messagesConsumer.value ?? {};
1807
1788
  return {
1808
- ...y,
1789
+ ...f,
1809
1790
  ...e,
1810
- operators: { ...y.operators, ...e.operators ?? {} }
1791
+ operators: { ...f.operators, ...e.operators ?? {} }
1811
1792
  };
1812
1793
  }
1813
1794
  render() {
1814
1795
  const e = this.node;
1815
- if (!e) return c;
1796
+ if (!e) return m;
1816
1797
  const t = this.resolveField(e.field), r = this.messages(), n = t?.label ?? e.field, i = r.operators[e.operator] ?? e.operator, s = t?.targetEntity ?? "";
1817
1798
  return K`
1818
1799
  <div class="qb-subquery" data-row-id=${e.id}>
@@ -1827,28 +1808,29 @@ class Qe extends L {
1827
1808
  >
1828
1809
  <span class="qb-subquery-field">${n}</span>
1829
1810
  <span class="qb-subquery-operator">${i}</span>
1830
- ${s ? K`<span class="qb-subquery-target">(${s})</span>` : c}
1811
+ ${s ? K`<span class="qb-subquery-target">(${s})</span>` : m}
1831
1812
  </div>
1832
1813
  <mp-query-builder
1833
1814
  .query=${e.subQuery}
1834
1815
  .schema=${this.schema}
1835
1816
  .rootEntity=${s}
1836
1817
  .depth=${this.depth + 1}
1818
+ .dragActive=${this.isDragging}
1837
1819
  ></mp-query-builder>
1838
1820
  </div>
1839
1821
  `;
1840
1822
  }
1841
1823
  }
1842
- T("query-subquery", Le);
1843
- typeof customElements < "u" && !customElements.get("mp-query-subquery") && customElements.define("mp-query-subquery", Qe);
1844
- const g = M("query-group");
1845
- class He extends L {
1824
+ L("query-subquery", ze);
1825
+ typeof customElements < "u" && !customElements.get("mp-query-subquery") && customElements.define("mp-query-subquery", We);
1826
+ const g = I("query-group");
1827
+ class Je extends M {
1846
1828
  constructor() {
1847
- super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this.depth = 0, this.isRoot = !1, this.qbRoot = "", this.isDragging = !1, this._messagesConsumer = new f(this, {
1848
- context: k,
1829
+ super(...arguments), this.node = null, this.schema = [], this.currentEntity = "", this.depth = 0, this.isRoot = !1, this.qbRoot = "", this.isDragging = !1, this._messagesConsumer = new h(this, {
1830
+ context: E,
1849
1831
  subscribe: !0
1850
- }), this._disabledConsumer = new f(this, {
1851
- context: S,
1832
+ }), this._disabledConsumer = new h(this, {
1833
+ context: R,
1852
1834
  subscribe: !0
1853
1835
  }), this._onLogicChange = (e) => {
1854
1836
  const t = this.node;
@@ -1889,9 +1871,9 @@ class He extends L {
1889
1871
  messages() {
1890
1872
  const e = this._messagesConsumer.value ?? {};
1891
1873
  return {
1892
- ...y,
1874
+ ...f,
1893
1875
  ...e,
1894
- operators: { ...y.operators, ...e.operators ?? {} }
1876
+ operators: { ...f.operators, ...e.operators ?? {} }
1895
1877
  };
1896
1878
  }
1897
1879
  renderChild(e) {
@@ -1923,7 +1905,7 @@ class He extends L {
1923
1905
  }
1924
1906
  }
1925
1907
  renderDropSlot(e) {
1926
- return !this.isDragging || !this.node ? c : g`<div
1908
+ return !this.isDragging || !this.node ? m : g`<div
1927
1909
  class="qb-drop-slot"
1928
1910
  data-drop-slot
1929
1911
  data-parent-id=${this.node.id}
@@ -1951,11 +1933,12 @@ class He extends L {
1951
1933
  }
1952
1934
  render() {
1953
1935
  const e = this.node;
1954
- if (!e) return c;
1936
+ if (!e) return m;
1955
1937
  const t = this.messages(), r = this.isDisabled(), n = this._hasRelation();
1956
1938
  return g`
1957
1939
  <div
1958
1940
  class="qb-group"
1941
+ data-row-id=${e.id}
1959
1942
  role="group"
1960
1943
  aria-label=${// Depth rides in the NAME: aria-level is not an allowed attribute
1961
1944
  // on role=group (axe aria-allowed-attr, serious) — it belongs to
@@ -1997,8 +1980,8 @@ class He extends L {
1997
1980
  class="btn btn-sm btn-outline-secondary qb-add-subquery"
1998
1981
  ?disabled=${r}
1999
1982
  @click=${this._onAddSubquery}
2000
- >+ ${t.addSubquery}</button>` : c}
2001
- ${this.isRoot ? c : g`<button
1983
+ >+ ${t.addSubquery}</button>` : m}
1984
+ ${this.isRoot ? m : g`<button
2002
1985
  type="button"
2003
1986
  class="btn btn-sm btn-link qb-remove-group"
2004
1987
  ?disabled=${r}
@@ -2015,30 +1998,30 @@ class He extends L {
2015
1998
  `;
2016
1999
  }
2017
2000
  }
2018
- T("query-group", Ae);
2019
- typeof customElements < "u" && !customElements.get("mp-query-group") && customElements.define("mp-query-group", He);
2020
- const b = M("query-builder"), Be = 32;
2021
- class Ue extends L {
2001
+ L("query-group", Oe);
2002
+ typeof customElements < "u" && !customElements.get("mp-query-group") && customElements.define("mp-query-group", Je);
2003
+ const Ze = "mp-query-group, mp-query-condition, mp-query-subquery, mp-query-builder", p = I("query-builder"), et = 32;
2004
+ class tt extends M {
2022
2005
  constructor() {
2023
- super(...arguments), this.query = null, this.schema = [], this.rootEntity = "", this.multiEntityPickerEnabled = !1, this.selectedFields = [], this.sortBy = [], this.disabled = !1, this.editorRegistry = void 0, this.messages = void 0, this.maxDepth = Be, this.showPreview = !1, this.showSavedQueries = !1, this.savedQueries = [], this._saveDraftName = "", this.depth = 0, this._qbRootId = `qb-${Math.random().toString(36).slice(2, 10)}`, this._isDragging = !1, this._drag = new Te(), this._pointerMoveHandler = null, this._pointerUpHandler = null, this._pointerCancelHandler = null, this._registryConsumer = new f(this, {
2024
- context: O,
2006
+ super(...arguments), this.query = null, this.schema = [], this.rootEntity = "", this.multiEntityPickerEnabled = !1, this.selectedFields = [], this.sortBy = [], this.disabled = !1, this.editorRegistry = void 0, this.messages = void 0, this.maxDepth = et, this.showPreview = !1, this.showSavedQueries = !1, this.savedQueries = [], this._saveDraftName = "", this.depth = 0, this.dragActive = !1, this._qbRootId = `qb-${Math.random().toString(36).slice(2, 10)}`, this._isDragging = !1, this._drag = new He(), this._pointerMoveHandler = null, this._pointerUpHandler = null, this._pointerCancelHandler = null, this._registryConsumer = new h(this, {
2007
+ context: Q,
2025
2008
  subscribe: !0
2026
2009
  }), this._registryProvider = new x(this, {
2027
- context: O,
2010
+ context: Q,
2028
2011
  initialValue: void 0
2029
- }), this._disabledConsumer = new f(this, {
2030
- context: S,
2012
+ }), this._disabledConsumer = new h(this, {
2013
+ context: R,
2031
2014
  subscribe: !0
2032
2015
  }), this._disabledProvider = new x(this, {
2033
- context: S,
2016
+ context: R,
2034
2017
  initialValue: void 0
2035
- }), this._messagesConsumer = new f(this, {
2036
- context: k,
2018
+ }), this._messagesConsumer = new h(this, {
2019
+ context: E,
2037
2020
  subscribe: !0
2038
2021
  }), this._messagesProvider = new x(this, {
2039
- context: k,
2022
+ context: E,
2040
2023
  initialValue: void 0
2041
- }), this._maxDepthConsumer = new f(this, {
2024
+ }), this._maxDepthConsumer = new h(this, {
2042
2025
  context: V,
2043
2026
  subscribe: !0
2044
2027
  }), this._maxDepthProvider = new x(this, {
@@ -2049,49 +2032,49 @@ class Ue extends L {
2049
2032
  e.stopPropagation();
2050
2033
  const { id: t, field: r } = e.detail, n = this.query;
2051
2034
  if (!n) return;
2052
- const s = this._resolveEntityForNode(t)?.fields.find((a) => a.name === r);
2053
- s && this._mutate(ve(n, t, s));
2035
+ const s = this._resolveEntityForNode(t)?.fields.find((d) => d.name === r);
2036
+ s && this._mutate(Ce(n, t, s));
2054
2037
  }, this._onConditionOperatorChange = (e) => {
2055
2038
  if (!this._handlesEvents()) return;
2056
2039
  e.stopPropagation();
2057
2040
  const { id: t, operator: r } = e.detail, n = this.query;
2058
- n && this._mutate(qe(n, t, r));
2041
+ n && this._mutate(Se(n, t, r));
2059
2042
  }, this._onConditionValueChange = (e) => {
2060
2043
  if (!this._handlesEvents()) return;
2061
2044
  e.stopPropagation();
2062
2045
  const { id: t, value: r } = e.detail, n = this.query;
2063
- n && this._mutate(ge(n, t, { value: r }));
2046
+ n && this._mutate(xe(n, t, { value: r }));
2064
2047
  }, this._onGroupLogicChange = (e) => {
2065
2048
  if (!this._handlesEvents()) return;
2066
2049
  e.stopPropagation();
2067
2050
  const { id: t, logic: r } = e.detail, n = this.query;
2068
- n && this._mutate(ye(n, t, r));
2051
+ n && this._mutate(ke(n, t, r));
2069
2052
  }, this._onAddCondition = (e) => {
2070
2053
  if (!this._handlesEvents()) return;
2071
2054
  e.stopPropagation();
2072
2055
  const { groupId: t } = e.detail, r = this.query;
2073
2056
  if (!r) return;
2074
2057
  const n = this._resolveEntityForNode(t);
2075
- n && this._mutate(be(r, t, n));
2058
+ n && this._mutate(_e(r, t, n));
2076
2059
  }, this._onAddGroup = (e) => {
2077
2060
  if (!this._handlesEvents()) return;
2078
2061
  e.stopPropagation();
2079
2062
  const { groupId: t } = e.detail, r = this.query;
2080
- r && this._mutate(he(r, t, "and"));
2063
+ r && this._mutate($e(r, t, "and"));
2081
2064
  }, this._onAddSubquery = (e) => {
2082
2065
  if (!this._handlesEvents()) return;
2083
2066
  e.stopPropagation();
2084
2067
  const { groupId: t } = e.detail, r = this.query;
2085
2068
  if (!r) return;
2086
2069
  const n = this._resolveEntityForNode(t);
2087
- n && this._mutate(fe(r, t, n));
2070
+ n && this._mutate(Ee(r, t, n));
2088
2071
  }, this._onNodeRemove = (e) => {
2089
2072
  if (!this._handlesEvents()) return;
2090
2073
  e.stopPropagation();
2091
2074
  const { id: t } = e.detail, r = this.query;
2092
2075
  if (!r || r.id === t) return;
2093
2076
  const n = D(r, t);
2094
- this._pendingRefocusId = n?.parent.id ?? r.id, this._mutate(Z(r, t));
2077
+ this._pendingRefocusId = n?.parent.id ?? r.id, this._mutate(te(r, t));
2095
2078
  }, this._pendingRefocusId = null, this._onKeyboardMove = (e) => {
2096
2079
  if (!this._handlesEvents()) return;
2097
2080
  e.stopPropagation();
@@ -2106,9 +2089,9 @@ class Ue extends L {
2106
2089
  e.stopPropagation();
2107
2090
  const t = e.detail, r = this.query;
2108
2091
  if (!r) return;
2109
- const n = E(r, t.id);
2092
+ const n = $(r, t.id);
2110
2093
  if (!n) return;
2111
- const i = J(n);
2094
+ const i = ee(n);
2112
2095
  this._drag.start(
2113
2096
  {
2114
2097
  id: t.id,
@@ -2166,6 +2149,7 @@ class Ue extends L {
2166
2149
  showSavedQueries: { attribute: "show-saved-queries", type: Boolean, reflect: !0 },
2167
2150
  savedQueries: { attribute: !1 },
2168
2151
  depth: { attribute: !1 },
2152
+ dragActive: { attribute: !1 },
2169
2153
  _isDragging: { state: !0 },
2170
2154
  _saveDraftName: { state: !0 }
2171
2155
  };
@@ -2178,27 +2162,25 @@ class Ue extends L {
2178
2162
  const n = this.messages, i = this._messagesConsumer.value;
2179
2163
  let s;
2180
2164
  this._lastEffMessages !== void 0 && this._lastMessagesOwn === n && this._lastMessagesConsumed === i ? s = this._lastEffMessages : (s = { ...i ?? {}, ...n ?? {} }, this._lastMessagesOwn = n, this._lastMessagesConsumed = i, this._lastEffMessages = s), this._messagesProvider.setValue(s);
2181
- const d = this._maxDepthConsumer.value ?? this.maxDepth;
2182
- this._maxDepthProvider.setValue(d);
2165
+ const a = this._maxDepthConsumer.value ?? this.maxDepth;
2166
+ this._maxDepthProvider.setValue(a);
2183
2167
  }
2184
2168
  updated(e) {
2185
2169
  if (this._pendingRefocusId === null) return;
2186
2170
  const t = this._pendingRefocusId;
2187
- this._pendingRefocusId = null, queueMicrotask(() => this._focusRowById(t));
2171
+ this._pendingRefocusId = null, this._descendantsSettled().then(() => this._focusRowById(t));
2172
+ }
2173
+ async _descendantsSettled() {
2174
+ const e = Array.from(this.querySelectorAll(Ze)).filter((t) => t.isUpdatePending);
2175
+ if (e.length !== 0)
2176
+ return await Promise.all(e.map((t) => t.updateComplete)), this._descendantsSettled();
2188
2177
  }
2189
2178
  _focusRowById(e) {
2190
- const t = (n) => {
2191
- const i = n.querySelector(`[data-row-id="${e}"]`);
2192
- if (i)
2193
- return i.querySelector(".qb-subquery-header") ?? i;
2194
- for (const s of Array.from(n.querySelectorAll("*")))
2195
- if (s.shadowRoot) {
2196
- const a = t(s.shadowRoot);
2197
- if (a) return a;
2198
- }
2199
- return null;
2200
- };
2201
- t(this.renderRoot)?.focus();
2179
+ const t = this.querySelector(`[data-row-id="${e}"]`);
2180
+ if (!t) return;
2181
+ (t.querySelector(
2182
+ ":scope > .qb-subquery-header, :scope > .qb-group-header .qb-add-condition"
2183
+ ) ?? t).focus();
2202
2184
  }
2203
2185
  /**
2204
2186
  * Effective max-depth used for the render check. The OUTER builder's
@@ -2218,15 +2200,15 @@ class Ue extends L {
2218
2200
  if (!t) return null;
2219
2201
  const r = this.query;
2220
2202
  if (!r) return t;
2221
- const n = { entity: t }, i = (s, a) => {
2203
+ const n = { entity: t }, i = (s, d) => {
2222
2204
  if (s.id === e)
2223
- return n.entity = a, !0;
2205
+ return n.entity = d, !0;
2224
2206
  if (s.kind === "group") {
2225
- for (const d of s.children)
2226
- if (i(d, a)) return !0;
2207
+ for (const a of s.children)
2208
+ if (i(a, d)) return !0;
2227
2209
  } else if (s.kind === "subquery") {
2228
- const d = a.fields.find((u) => u.name === s.field), l = d?.targetEntity ? this.schema.find((u) => u.name === d.targetEntity) ?? a : a;
2229
- if (i(s.subQuery, l)) return !0;
2210
+ const a = d.fields.find((l) => l.name === s.field), u = a?.targetEntity ? this.schema.find((l) => l.name === a.targetEntity) ?? d : d;
2211
+ if (i(s.subQuery, u)) return !0;
2230
2212
  }
2231
2213
  return !1;
2232
2214
  };
@@ -2247,8 +2229,8 @@ class Ue extends L {
2247
2229
  return this.depth === 0;
2248
2230
  }
2249
2231
  _finishDrag(e) {
2250
- const t = this._drag.end(e);
2251
- this._teardownDragListeners(), this._isDragging = !1, t && this._applyDrop(t);
2232
+ const t = this._drag.source(), r = this._drag.end(e);
2233
+ this._teardownDragListeners(), this._isDragging = !1, !(!r || !t) && this._applyDrop(t, r);
2252
2234
  }
2253
2235
  _cancelDrag() {
2254
2236
  this._drag.cancel(), this._teardownDragListeners(), this._isDragging = !1;
@@ -2256,38 +2238,20 @@ class Ue extends L {
2256
2238
  _teardownDragListeners() {
2257
2239
  typeof window > "u" || (this._pointerMoveHandler && window.removeEventListener("pointermove", this._pointerMoveHandler), this._pointerUpHandler && window.removeEventListener("pointerup", this._pointerUpHandler), this._pointerCancelHandler && window.removeEventListener("pointercancel", this._pointerCancelHandler), this._pointerMoveHandler = null, this._pointerUpHandler = null, this._pointerCancelHandler = null);
2258
2240
  }
2259
- _applyDrop(e) {
2260
- const t = this.query, r = this._drag.source();
2261
- if (!t || !r) return;
2262
- const n = e.qbRoot !== r.qbRoot ? this._schemaForGroup(e.parentId) : void 0, i = j(t, r.id, e.parentId, e.index, n);
2263
- this._mutate(i);
2264
- }
2265
- _schemaForGroup(e) {
2266
- const t = this.query;
2267
- if (!t) return;
2268
- const r = this._entitySchemaForCurrentRoot();
2241
+ _applyDrop(e, t) {
2242
+ const r = this.query;
2269
2243
  if (!r) return;
2270
- const n = { schema: r }, i = (s, a) => {
2271
- if (s.id === e)
2272
- return n.schema = a, !0;
2273
- if (s.kind === "group") {
2274
- for (const d of s.children) if (i(d, a)) return !0;
2275
- } else if (s.kind === "subquery") {
2276
- const d = a.fields.find((u) => u.name === s.field), l = d?.targetEntity ? this.schema.find((u) => u.name === d.targetEntity) ?? a : a;
2277
- if (i(s.subQuery, l)) return !0;
2278
- }
2279
- return !1;
2280
- };
2281
- return i(t, r), n.schema;
2244
+ const n = t.qbRoot !== e.qbRoot ? this._resolveEntityForNode(t.parentId) ?? void 0 : void 0, i = j(r, e.id, t.parentId, t.index, n);
2245
+ this._mutate(i);
2282
2246
  }
2283
2247
  disconnectedCallback() {
2284
2248
  super.disconnectedCallback(), this._teardownDragListeners(), this._drag.cancel();
2285
2249
  }
2286
2250
  _renderSavedPicker(e) {
2287
- return b`
2251
+ return p`
2288
2252
  <div class="qb-saved">
2289
2253
  <div class="qb-saved-list">
2290
- ${this.savedQueries.length === 0 ? b`<span class="qb-saved-empty">No saved queries</span>` : this.savedQueries.map((t) => b`
2254
+ ${this.savedQueries.length === 0 ? p`<span class="qb-saved-empty">No saved queries</span>` : this.savedQueries.map((t) => p`
2291
2255
  <span class="qb-saved-row" data-name=${t.name}>
2292
2256
  <button
2293
2257
  type="button"
@@ -2329,11 +2293,11 @@ class Ue extends L {
2329
2293
  * Phase-2 widgets (field projection, sort-by) hang off this same toolbar.
2330
2294
  */
2331
2295
  _renderToolbar() {
2332
- if (this.depth !== 0) return c;
2333
- if (!this.multiEntityPickerEnabled) return c;
2334
- if (this.schema.length < 2) return c;
2296
+ if (this.depth !== 0) return m;
2297
+ if (!this.multiEntityPickerEnabled) return m;
2298
+ if (this.schema.length < 2) return m;
2335
2299
  const t = this.schema.find((n) => n.name === this.rootEntity)?.fields.filter((n) => n.type !== "relation") ?? [], r = this._messages();
2336
- return b`
2300
+ return p`
2337
2301
  <div class="qb-toolbar">
2338
2302
  <label class="qb-toolbar-label">
2339
2303
  Entity:
@@ -2345,13 +2309,13 @@ class Ue extends L {
2345
2309
  @change=${this._onRootEntityChange}
2346
2310
  aria-label=${r.entity}
2347
2311
  >
2348
- ${this.schema.map((n) => b`<option value=${n.name}>${n.label}</option>`)}
2312
+ ${this.schema.map((n) => p`<option value=${n.name}>${n.label}</option>`)}
2349
2313
  </mp-select>
2350
2314
  </label>
2351
- ${t.length > 0 ? b`
2315
+ ${t.length > 0 ? p`
2352
2316
  <span class="qb-toolbar-section qb-field-projection" role="group" aria-label=${r.columns}>
2353
2317
  <span class="qb-toolbar-label">${r.columns}:</span>
2354
- ${t.map((n) => b`
2318
+ ${t.map((n) => p`
2355
2319
  <mp-checkbox
2356
2320
  class="qb-field-checkbox"
2357
2321
  value=${n.name}
@@ -2362,17 +2326,17 @@ class Ue extends L {
2362
2326
  >${n.label}</mp-checkbox>
2363
2327
  `)}
2364
2328
  </span>
2365
- ` : c}
2366
- ${t.length > 0 ? this._renderSortBy(t) : c}
2329
+ ` : m}
2330
+ ${t.length > 0 ? this._renderSortBy(t) : m}
2367
2331
  </div>
2368
2332
  `;
2369
2333
  }
2370
2334
  _renderSortBy(e) {
2371
2335
  const t = this._messages();
2372
- return b`
2336
+ return p`
2373
2337
  <span class="qb-toolbar-section qb-sort-by" role="group" aria-label=${t.sortBy}>
2374
2338
  <span class="qb-toolbar-label">${t.sortBy}:</span>
2375
- ${this.sortBy.map((r, n) => b`
2339
+ ${this.sortBy.map((r, n) => p`
2376
2340
  <span class="qb-sort-row">
2377
2341
  <mp-select
2378
2342
  class="qb-sort-field"
@@ -2382,8 +2346,8 @@ class Ue extends L {
2382
2346
  @change=${(i) => this._onSortFieldChange(n, i)}
2383
2347
  aria-label=${`Sort ${n + 1} field`}
2384
2348
  >
2385
- ${e.map((i) => b`<option value=${i.name}>${i.label}</option>`)}
2386
- ${e.some((i) => i.name === r.field) ? c : b`
2349
+ ${e.map((i) => p`<option value=${i.name}>${i.label}</option>`)}
2350
+ ${e.some((i) => i.name === r.field) ? m : p`
2387
2351
  <option value=${r.field}>(${r.field})</option>
2388
2352
  `}
2389
2353
  </mp-select>
@@ -2454,9 +2418,9 @@ class Ue extends L {
2454
2418
  }
2455
2419
  render() {
2456
2420
  if (this.depth > this.effectiveMaxDepth())
2457
- return b`<div class="qb-too-deep" role="alert">Tree too deep</div>`;
2421
+ return p`<div class="qb-too-deep" role="alert">Tree too deep</div>`;
2458
2422
  const e = this.query;
2459
- return e ? b`
2423
+ return e ? p`
2460
2424
  <div
2461
2425
  class="qb-root"
2462
2426
  data-qb-root=${this._qbRootId}
@@ -2472,20 +2436,20 @@ class Ue extends L {
2472
2436
  @qb-keyboard-move=${this._onKeyboardMove}
2473
2437
  >
2474
2438
  ${this._renderToolbar()}
2475
- ${this.showSavedQueries && this.depth === 0 ? this._renderSavedPicker(this._messages()) : c}
2476
- ${this.showPreview && this.depth === 0 ? b`<pre class="qb-preview">${this._renderPreview(e)}</pre>` : c}
2439
+ ${this.showSavedQueries && this.depth === 0 ? this._renderSavedPicker(this._messages()) : m}
2440
+ ${this.showPreview && this.depth === 0 ? p`<pre class="qb-preview">${this._renderPreview(e)}</pre>` : m}
2477
2441
  ${this.renderTreeRoot(e)}
2478
2442
  </div>
2479
- ` : c;
2443
+ ` : m;
2480
2444
  }
2481
2445
  _messages() {
2482
2446
  const e = this._messagesConsumer.value ?? {};
2483
2447
  return {
2484
- ...y,
2448
+ ...f,
2485
2449
  ...e,
2486
2450
  ...this.messages ?? {},
2487
2451
  operators: {
2488
- ...y.operators,
2452
+ ...f.operators,
2489
2453
  ...e.operators ?? {},
2490
2454
  ...this.messages?.operators ?? {}
2491
2455
  }
@@ -2497,7 +2461,7 @@ class Ue extends L {
2497
2461
  ...this._messagesConsumer.value ?? {},
2498
2462
  ...this.messages ?? {}
2499
2463
  };
2500
- return $e(e, this.schema, {
2464
+ return Ae(e, this.schema, {
2501
2465
  messages: t,
2502
2466
  rootEntity: this.rootEntity,
2503
2467
  maxDepth: this.effectiveMaxDepth()
@@ -2507,69 +2471,57 @@ class Ue extends L {
2507
2471
  }
2508
2472
  }
2509
2473
  renderTreeRoot(e) {
2510
- return e.kind === "group" ? b`<mp-query-group
2511
- .node=${e}
2512
- .schema=${this.schema}
2513
- .currentEntity=${this.rootEntity}
2514
- .depth=${this.depth}
2515
- .isRoot=${!0}
2516
- .qbRoot=${this._qbRootId}
2517
- .isDragging=${this._isDragging}
2518
- ></mp-query-group>` : b`<mp-query-group
2519
- .node=${{
2520
- kind: "group",
2521
- id: "synthetic-root",
2522
- logic: "and",
2523
- children: [e]
2524
- }}
2474
+ const t = e.kind === "group" ? e : { kind: "group", id: "synthetic-root", logic: "and", children: [e] };
2475
+ return p`<mp-query-group
2476
+ .node=${t}
2525
2477
  .schema=${this.schema}
2526
2478
  .currentEntity=${this.rootEntity}
2527
2479
  .depth=${this.depth}
2528
2480
  .isRoot=${!0}
2529
2481
  .qbRoot=${this._qbRootId}
2530
- .isDragging=${this._isDragging}
2482
+ .isDragging=${this._isDragging || this.dragActive}
2531
2483
  ></mp-query-group>`;
2532
2484
  }
2533
2485
  }
2534
- T("query-builder", Se);
2535
- typeof customElements < "u" && !customElements.get("mp-query-builder") && customElements.define("mp-query-builder", Ue);
2486
+ L("query-builder", Ne);
2487
+ typeof customElements < "u" && !customElements.get("mp-query-builder") && customElements.define("mp-query-builder", tt);
2536
2488
  export {
2537
- y as DEFAULT_MESSAGES,
2538
- W as DEFAULT_OPERATOR_CATALOG,
2539
- te as MaxDepthExceededError,
2540
- Ue as MpQueryBuilderElement,
2541
- Oe as MpQueryConditionElement,
2542
- He as MpQueryGroupElement,
2543
- Qe as MpQuerySubqueryElement,
2544
- H as addChild,
2545
- be as addEmptyConditionTo,
2546
- he as addEmptyGroupTo,
2547
- fe as addEmptySubqueryTo,
2548
- ve as changeConditionField,
2549
- qe as changeConditionOperator,
2489
+ f as DEFAULT_MESSAGES,
2490
+ J as DEFAULT_OPERATOR_CATALOG,
2491
+ ne as MaxDepthExceededError,
2492
+ tt as MpQueryBuilderElement,
2493
+ Ke as MpQueryConditionElement,
2494
+ Je as MpQueryGroupElement,
2495
+ We as MpQuerySubqueryElement,
2496
+ B as addChild,
2497
+ _e as addEmptyConditionTo,
2498
+ $e as addEmptyGroupTo,
2499
+ Ee as addEmptySubqueryTo,
2500
+ Ce as changeConditionField,
2501
+ Se as changeConditionOperator,
2550
2502
  G as cloneTree,
2551
- J as collectDescendantIds,
2552
- $ as defaultValueFor,
2553
- S as disabledContext,
2554
- O as editorRegistryContext,
2555
- me as emptyCondition,
2556
- Q as emptyGroup,
2557
- pe as emptySubquery,
2558
- E as findNodeById,
2559
- v as mapTree,
2560
- k as messagesContext,
2503
+ ee as collectDescendantIds,
2504
+ N as defaultValueFor,
2505
+ R as disabledContext,
2506
+ Q as editorRegistryContext,
2507
+ qe as emptyCondition,
2508
+ H as emptyGroup,
2509
+ we as emptySubquery,
2510
+ $ as findNodeById,
2511
+ S as mapTree,
2512
+ E as messagesContext,
2561
2513
  j as moveNode,
2562
2514
  C as newId,
2563
- w as operatorsForType,
2564
- Se as queryBuilderLightStyles,
2565
- Re as queryConditionLightStyles,
2566
- Ae as queryGroupLightStyles,
2567
- Le as querySubqueryLightStyles,
2568
- Z as removeNode,
2569
- $e as renderExpression,
2570
- ye as setGroupLogic,
2571
- ge as updateCondition,
2572
- We as validateOperatorOverrides,
2573
- h as valueShapeFor,
2574
- Je as visitTree
2515
+ k as operatorsForType,
2516
+ Ne as queryBuilderLightStyles,
2517
+ Fe as queryConditionLightStyles,
2518
+ Oe as queryGroupLightStyles,
2519
+ ze as querySubqueryLightStyles,
2520
+ te as removeNode,
2521
+ Ae as renderExpression,
2522
+ ke as setGroupLogic,
2523
+ xe as updateCondition,
2524
+ lt as validateOperatorOverrides,
2525
+ q as valueShapeFor,
2526
+ ut as visitTree
2575
2527
  };