@restio/ui 0.2.1-20260917153719 → 0.2.1-20261007123729

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,52 +1,114 @@
1
- import { Bt as Me, D as Se, E as he, Et as xe, Ft as le, Ht as U, It as We, Jt as Ie, Lt as ze, O as be, Pt as Re, Rt as pe, T as Fe, Wt as ce, Y as Pe, Yt as Oe, f as Ee, jt as ue, mt as ke, nt as Te, qt as fe, rt as je, u as Be, w as He } from "./src-CIojZORu.js";
2
- import { useCallback as f, useEffect as oe, useMemo as J, useRef as me, useState as W } from "react";
3
- var Ze = 1;
4
- function Ge(r, u) {
5
- const m = r.col + r.w, c = r.row + r.h, y = u.col + u.w, x = u.row + u.h;
6
- return r.col < y && m > u.col && r.row < x && c > u.row;
1
+ import { A as Ie, B as fe, Bt as Ee, D as Pe, E as xe, Et as ge, Ft as ue, Ht as Z, I as Fe, It as Oe, Jt as Be, Lt as Te, N as Ae, O as pe, Pt as $e, Rt as _e, T as Le, Wt as te, Y as Ge, Yt as He, f as Ve, jt as me, mt as ke, nt as Ye, pt as qe, q as Ke, qt as ve, rt as Ne, u as Xe, w as Je, wt as Qe, z as Ze } from "./src-Bzrq1hWW.js";
2
+ import { useCallback as y, useEffect as se, useMemo as X, useRef as ie, useState as D } from "react";
3
+ import { createPortal as Ue } from "react-dom";
4
+ var er = { "rst-pip-container": "_rst-pip-container_63eby_1" }, e = Be(), kr = ({ pipWindow: r, className: a, children: i, ...s }) => r ? Ue(/* @__PURE__ */ (0, e.jsx)("div", {
5
+ className: [er["rst-pip-container"], a].filter(Boolean).join(" "),
6
+ ...s,
7
+ children: i
8
+ }), r.document.body) : null;
9
+ function Se() {
10
+ return globalThis.documentPictureInPicture;
7
11
  }
8
- function ge(r) {
12
+ function rr() {
13
+ return Se() !== void 0;
14
+ }
15
+ function ar(r, a = document) {
16
+ for (const i of Array.from(a.querySelectorAll('style, link[rel="stylesheet"]'))) r.head.appendChild(i.cloneNode(!0));
17
+ for (const { name: i, value: s } of Array.from(a.documentElement.attributes)) r.documentElement.setAttribute(i, s);
18
+ for (const { name: i, value: s } of Array.from(a.body.attributes)) r.body.setAttribute(i, s);
19
+ }
20
+ function tr(r) {
21
+ const a = r.createElement("style");
22
+ a.textContent = [
23
+ "html, body { height: 100%; margin: 0; }",
24
+ "body {",
25
+ " background-color: var(--rst-backgroundColor-default);",
26
+ " color: var(--rst-fontColor-main);",
27
+ " font: var(--rst-font-body);",
28
+ "}"
29
+ ].join(`
30
+ `), r.head.appendChild(a);
31
+ }
32
+ function Nr({ width: r, height: a, copyStyles: i = !0 } = {}) {
33
+ const [s, b] = D(null), [h, p] = D(null), j = ie(null), k = y(async () => {
34
+ const f = Se();
35
+ if (!(!f || j.current)) {
36
+ p(null);
37
+ try {
38
+ const g = await f.requestWindow({
39
+ width: r,
40
+ height: a
41
+ });
42
+ j.current = g, i && ar(g.document), tr(g.document), g.addEventListener("pagehide", () => {
43
+ j.current = null, b(null);
44
+ }), b(g);
45
+ } catch (g) {
46
+ p(g instanceof Error ? `${g.name}: ${g.message}` : String(g));
47
+ }
48
+ }
49
+ }, [
50
+ r,
51
+ a,
52
+ i
53
+ ]), c = y(() => {
54
+ j.current?.close();
55
+ }, []);
56
+ return se(() => () => j.current?.close(), []), {
57
+ pipWindow: s,
58
+ error: h,
59
+ isOpen: s !== null,
60
+ isSupported: rr(),
61
+ open: k,
62
+ close: c
63
+ };
64
+ }
65
+ var Sr = 1;
66
+ function sr(r, a) {
67
+ const i = r.col + r.w, s = r.row + r.h, b = a.col + a.w, h = a.row + a.h;
68
+ return r.col < b && i > a.col && r.row < h && s > a.row;
69
+ }
70
+ function ye(r) {
9
71
  return r.col >= 1 && r.col + r.w - 1 <= 12 && r.row >= 1 && r.row + r.h - 1 <= 30;
10
72
  }
11
- function ne(r, u, m) {
12
- for (const c of u)
13
- if (c.id !== m && Ge(r, c.position))
14
- return c.id;
73
+ function be(r, a, i) {
74
+ for (const s of a)
75
+ if (s.id !== i && sr(r, s.position))
76
+ return s.id;
15
77
  return null;
16
78
  }
17
- function Ce(r, u, m) {
18
- for (let x = 1; x <= 30 - u + 1; x++) for (let p = 1; p <= 12 - r + 1; p++) {
19
- const S = {
79
+ function Me(r, a, i) {
80
+ for (let h = 1; h <= 30 - a + 1; h++) for (let p = 1; p <= 12 - r + 1; p++) {
81
+ const j = {
20
82
  col: p,
21
- row: x,
83
+ row: h,
22
84
  w: r,
23
- h: u
85
+ h: a
24
86
  };
25
- if (!ne(S, m)) return S;
87
+ if (!be(j, i)) return j;
26
88
  }
27
89
  return {
28
90
  col: 1,
29
- row: m.reduce((x, p) => Math.max(x, p.position.row + p.position.h), 1),
91
+ row: i.reduce((h, p) => Math.max(h, p.position.row + p.position.h), 1),
30
92
  w: r,
31
- h: u
93
+ h: a
32
94
  };
33
95
  }
34
- function Le(r, u) {
35
- const m = {};
36
- for (const c of r) {
37
- const y = u[c.dataSourceId];
38
- if (!y) continue;
39
- const x = y.data ?? [], p = ke(x.length > 0 ? Object.keys(x[0]) : []), S = je(c.columns ?? p), D = /* @__PURE__ */ new Set(), l = [];
40
- for (const _ of S) D.has(_.id) || (D.add(_.id), l.push(_));
41
- m[c.dataSourceId] = l;
96
+ function dr(r, a) {
97
+ const i = {};
98
+ for (const s of r) {
99
+ const b = a[s.dataSourceId];
100
+ if (!b) continue;
101
+ const h = b.data ?? [], p = ke(h.length > 0 ? Object.keys(h[0]) : []), j = Ne(s.columns ?? p), k = /* @__PURE__ */ new Set(), c = [];
102
+ for (const f of j) k.has(f.id) || (k.add(f.id), c.push(f));
103
+ i[s.dataSourceId] = c;
42
104
  }
43
- return m;
44
- }
45
- var _e = 0;
46
- function ve() {
47
- return _e += 1, `widget-${Date.now()}-${_e}`;
105
+ return i;
48
106
  }
107
+ var je = 0;
49
108
  function we() {
109
+ return je += 1, `widget-${Date.now()}-${je}`;
110
+ }
111
+ function Ce() {
50
112
  return {
51
113
  version: 1,
52
114
  name: "Untitled Dashboard",
@@ -54,97 +116,97 @@ function we() {
54
116
  widgets: []
55
117
  };
56
118
  }
57
- function $e(r, u) {
58
- const [m, c] = W(r ?? we), [y, x] = W(null), [p, S] = W(u ? "view" : "edit"), D = me(!1), l = f(() => {
59
- D.current = !0;
60
- }, []), _ = f((t, n, N) => {
61
- c((s) => {
62
- const g = {
63
- id: ve(),
64
- title: `New ${t}`,
65
- componentType: t,
66
- dataSourceId: n,
67
- position: N
119
+ function ir(r, a) {
120
+ const [i, s] = D(r ?? Ce), [b, h] = D(null), [p, j] = D(a ? "view" : "edit"), k = ie(!1), c = y(() => {
121
+ k.current = !0;
122
+ }, []), f = y((u, x, W) => {
123
+ s((d) => {
124
+ const C = {
125
+ id: we(),
126
+ title: `New ${u}`,
127
+ componentType: u,
128
+ dataSourceId: x,
129
+ position: W
68
130
  };
69
131
  return {
70
- ...s,
71
- widgets: [...s.widgets, g]
132
+ ...d,
133
+ widgets: [...d.widgets, C]
72
134
  };
73
- }), l();
74
- }, [l]), I = f((t) => {
75
- c((n) => {
76
- const N = Ce(6, 3, n.widgets), s = {
77
- id: ve(),
78
- position: N,
79
- ...t.widget
135
+ }), c();
136
+ }, [c]), g = y((u) => {
137
+ s((x) => {
138
+ const W = Me(6, 3, x.widgets), d = {
139
+ id: we(),
140
+ position: W,
141
+ ...u.widget
80
142
  };
81
143
  return {
82
- ...n,
83
- widgets: [...n.widgets, s]
144
+ ...x,
145
+ widgets: [...x.widgets, d]
84
146
  };
85
- }), l();
86
- }, [l]), z = f((t) => {
87
- c((n) => ({
88
- ...n,
89
- widgets: n.widgets.filter((N) => N.id !== t)
90
- })), x((n) => n === t ? null : n), l();
91
- }, [l]), P = f((t, n) => {
92
- c((N) => ({
93
- ...N,
94
- widgets: N.widgets.map((s) => {
95
- if (s.id !== t) return s;
96
- const g = {
97
- ...s,
98
- ...n
147
+ }), c();
148
+ }, [c]), w = y((u) => {
149
+ s((x) => ({
150
+ ...x,
151
+ widgets: x.widgets.filter((W) => W.id !== u)
152
+ })), h((x) => x === u ? null : x), c();
153
+ }, [c]), R = y((u, x) => {
154
+ s((W) => ({
155
+ ...W,
156
+ widgets: W.widgets.map((d) => {
157
+ if (d.id !== u) return d;
158
+ const C = {
159
+ ...d,
160
+ ...x
99
161
  };
100
- if (n.dataSourceId && n.dataSourceId !== s.dataSourceId) {
101
- const R = be[s.componentType] ?? [];
102
- g.columns = void 0, g.componentProps = he(R), g.filters = void 0, g.uiConfig = void 0;
162
+ if (x.dataSourceId && x.dataSourceId !== d.dataSourceId) {
163
+ const P = pe[d.componentType] ?? [];
164
+ C.columns = void 0, C.componentProps = xe(P), C.filters = void 0, C.uiConfig = void 0;
103
165
  }
104
- return g;
166
+ return C;
105
167
  })
106
- })), l();
107
- }, [l]), j = f((t, n) => {
108
- P(t, { position: n });
109
- }, [P]), T = f((t) => {
110
- x(t);
111
- }, []), X = m.widgets.find((t) => t.id === y) ?? null, H = f((t) => {
112
- c((n) => ({
113
- ...n,
114
- name: t
115
- })), l();
116
- }, [l]), a = f((t) => {
117
- c((n) => ({
118
- ...n,
119
- filters: typeof t == "function" ? t(n.filters) : t
120
- })), l();
121
- }, [l]), i = f((t) => {
122
- c(t ?? we()), x(null), D.current = !1;
123
- }, []), O = f((t) => {
124
- c(t), x(null), D.current = !1;
168
+ })), c();
169
+ }, [c]), o = y((u, x) => {
170
+ R(u, { position: x });
171
+ }, [R]), E = y((u) => {
172
+ h(u);
173
+ }, []), L = i.widgets.find((u) => u.id === b) ?? null, O = y((u) => {
174
+ s((x) => ({
175
+ ...x,
176
+ name: u
177
+ })), c();
178
+ }, [c]), t = y((u) => {
179
+ s((x) => ({
180
+ ...x,
181
+ filters: typeof u == "function" ? u(x.filters) : u
182
+ })), c();
183
+ }, [c]), l = y((u) => {
184
+ s(u ?? Ce()), h(null), k.current = !1;
185
+ }, []), B = y((u) => {
186
+ s(u), h(null), k.current = !1;
125
187
  }, []);
126
188
  return {
127
189
  state: {
128
- config: m,
129
- selectedWidgetId: y,
130
- isDirty: D.current
190
+ config: i,
191
+ selectedWidgetId: b,
192
+ isDirty: k.current
131
193
  },
132
194
  mode: p,
133
- setMode: S,
134
- addWidget: _,
135
- addPrebuiltWidget: I,
136
- removeWidget: z,
137
- updateWidget: P,
138
- moveWidget: j,
139
- selectWidget: T,
140
- selectedWidget: X,
141
- setName: H,
142
- setFilters: a,
143
- resetConfig: i,
144
- loadConfig: O
195
+ setMode: j,
196
+ addWidget: f,
197
+ addPrebuiltWidget: g,
198
+ removeWidget: w,
199
+ updateWidget: R,
200
+ moveWidget: o,
201
+ selectWidget: E,
202
+ selectedWidget: L,
203
+ setName: O,
204
+ setFilters: t,
205
+ resetConfig: l,
206
+ loadConfig: B
145
207
  };
146
208
  }
147
- var d = {
209
+ var n = {
148
210
  "rst-dashboard-builder": "_rst-dashboard-builder_ukxxh_2",
149
211
  "rst-dashboard-builder-sidebar": "_rst-dashboard-builder-sidebar_ukxxh_18",
150
212
  "rst-dashboard-builder-sidebar-header": "_rst-dashboard-builder-sidebar-header_ukxxh_28",
@@ -201,331 +263,331 @@ var d = {
201
263
  "rst-dashboard-builder-template-item": "_rst-dashboard-builder-template-item_ukxxh_705",
202
264
  "rst-dashboard-builder-template-item-name": "_rst-dashboard-builder-template-item-name_ukxxh_727",
203
265
  "rst-dashboard-builder-template-item-desc": "_rst-dashboard-builder-template-item-desc_ukxxh_733"
204
- }, q = 12, re = 30, de = 12;
205
- function Ve({ widgets: r, onMoveWidget: u, onAddWidget: m, onChange: c }) {
206
- const y = me(null), [x, p] = W(null), [S, D] = W(null), [l, _] = W(null), [I, z] = W(null), [P, j] = W(!1), [T, X] = W(null), [H, a] = W(null), [i, O] = W(null), [t, n] = W(null), [N, s] = W(!1), g = f(() => y.current ? {
207
- colWidth: (y.current.getBoundingClientRect().width - de * (q - 1)) / q,
266
+ }, Q = 12, de = 30, oe = 12;
267
+ function nr({ widgets: r, onMoveWidget: a, onAddWidget: i, onChange: s }) {
268
+ const b = ie(null), [h, p] = D(null), [j, k] = D(null), [c, f] = D(null), [g, w] = D(null), [R, o] = D(!1), [E, L] = D(null), [O, t] = D(null), [l, B] = D(null), [u, x] = D(null), [W, d] = D(!1), C = y(() => b.current ? {
269
+ colWidth: (b.current.getBoundingClientRect().width - oe * (Q - 1)) / Q,
208
270
  rowHeight: 92
209
- } : null, []), R = f((b, v) => {
210
- if (!y.current) return {
271
+ } : null, []), P = y((v, N) => {
272
+ if (!b.current) return {
211
273
  col: 1,
212
274
  row: 1
213
275
  };
214
- const C = y.current.getBoundingClientRect(), k = (C.width - de * (q - 1)) / q;
276
+ const z = b.current.getBoundingClientRect(), M = (z.width - oe * (Q - 1)) / Q;
215
277
  return {
216
- col: Math.max(1, Math.min(q, Math.round((b - C.left) / (k + de)) + 1)),
217
- row: Math.max(1, Math.min(re, Math.round((v - C.top) / 92) + 1))
278
+ col: Math.max(1, Math.min(Q, Math.round((v - z.left) / (M + oe)) + 1)),
279
+ row: Math.max(1, Math.min(de, Math.round((N - z.top) / 92) + 1))
218
280
  };
219
- }, []), Q = f((b) => {
220
- if (b.preventDefault(), b.dataTransfer.types.includes("application/widget-type")) {
221
- b.dataTransfer.dropEffect = "copy";
281
+ }, []), U = y((v) => {
282
+ if (v.preventDefault(), v.dataTransfer.types.includes("application/widget-type")) {
283
+ v.dataTransfer.dropEffect = "copy";
222
284
  return;
223
285
  }
224
- if (b.dataTransfer.types.includes("application/move-widget") && x && S && l) {
225
- b.dataTransfer.dropEffect = "move";
226
- const v = r.find((M) => M.id === x);
227
- if (!v) return;
228
- const C = g();
229
- if (!C) return;
230
- const k = b.clientX - S.x, L = b.clientY - S.y, se = Math.round(k / (C.colWidth + de)), V = Math.round(L / C.rowHeight), $ = {
231
- col: Math.max(1, Math.min(q - v.position.w + 1, l.col + se)),
232
- row: Math.max(1, Math.min(re - v.position.h + 1, l.row + V)),
233
- w: v.position.w,
234
- h: v.position.h
286
+ if (v.dataTransfer.types.includes("application/move-widget") && h && j && c) {
287
+ v.dataTransfer.dropEffect = "move";
288
+ const N = r.find((I) => I.id === h);
289
+ if (!N) return;
290
+ const z = C();
291
+ if (!z) return;
292
+ const M = v.clientX - j.x, G = v.clientY - j.y, ne = Math.round(M / (z.colWidth + oe)), Y = Math.round(G / z.rowHeight), H = {
293
+ col: Math.max(1, Math.min(Q - N.position.w + 1, c.col + ne)),
294
+ row: Math.max(1, Math.min(de - N.position.h + 1, c.row + Y)),
295
+ w: N.position.w,
296
+ h: N.position.h
235
297
  };
236
- z($);
237
- const E = ne($, r, x);
238
- j(E !== null);
298
+ w(H);
299
+ const T = be(H, r, h);
300
+ o(T !== null);
239
301
  }
240
302
  }, [
241
- x,
242
- S,
243
- l,
244
- g,
303
+ h,
304
+ j,
305
+ c,
306
+ C,
245
307
  r
246
- ]), Z = f((b) => {
247
- b.preventDefault();
248
- const v = b.dataTransfer.getData("application/widget-type");
249
- if (v) {
250
- const { col: C, row: k } = R(b.clientX, b.clientY), L = {
251
- col: C,
252
- row: k,
308
+ ]), ee = y((v) => {
309
+ v.preventDefault();
310
+ const N = v.dataTransfer.getData("application/widget-type");
311
+ if (N) {
312
+ const { col: z, row: M } = P(v.clientX, v.clientY), G = {
313
+ col: z,
314
+ row: M,
253
315
  w: 4,
254
316
  h: 3
255
317
  };
256
- if (C + 4 - 1 > q && (L.col = 9), k + 3 - 1 > re && (L.row = 28), ne(L, r)) return;
257
- m(v, "", L), c();
318
+ if (z + 4 - 1 > Q && (G.col = 9), M + 3 - 1 > de && (G.row = 28), be(G, r)) return;
319
+ i(N, "", G), s();
258
320
  return;
259
321
  }
260
- x && I && (!P && ge(I) && (u(x, I), c()), p(null), D(null), _(null), z(null), j(!1));
322
+ h && g && (!R && ye(g) && (a(h, g), s()), p(null), k(null), f(null), w(null), o(!1));
261
323
  }, [
262
- R,
263
- r,
264
- m,
265
- c,
266
- x,
267
- I,
268
324
  P,
269
- u
270
- ]), ee = f((b, v) => {
271
- b.stopPropagation(), b.dataTransfer.setData("application/move-widget", v.id), b.dataTransfer.effectAllowed = "move", p(v.id), D({
272
- x: b.clientX,
273
- y: b.clientY
274
- }), _({ ...v.position }), z({ ...v.position }), j(!1);
275
- }, []), h = f(() => {
276
- p(null), D(null), _(null), z(null), j(!1);
277
- }, []), te = f((b, v, C) => {
278
- b.stopPropagation(), b.preventDefault(), X(v.id), a(C), O({ ...v.position }), n({
279
- x: b.clientX,
280
- y: b.clientY
281
- }), s(!1);
325
+ r,
326
+ i,
327
+ s,
328
+ h,
329
+ g,
330
+ R,
331
+ a
332
+ ]), re = y((v, N) => {
333
+ v.stopPropagation(), v.dataTransfer.setData("application/move-widget", N.id), v.dataTransfer.effectAllowed = "move", p(N.id), k({
334
+ x: v.clientX,
335
+ y: v.clientY
336
+ }), f({ ...N.position }), w({ ...N.position }), o(!1);
337
+ }, []), _ = y(() => {
338
+ p(null), k(null), f(null), w(null), o(!1);
339
+ }, []), le = y((v, N, z) => {
340
+ v.stopPropagation(), v.preventDefault(), L(N.id), t(z), B({ ...N.position }), x({
341
+ x: v.clientX,
342
+ y: v.clientY
343
+ }), d(!1);
282
344
  }, []);
283
- return oe(() => {
284
- if (!T || !H || !i || !t) return;
285
- const b = (C) => {
286
- if (!r.find((w) => w.id === T)) return;
287
- const k = g();
288
- if (!k) return;
289
- const L = C.clientX - t.x, se = C.clientY - t.y, V = Math.round(L / (k.colWidth + de)), $ = Math.round(se / k.rowHeight), E = i.col, M = i.row, A = i.w, Y = i.h;
290
- let F = { ...i };
291
- switch (H) {
345
+ return se(() => {
346
+ if (!E || !O || !l || !u) return;
347
+ const v = (z) => {
348
+ if (!r.find((S) => S.id === E)) return;
349
+ const M = C();
350
+ if (!M) return;
351
+ const G = z.clientX - u.x, ne = z.clientY - u.y, Y = Math.round(G / (M.colWidth + oe)), H = Math.round(ne / M.rowHeight), T = l.col, I = l.row, q = l.w, K = l.h;
352
+ let F = { ...l };
353
+ switch (O) {
292
354
  case "e": {
293
- const w = Math.max(1, Math.min(q - E + 1, A + V));
355
+ const S = Math.max(1, Math.min(Q - T + 1, q + Y));
294
356
  F = {
295
357
  ...F,
296
- w
358
+ w: S
297
359
  };
298
360
  break;
299
361
  }
300
362
  case "w": {
301
- const w = Math.max(1, Math.min(E + A - 1, E + V)), B = E + A - w;
363
+ const S = Math.max(1, Math.min(T + q - 1, T + Y)), A = T + q - S;
302
364
  F = {
303
- ...i,
304
- col: w,
305
- w: Math.max(1, B)
365
+ ...l,
366
+ col: S,
367
+ w: Math.max(1, A)
306
368
  };
307
369
  break;
308
370
  }
309
371
  case "s": {
310
- const w = Math.max(1, Math.min(re - M + 1, Y + $));
372
+ const S = Math.max(1, Math.min(de - I + 1, K + H));
311
373
  F = {
312
- ...i,
313
- h: w
374
+ ...l,
375
+ h: S
314
376
  };
315
377
  break;
316
378
  }
317
379
  case "n": {
318
- const w = Math.max(1, Math.min(M + Y - 1, M + $)), B = M + Y - w;
380
+ const S = Math.max(1, Math.min(I + K - 1, I + H)), A = I + K - S;
319
381
  F = {
320
- ...i,
321
- row: w,
322
- h: Math.max(1, B)
382
+ ...l,
383
+ row: S,
384
+ h: Math.max(1, A)
323
385
  };
324
386
  break;
325
387
  }
326
388
  case "se": {
327
- const w = Math.max(1, Math.min(q - E + 1, A + V)), B = Math.max(1, Math.min(re - M + 1, Y + $));
389
+ const S = Math.max(1, Math.min(Q - T + 1, q + Y)), A = Math.max(1, Math.min(de - I + 1, K + H));
328
390
  F = {
329
- ...i,
330
- w,
331
- h: B
391
+ ...l,
392
+ w: S,
393
+ h: A
332
394
  };
333
395
  break;
334
396
  }
335
397
  case "sw": {
336
- const w = Math.max(1, Math.min(E + A - 1, E + V)), B = E + A - w, o = Math.max(1, Math.min(re - M + 1, Y + $));
398
+ const S = Math.max(1, Math.min(T + q - 1, T + Y)), A = T + q - S, m = Math.max(1, Math.min(de - I + 1, K + H));
337
399
  F = {
338
- ...i,
339
- col: w,
340
- w: Math.max(1, B),
341
- h: o
400
+ ...l,
401
+ col: S,
402
+ w: Math.max(1, A),
403
+ h: m
342
404
  };
343
405
  break;
344
406
  }
345
407
  case "ne": {
346
- const w = Math.max(1, Math.min(M + Y - 1, M + $)), B = M + Y - w, o = Math.max(1, Math.min(q - E + 1, A + V));
408
+ const S = Math.max(1, Math.min(I + K - 1, I + H)), A = I + K - S, m = Math.max(1, Math.min(Q - T + 1, q + Y));
347
409
  F = {
348
- ...i,
349
- row: w,
350
- h: Math.max(1, B),
351
- w: o
410
+ ...l,
411
+ row: S,
412
+ h: Math.max(1, A),
413
+ w: m
352
414
  };
353
415
  break;
354
416
  }
355
417
  case "nw": {
356
- const w = Math.max(1, Math.min(E + A - 1, E + V)), B = Math.max(1, Math.min(M + Y - 1, M + $)), o = E + A - w, G = M + Y - B;
418
+ const S = Math.max(1, Math.min(T + q - 1, T + Y)), A = Math.max(1, Math.min(I + K - 1, I + H)), m = T + q - S, $ = I + K - A;
357
419
  F = {
358
- col: w,
359
- row: B,
360
- w: Math.max(1, o),
361
- h: Math.max(1, G)
420
+ col: S,
421
+ row: A,
422
+ w: Math.max(1, m),
423
+ h: Math.max(1, $)
362
424
  };
363
425
  break;
364
426
  }
365
427
  }
366
- z(F), p(T);
367
- const ie = ne(F, r, T);
368
- s(ie !== null), j(ie !== null);
369
- }, v = () => {
370
- r.find((C) => C.id === T) && I && !N && ge(I) && (u(T, I), c()), X(null), a(null), O(null), n(null), s(!1), p(null), D(null), _(null), z(null), j(!1);
428
+ w(F), p(E);
429
+ const ce = be(F, r, E);
430
+ d(ce !== null), o(ce !== null);
431
+ }, N = () => {
432
+ r.find((z) => z.id === E) && g && !W && ye(g) && (a(E, g), s()), L(null), t(null), B(null), x(null), d(!1), p(null), k(null), f(null), w(null), o(!1);
371
433
  };
372
- return document.addEventListener("mousemove", b), document.addEventListener("mouseup", v), () => {
373
- document.removeEventListener("mousemove", b), document.removeEventListener("mouseup", v);
434
+ return document.addEventListener("mousemove", v), document.addEventListener("mouseup", N), () => {
435
+ document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", N);
374
436
  };
375
437
  }, [
376
- T,
377
- H,
378
- i,
379
- t,
438
+ E,
439
+ O,
440
+ l,
441
+ u,
380
442
  r,
381
- I,
382
- N,
383
443
  g,
384
- u,
385
- c
444
+ W,
445
+ C,
446
+ a,
447
+ s
386
448
  ]), {
387
- gridRef: y,
388
- draggingWidgetId: x,
389
- dragPreviewPos: I,
390
- hasCollision: P,
391
- resizeCollision: N,
392
- handleDragOver: Q,
393
- handleDrop: Z,
394
- handleWidgetDragStart: ee,
395
- handleWidgetDragEnd: h,
396
- handleResizeStart: te,
397
- pixelToGrid: R
449
+ gridRef: b,
450
+ draggingWidgetId: h,
451
+ dragPreviewPos: g,
452
+ hasCollision: R,
453
+ resizeCollision: W,
454
+ handleDragOver: U,
455
+ handleDrop: ee,
456
+ handleWidgetDragStart: re,
457
+ handleWidgetDragEnd: _,
458
+ handleResizeStart: le,
459
+ pixelToGrid: P
398
460
  };
399
461
  }
400
- var e = Ie(), Ae = 12, Ye = 20, ye = ({ widgets: r, selectedWidgetId: u, dataSources: m, onSelectWidget: c, onMoveWidget: y, onRemoveWidget: x, onAddWidget: p, onChange: S, getWidgetActions: D, mode: l = "edit" }) => {
401
- const _ = l === "view", { gridRef: I, draggingWidgetId: z, dragPreviewPos: P, hasCollision: j, handleDragOver: T, handleDrop: X, handleWidgetDragStart: H, handleWidgetDragEnd: a, handleResizeStart: i } = Ve({
462
+ var or = 12, lr = 20, De = ({ widgets: r, selectedWidgetId: a, dataSources: i, onSelectWidget: s, onMoveWidget: b, onRemoveWidget: h, onAddWidget: p, onChange: j, getWidgetActions: k, mode: c = "edit" }) => {
463
+ const f = c === "view", { gridRef: g, draggingWidgetId: w, dragPreviewPos: R, hasCollision: o, handleDragOver: E, handleDrop: L, handleWidgetDragStart: O, handleWidgetDragEnd: t, handleResizeStart: l } = nr({
402
464
  widgets: r,
403
- onMoveWidget: y,
465
+ onMoveWidget: b,
404
466
  onAddWidget: p,
405
- onChange: S
406
- }), O = f((s, g) => {
407
- s.stopPropagation(), c(g);
408
- }, [c]), t = f(() => {
409
- c(null);
410
- }, [c]), n = f((s) => {
411
- const g = m[s.dataSourceId]?.data ?? [], R = g.length > 0 ? Object.keys(g[0]) : [];
467
+ onChange: j
468
+ }), B = y((d, C) => {
469
+ d.stopPropagation(), s(C);
470
+ }, [s]), u = y(() => {
471
+ s(null);
472
+ }, [s]), x = y((d) => {
473
+ const C = i[d.dataSourceId]?.data ?? [], P = C.length > 0 ? Object.keys(C[0]) : [];
412
474
  return {
413
- data: g,
414
- columns: s.columns ?? ke(R)
475
+ data: C,
476
+ columns: d.columns ?? ke(P)
415
477
  };
416
- }, [m]), N = [];
417
- for (let s = 1; s <= Ye; s++) for (let g = 1; g <= Ae; g++) {
418
- const R = _ ? d["rst-dashboard-builder-grid-cell-view"] : d["rst-dashboard-builder-grid-cell"];
419
- N.push(/* @__PURE__ */ (0, e.jsx)("div", {
420
- className: R,
478
+ }, [i]), W = [];
479
+ for (let d = 1; d <= lr; d++) for (let C = 1; C <= or; C++) {
480
+ const P = f ? n["rst-dashboard-builder-grid-cell-view"] : n["rst-dashboard-builder-grid-cell"];
481
+ W.push(/* @__PURE__ */ (0, e.jsx)("div", {
482
+ className: P,
421
483
  style: {
422
- gridColumn: g,
423
- gridRow: s
484
+ gridColumn: C,
485
+ gridRow: d
424
486
  }
425
- }, `cell-${s}-${g}`));
487
+ }, `cell-${d}-${C}`));
426
488
  }
427
489
  return /* @__PURE__ */ (0, e.jsx)("div", {
428
- className: d["rst-dashboard-builder-canvas"],
429
- onClick: t,
490
+ className: n["rst-dashboard-builder-canvas"],
491
+ onClick: u,
430
492
  children: /* @__PURE__ */ (0, e.jsxs)("div", {
431
- ref: I,
432
- className: d["rst-dashboard-builder-grid"],
433
- onDragOver: T,
434
- onDrop: X,
493
+ ref: g,
494
+ className: n["rst-dashboard-builder-grid"],
495
+ onDragOver: E,
496
+ onDrop: L,
435
497
  children: [
436
- N,
498
+ W,
437
499
  r.length === 0 && /* @__PURE__ */ (0, e.jsx)("div", {
438
- className: d["rst-dashboard-builder-grid-empty"],
500
+ className: n["rst-dashboard-builder-grid-empty"],
439
501
  children: "Drag a widget from the palette to get started"
440
502
  }),
441
- r.map((s) => {
442
- const g = !_ && s.id === u, R = !_ && s.id === z, Q = n(s), Z = R && P ? P : s.position, ee = R && j;
503
+ r.map((d) => {
504
+ const C = !f && d.id === a, P = !f && d.id === w, U = x(d), ee = P && R ? R : d.position, re = P && o;
443
505
  return /* @__PURE__ */ (0, e.jsxs)("div", {
444
506
  className: [
445
- d["rst-dashboard-builder-widget"],
446
- _ ? d["rst-dashboard-builder-widget-view"] : "",
447
- g ? d["rst-dashboard-builder-widget-selected"] : "",
448
- R ? d["rst-dashboard-builder-widget-dragging"] : "",
449
- ee ? d["rst-dashboard-builder-widget-collision"] : ""
507
+ n["rst-dashboard-builder-widget"],
508
+ f ? n["rst-dashboard-builder-widget-view"] : "",
509
+ C ? n["rst-dashboard-builder-widget-selected"] : "",
510
+ P ? n["rst-dashboard-builder-widget-dragging"] : "",
511
+ re ? n["rst-dashboard-builder-widget-collision"] : ""
450
512
  ].filter(Boolean).join(" "),
451
513
  style: {
452
- gridColumn: `${Z.col} / span ${Z.w}`,
453
- gridRow: `${Z.row} / span ${Z.h}`
514
+ gridColumn: `${ee.col} / span ${ee.w}`,
515
+ gridRow: `${ee.row} / span ${ee.h}`
454
516
  },
455
- draggable: !_,
456
- ..._ ? {} : {
457
- onDragStart: (h) => H(h, s),
458
- onDragEnd: a,
459
- onClick: (h) => O(h, s.id),
517
+ draggable: !f,
518
+ ...f ? {} : {
519
+ onDragStart: (_) => O(_, d),
520
+ onDragEnd: t,
521
+ onClick: (_) => B(_, d.id),
460
522
  role: "button",
461
523
  tabIndex: 0,
462
- "aria-label": `Widget: ${s.title}`,
463
- onKeyDown: (h) => {
464
- (h.key === "Enter" || h.key === " ") && (h.preventDefault(), c(s.id)), (h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), x(s.id), S());
524
+ "aria-label": `Widget: ${d.title}`,
525
+ onKeyDown: (_) => {
526
+ (_.key === "Enter" || _.key === " ") && (_.preventDefault(), s(d.id)), (_.key === "Delete" || _.key === "Backspace") && (_.preventDefault(), h(d.id), j());
465
527
  }
466
528
  },
467
- children: [/* @__PURE__ */ (0, e.jsx)(Be, {
468
- id: s.id,
469
- dataSourceId: s.dataSourceId,
470
- title: s.title,
471
- subtitle: s.subtitle,
472
- icon: s.icon,
473
- data: Q.data,
474
- columns: Q.columns,
475
- enableExport: D?.(s).enableExport ?? !0,
476
- enableScreenshot: D?.(s).enableScreenshot ?? !1,
477
- enableExpand: D?.(s).enableExpand ?? !0,
478
- enableFilter: D?.(s).enableFilter ?? !1,
479
- fieldOptions: je(Q.columns),
480
- children: ({ data: h }) => /* @__PURE__ */ (0, e.jsx)(He, {
481
- data: h,
482
- columns: Q.columns,
483
- activeComponent: s.componentType,
484
- componentProps: s.componentProps,
529
+ children: [/* @__PURE__ */ (0, e.jsx)(Xe, {
530
+ id: d.id,
531
+ dataSourceId: d.dataSourceId,
532
+ title: d.title,
533
+ subtitle: d.subtitle,
534
+ icon: d.icon,
535
+ data: U.data,
536
+ columns: U.columns,
537
+ enableExport: k?.(d).enableExport ?? !0,
538
+ enableScreenshot: k?.(d).enableScreenshot ?? !1,
539
+ enableExpand: k?.(d).enableExpand ?? !0,
540
+ enableFilter: k?.(d).enableFilter ?? !1,
541
+ fieldOptions: Ne(U.columns),
542
+ children: ({ data: _ }) => /* @__PURE__ */ (0, e.jsx)(Je, {
543
+ data: _,
544
+ columns: U.columns,
545
+ activeComponent: d.componentType,
546
+ componentProps: d.componentProps,
485
547
  showConfigurator: !1
486
548
  })
487
- }), !_ && g && /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [
549
+ }), !f && C && /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [
488
550
  /* @__PURE__ */ (0, e.jsx)("div", {
489
- className: d["rst-dashboard-builder-resize-handle-n"],
490
- onMouseDown: (h) => i(h, s, "n")
551
+ className: n["rst-dashboard-builder-resize-handle-n"],
552
+ onMouseDown: (_) => l(_, d, "n")
491
553
  }),
492
554
  /* @__PURE__ */ (0, e.jsx)("div", {
493
- className: d["rst-dashboard-builder-resize-handle-s"],
494
- onMouseDown: (h) => i(h, s, "s")
555
+ className: n["rst-dashboard-builder-resize-handle-s"],
556
+ onMouseDown: (_) => l(_, d, "s")
495
557
  }),
496
558
  /* @__PURE__ */ (0, e.jsx)("div", {
497
- className: d["rst-dashboard-builder-resize-handle-e"],
498
- onMouseDown: (h) => i(h, s, "e")
559
+ className: n["rst-dashboard-builder-resize-handle-e"],
560
+ onMouseDown: (_) => l(_, d, "e")
499
561
  }),
500
562
  /* @__PURE__ */ (0, e.jsx)("div", {
501
- className: d["rst-dashboard-builder-resize-handle-w"],
502
- onMouseDown: (h) => i(h, s, "w")
563
+ className: n["rst-dashboard-builder-resize-handle-w"],
564
+ onMouseDown: (_) => l(_, d, "w")
503
565
  }),
504
566
  /* @__PURE__ */ (0, e.jsx)("div", {
505
- className: d["rst-dashboard-builder-resize-handle-ne"],
506
- onMouseDown: (h) => i(h, s, "ne")
567
+ className: n["rst-dashboard-builder-resize-handle-ne"],
568
+ onMouseDown: (_) => l(_, d, "ne")
507
569
  }),
508
570
  /* @__PURE__ */ (0, e.jsx)("div", {
509
- className: d["rst-dashboard-builder-resize-handle-nw"],
510
- onMouseDown: (h) => i(h, s, "nw")
571
+ className: n["rst-dashboard-builder-resize-handle-nw"],
572
+ onMouseDown: (_) => l(_, d, "nw")
511
573
  }),
512
574
  /* @__PURE__ */ (0, e.jsx)("div", {
513
- className: d["rst-dashboard-builder-resize-handle-se"],
514
- onMouseDown: (h) => i(h, s, "se")
575
+ className: n["rst-dashboard-builder-resize-handle-se"],
576
+ onMouseDown: (_) => l(_, d, "se")
515
577
  }),
516
578
  /* @__PURE__ */ (0, e.jsx)("div", {
517
- className: d["rst-dashboard-builder-resize-handle-sw"],
518
- onMouseDown: (h) => i(h, s, "sw")
579
+ className: n["rst-dashboard-builder-resize-handle-sw"],
580
+ onMouseDown: (_) => l(_, d, "sw")
519
581
  })
520
582
  ] })]
521
- }, `${s.id}::${s.dataSourceId}`);
583
+ }, `${d.id}::${d.dataSourceId}`);
522
584
  })
523
585
  ]
524
586
  })
525
587
  });
526
588
  };
527
- ye.displayName = "BuilderCanvas";
528
- var Xe = [
589
+ De.displayName = "BuilderCanvas";
590
+ var cr = [
529
591
  {
530
592
  type: "table-grid",
531
593
  label: "Table",
@@ -568,349 +630,349 @@ var Xe = [
568
630
  icon: "chart",
569
631
  description: "Single-metric KPI card"
570
632
  }
571
- ], De = ({ widget: r, dataSources: u, onUpdate: m, onRemove: c, onClose: y, onAddWidget: x, prebuiltSections: p, onAddPrebuiltSection: S }) => {
572
- const D = Object.values(u).map((a) => ({
573
- value: a.id,
574
- label: a.name
575
- })), l = J(() => [{
633
+ ], ze = ({ widget: r, dataSources: a, onUpdate: i, onRemove: s, onClose: b, onAddWidget: h, prebuiltSections: p, onAddPrebuiltSection: j }) => {
634
+ const k = Object.values(a).map((t) => ({
635
+ value: t.id,
636
+ label: t.name
637
+ })), c = X(() => [{
576
638
  value: "",
577
639
  id: "none"
578
- }, ...Object.keys(Oe).map((a) => ({
579
- value: a,
580
- leadingVisual: a
581
- }))], []), _ = r?.dataSourceId, I = J(() => {
582
- if (!_) return [];
583
- const a = u[_];
584
- return a ? a.fields.map((i) => ({
585
- id: i.id,
586
- header: i.name,
587
- accessorKey: i.id
640
+ }, ...Object.keys(He).map((t) => ({
641
+ value: t,
642
+ leadingVisual: t
643
+ }))], []), f = r?.dataSourceId, g = X(() => {
644
+ if (!f) return [];
645
+ const t = a[f];
646
+ return t ? t.fields.map((l) => ({
647
+ id: l.id,
648
+ header: l.name,
649
+ accessorKey: l.id
588
650
  })) : [];
589
- }, [_, u]), z = J(() => be[r?.componentType ?? "table-grid"] ?? [], [r?.componentType]), P = J(() => r?.componentProps ?? he(z), [r?.componentProps, z]), j = f((a, i) => {
590
- m({ [a]: i });
591
- }, [m]), T = f((a) => {
592
- m({
593
- componentType: a,
594
- componentProps: he(be[a] ?? [])
651
+ }, [f, a]), w = X(() => pe[r?.componentType ?? "table-grid"] ?? [], [r?.componentType]), R = X(() => r?.componentProps ?? xe(w), [r?.componentProps, w]), o = y((t, l) => {
652
+ i({ [t]: l });
653
+ }, [i]), E = y((t) => {
654
+ i({
655
+ componentType: t,
656
+ componentProps: xe(pe[t] ?? [])
595
657
  });
596
- }, [m]), X = f((a, i) => {
597
- m({ componentProps: {
598
- ...P,
599
- [a]: i
658
+ }, [i]), L = y((t, l) => {
659
+ i({ componentProps: {
660
+ ...R,
661
+ [t]: l
600
662
  } });
601
- }, [P, m]), H = J(() => !p || p.length === 0 ? [] : p.filter((a) => a.version === 1), [p]);
663
+ }, [R, i]), O = X(() => !p || p.length === 0 ? [] : p.filter((t) => t.version === 1), [p]);
602
664
  return r ? /* @__PURE__ */ (0, e.jsxs)("aside", {
603
- className: d["rst-dashboard-builder-configurator"],
665
+ className: n["rst-dashboard-builder-configurator"],
604
666
  "aria-label": "Widget configurator",
605
667
  children: [/* @__PURE__ */ (0, e.jsxs)("div", {
606
- className: d["rst-dashboard-builder-configurator-header"],
607
- children: [/* @__PURE__ */ (0, e.jsx)(ce, {
668
+ className: n["rst-dashboard-builder-configurator-header"],
669
+ children: [/* @__PURE__ */ (0, e.jsx)(te, {
608
670
  variant: "heading",
609
671
  children: "Configure"
610
- }), /* @__PURE__ */ (0, e.jsx)(U, {
672
+ }), /* @__PURE__ */ (0, e.jsx)(Z, {
611
673
  variant: "invisible",
612
674
  size: "small",
613
675
  leadingVisual: "close",
614
- onClick: y,
676
+ onClick: b,
615
677
  "aria-label": "Close configurator"
616
678
  })]
617
679
  }), /* @__PURE__ */ (0, e.jsxs)("div", {
618
- className: d["rst-dashboard-builder-configurator-body"],
680
+ className: n["rst-dashboard-builder-configurator-body"],
619
681
  children: [
620
682
  /* @__PURE__ */ (0, e.jsxs)("div", {
621
- className: d["rst-dashboard-builder-field"],
683
+ className: n["rst-dashboard-builder-field"],
622
684
  children: [/* @__PURE__ */ (0, e.jsx)("label", {
623
- className: d["rst-dashboard-builder-field-label"],
685
+ className: n["rst-dashboard-builder-field-label"],
624
686
  children: "Title"
625
- }), /* @__PURE__ */ (0, e.jsx)(pe, {
687
+ }), /* @__PURE__ */ (0, e.jsx)(_e, {
626
688
  value: r.title,
627
- onChange: (a) => j("title", a ?? ""),
689
+ onChange: (t) => o("title", t ?? ""),
628
690
  placeholder: "Widget title"
629
691
  })]
630
692
  }),
631
693
  /* @__PURE__ */ (0, e.jsxs)("div", {
632
- className: d["rst-dashboard-builder-field"],
694
+ className: n["rst-dashboard-builder-field"],
633
695
  children: [/* @__PURE__ */ (0, e.jsx)("label", {
634
- className: d["rst-dashboard-builder-field-label"],
696
+ className: n["rst-dashboard-builder-field-label"],
635
697
  children: "Subtitle"
636
- }), /* @__PURE__ */ (0, e.jsx)(pe, {
698
+ }), /* @__PURE__ */ (0, e.jsx)(_e, {
637
699
  value: r.subtitle ?? "",
638
- onChange: (a) => j("subtitle", a || void 0),
700
+ onChange: (t) => o("subtitle", t || void 0),
639
701
  placeholder: "Optional subtitle"
640
702
  })]
641
703
  }),
642
704
  /* @__PURE__ */ (0, e.jsxs)("div", {
643
- className: d["rst-dashboard-builder-field"],
705
+ className: n["rst-dashboard-builder-field"],
644
706
  children: [/* @__PURE__ */ (0, e.jsx)("label", {
645
- className: d["rst-dashboard-builder-field-label"],
707
+ className: n["rst-dashboard-builder-field-label"],
646
708
  children: "Icon"
647
- }), /* @__PURE__ */ (0, e.jsx)(xe, {
709
+ }), /* @__PURE__ */ (0, e.jsx)(ge, {
648
710
  value: r.icon ?? "",
649
- onChange: (a) => j("icon", a || void 0),
650
- options: l,
651
- renderList: ({ options: a, value: i, onChange: O, onClose: t }) => /* @__PURE__ */ (0, e.jsx)(ze, {
652
- options: a,
653
- activeIndex: [typeof i == "string" ? i : ""],
654
- onClick: (n) => {
655
- O(n.value), t();
711
+ onChange: (t) => o("icon", t || void 0),
712
+ options: c,
713
+ renderList: ({ options: t, value: l, onChange: B, onClose: u }) => /* @__PURE__ */ (0, e.jsx)(Te, {
714
+ options: t,
715
+ activeIndex: [typeof l == "string" ? l : ""],
716
+ onClick: (x) => {
717
+ B(x.value), u();
656
718
  },
657
719
  showFilter: !0
658
720
  })
659
721
  })]
660
722
  }),
661
723
  /* @__PURE__ */ (0, e.jsxs)("div", {
662
- className: d["rst-dashboard-builder-field"],
724
+ className: n["rst-dashboard-builder-field"],
663
725
  children: [/* @__PURE__ */ (0, e.jsx)("label", {
664
- className: d["rst-dashboard-builder-field-label"],
726
+ className: n["rst-dashboard-builder-field-label"],
665
727
  children: "Data Source"
666
- }), /* @__PURE__ */ (0, e.jsx)(xe, {
728
+ }), /* @__PURE__ */ (0, e.jsx)(ge, {
667
729
  value: r.dataSourceId,
668
- onChange: (a) => j("dataSourceId", a),
669
- options: D
730
+ onChange: (t) => o("dataSourceId", t),
731
+ options: k
670
732
  })]
671
733
  }),
672
- r.dataSourceId && u[r.dataSourceId] && /* @__PURE__ */ (0, e.jsxs)("div", {
673
- className: d["rst-dashboard-builder-field"],
734
+ r.dataSourceId && a[r.dataSourceId] && /* @__PURE__ */ (0, e.jsxs)("div", {
735
+ className: n["rst-dashboard-builder-field"],
674
736
  children: [/* @__PURE__ */ (0, e.jsx)("label", {
675
- className: d["rst-dashboard-builder-field-label"],
737
+ className: n["rst-dashboard-builder-field-label"],
676
738
  children: "Columns"
677
- }), /* @__PURE__ */ (0, e.jsx)(Re, {
678
- options: u[r.dataSourceId].fields.map((a) => ({
679
- value: a.id,
680
- label: a.name
739
+ }), /* @__PURE__ */ (0, e.jsx)($e, {
740
+ options: a[r.dataSourceId].fields.map((t) => ({
741
+ value: t.id,
742
+ label: t.name
681
743
  })),
682
- value: r.columns?.map((a) => a.id).filter(Boolean) ?? u[r.dataSourceId].fields.map((a) => a.id),
683
- onChange: (a) => {
684
- const i = u[r.dataSourceId], O = a.map((t) => i.fields.find((n) => n.id === t)).filter(Boolean).map((t) => ({
685
- id: t.id,
686
- header: t.name,
687
- accessorKey: t.id
744
+ value: r.columns?.map((t) => t.id).filter(Boolean) ?? a[r.dataSourceId].fields.map((t) => t.id),
745
+ onChange: (t) => {
746
+ const l = a[r.dataSourceId], B = t.map((u) => l.fields.find((x) => x.id === u)).filter(Boolean).map((u) => ({
747
+ id: u.id,
748
+ header: u.name,
749
+ accessorKey: u.id
688
750
  }));
689
- m({ columns: O.length === i.fields.length ? void 0 : O });
751
+ i({ columns: B.length === l.fields.length ? void 0 : B });
690
752
  }
691
753
  })]
692
754
  }),
693
755
  /* @__PURE__ */ (0, e.jsxs)("div", {
694
- className: d["rst-dashboard-builder-field"],
756
+ className: n["rst-dashboard-builder-field"],
695
757
  children: [
696
758
  /* @__PURE__ */ (0, e.jsx)("label", {
697
- className: d["rst-dashboard-builder-field-label"],
759
+ className: n["rst-dashboard-builder-field-label"],
698
760
  children: "Actions"
699
761
  }),
700
762
  /* @__PURE__ */ (0, e.jsxs)("div", {
701
- className: d["rst-dashboard-builder-checkbox-row"],
702
- children: [/* @__PURE__ */ (0, e.jsx)(le, {
763
+ className: n["rst-dashboard-builder-checkbox-row"],
764
+ children: [/* @__PURE__ */ (0, e.jsx)(ue, {
703
765
  checked: r.enableExport ?? !0,
704
- onChange: (a) => j("enableExport", a)
766
+ onChange: (t) => o("enableExport", t)
705
767
  }), /* @__PURE__ */ (0, e.jsx)("span", {
706
- className: d["rst-dashboard-builder-checkbox-label"],
768
+ className: n["rst-dashboard-builder-checkbox-label"],
707
769
  children: "Export CSV"
708
770
  })]
709
771
  }),
710
772
  /* @__PURE__ */ (0, e.jsxs)("div", {
711
- className: d["rst-dashboard-builder-checkbox-row"],
712
- children: [/* @__PURE__ */ (0, e.jsx)(le, {
773
+ className: n["rst-dashboard-builder-checkbox-row"],
774
+ children: [/* @__PURE__ */ (0, e.jsx)(ue, {
713
775
  checked: r.enableScreenshot ?? !1,
714
- onChange: (a) => j("enableScreenshot", a)
776
+ onChange: (t) => o("enableScreenshot", t)
715
777
  }), /* @__PURE__ */ (0, e.jsx)("span", {
716
- className: d["rst-dashboard-builder-checkbox-label"],
778
+ className: n["rst-dashboard-builder-checkbox-label"],
717
779
  children: "Screenshot"
718
780
  })]
719
781
  }),
720
782
  /* @__PURE__ */ (0, e.jsxs)("div", {
721
- className: d["rst-dashboard-builder-checkbox-row"],
722
- children: [/* @__PURE__ */ (0, e.jsx)(le, {
783
+ className: n["rst-dashboard-builder-checkbox-row"],
784
+ children: [/* @__PURE__ */ (0, e.jsx)(ue, {
723
785
  checked: r.enableExpand ?? !0,
724
- onChange: (a) => j("enableExpand", a)
786
+ onChange: (t) => o("enableExpand", t)
725
787
  }), /* @__PURE__ */ (0, e.jsx)("span", {
726
- className: d["rst-dashboard-builder-checkbox-label"],
788
+ className: n["rst-dashboard-builder-checkbox-label"],
727
789
  children: "Expand"
728
790
  })]
729
791
  }),
730
792
  /* @__PURE__ */ (0, e.jsxs)("div", {
731
- className: d["rst-dashboard-builder-checkbox-row"],
732
- children: [/* @__PURE__ */ (0, e.jsx)(le, {
793
+ className: n["rst-dashboard-builder-checkbox-row"],
794
+ children: [/* @__PURE__ */ (0, e.jsx)(ue, {
733
795
  checked: r.enableFilter ?? !0,
734
- onChange: (a) => j("enableFilter", a)
796
+ onChange: (t) => o("enableFilter", t)
735
797
  }), /* @__PURE__ */ (0, e.jsx)("span", {
736
- className: d["rst-dashboard-builder-checkbox-label"],
798
+ className: n["rst-dashboard-builder-checkbox-label"],
737
799
  children: "Filter"
738
800
  })]
739
801
  })
740
802
  ]
741
803
  }),
742
- /* @__PURE__ */ (0, e.jsx)("div", { className: d["rst-dashboard-builder-configurator-divider"] }),
743
- /* @__PURE__ */ (0, e.jsx)(Fe, {
744
- schema: z,
745
- values: P,
746
- onChange: X,
747
- columns: I,
804
+ /* @__PURE__ */ (0, e.jsx)("div", { className: n["rst-dashboard-builder-configurator-divider"] }),
805
+ /* @__PURE__ */ (0, e.jsx)(Le, {
806
+ schema: w,
807
+ values: R,
808
+ onChange: L,
809
+ columns: g,
748
810
  scope: "all",
749
811
  componentId: r.componentType,
750
- onComponentChange: T,
751
- componentMetaList: Se
812
+ onComponentChange: E,
813
+ componentMetaList: Pe
752
814
  }, r.dataSourceId ?? "no-ds"),
753
- /* @__PURE__ */ (0, e.jsx)("div", { className: d["rst-dashboard-builder-configurator-divider"] }),
754
- /* @__PURE__ */ (0, e.jsx)(U, {
815
+ /* @__PURE__ */ (0, e.jsx)("div", { className: n["rst-dashboard-builder-configurator-divider"] }),
816
+ /* @__PURE__ */ (0, e.jsx)(Z, {
755
817
  variant: "danger",
756
818
  size: "small",
757
819
  value: "Remove widget",
758
820
  leadingVisual: "trash",
759
- onClick: c
821
+ onClick: s
760
822
  })
761
823
  ]
762
824
  })]
763
825
  }) : /* @__PURE__ */ (0, e.jsxs)("aside", {
764
- className: d["rst-dashboard-builder-configurator"],
826
+ className: n["rst-dashboard-builder-configurator"],
765
827
  "aria-label": "Add widget",
766
828
  children: [/* @__PURE__ */ (0, e.jsx)("div", {
767
- className: d["rst-dashboard-builder-configurator-header"],
768
- children: /* @__PURE__ */ (0, e.jsx)(ce, {
829
+ className: n["rst-dashboard-builder-configurator-header"],
830
+ children: /* @__PURE__ */ (0, e.jsx)(te, {
769
831
  variant: "heading",
770
832
  children: "Add Widget"
771
833
  })
772
834
  }), /* @__PURE__ */ (0, e.jsxs)("div", {
773
- className: d["rst-dashboard-builder-configurator-body"],
774
- children: [Xe.map((a) => /* @__PURE__ */ (0, e.jsxs)("button", {
775
- className: d["rst-dashboard-builder-add-widget-item"],
776
- onClick: () => x(a.type),
777
- children: [/* @__PURE__ */ (0, e.jsx)(fe, { src: a.icon }), /* @__PURE__ */ (0, e.jsxs)("div", { children: [/* @__PURE__ */ (0, e.jsx)("div", {
778
- className: d["rst-dashboard-builder-add-widget-item-label"],
779
- children: a.label
835
+ className: n["rst-dashboard-builder-configurator-body"],
836
+ children: [cr.map((t) => /* @__PURE__ */ (0, e.jsxs)("button", {
837
+ className: n["rst-dashboard-builder-add-widget-item"],
838
+ onClick: () => h(t.type),
839
+ children: [/* @__PURE__ */ (0, e.jsx)(ve, { src: t.icon }), /* @__PURE__ */ (0, e.jsxs)("div", { children: [/* @__PURE__ */ (0, e.jsx)("div", {
840
+ className: n["rst-dashboard-builder-add-widget-item-label"],
841
+ children: t.label
780
842
  }), /* @__PURE__ */ (0, e.jsx)("div", {
781
- className: d["rst-dashboard-builder-add-widget-item-desc"],
782
- children: a.description
843
+ className: n["rst-dashboard-builder-add-widget-item-desc"],
844
+ children: t.description
783
845
  })] })]
784
- }, a.type)), H.length > 0 && /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [
785
- /* @__PURE__ */ (0, e.jsx)("div", { className: d["rst-dashboard-builder-configurator-divider"] }),
786
- /* @__PURE__ */ (0, e.jsx)(ce, {
846
+ }, t.type)), O.length > 0 && /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [
847
+ /* @__PURE__ */ (0, e.jsx)("div", { className: n["rst-dashboard-builder-configurator-divider"] }),
848
+ /* @__PURE__ */ (0, e.jsx)(te, {
787
849
  variant: "heading",
788
850
  children: "Pre-built Sections"
789
851
  }),
790
- H.map((a) => /* @__PURE__ */ (0, e.jsxs)("button", {
791
- className: d["rst-dashboard-builder-add-widget-item"],
792
- onClick: () => S?.(a),
793
- children: [/* @__PURE__ */ (0, e.jsx)(fe, { src: "layout" }), /* @__PURE__ */ (0, e.jsxs)("div", { children: [/* @__PURE__ */ (0, e.jsx)("div", {
794
- className: d["rst-dashboard-builder-add-widget-item-label"],
795
- children: a.name
852
+ O.map((t) => /* @__PURE__ */ (0, e.jsxs)("button", {
853
+ className: n["rst-dashboard-builder-add-widget-item"],
854
+ onClick: () => j?.(t),
855
+ children: [/* @__PURE__ */ (0, e.jsx)(ve, { src: "layout" }), /* @__PURE__ */ (0, e.jsxs)("div", { children: [/* @__PURE__ */ (0, e.jsx)("div", {
856
+ className: n["rst-dashboard-builder-add-widget-item-label"],
857
+ children: t.name
796
858
  }), /* @__PURE__ */ (0, e.jsx)("div", {
797
- className: d["rst-dashboard-builder-add-widget-item-desc"],
798
- children: a.description
859
+ className: n["rst-dashboard-builder-add-widget-item-desc"],
860
+ children: t.description
799
861
  })] })]
800
- }, a.name))
862
+ }, t.name))
801
863
  ] })]
802
864
  })]
803
865
  });
804
866
  };
805
- De.displayName = "WidgetConfigurator";
806
- var Ke = ({ dataSources: r, initialConfig: u, templates: m, prebuiltSections: c, onSave: y, onChange: x, widgetActionDefaults: p, readOnly: S, className: D }) => {
807
- const { state: l, mode: _, setMode: I, addWidget: z, addPrebuiltWidget: P, removeWidget: j, updateWidget: T, moveWidget: X, selectWidget: H, selectedWidget: a, setName: i, setFilters: O, loadConfig: t } = $e(u, S), [n, N] = W(!1), [s, g] = W("dialog"), [R, Q] = W(null), [Z, ee] = W(null), [h, te] = W(!1), [b, v] = W(null), C = J(() => Le(l.config.widgets, r), [l.config.widgets, r]), k = _ === "view", L = k ? Z : l.config.filters;
808
- oe(() => {
809
- n && v(L);
810
- }, [n]);
811
- const se = f(() => {
812
- k ? ee(b) : O(b), N(!1);
867
+ ze.displayName = "WidgetConfigurator";
868
+ var ur = ({ dataSources: r, initialConfig: a, templates: i, prebuiltSections: s, onSave: b, onChange: h, widgetActionDefaults: p, readOnly: j, className: k }) => {
869
+ const { state: c, mode: f, setMode: g, addWidget: w, addPrebuiltWidget: R, removeWidget: o, updateWidget: E, moveWidget: L, selectWidget: O, selectedWidget: t, setName: l, setFilters: B, loadConfig: u } = ir(a, j), [x, W] = D(!1), [d, C] = D("dialog"), [P, U] = D(null), [ee, re] = D(null), [_, le] = D(!1), [v, N] = D(null), z = X(() => dr(c.config.widgets, r), [c.config.widgets, r]), M = f === "view", G = M ? ee : c.config.filters;
870
+ se(() => {
871
+ x && N(G);
872
+ }, [x]);
873
+ const ne = y(() => {
874
+ M ? re(v) : B(v), W(!1);
813
875
  }, [
814
- b,
815
- k,
816
- O
876
+ v,
877
+ M,
878
+ B
817
879
  ]);
818
- oe(() => {
819
- k && !h && (ee(l.config.filters), te(!0)), k || te(!1);
880
+ se(() => {
881
+ M && !_ && (re(c.config.filters), le(!0)), M || le(!1);
820
882
  }, [
821
- k,
822
- h,
823
- l.config.filters
883
+ M,
884
+ _,
885
+ c.config.filters
824
886
  ]);
825
- const V = me(x);
826
- V.current = x;
827
- const $ = f((o, G) => {
828
- (k ? ee : O)((ae) => ({
887
+ const Y = ie(h);
888
+ Y.current = h;
889
+ const H = y((m, $) => {
890
+ (M ? re : B)((ae) => ({
829
891
  ...ae ?? {},
830
- [o]: G
892
+ [m]: $
831
893
  }));
832
- }, [k, O]), E = J(() => ({
833
- filters: L,
834
- onFilterChange: $
835
- }), [L, $]), M = J(() => !m || m.length === 0 ? [] : m.filter((o) => o.version === 1), [m]), A = J(() => M.map((o) => ({
836
- value: o.name,
837
- id: o.name,
838
- description: o.description
839
- })), [M]), Y = f((o) => {
840
- const G = M.find((K) => K.name === o);
841
- if (!G) return;
894
+ }, [M, B]), T = X(() => ({
895
+ filters: G,
896
+ onFilterChange: H
897
+ }), [G, H]), I = X(() => !i || i.length === 0 ? [] : i.filter((m) => m.version === 1), [i]), q = X(() => I.map((m) => ({
898
+ value: m.name,
899
+ id: m.name,
900
+ description: m.description
901
+ })), [I]), K = y((m) => {
902
+ const $ = I.find((J) => J.name === m);
903
+ if (!$) return;
842
904
  const ae = {
843
905
  version: 1,
844
- ...G.config
906
+ ...$.config
845
907
  };
846
- t(ae);
847
- }, [M, t]), F = J(() => ({
908
+ u(ae);
909
+ }, [I, u]), F = X(() => ({
848
910
  enableExport: p?.enableExport ?? !0,
849
911
  enableScreenshot: p?.enableScreenshot ?? !1,
850
912
  enableExpand: p?.enableExpand ?? !0,
851
913
  enableFilter: p?.enableFilter ?? !0
852
- }), [p]), ie = f((o) => ({
853
- enableExport: o.enableExport ?? F.enableExport,
854
- enableScreenshot: o.enableScreenshot ?? F.enableScreenshot,
855
- enableExpand: o.enableExpand ?? F.enableExpand,
856
- enableFilter: o.enableFilter ?? F.enableFilter
914
+ }), [p]), ce = y((m) => ({
915
+ enableExport: m.enableExport ?? F.enableExport,
916
+ enableScreenshot: m.enableScreenshot ?? F.enableScreenshot,
917
+ enableExpand: m.enableExpand ?? F.enableExpand,
918
+ enableFilter: m.enableFilter ?? F.enableFilter
857
919
  }), [F]);
858
- oe(() => {
859
- V.current?.(l.config);
860
- }, [l.config]);
861
- const w = [d["rst-dashboard-builder"], D].filter(Boolean).join(" "), B = f(() => {
862
- y(l.config);
863
- }, [l.config, y]);
920
+ se(() => {
921
+ Y.current?.(c.config);
922
+ }, [c.config]);
923
+ const S = [n["rst-dashboard-builder"], k].filter(Boolean).join(" "), A = y(() => {
924
+ b(c.config);
925
+ }, [c.config, b]);
864
926
  return /* @__PURE__ */ (0, e.jsx)("div", {
865
- className: w,
927
+ className: S,
866
928
  children: /* @__PURE__ */ (0, e.jsxs)("div", {
867
- className: d["rst-dashboard-builder-main"],
929
+ className: n["rst-dashboard-builder-main"],
868
930
  children: [/* @__PURE__ */ (0, e.jsxs)("div", {
869
- className: d["rst-dashboard-builder-toolbar"],
931
+ className: n["rst-dashboard-builder-toolbar"],
870
932
  children: [/* @__PURE__ */ (0, e.jsxs)("div", {
871
- className: d["rst-dashboard-builder-toolbar-left"],
872
- children: [k ? /* @__PURE__ */ (0, e.jsx)("span", {
873
- className: d["rst-dashboard-builder-name-display"],
874
- children: l.config.name
933
+ className: n["rst-dashboard-builder-toolbar-left"],
934
+ children: [M ? /* @__PURE__ */ (0, e.jsx)("span", {
935
+ className: n["rst-dashboard-builder-name-display"],
936
+ children: c.config.name
875
937
  }) : /* @__PURE__ */ (0, e.jsx)("input", {
876
- className: d["rst-dashboard-builder-name-input"],
938
+ className: n["rst-dashboard-builder-name-input"],
877
939
  type: "text",
878
- value: l.config.name,
879
- onChange: (o) => i(o.target.value),
940
+ value: c.config.name,
941
+ onChange: (m) => l(m.target.value),
880
942
  placeholder: "Dashboard name",
881
943
  "aria-label": "Dashboard name"
882
- }), Object.keys(C).length > 0 && /* @__PURE__ */ (0, e.jsx)(U, {
944
+ }), Object.keys(z).length > 0 && /* @__PURE__ */ (0, e.jsx)(Z, {
883
945
  variant: "invisible",
884
946
  size: "small",
885
947
  leadingVisual: "filter",
886
- onClick: () => N((o) => !o),
948
+ onClick: () => W((m) => !m),
887
949
  "aria-label": "Toggle filter panel",
888
- "aria-pressed": n
950
+ "aria-pressed": x
889
951
  })]
890
952
  }), /* @__PURE__ */ (0, e.jsxs)("div", {
891
- className: d["rst-dashboard-builder-toolbar-right"],
953
+ className: n["rst-dashboard-builder-toolbar-right"],
892
954
  children: [
893
- M.length > 0 && !k && /* @__PURE__ */ (0, e.jsx)(We, {
894
- options: A,
895
- onChange: Y,
955
+ I.length > 0 && !M && /* @__PURE__ */ (0, e.jsx)(Oe, {
956
+ options: q,
957
+ onChange: K,
896
958
  placeholder: "Load Template",
897
959
  size: "small"
898
960
  }),
899
- !S && /* @__PURE__ */ (0, e.jsx)(Me, {
900
- value: _,
961
+ !j && /* @__PURE__ */ (0, e.jsx)(Ee, {
962
+ value: f,
901
963
  options: [{ value: "edit" }, { value: "view" }],
902
- onChange: (o) => I(o)
964
+ onChange: (m) => g(m)
903
965
  }),
904
- !k && /* @__PURE__ */ (0, e.jsx)(U, {
966
+ !M && /* @__PURE__ */ (0, e.jsx)(Z, {
905
967
  variant: "primary",
906
968
  size: "small",
907
969
  value: "Save",
908
- onClick: B
970
+ onClick: A
909
971
  })
910
972
  ]
911
973
  })]
912
- }), /* @__PURE__ */ (0, e.jsx)(Ee, {
913
- value: E,
974
+ }), /* @__PURE__ */ (0, e.jsx)(Ve, {
975
+ value: T,
914
976
  children: /* @__PURE__ */ (0, e.jsxs)("div", {
915
977
  style: {
916
978
  display: "flex",
@@ -918,100 +980,100 @@ var Ke = ({ dataSources: r, initialConfig: u, templates: m, prebuiltSections: c,
918
980
  overflow: "hidden"
919
981
  },
920
982
  children: [
921
- /* @__PURE__ */ (0, e.jsx)(ye, {
922
- mode: _,
923
- widgets: l.config.widgets,
924
- selectedWidgetId: l.selectedWidgetId,
983
+ /* @__PURE__ */ (0, e.jsx)(De, {
984
+ mode: f,
985
+ widgets: c.config.widgets,
986
+ selectedWidgetId: c.selectedWidgetId,
925
987
  dataSources: r,
926
- onSelectWidget: H,
927
- onMoveWidget: X,
928
- onRemoveWidget: j,
929
- onAddWidget: z,
988
+ onSelectWidget: O,
989
+ onMoveWidget: L,
990
+ onRemoveWidget: o,
991
+ onAddWidget: w,
930
992
  onChange: () => {
931
993
  },
932
- getWidgetActions: ie
994
+ getWidgetActions: ce
933
995
  }),
934
- n && Object.keys(C).length > 0 && /* @__PURE__ */ (0, e.jsxs)(ue, {
935
- open: n,
936
- variant: s,
937
- position: s === "dialog" ? "center" : "right",
938
- onClose: () => N(!1),
996
+ x && Object.keys(z).length > 0 && /* @__PURE__ */ (0, e.jsxs)(me, {
997
+ open: x,
998
+ variant: d,
999
+ position: d === "dialog" ? "center" : "right",
1000
+ onClose: () => W(!1),
939
1001
  closeOnEscape: !0,
940
- closeOnClickOutside: s === "dialog",
941
- width: s === "sidepanel" ? 360 : void 0,
942
- maxWidth: s === "dialog" ? 640 : void 0,
943
- maxHeight: s === "dialog" ? "80vh" : void 0,
1002
+ closeOnClickOutside: d === "dialog",
1003
+ width: d === "sidepanel" ? 360 : void 0,
1004
+ maxWidth: d === "dialog" ? 640 : void 0,
1005
+ maxHeight: d === "dialog" ? "80vh" : void 0,
944
1006
  "aria-label": "Dashboard filters",
945
1007
  children: [
946
- /* @__PURE__ */ (0, e.jsx)(ue.Header, {
1008
+ /* @__PURE__ */ (0, e.jsx)(me.Header, {
947
1009
  title: "Filters",
948
- onClose: () => N(!1),
949
- actions: /* @__PURE__ */ (0, e.jsx)(U, {
1010
+ onClose: () => W(!1),
1011
+ actions: /* @__PURE__ */ (0, e.jsx)(Z, {
950
1012
  variant: "invisible",
951
1013
  size: "small",
952
- leadingVisual: s === "dialog" ? "square-half" : "open-center",
953
- onClick: () => g((o) => o === "dialog" ? "sidepanel" : "dialog"),
954
- "aria-label": s === "dialog" ? "Switch to side panel" : "Switch to dialog"
1014
+ leadingVisual: d === "dialog" ? "square-half" : "open-center",
1015
+ onClick: () => C((m) => m === "dialog" ? "sidepanel" : "dialog"),
1016
+ "aria-label": d === "dialog" ? "Switch to side panel" : "Switch to dialog"
955
1017
  })
956
1018
  }),
957
1019
  /* @__PURE__ */ (0, e.jsx)("div", {
958
- className: d["rst-dashboard-builder-filter-body"],
1020
+ className: n["rst-dashboard-builder-filter-body"],
959
1021
  children: (() => {
960
- const o = Object.keys(C);
961
- if (o.length === 0) return /* @__PURE__ */ (0, e.jsx)("div", {
1022
+ const m = Object.keys(z);
1023
+ if (m.length === 0) return /* @__PURE__ */ (0, e.jsx)("div", {
962
1024
  style: { padding: "var(--rst-space-default)" },
963
1025
  children: "No data sources to filter."
964
1026
  });
965
- const G = R && o.includes(R) ? R : o[0], ae = b?.[G] ?? Te();
1027
+ const $ = P && m.includes(P) ? P : m[0], ae = v?.[$] ?? Ye();
966
1028
  return /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [/* @__PURE__ */ (0, e.jsx)("div", {
967
- className: d["rst-dashboard-builder-filter-tabs"],
968
- children: o.map((K) => /* @__PURE__ */ (0, e.jsx)(U, {
969
- value: K,
970
- variant: K === G ? "base" : "invisible",
1029
+ className: n["rst-dashboard-builder-filter-tabs"],
1030
+ children: m.map((J) => /* @__PURE__ */ (0, e.jsx)(Z, {
1031
+ value: J,
1032
+ variant: J === $ ? "base" : "invisible",
971
1033
  size: "small",
972
- onClick: () => Q(K),
973
- children: K
974
- }, K))
975
- }), /* @__PURE__ */ (0, e.jsx)(Pe, {
1034
+ onClick: () => U(J),
1035
+ children: J
1036
+ }, J))
1037
+ }), /* @__PURE__ */ (0, e.jsx)(Ge, {
976
1038
  filters: ae,
977
- onChange: (K) => v((Ne) => ({
978
- ...Ne ?? {},
979
- [G]: K.filters.length === 0 ? null : K
1039
+ onChange: (J) => N((We) => ({
1040
+ ...We ?? {},
1041
+ [$]: J.filters.length === 0 ? null : J
980
1042
  })),
981
- fieldOptions: C[G]
1043
+ fieldOptions: z[$]
982
1044
  })] });
983
1045
  })()
984
1046
  }),
985
- /* @__PURE__ */ (0, e.jsxs)(ue.Footer, { children: [/* @__PURE__ */ (0, e.jsx)(U, {
1047
+ /* @__PURE__ */ (0, e.jsxs)(me.Footer, { children: [/* @__PURE__ */ (0, e.jsx)(Z, {
986
1048
  variant: "invisible",
987
1049
  size: "small",
988
1050
  value: "Clear",
989
- onClick: () => v({})
990
- }), /* @__PURE__ */ (0, e.jsx)(U, {
1051
+ onClick: () => N({})
1052
+ }), /* @__PURE__ */ (0, e.jsx)(Z, {
991
1053
  variant: "primary",
992
1054
  size: "small",
993
1055
  value: "Apply",
994
- onClick: se
1056
+ onClick: ne
995
1057
  })] })
996
1058
  ]
997
1059
  }),
998
- !k && /* @__PURE__ */ (0, e.jsx)(De, {
999
- widget: a,
1060
+ !M && /* @__PURE__ */ (0, e.jsx)(ze, {
1061
+ widget: t,
1000
1062
  dataSources: r,
1001
- onUpdate: (o) => {
1002
- a && T(a.id, o);
1063
+ onUpdate: (m) => {
1064
+ t && E(t.id, m);
1003
1065
  },
1004
1066
  onRemove: () => {
1005
- a && j(a.id);
1067
+ t && o(t.id);
1006
1068
  },
1007
- onClose: () => H(null),
1008
- onAddWidget: (o) => {
1009
- const G = Object.values(r)[0], ae = Ce(6, 3, l.config.widgets);
1010
- z(o, G?.id ?? "", ae);
1069
+ onClose: () => O(null),
1070
+ onAddWidget: (m) => {
1071
+ const $ = Object.values(r)[0], ae = Me(6, 3, c.config.widgets);
1072
+ w(m, $?.id ?? "", ae);
1011
1073
  },
1012
- prebuiltSections: c,
1013
- onAddPrebuiltSection: (o) => {
1014
- P(o);
1074
+ prebuiltSections: s,
1075
+ onAddPrebuiltSection: (m) => {
1076
+ R(m);
1015
1077
  }
1016
1078
  })
1017
1079
  ]
@@ -1020,8 +1082,279 @@ var Ke = ({ dataSources: r, initialConfig: u, templates: m, prebuiltSections: c,
1020
1082
  })
1021
1083
  });
1022
1084
  };
1023
- Ke.displayName = "DashboardBuilder";
1085
+ ur.displayName = "DashboardBuilder";
1086
+ var he = {
1087
+ "rst-border-beam": "_rst-border-beam_4g5sg_1",
1088
+ "rst-border-beam-effect": "_rst-border-beam-effect_4g5sg_7",
1089
+ "rst-border-beam-ring": "_rst-border-beam-ring_4g5sg_15",
1090
+ "rst-border-beam-spin": "_rst-border-beam-spin_4g5sg_27",
1091
+ "rst-border-beam-travel": "_rst-border-beam-travel_4g5sg_1"
1092
+ };
1093
+ function hr(r) {
1094
+ return [...r].filter((a) => a.color).map((a) => ({
1095
+ ...a,
1096
+ percent: Math.min(100, Math.max(0, a.percent))
1097
+ })).sort((a, i) => a.percent - i.percent);
1098
+ }
1099
+ function br(r, a, i, s) {
1100
+ const b = 360 / Math.max(1, s), h = 2 * (a + i);
1101
+ return h <= 0 || r <= 0 ? Math.min(90, b) : Math.min(r / h * 360, b);
1102
+ }
1103
+ function mr(r, a) {
1104
+ const i = Math.max(0, Math.min(a, 360)), s = hr(r);
1105
+ return `conic-gradient(from 0deg, ${s.length ? s.map((b) => `${b.color} ${b.percent / 100 * i}deg`).join(", ") : "var(--rst-borderColor-focus) 0deg"}, transparent ${i}deg, transparent 360deg)`;
1106
+ }
1107
+ var xr = [
1108
+ {
1109
+ color: "transparent",
1110
+ percent: 0
1111
+ },
1112
+ {
1113
+ color: "var(--rst-borderColor-primary-default)",
1114
+ percent: 70
1115
+ },
1116
+ {
1117
+ color: "var(--rst-borderColor-focus)",
1118
+ percent: 100
1119
+ }
1120
+ ], pr = ({ children: r, color: a = xr, count: i = 1, duration: s = 6, lineWidth: b = 1, outset: h = 0, inset: p = 0, size: j = 120, className: k, style: c, ...f }) => {
1121
+ const g = ie(null), [w, R] = D({
1122
+ radius: "",
1123
+ width: 0,
1124
+ height: 0
1125
+ });
1126
+ se(() => {
1127
+ const t = g.current?.firstElementChild;
1128
+ if (!t || typeof ResizeObserver > "u") return;
1129
+ const l = new ResizeObserver(() => {
1130
+ R({
1131
+ radius: getComputedStyle(t).borderTopLeftRadius,
1132
+ width: t.clientWidth,
1133
+ height: t.clientHeight
1134
+ });
1135
+ });
1136
+ return l.observe(t), () => l.disconnect();
1137
+ }, []);
1138
+ const o = Math.max(1, Math.floor(i)), E = X(() => mr(a, br(j, w.width, w.height, o)), [
1139
+ a,
1140
+ j,
1141
+ w.width,
1142
+ w.height,
1143
+ o
1144
+ ]), L = 360 / o, O = Math.hypot(w.width + 2 * h, w.height + 2 * h);
1145
+ return /* @__PURE__ */ (0, e.jsxs)("div", {
1146
+ ref: g,
1147
+ className: [he["rst-border-beam"], k].filter(Boolean).join(" "),
1148
+ style: {
1149
+ "--rst-border-beam-gradient": E,
1150
+ "--rst-border-beam-duration": `${s}s`,
1151
+ "--rst-border-beam-line-width": `${b}px`,
1152
+ "--rst-border-beam-outset": `${h}px`,
1153
+ "--rst-border-beam-inset": `${p}px`,
1154
+ ...O > 0 ? { "--rst-border-beam-diagonal": `${O}px` } : {},
1155
+ ...w.radius ? { "--rst-border-beam-radius": w.radius } : {},
1156
+ ...c
1157
+ },
1158
+ ...f,
1159
+ children: [r, /* @__PURE__ */ (0, e.jsx)("span", {
1160
+ className: he["rst-border-beam-effect"],
1161
+ "aria-hidden": "true",
1162
+ children: /* @__PURE__ */ (0, e.jsx)("span", {
1163
+ className: he["rst-border-beam-ring"],
1164
+ children: Array.from({ length: o }, (t, l) => /* @__PURE__ */ (0, e.jsx)("span", {
1165
+ className: he["rst-border-beam-spin"],
1166
+ style: { "--rst-border-beam-offset": `${l * L}deg` }
1167
+ }, l))
1168
+ })
1169
+ })]
1170
+ });
1171
+ };
1172
+ pr.displayName = "BorderBeam";
1173
+ function fr(r) {
1174
+ return r.filter((a) => a.type === "text").map((a) => a.text).join(" ").trim();
1175
+ }
1176
+ function gr(r) {
1177
+ return r.data ?? [];
1178
+ }
1179
+ function Re(r, a) {
1180
+ return r.events?.includes(a) ?? !1;
1181
+ }
1182
+ function _r({ block: r, onBlockEvent: a }) {
1183
+ const i = gr(r), s = r.props ?? {};
1184
+ if (r.component === "form") return /* @__PURE__ */ (0, e.jsx)(vr, {
1185
+ block: r,
1186
+ onBlockEvent: a
1187
+ });
1188
+ if (r.component === "chart") {
1189
+ const b = s.height ?? 16;
1190
+ return /* @__PURE__ */ (0, e.jsx)(qe, {
1191
+ data: i,
1192
+ columns: r.columns,
1193
+ type: s.type ?? "bar",
1194
+ xAxisColumn: s.xAxisColumn,
1195
+ yAxisColumns: s.yAxisColumns,
1196
+ series: s.series,
1197
+ title: s.title,
1198
+ subtitle: s.subtitle,
1199
+ showLegend: s.showLegend,
1200
+ showGrid: s.showGrid,
1201
+ height: b
1202
+ });
1203
+ }
1204
+ return r.component === "kpi" ? /* @__PURE__ */ (0, e.jsx)(Fe, {
1205
+ data: i[0] ?? {},
1206
+ columns: r.columns,
1207
+ layout: Ie(s.layout)
1208
+ }) : r.component === "card-list" ? /* @__PURE__ */ (0, e.jsx)(Ze, {
1209
+ data: i,
1210
+ columns: r.columns,
1211
+ layout: Ae(s.layout),
1212
+ onCardClick: Re(r, "action") ? (b) => a?.({
1213
+ blockId: r.id,
1214
+ component: "card-list",
1215
+ event: "action",
1216
+ handler: r.handler,
1217
+ values: b
1218
+ }) : void 0
1219
+ }) : /* @__PURE__ */ (0, e.jsx)(Ke, {
1220
+ data: i,
1221
+ columns: r.columns,
1222
+ enableSorting: s.enableSorting !== !1,
1223
+ enableSelection: s.enableSelection === !0,
1224
+ showGrid: s.showGrid ?? "horizontal",
1225
+ columnSizing: "fixed",
1226
+ enableVirtualization: s.enableVirtualization !== !1
1227
+ });
1228
+ }
1229
+ function vr({ block: r, onBlockEvent: a }) {
1230
+ const [i, s] = D(!1);
1231
+ return Re(r, "submit") ? /* @__PURE__ */ (0, e.jsx)(fe, {
1232
+ data: r.data ?? [{}],
1233
+ columns: r.columns,
1234
+ labelAlign: "top",
1235
+ onSubmit: async (b) => {
1236
+ s(!0);
1237
+ try {
1238
+ await a?.({
1239
+ blockId: r.id,
1240
+ component: "form",
1241
+ event: "submit",
1242
+ handler: r.handler,
1243
+ values: b
1244
+ });
1245
+ } finally {
1246
+ s(!1);
1247
+ }
1248
+ },
1249
+ actions: [{
1250
+ type: "submit",
1251
+ variant: "primary",
1252
+ value: "Submit",
1253
+ loading: i,
1254
+ disabled: i
1255
+ }, {
1256
+ type: "reset",
1257
+ variant: "invisible",
1258
+ value: "Reset",
1259
+ disabled: i
1260
+ }]
1261
+ }) : /* @__PURE__ */ (0, e.jsx)(fe, {
1262
+ data: r.data ?? [{}],
1263
+ columns: r.columns
1264
+ });
1265
+ }
1266
+ var V = {
1267
+ "rst-chat": "_rst-chat_12syz_1",
1268
+ "rst-chat-empty": "_rst-chat-empty_12syz_9",
1269
+ "rst-chat-messages": "_rst-chat-messages_12syz_19",
1270
+ "rst-chat-message": "_rst-chat-message_12syz_19",
1271
+ "rst-chat-message-user": "_rst-chat-message-user_12syz_33",
1272
+ "rst-chat-message-assistant": "_rst-chat-message-assistant_12syz_37",
1273
+ "rst-chat-bubble": "_rst-chat-bubble_12syz_41",
1274
+ "rst-chat-bubble-user": "_rst-chat-bubble-user_12syz_51",
1275
+ "rst-chat-bubble-assistant": "_rst-chat-bubble-assistant_12syz_56",
1276
+ "rst-chat-text": "_rst-chat-text_12syz_63",
1277
+ "rst-chat-block": "_rst-chat-block_12syz_68",
1278
+ "rst-chat-block-title": "_rst-chat-block-title_12syz_76",
1279
+ "rst-chat-processing": "_rst-chat-processing_12syz_80",
1280
+ "rst-chat-composer": "_rst-chat-composer_12syz_84"
1281
+ };
1282
+ function Mr({ messages: r, isProcessing: a = !1, inputValue: i, onInputChange: s, onSubmit: b, onKeyDown: h, onBlockEvent: p, emptyStateText: j = "Ask a question to get started.", inputPlaceholder: k = "Ask something...", className: c, renderBlock: f }) {
1283
+ const g = ie(null);
1284
+ se(() => {
1285
+ const o = g.current;
1286
+ o && (o.scrollTop = o.scrollHeight);
1287
+ }, [r, a]);
1288
+ const w = a || i.trim().length === 0, R = (o, E) => o.type === "text" ? /* @__PURE__ */ (0, e.jsx)(te, {
1289
+ variant: "body",
1290
+ className: V["rst-chat-text"],
1291
+ children: o.text
1292
+ }, E) : /* @__PURE__ */ (0, e.jsxs)("div", {
1293
+ className: V["rst-chat-block"],
1294
+ children: [o.block.meta?.title && /* @__PURE__ */ (0, e.jsx)(te, {
1295
+ variant: "label",
1296
+ className: V["rst-chat-block-title"],
1297
+ children: o.block.meta.title
1298
+ }), f ? f(o.block) : /* @__PURE__ */ (0, e.jsx)(_r, {
1299
+ block: o.block,
1300
+ onBlockEvent: p
1301
+ })]
1302
+ }, o.block.id);
1303
+ return /* @__PURE__ */ (0, e.jsxs)("div", {
1304
+ className: [V["rst-chat"], c].filter(Boolean).join(" "),
1305
+ children: [r.length === 0 ? /* @__PURE__ */ (0, e.jsx)("div", {
1306
+ className: V["rst-chat-empty"],
1307
+ children: /* @__PURE__ */ (0, e.jsx)(te, {
1308
+ variant: "body",
1309
+ children: j
1310
+ })
1311
+ }) : /* @__PURE__ */ (0, e.jsxs)("div", {
1312
+ ref: g,
1313
+ className: V["rst-chat-messages"],
1314
+ role: "log",
1315
+ "aria-live": "polite",
1316
+ children: [r.map((o) => /* @__PURE__ */ (0, e.jsx)("article", {
1317
+ className: [V["rst-chat-message"], V[`rst-chat-message-${o.role}`]].join(" "),
1318
+ "aria-label": `${o.role === "user" ? "You" : "Assistant"}: ${fr(o.parts)}`,
1319
+ children: /* @__PURE__ */ (0, e.jsx)("div", {
1320
+ className: [V["rst-chat-bubble"], V[`rst-chat-bubble-${o.role}`]].join(" "),
1321
+ children: o.parts.map(R)
1322
+ })
1323
+ }, o.id)), a && /* @__PURE__ */ (0, e.jsx)("div", {
1324
+ className: V["rst-chat-processing"],
1325
+ children: /* @__PURE__ */ (0, e.jsx)(te, {
1326
+ variant: "caption",
1327
+ children: "Working..."
1328
+ })
1329
+ })]
1330
+ }), /* @__PURE__ */ (0, e.jsxs)("form", {
1331
+ className: V["rst-chat-composer"],
1332
+ onSubmit: (o) => {
1333
+ o.preventDefault(), w || b();
1334
+ },
1335
+ children: [/* @__PURE__ */ (0, e.jsx)(Qe, {
1336
+ value: i,
1337
+ onChange: s,
1338
+ onKeyDown: h,
1339
+ placeholder: k,
1340
+ ariaLabel: "Message",
1341
+ rows: 1,
1342
+ disabled: a
1343
+ }), /* @__PURE__ */ (0, e.jsx)(Z, {
1344
+ type: "submit",
1345
+ variant: "primary",
1346
+ value: "Send",
1347
+ leadingVisual: "send",
1348
+ disabled: w
1349
+ })]
1350
+ })]
1351
+ });
1352
+ }
1024
1353
  export {
1025
- Ze as DASHBOARD_CONFIG_VERSION,
1026
- Ke as DashboardBuilder
1354
+ pr as BorderBeam,
1355
+ Mr as ChatSurface,
1356
+ Sr as DASHBOARD_CONFIG_VERSION,
1357
+ ur as DashboardBuilder,
1358
+ kr as PipContainer,
1359
+ Nr as usePip
1027
1360
  };