@object-ui/plugin-report 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +2346 -2140
  2. package/dist/index.umd.cjs +21 -37
  3. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -1,356 +1,268 @@
1
- import { ComponentRegistry as U } from "@object-ui/core";
2
- import * as Ee from "react";
3
- import ve, { useState as J } from "react";
4
- import { Card as V, CardHeader as ae, CardTitle as se, CardDescription as he, CardContent as Y, Button as E, Skeleton as ne, Badge as Ae, Label as j, Input as M, Tabs as Fe, TabsList as _e, TabsTrigger as W, TabsContent as H, useConfigDraft as $e, ConfigPanelRenderer as Oe, Checkbox as Pe } from "@object-ui/components";
5
- import { SchemaRenderer as xe } from "@object-ui/react";
6
- import { RefreshCw as De, Printer as Le, Download as ue, Calendar as je, Clock as Be, Mail as Me, Settings as ze, Layers as me, Filter as Ie, Plus as G, Trash2 as X, Save as Ge } from "lucide-react";
7
- var pe = { exports: {} }, ee = {};
8
- /**
9
- * @license React
10
- * react-jsx-runtime.production.js
11
- *
12
- * Copyright (c) Meta Platforms, Inc. and affiliates.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- */
17
- var fe;
18
- function Ue() {
19
- if (fe) return ee;
20
- fe = 1;
21
- var s = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
22
- function a(o, c, x) {
23
- var u = null;
24
- if (x !== void 0 && (u = "" + x), c.key !== void 0 && (u = "" + c.key), "key" in c) {
25
- x = {};
26
- for (var t in c)
27
- t !== "key" && (x[t] = c[t]);
28
- } else x = c;
29
- return c = x.ref, {
30
- $$typeof: s,
31
- type: o,
32
- key: u,
33
- ref: c !== void 0 ? c : null,
34
- props: x
35
- };
36
- }
37
- return ee.Fragment = n, ee.jsx = a, ee.jsxs = a, ee;
38
- }
39
- var te = {};
40
- /**
41
- * @license React
42
- * react-jsx-runtime.development.js
43
- *
44
- * Copyright (c) Meta Platforms, Inc. and affiliates.
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE file in the root directory of this source tree.
48
- */
49
- var be;
50
- function Ve() {
51
- return be || (be = 1, process.env.NODE_ENV !== "production" && function() {
52
- function s(l) {
53
- if (l == null) return null;
54
- if (typeof l == "function")
55
- return l.$$typeof === Z ? null : l.displayName || l.name || null;
56
- if (typeof l == "string") return l;
57
- switch (l) {
58
- case m:
59
- return "Fragment";
60
- case C:
61
- return "Profiler";
62
- case N:
63
- return "StrictMode";
64
- case $:
65
- return "Suspense";
66
- case P:
67
- return "SuspenseList";
68
- case B:
69
- return "Activity";
70
- }
71
- if (typeof l == "object")
72
- switch (typeof l.tag == "number" && console.error(
73
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
74
- ), l.$$typeof) {
75
- case k:
76
- return "Portal";
77
- case g:
78
- return l.displayName || "Context";
79
- case y:
80
- return (l._context.displayName || "Context") + ".Consumer";
81
- case T:
82
- var b = l.render;
83
- return l = l.displayName, l || (l = b.displayName || b.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
84
- case D:
85
- return b = l.displayName || null, b !== null ? b : s(l.type) || "Memo";
86
- case L:
87
- b = l._payload, l = l._init;
88
- try {
89
- return s(l(b));
90
- } catch {
91
- }
92
- }
93
- return null;
94
- }
95
- function n(l) {
96
- return "" + l;
97
- }
98
- function a(l) {
99
- try {
100
- n(l);
101
- var b = !1;
102
- } catch {
103
- b = !0;
104
- }
105
- if (b) {
106
- b = console;
107
- var R = b.error, A = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
108
- return R.call(
109
- b,
110
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
111
- A
112
- ), n(l);
113
- }
114
- }
115
- function o(l) {
116
- if (l === m) return "<>";
117
- if (typeof l == "object" && l !== null && l.$$typeof === L)
118
- return "<...>";
119
- try {
120
- var b = s(l);
121
- return b ? "<" + b + ">" : "<...>";
122
- } catch {
123
- return "<...>";
124
- }
125
- }
126
- function c() {
127
- var l = I.A;
128
- return l === null ? null : l.getOwner();
129
- }
130
- function x() {
131
- return Error("react-stack-top-frame");
132
- }
133
- function u(l) {
134
- if (re.call(l, "key")) {
135
- var b = Object.getOwnPropertyDescriptor(l, "key").get;
136
- if (b && b.isReactWarning) return !1;
137
- }
138
- return l.key !== void 0;
139
- }
140
- function t(l, b) {
141
- function R() {
142
- h || (h = !0, console.error(
143
- "%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)",
144
- b
145
- ));
146
- }
147
- R.isReactWarning = !0, Object.defineProperty(l, "key", {
148
- get: R,
149
- configurable: !0
150
- });
151
- }
152
- function i() {
153
- var l = s(this.type);
154
- return f[l] || (f[l] = !0, console.error(
155
- "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."
156
- )), l = this.props.ref, l !== void 0 ? l : null;
157
- }
158
- function r(l, b, R, A, le, ce) {
159
- var F = R.ref;
160
- return l = {
161
- $$typeof: _,
162
- type: l,
163
- key: b,
164
- props: R,
165
- _owner: A
166
- }, (F !== void 0 ? F : null) !== null ? Object.defineProperty(l, "ref", {
167
- enumerable: !1,
168
- get: i
169
- }) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
170
- configurable: !1,
171
- enumerable: !1,
172
- writable: !0,
173
- value: 0
174
- }), Object.defineProperty(l, "_debugInfo", {
175
- configurable: !1,
176
- enumerable: !1,
177
- writable: !0,
178
- value: null
179
- }), Object.defineProperty(l, "_debugStack", {
180
- configurable: !1,
181
- enumerable: !1,
182
- writable: !0,
183
- value: le
184
- }), Object.defineProperty(l, "_debugTask", {
185
- configurable: !1,
186
- enumerable: !1,
187
- writable: !0,
188
- value: ce
189
- }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
190
- }
191
- function p(l, b, R, A, le, ce) {
192
- var F = b.children;
193
- if (F !== void 0)
194
- if (A)
195
- if (ie(F)) {
196
- for (A = 0; A < F.length; A++)
197
- v(F[A]);
198
- Object.freeze && Object.freeze(F);
199
- } else
200
- console.error(
201
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
202
- );
203
- else v(F);
204
- if (re.call(b, "key")) {
205
- F = s(l);
206
- var q = Object.keys(b).filter(function(Te) {
207
- return Te !== "key";
208
- });
209
- A = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", K[F + A] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
210
- `A props object containing a "key" prop is being spread into JSX:
211
- let props = %s;
212
- <%s {...props} />
213
- React keys must be passed directly to JSX without using spread:
214
- let props = %s;
215
- <%s key={someKey} {...props} />`,
216
- A,
217
- F,
218
- q,
219
- F
220
- ), K[F + A] = !0);
221
- }
222
- if (F = null, R !== void 0 && (a(R), F = "" + R), u(b) && (a(b.key), F = "" + b.key), "key" in b) {
223
- R = {};
224
- for (var de in b)
225
- de !== "key" && (R[de] = b[de]);
226
- } else R = b;
227
- return F && t(
228
- R,
229
- typeof l == "function" ? l.displayName || l.name || "Unknown" : l
230
- ), r(
231
- l,
232
- F,
233
- R,
234
- c(),
235
- le,
236
- ce
237
- );
238
- }
239
- function v(l) {
240
- S(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === L && (l._payload.status === "fulfilled" ? S(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
241
- }
242
- function S(l) {
243
- return typeof l == "object" && l !== null && l.$$typeof === _;
244
- }
245
- var w = ve, _ = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), N = Symbol.for("react.strict_mode"), C = Symbol.for("react.profiler"), y = Symbol.for("react.consumer"), g = Symbol.for("react.context"), T = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), B = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), I = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, re = Object.prototype.hasOwnProperty, ie = Array.isArray, d = console.createTask ? console.createTask : function() {
246
- return null;
247
- };
248
- w = {
249
- react_stack_bottom_frame: function(l) {
250
- return l();
251
- }
252
- };
253
- var h, f = {}, O = w.react_stack_bottom_frame.bind(
254
- w,
255
- x
256
- )(), Q = d(o(x)), K = {};
257
- te.Fragment = m, te.jsx = function(l, b, R) {
258
- var A = 1e4 > I.recentlyCreatedOwnerStacks++;
259
- return p(
260
- l,
261
- b,
262
- R,
263
- !1,
264
- A ? Error("react-stack-top-frame") : O,
265
- A ? d(o(l)) : Q
266
- );
267
- }, te.jsxs = function(l, b, R) {
268
- var A = 1e4 > I.recentlyCreatedOwnerStacks++;
269
- return p(
270
- l,
271
- b,
272
- R,
273
- !0,
274
- A ? Error("react-stack-top-frame") : O,
275
- A ? d(o(l)) : Q
276
- );
277
- };
278
- }()), te;
279
- }
280
- process.env.NODE_ENV === "production" ? pe.exports = Ue() : pe.exports = Ve();
281
- var e = pe.exports;
282
- const Ye = ({ schema: s }) => {
283
- var i;
284
- const { title: n, description: a, data: o, columns: c } = s;
285
- (i = s.chart) != null && i.type;
286
- const x = !!s.chart, t = !(process.env.NODE_ENV === "test");
287
- return /* @__PURE__ */ e.jsxs(V, { className: `h-full flex flex-col ${s.className || ""}`, children: [
288
- /* @__PURE__ */ e.jsxs(ae, { children: [
289
- n && /* @__PURE__ */ e.jsx(se, { children: n }),
290
- a && /* @__PURE__ */ e.jsx(he, { children: a })
291
- ] }),
292
- /* @__PURE__ */ e.jsxs(Y, { className: "flex-1 overflow-auto space-y-4", children: [
293
- x && (() => {
294
- var v;
295
- const r = (v = s.chart) == null ? void 0 : v.type;
296
- let p = r ? U.get(r) : null;
297
- return p || (p = U.get("chart")), p ? /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px] border rounded-lg p-4 bg-background/50", children: /* @__PURE__ */ e.jsx(p, { schema: { ...s.chart, data: s.chart.data || o } }) }) : /* @__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: [
298
- "Unknown component type: ",
299
- r || "chart"
300
- ] });
301
- })(),
302
- o && o.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg", children: (() => {
303
- const r = t ? U.get("aggrid") || U.get("table") : null;
304
- return r ? /* @__PURE__ */ e.jsx(
305
- r,
306
- {
307
- schema: {
308
- type: "aggrid",
309
- rowData: o,
310
- columnDefs: c,
311
- domLayout: "autoHeight"
312
- }
313
- }
314
- ) : (
315
- // Simple Fallback Table if Grid plugin missing
316
- /* @__PURE__ */ e.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm text-left", children: [
317
- /* @__PURE__ */ e.jsx("thead", { className: "text-xs uppercase bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: c == null ? void 0 : c.map((p) => /* @__PURE__ */ e.jsx("th", { className: "px-6 py-3", children: p.headerName || p.label || p.field }, p.field)) }) }),
318
- /* @__PURE__ */ e.jsx("tbody", { children: o.map((p, v) => /* @__PURE__ */ e.jsx("tr", { className: "bg-background border-b", children: c == null ? void 0 : c.map((S) => /* @__PURE__ */ e.jsx("td", { className: "px-6 py-4", children: p[S.field] }, S.field)) }, v)) })
319
- ] }) })
320
- );
321
- })() })
322
- ] })
323
- ] });
1
+ import { ComponentRegistry as e } from "@object-ui/core";
2
+ import * as t from "react";
3
+ import n, { useState as r } from "react";
4
+ import { Badge as i, Button as a, Card as o, CardContent as s, CardDescription as c, CardHeader as l, CardTitle as u, Checkbox as d, ConfigPanelRenderer as f, Input as p, Label as m, Skeleton as h, Tabs as g, TabsContent as _, TabsList as v, TabsTrigger as y, useConfigDraft as b } from "@object-ui/components";
5
+ import { SchemaRenderer as x } from "@object-ui/react";
6
+ import { Calendar as S, Clock as C, Download as w, Filter as T, Layers as E, Mail as D, Plus as O, Printer as k, RefreshCw as A, Save as j, Settings as M, Trash2 as N } from "lucide-react";
7
+ //#region \0rolldown/runtime.js
8
+ var P = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), F = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
9
+ if (typeof require < "u") return require.apply(this, arguments);
10
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
11
+ }), I = /* @__PURE__ */ P(((e) => {
12
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
13
+ function r(e, n, r) {
14
+ var i = null;
15
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
16
+ else r = n;
17
+ return n = r.ref, {
18
+ $$typeof: t,
19
+ type: e,
20
+ key: i,
21
+ ref: n === void 0 ? null : n,
22
+ props: r
23
+ };
24
+ }
25
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
26
+ })), L = /* @__PURE__ */ P(((e) => {
27
+ process.env.NODE_ENV !== "production" && (function() {
28
+ function t(e) {
29
+ if (e == null) return null;
30
+ if (typeof e == "function") return e.$$typeof === O ? null : e.displayName || e.name || null;
31
+ if (typeof e == "string") return e;
32
+ switch (e) {
33
+ case _: return "Fragment";
34
+ case y: return "Profiler";
35
+ case v: return "StrictMode";
36
+ case C: return "Suspense";
37
+ case w: return "SuspenseList";
38
+ case D: return "Activity";
39
+ }
40
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
41
+ case g: return "Portal";
42
+ case x: return e.displayName || "Context";
43
+ case b: return (e._context.displayName || "Context") + ".Consumer";
44
+ case S:
45
+ var n = e.render;
46
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
47
+ case T: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
48
+ case E:
49
+ n = e._payload, e = e._init;
50
+ try {
51
+ return t(e(n));
52
+ } catch {}
53
+ }
54
+ return null;
55
+ }
56
+ function n(e) {
57
+ return "" + e;
58
+ }
59
+ function r(e) {
60
+ try {
61
+ n(e);
62
+ var t = !1;
63
+ } catch {
64
+ t = !0;
65
+ }
66
+ if (t) {
67
+ t = console;
68
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
69
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
70
+ }
71
+ }
72
+ function i(e) {
73
+ if (e === _) return "<>";
74
+ if (typeof e == "object" && e && e.$$typeof === E) return "<...>";
75
+ try {
76
+ var n = t(e);
77
+ return n ? "<" + n + ">" : "<...>";
78
+ } catch {
79
+ return "<...>";
80
+ }
81
+ }
82
+ function a() {
83
+ var e = k.A;
84
+ return e === null ? null : e.getOwner();
85
+ }
86
+ function o() {
87
+ return Error("react-stack-top-frame");
88
+ }
89
+ function s(e) {
90
+ if (A.call(e, "key")) {
91
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
92
+ if (t && t.isReactWarning) return !1;
93
+ }
94
+ return e.key !== void 0;
95
+ }
96
+ function c(e, t) {
97
+ function n() {
98
+ N || (N = !0, console.error("%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)", t));
99
+ }
100
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
101
+ get: n,
102
+ configurable: !0
103
+ });
104
+ }
105
+ function l() {
106
+ var e = t(this.type);
107
+ return P[e] || (P[e] = !0, console.error("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.")), e = this.props.ref, e === void 0 ? null : e;
108
+ }
109
+ function u(e, t, n, r, i, a) {
110
+ var o = n.ref;
111
+ return e = {
112
+ $$typeof: h,
113
+ type: e,
114
+ key: t,
115
+ props: n,
116
+ _owner: r
117
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
118
+ enumerable: !1,
119
+ value: null
120
+ }) : Object.defineProperty(e, "ref", {
121
+ enumerable: !1,
122
+ get: l
123
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
124
+ configurable: !1,
125
+ enumerable: !1,
126
+ writable: !0,
127
+ value: 0
128
+ }), Object.defineProperty(e, "_debugInfo", {
129
+ configurable: !1,
130
+ enumerable: !1,
131
+ writable: !0,
132
+ value: null
133
+ }), Object.defineProperty(e, "_debugStack", {
134
+ configurable: !1,
135
+ enumerable: !1,
136
+ writable: !0,
137
+ value: i
138
+ }), Object.defineProperty(e, "_debugTask", {
139
+ configurable: !1,
140
+ enumerable: !1,
141
+ writable: !0,
142
+ value: a
143
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
144
+ }
145
+ function d(e, n, i, o, l, d) {
146
+ var p = n.children;
147
+ if (p !== void 0) if (o) if (j(p)) {
148
+ for (o = 0; o < p.length; o++) f(p[o]);
149
+ Object.freeze && Object.freeze(p);
150
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
151
+ else f(p);
152
+ if (A.call(n, "key")) {
153
+ p = t(e);
154
+ var m = Object.keys(n).filter(function(e) {
155
+ return e !== "key";
156
+ });
157
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), R[p + o] = !0);
158
+ }
159
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
160
+ else i = n;
161
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
162
+ }
163
+ function f(e) {
164
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === E && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
165
+ }
166
+ function p(e) {
167
+ return typeof e == "object" && !!e && e.$$typeof === h;
168
+ }
169
+ var m = F("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), x = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), D = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
170
+ return null;
171
+ };
172
+ m = { react_stack_bottom_frame: function(e) {
173
+ return e();
174
+ } };
175
+ var N, P = {}, I = m.react_stack_bottom_frame.bind(m, o)(), L = M(i(o)), R = {};
176
+ e.Fragment = _, e.jsx = function(e, t, n) {
177
+ var r = 1e4 > k.recentlyCreatedOwnerStacks++;
178
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? M(i(e)) : L);
179
+ }, e.jsxs = function(e, t, n) {
180
+ var r = 1e4 > k.recentlyCreatedOwnerStacks++;
181
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? M(i(e)) : L);
182
+ };
183
+ })();
184
+ })), R = (/* @__PURE__ */ P(((e, t) => {
185
+ process.env.NODE_ENV === "production" ? t.exports = I() : t.exports = L();
186
+ })))(), z = ({ schema: t }) => {
187
+ let { title: n, description: r, data: i, columns: a } = t;
188
+ t.chart?.type;
189
+ let d = !!t.chart, f = process.env.NODE_ENV !== "test";
190
+ return /* @__PURE__ */ (0, R.jsxs)(o, {
191
+ className: `h-full flex flex-col ${t.className || ""}`,
192
+ children: [/* @__PURE__ */ (0, R.jsxs)(l, { children: [n && /* @__PURE__ */ (0, R.jsx)(u, { children: n }), r && /* @__PURE__ */ (0, R.jsx)(c, { children: r })] }), /* @__PURE__ */ (0, R.jsxs)(s, {
193
+ className: "flex-1 overflow-auto space-y-4",
194
+ children: [d && (() => {
195
+ let n = t.chart?.type, r = n ? e.get(n) : null;
196
+ return r ||= e.get("chart"), r ? /* @__PURE__ */ (0, R.jsx)("div", {
197
+ className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
198
+ children: /* @__PURE__ */ (0, R.jsx)(r, { schema: {
199
+ ...t.chart,
200
+ data: t.chart.data || i
201
+ } })
202
+ }) : /* @__PURE__ */ (0, R.jsxs)("div", {
203
+ className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center",
204
+ children: ["Unknown component type: ", n || "chart"]
205
+ });
206
+ })(), i && i.length > 0 && /* @__PURE__ */ (0, R.jsx)("div", {
207
+ className: "border rounded-lg",
208
+ children: (() => {
209
+ let t = f ? e.get("aggrid") || e.get("table") : null;
210
+ return t ? /* @__PURE__ */ (0, R.jsx)(t, { schema: {
211
+ type: "aggrid",
212
+ rowData: i,
213
+ columnDefs: a,
214
+ domLayout: "autoHeight"
215
+ } }) : /* @__PURE__ */ (0, R.jsx)("div", {
216
+ className: "overflow-x-auto",
217
+ children: /* @__PURE__ */ (0, R.jsxs)("table", {
218
+ className: "w-full text-sm text-left",
219
+ children: [/* @__PURE__ */ (0, R.jsx)("thead", {
220
+ className: "text-xs uppercase bg-muted",
221
+ children: /* @__PURE__ */ (0, R.jsx)("tr", { children: a?.map((e) => /* @__PURE__ */ (0, R.jsx)("th", {
222
+ className: "px-6 py-3",
223
+ children: e.headerName || e.label || e.field
224
+ }, e.field)) })
225
+ }), /* @__PURE__ */ (0, R.jsx)("tbody", { children: i.map((e, t) => /* @__PURE__ */ (0, R.jsx)("tr", {
226
+ className: "bg-background border-b",
227
+ children: a?.map((t) => /* @__PURE__ */ (0, R.jsx)("td", {
228
+ className: "px-6 py-4",
229
+ children: e[t.field]
230
+ }, t.field))
231
+ }, t)) })]
232
+ })
233
+ });
234
+ })()
235
+ })]
236
+ })]
237
+ });
324
238
  };
