@nivaro/react 0.3.58 → 0.3.60

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