treege 3.0.0-beta.11 → 3.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{ThemeContext-BC-hvzzD.js → ThemeContext-mnnnxuZU.js} +30 -30
  2. package/dist/{TreegeEditor-BCdlhdkk.js → TreegeEditor-DvCdZUeV.js} +989 -998
  3. package/dist/TreegeRenderer-DJaR2FqI.js +1441 -0
  4. package/dist/editor/constants/defaultNode.d.ts +1 -1
  5. package/dist/editor/constants/edgeTypes.d.ts +1 -1
  6. package/dist/editor/constants/nodeSpacing.d.ts +20 -0
  7. package/dist/editor/constants/nodeTypes.d.ts +1 -1
  8. package/dist/editor/hooks/useFlowConnections.d.ts +1 -0
  9. package/dist/editor.js +2 -2
  10. package/dist/main.js +3 -3
  11. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  12. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  13. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  14. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  15. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  16. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  17. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  18. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  19. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  20. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  21. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  22. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  23. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  24. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  25. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  26. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  27. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  28. package/dist/renderer/types/renderer.d.ts +9 -0
  29. package/dist/renderer/utils/form.d.ts +3 -2
  30. package/dist/renderer/utils/node.d.ts +9 -1
  31. package/dist/renderer.js +2 -2
  32. package/dist/shared/locales/ar.json.d.ts +1 -0
  33. package/dist/shared/locales/de.json.d.ts +1 -0
  34. package/dist/shared/locales/en.json.d.ts +1 -0
  35. package/dist/shared/locales/es.json.d.ts +1 -0
  36. package/dist/shared/locales/fr.json.d.ts +1 -0
  37. package/dist/shared/locales/it.json.d.ts +1 -0
  38. package/dist/shared/locales/pt.json.d.ts +1 -0
  39. package/package.json +2 -2
  40. package/dist/TreegeRenderer-BAvL4iDF.js +0 -1405
  41. package/dist/editor/hooks/useAddConnectedNode.d.ts +0 -7
  42. /package/dist/editor/features/TreegeEditor/nodes/{useBottomHandleClick.d.ts → hooks/useBottomHandleClick.d.ts} +0 -0
