@object-ui/plugin-report 0.1.0 → 2.0.0

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.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { ComponentRegistry as P } from "@object-ui/core";
2
- import fe, { useState as W } from "react";
3
- import { Card as z, CardHeader as ee, CardTitle as se, CardDescription as de, CardContent as Y, Button as E, Tabs as je, TabsList as ve, TabsTrigger as q, TabsContent as H, Label as x, Input as D } from "@object-ui/components";
4
- import { SchemaRenderer as ue } from "@object-ui/react";
5
- import { RefreshCw as ge, Printer as be, Download as Ne, Settings as ye, Layers as oe, Filter as we, Plus as I, Trash2 as Q, Save as Re } from "lucide-react";
6
- var ce = { exports: {} }, J = {};
1
+ import { ComponentRegistry as L } from "@object-ui/core";
2
+ import ke, { useState as W } from "react";
3
+ import { Card as B, CardHeader as ee, CardTitle as te, CardDescription as he, CardContent as z, Button as F, Label as b, Input as A, Tabs as Re, TabsList as Se, TabsTrigger as U, TabsContent as Y } from "@object-ui/components";
4
+ import { SchemaRenderer as pe } from "@object-ui/react";
5
+ import { RefreshCw as Ee, Printer as Te, Download as de, Calendar as je, Clock as Fe, Mail as _e, Settings as Ae, Layers as ue, Filter as $e, Plus as V, Trash2 as ae, Save as Oe } from "lucide-react";
6
+ var me = { exports: {} }, Q = {};
7
7
  /**
8
8
  * @license React
9
9
  * react-jsx-runtime.production.js
@@ -13,29 +13,29 @@ var ce = { exports: {} }, J = {};
13
13
  * This source code is licensed under the MIT license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
- var he;
17
- function Ee() {
18
- if (he) return J;
19
- he = 1;
20
- var v = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
21
- function u(d, m, N) {
22
- var S = null;
23
- if (N !== void 0 && (S = "" + N), m.key !== void 0 && (S = "" + m.key), "key" in m) {
24
- N = {};
25
- for (var i in m)
26
- i !== "key" && (N[i] = m[i]);
27
- } else N = m;
28
- return m = N.ref, {
29
- $$typeof: v,
30
- type: d,
31
- key: S,
32
- ref: m !== void 0 ? m : null,
33
- props: N
16
+ var xe;
17
+ function Pe() {
18
+ if (xe) return Q;
19
+ xe = 1;
20
+ var r = Symbol.for("react.transitional.element"), i = Symbol.for("react.fragment");
21
+ function s(c, d, p) {
22
+ var f = null;
23
+ if (p !== void 0 && (f = "" + p), d.key !== void 0 && (f = "" + d.key), "key" in d) {
24
+ p = {};
25
+ for (var n in d)
26
+ n !== "key" && (p[n] = d[n]);
27
+ } else p = d;
28
+ return d = p.ref, {
29
+ $$typeof: r,
30
+ type: c,
31
+ key: f,
32
+ ref: d !== void 0 ? d : null,
33
+ props: p
34
34
  };
35
35
  }
36
- return J.Fragment = c, J.jsx = u, J.jsxs = u, J;
36
+ return Q.Fragment = i, Q.jsx = s, Q.jsxs = s, Q;
37
37
  }
38
- var X = {};
38
+ var K = {};
39
39
  /**
40
40
  * @license React
41
41
  * react-jsx-runtime.development.js
@@ -45,395 +45,761 @@ var X = {};
45
45
  * This source code is licensed under the MIT license found in the
46
46
  * LICENSE file in the root directory of this source tree.
47
47
  */
