treege 3.0.0-beta.60 → 3.0.0-beta.62

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 (33) hide show
  1. package/README.md +46 -46
  2. package/dist/DefaultInputs-DamDWb5R.js +1988 -0
  3. package/dist/{ThemeContext-Ddk_Y-Dz.js → ThemeContext-cGSTk24y.js} +121 -126
  4. package/dist/editor/context/TreegeEditorRuntimeProvider.d.ts +2 -2
  5. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  6. package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +3 -3
  7. package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +3 -3
  8. package/dist/editor/features/TreegeEditor/forms/OptionsMappingFields.d.ts +3 -3
  9. package/dist/editor/features/TreegeEditor/forms/SensitiveHeaderWarning.d.ts +2 -2
  10. package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +4 -4
  11. package/dist/editor/hooks/useKeyValueRows.d.ts +15 -0
  12. package/dist/editor/types/editor.d.ts +4 -10
  13. package/dist/editor/utils/sensitiveHeaders.d.ts +8 -3
  14. package/dist/{editor-D2pBjE7E.js → editor-K1jjfc5n.js} +1350 -1324
  15. package/dist/editor.js +2 -2
  16. package/dist/main.js +4 -4
  17. package/dist/renderer/context/TreegeRenderRuntimeProvider.d.ts +3 -3
  18. package/dist/renderer/features/TreegeRenderer/native/components/OptionItemContent.d.ts +17 -0
  19. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +1 -1
  20. package/dist/renderer/features/TreegeRenderer/web/components/OptionItemContent.d.ts +17 -0
  21. package/dist/renderer/hooks/useSubmitHandler.d.ts +2 -2
  22. package/dist/renderer/types/renderer.d.ts +5 -2
  23. package/dist/renderer/utils/http.d.ts +14 -5
  24. package/dist/renderer/utils/submit.d.ts +2 -2
  25. package/dist/renderer-native.js +1114 -1080
  26. package/dist/renderer.js +3 -3
  27. package/dist/shared/components/ui/item.d.ts +23 -0
  28. package/dist/shared/components/ui/popover.d.ts +7 -1
  29. package/dist/shared/context/PortalContainerContext.d.ts +5 -0
  30. package/dist/shared/types/node.d.ts +26 -26
  31. package/dist/shared/utils/httpRecord.d.ts +20 -0
  32. package/package.json +1 -1
  33. package/dist/DefaultInputs-nRQc9BHG.js +0 -1881
