treege 2.1.0 → 3.0.0-beta.2

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 (226) hide show
  1. package/README.md +378 -64
  2. package/dist/ThemeContext-BIvs8Kw-.js +758 -0
  3. package/dist/TreegeEditor-BSPfQQk3.js +2151 -0
  4. package/dist/TreegeRenderer-D3EvsEfJ.js +1413 -0
  5. package/dist/_name_.css +1 -0
  6. package/dist/editor/components/data-display/logo.d.ts +5 -0
  7. package/dist/editor/components/input/ComboboxWithCreate.d.ts +21 -0
  8. package/dist/editor/constants/defaultNode.d.ts +11 -0
  9. package/dist/editor/constants/edgeTypes.d.ts +3 -0
  10. package/dist/editor/constants/nodeTypes.d.ts +6 -0
  11. package/dist/editor/context/TreegeEditorContext.d.ts +12 -0
  12. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +3 -0
  13. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +6 -0
  14. package/dist/editor/features/TreegeEditor/forms/FlowNodeForm.d.ts +2 -0
  15. package/dist/editor/features/TreegeEditor/forms/GroupNodeForm.d.ts +2 -0
  16. package/dist/editor/features/TreegeEditor/forms/HttpConfigForm.d.ts +7 -0
  17. package/dist/editor/features/TreegeEditor/forms/InputNodeForm.d.ts +2 -0
  18. package/dist/editor/features/TreegeEditor/forms/UINodeForm.d.ts +2 -0
  19. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +6 -0
  20. package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +7 -0
  21. package/dist/editor/features/TreegeEditor/inputs/SelectLanguage.d.ts +7 -0
  22. package/dist/editor/features/TreegeEditor/inputs/SelectNodeGroup.d.ts +2 -0
  23. package/dist/editor/features/TreegeEditor/inputs/SelectNodeType.d.ts +2 -0
  24. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +6 -0
  25. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +6 -0
  26. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +6 -0
  27. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +6 -0
  28. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +6 -0
  29. package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +7 -0
  30. package/dist/editor/features/TreegeEditor/sheets/NodeActionsSheet.d.ts +2 -0
  31. package/dist/editor/hooks/useAvailableParentFields.d.ts +7 -0
  32. package/dist/editor/hooks/useEdgesSelection.d.ts +11 -0
  33. package/dist/editor/hooks/useFlowActions.d.ts +12 -0
  34. package/dist/editor/hooks/useFlowConnections.d.ts +15 -0
  35. package/dist/editor/hooks/useNodesSelection.d.ts +54 -0
  36. package/dist/editor/hooks/useTranslate.d.ts +19 -0
  37. package/dist/editor/index.d.ts +4 -0
  38. package/dist/editor/types/editor.d.ts +37 -0
  39. package/dist/editor.d.ts +2 -0
  40. package/dist/editor.js +7 -0
  41. package/dist/favicon.svg +12 -0
  42. package/dist/main.d.ts +7 -4
  43. package/dist/main.js +50 -7672
  44. package/dist/renderer/context/TreegeConfigContext.d.ts +39 -0
  45. package/dist/renderer/context/TreegeRendererContext.d.ts +25 -0
  46. package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +13 -0
  47. package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -0
  48. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -0
  49. package/dist/renderer/features/TreegeRenderer/native/components/DefaultHttpInput.d.ts +15 -0
  50. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +15 -0
  51. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +7 -0
  52. package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +7 -0
  53. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +50 -0
  54. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +3 -0
  55. package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +6 -0
  56. package/dist/renderer/features/TreegeRenderer/web/components/DefaultGroup.d.ts +6 -0
  57. package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputs.d.ts +20 -0
  58. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +9 -0
  59. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButtonWrapper.d.ts +10 -0
  60. package/dist/renderer/features/TreegeRenderer/web/components/DefaultUI.d.ts +7 -0
  61. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +3 -0
  62. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
  63. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +3 -0
  64. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +3 -0
  65. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +3 -0
  66. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +3 -0
  67. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +3 -0
  68. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +3 -0
  69. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +3 -0
  70. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +3 -0
  71. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +3 -0
  72. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +3 -0
  73. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +3 -0
  74. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +3 -0
  75. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +3 -0
  76. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +3 -0
  77. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
  78. package/dist/renderer/hooks/useTranslate.d.ts +24 -0
  79. package/dist/renderer/index.d.ts +17 -0
  80. package/dist/renderer/types/renderer.d.ts +187 -0
  81. package/dist/renderer/utils/conditions.d.ts +14 -0
  82. package/dist/renderer/utils/file.d.ts +22 -0
  83. package/dist/renderer/utils/flow.d.ts +91 -0
  84. package/dist/renderer/utils/form.d.ts +26 -0
  85. package/dist/renderer/utils/node.d.ts +16 -0
  86. package/dist/renderer.d.ts +2 -0
  87. package/dist/renderer.js +45 -0
  88. package/dist/shared/components/ui/badge.d.ts +9 -0
  89. package/dist/shared/components/ui/button.d.ts +10 -0
  90. package/dist/shared/components/ui/calendar.d.ts +8 -0
  91. package/dist/shared/components/ui/checkbox.d.ts +4 -0
  92. package/dist/shared/components/ui/collapsible.d.ts +5 -0
  93. package/dist/shared/components/ui/command.d.ts +18 -0
  94. package/dist/shared/components/ui/dialog.d.ts +15 -0
  95. package/dist/shared/components/ui/dropdown-menu.d.ts +25 -0
  96. package/dist/shared/components/ui/form.d.ts +5 -0
  97. package/dist/shared/components/ui/input.d.ts +3 -0
  98. package/dist/shared/components/ui/label.d.ts +4 -0
  99. package/dist/shared/components/ui/popover.d.ts +7 -0
  100. package/dist/shared/components/ui/radio-group.d.ts +5 -0
  101. package/dist/shared/components/ui/scroll-area.d.ts +5 -0
  102. package/dist/shared/components/ui/select.d.ts +15 -0
  103. package/dist/shared/components/ui/separator.d.ts +4 -0
  104. package/dist/shared/components/ui/sheet.d.ts +13 -0
  105. package/dist/shared/components/ui/sonner.d.ts +3 -0
  106. package/dist/shared/components/ui/switch.d.ts +4 -0
  107. package/dist/shared/components/ui/textarea.d.ts +3 -0
  108. package/dist/shared/components/ui/tooltip.d.ts +7 -0
  109. package/dist/shared/constants/inputType.d.ts +19 -0
  110. package/dist/shared/constants/languages.d.ts +10 -0
  111. package/dist/shared/constants/node.d.ts +6 -0
  112. package/dist/shared/constants/operator.d.ts +4 -0
  113. package/dist/shared/constants/pattern.d.ts +7 -0
  114. package/dist/shared/constants/uiType.d.ts +4 -0
  115. package/dist/shared/context/ThemeContext.d.ts +15 -0
  116. package/dist/shared/hooks/useTranslate.d.ts +23 -0
  117. package/dist/shared/lib/utils.d.ts +2 -0
  118. package/dist/shared/locales/ar.json.d.ts +229 -0
  119. package/dist/shared/locales/de.json.d.ts +229 -0
  120. package/dist/shared/locales/en.json.d.ts +229 -0
  121. package/dist/shared/locales/es.json.d.ts +229 -0
  122. package/dist/shared/locales/fr.json.d.ts +229 -0
  123. package/dist/shared/locales/it.json.d.ts +229 -0
  124. package/dist/shared/locales/pt.json.d.ts +229 -0
  125. package/dist/shared/types/edge.d.ts +34 -0
  126. package/dist/shared/types/languages.d.ts +5 -0
  127. package/dist/shared/types/node.d.ts +171 -0
  128. package/dist/shared/types/operator.d.ts +9 -0
  129. package/dist/shared/types/translate.d.ts +9 -0
  130. package/dist/shared/utils/nodeTypeGuards.d.ts +22 -0
  131. package/dist/shared/utils/translations.d.ts +30 -0
  132. package/package.json +69 -41
  133. package/CHANGELOG.md +0 -7
  134. package/dist/components/DataDisplay/Icons/TreePlusIcon.d.ts +0 -7
  135. package/dist/components/DataDisplay/Logo/Logo.d.ts +0 -2
  136. package/dist/components/DataDisplay/Tree/Tree.d.ts +0 -14
  137. package/dist/components/DataDisplay/Tree/useTree.d.ts +0 -12
  138. package/dist/components/DataDisplay/TreeCard/TreeCard.d.ts +0 -14
  139. package/dist/components/DataDisplay/ViewerJSON/ViewerJSON.d.ts +0 -6
  140. package/dist/components/DataDisplay/ViewerJSON/useViewerJSON.d.ts +0 -4
  141. package/dist/components/DataDisplay/ViewerJSONAction/ViewerJSONAction.d.ts +0 -6
  142. package/dist/components/DataDisplay/ViewerJSONAction/useViewerJSONAction.d.ts +0 -11
  143. package/dist/components/FeedBack/MainModal/MainModal.d.ts +0 -10
  144. package/dist/components/FeedBack/TreeModal/TreeModal.d.ts +0 -13
  145. package/dist/components/Layouts/Action/Action.d.ts +0 -6
  146. package/dist/components/Layouts/Header/Header.d.ts +0 -6
  147. package/dist/components/Layouts/Main/Main.d.ts +0 -6
  148. package/dist/components/Layouts/MosaicLayout/MosaicLayout.d.ts +0 -6
  149. package/dist/components/Layouts/Sidebar/Sidebar.d.ts +0 -6
  150. package/dist/components/Theme/DarkTheme/DarkTheme.d.ts +0 -6
  151. package/dist/config/i18n.config.d.ts +0 -2
  152. package/dist/config/query.config.d.ts +0 -3
  153. package/dist/config/test.config.d.ts +0 -0
  154. package/dist/config/theme.config.d.ts +0 -3
  155. package/dist/constants/colors.d.ts +0 -10
  156. package/dist/constants/fields.d.ts +0 -152
  157. package/dist/context/Auth/AuthContext.d.ts +0 -7
  158. package/dist/context/Auth/AuthProvider.d.ts +0 -7
  159. package/dist/features/Treege/Treege.d.ts +0 -24
  160. package/dist/features/Treege/components/Feedback/EndPointWarning.d.ts +0 -8
  161. package/dist/features/Treege/components/Forms/AssignValueToChildren/AssignValueToChildren.d.ts +0 -8
  162. package/dist/features/Treege/components/Forms/AssignValueToChildren/Examples/ObjectMappingExample.d.ts +0 -2
  163. package/dist/features/Treege/components/Forms/FormTreeCardDelete/FormTreeCardDelete.d.ts +0 -5
  164. package/dist/features/Treege/components/Forms/FormTreeCardDelete/useFormTreeCardDelete.d.ts +0 -5
  165. package/dist/features/Treege/components/Forms/FormTreeCardMutation/Fields/ApiFieldsConfigAccordion.d.ts +0 -32
  166. package/dist/features/Treege/components/Forms/FormTreeCardMutation/Fields/ExtraField.d.ts +0 -15
  167. package/dist/features/Treege/components/Forms/FormTreeCardMutation/Fields/FillerFieldAccordion.d.ts +0 -14
  168. package/dist/features/Treege/components/Forms/FormTreeCardMutation/FormTreeCardMutation.d.ts +0 -6
  169. package/dist/features/Treege/components/Forms/FormTreeCardMutation/useFormTreeCardMutation.d.ts +0 -110
  170. package/dist/features/Treege/components/Inputs/AutocompleteSelectType/AutocompleteSelectType.d.ts +0 -12
  171. package/dist/features/Treege/components/Inputs/AutocompleteSelectType/index.d.ts +0 -3
  172. package/dist/features/Treege/components/Inputs/AutocompleteSelectType/useAutocompleteSelectType.d.ts +0 -305
  173. package/dist/features/Treege/components/Inputs/ButtonCreateTree/ButtonCreateTree.d.ts +0 -2
  174. package/dist/features/Treege/components/Inputs/ButtonCreateTree/useButtonCreateTree.d.ts +0 -4
  175. package/dist/features/Treege/components/Inputs/FieldSelectAutocompleteCreatable.d.ts +0 -12
  176. package/dist/features/Treege/components/TreeCardContainer/TreeCardContainer.d.ts +0 -8
  177. package/dist/features/Treege/components/TreeCardContainer/useTreeCardContainer.d.ts +0 -10
  178. package/dist/features/Treege/components/TreeGrid/TreeGrid.d.ts +0 -2
  179. package/dist/features/Treege/components/TreeGrid/useTreeGrid.d.ts +0 -9
  180. package/dist/features/Treege/components/TreeNameTextField/TreeNameTextField.d.ts +0 -2
  181. package/dist/features/Treege/components/TreeNameTextField/index.d.ts +0 -2
  182. package/dist/features/Treege/components/TreeNameTextField/useTreeNameTextField.d.ts +0 -9
  183. package/dist/features/Treege/components/TreeSelect/TreeSelect.d.ts +0 -12
  184. package/dist/features/Treege/components/TreeSelect/index.d.ts +0 -2
  185. package/dist/features/Treege/components/TreeSelect/useTreeSelect.d.ts +0 -16
  186. package/dist/features/Treege/context/TreegeProvider.d.ts +0 -90
  187. package/dist/features/Treege/reducer/treeReducer.d.ts +0 -35
  188. package/dist/hooks/useTreegeContext/index.d.ts +0 -3
  189. package/dist/hooks/useTreegeContext/useTreegeContext.d.ts +0 -2
  190. package/dist/locales/en/button-en.d.ts +0 -11
  191. package/dist/locales/en/form-en.d.ts +0 -93
  192. package/dist/locales/en/modal-en.d.ts +0 -9
  193. package/dist/locales/en/snackMessage-en.d.ts +0 -13
  194. package/dist/locales/en/translation-en.d.ts +0 -30
  195. package/dist/locales/fr/button-fr.d.ts +0 -11
  196. package/dist/locales/fr/form-fr.d.ts +0 -93
  197. package/dist/locales/fr/modal-fr.d.ts +0 -9
  198. package/dist/locales/fr/snackMessage-fr.d.ts +0 -13
  199. package/dist/locales/fr/translation-fr.d.ts +0 -30
  200. package/dist/main.umd.cjs +0 -97
  201. package/dist/services/workflows/mutation/usePatchWorkflowsMutation.d.ts +0 -12
  202. package/dist/services/workflows/mutation/usePostWorkflowMutation.d.ts +0 -11
  203. package/dist/services/workflows/query/useWorkflowQuery.d.ts +0 -10
  204. package/dist/services/workflows/query/useWorkflowsQuery.d.ts +0 -10
  205. package/dist/utils/index.d.ts +0 -3
  206. package/dist/utils/tree/appendNode/appendNode.d.ts +0 -83
  207. package/dist/utils/tree/appendNode/test/mock.d.ts +0 -16
  208. package/dist/utils/tree/findNodeByUUIDInTree/findNodeByUUIDInTree.d.ts +0 -8
  209. package/dist/utils/tree/findNodeByUUIDInTree/test/mock.d.ts +0 -12
  210. package/dist/utils/tree/findParentNodeByUUIDInTree/findParentNodeByUUIDInTree.d.ts +0 -9
  211. package/dist/utils/tree/findParentNodeByUUIDInTree/test/mock.d.ts +0 -11
  212. package/dist/utils/tree/getAllAncestorFromTree/getAllAncestorFromTree.d.ts +0 -12
  213. package/dist/utils/tree/getAllAncestorFromTree/test/mock.d.ts +0 -3
  214. package/dist/utils/tree/getNode/getNode.d.ts +0 -9
  215. package/dist/utils/tree/getNode/test/mock.d.ts +0 -12
  216. package/dist/utils/tree/getTree/getTree.d.ts +0 -9
  217. package/dist/utils/tree/getTree/test/mock.d.ts +0 -13
  218. package/dist/utils/tree/getUniqueTagsInTree/getUniqueTagsInTree.d.ts +0 -7
  219. package/dist/utils/tree/getUniqueTagsInTree/test/getUniqueTagsInTree.d.ts +0 -1
  220. package/dist/utils/tree/getUniqueTagsInTree/test/mock.d.ts +0 -10
  221. package/dist/utils/tree/index.d.ts +0 -9
  222. package/dist/utils/tree/removeNode/removeNode.d.ts +0 -14
  223. package/dist/utils/tree/removeNode/test/mock.d.ts +0 -14
  224. package/dist/utils/tree/updateNodeInTree/test/mock.d.ts +0 -14
  225. package/dist/utils/tree/updateNodeInTree/updateNodeInTree.d.ts +0 -16
  226. package/dist/utils/uuid/getUUID.d.ts +0 -5
