@nice2dev/ui-api 1.0.29 → 1.1.6

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,3918 +1,7 @@
1
- import { jsxs as t, jsx as e, Fragment as F } from "react/jsx-runtime";
2
- import { forwardRef as ue, useContext as be, createContext as D, memo as Te, useState as v, useEffect as he, useCallback as R, useRef as oe, useMemo as Ee } from "react";
3
- const de = ue(
4
- ({
5
- menubar: r,
6
- toolbar: a,
7
- sidebar: i,
8
- sidebarWidth: n = 220,
9
- rightSidebar: c,
10
- rightSidebarWidth: u = 280,
11
- children: l,
12
- bottomPanel: y,
13
- bottomPanelHeight: b,
14
- statusBar: d,
15
- height: h = "100%",
16
- flush: S = !1,
17
- className: m,
18
- style: k,
19
- id: g,
20
- "data-testid": P
21
- }, C) => {
22
- const O = `nice-app-shell__sidebar${S ? " nice-app-shell__sidebar--flush" : ""}`;
23
- return /* @__PURE__ */ t(
24
- "div",
25
- {
26
- ref: C,
27
- id: g,
28
- "data-testid": P,
29
- className: `nice-app-shell${m ? ` ${m}` : ""}`,
30
- style: { height: h, ...k },
31
- children: [
32
- r != null && /* @__PURE__ */ e(
33
- "div",
34
- {
35
- className: `nice-app-shell__menubar${S ? " nice-app-shell__chrome--flush" : ""}`,
36
- children: r
37
- }
38
- ),
39
- a != null && /* @__PURE__ */ e(
40
- "div",
41
- {
42
- className: `nice-app-shell__toolbar${S ? " nice-app-shell__chrome--flush" : ""}`,
43
- children: a
44
- }
45
- ),
46
- /* @__PURE__ */ t("div", { className: "nice-app-shell__body", children: [
47
- i != null && /* @__PURE__ */ e("aside", { className: O, style: S ? void 0 : { width: n }, children: i }),
48
- /* @__PURE__ */ e("main", { className: "nice-app-shell__content", children: l }),
49
- c != null && /* @__PURE__ */ e(
50
- "aside",
51
- {
52
- className: `${O} nice-app-shell__sidebar--right`,
53
- style: S ? void 0 : { width: u },
54
- children: c
55
- }
56
- )
57
- ] }),
58
- y != null && /* @__PURE__ */ e(
59
- "div",
60
- {
61
- className: `nice-app-shell__bottom${S ? " nice-app-shell__bottom--flush" : ""}`,
62
- style: b != null ? { height: b } : void 0,
63
- children: y
64
- }
65
- ),
66
- d != null && /* @__PURE__ */ e("div", { className: "nice-app-shell__status", children: d })
67
- ]
68
- }
69
- );
70
- }
71
- );
72
- de.displayName = "NiceAppShell";
73
- const Ae = (r, a) => a, Re = D(Ae);
74
- function Pe() {
75
- return { t: be(Re) };
76
- }
77
- D({
78
- dir: "ltr",
79
- isRTL: !1,
80
- flip: (r) => r,
81
- value: (r) => r.ltr
82
- });
83
- D(null);
84
- D(null);
85
- const De = {
86
- radius: "md",
87
- shadow: "md",
88
- fill: "solid",
89
- buttonStyle: "flat",
90
- inputStyle: "bordered",
91
- cardStyle: "elevated",
92
- badgeStyle: "solid",
93
- tabStyle: "underline",
94
- toggleStyle: "default",
95
- tooltipStyle: "dark",
96
- modalStyle: "default",
97
- tableStyle: "default",
98
- menuStyle: "default",
99
- animation: "normal",
100
- density: "normal"
101
- };
102
- D({
103
- displayStyle: "default",
104
- variantConfig: De,
105
- setDisplayStyle: () => {
106
- }
107
- });
108
- D({});
109
- D({
110
- direction: "ltr",
111
- isRTL: !1,
112
- flip: (r) => r,
113
- flipStyle: (r, a) => ({ [r]: a })
114
- });
115
- D({
116
- permissions: {},
117
- getAccessMode: () => "full"
118
- });
119
- D(null);
120
- const $e = process.env.NODE_ENV === "development";
121
- let ge = {
122
- enabled: $e,
123
- slowRenderThreshold: 16
124
- };
125
- const ve = [], le = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map();
126
- function Ie() {
127
- ve.length = 0, le.clear(), _e.clear();
128
- }
129
- function Oe(r) {
130
- const a = ge.slowRenderThreshold;
131
- return ve.filter((i) => i.actualDuration > a);
132
- }
133
- function z(r) {
134
- return r < 1 ? `${(r * 1e3).toFixed(0)}μs` : r < 1e3 ? `${r.toFixed(2)}ms` : `${(r / 1e3).toFixed(2)}s`;
135
- }
136
- function Me() {
137
- const r = Array.from(le.values()), a = Oe(), i = r.reduce((u, l) => u + l.renderCount, 0), n = r.length > 0 ? r.reduce((u, l) => u + l.avgRenderTime, 0) / r.length : 0, c = Array.from(_e.values());
138
- return { stats: r, slowRenders: a, totalRenders: i, avgRenderTime: n, marks: c };
139
- }
140
- function Le() {
141
- const r = Me();
142
- console.group(
143
- "%c[Nice2Dev Performance Report]",
144
- "color: var(--nice-info, #6366f1); font-weight: bold; font-size: 14px"
145
- ), console.log(`Total renders: ${r.totalRenders}`), console.log(`Average render time: ${z(r.avgRenderTime)}`), console.log(`Slow renders: ${r.slowRenders.length}`), console.group("Component Stats"), console.table(
146
- r.stats.sort((a, i) => i.totalRenderTime - a.totalRenderTime).map((a) => ({
147
- Name: a.componentName,
148
- Renders: a.renderCount,
149
- "Avg Time": z(a.avgRenderTime),
150
- "Max Time": z(a.maxRenderTime),
151
- "Total Time": z(a.totalRenderTime),
152
- "Slow Renders": a.slowRenderCount
153
- }))
154
- ), console.groupEnd(), r.slowRenders.length > 0 && (console.group("Slow Renders (last 10)"), console.table(
155
- r.slowRenders.slice(-10).map((a) => ({
156
- Component: a.componentName,
157
- Phase: a.phase,
158
- Duration: z(a.actualDuration),
159
- Time: new Date(a.timestamp).toLocaleTimeString()
160
- }))
161
- ), console.groupEnd()), r.marks.length > 0 && (console.group("Custom Marks"), console.table(
162
- r.marks.filter((a) => a.duration).map((a) => ({
163
- Name: a.name,
164
- Duration: z(a.duration)
165
- }))
166
- ), console.groupEnd()), console.groupEnd();
167
- }
168
- const Ue = Te(
169
- ({ position: r = "bottom-right", defaultCollapsed: a = !0 }) => {
170
- const [i, n] = v(a), [c, u] = v([]), [l, y] = v({ used: 0, total: 0 });
171
- if (he(() => {
172
- const d = () => {
173
- const S = Array.from(le.values());
174
- u(S.sort((k, g) => g.totalRenderTime - k.totalRenderTime).slice(0, 10));
175
- const m = window.performance;
176
- m.memory && y({
177
- used: m.memory.usedJSHeapSize / 1024 / 1024,
178
- total: m.memory.totalJSHeapSize / 1024 / 1024
179
- });
180
- };
181
- d();
182
- const h = setInterval(d, 2e3);
183
- return () => clearInterval(h);
184
- }, []), !ge.enabled)
185
- return null;
186
- const b = {
187
- position: "fixed",
188
- zIndex: 99999,
189
- ...r.includes("top") ? { top: 8 } : { bottom: 8 },
190
- ...r.includes("left") ? { left: 8 } : { right: 8 }
191
- };
192
- return /* @__PURE__ */ t(
193
- "div",
194
- {
195
- style: {
196
- ...b,
197
- background: "var(--nice-overlay-85, rgba(0, 0, 0, 0.85))",
198
- color: "var(--bg-primary, #fff)",
199
- borderRadius: 8,
200
- fontSize: 11,
201
- fontFamily: "Monaco, Consolas, monospace",
202
- padding: i ? "4px 8px" : 8,
203
- maxWidth: i ? "auto" : 300,
204
- maxHeight: i ? "auto" : 400,
205
- overflow: "auto"
206
- },
207
- children: [
208
- /* @__PURE__ */ t(
209
- "div",
210
- {
211
- style: { cursor: "pointer", display: "flex", alignItems: "center", gap: 8 },
212
- onClick: () => n((d) => !d),
213
- children: [
214
- /* @__PURE__ */ e("span", { style: { color: "var(--color-success, #22c55e)" }, children: "●" }),
215
- /* @__PURE__ */ e("span", { children: "Profiler" }),
216
- l.used > 0 && /* @__PURE__ */ t(
217
- "span",
218
- {
219
- style: {
220
- color: l.used > 100 ? "var(--color-warning, #f59e0b)" : "var(--text-muted, #64748b)"
221
- },
222
- children: [
223
- l.used.toFixed(0),
224
- "MB"
225
- ]
226
- }
227
- ),
228
- /* @__PURE__ */ e("span", { style: { marginLeft: "auto", opacity: 0.5 }, children: i ? "▼" : "▲" })
229
- ]
230
- }
231
- ),
232
- !i && /* @__PURE__ */ t("div", { style: { marginTop: 8 }, children: [
233
- /* @__PURE__ */ e(
234
- "div",
235
- {
236
- style: {
237
- borderBottom: "1px solid var(--border-color, #333)",
238
- paddingBottom: 4,
239
- marginBottom: 8
240
- },
241
- children: /* @__PURE__ */ e("strong", { children: "Top Components" })
242
- }
243
- ),
244
- c.map((d) => /* @__PURE__ */ t("div", { style: { marginBottom: 4, display: "flex", gap: 8 }, children: [
245
- /* @__PURE__ */ e("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis" }, children: d.componentName }),
246
- /* @__PURE__ */ e(
247
- "span",
248
- {
249
- style: {
250
- color: d.avgRenderTime > 16 ? "var(--color-warning, #f59e0b)" : "var(--color-success, #22c55e)"
251
- },
252
- children: z(d.avgRenderTime)
253
- }
254
- ),
255
- /* @__PURE__ */ t(
256
- "span",
257
- {
258
- style: { color: "var(--text-muted, #64748b)", minWidth: 30, textAlign: "right" },
259
- children: [
260
- "x",
261
- d.renderCount
262
- ]
263
- }
264
- )
265
- ] }, d.componentName)),
266
- /* @__PURE__ */ t("div", { style: { marginTop: 8, display: "flex", gap: 8 }, children: [
267
- /* @__PURE__ */ e(
268
- "button",
269
- {
270
- onClick: Le,
271
- style: {
272
- flex: 1,
273
- padding: "4px 8px",
274
- background: "var(--bg-tertiary, #333)",
275
- border: "none",
276
- borderRadius: 4,
277
- color: "var(--bg-primary, #fff)",
278
- cursor: "pointer",
279
- fontSize: 10
280
- },
281
- children: "Print Report"
282
- }
283
- ),
284
- /* @__PURE__ */ e(
285
- "button",
286
- {
287
- onClick: Ie,
288
- style: {
289
- flex: 1,
290
- padding: "4px 8px",
291
- background: "var(--bg-tertiary, #333)",
292
- border: "none",
293
- borderRadius: 4,
294
- color: "var(--bg-primary, #fff)",
295
- cursor: "pointer",
296
- fontSize: 10
297
- },
298
- children: "Clear"
299
- }
300
- )
301
- ] })
302
- ] })
303
- ]
304
- }
305
- );
306
- }
307
- );
308
- Ue.displayName = "ProfilerOverlay";
309
- process.env.NODE_ENV;
310
- D(null);
311
- const je = D({
312
- enabled: !0,
313
- active: !1,
314
- run: () => {
315
- }
316
- });
317
- function Ke() {
318
- return be(je);
319
- }
320
- function ae(r, a) {
321
- if (!r)
322
- return null;
323
- if (r === !0)
324
- return a && a.length > 0 ? a : null;
325
- if (Array.isArray(r))
326
- return r.length > 0 ? r : null;
327
- const i = r.steps ?? a;
328
- return i && i.length > 0 ? i : null;
329
- }
330
- function qe(r, a) {
331
- return r.map((i) => ({
332
- target: i.target,
333
- title: i.titleKey ? a(i.titleKey, i.title ?? "") : i.title ?? "",
334
- content: i.contentKey ? a(i.contentKey, i.content ?? "") : i.content ?? "",
335
- placement: i.placement,
336
- highlightPadding: i.highlightPadding,
337
- showArrow: i.showArrow,
338
- scrollIntoView: i.scrollIntoView,
339
- disableInteraction: i.disableInteraction
340
- }));
341
- }
342
- const ie = ({
343
- steps: r,
344
- autoStart: a,
345
- label: i,
346
- size: n = "md",
347
- className: c,
348
- style: u,
349
- "data-testid": l
350
- }) => {
351
- const { enabled: y, run: b } = Ke(), { t: d } = Pe();
352
- if (!y || !r || r.length === 0)
353
- return null;
354
- const h = i ?? d("tutorial.startAria", "Start tutorial");
355
- return /* @__PURE__ */ e(
356
- "button",
357
- {
358
- type: "button",
359
- className: `nice-tutorial-button nice-tutorial-button--${n}` + (c ? ` ${c}` : ""),
360
- style: u,
361
- "data-testid": l,
362
- "aria-label": h,
363
- title: h,
364
- onClick: () => b(qe(r, d), { autoStart: a }),
365
- children: "?"
366
- }
367
- );
368
- }, fe = "nice-tutorial-button-styles";
369
- if (typeof document < "u" && !document.getElementById(fe)) {
370
- const r = document.createElement("style");
371
- r.id = fe, r.textContent = `
372
- .nice-tutorial-button {
373
- display: inline-flex;
374
- align-items: center;
375
- justify-content: center;
376
- border: 1px solid var(--nice-border, #cbd5e1);
377
- background: var(--nice-bg, #fff);
378
- color: var(--nice-text-secondary, #475569);
379
- border-radius: var(--nice-radius-full, 9999px);
380
- cursor: help;
381
- font-weight: 700;
382
- line-height: 1;
383
- padding: 0;
384
- transition: background var(--nice-transition, 200ms ease), color var(--nice-transition, 200ms ease), border-color var(--nice-transition, 200ms ease);
385
- }
386
- .nice-tutorial-button:hover {
387
- background: var(--nice-primary, #2563eb);
388
- border-color: var(--nice-primary, #2563eb);
389
- color: var(--nice-text-inverse, #fff);
390
- }
391
- .nice-tutorial-button:focus-visible {
392
- outline: none;
393
- box-shadow: 0 0 0 2px var(--nice-bg, #fff), 0 0 0 4px var(--nice-primary, #2563eb);
394
- }
395
- .nice-tutorial-button--sm { width: 16px; height: 16px; font-size: 11px; }
396
- .nice-tutorial-button--md { width: 20px; height: 20px; font-size: 12px; }
397
- `, document.head.appendChild(r);
398
- }
399
- D(null);
400
- D(null);
401
- D(null);
402
- const we = {
403
- space1: "4px",
404
- space2: "8px",
405
- space3: "12px",
406
- space4: "16px",
407
- space5: "20px",
408
- space6: "24px",
409
- space8: "32px"
410
- }, Ne = {
411
- fontFamily: "'Inter', system-ui, -apple-system, sans-serif",
412
- fontSizeXs: "0.75rem",
413
- fontSizeSm: "0.8125rem",
414
- fontSizeMd: "0.875rem",
415
- fontSizeLg: "1rem",
416
- fontSizeXl: "1.125rem",
417
- fontWeightNormal: 400,
418
- fontWeightMedium: 500,
419
- fontWeightSemibold: 600,
420
- fontWeightBold: 700,
421
- lineHeight: 1.5
422
- }, xe = { fast: "120ms ease", normal: "200ms ease", slow: "300ms ease" }, Se = (r) => ({
423
- color: r,
424
- radiusSm: "4px",
425
- radiusMd: "6px",
426
- radiusLg: "8px",
427
- radiusXl: "12px",
428
- radiusFull: "9999px"
429
- }), Be = {
430
- sm: "0 1px 2px rgba(0,0,0,0.05)",
431
- md: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",
432
- lg: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
433
- xl: "0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"
434
- }, Ve = {
435
- sm: "0 1px 2px rgba(0,0,0,0.3)",
436
- md: "0 4px 6px -1px rgba(0,0,0,0.4)",
437
- lg: "0 10px 15px -3px rgba(0,0,0,0.4)",
438
- xl: "0 20px 25px -5px rgba(0,0,0,0.4)"
439
- };
440
- function f(r, a, i, n, c) {
441
- return {
442
- name: r,
443
- darkMode: "light",
444
- colors: {
445
- ...a,
446
- surface: a.surface ?? i.primary,
447
- surfaceHover: a.surfaceHover ?? i.secondary
448
- },
449
- backgrounds: {
450
- ...i,
451
- elevated: i.elevated ?? i.primary,
452
- inset: i.inset ?? i.tertiary,
453
- canvas: i.canvas ?? i.primary
454
- },
455
- text: { ...n, inverse: n.inverse ?? "#ffffff" },
456
- borders: Se(c),
457
- shadows: Be,
458
- spacing: we,
459
- typography: Ne,
460
- transitions: xe
461
- };
462
- }
463
- function T(r, a, i, n, c) {
464
- return {
465
- name: r,
466
- darkMode: "dark",
467
- colors: {
468
- ...a,
469
- surface: a.surface ?? i.secondary,
470
- surfaceHover: a.surfaceHover ?? i.tertiary
471
- },
472
- backgrounds: {
473
- ...i,
474
- elevated: i.elevated ?? i.secondary,
475
- inset: i.inset ?? i.primary,
476
- canvas: i.canvas ?? i.primary
477
- },
478
- text: { ...n, inverse: n.inverse ?? "#0f172a" },
479
- borders: Se(c),
480
- shadows: Ve,
481
- spacing: we,
482
- typography: Ne,
483
- transitions: xe
484
- };
485
- }
486
- f(
487
- "Slate",
488
- {
489
- primary: "#64748b",
490
- primaryHover: "#475569",
491
- success: "#10b981",
492
- warning: "#f59e0b",
493
- error: "#ef4444",
494
- info: "#06b6d4"
495
- },
496
- { primary: "#f8fafc", secondary: "#f1f5f9", tertiary: "#e2e8f0", hover: "#e2e8f0" },
497
- { primary: "#1e293b", secondary: "#475569", muted: "#94a3b8" },
498
- "#cbd5e1"
499
- );
500
- f(
501
- "Zinc",
502
- {
503
- primary: "#71717a",
504
- primaryHover: "#52525b",
505
- success: "#22c55e",
506
- warning: "#eab308",
507
- error: "#ef4444",
508
- info: "#06b6d4"
509
- },
510
- { primary: "#fafafa", secondary: "#f4f4f5", tertiary: "#e4e4e7", hover: "#e4e4e7" },
511
- { primary: "#18181b", secondary: "#3f3f46", muted: "#a1a1aa" },
512
- "#d4d4d8"
513
- );
514
- f(
515
- "Stone",
516
- {
517
- primary: "#78716c",
518
- primaryHover: "#57534e",
519
- success: "#16a34a",
520
- warning: "#ca8a04",
521
- error: "#dc2626",
522
- info: "#0891b2"
523
- },
524
- { primary: "#fafaf9", secondary: "#f5f5f4", tertiary: "#e7e5e4", hover: "#e7e5e4" },
525
- { primary: "#1c1917", secondary: "#44403c", muted: "#a8a29e" },
526
- "#d6d3d1"
527
- );
528
- f(
529
- "Cool Gray",
530
- {
531
- primary: "#6b7280",
532
- primaryHover: "#4b5563",
533
- success: "#10b981",
534
- warning: "#f59e0b",
535
- error: "#ef4444",
536
- info: "#3b82f6"
537
- },
538
- { primary: "#f9fafb", secondary: "#f3f4f6", tertiary: "#e5e7eb", hover: "#e5e7eb" },
539
- { primary: "#111827", secondary: "#374151", muted: "#9ca3af" },
540
- "#d1d5db"
541
- );
542
- f(
543
- "Warm Gray",
544
- {
545
- primary: "#7c7568",
546
- primaryHover: "#5c564c",
547
- success: "#4d7c0f",
548
- warning: "#a16207",
549
- error: "#b91c1c",
550
- info: "#0e7490"
551
- },
552
- { primary: "#faf9f7", secondary: "#f5f4f0", tertiary: "#e8e6e1", hover: "#e8e6e1" },
553
- { primary: "#1f1d19", secondary: "#4a463d", muted: "#a09888" },
554
- "#d4d0c8"
555
- );
556
- f(
557
- "Silver",
558
- {
559
- primary: "#94a3b8",
560
- primaryHover: "#64748b",
561
- success: "#10b981",
562
- warning: "#f59e0b",
563
- error: "#ef4444",
564
- info: "#38bdf8"
565
- },
566
- { primary: "#f8fafc", secondary: "#f1f5f9", tertiary: "#e2e8f0", hover: "#e2e8f0" },
567
- { primary: "#334155", secondary: "#64748b", muted: "#94a3b8" },
568
- "#cbd5e1"
569
- );
570
- f(
571
- "Charcoal",
572
- {
573
- primary: "#374151",
574
- primaryHover: "#1f2937",
575
- success: "#059669",
576
- warning: "#d97706",
577
- error: "#dc2626",
578
- info: "#0284c7"
579
- },
580
- { primary: "#f9fafb", secondary: "#f3f4f6", tertiary: "#e5e7eb", hover: "#e5e7eb" },
581
- { primary: "#111827", secondary: "#374151", muted: "#6b7280" },
582
- "#d1d5db"
583
- );
584
- f(
585
- "Ivory",
586
- {
587
- primary: "#92876d",
588
- primaryHover: "#7a6f55",
589
- success: "#4d7c0f",
590
- warning: "#a16207",
591
- error: "#b91c1c",
592
- info: "#0e7490"
593
- },
594
- { primary: "#fffef7", secondary: "#faf6eb", tertiary: "#f0ead6", hover: "#f0ead6" },
595
- { primary: "#2b2517", secondary: "#5c5340", muted: "#9c9280" },
596
- "#ddd8c4"
597
- );
598
- f(
599
- "Rose",
600
- {
601
- primary: "#e11d48",
602
- primaryHover: "#be123c",
603
- success: "#16a34a",
604
- warning: "#ea580c",
605
- error: "#dc2626",
606
- info: "#0891b2"
607
- },
608
- { primary: "#fff1f2", secondary: "#ffe4e6", tertiary: "#fecdd3", hover: "#ffe4e6" },
609
- { primary: "#4c0519", secondary: "#881337", muted: "#f43f5e" },
610
- "#fda4af"
611
- );
612
- f(
613
- "Emerald",
614
- {
615
- primary: "#059669",
616
- primaryHover: "#047857",
617
- success: "#16a34a",
618
- warning: "#d97706",
619
- error: "#dc2626",
620
- info: "#0891b2"
621
- },
622
- { primary: "#ecfdf5", secondary: "#d1fae5", tertiary: "#a7f3d0", hover: "#d1fae5" },
623
- { primary: "#064e3b", secondary: "#065f46", muted: "#34d399" },
624
- "#6ee7b7"
625
- );
626
- f(
627
- "Amber",
628
- {
629
- primary: "#d97706",
630
- primaryHover: "#b45309",
631
- success: "#16a34a",
632
- warning: "#ca8a04",
633
- error: "#dc2626",
634
- info: "#0284c7"
635
- },
636
- { primary: "#fffbeb", secondary: "#fef3c7", tertiary: "#fde68a", hover: "#fef3c7" },
637
- { primary: "#451a03", secondary: "#78350f", muted: "#f59e0b" },
638
- "#fcd34d"
639
- );
640
- f(
641
- "Violet",
642
- {
643
- primary: "#7c3aed",
644
- primaryHover: "#6d28d9",
645
- success: "#10b981",
646
- warning: "#f59e0b",
647
- error: "#ef4444",
648
- info: "#06b6d4"
649
- },
650
- { primary: "#f5f3ff", secondary: "#ede9fe", tertiary: "#ddd6fe", hover: "#ede9fe" },
651
- { primary: "#2e1065", secondary: "#4c1d95", muted: "#a78bfa" },
652
- "#c4b5fd"
653
- );
654
- f(
655
- "Teal",
656
- {
657
- primary: "#0d9488",
658
- primaryHover: "#0f766e",
659
- success: "#16a34a",
660
- warning: "#d97706",
661
- error: "#dc2626",
662
- info: "#0284c7"
663
- },
664
- { primary: "#f0fdfa", secondary: "#ccfbf1", tertiary: "#99f6e4", hover: "#ccfbf1" },
665
- { primary: "#134e4a", secondary: "#115e59", muted: "#2dd4bf" },
666
- "#5eead4"
667
- );
668
- f(
669
- "Indigo",
670
- {
671
- primary: "#4f46e5",
672
- primaryHover: "#4338ca",
673
- success: "#10b981",
674
- warning: "#f59e0b",
675
- error: "#ef4444",
676
- info: "#06b6d4"
677
- },
678
- { primary: "#eef2ff", secondary: "#e0e7ff", tertiary: "#c7d2fe", hover: "#e0e7ff" },
679
- { primary: "#1e1b4b", secondary: "#312e81", muted: "#818cf8" },
680
- "#a5b4fc"
681
- );
682
- f(
683
- "Cyan",
684
- {
685
- primary: "#0891b2",
686
- primaryHover: "#0e7490",
687
- success: "#10b981",
688
- warning: "#f59e0b",
689
- error: "#ef4444",
690
- info: "#0284c7"
691
- },
692
- { primary: "#ecfeff", secondary: "#cffafe", tertiary: "#a5f3fc", hover: "#cffafe" },
693
- { primary: "#164e63", secondary: "#155e75", muted: "#22d3ee" },
694
- "#67e8f9"
695
- );
696
- f(
697
- "Lime",
698
- {
699
- primary: "#65a30d",
700
- primaryHover: "#4d7c0f",
701
- success: "#16a34a",
702
- warning: "#ca8a04",
703
- error: "#dc2626",
704
- info: "#0891b2"
705
- },
706
- { primary: "#f7fee7", secondary: "#ecfccb", tertiary: "#d9f99d", hover: "#ecfccb" },
707
- { primary: "#1a2e05", secondary: "#365314", muted: "#84cc16" },
708
- "#bef264"
709
- );
710
- f(
711
- "Pink",
712
- {
713
- primary: "#db2777",
714
- primaryHover: "#be185d",
715
- success: "#10b981",
716
- warning: "#f59e0b",
717
- error: "#dc2626",
718
- info: "#06b6d4"
719
- },
720
- { primary: "#fdf2f8", secondary: "#fce7f3", tertiary: "#fbcfe8", hover: "#fce7f3" },
721
- { primary: "#500724", secondary: "#831843", muted: "#f472b6" },
722
- "#f9a8d4"
723
- );
724
- f(
725
- "Orange",
726
- {
727
- primary: "#ea580c",
728
- primaryHover: "#c2410c",
729
- success: "#16a34a",
730
- warning: "#ca8a04",
731
- error: "#dc2626",
732
- info: "#0891b2"
733
- },
734
- { primary: "#fff7ed", secondary: "#ffedd5", tertiary: "#fed7aa", hover: "#ffedd5" },
735
- { primary: "#431407", secondary: "#7c2d12", muted: "#fb923c" },
736
- "#fdba74"
737
- );
738
- f(
739
- "Fuchsia",
740
- {
741
- primary: "#c026d3",
742
- primaryHover: "#a21caf",
743
- success: "#10b981",
744
- warning: "#eab308",
745
- error: "#ef4444",
746
- info: "#06b6d4"
747
- },
748
- { primary: "#fdf4ff", secondary: "#fae8ff", tertiary: "#f5d0fe", hover: "#fae8ff" },
749
- { primary: "#4a044e", secondary: "#701a75", muted: "#d946ef" },
750
- "#e879f9"
751
- );
752
- f(
753
- "Sky",
754
- {
755
- primary: "#0284c7",
756
- primaryHover: "#0369a1",
757
- success: "#10b981",
758
- warning: "#f59e0b",
759
- error: "#ef4444",
760
- info: "#06b6d4"
761
- },
762
- { primary: "#f0f9ff", secondary: "#e0f2fe", tertiary: "#bae6fd", hover: "#e0f2fe" },
763
- { primary: "#0c4a6e", secondary: "#075985", muted: "#38bdf8" },
764
- "#7dd3fc"
765
- );
766
- f(
767
- "Ruby",
768
- {
769
- primary: "#be123c",
770
- primaryHover: "#9f1239",
771
- success: "#059669",
772
- warning: "#d97706",
773
- error: "#dc2626",
774
- info: "#0284c7"
775
- },
776
- { primary: "#fff1f2", secondary: "#ffe4e6", tertiary: "#fecdd3", hover: "#ffe4e6" },
777
- { primary: "#4c0519", secondary: "#881337", muted: "#fb7185" },
778
- "#fda4af"
779
- );
780
- f(
781
- "Coral",
782
- {
783
- primary: "#f97316",
784
- primaryHover: "#ea580c",
785
- success: "#10b981",
786
- warning: "#eab308",
787
- error: "#ef4444",
788
- info: "#06b6d4"
789
- },
790
- { primary: "#fff7ed", secondary: "#ffedd5", tertiary: "#fed7aa", hover: "#ffedd5" },
791
- { primary: "#431407", secondary: "#9a3412", muted: "#fb923c" },
792
- "#fdba74"
793
- );
794
- T(
795
- "Midnight",
796
- {
797
- primary: "#818cf8",
798
- primaryHover: "#6366f1",
799
- success: "#34d399",
800
- warning: "#fbbf24",
801
- error: "#f87171",
802
- info: "#22d3ee"
803
- },
804
- { primary: "#020617", secondary: "#0f172a", tertiary: "#1e293b", hover: "#1e293b" },
805
- { primary: "#f1f5f9", secondary: "#94a3b8", muted: "#475569" },
806
- "#1e293b"
807
- );
808
- T(
809
- "Obsidian",
810
- {
811
- primary: "#a78bfa",
812
- primaryHover: "#8b5cf6",
813
- success: "#4ade80",
814
- warning: "#facc15",
815
- error: "#fb7185",
816
- info: "#38bdf8"
817
- },
818
- { primary: "#09090b", secondary: "#18181b", tertiary: "#27272a", hover: "#27272a" },
819
- { primary: "#fafafa", secondary: "#a1a1aa", muted: "#52525b" },
820
- "#3f3f46"
821
- );
822
- T(
823
- "Eclipse",
824
- {
825
- primary: "#c084fc",
826
- primaryHover: "#a855f7",
827
- success: "#34d399",
828
- warning: "#fbbf24",
829
- error: "#f87171",
830
- info: "#67e8f9"
831
- },
832
- { primary: "#0c0a1d", secondary: "#1a1533", tertiary: "#2a2248", hover: "#2a2248" },
833
- { primary: "#f5f3ff", secondary: "#a78bfa", muted: "#6d5eac" },
834
- "#3b3266"
835
- );
836
- T(
837
- "Onyx",
838
- {
839
- primary: "#60a5fa",
840
- primaryHover: "#3b82f6",
841
- success: "#4ade80",
842
- warning: "#fbbf24",
843
- error: "#f87171",
844
- info: "#22d3ee"
845
- },
846
- { primary: "#000000", secondary: "#0a0a0a", tertiary: "#171717", hover: "#171717" },
847
- { primary: "#ffffff", secondary: "#a3a3a3", muted: "#525252" },
848
- "#262626"
849
- );
850
- T(
851
- "Carbon",
852
- {
853
- primary: "#38bdf8",
854
- primaryHover: "#0ea5e9",
855
- success: "#4ade80",
856
- warning: "#facc15",
857
- error: "#f87171",
858
- info: "#67e8f9"
859
- },
860
- { primary: "#161616", secondary: "#262626", tertiary: "#393939", hover: "#393939" },
861
- { primary: "#f4f4f4", secondary: "#c6c6c6", muted: "#6f6f6f" },
862
- "#525252"
863
- );
864
- T(
865
- "Cosmos",
866
- {
867
- primary: "#6366f1",
868
- primaryHover: "#4f46e5",
869
- success: "#34d399",
870
- warning: "#fbbf24",
871
- error: "#f87171",
872
- info: "#22d3ee"
873
- },
874
- { primary: "#030712", secondary: "#111827", tertiary: "#1f2937", hover: "#1f2937" },
875
- { primary: "#e5e7eb", secondary: "#9ca3af", muted: "#4b5563" },
876
- "#374151"
877
- );
878
- T(
879
- "Nebula",
880
- {
881
- primary: "#e879f9",
882
- primaryHover: "#d946ef",
883
- success: "#4ade80",
884
- warning: "#fbbf24",
885
- error: "#fb7185",
886
- info: "#67e8f9"
887
- },
888
- { primary: "#0d0117", secondary: "#1a0533", tertiary: "#2d0a52", hover: "#2d0a52" },
889
- { primary: "#fae8ff", secondary: "#d8b4fe", muted: "#7c3aed" },
890
- "#581c87"
891
- );
892
- T(
893
- "Abyss",
894
- {
895
- primary: "#22d3ee",
896
- primaryHover: "#06b6d4",
897
- success: "#34d399",
898
- warning: "#fbbf24",
899
- error: "#f87171",
900
- info: "#38bdf8"
901
- },
902
- { primary: "#001219", secondary: "#002a3a", tertiary: "#003e54", hover: "#003e54" },
903
- { primary: "#e0f2fe", secondary: "#7dd3fc", muted: "#0369a1" },
904
- "#075985"
905
- );
906
- T(
907
- "Shadow",
908
- {
909
- primary: "#a3a3a3",
910
- primaryHover: "#737373",
911
- success: "#4ade80",
912
- warning: "#facc15",
913
- error: "#f87171",
914
- info: "#38bdf8"
915
- },
916
- { primary: "#171717", secondary: "#1f1f1f", tertiary: "#2a2a2a", hover: "#2a2a2a" },
917
- { primary: "#e5e5e5", secondary: "#a3a3a3", muted: "#525252" },
918
- "#404040"
919
- );
920
- T(
921
- "Emerald Dark",
922
- {
923
- primary: "#34d399",
924
- primaryHover: "#10b981",
925
- success: "#4ade80",
926
- warning: "#fbbf24",
927
- error: "#f87171",
928
- info: "#22d3ee"
929
- },
930
- { primary: "#022c22", secondary: "#064e3b", tertiary: "#065f46", hover: "#065f46" },
931
- { primary: "#ecfdf5", secondary: "#6ee7b7", muted: "#047857" },
932
- "#047857"
933
- );
934
- f(
935
- "Forest",
936
- {
937
- primary: "#166534",
938
- primaryHover: "#14532d",
939
- success: "#22c55e",
940
- warning: "#ca8a04",
941
- error: "#dc2626",
942
- info: "#0891b2"
943
- },
944
- { primary: "#f0fdf4", secondary: "#dcfce7", tertiary: "#bbf7d0", hover: "#dcfce7" },
945
- { primary: "#052e16", secondary: "#166534", muted: "#4ade80" },
946
- "#86efac"
947
- );
948
- f(
949
- "Ocean",
950
- {
951
- primary: "#0369a1",
952
- primaryHover: "#075985",
953
- success: "#059669",
954
- warning: "#d97706",
955
- error: "#dc2626",
956
- info: "#0284c7"
957
- },
958
- { primary: "#f0f9ff", secondary: "#e0f2fe", tertiary: "#bae6fd", hover: "#e0f2fe" },
959
- { primary: "#0c4a6e", secondary: "#0369a1", muted: "#38bdf8" },
960
- "#7dd3fc"
961
- );
962
- f(
963
- "Desert",
964
- {
965
- primary: "#b45309",
966
- primaryHover: "#92400e",
967
- success: "#4d7c0f",
968
- warning: "#a16207",
969
- error: "#b91c1c",
970
- info: "#0e7490"
971
- },
972
- { primary: "#fefce8", secondary: "#fef9c3", tertiary: "#fef08a", hover: "#fef9c3" },
973
- { primary: "#422006", secondary: "#713f12", muted: "#ca8a04" },
974
- "#fde047"
975
- );
976
- f(
977
- "Sunset",
978
- {
979
- primary: "#ea580c",
980
- primaryHover: "#c2410c",
981
- success: "#16a34a",
982
- warning: "#d97706",
983
- error: "#dc2626",
984
- info: "#0891b2"
985
- },
986
- { primary: "#fff7ed", secondary: "#ffedd5", tertiary: "#fed7aa", hover: "#ffedd5" },
987
- { primary: "#431407", secondary: "#9a3412", muted: "#f97316" },
988
- "#fdba74"
989
- );
990
- f(
991
- "Aurora",
992
- {
993
- primary: "#0d9488",
994
- primaryHover: "#0f766e",
995
- success: "#22c55e",
996
- warning: "#eab308",
997
- error: "#ef4444",
998
- info: "#06b6d4"
999
- },
1000
- { primary: "#f0fdfa", secondary: "#ccfbf1", tertiary: "#99f6e4", hover: "#ccfbf1" },
1001
- { primary: "#134e4a", secondary: "#115e59", muted: "#2dd4bf" },
1002
- "#5eead4"
1003
- );
1004
- f(
1005
- "Lavender",
1006
- {
1007
- primary: "#7e22ce",
1008
- primaryHover: "#6b21a8",
1009
- success: "#16a34a",
1010
- warning: "#d97706",
1011
- error: "#dc2626",
1012
- info: "#0891b2"
1013
- },
1014
- { primary: "#faf5ff", secondary: "#f3e8ff", tertiary: "#e9d5ff", hover: "#f3e8ff" },
1015
- { primary: "#3b0764", secondary: "#581c87", muted: "#a855f7" },
1016
- "#d8b4fe"
1017
- );
1018
- f(
1019
- "Autumn",
1020
- {
1021
- primary: "#c2410c",
1022
- primaryHover: "#9a3412",
1023
- success: "#4d7c0f",
1024
- warning: "#a16207",
1025
- error: "#b91c1c",
1026
- info: "#0e7490"
1027
- },
1028
- { primary: "#fef2f2", secondary: "#fee2e2", tertiary: "#fecaca", hover: "#fee2e2" },
1029
- { primary: "#450a0a", secondary: "#7f1d1d", muted: "#f87171" },
1030
- "#fca5a5"
1031
- );
1032
- f(
1033
- "Spring",
1034
- {
1035
- primary: "#16a34a",
1036
- primaryHover: "#15803d",
1037
- success: "#22c55e",
1038
- warning: "#eab308",
1039
- error: "#ef4444",
1040
- info: "#06b6d4"
1041
- },
1042
- { primary: "#f0fdf4", secondary: "#dcfce7", tertiary: "#bbf7d0", hover: "#dcfce7" },
1043
- { primary: "#14532d", secondary: "#166534", muted: "#4ade80" },
1044
- "#86efac"
1045
- );
1046
- f(
1047
- "Arctic",
1048
- {
1049
- primary: "#0ea5e9",
1050
- primaryHover: "#0284c7",
1051
- success: "#10b981",
1052
- warning: "#f59e0b",
1053
- error: "#ef4444",
1054
- info: "#06b6d4"
1055
- },
1056
- { primary: "#f0f9ff", secondary: "#e0f2fe", tertiary: "#bae6fd", hover: "#e0f2fe" },
1057
- { primary: "#0c4a6e", secondary: "#0369a1", muted: "#7dd3fc" },
1058
- "#bae6fd"
1059
- );
1060
- f(
1061
- "Tropical",
1062
- {
1063
- primary: "#0d9488",
1064
- primaryHover: "#0f766e",
1065
- success: "#16a34a",
1066
- warning: "#f59e0b",
1067
- error: "#ef4444",
1068
- info: "#06b6d4"
1069
- },
1070
- { primary: "#ecfdf5", secondary: "#d1fae5", tertiary: "#a7f3d0", hover: "#d1fae5" },
1071
- { primary: "#064e3b", secondary: "#065f46", muted: "#6ee7b7" },
1072
- "#a7f3d0"
1073
- );
1074
- f(
1075
- "Pastel Rose",
1076
- {
1077
- primary: "#f472b6",
1078
- primaryHover: "#ec4899",
1079
- success: "#4ade80",
1080
- warning: "#fcd34d",
1081
- error: "#fb7185",
1082
- info: "#67e8f9"
1083
- },
1084
- { primary: "#fdf2f8", secondary: "#fce7f3", tertiary: "#fbcfe8", hover: "#fce7f3" },
1085
- { primary: "#831843", secondary: "#9d174d", muted: "#f9a8d4" },
1086
- "#f9a8d4"
1087
- );
1088
- f(
1089
- "Pastel Sky",
1090
- {
1091
- primary: "#38bdf8",
1092
- primaryHover: "#0ea5e9",
1093
- success: "#4ade80",
1094
- warning: "#fcd34d",
1095
- error: "#fb7185",
1096
- info: "#67e8f9"
1097
- },
1098
- { primary: "#f0f9ff", secondary: "#e0f2fe", tertiary: "#bae6fd", hover: "#e0f2fe" },
1099
- { primary: "#075985", secondary: "#0369a1", muted: "#7dd3fc" },
1100
- "#bae6fd"
1101
- );
1102
- f(
1103
- "Pastel Mint",
1104
- {
1105
- primary: "#34d399",
1106
- primaryHover: "#10b981",
1107
- success: "#4ade80",
1108
- warning: "#fcd34d",
1109
- error: "#fb7185",
1110
- info: "#67e8f9"
1111
- },
1112
- { primary: "#ecfdf5", secondary: "#d1fae5", tertiary: "#a7f3d0", hover: "#d1fae5" },
1113
- { primary: "#065f46", secondary: "#047857", muted: "#6ee7b7" },
1114
- "#a7f3d0"
1115
- );
1116
- f(
1117
- "Pastel Peach",
1118
- {
1119
- primary: "#fb923c",
1120
- primaryHover: "#f97316",
1121
- success: "#4ade80",
1122
- warning: "#fcd34d",
1123
- error: "#fb7185",
1124
- info: "#67e8f9"
1125
- },
1126
- { primary: "#fff7ed", secondary: "#ffedd5", tertiary: "#fed7aa", hover: "#ffedd5" },
1127
- { primary: "#7c2d12", secondary: "#9a3412", muted: "#fdba74" },
1128
- "#fed7aa"
1129
- );
1130
- f(
1131
- "Pastel Lavender",
1132
- {
1133
- primary: "#a78bfa",
1134
- primaryHover: "#8b5cf6",
1135
- success: "#4ade80",
1136
- warning: "#fcd34d",
1137
- error: "#fb7185",
1138
- info: "#67e8f9"
1139
- },
1140
- { primary: "#f5f3ff", secondary: "#ede9fe", tertiary: "#ddd6fe", hover: "#ede9fe" },
1141
- { primary: "#4c1d95", secondary: "#5b21b6", muted: "#c4b5fd" },
1142
- "#ddd6fe"
1143
- );
1144
- f(
1145
- "Pastel Lemon",
1146
- {
1147
- primary: "#facc15",
1148
- primaryHover: "#eab308",
1149
- success: "#4ade80",
1150
- warning: "#fcd34d",
1151
- error: "#fb7185",
1152
- info: "#67e8f9"
1153
- },
1154
- { primary: "#fefce8", secondary: "#fef9c3", tertiary: "#fef08a", hover: "#fef9c3" },
1155
- { primary: "#713f12", secondary: "#854d0e", muted: "#fde047" },
1156
- "#fef08a"
1157
- );
1158
- f(
1159
- "Pastel Sage",
1160
- {
1161
- primary: "#86efac",
1162
- primaryHover: "#4ade80",
1163
- success: "#22c55e",
1164
- warning: "#fcd34d",
1165
- error: "#fb7185",
1166
- info: "#67e8f9"
1167
- },
1168
- { primary: "#f0fdf4", secondary: "#dcfce7", tertiary: "#bbf7d0", hover: "#dcfce7" },
1169
- { primary: "#166534", secondary: "#15803d", muted: "#86efac" },
1170
- "#bbf7d0"
1171
- );
1172
- f(
1173
- "Pastel Coral",
1174
- {
1175
- primary: "#fb7185",
1176
- primaryHover: "#f43f5e",
1177
- success: "#4ade80",
1178
- warning: "#fcd34d",
1179
- error: "#ef4444",
1180
- info: "#67e8f9"
1181
- },
1182
- { primary: "#fff1f2", secondary: "#ffe4e6", tertiary: "#fecdd3", hover: "#ffe4e6" },
1183
- { primary: "#881337", secondary: "#9f1239", muted: "#fda4af" },
1184
- "#fecdd3"
1185
- );
1186
- f(
1187
- "Banking",
1188
- {
1189
- primary: "#1e3a5f",
1190
- primaryHover: "#152c4a",
1191
- success: "#059669",
1192
- warning: "#d97706",
1193
- error: "#dc2626",
1194
- info: "#0891b2"
1195
- },
1196
- { primary: "#f8fafc", secondary: "#f1f5f9", tertiary: "#e2e8f0", hover: "#e2e8f0" },
1197
- { primary: "#0f172a", secondary: "#334155", muted: "#94a3b8" },
1198
- "#cbd5e1"
1199
- );
1200
- f(
1201
- "Healthcare",
1202
- {
1203
- primary: "#0891b2",
1204
- primaryHover: "#0e7490",
1205
- success: "#059669",
1206
- warning: "#d97706",
1207
- error: "#dc2626",
1208
- info: "#0284c7"
1209
- },
1210
- { primary: "#f0fdfa", secondary: "#e0f7fa", tertiary: "#b2ebf2", hover: "#e0f7fa" },
1211
- { primary: "#134e4a", secondary: "#1a6b6a", muted: "#80cbc4" },
1212
- "#b2dfdb"
1213
- );
1214
- f(
1215
- "Legal",
1216
- {
1217
- primary: "#1e293b",
1218
- primaryHover: "#0f172a",
1219
- success: "#059669",
1220
- warning: "#d97706",
1221
- error: "#dc2626",
1222
- info: "#0284c7"
1223
- },
1224
- { primary: "#fafaf9", secondary: "#f5f5f4", tertiary: "#e7e5e4", hover: "#e7e5e4" },
1225
- { primary: "#0f172a", secondary: "#44403c", muted: "#a8a29e" },
1226
- "#d6d3d1"
1227
- );
1228
- f(
1229
- "Tech Startup",
1230
- {
1231
- primary: "#7c3aed",
1232
- primaryHover: "#6d28d9",
1233
- success: "#10b981",
1234
- warning: "#f59e0b",
1235
- error: "#ef4444",
1236
- info: "#06b6d4"
1237
- },
1238
- { primary: "#faf5ff", secondary: "#f3e8ff", tertiary: "#e9d5ff", hover: "#f3e8ff" },
1239
- { primary: "#1e1b4b", secondary: "#4c1d95", muted: "#a78bfa" },
1240
- "#c4b5fd"
1241
- );
1242
- f(
1243
- "Enterprise",
1244
- {
1245
- primary: "#1e40af",
1246
- primaryHover: "#1e3a8a",
1247
- success: "#059669",
1248
- warning: "#d97706",
1249
- error: "#dc2626",
1250
- info: "#0891b2"
1251
- },
1252
- { primary: "#eff6ff", secondary: "#dbeafe", tertiary: "#bfdbfe", hover: "#dbeafe" },
1253
- { primary: "#1e3a5f", secondary: "#1e40af", muted: "#60a5fa" },
1254
- "#93c5fd"
1255
- );
1256
- f(
1257
- "Government",
1258
- {
1259
- primary: "#1d4ed8",
1260
- primaryHover: "#1e40af",
1261
- success: "#059669",
1262
- warning: "#d97706",
1263
- error: "#dc2626",
1264
- info: "#0891b2"
1265
- },
1266
- { primary: "#f8fafc", secondary: "#f1f5f9", tertiary: "#e2e8f0", hover: "#e2e8f0" },
1267
- { primary: "#0f172a", secondary: "#1e293b", muted: "#64748b" },
1268
- "#cbd5e1"
1269
- );
1270
- f(
1271
- "Education",
1272
- {
1273
- primary: "#059669",
1274
- primaryHover: "#047857",
1275
- success: "#16a34a",
1276
- warning: "#f59e0b",
1277
- error: "#ef4444",
1278
- info: "#0891b2"
1279
- },
1280
- { primary: "#f0fdf9", secondary: "#d1fae5", tertiary: "#a7f3d0", hover: "#d1fae5" },
1281
- { primary: "#064e3b", secondary: "#065f46", muted: "#6ee7b7" },
1282
- "#a7f3d0"
1283
- );
1284
- f(
1285
- "Real Estate",
1286
- {
1287
- primary: "#92400e",
1288
- primaryHover: "#78350f",
1289
- success: "#059669",
1290
- warning: "#b45309",
1291
- error: "#dc2626",
1292
- info: "#0891b2"
1293
- },
1294
- { primary: "#fffbeb", secondary: "#fef3c7", tertiary: "#fde68a", hover: "#fef3c7" },
1295
- { primary: "#422006", secondary: "#713f12", muted: "#d97706" },
1296
- "#fcd34d"
1297
- );
1298
- f(
1299
- "Nord",
1300
- {
1301
- primary: "#5e81ac",
1302
- primaryHover: "#4c6b90",
1303
- success: "#a3be8c",
1304
- warning: "#ebcb8b",
1305
- error: "#bf616a",
1306
- info: "#88c0d0"
1307
- },
1308
- { primary: "#eceff4", secondary: "#e5e9f0", tertiary: "#d8dee9", hover: "#d8dee9" },
1309
- { primary: "#2e3440", secondary: "#3b4252", muted: "#4c566a" },
1310
- "#d8dee9"
1311
- );
1312
- T(
1313
- "Dracula",
1314
- {
1315
- primary: "#bd93f9",
1316
- primaryHover: "#9d79d9",
1317
- success: "#50fa7b",
1318
- warning: "#f1fa8c",
1319
- error: "#ff5555",
1320
- info: "#8be9fd"
1321
- },
1322
- { primary: "#282a36", secondary: "#343746", tertiary: "#44475a", hover: "#44475a" },
1323
- { primary: "#f8f8f2", secondary: "#c0c0c0", muted: "#6272a4" },
1324
- "#44475a"
1325
- );
1326
- f(
1327
- "Solarized Light",
1328
- {
1329
- primary: "#268bd2",
1330
- primaryHover: "#1a6da0",
1331
- success: "#859900",
1332
- warning: "#b58900",
1333
- error: "#dc322f",
1334
- info: "#2aa198"
1335
- },
1336
- { primary: "#fdf6e3", secondary: "#eee8d5", tertiary: "#e0dbc7", hover: "#eee8d5" },
1337
- { primary: "#073642", secondary: "#586e75", muted: "#93a1a1" },
1338
- "#eee8d5"
1339
- );
1340
- T(
1341
- "Solarized Dark",
1342
- {
1343
- primary: "#268bd2",
1344
- primaryHover: "#3d98db",
1345
- success: "#859900",
1346
- warning: "#b58900",
1347
- error: "#dc322f",
1348
- info: "#2aa198"
1349
- },
1350
- { primary: "#002b36", secondary: "#073642", tertiary: "#0a4858", hover: "#073642" },
1351
- { primary: "#eee8d5", secondary: "#93a1a1", muted: "#586e75" },
1352
- "#073642"
1353
- );
1354
- T(
1355
- "Monokai",
1356
- {
1357
- primary: "#66d9ef",
1358
- primaryHover: "#45c0d6",
1359
- success: "#a6e22e",
1360
- warning: "#e6db74",
1361
- error: "#f92672",
1362
- info: "#66d9ef"
1363
- },
1364
- { primary: "#272822", secondary: "#34352e", tertiary: "#3e3d32", hover: "#3e3d32" },
1365
- { primary: "#f8f8f2", secondary: "#cfcfc2", muted: "#75715e" },
1366
- "#3e3d32"
1367
- );
1368
- T(
1369
- "One Dark",
1370
- {
1371
- primary: "#61afef",
1372
- primaryHover: "#4b9ee0",
1373
- success: "#98c379",
1374
- warning: "#e5c07b",
1375
- error: "#e06c75",
1376
- info: "#56b6c2"
1377
- },
1378
- { primary: "#282c34", secondary: "#2c313a", tertiary: "#353b45", hover: "#353b45" },
1379
- { primary: "#abb2bf", secondary: "#828997", muted: "#545862" },
1380
- "#3e4452"
1381
- );
1382
- T(
1383
- "Synthwave",
1384
- {
1385
- primary: "#ff7edb",
1386
- primaryHover: "#e660c2",
1387
- success: "#72f1b8",
1388
- warning: "#fede5d",
1389
- error: "#fe4450",
1390
- info: "#36f9f6"
1391
- },
1392
- { primary: "#241b2f", secondary: "#2d2140", tertiary: "#362a50", hover: "#362a50" },
1393
- { primary: "#f0e4fc", secondary: "#b4a0cc", muted: "#6c5c84" },
1394
- "#4a3866"
1395
- );
1396
- f(
1397
- "Vaporwave",
1398
- {
1399
- primary: "#ff71ce",
1400
- primaryHover: "#e655b5",
1401
- success: "#78dcca",
1402
- warning: "#ffb86c",
1403
- error: "#ff5555",
1404
- info: "#76e8fc"
1405
- },
1406
- { primary: "#fce4f7", secondary: "#e8d0f4", tertiary: "#d4bcf0", hover: "#e8d0f4" },
1407
- { primary: "#4a1a4e", secondary: "#7b3f7d", muted: "#c080c0" },
1408
- "#d8a8e8"
1409
- );
1410
- T(
1411
- "Terminal Green",
1412
- {
1413
- primary: "#00ff41",
1414
- primaryHover: "#00cc34",
1415
- success: "#00ff41",
1416
- warning: "#ffff00",
1417
- error: "#ff0000",
1418
- info: "#00ffff"
1419
- },
1420
- { primary: "#0a0a0a", secondary: "#0d1a0d", tertiary: "#1a2e1a", hover: "#1a2e1a" },
1421
- { primary: "#00ff41", secondary: "#00cc33", muted: "#008822" },
1422
- "#003300"
1423
- );
1424
- f(
1425
- "Sepia",
1426
- {
1427
- primary: "#8b6914",
1428
- primaryHover: "#704f10",
1429
- success: "#6b8e23",
1430
- warning: "#cd853f",
1431
- error: "#b22222",
1432
- info: "#5f9ea0"
1433
- },
1434
- { primary: "#faf0e6", secondary: "#f5e6d3", tertiary: "#eddcc7", hover: "#f5e6d3" },
1435
- { primary: "#3e2723", secondary: "#5d4037", muted: "#a1887f" },
1436
- "#d7ccc8"
1437
- );
1438
- f(
1439
- "Vintage",
1440
- {
1441
- primary: "#8d6e63",
1442
- primaryHover: "#6d4c41",
1443
- success: "#66bb6a",
1444
- warning: "#ffb300",
1445
- error: "#e53935",
1446
- info: "#29b6f6"
1447
- },
1448
- { primary: "#efebe9", secondary: "#d7ccc8", tertiary: "#bcaaa4", hover: "#d7ccc8" },
1449
- { primary: "#3e2723", secondary: "#5d4037", muted: "#a1887f" },
1450
- "#bcaaa4"
1451
- );
1452
- T(
1453
- "Cyberpunk",
1454
- {
1455
- primary: "#00f0ff",
1456
- primaryHover: "#00c8d4",
1457
- success: "#39ff14",
1458
- warning: "#ffff00",
1459
- error: "#ff003c",
1460
- info: "#bf00ff"
1461
- },
1462
- { primary: "#0a0e17", secondary: "#131824", tertiary: "#1c2333", hover: "#1c2333" },
1463
- { primary: "#e0fbfc", secondary: "#80d4dd", muted: "#3a6b72" },
1464
- "#1c3a44"
1465
- );
1466
- T(
1467
- "Neon",
1468
- {
1469
- primary: "#ff00ff",
1470
- primaryHover: "#cc00cc",
1471
- success: "#00ff00",
1472
- warning: "#ffff00",
1473
- error: "#ff0000",
1474
- info: "#00ffff"
1475
- },
1476
- { primary: "#0d0d0d", secondary: "#1a1a1a", tertiary: "#262626", hover: "#262626" },
1477
- { primary: "#ffffff", secondary: "#cccccc", muted: "#666666" },
1478
- "#333333"
1479
- );
1480
- T(
1481
- "Retrowave",
1482
- {
1483
- primary: "#f77fbe",
1484
- primaryHover: "#e462a3",
1485
- success: "#72f1b8",
1486
- warning: "#ffe261",
1487
- error: "#ff4444",
1488
- info: "#79e8fb"
1489
- },
1490
- { primary: "#1b0a2e", secondary: "#261440", tertiary: "#321e52", hover: "#321e52" },
1491
- { primary: "#ffe6f7", secondary: "#c9a0c9", muted: "#6b4c7a" },
1492
- "#4a2d66"
1493
- );
1494
- f(
1495
- "Christmas",
1496
- {
1497
- primary: "#c41e3a",
1498
- primaryHover: "#a01830",
1499
- success: "#228b22",
1500
- warning: "#ffd700",
1501
- error: "#dc2626",
1502
- info: "#0891b2"
1503
- },
1504
- { primary: "#fef2f2", secondary: "#fde8e8", tertiary: "#f8d0d0", hover: "#fde8e8" },
1505
- { primary: "#3b0a0a", secondary: "#7f1d1d", muted: "#dc6868" },
1506
- "#e8a0a0"
1507
- );
1508
- T(
1509
- "Halloween",
1510
- {
1511
- primary: "#ff6600",
1512
- primaryHover: "#e05500",
1513
- success: "#4ade80",
1514
- warning: "#fbbf24",
1515
- error: "#ff0000",
1516
- info: "#9333ea"
1517
- },
1518
- { primary: "#1a0a00", secondary: "#2d1500", tertiary: "#402000", hover: "#402000" },
1519
- { primary: "#ffedd5", secondary: "#fdba74", muted: "#9a5c28" },
1520
- "#5c3400"
1521
- );
1522
- f(
1523
- "Valentine",
1524
- {
1525
- primary: "#e11d48",
1526
- primaryHover: "#be123c",
1527
- success: "#10b981",
1528
- warning: "#f59e0b",
1529
- error: "#dc2626",
1530
- info: "#ec4899"
1531
- },
1532
- { primary: "#fff1f2", secondary: "#ffe4e6", tertiary: "#fecdd3", hover: "#ffe4e6" },
1533
- { primary: "#4c0519", secondary: "#881337", muted: "#f9a8d4" },
1534
- "#fda4af"
1535
- );
1536
- f(
1537
- "Easter",
1538
- {
1539
- primary: "#a78bfa",
1540
- primaryHover: "#8b5cf6",
1541
- success: "#4ade80",
1542
- warning: "#fcd34d",
1543
- error: "#fb7185",
1544
- info: "#67e8f9"
1545
- },
1546
- { primary: "#fef9ff", secondary: "#f3e8ff", tertiary: "#e8d5ff", hover: "#f3e8ff" },
1547
- { primary: "#581c87", secondary: "#6d28d9", muted: "#c4b5fd" },
1548
- "#ddd6fe"
1549
- );
1550
- f(
1551
- "Summer Beach",
1552
- {
1553
- primary: "#0ea5e9",
1554
- primaryHover: "#0284c7",
1555
- success: "#10b981",
1556
- warning: "#f59e0b",
1557
- error: "#ef4444",
1558
- info: "#06b6d4"
1559
- },
1560
- { primary: "#fffbeb", secondary: "#fef3c7", tertiary: "#fde68a", hover: "#fef3c7" },
1561
- { primary: "#0c4a6e", secondary: "#0369a1", muted: "#7dd3fc" },
1562
- "#fcd34d"
1563
- );
1564
- f(
1565
- "Winter Frost",
1566
- {
1567
- primary: "#3b82f6",
1568
- primaryHover: "#2563eb",
1569
- success: "#10b981",
1570
- warning: "#f59e0b",
1571
- error: "#ef4444",
1572
- info: "#06b6d4"
1573
- },
1574
- { primary: "#f0f9ff", secondary: "#e0f2fe", tertiary: "#bae6fd", hover: "#e0f2fe" },
1575
- { primary: "#1e3a5f", secondary: "#1e40af", muted: "#93c5fd" },
1576
- "#bfdbfe"
1577
- );
1578
- f(
1579
- "Cherry Blossom",
1580
- {
1581
- primary: "#ec4899",
1582
- primaryHover: "#db2777",
1583
- success: "#10b981",
1584
- warning: "#f59e0b",
1585
- error: "#ef4444",
1586
- info: "#06b6d4"
1587
- },
1588
- { primary: "#fdf2f8", secondary: "#fce7f3", tertiary: "#fbcfe8", hover: "#fce7f3" },
1589
- { primary: "#831843", secondary: "#9d174d", muted: "#f9a8d4" },
1590
- "#fbcfe8"
1591
- );
1592
- f(
1593
- "Harvest",
1594
- {
1595
- primary: "#b45309",
1596
- primaryHover: "#92400e",
1597
- success: "#4d7c0f",
1598
- warning: "#a16207",
1599
- error: "#b91c1c",
1600
- info: "#0e7490"
1601
- },
1602
- { primary: "#fffbeb", secondary: "#fef3c7", tertiary: "#fde68a", hover: "#fef3c7" },
1603
- { primary: "#451a03", secondary: "#78350f", muted: "#d97706" },
1604
- "#fcd34d"
1605
- );
1606
- f(
1607
- "Japanese Zen",
1608
- {
1609
- primary: "#6b7280",
1610
- primaryHover: "#4b5563",
1611
- success: "#6b8e23",
1612
- warning: "#d4a017",
1613
- error: "#c0392b",
1614
- info: "#5f9ea0"
1615
- },
1616
- { primary: "#faf9f6", secondary: "#f0ece3", tertiary: "#e6e0d4", hover: "#f0ece3" },
1617
- { primary: "#2c2c2c", secondary: "#5c5c5c", muted: "#a0998a" },
1618
- "#d5cec0"
1619
- );
1620
- f(
1621
- "Moroccan",
1622
- {
1623
- primary: "#c2410c",
1624
- primaryHover: "#9a3412",
1625
- success: "#15803d",
1626
- warning: "#ca8a04",
1627
- error: "#b91c1c",
1628
- info: "#0e7490"
1629
- },
1630
- { primary: "#fffbf0", secondary: "#fef3e0", tertiary: "#fde6c4", hover: "#fef3e0" },
1631
- { primary: "#3a1a00", secondary: "#7c2d12", muted: "#d97706" },
1632
- "#f5d0a0"
1633
- );
1634
- f(
1635
- "Scandinavian",
1636
- {
1637
- primary: "#4b5563",
1638
- primaryHover: "#374151",
1639
- success: "#059669",
1640
- warning: "#d97706",
1641
- error: "#dc2626",
1642
- info: "#0891b2"
1643
- },
1644
- { primary: "#ffffff", secondary: "#f9fafb", tertiary: "#f3f4f6", hover: "#f3f4f6" },
1645
- { primary: "#111827", secondary: "#374151", muted: "#9ca3af" },
1646
- "#e5e7eb"
1647
- );
1648
- f(
1649
- "Mediterranean",
1650
- {
1651
- primary: "#1e40af",
1652
- primaryHover: "#1e3a8a",
1653
- success: "#059669",
1654
- warning: "#d97706",
1655
- error: "#dc2626",
1656
- info: "#0891b2"
1657
- },
1658
- { primary: "#eff6ff", secondary: "#dbeafe", tertiary: "#bfdbfe", hover: "#dbeafe" },
1659
- { primary: "#1e3a5f", secondary: "#2563eb", muted: "#93c5fd" },
1660
- "#bfdbfe"
1661
- );
1662
- f(
1663
- "Chinese New Year",
1664
- {
1665
- primary: "#dc2626",
1666
- primaryHover: "#b91c1c",
1667
- success: "#16a34a",
1668
- warning: "#d4a017",
1669
- error: "#ef4444",
1670
- info: "#0891b2"
1671
- },
1672
- { primary: "#fef2f2", secondary: "#fee2e2", tertiary: "#fecaca", hover: "#fee2e2" },
1673
- { primary: "#450a0a", secondary: "#991b1b", muted: "#f87171" },
1674
- "#fca5a5"
1675
- );
1676
- f(
1677
- "Indian Festive",
1678
- {
1679
- primary: "#d97706",
1680
- primaryHover: "#b45309",
1681
- success: "#16a34a",
1682
- warning: "#ca8a04",
1683
- error: "#dc2626",
1684
- info: "#7c3aed"
1685
- },
1686
- { primary: "#fffbeb", secondary: "#fef3c7", tertiary: "#fde68a", hover: "#fef3c7" },
1687
- { primary: "#451a03", secondary: "#92400e", muted: "#f59e0b" },
1688
- "#fcd34d"
1689
- );
1690
- f(
1691
- "Brazilian Carnival",
1692
- {
1693
- primary: "#16a34a",
1694
- primaryHover: "#15803d",
1695
- success: "#22c55e",
1696
- warning: "#facc15",
1697
- error: "#ef4444",
1698
- info: "#0ea5e9"
1699
- },
1700
- { primary: "#f0fdf4", secondary: "#dcfce7", tertiary: "#bbf7d0", hover: "#dcfce7" },
1701
- { primary: "#052e16", secondary: "#166534", muted: "#4ade80" },
1702
- "#86efac"
1703
- );
1704
- f(
1705
- "African Earth",
1706
- {
1707
- primary: "#92400e",
1708
- primaryHover: "#78350f",
1709
- success: "#4d7c0f",
1710
- warning: "#a16207",
1711
- error: "#b91c1c",
1712
- info: "#0e7490"
1713
- },
1714
- { primary: "#faf5f0", secondary: "#f0e6d6", tertiary: "#e6d5bb", hover: "#f0e6d6" },
1715
- { primary: "#2b1a0e", secondary: "#5c3d1e", muted: "#a08060" },
1716
- "#d4b896"
1717
- );
1718
- T(
1719
- "High Contrast Dark",
1720
- {
1721
- primary: "#ffff00",
1722
- primaryHover: "#cccc00",
1723
- success: "#00ff00",
1724
- warning: "#ff8c00",
1725
- error: "#ff0000",
1726
- info: "#00ffff"
1727
- },
1728
- { primary: "#000000", secondary: "#1a1a1a", tertiary: "#333333", hover: "#333333" },
1729
- { primary: "#ffffff", secondary: "#ffffff", muted: "#cccccc" },
1730
- "#ffffff"
1731
- );
1732
- f(
1733
- "Monochrome",
1734
- {
1735
- primary: "#404040",
1736
- primaryHover: "#262626",
1737
- success: "#4d7c0f",
1738
- warning: "#a16207",
1739
- error: "#b91c1c",
1740
- info: "#0e7490"
1741
- },
1742
- { primary: "#fafafa", secondary: "#f0f0f0", tertiary: "#e0e0e0", hover: "#e0e0e0" },
1743
- { primary: "#1a1a1a", secondary: "#404040", muted: "#808080" },
1744
- "#c0c0c0"
1745
- );
1746
- f(
1747
- "Enhanced Contrast",
1748
- {
1749
- primary: "#0050b3",
1750
- primaryHover: "#003d8c",
1751
- success: "#006400",
1752
- warning: "#cc7000",
1753
- error: "#cc0000",
1754
- info: "#006680"
1755
- },
1756
- { primary: "#ffffff", secondary: "#f5f5f5", tertiary: "#ebebeb", hover: "#ebebeb" },
1757
- { primary: "#000000", secondary: "#1a1a1a", muted: "#595959" },
1758
- "#8c8c8c"
1759
- );
1760
- f(
1761
- "Minimalist",
1762
- {
1763
- primary: "#18181b",
1764
- primaryHover: "#27272a",
1765
- success: "#22c55e",
1766
- warning: "#eab308",
1767
- error: "#ef4444",
1768
- info: "#3b82f6"
1769
- },
1770
- { primary: "#ffffff", secondary: "#fafafa", tertiary: "#f5f5f5", hover: "#f5f5f5" },
1771
- { primary: "#0a0a0a", secondary: "#404040", muted: "#a3a3a3" },
1772
- "#e5e5e5"
1773
- );
1774
- T(
1775
- "Warm Dark",
1776
- {
1777
- primary: "#f59e0b",
1778
- primaryHover: "#d97706",
1779
- success: "#10b981",
1780
- warning: "#fbbf24",
1781
- error: "#f87171",
1782
- info: "#38bdf8"
1783
- },
1784
- { primary: "#1c1917", secondary: "#292524", tertiary: "#44403c", hover: "#44403c" },
1785
- { primary: "#fafaf9", secondary: "#d6d3d1", muted: "#78716c" },
1786
- "#57534e"
1787
- );
1788
- T(
1789
- "Soft Dark",
1790
- {
1791
- primary: "#a78bfa",
1792
- primaryHover: "#8b5cf6",
1793
- success: "#34d399",
1794
- warning: "#fcd34d",
1795
- error: "#fb7185",
1796
- info: "#67e8f9"
1797
- },
1798
- { primary: "#1e1e2e", secondary: "#262637", tertiary: "#313147", hover: "#313147" },
1799
- { primary: "#e8e8f0", secondary: "#a0a0b8", muted: "#5c5c74" },
1800
- "#3e3e58"
1801
- );
1802
- f(
1803
- "Coffee",
1804
- {
1805
- primary: "#6f4e37",
1806
- primaryHover: "#5c3d28",
1807
- success: "#4d7c0f",
1808
- warning: "#a16207",
1809
- error: "#b91c1c",
1810
- info: "#0e7490"
1811
- },
1812
- { primary: "#faf6f1", secondary: "#f0e8dc", tertiary: "#e6d8c6", hover: "#f0e8dc" },
1813
- { primary: "#2c1a0e", secondary: "#5c3d28", muted: "#a08868" },
1814
- "#d4c4a8"
1815
- );
1816
- f(
1817
- "Wine",
1818
- {
1819
- primary: "#7f1d1d",
1820
- primaryHover: "#641717",
1821
- success: "#059669",
1822
- warning: "#d97706",
1823
- error: "#dc2626",
1824
- info: "#0891b2"
1825
- },
1826
- { primary: "#fef2f2", secondary: "#fde8e8", tertiary: "#f8d0d0", hover: "#fde8e8" },
1827
- { primary: "#3b0a0a", secondary: "#7f1d1d", muted: "#dc6868" },
1828
- "#e8a0a0"
1829
- );
1830
- D(null);
1831
- D(null);
1832
- const ze = [
1833
- {
1834
- target: ".nice-api-designer",
1835
- titleKey: "tutorial.apiDesigner.intro.title",
1836
- title: "API designer",
1837
- contentKey: "tutorial.apiDesigner.intro.content",
1838
- content: "Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",
1839
- placement: "auto"
1840
- }
1841
- ], Fe = {
1842
- openapi: "3.0.3",
1843
- info: {
1844
- title: "New API",
1845
- version: "1.0.0",
1846
- description: "API description"
1847
- },
1848
- paths: {},
1849
- components: {
1850
- schemas: {},
1851
- securitySchemes: {}
1852
- },
1853
- tags: []
1854
- }, He = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
1855
- function pe(r) {
1856
- var i, n;
1857
- const a = [];
1858
- return r.openapi || a.push({ path: "openapi", message: "OpenAPI version is required", severity: "error" }), (i = r.info) != null && i.title || a.push({ path: "info.title", message: "API title is required", severity: "error" }), (n = r.info) != null && n.version || a.push({ path: "info.version", message: "API version is required", severity: "error" }), Object.entries(r.paths || {}).forEach(([c, u]) => {
1859
- c.startsWith("/") || a.push({ path: `paths.${c}`, message: "Path must start with /", severity: "error" }), He.forEach((l) => {
1860
- const y = u[l.toLowerCase()];
1861
- y && !y.responses && a.push({
1862
- path: `paths.${c}.${l.toLowerCase()}.responses`,
1863
- message: "Responses are required",
1864
- severity: "error"
1865
- });
1866
- });
1867
- }), a;
1868
- }
1869
- function wr({
1870
- schema: r,
1871
- onChange: a,
1872
- onSave: i,
1873
- readOnly: n = !1,
1874
- className: c = "",
1875
- tutorial: u
1876
- }) {
1877
- var I, j;
1878
- const [l, y] = v(r || Fe), [b, d] = v(null), [h, S] = v(null), [m, k] = v("info"), [g, P] = v([]), C = R(
1879
- (w) => {
1880
- y((N) => {
1881
- const x = w(N);
1882
- return a == null || a(x), P(pe(x)), x;
1883
- });
1884
- },
1885
- [a]
1886
- ), O = R(() => {
1887
- const w = "/new-endpoint";
1888
- C((N) => ({
1889
- ...N,
1890
- paths: {
1891
- ...N.paths,
1892
- [w]: {
1893
- get: {
1894
- summary: "New endpoint",
1895
- responses: { 200: { description: "Success" } }
1896
- }
1897
- }
1898
- }
1899
- })), d(w), S("get");
1900
- }, [C]), U = R(
1901
- (w) => {
1902
- C((N) => {
1903
- const { [w]: x, ...K } = N.paths;
1904
- return { ...N, paths: K };
1905
- }), d(null), S(null);
1906
- },
1907
- [C]
1908
- ), W = R(() => {
1909
- const w = "NewSchema";
1910
- C((N) => {
1911
- var x;
1912
- return {
1913
- ...N,
1914
- components: {
1915
- ...N.components,
1916
- schemas: {
1917
- ...(x = N.components) == null ? void 0 : x.schemas,
1918
- [w]: { type: "object", properties: {} }
1919
- }
1920
- }
1921
- };
1922
- });
1923
- }, [C]), $ = R(() => {
1924
- const w = pe(l);
1925
- P(w), w.filter((N) => N.severity === "error").length === 0 && (i == null || i(l));
1926
- }, [l, i]), L = Object.entries(l.paths).flatMap(
1927
- ([w, N]) => He.filter((x) => N[x.toLowerCase()]).map(
1928
- (x) => ({
1929
- path: w,
1930
- method: x,
1931
- operation: N[x.toLowerCase()]
1932
- })
1933
- )
1934
- );
1935
- return /* @__PURE__ */ t("div", { style: { position: "relative", height: "100%" }, children: [
1936
- u && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ie, { steps: ae(u, ze) }) }),
1937
- /* @__PURE__ */ e(
1938
- de,
1939
- {
1940
- flush: !0,
1941
- className: `nice-api-designer ${c}`,
1942
- height: "100%",
1943
- style: { minHeight: 600 },
1944
- toolbar: /* @__PURE__ */ t("div", { className: "nice-api-designer__toolbar", children: [
1945
- /* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children: ["info", "paths", "schemas", "security", "preview"].map((w) => /* @__PURE__ */ e(
1946
- "button",
1947
- {
1948
- className: `nice-api-designer__tab ${m === w ? "nice-api-designer__tab--active" : ""}`,
1949
- onClick: () => k(w),
1950
- children: w.charAt(0).toUpperCase() + w.slice(1)
1951
- },
1952
- w
1953
- )) }),
1954
- !n && /* @__PURE__ */ e("button", { className: "nice-api-designer__save-btn", onClick: $, children: "Save" })
1955
- ] }),
1956
- bottomPanel: g.length > 0 ? /* @__PURE__ */ e("div", { className: "nice-api-designer__errors", children: g.map((w, N) => /* @__PURE__ */ t(
1957
- "div",
1958
- {
1959
- className: `nice-api-designer__error nice-api-designer__error--${w.severity}`,
1960
- children: [
1961
- /* @__PURE__ */ t("strong", { children: [
1962
- w.path,
1963
- ":"
1964
- ] }),
1965
- " ",
1966
- w.message
1967
- ]
1968
- },
1969
- N
1970
- )) }) : void 0,
1971
- children: /* @__PURE__ */ t("div", { className: "nice-api-designer__content", children: [
1972
- m === "info" && /* @__PURE__ */ e(We, { schema: l, onChange: C, readOnly: n }),
1973
- m === "paths" && /* @__PURE__ */ e(
1974
- Je,
1975
- {
1976
- endpoints: L,
1977
- schema: l,
1978
- selectedPath: b,
1979
- selectedMethod: h,
1980
- onSelectEndpoint: (w, N) => {
1981
- d(w), S(N);
1982
- },
1983
- onAdd: O,
1984
- onDelete: U,
1985
- onChange: C,
1986
- readOnly: n
1987
- }
1988
- ),
1989
- m === "schemas" && /* @__PURE__ */ e(
1990
- Ge,
1991
- {
1992
- schemas: ((I = l.components) == null ? void 0 : I.schemas) || {},
1993
- onAdd: W,
1994
- onChange: (w) => C((N) => ({
1995
- ...N,
1996
- components: { ...N.components, schemas: w }
1997
- })),
1998
- readOnly: n
1999
- }
2000
- ),
2001
- m === "security" && /* @__PURE__ */ e(
2002
- Xe,
2003
- {
2004
- schemes: ((j = l.components) == null ? void 0 : j.securitySchemes) || {},
2005
- onChange: (w) => C((N) => ({
2006
- ...N,
2007
- components: { ...N.components, securitySchemes: w }
2008
- })),
2009
- readOnly: n
2010
- }
2011
- ),
2012
- m === "preview" && /* @__PURE__ */ e(Ye, { schema: l })
2013
- ] })
2014
- }
2015
- )
2016
- ] });
2017
- }
2018
- function We({ schema: r, onChange: a, readOnly: i }) {
2019
- return /* @__PURE__ */ t("div", { className: "nice-api-designer__info-editor", children: [
2020
- /* @__PURE__ */ e("h3", { children: "API Information" }),
2021
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2022
- /* @__PURE__ */ e("label", { children: "Title" }),
2023
- /* @__PURE__ */ e(
2024
- "input",
2025
- {
2026
- type: "text",
2027
- value: r.info.title,
2028
- onChange: (n) => a((c) => ({
2029
- ...c,
2030
- info: { ...c.info, title: n.target.value }
2031
- })),
2032
- disabled: i
2033
- }
2034
- )
2035
- ] }),
2036
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2037
- /* @__PURE__ */ e("label", { children: "Version" }),
2038
- /* @__PURE__ */ e(
2039
- "input",
2040
- {
2041
- type: "text",
2042
- value: r.info.version,
2043
- onChange: (n) => a((c) => ({
2044
- ...c,
2045
- info: { ...c.info, version: n.target.value }
2046
- })),
2047
- disabled: i
2048
- }
2049
- )
2050
- ] }),
2051
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2052
- /* @__PURE__ */ e("label", { children: "Description" }),
2053
- /* @__PURE__ */ e(
2054
- "textarea",
2055
- {
2056
- value: r.info.description || "",
2057
- onChange: (n) => a((c) => ({
2058
- ...c,
2059
- info: { ...c.info, description: n.target.value }
2060
- })),
2061
- disabled: i,
2062
- rows: 5
2063
- }
2064
- )
2065
- ] }),
2066
- /* @__PURE__ */ e("h4", { children: "Servers" }),
2067
- (r.servers || []).map((n, c) => /* @__PURE__ */ t("div", { className: "nice-api-designer__server", children: [
2068
- /* @__PURE__ */ e(
2069
- "input",
2070
- {
2071
- type: "text",
2072
- value: n.url,
2073
- placeholder: "Server URL",
2074
- onChange: (u) => a((l) => {
2075
- var y;
2076
- return {
2077
- ...l,
2078
- servers: (y = l.servers) == null ? void 0 : y.map(
2079
- (b, d) => d === c ? { ...b, url: u.target.value } : b
2080
- )
2081
- };
2082
- }),
2083
- disabled: i
2084
- }
2085
- ),
2086
- /* @__PURE__ */ e(
2087
- "input",
2088
- {
2089
- type: "text",
2090
- value: n.description || "",
2091
- placeholder: "Description",
2092
- onChange: (u) => a((l) => {
2093
- var y;
2094
- return {
2095
- ...l,
2096
- servers: (y = l.servers) == null ? void 0 : y.map(
2097
- (b, d) => d === c ? { ...b, description: u.target.value } : b
2098
- )
2099
- };
2100
- }),
2101
- disabled: i
2102
- }
2103
- )
2104
- ] }, c)),
2105
- !i && /* @__PURE__ */ e(
2106
- "button",
2107
- {
2108
- onClick: () => a((n) => ({
2109
- ...n,
2110
- servers: [...n.servers || [], { url: "https://api.example.com" }]
2111
- })),
2112
- children: "Add Server"
2113
- }
2114
- )
2115
- ] });
2116
- }
2117
- function Je({
2118
- endpoints: r,
2119
- schema: a,
2120
- selectedPath: i,
2121
- selectedMethod: n,
2122
- onSelectEndpoint: c,
2123
- onAdd: u,
2124
- onDelete: l,
2125
- onChange: y,
2126
- readOnly: b
2127
- }) {
2128
- var h;
2129
- const d = i && n ? (h = a.paths[i]) == null ? void 0 : h[n] : null;
2130
- return /* @__PURE__ */ t("div", { className: "nice-api-designer__paths-editor", children: [
2131
- /* @__PURE__ */ t("div", { className: "nice-api-designer__endpoints-list", children: [
2132
- /* @__PURE__ */ t("div", { className: "nice-api-designer__list-header", children: [
2133
- /* @__PURE__ */ e("h3", { children: "Endpoints" }),
2134
- !b && /* @__PURE__ */ e("button", { onClick: u, children: "+ Add" })
2135
- ] }),
2136
- r.map(({ path: S, method: m }) => /* @__PURE__ */ t(
2137
- "div",
2138
- {
2139
- className: `nice-api-designer__endpoint ${i === S && n === m.toLowerCase() ? "nice-api-designer__endpoint--selected" : ""}`,
2140
- onClick: () => c(S, m.toLowerCase()),
2141
- children: [
2142
- /* @__PURE__ */ e(
2143
- "span",
2144
- {
2145
- className: `nice-api-designer__method nice-api-designer__method--${m.toLowerCase()}`,
2146
- children: m
2147
- }
2148
- ),
2149
- /* @__PURE__ */ e("span", { className: "nice-api-designer__path", children: S })
2150
- ]
2151
- },
2152
- `${m}-${S}`
2153
- ))
2154
- ] }),
2155
- d && i && n && /* @__PURE__ */ t("div", { className: "nice-api-designer__operation-editor", children: [
2156
- /* @__PURE__ */ t("h3", { children: [
2157
- n.toUpperCase(),
2158
- " ",
2159
- i
2160
- ] }),
2161
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2162
- /* @__PURE__ */ e("label", { children: "Summary" }),
2163
- /* @__PURE__ */ e(
2164
- "input",
2165
- {
2166
- type: "text",
2167
- value: d.summary || "",
2168
- onChange: (S) => y((m) => ({
2169
- ...m,
2170
- paths: {
2171
- ...m.paths,
2172
- [i]: {
2173
- ...m.paths[i],
2174
- [n]: {
2175
- ...d,
2176
- summary: S.target.value
2177
- }
2178
- }
2179
- }
2180
- })),
2181
- disabled: b
2182
- }
2183
- )
2184
- ] }),
2185
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2186
- /* @__PURE__ */ e("label", { children: "Description" }),
2187
- /* @__PURE__ */ e(
2188
- "textarea",
2189
- {
2190
- value: d.description || "",
2191
- onChange: (S) => y((m) => ({
2192
- ...m,
2193
- paths: {
2194
- ...m.paths,
2195
- [i]: {
2196
- ...m.paths[i],
2197
- [n]: {
2198
- ...d,
2199
- description: S.target.value
2200
- }
2201
- }
2202
- }
2203
- })),
2204
- disabled: b,
2205
- rows: 3
2206
- }
2207
- )
2208
- ] }),
2209
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2210
- /* @__PURE__ */ e("label", { children: "Operation ID" }),
2211
- /* @__PURE__ */ e(
2212
- "input",
2213
- {
2214
- type: "text",
2215
- value: d.operationId || "",
2216
- onChange: (S) => y((m) => ({
2217
- ...m,
2218
- paths: {
2219
- ...m.paths,
2220
- [i]: {
2221
- ...m.paths[i],
2222
- [n]: {
2223
- ...d,
2224
- operationId: S.target.value
2225
- }
2226
- }
2227
- }
2228
- })),
2229
- disabled: b
2230
- }
2231
- )
2232
- ] }),
2233
- !b && /* @__PURE__ */ e(
2234
- "button",
2235
- {
2236
- className: "nice-api-designer__delete-btn",
2237
- onClick: () => l(i),
2238
- children: "Delete Endpoint"
2239
- }
2240
- )
2241
- ] })
2242
- ] });
2243
- }
2244
- function Ge({
2245
- schemas: r,
2246
- onAdd: a,
2247
- onChange: i,
2248
- readOnly: n
2249
- }) {
2250
- const [c, u] = v(null);
2251
- return /* @__PURE__ */ t("div", { className: "nice-api-designer__schemas-editor", children: [
2252
- /* @__PURE__ */ t("div", { className: "nice-api-designer__schemas-list", children: [
2253
- /* @__PURE__ */ t("div", { className: "nice-api-designer__list-header", children: [
2254
- /* @__PURE__ */ e("h3", { children: "Schemas" }),
2255
- !n && /* @__PURE__ */ e("button", { onClick: a, children: "+ Add" })
2256
- ] }),
2257
- Object.keys(r).map((l) => /* @__PURE__ */ e(
2258
- "div",
2259
- {
2260
- className: `nice-api-designer__schema-item ${c === l ? "nice-api-designer__schema-item--selected" : ""}`,
2261
- onClick: () => u(l),
2262
- children: l
2263
- },
2264
- l
2265
- ))
2266
- ] }),
2267
- c && r[c] && /* @__PURE__ */ t("div", { className: "nice-api-designer__schema-editor", children: [
2268
- /* @__PURE__ */ e("h3", { children: c }),
2269
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2270
- /* @__PURE__ */ e("label", { children: "Type" }),
2271
- /* @__PURE__ */ t(
2272
- "select",
2273
- {
2274
- value: r[c].type || "object",
2275
- onChange: (l) => i({
2276
- ...r,
2277
- [c]: {
2278
- ...r[c],
2279
- type: l.target.value
2280
- }
2281
- }),
2282
- disabled: n,
2283
- children: [
2284
- /* @__PURE__ */ e("option", { value: "object", children: "object" }),
2285
- /* @__PURE__ */ e("option", { value: "array", children: "array" }),
2286
- /* @__PURE__ */ e("option", { value: "string", children: "string" }),
2287
- /* @__PURE__ */ e("option", { value: "number", children: "number" }),
2288
- /* @__PURE__ */ e("option", { value: "integer", children: "integer" }),
2289
- /* @__PURE__ */ e("option", { value: "boolean", children: "boolean" })
2290
- ]
2291
- }
2292
- )
2293
- ] }),
2294
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2295
- /* @__PURE__ */ e("label", { children: "Description" }),
2296
- /* @__PURE__ */ e(
2297
- "textarea",
2298
- {
2299
- value: r[c].description || "",
2300
- onChange: (l) => i({
2301
- ...r,
2302
- [c]: { ...r[c], description: l.target.value }
2303
- }),
2304
- disabled: n,
2305
- rows: 3
2306
- }
2307
- )
2308
- ] }),
2309
- /* @__PURE__ */ t("div", { className: "nice-api-designer__field", children: [
2310
- /* @__PURE__ */ e("label", { children: "JSON Schema" }),
2311
- /* @__PURE__ */ e(
2312
- "textarea",
2313
- {
2314
- value: JSON.stringify(r[c], null, 2),
2315
- onChange: (l) => {
2316
- try {
2317
- const y = JSON.parse(l.target.value);
2318
- i({ ...r, [c]: y });
2319
- } catch {
2320
- }
2321
- },
2322
- disabled: n,
2323
- rows: 10,
2324
- className: "nice-api-designer__code"
2325
- }
2326
- )
2327
- ] })
2328
- ] })
2329
- ] });
2330
- }
2331
- function Xe({ schemes: r, onChange: a, readOnly: i }) {
2332
- return /* @__PURE__ */ t("div", { className: "nice-api-designer__security-editor", children: [
2333
- /* @__PURE__ */ t("div", { className: "nice-api-designer__list-header", children: [
2334
- /* @__PURE__ */ e("h3", { children: "Security Schemes" }),
2335
- !i && /* @__PURE__ */ e("button", { onClick: () => {
2336
- a({
2337
- ...r,
2338
- newScheme: { type: "apiKey", name: "X-API-Key", in: "header" }
2339
- });
2340
- }, children: "+ Add" })
2341
- ] }),
2342
- Object.entries(r).map(([c, u]) => /* @__PURE__ */ t("div", { className: "nice-api-designer__security-item", children: [
2343
- /* @__PURE__ */ e("h4", { children: c }),
2344
- /* @__PURE__ */ e("pre", { children: JSON.stringify(u, null, 2) })
2345
- ] }, c))
2346
- ] });
2347
- }
2348
- function Ye({ schema: r }) {
2349
- return /* @__PURE__ */ t("div", { className: "nice-api-designer__json-preview", children: [
2350
- /* @__PURE__ */ e("h3", { children: "OpenAPI Specification" }),
2351
- /* @__PURE__ */ e("pre", { className: "nice-api-designer__code", children: JSON.stringify(r, null, 2) })
2352
- ] });
2353
- }
2354
- const Qe = [
2355
- {
2356
- target: ".nice-api-tester",
2357
- titleKey: "tutorial.apiTester.intro.title",
2358
- title: "API tester",
2359
- contentKey: "tutorial.apiTester.intro.content",
2360
- content: "Build requests with collections and environment variables, send them and assert on the responses.",
2361
- placement: "auto"
2362
- }
2363
- ], Ze = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], er = {
2364
- id: "",
2365
- name: "New Request",
2366
- method: "GET",
2367
- url: "",
2368
- headers: {},
2369
- queryParams: {}
2370
- };
2371
- function se(r, a) {
2372
- return r.replace(/\{\{(\w+)\}\}/g, (i, n) => a[n] || `{{${n}}}`);
2373
- }
2374
- function rr(r, a) {
2375
- const i = Object.entries(a).filter(([, n]) => n).map(([n, c]) => `${encodeURIComponent(n)}=${encodeURIComponent(c)}`).join("&");
2376
- return i ? `${r}?${i}` : r;
2377
- }
2378
- function Nr({
2379
- collections: r = [],
2380
- environments: a = [],
2381
- onRequest: i,
2382
- onSaveCollection: n,
2383
- className: c = "",
2384
- tutorial: u
2385
- }) {
2386
- const [l, y] = v(r), [b, d] = v(a), [h, S] = v(
2387
- a.find((s) => s.isActive) || null
2388
- ), [m, k] = v({
2389
- ...er,
2390
- id: crypto.randomUUID()
2391
- }), [g, P] = v(null), [C, O] = v(!1), [U, W] = v("none"), [$, L] = v(
2392
- "params"
2393
- ), [I, j] = v("body"), [w, N] = v(""), [x, K] = v(""), [q, B] = v([]), [M, J] = v([]), V = oe(null), Y = R(async () => {
2394
- var E;
2395
- if (!m.url)
2396
- return;
2397
- O(!0), P(null), B([]);
2398
- const s = Object.fromEntries(
2399
- Object.entries((h == null ? void 0 : h.variables) || {}).map(([H, A]) => [H, A.value])
2400
- ), o = {
2401
- ...m,
2402
- url: se(m.url, s),
2403
- headers: Object.fromEntries(
2404
- Object.entries(m.headers).map(([H, A]) => [H, se(A, s)])
2405
- ),
2406
- queryParams: Object.fromEntries(
2407
- Object.entries(m.queryParams).map(([H, A]) => [
2408
- H,
2409
- se(A, s)
2410
- ])
2411
- )
2412
- }, _ = performance.now();
2413
- try {
2414
- let H;
2415
- if (i)
2416
- H = await i(o);
2417
- else {
2418
- V.current = new AbortController();
2419
- const A = { ...o.headers };
2420
- m.auth && ar(A, m.auth);
2421
- const ee = rr(o.url, o.queryParams), X = {
2422
- method: o.method,
2423
- headers: A,
2424
- signal: V.current.signal
2425
- };
2426
- ["POST", "PUT", "PATCH"].includes(o.method) && ((E = m.body) != null && E.content) && (X.body = typeof m.body.content == "string" ? m.body.content : JSON.stringify(m.body.content), m.body.type === "json" && (A["Content-Type"] = "application/json"));
2427
- const re = await fetch(ee, X), ne = await re.text();
2428
- let te;
2429
- try {
2430
- te = JSON.parse(ne);
2431
- } catch {
2432
- te = ne;
2433
- }
2434
- const ke = performance.now();
2435
- H = {
2436
- status: re.status,
2437
- statusText: re.statusText,
2438
- headers: Object.fromEntries(re.headers.entries()),
2439
- body: te,
2440
- time: Math.round(ke - _),
2441
- size: new Blob([ne]).size,
2442
- timestamp: /* @__PURE__ */ new Date()
2443
- };
2444
- }
2445
- if (P(H), J(
2446
- (A) => [...A, { request: m, response: H }].slice(-50)
2447
- ), x) {
2448
- const A = nr(x, H);
2449
- B(A);
2450
- }
2451
- } catch (H) {
2452
- H.name !== "AbortError" && P({
2453
- status: 0,
2454
- statusText: "Error",
2455
- headers: {},
2456
- body: { error: H.message },
2457
- time: Math.round(performance.now() - _),
2458
- size: 0,
2459
- timestamp: /* @__PURE__ */ new Date()
2460
- });
2461
- } finally {
2462
- O(!1), V.current = null;
2463
- }
2464
- }, [m, h, i, x]), G = R(() => {
2465
- var s;
2466
- (s = V.current) == null || s.abort(), O(!1);
2467
- }, []), Q = R(() => {
2468
- k((s) => ({
2469
- ...s,
2470
- headers: { ...s.headers, "": "" }
2471
- }));
2472
- }, []), Z = R(() => {
2473
- k((s) => ({
2474
- ...s,
2475
- queryParams: { ...s.queryParams, "": "" }
2476
- }));
2477
- }, []), p = R(() => {
2478
- if (l.length === 0) {
2479
- const s = {
2480
- id: crypto.randomUUID(),
2481
- name: "My Collection",
2482
- requests: [m]
2483
- };
2484
- y([s]), n == null || n(s);
2485
- } else {
2486
- const s = {
2487
- ...l[0],
2488
- requests: [...l[0].requests, m]
2489
- };
2490
- y((o) => [s, ...o.slice(1)]), n == null || n(s);
2491
- }
2492
- }, [l, m, n]);
2493
- return /* @__PURE__ */ t("div", { className: `nice-api-tester ${c}`, style: { position: "relative" }, children: [
2494
- u && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ie, { steps: ae(u, Qe) }) }),
2495
- /* @__PURE__ */ e("div", { className: "nice-api-tester__toolbar", children: /* @__PURE__ */ e("div", { className: "nice-api-tester__env-selector", children: /* @__PURE__ */ t(
2496
- "select",
2497
- {
2498
- value: (h == null ? void 0 : h.id) || "",
2499
- onChange: (s) => S(b.find((o) => o.id === s.target.value) || null),
2500
- children: [
2501
- /* @__PURE__ */ e("option", { value: "", children: "No Environment" }),
2502
- b.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, s.id))
2503
- ]
2504
- }
2505
- ) }) }),
2506
- /* @__PURE__ */ t("div", { className: "nice-api-tester__request-bar", children: [
2507
- /* @__PURE__ */ e(
2508
- "select",
2509
- {
2510
- value: m.method,
2511
- onChange: (s) => k((o) => ({
2512
- ...o,
2513
- method: s.target.value
2514
- })),
2515
- className: `nice-api-tester__method nice-api-tester__method--${m.method.toLowerCase()}`,
2516
- children: Ze.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
2517
- }
2518
- ),
2519
- /* @__PURE__ */ e(
2520
- "input",
2521
- {
2522
- type: "text",
2523
- value: m.url,
2524
- onChange: (s) => k((o) => ({ ...o, url: s.target.value })),
2525
- placeholder: "Enter request URL",
2526
- className: "nice-api-tester__url-input"
2527
- }
2528
- ),
2529
- /* @__PURE__ */ e(
2530
- "button",
2531
- {
2532
- onClick: C ? G : Y,
2533
- className: `nice-api-tester__send-btn ${C ? "nice-api-tester__send-btn--loading" : ""}`,
2534
- children: C ? "Cancel" : "Send"
2535
- }
2536
- ),
2537
- /* @__PURE__ */ e("button", { onClick: p, className: "nice-api-tester__save-btn", children: "Save" })
2538
- ] }),
2539
- /* @__PURE__ */ t("div", { className: "nice-api-tester__main", children: [
2540
- /* @__PURE__ */ t("div", { className: "nice-api-tester__request-panel", children: [
2541
- /* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["params", "headers", "body", "auth", "tests"].map((s) => /* @__PURE__ */ e(
2542
- "button",
2543
- {
2544
- className: `nice-api-tester__tab ${$ === s ? "nice-api-tester__tab--active" : ""}`,
2545
- onClick: () => L(s),
2546
- children: s.charAt(0).toUpperCase() + s.slice(1)
2547
- },
2548
- s
2549
- )) }),
2550
- /* @__PURE__ */ t("div", { className: "nice-api-tester__tab-content", children: [
2551
- $ === "params" && /* @__PURE__ */ e(
2552
- tr,
2553
- {
2554
- params: m.queryParams,
2555
- onChange: (s) => k((o) => ({ ...o, queryParams: s })),
2556
- onAdd: Z
2557
- }
2558
- ),
2559
- $ === "headers" && /* @__PURE__ */ e(
2560
- sr,
2561
- {
2562
- headers: m.headers,
2563
- onChange: (s) => k((o) => ({ ...o, headers: s })),
2564
- onAdd: Q
2565
- }
2566
- ),
2567
- $ === "body" && /* @__PURE__ */ e(
2568
- cr,
2569
- {
2570
- body: m.body,
2571
- bodyTab: U,
2572
- onBodyTabChange: W,
2573
- onChange: (s) => k((o) => ({ ...o, body: s }))
2574
- }
2575
- ),
2576
- $ === "auth" && /* @__PURE__ */ e(
2577
- or,
2578
- {
2579
- auth: m.auth,
2580
- onChange: (s) => k((o) => ({ ...o, auth: s }))
2581
- }
2582
- ),
2583
- $ === "tests" && /* @__PURE__ */ e(
2584
- dr,
2585
- {
2586
- preRequestScript: w,
2587
- testScript: x,
2588
- onPreRequestChange: N,
2589
- onTestChange: K
2590
- }
2591
- )
2592
- ] })
2593
- ] }),
2594
- /* @__PURE__ */ e("div", { className: "nice-api-tester__response-panel", children: g ? /* @__PURE__ */ t(F, { children: [
2595
- /* @__PURE__ */ t("div", { className: "nice-api-tester__response-meta", children: [
2596
- /* @__PURE__ */ t(
2597
- "span",
2598
- {
2599
- className: `nice-api-tester__status nice-api-tester__status--${Math.floor(g.status / 100)}`,
2600
- children: [
2601
- g.status,
2602
- " ",
2603
- g.statusText
2604
- ]
2605
- }
2606
- ),
2607
- /* @__PURE__ */ t("span", { className: "nice-api-tester__time", children: [
2608
- g.time,
2609
- "ms"
2610
- ] }),
2611
- /* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: ir(g.size) })
2612
- ] }),
2613
- /* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["body", "headers", "tests"].map((s) => /* @__PURE__ */ t(
2614
- "button",
2615
- {
2616
- className: `nice-api-tester__tab ${I === s ? "nice-api-tester__tab--active" : ""}`,
2617
- onClick: () => j(s),
2618
- children: [
2619
- s.charAt(0).toUpperCase() + s.slice(1),
2620
- s === "tests" && q.length > 0 && /* @__PURE__ */ t("span", { className: "nice-api-tester__test-badge", children: [
2621
- q.filter((o) => o.passed).length,
2622
- "/",
2623
- q.length
2624
- ] })
2625
- ]
2626
- },
2627
- s
2628
- )) }),
2629
- /* @__PURE__ */ t("div", { className: "nice-api-tester__response-content", children: [
2630
- I === "body" && /* @__PURE__ */ e("pre", { className: "nice-api-tester__response-body", children: typeof g.body == "string" ? g.body : JSON.stringify(g.body, null, 2) }),
2631
- I === "headers" && /* @__PURE__ */ e("div", { className: "nice-api-tester__response-headers", children: Object.entries(g.headers).map(([s, o]) => /* @__PURE__ */ t("div", { className: "nice-api-tester__header-row", children: [
2632
- /* @__PURE__ */ e("span", { className: "nice-api-tester__header-key", children: s }),
2633
- /* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children: o })
2634
- ] }, s)) }),
2635
- I === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: q.map((s, o) => /* @__PURE__ */ t(
2636
- "div",
2637
- {
2638
- className: `nice-api-tester__test-result nice-api-tester__test-result--${s.passed ? "pass" : "fail"}`,
2639
- children: [
2640
- /* @__PURE__ */ e("span", { className: "nice-api-tester__test-icon", children: s.passed ? "✓" : "✗" }),
2641
- /* @__PURE__ */ e("span", { className: "nice-api-tester__test-name", children: s.name }),
2642
- s.message && /* @__PURE__ */ e("span", { className: "nice-api-tester__test-message", children: s.message })
2643
- ]
2644
- },
2645
- o
2646
- )) })
2647
- ] })
2648
- ] }) : /* @__PURE__ */ e("div", { className: "nice-api-tester__empty-response", children: C ? "Loading..." : "Send a request to see the response" }) })
2649
- ] }),
2650
- M.length > 0 && /* @__PURE__ */ t("div", { className: "nice-api-tester__history", children: [
2651
- /* @__PURE__ */ e("h4", { children: "History" }),
2652
- /* @__PURE__ */ e("div", { className: "nice-api-tester__history-list", children: M.slice().reverse().map(({ request: s, response: o }, _) => /* @__PURE__ */ t(
2653
- "div",
2654
- {
2655
- className: "nice-api-tester__history-item",
2656
- onClick: () => k(s),
2657
- children: [
2658
- /* @__PURE__ */ e(
2659
- "span",
2660
- {
2661
- className: `nice-api-tester__method nice-api-tester__method--${s.method.toLowerCase()}`,
2662
- children: s.method
2663
- }
2664
- ),
2665
- /* @__PURE__ */ e("span", { className: "nice-api-tester__history-url", children: s.url }),
2666
- /* @__PURE__ */ e(
2667
- "span",
2668
- {
2669
- className: `nice-api-tester__status nice-api-tester__status--${Math.floor(
2670
- o.status / 100
2671
- )}`,
2672
- children: o.status
2673
- }
2674
- )
2675
- ]
2676
- },
2677
- _
2678
- )) })
2679
- ] })
2680
- ] });
2681
- }
2682
- function ar(r, a) {
2683
- var i, n, c, u, l;
2684
- switch (a.type) {
2685
- case "bearer":
2686
- r.Authorization = `${((i = a.bearer) == null ? void 0 : i.prefix) || "Bearer"} ${(n = a.bearer) == null ? void 0 : n.token}`;
2687
- break;
2688
- case "basic":
2689
- r.Authorization = `Basic ${btoa(`${(c = a.basic) == null ? void 0 : c.username}:${(u = a.basic) == null ? void 0 : u.password}`)}`;
2690
- break;
2691
- case "api-key":
2692
- ((l = a.apiKey) == null ? void 0 : l.in) === "header" && (r[a.apiKey.key] = a.apiKey.value);
2693
- break;
2694
- }
2695
- }
2696
- function ir(r) {
2697
- return r < 1024 ? `${r} B` : r < 1024 * 1024 ? `${(r / 1024).toFixed(1)} KB` : `${(r / (1024 * 1024)).toFixed(1)} MB`;
2698
- }
2699
- function nr(r, a) {
2700
- const i = [], n = {
2701
- response: {
2702
- code: a.status,
2703
- status: a.statusText,
2704
- headers: a.headers,
2705
- json: () => a.body,
2706
- text: () => typeof a.body == "string" ? a.body : JSON.stringify(a.body),
2707
- responseTime: a.time
2708
- },
2709
- test: (c, u) => {
2710
- const l = performance.now();
2711
- try {
2712
- u(), i.push({ name: c, passed: !0, duration: performance.now() - l });
2713
- } catch (y) {
2714
- i.push({
2715
- name: c,
2716
- passed: !1,
2717
- message: y.message,
2718
- duration: performance.now() - l
2719
- });
2720
- }
2721
- },
2722
- expect: (c) => ({
2723
- to: {
2724
- equal: (u) => {
2725
- if (c !== u)
2726
- throw new Error(`Expected ${u} but got ${c}`);
2727
- },
2728
- be: {
2729
- oneOf: (u) => {
2730
- if (!u.includes(c))
2731
- throw new Error(`Expected ${c} to be one of ${u}`);
2732
- }
2733
- },
2734
- have: {
2735
- property: (u) => {
2736
- if (typeof c != "object" || c === null || !(u in c))
2737
- throw new Error(`Expected object to have property ${u}`);
2738
- }
2739
- }
2740
- }
2741
- })
2742
- };
2743
- try {
2744
- new Function("pm", r)(n);
2745
- } catch (c) {
2746
- i.push({
2747
- name: "Script Error",
2748
- passed: !1,
2749
- message: c.message,
2750
- duration: 0
2751
- });
2752
- }
2753
- return i;
2754
- }
2755
- function Ce({
2756
- items: r,
2757
- onChange: a,
2758
- onAdd: i,
2759
- keyPlaceholder: n = "Key",
2760
- valuePlaceholder: c = "Value"
2761
- }) {
2762
- return /* @__PURE__ */ t("div", { className: "nice-api-tester__kv-editor", children: [
2763
- Object.entries(r).map(([u, l], y) => /* @__PURE__ */ t("div", { className: "nice-api-tester__kv-row", children: [
2764
- /* @__PURE__ */ e(
2765
- "input",
2766
- {
2767
- type: "text",
2768
- value: u,
2769
- placeholder: n,
2770
- onChange: (b) => {
2771
- const d = Object.entries(r);
2772
- d[y] = [b.target.value, l], a(Object.fromEntries(d));
2773
- }
2774
- }
2775
- ),
2776
- /* @__PURE__ */ e(
2777
- "input",
2778
- {
2779
- type: "text",
2780
- value: l,
2781
- placeholder: c,
2782
- onChange: (b) => a({ ...r, [u]: b.target.value })
2783
- }
2784
- ),
2785
- /* @__PURE__ */ e(
2786
- "button",
2787
- {
2788
- onClick: () => {
2789
- const { [u]: b, ...d } = r;
2790
- a(d);
2791
- },
2792
- children: "×"
2793
- }
2794
- )
2795
- ] }, y)),
2796
- /* @__PURE__ */ e("button", { onClick: i, className: "nice-api-tester__add-btn", children: "+ Add" })
2797
- ] });
2798
- }
2799
- function tr({
2800
- params: r,
2801
- onChange: a,
2802
- onAdd: i
2803
- }) {
2804
- return /* @__PURE__ */ e(
2805
- Ce,
2806
- {
2807
- items: r,
2808
- onChange: a,
2809
- onAdd: i,
2810
- keyPlaceholder: "Parameter",
2811
- valuePlaceholder: "Value"
2812
- }
2813
- );
2814
- }
2815
- function sr({
2816
- headers: r,
2817
- onChange: a,
2818
- onAdd: i
2819
- }) {
2820
- return /* @__PURE__ */ e(
2821
- Ce,
2822
- {
2823
- items: r,
2824
- onChange: a,
2825
- onAdd: i,
2826
- keyPlaceholder: "Header",
2827
- valuePlaceholder: "Value"
2828
- }
2829
- );
2830
- }
2831
- function cr({
2832
- body: r,
2833
- bodyTab: a,
2834
- onBodyTabChange: i,
2835
- onChange: n
2836
- }) {
2837
- return /* @__PURE__ */ t("div", { className: "nice-api-tester__body-editor", children: [
2838
- /* @__PURE__ */ e("div", { className: "nice-api-tester__body-tabs", children: ["none", "json", "form-data", "raw"].map((c) => /* @__PURE__ */ t("label", { children: [
2839
- /* @__PURE__ */ e(
2840
- "input",
2841
- {
2842
- type: "radio",
2843
- checked: a === c,
2844
- onChange: () => {
2845
- i(c), n({ type: c, content: "" });
2846
- }
2847
- }
2848
- ),
2849
- c
2850
- ] }, c)) }),
2851
- a !== "none" && /* @__PURE__ */ e(
2852
- "textarea",
2853
- {
2854
- value: typeof (r == null ? void 0 : r.content) == "string" ? r.content : JSON.stringify(r == null ? void 0 : r.content, null, 2),
2855
- onChange: (c) => n({ type: a, content: c.target.value }),
2856
- placeholder: a === "json" ? '{ "key": "value" }' : "Enter body content",
2857
- rows: 10,
2858
- className: "nice-api-tester__body-textarea"
2859
- }
2860
- )
2861
- ] });
2862
- }
2863
- function or({
2864
- auth: r,
2865
- onChange: a
2866
- }) {
2867
- var i, n, c, u, l, y;
2868
- return /* @__PURE__ */ t("div", { className: "nice-api-tester__auth-editor", children: [
2869
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2870
- /* @__PURE__ */ e("label", { children: "Type" }),
2871
- /* @__PURE__ */ t(
2872
- "select",
2873
- {
2874
- value: (r == null ? void 0 : r.type) || "none",
2875
- onChange: (b) => a({ type: b.target.value }),
2876
- children: [
2877
- /* @__PURE__ */ e("option", { value: "none", children: "No Auth" }),
2878
- /* @__PURE__ */ e("option", { value: "api-key", children: "API Key" }),
2879
- /* @__PURE__ */ e("option", { value: "bearer", children: "Bearer Token" }),
2880
- /* @__PURE__ */ e("option", { value: "basic", children: "Basic Auth" }),
2881
- /* @__PURE__ */ e("option", { value: "oauth2", children: "OAuth 2.0" })
2882
- ]
2883
- }
2884
- )
2885
- ] }),
2886
- (r == null ? void 0 : r.type) === "api-key" && /* @__PURE__ */ t(F, { children: [
2887
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2888
- /* @__PURE__ */ e("label", { children: "Key" }),
2889
- /* @__PURE__ */ e(
2890
- "input",
2891
- {
2892
- type: "text",
2893
- value: ((i = r.apiKey) == null ? void 0 : i.key) || "",
2894
- onChange: (b) => {
2895
- var d, h;
2896
- return a({
2897
- ...r,
2898
- apiKey: {
2899
- ...r.apiKey,
2900
- key: b.target.value,
2901
- value: ((d = r.apiKey) == null ? void 0 : d.value) || "",
2902
- in: ((h = r.apiKey) == null ? void 0 : h.in) || "header"
2903
- }
2904
- });
2905
- },
2906
- placeholder: "X-API-Key"
2907
- }
2908
- )
2909
- ] }),
2910
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2911
- /* @__PURE__ */ e("label", { children: "Value" }),
2912
- /* @__PURE__ */ e(
2913
- "input",
2914
- {
2915
- type: "text",
2916
- value: ((n = r.apiKey) == null ? void 0 : n.value) || "",
2917
- onChange: (b) => {
2918
- var d, h;
2919
- return a({
2920
- ...r,
2921
- apiKey: {
2922
- ...r.apiKey,
2923
- value: b.target.value,
2924
- key: ((d = r.apiKey) == null ? void 0 : d.key) || "",
2925
- in: ((h = r.apiKey) == null ? void 0 : h.in) || "header"
2926
- }
2927
- });
2928
- },
2929
- placeholder: "your-api-key"
2930
- }
2931
- )
2932
- ] }),
2933
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2934
- /* @__PURE__ */ e("label", { children: "Add to" }),
2935
- /* @__PURE__ */ t(
2936
- "select",
2937
- {
2938
- value: ((c = r.apiKey) == null ? void 0 : c.in) || "header",
2939
- onChange: (b) => {
2940
- var d, h;
2941
- return a({
2942
- ...r,
2943
- apiKey: {
2944
- ...r.apiKey,
2945
- in: b.target.value,
2946
- key: ((d = r.apiKey) == null ? void 0 : d.key) || "",
2947
- value: ((h = r.apiKey) == null ? void 0 : h.value) || ""
2948
- }
2949
- });
2950
- },
2951
- children: [
2952
- /* @__PURE__ */ e("option", { value: "header", children: "Header" }),
2953
- /* @__PURE__ */ e("option", { value: "query", children: "Query Params" })
2954
- ]
2955
- }
2956
- )
2957
- ] })
2958
- ] }),
2959
- (r == null ? void 0 : r.type) === "bearer" && /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2960
- /* @__PURE__ */ e("label", { children: "Token" }),
2961
- /* @__PURE__ */ e(
2962
- "input",
2963
- {
2964
- type: "text",
2965
- value: ((u = r.bearer) == null ? void 0 : u.token) || "",
2966
- onChange: (b) => a({ ...r, bearer: { token: b.target.value } }),
2967
- placeholder: "your-bearer-token"
2968
- }
2969
- )
2970
- ] }),
2971
- (r == null ? void 0 : r.type) === "basic" && /* @__PURE__ */ t(F, { children: [
2972
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2973
- /* @__PURE__ */ e("label", { children: "Username" }),
2974
- /* @__PURE__ */ e(
2975
- "input",
2976
- {
2977
- type: "text",
2978
- value: ((l = r.basic) == null ? void 0 : l.username) || "",
2979
- onChange: (b) => {
2980
- var d;
2981
- return a({
2982
- ...r,
2983
- basic: {
2984
- ...r.basic,
2985
- username: b.target.value,
2986
- password: ((d = r.basic) == null ? void 0 : d.password) || ""
2987
- }
2988
- });
2989
- }
2990
- }
2991
- )
2992
- ] }),
2993
- /* @__PURE__ */ t("div", { className: "nice-api-tester__field", children: [
2994
- /* @__PURE__ */ e("label", { children: "Password" }),
2995
- /* @__PURE__ */ e(
2996
- "input",
2997
- {
2998
- type: "password",
2999
- value: ((y = r.basic) == null ? void 0 : y.password) || "",
3000
- onChange: (b) => {
3001
- var d;
3002
- return a({
3003
- ...r,
3004
- basic: {
3005
- ...r.basic,
3006
- password: b.target.value,
3007
- username: ((d = r.basic) == null ? void 0 : d.username) || ""
3008
- }
3009
- });
3010
- }
3011
- }
3012
- )
3013
- ] })
3014
- ] })
3015
- ] });
3016
- }
3017
- function dr({
3018
- preRequestScript: r,
3019
- testScript: a,
3020
- onPreRequestChange: i,
3021
- onTestChange: n
3022
- }) {
3023
- return /* @__PURE__ */ t("div", { className: "nice-api-tester__tests-editor", children: [
3024
- /* @__PURE__ */ t("div", { className: "nice-api-tester__script-section", children: [
3025
- /* @__PURE__ */ e("h4", { children: "Pre-request Script" }),
3026
- /* @__PURE__ */ e(
3027
- "textarea",
3028
- {
3029
- value: r,
3030
- onChange: (c) => i(c.target.value),
3031
- placeholder: "// Code to run before the request",
3032
- rows: 5
3033
- }
3034
- )
3035
- ] }),
3036
- /* @__PURE__ */ t("div", { className: "nice-api-tester__script-section", children: [
3037
- /* @__PURE__ */ e("h4", { children: "Tests" }),
3038
- /* @__PURE__ */ e(
3039
- "textarea",
3040
- {
3041
- value: a,
3042
- onChange: (c) => n(c.target.value),
3043
- placeholder: `pm.test("Status code is 200", function () {
3044
- pm.expect(pm.response.code).to.equal(200);
3045
- });`,
3046
- rows: 8
3047
- }
3048
- )
3049
- ] })
3050
- ] });
3051
- }
3052
- const lr = [
3053
- {
3054
- target: ".nice-integration-builder",
3055
- titleKey: "tutorial.integrationBuilder.intro.title",
3056
- title: "Integration builder",
3057
- contentKey: "tutorial.integrationBuilder.intro.content",
3058
- content: "Wire a flow of nodes (triggers → actions → error handling) and connect them to build an integration.",
3059
- placement: "auto"
3060
- }
3061
- ], ce = [
3062
- { type: "trigger", label: "Trigger", icon: "⚡", category: "Control" },
3063
- { type: "http-request", label: "HTTP Request", icon: "🌐", category: "Actions" },
3064
- { type: "transform", label: "Transform", icon: "🔄", category: "Data" },
3065
- { type: "filter", label: "Filter", icon: "🔍", category: "Data" },
3066
- { type: "switch", label: "Switch", icon: "⑂", category: "Control" },
3067
- { type: "loop", label: "Loop", icon: "🔁", category: "Control" },
3068
- { type: "delay", label: "Delay", icon: "⏱️", category: "Control" },
3069
- { type: "set-variable", label: "Set Variable", icon: "📝", category: "Data" },
3070
- { type: "database", label: "Database", icon: "🗄️", category: "Actions" },
3071
- { type: "email", label: "Email", icon: "✉️", category: "Actions" },
3072
- { type: "webhook", label: "Webhook", icon: "🔗", category: "Actions" },
3073
- { type: "function", label: "Function", icon: "ƒ", category: "Actions" },
3074
- { type: "error-handler", label: "Error Handler", icon: "⚠️", category: "Control" }
3075
- ], fr = {
3076
- id: "",
3077
- name: "New Flow",
3078
- nodes: [],
3079
- connections: [],
3080
- variables: {},
3081
- triggers: [],
3082
- errorHandling: { strategy: "stop" }
3083
- };
3084
- function xr({
3085
- flow: r,
3086
- connectors: a = [],
3087
- onChange: i,
3088
- onSave: n,
3089
- onRun: c,
3090
- className: u = "",
3091
- tutorial: l
3092
- }) {
3093
- const [y, b] = v(
3094
- r || { ...fr, id: crypto.randomUUID() }
3095
- ), [d, h] = v(null), [S, m] = v(!0), [k, g] = v("canvas"), [P, C] = v(!1), [O, U] = v(null), [W, $] = v(!1), [L, I] = v(null), [j, w] = v(!1), N = oe(null), x = R(
3096
- (p) => {
3097
- b((s) => {
3098
- const o = p(s);
3099
- return i == null || i(o), o;
3100
- });
3101
- },
3102
- [i]
3103
- ), K = R(
3104
- (p, s) => {
3105
- var _;
3106
- const o = {
3107
- id: crypto.randomUUID(),
3108
- type: p,
3109
- name: ((_ = ce.find((E) => E.type === p)) == null ? void 0 : _.label) || p,
3110
- position: s,
3111
- config: pr(p),
3112
- inputs: p !== "trigger" ? ["input"] : [],
3113
- outputs: ["output"]
3114
- };
3115
- x((E) => ({
3116
- ...E,
3117
- nodes: [...E.nodes, o]
3118
- })), h(o);
3119
- },
3120
- [x]
3121
- ), q = R(
3122
- (p) => {
3123
- x((s) => ({
3124
- ...s,
3125
- nodes: s.nodes.filter((o) => o.id !== p),
3126
- connections: s.connections.filter(
3127
- (o) => o.sourceNodeId !== p && o.targetNodeId !== p
3128
- )
3129
- })), h(null);
3130
- },
3131
- [x]
3132
- ), B = R(
3133
- (p, s) => {
3134
- x((o) => ({
3135
- ...o,
3136
- nodes: o.nodes.map((_) => _.id === p ? { ..._, ...s } : _)
3137
- })), (d == null ? void 0 : d.id) === p && h((o) => o ? { ...o, ...s } : null);
3138
- },
3139
- [x, d]
3140
- ), M = R(
3141
- (p, s, o, _) => {
3142
- p === o || y.connections.some(
3143
- (H) => H.sourceNodeId === p && H.targetNodeId === o && H.sourceOutput === s && H.targetInput === _
3144
- ) || x((H) => ({
3145
- ...H,
3146
- connections: [
3147
- ...H.connections,
3148
- {
3149
- id: crypto.randomUUID(),
3150
- sourceNodeId: p,
3151
- sourceOutput: s,
3152
- targetNodeId: o,
3153
- targetInput: _
3154
- }
3155
- ]
3156
- }));
3157
- },
3158
- [y.connections, x]
3159
- ), J = R(
3160
- (p) => {
3161
- x((s) => ({
3162
- ...s,
3163
- connections: s.connections.filter((o) => o.id !== p)
3164
- }));
3165
- },
3166
- [x]
3167
- ), V = R(
3168
- (p) => {
3169
- if (p.preventDefault(), !O || !N.current)
3170
- return;
3171
- const s = N.current.getBoundingClientRect(), o = p.clientX - s.left, _ = p.clientY - s.top;
3172
- K(O, { x: o, y: _ }), C(!1), U(null);
3173
- },
3174
- [O, K]
3175
- ), Y = R(async () => {
3176
- if (c) {
3177
- w(!0);
3178
- try {
3179
- await c(y);
3180
- } finally {
3181
- w(!1);
3182
- }
3183
- }
3184
- }, [y, c]), G = R(() => {
3185
- n == null || n(y);
3186
- }, [y, n]), Q = S && k === "canvas" ? /* @__PURE__ */ t("div", { className: "nice-integration-builder__palette", children: [
3187
- /* @__PURE__ */ e("h4", { children: "Nodes" }),
3188
- ["Control", "Actions", "Data"].map((p) => /* @__PURE__ */ t("div", { className: "nice-integration-builder__category", children: [
3189
- /* @__PURE__ */ e("h5", { children: p }),
3190
- ce.filter((s) => s.category === p).map((s) => /* @__PURE__ */ t(
3191
- "div",
3192
- {
3193
- className: "nice-integration-builder__palette-item",
3194
- draggable: !0,
3195
- onDragStart: () => {
3196
- C(!0), U(s.type);
3197
- },
3198
- onDragEnd: () => {
3199
- C(!1), U(null);
3200
- },
3201
- children: [
3202
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: s.icon }),
3203
- /* @__PURE__ */ e("span", { children: s.label })
3204
- ]
3205
- },
3206
- s.type
3207
- ))
3208
- ] }, p)),
3209
- a.length > 0 && /* @__PURE__ */ t("div", { className: "nice-integration-builder__category", children: [
3210
- /* @__PURE__ */ e("h5", { children: "Connectors" }),
3211
- a.map((p) => /* @__PURE__ */ t("div", { className: "nice-integration-builder__palette-item", children: [
3212
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: "🔌" }),
3213
- /* @__PURE__ */ e("span", { children: p.name })
3214
- ] }, p.id))
3215
- ] })
3216
- ] }) : void 0, Z = d && k === "canvas" ? /* @__PURE__ */ e(
3217
- yr,
3218
- {
3219
- node: d,
3220
- onChange: (p) => B(d.id, p),
3221
- onClose: () => h(null)
3222
- }
3223
- ) : void 0;
3224
- return /* @__PURE__ */ t("div", { style: { position: "relative", height: "100%" }, children: [
3225
- l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ie, { steps: ae(l, lr) }) }),
3226
- /* @__PURE__ */ t(
3227
- de,
3228
- {
3229
- flush: !0,
3230
- className: `nice-integration-builder ${u}`,
3231
- height: "100%",
3232
- style: { minHeight: 600 },
3233
- sidebar: Q,
3234
- rightSidebar: Z,
3235
- toolbar: /* @__PURE__ */ t("div", { className: "nice-integration-builder__toolbar", children: [
3236
- /* @__PURE__ */ e(
3237
- "input",
3238
- {
3239
- type: "text",
3240
- value: y.name,
3241
- onChange: (p) => x((s) => ({ ...s, name: p.target.value })),
3242
- className: "nice-integration-builder__name-input"
3243
- }
3244
- ),
3245
- /* @__PURE__ */ e("div", { className: "nice-integration-builder__tabs", children: ["canvas", "code", "variables", "settings"].map((p) => /* @__PURE__ */ e(
3246
- "button",
3247
- {
3248
- className: `nice-integration-builder__tab ${k === p ? "nice-integration-builder__tab--active" : ""}`,
3249
- onClick: () => g(p),
3250
- children: p.charAt(0).toUpperCase() + p.slice(1)
3251
- },
3252
- p
3253
- )) }),
3254
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__actions", children: [
3255
- /* @__PURE__ */ e(
3256
- "button",
3257
- {
3258
- onClick: Y,
3259
- disabled: j,
3260
- className: "nice-integration-builder__run-btn",
3261
- children: j ? "⏳ Running..." : "▶ Run"
3262
- }
3263
- ),
3264
- /* @__PURE__ */ e("button", { onClick: G, className: "nice-integration-builder__save-btn", children: "💾 Save" })
3265
- ] })
3266
- ] }),
3267
- children: [
3268
- k === "canvas" && /* @__PURE__ */ t(
3269
- "div",
3270
- {
3271
- ref: N,
3272
- className: `nice-integration-builder__canvas ${P ? "nice-integration-builder__canvas--dragging" : ""}`,
3273
- onDragOver: (p) => p.preventDefault(),
3274
- onDrop: V,
3275
- onClick: () => h(null),
3276
- children: [
3277
- /* @__PURE__ */ e("svg", { className: "nice-integration-builder__connections", children: y.connections.map((p) => {
3278
- const s = y.nodes.find((X) => X.id === p.sourceNodeId), o = y.nodes.find((X) => X.id === p.targetNodeId);
3279
- if (!s || !o)
3280
- return null;
3281
- const _ = s.position.x + 150, E = s.position.y + 30, H = o.position.x, A = o.position.y + 30, ee = (_ + H) / 2;
3282
- return /* @__PURE__ */ e("g", { onClick: () => J(p.id), children: /* @__PURE__ */ e(
3283
- "path",
3284
- {
3285
- d: `M ${_} ${E} C ${ee} ${E}, ${ee} ${A}, ${H} ${A}`,
3286
- className: "nice-integration-builder__connection"
3287
- }
3288
- ) }, p.id);
3289
- }) }),
3290
- y.nodes.map((p) => /* @__PURE__ */ e(
3291
- mr,
3292
- {
3293
- node: p,
3294
- isSelected: (d == null ? void 0 : d.id) === p.id,
3295
- onSelect: () => h(p),
3296
- onDelete: () => q(p.id),
3297
- onPositionChange: (s) => B(p.id, { position: s }),
3298
- onStartConnection: (s) => {
3299
- $(!0), I({ nodeId: p.id, output: s });
3300
- },
3301
- onEndConnection: (s) => {
3302
- L && M(L.nodeId, L.output, p.id, s), $(!1), I(null);
3303
- }
3304
- },
3305
- p.id
3306
- )),
3307
- y.nodes.length === 0 && /* @__PURE__ */ e("div", { className: "nice-integration-builder__empty", children: "Drag nodes from the palette to build your flow" })
3308
- ]
3309
- }
3310
- ),
3311
- k === "code" && /* @__PURE__ */ e("div", { className: "nice-integration-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(y, null, 2) }) }),
3312
- k === "variables" && /* @__PURE__ */ e(
3313
- ur,
3314
- {
3315
- variables: y.variables,
3316
- onChange: (p) => x((s) => ({ ...s, variables: p }))
3317
- }
3318
- ),
3319
- k === "settings" && /* @__PURE__ */ e(
3320
- br,
3321
- {
3322
- errorHandling: y.errorHandling,
3323
- schedule: y.schedule,
3324
- onChange: (p, s) => x((o) => ({ ...o, errorHandling: p, schedule: s }))
3325
- }
3326
- )
3327
- ]
3328
- }
3329
- )
3330
- ] });
3331
- }
3332
- function pr(r) {
3333
- switch (r) {
3334
- case "http-request":
3335
- return { method: "GET", url: "", headers: {}, body: "" };
3336
- case "transform":
3337
- return { mapping: [] };
3338
- case "filter":
3339
- return { condition: "" };
3340
- case "switch":
3341
- return { cases: [] };
3342
- case "loop":
3343
- return { collection: "", itemVariable: "item" };
3344
- case "delay":
3345
- return { duration: 1e3 };
3346
- case "set-variable":
3347
- return { name: "", value: "" };
3348
- case "database":
3349
- return { operation: "query", query: "" };
3350
- case "email":
3351
- return { to: "", subject: "", body: "" };
3352
- case "webhook":
3353
- return { method: "POST", url: "" };
3354
- case "function":
3355
- return { code: `// Your code here
3356
- return input;` };
3357
- case "error-handler":
3358
- return { strategy: "retry", maxRetries: 3 };
3359
- default:
3360
- return {};
3361
- }
3362
- }
3363
- function mr({
3364
- node: r,
3365
- isSelected: a,
3366
- onSelect: i,
3367
- onDelete: n,
3368
- onPositionChange: c,
3369
- onStartConnection: u,
3370
- onEndConnection: l
3371
- }) {
3372
- const [y, b] = v(!1), [d, h] = v({ x: 0, y: 0 }), S = oe(null), m = ce.find((g) => g.type === r.type), k = (g) => {
3373
- g.button === 0 && (g.stopPropagation(), b(!0), h({
3374
- x: g.clientX - r.position.x,
3375
- y: g.clientY - r.position.y
3376
- }), i());
3377
- };
3378
- return he(() => {
3379
- if (!y)
3380
- return;
3381
- const g = (C) => {
3382
- c({
3383
- x: C.clientX - d.x,
3384
- y: C.clientY - d.y
3385
- });
3386
- }, P = () => {
3387
- b(!1);
3388
- };
3389
- return window.addEventListener("mousemove", g), window.addEventListener("mouseup", P), () => {
3390
- window.removeEventListener("mousemove", g), window.removeEventListener("mouseup", P);
3391
- };
3392
- }, [y, d, c]), /* @__PURE__ */ t(
3393
- "div",
3394
- {
3395
- ref: S,
3396
- className: `nice-integration-builder__node nice-integration-builder__node--${r.type} ${a ? "nice-integration-builder__node--selected" : ""}`,
3397
- style: {
3398
- left: r.position.x,
3399
- top: r.position.y
3400
- },
3401
- onMouseDown: k,
3402
- children: [
3403
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__node-header", children: [
3404
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__node-icon", children: (m == null ? void 0 : m.icon) || "📦" }),
3405
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__node-name", children: r.name }),
3406
- /* @__PURE__ */ e(
3407
- "button",
3408
- {
3409
- className: "nice-integration-builder__node-delete",
3410
- onClick: (g) => {
3411
- g.stopPropagation(), n();
3412
- },
3413
- children: "×"
3414
- }
3415
- )
3416
- ] }),
3417
- r.inputs.map((g) => /* @__PURE__ */ t(
3418
- "div",
3419
- {
3420
- className: "nice-integration-builder__port nice-integration-builder__port--input",
3421
- onMouseUp: () => l(g),
3422
- children: [
3423
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-dot" }),
3424
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: g })
3425
- ]
3426
- },
3427
- g
3428
- )),
3429
- r.outputs.map((g) => /* @__PURE__ */ t(
3430
- "div",
3431
- {
3432
- className: "nice-integration-builder__port nice-integration-builder__port--output",
3433
- onMouseDown: (P) => {
3434
- P.stopPropagation(), u(g);
3435
- },
3436
- children: [
3437
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: g }),
3438
- /* @__PURE__ */ e("span", { className: "nice-integration-builder__port-dot" })
3439
- ]
3440
- },
3441
- g
3442
- ))
3443
- ]
3444
- }
3445
- );
3446
- }
3447
- function yr({
3448
- node: r,
3449
- onChange: a,
3450
- onClose: i
3451
- }) {
3452
- return /* @__PURE__ */ t("div", { className: "nice-integration-builder__properties", children: [
3453
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__properties-header", children: [
3454
- /* @__PURE__ */ e("h4", { children: r.name }),
3455
- /* @__PURE__ */ e("button", { onClick: i, children: "×" })
3456
- ] }),
3457
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__properties-content", children: [
3458
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3459
- /* @__PURE__ */ e("label", { children: "Name" }),
3460
- /* @__PURE__ */ e(
3461
- "input",
3462
- {
3463
- type: "text",
3464
- value: r.name,
3465
- onChange: (n) => a({ name: n.target.value })
3466
- }
3467
- )
3468
- ] }),
3469
- r.type === "http-request" && /* @__PURE__ */ t(F, { children: [
3470
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3471
- /* @__PURE__ */ e("label", { children: "Method" }),
3472
- /* @__PURE__ */ e(
3473
- "select",
3474
- {
3475
- value: r.config.method || "GET",
3476
- onChange: (n) => a({ config: { ...r.config, method: n.target.value } }),
3477
- children: ["GET", "POST", "PUT", "PATCH", "DELETE"].map((n) => /* @__PURE__ */ e("option", { value: n, children: n }, n))
3478
- }
3479
- )
3480
- ] }),
3481
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3482
- /* @__PURE__ */ e("label", { children: "URL" }),
3483
- /* @__PURE__ */ e(
3484
- "input",
3485
- {
3486
- type: "text",
3487
- value: r.config.url || "",
3488
- onChange: (n) => a({ config: { ...r.config, url: n.target.value } }),
3489
- placeholder: "https://api.example.com/endpoint"
3490
- }
3491
- )
3492
- ] })
3493
- ] }),
3494
- r.type === "delay" && /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3495
- /* @__PURE__ */ e("label", { children: "Duration (ms)" }),
3496
- /* @__PURE__ */ e(
3497
- "input",
3498
- {
3499
- type: "number",
3500
- value: r.config.duration || 1e3,
3501
- onChange: (n) => a({ config: { ...r.config, duration: parseInt(n.target.value, 10) } })
3502
- }
3503
- )
3504
- ] }),
3505
- r.type === "set-variable" && /* @__PURE__ */ t(F, { children: [
3506
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3507
- /* @__PURE__ */ e("label", { children: "Variable Name" }),
3508
- /* @__PURE__ */ e(
3509
- "input",
3510
- {
3511
- type: "text",
3512
- value: r.config.name || "",
3513
- onChange: (n) => a({ config: { ...r.config, name: n.target.value } })
3514
- }
3515
- )
3516
- ] }),
3517
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3518
- /* @__PURE__ */ e("label", { children: "Value" }),
3519
- /* @__PURE__ */ e(
3520
- "input",
3521
- {
3522
- type: "text",
3523
- value: r.config.value || "",
3524
- onChange: (n) => a({ config: { ...r.config, value: n.target.value } })
3525
- }
3526
- )
3527
- ] })
3528
- ] }),
3529
- r.type === "function" && /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3530
- /* @__PURE__ */ e("label", { children: "Code" }),
3531
- /* @__PURE__ */ e(
3532
- "textarea",
3533
- {
3534
- value: r.config.code || "",
3535
- onChange: (n) => a({ config: { ...r.config, code: n.target.value } }),
3536
- rows: 10,
3537
- className: "nice-integration-builder__code-input"
3538
- }
3539
- )
3540
- ] }),
3541
- r.type === "email" && /* @__PURE__ */ t(F, { children: [
3542
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3543
- /* @__PURE__ */ e("label", { children: "To" }),
3544
- /* @__PURE__ */ e(
3545
- "input",
3546
- {
3547
- type: "text",
3548
- value: r.config.to || "",
3549
- onChange: (n) => a({ config: { ...r.config, to: n.target.value } })
3550
- }
3551
- )
3552
- ] }),
3553
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3554
- /* @__PURE__ */ e("label", { children: "Subject" }),
3555
- /* @__PURE__ */ e(
3556
- "input",
3557
- {
3558
- type: "text",
3559
- value: r.config.subject || "",
3560
- onChange: (n) => a({ config: { ...r.config, subject: n.target.value } })
3561
- }
3562
- )
3563
- ] }),
3564
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3565
- /* @__PURE__ */ e("label", { children: "Body" }),
3566
- /* @__PURE__ */ e(
3567
- "textarea",
3568
- {
3569
- value: r.config.body || "",
3570
- onChange: (n) => a({ config: { ...r.config, body: n.target.value } }),
3571
- rows: 5
3572
- }
3573
- )
3574
- ] })
3575
- ] })
3576
- ] })
3577
- ] });
3578
- }
3579
- function ur({ variables: r, onChange: a }) {
3580
- const i = () => {
3581
- a({ ...r, newVariable: "" });
3582
- };
3583
- return /* @__PURE__ */ t("div", { className: "nice-integration-builder__variables", children: [
3584
- /* @__PURE__ */ e("h4", { children: "Flow Variables" }),
3585
- /* @__PURE__ */ e("div", { className: "nice-integration-builder__variables-list", children: Object.entries(r).map(([n, c]) => /* @__PURE__ */ t("div", { className: "nice-integration-builder__variable-row", children: [
3586
- /* @__PURE__ */ e(
3587
- "input",
3588
- {
3589
- type: "text",
3590
- value: n,
3591
- onChange: (u) => {
3592
- const { [n]: l, ...y } = r;
3593
- a({ ...y, [u.target.value]: c });
3594
- },
3595
- placeholder: "Name"
3596
- }
3597
- ),
3598
- /* @__PURE__ */ e(
3599
- "input",
3600
- {
3601
- type: "text",
3602
- value: String(c),
3603
- onChange: (u) => a({ ...r, [n]: u.target.value }),
3604
- placeholder: "Value"
3605
- }
3606
- ),
3607
- /* @__PURE__ */ e(
3608
- "button",
3609
- {
3610
- onClick: () => {
3611
- const { [n]: u, ...l } = r;
3612
- a(l);
3613
- },
3614
- children: "×"
3615
- }
3616
- )
3617
- ] }, n)) }),
3618
- /* @__PURE__ */ e("button", { onClick: i, children: "+ Add Variable" })
3619
- ] });
3620
- }
3621
- function br({
3622
- errorHandling: r,
3623
- schedule: a,
3624
- onChange: i
3625
- }) {
3626
- return /* @__PURE__ */ t("div", { className: "nice-integration-builder__settings", children: [
3627
- /* @__PURE__ */ e("h4", { children: "Error Handling" }),
3628
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3629
- /* @__PURE__ */ e("label", { children: "Strategy" }),
3630
- /* @__PURE__ */ t(
3631
- "select",
3632
- {
3633
- value: r.strategy,
3634
- onChange: (n) => i(
3635
- { ...r, strategy: n.target.value },
3636
- a
3637
- ),
3638
- children: [
3639
- /* @__PURE__ */ e("option", { value: "stop", children: "Stop on error" }),
3640
- /* @__PURE__ */ e("option", { value: "continue", children: "Continue on error" }),
3641
- /* @__PURE__ */ e("option", { value: "retry", children: "Retry on error" })
3642
- ]
3643
- }
3644
- )
3645
- ] }),
3646
- r.strategy === "retry" && /* @__PURE__ */ t(F, { children: [
3647
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3648
- /* @__PURE__ */ e("label", { children: "Max Retries" }),
3649
- /* @__PURE__ */ e(
3650
- "input",
3651
- {
3652
- type: "number",
3653
- value: r.maxRetries || 3,
3654
- onChange: (n) => i({ ...r, maxRetries: parseInt(n.target.value, 10) }, a)
3655
- }
3656
- )
3657
- ] }),
3658
- /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3659
- /* @__PURE__ */ e("label", { children: "Retry Delay (ms)" }),
3660
- /* @__PURE__ */ e(
3661
- "input",
3662
- {
3663
- type: "number",
3664
- value: r.retryDelay || 1e3,
3665
- onChange: (n) => i({ ...r, retryDelay: parseInt(n.target.value, 10) }, a)
3666
- }
3667
- )
3668
- ] })
3669
- ] }),
3670
- /* @__PURE__ */ e("h4", { children: "Schedule" }),
3671
- /* @__PURE__ */ e("div", { className: "nice-integration-builder__field", children: /* @__PURE__ */ t("label", { children: [
3672
- /* @__PURE__ */ e(
3673
- "input",
3674
- {
3675
- type: "checkbox",
3676
- checked: (a == null ? void 0 : a.enabled) || !1,
3677
- onChange: (n) => i(r, { ...a, enabled: n.target.checked })
3678
- }
3679
- ),
3680
- "Enable scheduled execution"
3681
- ] }) }),
3682
- (a == null ? void 0 : a.enabled) && /* @__PURE__ */ t("div", { className: "nice-integration-builder__field", children: [
3683
- /* @__PURE__ */ e("label", { children: "Cron Expression" }),
3684
- /* @__PURE__ */ e(
3685
- "input",
3686
- {
3687
- type: "text",
3688
- value: a.cron || "",
3689
- onChange: (n) => i(r, { ...a, cron: n.target.value }),
3690
- placeholder: "0 0 * * *"
3691
- }
3692
- )
3693
- ] })
3694
- ] });
3695
- }
3696
- const hr = [
3697
- {
3698
- target: ".nice-webhook-tester",
3699
- titleKey: "tutorial.webhookTester.intro.title",
3700
- title: "Webhook tester",
3701
- contentKey: "tutorial.webhookTester.intro.content",
3702
- content: "Pick a saved payload (or write one), optionally sign it, send it to the endpoint and inspect the response.",
3703
- placement: "auto"
3704
- }
3705
- ];
3706
- function me(r) {
3707
- return r ? Object.entries(r).map(([a, i]) => ({ key: a, value: i })) : [];
3708
- }
3709
- function ye(r) {
3710
- const a = {};
3711
- for (const i of r)
3712
- i.key.trim() !== "" && (a[i.key] = i.value);
3713
- return a;
3714
- }
3715
- async function gr(r, a) {
3716
- var l;
3717
- const i = (l = globalThis.crypto) == null ? void 0 : l.subtle;
3718
- if (!i)
3719
- throw new Error("Web Crypto (crypto.subtle) is unavailable in this environment");
3720
- const n = new TextEncoder(), c = await i.importKey(
3721
- "raw",
3722
- n.encode(r),
3723
- { name: "HMAC", hash: "SHA-256" },
3724
- !1,
3725
- ["sign"]
3726
- ), u = await i.sign("HMAC", c, n.encode(a));
3727
- return [...new Uint8Array(u)].map((y) => y.toString(16).padStart(2, "0")).join("");
3728
- }
3729
- const Sr = ue(
3730
- function(a, i) {
3731
- const {
3732
- url: n = "",
3733
- method: c = "POST",
3734
- headers: u,
3735
- payload: l = "",
3736
- samples: y = [],
3737
- onSend: b,
3738
- signing: d,
3739
- onSaveSample: h,
3740
- tutorial: S,
3741
- className: m,
3742
- style: k,
3743
- id: g,
3744
- "data-testid": P
3745
- } = a, [C, O] = v(n), [U, W] = v(c), [$, L] = v(() => me(u)), [I, j] = v(l), [w, N] = v(""), [x, K] = v(!1), [q, B] = v(null), [M, J] = v(null), V = Ee(() => {
3746
- const o = /* @__PURE__ */ new Map();
3747
- for (const _ of y)
3748
- o.set(_.id, _);
3749
- return o;
3750
- }, [y]), Y = (o) => {
3751
- N(o);
3752
- const _ = V.get(o);
3753
- _ && (j(_.payload), _.headers && L(me(_.headers)));
3754
- }, G = (o, _) => {
3755
- L((E) => E.map((H, A) => A === o ? { ...H, ..._ } : H));
3756
- }, Q = async () => {
3757
- K(!0), B(null), J(null);
3758
- try {
3759
- const o = ye($);
3760
- if (d && d.secret) {
3761
- const A = await gr(d.secret, I);
3762
- o[d.header] = `${d.prefix ?? ""}${A}`;
3763
- }
3764
- const _ = typeof performance < "u" ? performance.now() : Date.now(), E = await b({ url: C, method: U ?? "POST", headers: o, body: I }), H = Math.round(
3765
- (typeof performance < "u" ? performance.now() : Date.now()) - _
3766
- );
3767
- J({ ...E, durationMs: E.durationMs ?? H });
3768
- } catch (o) {
3769
- B(o instanceof Error ? o.message : String(o));
3770
- } finally {
3771
- K(!1);
3772
- }
3773
- }, Z = () => {
3774
- var _;
3775
- if (!h)
3776
- return;
3777
- const o = typeof window < "u" && ((_ = window.prompt) == null ? void 0 : _.call(window, "Sample name")) || "";
3778
- o && h({
3779
- id: `sample_${Date.now().toString(36)}`,
3780
- name: o,
3781
- payload: I,
3782
- headers: ye($)
3783
- });
3784
- }, p = M == null ? "" : M.status >= 200 && M.status < 300 ? " nice-webhook-tester__status--ok" : " nice-webhook-tester__status--error", s = "nice-webhook-tester" + (m ? ` ${m}` : "");
3785
- return /* @__PURE__ */ t("div", { ref: i, id: g, className: s, style: k, "data-testid": P, children: [
3786
- S && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(ie, { steps: ae(S, hr) }) }),
3787
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__bar", children: [
3788
- /* @__PURE__ */ e(
3789
- "select",
3790
- {
3791
- className: "nice-webhook-tester__method",
3792
- value: U,
3793
- onChange: (o) => W(o.target.value),
3794
- "aria-label": "Method",
3795
- children: ["POST", "PUT", "GET", "PATCH", "DELETE"].map((o) => /* @__PURE__ */ e("option", { value: o, children: o }, o))
3796
- }
3797
- ),
3798
- /* @__PURE__ */ e(
3799
- "input",
3800
- {
3801
- type: "text",
3802
- className: "nice-webhook-tester__url",
3803
- value: C,
3804
- placeholder: "https://example.com/api/payments/stripe/webhook",
3805
- onChange: (o) => O(o.target.value),
3806
- "aria-label": "URL"
3807
- }
3808
- ),
3809
- /* @__PURE__ */ e(
3810
- "button",
3811
- {
3812
- type: "button",
3813
- className: "nice-webhook-tester__send",
3814
- onClick: () => void Q(),
3815
- disabled: x || C.trim() === "",
3816
- children: x ? "Sending…" : "Send"
3817
- }
3818
- )
3819
- ] }),
3820
- y.length > 0 && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__samples", children: /* @__PURE__ */ t("label", { children: [
3821
- "Sample:",
3822
- " ",
3823
- /* @__PURE__ */ t("select", { value: w, onChange: (o) => Y(o.target.value), children: [
3824
- /* @__PURE__ */ e("option", { value: "", children: "— choose a saved payload —" }),
3825
- y.map((o) => /* @__PURE__ */ e("option", { value: o.id, children: o.name }, o.id))
3826
- ] })
3827
- ] }) }),
3828
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__headers", children: [
3829
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__section-label", children: [
3830
- "Headers",
3831
- d && /* @__PURE__ */ t("span", { className: "nice-webhook-tester__signed", children: [
3832
- " ",
3833
- "· auto-signs ",
3834
- /* @__PURE__ */ e("code", { children: d.header })
3835
- ] })
3836
- ] }),
3837
- $.map((o, _) => /* @__PURE__ */ t("div", { className: "nice-webhook-tester__header-row", children: [
3838
- /* @__PURE__ */ e(
3839
- "input",
3840
- {
3841
- type: "text",
3842
- value: o.key,
3843
- placeholder: "Header",
3844
- onChange: (E) => G(_, { key: E.target.value }),
3845
- "aria-label": "Header name"
3846
- }
3847
- ),
3848
- /* @__PURE__ */ e(
3849
- "input",
3850
- {
3851
- type: "text",
3852
- value: o.value,
3853
- placeholder: "Value",
3854
- onChange: (E) => G(_, { value: E.target.value }),
3855
- "aria-label": "Header value"
3856
- }
3857
- ),
3858
- /* @__PURE__ */ e(
3859
- "button",
3860
- {
3861
- type: "button",
3862
- onClick: () => L((E) => E.filter((H, A) => A !== _)),
3863
- "aria-label": "Remove header",
3864
- children: "✕"
3865
- }
3866
- )
3867
- ] }, _)),
3868
- /* @__PURE__ */ e(
3869
- "button",
3870
- {
3871
- type: "button",
3872
- className: "nice-webhook-tester__add-header",
3873
- onClick: () => L((o) => [...o, { key: "", value: "" }]),
3874
- children: "+ Header"
3875
- }
3876
- )
3877
- ] }),
3878
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__payload", children: [
3879
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__section-label", children: [
3880
- "Payload",
3881
- h && /* @__PURE__ */ e("button", { type: "button", className: "nice-webhook-tester__save", onClick: Z, children: "Save as sample" })
3882
- ] }),
3883
- /* @__PURE__ */ e(
3884
- "textarea",
3885
- {
3886
- className: "nice-webhook-tester__textarea",
3887
- value: I,
3888
- spellCheck: !1,
3889
- rows: 8,
3890
- placeholder: '{ "type": "payment.succeeded", "data": { ... } }',
3891
- onChange: (o) => j(o.target.value),
3892
- "aria-label": "Payload"
3893
- }
3894
- )
3895
- ] }),
3896
- q && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: q }),
3897
- M && /* @__PURE__ */ t("div", { className: "nice-webhook-tester__response", children: [
3898
- /* @__PURE__ */ t("div", { className: "nice-webhook-tester__section-label", children: [
3899
- "Response",
3900
- " ",
3901
- /* @__PURE__ */ e("span", { className: "nice-webhook-tester__status" + p, children: M.status }),
3902
- M.durationMs != null && /* @__PURE__ */ t("span", { className: "nice-webhook-tester__time", children: [
3903
- " · ",
3904
- M.durationMs,
3905
- " ms"
3906
- ] })
3907
- ] }),
3908
- M.body != null && /* @__PURE__ */ e("pre", { className: "nice-webhook-tester__response-body", children: M.body })
3909
- ] })
3910
- ] });
3911
- }
3912
- );
1
+ import { N as r, a as s, b as a, c } from "./index-HyLjDY_p.js";
3913
2
  export {
3914
- wr as NiceAPIDesigner,
3915
- Nr as NiceAPITester,
3916
- xr as NiceIntegrationBuilder,
3917
- Sr as NiceWebhookTester
3
+ r as NiceAPIDesigner,
4
+ s as NiceAPITester,
5
+ a as NiceIntegrationBuilder,
6
+ c as NiceWebhookTester
3918
7
  };