treege 3.0.0-beta.3 → 3.0.0-beta.31

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 (133) hide show
  1. package/LICENSE +18 -12
  2. package/README.md +306 -52
  3. package/dist/ThemeContext-Cw-S1U8B.js +990 -0
  4. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  5. package/dist/editor/constants/defaultNode.d.ts +1 -1
  6. package/dist/editor/constants/edgeTypes.d.ts +3 -2
  7. package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
  8. package/dist/editor/constants/nodeSpacing.d.ts +20 -0
  9. package/dist/editor/constants/nodeTypes.d.ts +5 -5
  10. package/dist/editor/context/TreegeEditorContext.d.ts +24 -1
  11. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  12. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  13. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  14. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  15. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  16. package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
  17. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  18. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
  19. package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
  20. package/dist/editor/features/TreegeEditor/nodes/components/InputTypeBadge.d.ts +7 -0
  21. package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
  22. package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
  23. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
  24. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
  25. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  26. package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
  27. package/dist/editor/hooks/useFlowActions.d.ts +3 -0
  28. package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
  29. package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
  30. package/dist/editor/types/ai.d.ts +65 -0
  31. package/dist/editor/types/editor.d.ts +9 -8
  32. package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
  33. package/dist/editor/utils/image.d.ts +7 -0
  34. package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
  35. package/dist/editor-Bs1sHj4p.js +3751 -0
  36. package/dist/editor.js +3 -7
  37. package/dist/main.js +5 -52
  38. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  39. package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
  40. package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
  41. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -7
  42. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
  43. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
  44. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
  45. package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
  46. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
  47. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
  48. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
  49. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
  50. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
  51. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
  52. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
  53. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
  54. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
  55. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
  56. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
  57. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
  58. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
  59. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
  60. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
  61. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
  62. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
  63. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +84 -24
  64. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  65. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  66. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  67. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  68. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  69. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  70. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  71. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  72. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  73. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  74. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  75. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  76. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  77. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  78. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  79. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  80. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  81. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  82. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  83. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  84. package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
  85. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  86. package/dist/renderer/hooks/useTranslate.d.ts +6 -4
  87. package/dist/renderer/index.d.ts +2 -0
  88. package/dist/renderer/index.native.d.ts +19 -0
  89. package/dist/renderer/types/renderer.d.ts +60 -6
  90. package/dist/renderer/utils/form.d.ts +22 -2
  91. package/dist/renderer/utils/http.d.ts +101 -0
  92. package/dist/renderer/utils/node.d.ts +9 -1
  93. package/dist/renderer/utils/sanitize.d.ts +85 -0
  94. package/dist/renderer/utils/sanitize.native.d.ts +69 -0
  95. package/dist/renderer/utils/submit.d.ts +47 -0
  96. package/dist/renderer-CsU2Y0iu.js +1204 -0
  97. package/dist/renderer-native.d.ts +2 -0
  98. package/dist/renderer-native.js +3496 -0
  99. package/dist/renderer.js +4 -45
  100. package/dist/separator-B9rc85M6.js +351 -0
  101. package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
  102. package/dist/shared/components/ui/badge.d.ts +2 -2
  103. package/dist/shared/components/ui/button.d.ts +2 -2
  104. package/dist/shared/components/ui/collapsible.d.ts +1 -1
  105. package/dist/shared/components/ui/command.d.ts +1 -1
  106. package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
  107. package/dist/shared/components/ui/form.d.ts +1 -1
  108. package/dist/shared/components/ui/popover.d.ts +4 -2
  109. package/dist/shared/components/ui/select.d.ts +3 -1
  110. package/dist/shared/components/ui/sheet.d.ts +1 -1
  111. package/dist/shared/components/ui/tooltip.d.ts +1 -1
  112. package/dist/shared/constants/colors.d.ts +45 -0
  113. package/dist/shared/constants/inputType.d.ts +1 -0
  114. package/dist/shared/context/ThemeContext.d.ts +2 -0
  115. package/dist/shared/context/ThemeContext.native.d.ts +22 -0
  116. package/dist/shared/hooks/useThemeColors.d.ts +37 -0
  117. package/dist/shared/locales/ar.json.d.ts +109 -10
  118. package/dist/shared/locales/de.json.d.ts +110 -11
  119. package/dist/shared/locales/en.json.d.ts +111 -12
  120. package/dist/shared/locales/es.json.d.ts +110 -11
  121. package/dist/shared/locales/fr.json.d.ts +110 -11
  122. package/dist/shared/locales/it.json.d.ts +110 -11
  123. package/dist/shared/locales/pt.json.d.ts +110 -11
  124. package/dist/shared/types/node.d.ts +64 -0
  125. package/dist/useRenderNode-IL6mmCOS.js +774 -0
  126. package/package.json +39 -12
  127. package/dist/ThemeContext-BIvs8Kw-.js +0 -758
  128. package/dist/TreegeEditor-BSPfQQk3.js +0 -2151
  129. package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
  130. package/dist/_name_.css +0 -1
  131. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
  132. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
  133. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
