@nivaro/react 0.3.13 → 0.3.15

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 (48) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2393 -2318
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,25 +1,26 @@
1
1
  import { jsx as t, jsxs as p, Fragment as E } from "react/jsx-runtime";
2
- import { useQuery as Q, useQueryClient as Ae } from "@tanstack/react-query";
3
- import { useState as q, useEffect as ee, useRef as te, useMemo as Pe, useCallback as Fe } from "react";
4
- import { createPortal as Be } from "react-dom";
5
- import { useNivaroClient as D, useDrilldown as ke, useOverlayState as Ee, DrilldownContext as Le, useItemNavigation as Ie } from "../context.js";
6
- import { get as we, post as U } from "../lib/commands.js";
7
- import { explicitAllUrlParams as Qe, initialFilterSelection as De, filterSelectionToSearch as ze } from "../lib/query-filter-seed.js";
8
- import { uniqueByValue as Ke } from "../lib/unique-options.js";
9
- import { userErrorMessage as Ne } from "../lib/safe-error.js";
10
- import { resolveSheetDef as Ve } from "../lib/sheet-def.js";
11
- import { useMyScopes as Ge, matchScopeDimension as ge, effectiveScopeSeedIds as Ue, translateScopeValues as He } from "../lib/use-my-scopes.js";
12
- import { titleCase as L, formatRelative as Ye, formatNumber as Je } from "../lib/utils.js";
13
- import { CacheStamp as Xe } from "./CacheStamp.js";
14
- import { RelationCombobox as Ze } from "./item-edit/RelationCombobox.js";
15
- import { MatrixEditor as re } from "./MatrixEditor.js";
16
- import { QueryStatStrip as et } from "./QueryStatStrip.js";
17
- import { QueryTable as tt } from "./QueryTable.js";
18
- import { RecordDrilldownSheet as rt } from "./RecordDrilldownSheet.js";
19
- import { RecordGridEditor as ye } from "./RecordGridEditor.js";
20
- import { SheetHeaderBody as at } from "./SheetHeaderBody.js";
21
- const X = 76;
22
- function H() {
2
+ import { useQuery as Q, useQueryClient as ze } from "@tanstack/react-query";
3
+ import { useState as q, useEffect as H, useRef as D, useMemo as Ne, useCallback as Ke } from "react";
4
+ import { createPortal as Je } from "react-dom";
5
+ import { useNivaroClient as z, useDrilldown as qe, useOverlayState as Ve, DrilldownContext as Ge, useItemNavigation as Ue } from "../context.js";
6
+ import { useDebounced as He } from "../hooks/useDebounced.js";
7
+ import { get as je, post as Y } from "../lib/commands.js";
8
+ import { explicitAllUrlParams as Ye, initialFilterSelection as Xe, filterSelectionToSearch as Ze } from "../lib/query-filter-seed.js";
9
+ import { userErrorMessage as Re } from "../lib/safe-error.js";
10
+ import { resolveSheetDef as et } from "../lib/sheet-def.js";
11
+ import { uniqueByValue as tt } from "../lib/unique-options.js";
12
+ import { useMyScopes as rt, matchScopeDimension as Se, effectiveScopeSeedIds as nt, translateScopeValues as at } from "../lib/use-my-scopes.js";
13
+ import { titleCase as L, formatRelative as lt, formatNumber as st } from "../lib/utils.js";
14
+ import { CacheStamp as it } from "./CacheStamp.js";
15
+ import { RelationCombobox as ot } from "./item-edit/RelationCombobox.js";
16
+ import { MatrixEditor as se } from "./MatrixEditor.js";
17
+ import { QueryStatStrip as dt } from "./QueryStatStrip.js";
18
+ import { QueryTable as ct } from "./QueryTable.js";
19
+ import { RecordDrilldownSheet as ut } from "./RecordDrilldownSheet.js";
20
+ import { RecordGridEditor as $e } from "./RecordGridEditor.js";
21
+ import { SheetHeaderBody as mt } from "./SheetHeaderBody.js";
22
+ const ae = 76;
23
+ function X() {
23
24
  return /* @__PURE__ */ t("div", { className: "space-y-1.5 p-3", children: [1, 2, 3].map((e) => /* @__PURE__ */ t(
24
25
  "div",
25
26
  {
@@ -28,155 +29,155 @@ function H() {
28
29
  e
29
30
  )) });
30
31
  }
31
- function Y({ error: e }) {
32
- const r = Ne(e, "Failed to load widget data");
32
+ function Z({ error: e }) {
33
+ const r = Re(e, "Failed to load widget data");
33
34
  return /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center p-3 text-[12px] text-amber-600 dark:text-amber-500", children: r });
34
35
  }
35
- function lt(e) {
36
+ function pt(e) {
36
37
  if (e == null) return "—";
37
38
  if (typeof e == "boolean") return e ? "true" : "false";
38
39
  const r = String(e);
39
40
  return r.length > 80 ? `${r.slice(0, 80)}…` : r;
40
41
  }
41
- function Z(e, r) {
42
- const a = [], n = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
43
- return e.split(n).forEach((i, m) => {
44
- const s = `${r}-${m}`;
45
- if (i)
46
- if (i.startsWith("**") && i.endsWith("**"))
47
- a.push(/* @__PURE__ */ t("strong", { children: i.slice(2, -2) }, s));
48
- else if (i.startsWith("*") && i.endsWith("*") && i.length > 2)
49
- a.push(/* @__PURE__ */ t("em", { children: i.slice(1, -1) }, s));
50
- else if (i.startsWith("`") && i.endsWith("`"))
51
- a.push(
42
+ function le(e, r) {
43
+ const n = [], l = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
44
+ return e.split(l).forEach((o, m) => {
45
+ const d = `${r}-${m}`;
46
+ if (o)
47
+ if (o.startsWith("**") && o.endsWith("**"))
48
+ n.push(/* @__PURE__ */ t("strong", { children: o.slice(2, -2) }, d));
49
+ else if (o.startsWith("*") && o.endsWith("*") && o.length > 2)
50
+ n.push(/* @__PURE__ */ t("em", { children: o.slice(1, -1) }, d));
51
+ else if (o.startsWith("`") && o.endsWith("`"))
52
+ n.push(
52
53
  /* @__PURE__ */ t(
53
54
  "code",
54
55
  {
55
56
  className: "rounded bg-slate-100 px-1 py-0.5 font-mono text-[0.9em] dark:bg-muted",
56
- children: i.slice(1, -1)
57
+ children: o.slice(1, -1)
57
58
  },
58
- s
59
+ d
59
60
  )
60
61
  );
61
62
  else {
62
- const l = i.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
63
- l && (/^https?:\/\//i.test(l[2]) || l[2].startsWith("/")) ? a.push(
64
- /* @__PURE__ */ t("a", { href: l[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: l[1] }, s)
65
- ) : a.push(i);
63
+ const a = o.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
64
+ a && (/^https?:\/\//i.test(a[2]) || a[2].startsWith("/")) ? n.push(
65
+ /* @__PURE__ */ t("a", { href: a[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: a[1] }, d)
66
+ ) : n.push(o);
66
67
  }
67
- }), a;
68
+ }), n;
68
69
  }
69
- function nt({ content: e }) {
70
+ function ht({ content: e }) {
70
71
  const r = [];
71
- let a = [], n = [], i = !1;
72
- const m = (l) => {
73
- a.length && (r.push(
74
- /* @__PURE__ */ t("p", { className: "leading-relaxed", children: Z(a.join(" "), l) }, l)
75
- ), a = []);
76
- }, s = (l) => {
77
- if (!n.length) return;
78
- const o = n.map((u, x) => /* @__PURE__ */ t("li", { children: Z(u, `${l}-${x}`) }, `${l}-${x}`));
72
+ let n = [], l = [], o = !1;
73
+ const m = (a) => {
74
+ n.length && (r.push(
75
+ /* @__PURE__ */ t("p", { className: "leading-relaxed", children: le(n.join(" "), a) }, a)
76
+ ), n = []);
77
+ }, d = (a) => {
78
+ if (!l.length) return;
79
+ const c = l.map((u, f) => /* @__PURE__ */ t("li", { children: le(u, `${a}-${f}`) }, `${a}-${f}`));
79
80
  r.push(
80
- i ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: o }, l) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: o }, l)
81
- ), n = [];
81
+ o ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: c }, a) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: c }, a)
82
+ ), l = [];
82
83
  };
83
84
  return e.split(`
84
- `).forEach((l, o) => {
85
- const u = `md-${o}`, x = l.match(/^(#{1,3})\s+(.*)$/), b = l.match(/^[-*]\s+(.*)$/), N = l.match(/^\d+\.\s+(.*)$/);
86
- if (x) {
87
- s(`${u}-fl`), m(`${u}-fp`);
88
- const S = x[1].length, W = S === 1 ? "text-[17px] font-semibold" : S === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
85
+ `).forEach((a, c) => {
86
+ const u = `md-${c}`, f = a.match(/^(#{1,3})\s+(.*)$/), S = a.match(/^[-*]\s+(.*)$/), $ = a.match(/^\d+\.\s+(.*)$/);
87
+ if (f) {
88
+ d(`${u}-fl`), m(`${u}-fp`);
89
+ const w = f[1].length, R = w === 1 ? "text-[17px] font-semibold" : w === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
89
90
  r.push(
90
- /* @__PURE__ */ t("div", { className: `${W} text-slate-900 dark:text-slate-100`, children: Z(x[2], `${u}-h`) }, u)
91
+ /* @__PURE__ */ t("div", { className: `${R} text-slate-900 dark:text-slate-100`, children: le(f[2], `${u}-h`) }, u)
91
92
  );
92
- } else if (b || N) {
93
+ } else if (S || $) {
93
94
  m(`${u}-fp`);
94
- const S = !!N;
95
- n.length && i !== S && s(`${u}-fl`), i = S, n.push((b == null ? void 0 : b[1]) ?? (N == null ? void 0 : N[1]));
96
- } else l.trim() === "" ? (s(`${u}-fl`), m(`${u}-fp`)) : (s(`${u}-fl`), a.push(l.trim()));
97
- }), s("md-end-l"), m("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
95
+ const w = !!$;
96
+ l.length && o !== w && d(`${u}-fl`), o = w, l.push((S == null ? void 0 : S[1]) ?? ($ == null ? void 0 : $[1]));
97
+ } else a.trim() === "" ? (d(`${u}-fl`), m(`${u}-fp`)) : (d(`${u}-fl`), n.push(a.trim()));
98
+ }), d("md-end-l"), m("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
98
99
  }
99
- function ae(e, r, a) {
100
- const n = D();
100
+ function ie(e, r, n) {
101
+ const l = z();
101
102
  return Q({
102
103
  queryKey: ["page-renderer-widget-data", e, r.id],
103
- queryFn: () => n.request(U(`/pages/${e}/widget-data`, { widget_id: r.id })).then((i) => i.data),
104
- enabled: a,
104
+ queryFn: () => l.request(Y(`/pages/${e}/widget-data`, { widget_id: r.id })).then((o) => o.data),
105
+ enabled: n,
105
106
  retry: !1,
106
107
  staleTime: 3e4
107
108
  });
108
109
  }
109
- function st({ slug: e, widget: r }) {
110
+ function xt({ slug: e, widget: r }) {
110
111
  var u;
111
- const a = r.config ?? {}, { data: n, isLoading: i, error: m } = ae(e, r, !!a.collection), s = Ie();
112
- if (!a.collection)
112
+ const n = r.config ?? {}, { data: l, isLoading: o, error: m } = ie(e, r, !!n.collection), d = Ue();
113
+ if (!n.collection)
113
114
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
114
- if (i) return /* @__PURE__ */ t(H, {});
115
- if (m) return /* @__PURE__ */ t(Y, { error: m });
116
- const l = (n == null ? void 0 : n.rows) ?? [];
117
- if (!l.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
118
- const o = (u = a.columns) != null && u.length ? a.columns : Object.keys(l[0]).filter((x) => {
119
- const b = l[0][x];
120
- return b === null || ["string", "number", "boolean"].includes(typeof b);
115
+ if (o) return /* @__PURE__ */ t(X, {});
116
+ if (m) return /* @__PURE__ */ t(Z, { error: m });
117
+ const a = (l == null ? void 0 : l.rows) ?? [];
118
+ if (!a.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
119
+ const c = (u = n.columns) != null && u.length ? n.columns : Object.keys(a[0]).filter((f) => {
120
+ const S = a[0][f];
121
+ return S === null || ["string", "number", "boolean"].includes(typeof S);
121
122
  }).slice(0, 5);
122
123
  return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ p("table", { className: "w-full text-[12px]", children: [
123
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: o.map((x) => /* @__PURE__ */ t(
124
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: c.map((f) => /* @__PURE__ */ t(
124
125
  "th",
125
126
  {
126
127
  className: "whitespace-nowrap px-3 py-1.5 text-left font-medium text-slate-400",
127
- children: L(x)
128
+ children: L(f)
128
129
  },
129
- x
130
+ f
130
131
  )) }) }),
131
- /* @__PURE__ */ t("tbody", { children: l.map((x, b) => /* @__PURE__ */ t(
132
+ /* @__PURE__ */ t("tbody", { children: a.map((f, S) => /* @__PURE__ */ t(
132
133
  "tr",
133
134
  {
134
- onClick: x.id != null ? () => s.open({ collection: a.collection, itemId: String(x.id) }) : void 0,
135
- className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${x.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
136
- children: o.map((N) => /* @__PURE__ */ t(
135
+ onClick: f.id != null ? () => d.open({ collection: n.collection, itemId: String(f.id) }) : void 0,
136
+ className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${f.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
137
+ children: c.map(($) => /* @__PURE__ */ t(
137
138
  "td",
138
139
  {
139
140
  className: "whitespace-nowrap px-3 py-1.5 text-slate-700 dark:text-slate-300",
140
- children: lt(x[N])
141
+ children: pt(f[$])
141
142
  },
142
- N
143
+ $
143
144
  ))
144
145
  },
145
- x.id != null ? `${x.id}-${b}` : b
146
+ f.id != null ? `${f.id}-${S}` : S
146
147
  )) })
147
148
  ] }) });
148
149
  }
149
- function it({ slug: e, widget: r }) {
150
- const a = r.config ?? {}, { data: n, isLoading: i, error: m } = ae(e, r, !!a.collection);
151
- return a.collection ? m ? /* @__PURE__ */ t(Y, { error: m }) : /* @__PURE__ */ p("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
152
- i ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (n == null ? void 0 : n.value) != null ? Je(Number(n.value)) : "—" }),
153
- /* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: a.label || `${a.aggregate ?? "count"} of ${a.collection}` })
150
+ function ft({ slug: e, widget: r }) {
151
+ const n = r.config ?? {}, { data: l, isLoading: o, error: m } = ie(e, r, !!n.collection);
152
+ return n.collection ? m ? /* @__PURE__ */ t(Z, { error: m }) : /* @__PURE__ */ p("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
153
+ o ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (l == null ? void 0 : l.value) != null ? st(Number(l.value)) : "—" }),
154
+ /* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: n.label || `${n.aggregate ?? "count"} of ${n.collection}` })
154
155
  ] }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
155
156
  }
156
- function ot({ slug: e, widget: r }) {
157
- const { data: a, isLoading: n, error: i } = ae(e, r, !0);
158
- if (n) return /* @__PURE__ */ t(H, {});
159
- if (i) return /* @__PURE__ */ t(Y, { error: i });
160
- const m = (a == null ? void 0 : a.rows) ?? [];
161
- return m.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: m.map((s) => /* @__PURE__ */ p(
157
+ function bt({ slug: e, widget: r }) {
158
+ const { data: n, isLoading: l, error: o } = ie(e, r, !0);
159
+ if (l) return /* @__PURE__ */ t(X, {});
160
+ if (o) return /* @__PURE__ */ t(Z, { error: o });
161
+ const m = (n == null ? void 0 : n.rows) ?? [];
162
+ return m.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: m.map((d) => /* @__PURE__ */ p(
162
163
  "div",
163
164
  {
164
165
  className: "flex items-center gap-2 border-b border-slate-50 py-1.5 text-[12px] last:border-0 dark:border-border/50",
165
166
  children: [
166
- /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: s.action }),
167
- s.collection && /* @__PURE__ */ p("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
168
- s.collection,
169
- s.item ? ` · ${s.item}` : ""
167
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: d.action }),
168
+ d.collection && /* @__PURE__ */ p("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
169
+ d.collection,
170
+ d.item ? ` · ${d.item}` : ""
170
171
  ] }),
171
- /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: Ye(s.timestamp) })
172
+ /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: lt(d.timestamp) })
172
173
  ]
173
174
  },
174
- s.id
175
+ d.id
175
176
  )) }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No activity" });
176
177
  }
177
- function dt({ widget: e }) {
178
- var a;
179
- const r = String(((a = e.config) == null ? void 0 : a.url) ?? "");
178
+ function gt({ widget: e }) {
179
+ var n;
180
+ const r = String(((n = e.config) == null ? void 0 : n.url) ?? "");
180
181
  return r ? /^https?:\/\//i.test(r) ? /* @__PURE__ */ t(
181
182
  "iframe",
182
183
  {
@@ -187,98 +188,98 @@ function dt({ widget: e }) {
187
188
  }
188
189
  ) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-amber-600", children: "URL must start with http(s)://" }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set an iframe URL" });
189
190
  }
190
- function $e({
191
+ function Te({
191
192
  config: e,
192
193
  initialScope: r,
193
- width: a,
194
- title: n,
195
- onClose: i
194
+ width: n,
195
+ title: l,
196
+ onClose: o
196
197
  }) {
197
- const m = typeof a == "number" ? `${a}px` : a ?? "85%";
198
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: i, children: /* @__PURE__ */ p(
198
+ const m = typeof n == "number" ? `${n}px` : n ?? "85%";
199
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: o, children: /* @__PURE__ */ p(
199
200
  "div",
200
201
  {
201
202
  className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
202
203
  style: { width: m, maxWidth: "96%" },
203
- onClick: (s) => s.stopPropagation(),
204
+ onClick: (d) => d.stopPropagation(),
204
205
  children: [
205
206
  /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
206
- /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: n ?? e.title ?? "Manage" }),
207
+ /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: l ?? e.title ?? "Manage" }),
207
208
  /* @__PURE__ */ t(
208
209
  "button",
209
210
  {
210
211
  type: "button",
211
- onClick: i,
212
+ onClick: o,
212
213
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
213
214
  children: "Close"
214
215
  }
215
216
  )
216
217
  ] }),
217
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(re, { config: e, initialScope: r }) })
218
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(se, { config: e, initialScope: r }) })
218
219
  ]
219
220
  }
220
221
  ) });
221
222
  }
222
- function ct({ widget: e }) {
223
- const r = e.config ?? {}, [a, n] = q(!1);
223
+ function yt({ widget: e }) {
224
+ const r = e.config ?? {}, [n, l] = q(!1);
224
225
  return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
225
226
  /* @__PURE__ */ t(
226
227
  "button",
227
228
  {
228
229
  type: "button",
229
- onClick: () => n(!0),
230
+ onClick: () => l(!0),
230
231
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-3 text-[12.5px] font-medium text-slate-700 shadow-sm transition-colors hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
231
232
  children: r.button_label ?? r.title ?? "Manage"
232
233
  }
233
234
  ),
234
- a && /* @__PURE__ */ t(
235
- $e,
235
+ n && /* @__PURE__ */ t(
236
+ Te,
236
237
  {
237
238
  config: r,
238
239
  width: r.sheet_width,
239
- onClose: () => n(!1)
240
+ onClose: () => l(!1)
240
241
  }
241
242
  )
242
- ] }) : /* @__PURE__ */ t(re, { config: r });
243
+ ] }) : /* @__PURE__ */ t(se, { config: r });
243
244
  }
244
- function mt(e) {
245
- return De(
245
+ function vt(e) {
246
+ return Xe(
246
247
  e,
247
248
  typeof window > "u" ? "" : window.location.search
248
249
  );
249
250
  }
250
- function Se(e, r, a, n, i, m) {
251
+ function We(e, r, n, l, o, m) {
251
252
  if (typeof e != "string") return e;
252
253
  if (e.startsWith("$row.")) return r == null ? void 0 : r[e.slice(5)];
253
254
  if (e.startsWith("$rows.")) {
254
- const s = e.slice(6), l = [...new Set(a.map((o) => o[s]).filter((o) => o != null && o !== ""))];
255
- return l.length ? l.join(",") : void 0;
255
+ const d = e.slice(6), a = [...new Set(n.map((c) => c[d]).filter((c) => c != null && c !== ""))];
256
+ return a.length ? a.join(",") : void 0;
256
257
  }
257
- if (e.startsWith("$param.")) return n[e.slice(7)];
258
+ if (e.startsWith("$param.")) return l[e.slice(7)];
258
259
  if (e.startsWith("$filters.")) {
259
- const s = e.slice(9), l = m == null ? void 0 : m.find((u) => u.param === s), o = i[s] ?? [];
260
- return o.length ? o.map((u) => String(u[(l == null ? void 0 : l.value_field) ?? "id"] ?? "")).join(",") : void 0;
260
+ const d = e.slice(9), a = m == null ? void 0 : m.find((u) => u.param === d), c = o[d] ?? [];
261
+ return c.length ? c.map((u) => String(u[(a == null ? void 0 : a.value_field) ?? "id"] ?? "")).join(",") : void 0;
261
262
  }
262
263
  return e;
263
264
  }
264
- function ut(e, r, a, n, i, m) {
265
- const s = {};
266
- for (const [l, o] of Object.entries(e.params ?? {})) {
267
- const u = Se(o, r, a, n, i, m);
268
- u !== void 0 && (s[l] = u);
265
+ function kt(e, r, n, l, o, m) {
266
+ const d = {};
267
+ for (const [a, c] of Object.entries(e.params ?? {})) {
268
+ const u = We(c, r, n, l, o, m);
269
+ u !== void 0 && (d[a] = u);
269
270
  }
270
- return { ...e, params: s };
271
+ return { ...e, params: d };
271
272
  }
272
- function pt({
273
+ function wt({
273
274
  config: e,
274
275
  stats: r,
275
- asOf: a,
276
- note: n
276
+ asOf: n,
277
+ note: l
277
278
  }) {
278
- const i = D(), m = e.params ?? {}, { data: s, isPending: l, isError: o } = Q({
279
+ const o = z(), m = e.params ?? {}, { data: d, isPending: a, isError: c } = Q({
279
280
  queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(m)],
280
- queryFn: () => i.request(
281
- U(`/custom-queries/${e.query_slug}/execute`, { params: m })
281
+ queryFn: () => o.request(
282
+ Y(`/custom-queries/${e.query_slug}/execute`, { params: m })
282
283
  ),
283
284
  enabled: !!e.query_slug,
284
285
  staleTime: 6e4
@@ -289,62 +290,62 @@ function pt({
289
290
  className: "shrink-0 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card",
290
291
  "data-sheet-header": !0,
291
292
  children: /* @__PURE__ */ t(
292
- at,
293
+ mt,
293
294
  {
294
295
  stats: r,
295
- rows: (s == null ? void 0 : s.data) ?? [],
296
+ rows: (d == null ? void 0 : d.data) ?? [],
296
297
  params: m,
297
- loading: l && !o,
298
- error: o,
299
- asOf: a,
300
- note: n
298
+ loading: a && !c,
299
+ error: c,
300
+ asOf: n,
301
+ note: l
301
302
  }
302
303
  )
303
304
  }
304
305
  );
305
306
  }
306
- function ht({
307
+ function Nt({
307
308
  def: e,
308
309
  row: r,
309
- onClose: a
310
+ onClose: n
310
311
  }) {
311
- const [n, i] = q(e.initialTab ?? 0), m = e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (o, u) => {
312
- const x = r == null ? void 0 : r[u];
313
- return x == null ? "" : String(x);
314
- }) : "Details", s = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", l = e.resolvedTabs[n];
315
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: a, children: /* @__PURE__ */ p(
312
+ const [l, o] = q(e.initialTab ?? 0), m = e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (c, u) => {
313
+ const f = r == null ? void 0 : r[u];
314
+ return f == null ? "" : String(f);
315
+ }) : "Details", d = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", a = e.resolvedTabs[l];
316
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: n, children: /* @__PURE__ */ p(
316
317
  "div",
317
318
  {
318
319
  className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
319
- style: { width: s, maxWidth: "96%" },
320
- onClick: (o) => o.stopPropagation(),
320
+ style: { width: d, maxWidth: "96%" },
321
+ onClick: (c) => c.stopPropagation(),
321
322
  children: [
322
323
  /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
323
324
  /* @__PURE__ */ p("div", { className: "flex items-center gap-3", children: [
324
325
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: m }),
325
- e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((o, u) => /* @__PURE__ */ t(
326
+ e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((c, u) => /* @__PURE__ */ t(
326
327
  "button",
327
328
  {
328
329
  type: "button",
329
- onClick: () => i(u),
330
- className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${u === n ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
331
- children: o.label
330
+ onClick: () => o(u),
331
+ className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${u === l ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
332
+ children: c.label
332
333
  },
333
- o.label
334
+ c.label
334
335
  )) })
335
336
  ] }),
336
337
  /* @__PURE__ */ t(
337
338
  "button",
338
339
  {
339
340
  type: "button",
340
- onClick: a,
341
+ onClick: n,
341
342
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
342
343
  children: "Close"
343
344
  }
344
345
  )
345
346
  ] }),
346
347
  e.header && /* @__PURE__ */ t(
347
- pt,
348
+ wt,
348
349
  {
349
350
  config: e.header.config,
350
351
  stats: e.header.stats,
@@ -352,110 +353,120 @@ function ht({
352
353
  note: e.header.note
353
354
  }
354
355
  ),
355
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: l != null && l.matrix ? /* @__PURE__ */ t(
356
- re,
356
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: a != null && a.matrix ? /* @__PURE__ */ t(
357
+ se,
357
358
  {
358
- config: l.matrix.config,
359
- initialScope: l.matrix.initialScope,
359
+ config: a.matrix.config,
360
+ initialScope: a.matrix.initialScope,
360
361
  lockScope: !0
361
362
  },
362
- n
363
- ) : l != null && l.config ? /* @__PURE__ */ p(E, { children: [
364
- l.note && /* @__PURE__ */ t(
363
+ l
364
+ ) : a != null && a.config ? /* @__PURE__ */ p(E, { children: [
365
+ a.note && /* @__PURE__ */ t(
365
366
  "p",
366
367
  {
367
368
  className: "border-b border-slate-200 bg-white px-4 py-1.5 text-[11.5px] text-slate-500 dark:border-border dark:bg-card dark:text-slate-400",
368
369
  "data-sheet-tab-note": !0,
369
- children: l.note
370
+ children: a.note
370
371
  }
371
372
  ),
372
- /* @__PURE__ */ t(_e, { config: l.config }, n)
373
+ /* @__PURE__ */ t(Me, { config: a.config }, l)
373
374
  ] }) : /* @__PURE__ */ t("p", { className: "p-4 text-[12px] text-slate-400", children: "Sheet not configured" }) })
374
375
  ]
375
376
  }
376
377
  ) });
377
378
  }
378
- function xt(e, r, a, n) {
379
+ function St(e, r, n, l) {
379
380
  if (!e) return;
380
- const i = (o) => {
381
- const u = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(o);
381
+ const o = (c) => {
382
+ const u = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(c);
382
383
  if (!u) return;
383
- const x = n == null ? void 0 : n.find((S) => S.param === u[1]), b = (a == null ? void 0 : a[u[1]]) ?? [];
384
- if (b.length === 0) return;
385
- const N = u[2] ?? (x == null ? void 0 : x.value_field) ?? "id";
386
- return b.map((S) => S[N]);
387
- }, m = (o) => typeof o == "string" && o.startsWith("$row.") ? r[o.slice(5)] : typeof o == "string" && o.startsWith("$filters.") ? i(o) : Array.isArray(o) ? o.map(m) : o && typeof o == "object" ? Object.fromEntries(
388
- Object.entries(o).map(([u, x]) => [u, m(x)])
389
- ) : o, s = (o) => o === void 0 ? !0 : Array.isArray(o) ? o.some(s) : o && typeof o == "object" ? Object.values(o).some(s) : !1, l = m(e);
390
- return Array.isArray(l._and) && (l._and = l._and.filter((o) => !s(o))), s(l) ? void 0 : l;
384
+ const f = l == null ? void 0 : l.find((w) => w.param === u[1]), S = (n == null ? void 0 : n[u[1]]) ?? [];
385
+ if (S.length === 0) return;
386
+ const $ = u[2] ?? (f == null ? void 0 : f.value_field) ?? "id";
387
+ return S.map((w) => w[$]);
388
+ }, m = (c) => typeof c == "string" && c.startsWith("$row.") ? r[c.slice(5)] : typeof c == "string" && c.startsWith("$filters.") ? o(c) : Array.isArray(c) ? c.map(m) : c && typeof c == "object" ? Object.fromEntries(
389
+ Object.entries(c).map(([u, f]) => [u, m(f)])
390
+ ) : c, d = (c) => c === void 0 ? !0 : Array.isArray(c) ? c.some(d) : c && typeof c == "object" ? Object.values(c).some(d) : !1, a = m(e);
391
+ return Array.isArray(a._and) && (a._and = a._and.filter((c) => !d(c))), d(a) ? void 0 : a;
391
392
  }
392
- function ft({
393
+ const $t = 400, _t = 2500;
394
+ function _e(e, r) {
395
+ return e.map((n) => String(n[r] ?? "")).sort().join("\0");
396
+ }
397
+ function Ct({
393
398
  filter: e,
394
399
  selected: r,
395
- onChange: a,
396
- allowedIds: n,
397
- scopeDefault: i
400
+ onChange: n,
401
+ allowedIds: l,
402
+ scopeDefault: o,
403
+ onOpenChange: m
398
404
  }) {
399
- const m = D(), [s, l] = q(!1), [o, u] = q(""), x = te(null), b = e.value_field ?? "id", N = e.label_field ?? b, { data: S = [] } = Q({
400
- queryKey: ["page-renderer-filter", e.collection, b, N, e.sort],
401
- queryFn: () => m.request(
402
- we(`/items/${e.collection}`, {
403
- fields: [.../* @__PURE__ */ new Set(["id", b, N])].join(","),
405
+ const d = z(), [a, c] = q(!1), u = D(m);
406
+ u.current = m, H(() => {
407
+ var v;
408
+ (v = u.current) == null || v.call(u, a);
409
+ }, [a]);
410
+ const [f, S] = q(""), $ = D(null), w = e.value_field ?? "id", R = e.label_field ?? w, { data: _ = [] } = Q({
411
+ queryKey: ["page-renderer-filter", e.collection, w, R, e.sort],
412
+ queryFn: () => d.request(
413
+ je(`/items/${e.collection}`, {
414
+ fields: [.../* @__PURE__ */ new Set(["id", w, R])].join(","),
404
415
  limit: e.limit ?? 500,
405
416
  ...e.sort ? { sort: e.sort } : {}
406
417
  })
407
- ).then((w) => w.data ?? []),
418
+ ).then((v) => v.data ?? []),
408
419
  staleTime: 6e4
409
420
  });
410
- ee(() => {
411
- if (!s) return;
412
- const w = ($) => {
413
- x.current && !x.current.contains($.target) && l(!1);
421
+ H(() => {
422
+ if (!a) return;
423
+ const v = (s) => {
424
+ $.current && !$.current.contains(s.target) && c(!1);
414
425
  };
415
- return window.addEventListener("mousedown", w), () => window.removeEventListener("mousedown", w);
416
- }, [s]);
417
- const W = e.label ?? L(e.param), j = Ke(
418
- n != null && n.length ? S.filter((w) => n.some(($) => String($) === String(w.id))) : S,
419
- (w) => String(w[b] ?? "")
426
+ return window.addEventListener("mousedown", v), () => window.removeEventListener("mousedown", v);
427
+ }, [a]);
428
+ const j = e.label ?? L(e.param), O = tt(
429
+ l != null && l.length ? _.filter((v) => l.some((s) => String(s) === String(v.id))) : _,
430
+ (v) => String(v[w] ?? "")
420
431
  ).filter(
421
- (w) => o ? String(w[N] ?? "").toLowerCase().includes(o.toLowerCase()) : !0
422
- ), R = n != null && n.length ? {
432
+ (v) => f ? String(v[R] ?? "").toLowerCase().includes(f.toLowerCase()) : !0
433
+ ), C = l != null && l.length ? {
423
434
  label: "restricted",
424
435
  cls: "bg-amber-500/15 text-amber-700 dark:text-amber-300",
425
- title: `Options limited to your restricted ${W} scope${i ? "; selection seeded from your defaults" : ""}`
426
- } : i && r.length > 0 ? {
436
+ title: `Options limited to your restricted ${j} scope${o ? "; selection seeded from your defaults" : ""}`
437
+ } : o && r.length > 0 ? {
427
438
  label: "your default",
428
439
  cls: "bg-nvr-cyan/[0.12] text-[#0284a8] dark:text-nvr-cyan",
429
- title: `Pre-selected from your default ${W} scope — adjust freely`
440
+ title: `Pre-selected from your default ${j} scope — adjust freely`
430
441
  } : null;
431
- return /* @__PURE__ */ p("div", { ref: x, className: "relative", children: [
442
+ return /* @__PURE__ */ p("div", { ref: $, className: "relative", children: [
432
443
  /* @__PURE__ */ p(
433
444
  "button",
434
445
  {
435
446
  type: "button",
436
- onClick: () => l((w) => !w),
447
+ onClick: () => c((v) => !v),
437
448
  className: `inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[12px] transition-colors ${r.length > 0 ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-700 dark:text-slate-200" : "border-slate-200 bg-white text-slate-600 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-300"}`,
438
449
  children: [
439
- /* @__PURE__ */ t("span", { className: "font-medium", children: W }),
440
- R && /* @__PURE__ */ t(
450
+ /* @__PURE__ */ t("span", { className: "font-medium", children: j }),
451
+ C && /* @__PURE__ */ t(
441
452
  "span",
442
453
  {
443
- title: R.title,
444
- className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${R.cls}`,
445
- children: R.label
454
+ title: C.title,
455
+ className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${C.cls}`,
456
+ children: C.label
446
457
  }
447
458
  ),
448
- /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][N] ?? r[0][b] ?? "") : `${r.length} selected` }),
459
+ /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][R] ?? r[0][w] ?? "") : `${r.length} selected` }),
449
460
  /* @__PURE__ */ t("span", { className: "text-slate-400", children: "⌃" })
450
461
  ]
451
462
  }
452
463
  ),
