@nivaro/react 0.3.51 → 0.3.53

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