@codee-sh/medusa-plugin-notification-emails 0.0.1 → 0.1.0

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 (56) hide show
  1. package/.medusa/server/emails-previews/contact-form.js +5 -7
  2. package/.medusa/server/emails-previews/inventory-level.js +23 -0
  3. package/.medusa/server/emails-previews/order-completed.js +20 -14
  4. package/.medusa/server/emails-previews/order-placed.js +19 -13
  5. package/.medusa/server/src/admin/index.js +392 -2528
  6. package/.medusa/server/src/admin/index.mjs +314 -2450
  7. package/.medusa/server/src/api/admin/notification-plugin/render-template/route.js +2 -2
  8. package/.medusa/server/src/hooks/api/orders.js +3 -2
  9. package/.medusa/server/src/templates/emails/base-template/index.js +23 -0
  10. package/.medusa/server/src/templates/emails/base-template/template.js +25 -0
  11. package/.medusa/server/src/templates/emails/blocks/components/heading.js +15 -0
  12. package/.medusa/server/src/templates/emails/blocks/components/product-item.js +14 -0
  13. package/.medusa/server/src/templates/emails/blocks/components/repeater.js +26 -0
  14. package/.medusa/server/src/templates/emails/blocks/components/row.js +13 -0
  15. package/.medusa/server/src/templates/emails/blocks/components/section.js +14 -0
  16. package/.medusa/server/src/templates/emails/blocks/components/separator.js +13 -0
  17. package/.medusa/server/src/templates/emails/blocks/components/text.js +15 -0
  18. package/.medusa/server/src/templates/emails/blocks/index.js +41 -0
  19. package/.medusa/server/src/templates/{shared/i18n → emails/blocks}/types.js +1 -1
  20. package/.medusa/server/src/templates/emails/contact-form/config.js +95 -0
  21. package/.medusa/server/src/templates/emails/contact-form/index.js +6 -17
  22. package/.medusa/server/src/templates/emails/contact-form/translations/de.json +14 -0
  23. package/.medusa/server/src/templates/emails/contact-form/translations/en.json +12 -14
  24. package/.medusa/server/src/templates/emails/contact-form/translations/pl.json +8 -10
  25. package/.medusa/server/src/templates/emails/index.js +191 -45
  26. package/.medusa/server/src/templates/emails/inventory-level/config.js +126 -0
  27. package/.medusa/server/src/templates/emails/inventory-level/index.js +8 -0
  28. package/.medusa/server/src/templates/emails/inventory-level/translations/en.json +12 -0
  29. package/.medusa/server/src/templates/emails/{contact-form → inventory-level}/translations/index.js +1 -1
  30. package/.medusa/server/src/templates/emails/inventory-level/translations/pl.json +14 -0
  31. package/.medusa/server/src/templates/emails/order-completed/config.js +233 -0
  32. package/.medusa/server/src/templates/emails/order-completed/index.js +6 -17
  33. package/.medusa/server/src/templates/emails/order-completed/translations/en.json +2 -1
  34. package/.medusa/server/src/templates/emails/order-completed/translations/pl.json +2 -1
  35. package/.medusa/server/src/templates/emails/order-placed/config.js +221 -0
  36. package/.medusa/server/src/templates/emails/order-placed/index.js +6 -17
  37. package/.medusa/server/src/templates/emails/order-placed/translations/en.json +1 -1
  38. package/.medusa/server/src/templates/emails/order-placed/translations/pl.json +1 -1
  39. package/.medusa/server/src/templates/emails/types.js +3 -1
  40. package/.medusa/server/src/utils/i18n/i18n.js +194 -0
  41. package/.medusa/server/src/utils/i18n/index.js +18 -0
  42. package/.medusa/server/src/utils/index.js +5 -1
  43. package/.medusa/server/src/utils/is-defined.js +7 -0
  44. package/.medusa/server/src/utils/is-object.js +7 -0
  45. package/.medusa/server/src/utils/pick-value-from-object.js +28 -0
  46. package/README.md +8 -8
  47. package/package.json +18 -11
  48. package/.medusa/server/src/templates/emails/contact-form/template.js +0 -28
  49. package/.medusa/server/src/templates/emails/contact-form/types.js +0 -3
  50. package/.medusa/server/src/templates/emails/order-completed/template.js +0 -36
  51. package/.medusa/server/src/templates/emails/order-completed/types.js +0 -3
  52. package/.medusa/server/src/templates/emails/order-placed/template.js +0 -36
  53. package/.medusa/server/src/templates/emails/order-placed/types.js +0 -3
  54. package/.medusa/server/src/templates/shared/i18n/index.js +0 -6
  55. package/.medusa/server/src/templates/shared/i18n/languages.js +0 -187
  56. package/.medusa/server/src/templates/shared/i18n/utils.js +0 -186
@@ -5,11 +5,11 @@ const ui = require("@medusajs/ui");
5
5
  const reactI18next = require("react-i18next");
6
6
  const reactQuery = require("@tanstack/react-query");
7
7
  const Medusa = require("@medusajs/js-sdk");
8
- const React = require("react");
8
+ const react = require("react");
9
9
  const icons = require("@medusajs/icons");
10
10
  const reactRouterDom = require("react-router-dom");
11
- require("@react-email/components");
12
- require("@react-email/render");
11
+ const components = require("@react-email/components");
12
+ const render = require("@react-email/render");
13
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
14
  const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
15
15
  const sdk = new Medusa__default.default({
@@ -54,7 +54,7 @@ const Actions$1 = ({ onSend, isPending, isError, eventsData }) => {
54
54
  ] });
55
55
  };
56
56
  const SelectAction$1 = ({ onSend, isPending }) => {
57
- const [selectedEvent, setSelectedEvent] = React.useState("order.placed");
57
+ const [selectedEvent, setSelectedEvent] = react.useState("order.placed");
58
58
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
59
59
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2", children: [
60
60
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "flex-shrink-0", children: "Select event:" }),
@@ -100,7 +100,7 @@ const Actions = ({ onSend, isPending, isError, eventsData }) => {
100
100
  ] });
101
101
  };
102
102
  const SelectAction = ({ onSend, isPending }) => {
103
- const [selectedEvent, setSelectedEvent] = React.useState("payment.captured");
103
+ const [selectedEvent, setSelectedEvent] = react.useState("payment.captured");
104
104
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
105
105
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2", children: [
106
106
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "flex-shrink-0", children: "Select event:" }),
@@ -182,12 +182,12 @@ const useListNotifications = (params, options) => {
182
182
  return { data, ...rest };
183
183
  };