48
- var me;
49
- function Ce() {
50
- return me || (me = 1, process.env.NODE_ENV !== "production" && function() {
51
- function v(s) {
52
- if (s == null) return null;
53
- if (typeof s == "function")
54
- return s.$$typeof === ae ? null : s.displayName || s.name || null;
55
- if (typeof s == "string") return s;
56
- switch (s) {
57
- case o:
48
+ var fe;
49
+ function Le() {
50
+ return fe || (fe = 1, process.env.NODE_ENV !== "production" && function() {
51
+ function r(t) {
52
+ if (t == null) return null;
53
+ if (typeof t == "function")
54
+ return t.$$typeof === ne ? null : t.displayName || t.name || null;
55
+ if (typeof t == "string") return t;
56
+ switch (t) {
57
+ case N:
58
58
  return "Fragment";
59
- case k:
59
+ case g:
60
60
  return "Profiler";
61
- case _:
61
+ case k:
62
62
  return "StrictMode";
63
- case B:
63
+ case O:
64
64
  return "Suspense";
65
- case re:
65
+ case q:
66
66
  return "SuspenseList";
67
- case M:
67
+ case J:
68
68
  return "Activity";
69
69
  }
70
- if (typeof s == "object")
71
- switch (typeof s.tag == "number" && console.error(
70
+ if (typeof t == "object")
71
+ switch (typeof t.tag == "number" && console.error(
72
72
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
73
- ), s.$$typeof) {
74
- case C:
73
+ ), t.$$typeof) {
74
+ case v:
75
75
  return "Portal";
76
- case O:
77
- return s.displayName || "Context";
78
- case A:
79
- return (s._context.displayName || "Context") + ".Consumer";
80
- case $:
81
- var n = s.render;
82
- return s = s.displayName, s || (s = n.displayName || n.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
83
- case te:
84
- return n = s.displayName || null, n !== null ? n : v(s.type) || "Memo";
85
- case L:
86
- n = s._payload, s = s._init;
76
+ case D:
77
+ return t.displayName || "Context";
78
+ case _:
79
+ return (t._context.displayName || "Context") + ".Consumer";
80
+ case M:
81
+ var x = t.render;
82
+ return t = t.displayName, t || (t = x.displayName || x.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
83
+ case H:
84
+ return x = t.displayName || null, x !== null ? x : r(t.type) || "Memo";
85
+ case I:
86
+ x = t._payload, t = t._init;
87
87
  try {
88
- return v(s(n));
88
+ return r(t(x));
89
89
  } catch {
90
90
  }
91
91
  }
92
92
  return null;
93
93
  }
94
- function c(s) {
95
- return "" + s;
94
+ function i(t) {
95
+ return "" + t;
96
96
  }
97
- function u(s) {
97
+ function s(t) {
98
98
  try {
99
- c(s);
100
- var n = !1;
99
+ i(t);
100
+ var x = !1;
101
101
  } catch {
102
- n = !0;
102
+ x = !0;
103
103
  }
104
- if (n) {
105
- n = console;
106
- var p = n.error, g = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
107
- return p.call(
108
- n,
104
+ if (x) {
105
+ x = console;
106
+ var C = x.error, S = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
107
+ return C.call(
108
+ x,
109
109
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
110
- g
111
- ), c(s);
110
+ S
111
+ ), i(t);
112
112
  }
113
113
  }
114
- function d(s) {
115
- if (s === o) return "<>";
116
- if (typeof s == "object" && s !== null && s.$$typeof === L)
114
+ function c(t) {
115
+ if (t === N) return "<>";
116
+ if (typeof t == "object" && t !== null && t.$$typeof === I)
117
117
  return "<...>";
118
118
  try {
119
- var n = v(s);
120
- return n ? "<" + n + ">" : "<...>";
119
+ var x = r(t);
120
+ return x ? "<" + x + ">" : "<...>";
121
121
  } catch {
122
122
  return "<...>";
123
123
  }
124
124
  }
125
- function m() {
126
- var s = F.A;
127
- return s === null ? null : s.getOwner();
125
+ function d() {
126
+ var t = P.A;
127
+ return t === null ? null : t.getOwner();
128
128
  }
129
- function N() {
129
+ function p() {
130
130
  return Error("react-stack-top-frame");
131
131
  }
132
- function S(s) {
133
- if (Z.call(s, "key")) {
134
- var n = Object.getOwnPropertyDescriptor(s, "key").get;
135
- if (n && n.isReactWarning) return !1;
132
+ function f(t) {
133
+ if (se.call(t, "key")) {
134
+ var x = Object.getOwnPropertyDescriptor(t, "key").get;
135
+ if (x && x.isReactWarning) return !1;
136
136
  }
137
- return s.key !== void 0;
137
+ return t.key !== void 0;
138
138
  }
139
- function i(s, n) {
140
- function p() {
141
- t || (t = !0, console.error(
139
+ function n(t, x) {
140
+ function C() {
141
+ o || (o = !0, console.error(
142
142
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
143
- n
143
+ x
144
144
  ));
145
145
  }
146
- p.isReactWarning = !0, Object.defineProperty(s, "key", {
147
- get: p,
146
+ C.isReactWarning = !0, Object.defineProperty(t, "key", {
147
+ get: C,
148
148
  configurable: !0
149
149
  });
150
150
  }
151
151
  function h() {
152
- var s = v(this.type);
153
- return a[s] || (a[s] = !0, console.error(
152
+ var t = r(this.type);
153
+ return u[t] || (u[t] = !0, console.error(
154
154
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
155
- )), s = this.props.ref, s !== void 0 ? s : null;
155
+ )), t = this.props.ref, t !== void 0 ? t : null;
156
156
  }
157
- function j(s, n, p, g, K, ne) {
158
- var b = p.ref;
159
- return s = {
160
- $$typeof: T,
161
- type: s,
162
- key: n,
163
- props: p,
164
- _owner: g
165
- }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(s, "ref", {
157
+ function l(t, x, C, S, re, ce) {
158
+ var E = C.ref;
159
+ return t = {
160
+ $$typeof: m,
161
+ type: t,
162
+ key: x,
163
+ props: C,
164
+ _owner: S
165
+ }, (E !== void 0 ? E : null) !== null ? Object.defineProperty(t, "ref", {
166
166
  enumerable: !1,
167
167
  get: h
168
- }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
168
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
172
  value: 0
173
- }), Object.defineProperty(s, "_debugInfo", {
173
+ }), Object.defineProperty(t, "_debugInfo", {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
177
  value: null
178
- }), Object.defineProperty(s, "_debugStack", {
178
+ }), Object.defineProperty(t, "_debugStack", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: K
183
- }), Object.defineProperty(s, "_debugTask", {
182
+ value: re
183
+ }), Object.defineProperty(t, "_debugTask", {
184
184
  configurable: !1,
185
185
  enumerable: !1,
186
186
  writable: !0,
187
- value: ne
188
- }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
187
+ value: ce
188
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
189
189
  }
190
- function f(s, n, p, g, K, ne) {
191
- var b = n.children;
192
- if (b !== void 0)
193
- if (g)
194
- if (le(b)) {
195
- for (g = 0; g < b.length; g++)
196
- y(b[g]);
197
- Object.freeze && Object.freeze(b);
190
+ function j(t, x, C, S, re, ce) {
191
+ var E = x.children;
192
+ if (E !== void 0)
193
+ if (S)
194
+ if (ie(E)) {
195
+ for (S = 0; S < E.length; S++)
196
+ y(E[S]);
197
+ Object.freeze && Object.freeze(E);
198
198
  } else
199
199
  console.error(
200
200
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
201
201
  );
202
- else y(b);
203
- if (Z.call(n, "key")) {
204
- b = v(s);
205
- var G = Object.keys(n).filter(function(pe) {
206
- return pe !== "key";
202
+ else y(E);
203
+ if (se.call(x, "key")) {
204
+ E = r(t);
205
+ var G = Object.keys(x).filter(function(Ce) {
206
+ return Ce !== "key";
207
207
  });
208
- g = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", U[b + g] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
208
+ S = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", Z[E + S] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
209
209
  `A props object containing a "key" prop is being spread into JSX:
210
210
  let props = %s;
211
211
  <%s {...props} />
212
212
  React keys must be passed directly to JSX without using spread:
213
213
  let props = %s;
214
214
  <%s key={someKey} {...props} />`,
215
- g,
216
- b,
215
+ S,
216
+ E,
217
217
  G,
218
- b
219
- ), U[b + g] = !0);
218
+ E
219
+ ), Z[E + S] = !0);
220
220
  }
221
- if (b = null, p !== void 0 && (u(p), b = "" + p), S(n) && (u(n.key), b = "" + n.key), "key" in n) {
222
- p = {};
223
- for (var ie in n)
224
- ie !== "key" && (p[ie] = n[ie]);
225
- } else p = n;
226
- return b && i(
227
- p,
228
- typeof s == "function" ? s.displayName || s.name || "Unknown" : s
229
- ), j(
230
- s,
231
- b,
232
- p,
233
- m(),
234
- K,
235
- ne
221
+ if (E = null, C !== void 0 && (s(C), E = "" + C), f(x) && (s(x.key), E = "" + x.key), "key" in x) {
222
+ C = {};
223
+ for (var oe in x)
224
+ oe !== "key" && (C[oe] = x[oe]);
225
+ } else C = x;
226
+ return E && n(
227
+ C,
228
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
229
+ ), l(
230
+ t,
231
+ E,
232
+ C,
233
+ d(),
234
+ re,
235
+ ce
236
236
  );
237
237
  }
238
- function y(s) {
239
- l(s) ? s._store && (s._store.validated = 1) : typeof s == "object" && s !== null && s.$$typeof === L && (s._payload.status === "fulfilled" ? l(s._payload.value) && s._payload.value._store && (s._payload.value._store.validated = 1) : s._store && (s._store.validated = 1));
238
+ function y(t) {
239
+ R(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === I && (t._payload.status === "fulfilled" ? R(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
240
240
  }
241
- function l(s) {
242
- return typeof s == "object" && s !== null && s.$$typeof === T;
241
+ function R(t) {
242
+ return typeof t == "object" && t !== null && t.$$typeof === m;
243
243
  }
244
- var w = fe, T = Symbol.for("react.transitional.element"), C = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), O = Symbol.for("react.context"), $ = Symbol.for("react.forward_ref"), B = Symbol.for("react.suspense"), re = Symbol.for("react.suspense_list"), te = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ae = Symbol.for("react.client.reference"), F = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, le = Array.isArray, r = console.createTask ? console.createTask : function() {
244
+ var w = ke, m = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), N = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), D = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), ne = Symbol.for("react.client.reference"), P = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, se = Object.prototype.hasOwnProperty, ie = Array.isArray, a = console.createTask ? console.createTask : function() {
245
245
  return null;
246
246
  };
247
247
  w = {
248
- react_stack_bottom_frame: function(s) {
249
- return s();
248
+ react_stack_bottom_frame: function(t) {
249
+ return t();
250
250
  }
251
251
  };
252
- var t, a = {}, R = w.react_stack_bottom_frame.bind(
252
+ var o, u = {}, T = w.react_stack_bottom_frame.bind(
253
253
  w,
254
- N
255
- )(), V = r(d(N)), U = {};
256
- X.Fragment = o, X.jsx = function(s, n, p) {
257
- var g = 1e4 > F.recentlyCreatedOwnerStacks++;
258
- return f(
259
- s,
260
- n,
261
- p,
254
+ p
255
+ )(), X = a(c(p)), Z = {};
256
+ K.Fragment = N, K.jsx = function(t, x, C) {
257
+ var S = 1e4 > P.recentlyCreatedOwnerStacks++;
258
+ return j(
259
+ t,
260
+ x,
261
+ C,
262
262
  !1,
263
- g ? Error("react-stack-top-frame") : R,
264
- g ? r(d(s)) : V
263
+ S ? Error("react-stack-top-frame") : T,
264
+ S ? a(c(t)) : X
265
265
  );
266
- }, X.jsxs = function(s, n, p) {
267
- var g = 1e4 > F.recentlyCreatedOwnerStacks++;
268
- return f(
269
- s,
270
- n,
271
- p,
266
+ }, K.jsxs = function(t, x, C) {
267
+ var S = 1e4 > P.recentlyCreatedOwnerStacks++;
268
+ return j(
269
+ t,
270
+ x,
271
+ C,
272
272
  !0,
273
- g ? Error("react-stack-top-frame") : R,
274
- g ? r(d(s)) : V
273
+ S ? Error("react-stack-top-frame") : T,
274
+ S ? a(c(t)) : X
275
275
  );
276
276
  };
277
- }()), X;
277
+ }()), K;
278
278
  }
279
- process.env.NODE_ENV === "production" ? ce.exports = Ee() : ce.exports = Ce();
280
- var e = ce.exports;
281
- const Te = ({ schema: v }) => {
279
+ process.env.NODE_ENV === "production" ? me.exports = Pe() : me.exports = Le();
280
+ var e = me.exports;
281
+ const De = ({ schema: r }) => {
282
282
  var h;
283
- const { title: c, description: u, data: d, columns: m } = v;
284
- (h = v.chart) != null && h.type;
285
- const N = !!v.chart, i = !(process.env.NODE_ENV === "test");
286
- return /* @__PURE__ */ e.jsxs(z, { className: `h-full flex flex-col ${v.className || ""}`, children: [
283
+ const { title: i, description: s, data: c, columns: d } = r;
284
+ (h = r.chart) != null && h.type;
285
+ const p = !!r.chart, n = !(process.env.NODE_ENV === "test");
286
+ return /* @__PURE__ */ e.jsxs(B, { className: `h-full flex flex-col ${r.className || ""}`, children: [
287
287
  /* @__PURE__ */ e.jsxs(ee, { children: [
288
- c && /* @__PURE__ */ e.jsx(se, { children: c }),
289
- u && /* @__PURE__ */ e.jsx(de, { children: u })
288
+ i && /* @__PURE__ */ e.jsx(te, { children: i }),
289
+ s && /* @__PURE__ */ e.jsx(he, { children: s })
290
290
  ] }),
291
- /* @__PURE__ */ e.jsxs(Y, { className: "flex-1 overflow-auto space-y-4", children: [
292
- N && (() => {
291
+ /* @__PURE__ */ e.jsxs(z, { className: "flex-1 overflow-auto space-y-4", children: [
292
+ p && (() => {
293
293
  var y;
294
- const j = (y = v.chart) == null ? void 0 : y.type;
295
- let f = j ? P.get(j) : null;
296
- return f || (f = P.get("chart")), f ? /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px] border rounded-md p-4 bg-white/50", children: /* @__PURE__ */ e.jsx(f, { schema: { ...v.chart, data: v.chart.data || d } }) }) : /* @__PURE__ */ e.jsxs("div", { className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center", children: [
294
+ const l = (y = r.chart) == null ? void 0 : y.type;
295
+ let j = l ? L.get(l) : null;
296
+ return j || (j = L.get("chart")), j ? /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px] border rounded-md p-4 bg-white/50", children: /* @__PURE__ */ e.jsx(j, { schema: { ...r.chart, data: r.chart.data || c } }) }) : /* @__PURE__ */ e.jsxs("div", { className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center", children: [
297
297
  "Unknown component type: ",
298
- j || "chart"
298
+ l || "chart"
299
299
  ] });
300
300
  })(),
301
- d && d.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-md", children: (() => {
302
- const j = i ? P.get("aggrid") || P.get("table") : null;
303
- return j ? /* @__PURE__ */ e.jsx(
304
- j,
301
+ c && c.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-md", children: (() => {
302
+ const l = n ? L.get("aggrid") || L.get("table") : null;
303
+ return l ? /* @__PURE__ */ e.jsx(
304
+ l,
305
305
  {
306
306
  schema: {
307
307
  type: "aggrid",
308
- rowData: d,
309
- columnDefs: m,
308
+ rowData: c,
309
+ columnDefs: d,
310
310
  domLayout: "autoHeight"
311
311
  }
312
312
  }
313
313
  ) : (
314
314
  // Simple Fallback Table if Grid plugin missing
315
315
  /* @__PURE__ */ e.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm text-left", children: [
316
- /* @__PURE__ */ e.jsx("thead", { className: "text-xs uppercase bg-gray-50", children: /* @__PURE__ */ e.jsx("tr", { children: m == null ? void 0 : m.map((f) => /* @__PURE__ */ e.jsx("th", { className: "px-6 py-3", children: f.headerName || f.label || f.field }, f.field)) }) }),
317
- /* @__PURE__ */ e.jsx("tbody", { children: d.map((f, y) => /* @__PURE__ */ e.jsx("tr", { className: "bg-white border-b", children: m == null ? void 0 : m.map((l) => /* @__PURE__ */ e.jsx("td", { className: "px-6 py-4", children: f[l.field] }, l.field)) }, y)) })
316
+ /* @__PURE__ */ e.jsx("thead", { className: "text-xs uppercase bg-gray-50", children: /* @__PURE__ */ e.jsx("tr", { children: d == null ? void 0 : d.map((j) => /* @__PURE__ */ e.jsx("th", { className: "px-6 py-3", children: j.headerName || j.label || j.field }, j.field)) }) }),
317
+ /* @__PURE__ */ e.jsx("tbody", { children: c.map((j, y) => /* @__PURE__ */ e.jsx("tr", { className: "bg-white border-b", children: d == null ? void 0 : d.map((R) => /* @__PURE__ */ e.jsx("td", { className: "px-6 py-4", children: j[R.field] }, R.field)) }, y)) })
318
318
  ] }) })
319
319
  );
320
320
  })() })
321
321
  ] })
322
322
  ] });
323
- }, xe = ({ schema: v }) => {
324
- var f, y;
323
+ };
324
+ function Be(r, i, s) {
325
+ const c = r.fields || [], d = c.map((n) => n.label || n.name), p = i.map((n) => c.map((h) => {
326
+ let l = n[h.name];
327
+ return l = ge(l), typeof l == "string" && (l.includes(",") || l.includes('"') || l.includes(`
328
+ `)) ? `"${l.replace(/"/g, '""')}"` : l ?? "";
329
+ })), f = [
330
+ ...(s == null ? void 0 : s.includeHeaders) !== !1 ? [d.join(",")] : [],
331
+ ...p.map((n) => n.join(","))
332
+ ].join(`
333
+ `);
334
+ le(f, (s == null ? void 0 : s.filename) || `${r.title || "report"}.csv`, "text/csv");
335
+ }
336
+ function ze(r, i, s) {
337
+ const c = {
338
+ title: r.title,
339
+ description: r.description,
340
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
341
+ data: i
342
+ }, d = JSON.stringify(c, null, 2);
343
+ le(d, (s == null ? void 0 : s.filename) || `${r.title || "report"}.json`, "application/json");
344
+ }
345
+ function ve(r, i, s) {
346
+ const c = r.fields || [], d = Ne(s == null ? void 0 : s.orientation), p = ye(s == null ? void 0 : s.pageSize), f = `<!DOCTYPE html>
347
+ <html>
348
+ <head>
349
+ <meta charset="utf-8">
350
+ <title>${$(r.title || "Report")}</title>
351
+ <style>
352
+ @page { size: ${p} ${d}; margin: 20mm; }
353
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
354
+ h1 { font-size: 24px; margin-bottom: 8px; }
355
+ .description { color: #666; margin-bottom: 24px; }
356
+ .meta { color: #999; font-size: 12px; margin-bottom: 16px; }
357
+ table { width: 100%; border-collapse: collapse; margin-top: 16px; }
358
+ th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
359
+ td { padding: 8px 12px; border: 1px solid #ddd; }
360
+ tr:nth-child(even) { background: #fafafa; }
361
+ </style>
362
+ </head>
363
+ <body>
364
+ <h1>${$(r.title || "Report")}</h1>
365
+ ${r.description ? `<p class="description">${$(r.description)}</p>` : ""}
366
+ <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
367
+ <table>
368
+ <thead><tr>${c.map((n) => `<th>${$(n.label || n.name)}</th>`).join("")}</tr></thead>
369
+ <tbody>${i.map((n) => `<tr>${c.map((h) => `<td>${$(String(n[h.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
370
+ </table>
371
+ </body>
372
+ </html>`;
373
+ le(f, (s == null ? void 0 : s.filename) || `${r.title || "report"}.html`, "text/html");
374
+ }
375
+ function Me(r, i, s) {
376
+ var n;
377
+ const c = r.fields || [], d = Ne(s == null ? void 0 : s.orientation), p = ye(s == null ? void 0 : s.pageSize), f = window.open("", "_blank");
378
+ if (!f) {
379
+ const h = {
380
+ ...s,
381
+ filename: ((n = s == null ? void 0 : s.filename) == null ? void 0 : n.replace(/\.pdf$/, ".html")) || `${r.title || "report"}.html`
382
+ };
383
+ ve(r, i, h);
384
+ return;
385
+ }
386
+ f.document.write(`<!DOCTYPE html>
387
+ <html>
388
+ <head>
389
+ <meta charset="utf-8">
390
+ <title>${$(r.title || "Report")}</title>
391
+ <style>
392
+ @page { size: ${p} ${d}; margin: 20mm; }
393
+ @media print { .no-print { display: none; } }
394
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
395
+ h1 { font-size: 24px; margin-bottom: 8px; }
396
+ .description { color: #666; margin-bottom: 24px; }
397
+ .meta { color: #999; font-size: 12px; margin-bottom: 16px; }
398
+ table { width: 100%; border-collapse: collapse; margin-top: 16px; }
399
+ th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
400
+ td { padding: 8px 12px; border: 1px solid #ddd; }
401
+ tr:nth-child(even) { background: #fafafa; }
402
+ </style>
403
+ </head>
404
+ <body>
405
+ <h1>${$(r.title || "Report")}</h1>
406
+ ${r.description ? `<p class="description">${$(r.description)}</p>` : ""}
407
+ <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
408
+ <table>
409
+ <thead><tr>${c.map((h) => `<th>${$(h.label || h.name)}</th>`).join("")}</tr></thead>
410
+ <tbody>${i.map((h) => `<tr>${c.map((l) => `<td>${$(String(h[l.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
411
+ </table>
412
+ </body>
413
+ </html>`), f.document.close(), f.onload = () => {
414
+ f.print();
415
+ };
416
+ }
417
+ function Ie(r, i, s) {
418
+ const c = r.fields || [], d = c.map((n) => n.label || n.name), p = i.map((n) => c.map((h) => {
419
+ let l = n[h.name];
420
+ return l = ge(l), typeof l == "string" && (l.includes(",") || l.includes('"') || l.includes(`
421
+ `) || l.includes(" ")) ? `"${l.replace(/"/g, '""')}"` : l ?? "";
422
+ })), f = "\uFEFF" + [
423
+ ...(s == null ? void 0 : s.includeHeaders) !== !1 ? [d.join(" ")] : [],
424
+ ...p.map((n) => n.join(" "))
425
+ ].join(`
426
+ `);
427
+ le(f, (s == null ? void 0 : s.filename) || `${r.title || "report"}.tsv`, "text/tab-separated-values");
428
+ }
429
+ function be(r, i, s, c) {
430
+ switch (r) {
431
+ case "csv":
432
+ Be(i, s, c);
433
+ break;
434
+ case "json":
435
+ ze(i, s, c);
436
+ break;
437
+ case "html":
438
+ ve(i, s, c);
439
+ break;
440
+ case "pdf":
441
+ Me(i, s, c);
442
+ break;
443
+ case "excel":
444
+ Ie(i, s, c);
445
+ break;
446
+ default:
447
+ console.warn(`Unsupported export format: ${r}`);
448
+ }
449
+ }
450
+ function $(r) {
451
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
452
+ }
453
+ function ge(r) {
454
+ if (typeof r == "string" && r.length > 0) {
455
+ const i = r.charAt(0);
456
+ if (i === "=" || i === "+" || i === "-" || i === "@" || i === "|")
457
+ return ` ${r}`;
458
+ }
459
+ return r;
460
+ }
461
+ function ye(r) {
462
+ return ["A4", "A3", "Letter", "Legal"].includes(r || "") ? r : "A4";
463
+ }
464
+ function Ne(r) {
465
+ return r === "landscape" ? "landscape" : "portrait";
466
+ }
467
+ function le(r, i, s) {
468
+ const c = new Blob([r], { type: `${s};charset=utf-8` }), d = URL.createObjectURL(c), p = document.createElement("a");
469
+ p.href = d, p.download = i, document.body.appendChild(p), p.click(), document.body.removeChild(p), URL.revokeObjectURL(d);
470
+ }
471
+ const we = ({ schema: r, onRefresh: i }) => {
472
+ var R, w;
325
473
  const {
326
- report: c,
327
- data: u,
474
+ report: s,
475
+ data: c,
328
476
  showToolbar: d = !0,
329
- allowExport: m = !0,
330
- allowPrint: N = !0,
331
- loading: S = !1
332
- } = v, i = (l) => {
333
- console.log("Export report as:", l), alert(`Export to ${l.toUpperCase()} - Feature coming soon!`);
334
- }, h = () => {
335
- console.log("Print report"), window.print();
477
+ allowExport: p = !0,
478
+ allowPrint: f = !0,
479
+ loading: n = !1
480
+ } = r, h = (m) => {
481
+ var v;
482
+ if (!s) {
483
+ console.warn("ReportViewer: Cannot export, no report defined");
484
+ return;
485
+ }
486
+ be(
487
+ m,
488
+ s,
489
+ c || [],
490
+ (v = s.exportConfigs) == null ? void 0 : v[m]
491
+ );
492
+ }, l = () => {
493
+ window.print();
336
494
  }, j = () => {
337
- console.log("Refresh report");
495
+ i == null || i();
496
+ }, y = (m, v) => {
497
+ if (!c) return 0;
498
+ const N = c.map((k) => Number(k[m]) || 0);
499
+ switch (v) {
500
+ case "count":
501
+ return c.length;
502
+ case "sum":
503
+ return N.reduce((k, g) => k + g, 0);
504
+ case "avg":
505
+ return N.length > 0 ? (N.reduce((k, g) => k + g, 0) / N.length).toFixed(2) : 0;
506
+ case "min":
507
+ return N.length > 0 ? Math.min(...N) : 0;
508
+ case "max":
509
+ return N.length > 0 ? Math.max(...N) : 0;
510
+ default:
511
+ return "";
512
+ }
338
513
  };
339
- return c ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
514
+ return s ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
340
515
  d && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border", children: [
341
516
  /* @__PURE__ */ e.jsxs("div", { children: [
342
- /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: c.title }),
343
- c.description && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: c.description })
517
+ /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: s.title }),
518
+ s.description && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: s.description })
344
519
  ] }),
345
520
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
346
- c.refreshInterval && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: j, children: [
347
- /* @__PURE__ */ e.jsx(ge, { className: "h-4 w-4 mr-2" }),
521
+ s.refreshInterval && /* @__PURE__ */ e.jsxs(F, { variant: "outline", size: "sm", onClick: j, children: [
522
+ /* @__PURE__ */ e.jsx(Ee, { className: "h-4 w-4 mr-2" }),
348
523
  "Refresh"
349
524
  ] }),
350
- N && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: h, children: [
351
- /* @__PURE__ */ e.jsx(be, { className: "h-4 w-4 mr-2" }),
525
+ f && /* @__PURE__ */ e.jsxs(F, { variant: "outline", size: "sm", onClick: l, children: [
526
+ /* @__PURE__ */ e.jsx(Te, { className: "h-4 w-4 mr-2" }),
352
527
  "Print"
353
528
  ] }),
354
- m && c.showExportButtons && /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(
355
- E,
356
- {
357
- variant: "outline",
358
- size: "sm",
359
- onClick: () => i(c.defaultExportFormat || "pdf"),
360
- children: [
361
- /* @__PURE__ */ e.jsx(Ne, { className: "h-4 w-4 mr-2" }),
362
- "Export"
363
- ]
364
- }
365
- ) })
529
+ p && s.showExportButtons && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1", children: [
530
+ /* @__PURE__ */ e.jsxs(
531
+ F,
532
+ {
533
+ variant: "outline",
534
+ size: "sm",
535
+ onClick: () => h("pdf"),
536
+ children: [
537
+ /* @__PURE__ */ e.jsx(de, { className: "h-4 w-4 mr-2" }),
538
+ "PDF"
539
+ ]
540
+ }
541
+ ),
542
+ /* @__PURE__ */ e.jsxs(
543
+ F,
544
+ {
545
+ variant: "outline",
546
+ size: "sm",
547
+ onClick: () => h("excel"),
548
+ children: [
549
+ /* @__PURE__ */ e.jsx(de, { className: "h-4 w-4 mr-2" }),
550
+ "Excel"
551
+ ]
552
+ }
553
+ ),
554
+ /* @__PURE__ */ e.jsxs(
555
+ F,
556
+ {
557
+ variant: "outline",
558
+ size: "sm",
559
+ onClick: () => h("csv"),
560
+ children: [
561
+ /* @__PURE__ */ e.jsx(de, { className: "h-4 w-4 mr-2" }),
562
+ "CSV"
563
+ ]
564
+ }
565
+ )
566
+ ] })
366
567
  ] })
367
568
  ] }),
368
- /* @__PURE__ */ e.jsxs(z, { children: [
569
+ /* @__PURE__ */ e.jsxs(B, { children: [
369
570
  /* @__PURE__ */ e.jsxs(ee, { children: [
370
- !d && c.title && /* @__PURE__ */ e.jsx(se, { children: c.title }),
371
- !d && c.description && /* @__PURE__ */ e.jsx(de, { children: c.description })
571
+ !d && s.title && /* @__PURE__ */ e.jsx(te, { children: s.title }),
572
+ !d && s.description && /* @__PURE__ */ e.jsx(he, { children: s.description })
372
573
  ] }),
373
- /* @__PURE__ */ e.jsxs(Y, { className: "space-y-6", children: [
374
- S && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground", children: "Loading report data..." }),
375
- !S && ((f = c.sections) == null ? void 0 : f.map((l, w) => {
376
- var T, C;
377
- return l.visible === !1 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
378
- l.title && /* @__PURE__ */ e.jsx("h3", { className: "text-lg font-semibold border-b pb-2", children: l.title }),
379
- l.type === "header" && l.title && /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold py-4", children: l.title }),
380
- l.type === "summary" && /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: (T = c.fields) == null ? void 0 : T.filter((o) => o.showInSummary).map((o, _) => /* @__PURE__ */ e.jsx(z, { children: /* @__PURE__ */ e.jsxs(Y, { className: "p-4", children: [
381
- /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: o.label || o.name }),
382
- /* @__PURE__ */ e.jsxs("div", { className: "text-2xl font-bold", children: [
383
- o.aggregation === "count" && (u == null ? void 0 : u.length),
384
- o.aggregation === "sum" && (u == null ? void 0 : u.reduce((k, A) => k + (A[o.name] || 0), 0))
385
- ] })
574
+ /* @__PURE__ */ e.jsxs(z, { className: "space-y-6", children: [
575
+ n && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground", children: "Loading report data..." }),
576
+ !n && ((R = s.sections) == null ? void 0 : R.map((m, v) => {
577
+ var N, k;
578
+ return m.visible === !1 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
579
+ m.title && /* @__PURE__ */ e.jsx("h3", { className: "text-lg font-semibold border-b pb-2", children: m.title }),
580
+ m.type === "header" && m.title && /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold py-4", children: m.title }),
581
+ m.type === "summary" && /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: (N = s.fields) == null ? void 0 : N.filter((g) => g.showInSummary).map((g, _) => /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsxs(z, { className: "p-4", children: [
582
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: g.label || g.name }),
583
+ /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold", children: y(g.name, g.aggregation) })
386
584
  ] }) }, _)) }),
387
- l.type === "chart" && l.chart && /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px]", children: (() => {
388
- let o = l.chart.type;
389
- const _ = !!l.chart.chartType;
390
- !o && _ && (o = "chart"), o && !!P.get(o) || (o = "chart");
391
- const O = o === "chart" ? {
392
- xAxisKey: l.chart.xAxisKey || l.chart.xAxisField || "name",
393
- series: l.chart.series || (l.chart.yAxisFields ? l.chart.yAxisFields.map((B) => ({ dataKey: B })) : []),
585
+ m.type === "chart" && m.chart && /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px]", children: (() => {
586
+ let g = m.chart.type;
587
+ const _ = !!m.chart.chartType;
588
+ !g && _ && (g = "chart"), g && !!L.get(g) || (g = "chart");
589
+ const O = g === "chart" ? {
590
+ xAxisKey: m.chart.xAxisKey || m.chart.xAxisField || "name",
591
+ series: m.chart.series || (m.chart.yAxisFields ? m.chart.yAxisFields.map((H) => ({ dataKey: H })) : []),
394
592
  // Ensure chartType is passed if we are using the generic renderer
395
- chartType: l.chart.chartType || "bar"
396
- } : {}, $ = {
397
- ...l.chart,
398
- type: o,
593
+ chartType: m.chart.chartType || "bar"
594
+ } : {}, q = {
595
+ ...m.chart,
596
+ type: g,
399
597
  ...O,
400
- data: u || l.chart.data,
598
+ data: c || m.chart.data,
401
599
  // Force explicit height to preventing Recharts "height(-1)" error
402
- className: l.chart.className || "w-full h-[350px]"
600
+ className: m.chart.className || "w-full h-[350px]"
403
601
  };
404
- return /* @__PURE__ */ e.jsx(ue, { schema: $ });
602
+ return /* @__PURE__ */ e.jsx(pe, { schema: q });
405
603
  })() }),
406
- l.type === "table" && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
407
- /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (C = l.columns) == null ? void 0 : C.map((o, _) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: o.label || o.name }, _)) }) }),
408
- /* @__PURE__ */ e.jsx("tbody", { children: u == null ? void 0 : u.map((o, _) => {
409
- var k;
410
- return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (k = l.columns) == null ? void 0 : k.map((A, O) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: o[A.name] }, O)) }, _);
604
+ m.type === "table" && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
605
+ /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (k = m.columns) == null ? void 0 : k.map((g, _) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: g.label || g.name }, _)) }) }),
606
+ /* @__PURE__ */ e.jsx("tbody", { children: c == null ? void 0 : c.map((g, _) => {
607
+ var D;
608
+ return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (D = m.columns) == null ? void 0 : D.map((M, O) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: g[M.name] }, O)) }, _);
411
609
  }) })
412
610
  ] }) }),
413
- l.type === "text" && l.text && /* @__PURE__ */ e.jsx("div", { className: "prose max-w-none", children: /* @__PURE__ */ e.jsx("p", { children: l.text }) }),
414
- l.type === "page-break" && /* @__PURE__ */ e.jsx("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
415
- l.content && /* @__PURE__ */ e.jsx(ue, { schema: l.content })
416
- ] }, w);
611
+ m.type === "text" && m.text && /* @__PURE__ */ e.jsx("div", { className: "prose max-w-none", children: /* @__PURE__ */ e.jsx("p", { children: m.text }) }),
612
+ m.type === "page-break" && /* @__PURE__ */ e.jsx("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
613
+ m.content && /* @__PURE__ */ e.jsx(pe, { schema: m.content })
614
+ ] }, v);
417
615
  })),
