@nivaro/react 0.3.85 → 0.3.87

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.
@@ -1,91 +1,91 @@
1
- import { jsx as t, jsxs as x, Fragment as _e } from "react/jsx-runtime";
2
- import { useQueryClient as et, useQuery as tt } from "@tanstack/react-query";
3
- import { AlertTriangle as Qe, RefreshCw as ze, MoreVertical as rt, MoreHorizontal as nt, Clipboard as lt, Copy as it, Clock as st, Calendar as at, Paperclip as ot, Folder as ct, File as dt, FileText as ut, Bell as ft, Phone as pt, MessageSquare as mt, Mail as ht, UserCheck as gt, UserPlus as yt, Users as xt, User as wt, Activity as bt, Zap as vt, Power as _t, Search as Nt, Filter as kt, Sliders as St, Settings as Rt, RotateCcw as Lt, Pause as Ct, Play as $t, HelpCircle as Et, Info as Tt, AlertCircle as jt, Flag as Ot, Bookmark as It, Heart as qt, Star as Dt, Unlock as At, Lock as Ut, EyeOff as Pt, Eye as Wt, Send as Mt, Upload as Bt, Download as Ht, Save as Vt, Trash2 as Ft, Edit2 as Jt, Edit as Kt, Minus as Qt, Plus as zt, XCircle as Gt, X as Xt, CheckCircle as Yt, Check as Zt, Share2 as er, Link as tr, ExternalLink as rr, ArrowUpRight as nr, ArrowDown as lr, ArrowUp as ir, ArrowLeft as sr, ArrowRight as ar } from "lucide-react";
4
- import { useState as P, useRef as te, useCallback as De, useEffect as ee, useMemo as Ae } from "react";
5
- import { useApiFetchConfig as Ne, useDrilldown as or, useOptionalNivaroClient as cr } from "../context.js";
6
- import { useDebounced as dr } from "../hooks/useDebounced.js";
7
- import { PRETEND_DOWN_EVENT as Ue } from "../lib/client-chaos.js";
8
- import { get as ur, post as fr } from "../lib/commands.js";
9
- import { HEADER_CELL_DENSE as pr, HEADER_CELL_LIST as mr, HEADER_LABEL as hr, HEADER_VALUE_LINE as gr, HEADER_VALUE_HERO as yr, HEADER_VALUE as xr } from "../lib/header-strip.js";
10
- import { loadErrorText as Pe } from "../lib/load-error.js";
11
- import { affixesFor as oe, formatWidgetValue as ce } from "../lib/widget-value-format.js";
12
- import { BackgroundRunOffer as wr } from "./BackgroundRunOffer.js";
13
- import { cacheStampTip as br, CacheStamp as vr } from "./CacheStamp.js";
14
- import { useStagedRelations as _r } from "./item-edit/O2MStagingContext.js";
15
- import { LoadErrorNote as We } from "./LoadErrorNote.js";
16
- import { QueryTable as Nr } from "./QueryTable.js";
17
- import { CardSkeleton as ye } from "./Skeletons.js";
18
- import { Button as ae } from "./ui/button.js";
19
- import { DropdownMenu as Me, DropdownMenuTrigger as Be, DropdownMenuContent as He, DropdownMenuItem as Ve } from "./ui/dropdown-menu.js";
20
- import { reportSlotScalar as kr, ReportSlotWidget as Sr } from "./widgets/ReportSlotWidget.js";
21
- import { ReviewListWidget as Rr } from "./widgets/ReviewListWidget.js";
22
- import { RollupWidget as Lr } from "./widgets/RollupWidget.js";
23
- const X = {
24
- ArrowRight: ar,
25
- ArrowLeft: sr,
26
- ArrowUp: ir,
27
- ArrowDown: lr,
28
- ArrowUpRight: nr,
29
- ExternalLink: rr,
30
- Link: tr,
31
- Share2: er,
32
- Check: Zt,
33
- CheckCircle: Yt,
34
- X: Xt,
35
- XCircle: Gt,
36
- Plus: zt,
37
- Minus: Qt,
38
- Edit: Kt,
39
- Edit2: Jt,
40
- Trash2: Ft,
41
- Save: Vt,
42
- Download: Ht,
43
- Upload: Bt,
44
- Send: Mt,
45
- Eye: Wt,
46
- EyeOff: Pt,
47
- Lock: Ut,
48
- Unlock: At,
49
- Star: Dt,
50
- Heart: qt,
51
- Bookmark: It,
52
- Flag: Ot,
53
- AlertCircle: jt,
54
- AlertTriangle: Qe,
55
- Info: Tt,
56
- HelpCircle: Et,
57
- Play: $t,
58
- Pause: Ct,
59
- RefreshCw: ze,
60
- RotateCcw: Lt,
61
- Settings: Rt,
62
- Sliders: St,
63
- Filter: kt,
64
- Search: Nt,
65
- Power: _t,
66
- Zap: vt,
67
- Activity: bt,
68
- User: wt,
69
- Users: xt,
70
- UserPlus: yt,
71
- UserCheck: gt,
72
- Mail: ht,
73
- MessageSquare: mt,
74
- Phone: pt,
75
- Bell: ft,
76
- FileText: ut,
77
- File: dt,
78
- Folder: ct,
79
- Paperclip: ot,
80
- Calendar: at,
81
- Clock: st,
82
- Copy: it,
83
- Clipboard: lt,
84
- MoreHorizontal: nt,
85
- MoreVertical: rt
1
+ import { jsx as t, jsxs as w, Fragment as ke } from "react/jsx-runtime";
2
+ import { useQueryClient as rt, useQuery as nt } from "@tanstack/react-query";
3
+ import { AlertTriangle as Xe, RefreshCw as Ye, MoreVertical as lt, MoreHorizontal as st, Clipboard as it, Copy as at, Clock as ot, Calendar as ct, Paperclip as dt, Folder as ut, File as ft, FileText as pt, Bell as mt, Phone as ht, MessageSquare as gt, Mail as yt, UserCheck as xt, UserPlus as wt, Users as bt, User as vt, Activity as _t, Zap as Nt, Power as kt, Search as St, Filter as Rt, Sliders as Lt, Settings as Ct, RotateCcw as $t, Pause as Et, Play as Tt, HelpCircle as qt, Info as jt, AlertCircle as Ot, Flag as It, Bookmark as Dt, Heart as At, Star as Wt, Unlock as Ut, Lock as Pt, EyeOff as Mt, Eye as Bt, Send as Ht, Upload as Vt, Download as Ft, Save as Jt, Trash2 as Kt, Edit2 as Qt, Edit as zt, Minus as Gt, Plus as Xt, XCircle as Yt, X as Zt, CheckCircle as er, Check as tr, Share2 as rr, Link as nr, ExternalLink as lr, ArrowUpRight as sr, ArrowDown as ir, ArrowUp as ar, ArrowLeft as or, ArrowRight as cr } from "lucide-react";
4
+ import { useState as M, useRef as re, useCallback as Ue, useEffect as te, useMemo as Pe } from "react";
5
+ import { useApiFetchConfig as Se, useDrilldown as dr, useOptionalNivaroClient as ur } from "../context.js";
6
+ import { useDebounced as fr } from "../hooks/useDebounced.js";
7
+ import { PRETEND_DOWN_EVENT as Me } from "../lib/client-chaos.js";
8
+ import { get as pr, post as mr } from "../lib/commands.js";
9
+ import { HEADER_CELL_DENSE as hr, HEADER_CELL_LIST as gr, HEADER_LABEL as yr, HEADER_VALUE_LINE as xr, HEADER_VALUE_HERO as wr, HEADER_VALUE as br } from "../lib/header-strip.js";
10
+ import { loadErrorText as Be } from "../lib/load-error.js";
11
+ import { affixesFor as de, formatWidgetValue as ue } from "../lib/widget-value-format.js";
12
+ import { BackgroundRunOffer as vr } from "./BackgroundRunOffer.js";
13
+ import { cacheStampTip as _r, CacheStamp as Nr } from "./CacheStamp.js";
14
+ import { useStagedRelations as kr } from "./item-edit/O2MStagingContext.js";
15
+ import { LoadErrorNote as He } from "./LoadErrorNote.js";
16
+ import { QueryTable as Sr } from "./QueryTable.js";
17
+ import { CardSkeleton as we } from "./Skeletons.js";
18
+ import { Button as ce } from "./ui/button.js";
19
+ import { DropdownMenu as Ve, DropdownMenuTrigger as Fe, DropdownMenuContent as Je, DropdownMenuItem as Ke } from "./ui/dropdown-menu.js";
20
+ import { reportSlotScalar as Rr, ReportSlotWidget as Lr } from "./widgets/ReportSlotWidget.js";
21
+ import { ReviewListWidget as Cr } from "./widgets/ReviewListWidget.js";
22
+ import { RollupWidget as $r } from "./widgets/RollupWidget.js";
23
+ const Y = {
24
+ ArrowRight: cr,
25
+ ArrowLeft: or,
26
+ ArrowUp: ar,
27
+ ArrowDown: ir,
28
+ ArrowUpRight: sr,
29
+ ExternalLink: lr,
30
+ Link: nr,
31
+ Share2: rr,
32
+ Check: tr,
33
+ CheckCircle: er,
34
+ X: Zt,
35
+ XCircle: Yt,
36
+ Plus: Xt,
37
+ Minus: Gt,
38
+ Edit: zt,
39
+ Edit2: Qt,
40
+ Trash2: Kt,
41
+ Save: Jt,
42
+ Download: Ft,
43
+ Upload: Vt,
44
+ Send: Ht,
45
+ Eye: Bt,
46
+ EyeOff: Mt,
47
+ Lock: Pt,
48
+ Unlock: Ut,
49
+ Star: Wt,
50
+ Heart: At,
51
+ Bookmark: Dt,
52
+ Flag: It,
53
+ AlertCircle: Ot,
54
+ AlertTriangle: Xe,
55
+ Info: jt,
56
+ HelpCircle: qt,
57
+ Play: Tt,
58
+ Pause: Et,
59
+ RefreshCw: Ye,
60
+ RotateCcw: $t,
61
+ Settings: Ct,
62
+ Sliders: Lt,
63
+ Filter: Rt,
64
+ Search: St,
65
+ Power: kt,
66
+ Zap: Nt,
67
+ Activity: _t,
68
+ User: vt,
69
+ Users: bt,
70
+ UserPlus: wt,
71
+ UserCheck: xt,
72
+ Mail: yt,
73
+ MessageSquare: gt,
74
+ Phone: ht,
75
+ Bell: mt,
76
+ FileText: pt,
77
+ File: ft,
78
+ Folder: ut,
79
+ Paperclip: dt,
80
+ Calendar: ct,
81
+ Clock: ot,
82
+ Copy: at,
83
+ Clipboard: it,
84
+ MoreHorizontal: st,
85
+ MoreVertical: lt
86
86
  };
87
- function ke({ awaiting: n, dark: a }) {
88
- return /* @__PURE__ */ x(
87
+ function Re({ awaiting: n, dark: a }) {
88
+ return /* @__PURE__ */ w(
89
89
  "span",
90
90
  {
91
91
  className: `text-[12px] font-normal italic ${a ? "text-slate-400" : "text-slate-400 dark:text-slate-500"}`,
@@ -98,36 +98,36 @@ function ke({ awaiting: n, dark: a }) {
98
98
  }
99
99
  );
100
100
  }
101
- function xe({
101
+ function be({
102
102
  label: n,
103
103
  value: a,
104
104
  display: o,
105
- loading: i,
105
+ loading: s,
106
106
  awaiting: d
107
107
  }) {
108
- const { prefix: m, suffix: _ } = oe(a, o), v = i ? null : ce(a, o.format ?? "");
108
+ const { prefix: g, suffix: v } = de(a, o), b = s ? null : ue(a, o.format ?? "");
109
109
  return (
110
110
  // Same label / value vocabulary as a field tile in the record sub-header
111
111
  // (lib/header-strip.ts) — the two kinds of cell read as one row.
112
- /* @__PURE__ */ x(
112
+ /* @__PURE__ */ w(
113
113
  "div",
114
114
  {
115
- className: `flex h-full min-w-0 flex-col justify-start gap-1 px-4 pt-[9px] pb-2 ${pr} ${mr}`,
115
+ className: `flex h-full min-w-0 flex-col justify-start gap-1 px-4 pt-[9px] pb-2 ${hr} ${gr}`,
116
116
  children: [
117
- /* @__PURE__ */ t("span", { className: hr, "data-header-label": !0, children: n }),
117
+ /* @__PURE__ */ t("span", { className: yr, "data-header-label": !0, children: n }),
118
118
  /* @__PURE__ */ t(
119
119
  "span",
120
120
  {
121
121
  "data-header-value": !0,
122
- className: `${gr} max-w-[232px] items-baseline truncate leading-tight`,
123
- children: i ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : d && a == null ? /* @__PURE__ */ t(ke, { awaiting: d }) : /* @__PURE__ */ x(
122
+ className: `${xr} max-w-[232px] items-baseline truncate leading-tight`,
123
+ children: s ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : d && a == null ? /* @__PURE__ */ t(Re, { awaiting: d }) : /* @__PURE__ */ w(
124
124
  "span",
125
125
  {
126
- className: String(o.format ?? "").startsWith("currency") || /^[$€£¥]/.test(m) ? yr : xr,
126
+ className: String(o.format ?? "").startsWith("currency") || /^[$€£¥]/.test(g) ? wr : br,
127
127
  children: [
128
- m,
129
- v,
130
- _
128
+ g,
129
+ b,
130
+ v
131
131
  ]
132
132
  }
133
133
  )
@@ -138,22 +138,22 @@ function xe({
138
138
  )
139
139
  );
140
140
  }
141
- function Cr({
141
+ function Er({
142
142
  data: n,
143
143
  label: a,
144
144
  loading: o,
145
- widgetConfig: i,
145
+ widgetConfig: s,
146
146
  awaiting: d
147
147
  }) {
148
- const m = "h-full flex items-stretch divide-x divide-slate-200 dark:divide-border [[data-header-list]_&]:w-full [[data-header-list]_&]:flex-col [[data-header-list]_&]:divide-x-0";
148
+ const g = "h-full flex items-stretch divide-x divide-slate-200 dark:divide-border [[data-header-list]_&]:w-full [[data-header-list]_&]:flex-col [[data-header-list]_&]:divide-x-0";
149
149
  if (n && "values" in n) {
150
- const v = n.values ?? [];
151
- return v.length === 0 ? null : /* @__PURE__ */ t("div", { className: m, children: v.map((N, R) => /* @__PURE__ */ t(
152
- xe,
150
+ const b = n.values ?? [];
151
+ return b.length === 0 ? null : /* @__PURE__ */ t("div", { className: g, children: b.map((_, R) => /* @__PURE__ */ t(
152
+ be,
153
153
  {
154
- label: N.label,
155
- value: N.value,
156
- display: N.display ?? {},
154
+ label: _.label,
155
+ value: _.value,
156
+ display: _.display ?? {},
157
157
  loading: !1,
158
158
  awaiting: d
159
159
  },
@@ -161,9 +161,9 @@ function Cr({
161
161
  )) });
162
162
  }
163
163
  if (o) {
164
- const v = (i == null ? void 0 : i.value_fields) ?? [], N = v.length > 0 ? v : [{ label: a }];
165
- return /* @__PURE__ */ t("div", { className: m, children: N.map((R, C) => /* @__PURE__ */ t(
166
- xe,
164
+ const b = (s == null ? void 0 : s.value_fields) ?? [], _ = b.length > 0 ? b : [{ label: a }];
165
+ return /* @__PURE__ */ t("div", { className: g, children: _.map((R, C) => /* @__PURE__ */ t(
166
+ be,
167
167
  {
168
168
  label: R.label ?? a,
169
169
  display: { prefix: R.prefix ?? "", suffix: R.suffix ?? "", format: R.format ?? "" },
@@ -173,237 +173,237 @@ function Cr({
173
173
  )) });
174
174
  }
175
175
  if (!n) return null;
176
- const _ = n.display ?? {};
177
- return /* @__PURE__ */ t("div", { className: m, children: /* @__PURE__ */ t(
178
- xe,
176
+ const v = n.display ?? {};
177
+ return /* @__PURE__ */ t("div", { className: g, children: /* @__PURE__ */ t(
178
+ be,
179
179
  {
180
180
  label: a,
181
181
  value: n.value,
182
- display: _,
182
+ display: v,
183
183
  loading: !1,
184
184
  awaiting: d
185
185
  }
186
186
  ) });
187
187
  }
188
- function $r(n, a) {
188
+ function Tr(n, a) {
189
189
  if (Object.hasOwn(n, a)) return n[a] ?? null;
190
190
  const o = a.split(".");
191
- let i = n;
191
+ let s = n;
192
192
  for (const d of o) {
193
- if (i == null || typeof i != "object") return i ?? null;
194
- i = i[d];
193
+ if (s == null || typeof s != "object") return s ?? null;
194
+ s = s[d];
195
195
  }
196
- return i ?? null;
196
+ return s ?? null;
197
197
  }
198
- function Er(n, a) {
198
+ function qr(n, a) {
199
199
  const o = {};
200
- for (const i of n)
201
- if (i.binding_type === "item_field")
202
- o[i.key] = $r(a, i.binding_value);
203
- else if (i.binding_type === "static")
204
- o[i.key] = i.binding_value;
205
- else if (i.binding_type === "url_param" && typeof window < "u") {
200
+ for (const s of n)
201
+ if (s.binding_type === "item_field")
202
+ o[s.key] = Tr(a, s.binding_value);
203
+ else if (s.binding_type === "static")
204
+ o[s.key] = s.binding_value;
205
+ else if (s.binding_type === "url_param" && typeof window < "u") {
206
206
  const d = new URLSearchParams(window.location.search);
207
- o[i.key] = d.get(i.binding_value) ?? null;
207
+ o[s.key] = d.get(s.binding_value) ?? null;
208
208
  }
209
209
  return o;
210
210
  }
211
- function we({
211
+ function ve({
212
212
  data: n,
213
213
  awaiting: a
214
214
  }) {
215
- if (a && n.value == null) return /* @__PURE__ */ t(ke, { awaiting: a });
216
- const o = n.display ?? {}, { prefix: i, suffix: d } = oe(n.value, o), m = ce(n.value, o.format ?? "");
217
- return /* @__PURE__ */ x("div", { className: "flex items-baseline gap-1", children: [
218
- i && /* @__PURE__ */ t("span", { className: "text-[13px] text-slate-500", children: i }),
219
- /* @__PURE__ */ t("span", { className: "text-2xl font-semibold text-slate-900 dark:text-slate-100", children: m }),
215
+ if (a && n.value == null) return /* @__PURE__ */ t(Re, { awaiting: a });
216
+ const o = n.display ?? {}, { prefix: s, suffix: d } = de(n.value, o), g = ue(n.value, o.format ?? "");
217
+ return /* @__PURE__ */ w("div", { className: "flex items-baseline gap-1", children: [
218
+ s && /* @__PURE__ */ t("span", { className: "text-[13px] text-slate-500", children: s }),
219
+ /* @__PURE__ */ t("span", { className: "text-2xl font-semibold text-slate-900 dark:text-slate-100", children: g }),
220
220
  d && /* @__PURE__ */ t("span", { className: "text-[13px] text-slate-500", children: d })
221
221
  ] });
222
222
  }
223
- function be({
223
+ function _e({
224
224
  label: n,
225
225
  value: a,
226
226
  display: o,
227
- dark: i,
227
+ dark: s,
228
228
  loading: d,
229
- awaiting: m
229
+ awaiting: g
230
230
  }) {
231
- const { prefix: _, suffix: v } = oe(a, o), N = d ? null : ce(a, o.format ?? "");
232
- return /* @__PURE__ */ x("div", { className: "flex flex-col justify-center px-2.5 py-1 min-w-0 gap-0.5", children: [
231
+ const { prefix: v, suffix: b } = de(a, o), _ = d ? null : ue(a, o.format ?? "");
232
+ return /* @__PURE__ */ w("div", { className: "flex flex-col justify-center px-2.5 py-1 min-w-0 gap-0.5", children: [
233
233
  /* @__PURE__ */ t(
234
234
  "span",
235
235
  {
236
- className: `text-[9px] font-medium uppercase tracking-wider leading-none truncate ${i ? "text-slate-500" : "text-slate-400"}`,
236
+ className: `text-[9px] font-medium uppercase tracking-wider leading-none truncate ${s ? "text-slate-500" : "text-slate-400"}`,
237
237
  children: n
238
238
  }
239
239
  ),
240
240
  /* @__PURE__ */ t(
241
241
  "span",
242
242
  {
243
- className: `flex items-baseline gap-0.5 text-[13px] font-semibold tabular-nums leading-none ${i ? "text-slate-100" : "text-slate-900"}`,
243
+ className: `flex items-baseline gap-0.5 text-[13px] font-semibold tabular-nums leading-none ${s ? "text-slate-100" : "text-slate-900"}`,
244
244
  children: d ? /* @__PURE__ */ t(
245
245
  "span",
246
246
  {
247
- className: `animate-pulse inline-block h-3 w-14 rounded ${i ? "bg-slate-600" : "bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]"}`
247
+ className: `animate-pulse inline-block h-3 w-14 rounded ${s ? "bg-slate-600" : "bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]"}`
248
248
  }
249
- ) : m && a == null ? /* @__PURE__ */ t(ke, { awaiting: m, dark: i }) : /* @__PURE__ */ x(_e, { children: [
250
- _ && /* @__PURE__ */ t("span", { className: `text-[10px] ${i ? "text-slate-400" : "text-slate-500"}`, children: _ }),
251
- N,
252
- v && /* @__PURE__ */ t("span", { className: `text-[10px] ${i ? "text-slate-400" : "text-slate-500"}`, children: v })
249
+ ) : g && a == null ? /* @__PURE__ */ t(Re, { awaiting: g, dark: s }) : /* @__PURE__ */ w(ke, { children: [
250
+ v && /* @__PURE__ */ t("span", { className: `text-[10px] ${s ? "text-slate-400" : "text-slate-500"}`, children: v }),
251
+ _,
252
+ b && /* @__PURE__ */ t("span", { className: `text-[10px] ${s ? "text-slate-400" : "text-slate-500"}`, children: b })
253
253
  ] })
254
254
  }
255
255
  )
256
256
  ] });
257
257
  }
258
- function Tr({
258
+ function jr({
259
259
  data: n,
260
260
  label: a,
261
261
  style: o,
262
- loading: i,
262
+ loading: s,
263
263
  widgetConfig: d,
264
- awaiting: m
264
+ awaiting: g
265
265
  }) {
266
- const _ = o === "pill-dark", v = _ ? "flex items-stretch divide-x divide-slate-700 rounded-md bg-slate-800/90 border border-slate-700 overflow-hidden" : "flex items-stretch divide-x divide-slate-200 rounded-md bg-white border border-slate-200 overflow-hidden dark:bg-card dark:border-border dark:divide-border";
266
+ const v = o === "pill-dark", b = v ? "flex items-stretch divide-x divide-slate-700 rounded-md bg-slate-800/90 border border-slate-700 overflow-hidden" : "flex items-stretch divide-x divide-slate-200 rounded-md bg-white border border-slate-200 overflow-hidden dark:bg-card dark:border-border dark:divide-border";
267
267
  if (n && "values" in n) {
268
268
  const R = n.values ?? [];
269
- return R.length === 0 ? null : /* @__PURE__ */ t("div", { className: v, children: R.map((C, S) => /* @__PURE__ */ t(
270
- be,
269
+ return R.length === 0 ? null : /* @__PURE__ */ t("div", { className: b, children: R.map((C, S) => /* @__PURE__ */ t(
270
+ _e,
271
271
  {
272
272
  label: C.label,
273
273
  value: C.value,
274
274
  display: C.display ?? {},
275
- dark: _,
275
+ dark: v,
276
276
  loading: !1,
277
- awaiting: m
277
+ awaiting: g
278
278
  },
279
279
  S
280
280
  )) });
281
281
  }
282
- if (i) {
282
+ if (s) {
283
283
  const R = (d == null ? void 0 : d.value_fields) ?? [], C = R.length > 0 ? R : [{ label: a }];
284
- return /* @__PURE__ */ t("div", { className: v, children: C.map((S, A) => /* @__PURE__ */ t(
285
- be,
284
+ return /* @__PURE__ */ t("div", { className: b, children: C.map((S, U) => /* @__PURE__ */ t(
285
+ _e,
286
286
  {
287
287
  label: S.label ?? a,
288
288
  display: { prefix: S.prefix ?? "", suffix: S.suffix ?? "", format: S.format ?? "" },
289
- dark: _,
289
+ dark: v,
290
290
  loading: !0
291
291
  },
292
- A
292
+ U
293
293
  )) });
294
294
  }
295
295
  if (!n) return null;
296
- const N = n.display ?? {};
297
- return /* @__PURE__ */ t("div", { className: v, children: /* @__PURE__ */ t(
298
- be,
296
+ const _ = n.display ?? {};
297
+ return /* @__PURE__ */ t("div", { className: b, children: /* @__PURE__ */ t(
298
+ _e,
299
299
  {
300
300
  label: a,
301
301
  value: n.value,
302
- display: N,
303
- dark: _,
302
+ display: _,
303
+ dark: v,
304
304
  loading: !1,
305
- awaiting: m
305
+ awaiting: g
306
306
  }
307
307
  ) });
308
308
  }
309
- function Fe({ data: n }) {
309
+ function Qe({ data: n }) {
310
310
  const a = n.values ?? [];
311
311
  return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No values" }) : /* @__PURE__ */ t(
312
312
  "div",
313
313
  {
314
314
  className: "grid gap-3",
315
315
  style: { gridTemplateColumns: `repeat(${Math.min(a.length, 3)}, minmax(0, 1fr))` },
316
- children: a.map((o, i) => {
317
- var v;
318
- const { prefix: d, suffix: m } = oe(o.value, o.display), _ = ((v = o.display) == null ? void 0 : v.format) ?? "";
319
- return /* @__PURE__ */ x("div", { className: "flex flex-col gap-0.5", children: [
316
+ children: a.map((o, s) => {
317
+ var b;
318
+ const { prefix: d, suffix: g } = de(o.value, o.display), v = ((b = o.display) == null ? void 0 : b.format) ?? "";
319
+ return /* @__PURE__ */ w("div", { className: "flex flex-col gap-0.5", children: [
320
320
  o.label && /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: o.label }),
321
- /* @__PURE__ */ x("div", { className: "flex items-baseline gap-0.5", children: [
321
+ /* @__PURE__ */ w("div", { className: "flex items-baseline gap-0.5", children: [
322
322
  d && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: d }),
323
- /* @__PURE__ */ t("span", { className: "text-xl font-semibold text-slate-900 dark:text-slate-100", children: ce(o.value, _) }),
324
- m && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: m })
323
+ /* @__PURE__ */ t("span", { className: "text-xl font-semibold text-slate-900 dark:text-slate-100", children: ue(o.value, v) }),
324
+ g && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: g })
325
325
  ] })
326
- ] }, i);
326
+ ] }, s);
327
327
  })
328
328
  }
329
329
  );
330
330
  }
331
- function jr({ data: n }) {
331
+ function Or({ data: n }) {
332
332
  const a = n.rows ?? [], o = n.fields ?? [];
333
- return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No items" }) : /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ x("table", { className: "w-full text-[12px]", children: [
334
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100", children: o.map((i) => /* @__PURE__ */ t("th", { className: "py-1 pr-3 text-left font-medium text-slate-500", children: i }, i)) }) }),
335
- /* @__PURE__ */ t("tbody", { children: a.map((i, d) => /* @__PURE__ */ t("tr", { className: "border-b border-slate-50", children: o.map((m) => /* @__PURE__ */ t("td", { className: "py-1 pr-3 text-slate-700", children: String(i[m] ?? "") }, m)) }, d)) })
333
+ return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No items" }) : /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ w("table", { className: "w-full text-[12px]", children: [
334
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100", children: o.map((s) => /* @__PURE__ */ t("th", { className: "py-1 pr-3 text-left font-medium text-slate-500", children: s }, s)) }) }),
335
+ /* @__PURE__ */ t("tbody", { children: a.map((s, d) => /* @__PURE__ */ t("tr", { className: "border-b border-slate-50", children: o.map((g) => /* @__PURE__ */ t("td", { className: "py-1 pr-3 text-slate-700", children: String(s[g] ?? "") }, g)) }, d)) })
336
336
  ] }) });
337
337
  }
338
- function Je({
338
+ function ze({
339
339
  data: n,
340
340
  widgetId: a,
341
341
  inputs: o,
342
- apiBase: i,
342
+ apiBase: s,
343
343
  onAction: d
344
344
  }) {
345
- const m = n.buttons ?? [], [_, v] = P(null), N = Ne(), R = async (C) => {
346
- v(C);
345
+ const g = n.buttons ?? [], [v, b] = M(null), _ = Se(), R = async (C) => {
346
+ b(C);
347
347
  try {
348
- const S = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", E = (await (await fetch(`${i}/widgets-internal/${a}/action`, {
348
+ const S = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", $ = (await (await fetch(`${s}/widgets-internal/${a}/action`, {
349
349
  method: "POST",
350
350
  headers: {
351
351
  "Content-Type": "application/json",
352
- ...N.authHeaders,
352
+ ..._.authHeaders,
353
353
  ...S ? { "x-workspace": S } : {}
354
354
  },
355
- credentials: N.credentials,
355
+ credentials: _.credentials,
356
356
  body: JSON.stringify({ button_index: C, inputs: o })
357
357
  })).json()).data;
358
- if (E != null && E.redirect_url)
358
+ if ($ != null && $.redirect_url)
359
359
  try {
360
- const T = new URL(E.redirect_url, window.location.origin);
361
- T.origin === window.location.origin && (window.location.href = T.toString());
360
+ const E = new URL($.redirect_url, window.location.origin);
361
+ E.origin === window.location.origin && (window.location.href = E.toString());
362
362
  } catch {
363
363
  }
364
- d == null || d(E);
364
+ d == null || d($);
365
365
  } finally {
366
- v(null);
366
+ b(null);
367
367
  }
368
368
  };
369
- return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: m.map((C, S) => {
370
- const A = C.style ?? "secondary", D = "inline-flex items-center gap-1.5 rounded px-3 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50", E = A === "primary" ? `${D} bg-nvr-cyan text-white hover:bg-nvr-cyan/90` : A === "danger" ? `${D} bg-red-500 text-white hover:bg-red-600` : `${D} border border-slate-200 bg-white text-slate-700 hover:bg-slate-50`;
369
+ return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: g.map((C, S) => {
370
+ const U = C.style ?? "secondary", A = "inline-flex items-center gap-1.5 rounded px-3 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50", $ = U === "primary" ? `${A} bg-nvr-cyan text-white hover:bg-nvr-cyan/90` : U === "danger" ? `${A} bg-red-500 text-white hover:bg-red-600` : `${A} border border-slate-200 bg-white text-slate-700 hover:bg-slate-50`;
371
371
  return /* @__PURE__ */ t(
372
372
  "button",
373
373
  {
374
374
  type: "button",
375
- className: E,
376
- disabled: _ !== null,
375
+ className: $,
376
+ disabled: v !== null,
377
377
  onClick: () => R(S),
378
- children: _ === S ? "…" : String(C.label ?? `Action ${S + 1}`)
378
+ children: v === S ? "…" : String(C.label ?? `Action ${S + 1}`)
379
379
  },
380
380
  S
381
381
  );
382
382
  }) });
383
383
  }
384
- const Or = /* @__PURE__ */ new Set(["navigate", "field-update", "flow", "toggle"]);
385
- function ve({
384
+ const Ir = /* @__PURE__ */ new Set(["navigate", "field-update", "flow", "toggle"]);
385
+ function Ne({
386
386
  buttons: n,
387
387
  layout: a,
388
388
  widgetId: o,
389
- inputs: i,
389
+ inputs: s,
390
390
  apiBase: d,
391
- onClientAction: m
391
+ onClientAction: g
392
392
  }) {
393
- const [_, v] = P(null), [N, R] = P(null), [C, S] = P({}), A = te(null), D = Ne();
394
- function E(e) {
393
+ const [v, b] = M(null), [_, R] = M(null), [C, S] = M({}), U = re(null), A = Se();
394
+ function $(e) {
395
395
  return e === !0 || e === 1 ? "1" : e === !1 || e === 0 ? "0" : String(e ?? "");
396
396
  }
397
- function T(e, f) {
397
+ function E(e, f) {
398
398
  const u = e.id ?? String(f);
399
- return C[u] !== void 0 ? C[u] : e.is_on !== void 0 ? e.is_on : E(i[e.toggle_input ?? ""]) === E(e.toggle_on_value ?? "1");
399
+ return C[u] !== void 0 ? C[u] : e.is_on !== void 0 ? e.is_on : $(s[e.toggle_input ?? ""]) === $(e.toggle_on_value ?? "1");
400
400
  }
401
- function Y(e, f) {
401
+ function Z(e, f) {
402
402
  if (e.action !== "toggle") return e.label ?? `Action ${f + 1}`;
403
- const u = e.action_config, p = e.toggle_input || (u == null ? void 0 : u.toggle_input) || (u == null ? void 0 : u.field) || "", j = p && p !== e.toggle_input ? { ...e, toggle_input: p } : e;
404
- return T(j, f) ? e.label_on || e.label || `Action ${f + 1}` : e.label_off || e.label || `Action ${f + 1}`;
403
+ const u = e.action_config, p = e.toggle_input || (u == null ? void 0 : u.toggle_input) || (u == null ? void 0 : u.field) || "", T = p && p !== e.toggle_input ? { ...e, toggle_input: p } : e;
404
+ return E(T, f) ? e.label_on || e.label || `Action ${f + 1}` : e.label_off || e.label || `Action ${f + 1}`;
405
405
  }
406
- function de(e) {
406
+ function fe(e) {
407
407
  try {
408
408
  if (e.startsWith("/") && !e.startsWith("//")) return e;
409
409
  const f = new URL(e, window.location.origin);
@@ -416,38 +416,38 @@ function ve({
416
416
  const u = e.id ?? String(f);
417
417
  R(u);
418
418
  try {
419
- const p = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", g = (await (await fetch(`${d}/widgets-internal/${o}/action`, {
419
+ const p = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", x = (await (await fetch(`${d}/widgets-internal/${o}/action`, {
420
420
  method: "POST",
421
421
  headers: {
422
422
  "Content-Type": "application/json",
423
- ...D.authHeaders,
423
+ ...A.authHeaders,
424
424
  ...p ? { "x-workspace": p } : {}
425
425
  },
426
- credentials: D.credentials,
427
- body: JSON.stringify({ button_index: f, inputs: i })
426
+ credentials: A.credentials,
427
+ body: JSON.stringify({ button_index: f, inputs: s })
428
428
  })).json()).data;
429
- if (g != null && g.redirect_url)
429
+ if (x != null && x.redirect_url)
430
430
  try {
431
- const k = new URL(g.redirect_url, window.location.origin);
432
- k.origin === window.location.origin && (window.location.href = k.toString());
431
+ const N = new URL(x.redirect_url, window.location.origin);
432
+ N.origin === window.location.origin && (window.location.href = N.toString());
433
433
  } catch {
434
434
  }
435
435
  } finally {
436
436
  R(null);
437
437
  }
438
438
  }
439
- function z(e, f) {
439
+ function G(e, f) {
440
440
  const u = e.action ?? "open-url";
441
- if (Or.has(u)) {
441
+ if (Ir.has(u)) {
442
442
  if (u === "toggle") {
443
443
  const p = e.id ?? String(f);
444
- S((j) => ({ ...j, [p]: !T(e, f) }));
444
+ S((T) => ({ ...T, [p]: !E(e, f) }));
445
445
  }
446
446
  r(e, f);
447
447
  return;
448
448
  }
449
449
  if (u === "open-url" && e.url) {
450
- const p = de(e.url);
450
+ const p = fe(e.url);
451
451
  if (!p) return;
452
452
  e.new_tab ? window.open(p, "_blank", "noopener,noreferrer") : window.location.href = p;
453
453
  } else if (u === "email") {
@@ -456,46 +456,46 @@ function ve({
456
456
  } else if (u === "copy") {
457
457
  const p = e.copy_value ?? "";
458
458
  navigator.clipboard.writeText(p).then(() => {
459
- v(e.id ?? String(f)), A.current && clearTimeout(A.current), A.current = setTimeout(() => v(null), 1800);
459
+ b(e.id ?? String(f)), U.current && clearTimeout(U.current), U.current = setTimeout(() => b(null), 1800);
460
460
  });
461
- } else u === "open-sidebar" && e.sidebar_collection && e.sidebar_id && (m == null || m({
461
+ } else u === "open-sidebar" && e.sidebar_collection && e.sidebar_id && (g == null || g({
462
462
  type: "open-sidebar",
463
463
  collection: e.sidebar_collection,
464
464
  itemId: e.sidebar_id
465
465
  }));
466
466
  }
467
- function s(e) {
467
+ function i(e) {
468
468
  const f = e.replace("#", "");
469
469
  if (f.length < 6) return !0;
470
- const u = parseInt(f.slice(0, 2), 16), p = parseInt(f.slice(2, 4), 16), j = parseInt(f.slice(4, 6), 16);
471
- return (u * 299 + p * 587 + j * 114) / 1e3 > 128;
470
+ const u = parseInt(f.slice(0, 2), 16), p = parseInt(f.slice(2, 4), 16), T = parseInt(f.slice(4, 6), 16);
471
+ return (u * 299 + p * 587 + T * 114) / 1e3 > 128;
472
472
  }
473
- function re(e, f, u) {
474
- const p = e.id ?? String(f), j = _ === p, U = N === p;
475
- let g = e.label ?? "Button", k = e.variant ?? "secondary";
476
- const W = e.action_config, I = e.toggle_input || (W == null ? void 0 : W.toggle_input) || (W == null ? void 0 : W.field) || "";
473
+ function ne(e, f, u) {
474
+ const p = e.id ?? String(f), T = v === p, P = _ === p;
475
+ let x = e.label ?? "Button", N = e.variant ?? "secondary";
476
+ const B = e.action_config, I = e.toggle_input || (B == null ? void 0 : B.toggle_input) || (B == null ? void 0 : B.field) || "";
477
477
  if (e.action === "toggle") {
478
- const O = I && I !== e.toggle_input ? { ...e, toggle_input: I } : e, V = T(O, f);
479
- g = V ? e.label_on || g : e.label_off || g, k = V ? e.variant_on ?? k : e.variant_off ?? k;
478
+ const q = I && I !== e.toggle_input ? { ...e, toggle_input: I } : e, J = E(q, f);
479
+ x = J ? e.label_on || x : e.label_off || x, N = J ? e.variant_on ?? N : e.variant_off ?? N;
480
480
  }
481
- const H = e.icon ? X[e.icon] : null, L = e.color ? {
481
+ const F = e.icon ? Y[e.icon] : null, L = e.color ? {
482
482
  backgroundColor: e.color,
483
483
  borderColor: e.color,
484
- color: s(e.color) ? "#1e293b" : "#ffffff"
484
+ color: i(e.color) ? "#1e293b" : "#ffffff"
485
485
  } : void 0;
486
- return /* @__PURE__ */ x(
487
- ae,
486
+ return /* @__PURE__ */ w(
487
+ ce,
488
488
  {
489
489
  type: "button",
490
- variant: k,
490
+ variant: N,
491
491
  size: "sm",
492
492
  className: "h-7 gap-1.5 text-[12px]",
493
493
  style: L,
494
- disabled: N !== null,
495
- onClick: () => z(e, f),
494
+ disabled: _ !== null,
495
+ onClick: () => G(e, f),
496
496
  children: [
497
- H && /* @__PURE__ */ t(H, { className: "h-3.5 w-3.5 shrink-0" }),
498
- U ? "…" : j ? "✓ Copied" : g
497
+ F && /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5 shrink-0" }),
498
+ P ? "…" : T ? "✓ Copied" : x
499
499
  ]
500
500
  },
501
501
  p
@@ -503,31 +503,31 @@ function ve({
503
503
  }
504
504
  if (n.length === 0) return null;
505
505
  if (a === "split" && n.length > 1) {
506
- const [e, ...f] = n, u = e.id ?? "0", p = N === u, j = e.action === "none" || !e.action;
507
- let U = e.label ?? "Button", g = e.variant ?? "default";
508
- const k = e.action_config, W = e.toggle_input || (k == null ? void 0 : k.toggle_input) || (k == null ? void 0 : k.field) || "";
509
- if (e.action === "toggle" && W) {
510
- const L = W !== e.toggle_input ? { ...e, toggle_input: W } : e, O = T(L, 0);
511
- U = O ? e.label_on || U : e.label_off || U, g = O ? e.variant_on ?? g : e.variant_off ?? g;
506
+ const [e, ...f] = n, u = e.id ?? "0", p = _ === u, T = e.action === "none" || !e.action;
507
+ let P = e.label ?? "Button", x = e.variant ?? "default";
508
+ const N = e.action_config, B = e.toggle_input || (N == null ? void 0 : N.toggle_input) || (N == null ? void 0 : N.field) || "";
509
+ if (e.action === "toggle" && B) {
510
+ const L = B !== e.toggle_input ? { ...e, toggle_input: B } : e, q = E(L, 0);
511
+ P = q ? e.label_on || P : e.label_off || P, x = q ? e.variant_on ?? x : e.variant_off ?? x;
512
512
  }
513
- const I = e.icon ? X[e.icon] : null, H = e.color ? {
513
+ const I = e.icon ? Y[e.icon] : null, F = e.color ? {
514
514
  backgroundColor: e.color,
515
515
  borderColor: e.color,
516
- color: s(e.color) ? "#1e293b" : "#ffffff"
516
+ color: i(e.color) ? "#1e293b" : "#ffffff"
517
517
  } : void 0;
518
- return j ? /* @__PURE__ */ t("div", { className: "flex items-center", children: /* @__PURE__ */ x(Me, { children: [
519
- /* @__PURE__ */ t(Be, { asChild: !0, children: /* @__PURE__ */ x(
520
- ae,
518
+ return T ? /* @__PURE__ */ t("div", { className: "flex items-center", children: /* @__PURE__ */ w(Ve, { children: [
519
+ /* @__PURE__ */ t(Fe, { asChild: !0, children: /* @__PURE__ */ w(
520
+ ce,
521
521
  {
522
522
  type: "button",
523
- variant: g,
523
+ variant: x,
524
524
  size: "sm",
525
525
  className: "h-7 gap-1.5 text-[12px]",
526
- style: H,
527
- disabled: N !== null,
526
+ style: F,
527
+ disabled: _ !== null,
528
528
  children: [
529
529
  I && /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 shrink-0" }),
530
- U,
530
+ P,
531
531
  /* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ t(
532
532
  "path",
533
533
  {
@@ -541,48 +541,48 @@ function ve({
541
541
  ]
542
542
  }
543
543
  ) }),
544
- /* @__PURE__ */ t(He, { align: "end", className: "min-w-[140px]", children: f.map((L, O) => /* @__PURE__ */ x(
545
- Ve,
544
+ /* @__PURE__ */ t(Je, { align: "end", className: "min-w-[140px]", children: f.map((L, q) => /* @__PURE__ */ w(
545
+ Ke,
546
546
  {
547
547
  className: "cursor-pointer text-[12px]",
548
- onSelect: () => z(L, O + 1),
548
+ onSelect: () => G(L, q + 1),
549
549
  children: [
550
- L.icon && X[L.icon] && (() => {
551
- const V = X[L.icon];
552
- return /* @__PURE__ */ t(V, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
550
+ L.icon && Y[L.icon] && (() => {
551
+ const J = Y[L.icon];
552
+ return /* @__PURE__ */ t(J, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
553
553
  })(),
554
- Y(L, O + 1)
554
+ Z(L, q + 1)
555
555
  ]
556
556
  },
557
- L.id ?? O
557
+ L.id ?? q
558
558
  )) })
559
- ] }) }) : /* @__PURE__ */ x("div", { className: "flex items-center", children: [
560
- /* @__PURE__ */ x(
561
- ae,
559
+ ] }) }) : /* @__PURE__ */ w("div", { className: "flex items-center", children: [
560
+ /* @__PURE__ */ w(
561
+ ce,
562
562
  {
563
563
  type: "button",
564
- variant: g,
564
+ variant: x,
565
565
  size: "sm",
566
566
  className: "h-7 rounded-r-none text-[12px] gap-1.5 border-r-0",
567
- style: H,
568
- disabled: N !== null,
569
- onClick: () => z(e, 0),
567
+ style: F,
568
+ disabled: _ !== null,
569
+ onClick: () => G(e, 0),
570
570
  children: [
571
571
  I && /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 shrink-0" }),
572
- p ? "…" : _ === u ? "✓ Copied" : U
572
+ p ? "…" : v === u ? "✓ Copied" : P
573
573
  ]
574
574
  }
575
575
  ),
576
- /* @__PURE__ */ x(Me, { children: [
577
- /* @__PURE__ */ t(Be, { asChild: !0, children: /* @__PURE__ */ t(
578
- ae,
576
+ /* @__PURE__ */ w(Ve, { children: [
577
+ /* @__PURE__ */ t(Fe, { asChild: !0, children: /* @__PURE__ */ t(
578
+ ce,
579
579
  {
580
580
  type: "button",
581
- variant: g,
581
+ variant: x,
582
582
  size: "sm",
583
583
  className: "h-7 rounded-l-none px-1.5 text-[12px]",
584
- style: H,
585
- disabled: N !== null,
584
+ style: F,
585
+ disabled: _ !== null,
586
586
  "aria-label": "More actions",
587
587
  children: /* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ t(
588
588
  "path",
@@ -596,320 +596,329 @@ function ve({
596
596
  ) })
597
597
  }
598
598
  ) }),
599
- /* @__PURE__ */ t(He, { align: "end", className: "min-w-[140px]", children: f.map((L, O) => /* @__PURE__ */ x(
600
- Ve,
599
+ /* @__PURE__ */ t(Je, { align: "end", className: "min-w-[140px]", children: f.map((L, q) => /* @__PURE__ */ w(
600
+ Ke,
601
601
  {
602
602
  className: "text-[12px]",
603
- onSelect: () => z(L, O + 1),
603
+ onSelect: () => G(L, q + 1),
604
604
  children: [
605
- L.icon && X[L.icon] && (() => {
606
- const V = X[L.icon];
607
- return /* @__PURE__ */ t(V, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
605
+ L.icon && Y[L.icon] && (() => {
606
+ const J = Y[L.icon];
607
+ return /* @__PURE__ */ t(J, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
608
608
  })(),
609
- Y(L, O + 1)
609
+ Z(L, q + 1)
610
610
  ]
611
611
  },
612
- L.id ?? O
612
+ L.id ?? q
613
613
  )) })
614
614
  ] })
615
615
  ] });
616
616
  }
617
- return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5", children: n.map((e, f) => re(e, f)) });
617
+ return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5", children: n.map((e, f) => ne(e, f)) });
618
618
  }
619
- function Ke(n, a) {
620
- var i;
619
+ function Ge(n, a) {
620
+ var s;
621
621
  if (a == null) return { next: n, moved: !1 };
622
- const o = ((i = a == null ? void 0 : a.instance) == null ? void 0 : i.current_state) ?? null;
622
+ const o = ((s = a == null ? void 0 : a.instance) == null ? void 0 : s.current_state) ?? null;
623
623
  return { next: o, moved: n !== void 0 && n !== o };
624
624
  }
625
- function rn({
625
+ function sn({
626
626
  widgetId: n,
627
627
  inputBindings: a = [],
628
628
  itemDraft: o = {},
629
- itemCollection: i,
629
+ itemCollection: s,
630
630
  ready: d = !0,
631
- label: m,
632
- defaultExpanded: _ = !0,
633
- frameless: v = !1,
634
- apiBase: N,
631
+ label: g,
632
+ defaultExpanded: v = !0,
633
+ frameless: b = !1,
634
+ apiBase: _,
635
635
  compact: R = !1,
636
636
  strip: C = !1,
637
637
  onClientAction: S,
638
- onWidgetType: A,
639
- onContentChange: D
638
+ onWidgetType: U,
639
+ onContentChange: A
640
640
  }) {
641
- var Ie, qe;
642
- const E = Ne(), T = N ?? E.apiBase, [Y, de] = P(_), [r, z] = P(null), [s, re] = P(null), [e, f] = P(!0), [u, p] = P(!0), [j, U] = P(!0), [g, k] = P(null), [W, I] = P(0), [H, L] = P(null), O = te(!1), V = De(() => {
643
- O.current = !0, I((l) => l + 1);
644
- }, []), F = te(null), ne = te(void 0), ue = te(!1), fe = et();
645
- ee(() => {
641
+ var De, Ae;
642
+ const $ = Se(), E = _ ?? $.apiBase, [Z, fe] = M(v), [r, G] = M(null), [i, ne] = M(null), [e, f] = M(!0), [u, p] = M(!0), [T, P] = M(!0), [x, N] = M(null), [B, I] = M(0), [F, L] = M(null), q = re(!1), J = Ue(() => {
643
+ q.current = !0, I((l) => l + 1);
644
+ }, []), K = re(null), le = re(void 0), pe = re(!1), se = rt();
645
+ te(() => {
646
+ var k;
646
647
  const l = r == null ? void 0 : r.widget_type;
647
648
  if (l !== "rollup" && l !== "review_list" && l !== "custom-query") return;
648
649
  let c = null;
649
- if (ne.current === void 0 && F.current != null) {
650
- const w = fe.getQueryCache().findAll({ queryKey: ["pipeline-instance-lock"] }).find((b) => String(b.queryKey[2]) === String(F.current));
651
- (w == null ? void 0 : w.state.status) === "success" && (ne.current = Ke(void 0, w.state.data).next);
650
+ if (le.current === void 0 && K.current != null) {
651
+ const h = se.getQueryCache().findAll({ queryKey: ["pipeline-instance-lock"] }).find((O) => String(O.queryKey[2]) === String(K.current));
652
+ (h == null ? void 0 : h.state.status) === "success" && (le.current = Ge(void 0, h.state.data).next);
653
+ }
654
+ const m = /* @__PURE__ */ new WeakMap();
655
+ for (const h of se.getQueryCache().getAll()) {
656
+ const O = (k = h.queryKey) == null ? void 0 : k[0];
657
+ typeof O != "string" || h.state.status !== "success" || (O.startsWith("o2m-rows") || O.startsWith("nested") || O === "match-agg" || O === "m2m-items") && m.set(h, h.state.data);
652
658
  }
653
- const y = fe.getQueryCache().subscribe((w) => {
654
- var G;
655
- if (w.type !== "updated" || ((G = w.action) == null ? void 0 : G.type) !== "success") return;
656
- const b = w.query.queryKey, $ = b == null ? void 0 : b[0];
657
- if (typeof $ == "string") {
658
- if ($ === "pipeline-instance-lock") {
659
- if (F.current == null || String(b[2]) !== String(F.current))
660
- return;
661
- const Q = Ke(ne.current, w.query.state.data);
662
- if (ne.current = Q.next, !Q.moved) return;
663
- c && clearTimeout(c), c = setTimeout(() => {
664
- O.current = !0, I((Ze) => Ze + 1);
665
- }, 400);
659
+ const j = se.getQueryCache().subscribe((h) => {
660
+ var We;
661
+ if (h.type !== "updated" || ((We = h.action) == null ? void 0 : We.type) !== "success") return;
662
+ const O = h.query.queryKey, W = O == null ? void 0 : O[0];
663
+ if (typeof W != "string") return;
664
+ if (W.startsWith("o2m-rows") || W.startsWith("nested") || W === "match-agg" || W === "m2m-items") {
665
+ const X = m.has(h.query), xe = m.get(h.query);
666
+ if (m.set(h.query, h.query.state.data), X && xe === h.query.state.data) return;
667
+ }
668
+ if (W === "pipeline-instance-lock") {
669
+ if (K.current == null || String(O[2]) !== String(K.current))
666
670
  return;
667
- }
668
- !$.startsWith("o2m-rows") && !$.startsWith("nested") && $ !== "match-agg" && $ !== "m2m-items" || w.query.state.dataUpdateCount <= 1 || $.startsWith("o2m-rows") && F.current != null && String(b[3]) !== String(F.current) || (c && clearTimeout(c), c = setTimeout(() => I((Q) => Q + 1), 400));
671
+ const X = Ge(le.current, h.query.state.data);
672
+ if (le.current = X.next, !X.moved) return;
673
+ c && clearTimeout(c), c = setTimeout(() => {
674
+ q.current = !0, I((xe) => xe + 1);
675
+ }, 400);
676
+ return;
669
677
  }
678
+ !W.startsWith("o2m-rows") && !W.startsWith("nested") && W !== "match-agg" && W !== "m2m-items" || h.query.state.dataUpdateCount <= 1 || W.startsWith("o2m-rows") && K.current != null && String(O[3]) !== String(K.current) || (c && clearTimeout(c), c = setTimeout(() => I((X) => X + 1), 400));
670
679
  });
671
680
  return () => {
672
- c && clearTimeout(c), y();
681
+ c && clearTimeout(c), j();
673
682
  };
674
- }, [fe, r == null ? void 0 : r.widget_type]);
675
- const Se = {};
683
+ }, [se, r == null ? void 0 : r.widget_type]);
684
+ const Le = {};
676
685
  for (const [l, c] of Object.entries(o))
677
- l.includes(".") || (c == null || typeof c != "object") && (Se[l] = c);
678
- const q = { ...Se, ...Er(a, o) }, pe = _r(), J = Ae(() => {
679
- if ((r == null ? void 0 : r.widget_type) !== "rollup" || !pe) return null;
686
+ l.includes(".") || (c == null || typeof c != "object") && (Le[l] = c);
687
+ const D = { ...Le, ...qr(a, o) }, me = kr(), Q = Pe(() => {
688
+ if ((r == null ? void 0 : r.widget_type) !== "rollup" || !me) return null;
680
689
  const l = r.config, c = l == null ? void 0 : l.collection;
681
690
  if (!c) return null;
682
- const y = {
691
+ const m = {
683
692
  created: [],
684
693
  updated: [],
685
694
  deleted: []
686
695
  };
687
- for (const w of pe.byGrid.values()) {
688
- const b = w[c];
689
- b && (y.created.push(...b.created), y.updated.push(...b.updated), y.deleted.push(...b.deleted));
696
+ for (const j of me.byGrid.values()) {
697
+ const k = j[c];
698
+ k && (m.created.push(...k.created), m.updated.push(...k.updated), m.deleted.push(...k.deleted));
690
699
  }
691
- return !y.created.length && !y.updated.length && !y.deleted.length ? null : y;
692
- }, [r, pe]), Ge = Ae(
693
- () => J ? JSON.stringify(J) : "",
694
- [J]
695
- ), h = (Ie = r == null ? void 0 : r.config) == null ? void 0 : Ie.drilldown, le = or(), me = h != null && h.id_input ? q[h.id_input] : null, he = !!le && !!(h != null && h.collection) && me != null && me !== "", Re = async () => {
696
- var w, b;
697
- if (!he || !(h != null && h.collection)) return;
698
- const l = String(me);
700
+ return !m.created.length && !m.updated.length && !m.deleted.length ? null : m;
701
+ }, [r, me]), Ze = Pe(
702
+ () => Q ? JSON.stringify(Q) : "",
703
+ [Q]
704
+ ), y = (De = r == null ? void 0 : r.config) == null ? void 0 : De.drilldown, ie = dr(), he = y != null && y.id_input ? D[y.id_input] : null, ge = !!ie && !!(y != null && y.collection) && he != null && he !== "", Ce = async () => {
705
+ var j, k;
706
+ if (!ge || !(y != null && y.collection)) return;
707
+ const l = String(he);
699
708
  let c = null;
700
- const y = ($) => fetch(`${T}${$}`, {
701
- credentials: E.credentials,
702
- headers: E.authHeaders
709
+ const m = (h) => fetch(`${E}${h}`, {
710
+ credentials: $.credentials,
711
+ headers: $.authHeaders
703
712
  });
704
713
  try {
705
- if (h.match_field) {
706
- const $ = await y(
707
- `/items/${h.collection}?filter=${encodeURIComponent(
708
- JSON.stringify({ [h.match_field]: { _eq: l } })
714
+ if (y.match_field) {
715
+ const h = await m(
716
+ `/items/${y.collection}?filter=${encodeURIComponent(
717
+ JSON.stringify({ [y.match_field]: { _eq: l } })
709
718
  )}&fields=id&limit=1`
710
719
  );
711
- if ($.ok) {
712
- const G = await $.json(), Q = (b = (w = G == null ? void 0 : G.data) == null ? void 0 : w[0]) == null ? void 0 : b.id;
713
- Q != null && (c = String(Q));
720
+ if (h.ok) {
721
+ const O = await h.json(), W = (k = (j = O == null ? void 0 : O.data) == null ? void 0 : j[0]) == null ? void 0 : k.id;
722
+ W != null && (c = String(W));
714
723
  }
715
724
  }
716
- c == null && (await y(`/items/${h.collection}/${encodeURIComponent(l)}?fields=id`)).ok && (c = l);
725
+ c == null && (await m(`/items/${y.collection}/${encodeURIComponent(l)}?fields=id`)).ok && (c = l);
717
726
  } catch {
718
727
  return;
719
728
  }
720
- c != null && (le == null || le.open({
721
- collection: h.collection,
729
+ c != null && (ie == null || ie.open({
730
+ collection: y.collection,
722
731
  itemId: c,
723
- layoutId: h.layout_id ?? null,
724
- width: h.width ?? "75%",
725
- title: h.title
732
+ layoutId: y.layout_id ?? null,
733
+ width: y.width ?? "75%",
734
+ title: y.title
726
735
  }));
727
736
  };
728
- if (q.record_id == null || q.record_id === "") {
737
+ if (D.record_id == null || D.record_id === "") {
729
738
  const l = o.id;
730
- l != null && l !== "" && (q.record_id = l);
739
+ l != null && l !== "" && (D.record_id = l);
731
740
  }
732
- F.current = o.id ?? null;
733
- const Xe = JSON.stringify(q) + (i ?? "") + Ge, Ye = dr(Xe, 400);
734
- function Le() {
741
+ K.current = o.id ?? null;
742
+ const et = JSON.stringify(D) + (s ?? "") + Ze, tt = fr(et, 400);
743
+ function $e() {
735
744
  const l = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "";
736
745
  return {
737
746
  "Content-Type": "application/json",
738
- ...E.authHeaders,
747
+ ...$.authHeaders,
739
748
  ...l ? { "x-workspace": l } : {}
740
749
  };
741
750
  }
742
- const Z = cr(), B = tt({
751
+ const ee = ur(), V = nt({
743
752
  queryKey: ["nvr-widget-def", n],
744
753
  enabled: d,
745
754
  staleTime: 6e4,
746
755
  retry: !1,
747
756
  queryFn: async () => {
748
- if (Z)
749
- return (await Z.request(ur(`/widgets-internal/${n}`))).data;
750
- const l = await fetch(`${T}/widgets-internal/${n}`, {
751
- credentials: E.credentials,
752
- headers: Le()
757
+ if (ee)
758
+ return (await ee.request(pr(`/widgets-internal/${n}`))).data;
759
+ const l = await fetch(`${E}/widgets-internal/${n}`, {
760
+ credentials: $.credentials,
761
+ headers: $e()
753
762
  });
754
763
  if (!l.ok) throw Object.assign(new Error("Widget not found"), { status: l.status });
755
764
  return (await l.json()).data;
756
765
  }
757
- }), Ce = B.refetch, ge = De(() => {
758
- k(null), B.error ? Ce() : I((l) => l + 1);
759
- }, [B.error, Ce]);
760
- ee(() => {
766
+ }), Ee = V.refetch, ye = Ue(() => {
767
+ N(null), V.error ? Ee() : I((l) => l + 1);
768
+ }, [V.error, Ee]);
769
+ te(() => {
761
770
  const l = () => I((c) => c + 1);
762
- return window.addEventListener(Ue, l), () => window.removeEventListener(Ue, l);
763
- }, []), ee(() => {
764
- d && (B.data ? (z(B.data), f(!1), k(null), A == null || A(B.data.widget_type)) : B.error && k(Pe(B.error, "this widget")));
765
- }, [d, B.data, B.error]), ee(() => {
771
+ return window.addEventListener(Me, l), () => window.removeEventListener(Me, l);
772
+ }, []), te(() => {
773
+ d && (V.data ? (G(V.data), f(!1), N(null), U == null || U(V.data.widget_type)) : V.error && N(Be(V.error, "this widget")));
774
+ }, [d, V.data, V.error]), te(() => {
766
775
  if (!d || !r) return;
767
- const l = q.record_id == null || q.record_id === "";
768
- if (r.widget_type === "review_list" && l || r.widget_type === "rollup" && l && !J) return;
776
+ const l = D.record_id == null || D.record_id === "";
777
+ if (r.widget_type === "review_list" && l || r.widget_type === "rollup" && l && !Q) return;
769
778
  let c = !1;
770
- return ue.current || (p(!0), U(!0)), (async () => {
779
+ return pe.current || (p(!0), P(!0)), (async () => {
771
780
  try {
772
- const y = {
773
- inputs: J ? { ...q, staged: J } : q,
781
+ const m = {
782
+ inputs: Q ? { ...D, staged: Q } : D,
774
783
  draft: o,
775
784
  bindings: a,
776
- item_collection: i
785
+ item_collection: s
777
786
  };
778
- O.current && (y.refresh = !0, O.current = !1), L(y);
779
- let w;
780
- if (Z)
781
- w = await Z.request(
782
- fr(`/widgets-internal/${n}/render`, y)
787
+ q.current && (m.refresh = !0, q.current = !1), L(m);
788
+ let j;
789
+ if (ee)
790
+ j = await ee.request(
791
+ mr(`/widgets-internal/${n}/render`, m)
783
792
  );
784
793
  else {
785
- const b = await fetch(`${T}/widgets-internal/${n}/render`, {
794
+ const k = await fetch(`${E}/widgets-internal/${n}/render`, {
786
795
  method: "POST",
787
- credentials: E.credentials,
788
- headers: Le(),
789
- body: JSON.stringify(y)
796
+ credentials: $.credentials,
797
+ headers: $e(),
798
+ body: JSON.stringify(m)
790
799
  });
791
- if (!b.ok)
792
- throw Object.assign(new Error("Render failed"), { status: b.status });
793
- w = await b.json();
800
+ if (!k.ok)
801
+ throw Object.assign(new Error("Render failed"), { status: k.status });
802
+ j = await k.json();
794
803
  }
795
804
  if (c) return;
796
- c || (ue.current = !0, re(w.data), p(!1), k(null));
797
- } catch (y) {
798
- c || k(Pe(y, "this widget"));
805
+ c || (pe.current = !0, ne(j.data), p(!1), N(null));
806
+ } catch (m) {
807
+ c || N(Be(m, "this widget"));
799
808
  } finally {
800
- c || U(!1);
809
+ c || P(!1);
801
810
  }
802
811
  })(), () => {
803
812
  c = !0;
804
813
  };
805
- }, [n, T, Ye, d, W, r == null ? void 0 : r.widget_type]), ee(() => {
806
- if (D) {
807
- if (g) {
808
- D(!0);
814
+ }, [n, E, tt, d, B, r == null ? void 0 : r.widget_type]), te(() => {
815
+ if (A) {
816
+ if (x) {
817
+ A(!0);
809
818
  return;
810
819
  }
811
- if (s) {
820
+ if (i) {
812
821
  if ((r == null ? void 0 : r.widget_type) === "review_list" || (r == null ? void 0 : r.widget_type) === "rollup") {
813
- const l = s.rows;
814
- D(Array.isArray(l) && l.length > 0);
822
+ const l = i.rows;
823
+ A(Array.isArray(l) && l.length > 0);
815
824
  return;
816
825
  }
817
- if ((r == null ? void 0 : r.widget_type) === "custom-query" && "rows" in s) {
818
- const l = s.rows;
819
- D(Array.isArray(l) && l.length > 0);
826
+ if ((r == null ? void 0 : r.widget_type) === "custom-query" && "rows" in i) {
827
+ const l = i.rows;
828
+ A(Array.isArray(l) && l.length > 0);
820
829
  return;
821
830
  }
822
- D(!0);
831
+ A(!0);
823
832
  }
824
833
  }
825
- }, [s, g, r == null ? void 0 : r.widget_type, D]);
826
- const K = m || (r == null ? void 0 : r.name) || "", ie = (r == null ? void 0 : r.widget_type) === "report_widget" && s ? kr(s) : s, M = (() => {
827
- const l = s == null ? void 0 : s.awaiting;
834
+ }, [i, x, r == null ? void 0 : r.widget_type, A]);
835
+ const z = g || (r == null ? void 0 : r.name) || "", ae = (r == null ? void 0 : r.widget_type) === "report_widget" && i ? Rr(i) : i, H = (() => {
836
+ const l = i == null ? void 0 : i.awaiting;
828
837
  if (!Array.isArray(l) || l.length === 0) return null;
829
- const c = l.map((y) => {
830
- const w = a.find(($) => $.key === y && $.binding_type === "item_field");
831
- return String((w == null ? void 0 : w.binding_value) ?? y).split(".")[0].replace(/_id$/, "").replace(/_/g, " ").replace(/^\w/, ($) => $.toUpperCase());
838
+ const c = l.map((m) => {
839
+ const j = a.find((h) => h.key === m && h.binding_type === "item_field");
840
+ return String((j == null ? void 0 : j.binding_value) ?? m).split(".")[0].replace(/_id$/, "").replace(/_/g, " ").replace(/^\w/, (h) => h.toUpperCase());
832
841
  });
833
842
  return [...new Set(c)].join(", ");
834
- })(), $e = q.record_id, Ee = $e == null || $e === "";
835
- if ((r == null ? void 0 : r.widget_type) === "review_list" && Ee || (r == null ? void 0 : r.widget_type) === "rollup" && Ee && !J) return null;
843
+ })(), Te = D.record_id, qe = Te == null || Te === "";
844
+ if ((r == null ? void 0 : r.widget_type) === "review_list" && qe || (r == null ? void 0 : r.widget_type) === "rollup" && qe && !Q) return null;
836
845
  if (R) {
837
- const l = ((qe = r == null ? void 0 : r.config) == null ? void 0 : qe.compact_style) ?? "default", c = l === "pill-dark" || l === "pill-light";
838
- if (g)
846
+ const l = ((Ae = r == null ? void 0 : r.config) == null ? void 0 : Ae.compact_style) ?? "default", c = l === "pill-dark" || l === "pill-light";
847
+ if (x)
839
848
  return /* @__PURE__ */ t(
840
849
  "button",
841
850
  {
842
851
  type: "button",
843
- onClick: ge,
852
+ onClick: ye,
844
853
  "data-load-error": "",
845
- "data-tip": `${g} Click to try again.`,
846
- "aria-label": `${g} Try again`,
854
+ "data-tip": `${x} Click to try again.`,
855
+ "aria-label": `${x} Try again`,
847
856
  className: "inline-flex h-5 w-5 items-center justify-center rounded text-amber-500 hover:bg-amber-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-amber-400 dark:hover:bg-amber-400/10",
848
- children: /* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
857
+ children: /* @__PURE__ */ t(Xe, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
849
858
  }
850
859
  );
851
860
  if (C) {
852
861
  if (e)
853
- return /* @__PURE__ */ x("div", { className: "flex h-full w-36 flex-col justify-center px-4 py-2.5", children: [
862
+ return /* @__PURE__ */ w("div", { className: "flex h-full w-36 flex-col justify-center px-4 py-2.5", children: [
854
863
  /* @__PURE__ */ t("span", { className: "animate-pulse h-2 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] mb-1" }),
855
864
  /* @__PURE__ */ t("span", { className: "animate-pulse h-3.5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" })
856
865
  ] });
857
866
  if (r.widget_type === "button-group")
858
- return /* @__PURE__ */ t("div", { className: "h-full flex items-center px-3", children: u ? /* @__PURE__ */ t("div", { className: "animate-pulse h-7 w-24 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : s && /* @__PURE__ */ t(
859
- ve,
867
+ return /* @__PURE__ */ t("div", { className: "h-full flex items-center px-3", children: u ? /* @__PURE__ */ t("div", { className: "animate-pulse h-7 w-24 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : i && /* @__PURE__ */ t(
868
+ Ne,
860
869
  {
861
- buttons: s.buttons ?? [],
862
- layout: s.layout ?? "flat",
870
+ buttons: i.buttons ?? [],
871
+ layout: i.layout ?? "flat",
863
872
  widgetId: n,
864
- inputs: q,
865
- apiBase: T,
873
+ inputs: D,
874
+ apiBase: E,
866
875
  onClientAction: S
867
876
  }
868
877
  ) });
869
878
  {
870
- const y = /* @__PURE__ */ t(
871
- Cr,
879
+ const m = /* @__PURE__ */ t(
880
+ Er,
872
881
  {
873
- data: u ? null : ie ?? null,
874
- label: m || r.name,
882
+ data: u ? null : ae ?? null,
883
+ label: g || r.name,
875
884
  loading: u,
876
885
  widgetConfig: r.config,
877
- awaiting: M
886
+ awaiting: H
878
887
  }
879
- ), w = he ? /* @__PURE__ */ t(
888
+ ), j = ge ? /* @__PURE__ */ t(
880
889
  "button",
881
890
  {
882
891
  type: "button",
883
- onClick: () => void Re(),
884
- title: (h == null ? void 0 : h.title) ?? "Open details",
892
+ onClick: () => void Ce(),
893
+ title: (y == null ? void 0 : y.title) ?? "Open details",
885
894
  className: "h-full w-full cursor-pointer text-left transition-colors hover:bg-nvr-cyan/5",
886
- "data-nvr-widget-drill": h == null ? void 0 : h.collection,
887
- children: y
895
+ "data-nvr-widget-drill": y == null ? void 0 : y.collection,
896
+ children: m
888
897
  }
889
- ) : y, b = s == null ? void 0 : s.cache;
890
- return b != null && b.cache_ttl ? /* @__PURE__ */ x(
898
+ ) : m, k = i == null ? void 0 : i.cache;
899
+ return k != null && k.cache_ttl ? /* @__PURE__ */ w(
891
900
  "div",
892
901
  {
893
902
  className: "group/cache relative h-full w-full",
894
- "data-cache-stamp": b.cached ? "cached" : "fresh",
903
+ "data-cache-stamp": k.cached ? "cached" : "fresh",
895
904
  children: [
896
- w,
905
+ j,
897
906
  /* @__PURE__ */ t(
898
907
  "button",
899
908
  {
900
909
  type: "button",
901
- onClick: V,
910
+ onClick: J,
902
911
  disabled: u,
903
912
  "data-cache-refresh": !0,
904
913
  "aria-label": "Refresh this figure",
905
- "data-tip": br(b),
914
+ "data-tip": _r(k),
906
915
  className: "absolute bottom-1 right-1 rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:bg-muted group-hover/cache:opacity-100 focus-visible:opacity-100 disabled:opacity-50",
907
- children: /* @__PURE__ */ t(ze, { className: `h-3 w-3 ${u ? "animate-spin" : ""}` })
916
+ children: /* @__PURE__ */ t(Ye, { className: `h-3 w-3 ${u ? "animate-spin" : ""}` })
908
917
  }
909
918
  )
910
919
  ]
911
920
  }
912
- ) : w;
921
+ ) : j;
913
922
  }
914
923
  }
915
924
  if (c) {
@@ -921,174 +930,174 @@ function rn({
921
930
  }
922
931
  );
923
932
  {
924
- const y = /* @__PURE__ */ t(
925
- Tr,
933
+ const m = /* @__PURE__ */ t(
934
+ jr,
926
935
  {
927
- data: u ? null : ie ?? null,
928
- label: m || r.name,
936
+ data: u ? null : ae ?? null,
937
+ label: g || r.name,
929
938
  style: l,
930
939
  loading: u,
931
940
  widgetConfig: r.config,
932
- awaiting: M
941
+ awaiting: H
933
942
  }
934
943
  );
935
- return he ? /* @__PURE__ */ t(
944
+ return ge ? /* @__PURE__ */ t(
936
945
  "button",
937
946
  {
938
947
  type: "button",
939
- onClick: () => void Re(),
940
- title: (h == null ? void 0 : h.title) ?? "Open details",
948
+ onClick: () => void Ce(),
949
+ title: (y == null ? void 0 : y.title) ?? "Open details",
941
950
  className: "cursor-pointer text-left",
942
- "data-nvr-widget-drill": h == null ? void 0 : h.collection,
943
- children: y
951
+ "data-nvr-widget-drill": y == null ? void 0 : y.collection,
952
+ children: m
944
953
  }
945
- ) : y;
954
+ ) : m;
946
955
  }
947
956
  }
948
- return e ? /* @__PURE__ */ t("div", { className: "animate-pulse h-4 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5", children: u ? /* @__PURE__ */ t("div", { className: "flex items-baseline gap-1", children: /* @__PURE__ */ t("div", { className: "animate-pulse h-5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) }) : s && r && /* @__PURE__ */ x(_e, { children: [
949
- (r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in s) && /* @__PURE__ */ t(we, { data: s, awaiting: M }),
950
- r.widget_type === "report_widget" && ie && /* @__PURE__ */ t(we, { data: ie, awaiting: M }),
951
- r.widget_type === "custom-query" && "values" in s && /* @__PURE__ */ t(Fe, { data: s }),
957
+ return e ? /* @__PURE__ */ t("div", { className: "animate-pulse h-4 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5", children: u ? /* @__PURE__ */ t("div", { className: "flex items-baseline gap-1", children: /* @__PURE__ */ t("div", { className: "animate-pulse h-5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) }) : i && r && /* @__PURE__ */ w(ke, { children: [
958
+ (r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in i) && /* @__PURE__ */ t(ve, { data: i, awaiting: H }),
959
+ r.widget_type === "report_widget" && ae && /* @__PURE__ */ t(ve, { data: ae, awaiting: H }),
960
+ r.widget_type === "custom-query" && "values" in i && /* @__PURE__ */ t(Qe, { data: i }),
952
961
  r.widget_type === "action-buttons" && /* @__PURE__ */ t(
953
- Je,
962
+ ze,
954
963
  {
955
- data: s,
964
+ data: i,
956
965
  widgetId: n,
957
- inputs: q,
958
- apiBase: T
966
+ inputs: D,
967
+ apiBase: E
959
968
  }
960
969
  ),
961
970
  r.widget_type === "button-group" && /* @__PURE__ */ t(
962
- ve,
971
+ Ne,
963
972
  {
964
- buttons: s.buttons ?? [],
965
- layout: s.layout ?? "flat",
973
+ buttons: i.buttons ?? [],
974
+ layout: i.layout ?? "flat",
966
975
  widgetId: n,
967
- inputs: q,
968
- apiBase: T,
976
+ inputs: D,
977
+ apiBase: E,
969
978
  onClientAction: S
970
979
  }
971
980
  )
972
981
  ] }) });
973
982
  }
974
- const se = r == null ? void 0 : r.widget_type, Te = se === "stat" ? /* @__PURE__ */ t(ye, { framed: !1, title: !1, kpi: !0, className: "py-0.5" }) : se === "list" || se === "review_list" || se === "custom-query" ? /* @__PURE__ */ t(ye, { framed: !1, title: !1, lines: 4, className: "py-0.5" }) : /* @__PURE__ */ t(ye, { framed: !1, title: !1, lines: 3, className: "py-0.5" }), je = Z ? /* @__PURE__ */ t(
975
- wr,
983
+ const oe = r == null ? void 0 : r.widget_type, je = oe === "stat" ? /* @__PURE__ */ t(we, { framed: !1, title: !1, kpi: !0, className: "py-0.5" }) : oe === "list" || oe === "review_list" || oe === "custom-query" ? /* @__PURE__ */ t(we, { framed: !1, title: !1, lines: 4, className: "py-0.5" }) : /* @__PURE__ */ t(we, { framed: !1, title: !1, lines: 3, className: "py-0.5" }), Oe = ee ? /* @__PURE__ */ t(
984
+ vr,
976
985
  {
977
986
  className: "mt-2",
978
987
  pending: u && !!r,
979
- request: H ? { method: "POST", url: `/widgets-internal/${n}/render`, body: H } : null,
980
- label: K || "Widget",
988
+ request: F ? { method: "POST", url: `/widgets-internal/${n}/render`, body: F } : null,
989
+ label: z || "Widget",
981
990
  onResult: (l) => {
982
991
  const c = l == null ? void 0 : l.data;
983
- c && (ue.current = !0, re(c), p(!1), U(!1), k(null));
992
+ c && (pe.current = !0, ne(c), p(!1), P(!1), N(null));
984
993
  },
985
994
  onGone: () => I((l) => l + 1)
986
995
  }
987
996
  ) : null;
988
- if (v)
989
- return /* @__PURE__ */ x("div", { children: [
990
- j && Te,
991
- j && je,
992
- g && /* @__PURE__ */ t(We, { message: g, onRetry: ge }),
993
- !j && !g && s && r && Oe()
997
+ if (b)
998
+ return /* @__PURE__ */ w("div", { children: [
999
+ T && je,
1000
+ T && Oe,
1001
+ x && /* @__PURE__ */ t(He, { message: x, onRetry: ye }),
1002
+ !T && !x && i && r && Ie()
994
1003
  ] });
995
- return /* @__PURE__ */ x("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
996
- /* @__PURE__ */ x(
1004
+ return /* @__PURE__ */ w("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
1005
+ /* @__PURE__ */ w(
997
1006
  "button",
998
1007
  {
999
1008
  type: "button",
1000
1009
  className: "flex w-full items-center justify-between px-4 py-3 text-left",
1001
- onClick: () => de((l) => !l),
1010
+ onClick: () => fe((l) => !l),
1002
1011
  children: [
1003
- /* @__PURE__ */ t("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: K || /* @__PURE__ */ t("span", { className: "inline-block h-3 w-28 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))] align-middle" }) }),
1004
- /* @__PURE__ */ t("span", { className: `text-slate-400 transition-transform ${Y ? "rotate-90" : ""}`, children: "›" })
1012
+ /* @__PURE__ */ t("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: z || /* @__PURE__ */ t("span", { className: "inline-block h-3 w-28 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))] align-middle" }) }),
1013
+ /* @__PURE__ */ t("span", { className: `text-slate-400 transition-transform ${Z ? "rotate-90" : ""}`, children: "›" })
1005
1014
  ]
1006
1015
  }
1007
1016
  ),
1008
- Y && /* @__PURE__ */ x("div", { className: "border-t border-slate-100 px-4 py-3 dark:border-border", children: [
1009
- j && Te,
1010
- j && je,
1011
- g && /* @__PURE__ */ t(We, { message: g, onRetry: ge }),
1012
- !j && !g && s && r && Oe()
1017
+ Z && /* @__PURE__ */ w("div", { className: "border-t border-slate-100 px-4 py-3 dark:border-border", children: [
1018
+ T && je,
1019
+ T && Oe,
1020
+ x && /* @__PURE__ */ t(He, { message: x, onRetry: ye }),
1021
+ !T && !x && i && r && Ie()
1013
1022
  ] })
1014
1023
  ] });
1015
- function Oe() {
1024
+ function Ie() {
1016
1025
  var l;
1017
- return !s || !r ? null : /* @__PURE__ */ x(_e, { children: [
1018
- (r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in s) && /* @__PURE__ */ t(we, { data: s, awaiting: M }),
1019
- r.widget_type === "custom-query" && "values" in s && (M ? /* @__PURE__ */ x(
1026
+ return !i || !r ? null : /* @__PURE__ */ w(ke, { children: [
1027
+ (r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in i) && /* @__PURE__ */ t(ve, { data: i, awaiting: H }),
1028
+ r.widget_type === "custom-query" && "values" in i && (H ? /* @__PURE__ */ w(
1020
1029
  "p",
1021
1030
  {
1022
1031
  className: "text-[12px] text-slate-500 dark:text-slate-400",
1023
- "data-widget-awaiting": M,
1032
+ "data-widget-awaiting": H,
1024
1033
  children: [
1025
1034
  "Set ",
1026
- M,
1035
+ H,
1027
1036
  " on this record to see ",
1028
- K || "this",
1037
+ z || "this",
1029
1038
  "."
1030
1039
  ]
1031
1040
  }
1032
- ) : /* @__PURE__ */ t(Fe, { data: s })),
1033
- r.widget_type === "list" && /* @__PURE__ */ t(jr, { data: s }),
1034
- M && r.widget_type === "custom-query" && "rows" in s && /* @__PURE__ */ x(
1041
+ ) : /* @__PURE__ */ t(Qe, { data: i })),
1042
+ r.widget_type === "list" && /* @__PURE__ */ t(Or, { data: i }),
1043
+ H && r.widget_type === "custom-query" && "rows" in i && /* @__PURE__ */ w(
1035
1044
  "p",
1036
1045
  {
1037
1046
  className: "text-[12px] text-slate-500 dark:text-slate-400",
1038
- "data-widget-awaiting": M,
1047
+ "data-widget-awaiting": H,
1039
1048
  children: [
1040
1049
  "Set ",
1041
- M,
1050
+ H,
1042
1051
  " on this record to see ",
1043
- K || "this",
1052
+ z || "this",
1044
1053
  "."
1045
1054
  ]
1046
1055
  }
1047
1056
  ),
1048
- !M && r.widget_type === "custom-query" && "rows" in s && /* @__PURE__ */ t(
1049
- Nr,
1057
+ !H && r.widget_type === "custom-query" && "rows" in i && /* @__PURE__ */ t(
1058
+ Sr,
1050
1059
  {
1051
- rows: s.rows ?? [],
1060
+ rows: i.rows ?? [],
1052
1061
  config: (l = r.config) == null ? void 0 : l.table,
1053
- emptyLabel: K
1062
+ emptyLabel: z
1054
1063
  }
1055
1064
  ),
1056
1065
  r.widget_type === "review_list" && /* @__PURE__ */ t(
1057
- Rr,
1066
+ Cr,
1058
1067
  {
1059
- data: s,
1068
+ data: i,
1060
1069
  config: r.config ?? {},
1061
1070
  onRefetch: () => I((c) => c + 1),
1062
- hostRecordId: q.record_id,
1063
- emptyLabel: K
1071
+ hostRecordId: D.record_id,
1072
+ emptyLabel: z
1064
1073
  }
1065
1074
  ),
1066
1075
  r.widget_type === "rollup" && /* @__PURE__ */ t(
1067
- Lr,
1076
+ $r,
1068
1077
  {
1069
- data: s,
1078
+ data: i,
1070
1079
  config: r.config ?? {},
1071
- emptyLabel: K
1080
+ emptyLabel: z
1072
1081
  }
1073
1082
  ),
1074
- r.widget_type === "report_widget" && /* @__PURE__ */ t(Sr, { payload: s }),
1083
+ r.widget_type === "report_widget" && /* @__PURE__ */ t(Lr, { payload: i }),
1075
1084
  r.widget_type === "action-buttons" && /* @__PURE__ */ t(
1076
- Je,
1085
+ ze,
1077
1086
  {
1078
- data: s,
1087
+ data: i,
1079
1088
  widgetId: n,
1080
- inputs: q,
1081
- apiBase: T
1089
+ inputs: D,
1090
+ apiBase: E
1082
1091
  }
1083
1092
  ),
1084
1093
  r.widget_type === "button-group" && /* @__PURE__ */ t(
1085
- ve,
1094
+ Ne,
1086
1095
  {
1087
- buttons: s.buttons ?? [],
1088
- layout: s.layout ?? "flat",
1096
+ buttons: i.buttons ?? [],
1097
+ layout: i.layout ?? "flat",
1089
1098
  widgetId: n,
1090
- inputs: q,
1091
- apiBase: T,
1099
+ inputs: D,
1100
+ apiBase: E,
1092
1101
  onClientAction: S
1093
1102
  }
1094
1103
  ),
@@ -1101,12 +1110,12 @@ function rn({
1101
1110
  "review_list",
1102
1111
  "rollup",
1103
1112
  "report_widget"
1104
- ].includes(r.widget_type) && /* @__PURE__ */ t("pre", { className: "whitespace-pre-wrap text-[11px] text-slate-500", children: JSON.stringify(s, null, 2) }),
1105
- s.cache ? /* @__PURE__ */ t(
1106
- vr,
1113
+ ].includes(r.widget_type) && /* @__PURE__ */ t("pre", { className: "whitespace-pre-wrap text-[11px] text-slate-500", children: JSON.stringify(i, null, 2) }),
1114
+ i.cache ? /* @__PURE__ */ t(
1115
+ Nr,
1107
1116
  {
1108
- envelope: s.cache,
1109
- onRefresh: V,
1117
+ envelope: i.cache,
1118
+ onRefresh: J,
1110
1119
  refreshing: u,
1111
1120
  className: "mt-2 justify-end"
1112
1121
  }
@@ -1115,6 +1124,6 @@ function rn({
1115
1124
  }
1116
1125
  }
1117
1126
  export {
1118
- rn as WidgetSlot,
1119
- Ke as hostStepChange
1127
+ sn as WidgetSlot,
1128
+ Ge as hostStepChange
1120
1129
  };