184
184
  const NotificationsList = ({ entityId, entityType }) => {
185
- const [pagination, setPagination] = React.useState({
185
+ const [pagination, setPagination] = react.useState({
186
186
  pageSize: 8,
187
187
  pageIndex: 0
188
188
  });
189
189
  const limit = 8;
190
- const offset = React.useMemo(() => {
190
+ const offset = react.useMemo(() => {
191
191
  return pagination.pageIndex * limit;
192
192
  }, [pagination]);
193
193
  const { data: notificationsData, isLoading: isNotificationsLoading } = useListNotifications({
@@ -307,19 +307,19 @@ function _objectWithoutPropertiesLoose(r, e) {
307
307
  return t;
308
308
  }
309
309
  var initialState$5 = {};
310
- var Context$5 = /* @__PURE__ */ React.createContext(initialState$5);
310
+ var Context$5 = /* @__PURE__ */ react.createContext(initialState$5);
311
311
  var reducer$5 = (state, action) => _extends({}, state, action);
312
312
  var useShowToolsStore = () => {
313
- return React.useContext(Context$5);
313
+ return react.useContext(Context$5);
314
314
  };
315
- var DispatchShowTools = /* @__PURE__ */ React.createContext(() => {
315
+ var DispatchShowTools = /* @__PURE__ */ react.createContext(() => {
316
316
  });
317
317
  DispatchShowTools.displayName = "JVR.DispatchShowTools";
318
318
  function useShowTools() {
319
- return React.useReducer(reducer$5, initialState$5);
319
+ return react.useReducer(reducer$5, initialState$5);
320
320
  }
321
321
  function useShowToolsDispatch() {
322
- return React.useContext(DispatchShowTools);
322
+ return react.useContext(DispatchShowTools);
323
323
  }
324
324
  var ShowTools = (_ref) => {
325
325
  var {
@@ -337,19 +337,19 @@ var ShowTools = (_ref) => {
337
337
  };
338
338
  ShowTools.displayName = "JVR.ShowTools";
339
339
  var initialState$4 = {};
340
- var Context$4 = /* @__PURE__ */ React.createContext(initialState$4);
340
+ var Context$4 = /* @__PURE__ */ react.createContext(initialState$4);
341
341
  var reducer$4 = (state, action) => _extends({}, state, action);
342
342
  var useExpandsStore = () => {
343
- return React.useContext(Context$4);
343
+ return react.useContext(Context$4);
344
344
  };
345
- var DispatchExpands = /* @__PURE__ */ React.createContext(() => {
345
+ var DispatchExpands = /* @__PURE__ */ react.createContext(() => {
346
346
  });
347
347
  DispatchExpands.displayName = "JVR.DispatchExpands";
348
348
  function useExpands() {
349
- return React.useReducer(reducer$4, initialState$4);
349
+ return react.useReducer(reducer$4, initialState$4);
350
350
  }
351
351
  function useExpandsDispatch() {
352
- return React.useContext(DispatchExpands);
352
+ return react.useContext(DispatchExpands);
353
353
  }
354
354
  var Expands = (_ref) => {
355
355
  var {
@@ -487,19 +487,19 @@ var initialState$3 = {
487
487
  children: "date"
488
488
  }
489
489
  };
490
- var Context$3 = /* @__PURE__ */ React.createContext(initialState$3);
490
+ var Context$3 = /* @__PURE__ */ react.createContext(initialState$3);
491
491
  var reducer$3 = (state, action) => _extends({}, state, action);
492
492
  var useTypesStore = () => {
493
- return React.useContext(Context$3);
493
+ return react.useContext(Context$3);
494
494
  };
495
- var DispatchTypes = /* @__PURE__ */ React.createContext(() => {
495
+ var DispatchTypes = /* @__PURE__ */ react.createContext(() => {
496
496
  });
497
497
  DispatchTypes.displayName = "JVR.DispatchTypes";
498
498
  function useTypes() {
499
- return React.useReducer(reducer$3, initialState$3);
499
+ return react.useReducer(reducer$3, initialState$3);
500
500
  }
501
501
  function useTypesDispatch() {
502
- return React.useContext(DispatchTypes);
502
+ return react.useContext(DispatchTypes);
503
503
  }
504
504
  function Types(_ref) {
505
505
  var {
@@ -608,19 +608,19 @@ var initialState$2 = {
608
608
  children: "}"
609
609
  }
610
610
  };
611
- var Context$2 = /* @__PURE__ */ React.createContext(initialState$2);
611
+ var Context$2 = /* @__PURE__ */ react.createContext(initialState$2);
612
612
  var reducer$2 = (state, action) => _extends({}, state, action);
613
613
  var useSymbolsStore = () => {
614
- return React.useContext(Context$2);
614
+ return react.useContext(Context$2);
615
615
  };
616
- var DispatchSymbols = /* @__PURE__ */ React.createContext(() => {
616
+ var DispatchSymbols = /* @__PURE__ */ react.createContext(() => {
617
617
  });
618
618
  DispatchSymbols.displayName = "JVR.DispatchSymbols";
619
619
  function useSymbols() {
620
- return React.useReducer(reducer$2, initialState$2);
620
+ return react.useReducer(reducer$2, initialState$2);
621
621
  }
622
622
  function useSymbolsDispatch() {
623
- return React.useContext(DispatchSymbols);
623
+ return react.useContext(DispatchSymbols);
624
624
  }
625
625
  var Symbols = (_ref) => {
626
626
  var {
@@ -683,19 +683,19 @@ var initialState$1 = {
683
683
  className: "w-rjv-object-key"
684
684
  }
685
685
  };
686
- var Context$1 = /* @__PURE__ */ React.createContext(initialState$1);
686
+ var Context$1 = /* @__PURE__ */ react.createContext(initialState$1);
687
687
  var reducer$1 = (state, action) => _extends({}, state, action);
688
688
  var useSectionStore = () => {
689
- return React.useContext(Context$1);
689
+ return react.useContext(Context$1);
690
690
  };
691
- var DispatchSection = /* @__PURE__ */ React.createContext(() => {
691
+ var DispatchSection = /* @__PURE__ */ react.createContext(() => {
692
692
  });
693
693
  DispatchSection.displayName = "JVR.DispatchSection";
694
694
  function useSection() {
695
- return React.useReducer(reducer$1, initialState$1);
695
+ return react.useReducer(reducer$1, initialState$1);
696
696
  }
697
697
  function useSectionDispatch() {
698
- return React.useContext(DispatchSection);
698
+ return react.useContext(DispatchSection);
699
699
  }
700
700
  var Section = (_ref) => {
701
701
  var {
@@ -716,16 +716,16 @@ var initialState = {
716
716
  objectSortKeys: false,
717
717
  indentWidth: 15
718
718
  };
719
- var Context = /* @__PURE__ */ React.createContext(initialState);
719
+ var Context = /* @__PURE__ */ react.createContext(initialState);
720
720
  Context.displayName = "JVR.Context";
721
- var DispatchContext = /* @__PURE__ */ React.createContext(() => {
721
+ var DispatchContext = /* @__PURE__ */ react.createContext(() => {
722
722
  });
723
723
  DispatchContext.displayName = "JVR.DispatchContext";
724
724
  function reducer(state, action) {
725
725
  return _extends({}, state, action);
726
726
  }
727
727
  var useStore = () => {
728
- return React.useContext(Context);
728
+ return react.useContext(Context);
729
729
  };
730
730
  var Provider = (_ref) => {
731
731
  var {
@@ -733,13 +733,13 @@ var Provider = (_ref) => {
733
733
  initialState: init,
734
734
  initialTypes
735
735
  } = _ref;
736
- var [state, dispatch] = React.useReducer(reducer, Object.assign({}, initialState, init));
736
+ var [state, dispatch] = react.useReducer(reducer, Object.assign({}, initialState, init));
737
737
  var [showTools, showToolsDispatch] = useShowTools();
738
738
  var [expands, expandsDispatch] = useExpands();
739
739
  var [types, typesDispatch] = useTypes();
740
740
  var [symbols, symbolsDispatch] = useSymbols();
741
741
  var [section, sectionDispatch] = useSection();
742
- React.useEffect(() => dispatch(_extends({}, init)), [init]);
742
+ react.useEffect(() => dispatch(_extends({}, init)), [init]);
743
743
  return /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, {
744
744
  value: state,
745
745
  children: /* @__PURE__ */ jsxRuntime.jsx(DispatchContext.Provider, {
@@ -787,7 +787,7 @@ var Quote$1 = (props) => {
787
787
  if (isNumber) return null;
788
788
  var {
789
789
  as,
790
- render
790
+ render: render2
791
791
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$5);
792
792
  var Elm = as || "span";
793
793
  var elmProps = _extends({}, other, reset);
@@ -797,7 +797,7 @@ var Quote$1 = (props) => {
797
797
  keyName,
798
798
  keys: keys || (keyName ? [keyName] : [])
799
799
  };
800
- var child = render && typeof render === "function" && render(elmProps, result);
800
+ var child = render2 && typeof render2 === "function" && render2(elmProps, result);
801
801
  if (child) return child;
802
802
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, elmProps));
803
803
  };
@@ -809,11 +809,11 @@ var ValueQuote$1 = (props) => {
809
809
  var other = _extends({}, (_objectDestructuringEmpty(props), props));
810
810
  var {
811
811
  as,
812
- render
812
+ render: render2
813
813
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded3$1);
814
814
  var Elm = as || "span";
815
815
  var elmProps = _extends({}, other, reset);
816
- var child = render && typeof render === "function" && render(elmProps, {});
816
+ var child = render2 && typeof render2 === "function" && render2(elmProps, {});
817
817
  if (child) return child;
818
818
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, elmProps));
819
819
  };
@@ -830,10 +830,10 @@ var Colon$1 = (props) => {
830
830
  } = useSymbolsStore();
831
831
  var {
832
832
  as,
833
- render
833
+ render: render2
834
834
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded4$1);
835
835
  var Elm = as || "span";
836
- var child = render && typeof render === "function" && render(reset, {
836
+ var child = render2 && typeof render2 === "function" && render2(reset, {
837
837
  value,
838
838
  parentValue,
839
839
  keyName,
@@ -860,10 +860,10 @@ var Arrow$1 = (props) => {
860
860
  var {
861
861
  as,
862
862
  style,
863
- render
863
+ render: render2
864
864
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded5$1);
865
865
  var Elm = as || "span";
866
- var isRender = render && typeof render === "function";
866
+ var isRender = render2 && typeof render2 === "function";
867
867
  var elmProps = _extends({}, reset, {
868
868
  "data-expanded": isExpanded,
869
869
  style: _extends({}, style, resetStyle)
@@ -874,7 +874,7 @@ var Arrow$1 = (props) => {
874
874
  keyName,
875
875
  keys: keys || (keyName ? [keyName] : [])
876
876
  };
877
- var child = isRender && render(elmProps, result);
877
+ var child = isRender && render2(elmProps, result);
878
878
  if (child) return child;
879
879
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, reset, {
880
880
  style: _extends({}, style, resetStyle)
@@ -911,10 +911,10 @@ var BracketsOpen = (props) => {
911
911
  }
912
912
  var {
913
913
  as: elm,
914
- render
914
+ render: render2
915
915
  } = BraceLeft2, resetProps = _objectWithoutPropertiesLoose(BraceLeft2, _excluded7$1);
916
916
  var BraceLeftComp = elm || "span";
917
- var child = render && typeof render === "function" && render(resetProps, result);
917
+ var child = render2 && typeof render2 === "function" && render2(resetProps, result);
918
918
  if (child) return child;
919
919
  return /* @__PURE__ */ jsxRuntime.jsx(BraceLeftComp, _extends({}, resetProps));
920
920
  };
@@ -951,10 +951,10 @@ var BracketsClose = (props) => {
951
951
  }
952
952
  var {
953
953
  as: elm,
954
- render
954
+ render: render2
955
955
  } = BraceRight2, reset = _objectWithoutPropertiesLoose(BraceRight2, _excluded9$1);
956
956
  var BraceRightComp = elm || "span";
957
- var child = render && typeof render === "function" && render(reset, result);
957
+ var child = render2 && typeof render2 === "function" && render2(reset, result);
958
958
  if (child) return child;
959
959
  return /* @__PURE__ */ jsxRuntime.jsx(BraceRightComp, _extends({}, reset));
960
960
  };
@@ -1037,10 +1037,10 @@ var SetComp = (_ref) => {
1037
1037
  if (!isSet || !displayDataTypes) return null;
1038
1038
  var {
1039
1039
  as,
1040
- render
1040
+ render: render2
1041
1041
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$8);
1042
- var isRender = render && typeof render === "function";
1043
- var type = isRender && render(reset, {
1042
+ var isRender = render2 && typeof render2 === "function";
1043
+ var type = isRender && render2(reset, {
1044
1044
  type: "type",
1045
1045
  value,
1046
1046
  keyName
@@ -1063,10 +1063,10 @@ var MapComp = (_ref2) => {
1063
1063
  if (!isMap || !displayDataTypes) return null;
1064
1064
  var {
1065
1065
  as,
1066
- render
1066
+ render: render2
1067
1067
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$4);
1068
- var isRender = render && typeof render === "function";
1069
- var type = isRender && render(reset, {
1068
+ var isRender = render2 && typeof render2 === "function";
1069
+ var type = isRender && render2(reset, {
1070
1070
  type: "type",
1071
1071
  value,
1072
1072
  keyName
@@ -1096,11 +1096,11 @@ var TypeString = (_ref3) => {
1096
1096
  } = useStore();
1097
1097
  var {
1098
1098
  as,
1099
- render
1099
+ render: render2
1100
1100
  } = Str, reset = _objectWithoutPropertiesLoose(Str, _excluded3);
1101
1101
  var childrenStr = children;
1102
- var [shorten, setShorten] = React.useState(length && childrenStr.length > length);
1103
- React.useEffect(() => setShorten(length && childrenStr.length > length), [length]);
1102
+ var [shorten, setShorten] = react.useState(length && childrenStr.length > length);
1103
+ react.useEffect(() => setShorten(length && childrenStr.length > length), [length]);
1104
1104
  var Comp = as || "span";
1105
1105
  var style = _extends({}, defalutStyle, Str.style || {});
1106
1106
  if (length > 0) {
@@ -1114,8 +1114,8 @@ var TypeString = (_ref3) => {
1114
1114
  }
1115
1115
  }
1116
1116
  var text = shorten ? "" + childrenStr.slice(0, length) + stringEllipsis : childrenStr;
1117
- var isRender = render && typeof render === "function";
1118
- var type = isRender && render(_extends({}, reset, {
1117
+ var isRender = render2 && typeof render2 === "function";
1118
+ var type = isRender && render2(_extends({}, reset, {
1119
1119
  style
1120
1120
  }), {
1121
1121
  type: "type",
@@ -1124,7 +1124,7 @@ var TypeString = (_ref3) => {
1124
1124
  keys
1125
1125
  });
1126
1126
  var cls = shorten ? "w-rjv-value w-rjv-value-short" : "w-rjv-value";
1127
- var child = isRender && render(_extends({}, reset, {
1127
+ var child = isRender && render2(_extends({}, reset, {
1128
1128
  children: text,
1129
1129
  className: cls
1130
1130
  }), {
@@ -1133,10 +1133,10 @@ var TypeString = (_ref3) => {
1133
1133
  keyName,
1134
1134
  keys
1135
1135
  });
1136
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1136
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1137
1137
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1138
1138
  style
1139
- }))), child || /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1139
+ }))), child || /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1140
1140
  children: [/* @__PURE__ */ jsxRuntime.jsx(ValueQuote$1, {}), /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1141
1141
  className: cls,
1142
1142
  children: text
@@ -1157,12 +1157,12 @@ var TypeTrue = (_ref4) => {
1157
1157
  } = useTypesStore();
1158
1158
  var {
1159
1159
  as,
1160
- render
1160
+ render: render2
1161
1161
  } = True2, reset = _objectWithoutPropertiesLoose(True2, _excluded4);
1162
1162
  var Comp = as || "span";
1163
1163
  var style = _extends({}, defalutStyle, True2.style || {});
1164
- var isRender = render && typeof render === "function";
1165
- var type = isRender && render(_extends({}, reset, {
1164
+ var isRender = render2 && typeof render2 === "function";
1165
+ var type = isRender && render2(_extends({}, reset, {
1166
1166
  style
1167
1167
  }), {
1168
1168
  type: "type",
@@ -1170,7 +1170,7 @@ var TypeTrue = (_ref4) => {
1170
1170
  keyName,
1171
1171
  keys
1172
1172
  });
1173
- var child = isRender && render(_extends({}, reset, {
1173
+ var child = isRender && render2(_extends({}, reset, {
1174
1174
  children,
1175
1175
  className: "w-rjv-value"
1176
1176
  }), {
@@ -1179,7 +1179,7 @@ var TypeTrue = (_ref4) => {
1179
1179
  keyName,
1180
1180
  keys
1181
1181
  });
1182
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1182
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1183
1183
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1184
1184
  style
1185
1185
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1201,12 +1201,12 @@ var TypeFalse = (_ref5) => {
1201
1201
  } = useTypesStore();
1202
1202
  var {
1203
1203
  as,
1204
- render
1204
+ render: render2
1205
1205
  } = False2, reset = _objectWithoutPropertiesLoose(False2, _excluded5);
1206
1206
  var Comp = as || "span";
1207
1207
  var style = _extends({}, defalutStyle, False2.style || {});
1208
- var isRender = render && typeof render === "function";
1209
- var type = isRender && render(_extends({}, reset, {
1208
+ var isRender = render2 && typeof render2 === "function";
1209
+ var type = isRender && render2(_extends({}, reset, {
1210
1210
  style
1211
1211
  }), {
1212
1212
  type: "type",
@@ -1214,7 +1214,7 @@ var TypeFalse = (_ref5) => {
1214
1214
  keyName,
1215
1215
  keys
1216
1216
  });
1217
- var child = isRender && render(_extends({}, reset, {
1217
+ var child = isRender && render2(_extends({}, reset, {
1218
1218
  children,
1219
1219
  className: "w-rjv-value"
1220
1220
  }), {
@@ -1223,7 +1223,7 @@ var TypeFalse = (_ref5) => {
1223
1223
  keyName,
1224
1224
  keys
1225
1225
  });
1226
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1226
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1227
1227
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1228
1228
  style
1229
1229
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1245,12 +1245,12 @@ var TypeFloat = (_ref6) => {
1245
1245
  } = useTypesStore();
1246
1246
  var {
1247
1247
  as,
1248
- render
1248
+ render: render2
1249
1249
  } = Float2, reset = _objectWithoutPropertiesLoose(Float2, _excluded6);
1250
1250
  var Comp = as || "span";
1251
1251
  var style = _extends({}, defalutStyle, Float2.style || {});
1252
- var isRender = render && typeof render === "function";
1253
- var type = isRender && render(_extends({}, reset, {
1252
+ var isRender = render2 && typeof render2 === "function";
1253
+ var type = isRender && render2(_extends({}, reset, {
1254
1254
  style
1255
1255
  }), {
1256
1256
  type: "type",
@@ -1258,7 +1258,7 @@ var TypeFloat = (_ref6) => {
1258
1258
  keyName,
1259
1259
  keys
1260
1260
  });
1261
- var child = isRender && render(_extends({}, reset, {
1261
+ var child = isRender && render2(_extends({}, reset, {
1262
1262
  children,
1263
1263
  className: "w-rjv-value"
1264
1264
  }), {
@@ -1267,7 +1267,7 @@ var TypeFloat = (_ref6) => {
1267
1267
  keyName,
1268
1268
  keys
1269
1269
  });
1270
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1270
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1271
1271
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1272
1272
  style
1273
1273
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1289,12 +1289,12 @@ var TypeInt = (_ref7) => {
1289
1289
  } = useTypesStore();
1290
1290
  var {
1291
1291
  as,
1292
- render
1292
+ render: render2
1293
1293
  } = Int2, reset = _objectWithoutPropertiesLoose(Int2, _excluded7);
1294
1294
  var Comp = as || "span";
1295
1295
  var style = _extends({}, defalutStyle, Int2.style || {});
1296
- var isRender = render && typeof render === "function";
1297
- var type = isRender && render(_extends({}, reset, {
1296
+ var isRender = render2 && typeof render2 === "function";
1297
+ var type = isRender && render2(_extends({}, reset, {
1298
1298
  style
1299
1299
  }), {
1300
1300
  type: "type",
@@ -1302,7 +1302,7 @@ var TypeInt = (_ref7) => {
1302
1302
  keyName,
1303
1303
  keys
1304
1304
  });
1305
- var child = isRender && render(_extends({}, reset, {
1305
+ var child = isRender && render2(_extends({}, reset, {
1306
1306
  children,
1307
1307
  className: "w-rjv-value"
1308
1308
  }), {
@@ -1311,7 +1311,7 @@ var TypeInt = (_ref7) => {
1311
1311
  keyName,
1312
1312
  keys
1313
1313
  });
1314
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1314
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1315
1315
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1316
1316
  style
1317
1317
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1333,12 +1333,12 @@ var TypeBigint = (_ref8) => {
1333
1333
  } = useTypesStore();
1334
1334
  var {
1335
1335
  as,
1336
- render
1336
+ render: render2
1337
1337
  } = CompBigint, reset = _objectWithoutPropertiesLoose(CompBigint, _excluded8);
1338
1338
  var Comp = as || "span";
1339
1339
  var style = _extends({}, defalutStyle, CompBigint.style || {});
1340
- var isRender = render && typeof render === "function";
1341
- var type = isRender && render(_extends({}, reset, {
1340
+ var isRender = render2 && typeof render2 === "function";
1341
+ var type = isRender && render2(_extends({}, reset, {
1342
1342
  style
1343
1343
  }), {
1344
1344
  type: "type",
@@ -1346,7 +1346,7 @@ var TypeBigint = (_ref8) => {
1346
1346
  keyName,
1347
1347
  keys
1348
1348
  });
1349
- var child = isRender && render(_extends({}, reset, {
1349
+ var child = isRender && render2(_extends({}, reset, {
1350
1350
  children,
1351
1351
  className: "w-rjv-value"
1352
1352
  }), {
@@ -1355,7 +1355,7 @@ var TypeBigint = (_ref8) => {
1355
1355
  keyName,
1356
1356
  keys
1357
1357
  });
1358
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1358
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1359
1359
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1360
1360
  style
1361
1361
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1377,12 +1377,12 @@ var TypeUrl = (_ref9) => {
1377
1377
  } = useTypesStore();
1378
1378
  var {
1379
1379
  as,
1380
- render
1380
+ render: render2
1381
1381
  } = Url2, reset = _objectWithoutPropertiesLoose(Url2, _excluded9);
1382
1382
  var Comp = as || "span";
1383
1383
  var style = _extends({}, defalutStyle, Url2.style);
1384
- var isRender = render && typeof render === "function";
1385
- var type = isRender && render(_extends({}, reset, {
1384
+ var isRender = render2 && typeof render2 === "function";
1385
+ var type = isRender && render2(_extends({}, reset, {
1386
1386
  style
1387
1387
  }), {
1388
1388
  type: "type",
@@ -1390,7 +1390,7 @@ var TypeUrl = (_ref9) => {
1390
1390
  keyName,
1391
1391
  keys
1392
1392
  });
1393
- var child = isRender && render(_extends({}, reset, {
1393
+ var child = isRender && render2(_extends({}, reset, {
1394
1394
  children: children == null ? void 0 : children.href,
1395
1395
  className: "w-rjv-value"
1396
1396
  }), {
@@ -1399,7 +1399,7 @@ var TypeUrl = (_ref9) => {
1399
1399
  keyName,
1400
1400
  keys
1401
1401
  });
1402
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1402
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1403
1403
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1404
1404
  style
1405
1405
  }))), child || /* @__PURE__ */ jsxRuntime.jsxs("a", _extends({
@@ -1424,12 +1424,12 @@ var TypeDate = (_ref0) => {
1424
1424
  } = useTypesStore();
1425
1425
  var {
1426
1426
  as,
1427
- render
1427
+ render: render2
1428
1428
  } = CompData, reset = _objectWithoutPropertiesLoose(CompData, _excluded0);
1429
1429
  var Comp = as || "span";
1430
1430
  var style = _extends({}, defalutStyle, CompData.style || {});
1431
- var isRender = render && typeof render === "function";
1432
- var type = isRender && render(_extends({}, reset, {
1431
+ var isRender = render2 && typeof render2 === "function";
1432
+ var type = isRender && render2(_extends({}, reset, {
1433
1433
  style
1434
1434
  }), {
1435
1435
  type: "type",
@@ -1438,7 +1438,7 @@ var TypeDate = (_ref0) => {
1438
1438
  keys
1439
1439
  });
1440
1440
  var childStr = children instanceof Date ? children.toLocaleString() : children;
1441
- var child = isRender && render(_extends({}, reset, {
1441
+ var child = isRender && render2(_extends({}, reset, {
1442
1442
  children: childStr,
1443
1443
  className: "w-rjv-value"
1444
1444
  }), {
@@ -1447,7 +1447,7 @@ var TypeDate = (_ref0) => {
1447
1447
  keyName,
1448
1448
  keys
1449
1449
  });
1450
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1450
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1451
1451
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1452
1452
  style
1453
1453
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1469,12 +1469,12 @@ var TypeUndefined = (_ref1) => {
1469
1469
  } = useTypesStore();
1470
1470
  var {
1471
1471
  as,
1472
- render
1472
+ render: render2
1473
1473
  } = Undefined2, reset = _objectWithoutPropertiesLoose(Undefined2, _excluded1);
1474
1474
  var Comp = as || "span";
1475
1475
  var style = _extends({}, defalutStyle, Undefined2.style || {});
1476
- var isRender = render && typeof render === "function";
1477
- var type = isRender && render(_extends({}, reset, {
1476
+ var isRender = render2 && typeof render2 === "function";
1477
+ var type = isRender && render2(_extends({}, reset, {
1478
1478
  style
1479
1479
  }), {
1480
1480
  type: "type",
@@ -1482,7 +1482,7 @@ var TypeUndefined = (_ref1) => {
1482
1482
  keyName,
1483
1483
  keys
1484
1484
  });
1485
- var child = isRender && render(_extends({}, reset, {
1485
+ var child = isRender && render2(_extends({}, reset, {
1486
1486
  children,
1487
1487
  className: "w-rjv-value"
1488
1488
  }), {
@@ -1491,7 +1491,7 @@ var TypeUndefined = (_ref1) => {
1491
1491
  keyName,
1492
1492
  keys
1493
1493
  });
1494
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1494
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1495
1495
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1496
1496
  style
1497
1497
  }))), child]
@@ -1510,12 +1510,12 @@ var TypeNull = (_ref10) => {
1510
1510
  } = useTypesStore();
1511
1511
  var {
1512
1512
  as,
1513
- render
1513
+ render: render2
1514
1514
  } = Null2, reset = _objectWithoutPropertiesLoose(Null2, _excluded10);
1515
1515
  var Comp = as || "span";
1516
1516
  var style = _extends({}, defalutStyle, Null2.style || {});
1517
- var isRender = render && typeof render === "function";
1518
- var type = isRender && render(_extends({}, reset, {
1517
+ var isRender = render2 && typeof render2 === "function";
1518
+ var type = isRender && render2(_extends({}, reset, {
1519
1519
  style
1520
1520
  }), {
1521
1521
  type: "type",
@@ -1523,7 +1523,7 @@ var TypeNull = (_ref10) => {
1523
1523
  keyName,
1524
1524
  keys
1525
1525
  });
1526
- var child = isRender && render(_extends({}, reset, {
1526
+ var child = isRender && render2(_extends({}, reset, {
1527
1527
  children,
1528
1528
  className: "w-rjv-value"
1529
1529
  }), {
@@ -1532,7 +1532,7 @@ var TypeNull = (_ref10) => {
1532
1532
  keyName,
1533
1533
  keys
1534
1534
  });
1535
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1535
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1536
1536
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1537
1537
  style
1538
1538
  }))), child]
@@ -1551,12 +1551,12 @@ var TypeNan = (_ref11) => {
1551
1551
  } = useTypesStore();
1552
1552
  var {
1553
1553
  as,
1554
- render
1554
+ render: render2
1555
1555
  } = Nan2, reset = _objectWithoutPropertiesLoose(Nan2, _excluded11);
1556
1556
  var Comp = as || "span";
1557
1557
  var style = _extends({}, defalutStyle, Nan2.style || {});
1558
- var isRender = render && typeof render === "function";
1559
- var type = isRender && render(_extends({}, reset, {
1558
+ var isRender = render2 && typeof render2 === "function";
1559
+ var type = isRender && render2(_extends({}, reset, {
1560
1560
  style
1561
1561
  }), {
1562
1562
  type: "type",
@@ -1564,7 +1564,7 @@ var TypeNan = (_ref11) => {
1564
1564
  keyName,
1565
1565
  keys
1566
1566
  });
1567
- var child = isRender && render(_extends({}, reset, {
1567
+ var child = isRender && render2(_extends({}, reset, {
1568
1568
  children: children == null ? void 0 : children.toString(),
1569
1569
  className: "w-rjv-value"
1570
1570
  }), {
@@ -1573,7 +1573,7 @@ var TypeNan = (_ref11) => {
1573
1573
  keyName,
1574
1574
  keys
1575
1575
  });
1576
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1576
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1577
1577
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1578
1578
  style
1579
1579
  }))), child]
@@ -1654,7 +1654,7 @@ function useSymbolsRender(currentProps, props, key) {
1654
1654
  style: _extends({}, currentProps.style, props.style),
1655
1655
  children: props.children || currentProps.children
1656
1656
  });
1657
- React.useEffect(() => dispatch({
1657
+ react.useEffect(() => dispatch({
1658
1658
  [key]: reset
1659
1659
  }), [props]);
1660
1660
  }
@@ -1666,7 +1666,7 @@ function useTypesRender(currentProps, props, key) {
1666
1666
  style: _extends({}, currentProps.style, props.style),
1667
1667
  children: props.children || currentProps.children
1668
1668
  });
1669
- React.useEffect(() => dispatch({
1669
+ react.useEffect(() => dispatch({
1670
1670
  [key]: reset
1671
1671
  }), [props]);
1672
1672
  }
@@ -1678,7 +1678,7 @@ function useSectionRender(currentProps, props, key) {
1678
1678
  style: _extends({}, currentProps.style, props.style),
1679
1679
  children: props.children || currentProps.children
1680
1680
  });
1681
- React.useEffect(() => dispatch({
1681
+ react.useEffect(() => dispatch({
1682
1682
  [key]: reset
1683
1683
  }), [props]);
1684
1684
  }
@@ -1708,11 +1708,11 @@ var KeyNameComp = (props) => {
1708
1708
  } = useSectionStore();
1709
1709
  var {
1710
1710
  as,
1711
- render
1711
+ render: render2
1712
1712
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$7);
1713
1713
  reset.style = _extends({}, reset.style, style);
1714
1714
  var Elm = as || "span";
1715
- var child = render && typeof render === "function" && render(_extends({}, reset, {
1715
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
1716
1716
  children
1717
1717
  }), {
1718
1718
  value,
@@ -1748,10 +1748,10 @@ var RowComp = (props) => {
1748
1748
  } = useSectionStore();
1749
1749
  var {
1750
1750
  as,
1751
- render
1751
+ render: render2
1752
1752
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$3);
1753
1753
  var Elm = as || "div";
1754
- var child = render && typeof render === "function" && render(_extends({}, other, reset, {
1754
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, other, reset, {
1755
1755
  children
1756
1756
  }), {
1757
1757
  value,
@@ -1766,8 +1766,8 @@ var RowComp = (props) => {
1766
1766
  };
1767
1767
  RowComp.displayName = "JVR.RowComp";
1768
1768
  function usePrevious(value) {
1769
- var ref = React.useRef();
1770
- React.useEffect(() => {
1769
+ var ref = react.useRef();
1770
+ react.useEffect(() => {
1771
1771
  ref.current = value;
1772
1772
  });
1773
1773
  return ref.current;
@@ -1779,7 +1779,7 @@ function useHighlight(_ref) {
1779
1779
  highlightContainer
1780
1780
  } = _ref;
1781
1781
  var prevValue = usePrevious(value);
1782
- var isHighlight = React.useMemo(() => {
1782
+ var isHighlight = react.useMemo(() => {
1783
1783
  if (!highlightUpdates || prevValue === void 0) return false;
1784
1784
  if (typeof value !== typeof prevValue) {
1785
1785
  return true;
@@ -1798,7 +1798,7 @@ function useHighlight(_ref) {
1798
1798
  return true;
1799
1799
  }
1800
1800
  }, [highlightUpdates, value]);
1801
- React.useEffect(() => {
1801
+ react.useEffect(() => {
1802
1802
  if (highlightContainer && highlightContainer.current && isHighlight && "animate" in highlightContainer.current) {
1803
1803
  highlightContainer.current.animate([{
1804
1804
  backgroundColor: "var(--w-rjv-update-color, #ebcb8b)"
@@ -1828,7 +1828,7 @@ var Copied$2 = (props) => {
1828
1828
  } = useStore();
1829
1829
  var showTools = useShowToolsStore();
1830
1830
  var isShowTools = showTools[expandKey];
1831
- var [copied, setCopied] = React.useState(false);
1831
+ var [copied, setCopied] = react.useState(false);
1832
1832
  var {
1833
1833
  Copied: Comp = {}
1834
1834
  } = useSectionStore();
@@ -1889,13 +1889,13 @@ var Copied$2 = (props) => {
1889
1889
  onClick: click
1890
1890
  };
1891
1891
  var {
1892
- render
1892
+ render: render2
1893
1893
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$2);
1894
1894
  var elmProps = _extends({}, reset, other, svgProps, {
1895
1895
  style: _extends({}, reset.style, other.style, svgProps.style)
1896
1896
  });
1897
- var isRender = render && typeof render === "function";
1898
- var child = isRender && render(_extends({}, elmProps, {
1897
+ var isRender = render2 && typeof render2 === "function";
1898
+ var child = isRender && render2(_extends({}, elmProps, {
1899
1899
  "data-copied": copied
1900
1900
  }), {
1901
1901
  value,
@@ -1923,7 +1923,7 @@ var Copied$2 = (props) => {
1923
1923
  };
1924
1924
  Copied$2.displayName = "JVR.Copied";
1925
1925
  function useIdCompat() {
1926
- var idRef = React.useRef(null);
1926
+ var idRef = react.useRef(null);
1927
1927
  if (idRef.current === null) {
1928
1928
  idRef.current = "custom-id-" + Math.random().toString(36).substr(2, 9);
1929
1929
  }
@@ -2006,7 +2006,7 @@ var KayName = (props) => {
2006
2006
  highlightUpdates
2007
2007
  } = useStore();
2008
2008
  var isNumber = typeof keyName === "number";
2009
- var highlightContainer = React.useRef(null);
2009
+ var highlightContainer = react.useRef(null);
2010
2010
  useHighlight({
2011
2011
  value,
2012
2012
  highlightUpdates,
@@ -2018,7 +2018,7 @@ var KayName = (props) => {
2018
2018
  keys,
2019
2019
  parentValue
2020
2020
  };
2021
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
2021
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
2022
2022
  children: [/* @__PURE__ */ jsxRuntime.jsxs("span", {
2023
2023
  ref: highlightContainer,
2024
2024
  children: [/* @__PURE__ */ jsxRuntime.jsx(Quote$1, _extends({
@@ -2115,13 +2115,13 @@ var CountInfoExtraComps = (props) => {
2115
2115
  } = useSectionStore();
2116
2116
  var {
2117
2117
  as,
2118
- render
2118
+ render: render2
2119
2119
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$1);
2120
- if (!render && !reset.children) return null;
2120
+ if (!render2 && !reset.children) return null;
2121
2121
  var Elm = as || "span";
2122
- var isRender = render && typeof render === "function";
2122
+ var isRender = render2 && typeof render2 === "function";
2123
2123
  var elmProps = _extends({}, reset, other);
2124
- var child = isRender && render(elmProps, {
2124
+ var child = isRender && render2(elmProps, {
2125
2125
  value,
2126
2126
  keyName
2127
2127
  });
@@ -2152,7 +2152,7 @@ var CountInfoComp = (props) => {
2152
2152
  if (!displayObjectSize) return null;
2153
2153
  var {
2154
2154
  as,
2155
- render
2155
+ render: render2
2156
2156
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
2157
2157
  var Elm = as || "span";
2158
2158
  reset.style = _extends({}, reset.style, props.style);
@@ -2161,8 +2161,8 @@ var CountInfoComp = (props) => {
2161
2161
  reset.children = len + " item" + (len === 1 ? "" : "s");
2162
2162
  }
2163
2163
  var elmProps = _extends({}, reset, other);
2164
- var isRender = render && typeof render === "function";
2165
- var child = isRender && render(_extends({}, elmProps, {
2164
+ var isRender = render2 && typeof render2 === "function";
2165
+ var child = isRender && render2(_extends({}, elmProps, {
2166
2166
  "data-length": len
2167
2167
  }), {
2168
2168
  value,
@@ -2192,10 +2192,10 @@ var EllipsisComp = (_ref) => {
2192
2192
  } = useSectionStore();
2193
2193
  var {
2194
2194
  as,
2195
- render
2195
+ render: render2
2196
2196
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$2);
2197
2197
  var Elm = as || "span";
2198
- var child = render && typeof render === "function" && render(_extends({}, reset, {
2198
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
2199
2199
  "data-expanded": isExpanded
2200
2200
  }), {
2201
2201
  value,
@@ -2309,7 +2309,7 @@ var NestedOpen = (props) => {
2309
2309
  };
2310
2310
  NestedOpen.displayName = "JVR.NestedOpen";
2311
2311
  var _excluded$1 = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keys", "keyName"];
2312
- var Container = /* @__PURE__ */ React.forwardRef((props, ref) => {
2312
+ var Container = /* @__PURE__ */ react.forwardRef((props, ref) => {
2313
2313
  var {
2314
2314
  className = "",
2315
2315
  parentValue,
@@ -2537,7 +2537,7 @@ var Copied$1 = (props) => {
2537
2537
  };
2538
2538
  Copied$1.displayName = "JVR.Copied";
2539
2539
  var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied", "beforeCopy"];
2540
- var JsonView = /* @__PURE__ */ React.forwardRef((props, ref) => {
2540
+ var JsonView = /* @__PURE__ */ react.forwardRef((props, ref) => {
2541
2541
  var {
2542
2542
  className = "",
2543
2543
  style,
@@ -2670,7 +2670,7 @@ const JsonViewSection = ({ data }) => {
2670
2670
  ] })
2671
2671
  ] }),
2672
2672
  /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
2673
- React.Suspense,
2673
+ react.Suspense,
2674
2674
  {
2675
2675
  fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full flex-col" }),
2676
2676
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2743,7 +2743,7 @@ const JsonViewSection = ({ data }) => {
2743
2743
  ] });
2744
2744
  };
2745
2745
  const Copied = ({ style, value }) => {
2746
- const [copied, setCopied] = React.useState(false);
2746
+ const [copied, setCopied] = react.useState(false);
2747
2747
  const handler = (e) => {
2748
2748
  e.stopPropagation();
2749
2749
  setCopied(true);
@@ -2834,11 +2834,11 @@ const SingleColumnPage = ({
2834
2834
  }
2835
2835
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-3", children: [
2836
2836
  before.map((Component, i) => {
2837
- return /* @__PURE__ */ React.createElement(Component, { ...widgetProps, key: i });
2837
+ return /* @__PURE__ */ react.createElement(Component, { ...widgetProps, key: i });
2838
2838
  }),
2839
2839
  children,
2840
2840
  after.map((Component, i) => {
2841
- return /* @__PURE__ */ React.createElement(Component, { ...widgetProps, key: i });
2841
+ return /* @__PURE__ */ react.createElement(Component, { ...widgetProps, key: i });
2842
2842
  }),
2843
2843
  showMetadata && /* @__PURE__ */ jsxRuntime.jsx(MetadataSection, { data }),
2844
2844
  showJSON && /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data }),
@@ -2846,12 +2846,12 @@ const SingleColumnPage = ({
2846
2846
  ] });
2847
2847
  };
2848
2848
  const NotificationsFullList = () => {
2849
- const [pagination, setPagination] = React.useState({
2849
+ const [pagination, setPagination] = react.useState({
2850
2850
  pageSize: 8,
2851
2851
  pageIndex: 0
2852
2852
  });
2853
2853
  const limit = 8;
2854
- const offset = React.useMemo(() => {
2854
+ const offset = react.useMemo(() => {
2855
2855
  return pagination.pageIndex * limit;
2856
2856
  }, [pagination]);
2857
2857
  const { data: notificationsData, isLoading: isNotificationsLoading } = useListNotifications({
@@ -2949,7 +2949,7 @@ const config$1 = adminSdk.defineRouteConfig({
2949
2949
  icon: icons.ListBullet
2950
2950
  });
2951
2951
  const useOrders = (params = {}, options) => {
2952
- const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id" } = params;
2952
+ const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id", order = "-created_at" } = params;
2953
2953
  const queryKey = [
2954
2954
  "orders",
2955
2955
  ...extraKey
@@ -2957,7 +2957,8 @@ const useOrders = (params = {}, options) => {
2957
2957
  const query = {
2958
2958
  limit,
2959
2959
  offset,
2960
- fields
2960
+ fields,
2961
+ order
2961
2962
  };
2962
2963
  const { data, ...rest } = reactQuery.useQuery({
2963
2964
  queryKey,
@@ -7376,2395 +7377,259 @@ const getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc,
7376
7377
  acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
7377
7378
  return acc;
7378
7379
  }, 0);
7379
- const TEMPLATES_NAMES = {
7380
- ORDER_PLACED: "order-placed",
7381
- CONTACT_FORM: "contact-form"
7382
- };
7383
- const isString = (obj) => typeof obj === "string";
7384
- const defer = () => {
7385
- let res;
7386
- let rej;
7387
- const promise = new Promise((resolve, reject) => {
7388
- res = resolve;
7389
- rej = reject;
7390
- });
7391
- promise.resolve = res;
7392
- promise.reject = rej;
7393
- return promise;
7394
- };
7395
- const makeString = (object) => {
7396
- if (object == null) return "";
7397
- return "" + object;
7398
- };
7399
- const copy = (a, s, t) => {
7400
- a.forEach((m) => {
7401
- if (s[m]) t[m] = s[m];
7402
- });
7403
- };
7404
- const lastOfPathSeparatorRegExp = /###/g;
7405
- const cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
7406
- const canNotTraverseDeeper = (object) => !object || isString(object);
7407
- const getLastOfPath = (object, path, Empty) => {
7408
- const stack = !isString(path) ? path : path.split(".");
7409
- let stackIndex = 0;
7410
- while (stackIndex < stack.length - 1) {
7411
- if (canNotTraverseDeeper(object)) return {};
7412
- const key = cleanKey(stack[stackIndex]);
7413
- if (!object[key] && Empty) object[key] = new Empty();
7414
- if (Object.prototype.hasOwnProperty.call(object, key)) {
7415
- object = object[key];
7416
- } else {
7417
- object = {};
7418
- }
7419
- ++stackIndex;
7420
- }
7421
- if (canNotTraverseDeeper(object)) return {};
7422
- return {
7423
- obj: object,
7424
- k: cleanKey(stack[stackIndex])
7425
- };
7426
- };
7427
- const setPath = (object, path, newValue) => {
7428
- const {
7429
- obj,
7430
- k
7431
- } = getLastOfPath(object, path, Object);
7432
- if (obj !== void 0 || path.length === 1) {
7433
- obj[k] = newValue;
7434
- return;
7435
- }
7436
- let e = path[path.length - 1];
7437
- let p = path.slice(0, path.length - 1);
7438
- let last = getLastOfPath(object, p, Object);
7439
- while (last.obj === void 0 && p.length) {
7440
- e = `${p[p.length - 1]}.${e}`;
7441
- p = p.slice(0, p.length - 1);
7442
- last = getLastOfPath(object, p, Object);
7443
- if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") {
7444
- last.obj = void 0;
7445
- }
7446
- }
7447
- last.obj[`${last.k}.${e}`] = newValue;
7448
- };
7449
- const pushPath = (object, path, newValue, concat) => {
7450
- const {
7451
- obj,
7452
- k
7453
- } = getLastOfPath(object, path, Object);
7454
- obj[k] = obj[k] || [];
7455
- obj[k].push(newValue);
7456
- };
7457
- const getPath = (object, path) => {
7458
- const {
7459
- obj,
7460
- k
7461
- } = getLastOfPath(object, path);
7462
- if (!obj) return void 0;
7463
- return obj[k];
7464
- };
7465
- const getPathWithDefaults = (data, defaultData, key) => {
7466
- const value = getPath(data, key);
7467
- if (value !== void 0) {
7468
- return value;
7469
- }
7470
- return getPath(defaultData, key);
7471
- };
7472
- const deepExtend = (target, source, overwrite) => {
7473
- for (const prop in source) {
7474
- if (prop !== "__proto__" && prop !== "constructor") {
7475
- if (prop in target) {
7476
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
7477
- if (overwrite) target[prop] = source[prop];
7478
- } else {
7479
- deepExtend(target[prop], source[prop], overwrite);
7480
- }
7481
- } else {
7482
- target[prop] = source[prop];
7483
- }
7484
- }
7485
- }
7486
- return target;
7487
- };
7488
- const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
7489
- var _entityMap = {
7490
- "&": "&amp;",
7491
- "<": "&lt;",
7492
- ">": "&gt;",
7493
- '"': "&quot;",
7494
- "'": "&#39;",
7495
- "/": "&#x2F;"
7496
- };
7497
- const escape = (data) => {
7498
- if (isString(data)) {
7499
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
7500
- }
7501
- return data;
7502
- };
7503
- class RegExpCache {
7504
- constructor(capacity) {
7505
- this.capacity = capacity;
7506
- this.regExpMap = /* @__PURE__ */ new Map();
7507
- this.regExpQueue = [];
7508
- }
7509
- getRegExp(pattern) {
7510
- const regExpFromCache = this.regExpMap.get(pattern);
7511
- if (regExpFromCache !== void 0) {
7512
- return regExpFromCache;
7513
- }
7514
- const regExpNew = new RegExp(pattern);
7515
- if (this.regExpQueue.length === this.capacity) {
7516
- this.regExpMap.delete(this.regExpQueue.shift());
7517
- }
7518
- this.regExpMap.set(pattern, regExpNew);
7519
- this.regExpQueue.push(pattern);
7520
- return regExpNew;
7521
- }
7380
+ function SectionBlock({
7381
+ id,
7382
+ props,
7383
+ data,
7384
+ isLastBlock,
7385
+ isFirstBlock
7386
+ }) {
7387
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Section, { className: "m-0 p-0", children: /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks: props.blocks || [], data }) });
7522
7388
  }
7523
- const chars = [" ", ",", "?", "!", ";"];
7524
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
7525
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
7526
- nsSeparator = nsSeparator || "";
7527
- keySeparator = keySeparator || "";
7528
- const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
7529
- if (possibleChars.length === 0) return true;
7530
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
7531
- let matched = !r.test(key);
7532
- if (!matched) {
7533
- const ki = key.indexOf(keySeparator);
7534
- if (ki > 0 && !r.test(key.substring(0, ki))) {
7535
- matched = true;
7536
- }
7537
- }
7538
- return matched;
7539
- };
7540
- const deepFind = function(obj, path) {
7541
- let keySeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
7542
- if (!obj) return void 0;
7543
- if (obj[path]) return obj[path];
7544
- const tokens = path.split(keySeparator);
7545
- let current = obj;
7546
- for (let i = 0; i < tokens.length; ) {
7547
- if (!current || typeof current !== "object") {
7548
- return void 0;
7549
- }
7550
- let next;
7551
- let nextPath = "";
7552
- for (let j = i; j < tokens.length; ++j) {
7553
- if (j !== i) {
7554
- nextPath += keySeparator;
7555
- }
7556
- nextPath += tokens[j];
7557
- next = current[nextPath];
7558
- if (next !== void 0) {
7559
- if (["string", "number", "boolean"].indexOf(typeof next) > -1 && j < tokens.length - 1) {
7560
- continue;
7561
- }
7562
- i += j - i + 1;
7563
- break;
7564
- }
7565
- }
7566
- current = next;
7567
- }
7568
- return current;
7569
- };
7570
- const getCleanedCode = (code) => code && code.replace("_", "-");
7571
- const consoleLogger = {
7572
- type: "logger",
7573
- log(args) {
7574
- this.output("log", args);
7575
- },
7576
- warn(args) {
7577
- this.output("warn", args);
7578
- },
7579
- error(args) {
7580
- this.output("error", args);
7581
- },
7582
- output(type, args) {
7583
- if (console && console[type]) console[type].apply(console, args);
7584
- }
7585
- };
7586
- class Logger {
7587
- constructor(concreteLogger) {
7588
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7589
- this.init(concreteLogger, options);
7590
- }
7591
- init(concreteLogger) {
7592
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7593
- this.prefix = options.prefix || "i18next:";
7594
- this.logger = concreteLogger || consoleLogger;
7595
- this.options = options;
7596
- this.debug = options.debug;
7597
- }
7598
- log() {
7599
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7600
- args[_key] = arguments[_key];
7601
- }
7602
- return this.forward(args, "log", "", true);
7603
- }
7604
- warn() {
7605
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
7606
- args[_key2] = arguments[_key2];
7607
- }
7608
- return this.forward(args, "warn", "", true);
7609
- }
7610
- error() {
7611
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
7612
- args[_key3] = arguments[_key3];
7613
- }
7614
- return this.forward(args, "error", "");
7615
- }
7616
- deprecate() {
7617
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
7618
- args[_key4] = arguments[_key4];
7619
- }
7620
- return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
7621
- }
7622
- forward(args, lvl, prefix, debugOnly) {
7623
- if (debugOnly && !this.debug) return null;
7624
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
7625
- return this.logger[lvl](args);
7626
- }
7627
- create(moduleName) {
7628
- return new Logger(this.logger, {
7629
- ...{
7630
- prefix: `${this.prefix}:${moduleName}:`
7631
- },
7632
- ...this.options
7633
- });
7634
- }
7635
- clone(options) {
7636
- options = options || this.options;
7637
- options.prefix = options.prefix || this.prefix;
7638
- return new Logger(this.logger, options);
7639
- }
7389
+ function TextBlock({
7390
+ id,
7391
+ props,
7392
+ isLastBlock,
7393
+ isFirstBlock
7394
+ }) {
7395
+ const className = ui.clx(
7396
+ isLastBlock ? "mb-0" : "mb-4",
7397
+ isFirstBlock && "mt-0"
7398
+ );
7399
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Text, { className, children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value }, id);
7640
7400
  }
7641
- var baseLogger = new Logger();
7642
- class EventEmitter {
7643
- constructor() {
7644
- this.observers = {};
7645
- }
7646
- on(events, listener) {
7647
- events.split(" ").forEach((event) => {
7648
- if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
7649
- const numListeners = this.observers[event].get(listener) || 0;
7650
- this.observers[event].set(listener, numListeners + 1);
7651
- });
7652
- return this;
7653
- }
7654
- off(event, listener) {
7655
- if (!this.observers[event]) return;
7656
- if (!listener) {
7657
- delete this.observers[event];
7658
- return;
7659
- }
7660
- this.observers[event].delete(listener);
7661
- }
7662
- emit(event) {
7663
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7664
- args[_key - 1] = arguments[_key];
7665
- }
7666
- if (this.observers[event]) {
7667
- const cloned = Array.from(this.observers[event].entries());
7668
- cloned.forEach((_ref) => {
7669
- let [observer, numTimesAdded] = _ref;
7670
- for (let i = 0; i < numTimesAdded; i++) {
7671
- observer(...args);
7672
- }
7673
- });
7674
- }
7675
- if (this.observers["*"]) {
7676
- const cloned = Array.from(this.observers["*"].entries());
7677
- cloned.forEach((_ref2) => {
7678
- let [observer, numTimesAdded] = _ref2;
7679
- for (let i = 0; i < numTimesAdded; i++) {
7680
- observer.apply(observer, [event, ...args]);
7681
- }
7682
- });
7683
- }
7684
- }
7401
+ function RepeaterBlock({
7402
+ id,
7403
+ props,
7404
+ data
7405
+ }) {
7406
+ const array = props.itemBlocks;
7407
+ return /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks: array, data });
7685
7408
  }
7686
- class ResourceStore extends EventEmitter {
7687
- constructor(data) {
7688
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
7689
- ns: ["translation"],
7690
- defaultNS: "translation"
7691
- };
7692
- super();
7693
- this.data = data || {};
7694
- this.options = options;
7695
- if (this.options.keySeparator === void 0) {
7696
- this.options.keySeparator = ".";
7697
- }
7698
- if (this.options.ignoreJSONStructure === void 0) {
7699
- this.options.ignoreJSONStructure = true;
7700
- }
7701
- }
7702
- addNamespaces(ns) {
7703
- if (this.options.ns.indexOf(ns) < 0) {
7704
- this.options.ns.push(ns);
7705
- }
7706
- }
7707
- removeNamespaces(ns) {
7708
- const index = this.options.ns.indexOf(ns);
7709
- if (index > -1) {
7710
- this.options.ns.splice(index, 1);
7711
- }
7712
- }
7713
- getResource(lng, ns, key) {
7714
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
7715
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7716
- const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
7717
- let path;
7718
- if (lng.indexOf(".") > -1) {
7719
- path = lng.split(".");
7720
- } else {
7721
- path = [lng, ns];
7722
- if (key) {
7723
- if (Array.isArray(key)) {
7724
- path.push(...key);
7725
- } else if (isString(key) && keySeparator) {
7726
- path.push(...key.split(keySeparator));
7727
- } else {
7728
- path.push(key);
7729
- }
7730
- }
7731
- }
7732
- const result = getPath(this.data, path);
7733
- if (!result && !ns && !key && lng.indexOf(".") > -1) {
7734
- lng = path[0];
7735
- ns = path[1];
7736
- key = path.slice(2).join(".");
7737
- }
7738
- if (result || !ignoreJSONStructure || !isString(key)) return result;
7739
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
7740
- }
7741
- addResource(lng, ns, key, value) {
7742
- let options = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
7743
- silent: false
7744
- };
7745
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7746
- let path = [lng, ns];
7747
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
7748
- if (lng.indexOf(".") > -1) {
7749
- path = lng.split(".");
7750
- value = ns;
7751
- ns = path[1];
7752
- }
7753
- this.addNamespaces(ns);
7754
- setPath(this.data, path, value);
7755
- if (!options.silent) this.emit("added", lng, ns, key, value);
7756
- }
7757
- addResources(lng, ns, resources) {
7758
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
7759
- silent: false
7760
- };
7761
- for (const m in resources) {
7762
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
7763
- silent: true
7764
- });
7765
- }
7766
- if (!options.silent) this.emit("added", lng, ns, resources);
7767
- }
7768
- addResourceBundle(lng, ns, resources, deep, overwrite) {
7769
- let options = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
7770
- silent: false,
7771
- skipCopy: false
7772
- };
7773
- let path = [lng, ns];
7774
- if (lng.indexOf(".") > -1) {
7775
- path = lng.split(".");
7776
- deep = resources;
7777
- resources = ns;
7778
- ns = path[1];
7779
- }
7780
- this.addNamespaces(ns);
7781
- let pack = getPath(this.data, path) || {};
7782
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
7783
- if (deep) {
7784
- deepExtend(pack, resources, overwrite);
7785
- } else {
7786
- pack = {
7787
- ...pack,
7788
- ...resources
7789
- };
7790
- }
7791
- setPath(this.data, path, pack);
7792
- if (!options.silent) this.emit("added", lng, ns, resources);
7793
- }
7794
- removeResourceBundle(lng, ns) {
7795
- if (this.hasResourceBundle(lng, ns)) {
7796
- delete this.data[lng][ns];
7797
- }
7798
- this.removeNamespaces(ns);
7799
- this.emit("removed", lng, ns);
7800
- }
7801
- hasResourceBundle(lng, ns) {
7802
- return this.getResource(lng, ns) !== void 0;
7803
- }
7804
- getResourceBundle(lng, ns) {
7805
- if (!ns) ns = this.options.defaultNS;
7806
- if (this.options.compatibilityAPI === "v1") return {
7807
- ...{},
7808
- ...this.getResource(lng, ns)
7809
- };
7810
- return this.getResource(lng, ns);
7811
- }
7812
- getDataByLanguage(lng) {
7813
- return this.data[lng];
7814
- }
7815
- hasLanguageSomeTranslations(lng) {
7816
- const data = this.getDataByLanguage(lng);
7817
- const n = data && Object.keys(data) || [];
7818
- return !!n.find((v) => data[v] && Object.keys(data[v]).length > 0);
7819
- }
7820
- toJSON() {
7821
- return this.data;
7822
- }
7409
+ function HeadingBlock({
7410
+ id,
7411
+ props,
7412
+ data,
7413
+ isLastBlock,
7414
+ isFirstBlock
7415
+ }) {
7416
+ const className = ui.clx(
7417
+ "text-xl",
7418
+ "font-bold",
7419
+ isLastBlock ? "mb-0" : "mb-4",
7420
+ isFirstBlock ? "mt-0" : "mt-4"
7421
+ );
7422
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Heading, { className, children: props.value });
7823
7423
  }
7824
- var postProcessor = {
7825
- processors: {},
7826
- addPostProcessor(module2) {
7827
- this.processors[module2.name] = module2;
7828
- },
7829
- handle(processors, value, key, options, translator) {
7830
- processors.forEach((processor) => {
7831
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
7832
- });
7833
- return value;
7834
- }
7835
- };
7836
- const checkedLoadedFor = {};
7837
- class Translator extends EventEmitter {
7838
- constructor(services) {
7839
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7840
- super();
7841
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
7842
- this.options = options;
7843
- if (this.options.keySeparator === void 0) {
7844
- this.options.keySeparator = ".";
7845
- }
7846
- this.logger = baseLogger.create("translator");
7847
- }
7848
- changeLanguage(lng) {
7849
- if (lng) this.language = lng;
7850
- }
7851
- exists(key) {
7852
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
7853
- interpolation: {}
7854
- };
7855
- if (key === void 0 || key === null) {
7856
- return false;
7857
- }
7858
- const resolved = this.resolve(key, options);
7859
- return resolved && resolved.res !== void 0;
7860
- }
7861
- extractFromKey(key, options) {
7862
- let nsSeparator = options.nsSeparator !== void 0 ? options.nsSeparator : this.options.nsSeparator;
7863
- if (nsSeparator === void 0) nsSeparator = ":";
7864
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7865
- let namespaces = options.ns || this.options.defaultNS || [];
7866
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
7867
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
7868
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
7869
- const m = key.match(this.interpolator.nestingRegexp);
7870
- if (m && m.length > 0) {
7871
- return {
7872
- key,
7873
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7874
- };
7875
- }
7876
- const parts = key.split(nsSeparator);
7877
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
7878
- key = parts.join(keySeparator);
7879
- }
7880
- return {
7881
- key,
7882
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7883
- };
7884
- }
7885
- translate(keys, options, lastKey) {
7886
- if (typeof options !== "object" && this.options.overloadTranslationOptionHandler) {
7887
- options = this.options.overloadTranslationOptionHandler(arguments);
7888
- }
7889
- if (typeof options === "object") options = {
7890
- ...options
7891
- };
7892
- if (!options) options = {};
7893
- if (keys === void 0 || keys === null) return "";
7894
- if (!Array.isArray(keys)) keys = [String(keys)];
7895
- const returnDetails = options.returnDetails !== void 0 ? options.returnDetails : this.options.returnDetails;
7896
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7897
- const {
7898
- key,
7899
- namespaces
7900
- } = this.extractFromKey(keys[keys.length - 1], options);
7901
- const namespace = namespaces[namespaces.length - 1];
7902
- const lng = options.lng || this.language;
7903
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
7904
- if (lng && lng.toLowerCase() === "cimode") {
7905
- if (appendNamespaceToCIMode) {
7906
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
7907
- if (returnDetails) {
7908
- return {
7909
- res: `${namespace}${nsSeparator}${key}`,
7910
- usedKey: key,
7911
- exactUsedKey: key,
7912
- usedLng: lng,
7913
- usedNS: namespace,
7914
- usedParams: this.getUsedParamsDetails(options)
7915
- };
7916
- }
7917
- return `${namespace}${nsSeparator}${key}`;
7918
- }
7919
- if (returnDetails) {
7920
- return {
7921
- res: key,
7922
- usedKey: key,
7923
- exactUsedKey: key,
7924
- usedLng: lng,
7925
- usedNS: namespace,
7926
- usedParams: this.getUsedParamsDetails(options)
7927
- };
7928
- }
7929
- return key;
7930
- }
7931
- const resolved = this.resolve(keys, options);
7932
- let res = resolved && resolved.res;
7933
- const resUsedKey = resolved && resolved.usedKey || key;
7934
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
7935
- const resType = Object.prototype.toString.apply(res);
7936
- const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
7937
- const joinArrays = options.joinArrays !== void 0 ? options.joinArrays : this.options.joinArrays;
7938
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
7939
- const handleAsObject = !isString(res) && typeof res !== "boolean" && typeof res !== "number";
7940
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
7941
- if (!options.returnObjects && !this.options.returnObjects) {
7942
- if (!this.options.returnedObjectHandler) {
7943
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
7944
- }
7945
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
7946
- ...options,
7947
- ns: namespaces
7948
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
7949
- if (returnDetails) {
7950
- resolved.res = r;
7951
- resolved.usedParams = this.getUsedParamsDetails(options);
7952
- return resolved;
7953
- }
7954
- return r;
7955
- }
7956
- if (keySeparator) {
7957
- const resTypeIsArray = Array.isArray(res);
7958
- const copy2 = resTypeIsArray ? [] : {};
7959
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
7960
- for (const m in res) {
7961
- if (Object.prototype.hasOwnProperty.call(res, m)) {
7962
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
7963
- copy2[m] = this.translate(deepKey, {
7964
- ...options,
7965
- ...{
7966
- joinArrays: false,
7967
- ns: namespaces
7968
- }
7969
- });
7970
- if (copy2[m] === deepKey) copy2[m] = res[m];
7971
- }
7972
- }
7973
- res = copy2;
7974
- }
7975
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
7976
- res = res.join(joinArrays);
7977
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
7978
- } else {
7979
- let usedDefault = false;
7980
- let usedKey = false;
7981
- const needsPluralHandling = options.count !== void 0 && !isString(options.count);
7982
- const hasDefaultValue = Translator.hasDefaultValue(options);
7983
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : "";
7984
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
7985
- ordinal: false
7986
- }) : "";
7987
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
7988
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
7989
- if (!this.isValidLookup(res) && hasDefaultValue) {
7990
- usedDefault = true;
7991
- res = defaultValue;
7992
- }
7993
- if (!this.isValidLookup(res)) {
7994
- usedKey = true;
7995
- res = key;
7996
- }
7997
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
7998
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
7999
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
8000
- if (usedKey || usedDefault || updateMissing) {
8001
- this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
8002
- if (keySeparator) {
8003
- const fk = this.resolve(key, {
8004
- ...options,
8005
- keySeparator: false
8006
- });
8007
- if (fk && fk.res) this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
8008
- }
8009
- let lngs = [];
8010
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
8011
- if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
8012
- for (let i = 0; i < fallbackLngs.length; i++) {
8013
- lngs.push(fallbackLngs[i]);
8014
- }
8015
- } else if (this.options.saveMissingTo === "all") {
8016
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
8017
- } else {
8018
- lngs.push(options.lng || this.language);
8019
- }
8020
- const send = (l, k, specificDefaultValue) => {
8021
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
8022
- if (this.options.missingKeyHandler) {
8023
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
8024
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
8025
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
8026
- }
8027
- this.emit("missingKey", l, namespace, k, res);
8028
- };
8029
- if (this.options.saveMissing) {
8030
- if (this.options.saveMissingPlurals && needsPluralHandling) {
8031
- lngs.forEach((language) => {
8032
- const suffixes = this.pluralResolver.getSuffixes(language, options);
8033
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
8034
- suffixes.push(`${this.options.pluralSeparator}zero`);
8035
- }
8036
- suffixes.forEach((suffix) => {
8037
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
8038
- });
8039
- });
8040
- } else {
8041
- send(lngs, key, defaultValue);
8042
- }
8043
- }
8044
- }
8045
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
8046
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
8047
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8048
- if (this.options.compatibilityAPI !== "v1") {
8049
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0);
8050
- } else {
8051
- res = this.options.parseMissingKeyHandler(res);
8052
- }
8053
- }
8054
- }
8055
- if (returnDetails) {
8056
- resolved.res = res;
8057
- resolved.usedParams = this.getUsedParamsDetails(options);
8058
- return resolved;
8059
- }
8060
- return res;
8061
- }
8062
- extendTranslation(res, key, options, resolved, lastKey) {
8063
- var _this = this;
8064
- if (this.i18nFormat && this.i18nFormat.parse) {
8065
- res = this.i18nFormat.parse(res, {
8066
- ...this.options.interpolation.defaultVariables,
8067
- ...options
8068
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
8069
- resolved
8070
- });
8071
- } else if (!options.skipInterpolation) {
8072
- if (options.interpolation) this.interpolator.init({
8073
- ...options,
8074
- ...{
8075
- interpolation: {
8076
- ...this.options.interpolation,
8077
- ...options.interpolation
8078
- }
8079
- }
8080
- });
8081
- const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
8082
- let nestBef;
8083
- if (skipOnVariables) {
8084
- const nb = res.match(this.interpolator.nestingRegexp);
8085
- nestBef = nb && nb.length;
8086
- }
8087
- let data = options.replace && !isString(options.replace) ? options.replace : options;
8088
- if (this.options.interpolation.defaultVariables) data = {
8089
- ...this.options.interpolation.defaultVariables,
8090
- ...data
8091
- };
8092
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
8093
- if (skipOnVariables) {
8094
- const na = res.match(this.interpolator.nestingRegexp);
8095
- const nestAft = na && na.length;
8096
- if (nestBef < nestAft) options.nest = false;
8097
- }
8098
- if (!options.lng && this.options.compatibilityAPI !== "v1" && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
8099
- if (options.nest !== false) res = this.interpolator.nest(res, function() {
8100
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8101
- args[_key] = arguments[_key];
8102
- }
8103
- if (lastKey && lastKey[0] === args[0] && !options.context) {
8104
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
7424
+ function RowBlock({
7425
+ id,
7426
+ props,
7427
+ data,
7428
+ isLastBlock,
7429
+ isFirstBlock
7430
+ }) {
7431
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Row, { children: [
7432
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "font-semibold", children: props.label }),
7433
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "text-right", children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7434
+ ] });
7435
+ }
7436
+ function SeparatorBlock({
7437
+ id,
7438
+ props,
7439
+ isLastBlock,
7440
+ isFirstBlock
7441
+ }) {
7442
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Hr, { className: "my-4 border-ui-border" });
7443
+ }
7444
+ function ProductItemBlock({
7445
+ props,
7446
+ data,
7447
+ isLastBlock,
7448
+ isFirstBlock
7449
+ }) {
7450
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Row, { children: [
7451
+ props.thumbnail && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7452
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "w-[50px]", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: props.thumbnail, width: 50, height: 50 }) }),
7453
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "w-[12px]" })
7454
+ ] }),
7455
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "text-left", children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7456
+ ] });
7457
+ }
7458
+ function BlockRenderer({ blocks, data }) {
7459
+ return blocks.map((block, index) => {
7460
+ const blockKey = block.id || `block-${index}`;
7461
+ const isLastBlock = index === blocks.length - 1;
7462
+ const isFirstBlock = index === 0;
7463
+ switch (block.type) {
7464
+ case "section":
7465
+ return /* @__PURE__ */ jsxRuntime.jsx(
7466
+ SectionBlock,
7467
+ {
7468
+ id: blockKey,
7469
+ props: block.props,
7470
+ data,
7471
+ isLastBlock,
7472
+ isFirstBlock
7473
+ },
7474
+ blockKey
7475
+ );
7476
+ case "row":
7477
+ return /* @__PURE__ */ jsxRuntime.jsx(
7478
+ RowBlock,
7479
+ {
7480
+ id: blockKey,
7481
+ props: block.props,
7482
+ data,
7483
+ isLastBlock,
7484
+ isFirstBlock
7485
+ },
7486
+ blockKey
7487
+ );
7488
+ case "product-item":
7489
+ return /* @__PURE__ */ jsxRuntime.jsx(
7490
+ ProductItemBlock,
7491
+ {
7492
+ id: blockKey,
7493
+ props: block.props,
7494
+ data,
7495
+ isLastBlock,
7496
+ isFirstBlock
7497
+ },
7498
+ blockKey
7499
+ );
7500
+ case "heading":
7501
+ return /* @__PURE__ */ jsxRuntime.jsx(
7502
+ HeadingBlock,
7503
+ {
7504
+ id: blockKey,
7505
+ props: block.props,
7506
+ data,
7507
+ isLastBlock,
7508
+ isFirstBlock
7509
+ },
7510
+ blockKey
7511
+ );
7512
+ case "text":
7513
+ return /* @__PURE__ */ jsxRuntime.jsx(
7514
+ TextBlock,
7515
+ {
7516
+ id: blockKey,
7517
+ props: block.props,
7518
+ isLastBlock,
7519
+ isFirstBlock
7520
+ },
7521
+ blockKey
7522
+ );
7523
+ case "separator":
7524
+ return /* @__PURE__ */ jsxRuntime.jsx(
7525
+ SeparatorBlock,
7526
+ {
7527
+ id: blockKey,
7528
+ props: block.props,
7529
+ isLastBlock,
7530
+ isFirstBlock
7531
+ },
7532
+ blockKey
7533
+ );
7534
+ case "repeater":
7535
+ if (!data) {
7536
+ console.warn("RepeaterBlock requires data prop");
8105
7537
  return null;
8106
7538
  }
8107
- return _this.translate(...args, key);
8108
- }, options);
8109
- if (options.interpolation) this.interpolator.reset();
7539
+ return /* @__PURE__ */ jsxRuntime.jsx(
7540
+ RepeaterBlock,
7541
+ {
7542
+ id: blockKey,
7543
+ props: block.props,
7544
+ data
7545
+ },
7546
+ blockKey
7547
+ );
7548
+ default:
7549
+ return null;
8110
7550
  }
8111
- const postProcess = options.postProcess || this.options.postProcess;
8112
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
8113
- if (res !== void 0 && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
8114
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
8115
- i18nResolved: {
8116
- ...resolved,
8117
- usedParams: this.getUsedParamsDetails(options)
7551
+ });
7552
+ }
7553
+ function renderHTMLReact(data, options) {
7554
+ const theme = options.theme || {};
7555
+ const blocks = options.blocks || [];
7556
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Html, { children: [
7557
+ /* @__PURE__ */ jsxRuntime.jsx(components.Head, {}),
7558
+ /* @__PURE__ */ jsxRuntime.jsx(
7559
+ components.Tailwind,
7560
+ {
7561
+ config: {
7562
+ presets: [components.pixelBasedPreset],
7563
+ theme
8118
7564
  },
8119
- ...options
8120
- } : options, this);
8121
- }
8122
- return res;
8123
- }
8124
- resolve(keys) {
8125
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8126
- let found;
8127
- let usedKey;
8128
- let exactUsedKey;
8129
- let usedLng;
8130
- let usedNS;
8131
- if (isString(keys)) keys = [keys];
8132
- keys.forEach((k) => {
8133
- if (this.isValidLookup(found)) return;
8134
- const extracted = this.extractFromKey(k, options);
8135
- const key = extracted.key;
8136
- usedKey = key;
8137
- let namespaces = extracted.namespaces;
8138
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
8139
- const needsPluralHandling = options.count !== void 0 && !isString(options.count);
8140
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
8141
- const needsContextHandling = options.context !== void 0 && (isString(options.context) || typeof options.context === "number") && options.context !== "";
8142
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
8143
- namespaces.forEach((ns) => {
8144
- if (this.isValidLookup(found)) return;
8145
- usedNS = ns;
8146
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
8147
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
8148
- this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
8149
- }
8150
- codes.forEach((code) => {
8151
- if (this.isValidLookup(found)) return;
8152
- usedLng = code;
8153
- const finalKeys = [key];
8154
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
8155
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
8156
- } else {
8157
- let pluralSuffix;
8158
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
8159
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
8160
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
8161
- if (needsPluralHandling) {
8162
- finalKeys.push(key + pluralSuffix);
8163
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8164
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8165
- }
8166
- if (needsZeroSuffixLookup) {
8167
- finalKeys.push(key + zeroSuffix);
8168
- }
8169
- }
8170
- if (needsContextHandling) {
8171
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
8172
- finalKeys.push(contextKey);
8173
- if (needsPluralHandling) {
8174
- finalKeys.push(contextKey + pluralSuffix);
8175
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8176
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8177
- }
8178
- if (needsZeroSuffixLookup) {
8179
- finalKeys.push(contextKey + zeroSuffix);
8180
- }
8181
- }
8182
- }
8183
- }
8184
- let possibleKey;
8185
- while (possibleKey = finalKeys.pop()) {
8186
- if (!this.isValidLookup(found)) {
8187
- exactUsedKey = possibleKey;
8188
- found = this.getResource(code, ns, possibleKey, options);
8189
- }
8190
- }
8191
- });
8192
- });
8193
- });
8194
- return {
8195
- res: found,
8196
- usedKey,
8197
- exactUsedKey,
8198
- usedLng,
8199
- usedNS
8200
- };
8201
- }
8202
- isValidLookup(res) {
8203
- return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
8204
- }
8205
- getResource(code, ns, key) {
8206
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8207
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
8208
- return this.resourceStore.getResource(code, ns, key, options);
8209
- }
8210
- getUsedParamsDetails() {
8211
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8212
- const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
8213
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
8214
- let data = useOptionsReplaceForData ? options.replace : options;
8215
- if (useOptionsReplaceForData && typeof options.count !== "undefined") {
8216
- data.count = options.count;
8217
- }
8218
- if (this.options.interpolation.defaultVariables) {
8219
- data = {
8220
- ...this.options.interpolation.defaultVariables,
8221
- ...data
8222
- };
8223
- }
8224
- if (!useOptionsReplaceForData) {
8225
- data = {
8226
- ...data
8227
- };
8228
- for (const key of optionsKeys) {
8229
- delete data[key];
8230
- }
8231
- }
8232
- return data;
8233
- }
8234
- static hasDefaultValue(options) {
8235
- const prefix = "defaultValue";
8236
- for (const option in options) {
8237
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && void 0 !== options[option]) {
8238
- return true;
7565
+ children: /* @__PURE__ */ jsxRuntime.jsx(components.Body, { className: "mx-auto my-auto px-4 font-arial font-normal text-base bg-ui-bg text-ui-text", children: /* @__PURE__ */ jsxRuntime.jsx(components.Container, { className: "py-4", children: /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks, data }) }) })
8239
7566
  }
8240
- }
8241
- return false;
8242
- }
7567
+ )
7568
+ ] });
8243
7569
  }
8244
- const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
8245
- class LanguageUtil {
8246
- constructor(options) {
8247
- this.options = options;
8248
- this.supportedLngs = this.options.supportedLngs || false;
8249
- this.logger = baseLogger.create("languageUtils");
8250
- }
8251
- getScriptPartFromCode(code) {
8252
- code = getCleanedCode(code);
8253
- if (!code || code.indexOf("-") < 0) return null;
8254
- const p = code.split("-");
8255
- if (p.length === 2) return null;
8256
- p.pop();
8257
- if (p[p.length - 1].toLowerCase() === "x") return null;
8258
- return this.formatLanguageCode(p.join("-"));
8259
- }
8260
- getLanguagePartFromCode(code) {
8261
- code = getCleanedCode(code);
8262
- if (!code || code.indexOf("-") < 0) return code;
8263
- const p = code.split("-");
8264
- return this.formatLanguageCode(p[0]);
8265
- }
8266
- formatLanguageCode(code) {
8267
- if (isString(code) && code.indexOf("-") > -1) {
8268
- if (typeof Intl !== "undefined" && typeof Intl.getCanonicalLocales !== "undefined") {
8269
- try {
8270
- let formattedCode = Intl.getCanonicalLocales(code)[0];
8271
- if (formattedCode && this.options.lowerCaseLng) {
8272
- formattedCode = formattedCode.toLowerCase();
8273
- }
8274
- if (formattedCode) return formattedCode;
8275
- } catch (e) {
8276
- }
8277
- }
8278
- const specialCases = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
8279
- let p = code.split("-");
8280
- if (this.options.lowerCaseLng) {
8281
- p = p.map((part) => part.toLowerCase());
8282
- } else if (p.length === 2) {
8283
- p[0] = p[0].toLowerCase();
8284
- p[1] = p[1].toUpperCase();
8285
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
8286
- } else if (p.length === 3) {
8287
- p[0] = p[0].toLowerCase();
8288
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
8289
- if (p[0] !== "sgn" && p[2].length === 2) p[2] = p[2].toUpperCase();
8290
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
8291
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
8292
- }
8293
- return p.join("-");
8294
- }
8295
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
8296
- }
8297
- isSupportedCode(code) {
8298
- if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
8299
- code = this.getLanguagePartFromCode(code);
8300
- }
8301
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
8302
- }
8303
- getBestMatchFromCodes(codes) {
8304
- if (!codes) return null;
8305
- let found;
8306
- codes.forEach((code) => {
8307
- if (found) return;
8308
- const cleanedLng = this.formatLanguageCode(code);
8309
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
8310
- });
8311
- if (!found && this.options.supportedLngs) {
8312
- codes.forEach((code) => {
8313
- if (found) return;
8314
- const lngOnly = this.getLanguagePartFromCode(code);
8315
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
8316
- found = this.options.supportedLngs.find((supportedLng) => {
8317
- if (supportedLng === lngOnly) return supportedLng;
8318
- if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
8319
- if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
8320
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
8321
- });
8322
- });
7570
+ async function renderHTML(data, options) {
7571
+ return await render.pretty(await render.render(renderHTMLReact(data, options)));
7572
+ }
7573
+ async function renderText(data, options) {
7574
+ const html = await render.render(renderHTMLReact(data, options));
7575
+ return render.toPlainText(html);
7576
+ }
7577
+ async function getBaseTemplateHtml(data, options) {
7578
+ return await renderHTML(data, options);
7579
+ }
7580
+ async function getBaseTemplateText(data, options) {
7581
+ return await renderText(data, options);
7582
+ }
7583
+ function getBaseTemplateReactNode(data, options) {
7584
+ return renderHTMLReact(data, options);
7585
+ }
7586
+ const TEMPLATES_NAMES = {
7587
+ BASE_TEMPLATE: "base-template",
7588
+ INVENTORY_LEVEL: "inventory-level",
7589
+ ORDER_PLACED: "order-placed",
7590
+ ORDER_COMPLETED: "order-completed",
7591
+ CONTACT_FORM: "contact-form"
7592
+ };
7593
+ const baseTemplateConfig = {
7594
+ [TEMPLATES_NAMES.BASE_TEMPLATE]: {
7595
+ getHtml: async (data, options) => {
7596
+ return await getBaseTemplateHtml(data, options);
7597
+ },
7598
+ getText: async (data, options) => {
7599
+ return await getBaseTemplateText(data, options);
7600
+ },
7601
+ getReactNode: (data, options) => {
7602
+ return getBaseTemplateReactNode(data, options);
8323
7603
  }
8324
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
8325
- return found;
8326
7604
  }
8327
- getFallbackCodes(fallbacks, code) {
8328
- if (!fallbacks) return [];
8329
- if (typeof fallbacks === "function") fallbacks = fallbacks(code);
8330
- if (isString(fallbacks)) fallbacks = [fallbacks];
8331
- if (Array.isArray(fallbacks)) return fallbacks;
8332
- if (!code) return fallbacks.default || [];
8333
- let found = fallbacks[code];
8334
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
8335
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
8336
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
8337
- if (!found) found = fallbacks.default;
8338
- return found || [];
8339
- }
8340
- toResolveHierarchy(code, fallbackCode) {
8341
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
8342
- const codes = [];
8343
- const addCode = (c) => {
8344
- if (!c) return;
8345
- if (this.isSupportedCode(c)) {
8346
- codes.push(c);
8347
- } else {
8348
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
8349
- }
8350
- };
8351
- if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
8352
- if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
8353
- if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
8354
- if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
8355
- } else if (isString(code)) {
8356
- addCode(this.formatLanguageCode(code));
8357
- }
8358
- fallbackCodes.forEach((fc) => {
8359
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
8360
- });
8361
- return codes;
8362
- }
8363
- }
8364
- let sets = [{
8365
- lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
8366
- nr: [1, 2],
8367
- fc: 1
8368
- }, {
8369
- lngs: ["af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "hu", "hy", "ia", "it", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "ps", "pt-PT", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ta", "te", "tk", "ur", "yo"],
8370
- nr: [1, 2],
8371
- fc: 2
8372
- }, {
8373
- lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
8374
- nr: [1],
8375
- fc: 3
8376
- }, {
8377
- lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
8378
- nr: [1, 2, 5],
8379
- fc: 4
8380
- }, {
8381
- lngs: ["ar"],
8382
- nr: [0, 1, 2, 3, 11, 100],
8383
- fc: 5
8384
- }, {
8385
- lngs: ["cs", "sk"],
8386
- nr: [1, 2, 5],
8387
- fc: 6
8388
- }, {
8389
- lngs: ["csb", "pl"],
8390
- nr: [1, 2, 5],
8391
- fc: 7
8392
- }, {
8393
- lngs: ["cy"],
8394
- nr: [1, 2, 3, 8],
8395
- fc: 8
8396
- }, {
8397
- lngs: ["fr"],
8398
- nr: [1, 2],
8399
- fc: 9
8400
- }, {
8401
- lngs: ["ga"],
8402
- nr: [1, 2, 3, 7, 11],
8403
- fc: 10
8404
- }, {
8405
- lngs: ["gd"],
8406
- nr: [1, 2, 3, 20],
8407
- fc: 11
8408
- }, {
8409
- lngs: ["is"],
8410
- nr: [1, 2],
8411
- fc: 12
8412
- }, {
8413
- lngs: ["jv"],
8414
- nr: [0, 1],
8415
- fc: 13
8416
- }, {
8417
- lngs: ["kw"],
8418
- nr: [1, 2, 3, 4],
8419
- fc: 14
8420
- }, {
8421
- lngs: ["lt"],
8422
- nr: [1, 2, 10],
8423
- fc: 15
8424
- }, {
8425
- lngs: ["lv"],
8426
- nr: [1, 2, 0],
8427
- fc: 16
8428
- }, {
8429
- lngs: ["mk"],
8430
- nr: [1, 2],
8431
- fc: 17
8432
- }, {
8433
- lngs: ["mnk"],
8434
- nr: [0, 1, 2],
8435
- fc: 18
8436
- }, {
8437
- lngs: ["mt"],
8438
- nr: [1, 2, 11, 20],
8439
- fc: 19
8440
- }, {
8441
- lngs: ["or"],
8442
- nr: [2, 1],
8443
- fc: 2
8444
- }, {
8445
- lngs: ["ro"],
8446
- nr: [1, 2, 20],
8447
- fc: 20
8448
- }, {
8449
- lngs: ["sl"],
8450
- nr: [5, 1, 2, 3],
8451
- fc: 21
8452
- }, {
8453
- lngs: ["he", "iw"],
8454
- nr: [1, 2, 20, 21],
8455
- fc: 22
8456
- }];
8457
- let _rulesPluralsTypes = {
8458
- 1: (n) => Number(n > 1),
8459
- 2: (n) => Number(n != 1),
8460
- 3: (n) => 0,
8461
- 4: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8462
- 5: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
8463
- 6: (n) => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
8464
- 7: (n) => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8465
- 8: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
8466
- 9: (n) => Number(n >= 2),
8467
- 10: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
8468
- 11: (n) => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
8469
- 12: (n) => Number(n % 10 != 1 || n % 100 == 11),
8470
- 13: (n) => Number(n !== 0),
8471
- 14: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
8472
- 15: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8473
- 16: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
8474
- 17: (n) => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
8475
- 18: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
8476
- 19: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
8477
- 20: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
8478
- 21: (n) => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
8479
- 22: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
8480
- };
8481
- const nonIntlVersions = ["v1", "v2", "v3"];
8482
- const intlVersions = ["v4"];
8483
- const suffixesOrder = {
8484
- zero: 0,
8485
- one: 1,
8486
- two: 2,
8487
- few: 3,
8488
- many: 4,
8489
- other: 5
8490
- };
8491
- const createRules = () => {
8492
- const rules = {};
8493
- sets.forEach((set) => {
8494
- set.lngs.forEach((l) => {
8495
- rules[l] = {
8496
- numbers: set.nr,
8497
- plurals: _rulesPluralsTypes[set.fc]
8498
- };
8499
- });
8500
- });
8501
- return rules;
8502
- };
8503
- class PluralResolver {
8504
- constructor(languageUtils) {
8505
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8506
- this.languageUtils = languageUtils;
8507
- this.options = options;
8508
- this.logger = baseLogger.create("pluralResolver");
8509
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === "undefined" || !Intl.PluralRules)) {
8510
- this.options.compatibilityJSON = "v3";
8511
- this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.");
8512
- }
8513
- this.rules = createRules();
8514
- this.pluralRulesCache = {};
8515
- }
8516
- addRule(lng, obj) {
8517
- this.rules[lng] = obj;
8518
- }
8519
- clearCache() {
8520
- this.pluralRulesCache = {};
8521
- }
8522
- getRule(code) {
8523
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8524
- if (this.shouldUseIntlApi()) {
8525
- const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
8526
- const type = options.ordinal ? "ordinal" : "cardinal";
8527
- const cacheKey = JSON.stringify({
8528
- cleanedCode,
8529
- type
8530
- });
8531
- if (cacheKey in this.pluralRulesCache) {
8532
- return this.pluralRulesCache[cacheKey];
8533
- }
8534
- let rule;
8535
- try {
8536
- rule = new Intl.PluralRules(cleanedCode, {
8537
- type
8538
- });
8539
- } catch (err) {
8540
- if (!code.match(/-|_/)) return;
8541
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
8542
- rule = this.getRule(lngPart, options);
8543
- }
8544
- this.pluralRulesCache[cacheKey] = rule;
8545
- return rule;
8546
- }
8547
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
8548
- }
8549
- needsPlural(code) {
8550
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8551
- const rule = this.getRule(code, options);
8552
- if (this.shouldUseIntlApi()) {
8553
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
8554
- }
8555
- return rule && rule.numbers.length > 1;
8556
- }
8557
- getPluralFormsOfKey(code, key) {
8558
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8559
- return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
8560
- }
8561
- getSuffixes(code) {
8562
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8563
- const rule = this.getRule(code, options);
8564
- if (!rule) {
8565
- return [];
8566
- }
8567
- if (this.shouldUseIntlApi()) {
8568
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
8569
- }
8570
- return rule.numbers.map((number) => this.getSuffix(code, number, options));
8571
- }
8572
- getSuffix(code, count) {
8573
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8574
- const rule = this.getRule(code, options);
8575
- if (rule) {
8576
- if (this.shouldUseIntlApi()) {
8577
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
8578
- }
8579
- return this.getSuffixRetroCompatible(rule, count);
8580
- }
8581
- this.logger.warn(`no plural rule found for: ${code}`);
8582
- return "";
8583
- }
8584
- getSuffixRetroCompatible(rule, count) {
8585
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
8586
- let suffix = rule.numbers[idx];
8587
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
8588
- if (suffix === 2) {
8589
- suffix = "plural";
8590
- } else if (suffix === 1) {
8591
- suffix = "";
8592
- }
8593
- }
8594
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
8595
- if (this.options.compatibilityJSON === "v1") {
8596
- if (suffix === 1) return "";
8597
- if (typeof suffix === "number") return `_plural_${suffix.toString()}`;
8598
- return returnSuffix();
8599
- } else if (this.options.compatibilityJSON === "v2") {
8600
- return returnSuffix();
8601
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
8602
- return returnSuffix();
8603
- }
8604
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
8605
- }
8606
- shouldUseIntlApi() {
8607
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
8608
- }
8609
- }
8610
- const deepFindWithDefaults = function(data, defaultData, key) {
8611
- let keySeparator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".";
8612
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
8613
- let path = getPathWithDefaults(data, defaultData, key);
8614
- if (!path && ignoreJSONStructure && isString(key)) {
8615
- path = deepFind(data, key, keySeparator);
8616
- if (path === void 0) path = deepFind(defaultData, key, keySeparator);
8617
- }
8618
- return path;
8619
- };
8620
- const regexSafe = (val) => val.replace(/\$/g, "$$$$");
8621
- class Interpolator {
8622
- constructor() {
8623
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8624
- this.logger = baseLogger.create("interpolator");
8625
- this.options = options;
8626
- this.format = options.interpolation && options.interpolation.format || ((value) => value);
8627
- this.init(options);
8628
- }
8629
- init() {
8630
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8631
- if (!options.interpolation) options.interpolation = {
8632
- escapeValue: true
8633
- };
8634
- const {
8635
- escape: escape$1,
8636
- escapeValue,
8637
- useRawValueToEscape,
8638
- prefix,
8639
- prefixEscaped,
8640
- suffix,
8641
- suffixEscaped,
8642
- formatSeparator,
8643
- unescapeSuffix,
8644
- unescapePrefix,
8645
- nestingPrefix,
8646
- nestingPrefixEscaped,
8647
- nestingSuffix,
8648
- nestingSuffixEscaped,
8649
- nestingOptionsSeparator,
8650
- maxReplaces,
8651
- alwaysFormat
8652
- } = options.interpolation;
8653
- this.escape = escape$1 !== void 0 ? escape$1 : escape;
8654
- this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
8655
- this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
8656
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
8657
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
8658
- this.formatSeparator = formatSeparator || ",";
8659
- this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
8660
- this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
8661
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
8662
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
8663
- this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
8664
- this.maxReplaces = maxReplaces || 1e3;
8665
- this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
8666
- this.resetRegExp();
8667
- }
8668
- reset() {
8669
- if (this.options) this.init(this.options);
8670
- }
8671
- resetRegExp() {
8672
- const getOrResetRegExp = (existingRegExp, pattern) => {
8673
- if (existingRegExp && existingRegExp.source === pattern) {
8674
- existingRegExp.lastIndex = 0;
8675
- return existingRegExp;
8676
- }
8677
- return new RegExp(pattern, "g");
8678
- };
8679
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
8680
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
8681
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
8682
- }
8683
- interpolate(str, data, lng, options) {
8684
- let match2;
8685
- let value;
8686
- let replaces;
8687
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
8688
- const handleFormat = (key) => {
8689
- if (key.indexOf(this.formatSeparator) < 0) {
8690
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
8691
- return this.alwaysFormat ? this.format(path, void 0, lng, {
8692
- ...options,
8693
- ...data,
8694
- interpolationkey: key
8695
- }) : path;
8696
- }
8697
- const p = key.split(this.formatSeparator);
8698
- const k = p.shift().trim();
8699
- const f = p.join(this.formatSeparator).trim();
8700
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
8701
- ...options,
8702
- ...data,
8703
- interpolationkey: k
8704
- });
8705
- };
8706
- this.resetRegExp();
8707
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
8708
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
8709
- const todos = [{
8710
- regex: this.regexpUnescape,
8711
- safeValue: (val) => regexSafe(val)
8712
- }, {
8713
- regex: this.regexp,
8714
- safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
8715
- }];
8716
- todos.forEach((todo) => {
8717
- replaces = 0;
8718
- while (match2 = todo.regex.exec(str)) {
8719
- const matchedVar = match2[1].trim();
8720
- value = handleFormat(matchedVar);
8721
- if (value === void 0) {
8722
- if (typeof missingInterpolationHandler === "function") {
8723
- const temp = missingInterpolationHandler(str, match2, options);
8724
- value = isString(temp) ? temp : "";
8725
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
8726
- value = "";
8727
- } else if (skipOnVariables) {
8728
- value = match2[0];
8729
- continue;
8730
- } else {
8731
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
8732
- value = "";
8733
- }
8734
- } else if (!isString(value) && !this.useRawValueToEscape) {
8735
- value = makeString(value);
8736
- }
8737
- const safeValue = todo.safeValue(value);
8738
- str = str.replace(match2[0], safeValue);
8739
- if (skipOnVariables) {
8740
- todo.regex.lastIndex += value.length;
8741
- todo.regex.lastIndex -= match2[0].length;
8742
- } else {
8743
- todo.regex.lastIndex = 0;
8744
- }
8745
- replaces++;
8746
- if (replaces >= this.maxReplaces) {
8747
- break;
8748
- }
8749
- }
8750
- });
8751
- return str;
8752
- }
8753
- nest(str, fc) {
8754
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8755
- let match2;
8756
- let value;
8757
- let clonedOptions;
8758
- const handleHasOptions = (key, inheritedOptions) => {
8759
- const sep = this.nestingOptionsSeparator;
8760
- if (key.indexOf(sep) < 0) return key;
8761
- const c = key.split(new RegExp(`${sep}[ ]*{`));
8762
- let optionsString = `{${c[1]}`;
8763
- key = c[0];
8764
- optionsString = this.interpolate(optionsString, clonedOptions);
8765
- const matchedSingleQuotes = optionsString.match(/'/g);
8766
- const matchedDoubleQuotes = optionsString.match(/"/g);
8767
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
8768
- optionsString = optionsString.replace(/'/g, '"');
8769
- }
8770
- try {
8771
- clonedOptions = JSON.parse(optionsString);
8772
- if (inheritedOptions) clonedOptions = {
8773
- ...inheritedOptions,
8774
- ...clonedOptions
8775
- };
8776
- } catch (e) {
8777
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
8778
- return `${key}${sep}${optionsString}`;
8779
- }
8780
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
8781
- return key;
8782
- };
8783
- while (match2 = this.nestingRegexp.exec(str)) {
8784
- let formatters2 = [];
8785
- clonedOptions = {
8786
- ...options
8787
- };
8788
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
8789
- clonedOptions.applyPostProcessor = false;
8790
- delete clonedOptions.defaultValue;
8791
- let doReduce = false;
8792
- if (match2[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match2[1])) {
8793
- const r = match2[1].split(this.formatSeparator).map((elem) => elem.trim());
8794
- match2[1] = r.shift();
8795
- formatters2 = r;
8796
- doReduce = true;
8797
- }
8798
- value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
8799
- if (value && match2[0] === str && !isString(value)) return value;
8800
- if (!isString(value)) value = makeString(value);
8801
- if (!value) {
8802
- this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
8803
- value = "";
8804
- }
8805
- if (doReduce) {
8806
- value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
8807
- ...options,
8808
- interpolationkey: match2[1].trim()
8809
- }), value.trim());
8810
- }
8811
- str = str.replace(match2[0], value);
8812
- this.regexp.lastIndex = 0;
8813
- }
8814
- return str;
8815
- }
8816
- }
8817
- const parseFormatStr = (formatStr) => {
8818
- let formatName = formatStr.toLowerCase().trim();
8819
- const formatOptions = {};
8820
- if (formatStr.indexOf("(") > -1) {
8821
- const p = formatStr.split("(");
8822
- formatName = p[0].toLowerCase().trim();
8823
- const optStr = p[1].substring(0, p[1].length - 1);
8824
- if (formatName === "currency" && optStr.indexOf(":") < 0) {
8825
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
8826
- } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
8827
- if (!formatOptions.range) formatOptions.range = optStr.trim();
8828
- } else {
8829
- const opts = optStr.split(";");
8830
- opts.forEach((opt) => {
8831
- if (opt) {
8832
- const [key, ...rest] = opt.split(":");
8833
- const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
8834
- const trimmedKey = key.trim();
8835
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
8836
- if (val === "false") formatOptions[trimmedKey] = false;
8837
- if (val === "true") formatOptions[trimmedKey] = true;
8838
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
8839
- }
8840
- });
8841
- }
8842
- }
8843
- return {
8844
- formatName,
8845
- formatOptions
8846
- };
8847
- };
8848
- const createCachedFormatter = (fn) => {
8849
- const cache = {};
8850
- return (val, lng, options) => {
8851
- let optForCache = options;
8852
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
8853
- optForCache = {
8854
- ...optForCache,
8855
- [options.interpolationkey]: void 0
8856
- };
8857
- }
8858
- const key = lng + JSON.stringify(optForCache);
8859
- let formatter = cache[key];
8860
- if (!formatter) {
8861
- formatter = fn(getCleanedCode(lng), options);
8862
- cache[key] = formatter;
8863
- }
8864
- return formatter(val);
8865
- };
8866
- };
8867
- class Formatter {
8868
- constructor() {
8869
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8870
- this.logger = baseLogger.create("formatter");
8871
- this.options = options;
8872
- this.formats = {
8873
- number: createCachedFormatter((lng, opt) => {
8874
- const formatter = new Intl.NumberFormat(lng, {
8875
- ...opt
8876
- });
8877
- return (val) => formatter.format(val);
8878
- }),
8879
- currency: createCachedFormatter((lng, opt) => {
8880
- const formatter = new Intl.NumberFormat(lng, {
8881
- ...opt,
8882
- style: "currency"
8883
- });
8884
- return (val) => formatter.format(val);
8885
- }),
8886
- datetime: createCachedFormatter((lng, opt) => {
8887
- const formatter = new Intl.DateTimeFormat(lng, {
8888
- ...opt
8889
- });
8890
- return (val) => formatter.format(val);
8891
- }),
8892
- relativetime: createCachedFormatter((lng, opt) => {
8893
- const formatter = new Intl.RelativeTimeFormat(lng, {
8894
- ...opt
8895
- });
8896
- return (val) => formatter.format(val, opt.range || "day");
8897
- }),
8898
- list: createCachedFormatter((lng, opt) => {
8899
- const formatter = new Intl.ListFormat(lng, {
8900
- ...opt
8901
- });
8902
- return (val) => formatter.format(val);
8903
- })
8904
- };
8905
- this.init(options);
8906
- }
8907
- init(services) {
8908
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8909
- interpolation: {}
8910
- };
8911
- this.formatSeparator = options.interpolation.formatSeparator || ",";
8912
- }
8913
- add(name, fc) {
8914
- this.formats[name.toLowerCase().trim()] = fc;
8915
- }
8916
- addCached(name, fc) {
8917
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
8918
- }
8919
- format(value, format2, lng) {
8920
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8921
- const formats = format2.split(this.formatSeparator);
8922
- if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
8923
- const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
8924
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
8925
- }
8926
- const result = formats.reduce((mem, f) => {
8927
- const {
8928
- formatName,
8929
- formatOptions
8930
- } = parseFormatStr(f);
8931
- if (this.formats[formatName]) {
8932
- let formatted = mem;
8933
- try {
8934
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
8935
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
8936
- formatted = this.formats[formatName](mem, l, {
8937
- ...formatOptions,
8938
- ...options,
8939
- ...valOptions
8940
- });
8941
- } catch (error) {
8942
- this.logger.warn(error);
8943
- }
8944
- return formatted;
8945
- } else {
8946
- this.logger.warn(`there was no format function for ${formatName}`);
8947
- }
8948
- return mem;
8949
- }, value);
8950
- return result;
8951
- }
8952
- }
8953
- const removePending = (q, name) => {
8954
- if (q.pending[name] !== void 0) {
8955
- delete q.pending[name];
8956
- q.pendingCount--;
8957
- }
8958
- };
8959
- class Connector extends EventEmitter {
8960
- constructor(backend, store, services) {
8961
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8962
- super();
8963
- this.backend = backend;
8964
- this.store = store;
8965
- this.services = services;
8966
- this.languageUtils = services.languageUtils;
8967
- this.options = options;
8968
- this.logger = baseLogger.create("backendConnector");
8969
- this.waitingReads = [];
8970
- this.maxParallelReads = options.maxParallelReads || 10;
8971
- this.readingCalls = 0;
8972
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
8973
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
8974
- this.state = {};
8975
- this.queue = [];
8976
- if (this.backend && this.backend.init) {
8977
- this.backend.init(services, options.backend, options);
8978
- }
8979
- }
8980
- queueLoad(languages, namespaces, options, callback) {
8981
- const toLoad = {};
8982
- const pending = {};
8983
- const toLoadLanguages = {};
8984
- const toLoadNamespaces = {};
8985
- languages.forEach((lng) => {
8986
- let hasAllNamespaces = true;
8987
- namespaces.forEach((ns) => {
8988
- const name = `${lng}|${ns}`;
8989
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
8990
- this.state[name] = 2;
8991
- } else if (this.state[name] < 0) ;
8992
- else if (this.state[name] === 1) {
8993
- if (pending[name] === void 0) pending[name] = true;
8994
- } else {
8995
- this.state[name] = 1;
8996
- hasAllNamespaces = false;
8997
- if (pending[name] === void 0) pending[name] = true;
8998
- if (toLoad[name] === void 0) toLoad[name] = true;
8999
- if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
9000
- }
9001
- });
9002
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
9003
- });
9004
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
9005
- this.queue.push({
9006
- pending,
9007
- pendingCount: Object.keys(pending).length,
9008
- loaded: {},
9009
- errors: [],
9010
- callback
9011
- });
9012
- }
9013
- return {
9014
- toLoad: Object.keys(toLoad),
9015
- pending: Object.keys(pending),
9016
- toLoadLanguages: Object.keys(toLoadLanguages),
9017
- toLoadNamespaces: Object.keys(toLoadNamespaces)
9018
- };
9019
- }
9020
- loaded(name, err, data) {
9021
- const s = name.split("|");
9022
- const lng = s[0];
9023
- const ns = s[1];
9024
- if (err) this.emit("failedLoading", lng, ns, err);
9025
- if (!err && data) {
9026
- this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
9027
- skipCopy: true
9028
- });
9029
- }
9030
- this.state[name] = err ? -1 : 2;
9031
- if (err && data) this.state[name] = 0;
9032
- const loaded = {};
9033
- this.queue.forEach((q) => {
9034
- pushPath(q.loaded, [lng], ns);
9035
- removePending(q, name);
9036
- if (err) q.errors.push(err);
9037
- if (q.pendingCount === 0 && !q.done) {
9038
- Object.keys(q.loaded).forEach((l) => {
9039
- if (!loaded[l]) loaded[l] = {};
9040
- const loadedKeys = q.loaded[l];
9041
- if (loadedKeys.length) {
9042
- loadedKeys.forEach((n) => {
9043
- if (loaded[l][n] === void 0) loaded[l][n] = true;
9044
- });
9045
- }
9046
- });
9047
- q.done = true;
9048
- if (q.errors.length) {
9049
- q.callback(q.errors);
9050
- } else {
9051
- q.callback();
9052
- }
9053
- }
9054
- });
9055
- this.emit("loaded", loaded);
9056
- this.queue = this.queue.filter((q) => !q.done);
9057
- }
9058
- read(lng, ns, fcName) {
9059
- let tried = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
9060
- let wait = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout;
9061
- let callback = arguments.length > 5 ? arguments[5] : void 0;
9062
- if (!lng.length) return callback(null, {});
9063
- if (this.readingCalls >= this.maxParallelReads) {
9064
- this.waitingReads.push({
9065
- lng,
9066
- ns,
9067
- fcName,
9068
- tried,
9069
- wait,
9070
- callback
9071
- });
9072
- return;
9073
- }
9074
- this.readingCalls++;
9075
- const resolver = (err, data) => {
9076
- this.readingCalls--;
9077
- if (this.waitingReads.length > 0) {
9078
- const next = this.waitingReads.shift();
9079
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
9080
- }
9081
- if (err && data && tried < this.maxRetries) {
9082
- setTimeout(() => {
9083
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
9084
- }, wait);
9085
- return;
9086
- }
9087
- callback(err, data);
9088
- };
9089
- const fc = this.backend[fcName].bind(this.backend);
9090
- if (fc.length === 2) {
9091
- try {
9092
- const r = fc(lng, ns);
9093
- if (r && typeof r.then === "function") {
9094
- r.then((data) => resolver(null, data)).catch(resolver);
9095
- } else {
9096
- resolver(null, r);
9097
- }
9098
- } catch (err) {
9099
- resolver(err);
9100
- }
9101
- return;
9102
- }
9103
- return fc(lng, ns, resolver);
9104
- }
9105
- prepareLoading(languages, namespaces) {
9106
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
9107
- let callback = arguments.length > 3 ? arguments[3] : void 0;
9108
- if (!this.backend) {
9109
- this.logger.warn("No backend was added via i18next.use. Will not load resources.");
9110
- return callback && callback();
9111
- }
9112
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
9113
- if (isString(namespaces)) namespaces = [namespaces];
9114
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
9115
- if (!toLoad.toLoad.length) {
9116
- if (!toLoad.pending.length) callback();
9117
- return null;
9118
- }
9119
- toLoad.toLoad.forEach((name) => {
9120
- this.loadOne(name);
9121
- });
9122
- }
9123
- load(languages, namespaces, callback) {
9124
- this.prepareLoading(languages, namespaces, {}, callback);
9125
- }
9126
- reload(languages, namespaces, callback) {
9127
- this.prepareLoading(languages, namespaces, {
9128
- reload: true
9129
- }, callback);
9130
- }
9131
- loadOne(name) {
9132
- let prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
9133
- const s = name.split("|");
9134
- const lng = s[0];
9135
- const ns = s[1];
9136
- this.read(lng, ns, "read", void 0, void 0, (err, data) => {
9137
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
9138
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
9139
- this.loaded(name, err, data);
9140
- });
9141
- }
9142
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
9143
- let options = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
9144
- let clb = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
9145
- };
9146
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
9147
- this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
9148
- return;
9149
- }
9150
- if (key === void 0 || key === null || key === "") return;
9151
- if (this.backend && this.backend.create) {
9152
- const opts = {
9153
- ...options,
9154
- isUpdate
9155
- };
9156
- const fc = this.backend.create.bind(this.backend);
9157
- if (fc.length < 6) {
9158
- try {
9159
- let r;
9160
- if (fc.length === 5) {
9161
- r = fc(languages, namespace, key, fallbackValue, opts);
9162
- } else {
9163
- r = fc(languages, namespace, key, fallbackValue);
9164
- }
9165
- if (r && typeof r.then === "function") {
9166
- r.then((data) => clb(null, data)).catch(clb);
9167
- } else {
9168
- clb(null, r);
9169
- }
9170
- } catch (err) {
9171
- clb(err);
9172
- }
9173
- } else {
9174
- fc(languages, namespace, key, fallbackValue, clb, opts);
9175
- }
9176
- }
9177
- if (!languages || !languages[0]) return;
9178
- this.store.addResource(languages[0], namespace, key, fallbackValue);
9179
- }
9180
- }
9181
- const get = () => ({
9182
- debug: false,
9183
- initImmediate: true,
9184
- ns: ["translation"],
9185
- defaultNS: ["translation"],
9186
- fallbackLng: ["dev"],
9187
- fallbackNS: false,
9188
- supportedLngs: false,
9189
- nonExplicitSupportedLngs: false,
9190
- load: "all",
9191
- preload: false,
9192
- simplifyPluralSuffix: true,
9193
- keySeparator: ".",
9194
- nsSeparator: ":",
9195
- pluralSeparator: "_",
9196
- contextSeparator: "_",
9197
- partialBundledLanguages: false,
9198
- saveMissing: false,
9199
- updateMissing: false,
9200
- saveMissingTo: "fallback",
9201
- saveMissingPlurals: true,
9202
- missingKeyHandler: false,
9203
- missingInterpolationHandler: false,
9204
- postProcess: false,
9205
- postProcessPassResolved: false,
9206
- returnNull: false,
9207
- returnEmptyString: true,
9208
- returnObjects: false,
9209
- joinArrays: false,
9210
- returnedObjectHandler: false,
9211
- parseMissingKeyHandler: false,
9212
- appendNamespaceToMissingKey: false,
9213
- appendNamespaceToCIMode: false,
9214
- overloadTranslationOptionHandler: (args) => {
9215
- let ret = {};
9216
- if (typeof args[1] === "object") ret = args[1];
9217
- if (isString(args[1])) ret.defaultValue = args[1];
9218
- if (isString(args[2])) ret.tDescription = args[2];
9219
- if (typeof args[2] === "object" || typeof args[3] === "object") {
9220
- const options = args[3] || args[2];
9221
- Object.keys(options).forEach((key) => {
9222
- ret[key] = options[key];
9223
- });
9224
- }
9225
- return ret;
9226
- },
9227
- interpolation: {
9228
- escapeValue: true,
9229
- format: (value) => value,
9230
- prefix: "{{",
9231
- suffix: "}}",
9232
- formatSeparator: ",",
9233
- unescapePrefix: "-",
9234
- nestingPrefix: "$t(",
9235
- nestingSuffix: ")",
9236
- nestingOptionsSeparator: ",",
9237
- maxReplaces: 1e3,
9238
- skipOnVariables: true
7605
+ };
7606
+ ({
7607
+ [TEMPLATES_NAMES.CONTACT_FORM]: {
7608
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7609
+ },
7610
+ [TEMPLATES_NAMES.ORDER_PLACED]: {
7611
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7612
+ },
7613
+ [TEMPLATES_NAMES.ORDER_COMPLETED]: {
7614
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7615
+ },
7616
+ [TEMPLATES_NAMES.INVENTORY_LEVEL]: {
7617
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
9239
7618
  }
9240
7619
  });
9241
- const transformOptions = (options) => {
9242
- if (isString(options.ns)) options.ns = [options.ns];
9243
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
9244
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
9245
- if (options.supportedLngs && options.supportedLngs.indexOf("cimode") < 0) {
9246
- options.supportedLngs = options.supportedLngs.concat(["cimode"]);
9247
- }
9248
- return options;
9249
- };
9250
- const noop = () => {
9251
- };
9252
- const bindMemberFunctions = (inst) => {
9253
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
9254
- mems.forEach((mem) => {
9255
- if (typeof inst[mem] === "function") {
9256
- inst[mem] = inst[mem].bind(inst);
9257
- }
9258
- });
9259
- };
9260
- class I18n extends EventEmitter {
9261
- constructor() {
9262
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9263
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9264
- super();
9265
- this.options = transformOptions(options);
9266
- this.services = {};
9267
- this.logger = baseLogger;
9268
- this.modules = {
9269
- external: []
9270
- };
9271
- bindMemberFunctions(this);
9272
- if (callback && !this.isInitialized && !options.isClone) {
9273
- if (!this.options.initImmediate) {
9274
- this.init(options, callback);
9275
- return this;
9276
- }
9277
- setTimeout(() => {
9278
- this.init(options, callback);
9279
- }, 0);
9280
- }
9281
- }
9282
- init() {
9283
- var _this = this;
9284
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9285
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9286
- this.isInitializing = true;
9287
- if (typeof options === "function") {
9288
- callback = options;
9289
- options = {};
9290
- }
9291
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
9292
- if (isString(options.ns)) {
9293
- options.defaultNS = options.ns;
9294
- } else if (options.ns.indexOf("translation") < 0) {
9295
- options.defaultNS = options.ns[0];
9296
- }
9297
- }
9298
- const defOpts = get();
9299
- this.options = {
9300
- ...defOpts,
9301
- ...this.options,
9302
- ...transformOptions(options)
9303
- };
9304
- if (this.options.compatibilityAPI !== "v1") {
9305
- this.options.interpolation = {
9306
- ...defOpts.interpolation,
9307
- ...this.options.interpolation
9308
- };
9309
- }
9310
- if (options.keySeparator !== void 0) {
9311
- this.options.userDefinedKeySeparator = options.keySeparator;
9312
- }
9313
- if (options.nsSeparator !== void 0) {
9314
- this.options.userDefinedNsSeparator = options.nsSeparator;
9315
- }
9316
- const createClassOnDemand = (ClassOrObject) => {
9317
- if (!ClassOrObject) return null;
9318
- if (typeof ClassOrObject === "function") return new ClassOrObject();
9319
- return ClassOrObject;
9320
- };
9321
- if (!this.options.isClone) {
9322
- if (this.modules.logger) {
9323
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
9324
- } else {
9325
- baseLogger.init(null, this.options);
9326
- }
9327
- let formatter;
9328
- if (this.modules.formatter) {
9329
- formatter = this.modules.formatter;
9330
- } else if (typeof Intl !== "undefined") {
9331
- formatter = Formatter;
9332
- }
9333
- const lu = new LanguageUtil(this.options);
9334
- this.store = new ResourceStore(this.options.resources, this.options);
9335
- const s = this.services;
9336
- s.logger = baseLogger;
9337
- s.resourceStore = this.store;
9338
- s.languageUtils = lu;
9339
- s.pluralResolver = new PluralResolver(lu, {
9340
- prepend: this.options.pluralSeparator,
9341
- compatibilityJSON: this.options.compatibilityJSON,
9342
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
9343
- });
9344
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9345
- s.formatter = createClassOnDemand(formatter);
9346
- s.formatter.init(s, this.options);
9347
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
9348
- }
9349
- s.interpolator = new Interpolator(this.options);
9350
- s.utils = {
9351
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
9352
- };
9353
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
9354
- s.backendConnector.on("*", function(event) {
9355
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
9356
- args[_key - 1] = arguments[_key];
9357
- }
9358
- _this.emit(event, ...args);
9359
- });
9360
- if (this.modules.languageDetector) {
9361
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
9362
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
9363
- }
9364
- if (this.modules.i18nFormat) {
9365
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
9366
- if (s.i18nFormat.init) s.i18nFormat.init(this);
9367
- }
9368
- this.translator = new Translator(this.services, this.options);
9369
- this.translator.on("*", function(event) {
9370
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
9371
- args[_key2 - 1] = arguments[_key2];
9372
- }
9373
- _this.emit(event, ...args);
9374
- });
9375
- this.modules.external.forEach((m) => {
9376
- if (m.init) m.init(this);
9377
- });
9378
- }
9379
- this.format = this.options.interpolation.format;
9380
- if (!callback) callback = noop;
9381
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
9382
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9383
- if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
9384
- }
9385
- if (!this.services.languageDetector && !this.options.lng) {
9386
- this.logger.warn("init: no languageDetector is used and no lng is defined");
9387
- }
9388
- const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
9389
- storeApi.forEach((fcName) => {
9390
- this[fcName] = function() {
9391
- return _this.store[fcName](...arguments);
9392
- };
9393
- });
9394
- const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
9395
- storeApiChained.forEach((fcName) => {
9396
- this[fcName] = function() {
9397
- _this.store[fcName](...arguments);
9398
- return _this;
9399
- };
9400
- });
9401
- const deferred = defer();
9402
- const load = () => {
9403
- const finish = (err, t) => {
9404
- this.isInitializing = false;
9405
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
9406
- this.isInitialized = true;
9407
- if (!this.options.isClone) this.logger.log("initialized", this.options);
9408
- this.emit("initialized", this.options);
9409
- deferred.resolve(t);
9410
- callback(err, t);
9411
- };
9412
- if (this.languages && this.options.compatibilityAPI !== "v1" && !this.isInitialized) return finish(null, this.t.bind(this));
9413
- this.changeLanguage(this.options.lng, finish);
9414
- };
9415
- if (this.options.resources || !this.options.initImmediate) {
9416
- load();
9417
- } else {
9418
- setTimeout(load, 0);
9419
- }
9420
- return deferred;
9421
- }
9422
- loadResources(language) {
9423
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9424
- let usedCallback = callback;
9425
- const usedLng = isString(language) ? language : this.language;
9426
- if (typeof language === "function") usedCallback = language;
9427
- if (!this.options.resources || this.options.partialBundledLanguages) {
9428
- if (usedLng && usedLng.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
9429
- const toLoad = [];
9430
- const append = (lng) => {
9431
- if (!lng) return;
9432
- if (lng === "cimode") return;
9433
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
9434
- lngs.forEach((l) => {
9435
- if (l === "cimode") return;
9436
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
9437
- });
9438
- };
9439
- if (!usedLng) {
9440
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9441
- fallbacks.forEach((l) => append(l));
9442
- } else {
9443
- append(usedLng);
9444
- }
9445
- if (this.options.preload) {
9446
- this.options.preload.forEach((l) => append(l));
9447
- }
9448
- this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
9449
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
9450
- usedCallback(e);
9451
- });
9452
- } else {
9453
- usedCallback(null);
9454
- }
9455
- }
9456
- reloadResources(lngs, ns, callback) {
9457
- const deferred = defer();
9458
- if (typeof lngs === "function") {
9459
- callback = lngs;
9460
- lngs = void 0;
9461
- }
9462
- if (typeof ns === "function") {
9463
- callback = ns;
9464
- ns = void 0;
9465
- }
9466
- if (!lngs) lngs = this.languages;
9467
- if (!ns) ns = this.options.ns;
9468
- if (!callback) callback = noop;
9469
- this.services.backendConnector.reload(lngs, ns, (err) => {
9470
- deferred.resolve();
9471
- callback(err);
9472
- });
9473
- return deferred;
9474
- }
9475
- use(module2) {
9476
- if (!module2) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
9477
- if (!module2.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
9478
- if (module2.type === "backend") {
9479
- this.modules.backend = module2;
9480
- }
9481
- if (module2.type === "logger" || module2.log && module2.warn && module2.error) {
9482
- this.modules.logger = module2;
9483
- }
9484
- if (module2.type === "languageDetector") {
9485
- this.modules.languageDetector = module2;
9486
- }
9487
- if (module2.type === "i18nFormat") {
9488
- this.modules.i18nFormat = module2;
9489
- }
9490
- if (module2.type === "postProcessor") {
9491
- postProcessor.addPostProcessor(module2);
9492
- }
9493
- if (module2.type === "formatter") {
9494
- this.modules.formatter = module2;
9495
- }
9496
- if (module2.type === "3rdParty") {
9497
- this.modules.external.push(module2);
9498
- }
9499
- return this;
9500
- }
9501
- setResolvedLanguage(l) {
9502
- if (!l || !this.languages) return;
9503
- if (["cimode", "dev"].indexOf(l) > -1) return;
9504
- for (let li = 0; li < this.languages.length; li++) {
9505
- const lngInLngs = this.languages[li];
9506
- if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
9507
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
9508
- this.resolvedLanguage = lngInLngs;
9509
- break;
9510
- }
9511
- }
9512
- }
9513
- changeLanguage(lng, callback) {
9514
- var _this2 = this;
9515
- this.isLanguageChangingTo = lng;
9516
- const deferred = defer();
9517
- this.emit("languageChanging", lng);
9518
- const setLngProps = (l) => {
9519
- this.language = l;
9520
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
9521
- this.resolvedLanguage = void 0;
9522
- this.setResolvedLanguage(l);
9523
- };
9524
- const done = (err, l) => {
9525
- if (l) {
9526
- setLngProps(l);
9527
- this.translator.changeLanguage(l);
9528
- this.isLanguageChangingTo = void 0;
9529
- this.emit("languageChanged", l);
9530
- this.logger.log("languageChanged", l);
9531
- } else {
9532
- this.isLanguageChangingTo = void 0;
9533
- }
9534
- deferred.resolve(function() {
9535
- return _this2.t(...arguments);
9536
- });
9537
- if (callback) callback(err, function() {
9538
- return _this2.t(...arguments);
9539
- });
9540
- };
9541
- const setLng = (lngs) => {
9542
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
9543
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
9544
- if (l) {
9545
- if (!this.language) {
9546
- setLngProps(l);
9547
- }
9548
- if (!this.translator.language) this.translator.changeLanguage(l);
9549
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
9550
- }
9551
- this.loadResources(l, (err) => {
9552
- done(err, l);
9553
- });
9554
- };
9555
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
9556
- setLng(this.services.languageDetector.detect());
9557
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
9558
- if (this.services.languageDetector.detect.length === 0) {
9559
- this.services.languageDetector.detect().then(setLng);
9560
- } else {
9561
- this.services.languageDetector.detect(setLng);
9562
- }
9563
- } else {
9564
- setLng(lng);
9565
- }
9566
- return deferred;
9567
- }
9568
- getFixedT(lng, ns, keyPrefix) {
9569
- var _this3 = this;
9570
- const fixedT = function(key, opts) {
9571
- let options;
9572
- if (typeof opts !== "object") {
9573
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
9574
- rest[_key3 - 2] = arguments[_key3];
9575
- }
9576
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9577
- } else {
9578
- options = {
9579
- ...opts
9580
- };
9581
- }
9582
- options.lng = options.lng || fixedT.lng;
9583
- options.lngs = options.lngs || fixedT.lngs;
9584
- options.ns = options.ns || fixedT.ns;
9585
- if (options.keyPrefix !== "") options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
9586
- const keySeparator = _this3.options.keySeparator || ".";
9587
- let resultKey;
9588
- if (options.keyPrefix && Array.isArray(key)) {
9589
- resultKey = key.map((k) => `${options.keyPrefix}${keySeparator}${k}`);
9590
- } else {
9591
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
9592
- }
9593
- return _this3.t(resultKey, options);
9594
- };
9595
- if (isString(lng)) {
9596
- fixedT.lng = lng;
9597
- } else {
9598
- fixedT.lngs = lng;
9599
- }
9600
- fixedT.ns = ns;
9601
- fixedT.keyPrefix = keyPrefix;
9602
- return fixedT;
9603
- }
9604
- t() {
9605
- return this.translator && this.translator.translate(...arguments);
9606
- }
9607
- exists() {
9608
- return this.translator && this.translator.exists(...arguments);
9609
- }
9610
- setDefaultNamespace(ns) {
9611
- this.options.defaultNS = ns;
9612
- }
9613
- hasLoadedNamespace(ns) {
9614
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
9615
- if (!this.isInitialized) {
9616
- this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
9617
- return false;
9618
- }
9619
- if (!this.languages || !this.languages.length) {
9620
- this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
9621
- return false;
9622
- }
9623
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
9624
- const fallbackLng = this.options ? this.options.fallbackLng : false;
9625
- const lastLng = this.languages[this.languages.length - 1];
9626
- if (lng.toLowerCase() === "cimode") return true;
9627
- const loadNotPending = (l, n) => {
9628
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
9629
- return loadState === -1 || loadState === 0 || loadState === 2;
9630
- };
9631
- if (options.precheck) {
9632
- const preResult = options.precheck(this, loadNotPending);
9633
- if (preResult !== void 0) return preResult;
9634
- }
9635
- if (this.hasResourceBundle(lng, ns)) return true;
9636
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
9637
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
9638
- return false;
9639
- }
9640
- loadNamespaces(ns, callback) {
9641
- const deferred = defer();
9642
- if (!this.options.ns) {
9643
- if (callback) callback();
9644
- return Promise.resolve();
9645
- }
9646
- if (isString(ns)) ns = [ns];
9647
- ns.forEach((n) => {
9648
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
9649
- });
9650
- this.loadResources((err) => {
9651
- deferred.resolve();
9652
- if (callback) callback(err);
9653
- });
9654
- return deferred;
9655
- }
9656
- loadLanguages(lngs, callback) {
9657
- const deferred = defer();
9658
- if (isString(lngs)) lngs = [lngs];
9659
- const preloaded = this.options.preload || [];
9660
- const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
9661
- if (!newLngs.length) {
9662
- if (callback) callback();
9663
- return Promise.resolve();
9664
- }
9665
- this.options.preload = preloaded.concat(newLngs);
9666
- this.loadResources((err) => {
9667
- deferred.resolve();
9668
- if (callback) callback(err);
9669
- });
9670
- return deferred;
9671
- }
9672
- dir(lng) {
9673
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
9674
- if (!lng) return "rtl";
9675
- const rtlLngs = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"];
9676
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
9677
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
9678
- }
9679
- static createInstance() {
9680
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9681
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9682
- return new I18n(options, callback);
9683
- }
9684
- cloneInstance() {
9685
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9686
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9687
- const forkResourceStore = options.forkResourceStore;
9688
- if (forkResourceStore) delete options.forkResourceStore;
9689
- const mergedOptions = {
9690
- ...this.options,
9691
- ...options,
9692
- ...{
9693
- isClone: true
9694
- }
9695
- };
9696
- const clone = new I18n(mergedOptions);
9697
- if (options.debug !== void 0 || options.prefix !== void 0) {
9698
- clone.logger = clone.logger.clone(options);
9699
- }
9700
- const membersToCopy = ["store", "services", "language"];
9701
- membersToCopy.forEach((m) => {
9702
- clone[m] = this[m];
9703
- });
9704
- clone.services = {
9705
- ...this.services
9706
- };
9707
- clone.services.utils = {
9708
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9709
- };
9710
- if (forkResourceStore) {
9711
- clone.store = new ResourceStore(this.store.data, mergedOptions);
9712
- clone.services.resourceStore = clone.store;
9713
- }
9714
- clone.translator = new Translator(clone.services, mergedOptions);
9715
- clone.translator.on("*", function(event) {
9716
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
9717
- args[_key4 - 1] = arguments[_key4];
9718
- }
9719
- clone.emit(event, ...args);
9720
- });
9721
- clone.init(mergedOptions, callback);
9722
- clone.translator.options = mergedOptions;
9723
- clone.translator.backendConnector.services.utils = {
9724
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9725
- };
9726
- return clone;
9727
- }
9728
- toJSON() {
9729
- return {
9730
- options: this.options,
9731
- store: this.store,
9732
- language: this.language,
9733
- languages: this.languages,
9734
- resolvedLanguage: this.resolvedLanguage
9735
- };
9736
- }
9737
- }
9738
- const instance = I18n.createInstance();
9739
- instance.createInstance = I18n.createInstance;
9740
- instance.createInstance;
9741
- instance.dir;
9742
- instance.init;
9743
- instance.loadResources;
9744
- instance.reloadResources;
9745
- instance.use;
9746
- instance.changeLanguage;
9747
- instance.getFixedT;
9748
- instance.t;
9749
- instance.exists;
9750
- instance.setDefaultNamespace;
9751
- instance.hasLoadedNamespace;
9752
- instance.loadNamespaces;
9753
- instance.loadLanguages;
9754
7620
  const OrderPlacedTemplate = ({ orderId }) => {
9755
- const [templateData, setTemplateData] = React.useState(null);
9756
- const [previewData, setPreviewData] = React.useState(null);
7621
+ const [templateData, setTemplateData] = react.useState(null);
7622
+ const [previewData, setPreviewData] = react.useState(null);
9757
7623
  const { data: order, isLoading: isOrderLoading } = useOrder({
9758
7624
  order_id: orderId,
9759
7625
  enabled: !!orderId
9760
7626
  });
9761
- React.useEffect(() => {
7627
+ react.useEffect(() => {
9762
7628
  var _a, _b;
9763
7629
  if (order == null ? void 0 : order.display_id) {
9764
7630
  const shippingAddressText = getFormattedAddress({ address: order.shipping_address }).join("<br/>");
9765
7631
  const billingAddressText = getFormattedAddress({ address: order.billing_address }).join("<br/>");
9766
7632
  const templateData2 = {
9767
- // subject: `#${order.display_id} - Zamówienie zostało złożone`,
9768
7633
  orderNumber: `#${order.display_id}`,
9769
7634
  customerName: order.email,
9770
7635
  customerEmail: order.email,
@@ -9773,9 +7638,9 @@ const OrderPlacedTemplate = ({ orderId }) => {
9773
7638
  var _a2, _b2, _c;
9774
7639
  return acc + (((_c = (_b2 = (_a2 = item.variant) == null ? void 0 : _a2.prices) == null ? void 0 : _b2[0]) == null ? void 0 : _c.amount) || 0) * item.quantity;
9775
7640
  }, 0),
9776
- currency: order.currency_code,
7641
+ currency_code: order.currency_code,
9777
7642
  items: order.items.map((item) => ({
9778
- thumbnail: item.thumbnail,
7643
+ thumbnail: item.thumbnail == null ? "" : item.thumbnail,
9779
7644
  title: item.title,
9780
7645
  quantity: item.quantity,
9781
7646
  price: getLocaleAmount(item.unit_price, order.currency_code)
@@ -9786,8 +7651,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9786
7651
  total: getLocaleAmount(order.summary.original_order_total, order.currency_code),
9787
7652
  paid_total: getLocaleAmount(getTotalCaptured(order.payment_collections || []), order.currency_code),
9788
7653
  tax_total: getLocaleAmount(order.tax_total, order.currency_code),
9789
- discount_total: getLocaleAmount(order.discount_total, order.currency_code),
9790
- currency: order.currency_code
7654
+ discount_total: getLocaleAmount(order.discount_total, order.currency_code)
9791
7655
  },
9792
7656
  sales_channel: {
9793
7657
  name: (_a = order == null ? void 0 : order.sales_channel) == null ? void 0 : _a.name,
@@ -9805,12 +7669,12 @@ const OrderPlacedTemplate = ({ orderId }) => {
9805
7669
  enabled: !!templateData,
9806
7670
  extraKey: [templateData, orderId]
9807
7671
  });
9808
- React.useEffect(() => {
7672
+ react.useEffect(() => {
9809
7673
  if (isOrderLoading) {
9810
7674
  setPreviewData(null);
9811
7675
  }
9812
7676
  }, [isOrderLoading]);
9813
- React.useEffect(() => {
7677
+ react.useEffect(() => {
9814
7678
  if (preview) {
9815
7679
  setPreviewData(preview);
9816
7680
  }
@@ -9833,7 +7697,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9833
7697
  };
9834
7698
  const OrderTemplateGroup = () => {
9835
7699
  var _a;
9836
- const [selectedOrder, setSelectedOrder] = React.useState("");
7700
+ const [selectedOrder, setSelectedOrder] = react.useState("");
9837
7701
  const { data: orders, isLoading: isOrdersLoading } = useOrders({
9838
7702
  fields: "id,display_id",
9839
7703
  enabled: true
@@ -9867,9 +7731,9 @@ const contactFormMockData = {
9867
7731
  message: "Test messages"
9868
7732
  };
9869
7733
  const ContactFormTemplate = () => {
9870
- const [templateData, setTemplateData] = React.useState(null);
9871
- const [previewData, setPreviewData] = React.useState(null);
9872
- React.useEffect(() => {
7734
+ const [templateData, setTemplateData] = react.useState(null);
7735
+ const [previewData, setPreviewData] = react.useState(null);
7736
+ react.useEffect(() => {
9873
7737
  setTemplateData(contactFormMockData);
9874
7738
  }, []);
9875
7739
  const { data: preview, isLoading: isPreviewLoading } = usePreview({
@@ -9879,7 +7743,7 @@ const ContactFormTemplate = () => {
9879
7743
  enabled: !!templateData,
9880
7744
  extraKey: [templateData]
9881
7745
  });
9882
- React.useEffect(() => {
7746
+ react.useEffect(() => {
9883
7747
  if (preview) {
9884
7748
  setPreviewData(preview);
9885
7749
  }
@@ -9901,7 +7765,7 @@ const ContactFormTemplateGroup = () => {
9901
7765
  };
9902
7766
  const PreviewTemplatePage = () => {
9903
7767
  const templateName = "";
9904
- const [selectedTemplate, setSelectedTemplate] = React.useState(templateName);
7768
+ const [selectedTemplate, setSelectedTemplate] = react.useState(templateName);
9905
7769
  const templates = [
9906
7770
  { label: "Contact Form", value: TEMPLATES_NAMES.CONTACT_FORM },
9907
7771
  { label: "Order", value: "order" }