325
- function qe(s, n, a) {
326
- const o = s.fields || [], c = o.map((t) => t.label || t.name), x = n.map((t) => o.map((i) => {
327
- let r = t[i.name];
328
- return r = we(r), typeof r == "string" && (r.includes(",") || r.includes('"') || r.includes(`
329
- `)) ? `"${r.replace(/"/g, '""')}"` : r ?? "";
330
- })), u = [
331
- ...(a == null ? void 0 : a.includeHeaders) !== !1 ? [c.join(",")] : [],
332
- ...x.map((t) => t.join(","))
333
- ].join(`
334
- `);
335
- oe(u, (a == null ? void 0 : a.filename) || `${s.title || "report"}.csv`, "text/csv");
239
+ //#endregion
240
+ //#region src/ReportExportEngine.ts
241
+ function B(e, t, n) {
242
+ let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
243
+ let n = e[t.name];
244
+ return n = q(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
245
+ }));
246
+ X([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
336
247
  }
337
- function We(s, n, a) {
338
- const o = {
339
- title: s.title,
340
- description: s.description,
341
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
342
- data: n
343
- }, c = JSON.stringify(o, null, 2);
344
- oe(c, (a == null ? void 0 : a.filename) || `${s.title || "report"}.json`, "application/json");
248
+ function V(e, t, n) {
249
+ let r = {
250
+ title: e.title,
251
+ description: e.description,
252
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
253
+ data: t
254
+ };
255
+ X(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
345
256
  }
346
- function ye(s, n, a) {
347
- const o = s.fields || [], c = ke(a == null ? void 0 : a.orientation), x = Ce(a == null ? void 0 : a.pageSize), u = `<!DOCTYPE html>
257
+ function H(e, t, n) {
258
+ let r = e.fields || [], i = Y(n?.orientation), a = J(n?.pageSize);
259
+ X(`<!DOCTYPE html>
348
260
  <html>
349
261
  <head>
350
262
  <meta charset="utf-8">
351
- <title>${z(s.title || "Report")}</title>
263
+ <title>${K(e.title || "Report")}</title>
352
264
  <style>
353
- @page { size: ${x} ${c}; margin: 20mm; }
265
+ @page { size: ${a} ${i}; margin: 20mm; }
354
266
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
355
267
  h1 { font-size: 24px; margin-bottom: 8px; }
356
268
  .description { color: #666; margin-bottom: 24px; }
@@ -362,35 +274,33 @@ function ye(s, n, a) {
362
274
  </style>
363
275
  </head>
364
276
  <body>
365
- <h1>${z(s.title || "Report")}</h1>
366
- ${s.description ? `<p class="description">${z(s.description)}</p>` : ""}
277
+ <h1>${K(e.title || "Report")}</h1>
278
+ ${e.description ? `<p class="description">${K(e.description)}</p>` : ""}
367
279
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
368
280
  <table>
369
- <thead><tr>${o.map((t) => `<th>${z(t.label || t.name)}</th>`).join("")}</tr></thead>
370
- <tbody>${n.map((t) => `<tr>${o.map((i) => `<td>${z(String(t[i.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
281
+ <thead><tr>${r.map((e) => `<th>${K(e.label || e.name)}</th>`).join("")}</tr></thead>
282
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${K(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
371
283
  </table>
372
284
  </body>
373
- </html>`;
374
- oe(u, (a == null ? void 0 : a.filename) || `${s.title || "report"}.html`, "text/html");
285
+ </html>`, n?.filename || `${e.title || "report"}.html`, "text/html");
375
286
  }
376
- function He(s, n, a) {
377
- var t;
378
- const o = s.fields || [], c = ke(a == null ? void 0 : a.orientation), x = Ce(a == null ? void 0 : a.pageSize), u = window.open("", "_blank");
379
- if (!u) {
380
- const i = {
381
- ...a,
382
- filename: ((t = a == null ? void 0 : a.filename) == null ? void 0 : t.replace(/\.pdf$/, ".html")) || `${s.title || "report"}.html`
383
- };
384
- ye(s, n, i);
385
- return;
386
- }
387
- u.document.write(`<!DOCTYPE html>
287
+ function U(e, t, n) {
288
+ let r = e.fields || [], i = Y(n?.orientation), a = J(n?.pageSize), o = window.open("", "_blank");
289
+ if (!o) {
290
+ H(e, t, {
291
+ ...n,
292
+ format: "html",
293
+ filename: n?.filename?.replace(/\.pdf$/, ".html") || `${e.title || "report"}.html`
294
+ });
295
+ return;
296
+ }
297
+ o.document.write(`<!DOCTYPE html>
388
298
  <html>
389
299
  <head>
390
300
  <meta charset="utf-8">
391
- <title>${z(s.title || "Report")}</title>
301
+ <title>${K(e.title || "Report")}</title>
392
302
  <style>
393
- @page { size: ${x} ${c}; margin: 20mm; }
303
+ @page { size: ${a} ${i}; margin: 20mm; }
394
304
  @media print { .no-print { display: none; } }
395
305
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
396
306
  h1 { font-size: 24px; margin-bottom: 8px; }
@@ -403,1812 +313,2108 @@ function He(s, n, a) {
403
313
  </style>
404
314
  </head>
405
315
  <body>
406
- <h1>${z(s.title || "Report")}</h1>
407
- ${s.description ? `<p class="description">${z(s.description)}</p>` : ""}
316
+ <h1>${K(e.title || "Report")}</h1>
317
+ ${e.description ? `<p class="description">${K(e.description)}</p>` : ""}
408
318
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
409
319
  <table>
410
- <thead><tr>${o.map((i) => `<th>${z(i.label || i.name)}</th>`).join("")}</tr></thead>
411
- <tbody>${n.map((i) => `<tr>${o.map((r) => `<td>${z(String(i[r.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
320
+ <thead><tr>${r.map((e) => `<th>${K(e.label || e.name)}</th>`).join("")}</tr></thead>
321
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${K(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
412
322
  </table>
413
323
  </body>
414
- </html>`), u.document.close(), u.onload = () => {
415
- u.print();
416
- };
324
+ </html>`), o.document.close(), o.onload = () => {
325
+ o.print();
326
+ };
417
327
  }
418
- function Je(s, n, a) {
419
- const o = s.fields || [], c = o.map((t) => t.label || t.name), x = n.map((t) => o.map((i) => {
420
- let r = t[i.name];
421
- return r = we(r), typeof r == "string" && (r.includes(",") || r.includes('"') || r.includes(`
422
- `) || r.includes(" ")) ? `"${r.replace(/"/g, '""')}"` : r ?? "";
423
- })), u = "\uFEFF" + [
424
- ...(a == null ? void 0 : a.includeHeaders) !== !1 ? [c.join(" ")] : [],
425
- ...x.map((t) => t.join(" "))
426
- ].join(`
427
- `);
428
- oe(u, (a == null ? void 0 : a.filename) || `${s.title || "report"}.tsv`, "text/tab-separated-values");
328
+ function W(e, t, n) {
329
+ let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
330
+ let n = e[t.name];
331
+ return n = q(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
332
+ }));
333
+ X("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
429
334
  }
430
- function Ne(s, n, a, o) {
431
- switch (s) {
432
- case "csv":
433
- qe(n, a, o);
434
- break;
435
- case "json":
436
- We(n, a, o);
437
- break;
438
- case "html":
439
- ye(n, a, o);
440
- break;
441
- case "pdf":
442
- He(n, a, o);
443
- break;
444
- case "excel":
445
- Je(n, a, o);
446
- break;
447
- default:
448
- console.warn(`Unsupported export format: ${s}`);
449
- }
335
+ function G(e, t, n, r) {
336
+ switch (e) {
337
+ case "csv":
338
+ B(t, n, r);
339
+ break;
340
+ case "json":
341
+ V(t, n, r);
342
+ break;
343
+ case "html":
344
+ H(t, n, r);
345
+ break;
346
+ case "pdf":
347
+ U(t, n, r);
348
+ break;
349
+ case "excel":
350
+ W(t, n, r);
351
+ break;
352
+ default: console.warn(`Unsupported export format: ${e}`);
353
+ }
450
354
  }
451
- function z(s) {
452
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
355
+ function K(e) {
356
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
453
357
  }
454
- function we(s) {
455
- if (typeof s == "string" && s.length > 0) {
456
- const n = s.charAt(0);
457
- if (n === "=" || n === "+" || n === "-" || n === "@" || n === "|")
458
- return ` ${s}`;
459
- }
460
- return s;
358
+ function q(e) {
359
+ if (typeof e == "string" && e.length > 0) {
360
+ let t = e.charAt(0);
361
+ if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `\t${e}`;
362
+ }
363
+ return e;
461
364
  }
462
- function Ce(s) {
463
- return ["A4", "A3", "Letter", "Legal"].includes(s || "") ? s : "A4";
365
+ function J(e) {
366
+ return [
367
+ "A4",
368
+ "A3",
369
+ "Letter",
370
+ "Legal"
371
+ ].includes(e || "") ? e : "A4";
464
372
  }
465
- function ke(s) {
466
- return s === "landscape" ? "landscape" : "portrait";
373
+ function Y(e) {
374
+ return e === "landscape" ? "landscape" : "portrait";
467
375
  }
468
- function oe(s, n, a) {
469
- const o = new Blob([s], { type: `${a};charset=utf-8` }), c = URL.createObjectURL(o), x = document.createElement("a");
470
- x.href = c, x.download = n, document.body.appendChild(x), x.click(), document.body.removeChild(x), URL.revokeObjectURL(c);
376
+ function X(e, t, n) {
377
+ let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
378
+ a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
471
379
  }
472
- function ge(s, n) {
473
- if (s == null || s === "") return "";
474
- const a = n == null ? void 0 : n.type, o = n == null ? void 0 : n.format;
475
- if (a === "date" || o === "date" || Xe(s))
476
- return Ze(s);
477
- if (a === "number" || typeof s == "number") {
478
- const c = typeof s == "number" ? s : Number(s);
479
- return isNaN(c) ? String(s) : o === "currency" || o === "currency_cny" ? `¥${c.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: 0 })}` : o === "currency_usd" ? `$${c.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: 0 })}` : o === "percent" ? `${c.toLocaleString("en-US", { minimumFractionDigits: 1, maximumFractionDigits: 1 })}%` : c.toLocaleString("en-US");
480
- }
481
- return String(s);
380
+ //#endregion
381
+ //#region src/formatValue.ts
382
+ function Z(e, t) {
383
+ if (e == null || e === "") return "";
384
+ let n = t?.type, r = t?.format;
385
+ if (n === "date" || r === "date" || ee(e)) return te(e);
386
+ if (n === "number" || typeof e == "number") {
387
+ let t = typeof e == "number" ? e : Number(e);
388
+ return isNaN(t) ? String(e) : r === "currency" || r === "currency_cny" ? `¥${t.toLocaleString("en-US", {
389
+ minimumFractionDigits: 0,
390
+ maximumFractionDigits: 0
391
+ })}` : r === "currency_usd" ? `$${t.toLocaleString("en-US", {
392
+ minimumFractionDigits: 0,
393
+ maximumFractionDigits: 0
394
+ })}` : r === "percent" ? `${t.toLocaleString("en-US", {
395
+ minimumFractionDigits: 1,
396
+ maximumFractionDigits: 1
397
+ })}%` : t.toLocaleString("en-US");
398
+ }
399
+ return String(e);
482
400
  }
483
- function Xe(s) {
484
- return typeof s != "string" ? !1 : /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(s);
401
+ function ee(e) {
402
+ return typeof e == "string" ? /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e) : !1;
485
403
  }
486
- function Ze(s) {
487
- try {
488
- const n = new Date(s);
489
- if (isNaN(n.getTime())) return String(s);
490
- const a = n.getFullYear(), o = String(n.getMonth() + 1).padStart(2, "0"), c = String(n.getDate()).padStart(2, "0");
491
- return `${a}-${o}-${c}`;
492
- } catch {
493
- return String(s);
494
- }
404
+ function te(e) {
405
+ try {
406
+ let t = new Date(e);
407
+ return isNaN(t.getTime()) ? String(e) : `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
408
+ } catch {
409
+ return String(e);
410
+ }
495
411
  }
496
- function Qe(s, n) {
497
- if (!n || n.length === 0 || !s || s.length === 0) return null;
498
- const a = n[0], o = a.field, c = /* @__PURE__ */ new Map();
499
- for (const t of s) {
500
- const i = String(t[o] ?? "(empty)");
501
- c.has(i) || c.set(i, []), c.get(i).push(t);
502
- }
503
- const x = [];
504
- for (const [t, i] of c)
505
- x.push({ key: t, label: `${a.label || o}: ${t}`, rows: i });
506
- const u = a.sort === "desc" ? -1 : 1;
507
- return x.sort((t, i) => t.key.localeCompare(i.key) * u), x;
412
+ //#endregion
413
+ //#region src/ReportViewer.tsx
414
+ function ne(e, t) {
415
+ if (!t || t.length === 0 || !e || e.length === 0) return null;
416
+ let n = t[0], r = n.field, i = /* @__PURE__ */ new Map();
417
+ for (let t of e) {
418
+ let e = String(t[r] ?? "(empty)");
419
+ i.has(e) || i.set(e, []), i.get(e).push(t);
420
+ }
421
+ let a = [];
422
+ for (let [e, t] of i) a.push({
423
+ key: e,
424
+ label: `${n.label || r}: ${e}`,
425
+ rows: t
426
+ });
427
+ let o = n.sort === "desc" ? -1 : 1;
428
+ return a.sort((e, t) => e.key.localeCompare(t.key) * o), a;
508
429
  }
509
- const Se = ({ schema: s, onRefresh: n }) => {
510
- var _, k;
511
- const {
512
- report: a,
513
- data: o,
514
- showToolbar: c = !0,
515
- allowExport: x = !0,
516
- allowPrint: u = !0,
517
- loading: t = !1
518
- } = s, i = (m) => {
519
- var N;
520
- if (!a) {
521
- console.warn("ReportViewer: Cannot export, no report defined");
522
- return;
523
- }
524
- Ne(
525
- m,
526
- a,
527
- o || [],
528
- (N = a.exportConfigs) == null ? void 0 : N[m]
529
- );
530
- }, r = () => {
531
- window.print();
532
- }, p = () => {
533
- n == null || n();
534
- }, v = (m, N) => {
535
- if (!o) return 0;
536
- const C = o.map((y) => Number(y[m]) || 0);
537
- switch (N) {
538
- case "count":
539
- return o.length;
540
- case "sum":
541
- return C.reduce((y, g) => y + g, 0);
542
- case "avg":
543
- return C.length > 0 ? (C.reduce((y, g) => y + g, 0) / C.length).toFixed(2) : 0;
544
- case "min":
545
- return C.length > 0 ? Math.min(...C) : 0;
546
- case "max":
547
- return C.length > 0 ? Math.max(...C) : 0;
548
- default:
549
- return "";
550
- }
551
- }, S = (m, N) => {
552
- const C = a == null ? void 0 : a.conditionalFormatting;
553
- if (!(!C || !Array.isArray(C)))
554
- for (const y of C) {
555
- if (y.field !== m) continue;
556
- const g = String(N ?? ""), T = String(y.value ?? "");
557
- let $ = !1;
558
- switch (y.operator) {
559
- case "equals":
560
- $ = g === T;
561
- break;
562
- case "not_equals":
563
- $ = g !== T;
564
- break;
565
- case "contains":
566
- $ = g.includes(T);
567
- break;
568
- case "greater_than":
569
- $ = Number(N) > Number(y.value);
570
- break;
571
- case "less_than":
572
- $ = Number(N) < Number(y.value);
573
- break;
574
- }
575
- if ($) {
576
- const P = {};
577
- return y.backgroundColor && (P.backgroundColor = y.backgroundColor), y.textColor && (P.color = y.textColor), P;
578
- }
579
- }
580
- }, w = (m, N) => {
581
- var C;
582
- if (m == null || m === "") return "";
583
- if (N.renderAs === "badge") {
584
- const y = ((C = N.colorMap) == null ? void 0 : C[String(m)]) || "";
585
- return /* @__PURE__ */ e.jsx(Ae, { className: y, children: String(m) });
586
- }
587
- return ge(m, N);
588
- };
589
- return a ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
590
- c && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border", children: [
591
- /* @__PURE__ */ e.jsxs("div", { children: [
592
- /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: a.title }),
593
- a.description && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: a.description })
594
- ] }),
595
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
596
- a.refreshInterval && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: p, children: [
597
- /* @__PURE__ */ e.jsx(De, { className: "h-4 w-4 mr-2" }),
598
- "Refresh"
599
- ] }),
600
- u && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: r, children: [
601
- /* @__PURE__ */ e.jsx(Le, { className: "h-4 w-4 mr-2" }),
602
- "Print"
603
- ] }),
604
- x && a.showExportButtons && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1", children: [
605
- /* @__PURE__ */ e.jsxs(
606
- E,
607
- {
608
- variant: "outline",
609
- size: "sm",
610
- onClick: () => i("pdf"),
611
- children: [
612
- /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
613
- "PDF"
614
- ]
615
- }
616
- ),
617
- /* @__PURE__ */ e.jsxs(
618
- E,
619
- {
620
- variant: "outline",
621
- size: "sm",
622
- onClick: () => i("excel"),
623
- children: [
624
- /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
625
- "Excel"
626
- ]
627
- }
628
- ),
629
- /* @__PURE__ */ e.jsxs(
630
- E,
631
- {
632
- variant: "outline",
633
- size: "sm",
634
- onClick: () => i("csv"),
635
- children: [
636
- /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 mr-2" }),
637
- "CSV"
638
- ]
639
- }
640
- )
641
- ] })
642
- ] })
643
- ] }),
644
- /* @__PURE__ */ e.jsxs(V, { children: [
645
- /* @__PURE__ */ e.jsxs(ae, { children: [
646
- !c && a.title && /* @__PURE__ */ e.jsx(se, { children: a.title }),
647
- !c && a.description && /* @__PURE__ */ e.jsx(he, { children: a.description })
648
- ] }),
649
- /* @__PURE__ */ e.jsxs(Y, { className: "space-y-6", children: [
650
- t && /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
651
- /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [1, 2, 3].map((m) => /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsxs(Y, { className: "p-4 space-y-2", children: [
652
- /* @__PURE__ */ e.jsx(ne, { className: "h-4 w-20" }),
653
- /* @__PURE__ */ e.jsx(ne, { className: "h-8 w-28" })
654
- ] }) }, m)) }),
655
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
656
- /* @__PURE__ */ e.jsx(ne, { className: "h-10 w-full" }),
657
- [1, 2, 3, 4, 5].map((m) => /* @__PURE__ */ e.jsx(ne, { className: "h-8 w-full" }, m))
658
- ] })
659
- ] }),
660
- !t && ((_ = a.sections) == null ? void 0 : _.map((m, N) => {
661
- var C, y;
662
- return m.visible === !1 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
663
- m.title && m.type !== "header" && /* @__PURE__ */ e.jsx("h3", { className: "text-lg font-semibold border-b pb-2", children: m.title }),
664
- m.type === "header" && m.title && /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold py-4", children: m.title }),
665
- m.type === "summary" && /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: (C = a.fields) == null ? void 0 : C.filter((g) => g.showInSummary).map((g, T) => /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsxs(Y, { className: "p-4", children: [
666
- /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: g.label || g.name }),
667
- /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold", children: ge(v(g.name, g.aggregation), g) })
668
- ] }) }, T)) }),
669
- m.type === "chart" && m.chart && /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px]", children: (() => {
670
- let g = m.chart.type;
671
- const T = !!m.chart.chartType;
672
- !g && T && (g = "chart"), g && !!U.get(g) || (g = "chart");
673
- const D = g === "chart" ? {
674
- xAxisKey: m.chart.xAxisKey || m.chart.xAxisField || "name",
675
- series: m.chart.series || (m.chart.yAxisFields ? m.chart.yAxisFields.map((B) => ({ dataKey: B })) : []),
676
- // Ensure chartType is passed if we are using the generic renderer
677
- chartType: m.chart.chartType || "bar"
678
- } : {}, L = {
679
- ...m.chart,
680
- type: g,
681
- ...D,
682
- data: o || m.chart.data,
683
- // Force explicit height to preventing Recharts "height(-1)" error
684
- className: m.chart.className || "w-full h-[350px]"
685
- };
686
- return /* @__PURE__ */ e.jsx(xe, { schema: L });
687
- })() }),
688
- m.type === "table" && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-x-auto", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm min-w-[600px]", children: [
689
- /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (y = m.columns) == null ? void 0 : y.map((g, T) => /* @__PURE__ */ e.jsx("th", { className: `px-4 py-2 font-medium ${g.type === "number" ? "text-right" : "text-left"}`, children: g.label || g.name }, T)) }) }),
690
- /* @__PURE__ */ e.jsx("tbody", { children: (() => {
691
- const g = Qe(o || [], a.groupBy || []);
692
- return g ? g.map((T) => {
693
- var $;
694
- return /* @__PURE__ */ e.jsxs(ve.Fragment, { children: [
695
- /* @__PURE__ */ e.jsx("tr", { className: "bg-muted/60", children: /* @__PURE__ */ e.jsxs(
696
- "td",
697
- {
698
- colSpan: (($ = m.columns) == null ? void 0 : $.length) || 1,
699
- className: "px-4 py-2 font-semibold text-sm",
700
- children: [
701
- T.label,
702
- " (",
703
- T.rows.length,
704
- ")"
705
- ]
706
- }
707
- ) }),
708
- T.rows.map((P, D) => {
709
- var L;
710
- return /* @__PURE__ */ e.jsx("tr", { className: "border-t hover:bg-muted/50 even:bg-muted/20", children: (L = m.columns) == null ? void 0 : L.map((B, Z) => /* @__PURE__ */ e.jsx("td", { className: `px-4 py-2 ${B.type === "number" ? "text-right tabular-nums" : ""}`, style: S(B.name, P[B.name]), children: w(P[B.name], B) }, Z)) }, D);
711
- })
712
- ] }, T.key);
713
- }) : o == null ? void 0 : o.map((T, $) => {
714
- var P;
715
- return /* @__PURE__ */ e.jsx("tr", { className: "border-t hover:bg-muted/50 even:bg-muted/20", children: (P = m.columns) == null ? void 0 : P.map((D, L) => /* @__PURE__ */ e.jsx("td", { className: `px-4 py-2 ${D.type === "number" ? "text-right tabular-nums" : ""}`, style: S(D.name, T[D.name]), children: w(T[D.name], D) }, L)) }, $);
716
- });
717
- })() })
718
- ] }) }),
719
- m.type === "text" && m.text && /* @__PURE__ */ e.jsx("div", { className: "prose max-w-none", children: /* @__PURE__ */ e.jsx("p", { children: m.text }) }),
720
- m.type === "page-break" && /* @__PURE__ */ e.jsx("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
721
- m.content && /* @__PURE__ */ e.jsx(xe, { schema: m.content })
722
- ] }, N);
723
- })),
724
- !a.sections && o && o.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-x-auto", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm min-w-[600px]", children: [
725
- /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (k = a.fields) == null ? void 0 : k.map((m, N) => /* @__PURE__ */ e.jsx("th", { className: `px-4 py-2 font-medium ${m.type === "number" ? "text-right" : "text-left"}`, children: m.label || m.name }, N)) }) }),
726
- /* @__PURE__ */ e.jsx("tbody", { children: o.map((m, N) => {
727
- var C;
728
- return /* @__PURE__ */ e.jsx("tr", { className: "border-t hover:bg-muted/50 even:bg-muted/20", children: (C = a.fields) == null ? void 0 : C.map((y, g) => /* @__PURE__ */ e.jsx("td", { className: `px-4 py-2 ${y.type === "number" ? "text-right tabular-nums" : ""}`, style: S(y.name, m[y.name]), children: w(m[y.name], y) }, g)) }, N);
729
- }) })
730
- ] }) })
731
- ] })
732
- ] })
733
- ] }) : /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsx(Y, { className: "p-8 text-center text-muted-foreground", children: "No report to display" }) });
734
- }, Re = ({ schedule: s, onChange: n }) => {
735
- var i;
736
- const [a, o] = J(s || {
737
- enabled: !1,
738
- frequency: "weekly",
739
- time: "09:00",
740
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
741
- recipients: [],
742
- formats: ["pdf"]
743
- }), c = (r) => {
744
- const p = { ...a, ...r };
745
- o(p), n == null || n(p);
746
- }, x = [
747
- { value: "once", label: "Once" },
748
- { value: "daily", label: "Daily" },
749
- { value: "weekly", label: "Weekly" },
750
- { value: "monthly", label: "Monthly" },
751
- { value: "quarterly", label: "Quarterly" },
752
- { value: "yearly", label: "Yearly" }
753
- ], u = [
754
- { value: "pdf", label: "PDF" },
755
- { value: "excel", label: "Excel" },
756
- { value: "csv", label: "CSV" },
757
- { value: "html", label: "HTML" }
758
- ], t = [
759
- { value: 0, label: "Sunday" },
760
- { value: 1, label: "Monday" },
761
- { value: 2, label: "Tuesday" },
762
- { value: 3, label: "Wednesday" },
763
- { value: 4, label: "Thursday" },
764
- { value: 5, label: "Friday" },
765
- { value: 6, label: "Saturday" }
766
- ];
767
- return /* @__PURE__ */ e.jsxs(V, { children: [
768
- /* @__PURE__ */ e.jsx(ae, { children: /* @__PURE__ */ e.jsxs(se, { className: "flex items-center gap-2", children: [
769
- /* @__PURE__ */ e.jsx(je, { className: "h-5 w-5" }),
770
- "Schedule Configuration"
771
- ] }) }),
772
- /* @__PURE__ */ e.jsxs(Y, { className: "space-y-4", children: [
773
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
774
- /* @__PURE__ */ e.jsx(
775
- "input",
776
- {
777
- type: "checkbox",
778
- id: "schedule-enabled",
779
- checked: a.enabled || !1,
780
- onChange: (r) => c({ enabled: r.target.checked }),
781
- className: "rounded"
782
- }
783
- ),
784
- /* @__PURE__ */ e.jsx(j, { htmlFor: "schedule-enabled", children: "Enable Scheduled Report" })
785
- ] }),
786
- a.enabled && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
787
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
788
- /* @__PURE__ */ e.jsx(j, { children: "Frequency" }),
789
- /* @__PURE__ */ e.jsx(
790
- "select",
791
- {
792
- className: "w-full border rounded-md p-2 bg-background",
793
- value: a.frequency || "weekly",
794
- onChange: (r) => c({ frequency: r.target.value }),
795
- children: x.map((r) => /* @__PURE__ */ e.jsx("option", { value: r.value, children: r.label }, r.value))
796
- }
797
- )
798
- ] }),
799
- a.frequency === "weekly" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
800
- /* @__PURE__ */ e.jsx(j, { children: "Day of Week" }),
801
- /* @__PURE__ */ e.jsx(
802
- "select",
803
- {
804
- className: "w-full border rounded-md p-2 bg-background",
805
- value: a.dayOfWeek ?? 1,
806
- onChange: (r) => c({ dayOfWeek: Number(r.target.value) }),
807
- children: t.map((r) => /* @__PURE__ */ e.jsx("option", { value: r.value, children: r.label }, r.value))
808
- }
809
- )
810
- ] }),
811
- a.frequency === "monthly" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
812
- /* @__PURE__ */ e.jsx(j, { children: "Day of Month" }),
813
- /* @__PURE__ */ e.jsx(
814
- M,
815
- {
816
- type: "number",
817
- min: 1,
818
- max: 31,
819
- value: a.dayOfMonth ?? 1,
820
- onChange: (r) => c({ dayOfMonth: Number(r.target.value) })
821
- }
822
- )
823
- ] }),
824
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
825
- /* @__PURE__ */ e.jsxs(j, { className: "flex items-center gap-2", children: [
826
- /* @__PURE__ */ e.jsx(Be, { className: "h-4 w-4" }),
827
- "Time"
828
- ] }),
829
- /* @__PURE__ */ e.jsx(
830
- M,
831
- {
832
- type: "time",
833
- value: a.time || "09:00",
834
- onChange: (r) => c({ time: r.target.value })
835
- }
836
- )
837
- ] }),
838
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
839
- /* @__PURE__ */ e.jsx(j, { children: "Timezone" }),
840
- /* @__PURE__ */ e.jsx(
841
- M,
842
- {
843
- value: a.timezone || "",
844
- onChange: (r) => c({ timezone: r.target.value }),
845
- placeholder: "e.g. America/New_York"
846
- }
847
- )
848
- ] }),
849
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
850
- /* @__PURE__ */ e.jsx(j, { children: "Export Formats" }),
851
- /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-2", children: u.map((r) => {
852
- var p;
853
- 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: [
854
- /* @__PURE__ */ e.jsx(
855
- "input",
856
- {
857
- type: "checkbox",
858
- checked: ((p = a.formats) == null ? void 0 : p.includes(r.value)) || !1,
859
- onChange: (v) => {
860
- const S = a.formats || [];
861
- c({
862
- formats: v.target.checked ? [...S, r.value] : S.filter((w) => w !== r.value)
863
- });
864
- },
865
- className: "rounded"
866
- }
867
- ),
868
- /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: r.label })
869
- ] }, r.value);
870
- }) })
871
- ] }),
872
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
873
- /* @__PURE__ */ e.jsxs(j, { className: "flex items-center gap-2", children: [
874
- /* @__PURE__ */ e.jsx(Me, { className: "h-4 w-4" }),
875
- "Email Recipients"
876
- ] }),
877
- /* @__PURE__ */ e.jsx(
878
- M,
879
- {
880
- placeholder: "email1@example.com, email2@example.com",
881
- value: ((i = a.recipients) == null ? void 0 : i.join(", ")) || "",
882
- onChange: (r) => c({
883
- recipients: r.target.value.split(",").map((p) => p.trim()).filter(Boolean)
884
- })
885
- }
886
- )
887
- ] }),
888
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
889
- /* @__PURE__ */ e.jsx(j, { children: "Email Subject" }),
890
- /* @__PURE__ */ e.jsx(
891
- M,
892
- {
893
- value: a.subject || "",
894
- onChange: (r) => c({ subject: r.target.value }),
895
- placeholder: "Scheduled Report: {report_title}"
896
- }
897
- )
898
- ] })
899
- ] })
900
- ] })
901
- ] });
902
- }, Ke = ({ schema: s }) => {
903
- const {
904
- report: n,
905
- dataSources: a = [],
906
- availableFields: o = [],
907
- showPreview: c = !0,
908
- onSave: x,
909
- onCancel: u
910
- } = s, [t, i] = J(n || {
911
- type: "report",
912
- title: "New Report",
913
- fields: [],
914
- filters: [],
915
- groupBy: [],
916
- sections: [],
917
- showExportButtons: !0,
918
- showPrintButton: !0
919
- }), [r, p] = J(t.fields || []), [v, S] = J(t.filters || []), [w, _] = J(t.groupBy || []), [k, m] = J(t.sections || []), N = () => {
920
- if (o.length > 0 && r.length < o.length) {
921
- const d = o.find(
922
- (h) => !r.some((f) => f.name === h.name)
923
- );
924
- if (d) {
925
- const h = [...r, d];
926
- p(h), i({ ...t, fields: h });
927
- }
928
- }
929
- }, C = (d) => {
930
- const h = r.filter((f, O) => O !== d);
931
- p(h), i({ ...t, fields: h });
932
- }, y = (d, h) => {
933
- const f = [...r];
934
- f[d] = h, p(f), i({ ...t, fields: f });
935
- }, g = () => {
936
- var f;
937
- const d = {
938
- field: ((f = o[0]) == null ? void 0 : f.name) || "",
939
- operator: "equals",
940
- value: ""
941
- }, h = [...v, d];
942
- S(h), i({ ...t, filters: h });
943
- }, T = (d) => {
944
- const h = v.filter((f, O) => O !== d);
945
- S(h), i({ ...t, filters: h });
946
- }, $ = (d, h) => {
947
- const f = [...v];
948
- f[d] = h, S(f), i({ ...t, filters: f });
949
- }, P = () => {
950
- var f;
951
- const d = {
952
- field: ((f = o[0]) == null ? void 0 : f.name) || "",
953
- sort: "asc"
954
- }, h = [...w, d];
955
- _(h), i({ ...t, groupBy: h });
956
- }, D = (d) => {
957
- const h = w.filter((f, O) => O !== d);
958
- _(h), i({ ...t, groupBy: h });
959
- }, L = (d, h) => {
960
- const f = [...w];
961
- f[d] = h, _(f), i({ ...t, groupBy: f });
962
- }, B = (d) => {
963
- const h = {
964
- type: d,
965
- title: `New ${d} Section`
966
- }, f = [...k, h];
967
- m(f), i({ ...t, sections: f });
968
- }, Z = (d) => {
969
- const h = k.filter((f, O) => O !== d);
970
- m(h), i({ ...t, sections: h });
971
- }, I = (d, h) => {
972
- const f = [...k];
973
- f[d] = h, m(f), i({ ...t, sections: f });
974
- }, re = () => {
975
- console.log("Saving report:", t), x && alert("Report saved! (Handler: " + x + ")");
976
- }, ie = () => {
977
- u && console.log("Report cancelled:", u);
978
- };
979
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
980
- /* @__PURE__ */ e.jsxs(V, { children: [
981
- /* @__PURE__ */ e.jsxs(ae, { children: [
982
- /* @__PURE__ */ e.jsx(se, { children: "Report Builder" }),
983
- /* @__PURE__ */ e.jsx(he, { children: "Configure your report settings, fields, filters, and sections" })
984
- ] }),
985
- /* @__PURE__ */ e.jsxs(Y, { children: [
986
- /* @__PURE__ */ e.jsxs(Fe, { defaultValue: "basic", className: "w-full", children: [
987
- /* @__PURE__ */ e.jsxs(_e, { className: "grid w-full grid-cols-6", children: [
988
- /* @__PURE__ */ e.jsxs(W, { value: "basic", children: [
989
- /* @__PURE__ */ e.jsx(ze, { className: "h-4 w-4 mr-2" }),
990
- "Basic"
991
- ] }),
992
- /* @__PURE__ */ e.jsxs(W, { value: "fields", children: [
993
- /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4 mr-2" }),
994
- "Fields"
995
- ] }),
996
- /* @__PURE__ */ e.jsxs(W, { value: "filters", children: [
997
- /* @__PURE__ */ e.jsx(Ie, { className: "h-4 w-4 mr-2" }),
998
- "Filters"
999
- ] }),
1000
- /* @__PURE__ */ e.jsxs(W, { value: "grouping", children: [
1001
- /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4 mr-2" }),
1002
- "Group By"
1003
- ] }),
1004
- /* @__PURE__ */ e.jsxs(W, { value: "sections", children: [
1005
- /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4 mr-2" }),
1006
- "Sections"
1007
- ] }),
1008
- /* @__PURE__ */ e.jsxs(W, { value: "schedule", children: [
1009
- /* @__PURE__ */ e.jsx(je, { className: "h-4 w-4 mr-2" }),
1010
- "Schedule"
1011
- ] })
1012
- ] }),
1013
- /* @__PURE__ */ e.jsx(H, { value: "basic", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1014
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1015
- /* @__PURE__ */ e.jsx(j, { htmlFor: "report-title", children: "Report Title" }),
1016
- /* @__PURE__ */ e.jsx(
1017
- M,
1018
- {
1019
- id: "report-title",
1020
- value: t.title || "",
1021
- onChange: (d) => i({ ...t, title: d.target.value }),
1022
- placeholder: "Enter report title"
1023
- }
1024
- )
1025
- ] }),
1026
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1027
- /* @__PURE__ */ e.jsx(j, { htmlFor: "report-description", children: "Description" }),
1028
- /* @__PURE__ */ e.jsx(
1029
- M,
1030
- {
1031
- id: "report-description",
1032
- value: t.description || "",
1033
- onChange: (d) => i({ ...t, description: d.target.value }),
1034
- placeholder: "Enter report description"
1035
- }
1036
- )
1037
- ] }),
1038
- a.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1039
- /* @__PURE__ */ e.jsx(j, { children: "Data Source" }),
1040
- /* @__PURE__ */ e.jsxs("select", { className: "w-full border rounded-md p-2", children: [
1041
- /* @__PURE__ */ e.jsx("option", { value: "", children: "Select a data source" }),
1042
- a.map((d, h) => /* @__PURE__ */ e.jsxs("option", { value: h, children: [
1043
- "Data Source ",
1044
- h + 1
1045
- ] }, h))
1046
- ] })
1047
- ] }),
1048
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1049
- /* @__PURE__ */ e.jsx(j, { children: "Export Options" }),
1050
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
1051
- /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2", children: [
1052
- /* @__PURE__ */ e.jsx(
1053
- "input",
1054
- {
1055
- type: "checkbox",
1056
- checked: t.showExportButtons || !1,
1057
- onChange: (d) => i({ ...t, showExportButtons: d.target.checked })
1058
- }
1059
- ),
1060
- /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Export Buttons" })
1061
- ] }),
1062
- /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2", children: [
1063
- /* @__PURE__ */ e.jsx(
1064
- "input",
1065
- {
1066
- type: "checkbox",
1067
- checked: t.showPrintButton || !1,
1068
- onChange: (d) => i({ ...t, showPrintButton: d.target.checked })
1069
- }
1070
- ),
1071
- /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Print Button" })
1072
- ] })
1073
- ] })
1074
- ] }),
1075
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1076
- /* @__PURE__ */ e.jsx(j, { htmlFor: "export-format", children: "Default Export Format" }),
1077
- /* @__PURE__ */ e.jsxs(
1078
- "select",
1079
- {
1080
- id: "export-format",
1081
- className: "w-full border rounded-md p-2",
1082
- value: t.defaultExportFormat || "pdf",
1083
- onChange: (d) => i({ ...t, defaultExportFormat: d.target.value }),
1084
- children: [
1085
- /* @__PURE__ */ e.jsx("option", { value: "pdf", children: "PDF" }),
1086
- /* @__PURE__ */ e.jsx("option", { value: "excel", children: "Excel" }),
1087
- /* @__PURE__ */ e.jsx("option", { value: "csv", children: "CSV" }),
1088
- /* @__PURE__ */ e.jsx("option", { value: "json", children: "JSON" }),
1089
- /* @__PURE__ */ e.jsx("option", { value: "html", children: "HTML" })
1090
- ]
1091
- }
1092
- )
1093
- ] })
1094
- ] }) }),
1095
- /* @__PURE__ */ e.jsxs(H, { value: "fields", className: "space-y-4 mt-4", children: [
1096
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1097
- /* @__PURE__ */ e.jsx(j, { children: "Report Fields" }),
1098
- /* @__PURE__ */ e.jsxs(
1099
- E,
1100
- {
1101
- size: "sm",
1102
- variant: "outline",
1103
- onClick: N,
1104
- disabled: r.length >= o.length,
1105
- children: [
1106
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1107
- "Add Field"
1108
- ]
1109
- }
1110
- )
1111
- ] }),
1112
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1113
- r.map((d, h) => /* @__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: [
1114
- /* @__PURE__ */ e.jsxs("div", { children: [
1115
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Field Name" }),
1116
- /* @__PURE__ */ e.jsx("div", { className: "text-sm font-medium", children: d.name })
1117
- ] }),
1118
- /* @__PURE__ */ e.jsxs("div", { children: [
1119
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Label" }),
1120
- /* @__PURE__ */ e.jsx(
1121
- M,
1122
- {
1123
- className: "h-8 text-sm",
1124
- value: d.label || d.name,
1125
- onChange: (f) => y(h, { ...d, label: f.target.value })
1126
- }
1127
- )
1128
- ] }),
1129
- /* @__PURE__ */ e.jsxs("div", { children: [
1130
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Aggregation" }),
1131
- /* @__PURE__ */ e.jsxs(
1132
- "select",
1133
- {
1134
- className: "w-full border rounded-md h-8 text-sm px-2",
1135
- value: d.aggregation || "",
1136
- onChange: (f) => y(h, { ...d, aggregation: f.target.value }),
1137
- children: [
1138
- /* @__PURE__ */ e.jsx("option", { value: "", children: "None" }),
1139
- /* @__PURE__ */ e.jsx("option", { value: "sum", children: "Sum" }),
1140
- /* @__PURE__ */ e.jsx("option", { value: "count", children: "Count" }),
1141
- /* @__PURE__ */ e.jsx("option", { value: "avg", children: "Average" }),
1142
- /* @__PURE__ */ e.jsx("option", { value: "min", children: "Min" }),
1143
- /* @__PURE__ */ e.jsx("option", { value: "max", children: "Max" })
1144
- ]
1145
- }
1146
- )
1147
- ] }),
1148
- /* @__PURE__ */ e.jsx("div", { className: "flex items-end justify-end", children: /* @__PURE__ */ e.jsx(
1149
- E,
1150
- {
1151
- size: "sm",
1152
- variant: "ghost",
1153
- className: "text-red-500 hover:text-red-700 hover:bg-red-50",
1154
- onClick: () => C(h),
1155
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4" })
1156
- }
1157
- ) })
1158
- ] }) }, h)),
1159
- r.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.' })
1160
- ] })
1161
- ] }),
1162
- /* @__PURE__ */ e.jsxs(H, { value: "filters", className: "space-y-4 mt-4", children: [
1163
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1164
- /* @__PURE__ */ e.jsx(j, { children: "Report Filters" }),
1165
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: g, children: [
1166
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1167
- "Add Filter"
1168
- ] })
1169
- ] }),
1170
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1171
- v.map((d, h) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
1172
- /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-3 gap-2", children: [
1173
- /* @__PURE__ */ e.jsxs("div", { children: [
1174
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Field" }),
1175
- /* @__PURE__ */ e.jsx(
1176
- "select",
1177
- {
1178
- className: "w-full border rounded-md h-8 text-sm px-2",
1179
- value: d.field,
1180
- onChange: (f) => $(h, { ...d, field: f.target.value }),
1181
- children: o.map((f, O) => /* @__PURE__ */ e.jsx("option", { value: f.name, children: f.label || f.name }, O))
1182
- }
1183
- )
1184
- ] }),
1185
- /* @__PURE__ */ e.jsxs("div", { children: [
1186
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Operator" }),
1187
- /* @__PURE__ */ e.jsxs(
1188
- "select",
1189
- {
1190
- className: "w-full border rounded-md h-8 text-sm px-2",
1191
- value: d.operator,
1192
- onChange: (f) => $(h, { ...d, operator: f.target.value }),
1193
- children: [
1194
- /* @__PURE__ */ e.jsx("option", { value: "equals", children: "Equals" }),
1195
- /* @__PURE__ */ e.jsx("option", { value: "contains", children: "Contains" }),
1196
- /* @__PURE__ */ e.jsx("option", { value: "gt", children: "Greater Than" }),
1197
- /* @__PURE__ */ e.jsx("option", { value: "lt", children: "Less Than" }),
1198
- /* @__PURE__ */ e.jsx("option", { value: "between", children: "Between" })
1199
- ]
1200
- }
1201
- )
1202
- ] }),
1203
- /* @__PURE__ */ e.jsxs("div", { children: [
1204
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Value" }),
1205
- /* @__PURE__ */ e.jsx(
1206
- M,
1207
- {
1208
- className: "h-8 text-sm",
1209
- value: String(d.value),
1210
- onChange: (f) => $(h, { ...d, value: f.target.value })
1211
- }
1212
- )
1213
- ] })
1214
- ] }),
1215
- /* @__PURE__ */ e.jsx(
1216
- E,
1217
- {
1218
- size: "sm",
1219
- variant: "ghost",
1220
- className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
1221
- onClick: () => T(h),
1222
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4" })
1223
- }
1224
- )
1225
- ] }, h)),
1226
- v.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No filters defined." })
1227
- ] })
1228
- ] }),
1229
- /* @__PURE__ */ e.jsxs(H, { value: "grouping", className: "space-y-4 mt-4", children: [
1230
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1231
- /* @__PURE__ */ e.jsx(j, { children: "Grouping Rules" }),
1232
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: P, children: [
1233
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1234
- "Add Group"
1235
- ] })
1236
- ] }),
1237
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1238
- w.map((d, h) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
1239
- /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-2 gap-2", children: [
1240
- /* @__PURE__ */ e.jsxs("div", { children: [
1241
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Field" }),
1242
- /* @__PURE__ */ e.jsx(
1243
- "select",
1244
- {
1245
- className: "w-full border rounded-md h-8 text-sm px-2",
1246
- value: d.field,
1247
- onChange: (f) => L(h, { ...d, field: f.target.value }),
1248
- children: o.map((f, O) => /* @__PURE__ */ e.jsx("option", { value: f.name, children: f.label || f.name }, O))
1249
- }
1250
- )
1251
- ] }),
1252
- /* @__PURE__ */ e.jsxs("div", { children: [
1253
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Sort Order" }),
1254
- /* @__PURE__ */ e.jsxs(
1255
- "select",
1256
- {
1257
- className: "w-full border rounded-md h-8 text-sm px-2",
1258
- value: d.sort || "asc",
1259
- onChange: (f) => L(h, { ...d, sort: f.target.value }),
1260
- children: [
1261
- /* @__PURE__ */ e.jsx("option", { value: "asc", children: "Ascending" }),
1262
- /* @__PURE__ */ e.jsx("option", { value: "desc", children: "Descending" })
1263
- ]
1264
- }
1265
- )
1266
- ] })
1267
- ] }),
1268
- /* @__PURE__ */ e.jsx(
1269
- E,
1270
- {
1271
- size: "sm",
1272
- variant: "ghost",
1273
- className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
1274
- onClick: () => D(h),
1275
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4" })
1276
- }
1277
- )
1278
- ] }, h)),
1279
- 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." })
1280
- ] })
1281
- ] }),
1282
- /* @__PURE__ */ e.jsxs(H, { value: "sections", className: "space-y-4 mt-4", children: [
1283
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1284
- /* @__PURE__ */ e.jsx(j, { children: "Report Sections" }),
1285
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
1286
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => B("header"), children: [
1287
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1288
- "Header"
1289
- ] }),
1290
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => B("chart"), children: [
1291
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1292
- "Chart"
1293
- ] }),
1294
- /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => B("table"), children: [
1295
- /* @__PURE__ */ e.jsx(G, { className: "h-4 w-4 mr-2" }),
1296
- "Table"
1297
- ] })
1298
- ] })
1299
- ] }),
1300
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1301
- k.map((d, h) => {
1302
- var f, O, Q, K;
1303
- return /* @__PURE__ */ e.jsxs("div", { className: "p-3 border rounded-lg space-y-2", children: [
1304
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1305
- /* @__PURE__ */ e.jsxs("div", { className: "font-medium flex items-center gap-2", children: [
1306
- /* @__PURE__ */ e.jsx("div", { className: "text-xs bg-muted px-2 py-0.5 rounded uppercase", children: d.type }),
1307
- d.title
1308
- ] }),
1309
- /* @__PURE__ */ e.jsx(
1310
- E,
1311
- {
1312
- size: "sm",
1313
- variant: "ghost",
1314
- className: "text-red-500 hover:text-red-700 hover:bg-red-50",
1315
- onClick: () => Z(h),
1316
- children: /* @__PURE__ */ e.jsx(X, { className: "h-4 w-4" })
1317
- }
1318
- )
1319
- ] }),
1320
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
1321
- /* @__PURE__ */ e.jsxs("div", { children: [
1322
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Title" }),
1323
- /* @__PURE__ */ e.jsx(
1324
- M,
1325
- {
1326
- className: "h-8 text-sm",
1327
- value: d.title || "",
1328
- onChange: (l) => I(h, { ...d, title: l.target.value })
1329
- }
1330
- )
1331
- ] }),
1332
- d.type === "text" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
1333
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Content" }),
1334
- /* @__PURE__ */ e.jsx(
1335
- M,
1336
- {
1337
- className: "h-8 text-sm",
1338
- value: d.text || "",
1339
- onChange: (l) => I(h, { ...d, text: l.target.value })
1340
- }
1341
- )
1342
- ] }),
1343
- d.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: [
1344
- /* @__PURE__ */ e.jsx("div", { className: "col-span-2", children: /* @__PURE__ */ e.jsx(j, { className: "text-xs font-semibold", children: "Chart Configuration" }) }),
1345
- /* @__PURE__ */ e.jsxs("div", { children: [
1346
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Chart Type" }),
1347
- /* @__PURE__ */ e.jsxs(
1348
- "select",
1349
- {
1350
- 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",
1351
- value: ((f = d.chart) == null ? void 0 : f.chartType) || "bar",
1352
- onChange: (l) => I(h, {
1353
- ...d,
1354
- chart: { ...d.chart, type: "chart", chartType: l.target.value }
1355
- }),
1356
- children: [
1357
- /* @__PURE__ */ e.jsx("option", { value: "bar", children: "Bar" }),
1358
- /* @__PURE__ */ e.jsx("option", { value: "line", children: "Line" }),
1359
- /* @__PURE__ */ e.jsx("option", { value: "area", children: "Area" }),
1360
- /* @__PURE__ */ e.jsx("option", { value: "pie", children: "Pie" })
1361
- ]
1362
- }
1363
- )
1364
- ] }),
1365
- /* @__PURE__ */ e.jsxs("div", { children: [
1366
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "X-Axis Field" }),
1367
- /* @__PURE__ */ e.jsxs(
1368
- "select",
1369
- {
1370
- 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",
1371
- value: ((O = d.chart) == null ? void 0 : O.xAxisField) || "",
1372
- onChange: (l) => I(h, {
1373
- ...d,
1374
- chart: { ...d.chart, type: "chart", xAxisField: l.target.value }
1375
- }),
1376
- children: [
1377
- /* @__PURE__ */ e.jsx("option", { value: "", children: "Select Field..." }),
1378
- o.map((l) => /* @__PURE__ */ e.jsx("option", { value: l.name, children: l.label || l.name }, l.name)),
1379
- o.length === 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1380
- /* @__PURE__ */ e.jsx("option", { value: "name", children: "Name" }),
1381
- /* @__PURE__ */ e.jsx("option", { value: "month", children: "Month" })
1382
- ] })
1383
- ]
1384
- }
1385
- )
1386
- ] }),
1387
- /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
1388
- /* @__PURE__ */ e.jsx(j, { className: "text-xs", children: "Y-Axis Fields (comma separated)" }),
1389
- /* @__PURE__ */ e.jsx(
1390
- M,
1391
- {
1392
- className: "h-8 text-sm",
1393
- placeholder: "e.g. value, count",
1394
- value: ((K = (Q = d.chart) == null ? void 0 : Q.yAxisFields) == null ? void 0 : K.join(", ")) || "",
1395
- onChange: (l) => I(h, {
1396
- ...d,
1397
- chart: {
1398
- ...d.chart,
1399
- type: "chart",
1400
- yAxisFields: l.target.value.split(",").map((b) => b.trim()).filter(Boolean)
1401
- }
1402
- })
1403
- }
1404
- )
1405
- ] })
1406
- ] })
1407
- ] })
1408
- ] }, h);
1409
- }),
1410
- k.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." })
1411
- ] })
1412
- ] }),
1413
- /* @__PURE__ */ e.jsx(H, { value: "schedule", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsx(
1414
- Re,
1415
- {
1416
- schedule: t.schedule,
1417
- onChange: (d) => i({ ...t, schedule: d })
1418
- }
1419
- ) })
1420
- ] }),
1421
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t", children: [
1422
- /* @__PURE__ */ e.jsx(E, { variant: "outline", onClick: ie, children: "Cancel" }),
1423
- /* @__PURE__ */ e.jsxs(E, { onClick: re, children: [
1424
- /* @__PURE__ */ e.jsx(Ge, { className: "h-4 w-4 mr-2" }),
1425
- "Save Report"
1426
- ] })
1427
- ] })
1428
- ] })
1429
- ] }),
1430
- c && /* @__PURE__ */ e.jsxs(V, { className: "mt-8 border-2 border-blue-100", children: [
1431
- /* @__PURE__ */ e.jsx(ae, { className: "bg-blue-50/50", children: /* @__PURE__ */ e.jsx(se, { className: "text-blue-900 text-sm uppercase tracking-wide", children: "Live Preview" }) }),
1432
- /* @__PURE__ */ e.jsx(Y, { className: "pt-6", children: /* @__PURE__ */ e.jsx(
1433
- Se,
1434
- {
1435
- schema: {
1436
- type: "report-viewer",
1437
- report: {
1438
- ...t,
1439
- fields: r,
1440
- filters: v,
1441
- groupBy: w,
1442
- sections: k
1443
- },
1444
- // Mock data for preview
1445
- data: [
1446
- { id: 1, name: "Sample Item A", value: 100, status: "New" },
1447
- { id: 2, name: "Sample Item B", value: 250, status: "Active" },
1448
- { id: 3, name: "Sample Item C", value: 75, status: "Closed" }
1449
- ]
1450
- }
1451
- }
1452
- ) })
1453
- ] })
1454
- ] });
1455
- }, et = [
1456
- { value: "", label: "None" },
1457
- { value: "sum", label: "Sum" },
1458
- { value: "count", label: "Count" },
1459
- { value: "avg", label: "Average" },
1460
- { value: "min", label: "Min" },
1461
- { value: "max", label: "Max" }
430
+ var Q = ({ schema: t, onRefresh: r }) => {
431
+ let { report: d, data: f, showToolbar: p = !0, allowExport: m = !0, allowPrint: g = !0, loading: _ = !1 } = t, v = (e) => {
432
+ if (!d) {
433
+ console.warn("ReportViewer: Cannot export, no report defined");
434
+ return;
435
+ }
436
+ G(e, d, f || [], d.exportConfigs?.[e]);
437
+ }, y = () => {
438
+ window.print();
439
+ }, b = () => {
440
+ r?.();
441
+ }, S = (e, t) => {
442
+ if (!f) return 0;
443
+ let n = f.map((t) => Number(t[e]) || 0);
444
+ switch (t) {
445
+ case "count": return f.length;
446
+ case "sum": return n.reduce((e, t) => e + t, 0);
447
+ case "avg": return n.length > 0 ? (n.reduce((e, t) => e + t, 0) / n.length).toFixed(2) : 0;
448
+ case "min": return n.length > 0 ? Math.min(...n) : 0;
449
+ case "max": return n.length > 0 ? Math.max(...n) : 0;
450
+ default: return "";
451
+ }
452
+ }, C = (e, t) => {
453
+ let n = d?.conditionalFormatting;
454
+ if (!(!n || !Array.isArray(n))) for (let r of n) {
455
+ if (r.field !== e) continue;
456
+ let n = String(t ?? ""), i = String(r.value ?? ""), a = !1;
457
+ switch (r.operator) {
458
+ case "equals":
459
+ a = n === i;
460
+ break;
461
+ case "not_equals":
462
+ a = n !== i;
463
+ break;
464
+ case "contains":
465
+ a = n.includes(i);
466
+ break;
467
+ case "greater_than":
468
+ a = Number(t) > Number(r.value);
469
+ break;
470
+ case "less_than":
471
+ a = Number(t) < Number(r.value);
472
+ break;
473
+ }
474
+ if (a) {
475
+ let e = {};
476
+ return r.backgroundColor && (e.backgroundColor = r.backgroundColor), r.textColor && (e.color = r.textColor), e;
477
+ }
478
+ }
479
+ }, T = (e, t) => e == null || e === "" ? "" : t.renderAs === "badge" ? /* @__PURE__ */ (0, R.jsx)(i, {
480
+ className: t.colorMap?.[String(e)] || "",
481
+ children: String(e)
482
+ }) : Z(e, t);
483
+ return d ? /* @__PURE__ */ (0, R.jsxs)("div", {
484
+ className: "space-y-4",
485
+ children: [p && /* @__PURE__ */ (0, R.jsxs)("div", {
486
+ className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
487
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)("h2", {
488
+ className: "text-lg font-semibold",
489
+ children: d.title
490
+ }), d.description && /* @__PURE__ */ (0, R.jsx)("p", {
491
+ className: "text-sm text-muted-foreground",
492
+ children: d.description
493
+ })] }), /* @__PURE__ */ (0, R.jsxs)("div", {
494
+ className: "flex items-center gap-2",
495
+ children: [
496
+ d.refreshInterval && /* @__PURE__ */ (0, R.jsxs)(a, {
497
+ variant: "outline",
498
+ size: "sm",
499
+ onClick: b,
500
+ children: [/* @__PURE__ */ (0, R.jsx)(A, { className: "h-4 w-4 mr-2" }), "Refresh"]
501
+ }),
502
+ g && /* @__PURE__ */ (0, R.jsxs)(a, {
503
+ variant: "outline",
504
+ size: "sm",
505
+ onClick: y,
506
+ children: [/* @__PURE__ */ (0, R.jsx)(k, { className: "h-4 w-4 mr-2" }), "Print"]
507
+ }),
508
+ m && d.showExportButtons && /* @__PURE__ */ (0, R.jsxs)("div", {
509
+ className: "flex items-center gap-1",
510
+ children: [
511
+ /* @__PURE__ */ (0, R.jsxs)(a, {
512
+ variant: "outline",
513
+ size: "sm",
514
+ onClick: () => v("pdf"),
515
+ children: [/* @__PURE__ */ (0, R.jsx)(w, { className: "h-4 w-4 mr-2" }), "PDF"]
516
+ }),
517
+ /* @__PURE__ */ (0, R.jsxs)(a, {
518
+ variant: "outline",
519
+ size: "sm",
520
+ onClick: () => v("excel"),
521
+ children: [/* @__PURE__ */ (0, R.jsx)(w, { className: "h-4 w-4 mr-2" }), "Excel"]
522
+ }),
523
+ /* @__PURE__ */ (0, R.jsxs)(a, {
524
+ variant: "outline",
525
+ size: "sm",
526
+ onClick: () => v("csv"),
527
+ children: [/* @__PURE__ */ (0, R.jsx)(w, { className: "h-4 w-4 mr-2" }), "CSV"]
528
+ })
529
+ ]
530
+ })
531
+ ]
532
+ })]
533
+ }), /* @__PURE__ */ (0, R.jsxs)(o, { children: [/* @__PURE__ */ (0, R.jsxs)(l, { children: [!p && d.title && /* @__PURE__ */ (0, R.jsx)(u, { children: d.title }), !p && d.description && /* @__PURE__ */ (0, R.jsx)(c, { children: d.description })] }), /* @__PURE__ */ (0, R.jsxs)(s, {
534
+ className: "space-y-6",
535
+ children: [
536
+ _ && /* @__PURE__ */ (0, R.jsxs)("div", {
537
+ className: "space-y-6",
538
+ children: [/* @__PURE__ */ (0, R.jsx)("div", {
539
+ className: "grid grid-cols-1 md:grid-cols-3 gap-4",
540
+ children: [
541
+ 1,
542
+ 2,
543
+ 3
544
+ ].map((e) => /* @__PURE__ */ (0, R.jsx)(o, { children: /* @__PURE__ */ (0, R.jsxs)(s, {
545
+ className: "p-4 space-y-2",
546
+ children: [/* @__PURE__ */ (0, R.jsx)(h, { className: "h-4 w-20" }), /* @__PURE__ */ (0, R.jsx)(h, { className: "h-8 w-28" })]
547
+ }) }, e))
548
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
549
+ className: "space-y-2",
550
+ children: [/* @__PURE__ */ (0, R.jsx)(h, { className: "h-10 w-full" }), [
551
+ 1,
552
+ 2,
553
+ 3,
554
+ 4,
555
+ 5
556
+ ].map((e) => /* @__PURE__ */ (0, R.jsx)(h, { className: "h-8 w-full" }, e))]
557
+ })]
558
+ }),
559
+ !_ && d.sections?.map((t, r) => t.visible === !1 ? null : /* @__PURE__ */ (0, R.jsxs)("div", {
560
+ className: "space-y-2",
561
+ children: [
562
+ t.title && t.type !== "header" && /* @__PURE__ */ (0, R.jsx)("h3", {
563
+ className: "text-lg font-semibold border-b pb-2",
564
+ children: t.title
565
+ }),
566
+ t.type === "header" && t.title && /* @__PURE__ */ (0, R.jsx)("div", {
567
+ className: "text-2xl font-bold py-4",
568
+ children: t.title
569
+ }),
570
+ t.type === "summary" && /* @__PURE__ */ (0, R.jsx)("div", {
571
+ className: "grid grid-cols-1 md:grid-cols-3 gap-4",
572
+ children: d.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ (0, R.jsx)(o, { children: /* @__PURE__ */ (0, R.jsxs)(s, {
573
+ className: "p-4",
574
+ children: [/* @__PURE__ */ (0, R.jsx)("div", {
575
+ className: "text-sm text-muted-foreground",
576
+ children: e.label || e.name
577
+ }), /* @__PURE__ */ (0, R.jsx)("div", {
578
+ className: "text-2xl font-bold",
579
+ children: Z(S(e.name, e.aggregation), e)
580
+ })]
581
+ }) }, t))
582
+ }),
583
+ t.type === "chart" && t.chart && /* @__PURE__ */ (0, R.jsx)("div", {
584
+ className: "min-h-[300px]",
585
+ children: (() => {
586
+ let n = t.chart.type, r = !!t.chart.chartType;
587
+ !n && r && (n = "chart"), n && e.get(n) || (n = "chart");
588
+ let i = n === "chart" ? {
589
+ xAxisKey: t.chart.xAxisKey || t.chart.xAxisField || "name",
590
+ series: t.chart.series || (t.chart.yAxisFields ? t.chart.yAxisFields.map((e) => ({ dataKey: e })) : []),
591
+ chartType: t.chart.chartType || "bar"
592
+ } : {};
593
+ return /* @__PURE__ */ (0, R.jsx)(x, { schema: {
594
+ ...t.chart,
595
+ type: n,
596
+ ...i,
597
+ data: f || t.chart.data,
598
+ className: t.chart.className || "w-full h-[350px]"
599
+ } });
600
+ })()
601
+ }),
602
+ t.type === "table" && /* @__PURE__ */ (0, R.jsx)("div", {
603
+ className: "border rounded-lg overflow-x-auto",
604
+ children: /* @__PURE__ */ (0, R.jsxs)("table", {
605
+ className: "w-full text-sm min-w-[600px]",
606
+ children: [/* @__PURE__ */ (0, R.jsx)("thead", {
607
+ className: "bg-muted",
608
+ children: /* @__PURE__ */ (0, R.jsx)("tr", { children: t.columns?.map((e, t) => /* @__PURE__ */ (0, R.jsx)("th", {
609
+ className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
610
+ children: e.label || e.name
611
+ }, t)) })
612
+ }), /* @__PURE__ */ (0, R.jsx)("tbody", { children: (() => {
613
+ let e = ne(f || [], d.groupBy || []);
614
+ return e ? e.map((e) => /* @__PURE__ */ (0, R.jsxs)(n.Fragment, { children: [/* @__PURE__ */ (0, R.jsx)("tr", {
615
+ className: "bg-muted/60",
616
+ children: /* @__PURE__ */ (0, R.jsxs)("td", {
617
+ colSpan: t.columns?.length || 1,
618
+ className: "px-4 py-2 font-semibold text-sm",
619
+ children: [
620
+ e.label,
621
+ " (",
622
+ e.rows.length,
623
+ ")"
624
+ ]
625
+ })
626
+ }), e.rows.map((e, n) => /* @__PURE__ */ (0, R.jsx)("tr", {
627
+ className: "border-t hover:bg-muted/50 even:bg-muted/20",
628
+ children: t.columns?.map((t, n) => /* @__PURE__ */ (0, R.jsx)("td", {
629
+ className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
630
+ style: C(t.name, e[t.name]),
631
+ children: T(e[t.name], t)
632
+ }, n))
633
+ }, n))] }, e.key)) : f?.map((e, n) => /* @__PURE__ */ (0, R.jsx)("tr", {
634
+ className: "border-t hover:bg-muted/50 even:bg-muted/20",
635
+ children: t.columns?.map((t, n) => /* @__PURE__ */ (0, R.jsx)("td", {
636
+ className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
637
+ style: C(t.name, e[t.name]),
638
+ children: T(e[t.name], t)
639
+ }, n))
640
+ }, n));
641
+ })() })]
642
+ })
643
+ }),
644
+ t.type === "text" && t.text && /* @__PURE__ */ (0, R.jsx)("div", {
645
+ className: "prose max-w-none",
646
+ children: /* @__PURE__ */ (0, R.jsx)("p", { children: t.text })
647
+ }),
648
+ t.type === "page-break" && /* @__PURE__ */ (0, R.jsx)("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
649
+ t.content && /* @__PURE__ */ (0, R.jsx)(x, { schema: t.content })
650
+ ]
651
+ }, r)),
652
+ !d.sections && f && f.length > 0 && /* @__PURE__ */ (0, R.jsx)("div", {
653
+ className: "border rounded-lg overflow-x-auto",
654
+ children: /* @__PURE__ */ (0, R.jsxs)("table", {
655
+ className: "w-full text-sm min-w-[600px]",
656
+ children: [/* @__PURE__ */ (0, R.jsx)("thead", {
657
+ className: "bg-muted",
658
+ children: /* @__PURE__ */ (0, R.jsx)("tr", { children: d.fields?.map((e, t) => /* @__PURE__ */ (0, R.jsx)("th", {
659
+ className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
660
+ children: e.label || e.name
661
+ }, t)) })
662
+ }), /* @__PURE__ */ (0, R.jsx)("tbody", { children: f.map((e, t) => /* @__PURE__ */ (0, R.jsx)("tr", {
663
+ className: "border-t hover:bg-muted/50 even:bg-muted/20",
664
+ children: d.fields?.map((t, n) => /* @__PURE__ */ (0, R.jsx)("td", {
665
+ className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
666
+ style: C(t.name, e[t.name]),
667
+ children: T(e[t.name], t)
668
+ }, n))
669
+ }, t)) })]
670
+ })
671
+ })
672
+ ]
673
+ })] })]
674
+ }) : /* @__PURE__ */ (0, R.jsx)(o, { children: /* @__PURE__ */ (0, R.jsx)(s, {
675
+ className: "p-8 text-center text-muted-foreground",
676
+ children: "No report to display"
677
+ }) });
678
+ }, $ = ({ schedule: e, onChange: t }) => {
679
+ let [n, i] = r(e || {
680
+ enabled: !1,
681
+ frequency: "weekly",
682
+ time: "09:00",
683
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
684
+ recipients: [],
685
+ formats: ["pdf"]
686
+ }), a = (e) => {
687
+ let r = {
688
+ ...n,
689
+ ...e
690
+ };
691
+ i(r), t?.(r);
692
+ };
693
+ return /* @__PURE__ */ (0, R.jsxs)(o, { children: [/* @__PURE__ */ (0, R.jsx)(l, { children: /* @__PURE__ */ (0, R.jsxs)(u, {
694
+ className: "flex items-center gap-2",
695
+ children: [/* @__PURE__ */ (0, R.jsx)(S, { className: "h-5 w-5" }), "Schedule Configuration"]
696
+ }) }), /* @__PURE__ */ (0, R.jsxs)(s, {
697
+ className: "space-y-4",
698
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
699
+ className: "flex items-center gap-2",
700
+ children: [/* @__PURE__ */ (0, R.jsx)("input", {
701
+ type: "checkbox",
702
+ id: "schedule-enabled",
703
+ checked: n.enabled || !1,
704
+ onChange: (e) => a({ enabled: e.target.checked }),
705
+ className: "rounded"
706
+ }), /* @__PURE__ */ (0, R.jsx)(m, {
707
+ htmlFor: "schedule-enabled",
708
+ children: "Enable Scheduled Report"
709
+ })]
710
+ }), n.enabled && /* @__PURE__ */ (0, R.jsxs)(R.Fragment, { children: [
711
+ /* @__PURE__ */ (0, R.jsxs)("div", {
712
+ className: "space-y-2",
713
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Frequency" }), /* @__PURE__ */ (0, R.jsx)("select", {
714
+ className: "w-full border rounded-md p-2 bg-background",
715
+ value: n.frequency || "weekly",
716
+ onChange: (e) => a({ frequency: e.target.value }),
717
+ children: [
718
+ {
719
+ value: "once",
720
+ label: "Once"
721
+ },
722
+ {
723
+ value: "daily",
724
+ label: "Daily"
725
+ },
726
+ {
727
+ value: "weekly",
728
+ label: "Weekly"
729
+ },
730
+ {
731
+ value: "monthly",
732
+ label: "Monthly"
733
+ },
734
+ {
735
+ value: "quarterly",
736
+ label: "Quarterly"
737
+ },
738
+ {
739
+ value: "yearly",
740
+ label: "Yearly"
741
+ }
742
+ ].map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
743
+ value: e.value,
744
+ children: e.label
745
+ }, e.value))
746
+ })]
747
+ }),
748
+ n.frequency === "weekly" && /* @__PURE__ */ (0, R.jsxs)("div", {
749
+ className: "space-y-2",
750
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Day of Week" }), /* @__PURE__ */ (0, R.jsx)("select", {
751
+ className: "w-full border rounded-md p-2 bg-background",
752
+ value: n.dayOfWeek ?? 1,
753
+ onChange: (e) => a({ dayOfWeek: Number(e.target.value) }),
754
+ children: [
755
+ {
756
+ value: 0,
757
+ label: "Sunday"
758
+ },
759
+ {
760
+ value: 1,
761
+ label: "Monday"
762
+ },
763
+ {
764
+ value: 2,
765
+ label: "Tuesday"
766
+ },
767
+ {
768
+ value: 3,
769
+ label: "Wednesday"
770
+ },
771
+ {
772
+ value: 4,
773
+ label: "Thursday"
774
+ },
775
+ {
776
+ value: 5,
777
+ label: "Friday"
778
+ },
779
+ {
780
+ value: 6,
781
+ label: "Saturday"
782
+ }
783
+ ].map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
784
+ value: e.value,
785
+ children: e.label
786
+ }, e.value))
787
+ })]
788
+ }),
789
+ n.frequency === "monthly" && /* @__PURE__ */ (0, R.jsxs)("div", {
790
+ className: "space-y-2",
791
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Day of Month" }), /* @__PURE__ */ (0, R.jsx)(p, {
792
+ type: "number",
793
+ min: 1,
794
+ max: 31,
795
+ value: n.dayOfMonth ?? 1,
796
+ onChange: (e) => a({ dayOfMonth: Number(e.target.value) })
797
+ })]
798
+ }),
799
+ /* @__PURE__ */ (0, R.jsxs)("div", {
800
+ className: "space-y-2",
801
+ children: [/* @__PURE__ */ (0, R.jsxs)(m, {
802
+ className: "flex items-center gap-2",
803
+ children: [/* @__PURE__ */ (0, R.jsx)(C, { className: "h-4 w-4" }), "Time"]
804
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
805
+ type: "time",
806
+ value: n.time || "09:00",
807
+ onChange: (e) => a({ time: e.target.value })
808
+ })]
809
+ }),
810
+ /* @__PURE__ */ (0, R.jsxs)("div", {
811
+ className: "space-y-2",
812
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Timezone" }), /* @__PURE__ */ (0, R.jsx)(p, {
813
+ value: n.timezone || "",
814
+ onChange: (e) => a({ timezone: e.target.value }),
815
+ placeholder: "e.g. America/New_York"
816
+ })]
817
+ }),
818
+ /* @__PURE__ */ (0, R.jsxs)("div", {
819
+ className: "space-y-2",
820
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Export Formats" }), /* @__PURE__ */ (0, R.jsx)("div", {
821
+ className: "flex flex-wrap gap-2",
822
+ children: [
823
+ {
824
+ value: "pdf",
825
+ label: "PDF"
826
+ },
827
+ {
828
+ value: "excel",
829
+ label: "Excel"
830
+ },
831
+ {
832
+ value: "csv",
833
+ label: "CSV"
834
+ },
835
+ {
836
+ value: "html",
837
+ label: "HTML"
838
+ }
839
+ ].map((e) => /* @__PURE__ */ (0, R.jsxs)("label", {
840
+ className: "flex items-center gap-1.5 px-3 py-1.5 border rounded-md cursor-pointer hover:bg-muted/50",
841
+ children: [/* @__PURE__ */ (0, R.jsx)("input", {
842
+ type: "checkbox",
843
+ checked: n.formats?.includes(e.value) || !1,
844
+ onChange: (t) => {
845
+ let r = n.formats || [];
846
+ a({ formats: t.target.checked ? [...r, e.value] : r.filter((t) => t !== e.value) });
847
+ },
848
+ className: "rounded"
849
+ }), /* @__PURE__ */ (0, R.jsx)("span", {
850
+ className: "text-sm",
851
+ children: e.label
852
+ })]
853
+ }, e.value))
854
+ })]
855
+ }),
856
+ /* @__PURE__ */ (0, R.jsxs)("div", {
857
+ className: "space-y-2",
858
+ children: [/* @__PURE__ */ (0, R.jsxs)(m, {
859
+ className: "flex items-center gap-2",
860
+ children: [/* @__PURE__ */ (0, R.jsx)(D, { className: "h-4 w-4" }), "Email Recipients"]
861
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
862
+ placeholder: "email1@example.com, email2@example.com",
863
+ value: n.recipients?.join(", ") || "",
864
+ onChange: (e) => a({ recipients: e.target.value.split(",").map((e) => e.trim()).filter(Boolean) })
865
+ })]
866
+ }),
867
+ /* @__PURE__ */ (0, R.jsxs)("div", {
868
+ className: "space-y-2",
869
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Email Subject" }), /* @__PURE__ */ (0, R.jsx)(p, {
870
+ value: n.subject || "",
871
+ onChange: (e) => a({ subject: e.target.value }),
872
+ placeholder: "Scheduled Report: {report_title}"
873
+ })]
874
+ })
875
+ ] })]
876
+ })] });
877
+ }, re = ({ schema: e }) => {
878
+ let { report: t, dataSources: n = [], availableFields: i = [], showPreview: d = !0, onSave: f, onCancel: h } = e, [b, x] = r(t || {
879
+ type: "report",
880
+ title: "New Report",
881
+ fields: [],
882
+ filters: [],
883
+ groupBy: [],
884
+ sections: [],
885
+ showExportButtons: !0,
886
+ showPrintButton: !0
887
+ }), [C, w] = r(b.fields || []), [D, k] = r(b.filters || []), [A, P] = r(b.groupBy || []), [F, I] = r(b.sections || []), L = () => {
888
+ if (i.length > 0 && C.length < i.length) {
889
+ let e = i.find((e) => !C.some((t) => t.name === e.name));
890
+ if (e) {
891
+ let t = [...C, e];
892
+ w(t), x({
893
+ ...b,
894
+ fields: t
895
+ });
896
+ }
897
+ }
898
+ }, z = (e) => {
899
+ let t = C.filter((t, n) => n !== e);
900
+ w(t), x({
901
+ ...b,
902
+ fields: t
903
+ });
904
+ }, B = (e, t) => {
905
+ let n = [...C];
906
+ n[e] = t, w(n), x({
907
+ ...b,
908
+ fields: n
909
+ });
910
+ }, V = () => {
911
+ let e = {
912
+ field: i[0]?.name || "",
913
+ operator: "equals",
914
+ value: ""
915
+ }, t = [...D, e];
916
+ k(t), x({
917
+ ...b,
918
+ filters: t
919
+ });
920
+ }, H = (e) => {
921
+ let t = D.filter((t, n) => n !== e);
922
+ k(t), x({
923
+ ...b,
924
+ filters: t
925
+ });
926
+ }, U = (e, t) => {
927
+ let n = [...D];
928
+ n[e] = t, k(n), x({
929
+ ...b,
930
+ filters: n
931
+ });
932
+ }, W = () => {
933
+ let e = {
934
+ field: i[0]?.name || "",
935
+ sort: "asc"
936
+ }, t = [...A, e];
937
+ P(t), x({
938
+ ...b,
939
+ groupBy: t
940
+ });
941
+ }, G = (e) => {
942
+ let t = A.filter((t, n) => n !== e);
943
+ P(t), x({
944
+ ...b,
945
+ groupBy: t
946
+ });
947
+ }, K = (e, t) => {
948
+ let n = [...A];
949
+ n[e] = t, P(n), x({
950
+ ...b,
951
+ groupBy: n
952
+ });
953
+ }, q = (e) => {
954
+ let t = {
955
+ type: e,
956
+ title: `New ${e} Section`
957
+ }, n = [...F, t];
958
+ I(n), x({
959
+ ...b,
960
+ sections: n
961
+ });
962
+ }, J = (e) => {
963
+ let t = F.filter((t, n) => n !== e);
964
+ I(t), x({
965
+ ...b,
966
+ sections: t
967
+ });
968
+ }, Y = (e, t) => {
969
+ let n = [...F];
970
+ n[e] = t, I(n), x({
971
+ ...b,
972
+ sections: n
973
+ });
974
+ };
975
+ return /* @__PURE__ */ (0, R.jsxs)("div", {
976
+ className: "space-y-4",
977
+ children: [/* @__PURE__ */ (0, R.jsxs)(o, { children: [/* @__PURE__ */ (0, R.jsxs)(l, { children: [/* @__PURE__ */ (0, R.jsx)(u, { children: "Report Builder" }), /* @__PURE__ */ (0, R.jsx)(c, { children: "Configure your report settings, fields, filters, and sections" })] }), /* @__PURE__ */ (0, R.jsxs)(s, { children: [/* @__PURE__ */ (0, R.jsxs)(g, {
978
+ defaultValue: "basic",
979
+ className: "w-full",
980
+ children: [
981
+ /* @__PURE__ */ (0, R.jsxs)(v, {
982
+ className: "grid w-full grid-cols-6",
983
+ children: [
984
+ /* @__PURE__ */ (0, R.jsxs)(y, {
985
+ value: "basic",
986
+ children: [/* @__PURE__ */ (0, R.jsx)(M, { className: "h-4 w-4 mr-2" }), "Basic"]
987
+ }),
988
+ /* @__PURE__ */ (0, R.jsxs)(y, {
989
+ value: "fields",
990
+ children: [/* @__PURE__ */ (0, R.jsx)(E, { className: "h-4 w-4 mr-2" }), "Fields"]
991
+ }),
992
+ /* @__PURE__ */ (0, R.jsxs)(y, {
993
+ value: "filters",
994
+ children: [/* @__PURE__ */ (0, R.jsx)(T, { className: "h-4 w-4 mr-2" }), "Filters"]
995
+ }),
996
+ /* @__PURE__ */ (0, R.jsxs)(y, {
997
+ value: "grouping",
998
+ children: [/* @__PURE__ */ (0, R.jsx)(E, { className: "h-4 w-4 mr-2" }), "Group By"]
999
+ }),
1000
+ /* @__PURE__ */ (0, R.jsxs)(y, {
1001
+ value: "sections",
1002
+ children: [/* @__PURE__ */ (0, R.jsx)(E, { className: "h-4 w-4 mr-2" }), "Sections"]
1003
+ }),
1004
+ /* @__PURE__ */ (0, R.jsxs)(y, {
1005
+ value: "schedule",
1006
+ children: [/* @__PURE__ */ (0, R.jsx)(S, { className: "h-4 w-4 mr-2" }), "Schedule"]
1007
+ })
1008
+ ]
1009
+ }),
1010
+ /* @__PURE__ */ (0, R.jsx)(_, {
1011
+ value: "basic",
1012
+ className: "space-y-4 mt-4",
1013
+ children: /* @__PURE__ */ (0, R.jsxs)("div", {
1014
+ className: "space-y-4",
1015
+ children: [
1016
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1017
+ className: "space-y-2",
1018
+ children: [/* @__PURE__ */ (0, R.jsx)(m, {
1019
+ htmlFor: "report-title",
1020
+ children: "Report Title"
1021
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1022
+ id: "report-title",
1023
+ value: b.title || "",
1024
+ onChange: (e) => x({
1025
+ ...b,
1026
+ title: e.target.value
1027
+ }),
1028
+ placeholder: "Enter report title"
1029
+ })]
1030
+ }),
1031
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1032
+ className: "space-y-2",
1033
+ children: [/* @__PURE__ */ (0, R.jsx)(m, {
1034
+ htmlFor: "report-description",
1035
+ children: "Description"
1036
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1037
+ id: "report-description",
1038
+ value: b.description || "",
1039
+ onChange: (e) => x({
1040
+ ...b,
1041
+ description: e.target.value
1042
+ }),
1043
+ placeholder: "Enter report description"
1044
+ })]
1045
+ }),
1046
+ n.length > 0 && /* @__PURE__ */ (0, R.jsxs)("div", {
1047
+ className: "space-y-2",
1048
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Data Source" }), /* @__PURE__ */ (0, R.jsxs)("select", {
1049
+ className: "w-full border rounded-md p-2",
1050
+ children: [/* @__PURE__ */ (0, R.jsx)("option", {
1051
+ value: "",
1052
+ children: "Select a data source"
1053
+ }), n.map((e, t) => /* @__PURE__ */ (0, R.jsxs)("option", {
1054
+ value: t,
1055
+ children: ["Data Source ", t + 1]
1056
+ }, t))]
1057
+ })]
1058
+ }),
1059
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1060
+ className: "space-y-2",
1061
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Export Options" }), /* @__PURE__ */ (0, R.jsxs)("div", {
1062
+ className: "flex items-center gap-4",
1063
+ children: [/* @__PURE__ */ (0, R.jsxs)("label", {
1064
+ className: "flex items-center gap-2",
1065
+ children: [/* @__PURE__ */ (0, R.jsx)("input", {
1066
+ type: "checkbox",
1067
+ checked: b.showExportButtons || !1,
1068
+ onChange: (e) => x({
1069
+ ...b,
1070
+ showExportButtons: e.target.checked
1071
+ })
1072
+ }), /* @__PURE__ */ (0, R.jsx)("span", {
1073
+ className: "text-sm",
1074
+ children: "Show Export Buttons"
1075
+ })]
1076
+ }), /* @__PURE__ */ (0, R.jsxs)("label", {
1077
+ className: "flex items-center gap-2",
1078
+ children: [/* @__PURE__ */ (0, R.jsx)("input", {
1079
+ type: "checkbox",
1080
+ checked: b.showPrintButton || !1,
1081
+ onChange: (e) => x({
1082
+ ...b,
1083
+ showPrintButton: e.target.checked
1084
+ })
1085
+ }), /* @__PURE__ */ (0, R.jsx)("span", {
1086
+ className: "text-sm",
1087
+ children: "Show Print Button"
1088
+ })]
1089
+ })]
1090
+ })]
1091
+ }),
1092
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1093
+ className: "space-y-2",
1094
+ children: [/* @__PURE__ */ (0, R.jsx)(m, {
1095
+ htmlFor: "export-format",
1096
+ children: "Default Export Format"
1097
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1098
+ id: "export-format",
1099
+ className: "w-full border rounded-md p-2",
1100
+ value: b.defaultExportFormat || "pdf",
1101
+ onChange: (e) => x({
1102
+ ...b,
1103
+ defaultExportFormat: e.target.value
1104
+ }),
1105
+ children: [
1106
+ /* @__PURE__ */ (0, R.jsx)("option", {
1107
+ value: "pdf",
1108
+ children: "PDF"
1109
+ }),
1110
+ /* @__PURE__ */ (0, R.jsx)("option", {
1111
+ value: "excel",
1112
+ children: "Excel"
1113
+ }),
1114
+ /* @__PURE__ */ (0, R.jsx)("option", {
1115
+ value: "csv",
1116
+ children: "CSV"
1117
+ }),
1118
+ /* @__PURE__ */ (0, R.jsx)("option", {
1119
+ value: "json",
1120
+ children: "JSON"
1121
+ }),
1122
+ /* @__PURE__ */ (0, R.jsx)("option", {
1123
+ value: "html",
1124
+ children: "HTML"
1125
+ })
1126
+ ]
1127
+ })]
1128
+ })
1129
+ ]
1130
+ })
1131
+ }),
1132
+ /* @__PURE__ */ (0, R.jsxs)(_, {
1133
+ value: "fields",
1134
+ className: "space-y-4 mt-4",
1135
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1136
+ className: "flex items-center justify-between",
1137
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Report Fields" }), /* @__PURE__ */ (0, R.jsxs)(a, {
1138
+ size: "sm",
1139
+ variant: "outline",
1140
+ onClick: L,
1141
+ disabled: C.length >= i.length,
1142
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Add Field"]
1143
+ })]
1144
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1145
+ className: "space-y-2",
1146
+ children: [C.map((e, t) => /* @__PURE__ */ (0, R.jsx)("div", {
1147
+ className: "flex items-center gap-2 p-3 border rounded-lg",
1148
+ children: /* @__PURE__ */ (0, R.jsxs)("div", {
1149
+ className: "flex-1 grid grid-cols-4 gap-2",
1150
+ children: [
1151
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1152
+ className: "text-xs",
1153
+ children: "Field Name"
1154
+ }), /* @__PURE__ */ (0, R.jsx)("div", {
1155
+ className: "text-sm font-medium",
1156
+ children: e.name
1157
+ })] }),
1158
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1159
+ className: "text-xs",
1160
+ children: "Label"
1161
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1162
+ className: "h-8 text-sm",
1163
+ value: e.label || e.name,
1164
+ onChange: (n) => B(t, {
1165
+ ...e,
1166
+ label: n.target.value
1167
+ })
1168
+ })] }),
1169
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1170
+ className: "text-xs",
1171
+ children: "Aggregation"
1172
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1173
+ className: "w-full border rounded-md h-8 text-sm px-2",
1174
+ value: e.aggregation || "",
1175
+ onChange: (n) => B(t, {
1176
+ ...e,
1177
+ aggregation: n.target.value
1178
+ }),
1179
+ children: [
1180
+ /* @__PURE__ */ (0, R.jsx)("option", {
1181
+ value: "",
1182
+ children: "None"
1183
+ }),
1184
+ /* @__PURE__ */ (0, R.jsx)("option", {
1185
+ value: "sum",
1186
+ children: "Sum"
1187
+ }),
1188
+ /* @__PURE__ */ (0, R.jsx)("option", {
1189
+ value: "count",
1190
+ children: "Count"
1191
+ }),
1192
+ /* @__PURE__ */ (0, R.jsx)("option", {
1193
+ value: "avg",
1194
+ children: "Average"
1195
+ }),
1196
+ /* @__PURE__ */ (0, R.jsx)("option", {
1197
+ value: "min",
1198
+ children: "Min"
1199
+ }),
1200
+ /* @__PURE__ */ (0, R.jsx)("option", {
1201
+ value: "max",
1202
+ children: "Max"
1203
+ })
1204
+ ]
1205
+ })] }),
1206
+ /* @__PURE__ */ (0, R.jsx)("div", {
1207
+ className: "flex items-end justify-end",
1208
+ children: /* @__PURE__ */ (0, R.jsx)(a, {
1209
+ size: "sm",
1210
+ variant: "ghost",
1211
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50",
1212
+ onClick: () => z(t),
1213
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-4 w-4" })
1214
+ })
1215
+ })
1216
+ ]
1217
+ })
1218
+ }, t)), C.length === 0 && /* @__PURE__ */ (0, R.jsx)("div", {
1219
+ className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
1220
+ children: "No fields selected. Click \"Add Field\" to begin."
1221
+ })]
1222
+ })]
1223
+ }),
1224
+ /* @__PURE__ */ (0, R.jsxs)(_, {
1225
+ value: "filters",
1226
+ className: "space-y-4 mt-4",
1227
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1228
+ className: "flex items-center justify-between",
1229
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Report Filters" }), /* @__PURE__ */ (0, R.jsxs)(a, {
1230
+ size: "sm",
1231
+ variant: "outline",
1232
+ onClick: V,
1233
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Add Filter"]
1234
+ })]
1235
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1236
+ className: "space-y-2",
1237
+ children: [D.map((e, t) => /* @__PURE__ */ (0, R.jsxs)("div", {
1238
+ className: "flex items-center gap-2 p-3 border rounded-lg",
1239
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1240
+ className: "flex-1 grid grid-cols-3 gap-2",
1241
+ children: [
1242
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1243
+ className: "text-xs",
1244
+ children: "Field"
1245
+ }), /* @__PURE__ */ (0, R.jsx)("select", {
1246
+ className: "w-full border rounded-md h-8 text-sm px-2",
1247
+ value: e.field,
1248
+ onChange: (n) => U(t, {
1249
+ ...e,
1250
+ field: n.target.value
1251
+ }),
1252
+ children: i.map((e, t) => /* @__PURE__ */ (0, R.jsx)("option", {
1253
+ value: e.name,
1254
+ children: e.label || e.name
1255
+ }, t))
1256
+ })] }),
1257
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1258
+ className: "text-xs",
1259
+ children: "Operator"
1260
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1261
+ className: "w-full border rounded-md h-8 text-sm px-2",
1262
+ value: e.operator,
1263
+ onChange: (n) => U(t, {
1264
+ ...e,
1265
+ operator: n.target.value
1266
+ }),
1267
+ children: [
1268
+ /* @__PURE__ */ (0, R.jsx)("option", {
1269
+ value: "equals",
1270
+ children: "Equals"
1271
+ }),
1272
+ /* @__PURE__ */ (0, R.jsx)("option", {
1273
+ value: "contains",
1274
+ children: "Contains"
1275
+ }),
1276
+ /* @__PURE__ */ (0, R.jsx)("option", {
1277
+ value: "gt",
1278
+ children: "Greater Than"
1279
+ }),
1280
+ /* @__PURE__ */ (0, R.jsx)("option", {
1281
+ value: "lt",
1282
+ children: "Less Than"
1283
+ }),
1284
+ /* @__PURE__ */ (0, R.jsx)("option", {
1285
+ value: "between",
1286
+ children: "Between"
1287
+ })
1288
+ ]
1289
+ })] }),
1290
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1291
+ className: "text-xs",
1292
+ children: "Value"
1293
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1294
+ className: "h-8 text-sm",
1295
+ value: String(e.value),
1296
+ onChange: (n) => U(t, {
1297
+ ...e,
1298
+ value: n.target.value
1299
+ })
1300
+ })] })
1301
+ ]
1302
+ }), /* @__PURE__ */ (0, R.jsx)(a, {
1303
+ size: "sm",
1304
+ variant: "ghost",
1305
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
1306
+ onClick: () => H(t),
1307
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-4 w-4" })
1308
+ })]
1309
+ }, t)), D.length === 0 && /* @__PURE__ */ (0, R.jsx)("div", {
1310
+ className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
1311
+ children: "No filters defined."
1312
+ })]
1313
+ })]
1314
+ }),
1315
+ /* @__PURE__ */ (0, R.jsxs)(_, {
1316
+ value: "grouping",
1317
+ className: "space-y-4 mt-4",
1318
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1319
+ className: "flex items-center justify-between",
1320
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Grouping Rules" }), /* @__PURE__ */ (0, R.jsxs)(a, {
1321
+ size: "sm",
1322
+ variant: "outline",
1323
+ onClick: W,
1324
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Add Group"]
1325
+ })]
1326
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1327
+ className: "space-y-2",
1328
+ children: [A.map((e, t) => /* @__PURE__ */ (0, R.jsxs)("div", {
1329
+ className: "flex items-center gap-2 p-3 border rounded-lg",
1330
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1331
+ className: "flex-1 grid grid-cols-2 gap-2",
1332
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1333
+ className: "text-xs",
1334
+ children: "Field"
1335
+ }), /* @__PURE__ */ (0, R.jsx)("select", {
1336
+ className: "w-full border rounded-md h-8 text-sm px-2",
1337
+ value: e.field,
1338
+ onChange: (n) => K(t, {
1339
+ ...e,
1340
+ field: n.target.value
1341
+ }),
1342
+ children: i.map((e, t) => /* @__PURE__ */ (0, R.jsx)("option", {
1343
+ value: e.name,
1344
+ children: e.label || e.name
1345
+ }, t))
1346
+ })] }), /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1347
+ className: "text-xs",
1348
+ children: "Sort Order"
1349
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1350
+ className: "w-full border rounded-md h-8 text-sm px-2",
1351
+ value: e.sort || "asc",
1352
+ onChange: (n) => K(t, {
1353
+ ...e,
1354
+ sort: n.target.value
1355
+ }),
1356
+ children: [/* @__PURE__ */ (0, R.jsx)("option", {
1357
+ value: "asc",
1358
+ children: "Ascending"
1359
+ }), /* @__PURE__ */ (0, R.jsx)("option", {
1360
+ value: "desc",
1361
+ children: "Descending"
1362
+ })]
1363
+ })] })]
1364
+ }), /* @__PURE__ */ (0, R.jsx)(a, {
1365
+ size: "sm",
1366
+ variant: "ghost",
1367
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
1368
+ onClick: () => G(t),
1369
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-4 w-4" })
1370
+ })]
1371
+ }, t)), A.length === 0 && /* @__PURE__ */ (0, R.jsx)("div", {
1372
+ className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
1373
+ children: "No grouping rules applied."
1374
+ })]
1375
+ })]
1376
+ }),
1377
+ /* @__PURE__ */ (0, R.jsxs)(_, {
1378
+ value: "sections",
1379
+ className: "space-y-4 mt-4",
1380
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1381
+ className: "flex items-center justify-between",
1382
+ children: [/* @__PURE__ */ (0, R.jsx)(m, { children: "Report Sections" }), /* @__PURE__ */ (0, R.jsxs)("div", {
1383
+ className: "flex gap-2",
1384
+ children: [
1385
+ /* @__PURE__ */ (0, R.jsxs)(a, {
1386
+ size: "sm",
1387
+ variant: "outline",
1388
+ onClick: () => q("header"),
1389
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Header"]
1390
+ }),
1391
+ /* @__PURE__ */ (0, R.jsxs)(a, {
1392
+ size: "sm",
1393
+ variant: "outline",
1394
+ onClick: () => q("chart"),
1395
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Chart"]
1396
+ }),
1397
+ /* @__PURE__ */ (0, R.jsxs)(a, {
1398
+ size: "sm",
1399
+ variant: "outline",
1400
+ onClick: () => q("table"),
1401
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-4 w-4 mr-2" }), "Table"]
1402
+ })
1403
+ ]
1404
+ })]
1405
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1406
+ className: "space-y-2",
1407
+ children: [F.map((e, t) => /* @__PURE__ */ (0, R.jsxs)("div", {
1408
+ className: "p-3 border rounded-lg space-y-2",
1409
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1410
+ className: "flex items-center justify-between",
1411
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", {
1412
+ className: "font-medium flex items-center gap-2",
1413
+ children: [/* @__PURE__ */ (0, R.jsx)("div", {
1414
+ className: "text-xs bg-muted px-2 py-0.5 rounded uppercase",
1415
+ children: e.type
1416
+ }), e.title]
1417
+ }), /* @__PURE__ */ (0, R.jsx)(a, {
1418
+ size: "sm",
1419
+ variant: "ghost",
1420
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50",
1421
+ onClick: () => J(t),
1422
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-4 w-4" })
1423
+ })]
1424
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1425
+ className: "grid grid-cols-2 gap-2",
1426
+ children: [
1427
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1428
+ className: "text-xs",
1429
+ children: "Title"
1430
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1431
+ className: "h-8 text-sm",
1432
+ value: e.title || "",
1433
+ onChange: (n) => Y(t, {
1434
+ ...e,
1435
+ title: n.target.value
1436
+ })
1437
+ })] }),
1438
+ e.type === "text" && /* @__PURE__ */ (0, R.jsxs)("div", {
1439
+ className: "col-span-2",
1440
+ children: [/* @__PURE__ */ (0, R.jsx)(m, {
1441
+ className: "text-xs",
1442
+ children: "Content"
1443
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1444
+ className: "h-8 text-sm",
1445
+ value: e.text || "",
1446
+ onChange: (n) => Y(t, {
1447
+ ...e,
1448
+ text: n.target.value
1449
+ })
1450
+ })]
1451
+ }),
1452
+ e.type === "chart" && /* @__PURE__ */ (0, R.jsxs)("div", {
1453
+ className: "col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded",
1454
+ children: [
1455
+ /* @__PURE__ */ (0, R.jsx)("div", {
1456
+ className: "col-span-2",
1457
+ children: /* @__PURE__ */ (0, R.jsx)(m, {
1458
+ className: "text-xs font-semibold",
1459
+ children: "Chart Configuration"
1460
+ })
1461
+ }),
1462
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1463
+ className: "text-xs",
1464
+ children: "Chart Type"
1465
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1466
+ 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",
1467
+ value: e.chart?.chartType || "bar",
1468
+ onChange: (n) => Y(t, {
1469
+ ...e,
1470
+ chart: {
1471
+ ...e.chart,
1472
+ type: "chart",
1473
+ chartType: n.target.value
1474
+ }
1475
+ }),
1476
+ children: [
1477
+ /* @__PURE__ */ (0, R.jsx)("option", {
1478
+ value: "bar",
1479
+ children: "Bar"
1480
+ }),
1481
+ /* @__PURE__ */ (0, R.jsx)("option", {
1482
+ value: "line",
1483
+ children: "Line"
1484
+ }),
1485
+ /* @__PURE__ */ (0, R.jsx)("option", {
1486
+ value: "area",
1487
+ children: "Area"
1488
+ }),
1489
+ /* @__PURE__ */ (0, R.jsx)("option", {
1490
+ value: "pie",
1491
+ children: "Pie"
1492
+ })
1493
+ ]
1494
+ })] }),
1495
+ /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)(m, {
1496
+ className: "text-xs",
1497
+ children: "X-Axis Field"
1498
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1499
+ 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",
1500
+ value: e.chart?.xAxisField || "",
1501
+ onChange: (n) => Y(t, {
1502
+ ...e,
1503
+ chart: {
1504
+ ...e.chart,
1505
+ type: "chart",
1506
+ xAxisField: n.target.value
1507
+ }
1508
+ }),
1509
+ children: [
1510
+ /* @__PURE__ */ (0, R.jsx)("option", {
1511
+ value: "",
1512
+ children: "Select Field..."
1513
+ }),
1514
+ i.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1515
+ value: e.name,
1516
+ children: e.label || e.name
1517
+ }, e.name)),
1518
+ i.length === 0 && /* @__PURE__ */ (0, R.jsxs)(R.Fragment, { children: [/* @__PURE__ */ (0, R.jsx)("option", {
1519
+ value: "name",
1520
+ children: "Name"
1521
+ }), /* @__PURE__ */ (0, R.jsx)("option", {
1522
+ value: "month",
1523
+ children: "Month"
1524
+ })] })
1525
+ ]
1526
+ })] }),
1527
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1528
+ className: "col-span-2",
1529
+ children: [/* @__PURE__ */ (0, R.jsx)(m, {
1530
+ className: "text-xs",
1531
+ children: "Y-Axis Fields (comma separated)"
1532
+ }), /* @__PURE__ */ (0, R.jsx)(p, {
1533
+ className: "h-8 text-sm",
1534
+ placeholder: "e.g. value, count",
1535
+ value: e.chart?.yAxisFields?.join(", ") || "",
1536
+ onChange: (n) => Y(t, {
1537
+ ...e,
1538
+ chart: {
1539
+ ...e.chart,
1540
+ type: "chart",
1541
+ yAxisFields: n.target.value.split(",").map((e) => e.trim()).filter(Boolean)
1542
+ }
1543
+ })
1544
+ })]
1545
+ })
1546
+ ]
1547
+ })
1548
+ ]
1549
+ })]
1550
+ }, t)), F.length === 0 && /* @__PURE__ */ (0, R.jsx)("div", {
1551
+ className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
1552
+ children: "No customized sections. The default report layout will be used."
1553
+ })]
1554
+ })]
1555
+ }),
1556
+ /* @__PURE__ */ (0, R.jsx)(_, {
1557
+ value: "schedule",
1558
+ className: "space-y-4 mt-4",
1559
+ children: /* @__PURE__ */ (0, R.jsx)($, {
1560
+ schedule: b.schedule,
1561
+ onChange: (e) => x({
1562
+ ...b,
1563
+ schedule: e
1564
+ })
1565
+ })
1566
+ })
1567
+ ]
1568
+ }), /* @__PURE__ */ (0, R.jsxs)("div", {
1569
+ className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t",
1570
+ children: [/* @__PURE__ */ (0, R.jsx)(a, {
1571
+ variant: "outline",
1572
+ onClick: () => {
1573
+ h && console.log("Report cancelled:", h);
1574
+ },
1575
+ children: "Cancel"
1576
+ }), /* @__PURE__ */ (0, R.jsxs)(a, {
1577
+ onClick: () => {
1578
+ console.log("Saving report:", b), f && alert("Report saved! (Handler: " + f + ")");
1579
+ },
1580
+ children: [/* @__PURE__ */ (0, R.jsx)(j, { className: "h-4 w-4 mr-2" }), "Save Report"]
1581
+ })]
1582
+ })] })] }), d && /* @__PURE__ */ (0, R.jsxs)(o, {
1583
+ className: "mt-8 border-2 border-blue-100",
1584
+ children: [/* @__PURE__ */ (0, R.jsx)(l, {
1585
+ className: "bg-blue-50/50",
1586
+ children: /* @__PURE__ */ (0, R.jsx)(u, {
1587
+ className: "text-blue-900 text-sm uppercase tracking-wide",
1588
+ children: "Live Preview"
1589
+ })
1590
+ }), /* @__PURE__ */ (0, R.jsx)(s, {
1591
+ className: "pt-6",
1592
+ children: /* @__PURE__ */ (0, R.jsx)(Q, { schema: {
1593
+ type: "report-viewer",
1594
+ report: {
1595
+ ...b,
1596
+ fields: C,
1597
+ filters: D,
1598
+ groupBy: A,
1599
+ sections: F
1600
+ },
1601
+ data: [
1602
+ {
1603
+ id: 1,
1604
+ name: "Sample Item A",
1605
+ value: 100,
1606
+ status: "New"
1607
+ },
1608
+ {
1609
+ id: 2,
1610
+ name: "Sample Item B",
1611
+ value: 250,
1612
+ status: "Active"
1613
+ },
1614
+ {
1615
+ id: 3,
1616
+ name: "Sample Item C",
1617
+ value: 75,
1618
+ status: "Closed"
1619
+ }
1620
+ ]
1621
+ } })
1622
+ })]
1623
+ })]
1624
+ });
1625
+ }, ie = [
1626
+ {
1627
+ value: "",
1628
+ label: "None"
1629
+ },
1630
+ {
1631
+ value: "sum",
1632
+ label: "Sum"
1633
+ },
1634
+ {
1635
+ value: "count",
1636
+ label: "Count"
1637
+ },
1638
+ {
1639
+ value: "avg",
1640
+ label: "Average"
1641
+ },
1642
+ {
1643
+ value: "min",
1644
+ label: "Min"
1645
+ },
1646
+ {
1647
+ value: "max",
1648
+ label: "Max"
1649
+ }
1462
1650
  ];
1463
- function tt({
1464
- availableFields: s,
1465
- value: n,
1466
- onChange: a
1467
- }) {
1468
- const o = Array.isArray(n) ? n.map((t) => typeof t == "string" ? { name: t, label: t, type: "string" } : { name: t.name || t.field || t.value, label: t.label || t.name || "", type: t.type || "string", aggregation: t.aggregation }) : [], c = o.map((t) => t.name), x = (t) => {
1469
- const i = c.includes(t);
1470
- let r;
1471
- if (i)
1472
- r = o.filter((p) => p.name !== t);
1473
- else {
1474
- const p = s.find((v) => v.value === t);
1475
- r = [...o, { name: t, label: (p == null ? void 0 : p.label) || t, type: (p == null ? void 0 : p.type) || "string" }];
1476
- }
1477
- a(r);
1478
- }, u = (t, i) => {
1479
- const r = o.map(
1480
- (p) => p.name === t ? { ...p, aggregation: i || void 0, showInSummary: !!i } : p
1481
- );
1482
- a(r);
1483
- };
1484
- return s.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "text-xs text-muted-foreground py-2", "data-testid": "field-picker-empty", children: "No fields available" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-1 py-1", "data-testid": "field-picker", children: s.map((t) => {
1485
- const i = c.includes(t.value), r = o.find((p) => p.name === t.value);
1486
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 px-1 py-0.5 rounded hover:bg-muted/50 text-xs", children: [
1487
- /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 flex-1 cursor-pointer", children: [
1488
- /* @__PURE__ */ e.jsx(
1489
- Pe,
1490
- {
1491
- checked: i,
1492
- onCheckedChange: () => x(t.value),
1493
- "data-testid": `field-picker-${t.value}`
1494
- }
1495
- ),
1496
- /* @__PURE__ */ e.jsx("span", { className: "flex-1", children: t.label }),
1497
- t.type && /* @__PURE__ */ e.jsx("span", { className: "text-[10px] text-muted-foreground", children: t.type })
1498
- ] }),
1499
- i && /* @__PURE__ */ e.jsx(
1500
- "select",
1501
- {
1502
- className: "h-5 text-[10px] border rounded px-1 bg-background",
1503
- value: (r == null ? void 0 : r.aggregation) || "",
1504
- onChange: (p) => u(t.value, p.target.value),
1505
- "data-testid": `field-agg-${t.value}`,
1506
- children: et.map((p) => /* @__PURE__ */ e.jsx("option", { value: p.value, children: p.label }, p.value))
1507
- }
1508
- )
1509
- ] }, t.value);
1510
- }) });
1651
+ function ae({ availableFields: e, value: t, onChange: n }) {
1652
+ let r = Array.isArray(t) ? t.map((e) => typeof e == "string" ? {
1653
+ name: e,
1654
+ label: e,
1655
+ type: "string"
1656
+ } : {
1657
+ name: e.name || e.field || e.value,
1658
+ label: e.label || e.name || "",
1659
+ type: e.type || "string",
1660
+ aggregation: e.aggregation
1661
+ }) : [], i = r.map((e) => e.name), a = (t) => {
1662
+ let a = i.includes(t), o;
1663
+ if (a) o = r.filter((e) => e.name !== t);
1664
+ else {
1665
+ let n = e.find((e) => e.value === t);
1666
+ o = [...r, {
1667
+ name: t,
1668
+ label: n?.label || t,
1669
+ type: n?.type || "string"
1670
+ }];
1671
+ }
1672
+ n(o);
1673
+ }, o = (e, t) => {
1674
+ n(r.map((n) => n.name === e ? {
1675
+ ...n,
1676
+ aggregation: t || void 0,
1677
+ showInSummary: !!t
1678
+ } : n));
1679
+ };
1680
+ return e.length === 0 ? /* @__PURE__ */ (0, R.jsx)("div", {
1681
+ className: "text-xs text-muted-foreground py-2",
1682
+ "data-testid": "field-picker-empty",
1683
+ children: "No fields available"
1684
+ }) : /* @__PURE__ */ (0, R.jsx)("div", {
1685
+ className: "space-y-1 py-1",
1686
+ "data-testid": "field-picker",
1687
+ children: e.map((e) => {
1688
+ let t = i.includes(e.value), n = r.find((t) => t.name === e.value);
1689
+ return /* @__PURE__ */ (0, R.jsxs)("div", {
1690
+ className: "flex items-center gap-2 px-1 py-0.5 rounded hover:bg-muted/50 text-xs",
1691
+ children: [/* @__PURE__ */ (0, R.jsxs)("label", {
1692
+ className: "flex items-center gap-2 flex-1 cursor-pointer",
1693
+ children: [
1694
+ /* @__PURE__ */ (0, R.jsx)(d, {
1695
+ checked: t,
1696
+ onCheckedChange: () => a(e.value),
1697
+ "data-testid": `field-picker-${e.value}`
1698
+ }),
1699
+ /* @__PURE__ */ (0, R.jsx)("span", {
1700
+ className: "flex-1",
1701
+ children: e.label
1702
+ }),
1703
+ e.type && /* @__PURE__ */ (0, R.jsx)("span", {
1704
+ className: "text-[10px] text-muted-foreground",
1705
+ children: e.type
1706
+ })
1707
+ ]
1708
+ }), t && /* @__PURE__ */ (0, R.jsx)("select", {
1709
+ className: "h-5 text-[10px] border rounded px-1 bg-background",
1710
+ value: n?.aggregation || "",
1711
+ onChange: (t) => o(e.value, t.target.value),
1712
+ "data-testid": `field-agg-${e.value}`,
1713
+ children: ie.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1714
+ value: e.value,
1715
+ children: e.label
1716
+ }, e.value))
1717
+ })]
1718
+ }, e.value);
1719
+ })
1720
+ });
1511
1721
  }
1512
- const at = [
1513
- { value: "", label: "None" },
1514
- { value: "bar", label: "Bar Chart" },
1515
- { value: "line", label: "Line Chart" },
1516
- { value: "pie", label: "Pie Chart" },
1517
- { value: "area", label: "Area Chart" },
1518
- { value: "donut", label: "Donut Chart" },
1519
- { value: "scatter", label: "Scatter Plot" }
1722
+ var oe = [
1723
+ {
1724
+ value: "",
1725
+ label: "None"
1726
+ },
1727
+ {
1728
+ value: "bar",
1729
+ label: "Bar Chart"
1730
+ },
1731
+ {
1732
+ value: "line",
1733
+ label: "Line Chart"
1734
+ },
1735
+ {
1736
+ value: "pie",
1737
+ label: "Pie Chart"
1738
+ },
1739
+ {
1740
+ value: "area",
1741
+ label: "Area Chart"
1742
+ },
1743
+ {
1744
+ value: "donut",
1745
+ label: "Donut Chart"
1746
+ },
1747
+ {
1748
+ value: "scatter",
1749
+ label: "Scatter Plot"
1750
+ }
1520
1751
  ];
1521
- function st({
1522
- availableFields: s,
1523
- value: n,
1524
- onChange: a
1525
- }) {
1526
- var x;
1527
- const o = n || {}, c = (u) => a({ ...o, ...u });
1528
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 py-1", "data-testid": "chart-config", children: [
1529
- /* @__PURE__ */ e.jsxs("div", { children: [
1530
- /* @__PURE__ */ e.jsx("label", { className: "text-[10px] text-muted-foreground", children: "Chart type" }),
1531
- /* @__PURE__ */ e.jsx(
1532
- "select",
1533
- {
1534
- className: "w-full h-7 text-xs border rounded px-2 bg-background",
1535
- value: o.chartType || "",
1536
- onChange: (u) => c({ chartType: u.target.value || void 0 }),
1537
- "data-testid": "chart-type-select",
1538
- children: at.map((u) => /* @__PURE__ */ e.jsx("option", { value: u.value, children: u.label }, u.value))
1539
- }
1540
- )
1541
- ] }),
1542
- o.chartType && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1543
- /* @__PURE__ */ e.jsxs("div", { children: [
1544
- /* @__PURE__ */ e.jsx("label", { className: "text-[10px] text-muted-foreground", children: "X-axis field" }),
1545
- /* @__PURE__ */ e.jsxs(
1546
- "select",
1547
- {
1548
- className: "w-full h-7 text-xs border rounded px-2 bg-background",
1549
- value: o.xAxisField || "",
1550
- onChange: (u) => c({ xAxisField: u.target.value || void 0 }),
1551
- "data-testid": "chart-x-field",
1552
- children: [
1553
- /* @__PURE__ */ e.jsx("option", { value: "", children: "Select field…" }),
1554
- s.map((u) => /* @__PURE__ */ e.jsx("option", { value: u.value, children: u.label }, u.value))
1555
- ]
1556
- }
1557
- )
1558
- ] }),
1559
- /* @__PURE__ */ e.jsxs("div", { children: [
1560
- /* @__PURE__ */ e.jsx("label", { className: "text-[10px] text-muted-foreground", children: "Y-axis field" }),
1561
- /* @__PURE__ */ e.jsxs(
1562
- "select",
1563
- {
1564
- className: "w-full h-7 text-xs border rounded px-2 bg-background",
1565
- value: ((x = o.yAxisFields) == null ? void 0 : x[0]) || "",
1566
- onChange: (u) => c({ yAxisFields: u.target.value ? [u.target.value] : [] }),
1567
- "data-testid": "chart-y-field",
1568
- children: [
1569
- /* @__PURE__ */ e.jsx("option", { value: "", children: "Select field…" }),
1570
- s.filter((u) => u.type === "number").map((u) => /* @__PURE__ */ e.jsx("option", { value: u.value, children: u.label }, u.value))
1571
- ]
1572
- }
1573
- )
1574
- ] })
1575
- ] })
1576
- ] });
1752
+ function se({ availableFields: e, value: t, onChange: n }) {
1753
+ let r = t || {}, i = (e) => n({
1754
+ ...r,
1755
+ ...e
1756
+ });
1757
+ return /* @__PURE__ */ (0, R.jsxs)("div", {
1758
+ className: "space-y-2 py-1",
1759
+ "data-testid": "chart-config",
1760
+ children: [/* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)("label", {
1761
+ className: "text-[10px] text-muted-foreground",
1762
+ children: "Chart type"
1763
+ }), /* @__PURE__ */ (0, R.jsx)("select", {
1764
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
1765
+ value: r.chartType || "",
1766
+ onChange: (e) => i({ chartType: e.target.value || void 0 }),
1767
+ "data-testid": "chart-type-select",
1768
+ children: oe.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1769
+ value: e.value,
1770
+ children: e.label
1771
+ }, e.value))
1772
+ })] }), r.chartType && /* @__PURE__ */ (0, R.jsxs)(R.Fragment, { children: [/* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)("label", {
1773
+ className: "text-[10px] text-muted-foreground",
1774
+ children: "X-axis field"
1775
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1776
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
1777
+ value: r.xAxisField || "",
1778
+ onChange: (e) => i({ xAxisField: e.target.value || void 0 }),
1779
+ "data-testid": "chart-x-field",
1780
+ children: [/* @__PURE__ */ (0, R.jsx)("option", {
1781
+ value: "",
1782
+ children: "Select field…"
1783
+ }), e.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1784
+ value: e.value,
1785
+ children: e.label
1786
+ }, e.value))]
1787
+ })] }), /* @__PURE__ */ (0, R.jsxs)("div", { children: [/* @__PURE__ */ (0, R.jsx)("label", {
1788
+ className: "text-[10px] text-muted-foreground",
1789
+ children: "Y-axis field"
1790
+ }), /* @__PURE__ */ (0, R.jsxs)("select", {
1791
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
1792
+ value: r.yAxisFields?.[0] || "",
1793
+ onChange: (e) => i({ yAxisFields: e.target.value ? [e.target.value] : [] }),
1794
+ "data-testid": "chart-y-field",
1795
+ children: [/* @__PURE__ */ (0, R.jsx)("option", {
1796
+ value: "",
1797
+ children: "Select field…"
1798
+ }), e.filter((e) => e.type === "number").map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1799
+ value: e.value,
1800
+ children: e.label
1801
+ }, e.value))]
1802
+ })] })] })]
1803
+ });
1577
1804
  }
1578
- const rt = [
1579
- { value: "equals", label: "=" },
1580
- { value: "not_equals", label: "≠" },
1581
- { value: "greater_than", label: ">" },
1582
- { value: "less_than", label: "<" },
1583
- { value: "contains", label: "Contains" }
1805
+ var ce = [
1806
+ {
1807
+ value: "equals",
1808
+ label: "="
1809
+ },
1810
+ {
1811
+ value: "not_equals",
1812
+ label: "≠"
1813
+ },
1814
+ {
1815
+ value: "greater_than",
1816
+ label: ">"
1817
+ },
1818
+ {
1819
+ value: "less_than",
1820
+ label: "<"
1821
+ },
1822
+ {
1823
+ value: "contains",
1824
+ label: "Contains"
1825
+ }
1584
1826
  ];
1585
- function lt({
1586
- availableFields: s,
1587
- value: n,
1588
- onChange: a
1589
- }) {
1590
- const o = Array.isArray(n) ? n : [], c = () => {
1591
- var t;
1592
- a([
1593
- ...o,
1594
- {
1595
- field: ((t = s[0]) == null ? void 0 : t.value) || "",
1596
- operator: "equals",
1597
- value: "",
1598
- backgroundColor: "#fef9c3",
1599
- textColor: ""
1600
- }
1601
- ]);
1602
- }, x = (t) => {
1603
- a(o.filter((i, r) => r !== t));
1604
- }, u = (t, i) => {
1605
- a(o.map((r, p) => p === t ? { ...r, ...i } : r));
1606
- };
1607
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 py-1", "data-testid": "conditional-format-rules", children: [
1608
- o.map((t, i) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20", children: [
1609
- /* @__PURE__ */ e.jsx(
1610
- "select",
1611
- {
1612
- className: "h-5 text-[10px] border rounded px-1 bg-background flex-1",
1613
- value: t.field,
1614
- onChange: (r) => u(i, { field: r.target.value }),
1615
- "data-testid": `cf-rule-field-${i}`,
1616
- children: s.map((r) => /* @__PURE__ */ e.jsx("option", { value: r.value, children: r.label }, r.value))
1617
- }
1618
- ),
1619
- /* @__PURE__ */ e.jsx(
1620
- "select",
1621
- {
1622
- className: "h-5 text-[10px] border rounded px-1 bg-background w-12",
1623
- value: t.operator,
1624
- onChange: (r) => u(i, { operator: r.target.value }),
1625
- children: rt.map((r) => /* @__PURE__ */ e.jsx("option", { value: r.value, children: r.label }, r.value))
1626
- }
1627
- ),
1628
- /* @__PURE__ */ e.jsx(
1629
- "input",
1630
- {
1631
- className: "h-5 text-[10px] border rounded px-1 bg-background w-16",
1632
- value: t.value,
1633
- placeholder: "value",
1634
- onChange: (r) => u(i, { value: r.target.value }),
1635
- "data-testid": `cf-rule-value-${i}`
1636
- }
1637
- ),
1638
- /* @__PURE__ */ e.jsx(
1639
- "input",
1640
- {
1641
- type: "color",
1642
- className: "h-5 w-5 rounded border cursor-pointer",
1643
- value: t.backgroundColor || "#fef9c3",
1644
- onChange: (r) => u(i, { backgroundColor: r.target.value }),
1645
- title: "Background color"
1646
- }
1647
- ),
1648
- /* @__PURE__ */ e.jsx(
1649
- E,
1650
- {
1651
- type: "button",
1652
- size: "sm",
1653
- variant: "ghost",
1654
- className: "h-5 w-5 p-0",
1655
- onClick: () => x(i),
1656
- "data-testid": `cf-rule-remove-${i}`,
1657
- children: /* @__PURE__ */ e.jsx(X, { className: "h-3 w-3" })
1658
- }
1659
- )
1660
- ] }, i)),
1661
- /* @__PURE__ */ e.jsxs(
1662
- E,
1663
- {
1664
- type: "button",
1665
- size: "sm",
1666
- variant: "outline",
1667
- className: "h-6 text-[10px] w-full",
1668
- onClick: c,
1669
- "data-testid": "cf-add-rule",
1670
- children: [
1671
- /* @__PURE__ */ e.jsx(G, { className: "h-3 w-3 mr-1" }),
1672
- "Add Rule"
1673
- ]
1674
- }
1675
- )
1676
- ] });
1827
+ function le({ availableFields: e, value: t, onChange: n }) {
1828
+ let r = Array.isArray(t) ? t : [], i = () => {
1829
+ n([...r, {
1830
+ field: e[0]?.value || "",
1831
+ operator: "equals",
1832
+ value: "",
1833
+ backgroundColor: "#fef9c3",
1834
+ textColor: ""
1835
+ }]);
1836
+ }, o = (e) => {
1837
+ n(r.filter((t, n) => n !== e));
1838
+ }, s = (e, t) => {
1839
+ n(r.map((n, r) => r === e ? {
1840
+ ...n,
1841
+ ...t
1842
+ } : n));
1843
+ };
1844
+ return /* @__PURE__ */ (0, R.jsxs)("div", {
1845
+ className: "space-y-2 py-1",
1846
+ "data-testid": "conditional-format-rules",
1847
+ children: [r.map((t, n) => /* @__PURE__ */ (0, R.jsxs)("div", {
1848
+ className: "flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20",
1849
+ children: [
1850
+ /* @__PURE__ */ (0, R.jsx)("select", {
1851
+ className: "h-5 text-[10px] border rounded px-1 bg-background flex-1",
1852
+ value: t.field,
1853
+ onChange: (e) => s(n, { field: e.target.value }),
1854
+ "data-testid": `cf-rule-field-${n}`,
1855
+ children: e.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1856
+ value: e.value,
1857
+ children: e.label
1858
+ }, e.value))
1859
+ }),
1860
+ /* @__PURE__ */ (0, R.jsx)("select", {
1861
+ className: "h-5 text-[10px] border rounded px-1 bg-background w-12",
1862
+ value: t.operator,
1863
+ onChange: (e) => s(n, { operator: e.target.value }),
1864
+ children: ce.map((e) => /* @__PURE__ */ (0, R.jsx)("option", {
1865
+ value: e.value,
1866
+ children: e.label
1867
+ }, e.value))
1868
+ }),
1869
+ /* @__PURE__ */ (0, R.jsx)("input", {
1870
+ className: "h-5 text-[10px] border rounded px-1 bg-background w-16",
1871
+ value: t.value,
1872
+ placeholder: "value",
1873
+ onChange: (e) => s(n, { value: e.target.value }),
1874
+ "data-testid": `cf-rule-value-${n}`
1875
+ }),
1876
+ /* @__PURE__ */ (0, R.jsx)("input", {
1877
+ type: "color",
1878
+ className: "h-5 w-5 rounded border cursor-pointer",
1879
+ value: t.backgroundColor || "#fef9c3",
1880
+ onChange: (e) => s(n, { backgroundColor: e.target.value }),
1881
+ title: "Background color"
1882
+ }),
1883
+ /* @__PURE__ */ (0, R.jsx)(a, {
1884
+ type: "button",
1885
+ size: "sm",
1886
+ variant: "ghost",
1887
+ className: "h-5 w-5 p-0",
1888
+ onClick: () => o(n),
1889
+ "data-testid": `cf-rule-remove-${n}`,
1890
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-3 w-3" })
1891
+ })
1892
+ ]
1893
+ }, n)), /* @__PURE__ */ (0, R.jsxs)(a, {
1894
+ type: "button",
1895
+ size: "sm",
1896
+ variant: "outline",
1897
+ className: "h-6 text-[10px] w-full",
1898
+ onClick: i,
1899
+ "data-testid": "cf-add-rule",
1900
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-3 w-3 mr-1" }), "Add Rule"]
1901
+ })]
1902
+ });
1677
1903
  }
1678
- const nt = [
1679
- { value: "header", label: "Header" },
1680
- { value: "summary", label: "Summary" },
1681
- { value: "table", label: "Table" },
1682
- { value: "chart", label: "Chart" },
1683
- { value: "text", label: "Text" }
1904
+ var ue = [
1905
+ {
1906
+ value: "header",
1907
+ label: "Header"
1908
+ },
1909
+ {
1910
+ value: "summary",
1911
+ label: "Summary"
1912
+ },
1913
+ {
1914
+ value: "table",
1915
+ label: "Table"
1916
+ },
1917
+ {
1918
+ value: "chart",
1919
+ label: "Chart"
1920
+ },
1921
+ {
1922
+ value: "text",
1923
+ label: "Text"
1924
+ }
1684
1925
  ];
1685
- function ot({
1686
- value: s,
1687
- onChange: n
1688
- }) {
1689
- const a = Array.isArray(s) ? s : [], o = (t) => {
1690
- n([...a, { type: t, title: `New ${t}`, visible: !0 }]);
1691
- }, c = (t) => {
1692
- n(a.filter((i, r) => r !== t));
1693
- }, x = (t, i) => {
1694
- n(a.map((r, p) => p === t ? { ...r, ...i } : r));
1695
- }, u = (t, i) => {
1696
- const r = t + i;
1697
- if (r < 0 || r >= a.length) return;
1698
- const p = [...a];
1699
- [p[t], p[r]] = [p[r], p[t]], n(p);
1700
- };
1701
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 py-1", "data-testid": "section-manager", children: [
1702
- a.map((t, i) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 text-[10px] p-1.5 border rounded bg-muted/20", children: [
1703
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-0.5 mr-1", children: [
1704
- /* @__PURE__ */ e.jsx(
1705
- "button",
1706
- {
1707
- type: "button",
1708
- className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
1709
- disabled: i === 0,
1710
- onClick: () => u(i, -1),
1711
- "data-testid": `section-up-${i}`,
1712
- children: "▲"
1713
- }
1714
- ),
1715
- /* @__PURE__ */ e.jsx(
1716
- "button",
1717
- {
1718
- type: "button",
1719
- className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
1720
- disabled: i === a.length - 1,
1721
- onClick: () => u(i, 1),
1722
- "data-testid": `section-down-${i}`,
1723
- children: "▼"
1724
- }
1725
- )
1726
- ] }),
1727
- /* @__PURE__ */ e.jsx("span", { className: "text-[9px] bg-muted px-1.5 py-0.5 rounded uppercase font-medium shrink-0", children: t.type }),
1728
- /* @__PURE__ */ e.jsx(
1729
- "input",
1730
- {
1731
- className: "h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0",
1732
- value: t.title || "",
1733
- placeholder: "Section title",
1734
- onChange: (r) => x(i, { title: r.target.value }),
1735
- "data-testid": `section-title-${i}`
1736
- }
1737
- ),
1738
- /* @__PURE__ */ e.jsx(
1739
- E,
1740
- {
1741
- type: "button",
1742
- size: "sm",
1743
- variant: "ghost",
1744
- className: "h-5 w-5 p-0 shrink-0",
1745
- onClick: () => c(i),
1746
- "data-testid": `section-remove-${i}`,
1747
- children: /* @__PURE__ */ e.jsx(X, { className: "h-3 w-3" })
1748
- }
1749
- )
1750
- ] }, i)),
1751
- /* @__PURE__ */ e.jsx("div", { className: "flex gap-1 flex-wrap", children: nt.map((t) => /* @__PURE__ */ e.jsxs(
1752
- E,
1753
- {
1754
- type: "button",
1755
- size: "sm",
1756
- variant: "outline",
1757
- className: "h-6 text-[10px]",
1758
- onClick: () => o(t.value),
1759
- "data-testid": `section-add-${t.value}`,
1760
- children: [
1761
- /* @__PURE__ */ e.jsx(G, { className: "h-3 w-3 mr-0.5" }),
1762
- t.label
1763
- ]
1764
- },
1765
- t.value
1766
- )) })
1767
- ] });
1926
+ function de({ value: e, onChange: t }) {
1927
+ let n = Array.isArray(e) ? e : [], r = (e) => {
1928
+ t([...n, {
1929
+ type: e,
1930
+ title: `New ${e}`,
1931
+ visible: !0
1932
+ }]);
1933
+ }, i = (e) => {
1934
+ t(n.filter((t, n) => n !== e));
1935
+ }, o = (e, r) => {
1936
+ t(n.map((t, n) => n === e ? {
1937
+ ...t,
1938
+ ...r
1939
+ } : t));
1940
+ }, s = (e, r) => {
1941
+ let i = e + r;
1942
+ if (i < 0 || i >= n.length) return;
1943
+ let a = [...n];
1944
+ [a[e], a[i]] = [a[i], a[e]], t(a);
1945
+ };
1946
+ return /* @__PURE__ */ (0, R.jsxs)("div", {
1947
+ className: "space-y-2 py-1",
1948
+ "data-testid": "section-manager",
1949
+ children: [n.map((e, t) => /* @__PURE__ */ (0, R.jsxs)("div", {
1950
+ className: "flex items-center gap-1 text-[10px] p-1.5 border rounded bg-muted/20",
1951
+ children: [
1952
+ /* @__PURE__ */ (0, R.jsxs)("div", {
1953
+ className: "flex flex-col gap-0.5 mr-1",
1954
+ children: [/* @__PURE__ */ (0, R.jsx)("button", {
1955
+ type: "button",
1956
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
1957
+ disabled: t === 0,
1958
+ onClick: () => s(t, -1),
1959
+ "data-testid": `section-up-${t}`,
1960
+ children: "▲"
1961
+ }), /* @__PURE__ */ (0, R.jsx)("button", {
1962
+ type: "button",
1963
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
1964
+ disabled: t === n.length - 1,
1965
+ onClick: () => s(t, 1),
1966
+ "data-testid": `section-down-${t}`,
1967
+ children: "▼"
1968
+ })]
1969
+ }),
1970
+ /* @__PURE__ */ (0, R.jsx)("span", {
1971
+ className: "text-[9px] bg-muted px-1.5 py-0.5 rounded uppercase font-medium shrink-0",
1972
+ children: e.type
1973
+ }),
1974
+ /* @__PURE__ */ (0, R.jsx)("input", {
1975
+ className: "h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0",
1976
+ value: e.title || "",
1977
+ placeholder: "Section title",
1978
+ onChange: (e) => o(t, { title: e.target.value }),
1979
+ "data-testid": `section-title-${t}`
1980
+ }),
1981
+ /* @__PURE__ */ (0, R.jsx)(a, {
1982
+ type: "button",
1983
+ size: "sm",
1984
+ variant: "ghost",
1985
+ className: "h-5 w-5 p-0 shrink-0",
1986
+ onClick: () => i(t),
1987
+ "data-testid": `section-remove-${t}`,
1988
+ children: /* @__PURE__ */ (0, R.jsx)(N, { className: "h-3 w-3" })
1989
+ })
1990
+ ]
1991
+ }, t)), /* @__PURE__ */ (0, R.jsx)("div", {
1992
+ className: "flex gap-1 flex-wrap",
1993
+ children: ue.map((e) => /* @__PURE__ */ (0, R.jsxs)(a, {
1994
+ type: "button",
1995
+ size: "sm",
1996
+ variant: "outline",
1997
+ className: "h-6 text-[10px]",
1998
+ onClick: () => r(e.value),
1999
+ "data-testid": `section-add-${e.value}`,
2000
+ children: [/* @__PURE__ */ (0, R.jsx)(O, { className: "h-3 w-3 mr-0.5" }), e.label]
2001
+ }, e.value))
2002
+ })]
2003
+ });
1768
2004
  }
1769
- function it(s = []) {
1770
- return {
1771
- breadcrumb: ["Report", "Configuration"],
1772
- sections: [
1773
- {
1774
- key: "basic",
1775
- title: "Basic",
1776
- fields: [
1777
- {
1778
- key: "title",
1779
- label: "Title",
1780
- type: "input",
1781
- placeholder: "Report title"
1782
- },
1783
- {
1784
- key: "description",
1785
- label: "Description",
1786
- type: "input",
1787
- placeholder: "Report description"
1788
- },
1789
- {
1790
- key: "reportType",
1791
- label: "Report type",
1792
- type: "select",
1793
- defaultValue: "tabular",
1794
- options: [
1795
- { value: "tabular", label: "Tabular" },
1796
- { value: "summary", label: "Summary" },
1797
- { value: "matrix", label: "Matrix" }
1798
- ],
1799
- helpText: "Tabular: flat table. Summary: grouped with subtotals. Matrix: pivot table (planned)."
1800
- }
1801
- ]
1802
- },
1803
- {
1804
- key: "data",
1805
- title: "Data",
1806
- collapsible: !0,
1807
- fields: [
1808
- {
1809
- key: "objectName",
1810
- label: "Data source",
1811
- type: "input",
1812
- placeholder: "e.g. opportunity",
1813
- helpText: "Object name to query data from"
1814
- },
1815
- {
1816
- key: "limit",
1817
- label: "Row limit",
1818
- type: "input",
1819
- defaultValue: "100",
1820
- placeholder: "e.g. 100"
1821
- }
1822
- ]
1823
- },
1824
- {
1825
- key: "columns",
1826
- title: "Columns",
1827
- collapsible: !0,
1828
- hint: "Select fields to display as report columns. Set aggregation per column for summary reports.",
1829
- fields: [
1830
- {
1831
- key: "fields",
1832
- label: "Report columns",
1833
- type: "custom",
1834
- render: (n, a) => /* @__PURE__ */ e.jsx(
1835
- tt,
1836
- {
1837
- availableFields: s,
1838
- value: n,
1839
- onChange: a
1840
- }
1841
- )
1842
- }
1843
- ]
1844
- },
1845
- {
1846
- key: "filters",
1847
- title: "Filters",
1848
- collapsible: !0,
1849
- hint: "Define filter conditions for the report data",
1850
- fields: [
1851
- {
1852
- key: "filters",
1853
- label: "Conditions",
1854
- type: "filter",
1855
- fields: s
1856
- }
1857
- ]
1858
- },
1859
- {
1860
- key: "groupBy",
1861
- title: "Group By",
1862
- collapsible: !0,
1863
- hint: "Group report data and compute aggregations",
1864
- fields: [
1865
- {
1866
- key: "groupBy",
1867
- label: "Grouping",
1868
- type: "sort",
1869
- fields: s
1870
- }
1871
- ]
1872
- },
1873
- {
1874
- key: "chart",
1875
- title: "Chart",
1876
- collapsible: !0,
1877
- hint: "Add a chart visualization to the report",
1878
- fields: [
1879
- {
1880
- key: "chartConfig",
1881
- label: "Chart",
1882
- type: "custom",
1883
- render: (n, a) => /* @__PURE__ */ e.jsx(
1884
- st,
1885
- {
1886
- availableFields: s,
1887
- value: n,
1888
- onChange: a
1889
- }
1890
- )
1891
- }
1892
- ]
1893
- },
1894
- {
1895
- key: "conditionalFormatting",
1896
- title: "Conditional Format",
1897
- collapsible: !0,
1898
- defaultCollapsed: !0,
1899
- hint: "Highlight cells based on field value conditions",
1900
- fields: [
1901
- {
1902
- key: "conditionalFormatting",
1903
- label: "Rules",
1904
- type: "custom",
1905
- render: (n, a) => /* @__PURE__ */ e.jsx(
1906
- lt,
1907
- {
1908
- availableFields: s,
1909
- value: n,
1910
- onChange: a
1911
- }
1912
- )
1913
- }
1914
- ]
1915
- },
1916
- {
1917
- key: "sections",
1918
- title: "Sections",
1919
- collapsible: !0,
1920
- defaultCollapsed: !0,
1921
- hint: "Manage report layout blocks (header, table, chart, summary)",
1922
- fields: [
1923
- {
1924
- key: "sections",
1925
- label: "Report sections",
1926
- type: "custom",
1927
- render: (n, a) => /* @__PURE__ */ e.jsx(ot, { value: n, onChange: a })
1928
- }
1929
- ]
1930
- },
1931
- {
1932
- key: "export",
1933
- title: "Export",
1934
- collapsible: !0,
1935
- defaultCollapsed: !0,
1936
- fields: [
1937
- {
1938
- key: "showExportButtons",
1939
- label: "Show export buttons",
1940
- type: "switch",
1941
- defaultValue: !0
1942
- },
1943
- {
1944
- key: "showPrintButton",
1945
- label: "Show print button",
1946
- type: "switch",
1947
- defaultValue: !0
1948
- },
1949
- {
1950
- key: "defaultExportFormat",
1951
- label: "Default export format",
1952
- type: "select",
1953
- defaultValue: "pdf",
1954
- options: [
1955
- { value: "pdf", label: "PDF" },
1956
- { value: "excel", label: "Excel" },
1957
- { value: "csv", label: "CSV" },
1958
- { value: "json", label: "JSON" },
1959
- { value: "html", label: "HTML" }
1960
- ]
1961
- }
1962
- ]
1963
- },
1964
- {
1965
- key: "schedule",
1966
- title: "Schedule",
1967
- collapsible: !0,
1968
- defaultCollapsed: !0,
1969
- fields: [
1970
- {
1971
- key: "schedule",
1972
- label: "Schedule",
1973
- type: "custom",
1974
- render: (n, a) => /* @__PURE__ */ e.jsx(Re, { schedule: n, onChange: a })
1975
- }
1976
- ]
1977
- },
1978
- {
1979
- key: "appearance",
1980
- title: "Appearance",
1981
- collapsible: !0,
1982
- defaultCollapsed: !0,
1983
- fields: [
1984
- {
1985
- key: "showToolbar",
1986
- label: "Show toolbar",
1987
- type: "switch",
1988
- defaultValue: !0
1989
- },
1990
- {
1991
- key: "refreshInterval",
1992
- label: "Refresh interval",
1993
- type: "select",
1994
- defaultValue: "0",
1995
- options: [
1996
- { value: "0", label: "Manual" },
1997
- { value: "30", label: "30s" },
1998
- { value: "60", label: "1 min" },
1999
- { value: "300", label: "5 min" }
2000
- ]
2001
- }
2002
- ]
2003
- }
2004
- ]
2005
- };
2005
+ function fe(e = []) {
2006
+ return {
2007
+ breadcrumb: ["Report", "Configuration"],
2008
+ sections: [
2009
+ {
2010
+ key: "basic",
2011
+ title: "Basic",
2012
+ fields: [
2013
+ {
2014
+ key: "title",
2015
+ label: "Title",
2016
+ type: "input",
2017
+ placeholder: "Report title"
2018
+ },
2019
+ {
2020
+ key: "description",
2021
+ label: "Description",
2022
+ type: "input",
2023
+ placeholder: "Report description"
2024
+ },
2025
+ {
2026
+ key: "reportType",
2027
+ label: "Report type",
2028
+ type: "select",
2029
+ defaultValue: "tabular",
2030
+ options: [
2031
+ {
2032
+ value: "tabular",
2033
+ label: "Tabular"
2034
+ },
2035
+ {
2036
+ value: "summary",
2037
+ label: "Summary"
2038
+ },
2039
+ {
2040
+ value: "matrix",
2041
+ label: "Matrix"
2042
+ }
2043
+ ],
2044
+ helpText: "Tabular: flat table. Summary: grouped with subtotals. Matrix: pivot table (planned)."
2045
+ }
2046
+ ]
2047
+ },
2048
+ {
2049
+ key: "data",
2050
+ title: "Data",
2051
+ collapsible: !0,
2052
+ fields: [{
2053
+ key: "objectName",
2054
+ label: "Data source",
2055
+ type: "input",
2056
+ placeholder: "e.g. opportunity",
2057
+ helpText: "Object name to query data from"
2058
+ }, {
2059
+ key: "limit",
2060
+ label: "Row limit",
2061
+ type: "input",
2062
+ defaultValue: "100",
2063
+ placeholder: "e.g. 100"
2064
+ }]
2065
+ },
2066
+ {
2067
+ key: "columns",
2068
+ title: "Columns",
2069
+ collapsible: !0,
2070
+ hint: "Select fields to display as report columns. Set aggregation per column for summary reports.",
2071
+ fields: [{
2072
+ key: "fields",
2073
+ label: "Report columns",
2074
+ type: "custom",
2075
+ render: (t, n) => /* @__PURE__ */ (0, R.jsx)(ae, {
2076
+ availableFields: e,
2077
+ value: t,
2078
+ onChange: n
2079
+ })
2080
+ }]
2081
+ },
2082
+ {
2083
+ key: "filters",
2084
+ title: "Filters",
2085
+ collapsible: !0,
2086
+ hint: "Define filter conditions for the report data",
2087
+ fields: [{
2088
+ key: "filters",
2089
+ label: "Conditions",
2090
+ type: "filter",
2091
+ fields: e
2092
+ }]
2093
+ },
2094
+ {
2095
+ key: "groupBy",
2096
+ title: "Group By",
2097
+ collapsible: !0,
2098
+ hint: "Group report data and compute aggregations",
2099
+ fields: [{
2100
+ key: "groupBy",
2101
+ label: "Grouping",
2102
+ type: "sort",
2103
+ fields: e
2104
+ }]
2105
+ },
2106
+ {
2107
+ key: "chart",
2108
+ title: "Chart",
2109
+ collapsible: !0,
2110
+ hint: "Add a chart visualization to the report",
2111
+ fields: [{
2112
+ key: "chartConfig",
2113
+ label: "Chart",
2114
+ type: "custom",
2115
+ render: (t, n) => /* @__PURE__ */ (0, R.jsx)(se, {
2116
+ availableFields: e,
2117
+ value: t,
2118
+ onChange: n
2119
+ })
2120
+ }]
2121
+ },
2122
+ {
2123
+ key: "conditionalFormatting",
2124
+ title: "Conditional Format",
2125
+ collapsible: !0,
2126
+ defaultCollapsed: !0,
2127
+ hint: "Highlight cells based on field value conditions",
2128
+ fields: [{
2129
+ key: "conditionalFormatting",
2130
+ label: "Rules",
2131
+ type: "custom",
2132
+ render: (t, n) => /* @__PURE__ */ (0, R.jsx)(le, {
2133
+ availableFields: e,
2134
+ value: t,
2135
+ onChange: n
2136
+ })
2137
+ }]
2138
+ },
2139
+ {
2140
+ key: "sections",
2141
+ title: "Sections",
2142
+ collapsible: !0,
2143
+ defaultCollapsed: !0,
2144
+ hint: "Manage report layout blocks (header, table, chart, summary)",
2145
+ fields: [{
2146
+ key: "sections",
2147
+ label: "Report sections",
2148
+ type: "custom",
2149
+ render: (e, t) => /* @__PURE__ */ (0, R.jsx)(de, {
2150
+ value: e,
2151
+ onChange: t
2152
+ })
2153
+ }]
2154
+ },
2155
+ {
2156
+ key: "export",
2157
+ title: "Export",
2158
+ collapsible: !0,
2159
+ defaultCollapsed: !0,
2160
+ fields: [
2161
+ {
2162
+ key: "showExportButtons",
2163
+ label: "Show export buttons",
2164
+ type: "switch",
2165
+ defaultValue: !0
2166
+ },
2167
+ {
2168
+ key: "showPrintButton",
2169
+ label: "Show print button",
2170
+ type: "switch",
2171
+ defaultValue: !0
2172
+ },
2173
+ {
2174
+ key: "defaultExportFormat",
2175
+ label: "Default export format",
2176
+ type: "select",
2177
+ defaultValue: "pdf",
2178
+ options: [
2179
+ {
2180
+ value: "pdf",
2181
+ label: "PDF"
2182
+ },
2183
+ {
2184
+ value: "excel",
2185
+ label: "Excel"
2186
+ },
2187
+ {
2188
+ value: "csv",
2189
+ label: "CSV"
2190
+ },
2191
+ {
2192
+ value: "json",
2193
+ label: "JSON"
2194
+ },
2195
+ {
2196
+ value: "html",
2197
+ label: "HTML"
2198
+ }
2199
+ ]
2200
+ }
2201
+ ]
2202
+ },
2203
+ {
2204
+ key: "schedule",
2205
+ title: "Schedule",
2206
+ collapsible: !0,
2207
+ defaultCollapsed: !0,
2208
+ fields: [{
2209
+ key: "schedule",
2210
+ label: "Schedule",
2211
+ type: "custom",
2212
+ render: (e, t) => /* @__PURE__ */ (0, R.jsx)($, {
2213
+ schedule: e,
2214
+ onChange: t
2215
+ })
2216
+ }]
2217
+ },
2218
+ {
2219
+ key: "appearance",
2220
+ title: "Appearance",
2221
+ collapsible: !0,
2222
+ defaultCollapsed: !0,
2223
+ fields: [{
2224
+ key: "showToolbar",
2225
+ label: "Show toolbar",
2226
+ type: "switch",
2227
+ defaultValue: !0
2228
+ }, {
2229
+ key: "refreshInterval",
2230
+ label: "Refresh interval",
2231
+ type: "select",
2232
+ defaultValue: "0",
2233
+ options: [
2234
+ {
2235
+ value: "0",
2236
+ label: "Manual"
2237
+ },
2238
+ {
2239
+ value: "30",
2240
+ label: "30s"
2241
+ },
2242
+ {
2243
+ value: "60",
2244
+ label: "1 min"
2245
+ },
2246
+ {
2247
+ value: "300",
2248
+ label: "5 min"
2249
+ }
2250
+ ]
2251
+ }]
2252
+ }
2253
+ ]
2254
+ };
2006
2255
  }
2007
- function yt({
2008
- open: s,
2009
- onClose: n,
2010
- config: a,
2011
- onSave: o,
2012
- onFieldChange: c,
2013
- availableFields: x
2014
- }) {
2015
- const { draft: u, isDirty: t, updateField: i, discard: r, undo: p, redo: v, canUndo: S, canRedo: w } = $e(a, {
2016
- onUpdate: c
2017
- }), _ = Ee.useMemo(
2018
- () => it(x),
2019
- [x]
2020
- );
2021
- return /* @__PURE__ */ e.jsx(
2022
- Oe,
2023
- {
2024
- open: s,
2025
- onClose: n,
2026
- schema: _,
2027
- draft: u,
2028
- isDirty: t,
2029
- onFieldChange: i,
2030
- onSave: () => o(u),
2031
- onDiscard: r,
2032
- onUndo: p,
2033
- onRedo: v,
2034
- canUndo: S,
2035
- canRedo: w
2036
- }
2037
- );
2256
+ function pe({ open: e, onClose: n, config: r, onSave: i, onFieldChange: a, availableFields: o }) {
2257
+ let { draft: s, isDirty: c, updateField: l, discard: u, undo: d, redo: p, canUndo: m, canRedo: h } = b(r, { onUpdate: a });
2258
+ return /* @__PURE__ */ (0, R.jsx)(f, {
2259
+ open: e,
2260
+ onClose: n,
2261
+ schema: t.useMemo(() => fe(o), [o]),
2262
+ draft: s,
2263
+ isDirty: c,
2264
+ onFieldChange: l,
2265
+ onSave: () => i(s),
2266
+ onDiscard: u,
2267
+ onUndo: d,
2268
+ onRedo: p,
2269
+ canUndo: m,
2270
+ canRedo: h
2271
+ });
2038
2272
  }
2039
- async function ct(s, n) {
2040
- var i;
2041
- const {
2042
- dataSource: a,
2043
- resource: o,
2044
- queryParams: c,
2045
- format: x,
2046
- exportConfig: u
2047
- } = n, t = x || s.defaultExportFormat || "pdf";
2048
- try {
2049
- const p = (await a.find(o, c)).data || [], v = {
2050
- format: t,
2051
- ...(i = s.exportConfigs) == null ? void 0 : i[t],
2052
- ...u
2053
- };
2054
- return Ne(t, s, p, v), {
2055
- success: !0,
2056
- recordCount: p.length,
2057
- format: t
2058
- };
2059
- } catch (r) {
2060
- return {
2061
- success: !1,
2062
- recordCount: 0,
2063
- format: t,
2064
- error: r.message
2065
- };
2066
- }
2273
+ //#endregion
2274
+ //#region src/LiveReportExporter.ts
2275
+ async function me(e, t) {
2276
+ let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
2277
+ try {
2278
+ let t = (await n.find(r, i)).data || [];
2279
+ return G(s, e, t, {
2280
+ format: s,
2281
+ ...e.exportConfigs?.[s],
2282
+ ...o
2283
+ }), {
2284
+ success: !0,
2285
+ recordCount: t.length,
2286
+ format: s
2287
+ };
2288
+ } catch (e) {
2289
+ return {
2290
+ success: !1,
2291
+ recordCount: 0,
2292
+ format: s,
2293
+ error: e.message
2294
+ };
2295
+ }
2067
2296
  }
2068
- function Nt(s, n, a = {}) {
2069
- const { columns: o, filename: c, includeAggregationRow: x = !1 } = a, u = o || (s.fields || []).map(dt), t = u.map((v) => v.header), i = n.map((v, S) => u.map((w) => {
2070
- if (w.formula)
2071
- return w.formula.replace(/\{ROW\}/g, String(S + 2));
2072
- const _ = v[w.name];
2073
- return ut(_, w.numberFormat);
2074
- }));
2075
- if (x && n.length > 0) {
2076
- const v = u.map((S, w) => {
2077
- const _ = (s.fields || []).find((k) => k.name === S.name);
2078
- if (_ != null && _.aggregation) {
2079
- const k = pt(w), m = 2, N = n.length + 1;
2080
- switch (_.aggregation) {
2081
- case "sum":
2082
- return `=SUM(${k}${m}:${k}${N})`;
2083
- case "avg":
2084
- return `=AVERAGE(${k}${m}:${k}${N})`;
2085
- case "count":
2086
- return `=COUNTA(${k}${m}:${k}${N})`;
2087
- case "min":
2088
- return `=MIN(${k}${m}:${k}${N})`;
2089
- case "max":
2090
- return `=MAX(${k}${m}:${k}${N})`;
2091
- default:
2092
- return "";
2093
- }
2094
- }
2095
- return "";
2096
- });
2097
- i.push(v);
2098
- }
2099
- const r = "\uFEFF" + [
2100
- t.join(" "),
2101
- ...i.map((v) => v.join(" "))
2102
- ].join(`
2103
- `), p = c || `${s.title || "report"}.tsv`;
2104
- xt(r, p, "text/tab-separated-values");
2297
+ function he(e, t, n = {}) {
2298
+ let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(_e), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
2299
+ if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
2300
+ let r = e[n.name];
2301
+ return ve(r, n.numberFormat);
2302
+ }));
2303
+ if (a && t.length > 0) {
2304
+ let n = o.map((n, r) => {
2305
+ let i = (e.fields || []).find((e) => e.name === n.name);
2306
+ if (i?.aggregation) {
2307
+ let e = be(r), n = t.length + 1;
2308
+ switch (i.aggregation) {
2309
+ case "sum": return `=SUM(${e}2:${e}${n})`;
2310
+ case "avg": return `=AVERAGE(${e}2:${e}${n})`;
2311
+ case "count": return `=COUNTA(${e}2:${e}${n})`;
2312
+ case "min": return `=MIN(${e}2:${e}${n})`;
2313
+ case "max": return `=MAX(${e}2:${e}${n})`;
2314
+ default: return "";
2315
+ }
2316
+ }
2317
+ return "";
2318
+ });
2319
+ c.push(n);
2320
+ }
2321
+ Se("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
2105
2322
  }
2106
- function wt(s, n, a, o) {
2107
- return async () => {
2108
- const c = s.schedule;
2109
- if (!(c != null && c.enabled))
2110
- return [];
2111
- const x = c.formats || [s.defaultExportFormat || "pdf"], u = [];
2112
- for (const t of x) {
2113
- const i = await ct(s, {
2114
- dataSource: n,
2115
- resource: a,
2116
- format: t
2117
- });
2118
- u.push(i);
2119
- }
2120
- return o(s, c), u;
2121
- };
2323
+ function ge(e, t, n, r) {
2324
+ return async () => {
2325
+ let i = e.schedule;
2326
+ if (!i?.enabled) return [];
2327
+ let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
2328
+ for (let r of a) {
2329
+ let i = await me(e, {
2330
+ dataSource: t,
2331
+ resource: n,
2332
+ format: r
2333
+ });
2334
+ o.push(i);
2335
+ }
2336
+ return r(e, i), o;
2337
+ };
2122
2338
  }
2123
- function dt(s) {
2124
- return {
2125
- name: s.name,
2126
- header: s.label || s.name
2127
- };
2339
+ function _e(e) {
2340
+ return {
2341
+ name: e.name,
2342
+ header: e.label || e.name
2343
+ };
2128
2344
  }
2129
- function ut(s, n) {
2130
- return s == null ? "" : typeof s == "number" && n ? s.toLocaleString("en-US", mt(n)) : ht(String(s));
2345
+ function ve(e, t) {
2346
+ return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", ye(t)) : xe(String(e));
2131
2347
  }
2132
- function mt(s) {
2133
- if (s.includes("%"))
2134
- return { style: "percent", minimumFractionDigits: 0 };
2135
- const n = (s.match(/0/g) || []).length;
2136
- return {
2137
- minimumFractionDigits: Math.max(0, n - 1),
2138
- maximumFractionDigits: Math.max(0, n - 1)
2139
- };
2348
+ function ye(e) {
2349
+ if (e.includes("%")) return {
2350
+ style: "percent",
2351
+ minimumFractionDigits: 0
2352
+ };
2353
+ let t = (e.match(/0/g) || []).length;
2354
+ return {
2355
+ minimumFractionDigits: Math.max(0, t - 1),
2356
+ maximumFractionDigits: Math.max(0, t - 1)
2357
+ };
2140
2358
  }
2141
- function pt(s) {
2142
- let n = "", a = s;
2143
- for (; a >= 0; )
2144
- n = String.fromCharCode(a % 26 + 65) + n, a = Math.floor(a / 26) - 1;
2145
- return n;
2359
+ function be(e) {
2360
+ let t = "", n = e;
2361
+ for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
2362
+ return t;
2146
2363
  }
2147
- function ht(s) {
2148
- if (s.length > 0) {
2149
- const n = s.charAt(0);
2150
- if (n === "=" || n === "+" || n === "-" || n === "@" || n === "|")
2151
- return `'${s}`;
2152
- }
2153
- return s;
2364
+ function xe(e) {
2365
+ if (e.length > 0) {
2366
+ let t = e.charAt(0);
2367
+ if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
2368
+ }
2369
+ return e;
2154
2370
  }
2155
- function xt(s, n, a) {
2156
- const o = new Blob([s], { type: `${a};charset=utf-8` }), c = URL.createObjectURL(o), x = document.createElement("a");
2157
- x.href = c, x.download = n, document.body.appendChild(x), x.click(), document.body.removeChild(x), URL.revokeObjectURL(c);
2371
+ function Se(e, t, n) {
2372
+ let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
2373
+ a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
2158
2374
  }
2159
- U.register(
2160
- "report",
2161
- Ye,
2162
- {
2163
- namespace: "report",
2164
- label: "Report",
2165
- category: "Report",
2166
- inputs: [
2167
- { name: "title", type: "string", label: "Title" },
2168
- { name: "description", type: "string", label: "Description" },
2169
- { name: "chart", type: "code", label: "Chart Configuration" }
2170
- ]
2171
- }
2172
- );
2173
- U.register(
2174
- "report-viewer",
2175
- Se,
2176
- {
2177
- namespace: "report",
2178
- label: "Report Viewer",
2179
- category: "Report",
2180
- inputs: [
2181
- { name: "report", type: "code", label: "Report Definition" },
2182
- { name: "showToolbar", type: "boolean", label: "Show Toolbar" }
2183
- ]
2184
- }
2185
- );
2186
- U.register(
2187
- "report-builder",
2188
- Ke,
2189
- {
2190
- namespace: "report",
2191
- label: "Report Builder",
2192
- category: "Report",
2193
- inputs: [
2194
- { name: "report", type: "code", label: "Initial Report" }
2195
- ]
2196
- }
2197
- );
2198
- export {
2199
- Ke as ReportBuilder,
2200
- yt as ReportConfigPanel,
2201
- Ye as ReportRenderer,
2202
- Se as ReportViewer,
2203
- Re as ScheduleConfig,
2204
- wt as createScheduleTrigger,
2205
- qe as exportAsCSV,
2206
- Je as exportAsExcel,
2207
- ye as exportAsHTML,
2208
- We as exportAsJSON,
2209
- He as exportAsPDF,
2210
- Nt as exportExcelWithFormulas,
2211
- Ne as exportReport,
2212
- ct as exportWithLiveData,
2213
- ge as formatValue
2214
- };
2375
+ e.register("report", z, {
2376
+ namespace: "report",
2377
+ label: "Report",
2378
+ category: "Report",
2379
+ inputs: [
2380
+ {
2381
+ name: "title",
2382
+ type: "string",
2383
+ label: "Title"
2384
+ },
2385
+ {
2386
+ name: "description",
2387
+ type: "string",
2388
+ label: "Description"
2389
+ },
2390
+ {
2391
+ name: "chart",
2392
+ type: "code",
2393
+ label: "Chart Configuration"
2394
+ }
2395
+ ]
2396
+ }), e.register("report-viewer", Q, {
2397
+ namespace: "report",
2398
+ label: "Report Viewer",
2399
+ category: "Report",
2400
+ inputs: [{
2401
+ name: "report",
2402
+ type: "code",
2403
+ label: "Report Definition"
2404
+ }, {
2405
+ name: "showToolbar",
2406
+ type: "boolean",
2407
+ label: "Show Toolbar"
2408
+ }]
2409
+ }), e.register("report-builder", re, {
2410
+ namespace: "report",
2411
+ label: "Report Builder",
2412
+ category: "Report",
2413
+ inputs: [{
2414
+ name: "report",
2415
+ type: "code",
2416
+ label: "Initial Report"
2417
+ }]
2418
+ });
2419
+ //#endregion
2420
+ export { re as ReportBuilder, pe as ReportConfigPanel, z as ReportRenderer, Q as ReportViewer, $ as ScheduleConfig, ge as createScheduleTrigger, B as exportAsCSV, W as exportAsExcel, H as exportAsHTML, V as exportAsJSON, U as exportAsPDF, he as exportExcelWithFormulas, G as exportReport, me as exportWithLiveData, Z as formatValue };