treege 3.0.0-beta.43 → 3.0.0-beta.45

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 (59) hide show
  1. package/README.md +16 -9
  2. package/dist/DefaultInputs-DYKtphqY.js +1701 -0
  3. package/dist/ThemeContext-O482h1XZ.js +1397 -0
  4. package/dist/editor/components/styles/EditorStyles.d.ts +2 -0
  5. package/dist/editor/context/OpenApiContext.d.ts +79 -0
  6. package/dist/editor/context/TreegeEditorContext.d.ts +7 -0
  7. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  8. package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
  9. package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
  10. package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
  11. package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
  12. package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +30 -0
  13. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +0 -1
  14. package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
  15. package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
  16. package/dist/editor/features/TreegeEditor/nodes/components/NodeOptions.d.ts +12 -0
  17. package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
  18. package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +5 -2
  19. package/dist/editor/types/editor.d.ts +39 -1
  20. package/dist/editor/types/openapi.d.ts +81 -0
  21. package/dist/editor/utils/openapi.d.ts +35 -0
  22. package/dist/editor-DBCMmZtt.js +5147 -0
  23. package/dist/editor.js +2 -3
  24. package/dist/main.js +4 -5
  25. package/dist/renderer/context/TreegeConfigContext.d.ts +3 -27
  26. package/dist/renderer/context/TreegeRendererContext.d.ts +99 -2
  27. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
  28. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +3 -2
  29. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  30. package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
  31. package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
  32. package/dist/renderer/features/TreegeRenderer/web/components/styles/RendererStyles.d.ts +2 -0
  33. package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
  34. package/dist/renderer/hooks/useRenderNode.d.ts +7 -3
  35. package/dist/renderer/hooks/useSubmitHandler.d.ts +3 -2
  36. package/dist/renderer/types/renderer.d.ts +13 -25
  37. package/dist/renderer/utils/http.d.ts +29 -1
  38. package/dist/renderer/utils/submit.d.ts +3 -2
  39. package/dist/renderer-native.js +794 -782
  40. package/dist/renderer.js +3 -4
  41. package/dist/shared/components/ui/button.d.ts +1 -1
  42. package/dist/shared/components/ui/field.d.ts +24 -0
  43. package/dist/shared/components/ui/toggle-group.d.ts +7 -0
  44. package/dist/shared/components/ui/toggle.d.ts +9 -0
  45. package/dist/shared/locales/ar.json.d.ts +80 -0
  46. package/dist/shared/locales/de.json.d.ts +80 -0
  47. package/dist/shared/locales/en.json.d.ts +80 -0
  48. package/dist/shared/locales/es.json.d.ts +80 -0
  49. package/dist/shared/locales/fr.json.d.ts +80 -0
  50. package/dist/shared/locales/it.json.d.ts +80 -0
  51. package/dist/shared/locales/pt.json.d.ts +80 -0
  52. package/dist/shared/types/node.d.ts +44 -0
  53. package/package.json +3 -2
  54. package/dist/DefaultInputs-Cr6wTVNE.js +0 -1558
  55. package/dist/ThemeContext-CUHjGVUf.js +0 -1602
  56. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +0 -7
  57. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +0 -6
  58. package/dist/editor-CE8g1o72.js +0 -4037
  59. /package/dist/editor/components/{data-display/logo.d.ts → branding/Logo.d.ts} +0 -0