@@ -0,0 +1,1441 @@
1
+ import { j as e, i as Q, L as he, b as ze, e as it, F as R, f as I, I as L, C as Se, h as Ce, k as Ie, l as De, m as Re, n as A, o as k, P as ie, p as ce, B as re, q as de, r as Ve, s as b, t as Ee, v as _e, S as Me, w as Be, x as qe, y as Le, z as Ge, A as Ue, D as ct, E as dt, G as pe, N as le, a as ut, c as mt, g as ge, T as ft } from "./ThemeContext-mnnnxuZU.js";
2
+ import * as Pe from "react";
3
+ import { createContext as He, useContext as Ke, useMemo as H, useState as V, useCallback as Y, useEffect as K, useRef as J } from "react";
4
+ import { MapPin as $e, ChevronsUpDown as We, Check as Je, ChevronLeftIcon as ht, ChevronRightIcon as pt, ChevronDownIcon as Ae, Loader2 as xe, CircleIcon as gt } from "lucide-react";
5
+ import { getDefaultClassNames as Qe, DayPicker as xt } from "react-day-picker";
6
+ import * as ae from "@radix-ui/react-tooltip";
7
+ import * as we from "@radix-ui/react-radio-group";
8
+ const Xe = He(void 0), jt = () => Ke(Xe), hs = ({
9
+ children: t,
10
+ components: a,
11
+ googleApiKey: n,
12
+ language: s,
13
+ theme: o,
14
+ validationMode: l
15
+ }) => {
16
+ const r = {
17
+ components: a,
18
+ googleApiKey: n,
19
+ language: s,
20
+ theme: o,
21
+ validationMode: l
22
+ };
23
+ return /* @__PURE__ */ e.jsx(Xe.Provider, { value: r, children: t });
24
+ }, Oe = (t) => t == null ? null : typeof t == "boolean" || typeof t == "number" ? t : typeof t == "string" ? t === "" ? null : t : typeof t == "object" ? JSON.stringify(t) : String(t), bt = (t, a, n) => {
25
+ const s = Oe(t), o = Oe(a);
26
+ if (s === null || o === null)
27
+ switch (n) {
28
+ case "===":
29
+ return s === o;
30
+ case "!==":
31
+ return s !== o;
32
+ default:
33
+ return !1;
34
+ }
35
+ if ([">", "<", ">=", "<="].includes(n)) {
36
+ const l = Number(s), r = Number(o);
37
+ if (!(Number.isNaN(l) || Number.isNaN(r)))
38
+ switch (n) {
39
+ case ">":
40
+ return l > r;
41
+ case "<":
42
+ return l < r;
43
+ case ">=":
44
+ return l >= r;
45
+ case "<=":
46
+ return l <= r;
47
+ default:
48
+ return !1;
49
+ }
50
+ return !1;
51
+ }
52
+ switch (n) {
53
+ case "===": {
54
+ const l = Number(s), r = Number(o);
55
+ return Number.isNaN(l) || Number.isNaN(r) ? String(s) === String(o) : l === r;
56
+ }
57
+ case "!==": {
58
+ const l = Number(s), r = Number(o);
59
+ return Number.isNaN(l) || Number.isNaN(r) ? String(s) !== String(o) : l !== r;
60
+ }
61
+ default:
62
+ return !1;
63
+ }
64
+ }, je = (t, a, n) => {
65
+ const { field: s, operator: o, value: l } = t;
66
+ if (!(s && o) || l === void 0)
67
+ return !0;
68
+ let r = a[s];
69
+ if (r === void 0 && n) {
70
+ const d = n.get(s);
71
+ d && Q(d) && (r = a[d.id]);
72
+ }
73
+ return bt(r, l, o);
74
+ }, vt = (t, a, n) => {
75
+ if (!t || t.length === 0)
76
+ return !0;
77
+ if (t.length === 1)
78
+ return je(t[0], a, n);
79
+ let s = je(t[0], a, n);
80
+ for (let o = 1; o < t.length; o += 1) {
81
+ const l = t[o], r = je(l, a, n), d = t[o - 1].logicalOperator || he.AND;
82
+ if (d === he.AND) {
83
+ if (s = s && r, !s)
84
+ return !1;
85
+ } else if (d === he.OR && (s = s || r, s))
86
+ return !0;
87
+ }
88
+ return s;
89
+ }, Nt = (t) => t.filter(Q), Ye = (t) => {
90
+ if (t.data.name)
91
+ return t.data.name;
92
+ if (t.data.label) {
93
+ if (t.data.label.en)
94
+ return t.data.label.en;
95
+ const a = Object.values(t.data.label).find(Boolean);
96
+ if (a)
97
+ return a;
98
+ }
99
+ return t.id;
100
+ }, be = (t) => t == null || typeof t == "string" && t.trim() === "" ? !0 : Array.isArray(t) && t.length === 0, yt = (t, a) => {
101
+ if (!t)
102
+ return !1;
103
+ const n = a[t];
104
+ return n != null;
105
+ }, wt = (t, a) => {
106
+ const n = {};
107
+ return a.forEach((s) => {
108
+ const o = s.id, l = Ye(s);
109
+ t[o] !== void 0 && (n[l] = t[o]);
110
+ }), n;
111
+ }, Ft = (t) => {
112
+ const a = /* @__PURE__ */ new Map();
113
+ return t.forEach((n) => {
114
+ const s = a.get(n.source);
115
+ s ? s.push(n) : a.set(n.source, [n]);
116
+ }), a;
117
+ }, St = (t, a, n) => {
118
+ const s = [], o = [], l = [];
119
+ t.forEach((u) => {
120
+ const m = u.data?.isFallback, c = u.data?.conditions?.length;
121
+ m ? l.push(u) : c ? o.push(u) : s.push(u);
122
+ });
123
+ const r = [...s];
124
+ if (o.length === 0)
125
+ return l.length > 0 && r.length === 0 && r.push(...l), { edgesToFollow: r, waitingForInput: !1 };
126
+ if (!o.every((u) => {
127
+ const m = u.data?.conditions;
128
+ return m ? m.every((c) => {
129
+ if (!c.field)
130
+ return !0;
131
+ const h = n.get(c.field), p = Q(h) ? h.id : c.field;
132
+ return yt(p, a);
133
+ }) : !1;
134
+ }))
135
+ return l.length > 0 && r.push(...l), { edgesToFollow: r, waitingForInput: r.length === 0 };
136
+ const i = o.filter((u) => vt(u.data?.conditions, a, n));
137
+ return i.length > 0 ? (r.push(...i), { edgesToFollow: r, waitingForInput: !1 }) : (r.push(...l), { edgesToFollow: r, waitingForInput: !1 });
138
+ }, Ze = (t, a) => !a.some((n) => n.target === t), Ct = (t, a) => {
139
+ const n = t.filter((s) => Ze(s.id, a));
140
+ return n.find(Q) || n[0];
141
+ }, It = (t, a, n, s) => {
142
+ t.forEach((o) => {
143
+ const l = s.get(o);
144
+ if (!l)
145
+ return;
146
+ let { parentId: r } = l;
147
+ const d = /* @__PURE__ */ new Set();
148
+ for (; r && !d.has(r); ) {
149
+ if (d.add(r), a.add(r), !n.has(r)) {
150
+ const i = n.get(o);
151
+ i !== void 0 && n.set(r, i);
152
+ }
153
+ r = s.get(r)?.parentId;
154
+ }
155
+ });
156
+ }, Dt = (t, a, n) => {
157
+ const s = Ct(t, a);
158
+ if (!s)
159
+ return {
160
+ endOfPathReached: !0,
161
+ visibleNodeIds: /* @__PURE__ */ new Set(),
162
+ visibleNodes: [],
163
+ visibleRootNodes: []
164
+ };
165
+ const o = new Map(t.map((f) => [f.id, f])), l = Ft(a), r = [], d = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
166
+ let u = !1;
167
+ const m = (f) => {
168
+ if (i.has(f))
169
+ return;
170
+ i.add(f);
171
+ const w = o.get(f);
172
+ if (!w)
173
+ return;
174
+ d.add(f), r.push(w);
175
+ const T = l.get(f) || [], { edgesToFollow: y, waitingForInput: N } = St(T, n, o);
176
+ if (N) {
177
+ u = !0;
178
+ return;
179
+ }
180
+ y.forEach((x) => {
181
+ m(x.target);
182
+ });
183
+ };
184
+ m(s.id);
185
+ const c = new Map(r.map((f, w) => [f.id, w])), h = new Set(d);
186
+ It(d, h, c, o);
187
+ const p = t.filter((f) => h.has(f.id)).sort((f, w) => (c.get(f.id) ?? Number.MAX_SAFE_INTEGER) - (c.get(w.id) ?? Number.MAX_SAFE_INTEGER)), j = p.filter((f) => !(f.parentId && h.has(f.parentId)));
188
+ return {
189
+ endOfPathReached: !u,
190
+ visibleNodeIds: h,
191
+ visibleNodes: p,
192
+ visibleRootNodes: j
193
+ };
194
+ }, Rt = (t) => {
195
+ if (t.length === 1)
196
+ return t[0];
197
+ const a = new Set(t.map((s) => s.id)), n = /* @__PURE__ */ new Set();
198
+ return t.forEach((s) => {
199
+ s.nodes.forEach((o) => {
200
+ if (ze(o)) {
201
+ const l = o.data.targetId;
202
+ l && a.has(l) && n.add(l);
203
+ }
204
+ });
205
+ }), t.find((s) => !n.has(s.id)) || t[0];
206
+ }, et = (t, a, n, s, o = /* @__PURE__ */ new Set()) => {
207
+ const l = /* @__PURE__ */ new Set();
208
+ for (const r of t)
209
+ if (n.has(r)) {
210
+ const d = s.get(r), i = d ? a.get(d) : void 0;
211
+ if (i) {
212
+ if (d && o.has(d))
213
+ continue;
214
+ d && o.add(d);
215
+ const u = new Set(i.nodes.map((c) => c.id)), m = et(u, a, n, s, o);
216
+ for (const c of m)
217
+ l.add(c);
218
+ }
219
+ } else
220
+ l.add(r);
221
+ return l;
222
+ }, At = (t, a) => {
223
+ const n = /* @__PURE__ */ new Set();
224
+ return a.forEach((s) => {
225
+ t.has(s.source) && t.has(s.target) && n.add(s.source);
226
+ }), Array.from(t).filter((s) => !n.has(s));
227
+ }, tt = (t) => {
228
+ if (!t)
229
+ return { edges: [], id: "empty", nodes: [] };
230
+ const a = Array.isArray(t) ? t : [t];
231
+ if (a.length === 0)
232
+ return { edges: [], id: "empty", nodes: [] };
233
+ const n = Rt(a);
234
+ if (a.length === 1)
235
+ return n;
236
+ const s = new Map(a.map((h) => [h.id, h])), o = [], l = [...n.edges], r = /* @__PURE__ */ new Set([n.id]), d = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), m = (h) => {
237
+ const p = [];
238
+ return h.forEach((j) => {
239
+ if (!ze(j)) {
240
+ p.push(j);
241
+ return;
242
+ }
243
+ const f = j.data.targetId;
244
+ if (!f)
245
+ return;
246
+ const w = s.get(f);
247
+ if (!w) {
248
+ console.warn(`Flow with id "${f}" not found`);
249
+ return;
250
+ }
251
+ const T = w.nodes.find((y) => !y.parentId);
252
+ if (!T) {
253
+ console.warn(`Flow "${f}" has no root node; preserving FlowNode "${j.id}"`), p.push(j);
254
+ return;
255
+ }
256
+ d.set(j.id, T.id), i.set(j.id, f), r.has(f) || (r.add(f), l.push(...w.edges), p.push(...m(w.nodes)));
257
+ }), p;
258
+ };
259
+ o.push(...m(n.nodes)), l.forEach((h) => {
260
+ if (d.has(h.source)) {
261
+ const p = u.get(h.source);
262
+ p ? p.push(h) : u.set(h.source, [h]);
263
+ }
264
+ });
265
+ const c = l.map((h) => {
266
+ if (d.has(h.source))
267
+ return null;
268
+ const p = d.get(h.target);
269
+ return p ? { ...h, target: p } : h;
270
+ }).filter((h) => h !== null);
271
+ return d.forEach((h, p) => {
272
+ const j = u.get(p);
273
+ if (!j?.length)
274
+ return;
275
+ const f = i.get(p), w = f ? s.get(f) : void 0;
276
+ if (!w)
277
+ return;
278
+ const T = new Set(w.nodes.map((x) => x.id)), y = et(
279
+ T,
280
+ s,
281
+ d,
282
+ i,
283
+ new Set(f ? [f] : [])
284
+ );
285
+ At(y, c).forEach((x) => {
286
+ j.forEach((g) => {
287
+ const C = d.get(g.target) ?? g.target, _ = g.id ?? `${p}__${g.target}`;
288
+ c.push({
289
+ ...g,
290
+ id: `${x}__${_}`,
291
+ source: x,
292
+ target: C
293
+ });
294
+ });
295
+ });
296
+ }), {
297
+ edges: c,
298
+ id: n.id,
299
+ nodes: o
300
+ };
301
+ }, st = He(null), kt = ({ children: t, value: a }) => /* @__PURE__ */ e.jsx(st.Provider, { value: a, children: t }), ue = () => {
302
+ const a = Ke(st) ?? {
303
+ flows: null,
304
+ formErrors: {},
305
+ formValues: {},
306
+ googleApiKey: void 0,
307
+ language: "",
308
+ setFieldValue: () => {
309
+ }
310
+ }, n = H(() => a.flows ? tt(a.flows).edges : [], [a.flows]);
311
+ return {
312
+ ...a,
313
+ edges: n
314
+ };
315
+ }, O = (t) => {
316
+ const a = ue(), n = t ?? a.language;
317
+ return it(n);
318
+ }, Tt = (t, a = {}, n = "en") => {
319
+ const s = H(() => tt(t), [t]), { nodes: o, edges: l } = s, r = H(() => Nt(o), [o]), d = O(n), [i, u] = V({}), [m, c] = V(() => {
320
+ const y = { ...a };
321
+ return o.forEach((N) => {
322
+ if (Q(N)) {
323
+ const x = N.id;
324
+ if (y[x] !== void 0)
325
+ return;
326
+ const { defaultValue: g } = N.data;
327
+ if (!g)
328
+ return;
329
+ if (g.type === "static" && g.staticValue !== void 0 && (y[x] = g.staticValue), g.type === "reference" && g.referenceField) {
330
+ const { referenceField: C } = g, _ = y[C];
331
+ _ !== void 0 && (y[x] = _);
332
+ }
333
+ }
334
+ }), y;
335
+ }), { endOfPathReached: h, visibleNodes: p, visibleRootNodes: j } = H(
336
+ () => Dt(o, l, m),
337
+ [o, l, m]
338
+ ), f = Y((y, N) => {
339
+ c((x) => ({
340
+ ...x,
341
+ [y]: N
342
+ })), u((x) => {
343
+ const g = { ...x };
344
+ return delete g[y], g;
345
+ });
346
+ }, []), w = Y(
347
+ (y) => {
348
+ const N = {};
349
+ p.forEach((C) => {
350
+ if (Q(C)) {
351
+ const _ = C.id, G = m[_];
352
+ if (C.data.required && be(G)) {
353
+ N[_] = d(C.data.errorMessage) || d("validation.required");
354
+ return;
355
+ }
356
+ if (!be(G) && C.data.pattern)
357
+ try {
358
+ new RegExp(C.data.pattern).test(String(G)) || (N[_] = d(C.data.errorMessage) || d("validation.invalidFormat"));
359
+ } catch (W) {
360
+ console.error(`Invalid pattern for field ${_}:`, W);
361
+ }
362
+ }
363
+ });
364
+ const x = y ? y(m, p) : {}, g = {
365
+ ...N,
366
+ ...x
367
+ };
368
+ return u(g), {
369
+ errors: g,
370
+ hasCustomErrors: Object.keys(x).length > 0,
371
+ isValid: Object.keys(g).length === 0
372
+ };
373
+ },
374
+ [p, m, d]
375
+ ), T = H(() => {
376
+ const y = [];
377
+ return p.forEach((N) => {
378
+ if (!Q(N))
379
+ return;
380
+ const x = N.id, g = m[x];
381
+ if (N.data.required && be(g)) {
382
+ const C = d(N.data.label) || x;
383
+ y.push(C);
384
+ }
385
+ }), y;
386
+ }, [p, m, d]);
387
+ return {
388
+ canSubmit: h && o.length > 0,
389
+ formErrors: i,
390
+ formValues: m,
391
+ inputNodes: r,
392
+ mergedFlow: s,
393
+ missingRequiredFields: T,
394
+ setFieldValue: f,
395
+ setFormErrors: u,
396
+ t: d,
397
+ validateForm: w,
398
+ visibleNodes: p,
399
+ visibleRootNodes: j
400
+ };
401
+ }, Et = ({ children: t, onSubmit: a }) => /* @__PURE__ */ e.jsx("form", { onSubmit: a, className: "mx-auto max-w-2xl gap-y-3", children: t }), _t = ({ node: t, children: a }) => {
402
+ const n = O();
403
+ return /* @__PURE__ */ e.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
404
+ t.data.label && /* @__PURE__ */ e.jsx("h3", { className: "text-lg font-semibold mb-4", children: n(t.data.label) }),
405
+ a
406
+ ] });
407
+ }, Pt = async (t, a) => {
408
+ if (!t || t.trim().length < 3)
409
+ return [];
410
+ try {
411
+ const n = await fetch(
412
+ `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(t)}&format=jsonv2&addressdetails=1&limit=5`,
413
+ {
414
+ headers: {
415
+ Accept: "application/json",
416
+ "User-Agent": "Treege Renderer",
417
+ ...a && { "Accept-Language": a }
418
+ }
419
+ }
420
+ );
421
+ return n.ok ? (await n.json()).map((o) => ({
422
+ label: o.display_name,
423
+ value: o.display_name
424
+ })) : [];
425
+ } catch (n) {
426
+ return console.error("Nominatim fetch error:", n), [];
427
+ }
428
+ }, $t = (t) => !t || t.trim().length < 3 ? Promise.resolve([]) : new Promise((a) => {
429
+ if (!window.google?.maps?.places) {
430
+ console.warn("Google Places SDK not loaded yet"), a([]);
431
+ return;
432
+ }
433
+ new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: t }, (s, o) => {
434
+ if (o !== google.maps.places.PlacesServiceStatus.OK || !s) {
435
+ console.warn("Google Places API status:", o), a([]);
436
+ return;
437
+ }
438
+ a(
439
+ s.map((l) => ({
440
+ label: l.description,
441
+ value: l.description
442
+ }))
443
+ );
444
+ });
445
+ }), Ot = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, id: d, name: i }) => {
446
+ const [u, m] = V(""), [c, h] = V([]), [p, j] = V(!1), { googleApiKey: f, language: w } = ue(), T = O(), y = Y(
447
+ (x) => {
448
+ n(x.value), m(x.value), j(!1);
449
+ },
450
+ [n]
451
+ );
452
+ K(() => {
453
+ if (!u || u.trim().length < 3) {
454
+ h([]);
455
+ return;
456
+ }
457
+ const x = setTimeout(async () => {
458
+ const g = f ? await $t(u) : await Pt(u, w);
459
+ h(g);
460
+ }, 300);
461
+ return () => clearTimeout(x);
462
+ }, [u, f, w]);
463
+ const N = Y(
464
+ (x) => {
465
+ n(x), m(x), x.length >= 3 && j(!0);
466
+ },
467
+ [n]
468
+ );
469
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
470
+ f && /* @__PURE__ */ e.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${f}&libraries=places` }),
471
+ /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
472
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
473
+ o || t.data.name,
474
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
475
+ ] }),
476
+ /* @__PURE__ */ e.jsxs("div", { className: "relative", children: [
477
+ /* @__PURE__ */ e.jsx(
478
+ L,
479
+ {
480
+ type: "text",
481
+ id: d,
482
+ name: i,
483
+ value: a || "",
484
+ onChange: (x) => N(x.target.value),
485
+ onFocus: () => {
486
+ c.length > 0 && j(!0);
487
+ },
488
+ placeholder: l || T("renderer.defaultAddressInput.enterAddress"),
489
+ className: "pr-10",
490
+ autoComplete: "off"
491
+ }
492
+ ),
493
+ /* @__PURE__ */ e.jsx($e, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
494
+ p && /* @__PURE__ */ e.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ e.jsx(Se, { children: /* @__PURE__ */ e.jsxs(Ce, { children: [
495
+ /* @__PURE__ */ e.jsx(Ie, { children: T("renderer.defaultAddressInput.noAddressesFound") }),
496
+ /* @__PURE__ */ e.jsx(De, { children: c.map((x, g) => /* @__PURE__ */ e.jsxs(
497
+ Re,
498
+ {
499
+ value: x.value,
500
+ onSelect: () => y(x),
501
+ onMouseDown: (C) => C.preventDefault(),
502
+ children: [
503
+ /* @__PURE__ */ e.jsx($e, { className: "mr-2 h-4 w-4" }),
504
+ x.label
505
+ ]
506
+ },
507
+ g
508
+ )) })
509
+ ] }) }) })
510
+ ] }),
511
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
512
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
513
+ ] })
514
+ ] });
515
+ }, zt = ({
516
+ node: t,
517
+ value: a,
518
+ setValue: n,
519
+ error: s,
520
+ label: o,
521
+ placeholder: l,
522
+ helperText: r,
523
+ id: d
524
+ }) => {
525
+ const i = O(), [u, m] = V(!1), c = `${d}-trigger`, h = `${d}-error`, p = t.data.options || [], j = p.find((f) => f.value === a);
526
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
527
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: c, children: [
528
+ o || t.data.name,
529
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
530
+ ] }),
531
+ /* @__PURE__ */ e.jsxs(ie, { open: u, onOpenChange: m, children: [
532
+ /* @__PURE__ */ e.jsx(ce, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
533
+ re,
534
+ {
535
+ id: c,
536
+ variant: "outline",
537
+ role: "combobox",
538
+ "aria-expanded": u,
539
+ "aria-invalid": !!s || void 0,
540
+ "aria-describedby": s ? h : void 0,
541
+ className: "w-full justify-between font-normal",
542
+ children: [
543
+ a ? j?.label ? i(j.label) : a : l || i("renderer.defaultAutocompleteInput.selectOption"),
544
+ /* @__PURE__ */ e.jsx(We, { className: "ml-2 size-4 shrink-0 opacity-50" })
545
+ ]
546
+ }
547
+ ) }),
548
+ /* @__PURE__ */ e.jsx(de, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ e.jsxs(Se, { children: [
549
+ /* @__PURE__ */ e.jsx(Ve, { placeholder: l || i("renderer.defaultAutocompleteInput.search") }),
550
+ /* @__PURE__ */ e.jsxs(Ce, { children: [
551
+ /* @__PURE__ */ e.jsx(Ie, { children: i("renderer.defaultAutocompleteInput.noResults") }),
552
+ /* @__PURE__ */ e.jsx(De, { children: p.map((f) => /* @__PURE__ */ e.jsxs(
553
+ Re,
554
+ {
555
+ value: f.value,
556
+ disabled: f.disabled,
557
+ onSelect: (w) => {
558
+ n(w === a ? "" : w), m(!1);
559
+ },
560
+ children: [
561
+ /* @__PURE__ */ e.jsx(Je, { className: b("mr-2 size-4", a === f.value ? "opacity-100" : "opacity-0") }),
562
+ i(f.label)
563
+ ]
564
+ },
565
+ f.value
566
+ )) })
567
+ ] })
568
+ ] }) })
569
+ ] }),
570
+ s && /* @__PURE__ */ e.jsx(A, { id: h, children: s }),
571
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
572
+ ] });
573
+ }, Vt = ({ node: t, value: a, setValue: n, error: s, label: o, helperText: l, id: r, name: d }) => {
574
+ const i = O();
575
+ if (t.data.options && t.data.options.length > 0) {
576
+ const u = Array.isArray(a) ? a.map(String) : [], m = (c, h) => {
577
+ const p = h ? [...u, c] : u.filter((j) => j !== c);
578
+ n(p);
579
+ };
580
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
581
+ /* @__PURE__ */ e.jsxs(I, { className: "mb-1", htmlFor: r, children: [
582
+ o || t.data.name,
583
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
584
+ ] }),
585
+ /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: t.data.options.map((c, h) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
586
+ /* @__PURE__ */ e.jsx(
587
+ Ee,
588
+ {
589
+ id: `${r}-${c.value}`,
590
+ name: d,
591
+ checked: u.includes(String(c.value)),
592
+ onCheckedChange: (p) => m(String(c.value), !!p),
593
+ disabled: c.disabled
594
+ }
595
+ ),
596
+ /* @__PURE__ */ e.jsx(I, { htmlFor: `${r}-${c.value}`, className: "cursor-pointer font-normal text-sm", children: i(c.label) ? i(c.label) : c.value })
597
+ ] }, c.value + h)) }),
598
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
599
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l })
600
+ ] });
601
+ }
602
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
603
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
604
+ /* @__PURE__ */ e.jsx(
605
+ Ee,
606
+ {
607
+ id: r,
608
+ name: d,
609
+ checked: typeof a == "boolean" ? a : !1,
610
+ onCheckedChange: (u) => n(!!u)
611
+ }
612
+ ),
613
+ /* @__PURE__ */ e.jsxs("div", { children: [
614
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: r, className: "cursor-pointer font-medium text-sm", children: [
615
+ o || t.data.name,
616
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
617
+ ] }),
618
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l })
619
+ ] })
620
+ ] }),
621
+ s && /* @__PURE__ */ e.jsx(A, { children: s })
622
+ ] });
623
+ };
624
+ function at({
625
+ className: t,
626
+ classNames: a,
627
+ showOutsideDays: n = !0,
628
+ captionLayout: s = "label",
629
+ buttonVariant: o = "ghost",
630
+ formatters: l,
631
+ components: r,
632
+ ...d
633
+ }) {
634
+ const i = Qe();
635
+ return /* @__PURE__ */ e.jsx(
636
+ xt,
637
+ {
638
+ showOutsideDays: n,
639
+ className: b(
640
+ "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
641
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
642
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
643
+ t
644
+ ),
645
+ captionLayout: s,
646
+ formatters: {
647
+ formatMonthDropdown: (u) => u.toLocaleString("default", { month: "short" }),
648
+ ...l
649
+ },
650
+ classNames: {
651
+ button_next: b(
652
+ _e({ variant: o }),
653
+ "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
654
+ i.button_next
655
+ ),
656
+ button_previous: b(
657
+ _e({ variant: o }),
658
+ "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
659
+ i.button_previous
660
+ ),
661
+ caption_label: b(
662
+ "select-none font-medium",
663
+ s === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
664
+ i.caption_label
665
+ ),
666
+ day: b(
667
+ "relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
668
+ i.day
669
+ ),
670
+ disabled: b("text-muted-foreground opacity-50", i.disabled),
671
+ dropdown: b("absolute bg-popover inset-0 opacity-0", i.dropdown),
672
+ dropdown_root: b(
673
+ "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
674
+ i.dropdown_root
675
+ ),
676
+ dropdowns: b("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", i.dropdowns),
677
+ hidden: b("invisible", i.hidden),
678
+ month: b("flex flex-col w-full gap-4", i.month),
679
+ month_caption: b("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", i.month_caption),
680
+ months: b("flex gap-4 flex-col md:flex-row relative", i.months),
681
+ nav: b("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", i.nav),
682
+ outside: b("text-muted-foreground aria-selected:text-muted-foreground", i.outside),
683
+ range_end: b("rounded-r-md bg-accent", i.range_end),
684
+ range_middle: b("rounded-none", i.range_middle),
685
+ range_start: b("rounded-l-md bg-accent", i.range_start),
686
+ root: b("w-fit", i.root),
687
+ table: "w-full border-collapse",
688
+ today: b("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", i.today),
689
+ week: b("flex w-full mt-2", i.week),
690
+ week_number: b("text-[0.8rem] select-none text-muted-foreground", i.week_number),
691
+ week_number_header: b("select-none w-(--cell-size)", i.week_number_header),
692
+ weekday: b("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", i.weekday),
693
+ weekdays: b("flex", i.weekdays),
694
+ ...a
695
+ },
696
+ components: {
697
+ Chevron: ({ className: u, orientation: m, ...c }) => m === "left" ? /* @__PURE__ */ e.jsx(ht, { className: b("size-4", u), ...c }) : m === "right" ? /* @__PURE__ */ e.jsx(pt, { className: b("size-4", u), ...c }) : /* @__PURE__ */ e.jsx(Ae, { className: b("size-4", u), ...c }),
698
+ DayButton: Mt,
699
+ Root: ({ className: u, rootRef: m, ...c }) => /* @__PURE__ */ e.jsx("div", { "data-slot": "calendar", ref: m, className: b(u), ...c }),
700
+ WeekNumber: ({ children: u, ...m }) => /* @__PURE__ */ e.jsx("td", { ...m, children: /* @__PURE__ */ e.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: u }) }),
701
+ ...r
702
+ },
703
+ ...d
704
+ }
705
+ );
706
+ }
707
+ function Mt({ className: t, day: a, modifiers: n, ...s }) {
708
+ const o = Qe(), l = Pe.useRef(null);
709
+ return Pe.useEffect(() => {
710
+ n.focused && l.current?.focus();
711
+ }, [n.focused]), /* @__PURE__ */ e.jsx(
712
+ re,
713
+ {
714
+ ref: l,
715
+ variant: "ghost",
716
+ size: "icon",
717
+ "data-day": a.date.toLocaleDateString(),
718
+ "data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
719
+ "data-range-start": n.range_start,
720
+ "data-range-end": n.range_end,
721
+ "data-range-middle": n.range_middle,
722
+ className: b(
723
+ "flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-start=true]:rounded-l-md data-[range-end=true]:bg-primary data-[range-middle=true]:bg-accent data-[range-start=true]:bg-primary data-[selected-single=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:text-accent-foreground data-[range-start=true]:text-primary-foreground data-[selected-single=true]:text-primary-foreground group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
724
+ o.day,
725
+ t
726
+ ),
727
+ ...s
728
+ }
729
+ );
730
+ }
731
+ const Bt = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, id: d, name: i }) => {
732
+ const [u, m] = V(!1), c = O(), h = a ? new Date(a) : void 0;
733
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
734
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
735
+ o || t.data.name,
736
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
737
+ ] }),
738
+ /* @__PURE__ */ e.jsxs(ie, { open: u, onOpenChange: m, children: [
739
+ /* @__PURE__ */ e.jsx(ce, { asChild: !0, children: /* @__PURE__ */ e.jsxs(re, { variant: "outline", id: d, name: i, className: "w-full justify-between font-normal", children: [
740
+ h ? h.toLocaleDateString() : l || c("renderer.defaultInputs.selectDate"),
741
+ /* @__PURE__ */ e.jsx(Ae, { className: "size-4" })
742
+ ] }) }),
743
+ /* @__PURE__ */ e.jsx(de, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ e.jsx(
744
+ at,
745
+ {
746
+ mode: "single",
747
+ selected: h,
748
+ captionLayout: "dropdown",
749
+ onSelect: (p) => {
750
+ n(p ? p.toISOString() : ""), m(!1);
751
+ }
752
+ }
753
+ ) })
754
+ ] }),
755
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
756
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
757
+ ] });
758
+ }, qt = ({ node: t, value: a, setValue: n, error: s, label: o, helperText: l, id: r }) => {
759
+ const [d, i] = V(!1), u = O(), m = Array.isArray(a) ? a : [], c = m[0] ? new Date(m[0]) : void 0, h = m[1] ? new Date(m[1]) : void 0, p = (f) => {
760
+ n([f?.from ? f.from.toISOString() : void 0, f?.to ? f.to.toISOString() : void 0]);
761
+ }, j = () => c && h ? `${c.toLocaleDateString()} - ${h.toLocaleDateString()}` : c ? c.toLocaleDateString() : u("renderer.defaultInputs.selectDateRange");
762
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
763
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: r, children: [
764
+ o || t.data.name,
765
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
766
+ ] }),
767
+ /* @__PURE__ */ e.jsxs(ie, { open: d, onOpenChange: i, children: [
768
+ /* @__PURE__ */ e.jsx(ce, { asChild: !0, children: /* @__PURE__ */ e.jsxs(re, { id: r, variant: "outline", className: "w-full justify-between font-normal", children: [
769
+ j(),
770
+ /* @__PURE__ */ e.jsx(Ae, { className: "size-4" })
771
+ ] }) }),
772
+ /* @__PURE__ */ e.jsx(de, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ e.jsx(
773
+ at,
774
+ {
775
+ mode: "range",
776
+ selected: { from: c, to: h },
777
+ captionLayout: "dropdown",
778
+ onSelect: p,
779
+ numberOfMonths: 2
780
+ }
781
+ ) })
782
+ ] }),
783
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
784
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l })
785
+ ] });
786
+ }, nt = (t) => new Promise((a, n) => {
787
+ const s = new FileReader();
788
+ s.onload = () => {
789
+ const o = s.result;
790
+ a({
791
+ data: o,
792
+ lastModified: t.lastModified,
793
+ name: t.name,
794
+ size: t.size,
795
+ type: t.type
796
+ });
797
+ }, s.onerror = () => {
798
+ n(new Error(`Failed to read file: ${t.name}`));
799
+ }, s.readAsDataURL(t);
800
+ }), ps = (t) => {
801
+ const a = t.data.split(",")[1], n = atob(a), s = new ArrayBuffer(n.length), o = new Uint8Array(s);
802
+ for (let r = 0; r < n.length; r++)
803
+ o[r] = n.charCodeAt(r);
804
+ const l = new Blob([s], { type: t.type });
805
+ return new File([l], t.name, {
806
+ lastModified: t.lastModified,
807
+ type: t.type
808
+ });
809
+ }, Lt = (t) => Promise.all(t.map((a) => nt(a))), Gt = ({ node: t, setValue: a, error: n, label: s, placeholder: o, helperText: l, name: r, id: d }) => {
810
+ const i = async (u) => {
811
+ const { files: m } = u.target;
812
+ if (!m || m.length === 0) {
813
+ a(null);
814
+ return;
815
+ }
816
+ if (t.data.multiple) {
817
+ const h = await Lt(Array.from(m));
818
+ a(h);
819
+ return;
820
+ }
821
+ const c = await nt(m[0]);
822
+ a(c);
823
+ };
824
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
825
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
826
+ s || t.data.name,
827
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
828
+ ] }),
829
+ /* @__PURE__ */ e.jsx(L, { type: "file", name: r, id: d, onChange: i, multiple: t.data.multiple, placeholder: o }),
830
+ n && /* @__PURE__ */ e.jsx(A, { children: n }),
831
+ l && !n && /* @__PURE__ */ e.jsx(k, { children: l })
832
+ ] });
833
+ }, Ut = ({ value: t, name: a, id: n }) => /* @__PURE__ */ e.jsx(L, { type: "hidden", id: n, name: a, value: t ?? "" });
834
+ function ke({ delayDuration: t = 0, ...a }) {
835
+ return /* @__PURE__ */ e.jsx(ae.Provider, { "data-slot": "tooltip-provider", delayDuration: t, ...a });
836
+ }
837
+ function rt({ ...t }) {
838
+ return /* @__PURE__ */ e.jsx(ke, { children: /* @__PURE__ */ e.jsx(ae.Root, { "data-slot": "tooltip", ...t }) });
839
+ }
840
+ function ot({ ...t }) {
841
+ return /* @__PURE__ */ e.jsx(ae.Trigger, { "data-slot": "tooltip-trigger", ...t });
842
+ }
843
+ function lt({ className: t, sideOffset: a = 0, children: n, ...s }) {
844
+ return /* @__PURE__ */ e.jsx(ae.Portal, { children: /* @__PURE__ */ e.jsxs(
845
+ ae.Content,
846
+ {
847
+ "data-slot": "tooltip-content",
848
+ sideOffset: a,
849
+ className: b(
850
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
851
+ t
852
+ ),
853
+ ...s,
854
+ children: [
855
+ n,
856
+ /* @__PURE__ */ e.jsx(ae.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
857
+ ]
858
+ }
859
+ ) });
860
+ }
861
+ const ve = (t, a) => a ? a.split(".").reduce((s, o) => {
862
+ if (s == null)
863
+ return;
864
+ const l = o.match(/^(\w+)\[(\d+)]$/);
865
+ if (l) {
866
+ const [, r, d] = l, i = s[r];
867
+ return Array.isArray(i) ? i[Number.parseInt(d, 10)] : i;
868
+ }
869
+ return s[o];
870
+ }, t) : t, Fe = (t) => {
871
+ const a = t.matchAll(/{{([\w-]+)}}/g);
872
+ return Array.from(a, (n) => n[1]);
873
+ }, Ne = (t, a) => Fe(t).every((s) => {
874
+ const o = a[s];
875
+ return o != null && o !== "";
876
+ }), ye = (t, a, n = !1) => t.replace(/{{([\w-]+)}}/g, (s, o) => {
877
+ const l = String(a[o] || "");
878
+ return n ? encodeURIComponent(l) : l;
879
+ }), Ht = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, id: d, name: i }) => {
880
+ const [u, m] = V(!1), [c, h] = V(null), [p, j] = V([]), [f, w] = V(""), [T, y] = V(!1), { formValues: N } = ue(), x = O(), { httpConfig: g } = t.data, C = J(!1), _ = J(""), G = J(g), W = J(N), ne = J(n), Z = J(null), U = H(() => g?.url ? Fe(g.url) : [], [g?.url]), ee = U.length > 0, te = H(() => U.map((F) => `${F}:${String(N[F] ?? "")}`).join("|"), [U, N]), S = H(() => g?.url ? ee ? Ne(g.url, N) : !0 : !1, [g?.url, ee, N]), M = Y(
881
+ async (F) => {
882
+ const v = G.current, D = W.current, q = ne.current;
883
+ if (!v?.url) {
884
+ h(x("renderer.defaultHttpInput.noUrlConfigured"));
885
+ return;
886
+ }
887
+ if (!(v.url && !Ne(v.url, D))) {
888
+ m(!0), h(null);
889
+ try {
890
+ const E = ye(v.url, D, !0), z = v.searchParam && F ? `${E}${E.includes("?") ? "&" : "?"}${v.searchParam}=${encodeURIComponent(F)}` : E, P = {};
891
+ v.headers?.forEach((se) => {
892
+ P[se.key] = ye(se.value, D);
893
+ });
894
+ const B = v.body && ["POST", "PUT", "PATCH"].includes(v.method || "") ? ye(v.body, D) : void 0, $ = await fetch(z, {
895
+ body: B || void 0,
896
+ headers: {
897
+ "Content-Type": "application/json",
898
+ ...P
899
+ },
900
+ method: v.method || "GET"
901
+ });
902
+ if (!$.ok) {
903
+ h(`HTTP ${$.status}: ${$.statusText}`), m(!1);
904
+ return;
905
+ }
906
+ const oe = await $.json(), X = v.responsePath ? ve(oe, v.responsePath) : oe;
907
+ if (v.responseMapping && Array.isArray(X)) {
908
+ const { valueField: se = "value", labelField: me = "label" } = v.responseMapping, fe = X.map((Te) => ({
909
+ label: String(ve(Te, me) || ""),
910
+ value: String(ve(Te, se) || "")
911
+ }));
912
+ j(fe);
913
+ } else
914
+ q(typeof X == "string" ? X : JSON.stringify(X));
915
+ } catch (E) {
916
+ const z = E instanceof Error ? E.message : x("renderer.defaultHttpInput.fetchFailed");
917
+ h(z), console.error("HTTP Input fetch error:", E);
918
+ } finally {
919
+ m(!1);
920
+ }
921
+ }
922
+ },
923
+ [x]
924
+ );
925
+ if (K(() => {
926
+ G.current = g, W.current = N, ne.current = n, Z.current = M;
927
+ }, [g, N, n, M]), K(() => {
928
+ if (C.current)
929
+ return;
930
+ C.current = !0;
931
+ const F = G.current, v = W.current, D = Z.current, q = F?.url && Ne(F.url, v);
932
+ if (F?.fetchOnMount && q && D && (D(), F.url)) {
933
+ const E = Fe(F.url);
934
+ _.current = E.map((z) => `${z}:${String(v[z] ?? "")}`).join("|");
935
+ }
936
+ }, []), K(() => {
937
+ if (!C.current || !ee || _.current === te || !S)
938
+ return;
939
+ const F = setTimeout(() => {
940
+ M(), _.current = te;
941
+ }, 500);
942
+ return () => clearTimeout(F);
943
+ }, [te, ee, S, M]), K(() => {
944
+ if (!(g?.searchParam && f))
945
+ return;
946
+ const F = setTimeout(() => {
947
+ M(f);
948
+ }, 300);
949
+ return () => clearTimeout(F);
950
+ }, [f, g?.searchParam, M]), g?.responseMapping) {
951
+ const F = Array.isArray(a) ? a[0] : a, v = p.find((P) => P.value === F);
952
+ if (g.searchParam) {
953
+ const B = u && g?.showLoading ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
954
+ /* @__PURE__ */ e.jsx(xe, { className: "h-4 w-4 animate-spin" }),
955
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: v?.label || l || "Search..." })
956
+ ] }) : v?.label || l || "Search...";
957
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
958
+ /* @__PURE__ */ e.jsxs(I, { children: [
959
+ o || t.data.name,
960
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
961
+ ] }),
962
+ /* @__PURE__ */ e.jsxs(ie, { open: T, onOpenChange: y, children: [
963
+ /* @__PURE__ */ e.jsx(ce, { asChild: !0, children: /* @__PURE__ */ e.jsxs(re, { variant: "outline", role: "combobox", "aria-expanded": T, className: "w-full justify-between", children: [
964
+ B,
965
+ /* @__PURE__ */ e.jsx(We, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
966
+ ] }) }),
967
+ /* @__PURE__ */ e.jsx(de, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ e.jsxs(Se, { shouldFilter: !1, children: [
968
+ /* @__PURE__ */ e.jsx(
969
+ Ve,
970
+ {
971
+ placeholder: "Search...",
972
+ value: f,
973
+ onValueChange: ($) => {
974
+ w($), h(null);
975
+ }
976
+ }
977
+ ),
978
+ /* @__PURE__ */ e.jsxs(Ce, { children: [
979
+ u && /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e.jsx(xe, { className: "h-4 w-4 animate-spin" }) }),
980
+ !u && c && /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
981
+ /* @__PURE__ */ e.jsx("div", { children: c }),
982
+ /* @__PURE__ */ e.jsx("button", { type: "button", onClick: () => M(f), className: "mt-2 block text-primary hover:underline", children: "Retry" })
983
+ ] }),
984
+ !(u || c) && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
985
+ /* @__PURE__ */ e.jsx(Ie, { children: "No results found." }),
986
+ /* @__PURE__ */ e.jsx(De, { children: p.map(($) => /* @__PURE__ */ e.jsxs(
987
+ Re,
988
+ {
989
+ value: $.value,
990
+ onSelect: () => {
991
+ n($.value), y(!1);
992
+ },
993
+ children: [
994
+ /* @__PURE__ */ e.jsx(Je, { className: b("mr-2 h-4 w-4", a === $.value ? "opacity-100" : "opacity-0") }),
995
+ $.label
996
+ ]
997
+ },
998
+ $.value
999
+ )) })
1000
+ ] })
1001
+ ] })
1002
+ ] }) })
1003
+ ] }),
1004
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1005
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1006
+ ] });
1007
+ }
1008
+ const D = u && g?.showLoading, q = U.filter((P) => {
1009
+ const B = N[P];
1010
+ return B == null || B === "";
1011
+ }), E = p.length === 0 && !D ? q.length > 0 ? `Waiting for required fields: ${q.join(", ")}` : 'No data available. Configure "Fetch on mount" or add a search parameter.' : void 0, z = /* @__PURE__ */ e.jsxs(
1012
+ Me,
1013
+ {
1014
+ value: Array.isArray(a) ? a[0] ?? "" : a ?? "",
1015
+ onValueChange: (P) => n(P),
1016
+ disabled: D || p.length === 0,
1017
+ name: i,
1018
+ children: [
1019
+ /* @__PURE__ */ e.jsxs(Be, { id: d, name: i, className: "w-full", children: [
1020
+ D && /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4 animate-spin" }),
1021
+ /* @__PURE__ */ e.jsx(qe, { placeholder: l || x("renderer.defaultHttpInput.selectOption") })
1022
+ ] }),
1023
+ /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsx(Ge, { children: p.map((P, B) => /* @__PURE__ */ e.jsx(Ue, { value: P.value, children: P.label }, P.value + B)) }) })
1024
+ ]
1025
+ }
1026
+ );
1027
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1028
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
1029
+ o || t.data.name,
1030
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1031
+ ] }),
1032
+ E ? /* @__PURE__ */ e.jsx(ke, { children: /* @__PURE__ */ e.jsxs(rt, { children: [
1033
+ /* @__PURE__ */ e.jsx(ot, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { className: "w-full", children: z }) }),
1034
+ /* @__PURE__ */ e.jsx(lt, { children: /* @__PURE__ */ e.jsx("p", { children: E }) })
1035
+ ] }) }) : z,
1036
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1037
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1038
+ ] });
1039
+ }
1040
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1041
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
1042
+ o || t.data.name,
1043
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1044
+ ] }),
1045
+ /* @__PURE__ */ e.jsx(L, { type: "text", name: i, id: d, value: typeof a == "string" ? a : JSON.stringify(a), readOnly: !0, disabled: !0 }),
1046
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1047
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1048
+ ] });
1049
+ }, Kt = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1050
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1051
+ o || t.data.name,
1052
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1053
+ ] }),
1054
+ /* @__PURE__ */ e.jsx(
1055
+ L,
1056
+ {
1057
+ id: i,
1058
+ type: "number",
1059
+ name: d,
1060
+ value: a ?? "",
1061
+ onChange: (u) => n(u.target.value === "" ? null : Number(u.target.value)),
1062
+ placeholder: l
1063
+ }
1064
+ ),
1065
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1066
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1067
+ ] }), Wt = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1068
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1069
+ o || t.data.name,
1070
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1071
+ ] }),
1072
+ /* @__PURE__ */ e.jsx(
1073
+ L,
1074
+ {
1075
+ id: i,
1076
+ name: d,
1077
+ type: "password",
1078
+ value: a ?? "",
1079
+ onChange: (u) => n(u.target.value),
1080
+ placeholder: l,
1081
+ autoComplete: "new-password"
1082
+ }
1083
+ ),
1084
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1085
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1086
+ ] });
1087
+ function Jt({ className: t, ...a }) {
1088
+ return /* @__PURE__ */ e.jsx(we.Root, { "data-slot": "radio-group", className: b("grid gap-3", t), ...a });
1089
+ }
1090
+ function Qt({ className: t, ...a }) {
1091
+ return /* @__PURE__ */ e.jsx(
1092
+ we.Item,
1093
+ {
1094
+ "data-slot": "radio-group-item",
1095
+ className: b(
1096
+ "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
1097
+ t
1098
+ ),
1099
+ ...a,
1100
+ children: /* @__PURE__ */ e.jsx(we.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ e.jsx(gt, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" }) })
1101
+ }
1102
+ );
1103
+ }
1104
+ const Xt = ({ node: t, value: a, setValue: n, error: s, label: o, helperText: l, id: r, name: d }) => {
1105
+ const i = O(), u = a ? String(a) : "";
1106
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1107
+ /* @__PURE__ */ e.jsxs(I, { className: "mb-1", htmlFor: r, children: [
1108
+ o || t.data.name,
1109
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1110
+ ] }),
1111
+ /* @__PURE__ */ e.jsx(Jt, { value: u, onValueChange: (m) => n(m), id: r, name: d, children: t.data.options?.map((m, c) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1112
+ /* @__PURE__ */ e.jsx(Qt, { value: String(m.value), id: `${r}-${m.value}`, disabled: m.disabled }),
1113
+ /* @__PURE__ */ e.jsx(I, { htmlFor: `${r}-${m.value}`, className: "cursor-pointer font-normal text-sm", children: i(m.label) ? i(m.label) : m.value })
1114
+ ] }, m.value + c)) }),
1115
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1116
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l })
1117
+ ] });
1118
+ }, Yt = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => {
1119
+ const u = O(), m = a ? String(a) : "";
1120
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1121
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1122
+ o || t.data.name,
1123
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1124
+ ] }),
1125
+ /* @__PURE__ */ e.jsxs(Me, { name: d, value: m, onValueChange: (c) => n(c), children: [
1126
+ /* @__PURE__ */ e.jsx(Be, { id: i, name: d, className: "w-full", children: /* @__PURE__ */ e.jsx(qe, { placeholder: l || u("renderer.defaultSelectInput.selectOption") }) }),
1127
+ /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsx(Ge, { children: t.data.options?.map((c, h) => /* @__PURE__ */ e.jsx(Ue, { value: String(c.value), disabled: c.disabled, children: u(c.label) ? u(c.label) : c.value }, `${c.value}-${h}`)) }) })
1128
+ ] }),
1129
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1130
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1131
+ ] });
1132
+ }, Zt = ({ node: t, value: a, setValue: n, error: s, label: o, helperText: l, name: r, id: d }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1133
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: d, children: [
1134
+ o || t.data.name,
1135
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1136
+ ] }),
1137
+ /* @__PURE__ */ e.jsx(ct, { id: d, name: r, checked: a, onCheckedChange: n }),
1138
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l }),
1139
+ s && /* @__PURE__ */ e.jsx(A, { children: s })
1140
+ ] }), es = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1141
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1142
+ o || t.data.name,
1143
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1144
+ ] }),
1145
+ /* @__PURE__ */ e.jsx(
1146
+ dt,
1147
+ {
1148
+ id: i,
1149
+ name: d,
1150
+ value: a ?? "",
1151
+ onChange: (u) => n(u.target.value),
1152
+ placeholder: l,
1153
+ className: "w-full rounded-md border px-3 py-2",
1154
+ rows: 4
1155
+ }
1156
+ ),
1157
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1158
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1159
+ ] }), ts = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1160
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1161
+ o || t.data.name,
1162
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1163
+ ] }),
1164
+ /* @__PURE__ */ e.jsx(L, { type: "text", id: i, name: d, value: a ?? "", onChange: (u) => n(u.target.value), placeholder: l }),
1165
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1166
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1167
+ ] }), ss = ({ node: t, value: a, setValue: n, error: s, label: o, placeholder: l, helperText: r, name: d, id: i }) => /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1168
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: i, children: [
1169
+ o || t.data.name,
1170
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1171
+ ] }),
1172
+ /* @__PURE__ */ e.jsx(
1173
+ L,
1174
+ {
1175
+ type: "time",
1176
+ id: i,
1177
+ name: d,
1178
+ value: a ?? "",
1179
+ onChange: (u) => n(u.target.value),
1180
+ placeholder: l,
1181
+ className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
1182
+ }
1183
+ ),
1184
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1185
+ r && !s && /* @__PURE__ */ e.jsx(k, { children: r })
1186
+ ] }), as = ({ node: t, value: a, setValue: n, error: s, label: o, helperText: l, id: r, name: d }) => {
1187
+ const i = O(), u = Array.isArray(a) ? a : [], m = u[0] || "", c = u[1] || "", h = (j) => {
1188
+ n([j, c]);
1189
+ }, p = (j) => {
1190
+ n([m, j]);
1191
+ };
1192
+ return /* @__PURE__ */ e.jsxs(R, { className: "mb-4", children: [
1193
+ /* @__PURE__ */ e.jsxs(I, { htmlFor: `${r}-start`, children: [
1194
+ o || t.data.name,
1195
+ t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
1196
+ ] }),
1197
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
1198
+ /* @__PURE__ */ e.jsx(
1199
+ L,
1200
+ {
1201
+ id: `${r}-start`,
1202
+ name: `${d}-start`,
1203
+ "aria-label": `${o || t.data.name} - ${i("renderer.defaultInputs.startTime")}`,
1204
+ "aria-invalid": !!s,
1205
+ "aria-describedby": s ? `${t.id}-error` : void 0,
1206
+ type: "time",
1207
+ value: m,
1208
+ onChange: (j) => h(j.target.value),
1209
+ placeholder: i("renderer.defaultInputs.startTime"),
1210
+ className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1211
+ }
1212
+ ),
1213
+ /* @__PURE__ */ e.jsx(
1214
+ L,
1215
+ {
1216
+ id: `${r}-end`,
1217
+ name: `${d}-end`,
1218
+ "aria-label": `${o || t.data.name} - ${i("renderer.defaultInputs.endTime")}`,
1219
+ "aria-invalid": !!s,
1220
+ "aria-describedby": s ? `${t.id}-error` : void 0,
1221
+ type: "time",
1222
+ value: c,
1223
+ onChange: (j) => p(j.target.value),
1224
+ placeholder: i("renderer.defaultInputs.endTime"),
1225
+ className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1226
+ }
1227
+ )
1228
+ ] }),
1229
+ s && /* @__PURE__ */ e.jsx(A, { children: s }),
1230
+ l && !s && /* @__PURE__ */ e.jsx(k, { children: l })
1231
+ ] });
1232
+ }, ns = {
1233
+ address: Ot,
1234
+ autocomplete: zt,
1235
+ checkbox: Vt,
1236
+ date: Bt,
1237
+ daterange: qt,
1238
+ file: Gt,
1239
+ hidden: Ut,
1240
+ http: Ht,
1241
+ number: Kt,
1242
+ password: Wt,
1243
+ radio: Xt,
1244
+ select: Yt,
1245
+ switch: Zt,
1246
+ text: ts,
1247
+ textarea: es,
1248
+ time: ss,
1249
+ timerange: as
1250
+ }, rs = ({ label: t = "Submit", ...a }) => /* @__PURE__ */ e.jsx(
1251
+ "button",
1252
+ {
1253
+ type: "submit",
1254
+ className: "mt-4 rounded-md bg-blue-500 px-4 py-2 font-medium text-white transition-colors hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
1255
+ ...a,
1256
+ children: t
1257
+ }
1258
+ ), os = ({ node: t }) => {
1259
+ const n = O()(t.data?.label);
1260
+ return n ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-3", children: [
1261
+ /* @__PURE__ */ e.jsx(pe, { className: "my-8 flex-1" }),
1262
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: n }),
1263
+ /* @__PURE__ */ e.jsx(pe, { className: "my-8 flex-1" })
1264
+ ] }) : /* @__PURE__ */ e.jsx(pe, { className: "my-8" });
1265
+ }, ls = ({ node: t }) => {
1266
+ const { edges: a } = ue(), n = O(), s = Ze(t.id, a);
1267
+ return /* @__PURE__ */ e.jsx("h2", { className: b("mb-5 font-bold text-2xl", !s && "mt-10"), children: n(t.data?.label) });
1268
+ }, is = {
1269
+ divider: os,
1270
+ title: ls
1271
+ }, cs = ({ children: t, missingFields: a = [] }) => {
1272
+ const n = a.length > 0, s = O();
1273
+ return n ? /* @__PURE__ */ e.jsx(ke, { children: /* @__PURE__ */ e.jsxs(rt, { children: [
1274
+ /* @__PURE__ */ e.jsx(ot, { asChild: !0, children: t }),
1275
+ /* @__PURE__ */ e.jsx(lt, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1276
+ /* @__PURE__ */ e.jsxs("p", { className: "font-semibold", children: [
1277
+ s("renderer.defaultSubmitButton.requiredFieldsMissing"),
1278
+ ":"
1279
+ ] }),
1280
+ /* @__PURE__ */ e.jsx("ul", { className: "list-inside list-disc", children: a.map((o, l) => /* @__PURE__ */ e.jsx("li", { children: o }, l)) })
1281
+ ] }) })
1282
+ ] }) }) : t;
1283
+ }, gs = ({
1284
+ components: t,
1285
+ flows: a,
1286
+ googleApiKey: n,
1287
+ initialValues: s = {},
1288
+ language: o,
1289
+ onChange: l,
1290
+ onSubmit: r,
1291
+ theme: d,
1292
+ validate: i,
1293
+ validationMode: u
1294
+ }) => {
1295
+ const m = jt(), c = {
1296
+ components: {
1297
+ form: t?.form ?? m?.components?.form,
1298
+ group: t?.group ?? m?.components?.group,
1299
+ inputs: { ...m?.components?.inputs, ...t?.inputs },
1300
+ submitButton: t?.submitButton ?? m?.components?.submitButton,
1301
+ submitButtonWrapper: t?.submitButtonWrapper ?? m?.components?.submitButtonWrapper,
1302
+ ui: { ...m?.components?.ui, ...t?.ui }
1303
+ },
1304
+ googleApiKey: n ?? m?.googleApiKey,
1305
+ language: o ?? m?.language ?? "en",
1306
+ theme: d ?? m?.theme ?? "dark",
1307
+ validationMode: u ?? m?.validationMode ?? "onSubmit"
1308
+ }, {
1309
+ canSubmit: h,
1310
+ mergedFlow: p,
1311
+ formErrors: j,
1312
+ formValues: f,
1313
+ inputNodes: w,
1314
+ missingRequiredFields: T,
1315
+ visibleNodes: y,
1316
+ visibleRootNodes: N,
1317
+ setFieldValue: x,
1318
+ validateForm: g,
1319
+ t: C
1320
+ } = Tt(a, s, c.language), _ = c.components.form || Et, G = c.components.submitButton || rs, W = c.components.submitButtonWrapper || cs, ne = J(l), Z = J(i), U = H(() => wt(f, w), [f, w]), ee = Y(
1321
+ (S) => {
1322
+ S.preventDefault();
1323
+ const { isValid: M, errors: F } = g(Z.current);
1324
+ if (M && r) {
1325
+ r(U);
1326
+ return;
1327
+ }
1328
+ const v = Object.keys(F)[0];
1329
+ console.log(v), v && document.getElementById(v)?.focus();
1330
+ },
1331
+ [g, r, U]
1332
+ ), te = Y(
1333
+ (S) => {
1334
+ const { type: M } = S;
1335
+ switch (M) {
1336
+ case le.input: {
1337
+ if (!Q(S))
1338
+ return null;
1339
+ const F = S.data, v = F.type || "text", D = c.components.inputs?.[v], q = ns[v], E = D || q, z = S.id, P = f[z], B = j[z], $ = (fe) => x(z, fe), oe = ge(F.label, c.language), X = ge(F.placeholder, c.language), se = ge(F.helperText, c.language), me = Ye(S);
1340
+ return /* @__PURE__ */ e.jsx(
1341
+ E,
1342
+ {
1343
+ id: S.id,
1344
+ node: S,
1345
+ value: P,
1346
+ error: B,
1347
+ label: oe,
1348
+ placeholder: X,
1349
+ helperText: se,
1350
+ name: me,
1351
+ setValue: $
1352
+ },
1353
+ S.id
1354
+ );
1355
+ }
1356
+ case le.group: {
1357
+ if (!mt(S))
1358
+ return null;
1359
+ const F = c.components.group || _t, v = y.filter((D) => D.parentId === S.id);
1360
+ return /* @__PURE__ */ e.jsx(F, { node: S, children: v.map((D) => te(D)) }, S.id);
1361
+ }
1362
+ case le.ui: {
1363
+ if (!ut(S))
1364
+ return null;
1365
+ const v = S.data.type || "title", D = c.components.ui?.[v], q = is[v], E = D || q;
1366
+ return /* @__PURE__ */ e.jsx(E, { node: S }, S.id);
1367
+ }
1368
+ case le.flow:
1369
+ return null;
1370
+ default:
1371
+ return console.warn("Unknown node type:", M), null;
1372
+ }
1373
+ },
1374
+ [c.components, c.language, y, f, j, x]
1375
+ );
1376
+ return K(() => {
1377
+ ne.current = l;
1378
+ }, [l]), K(() => {
1379
+ Z.current = i;
1380
+ }, [i]), K(() => {
1381
+ ne.current?.(U);
1382
+ }, [U]), K(() => {
1383
+ c.validationMode === "onChange" && g(Z.current);
1384
+ }, [c.validationMode, g]), /* @__PURE__ */ e.jsx(ft, { theme: c.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ e.jsx(
1385
+ kt,
1386
+ {
1387
+ value: {
1388
+ flows: p,
1389
+ formErrors: j,
1390
+ formValues: f,
1391
+ googleApiKey: c.googleApiKey,
1392
+ language: c.language,
1393
+ setFieldValue: x
1394
+ },
1395
+ children: /* @__PURE__ */ e.jsxs(_, { onSubmit: ee, children: [
1396
+ N.map((S) => te(S)),
1397
+ h && /* @__PURE__ */ e.jsx(W, { missingFields: T, children: /* @__PURE__ */ e.jsx(G, { label: C("renderer.defaultSubmitButton.submit") }) })
1398
+ ] })
1399
+ }
1400
+ ) });
1401
+ };
1402
+ export {
1403
+ nt as A,
1404
+ ps as B,
1405
+ Lt as C,
1406
+ _t as D,
1407
+ Ze as E,
1408
+ Ct as F,
1409
+ Dt as G,
1410
+ tt as H,
1411
+ be as I,
1412
+ yt as J,
1413
+ wt as K,
1414
+ hs as T,
1415
+ Tt as a,
1416
+ gs as b,
1417
+ Ot as c,
1418
+ zt as d,
1419
+ Vt as e,
1420
+ Bt as f,
1421
+ qt as g,
1422
+ Gt as h,
1423
+ Ut as i,
1424
+ Ht as j,
1425
+ Kt as k,
1426
+ Wt as l,
1427
+ Xt as m,
1428
+ Yt as n,
1429
+ Zt as o,
1430
+ es as p,
1431
+ ts as q,
1432
+ ss as r,
1433
+ as as s,
1434
+ ns as t,
1435
+ jt as u,
1436
+ os as v,
1437
+ ls as w,
1438
+ is as x,
1439
+ je as y,
1440
+ vt as z
1441
+ };