@@ -0,0 +1,3751 @@
1
+ import { a as e, c as t, d as n, f as r, i, l as a, r as o, t as s, u as c } from "./ThemeContext-Cw-S1U8B.js";
2
+ import { C as l, D as u, E as d, F as f, M as p, N as m, O as h, P as g, S as _, T as v, _ as y, a as b, b as x, c as S, d as C, f as ee, g as te, h as ne, i as re, j as w, k as T, l as E, m as D, n as O, o as ie, p as ae, r as k, s as oe, t as se, u as ce, v as A, w as le, x as ue, y as j } from "./separator-B9rc85M6.js";
3
+ import { Background as de, BackgroundVariant as fe, BaseEdge as pe, Controls as me, EdgeLabelRenderer as he, Handle as ge, MiniMap as _e, NodeResizer as ve, Panel as ye, Position as be, ReactFlow as xe, ReactFlowProvider as Se, addEdge as Ce, getBezierPath as we, useEdges as Te, useNodes as Ee, useReactFlow as M } from "@xyflow/react";
4
+ import { createContext as De, memo as Oe, useCallback as N, useContext as ke, useEffect as Ae, useId as je, useMemo as P, useRef as Me, useState as F } from "react";
5
+ import { useForm as I } from "@tanstack/react-form";
6
+ import { AlignLeft as Ne, ArrowRightFromLine as Pe, Boxes as Fe, Calendar as Ie, CalendarRange as Le, CaseSensitive as Re, Check as ze, CheckSquare as Be, ChevronDown as Ve, ChevronsUpDown as L, CircleDot as He, Clock as Ue, Cloud as We, Copy as Ge, Download as Ke, EllipsisVertical as qe, EyeOff as Je, Hash as Ye, Heading as Xe, ImagePlus as Ze, KeyRound as Qe, Link2 as $e, ListFilter as et, Loader2 as tt, MapPin as nt, Minus as rt, MoreVertical as it, Paperclip as at, Plus as R, PlusCircle as ot, RectangleEllipsis as st, Save as ct, Search as lt, Send as ut, Settings as dt, ToggleLeft as ft, Trash2 as pt, Upload as mt, Variable as ht, WandSparkles as gt, Waypoints as _t, X as z, XIcon as vt } from "lucide-react";
7
+ import { Slot as yt } from "@radix-ui/react-slot";
8
+ import { cva as bt } from "class-variance-authority";
9
+ import * as xt from "@radix-ui/react-scroll-area";
10
+ import * as B from "@radix-ui/react-alert-dialog";
11
+ import * as V from "@radix-ui/react-dropdown-menu";
12
+ import { Toaster as St, toast as H } from "sonner";
13
+ import * as U from "@radix-ui/react-dialog";
14
+ import * as Ct from "@radix-ui/react-collapsible";
15
+ import { useTheme as wt } from "next-themes";
16
+ //#region src/editor/assets/img/treege-black.svg
17
+ var Tt = "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", Et = "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", W = r(), Dt = ({ theme: e = "dark" }) => /* @__PURE__ */ (0, W.jsx)("div", {
18
+ className: "absolute top-5 left-5 z-50 select-none",
19
+ children: /* @__PURE__ */ (0, W.jsx)("img", {
20
+ src: e === "dark" ? Et : Tt,
21
+ alt: "Treege",
22
+ className: "relative h-14 w-auto drop-shadow-[0_0px_35px] drop-shadow-blue-600"
23
+ })
24
+ }), Ot = (e) => {
25
+ let t = Ee(), n = Te();
26
+ return P(() => {
27
+ if (!e) return [];
28
+ let r = (e, t = /* @__PURE__ */ new Set()) => {
29
+ if (t.has(e)) return [];
30
+ let i = new Set(t).add(e);
31
+ return n.filter((t) => t.target === e).flatMap((e) => [e.source, ...r(e.source, i)]);
32
+ }, i = r(e);
33
+ return t.filter((e) => i.includes(e.id) && c(e)).map((e) => {
34
+ let t = e.data;
35
+ return {
36
+ label: (typeof t.label == "object" ? t.label.en : t.label) || t.name || e.id,
37
+ name: t.name,
38
+ nodeId: e.id,
39
+ type: t.type || "text"
40
+ };
41
+ });
42
+ }, [
43
+ e,
44
+ t,
45
+ n
46
+ ]);
47
+ }, kt = De(null), At = ({ children: e, value: t }) => {
48
+ let [n, r] = F(t?.flowId), [i, a] = F(!1), o = P(() => ({
49
+ ...t,
50
+ ...t?.aiConfig && { aiConfig: {
51
+ ...t.aiConfig,
52
+ provider: t?.aiConfig.provider ?? "gemini"
53
+ } },
54
+ flowId: n,
55
+ isNodeSheetOpen: i,
56
+ setFlowId: r,
57
+ setIsNodeSheetOpen: a
58
+ }), [
59
+ n,
60
+ t,
61
+ i
62
+ ]);
63
+ return /* @__PURE__ */ (0, W.jsx)(kt.Provider, {
64
+ value: o,
65
+ children: e
66
+ });
67
+ }, jt = () => ke(kt) ?? {
68
+ flowId: void 0,
69
+ isNodeSheetOpen: !1,
70
+ language: "en",
71
+ setFlowId: () => {},
72
+ setIsNodeSheetOpen: () => {}
73
+ }, G = (t) => {
74
+ let n = jt();
75
+ return e(t ?? n.language);
76
+ };
77
+ //#endregion
78
+ //#region src/shared/components/ui/scroll-area.tsx
79
+ function Mt({ className: e, children: t, ...n }) {
80
+ return /* @__PURE__ */ (0, W.jsxs)(xt.Root, {
81
+ "data-slot": "scroll-area",
82
+ className: f("relative", e),
83
+ ...n,
84
+ children: [
85
+ /* @__PURE__ */ (0, W.jsx)(xt.Viewport, {
86
+ "data-slot": "scroll-area-viewport",
87
+ className: "size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50",
88
+ children: t
89
+ }),
90
+ /* @__PURE__ */ (0, W.jsx)(Nt, {}),
91
+ /* @__PURE__ */ (0, W.jsx)(xt.Corner, {})
92
+ ]
93
+ });
94
+ }
95
+ function Nt({ className: e, orientation: t = "vertical", ...n }) {
96
+ return /* @__PURE__ */ (0, W.jsx)(xt.ScrollAreaScrollbar, {
97
+ "data-slot": "scroll-area-scrollbar",
98
+ orientation: t,
99
+ className: f("flex touch-none select-none p-px transition-colors", t === "vertical" && "h-full w-2.5 border-l border-l-transparent", t === "horizontal" && "h-2.5 flex-col border-t border-t-transparent", e),
100
+ ...n,
101
+ children: /* @__PURE__ */ (0, W.jsx)(xt.ScrollAreaThumb, {
102
+ "data-slot": "scroll-area-thumb",
103
+ className: "relative flex-1 rounded-full bg-border"
104
+ })
105
+ });
106
+ }
107
+ //#endregion
108
+ //#region src/editor/constants/edgeTypes.ts
109
+ var Pt = {
110
+ conditional: Oe(({ id: e, target: t, sourceX: n, sourceY: r, targetX: a, targetY: o, sourcePosition: s, targetPosition: c, markerEnd: f, style: g, data: b }) => {
111
+ let [S, C, ee] = we({
112
+ sourcePosition: s,
113
+ sourceX: n,
114
+ sourceY: r,
115
+ targetPosition: c,
116
+ targetX: a,
117
+ targetY: o
118
+ }), [te, ne] = F(!1), { updateEdgeData: re } = M(), E = Ot(t), D = b?.conditions && b.conditions.length > 0, O = G(), { handleSubmit: ie, reset: ae, Field: k } = I({
119
+ defaultValues: {
120
+ conditions: b?.conditions || [{
121
+ field: E[0]?.nodeId ?? "",
122
+ operator: "===",
123
+ value: ""
124
+ }],
125
+ isFallback: !!b?.isFallback,
126
+ label: b?.label || ""
127
+ },
128
+ listeners: {
129
+ onChange: ({ formApi: e }) => {
130
+ e.handleSubmit().then();
131
+ },
132
+ onChangeDebounceMs: 150
133
+ },
134
+ onSubmit: ({ value: t }) => {
135
+ re(e, t);
136
+ }
137
+ }), oe = (e) => {
138
+ e.stopPropagation();
139
+ }, se = () => {
140
+ ae({
141
+ conditions: [],
142
+ isFallback: !1,
143
+ label: ""
144
+ }), re(e, {
145
+ conditions: void 0,
146
+ isFallback: void 0,
147
+ label: void 0
148
+ });
149
+ }, ce = () => {
150
+ if (b?.isFallback) return b.label || O("editor.conditionalEdge.fallback");
151
+ if (!D) return null;
152
+ if (b.label) return b.label;
153
+ let e = b.conditions;
154
+ if (e.length === 1) return `${E.find((t) => t.nodeId === e[0].field)?.label || e[0].field} ${e[0].operator} ${e[0].value}`;
155
+ let t = e.filter((e) => e.logicalOperator === i.AND).length, n = e.filter((e) => e.logicalOperator === i.OR).length;
156
+ return t > 0 && n === 0 ? `${e.length} ${O("editor.conditionalEdge.conditionsAnd")}` : n > 0 && t === 0 ? `${e.length} ${O("editor.conditionalEdge.conditionsOr")}` : `${e.length} ${O("editor.conditionalEdge.conditionsMixed")}`;
157
+ }, ue = () => b?.isFallback ? "var(--color-chart-4)" : D ? "var(--color-chart-2)" : "var(--color-chart-3)";
158
+ return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(pe, {
159
+ path: S,
160
+ markerEnd: f,
161
+ style: {
162
+ ...g,
163
+ stroke: ue(),
164
+ strokeDasharray: b?.isFallback ? "5,5" : void 0,
165
+ strokeWidth: D || b?.isFallback ? 2 : g?.strokeWidth
166
+ }
167
+ }), /* @__PURE__ */ (0, W.jsx)(he, { children: /* @__PURE__ */ (0, W.jsx)("div", {
168
+ className: "nodrag nopan absolute",
169
+ style: {
170
+ pointerEvents: "all",
171
+ transform: `translate(-50%, -50%) translate(${C}px,${ee}px)`
172
+ },
173
+ children: /* @__PURE__ */ (0, W.jsxs)(le, {
174
+ open: te,
175
+ onOpenChange: ne,
176
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
177
+ asChild: !0,
178
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
179
+ variant: D || b?.isFallback ? "default" : "secondary",
180
+ className: "h-8 px-2 text-xs",
181
+ onClick: oe,
182
+ children: [/* @__PURE__ */ (0, W.jsx)(_t, { className: "mr-1 h-3 w-3" }), D || b?.isFallback ? ce() : O("editor.conditionalEdge.condition")]
183
+ })
184
+ }), /* @__PURE__ */ (0, W.jsx)(v, {
185
+ className: "w-96 p-1",
186
+ align: "center",
187
+ onClick: (e) => e.stopPropagation(),
188
+ children: /* @__PURE__ */ (0, W.jsx)(Mt, {
189
+ className: "flex max-h-150 flex-col p-3",
190
+ children: /* @__PURE__ */ (0, W.jsx)("form", {
191
+ onSubmit: (e) => {
192
+ e.preventDefault(), e.stopPropagation();
193
+ },
194
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
195
+ className: "grid gap-5",
196
+ children: [
197
+ /* @__PURE__ */ (0, W.jsxs)("div", {
198
+ className: "space-y-2",
199
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
200
+ className: "font-medium leading-none",
201
+ children: O("editor.conditionalEdge.displayConditions")
202
+ }), /* @__PURE__ */ (0, W.jsx)("p", {
203
+ className: "text-muted-foreground text-sm",
204
+ children: O("editor.conditionalEdge.displayConditionsDesc")
205
+ })]
206
+ }),
207
+ /* @__PURE__ */ (0, W.jsxs)("div", {
208
+ className: "grid gap-4",
209
+ children: [
210
+ /* @__PURE__ */ (0, W.jsx)(k, {
211
+ name: "label",
212
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
213
+ /* @__PURE__ */ (0, W.jsx)(u, {
214
+ htmlFor: e.name,
215
+ children: O("editor.conditionalEdge.labelOptional")
216
+ }),
217
+ /* @__PURE__ */ (0, W.jsx)(h, {
218
+ id: e.name,
219
+ placeholder: O("editor.conditionalEdge.labelPlaceholder"),
220
+ value: e.state.value,
221
+ onChange: (t) => e.handleChange(t.target.value)
222
+ }),
223
+ /* @__PURE__ */ (0, W.jsx)(T, { children: O("editor.conditionalEdge.labelDesc") })
224
+ ] })
225
+ }),
226
+ /* @__PURE__ */ (0, W.jsx)(k, {
227
+ name: "isFallback",
228
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(w, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
229
+ className: "flex items-center gap-3 rounded-lg border bg-muted/20 p-3",
230
+ children: [/* @__PURE__ */ (0, W.jsx)(p, {
231
+ id: e.name,
232
+ checked: e.state.value,
233
+ onCheckedChange: (t) => e.handleChange(t)
234
+ }), /* @__PURE__ */ (0, W.jsxs)("div", {
235
+ className: "flex flex-col gap-1",
236
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
237
+ htmlFor: e.name,
238
+ className: "cursor-pointer font-medium",
239
+ children: O("editor.conditionalEdge.fallbackPath")
240
+ }), /* @__PURE__ */ (0, W.jsx)(T, {
241
+ className: "text-xs",
242
+ children: O("editor.conditionalEdge.fallbackPathDesc")
243
+ })]
244
+ })]
245
+ }) })
246
+ }),
247
+ /* @__PURE__ */ (0, W.jsx)(k, {
248
+ name: "conditions",
249
+ mode: "array",
250
+ children: (e) => {
251
+ let t = e.form.getFieldValue("isFallback");
252
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
253
+ className: "space-y-3",
254
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
255
+ className: t ? "text-muted-foreground" : "",
256
+ children: O("editor.conditionalEdge.conditions")
257
+ }), /* @__PURE__ */ (0, W.jsxs)("div", {
258
+ className: "space-y-2",
259
+ children: [e.state.value?.map((n, r) => /* @__PURE__ */ (0, W.jsxs)("div", {
260
+ className: "space-y-2",
261
+ children: [/* @__PURE__ */ (0, W.jsxs)("div", {
262
+ className: "space-y-2 rounded-lg border bg-muted/30 p-3",
263
+ children: [
264
+ /* @__PURE__ */ (0, W.jsx)(k, {
265
+ name: `conditions[${r}].field`,
266
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
267
+ htmlFor: `field-${r}`,
268
+ children: O("editor.conditionalEdge.field")
269
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
270
+ disabled: t,
271
+ value: e.state.value || "",
272
+ onValueChange: (t) => e.handleChange(t),
273
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
274
+ id: `field-${r}`,
275
+ className: "w-full",
276
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: O("editor.conditionalEdge.selectField") })
277
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: E.length === 0 ? /* @__PURE__ */ (0, W.jsx)(x, {
278
+ value: "none",
279
+ disabled: !0,
280
+ children: O("editor.conditionalEdge.noFieldsAvailable")
281
+ }) : E.map((e) => /* @__PURE__ */ (0, W.jsxs)(x, {
282
+ value: e.nodeId,
283
+ children: [
284
+ e.label,
285
+ " (",
286
+ e.type,
287
+ ")"
288
+ ]
289
+ }, e.nodeId)) })]
290
+ })] })
291
+ }),
292
+ /* @__PURE__ */ (0, W.jsxs)("div", {
293
+ className: "flex gap-2",
294
+ children: [/* @__PURE__ */ (0, W.jsx)(k, {
295
+ name: `conditions[${r}].operator`,
296
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
297
+ htmlFor: `operator-${r}`,
298
+ children: O("editor.conditionalEdge.operator")
299
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
300
+ disabled: t,
301
+ value: e.state.value || "===",
302
+ onValueChange: (t) => e.handleChange(t),
303
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
304
+ id: `operator-${r}`,
305
+ children: /* @__PURE__ */ (0, W.jsx)(l, {})
306
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [
307
+ /* @__PURE__ */ (0, W.jsx)(x, {
308
+ value: "===",
309
+ children: "="
310
+ }),
311
+ /* @__PURE__ */ (0, W.jsx)(x, {
312
+ value: "!==",
313
+ children: "≠"
314
+ }),
315
+ /* @__PURE__ */ (0, W.jsx)(x, {
316
+ value: ">",
317
+ children: ">"
318
+ }),
319
+ /* @__PURE__ */ (0, W.jsx)(x, {
320
+ value: "<",
321
+ children: "<"
322
+ }),
323
+ /* @__PURE__ */ (0, W.jsx)(x, {
324
+ value: ">=",
325
+ children: ">="
326
+ }),
327
+ /* @__PURE__ */ (0, W.jsx)(x, {
328
+ value: "<=",
329
+ children: "<="
330
+ })
331
+ ] })]
332
+ })] })
333
+ }), /* @__PURE__ */ (0, W.jsx)(k, {
334
+ name: `conditions[${r}].value`,
335
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, {
336
+ className: "w-full",
337
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
338
+ htmlFor: `value-${r}`,
339
+ children: O("editor.conditionalEdge.value")
340
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
341
+ disabled: t,
342
+ id: `value-${r}`,
343
+ placeholder: O("editor.conditionalEdge.valuePlaceholder"),
344
+ value: e.state.value || "",
345
+ onChange: (t) => e.handleChange(t.target.value)
346
+ })]
347
+ })
348
+ })]
349
+ }),
350
+ e.state.value && e.state.value.length > 1 && /* @__PURE__ */ (0, W.jsxs)(m, {
351
+ disabled: t,
352
+ type: "button",
353
+ variant: "ghost",
354
+ size: "sm",
355
+ className: "w-full",
356
+ onClick: () => {
357
+ e.removeValue(r), ie().then();
358
+ },
359
+ children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-1 h-4 w-4" }), O("editor.conditionalEdge.removeCondition")]
360
+ })
361
+ ]
362
+ }), e.state.value && r < e.state.value.length - 1 && /* @__PURE__ */ (0, W.jsx)(k, {
363
+ name: `conditions[${r}].logicalOperator`,
364
+ children: (e) => /* @__PURE__ */ (0, W.jsx)("div", {
365
+ className: "flex justify-center",
366
+ children: /* @__PURE__ */ (0, W.jsxs)(y, {
367
+ disabled: t,
368
+ value: e.state.value || i.AND,
369
+ onValueChange: (t) => e.handleChange(t),
370
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
371
+ className: "h-9 w-32 font-semibold",
372
+ children: /* @__PURE__ */ (0, W.jsx)(l, {})
373
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
374
+ value: i.AND,
375
+ children: "AND"
376
+ }), /* @__PURE__ */ (0, W.jsx)(x, {
377
+ value: i.OR,
378
+ children: "OR"
379
+ })] })]
380
+ })
381
+ })
382
+ })]
383
+ }, `condition-${r}`)), /* @__PURE__ */ (0, W.jsxs)(m, {
384
+ disabled: t,
385
+ type: "button",
386
+ variant: "outline",
387
+ size: "sm",
388
+ className: "w-full",
389
+ onClick: () => {
390
+ e.pushValue({
391
+ field: E[0]?.nodeId ?? "",
392
+ logicalOperator: i.AND,
393
+ operator: "===",
394
+ value: ""
395
+ }), ie().then();
396
+ },
397
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), O("editor.conditionalEdge.addCondition")]
398
+ })]
399
+ })]
400
+ });
401
+ }
402
+ })
403
+ ]
404
+ }),
405
+ /* @__PURE__ */ (0, W.jsxs)("div", {
406
+ className: "flex justify-end gap-2 pt-2",
407
+ children: [/* @__PURE__ */ (0, W.jsxs)(m, {
408
+ type: "button",
409
+ size: "sm",
410
+ variant: "outline",
411
+ onClick: se,
412
+ children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-1 h-4 w-4" }), O("common.clear")]
413
+ }), /* @__PURE__ */ (0, W.jsx)(m, {
414
+ type: "button",
415
+ size: "sm",
416
+ onClick: () => ne(!1),
417
+ children: O("common.close")
418
+ })]
419
+ })
420
+ ]
421
+ })
422
+ })
423
+ })
424
+ })]
425
+ })
426
+ }) })] });
427
+ }),
428
+ default: Oe(({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, style: s, markerEnd: c, selected: l }) => {
429
+ let [u, d, f] = we({
430
+ sourcePosition: a,
431
+ sourceX: t,
432
+ sourceY: n,
433
+ targetPosition: o,
434
+ targetX: r,
435
+ targetY: i
436
+ }), { setEdges: p } = M();
437
+ return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(pe, {
438
+ path: u,
439
+ markerEnd: c,
440
+ style: s
441
+ }), /* @__PURE__ */ (0, W.jsx)(he, { children: l && /* @__PURE__ */ (0, W.jsx)("div", {
442
+ className: "button-edge__label nodrag nopan",
443
+ style: { transform: `translate(-50%, -50%) translate(${d}px,${f}px)` },
444
+ children: /* @__PURE__ */ (0, W.jsx)("button", {
445
+ type: "button",
446
+ className: "button-edge__button",
447
+ onClick: () => {
448
+ p((t) => t.filter((t) => t.id !== e));
449
+ },
450
+ "aria-label": "Remove edge",
451
+ children: "×"
452
+ })
453
+ }) })] });
454
+ })
455
+ }, K = {
456
+ address: "address",
457
+ autocomplete: "autocomplete",
458
+ checkbox: "checkbox",
459
+ date: "date",
460
+ daterange: "daterange",
461
+ file: "file",
462
+ hidden: "hidden",
463
+ http: "http",
464
+ number: "number",
465
+ password: "password",
466
+ radio: "radio",
467
+ select: "select",
468
+ submit: "submit",
469
+ switch: "switch",
470
+ text: "text",
471
+ textarea: "textarea",
472
+ time: "time",
473
+ timerange: "timerange"
474
+ }, Ft = { [o.input]: { type: K.text } }, q = () => {
475
+ let { setNodes: e, setEdges: t, getNodes: n } = M(), r = N(() => {
476
+ e((e) => e.map(({ selected: e, ...t }) => t)), t((e) => e.map(({ selected: e, ...t }) => t));
477
+ }, [t, e]), i = N((n) => {
478
+ e((e) => e.map((e) => ({
479
+ ...e,
480
+ selected: e.id === n
481
+ }))), t((e) => e.map(({ selected: e, ...t }) => t));
482
+ }, [t, e]), a = N((t, n) => {
483
+ e((e) => e.map((e) => e.id === t ? {
484
+ ...e,
485
+ data: {
486
+ ...e.data,
487
+ ...n
488
+ }
489
+ } : e));
490
+ }, [e]), o = N((t, n) => {
491
+ e((e) => e.map((e) => e.id === t ? {
492
+ ...e,
493
+ data: Ft[n] ?? {},
494
+ type: n
495
+ } : e));
496
+ }, [e]), s = N((e) => {
497
+ let t = n().find((e) => e.selected);
498
+ t && o(t.id, e);
499
+ }, [n, o]), c = N((e) => {
500
+ let t = n().find((e) => e.selected);
501
+ t && a(t.id, e);
502
+ }, [n, a]), l = N((n) => {
503
+ e((e) => e.filter((e) => e.id !== n)), t((e) => e.filter((e) => e.source !== n && e.target !== n));
504
+ }, [e, t]);
505
+ return {
506
+ clearSelection: r,
507
+ deleteNode: l,
508
+ deleteSelectedNode: N(() => {
509
+ let e = n().find((e) => e.selected);
510
+ e && l(e.id);
511
+ }, [n, l]),
512
+ selectNode: i,
513
+ updateNodeData: a,
514
+ updateNodeType: o,
515
+ updateSelectedNodeData: c,
516
+ updateSelectedNodeType: s
517
+ };
518
+ }, It = ({ nodeId: e, label: t, placeholder: n, className: r }) => {
519
+ let { language: i } = jt(), { updateNodeData: a } = q(), o = G(), s = t?.[i] ?? "", c = n || o("editor.treegeNode.labelPlaceholder"), l = (n) => {
520
+ a(e, { label: {
521
+ ...t,
522
+ [i]: n.target.value
523
+ } });
524
+ }, u = (e) => e.stopPropagation();
525
+ return /* @__PURE__ */ (0, W.jsx)("input", {
526
+ type: "text",
527
+ value: s,
528
+ placeholder: c,
529
+ onChange: l,
530
+ onClick: u,
531
+ onMouseDown: u,
532
+ onPointerDown: u,
533
+ className: f("nodrag nopan w-full truncate bg-transparent outline-none placeholder:text-muted-foreground/40", r)
534
+ });
535
+ };
536
+ //#endregion
537
+ //#region src/shared/components/ui/alert-dialog.tsx
538
+ function Lt({ ...e }) {
539
+ return /* @__PURE__ */ (0, W.jsx)(B.Root, {
540
+ "data-slot": "alert-dialog",
541
+ ...e
542
+ });
543
+ }
544
+ function Rt({ ...e }) {
545
+ return /* @__PURE__ */ (0, W.jsx)(B.Trigger, {
546
+ "data-slot": "alert-dialog-trigger",
547
+ ...e
548
+ });
549
+ }
550
+ function zt({ ...e }) {
551
+ return /* @__PURE__ */ (0, W.jsx)(B.Portal, {
552
+ "data-slot": "alert-dialog-portal",
553
+ ...e
554
+ });
555
+ }
556
+ function Bt({ className: e, ...t }) {
557
+ return /* @__PURE__ */ (0, W.jsx)(B.Overlay, {
558
+ "data-slot": "alert-dialog-overlay",
559
+ className: f("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in", e),
560
+ ...t
561
+ });
562
+ }
563
+ function Vt({ className: e, ...t }) {
564
+ return /* @__PURE__ */ (0, W.jsxs)(zt, { children: [/* @__PURE__ */ (0, W.jsx)(Bt, {}), /* @__PURE__ */ (0, W.jsx)(B.Content, {
565
+ "data-slot": "alert-dialog-content",
566
+ className: f("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg", e),
567
+ ...t
568
+ })] });
569
+ }
570
+ function Ht({ className: e, ...t }) {
571
+ return /* @__PURE__ */ (0, W.jsx)("div", {
572
+ "data-slot": "alert-dialog-header",
573
+ className: f("flex flex-col gap-2 text-center sm:text-left", e),
574
+ ...t
575
+ });
576
+ }
577
+ function Ut({ className: e, ...t }) {
578
+ return /* @__PURE__ */ (0, W.jsx)("div", {
579
+ "data-slot": "alert-dialog-footer",
580
+ className: f("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", e),
581
+ ...t
582
+ });
583
+ }
584
+ function Wt({ className: e, ...t }) {
585
+ return /* @__PURE__ */ (0, W.jsx)(B.Title, {
586
+ "data-slot": "alert-dialog-title",
587
+ className: f("font-semibold text-lg", e),
588
+ ...t
589
+ });
590
+ }
591
+ function Gt({ className: e, ...t }) {
592
+ return /* @__PURE__ */ (0, W.jsx)(B.Description, {
593
+ "data-slot": "alert-dialog-description",
594
+ className: f("text-muted-foreground text-sm", e),
595
+ ...t
596
+ });
597
+ }
598
+ function Kt({ className: e, ...t }) {
599
+ return /* @__PURE__ */ (0, W.jsx)(B.Action, {
600
+ className: f(g(), e),
601
+ ...t
602
+ });
603
+ }
604
+ function qt({ className: e, ...t }) {
605
+ return /* @__PURE__ */ (0, W.jsx)(B.Cancel, {
606
+ className: f(g({ variant: "outline" }), e),
607
+ ...t
608
+ });
609
+ }
610
+ //#endregion
611
+ //#region src/shared/components/ui/dropdown-menu.tsx
612
+ function J({ ...e }) {
613
+ return /* @__PURE__ */ (0, W.jsx)(V.Root, {
614
+ "data-slot": "dropdown-menu",
615
+ ...e
616
+ });
617
+ }
618
+ function Y({ ...e }) {
619
+ return /* @__PURE__ */ (0, W.jsx)(V.Trigger, {
620
+ "data-slot": "dropdown-menu-trigger",
621
+ ...e
622
+ });
623
+ }
624
+ function X({ className: e, sideOffset: t = 4, ...n }) {
625
+ return /* @__PURE__ */ (0, W.jsx)(V.Portal, { children: /* @__PURE__ */ (0, W.jsx)(V.Content, {
626
+ "data-slot": "dropdown-menu-content",
627
+ sideOffset: t,
628
+ className: f("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-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in", e),
629
+ ...n
630
+ }) });
631
+ }
632
+ function Jt({ ...e }) {
633
+ return /* @__PURE__ */ (0, W.jsx)(V.Group, {
634
+ "data-slot": "dropdown-menu-group",
635
+ ...e
636
+ });
637
+ }
638
+ function Z({ className: e, inset: t, variant: n = "default", ...r }) {
639
+ return /* @__PURE__ */ (0, W.jsx)(V.Item, {
640
+ "data-slot": "dropdown-menu-item",
641
+ "data-inset": t,
642
+ "data-variant": n,
643
+ className: f("data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[disabled]:opacity-50 data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0", e),
644
+ ...r
645
+ });
646
+ }
647
+ function Yt({ className: e, inset: t, ...n }) {
648
+ return /* @__PURE__ */ (0, W.jsx)(V.Label, {
649
+ "data-slot": "dropdown-menu-label",
650
+ "data-inset": t,
651
+ className: f("px-1.5 py-1 font-medium text-muted-foreground text-xs data-[inset]:pl-7", e),
652
+ ...n
653
+ });
654
+ }
655
+ function Xt({ className: e, ...t }) {
656
+ return /* @__PURE__ */ (0, W.jsx)(V.Separator, {
657
+ "data-slot": "dropdown-menu-separator",
658
+ className: f("-mx-1 my-1 h-px bg-border", e),
659
+ ...t
660
+ });
661
+ }
662
+ //#endregion
663
+ //#region src/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.tsx
664
+ var Zt = ({ nodeId: e, className: t }) => {
665
+ let { deleteNode: n, selectNode: r } = q(), { setIsNodeSheetOpen: i } = jt(), a = G(), [o, s] = F(!1), c = (e) => e.stopPropagation(), l = () => {
666
+ r(e), i(!0);
667
+ }, u = () => {
668
+ n(e), s(!1);
669
+ };
670
+ return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
671
+ asChild: !0,
672
+ onClick: c,
673
+ children: /* @__PURE__ */ (0, W.jsx)("button", {
674
+ type: "button",
675
+ "aria-label": a("editor.nodeActionsSheet.editNode"),
676
+ className: f("nodrag nopan absolute top-2 right-2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-md opacity-60 transition-all hover:text-[--treege-color-primary] hover:opacity-100", t),
677
+ children: /* @__PURE__ */ (0, W.jsx)(it, { className: "h-3.5 w-3.5" })
678
+ })
679
+ }), /* @__PURE__ */ (0, W.jsxs)(X, {
680
+ align: "end",
681
+ onClick: c,
682
+ children: [
683
+ /* @__PURE__ */ (0, W.jsxs)(Z, {
684
+ onClick: l,
685
+ children: [/* @__PURE__ */ (0, W.jsx)(dt, {}), a("common.settings")]
686
+ }),
687
+ /* @__PURE__ */ (0, W.jsx)(Xt, {}),
688
+ /* @__PURE__ */ (0, W.jsxs)(Z, {
689
+ variant: "destructive",
690
+ onClick: () => s(!0),
691
+ children: [/* @__PURE__ */ (0, W.jsx)(pt, {}), a("common.delete")]
692
+ })
693
+ ]
694
+ })] }), /* @__PURE__ */ (0, W.jsx)(Lt, {
695
+ open: o,
696
+ onOpenChange: s,
697
+ children: /* @__PURE__ */ (0, W.jsxs)(Vt, {
698
+ onClick: c,
699
+ children: [/* @__PURE__ */ (0, W.jsxs)(Ht, { children: [/* @__PURE__ */ (0, W.jsx)(Wt, { children: a("editor.nodeActionsSheet.deleteNode") }), /* @__PURE__ */ (0, W.jsx)(Gt, { children: a("editor.nodeActionsSheet.deleteNodeConfirm") })] }), /* @__PURE__ */ (0, W.jsxs)(Ut, { children: [/* @__PURE__ */ (0, W.jsx)(qt, { children: a("common.cancel") }), /* @__PURE__ */ (0, W.jsx)(Kt, {
700
+ onClick: u,
701
+ children: a("common.delete")
702
+ })] })]
703
+ })
704
+ })] });
705
+ }, Qt = bt("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3", {
706
+ defaultVariants: { variant: "default" },
707
+ variants: { variant: {
708
+ blue: "bg-blue-500 text-white dark:bg-blue-600",
709
+ default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
710
+ 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",
711
+ outline: "border-foreground/30 text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
712
+ purple: "bg-purple-600 hover:bg-purple-700 text-white",
713
+ secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90"
714
+ } }
715
+ });
716
+ function $t({ className: e, variant: t, asChild: n = !1, ...r }) {
717
+ return /* @__PURE__ */ (0, W.jsx)(n ? yt : "span", {
718
+ "data-slot": "badge",
719
+ className: f(Qt({ variant: t }), e),
720
+ ...r
721
+ });
722
+ }
723
+ var en = Oe(({ data: e, id: t }) => /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
724
+ /* @__PURE__ */ (0, W.jsx)(ve, {}),
725
+ /* @__PURE__ */ (0, W.jsx)("div", {
726
+ className: "-top-3.5 absolute left-6",
727
+ children: /* @__PURE__ */ (0, W.jsxs)($t, {
728
+ className: "max-w-50 bg-chart-2",
729
+ children: [/* @__PURE__ */ (0, W.jsx)(Fe, { className: "!w-3 !h-3" }), /* @__PURE__ */ (0, W.jsx)(It, {
730
+ nodeId: t,
731
+ label: e?.label,
732
+ className: "min-w-0 flex-1 text-xs text-white placeholder:text-white/60"
733
+ })]
734
+ })
735
+ }),
736
+ /* @__PURE__ */ (0, W.jsx)(Zt, { nodeId: t })
737
+ ] })), tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", nn = (e = 21) => {
738
+ let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
739
+ for (; e--;) t += tn[n[e] & 63];
740
+ return t;
741
+ }, rn = {
742
+ data: { type: "text" },
743
+ id: nn(),
744
+ position: {
745
+ x: 0,
746
+ y: 0
747
+ },
748
+ type: "input"
749
+ }, an = () => {
750
+ let { setNodes: e, setEdges: t, screenToFlowPosition: n, getNode: r, getNodes: i, getEdges: a } = M(), o = N((n, r, i = !1, o) => {
751
+ let s = n.id, l = a().filter((e) => e.source === s), u = c(n);
752
+ if (l.length > 0 && !u) return;
753
+ let d = nn(), f = {
754
+ ...rn,
755
+ ...o && {
756
+ data: o.data ?? {},
757
+ type: o.type
758
+ },
759
+ id: d,
760
+ position: r,
761
+ selected: i
762
+ };
763
+ n?.parentId && (f.parentId = n.parentId, f.extent = "parent"), e((e) => e.concat(f)), t((e) => {
764
+ let t = e.filter((e) => e.source === s).length > 0, n = {
765
+ data: t && u ? { conditions: [{
766
+ field: s,
767
+ operator: "===",
768
+ value: ""
769
+ }] } : void 0,
770
+ id: nn(),
771
+ source: s,
772
+ target: d,
773
+ type: t && u ? "conditional" : "default"
774
+ };
775
+ return t && u ? e.map((e) => e.source === s ? {
776
+ ...e,
777
+ data: {
778
+ ...e.data,
779
+ conditions: e.data?.conditions || [{
780
+ field: s,
781
+ operator: "===",
782
+ value: ""
783
+ }]
784
+ },
785
+ type: "conditional"
786
+ } : e).concat(n) : e.concat(n);
787
+ }), i && (e((e) => e.map((e) => ({
788
+ ...e,
789
+ selected: e.id === d
790
+ }))), t((e) => e.map((e) => ({
791
+ ...e,
792
+ selected: !1
793
+ }))));
794
+ }, [
795
+ a,
796
+ e,
797
+ t
798
+ ]), s = N((e) => {
799
+ t((t) => {
800
+ let n = Ce(e, t), i = e.source, a = r(i);
801
+ return n.filter((e) => e.source === i).length > 1 && a && c(a) ? n.map((e) => e.source === i ? {
802
+ ...e,
803
+ data: {
804
+ ...e.data,
805
+ conditions: e.data?.conditions || [{
806
+ field: i,
807
+ operator: "===",
808
+ value: ""
809
+ }]
810
+ },
811
+ type: "conditional"
812
+ } : e) : n;
813
+ });
814
+ }, [t, r]), l = N((e, t) => {
815
+ let n = r(e);
816
+ if (!n) return;
817
+ let s = getComputedStyle(document.documentElement).getPropertyValue("--node-height"), c = getComputedStyle(document.documentElement).getPropertyValue("--node-width"), l = parseFloat(s) || 100, u = parseFloat(c) || 100, d = n.position.y + l + 100, f = i(), p = a(), m = f.filter((t) => p.some((n) => n.source === e && n.target === t.id));
818
+ o(n, {
819
+ x: m.length > 0 ? m.reduce((e, t) => t.position.x > e.position.x ? t : e, m[0]).position.x + u + 50 : n.position.x,
820
+ y: d
821
+ }, !0, t);
822
+ }, [
823
+ r,
824
+ i,
825
+ a,
826
+ o
827
+ ]), u = N((e, t) => {
828
+ if (!t.isValid) {
829
+ let { clientX: i, clientY: a } = "changedTouches" in e ? e.changedTouches[0] : e, s = t.fromNode;
830
+ if (!s) return;
831
+ let c = n({
832
+ x: i,
833
+ y: a
834
+ }), l = s.parentId ? r(s.parentId) : void 0, u = l?.position ?? {
835
+ x: 0,
836
+ y: 0
837
+ };
838
+ o(s, l ? {
839
+ x: c.x - u.x,
840
+ y: c.y - u.y
841
+ } : c);
842
+ }
843
+ }, [
844
+ o,
845
+ r,
846
+ n
847
+ ]), d = N((e) => {
848
+ t((t) => {
849
+ let n = t.filter((t) => !e.find((e) => e.id === t.id)), r = new Set(e.map((e) => e.source)), i = /* @__PURE__ */ new Map();
850
+ return n.forEach((e) => {
851
+ i.set(e.source, (i.get(e.source) ?? 0) + 1);
852
+ }), n.map((e) => {
853
+ if (r.has(e.source) && (i.get(e.source) ?? 0) === 1) {
854
+ let { conditions: t, isFallback: n, ...r } = e.data ?? {}, i = r && Object.keys(r).length > 0 ? r : void 0;
855
+ return {
856
+ ...e,
857
+ data: i,
858
+ type: "default"
859
+ };
860
+ }
861
+ return e;
862
+ });
863
+ });
864
+ }, [t]);
865
+ return {
866
+ isValidConnection: N((e) => {
867
+ if (e.source === e.target) return !1;
868
+ let t = r(e.source);
869
+ return t ? !(a().filter((t) => t.source === e.source).length > 0 && !c(t)) : !1;
870
+ }, [r, a]),
871
+ onAddFromHandle: l,
872
+ onConnect: s,
873
+ onConnectEnd: u,
874
+ onEdgesDelete: d
875
+ };
876
+ }, on = {
877
+ divider: "divider",
878
+ title: "title"
879
+ }, sn = ({ nodeId: e, isConnectable: t }) => {
880
+ let { onAddFromHandle: n } = an(), r = G(), [i, a] = F(!1);
881
+ return /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(ge, {
882
+ type: "source",
883
+ position: be.Bottom,
884
+ isConnectable: t,
885
+ onClick: (e) => {
886
+ e.defaultPrevented || a(!0);
887
+ },
888
+ className: "flex h-6! w-6! cursor-pointer items-center justify-center rounded-sm transition-colors hover:bg-primary/80!",
889
+ children: /* @__PURE__ */ (0, W.jsx)(R, { className: "h-4 w-4 text-primary-foreground" })
890
+ }), /* @__PURE__ */ (0, W.jsxs)(J, {
891
+ open: i,
892
+ onOpenChange: a,
893
+ children: [/* @__PURE__ */ (0, W.jsx)(Y, {
894
+ asChild: !0,
895
+ children: /* @__PURE__ */ (0, W.jsx)("span", {
896
+ "aria-hidden": !0,
897
+ className: "-translate-x-1/2 pointer-events-none absolute bottom-0 left-1/2 h-0 w-0"
898
+ })
899
+ }), /* @__PURE__ */ (0, W.jsxs)(X, {
900
+ align: "center",
901
+ side: "bottom",
902
+ className: "treege-scrollbar max-h-80",
903
+ children: [
904
+ /* @__PURE__ */ (0, W.jsxs)(Jt, { children: [/* @__PURE__ */ (0, W.jsx)(Yt, { children: r("editor.selectNodeType.options.input") }), Object.values(K).map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
905
+ onClick: () => n(e, {
906
+ data: { type: t },
907
+ type: o.input
908
+ }),
909
+ className: "capitalize",
910
+ children: t
911
+ }, t))] }),
912
+ /* @__PURE__ */ (0, W.jsx)(Xt, {}),
913
+ /* @__PURE__ */ (0, W.jsxs)(Jt, { children: [/* @__PURE__ */ (0, W.jsx)(Yt, { children: r("editor.selectNodeType.options.ui") }), Object.values(on).map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
914
+ onClick: () => n(e, {
915
+ data: { type: t },
916
+ type: o.ui
917
+ }),
918
+ className: "capitalize",
919
+ children: t
920
+ }, t))] }),
921
+ /* @__PURE__ */ (0, W.jsx)(Xt, {}),
922
+ /* @__PURE__ */ (0, W.jsxs)(Jt, { children: [/* @__PURE__ */ (0, W.jsx)(Yt, { children: r("common.other") }), /* @__PURE__ */ (0, W.jsx)(Z, {
923
+ onClick: () => n(e, {
924
+ data: {},
925
+ type: o.flow
926
+ }),
927
+ children: r("editor.selectNodeType.options.flow")
928
+ })] })
929
+ ]
930
+ })]
931
+ })] });
932
+ }, cn = {
933
+ [K.address]: nt,
934
+ [K.autocomplete]: lt,
935
+ [K.checkbox]: Be,
936
+ [K.date]: Ie,
937
+ [K.daterange]: Le,
938
+ [K.file]: at,
939
+ [K.hidden]: Je,
940
+ [K.http]: We,
941
+ [K.number]: Ye,
942
+ [K.password]: Qe,
943
+ [K.radio]: He,
944
+ [K.select]: et,
945
+ [K.submit]: ut,
946
+ [K.switch]: ft,
947
+ [K.text]: Re,
948
+ [K.textarea]: Ne,
949
+ [K.time]: Ue,
950
+ [K.timerange]: Ue,
951
+ [on.divider]: rt,
952
+ [on.title]: Xe
953
+ }, ln = st, un = (e) => e && cn[e] || ln, dn = {
954
+ input: Object.values(K),
955
+ ui: Object.values(on)
956
+ }, fn = ({ nodeId: e, type: t, inputType: n }) => {
957
+ let { updateNodeData: r } = q(), i = G(), a = dn[t], o = (e) => e.stopPropagation();
958
+ return /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
959
+ asChild: !0,
960
+ onClick: o,
961
+ children: /* @__PURE__ */ (0, W.jsxs)($t, {
962
+ variant: "default",
963
+ className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
964
+ children: [
965
+ /* @__PURE__ */ (0, W.jsx)(un(n), { className: "mt-0.5" }),
966
+ n || i("editor.selectInputType.type"),
967
+ /* @__PURE__ */ (0, W.jsx)(Ve, {})
968
+ ]
969
+ })
970
+ }), /* @__PURE__ */ (0, W.jsx)(X, {
971
+ align: "start",
972
+ className: "treege-scrollbar max-h-60",
973
+ onClick: o,
974
+ children: a.map((t) => {
975
+ let i = un(t);
976
+ return /* @__PURE__ */ (0, W.jsxs)(Z, {
977
+ onClick: () => r(e, { type: t }),
978
+ className: f("capitalize", t === n && "bg-accent"),
979
+ children: [/* @__PURE__ */ (0, W.jsx)(i, {}), t]
980
+ }, t);
981
+ })
982
+ })] });
983
+ }, pn = [
984
+ "radio",
985
+ "select",
986
+ "checkbox",
987
+ "autocomplete"
988
+ ], mn = ({ nodeId: e, data: t }) => {
989
+ let [n, r] = F(!1), [i, a] = F(""), [o, s] = F(""), { updateNodeData: c } = q(), { language: l } = jt(), f = G(), p = t && "type" in t ? t.type : void 0;
990
+ if (!(p && pn.includes(p))) return null;
991
+ let g = t.options ?? [], _ = () => {
992
+ a(""), s("");
993
+ }, y = (t) => {
994
+ t?.preventDefault();
995
+ let n = i.trim(), a = o.trim() || n;
996
+ if (!(n || a)) return;
997
+ let s = {
998
+ label: { [l]: n },
999
+ value: a
1000
+ };
1001
+ c(e, { options: [...g, s] }), _(), r(!1);
1002
+ }, b = (e) => {
1003
+ r(e), e || _();
1004
+ }, x = (e) => {
1005
+ e.key === "Enter" && (e.preventDefault(), y());
1006
+ }, S = (e) => e.stopPropagation();
1007
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
1008
+ className: "nodrag nopan my-1 flex flex-col gap-0.5",
1009
+ children: [g.map((e, t) => {
1010
+ let n = f(e.label) || e.value || "—", r = `${e.value || "opt"}-${t}`;
1011
+ return /* @__PURE__ */ (0, W.jsx)("div", {
1012
+ className: "truncate text-muted-foreground text-xs",
1013
+ children: n
1014
+ }, r);
1015
+ }), /* @__PURE__ */ (0, W.jsxs)(le, {
1016
+ open: n,
1017
+ onOpenChange: b,
1018
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
1019
+ asChild: !0,
1020
+ onClick: S,
1021
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
1022
+ type: "button",
1023
+ variant: "link",
1024
+ size: "xs",
1025
+ className: "w-fit p-0!",
1026
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "size-3" }), f("editor.inputNodeForm.addOption")]
1027
+ })
1028
+ }), /* @__PURE__ */ (0, W.jsx)(v, {
1029
+ align: "start",
1030
+ className: "w-64 p-3",
1031
+ onClick: S,
1032
+ children: /* @__PURE__ */ (0, W.jsxs)("form", {
1033
+ onSubmit: y,
1034
+ className: "flex flex-col gap-2",
1035
+ children: [
1036
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1037
+ className: "flex flex-col gap-1",
1038
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
1039
+ htmlFor: `${e}-option-label`,
1040
+ className: "text-xs",
1041
+ children: f("editor.inputNodeForm.optionLabel")
1042
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
1043
+ id: `${e}-option-label`,
1044
+ autoFocus: !0,
1045
+ value: i,
1046
+ onChange: (e) => a(e.target.value),
1047
+ onKeyDown: x
1048
+ })]
1049
+ }),
1050
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1051
+ className: "flex flex-col gap-1",
1052
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
1053
+ htmlFor: `${e}-option-value`,
1054
+ className: "text-xs",
1055
+ children: f("editor.inputNodeForm.optionValue")
1056
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
1057
+ id: `${e}-option-value`,
1058
+ value: o,
1059
+ onChange: (e) => s(e.target.value),
1060
+ onKeyDown: x
1061
+ })]
1062
+ }),
1063
+ /* @__PURE__ */ (0, W.jsx)(m, {
1064
+ type: "submit",
1065
+ size: "sm",
1066
+ disabled: !(i.trim() || o.trim()),
1067
+ children: f("common.create")
1068
+ })
1069
+ ]
1070
+ })
1071
+ })]
1072
+ })]
1073
+ });
1074
+ }, hn = ({ nodeId: e, required: t }) => {
1075
+ let { updateNodeData: n } = q(), r = G();
1076
+ return /* @__PURE__ */ (0, W.jsx)($t, {
1077
+ variant: t ? "destructive" : "outline",
1078
+ asChild: !0,
1079
+ className: "nodrag nopan cursor-pointer px-1.5 py-0 text-[10px] capitalize [&>svg]:size-2.5",
1080
+ children: /* @__PURE__ */ (0, W.jsx)("button", {
1081
+ type: "button",
1082
+ onClick: (r) => {
1083
+ r.stopPropagation(), n(e, { required: !t });
1084
+ },
1085
+ children: r(t ? "editor.inputNodeForm.required" : "editor.inputNodeForm.optional")
1086
+ })
1087
+ });
1088
+ }, gn = ({ children: e, inGroup: t, isSubmit: n }) => /* @__PURE__ */ (0, W.jsx)("div", {
1089
+ className: f("react-flow__node__wrapper relative", t && "in-group", n && "submit-type"),
1090
+ children: e
1091
+ }), _n = Oe(({ data: e, isConnectable: t, parentId: n, type: r, id: i }) => {
1092
+ let a = r === "input" || r === "ui" ? e?.type : void 0, o = r === "input" && e?.type === "submit", s = r === "input" ? e?.name : void 0;
1093
+ return /* @__PURE__ */ (0, W.jsxs)(gn, {
1094
+ inGroup: !!n,
1095
+ isSubmit: o,
1096
+ children: [
1097
+ /* @__PURE__ */ (0, W.jsx)(Zt, { nodeId: i }),
1098
+ /* @__PURE__ */ (0, W.jsx)(ge, {
1099
+ type: "target",
1100
+ position: be.Top,
1101
+ isConnectable: t,
1102
+ isConnectableStart: r === "ui"
1103
+ }),
1104
+ /* @__PURE__ */ (0, W.jsx)(It, {
1105
+ nodeId: i,
1106
+ label: e?.label,
1107
+ placeholder: s,
1108
+ className: f("py-1", r === "ui" && "capitalize")
1109
+ }),
1110
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1111
+ className: "mb-1 flex gap-1",
1112
+ children: [(r === "input" || r === "ui") && /* @__PURE__ */ (0, W.jsx)(fn, {
1113
+ nodeId: i,
1114
+ type: r,
1115
+ inputType: a
1116
+ }), r === "input" && !o && /* @__PURE__ */ (0, W.jsx)(hn, {
1117
+ nodeId: i,
1118
+ required: e?.required
1119
+ })]
1120
+ }),
1121
+ r === "input" && /* @__PURE__ */ (0, W.jsx)(mn, {
1122
+ nodeId: i,
1123
+ data: e
1124
+ }),
1125
+ /* @__PURE__ */ (0, W.jsx)(sn, {
1126
+ nodeId: i,
1127
+ isConnectable: t
1128
+ })
1129
+ ]
1130
+ });
1131
+ }), vn = {
1132
+ [o.flow]: _n,
1133
+ [o.group]: en,
1134
+ [o.input]: _n,
1135
+ [o.ui]: _n
1136
+ }, yn = "You are a Treege decision tree generator. You must generate valid JSON structures for decision trees.\n\nIMPORTANT RULES:\n1. Always respond with valid JSON only, no markdown, no code blocks, no explanations outside the JSON\n2. The JSON must have this exact structure: { \"nodes\": [...], \"edges\": [...] }\n3. Every node must have: id (string), type (string), position ({ x: number, y: number }), data (object)\n4. Every edge must have: id (string), source (string), target (string)\n5. For regex patterns: ALWAYS use double backslashes (\\\\) for special characters (\\\\s, \\\\d, etc.)\n6. AVOID using \"pattern\" field unless specifically requested - prefer using simple validation\n7. For submit buttons, use type \"input\" with data.type \"submit\", NOT type \"flow\"\n8. For conditional logic, use conditional edges with proper operators (===, !==, >, <, >=, <=)\n\nNODE TYPES:\n- \"input\": Form input fields (text, number, select, checkbox, etc.)\n- \"ui\": UI elements (title, divider)\n- \"flow\": Navigation/flow control nodes\n- \"group\": Container for organizing nodes\n\nINPUT NODE TYPES (data.type):\n- \"text\", \"number\", \"textarea\", \"password\"\n- \"select\", \"radio\", \"checkbox\", \"switch\"\n- \"autocomplete\", \"date\", \"daterange\", \"time\", \"timerange\"\n- \"file\", \"address\", \"http\", \"hidden\", \"submit\"\n\nINPUT NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Field Label\",\n \"name\": \"fieldName\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter value...\",\n \"helperText\": \"Optional helper text\",\n \"pattern\": \"regex pattern (optional)\",\n \"errorMessage\": \"Error message if validation fails\",\n \"options\": [{ \"value\": \"val\", \"label\": \"Label\" }], // for select/radio/checkbox\n \"multiple\": false // for select/checkbox\n }\n}\n\nUI NODE TYPES (data.type):\n- \"title\": Display a title\n- \"divider\": Display a divider line\n\nUI NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"UI Element Label\",\n \"type\": \"title\" // or \"divider\"\n }\n}\n\nFLOW NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"flow\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Flow Step Label\",\n \"targetId\": \"next-node-id\" // optional\n }\n}\n\nGROUP NODE DATA STRUCTURE:\n{\n \"id\": \"unique-id\",\n \"type\": \"group\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": {\n \"label\": \"Group Label\"\n }\n}\n\nEDGE STRUCTURE:\n{\n \"id\": \"edge-id\",\n \"source\": \"source-node-id\",\n \"target\": \"target-node-id\",\n \"type\": \"default\" // or \"conditional\" for conditional logic\n}\n\nCONDITIONAL EDGE STRUCTURE:\n{\n \"id\": \"edge-id\",\n \"source\": \"source-node-id\",\n \"target\": \"target-node-id\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If condition is true\", // optional label for the edge\n \"conditions\": [\n {\n \"field\": \"field-node-id\", // ID of the field to check\n \"operator\": \">=\", // operators: ===, !==, >, <, >=, <=\n \"value\": \"18\" // value to compare (as string)\n }\n ],\n \"operator\": \"AND\" // optional: \"AND\" or \"OR\" for multiple conditions (default: AND)\n }\n}\n\nIMPORTANT: For conditional edges, the value must ALWAYS be a string, even for numbers.\nExample: For \"age >= 18\", use \"value\": \"18\" (not value: 18)\n\nLAYOUT GUIDELINES:\n- Position nodes in a vertical flow (top to bottom)\n- Start at position { x: 0, y: 0 }\n- Space nodes vertically by exactly 250 pixels between each position (node height 150px + 100px spacing)\n- For horizontal spacing, use 350 pixels\n- Create logical flow from top to bottom\n- IMPORTANT: Keep consistent vertical spacing to avoid overlap\n- Each node position Y should increment by 250: first at y:0, second at y:250, third at y:500, etc.\n\nEXAMPLES:\n\nUser: \"Create a simple contact form with name, email and message\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"Contact Form\", \"type\": \"title\" }\n },\n {\n \"id\": \"name-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Name\",\n \"name\": \"name\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter your name\"\n }\n },\n {\n \"id\": \"email-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Email\",\n \"name\": \"email\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"your@email.com\"\n }\n },\n {\n \"id\": \"message-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 750 },\n \"data\": {\n \"label\": \"Message\",\n \"name\": \"message\",\n \"type\": \"textarea\",\n \"required\": true,\n \"placeholder\": \"Enter your message\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"name-1\" },\n { \"id\": \"e2\", \"source\": \"name-1\", \"target\": \"email-1\" },\n { \"id\": \"e3\", \"source\": \"email-1\", \"target\": \"message-1\" }\n ]\n}\n\nUser: \"Create a user registration form with age, address and country selector\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"User Registration\", \"type\": \"title\" }\n },\n {\n \"id\": \"age-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Age\",\n \"name\": \"age\",\n \"type\": \"number\",\n \"required\": true,\n \"placeholder\": \"Enter your age\"\n }\n },\n {\n \"id\": \"address-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Address\",\n \"name\": \"address\",\n \"type\": \"address\",\n \"required\": true,\n \"placeholder\": \"Enter your address\"\n }\n },\n {\n \"id\": \"country-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 750 },\n \"data\": {\n \"label\": \"Country\",\n \"name\": \"country\",\n \"type\": \"select\",\n \"required\": true,\n \"options\": [\n { \"value\": \"us\", \"label\": \"United States\" },\n { \"value\": \"ca\", \"label\": \"Canada\" },\n { \"value\": \"uk\", \"label\": \"United Kingdom\" },\n { \"value\": \"fr\", \"label\": \"France\" },\n { \"value\": \"de\", \"label\": \"Germany\" }\n ]\n }\n },\n {\n \"id\": \"submit-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 1000 },\n \"data\": {\n \"label\": \"Submit\",\n \"type\": \"submit\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"age-1\" },\n { \"id\": \"e2\", \"source\": \"age-1\", \"target\": \"address-1\" },\n { \"id\": \"e3\", \"source\": \"address-1\", \"target\": \"country-1\" },\n { \"id\": \"e4\", \"source\": \"country-1\", \"target\": \"submit-1\" }\n ]\n}\n\nUser: \"Create a form with name, age, and show different questions based on age (movie for 18+, color for under 18)\"\nResponse:\n{\n \"nodes\": [\n {\n \"id\": \"title-1\",\n \"type\": \"ui\",\n \"position\": { \"x\": 0, \"y\": 0 },\n \"data\": { \"label\": \"Survey Form\", \"type\": \"title\" }\n },\n {\n \"id\": \"name-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 250 },\n \"data\": {\n \"label\": \"Name\",\n \"name\": \"name\",\n \"type\": \"text\",\n \"required\": true,\n \"placeholder\": \"Enter your name\"\n }\n },\n {\n \"id\": \"age-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 500 },\n \"data\": {\n \"label\": \"Age\",\n \"name\": \"age\",\n \"type\": \"number\",\n \"required\": true,\n \"placeholder\": \"Enter your age\"\n }\n },\n {\n \"id\": \"movie-1\",\n \"type\": \"input\",\n \"position\": { \"x\": -350, \"y\": 750 },\n \"data\": {\n \"label\": \"Favorite Movie\",\n \"name\": \"favoriteMovie\",\n \"type\": \"text\",\n \"required\": true,\n \"helperText\": \"For adults 18 and over\"\n }\n },\n {\n \"id\": \"color-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 350, \"y\": 750 },\n \"data\": {\n \"label\": \"Favorite Color\",\n \"name\": \"favoriteColor\",\n \"type\": \"text\",\n \"required\": true,\n \"helperText\": \"For those under 18\"\n }\n },\n {\n \"id\": \"submit-1\",\n \"type\": \"input\",\n \"position\": { \"x\": 0, \"y\": 1000 },\n \"data\": {\n \"label\": \"Submit\",\n \"type\": \"submit\"\n }\n }\n ],\n \"edges\": [\n { \"id\": \"e1\", \"source\": \"title-1\", \"target\": \"name-1\" },\n { \"id\": \"e2\", \"source\": \"name-1\", \"target\": \"age-1\" },\n {\n \"id\": \"e3\",\n \"source\": \"age-1\",\n \"target\": \"movie-1\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If 18 or older\",\n \"conditions\": [\n {\n \"field\": \"age-1\",\n \"operator\": \">=\",\n \"value\": \"18\"\n }\n ]\n }\n },\n {\n \"id\": \"e4\",\n \"source\": \"age-1\",\n \"target\": \"color-1\",\n \"type\": \"conditional\",\n \"data\": {\n \"label\": \"If under 18\",\n \"conditions\": [\n {\n \"field\": \"age-1\",\n \"operator\": \"<\",\n \"value\": \"18\"\n }\n ]\n }\n },\n { \"id\": \"e5\", \"source\": \"movie-1\", \"target\": \"submit-1\" },\n { \"id\": \"e6\", \"source\": \"color-1\", \"target\": \"submit-1\" }\n ]\n}\n\nRemember:\n- Always respond with ONLY valid JSON\n- No markdown code blocks\n- No explanations outside the JSON\n- Follow the exact structure shown above\n- For submit buttons, ALWAYS use type \"input\" with data.type \"submit\"\n- For conditional edges, ALWAYS specify the value as a string and use proper operators (>=, <, ===, etc.)\n- Never leave condition values empty - always provide the comparison value\n", bn = {
1137
+ claude: "claude-3-5-haiku-20241022",
1138
+ deepseek: "deepseek-chat",
1139
+ gemini: "gemini-2.5-flash",
1140
+ openai: "gpt-4o-mini"
1141
+ }, xn = .3;
1142
+ function Sn(e) {
1143
+ try {
1144
+ return JSON.parse(e);
1145
+ } catch (t) {
1146
+ let n = e.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
1147
+ try {
1148
+ return JSON.parse(n);
1149
+ } catch {
1150
+ throw console.error("Failed to parse AI response:", e.substring(0, 500)), Error(`Invalid JSON response from AI: ${t instanceof Error ? t.message : "Unknown error"}`);
1151
+ }
1152
+ }
1153
+ }
1154
+ async function Cn(e) {
1155
+ let t = e.config.model || bn.gemini, n = e.config.temperature ?? xn, r = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:generateContent?key=${e.config.apiKey}`, {
1156
+ body: JSON.stringify({
1157
+ contents: [{ parts: [{ text: `${yn}\n\nUser request: ${e.prompt}` }] }],
1158
+ generationConfig: {
1159
+ responseMimeType: "application/json",
1160
+ temperature: n
1161
+ }
1162
+ }),
1163
+ headers: { "Content-Type": "application/json" },
1164
+ method: "POST"
1165
+ });
1166
+ if (!r.ok) {
1167
+ let e = await r.text();
1168
+ throw Error(`Gemini API error: ${e}`);
1169
+ }
1170
+ let i = (await r.json()).candidates?.[0]?.content?.parts?.[0]?.text;
1171
+ if (!i) throw Error("No response from Gemini");
1172
+ return Sn(i);
1173
+ }
1174
+ async function wn(e) {
1175
+ let t = e.config.model || bn.openai, n = e.config.temperature ?? xn, r = await fetch("https://api.openai.com/v1/chat/completions", {
1176
+ body: JSON.stringify({
1177
+ messages: [{
1178
+ content: yn,
1179
+ role: "system"
1180
+ }, {
1181
+ content: e.prompt,
1182
+ role: "user"
1183
+ }],
1184
+ model: t,
1185
+ response_format: { type: "json_object" },
1186
+ temperature: n
1187
+ }),
1188
+ headers: {
1189
+ Authorization: `Bearer ${e.config.apiKey}`,
1190
+ "Content-Type": "application/json"
1191
+ },
1192
+ method: "POST"
1193
+ });
1194
+ if (!r.ok) {
1195
+ let e = await r.text();
1196
+ throw Error(`OpenAI API error: ${e}`);
1197
+ }
1198
+ let i = (await r.json()).choices?.[0]?.message?.content;
1199
+ if (!i) throw Error("No response from OpenAI");
1200
+ return Sn(i);
1201
+ }
1202
+ async function Tn(e) {
1203
+ let t = e.config.model || bn.deepseek, n = e.config.temperature ?? xn, r = await fetch("https://api.deepseek.com/v1/chat/completions", {
1204
+ body: JSON.stringify({
1205
+ messages: [{
1206
+ content: yn,
1207
+ role: "system"
1208
+ }, {
1209
+ content: e.prompt,
1210
+ role: "user"
1211
+ }],
1212
+ model: t,
1213
+ response_format: { type: "json_object" },
1214
+ temperature: n
1215
+ }),
1216
+ headers: {
1217
+ Authorization: `Bearer ${e.config.apiKey}`,
1218
+ "Content-Type": "application/json"
1219
+ },
1220
+ method: "POST"
1221
+ });
1222
+ if (!r.ok) {
1223
+ let e = await r.text();
1224
+ throw Error(`DeepSeek API error: ${e}`);
1225
+ }
1226
+ let i = (await r.json()).choices?.[0]?.message?.content;
1227
+ if (!i) throw Error("No response from DeepSeek");
1228
+ return Sn(i);
1229
+ }
1230
+ async function En(e) {
1231
+ let t = e.config.model || bn.claude, n = e.config.temperature ?? xn, r = await fetch("https://api.anthropic.com/v1/messages", {
1232
+ body: JSON.stringify({
1233
+ max_tokens: 4096,
1234
+ messages: [{
1235
+ content: e.prompt,
1236
+ role: "user"
1237
+ }],
1238
+ model: t,
1239
+ system: yn,
1240
+ temperature: n
1241
+ }),
1242
+ headers: {
1243
+ "anthropic-version": "2023-06-01",
1244
+ "Content-Type": "application/json",
1245
+ "x-api-key": e.config.apiKey
1246
+ },
1247
+ method: "POST"
1248
+ });
1249
+ if (!r.ok) {
1250
+ let e = await r.text();
1251
+ throw Error(`Claude API error: ${e}`);
1252
+ }
1253
+ let i = (await r.json()).content?.[0]?.text;
1254
+ if (!i) throw Error("No response from Claude");
1255
+ return Sn(i);
1256
+ }
1257
+ function Dn(e) {
1258
+ switch (e.config.provider) {
1259
+ case "gemini": return Cn(e);
1260
+ case "openai": return wn(e);
1261
+ case "deepseek": return Tn(e);
1262
+ case "claude": return En(e);
1263
+ default: throw Error(`Unsupported AI provider: ${e.config.provider}`);
1264
+ }
1265
+ }
1266
+ //#endregion
1267
+ //#region src/editor/features/TreegeEditor/panel/AIGeneratorDialog.tsx
1268
+ var On = ({ aiConfig: e, onGenerate: t }) => {
1269
+ let [n, r] = F(!1), [i, a] = F(""), [o, s] = F(!1), c = G(), l = async () => {
1270
+ if (!i.trim()) {
1271
+ H.error(c("editor.aiGenerator.enterDescription"));
1272
+ return;
1273
+ }
1274
+ if (!e?.apiKey) {
1275
+ H.error(c("editor.aiGenerator.missingApiKey"), { description: c("editor.aiGenerator.missingApiKeyDesc") });
1276
+ return;
1277
+ }
1278
+ s(!0);
1279
+ try {
1280
+ let n = await Dn({
1281
+ config: e,
1282
+ prompt: i.trim()
1283
+ });
1284
+ t({
1285
+ edges: n.edges,
1286
+ nodes: n.nodes
1287
+ }), H.success(c("editor.aiGenerator.successTitle"), { description: c("editor.aiGenerator.successDescription").replace("{nodes}", String(n.nodes.length)).replace("{edges}", String(n.edges.length)) }), a(""), r(!1);
1288
+ } catch (e) {
1289
+ console.error("AI generation error:", e), H.error(c("editor.aiGenerator.failedToGenerate"), { description: e instanceof Error ? e.message : c("editor.aiGenerator.unknownError") });
1290
+ } finally {
1291
+ s(!1);
1292
+ }
1293
+ };
1294
+ return /* @__PURE__ */ (0, W.jsxs)(ce, {
1295
+ open: n,
1296
+ onOpenChange: r,
1297
+ children: [/* @__PURE__ */ (0, W.jsx)(te, {
1298
+ asChild: !0,
1299
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
1300
+ variant: "outline",
1301
+ size: "sm",
1302
+ disabled: !e?.apiKey,
1303
+ children: [
1304
+ /* @__PURE__ */ (0, W.jsx)(gt, { className: "h-4 w-4 text-[#13d3b4]" }),
1305
+ " ",
1306
+ c("editor.aiGenerator.buttonLabel")
1307
+ ]
1308
+ })
1309
+ }), /* @__PURE__ */ (0, W.jsxs)(C, {
1310
+ className: "sm:max-w-[550px]",
1311
+ children: [
1312
+ /* @__PURE__ */ (0, W.jsxs)(D, { children: [/* @__PURE__ */ (0, W.jsx)(ne, { children: c("editor.aiGenerator.title") }), /* @__PURE__ */ (0, W.jsx)(ee, { children: c("editor.aiGenerator.titleDescription") })] }),
1313
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1314
+ className: "grid gap-4 py-4",
1315
+ children: [/* @__PURE__ */ (0, W.jsxs)("div", {
1316
+ className: "grid gap-2",
1317
+ children: [
1318
+ /* @__PURE__ */ (0, W.jsx)("label", {
1319
+ htmlFor: "ai-prompt",
1320
+ className: "font-medium text-sm",
1321
+ children: c("editor.aiGenerator.description")
1322
+ }),
1323
+ /* @__PURE__ */ (0, W.jsx)(E, {
1324
+ placeholder: c("editor.aiGenerator.descriptionPlaceholder"),
1325
+ value: i,
1326
+ onChange: (e) => a(e.target.value),
1327
+ onKeyDown: (e) => {
1328
+ (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), l());
1329
+ },
1330
+ rows: 6,
1331
+ disabled: o,
1332
+ className: "resize-none"
1333
+ }),
1334
+ /* @__PURE__ */ (0, W.jsx)("p", {
1335
+ className: "text-muted-foreground text-xs",
1336
+ children: c("editor.aiGenerator.keyboardShortcut").replace("{cmdEnter}", "⌘ Enter").replace("{ctrlEnter}", "Ctrl Enter")
1337
+ })
1338
+ ]
1339
+ }), !e?.apiKey && /* @__PURE__ */ (0, W.jsxs)("div", {
1340
+ className: "rounded-md bg-muted p-3 text-sm",
1341
+ children: [/* @__PURE__ */ (0, W.jsx)("p", {
1342
+ className: "font-medium",
1343
+ children: c("editor.aiGenerator.aiNotConfigured")
1344
+ }), /* @__PURE__ */ (0, W.jsxs)("p", {
1345
+ className: "mt-1 text-muted-foreground text-xs",
1346
+ children: [
1347
+ c("editor.aiGenerator.aiNotConfiguredDesc").replace("{code}", ""),
1348
+ " ",
1349
+ /* @__PURE__ */ (0, W.jsx)("code", {
1350
+ className: "rounded bg-background px-1 py-0.5",
1351
+ children: "aiConfig"
1352
+ })
1353
+ ]
1354
+ })]
1355
+ })]
1356
+ }),
1357
+ /* @__PURE__ */ (0, W.jsxs)(ae, { children: [/* @__PURE__ */ (0, W.jsx)(m, {
1358
+ variant: "outline",
1359
+ onClick: () => r(!1),
1360
+ disabled: o,
1361
+ children: c("editor.aiGenerator.cancel")
1362
+ }), /* @__PURE__ */ (0, W.jsx)(m, {
1363
+ onClick: l,
1364
+ disabled: o || !i.trim() || !e?.apiKey,
1365
+ children: o ? /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(tt, { className: "h-4 w-4 animate-spin" }), c("editor.aiGenerator.generating")] }) : /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [/* @__PURE__ */ (0, W.jsx)(gt, { className: "h-4 w-4 text-[--treege-color-primary]" }), c("editor.aiGenerator.generate")] })
1366
+ })] })
1367
+ ]
1368
+ })]
1369
+ });
1370
+ }, kn = nn(), An = ({ onExportJson: e, onSave: t }) => {
1371
+ let { flowId: n, setFlowId: r, aiConfig: i } = jt(), { setNodes: a, setEdges: o, addNodes: s, screenToFlowPosition: c } = M(), l = n || kn, u = Ee(), d = Te(), f = Me(null), p = G(), h = () => {
1372
+ let e = (window.innerWidth || 0) / 2, t = (window.innerHeight || 0) / 2, n = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-width"), 10), r = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--node-height"), 10), i = c({
1373
+ x: e - n,
1374
+ y: t - r
1375
+ });
1376
+ s([{
1377
+ ...rn,
1378
+ id: nn(),
1379
+ position: i,
1380
+ selected: !0
1381
+ }]);
1382
+ }, g = ({ target: e }) => {
1383
+ let t = e.files?.[0];
1384
+ if (!t) return;
1385
+ let n = new FileReader();
1386
+ n.onload = (e) => {
1387
+ try {
1388
+ let t = JSON.parse(e.target?.result);
1389
+ t && Array.isArray(t.nodes) && Array.isArray(t.edges) ? (a(t.nodes), o(t.edges), H.success(p("editor.actionsPanel.importSuccess"), { description: p("editor.actionsPanel.importSuccessDesc") })) : H.error(p("editor.actionsPanel.invalidJson"), { description: p("editor.actionsPanel.invalidJsonDesc") });
1390
+ } catch (e) {
1391
+ console.warn(e), H.error(p("editor.actionsPanel.parseError"), { description: p("editor.actionsPanel.parseErrorDesc") });
1392
+ }
1393
+ f.current && (f.current.value = "");
1394
+ }, n.readAsText(t);
1395
+ }, _ = () => {
1396
+ let t = {
1397
+ edges: d,
1398
+ id: l,
1399
+ nodes: u
1400
+ }, i = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), a = URL.createObjectURL(i), o = document.createElement("a");
1401
+ o.href = a, o.download = "treege.json", o.click(), URL.revokeObjectURL(a), H.success(p("editor.actionsPanel.downloadSuccess"), { description: p("editor.actionsPanel.downloadSuccessDesc") }), n || r?.(l), e?.(t);
1402
+ }, v = N(() => {
1403
+ n || r?.(l), t?.({
1404
+ edges: d,
1405
+ id: l,
1406
+ nodes: u
1407
+ });
1408
+ }, [
1409
+ d,
1410
+ n,
1411
+ l,
1412
+ u,
1413
+ t,
1414
+ r
1415
+ ]);
1416
+ return Ae(() => {
1417
+ let e = (e) => {
1418
+ (e.ctrlKey || e.metaKey) && e.key === "s" && (e.preventDefault(), v());
1419
+ };
1420
+ return window.addEventListener("keydown", e), () => {
1421
+ window.removeEventListener("keydown", e);
1422
+ };
1423
+ }, [v]), /* @__PURE__ */ (0, W.jsxs)(ye, {
1424
+ position: "top-right",
1425
+ className: "flex gap-2",
1426
+ children: [
1427
+ /* @__PURE__ */ (0, W.jsx)(On, {
1428
+ aiConfig: i,
1429
+ onGenerate: (e) => {
1430
+ a(e.nodes), o(e.edges);
1431
+ }
1432
+ }),
1433
+ /* @__PURE__ */ (0, W.jsxs)(m, {
1434
+ variant: "outline",
1435
+ size: "sm",
1436
+ onClick: h,
1437
+ children: [
1438
+ /* @__PURE__ */ (0, W.jsx)(R, {}),
1439
+ " ",
1440
+ p("editor.actionsPanel.addNode")
1441
+ ]
1442
+ }),
1443
+ /* @__PURE__ */ (0, W.jsxs)(m, {
1444
+ variant: "outline",
1445
+ size: "sm",
1446
+ onClick: v,
1447
+ children: [
1448
+ /* @__PURE__ */ (0, W.jsx)(ct, {}),
1449
+ " ",
1450
+ p("common.save")
1451
+ ]
1452
+ }),
1453
+ /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
1454
+ asChild: !0,
1455
+ children: /* @__PURE__ */ (0, W.jsx)(m, {
1456
+ variant: "outline",
1457
+ size: "sm",
1458
+ children: /* @__PURE__ */ (0, W.jsx)(qe, {})
1459
+ })
1460
+ }), /* @__PURE__ */ (0, W.jsxs)(X, {
1461
+ align: "start",
1462
+ children: [
1463
+ /* @__PURE__ */ (0, W.jsx)(Yt, {
1464
+ className: "font-normal",
1465
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
1466
+ className: "flex flex-col gap-1",
1467
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
1468
+ className: "text-muted-foreground text-xs",
1469
+ children: "Flow ID"
1470
+ }), /* @__PURE__ */ (0, W.jsxs)("button", {
1471
+ onClick: async () => {
1472
+ try {
1473
+ await navigator.clipboard.writeText(l), H.success(p("editor.actionsPanel.idCopied"), { description: l });
1474
+ } catch {
1475
+ H.error(p("editor.actionsPanel.copyFailed"));
1476
+ }
1477
+ },
1478
+ className: "flex items-center gap-2 font-mono text-muted-foreground transition-colors hover:text-primary",
1479
+ type: "button",
1480
+ children: [/* @__PURE__ */ (0, W.jsx)(Ge, { className: "h-3 w-3" }), /* @__PURE__ */ (0, W.jsx)("span", {
1481
+ className: "truncate text-xs",
1482
+ children: l
1483
+ })]
1484
+ })]
1485
+ })
1486
+ }),
1487
+ /* @__PURE__ */ (0, W.jsx)(Xt, {}),
1488
+ /* @__PURE__ */ (0, W.jsxs)(Jt, { children: [/* @__PURE__ */ (0, W.jsxs)(Z, {
1489
+ onClick: () => f?.current?.click(),
1490
+ children: [
1491
+ /* @__PURE__ */ (0, W.jsx)(Ke, {}),
1492
+ " ",
1493
+ p("editor.actionsPanel.importJson")
1494
+ ]
1495
+ }), /* @__PURE__ */ (0, W.jsxs)(Z, {
1496
+ onClick: _,
1497
+ children: [
1498
+ /* @__PURE__ */ (0, W.jsx)(Pe, {}),
1499
+ " ",
1500
+ p("editor.actionsPanel.exportJson")
1501
+ ]
1502
+ })] }),
1503
+ /* @__PURE__ */ (0, W.jsx)(Xt, {}),
1504
+ /* @__PURE__ */ (0, W.jsx)(Jt, { children: /* @__PURE__ */ (0, W.jsxs)(Z, {
1505
+ onClick: () => {
1506
+ a([]), o([]), H.success(p("editor.actionsPanel.clearSuccess"), { description: p("editor.actionsPanel.clearSuccessDesc") });
1507
+ },
1508
+ className: "text-destructive focus:text-destructive",
1509
+ children: [
1510
+ /* @__PURE__ */ (0, W.jsx)(pt, { className: "text-destructive" }),
1511
+ " ",
1512
+ p("editor.actionsPanel.clear")
1513
+ ]
1514
+ }) })
1515
+ ]
1516
+ })] }),
1517
+ /* @__PURE__ */ (0, W.jsx)("input", {
1518
+ type: "file",
1519
+ accept: "application/json,.json",
1520
+ className: "hidden",
1521
+ ref: f,
1522
+ onChange: g
1523
+ })
1524
+ ]
1525
+ });
1526
+ }, jn = {
1527
+ ar: "ar",
1528
+ de: "de",
1529
+ en: "en",
1530
+ es: "es",
1531
+ fr: "fr",
1532
+ it: "it",
1533
+ pt: "pt"
1534
+ }, Q = ({ value: e = "en", onValueChange: t }) => /* @__PURE__ */ (0, W.jsxs)(y, {
1535
+ value: e,
1536
+ onValueChange: t,
1537
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
1538
+ className: "uppercase",
1539
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
1540
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: /* @__PURE__ */ (0, W.jsx)(j, { children: Object.values(jn).map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
1541
+ value: e,
1542
+ className: "uppercase",
1543
+ children: e
1544
+ }, e)) }) })]
1545
+ }), $ = () => {
1546
+ let e = Ee(), t = P(() => e.filter(a), [e]), n = P(() => e.filter((e) => e.selected), [e]), r = P(() => e.find((e) => e.selected), [e]);
1547
+ return {
1548
+ groupNodes: t,
1549
+ hasSelectedNodes: n.length > 0,
1550
+ nodes: e,
1551
+ selectedNode: r,
1552
+ selectedNodes: n
1553
+ };
1554
+ }, Mn = () => {
1555
+ let [e, t] = F("en"), { updateSelectedNodeData: n } = q(), { selectedNode: r } = $(), i = G(), { Field: a } = I({
1556
+ defaultValues: {
1557
+ label: r?.data?.label || { en: "" },
1558
+ targetId: r?.data?.targetId || ""
1559
+ },
1560
+ listeners: {
1561
+ onChange: ({ formApi: e }) => {
1562
+ e.handleSubmit().then();
1563
+ },
1564
+ onChangeDebounceMs: 150
1565
+ },
1566
+ onSubmit: ({ value: e }) => {
1567
+ n(e);
1568
+ }
1569
+ });
1570
+ return /* @__PURE__ */ (0, W.jsx)("form", {
1571
+ onSubmit: (e) => {
1572
+ e.preventDefault(), e.stopPropagation();
1573
+ },
1574
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
1575
+ className: "grid gap-6",
1576
+ children: [/* @__PURE__ */ (0, W.jsxs)("div", {
1577
+ className: "flex items-end gap-2",
1578
+ children: [/* @__PURE__ */ (0, W.jsx)(a, {
1579
+ name: "label",
1580
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
1581
+ className: "flex-1",
1582
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
1583
+ htmlFor: t.name,
1584
+ children: i("editor.flowNodeForm.label")
1585
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
1586
+ id: t.name,
1587
+ name: t.name,
1588
+ value: t.state.value?.[e] || "",
1589
+ onBlur: t.handleBlur,
1590
+ onChange: ({ target: n }) => {
1591
+ t.handleChange({
1592
+ ...t.state.value,
1593
+ [e]: n.value
1594
+ });
1595
+ }
1596
+ })]
1597
+ })
1598
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
1599
+ value: e,
1600
+ onValueChange: t
1601
+ })]
1602
+ }), /* @__PURE__ */ (0, W.jsx)(a, {
1603
+ name: "targetId",
1604
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1605
+ /* @__PURE__ */ (0, W.jsxs)(u, {
1606
+ htmlFor: e.name,
1607
+ children: [i("editor.flowNodeForm.targetId"), " (Flow ID)"]
1608
+ }),
1609
+ /* @__PURE__ */ (0, W.jsx)(h, {
1610
+ id: e.name,
1611
+ name: e.name,
1612
+ value: e.state.value,
1613
+ onBlur: e.handleBlur,
1614
+ onChange: ({ target: t }) => e.handleChange(t.value)
1615
+ }),
1616
+ /* @__PURE__ */ (0, W.jsx)(T, { children: "Unique identifier of the target flow." })
1617
+ ] })
1618
+ })]
1619
+ })
1620
+ });
1621
+ }, Nn = () => {
1622
+ let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = q(), { Field: i } = I({
1623
+ defaultValues: { label: n?.data?.label || { en: "" } },
1624
+ listeners: {
1625
+ onChange: ({ formApi: e }) => {
1626
+ e.handleSubmit().then();
1627
+ },
1628
+ onChangeDebounceMs: 150
1629
+ },
1630
+ onSubmit: ({ value: e }) => {
1631
+ r(e);
1632
+ }
1633
+ });
1634
+ return /* @__PURE__ */ (0, W.jsx)("form", {
1635
+ onSubmit: (e) => {
1636
+ e.preventDefault(), e.stopPropagation();
1637
+ },
1638
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
1639
+ className: "flex items-end gap-2",
1640
+ children: [/* @__PURE__ */ (0, W.jsx)(i, {
1641
+ name: "label",
1642
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
1643
+ className: "flex-1",
1644
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
1645
+ htmlFor: t.name,
1646
+ children: "Label"
1647
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
1648
+ id: t.name,
1649
+ name: t.name,
1650
+ value: t.state.value?.[e] || "",
1651
+ onBlur: t.handleBlur,
1652
+ onChange: ({ target: n }) => {
1653
+ t.handleChange({
1654
+ ...t.state.value,
1655
+ [e]: n.value
1656
+ });
1657
+ }
1658
+ })]
1659
+ })
1660
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
1661
+ value: e,
1662
+ onValueChange: t
1663
+ })]
1664
+ })
1665
+ });
1666
+ }, Pn = [
1667
+ "POST",
1668
+ "PUT",
1669
+ "PATCH"
1670
+ ], Fn = ({ value: e, onChange: t }) => {
1671
+ let { selectedNode: n } = $(), r = G(), i = Ot(n?.id), { handleSubmit: a, Field: o, Subscribe: s } = I({
1672
+ defaultValues: {
1673
+ body: e?.body || "",
1674
+ fetchOnMount: e?.fetchOnMount ?? !e?.searchParam,
1675
+ headers: e?.headers || [],
1676
+ method: e?.method || "GET",
1677
+ responseMapping: e?.responseMapping || {
1678
+ labelField: "",
1679
+ valueField: ""
1680
+ },
1681
+ responsePath: e?.responsePath || "",
1682
+ searchParam: e?.searchParam || "",
1683
+ sendAllFormValues: !!e?.sendAllFormValues,
1684
+ showLoading: e?.showLoading !== !1,
1685
+ url: e?.url || ""
1686
+ },
1687
+ listeners: {
1688
+ onChange: ({ formApi: e }) => {
1689
+ e.handleSubmit().then();
1690
+ },
1691
+ onChangeDebounceMs: 150
1692
+ },
1693
+ onSubmit: ({ value: e }) => {
1694
+ t(e);
1695
+ }
1696
+ });
1697
+ return /* @__PURE__ */ (0, W.jsx)("div", { children: /* @__PURE__ */ (0, W.jsxs)("div", {
1698
+ className: "grid gap-6",
1699
+ children: [
1700
+ /* @__PURE__ */ (0, W.jsx)(o, {
1701
+ name: "url",
1702
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1703
+ /* @__PURE__ */ (0, W.jsx)(u, {
1704
+ htmlFor: e.name,
1705
+ children: r("editor.httpConfigForm.apiUrl")
1706
+ }),
1707
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1708
+ className: "flex gap-2",
1709
+ children: [/* @__PURE__ */ (0, W.jsx)(h, {
1710
+ id: e.name,
1711
+ name: e.name,
1712
+ value: e.state.value,
1713
+ onBlur: e.handleBlur,
1714
+ onChange: ({ target: t }) => e.handleChange(t.value),
1715
+ placeholder: r("editor.httpConfigForm.apiUrlPlaceholder"),
1716
+ className: "flex-1"
1717
+ }), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
1718
+ asChild: !0,
1719
+ children: /* @__PURE__ */ (0, W.jsx)(m, {
1720
+ type: "button",
1721
+ variant: "outline",
1722
+ size: "icon",
1723
+ children: /* @__PURE__ */ (0, W.jsx)(ht, { className: "h-4 w-4" })
1724
+ })
1725
+ }), /* @__PURE__ */ (0, W.jsx)(X, {
1726
+ align: "end",
1727
+ children: i.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
1728
+ disabled: !0,
1729
+ children: r("editor.httpConfigForm.noFieldsAvailable")
1730
+ }) : i.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
1731
+ onClick: () => {
1732
+ let n = `{{${t.nodeId}}}`, r = e.state.value || "";
1733
+ e.handleChange(r + n);
1734
+ },
1735
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
1736
+ className: "flex flex-col",
1737
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
1738
+ className: "font-medium",
1739
+ children: t.label
1740
+ }), /* @__PURE__ */ (0, W.jsx)("span", {
1741
+ className: "text-muted-foreground text-xs",
1742
+ children: `{{${t.nodeId}}}`
1743
+ })]
1744
+ })
1745
+ }, t.nodeId))
1746
+ })] })]
1747
+ }),
1748
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r("editor.httpConfigForm.apiUrlDesc") })
1749
+ ] })
1750
+ }),
1751
+ /* @__PURE__ */ (0, W.jsx)(o, {
1752
+ name: "method",
1753
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
1754
+ htmlFor: e.name,
1755
+ children: r("editor.httpConfigForm.httpMethod")
1756
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
1757
+ value: e.state.value,
1758
+ onValueChange: (t) => e.handleChange(t),
1759
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
1760
+ id: e.name,
1761
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: r("editor.httpConfigForm.selectMethod") })
1762
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [
1763
+ /* @__PURE__ */ (0, W.jsx)(x, {
1764
+ value: "GET",
1765
+ children: r("editor.httpConfigForm.methodGet")
1766
+ }),
1767
+ /* @__PURE__ */ (0, W.jsx)(x, {
1768
+ value: "POST",
1769
+ children: r("editor.httpConfigForm.methodPost")
1770
+ }),
1771
+ /* @__PURE__ */ (0, W.jsx)(x, {
1772
+ value: "PUT",
1773
+ children: r("editor.httpConfigForm.methodPut")
1774
+ }),
1775
+ /* @__PURE__ */ (0, W.jsx)(x, {
1776
+ value: "DELETE",
1777
+ children: r("editor.httpConfigForm.methodDelete")
1778
+ }),
1779
+ /* @__PURE__ */ (0, W.jsx)(x, {
1780
+ value: "PATCH",
1781
+ children: r("editor.httpConfigForm.methodPatch")
1782
+ })
1783
+ ] })]
1784
+ })] })
1785
+ }),
1786
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1787
+ className: "space-y-4",
1788
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
1789
+ className: "font-semibold text-sm",
1790
+ children: r("editor.httpConfigForm.headers")
1791
+ }), /* @__PURE__ */ (0, W.jsx)(o, {
1792
+ name: "headers",
1793
+ mode: "array",
1794
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
1795
+ className: "space-y-2",
1796
+ children: [e.state.value?.map((t, n) => {
1797
+ let i = `headers[${n}]`;
1798
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
1799
+ className: "flex items-start gap-2",
1800
+ children: [
1801
+ /* @__PURE__ */ (0, W.jsx)(o, {
1802
+ name: `headers[${n}].key`,
1803
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
1804
+ placeholder: r("editor.httpConfigForm.headerName"),
1805
+ value: e.state.value || "",
1806
+ onChange: ({ target: t }) => e.handleChange(t.value)
1807
+ })
1808
+ }),
1809
+ /* @__PURE__ */ (0, W.jsx)(o, {
1810
+ name: `headers[${n}].value`,
1811
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
1812
+ placeholder: r("editor.httpConfigForm.headerValue"),
1813
+ value: e.state.value || "",
1814
+ onChange: ({ target: t }) => e.handleChange(t.value)
1815
+ })
1816
+ }),
1817
+ /* @__PURE__ */ (0, W.jsx)(m, {
1818
+ type: "button",
1819
+ variant: "ghost",
1820
+ size: "icon",
1821
+ onClick: () => {
1822
+ e.removeValue(n);
1823
+ },
1824
+ children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
1825
+ })
1826
+ ]
1827
+ }, i);
1828
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
1829
+ type: "button",
1830
+ variant: "outline",
1831
+ size: "sm",
1832
+ onClick: () => {
1833
+ e.pushValue({
1834
+ key: "",
1835
+ value: ""
1836
+ });
1837
+ },
1838
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.addHeader")]
1839
+ })]
1840
+ })
1841
+ })]
1842
+ }),
1843
+ /* @__PURE__ */ (0, W.jsx)(s, {
1844
+ selector: (e) => ({
1845
+ method: e.values.method,
1846
+ sendAllFormValues: e.values.sendAllFormValues
1847
+ }),
1848
+ children: ({ method: e, sendAllFormValues: t }) => Pn.includes(e || "") && /* @__PURE__ */ (0, W.jsxs)("div", {
1849
+ className: "space-y-4",
1850
+ children: [/* @__PURE__ */ (0, W.jsx)(o, {
1851
+ name: "sendAllFormValues",
1852
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
1853
+ className: "flex items-center space-x-2",
1854
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
1855
+ id: e.name,
1856
+ checked: e.state.value,
1857
+ onCheckedChange: (t) => e.handleChange(t)
1858
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
1859
+ htmlFor: e.name,
1860
+ children: r("editor.httpConfigForm.sendAllFormValues")
1861
+ })]
1862
+ })
1863
+ }), /* @__PURE__ */ (0, W.jsx)(o, {
1864
+ name: "body",
1865
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1866
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1867
+ className: "mb-2 flex items-center justify-between",
1868
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
1869
+ htmlFor: e.name,
1870
+ children: r("editor.httpConfigForm.requestBody")
1871
+ }), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
1872
+ asChild: !0,
1873
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
1874
+ type: "button",
1875
+ variant: "ghost",
1876
+ size: "sm",
1877
+ disabled: t,
1878
+ children: [/* @__PURE__ */ (0, W.jsx)(ht, { className: "mr-2 h-4 w-4" }), r("editor.httpConfigForm.insertVariable")]
1879
+ })
1880
+ }), /* @__PURE__ */ (0, W.jsx)(X, {
1881
+ align: "end",
1882
+ children: i.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
1883
+ disabled: !0,
1884
+ children: r("editor.httpConfigForm.noFieldsAvailable")
1885
+ }) : i.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
1886
+ onClick: () => {
1887
+ let n = `{{${t.nodeId}}}`, r = e.state.value || "";
1888
+ e.handleChange(r + n), a().then();
1889
+ },
1890
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
1891
+ className: "flex flex-col",
1892
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
1893
+ className: "font-medium",
1894
+ children: t.label
1895
+ }), /* @__PURE__ */ (0, W.jsx)("span", {
1896
+ className: "text-muted-foreground text-xs",
1897
+ children: `{{${t.nodeId}}}`
1898
+ })]
1899
+ })
1900
+ }, t.nodeId))
1901
+ })] })]
1902
+ }),
1903
+ /* @__PURE__ */ (0, W.jsx)(E, {
1904
+ id: e.name,
1905
+ name: e.name,
1906
+ value: e.state.value,
1907
+ onBlur: e.handleBlur,
1908
+ onChange: ({ target: t }) => e.handleChange(t.value),
1909
+ placeholder: r("editor.httpConfigForm.requestBodyPlaceholder"),
1910
+ rows: 4,
1911
+ disabled: t
1912
+ }),
1913
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r(t ? "editor.httpConfigForm.sendAllFormValuesDesc" : "editor.httpConfigForm.requestBodyDesc") })
1914
+ ] })
1915
+ })]
1916
+ })
1917
+ }),
1918
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1919
+ className: "space-y-4",
1920
+ children: [
1921
+ /* @__PURE__ */ (0, W.jsx)("h4", {
1922
+ className: "font-semibold text-sm",
1923
+ children: r("editor.httpConfigForm.responseConfiguration")
1924
+ }),
1925
+ /* @__PURE__ */ (0, W.jsx)(o, {
1926
+ name: "responsePath",
1927
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1928
+ /* @__PURE__ */ (0, W.jsx)(u, {
1929
+ htmlFor: e.name,
1930
+ children: r("editor.httpConfigForm.responsePath")
1931
+ }),
1932
+ /* @__PURE__ */ (0, W.jsx)(h, {
1933
+ id: e.name,
1934
+ name: e.name,
1935
+ value: e.state.value,
1936
+ onBlur: e.handleBlur,
1937
+ onChange: ({ target: t }) => e.handleChange(t.value),
1938
+ placeholder: r("editor.httpConfigForm.responsePathPlaceholder")
1939
+ }),
1940
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r("editor.httpConfigForm.responsePathDesc") })
1941
+ ] })
1942
+ }),
1943
+ /* @__PURE__ */ (0, W.jsxs)("div", {
1944
+ className: "space-y-4",
1945
+ children: [
1946
+ /* @__PURE__ */ (0, W.jsx)("h5", {
1947
+ className: "font-medium text-sm",
1948
+ children: r("editor.httpConfigForm.mapToOptions")
1949
+ }),
1950
+ /* @__PURE__ */ (0, W.jsx)(o, {
1951
+ name: "responseMapping.valueField",
1952
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1953
+ /* @__PURE__ */ (0, W.jsx)(u, {
1954
+ htmlFor: e.name,
1955
+ children: r("editor.httpConfigForm.valueField")
1956
+ }),
1957
+ /* @__PURE__ */ (0, W.jsx)(h, {
1958
+ id: e.name,
1959
+ name: e.name,
1960
+ value: e.state.value,
1961
+ onBlur: e.handleBlur,
1962
+ onChange: ({ target: t }) => e.handleChange(t.value),
1963
+ placeholder: r("editor.httpConfigForm.valueFieldPlaceholder")
1964
+ }),
1965
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r("editor.httpConfigForm.valueFieldDesc") })
1966
+ ] })
1967
+ }),
1968
+ /* @__PURE__ */ (0, W.jsx)(o, {
1969
+ name: "responseMapping.labelField",
1970
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1971
+ /* @__PURE__ */ (0, W.jsx)(u, {
1972
+ htmlFor: e.name,
1973
+ children: r("editor.httpConfigForm.labelField")
1974
+ }),
1975
+ /* @__PURE__ */ (0, W.jsx)(h, {
1976
+ id: e.name,
1977
+ name: e.name,
1978
+ value: e.state.value,
1979
+ onBlur: e.handleBlur,
1980
+ onChange: ({ target: t }) => e.handleChange(t.value),
1981
+ placeholder: r("editor.httpConfigForm.labelFieldPlaceholder")
1982
+ }),
1983
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r("editor.httpConfigForm.labelFieldDesc") })
1984
+ ] })
1985
+ })
1986
+ ]
1987
+ }),
1988
+ /* @__PURE__ */ (0, W.jsx)(o, {
1989
+ name: "searchParam",
1990
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
1991
+ /* @__PURE__ */ (0, W.jsx)(u, {
1992
+ htmlFor: e.name,
1993
+ children: r("editor.httpConfigForm.searchParameter")
1994
+ }),
1995
+ /* @__PURE__ */ (0, W.jsx)(h, {
1996
+ id: e.name,
1997
+ name: e.name,
1998
+ value: e.state.value,
1999
+ onBlur: e.handleBlur,
2000
+ onChange: ({ target: t }) => e.handleChange(t.value),
2001
+ placeholder: r("editor.httpConfigForm.searchParameterPlaceholder")
2002
+ }),
2003
+ /* @__PURE__ */ (0, W.jsx)(T, { children: r("editor.httpConfigForm.searchParameterDesc") })
2004
+ ] })
2005
+ })
2006
+ ]
2007
+ }),
2008
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2009
+ className: "space-y-4",
2010
+ children: [
2011
+ /* @__PURE__ */ (0, W.jsx)("h4", {
2012
+ className: "font-semibold text-sm",
2013
+ children: r("editor.httpConfigForm.behavior")
2014
+ }),
2015
+ /* @__PURE__ */ (0, W.jsx)(s, {
2016
+ selector: (e) => e.values.searchParam,
2017
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(o, {
2018
+ name: "fetchOnMount",
2019
+ children: (t) => {
2020
+ let n = !!e?.trim(), i = n ? t.state.value : !0;
2021
+ return !n && t.state.value !== !0 && t.handleChange(!0), /* @__PURE__ */ (0, W.jsxs)("div", {
2022
+ className: "flex items-center space-x-2",
2023
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2024
+ id: t.name,
2025
+ checked: i,
2026
+ disabled: !n,
2027
+ onCheckedChange: (e) => t.handleChange(e)
2028
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2029
+ htmlFor: t.name,
2030
+ className: n ? "" : "text-muted-foreground",
2031
+ children: r("editor.httpConfigForm.fetchOnMount")
2032
+ })]
2033
+ });
2034
+ }
2035
+ })
2036
+ }),
2037
+ /* @__PURE__ */ (0, W.jsx)(o, {
2038
+ name: "showLoading",
2039
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2040
+ className: "flex items-center space-x-2",
2041
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2042
+ id: e.name,
2043
+ checked: e.state.value,
2044
+ onCheckedChange: (t) => e.handleChange(t)
2045
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2046
+ htmlFor: e.name,
2047
+ children: r("editor.httpConfigForm.showLoadingState")
2048
+ })]
2049
+ })
2050
+ })
2051
+ ]
2052
+ })
2053
+ ]
2054
+ }) });
2055
+ }, In = [
2056
+ "POST",
2057
+ "PUT",
2058
+ "PATCH"
2059
+ ], Ln = ({ value: e, onChange: t }) => {
2060
+ let [n, r] = F("en"), { selectedNode: i } = $(), a = G(), o = Ot(i?.id), { handleSubmit: s, Field: c, Subscribe: d } = I({
2061
+ defaultValues: {
2062
+ body: e?.body || "",
2063
+ errorMessage: e?.errorMessage || { en: "" },
2064
+ headers: e?.headers || [],
2065
+ method: e?.method || "POST",
2066
+ redirectUrl: e?.redirectUrl || "",
2067
+ sendAllFormValues: !!e?.sendAllFormValues,
2068
+ showLoading: e?.showLoading !== !1,
2069
+ successMessage: e?.successMessage || { en: "" },
2070
+ url: e?.url || ""
2071
+ },
2072
+ listeners: {
2073
+ onChange: ({ formApi: e }) => {
2074
+ e.handleSubmit().then();
2075
+ },
2076
+ onChangeDebounceMs: 150
2077
+ },
2078
+ onSubmit: ({ value: e }) => {
2079
+ t(e);
2080
+ }
2081
+ });
2082
+ return /* @__PURE__ */ (0, W.jsx)("div", { children: /* @__PURE__ */ (0, W.jsxs)("div", {
2083
+ className: "grid gap-6",
2084
+ children: [
2085
+ /* @__PURE__ */ (0, W.jsx)(c, {
2086
+ name: "url",
2087
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
2088
+ /* @__PURE__ */ (0, W.jsx)(u, {
2089
+ htmlFor: e.name,
2090
+ children: a("editor.submitConfigForm.apiUrl")
2091
+ }),
2092
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2093
+ className: "flex gap-2",
2094
+ children: [/* @__PURE__ */ (0, W.jsx)(h, {
2095
+ id: e.name,
2096
+ name: e.name,
2097
+ value: e.state.value,
2098
+ onBlur: e.handleBlur,
2099
+ onChange: ({ target: t }) => e.handleChange(t.value),
2100
+ placeholder: a("editor.submitConfigForm.apiUrlPlaceholder"),
2101
+ className: "flex-1"
2102
+ }), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
2103
+ asChild: !0,
2104
+ children: /* @__PURE__ */ (0, W.jsx)(m, {
2105
+ type: "button",
2106
+ variant: "outline",
2107
+ size: "icon",
2108
+ children: /* @__PURE__ */ (0, W.jsx)(ht, { className: "h-4 w-4" })
2109
+ })
2110
+ }), /* @__PURE__ */ (0, W.jsx)(X, {
2111
+ align: "end",
2112
+ children: o.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
2113
+ disabled: !0,
2114
+ children: a("editor.submitConfigForm.noFieldsAvailable")
2115
+ }) : o.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
2116
+ onClick: () => {
2117
+ let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2118
+ e.handleChange(r + n);
2119
+ },
2120
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2121
+ className: "flex flex-col",
2122
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
2123
+ className: "font-medium",
2124
+ children: t.label
2125
+ }), /* @__PURE__ */ (0, W.jsx)("span", {
2126
+ className: "text-muted-foreground text-xs",
2127
+ children: `{{${t.nodeId}}}`
2128
+ })]
2129
+ })
2130
+ }, t.nodeId))
2131
+ })] })]
2132
+ }),
2133
+ /* @__PURE__ */ (0, W.jsx)(T, { children: a("editor.submitConfigForm.apiUrlDesc") })
2134
+ ] })
2135
+ }),
2136
+ /* @__PURE__ */ (0, W.jsx)(c, {
2137
+ name: "method",
2138
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
2139
+ htmlFor: e.name,
2140
+ children: a("editor.submitConfigForm.httpMethod")
2141
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
2142
+ value: e.state.value,
2143
+ onValueChange: (t) => e.handleChange(t),
2144
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
2145
+ id: e.name,
2146
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: a("editor.submitConfigForm.selectMethod") })
2147
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [
2148
+ /* @__PURE__ */ (0, W.jsx)(x, {
2149
+ value: "POST",
2150
+ children: a("editor.submitConfigForm.methodPost")
2151
+ }),
2152
+ /* @__PURE__ */ (0, W.jsx)(x, {
2153
+ value: "PUT",
2154
+ children: a("editor.submitConfigForm.methodPut")
2155
+ }),
2156
+ /* @__PURE__ */ (0, W.jsx)(x, {
2157
+ value: "DELETE",
2158
+ children: a("editor.submitConfigForm.methodDelete")
2159
+ }),
2160
+ /* @__PURE__ */ (0, W.jsx)(x, {
2161
+ value: "PATCH",
2162
+ children: a("editor.submitConfigForm.methodPatch")
2163
+ })
2164
+ ] })]
2165
+ })] })
2166
+ }),
2167
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2168
+ className: "space-y-4",
2169
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
2170
+ className: "font-semibold text-sm",
2171
+ children: a("editor.submitConfigForm.headers")
2172
+ }), /* @__PURE__ */ (0, W.jsx)(c, {
2173
+ name: "headers",
2174
+ mode: "array",
2175
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2176
+ className: "space-y-2",
2177
+ children: [e.state.value?.map((t, n) => {
2178
+ let r = `headers[${n}]`;
2179
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
2180
+ className: "flex items-start gap-2",
2181
+ children: [
2182
+ /* @__PURE__ */ (0, W.jsx)(c, {
2183
+ name: `headers[${n}].key`,
2184
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
2185
+ placeholder: a("editor.submitConfigForm.headerName"),
2186
+ value: e.state.value || "",
2187
+ onChange: ({ target: t }) => e.handleChange(t.value)
2188
+ })
2189
+ }),
2190
+ /* @__PURE__ */ (0, W.jsx)(c, {
2191
+ name: `headers[${n}].value`,
2192
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
2193
+ placeholder: a("editor.submitConfigForm.headerValue"),
2194
+ value: e.state.value || "",
2195
+ onChange: ({ target: t }) => e.handleChange(t.value)
2196
+ })
2197
+ }),
2198
+ /* @__PURE__ */ (0, W.jsx)(m, {
2199
+ type: "button",
2200
+ variant: "ghost",
2201
+ size: "icon",
2202
+ onClick: () => {
2203
+ e.removeValue(n);
2204
+ },
2205
+ children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
2206
+ })
2207
+ ]
2208
+ }, r);
2209
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
2210
+ type: "button",
2211
+ variant: "outline",
2212
+ size: "sm",
2213
+ onClick: () => {
2214
+ e.pushValue({
2215
+ key: "",
2216
+ value: ""
2217
+ });
2218
+ },
2219
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.addHeader")]
2220
+ })]
2221
+ })
2222
+ })]
2223
+ }),
2224
+ /* @__PURE__ */ (0, W.jsx)(d, {
2225
+ selector: (e) => ({
2226
+ method: e.values.method,
2227
+ sendAllFormValues: e.values.sendAllFormValues
2228
+ }),
2229
+ children: ({ method: e, sendAllFormValues: t }) => In.includes(e || "") && /* @__PURE__ */ (0, W.jsxs)("div", {
2230
+ className: "space-y-4",
2231
+ children: [/* @__PURE__ */ (0, W.jsx)(c, {
2232
+ name: "sendAllFormValues",
2233
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2234
+ className: "flex items-center space-x-2",
2235
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2236
+ id: e.name,
2237
+ checked: e.state.value,
2238
+ onCheckedChange: (t) => e.handleChange(t)
2239
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2240
+ htmlFor: e.name,
2241
+ children: a("editor.submitConfigForm.sendAllFormValues")
2242
+ })]
2243
+ })
2244
+ }), /* @__PURE__ */ (0, W.jsx)(c, {
2245
+ name: "body",
2246
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
2247
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2248
+ className: "mb-2 flex items-center justify-between",
2249
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
2250
+ htmlFor: e.name,
2251
+ children: a("editor.submitConfigForm.requestBody")
2252
+ }), /* @__PURE__ */ (0, W.jsxs)(J, { children: [/* @__PURE__ */ (0, W.jsx)(Y, {
2253
+ asChild: !0,
2254
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
2255
+ type: "button",
2256
+ variant: "ghost",
2257
+ size: "sm",
2258
+ disabled: t,
2259
+ children: [/* @__PURE__ */ (0, W.jsx)(ht, { className: "mr-2 h-4 w-4" }), a("editor.submitConfigForm.insertVariable")]
2260
+ })
2261
+ }), /* @__PURE__ */ (0, W.jsx)(X, {
2262
+ align: "end",
2263
+ children: o.length === 0 ? /* @__PURE__ */ (0, W.jsx)(Z, {
2264
+ disabled: !0,
2265
+ children: a("editor.submitConfigForm.noFieldsAvailable")
2266
+ }) : o.map((t) => /* @__PURE__ */ (0, W.jsx)(Z, {
2267
+ onClick: () => {
2268
+ let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2269
+ e.handleChange(r + n), s().then();
2270
+ },
2271
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2272
+ className: "flex flex-col",
2273
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
2274
+ className: "font-medium",
2275
+ children: t.label
2276
+ }), /* @__PURE__ */ (0, W.jsx)("span", {
2277
+ className: "text-muted-foreground text-xs",
2278
+ children: `{{${t.nodeId}}}`
2279
+ })]
2280
+ })
2281
+ }, t.nodeId))
2282
+ })] })]
2283
+ }),
2284
+ /* @__PURE__ */ (0, W.jsx)(E, {
2285
+ id: e.name,
2286
+ name: e.name,
2287
+ value: e.state.value,
2288
+ onBlur: e.handleBlur,
2289
+ onChange: ({ target: t }) => e.handleChange(t.value),
2290
+ placeholder: a("editor.submitConfigForm.requestBodyPlaceholder"),
2291
+ rows: 4,
2292
+ disabled: t
2293
+ }),
2294
+ /* @__PURE__ */ (0, W.jsx)(T, { children: a(t ? "editor.submitConfigForm.sendAllFormValuesDesc" : "editor.submitConfigForm.requestBodyDesc") })
2295
+ ] })
2296
+ })]
2297
+ })
2298
+ }),
2299
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2300
+ className: "space-y-4",
2301
+ children: [
2302
+ /* @__PURE__ */ (0, W.jsx)("h4", {
2303
+ className: "font-semibold text-sm",
2304
+ children: a("editor.submitConfigForm.postSubmission")
2305
+ }),
2306
+ /* @__PURE__ */ (0, W.jsx)(c, {
2307
+ name: "redirectUrl",
2308
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
2309
+ /* @__PURE__ */ (0, W.jsx)(u, {
2310
+ htmlFor: e.name,
2311
+ children: a("editor.submitConfigForm.redirectUrl")
2312
+ }),
2313
+ /* @__PURE__ */ (0, W.jsx)(h, {
2314
+ id: e.name,
2315
+ name: e.name,
2316
+ value: e.state.value,
2317
+ onBlur: e.handleBlur,
2318
+ onChange: ({ target: t }) => e.handleChange(t.value),
2319
+ placeholder: a("editor.submitConfigForm.redirectUrlPlaceholder")
2320
+ }),
2321
+ /* @__PURE__ */ (0, W.jsx)(T, { children: a("editor.submitConfigForm.redirectUrlDesc") })
2322
+ ] })
2323
+ }),
2324
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2325
+ className: "flex items-center gap-2",
2326
+ children: [/* @__PURE__ */ (0, W.jsx)(c, {
2327
+ name: "successMessage",
2328
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, {
2329
+ className: "flex-1",
2330
+ children: [
2331
+ /* @__PURE__ */ (0, W.jsx)(u, {
2332
+ htmlFor: e.name,
2333
+ children: a("editor.submitConfigForm.successMessage")
2334
+ }),
2335
+ /* @__PURE__ */ (0, W.jsx)(h, {
2336
+ id: e.name,
2337
+ name: e.name,
2338
+ value: e.state.value?.[n] || "",
2339
+ onBlur: e.handleBlur,
2340
+ onChange: ({ target: t }) => {
2341
+ e.handleChange({
2342
+ ...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
2343
+ [n]: t.value
2344
+ });
2345
+ },
2346
+ placeholder: a("editor.submitConfigForm.successMessagePlaceholder")
2347
+ }),
2348
+ /* @__PURE__ */ (0, W.jsx)(T, { children: a("editor.submitConfigForm.successMessageDesc") })
2349
+ ]
2350
+ })
2351
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
2352
+ value: n,
2353
+ onValueChange: r
2354
+ })]
2355
+ }),
2356
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2357
+ className: "flex items-center gap-2",
2358
+ children: [/* @__PURE__ */ (0, W.jsx)(c, {
2359
+ name: "errorMessage",
2360
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, {
2361
+ className: "flex-1",
2362
+ children: [
2363
+ /* @__PURE__ */ (0, W.jsx)(u, {
2364
+ htmlFor: e.name,
2365
+ children: a("editor.submitConfigForm.errorMessage")
2366
+ }),
2367
+ /* @__PURE__ */ (0, W.jsx)(h, {
2368
+ id: e.name,
2369
+ name: e.name,
2370
+ value: e.state.value?.[n] || "",
2371
+ onBlur: e.handleBlur,
2372
+ onChange: ({ target: t }) => {
2373
+ e.handleChange({
2374
+ ...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
2375
+ [n]: t.value
2376
+ });
2377
+ },
2378
+ placeholder: a("editor.submitConfigForm.errorMessagePlaceholder")
2379
+ }),
2380
+ /* @__PURE__ */ (0, W.jsx)(T, { children: a("editor.submitConfigForm.errorMessageDesc") })
2381
+ ]
2382
+ })
2383
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
2384
+ value: n,
2385
+ onValueChange: r
2386
+ })]
2387
+ })
2388
+ ]
2389
+ }),
2390
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2391
+ className: "space-y-4",
2392
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
2393
+ className: "font-semibold text-sm",
2394
+ children: a("editor.submitConfigForm.behavior")
2395
+ }), /* @__PURE__ */ (0, W.jsx)(c, {
2396
+ name: "showLoading",
2397
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2398
+ className: "flex items-center space-x-2",
2399
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2400
+ id: e.name,
2401
+ checked: e.state.value,
2402
+ onCheckedChange: (t) => e.handleChange(t)
2403
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2404
+ htmlFor: e.name,
2405
+ children: a("editor.submitConfigForm.showLoadingState")
2406
+ })]
2407
+ })
2408
+ })]
2409
+ })
2410
+ ]
2411
+ }) });
2412
+ }, Rn = ({ options: e, id: t, value: n, onValueChange: r, placeholder: i = "Select...", searchPlaceholder: a = "Search or create...", createLabel: o = (e) => `Use: ${e}`, clearLabel: s = "Clear selection", emptyLabel: c = "No results found", className: l, allowClear: u = !0, allowCreate: p = !0 }) => {
2413
+ let [h, g] = F(!1), [_, y] = F(""), x = (e) => e ?? "", S = (e) => e.trim().toLowerCase(), C = x(n), ee = n !== null && n !== "", te = ee ? e.find((e) => x(e.value) === C) : void 0, ne = S(_), w = p && ne !== "" && !e.some((e) => S(e.label) === ne || S(e.value ?? "") === ne), T = (e) => {
2414
+ e === C ? u && r?.("") : r?.(e), g(!1), y("");
2415
+ }, E = () => {
2416
+ _.trim() && (r?.(_.trim()), g(!1), y(""));
2417
+ }, D = () => {
2418
+ r?.(""), g(!1), y("");
2419
+ };
2420
+ return /* @__PURE__ */ (0, W.jsxs)(le, {
2421
+ open: h,
2422
+ onOpenChange: g,
2423
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
2424
+ asChild: !0,
2425
+ id: t,
2426
+ children: /* @__PURE__ */ (0, W.jsxs)(m, {
2427
+ type: "button",
2428
+ variant: "outline",
2429
+ role: "combobox",
2430
+ "aria-expanded": h,
2431
+ className: f("w-full justify-between font-normal", l),
2432
+ children: [/* @__PURE__ */ (0, W.jsx)("span", {
2433
+ className: "truncate",
2434
+ children: ee && te ? te.label : i
2435
+ }), /* @__PURE__ */ (0, W.jsx)(L, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
2436
+ })
2437
+ }), /* @__PURE__ */ (0, W.jsx)(v, {
2438
+ className: "w-full p-0",
2439
+ align: "start",
2440
+ children: /* @__PURE__ */ (0, W.jsxs)(O, {
2441
+ shouldFilter: !1,
2442
+ children: [/* @__PURE__ */ (0, W.jsx)(b, {
2443
+ placeholder: a,
2444
+ value: _,
2445
+ onValueChange: y
2446
+ }), /* @__PURE__ */ (0, W.jsxs)(oe, { children: [
2447
+ /* @__PURE__ */ (0, W.jsx)(k, { children: c }),
2448
+ u && ee && /* @__PURE__ */ (0, W.jsx)(re, { children: /* @__PURE__ */ (0, W.jsxs)(ie, {
2449
+ value: "__clear__",
2450
+ onSelect: D,
2451
+ className: "mt-1 text-muted-foreground",
2452
+ children: [/* @__PURE__ */ (0, W.jsx)(z, { className: "mr-2 h-4 w-4" }), s]
2453
+ }) }),
2454
+ /* @__PURE__ */ (0, W.jsxs)(re, { children: [w && /* @__PURE__ */ (0, W.jsxs)(ie, {
2455
+ value: `__create__${_}`,
2456
+ onSelect: E,
2457
+ className: "text-primary",
2458
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), o(_)]
2459
+ }), e.filter((e) => {
2460
+ let t = _.toLowerCase();
2461
+ return e.label.toLowerCase().includes(t) || (e.value?.toLowerCase() ?? "").includes(t);
2462
+ }).map((e, t) => /* @__PURE__ */ (0, W.jsxs)(ie, {
2463
+ value: e.label,
2464
+ onSelect: () => T(e?.value || ""),
2465
+ children: [/* @__PURE__ */ (0, W.jsx)(ze, {
2466
+ "aria-hidden": "true",
2467
+ className: f("mr-2 h-4 w-4", ee && x(e.value) === C ? "opacity-100" : "opacity-0")
2468
+ }), e.label]
2469
+ }, e.value ?? e.label ?? t))] })
2470
+ ] })]
2471
+ })
2472
+ })]
2473
+ });
2474
+ }, zn = Object.entries({
2475
+ alphanumeric: "^[a-zA-Z0-9]+$",
2476
+ email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
2477
+ letters: "^[a-zA-Z]+$",
2478
+ number: "^[0-9]+$",
2479
+ url: "^https?:\\/\\/.+$"
2480
+ }).map(([e, t]) => ({
2481
+ label: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
2482
+ value: t
2483
+ })), Bn = ({ id: e, value: t, onValueChange: n }) => /* @__PURE__ */ (0, W.jsx)(Rn, {
2484
+ id: e,
2485
+ options: P(() => t && !zn.some((e) => e.value === t) ? [...zn, {
2486
+ label: `Custom: ${t}`,
2487
+ value: t
2488
+ }] : zn, [t]),
2489
+ value: t,
2490
+ onValueChange: n,
2491
+ placeholder: "Select or create a pattern",
2492
+ searchPlaceholder: "Search patterns...",
2493
+ createLabel: (e) => `Use pattern: ${e}`
2494
+ }), Vn = 400, Hn = .8, Un = (e) => new Promise((t, n) => {
2495
+ let r = new FileReader();
2496
+ r.onerror = () => n(/* @__PURE__ */ Error("read_failed")), r.onload = () => {
2497
+ let e = new Image();
2498
+ e.onload = () => t(e), e.onerror = () => n(/* @__PURE__ */ Error("decode_failed")), e.src = r.result;
2499
+ }, r.readAsDataURL(e);
2500
+ }), Wn = async (e) => {
2501
+ if (!e.type.startsWith("image/")) throw Error("invalid_type");
2502
+ if (e.size > 5242880) throw Error("too_large");
2503
+ let t = await Un(e), n = Math.min(1, Vn / Math.max(t.width, t.height)), r = document.createElement("canvas");
2504
+ r.width = Math.round(t.width * n), r.height = Math.round(t.height * n);
2505
+ let i = r.getContext("2d");
2506
+ if (!i) throw Error("canvas_unavailable");
2507
+ return i.drawImage(t, 0, 0, r.width, r.height), r.toDataURL("image/jpeg", Hn);
2508
+ }, Gn = 400, Kn = (e) => {
2509
+ if (!/^https?:\/\//i.test(e)) return !1;
2510
+ try {
2511
+ return !!new URL(e).hostname;
2512
+ } catch {
2513
+ return !1;
2514
+ }
2515
+ }, qn = ({ value: e, onChange: t }) => {
2516
+ let n = Me(null), r = Me(null), [i, a] = F(!1), [o, s] = F(e && /^https?:\/\//i.test(e) ? e : ""), c = G();
2517
+ Ae(() => {
2518
+ i || s(e && /^https?:\/\//i.test(e) ? e : "");
2519
+ }, [i, e]), Ae(() => () => {
2520
+ r.current && clearTimeout(r.current);
2521
+ }, []);
2522
+ let l = async (e) => {
2523
+ let r = e.target.files?.[0];
2524
+ if (r) try {
2525
+ t(await Wn(r)), a(!1);
2526
+ } catch (e) {
2527
+ let t = e.message;
2528
+ t === "too_large" ? H.error(c("editor.inputNodeForm.optionImageTooLarge")) : t === "invalid_type" ? H.error(c("editor.inputNodeForm.optionImageInvalid")) : H.error(c("editor.inputNodeForm.optionImageError"));
2529
+ } finally {
2530
+ n.current && (n.current.value = "");
2531
+ }
2532
+ }, u = () => {
2533
+ let e = o.trim();
2534
+ e && (t(e), a(!1));
2535
+ }, f = (n) => {
2536
+ let i = n.target.value;
2537
+ s(i), r.current && clearTimeout(r.current);
2538
+ let a = i.trim();
2539
+ !Kn(a) || a === e || (r.current = setTimeout(() => {
2540
+ t(a);
2541
+ }, Gn));
2542
+ };
2543
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
2544
+ className: "relative",
2545
+ children: [
2546
+ /* @__PURE__ */ (0, W.jsx)("input", {
2547
+ ref: n,
2548
+ type: "file",
2549
+ accept: "image/*",
2550
+ className: "hidden",
2551
+ onChange: l
2552
+ }),
2553
+ /* @__PURE__ */ (0, W.jsxs)(le, {
2554
+ open: i,
2555
+ onOpenChange: a,
2556
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
2557
+ asChild: !0,
2558
+ children: e ? /* @__PURE__ */ (0, W.jsx)("button", {
2559
+ type: "button",
2560
+ className: "h-9 w-9 cursor-pointer overflow-hidden rounded-md border border-input",
2561
+ "aria-label": c("editor.inputNodeForm.optionImageReplace"),
2562
+ children: /* @__PURE__ */ (0, W.jsx)("img", {
2563
+ src: e,
2564
+ alt: "",
2565
+ className: "h-full w-full object-cover"
2566
+ })
2567
+ }) : /* @__PURE__ */ (0, W.jsx)(m, {
2568
+ type: "button",
2569
+ variant: "outline",
2570
+ size: "icon",
2571
+ "aria-label": c("editor.inputNodeForm.optionImageAdd"),
2572
+ children: /* @__PURE__ */ (0, W.jsx)(Ze, { className: "h-4 w-4" })
2573
+ })
2574
+ }), /* @__PURE__ */ (0, W.jsxs)(v, {
2575
+ align: "start",
2576
+ className: "w-64 space-y-3 p-3",
2577
+ children: [
2578
+ /* @__PURE__ */ (0, W.jsxs)(m, {
2579
+ type: "button",
2580
+ variant: "outline",
2581
+ size: "sm",
2582
+ className: "w-full",
2583
+ onClick: () => n.current?.click(),
2584
+ children: [/* @__PURE__ */ (0, W.jsx)(mt, { className: "mr-2 h-4 w-4" }), c("editor.inputNodeForm.optionImageUpload")]
2585
+ }),
2586
+ /* @__PURE__ */ (0, W.jsx)(se, {}),
2587
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2588
+ className: "flex items-center gap-2",
2589
+ children: [/* @__PURE__ */ (0, W.jsx)($e, { className: "h-4 w-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ (0, W.jsx)(h, {
2590
+ placeholder: c("editor.inputNodeForm.optionImageUrlPlaceholder"),
2591
+ value: o,
2592
+ onChange: f,
2593
+ onKeyDown: (e) => {
2594
+ e.key === "Enter" && (e.preventDefault(), u());
2595
+ },
2596
+ onBlur: u
2597
+ })]
2598
+ })
2599
+ ]
2600
+ })]
2601
+ }),
2602
+ e && /* @__PURE__ */ (0, W.jsx)("button", {
2603
+ type: "button",
2604
+ onClick: (e) => {
2605
+ e.stopPropagation(), t("");
2606
+ },
2607
+ className: "-top-1 -right-1 absolute flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-destructive text-destructive-foreground",
2608
+ "aria-label": c("editor.inputNodeForm.optionImageRemove"),
2609
+ children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-3 w-3" })
2610
+ })
2611
+ ]
2612
+ });
2613
+ }, Jn = ({ value: e, onValueChange: t }) => {
2614
+ let n = G(), r = je();
2615
+ return /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(ue, {
2616
+ htmlFor: r,
2617
+ children: n("editor.selectInputType.type")
2618
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
2619
+ value: e,
2620
+ onValueChange: t,
2621
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
2622
+ id: r,
2623
+ className: "w-full capitalize",
2624
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
2625
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: /* @__PURE__ */ (0, W.jsx)(j, { children: Object.values(K).map((e) => /* @__PURE__ */ (0, W.jsxs)(x, {
2626
+ value: e,
2627
+ className: "capitalize",
2628
+ children: [/* @__PURE__ */ (0, W.jsx)(un(e), {}), e]
2629
+ }, e)) }) })]
2630
+ })] });
2631
+ };
2632
+ //#endregion
2633
+ //#region src/shared/components/ui/collapsible.tsx
2634
+ function Yn({ ...e }) {
2635
+ return /* @__PURE__ */ (0, W.jsx)(Ct.Root, {
2636
+ "data-slot": "collapsible",
2637
+ ...e
2638
+ });
2639
+ }
2640
+ function Xn({ ...e }) {
2641
+ return /* @__PURE__ */ (0, W.jsx)(Ct.CollapsibleTrigger, {
2642
+ "data-slot": "collapsible-trigger",
2643
+ ...e
2644
+ });
2645
+ }
2646
+ function Zn({ ...e }) {
2647
+ return /* @__PURE__ */ (0, W.jsx)(Ct.CollapsibleContent, {
2648
+ "data-slot": "collapsible-content",
2649
+ ...e
2650
+ });
2651
+ }
2652
+ //#endregion
2653
+ //#region src/editor/features/TreegeEditor/forms/InputNodeForm.tsx
2654
+ var Qn = () => {
2655
+ let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = q(), i = [
2656
+ "select",
2657
+ "radio",
2658
+ "autocomplete",
2659
+ "checkbox"
2660
+ ].includes(n?.data?.type || ""), a = Ot(n?.id), o = G(), s = n?.data?.type === "submit", { handleSubmit: c, Field: d } = I({
2661
+ defaultValues: {
2662
+ defaultValue: n?.data?.defaultValue,
2663
+ disablePast: n?.data?.disablePast,
2664
+ errorMessage: n?.data?.errorMessage || { en: "" },
2665
+ helperText: n?.data?.helperText || { en: "" },
2666
+ httpConfig: n?.data?.httpConfig,
2667
+ label: n?.data?.label || { en: "" },
2668
+ multiple: n?.data?.multiple,
2669
+ name: n?.data?.name || "",
2670
+ options: n?.data?.options || [],
2671
+ pattern: n?.data?.pattern || "",
2672
+ placeholder: n?.data?.placeholder || { en: "" },
2673
+ required: n?.data?.required,
2674
+ submitConfig: n?.data?.submitConfig,
2675
+ type: n?.data?.type || "",
2676
+ variant: n?.data?.variant || "default"
2677
+ },
2678
+ listeners: {
2679
+ onChange: ({ formApi: e }) => {
2680
+ e.handleSubmit().then();
2681
+ },
2682
+ onChangeDebounceMs: 150
2683
+ },
2684
+ onSubmit: ({ value: e }) => {
2685
+ r(e);
2686
+ }
2687
+ });
2688
+ return /* @__PURE__ */ (0, W.jsx)("form", {
2689
+ onSubmit: (e) => {
2690
+ e.preventDefault(), e.stopPropagation();
2691
+ },
2692
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2693
+ className: "grid gap-6",
2694
+ children: [
2695
+ /* @__PURE__ */ (0, W.jsx)(d, {
2696
+ name: "type",
2697
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(w, { children: /* @__PURE__ */ (0, W.jsx)(Jn, {
2698
+ value: e.state.value,
2699
+ onValueChange: (t) => e.handleChange(t)
2700
+ }) })
2701
+ }),
2702
+ /* @__PURE__ */ (0, W.jsxs)("div", {
2703
+ className: "flex items-end gap-2",
2704
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
2705
+ name: "label",
2706
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
2707
+ className: "flex-1",
2708
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
2709
+ htmlFor: t.name,
2710
+ children: o("editor.inputNodeForm.label")
2711
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
2712
+ autoFocus: !0,
2713
+ id: t.name,
2714
+ name: t.name,
2715
+ value: t.state.value?.[e] || "",
2716
+ onBlur: t.handleBlur,
2717
+ onChange: ({ target: n }) => {
2718
+ t.handleChange({
2719
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2720
+ [e]: n.value
2721
+ });
2722
+ }
2723
+ })]
2724
+ })
2725
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
2726
+ value: e,
2727
+ onValueChange: t
2728
+ })]
2729
+ }),
2730
+ !s && n?.data?.type !== "file" && /* @__PURE__ */ (0, W.jsxs)("div", {
2731
+ className: "flex items-end gap-2",
2732
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
2733
+ name: "placeholder",
2734
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
2735
+ className: "flex-1",
2736
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
2737
+ htmlFor: t.name,
2738
+ children: o("editor.inputNodeForm.placeholder")
2739
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
2740
+ id: t.name,
2741
+ name: t.name,
2742
+ value: t.state.value?.[e] || "",
2743
+ onBlur: t.handleBlur,
2744
+ onChange: ({ target: n }) => {
2745
+ t.handleChange({
2746
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2747
+ [e]: n.value
2748
+ });
2749
+ }
2750
+ })]
2751
+ })
2752
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
2753
+ value: e,
2754
+ onValueChange: t
2755
+ })]
2756
+ }),
2757
+ !s && /* @__PURE__ */ (0, W.jsxs)("div", {
2758
+ className: "flex items-end gap-2",
2759
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
2760
+ name: "helperText",
2761
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
2762
+ className: "flex-1",
2763
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
2764
+ htmlFor: t.name,
2765
+ children: o("editor.inputNodeForm.helperText")
2766
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
2767
+ id: t.name,
2768
+ name: t.name,
2769
+ value: t.state.value?.[e] || "",
2770
+ onBlur: t.handleBlur,
2771
+ onChange: ({ target: n }) => {
2772
+ t.handleChange({
2773
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2774
+ [e]: n.value
2775
+ });
2776
+ }
2777
+ })]
2778
+ })
2779
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
2780
+ value: e,
2781
+ onValueChange: t
2782
+ })]
2783
+ }),
2784
+ n?.data?.type === "http" && /* @__PURE__ */ (0, W.jsxs)(Yn, {
2785
+ defaultOpen: !0,
2786
+ className: "flex w-full max-w-[350px] flex-col gap-2",
2787
+ children: [/* @__PURE__ */ (0, W.jsx)(Xn, {
2788
+ asChild: !0,
2789
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2790
+ className: "flex items-center justify-between gap-4",
2791
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
2792
+ className: "font-semibold text-sm",
2793
+ children: o("editor.inputNodeForm.httpConfiguration")
2794
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
2795
+ variant: "ghost",
2796
+ size: "icon",
2797
+ className: "size-8",
2798
+ children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
2799
+ className: "sr-only",
2800
+ children: o("common.toggle")
2801
+ })]
2802
+ })]
2803
+ })
2804
+ }), /* @__PURE__ */ (0, W.jsx)(Zn, {
2805
+ className: "flex flex-col gap-4",
2806
+ children: /* @__PURE__ */ (0, W.jsx)(d, {
2807
+ name: "httpConfig",
2808
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(Fn, {
2809
+ value: e.state.value,
2810
+ onChange: (t) => {
2811
+ e.handleChange(t), c().then();
2812
+ }
2813
+ })
2814
+ })
2815
+ })]
2816
+ }),
2817
+ s && /* @__PURE__ */ (0, W.jsxs)(Yn, {
2818
+ className: "flex w-full max-w-[350px] flex-col gap-2",
2819
+ children: [/* @__PURE__ */ (0, W.jsx)(Xn, {
2820
+ asChild: !0,
2821
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2822
+ className: "flex items-center justify-between gap-4",
2823
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
2824
+ className: "font-semibold text-sm",
2825
+ children: o("editor.inputNodeForm.submitConfiguration")
2826
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
2827
+ variant: "ghost",
2828
+ size: "icon",
2829
+ className: "size-8",
2830
+ children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
2831
+ className: "sr-only",
2832
+ children: o("common.toggle")
2833
+ })]
2834
+ })]
2835
+ })
2836
+ }), /* @__PURE__ */ (0, W.jsx)(Zn, {
2837
+ className: "flex flex-col gap-4",
2838
+ children: /* @__PURE__ */ (0, W.jsx)(d, {
2839
+ name: "submitConfig",
2840
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(Ln, {
2841
+ value: e.state.value,
2842
+ onChange: (t) => {
2843
+ e.handleChange(t), c().then();
2844
+ }
2845
+ })
2846
+ })
2847
+ })]
2848
+ }),
2849
+ n?.data?.type === "file" && /* @__PURE__ */ (0, W.jsx)(d, {
2850
+ name: "multiple",
2851
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2852
+ className: "flex items-center space-x-2",
2853
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2854
+ id: e.name,
2855
+ checked: e.state.value,
2856
+ onCheckedChange: (t) => e.handleChange(t)
2857
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2858
+ htmlFor: e.name,
2859
+ children: o("editor.inputNodeForm.multipleFiles")
2860
+ })]
2861
+ })
2862
+ }),
2863
+ i && /* @__PURE__ */ (0, W.jsxs)(Yn, {
2864
+ defaultOpen: !0,
2865
+ className: "flex w-full max-w-[350px] flex-col gap-2",
2866
+ children: [/* @__PURE__ */ (0, W.jsx)(Xn, {
2867
+ asChild: !0,
2868
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
2869
+ className: "flex items-center justify-between gap-4",
2870
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
2871
+ className: "font-semibold text-sm",
2872
+ children: o("editor.inputNodeForm.options")
2873
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
2874
+ variant: "ghost",
2875
+ size: "icon",
2876
+ className: "size-8",
2877
+ children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
2878
+ className: "sr-only",
2879
+ children: o("common.toggle")
2880
+ })]
2881
+ })]
2882
+ })
2883
+ }), /* @__PURE__ */ (0, W.jsxs)(Zn, {
2884
+ className: "flex flex-col gap-4",
2885
+ children: [
2886
+ /* @__PURE__ */ (0, W.jsx)(d, {
2887
+ name: "options",
2888
+ mode: "array",
2889
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)("div", {
2890
+ className: "space-y-2",
2891
+ children: [t.state.value?.map((r, i) => {
2892
+ let a = `options[${i}]`;
2893
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
2894
+ className: "flex flex-col gap-2",
2895
+ children: [/* @__PURE__ */ (0, W.jsxs)("div", {
2896
+ className: "flex items-start gap-2",
2897
+ children: [
2898
+ n?.data?.type === "radio" && /* @__PURE__ */ (0, W.jsx)(d, {
2899
+ name: `options[${i}].image`,
2900
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(qn, {
2901
+ value: e.state.value,
2902
+ onChange: (t) => e.handleChange(t)
2903
+ })
2904
+ }),
2905
+ /* @__PURE__ */ (0, W.jsx)(d, {
2906
+ name: `options[${i}].label`,
2907
+ children: (t) => /* @__PURE__ */ (0, W.jsx)(h, {
2908
+ placeholder: o("editor.inputNodeForm.optionLabel"),
2909
+ value: t.state.value?.[e] || "",
2910
+ onChange: ({ target: n }) => {
2911
+ t.handleChange({
2912
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2913
+ [e]: n.value
2914
+ });
2915
+ }
2916
+ })
2917
+ }),
2918
+ /* @__PURE__ */ (0, W.jsx)(d, {
2919
+ name: `options[${i}].value`,
2920
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
2921
+ placeholder: o("editor.inputNodeForm.optionValue"),
2922
+ value: e.state.value || "",
2923
+ onChange: ({ target: t }) => e.handleChange(t.value)
2924
+ })
2925
+ }),
2926
+ /* @__PURE__ */ (0, W.jsx)(m, {
2927
+ type: "button",
2928
+ variant: "ghost",
2929
+ size: "icon",
2930
+ onClick: () => {
2931
+ t.removeValue(i), c().then();
2932
+ },
2933
+ children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
2934
+ })
2935
+ ]
2936
+ }), (n?.data?.type === "radio" || n?.data?.type === "checkbox") && /* @__PURE__ */ (0, W.jsx)(d, {
2937
+ name: `options[${i}].description`,
2938
+ children: (t) => /* @__PURE__ */ (0, W.jsx)(h, {
2939
+ placeholder: o("editor.inputNodeForm.optionDescription"),
2940
+ value: t.state.value?.[e] || "",
2941
+ onChange: ({ target: n }) => {
2942
+ t.handleChange({
2943
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2944
+ [e]: n.value
2945
+ });
2946
+ }
2947
+ })
2948
+ })]
2949
+ }, a);
2950
+ }), /* @__PURE__ */ (0, W.jsx)(m, {
2951
+ type: "button",
2952
+ variant: "outline",
2953
+ size: "sm",
2954
+ onClick: () => {
2955
+ t.pushValue({
2956
+ label: { en: "" },
2957
+ value: ""
2958
+ }), c().then();
2959
+ },
2960
+ children: o("editor.inputNodeForm.addOption")
2961
+ })]
2962
+ })
2963
+ }),
2964
+ n?.data?.type === "select" && /* @__PURE__ */ (0, W.jsx)(d, {
2965
+ name: "multiple",
2966
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)("div", {
2967
+ className: "flex items-center space-x-2",
2968
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
2969
+ id: e.name,
2970
+ checked: e.state.value,
2971
+ onCheckedChange: (t) => e.handleChange(t)
2972
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
2973
+ htmlFor: e.name,
2974
+ children: o("editor.inputNodeForm.multipleSelection")
2975
+ })]
2976
+ })
2977
+ }),
2978
+ n?.data?.type === "radio" && /* @__PURE__ */ (0, W.jsx)(d, {
2979
+ name: "variant",
2980
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
2981
+ htmlFor: e.name,
2982
+ children: o("editor.inputNodeForm.variant")
2983
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
2984
+ value: e.state.value || "default",
2985
+ onValueChange: (t) => e.handleChange(t),
2986
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
2987
+ id: e.name,
2988
+ className: "w-full",
2989
+ children: /* @__PURE__ */ (0, W.jsx)(l, {})
2990
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
2991
+ value: "default",
2992
+ children: o("editor.inputNodeForm.variantDefault")
2993
+ }), /* @__PURE__ */ (0, W.jsx)(x, {
2994
+ value: "card",
2995
+ children: o("editor.inputNodeForm.variantCard")
2996
+ })] })]
2997
+ })] })
2998
+ })
2999
+ ]
3000
+ })]
3001
+ }),
3002
+ !s && /* @__PURE__ */ (0, W.jsxs)(Yn, {
3003
+ className: "flex w-full max-w-[350px] flex-col gap-2",
3004
+ children: [/* @__PURE__ */ (0, W.jsx)(Xn, {
3005
+ asChild: !0,
3006
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
3007
+ className: "flex items-center justify-between gap-4",
3008
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
3009
+ className: "font-semibold text-sm",
3010
+ children: o("editor.inputNodeForm.validation")
3011
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
3012
+ variant: "ghost",
3013
+ size: "icon",
3014
+ className: "size-8",
3015
+ children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
3016
+ className: "sr-only",
3017
+ children: o("common.toggle")
3018
+ })]
3019
+ })]
3020
+ })
3021
+ }), /* @__PURE__ */ (0, W.jsxs)(Zn, {
3022
+ className: "flex flex-col gap-6",
3023
+ children: [
3024
+ /* @__PURE__ */ (0, W.jsx)(d, {
3025
+ name: "required",
3026
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(w, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
3027
+ className: "flex items-center space-x-2",
3028
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
3029
+ id: e.name,
3030
+ checked: e.state.value,
3031
+ onCheckedChange: (t) => e.handleChange(t)
3032
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
3033
+ htmlFor: e.name,
3034
+ children: o("editor.inputNodeForm.required")
3035
+ })]
3036
+ }) })
3037
+ }),
3038
+ (n?.data?.type === "date" || n?.data?.type === "daterange") && /* @__PURE__ */ (0, W.jsx)(d, {
3039
+ name: "disablePast",
3040
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(w, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
3041
+ className: "flex items-center space-x-2",
3042
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
3043
+ id: e.name,
3044
+ checked: e.state.value,
3045
+ onCheckedChange: (t) => e.handleChange(t)
3046
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
3047
+ htmlFor: e.name,
3048
+ children: o("editor.inputNodeForm.disablePast")
3049
+ })]
3050
+ }) })
3051
+ }),
3052
+ /* @__PURE__ */ (0, W.jsx)(d, {
3053
+ name: "pattern",
3054
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
3055
+ htmlFor: e.name,
3056
+ children: o("editor.inputNodeForm.pattern")
3057
+ }), /* @__PURE__ */ (0, W.jsx)(Bn, {
3058
+ id: e.name,
3059
+ value: e.state.value,
3060
+ onValueChange: e.handleChange
3061
+ })] })
3062
+ }),
3063
+ /* @__PURE__ */ (0, W.jsxs)("div", {
3064
+ className: "flex items-end gap-2",
3065
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
3066
+ name: "errorMessage",
3067
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
3068
+ className: "flex-1",
3069
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
3070
+ htmlFor: t.name,
3071
+ children: o("editor.inputNodeForm.errorMessage")
3072
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
3073
+ id: t.name,
3074
+ name: t.name,
3075
+ value: t.state.value?.[e] || "",
3076
+ onBlur: t.handleBlur,
3077
+ onChange: ({ target: n }) => {
3078
+ t.handleChange({
3079
+ ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
3080
+ [e]: n.value
3081
+ });
3082
+ }
3083
+ })]
3084
+ })
3085
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
3086
+ value: e,
3087
+ onValueChange: t
3088
+ })]
3089
+ })
3090
+ ]
3091
+ })]
3092
+ }),
3093
+ !s && /* @__PURE__ */ (0, W.jsxs)(Yn, {
3094
+ className: "flex w-full max-w-[350px] flex-col gap-2",
3095
+ children: [/* @__PURE__ */ (0, W.jsx)(Xn, {
3096
+ asChild: !0,
3097
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
3098
+ className: "flex items-center justify-between gap-4",
3099
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
3100
+ className: "font-semibold text-sm",
3101
+ children: o("editor.inputNodeForm.advancedConfiguration")
3102
+ }), /* @__PURE__ */ (0, W.jsxs)(m, {
3103
+ variant: "ghost",
3104
+ size: "icon",
3105
+ className: "size-8",
3106
+ children: [/* @__PURE__ */ (0, W.jsx)(L, {}), /* @__PURE__ */ (0, W.jsx)("span", {
3107
+ className: "sr-only",
3108
+ children: o("common.toggle")
3109
+ })]
3110
+ })]
3111
+ })
3112
+ }), /* @__PURE__ */ (0, W.jsxs)(Zn, {
3113
+ className: "flex flex-col gap-6",
3114
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
3115
+ name: "name",
3116
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
3117
+ /* @__PURE__ */ (0, W.jsx)(u, {
3118
+ htmlFor: e.name,
3119
+ children: o("editor.inputNodeForm.name")
3120
+ }),
3121
+ /* @__PURE__ */ (0, W.jsx)(h, {
3122
+ id: e.name,
3123
+ name: e.name,
3124
+ value: e.state.value,
3125
+ onBlur: e.handleBlur,
3126
+ onChange: ({ target: t }) => e.handleChange(t.value)
3127
+ }),
3128
+ /* @__PURE__ */ (0, W.jsx)(T, { children: o("editor.inputNodeForm.nameDescription") })
3129
+ ] })
3130
+ }), /* @__PURE__ */ (0, W.jsx)(d, {
3131
+ name: "defaultValue",
3132
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
3133
+ /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
3134
+ htmlFor: e.name,
3135
+ children: o("editor.inputNodeForm.defaultValueType")
3136
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
3137
+ value: e.state.value?.type || "none",
3138
+ onValueChange: (t) => {
3139
+ e.handleChange(t === "none" ? null : { type: t });
3140
+ },
3141
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3142
+ id: e.name,
3143
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectType") })
3144
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [
3145
+ /* @__PURE__ */ (0, W.jsx)(x, {
3146
+ value: "none",
3147
+ children: o("editor.inputNodeForm.defaultValueTypeNone")
3148
+ }),
3149
+ /* @__PURE__ */ (0, W.jsx)(x, {
3150
+ value: "static",
3151
+ children: o("editor.inputNodeForm.defaultValueTypeStatic")
3152
+ }),
3153
+ /* @__PURE__ */ (0, W.jsx)(x, {
3154
+ value: "reference",
3155
+ children: o("editor.inputNodeForm.defaultValueTypeReference")
3156
+ })
3157
+ ] })]
3158
+ })] }),
3159
+ e.state.value?.type === "static" && /* @__PURE__ */ (0, W.jsx)(d, {
3160
+ name: "defaultValue.staticValue",
3161
+ children: (e) => {
3162
+ let t = n?.data?.type;
3163
+ return (t === "select" || t === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
3164
+ htmlFor: e.name,
3165
+ children: o("editor.inputNodeForm.defaultValuesCommaSeparated")
3166
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
3167
+ id: e.name,
3168
+ placeholder: o("editor.inputNodeForm.defaultValuesPlaceholder"),
3169
+ value: Array.isArray(e.state.value) ? e.state.value.join(", ") : "",
3170
+ onChange: ({ target: t }) => {
3171
+ let n = t.value.split(",").map((e) => e.trim()).filter(Boolean);
3172
+ e.handleChange(n.length > 0 ? n : null);
3173
+ }
3174
+ })] }) : t === "checkbox" ? /* @__PURE__ */ (0, W.jsx)(w, { children: /* @__PURE__ */ (0, W.jsxs)("div", {
3175
+ className: "flex items-center space-x-2",
3176
+ children: [/* @__PURE__ */ (0, W.jsx)(S, {
3177
+ id: e.name,
3178
+ checked: !!e.state.value,
3179
+ onCheckedChange: (t) => e.handleChange(t)
3180
+ }), /* @__PURE__ */ (0, W.jsx)(u, {
3181
+ htmlFor: e.name,
3182
+ children: o("editor.inputNodeForm.defaultChecked")
3183
+ })]
3184
+ }) }) : /* @__PURE__ */ (0, W.jsxs)(w, { children: [/* @__PURE__ */ (0, W.jsx)(u, {
3185
+ htmlFor: e.name,
3186
+ children: o("editor.inputNodeForm.staticValue")
3187
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
3188
+ id: e.name,
3189
+ placeholder: o("editor.inputNodeForm.staticValuePlaceholder"),
3190
+ value: typeof e.state.value == "string" ? e.state.value : "",
3191
+ onChange: ({ target: t }) => e.handleChange(t.value || "")
3192
+ })] });
3193
+ }
3194
+ }),
3195
+ e.state.value?.type === "reference" && /* @__PURE__ */ (0, W.jsxs)(W.Fragment, { children: [
3196
+ /* @__PURE__ */ (0, W.jsx)(d, {
3197
+ name: "defaultValue.referenceField",
3198
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
3199
+ /* @__PURE__ */ (0, W.jsx)(u, {
3200
+ htmlFor: e.name,
3201
+ children: o("editor.inputNodeForm.referenceField")
3202
+ }),
3203
+ /* @__PURE__ */ (0, W.jsxs)(y, {
3204
+ value: e.state.value || "",
3205
+ onValueChange: (t) => {
3206
+ e.handleChange(t);
3207
+ },
3208
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3209
+ id: e.name,
3210
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectReferenceField") })
3211
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: a.length === 0 ? /* @__PURE__ */ (0, W.jsx)(x, {
3212
+ value: "none",
3213
+ disabled: !0,
3214
+ children: o("editor.inputNodeForm.noParentFieldsAvailable")
3215
+ }) : a.map((e) => /* @__PURE__ */ (0, W.jsxs)(x, {
3216
+ value: e.nodeId,
3217
+ children: [
3218
+ e.label,
3219
+ " (",
3220
+ e.type,
3221
+ ")"
3222
+ ]
3223
+ }, e.nodeId)) })]
3224
+ }),
3225
+ a.length === 0 && /* @__PURE__ */ (0, W.jsx)(T, { children: o("editor.inputNodeForm.addInputFieldsBeforeReference") })
3226
+ ] })
3227
+ }),
3228
+ /* @__PURE__ */ (0, W.jsx)(d, {
3229
+ name: "defaultValue.transformFunction",
3230
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
3231
+ /* @__PURE__ */ (0, W.jsx)(u, {
3232
+ htmlFor: t.name,
3233
+ children: o("editor.inputNodeForm.transformType")
3234
+ }),
3235
+ /* @__PURE__ */ (0, W.jsxs)(y, {
3236
+ value: t.state.value || "none",
3237
+ onValueChange: (n) => {
3238
+ let r = n === "none" ? null : n;
3239
+ if (t.handleChange(r), n === "toObject") {
3240
+ let t = e.state.value;
3241
+ e.handleChange({
3242
+ ...t,
3243
+ objectMapping: []
3244
+ });
3245
+ }
3246
+ },
3247
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3248
+ id: t.name,
3249
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: o("editor.inputNodeForm.selectTransformation") })
3250
+ }), /* @__PURE__ */ (0, W.jsxs)(A, { children: [
3251
+ /* @__PURE__ */ (0, W.jsx)(x, {
3252
+ value: "none",
3253
+ children: o("editor.inputNodeForm.transformNone")
3254
+ }),
3255
+ /* @__PURE__ */ (0, W.jsx)(x, {
3256
+ value: "toString",
3257
+ children: o("editor.inputNodeForm.transformString")
3258
+ }),
3259
+ /* @__PURE__ */ (0, W.jsx)(x, {
3260
+ value: "toNumber",
3261
+ children: o("editor.inputNodeForm.transformNumber")
3262
+ }),
3263
+ /* @__PURE__ */ (0, W.jsx)(x, {
3264
+ value: "toBoolean",
3265
+ children: o("editor.inputNodeForm.transformBoolean")
3266
+ }),
3267
+ /* @__PURE__ */ (0, W.jsx)(x, {
3268
+ value: "toArray",
3269
+ children: o("editor.inputNodeForm.transformArray")
3270
+ }),
3271
+ /* @__PURE__ */ (0, W.jsx)(x, {
3272
+ value: "toObject",
3273
+ children: o("editor.inputNodeForm.transformMapToObject")
3274
+ })
3275
+ ] })]
3276
+ }),
3277
+ /* @__PURE__ */ (0, W.jsx)(T, { children: o("editor.inputNodeForm.transformDesc") })
3278
+ ] })
3279
+ }),
3280
+ e.state.value?.transformFunction === "toObject" && /* @__PURE__ */ (0, W.jsx)(d, {
3281
+ name: "defaultValue.objectMapping",
3282
+ mode: "array",
3283
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(w, { children: [
3284
+ /* @__PURE__ */ (0, W.jsx)(u, { children: o("editor.inputNodeForm.objectMapping") }),
3285
+ /* @__PURE__ */ (0, W.jsxs)("div", {
3286
+ className: "space-y-2",
3287
+ children: [e.state.value?.map((t, n) => /* @__PURE__ */ (0, W.jsxs)("div", {
3288
+ className: "flex items-center gap-2",
3289
+ children: [
3290
+ /* @__PURE__ */ (0, W.jsx)(d, {
3291
+ name: `defaultValue.objectMapping[${n}].sourceKey`,
3292
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
3293
+ placeholder: o("editor.inputNodeForm.sourceKey"),
3294
+ value: e.state.value || "",
3295
+ onChange: ({ target: t }) => e.handleChange(t.value)
3296
+ })
3297
+ }),
3298
+ /* @__PURE__ */ (0, W.jsx)("span", {
3299
+ className: "text-muted-foreground",
3300
+ children: "→"
3301
+ }),
3302
+ /* @__PURE__ */ (0, W.jsx)(d, {
3303
+ name: `defaultValue.objectMapping[${n}].targetKey`,
3304
+ children: (e) => /* @__PURE__ */ (0, W.jsx)(h, {
3305
+ placeholder: o("editor.inputNodeForm.targetKey"),
3306
+ value: e.state.value || "",
3307
+ onChange: ({ target: t }) => e.handleChange(t.value)
3308
+ })
3309
+ }),
3310
+ /* @__PURE__ */ (0, W.jsx)(m, {
3311
+ type: "button",
3312
+ variant: "ghost",
3313
+ size: "icon",
3314
+ onClick: () => {
3315
+ e.removeValue(n), c().then();
3316
+ },
3317
+ children: /* @__PURE__ */ (0, W.jsx)(z, { className: "h-4 w-4" })
3318
+ })
3319
+ ]
3320
+ }, `mapping-${n}`)), /* @__PURE__ */ (0, W.jsxs)(m, {
3321
+ type: "button",
3322
+ variant: "outline",
3323
+ size: "sm",
3324
+ className: "w-full",
3325
+ onClick: () => {
3326
+ e.pushValue({
3327
+ sourceKey: "",
3328
+ targetKey: ""
3329
+ }), c().then();
3330
+ },
3331
+ children: [/* @__PURE__ */ (0, W.jsx)(R, { className: "mr-2 h-4 w-4" }), o("editor.inputNodeForm.addMapping")]
3332
+ })]
3333
+ }),
3334
+ /* @__PURE__ */ (0, W.jsx)(T, { children: o("editor.inputNodeForm.objectMappingDesc") })
3335
+ ] })
3336
+ })
3337
+ ] })
3338
+ ] })
3339
+ })]
3340
+ })]
3341
+ })
3342
+ ]
3343
+ })
3344
+ });
3345
+ }, $n = () => {
3346
+ let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = q(), { Field: i } = I({
3347
+ defaultValues: {
3348
+ label: n?.data?.label || { en: "" },
3349
+ type: n?.data?.type || ""
3350
+ },
3351
+ listeners: {
3352
+ onChange: ({ formApi: e }) => {
3353
+ e.handleSubmit().then();
3354
+ },
3355
+ onChangeDebounceMs: 150
3356
+ },
3357
+ onSubmit: ({ value: e }) => {
3358
+ r(e);
3359
+ }
3360
+ });
3361
+ return /* @__PURE__ */ (0, W.jsx)("form", {
3362
+ onSubmit: (e) => {
3363
+ e.preventDefault(), e.stopPropagation();
3364
+ },
3365
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
3366
+ className: "grid gap-6",
3367
+ children: [/* @__PURE__ */ (0, W.jsxs)("div", {
3368
+ className: "flex items-end gap-2",
3369
+ children: [/* @__PURE__ */ (0, W.jsx)(i, {
3370
+ name: "label",
3371
+ children: (t) => /* @__PURE__ */ (0, W.jsxs)(w, {
3372
+ className: "flex-1",
3373
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
3374
+ htmlFor: t.name,
3375
+ children: "Label"
3376
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
3377
+ id: t.name,
3378
+ name: t.name,
3379
+ value: t.state.value?.[e] || "",
3380
+ onBlur: t.handleBlur,
3381
+ onChange: ({ target: n }) => {
3382
+ t.handleChange({
3383
+ ...t.state.value,
3384
+ [e]: n.value
3385
+ });
3386
+ }
3387
+ })]
3388
+ })
3389
+ }), /* @__PURE__ */ (0, W.jsx)(Q, {
3390
+ value: e,
3391
+ onValueChange: t
3392
+ })]
3393
+ }), /* @__PURE__ */ (0, W.jsx)(i, {
3394
+ name: "type",
3395
+ children: (e) => /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(ue, {
3396
+ htmlFor: e.name,
3397
+ children: "Type"
3398
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
3399
+ value: e.state.value,
3400
+ onValueChange: (t) => e.handleChange(t),
3401
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3402
+ id: e.name,
3403
+ className: "w-full",
3404
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: "" })
3405
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
3406
+ value: on.title,
3407
+ children: "Title"
3408
+ }), /* @__PURE__ */ (0, W.jsx)(x, {
3409
+ value: on.divider,
3410
+ children: "Divider"
3411
+ })] }) })]
3412
+ })] })
3413
+ })]
3414
+ })
3415
+ });
3416
+ }, er = () => {
3417
+ let [e, t] = F(""), [n, r] = F(!1), { selectedNode: i, groupNodes: o } = $(), { setNodes: s } = M(), c = i?.parentId || "none", f = a(i), p = G(), g = je(), b = je();
3418
+ if (f) return null;
3419
+ let S = (e) => {
3420
+ i && s((t) => e === "none" ? t.map((e) => {
3421
+ if (e.id === i.id) {
3422
+ let { parentId: t, extent: n, ...r } = e;
3423
+ return r;
3424
+ }
3425
+ return e;
3426
+ }) : t.find((t) => t.id === e) ? t.map((t) => t.id === i.id ? {
3427
+ ...t,
3428
+ extent: "parent",
3429
+ parentId: e,
3430
+ position: {
3431
+ x: 50,
3432
+ y: 80
3433
+ }
3434
+ } : t) : t);
3435
+ }, C = () => {
3436
+ if (!(e.trim() && i)) return;
3437
+ if (o.find((t) => {
3438
+ let n = t.data?.label?.en || t.data?.label;
3439
+ return String(n).toLowerCase() === e.trim().toLowerCase();
3440
+ })) {
3441
+ H.error("This group already exists", { description: "Use the selector to add the node to an existing group." });
3442
+ return;
3443
+ }
3444
+ let n = nn();
3445
+ s((t) => [{
3446
+ data: { label: { en: e.trim() } },
3447
+ id: n,
3448
+ position: {
3449
+ x: i.position.x - 300,
3450
+ y: i.position.y
3451
+ },
3452
+ style: {
3453
+ height: 400,
3454
+ width: 600
3455
+ },
3456
+ type: "group"
3457
+ }, ...t.map((e) => e.id === i.id ? {
3458
+ ...e,
3459
+ extent: "parent",
3460
+ parentId: n,
3461
+ position: {
3462
+ x: 175,
3463
+ y: 30
3464
+ }
3465
+ } : e)]), t(""), r(!1), H.success("Group created", { description: `The group "${e.trim()}" has been created successfully.` });
3466
+ };
3467
+ return /* @__PURE__ */ (0, W.jsxs)("div", {
3468
+ className: "space-y-2",
3469
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
3470
+ htmlFor: g,
3471
+ children: p("editor.selectNodeGroup.group")
3472
+ }), /* @__PURE__ */ (0, W.jsxs)("div", {
3473
+ className: "flex gap-2",
3474
+ children: [/* @__PURE__ */ (0, W.jsxs)(y, {
3475
+ value: c,
3476
+ onValueChange: S,
3477
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3478
+ id: g,
3479
+ className: "flex-1",
3480
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: p("editor.selectNodeGroup.noGroup") })
3481
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(x, {
3482
+ value: "none",
3483
+ children: p("editor.selectNodeGroup.noGroup")
3484
+ }), o.map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
3485
+ value: e.id,
3486
+ children: e.data.label?.en ? String(e.data.label?.en) : e.id
3487
+ }, e.id))] }) })]
3488
+ }), /* @__PURE__ */ (0, W.jsxs)(le, {
3489
+ open: n,
3490
+ onOpenChange: r,
3491
+ children: [/* @__PURE__ */ (0, W.jsx)(d, {
3492
+ asChild: !0,
3493
+ children: /* @__PURE__ */ (0, W.jsx)(m, {
3494
+ variant: "outline",
3495
+ size: "icon",
3496
+ title: "Create a new group",
3497
+ children: /* @__PURE__ */ (0, W.jsx)(ot, { className: "h-4 w-4" })
3498
+ })
3499
+ }), /* @__PURE__ */ (0, W.jsx)(v, {
3500
+ className: "w-80",
3501
+ align: "end",
3502
+ disablePortal: !0,
3503
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
3504
+ className: "space-y-4",
3505
+ children: [
3506
+ /* @__PURE__ */ (0, W.jsxs)("div", {
3507
+ className: "space-y-2",
3508
+ children: [/* @__PURE__ */ (0, W.jsx)("h4", {
3509
+ className: "font-medium leading-none",
3510
+ children: p("editor.selectNodeGroup.newGroup")
3511
+ }), /* @__PURE__ */ (0, W.jsx)("p", {
3512
+ className: "text-muted-foreground text-sm",
3513
+ children: p("editor.selectNodeGroup.newGroupDescription")
3514
+ })]
3515
+ }),
3516
+ /* @__PURE__ */ (0, W.jsxs)("div", {
3517
+ className: "space-y-2",
3518
+ children: [/* @__PURE__ */ (0, W.jsx)(u, {
3519
+ htmlFor: b,
3520
+ children: p("editor.selectNodeGroup.groupName")
3521
+ }), /* @__PURE__ */ (0, W.jsx)(h, {
3522
+ autoFocus: !0,
3523
+ id: b,
3524
+ value: e,
3525
+ onChange: (e) => t(e.target.value),
3526
+ placeholder: "Ex: Step 1 - Personal info",
3527
+ onKeyDown: (e) => {
3528
+ e.key === "Enter" && (e.preventDefault(), C());
3529
+ }
3530
+ })]
3531
+ }),
3532
+ /* @__PURE__ */ (0, W.jsxs)("div", {
3533
+ className: "flex justify-end gap-2",
3534
+ children: [/* @__PURE__ */ (0, W.jsx)(m, {
3535
+ variant: "outline",
3536
+ size: "sm",
3537
+ onClick: () => r(!1),
3538
+ children: "Cancel"
3539
+ }), /* @__PURE__ */ (0, W.jsx)(m, {
3540
+ size: "sm",
3541
+ onClick: C,
3542
+ disabled: !e.trim(),
3543
+ children: "Create"
3544
+ })]
3545
+ })
3546
+ ]
3547
+ })
3548
+ })]
3549
+ })]
3550
+ })]
3551
+ });
3552
+ }, tr = () => {
3553
+ let { selectedNode: e } = $(), { updateSelectedNodeType: t } = q(), n = e?.type || "", r = a(e), i = G(), o = je();
3554
+ return /* @__PURE__ */ (0, W.jsxs)(j, { children: [/* @__PURE__ */ (0, W.jsx)(ue, {
3555
+ htmlFor: o,
3556
+ children: i("editor.selectNodeType.nodeType")
3557
+ }), /* @__PURE__ */ (0, W.jsxs)(y, {
3558
+ value: n,
3559
+ onValueChange: (e) => t(e),
3560
+ disabled: r,
3561
+ children: [/* @__PURE__ */ (0, W.jsx)(_, {
3562
+ className: "w-full",
3563
+ id: o,
3564
+ children: /* @__PURE__ */ (0, W.jsx)(l, { placeholder: i("editor.selectNodeType.nodeType") })
3565
+ }), /* @__PURE__ */ (0, W.jsx)(A, { children: /* @__PURE__ */ (0, W.jsx)(j, { children: Object.keys(vn).filter((e) => r ? e === "group" : e !== "group").map((e) => /* @__PURE__ */ (0, W.jsx)(x, {
3566
+ value: e,
3567
+ children: i(`editor.selectNodeType.options.${e}`)
3568
+ }, e)) }) })]
3569
+ })] });
3570
+ };
3571
+ //#endregion
3572
+ //#region src/shared/components/ui/sheet.tsx
3573
+ function nr({ ...e }) {
3574
+ return /* @__PURE__ */ (0, W.jsx)(U.Root, {
3575
+ "data-slot": "sheet",
3576
+ ...e
3577
+ });
3578
+ }
3579
+ function rr({ ...e }) {
3580
+ return /* @__PURE__ */ (0, W.jsx)(U.Portal, {
3581
+ "data-slot": "sheet-portal",
3582
+ ...e
3583
+ });
3584
+ }
3585
+ function ir({ className: e, ...t }) {
3586
+ return /* @__PURE__ */ (0, W.jsx)(U.Overlay, {
3587
+ "data-slot": "sheet-overlay",
3588
+ className: f("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in", e),
3589
+ ...t
3590
+ });
3591
+ }
3592
+ function ar({ className: e, children: t, side: n = "right", ...r }) {
3593
+ return /* @__PURE__ */ (0, W.jsxs)(rr, { children: [/* @__PURE__ */ (0, W.jsx)(ir, {}), /* @__PURE__ */ (0, W.jsxs)(U.Content, {
3594
+ "data-slot": "sheet-content",
3595
+ className: f("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500", 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", 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", 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", 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", e),
3596
+ ...r,
3597
+ children: [t, /* @__PURE__ */ (0, W.jsxs)(U.Close, {
3598
+ className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",
3599
+ children: [/* @__PURE__ */ (0, W.jsx)(vt, { className: "size-4" }), /* @__PURE__ */ (0, W.jsx)("span", {
3600
+ className: "sr-only",
3601
+ children: "Close"
3602
+ })]
3603
+ })]
3604
+ })] });
3605
+ }
3606
+ function or({ className: e, ...t }) {
3607
+ return /* @__PURE__ */ (0, W.jsx)("div", {
3608
+ "data-slot": "sheet-header",
3609
+ className: f("flex flex-col gap-1.5 p-4", e),
3610
+ ...t
3611
+ });
3612
+ }
3613
+ function sr({ className: e, ...t }) {
3614
+ return /* @__PURE__ */ (0, W.jsx)("div", {
3615
+ "data-slot": "sheet-footer",
3616
+ className: f("mt-auto flex flex-col gap-2 p-4", e),
3617
+ ...t
3618
+ });
3619
+ }
3620
+ function cr({ className: e, ...t }) {
3621
+ return /* @__PURE__ */ (0, W.jsx)(U.Title, {
3622
+ "data-slot": "sheet-title",
3623
+ className: f("font-semibold text-foreground", e),
3624
+ ...t
3625
+ });
3626
+ }
3627
+ function lr({ className: e, ...t }) {
3628
+ return /* @__PURE__ */ (0, W.jsx)(U.Description, {
3629
+ "data-slot": "sheet-description",
3630
+ className: f("text-muted-foreground text-sm", e),
3631
+ ...t
3632
+ });
3633
+ }
3634
+ //#endregion
3635
+ //#region src/editor/features/TreegeEditor/sheets/NodeActionsSheet.tsx
3636
+ var ur = () => {
3637
+ let { selectedNode: e } = $(), { clearSelection: r, deleteSelectedNode: i } = q(), { isNodeSheetOpen: o, setIsNodeSheetOpen: s } = jt(), l = G(), u = l(e?.data?.label), d = () => {
3638
+ s(!1), r();
3639
+ };
3640
+ return /* @__PURE__ */ (0, W.jsx)(nr, {
3641
+ open: o && !!e,
3642
+ onOpenChange: (e) => {
3643
+ e || d();
3644
+ },
3645
+ children: /* @__PURE__ */ (0, W.jsxs)(ar, {
3646
+ className: "flex flex-col gap-0",
3647
+ children: [
3648
+ /* @__PURE__ */ (0, W.jsxs)(or, { children: [/* @__PURE__ */ (0, W.jsxs)(cr, { children: [
3649
+ l("editor.nodeActionsSheet.editNode"),
3650
+ " ",
3651
+ /* @__PURE__ */ (0, W.jsx)("span", {
3652
+ className: "font-light text-muted-foreground text-xs",
3653
+ children: e?.id
3654
+ })
3655
+ ] }), /* @__PURE__ */ (0, W.jsx)(lr, { children: u || "\xA0" })] }),
3656
+ /* @__PURE__ */ (0, W.jsx)(Mt, {
3657
+ className: "flex min-h-0 flex-1 flex-col px-4",
3658
+ children: /* @__PURE__ */ (0, W.jsxs)("div", {
3659
+ className: "space-y-6 py-4",
3660
+ children: [
3661
+ /* @__PURE__ */ (0, W.jsx)(tr, {}),
3662
+ /* @__PURE__ */ (0, W.jsx)(er, {}),
3663
+ /* @__PURE__ */ (0, W.jsx)(se, {}),
3664
+ c(e) && /* @__PURE__ */ (0, W.jsx)(Qn, {}),
3665
+ n(e) && /* @__PURE__ */ (0, W.jsx)($n, {}),
3666
+ t(e) && /* @__PURE__ */ (0, W.jsx)(Mn, {}),
3667
+ a(e) && /* @__PURE__ */ (0, W.jsx)(Nn, {})
3668
+ ]
3669
+ })
3670
+ }),
3671
+ /* @__PURE__ */ (0, W.jsx)(sr, {
3672
+ className: "flex items-end border-t",
3673
+ children: /* @__PURE__ */ (0, W.jsxs)(Lt, { children: [/* @__PURE__ */ (0, W.jsx)(Rt, {
3674
+ asChild: !0,
3675
+ children: /* @__PURE__ */ (0, W.jsx)(m, {
3676
+ variant: "ghost",
3677
+ size: "icon",
3678
+ children: /* @__PURE__ */ (0, W.jsx)(pt, {})
3679
+ })
3680
+ }), /* @__PURE__ */ (0, W.jsxs)(Vt, { children: [/* @__PURE__ */ (0, W.jsxs)(Ht, { children: [/* @__PURE__ */ (0, W.jsx)(Wt, { children: l("editor.nodeActionsSheet.deleteNode") }), /* @__PURE__ */ (0, W.jsx)(Gt, { children: l("editor.nodeActionsSheet.deleteNodeConfirm") })] }), /* @__PURE__ */ (0, W.jsxs)(Ut, { children: [/* @__PURE__ */ (0, W.jsx)(qt, { children: l("common.cancel") }), /* @__PURE__ */ (0, W.jsx)(Kt, {
3681
+ onClick: () => {
3682
+ i(), d();
3683
+ },
3684
+ children: l("common.delete")
3685
+ })] })] })] })
3686
+ })
3687
+ ]
3688
+ })
3689
+ });
3690
+ }, dr = ({ ...e }) => {
3691
+ let { theme: t = "system" } = wt();
3692
+ return /* @__PURE__ */ (0, W.jsx)(St, {
3693
+ theme: t,
3694
+ className: "toaster group",
3695
+ style: {
3696
+ "--normal-bg": "var(--treege-popover)",
3697
+ "--normal-border": "var(--treege-border)",
3698
+ "--normal-text": "var(--treege-popover-foreground)"
3699
+ },
3700
+ ...e
3701
+ });
3702
+ }, fr = ({ flow: e, onExportJson: t, onSave: n, theme: r, className: i }) => {
3703
+ let { onConnect: a, onConnectEnd: o, onEdgesDelete: s, isValidConnection: c } = an();
3704
+ return /* @__PURE__ */ (0, W.jsxs)(xe, {
3705
+ fitView: !0,
3706
+ colorMode: r,
3707
+ selectNodesOnDrag: !1,
3708
+ nodeTypes: vn,
3709
+ edgeTypes: Pt,
3710
+ defaultEdges: e?.edges || [],
3711
+ defaultNodes: e?.nodes || [],
3712
+ onConnect: a,
3713
+ onConnectEnd: o,
3714
+ onEdgesDelete: s,
3715
+ isValidConnection: c,
3716
+ className: f(i, "treege"),
3717
+ children: [
3718
+ /* @__PURE__ */ (0, W.jsx)(de, {
3719
+ gap: 10,
3720
+ variant: fe.Dots
3721
+ }),
3722
+ /* @__PURE__ */ (0, W.jsx)(An, {
3723
+ onExportJson: t,
3724
+ onSave: n
3725
+ }),
3726
+ /* @__PURE__ */ (0, W.jsx)(Dt, { theme: r }),
3727
+ /* @__PURE__ */ (0, W.jsx)(_e, {}),
3728
+ /* @__PURE__ */ (0, W.jsx)(me, {}),
3729
+ /* @__PURE__ */ (0, W.jsx)(ur, {})
3730
+ ]
3731
+ });
3732
+ }, pr = ({ flow: e, onExportJson: t, onSave: n, theme: r = "dark", language: i = "en", aiConfig: a }) => /* @__PURE__ */ (0, W.jsx)(s, {
3733
+ defaultTheme: r,
3734
+ storageKey: "treege-editor-theme",
3735
+ theme: r,
3736
+ children: /* @__PURE__ */ (0, W.jsxs)(At, {
3737
+ value: {
3738
+ aiConfig: a,
3739
+ flowId: e?.id,
3740
+ language: i
3741
+ },
3742
+ children: [/* @__PURE__ */ (0, W.jsx)(dr, { position: "bottom-center" }), /* @__PURE__ */ (0, W.jsx)(Se, { children: /* @__PURE__ */ (0, W.jsx)(fr, {
3743
+ onExportJson: t,
3744
+ onSave: n,
3745
+ flow: e,
3746
+ theme: r
3747
+ }) })]
3748
+ })
3749
+ });
3750
+ //#endregion
3751
+ export { pr as t };