453
- s && /* @__PURE__ */ p("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
464
+ a && /* @__PURE__ */ p("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
454
465
  /* @__PURE__ */ t(
455
466
  "input",
456
467
  {
457
- value: o,
458
- onChange: (w) => u(w.target.value),
468
+ value: f,
469
+ onChange: (v) => S(v.target.value),
459
470
  placeholder: "Search…",
460
471
  className: "mb-1 h-7 w-full rounded border border-slate-200 bg-white px-2 text-[12px] outline-none dark:border-border dark:bg-background"
461
472
  }
@@ -465,60 +476,60 @@ function ft({
465
476
  "button",
466
477
  {
467
478
  type: "button",
468
- onClick: () => a([]),
479
+ onClick: () => n([]),
469
480
  className: "flex w-full items-center rounded px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-slate-100 dark:hover:bg-muted",
470
481
  children: "Clear selection"
471
482
  }
472
483
  ),
473
- j.map((w) => {
474
- const $ = String(w[b] ?? ""), O = r.some((d) => String(d[b] ?? "") === $);
484
+ O.map((v) => {
485
+ const s = String(v[w] ?? ""), y = r.some((M) => String(M[w] ?? "") === s);
475
486
  return /* @__PURE__ */ p(
476
487
  "button",
477
488
  {
478
489
  type: "button",
479
490
  onClick: () => {
480
491
  if (e.single) {
481
- a(O ? [] : [w]), l(!1);
492
+ n(y ? [] : [v]), c(!1);
482
493
  return;
483
494
  }
484
- a(
485
- O ? r.filter((d) => String(d[b] ?? "") !== $) : [...r, w]
495
+ n(
496
+ y ? r.filter((M) => String(M[w] ?? "") !== s) : [...r, v]
486
497
  );
487
498
  },
488
499
  className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-muted",
489
500
  children: [
490
- /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${O ? "" : "invisible"}`, children: "✓" }),
491
- /* @__PURE__ */ t("span", { className: "truncate", children: String(w[N] ?? $) })
501
+ /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${y ? "" : "invisible"}`, children: "✓" }),
502
+ /* @__PURE__ */ t("span", { className: "truncate", children: String(v[R] ?? s) })
492
503
  ]
493
504
  },
494
- $
505
+ s
495
506
  );
496
507
  }),
497
- j.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No options" })
508
+ O.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No options" })
498
509
  ] })
499
510
  ] })