418
- !c.sections && u && u.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
419
- /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (y = c.fields) == null ? void 0 : y.map((l, w) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: l.label || l.name }, w)) }) }),
420
- /* @__PURE__ */ e.jsx("tbody", { children: u.map((l, w) => {
421
- var T;
422
- return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (T = c.fields) == null ? void 0 : T.map((C, o) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: l[C.name] }, o)) }, w);
616
+ !s.sections && c && c.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
617
+ /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (w = s.fields) == null ? void 0 : w.map((m, v) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: m.label || m.name }, v)) }) }),
618
+ /* @__PURE__ */ e.jsx("tbody", { children: c.map((m, v) => {
619
+ var N;
620
+ return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (N = s.fields) == null ? void 0 : N.map((k, g) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: m[k.name] }, g)) }, v);
423
621
  }) })
424
622
  ] }) })
425
623
  ] })
426
624
  ] })
427
- ] }) : /* @__PURE__ */ e.jsx(z, { children: /* @__PURE__ */ e.jsx(Y, { className: "p-8 text-center text-muted-foreground", children: "No report to display" }) });
428
- }, _e = ({ schema: v }) => {
625
+ ] }) : /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(z, { className: "p-8 text-center text-muted-foreground", children: "No report to display" }) });
626
+ }, Ge = ({ schedule: r, onChange: i }) => {
627
+ var h;
628
+ const [s, c] = W(r || {
629
+ enabled: !1,
630
+ frequency: "weekly",
631
+ time: "09:00",
632
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
633
+ recipients: [],
634
+ formats: ["pdf"]
635
+ }), d = (l) => {
636
+ const j = { ...s, ...l };
637
+ c(j), i == null || i(j);
638
+ }, p = [
639
+ { value: "once", label: "Once" },
640
+ { value: "daily", label: "Daily" },
641
+ { value: "weekly", label: "Weekly" },
642
+ { value: "monthly", label: "Monthly" },
643
+ { value: "quarterly", label: "Quarterly" },
644
+ { value: "yearly", label: "Yearly" }
645
+ ], f = [
646
+ { value: "pdf", label: "PDF" },
647
+ { value: "excel", label: "Excel" },
648
+ { value: "csv", label: "CSV" },
649
+ { value: "html", label: "HTML" }
650
+ ], n = [
651
+ { value: 0, label: "Sunday" },
652
+ { value: 1, label: "Monday" },
653
+ { value: 2, label: "Tuesday" },
654
+ { value: 3, label: "Wednesday" },
655
+ { value: 4, label: "Thursday" },
656
+ { value: 5, label: "Friday" },
657
+ { value: 6, label: "Saturday" }
658
+ ];
659
+ return /* @__PURE__ */ e.jsxs(B, { children: [
660
+ /* @__PURE__ */ e.jsx(ee, { children: /* @__PURE__ */ e.jsxs(te, { className: "flex items-center gap-2", children: [
661
+ /* @__PURE__ */ e.jsx(je, { className: "h-5 w-5" }),
662
+ "Schedule Configuration"
663
+ ] }) }),
664
+ /* @__PURE__ */ e.jsxs(z, { className: "space-y-4", children: [
665
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
666
+ /* @__PURE__ */ e.jsx(
667
+ "input",
668
+ {
669
+ type: "checkbox",
670
+ id: "schedule-enabled",
671
+ checked: s.enabled || !1,
672
+ onChange: (l) => d({ enabled: l.target.checked }),
673
+ className: "rounded"
674
+ }
675
+ ),
676
+ /* @__PURE__ */ e.jsx(b, { htmlFor: "schedule-enabled", children: "Enable Scheduled Report" })
677
+ ] }),
678
+ s.enabled && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
679
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
680
+ /* @__PURE__ */ e.jsx(b, { children: "Frequency" }),
681
+ /* @__PURE__ */ e.jsx(
682
+ "select",
683
+ {
684
+ className: "w-full border rounded-md p-2 bg-background",
685
+ value: s.frequency || "weekly",
686
+ onChange: (l) => d({ frequency: l.target.value }),
687
+ children: p.map((l) => /* @__PURE__ */ e.jsx("option", { value: l.value, children: l.label }, l.value))
688
+ }
689
+ )
690
+ ] }),
691
+ s.frequency === "weekly" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
692
+ /* @__PURE__ */ e.jsx(b, { children: "Day of Week" }),
693
+ /* @__PURE__ */ e.jsx(
694
+ "select",
695
+ {
696
+ className: "w-full border rounded-md p-2 bg-background",
697
+ value: s.dayOfWeek ?? 1,
698
+ onChange: (l) => d({ dayOfWeek: Number(l.target.value) }),
699
+ children: n.map((l) => /* @__PURE__ */ e.jsx("option", { value: l.value, children: l.label }, l.value))
700
+ }
701
+ )
702
+ ] }),
703
+ s.frequency === "monthly" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
704
+ /* @__PURE__ */ e.jsx(b, { children: "Day of Month" }),
705
+ /* @__PURE__ */ e.jsx(
706
+ A,
707
+ {
708
+ type: "number",
709
+ min: 1,
710
+ max: 31,
711
+ value: s.dayOfMonth ?? 1,
712
+ onChange: (l) => d({ dayOfMonth: Number(l.target.value) })
713
+ }
714
+ )
715
+ ] }),
716
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
717
+ /* @__PURE__ */ e.jsxs(b, { className: "flex items-center gap-2", children: [
718
+ /* @__PURE__ */ e.jsx(Fe, { className: "h-4 w-4" }),
719
+ "Time"
720
+ ] }),
721
+ /* @__PURE__ */ e.jsx(
722
+ A,
723
+ {
724
+ type: "time",
725
+ value: s.time || "09:00",
726
+ onChange: (l) => d({ time: l.target.value })
727
+ }
728
+ )
729
+ ] }),
730
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
731
+ /* @__PURE__ */ e.jsx(b, { children: "Timezone" }),
732
+ /* @__PURE__ */ e.jsx(
733
+ A,
734
+ {
735
+ value: s.timezone || "",
736
+ onChange: (l) => d({ timezone: l.target.value }),
737
+ placeholder: "e.g. America/New_York"
738
+ }
739
+ )
740
+ ] }),
741
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
742
+ /* @__PURE__ */ e.jsx(b, { children: "Export Formats" }),
743
+ /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-2", children: f.map((l) => {
744
+ var j;
745
+ return /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-1.5 px-3 py-1.5 border rounded-md cursor-pointer hover:bg-muted/50", children: [
746
+ /* @__PURE__ */ e.jsx(
747
+ "input",
748
+ {
749
+ type: "checkbox",
750
+ checked: ((j = s.formats) == null ? void 0 : j.includes(l.value)) || !1,
751
+ onChange: (y) => {
752
+ const R = s.formats || [];
753
+ d({
754
+ formats: y.target.checked ? [...R, l.value] : R.filter((w) => w !== l.value)
755
+ });
756
+ },
757
+ className: "rounded"
758
+ }
759
+ ),
760
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: l.label })
761
+ ] }, l.value);
762
+ }) })
763
+ ] }),
764
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
765
+ /* @__PURE__ */ e.jsxs(b, { className: "flex items-center gap-2", children: [
766
+ /* @__PURE__ */ e.jsx(_e, { className: "h-4 w-4" }),
767
+ "Email Recipients"
768
+ ] }),
769
+ /* @__PURE__ */ e.jsx(
770
+ A,
771
+ {
772
+ placeholder: "email1@example.com, email2@example.com",
773
+ value: ((h = s.recipients) == null ? void 0 : h.join(", ")) || "",
774
+ onChange: (l) => d({
775
+ recipients: l.target.value.split(",").map((j) => j.trim()).filter(Boolean)
776
+ })
777
+ }
778
+ )
779
+ ] }),
780
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
781
+ /* @__PURE__ */ e.jsx(b, { children: "Email Subject" }),
782
+ /* @__PURE__ */ e.jsx(
783
+ A,
784
+ {
785
+ value: s.subject || "",
786
+ onChange: (l) => d({ subject: l.target.value }),
787
+ placeholder: "Scheduled Report: {report_title}"
788
+ }
789
+ )
790
+ ] })
791
+ ] })
792
+ ] })
793
+ ] });
794
+ }, Ue = ({ schema: r }) => {
429
795
  const {
430
- report: c,
431
- dataSources: u = [],
432
- availableFields: d = [],
433
- showPreview: m = !0,
434
- onSave: N,
435
- onCancel: S
436
- } = v, [i, h] = W(c || {
796
+ report: i,
797
+ dataSources: s = [],
798
+ availableFields: c = [],
799
+ showPreview: d = !0,
800
+ onSave: p,
801
+ onCancel: f
802
+ } = r, [n, h] = W(i || {
437
803
  type: "report",
438
804
  title: "New Report",
439
805
  fields: [],
@@ -442,141 +808,145 @@ const Te = ({ schema: v }) => {
442
808
  sections: [],
443
809
  showExportButtons: !0,
444
810
  showPrintButton: !0
445
- }), [j, f] = W(i.fields || []), [y, l] = W(i.filters || []), [w, T] = W(i.groupBy || []), [C, o] = W(i.sections || []), _ = () => {
446
- if (d.length > 0 && j.length < d.length) {
447
- const r = d.find(
448
- (t) => !j.some((a) => a.name === t.name)
811
+ }), [l, j] = W(n.fields || []), [y, R] = W(n.filters || []), [w, m] = W(n.groupBy || []), [v, N] = W(n.sections || []), k = () => {
812
+ if (c.length > 0 && l.length < c.length) {
813
+ const a = c.find(
814
+ (o) => !l.some((u) => u.name === o.name)
449
815
  );
450
- if (r) {
451
- const t = [...j, r];
452
- f(t), h({ ...i, fields: t });
816
+ if (a) {
817
+ const o = [...l, a];
818
+ j(o), h({ ...n, fields: o });
453
819
  }
454
820
  }
455
- }, k = (r) => {
456
- const t = j.filter((a, R) => R !== r);
457
- f(t), h({ ...i, fields: t });
458
- }, A = (r, t) => {
459
- const a = [...j];
460
- a[r] = t, f(a), h({ ...i, fields: a });
461
- }, O = () => {
462
- var a;
463
- const r = {
464
- field: ((a = d[0]) == null ? void 0 : a.name) || "",
821
+ }, g = (a) => {
822
+ const o = l.filter((u, T) => T !== a);
823
+ j(o), h({ ...n, fields: o });
824
+ }, _ = (a, o) => {
825
+ const u = [...l];
826
+ u[a] = o, j(u), h({ ...n, fields: u });
827
+ }, D = () => {
828
+ var u;
829
+ const a = {
830
+ field: ((u = c[0]) == null ? void 0 : u.name) || "",
465
831
  operator: "equals",
466
832
  value: ""
467
- }, t = [...y, r];
468
- l(t), h({ ...i, filters: t });
469
- }, $ = (r) => {
470
- const t = y.filter((a, R) => R !== r);
471
- l(t), h({ ...i, filters: t });
472
- }, B = (r, t) => {
473
- const a = [...y];
474
- a[r] = t, l(a), h({ ...i, filters: a });
475
- }, re = () => {
476
- var a;
477
- const r = {
478
- field: ((a = d[0]) == null ? void 0 : a.name) || "",
833
+ }, o = [...y, a];
834
+ R(o), h({ ...n, filters: o });
835
+ }, M = (a) => {
836
+ const o = y.filter((u, T) => T !== a);
837
+ R(o), h({ ...n, filters: o });
838
+ }, O = (a, o) => {
839
+ const u = [...y];
840
+ u[a] = o, R(u), h({ ...n, filters: u });
841
+ }, q = () => {
842
+ var u;
843
+ const a = {
844
+ field: ((u = c[0]) == null ? void 0 : u.name) || "",
479
845
  sort: "asc"
480
- }, t = [...w, r];
481
- T(t), h({ ...i, groupBy: t });
482
- }, te = (r) => {
483
- const t = w.filter((a, R) => R !== r);
484
- T(t), h({ ...i, groupBy: t });
485
- }, L = (r, t) => {
486
- const a = [...w];
487
- a[r] = t, T(a), h({ ...i, groupBy: a });
488
- }, M = (r) => {
489
- const t = {
490
- type: r,
491
- title: `New ${r} Section`
492
- }, a = [...C, t];
493
- o(a), h({ ...i, sections: a });
494
- }, ae = (r) => {
495
- const t = C.filter((a, R) => R !== r);
496
- o(t), h({ ...i, sections: t });
497
- }, F = (r, t) => {
498
- const a = [...C];
499
- a[r] = t, o(a), h({ ...i, sections: a });
500
- }, Z = () => {
501
- console.log("Saving report:", i), N && alert("Report saved! (Handler: " + N + ")");
502
- }, le = () => {
503
- console.log("Canceling report builder");
846
+ }, o = [...w, a];
847
+ m(o), h({ ...n, groupBy: o });
848
+ }, H = (a) => {
849
+ const o = w.filter((u, T) => T !== a);
850
+ m(o), h({ ...n, groupBy: o });
851
+ }, I = (a, o) => {
852
+ const u = [...w];
853
+ u[a] = o, m(u), h({ ...n, groupBy: u });
854
+ }, J = (a) => {
855
+ const o = {
856
+ type: a,
857
+ title: `New ${a} Section`
858
+ }, u = [...v, o];
859
+ N(u), h({ ...n, sections: u });
860
+ }, ne = (a) => {
861
+ const o = v.filter((u, T) => T !== a);
862
+ N(o), h({ ...n, sections: o });
863
+ }, P = (a, o) => {
864
+ const u = [...v];
865
+ u[a] = o, N(u), h({ ...n, sections: u });
866
+ }, se = () => {
867
+ console.log("Saving report:", n), p && alert("Report saved! (Handler: " + p + ")");
868
+ }, ie = () => {
869
+ f && console.log("Report cancelled:", f);
504
870
  };
505
871
  return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
506
- /* @__PURE__ */ e.jsxs(z, { children: [
872
+ /* @__PURE__ */ e.jsxs(B, { children: [
507
873
  /* @__PURE__ */ e.jsxs(ee, { children: [
508
- /* @__PURE__ */ e.jsx(se, { children: "Report Builder" }),
509
- /* @__PURE__ */ e.jsx(de, { children: "Configure your report settings, fields, filters, and sections" })
874
+ /* @__PURE__ */ e.jsx(te, { children: "Report Builder" }),
875
+ /* @__PURE__ */ e.jsx(he, { children: "Configure your report settings, fields, filters, and sections" })
510
876
  ] }),
511
- /* @__PURE__ */ e.jsxs(Y, { children: [
512
- /* @__PURE__ */ e.jsxs(je, { defaultValue: "basic", className: "w-full", children: [
513
- /* @__PURE__ */ e.jsxs(ve, { className: "grid w-full grid-cols-5", children: [
514
- /* @__PURE__ */ e.jsxs(q, { value: "basic", children: [
515
- /* @__PURE__ */ e.jsx(ye, { className: "h-4 w-4 mr-2" }),
877
+ /* @__PURE__ */ e.jsxs(z, { children: [
878
+ /* @__PURE__ */ e.jsxs(Re, { defaultValue: "basic", className: "w-full", children: [
879
+ /* @__PURE__ */ e.jsxs(Se, { className: "grid w-full grid-cols-6", children: [
880
+ /* @__PURE__ */ e.jsxs(U, { value: "basic", children: [
881
+ /* @__PURE__ */ e.jsx(Ae, { className: "h-4 w-4 mr-2" }),
516
882
  "Basic"
517
883
  ] }),
518
- /* @__PURE__ */ e.jsxs(q, { value: "fields", children: [
519
- /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
884
+ /* @__PURE__ */ e.jsxs(U, { value: "fields", children: [
885
+ /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
520
886
  "Fields"
521
887
  ] }),
522
- /* @__PURE__ */ e.jsxs(q, { value: "filters", children: [
523
- /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4 mr-2" }),
888
+ /* @__PURE__ */ e.jsxs(U, { value: "filters", children: [
889
+ /* @__PURE__ */ e.jsx($e, { className: "h-4 w-4 mr-2" }),
524
890
  "Filters"
525
891
  ] }),
526
- /* @__PURE__ */ e.jsxs(q, { value: "grouping", children: [
527
- /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
892
+ /* @__PURE__ */ e.jsxs(U, { value: "grouping", children: [
893
+ /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
528
894
  "Group By"
529
895
  ] }),
530
- /* @__PURE__ */ e.jsxs(q, { value: "sections", children: [
531
- /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
896
+ /* @__PURE__ */ e.jsxs(U, { value: "sections", children: [
897
+ /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
532
898
  "Sections"
899
+ ] }),
900
+ /* @__PURE__ */ e.jsxs(U, { value: "schedule", children: [
901
+ /* @__PURE__ */ e.jsx(je, { className: "h-4 w-4 mr-2" }),
902
+ "Schedule"
533
903
  ] })
534
904
  ] }),
535
- /* @__PURE__ */ e.jsx(H, { value: "basic", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
905
+ /* @__PURE__ */ e.jsx(Y, { value: "basic", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
536
906
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
537
- /* @__PURE__ */ e.jsx(x, { htmlFor: "report-title", children: "Report Title" }),
907
+ /* @__PURE__ */ e.jsx(b, { htmlFor: "report-title", children: "Report Title" }),
538
908
  /* @__PURE__ */ e.jsx(
539
- D,
909
+ A,
540
910
  {
541
911
  id: "report-title",
542
- value: i.title || "",
543
- onChange: (r) => h({ ...i, title: r.target.value }),
912
+ value: n.title || "",
913
+ onChange: (a) => h({ ...n, title: a.target.value }),
544
914
  placeholder: "Enter report title"
545
915
  }
546
916
  )
547
917
  ] }),
548
918
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
549
- /* @__PURE__ */ e.jsx(x, { htmlFor: "report-description", children: "Description" }),
919
+ /* @__PURE__ */ e.jsx(b, { htmlFor: "report-description", children: "Description" }),
550
920
  /* @__PURE__ */ e.jsx(
551
- D,
921
+ A,
552
922
  {
553
923
  id: "report-description",
554
- value: i.description || "",
555
- onChange: (r) => h({ ...i, description: r.target.value }),
924
+ value: n.description || "",
925
+ onChange: (a) => h({ ...n, description: a.target.value }),
556
926
  placeholder: "Enter report description"
557
927
  }
558
928
  )
559
929
  ] }),
560
- u.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
561
- /* @__PURE__ */ e.jsx(x, { children: "Data Source" }),
930
+ s.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
931
+ /* @__PURE__ */ e.jsx(b, { children: "Data Source" }),
562
932
  /* @__PURE__ */ e.jsxs("select", { className: "w-full border rounded-md p-2", children: [
563
933
  /* @__PURE__ */ e.jsx("option", { value: "", children: "Select a data source" }),
564
- u.map((r, t) => /* @__PURE__ */ e.jsxs("option", { value: t, children: [
934
+ s.map((a, o) => /* @__PURE__ */ e.jsxs("option", { value: o, children: [
565
935
  "Data Source ",
566
- t + 1
567
- ] }, t))
936
+ o + 1
937
+ ] }, o))
568
938
  ] })
569
939
  ] }),
570
940
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
571
- /* @__PURE__ */ e.jsx(x, { children: "Export Options" }),
941
+ /* @__PURE__ */ e.jsx(b, { children: "Export Options" }),
572
942
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
573
943
  /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2", children: [
574
944
  /* @__PURE__ */ e.jsx(
575
945
  "input",
576
946
  {
577
947
  type: "checkbox",
578
- checked: i.showExportButtons || !1,
579
- onChange: (r) => h({ ...i, showExportButtons: r.target.checked })
948
+ checked: n.showExportButtons || !1,
949
+ onChange: (a) => h({ ...n, showExportButtons: a.target.checked })
580
950
  }
581
951
  ),
582
952
  /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Export Buttons" })
@@ -586,8 +956,8 @@ const Te = ({ schema: v }) => {
586
956
  "input",
587
957
  {
588
958
  type: "checkbox",
589
- checked: i.showPrintButton || !1,
590
- onChange: (r) => h({ ...i, showPrintButton: r.target.checked })
959
+ checked: n.showPrintButton || !1,
960
+ onChange: (a) => h({ ...n, showPrintButton: a.target.checked })
591
961
  }
592
962
  ),
593
963
  /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Print Button" })
@@ -595,14 +965,14 @@ const Te = ({ schema: v }) => {
595
965
  ] })
596
966
  ] }),
597
967
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
598
- /* @__PURE__ */ e.jsx(x, { htmlFor: "export-format", children: "Default Export Format" }),
968
+ /* @__PURE__ */ e.jsx(b, { htmlFor: "export-format", children: "Default Export Format" }),
599
969
  /* @__PURE__ */ e.jsxs(
600
970
  "select",
601
971
  {
602
972
  id: "export-format",
603
973
  className: "w-full border rounded-md p-2",
604
- value: i.defaultExportFormat || "pdf",
605
- onChange: (r) => h({ ...i, defaultExportFormat: r.target.value }),
974
+ value: n.defaultExportFormat || "pdf",
975
+ onChange: (a) => h({ ...n, defaultExportFormat: a.target.value }),
606
976
  children: [
607
977
  /* @__PURE__ */ e.jsx("option", { value: "pdf", children: "PDF" }),
608
978
  /* @__PURE__ */ e.jsx("option", { value: "excel", children: "Excel" }),
@@ -614,48 +984,48 @@ const Te = ({ schema: v }) => {
614
984
  )
615
985
  ] })
616
986
  ] }) }),
617
- /* @__PURE__ */ e.jsxs(H, { value: "fields", className: "space-y-4 mt-4", children: [
987
+ /* @__PURE__ */ e.jsxs(Y, { value: "fields", className: "space-y-4 mt-4", children: [
618
988
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
619
- /* @__PURE__ */ e.jsx(x, { children: "Report Fields" }),
989
+ /* @__PURE__ */ e.jsx(b, { children: "Report Fields" }),
620
990
  /* @__PURE__ */ e.jsxs(
621
- E,
991
+ F,
622
992
  {
623
993
  size: "sm",
624
994
  variant: "outline",
625
- onClick: _,
626
- disabled: j.length >= d.length,
995
+ onClick: k,
996
+ disabled: l.length >= c.length,
627
997
  children: [
628
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
998
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
629
999
  "Add Field"
630
1000
  ]
631
1001
  }
632
1002
  )
633
1003
  ] }),
634
1004
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
635
- j.map((r, t) => /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-4 gap-2", children: [
1005
+ l.map((a, o) => /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-4 gap-2", children: [
636
1006
  /* @__PURE__ */ e.jsxs("div", { children: [
637
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field Name" }),
638
- /* @__PURE__ */ e.jsx("div", { className: "text-sm font-medium", children: r.name })
1007
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Field Name" }),
1008
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm font-medium", children: a.name })
639
1009
  ] }),
640
1010
  /* @__PURE__ */ e.jsxs("div", { children: [
641
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Label" }),
1011
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Label" }),
642
1012
  /* @__PURE__ */ e.jsx(
643
- D,
1013
+ A,
644
1014
  {
645
1015
  className: "h-8 text-sm",
646
- value: r.label || r.name,
647
- onChange: (a) => A(t, { ...r, label: a.target.value })
1016
+ value: a.label || a.name,
1017
+ onChange: (u) => _(o, { ...a, label: u.target.value })
648
1018
  }
649
1019
  )
650
1020
  ] }),
651
1021
  /* @__PURE__ */ e.jsxs("div", { children: [
652
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Aggregation" }),
1022
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Aggregation" }),
653
1023
  /* @__PURE__ */ e.jsxs(
654
1024
  "select",
655
1025
  {
656
1026
  className: "w-full border rounded-md h-8 text-sm px-2",
657
- value: r.aggregation || "",
658
- onChange: (a) => A(t, { ...r, aggregation: a.target.value }),
1027
+ value: a.aggregation || "",
1028
+ onChange: (u) => _(o, { ...a, aggregation: u.target.value }),
659
1029
  children: [
660
1030
  /* @__PURE__ */ e.jsx("option", { value: "", children: "None" }),
661
1031
  /* @__PURE__ */ e.jsx("option", { value: "sum", children: "Sum" }),
@@ -668,50 +1038,50 @@ const Te = ({ schema: v }) => {
668
1038
  )
669
1039
  ] }),
670
1040
  /* @__PURE__ */ e.jsx("div", { className: "flex items-end justify-end", children: /* @__PURE__ */ e.jsx(
671
- E,
1041
+ F,
672
1042
  {
673
1043
  size: "sm",
674
1044
  variant: "ghost",
675
1045
  className: "text-red-500 hover:text-red-700 hover:bg-red-50",
676
- onClick: () => k(t),
677
- children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
1046
+ onClick: () => g(o),
1047
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-4 w-4" })
678
1048
  }
679
1049
  ) })
680
- ] }) }, t)),
681
- j.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: 'No fields selected. Click "Add Field" to begin.' })
1050
+ ] }) }, o)),
1051
+ l.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: 'No fields selected. Click "Add Field" to begin.' })
682
1052
  ] })
683
1053
  ] }),
684
- /* @__PURE__ */ e.jsxs(H, { value: "filters", className: "space-y-4 mt-4", children: [
1054
+ /* @__PURE__ */ e.jsxs(Y, { value: "filters", className: "space-y-4 mt-4", children: [
685
1055
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
686
- /* @__PURE__ */ e.jsx(x, { children: "Report Filters" }),
687
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: O, children: [
688
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
1056
+ /* @__PURE__ */ e.jsx(b, { children: "Report Filters" }),
1057
+ /* @__PURE__ */ e.jsxs(F, { size: "sm", variant: "outline", onClick: D, children: [
1058
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
689
1059
  "Add Filter"
690
1060
  ] })
691
1061
  ] }),
692
1062
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
693
- y.map((r, t) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
1063
+ y.map((a, o) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
694
1064
  /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-3 gap-2", children: [
695
1065
  /* @__PURE__ */ e.jsxs("div", { children: [
696
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field" }),
1066
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Field" }),
697
1067
  /* @__PURE__ */ e.jsx(
698
1068
  "select",
699
1069
  {
700
1070
  className: "w-full border rounded-md h-8 text-sm px-2",
701
- value: r.field,
702
- onChange: (a) => B(t, { ...r, field: a.target.value }),
703
- children: d.map((a, R) => /* @__PURE__ */ e.jsx("option", { value: a.name, children: a.label || a.name }, R))
1071
+ value: a.field,
1072
+ onChange: (u) => O(o, { ...a, field: u.target.value }),
1073
+ children: c.map((u, T) => /* @__PURE__ */ e.jsx("option", { value: u.name, children: u.label || u.name }, T))
704
1074
  }
705
1075
  )
706
1076
  ] }),
707
1077
  /* @__PURE__ */ e.jsxs("div", { children: [
708
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Operator" }),
1078
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Operator" }),
709
1079
  /* @__PURE__ */ e.jsxs(
710
1080
  "select",
711
1081
  {
712
1082
  className: "w-full border rounded-md h-8 text-sm px-2",
713
- value: r.operator,
714
- onChange: (a) => B(t, { ...r, operator: a.target.value }),
1083
+ value: a.operator,
1084
+ onChange: (u) => O(o, { ...a, operator: u.target.value }),
715
1085
  children: [
716
1086
  /* @__PURE__ */ e.jsx("option", { value: "equals", children: "Equals" }),
717
1087
  /* @__PURE__ */ e.jsx("option", { value: "contains", children: "Contains" }),
@@ -723,62 +1093,62 @@ const Te = ({ schema: v }) => {
723
1093
  )
724
1094
  ] }),
725
1095
  /* @__PURE__ */ e.jsxs("div", { children: [
726
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Value" }),
1096
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Value" }),
727
1097
  /* @__PURE__ */ e.jsx(
728
- D,
1098
+ A,
729
1099
  {
730
1100
  className: "h-8 text-sm",
731
- value: String(r.value),
732
- onChange: (a) => B(t, { ...r, value: a.target.value })
1101
+ value: String(a.value),
1102
+ onChange: (u) => O(o, { ...a, value: u.target.value })
733
1103
  }
734
1104
  )
735
1105
  ] })
736
1106
  ] }),
737
1107
  /* @__PURE__ */ e.jsx(
738
- E,
1108
+ F,
739
1109
  {
740
1110
  size: "sm",
741
1111
  variant: "ghost",
742
1112
  className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
743
- onClick: () => $(t),
744
- children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
1113
+ onClick: () => M(o),
1114
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-4 w-4" })
745
1115
  }
746
1116
  )
747
- ] }, t)),
1117
+ ] }, o)),
748
1118
  y.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No filters defined." })
749
1119
  ] })
750
1120
  ] }),
751
- /* @__PURE__ */ e.jsxs(H, { value: "grouping", className: "space-y-4 mt-4", children: [
1121
+ /* @__PURE__ */ e.jsxs(Y, { value: "grouping", className: "space-y-4 mt-4", children: [
752
1122
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
753
- /* @__PURE__ */ e.jsx(x, { children: "Grouping Rules" }),
754
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: re, children: [
755
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
1123
+ /* @__PURE__ */ e.jsx(b, { children: "Grouping Rules" }),
1124
+ /* @__PURE__ */ e.jsxs(F, { size: "sm", variant: "outline", onClick: q, children: [
1125
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
756
1126
  "Add Group"
757
1127
  ] })
758
1128
  ] }),
759
1129
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
760
- w.map((r, t) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
1130
+ w.map((a, o) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
761
1131
  /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-2 gap-2", children: [
762
1132
  /* @__PURE__ */ e.jsxs("div", { children: [
763
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field" }),
1133
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Field" }),
764
1134
  /* @__PURE__ */ e.jsx(
765
1135
  "select",
766
1136
  {
767
1137
  className: "w-full border rounded-md h-8 text-sm px-2",
768
- value: r.field,
769
- onChange: (a) => L(t, { ...r, field: a.target.value }),
770
- children: d.map((a, R) => /* @__PURE__ */ e.jsx("option", { value: a.name, children: a.label || a.name }, R))
1138
+ value: a.field,
1139
+ onChange: (u) => I(o, { ...a, field: u.target.value }),
1140
+ children: c.map((u, T) => /* @__PURE__ */ e.jsx("option", { value: u.name, children: u.label || u.name }, T))
771
1141
  }
772
1142
  )
773
1143
  ] }),
774
1144
  /* @__PURE__ */ e.jsxs("div", { children: [
775
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Sort Order" }),
1145
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Sort Order" }),
776
1146
  /* @__PURE__ */ e.jsxs(
777
1147
  "select",
778
1148
  {
779
1149
  className: "w-full border rounded-md h-8 text-sm px-2",
780
- value: r.sort || "asc",
781
- onChange: (a) => L(t, { ...r, sort: a.target.value }),
1150
+ value: a.sort || "asc",
1151
+ onChange: (u) => I(o, { ...a, sort: u.target.value }),
782
1152
  children: [
783
1153
  /* @__PURE__ */ e.jsx("option", { value: "asc", children: "Ascending" }),
784
1154
  /* @__PURE__ */ e.jsx("option", { value: "desc", children: "Descending" })
@@ -788,92 +1158,92 @@ const Te = ({ schema: v }) => {
788
1158
  ] })
789
1159
  ] }),
790
1160
  /* @__PURE__ */ e.jsx(
791
- E,
1161
+ F,
792
1162
  {
793
1163
  size: "sm",
794
1164
  variant: "ghost",
795
1165
  className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
796
- onClick: () => te(t),
797
- children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
1166
+ onClick: () => H(o),
1167
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-4 w-4" })
798
1168
  }
799
1169
  )
800
- ] }, t)),
1170
+ ] }, o)),
801
1171
  w.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No grouping rules applied." })
802
1172
  ] })
