@nice2dev/ui-bi 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,2059 @@
1
+ import { jsxs as t, jsx as e, Fragment as F } from "react/jsx-runtime";
2
+ import { useState as S, useCallback as w, useRef as q } from "react";
3
+ const Y = {
4
+ id: "",
5
+ name: "New Report",
6
+ dataSource: "",
7
+ layout: {
8
+ type: "table",
9
+ elements: [],
10
+ pageSize: "A4",
11
+ orientation: "portrait"
12
+ },
13
+ parameters: [],
14
+ filters: [],
15
+ sorting: [],
16
+ grouping: [],
17
+ calculations: [],
18
+ formatting: {
19
+ conditionalFormats: [],
20
+ alternateRowColors: !0,
21
+ gridLines: !0
22
+ }
23
+ }, W = [
24
+ { type: "table", label: "Table", icon: "📊" },
25
+ { type: "chart", label: "Chart", icon: "📈" },
26
+ { type: "text", label: "Text", icon: "📝" },
27
+ { type: "image", label: "Image", icon: "🖼️" },
28
+ { type: "shape", label: "Shape", icon: "⬜" },
29
+ { type: "barcode", label: "Barcode", icon: "▮▯▮" },
30
+ { type: "qrcode", label: "QR Code", icon: "⊞" },
31
+ { type: "subreport", label: "Subreport", icon: "📋" },
32
+ { type: "page-break", label: "Page Break", icon: "📄" }
33
+ ];
34
+ function he({
35
+ report: i,
36
+ dataSources: l = [],
37
+ onChange: o,
38
+ onPreview: s,
39
+ onExport: d,
40
+ className: m = ""
41
+ }) {
42
+ const [a, y] = S(
43
+ i || { ...Y, id: crypto.randomUUID() }
44
+ ), [r, v] = S(null), [_, p] = S("design"), [f, M] = S(null), [T, L] = S(100), b = w(
45
+ (n) => {
46
+ y((h) => {
47
+ const g = n(h);
48
+ return o == null || o(g), g;
49
+ });
50
+ },
51
+ [o]
52
+ ), D = w(
53
+ (n, h) => {
54
+ const g = {
55
+ id: crypto.randomUUID(),
56
+ type: n,
57
+ position: {
58
+ x: h.x,
59
+ y: h.y,
60
+ width: 200,
61
+ height: n === "page-break" ? 20 : 100
62
+ },
63
+ config: B(n),
64
+ style: {}
65
+ };
66
+ b((k) => ({
67
+ ...k,
68
+ layout: {
69
+ ...k.layout,
70
+ elements: [...k.layout.elements, g]
71
+ }
72
+ })), v(g);
73
+ },
74
+ [b]
75
+ ), z = w(
76
+ (n, h) => {
77
+ b((g) => ({
78
+ ...g,
79
+ layout: {
80
+ ...g.layout,
81
+ elements: g.layout.elements.map(
82
+ (k) => k.id === n ? { ...k, ...h } : k
83
+ )
84
+ }
85
+ })), (r == null ? void 0 : r.id) === n && v((g) => g ? { ...g, ...h } : null);
86
+ },
87
+ [b, r]
88
+ ), C = w(
89
+ (n) => {
90
+ b((h) => ({
91
+ ...h,
92
+ layout: {
93
+ ...h.layout,
94
+ elements: h.layout.elements.filter((g) => g.id !== n)
95
+ }
96
+ })), v(null);
97
+ },
98
+ [b]
99
+ ), E = w(
100
+ (n) => {
101
+ if (n.preventDefault(), !f)
102
+ return;
103
+ const h = n.currentTarget.getBoundingClientRect(), g = (n.clientX - h.left) * (100 / T), k = (n.clientY - h.top) * (100 / T);
104
+ D(f, { x: g, y: k }), M(null);
105
+ },
106
+ [f, D, T]
107
+ ), P = w(() => {
108
+ s == null || s(a);
109
+ }, [a, s]), U = w(
110
+ (n) => {
111
+ d == null || d(a, n);
112
+ },
113
+ [a, d]
114
+ ), u = l.find((n) => n.id === a.dataSource);
115
+ return /* @__PURE__ */ t("div", { className: `nice-report-builder ${m}`, children: [
116
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__toolbar", children: [
117
+ /* @__PURE__ */ e(
118
+ "input",
119
+ {
120
+ type: "text",
121
+ value: a.name,
122
+ onChange: (n) => b((h) => ({ ...h, name: n.target.value })),
123
+ className: "nice-report-builder__name-input"
124
+ }
125
+ ),
126
+ /* @__PURE__ */ e("div", { className: "nice-report-builder__tabs", children: ["design", "data", "parameters", "formatting"].map((n) => /* @__PURE__ */ e(
127
+ "button",
128
+ {
129
+ className: `nice-report-builder__tab ${_ === n ? "nice-report-builder__tab--active" : ""}`,
130
+ onClick: () => p(n),
131
+ children: n.charAt(0).toUpperCase() + n.slice(1)
132
+ },
133
+ n
134
+ )) }),
135
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__zoom", children: [
136
+ /* @__PURE__ */ e("button", { onClick: () => L((n) => Math.max(25, n - 25)), children: "−" }),
137
+ /* @__PURE__ */ t("span", { children: [
138
+ T,
139
+ "%"
140
+ ] }),
141
+ /* @__PURE__ */ e("button", { onClick: () => L((n) => Math.min(200, n + 25)), children: "+" })
142
+ ] }),
143
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__actions", children: [
144
+ /* @__PURE__ */ e("button", { onClick: P, children: "👁 Preview" }),
145
+ /* @__PURE__ */ e("button", { onClick: () => U("pdf"), children: "📄 PDF" }),
146
+ /* @__PURE__ */ e("button", { onClick: () => U("excel"), children: "📊 Excel" })
147
+ ] })
148
+ ] }),
149
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__main", children: [
150
+ _ === "design" && /* @__PURE__ */ t("div", { className: "nice-report-builder__palette", children: [
151
+ /* @__PURE__ */ e("h4", { children: "Elements" }),
152
+ W.map((n) => /* @__PURE__ */ t(
153
+ "div",
154
+ {
155
+ className: "nice-report-builder__palette-item",
156
+ draggable: !0,
157
+ onDragStart: () => M(n.type),
158
+ onDragEnd: () => M(null),
159
+ children: [
160
+ /* @__PURE__ */ e("span", { className: "nice-report-builder__palette-icon", children: n.icon }),
161
+ /* @__PURE__ */ e("span", { children: n.label })
162
+ ]
163
+ },
164
+ n.type
165
+ )),
166
+ /* @__PURE__ */ e("h4", { children: "Data Source" }),
167
+ /* @__PURE__ */ t(
168
+ "select",
169
+ {
170
+ value: a.dataSource,
171
+ onChange: (n) => b((h) => ({ ...h, dataSource: n.target.value })),
172
+ children: [
173
+ /* @__PURE__ */ e("option", { value: "", children: "Select data source..." }),
174
+ l.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, n.id))
175
+ ]
176
+ }
177
+ ),
178
+ (u == null ? void 0 : u.schema) && /* @__PURE__ */ t("div", { className: "nice-report-builder__fields", children: [
179
+ /* @__PURE__ */ e("h5", { children: "Fields" }),
180
+ u.schema.tables.map((n) => /* @__PURE__ */ t("div", { className: "nice-report-builder__table-fields", children: [
181
+ /* @__PURE__ */ e("strong", { children: n.name }),
182
+ n.columns.map((h) => /* @__PURE__ */ t(
183
+ "div",
184
+ {
185
+ className: "nice-report-builder__field",
186
+ draggable: !0,
187
+ onDragStart: () => {
188
+ },
189
+ children: [
190
+ h.name,
191
+ " ",
192
+ /* @__PURE__ */ t("small", { children: [
193
+ "(",
194
+ h.type,
195
+ ")"
196
+ ] })
197
+ ]
198
+ },
199
+ h.name
200
+ ))
201
+ ] }, n.name))
202
+ ] })
203
+ ] }),
204
+ _ === "design" && /* @__PURE__ */ e("div", { className: "nice-report-builder__canvas-container", children: /* @__PURE__ */ t(
205
+ "div",
206
+ {
207
+ className: "nice-report-builder__canvas",
208
+ style: {
209
+ transform: `scale(${T / 100})`,
210
+ transformOrigin: "top left",
211
+ width: a.layout.orientation === "landscape" ? "297mm" : "210mm",
212
+ height: a.layout.orientation === "landscape" ? "210mm" : "297mm"
213
+ },
214
+ onDragOver: (n) => n.preventDefault(),
215
+ onDrop: E,
216
+ onClick: () => v(null),
217
+ children: [
218
+ a.layout.elements.map((n) => /* @__PURE__ */ e(
219
+ O,
220
+ {
221
+ element: n,
222
+ isSelected: (r == null ? void 0 : r.id) === n.id,
223
+ onSelect: () => v(n),
224
+ onUpdate: (h) => z(n.id, h),
225
+ onDelete: () => C(n.id)
226
+ },
227
+ n.id
228
+ )),
229
+ a.layout.elements.length === 0 && /* @__PURE__ */ e("div", { className: "nice-report-builder__canvas-empty", children: "Drag elements here to build your report" })
230
+ ]
231
+ }
232
+ ) }),
233
+ _ === "data" && /* @__PURE__ */ e(
234
+ X,
235
+ {
236
+ report: a,
237
+ dataSource: u,
238
+ onChange: (n) => b((h) => ({ ...h, query: n }))
239
+ }
240
+ ),
241
+ _ === "parameters" && /* @__PURE__ */ e(
242
+ H,
243
+ {
244
+ parameters: a.parameters,
245
+ calculations: a.calculations,
246
+ onChange: (n, h) => b((g) => ({ ...g, parameters: n, calculations: h }))
247
+ }
248
+ ),
249
+ _ === "formatting" && /* @__PURE__ */ e(
250
+ j,
251
+ {
252
+ formatting: a.formatting,
253
+ grouping: a.grouping,
254
+ sorting: a.sorting,
255
+ onChange: (n, h, g) => b((k) => ({ ...k, formatting: n, grouping: h, sorting: g }))
256
+ }
257
+ ),
258
+ r && _ === "design" && /* @__PURE__ */ e(
259
+ G,
260
+ {
261
+ element: r,
262
+ dataSource: u,
263
+ onChange: (n) => z(r.id, n),
264
+ onClose: () => v(null)
265
+ }
266
+ )
267
+ ] })
268
+ ] });
269
+ }
270
+ function B(i) {
271
+ switch (i) {
272
+ case "table":
273
+ return { columns: [], showHeader: !0, showFooter: !1 };
274
+ case "chart":
275
+ return { chartType: "bar", series: [], axes: [] };
276
+ case "text":
277
+ return { content: "Text", fontSize: 12 };
278
+ case "image":
279
+ return { src: "", fit: "contain" };
280
+ case "shape":
281
+ return { shape: "rectangle", fill: "#e0e0e0", stroke: "#333" };
282
+ case "barcode":
283
+ return { format: "CODE128", value: "" };
284
+ case "qrcode":
285
+ return { value: "" };
286
+ case "subreport":
287
+ return { reportId: "" };
288
+ case "page-break":
289
+ return {};
290
+ default:
291
+ return {};
292
+ }
293
+ }
294
+ function O({
295
+ element: i,
296
+ isSelected: l,
297
+ onSelect: o,
298
+ onUpdate: s,
299
+ onDelete: d
300
+ }) {
301
+ var L;
302
+ const [m, a] = S(!1), [y, r] = S(!1), v = (b) => {
303
+ if (b.button !== 0)
304
+ return;
305
+ b.stopPropagation(), o(), a(!0);
306
+ const D = b.clientX, z = b.clientY, C = { ...i.position }, E = (U) => {
307
+ const u = U.clientX - D, n = U.clientY - z;
308
+ s({
309
+ position: {
310
+ ...C,
311
+ x: Math.max(0, C.x + u),
312
+ y: Math.max(0, C.y + n)
313
+ }
314
+ });
315
+ }, P = () => {
316
+ a(!1), window.removeEventListener("mousemove", E), window.removeEventListener("mouseup", P);
317
+ };
318
+ window.addEventListener("mousemove", E), window.addEventListener("mouseup", P);
319
+ }, _ = (b, D) => {
320
+ b.stopPropagation(), r(!0);
321
+ const z = b.clientX, C = b.clientY, E = { ...i.position }, P = (u) => {
322
+ const n = u.clientX - z, h = u.clientY - C, g = { ...E };
323
+ D.includes("e") && (g.width = Math.max(50, E.width + n)), D.includes("s") && (g.height = Math.max(30, E.height + h)), D.includes("w") && (g.x = E.x + n, g.width = Math.max(50, E.width - n)), D.includes("n") && (g.y = E.y + h, g.height = Math.max(30, E.height - h)), s({ position: g });
324
+ }, U = () => {
325
+ r(!1), window.removeEventListener("mousemove", P), window.removeEventListener("mouseup", U);
326
+ };
327
+ window.addEventListener("mousemove", P), window.addEventListener("mouseup", U);
328
+ }, p = W.find((b) => b.type === i.type), { padding: f, ...M } = i.style ?? {}, T = typeof f == "object" && f !== null ? `${f.top}px ${f.right}px ${f.bottom}px ${f.left}px` : f;
329
+ return /* @__PURE__ */ t(
330
+ "div",
331
+ {
332
+ className: `nice-report-builder__element nice-report-builder__element--${i.type} ${l ? "nice-report-builder__element--selected" : ""}`,
333
+ style: {
334
+ left: i.position.x,
335
+ top: i.position.y,
336
+ width: i.position.width,
337
+ height: i.position.height,
338
+ ...M,
339
+ padding: T
340
+ },
341
+ onMouseDown: v,
342
+ children: [
343
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__element-content", children: [
344
+ /* @__PURE__ */ e("span", { className: "nice-report-builder__element-icon", children: p == null ? void 0 : p.icon }),
345
+ /* @__PURE__ */ e("span", { className: "nice-report-builder__element-label", children: ((L = i.binding) == null ? void 0 : L.field) || (p == null ? void 0 : p.label) })
346
+ ] }),
347
+ l && /* @__PURE__ */ t(F, { children: [
348
+ /* @__PURE__ */ e(
349
+ "button",
350
+ {
351
+ className: "nice-report-builder__element-delete",
352
+ onClick: (b) => {
353
+ b.stopPropagation(), d();
354
+ },
355
+ children: "×"
356
+ }
357
+ ),
358
+ /* @__PURE__ */ e(
359
+ "div",
360
+ {
361
+ className: "nice-report-builder__resize-handle nice-report-builder__resize-handle--se",
362
+ onMouseDown: (b) => _(b, "se")
363
+ }
364
+ ),
365
+ /* @__PURE__ */ e(
366
+ "div",
367
+ {
368
+ className: "nice-report-builder__resize-handle nice-report-builder__resize-handle--e",
369
+ onMouseDown: (b) => _(b, "e")
370
+ }
371
+ ),
372
+ /* @__PURE__ */ e(
373
+ "div",
374
+ {
375
+ className: "nice-report-builder__resize-handle nice-report-builder__resize-handle--s",
376
+ onMouseDown: (b) => _(b, "s")
377
+ }
378
+ )
379
+ ] })
380
+ ]
381
+ }
382
+ );
383
+ }
384
+ function X({
385
+ report: i,
386
+ dataSource: l,
387
+ onChange: o
388
+ }) {
389
+ var m, a, y, r;
390
+ const [s, d] = S("builder");
391
+ return /* @__PURE__ */ t("div", { className: "nice-report-builder__query-builder", children: [
392
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__query-tabs", children: [
393
+ /* @__PURE__ */ e("button", { className: s === "builder" ? "active" : "", onClick: () => d("builder"), children: "Query Builder" }),
394
+ /* @__PURE__ */ e("button", { className: s === "sql" ? "active" : "", onClick: () => d("sql"), children: "SQL" })
395
+ ] }),
396
+ s === "builder" ? /* @__PURE__ */ t("div", { className: "nice-report-builder__visual-query", children: [
397
+ /* @__PURE__ */ e("h4", { children: "Tables" }),
398
+ (m = l == null ? void 0 : l.schema) == null ? void 0 : m.tables.map((v) => {
399
+ var _, p;
400
+ return /* @__PURE__ */ e("div", { className: "nice-report-builder__query-table", children: /* @__PURE__ */ t("label", { children: [
401
+ /* @__PURE__ */ e(
402
+ "input",
403
+ {
404
+ type: "checkbox",
405
+ checked: ((p = (_ = i.query) == null ? void 0 : _.tables) == null ? void 0 : p.includes(v.name)) || !1,
406
+ onChange: (f) => {
407
+ var T, L;
408
+ const M = f.target.checked ? [...((T = i.query) == null ? void 0 : T.tables) || [], v.name] : (((L = i.query) == null ? void 0 : L.tables) || []).filter((b) => b !== v.name);
409
+ o({ ...i.query, type: "builder", tables: M });
410
+ }
411
+ }
412
+ ),
413
+ v.name
414
+ ] }) }, v.name);
415
+ }),
416
+ /* @__PURE__ */ e("h4", { children: "Columns" }),
417
+ /* @__PURE__ */ e("div", { className: "nice-report-builder__column-list", children: (y = (a = i.query) == null ? void 0 : a.tables) == null ? void 0 : y.map((v) => {
418
+ var p;
419
+ const _ = (p = l == null ? void 0 : l.schema) == null ? void 0 : p.tables.find((f) => f.name === v);
420
+ return _ == null ? void 0 : _.columns.map((f) => /* @__PURE__ */ t("div", { className: "nice-report-builder__column-item", children: [
421
+ /* @__PURE__ */ e("input", { type: "checkbox" }),
422
+ /* @__PURE__ */ t("span", { children: [
423
+ v,
424
+ ".",
425
+ f.name
426
+ ] }),
427
+ /* @__PURE__ */ t("select", { children: [
428
+ /* @__PURE__ */ e("option", { value: "", children: "No aggregate" }),
429
+ /* @__PURE__ */ e("option", { value: "sum", children: "SUM" }),
430
+ /* @__PURE__ */ e("option", { value: "avg", children: "AVG" }),
431
+ /* @__PURE__ */ e("option", { value: "count", children: "COUNT" }),
432
+ /* @__PURE__ */ e("option", { value: "min", children: "MIN" }),
433
+ /* @__PURE__ */ e("option", { value: "max", children: "MAX" })
434
+ ] })
435
+ ] }, `${v}.${f.name}`));
436
+ }) })
437
+ ] }) : /* @__PURE__ */ e("div", { className: "nice-report-builder__sql-editor", children: /* @__PURE__ */ e(
438
+ "textarea",
439
+ {
440
+ value: ((r = i.query) == null ? void 0 : r.text) || "",
441
+ onChange: (v) => o({ ...i.query, type: "sql", text: v.target.value }),
442
+ placeholder: "SELECT * FROM table_name",
443
+ rows: 15
444
+ }
445
+ ) })
446
+ ] });
447
+ }
448
+ function H({
449
+ parameters: i,
450
+ calculations: l,
451
+ onChange: o
452
+ }) {
453
+ const s = () => {
454
+ const m = {
455
+ id: crypto.randomUUID(),
456
+ name: "param" + (i.length + 1),
457
+ label: "Parameter " + (i.length + 1),
458
+ type: "text"
459
+ };
460
+ o([...i, m], l);
461
+ }, d = () => {
462
+ const m = {
463
+ id: crypto.randomUUID(),
464
+ name: "calc" + (l.length + 1),
465
+ expression: ""
466
+ };
467
+ o(i, [...l, m]);
468
+ };
469
+ return /* @__PURE__ */ t("div", { className: "nice-report-builder__parameters-editor", children: [
470
+ /* @__PURE__ */ t("section", { children: [
471
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__section-header", children: [
472
+ /* @__PURE__ */ e("h4", { children: "Parameters" }),
473
+ /* @__PURE__ */ e("button", { onClick: s, children: "+ Add" })
474
+ ] }),
475
+ i.map((m, a) => /* @__PURE__ */ t("div", { className: "nice-report-builder__param-row", children: [
476
+ /* @__PURE__ */ e(
477
+ "input",
478
+ {
479
+ type: "text",
480
+ value: m.name,
481
+ placeholder: "Name",
482
+ onChange: (y) => {
483
+ const r = [...i];
484
+ r[a] = { ...m, name: y.target.value }, o(r, l);
485
+ }
486
+ }
487
+ ),
488
+ /* @__PURE__ */ e(
489
+ "input",
490
+ {
491
+ type: "text",
492
+ value: m.label,
493
+ placeholder: "Label",
494
+ onChange: (y) => {
495
+ const r = [...i];
496
+ r[a] = { ...m, label: y.target.value }, o(r, l);
497
+ }
498
+ }
499
+ ),
500
+ /* @__PURE__ */ t(
501
+ "select",
502
+ {
503
+ value: m.type,
504
+ onChange: (y) => {
505
+ const r = [...i];
506
+ r[a] = { ...m, type: y.target.value }, o(r, l);
507
+ },
508
+ children: [
509
+ /* @__PURE__ */ e("option", { value: "text", children: "Text" }),
510
+ /* @__PURE__ */ e("option", { value: "number", children: "Number" }),
511
+ /* @__PURE__ */ e("option", { value: "date", children: "Date" }),
512
+ /* @__PURE__ */ e("option", { value: "daterange", children: "Date Range" }),
513
+ /* @__PURE__ */ e("option", { value: "select", children: "Select" }),
514
+ /* @__PURE__ */ e("option", { value: "multiselect", children: "Multi-select" })
515
+ ]
516
+ }
517
+ ),
518
+ /* @__PURE__ */ e(
519
+ "button",
520
+ {
521
+ onClick: () => {
522
+ o(
523
+ i.filter((y) => y.id !== m.id),
524
+ l
525
+ );
526
+ },
527
+ children: "×"
528
+ }
529
+ )
530
+ ] }, m.id))
531
+ ] }),
532
+ /* @__PURE__ */ t("section", { children: [
533
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__section-header", children: [
534
+ /* @__PURE__ */ e("h4", { children: "Calculated Fields" }),
535
+ /* @__PURE__ */ e("button", { onClick: d, children: "+ Add" })
536
+ ] }),
537
+ l.map((m, a) => /* @__PURE__ */ t("div", { className: "nice-report-builder__calc-row", children: [
538
+ /* @__PURE__ */ e(
539
+ "input",
540
+ {
541
+ type: "text",
542
+ value: m.name,
543
+ placeholder: "Name",
544
+ onChange: (y) => {
545
+ const r = [...l];
546
+ r[a] = { ...m, name: y.target.value }, o(i, r);
547
+ }
548
+ }
549
+ ),
550
+ /* @__PURE__ */ e(
551
+ "input",
552
+ {
553
+ type: "text",
554
+ value: m.expression,
555
+ placeholder: "Expression (e.g., [Sales] * [Quantity])",
556
+ onChange: (y) => {
557
+ const r = [...l];
558
+ r[a] = { ...m, expression: y.target.value }, o(i, r);
559
+ }
560
+ }
561
+ ),
562
+ /* @__PURE__ */ e(
563
+ "button",
564
+ {
565
+ onClick: () => {
566
+ o(
567
+ i,
568
+ l.filter((y) => y.id !== m.id)
569
+ );
570
+ },
571
+ children: "×"
572
+ }
573
+ )
574
+ ] }, m.id))
575
+ ] })
576
+ ] });
577
+ }
578
+ function j({
579
+ formatting: i,
580
+ grouping: l,
581
+ sorting: o,
582
+ onChange: s
583
+ }) {
584
+ return /* @__PURE__ */ t("div", { className: "nice-report-builder__formatting-editor", children: [
585
+ /* @__PURE__ */ t("section", { children: [
586
+ /* @__PURE__ */ e("h4", { children: "General" }),
587
+ /* @__PURE__ */ t("label", { children: [
588
+ /* @__PURE__ */ e(
589
+ "input",
590
+ {
591
+ type: "checkbox",
592
+ checked: i.alternateRowColors,
593
+ onChange: (d) => s({ ...i, alternateRowColors: d.target.checked }, l, o)
594
+ }
595
+ ),
596
+ "Alternate row colors"
597
+ ] }),
598
+ /* @__PURE__ */ t("label", { children: [
599
+ /* @__PURE__ */ e(
600
+ "input",
601
+ {
602
+ type: "checkbox",
603
+ checked: i.gridLines,
604
+ onChange: (d) => s({ ...i, gridLines: d.target.checked }, l, o)
605
+ }
606
+ ),
607
+ "Show grid lines"
608
+ ] })
609
+ ] }),
610
+ /* @__PURE__ */ t("section", { children: [
611
+ /* @__PURE__ */ e("h4", { children: "Conditional Formatting" }),
612
+ /* @__PURE__ */ e(
613
+ "button",
614
+ {
615
+ onClick: () => {
616
+ const d = {
617
+ id: crypto.randomUUID(),
618
+ condition: { column: "", operator: "gt", value: 0 },
619
+ style: { backgroundColor: "#ffcccc" },
620
+ scope: "cell"
621
+ };
622
+ s(
623
+ {
624
+ ...i,
625
+ conditionalFormats: [...i.conditionalFormats, d]
626
+ },
627
+ l,
628
+ o
629
+ );
630
+ },
631
+ children: "+ Add Rule"
632
+ }
633
+ ),
634
+ i.conditionalFormats.map((d) => /* @__PURE__ */ t("div", { className: "nice-report-builder__format-rule", children: [
635
+ /* @__PURE__ */ t("span", { children: [
636
+ "If column ",
637
+ d.condition.operator,
638
+ " ",
639
+ String(d.condition.value)
640
+ ] }),
641
+ /* @__PURE__ */ e(
642
+ "input",
643
+ {
644
+ type: "color",
645
+ value: d.style.backgroundColor || "#ffffff",
646
+ onChange: (m) => {
647
+ s(
648
+ {
649
+ ...i,
650
+ conditionalFormats: i.conditionalFormats.map(
651
+ (a) => a.id === d.id ? { ...a, style: { ...a.style, backgroundColor: m.target.value } } : a
652
+ )
653
+ },
654
+ l,
655
+ o
656
+ );
657
+ }
658
+ }
659
+ )
660
+ ] }, d.id))
661
+ ] })
662
+ ] });
663
+ }
664
+ function G({
665
+ element: i,
666
+ dataSource: l,
667
+ onChange: o,
668
+ onClose: s
669
+ }) {
670
+ var d, m, a, y, r, v, _;
671
+ return /* @__PURE__ */ t("div", { className: "nice-report-builder__properties", children: [
672
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__properties-header", children: [
673
+ /* @__PURE__ */ t("h4", { children: [
674
+ (d = W.find((p) => p.type === i.type)) == null ? void 0 : d.label,
675
+ " Properties"
676
+ ] }),
677
+ /* @__PURE__ */ e("button", { onClick: s, children: "×" })
678
+ ] }),
679
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__properties-content", children: [
680
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
681
+ /* @__PURE__ */ e("label", { children: "Data Binding" }),
682
+ /* @__PURE__ */ t(
683
+ "select",
684
+ {
685
+ value: ((m = i.binding) == null ? void 0 : m.field) || "",
686
+ onChange: (p) => o({ binding: { ...i.binding, field: p.target.value } }),
687
+ children: [
688
+ /* @__PURE__ */ e("option", { value: "", children: "None" }),
689
+ (a = l == null ? void 0 : l.schema) == null ? void 0 : a.tables.flatMap(
690
+ (p) => p.columns.map((f) => /* @__PURE__ */ t("option", { value: `${p.name}.${f.name}`, children: [
691
+ p.name,
692
+ ".",
693
+ f.name
694
+ ] }, `${p.name}.${f.name}`))
695
+ )
696
+ ]
697
+ }
698
+ )
699
+ ] }),
700
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
701
+ /* @__PURE__ */ e("label", { children: "Position" }),
702
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__position-inputs", children: [
703
+ /* @__PURE__ */ e(
704
+ "input",
705
+ {
706
+ type: "number",
707
+ value: i.position.x,
708
+ onChange: (p) => o({
709
+ position: { ...i.position, x: parseInt(p.target.value, 10) || 0 }
710
+ }),
711
+ placeholder: "X"
712
+ }
713
+ ),
714
+ /* @__PURE__ */ e(
715
+ "input",
716
+ {
717
+ type: "number",
718
+ value: i.position.y,
719
+ onChange: (p) => o({
720
+ position: { ...i.position, y: parseInt(p.target.value, 10) || 0 }
721
+ }),
722
+ placeholder: "Y"
723
+ }
724
+ ),
725
+ /* @__PURE__ */ e(
726
+ "input",
727
+ {
728
+ type: "number",
729
+ value: i.position.width,
730
+ onChange: (p) => o({
731
+ position: { ...i.position, width: parseInt(p.target.value, 10) || 50 }
732
+ }),
733
+ placeholder: "W"
734
+ }
735
+ ),
736
+ /* @__PURE__ */ e(
737
+ "input",
738
+ {
739
+ type: "number",
740
+ value: i.position.height,
741
+ onChange: (p) => o({
742
+ position: { ...i.position, height: parseInt(p.target.value, 10) || 30 }
743
+ }),
744
+ placeholder: "H"
745
+ }
746
+ )
747
+ ] })
748
+ ] }),
749
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
750
+ /* @__PURE__ */ e("label", { children: "Background Color" }),
751
+ /* @__PURE__ */ e(
752
+ "input",
753
+ {
754
+ type: "color",
755
+ value: ((y = i.style) == null ? void 0 : y.backgroundColor) || "#ffffff",
756
+ onChange: (p) => o({ style: { ...i.style, backgroundColor: p.target.value } })
757
+ }
758
+ )
759
+ ] }),
760
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
761
+ /* @__PURE__ */ e("label", { children: "Border" }),
762
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__border-inputs", children: [
763
+ /* @__PURE__ */ e(
764
+ "input",
765
+ {
766
+ type: "color",
767
+ value: ((r = i.style) == null ? void 0 : r.borderColor) || "#000000",
768
+ onChange: (p) => o({ style: { ...i.style, borderColor: p.target.value } })
769
+ }
770
+ ),
771
+ /* @__PURE__ */ e(
772
+ "input",
773
+ {
774
+ type: "number",
775
+ value: ((v = i.style) == null ? void 0 : v.borderWidth) || 0,
776
+ onChange: (p) => o({
777
+ style: { ...i.style, borderWidth: parseInt(p.target.value, 10) || 0 }
778
+ }),
779
+ placeholder: "Width",
780
+ min: 0,
781
+ max: 10
782
+ }
783
+ )
784
+ ] })
785
+ ] }),
786
+ i.type === "text" && /* @__PURE__ */ t(F, { children: [
787
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
788
+ /* @__PURE__ */ e("label", { children: "Content" }),
789
+ /* @__PURE__ */ e(
790
+ "textarea",
791
+ {
792
+ value: i.config.content || "",
793
+ onChange: (p) => o({ config: { ...i.config, content: p.target.value } }),
794
+ rows: 3
795
+ }
796
+ )
797
+ ] }),
798
+ /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
799
+ /* @__PURE__ */ e("label", { children: "Font Size" }),
800
+ /* @__PURE__ */ e(
801
+ "input",
802
+ {
803
+ type: "number",
804
+ value: ((_ = i.style) == null ? void 0 : _.fontSize) || 12,
805
+ onChange: (p) => o({
806
+ style: { ...i.style, fontSize: parseInt(p.target.value, 10) || 12 }
807
+ }),
808
+ min: 8,
809
+ max: 72
810
+ }
811
+ )
812
+ ] })
813
+ ] }),
814
+ i.type === "chart" && /* @__PURE__ */ t("div", { className: "nice-report-builder__field", children: [
815
+ /* @__PURE__ */ e("label", { children: "Chart Type" }),
816
+ /* @__PURE__ */ t(
817
+ "select",
818
+ {
819
+ value: i.config.chartType || "bar",
820
+ onChange: (p) => o({ config: { ...i.config, chartType: p.target.value } }),
821
+ children: [
822
+ /* @__PURE__ */ e("option", { value: "bar", children: "Bar" }),
823
+ /* @__PURE__ */ e("option", { value: "line", children: "Line" }),
824
+ /* @__PURE__ */ e("option", { value: "pie", children: "Pie" }),
825
+ /* @__PURE__ */ e("option", { value: "area", children: "Area" }),
826
+ /* @__PURE__ */ e("option", { value: "scatter", children: "Scatter" })
827
+ ]
828
+ }
829
+ )
830
+ ] })
831
+ ] })
832
+ ] });
833
+ }
834
+ const Q = {
835
+ id: "",
836
+ name: "New Dashboard",
837
+ layout: {
838
+ type: "grid",
839
+ columns: 12,
840
+ rowHeight: 50,
841
+ gap: 8
842
+ },
843
+ widgets: [],
844
+ filters: []
845
+ }, V = [
846
+ { type: "chart", label: "Chart", icon: "📈", category: "Visualization" },
847
+ { type: "table", label: "Table", icon: "📊", category: "Visualization" },
848
+ { type: "card", label: "KPI Card", icon: "🎯", category: "Visualization" },
849
+ { type: "gauge", label: "Gauge", icon: "⏱️", category: "Visualization" },
850
+ { type: "map", label: "Map", icon: "🗺️", category: "Visualization" },
851
+ { type: "treemap", label: "Treemap", icon: "🌳", category: "Visualization" },
852
+ { type: "funnel", label: "Funnel", icon: "🔻", category: "Visualization" },
853
+ { type: "heatmap", label: "Heatmap", icon: "🌡️", category: "Visualization" },
854
+ { type: "timeline", label: "Timeline", icon: "📅", category: "Visualization" },
855
+ { type: "sankey", label: "Sankey", icon: "〰️", category: "Visualization" },
856
+ { type: "filter", label: "Filter", icon: "🔍", category: "Controls" },
857
+ { type: "slicer", label: "Slicer", icon: "📋", category: "Controls" },
858
+ { type: "text", label: "Text", icon: "📝", category: "Layout" },
859
+ { type: "image", label: "Image", icon: "🖼️", category: "Layout" }
860
+ ];
861
+ function pe({
862
+ dashboard: i,
863
+ dataSources: l = [],
864
+ onChange: o,
865
+ onWidgetAdd: s,
866
+ onRefresh: d,
867
+ className: m = ""
868
+ }) {
869
+ const [a, y] = S(
870
+ i || { ...Q, id: crypto.randomUUID() }
871
+ ), [r, v] = S(null), [_, p] = S(!0), [f, M] = S(null), [T, L] = S(!0), b = q(null), D = w(
872
+ (u) => {
873
+ y((n) => {
874
+ const h = u(n);
875
+ return o == null || o(h), h;
876
+ });
877
+ },
878
+ [o]
879
+ ), z = w(
880
+ (u, n) => {
881
+ var g;
882
+ const h = {
883
+ id: crypto.randomUUID(),
884
+ type: u,
885
+ title: ((g = V.find((k) => k.type === u)) == null ? void 0 : g.label) || u,
886
+ position: {
887
+ x: (n == null ? void 0 : n.x) ?? 0,
888
+ y: (n == null ? void 0 : n.y) ?? K(a.widgets),
889
+ width: (n == null ? void 0 : n.width) ?? J(u),
890
+ height: (n == null ? void 0 : n.height) ?? Z(u)
891
+ },
892
+ config: ee(u)
893
+ };
894
+ D((k) => ({
895
+ ...k,
896
+ widgets: [...k.widgets, h]
897
+ })), v(h), s == null || s(u);
898
+ },
899
+ [a.widgets, D, s]
900
+ ), C = w(
901
+ (u, n) => {
902
+ D((h) => ({
903
+ ...h,
904
+ widgets: h.widgets.map((g) => g.id === u ? { ...g, ...n } : g)
905
+ })), (r == null ? void 0 : r.id) === u && v((h) => h ? { ...h, ...n } : null);
906
+ },
907
+ [D, r]
908
+ ), E = w(
909
+ (u) => {
910
+ D((n) => ({
911
+ ...n,
912
+ widgets: n.widgets.filter((h) => h.id !== u)
913
+ })), v(null);
914
+ },
915
+ [D]
916
+ ), P = w(
917
+ (u) => {
918
+ if (u.preventDefault(), !f || !b.current)
919
+ return;
920
+ const n = b.current.getBoundingClientRect(), h = n.width / (a.layout.columns || 12), g = Math.floor((u.clientX - n.left) / h), k = Math.floor((u.clientY - n.top) / (a.layout.rowHeight || 50));
921
+ z(f, { x: g, y: k }), M(null);
922
+ },
923
+ [f, a.layout, z]
924
+ ), U = w(() => {
925
+ d == null || d();
926
+ }, [d]);
927
+ return /* @__PURE__ */ t("div", { className: `nice-dashboard-studio ${m}`, children: [
928
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__toolbar", children: [
929
+ /* @__PURE__ */ e(
930
+ "input",
931
+ {
932
+ type: "text",
933
+ value: a.name,
934
+ onChange: (u) => D((n) => ({ ...n, name: u.target.value })),
935
+ className: "nice-dashboard-studio__name-input",
936
+ disabled: !_
937
+ }
938
+ ),
939
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__actions", children: [
940
+ /* @__PURE__ */ e(
941
+ "button",
942
+ {
943
+ className: `nice-dashboard-studio__action ${_ ? "active" : ""}`,
944
+ onClick: () => p(!_),
945
+ children: _ ? "✏️ Editing" : "👁 Viewing"
946
+ }
947
+ ),
948
+ /* @__PURE__ */ t("button", { onClick: () => L(!T), children: [
949
+ "🔍 Filters ",
950
+ T ? "▲" : "▼"
951
+ ] }),
952
+ /* @__PURE__ */ e("button", { onClick: U, children: "🔄 Refresh" }),
953
+ /* @__PURE__ */ e("button", { children: "📤 Share" }),
954
+ /* @__PURE__ */ e("button", { children: "💾 Save" })
955
+ ] })
956
+ ] }),
957
+ T && a.filters.length > 0 && /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__filters-bar", children: a.filters.map((u) => /* @__PURE__ */ e(ne, { filter: u }, u.id)) }),
958
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__main", children: [
959
+ _ && /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__palette", children: [
960
+ /* @__PURE__ */ e("h4", { children: "Widgets" }),
961
+ ["Visualization", "Controls", "Layout"].map((u) => /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__category", children: [
962
+ /* @__PURE__ */ e("h5", { children: u }),
963
+ V.filter((n) => n.category === u).map((n) => /* @__PURE__ */ t(
964
+ "div",
965
+ {
966
+ className: "nice-dashboard-studio__palette-item",
967
+ draggable: !0,
968
+ onDragStart: () => M(n.type),
969
+ onDragEnd: () => M(null),
970
+ children: [
971
+ /* @__PURE__ */ e("span", { className: "nice-dashboard-studio__palette-icon", children: n.icon }),
972
+ /* @__PURE__ */ e("span", { children: n.label })
973
+ ]
974
+ },
975
+ n.type
976
+ ))
977
+ ] }, u)),
978
+ /* @__PURE__ */ e("h4", { children: "Data Sources" }),
979
+ l.map((u) => /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__datasource", children: /* @__PURE__ */ t("span", { children: [
980
+ "🗄️ ",
981
+ u.name
982
+ ] }) }, u.id))
983
+ ] }),
984
+ /* @__PURE__ */ t(
985
+ "div",
986
+ {
987
+ ref: b,
988
+ className: `nice-dashboard-studio__grid ${_ ? "nice-dashboard-studio__grid--editing" : ""}`,
989
+ style: {
990
+ "--columns": a.layout.columns || 12,
991
+ "--row-height": `${a.layout.rowHeight || 50}px`,
992
+ "--gap": `${a.layout.gap || 8}px`
993
+ },
994
+ onDragOver: (u) => u.preventDefault(),
995
+ onDrop: P,
996
+ onClick: () => v(null),
997
+ children: [
998
+ a.widgets.map((u) => /* @__PURE__ */ e(
999
+ ie,
1000
+ {
1001
+ widget: u,
1002
+ isSelected: (r == null ? void 0 : r.id) === u.id,
1003
+ isEditing: _,
1004
+ onSelect: () => v(u),
1005
+ onUpdate: (n) => C(u.id, n),
1006
+ onDelete: () => E(u.id)
1007
+ },
1008
+ u.id
1009
+ )),
1010
+ a.widgets.length === 0 && _ && /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__empty", children: "Drag widgets from the palette to build your dashboard" })
1011
+ ]
1012
+ }
1013
+ ),
1014
+ r && _ && /* @__PURE__ */ e(
1015
+ ae,
1016
+ {
1017
+ widget: r,
1018
+ dataSources: l,
1019
+ onChange: (u) => C(r.id, u),
1020
+ onClose: () => v(null)
1021
+ }
1022
+ )
1023
+ ] })
1024
+ ] });
1025
+ }
1026
+ function K(i) {
1027
+ return i.length === 0 ? 0 : Math.max(...i.map((l) => l.position.y + l.position.height));
1028
+ }
1029
+ function J(i) {
1030
+ switch (i) {
1031
+ case "card":
1032
+ return 3;
1033
+ case "gauge":
1034
+ return 3;
1035
+ case "filter":
1036
+ case "slicer":
1037
+ return 3;
1038
+ case "text":
1039
+ return 4;
1040
+ case "chart":
1041
+ case "table":
1042
+ return 6;
1043
+ case "map":
1044
+ return 8;
1045
+ default:
1046
+ return 4;
1047
+ }
1048
+ }
1049
+ function Z(i) {
1050
+ switch (i) {
1051
+ case "card":
1052
+ return 2;
1053
+ case "gauge":
1054
+ return 3;
1055
+ case "filter":
1056
+ case "slicer":
1057
+ return 1;
1058
+ case "text":
1059
+ return 2;
1060
+ case "chart":
1061
+ case "table":
1062
+ return 5;
1063
+ case "map":
1064
+ return 8;
1065
+ default:
1066
+ return 4;
1067
+ }
1068
+ }
1069
+ function ee(i) {
1070
+ switch (i) {
1071
+ case "chart":
1072
+ return { chartType: "bar", series: [], axes: [], legend: { show: !0, position: "bottom" } };
1073
+ case "table":
1074
+ return { columns: [], pageSize: 10 };
1075
+ case "card":
1076
+ return { value: "", label: "", format: "number", icon: "📊" };
1077
+ case "gauge":
1078
+ return { value: "0", min: 0, max: 100, target: 75, format: "percent" };
1079
+ case "map":
1080
+ return { type: "choropleth", geoField: "", valueField: "" };
1081
+ case "filter":
1082
+ return { field: "", type: "dropdown" };
1083
+ case "slicer":
1084
+ return { field: "", multiSelect: !0 };
1085
+ case "text":
1086
+ return { content: "Text content", fontSize: 14 };
1087
+ case "image":
1088
+ return { src: "", fit: "contain" };
1089
+ default:
1090
+ return {};
1091
+ }
1092
+ }
1093
+ function ie({
1094
+ widget: i,
1095
+ isSelected: l,
1096
+ isEditing: o,
1097
+ onSelect: s,
1098
+ onUpdate: d,
1099
+ onDelete: m
1100
+ }) {
1101
+ const a = (r) => {
1102
+ if (!o || r.button !== 0)
1103
+ return;
1104
+ r.stopPropagation(), s();
1105
+ const v = r.clientX, _ = r.clientY, p = { ...i.position }, f = (T) => {
1106
+ const L = Math.round((T.clientX - v) / 50), b = Math.round((T.clientY - _) / 50);
1107
+ d({
1108
+ position: {
1109
+ ...p,
1110
+ x: Math.max(0, p.x + L),
1111
+ y: Math.max(0, p.y + b)
1112
+ }
1113
+ });
1114
+ }, M = () => {
1115
+ window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", M);
1116
+ };
1117
+ window.addEventListener("mousemove", f), window.addEventListener("mouseup", M);
1118
+ }, y = V.find((r) => r.type === i.type);
1119
+ return /* @__PURE__ */ t(
1120
+ "div",
1121
+ {
1122
+ className: `nice-dashboard-studio__widget nice-dashboard-studio__widget--${i.type} ${l ? "nice-dashboard-studio__widget--selected" : ""}`,
1123
+ style: {
1124
+ gridColumn: `${i.position.x + 1} / span ${i.position.width}`,
1125
+ gridRow: `${i.position.y + 1} / span ${i.position.height}`
1126
+ },
1127
+ onMouseDown: a,
1128
+ children: [
1129
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__widget-header", children: [
1130
+ /* @__PURE__ */ e("span", { className: "nice-dashboard-studio__widget-icon", children: y == null ? void 0 : y.icon }),
1131
+ /* @__PURE__ */ e("span", { className: "nice-dashboard-studio__widget-title", children: i.title }),
1132
+ o && /* @__PURE__ */ e(
1133
+ "button",
1134
+ {
1135
+ className: "nice-dashboard-studio__widget-delete",
1136
+ onClick: (r) => {
1137
+ r.stopPropagation(), m();
1138
+ },
1139
+ children: "×"
1140
+ }
1141
+ )
1142
+ ] }),
1143
+ /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__widget-content", children: /* @__PURE__ */ e(te, { widget: i }) })
1144
+ ]
1145
+ }
1146
+ );
1147
+ }
1148
+ function te({ widget: i }) {
1149
+ switch (i.type) {
1150
+ case "card":
1151
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__card", children: [
1152
+ /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__card-value", children: String(i.config.value || "0") }),
1153
+ /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__card-label", children: String(i.config.label || "Label") })
1154
+ ] });
1155
+ case "gauge":
1156
+ const l = Number(i.config.value) || 0, o = Number(i.config.max) || 100, s = l / o * 100;
1157
+ return /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__gauge", children: /* @__PURE__ */ t("svg", { viewBox: "0 0 100 60", children: [
1158
+ /* @__PURE__ */ e("path", { d: "M 10 55 A 40 40 0 0 1 90 55", fill: "none", stroke: "#e0e0e0", strokeWidth: "8" }),
1159
+ /* @__PURE__ */ e(
1160
+ "path",
1161
+ {
1162
+ d: "M 10 55 A 40 40 0 0 1 90 55",
1163
+ fill: "none",
1164
+ stroke: "#0066cc",
1165
+ strokeWidth: "8",
1166
+ strokeDasharray: `${s * 1.26} 126`
1167
+ }
1168
+ ),
1169
+ /* @__PURE__ */ t("text", { x: "50", y: "50", textAnchor: "middle", fontSize: "16", fontWeight: "bold", children: [
1170
+ l,
1171
+ "%"
1172
+ ] })
1173
+ ] }) });
1174
+ case "chart":
1175
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__chart-placeholder", children: [
1176
+ /* @__PURE__ */ e("span", { children: "📊" }),
1177
+ /* @__PURE__ */ t("span", { children: [
1178
+ String(i.config.chartType || "bar"),
1179
+ " chart"
1180
+ ] })
1181
+ ] });
1182
+ case "table":
1183
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__table-placeholder", children: [
1184
+ /* @__PURE__ */ e("span", { children: "📋" }),
1185
+ /* @__PURE__ */ e("span", { children: "Data table" })
1186
+ ] });
1187
+ case "map":
1188
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__map-placeholder", children: [
1189
+ /* @__PURE__ */ e("span", { children: "🗺️" }),
1190
+ /* @__PURE__ */ e("span", { children: "Map visualization" })
1191
+ ] });
1192
+ case "text":
1193
+ return /* @__PURE__ */ e(
1194
+ "div",
1195
+ {
1196
+ className: "nice-dashboard-studio__text",
1197
+ style: { fontSize: Number(i.config.fontSize) || 14 },
1198
+ children: String(i.config.content || "")
1199
+ }
1200
+ );
1201
+ default:
1202
+ return /* @__PURE__ */ e("div", { className: "nice-dashboard-studio__widget-placeholder", children: i.type });
1203
+ }
1204
+ }
1205
+ function ne({ filter: i }) {
1206
+ const [l, o] = S(i.defaultValue);
1207
+ switch (i.type) {
1208
+ case "dropdown":
1209
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__filter", children: [
1210
+ /* @__PURE__ */ e("label", { children: i.label }),
1211
+ /* @__PURE__ */ e("select", { value: String(l || ""), onChange: (s) => o(s.target.value), children: /* @__PURE__ */ e("option", { value: "", children: "All" }) })
1212
+ ] });
1213
+ case "daterange":
1214
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__filter", children: [
1215
+ /* @__PURE__ */ e("label", { children: i.label }),
1216
+ /* @__PURE__ */ e("input", { type: "date" }),
1217
+ /* @__PURE__ */ e("span", { children: "to" }),
1218
+ /* @__PURE__ */ e("input", { type: "date" })
1219
+ ] });
1220
+ case "slider":
1221
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__filter", children: [
1222
+ /* @__PURE__ */ e("label", { children: i.label }),
1223
+ /* @__PURE__ */ e("input", { type: "range" })
1224
+ ] });
1225
+ default:
1226
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__filter", children: [
1227
+ /* @__PURE__ */ e("label", { children: i.label }),
1228
+ /* @__PURE__ */ e(
1229
+ "input",
1230
+ {
1231
+ type: "text",
1232
+ value: String(l || ""),
1233
+ onChange: (s) => o(s.target.value)
1234
+ }
1235
+ )
1236
+ ] });
1237
+ }
1238
+ }
1239
+ function ae({
1240
+ widget: i,
1241
+ dataSources: l,
1242
+ onChange: o,
1243
+ onClose: s
1244
+ }) {
1245
+ return /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__properties", children: [
1246
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__properties-header", children: [
1247
+ /* @__PURE__ */ e("h4", { children: "Widget Properties" }),
1248
+ /* @__PURE__ */ e("button", { onClick: s, children: "×" })
1249
+ ] }),
1250
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__properties-content", children: [
1251
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1252
+ /* @__PURE__ */ e("label", { children: "Title" }),
1253
+ /* @__PURE__ */ e(
1254
+ "input",
1255
+ {
1256
+ type: "text",
1257
+ value: i.title || "",
1258
+ onChange: (d) => o({ title: d.target.value })
1259
+ }
1260
+ )
1261
+ ] }),
1262
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1263
+ /* @__PURE__ */ e("label", { children: "Data Source" }),
1264
+ /* @__PURE__ */ t(
1265
+ "select",
1266
+ {
1267
+ value: i.dataSource || "",
1268
+ onChange: (d) => o({ dataSource: d.target.value }),
1269
+ children: [
1270
+ /* @__PURE__ */ e("option", { value: "", children: "Select..." }),
1271
+ l.map((d) => /* @__PURE__ */ e("option", { value: d.id, children: d.name }, d.id))
1272
+ ]
1273
+ }
1274
+ )
1275
+ ] }),
1276
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1277
+ /* @__PURE__ */ e("label", { children: "Size" }),
1278
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__size-inputs", children: [
1279
+ /* @__PURE__ */ e(
1280
+ "input",
1281
+ {
1282
+ type: "number",
1283
+ value: i.position.width,
1284
+ onChange: (d) => o({
1285
+ position: { ...i.position, width: parseInt(d.target.value, 10) || 1 }
1286
+ }),
1287
+ min: 1,
1288
+ max: 12
1289
+ }
1290
+ ),
1291
+ /* @__PURE__ */ e("span", { children: "×" }),
1292
+ /* @__PURE__ */ e(
1293
+ "input",
1294
+ {
1295
+ type: "number",
1296
+ value: i.position.height,
1297
+ onChange: (d) => o({
1298
+ position: { ...i.position, height: parseInt(d.target.value, 10) || 1 }
1299
+ }),
1300
+ min: 1,
1301
+ max: 20
1302
+ }
1303
+ )
1304
+ ] })
1305
+ ] }),
1306
+ i.type === "chart" && /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1307
+ /* @__PURE__ */ e("label", { children: "Chart Type" }),
1308
+ /* @__PURE__ */ t(
1309
+ "select",
1310
+ {
1311
+ value: String(i.config.chartType || "bar"),
1312
+ onChange: (d) => o({ config: { ...i.config, chartType: d.target.value } }),
1313
+ children: [
1314
+ /* @__PURE__ */ e("option", { value: "bar", children: "Bar" }),
1315
+ /* @__PURE__ */ e("option", { value: "line", children: "Line" }),
1316
+ /* @__PURE__ */ e("option", { value: "pie", children: "Pie" }),
1317
+ /* @__PURE__ */ e("option", { value: "area", children: "Area" }),
1318
+ /* @__PURE__ */ e("option", { value: "scatter", children: "Scatter" }),
1319
+ /* @__PURE__ */ e("option", { value: "donut", children: "Donut" })
1320
+ ]
1321
+ }
1322
+ )
1323
+ ] }),
1324
+ i.type === "card" && /* @__PURE__ */ t(F, { children: [
1325
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1326
+ /* @__PURE__ */ e("label", { children: "Value Field" }),
1327
+ /* @__PURE__ */ e(
1328
+ "input",
1329
+ {
1330
+ type: "text",
1331
+ value: String(i.config.value || ""),
1332
+ onChange: (d) => o({ config: { ...i.config, value: d.target.value } }),
1333
+ placeholder: "e.g., SUM(Sales)"
1334
+ }
1335
+ )
1336
+ ] }),
1337
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1338
+ /* @__PURE__ */ e("label", { children: "Label" }),
1339
+ /* @__PURE__ */ e(
1340
+ "input",
1341
+ {
1342
+ type: "text",
1343
+ value: String(i.config.label || ""),
1344
+ onChange: (d) => o({ config: { ...i.config, label: d.target.value } })
1345
+ }
1346
+ )
1347
+ ] })
1348
+ ] }),
1349
+ i.type === "text" && /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1350
+ /* @__PURE__ */ e("label", { children: "Content" }),
1351
+ /* @__PURE__ */ e(
1352
+ "textarea",
1353
+ {
1354
+ value: String(i.config.content || ""),
1355
+ onChange: (d) => o({ config: { ...i.config, content: d.target.value } }),
1356
+ rows: 4
1357
+ }
1358
+ )
1359
+ ] }),
1360
+ /* @__PURE__ */ t("div", { className: "nice-dashboard-studio__field", children: [
1361
+ /* @__PURE__ */ e("label", { children: "Refresh Interval (seconds)" }),
1362
+ /* @__PURE__ */ e(
1363
+ "input",
1364
+ {
1365
+ type: "number",
1366
+ value: i.refreshInterval || 0,
1367
+ onChange: (d) => o({ refreshInterval: parseInt(d.target.value, 10) || 0 }),
1368
+ min: 0,
1369
+ placeholder: "0 = manual"
1370
+ }
1371
+ )
1372
+ ] })
1373
+ ] })
1374
+ ] });
1375
+ }
1376
+ const le = {
1377
+ id: "",
1378
+ name: "New Pipeline",
1379
+ sources: [],
1380
+ transformations: [],
1381
+ destinations: [],
1382
+ version: 1
1383
+ }, R = [
1384
+ { type: "filter", label: "Filter", icon: "🔍" },
1385
+ { type: "map", label: "Map", icon: "🔄" },
1386
+ { type: "aggregate", label: "Aggregate", icon: "∑" },
1387
+ { type: "join", label: "Join", icon: "🔗" },
1388
+ { type: "union", label: "Union", icon: "∪" },
1389
+ { type: "sort", label: "Sort", icon: "↕️" },
1390
+ { type: "deduplicate", label: "Deduplicate", icon: "🔲" },
1391
+ { type: "pivot", label: "Pivot", icon: "⤢" },
1392
+ { type: "unpivot", label: "Unpivot", icon: "⤡" },
1393
+ { type: "split", label: "Split", icon: "✂️" },
1394
+ { type: "merge", label: "Merge", icon: "🔀" },
1395
+ { type: "lookup", label: "Lookup", icon: "📖" },
1396
+ { type: "derive", label: "Derive Column", icon: "➕" },
1397
+ { type: "validate", label: "Validate", icon: "✓" },
1398
+ { type: "cleanse", label: "Cleanse", icon: "🧹" },
1399
+ { type: "custom", label: "Custom", icon: "ƒ" }
1400
+ ];
1401
+ function me({
1402
+ pipeline: i,
1403
+ dataSources: l = [],
1404
+ onChange: o,
1405
+ onRun: s,
1406
+ onSchedule: d,
1407
+ className: m = ""
1408
+ }) {
1409
+ const [a, y] = S(
1410
+ i || { ...le, id: crypto.randomUUID() }
1411
+ ), [r, v] = S(null), [_, p] = S("design"), [f, M] = S(!1), [T, L] = S([]), [b, D] = S(null), z = q(null), C = w(
1412
+ (c) => {
1413
+ y((N) => {
1414
+ const x = c(N);
1415
+ return o == null || o(x), x;
1416
+ });
1417
+ },
1418
+ [o]
1419
+ ), E = w(
1420
+ (c) => {
1421
+ var x;
1422
+ const N = {
1423
+ id: crypto.randomUUID(),
1424
+ type: c.type,
1425
+ name: c.name,
1426
+ config: c.config,
1427
+ schema: (x = c.schema) == null ? void 0 : x.tables[0]
1428
+ };
1429
+ C((I) => ({
1430
+ ...I,
1431
+ sources: [...I.sources, N]
1432
+ }));
1433
+ },
1434
+ [C]
1435
+ ), P = w(
1436
+ (c, N) => {
1437
+ var I;
1438
+ const x = {
1439
+ id: crypto.randomUUID(),
1440
+ type: c,
1441
+ name: ((I = R.find(($) => $.type === c)) == null ? void 0 : I.label) || c,
1442
+ input: [],
1443
+ output: crypto.randomUUID(),
1444
+ config: re(c)
1445
+ };
1446
+ C(($) => ({
1447
+ ...$,
1448
+ transformations: [...$.transformations, x]
1449
+ })), v({ type: "transformation", id: x.id });
1450
+ },
1451
+ [C]
1452
+ ), U = w(() => {
1453
+ const c = {
1454
+ id: crypto.randomUUID(),
1455
+ type: "database",
1456
+ name: "New Destination",
1457
+ config: {},
1458
+ writeMode: "append"
1459
+ };
1460
+ C((N) => ({
1461
+ ...N,
1462
+ destinations: [...N.destinations, c]
1463
+ })), v({ type: "destination", id: c.id });
1464
+ }, [C]), u = w(
1465
+ (c, N) => {
1466
+ C((x) => {
1467
+ switch (c) {
1468
+ case "source":
1469
+ return { ...x, sources: x.sources.filter((I) => I.id !== N) };
1470
+ case "transformation":
1471
+ return {
1472
+ ...x,
1473
+ transformations: x.transformations.filter((I) => I.id !== N)
1474
+ };
1475
+ case "destination":
1476
+ return { ...x, destinations: x.destinations.filter((I) => I.id !== N) };
1477
+ default:
1478
+ return x;
1479
+ }
1480
+ }), v(null);
1481
+ },
1482
+ [C]
1483
+ ), n = w(async () => {
1484
+ if (s) {
1485
+ M(!0);
1486
+ try {
1487
+ const c = await s(a);
1488
+ L((N) => [c, ...N].slice(0, 50));
1489
+ } finally {
1490
+ M(!1);
1491
+ }
1492
+ }
1493
+ }, [a, s]), h = w(
1494
+ (c) => {
1495
+ C((N) => ({ ...N, schedule: c })), d == null || d(a, c);
1496
+ },
1497
+ [a, C, d]
1498
+ ), g = w(
1499
+ (c) => {
1500
+ if (c.preventDefault(), !!b) {
1501
+ if (b.startsWith("transform:")) {
1502
+ const N = b.replace("transform:", "");
1503
+ P(N);
1504
+ }
1505
+ D(null);
1506
+ }
1507
+ },
1508
+ [b, P]
1509
+ ), k = () => {
1510
+ if (!r)
1511
+ return null;
1512
+ switch (r.type) {
1513
+ case "source":
1514
+ return a.sources.find((c) => c.id === r.id);
1515
+ case "transformation":
1516
+ return a.transformations.find((c) => c.id === r.id);
1517
+ case "destination":
1518
+ return a.destinations.find((c) => c.id === r.id);
1519
+ default:
1520
+ return null;
1521
+ }
1522
+ };
1523
+ return /* @__PURE__ */ t("div", { className: `nice-etl-builder ${m}`, children: [
1524
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__toolbar", children: [
1525
+ /* @__PURE__ */ e(
1526
+ "input",
1527
+ {
1528
+ type: "text",
1529
+ value: a.name,
1530
+ onChange: (c) => C((N) => ({ ...N, name: c.target.value })),
1531
+ className: "nice-etl-builder__name-input"
1532
+ }
1533
+ ),
1534
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__tabs", children: ["design", "code", "schedule", "history"].map((c) => /* @__PURE__ */ e(
1535
+ "button",
1536
+ {
1537
+ className: `nice-etl-builder__tab ${_ === c ? "nice-etl-builder__tab--active" : ""}`,
1538
+ onClick: () => p(c),
1539
+ children: c.charAt(0).toUpperCase() + c.slice(1)
1540
+ },
1541
+ c
1542
+ )) }),
1543
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__actions", children: [
1544
+ /* @__PURE__ */ e("button", { onClick: n, disabled: f, className: "nice-etl-builder__run-btn", children: f ? "⏳ Running..." : "▶ Run" }),
1545
+ /* @__PURE__ */ e("button", { className: "nice-etl-builder__save-btn", children: "💾 Save" })
1546
+ ] })
1547
+ ] }),
1548
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__main", children: [
1549
+ _ === "design" && /* @__PURE__ */ t("div", { className: "nice-etl-builder__palette", children: [
1550
+ /* @__PURE__ */ e("h4", { children: "Sources" }),
1551
+ l.map((c) => /* @__PURE__ */ t(
1552
+ "div",
1553
+ {
1554
+ className: "nice-etl-builder__palette-item",
1555
+ onClick: () => E(c),
1556
+ children: [
1557
+ /* @__PURE__ */ e("span", { className: "nice-etl-builder__palette-icon", children: "🗄️" }),
1558
+ /* @__PURE__ */ e("span", { children: c.name })
1559
+ ]
1560
+ },
1561
+ c.id
1562
+ )),
1563
+ /* @__PURE__ */ e(
1564
+ "button",
1565
+ {
1566
+ onClick: () => E({ id: "", name: "New Source", type: "database", config: {} }),
1567
+ children: "+ Add Source"
1568
+ }
1569
+ ),
1570
+ /* @__PURE__ */ e("h4", { children: "Transformations" }),
1571
+ R.map((c) => /* @__PURE__ */ t(
1572
+ "div",
1573
+ {
1574
+ className: "nice-etl-builder__palette-item",
1575
+ draggable: !0,
1576
+ onDragStart: () => D(`transform:${c.type}`),
1577
+ onDragEnd: () => D(null),
1578
+ children: [
1579
+ /* @__PURE__ */ e("span", { className: "nice-etl-builder__palette-icon", children: c.icon }),
1580
+ /* @__PURE__ */ e("span", { children: c.label })
1581
+ ]
1582
+ },
1583
+ c.type
1584
+ )),
1585
+ /* @__PURE__ */ e("h4", { children: "Destinations" }),
1586
+ /* @__PURE__ */ e("button", { onClick: U, children: "+ Add Destination" })
1587
+ ] }),
1588
+ _ === "design" && /* @__PURE__ */ e(
1589
+ "div",
1590
+ {
1591
+ ref: z,
1592
+ className: "nice-etl-builder__canvas",
1593
+ onDragOver: (c) => c.preventDefault(),
1594
+ onDrop: g,
1595
+ onClick: () => v(null),
1596
+ children: /* @__PURE__ */ t("div", { className: "nice-etl-builder__flow", children: [
1597
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__column", children: [
1598
+ /* @__PURE__ */ e("h5", { children: "Sources" }),
1599
+ a.sources.map((c) => /* @__PURE__ */ e(
1600
+ A,
1601
+ {
1602
+ node: c,
1603
+ nodeType: "source",
1604
+ icon: "🗄️",
1605
+ isSelected: (r == null ? void 0 : r.id) === c.id,
1606
+ onSelect: () => v({ type: "source", id: c.id }),
1607
+ onDelete: () => u("source", c.id)
1608
+ },
1609
+ c.id
1610
+ ))
1611
+ ] }),
1612
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__arrow", children: "→" }),
1613
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__column nice-etl-builder__column--transforms", children: [
1614
+ /* @__PURE__ */ e("h5", { children: "Transformations" }),
1615
+ a.transformations.map((c) => {
1616
+ const N = R.find((x) => x.type === c.type);
1617
+ return /* @__PURE__ */ e(
1618
+ A,
1619
+ {
1620
+ node: c,
1621
+ nodeType: "transformation",
1622
+ icon: (N == null ? void 0 : N.icon) || "🔄",
1623
+ isSelected: (r == null ? void 0 : r.id) === c.id,
1624
+ onSelect: () => v({ type: "transformation", id: c.id }),
1625
+ onDelete: () => u("transformation", c.id)
1626
+ },
1627
+ c.id
1628
+ );
1629
+ }),
1630
+ a.transformations.length === 0 && /* @__PURE__ */ e("div", { className: "nice-etl-builder__empty-column", children: "Drag transformations here" })
1631
+ ] }),
1632
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__arrow", children: "→" }),
1633
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__column", children: [
1634
+ /* @__PURE__ */ e("h5", { children: "Destinations" }),
1635
+ a.destinations.map((c) => /* @__PURE__ */ e(
1636
+ A,
1637
+ {
1638
+ node: c,
1639
+ nodeType: "destination",
1640
+ icon: "📥",
1641
+ isSelected: (r == null ? void 0 : r.id) === c.id,
1642
+ onSelect: () => v({ type: "destination", id: c.id }),
1643
+ onDelete: () => u("destination", c.id)
1644
+ },
1645
+ c.id
1646
+ ))
1647
+ ] })
1648
+ ] })
1649
+ }
1650
+ ),
1651
+ _ === "code" && /* @__PURE__ */ e("div", { className: "nice-etl-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(a, null, 2) }) }),
1652
+ _ === "schedule" && /* @__PURE__ */ e(
1653
+ oe,
1654
+ {
1655
+ schedule: a.schedule,
1656
+ monitoring: a.monitoring,
1657
+ onChange: h
1658
+ }
1659
+ ),
1660
+ _ === "history" && /* @__PURE__ */ e(de, { runs: T }),
1661
+ r && _ === "design" && /* @__PURE__ */ e(
1662
+ ce,
1663
+ {
1664
+ nodeType: r.type,
1665
+ node: k() ?? null,
1666
+ dataSources: l,
1667
+ onChange: (c) => {
1668
+ C((N) => {
1669
+ switch (r.type) {
1670
+ case "source":
1671
+ return {
1672
+ ...N,
1673
+ sources: N.sources.map(
1674
+ (x) => x.id === r.id ? { ...x, ...c } : x
1675
+ )
1676
+ };
1677
+ case "transformation":
1678
+ return {
1679
+ ...N,
1680
+ transformations: N.transformations.map(
1681
+ (x) => x.id === r.id ? { ...x, ...c } : x
1682
+ )
1683
+ };
1684
+ case "destination":
1685
+ return {
1686
+ ...N,
1687
+ destinations: N.destinations.map(
1688
+ (x) => x.id === r.id ? { ...x, ...c } : x
1689
+ )
1690
+ };
1691
+ default:
1692
+ return N;
1693
+ }
1694
+ });
1695
+ },
1696
+ onClose: () => v(null)
1697
+ }
1698
+ )
1699
+ ] })
1700
+ ] });
1701
+ }
1702
+ function re(i) {
1703
+ switch (i) {
1704
+ case "filter":
1705
+ return { condition: "" };
1706
+ case "map":
1707
+ return { mappings: [] };
1708
+ case "aggregate":
1709
+ return { groupBy: [], aggregations: [] };
1710
+ case "join":
1711
+ return { joinType: "inner", leftKey: "", rightKey: "" };
1712
+ case "union":
1713
+ return { inputs: [] };
1714
+ case "sort":
1715
+ return { columns: [], directions: [] };
1716
+ case "deduplicate":
1717
+ return { columns: [], keepFirst: !0 };
1718
+ case "pivot":
1719
+ return { pivotColumn: "", valueColumn: "", aggregation: "sum" };
1720
+ case "unpivot":
1721
+ return { columns: [], nameColumn: "name", valueColumn: "value" };
1722
+ case "derive":
1723
+ return { name: "", expression: "" };
1724
+ case "validate":
1725
+ return { rules: [] };
1726
+ case "cleanse":
1727
+ return { operations: [] };
1728
+ case "custom":
1729
+ return { code: `// Custom transformation
1730
+ return data;` };
1731
+ default:
1732
+ return {};
1733
+ }
1734
+ }
1735
+ function A({
1736
+ node: i,
1737
+ nodeType: l,
1738
+ icon: o,
1739
+ isSelected: s,
1740
+ onSelect: d,
1741
+ onDelete: m
1742
+ }) {
1743
+ return /* @__PURE__ */ t(
1744
+ "div",
1745
+ {
1746
+ className: `nice-etl-builder__node nice-etl-builder__node--${l} ${s ? "nice-etl-builder__node--selected" : ""}`,
1747
+ onClick: (a) => {
1748
+ a.stopPropagation(), d();
1749
+ },
1750
+ children: [
1751
+ /* @__PURE__ */ e("span", { className: "nice-etl-builder__node-icon", children: o }),
1752
+ /* @__PURE__ */ e("span", { className: "nice-etl-builder__node-name", children: i.name }),
1753
+ /* @__PURE__ */ e(
1754
+ "button",
1755
+ {
1756
+ className: "nice-etl-builder__node-delete",
1757
+ onClick: (a) => {
1758
+ a.stopPropagation(), m();
1759
+ },
1760
+ children: "×"
1761
+ }
1762
+ )
1763
+ ]
1764
+ }
1765
+ );
1766
+ }
1767
+ function ce({
1768
+ nodeType: i,
1769
+ node: l,
1770
+ dataSources: o,
1771
+ onChange: s,
1772
+ onClose: d
1773
+ }) {
1774
+ var m;
1775
+ return l ? /* @__PURE__ */ t("div", { className: "nice-etl-builder__properties", children: [
1776
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__properties-header", children: [
1777
+ /* @__PURE__ */ t("h4", { children: [
1778
+ i.charAt(0).toUpperCase() + i.slice(1),
1779
+ " Properties"
1780
+ ] }),
1781
+ /* @__PURE__ */ e("button", { onClick: d, children: "×" })
1782
+ ] }),
1783
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__properties-content", children: [
1784
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1785
+ /* @__PURE__ */ e("label", { children: "Name" }),
1786
+ /* @__PURE__ */ e(
1787
+ "input",
1788
+ {
1789
+ type: "text",
1790
+ value: l.name,
1791
+ onChange: (a) => s({ name: a.target.value })
1792
+ }
1793
+ )
1794
+ ] }),
1795
+ i === "source" && /* @__PURE__ */ t(F, { children: [
1796
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1797
+ /* @__PURE__ */ e("label", { children: "Type" }),
1798
+ /* @__PURE__ */ t(
1799
+ "select",
1800
+ {
1801
+ value: l.type,
1802
+ onChange: (a) => s({ type: a.target.value }),
1803
+ children: [
1804
+ /* @__PURE__ */ e("option", { value: "database", children: "Database" }),
1805
+ /* @__PURE__ */ e("option", { value: "api", children: "API" }),
1806
+ /* @__PURE__ */ e("option", { value: "file", children: "File" }),
1807
+ /* @__PURE__ */ e("option", { value: "stream", children: "Stream" })
1808
+ ]
1809
+ }
1810
+ )
1811
+ ] }),
1812
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__field", children: /* @__PURE__ */ t("label", { children: [
1813
+ /* @__PURE__ */ e(
1814
+ "input",
1815
+ {
1816
+ type: "checkbox",
1817
+ checked: ((m = l.incremental) == null ? void 0 : m.enabled) || !1,
1818
+ onChange: (a) => {
1819
+ var y;
1820
+ return s({
1821
+ incremental: {
1822
+ ...l.incremental,
1823
+ enabled: a.target.checked,
1824
+ column: ((y = l.incremental) == null ? void 0 : y.column) || ""
1825
+ }
1826
+ });
1827
+ }
1828
+ }
1829
+ ),
1830
+ "Incremental Load"
1831
+ ] }) })
1832
+ ] }),
1833
+ i === "transformation" && /* @__PURE__ */ t(F, { children: [
1834
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1835
+ /* @__PURE__ */ e("label", { children: "Type" }),
1836
+ /* @__PURE__ */ e("span", { children: l.type })
1837
+ ] }),
1838
+ l.type === "filter" && /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1839
+ /* @__PURE__ */ e("label", { children: "Condition" }),
1840
+ /* @__PURE__ */ e(
1841
+ "textarea",
1842
+ {
1843
+ value: String(l.config.condition || ""),
1844
+ onChange: (a) => s({
1845
+ config: { ...l.config, condition: a.target.value }
1846
+ }),
1847
+ placeholder: "e.g., age > 18 AND status = 'active'",
1848
+ rows: 3
1849
+ }
1850
+ )
1851
+ ] }),
1852
+ l.type === "derive" && /* @__PURE__ */ t(F, { children: [
1853
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1854
+ /* @__PURE__ */ e("label", { children: "Column Name" }),
1855
+ /* @__PURE__ */ e(
1856
+ "input",
1857
+ {
1858
+ type: "text",
1859
+ value: String(l.config.name || ""),
1860
+ onChange: (a) => s({
1861
+ config: { ...l.config, name: a.target.value }
1862
+ })
1863
+ }
1864
+ )
1865
+ ] }),
1866
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1867
+ /* @__PURE__ */ e("label", { children: "Expression" }),
1868
+ /* @__PURE__ */ e(
1869
+ "input",
1870
+ {
1871
+ type: "text",
1872
+ value: String(l.config.expression || ""),
1873
+ onChange: (a) => s({
1874
+ config: {
1875
+ ...l.config,
1876
+ expression: a.target.value
1877
+ }
1878
+ }),
1879
+ placeholder: "e.g., price * quantity"
1880
+ }
1881
+ )
1882
+ ] })
1883
+ ] }),
1884
+ l.type === "custom" && /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1885
+ /* @__PURE__ */ e("label", { children: "Code" }),
1886
+ /* @__PURE__ */ e(
1887
+ "textarea",
1888
+ {
1889
+ value: String(l.config.code || ""),
1890
+ onChange: (a) => s({
1891
+ config: { ...l.config, code: a.target.value }
1892
+ }),
1893
+ rows: 10,
1894
+ className: "nice-etl-builder__code-input"
1895
+ }
1896
+ )
1897
+ ] })
1898
+ ] }),
1899
+ i === "destination" && /* @__PURE__ */ t(F, { children: [
1900
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1901
+ /* @__PURE__ */ e("label", { children: "Type" }),
1902
+ /* @__PURE__ */ t(
1903
+ "select",
1904
+ {
1905
+ value: l.type,
1906
+ onChange: (a) => s({ type: a.target.value }),
1907
+ children: [
1908
+ /* @__PURE__ */ e("option", { value: "database", children: "Database" }),
1909
+ /* @__PURE__ */ e("option", { value: "file", children: "File" }),
1910
+ /* @__PURE__ */ e("option", { value: "api", children: "API" }),
1911
+ /* @__PURE__ */ e("option", { value: "warehouse", children: "Data Warehouse" })
1912
+ ]
1913
+ }
1914
+ )
1915
+ ] }),
1916
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1917
+ /* @__PURE__ */ e("label", { children: "Write Mode" }),
1918
+ /* @__PURE__ */ t(
1919
+ "select",
1920
+ {
1921
+ value: l.writeMode,
1922
+ onChange: (a) => s({ writeMode: a.target.value }),
1923
+ children: [
1924
+ /* @__PURE__ */ e("option", { value: "append", children: "Append" }),
1925
+ /* @__PURE__ */ e("option", { value: "overwrite", children: "Overwrite" }),
1926
+ /* @__PURE__ */ e("option", { value: "upsert", children: "Upsert" }),
1927
+ /* @__PURE__ */ e("option", { value: "merge", children: "Merge" })
1928
+ ]
1929
+ }
1930
+ )
1931
+ ] })
1932
+ ] })
1933
+ ] })
1934
+ ] }) : /* @__PURE__ */ e(F, {});
1935
+ }
1936
+ function oe({
1937
+ schedule: i,
1938
+ monitoring: l,
1939
+ onChange: o
1940
+ }) {
1941
+ const [s, d] = S(i || { enabled: !1 });
1942
+ return /* @__PURE__ */ t("div", { className: "nice-etl-builder__schedule-editor", children: [
1943
+ /* @__PURE__ */ e("h4", { children: "Schedule Configuration" }),
1944
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__field", children: /* @__PURE__ */ t("label", { children: [
1945
+ /* @__PURE__ */ e(
1946
+ "input",
1947
+ {
1948
+ type: "checkbox",
1949
+ checked: s.enabled,
1950
+ onChange: (m) => {
1951
+ const a = { ...s, enabled: m.target.checked };
1952
+ d(a), o(a);
1953
+ }
1954
+ }
1955
+ ),
1956
+ "Enable scheduled execution"
1957
+ ] }) }),
1958
+ s.enabled && /* @__PURE__ */ t(F, { children: [
1959
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1960
+ /* @__PURE__ */ e("label", { children: "Cron Expression" }),
1961
+ /* @__PURE__ */ e(
1962
+ "input",
1963
+ {
1964
+ type: "text",
1965
+ value: s.cron || "",
1966
+ onChange: (m) => {
1967
+ const a = { ...s, cron: m.target.value };
1968
+ d(a);
1969
+ },
1970
+ placeholder: "0 0 * * * (every hour)"
1971
+ }
1972
+ ),
1973
+ /* @__PURE__ */ e("small", { children: "Format: minute hour day month weekday" })
1974
+ ] }),
1975
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
1976
+ /* @__PURE__ */ e("label", { children: "Timezone" }),
1977
+ /* @__PURE__ */ t(
1978
+ "select",
1979
+ {
1980
+ value: s.timezone || "UTC",
1981
+ onChange: (m) => {
1982
+ const a = { ...s, timezone: m.target.value };
1983
+ d(a);
1984
+ },
1985
+ children: [
1986
+ /* @__PURE__ */ e("option", { value: "UTC", children: "UTC" }),
1987
+ /* @__PURE__ */ e("option", { value: "America/New_York", children: "Eastern Time" }),
1988
+ /* @__PURE__ */ e("option", { value: "America/Chicago", children: "Central Time" }),
1989
+ /* @__PURE__ */ e("option", { value: "America/Los_Angeles", children: "Pacific Time" }),
1990
+ /* @__PURE__ */ e("option", { value: "Europe/London", children: "London" }),
1991
+ /* @__PURE__ */ e("option", { value: "Europe/Warsaw", children: "Warsaw" })
1992
+ ]
1993
+ }
1994
+ )
1995
+ ] }),
1996
+ /* @__PURE__ */ e("button", { onClick: () => o(s), children: "Save Schedule" })
1997
+ ] }),
1998
+ /* @__PURE__ */ e("h4", { children: "Monitoring" }),
1999
+ /* @__PURE__ */ e("div", { className: "nice-etl-builder__field", children: /* @__PURE__ */ t("label", { children: [
2000
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: (l == null ? void 0 : l.alertOnFailure) || !1, disabled: !0 }),
2001
+ "Alert on failure"
2002
+ ] }) }),
2003
+ /* @__PURE__ */ t("div", { className: "nice-etl-builder__field", children: [
2004
+ /* @__PURE__ */ e("label", { children: "Log Level" }),
2005
+ /* @__PURE__ */ t("select", { value: (l == null ? void 0 : l.logLevel) || "info", disabled: !0, children: [
2006
+ /* @__PURE__ */ e("option", { value: "error", children: "Error" }),
2007
+ /* @__PURE__ */ e("option", { value: "warn", children: "Warning" }),
2008
+ /* @__PURE__ */ e("option", { value: "info", children: "Info" }),
2009
+ /* @__PURE__ */ e("option", { value: "debug", children: "Debug" })
2010
+ ] })
2011
+ ] })
2012
+ ] });
2013
+ }
2014
+ function de({ runs: i }) {
2015
+ return /* @__PURE__ */ t("div", { className: "nice-etl-builder__history-view", children: [
2016
+ /* @__PURE__ */ e("h4", { children: "Run History" }),
2017
+ i.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-etl-builder__no-history", children: "No runs yet" }) : /* @__PURE__ */ t("table", { className: "nice-etl-builder__history-table", children: [
2018
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
2019
+ /* @__PURE__ */ e("th", { children: "Status" }),
2020
+ /* @__PURE__ */ e("th", { children: "Start Time" }),
2021
+ /* @__PURE__ */ e("th", { children: "Duration" }),
2022
+ /* @__PURE__ */ e("th", { children: "Rows" }),
2023
+ /* @__PURE__ */ e("th", { children: "Errors" })
2024
+ ] }) }),
2025
+ /* @__PURE__ */ e("tbody", { children: i.map((l) => /* @__PURE__ */ t(
2026
+ "tr",
2027
+ {
2028
+ className: `nice-etl-builder__run nice-etl-builder__run--${l.status}`,
2029
+ children: [
2030
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ t(
2031
+ "span",
2032
+ {
2033
+ className: `nice-etl-builder__status nice-etl-builder__status--${l.status}`,
2034
+ children: [
2035
+ l.status === "success" ? "✓" : l.status === "failed" ? "✗" : "⏳",
2036
+ l.status
2037
+ ]
2038
+ }
2039
+ ) }),
2040
+ /* @__PURE__ */ e("td", { children: l.startTime.toLocaleString() }),
2041
+ /* @__PURE__ */ e("td", { children: l.endTime ? `${Math.round((l.endTime.getTime() - l.startTime.getTime()) / 1e3)}s` : "-" }),
2042
+ /* @__PURE__ */ t("td", { children: [
2043
+ l.rowsProcessed.toLocaleString(),
2044
+ " / ",
2045
+ l.rowsWritten.toLocaleString()
2046
+ ] }),
2047
+ /* @__PURE__ */ e("td", { children: l.errors.length })
2048
+ ]
2049
+ },
2050
+ l.id
2051
+ )) })
2052
+ ] })
2053
+ ] });
2054
+ }
2055
+ export {
2056
+ pe as NiceDashboardStudio,
2057
+ me as NiceETLBuilder,
2058
+ he as NiceReportBuilder
2059
+ };