@nivaro/react 0.3.10 → 0.3.11

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