803
1173
  ] }),
804
- /* @__PURE__ */ e.jsxs(H, { value: "sections", className: "space-y-4 mt-4", children: [
1174
+ /* @__PURE__ */ e.jsxs(Y, { value: "sections", className: "space-y-4 mt-4", children: [
805
1175
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
806
- /* @__PURE__ */ e.jsx(x, { children: "Report Sections" }),
1176
+ /* @__PURE__ */ e.jsx(b, { children: "Report Sections" }),
807
1177
  /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
808
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("header"), children: [
809
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
1178
+ /* @__PURE__ */ e.jsxs(F, { size: "sm", variant: "outline", onClick: () => J("header"), children: [
1179
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
810
1180
  "Header"
811
1181
  ] }),
812
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("chart"), children: [
813
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
1182
+ /* @__PURE__ */ e.jsxs(F, { size: "sm", variant: "outline", onClick: () => J("chart"), children: [
1183
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
814
1184
  "Chart"
815
1185
  ] }),
816
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("table"), children: [
817
- /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
1186
+ /* @__PURE__ */ e.jsxs(F, { size: "sm", variant: "outline", onClick: () => J("table"), children: [
1187
+ /* @__PURE__ */ e.jsx(V, { className: "h-4 w-4 mr-2" }),
818
1188
  "Table"
819
1189
  ] })
820
1190
  ] })
821
1191
  ] }),
822
1192
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
823
- C.map((r, t) => {
824
- var a, R, V, U;
1193
+ v.map((a, o) => {
1194
+ var u, T, X, Z;
825
1195
  return /* @__PURE__ */ e.jsxs("div", { className: "p-3 border rounded-lg space-y-2", children: [
826
1196
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
827
1197
  /* @__PURE__ */ e.jsxs("div", { className: "font-medium flex items-center gap-2", children: [
828
- /* @__PURE__ */ e.jsx("div", { className: "text-xs bg-muted px-2 py-0.5 rounded uppercase", children: r.type }),
829
- r.title
1198
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs bg-muted px-2 py-0.5 rounded uppercase", children: a.type }),
1199
+ a.title
830
1200
  ] }),
831
1201
  /* @__PURE__ */ e.jsx(
832
- E,
1202
+ F,
833
1203
  {
834
1204
  size: "sm",
835
1205
  variant: "ghost",
836
1206
  className: "text-red-500 hover:text-red-700 hover:bg-red-50",
837
- onClick: () => ae(t),
838
- children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
1207
+ onClick: () => ne(o),
1208
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-4 w-4" })
839
1209
  }
840
1210
  )
841
1211
  ] }),
842
1212
  /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
843
1213
  /* @__PURE__ */ e.jsxs("div", { children: [
844
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Title" }),
1214
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Title" }),
845
1215
  /* @__PURE__ */ e.jsx(
846
- D,
1216
+ A,
847
1217
  {
848
1218
  className: "h-8 text-sm",
849
- value: r.title || "",
850
- onChange: (s) => F(t, { ...r, title: s.target.value })
1219
+ value: a.title || "",
1220
+ onChange: (t) => P(o, { ...a, title: t.target.value })
851
1221
  }
852
1222
  )
853
1223
  ] }),
854
- r.type === "text" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
855
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Content" }),
1224
+ a.type === "text" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
1225
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Content" }),
856
1226
  /* @__PURE__ */ e.jsx(
857
- D,
1227
+ A,
858
1228
  {
859
1229
  className: "h-8 text-sm",
860
- value: r.text || "",
861
- onChange: (s) => F(t, { ...r, text: s.target.value })
1230
+ value: a.text || "",
1231
+ onChange: (t) => P(o, { ...a, text: t.target.value })
862
1232
  }
863
1233
  )
864
1234
  ] }),
865
- r.type === "chart" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded", children: [
866
- /* @__PURE__ */ e.jsx("div", { className: "col-span-2", children: /* @__PURE__ */ e.jsx(x, { className: "text-xs font-semibold", children: "Chart Configuration" }) }),
1235
+ a.type === "chart" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded", children: [
1236
+ /* @__PURE__ */ e.jsx("div", { className: "col-span-2", children: /* @__PURE__ */ e.jsx(b, { className: "text-xs font-semibold", children: "Chart Configuration" }) }),
867
1237
  /* @__PURE__ */ e.jsxs("div", { children: [
868
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Chart Type" }),
1238
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Chart Type" }),
869
1239
  /* @__PURE__ */ e.jsxs(
870
1240
  "select",
871
1241
  {
872
1242
  className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
873
- value: ((a = r.chart) == null ? void 0 : a.chartType) || "bar",
874
- onChange: (s) => F(t, {
875
- ...r,
876
- chart: { ...r.chart, type: "chart", chartType: s.target.value }
1243
+ value: ((u = a.chart) == null ? void 0 : u.chartType) || "bar",
1244
+ onChange: (t) => P(o, {
1245
+ ...a,
1246
+ chart: { ...a.chart, type: "chart", chartType: t.target.value }
877
1247
  }),
878
1248
  children: [
879
1249
  /* @__PURE__ */ e.jsx("option", { value: "bar", children: "Bar" }),
@@ -885,20 +1255,20 @@ const Te = ({ schema: v }) => {
885
1255
  )
886
1256
  ] }),
887
1257
  /* @__PURE__ */ e.jsxs("div", { children: [
888
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "X-Axis Field" }),
1258
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "X-Axis Field" }),
889
1259
  /* @__PURE__ */ e.jsxs(
890
1260
  "select",
891
1261
  {
892
1262
  className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
893
- value: ((R = r.chart) == null ? void 0 : R.xAxisField) || "",
894
- onChange: (s) => F(t, {
895
- ...r,
896
- chart: { ...r.chart, type: "chart", xAxisField: s.target.value }
1263
+ value: ((T = a.chart) == null ? void 0 : T.xAxisField) || "",
1264
+ onChange: (t) => P(o, {
1265
+ ...a,
1266
+ chart: { ...a.chart, type: "chart", xAxisField: t.target.value }
897
1267
  }),
898
1268
  children: [
899
1269
  /* @__PURE__ */ e.jsx("option", { value: "", children: "Select Field..." }),
900
- d.map((s) => /* @__PURE__ */ e.jsx("option", { value: s.name, children: s.label || s.name }, s.name)),
901
- d.length === 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1270
+ c.map((t) => /* @__PURE__ */ e.jsx("option", { value: t.name, children: t.label || t.name }, t.name)),
1271
+ c.length === 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
902
1272
  /* @__PURE__ */ e.jsx("option", { value: "name", children: "Name" }),
903
1273
  /* @__PURE__ */ e.jsx("option", { value: "month", children: "Month" })
904
1274
  ] })
@@ -907,19 +1277,19 @@ const Te = ({ schema: v }) => {
907
1277
  )
908
1278
  ] }),
909
1279
  /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
910
- /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Y-Axis Fields (comma separated)" }),
1280
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Y-Axis Fields (comma separated)" }),
911
1281
  /* @__PURE__ */ e.jsx(
912
- D,
1282
+ A,
913
1283
  {
914
1284
  className: "h-8 text-sm",
915
1285
  placeholder: "e.g. value, count",
916
- value: ((U = (V = r.chart) == null ? void 0 : V.yAxisFields) == null ? void 0 : U.join(", ")) || "",
917
- onChange: (s) => F(t, {
918
- ...r,
1286
+ value: ((Z = (X = a.chart) == null ? void 0 : X.yAxisFields) == null ? void 0 : Z.join(", ")) || "",
1287
+ onChange: (t) => P(o, {
1288
+ ...a,
919
1289
  chart: {
920
- ...r.chart,
1290
+ ...a.chart,
921
1291
  type: "chart",
922
- yAxisFields: s.target.value.split(",").map((n) => n.trim()).filter(Boolean)
1292
+ yAxisFields: t.target.value.split(",").map((x) => x.trim()).filter(Boolean)
923
1293
  }
924
1294
  })
925
1295
  }
@@ -927,34 +1297,41 @@ const Te = ({ schema: v }) => {
927
1297
  ] })
928
1298
  ] })
929
1299
  ] })
930
- ] }, t);
1300
+ ] }, o);
931
1301
  }),