500
511
  ] });
501
512
  }
502
- function bt({ widget: e }) {
503
- return /* @__PURE__ */ t(_e, { config: e.config ?? {} });
513
+ function qt({ widget: e }) {
514
+ return /* @__PURE__ */ t(Me, { config: e.config ?? {} });
504
515
  }
505
- function gt({ widget: e }) {
506
- const r = e.config ?? {}, [a, n] = q(!1);
516
+ function jt({ widget: e }) {
517
+ const r = e.config ?? {}, [n, l] = q(!1);
507
518
  return r.collection ? r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
508
519
  /* @__PURE__ */ t(
509
520
  "button",
510
521
  {
511
522
  type: "button",
512
- onClick: () => n(!0),
523
+ onClick: () => l(!0),
513
524
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-3 text-[12.5px] font-medium text-slate-700 shadow-sm transition-colors hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
514
525
  children: r.button_label ?? r.title ?? "Manage"
515
526
  }
516
527
  ),
517
- a && /* @__PURE__ */ t(
528
+ n && /* @__PURE__ */ t(
518
529
  "div",
519
530
  {
520
531
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
521
- onClick: () => n(!1),
532
+ onClick: () => l(!1),
522
533
  children: /* @__PURE__ */ p(
523
534
  "div",
524
535
  {
@@ -527,7 +538,7 @@ function gt({ widget: e }) {
527
538
  width: typeof r.sheet_width == "number" ? `${r.sheet_width}px` : r.sheet_width ?? "92%",
528
539
  maxWidth: "96%"
529
540
  },
530
- onClick: (i) => i.stopPropagation(),
541
+ onClick: (o) => o.stopPropagation(),
531
542
  children: [
532
543
  /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
533
544
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: r.button_label ?? r.title ?? "Manage" }),
@@ -535,30 +546,30 @@ function gt({ widget: e }) {
535
546
  "button",
536
547
  {
537
548
  type: "button",
538
- onClick: () => n(!1),
549
+ onClick: () => l(!1),
539
550
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
540
551
  children: "Close"
541
552
  }
542
553
  )
543
554
  ] }),
544
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(ye, { config: r }) })
555
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t($e, { config: r }) })
545
556
  ]