@@ -0,0 +1,2151 @@
1
+ import { j as e, i as he, e as Ue, s as D, P as Pe, p as ke, B as w, q as Ee, F as N, f as C, I as y, o as O, t as qe, S as $, w as A, x as z, y as G, A as f, L as ee, N as pe, z as q, c as ve, E as Ke, D as te, C as We, r as Ye, h as Je, k as Xe, l as Be, m as be, H as Te, a as Qe, b as et, G as tt, T as at } from "./ThemeContext-BIvs8Kw-.js";
2
+ import { useNodes as De, useEdges as $e, getBezierPath as st, useReactFlow as me, BaseEdge as nt, EdgeLabelRenderer as ot, Handle as se, Position as ne, NodeResizer as rt, Panel as lt, addEdge as it, ReactFlowProvider as ct, ReactFlow as dt, Background as ht, BackgroundVariant as ut, MiniMap as mt, Controls as xt } from "@xyflow/react";
3
+ import { useForm as ie } from "@tanstack/react-form";
4
+ import { Waypoints as pt, X as oe, Plus as xe, Network as jt, Boxes as gt, RectangleEllipsis as Ct, Type as Ae, LucidePencilRuler as vt, EllipsisVertical as ft, Copy as bt, Download as Nt, ArrowRightFromLine as yt, Save as wt, Trash2 as Ft, Variable as He, ChevronsUpDown as de, Check as St, PlusCircle as Vt, XIcon as Pt } from "lucide-react";
5
+ import { useMemo as ae, createContext as kt, useState as _, useContext as Et, useRef as Tt, useCallback as Z } from "react";
6
+ import * as ue from "@radix-ui/react-scroll-area";
7
+ import { Slot as Dt } from "@radix-ui/react-slot";
8
+ import { cva as Mt } from "class-variance-authority";
9
+ import { toast as R, Toaster as It } from "sonner";
10
+ import * as K from "@radix-ui/react-dropdown-menu";
11
+ import * as Me from "@radix-ui/react-collapsible";
12
+ import * as J from "@radix-ui/react-dialog";
13
+ import { useTheme as Lt } from "next-themes";
14
+ const Bt = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1809_3434)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1303%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.455%2046.7988C17.0611%2047.1509%2017.7491%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34V41.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.251%20116.58%20138.64L151.39%2078.3401C151.741%2077.7316%20151.926%2077.0413%20151.926%2076.3386C151.926%2075.636%20151.74%2074.9458%20151.389%2074.3375C151.037%2073.7293%20150.531%2073.2244%20149.922%2072.8738C149.313%2072.5231%20148.623%2072.3391%20147.92%2072.3401H92.48C91.4191%2072.3401%2090.4017%2072.7615%2089.6516%2073.5117C88.9014%2074.2618%2088.48%2075.2792%2088.48%2076.3401V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.469C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.3201H3.99999C3.29819%2072.3208%202.60893%2072.5061%202.00143%2072.8575C1.39392%2073.2089%200.88955%2073.7139%200.538962%2074.3218C0.188375%2074.9298%200.00390931%2075.6193%200.00408949%2076.3211C0.00426966%2077.0229%200.189089%2077.7123%200.539989%2078.3201L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.489C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.3101C63.4773%2075.2509%2063.0547%2074.2361%2062.3049%2073.4881C61.555%2072.7401%2060.5391%2072.3201%2059.48%2072.3201V72.3201Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='black'/%3e%3cdefs%3e%3cclipPath%20id='clip0_1809_3434'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Ht = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_2_65)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1302%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.4549%2046.7988C17.061%2047.1509%2017.749%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.25%20116.58%20138.64L151.39%2078.34C151.741%2077.7315%20151.926%2077.0412%20151.926%2076.3385C151.926%2075.6359%20151.74%2074.9457%20151.389%2074.3374C151.037%2073.7292%20150.531%2073.2243%20149.922%2072.8737C149.313%2072.523%20148.623%2072.339%20147.92%2072.34H92.48C91.4191%2072.34%2090.4017%2072.7614%2089.6516%2073.5116C88.9014%2074.2617%2088.48%2075.2791%2088.48%2076.34V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.468C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.32H4C3.2982%2072.3207%202.60894%2072.5061%202.00143%2072.8574C1.39393%2073.2088%200.889558%2073.7138%200.53897%2074.3218C0.188382%2074.9297%200.00391694%2075.6192%200.00409712%2076.321C0.00427729%2077.0228%200.189097%2077.7122%200.539997%2078.32L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.488C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.31C63.4773%2075.2509%2063.0548%2074.236%2062.3049%2073.488C61.555%2072.7401%2060.5391%2072.32%2059.48%2072.32Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='white'/%3e%3cdefs%3e%3cclipPath%20id='clip0_2_65'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Ot = ({ theme: t = "dark" }) => /* @__PURE__ */ e.jsx("div", { className: "fixed left-5 top-5 z-50 select-none", children: /* @__PURE__ */ e.jsx(
15
+ "img",
16
+ {
17
+ src: t === "dark" ? Ht : Bt,
18
+ alt: "Treege",
19
+ className: "relative w-auto h-14 drop-shadow-[0_0px_35px] drop-shadow-blue-600"
20
+ }
21
+ ) }), Ie = (t) => {
22
+ const r = De(), n = $e();
23
+ return ae(() => {
24
+ if (!t)
25
+ return [];
26
+ const l = (i, s = /* @__PURE__ */ new Set()) => {
27
+ if (s.has(i))
28
+ return [];
29
+ const c = new Set(s).add(i);
30
+ return n.filter((a) => a.target === i).flatMap((a) => [a.source, ...l(a.source, c)]);
31
+ }, m = l(t);
32
+ return r.filter((i) => m.includes(i.id) && he(i)).map((i) => {
33
+ const s = i.data, c = (typeof s.label == "object" ? s.label.en : s.label) || `Node ${i.id.slice(0, 8)}`;
34
+ return {
35
+ label: s.name ? `${c} (${s.name})` : c,
36
+ name: s.name,
37
+ nodeId: i.id,
38
+ type: s.type || "text"
39
+ };
40
+ });
41
+ }, [t, r, n]);
42
+ }, ze = kt(null), $t = ({ children: t, value: r }) => {
43
+ const [n, l] = _(r?.flowId), m = ae(
44
+ () => ({
45
+ ...r,
46
+ flowId: n,
47
+ setFlowId: l
48
+ }),
49
+ [n, r]
50
+ );
51
+ return /* @__PURE__ */ e.jsx(ze.Provider, { value: m, children: t });
52
+ }, Ge = () => Et(ze) ?? {
53
+ flowId: void 0,
54
+ language: "en",
55
+ setFlowId: () => {
56
+ }
57
+ }, B = (t) => {
58
+ const n = Ge().language;
59
+ return Ue(n);
60
+ };
61
+ function _e({ className: t, children: r, ...n }) {
62
+ return /* @__PURE__ */ e.jsxs(ue.Root, { "data-slot": "scroll-area", className: D("relative", t), ...n, children: [
63
+ /* @__PURE__ */ e.jsx(
64
+ ue.Viewport,
65
+ {
66
+ "data-slot": "scroll-area-viewport",
67
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
68
+ children: r
69
+ }
70
+ ),
71
+ /* @__PURE__ */ e.jsx(At, {}),
72
+ /* @__PURE__ */ e.jsx(ue.Corner, {})
73
+ ] });
74
+ }
75
+ function At({
76
+ className: t,
77
+ orientation: r = "vertical",
78
+ ...n
79
+ }) {
80
+ return /* @__PURE__ */ e.jsx(
81
+ ue.ScrollAreaScrollbar,
82
+ {
83
+ "data-slot": "scroll-area-scrollbar",
84
+ orientation: r,
85
+ className: D(
86
+ "flex touch-none p-px transition-colors select-none",
87
+ r === "vertical" && "h-full w-2.5 border-l border-l-transparent",
88
+ r === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
89
+ t
90
+ ),
91
+ ...n,
92
+ children: /* @__PURE__ */ e.jsx(ue.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "bg-border relative flex-1 rounded-full" })
93
+ }
94
+ );
95
+ }
96
+ const zt = ({
97
+ id: t,
98
+ target: r,
99
+ sourceX: n,
100
+ sourceY: l,
101
+ targetX: m,
102
+ targetY: i,
103
+ sourcePosition: s,
104
+ targetPosition: c,
105
+ markerEnd: d,
106
+ style: a,
107
+ data: o
108
+ }) => {
109
+ const [u, h, x] = st({
110
+ sourcePosition: s,
111
+ sourceX: n,
112
+ sourceY: l,
113
+ targetPosition: c,
114
+ targetX: m,
115
+ targetY: i
116
+ }), [p, v] = _(!1), { updateEdgeData: M } = me(), F = Ie(r), S = o?.conditions && o.conditions.length > 0, g = B(), { handleSubmit: E, reset: V, Field: P } = ie({
117
+ defaultValues: {
118
+ conditions: o?.conditions || [{ field: F[0]?.nodeId ?? "", operator: "===", value: "" }],
119
+ isFallback: !!o?.isFallback,
120
+ label: o?.label || ""
121
+ },
122
+ listeners: {
123
+ onChange: ({ formApi: j }) => {
124
+ j.handleSubmit().then();
125
+ },
126
+ onChangeDebounceMs: 150
127
+ },
128
+ onSubmit: ({ value: j }) => {
129
+ M(t, j);
130
+ }
131
+ }), T = (j) => {
132
+ j.stopPropagation();
133
+ }, X = () => {
134
+ V({ conditions: [], isFallback: !1, label: "" }), M(t, { conditions: void 0, isFallback: void 0, label: void 0 });
135
+ }, b = () => {
136
+ if (o?.isFallback)
137
+ return o.label || g("editor.conditionalEdge.fallback");
138
+ if (!S)
139
+ return null;
140
+ if (o.label)
141
+ return o.label;
142
+ const j = o.conditions;
143
+ if (j.length === 1)
144
+ return `${F.find((L) => L.nodeId === j[0].field)?.label || j[0].field} ${j[0].operator} ${j[0].value}`;
145
+ const I = j.filter((k) => k.logicalOperator === ee.AND).length, fe = j.filter((k) => k.logicalOperator === ee.OR).length;
146
+ return I > 0 && fe === 0 ? `${j.length} ${g("editor.conditionalEdge.conditionsAnd")}` : fe > 0 && I === 0 ? `${j.length} ${g("editor.conditionalEdge.conditionsOr")}` : `${j.length} ${g("editor.conditionalEdge.conditionsMixed")}`;
147
+ }, Q = () => o?.isFallback ? "var(--color-chart-4)" : S ? "var(--color-chart-2)" : "var(--color-chart-3)";
148
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
149
+ /* @__PURE__ */ e.jsx(
150
+ nt,
151
+ {
152
+ path: u,
153
+ markerEnd: d,
154
+ style: {
155
+ ...a,
156
+ stroke: Q(),
157
+ strokeDasharray: o?.isFallback ? "5,5" : void 0,
158
+ strokeWidth: S || o?.isFallback ? 2 : a?.strokeWidth
159
+ }
160
+ }
161
+ ),
162
+ /* @__PURE__ */ e.jsx(ot, { children: /* @__PURE__ */ e.jsx(
163
+ "div",
164
+ {
165
+ className: "nodrag nopan absolute",
166
+ style: {
167
+ pointerEvents: "all",
168
+ transform: `translate(-50%, -50%) translate(${h}px,${x}px)`
169
+ },
170
+ children: /* @__PURE__ */ e.jsxs(Pe, { open: p, onOpenChange: v, children: [
171
+ /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
172
+ w,
173
+ {
174
+ variant: S || o?.isFallback ? "default" : "secondary",
175
+ className: "h-8 px-2 text-xs",
176
+ onClick: T,
177
+ children: [
178
+ /* @__PURE__ */ e.jsx(pt, { className: "mr-1 h-3 w-3" }),
179
+ S || o?.isFallback ? b() : g("editor.conditionalEdge.condition")
180
+ ]
181
+ }
182
+ ) }),
183
+ /* @__PURE__ */ e.jsx(Ee, { className: "w-96 p-1", align: "center", onClick: (j) => j.stopPropagation(), children: /* @__PURE__ */ e.jsx(_e, { className: "flex max-h-150 flex-col p-3", children: /* @__PURE__ */ e.jsx(
184
+ "form",
185
+ {
186
+ onSubmit: (j) => {
187
+ j.preventDefault(), j.stopPropagation();
188
+ },
189
+ children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-5", children: [
190
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
191
+ /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: g("editor.conditionalEdge.displayConditions") }),
192
+ /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: g("editor.conditionalEdge.displayConditionsDesc") })
193
+ ] }),
194
+ /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4", children: [
195
+ /* @__PURE__ */ e.jsx(P, { name: "label", children: (j) => /* @__PURE__ */ e.jsxs(N, { children: [
196
+ /* @__PURE__ */ e.jsx(C, { htmlFor: j.name, children: g("editor.conditionalEdge.labelOptional") }),
197
+ /* @__PURE__ */ e.jsx(
198
+ y,
199
+ {
200
+ id: j.name,
201
+ placeholder: g("editor.conditionalEdge.labelPlaceholder"),
202
+ value: j.state.value,
203
+ onChange: (I) => j.handleChange(I.target.value)
204
+ }
205
+ ),
206
+ /* @__PURE__ */ e.jsx(O, { children: g("editor.conditionalEdge.labelDesc") })
207
+ ] }) }),
208
+ /* @__PURE__ */ e.jsx(P, { name: "isFallback", children: (j) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3", children: [
209
+ /* @__PURE__ */ e.jsx(
210
+ qe,
211
+ {
212
+ id: j.name,
213
+ checked: j.state.value,
214
+ onCheckedChange: (I) => j.handleChange(I)
215
+ }
216
+ ),
217
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
218
+ /* @__PURE__ */ e.jsx(C, { htmlFor: j.name, className: "cursor-pointer font-medium", children: g("editor.conditionalEdge.fallbackPath") }),
219
+ /* @__PURE__ */ e.jsx(O, { className: "text-xs", children: g("editor.conditionalEdge.fallbackPathDesc") })
220
+ ] })
221
+ ] }) }) }),
222
+ /* @__PURE__ */ e.jsx(P, { name: "conditions", mode: "array", children: (j) => {
223
+ const I = j.form.getFieldValue("isFallback");
224
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
225
+ /* @__PURE__ */ e.jsx(C, { className: I ? "text-muted-foreground" : "", children: g("editor.conditionalEdge.conditions") }),
226
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
227
+ j.state.value?.map((fe, k) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
228
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2 rounded-lg border bg-muted/30 p-3", children: [
229
+ /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].field`, children: (L) => /* @__PURE__ */ e.jsxs(N, { children: [
230
+ /* @__PURE__ */ e.jsx(C, { htmlFor: `field-${k}`, children: g("editor.conditionalEdge.field") }),
231
+ /* @__PURE__ */ e.jsxs(
232
+ $,
233
+ {
234
+ disabled: I,
235
+ value: L.state.value || "",
236
+ onValueChange: (H) => L.handleChange(H),
237
+ children: [
238
+ /* @__PURE__ */ e.jsx(A, { id: `field-${k}`, className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: g("editor.conditionalEdge.selectField") }) }),
239
+ /* @__PURE__ */ e.jsx(G, { children: F.length === 0 ? /* @__PURE__ */ e.jsx(f, { value: "none", disabled: !0, children: g("editor.conditionalEdge.noFieldsAvailable") }) : F.map((H) => /* @__PURE__ */ e.jsxs(f, { value: H.nodeId, children: [
240
+ H.label,
241
+ " (",
242
+ H.type,
243
+ ")"
244
+ ] }, H.nodeId)) })
245
+ ]
246
+ }
247
+ )
248
+ ] }) }),
249
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
250
+ /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].operator`, children: (L) => /* @__PURE__ */ e.jsxs(N, { children: [
251
+ /* @__PURE__ */ e.jsx(C, { htmlFor: `operator-${k}`, children: g("editor.conditionalEdge.operator") }),
252
+ /* @__PURE__ */ e.jsxs(
253
+ $,
254
+ {
255
+ disabled: I,
256
+ value: L.state.value || "===",
257
+ onValueChange: (H) => L.handleChange(H),
258
+ children: [
259
+ /* @__PURE__ */ e.jsx(A, { id: `operator-${k}`, children: /* @__PURE__ */ e.jsx(z, {}) }),
260
+ /* @__PURE__ */ e.jsxs(G, { children: [
261
+ /* @__PURE__ */ e.jsx(f, { value: "===", children: "=" }),
262
+ /* @__PURE__ */ e.jsx(f, { value: "!==", children: "≠" }),
263
+ /* @__PURE__ */ e.jsx(f, { value: ">", children: ">" }),
264
+ /* @__PURE__ */ e.jsx(f, { value: "<", children: "<" }),
265
+ /* @__PURE__ */ e.jsx(f, { value: ">=", children: ">=" }),
266
+ /* @__PURE__ */ e.jsx(f, { value: "<=", children: "<=" })
267
+ ] })
268
+ ]
269
+ }
270
+ )
271
+ ] }) }),
272
+ /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].value`, children: (L) => /* @__PURE__ */ e.jsxs(N, { className: "w-full", children: [
273
+ /* @__PURE__ */ e.jsx(C, { htmlFor: `value-${k}`, children: g("editor.conditionalEdge.value") }),
274
+ /* @__PURE__ */ e.jsx(
275
+ y,
276
+ {
277
+ disabled: I,
278
+ id: `value-${k}`,
279
+ placeholder: g("editor.conditionalEdge.valuePlaceholder"),
280
+ value: L.state.value || "",
281
+ onChange: (H) => L.handleChange(H.target.value)
282
+ }
283
+ )
284
+ ] }) })
285
+ ] }),
286
+ j.state.value && j.state.value.length > 1 && /* @__PURE__ */ e.jsxs(
287
+ w,
288
+ {
289
+ disabled: I,
290
+ type: "button",
291
+ variant: "ghost",
292
+ size: "sm",
293
+ className: "w-full",
294
+ onClick: () => {
295
+ j.removeValue(k), E().then();
296
+ },
297
+ children: [
298
+ /* @__PURE__ */ e.jsx(oe, { className: "mr-1 h-4 w-4" }),
299
+ g("editor.conditionalEdge.removeCondition")
300
+ ]
301
+ }
302
+ )
303
+ ] }),
304
+ j.state.value && k < j.state.value.length - 1 && /* @__PURE__ */ e.jsx(P, { name: `conditions[${k}].logicalOperator`, children: (L) => /* @__PURE__ */ e.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ e.jsxs(
305
+ $,
306
+ {
307
+ disabled: I,
308
+ value: L.state.value || ee.AND,
309
+ onValueChange: (H) => L.handleChange(H),
310
+ children: [
311
+ /* @__PURE__ */ e.jsx(A, { className: "h-9 w-32 font-semibold", children: /* @__PURE__ */ e.jsx(z, {}) }),
312
+ /* @__PURE__ */ e.jsxs(G, { children: [
313
+ /* @__PURE__ */ e.jsx(f, { value: ee.AND, children: "AND" }),
314
+ /* @__PURE__ */ e.jsx(f, { value: ee.OR, children: "OR" })
315
+ ] })
316
+ ]
317
+ }
318
+ ) }) })
319
+ ] }, `condition-${k}`)),
320
+ /* @__PURE__ */ e.jsxs(
321
+ w,
322
+ {
323
+ disabled: I,
324
+ type: "button",
325
+ variant: "outline",
326
+ size: "sm",
327
+ className: "w-full",
328
+ onClick: () => {
329
+ j.pushValue({
330
+ field: F[0]?.nodeId ?? "",
331
+ logicalOperator: ee.AND,
332
+ operator: "===",
333
+ value: ""
334
+ }), E().then();
335
+ },
336
+ children: [
337
+ /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
338
+ g("editor.conditionalEdge.addCondition")
339
+ ]
340
+ }
341
+ )
342
+ ] })
343
+ ] });
344
+ } })
345
+ ] }),
346
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
347
+ /* @__PURE__ */ e.jsxs(w, { type: "button", size: "sm", variant: "outline", onClick: X, children: [
348
+ /* @__PURE__ */ e.jsx(oe, { className: "mr-1 h-4 w-4" }),
349
+ g("common.clear")
350
+ ] }),
351
+ /* @__PURE__ */ e.jsx(w, { type: "button", size: "sm", onClick: () => v(!1), children: g("common.close") })
352
+ ] })
353
+ ] })
354
+ }
355
+ ) }) })
356
+ ] })
357
+ }
358
+ ) })
359
+ ] });
360
+ }, Gt = {
361
+ conditional: zt
362
+ }, Le = ({ children: t, inGroup: r }) => /* @__PURE__ */ e.jsx("div", { className: D("react-flow__node__wrapper", r ? "in-group" : ""), children: t }), _t = Mt(
363
+ "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
364
+ {
365
+ defaultVariants: {
366
+ variant: "default"
367
+ },
368
+ variants: {
369
+ variant: {
370
+ default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
371
+ destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
372
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
373
+ purple: "bg-purple-600 hover:bg-purple-700 text-white",
374
+ secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
375
+ }
376
+ }
377
+ }
378
+ );
379
+ function re({
380
+ className: t,
381
+ variant: r,
382
+ asChild: n = !1,
383
+ ...l
384
+ }) {
385
+ const m = n ? Dt : "span";
386
+ return /* @__PURE__ */ e.jsx(m, { "data-slot": "badge", className: D(_t({ variant: r }), t), ...l });
387
+ }
388
+ const Rt = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
389
+ const i = B()(t?.label);
390
+ return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
391
+ /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
392
+ /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: i }),
393
+ /* @__PURE__ */ e.jsxs(re, { variant: "destructive", children: [
394
+ /* @__PURE__ */ e.jsx(jt, {}),
395
+ n
396
+ ] }),
397
+ /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
398
+ ] });
399
+ }, Zt = ({ data: t }) => {
400
+ const n = B()(t?.label);
401
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
402
+ /* @__PURE__ */ e.jsx(rt, {}),
403
+ /* @__PURE__ */ e.jsx("div", { className: "-top-3.5 absolute left-6", children: /* @__PURE__ */ e.jsxs(re, { className: "max-w-50 bg-chart-2", children: [
404
+ /* @__PURE__ */ e.jsx(gt, { className: "!w-3 !h-3" }),
405
+ n
406
+ ] }) })
407
+ ] });
408
+ }, Ut = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
409
+ const i = B()(t?.label);
410
+ return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
411
+ /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
412
+ /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl", children: i || t?.name }),
413
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
414
+ n && /* @__PURE__ */ e.jsxs(re, { variant: "secondary", className: "bg-blue-500 text-white dark:bg-blue-600", children: [
415
+ /* @__PURE__ */ e.jsx(Ct, {}),
416
+ n
417
+ ] }),
418
+ t?.type && /* @__PURE__ */ e.jsxs(re, { variant: "outline", children: [
419
+ /* @__PURE__ */ e.jsx(Ae, {}),
420
+ t.type
421
+ ] })
422
+ ] }),
423
+ /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
424
+ ] });
425
+ }, qt = ({ data: t, isConnectable: r, type: n, parentId: l }) => {
426
+ const i = B()(t?.label);
427
+ return /* @__PURE__ */ e.jsxs(Le, { inGroup: !!l, children: [
428
+ /* @__PURE__ */ e.jsx(se, { type: "target", position: ne.Top, isConnectable: r }),
429
+ /* @__PURE__ */ e.jsx("div", { className: "mb-1 max-w-full overflow-hidden text-ellipsis text-nowrap text-2xl capitalize", children: i }),
430
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
431
+ /* @__PURE__ */ e.jsxs(re, { variant: "purple", children: [
432
+ /* @__PURE__ */ e.jsx(vt, {}),
433
+ n
434
+ ] }),
435
+ t?.type && /* @__PURE__ */ e.jsxs(re, { variant: "outline", children: [
436
+ /* @__PURE__ */ e.jsx(Ae, {}),
437
+ t.type
438
+ ] })
439
+ ] }),
440
+ /* @__PURE__ */ e.jsx(se, { type: "source", position: ne.Bottom, isConnectable: r })
441
+ ] });
442
+ }, Re = {
443
+ [pe.flow]: Rt,
444
+ [pe.group]: Zt,
445
+ [pe.input]: Ut,
446
+ [pe.ui]: qt
447
+ }, Kt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
448
+ let le = (t = 21) => {
449
+ let r = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
450
+ for (; t--; )
451
+ r += Kt[n[t] & 63];
452
+ return r;
453
+ };
454
+ const Ze = {
455
+ data: {
456
+ type: "text"
457
+ },
458
+ id: le(),
459
+ position: { x: 0, y: 0 },
460
+ type: "input"
461
+ };
462
+ function Fe({ ...t }) {
463
+ return /* @__PURE__ */ e.jsx(K.Root, { "data-slot": "dropdown-menu", ...t });
464
+ }
465
+ function Se({ ...t }) {
466
+ return /* @__PURE__ */ e.jsx(K.Trigger, { "data-slot": "dropdown-menu-trigger", ...t });
467
+ }
468
+ function Ve({ className: t, sideOffset: r = 4, ...n }) {
469
+ return /* @__PURE__ */ e.jsx(K.Portal, { children: /* @__PURE__ */ e.jsx(
470
+ K.Content,
471
+ {
472
+ "data-slot": "dropdown-menu-content",
473
+ sideOffset: r,
474
+ className: D(
475
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
476
+ t
477
+ ),
478
+ ...n
479
+ }
480
+ ) });
481
+ }
482
+ function Ne({ ...t }) {
483
+ return /* @__PURE__ */ e.jsx(K.Group, { "data-slot": "dropdown-menu-group", ...t });
484
+ }
485
+ function U({
486
+ className: t,
487
+ inset: r,
488
+ variant: n = "default",
489
+ ...l
490
+ }) {
491
+ return /* @__PURE__ */ e.jsx(
492
+ K.Item,
493
+ {
494
+ "data-slot": "dropdown-menu-item",
495
+ "data-inset": r,
496
+ "data-variant": n,
497
+ className: D(
498
+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
499
+ t
500
+ ),
501
+ ...l
502
+ }
503
+ );
504
+ }
505
+ function Wt({
506
+ className: t,
507
+ inset: r,
508
+ ...n
509
+ }) {
510
+ return /* @__PURE__ */ e.jsx(
511
+ K.Label,
512
+ {
513
+ "data-slot": "dropdown-menu-label",
514
+ "data-inset": r,
515
+ className: D("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", t),
516
+ ...n
517
+ }
518
+ );
519
+ }
520
+ function ye({ className: t, ...r }) {
521
+ return /* @__PURE__ */ e.jsx(
522
+ K.Separator,
523
+ {
524
+ "data-slot": "dropdown-menu-separator",
525
+ className: D("bg-border -mx-1 my-1 h-px", t),
526
+ ...r
527
+ }
528
+ );
529
+ }
530
+ const Yt = le(), Jt = ({ onExportJson: t, onSave: r }) => {
531
+ const { flowId: n, setFlowId: l } = Ge(), { setNodes: m, setEdges: i, addNodes: s, screenToFlowPosition: c } = me(), d = n || Yt, a = De(), o = $e(), u = Tt(null), h = B(), x = () => {
532
+ const g = (window.innerWidth || 0) / 2, E = (window.innerHeight || 0) / 2, V = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-width"), 10), P = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-height"), 10), T = c({ x: g - V, y: E - P });
533
+ s([
534
+ {
535
+ ...Ze,
536
+ id: le(),
537
+ position: T
538
+ }
539
+ ]);
540
+ }, p = ({ target: g }) => {
541
+ const E = g.files?.[0];
542
+ if (!E)
543
+ return;
544
+ const V = new FileReader();
545
+ V.onload = (P) => {
546
+ try {
547
+ const T = JSON.parse(P.target?.result);
548
+ T && Array.isArray(T.nodes) && Array.isArray(T.edges) ? (m(T.nodes), i(T.edges), R.success(h("editor.actionsPanel.importSuccess"), {
549
+ description: h("editor.actionsPanel.importSuccessDesc")
550
+ })) : R.error(h("editor.actionsPanel.invalidJson"), {
551
+ description: h("editor.actionsPanel.invalidJsonDesc")
552
+ });
553
+ } catch (T) {
554
+ console.warn(T), R.error(h("editor.actionsPanel.parseError"), {
555
+ description: h("editor.actionsPanel.parseErrorDesc")
556
+ });
557
+ }
558
+ u.current && (u.current.value = "");
559
+ }, V.readAsText(E);
560
+ }, v = () => {
561
+ const g = { edges: o, id: d, nodes: a }, E = new Blob([JSON.stringify(g, null, 2)], { type: "application/json" }), V = URL.createObjectURL(E), P = document.createElement("a");
562
+ P.href = V, P.download = "treege.json", P.click(), URL.revokeObjectURL(V), R.success(h("editor.actionsPanel.downloadSuccess"), {
563
+ description: h("editor.actionsPanel.downloadSuccessDesc")
564
+ }), n || l?.(d), t?.(g);
565
+ }, M = () => {
566
+ n || l?.(d), r?.({ edges: o, id: d, nodes: a });
567
+ }, F = async () => {
568
+ try {
569
+ await navigator.clipboard.writeText(d), R.success(h("editor.actionsPanel.idCopied"), {
570
+ description: d
571
+ });
572
+ } catch {
573
+ R.error(h("editor.actionsPanel.copyFailed"));
574
+ }
575
+ }, S = () => {
576
+ m([]), i([]), R.success(h("editor.actionsPanel.clearSuccess"), {
577
+ description: h("editor.actionsPanel.clearSuccessDesc")
578
+ });
579
+ };
580
+ return /* @__PURE__ */ e.jsxs(lt, { position: "top-right", className: "flex gap-2", children: [
581
+ /* @__PURE__ */ e.jsxs(w, { variant: "outline", size: "sm", onClick: x, children: [
582
+ /* @__PURE__ */ e.jsx(xe, {}),
583
+ " ",
584
+ h("editor.actionsPanel.addNode")
585
+ ] }),
586
+ /* @__PURE__ */ e.jsxs(Fe, { children: [
587
+ /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "sm", children: /* @__PURE__ */ e.jsx(ft, {}) }) }),
588
+ /* @__PURE__ */ e.jsxs(Ve, { align: "start", children: [
589
+ /* @__PURE__ */ e.jsx(Wt, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
590
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: "Treege ID" }),
591
+ /* @__PURE__ */ e.jsxs(
592
+ "button",
593
+ {
594
+ onClick: F,
595
+ className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
596
+ type: "button",
597
+ children: [
598
+ /* @__PURE__ */ e.jsx(bt, { className: "h-3 w-3" }),
599
+ /* @__PURE__ */ e.jsx("span", { className: "truncate text-xs", children: d })
600
+ ]
601
+ }
602
+ )
603
+ ] }) }),
604
+ /* @__PURE__ */ e.jsx(ye, {}),
605
+ /* @__PURE__ */ e.jsxs(Ne, { children: [
606
+ /* @__PURE__ */ e.jsxs(U, { onClick: () => u?.current?.click(), children: [
607
+ /* @__PURE__ */ e.jsx(Nt, {}),
608
+ " ",
609
+ h("editor.actionsPanel.importJson")
610
+ ] }),
611
+ /* @__PURE__ */ e.jsxs(U, { onClick: v, children: [
612
+ /* @__PURE__ */ e.jsx(yt, {}),
613
+ " ",
614
+ h("editor.actionsPanel.exportJson")
615
+ ] })
616
+ ] }),
617
+ /* @__PURE__ */ e.jsx(ye, {}),
618
+ /* @__PURE__ */ e.jsx(Ne, { children: /* @__PURE__ */ e.jsxs(U, { onClick: M, children: [
619
+ /* @__PURE__ */ e.jsx(wt, {}),
620
+ " ",
621
+ h("common.save")
622
+ ] }) }),
623
+ /* @__PURE__ */ e.jsx(ye, {}),
624
+ /* @__PURE__ */ e.jsx(Ne, { children: /* @__PURE__ */ e.jsxs(U, { onClick: S, className: "text-destructive focus:text-destructive", children: [
625
+ /* @__PURE__ */ e.jsx(Ft, { className: "text-destructive" }),
626
+ " ",
627
+ h("editor.actionsPanel.clear")
628
+ ] }) })
629
+ ] })
630
+ ] }),
631
+ /* @__PURE__ */ e.jsx("input", { type: "file", accept: "application/json,.json", className: "hidden", ref: u, onChange: p })
632
+ ] });
633
+ }, Xt = {
634
+ ar: "ar",
635
+ de: "de",
636
+ en: "en",
637
+ es: "es",
638
+ fr: "fr",
639
+ it: "it",
640
+ pt: "pt"
641
+ }, Y = ({ value: t = "en", onValueChange: r }) => /* @__PURE__ */ e.jsxs($, { value: t, onValueChange: r, children: [
642
+ /* @__PURE__ */ e.jsx(A, { className: "uppercase", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
643
+ /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.values(Xt).map((n) => /* @__PURE__ */ e.jsx(f, { value: n, className: "uppercase", children: n }, n)) }) })
644
+ ] }), ce = () => {
645
+ const { setNodes: t, setEdges: r, getNodes: n } = me(), l = Z(() => {
646
+ t((d) => d.map(({ selected: a, ...o }) => o)), r((d) => d.map(({ selected: a, ...o }) => o));
647
+ }, [r, t]), m = Z(
648
+ (d, a) => {
649
+ t(
650
+ (o) => o.map((u) => u.id === d ? {
651
+ ...u,
652
+ data: {
653
+ ...u.data,
654
+ ...a
655
+ }
656
+ } : u)
657
+ );
658
+ },
659
+ [t]
660
+ ), i = Z(
661
+ (d, a) => {
662
+ t(
663
+ (o) => o.map((u) => u.id === d ? {
664
+ ...u,
665
+ data: {},
666
+ type: a
667
+ } : u)
668
+ );
669
+ },
670
+ [t]
671
+ ), s = Z(
672
+ (d) => {
673
+ const a = n().find((o) => o.selected);
674
+ a && i(a.id, d);
675
+ },
676
+ [n, i]
677
+ ), c = Z(
678
+ (d) => {
679
+ const a = n().find((o) => o.selected);
680
+ a && m(a.id, d);
681
+ },
682
+ [n, m]
683
+ );
684
+ return {
685
+ clearSelection: l,
686
+ updateNodeData: m,
687
+ updateNodeType: i,
688
+ updateSelectedNodeData: c,
689
+ updateSelectedNodeType: s
690
+ };
691
+ }, W = () => {
692
+ const t = De(), r = ae(() => t.filter(ve), [t]), n = ae(() => t.filter((m) => m.selected), [t]), l = ae(() => t.find((m) => m.selected), [t]);
693
+ return {
694
+ groupNodes: r,
695
+ hasSelectedNodes: n.length > 0,
696
+ nodes: t,
697
+ selectedNode: l,
698
+ selectedNodes: n
699
+ };
700
+ }, Qt = () => {
701
+ const [t, r] = _("en"), { updateSelectedNodeData: n } = ce(), { selectedNode: l } = W(), m = B(), { Field: i } = ie({
702
+ defaultValues: {
703
+ label: l?.data?.label || { en: "" },
704
+ targetId: l?.data?.targetId || ""
705
+ },
706
+ listeners: {
707
+ onChange: ({ formApi: s }) => {
708
+ s.handleSubmit().then();
709
+ },
710
+ onChangeDebounceMs: 150
711
+ },
712
+ onSubmit: ({ value: s }) => {
713
+ n(s);
714
+ }
715
+ });
716
+ return /* @__PURE__ */ e.jsx(
717
+ "form",
718
+ {
719
+ onSubmit: (s) => {
720
+ s.preventDefault(), s.stopPropagation();
721
+ },
722
+ children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
723
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
724
+ /* @__PURE__ */ e.jsx(
725
+ i,
726
+ {
727
+ name: "label",
728
+ children: (s) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
729
+ /* @__PURE__ */ e.jsx(C, { htmlFor: s.name, children: m("editor.flowNodeForm.label") }),
730
+ /* @__PURE__ */ e.jsx(
731
+ y,
732
+ {
733
+ id: s.name,
734
+ name: s.name,
735
+ value: s.state.value?.[t] || "",
736
+ onBlur: s.handleBlur,
737
+ onChange: ({ target: c }) => {
738
+ s.handleChange({
739
+ ...s.state.value,
740
+ [t]: c.value
741
+ });
742
+ }
743
+ }
744
+ )
745
+ ] })
746
+ }
747
+ ),
748
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
749
+ ] }),
750
+ /* @__PURE__ */ e.jsx(
751
+ i,
752
+ {
753
+ name: "targetId",
754
+ children: (s) => /* @__PURE__ */ e.jsxs(N, { children: [
755
+ /* @__PURE__ */ e.jsxs(C, { htmlFor: s.name, children: [
756
+ m("editor.flowNodeForm.targetId"),
757
+ " (Flow ID)"
758
+ ] }),
759
+ /* @__PURE__ */ e.jsx(
760
+ y,
761
+ {
762
+ id: s.name,
763
+ name: s.name,
764
+ value: s.state.value,
765
+ onBlur: s.handleBlur,
766
+ onChange: ({ target: c }) => s.handleChange(c.value)
767
+ }
768
+ ),
769
+ /* @__PURE__ */ e.jsx(O, { children: "Unique identifier of the target flow." })
770
+ ] })
771
+ }
772
+ )
773
+ ] })
774
+ }
775
+ );
776
+ }, ea = () => {
777
+ const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), { Field: m } = ie({
778
+ defaultValues: {
779
+ label: n?.data?.label || { en: "" }
780
+ },
781
+ listeners: {
782
+ onChange: ({ formApi: i }) => {
783
+ i.handleSubmit().then();
784
+ },
785
+ onChangeDebounceMs: 150
786
+ },
787
+ onSubmit: ({ value: i }) => {
788
+ l(i);
789
+ }
790
+ });
791
+ return /* @__PURE__ */ e.jsx(
792
+ "form",
793
+ {
794
+ onSubmit: (i) => {
795
+ i.preventDefault(), i.stopPropagation();
796
+ },
797
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
798
+ /* @__PURE__ */ e.jsx(
799
+ m,
800
+ {
801
+ name: "label",
802
+ children: (i) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
803
+ /* @__PURE__ */ e.jsx(C, { htmlFor: i.name, children: "Label" }),
804
+ /* @__PURE__ */ e.jsx(
805
+ y,
806
+ {
807
+ id: i.name,
808
+ name: i.name,
809
+ value: i.state.value?.[t] || "",
810
+ onBlur: i.handleBlur,
811
+ onChange: ({ target: s }) => {
812
+ i.handleChange({
813
+ ...i.state.value,
814
+ [t]: s.value
815
+ });
816
+ }
817
+ }
818
+ )
819
+ ] })
820
+ }
821
+ ),
822
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
823
+ ] })
824
+ }
825
+ );
826
+ }, ta = ["POST", "PUT", "PATCH"], aa = ({ value: t, onChange: r }) => {
827
+ const { selectedNode: n } = W(), l = B(), m = Ie(n?.id), { handleSubmit: i, Field: s } = ie({
828
+ defaultValues: {
829
+ body: t?.body || "",
830
+ // fetchOnMount should be true by default if there's no searchParam
831
+ fetchOnMount: t?.fetchOnMount ?? !t?.searchParam,
832
+ headers: t?.headers || [],
833
+ method: t?.method || "GET",
834
+ responseMapping: t?.responseMapping || {
835
+ labelField: "",
836
+ valueField: ""
837
+ },
838
+ responsePath: t?.responsePath || "",
839
+ searchParam: t?.searchParam || "",
840
+ showLoading: t?.showLoading !== !1,
841
+ url: t?.url || ""
842
+ },
843
+ listeners: {
844
+ onChange: ({ formApi: c }) => {
845
+ c.handleSubmit().then();
846
+ },
847
+ onChangeDebounceMs: 150
848
+ },
849
+ onSubmit: ({ value: c }) => {
850
+ r(c);
851
+ }
852
+ });
853
+ return /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
854
+ /* @__PURE__ */ e.jsx(
855
+ s,
856
+ {
857
+ name: "url",
858
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
859
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.apiUrl") }),
860
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
861
+ /* @__PURE__ */ e.jsx(
862
+ y,
863
+ {
864
+ id: c.name,
865
+ name: c.name,
866
+ value: c.state.value,
867
+ onBlur: c.handleBlur,
868
+ onChange: ({ target: d }) => c.handleChange(d.value),
869
+ placeholder: l("editor.httpConfigForm.apiUrlPlaceholder"),
870
+ className: "flex-1"
871
+ }
872
+ ),
873
+ /* @__PURE__ */ e.jsxs(Fe, { children: [
874
+ /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { type: "button", variant: "outline", size: "icon", children: /* @__PURE__ */ e.jsx(He, { className: "h-4 w-4" }) }) }),
875
+ /* @__PURE__ */ e.jsx(Ve, { align: "end", children: m.length === 0 ? /* @__PURE__ */ e.jsx(U, { disabled: !0, children: l("editor.httpConfigForm.noFieldsAvailable") }) : m.map((d) => /* @__PURE__ */ e.jsx(
876
+ U,
877
+ {
878
+ onClick: () => {
879
+ const a = `{{${d.nodeId}}}`, o = c.state.value || "";
880
+ c.handleChange(o + a);
881
+ },
882
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
883
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: d.label }),
884
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `{{${d.nodeId}}}` })
885
+ ] })
886
+ },
887
+ d.nodeId
888
+ )) })
889
+ ] })
890
+ ] }),
891
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.apiUrlDesc") })
892
+ ] })
893
+ }
894
+ ),
895
+ /* @__PURE__ */ e.jsx(
896
+ s,
897
+ {
898
+ name: "method",
899
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
900
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.httpMethod") }),
901
+ /* @__PURE__ */ e.jsxs(
902
+ $,
903
+ {
904
+ value: c.state.value,
905
+ onValueChange: (d) => c.handleChange(d),
906
+ children: [
907
+ /* @__PURE__ */ e.jsx(A, { id: c.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: l("editor.httpConfigForm.selectMethod") }) }),
908
+ /* @__PURE__ */ e.jsxs(G, { children: [
909
+ /* @__PURE__ */ e.jsx(f, { value: "GET", children: l("editor.httpConfigForm.methodGet") }),
910
+ /* @__PURE__ */ e.jsx(f, { value: "POST", children: l("editor.httpConfigForm.methodPost") }),
911
+ /* @__PURE__ */ e.jsx(f, { value: "PUT", children: l("editor.httpConfigForm.methodPut") }),
912
+ /* @__PURE__ */ e.jsx(f, { value: "DELETE", children: l("editor.httpConfigForm.methodDelete") }),
913
+ /* @__PURE__ */ e.jsx(f, { value: "PATCH", children: l("editor.httpConfigForm.methodPatch") })
914
+ ] })
915
+ ]
916
+ }
917
+ )
918
+ ] })
919
+ }
920
+ ),
921
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
922
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.headers") }),
923
+ /* @__PURE__ */ e.jsx(s, { name: "headers", mode: "array", children: (c) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
924
+ c.state.value?.map((d, a) => {
925
+ const o = `headers[${a}]`;
926
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
927
+ /* @__PURE__ */ e.jsx(s, { name: `headers[${a}].key`, children: (u) => /* @__PURE__ */ e.jsx(
928
+ y,
929
+ {
930
+ placeholder: l("editor.httpConfigForm.headerName"),
931
+ value: u.state.value || "",
932
+ onChange: ({ target: h }) => u.handleChange(h.value)
933
+ }
934
+ ) }),
935
+ /* @__PURE__ */ e.jsx(s, { name: `headers[${a}].value`, children: (u) => /* @__PURE__ */ e.jsx(
936
+ y,
937
+ {
938
+ placeholder: l("editor.httpConfigForm.headerValue"),
939
+ value: u.state.value || "",
940
+ onChange: ({ target: h }) => u.handleChange(h.value)
941
+ }
942
+ ) }),
943
+ /* @__PURE__ */ e.jsx(
944
+ w,
945
+ {
946
+ type: "button",
947
+ variant: "ghost",
948
+ size: "icon",
949
+ onClick: () => {
950
+ c.removeValue(a);
951
+ },
952
+ children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
953
+ }
954
+ )
955
+ ] }, o);
956
+ }),
957
+ /* @__PURE__ */ e.jsxs(
958
+ w,
959
+ {
960
+ type: "button",
961
+ variant: "outline",
962
+ size: "sm",
963
+ onClick: () => {
964
+ c.pushValue({ key: "", value: "" });
965
+ },
966
+ children: [
967
+ /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
968
+ l("editor.httpConfigForm.addHeader")
969
+ ]
970
+ }
971
+ )
972
+ ] }) })
973
+ ] }),
974
+ /* @__PURE__ */ e.jsx(s, { name: "method", children: (c) => ta.includes(c.state.value || "") && /* @__PURE__ */ e.jsx(s, { name: "body", children: (d) => /* @__PURE__ */ e.jsxs(N, { children: [
975
+ /* @__PURE__ */ e.jsxs("div", { className: "mb-2 flex items-center justify-between", children: [
976
+ /* @__PURE__ */ e.jsx(C, { htmlFor: d.name, children: l("editor.httpConfigForm.requestBody") }),
977
+ /* @__PURE__ */ e.jsxs(Fe, { children: [
978
+ /* @__PURE__ */ e.jsx(Se, { asChild: !0, children: /* @__PURE__ */ e.jsxs(w, { type: "button", variant: "ghost", size: "sm", children: [
979
+ /* @__PURE__ */ e.jsx(He, { className: "mr-2 h-4 w-4" }),
980
+ l("editor.httpConfigForm.insertVariable")
981
+ ] }) }),
982
+ /* @__PURE__ */ e.jsx(Ve, { align: "end", children: m.length === 0 ? /* @__PURE__ */ e.jsx(U, { disabled: !0, children: l("editor.httpConfigForm.noFieldsAvailable") }) : m.map((a) => /* @__PURE__ */ e.jsx(
983
+ U,
984
+ {
985
+ onClick: () => {
986
+ const u = `\${${a.name || a.nodeId}}`, h = d.state.value || "";
987
+ d.handleChange(h + u), i().then();
988
+ },
989
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col", children: [
990
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: a.label }),
991
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground text-xs", children: `\${${a.name || a.nodeId}}` })
992
+ ] })
993
+ },
994
+ a.nodeId
995
+ )) })
996
+ ] })
997
+ ] }),
998
+ /* @__PURE__ */ e.jsx(
999
+ Ke,
1000
+ {
1001
+ id: d.name,
1002
+ name: d.name,
1003
+ value: d.state.value,
1004
+ onBlur: d.handleBlur,
1005
+ onChange: ({ target: a }) => d.handleChange(a.value),
1006
+ placeholder: l("editor.httpConfigForm.requestBodyPlaceholder"),
1007
+ rows: 4
1008
+ }
1009
+ ),
1010
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.requestBodyDesc") })
1011
+ ] }) }) }),
1012
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1013
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.responseConfiguration") }),
1014
+ /* @__PURE__ */ e.jsx(
1015
+ s,
1016
+ {
1017
+ name: "responsePath",
1018
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1019
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.responsePath") }),
1020
+ /* @__PURE__ */ e.jsx(
1021
+ y,
1022
+ {
1023
+ id: c.name,
1024
+ name: c.name,
1025
+ value: c.state.value,
1026
+ onBlur: c.handleBlur,
1027
+ onChange: ({ target: d }) => c.handleChange(d.value),
1028
+ placeholder: l("editor.httpConfigForm.responsePathPlaceholder")
1029
+ }
1030
+ ),
1031
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.responsePathDesc") })
1032
+ ] })
1033
+ }
1034
+ ),
1035
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1036
+ /* @__PURE__ */ e.jsx("h5", { className: "font-medium text-sm", children: l("editor.httpConfigForm.mapToOptions") }),
1037
+ /* @__PURE__ */ e.jsx(
1038
+ s,
1039
+ {
1040
+ name: "responseMapping.valueField",
1041
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1042
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.valueField") }),
1043
+ /* @__PURE__ */ e.jsx(
1044
+ y,
1045
+ {
1046
+ id: c.name,
1047
+ name: c.name,
1048
+ value: c.state.value,
1049
+ onBlur: c.handleBlur,
1050
+ onChange: ({ target: d }) => c.handleChange(d.value),
1051
+ placeholder: l("editor.httpConfigForm.valueFieldPlaceholder")
1052
+ }
1053
+ ),
1054
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.valueFieldDesc") })
1055
+ ] })
1056
+ }
1057
+ ),
1058
+ /* @__PURE__ */ e.jsx(
1059
+ s,
1060
+ {
1061
+ name: "responseMapping.labelField",
1062
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1063
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.labelField") }),
1064
+ /* @__PURE__ */ e.jsx(
1065
+ y,
1066
+ {
1067
+ id: c.name,
1068
+ name: c.name,
1069
+ value: c.state.value,
1070
+ onBlur: c.handleBlur,
1071
+ onChange: ({ target: d }) => c.handleChange(d.value),
1072
+ placeholder: l("editor.httpConfigForm.labelFieldPlaceholder")
1073
+ }
1074
+ ),
1075
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.labelFieldDesc") })
1076
+ ] })
1077
+ }
1078
+ )
1079
+ ] }),
1080
+ /* @__PURE__ */ e.jsx(
1081
+ s,
1082
+ {
1083
+ name: "searchParam",
1084
+ children: (c) => /* @__PURE__ */ e.jsxs(N, { children: [
1085
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.searchParameter") }),
1086
+ /* @__PURE__ */ e.jsx(
1087
+ y,
1088
+ {
1089
+ id: c.name,
1090
+ name: c.name,
1091
+ value: c.state.value,
1092
+ onBlur: c.handleBlur,
1093
+ onChange: ({ target: d }) => c.handleChange(d.value),
1094
+ placeholder: l("editor.httpConfigForm.searchParameterPlaceholder")
1095
+ }
1096
+ ),
1097
+ /* @__PURE__ */ e.jsx(O, { children: l("editor.httpConfigForm.searchParameterDesc") })
1098
+ ] })
1099
+ }
1100
+ )
1101
+ ] }),
1102
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1103
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: l("editor.httpConfigForm.behavior") }),
1104
+ /* @__PURE__ */ e.jsx(s, { name: "searchParam", children: (c) => /* @__PURE__ */ e.jsx(s, { name: "fetchOnMount", children: (d) => {
1105
+ const a = !!c.state.value?.trim(), o = a ? d.state.value : !0;
1106
+ return !a && d.state.value !== !0 && d.handleChange(!0), /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1107
+ /* @__PURE__ */ e.jsx(
1108
+ te,
1109
+ {
1110
+ id: d.name,
1111
+ checked: o,
1112
+ disabled: !a,
1113
+ onCheckedChange: (u) => d.handleChange(u)
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ e.jsx(C, { htmlFor: d.name, className: a ? "" : "text-muted-foreground", children: l("editor.httpConfigForm.fetchOnMount") })
1117
+ ] });
1118
+ } }) }),
1119
+ /* @__PURE__ */ e.jsx(
1120
+ s,
1121
+ {
1122
+ name: "showLoading",
1123
+ children: (c) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1124
+ /* @__PURE__ */ e.jsx(te, { id: c.name, checked: c.state.value, onCheckedChange: (d) => c.handleChange(d) }),
1125
+ /* @__PURE__ */ e.jsx(C, { htmlFor: c.name, children: l("editor.httpConfigForm.showLoadingState") })
1126
+ ] })
1127
+ }
1128
+ )
1129
+ ] })
1130
+ ] }) });
1131
+ }, sa = ({
1132
+ options: t,
1133
+ value: r,
1134
+ onValueChange: n,
1135
+ placeholder: l = "Select...",
1136
+ searchPlaceholder: m = "Search or create...",
1137
+ createLabel: i = (u) => `Use: ${u}`,
1138
+ clearLabel: s = "Clear selection",
1139
+ emptyLabel: c = "No results found",
1140
+ className: d,
1141
+ allowClear: a = !0,
1142
+ allowCreate: o = !0
1143
+ }) => {
1144
+ const [u, h] = _(!1), [x, p] = _(""), v = (b) => b ?? "", M = (b) => b.trim().toLowerCase(), F = v(r), S = r !== null && r !== "", g = S ? t.find((b) => v(b.value) === F) : void 0, E = M(x), V = o && E !== "" && !t.some((b) => M(b.label) === E || M(b.value ?? "") === E), P = (b) => {
1145
+ b === F ? a && n?.("") : n?.(b), h(!1), p("");
1146
+ }, T = () => {
1147
+ x.trim() && (n?.(x.trim()), h(!1), p(""));
1148
+ }, X = () => {
1149
+ n?.(""), h(!1), p("");
1150
+ };
1151
+ return /* @__PURE__ */ e.jsxs(Pe, { open: u, onOpenChange: h, children: [
1152
+ /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
1153
+ w,
1154
+ {
1155
+ type: "button",
1156
+ variant: "outline",
1157
+ role: "combobox",
1158
+ "aria-expanded": u,
1159
+ className: D("w-full justify-between font-normal", d),
1160
+ children: [
1161
+ /* @__PURE__ */ e.jsx("span", { className: "truncate", children: S && g ? g.label : l }),
1162
+ /* @__PURE__ */ e.jsx(de, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
1163
+ ]
1164
+ }
1165
+ ) }),
1166
+ /* @__PURE__ */ e.jsx(Ee, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ e.jsxs(We, { shouldFilter: !1, children: [
1167
+ /* @__PURE__ */ e.jsx(Ye, { placeholder: m, value: x, onValueChange: p }),
1168
+ /* @__PURE__ */ e.jsxs(Je, { children: [
1169
+ /* @__PURE__ */ e.jsx(Xe, { children: c }),
1170
+ a && S && /* @__PURE__ */ e.jsx(Be, { children: /* @__PURE__ */ e.jsxs(be, { value: "__clear__", onSelect: X, className: "text-muted-foreground mt-1", children: [
1171
+ /* @__PURE__ */ e.jsx(oe, { className: "mr-2 h-4 w-4" }),
1172
+ s
1173
+ ] }) }),
1174
+ /* @__PURE__ */ e.jsxs(Be, { children: [
1175
+ V && /* @__PURE__ */ e.jsxs(be, { value: `__create__${x}`, onSelect: T, className: "text-primary", children: [
1176
+ /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
1177
+ i(x)
1178
+ ] }),
1179
+ t.filter((b) => {
1180
+ const Q = x.toLowerCase();
1181
+ return b.label.toLowerCase().includes(Q) || (b.value?.toLowerCase() ?? "").includes(Q);
1182
+ }).map((b, Q) => /* @__PURE__ */ e.jsxs(
1183
+ be,
1184
+ {
1185
+ value: b.label,
1186
+ onSelect: () => P(b?.value || ""),
1187
+ children: [
1188
+ /* @__PURE__ */ e.jsx(
1189
+ St,
1190
+ {
1191
+ "aria-hidden": "true",
1192
+ className: D(
1193
+ "mr-2 h-4 w-4",
1194
+ S && v(b.value) === F ? "opacity-100" : "opacity-0"
1195
+ )
1196
+ }
1197
+ ),
1198
+ b.label
1199
+ ]
1200
+ },
1201
+ b.value ?? b.label ?? Q
1202
+ ))
1203
+ ] })
1204
+ ] })
1205
+ ] }) })
1206
+ ] });
1207
+ }, na = {
1208
+ alphanumeric: "^[a-zA-Z0-9]+$",
1209
+ email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
1210
+ letters: "^[a-zA-Z]+$",
1211
+ number: "^[0-9]+$",
1212
+ url: "^https?:\\/\\/.+$"
1213
+ }, we = Object.entries(na).map(([t, r]) => ({
1214
+ label: t.charAt(0).toUpperCase() + t.slice(1).replace(/_/g, " "),
1215
+ value: r
1216
+ })), oa = ({ value: t, onValueChange: r }) => {
1217
+ const n = ae(() => t && !we.some((l) => l.value === t) ? [
1218
+ ...we,
1219
+ {
1220
+ label: `Custom: ${t}`,
1221
+ value: t
1222
+ }
1223
+ ] : we, [t]);
1224
+ return /* @__PURE__ */ e.jsx(
1225
+ sa,
1226
+ {
1227
+ options: n,
1228
+ value: t,
1229
+ onValueChange: r,
1230
+ placeholder: "Select or create a pattern",
1231
+ searchPlaceholder: "Search patterns...",
1232
+ createLabel: (l) => `Use pattern: ${l}`
1233
+ }
1234
+ );
1235
+ }, ra = {
1236
+ address: "address",
1237
+ autocomplete: "autocomplete",
1238
+ checkbox: "checkbox",
1239
+ date: "date",
1240
+ daterange: "daterange",
1241
+ file: "file",
1242
+ hidden: "hidden",
1243
+ http: "http",
1244
+ number: "number",
1245
+ password: "password",
1246
+ radio: "radio",
1247
+ select: "select",
1248
+ switch: "switch",
1249
+ text: "text",
1250
+ textarea: "textarea",
1251
+ time: "time",
1252
+ timerange: "timerange"
1253
+ }, la = ({ value: t, onValueChange: r }) => {
1254
+ const n = B();
1255
+ return /* @__PURE__ */ e.jsxs(q, { children: [
1256
+ /* @__PURE__ */ e.jsx(Te, { children: n("editor.selectInputType.type") }),
1257
+ /* @__PURE__ */ e.jsxs($, { value: t, onValueChange: r, children: [
1258
+ /* @__PURE__ */ e.jsx(A, { className: "w-full capitalize", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
1259
+ /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.values(ra).map((l) => /* @__PURE__ */ e.jsx(f, { value: l, className: "capitalize", children: l }, l)) }) })
1260
+ ] })
1261
+ ] });
1262
+ };
1263
+ function je({ ...t }) {
1264
+ return /* @__PURE__ */ e.jsx(Me.Root, { "data-slot": "collapsible", ...t });
1265
+ }
1266
+ function ge({ ...t }) {
1267
+ return /* @__PURE__ */ e.jsx(Me.CollapsibleTrigger, { "data-slot": "collapsible-trigger", ...t });
1268
+ }
1269
+ function Ce({ ...t }) {
1270
+ return /* @__PURE__ */ e.jsx(Me.CollapsibleContent, { "data-slot": "collapsible-content", ...t });
1271
+ }
1272
+ const ia = () => {
1273
+ const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), m = ["select", "radio", "autocomplete", "checkbox"].includes(n?.data?.type || ""), i = Ie(n?.id), s = B(), { handleSubmit: c, Field: d } = ie({
1274
+ defaultValues: {
1275
+ defaultValue: n?.data?.defaultValue,
1276
+ errorMessage: n?.data?.errorMessage || { en: "" },
1277
+ helperText: n?.data?.helperText || { en: "" },
1278
+ httpConfig: n?.data?.httpConfig,
1279
+ label: n?.data?.label || { en: "" },
1280
+ multiple: n?.data?.multiple,
1281
+ name: n?.data?.name || "",
1282
+ options: n?.data?.options || [],
1283
+ pattern: n?.data?.pattern || "",
1284
+ placeholder: n?.data?.placeholder || { en: "" },
1285
+ required: n?.data?.required,
1286
+ type: n?.data?.type || ""
1287
+ },
1288
+ listeners: {
1289
+ onChange: ({ formApi: a }) => {
1290
+ a.handleSubmit().then();
1291
+ },
1292
+ onChangeDebounceMs: 150
1293
+ },
1294
+ onSubmit: ({ value: a }) => {
1295
+ l(a);
1296
+ }
1297
+ });
1298
+ return /* @__PURE__ */ e.jsx(
1299
+ "form",
1300
+ {
1301
+ onSubmit: (a) => {
1302
+ a.preventDefault(), a.stopPropagation();
1303
+ },
1304
+ children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1305
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1306
+ /* @__PURE__ */ e.jsx(
1307
+ d,
1308
+ {
1309
+ name: "label",
1310
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1311
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.label") }),
1312
+ /* @__PURE__ */ e.jsx(
1313
+ y,
1314
+ {
1315
+ id: a.name,
1316
+ name: a.name,
1317
+ value: a.state.value?.[t] || "",
1318
+ onBlur: a.handleBlur,
1319
+ onChange: ({ target: o }) => {
1320
+ a.handleChange({
1321
+ ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1322
+ [t]: o.value
1323
+ });
1324
+ }
1325
+ }
1326
+ )
1327
+ ] })
1328
+ }
1329
+ ),
1330
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1331
+ ] }),
1332
+ /* @__PURE__ */ e.jsx(
1333
+ d,
1334
+ {
1335
+ name: "type",
1336
+ children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsx(la, { value: a.state.value, onValueChange: (o) => a.handleChange(o) }) })
1337
+ }
1338
+ ),
1339
+ /* @__PURE__ */ e.jsx(
1340
+ d,
1341
+ {
1342
+ name: "name",
1343
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
1344
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.name") }),
1345
+ /* @__PURE__ */ e.jsx(
1346
+ y,
1347
+ {
1348
+ id: a.name,
1349
+ name: a.name,
1350
+ value: a.state.value,
1351
+ onBlur: a.handleBlur,
1352
+ onChange: ({ target: o }) => a.handleChange(o.value)
1353
+ }
1354
+ )
1355
+ ] })
1356
+ }
1357
+ ),
1358
+ n?.data?.type !== "file" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1359
+ /* @__PURE__ */ e.jsx(
1360
+ d,
1361
+ {
1362
+ name: "placeholder",
1363
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1364
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.placeholder") }),
1365
+ /* @__PURE__ */ e.jsx(
1366
+ y,
1367
+ {
1368
+ id: a.name,
1369
+ name: a.name,
1370
+ value: a.state.value?.[t] || "",
1371
+ onBlur: a.handleBlur,
1372
+ onChange: ({ target: o }) => {
1373
+ a.handleChange({
1374
+ ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1375
+ [t]: o.value
1376
+ });
1377
+ }
1378
+ }
1379
+ )
1380
+ ] })
1381
+ }
1382
+ ),
1383
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1384
+ ] }),
1385
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1386
+ /* @__PURE__ */ e.jsx(
1387
+ d,
1388
+ {
1389
+ name: "helperText",
1390
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1391
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.helperText") }),
1392
+ /* @__PURE__ */ e.jsx(
1393
+ y,
1394
+ {
1395
+ id: a.name,
1396
+ name: a.name,
1397
+ value: a.state.value?.[t] || "",
1398
+ onBlur: a.handleBlur,
1399
+ onChange: ({ target: o }) => {
1400
+ a.handleChange({
1401
+ ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1402
+ [t]: o.value
1403
+ });
1404
+ }
1405
+ }
1406
+ )
1407
+ ] })
1408
+ }
1409
+ ),
1410
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1411
+ ] }),
1412
+ n?.data?.type === "http" && /* @__PURE__ */ e.jsxs(je, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1413
+ /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1414
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.httpConfiguration") }),
1415
+ /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1416
+ /* @__PURE__ */ e.jsx(de, {}),
1417
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1418
+ ] })
1419
+ ] }) }),
1420
+ /* @__PURE__ */ e.jsx(Ce, { className: "flex flex-col gap-4", children: /* @__PURE__ */ e.jsx(d, { name: "httpConfig", children: (a) => /* @__PURE__ */ e.jsx(
1421
+ aa,
1422
+ {
1423
+ value: a.state.value,
1424
+ onChange: (o) => {
1425
+ a.handleChange(o), c().then();
1426
+ }
1427
+ }
1428
+ ) }) })
1429
+ ] }),
1430
+ n?.data?.type === "file" && /* @__PURE__ */ e.jsx(
1431
+ d,
1432
+ {
1433
+ name: "multiple",
1434
+ children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1435
+ /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1436
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.multipleFiles") })
1437
+ ] })
1438
+ }
1439
+ ),
1440
+ m && /* @__PURE__ */ e.jsxs(je, { defaultOpen: !0, className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1441
+ /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1442
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.options") }),
1443
+ /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1444
+ /* @__PURE__ */ e.jsx(de, {}),
1445
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1446
+ ] })
1447
+ ] }) }),
1448
+ /* @__PURE__ */ e.jsxs(Ce, { className: "flex flex-col gap-4", children: [
1449
+ /* @__PURE__ */ e.jsx(d, { name: "options", mode: "array", children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1450
+ a.state.value?.map((o, u) => {
1451
+ const h = `options[${u}]`;
1452
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-2", children: [
1453
+ /* @__PURE__ */ e.jsx(d, { name: `options[${u}].label`, children: (x) => /* @__PURE__ */ e.jsx(
1454
+ y,
1455
+ {
1456
+ placeholder: s("editor.inputNodeForm.optionLabel"),
1457
+ value: x.state.value?.[t] || "",
1458
+ onChange: ({ target: p }) => {
1459
+ x.handleChange({
1460
+ ...typeof x.state.value == "object" && x.state.value !== null ? x.state.value : {},
1461
+ [t]: p.value
1462
+ });
1463
+ }
1464
+ }
1465
+ ) }),
1466
+ /* @__PURE__ */ e.jsx(d, { name: `options[${u}].value`, children: (x) => /* @__PURE__ */ e.jsx(
1467
+ y,
1468
+ {
1469
+ placeholder: s("editor.inputNodeForm.optionValue"),
1470
+ value: x.state.value || "",
1471
+ onChange: ({ target: p }) => x.handleChange(p.value)
1472
+ }
1473
+ ) }),
1474
+ /* @__PURE__ */ e.jsx(
1475
+ w,
1476
+ {
1477
+ type: "button",
1478
+ variant: "ghost",
1479
+ size: "icon",
1480
+ onClick: () => {
1481
+ a.removeValue(u), c().then();
1482
+ },
1483
+ children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
1484
+ }
1485
+ )
1486
+ ] }, h);
1487
+ }),
1488
+ /* @__PURE__ */ e.jsx(
1489
+ w,
1490
+ {
1491
+ type: "button",
1492
+ variant: "outline",
1493
+ size: "sm",
1494
+ onClick: () => {
1495
+ a.pushValue({ label: { en: "" }, value: "" }), c().then();
1496
+ },
1497
+ children: s("editor.inputNodeForm.addOption")
1498
+ }
1499
+ )
1500
+ ] }) }),
1501
+ n?.data?.type === "select" && /* @__PURE__ */ e.jsx(
1502
+ d,
1503
+ {
1504
+ name: "multiple",
1505
+ children: (a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1506
+ /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1507
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.multipleSelection") })
1508
+ ] })
1509
+ }
1510
+ )
1511
+ ] })
1512
+ ] }),
1513
+ /* @__PURE__ */ e.jsxs(je, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1514
+ /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1515
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.validation") }),
1516
+ /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1517
+ /* @__PURE__ */ e.jsx(de, {}),
1518
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1519
+ ] })
1520
+ ] }) }),
1521
+ /* @__PURE__ */ e.jsxs(Ce, { className: "flex flex-col gap-6", children: [
1522
+ /* @__PURE__ */ e.jsx(
1523
+ d,
1524
+ {
1525
+ name: "required",
1526
+ children: (a) => /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1527
+ /* @__PURE__ */ e.jsx(te, { id: a.name, checked: a.state.value, onCheckedChange: (o) => a.handleChange(o) }),
1528
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.required") })
1529
+ ] }) })
1530
+ }
1531
+ ),
1532
+ /* @__PURE__ */ e.jsx(
1533
+ d,
1534
+ {
1535
+ name: "pattern",
1536
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { children: [
1537
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.pattern") }),
1538
+ /* @__PURE__ */ e.jsx(oa, { value: a.state.value, onValueChange: a.handleChange })
1539
+ ] })
1540
+ }
1541
+ ),
1542
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1543
+ /* @__PURE__ */ e.jsx(
1544
+ d,
1545
+ {
1546
+ name: "errorMessage",
1547
+ children: (a) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1548
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.errorMessage") }),
1549
+ /* @__PURE__ */ e.jsx(
1550
+ y,
1551
+ {
1552
+ id: a.name,
1553
+ name: a.name,
1554
+ value: a.state.value?.[t] || "",
1555
+ onBlur: a.handleBlur,
1556
+ onChange: ({ target: o }) => {
1557
+ a.handleChange({
1558
+ ...typeof a.state.value == "object" && a.state.value !== null ? a.state.value : {},
1559
+ [t]: o.value
1560
+ });
1561
+ }
1562
+ }
1563
+ )
1564
+ ] })
1565
+ }
1566
+ ),
1567
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1568
+ ] })
1569
+ ] })
1570
+ ] }),
1571
+ /* @__PURE__ */ e.jsxs(je, { className: "flex w-full max-w-[350px] flex-col gap-2", children: [
1572
+ /* @__PURE__ */ e.jsx(ge, { asChild: !0, children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1573
+ /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: s("editor.inputNodeForm.advancedConfiguration") }),
1574
+ /* @__PURE__ */ e.jsxs(w, { variant: "ghost", size: "icon", className: "size-8", children: [
1575
+ /* @__PURE__ */ e.jsx(de, {}),
1576
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: s("common.toggle") })
1577
+ ] })
1578
+ ] }) }),
1579
+ /* @__PURE__ */ e.jsx(Ce, { className: "flex flex-col gap-6", children: /* @__PURE__ */ e.jsx(d, { name: "defaultValue", children: (a) => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1580
+ /* @__PURE__ */ e.jsxs(N, { children: [
1581
+ /* @__PURE__ */ e.jsx(C, { htmlFor: a.name, children: s("editor.inputNodeForm.defaultValueType") }),
1582
+ /* @__PURE__ */ e.jsxs(
1583
+ $,
1584
+ {
1585
+ value: a.state.value?.type || "none",
1586
+ onValueChange: (o) => {
1587
+ a.handleChange(o === "none" ? null : { type: o });
1588
+ },
1589
+ children: [
1590
+ /* @__PURE__ */ e.jsx(A, { id: a.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectType") }) }),
1591
+ /* @__PURE__ */ e.jsxs(G, { children: [
1592
+ /* @__PURE__ */ e.jsx(f, { value: "none", children: s("editor.inputNodeForm.defaultValueTypeNone") }),
1593
+ /* @__PURE__ */ e.jsx(f, { value: "static", children: s("editor.inputNodeForm.defaultValueTypeStatic") }),
1594
+ /* @__PURE__ */ e.jsx(f, { value: "reference", children: s("editor.inputNodeForm.defaultValueTypeReference") })
1595
+ ] })
1596
+ ]
1597
+ }
1598
+ )
1599
+ ] }),
1600
+ a.state.value?.type === "static" && /* @__PURE__ */ e.jsx(d, { name: "defaultValue.staticValue", children: (o) => {
1601
+ const u = n?.data?.type;
1602
+ return (u === "select" || u === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ e.jsxs(N, { children: [
1603
+ /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.defaultValuesCommaSeparated") }),
1604
+ /* @__PURE__ */ e.jsx(
1605
+ y,
1606
+ {
1607
+ id: o.name,
1608
+ placeholder: s("editor.inputNodeForm.defaultValuesPlaceholder"),
1609
+ value: Array.isArray(o.state.value) ? o.state.value.join(", ") : "",
1610
+ onChange: ({ target: h }) => {
1611
+ const x = h.value.split(",").map((p) => p.trim()).filter(Boolean);
1612
+ o.handleChange(x.length > 0 ? x : null);
1613
+ }
1614
+ }
1615
+ )
1616
+ ] }) : u === "checkbox" ? /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1617
+ /* @__PURE__ */ e.jsx(
1618
+ te,
1619
+ {
1620
+ id: o.name,
1621
+ checked: !!o.state.value,
1622
+ onCheckedChange: (h) => o.handleChange(h)
1623
+ }
1624
+ ),
1625
+ /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.defaultChecked") })
1626
+ ] }) }) : /* @__PURE__ */ e.jsxs(N, { children: [
1627
+ /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.staticValue") }),
1628
+ /* @__PURE__ */ e.jsx(
1629
+ y,
1630
+ {
1631
+ id: o.name,
1632
+ placeholder: s("editor.inputNodeForm.staticValuePlaceholder"),
1633
+ value: typeof o.state.value == "string" ? o.state.value : "",
1634
+ onChange: ({ target: h }) => o.handleChange(h.value || "")
1635
+ }
1636
+ )
1637
+ ] });
1638
+ } }),
1639
+ a.state.value?.type === "reference" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1640
+ /* @__PURE__ */ e.jsx(d, { name: "defaultValue.referenceField", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1641
+ /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.referenceField") }),
1642
+ /* @__PURE__ */ e.jsxs(
1643
+ $,
1644
+ {
1645
+ value: o.state.value || "",
1646
+ onValueChange: (u) => {
1647
+ o.handleChange(u);
1648
+ },
1649
+ children: [
1650
+ /* @__PURE__ */ e.jsx(A, { id: o.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectReferenceField") }) }),
1651
+ /* @__PURE__ */ e.jsx(G, { children: i.length === 0 ? /* @__PURE__ */ e.jsx(f, { value: "none", disabled: !0, children: s("editor.inputNodeForm.noParentFieldsAvailable") }) : i.map((u) => /* @__PURE__ */ e.jsxs(f, { value: u.nodeId, children: [
1652
+ u.label,
1653
+ " (",
1654
+ u.type,
1655
+ ")"
1656
+ ] }, u.nodeId)) })
1657
+ ]
1658
+ }
1659
+ ),
1660
+ i.length === 0 && /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.addInputFieldsBeforeReference") })
1661
+ ] }) }),
1662
+ /* @__PURE__ */ e.jsx(d, { name: "defaultValue.transformFunction", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1663
+ /* @__PURE__ */ e.jsx(C, { htmlFor: o.name, children: s("editor.inputNodeForm.transformType") }),
1664
+ /* @__PURE__ */ e.jsxs(
1665
+ $,
1666
+ {
1667
+ value: o.state.value || "none",
1668
+ onValueChange: (u) => {
1669
+ const h = u === "none" ? null : u;
1670
+ if (o.handleChange(h), u === "toObject") {
1671
+ const x = a.state.value;
1672
+ a.handleChange({
1673
+ ...x,
1674
+ objectMapping: []
1675
+ });
1676
+ }
1677
+ },
1678
+ children: [
1679
+ /* @__PURE__ */ e.jsx(A, { id: o.name, children: /* @__PURE__ */ e.jsx(z, { placeholder: s("editor.inputNodeForm.selectTransformation") }) }),
1680
+ /* @__PURE__ */ e.jsxs(G, { children: [
1681
+ /* @__PURE__ */ e.jsx(f, { value: "none", children: s("editor.inputNodeForm.transformNone") }),
1682
+ /* @__PURE__ */ e.jsx(f, { value: "toString", children: s("editor.inputNodeForm.transformString") }),
1683
+ /* @__PURE__ */ e.jsx(f, { value: "toNumber", children: s("editor.inputNodeForm.transformNumber") }),
1684
+ /* @__PURE__ */ e.jsx(f, { value: "toBoolean", children: s("editor.inputNodeForm.transformBoolean") }),
1685
+ /* @__PURE__ */ e.jsx(f, { value: "toArray", children: s("editor.inputNodeForm.transformArray") }),
1686
+ /* @__PURE__ */ e.jsx(f, { value: "toObject", children: s("editor.inputNodeForm.transformMapToObject") })
1687
+ ] })
1688
+ ]
1689
+ }
1690
+ ),
1691
+ /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.transformDesc") })
1692
+ ] }) }),
1693
+ a.state.value?.transformFunction === "toObject" && /* @__PURE__ */ e.jsx(d, { name: "defaultValue.objectMapping", mode: "array", children: (o) => /* @__PURE__ */ e.jsxs(N, { children: [
1694
+ /* @__PURE__ */ e.jsx(C, { children: s("editor.inputNodeForm.objectMapping") }),
1695
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1696
+ o.state.value?.map((u, h) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1697
+ /* @__PURE__ */ e.jsx(d, { name: `defaultValue.objectMapping[${h}].sourceKey`, children: (x) => /* @__PURE__ */ e.jsx(
1698
+ y,
1699
+ {
1700
+ placeholder: s("editor.inputNodeForm.sourceKey"),
1701
+ value: x.state.value || "",
1702
+ onChange: ({ target: p }) => x.handleChange(p.value)
1703
+ }
1704
+ ) }),
1705
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: "→" }),
1706
+ /* @__PURE__ */ e.jsx(d, { name: `defaultValue.objectMapping[${h}].targetKey`, children: (x) => /* @__PURE__ */ e.jsx(
1707
+ y,
1708
+ {
1709
+ placeholder: s("editor.inputNodeForm.targetKey"),
1710
+ value: x.state.value || "",
1711
+ onChange: ({ target: p }) => x.handleChange(p.value)
1712
+ }
1713
+ ) }),
1714
+ /* @__PURE__ */ e.jsx(
1715
+ w,
1716
+ {
1717
+ type: "button",
1718
+ variant: "ghost",
1719
+ size: "icon",
1720
+ onClick: () => {
1721
+ o.removeValue(h), c().then();
1722
+ },
1723
+ children: /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4" })
1724
+ }
1725
+ )
1726
+ ] }, `mapping-${h}`)),
1727
+ /* @__PURE__ */ e.jsxs(
1728
+ w,
1729
+ {
1730
+ type: "button",
1731
+ variant: "outline",
1732
+ size: "sm",
1733
+ className: "w-full",
1734
+ onClick: () => {
1735
+ o.pushValue({ sourceKey: "", targetKey: "" }), c().then();
1736
+ },
1737
+ children: [
1738
+ /* @__PURE__ */ e.jsx(xe, { className: "mr-2 h-4 w-4" }),
1739
+ s("editor.inputNodeForm.addMapping")
1740
+ ]
1741
+ }
1742
+ )
1743
+ ] }),
1744
+ /* @__PURE__ */ e.jsx(O, { children: s("editor.inputNodeForm.objectMappingDesc") })
1745
+ ] }) })
1746
+ ] })
1747
+ ] }) }) })
1748
+ ] })
1749
+ ] })
1750
+ }
1751
+ );
1752
+ }, Oe = {
1753
+ divider: "divider",
1754
+ title: "title"
1755
+ }, ca = () => {
1756
+ const [t, r] = _("en"), { selectedNode: n } = W(), { updateSelectedNodeData: l } = ce(), { Field: m } = ie({
1757
+ defaultValues: {
1758
+ label: n?.data?.label || { en: "" },
1759
+ type: n?.data?.type
1760
+ },
1761
+ listeners: {
1762
+ onChange: ({ formApi: i }) => {
1763
+ i.handleSubmit().then();
1764
+ },
1765
+ onChangeDebounceMs: 150
1766
+ },
1767
+ onSubmit: ({ value: i }) => {
1768
+ l(i);
1769
+ }
1770
+ });
1771
+ return /* @__PURE__ */ e.jsx(
1772
+ "form",
1773
+ {
1774
+ onSubmit: (i) => {
1775
+ i.preventDefault(), i.stopPropagation();
1776
+ },
1777
+ children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-6", children: [
1778
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
1779
+ /* @__PURE__ */ e.jsx(
1780
+ m,
1781
+ {
1782
+ name: "label",
1783
+ children: (i) => /* @__PURE__ */ e.jsxs(N, { className: "flex-1", children: [
1784
+ /* @__PURE__ */ e.jsx(C, { htmlFor: i.name, children: "Label" }),
1785
+ /* @__PURE__ */ e.jsx(
1786
+ y,
1787
+ {
1788
+ id: i.name,
1789
+ name: i.name,
1790
+ value: i.state.value?.[t] || "",
1791
+ onBlur: i.handleBlur,
1792
+ onChange: ({ target: s }) => {
1793
+ i.handleChange({
1794
+ ...i.state.value,
1795
+ [t]: s.value
1796
+ });
1797
+ }
1798
+ }
1799
+ )
1800
+ ] })
1801
+ }
1802
+ ),
1803
+ /* @__PURE__ */ e.jsx(Y, { value: t, onValueChange: r })
1804
+ ] }),
1805
+ /* @__PURE__ */ e.jsx(
1806
+ m,
1807
+ {
1808
+ name: "type",
1809
+ children: (i) => /* @__PURE__ */ e.jsxs(q, { children: [
1810
+ /* @__PURE__ */ e.jsx(Te, { children: "Type" }),
1811
+ /* @__PURE__ */ e.jsxs($, { value: i.state.value, onValueChange: (s) => i.handleChange(s), children: [
1812
+ /* @__PURE__ */ e.jsx(A, { className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: "" }) }),
1813
+ /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsxs(q, { children: [
1814
+ /* @__PURE__ */ e.jsx(f, { value: Oe.title, children: "Title" }),
1815
+ /* @__PURE__ */ e.jsx(f, { value: Oe.divider, children: "Divider" })
1816
+ ] }) })
1817
+ ] })
1818
+ ] })
1819
+ }
1820
+ )
1821
+ ] })
1822
+ }
1823
+ );
1824
+ }, da = () => {
1825
+ const [t, r] = _(""), [n, l] = _(!1), { selectedNode: m, groupNodes: i } = W(), { setNodes: s } = me(), c = m?.parentId || "none", d = ve(m), a = B();
1826
+ if (d)
1827
+ return null;
1828
+ const o = (h) => {
1829
+ m && s((x) => h === "none" ? x.map((v) => {
1830
+ if (v.id === m.id) {
1831
+ const { parentId: M, extent: F, ...S } = v;
1832
+ return S;
1833
+ }
1834
+ return v;
1835
+ }) : x.find((v) => v.id === h) ? x.map((v) => v.id === m.id ? {
1836
+ ...v,
1837
+ extent: "parent",
1838
+ parentId: h,
1839
+ position: {
1840
+ x: 50,
1841
+ y: 80
1842
+ }
1843
+ } : v) : x);
1844
+ }, u = () => {
1845
+ if (!(t.trim() && m))
1846
+ return;
1847
+ if (i.find((p) => {
1848
+ const v = p.data?.label?.en || p.data?.label;
1849
+ return String(v).toLowerCase() === t.trim().toLowerCase();
1850
+ })) {
1851
+ R.error("This group already exists", {
1852
+ description: "Use the selector to add the node to an existing group."
1853
+ });
1854
+ return;
1855
+ }
1856
+ const x = le();
1857
+ s((p) => {
1858
+ const v = {
1859
+ data: {
1860
+ label: {
1861
+ en: t.trim()
1862
+ }
1863
+ },
1864
+ id: x,
1865
+ position: {
1866
+ x: m.position.x - 300,
1867
+ y: m.position.y
1868
+ },
1869
+ style: {
1870
+ height: 400,
1871
+ width: 600
1872
+ },
1873
+ type: "group"
1874
+ }, M = p.map((F) => F.id === m.id ? {
1875
+ ...F,
1876
+ extent: "parent",
1877
+ parentId: x,
1878
+ position: {
1879
+ x: 175,
1880
+ y: 30
1881
+ }
1882
+ } : F);
1883
+ return [v, ...M];
1884
+ }), r(""), l(!1), R.success("Group created", {
1885
+ description: `The group "${t.trim()}" has been created successfully.`
1886
+ });
1887
+ };
1888
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1889
+ /* @__PURE__ */ e.jsx(C, { children: a("editor.selectNodeGroup.group") }),
1890
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
1891
+ /* @__PURE__ */ e.jsxs($, { value: c, onValueChange: o, children: [
1892
+ /* @__PURE__ */ e.jsx(A, { className: "flex-1", children: /* @__PURE__ */ e.jsx(z, { placeholder: a("editor.selectNodeGroup.noGroup") }) }),
1893
+ /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsxs(q, { children: [
1894
+ /* @__PURE__ */ e.jsx(f, { value: "none", children: a("editor.selectNodeGroup.noGroup") }),
1895
+ i.map((h) => /* @__PURE__ */ e.jsx(f, { value: h.id, children: h.data.label?.en ? String(h.data.label?.en) : h.id }, h.id))
1896
+ ] }) })
1897
+ ] }),
1898
+ /* @__PURE__ */ e.jsxs(Pe, { open: n, onOpenChange: l, children: [
1899
+ /* @__PURE__ */ e.jsx(ke, { asChild: !0, children: /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "icon", title: "Create a new group", children: /* @__PURE__ */ e.jsx(Vt, { className: "h-4 w-4" }) }) }),
1900
+ /* @__PURE__ */ e.jsx(Ee, { className: "w-80", align: "end", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1901
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1902
+ /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: a("editor.selectNodeGroup.newGroup") }),
1903
+ /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground text-sm", children: a("editor.selectNodeGroup.newGroupDescription") })
1904
+ ] }),
1905
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
1906
+ /* @__PURE__ */ e.jsx(C, { htmlFor: "group-label", children: a("editor.selectNodeGroup.groupName") }),
1907
+ /* @__PURE__ */ e.jsx(
1908
+ y,
1909
+ {
1910
+ value: t,
1911
+ onChange: (h) => r(h.target.value),
1912
+ placeholder: "Ex: Step 1 - Personal info",
1913
+ onKeyDown: (h) => {
1914
+ h.key === "Enter" && (h.preventDefault(), u());
1915
+ }
1916
+ }
1917
+ )
1918
+ ] }),
1919
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2", children: [
1920
+ /* @__PURE__ */ e.jsx(w, { variant: "outline", size: "sm", onClick: () => l(!1), children: "Cancel" }),
1921
+ /* @__PURE__ */ e.jsx(w, { size: "sm", onClick: u, disabled: !t.trim(), children: "Create" })
1922
+ ] })
1923
+ ] }) })
1924
+ ] })
1925
+ ] })
1926
+ ] });
1927
+ }, ha = () => {
1928
+ const { selectedNode: t } = W(), { updateSelectedNodeType: r } = ce(), n = t?.type || "", l = ve(t), m = B();
1929
+ return /* @__PURE__ */ e.jsxs(q, { children: [
1930
+ /* @__PURE__ */ e.jsx(Te, { children: m("editor.selectNodeType.nodeType") }),
1931
+ /* @__PURE__ */ e.jsxs($, { value: n, onValueChange: (i) => r(i), disabled: l, children: [
1932
+ /* @__PURE__ */ e.jsx(A, { className: "w-full", children: /* @__PURE__ */ e.jsx(z, { placeholder: m("editor.selectNodeType.nodeType") }) }),
1933
+ /* @__PURE__ */ e.jsx(G, { children: /* @__PURE__ */ e.jsx(q, { children: Object.keys(Re).filter((i) => l ? i === "group" : i !== "group").map((i) => /* @__PURE__ */ e.jsx(f, { value: i, children: i.charAt(0).toUpperCase() + i.slice(1) }, i)) }) })
1934
+ ] })
1935
+ ] });
1936
+ };
1937
+ function ua({ ...t }) {
1938
+ return /* @__PURE__ */ e.jsx(J.Root, { "data-slot": "sheet", ...t });
1939
+ }
1940
+ function ma({ ...t }) {
1941
+ return /* @__PURE__ */ e.jsx(J.Portal, { "data-slot": "sheet-portal", ...t });
1942
+ }
1943
+ function xa({ className: t, ...r }) {
1944
+ return /* @__PURE__ */ e.jsx(
1945
+ J.Overlay,
1946
+ {
1947
+ "data-slot": "sheet-overlay",
1948
+ className: D(
1949
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
1950
+ t
1951
+ ),
1952
+ ...r
1953
+ }
1954
+ );
1955
+ }
1956
+ function pa({
1957
+ className: t,
1958
+ children: r,
1959
+ side: n = "right",
1960
+ ...l
1961
+ }) {
1962
+ return /* @__PURE__ */ e.jsxs(ma, { children: [
1963
+ /* @__PURE__ */ e.jsx(xa, {}),
1964
+ /* @__PURE__ */ e.jsxs(
1965
+ J.Content,
1966
+ {
1967
+ "data-slot": "sheet-content",
1968
+ className: D(
1969
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
1970
+ n === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
1971
+ n === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
1972
+ n === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
1973
+ n === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
1974
+ t
1975
+ ),
1976
+ ...l,
1977
+ children: [
1978
+ r,
1979
+ /* @__PURE__ */ e.jsxs(J.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
1980
+ /* @__PURE__ */ e.jsx(Pt, { className: "size-4" }),
1981
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Close" })
1982
+ ] })
1983
+ ]
1984
+ }
1985
+ )
1986
+ ] });
1987
+ }
1988
+ function ja({ className: t, ...r }) {
1989
+ return /* @__PURE__ */ e.jsx("div", { "data-slot": "sheet-header", className: D("flex flex-col gap-1.5 p-4", t), ...r });
1990
+ }
1991
+ function ga({ className: t, ...r }) {
1992
+ return /* @__PURE__ */ e.jsx(J.Title, { "data-slot": "sheet-title", className: D("text-foreground font-semibold", t), ...r });
1993
+ }
1994
+ function Ca({ className: t, ...r }) {
1995
+ return /* @__PURE__ */ e.jsx(J.Description, { "data-slot": "sheet-description", className: D("text-muted-foreground text-sm", t), ...r });
1996
+ }
1997
+ const va = () => {
1998
+ const { selectedNode: t, hasSelectedNodes: r } = W(), { clearSelection: n } = ce(), m = B()(t?.data?.label);
1999
+ return /* @__PURE__ */ e.jsx(ua, { open: r, onOpenChange: n, children: /* @__PURE__ */ e.jsxs(pa, { children: [
2000
+ /* @__PURE__ */ e.jsxs(ja, { children: [
2001
+ /* @__PURE__ */ e.jsxs(ga, { children: [
2002
+ "Edit node ",
2003
+ /* @__PURE__ */ e.jsx("span", { className: "font-light text-muted-foreground text-xs", children: t?.id })
2004
+ ] }),
2005
+ /* @__PURE__ */ e.jsx(Ca, { children: m || " " })
2006
+ ] }),
2007
+ /* @__PURE__ */ e.jsx(_e, { className: "flex min-h-0 flex-1 flex-col px-4 py-6", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
2008
+ /* @__PURE__ */ e.jsx(ha, {}),
2009
+ /* @__PURE__ */ e.jsx(da, {}),
2010
+ /* @__PURE__ */ e.jsx(tt, {}),
2011
+ he(t) && /* @__PURE__ */ e.jsx(ia, {}),
2012
+ Qe(t) && /* @__PURE__ */ e.jsx(ca, {}),
2013
+ et(t) && /* @__PURE__ */ e.jsx(Qt, {}),
2014
+ ve(t) && /* @__PURE__ */ e.jsx(ea, {})
2015
+ ] }) })
2016
+ ] }) });
2017
+ }, fa = () => {
2018
+ const { setNodes: t, setEdges: r, screenToFlowPosition: n, getNode: l, getEdges: m } = me(), i = Z(
2019
+ (a) => {
2020
+ r((o) => {
2021
+ const u = it(a, o), h = a.source, x = l(h);
2022
+ return u.filter((v) => v.source === h).length > 1 && x && he(x) ? u.map((v) => v.source === h ? {
2023
+ ...v,
2024
+ data: {
2025
+ ...v.data,
2026
+ conditions: v.data?.conditions || [{ field: h, operator: "===", value: "" }]
2027
+ },
2028
+ type: "conditional"
2029
+ } : v) : u;
2030
+ });
2031
+ },
2032
+ [r, l]
2033
+ ), s = Z(
2034
+ (a, o) => {
2035
+ if (!o.isValid) {
2036
+ const { clientX: u, clientY: h } = "changedTouches" in a ? a.changedTouches[0] : a, x = o.fromNode;
2037
+ if (!x)
2038
+ return;
2039
+ const p = x.id, M = m().filter((V) => V.source === p), F = x && he(x);
2040
+ if (M.length > 0 && !F)
2041
+ return;
2042
+ const S = le(), g = le(), E = {
2043
+ ...Ze,
2044
+ id: S,
2045
+ origin: [0.5, 0],
2046
+ position: n({
2047
+ x: u,
2048
+ y: h
2049
+ })
2050
+ };
2051
+ x?.parentId && (E.parentId = x.parentId, E.extent = "parent"), t((V) => V.concat(E)), r((V) => {
2052
+ const T = V.filter((b) => b.source === p).length > 0, X = {
2053
+ data: T && F ? {
2054
+ conditions: [{ field: p, operator: "===", value: "" }]
2055
+ } : void 0,
2056
+ id: g,
2057
+ source: p,
2058
+ target: S,
2059
+ type: T && F ? "conditional" : "default"
2060
+ };
2061
+ return T && F ? V.map((b) => b.source === p ? {
2062
+ ...b,
2063
+ data: {
2064
+ ...b.data,
2065
+ conditions: b.data?.conditions || [{ field: p, operator: "===", value: "" }]
2066
+ },
2067
+ type: "conditional"
2068
+ } : b).concat(X) : V.concat(X);
2069
+ });
2070
+ }
2071
+ },
2072
+ [n, r, t, m]
2073
+ ), c = Z(
2074
+ (a) => {
2075
+ r((o) => {
2076
+ const u = o.filter((p) => !a.find((v) => v.id === p.id)), h = new Set(a.map((p) => p.source)), x = /* @__PURE__ */ new Map();
2077
+ return u.forEach((p) => {
2078
+ x.set(p.source, (x.get(p.source) ?? 0) + 1);
2079
+ }), u.map((p) => {
2080
+ if (h.has(p.source) && (x.get(p.source) ?? 0) === 1) {
2081
+ const { conditions: M, isFallback: F, ...S } = p.data ?? {}, g = S && Object.keys(S).length > 0 ? S : void 0;
2082
+ return { ...p, data: g, type: "default" };
2083
+ }
2084
+ return p;
2085
+ });
2086
+ });
2087
+ },
2088
+ [r]
2089
+ );
2090
+ return {
2091
+ isValidConnection: Z(
2092
+ (a) => {
2093
+ if (a.source === a.target)
2094
+ return !1;
2095
+ const o = l(a.source);
2096
+ return o ? !(m().filter((x) => x.source === a.source).length > 0 && !he(o)) : !1;
2097
+ },
2098
+ [l, m]
2099
+ ),
2100
+ onConnect: i,
2101
+ onConnectEnd: s,
2102
+ onEdgesDelete: c
2103
+ };
2104
+ }, ba = ({ ...t }) => {
2105
+ const { theme: r = "system" } = Lt();
2106
+ return /* @__PURE__ */ e.jsx(
2107
+ It,
2108
+ {
2109
+ theme: r,
2110
+ className: "toaster group",
2111
+ style: {
2112
+ "--normal-bg": "var(--popover)",
2113
+ "--normal-border": "var(--border)",
2114
+ "--normal-text": "var(--popover-foreground)"
2115
+ },
2116
+ ...t
2117
+ }
2118
+ );
2119
+ }, Na = ({ edges: t, nodes: r, flow: n, onExportJson: l, onSave: m, theme: i }) => {
2120
+ const { onConnect: s, onConnectEnd: c, onEdgesDelete: d, isValidConnection: a } = fa();
2121
+ return /* @__PURE__ */ e.jsxs(
2122
+ dt,
2123
+ {
2124
+ fitView: !0,
2125
+ colorMode: i,
2126
+ selectNodesOnDrag: !1,
2127
+ nodeTypes: Re,
2128
+ edgeTypes: Gt,
2129
+ defaultEdges: t || n?.edges || [],
2130
+ defaultNodes: r || n?.nodes || [],
2131
+ onConnect: s,
2132
+ onConnectEnd: c,
2133
+ onEdgesDelete: d,
2134
+ isValidConnection: a,
2135
+ children: [
2136
+ /* @__PURE__ */ e.jsx(ht, { gap: 10, variant: ut.Dots }),
2137
+ /* @__PURE__ */ e.jsx(Jt, { onExportJson: l, onSave: m }),
2138
+ /* @__PURE__ */ e.jsx(Ot, { theme: i }),
2139
+ /* @__PURE__ */ e.jsx(mt, {}),
2140
+ /* @__PURE__ */ e.jsx(xt, {}),
2141
+ /* @__PURE__ */ e.jsx(va, {})
2142
+ ]
2143
+ }
2144
+ );
2145
+ }, Da = ({ edges: t, nodes: r, flow: n, onExportJson: l, onSave: m, theme: i = "dark", language: s = "en" }) => /* @__PURE__ */ e.jsx(at, { defaultTheme: i, storageKey: "treege-editor-theme", theme: i, children: /* @__PURE__ */ e.jsxs($t, { value: { flowId: n?.id, language: s }, children: [
2146
+ /* @__PURE__ */ e.jsx(ba, { position: "bottom-center" }),
2147
+ /* @__PURE__ */ e.jsx(ct, { children: /* @__PURE__ */ e.jsx(Na, { edges: t, nodes: r, onExportJson: l, onSave: m, flow: n, theme: i }) })
2148
+ ] }) });
2149
+ export {
2150
+ Da as T
2151
+ };