932
- C.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No customized sections. The default report layout will be used." })
1302
+ v.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No customized sections. The default report layout will be used." })
933
1303
  ] })
934
- ] })
1304
+ ] }),
1305
+ /* @__PURE__ */ e.jsx(Y, { value: "schedule", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsx(
1306
+ Ge,
1307
+ {
1308
+ schedule: n.schedule,
1309
+ onChange: (a) => h({ ...n, schedule: a })
1310
+ }
1311
+ ) })
935
1312
  ] }),
936
1313
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t", children: [
937
- /* @__PURE__ */ e.jsx(E, { variant: "outline", onClick: le, children: "Cancel" }),
938
- /* @__PURE__ */ e.jsxs(E, { onClick: Z, children: [
939
- /* @__PURE__ */ e.jsx(Re, { className: "h-4 w-4 mr-2" }),
1314
+ /* @__PURE__ */ e.jsx(F, { variant: "outline", onClick: ie, children: "Cancel" }),
1315
+ /* @__PURE__ */ e.jsxs(F, { onClick: se, children: [
1316
+ /* @__PURE__ */ e.jsx(Oe, { className: "h-4 w-4 mr-2" }),
940
1317
  "Save Report"
941
1318
  ] })
942
1319
  ] })
943
1320
  ] })