@@ -611,26 +611,27 @@ var M = [
611
611
  }, I = (...e) => {
612
612
  let t = /* @__PURE__ */ new Map();
613
613
  return e.forEach((e) => {
614
- e?.forEach((e) => {
615
- e.key && t.set(e.key.toLowerCase(), e);
614
+ e && Object.entries(e).forEach(([e, n]) => {
615
+ e && t.set(e.toLowerCase(), {
616
+ key: e,
617
+ value: n
618
+ });
616
619
  });
617
- }), Array.from(t.values());
618
- }, L = (e, t) => {
619
- if (!t?.length) return e;
620
- let n = t.filter((e) => e.key).map((e) => `${encodeURIComponent(e.key)}=${encodeURIComponent(e.value ?? "")}`).join("&");
621
- return n ? `${e}${e.includes("?") ? "&" : "?"}${n}` : e;
622
- }, R = (e, t) => !(t && e) || /^(https?:)?\/\//i.test(e) ? e : `${t.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}`, z = async (e) => {
620
+ }), Object.fromEntries(Array.from(t.values(), ({ key: e, value: t }) => [e, t]));
621
+ }, L = (e, t, n) => e && Object.fromEntries(Object.entries(e).map(([e, r]) => [e, V(r, t, n)])), R = (e, t) => {
622
+ let n = Object.entries(t ?? {}).filter(([e]) => e);
623
+ if (n.length === 0) return e;
624
+ let r = n.map(([e, t]) => `${encodeURIComponent(e)}=${encodeURIComponent(t ?? "")}`).join("&");
625
+ return r ? `${e}${e.includes("?") ? "&" : "?"}${r}` : e;
626
+ }, z = (e, t) => !(t && e) || /^(https?:)?\/\//i.test(e) ? e : `${t.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}`, B = async (e) => {
623
627
  try {
624
- let { url: t, method: n = "GET", headers: r = [], queryParams: i, body: a, signal: o } = e;
628
+ let { url: t, method: n = "GET", headers: r, queryParams: i, body: a, signal: o } = e;
625
629
  if (!t || t.trim() === "") return {
626
630
  error: "No URL provided",
627
631
  success: !1
628
632
  };
629
- let s = L(t, i), c = I([{
630
- key: "Content-Type",
631
- value: "application/json"
632
- }], r), l = {
633
- headers: Object.fromEntries(c.filter((e) => e.key && e.value).map((e) => [e.key, e.value])),
633
+ let s = R(t, i), c = I({ "Content-Type": "application/json" }, r), l = {
634
+ headers: Object.fromEntries(Object.entries(c).filter(([, e]) => e)),
634
635
  method: n,
635
636
  signal: o
636
637
  };
@@ -658,7 +659,7 @@ var M = [
658
659
  success: !1
659
660
  };
660
661
  }
661
- }, B = (e, t, n = {}) => {
662
+ }, V = (e, t, n = {}) => {
662
663
  if (!e) return "";
663
664
  let { encode: r = !1, json: i = !1 } = n;
664
665
  return e.replace(/\{\{([\w-]+)}}/g, (e, n) => {
@@ -673,14 +674,14 @@ var M = [
673
674
  }
674
675
  return String(o);
675
676
  });
676
- }, re = (e, t) => e ? e.replace(/\{\{response\.([\w.-]+)}}/g, (e, n) => {
677
- let r = V(t, n.trim());
677
+ }, H = (e, t) => e ? e.replace(/\{\{response\.([\w.-]+)}}/g, (e, n) => {
678
+ let r = re(t, n.trim());
678
679
  return r == null ? "" : String(r);
679
- }) : "", V = (e, t) => {
680
+ }) : "", re = (e, t) => {
680
681
  if (!(!e || typeof e != "object")) return t.split(".").reduce((e, t) => {
681
682
  if (!(typeof e != "object" || !e)) return e[t];
682
683
  }, e);
683
- }, H = (e, t) => t ? t.split(".").reduce((e, t) => {
684
+ }, U = (e, t) => t ? t.split(".").reduce((e, t) => {
684
685
  if (e == null) return;
685
686
  let n = t.match(/^(\w+)\[(\d+)]$/);
686
687
  if (n) {
@@ -689,25 +690,25 @@ var M = [
689
690
  }
690
691
  return e[t];
691
692
  }, e) : e, ie = (e, t, n) => {
692
- let r = H(e, t ?? "");
693
+ let r = U(e, t ?? "");
693
694
  return Array.isArray(r) ? r.map((e) => {
694
- let t = H(e, n.valueField), r = H(e, n.labelField);
695
+ let t = U(e, n.valueField), r = U(e, n.labelField);
695
696
  if (t == null) return null;
696
697
  let i = {
697
698
  label: { en: String(r ?? t) },
698
699
  value: String(t)
699
700
  };
700
701
  if (n.descriptionField) {
701
- let t = H(e, n.descriptionField);
702
+ let t = U(e, n.descriptionField);
702
703
  t != null && t !== "" && (i.description = { en: String(t) });
703
704
  }
704
705
  if (n.imageField) {
705
- let t = H(e, n.imageField);
706
+ let t = U(e, n.imageField);
706
707
  typeof t == "string" && t !== "" && (i.image = t);
707
708
  }
708
709
  return i;
709
710
  }).filter((e) => e !== null) : [];
710
- }, U = (e) => new Promise((t, n) => {
711
+ }, W = (e) => new Promise((t, n) => {
711
712
  let r = new FileReader();
712
713
  r.onload = () => {
713
714
  let n = r.result;
@@ -721,7 +722,7 @@ var M = [
721
722
  }, r.onerror = () => {
722
723
  n(/* @__PURE__ */ Error(`Failed to read file: ${e.name}`));
723
724
  }, r.readAsDataURL(e);
724
- }), ae = (e) => {
725
+ }), G = (e) => {
725
726
  let t = e.data.split(",")[1], n = atob(t), r = new ArrayBuffer(n.length), i = new Uint8Array(r);
726
727
  for (let e = 0; e < n.length; e++) i[e] = n.charCodeAt(e);
727
728
  let a = new Blob([r], { type: e.type });
@@ -729,13 +730,13 @@ var M = [
729
730
  lastModified: e.lastModified,
730
731
  type: e.type
731
732
  });
732
- }, W = (e) => Promise.all(e.map((e) => U(e))), G = new Set([
733
+ }, K = (e) => Promise.all(e.map((e) => W(e))), ae = new Set([
733
734
  "text",
734
735
  "number",
735
736
  "password",
736
737
  "textarea",
737
738
  "time"
738
- ]), oe = (e) => e.filter(d), K = (e) => {
739
+ ]), oe = (e) => e.filter(d), q = (e) => {
739
740
  if (e.data.name) return e.data.name;
740
741
  if (e.data.label) {
741
742
  if (e.data.label.en) return e.data.label.en;
@@ -743,16 +744,16 @@ var M = [
743
744
  if (t) return t;
744
745
  }
745
746
  return e.id;
746
- }, q = (e, t) => x(e.data.label, t) || e.data.name || e.id, J = (e, t) => {
747
+ }, J = (e, t) => x(e.data.label, t) || e.data.name || e.id, se = (e, t) => {
747
748
  let n = e.type ?? "text";
748
- return !e.placeholder?.[t] && G.has(n) ? w(t)["renderer.defaultInputs.newAnswer"] ?? "" : x(e.placeholder, t);
749
- }, Y = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, X = (e, t) => e ? t[e] != null : !1, se = (e, t) => {
749
+ return !e.placeholder?.[t] && ae.has(n) ? w(t)["renderer.defaultInputs.newAnswer"] ?? "" : x(e.placeholder, t);
750
+ }, Y = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, ce = (e, t) => e ? t[e] != null : !1, le = (e, t) => {
750
751
  let n = {};
751
752
  return t.forEach((t) => {
752
- let r = t.id, i = K(t);
753
+ let r = t.id, i = q(t);
753
754
  e[r] !== void 0 && (n[i] = e[r]);
754
755
  }), n;
755
- }, Z = (e, t, n) => {
756
+ }, X = (e, t, n) => {
756
757
  if (!t) return e;
757
758
  switch (t) {
758
759
  case "toString": return String(e);
@@ -787,7 +788,7 @@ var M = [
787
788
  return e;
788
789
  default: return e;
789
790
  }
790
- }, ce = (e, t) => {
791
+ }, ue = (e, t) => {
791
792
  if (Object.is(e, t)) return !0;
792
793
  if (!(e && t) || typeof e != "object" || typeof t != "object") return !1;
793
794
  try {
@@ -795,59 +796,53 @@ var M = [
795
796
  } catch {
796
797
  return !1;
797
798
  }
798
- }, le = (e, t, n) => {
799
+ }, de = (e, t, n) => {
799
800
  let r = {};
800
801
  return e.forEach((e) => {
801
802
  let { defaultValue: i } = e.data;
802
803
  if (!i || i.type !== "reference" || !i.referenceField) return;
803
804
  let a = e.id, { referenceField: o, transformFunction: s, objectMapping: c } = i, l = t[o], u = n[o];
804
805
  if (l === u || l == null) return;
805
- let d = Z(l, s, c), f = Z(u, s, c), p = t[a], m = ce(p, f), h = ce(p, d);
806
+ let d = X(l, s, c), f = X(u, s, c), p = t[a], m = ue(p, f), h = ue(p, d);
806
807
  !m || h || (r[a] = d);
807
808
  }), r;
808
- }, ue = t(void 0), de = () => r(ue), fe = ({ children: e, ...t }) => /* @__PURE__ */ l(ue.Provider, {
809
+ }, Z = t(void 0), fe = () => r(Z), pe = ({ children: e, ...t }) => /* @__PURE__ */ l(Z.Provider, {
809
810
  value: t,
810
811
  children: e
811
- }), pe = async (e, t, n, r, i) => {
812
+ }), me = async (e, t, n, r, i) => {
812
813
  if (!e.url || e.url.trim() === "") return {
813
814
  error: "No URL configured for submission",
814
815
  success: !1
815
816
  };
816
- let a = R(B(e.url, t, { encode: !0 }), i);
817
+ let a = z(V(e.url, t, { encode: !0 }), i);
817
818
  if (!a || a.trim() === "") return {
818
819
  error: "Invalid URL after template replacement",
819
820
  success: !1
820
821
  };
821
- let o = (e) => ({
822
- key: e.key,
823
- value: B(e.value, t)
824
- }), s = await z({
825
- body: e.sendAllFormValues ? JSON.stringify(se(t, n)) : e.body ? B(e.body, t, { json: !0 }) : void 0,
826
- headers: I(r?.map(o), e.headers?.map(o)),
822
+ let o = await B({
823
+ body: e.sendAllFormValues ? JSON.stringify(le(t, n)) : e.body ? V(e.body, t, { json: !0 }) : void 0,
824
+ headers: I(L(r, t), L(e.headers, t)),
827
825
  method: e.method || "POST",
828
- queryParams: e.queryParams?.map((e) => ({
829
- key: e.key,
830
- value: B(e.value, t)
831
- })),
826
+ queryParams: L(e.queryParams, t),
832
827
  url: a
833
828
  });
834
- if (!s.success) return {
835
- data: s.data,
836
- error: s.error,
829
+ if (!o.success) return {
830
+ data: o.data,
831
+ error: o.error,
837
832
  success: !1
838
833
  };
839
- let c = e.redirectUrl ? (() => {
840
- let t = re(e.redirectUrl, s.data);
834
+ let s = e.redirectUrl ? (() => {
835
+ let t = H(e.redirectUrl, o.data);
841
836
  return t && t.trim() !== "" ? t : void 0;
842
837
  })() : void 0;
843
838
  return {
844
- data: s.data,
845
- redirectUrl: c,
839
+ data: o.data,
840
+ redirectUrl: s,
846
841
  success: !0
847
842
  };
848
- }, me = (e) => {
843
+ }, he = (e) => {
849
844
  e && (e.startsWith("http://") || e.startsWith("https://") ? window.location.href = e : window.history?.pushState ? (window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e);
850
- }, he = (e, t, r, i, o, c) => {
845
+ }, ge = (e, t, r, i, o, c) => {
851
846
  let [l, u] = s(!1), [f, p] = s(null), m = a(() => {
852
847
  let t = e.find((e) => d(e) && e.data?.type === "submit");
853
848
  return t && d(t) ? t : null;
@@ -857,7 +852,7 @@ var M = [
857
852
  if (!n.url || n.url.trim() === "") return null;
858
853
  p(null), n.showLoading !== !1 && u(!0);
859
854
  try {
860
- let a = await pe(n, t, i, o, c);
855
+ let a = await me(n, t, i, o, c);
861
856
  if (a.success) {
862
857
  let t = x(n.successMessage, r);
863
858
  if (t && p({
@@ -865,7 +860,7 @@ var M = [
865
860
  type: "success"
866
861
  }), e && e(a.data), a.redirectUrl) {
867
862
  let e = a.redirectUrl;
868
- setTimeout(() => me(e), 1e3);
863
+ setTimeout(() => he(e), 1e3);
869
864
  }
870
865
  } else p({
871
866
  message: x(n.errorMessage, r) || a.error || "An error occurred during submission",
@@ -902,8 +897,8 @@ var M = [
902
897
  submitButtonNode: m,
903
898
  submitMessage: f
904
899
  };
905
- }, ge = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), Q = (e, t, n) => {
906
- let r = ge(e), i = ge(t);
900
+ }, _e = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), Q = (e, t, n) => {
901
+ let r = _e(e), i = _e(t);
907
902
  if (r === null || i === null) switch (n) {
908
903
  case "===": return r === i;
909
904
  case "!==": return r !== i;
@@ -945,7 +940,7 @@ var M = [
945
940
  e && d(e) && (o = t[e.id]);
946
941
  }
947
942
  return Array.isArray(o) ? i === "===" ? o.some((e) => Q(e, a, "===")) || Q(o, a, "===") : i === "!==" ? o.every((e) => Q(e, a, "!==")) && Q(o, a, "!==") : o.some((e) => Q(e, a, i)) : Q(o, a, i);
948
- }, _e = (e, t, n) => {
943
+ }, ve = (e, t, n) => {
949
944
  if (!e || e.length === 0) return !0;
950
945
  if (e.length === 1) return $(e[0], t, n);
951
946
  let r = $(e[0], t, n);
@@ -956,13 +951,13 @@ var M = [
956
951
  } else if (s === E.OR && (r ||= o, r)) return !0;
957
952
  }
958
953
  return r;
959
- }, ve = (e) => {
954
+ }, ye = (e) => {
960
955
  let t = /* @__PURE__ */ new Map();
961
956
  return e.forEach((e) => {
962
957
  let n = t.get(e.source);
963
958
  n ? n.push(e) : t.set(e.source, [e]);
964
959
  }), t;
965
- }, ye = (e, t, n) => {
960
+ }, be = (e, t, n) => {
966
961
  let r = [], i = [], a = [];
967
962
  e.forEach((e) => {
968
963
  let t = e.data?.isFallback, n = e.data?.conditions?.length;
@@ -978,13 +973,13 @@ var M = [
978
973
  return r ? r.every((e) => {
979
974
  if (!e.field) return !0;
980
975
  let r = n.get(e.field);
981
- return X(d(r) ? r.id : e.field, t);
976
+ return ce(d(r) ? r.id : e.field, t);
982
977
  }) : !1;
983
978
  })) return a.length > 0 && o.push(...a), {
984
979
  edgesToFollow: o,
985
980
  waitingForInput: o.length === 0
986
981
  };
987
- let s = i.filter((e) => _e(e.data?.conditions, t, n));
982
+ let s = i.filter((e) => ve(e.data?.conditions, t, n));
988
983
  return s.length > 0 ? (o.push(...s), {
989
984
  edgesToFollow: o,
990
985
  waitingForInput: !1
@@ -992,10 +987,10 @@ var M = [
992
987
  edgesToFollow: o,
993
988
  waitingForInput: !1
994
989
  });
995
- }, be = (e, t) => !t.some((t) => t.target === e), xe = (e, t) => {
996
- let n = e.filter((e) => be(e.id, t));
990
+ }, xe = (e, t) => !t.some((t) => t.target === e), Se = (e, t) => {
991
+ let n = e.filter((e) => xe(e.id, t));
997
992
  return n.find(d) || n[0];
998
- }, Se = (e, t, n, r) => {
993
+ }, Ce = (e, t, n, r) => {
999
994
  e.forEach((e) => {
1000
995
  let i = r.get(e);
1001
996
  if (!i) return;
@@ -1008,21 +1003,21 @@ var M = [
1008
1003
  a = r.get(a)?.parentId;
1009
1004
  }
1010
1005
  });
1011
- }, Ce = (e, t, n) => {
1012
- let r = xe(e, t);
1006
+ }, we = (e, t, n) => {
1007
+ let r = Se(e, t);
1013
1008
  if (!r) return {
1014
1009
  endOfPathReached: !0,
1015
1010
  visibleNodeIds: /* @__PURE__ */ new Set(),
1016
1011
  visibleNodes: [],
1017
1012
  visibleRootNodes: []
1018
1013
  };
1019
- let i = new Map(e.map((e) => [e.id, e])), a = ve(t), o = [], s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = !1, u = (e) => {
1014
+ let i = new Map(e.map((e) => [e.id, e])), a = ye(t), o = [], s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = !1, u = (e) => {
1020
1015
  if (c.has(e)) return;
1021
1016
  c.add(e);
1022
1017
  let t = i.get(e);
1023
1018
  if (!t) return;
1024
1019
  s.add(e), o.push(t);
1025
- let { edgesToFollow: r, waitingForInput: d } = ye(a.get(e) || [], n, i);
1020
+ let { edgesToFollow: r, waitingForInput: d } = be(a.get(e) || [], n, i);
1026
1021
  if (d) {
1027
1022
  l = !0;
1028
1023
  return;
@@ -1033,7 +1028,7 @@ var M = [
1033
1028
  };
1034
1029
  u(r.id);
1035
1030
  let d = new Map(o.map((e, t) => [e.id, t])), f = new Set(s);
1036
- Se(s, f, d, i);
1031
+ Ce(s, f, d, i);
1037
1032
  let p = e.filter((e) => f.has(e.id)).sort((e, t) => (d.get(e.id) ?? 2 ** 53 - 1) - (d.get(t.id) ?? 2 ** 53 - 1)), m = p.filter((e) => !(e.parentId && f.has(e.parentId)));
1038
1033
  return {
1039
1034
  endOfPathReached: !l,
@@ -1041,7 +1036,7 @@ var M = [
1041
1036
  visibleNodes: p,
1042
1037
  visibleRootNodes: m
1043
1038
  };
1044
- }, we = (e) => e.filter((e) => !p(e)).reduce((e, t) => {
1039
+ }, Te = (e) => e.filter((e) => !p(e)).reduce((e, t) => {
1045
1040
  let n = t.parentId ?? null, r = e.at(-1);
1046
1041
  return r && r.groupId === n ? [...e.slice(0, -1), {
1047
1042
  ...r,
@@ -1050,8 +1045,8 @@ var M = [
1050
1045
  groupId: n,
1051
1046
  nodes: [t]
1052
1047
  }];
1053
- }, []), Te = ({ baseUrl: e, components: t, flow: r, googleApiKey: c, headers: l, language: u, onChange: f, onSubmit: m, theme: h, validate: g, validationMode: _, initialValues: v = {} }) => {
1054
- let y = de(), b = a(() => ({
1048
+ }, []), Ee = ({ baseUrl: e, components: t, flow: r, googleApiKey: c, headers: l, language: u, onChange: f, onSubmit: m, theme: h, validate: g, validationMode: _, initialValues: v = {} }) => {
1049
+ let y = fe(), b = a(() => ({
1055
1050
  baseUrl: e ?? y?.baseUrl,
1056
1051
  components: {
1057
1052
  form: t?.form ?? y?.components?.form,
@@ -1096,16 +1091,16 @@ var M = [
1096
1091
  }
1097
1092
  }
1098
1093
  }), e;
1099
- }), { endOfPathReached: ee, visibleNodes: A, visibleRootNodes: j } = a(() => Ce(x, S, O), [
1094
+ }), { endOfPathReached: ee, visibleNodes: A, visibleRootNodes: j } = a(() => we(x, S, O), [
1100
1095
  x,
1101
1096
  S,
1102
1097
  O
1103
- ]), M = a(() => we(A), [A]), te = a(() => {
1098
+ ]), M = a(() => Te(A), [A]), te = a(() => {
1104
1099
  let e = /* @__PURE__ */ new Map();
1105
1100
  return x.forEach((t) => {
1106
1101
  p(t) && e.set(t.id, t);
1107
1102
  }), e;
1108
- }, [x]), [N, P] = s(0), F = M.length === 0 ? 0 : Math.min(N, M.length - 1), L = M[F], R = L?.groupId ? te.get(L.groupId) : void 0, z = F === 0, B = M.length === 0 || F >= M.length - 1, { clearSubmitMessage: re, handleSubmitWithConfig: V, hasSubmitConfig: H, isSubmitting: ie, submitMessage: U } = he(A, O, b.language, C, b.headers, b.baseUrl), ae = o(f), W = o(g), G = a(() => se(O, C), [O, C]), K = n((e, t) => {
1103
+ }, [x]), [N, P] = s(0), F = M.length === 0 ? 0 : Math.min(N, M.length - 1), L = M[F], R = L?.groupId ? te.get(L.groupId) : void 0, z = F === 0, B = M.length === 0 || F >= M.length - 1, { clearSubmitMessage: V, handleSubmitWithConfig: H, hasSubmitConfig: re, isSubmitting: U, submitMessage: ie } = ge(A, O, b.language, C, b.headers, b.baseUrl), W = o(f), G = o(g), K = a(() => le(O, C), [O, C]), ae = n((e, t) => {
1109
1104
  k((n) => ({
1110
1105
  ...n,
1111
1106
  [e]: t
@@ -1152,27 +1147,27 @@ var M = [
1152
1147
  A,
1153
1148
  O,
1154
1149
  w
1155
- ]), X = n(() => {
1150
+ ]), se = n(() => {
1156
1151
  P((e) => e >= M.length - 1 ? e : e + 1);
1157
- }, [M.length]), Z = n(() => {
1152
+ }, [M.length]), ce = n(() => {
1158
1153
  P((e) => Math.max(0, e - 1));
1159
- }, []), ce = n(async () => {
1160
- let { isValid: e } = J(W.current);
1154
+ }, []), X = n(async () => {
1155
+ let { isValid: e } = J(G.current);
1161
1156
  if (!e) return !1;
1162
- if (H) {
1163
- let e = await V((e) => {
1164
- m && m(G, { httpResponse: e });
1157
+ if (re) {
1158
+ let e = await H((e) => {
1159
+ m && m(K, { httpResponse: e });
1165
1160
  });
1166
- if (e === null) return m?.(G), !0;
1161
+ if (e === null) return m?.(K), !0;
1167
1162
  if (!e.success) return !0;
1168
- } else m && m(G);
1163
+ } else m && m(K);
1169
1164
  return !0;
1170
1165
  }, [
1171
1166
  J,
1167
+ re,
1172
1168
  H,
1173
- V,
1174
1169
  m,
1175
- G
1170
+ K
1176
1171
  ]), ue = a(() => {
1177
1172
  let e = [];
1178
1173
  return A.forEach((t) => {
@@ -1187,7 +1182,7 @@ var M = [
1187
1182
  A,
1188
1183
  O,
1189
1184
  w
1190
- ]), fe = a(() => A.some((e) => d(e) && e.data.type === "submit"), [A]), pe = a(() => L ? L.nodes.every((e) => !d(e) || !e.data.required || e.data.type === "submit" ? !0 : !Y(O[e.id])) : !1, [L, O]), me = a(() => {
1185
+ ]), Z = a(() => A.some((e) => d(e) && e.data.type === "submit"), [A]), pe = a(() => L ? L.nodes.every((e) => !d(e) || !e.data.required || e.data.type === "submit" ? !0 : !Y(O[e.id])) : !1, [L, O]), me = a(() => {
1191
1186
  let e = Object.keys(E);
1192
1187
  return e.length > 0 ? e[0] : void 0;
1193
1188
  }, [E]);
@@ -1198,15 +1193,15 @@ var M = [
1198
1193
  }
1199
1194
  N > M.length - 1 && P(M.length - 1);
1200
1195
  }, [M.length, N]), i(() => {
1201
- ae.current = f;
1196
+ W.current = f;
1202
1197
  }, [f]), i(() => {
1203
- W.current = g;
1198
+ G.current = g;
1204
1199
  }, [g]), i(() => {
1205
- ae.current?.(G);
1206
- }, [G]), i(() => {
1207
- b.validationMode === "onChange" && J(W.current);
1200
+ W.current?.(K);
1201
+ }, [K]), i(() => {
1202
+ b.validationMode === "onChange" && J(G.current);
1208
1203
  }, [b.validationMode, J]), i(() => {
1209
- let e = le(C, O, T.current);
1204
+ let e = de(C, O, T.current);
1210
1205
  Object.keys(e).length > 0 && q(e), T.current = O;
1211
1206
  }, [
1212
1207
  O,
@@ -1214,8 +1209,8 @@ var M = [
1214
1209
  q
1215
1210
  ]), {
1216
1211
  canContinueStep: pe,
1217
- canSubmit: !fe && ee && x.length > 0,
1218
- clearSubmitMessage: re,
1212
+ canSubmit: !Z && ee && x.length > 0,
1213
+ clearSubmitMessage: V,
1219
1214
  config: b,
1220
1215
  currentStep: L,
1221
1216
  currentStepGroupNode: R,
@@ -1223,42 +1218,42 @@ var M = [
1223
1218
  firstErrorFieldId: me,
1224
1219
  formErrors: E,
1225
1220
  formValues: O,
1226
- goToNextStep: X,
1227
- goToPreviousStep: Z,
1228
- handleSubmit: ce,
1229
- hasSubmitInput: fe,
1221
+ goToNextStep: se,
1222
+ goToPreviousStep: ce,
1223
+ handleSubmit: X,
1224
+ hasSubmitInput: Z,
1230
1225
  inputNodes: C,
1231
1226
  isFirstStep: z,
1232
1227
  isLastStep: B,
1233
- isSubmitting: ie,
1228
+ isSubmitting: U,
1234
1229
  missingRequiredFields: ue,
1235
1230
  prevFormValuesRef: T,
1236
1231
  setFieldErrors: D,
1237
- setFieldValue: K,
1232
+ setFieldValue: ae,
1238
1233
  setMultipleFieldValues: q,
1239
1234
  steps: M,
1240
- submitMessage: U,
1235
+ submitMessage: ie,
1241
1236
  t: w,
1242
1237
  validateForm: J,
1243
1238
  visibleNodes: A,
1244
1239
  visibleRootNodes: j
1245
1240
  };
1246
- }, Ee = /\{\{([\w-]+)}}/g, De = (e) => e == null || e === "", Oe = (...e) => {
1241
+ }, De = /\{\{([\w-]+)}}/g, Oe = (e) => e == null || e === "", ke = (...e) => {
1247
1242
  let t = [];
1248
- for (let n of e) if (n) for (let e of n.matchAll(Ee)) t.includes(e[1]) || t.push(e[1]);
1243
+ for (let n of e) if (n) for (let e of n.matchAll(De)) t.includes(e[1]) || t.push(e[1]);
1249
1244
  return t;
1250
- }, ke = (e) => {
1245
+ }, Ae = (e) => {
1251
1246
  let t = e.data.httpConfig ?? e.data.optionsSource;
1252
1247
  if (!t) return [];
1253
- let n = t.queryParams?.map((e) => e.value) ?? [];
1254
- return Oe(t.url, t.body, ...n);
1255
- }, Ae = (e, t, n, r) => ke(e).filter((e) => De(t[e])).map((e) => {
1248
+ let n = Object.values(t.queryParams ?? {});
1249
+ return ke(t.url, t.body, ...n);
1250
+ }, je = (e, t, n, r) => Ae(e).filter((e) => Oe(t[e])).map((e) => {
1256
1251
  let t = n.find((t) => t.id === e);
1257
1252
  return {
1258
1253
  id: e,
1259
- label: t ? q(t, r) : e
1254
+ label: t ? J(t, r) : e
1260
1255
  };
1261
- }), je = ({ DefaultFormWrapper: t, DefaultInputWrapper: r, DefaultSubmitButton: i, DefaultSubmitButtonWrapper: o, config: s, defaultInputRenderers: c, defaultUI: u, formErrors: p, formValues: m, inputNodes: h, missingRequiredFields: g, setFieldValue: _ }) => {
1256
+ }), Me = ({ DefaultFormWrapper: t, DefaultInputWrapper: r, DefaultSubmitButton: i, DefaultSubmitButtonWrapper: o, config: s, defaultInputRenderers: c, defaultUI: u, formErrors: p, formValues: m, inputNodes: h, missingRequiredFields: g, setFieldValue: _ }) => {
1262
1257
  let v = a(() => s.components.form || t, [s.components.form, t]), y = a(() => s.components.submitButton || i, [s.components.submitButton, i]), b = a(() => s.components.submitButtonWrapper || o || e, [s.components.submitButtonWrapper, o]);
1263
1258
  return {
1264
1259
  FormWrapper: v,
@@ -1267,7 +1262,7 @@ var M = [
1267
1262
  switch (t) {
1268
1263
  case D.input: {
1269
1264
  if (!d(e)) return null;
1270
- let t = e.data, n = t.type || "text", i = s.components.inputs?.[n], a = c[n], o = i || a, u = e.id, f = (e) => _(u, e), v = m[u], y = p[u], b = x(t.label, s.language), S = J(t, s.language), C = x(t.helperText, s.language), w = K(e), T = N(b), E = N(S), D = N(C);
1265
+ let t = e.data, n = t.type || "text", i = s.components.inputs?.[n], a = c[n], o = i || a, u = e.id, f = (e) => _(u, e), v = m[u], y = p[u], b = x(t.label, s.language), S = se(t, s.language), C = x(t.helperText, s.language), w = q(e), T = N(b), E = N(S), D = N(C);
1271
1266
  return o ? /* @__PURE__ */ l(r, {
1272
1267
  node: e,
1273
1268
  children: /* @__PURE__ */ l(j, {
@@ -1284,7 +1279,7 @@ var M = [
1284
1279
  error: y,
1285
1280
  helperText: D,
1286
1281
  label: T,
1287
- missingDependencies: Ae(e, m, h, s.language),
1282
+ missingDependencies: je(e, m, h, s.language),
1288
1283
  missingRequiredFields: g,
1289
1284
  node: e,
1290
1285
  setValue: f
@@ -1314,7 +1309,7 @@ var M = [
1314
1309
  SubmitButton: y,
1315
1310
  SubmitButtonWrapper: b
1316
1311
  };
1317
- }, Me = {
1312
+ }, Ne = {
1318
1313
  dark: {
1319
1314
  background: "#0A0A0A",
1320
1315
  border: "#262626",
@@ -1357,12 +1352,12 @@ var M = [
1357
1352
  textMuted: "#737373",
1358
1353
  textSecondary: "#525252"
1359
1354
  }
1360
- }, Ne = t({
1361
- colors: Me.light,
1355
+ }, Pe = t({
1356
+ colors: Ne.light,
1362
1357
  setTheme: () => null,
1363
1358
  theme: "system"
1364
- }), Pe = ({ children: e, defaultTheme: t = "system", storageKey: n = "treege-theme", theme: r, ...o }) => {
1365
- let [c, u] = s(() => r || typeof window < "u" && localStorage.getItem(n) || t), d = r ?? c, f = Me[d === "system" ? typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : d], p = a(() => ({
1359
+ }), Fe = ({ children: e, defaultTheme: t = "system", storageKey: n = "treege-theme", theme: r, ...o }) => {
1360
+ let [c, u] = s(() => r || typeof window < "u" && localStorage.getItem(n) || t), d = r ?? c, f = Ne[d === "system" ? typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : d], p = a(() => ({
1366
1361
  colors: f,
1367
1362
  setTheme: (e) => {
1368
1363
  !r && typeof window < "u" && localStorage.setItem(n, e), u(e);
@@ -1388,15 +1383,15 @@ var M = [
1388
1383
  return t.addEventListener("change", r), () => t.removeEventListener("change", r);
1389
1384
  }
1390
1385
  e.classList.add(d);
1391
- }, [d]), /* @__PURE__ */ l(Ne.Provider, {
1386
+ }, [d]), /* @__PURE__ */ l(Pe.Provider, {
1392
1387
  ...o,
1393
1388
  value: p,
1394
1389
  children: e
1395
1390
  });
1396
- }, Fe = () => {
1397
- let e = r(Ne);
1391
+ }, Ie = () => {
1392
+ let e = r(Pe);
1398
1393
  if (e === void 0) throw Error("useTheme must be used within a ThemeProvider");
1399
1394
  return e;
1400
1395
  };
1401
1396
  //#endregion
1402
- export { N as A, p as B, ie as C, B as D, I as E, D as F, f as H, E as I, T as L, j as M, ee as N, R as O, A as P, w as R, L as S, z as T, d as V, J as _, xe as a, W as b, $ as c, de as d, Z as f, Y as g, se as h, Te as i, F as j, ne as k, _e as l, X as m, Fe as n, Ce as o, le as p, je as r, be as s, Pe as t, fe as u, K as v, H as w, ae as x, U as y, x as z };
1397
+ export { ne as A, x as B, ie as C, V as D, I as E, A as F, d as H, D as I, E as L, F as M, j as N, L as O, ee as P, T as R, R as S, B as T, f as U, p as V, se as _, Se as a, K as b, $ as c, fe as d, X as f, Y as g, le as h, Ee as i, N as j, z as k, ve as l, ce as m, Ie as n, we as o, de as p, Me as r, xe as s, Fe as t, pe as u, q as v, U as w, G as x, W as y, w as z };
@@ -1,6 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { AIConfig } from '../types/ai';
3
- import { HttpHeader } from '../../shared/types/node';
3
+ import { HttpHeaders } from '../../shared/types/node';
4
4
  export interface TreegeEditorRuntimeContextValue {
5
5
  /**
6
6
  * Current language of the editor UI. Also used as the default language for
@@ -22,7 +22,7 @@ export interface TreegeEditorRuntimeContextValue {
22
22
  * "Detect fields" button). Forwarded by the consumer; same shape and
23
23
  * semantics as `TreegeRenderer`'s `headers`.
24
24
  */
25
- headers?: HttpHeader[];
25
+ headers?: HttpHeaders;
26
26
  /**
27
27
  * Function to set the current flow ID
28
28
  * @param flow
@@ -1,3 +1,3 @@
1
1
  import { TreegeEditorProps } from '../../types/editor';
2
- declare const TreegeEditor: ({ flow, onExportJson, onSave, theme, language: controlledLanguage, defaultLanguage, onLanguageChange, aiConfig, extraMenuItems, openApi, baseUrl, openApiBaseUrl, onAuthorize, headers, onHeadersChange, }: TreegeEditorProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TreegeEditor: ({ flow, onExportJson, onSave, onLanguageChange, aiConfig, extraMenuItems, openApi, baseUrl, onAuthorize, headers, onHeadersChange, language: controlledLanguage, theme, defaultLanguage, }: TreegeEditorProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TreegeEditor;
@@ -1,14 +1,14 @@
1
- import { HttpHeader } from '../../../../shared/types/node';
1
+ import { HttpHeaders } from '../../../../shared/types/node';
2
2
  interface AuthorizeDialogProps {
3
3
  open: boolean;
4
4
  onOpenChange: (open: boolean) => void;
5
- onAuthorize?: (headers: HttpHeader[]) => void;
5
+ onAuthorize?: (headers: HttpHeaders) => void;
6
6
  }
7
7
  /**
8
8
  * Reads supported security schemes from the loaded OpenAPI document and
9
9
  * collects credentials from the user (Bearer token, API key value, or
10
10
  * OAuth2 password grant). On submit, exchanges OAuth2 credentials at the
11
- * token endpoint, builds the resulting `HttpHeader[]`, and calls
11
+ * token endpoint, builds the resulting `HttpHeaders`, and calls
12
12
  * `onAuthorize` so the consumer can forward them to the renderer's
13
13
  * global `headers`.
14
14
  *
@@ -1,9 +1,9 @@
1
- import { HttpHeader } from '../../../../shared/types/node';
1
+ import { HttpHeaders } from '../../../../shared/types/node';
2
2
  interface HeadersDialogProps {
3
3
  open: boolean;
4
4
  onOpenChange: (open: boolean) => void;
5
- headers: HttpHeader[];
6
- onChange: (headers: HttpHeader[]) => void;
5
+ headers: HttpHeaders;
6
+ onChange: (headers: HttpHeaders) => void;
7
7
  }
8
8
  /**
9
9
  * Edit the editor's "global headers" — forwarded to every HTTP request the
@@ -1,10 +1,10 @@
1
- import { HttpHeader, OptionsSourceMapping, QueryParam } from '../../../../shared/types/node';
1
+ import { HttpHeaders, OptionsSourceMapping, QueryParams } from '../../../../shared/types/node';
2
2
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
3
3
  export interface OptionsMappingRequest {
4
4
  url?: string;
5
5
  method?: HttpMethod;
6
- headers?: HttpHeader[];
7
- queryParams?: QueryParam[];
6
+ headers?: HttpHeaders;
7
+ queryParams?: QueryParams;
8
8
  body?: string;
9
9
  responsePath?: string;
10
10
  }