@nice2dev/ui-enterprise 1.0.21 β†’ 1.0.22

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 CHANGED
@@ -1,3341 +1,10 @@
1
- import { jsxs as c, jsx as e, Fragment as re } from "react/jsx-runtime";
2
- import Me, { forwardRef as oe, useState as S, useCallback as _, useImperativeHandle as de, useEffect as fe, useRef as ge, useId as Ee, useMemo as pe } from "react";
3
- function je(i, t, l) {
4
- const n = l.csvDelimiter || ",", s = [];
5
- return l.includeHeaders !== !1 && s.push(
6
- t.filter((r) => r.include).map((r) => `"${r.label}"`).join(n)
7
- ), i.forEach((r) => {
8
- const h = t.filter((o) => o.include).map((o) => {
9
- let m = r[o.field];
10
- return o.transform && (m = o.transform(m)), m == null ? "" : typeof m == "string" ? `"${m.replace(/"/g, '""')}"` : String(m);
11
- });
12
- s.push(h.join(n));
13
- }), s.join(`
14
- `);
15
- }
16
- function Ue(i, t, l) {
17
- const n = t.filter((r) => r.include), s = i.map((r) => {
18
- const h = {};
19
- return n.forEach((o) => {
20
- let m = r[o.field];
21
- o.transform && (m = o.transform(m)), h[o.field] = m;
22
- }), h;
23
- });
24
- return JSON.stringify(s, null, 2);
25
- }
26
- const we = {
27
- csv: { label: "CSV", icon: "πŸ“„", description: "Comma-separated values" },
28
- xlsx: { label: "Excel", icon: "πŸ“Š", description: "Microsoft Excel" },
29
- json: { label: "JSON", icon: "{ }", description: "JavaScript Object Notation" },
30
- pdf: { label: "PDF", icon: "πŸ“•", description: "Portable Document Format" },
31
- xml: { label: "XML", icon: "πŸ“‹", description: "Extensible Markup Language" }
32
- }, Ye = ({ formats: i, selected: t, onChange: l }) => /* @__PURE__ */ e("div", { className: "nice-export-formats", children: i.map((n) => {
33
- const s = we[n];
34
- return /* @__PURE__ */ c(
35
- "button",
36
- {
37
- type: "button",
38
- className: `nice-export-format ${t === n ? "nice-export-format--selected" : ""}`,
39
- onClick: () => l(n),
40
- title: s.description,
41
- children: [
42
- /* @__PURE__ */ e("span", { className: "nice-export-format-icon", children: s.icon }),
43
- /* @__PURE__ */ e("span", { className: "nice-export-format-label", children: s.label })
44
- ]
45
- },
46
- n
47
- );
48
- }) }), qe = ({ fields: i, onChange: t }) => {
49
- const l = (r) => {
50
- const h = [...i];
51
- h[r] = { ...h[r], include: !h[r].include }, t(h);
52
- }, n = (r) => {
53
- t(i.map((h) => ({ ...h, include: r })));
54
- }, s = i.filter((r) => r.include).length;
55
- return /* @__PURE__ */ c("div", { className: "nice-export-fields", children: [
56
- /* @__PURE__ */ c("div", { className: "nice-export-fields-header", children: [
57
- /* @__PURE__ */ c("span", { children: [
58
- "Fields to export (",
59
- s,
60
- "/",
61
- i.length,
62
- ")"
63
- ] }),
64
- /* @__PURE__ */ c("div", { className: "nice-export-fields-actions", children: [
65
- /* @__PURE__ */ e("button", { type: "button", onClick: () => n(!0), children: "Select all" }),
66
- /* @__PURE__ */ e("button", { type: "button", onClick: () => n(!1), children: "Deselect all" })
67
- ] })
68
- ] }),
69
- /* @__PURE__ */ e("div", { className: "nice-export-fields-list", children: i.map((r, h) => /* @__PURE__ */ c("label", { className: "nice-export-field", children: [
70
- /* @__PURE__ */ e("input", { type: "checkbox", checked: r.include, onChange: () => l(h) }),
71
- /* @__PURE__ */ e("span", { className: "nice-export-field-label", children: r.label }),
72
- /* @__PURE__ */ e("span", { className: "nice-export-field-name", children: r.field })
73
- ] }, r.field)) })
74
- ] });
75
- }, Ve = ({ format: i, options: t, onChange: l }) => {
76
- const n = (s, r) => {
77
- l({ ...t, [s]: r });
78
- };
79
- return /* @__PURE__ */ c("div", { className: "nice-export-options", children: [
80
- /* @__PURE__ */ e("h4", { children: "Export Options" }),
81
- /* @__PURE__ */ c("label", { className: "nice-export-option", children: [
82
- /* @__PURE__ */ e(
83
- "input",
84
- {
85
- type: "checkbox",
86
- checked: t.includeHeaders !== !1,
87
- onChange: (s) => n("includeHeaders", s.target.checked)
88
- }
89
- ),
90
- "Include headers"
91
- ] }),
92
- i === "csv" && /* @__PURE__ */ c("label", { className: "nice-export-option", children: [
93
- /* @__PURE__ */ e("span", { children: "Delimiter:" }),
94
- /* @__PURE__ */ c(
95
- "select",
96
- {
97
- value: t.csvDelimiter || ",",
98
- onChange: (s) => n("csvDelimiter", s.target.value),
99
- children: [
100
- /* @__PURE__ */ e("option", { value: ",", children: "Comma (,)" }),
101
- /* @__PURE__ */ e("option", { value: ";", children: "Semicolon (;)" }),
102
- /* @__PURE__ */ e("option", { value: "\\t", children: "Tab" }),
103
- /* @__PURE__ */ e("option", { value: "|", children: "Pipe (|)" })
104
- ]
105
- }
106
- )
107
- ] }),
108
- /* @__PURE__ */ c("label", { className: "nice-export-option", children: [
109
- /* @__PURE__ */ e("span", { children: "Date format:" }),
110
- /* @__PURE__ */ c(
111
- "select",
112
- {
113
- value: t.dateFormat || "YYYY-MM-DD",
114
- onChange: (s) => n("dateFormat", s.target.value),
115
- children: [
116
- /* @__PURE__ */ e("option", { value: "YYYY-MM-DD", children: "YYYY-MM-DD" }),
117
- /* @__PURE__ */ e("option", { value: "DD/MM/YYYY", children: "DD/MM/YYYY" }),
118
- /* @__PURE__ */ e("option", { value: "MM/DD/YYYY", children: "MM/DD/YYYY" }),
119
- /* @__PURE__ */ e("option", { value: "ISO", children: "ISO 8601" })
120
- ]
121
- }
122
- )
123
- ] }),
124
- /* @__PURE__ */ c("label", { className: "nice-export-option", children: [
125
- /* @__PURE__ */ e("span", { children: "Encoding:" }),
126
- /* @__PURE__ */ c(
127
- "select",
128
- {
129
- value: t.encoding || "utf-8",
130
- onChange: (s) => n("encoding", s.target.value),
131
- children: [
132
- /* @__PURE__ */ e("option", { value: "utf-8", children: "UTF-8" }),
133
- /* @__PURE__ */ e("option", { value: "utf-16", children: "UTF-16" }),
134
- /* @__PURE__ */ e("option", { value: "iso-8859-1", children: "ISO-8859-1" })
135
- ]
136
- }
137
- )
138
- ] }),
139
- (i === "xlsx" || i === "pdf") && /* @__PURE__ */ c("label", { className: "nice-export-option", children: [
140
- /* @__PURE__ */ e("span", { children: "Password protect:" }),
141
- /* @__PURE__ */ e(
142
- "input",
143
- {
144
- type: "password",
145
- value: t.password || "",
146
- onChange: (s) => n("password", s.target.value || void 0),
147
- placeholder: "Leave empty for no password"
148
- }
149
- )
150
- ] })
151
- ] });
152
- }, Be = ({ jobs: i, onDownload: t }) => {
153
- if (i.length === 0)
154
- return /* @__PURE__ */ e("div", { className: "nice-export-history-empty", children: "No export history" });
155
- const l = (n) => n ? n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1024 / 1024).toFixed(1)} MB` : "-";
156
- return /* @__PURE__ */ c("div", { className: "nice-export-history", children: [
157
- /* @__PURE__ */ e("h4", { children: "Export History" }),
158
- /* @__PURE__ */ e("div", { className: "nice-export-history-list", children: i.map((n) => /* @__PURE__ */ c("div", { className: `nice-export-job nice-export-job--${n.status}`, children: [
159
- /* @__PURE__ */ c("div", { className: "nice-export-job-info", children: [
160
- /* @__PURE__ */ e("span", { className: "nice-export-job-name", children: n.name }),
161
- /* @__PURE__ */ e("span", { className: "nice-export-job-format", children: n.format.toUpperCase() }),
162
- /* @__PURE__ */ e("span", { className: "nice-export-job-date", children: new Date(n.createdAt).toLocaleString() })
163
- ] }),
164
- /* @__PURE__ */ c("div", { className: "nice-export-job-meta", children: [
165
- n.rowCount && /* @__PURE__ */ c("span", { children: [
166
- n.rowCount,
167
- " rows"
168
- ] }),
169
- n.fileSize && /* @__PURE__ */ e("span", { children: l(n.fileSize) })
170
- ] }),
171
- /* @__PURE__ */ c("div", { className: "nice-export-job-status", children: [
172
- n.status === "processing" && /* @__PURE__ */ e("div", { className: "nice-export-job-progress", children: /* @__PURE__ */ e(
173
- "div",
174
- {
175
- className: "nice-export-job-progress-bar",
176
- style: { width: `${n.progress}%` }
177
- }
178
- ) }),
179
- n.status === "completed" && n.downloadUrl && /* @__PURE__ */ e(
180
- "button",
181
- {
182
- type: "button",
183
- className: "nice-export-job-download",
184
- onClick: () => t == null ? void 0 : t(n),
185
- children: "Download"
186
- }
187
- ),
188
- n.status === "failed" && /* @__PURE__ */ e("span", { className: "nice-export-job-error", title: n.error, children: "Failed" })
189
- ] })
190
- ] }, n.id)) })
191
- ] });
192
- }, ze = oe(
193
- ({
194
- dataSource: i,
195
- formats: t = ["csv", "xlsx", "json", "pdf"],
196
- templates: l = [],
197
- enableScheduling: n = !1,
198
- exportHistory: s = [],
199
- onExportStart: r,
200
- onExportComplete: h,
201
- onExportError: o,
202
- onSaveTemplate: m,
203
- onDeleteTemplate: O,
204
- onSchedule: G,
205
- customExportHandler: N,
206
- title: C = "Data Export",
207
- description: U,
208
- className: P = "",
209
- style: X
210
- }, q) => {
211
- const [W, V] = S(t[0]), [B, v] = S(i.getFields()), [I, g] = S({
212
- includeHeaders: !0,
213
- dateFormat: "YYYY-MM-DD",
214
- encoding: "utf-8"
215
- }), [k, Y] = S(!1), [b, M] = S(0), [E, $] = S("export"), j = _(async () => {
216
- const f = {
217
- id: Date.now().toString(),
218
- name: `Export ${(/* @__PURE__ */ new Date()).toISOString()}`,
219
- format: W,
220
- status: "processing",
221
- progress: 0,
222
- createdAt: /* @__PURE__ */ new Date()
223
- };
224
- Y(!0), M(0), r == null || r(f);
225
- try {
226
- const R = await i.fetchData({
227
- fields: B,
228
- filters: void 0,
229
- sorting: void 0
230
- });
231
- M(50);
232
- let L;
233
- if (N)
234
- L = await N(W, R, I);
235
- else
236
- switch (W) {
237
- case "csv":
238
- L = je(R, B, I);
239
- break;
240
- case "json":
241
- L = Ue(R, B, I);
242
- break;
243
- default:
244
- throw new Error(`Format ${W} requires a custom export handler`);
245
- }
246
- M(100);
247
- const Z = typeof L == "string" ? new Blob([L], { type: "text/plain" }) : L, F = URL.createObjectURL(Z), y = document.createElement("a");
248
- y.href = F, y.download = `export-${Date.now()}.${W}`, document.body.appendChild(y), y.click(), document.body.removeChild(y), URL.revokeObjectURL(F);
249
- const u = {
250
- ...f,
251
- status: "completed",
252
- progress: 100,
253
- completedAt: /* @__PURE__ */ new Date(),
254
- rowCount: R.length,
255
- fileSize: Z.size
256
- };
257
- h == null || h(u);
258
- } catch (R) {
259
- const L = {
260
- ...f,
261
- status: "failed",
262
- error: R instanceof Error ? R.message : "Unknown error"
263
- };
264
- o == null || o(L, R instanceof Error ? R : new Error("Export failed"));
265
- } finally {
266
- Y(!1), M(0);
267
- }
268
- }, [
269
- W,
270
- B,
271
- I,
272
- i,
273
- N,
274
- r,
275
- h,
276
- o
277
- ]), K = _(
278
- (f) => {
279
- const R = l.find((L) => L.id === f);
280
- R && (V(R.format), v(R.fields), R.options && g(R.options));
281
- },
282
- [l]
283
- );
284
- return de(q, () => ({
285
- exportNow: async (f) => {
286
- V(f), await j();
287
- },
288
- getSelectedFields: () => B,
289
- loadTemplate: K
290
- })), /* @__PURE__ */ c("div", { className: `nice-export-center ${P}`, style: X, children: [
291
- /* @__PURE__ */ e("div", { className: "nice-export-header", children: /* @__PURE__ */ c("div", { className: "nice-export-title-area", children: [
292
- /* @__PURE__ */ e("h3", { className: "nice-export-title", children: C }),
293
- U && /* @__PURE__ */ e("p", { className: "nice-export-description", children: U })
294
- ] }) }),
295
- /* @__PURE__ */ c("div", { className: "nice-export-tabs", children: [
296
- /* @__PURE__ */ e(
297
- "button",
298
- {
299
- type: "button",
300
- className: `nice-export-tab ${E === "export" ? "nice-export-tab--active" : ""}`,
301
- onClick: () => $("export"),
302
- children: "Export"
303
- }
304
- ),
305
- l.length > 0 && /* @__PURE__ */ c(
306
- "button",
307
- {
308
- type: "button",
309
- className: `nice-export-tab ${E === "templates" ? "nice-export-tab--active" : ""}`,
310
- onClick: () => $("templates"),
311
- children: [
312
- "Templates (",
313
- l.length,
314
- ")"
315
- ]
316
- }
317
- ),
318
- s.length > 0 && /* @__PURE__ */ e(
319
- "button",
320
- {
321
- type: "button",
322
- className: `nice-export-tab ${E === "history" ? "nice-export-tab--active" : ""}`,
323
- onClick: () => $("history"),
324
- children: "History"
325
- }
326
- )
327
- ] }),
328
- /* @__PURE__ */ c("div", { className: "nice-export-content", children: [
329
- E === "export" && /* @__PURE__ */ c(re, { children: [
330
- /* @__PURE__ */ e(
331
- Ye,
332
- {
333
- formats: t,
334
- selected: W,
335
- onChange: V
336
- }
337
- ),
338
- /* @__PURE__ */ e(qe, { fields: B, onChange: v }),
339
- /* @__PURE__ */ e(Ve, { format: W, options: I, onChange: g }),
340
- /* @__PURE__ */ c("div", { className: "nice-export-actions", children: [
341
- /* @__PURE__ */ e(
342
- "button",
343
- {
344
- type: "button",
345
- className: "nice-export-btn nice-export-btn--primary",
346
- onClick: j,
347
- disabled: k || B.filter((f) => f.include).length === 0,
348
- children: k ? `Exporting... ${b}%` : "Export Now"
349
- }
350
- ),
351
- m && /* @__PURE__ */ e(
352
- "button",
353
- {
354
- type: "button",
355
- className: "nice-export-btn nice-export-btn--secondary",
356
- onClick: () => m({
357
- id: Date.now().toString(),
358
- name: `Template ${l.length + 1}`,
359
- format: W,
360
- fields: B,
361
- options: I
362
- }),
363
- children: "Save as Template"
364
- }
365
- )
366
- ] })
367
- ] }),
368
- E === "templates" && /* @__PURE__ */ e("div", { className: "nice-export-templates", children: l.map((f) => /* @__PURE__ */ c("div", { className: "nice-export-template", children: [
369
- /* @__PURE__ */ c("div", { className: "nice-export-template-info", children: [
370
- /* @__PURE__ */ e("span", { className: "nice-export-template-name", children: f.name }),
371
- /* @__PURE__ */ c("span", { className: "nice-export-template-format", children: [
372
- we[f.format].icon,
373
- " ",
374
- we[f.format].label
375
- ] }),
376
- f.description && /* @__PURE__ */ e("span", { className: "nice-export-template-desc", children: f.description })
377
- ] }),
378
- /* @__PURE__ */ c("div", { className: "nice-export-template-actions", children: [
379
- /* @__PURE__ */ e(
380
- "button",
381
- {
382
- type: "button",
383
- onClick: () => {
384
- K(f.id), $("export");
385
- },
386
- children: "Use"
387
- }
388
- ),
389
- O && /* @__PURE__ */ e("button", { type: "button", onClick: () => O(f.id), children: "Delete" })
390
- ] })
391
- ] }, f.id)) }),
392
- E === "history" && /* @__PURE__ */ e(
393
- Be,
394
- {
395
- jobs: s,
396
- onDownload: (f) => {
397
- f.downloadUrl && window.open(f.downloadUrl, "_blank");
398
- }
399
- }
400
- )
401
- ] })
402
- ] });
403
- }
404
- );
405
- ze.displayName = "NiceDataExportCenter";
406
- const ue = {
407
- create: { icon: "+", label: "Created", color: "var(--color-success, #10b981)" },
408
- update: { icon: "✎", label: "Updated", color: "var(--color-primary, #3b82f6)" },
409
- delete: { icon: "Γ—", label: "Deleted", color: "var(--color-error, #ef4444)" },
410
- view: { icon: "πŸ‘", label: "Viewed", color: "var(--text-muted, #6b7280)" },
411
- export: { icon: "↓", label: "Exported", color: "var(--color-accent, #8b5cf6)" },
412
- import: { icon: "↑", label: "Imported", color: "var(--color-accent, #8b5cf6)" },
413
- approve: { icon: "βœ“", label: "Approved", color: "var(--color-success, #10b981)" },
414
- reject: { icon: "βœ—", label: "Rejected", color: "var(--color-error, #ef4444)" },
415
- login: { icon: "β†’", label: "Login", color: "var(--color-success, #10b981)" },
416
- logout: { icon: "←", label: "Logout", color: "var(--text-muted, #6b7280)" },
417
- permission_change: { icon: "πŸ”", label: "Permissions", color: "var(--color-warning, #f59e0b)" },
418
- config_change: { icon: "βš™", label: "Config", color: "var(--color-warning, #f59e0b)" },
419
- custom: { icon: "β€’", label: "Action", color: "var(--text-muted, #6b7280)" }
420
- }, He = ({
421
- filter: i,
422
- onChange: t,
423
- availableFilters: l
424
- }) => {
425
- var s, r;
426
- const n = (h, o) => {
427
- t({ ...i, [h]: o });
428
- };
429
- return /* @__PURE__ */ c("div", { className: "nice-audit-filters", children: [
430
- /* @__PURE__ */ c("div", { className: "nice-audit-filter-group", children: [
431
- /* @__PURE__ */ e("label", { children: "Date Range" }),
432
- /* @__PURE__ */ c("div", { className: "nice-audit-date-range", children: [
433
- /* @__PURE__ */ e(
434
- "input",
435
- {
436
- type: "date",
437
- value: ((s = i.startDate) == null ? void 0 : s.toISOString().split("T")[0]) || "",
438
- onChange: (h) => n("startDate", h.target.value ? new Date(h.target.value) : void 0)
439
- }
440
- ),
441
- /* @__PURE__ */ e("span", { children: "to" }),
442
- /* @__PURE__ */ e(
443
- "input",
444
- {
445
- type: "date",
446
- value: ((r = i.endDate) == null ? void 0 : r.toISOString().split("T")[0]) || "",
447
- onChange: (h) => n("endDate", h.target.value ? new Date(h.target.value) : void 0)
448
- }
449
- )
450
- ] })
451
- ] }),
452
- /* @__PURE__ */ c("div", { className: "nice-audit-filter-group", children: [
453
- /* @__PURE__ */ e("label", { children: "Actions" }),
454
- /* @__PURE__ */ e("div", { className: "nice-audit-action-chips", children: Object.keys(ue).slice(0, 8).map((h) => {
455
- var O;
456
- const o = ue[h], m = (O = i.actions) == null ? void 0 : O.includes(h);
457
- return /* @__PURE__ */ c(
458
- "button",
459
- {
460
- type: "button",
461
- className: `nice-audit-chip ${m ? "nice-audit-chip--selected" : ""}`,
462
- style: { "--chip-color": o.color },
463
- onClick: () => {
464
- const G = i.actions || [];
465
- n(
466
- "actions",
467
- m ? G.filter((N) => N !== h) : [...G, h]
468
- );
469
- },
470
- children: [
471
- /* @__PURE__ */ e("span", { className: "nice-audit-chip-icon", children: o.icon }),
472
- o.label
473
- ]
474
- },
475
- h
476
- );
477
- }) })
478
- ] }),
479
- /* @__PURE__ */ c("div", { className: "nice-audit-filter-group", children: [
480
- /* @__PURE__ */ e("label", { children: "Search" }),
481
- /* @__PURE__ */ e(
482
- "input",
483
- {
484
- type: "text",
485
- className: "nice-audit-search",
486
- placeholder: "Search entries...",
487
- value: i.searchQuery || "",
488
- onChange: (h) => n("searchQuery", h.target.value || void 0)
489
- }
490
- )
491
- ] })
492
- ] });
493
- }, Je = ({ changes: i }) => {
494
- if (!i.length)
495
- return null;
496
- const t = (l, n) => n || (l == null ? "(empty)" : typeof l == "object" ? JSON.stringify(l, null, 2) : String(l));
497
- return /* @__PURE__ */ e("div", { className: "nice-audit-diff", children: i.map((l, n) => /* @__PURE__ */ c("div", { className: "nice-audit-diff-row", children: [
498
- /* @__PURE__ */ e("span", { className: "nice-audit-diff-field", children: l.field }),
499
- /* @__PURE__ */ c("div", { className: "nice-audit-diff-values", children: [
500
- /* @__PURE__ */ e("span", { className: "nice-audit-diff-old", children: t(l.oldValue, l.displayOldValue) }),
501
- /* @__PURE__ */ e("span", { className: "nice-audit-diff-arrow", children: "β†’" }),
502
- /* @__PURE__ */ e("span", { className: "nice-audit-diff-new", children: t(l.newValue, l.displayNewValue) })
503
- ] })
504
- ] }, n)) });
505
- }, Ge = ({
506
- entry: i,
507
- showDiff: t,
508
- renderActionIcon: l,
509
- renderUser: n,
510
- onClick: s
511
- }) => {
512
- const [r, h] = S(!1), o = ue[i.action] || ue.custom;
513
- return /* @__PURE__ */ c(
514
- "div",
515
- {
516
- className: `nice-audit-timeline-entry nice-audit-timeline-entry--${i.severity || "info"}`,
517
- onClick: s,
518
- role: s ? "button" : void 0,
519
- tabIndex: s ? 0 : void 0,
520
- children: [
521
- /* @__PURE__ */ e(
522
- "div",
523
- {
524
- className: "nice-audit-timeline-marker",
525
- style: { "--marker-color": o.color },
526
- children: l ? l(i.action) : o.icon
527
- }
528
- ),
529
- /* @__PURE__ */ c("div", { className: "nice-audit-timeline-content", children: [
530
- /* @__PURE__ */ c("div", { className: "nice-audit-timeline-header", children: [
531
- /* @__PURE__ */ e("span", { className: "nice-audit-timeline-action", children: i.actionLabel || o.label }),
532
- /* @__PURE__ */ c("span", { className: "nice-audit-timeline-entity", children: [
533
- i.entityType,
534
- " ",
535
- i.entityName && `"${i.entityName}"`
536
- ] }),
537
- /* @__PURE__ */ e("span", { className: "nice-audit-timeline-time", children: new Date(i.timestamp).toLocaleString() })
538
- ] }),
539
- /* @__PURE__ */ e("div", { className: "nice-audit-timeline-user", children: n ? n(i) : /* @__PURE__ */ c(re, { children: [
540
- i.userAvatar && /* @__PURE__ */ e("img", { src: i.userAvatar, alt: "", className: "nice-audit-avatar" }),
541
- /* @__PURE__ */ e("span", { className: "nice-audit-username", children: i.userName }),
542
- i.userRole && /* @__PURE__ */ e("span", { className: "nice-audit-role", children: i.userRole })
543
- ] }) }),
544
- i.notes && /* @__PURE__ */ e("div", { className: "nice-audit-timeline-notes", children: i.notes }),
545
- t && i.changes && i.changes.length > 0 && /* @__PURE__ */ c(re, { children: [
546
- /* @__PURE__ */ e(
547
- "button",
548
- {
549
- type: "button",
550
- className: "nice-audit-expand-btn",
551
- onClick: (m) => {
552
- m.stopPropagation(), h(!r);
553
- },
554
- children: r ? "β–Ό Hide changes" : `β–Ά Show ${i.changes.length} changes`
555
- }
556
- ),
557
- r && /* @__PURE__ */ e(Je, { changes: i.changes })
558
- ] }),
559
- i.ipAddress && /* @__PURE__ */ c("div", { className: "nice-audit-timeline-meta", children: [
560
- /* @__PURE__ */ c("span", { children: [
561
- "IP: ",
562
- i.ipAddress
563
- ] }),
564
- i.location && /* @__PURE__ */ c("span", { children: [
565
- "β€’ ",
566
- i.location
567
- ] })
568
- ] })
569
- ] })
570
- ]
571
- }
572
- );
573
- }, We = ({ entries: i, showDiff: t, onEntryClick: l }) => /* @__PURE__ */ c("table", { className: "nice-audit-table", children: [
574
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ c("tr", { children: [
575
- /* @__PURE__ */ e("th", { children: "Timestamp" }),
576
- /* @__PURE__ */ e("th", { children: "Action" }),
577
- /* @__PURE__ */ e("th", { children: "User" }),
578
- /* @__PURE__ */ e("th", { children: "Entity" }),
579
- /* @__PURE__ */ e("th", { children: "Changes" }),
580
- /* @__PURE__ */ e("th", { children: "IP Address" })
581
- ] }) }),
582
- /* @__PURE__ */ e("tbody", { children: i.map((n) => {
583
- const s = ue[n.action] || ue.custom;
584
- return /* @__PURE__ */ c(
585
- "tr",
586
- {
587
- className: `nice-audit-row nice-audit-row--${n.severity || "info"}`,
588
- onClick: () => l == null ? void 0 : l(n),
589
- role: l ? "button" : void 0,
590
- children: [
591
- /* @__PURE__ */ e("td", { className: "nice-audit-cell-time", children: new Date(n.timestamp).toLocaleString() }),
592
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ c(
593
- "span",
594
- {
595
- className: "nice-audit-action-badge",
596
- style: { "--badge-color": s.color },
597
- children: [
598
- s.icon,
599
- " ",
600
- n.actionLabel || s.label
601
- ]
602
- }
603
- ) }),
604
- /* @__PURE__ */ c("td", { className: "nice-audit-cell-user", children: [
605
- n.userAvatar && /* @__PURE__ */ e("img", { src: n.userAvatar, alt: "", className: "nice-audit-avatar-sm" }),
606
- n.userName
607
- ] }),
608
- /* @__PURE__ */ c("td", { children: [
609
- n.entityType,
610
- n.entityName && `: ${n.entityName}`
611
- ] }),
612
- /* @__PURE__ */ e("td", { children: n.changes && n.changes.length > 0 ? /* @__PURE__ */ c("span", { className: "nice-audit-changes-count", children: [
613
- n.changes.length,
614
- " field(s)"
615
- ] }) : "-" }),
616
- /* @__PURE__ */ e("td", { className: "nice-audit-cell-ip", children: n.ipAddress || "-" })
617
- ]
618
- },
619
- n.id
620
- );
621
- }) })
622
- ] }), Ke = oe(
623
- ({
624
- dataSource: i,
625
- initialFilter: t = {},
626
- pageSize: l = 50,
627
- viewMode: n = "timeline",
628
- enableExport: s = !0,
629
- showDiffs: r = !0,
630
- renderActionIcon: h,
631
- renderUser: o,
632
- onEntryClick: m,
633
- onExport: O,
634
- title: G = "Audit Trail",
635
- className: N = "",
636
- style: C
637
- }, U) => {
638
- const [P, X] = S([]), [q, W] = S(0), [V, B] = S(t), [v, I] = S(1), [g, k] = S(!1), [Y, b] = S(n), [M, E] = S(!1), $ = _(async () => {
639
- k(!0);
640
- try {
641
- const f = await i.fetchEntries(V, { page: v, pageSize: l });
642
- X(f.entries), W(f.totalCount);
643
- } finally {
644
- k(!1);
645
- }
646
- }, [i, V, v, l]);
647
- Me.useEffect(() => {
648
- $();
649
- }, [$]);
650
- const j = _(
651
- (f) => {
652
- if (O)
653
- O(P, f);
654
- else {
655
- let R, L;
656
- if (f === "json")
657
- R = JSON.stringify(P, null, 2), L = "application/json";
658
- else {
659
- const u = [
660
- "Timestamp",
661
- "Action",
662
- "User",
663
- "Entity Type",
664
- "Entity",
665
- "IP",
666
- "Changes"
667
- ], w = P.map((x) => {
668
- var z;
669
- return [
670
- new Date(x.timestamp).toISOString(),
671
- x.action,
672
- x.userName,
673
- x.entityType,
674
- x.entityName || x.entityId,
675
- x.ipAddress || "",
676
- ((z = x.changes) == null ? void 0 : z.length) || 0
677
- ];
678
- });
679
- R = [u.join(","), ...w.map((x) => x.join(","))].join(`
680
- `), L = "text/csv";
681
- }
682
- const Z = new Blob([R], { type: L }), F = URL.createObjectURL(Z), y = document.createElement("a");
683
- y.href = F, y.download = `audit-trail-${Date.now()}.${f}`, y.click(), URL.revokeObjectURL(F);
684
- }
685
- },
686
- [P, O]
687
- );
688
- de(U, () => ({
689
- refresh: $,
690
- setFilter: (f) => {
691
- B(f), I(1);
692
- },
693
- getEntries: () => P
694
- }));
695
- const K = Math.ceil(q / l);
696
- return /* @__PURE__ */ c("div", { className: `nice-audit-trail ${N}`, style: C, children: [
697
- /* @__PURE__ */ c("div", { className: "nice-audit-header", children: [
698
- /* @__PURE__ */ e("h3", { className: "nice-audit-title", children: G }),
699
- /* @__PURE__ */ c("div", { className: "nice-audit-header-actions", children: [
700
- /* @__PURE__ */ e(
701
- "button",
702
- {
703
- type: "button",
704
- className: `nice-audit-view-btn ${Y === "timeline" ? "nice-audit-view-btn--active" : ""}`,
705
- onClick: () => b("timeline"),
706
- title: "Timeline view",
707
- children: "≑"
708
- }
709
- ),
710
- /* @__PURE__ */ e(
711
- "button",
712
- {
713
- type: "button",
714
- className: `nice-audit-view-btn ${Y === "table" ? "nice-audit-view-btn--active" : ""}`,
715
- onClick: () => b("table"),
716
- title: "Table view",
717
- children: "⊞"
718
- }
719
- ),
720
- /* @__PURE__ */ e(
721
- "button",
722
- {
723
- type: "button",
724
- className: `nice-audit-filter-btn ${M ? "nice-audit-filter-btn--active" : ""}`,
725
- onClick: () => E(!M),
726
- children: "πŸ” Filter"
727
- }
728
- ),
729
- s && /* @__PURE__ */ c("div", { className: "nice-audit-export-dropdown", children: [
730
- /* @__PURE__ */ e("button", { type: "button", className: "nice-audit-export-btn", children: "↓ Export" }),
731
- /* @__PURE__ */ c("div", { className: "nice-audit-export-menu", children: [
732
- /* @__PURE__ */ e("button", { type: "button", onClick: () => j("csv"), children: "Export as CSV" }),
733
- /* @__PURE__ */ e("button", { type: "button", onClick: () => j("json"), children: "Export as JSON" })
734
- ] })
735
- ] })
736
- ] })
737
- ] }),
738
- M && /* @__PURE__ */ e(He, { filter: V, onChange: B }),
739
- /* @__PURE__ */ c("div", { className: "nice-audit-stats", children: [
740
- /* @__PURE__ */ c("span", { children: [
741
- "Showing ",
742
- P.length,
743
- " of ",
744
- q,
745
- " entries"
746
- ] }),
747
- V.startDate && V.endDate && /* @__PURE__ */ c("span", { className: "nice-audit-date-indicator", children: [
748
- V.startDate.toLocaleDateString(),
749
- " - ",
750
- V.endDate.toLocaleDateString()
751
- ] })
752
- ] }),
753
- /* @__PURE__ */ c("div", { className: `nice-audit-content ${g ? "nice-audit-content--loading" : ""}`, children: [
754
- g && /* @__PURE__ */ e("div", { className: "nice-audit-loader", children: /* @__PURE__ */ e("div", { className: "nice-audit-spinner" }) }),
755
- Y === "timeline" ? /* @__PURE__ */ e("div", { className: "nice-audit-timeline", children: P.map((f) => /* @__PURE__ */ e(
756
- Ge,
757
- {
758
- entry: f,
759
- showDiff: r,
760
- renderActionIcon: h,
761
- renderUser: o,
762
- onClick: m ? () => m(f) : void 0
763
- },
764
- f.id
765
- )) }) : /* @__PURE__ */ e(We, { entries: P, showDiff: r, onEntryClick: m }),
766
- P.length === 0 && !g && /* @__PURE__ */ e("div", { className: "nice-audit-empty", children: "No audit entries found matching the current filters." })
767
- ] }),
768
- K > 1 && /* @__PURE__ */ c("div", { className: "nice-audit-pagination", children: [
769
- /* @__PURE__ */ e("button", { type: "button", disabled: v === 1, onClick: () => I(v - 1), children: "Previous" }),
770
- /* @__PURE__ */ c("span", { children: [
771
- "Page ",
772
- v,
773
- " of ",
774
- K
775
- ] }),
776
- /* @__PURE__ */ e("button", { type: "button", disabled: v === K, onClick: () => I(v + 1), children: "Next" })
777
- ] })
778
- ] });
779
- }
780
- );
781
- Ke.displayName = "NiceAuditTrail";
782
- const se = {
783
- general: { label: "General", color: "var(--text-muted, #6b7280)", icon: "πŸ“„" },
784
- liability: { label: "Liability", color: "var(--color-error, #ef4444)", icon: "⚠️" },
785
- payment: { label: "Payment", color: "var(--color-success, #10b981)", icon: "πŸ’°" },
786
- termination: { label: "Termination", color: "var(--color-warning, #f59e0b)", icon: "β›”" },
787
- confidentiality: { label: "Confidentiality", color: "var(--color-accent, #8b5cf6)", icon: "πŸ”’" },
788
- compliance: { label: "Compliance", color: "var(--color-primary, #3b82f6)", icon: "βœ“" },
789
- custom: { label: "Custom", color: "var(--text-muted, #64748b)", icon: "✎" }
790
- }, Xe = {
791
- draft: { label: "Draft", color: "var(--text-muted, #6b7280)" },
792
- pending_review: { label: "Pending Review", color: "var(--color-warning, #f59e0b)" },
793
- approved: { label: "Approved", color: "var(--color-success, #10b981)" },
794
- rejected: { label: "Rejected", color: "var(--color-error, #ef4444)" },
795
- signed: { label: "Signed", color: "var(--color-accent, #8b5cf6)" }
796
- }, Ze = ({ clauses: i, onInsert: t }) => {
797
- const [l, n] = S(""), [s, r] = S("all"), h = i.filter((o) => {
798
- const m = l === "" || o.name.toLowerCase().includes(l.toLowerCase()) || o.content.toLowerCase().includes(l.toLowerCase()), O = s === "all" || o.category === s;
799
- return m && O;
800
- });
801
- return /* @__PURE__ */ c("div", { className: "nice-contract-library", children: [
802
- /* @__PURE__ */ c("div", { className: "nice-contract-library-header", children: [
803
- /* @__PURE__ */ e("h4", { children: "Clause Library" }),
804
- /* @__PURE__ */ e(
805
- "input",
806
- {
807
- type: "text",
808
- placeholder: "Search clauses...",
809
- value: l,
810
- onChange: (o) => n(o.target.value),
811
- className: "nice-contract-library-search"
812
- }
813
- )
814
- ] }),
815
- /* @__PURE__ */ c("div", { className: "nice-contract-library-categories", children: [
816
- /* @__PURE__ */ e(
817
- "button",
818
- {
819
- type: "button",
820
- className: `nice-contract-category-btn ${s === "all" ? "nice-contract-category-btn--active" : ""}`,
821
- onClick: () => r("all"),
822
- children: "All"
823
- }
824
- ),
825
- Object.keys(se).map((o) => /* @__PURE__ */ c(
826
- "button",
827
- {
828
- type: "button",
829
- className: `nice-contract-category-btn ${s === o ? "nice-contract-category-btn--active" : ""}`,
830
- onClick: () => r(o),
831
- style: { "--cat-color": se[o].color },
832
- children: [
833
- se[o].icon,
834
- " ",
835
- se[o].label
836
- ]
837
- },
838
- o
839
- ))
840
- ] }),
841
- /* @__PURE__ */ c("div", { className: "nice-contract-library-list", children: [
842
- h.map((o) => /* @__PURE__ */ c("div", { className: "nice-contract-library-item", children: [
843
- /* @__PURE__ */ c("div", { className: "nice-contract-library-item-header", children: [
844
- /* @__PURE__ */ e("span", { className: "nice-contract-library-item-name", children: o.name }),
845
- /* @__PURE__ */ e(
846
- "span",
847
- {
848
- className: "nice-contract-library-item-cat",
849
- style: { "--cat-color": se[o.category].color },
850
- children: se[o.category].icon
851
- }
852
- )
853
- ] }),
854
- o.description && /* @__PURE__ */ e("p", { className: "nice-contract-library-item-desc", children: o.description }),
855
- /* @__PURE__ */ e(
856
- "button",
857
- {
858
- type: "button",
859
- className: "nice-contract-library-insert",
860
- onClick: () => t(o),
861
- children: "+ Insert"
862
- }
863
- )
864
- ] }, o.id)),
865
- h.length === 0 && /* @__PURE__ */ e("div", { className: "nice-contract-library-empty", children: "No matching clauses" })
866
- ] })
867
- ] });
868
- }, Qe = ({ variables: i, definitions: t, onChange: l }) => /* @__PURE__ */ c("div", { className: "nice-contract-variables", children: [
869
- /* @__PURE__ */ e("h4", { children: "Variables" }),
870
- /* @__PURE__ */ e("div", { className: "nice-contract-variables-list", children: t.map((n) => /* @__PURE__ */ c("div", { className: "nice-contract-variable", children: [
871
- /* @__PURE__ */ c("label", { children: [
872
- n.name,
873
- n.required && /* @__PURE__ */ e("span", { className: "nice-contract-required", children: "*" })
874
- ] }),
875
- n.type === "select" && n.options ? /* @__PURE__ */ c(
876
- "select",
877
- {
878
- value: i[n.name] || n.defaultValue || "",
879
- onChange: (s) => l(n.name, s.target.value),
880
- children: [
881
- /* @__PURE__ */ e("option", { value: "", children: "Select..." }),
882
- n.options.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
883
- ]
884
- }
885
- ) : n.type === "date" ? /* @__PURE__ */ e(
886
- "input",
887
- {
888
- type: "date",
889
- value: i[n.name] || n.defaultValue || "",
890
- onChange: (s) => l(n.name, s.target.value)
891
- }
892
- ) : /* @__PURE__ */ e(
893
- "input",
894
- {
895
- type: n.type === "number" || n.type === "currency" ? "number" : "text",
896
- value: i[n.name] || n.defaultValue || "",
897
- placeholder: n.placeholder,
898
- onChange: (s) => l(n.name, s.target.value)
899
- }
900
- )
901
- ] }, n.name)) })
902
- ] }), ec = ({
903
- section: i,
904
- variables: t,
905
- readOnly: l,
906
- onToggle: n,
907
- onRemoveClause: s,
908
- onMoveClause: r
909
- }) => {
910
- const h = (o) => o.replace(/\{\{(\w+)\}\}/g, (m, O) => t[O] || `[${O}]`);
911
- return /* @__PURE__ */ c(
912
- "div",
913
- {
914
- className: `nice-contract-section ${i.collapsed ? "nice-contract-section--collapsed" : ""}`,
915
- children: [
916
- /* @__PURE__ */ c("div", { className: "nice-contract-section-header", onClick: n, children: [
917
- /* @__PURE__ */ e("span", { className: "nice-contract-section-toggle", children: i.collapsed ? "β–Ά" : "β–Ό" }),
918
- /* @__PURE__ */ e("h3", { children: i.title }),
919
- /* @__PURE__ */ c("span", { className: "nice-contract-section-count", children: [
920
- i.clauses.length,
921
- " clause(s)"
922
- ] })
923
- ] }),
924
- !i.collapsed && /* @__PURE__ */ c("div", { className: "nice-contract-section-content", children: [
925
- i.clauses.map((o, m) => /* @__PURE__ */ c("div", { className: "nice-contract-clause", children: [
926
- /* @__PURE__ */ c("div", { className: "nice-contract-clause-header", children: [
927
- /* @__PURE__ */ e(
928
- "span",
929
- {
930
- className: "nice-contract-clause-cat",
931
- style: { "--cat-color": se[o.category].color },
932
- children: se[o.category].icon
933
- }
934
- ),
935
- /* @__PURE__ */ e("span", { className: "nice-contract-clause-name", children: o.name }),
936
- o.isRequired && /* @__PURE__ */ e("span", { className: "nice-contract-clause-required", children: "Required" }),
937
- !l && /* @__PURE__ */ c("div", { className: "nice-contract-clause-actions", children: [
938
- /* @__PURE__ */ e(
939
- "button",
940
- {
941
- type: "button",
942
- onClick: () => r(o.id, "up"),
943
- disabled: m === 0,
944
- children: "↑"
945
- }
946
- ),
947
- /* @__PURE__ */ e(
948
- "button",
949
- {
950
- type: "button",
951
- onClick: () => r(o.id, "down"),
952
- disabled: m === i.clauses.length - 1,
953
- children: "↓"
954
- }
955
- ),
956
- /* @__PURE__ */ e("button", { type: "button", onClick: () => s(o.id), children: "Γ—" })
957
- ] })
958
- ] }),
959
- /* @__PURE__ */ e(
960
- "div",
961
- {
962
- className: "nice-contract-clause-content",
963
- dangerouslySetInnerHTML: { __html: h(o.content) }
964
- }
965
- )
966
- ] }, o.id)),
967
- i.clauses.length === 0 && /* @__PURE__ */ e("div", { className: "nice-contract-section-empty", children: "No clauses in this section. Drag clauses here or use the library." })
968
- ] })
969
- ]
970
- }
971
- );
972
- }, cc = ({ workflow: i, onAction: t }) => {
973
- const [l, n] = S(null), [s, r] = S("");
974
- return /* @__PURE__ */ c("div", { className: "nice-contract-workflow", children: [
975
- /* @__PURE__ */ e("h4", { children: "Approval Workflow" }),
976
- /* @__PURE__ */ e("div", { className: "nice-contract-workflow-steps", children: i.steps.map((h, o) => /* @__PURE__ */ c(
977
- "div",
978
- {
979
- className: `nice-contract-workflow-step nice-contract-workflow-step--${h.status}`,
980
- children: [
981
- /* @__PURE__ */ c("div", { className: "nice-contract-workflow-step-header", children: [
982
- /* @__PURE__ */ e("span", { className: "nice-contract-workflow-step-num", children: o + 1 }),
983
- /* @__PURE__ */ e("span", { className: "nice-contract-workflow-step-name", children: h.name }),
984
- /* @__PURE__ */ e(
985
- "span",
986
- {
987
- className: `nice-contract-workflow-step-status nice-contract-workflow-step-status--${h.status}`,
988
- children: h.status
989
- }
990
- )
991
- ] }),
992
- /* @__PURE__ */ e("div", { className: "nice-contract-workflow-approvers", children: h.approvers.map((m) => /* @__PURE__ */ c("div", { className: "nice-contract-approver", children: [
993
- m.avatar && /* @__PURE__ */ e("img", { src: m.avatar, alt: "", className: "nice-contract-approver-avatar" }),
994
- /* @__PURE__ */ e("span", { children: m.name }),
995
- /* @__PURE__ */ e("span", { className: "nice-contract-approver-role", children: m.role })
996
- ] }, m.id)) }),
997
- h.status === "pending" && i.currentStep === o && /* @__PURE__ */ e("div", { className: "nice-contract-workflow-actions", children: l === h.id ? /* @__PURE__ */ c(re, { children: [
998
- /* @__PURE__ */ e(
999
- "textarea",
1000
- {
1001
- placeholder: "Comments (optional)",
1002
- value: s,
1003
- onChange: (m) => r(m.target.value)
1004
- }
1005
- ),
1006
- /* @__PURE__ */ c("div", { className: "nice-contract-workflow-btns", children: [
1007
- /* @__PURE__ */ e(
1008
- "button",
1009
- {
1010
- type: "button",
1011
- className: "nice-contract-btn nice-contract-btn--approve",
1012
- onClick: () => {
1013
- t(h.id, "approve", s), n(null), r("");
1014
- },
1015
- children: "βœ“ Approve"
1016
- }
1017
- ),
1018
- /* @__PURE__ */ e(
1019
- "button",
1020
- {
1021
- type: "button",
1022
- className: "nice-contract-btn nice-contract-btn--reject",
1023
- onClick: () => {
1024
- t(h.id, "reject", s), n(null), r("");
1025
- },
1026
- children: "βœ— Reject"
1027
- }
1028
- ),
1029
- /* @__PURE__ */ e("button", { type: "button", onClick: () => n(null), children: "Cancel" })
1030
- ] })
1031
- ] }) : /* @__PURE__ */ e(
1032
- "button",
1033
- {
1034
- type: "button",
1035
- className: "nice-contract-btn",
1036
- onClick: () => n(h.id),
1037
- children: "Review"
1038
- }
1039
- ) })
1040
- ]
1041
- },
1042
- h.id
1043
- )) })
1044
- ] });
1045
- }, ic = oe(
1046
- ({
1047
- document: i,
1048
- clauseLibrary: t = [],
1049
- readOnly: l = !1,
1050
- showClauseLibrary: n = !0,
1051
- showVersionHistory: s = !1,
1052
- showComments: r = !1,
1053
- showWorkflow: h = !0,
1054
- currentUser: o,
1055
- onChange: m,
1056
- onAddClause: O,
1057
- onRemoveClause: G,
1058
- onVariableChange: N,
1059
- onAddComment: C,
1060
- onApprovalAction: U,
1061
- onRestoreVersion: P,
1062
- onSave: X,
1063
- onExport: q,
1064
- className: W = "",
1065
- style: V
1066
- }, B) => {
1067
- var y;
1068
- const [v, I] = S(i), [g, k] = S(n ? "library" : null), [Y, b] = S(
1069
- ((y = v.sections[0]) == null ? void 0 : y.id) || null
1070
- ), E = v.sections.flatMap(
1071
- (u) => u.clauses.flatMap((w) => w.variables || [])
1072
- ).filter(
1073
- (u, w, x) => x.findIndex((z) => z.name === u.name) === w
1074
- ), $ = _(
1075
- (u) => {
1076
- const w = { ...v, ...u, updatedAt: /* @__PURE__ */ new Date() };
1077
- I(w), m == null || m(w);
1078
- },
1079
- [v, m]
1080
- ), j = _(
1081
- (u, w) => {
1082
- const x = v.sections.map(
1083
- (z) => z.id === w ? { ...z, clauses: [...z.clauses, { ...u, id: `${u.id}-${Date.now()}` }] } : z
1084
- );
1085
- $({ sections: x }), O == null || O(u, w);
1086
- },
1087
- [v, $, O]
1088
- ), K = _(
1089
- (u, w) => {
1090
- const x = v.sections.map(
1091
- (z) => z.id === w ? { ...z, clauses: z.clauses.filter((T) => T.id !== u) } : z
1092
- );
1093
- $({ sections: x }), G == null || G(u, w);
1094
- },
1095
- [v, $, G]
1096
- ), f = _(
1097
- (u, w, x) => {
1098
- const z = v.sections.map((T) => {
1099
- if (T.id !== u)
1100
- return T;
1101
- const ee = T.clauses.findIndex((ce) => ce.id === w);
1102
- if (ee === -1)
1103
- return T;
1104
- const ne = x === "up" ? ee - 1 : ee + 1;
1105
- if (ne < 0 || ne >= T.clauses.length)
1106
- return T;
1107
- const ie = [...T.clauses];
1108
- return [ie[ee], ie[ne]] = [ie[ne], ie[ee]], { ...T, clauses: ie };
1109
- });
1110
- $({ sections: z });
1111
- },
1112
- [v, $]
1113
- ), R = _(
1114
- (u) => {
1115
- const w = v.sections.map(
1116
- (x) => x.id === u ? { ...x, collapsed: !x.collapsed } : x
1117
- );
1118
- $({ sections: w });
1119
- },
1120
- [v, $]
1121
- ), L = _(
1122
- (u, w) => {
1123
- $({ variables: { ...v.variables, [u]: w } }), N == null || N(u, w);
1124
- },
1125
- [v, $, N]
1126
- ), Z = _(() => {
1127
- const u = [];
1128
- return E.forEach((w) => {
1129
- w.required && !v.variables[w.name] && u.push(`Missing required variable: ${w.name}`);
1130
- }), v.sections.forEach((w) => {
1131
- w.clauses.forEach((x) => {
1132
- x.isRequired && !x.content && u.push(`Required clause "${x.name}" is empty`);
1133
- });
1134
- }), { valid: u.length === 0, errors: u };
1135
- }, [v, E]);
1136
- de(B, () => ({
1137
- getDocument: () => v,
1138
- insertClause: j,
1139
- setVariable: L,
1140
- exportDocument: (u) => q == null ? void 0 : q(u),
1141
- validate: Z
1142
- }));
1143
- const F = Xe[v.status];
1144
- return /* @__PURE__ */ c("div", { className: `nice-contract-editor ${W}`, style: V, children: [
1145
- /* @__PURE__ */ c("div", { className: "nice-contract-header", children: [
1146
- /* @__PURE__ */ c("div", { className: "nice-contract-header-info", children: [
1147
- /* @__PURE__ */ e("h2", { className: "nice-contract-title", children: v.title }),
1148
- /* @__PURE__ */ e(
1149
- "span",
1150
- {
1151
- className: "nice-contract-status",
1152
- style: { "--status-color": F.color },
1153
- children: F.label
1154
- }
1155
- )
1156
- ] }),
1157
- /* @__PURE__ */ c("div", { className: "nice-contract-header-actions", children: [
1158
- X && !l && /* @__PURE__ */ e(
1159
- "button",
1160
- {
1161
- type: "button",
1162
- className: "nice-contract-btn nice-contract-btn--primary",
1163
- onClick: () => X(v),
1164
- children: "Save"
1165
- }
1166
- ),
1167
- q && /* @__PURE__ */ c("div", { className: "nice-contract-export-dropdown", children: [
1168
- /* @__PURE__ */ e("button", { type: "button", className: "nice-contract-btn", children: "Export β–Ό" }),
1169
- /* @__PURE__ */ c("div", { className: "nice-contract-export-menu", children: [
1170
- /* @__PURE__ */ e("button", { type: "button", onClick: () => q("pdf"), children: "PDF" }),
1171
- /* @__PURE__ */ e("button", { type: "button", onClick: () => q("docx"), children: "Word (.docx)" }),
1172
- /* @__PURE__ */ e("button", { type: "button", onClick: () => q("html"), children: "HTML" })
1173
- ] })
1174
- ] })
1175
- ] })
1176
- ] }),
1177
- /* @__PURE__ */ c("div", { className: "nice-contract-toolbar", children: [
1178
- n && /* @__PURE__ */ e(
1179
- "button",
1180
- {
1181
- type: "button",
1182
- className: `nice-contract-toolbar-btn ${g === "library" ? "nice-contract-toolbar-btn--active" : ""}`,
1183
- onClick: () => k(g === "library" ? null : "library"),
1184
- children: "πŸ“š Library"
1185
- }
1186
- ),
1187
- /* @__PURE__ */ e(
1188
- "button",
1189
- {
1190
- type: "button",
1191
- className: `nice-contract-toolbar-btn ${g === "variables" ? "nice-contract-toolbar-btn--active" : ""}`,
1192
- onClick: () => k(g === "variables" ? null : "variables"),
1193
- children: "πŸ”€ Variables"
1194
- }
1195
- ),
1196
- h && v.workflow && /* @__PURE__ */ e(
1197
- "button",
1198
- {
1199
- type: "button",
1200
- className: `nice-contract-toolbar-btn ${g === "workflow" ? "nice-contract-toolbar-btn--active" : ""}`,
1201
- onClick: () => k(g === "workflow" ? null : "workflow"),
1202
- children: "βœ“ Workflow"
1203
- }
1204
- ),
1205
- s && /* @__PURE__ */ e(
1206
- "button",
1207
- {
1208
- type: "button",
1209
- className: `nice-contract-toolbar-btn ${g === "history" ? "nice-contract-toolbar-btn--active" : ""}`,
1210
- onClick: () => k(g === "history" ? null : "history"),
1211
- children: "πŸ“œ History"
1212
- }
1213
- )
1214
- ] }),
1215
- /* @__PURE__ */ c("div", { className: "nice-contract-main", children: [
1216
- g && /* @__PURE__ */ c("div", { className: "nice-contract-panel", children: [
1217
- g === "library" && /* @__PURE__ */ e(
1218
- Ze,
1219
- {
1220
- clauses: t,
1221
- onInsert: (u) => Y && j(u, Y)
1222
- }
1223
- ),
1224
- g === "variables" && /* @__PURE__ */ e(
1225
- Qe,
1226
- {
1227
- variables: v.variables,
1228
- definitions: E,
1229
- onChange: L
1230
- }
1231
- ),
1232
- g === "workflow" && v.workflow && /* @__PURE__ */ e(
1233
- cc,
1234
- {
1235
- workflow: v.workflow,
1236
- onAction: (u, w, x) => U == null ? void 0 : U(u, w, x)
1237
- }
1238
- )
1239
- ] }),
1240
- /* @__PURE__ */ e("div", { className: "nice-contract-document", children: v.sections.map((u) => /* @__PURE__ */ e(
1241
- ec,
1242
- {
1243
- section: u,
1244
- variables: v.variables,
1245
- readOnly: l,
1246
- onToggle: () => R(u.id),
1247
- onRemoveClause: (w) => K(w, u.id),
1248
- onMoveClause: (w, x) => f(u.id, w, x)
1249
- },
1250
- u.id
1251
- )) })
1252
- ] })
1253
- ] });
1254
- }
1255
- );
1256
- ic.displayName = "NiceContractEditor";
1257
- const nc = [
1258
- {
1259
- id: "necessary",
1260
- label: "Necessary",
1261
- description: "Essential cookies for site functionality. Cannot be disabled.",
1262
- required: !0,
1263
- enabled: !0,
1264
- cookies: ["session_id", "csrf_token", "consent"]
1265
- },
1266
- {
1267
- id: "analytics",
1268
- label: "Analytics",
1269
- description: "Help us understand how visitors interact with our website.",
1270
- enabled: !1,
1271
- cookies: ["_ga", "_gid", "_gat"],
1272
- partners: ["Google Analytics", "Hotjar"]
1273
- },
1274
- {
1275
- id: "marketing",
1276
- label: "Marketing",
1277
- description: "Used to deliver personalized advertisements.",
1278
- enabled: !1,
1279
- cookies: ["_fbp", "_gcl_au", "ads_id"],
1280
- partners: ["Facebook", "Google Ads", "LinkedIn"]
1281
- },
1282
- {
1283
- id: "preferences",
1284
- label: "Preferences",
1285
- description: "Remember your settings and preferences.",
1286
- enabled: !1,
1287
- cookies: ["theme", "language", "timezone"]
1288
- },
1289
- {
1290
- id: "social",
1291
- label: "Social Media",
1292
- description: "Enable social sharing and embedded content.",
1293
- enabled: !1,
1294
- cookies: ["social_session"],
1295
- partners: ["Twitter", "YouTube", "Instagram"]
1296
- }
1297
- ], tc = {
1298
- title: "Cookie Preferences",
1299
- description: "We use cookies to enhance your experience. Choose which types of cookies you allow.",
1300
- acceptAll: "Accept All",
1301
- rejectAll: "Reject All",
1302
- customize: "Customize",
1303
- savePreferences: "Save Preferences",
1304
- necessary: "Necessary",
1305
- analytics: "Analytics",
1306
- marketing: "Marketing",
1307
- preferences: "Preferences",
1308
- social: "Social Media",
1309
- dataRights: "Your Data Rights",
1310
- exportData: "Export My Data",
1311
- deleteData: "Delete My Data",
1312
- pending: "Pending",
1313
- processing: "Processing",
1314
- completed: "Completed",
1315
- close: "Close"
1316
- }, ac = ({ option: i, enabled: t, onChange: l }) => /* @__PURE__ */ c("div", { className: "nice-gdpr-option", children: [
1317
- /* @__PURE__ */ c("div", { className: "nice-gdpr-option-header", children: [
1318
- /* @__PURE__ */ c("label", { className: "nice-gdpr-option-toggle", children: [
1319
- /* @__PURE__ */ e(
1320
- "input",
1321
- {
1322
- type: "checkbox",
1323
- checked: t,
1324
- onChange: (n) => l(n.target.checked),
1325
- disabled: i.required
1326
- }
1327
- ),
1328
- /* @__PURE__ */ e("span", { className: "nice-gdpr-toggle-slider" })
1329
- ] }),
1330
- /* @__PURE__ */ c("div", { className: "nice-gdpr-option-info", children: [
1331
- /* @__PURE__ */ c("span", { className: "nice-gdpr-option-label", children: [
1332
- i.label,
1333
- i.required && /* @__PURE__ */ e("span", { className: "nice-gdpr-required", children: "Required" })
1334
- ] }),
1335
- /* @__PURE__ */ e("span", { className: "nice-gdpr-option-desc", children: i.description })
1336
- ] })
1337
- ] }),
1338
- i.partners && i.partners.length > 0 && /* @__PURE__ */ c("div", { className: "nice-gdpr-option-partners", children: [
1339
- /* @__PURE__ */ e("span", { children: "Partners: " }),
1340
- i.partners.join(", ")
1341
- ] })
1342
- ] }), lc = ({
1343
- requests: i,
1344
- policies: t,
1345
- onRequest: l,
1346
- onDownload: n,
1347
- labels: s
1348
- }) => /* @__PURE__ */ c("div", { className: "nice-gdpr-rights", children: [
1349
- /* @__PURE__ */ e("h4", { children: s.dataRights }),
1350
- /* @__PURE__ */ c("div", { className: "nice-gdpr-rights-actions", children: [
1351
- /* @__PURE__ */ c(
1352
- "button",
1353
- {
1354
- type: "button",
1355
- className: "nice-gdpr-btn nice-gdpr-btn--secondary",
1356
- onClick: () => l("export"),
1357
- children: [
1358
- "πŸ“₯ ",
1359
- s.exportData
1360
- ]
1361
- }
1362
- ),
1363
- /* @__PURE__ */ c(
1364
- "button",
1365
- {
1366
- type: "button",
1367
- className: "nice-gdpr-btn nice-gdpr-btn--danger",
1368
- onClick: () => l("delete"),
1369
- children: [
1370
- "πŸ—‘οΈ ",
1371
- s.deleteData
1372
- ]
1373
- }
1374
- )
1375
- ] }),
1376
- i.length > 0 && /* @__PURE__ */ c("div", { className: "nice-gdpr-requests", children: [
1377
- /* @__PURE__ */ e("h5", { children: "Previous Requests" }),
1378
- i.map((r) => /* @__PURE__ */ c("div", { className: `nice-gdpr-request nice-gdpr-request--${r.status}`, children: [
1379
- /* @__PURE__ */ e("span", { className: "nice-gdpr-request-type", children: r.type }),
1380
- /* @__PURE__ */ e("span", { className: "nice-gdpr-request-date", children: new Date(r.requestedAt).toLocaleDateString() }),
1381
- /* @__PURE__ */ e("span", { className: "nice-gdpr-request-status", children: r.status }),
1382
- r.status === "completed" && r.downloadUrl && /* @__PURE__ */ e(
1383
- "button",
1384
- {
1385
- type: "button",
1386
- className: "nice-gdpr-download-btn",
1387
- onClick: () => n(r.id),
1388
- children: "Download"
1389
- }
1390
- )
1391
- ] }, r.id))
1392
- ] }),
1393
- t.length > 0 && /* @__PURE__ */ c("div", { className: "nice-gdpr-policies", children: [
1394
- /* @__PURE__ */ e("h5", { children: "Data Retention" }),
1395
- /* @__PURE__ */ c("table", { className: "nice-gdpr-policies-table", children: [
1396
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ c("tr", { children: [
1397
- /* @__PURE__ */ e("th", { children: "Category" }),
1398
- /* @__PURE__ */ e("th", { children: "Retention" }),
1399
- /* @__PURE__ */ e("th", { children: "Legal Basis" })
1400
- ] }) }),
1401
- /* @__PURE__ */ e("tbody", { children: t.map((r, h) => /* @__PURE__ */ c("tr", { children: [
1402
- /* @__PURE__ */ e("td", { children: r.category }),
1403
- /* @__PURE__ */ c("td", { children: [
1404
- r.retentionDays,
1405
- " days"
1406
- ] }),
1407
- /* @__PURE__ */ e("td", { children: r.legalBasis })
1408
- ] }, h)) })
1409
- ] })
1410
- ] })
1411
- ] }), sc = oe(
1412
- ({
1413
- appName: i,
1414
- companyName: t,
1415
- options: l = nc,
1416
- currentConsent: n = null,
1417
- retentionPolicies: s = [],
1418
- dataRequests: r = [],
1419
- privacyPolicy: h = [],
1420
- storageKey: o = "nice_gdpr_consent",
1421
- consentVersion: m = "1.0",
1422
- variant: O = "banner",
1423
- position: G = "bottom",
1424
- onConsentChange: N,
1425
- onDataRequest: C,
1426
- onDownloadExport: U,
1427
- privacyPolicyUrl: P,
1428
- cookiePolicyUrl: X,
1429
- termsUrl: q,
1430
- labels: W,
1431
- className: V = "",
1432
- style: B
1433
- }, v) => {
1434
- const I = { ...tc, ...W }, [g, k] = S(!1), [Y, b] = S(!1), [M, E] = S(!1), [$, j] = S(() => {
1435
- const y = {};
1436
- return l.forEach((u) => {
1437
- y[u.id] = (n == null ? void 0 : n.categories[u.id]) ?? u.enabled;
1438
- }), y;
1439
- });
1440
- fe(() => {
1441
- (!n || n.version !== m) && k(!0);
1442
- }, [n, m]);
1443
- const K = _(
1444
- (y, u) => {
1445
- const w = u || $;
1446
- w.necessary = !0;
1447
- const x = {
1448
- version: m,
1449
- timestamp: /* @__PURE__ */ new Date(),
1450
- categories: w,
1451
- action: y
1452
- };
1453
- try {
1454
- localStorage.setItem(o, JSON.stringify(x));
1455
- } catch {
1456
- }
1457
- j(w), k(!1), b(!1), N == null || N(x);
1458
- },
1459
- [$, m, o, N]
1460
- ), f = _(() => {
1461
- const y = {};
1462
- l.forEach((u) => {
1463
- y[u.id] = !0;
1464
- }), K("accept_all", y);
1465
- }, [l, K]), R = _(() => {
1466
- const y = {};
1467
- l.forEach((u) => {
1468
- y[u.id] = u.required || !1;
1469
- }), K("reject_all", y);
1470
- }, [l, K]), L = _(
1471
- async (y) => {
1472
- C && await C(y);
1473
- },
1474
- [C]
1475
- );
1476
- if (de(v, () => ({
1477
- showBanner: () => k(!0),
1478
- hideBanner: () => k(!1),
1479
- getConsent: () => {
1480
- try {
1481
- const y = localStorage.getItem(o);
1482
- return y ? JSON.parse(y) : null;
1483
- } catch {
1484
- return null;
1485
- }
1486
- },
1487
- revokeConsent: () => {
1488
- try {
1489
- localStorage.removeItem(o);
1490
- } catch {
1491
- }
1492
- k(!0);
1493
- },
1494
- openPreferences: () => {
1495
- k(!0), b(!0);
1496
- }
1497
- })), !g && O !== "embedded")
1498
- return null;
1499
- const Z = /* @__PURE__ */ c("div", { className: "nice-gdpr-content", children: [
1500
- /* @__PURE__ */ c("div", { className: "nice-gdpr-header", children: [
1501
- /* @__PURE__ */ e("div", { className: "nice-gdpr-icon", children: "πŸͺ" }),
1502
- /* @__PURE__ */ c("div", { className: "nice-gdpr-header-text", children: [
1503
- /* @__PURE__ */ e("h3", { children: I.title }),
1504
- /* @__PURE__ */ e("p", { children: I.description.replace("{app}", i).replace("{company}", t) })
1505
- ] })
1506
- ] }),
1507
- !Y && !M && /* @__PURE__ */ c("div", { className: "nice-gdpr-quick-actions", children: [
1508
- /* @__PURE__ */ e(
1509
- "button",
1510
- {
1511
- type: "button",
1512
- className: "nice-gdpr-btn nice-gdpr-btn--primary",
1513
- onClick: f,
1514
- children: I.acceptAll
1515
- }
1516
- ),
1517
- /* @__PURE__ */ e(
1518
- "button",
1519
- {
1520
- type: "button",
1521
- className: "nice-gdpr-btn nice-gdpr-btn--secondary",
1522
- onClick: R,
1523
- children: I.rejectAll
1524
- }
1525
- ),
1526
- /* @__PURE__ */ e(
1527
- "button",
1528
- {
1529
- type: "button",
1530
- className: "nice-gdpr-btn nice-gdpr-btn--link",
1531
- onClick: () => b(!0),
1532
- children: I.customize
1533
- }
1534
- )
1535
- ] }),
1536
- Y && !M && /* @__PURE__ */ c("div", { className: "nice-gdpr-preferences", children: [
1537
- /* @__PURE__ */ e("div", { className: "nice-gdpr-options", children: l.map((y) => /* @__PURE__ */ e(
1538
- ac,
1539
- {
1540
- option: y,
1541
- enabled: $[y.id],
1542
- onChange: (u) => j((w) => ({ ...w, [y.id]: u }))
1543
- },
1544
- y.id
1545
- )) }),
1546
- /* @__PURE__ */ c("div", { className: "nice-gdpr-pref-actions", children: [
1547
- /* @__PURE__ */ e(
1548
- "button",
1549
- {
1550
- type: "button",
1551
- className: "nice-gdpr-btn nice-gdpr-btn--primary",
1552
- onClick: () => K("custom"),
1553
- children: I.savePreferences
1554
- }
1555
- ),
1556
- /* @__PURE__ */ e(
1557
- "button",
1558
- {
1559
- type: "button",
1560
- className: "nice-gdpr-btn nice-gdpr-btn--link",
1561
- onClick: () => E(!0),
1562
- children: I.dataRights
1563
- }
1564
- )
1565
- ] })
1566
- ] }),
1567
- M && /* @__PURE__ */ c(re, { children: [
1568
- /* @__PURE__ */ e(
1569
- lc,
1570
- {
1571
- requests: r,
1572
- policies: s,
1573
- onRequest: L,
1574
- onDownload: (y) => U == null ? void 0 : U(y),
1575
- labels: I
1576
- }
1577
- ),
1578
- /* @__PURE__ */ e(
1579
- "button",
1580
- {
1581
- type: "button",
1582
- className: "nice-gdpr-btn nice-gdpr-btn--link",
1583
- onClick: () => E(!1),
1584
- children: "← Back to preferences"
1585
- }
1586
- )
1587
- ] }),
1588
- /* @__PURE__ */ c("div", { className: "nice-gdpr-footer", children: [
1589
- P && /* @__PURE__ */ e("a", { href: P, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }),
1590
- X && /* @__PURE__ */ e("a", { href: X, target: "_blank", rel: "noopener noreferrer", children: "Cookie Policy" }),
1591
- q && /* @__PURE__ */ e("a", { href: q, target: "_blank", rel: "noopener noreferrer", children: "Terms of Service" })
1592
- ] })
1593
- ] }), F = `nice-gdpr-consent nice-gdpr-consent--${O} nice-gdpr-consent--${G} ${V}`;
1594
- return O === "modal" ? /* @__PURE__ */ e("div", { className: "nice-gdpr-overlay", children: /* @__PURE__ */ e("div", { className: F, style: B, role: "dialog", "aria-modal": "true", children: Z }) }) : /* @__PURE__ */ e("div", { className: F, style: B, children: Z });
1595
- }
1596
- );
1597
- sc.displayName = "NiceGDPRConsent";
1598
- const $e = {
1599
- document: "πŸ“„",
1600
- user: "πŸ‘€",
1601
- task: "βœ“",
1602
- project: "πŸ“",
1603
- setting: "βš™οΈ",
1604
- help: "❓",
1605
- action: "⚑",
1606
- custom: "β€’"
1607
- }, rc = ({
1608
- value: i,
1609
- onChange: t,
1610
- onKeyDown: l,
1611
- placeholder: n,
1612
- isLoading: s,
1613
- inputRef: r
1614
- }) => /* @__PURE__ */ c("div", { className: "nice-search-input-container", children: [
1615
- /* @__PURE__ */ e("span", { className: "nice-search-icon", children: "πŸ”" }),
1616
- /* @__PURE__ */ e(
1617
- "input",
1618
- {
1619
- ref: r,
1620
- type: "text",
1621
- className: "nice-search-input",
1622
- placeholder: n,
1623
- value: i,
1624
- onChange: (h) => t(h.target.value),
1625
- onKeyDown: l,
1626
- "aria-label": "Search"
1627
- }
1628
- ),
1629
- s && /* @__PURE__ */ e("span", { className: "nice-search-loader" }),
1630
- i && !s && /* @__PURE__ */ e(
1631
- "button",
1632
- {
1633
- type: "button",
1634
- className: "nice-search-clear",
1635
- onClick: () => t(""),
1636
- "aria-label": "Clear search",
1637
- children: "Γ—"
1638
- }
1639
- )
1640
- ] }), oc = ({ result: i, isSelected: t, onSelect: l, renderResult: n }) => n ? /* @__PURE__ */ e("div", { onClick: l, children: n(i, t) }) : /* @__PURE__ */ c(
1641
- "div",
1642
- {
1643
- className: `nice-search-result ${t ? "nice-search-result--selected" : ""}`,
1644
- onClick: l,
1645
- role: "option",
1646
- "aria-selected": t,
1647
- children: [
1648
- /* @__PURE__ */ e("div", { className: "nice-search-result-icon", children: i.icon || (i.image ? /* @__PURE__ */ e("img", { src: i.image, alt: "" }) : $e[i.type]) }),
1649
- /* @__PURE__ */ c("div", { className: "nice-search-result-content", children: [
1650
- /* @__PURE__ */ e("span", { className: "nice-search-result-title", children: i.title }),
1651
- i.subtitle && /* @__PURE__ */ e("span", { className: "nice-search-result-subtitle", children: i.subtitle }),
1652
- i.description && /* @__PURE__ */ e("span", { className: "nice-search-result-desc", children: i.description })
1653
- ] }),
1654
- /* @__PURE__ */ c("div", { className: "nice-search-result-meta", children: [
1655
- /* @__PURE__ */ e("span", { className: "nice-search-result-source", children: i.source }),
1656
- /* @__PURE__ */ e("span", { className: "nice-search-result-type", children: i.type })
1657
- ] }),
1658
- i.actions && i.actions.length > 0 && /* @__PURE__ */ e("div", { className: "nice-search-result-actions", children: i.actions.map((s) => /* @__PURE__ */ e(
1659
- "button",
1660
- {
1661
- type: "button",
1662
- className: "nice-search-action-btn",
1663
- onClick: (r) => {
1664
- r.stopPropagation(), s.onClick();
1665
- },
1666
- title: s.label,
1667
- children: s.icon || s.label
1668
- },
1669
- s.id
1670
- )) })
1671
- ]
1672
- }
1673
- ), dc = ({ categories: i, selected: t, onSelect: l }) => /* @__PURE__ */ c("div", { className: "nice-search-categories", children: [
1674
- /* @__PURE__ */ e(
1675
- "button",
1676
- {
1677
- type: "button",
1678
- className: `nice-search-category ${t === null ? "nice-search-category--active" : ""}`,
1679
- onClick: () => l(null),
1680
- children: "All"
1681
- }
1682
- ),
1683
- i.map((n) => /* @__PURE__ */ c(
1684
- "button",
1685
- {
1686
- type: "button",
1687
- className: `nice-search-category ${t === n.id ? "nice-search-category--active" : ""}`,
1688
- onClick: () => l(n.id),
1689
- children: [
1690
- n.icon && /* @__PURE__ */ e("span", { className: "nice-search-category-icon", children: n.icon }),
1691
- n.label,
1692
- n.count !== void 0 && /* @__PURE__ */ e("span", { className: "nice-search-category-count", children: n.count })
1693
- ]
1694
- },
1695
- n.id
1696
- ))
1697
- ] }), hc = ({
1698
- searches: i,
1699
- onSelect: t,
1700
- onClear: l,
1701
- label: n,
1702
- clearLabel: s
1703
- }) => /* @__PURE__ */ c("div", { className: "nice-search-recent", children: [
1704
- /* @__PURE__ */ c("div", { className: "nice-search-recent-header", children: [
1705
- /* @__PURE__ */ e("span", { children: n }),
1706
- /* @__PURE__ */ e("button", { type: "button", onClick: l, children: s })
1707
- ] }),
1708
- /* @__PURE__ */ e("div", { className: "nice-search-recent-list", children: i.map((r, h) => /* @__PURE__ */ c(
1709
- "button",
1710
- {
1711
- type: "button",
1712
- className: "nice-search-recent-item",
1713
- onClick: () => t(r.query),
1714
- children: [
1715
- /* @__PURE__ */ e("span", { className: "nice-search-recent-icon", children: "πŸ•’" }),
1716
- /* @__PURE__ */ e("span", { className: "nice-search-recent-query", children: r.query })
1717
- ]
1718
- },
1719
- h
1720
- )) })
1721
- ] }), pc = {
1722
- placeholder: "Search...",
1723
- recent: "Recent Searches",
1724
- noResults: "No results found for",
1725
- searching: "Searching...",
1726
- clearRecent: "Clear",
1727
- categories: "Categories",
1728
- filters: "Filters"
1729
- }, uc = oe(
1730
- ({
1731
- sources: i,
1732
- placeholder: t,
1733
- minQueryLength: l = 2,
1734
- debounceMs: n = 300,
1735
- showCategories: s = !0,
1736
- filters: r = [],
1737
- showRecent: h = !0,
1738
- maxRecent: o = 5,
1739
- showShortcuts: m = !0,
1740
- hotkey: O = "k",
1741
- onResultSelect: G,
1742
- onSearch: N,
1743
- onClose: C,
1744
- renderResult: U,
1745
- renderEmpty: P,
1746
- defaultOpen: X = !1,
1747
- open: q,
1748
- variant: W = "modal",
1749
- labels: V,
1750
- className: B = "",
1751
- style: v
1752
- }, I) => {
1753
- const g = { ...pc, ...V }, k = ge(null), Y = ge(), [b, M] = S(X), [E, $] = S(""), [j, K] = S([]), [f, R] = S(!1), [L, Z] = S(0), [F, y] = S(null), [u, w] = S([]), x = q !== void 0 ? q : b;
1754
- fe(() => {
1755
- try {
1756
- const p = localStorage.getItem("nice_recent_searches");
1757
- p && w(JSON.parse(p));
1758
- } catch {
1759
- }
1760
- }, []);
1761
- const z = _(
1762
- (p, A) => {
1763
- const ae = [{
1764
- query: p,
1765
- timestamp: /* @__PURE__ */ new Date(),
1766
- resultCount: A
1767
- }, ...u.filter((he) => he.query !== p)].slice(
1768
- 0,
1769
- o
1770
- );
1771
- w(ae);
1772
- try {
1773
- localStorage.setItem("nice_recent_searches", JSON.stringify(ae));
1774
- } catch {
1775
- }
1776
- },
1777
- [u, o]
1778
- ), T = _(
1779
- async (p) => {
1780
- if (p.length < l) {
1781
- K([]);
1782
- return;
1783
- }
1784
- R(!0);
1785
- try {
1786
- const A = i.map(async (ae) => {
1787
- try {
1788
- return (await ae.search(p)).map((me) => ({
1789
- ...me,
1790
- source: ae.name,
1791
- relevanceScore: me.relevanceScore * (ae.priority || 1)
1792
- }));
1793
- } catch {
1794
- return [];
1795
- }
1796
- }), H = (await Promise.all(A)).flat();
1797
- H.sort((ae, he) => he.relevanceScore - ae.relevanceScore), K(H), Z(0), N == null || N(p, H), H.length > 0 && z(p, H.length);
1798
- } finally {
1799
- R(!1);
1800
- }
1801
- },
1802
- [i, l, N, z]
1803
- ), ee = _(
1804
- (p) => {
1805
- $(p), Y.current && clearTimeout(Y.current), Y.current = setTimeout(() => {
1806
- T(p);
1807
- }, n);
1808
- },
1809
- [T, n]
1810
- ), ne = _(
1811
- (p) => {
1812
- switch (p.key) {
1813
- case "ArrowDown":
1814
- p.preventDefault(), Z((A) => Math.min(A + 1, j.length - 1));
1815
- break;
1816
- case "ArrowUp":
1817
- p.preventDefault(), Z((A) => Math.max(A - 1, 0));
1818
- break;
1819
- case "Enter":
1820
- p.preventDefault(), j[L] && (G == null || G(j[L]), M(!1), C == null || C());
1821
- break;
1822
- case "Escape":
1823
- p.preventDefault(), M(!1), C == null || C();
1824
- break;
1825
- }
1826
- },
1827
- [j, L, G, C]
1828
- );
1829
- fe(() => {
1830
- const p = (A) => {
1831
- (A.metaKey || A.ctrlKey) && A.key === O && (A.preventDefault(), M(!0), setTimeout(() => {
1832
- var H;
1833
- return (H = k.current) == null ? void 0 : H.focus();
1834
- }, 0));
1835
- };
1836
- return document.addEventListener("keydown", p), () => document.removeEventListener("keydown", p);
1837
- }, [O]), fe(() => {
1838
- x && setTimeout(() => {
1839
- var p;
1840
- return (p = k.current) == null ? void 0 : p.focus();
1841
- }, 0);
1842
- }, [x]);
1843
- const ie = F ? j.filter((p) => p.type === F) : j, ce = Array.from(new Set(j.map((p) => p.type))).map(
1844
- (p) => ({
1845
- id: p,
1846
- label: p.charAt(0).toUpperCase() + p.slice(1),
1847
- icon: $e[p],
1848
- count: j.filter((A) => A.type === p).length
1849
- })
1850
- );
1851
- if (de(I, () => ({
1852
- open: () => M(!0),
1853
- close: () => {
1854
- M(!1), C == null || C();
1855
- },
1856
- focus: () => {
1857
- var p;
1858
- return (p = k.current) == null ? void 0 : p.focus();
1859
- },
1860
- clear: () => {
1861
- $(""), K([]);
1862
- },
1863
- search: async (p) => {
1864
- $(p), await T(p);
1865
- }
1866
- })), !x && W !== "inline")
1867
- return null;
1868
- const d = /* @__PURE__ */ c("div", { className: "nice-search-content", children: [
1869
- /* @__PURE__ */ e(
1870
- rc,
1871
- {
1872
- value: E,
1873
- onChange: ee,
1874
- onKeyDown: ne,
1875
- placeholder: t || g.placeholder,
1876
- isLoading: f,
1877
- inputRef: k
1878
- }
1879
- ),
1880
- s && ce.length > 1 && E.length >= l && /* @__PURE__ */ e(
1881
- dc,
1882
- {
1883
- categories: ce,
1884
- selected: F,
1885
- onSelect: y
1886
- }
1887
- ),
1888
- /* @__PURE__ */ c("div", { className: "nice-search-results", role: "listbox", children: [
1889
- f && E.length >= l && /* @__PURE__ */ e("div", { className: "nice-search-loading", children: g.searching }),
1890
- !f && E.length >= l && ie.length === 0 && /* @__PURE__ */ e("div", { className: "nice-search-empty", children: P ? P(E) : /* @__PURE__ */ c(re, { children: [
1891
- /* @__PURE__ */ e("span", { className: "nice-search-empty-icon", children: "πŸ”" }),
1892
- /* @__PURE__ */ c("span", { children: [
1893
- g.noResults,
1894
- ' "',
1895
- E,
1896
- '"'
1897
- ] })
1898
- ] }) }),
1899
- ie.map((p, A) => /* @__PURE__ */ e(
1900
- oc,
1901
- {
1902
- result: p,
1903
- isSelected: A === L,
1904
- onSelect: () => {
1905
- G == null || G(p), M(!1), C == null || C();
1906
- },
1907
- renderResult: U
1908
- },
1909
- p.id
1910
- ))
1911
- ] }),
1912
- h && E.length < l && u.length > 0 && /* @__PURE__ */ e(
1913
- hc,
1914
- {
1915
- searches: u,
1916
- onSelect: (p) => {
1917
- $(p), T(p);
1918
- },
1919
- onClear: () => {
1920
- w([]), localStorage.removeItem("nice_recent_searches");
1921
- },
1922
- label: g.recent,
1923
- clearLabel: g.clearRecent
1924
- }
1925
- ),
1926
- m && /* @__PURE__ */ c("div", { className: "nice-search-shortcuts", children: [
1927
- /* @__PURE__ */ c("span", { children: [
1928
- /* @__PURE__ */ e("kbd", { children: "↑" }),
1929
- /* @__PURE__ */ e("kbd", { children: "↓" }),
1930
- " Navigate"
1931
- ] }),
1932
- /* @__PURE__ */ c("span", { children: [
1933
- /* @__PURE__ */ e("kbd", { children: "↡" }),
1934
- " Select"
1935
- ] }),
1936
- /* @__PURE__ */ c("span", { children: [
1937
- /* @__PURE__ */ e("kbd", { children: "Esc" }),
1938
- " Close"
1939
- ] })
1940
- ] })
1941
- ] });
1942
- return W === "modal" ? /* @__PURE__ */ e(
1943
- "div",
1944
- {
1945
- className: "nice-search-overlay",
1946
- onClick: () => {
1947
- M(!1), C == null || C();
1948
- },
1949
- children: /* @__PURE__ */ e(
1950
- "div",
1951
- {
1952
- className: `nice-global-search nice-global-search--modal ${B}`,
1953
- style: v,
1954
- onClick: (p) => p.stopPropagation(),
1955
- role: "dialog",
1956
- "aria-modal": "true",
1957
- children: d
1958
- }
1959
- )
1960
- }
1961
- ) : /* @__PURE__ */ e(
1962
- "div",
1963
- {
1964
- className: `nice-global-search nice-global-search--${W} ${B}`,
1965
- style: v,
1966
- children: d
1967
- }
1968
- );
1969
- }
1970
- );
1971
- uc.displayName = "NiceGlobalSearch";
1972
- const mc = {
1973
- title: "Invoice Designer",
1974
- templates: "Templates",
1975
- elements: "Elements",
1976
- properties: "Properties",
1977
- preview: "Preview",
1978
- export: "Export",
1979
- save: "Save",
1980
- addElement: "Add Element",
1981
- deleteElement: "Delete",
1982
- duplicateElement: "Duplicate",
1983
- lockElement: "Lock",
1984
- unlockElement: "Unlock",
1985
- undo: "Undo",
1986
- redo: "Redo",
1987
- zoom: "Zoom",
1988
- grid: "Grid",
1989
- snap: "Snap",
1990
- noSelection: "Select an element to edit",
1991
- lineItems: "Line Items",
1992
- addLineItem: "Add Item",
1993
- removeLineItem: "Remove"
1994
- }, Se = {
1995
- id: "default",
1996
- name: "Standard Invoice",
1997
- category: "standard",
1998
- pageSize: "a4",
1999
- orientation: "portrait",
2000
- margins: { top: 40, right: 40, bottom: 40, left: 40 },
2001
- elements: [
2002
- { id: "logo", type: "image", x: 40, y: 40, width: 150, height: 60, field: "seller.logo" },
2003
- {
2004
- id: "seller-name",
2005
- type: "field",
2006
- x: 40,
2007
- y: 110,
2008
- width: 200,
2009
- height: 24,
2010
- field: "seller.name",
2011
- style: { fontSize: 18, fontWeight: "bold" }
2012
- },
2013
- {
2014
- id: "seller-address",
2015
- type: "field",
2016
- x: 40,
2017
- y: 140,
2018
- width: 200,
2019
- height: 60,
2020
- field: "seller.address"
2021
- },
2022
- {
2023
- id: "invoice-title",
2024
- type: "text",
2025
- x: 400,
2026
- y: 40,
2027
- width: 150,
2028
- height: 40,
2029
- content: "INVOICE",
2030
- style: { fontSize: 32, fontWeight: "bold" }
2031
- },
2032
- {
2033
- id: "invoice-number",
2034
- type: "field",
2035
- x: 400,
2036
- y: 90,
2037
- width: 150,
2038
- height: 20,
2039
- field: "invoiceNumber"
2040
- },
2041
- { id: "invoice-date", type: "field", x: 400, y: 115, width: 150, height: 20, field: "date" },
2042
- { id: "due-date", type: "field", x: 400, y: 140, width: 150, height: 20, field: "dueDate" },
2043
- {
2044
- id: "buyer-name",
2045
- type: "field",
2046
- x: 40,
2047
- y: 220,
2048
- width: 200,
2049
- height: 24,
2050
- field: "buyer.name",
2051
- style: { fontWeight: "bold" }
2052
- },
2053
- {
2054
- id: "buyer-address",
2055
- type: "field",
2056
- x: 40,
2057
- y: 250,
2058
- width: 200,
2059
- height: 60,
2060
- field: "buyer.address"
2061
- },
2062
- { id: "items-table", type: "table", x: 40, y: 340, width: 520, height: 200, field: "items" },
2063
- { id: "subtotal", type: "subtotal", x: 400, y: 560, width: 160, height: 24, field: "subtotal" },
2064
- { id: "tax", type: "tax", x: 400, y: 590, width: 160, height: 24, field: "taxAmount" },
2065
- {
2066
- id: "total",
2067
- type: "total",
2068
- x: 400,
2069
- y: 620,
2070
- width: 160,
2071
- height: 30,
2072
- field: "total",
2073
- style: { fontSize: 20, fontWeight: "bold" }
2074
- },
2075
- { id: "notes", type: "field", x: 40, y: 680, width: 300, height: 60, field: "notes" },
2076
- {
2077
- id: "bank-details",
2078
- type: "field",
2079
- x: 40,
2080
- y: 760,
2081
- width: 300,
2082
- height: 60,
2083
- field: "bankDetails"
2084
- }
2085
- ]
2086
- }, vc = [
2087
- { key: "invoiceNumber", label: "Invoice Number", type: "text" },
2088
- { key: "date", label: "Invoice Date", type: "date" },
2089
- { key: "dueDate", label: "Due Date", type: "date" },
2090
- { key: "seller.name", label: "Seller Name", type: "text" },
2091
- { key: "seller.address", label: "Seller Address", type: "text" },
2092
- { key: "seller.taxId", label: "Seller Tax ID", type: "text" },
2093
- { key: "seller.logo", label: "Seller Logo", type: "text" },
2094
- { key: "buyer.name", label: "Buyer Name", type: "text" },
2095
- { key: "buyer.address", label: "Buyer Address", type: "text" },
2096
- { key: "buyer.taxId", label: "Buyer Tax ID", type: "text" },
2097
- { key: "items", label: "Line Items", type: "text" },
2098
- { key: "subtotal", label: "Subtotal", type: "currency" },
2099
- { key: "taxAmount", label: "Tax Amount", type: "currency" },
2100
- { key: "discount", label: "Discount", type: "currency" },
2101
- { key: "total", label: "Total", type: "currency" },
2102
- { key: "currency", label: "Currency", type: "text" },
2103
- { key: "notes", label: "Notes", type: "text" },
2104
- { key: "terms", label: "Terms", type: "text" },
2105
- { key: "bankDetails", label: "Bank Details", type: "text" }
2106
- ], bc = [
2107
- { type: "text", icon: "T", label: "Text" },
2108
- { type: "field", icon: "πŸ“‹", label: "Data Field" },
2109
- { type: "image", icon: "πŸ–ΌοΈ", label: "Image" },
2110
- { type: "table", icon: "πŸ“Š", label: "Table" },
2111
- { type: "divider", icon: "β€”", label: "Divider" },
2112
- { type: "qrcode", icon: "⬛", label: "QR Code" },
2113
- { type: "barcode", icon: "|||", label: "Barcode" },
2114
- { type: "signature", icon: "✍️", label: "Signature" },
2115
- { type: "shape", icon: "⬜", label: "Shape" }
2116
- ], Ce = () => `el-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Te = (i, t) => t.split(".").reduce((l, n) => {
2117
- if (l && typeof l == "object" && n in l)
2118
- return l[n];
2119
- }, i), ye = (i, t = "USD") => new Intl.NumberFormat("en-US", { style: "currency", currency: t }).format(i), gc = oe(
2120
- function(t, l) {
2121
- const {
2122
- template: n,
2123
- data: s = {},
2124
- templates: r = [],
2125
- dataFields: h = vc,
2126
- showGrid: o = !0,
2127
- gridSize: m = 10,
2128
- snapToGrid: O = !0,
2129
- showRulers: G = !0,
2130
- readOnly: N = !1,
2131
- labels: C,
2132
- onChange: U,
2133
- onExport: P,
2134
- onSave: X,
2135
- className: q = "",
2136
- ...W
2137
- } = t, V = ge(null), B = ge(null);
2138
- Ee();
2139
- const v = pe(() => ({ ...mc, ...C }), [C]), [I, g] = S(n || Se), [k, Y] = S(null), [b, M] = S(
2140
- "elements"
2141
- ), [E, $] = S(100), [j, K] = S(o), [f, R] = S(O), [L, Z] = S([]), [F, y] = S(-1), [u, w] = S(null), [x, z] = S({ x: 0, y: 0 }), T = pe(() => I.elements.find((a) => a.id === k) || null, [I.elements, k]), ee = _(
2142
- (a) => {
2143
- Z((D) => [...D.slice(0, F + 1), a]), y((D) => D + 1);
2144
- },
2145
- [F]
2146
- ), ne = _(() => {
2147
- F > 0 && (y((a) => a - 1), g(L[F - 1]));
2148
- }, [L, F]), ie = _(() => {
2149
- F < L.length - 1 && (y((a) => a + 1), g(L[F + 1]));
2150
- }, [L, F]), ce = _(
2151
- (a) => {
2152
- g((D) => {
2153
- const J = a(D);
2154
- return ee(J), U == null || U(J), J;
2155
- });
2156
- },
2157
- [U, ee]
2158
- ), d = _(
2159
- (a) => {
2160
- if (N)
2161
- return;
2162
- const D = {
2163
- id: Ce(),
2164
- type: a,
2165
- x: 100,
2166
- y: 100,
2167
- width: a === "divider" ? 200 : 120,
2168
- height: a === "divider" ? 2 : a === "table" ? 150 : 40,
2169
- content: a === "text" ? "New Text" : void 0
2170
- };
2171
- ce((J) => ({ ...J, elements: [...J.elements, D] })), Y(D.id);
2172
- },
2173
- [N, ce]
2174
- ), p = _(
2175
- (a) => {
2176
- N || (ce((D) => ({
2177
- ...D,
2178
- elements: D.elements.filter((J) => J.id !== a)
2179
- })), k === a && Y(null));
2180
- },
2181
- [N, k, ce]
2182
- ), A = _(
2183
- (a) => {
2184
- if (N)
2185
- return;
2186
- const D = I.elements.find((Q) => Q.id === a);
2187
- if (!D)
2188
- return;
2189
- const J = {
2190
- ...D,
2191
- id: Ce(),
2192
- x: D.x + 20,
2193
- y: D.y + 20
2194
- };
2195
- ce((Q) => ({ ...Q, elements: [...Q.elements, J] })), Y(J.id);
2196
- },
2197
- [N, I.elements, ce]
2198
- ), H = _(
2199
- (a, D) => {
2200
- N || ce((J) => ({
2201
- ...J,
2202
- elements: J.elements.map((Q) => Q.id === a ? { ...Q, ...D } : Q)
2203
- }));
2204
- },
2205
- [N, ce]
2206
- ), ae = _(
2207
- (a, D) => {
2208
- if (N)
2209
- return;
2210
- const J = I.elements.find((te) => te.id === D);
2211
- if (!J || J.locked)
2212
- return;
2213
- w(D), Y(D);
2214
- const Q = a.target.getBoundingClientRect();
2215
- z({
2216
- x: a.clientX - Q.left,
2217
- y: a.clientY - Q.top
2218
- });
2219
- },
2220
- [N, I.elements]
2221
- ), he = _(
2222
- (a) => {
2223
- if (!u || !B.current)
2224
- return;
2225
- const D = B.current.getBoundingClientRect();
2226
- let J = (a.clientX - D.left - x.x) / E * 100, Q = (a.clientY - D.top - x.y) / E * 100;
2227
- f && (J = Math.round(J / m) * m, Q = Math.round(Q / m) * m), H(u, { x: J, y: Q });
2228
- },
2229
- [u, x, m, f, H, E]
2230
- ), me = _(() => {
2231
- w(null);
2232
- }, []), Fe = _(
2233
- (a) => {
2234
- const D = r.find((J) => J.id === a);
2235
- D && (g(D), ee(D), U == null || U(D));
2236
- },
2237
- [r, U, ee]
2238
- ), Ne = _(
2239
- (a) => {
2240
- P == null || P(a);
2241
- },
2242
- [P]
2243
- ), Pe = _(() => {
2244
- X == null || X(I);
2245
- }, [X, I]), Re = _(
2246
- (a) => {
2247
- if (!a.field)
2248
- return "";
2249
- const D = Te(s, a.field);
2250
- return D == null ? `{${a.field}}` : a.type === "total" || a.type === "subtotal" || a.type === "tax" ? ye(Number(D), s.currency) : String(D);
2251
- },
2252
- [s]
2253
- );
2254
- de(
2255
- l,
2256
- () => ({
2257
- getTemplate: () => I,
2258
- setTemplate: (a) => {
2259
- g(a), ee(a);
2260
- },
2261
- export: Ne,
2262
- addElement: d,
2263
- removeSelected: () => {
2264
- k && p(k);
2265
- },
2266
- undo: ne,
2267
- redo: ie,
2268
- getElement: () => V.current
2269
- }),
2270
- [I, ee, Ne, d, p, k, ne, ie]
2271
- );
2272
- const Oe = (a) => {
2273
- var xe, De;
2274
- const D = a.id === k, J = a.id === u, Q = {
2275
- position: "absolute",
2276
- left: a.x,
2277
- top: a.y,
2278
- width: a.width,
2279
- height: a.height,
2280
- ...a.style
2281
- };
2282
- let te = null;
2283
- switch (a.type) {
2284
- case "text":
2285
- te = a.content || "Text";
2286
- break;
2287
- case "field":
2288
- case "total":
2289
- case "subtotal":
2290
- case "tax":
2291
- te = Re(a);
2292
- break;
2293
- case "image": {
2294
- const le = a.field ? Te(s, a.field) : a.content;
2295
- te = le ? /* @__PURE__ */ e("img", { src: le, alt: "" }) : /* @__PURE__ */ e("span", { className: "nice-invoice-placeholder", children: "πŸ“·" });
2296
- break;
2297
- }
2298
- case "table":
2299
- te = /* @__PURE__ */ c("div", { className: "nice-invoice-table-preview", children: [
2300
- /* @__PURE__ */ c("div", { className: "nice-invoice-table-header", children: [
2301
- /* @__PURE__ */ e("span", { children: "Description" }),
2302
- /* @__PURE__ */ e("span", { children: "Qty" }),
2303
- /* @__PURE__ */ e("span", { children: "Price" }),
2304
- /* @__PURE__ */ e("span", { children: "Total" })
2305
- ] }),
2306
- (s.items || []).slice(0, 3).map((le) => /* @__PURE__ */ c("div", { className: "nice-invoice-table-row", children: [
2307
- /* @__PURE__ */ e("span", { children: le.description }),
2308
- /* @__PURE__ */ e("span", { children: le.quantity }),
2309
- /* @__PURE__ */ e("span", { children: ye(le.unitPrice, s.currency) }),
2310
- /* @__PURE__ */ e("span", { children: ye(le.total, s.currency) })
2311
- ] }, le.id)),
2312
- (((xe = s.items) == null ? void 0 : xe.length) || 0) > 3 && /* @__PURE__ */ c("div", { className: "nice-invoice-table-more", children: [
2313
- "+",
2314
- (((De = s.items) == null ? void 0 : De.length) || 0) - 3,
2315
- " more items"
2316
- ] })
2317
- ] });
2318
- break;
2319
- case "divider":
2320
- te = /* @__PURE__ */ e("hr", {});
2321
- break;
2322
- case "qrcode":
2323
- te = /* @__PURE__ */ e("div", { className: "nice-invoice-qrcode", children: "QR" });
2324
- break;
2325
- case "barcode":
2326
- te = /* @__PURE__ */ e("div", { className: "nice-invoice-barcode", children: "|||||||||||" });
2327
- break;
2328
- case "signature":
2329
- te = /* @__PURE__ */ e("div", { className: "nice-invoice-signature", children: "Signature" });
2330
- break;
2331
- case "shape":
2332
- te = null;
2333
- break;
2334
- }
2335
- return /* @__PURE__ */ c(
2336
- "div",
2337
- {
2338
- className: `nice-invoice-element nice-invoice-element--${a.type} ${D ? "nice-invoice-element--selected" : ""} ${J ? "nice-invoice-element--dragging" : ""} ${a.locked ? "nice-invoice-element--locked" : ""}`,
2339
- style: Q,
2340
- onMouseDown: (le) => ae(le, a.id),
2341
- onClick: () => Y(a.id),
2342
- children: [
2343
- te,
2344
- D && !N && /* @__PURE__ */ c("div", { className: "nice-invoice-element-handles", children: [
2345
- /* @__PURE__ */ e("div", { className: "nice-invoice-handle nice-invoice-handle--nw" }),
2346
- /* @__PURE__ */ e("div", { className: "nice-invoice-handle nice-invoice-handle--ne" }),
2347
- /* @__PURE__ */ e("div", { className: "nice-invoice-handle nice-invoice-handle--sw" }),
2348
- /* @__PURE__ */ e("div", { className: "nice-invoice-handle nice-invoice-handle--se" })
2349
- ] })
2350
- ]
2351
- },
2352
- a.id
2353
- );
2354
- };
2355
- return /* @__PURE__ */ c("div", { ref: V, className: `nice-invoice-designer ${q}`, ...W, children: [
2356
- /* @__PURE__ */ c("div", { className: "nice-invoice-toolbar", children: [
2357
- /* @__PURE__ */ c("div", { className: "nice-invoice-toolbar-left", children: [
2358
- /* @__PURE__ */ e(
2359
- "button",
2360
- {
2361
- type: "button",
2362
- className: "nice-invoice-toolbar-btn",
2363
- onClick: ne,
2364
- disabled: F <= 0,
2365
- title: v.undo,
2366
- children: "↩"
2367
- }
2368
- ),
2369
- /* @__PURE__ */ e(
2370
- "button",
2371
- {
2372
- type: "button",
2373
- className: "nice-invoice-toolbar-btn",
2374
- onClick: ie,
2375
- disabled: F >= L.length - 1,
2376
- title: v.redo,
2377
- children: "β†ͺ"
2378
- }
2379
- ),
2380
- /* @__PURE__ */ e("div", { className: "nice-invoice-toolbar-divider" }),
2381
- /* @__PURE__ */ e(
2382
- "button",
2383
- {
2384
- type: "button",
2385
- className: `nice-invoice-toolbar-btn ${j ? "nice-invoice-toolbar-btn--active" : ""}`,
2386
- onClick: () => K(!j),
2387
- title: v.grid,
2388
- children: "⊞"
2389
- }
2390
- ),
2391
- /* @__PURE__ */ e(
2392
- "button",
2393
- {
2394
- type: "button",
2395
- className: `nice-invoice-toolbar-btn ${f ? "nice-invoice-toolbar-btn--active" : ""}`,
2396
- onClick: () => R(!f),
2397
- title: v.snap,
2398
- children: "βŒ–"
2399
- }
2400
- ),
2401
- /* @__PURE__ */ e("div", { className: "nice-invoice-toolbar-divider" }),
2402
- /* @__PURE__ */ c(
2403
- "select",
2404
- {
2405
- className: "nice-invoice-zoom-select",
2406
- value: E,
2407
- onChange: (a) => $(Number(a.target.value)),
2408
- children: [
2409
- /* @__PURE__ */ e("option", { value: 50, children: "50%" }),
2410
- /* @__PURE__ */ e("option", { value: 75, children: "75%" }),
2411
- /* @__PURE__ */ e("option", { value: 100, children: "100%" }),
2412
- /* @__PURE__ */ e("option", { value: 125, children: "125%" }),
2413
- /* @__PURE__ */ e("option", { value: 150, children: "150%" })
2414
- ]
2415
- }
2416
- )
2417
- ] }),
2418
- /* @__PURE__ */ c("div", { className: "nice-invoice-toolbar-right", children: [
2419
- /* @__PURE__ */ e(
2420
- "button",
2421
- {
2422
- type: "button",
2423
- className: "nice-invoice-toolbar-btn nice-invoice-toolbar-btn--primary",
2424
- onClick: () => Ne("pdf"),
2425
- children: "PDF"
2426
- }
2427
- ),
2428
- /* @__PURE__ */ e(
2429
- "button",
2430
- {
2431
- type: "button",
2432
- className: "nice-invoice-toolbar-btn",
2433
- onClick: () => Ne("print"),
2434
- children: "πŸ–¨οΈ"
2435
- }
2436
- ),
2437
- !N && /* @__PURE__ */ c(
2438
- "button",
2439
- {
2440
- type: "button",
2441
- className: "nice-invoice-toolbar-btn nice-invoice-toolbar-btn--success",
2442
- onClick: Pe,
2443
- children: [
2444
- "πŸ’Ύ ",
2445
- v.save
2446
- ]
2447
- }
2448
- )
2449
- ] })
2450
- ] }),
2451
- /* @__PURE__ */ c("div", { className: "nice-invoice-main", children: [
2452
- /* @__PURE__ */ c("div", { className: "nice-invoice-sidebar", children: [
2453
- /* @__PURE__ */ c("div", { className: "nice-invoice-sidebar-tabs", children: [
2454
- /* @__PURE__ */ e(
2455
- "button",
2456
- {
2457
- type: "button",
2458
- className: `nice-invoice-sidebar-tab ${b === "templates" ? "nice-invoice-sidebar-tab--active" : ""}`,
2459
- onClick: () => M("templates"),
2460
- children: "πŸ“„"
2461
- }
2462
- ),
2463
- /* @__PURE__ */ e(
2464
- "button",
2465
- {
2466
- type: "button",
2467
- className: `nice-invoice-sidebar-tab ${b === "elements" ? "nice-invoice-sidebar-tab--active" : ""}`,
2468
- onClick: () => M("elements"),
2469
- children: "⬛"
2470
- }
2471
- ),
2472
- /* @__PURE__ */ e(
2473
- "button",
2474
- {
2475
- type: "button",
2476
- className: `nice-invoice-sidebar-tab ${b === "properties" ? "nice-invoice-sidebar-tab--active" : ""}`,
2477
- onClick: () => M("properties"),
2478
- children: "βš™οΈ"
2479
- }
2480
- )
2481
- ] }),
2482
- /* @__PURE__ */ c("div", { className: "nice-invoice-sidebar-content", children: [
2483
- b === "templates" && /* @__PURE__ */ c("div", { className: "nice-invoice-panel", children: [
2484
- /* @__PURE__ */ e("h3", { className: "nice-invoice-panel-title", children: v.templates }),
2485
- /* @__PURE__ */ e("div", { className: "nice-invoice-templates-grid", children: [Se, ...r].map((a) => /* @__PURE__ */ c(
2486
- "button",
2487
- {
2488
- type: "button",
2489
- className: `nice-invoice-template-card ${a.id === I.id ? "nice-invoice-template-card--active" : ""}`,
2490
- onClick: () => Fe(a.id),
2491
- children: [
2492
- /* @__PURE__ */ e("div", { className: "nice-invoice-template-preview", children: a.thumbnail ? /* @__PURE__ */ e("img", { src: a.thumbnail, alt: a.name }) : /* @__PURE__ */ e("div", { className: "nice-invoice-template-placeholder", children: "πŸ“„" }) }),
2493
- /* @__PURE__ */ e("span", { className: "nice-invoice-template-name", children: a.name })
2494
- ]
2495
- },
2496
- a.id
2497
- )) })
2498
- ] }),
2499
- b === "elements" && /* @__PURE__ */ c("div", { className: "nice-invoice-panel", children: [
2500
- /* @__PURE__ */ e("h3", { className: "nice-invoice-panel-title", children: v.elements }),
2501
- /* @__PURE__ */ e("div", { className: "nice-invoice-elements-grid", children: bc.map((a) => /* @__PURE__ */ c(
2502
- "button",
2503
- {
2504
- type: "button",
2505
- className: "nice-invoice-element-btn",
2506
- onClick: () => d(a.type),
2507
- disabled: N,
2508
- children: [
2509
- /* @__PURE__ */ e("span", { className: "nice-invoice-element-icon", children: a.icon }),
2510
- /* @__PURE__ */ e("span", { className: "nice-invoice-element-label", children: a.label })
2511
- ]
2512
- },
2513
- a.type
2514
- )) }),
2515
- /* @__PURE__ */ e("h4", { className: "nice-invoice-panel-subtitle", children: "Data Fields" }),
2516
- /* @__PURE__ */ e("div", { className: "nice-invoice-fields-list", children: h.map((a) => /* @__PURE__ */ e(
2517
- "button",
2518
- {
2519
- type: "button",
2520
- className: "nice-invoice-field-btn",
2521
- onClick: () => {
2522
- T && H(T.id, { field: a.key });
2523
- },
2524
- disabled: !T || N,
2525
- children: a.label
2526
- },
2527
- a.key
2528
- )) })
2529
- ] }),
2530
- b === "properties" && /* @__PURE__ */ c("div", { className: "nice-invoice-panel", children: [
2531
- /* @__PURE__ */ e("h3", { className: "nice-invoice-panel-title", children: v.properties }),
2532
- T ? /* @__PURE__ */ c("div", { className: "nice-invoice-properties", children: [
2533
- /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2534
- /* @__PURE__ */ e("label", { children: "Type" }),
2535
- /* @__PURE__ */ e("input", { type: "text", value: T.type, readOnly: !0 })
2536
- ] }),
2537
- /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2538
- /* @__PURE__ */ e("label", { children: "X" }),
2539
- /* @__PURE__ */ e(
2540
- "input",
2541
- {
2542
- type: "number",
2543
- value: T.x,
2544
- onChange: (a) => H(T.id, { x: Number(a.target.value) }),
2545
- disabled: N
2546
- }
2547
- )
2548
- ] }),
2549
- /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2550
- /* @__PURE__ */ e("label", { children: "Y" }),
2551
- /* @__PURE__ */ e(
2552
- "input",
2553
- {
2554
- type: "number",
2555
- value: T.y,
2556
- onChange: (a) => H(T.id, { y: Number(a.target.value) }),
2557
- disabled: N
2558
- }
2559
- )
2560
- ] }),
2561
- /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2562
- /* @__PURE__ */ e("label", { children: "Width" }),
2563
- /* @__PURE__ */ e(
2564
- "input",
2565
- {
2566
- type: "number",
2567
- value: T.width,
2568
- onChange: (a) => H(T.id, { width: Number(a.target.value) }),
2569
- disabled: N
2570
- }
2571
- )
2572
- ] }),
2573
- /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2574
- /* @__PURE__ */ e("label", { children: "Height" }),
2575
- /* @__PURE__ */ e(
2576
- "input",
2577
- {
2578
- type: "number",
2579
- value: T.height,
2580
- onChange: (a) => H(T.id, { height: Number(a.target.value) }),
2581
- disabled: N
2582
- }
2583
- )
2584
- ] }),
2585
- T.type === "text" && /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2586
- /* @__PURE__ */ e("label", { children: "Content" }),
2587
- /* @__PURE__ */ e(
2588
- "input",
2589
- {
2590
- type: "text",
2591
- value: T.content || "",
2592
- onChange: (a) => H(T.id, { content: a.target.value }),
2593
- disabled: N
2594
- }
2595
- )
2596
- ] }),
2597
- T.field !== void 0 && /* @__PURE__ */ c("div", { className: "nice-invoice-property", children: [
2598
- /* @__PURE__ */ e("label", { children: "Field" }),
2599
- /* @__PURE__ */ c(
2600
- "select",
2601
- {
2602
- value: T.field || "",
2603
- onChange: (a) => H(T.id, { field: a.target.value }),
2604
- disabled: N,
2605
- children: [
2606
- /* @__PURE__ */ e("option", { value: "", children: "None" }),
2607
- h.map((a) => /* @__PURE__ */ e("option", { value: a.key, children: a.label }, a.key))
2608
- ]
2609
- }
2610
- )
2611
- ] }),
2612
- /* @__PURE__ */ c("div", { className: "nice-invoice-property-actions", children: [
2613
- /* @__PURE__ */ e(
2614
- "button",
2615
- {
2616
- type: "button",
2617
- onClick: () => A(T.id),
2618
- disabled: N,
2619
- children: v.duplicateElement
2620
- }
2621
- ),
2622
- /* @__PURE__ */ e(
2623
- "button",
2624
- {
2625
- type: "button",
2626
- onClick: () => H(T.id, { locked: !T.locked }),
2627
- disabled: N,
2628
- children: T.locked ? v.unlockElement : v.lockElement
2629
- }
2630
- ),
2631
- /* @__PURE__ */ e(
2632
- "button",
2633
- {
2634
- type: "button",
2635
- className: "nice-invoice-btn--danger",
2636
- onClick: () => p(T.id),
2637
- disabled: N,
2638
- children: v.deleteElement
2639
- }
2640
- )
2641
- ] })
2642
- ] }) : /* @__PURE__ */ e("p", { className: "nice-invoice-no-selection", children: v.noSelection })
2643
- ] })
2644
- ] })
2645
- ] }),
2646
- /* @__PURE__ */ c("div", { className: "nice-invoice-canvas-area", children: [
2647
- G && /* @__PURE__ */ c(re, { children: [
2648
- /* @__PURE__ */ e("div", { className: "nice-invoice-ruler nice-invoice-ruler--horizontal", children: Array.from({ length: 60 }, (a, D) => /* @__PURE__ */ e(
2649
- "span",
2650
- {
2651
- className: "nice-invoice-ruler-mark",
2652
- style: { left: D * 10 * (E / 100) },
2653
- children: D % 5 === 0 && /* @__PURE__ */ e("span", { className: "nice-invoice-ruler-label", children: D * 10 })
2654
- },
2655
- D
2656
- )) }),
2657
- /* @__PURE__ */ e("div", { className: "nice-invoice-ruler nice-invoice-ruler--vertical", children: Array.from({ length: 85 }, (a, D) => /* @__PURE__ */ e(
2658
- "span",
2659
- {
2660
- className: "nice-invoice-ruler-mark",
2661
- style: { top: D * 10 * (E / 100) },
2662
- children: D % 5 === 0 && /* @__PURE__ */ e("span", { className: "nice-invoice-ruler-label", children: D * 10 })
2663
- },
2664
- D
2665
- )) })
2666
- ] }),
2667
- /* @__PURE__ */ e(
2668
- "div",
2669
- {
2670
- ref: B,
2671
- className: `nice-invoice-canvas ${j ? "nice-invoice-canvas--grid" : ""}`,
2672
- style: {
2673
- width: I.orientation === "portrait" ? 595 : 842,
2674
- height: I.orientation === "portrait" ? 842 : 595,
2675
- transform: `scale(${E / 100})`,
2676
- transformOrigin: "top left",
2677
- backgroundSize: `${m}px ${m}px`
2678
- },
2679
- onMouseMove: he,
2680
- onMouseUp: me,
2681
- onMouseLeave: me,
2682
- onClick: () => Y(null),
2683
- children: I.elements.map((a) => Oe(a))
2684
- }
2685
- )
2686
- ] })
2687
- ] })
2688
- ] });
2689
- }
2690
- );
2691
- gc.displayName = "NiceInvoiceDesigner";
2692
- const ve = {
2693
- title: "Access Log",
2694
- filters: "Filters",
2695
- search: "Search users, IPs...",
2696
- export: "Export",
2697
- refresh: "Refresh",
2698
- details: "Details",
2699
- stats: "Statistics",
2700
- map: "Geographic Distribution",
2701
- timeline: "Timeline",
2702
- showMore: "Show More",
2703
- noResults: "No access logs found",
2704
- eventTypes: {
2705
- login_success: "Login Success",
2706
- login_failed: "Login Failed",
2707
- logout: "Logout",
2708
- password_change: "Password Change",
2709
- password_reset: "Password Reset",
2710
- mfa_enabled: "MFA Enabled",
2711
- mfa_disabled: "MFA Disabled",
2712
- mfa_challenged: "MFA Challenge",
2713
- permission_change: "Permission Change",
2714
- session_expired: "Session Expired",
2715
- account_locked: "Account Locked",
2716
- account_unlocked: "Account Unlocked",
2717
- api_key_created: "API Key Created",
2718
- api_key_revoked: "API Key Revoked",
2719
- token_refresh: "Token Refresh",
2720
- suspicious_activity: "Suspicious Activity"
2721
- },
2722
- riskLevels: {
2723
- low: "Low",
2724
- medium: "Medium",
2725
- high: "High",
2726
- critical: "Critical"
2727
- },
2728
- deviceTypes: {
2729
- desktop: "Desktop",
2730
- mobile: "Mobile",
2731
- tablet: "Tablet",
2732
- unknown: "Unknown"
2733
- },
2734
- columns: {
2735
- timestamp: "Time",
2736
- user: "User",
2737
- event: "Event",
2738
- ip: "IP Address",
2739
- location: "Location",
2740
- device: "Device",
2741
- risk: "Risk",
2742
- status: "Status"
2743
- }
2744
- }, ke = {
2745
- login_success: "βœ“",
2746
- login_failed: "βœ—",
2747
- logout: "β†—",
2748
- password_change: "πŸ”‘",
2749
- password_reset: "πŸ”„",
2750
- mfa_enabled: "πŸ›‘οΈ",
2751
- mfa_disabled: "⚠️",
2752
- mfa_challenged: "πŸ“±",
2753
- permission_change: "πŸ‘€",
2754
- session_expired: "⏰",
2755
- account_locked: "πŸ”’",
2756
- account_unlocked: "πŸ”“",
2757
- api_key_created: "πŸ”",
2758
- api_key_revoked: "❌",
2759
- token_refresh: "πŸ”ƒ",
2760
- suspicious_activity: "⚑"
2761
- }, be = {
2762
- low: "var(--color-success, #22c55e)",
2763
- medium: "var(--color-warning, #f59e0b)",
2764
- high: "var(--color-error, #ef4444)",
2765
- critical: "var(--color-accent-hover, #7c3aed)"
2766
- }, Ie = {
2767
- desktop: "πŸ–₯️",
2768
- mobile: "πŸ“±",
2769
- tablet: "πŸ“Ÿ",
2770
- unknown: "❓"
2771
- }, _e = (i) => (typeof i == "string" ? new Date(i) : i).toLocaleString("en-US", {
2772
- month: "short",
2773
- day: "numeric",
2774
- hour: "2-digit",
2775
- minute: "2-digit",
2776
- second: "2-digit"
2777
- }), Le = (i) => {
2778
- if (!i)
2779
- return "Unknown";
2780
- const t = [];
2781
- return i.city && t.push(i.city), i.country && t.push(i.country), t.length > 0 ? t.join(", ") : "Unknown";
2782
- }, Nc = (i) => {
2783
- if (!i)
2784
- return "Unknown";
2785
- const t = [];
2786
- return i.browser && t.push(i.browser), i.os && t.push(i.os), t.length > 0 ? t.join(" / ") : i.type;
2787
- }, Ae = (i) => i >= 80 ? be.critical : i >= 60 ? be.high : i >= 40 ? be.medium : be.low, fc = (i, t) => {
2788
- var l, n, s, r, h;
2789
- if (t.startDate) {
2790
- const o = typeof t.startDate == "string" ? new Date(t.startDate) : t.startDate;
2791
- if ((typeof i.timestamp == "string" ? new Date(i.timestamp) : i.timestamp) < o)
2792
- return !1;
2793
- }
2794
- if (t.endDate) {
2795
- const o = typeof t.endDate == "string" ? new Date(t.endDate) : t.endDate;
2796
- if ((typeof i.timestamp == "string" ? new Date(i.timestamp) : i.timestamp) > o)
2797
- return !1;
2798
- }
2799
- if ((l = t.eventTypes) != null && l.length && !t.eventTypes.includes(i.eventType) || (n = t.riskLevels) != null && n.length && !t.riskLevels.includes(i.riskLevel) || t.userId && i.userId !== t.userId || t.ipAddress && !i.ipAddress.includes(t.ipAddress) || t.country && ((s = i.location) == null ? void 0 : s.country) !== t.country || t.successOnly && !i.success || t.failedOnly && i.success)
2800
- return !1;
2801
- if (t.searchQuery) {
2802
- const o = t.searchQuery.toLowerCase();
2803
- if (![
2804
- i.userName,
2805
- i.userEmail,
2806
- i.userId,
2807
- i.ipAddress,
2808
- (r = i.location) == null ? void 0 : r.city,
2809
- (h = i.location) == null ? void 0 : h.country
2810
- ].filter(Boolean).join(" ").toLowerCase().includes(o))
2811
- return !1;
2812
- }
2813
- return !0;
2814
- }, yc = oe(
2815
- function(t, l) {
2816
- var ie, ce;
2817
- const {
2818
- entries: n,
2819
- filter: s = {},
2820
- stats: r,
2821
- realtime: h = !1,
2822
- pollingInterval: o = 3e4,
2823
- showMap: m = !1,
2824
- showStats: O = !0,
2825
- showDetails: G = !0,
2826
- pageSize: N = 50,
2827
- labels: C,
2828
- loading: U = !1,
2829
- onFilterChange: P,
2830
- onExport: X,
2831
- onEntrySelect: q,
2832
- onBlockIP: W,
2833
- onRefresh: V,
2834
- className: B = "",
2835
- ...v
2836
- } = t, I = ge(null);
2837
- Ee();
2838
- const g = pe(
2839
- () => ({
2840
- ...ve,
2841
- ...C,
2842
- eventTypes: { ...ve.eventTypes, ...C == null ? void 0 : C.eventTypes },
2843
- riskLevels: { ...ve.riskLevels, ...C == null ? void 0 : C.riskLevels },
2844
- deviceTypes: { ...ve.deviceTypes, ...C == null ? void 0 : C.deviceTypes },
2845
- columns: { ...ve.columns, ...C == null ? void 0 : C.columns }
2846
- }),
2847
- [C]
2848
- ), [k, Y] = S(s), [b, M] = S(null), [E, $] = S(N), [j, K] = S(!1), [f, R] = S("table"), L = pe(() => n.filter((d) => fc(d, k)), [n, k]), Z = pe(() => L.slice(0, E), [L, E]), F = pe(() => {
2849
- if (r)
2850
- return r;
2851
- const d = new Set(n.map((A) => A.ipAddress)), p = new Set(n.map((A) => {
2852
- var H;
2853
- return (H = A.location) == null ? void 0 : H.country;
2854
- }).filter(Boolean));
2855
- return {
2856
- totalEvents: n.length,
2857
- successfulLogins: n.filter((A) => A.eventType === "login_success").length,
2858
- failedLogins: n.filter((A) => A.eventType === "login_failed").length,
2859
- uniqueIPs: d.size,
2860
- uniqueCountries: p.size,
2861
- highRiskEvents: n.filter((A) => A.riskLevel === "high" || A.riskLevel === "critical").length,
2862
- suspiciousActivities: n.filter((A) => A.eventType === "suspicious_activity").length
2863
- };
2864
- }, [n, r]), y = _(
2865
- (d) => {
2866
- const p = { ...k, ...d };
2867
- Y(p), $(N), P == null || P(p);
2868
- },
2869
- [k, P, N]
2870
- ), u = _(() => {
2871
- Y({}), $(N), P == null || P({});
2872
- }, [P, N]), w = _(
2873
- (d) => {
2874
- M(d), q == null || q(d);
2875
- },
2876
- [q]
2877
- ), x = _(
2878
- (d) => {
2879
- X == null || X(d);
2880
- },
2881
- [X]
2882
- ), z = _(() => {
2883
- V == null || V();
2884
- }, [V]), T = _(() => {
2885
- $((d) => d + N);
2886
- }, [N]);
2887
- de(
2888
- l,
2889
- () => ({
2890
- getFilter: () => k,
2891
- applyFilter: y,
2892
- clearFilters: u,
2893
- export: x,
2894
- refresh: z,
2895
- getSelectedEntry: () => b,
2896
- getElement: () => I.current
2897
- }),
2898
- [k, y, u, x, z, b]
2899
- );
2900
- const ee = (d) => {
2901
- var p, A;
2902
- return /* @__PURE__ */ c(
2903
- "tr",
2904
- {
2905
- className: `nice-accesslog-row ${(b == null ? void 0 : b.id) === d.id ? "nice-accesslog-row--selected" : ""} ${d.success ? "" : "nice-accesslog-row--failed"}`,
2906
- onClick: () => w(d),
2907
- children: [
2908
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--timestamp", children: _e(d.timestamp) }),
2909
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--user", children: /* @__PURE__ */ c("div", { className: "nice-accesslog-user", children: [
2910
- /* @__PURE__ */ e("span", { className: "nice-accesslog-username", children: d.userName || d.userId }),
2911
- d.userEmail && /* @__PURE__ */ e("span", { className: "nice-accesslog-email", children: d.userEmail })
2912
- ] }) }),
2913
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--event", children: /* @__PURE__ */ c("span", { className: `nice-accesslog-event nice-accesslog-event--${d.eventType}`, children: [
2914
- /* @__PURE__ */ e("span", { className: "nice-accesslog-event-icon", children: ke[d.eventType] }),
2915
- g.eventTypes[d.eventType]
2916
- ] }) }),
2917
- /* @__PURE__ */ c("td", { className: "nice-accesslog-cell nice-accesslog-cell--ip", children: [
2918
- /* @__PURE__ */ e("span", { className: "nice-accesslog-ip", children: d.ipAddress }),
2919
- W && /* @__PURE__ */ e(
2920
- "button",
2921
- {
2922
- type: "button",
2923
- className: "nice-accesslog-block-btn",
2924
- onClick: (H) => {
2925
- H.stopPropagation(), W(d.ipAddress);
2926
- },
2927
- title: "Block IP",
2928
- children: "🚫"
2929
- }
2930
- )
2931
- ] }),
2932
- /* @__PURE__ */ c("td", { className: "nice-accesslog-cell nice-accesslog-cell--location", children: [
2933
- ((p = d.location) == null ? void 0 : p.countryCode) && /* @__PURE__ */ e("span", { className: "nice-accesslog-flag", children: "🏳️" }),
2934
- Le(d.location)
2935
- ] }),
2936
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--device", children: /* @__PURE__ */ c("span", { className: "nice-accesslog-device", children: [
2937
- Ie[((A = d.device) == null ? void 0 : A.type) || "unknown"],
2938
- Nc(d.device)
2939
- ] }) }),
2940
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--risk", children: /* @__PURE__ */ c(
2941
- "span",
2942
- {
2943
- className: `nice-accesslog-risk nice-accesslog-risk--${d.riskLevel}`,
2944
- style: { "--risk-color": Ae(d.riskScore) },
2945
- children: [
2946
- /* @__PURE__ */ e("span", { className: "nice-accesslog-risk-score", children: d.riskScore }),
2947
- /* @__PURE__ */ e("span", { className: "nice-accesslog-risk-label", children: g.riskLevels[d.riskLevel] })
2948
- ]
2949
- }
2950
- ) }),
2951
- /* @__PURE__ */ e("td", { className: "nice-accesslog-cell nice-accesslog-cell--status", children: /* @__PURE__ */ e(
2952
- "span",
2953
- {
2954
- className: `nice-accesslog-status ${d.success ? "nice-accesslog-status--success" : "nice-accesslog-status--failed"}`,
2955
- children: d.success ? "βœ“" : "βœ—"
2956
- }
2957
- ) })
2958
- ]
2959
- },
2960
- d.id
2961
- );
2962
- }, ne = (d) => /* @__PURE__ */ c(
2963
- "div",
2964
- {
2965
- className: `nice-accesslog-timeline-item nice-accesslog-timeline-item--${d.riskLevel}`,
2966
- onClick: () => w(d),
2967
- children: [
2968
- /* @__PURE__ */ e(
2969
- "div",
2970
- {
2971
- className: "nice-accesslog-timeline-marker",
2972
- style: { background: be[d.riskLevel] }
2973
- }
2974
- ),
2975
- /* @__PURE__ */ c("div", { className: "nice-accesslog-timeline-content", children: [
2976
- /* @__PURE__ */ c("div", { className: "nice-accesslog-timeline-header", children: [
2977
- /* @__PURE__ */ c("span", { className: "nice-accesslog-timeline-event", children: [
2978
- ke[d.eventType],
2979
- " ",
2980
- g.eventTypes[d.eventType]
2981
- ] }),
2982
- /* @__PURE__ */ e("span", { className: "nice-accesslog-timeline-time", children: _e(d.timestamp) })
2983
- ] }),
2984
- /* @__PURE__ */ c("div", { className: "nice-accesslog-timeline-details", children: [
2985
- /* @__PURE__ */ e("span", { children: d.userName || d.userId }),
2986
- /* @__PURE__ */ e("span", { children: "β€’" }),
2987
- /* @__PURE__ */ e("span", { children: d.ipAddress }),
2988
- /* @__PURE__ */ e("span", { children: "β€’" }),
2989
- /* @__PURE__ */ e("span", { children: Le(d.location) })
2990
- ] }),
2991
- d.flags && d.flags.length > 0 && /* @__PURE__ */ e("div", { className: "nice-accesslog-timeline-flags", children: d.flags.map((p, A) => /* @__PURE__ */ e("span", { className: "nice-accesslog-flag-badge", children: p }, A)) })
2992
- ] })
2993
- ]
2994
- },
2995
- d.id
2996
- );
2997
- return /* @__PURE__ */ c("div", { ref: I, className: `nice-accesslog ${B}`, ...v, children: [
2998
- /* @__PURE__ */ c("div", { className: "nice-accesslog-header", children: [
2999
- /* @__PURE__ */ c("div", { className: "nice-accesslog-header-left", children: [
3000
- /* @__PURE__ */ e("h2", { className: "nice-accesslog-title", children: g.title }),
3001
- h && /* @__PURE__ */ e("span", { className: "nice-accesslog-realtime-badge", children: "● Live" })
3002
- ] }),
3003
- /* @__PURE__ */ c("div", { className: "nice-accesslog-header-actions", children: [
3004
- /* @__PURE__ */ c(
3005
- "button",
3006
- {
3007
- type: "button",
3008
- className: "nice-accesslog-btn",
3009
- onClick: z,
3010
- disabled: U,
3011
- children: [
3012
- "πŸ”„ ",
3013
- g.refresh
3014
- ]
3015
- }
3016
- ),
3017
- /* @__PURE__ */ c("div", { className: "nice-accesslog-export-dropdown", children: [
3018
- /* @__PURE__ */ c("button", { type: "button", className: "nice-accesslog-btn", children: [
3019
- "πŸ“₯ ",
3020
- g.export
3021
- ] }),
3022
- /* @__PURE__ */ c("div", { className: "nice-accesslog-export-menu", children: [
3023
- /* @__PURE__ */ e("button", { onClick: () => x("csv"), children: "CSV" }),
3024
- /* @__PURE__ */ e("button", { onClick: () => x("json"), children: "JSON" }),
3025
- /* @__PURE__ */ e("button", { onClick: () => x("pdf"), children: "PDF" })
3026
- ] })
3027
- ] })
3028
- ] })
3029
- ] }),
3030
- O && /* @__PURE__ */ c("div", { className: "nice-accesslog-stats", children: [
3031
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat", children: [
3032
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.totalEvents }),
3033
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "Total Events" })
3034
- ] }),
3035
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat nice-accesslog-stat--success", children: [
3036
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.successfulLogins }),
3037
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "Successful" })
3038
- ] }),
3039
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat nice-accesslog-stat--failed", children: [
3040
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.failedLogins }),
3041
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "Failed" })
3042
- ] }),
3043
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat", children: [
3044
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.uniqueIPs }),
3045
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "Unique IPs" })
3046
- ] }),
3047
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat", children: [
3048
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.uniqueCountries }),
3049
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "Countries" })
3050
- ] }),
3051
- /* @__PURE__ */ c("div", { className: "nice-accesslog-stat nice-accesslog-stat--warning", children: [
3052
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-value", children: F.highRiskEvents }),
3053
- /* @__PURE__ */ e("span", { className: "nice-accesslog-stat-label", children: "High Risk" })
3054
- ] })
3055
- ] }),
3056
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filters", children: [
3057
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filters-row", children: [
3058
- /* @__PURE__ */ c("div", { className: "nice-accesslog-search", children: [
3059
- /* @__PURE__ */ e("span", { className: "nice-accesslog-search-icon", children: "πŸ”" }),
3060
- /* @__PURE__ */ e(
3061
- "input",
3062
- {
3063
- type: "text",
3064
- placeholder: g.search,
3065
- value: k.searchQuery || "",
3066
- onChange: (d) => y({ searchQuery: d.target.value })
3067
- }
3068
- )
3069
- ] }),
3070
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filter-quick", children: [
3071
- /* @__PURE__ */ e(
3072
- "button",
3073
- {
3074
- type: "button",
3075
- className: `nice-accesslog-filter-chip ${k.failedOnly ? "nice-accesslog-filter-chip--active" : ""}`,
3076
- onClick: () => y({ failedOnly: !k.failedOnly, successOnly: !1 }),
3077
- children: "Failed Only"
3078
- }
3079
- ),
3080
- /* @__PURE__ */ e(
3081
- "button",
3082
- {
3083
- type: "button",
3084
- className: `nice-accesslog-filter-chip ${(ie = k.riskLevels) != null && ie.includes("high") || (ce = k.riskLevels) != null && ce.includes("critical") ? "nice-accesslog-filter-chip--active" : ""}`,
3085
- onClick: () => {
3086
- var d;
3087
- return y({
3088
- riskLevels: (d = k.riskLevels) != null && d.includes("high") ? [] : ["high", "critical"]
3089
- });
3090
- },
3091
- children: "High Risk"
3092
- }
3093
- ),
3094
- /* @__PURE__ */ e(
3095
- "button",
3096
- {
3097
- type: "button",
3098
- className: "nice-accesslog-filter-toggle",
3099
- onClick: () => K(!j),
3100
- children: j ? "βˆ’ Less" : "+ More"
3101
- }
3102
- )
3103
- ] })
3104
- ] }),
3105
- j && /* @__PURE__ */ c("div", { className: "nice-accesslog-filters-expanded", children: [
3106
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filter-group", children: [
3107
- /* @__PURE__ */ e("label", { children: "Event Type" }),
3108
- /* @__PURE__ */ e(
3109
- "select",
3110
- {
3111
- multiple: !0,
3112
- value: k.eventTypes || [],
3113
- onChange: (d) => {
3114
- const p = Array.from(
3115
- d.target.selectedOptions,
3116
- (A) => A.value
3117
- );
3118
- y({ eventTypes: p.length ? p : void 0 });
3119
- },
3120
- children: Object.entries(g.eventTypes).map(([d, p]) => /* @__PURE__ */ e("option", { value: d, children: p }, d))
3121
- }
3122
- )
3123
- ] }),
3124
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filter-group", children: [
3125
- /* @__PURE__ */ e("label", { children: "Date Range" }),
3126
- /* @__PURE__ */ c("div", { className: "nice-accesslog-date-range", children: [
3127
- /* @__PURE__ */ e(
3128
- "input",
3129
- {
3130
- type: "date",
3131
- value: k.startDate ? new Date(k.startDate).toISOString().split("T")[0] : "",
3132
- onChange: (d) => y({ startDate: d.target.value || void 0 })
3133
- }
3134
- ),
3135
- /* @__PURE__ */ e("span", { children: "to" }),
3136
- /* @__PURE__ */ e(
3137
- "input",
3138
- {
3139
- type: "date",
3140
- value: k.endDate ? new Date(k.endDate).toISOString().split("T")[0] : "",
3141
- onChange: (d) => y({ endDate: d.target.value || void 0 })
3142
- }
3143
- )
3144
- ] })
3145
- ] }),
3146
- /* @__PURE__ */ c("div", { className: "nice-accesslog-filter-group", children: [
3147
- /* @__PURE__ */ e("label", { children: "IP Address" }),
3148
- /* @__PURE__ */ e(
3149
- "input",
3150
- {
3151
- type: "text",
3152
- placeholder: "e.g., 192.168",
3153
- value: k.ipAddress || "",
3154
- onChange: (d) => y({ ipAddress: d.target.value || void 0 })
3155
- }
3156
- )
3157
- ] }),
3158
- /* @__PURE__ */ e("button", { type: "button", className: "nice-accesslog-clear-filters", onClick: u, children: "Clear All Filters" })
3159
- ] })
3160
- ] }),
3161
- /* @__PURE__ */ c("div", { className: "nice-accesslog-tabs", children: [
3162
- /* @__PURE__ */ e(
3163
- "button",
3164
- {
3165
- type: "button",
3166
- className: `nice-accesslog-tab ${f === "table" ? "nice-accesslog-tab--active" : ""}`,
3167
- onClick: () => R("table"),
3168
- children: "πŸ“Š Table"
3169
- }
3170
- ),
3171
- /* @__PURE__ */ c(
3172
- "button",
3173
- {
3174
- type: "button",
3175
- className: `nice-accesslog-tab ${f === "timeline" ? "nice-accesslog-tab--active" : ""}`,
3176
- onClick: () => R("timeline"),
3177
- children: [
3178
- "πŸ“… ",
3179
- g.timeline
3180
- ]
3181
- }
3182
- ),
3183
- m && /* @__PURE__ */ c(
3184
- "button",
3185
- {
3186
- type: "button",
3187
- className: `nice-accesslog-tab ${f === "map" ? "nice-accesslog-tab--active" : ""}`,
3188
- onClick: () => R("map"),
3189
- children: [
3190
- "πŸ—ΊοΈ ",
3191
- g.map
3192
- ]
3193
- }
3194
- ),
3195
- /* @__PURE__ */ c("span", { className: "nice-accesslog-count", children: [
3196
- L.length,
3197
- " entries"
3198
- ] })
3199
- ] }),
3200
- /* @__PURE__ */ e("div", { className: "nice-accesslog-content", children: U ? /* @__PURE__ */ c("div", { className: "nice-accesslog-loading", children: [
3201
- /* @__PURE__ */ e("div", { className: "nice-accesslog-spinner" }),
3202
- "Loading access logs..."
3203
- ] }) : L.length === 0 ? /* @__PURE__ */ c("div", { className: "nice-accesslog-empty", children: [
3204
- /* @__PURE__ */ e("span", { className: "nice-accesslog-empty-icon", children: "πŸ”" }),
3205
- /* @__PURE__ */ e("span", { children: g.noResults })
3206
- ] }) : /* @__PURE__ */ c(re, { children: [
3207
- f === "table" && /* @__PURE__ */ e("div", { className: "nice-accesslog-table-wrapper", children: /* @__PURE__ */ c("table", { className: "nice-accesslog-table", children: [
3208
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ c("tr", { children: [
3209
- /* @__PURE__ */ e("th", { children: g.columns.timestamp }),
3210
- /* @__PURE__ */ e("th", { children: g.columns.user }),
3211
- /* @__PURE__ */ e("th", { children: g.columns.event }),
3212
- /* @__PURE__ */ e("th", { children: g.columns.ip }),
3213
- /* @__PURE__ */ e("th", { children: g.columns.location }),
3214
- /* @__PURE__ */ e("th", { children: g.columns.device }),
3215
- /* @__PURE__ */ e("th", { children: g.columns.risk }),
3216
- /* @__PURE__ */ e("th", { children: g.columns.status })
3217
- ] }) }),
3218
- /* @__PURE__ */ e("tbody", { children: Z.map(ee) })
3219
- ] }) }),
3220
- f === "timeline" && /* @__PURE__ */ e("div", { className: "nice-accesslog-timeline", children: Z.map(ne) }),
3221
- f === "map" && /* @__PURE__ */ e("div", { className: "nice-accesslog-map", children: /* @__PURE__ */ e("div", { className: "nice-accesslog-map-placeholder", children: "πŸ—ΊοΈ Geographic visualization would render here" }) }),
3222
- E < L.length && /* @__PURE__ */ c("button", { type: "button", className: "nice-accesslog-show-more", onClick: T, children: [
3223
- g.showMore,
3224
- " (",
3225
- L.length - E,
3226
- " remaining)"
3227
- ] })
3228
- ] }) }),
3229
- G && b && /* @__PURE__ */ c("div", { className: "nice-accesslog-detail", children: [
3230
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-header", children: [
3231
- /* @__PURE__ */ e("h3", { children: g.details }),
3232
- /* @__PURE__ */ e(
3233
- "button",
3234
- {
3235
- type: "button",
3236
- className: "nice-accesslog-detail-close",
3237
- onClick: () => M(null),
3238
- children: "βœ•"
3239
- }
3240
- )
3241
- ] }),
3242
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-content", children: [
3243
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3244
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Event ID" }),
3245
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-value", children: b.id })
3246
- ] }),
3247
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3248
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Timestamp" }),
3249
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-value", children: new Date(b.timestamp).toISOString() })
3250
- ] }),
3251
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3252
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "User" }),
3253
- /* @__PURE__ */ c("span", { className: "nice-accesslog-detail-value", children: [
3254
- b.userName,
3255
- " (",
3256
- b.userId,
3257
- ")",
3258
- b.userEmail && /* @__PURE__ */ e("div", { children: b.userEmail })
3259
- ] })
3260
- ] }),
3261
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3262
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Event Type" }),
3263
- /* @__PURE__ */ c("span", { className: "nice-accesslog-detail-value", children: [
3264
- ke[b.eventType],
3265
- " ",
3266
- g.eventTypes[b.eventType]
3267
- ] })
3268
- ] }),
3269
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3270
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "IP Address" }),
3271
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-value", children: b.ipAddress })
3272
- ] }),
3273
- b.location && /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3274
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Location" }),
3275
- /* @__PURE__ */ c("span", { className: "nice-accesslog-detail-value", children: [
3276
- b.location.city,
3277
- ", ",
3278
- b.location.region,
3279
- ",",
3280
- " ",
3281
- b.location.country,
3282
- b.location.latitude && b.location.longitude && /* @__PURE__ */ c("div", { className: "nice-accesslog-coords", children: [
3283
- "(",
3284
- b.location.latitude,
3285
- ", ",
3286
- b.location.longitude,
3287
- ")"
3288
- ] })
3289
- ] })
3290
- ] }),
3291
- b.device && /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3292
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Device" }),
3293
- /* @__PURE__ */ c("span", { className: "nice-accesslog-detail-value", children: [
3294
- Ie[b.device.type],
3295
- " ",
3296
- b.device.os,
3297
- " ",
3298
- b.device.osVersion,
3299
- /* @__PURE__ */ c("div", { children: [
3300
- b.device.browser,
3301
- " ",
3302
- b.device.browserVersion
3303
- ] }),
3304
- b.device.fingerprint && /* @__PURE__ */ c("div", { className: "nice-accesslog-fingerprint", children: [
3305
- "Fingerprint: ",
3306
- b.device.fingerprint
3307
- ] })
3308
- ] })
3309
- ] }),
3310
- /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3311
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Risk Score" }),
3312
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-value", children: /* @__PURE__ */ c("span", { style: { color: Ae(b.riskScore) }, children: [
3313
- b.riskScore,
3314
- "/100 (",
3315
- g.riskLevels[b.riskLevel],
3316
- ")"
3317
- ] }) })
3318
- ] }),
3319
- b.flags && b.flags.length > 0 && /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3320
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Flags" }),
3321
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-value", children: b.flags.map((d, p) => /* @__PURE__ */ e("span", { className: "nice-accesslog-flag-badge", children: d }, p)) })
3322
- ] }),
3323
- b.details && Object.keys(b.details).length > 0 && /* @__PURE__ */ c("div", { className: "nice-accesslog-detail-row", children: [
3324
- /* @__PURE__ */ e("span", { className: "nice-accesslog-detail-label", children: "Additional Details" }),
3325
- /* @__PURE__ */ e("pre", { className: "nice-accesslog-detail-json", children: JSON.stringify(b.details, null, 2) })
3326
- ] })
3327
- ] })
3328
- ] })
3329
- ] });
3330
- }
3331
- );
3332
- yc.displayName = "NiceAccessLog";
1
+ import { l as c, n as i, o as s, s as o, w as r, x as t, B as n } from "./index-0xFOYBPt.js";
3333
2
  export {
3334
- yc as NiceAccessLog,
3335
- Ke as NiceAuditTrail,
3336
- ic as NiceContractEditor,
3337
- ze as NiceDataExportCenter,
3338
- sc as NiceGDPRConsent,
3339
- uc as NiceGlobalSearch,
3340
- gc as NiceInvoiceDesigner
3
+ c as NiceAccessLog,
4
+ i as NiceAuditTrail,
5
+ s as NiceContractEditor,
6
+ o as NiceDataExportCenter,
7
+ r as NiceGDPRConsent,
8
+ t as NiceGlobalSearch,
9
+ n as NiceInvoiceDesigner
3341
10
  };