944
1321
  ] }),
945
- m && /* @__PURE__ */ e.jsxs(z, { className: "mt-8 border-2 border-blue-100", children: [
946
- /* @__PURE__ */ e.jsx(ee, { className: "bg-blue-50/50", children: /* @__PURE__ */ e.jsx(se, { className: "text-blue-900 text-sm uppercase tracking-wide", children: "Live Preview" }) }),
947
- /* @__PURE__ */ e.jsx(Y, { className: "pt-6", children: /* @__PURE__ */ e.jsx(
948
- xe,
1322
+ d && /* @__PURE__ */ e.jsxs(B, { className: "mt-8 border-2 border-blue-100", children: [
1323
+ /* @__PURE__ */ e.jsx(ee, { className: "bg-blue-50/50", children: /* @__PURE__ */ e.jsx(te, { className: "text-blue-900 text-sm uppercase tracking-wide", children: "Live Preview" }) }),
1324
+ /* @__PURE__ */ e.jsx(z, { className: "pt-6", children: /* @__PURE__ */ e.jsx(
1325
+ we,
949
1326
  {
950
1327
  schema: {
951
1328
  type: "report-viewer",
952
1329
  report: {
953
- ...i,
954
- fields: j,
1330
+ ...n,
1331
+ fields: l,
955
1332
  filters: y,
956
1333
  groupBy: w,
957
- sections: C
1334
+ sections: v
958
1335
  },
959
1336
  // Mock data for preview
960
1337
  data: [
@@ -968,9 +1345,129 @@ const Te = ({ schema: v }) => {
968
1345
  ] })
969
1346
  ] });
970
1347
  };
971
- P.register(
1348
+ async function Ye(r, i) {
1349
+ var h;
1350
+ const {
1351
+ dataSource: s,
1352
+ resource: c,
1353
+ queryParams: d,
1354
+ format: p,
1355
+ exportConfig: f
1356
+ } = i, n = p || r.defaultExportFormat || "pdf";
1357
+ try {
1358
+ const j = (await s.find(c, d)).data || [], y = {
1359
+ format: n,
1360
+ ...(h = r.exportConfigs) == null ? void 0 : h[n],
1361
+ ...f
1362
+ };
1363
+ return be(n, r, j, y), {
1364
+ success: !0,
1365
+ recordCount: j.length,
1366
+ format: n
1367
+ };
1368
+ } catch (l) {
1369
+ return {
1370
+ success: !1,
1371
+ recordCount: 0,
1372
+ format: n,
1373
+ error: l.message
1374
+ };
1375
+ }
1376
+ }
1377
+ function st(r, i, s = {}) {
1378
+ const { columns: c, filename: d, includeAggregationRow: p = !1 } = s, f = c || (r.fields || []).map(Ve), n = f.map((y) => y.header), h = i.map((y, R) => f.map((w) => {
1379
+ if (w.formula)
1380
+ return w.formula.replace(/\{ROW\}/g, String(R + 2));
1381
+ const m = y[w.name];
1382
+ return We(m, w.numberFormat);
1383
+ }));
1384
+ if (p && i.length > 0) {
1385
+ const y = f.map((R, w) => {
1386
+ const m = (r.fields || []).find((v) => v.name === R.name);
1387
+ if (m != null && m.aggregation) {
1388
+ const v = He(w), N = 2, k = i.length + 1;
1389
+ switch (m.aggregation) {
1390
+ case "sum":
1391
+ return `=SUM(${v}${N}:${v}${k})`;
1392
+ case "avg":
1393
+ return `=AVERAGE(${v}${N}:${v}${k})`;
1394
+ case "count":
1395
+ return `=COUNTA(${v}${N}:${v}${k})`;
1396
+ case "min":
1397
+ return `=MIN(${v}${N}:${v}${k})`;
1398
+ case "max":
1399
+ return `=MAX(${v}${N}:${v}${k})`;
1400
+ default:
1401
+ return "";
1402
+ }
1403
+ }
1404
+ return "";
1405
+ });
1406
+ h.push(y);
1407
+ }
1408
+ const l = "\uFEFF" + [
1409
+ n.join(" "),
1410
+ ...h.map((y) => y.join(" "))
1411
+ ].join(`
1412
+ `), j = d || `${r.title || "report"}.tsv`;
1413
+ Xe(l, j, "text/tab-separated-values");
1414
+ }
1415
+ function rt(r, i, s, c) {
1416
+ return async () => {
1417
+ const d = r.schedule;
1418
+ if (!(d != null && d.enabled))
1419
+ return [];
1420
+ const p = d.formats || [r.defaultExportFormat || "pdf"], f = [];
1421
+ for (const n of p) {
1422
+ const h = await Ye(r, {
1423
+ dataSource: i,
1424
+ resource: s,
1425
+ format: n
1426
+ });
1427
+ f.push(h);
1428
+ }
1429
+ return c(r, d), f;
1430
+ };
1431
+ }
1432
+ function Ve(r) {
1433
+ return {
1434
+ name: r.name,
1435
+ header: r.label || r.name
1436
+ };
1437
+ }
1438
+ function We(r, i) {
1439
+ return r == null ? "" : typeof r == "number" && i ? r.toLocaleString("en-US", qe(i)) : Je(String(r));
1440
+ }
1441
+ function qe(r) {
1442
+ if (r.includes("%"))
1443
+ return { style: "percent", minimumFractionDigits: 0 };
1444
+ const i = (r.match(/0/g) || []).length;
1445
+ return {
1446
+ minimumFractionDigits: Math.max(0, i - 1),
1447
+ maximumFractionDigits: Math.max(0, i - 1)
1448
+ };
1449
+ }
1450
+ function He(r) {
1451
+ let i = "", s = r;
1452
+ for (; s >= 0; )
1453
+ i = String.fromCharCode(s % 26 + 65) + i, s = Math.floor(s / 26) - 1;
1454
+ return i;
1455
+ }
1456
+ function Je(r) {
1457
+ if (r.length > 0) {
1458
+ const i = r.charAt(0);
1459
+ if (i === "=" || i === "+" || i === "-" || i === "@" || i === "|")
1460
+ return `'${r}`;
1461
+ }
1462
+ return r;
1463
+ }
1464
+ function Xe(r, i, s) {
1465
+ const c = new Blob([r], { type: `${s};charset=utf-8` }), d = URL.createObjectURL(c), p = document.createElement("a");
1466
+ p.href = d, p.download = i, document.body.appendChild(p), p.click(), document.body.removeChild(p), URL.revokeObjectURL(d);
1467
+ }
1468
+ L.register(
972
1469
  "report",
973
- Te,
1470
+ De,
974
1471
  {
975
1472
  label: "Report",
976
1473
  category: "Report",
@@ -981,9 +1478,9 @@ P.register(
981
1478
  ]
982
1479
  }
983
1480
  );
984
- P.register(
1481
+ L.register(
985
1482
  "report-viewer",
986
- xe,
1483
+ we,
987
1484
  {
988
1485
  label: "Report Viewer",
989
1486
  category: "Report",
@@ -993,9 +1490,9 @@ P.register(
993
1490
  ]
994
1491
  }
995
1492
  );
996
- P.register(
1493
+ L.register(
997
1494
  "report-builder",
998
- _e,
1495
+ Ue,
999
1496
  {
1000
1497
  label: "Report Builder",
1001
1498
  category: "Report",
@@ -1005,7 +1502,17 @@ P.register(
1005
1502
  }
1006
1503
  );
1007
1504
  export {
1008
- _e as ReportBuilder,
1009
- Te as ReportRenderer,
1010
- xe as ReportViewer
1505
+ Ue as ReportBuilder,
1506
+ De as ReportRenderer,
1507
+ we as ReportViewer,
1508
+ Ge as ScheduleConfig,
1509
+ rt as createScheduleTrigger,
1510
+ Be as exportAsCSV,
1511
+ Ie as exportAsExcel,
1512
+ ve as exportAsHTML,
1513
+ ze as exportAsJSON,
1514
+ Me as exportAsPDF,
1515
+ st as exportExcelWithFormulas,
1516
+ be as exportReport,
1517
+ Ye as exportWithLiveData
1011
1518
  };