treege 3.0.0-beta.9 → 3.0.0-beta.90

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