546
557
  }
547
558
  )
548
559
  }
549
560
  )
550
- ] }) : /* @__PURE__ */ t(ye, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
561
+ ] }) : /* @__PURE__ */ t($e, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
551
562
  }
552
- function yt({
563
+ function Rt({
553
564
  cfg: e
554
565
  }) {
555
- const [r, a] = q(!1), n = { ...e };
556
- return delete n.display, /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
566
+ const [r, n] = q(!1), l = { ...e };
567
+ return delete l.display, /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
557
568
  /* @__PURE__ */ t(
558
569
  "button",
559
570
  {
560
571
  type: "button",
561
- onClick: () => a(!0),
572
+ onClick: () => n(!0),
562
573
  className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-3 text-[12.5px] font-medium text-slate-700 shadow-sm transition-colors hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:bg-card dark:text-slate-200 dark:hover:text-nvr-cyan",
563
574
  children: e.button_label ?? e.label ?? "View"
564
575
  }
@@ -567,7 +578,7 @@ function yt({
567
578
  "div",
568
579
  {
569
580
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
570
- onClick: () => a(!1),
581
+ onClick: () => n(!1),
571
582
  children: /* @__PURE__ */ p(
572
583
  "div",
573
584
  {
@@ -576,7 +587,7 @@ function yt({
576
587
  width: typeof e.sheet_width == "number" ? `${e.sheet_width}px` : e.sheet_width ?? "90%",
577
588
  maxWidth: "96%"
578
589
  },
579
- onClick: (i) => i.stopPropagation(),
590
+ onClick: (o) => o.stopPropagation(),
580
591
  children: [
581
592
  /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
582
593
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: e.button_label ?? e.label ?? "View" }),
@@ -584,13 +595,13 @@ function yt({
584
595
  "button",
585
596
  {
586
597
  type: "button",
587
- onClick: () => a(!1),
598
+ onClick: () => n(!1),
588
599
  className: "rounded px-2 py-1 text-[12px] text-slate-500 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
589
600
  children: "Close"
590
601
  }
591
602
  )
592
603
  ] }),
593
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Ce, { config: n }) })
604
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Oe, { config: l }) })
594
605
  ]