@@ -1,4037 +0,0 @@
1
- import { A as e, E as t, F as n, I as r, L as i, N as a, P as o, T as s, j as c, k as l, t as u } from "./ThemeContext-CUHjGVUf.js";
2
- import { $ as d, A as f, B as p, F as m, G as h, H as g, I as _, J as v, K as y, L as ee, M as te, N as b, P as x, Q as ne, R as S, U as C, V as re, W as w, X as ie, Y as T, Z as ae, _ as E, at as D, c as O, et as k, it as A, j as oe, k as se, nt as j, o as ce, p as le, q as ue, rt as de, t as fe, tt as M, v as pe, z as me } from "./DefaultInputs-Cr6wTVNE.js";
3
- import { Background as he, BackgroundVariant as ge, BaseEdge as _e, ControlButton as ve, Controls as ye, EdgeLabelRenderer as be, Handle as xe, MiniMap as Se, NodeResizer as Ce, Panel as we, Position as Te, ReactFlow as Ee, ReactFlowProvider as De, addEdge as Oe, getBezierPath as ke, useEdges as Ae, useNodes as je, useNodesInitialized as Me, useReactFlow as N, useStore as Ne } from "@xyflow/react";
4
- import { createContext as Pe, memo as Fe, useCallback as P, useContext as Ie, useEffect as Le, useId as Re, useMemo as ze, useRef as Be, useState as F } from "react";
5
- import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
6
- import { useForm as Ve } from "@tanstack/react-form";
7
- import { AlignLeft as He, ArrowRightFromLine as Ue, Boxes as We, Calendar as Ge, CalendarRange as Ke, CaseSensitive as qe, Check as Je, CheckSquare as Ye, ChevronDown as Xe, ChevronsUpDown as Ze, CircleDot as Qe, Clock as $e, ClockFading as et, Cloud as tt, Copy as nt, Download as rt, EllipsisVertical as it, EyeOff as at, Hash as ot, Heading as st, ImagePlus as ct, KeyRound as lt, Link2 as ut, ListFilter as dt, Loader2 as ft, MapPin as pt, MapPinMinusInside as mt, Minus as ht, MoreVertical as gt, Network as _t, Paperclip as vt, Plus as z, PlusCircle as yt, RectangleEllipsis as bt, Save as xt, Search as St, Send as Ct, Settings as wt, ToggleLeft as Tt, Trash2 as Et, Upload as Dt, Variable as Ot, WandSparkles as kt, Waypoints as At, X as B, XIcon as jt } from "lucide-react";
8
- import { Slot as Mt } from "@radix-ui/react-slot";
9
- import { cva as Nt } from "class-variance-authority";
10
- import * as Pt from "@radix-ui/react-scroll-area";
11
- import * as V from "@radix-ui/react-dropdown-menu";
12
- import * as Ft from "@radix-ui/react-dialog";
13
- import It from "@dagrejs/dagre";
14
- import { Toaster as Lt, toast as H } from "sonner";
15
- import * as Rt from "@radix-ui/react-collapsible";
16
- import { useTheme as zt } from "next-themes";
17
- //#region src/editor/assets/img/treege-black.svg
18
- var Bt = "data:image/svg+xml,%3csvg%20width='462'%20height='144'%20viewBox='0%200%20462%20144'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1809_3434)'%3e%3cpath%20d='M137%2041.34L116.57%206C116.22%205.39399%20115.717%204.89037%20115.112%204.53942C114.507%204.18847%20113.82%204.00247%20113.12%204H38.83C38.1303%204.00247%2037.4434%204.18847%2036.838%204.53942C36.2326%204.89037%2035.7299%205.39399%2035.38%206L15%2041.34C14.6495%2041.947%2014.4647%2042.6355%2014.4641%2043.3365C14.4635%2044.0374%2014.6471%2044.7262%2014.9965%2045.3339C15.3459%2045.9416%2015.8488%2046.4467%2016.455%2046.7988C17.0611%2047.1509%2017.7491%2047.3375%2018.45%2047.34H133.53C134.233%2047.341%20134.923%2047.157%20135.532%2046.8063C136.141%2046.4557%20136.647%2045.9508%20136.999%2045.3426C137.35%2044.7343%20137.536%2044.0441%20137.536%2043.3415C137.536%2042.6388%20137.351%2041.9485%20137%2041.34V41.34Z'%20fill='%2311D3B4'/%3e%3cpath%20d='M92.48%20140.64H113.1C113.805%20140.643%20114.498%20140.459%20115.109%20140.108C115.72%20139.757%20116.228%20139.251%20116.58%20138.64L151.39%2078.3401C151.741%2077.7316%20151.926%2077.0413%20151.926%2076.3386C151.926%2075.636%20151.74%2074.9458%20151.389%2074.3375C151.037%2073.7293%20150.531%2073.2244%20149.922%2072.8738C149.313%2072.5231%20148.623%2072.3391%20147.92%2072.3401H92.48C91.4191%2072.3401%2090.4017%2072.7615%2089.6516%2073.5117C88.9014%2074.2618%2088.48%2075.2792%2088.48%2076.3401V136.64C88.48%20137.701%2088.9014%20138.718%2089.6516%20139.469C90.4017%20140.219%2091.4191%20140.64%2092.48%20140.64Z'%20fill='%23007EF6'/%3e%3cpath%20d='M59.48%2072.3201H3.99999C3.29819%2072.3208%202.60893%2072.5061%202.00143%2072.8575C1.39392%2073.2089%200.88955%2073.7139%200.538962%2074.3218C0.188375%2074.9298%200.00390931%2075.6193%200.00408949%2076.3211C0.00426966%2077.0229%200.189089%2077.7123%200.539989%2078.3201L35.38%20138.66C35.7299%20139.266%2036.2326%20139.77%2036.838%20140.121C37.4434%20140.472%2038.1302%20140.658%2038.83%20140.66H59.48C60.5409%20140.66%2061.5583%20140.239%2062.3084%20139.489C63.0586%20138.738%2063.48%20137.721%2063.48%20136.66V76.3101C63.4773%2075.2509%2063.0547%2074.2361%2062.3049%2073.4881C61.555%2072.7401%2060.5391%2072.3201%2059.48%2072.3201V72.3201Z'%20fill='%230164A8'/%3e%3c/g%3e%3cpath%20d='M207.52%20106.96C202.272%20106.96%20198.368%20105.584%20195.808%20102.832C193.312%20100.08%20192.064%2096.336%20192.064%2091.6V70.48H185.632V60.496H192.064V50.704L205.024%2046.864V60.496H216.544L215.776%2070.48H205.024V90.736C205.024%2093.232%20205.6%2094.96%20206.752%2095.92C207.904%2096.816%20209.696%2097.264%20212.128%2097.264C213.92%2097.264%20215.776%2096.944%20217.696%2096.304V105.232C216.288%20105.808%20214.752%20106.224%20213.088%20106.48C211.424%20106.8%20209.568%20106.96%20207.52%20106.96ZM224.347%20106V60.496H236.347L236.923%2065.2C238.971%2063.92%20241.499%2062.768%20244.507%2061.744C247.579%2060.656%20250.587%2059.92%20253.531%2059.536V69.328C251.803%2069.584%20249.915%2069.968%20247.867%2070.48C245.819%2070.992%20243.867%2071.568%20242.011%2072.208C240.155%2072.848%20238.587%2073.52%20237.307%2074.224V106H224.347ZM281.997%20106.96C274.125%20106.96%20267.885%20105.008%20263.277%20101.104C258.669%2097.136%20256.365%2091.152%20256.365%2083.152C256.365%2075.92%20258.285%2070.192%20262.125%2065.968C266.029%2061.68%20271.821%2059.536%20279.501%2059.536C286.541%2059.536%20291.917%2061.392%20295.629%2065.104C299.405%2068.752%20301.292%2073.552%20301.292%2079.504V87.76H268.365C269.069%2091.408%20270.733%2093.904%20273.357%2095.248C276.045%2096.592%20279.821%2097.264%20284.685%2097.264C287.117%2097.264%20289.581%2097.04%20292.077%2096.592C294.637%2096.144%20296.813%2095.568%20298.605%2094.864V104.08C296.493%20105.04%20294.029%20105.744%20291.213%20106.192C288.397%20106.704%20285.325%20106.96%20281.997%20106.96ZM268.365%2079.792H289.965V77.296C289.965%2074.672%20289.197%2072.624%20287.661%2071.152C286.125%2069.616%20283.533%2068.848%20279.885%2068.848C275.597%2068.848%20272.589%2069.712%20270.861%2071.44C269.197%2073.168%20268.365%2075.952%20268.365%2079.792ZM334.028%20106.96C326.156%20106.96%20319.916%20105.008%20315.308%20101.104C310.7%2097.136%20308.396%2091.152%20308.396%2083.152C308.396%2075.92%20310.316%2070.192%20314.156%2065.968C318.06%2061.68%20323.852%2059.536%20331.532%2059.536C338.572%2059.536%20343.948%2061.392%20347.66%2065.104C351.436%2068.752%20353.324%2073.552%20353.324%2079.504V87.76H320.396C321.1%2091.408%20322.764%2093.904%20325.388%2095.248C328.076%2096.592%20331.852%2097.264%20336.716%2097.264C339.148%2097.264%20341.612%2097.04%20344.108%2096.592C346.668%2096.144%20348.844%2095.568%20350.636%2094.864V104.08C348.524%20105.04%20346.06%20105.744%20343.244%20106.192C340.428%20106.704%20337.356%20106.96%20334.028%20106.96ZM320.396%2079.792H341.996V77.296C341.996%2074.672%20341.228%2072.624%20339.692%2071.152C338.156%2069.616%20335.564%2068.848%20331.916%2068.848C327.628%2068.848%20324.62%2069.712%20322.892%2071.44C321.228%2073.168%20320.396%2075.952%20320.396%2079.792ZM381.547%20122.896C378.155%20122.896%20374.667%20122.672%20371.083%20122.224C367.563%20121.776%20364.587%20121.136%20362.155%20120.304V110.608C364.715%20111.44%20367.723%20112.08%20371.179%20112.528C374.635%20113.04%20377.867%20113.296%20380.875%20113.296C385.291%20113.296%20388.491%20113.04%20390.475%20112.528C392.459%20112.08%20393.451%20111.248%20393.451%20110.032C393.451%20109.008%20393.003%20108.304%20392.107%20107.92C391.275%20107.536%20389.483%20107.344%20386.731%20107.344H374.347C366.219%20107.344%20362.155%20104.336%20362.155%2098.32C362.155%2096.464%20362.667%2094.768%20363.691%2093.232C364.715%2091.696%20366.347%2090.48%20368.587%2089.584C363.403%2086.96%20360.811%2082.544%20360.811%2076.336C360.811%2070.448%20362.635%2066.192%20366.283%2063.568C369.931%2060.88%20375.339%2059.536%20382.507%2059.536C383.979%2059.536%20385.579%2059.664%20387.307%2059.92C389.099%2060.112%20390.443%2060.304%20391.339%2060.496H408.427L408.139%2068.656H400.939C402.923%2070.512%20403.915%2073.104%20403.915%2076.432C403.915%2081.104%20402.443%2084.848%20399.499%2087.664C396.555%2090.416%20392.203%2091.792%20386.443%2091.792C385.419%2091.792%20384.427%2091.76%20383.467%2091.696C382.571%2091.568%20381.643%2091.44%20380.683%2091.312C378.763%2091.568%20377.131%2092.016%20375.787%2092.656C374.507%2093.296%20373.867%2094.16%20373.867%2095.248C373.867%2096.72%20375.179%2097.456%20377.803%2097.456H390.667C395.275%2097.456%20398.827%2098.512%20401.323%20100.624C403.819%20102.672%20405.067%20105.68%20405.067%20109.648C405.067%20114.128%20403.051%20117.456%20399.019%20119.632C394.987%20121.808%20389.163%20122.896%20381.547%20122.896ZM382.603%2084.496C386.443%2084.496%20389.099%2083.856%20390.571%2082.576C392.107%2081.232%20392.875%2078.992%20392.875%2075.856C392.875%2072.72%20392.107%2070.448%20390.571%2069.04C389.099%2067.632%20386.443%2066.928%20382.603%2066.928C378.955%2066.928%20376.331%2067.632%20374.731%2069.04C373.131%2070.384%20372.331%2072.656%20372.331%2075.856C372.331%2078.8%20373.067%2080.976%20374.539%2082.384C376.075%2083.792%20378.763%2084.496%20382.603%2084.496ZM439.028%20106.96C431.156%20106.96%20424.916%20105.008%20420.308%20101.104C415.7%2097.136%20413.396%2091.152%20413.396%2083.152C413.396%2075.92%20415.316%2070.192%20419.156%2065.968C423.06%2061.68%20428.852%2059.536%20436.532%2059.536C443.572%2059.536%20448.948%2061.392%20452.66%2065.104C456.436%2068.752%20458.324%2073.552%20458.324%2079.504V87.76H425.396C426.1%2091.408%20427.764%2093.904%20430.388%2095.248C433.076%2096.592%20436.852%2097.264%20441.716%2097.264C444.148%2097.264%20446.612%2097.04%20449.108%2096.592C451.668%2096.144%20453.844%2095.568%20455.636%2094.864V104.08C453.524%20105.04%20451.06%20105.744%20448.244%20106.192C445.428%20106.704%20442.356%20106.96%20439.028%20106.96ZM425.396%2079.792H446.996V77.296C446.996%2074.672%20446.228%2072.624%20444.692%2071.152C443.156%2069.616%20440.564%2068.848%20436.916%2068.848C432.628%2068.848%20429.62%2069.712%20427.892%2071.44C426.228%2073.168%20425.396%2075.952%20425.396%2079.792Z'%20fill='black'/%3e%3cdefs%3e%3cclipPath%20id='clip0_1809_3434'%3e%3crect%20width='151.93'%20height='136.64'%20fill='white'%20transform='translate(0%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e", Vt = "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", Ht = ({ theme: e = "dark" }) => /* @__PURE__ */ L("div", {
19
- className: "tg:absolute tg:top-4 tg:left-5 tg:z-50 tg:select-none tg:md:top-5",
20
- children: /* @__PURE__ */ L("img", {
21
- src: e === "dark" ? Vt : Bt,
22
- alt: "Treege",
23
- className: "tg:relative tg:h-7 tg:w-auto tg:drop-shadow-[0_0px_35px] tg:drop-shadow-blue-600 tg:md:h-14"
24
- })
25
- }), Ut = (e) => {
26
- let t = je(), n = Ae();
27
- return ze(() => {
28
- if (!e) return [];
29
- let i = (e, t = /* @__PURE__ */ new Set()) => {
30
- if (t.has(e)) return [];
31
- let r = new Set(t).add(e);
32
- return n.filter((t) => t.target === e).flatMap((e) => [e.source, ...i(e.source, r)]);
33
- }, a = i(e);
34
- return t.filter((e) => a.includes(e.id) && r(e)).map((e) => {
35
- let t = e.data;
36
- return {
37
- label: (typeof t.label == "object" ? t.label.en : t.label) || t.name || e.id,
38
- name: t.name,
39
- nodeId: e.id,
40
- type: t.type || "text"
41
- };
42
- });
43
- }, [
44
- e,
45
- t,
46
- n
47
- ]);
48
- }, Wt = Pe(null), Gt = ({ children: e, value: t }) => {
49
- let [n, r] = F(t?.flowId), [i, a] = F(!1), [o, s] = F(null), [c, l] = F(null), u = ze(() => ({
50
- ...t,
51
- ...t?.aiConfig && { aiConfig: {
52
- ...t.aiConfig,
53
- provider: t?.aiConfig.provider ?? "gemini"
54
- } },
55
- closeDeleteNodeConfirmation: () => s(null),
56
- closeNodeTypeChangeConfirmation: () => l(null),
57
- flowId: n,
58
- isNodeSheetOpen: i,
59
- openDeleteNodeConfirmation: (e) => s(e),
60
- openNodeTypeChangeConfirmation: (e) => l(e),
61
- pendingDeleteNodeId: o,
62
- pendingNodeTypeChange: c,
63
- setFlowId: r,
64
- setIsNodeSheetOpen: a
65
- }), [
66
- n,
67
- t,
68
- i,
69
- o,
70
- c
71
- ]);
72
- return /* @__PURE__ */ L(Wt.Provider, {
73
- value: u,
74
- children: e
75
- });
76
- }, U = () => Ie(Wt) ?? {
77
- closeDeleteNodeConfirmation: () => {},
78
- closeNodeTypeChangeConfirmation: () => {},
79
- flowId: void 0,
80
- isNodeSheetOpen: !1,
81
- language: "en",
82
- openDeleteNodeConfirmation: () => {},
83
- openNodeTypeChangeConfirmation: () => {},
84
- pendingDeleteNodeId: null,
85
- pendingNodeTypeChange: null,
86
- setFlowId: () => {},
87
- setIsNodeSheetOpen: () => {}
88
- }, W = (e) => {
89
- let t = U();
90
- return c(e ?? t.language);
91
- };
92
- //#endregion
93
- //#region src/shared/components/ui/scroll-area.tsx
94
- function Kt({ className: e, children: t, ...n }) {
95
- return /* @__PURE__ */ R(Pt.Root, {
96
- "data-slot": "scroll-area",
97
- className: D("tg:relative", e),
98
- ...n,
99
- children: [
100
- /* @__PURE__ */ L(Pt.Viewport, {
101
- "data-slot": "scroll-area-viewport",
102
- className: "tg:size-full tg:rounded-[inherit] tg:outline-none tg:transition-[color,box-shadow] tg:focus-visible:outline-1 tg:focus-visible:ring-[3px] tg:focus-visible:ring-ring/50",
103
- children: t
104
- }),
105
- /* @__PURE__ */ L(qt, {}),
106
- /* @__PURE__ */ L(Pt.Corner, {})
107
- ]
108
- });
109
- }
110
- function qt({ className: e, orientation: t = "vertical", ...n }) {
111
- return /* @__PURE__ */ L(Pt.ScrollAreaScrollbar, {
112
- "data-slot": "scroll-area-scrollbar",
113
- orientation: t,
114
- className: D("tg:flex tg:touch-none tg:select-none tg:p-px tg:transition-colors", t === "vertical" && "tg:h-full tg:w-2.5 tg:border-l tg:border-l-transparent", t === "horizontal" && "tg:h-2.5 tg:flex-col tg:border-t tg:border-t-transparent", e),
115
- ...n,
116
- children: /* @__PURE__ */ L(Pt.ScrollAreaThumb, {
117
- "data-slot": "scroll-area-thumb",
118
- className: "tg:relative tg:flex-1 tg:rounded-full tg:bg-border"
119
- })
120
- });
121
- }
122
- //#endregion
123
- //#region src/editor/features/TreegeEditor/edges/ConditionalEdge.tsx
124
- var Jt = {
125
- "!==": "≠",
126
- "<": "<",
127
- "<=": "≤",
128
- "===": "=",
129
- ">": ">",
130
- ">=": "≥"
131
- }, Yt = (e) => !!e.field && e.value !== void 0 && e.value !== "", Xt = {
132
- conditional: Fe(({ id: t, target: n, sourceX: r, sourceY: i, targetX: a, targetY: o, sourcePosition: s, targetPosition: c, markerEnd: l, style: u, data: f }) => {
133
- let [p, m, _] = ke({
134
- sourcePosition: s,
135
- sourceX: r,
136
- sourceY: i,
137
- targetPosition: c,
138
- targetX: a,
139
- targetY: o
140
- }), [y, ee] = F(!1), { updateEdgeData: te } = N(), b = Ut(n), x = W(), S = !!f?.configured || !!f?.isFallback || !!f?.label || (f?.conditions?.some(Yt) ?? !1), { handleSubmit: re, reset: w, Field: E } = Ve({
141
- defaultValues: {
142
- conditions: f?.conditions || [{
143
- field: b[0]?.nodeId ?? "",
144
- operator: "===",
145
- value: ""
146
- }],
147
- isFallback: !!f?.isFallback,
148
- label: f?.label || ""
149
- },
150
- listeners: {
151
- onChange: ({ formApi: e }) => {
152
- e.handleSubmit().then();
153
- },
154
- onChangeDebounceMs: 150
155
- },
156
- onSubmit: ({ value: e }) => {
157
- te(t, {
158
- ...e,
159
- configured: !0
160
- });
161
- }
162
- }), O = (e) => {
163
- e.stopPropagation();
164
- }, oe = () => {
165
- w({
166
- conditions: [],
167
- isFallback: !1,
168
- label: ""
169
- }), te(t, {
170
- conditions: void 0,
171
- configured: void 0,
172
- isFallback: void 0,
173
- label: void 0
174
- });
175
- }, se = (e) => {
176
- ee(e), !(e || f?.configured) && (f?.isFallback || f?.label || f?.conditions?.length) && te(t, { configured: !0 });
177
- }, ce = () => {
178
- if (f?.isFallback) return f.label || x("editor.conditionalEdge.fallback");
179
- if (f?.label) return f.label;
180
- let t = f?.conditions ?? [];
181
- if (t.length === 0) return null;
182
- if (t.length === 1) {
183
- let [e] = t, n = b.find((t) => t.nodeId === e.field)?.label ?? e.field ?? "";
184
- return `${n === e.field && n.length > 5 ? `${n.slice(0, 5)}…` : n} ${Jt[e.operator] ?? e.operator} ${e.value ?? ""}`;
185
- }
186
- let n = t.filter((t) => t.logicalOperator === e.AND).length, r = t.filter((t) => t.logicalOperator === e.OR).length;
187
- return n > 0 && r === 0 ? `${t.length} ${x("editor.conditionalEdge.conditionsAnd")}` : r > 0 && n === 0 ? `${t.length} ${x("editor.conditionalEdge.conditionsOr")}` : `${t.length} ${x("editor.conditionalEdge.conditionsMixed")}`;
188
- }, le = () => f?.isFallback ? "var(--treege-chart-4)" : S ? "var(--treege-chart-2)" : "var(--treege-chart-3)";
189
- return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(_e, {
190
- path: p,
191
- markerEnd: l,
192
- style: {
193
- ...u,
194
- stroke: le(),
195
- strokeDasharray: f?.isFallback ? "5,5" : void 0,
196
- strokeWidth: S ? 2 : u?.strokeWidth
197
- }
198
- }), /* @__PURE__ */ L(be, { children: /* @__PURE__ */ L("div", {
199
- className: "nodrag nopan tg:absolute",
200
- style: {
201
- pointerEvents: "all",
202
- transform: `translate(-50%, -50%) translate(${m}px,${_}px)`
203
- },
204
- children: /* @__PURE__ */ R(ie, {
205
- open: y,
206
- onOpenChange: se,
207
- children: [/* @__PURE__ */ L(ne, {
208
- asChild: !0,
209
- children: /* @__PURE__ */ R(A, {
210
- variant: S ? "default" : "secondary",
211
- size: "xs",
212
- className: D("tg:transition-[filter]", S ? "tg:hover:bg-primary tg:hover:brightness-125" : "tg:hover:bg-secondary tg:hover:brightness-90"),
213
- onClick: O,
214
- children: [/* @__PURE__ */ L(At, { className: "tg:h-3 tg:w-3" }), S ? ce() : x("editor.conditionalEdge.defineCondition")]
215
- })
216
- }), /* @__PURE__ */ L(ae, {
217
- className: "tg:w-96 tg:p-1",
218
- align: "center",
219
- onClick: (e) => e.stopPropagation(),
220
- children: /* @__PURE__ */ L(Kt, {
221
- className: "tg:flex tg:max-h-150 tg:flex-col tg:p-3",
222
- children: /* @__PURE__ */ L("form", {
223
- onSubmit: (e) => {
224
- e.preventDefault(), e.stopPropagation();
225
- },
226
- children: /* @__PURE__ */ R("div", {
227
- className: "tg:grid tg:gap-5",
228
- children: [
229
- /* @__PURE__ */ R("div", {
230
- className: "tg:space-y-2",
231
- children: [/* @__PURE__ */ L("h4", {
232
- className: "tg:font-medium tg:leading-none",
233
- children: x("editor.conditionalEdge.displayConditions")
234
- }), /* @__PURE__ */ L("p", {
235
- className: "tg:text-muted-foreground tg:text-sm",
236
- children: x("editor.conditionalEdge.displayConditionsDesc")
237
- })]
238
- }),
239
- /* @__PURE__ */ R("div", {
240
- className: "tg:grid tg:gap-4",
241
- children: [
242
- /* @__PURE__ */ L(E, {
243
- name: "label",
244
- children: (e) => /* @__PURE__ */ R(j, { children: [
245
- /* @__PURE__ */ L(d, {
246
- htmlFor: e.name,
247
- children: x("editor.conditionalEdge.labelOptional")
248
- }),
249
- /* @__PURE__ */ L(k, {
250
- id: e.name,
251
- placeholder: x("editor.conditionalEdge.labelPlaceholder"),
252
- value: e.state.value,
253
- onChange: (t) => e.handleChange(t.target.value)
254
- }),
255
- /* @__PURE__ */ L(M, { children: x("editor.conditionalEdge.labelDesc") })
256
- ] })
257
- }),
258
- /* @__PURE__ */ L(E, {
259
- name: "isFallback",
260
- children: (e) => /* @__PURE__ */ L(j, { children: /* @__PURE__ */ R("div", {
261
- className: "tg:flex tg:items-center tg:gap-3 tg:rounded-lg tg:border tg:bg-muted/20 tg:p-3",
262
- children: [/* @__PURE__ */ L(de, {
263
- id: e.name,
264
- checked: e.state.value,
265
- onCheckedChange: (t) => e.handleChange(t)
266
- }), /* @__PURE__ */ R("div", {
267
- className: "tg:flex tg:flex-col tg:gap-1",
268
- children: [/* @__PURE__ */ L(d, {
269
- htmlFor: e.name,
270
- className: "tg:cursor-pointer tg:font-medium",
271
- children: x("editor.conditionalEdge.fallbackPath")
272
- }), /* @__PURE__ */ L(M, {
273
- className: "tg:text-xs",
274
- children: x("editor.conditionalEdge.fallbackPathDesc")
275
- })]
276
- })]
277
- }) })
278
- }),
279
- /* @__PURE__ */ L(E, {
280
- name: "conditions",
281
- mode: "array",
282
- children: (t) => {
283
- let n = t.form.getFieldValue("isFallback");
284
- return /* @__PURE__ */ R("div", {
285
- className: "tg:space-y-3",
286
- children: [/* @__PURE__ */ L(d, {
287
- className: n ? "tg:text-muted-foreground" : "",
288
- children: x("editor.conditionalEdge.conditions")
289
- }), /* @__PURE__ */ R("div", {
290
- className: "tg:space-y-2",
291
- children: [t.state.value?.map((r, i) => /* @__PURE__ */ R("div", {
292
- className: "tg:space-y-2",
293
- children: [/* @__PURE__ */ R("div", {
294
- className: "tg:space-y-2 tg:rounded-lg tg:border tg:bg-muted/30 tg:p-3",
295
- children: [
296
- /* @__PURE__ */ L(E, {
297
- name: `conditions[${i}].field`,
298
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
299
- htmlFor: `field-${i}`,
300
- children: x("editor.conditionalEdge.field")
301
- }), /* @__PURE__ */ R(g, {
302
- disabled: n,
303
- value: e.state.value || "",
304
- onValueChange: (t) => e.handleChange(t),
305
- children: [/* @__PURE__ */ L(v, {
306
- id: `field-${i}`,
307
- className: "tg:w-full",
308
- children: /* @__PURE__ */ L(T, { placeholder: x("editor.conditionalEdge.selectField") })
309
- }), /* @__PURE__ */ L(C, { children: b.length === 0 ? /* @__PURE__ */ L(h, {
310
- value: "none",
311
- disabled: !0,
312
- children: x("editor.conditionalEdge.noFieldsAvailable")
313
- }) : b.map((e) => /* @__PURE__ */ R(h, {
314
- value: e.nodeId,
315
- children: [
316
- e.label,
317
- " (",
318
- e.type,
319
- ")"
320
- ]
321
- }, e.nodeId)) })]
322
- })] })
323
- }),
324
- /* @__PURE__ */ R("div", {
325
- className: "tg:flex tg:gap-2",
326
- children: [/* @__PURE__ */ L(E, {
327
- name: `conditions[${i}].operator`,
328
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
329
- htmlFor: `operator-${i}`,
330
- children: x("editor.conditionalEdge.operator")
331
- }), /* @__PURE__ */ R(g, {
332
- disabled: n,
333
- value: e.state.value || "===",
334
- onValueChange: (t) => e.handleChange(t),
335
- children: [/* @__PURE__ */ L(v, {
336
- id: `operator-${i}`,
337
- children: /* @__PURE__ */ L(T, {})
338
- }), /* @__PURE__ */ R(C, { children: [
339
- /* @__PURE__ */ L(h, {
340
- value: "===",
341
- children: "="
342
- }),
343
- /* @__PURE__ */ L(h, {
344
- value: "!==",
345
- children: "≠"
346
- }),
347
- /* @__PURE__ */ L(h, {
348
- value: ">",
349
- children: ">"
350
- }),
351
- /* @__PURE__ */ L(h, {
352
- value: "<",
353
- children: "<"
354
- }),
355
- /* @__PURE__ */ L(h, {
356
- value: ">=",
357
- children: ">="
358
- }),
359
- /* @__PURE__ */ L(h, {
360
- value: "<=",
361
- children: "<="
362
- })
363
- ] })]
364
- })] })
365
- }), /* @__PURE__ */ L(E, {
366
- name: `conditions[${i}].value`,
367
- children: (e) => /* @__PURE__ */ R(j, {
368
- className: "tg:w-full",
369
- children: [/* @__PURE__ */ L(d, {
370
- htmlFor: `value-${i}`,
371
- children: x("editor.conditionalEdge.value")
372
- }), /* @__PURE__ */ L(k, {
373
- disabled: n,
374
- id: `value-${i}`,
375
- placeholder: x("editor.conditionalEdge.valuePlaceholder"),
376
- value: e.state.value || "",
377
- onChange: (t) => e.handleChange(t.target.value)
378
- })]
379
- })
380
- })]
381
- }),
382
- t.state.value && t.state.value.length > 1 && /* @__PURE__ */ R(A, {
383
- disabled: n,
384
- type: "button",
385
- variant: "ghost",
386
- size: "sm",
387
- className: "tg:w-full",
388
- onClick: () => {
389
- t.removeValue(i), re().then();
390
- },
391
- children: [/* @__PURE__ */ L(B, { className: "tg:mr-1 tg:h-4 tg:w-4" }), x("editor.conditionalEdge.removeCondition")]
392
- })
393
- ]
394
- }), t.state.value && i < t.state.value.length - 1 && /* @__PURE__ */ L(E, {
395
- name: `conditions[${i}].logicalOperator`,
396
- children: (t) => /* @__PURE__ */ L("div", {
397
- className: "tg:flex tg:justify-center",
398
- children: /* @__PURE__ */ R(g, {
399
- disabled: n,
400
- value: t.state.value || e.AND,
401
- onValueChange: (e) => t.handleChange(e),
402
- children: [/* @__PURE__ */ L(v, {
403
- className: "tg:h-9 tg:w-32 tg:font-semibold",
404
- children: /* @__PURE__ */ L(T, {})
405
- }), /* @__PURE__ */ R(C, { children: [/* @__PURE__ */ L(h, {
406
- value: e.AND,
407
- children: "AND"
408
- }), /* @__PURE__ */ L(h, {
409
- value: e.OR,
410
- children: "OR"
411
- })] })]
412
- })
413
- })
414
- })]
415
- }, `condition-${i}`)), /* @__PURE__ */ R(A, {
416
- disabled: n,
417
- type: "button",
418
- variant: "outline",
419
- size: "sm",
420
- className: "tg:w-full",
421
- onClick: () => {
422
- t.pushValue({
423
- field: b[0]?.nodeId ?? "",
424
- logicalOperator: e.AND,
425
- operator: "===",
426
- value: ""
427
- }), re().then();
428
- },
429
- children: [/* @__PURE__ */ L(z, { className: "tg:mr-2 tg:h-4 tg:w-4" }), x("editor.conditionalEdge.addCondition")]
430
- })]
431
- })]
432
- });
433
- }
434
- })
435
- ]
436
- }),
437
- /* @__PURE__ */ R("div", {
438
- className: "tg:flex tg:justify-end tg:gap-2 tg:pt-2",
439
- children: [/* @__PURE__ */ R(A, {
440
- type: "button",
441
- size: "sm",
442
- variant: "outline",
443
- onClick: oe,
444
- children: [/* @__PURE__ */ L(B, { className: "tg:mr-1 tg:h-4 tg:w-4" }), x("common.clear")]
445
- }), /* @__PURE__ */ L(A, {
446
- type: "button",
447
- size: "sm",
448
- onClick: () => se(!1),
449
- children: x("common.close")
450
- })]
451
- })
452
- ]
453
- })
454
- })
455
- })
456
- })]
457
- })
458
- }) })] });
459
- }),
460
- default: Fe(({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, style: s, markerEnd: c, selected: l }) => {
461
- let [u, d, f] = ke({
462
- sourcePosition: a,
463
- sourceX: t,
464
- sourceY: n,
465
- targetPosition: o,
466
- targetX: r,
467
- targetY: i
468
- }), { setEdges: p } = N();
469
- return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(_e, {
470
- path: u,
471
- markerEnd: c,
472
- style: s
473
- }), /* @__PURE__ */ L(be, { children: l && /* @__PURE__ */ L("div", {
474
- className: "button-edge__label nodrag nopan",
475
- style: { transform: `translate(-50%, -50%) translate(${d}px,${f}px)` },
476
- children: /* @__PURE__ */ L("button", {
477
- type: "button",
478
- className: "button-edge__button",
479
- onClick: () => {
480
- p((t) => t.filter((t) => t.id !== e));
481
- },
482
- "aria-label": "Remove edge",
483
- children: "×"
484
- })
485
- }) })] });
486
- })
487
- }, Zt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Qt = (e = 21) => {
488
- let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
489
- for (; e--;) t += Zt[n[e] & 63];
490
- return t;
491
- }, $t = (e, t) => {
492
- if (t.size === 0) return e;
493
- let n = /* @__PURE__ */ new Map();
494
- return e.forEach((e) => {
495
- n.set(e.source, (n.get(e.source) ?? 0) + 1);
496
- }), e.map((e) => {
497
- if (!t.has(e.source) || (n.get(e.source) ?? 0) !== 1) return e;
498
- let { conditions: r, isFallback: i, ...a } = e.data ?? {}, o = a && Object.keys(a).length > 0 ? a : void 0;
499
- return {
500
- ...e,
501
- data: o,
502
- type: "default"
503
- };
504
- });
505
- }, G = () => {
506
- let { setNodes: e, setEdges: t, getNodes: n } = N(), r = P(() => {
507
- e((e) => e.map(({ selected: e, ...t }) => t)), t((e) => e.map(({ selected: e, ...t }) => t));
508
- }, [t, e]), i = P((n) => {
509
- e((e) => e.map((e) => ({
510
- ...e,
511
- selected: e.id === n
512
- }))), t((e) => e.map(({ selected: e, ...t }) => t));
513
- }, [t, e]), a = P((t, n) => {
514
- e((e) => e.map((e) => e.id === t ? {
515
- ...e,
516
- data: {
517
- ...e.data,
518
- ...n
519
- }
520
- } : e));
521
- }, [e]), o = P((t, n, r) => {
522
- e((e) => e.map((e) => {
523
- if (e.id !== t) return e;
524
- let i = e.type === n ? e.data : {};
525
- return {
526
- ...e,
527
- data: r === void 0 ? i : {
528
- ...i,
529
- type: r
530
- },
531
- type: n
532
- };
533
- }));
534
- }, [e]), s = P((e, t) => {
535
- let r = n().find((e) => e.selected);
536
- r && o(r.id, e, t);
537
- }, [n, o]), c = P((e) => {
538
- let t = n().find((e) => e.selected);
539
- t && a(t.id, e);
540
- }, [n, a]), l = P((n) => {
541
- e((e) => e.filter((e) => e.id !== n)), t((e) => {
542
- let t = e.filter((e) => e.target === n), r = e.filter((e) => e.source === n), i = new Set(t.map((e) => e.source)), a = e.filter((e) => e.source !== n && e.target !== n);
543
- if (t.length === 1 && r.length === 1) {
544
- let [e] = t, [n] = r, o = {
545
- data: e.data,
546
- id: Qt(),
547
- source: e.source,
548
- target: n.target,
549
- type: e.type
550
- };
551
- return $t([...a, o], i);
552
- }
553
- return $t(a, i);
554
- });
555
- }, [e, t]);
556
- return {
557
- clearSelection: r,
558
- deleteNode: l,
559
- deleteSelectedNode: P(() => {
560
- let e = n().find((e) => e.selected);
561
- e && l(e.id);
562
- }, [n, l]),
563
- selectNode: i,
564
- updateNodeData: a,
565
- updateNodeType: o,
566
- updateSelectedNodeData: c,
567
- updateSelectedNodeType: s
568
- };
569
- }, en = ({ nodeId: e, label: t, placeholder: n, className: r }) => {
570
- let { language: i } = U(), { updateNodeData: a, clearSelection: o } = G(), s = W(), c = Be(null), l = t?.[i] ?? "", u = n || s("editor.treegeNode.labelPlaceholder"), d = (e) => e.stopPropagation();
571
- return Le(() => {
572
- let e = setTimeout(() => {
573
- c.current?.focus();
574
- }, 300);
575
- return () => clearTimeout(e);
576
- }, []), /* @__PURE__ */ L("input", {
577
- ref: c,
578
- type: "text",
579
- value: l,
580
- placeholder: u,
581
- onChange: (n) => {
582
- a(e, { label: {
583
- ...t,
584
- [i]: n.target.value
585
- } });
586
- },
587
- onKeyDown: (e) => {
588
- e.key === "Enter" && (e.preventDefault(), c.current?.blur(), o());
589
- },
590
- onClick: d,
591
- onMouseDown: d,
592
- onPointerDown: d,
593
- className: D("nodrag nopan tg:w-full tg:truncate tg:bg-transparent tg:outline-none tg:placeholder:text-muted-foreground/40", r)
594
- });
595
- };
596
- //#endregion
597
- //#region src/shared/components/ui/dropdown-menu.tsx
598
- function K({ ...e }) {
599
- return /* @__PURE__ */ L(V.Root, {
600
- "data-slot": "dropdown-menu",
601
- ...e
602
- });
603
- }
604
- function tn({ ...e }) {
605
- return /* @__PURE__ */ L(V.Trigger, {
606
- "data-slot": "dropdown-menu-trigger",
607
- ...e
608
- });
609
- }
610
- function nn({ className: e, sideOffset: t = 4, ...n }) {
611
- return /* @__PURE__ */ L(V.Portal, { children: /* @__PURE__ */ L(V.Content, {
612
- "data-slot": "dropdown-menu-content",
613
- sideOffset: t,
614
- className: D("tg:data-[state=closed]:fade-out-0 tg:data-[state=open]:fade-in-0 tg:data-[state=closed]:zoom-out-95 tg:data-[state=open]:zoom-in-95 tg:data-[side=bottom]:slide-in-from-top-2 tg:data-[side=left]:slide-in-from-right-2 tg:data-[side=right]:slide-in-from-left-2 tg:data-[side=top]:slide-in-from-bottom-2 tg:z-50 tg:max-h-(--radix-dropdown-menu-content-available-height) tg:min-w-[8rem] tg:origin-(--radix-dropdown-menu-content-transform-origin) tg:overflow-y-auto tg:overflow-x-hidden tg:rounded-md tg:border tg:bg-popover tg:p-1 tg:text-popover-foreground tg:shadow-md tg:data-[state=closed]:animate-out tg:data-[state=open]:animate-in", e),
615
- ...n
616
- }) });
617
- }
618
- function q({ ...e }) {
619
- return /* @__PURE__ */ L(V.Group, {
620
- "data-slot": "dropdown-menu-group",
621
- ...e
622
- });
623
- }
624
- function J({ className: e, inset: t, variant: n = "default", ...r }) {
625
- return /* @__PURE__ */ L(V.Item, {
626
- "data-slot": "dropdown-menu-item",
627
- "data-inset": t,
628
- "data-variant": n,
629
- className: D("tg:data-[variant=destructive]:*:[svg]:!text-destructive tg:relative tg:flex tg:cursor-default tg:select-none tg:items-center tg:gap-2 tg:rounded-sm tg:px-2 tg:py-1.5 tg:text-sm tg:outline-hidden tg:focus:bg-accent tg:focus:text-accent-foreground tg:data-[disabled]:pointer-events-none tg:data-[inset]:pl-8 tg:data-[variant=destructive]:text-destructive tg:data-[disabled]:opacity-50 tg:data-[variant=destructive]:focus:bg-destructive/10 tg:data-[variant=destructive]:focus:text-destructive tg:dark:data-[variant=destructive]:focus:bg-destructive/20 tg:[&_svg:not([class*='size-'])]:size-4 tg:[&_svg:not([class*='text-'])]:text-muted-foreground tg:[&_svg]:pointer-events-none tg:[&_svg]:shrink-0", e),
630
- ...r
631
- });
632
- }
633
- function rn({ className: e, inset: t, ...n }) {
634
- return /* @__PURE__ */ L(V.Label, {
635
- "data-slot": "dropdown-menu-label",
636
- "data-inset": t,
637
- className: D("tg:px-1.5 tg:py-1 tg:font-medium tg:text-muted-foreground tg:text-xs tg:data-[inset]:pl-7", e),
638
- ...n
639
- });
640
- }
641
- function Y({ className: e, ...t }) {
642
- return /* @__PURE__ */ L(V.Separator, {
643
- "data-slot": "dropdown-menu-separator",
644
- className: D("tg:-mx-1 tg:my-1 tg:h-px tg:bg-border", e),
645
- ...t
646
- });
647
- }
648
- //#endregion
649
- //#region src/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.tsx
650
- var an = ({ nodeId: e, className: t }) => {
651
- let { selectNode: n } = G(), { setIsNodeSheetOpen: r, openDeleteNodeConfirmation: i } = U(), a = W(), o = (e) => e.stopPropagation();
652
- return /* @__PURE__ */ R(K, {
653
- modal: !1,
654
- children: [/* @__PURE__ */ L(tn, {
655
- asChild: !0,
656
- onClick: o,
657
- children: /* @__PURE__ */ L("button", {
658
- type: "button",
659
- "aria-label": a("editor.nodeActionsSheet.editNode"),
660
- className: D("nodrag nopan tg:absolute tg:top-2 tg:right-2 tg:flex tg:h-6 tg:w-6 tg:cursor-pointer tg:items-center tg:justify-center tg:rounded-md tg:opacity-60 tg:transition-all tg:hover:text-[--treege-color-primary] tg:hover:opacity-100", t),
661
- children: /* @__PURE__ */ L(gt, { className: "tg:h-3.5 tg:w-3.5" })
662
- })
663
- }), /* @__PURE__ */ R(nn, {
664
- align: "end",
665
- onClick: o,
666
- children: [
667
- /* @__PURE__ */ R(J, {
668
- onSelect: () => {
669
- n(e), r(!0);
670
- },
671
- children: [/* @__PURE__ */ L(wt, {}), a("common.settings")]
672
- }),
673
- /* @__PURE__ */ L(Y, {}),
674
- /* @__PURE__ */ R(J, {
675
- variant: "destructive",
676
- onSelect: () => {
677
- i(e);
678
- },
679
- children: [/* @__PURE__ */ L(Et, {}), a("common.delete")]
680
- })
681
- ]
682
- })]
683
- });
684
- }, on = Nt("tg:inline-flex tg:w-fit tg:shrink-0 tg:items-center tg:justify-center tg:gap-1 tg:overflow-hidden tg:rounded-full tg:border tg:border-transparent tg:px-2 tg:py-0.5 tg:text-xs tg:font-medium tg:whitespace-nowrap tg:transition-[color,box-shadow] tg:focus-visible:border-ring tg:focus-visible:ring-[3px] tg:focus-visible:ring-ring/50 tg:aria-invalid:border-destructive tg:aria-invalid:ring-destructive/20 tg:dark:aria-invalid:ring-destructive/40 tg:[&>svg]:pointer-events-none tg:[&>svg]:size-3", {
685
- defaultVariants: { variant: "default" },
686
- variants: { variant: {
687
- blue: "tg:bg-blue-500 tg:text-white tg:dark:bg-blue-600",
688
- default: "tg:border-transparent tg:bg-primary tg:text-primary-foreground tg:[a&]:hover:bg-primary/90",
689
- destructive: "tg:border-transparent tg:bg-destructive tg:text-white tg:[a&]:hover:bg-destructive/90 tg:focus-visible:ring-destructive/20 tg:dark:focus-visible:ring-destructive/40 tg:dark:bg-destructive/60",
690
- outline: "tg:border-foreground/30 tg:text-foreground tg:[a&]:hover:bg-accent tg:[a&]:hover:text-accent-foreground",
691
- purple: "tg:bg-purple-600 tg:hover:bg-purple-700 tg:text-white",
692
- secondary: "tg:border-transparent tg:bg-secondary tg:text-secondary-foreground tg:[a&]:hover:bg-secondary/90"
693
- } }
694
- });
695
- function sn({ className: e, variant: t, asChild: n = !1, ...r }) {
696
- return /* @__PURE__ */ L(n ? Mt : "span", {
697
- "data-slot": "badge",
698
- className: D(on({ variant: t }), e),
699
- ...r
700
- });
701
- }
702
- var cn = Fe(({ data: e, id: t }) => /* @__PURE__ */ R(I, { children: [
703
- /* @__PURE__ */ L(Ce, {}),
704
- /* @__PURE__ */ L("div", {
705
- className: "tg:-top-3.5 tg:absolute tg:left-6",
706
- children: /* @__PURE__ */ R(sn, {
707
- className: "tg:max-w-50 tg:bg-chart-2",
708
- children: [/* @__PURE__ */ L(We, { className: "tg:!w-3 tg:!h-3" }), /* @__PURE__ */ L(en, {
709
- nodeId: t,
710
- label: e?.label,
711
- className: "tg:min-w-0 tg:flex-1 tg:text-xs tg:text-white tg:placeholder:text-white/60"
712
- })]
713
- })
714
- }),
715
- /* @__PURE__ */ L(an, { nodeId: t })
716
- ] })), ln = {
717
- data: { type: "text" },
718
- id: Qt(),
719
- position: {
720
- x: 0,
721
- y: 0
722
- },
723
- type: "input"
724
- }, un = () => {
725
- let { setNodes: e, setEdges: t, screenToFlowPosition: n, getNode: i, getNodes: a, getEdges: o } = N(), s = P((n, i, a = !1, s) => {
726
- let c = n.id, l = o().filter((e) => e.source === c), u = r(n);
727
- if (l.length > 0 && !u) return;
728
- let d = Qt(), f = {
729
- ...ln,
730
- ...s && {
731
- data: s.data ?? {},
732
- type: s.type
733
- },
734
- id: d,
735
- position: i,
736
- selected: a
737
- };
738
- n?.parentId && (f.parentId = n.parentId, f.extent = "parent"), e((e) => e.concat(f)), t((e) => {
739
- let t = e.filter((e) => e.source === c).length > 0, n = {
740
- data: t && u ? { conditions: [{
741
- field: c,
742
- operator: "===",
743
- value: ""
744
- }] } : void 0,
745
- id: Qt(),
746
- source: c,
747
- target: d,
748
- type: t && u ? "conditional" : "default"
749
- };
750
- return t && u ? e.map((e) => e.source === c ? {
751
- ...e,
752
- data: {
753
- ...e.data,
754
- conditions: e.data?.conditions || [{
755
- field: c,
756
- operator: "===",
757
- value: ""
758
- }]
759
- },
760
- type: "conditional"
761
- } : e).concat(n) : e.concat(n);
762
- }), a && requestAnimationFrame(() => {
763
- e((e) => e.map((e) => ({
764
- ...e,
765
- selected: e.id === d
766
- }))), t((e) => e.map((e) => ({
767
- ...e,
768
- selected: !1
769
- })));
770
- });
771
- }, [
772
- o,
773
- e,
774
- t
775
- ]), c = P((e) => {
776
- t((t) => {
777
- let n = Oe(e, t), a = e.source, o = i(a);
778
- return n.filter((e) => e.source === a).length > 1 && o && r(o) ? n.map((e) => e.source === a ? {
779
- ...e,
780
- data: {
781
- ...e.data,
782
- conditions: e.data?.conditions || [{
783
- field: a,
784
- operator: "===",
785
- value: ""
786
- }]
787
- },
788
- type: "conditional"
789
- } : e) : n;
790
- });
791
- }, [t, i]), l = P((e, t) => {
792
- let n = i(e);
793
- if (!n) return;
794
- let r = getComputedStyle(document.documentElement).getPropertyValue("--node-height"), c = getComputedStyle(document.documentElement).getPropertyValue("--node-width"), l = parseFloat(r) || 100, u = parseFloat(c) || 100, d = n.position.y + l + 100, f = a(), p = o(), m = f.filter((t) => p.some((n) => n.source === e && n.target === t.id)).map((e) => e.position.x);
795
- s(n, {
796
- x: m.length === 0 ? n.position.x : m.length % 2 == 1 ? Math.max(...m) + u + 50 : Math.min(...m) - u - 50,
797
- y: d
798
- }, !0, t);
799
- }, [
800
- i,
801
- a,
802
- o,
803
- s
804
- ]), u = P((e, t) => {
805
- if (!t.isValid) {
806
- let { clientX: r, clientY: a } = "changedTouches" in e ? e.changedTouches[0] : e, o = t.fromNode;
807
- if (!o) return;
808
- let c = n({
809
- x: r,
810
- y: a
811
- }), l = o.parentId ? i(o.parentId) : void 0, u = l?.position ?? {
812
- x: 0,
813
- y: 0
814
- };
815
- s(o, l ? {
816
- x: c.x - u.x,
817
- y: c.y - u.y
818
- } : c, !0);
819
- }
820
- }, [
821
- s,
822
- i,
823
- n
824
- ]), d = P((e) => {
825
- t((t) => $t(t.filter((t) => !e.find((e) => e.id === t.id)), new Set(e.map((e) => e.source))));
826
- }, [t]);
827
- return {
828
- isValidConnection: P((e) => {
829
- if (e.source === e.target) return !1;
830
- let t = i(e.source);
831
- return t ? !(o().filter((t) => t.source === e.source).length > 0 && !r(t)) : !1;
832
- }, [i, o]),
833
- onAddFromHandle: l,
834
- onConnect: c,
835
- onConnectEnd: u,
836
- onEdgesDelete: d
837
- };
838
- }, X = {
839
- address: "address",
840
- autocomplete: "autocomplete",
841
- checkbox: "checkbox",
842
- date: "date",
843
- daterange: "daterange",
844
- file: "file",
845
- hidden: "hidden",
846
- http: "http",
847
- number: "number",
848
- password: "password",
849
- radio: "radio",
850
- select: "select",
851
- submit: "submit",
852
- switch: "switch",
853
- text: "text",
854
- textarea: "textarea",
855
- time: "time",
856
- timerange: "timerange"
857
- }, dn = {
858
- divider: "divider",
859
- title: "title"
860
- }, fn = {
861
- [X.address]: pt,
862
- [X.autocomplete]: St,
863
- [X.checkbox]: Ye,
864
- [X.date]: Ge,
865
- [X.daterange]: Ke,
866
- [X.file]: vt,
867
- [X.hidden]: at,
868
- [X.http]: tt,
869
- [X.number]: ot,
870
- [X.password]: lt,
871
- [X.radio]: Qe,
872
- [X.select]: dt,
873
- [X.submit]: Ct,
874
- [X.switch]: Tt,
875
- [X.text]: qe,
876
- [X.textarea]: He,
877
- [X.time]: $e,
878
- [X.timerange]: et,
879
- [dn.divider]: ht,
880
- [dn.title]: st,
881
- [l.flow]: _t
882
- }, pn = bt, Z = (e) => e && fn[e] || pn, mn = ({ nodeId: e, isConnectable: t }) => {
883
- let { onAddFromHandle: n } = un(), r = W(), [i, a] = F(!1), o = Z(l.flow);
884
- return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(xe, {
885
- type: "source",
886
- position: Te.Bottom,
887
- isConnectable: t,
888
- onClick: (e) => {
889
- e.defaultPrevented || a(!0);
890
- },
891
- className: "tg:flex tg:h-6! tg:w-6! tg:cursor-pointer tg:items-center tg:justify-center tg:rounded-sm tg:transition-colors tg:hover:bg-primary/80!",
892
- children: /* @__PURE__ */ L(z, { className: "tg:h-4 tg:w-4 tg:text-primary-foreground" })
893
- }), /* @__PURE__ */ R(K, {
894
- open: i,
895
- onOpenChange: a,
896
- children: [/* @__PURE__ */ L(tn, {
897
- asChild: !0,
898
- children: /* @__PURE__ */ L("span", {
899
- "aria-hidden": !0,
900
- className: "tg:-translate-x-1/2 tg:pointer-events-none tg:absolute tg:bottom-0 tg:left-1/2 tg:h-0 tg:w-0"
901
- })
902
- }), /* @__PURE__ */ R(nn, {
903
- align: "center",
904
- side: "bottom",
905
- className: "treege-scrollbar tg:max-h-80",
906
- children: [
907
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: r("editor.selectNodeType.options.input") }), Object.values(X).map((t) => /* @__PURE__ */ R(J, {
908
- onClick: () => n(e, {
909
- data: { type: t },
910
- type: l.input
911
- }),
912
- className: "tg:capitalize",
913
- children: [/* @__PURE__ */ L(Z(t), {}), t]
914
- }, t))] }),
915
- /* @__PURE__ */ L(Y, {}),
916
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: r("editor.selectNodeType.options.ui") }), Object.values(dn).map((t) => /* @__PURE__ */ R(J, {
917
- onClick: () => n(e, {
918
- data: { type: t },
919
- type: l.ui
920
- }),
921
- className: "tg:capitalize",
922
- children: [/* @__PURE__ */ L(Z(t), {}), t]
923
- }, t))] }),
924
- /* @__PURE__ */ L(Y, {}),
925
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: r("common.other") }), /* @__PURE__ */ R(J, {
926
- onClick: () => n(e, {
927
- data: {},
928
- type: l.flow
929
- }),
930
- children: [/* @__PURE__ */ L(o, {}), r("editor.selectNodeType.options.flow")]
931
- })] })
932
- ]
933
- })]
934
- })] });
935
- }, hn = (e) => {
936
- switch (e) {
937
- case "number":
938
- case "daterange":
939
- case "timerange":
940
- case "file": return null;
941
- case "switch": return !1;
942
- case "checkbox": return [];
943
- default: return "";
944
- }
945
- }, gn = ({ nodeId: e, data: n }) => {
946
- let { language: r } = U(), i = n?.type;
947
- if (!i) return null;
948
- let o = {
949
- data: n,
950
- id: e,
951
- position: {
952
- x: 0,
953
- y: 0
954
- },
955
- type: "input"
956
- }, c = a(n.label, r), l = t(o), u = /* @__PURE__ */ R("div", {
957
- className: "tg:flex tg:items-center tg:gap-1 tg:text-[10px] tg:text-muted-foreground tg:capitalize tg:[&>svg]:size-3",
958
- children: [/* @__PURE__ */ L(Z(i), {}), i]
959
- });
960
- if (i === "hidden") {
961
- let e = n.defaultValue?.type === "static" ? n.defaultValue.staticValue : void 0, t = n.defaultValue?.type === "reference" ? n.defaultValue.referenceField : void 0, r = Array.isArray(e) ? e.join(", ") : typeof e == "boolean" ? String(e) : e ?? (t ? `→ ${t}` : "");
962
- return /* @__PURE__ */ R("div", {
963
- className: "tg:pointer-events-none tg:flex tg:select-none tg:flex-col tg:gap-1 tg:text-sm",
964
- children: [
965
- u,
966
- /* @__PURE__ */ L("span", {
967
- className: "tg:truncate tg:font-medium",
968
- children: c || l
969
- }),
970
- /* @__PURE__ */ L("span", {
971
- className: "tg:truncate tg:text-muted-foreground tg:text-xs",
972
- children: r || "—"
973
- })
974
- ]
975
- });
976
- }
977
- let d = fe[i];
978
- if (!d) return null;
979
- let f = a(n.helperText, r), p = s(n, r);
980
- return /* @__PURE__ */ R("div", {
981
- className: D("tg:pointer-events-none tg:flex tg:select-none tg:flex-col tg:gap-1", i === "submit" && "tg:items-center"),
982
- children: [u, /* @__PURE__ */ L(d, {
983
- node: o,
984
- value: hn(i),
985
- setValue: () => {},
986
- id: e,
987
- name: l,
988
- label: c || void 0,
989
- placeholder: p || void 0,
990
- helperText: f || void 0
991
- })]
992
- });
993
- }, _n = Object.values(X), vn = Object.values(dn), yn = ({ nodeId: e, nodeType: t, subType: n }) => {
994
- let { updateNodeType: r } = G(), { getEdges: i } = N(), { openNodeTypeChangeConfirmation: a } = U(), o = W(), s = (e) => e.stopPropagation(), c = n || t, u = t === l.flow ? o("editor.selectNodeType.options.flow") : c, d = Z(c), f = Z(l.flow), p = (t, n) => {
995
- let o = i().filter((t) => t.source === e).length;
996
- if ((t === l.ui || t === l.flow) && o > 1) {
997
- a({
998
- nodeId: e,
999
- subType: n,
1000
- type: t
1001
- });
1002
- return;
1003
- }
1004
- r(e, t, n);
1005
- };
1006
- return /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
1007
- asChild: !0,
1008
- onClick: s,
1009
- children: /* @__PURE__ */ R(sn, {
1010
- variant: "default",
1011
- className: "nodrag nopan tg:cursor-pointer tg:px-1.5 tg:py-0 tg:text-[10px] tg:capitalize tg:[&>svg]:size-2.5",
1012
- children: [
1013
- /* @__PURE__ */ L(d, { className: "tg:mt-0.5" }),
1014
- u || o("editor.selectNodeType.nodeType"),
1015
- /* @__PURE__ */ L(Xe, {})
1016
- ]
1017
- })
1018
- }), /* @__PURE__ */ R(nn, {
1019
- align: "start",
1020
- className: "treege-scrollbar tg:max-h-80",
1021
- onClick: s,
1022
- children: [
1023
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: o("editor.selectNodeType.options.input") }), _n.map((e) => {
1024
- let r = Z(e);
1025
- return /* @__PURE__ */ R(J, {
1026
- onClick: () => p(l.input, e),
1027
- className: D("tg:capitalize", t === l.input && e === n && "tg:bg-accent"),
1028
- children: [/* @__PURE__ */ L(r, {}), e]
1029
- }, e);
1030
- })] }),
1031
- /* @__PURE__ */ L(Y, {}),
1032
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: o("editor.selectNodeType.options.ui") }), vn.map((e) => {
1033
- let r = Z(e);
1034
- return /* @__PURE__ */ R(J, {
1035
- onClick: () => p(l.ui, e),
1036
- className: D("tg:capitalize", t === l.ui && e === n && "tg:bg-accent"),
1037
- children: [/* @__PURE__ */ L(r, {}), e]
1038
- }, e);
1039
- })] }),
1040
- /* @__PURE__ */ L(Y, {}),
1041
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ L(rn, { children: o("common.other") }), /* @__PURE__ */ R(J, {
1042
- onClick: () => p(l.flow),
1043
- className: D(t === l.flow && "tg:bg-accent"),
1044
- children: [/* @__PURE__ */ L(f, {}), o("editor.selectNodeType.options.flow")]
1045
- })] })
1046
- ]
1047
- })] });
1048
- }, bn = [
1049
- "radio",
1050
- "select",
1051
- "checkbox",
1052
- "autocomplete"
1053
- ], xn = ({ nodeId: e, data: t }) => {
1054
- let [n, r] = F(!1), [i, a] = F(""), [o, s] = F(""), { updateNodeData: c } = G(), { language: l } = U(), u = W(), f = t && "type" in t ? t.type : void 0;
1055
- if (!(f && bn.includes(f))) return null;
1056
- let p = t.options ?? [], m = () => {
1057
- a(""), s("");
1058
- }, h = (t) => {
1059
- t?.preventDefault();
1060
- let n = i.trim(), a = o.trim() || n;
1061
- if (!(n || a)) return;
1062
- let s = {
1063
- label: { [l]: n },
1064
- value: a
1065
- };
1066
- c(e, { options: [...p, s] }), m(), r(!1);
1067
- }, g = (e) => {
1068
- r(e), e || m();
1069
- }, _ = (e) => {
1070
- e.key === "Enter" && (e.preventDefault(), h());
1071
- }, v = (e) => e.stopPropagation();
1072
- return /* @__PURE__ */ R("div", {
1073
- className: "nodrag nopan tg:my-1 tg:flex tg:flex-col tg:gap-0.5",
1074
- children: [p.map((e, t) => {
1075
- let n = u(e.label) || e.value || "—", r = `${e.value || "opt"}-${t}`;
1076
- return /* @__PURE__ */ L("div", {
1077
- className: "tg:truncate tg:text-muted-foreground tg:text-xs",
1078
- children: n
1079
- }, r);
1080
- }), /* @__PURE__ */ R(ie, {
1081
- open: n,
1082
- onOpenChange: g,
1083
- children: [/* @__PURE__ */ L(ne, {
1084
- asChild: !0,
1085
- onClick: v,
1086
- children: /* @__PURE__ */ R(A, {
1087
- type: "button",
1088
- variant: "link",
1089
- size: "xs",
1090
- className: "tg:w-fit tg:p-0! tg:focus-visible:border-transparent! tg:focus-visible:ring-0!",
1091
- children: [/* @__PURE__ */ L(z, { className: "tg:size-3" }), u("editor.inputNodeForm.addOption")]
1092
- })
1093
- }), /* @__PURE__ */ L(ae, {
1094
- align: "start",
1095
- className: "tg:w-64 tg:p-3",
1096
- onClick: v,
1097
- children: /* @__PURE__ */ R("form", {
1098
- onSubmit: h,
1099
- className: "tg:flex tg:flex-col tg:gap-2",
1100
- children: [
1101
- /* @__PURE__ */ R("div", {
1102
- className: "tg:flex tg:flex-col tg:gap-1",
1103
- children: [/* @__PURE__ */ L(d, {
1104
- htmlFor: `${e}-option-label`,
1105
- className: "tg:text-xs",
1106
- children: u("editor.inputNodeForm.optionLabel")
1107
- }), /* @__PURE__ */ L(k, {
1108
- id: `${e}-option-label`,
1109
- autoFocus: !0,
1110
- value: i,
1111
- onChange: (e) => a(e.target.value),
1112
- onKeyDown: _
1113
- })]
1114
- }),
1115
- /* @__PURE__ */ R("div", {
1116
- className: "tg:flex tg:flex-col tg:gap-1",
1117
- children: [/* @__PURE__ */ L(d, {
1118
- htmlFor: `${e}-option-value`,
1119
- className: "tg:text-xs",
1120
- children: u("editor.inputNodeForm.optionValue")
1121
- }), /* @__PURE__ */ L(k, {
1122
- id: `${e}-option-value`,
1123
- value: o,
1124
- onChange: (e) => s(e.target.value),
1125
- onKeyDown: _
1126
- })]
1127
- }),
1128
- /* @__PURE__ */ L(A, {
1129
- type: "submit",
1130
- size: "sm",
1131
- disabled: !(i.trim() || o.trim()),
1132
- children: u("common.create")
1133
- })
1134
- ]
1135
- })
1136
- })]
1137
- })]
1138
- });
1139
- }, Sn = ({ nodeId: e, required: t }) => {
1140
- let { updateNodeData: n } = G(), r = W();
1141
- return /* @__PURE__ */ L(sn, {
1142
- variant: t ? "destructive" : "outline",
1143
- asChild: !0,
1144
- className: "nodrag nopan tg:cursor-pointer tg:px-1.5 tg:py-0 tg:text-[10px] tg:capitalize tg:[&>svg]:size-2.5",
1145
- children: /* @__PURE__ */ L("button", {
1146
- type: "button",
1147
- onClick: (r) => {
1148
- r.stopPropagation(), n(e, { required: !t });
1149
- },
1150
- children: r(t ? "editor.inputNodeForm.required" : "editor.inputNodeForm.optional")
1151
- })
1152
- });
1153
- }, Cn = ({ children: e, inGroup: t, isSubmit: n }) => /* @__PURE__ */ L("div", {
1154
- className: D("react-flow__node__wrapper tg:relative", t && "in-group", n && "submit-type"),
1155
- children: e
1156
- }), wn = Fe((e) => {
1157
- let { id: t, isConnectable: n, parentId: r, selected: i, type: a } = e, o = e.type === "input" ? e.data : void 0, s = e.type === "ui" ? e.data : void 0, c = o?.type ?? s?.type, l = o?.type === "submit", u = !i && !!o?.type;
1158
- return /* @__PURE__ */ R(Cn, {
1159
- inGroup: !!r,
1160
- isSubmit: l,
1161
- children: [
1162
- /* @__PURE__ */ L(an, { nodeId: t }),
1163
- /* @__PURE__ */ L(xe, {
1164
- type: "target",
1165
- position: Te.Top,
1166
- isConnectable: n,
1167
- isConnectableStart: a === "ui"
1168
- }),
1169
- u && o ? /* @__PURE__ */ L(gn, {
1170
- nodeId: t,
1171
- data: o
1172
- }) : /* @__PURE__ */ R(I, { children: [
1173
- /* @__PURE__ */ L(en, {
1174
- nodeId: t,
1175
- label: e.data?.label,
1176
- placeholder: o?.name,
1177
- className: D("tg:py-1", a === "ui" && "tg:capitalize")
1178
- }),
1179
- /* @__PURE__ */ R("div", {
1180
- className: "tg:mb-1 tg:flex tg:gap-1",
1181
- children: [/* @__PURE__ */ L(yn, {
1182
- nodeId: t,
1183
- nodeType: a,
1184
- subType: c
1185
- }), o && !l && /* @__PURE__ */ L(Sn, {
1186
- nodeId: t,
1187
- required: o.required
1188
- })]
1189
- }),
1190
- o && /* @__PURE__ */ L(xn, {
1191
- nodeId: t,
1192
- data: o
1193
- })
1194
- ] }),
1195
- /* @__PURE__ */ L(mn, {
1196
- nodeId: t,
1197
- isConnectable: n
1198
- })
1199
- ]
1200
- });
1201
- }), Tn = {
1202
- [l.flow]: wn,
1203
- [l.group]: cn,
1204
- [l.input]: wn,
1205
- [l.ui]: wn
1206
- }, En = ({ show: e, onToggle: t }) => /* @__PURE__ */ L(ve, {
1207
- onClick: t,
1208
- title: e ? "Hide minimap" : "Show minimap",
1209
- children: L(e ? mt : pt, {})
1210
- }), Dn = {
1211
- "!==": "≠",
1212
- "<": "<",
1213
- "<=": "≤",
1214
- "===": "=",
1215
- ">": ">",
1216
- ">=": "≥"
1217
- }, On = (e, t) => {
1218
- let n = e?.filter((e) => e.value !== void 0 && e.value !== "") ?? [];
1219
- return n.length === 0 ? "" : n.map((e, n) => {
1220
- let r = Dn[e.operator ?? ""] ?? e.operator ?? "", i = `${e.field ? t(e.field) : ""} ${r} ${e.value ?? ""}`.trim();
1221
- return `${n === 0 ? "" : ` ${e.logicalOperator ?? "AND"} `}${i}`;
1222
- }).join("");
1223
- }, kn = () => {
1224
- let { pendingNodeTypeChange: e, closeNodeTypeChangeConfirmation: t } = U(), { getEdges: n, getNode: r, setEdges: i, updateEdgeData: a } = N(), { updateNodeType: o } = G(), s = W(), c = ze(() => e ? n().filter((t) => t.source === e.nodeId).sort((e, t) => {
1225
- let n = r(e.target)?.position ?? {
1226
- x: 0,
1227
- y: 0
1228
- }, i = r(t.target)?.position ?? {
1229
- x: 0,
1230
- y: 0
1231
- };
1232
- return n.x - i.x || n.y - i.y;
1233
- }) : [], [
1234
- e,
1235
- n,
1236
- r
1237
- ]), [l, u] = F("");
1238
- Le(() => {
1239
- c.length > 0 && u(c[0].id);
1240
- }, [c]);
1241
- let f = (e) => {
1242
- e || t();
1243
- }, h = () => {
1244
- if (!(e && l)) {
1245
- t();
1246
- return;
1247
- }
1248
- let { nodeId: n, type: r, subType: s } = e;
1249
- i((e) => e.filter((e) => e.source !== n || e.id === l)), a(l, {
1250
- conditions: void 0,
1251
- configured: void 0,
1252
- isFallback: void 0
1253
- }), o(n, r, s), t();
1254
- }, g = (e) => {
1255
- let t = r(e)?.data;
1256
- return s(t && "label" in t ? t.label : void 0) || t?.name || (e.length > 5 ? `${e.slice(0, 5)}…` : e);
1257
- }, v = (e) => {
1258
- let t = r(e)?.data, n = s(t?.label) || t?.name || e;
1259
- return n === e && n.length > 5 ? `${n.slice(0, 5)}…` : n;
1260
- }, y = (e) => e?.isFallback ? s("editor.conditionalEdge.fallback") : e?.label ? e.label : On(e?.conditions, v) || s("editor.changeNodeTypeDialog.noConditions");
1261
- return /* @__PURE__ */ L(m, {
1262
- open: e !== null,
1263
- onOpenChange: f,
1264
- children: /* @__PURE__ */ R(_, {
1265
- showCloseButton: !1,
1266
- children: [
1267
- /* @__PURE__ */ R(me, { children: [/* @__PURE__ */ L(p, { children: s("editor.changeNodeTypeDialog.title") }), /* @__PURE__ */ L(ee, { children: s("editor.changeNodeTypeDialog.description") })] }),
1268
- /* @__PURE__ */ L(Kt, {
1269
- className: "tg:max-h-80",
1270
- children: /* @__PURE__ */ L(E, {
1271
- value: l,
1272
- onValueChange: u,
1273
- className: "tg:gap-2 tg:pr-2",
1274
- children: c.map((e) => {
1275
- let t = e.data, n = y(t), r = g(e.target);
1276
- return /* @__PURE__ */ R(d, {
1277
- htmlFor: `keep-${e.id}`,
1278
- className: "tg:flex tg:cursor-pointer tg:items-start tg:gap-3 tg:rounded-lg tg:border tg:bg-muted/20 tg:p-3",
1279
- children: [/* @__PURE__ */ L(pe, {
1280
- id: `keep-${e.id}`,
1281
- value: e.id,
1282
- className: "tg:mt-1"
1283
- }), /* @__PURE__ */ R("div", {
1284
- className: "tg:flex tg:flex-col tg:gap-1",
1285
- children: [/* @__PURE__ */ L("span", {
1286
- className: "tg:font-medium",
1287
- children: r
1288
- }), /* @__PURE__ */ L("span", {
1289
- className: "tg:text-muted-foreground tg:text-xs",
1290
- children: n
1291
- })]
1292
- })]
1293
- }, e.id);
1294
- })
1295
- })
1296
- }),
1297
- /* @__PURE__ */ R(S, { children: [/* @__PURE__ */ L(A, {
1298
- variant: "outline",
1299
- onClick: t,
1300
- children: s("common.cancel")
1301
- }), /* @__PURE__ */ L(A, {
1302
- onClick: h,
1303
- disabled: !l,
1304
- children: s("editor.changeNodeTypeDialog.keepBranch")
1305
- })] })
1306
- ]
1307
- })
1308
- });
1309
- }, An = () => {
1310
- let { pendingDeleteNodeId: e, closeDeleteNodeConfirmation: t } = U(), { deleteNode: n } = G(), r = W();
1311
- return /* @__PURE__ */ L(m, {
1312
- open: e !== null,
1313
- onOpenChange: (e) => {
1314
- e || t();
1315
- },
1316
- children: /* @__PURE__ */ R(_, {
1317
- showCloseButton: !1,
1318
- children: [/* @__PURE__ */ R(me, { children: [/* @__PURE__ */ L(p, { children: r("editor.nodeActionsSheet.deleteNode") }), /* @__PURE__ */ L(ee, { children: r("editor.nodeActionsSheet.deleteNodeConfirm") })] }), /* @__PURE__ */ R(S, { children: [/* @__PURE__ */ L(A, {
1319
- variant: "outline",
1320
- onClick: t,
1321
- children: r("common.cancel")
1322
- }), /* @__PURE__ */ L(A, {
1323
- onClick: () => {
1324
- e && n(e), t();
1325
- },
1326
- children: r("common.delete")
1327
- })] })]
1328
- })
1329
- });
1330
- }, jn = 200, Mn = 100, Nn = (e) => !!(e.measured?.width && e.measured?.height), Pn = (e, t, n) => {
1331
- let r = n === "TB" ? "y" : "x";
1332
- return e.reduce((e, n) => t.node(n.id)[r] < t.node(e.id)[r] ? n : e, e[0]);
1333
- }, Fn = (e, t, n) => {
1334
- let r = new It.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
1335
- r.setGraph({
1336
- nodesep: n.horizontalSpacing,
1337
- rankdir: n.direction,
1338
- ranksep: n.verticalSpacing
1339
- });
1340
- let i = /* @__PURE__ */ new Set();
1341
- e.forEach((e) => {
1342
- i.add(e.id), r.setNode(e.id, {
1343
- height: e.measured?.height ?? Mn,
1344
- width: e.measured?.width ?? jn
1345
- });
1346
- }), t.forEach((e) => {
1347
- i.has(e.source) && i.has(e.target) && r.setEdge(e.source, e.target);
1348
- }), It.layout(r);
1349
- let a = Pn(e, r, n.direction), o = a.measured?.width ?? jn, s = a.measured?.height ?? Mn, c = r.node(a.id), l = a.position.x - (c.x - o / 2), u = a.position.y - (c.y - s / 2), d = /* @__PURE__ */ new Map();
1350
- return e.forEach((e) => {
1351
- let { x: t, y: n } = r.node(e.id), i = e.measured?.width ?? jn, a = e.measured?.height ?? Mn;
1352
- d.set(e.id, {
1353
- x: t - i / 2 + l,
1354
- y: n - a / 2 + u
1355
- });
1356
- }), d;
1357
- }, In = (e) => {
1358
- let t = /* @__PURE__ */ new Map();
1359
- return e.forEach((e) => {
1360
- let n = t.get(e.parentId) ?? [];
1361
- n.push(e), t.set(e.parentId, n);
1362
- }), t;
1363
- }, Ln = (e, t, n = {}) => {
1364
- let r = {
1365
- direction: n.direction ?? "TB",
1366
- horizontalSpacing: n.horizontalSpacing ?? 60,
1367
- verticalSpacing: n.verticalSpacing ?? 80
1368
- }, i = /* @__PURE__ */ new Map();
1369
- return In(e).forEach((e) => {
1370
- let n = e.filter(Nn);
1371
- n.length !== 0 && Fn(n, t, r).forEach((e, t) => {
1372
- i.set(t, e);
1373
- });
1374
- }), e.map((e) => {
1375
- let t = i.get(e.id);
1376
- return t ? {
1377
- ...e,
1378
- position: t
1379
- } : e;
1380
- });
1381
- }, Rn = (e) => Array.from(e.nodeLookup.values()).map((e) => `${e.id}:${e.measured?.width ?? 0}x${e.measured?.height ?? 0}`).join("|"), zn = ({ direction: e, horizontalSpacing: t, verticalSpacing: n } = {}) => {
1382
- let { getNodes: r, getEdges: i, setNodes: a } = N(), o = Me(), s = Ne(Rn);
1383
- return Le(() => {
1384
- o && s && a(Ln(r(), i(), {
1385
- direction: e,
1386
- horizontalSpacing: t,
1387
- verticalSpacing: n
1388
- }));
1389
- }, [
1390
- o,
1391
- s,
1392
- e,
1393
- t,
1394
- n,
1395
- r,
1396
- i,
1397
- a
1398
- ]), null;
1399
- }, Bn = "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", Vn = {
1400
- claude: "claude-3-5-haiku-20241022",
1401
- deepseek: "deepseek-chat",
1402
- gemini: "gemini-2.5-flash",
1403
- openai: "gpt-4o-mini"
1404
- }, Hn = .3;
1405
- function Un(e) {
1406
- try {
1407
- return JSON.parse(e);
1408
- } catch (t) {
1409
- let n = e.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
1410
- try {
1411
- return JSON.parse(n);
1412
- } catch {
1413
- 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"}`);
1414
- }
1415
- }
1416
- }
1417
- async function Wn(e) {
1418
- let t = e.config.model || Vn.gemini, n = e.config.temperature ?? Hn, r = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:generateContent?key=${e.config.apiKey}`, {
1419
- body: JSON.stringify({
1420
- contents: [{ parts: [{ text: `${Bn}\n\nUser request: ${e.prompt}` }] }],
1421
- generationConfig: {
1422
- responseMimeType: "application/json",
1423
- temperature: n
1424
- }
1425
- }),
1426
- headers: { "Content-Type": "application/json" },
1427
- method: "POST"
1428
- });
1429
- if (!r.ok) {
1430
- let e = await r.text();
1431
- throw Error(`Gemini API error: ${e}`);
1432
- }
1433
- let i = (await r.json()).candidates?.[0]?.content?.parts?.[0]?.text;
1434
- if (!i) throw Error("No response from Gemini");
1435
- return Un(i);
1436
- }
1437
- async function Gn(e) {
1438
- let t = e.config.model || Vn.openai, n = e.config.temperature ?? Hn, r = await fetch("https://api.openai.com/v1/chat/completions", {
1439
- body: JSON.stringify({
1440
- messages: [{
1441
- content: Bn,
1442
- role: "system"
1443
- }, {
1444
- content: e.prompt,
1445
- role: "user"
1446
- }],
1447
- model: t,
1448
- response_format: { type: "json_object" },
1449
- temperature: n
1450
- }),
1451
- headers: {
1452
- Authorization: `Bearer ${e.config.apiKey}`,
1453
- "Content-Type": "application/json"
1454
- },
1455
- method: "POST"
1456
- });
1457
- if (!r.ok) {
1458
- let e = await r.text();
1459
- throw Error(`OpenAI API error: ${e}`);
1460
- }
1461
- let i = (await r.json()).choices?.[0]?.message?.content;
1462
- if (!i) throw Error("No response from OpenAI");
1463
- return Un(i);
1464
- }
1465
- async function Kn(e) {
1466
- let t = e.config.model || Vn.deepseek, n = e.config.temperature ?? Hn, r = await fetch("https://api.deepseek.com/v1/chat/completions", {
1467
- body: JSON.stringify({
1468
- messages: [{
1469
- content: Bn,
1470
- role: "system"
1471
- }, {
1472
- content: e.prompt,
1473
- role: "user"
1474
- }],
1475
- model: t,
1476
- response_format: { type: "json_object" },
1477
- temperature: n
1478
- }),
1479
- headers: {
1480
- Authorization: `Bearer ${e.config.apiKey}`,
1481
- "Content-Type": "application/json"
1482
- },
1483
- method: "POST"
1484
- });
1485
- if (!r.ok) {
1486
- let e = await r.text();
1487
- throw Error(`DeepSeek API error: ${e}`);
1488
- }
1489
- let i = (await r.json()).choices?.[0]?.message?.content;
1490
- if (!i) throw Error("No response from DeepSeek");
1491
- return Un(i);
1492
- }
1493
- async function qn(e) {
1494
- let t = e.config.model || Vn.claude, n = e.config.temperature ?? Hn, r = await fetch("https://api.anthropic.com/v1/messages", {
1495
- body: JSON.stringify({
1496
- max_tokens: 4096,
1497
- messages: [{
1498
- content: e.prompt,
1499
- role: "user"
1500
- }],
1501
- model: t,
1502
- system: Bn,
1503
- temperature: n
1504
- }),
1505
- headers: {
1506
- "anthropic-version": "2023-06-01",
1507
- "Content-Type": "application/json",
1508
- "x-api-key": e.config.apiKey
1509
- },
1510
- method: "POST"
1511
- });
1512
- if (!r.ok) {
1513
- let e = await r.text();
1514
- throw Error(`Claude API error: ${e}`);
1515
- }
1516
- let i = (await r.json()).content?.[0]?.text;
1517
- if (!i) throw Error("No response from Claude");
1518
- return Un(i);
1519
- }
1520
- function Jn(e) {
1521
- switch (e.config.provider) {
1522
- case "gemini": return Wn(e);
1523
- case "openai": return Gn(e);
1524
- case "deepseek": return Kn(e);
1525
- case "claude": return qn(e);
1526
- default: throw Error(`Unsupported AI provider: ${e.config.provider}`);
1527
- }
1528
- }
1529
- //#endregion
1530
- //#region src/editor/features/TreegeEditor/panel/AIGeneratorDialog.tsx
1531
- var Yn = ({ aiConfig: e, onGenerate: t }) => {
1532
- let [n, r] = F(!1), [i, a] = F(""), [o, s] = F(!1), c = W(), l = async () => {
1533
- if (!i.trim()) {
1534
- H.error(c("editor.aiGenerator.enterDescription"));
1535
- return;
1536
- }
1537
- if (!e?.apiKey) {
1538
- H.error(c("editor.aiGenerator.missingApiKey"), { description: c("editor.aiGenerator.missingApiKeyDesc") });
1539
- return;
1540
- }
1541
- s(!0);
1542
- try {
1543
- let n = await Jn({
1544
- config: e,
1545
- prompt: i.trim()
1546
- });
1547
- t({
1548
- edges: n.edges,
1549
- nodes: n.nodes
1550
- }), 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);
1551
- } catch (e) {
1552
- console.error("AI generation error:", e), H.error(c("editor.aiGenerator.failedToGenerate"), { description: e instanceof Error ? e.message : c("editor.aiGenerator.unknownError") });
1553
- } finally {
1554
- s(!1);
1555
- }
1556
- };
1557
- return /* @__PURE__ */ R(m, {
1558
- open: n,
1559
- onOpenChange: r,
1560
- children: [/* @__PURE__ */ L(re, {
1561
- asChild: !0,
1562
- children: /* @__PURE__ */ R(A, {
1563
- variant: "outline",
1564
- size: "sm",
1565
- disabled: !e?.apiKey,
1566
- children: [
1567
- /* @__PURE__ */ L(kt, { className: "tg:h-4 tg:w-4 tg:text-[#13d3b4]" }),
1568
- " ",
1569
- /* @__PURE__ */ L("span", {
1570
- className: "tg:hidden tg:md:inline",
1571
- children: c("editor.aiGenerator.buttonLabel")
1572
- })
1573
- ]
1574
- })
1575
- }), /* @__PURE__ */ R(_, {
1576
- className: "tg:sm:max-w-[550px]!",
1577
- children: [
1578
- /* @__PURE__ */ R(me, { children: [/* @__PURE__ */ L(p, { children: c("editor.aiGenerator.title") }), /* @__PURE__ */ L(ee, { children: c("editor.aiGenerator.titleDescription") })] }),
1579
- /* @__PURE__ */ R("div", {
1580
- className: "tg:grid tg:gap-4 tg:py-4",
1581
- children: [/* @__PURE__ */ R("div", {
1582
- className: "tg:grid tg:gap-2",
1583
- children: [
1584
- /* @__PURE__ */ L("label", {
1585
- htmlFor: "ai-prompt",
1586
- className: "tg:font-medium tg:text-sm",
1587
- children: c("editor.aiGenerator.description")
1588
- }),
1589
- /* @__PURE__ */ L(ce, {
1590
- placeholder: c("editor.aiGenerator.descriptionPlaceholder"),
1591
- value: i,
1592
- onChange: (e) => a(e.target.value),
1593
- onKeyDown: (e) => {
1594
- (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), l());
1595
- },
1596
- rows: 6,
1597
- disabled: o,
1598
- className: "tg:resize-none"
1599
- }),
1600
- /* @__PURE__ */ L("p", {
1601
- className: "tg:text-muted-foreground tg:text-xs",
1602
- children: c("editor.aiGenerator.keyboardShortcut").replace("{cmdEnter}", "⌘ Enter").replace("{ctrlEnter}", "Ctrl Enter")
1603
- })
1604
- ]
1605
- }), !e?.apiKey && /* @__PURE__ */ R("div", {
1606
- className: "tg:rounded-md tg:bg-muted tg:p-3 tg:text-sm",
1607
- children: [/* @__PURE__ */ L("p", {
1608
- className: "tg:font-medium",
1609
- children: c("editor.aiGenerator.aiNotConfigured")
1610
- }), /* @__PURE__ */ R("p", {
1611
- className: "tg:mt-1 tg:text-muted-foreground tg:text-xs",
1612
- children: [
1613
- c("editor.aiGenerator.aiNotConfiguredDesc").replace("{code}", ""),
1614
- " ",
1615
- /* @__PURE__ */ L("code", {
1616
- className: "tg:rounded tg:bg-background tg:px-1 tg:py-0.5",
1617
- children: "aiConfig"
1618
- })
1619
- ]
1620
- })]
1621
- })]
1622
- }),
1623
- /* @__PURE__ */ R(S, { children: [/* @__PURE__ */ L(A, {
1624
- variant: "outline",
1625
- onClick: () => r(!1),
1626
- disabled: o,
1627
- children: c("editor.aiGenerator.cancel")
1628
- }), /* @__PURE__ */ L(A, {
1629
- onClick: l,
1630
- disabled: o || !i.trim() || !e?.apiKey,
1631
- children: o ? /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(ft, { className: "tg:h-4 tg:w-4 tg:animate-spin" }), c("editor.aiGenerator.generating")] }) : /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(kt, { className: "tg:h-4 tg:w-4 tg:text-[--treege-color-primary]" }), c("editor.aiGenerator.generate")] })
1632
- })] })
1633
- ]
1634
- })]
1635
- });
1636
- }, Xn = Qt(), Zn = ({ onExportJson: e, onSave: t, extraMenuItems: n }) => {
1637
- let { flowId: r, setFlowId: i, aiConfig: a } = U(), { setNodes: o, setEdges: s, addNodes: c, screenToFlowPosition: l } = N(), u = r || Xn, d = je(), f = Ae(), p = Be(null), m = W(), h = () => {
1638
- 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 = l({
1639
- x: e - n,
1640
- y: t - r
1641
- });
1642
- c([{
1643
- ...ln,
1644
- id: Qt(),
1645
- position: i,
1646
- selected: !0
1647
- }]);
1648
- }, g = ({ target: e }) => {
1649
- let t = e.files?.[0];
1650
- if (!t) return;
1651
- let n = new FileReader();
1652
- n.onload = (e) => {
1653
- try {
1654
- let t = JSON.parse(e.target?.result);
1655
- t && Array.isArray(t.nodes) && Array.isArray(t.edges) ? (o(t.nodes), s(t.edges), H.success(m("editor.actionsPanel.importSuccess"), { description: m("editor.actionsPanel.importSuccessDesc") })) : H.error(m("editor.actionsPanel.invalidJson"), { description: m("editor.actionsPanel.invalidJsonDesc") });
1656
- } catch (e) {
1657
- console.warn(e), H.error(m("editor.actionsPanel.parseError"), { description: m("editor.actionsPanel.parseErrorDesc") });
1658
- }
1659
- p.current && (p.current.value = "");
1660
- }, n.readAsText(t);
1661
- }, _ = () => {
1662
- let t = {
1663
- edges: f,
1664
- id: u,
1665
- nodes: d
1666
- }, n = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), a = URL.createObjectURL(n), o = document.createElement("a");
1667
- o.href = a, o.download = "treege.json", o.click(), URL.revokeObjectURL(a), H.success(m("editor.actionsPanel.downloadSuccess"), { description: m("editor.actionsPanel.downloadSuccessDesc") }), r || i?.(u), e?.(t);
1668
- }, v = P(() => {
1669
- r || i?.(u), t?.({
1670
- edges: f,
1671
- id: u,
1672
- nodes: d
1673
- });
1674
- }, [
1675
- f,
1676
- r,
1677
- u,
1678
- d,
1679
- t,
1680
- i
1681
- ]);
1682
- return Le(() => {
1683
- let e = (e) => {
1684
- (e.ctrlKey || e.metaKey) && e.key === "s" && (e.preventDefault(), v());
1685
- };
1686
- return window.addEventListener("keydown", e), () => {
1687
- window.removeEventListener("keydown", e);
1688
- };
1689
- }, [v]), /* @__PURE__ */ R(we, {
1690
- position: "top-right",
1691
- className: "tg:flex tg:gap-2",
1692
- children: [
1693
- /* @__PURE__ */ L(Yn, {
1694
- aiConfig: a,
1695
- onGenerate: (e) => {
1696
- o(e.nodes), s(e.edges);
1697
- }
1698
- }),
1699
- /* @__PURE__ */ R(A, {
1700
- variant: "outline",
1701
- size: "sm",
1702
- onClick: h,
1703
- children: [
1704
- /* @__PURE__ */ L(z, {}),
1705
- " ",
1706
- /* @__PURE__ */ L("span", {
1707
- className: "tg:hidden tg:md:inline",
1708
- children: m("editor.actionsPanel.addNode")
1709
- })
1710
- ]
1711
- }),
1712
- /* @__PURE__ */ R(A, {
1713
- variant: "outline",
1714
- size: "sm",
1715
- onClick: v,
1716
- children: [
1717
- /* @__PURE__ */ L(xt, {}),
1718
- " ",
1719
- /* @__PURE__ */ L("span", {
1720
- className: "tg:hidden tg:md:inline",
1721
- children: m("common.save")
1722
- })
1723
- ]
1724
- }),
1725
- /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
1726
- asChild: !0,
1727
- children: /* @__PURE__ */ L(A, {
1728
- variant: "outline",
1729
- size: "sm",
1730
- children: /* @__PURE__ */ L(it, {})
1731
- })
1732
- }), /* @__PURE__ */ R(nn, {
1733
- align: "start",
1734
- children: [
1735
- /* @__PURE__ */ L(rn, {
1736
- className: "tg:font-normal",
1737
- children: /* @__PURE__ */ R("div", {
1738
- className: "tg:flex tg:flex-col tg:gap-1",
1739
- children: [/* @__PURE__ */ L("span", {
1740
- className: "tg:text-muted-foreground tg:text-xs",
1741
- children: "Flow ID"
1742
- }), /* @__PURE__ */ R("button", {
1743
- onClick: async () => {
1744
- try {
1745
- await navigator.clipboard.writeText(u), H.success(m("editor.actionsPanel.idCopied"), { description: u });
1746
- } catch {
1747
- H.error(m("editor.actionsPanel.copyFailed"));
1748
- }
1749
- },
1750
- className: "tg:flex tg:items-center tg:gap-2 tg:font-mono tg:text-muted-foreground tg:transition-colors tg:hover:text-primary",
1751
- type: "button",
1752
- children: [/* @__PURE__ */ L(nt, { className: "tg:h-3 tg:w-3" }), /* @__PURE__ */ L("span", {
1753
- className: "tg:truncate tg:text-xs",
1754
- children: u
1755
- })]
1756
- })]
1757
- })
1758
- }),
1759
- /* @__PURE__ */ L(Y, {}),
1760
- /* @__PURE__ */ R(q, { children: [/* @__PURE__ */ R(J, {
1761
- onClick: () => p?.current?.click(),
1762
- children: [
1763
- /* @__PURE__ */ L(rt, {}),
1764
- " ",
1765
- m("editor.actionsPanel.importJson")
1766
- ]
1767
- }), /* @__PURE__ */ R(J, {
1768
- onClick: _,
1769
- children: [
1770
- /* @__PURE__ */ L(Ue, {}),
1771
- " ",
1772
- m("editor.actionsPanel.exportJson")
1773
- ]
1774
- })] }),
1775
- n && n.length > 0 && /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(Y, {}), /* @__PURE__ */ L(q, { children: n.map((e, t) => /* @__PURE__ */ R(J, {
1776
- onClick: e.onClick,
1777
- className: e.destructive ? "tg:text-destructive tg:focus:text-destructive" : void 0,
1778
- children: [e.icon, e.label]
1779
- }, t)) })] }),
1780
- /* @__PURE__ */ L(Y, {}),
1781
- /* @__PURE__ */ L(q, { children: /* @__PURE__ */ R(J, {
1782
- onClick: () => {
1783
- o([]), s([]), H.success(m("editor.actionsPanel.clearSuccess"), { description: m("editor.actionsPanel.clearSuccessDesc") });
1784
- },
1785
- className: "tg:text-destructive tg:focus:text-destructive",
1786
- children: [
1787
- /* @__PURE__ */ L(Et, { className: "tg:text-destructive" }),
1788
- " ",
1789
- m("editor.actionsPanel.clear")
1790
- ]
1791
- }) })
1792
- ]
1793
- })] }),
1794
- /* @__PURE__ */ L("input", {
1795
- type: "file",
1796
- accept: "application/json,.json",
1797
- className: "tg:hidden",
1798
- ref: p,
1799
- onChange: g
1800
- })
1801
- ]
1802
- });
1803
- }, Qn = {
1804
- ar: "ar",
1805
- de: "de",
1806
- en: "en",
1807
- es: "es",
1808
- fr: "fr",
1809
- it: "it",
1810
- pt: "pt"
1811
- }, Q = ({ value: e = "en", onValueChange: t }) => /* @__PURE__ */ R(g, {
1812
- value: e,
1813
- onValueChange: t,
1814
- children: [/* @__PURE__ */ L(v, {
1815
- className: "tg:uppercase",
1816
- children: /* @__PURE__ */ L(T, { placeholder: "" })
1817
- }), /* @__PURE__ */ L(C, { children: /* @__PURE__ */ L(w, { children: Object.values(Qn).map((e) => /* @__PURE__ */ L(h, {
1818
- value: e,
1819
- className: "tg:uppercase",
1820
- children: e
1821
- }, e)) }) })]
1822
- }), $ = () => {
1823
- let e = je(), t = ze(() => e.filter(n), [e]), r = ze(() => e.filter((e) => e.selected), [e]), i = ze(() => e.find((e) => e.selected), [e]);
1824
- return {
1825
- groupNodes: t,
1826
- hasSelectedNodes: r.length > 0,
1827
- nodes: e,
1828
- selectedNode: i,
1829
- selectedNodes: r
1830
- };
1831
- }, $n = () => {
1832
- let [e, t] = F("en"), { updateSelectedNodeData: n } = G(), { selectedNode: r } = $(), i = W(), { Field: a } = Ve({
1833
- defaultValues: {
1834
- label: r?.data?.label || { en: "" },
1835
- targetId: r?.data?.targetId || ""
1836
- },
1837
- listeners: {
1838
- onChange: ({ formApi: e }) => {
1839
- e.handleSubmit().then();
1840
- },
1841
- onChangeDebounceMs: 150
1842
- },
1843
- onSubmit: ({ value: e }) => {
1844
- n(e);
1845
- }
1846
- });
1847
- return /* @__PURE__ */ L("form", {
1848
- onSubmit: (e) => {
1849
- e.preventDefault(), e.stopPropagation();
1850
- },
1851
- children: /* @__PURE__ */ R("div", {
1852
- className: "tg:grid tg:gap-6",
1853
- children: [/* @__PURE__ */ R("div", {
1854
- className: "tg:flex tg:items-end tg:gap-2",
1855
- children: [/* @__PURE__ */ L(a, {
1856
- name: "label",
1857
- children: (t) => /* @__PURE__ */ R(j, {
1858
- className: "tg:flex-1",
1859
- children: [/* @__PURE__ */ L(d, {
1860
- htmlFor: t.name,
1861
- children: i("editor.flowNodeForm.label")
1862
- }), /* @__PURE__ */ L(k, {
1863
- id: t.name,
1864
- name: t.name,
1865
- value: t.state.value?.[e] || "",
1866
- onBlur: t.handleBlur,
1867
- onChange: ({ target: n }) => {
1868
- t.handleChange({
1869
- ...t.state.value,
1870
- [e]: n.value
1871
- });
1872
- }
1873
- })]
1874
- })
1875
- }), /* @__PURE__ */ L(Q, {
1876
- value: e,
1877
- onValueChange: t
1878
- })]
1879
- }), /* @__PURE__ */ L(a, {
1880
- name: "targetId",
1881
- children: (e) => /* @__PURE__ */ R(j, { children: [
1882
- /* @__PURE__ */ R(d, {
1883
- htmlFor: e.name,
1884
- children: [i("editor.flowNodeForm.targetId"), " (Flow ID)"]
1885
- }),
1886
- /* @__PURE__ */ L(k, {
1887
- id: e.name,
1888
- name: e.name,
1889
- value: e.state.value,
1890
- onBlur: e.handleBlur,
1891
- onChange: ({ target: t }) => e.handleChange(t.value)
1892
- }),
1893
- /* @__PURE__ */ L(M, { children: "Unique identifier of the target flow." })
1894
- ] })
1895
- })]
1896
- })
1897
- });
1898
- }, er = () => {
1899
- let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = G(), { Field: i } = Ve({
1900
- defaultValues: { label: n?.data?.label || { en: "" } },
1901
- listeners: {
1902
- onChange: ({ formApi: e }) => {
1903
- e.handleSubmit().then();
1904
- },
1905
- onChangeDebounceMs: 150
1906
- },
1907
- onSubmit: ({ value: e }) => {
1908
- r(e);
1909
- }
1910
- });
1911
- return /* @__PURE__ */ L("form", {
1912
- onSubmit: (e) => {
1913
- e.preventDefault(), e.stopPropagation();
1914
- },
1915
- children: /* @__PURE__ */ R("div", {
1916
- className: "tg:flex tg:items-end tg:gap-2",
1917
- children: [/* @__PURE__ */ L(i, {
1918
- name: "label",
1919
- children: (t) => /* @__PURE__ */ R(j, {
1920
- className: "tg:flex-1",
1921
- children: [/* @__PURE__ */ L(d, {
1922
- htmlFor: t.name,
1923
- children: "Label"
1924
- }), /* @__PURE__ */ L(k, {
1925
- id: t.name,
1926
- name: t.name,
1927
- value: t.state.value?.[e] || "",
1928
- onBlur: t.handleBlur,
1929
- onChange: ({ target: n }) => {
1930
- t.handleChange({
1931
- ...t.state.value,
1932
- [e]: n.value
1933
- });
1934
- }
1935
- })]
1936
- })
1937
- }), /* @__PURE__ */ L(Q, {
1938
- value: e,
1939
- onValueChange: t
1940
- })]
1941
- })
1942
- });
1943
- }, tr = [
1944
- "POST",
1945
- "PUT",
1946
- "PATCH"
1947
- ], nr = ({ value: e, onChange: t }) => {
1948
- let { selectedNode: n } = $(), r = W(), i = Ut(n?.id), { handleSubmit: a, Field: o, Subscribe: s } = Ve({
1949
- defaultValues: {
1950
- body: e?.body || "",
1951
- fetchOnMount: e?.fetchOnMount ?? !e?.searchParam,
1952
- headers: e?.headers || [],
1953
- method: e?.method || "GET",
1954
- responseMapping: e?.responseMapping || {
1955
- labelField: "",
1956
- valueField: ""
1957
- },
1958
- responsePath: e?.responsePath || "",
1959
- searchParam: e?.searchParam || "",
1960
- sendAllFormValues: !!e?.sendAllFormValues,
1961
- showLoading: e?.showLoading !== !1,
1962
- url: e?.url || ""
1963
- },
1964
- listeners: {
1965
- onChange: ({ formApi: e }) => {
1966
- e.handleSubmit().then();
1967
- },
1968
- onChangeDebounceMs: 150
1969
- },
1970
- onSubmit: ({ value: e }) => {
1971
- t(e);
1972
- }
1973
- });
1974
- return /* @__PURE__ */ L("div", { children: /* @__PURE__ */ R("div", {
1975
- className: "tg:grid tg:gap-6",
1976
- children: [
1977
- /* @__PURE__ */ L(o, {
1978
- name: "url",
1979
- children: (e) => /* @__PURE__ */ R(j, { children: [
1980
- /* @__PURE__ */ L(d, {
1981
- htmlFor: e.name,
1982
- children: r("editor.httpConfigForm.apiUrl")
1983
- }),
1984
- /* @__PURE__ */ R("div", {
1985
- className: "tg:flex tg:gap-2",
1986
- children: [/* @__PURE__ */ L(k, {
1987
- id: e.name,
1988
- name: e.name,
1989
- value: e.state.value,
1990
- onBlur: e.handleBlur,
1991
- onChange: ({ target: t }) => e.handleChange(t.value),
1992
- placeholder: r("editor.httpConfigForm.apiUrlPlaceholder"),
1993
- className: "tg:flex-1"
1994
- }), /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
1995
- asChild: !0,
1996
- children: /* @__PURE__ */ L(A, {
1997
- type: "button",
1998
- variant: "outline",
1999
- size: "icon",
2000
- children: /* @__PURE__ */ L(Ot, { className: "tg:h-4 tg:w-4" })
2001
- })
2002
- }), /* @__PURE__ */ L(nn, {
2003
- align: "end",
2004
- children: i.length === 0 ? /* @__PURE__ */ L(J, {
2005
- disabled: !0,
2006
- children: r("editor.httpConfigForm.noFieldsAvailable")
2007
- }) : i.map((t) => /* @__PURE__ */ L(J, {
2008
- onClick: () => {
2009
- let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2010
- e.handleChange(r + n);
2011
- },
2012
- children: /* @__PURE__ */ R("div", {
2013
- className: "tg:flex tg:flex-col",
2014
- children: [/* @__PURE__ */ L("span", {
2015
- className: "tg:font-medium",
2016
- children: t.label
2017
- }), /* @__PURE__ */ L("span", {
2018
- className: "tg:text-muted-foreground tg:text-xs",
2019
- children: `{{${t.nodeId}}}`
2020
- })]
2021
- })
2022
- }, t.nodeId))
2023
- })] })]
2024
- }),
2025
- /* @__PURE__ */ L(M, { children: r("editor.httpConfigForm.apiUrlDesc") })
2026
- ] })
2027
- }),
2028
- /* @__PURE__ */ L(o, {
2029
- name: "method",
2030
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
2031
- htmlFor: e.name,
2032
- children: r("editor.httpConfigForm.httpMethod")
2033
- }), /* @__PURE__ */ R(g, {
2034
- value: e.state.value,
2035
- onValueChange: (t) => e.handleChange(t),
2036
- children: [/* @__PURE__ */ L(v, {
2037
- id: e.name,
2038
- children: /* @__PURE__ */ L(T, { placeholder: r("editor.httpConfigForm.selectMethod") })
2039
- }), /* @__PURE__ */ R(C, { children: [
2040
- /* @__PURE__ */ L(h, {
2041
- value: "GET",
2042
- children: r("editor.httpConfigForm.methodGet")
2043
- }),
2044
- /* @__PURE__ */ L(h, {
2045
- value: "POST",
2046
- children: r("editor.httpConfigForm.methodPost")
2047
- }),
2048
- /* @__PURE__ */ L(h, {
2049
- value: "PUT",
2050
- children: r("editor.httpConfigForm.methodPut")
2051
- }),
2052
- /* @__PURE__ */ L(h, {
2053
- value: "DELETE",
2054
- children: r("editor.httpConfigForm.methodDelete")
2055
- }),
2056
- /* @__PURE__ */ L(h, {
2057
- value: "PATCH",
2058
- children: r("editor.httpConfigForm.methodPatch")
2059
- })
2060
- ] })]
2061
- })] })
2062
- }),
2063
- /* @__PURE__ */ R("div", {
2064
- className: "tg:space-y-4",
2065
- children: [/* @__PURE__ */ L("h4", {
2066
- className: "tg:font-semibold tg:text-sm",
2067
- children: r("editor.httpConfigForm.headers")
2068
- }), /* @__PURE__ */ L(o, {
2069
- name: "headers",
2070
- mode: "array",
2071
- children: (e) => /* @__PURE__ */ R("div", {
2072
- className: "tg:space-y-2",
2073
- children: [e.state.value?.map((t, n) => {
2074
- let i = `headers[${n}]`;
2075
- return /* @__PURE__ */ R("div", {
2076
- className: "tg:flex tg:items-start tg:gap-2",
2077
- children: [
2078
- /* @__PURE__ */ L(o, {
2079
- name: `headers[${n}].key`,
2080
- children: (e) => /* @__PURE__ */ L(k, {
2081
- placeholder: r("editor.httpConfigForm.headerName"),
2082
- value: e.state.value || "",
2083
- onChange: ({ target: t }) => e.handleChange(t.value)
2084
- })
2085
- }),
2086
- /* @__PURE__ */ L(o, {
2087
- name: `headers[${n}].value`,
2088
- children: (e) => /* @__PURE__ */ L(k, {
2089
- placeholder: r("editor.httpConfigForm.headerValue"),
2090
- value: e.state.value || "",
2091
- onChange: ({ target: t }) => e.handleChange(t.value)
2092
- })
2093
- }),
2094
- /* @__PURE__ */ L(A, {
2095
- type: "button",
2096
- variant: "ghost",
2097
- size: "icon",
2098
- onClick: () => {
2099
- e.removeValue(n);
2100
- },
2101
- children: /* @__PURE__ */ L(B, { className: "tg:h-4 tg:w-4" })
2102
- })
2103
- ]
2104
- }, i);
2105
- }), /* @__PURE__ */ R(A, {
2106
- type: "button",
2107
- variant: "outline",
2108
- size: "sm",
2109
- onClick: () => {
2110
- e.pushValue({
2111
- key: "",
2112
- value: ""
2113
- });
2114
- },
2115
- children: [/* @__PURE__ */ L(z, { className: "tg:mr-2 tg:h-4 tg:w-4" }), r("editor.httpConfigForm.addHeader")]
2116
- })]
2117
- })
2118
- })]
2119
- }),
2120
- /* @__PURE__ */ L(s, {
2121
- selector: (e) => ({
2122
- method: e.values.method,
2123
- sendAllFormValues: e.values.sendAllFormValues
2124
- }),
2125
- children: ({ method: e, sendAllFormValues: t }) => tr.includes(e || "") && /* @__PURE__ */ R("div", {
2126
- className: "tg:space-y-4",
2127
- children: [/* @__PURE__ */ L(o, {
2128
- name: "sendAllFormValues",
2129
- children: (e) => /* @__PURE__ */ R("div", {
2130
- className: "tg:flex tg:items-center tg:space-x-2",
2131
- children: [/* @__PURE__ */ L(O, {
2132
- id: e.name,
2133
- checked: e.state.value,
2134
- onCheckedChange: (t) => e.handleChange(t)
2135
- }), /* @__PURE__ */ L(d, {
2136
- htmlFor: e.name,
2137
- children: r("editor.httpConfigForm.sendAllFormValues")
2138
- })]
2139
- })
2140
- }), /* @__PURE__ */ L(o, {
2141
- name: "body",
2142
- children: (e) => /* @__PURE__ */ R(j, { children: [
2143
- /* @__PURE__ */ R("div", {
2144
- className: "tg:mb-2 tg:flex tg:items-center tg:justify-between",
2145
- children: [/* @__PURE__ */ L(d, {
2146
- htmlFor: e.name,
2147
- children: r("editor.httpConfigForm.requestBody")
2148
- }), /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
2149
- asChild: !0,
2150
- children: /* @__PURE__ */ R(A, {
2151
- type: "button",
2152
- variant: "ghost",
2153
- size: "sm",
2154
- disabled: t,
2155
- children: [/* @__PURE__ */ L(Ot, { className: "tg:mr-2 tg:h-4 tg:w-4" }), r("editor.httpConfigForm.insertVariable")]
2156
- })
2157
- }), /* @__PURE__ */ L(nn, {
2158
- align: "end",
2159
- children: i.length === 0 ? /* @__PURE__ */ L(J, {
2160
- disabled: !0,
2161
- children: r("editor.httpConfigForm.noFieldsAvailable")
2162
- }) : i.map((t) => /* @__PURE__ */ L(J, {
2163
- onClick: () => {
2164
- let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2165
- e.handleChange(r + n), a().then();
2166
- },
2167
- children: /* @__PURE__ */ R("div", {
2168
- className: "tg:flex tg:flex-col",
2169
- children: [/* @__PURE__ */ L("span", {
2170
- className: "tg:font-medium",
2171
- children: t.label
2172
- }), /* @__PURE__ */ L("span", {
2173
- className: "tg:text-muted-foreground tg:text-xs",
2174
- children: `{{${t.nodeId}}}`
2175
- })]
2176
- })
2177
- }, t.nodeId))
2178
- })] })]
2179
- }),
2180
- /* @__PURE__ */ L(ce, {
2181
- id: e.name,
2182
- name: e.name,
2183
- value: e.state.value,
2184
- onBlur: e.handleBlur,
2185
- onChange: ({ target: t }) => e.handleChange(t.value),
2186
- placeholder: r("editor.httpConfigForm.requestBodyPlaceholder"),
2187
- rows: 4,
2188
- disabled: t
2189
- }),
2190
- /* @__PURE__ */ L(M, { children: r(t ? "editor.httpConfigForm.sendAllFormValuesDesc" : "editor.httpConfigForm.requestBodyDesc") })
2191
- ] })
2192
- })]
2193
- })
2194
- }),
2195
- /* @__PURE__ */ R("div", {
2196
- className: "tg:space-y-4",
2197
- children: [
2198
- /* @__PURE__ */ L("h4", {
2199
- className: "tg:font-semibold tg:text-sm",
2200
- children: r("editor.httpConfigForm.responseConfiguration")
2201
- }),
2202
- /* @__PURE__ */ L(o, {
2203
- name: "responsePath",
2204
- children: (e) => /* @__PURE__ */ R(j, { children: [
2205
- /* @__PURE__ */ L(d, {
2206
- htmlFor: e.name,
2207
- children: r("editor.httpConfigForm.responsePath")
2208
- }),
2209
- /* @__PURE__ */ L(k, {
2210
- id: e.name,
2211
- name: e.name,
2212
- value: e.state.value,
2213
- onBlur: e.handleBlur,
2214
- onChange: ({ target: t }) => e.handleChange(t.value),
2215
- placeholder: r("editor.httpConfigForm.responsePathPlaceholder")
2216
- }),
2217
- /* @__PURE__ */ L(M, { children: r("editor.httpConfigForm.responsePathDesc") })
2218
- ] })
2219
- }),
2220
- /* @__PURE__ */ R("div", {
2221
- className: "tg:space-y-4",
2222
- children: [
2223
- /* @__PURE__ */ L("h5", {
2224
- className: "tg:font-medium tg:text-sm",
2225
- children: r("editor.httpConfigForm.mapToOptions")
2226
- }),
2227
- /* @__PURE__ */ L(o, {
2228
- name: "responseMapping.valueField",
2229
- children: (e) => /* @__PURE__ */ R(j, { children: [
2230
- /* @__PURE__ */ L(d, {
2231
- htmlFor: e.name,
2232
- children: r("editor.httpConfigForm.valueField")
2233
- }),
2234
- /* @__PURE__ */ L(k, {
2235
- id: e.name,
2236
- name: e.name,
2237
- value: e.state.value,
2238
- onBlur: e.handleBlur,
2239
- onChange: ({ target: t }) => e.handleChange(t.value),
2240
- placeholder: r("editor.httpConfigForm.valueFieldPlaceholder")
2241
- }),
2242
- /* @__PURE__ */ L(M, { children: r("editor.httpConfigForm.valueFieldDesc") })
2243
- ] })
2244
- }),
2245
- /* @__PURE__ */ L(o, {
2246
- name: "responseMapping.labelField",
2247
- children: (e) => /* @__PURE__ */ R(j, { children: [
2248
- /* @__PURE__ */ L(d, {
2249
- htmlFor: e.name,
2250
- children: r("editor.httpConfigForm.labelField")
2251
- }),
2252
- /* @__PURE__ */ L(k, {
2253
- id: e.name,
2254
- name: e.name,
2255
- value: e.state.value,
2256
- onBlur: e.handleBlur,
2257
- onChange: ({ target: t }) => e.handleChange(t.value),
2258
- placeholder: r("editor.httpConfigForm.labelFieldPlaceholder")
2259
- }),
2260
- /* @__PURE__ */ L(M, { children: r("editor.httpConfigForm.labelFieldDesc") })
2261
- ] })
2262
- })
2263
- ]
2264
- }),
2265
- /* @__PURE__ */ L(o, {
2266
- name: "searchParam",
2267
- children: (e) => /* @__PURE__ */ R(j, { children: [
2268
- /* @__PURE__ */ L(d, {
2269
- htmlFor: e.name,
2270
- children: r("editor.httpConfigForm.searchParameter")
2271
- }),
2272
- /* @__PURE__ */ L(k, {
2273
- id: e.name,
2274
- name: e.name,
2275
- value: e.state.value,
2276
- onBlur: e.handleBlur,
2277
- onChange: ({ target: t }) => e.handleChange(t.value),
2278
- placeholder: r("editor.httpConfigForm.searchParameterPlaceholder")
2279
- }),
2280
- /* @__PURE__ */ L(M, { children: r("editor.httpConfigForm.searchParameterDesc") })
2281
- ] })
2282
- })
2283
- ]
2284
- }),
2285
- /* @__PURE__ */ R("div", {
2286
- className: "tg:space-y-4",
2287
- children: [
2288
- /* @__PURE__ */ L("h4", {
2289
- className: "tg:font-semibold tg:text-sm",
2290
- children: r("editor.httpConfigForm.behavior")
2291
- }),
2292
- /* @__PURE__ */ L(s, {
2293
- selector: (e) => e.values.searchParam,
2294
- children: (e) => /* @__PURE__ */ L(o, {
2295
- name: "fetchOnMount",
2296
- children: (t) => {
2297
- let n = !!e?.trim(), i = n ? t.state.value : !0;
2298
- return !n && t.state.value !== !0 && t.handleChange(!0), /* @__PURE__ */ R("div", {
2299
- className: "tg:flex tg:items-center tg:space-x-2",
2300
- children: [/* @__PURE__ */ L(O, {
2301
- id: t.name,
2302
- checked: i,
2303
- disabled: !n,
2304
- onCheckedChange: (e) => t.handleChange(e)
2305
- }), /* @__PURE__ */ L(d, {
2306
- htmlFor: t.name,
2307
- className: n ? "" : "tg:text-muted-foreground",
2308
- children: r("editor.httpConfigForm.fetchOnMount")
2309
- })]
2310
- });
2311
- }
2312
- })
2313
- }),
2314
- /* @__PURE__ */ L(o, {
2315
- name: "showLoading",
2316
- children: (e) => /* @__PURE__ */ R("div", {
2317
- className: "tg:flex tg:items-center tg:space-x-2",
2318
- children: [/* @__PURE__ */ L(O, {
2319
- id: e.name,
2320
- checked: e.state.value,
2321
- onCheckedChange: (t) => e.handleChange(t)
2322
- }), /* @__PURE__ */ L(d, {
2323
- htmlFor: e.name,
2324
- children: r("editor.httpConfigForm.showLoadingState")
2325
- })]
2326
- })
2327
- })
2328
- ]
2329
- })
2330
- ]
2331
- }) });
2332
- }, rr = [
2333
- "POST",
2334
- "PUT",
2335
- "PATCH"
2336
- ], ir = ({ value: e, onChange: t }) => {
2337
- let [n, r] = F("en"), { selectedNode: i } = $(), a = W(), o = Ut(i?.id), { handleSubmit: s, Field: c, Subscribe: l } = Ve({
2338
- defaultValues: {
2339
- body: e?.body || "",
2340
- errorMessage: e?.errorMessage || { en: "" },
2341
- headers: e?.headers || [],
2342
- method: e?.method || "POST",
2343
- redirectUrl: e?.redirectUrl || "",
2344
- sendAllFormValues: !!e?.sendAllFormValues,
2345
- showLoading: e?.showLoading !== !1,
2346
- successMessage: e?.successMessage || { en: "" },
2347
- url: e?.url || ""
2348
- },
2349
- listeners: {
2350
- onChange: ({ formApi: e }) => {
2351
- e.handleSubmit().then();
2352
- },
2353
- onChangeDebounceMs: 150
2354
- },
2355
- onSubmit: ({ value: e }) => {
2356
- t(e);
2357
- }
2358
- });
2359
- return /* @__PURE__ */ L("div", { children: /* @__PURE__ */ R("div", {
2360
- className: "tg:grid tg:gap-6",
2361
- children: [
2362
- /* @__PURE__ */ L(c, {
2363
- name: "url",
2364
- children: (e) => /* @__PURE__ */ R(j, { children: [
2365
- /* @__PURE__ */ L(d, {
2366
- htmlFor: e.name,
2367
- children: a("editor.submitConfigForm.apiUrl")
2368
- }),
2369
- /* @__PURE__ */ R("div", {
2370
- className: "tg:flex tg:gap-2",
2371
- children: [/* @__PURE__ */ L(k, {
2372
- id: e.name,
2373
- name: e.name,
2374
- value: e.state.value,
2375
- onBlur: e.handleBlur,
2376
- onChange: ({ target: t }) => e.handleChange(t.value),
2377
- placeholder: a("editor.submitConfigForm.apiUrlPlaceholder"),
2378
- className: "tg:flex-1"
2379
- }), /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
2380
- asChild: !0,
2381
- children: /* @__PURE__ */ L(A, {
2382
- type: "button",
2383
- variant: "outline",
2384
- size: "icon",
2385
- children: /* @__PURE__ */ L(Ot, { className: "tg:h-4 tg:w-4" })
2386
- })
2387
- }), /* @__PURE__ */ L(nn, {
2388
- align: "end",
2389
- children: o.length === 0 ? /* @__PURE__ */ L(J, {
2390
- disabled: !0,
2391
- children: a("editor.submitConfigForm.noFieldsAvailable")
2392
- }) : o.map((t) => /* @__PURE__ */ L(J, {
2393
- onClick: () => {
2394
- let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2395
- e.handleChange(r + n);
2396
- },
2397
- children: /* @__PURE__ */ R("div", {
2398
- className: "tg:flex tg:flex-col",
2399
- children: [/* @__PURE__ */ L("span", {
2400
- className: "tg:font-medium",
2401
- children: t.label
2402
- }), /* @__PURE__ */ L("span", {
2403
- className: "tg:text-muted-foreground tg:text-xs",
2404
- children: `{{${t.nodeId}}}`
2405
- })]
2406
- })
2407
- }, t.nodeId))
2408
- })] })]
2409
- }),
2410
- /* @__PURE__ */ L(M, { children: a("editor.submitConfigForm.apiUrlDesc") })
2411
- ] })
2412
- }),
2413
- /* @__PURE__ */ L(c, {
2414
- name: "method",
2415
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
2416
- htmlFor: e.name,
2417
- children: a("editor.submitConfigForm.httpMethod")
2418
- }), /* @__PURE__ */ R(g, {
2419
- value: e.state.value,
2420
- onValueChange: (t) => e.handleChange(t),
2421
- children: [/* @__PURE__ */ L(v, {
2422
- id: e.name,
2423
- children: /* @__PURE__ */ L(T, { placeholder: a("editor.submitConfigForm.selectMethod") })
2424
- }), /* @__PURE__ */ R(C, { children: [
2425
- /* @__PURE__ */ L(h, {
2426
- value: "POST",
2427
- children: a("editor.submitConfigForm.methodPost")
2428
- }),
2429
- /* @__PURE__ */ L(h, {
2430
- value: "PUT",
2431
- children: a("editor.submitConfigForm.methodPut")
2432
- }),
2433
- /* @__PURE__ */ L(h, {
2434
- value: "DELETE",
2435
- children: a("editor.submitConfigForm.methodDelete")
2436
- }),
2437
- /* @__PURE__ */ L(h, {
2438
- value: "PATCH",
2439
- children: a("editor.submitConfigForm.methodPatch")
2440
- })
2441
- ] })]
2442
- })] })
2443
- }),
2444
- /* @__PURE__ */ R("div", {
2445
- className: "tg:space-y-4",
2446
- children: [/* @__PURE__ */ L("h4", {
2447
- className: "tg:font-semibold tg:text-sm",
2448
- children: a("editor.submitConfigForm.headers")
2449
- }), /* @__PURE__ */ L(c, {
2450
- name: "headers",
2451
- mode: "array",
2452
- children: (e) => /* @__PURE__ */ R("div", {
2453
- className: "tg:space-y-2",
2454
- children: [e.state.value?.map((t, n) => {
2455
- let r = `headers[${n}]`;
2456
- return /* @__PURE__ */ R("div", {
2457
- className: "tg:flex tg:items-start tg:gap-2",
2458
- children: [
2459
- /* @__PURE__ */ L(c, {
2460
- name: `headers[${n}].key`,
2461
- children: (e) => /* @__PURE__ */ L(k, {
2462
- placeholder: a("editor.submitConfigForm.headerName"),
2463
- value: e.state.value || "",
2464
- onChange: ({ target: t }) => e.handleChange(t.value)
2465
- })
2466
- }),
2467
- /* @__PURE__ */ L(c, {
2468
- name: `headers[${n}].value`,
2469
- children: (e) => /* @__PURE__ */ L(k, {
2470
- placeholder: a("editor.submitConfigForm.headerValue"),
2471
- value: e.state.value || "",
2472
- onChange: ({ target: t }) => e.handleChange(t.value)
2473
- })
2474
- }),
2475
- /* @__PURE__ */ L(A, {
2476
- type: "button",
2477
- variant: "ghost",
2478
- size: "icon",
2479
- onClick: () => {
2480
- e.removeValue(n);
2481
- },
2482
- children: /* @__PURE__ */ L(B, { className: "tg:h-4 tg:w-4" })
2483
- })
2484
- ]
2485
- }, r);
2486
- }), /* @__PURE__ */ R(A, {
2487
- type: "button",
2488
- variant: "outline",
2489
- size: "sm",
2490
- onClick: () => {
2491
- e.pushValue({
2492
- key: "",
2493
- value: ""
2494
- });
2495
- },
2496
- children: [/* @__PURE__ */ L(z, { className: "tg:mr-2 tg:h-4 tg:w-4" }), a("editor.submitConfigForm.addHeader")]
2497
- })]
2498
- })
2499
- })]
2500
- }),
2501
- /* @__PURE__ */ L(l, {
2502
- selector: (e) => ({
2503
- method: e.values.method,
2504
- sendAllFormValues: e.values.sendAllFormValues
2505
- }),
2506
- children: ({ method: e, sendAllFormValues: t }) => rr.includes(e || "") && /* @__PURE__ */ R("div", {
2507
- className: "tg:space-y-4",
2508
- children: [/* @__PURE__ */ L(c, {
2509
- name: "sendAllFormValues",
2510
- children: (e) => /* @__PURE__ */ R("div", {
2511
- className: "tg:flex tg:items-center tg:space-x-2",
2512
- children: [/* @__PURE__ */ L(O, {
2513
- id: e.name,
2514
- checked: e.state.value,
2515
- onCheckedChange: (t) => e.handleChange(t)
2516
- }), /* @__PURE__ */ L(d, {
2517
- htmlFor: e.name,
2518
- children: a("editor.submitConfigForm.sendAllFormValues")
2519
- })]
2520
- })
2521
- }), /* @__PURE__ */ L(c, {
2522
- name: "body",
2523
- children: (e) => /* @__PURE__ */ R(j, { children: [
2524
- /* @__PURE__ */ R("div", {
2525
- className: "tg:mb-2 tg:flex tg:items-center tg:justify-between",
2526
- children: [/* @__PURE__ */ L(d, {
2527
- htmlFor: e.name,
2528
- children: a("editor.submitConfigForm.requestBody")
2529
- }), /* @__PURE__ */ R(K, { children: [/* @__PURE__ */ L(tn, {
2530
- asChild: !0,
2531
- children: /* @__PURE__ */ R(A, {
2532
- type: "button",
2533
- variant: "ghost",
2534
- size: "sm",
2535
- disabled: t,
2536
- children: [/* @__PURE__ */ L(Ot, { className: "tg:mr-2 tg:h-4 tg:w-4" }), a("editor.submitConfigForm.insertVariable")]
2537
- })
2538
- }), /* @__PURE__ */ L(nn, {
2539
- align: "end",
2540
- children: o.length === 0 ? /* @__PURE__ */ L(J, {
2541
- disabled: !0,
2542
- children: a("editor.submitConfigForm.noFieldsAvailable")
2543
- }) : o.map((t) => /* @__PURE__ */ L(J, {
2544
- onClick: () => {
2545
- let n = `{{${t.nodeId}}}`, r = e.state.value || "";
2546
- e.handleChange(r + n), s().then();
2547
- },
2548
- children: /* @__PURE__ */ R("div", {
2549
- className: "tg:flex tg:flex-col",
2550
- children: [/* @__PURE__ */ L("span", {
2551
- className: "tg:font-medium",
2552
- children: t.label
2553
- }), /* @__PURE__ */ L("span", {
2554
- className: "tg:text-muted-foreground tg:text-xs",
2555
- children: `{{${t.nodeId}}}`
2556
- })]
2557
- })
2558
- }, t.nodeId))
2559
- })] })]
2560
- }),
2561
- /* @__PURE__ */ L(ce, {
2562
- id: e.name,
2563
- name: e.name,
2564
- value: e.state.value,
2565
- onBlur: e.handleBlur,
2566
- onChange: ({ target: t }) => e.handleChange(t.value),
2567
- placeholder: a("editor.submitConfigForm.requestBodyPlaceholder"),
2568
- rows: 4,
2569
- disabled: t
2570
- }),
2571
- /* @__PURE__ */ L(M, { children: a(t ? "editor.submitConfigForm.sendAllFormValuesDesc" : "editor.submitConfigForm.requestBodyDesc") })
2572
- ] })
2573
- })]
2574
- })
2575
- }),
2576
- /* @__PURE__ */ R("div", {
2577
- className: "tg:space-y-4",
2578
- children: [
2579
- /* @__PURE__ */ L("h4", {
2580
- className: "tg:font-semibold tg:text-sm",
2581
- children: a("editor.submitConfigForm.postSubmission")
2582
- }),
2583
- /* @__PURE__ */ L(c, {
2584
- name: "redirectUrl",
2585
- children: (e) => /* @__PURE__ */ R(j, { children: [
2586
- /* @__PURE__ */ L(d, {
2587
- htmlFor: e.name,
2588
- children: a("editor.submitConfigForm.redirectUrl")
2589
- }),
2590
- /* @__PURE__ */ L(k, {
2591
- id: e.name,
2592
- name: e.name,
2593
- value: e.state.value,
2594
- onBlur: e.handleBlur,
2595
- onChange: ({ target: t }) => e.handleChange(t.value),
2596
- placeholder: a("editor.submitConfigForm.redirectUrlPlaceholder")
2597
- }),
2598
- /* @__PURE__ */ L(M, { children: a("editor.submitConfigForm.redirectUrlDesc") })
2599
- ] })
2600
- }),
2601
- /* @__PURE__ */ R("div", {
2602
- className: "tg:flex tg:items-center tg:gap-2",
2603
- children: [/* @__PURE__ */ L(c, {
2604
- name: "successMessage",
2605
- children: (e) => /* @__PURE__ */ R(j, {
2606
- className: "tg:flex-1",
2607
- children: [
2608
- /* @__PURE__ */ L(d, {
2609
- htmlFor: e.name,
2610
- children: a("editor.submitConfigForm.successMessage")
2611
- }),
2612
- /* @__PURE__ */ L(k, {
2613
- id: e.name,
2614
- name: e.name,
2615
- value: e.state.value?.[n] || "",
2616
- onBlur: e.handleBlur,
2617
- onChange: ({ target: t }) => {
2618
- e.handleChange({
2619
- ...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
2620
- [n]: t.value
2621
- });
2622
- },
2623
- placeholder: a("editor.submitConfigForm.successMessagePlaceholder")
2624
- }),
2625
- /* @__PURE__ */ L(M, { children: a("editor.submitConfigForm.successMessageDesc") })
2626
- ]
2627
- })
2628
- }), /* @__PURE__ */ L(Q, {
2629
- value: n,
2630
- onValueChange: r
2631
- })]
2632
- }),
2633
- /* @__PURE__ */ R("div", {
2634
- className: "tg:flex tg:items-center tg:gap-2",
2635
- children: [/* @__PURE__ */ L(c, {
2636
- name: "errorMessage",
2637
- children: (e) => /* @__PURE__ */ R(j, {
2638
- className: "tg:flex-1",
2639
- children: [
2640
- /* @__PURE__ */ L(d, {
2641
- htmlFor: e.name,
2642
- children: a("editor.submitConfigForm.errorMessage")
2643
- }),
2644
- /* @__PURE__ */ L(k, {
2645
- id: e.name,
2646
- name: e.name,
2647
- value: e.state.value?.[n] || "",
2648
- onBlur: e.handleBlur,
2649
- onChange: ({ target: t }) => {
2650
- e.handleChange({
2651
- ...typeof e.state.value == "object" && e.state.value !== null ? e.state.value : {},
2652
- [n]: t.value
2653
- });
2654
- },
2655
- placeholder: a("editor.submitConfigForm.errorMessagePlaceholder")
2656
- }),
2657
- /* @__PURE__ */ L(M, { children: a("editor.submitConfigForm.errorMessageDesc") })
2658
- ]
2659
- })
2660
- }), /* @__PURE__ */ L(Q, {
2661
- value: n,
2662
- onValueChange: r
2663
- })]
2664
- })
2665
- ]
2666
- }),
2667
- /* @__PURE__ */ R("div", {
2668
- className: "tg:space-y-4",
2669
- children: [/* @__PURE__ */ L("h4", {
2670
- className: "tg:font-semibold tg:text-sm",
2671
- children: a("editor.submitConfigForm.behavior")
2672
- }), /* @__PURE__ */ L(c, {
2673
- name: "showLoading",
2674
- children: (e) => /* @__PURE__ */ R("div", {
2675
- className: "tg:flex tg:items-center tg:space-x-2",
2676
- children: [/* @__PURE__ */ L(O, {
2677
- id: e.name,
2678
- checked: e.state.value,
2679
- onCheckedChange: (t) => e.handleChange(t)
2680
- }), /* @__PURE__ */ L(d, {
2681
- htmlFor: e.name,
2682
- children: a("editor.submitConfigForm.showLoadingState")
2683
- })]
2684
- })
2685
- })]
2686
- })
2687
- ]
2688
- }) });
2689
- }, ar = ({ 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: d = !0 }) => {
2690
- let [p, m] = F(!1), [h, g] = F(""), _ = (e) => e ?? "", v = (e) => e.trim().toLowerCase(), y = _(n), ee = n !== null && n !== "", S = ee ? e.find((e) => _(e.value) === y) : void 0, C = v(h), re = d && C !== "" && !e.some((e) => v(e.label) === C || v(e.value ?? "") === C), w = (e) => {
2691
- e === y ? u && r?.("") : r?.(e), m(!1), g("");
2692
- };
2693
- return /* @__PURE__ */ R(ie, {
2694
- open: p,
2695
- onOpenChange: m,
2696
- children: [/* @__PURE__ */ L(ne, {
2697
- asChild: !0,
2698
- id: t,
2699
- children: /* @__PURE__ */ R(A, {
2700
- type: "button",
2701
- variant: "outline",
2702
- role: "combobox",
2703
- "aria-expanded": p,
2704
- className: D("tg:w-full tg:justify-between tg:font-normal", l),
2705
- children: [/* @__PURE__ */ L("span", {
2706
- className: "tg:truncate",
2707
- children: ee && S ? S.label : i
2708
- }), /* @__PURE__ */ L(Ze, { className: "tg:ml-2 tg:h-4 tg:w-4 tg:shrink-0 tg:opacity-50" })]
2709
- })
2710
- }), /* @__PURE__ */ L(ae, {
2711
- className: "tg:w-full tg:p-0",
2712
- align: "start",
2713
- children: /* @__PURE__ */ R(se, {
2714
- shouldFilter: !1,
2715
- children: [/* @__PURE__ */ L(te, {
2716
- placeholder: a,
2717
- value: h,
2718
- onValueChange: g
2719
- }), /* @__PURE__ */ R(x, { children: [
2720
- /* @__PURE__ */ L(f, { children: c }),
2721
- u && ee && /* @__PURE__ */ L(oe, { children: /* @__PURE__ */ R(b, {
2722
- value: "__clear__",
2723
- onSelect: () => {
2724
- r?.(""), m(!1), g("");
2725
- },
2726
- className: "tg:mt-1 tg:text-muted-foreground",
2727
- children: [/* @__PURE__ */ L(B, { className: "tg:mr-2 tg:h-4 tg:w-4" }), s]
2728
- }) }),
2729
- /* @__PURE__ */ R(oe, { children: [re && /* @__PURE__ */ R(b, {
2730
- value: `__create__${h}`,
2731
- onSelect: () => {
2732
- h.trim() && (r?.(h.trim()), m(!1), g(""));
2733
- },
2734
- className: "tg:text-primary",
2735
- children: [/* @__PURE__ */ L(z, { className: "tg:mr-2 tg:h-4 tg:w-4" }), o(h)]
2736
- }), e.filter((e) => {
2737
- let t = h.toLowerCase();
2738
- return e.label.toLowerCase().includes(t) || (e.value?.toLowerCase() ?? "").includes(t);
2739
- }).map((e, t) => /* @__PURE__ */ R(b, {
2740
- value: e.label,
2741
- onSelect: () => w(e?.value || ""),
2742
- children: [/* @__PURE__ */ L(Je, {
2743
- "aria-hidden": "true",
2744
- className: D("tg:mr-2 tg:h-4 tg:w-4", ee && _(e.value) === y ? "tg:opacity-100" : "tg:opacity-0")
2745
- }), e.label]
2746
- }, e.value ?? e.label ?? t))] })
2747
- ] })]
2748
- })
2749
- })]
2750
- });
2751
- }, or = Object.entries({
2752
- alphanumeric: "^[a-zA-Z0-9]+$",
2753
- email: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
2754
- letters: "^[a-zA-Z]+$",
2755
- number: "^[0-9]+$",
2756
- url: "^https?:\\/\\/.+$"
2757
- }).map(([e, t]) => ({
2758
- label: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
2759
- value: t
2760
- })), sr = ({ id: e, value: t, onValueChange: n }) => /* @__PURE__ */ L(ar, {
2761
- id: e,
2762
- options: ze(() => t && !or.some((e) => e.value === t) ? [...or, {
2763
- label: `Custom: ${t}`,
2764
- value: t
2765
- }] : or, [t]),
2766
- value: t,
2767
- onValueChange: n,
2768
- placeholder: "Select or create a pattern",
2769
- searchPlaceholder: "Search patterns...",
2770
- createLabel: (e) => `Use pattern: ${e}`
2771
- }), cr = 400, lr = .8, ur = (e) => new Promise((t, n) => {
2772
- let r = new FileReader();
2773
- r.onerror = () => n(/* @__PURE__ */ Error("read_failed")), r.onload = () => {
2774
- let e = new Image();
2775
- e.onload = () => t(e), e.onerror = () => n(/* @__PURE__ */ Error("decode_failed")), e.src = r.result;
2776
- }, r.readAsDataURL(e);
2777
- }), dr = async (e) => {
2778
- if (!e.type.startsWith("image/")) throw Error("invalid_type");
2779
- if (e.size > 5242880) throw Error("too_large");
2780
- let t = await ur(e), n = Math.min(1, cr / Math.max(t.width, t.height)), r = document.createElement("canvas");
2781
- r.width = Math.round(t.width * n), r.height = Math.round(t.height * n);
2782
- let i = r.getContext("2d");
2783
- if (!i) throw Error("canvas_unavailable");
2784
- return i.drawImage(t, 0, 0, r.width, r.height), r.toDataURL("image/jpeg", lr);
2785
- }, fr = 400, pr = (e) => {
2786
- if (!/^https?:\/\//i.test(e)) return !1;
2787
- try {
2788
- return !!new URL(e).hostname;
2789
- } catch {
2790
- return !1;
2791
- }
2792
- }, mr = ({ value: e, onChange: t }) => {
2793
- let n = Be(null), r = Be(null), [i, a] = F(!1), [o, s] = F(e && /^https?:\/\//i.test(e) ? e : ""), c = W();
2794
- Le(() => {
2795
- i || s(e && /^https?:\/\//i.test(e) ? e : "");
2796
- }, [i, e]), Le(() => () => {
2797
- r.current && clearTimeout(r.current);
2798
- }, []);
2799
- let l = async (e) => {
2800
- let r = e.target.files?.[0];
2801
- if (r) try {
2802
- t(await dr(r)), a(!1);
2803
- } catch (e) {
2804
- let t = e.message;
2805
- t === "too_large" ? H.error(c("editor.inputNodeForm.optionImageTooLarge")) : t === "invalid_type" ? H.error(c("editor.inputNodeForm.optionImageInvalid")) : H.error(c("editor.inputNodeForm.optionImageError"));
2806
- } finally {
2807
- n.current && (n.current.value = "");
2808
- }
2809
- }, u = () => {
2810
- let e = o.trim();
2811
- e && (t(e), a(!1));
2812
- };
2813
- return /* @__PURE__ */ R("div", {
2814
- className: "tg:relative",
2815
- children: [
2816
- /* @__PURE__ */ L("input", {
2817
- ref: n,
2818
- type: "file",
2819
- accept: "image/*",
2820
- className: "tg:hidden",
2821
- onChange: l
2822
- }),
2823
- /* @__PURE__ */ R(ie, {
2824
- open: i,
2825
- onOpenChange: a,
2826
- children: [/* @__PURE__ */ L(ne, {
2827
- asChild: !0,
2828
- children: e ? /* @__PURE__ */ L("button", {
2829
- type: "button",
2830
- className: "tg:h-9 tg:w-9 tg:cursor-pointer tg:overflow-hidden tg:rounded-md tg:border tg:border-input",
2831
- "aria-label": c("editor.inputNodeForm.optionImageReplace"),
2832
- children: /* @__PURE__ */ L("img", {
2833
- src: e,
2834
- alt: "",
2835
- className: "tg:h-full tg:w-full tg:object-cover"
2836
- })
2837
- }) : /* @__PURE__ */ L(A, {
2838
- type: "button",
2839
- variant: "outline",
2840
- size: "icon",
2841
- "aria-label": c("editor.inputNodeForm.optionImageAdd"),
2842
- children: /* @__PURE__ */ L(ct, { className: "tg:h-4 tg:w-4" })
2843
- })
2844
- }), /* @__PURE__ */ R(ae, {
2845
- align: "start",
2846
- className: "tg:w-64 tg:space-y-3 tg:p-3",
2847
- children: [
2848
- /* @__PURE__ */ R(A, {
2849
- type: "button",
2850
- variant: "outline",
2851
- size: "sm",
2852
- className: "tg:w-full",
2853
- onClick: () => n.current?.click(),
2854
- children: [/* @__PURE__ */ L(Dt, { className: "tg:mr-2 tg:h-4 tg:w-4" }), c("editor.inputNodeForm.optionImageUpload")]
2855
- }),
2856
- /* @__PURE__ */ L(le, {}),
2857
- /* @__PURE__ */ R("div", {
2858
- className: "tg:flex tg:items-center tg:gap-2",
2859
- children: [/* @__PURE__ */ L(ut, { className: "tg:h-4 tg:w-4 tg:shrink-0 tg:text-muted-foreground" }), /* @__PURE__ */ L(k, {
2860
- placeholder: c("editor.inputNodeForm.optionImageUrlPlaceholder"),
2861
- value: o,
2862
- onChange: (n) => {
2863
- let i = n.target.value;
2864
- s(i), r.current && clearTimeout(r.current);
2865
- let a = i.trim();
2866
- !pr(a) || a === e || (r.current = setTimeout(() => {
2867
- t(a);
2868
- }, fr));
2869
- },
2870
- onKeyDown: (e) => {
2871
- e.key === "Enter" && (e.preventDefault(), u());
2872
- },
2873
- onBlur: u
2874
- })]
2875
- })
2876
- ]
2877
- })]
2878
- }),
2879
- e && /* @__PURE__ */ L("button", {
2880
- type: "button",
2881
- onClick: (e) => {
2882
- e.stopPropagation(), t("");
2883
- },
2884
- className: "tg:-top-1 tg:-right-1 tg:absolute tg:flex tg:h-4 tg:w-4 tg:cursor-pointer tg:items-center tg:justify-center tg:rounded-full tg:bg-destructive tg:text-destructive-foreground",
2885
- "aria-label": c("editor.inputNodeForm.optionImageRemove"),
2886
- children: /* @__PURE__ */ L(B, { className: "tg:h-3 tg:w-3" })
2887
- })
2888
- ]
2889
- });
2890
- };
2891
- //#endregion
2892
- //#region src/shared/components/ui/collapsible.tsx
2893
- function hr({ ...e }) {
2894
- return /* @__PURE__ */ L(Rt.Root, {
2895
- "data-slot": "collapsible",
2896
- ...e
2897
- });
2898
- }
2899
- function gr({ ...e }) {
2900
- return /* @__PURE__ */ L(Rt.CollapsibleTrigger, {
2901
- "data-slot": "collapsible-trigger",
2902
- ...e
2903
- });
2904
- }
2905
- function _r({ ...e }) {
2906
- return /* @__PURE__ */ L(Rt.CollapsibleContent, {
2907
- "data-slot": "collapsible-content",
2908
- ...e
2909
- });
2910
- }
2911
- //#endregion
2912
- //#region src/editor/features/TreegeEditor/forms/InputNodeForm.tsx
2913
- var vr = () => {
2914
- let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = G(), i = [
2915
- "select",
2916
- "radio",
2917
- "autocomplete",
2918
- "checkbox"
2919
- ].includes(n?.data?.type || ""), a = Ut(n?.id), o = W(), s = n?.data?.type === "submit", c = n?.data?.type === "hidden", { handleSubmit: l, Field: u } = Ve({
2920
- defaultValues: {
2921
- defaultValue: n?.data?.defaultValue,
2922
- disablePast: n?.data?.disablePast,
2923
- errorMessage: n?.data?.errorMessage || { en: "" },
2924
- helperText: n?.data?.helperText || { en: "" },
2925
- httpConfig: n?.data?.httpConfig,
2926
- label: n?.data?.label || { en: "" },
2927
- multiple: n?.data?.multiple,
2928
- name: n?.data?.name || "",
2929
- options: n?.data?.options || [],
2930
- pattern: n?.data?.pattern || "",
2931
- placeholder: n?.data?.placeholder || { en: "" },
2932
- required: n?.data?.required,
2933
- submitConfig: n?.data?.submitConfig,
2934
- variant: n?.data?.variant || "default"
2935
- },
2936
- listeners: {
2937
- onChange: ({ formApi: e }) => {
2938
- e.handleSubmit().then();
2939
- },
2940
- onChangeDebounceMs: 150
2941
- },
2942
- onSubmit: ({ value: e }) => {
2943
- r(e);
2944
- }
2945
- });
2946
- return /* @__PURE__ */ L("form", {
2947
- onSubmit: (e) => {
2948
- e.preventDefault(), e.stopPropagation();
2949
- },
2950
- children: /* @__PURE__ */ R("div", {
2951
- className: "tg:grid tg:gap-6",
2952
- children: [
2953
- /* @__PURE__ */ R("div", {
2954
- className: "tg:flex tg:items-end tg:gap-2",
2955
- children: [/* @__PURE__ */ L(u, {
2956
- name: "label",
2957
- children: (t) => /* @__PURE__ */ R(j, {
2958
- className: "tg:flex-1",
2959
- children: [/* @__PURE__ */ L(d, {
2960
- htmlFor: t.name,
2961
- children: o("editor.inputNodeForm.label")
2962
- }), /* @__PURE__ */ L(k, {
2963
- autoFocus: !0,
2964
- id: t.name,
2965
- name: t.name,
2966
- value: t.state.value?.[e] || "",
2967
- onBlur: t.handleBlur,
2968
- onChange: ({ target: n }) => {
2969
- t.handleChange({
2970
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2971
- [e]: n.value
2972
- });
2973
- }
2974
- })]
2975
- })
2976
- }), /* @__PURE__ */ L(Q, {
2977
- value: e,
2978
- onValueChange: t
2979
- })]
2980
- }),
2981
- !(s || c) && n?.data?.type !== "file" && /* @__PURE__ */ R("div", {
2982
- className: "tg:flex tg:items-end tg:gap-2",
2983
- children: [/* @__PURE__ */ L(u, {
2984
- name: "placeholder",
2985
- children: (t) => /* @__PURE__ */ R(j, {
2986
- className: "tg:flex-1",
2987
- children: [/* @__PURE__ */ L(d, {
2988
- htmlFor: t.name,
2989
- children: o("editor.inputNodeForm.placeholder")
2990
- }), /* @__PURE__ */ L(k, {
2991
- id: t.name,
2992
- name: t.name,
2993
- value: t.state.value?.[e] || "",
2994
- onBlur: t.handleBlur,
2995
- onChange: ({ target: n }) => {
2996
- t.handleChange({
2997
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
2998
- [e]: n.value
2999
- });
3000
- }
3001
- })]
3002
- })
3003
- }), /* @__PURE__ */ L(Q, {
3004
- value: e,
3005
- onValueChange: t
3006
- })]
3007
- }),
3008
- !(s || c) && /* @__PURE__ */ R("div", {
3009
- className: "tg:flex tg:items-end tg:gap-2",
3010
- children: [/* @__PURE__ */ L(u, {
3011
- name: "helperText",
3012
- children: (t) => /* @__PURE__ */ R(j, {
3013
- className: "tg:flex-1",
3014
- children: [/* @__PURE__ */ L(d, {
3015
- htmlFor: t.name,
3016
- children: o("editor.inputNodeForm.helperText")
3017
- }), /* @__PURE__ */ L(k, {
3018
- id: t.name,
3019
- name: t.name,
3020
- value: t.state.value?.[e] || "",
3021
- onBlur: t.handleBlur,
3022
- onChange: ({ target: n }) => {
3023
- t.handleChange({
3024
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
3025
- [e]: n.value
3026
- });
3027
- }
3028
- })]
3029
- })
3030
- }), /* @__PURE__ */ L(Q, {
3031
- value: e,
3032
- onValueChange: t
3033
- })]
3034
- }),
3035
- n?.data?.type === "http" && /* @__PURE__ */ R(hr, {
3036
- defaultOpen: !0,
3037
- className: "tg:flex tg:w-full tg:max-w-[350px] tg:flex-col tg:gap-2",
3038
- children: [/* @__PURE__ */ L(gr, {
3039
- asChild: !0,
3040
- children: /* @__PURE__ */ R("div", {
3041
- className: "tg:flex tg:items-center tg:justify-between tg:gap-4",
3042
- children: [/* @__PURE__ */ L("h4", {
3043
- className: "tg:font-semibold tg:text-sm",
3044
- children: o("editor.inputNodeForm.httpConfiguration")
3045
- }), /* @__PURE__ */ R(A, {
3046
- variant: "ghost",
3047
- size: "icon",
3048
- className: "tg:size-8",
3049
- children: [/* @__PURE__ */ L(Ze, {}), /* @__PURE__ */ L("span", {
3050
- className: "tg:sr-only",
3051
- children: o("common.toggle")
3052
- })]
3053
- })]
3054
- })
3055
- }), /* @__PURE__ */ L(_r, {
3056
- className: "tg:flex tg:flex-col tg:gap-4",
3057
- children: /* @__PURE__ */ L(u, {
3058
- name: "httpConfig",
3059
- children: (e) => /* @__PURE__ */ L(nr, {
3060
- value: e.state.value,
3061
- onChange: (t) => {
3062
- e.handleChange(t), l().then();
3063
- }
3064
- })
3065
- })
3066
- })]
3067
- }),
3068
- s && /* @__PURE__ */ R(hr, {
3069
- className: "tg:flex tg:w-full tg:max-w-[350px] tg:flex-col tg:gap-2",
3070
- children: [/* @__PURE__ */ L(gr, {
3071
- asChild: !0,
3072
- children: /* @__PURE__ */ R("div", {
3073
- className: "tg:flex tg:items-center tg:justify-between tg:gap-4",
3074
- children: [/* @__PURE__ */ L("h4", {
3075
- className: "tg:font-semibold tg:text-sm",
3076
- children: o("editor.inputNodeForm.submitConfiguration")
3077
- }), /* @__PURE__ */ R(A, {
3078
- variant: "ghost",
3079
- size: "icon",
3080
- className: "tg:size-8",
3081
- children: [/* @__PURE__ */ L(Ze, {}), /* @__PURE__ */ L("span", {
3082
- className: "tg:sr-only",
3083
- children: o("common.toggle")
3084
- })]
3085
- })]
3086
- })
3087
- }), /* @__PURE__ */ L(_r, {
3088
- className: "tg:flex tg:flex-col tg:gap-4",
3089
- children: /* @__PURE__ */ L(u, {
3090
- name: "submitConfig",
3091
- children: (e) => /* @__PURE__ */ L(ir, {
3092
- value: e.state.value,
3093
- onChange: (t) => {
3094
- e.handleChange(t), l().then();
3095
- }
3096
- })
3097
- })
3098
- })]
3099
- }),
3100
- n?.data?.type === "file" && /* @__PURE__ */ L(u, {
3101
- name: "multiple",
3102
- children: (e) => /* @__PURE__ */ R("div", {
3103
- className: "tg:flex tg:items-center tg:space-x-2",
3104
- children: [/* @__PURE__ */ L(O, {
3105
- id: e.name,
3106
- checked: e.state.value,
3107
- onCheckedChange: (t) => e.handleChange(t)
3108
- }), /* @__PURE__ */ L(d, {
3109
- htmlFor: e.name,
3110
- children: o("editor.inputNodeForm.multipleFiles")
3111
- })]
3112
- })
3113
- }),
3114
- i && /* @__PURE__ */ R(hr, {
3115
- defaultOpen: !0,
3116
- className: "tg:flex tg:w-full tg:max-w-[350px] tg:flex-col tg:gap-2",
3117
- children: [/* @__PURE__ */ L(gr, {
3118
- asChild: !0,
3119
- children: /* @__PURE__ */ R("div", {
3120
- className: "tg:flex tg:items-center tg:justify-between tg:gap-4",
3121
- children: [/* @__PURE__ */ L("h4", {
3122
- className: "tg:font-semibold tg:text-sm",
3123
- children: o("editor.inputNodeForm.options")
3124
- }), /* @__PURE__ */ R(A, {
3125
- variant: "ghost",
3126
- size: "icon",
3127
- className: "tg:size-8",
3128
- children: [/* @__PURE__ */ L(Ze, {}), /* @__PURE__ */ L("span", {
3129
- className: "tg:sr-only",
3130
- children: o("common.toggle")
3131
- })]
3132
- })]
3133
- })
3134
- }), /* @__PURE__ */ R(_r, {
3135
- className: "tg:flex tg:flex-col tg:gap-4",
3136
- children: [
3137
- /* @__PURE__ */ L(u, {
3138
- name: "options",
3139
- mode: "array",
3140
- children: (t) => /* @__PURE__ */ R("div", {
3141
- className: "tg:space-y-2",
3142
- children: [t.state.value?.map((r, i) => {
3143
- let a = `options[${i}]`;
3144
- return /* @__PURE__ */ R("div", {
3145
- className: "tg:flex tg:flex-col tg:gap-2",
3146
- children: [/* @__PURE__ */ R("div", {
3147
- className: "tg:flex tg:items-start tg:gap-2",
3148
- children: [
3149
- n?.data?.type === "radio" && /* @__PURE__ */ L(u, {
3150
- name: `options[${i}].image`,
3151
- children: (e) => /* @__PURE__ */ L(mr, {
3152
- value: e.state.value,
3153
- onChange: (t) => e.handleChange(t)
3154
- })
3155
- }),
3156
- /* @__PURE__ */ L(u, {
3157
- name: `options[${i}].label`,
3158
- children: (t) => /* @__PURE__ */ L(k, {
3159
- placeholder: o("editor.inputNodeForm.optionLabel"),
3160
- value: t.state.value?.[e] || "",
3161
- onChange: ({ target: n }) => {
3162
- t.handleChange({
3163
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
3164
- [e]: n.value
3165
- });
3166
- }
3167
- })
3168
- }),
3169
- /* @__PURE__ */ L(u, {
3170
- name: `options[${i}].value`,
3171
- children: (e) => /* @__PURE__ */ L(k, {
3172
- placeholder: o("editor.inputNodeForm.optionValue"),
3173
- value: e.state.value || "",
3174
- onChange: ({ target: t }) => e.handleChange(t.value)
3175
- })
3176
- }),
3177
- /* @__PURE__ */ L(A, {
3178
- type: "button",
3179
- variant: "ghost",
3180
- size: "icon",
3181
- onClick: () => {
3182
- t.removeValue(i), l().then();
3183
- },
3184
- children: /* @__PURE__ */ L(B, { className: "tg:h-4 tg:w-4" })
3185
- })
3186
- ]
3187
- }), (n?.data?.type === "radio" || n?.data?.type === "checkbox") && /* @__PURE__ */ L(u, {
3188
- name: `options[${i}].description`,
3189
- children: (t) => /* @__PURE__ */ L(k, {
3190
- placeholder: o("editor.inputNodeForm.optionDescription"),
3191
- value: t.state.value?.[e] || "",
3192
- onChange: ({ target: n }) => {
3193
- t.handleChange({
3194
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
3195
- [e]: n.value
3196
- });
3197
- }
3198
- })
3199
- })]
3200
- }, a);
3201
- }), /* @__PURE__ */ L(A, {
3202
- type: "button",
3203
- variant: "outline",
3204
- size: "sm",
3205
- onClick: () => {
3206
- t.pushValue({
3207
- label: { en: "" },
3208
- value: ""
3209
- }), l().then();
3210
- },
3211
- children: o("editor.inputNodeForm.addOption")
3212
- })]
3213
- })
3214
- }),
3215
- n?.data?.type === "select" && /* @__PURE__ */ L(u, {
3216
- name: "multiple",
3217
- children: (e) => /* @__PURE__ */ R("div", {
3218
- className: "tg:flex tg:items-center tg:space-x-2",
3219
- children: [/* @__PURE__ */ L(O, {
3220
- id: e.name,
3221
- checked: e.state.value,
3222
- onCheckedChange: (t) => e.handleChange(t)
3223
- }), /* @__PURE__ */ L(d, {
3224
- htmlFor: e.name,
3225
- children: o("editor.inputNodeForm.multipleSelection")
3226
- })]
3227
- })
3228
- }),
3229
- n?.data?.type === "radio" && /* @__PURE__ */ L(u, {
3230
- name: "variant",
3231
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
3232
- htmlFor: e.name,
3233
- children: o("editor.inputNodeForm.variant")
3234
- }), /* @__PURE__ */ R(g, {
3235
- value: e.state.value || "default",
3236
- onValueChange: (t) => e.handleChange(t),
3237
- children: [/* @__PURE__ */ L(v, {
3238
- id: e.name,
3239
- className: "tg:w-full",
3240
- children: /* @__PURE__ */ L(T, {})
3241
- }), /* @__PURE__ */ R(C, { children: [/* @__PURE__ */ L(h, {
3242
- value: "default",
3243
- children: o("editor.inputNodeForm.variantDefault")
3244
- }), /* @__PURE__ */ L(h, {
3245
- value: "card",
3246
- children: o("editor.inputNodeForm.variantCard")
3247
- })] })]
3248
- })] })
3249
- })
3250
- ]
3251
- })]
3252
- }),
3253
- !s && /* @__PURE__ */ R(hr, {
3254
- className: "tg:flex tg:w-full tg:max-w-[350px] tg:flex-col tg:gap-2",
3255
- children: [/* @__PURE__ */ L(gr, {
3256
- asChild: !0,
3257
- children: /* @__PURE__ */ R("div", {
3258
- className: "tg:flex tg:items-center tg:justify-between tg:gap-4",
3259
- children: [/* @__PURE__ */ L("h4", {
3260
- className: "tg:font-semibold tg:text-sm",
3261
- children: o("editor.inputNodeForm.validation")
3262
- }), /* @__PURE__ */ R(A, {
3263
- variant: "ghost",
3264
- size: "icon",
3265
- className: "tg:size-8",
3266
- children: [/* @__PURE__ */ L(Ze, {}), /* @__PURE__ */ L("span", {
3267
- className: "tg:sr-only",
3268
- children: o("common.toggle")
3269
- })]
3270
- })]
3271
- })
3272
- }), /* @__PURE__ */ R(_r, {
3273
- className: "tg:flex tg:flex-col tg:gap-6",
3274
- children: [
3275
- /* @__PURE__ */ L(u, {
3276
- name: "required",
3277
- children: (e) => /* @__PURE__ */ L(j, { children: /* @__PURE__ */ R("div", {
3278
- className: "tg:flex tg:items-center tg:space-x-2",
3279
- children: [/* @__PURE__ */ L(O, {
3280
- id: e.name,
3281
- checked: e.state.value,
3282
- onCheckedChange: (t) => e.handleChange(t)
3283
- }), /* @__PURE__ */ L(d, {
3284
- htmlFor: e.name,
3285
- children: o("editor.inputNodeForm.required")
3286
- })]
3287
- }) })
3288
- }),
3289
- (n?.data?.type === "date" || n?.data?.type === "daterange") && /* @__PURE__ */ L(u, {
3290
- name: "disablePast",
3291
- children: (e) => /* @__PURE__ */ L(j, { children: /* @__PURE__ */ R("div", {
3292
- className: "tg:flex tg:items-center tg:space-x-2",
3293
- children: [/* @__PURE__ */ L(O, {
3294
- id: e.name,
3295
- checked: e.state.value,
3296
- onCheckedChange: (t) => e.handleChange(t)
3297
- }), /* @__PURE__ */ L(d, {
3298
- htmlFor: e.name,
3299
- children: o("editor.inputNodeForm.disablePast")
3300
- })]
3301
- }) })
3302
- }),
3303
- /* @__PURE__ */ L(u, {
3304
- name: "pattern",
3305
- children: (e) => /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
3306
- htmlFor: e.name,
3307
- children: o("editor.inputNodeForm.pattern")
3308
- }), /* @__PURE__ */ L(sr, {
3309
- id: e.name,
3310
- value: e.state.value,
3311
- onValueChange: e.handleChange
3312
- })] })
3313
- }),
3314
- /* @__PURE__ */ R("div", {
3315
- className: "tg:flex tg:items-end tg:gap-2",
3316
- children: [/* @__PURE__ */ L(u, {
3317
- name: "errorMessage",
3318
- children: (t) => /* @__PURE__ */ R(j, {
3319
- className: "tg:flex-1",
3320
- children: [/* @__PURE__ */ L(d, {
3321
- htmlFor: t.name,
3322
- children: o("editor.inputNodeForm.errorMessage")
3323
- }), /* @__PURE__ */ L(k, {
3324
- id: t.name,
3325
- name: t.name,
3326
- value: t.state.value?.[e] || "",
3327
- onBlur: t.handleBlur,
3328
- onChange: ({ target: n }) => {
3329
- t.handleChange({
3330
- ...typeof t.state.value == "object" && t.state.value !== null ? t.state.value : {},
3331
- [e]: n.value
3332
- });
3333
- }
3334
- })]
3335
- })
3336
- }), /* @__PURE__ */ L(Q, {
3337
- value: e,
3338
- onValueChange: t
3339
- })]
3340
- })
3341
- ]
3342
- })]
3343
- }),
3344
- !s && /* @__PURE__ */ R(hr, {
3345
- className: "tg:flex tg:w-full tg:max-w-[350px] tg:flex-col tg:gap-2",
3346
- children: [/* @__PURE__ */ L(gr, {
3347
- asChild: !0,
3348
- children: /* @__PURE__ */ R("div", {
3349
- className: "tg:flex tg:items-center tg:justify-between tg:gap-4",
3350
- children: [/* @__PURE__ */ L("h4", {
3351
- className: "tg:font-semibold tg:text-sm",
3352
- children: o("editor.inputNodeForm.advancedConfiguration")
3353
- }), /* @__PURE__ */ R(A, {
3354
- variant: "ghost",
3355
- size: "icon",
3356
- className: "tg:size-8",
3357
- children: [/* @__PURE__ */ L(Ze, {}), /* @__PURE__ */ L("span", {
3358
- className: "tg:sr-only",
3359
- children: o("common.toggle")
3360
- })]
3361
- })]
3362
- })
3363
- }), /* @__PURE__ */ R(_r, {
3364
- className: "tg:flex tg:flex-col tg:gap-6",
3365
- children: [/* @__PURE__ */ L(u, {
3366
- name: "name",
3367
- children: (e) => /* @__PURE__ */ R(j, { children: [
3368
- /* @__PURE__ */ L(d, {
3369
- htmlFor: e.name,
3370
- children: o("editor.inputNodeForm.name")
3371
- }),
3372
- /* @__PURE__ */ L(k, {
3373
- id: e.name,
3374
- name: e.name,
3375
- value: e.state.value,
3376
- onBlur: e.handleBlur,
3377
- onChange: ({ target: t }) => e.handleChange(t.value)
3378
- }),
3379
- /* @__PURE__ */ L(M, { children: o("editor.inputNodeForm.nameDescription") })
3380
- ] })
3381
- }), /* @__PURE__ */ L(u, {
3382
- name: "defaultValue",
3383
- children: (e) => /* @__PURE__ */ R(I, { children: [
3384
- /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
3385
- htmlFor: e.name,
3386
- children: o("editor.inputNodeForm.defaultValueType")
3387
- }), /* @__PURE__ */ R(g, {
3388
- value: e.state.value?.type || "none",
3389
- onValueChange: (t) => {
3390
- e.handleChange(t === "none" ? null : { type: t });
3391
- },
3392
- children: [/* @__PURE__ */ L(v, {
3393
- id: e.name,
3394
- children: /* @__PURE__ */ L(T, { placeholder: o("editor.inputNodeForm.selectType") })
3395
- }), /* @__PURE__ */ R(C, { children: [
3396
- /* @__PURE__ */ L(h, {
3397
- value: "none",
3398
- children: o("editor.inputNodeForm.defaultValueTypeNone")
3399
- }),
3400
- /* @__PURE__ */ L(h, {
3401
- value: "static",
3402
- children: o("editor.inputNodeForm.defaultValueTypeStatic")
3403
- }),
3404
- /* @__PURE__ */ L(h, {
3405
- value: "reference",
3406
- children: o("editor.inputNodeForm.defaultValueTypeReference")
3407
- })
3408
- ] })]
3409
- })] }),
3410
- e.state.value?.type === "static" && /* @__PURE__ */ L(u, {
3411
- name: "defaultValue.staticValue",
3412
- children: (e) => {
3413
- let t = n?.data?.type;
3414
- return (t === "select" || t === "checkbox") && n?.data?.multiple ? /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
3415
- htmlFor: e.name,
3416
- children: o("editor.inputNodeForm.defaultValuesCommaSeparated")
3417
- }), /* @__PURE__ */ L(k, {
3418
- id: e.name,
3419
- placeholder: o("editor.inputNodeForm.defaultValuesPlaceholder"),
3420
- value: Array.isArray(e.state.value) ? e.state.value.join(", ") : "",
3421
- onChange: ({ target: t }) => {
3422
- let n = t.value.split(",").map((e) => e.trim()).filter(Boolean);
3423
- e.handleChange(n.length > 0 ? n : null);
3424
- }
3425
- })] }) : t === "checkbox" ? /* @__PURE__ */ L(j, { children: /* @__PURE__ */ R("div", {
3426
- className: "tg:flex tg:items-center tg:space-x-2",
3427
- children: [/* @__PURE__ */ L(O, {
3428
- id: e.name,
3429
- checked: !!e.state.value,
3430
- onCheckedChange: (t) => e.handleChange(t)
3431
- }), /* @__PURE__ */ L(d, {
3432
- htmlFor: e.name,
3433
- children: o("editor.inputNodeForm.defaultChecked")
3434
- })]
3435
- }) }) : /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(d, {
3436
- htmlFor: e.name,
3437
- children: o("editor.inputNodeForm.staticValue")
3438
- }), /* @__PURE__ */ L(k, {
3439
- id: e.name,
3440
- placeholder: o("editor.inputNodeForm.staticValuePlaceholder"),
3441
- value: typeof e.state.value == "string" ? e.state.value : "",
3442
- onChange: ({ target: t }) => e.handleChange(t.value || "")
3443
- })] });
3444
- }
3445
- }),
3446
- e.state.value?.type === "reference" && /* @__PURE__ */ R(I, { children: [
3447
- /* @__PURE__ */ L(u, {
3448
- name: "defaultValue.referenceField",
3449
- children: (e) => /* @__PURE__ */ R(j, { children: [
3450
- /* @__PURE__ */ L(d, {
3451
- htmlFor: e.name,
3452
- children: o("editor.inputNodeForm.referenceField")
3453
- }),
3454
- /* @__PURE__ */ R(g, {
3455
- value: e.state.value || "",
3456
- onValueChange: (t) => {
3457
- e.handleChange(t);
3458
- },
3459
- children: [/* @__PURE__ */ L(v, {
3460
- id: e.name,
3461
- children: /* @__PURE__ */ L(T, { placeholder: o("editor.inputNodeForm.selectReferenceField") })
3462
- }), /* @__PURE__ */ L(C, { children: a.length === 0 ? /* @__PURE__ */ L(h, {
3463
- value: "none",
3464
- disabled: !0,
3465
- children: o("editor.inputNodeForm.noParentFieldsAvailable")
3466
- }) : a.map((e) => /* @__PURE__ */ R(h, {
3467
- value: e.nodeId,
3468
- children: [
3469
- e.label,
3470
- " (",
3471
- e.type,
3472
- ")"
3473
- ]
3474
- }, e.nodeId)) })]
3475
- }),
3476
- a.length === 0 && /* @__PURE__ */ L(M, { children: o("editor.inputNodeForm.addInputFieldsBeforeReference") })
3477
- ] })
3478
- }),
3479
- /* @__PURE__ */ L(u, {
3480
- name: "defaultValue.transformFunction",
3481
- children: (t) => /* @__PURE__ */ R(j, { children: [
3482
- /* @__PURE__ */ L(d, {
3483
- htmlFor: t.name,
3484
- children: o("editor.inputNodeForm.transformType")
3485
- }),
3486
- /* @__PURE__ */ R(g, {
3487
- value: t.state.value || "none",
3488
- onValueChange: (n) => {
3489
- let r = n === "none" ? null : n;
3490
- if (t.handleChange(r), n === "toObject") {
3491
- let t = e.state.value;
3492
- e.handleChange({
3493
- ...t,
3494
- objectMapping: []
3495
- });
3496
- }
3497
- },
3498
- children: [/* @__PURE__ */ L(v, {
3499
- id: t.name,
3500
- children: /* @__PURE__ */ L(T, { placeholder: o("editor.inputNodeForm.selectTransformation") })
3501
- }), /* @__PURE__ */ R(C, { children: [
3502
- /* @__PURE__ */ L(h, {
3503
- value: "none",
3504
- children: o("editor.inputNodeForm.transformNone")
3505
- }),
3506
- /* @__PURE__ */ L(h, {
3507
- value: "toString",
3508
- children: o("editor.inputNodeForm.transformString")
3509
- }),
3510
- /* @__PURE__ */ L(h, {
3511
- value: "toNumber",
3512
- children: o("editor.inputNodeForm.transformNumber")
3513
- }),
3514
- /* @__PURE__ */ L(h, {
3515
- value: "toBoolean",
3516
- children: o("editor.inputNodeForm.transformBoolean")
3517
- }),
3518
- /* @__PURE__ */ L(h, {
3519
- value: "toArray",
3520
- children: o("editor.inputNodeForm.transformArray")
3521
- }),
3522
- /* @__PURE__ */ L(h, {
3523
- value: "toObject",
3524
- children: o("editor.inputNodeForm.transformMapToObject")
3525
- })
3526
- ] })]
3527
- }),
3528
- /* @__PURE__ */ L(M, { children: o("editor.inputNodeForm.transformDesc") })
3529
- ] })
3530
- }),
3531
- e.state.value?.transformFunction === "toObject" && /* @__PURE__ */ L(u, {
3532
- name: "defaultValue.objectMapping",
3533
- mode: "array",
3534
- children: (e) => /* @__PURE__ */ R(j, { children: [
3535
- /* @__PURE__ */ L(d, { children: o("editor.inputNodeForm.objectMapping") }),
3536
- /* @__PURE__ */ R("div", {
3537
- className: "tg:space-y-2",
3538
- children: [e.state.value?.map((t, n) => /* @__PURE__ */ R("div", {
3539
- className: "tg:flex tg:items-center tg:gap-2",
3540
- children: [
3541
- /* @__PURE__ */ L(u, {
3542
- name: `defaultValue.objectMapping[${n}].sourceKey`,
3543
- children: (e) => /* @__PURE__ */ L(k, {
3544
- placeholder: o("editor.inputNodeForm.sourceKey"),
3545
- value: e.state.value || "",
3546
- onChange: ({ target: t }) => e.handleChange(t.value)
3547
- })
3548
- }),
3549
- /* @__PURE__ */ L("span", {
3550
- className: "tg:text-muted-foreground",
3551
- children: "→"
3552
- }),
3553
- /* @__PURE__ */ L(u, {
3554
- name: `defaultValue.objectMapping[${n}].targetKey`,
3555
- children: (e) => /* @__PURE__ */ L(k, {
3556
- placeholder: o("editor.inputNodeForm.targetKey"),
3557
- value: e.state.value || "",
3558
- onChange: ({ target: t }) => e.handleChange(t.value)
3559
- })
3560
- }),
3561
- /* @__PURE__ */ L(A, {
3562
- type: "button",
3563
- variant: "ghost",
3564
- size: "icon",
3565
- onClick: () => {
3566
- e.removeValue(n), l().then();
3567
- },
3568
- children: /* @__PURE__ */ L(B, { className: "tg:h-4 tg:w-4" })
3569
- })
3570
- ]
3571
- }, `mapping-${n}`)), /* @__PURE__ */ R(A, {
3572
- type: "button",
3573
- variant: "outline",
3574
- size: "sm",
3575
- className: "tg:w-full",
3576
- onClick: () => {
3577
- e.pushValue({
3578
- sourceKey: "",
3579
- targetKey: ""
3580
- }), l().then();
3581
- },
3582
- children: [/* @__PURE__ */ L(z, { className: "tg:mr-2 tg:h-4 tg:w-4" }), o("editor.inputNodeForm.addMapping")]
3583
- })]
3584
- }),
3585
- /* @__PURE__ */ L(M, { children: o("editor.inputNodeForm.objectMappingDesc") })
3586
- ] })
3587
- })
3588
- ] })
3589
- ] })
3590
- })]
3591
- })]
3592
- })
3593
- ]
3594
- })
3595
- });
3596
- }, yr = () => {
3597
- let [e, t] = F("en"), { selectedNode: n } = $(), { updateSelectedNodeData: r } = G(), { Field: i } = Ve({
3598
- defaultValues: { label: n?.data?.label || { en: "" } },
3599
- listeners: {
3600
- onChange: ({ formApi: e }) => {
3601
- e.handleSubmit().then();
3602
- },
3603
- onChangeDebounceMs: 150
3604
- },
3605
- onSubmit: ({ value: e }) => {
3606
- r(e);
3607
- }
3608
- });
3609
- return /* @__PURE__ */ L("form", {
3610
- onSubmit: (e) => {
3611
- e.preventDefault(), e.stopPropagation();
3612
- },
3613
- children: /* @__PURE__ */ L("div", {
3614
- className: "tg:grid tg:gap-6",
3615
- children: /* @__PURE__ */ R("div", {
3616
- className: "tg:flex tg:items-end tg:gap-2",
3617
- children: [/* @__PURE__ */ L(i, {
3618
- name: "label",
3619
- children: (t) => /* @__PURE__ */ R(j, {
3620
- className: "tg:flex-1",
3621
- children: [/* @__PURE__ */ L(d, {
3622
- htmlFor: t.name,
3623
- children: "Label"
3624
- }), /* @__PURE__ */ L(k, {
3625
- id: t.name,
3626
- name: t.name,
3627
- value: t.state.value?.[e] || "",
3628
- onBlur: t.handleBlur,
3629
- onChange: ({ target: n }) => {
3630
- t.handleChange({
3631
- ...t.state.value,
3632
- [e]: n.value
3633
- });
3634
- }
3635
- })]
3636
- })
3637
- }), /* @__PURE__ */ L(Q, {
3638
- value: e,
3639
- onValueChange: t
3640
- })]
3641
- })
3642
- })
3643
- });
3644
- }, br = () => {
3645
- let [e, t] = F(""), [r, i] = F(!1), { selectedNode: a, groupNodes: o } = $(), { setNodes: s } = N(), c = a?.parentId || "none", l = n(a), u = W(), f = Re(), p = Re();
3646
- if (l) return null;
3647
- let m = (e) => {
3648
- a && s((t) => e === "none" ? t.map((e) => {
3649
- if (e.id === a.id) {
3650
- let { parentId: t, extent: n, ...r } = e;
3651
- return r;
3652
- }
3653
- return e;
3654
- }) : t.find((t) => t.id === e) ? t.map((t) => t.id === a.id ? {
3655
- ...t,
3656
- extent: "parent",
3657
- parentId: e,
3658
- position: {
3659
- x: 50,
3660
- y: 80
3661
- }
3662
- } : t) : t);
3663
- }, _ = () => {
3664
- if (!(e.trim() && a)) return;
3665
- if (o.find((t) => {
3666
- let n = t.data?.label?.en || t.data?.label;
3667
- return String(n).toLowerCase() === e.trim().toLowerCase();
3668
- })) {
3669
- H.error("This group already exists", { description: "Use the selector to add the node to an existing group." });
3670
- return;
3671
- }
3672
- let n = Qt();
3673
- s((t) => [{
3674
- data: { label: { en: e.trim() } },
3675
- id: n,
3676
- position: {
3677
- x: a.position.x - 300,
3678
- y: a.position.y
3679
- },
3680
- style: {
3681
- height: 400,
3682
- width: 600
3683
- },
3684
- type: "group"
3685
- }, ...t.map((e) => e.id === a.id ? {
3686
- ...e,
3687
- extent: "parent",
3688
- parentId: n,
3689
- position: {
3690
- x: 175,
3691
- y: 30
3692
- }
3693
- } : e)]), t(""), i(!1), H.success("Group created", { description: `The group "${e.trim()}" has been created successfully.` });
3694
- };
3695
- return /* @__PURE__ */ R("div", {
3696
- className: "tg:space-y-2",
3697
- children: [/* @__PURE__ */ L(d, {
3698
- htmlFor: f,
3699
- children: u("editor.selectNodeGroup.group")
3700
- }), /* @__PURE__ */ R("div", {
3701
- className: "tg:flex tg:gap-2",
3702
- children: [/* @__PURE__ */ R(g, {
3703
- value: c,
3704
- onValueChange: m,
3705
- children: [/* @__PURE__ */ L(v, {
3706
- id: f,
3707
- className: "tg:flex-1",
3708
- children: /* @__PURE__ */ L(T, { placeholder: u("editor.selectNodeGroup.noGroup") })
3709
- }), /* @__PURE__ */ L(C, { children: /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(h, {
3710
- value: "none",
3711
- children: u("editor.selectNodeGroup.noGroup")
3712
- }), o.map((e) => /* @__PURE__ */ L(h, {
3713
- value: e.id,
3714
- children: e.data.label?.en ? String(e.data.label?.en) : e.id
3715
- }, e.id))] }) })]
3716
- }), /* @__PURE__ */ R(ie, {
3717
- open: r,
3718
- onOpenChange: i,
3719
- children: [/* @__PURE__ */ L(ne, {
3720
- asChild: !0,
3721
- children: /* @__PURE__ */ L(A, {
3722
- variant: "outline",
3723
- size: "icon",
3724
- title: "Create a new group",
3725
- children: /* @__PURE__ */ L(yt, { className: "tg:h-4 tg:w-4" })
3726
- })
3727
- }), /* @__PURE__ */ L(ae, {
3728
- className: "tg:w-80",
3729
- align: "end",
3730
- disablePortal: !0,
3731
- children: /* @__PURE__ */ R("div", {
3732
- className: "tg:space-y-4",
3733
- children: [
3734
- /* @__PURE__ */ R("div", {
3735
- className: "tg:space-y-2",
3736
- children: [/* @__PURE__ */ L("h4", {
3737
- className: "tg:font-medium tg:leading-none",
3738
- children: u("editor.selectNodeGroup.newGroup")
3739
- }), /* @__PURE__ */ L("p", {
3740
- className: "tg:text-muted-foreground tg:text-sm",
3741
- children: u("editor.selectNodeGroup.newGroupDescription")
3742
- })]
3743
- }),
3744
- /* @__PURE__ */ R("div", {
3745
- className: "tg:space-y-2",
3746
- children: [/* @__PURE__ */ L(d, {
3747
- htmlFor: p,
3748
- children: u("editor.selectNodeGroup.groupName")
3749
- }), /* @__PURE__ */ L(k, {
3750
- autoFocus: !0,
3751
- id: p,
3752
- value: e,
3753
- onChange: (e) => t(e.target.value),
3754
- placeholder: "Ex: Step 1 - Personal info",
3755
- onKeyDown: (e) => {
3756
- e.key === "Enter" && (e.preventDefault(), _());
3757
- }
3758
- })]
3759
- }),
3760
- /* @__PURE__ */ R("div", {
3761
- className: "tg:flex tg:justify-end tg:gap-2",
3762
- children: [/* @__PURE__ */ L(A, {
3763
- variant: "outline",
3764
- size: "sm",
3765
- onClick: () => i(!1),
3766
- children: "Cancel"
3767
- }), /* @__PURE__ */ L(A, {
3768
- size: "sm",
3769
- onClick: _,
3770
- disabled: !e.trim(),
3771
- children: "Create"
3772
- })]
3773
- })
3774
- ]
3775
- })
3776
- })]
3777
- })]
3778
- })]
3779
- });
3780
- }, xr = Object.values(X), Sr = Object.values(dn), Cr = () => {
3781
- let { selectedNode: e } = $(), { updateSelectedNodeType: t } = G(), { getEdges: a } = N(), { openNodeTypeChangeConfirmation: o } = U(), s = n(e), c = W(), u = Re(), d = Z(l.flow), f = () => e ? r(e) || i(e) ? e.data?.type || "" : e.type || "" : "", p = (n, r) => {
3782
- if (!e) return;
3783
- let i = a().filter((t) => t.source === e.id).length;
3784
- if ((n === l.ui || n === l.flow) && i > 1) {
3785
- o({
3786
- nodeId: e.id,
3787
- subType: r,
3788
- type: n
3789
- });
3790
- return;
3791
- }
3792
- t(n, r);
3793
- };
3794
- return /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(y, {
3795
- htmlFor: u,
3796
- children: c("editor.selectNodeType.nodeType")
3797
- }), /* @__PURE__ */ R(g, {
3798
- value: f(),
3799
- onValueChange: (e) => {
3800
- if (xr.includes(e)) {
3801
- p(l.input, e);
3802
- return;
3803
- }
3804
- if (Sr.includes(e)) {
3805
- p(l.ui, e);
3806
- return;
3807
- }
3808
- p(e);
3809
- },
3810
- disabled: s,
3811
- children: [/* @__PURE__ */ L(v, {
3812
- className: "tg:w-full tg:capitalize",
3813
- id: u,
3814
- children: /* @__PURE__ */ L(T, { placeholder: c("editor.selectNodeType.nodeType") })
3815
- }), /* @__PURE__ */ L(C, {
3816
- className: "treege-scrollbar tg:max-h-80",
3817
- children: s ? /* @__PURE__ */ L(w, { children: /* @__PURE__ */ L(h, {
3818
- value: l.group,
3819
- children: c("editor.selectNodeType.options.group")
3820
- }) }) : /* @__PURE__ */ R(I, { children: [
3821
- /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(y, { children: c("editor.selectNodeType.options.input") }), xr.map((e) => /* @__PURE__ */ R(h, {
3822
- value: e,
3823
- className: "tg:capitalize",
3824
- children: [/* @__PURE__ */ L(Z(e), {}), e]
3825
- }, e))] }),
3826
- /* @__PURE__ */ L(ue, {}),
3827
- /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(y, { children: c("editor.selectNodeType.options.ui") }), Sr.map((e) => /* @__PURE__ */ R(h, {
3828
- value: e,
3829
- className: "tg:capitalize",
3830
- children: [/* @__PURE__ */ L(Z(e), {}), e]
3831
- }, e))] }),
3832
- /* @__PURE__ */ L(ue, {}),
3833
- /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(y, { children: c("common.other") }), /* @__PURE__ */ R(h, {
3834
- value: l.flow,
3835
- children: [/* @__PURE__ */ L(d, {}), c("editor.selectNodeType.options.flow")]
3836
- })] })
3837
- ] })
3838
- })]
3839
- })] });
3840
- };
3841
- //#endregion
3842
- //#region src/shared/components/ui/sheet.tsx
3843
- function wr({ ...e }) {
3844
- return /* @__PURE__ */ L(Ft.Root, {
3845
- "data-slot": "sheet",
3846
- ...e
3847
- });
3848
- }
3849
- function Tr({ ...e }) {
3850
- return /* @__PURE__ */ L(Ft.Portal, {
3851
- "data-slot": "sheet-portal",
3852
- ...e
3853
- });
3854
- }
3855
- function Er({ className: e, ...t }) {
3856
- return /* @__PURE__ */ L(Ft.Overlay, {
3857
- "data-slot": "sheet-overlay",
3858
- className: D("tg:data-[state=closed]:fade-out-0 tg:data-[state=open]:fade-in-0 tg:fixed tg:inset-0 tg:z-50 tg:bg-black/50 tg:data-[state=closed]:animate-out tg:data-[state=open]:animate-in", e),
3859
- ...t
3860
- });
3861
- }
3862
- function Dr({ className: e, children: t, side: n = "right", ...r }) {
3863
- return /* @__PURE__ */ R(Tr, { children: [/* @__PURE__ */ L(Er, {}), /* @__PURE__ */ R(Ft.Content, {
3864
- "data-slot": "sheet-content",
3865
- className: D("tg:fixed tg:z-50 tg:flex tg:flex-col tg:gap-4 tg:bg-background tg:shadow-lg tg:transition tg:ease-in-out tg:data-[state=closed]:animate-out tg:data-[state=open]:animate-in tg:data-[state=closed]:duration-300 tg:data-[state=open]:duration-500", n === "right" && "tg:data-[state=closed]:slide-out-to-right tg:data-[state=open]:slide-in-from-right tg:inset-y-0 tg:right-0 tg:h-full tg:w-3/4 tg:border-l tg:sm:max-w-sm", n === "left" && "tg:data-[state=closed]:slide-out-to-left tg:data-[state=open]:slide-in-from-left tg:inset-y-0 tg:left-0 tg:h-full tg:w-3/4 tg:border-r tg:sm:max-w-sm", n === "top" && "tg:data-[state=closed]:slide-out-to-top tg:data-[state=open]:slide-in-from-top tg:inset-x-0 tg:top-0 tg:h-auto tg:border-b", n === "bottom" && "tg:data-[state=closed]:slide-out-to-bottom tg:data-[state=open]:slide-in-from-bottom tg:inset-x-0 tg:bottom-0 tg:h-auto tg:border-t", e),
3866
- ...r,
3867
- children: [t, /* @__PURE__ */ R(Ft.Close, {
3868
- className: "tg:absolute tg:top-4 tg:right-4 tg:rounded-xs tg:opacity-70 tg:ring-offset-background tg:transition-opacity tg:hover:opacity-100 tg:focus:outline-hidden tg:focus:ring-2 tg:focus:ring-ring tg:focus:ring-offset-2 tg:disabled:pointer-events-none tg:data-[state=open]:bg-secondary",
3869
- children: [/* @__PURE__ */ L(jt, { className: "tg:size-4" }), /* @__PURE__ */ L("span", {
3870
- className: "tg:sr-only",
3871
- children: "Close"
3872
- })]
3873
- })]
3874
- })] });
3875
- }
3876
- function Or({ className: e, ...t }) {
3877
- return /* @__PURE__ */ L("div", {
3878
- "data-slot": "sheet-header",
3879
- className: D("tg:flex tg:flex-col tg:gap-1.5 tg:p-4", e),
3880
- ...t
3881
- });
3882
- }
3883
- function kr({ className: e, ...t }) {
3884
- return /* @__PURE__ */ L("div", {
3885
- "data-slot": "sheet-footer",
3886
- className: D("tg:mt-auto tg:flex tg:flex-col tg:gap-2 tg:p-4", e),
3887
- ...t
3888
- });
3889
- }
3890
- function Ar({ className: e, ...t }) {
3891
- return /* @__PURE__ */ L(Ft.Title, {
3892
- "data-slot": "sheet-title",
3893
- className: D("tg:font-semibold tg:text-foreground", e),
3894
- ...t
3895
- });
3896
- }
3897
- function jr({ className: e, ...t }) {
3898
- return /* @__PURE__ */ L(Ft.Description, {
3899
- "data-slot": "sheet-description",
3900
- className: D("tg:text-muted-foreground tg:text-sm", e),
3901
- ...t
3902
- });
3903
- }
3904
- //#endregion
3905
- //#region src/editor/features/TreegeEditor/sheets/NodeActionsSheet.tsx
3906
- var Mr = () => {
3907
- let { selectedNode: e } = $(), { clearSelection: t } = G(), { isNodeSheetOpen: a, setIsNodeSheetOpen: s, openDeleteNodeConfirmation: c } = U(), l = W(), u = l(e?.data?.label), d = () => {
3908
- s(!1), t();
3909
- };
3910
- return /* @__PURE__ */ L(wr, {
3911
- open: a && !!e,
3912
- onOpenChange: (e) => {
3913
- e || d();
3914
- },
3915
- children: /* @__PURE__ */ R(Dr, {
3916
- className: "tg:flex tg:flex-col tg:gap-0",
3917
- children: [
3918
- /* @__PURE__ */ R(Or, { children: [/* @__PURE__ */ R(Ar, { children: [
3919
- l("editor.nodeActionsSheet.editNode"),
3920
- " ",
3921
- /* @__PURE__ */ L("span", {
3922
- className: "tg:font-light tg:text-muted-foreground tg:text-xs",
3923
- children: e?.id
3924
- })
3925
- ] }), /* @__PURE__ */ L(jr, { children: u || "\xA0" })] }),
3926
- /* @__PURE__ */ L(Kt, {
3927
- className: "tg:flex tg:min-h-0 tg:flex-1 tg:flex-col tg:px-4",
3928
- children: /* @__PURE__ */ R("div", {
3929
- className: "tg:space-y-6 tg:py-4",
3930
- children: [
3931
- /* @__PURE__ */ L(Cr, {}),
3932
- /* @__PURE__ */ L(br, {}),
3933
- /* @__PURE__ */ L(le, {}),
3934
- r(e) && /* @__PURE__ */ L(vr, {}),
3935
- i(e) && /* @__PURE__ */ L(yr, {}),
3936
- o(e) && /* @__PURE__ */ L($n, {}),
3937
- n(e) && /* @__PURE__ */ L(er, {})
3938
- ]
3939
- })
3940
- }),
3941
- /* @__PURE__ */ L(kr, {
3942
- className: "tg:flex tg:items-end tg:border-t",
3943
- children: /* @__PURE__ */ L(A, {
3944
- variant: "ghost",
3945
- size: "icon",
3946
- onClick: () => {
3947
- e && c(e.id);
3948
- },
3949
- "aria-label": l("editor.nodeActionsSheet.deleteNode"),
3950
- children: /* @__PURE__ */ L(Et, {})
3951
- })
3952
- })
3953
- ]
3954
- })
3955
- });
3956
- }, Nr = ({ ...e }) => {
3957
- let { theme: t = "system" } = zt();
3958
- return /* @__PURE__ */ L(Lt, {
3959
- theme: t,
3960
- className: "toaster tg:group",
3961
- style: {
3962
- "--normal-bg": "var(--treege-popover)",
3963
- "--normal-border": "var(--treege-border)",
3964
- "--normal-text": "var(--treege-popover-foreground)"
3965
- },
3966
- ...e
3967
- });
3968
- }, Pr = {
3969
- desktop: "(min-width: 1024px)",
3970
- mobile: "(max-width: 767px)",
3971
- tablet: "(min-width: 768px) and (max-width: 1023px)"
3972
- }, Fr = (e) => e in Pr, Ir = (e) => {
3973
- let [t, n] = F(void 0), r = Fr(e) ? Pr[e] : e;
3974
- return Le(() => {
3975
- let e = window.matchMedia(r), t = () => n(e.matches);
3976
- return e.addEventListener("change", t), n(e.matches), () => e.removeEventListener("change", t);
3977
- }, [r]), !!t;
3978
- }, Lr = ({ flow: e, onExportJson: t, onSave: n, theme: r, className: i, extraMenuItems: a }) => {
3979
- let { onConnect: o, onConnectEnd: s, onEdgesDelete: c, isValidConnection: l } = un(), [u, d] = F(!1);
3980
- return /* @__PURE__ */ R(Ee, {
3981
- fitView: !0,
3982
- minZoom: .1,
3983
- fitViewOptions: { maxZoom: Ir("mobile") ? .6 : 1 },
3984
- colorMode: r,
3985
- selectNodesOnDrag: !1,
3986
- nodeTypes: Tn,
3987
- edgeTypes: Xt,
3988
- defaultEdges: e?.edges || [],
3989
- defaultNodes: e?.nodes || [],
3990
- onConnect: o,
3991
- onConnectEnd: s,
3992
- onEdgesDelete: c,
3993
- isValidConnection: l,
3994
- className: D(i, "treege"),
3995
- children: [
3996
- /* @__PURE__ */ L(zn, {}),
3997
- /* @__PURE__ */ L(he, {
3998
- gap: 10,
3999
- variant: ge.Dots
4000
- }),
4001
- /* @__PURE__ */ L(Zn, {
4002
- onExportJson: t,
4003
- onSave: n,
4004
- extraMenuItems: a
4005
- }),
4006
- /* @__PURE__ */ L(Ht, { theme: r }),
4007
- u && /* @__PURE__ */ L(Se, {}),
4008
- /* @__PURE__ */ L(ye, { children: /* @__PURE__ */ L(En, {
4009
- show: u,
4010
- onToggle: () => d((e) => !e)
4011
- }) }),
4012
- /* @__PURE__ */ L(Mr, {}),
4013
- /* @__PURE__ */ L(An, {}),
4014
- /* @__PURE__ */ L(kn, {})
4015
- ]
4016
- });
4017
- }, Rr = ({ flow: e, onExportJson: t, onSave: n, theme: r = "dark", language: i = "en", aiConfig: a, extraMenuItems: o }) => /* @__PURE__ */ L(u, {
4018
- defaultTheme: r,
4019
- storageKey: "treege-editor-theme",
4020
- theme: r,
4021
- children: /* @__PURE__ */ R(Gt, {
4022
- value: {
4023
- aiConfig: a,
4024
- flowId: e?.id,
4025
- language: i
4026
- },
4027
- children: [/* @__PURE__ */ L(Nr, { position: "bottom-center" }), /* @__PURE__ */ L(De, { children: /* @__PURE__ */ L(Lr, {
4028
- onExportJson: t,
4029
- onSave: n,
4030
- flow: e,
4031
- theme: r,
4032
- extraMenuItems: o
4033
- }) })]
4034
- })
4035
- });
4036
- //#endregion
4037
- export { Rr as t };