595
606
  }
596
607
  )
@@ -598,311 +609,332 @@ function yt({
598
609
  )
599
610
  ] });
600
611
  }
601
- function _e({ config: e }) {
602
- return e.display === "drawer" ? /* @__PURE__ */ t(yt, { cfg: e }) : /* @__PURE__ */ t(Ce, { config: e });
612
+ function Me({ config: e }) {
613
+ return e.display === "drawer" ? /* @__PURE__ */ t(Rt, { cfg: e }) : /* @__PURE__ */ t(Oe, { config: e });
603
614
  }
604
- function Ce({ config: e }) {
605
- var me, ue, pe, he, xe, fe, be;
606
- const r = D(), a = ke(), [n, i] = q(null), [m, s] = q(null), [l, o] = q(null), [u, x] = q(
607
- () => mt(e.filters)
608
- ), [b] = q(
609
- () => Qe(e.filters, typeof window > "u" ? "" : window.location.search)
610
- ), N = (c, h) => {
611
- const g = { ...u, [c]: h };
612
- if (x(g), typeof window > "u" || !(e.filters ?? []).some((k) => k.url_param)) return;
613
- const f = ze(e.filters, g, window.location.search);
614
- f !== window.location.search && window.history.replaceState(
615
+ function Oe({ config: e }) {
616
+ var fe, be, ge, ye, ve, ke, we;
617
+ const r = z(), n = qe(), [l, o] = q(null), [m, d] = q(null), [a, c] = q(null), [u, f] = q(
618
+ () => vt(e.filters)
619
+ ), [S] = q(
620
+ () => Ye(e.filters, typeof window > "u" ? "" : window.location.search)
621
+ ), $ = (i, h) => {
622
+ const b = { ...u, [i]: h };
623
+ if (f(b), typeof window > "u" || !(e.filters ?? []).some((g) => g.url_param)) return;
624
+ const x = Ze(e.filters, b, window.location.search);
625
+ x !== window.location.search && window.history.replaceState(
615
626
  window.history.state,
616
627
  "",
617
- `${window.location.pathname}${f}${window.location.hash}`
628
+ `${window.location.pathname}${x}${window.location.hash}`
618
629
  );
619
- }, [S, W] = q(null), [C, j] = q(null), R = (C == null ? void 0 : C.phase) === "running", w = Ae();
620
- ee(() => {
621
- if ((C == null ? void 0 : C.phase) !== "running") return;
622
- const c = window.setInterval(() => {
630
+ }, [w, R] = q(null), [_, j] = q(null), W = (_ == null ? void 0 : _.phase) === "running", O = ze();
631
+ H(() => {
632
+ if ((_ == null ? void 0 : _.phase) !== "running") return;
633
+ const i = window.setInterval(() => {
623
634
  j(
624
635
  (h) => (h == null ? void 0 : h.phase) === "running" ? { ...h, elapsedMs: Date.now() - h.startedAt } : h
625
636
  );
626
637
  }, 250);
627
- return () => window.clearInterval(c);
628
- }, [C == null ? void 0 : C.phase]);
629
- const { scopes: $, ready: O } = Ge(), d = te(!1), [y, F] = q(!1), [z, K] = q(/* @__PURE__ */ new Set());
630
- ee(() => {
631
- if (d.current || !O) return;
632
- d.current = !0;
633
- const c = (e.filters ?? []).filter(
634
- (h) => !(u[h.param] ?? []).length && !b.has(h.param)
638
+ return () => window.clearInterval(i);
639
+ }, [_ == null ? void 0 : _.phase]);
640
+ const { scopes: C, ready: v } = rt(), s = D(!1), [y, M] = q(!1), [B, K] = q(/* @__PURE__ */ new Map());
641
+ H(() => {
642
+ if (s.current || !v) return;
643
+ s.current = !0;
644
+ const i = (e.filters ?? []).filter(
645
+ (h) => !(u[h.param] ?? []).length && !S.has(h.param)
635
646
  );
636
- if (!$ || !c.length) {
637
- F(!0);
647
+ if (!C || !i.length) {
648
+ M(!0);
638
649
  return;
639
650
  }
640
651
  (async () => {
641
652
  try {
642
653
  const h = {};
643
- for (const g of c) {
644
- const f = ge($, { key: g.param, collection: g.collection });
645
- if (!f) continue;
646
- const k = Ue($, f.name);
647
- if (!k.length) continue;
648
- const _ = g.value_field ?? "id", M = await He(
654
+ for (const b of i) {
655
+ const x = Se(C, { key: b.param, collection: b.collection });
656
+ if (!x) continue;
657
+ const g = nt(C, x.name);
658
+ if (!g.length) continue;
659
+ const N = b.value_field ?? "id", T = await at(
649
660
  r,
650
- f,
651
- k,
652
- _
661
+ x,
662
+ g,
663
+ N
653
664
  );
654
- if (M.length) {
655
- const P = M.map((I, Me) => ({ [_]: I, id: k[Me] }));
656
- h[g.param] = g.single ? P.slice(0, 1) : P;
665
+ if (T.length) {
666
+ const P = T.map((I, Qe) => ({ [N]: I, id: g[Qe] }));
667
+ h[b.param] = b.single ? P.slice(0, 1) : P;
657
668
  }
658
669
  }
659
- Object.keys(h).length && (x((g) => {
660
- const f = { ...g };
661
- for (const [k, _] of Object.entries(h))
662
- (f[k] ?? []).length || (f[k] = _);
663
- return f;
664
- }), K(new Set(Object.keys(h))));
670
+ Object.keys(h).length && (f((b) => {
671
+ const x = { ...b };
672
+ for (const [g, N] of Object.entries(h))
673
+ (x[g] ?? []).length || (x[g] = N);
674
+ return x;
675
+ }), K(
676
+ new Map(
677
+ Object.entries(h).map(([b, x]) => {
678
+ var N;
679
+ const g = ((N = (e.filters ?? []).find((T) => T.param === b)) == null ? void 0 : N.value_field) ?? "id";
680
+ return [b, _e(x, g)];
681
+ })
682
+ )
683
+ ));
665
684
  } finally {
666
- F(!0);
685
+ M(!0);
667
686
  }
668
687
  })();
669
- }, [O, $, e.filters, u, r, b]);
670
- const T = Pe(() => {
671
- const c = { ...e.params ?? {} };
688
+ }, [v, C, e.filters, u, r, S]);
689
+ const J = Ne(() => {
690
+ const i = { ...e.params ?? {} };
672
691
  for (const h of e.filters ?? []) {
673
- const g = u[h.param] ?? [];
674
- g.length > 0 && (c[h.param] = g.map((f) => String(f[h.value_field ?? "id"] ?? "")).join(","));
692
+ const b = u[h.param] ?? [];
693
+ b.length > 0 && (i[h.param] = b.map((x) => String(x[h.value_field ?? "id"] ?? "")).join(","));
675
694
  }
676
- return c;
677
- }, [e.params, e.filters, u]), B = te(!1), {
678
- data: A,
679
- isPending: le,
680
- error: ne,
681
- refetch: se,
682
- isFetching: qe
695
+ return i;
696
+ }, [e.params, e.filters, u]), [V, Fe] = q(/* @__PURE__ */ new Set()), ee = D(!1), oe = JSON.stringify(J), Pe = He(
697
+ oe,
698
+ ee.current ? V.size > 0 ? _t : $t : 0
699
+ ), te = ee.current ? Pe : oe, A = Ne(
700
+ () => JSON.parse(te),
701
+ [te]
702
+ ), re = D(!1), {
703
+ data: F,
704
+ isPending: de,
705
+ error: ce,
706
+ refetch: ue,
707
+ isFetching: Ae
683
708
  } = Q({
684
- queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(T)],
709
+ queryKey: ["page-renderer-query", e.query_slug, te],
685
710
  queryFn: () => {
686
- const c = B.current;
687
- return B.current = !1, r.request(
688
- U(`/custom-queries/${e.query_slug}/execute`, {
689
- params: T,
690
- ...c ? { refresh: !0 } : {}
711
+ const i = re.current;
712
+ return re.current = !1, r.request(
713
+ Y(`/custom-queries/${e.query_slug}/execute`, {
714
+ params: A,
715
+ ...i ? { refresh: !0 } : {}
691
716
  })
692
717
  );
693
718
  },
694
719
  enabled: !!e.query_slug && y,
695
720
  staleTime: 6e4
696
- }), V = A == null ? void 0 : A.data, je = Fe(() => {
697
- B.current = !0, se();
698
- }, [se]), ie = le;
721
+ }), G = F == null ? void 0 : F.data, Ee = Ke(() => {
722
+ re.current = !0, ue();
723
+ }, [ue]), me = de;
699
724
  if (!e.query_slug) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set a query slug" });
700
- const Re = (c) => {
701
- var k;
725
+ const Le = (i) => {
726
+ var g;
702
727
  const h = {};
703
- for (const [_, M] of Object.entries(c.params ?? {})) {
704
- const P = Se(M, null, V ?? [], T, u, e.filters);
728
+ for (const [N, T] of Object.entries(i.params ?? {})) {
729
+ const P = We(T, null, G ?? [], A, u, e.filters);
705
730
  if (P === void 0) {
706
- W(`Select a value for "${_}" first`);
731
+ R(`Select a value for "${N}" first`);
707
732
  return;
708
733
  }
709
- h[_] = P;
734
+ h[N] = P;
710
735
  }
711
- const g = (k = c.confirm) == null ? void 0 : k.replace(/\{(\w+)\}/g, (_, M) => String(h[M] ?? "")), f = {
712
- action: c,
736
+ const b = (g = i.confirm) == null ? void 0 : g.replace(/\{(\w+)\}/g, (N, T) => String(h[T] ?? "")), x = {
737
+ action: i,
713
738
  params: h,
714
- phase: g ? "confirm" : "running",
715
- confirmText: g ?? null,
739
+ phase: b ? "confirm" : "running",
740
+ confirmText: b ?? null,
716
741
  startedAt: Date.now(),
717
742
  elapsedMs: 0
718
743
  };
719
- j(f), g || oe(f);
720
- }, oe = async (c) => {
744
+ j(x), b || pe(x);
745
+ }, pe = async (i) => {
721
746
  const h = Date.now();
722
- j({ ...c, phase: "running", startedAt: h, elapsedMs: 0 });
747
+ j({ ...i, phase: "running", startedAt: h, elapsedMs: 0 });
723
748
  try {
724
- const g = await r.request(
725
- U(`/custom-queries/${c.action.query_slug}/execute`, { params: c.params })
726
- ), f = Array.isArray(g == null ? void 0 : g.data) ? g.data : [];
749
+ const b = await r.request(
750
+ Y(`/custom-queries/${i.action.query_slug}/execute`, { params: i.params })
751
+ ), x = Array.isArray(b == null ? void 0 : b.data) ? b.data : [];
727
752
  j(
728
- (k) => k && k.action === c.action ? {
729
- ...k,
753
+ (g) => g && g.action === i.action ? {
754
+ ...g,
730
755
  phase: "done",
731
756
  elapsedMs: Date.now() - h,
732
- resultRows: f.length,
733
- resultSample: f[0] ?? null
734
- } : k
735
- ), W(
736
- `${c.action.success_message ?? `${c.action.label} completed`} · ${G(Date.now() - h)}`
737
- ), w.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
738
- } catch (g) {
739
- const f = Ne(g, "unknown error");
757
+ resultRows: x.length,
758
+ resultSample: x[0] ?? null
759
+ } : g
760
+ ), R(
761
+ `${i.action.success_message ?? `${i.action.label} completed`} · ${U(Date.now() - h)}`
762
+ ), O.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
763
+ } catch (b) {
764
+ const x = Re(b, "unknown error");
740
765
  j(
741
- (k) => k && k.action === c.action ? { ...k, phase: "error", elapsedMs: Date.now() - h, error: f } : k
742
- ), W(`${c.action.label} failed: ${f}`);
766
+ (g) => g && g.action === i.action ? { ...g, phase: "error", elapsedMs: Date.now() - h, error: x } : g
767
+ ), R(`${i.action.label} failed: ${x}`);
743
768
  }
744
- }, We = /* @__PURE__ */ t(
745
- Xe,
769
+ }, Be = /* @__PURE__ */ t(
770
+ it,
746
771
  {
747
- envelope: A,
748
- onRefresh: je,
749
- refreshing: qe && !le,
772
+ envelope: F,
773
+ onRefresh: Ee,
774
+ refreshing: Ae && !de,
750
775
  className: "ml-auto"
751
776
  }
752
- ), J = e.filters && e.filters.length > 0 || (me = e.actions) != null && me.length || A != null && A.cache_ttl ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
753
- (e.filters ?? []).map((c) => {
754
- const h = ge($, { key: c.param, collection: c.collection }), g = h ? ($ == null ? void 0 : $.restricted[h.name]) ?? [] : [];
777
+ ), ne = e.filters && e.filters.length > 0 || (fe = e.actions) != null && fe.length || F != null && F.cache_ttl ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
778
+ (e.filters ?? []).map((i) => {
779
+ const h = Se(C, { key: i.param, collection: i.collection }), b = h ? (C == null ? void 0 : C.restricted[h.name]) ?? [] : [];
755
780
  return /* @__PURE__ */ t(
756
- ft,
781
+ Ct,
757
782
  {
758
- filter: c,
759
- selected: u[c.param] ?? [],
760
- allowedIds: g.length > 0 ? g : void 0,
761
- scopeDefault: z.has(c.param),
762
- onChange: (f) => N(c.param, f)
783
+ filter: i,
784
+ selected: u[i.param] ?? [],
785
+ allowedIds: b.length > 0 ? b : void 0,
786
+ scopeDefault: B.has(i.param) && B.get(i.param) === _e(u[i.param] ?? [], i.value_field ?? "id"),
787
+ onChange: (x) => {
788
+ ee.current = !0, $(i.param, x);
789
+ },
790
+ onOpenChange: (x) => Fe((g) => {
791
+ if (g.has(i.param) === x) return g;
792
+ const N = new Set(g);
793
+ return x ? N.add(i.param) : N.delete(i.param), N;
794
+ })
763
795
  },
764
- c.param
796
+ i.param
765
797
  );
766
798
  }),
767
- (e.actions ?? []).map((c) => /* @__PURE__ */ t(
799
+ (e.actions ?? []).map((i) => /* @__PURE__ */ t(
768
800
  "button",
769
801
  {
770
802
  type: "button",
771
- disabled: R,
772
- onClick: () => void Re(c),
803
+ disabled: W,
804
+ onClick: () => void Le(i),
773
805
  className: "ml-auto inline-flex h-8 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50",
774
- children: R ? "Running…" : c.label
806
+ children: W ? "Running…" : i.label
775
807
  },
776
- c.label
808
+ i.label
777
809
  )),
778
- S && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: S }),
779
- We
780
- ] }) : null, de = (ue = e.stats) != null && ue.length ? /* @__PURE__ */ t(
781
- et,
810
+ w && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: w }),
811
+ Be
812
+ ] }) : null, he = (be = e.stats) != null && be.length ? /* @__PURE__ */ t(
813
+ dt,
782
814
  {
783
815
  stats: e.stats,
784
- rows: V ?? [],
785
- effectiveParams: T,
786
- loading: ie
816
+ rows: G ?? [],
817
+ effectiveParams: A,
818
+ loading: me
787
819
  }
788
820
  ) : null;
789
- if (ie)
821
+ if (me)
790
822
  return /* @__PURE__ */ p("div", { className: "p-3", children: [
791
- J,
792
- de,
793
- /* @__PURE__ */ t(H, {})
823
+ ne,
824
+ he,
825
+ /* @__PURE__ */ t(X, {})
794
826
  ] });
795
- if (ne)
827
+ if (ce)
796
828
  return /* @__PURE__ */ p("div", { className: "p-3", children: [
797
- J,
798
- /* @__PURE__ */ t(Y, { error: ne })
829
+ ne,
830
+ /* @__PURE__ */ t(Z, { error: ce })
799
831
  ] });
800
- const v = e.row_click, ce = (c, h) => {
801
- const f = Ve(c, (_) => ut(
802
- _,
832
+ const k = e.row_click, xe = (i, h) => {
833
+ const x = et(i, (N) => kt(
834
+ N,
803
835
  h,
804
- V ?? [],
805
- T,
836
+ G ?? [],
837
+ A,
806
838
  u,
807
839
  e.filters
808
- )), k = f.resolvedTabs.map((_) => {
809
- if ("matrix" in _) {
810
- const M = {};
811
- for (const [P, I] of Object.entries(_.matrix.scope))
812
- M[P] = I.startsWith("$row.") ? h == null ? void 0 : h[I.slice(5)] : I;
840
+ )), g = x.resolvedTabs.map((N) => {
841
+ if ("matrix" in N) {
842
+ const T = {};
843
+ for (const [P, I] of Object.entries(N.matrix.scope))
844
+ T[P] = I.startsWith("$row.") ? h == null ? void 0 : h[I.slice(5)] : I;
813
845
  return {
814
- label: _.label,
815
- matrix: { config: _.matrix.config, initialScope: M }
846
+ label: N.label,
847
+ matrix: { config: N.matrix.config, initialScope: T }
816
848
  };
817
849
  }
818
- return { label: _.label, note: _.note, config: _.config };
850
+ return { label: N.label, note: N.note, config: N.config };
819
851
  });
820
- o({
852
+ c({
821
853
  def: {
822
- ...c,
823
- resolvedTabs: k,
824
- header: f.header ? {
825
- config: f.header.config,
826
- stats: f.header.stats,
827
- asOf: f.header.asOf,
828
- note: f.header.note
854
+ ...i,
855
+ resolvedTabs: g,
856
+ header: x.header ? {
857
+ config: x.header.config,
858
+ stats: x.header.stats,
859
+ asOf: x.header.asOf,
860
+ note: x.header.note
829
861
  } : null,
830
- initialTab: f.initialTab
862
+ initialTab: x.initialTab
831
863
  },
832
864
  row: h
833
865
  });
834
- }, Te = v ? (c) => {
835
- v.picker ? i(c) : v.sheet ? ce(v.sheet, c) : v.matrix && c.id != null ? s(c.id) : v.drill && c.id != null && (a == null || a.open({
836
- collection: v.drill.collection ?? "",
837
- itemId: String(c.id),
838
- layoutId: v.drill.layout_id,
839
- width: v.drill.width
866
+ }, Ie = k ? (i) => {
867
+ k.picker ? o(i) : k.sheet ? xe(k.sheet, i) : k.matrix && i.id != null ? d(i.id) : k.drill && i.id != null && (n == null || n.open({
868
+ collection: k.drill.collection ?? "",
869
+ itemId: String(i.id),
870
+ layoutId: k.drill.layout_id,
871
+ width: k.drill.width
840
872
  }));
841
- } : void 0, Oe = (pe = e.row_actions) != null && pe.length ? e.row_actions.map((c) => ({
842
- label: c.label,
843
- onClick: (h) => ce(c.sheet, h)
873
+ } : void 0, De = (ge = e.row_actions) != null && ge.length ? e.row_actions.map((i) => ({
874
+ label: i.label,
875
+ onClick: (h) => xe(i.sheet, h)
844
876
  })) : void 0;
845
877
  return /* @__PURE__ */ p(
846
878
  "div",
847
879
  {
848
- className: (he = e.table) != null && he.sticky ? (
880
+ className: (ye = e.table) != null && ye.sticky ? (
849
881
  // Sticky grids own their scroll: filters/stats stay pinned above a
850
882
  // scrolling table region (header/first-column/totals pin inside it).
851
883
  "flex h-full min-h-0 flex-col overflow-hidden p-3"
852
884
  ) : "h-full overflow-auto p-3",
853
885
  children: [
854
- J,
855
- de,
886
+ ne,
887
+ he,
856
888
  /* @__PURE__ */ t(
857
- tt,
889
+ ct,
858
890
  {
859
- rows: V ?? [],
891
+ rows: G ?? [],
860
892
  config: (
861
893
  // Current-month highlight only applies when the selected year param
862
894
  // IS the current year — otherwise strip it.
863
- (xe = e.table) != null && xe.highlight_group && e.table.highlight_year_param ? Number(
864
- String(T[e.table.highlight_year_param] ?? "").split(",")[0]
895
+ (ve = e.table) != null && ve.highlight_group && e.table.highlight_year_param ? Number(
896
+ String(A[e.table.highlight_year_param] ?? "").split(",")[0]
865
897
  ) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
866
898
  ),
867
- onRowClick: Te,
868
- rowActions: Oe,
899
+ onRowClick: Ie,
900
+ rowActions: De,
869
901
  emptyText: e.empty_label,
870
- pivotYear: (be = (fe = e.table) == null ? void 0 : fe.pivot) != null && be.year_param && Number(String(T[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
902
+ pivotYear: (we = (ke = e.table) == null ? void 0 : ke.pivot) != null && we.year_param && Number(String(A[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
871
903
  }
872
904
  ),
873
- (v == null ? void 0 : v.picker) && n && /* @__PURE__ */ t(
905
+ (k == null ? void 0 : k.picker) && l && /* @__PURE__ */ t(
874
906
  "div",
875
907
  {
876
908
  className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 pt-32",
877
- onClick: () => i(null),
909
+ onClick: () => o(null),
878
910
  children: /* @__PURE__ */ p(
879
911
  "div",
880
912
  {
881
913
  className: "w-[420px] rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-background",
882
- onClick: (c) => c.stopPropagation(),
914
+ onClick: (i) => i.stopPropagation(),
883
915
  children: [
884
- /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: v.picker.title ?? "Choose a record" }),
916
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: k.picker.title ?? "Choose a record" }),
885
917
  /* @__PURE__ */ t(
886
- Ze,
918
+ ot,
887
919
  {
888
- collection: v.picker.collection,
920
+ collection: k.picker.collection,
889
921
  value: null,
890
- onChange: (c) => {
891
- var h, g, f, k;
892
- if (i(null), c != null) {
893
- if (v.matrix) {
894
- s(c);
922
+ onChange: (i) => {
923
+ var h, b, x, g;
924
+ if (o(null), i != null) {
925
+ if (k.matrix) {
926
+ d(i);
895
927
  return;
896
928
  }
897
- a == null || a.open({
898
- collection: ((h = v.drill) == null ? void 0 : h.collection) ?? ((g = v.picker) == null ? void 0 : g.collection) ?? "",
899
- itemId: String(c),
900
- layoutId: (f = v.drill) == null ? void 0 : f.layout_id,
901
- width: (k = v.drill) == null ? void 0 : k.width
929
+ n == null || n.open({
930
+ collection: ((h = k.drill) == null ? void 0 : h.collection) ?? ((b = k.picker) == null ? void 0 : b.collection) ?? "",
931
+ itemId: String(i),
932
+ layoutId: (x = k.drill) == null ? void 0 : x.layout_id,
933
+ width: (g = k.drill) == null ? void 0 : g.width
902
934
  });
903
935
  }
904
936
  },
905
- extraFilter: xt(v.picker.filter, n, u, e.filters),
937
+ extraFilter: St(k.picker.filter, l, u, e.filters),
906
938
  placeholder: "Search…"
907
939
  }
908
940
  ),
@@ -910,7 +942,7 @@ function Ce({ config: e }) {
910
942
  "button",
911
943
  {
912
944
  type: "button",
913
- onClick: () => i(null),
945
+ onClick: () => o(null),
914
946
  className: "mt-3 h-7 rounded px-2 text-[12px] text-slate-500 hover:text-slate-700",
915
947
  children: "Cancel"
916
948
  }
@@ -920,22 +952,22 @@ function Ce({ config: e }) {
920
952
  )
921
953
  }
922
954
  ),
923
- (v == null ? void 0 : v.matrix) && m != null && /* @__PURE__ */ t(
924
- $e,
955
+ (k == null ? void 0 : k.matrix) && m != null && /* @__PURE__ */ t(
956
+ Te,
925
957
  {
926
- config: v.matrix.config,
927
- initialScope: { [v.matrix.scope_field]: m },
928
- width: v.matrix.width,
929
- title: v.matrix.title,
930
- onClose: () => s(null)
958
+ config: k.matrix.config,
959
+ initialScope: { [k.matrix.scope_field]: m },
960
+ width: k.matrix.width,
961
+ title: k.matrix.title,
962
+ onClose: () => d(null)
931
963
  }
932
964
  ),
933
- l && /* @__PURE__ */ t(ht, { def: l.def, row: l.row, onClose: () => o(null) }),
934
- C && /* @__PURE__ */ t(
935
- vt,
965
+ a && /* @__PURE__ */ t(Nt, { def: a.def, row: a.row, onClose: () => c(null) }),
966
+ _ && /* @__PURE__ */ t(
967
+ Tt,
936
968
  {
937
- run: C,
938
- onConfirm: () => void oe(C),
969
+ run: _,
970
+ onConfirm: () => void pe(_),
939
971
  onClose: () => {
940
972
  j(null);
941
973
  }
@@ -945,21 +977,21 @@ function Ce({ config: e }) {
945
977
  }
946
978
  );
947
979
  }
948
- const G = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
949
- function vt({
980
+ const U = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
981
+ function Tt({
950
982
  run: e,
951
983
  onConfirm: r,
952
- onClose: a
984
+ onClose: n
953
985
  }) {
954
- const n = Object.entries(e.params);
955
- return Be(
986
+ const l = Object.entries(e.params);
987
+ return Je(
956
988
  /* @__PURE__ */ p(E, { children: [
957
989
  /* @__PURE__ */ t(
958
990
  "div",
959
991
  {
960
992
  role: "presentation",
961
993
  className: "fixed inset-0 z-40 bg-slate-950/40",
962
- onClick: e.phase === "running" ? void 0 : a
994
+ onClick: e.phase === "running" ? void 0 : n
963
995
  }
964
996
  ),
965
997
  /* @__PURE__ */ p(
@@ -971,10 +1003,10 @@ function vt({
971
1003
  className: "fixed left-1/2 top-[24vh] z-50 w-[min(400px,92vw)] -translate-x-1/2 rounded-xl border border-slate-200 bg-white p-4 shadow-2xl dark:border-border dark:bg-card",
972
1004
  children: [
973
1005
  /* @__PURE__ */ t("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: e.action.label }),
974
- n.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: n.map(([i, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
975
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: L(i) }),
1006
+ l.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: l.map(([o, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1007
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: L(o) }),
976
1008
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m) })
977
- ] }, i)) }),
1009
+ ] }, o)) }),
978
1010
  e.phase === "confirm" && /* @__PURE__ */ p(E, { children: [
979
1011
  /* @__PURE__ */ t("p", { className: "mt-2 text-[12.5px] text-slate-600 dark:text-slate-300", children: e.confirmText }),
980
1012
  /* @__PURE__ */ p("div", { className: "mt-3 flex gap-2", children: [
@@ -991,7 +1023,7 @@ function vt({
991
1023
  "button",
992
1024
  {
993
1025
  type: "button",
994
- onClick: a,
1026
+ onClick: n,
995
1027
  className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] font-medium text-slate-600 dark:border-border dark:text-slate-300",
996
1028
  children: "Cancel"
997
1029
  }
@@ -1001,19 +1033,19 @@ function vt({
1001
1033
  e.phase === "running" && /* @__PURE__ */ p("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
1002
1034
  /* @__PURE__ */ t("span", { className: "h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-nvr-cyan border-t-transparent" }),
1003
1035
  "Running… ",
1004
- /* @__PURE__ */ t("span", { className: "tabular-nums", children: G(e.elapsedMs) })
1036
+ /* @__PURE__ */ t("span", { className: "tabular-nums", children: U(e.elapsedMs) })
1005
1037
  ] }),
1006
1038
  e.phase === "done" && /* @__PURE__ */ p(E, { children: [
1007
1039
  /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
1008
1040
  e.action.success_message ?? "Completed",
1009
1041
  " · ",
1010
- G(e.elapsedMs)
1042
+ U(e.elapsedMs)
1011
1043
  ] }),
1012
1044
  e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ p("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
1013
- Object.entries(e.resultSample).slice(0, 8).map(([i, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1014
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: L(i) }),
1045
+ Object.entries(e.resultSample).slice(0, 8).map(([o, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1046
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: L(o) }),
1015
1047
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m ?? "—") })
1016
- ] }, i)),
1048
+ ] }, o)),
1017
1049
  e.resultRows > 1 && /* @__PURE__ */ p("p", { className: "pt-0.5 text-slate-400", children: [
1018
1050
  "…",
1019
1051
  e.resultRows,
@@ -1024,7 +1056,7 @@ function vt({
1024
1056
  "button",
1025
1057
  {
1026
1058
  type: "button",
1027
- onClick: a,
1059
+ onClick: n,
1028
1060
  className: "mt-3 h-8 w-full rounded-md border border-slate-200 text-[12.5px] font-medium text-slate-600 dark:border-border dark:text-slate-300",
1029
1061
  children: "Close"
1030
1062
  }
@@ -1033,7 +1065,7 @@ function vt({
1033
1065
  e.phase === "error" && /* @__PURE__ */ p(E, { children: [
1034
1066
  /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
1035
1067
  "Failed after ",
1036
- G(e.elapsedMs),
1068
+ U(e.elapsedMs),
1037
1069
  ": ",
1038
1070
  e.error
1039
1071
  ] }),
@@ -1051,7 +1083,7 @@ function vt({
1051
1083
  "button",
1052
1084
  {
1053
1085
  type: "button",
1054
- onClick: a,
1086
+ onClick: n,
1055
1087
  className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] font-medium text-slate-600 dark:border-border dark:text-slate-300",
1056
1088
  children: "Close"
1057
1089
  }
@@ -1065,124 +1097,125 @@ function vt({
1065
1097
  document.body
1066
1098
  );
1067
1099
  }
1068
- function ve({ slug: e, widget: r }) {
1069
- var a;
1100
+ function Ce({ slug: e, widget: r }) {
1101
+ var n;
1070
1102
  switch (r.type) {
1071
1103
  case "table":
1072
- return /* @__PURE__ */ t(st, { slug: e, widget: r });
1104
+ return /* @__PURE__ */ t(xt, { slug: e, widget: r });
1073
1105
  case "kpi":
1074
- return /* @__PURE__ */ t(it, { slug: e, widget: r });
1106
+ return /* @__PURE__ */ t(ft, { slug: e, widget: r });
1075
1107
  case "markdown":
1076
- return /* @__PURE__ */ t(nt, { content: String(((a = r.config) == null ? void 0 : a.content) ?? "") });
1108
+ return /* @__PURE__ */ t(ht, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
1077
1109
  case "iframe":
1078
- return /* @__PURE__ */ t(dt, { widget: r });
1110
+ return /* @__PURE__ */ t(gt, { widget: r });
1079
1111
  case "query":
1080
- return /* @__PURE__ */ t(bt, { widget: r });
1112
+ return /* @__PURE__ */ t(qt, { widget: r });
1081
1113
  case "matrix":
1082
- return /* @__PURE__ */ t(ct, { widget: r });
1114
+ return /* @__PURE__ */ t(yt, { widget: r });
1083
1115
  case "record-grid":
1084
- return /* @__PURE__ */ t(gt, { widget: r });
1116
+ return /* @__PURE__ */ t(jt, { widget: r });
1085
1117
  case "recent-activity":
1086
- return /* @__PURE__ */ t(ot, { slug: e, widget: r });
1118
+ return /* @__PURE__ */ t(bt, { slug: e, widget: r });
1087
1119
  default:
1088
1120
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Unknown widget" });
1089
1121
  }
1090
1122
  }
1091
- function It({ slug: e, hideHeader: r, className: a }) {
1092
- var $, O;
1093
- const n = D(), i = ke(), m = Ee("drill.page"), s = m.value, {
1094
- data: l,
1095
- isLoading: o,
1123
+ function Zt({ slug: e, hideHeader: r, className: n }) {
1124
+ var C, v;
1125
+ const l = z(), o = qe(), m = Ve("drill.page"), d = m.value, {
1126
+ data: a,
1127
+ isLoading: c,
1096
1128
  error: u
1097
1129
  } = Q({
1098
1130
  queryKey: ["page-renderer", e],
1099
- queryFn: () => n.request(we(`/pages/${e}`)).then((d) => d.data),
1131
+ queryFn: () => l.request(je(`/pages/${e}`)).then((s) => s.data),
1100
1132
  enabled: !!e,
1101
1133
  retry: !1
1102
1134
  });
1103
- if (o)
1104
- return /* @__PURE__ */ t("div", { className: a ?? "p-6", children: /* @__PURE__ */ t(H, {}) });
1105
- if (u || !l)
1135
+ if (c)
1136
+ return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(X, {}) });
1137
+ if (u || !a)
1106
1138
  return /* @__PURE__ */ p(
1107
1139
  "div",
1108
1140
  {
1109
- className: `flex flex-col items-center justify-center p-10 text-center ${a ?? ""}`,
1141
+ className: `flex flex-col items-center justify-center p-10 text-center ${n ?? ""}`,
1110
1142
  children: [
1111
1143
  /* @__PURE__ */ t("p", { className: "text-sm font-medium text-slate-600 dark:text-slate-300", children: "Page not found" }),
1112
1144
  /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-slate-400", children: "This page does not exist or you do not have access to it." })
1113
1145
  ]
1114
1146
  }
1115
1147
  );
1116
- const x = (($ = l.layout) == null ? void 0 : $.columns) ?? 12, b = ((O = l.layout) == null ? void 0 : O.widgets) ?? [], N = (d) => {
1148
+ const f = ((C = a.layout) == null ? void 0 : C.columns) ?? 12, S = ((v = a.layout) == null ? void 0 : v.widgets) ?? [], $ = (s) => {
1117
1149
  var y;
1118
- return (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((y = d.config) == null ? void 0 : y.display) === "drawer";
1119
- }, S = [...new Set(b.filter(N).map((d) => d.y))].filter((d) => b.every((y) => N(y) || d < y.y || d >= y.y + Math.max(y.h, 1))).sort((d, y) => d - y), W = S.map((d) => ({
1120
- y: d,
1121
- items: b.filter((y) => y.y === d && N(y)).sort((y, F) => y.x - F.x)
1122
- })), C = b.filter((d) => !(N(d) && S.includes(d.y))), j = (d) => d - S.filter((y) => y < d).length, R = C.find((d) => {
1150
+ return (s.type === "matrix" || s.type === "query" || s.type === "record-grid") && ((y = s.config) == null ? void 0 : y.display) === "drawer";
1151
+ }, w = [...new Set(S.filter($).map((s) => s.y))].filter((s) => S.every((y) => $(y) || s < y.y || s >= y.y + Math.max(y.h, 1))).sort((s, y) => s - y), R = w.map((s) => ({
1152
+ y: s,
1153
+ items: S.filter((y) => y.y === s && $(y)).sort((y, M) => y.x - M.x)
1154
+ })), _ = S.filter((s) => !($(s) && w.includes(s.y))), j = (s) => s - w.filter((y) => y < s).length, W = _.find((s) => {
1123
1155
  var y;
1124
- return (y = d.config) == null ? void 0 : y.full_height;
1125
- }), w = /* @__PURE__ */ p("div", { className: `flex h-full min-h-0 flex-col ${a ?? ""}`, children: [
1126
- !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: l.name }) }),
1127
- /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${R ? "flex flex-col" : ""}`, children: b.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ p(E, { children: [
1128
- W.map((d) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: d.items.map((y) => /* @__PURE__ */ t(ve, { slug: l.slug, widget: y }, y.id)) }, d.y)),
1156
+ return (y = s.config) == null ? void 0 : y.full_height;
1157
+ }), O = /* @__PURE__ */ p("div", { className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
1158
+ !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: a.name }) }),
1159
+ /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${W ? "flex flex-col" : ""}`, children: S.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ p(E, { children: [
1160
+ R.map((s) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: s.items.map((y) => /* @__PURE__ */ t(Ce, { slug: a.slug, widget: y }, y.id)) }, s.y)),
1129
1161
  /* @__PURE__ */ t(
1130
1162
  "div",
1131
1163
  {
1132
- className: R ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1164
+ className: W ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1133
1165
  style: {
1134
- gridTemplateColumns: `repeat(${x}, minmax(0, 1fr))`,
1166
+ gridTemplateColumns: `repeat(${f}, minmax(0, 1fr))`,
1135
1167
  // repeat(0, …) is INVALID CSS (count must be ≥1) and drops the
1136
1168
  // whole declaration — a fill widget in the first row band emits
1137
1169
  // just the stretching track.
1138
- ...R ? {
1139
- gridTemplateRows: `${j(R.y) > 0 ? `repeat(${j(R.y)}, ${X}px) ` : ""}minmax(${X * 3}px, 1fr)`
1170
+ ...W ? {
1171
+ gridTemplateRows: `${j(W.y) > 0 ? `repeat(${j(W.y)}, ${ae}px) ` : ""}minmax(${ae * 3}px, 1fr)`
1140
1172
  } : {},
1141
- gridAutoRows: `${X}px`
1173
+ gridAutoRows: `${ae}px`
1142
1174
  },
1143
- children: C.map((d) => {
1144
- var z, K, T, B;
1145
- const y = (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((z = d.config) == null ? void 0 : z.display) === "drawer", F = d === R;
1175
+ children: _.map((s) => {
1176
+ var B, K, J, V;
1177
+ const y = (s.type === "matrix" || s.type === "query" || s.type === "record-grid") && ((B = s.config) == null ? void 0 : B.display) === "drawer", M = s === W;
1146
1178
  return /* @__PURE__ */ p(
1147
1179
  "div",
1148
1180
  {
1149
1181
  className: y ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1150
1182
  style: {
1151
- gridColumn: `${Math.min(d.x, x - 1) + 1} / span ${Math.min(d.w, x)}`,
1152
- gridRow: F ? `${j(d.y) + 1} / -1` : `${j(d.y) + 1} / span ${Math.max(d.h, 1)}`
1183
+ gridColumn: `${Math.min(s.x, f - 1) + 1} / span ${Math.min(s.w, f)}`,
1184
+ gridRow: M ? `${j(s.y) + 1} / -1` : `${j(s.y) + 1} / span ${Math.max(s.h, 1)}`
1153
1185
  },
1154
1186
  children: [
1155
- !y && d.type !== "kpi" && d.type !== "markdown" && ((K = d.config) == null ? void 0 : K.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((T = d.config) == null ? void 0 : T.label) ?? "") || (typeof ((B = d.config) == null ? void 0 : B.collection) == "string" ? L(String(d.config.collection)) : L(d.type)) }),
1156
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(ve, { slug: l.slug, widget: d }) })
1187
+ !y && s.type !== "kpi" && s.type !== "markdown" && ((K = s.config) == null ? void 0 : K.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((J = s.config) == null ? void 0 : J.label) ?? "") || (typeof ((V = s.config) == null ? void 0 : V.collection) == "string" ? L(String(s.config.collection)) : L(s.type)) }),
1188
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Ce, { slug: a.slug, widget: s }) })
1157
1189
  ]
1158
1190
  },
1159
- d.id
1191
+ s.id
1160
1192
  );
1161
1193
  })
1162
1194
  }
1163
1195
  )
1164
1196
  ] }) })
1165
1197
  ] });
1166
- return i ? w : /* @__PURE__ */ p(Le.Provider, { value: { open: (d) => m.push([d]) }, children: [
1167
- s != null && s.length ? /* @__PURE__ */ t(
1168
- rt,
1198
+ return o ? O : /* @__PURE__ */ p(Ge.Provider, { value: { open: (s) => m.push([s]) }, children: [
1199
+ d != null && d.length ? /* @__PURE__ */ t(
1200
+ ut,
1169
1201
  {
1170
- collection: s[0].collection,
1171
- itemId: s[0].itemId,
1172
- layoutId: s[0].layoutId,
1173
- width: s[0].width,
1174
- title: s[0].title,
1175
- stack: s,
1176
- onPush: (d) => m.push([...s, d]),
1202
+ collection: d[0].collection,
1203
+ itemId: d[0].itemId,
1204
+ layoutId: d[0].layoutId,
1205
+ width: d[0].width,
1206
+ title: d[0].title,
1207
+ stack: d,
1208
+ onPush: (s) => m.push([...d, s]),
1177
1209
  onPop: () => m.back(),
1178
- onClose: () => m.back(s.length)
1210
+ onClose: () => m.back(d.length)
1179
1211
  }
1180
1212
  ) : null,
1181
- w
1213
+ O
1182
1214
  ] });
1183
1215
  }
1184
1216
  export {
1185
- It as PageRenderer,
1186
- _e as QueryWidgetView,
1187
- gt as RecordGridWidgetBody
1217
+ Zt as PageRenderer,
1218
+ Me as QueryWidgetView,
1219
+ jt as RecordGridWidgetBody,
1220
+ _e as selectionSignature
1188
1221
  };