@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
@@ -1,14 +1,14 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
3
- import { Text, Label, Select, Button, Container as Container$1, Heading, createDataTableColumnHelper, Tooltip, useDataTable, DataTable, Badge, Drawer, IconButton, Kbd, Alert } from "@medusajs/ui";
3
+ import { Text, Label, Select, Button, Container as Container$1, Heading, createDataTableColumnHelper, Tooltip, useDataTable, DataTable, Badge, Drawer, IconButton, Kbd, clx, Alert } from "@medusajs/ui";
4
4
  import { useTranslation, Trans } from "react-i18next";
5
5
  import { useMutation, useQuery } from "@tanstack/react-query";
6
6
  import Medusa from "@medusajs/js-sdk";
7
7
  import { useState, useMemo, createContext, useContext, useReducer, useEffect, Fragment as Fragment$1, useRef, forwardRef, Suspense, createElement } from "react";
8
8
  import { InformationCircleSolid, ChatBubbleLeftRight, ArrowUpRightOnBox, XMarkMini, TriangleDownMini, Check, SquareTwoStack, ListBullet } from "@medusajs/icons";
9
9
  import { Outlet } from "react-router-dom";
10
- import "@react-email/components";
11
- import "@react-email/render";
10
+ import { Section as Section$1, Text as Text$1, Heading as Heading$1, Row as Row$1, Column, Hr, Html, Head, Tailwind, pixelBasedPreset, Body, Container as Container$2 } from "@react-email/components";
11
+ import { render, toPlainText, pretty } from "@react-email/render";
12
12
  const sdk = new Medusa({
13
13
  baseUrl: "/",
14
14
  debug: false,
@@ -784,7 +784,7 @@ var Quote$1 = (props) => {
784
784
  if (isNumber) return null;
785
785
  var {
786
786
  as,
787
- render
787
+ render: render2
788
788
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$5);
789
789
  var Elm = as || "span";
790
790
  var elmProps = _extends({}, other, reset);
@@ -794,7 +794,7 @@ var Quote$1 = (props) => {
794
794
  keyName,
795
795
  keys: keys || (keyName ? [keyName] : [])
796
796
  };
797
- var child = render && typeof render === "function" && render(elmProps, result);
797
+ var child = render2 && typeof render2 === "function" && render2(elmProps, result);
798
798
  if (child) return child;
799
799
  return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
800
800
  };
@@ -806,11 +806,11 @@ var ValueQuote$1 = (props) => {
806
806
  var other = _extends({}, (_objectDestructuringEmpty(props), props));
807
807
  var {
808
808
  as,
809
- render
809
+ render: render2
810
810
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded3$1);
811
811
  var Elm = as || "span";
812
812
  var elmProps = _extends({}, other, reset);
813
- var child = render && typeof render === "function" && render(elmProps, {});
813
+ var child = render2 && typeof render2 === "function" && render2(elmProps, {});
814
814
  if (child) return child;
815
815
  return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
816
816
  };
@@ -827,10 +827,10 @@ var Colon$1 = (props) => {
827
827
  } = useSymbolsStore();
828
828
  var {
829
829
  as,
830
- render
830
+ render: render2
831
831
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded4$1);
832
832
  var Elm = as || "span";
833
- var child = render && typeof render === "function" && render(reset, {
833
+ var child = render2 && typeof render2 === "function" && render2(reset, {
834
834
  value,
835
835
  parentValue,
836
836
  keyName,
@@ -857,10 +857,10 @@ var Arrow$1 = (props) => {
857
857
  var {
858
858
  as,
859
859
  style,
860
- render
860
+ render: render2
861
861
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded5$1);
862
862
  var Elm = as || "span";
863
- var isRender = render && typeof render === "function";
863
+ var isRender = render2 && typeof render2 === "function";
864
864
  var elmProps = _extends({}, reset, {
865
865
  "data-expanded": isExpanded,
866
866
  style: _extends({}, style, resetStyle)
@@ -871,7 +871,7 @@ var Arrow$1 = (props) => {
871
871
  keyName,
872
872
  keys: keys || (keyName ? [keyName] : [])
873
873
  };
874
- var child = isRender && render(elmProps, result);
874
+ var child = isRender && render2(elmProps, result);
875
875
  if (child) return child;
876
876
  return /* @__PURE__ */ jsx(Elm, _extends({}, reset, {
877
877
  style: _extends({}, style, resetStyle)
@@ -908,10 +908,10 @@ var BracketsOpen = (props) => {
908
908
  }
909
909
  var {
910
910
  as: elm,
911
- render
911
+ render: render2
912
912
  } = BraceLeft2, resetProps = _objectWithoutPropertiesLoose(BraceLeft2, _excluded7$1);
913
913
  var BraceLeftComp = elm || "span";
914
- var child = render && typeof render === "function" && render(resetProps, result);
914
+ var child = render2 && typeof render2 === "function" && render2(resetProps, result);
915
915
  if (child) return child;
916
916
  return /* @__PURE__ */ jsx(BraceLeftComp, _extends({}, resetProps));
917
917
  };
@@ -948,10 +948,10 @@ var BracketsClose = (props) => {
948
948
  }
949
949
  var {
950
950
  as: elm,
951
- render
951
+ render: render2
952
952
  } = BraceRight2, reset = _objectWithoutPropertiesLoose(BraceRight2, _excluded9$1);
953
953
  var BraceRightComp = elm || "span";
954
- var child = render && typeof render === "function" && render(reset, result);
954
+ var child = render2 && typeof render2 === "function" && render2(reset, result);
955
955
  if (child) return child;
956
956
  return /* @__PURE__ */ jsx(BraceRightComp, _extends({}, reset));
957
957
  };
@@ -1034,10 +1034,10 @@ var SetComp = (_ref) => {
1034
1034
  if (!isSet || !displayDataTypes) return null;
1035
1035
  var {
1036
1036
  as,
1037
- render
1037
+ render: render2
1038
1038
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$8);
1039
- var isRender = render && typeof render === "function";
1040
- var type = isRender && render(reset, {
1039
+ var isRender = render2 && typeof render2 === "function";
1040
+ var type = isRender && render2(reset, {
1041
1041
  type: "type",
1042
1042
  value,
1043
1043
  keyName
@@ -1060,10 +1060,10 @@ var MapComp = (_ref2) => {
1060
1060
  if (!isMap || !displayDataTypes) return null;
1061
1061
  var {
1062
1062
  as,
1063
- render
1063
+ render: render2
1064
1064
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$4);
1065
- var isRender = render && typeof render === "function";
1066
- var type = isRender && render(reset, {
1065
+ var isRender = render2 && typeof render2 === "function";
1066
+ var type = isRender && render2(reset, {
1067
1067
  type: "type",
1068
1068
  value,
1069
1069
  keyName
@@ -1093,7 +1093,7 @@ var TypeString = (_ref3) => {
1093
1093
  } = useStore();
1094
1094
  var {
1095
1095
  as,
1096
- render
1096
+ render: render2
1097
1097
  } = Str, reset = _objectWithoutPropertiesLoose(Str, _excluded3);
1098
1098
  var childrenStr = children;
1099
1099
  var [shorten, setShorten] = useState(length && childrenStr.length > length);
@@ -1111,8 +1111,8 @@ var TypeString = (_ref3) => {
1111
1111
  }
1112
1112
  }
1113
1113
  var text = shorten ? "" + childrenStr.slice(0, length) + stringEllipsis : childrenStr;
1114
- var isRender = render && typeof render === "function";
1115
- var type = isRender && render(_extends({}, reset, {
1114
+ var isRender = render2 && typeof render2 === "function";
1115
+ var type = isRender && render2(_extends({}, reset, {
1116
1116
  style
1117
1117
  }), {
1118
1118
  type: "type",
@@ -1121,7 +1121,7 @@ var TypeString = (_ref3) => {
1121
1121
  keys
1122
1122
  });
1123
1123
  var cls = shorten ? "w-rjv-value w-rjv-value-short" : "w-rjv-value";
1124
- var child = isRender && render(_extends({}, reset, {
1124
+ var child = isRender && render2(_extends({}, reset, {
1125
1125
  children: text,
1126
1126
  className: cls
1127
1127
  }), {
@@ -1154,12 +1154,12 @@ var TypeTrue = (_ref4) => {
1154
1154
  } = useTypesStore();
1155
1155
  var {
1156
1156
  as,
1157
- render
1157
+ render: render2
1158
1158
  } = True2, reset = _objectWithoutPropertiesLoose(True2, _excluded4);
1159
1159
  var Comp = as || "span";
1160
1160
  var style = _extends({}, defalutStyle, True2.style || {});
1161
- var isRender = render && typeof render === "function";
1162
- var type = isRender && render(_extends({}, reset, {
1161
+ var isRender = render2 && typeof render2 === "function";
1162
+ var type = isRender && render2(_extends({}, reset, {
1163
1163
  style
1164
1164
  }), {
1165
1165
  type: "type",
@@ -1167,7 +1167,7 @@ var TypeTrue = (_ref4) => {
1167
1167
  keyName,
1168
1168
  keys
1169
1169
  });
1170
- var child = isRender && render(_extends({}, reset, {
1170
+ var child = isRender && render2(_extends({}, reset, {
1171
1171
  children,
1172
1172
  className: "w-rjv-value"
1173
1173
  }), {
@@ -1198,12 +1198,12 @@ var TypeFalse = (_ref5) => {
1198
1198
  } = useTypesStore();
1199
1199
  var {
1200
1200
  as,
1201
- render
1201
+ render: render2
1202
1202
  } = False2, reset = _objectWithoutPropertiesLoose(False2, _excluded5);
1203
1203
  var Comp = as || "span";
1204
1204
  var style = _extends({}, defalutStyle, False2.style || {});
1205
- var isRender = render && typeof render === "function";
1206
- var type = isRender && render(_extends({}, reset, {
1205
+ var isRender = render2 && typeof render2 === "function";
1206
+ var type = isRender && render2(_extends({}, reset, {
1207
1207
  style
1208
1208
  }), {
1209
1209
  type: "type",
@@ -1211,7 +1211,7 @@ var TypeFalse = (_ref5) => {
1211
1211
  keyName,
1212
1212
  keys
1213
1213
  });
1214
- var child = isRender && render(_extends({}, reset, {
1214
+ var child = isRender && render2(_extends({}, reset, {
1215
1215
  children,
1216
1216
  className: "w-rjv-value"
1217
1217
  }), {
@@ -1242,12 +1242,12 @@ var TypeFloat = (_ref6) => {
1242
1242
  } = useTypesStore();
1243
1243
  var {
1244
1244
  as,
1245
- render
1245
+ render: render2
1246
1246
  } = Float2, reset = _objectWithoutPropertiesLoose(Float2, _excluded6);
1247
1247
  var Comp = as || "span";
1248
1248
  var style = _extends({}, defalutStyle, Float2.style || {});
1249
- var isRender = render && typeof render === "function";
1250
- var type = isRender && render(_extends({}, reset, {
1249
+ var isRender = render2 && typeof render2 === "function";
1250
+ var type = isRender && render2(_extends({}, reset, {
1251
1251
  style
1252
1252
  }), {
1253
1253
  type: "type",
@@ -1255,7 +1255,7 @@ var TypeFloat = (_ref6) => {
1255
1255
  keyName,
1256
1256
  keys
1257
1257
  });
1258
- var child = isRender && render(_extends({}, reset, {
1258
+ var child = isRender && render2(_extends({}, reset, {
1259
1259
  children,
1260
1260
  className: "w-rjv-value"
1261
1261
  }), {
@@ -1286,12 +1286,12 @@ var TypeInt = (_ref7) => {
1286
1286
  } = useTypesStore();
1287
1287
  var {
1288
1288
  as,
1289
- render
1289
+ render: render2
1290
1290
  } = Int2, reset = _objectWithoutPropertiesLoose(Int2, _excluded7);
1291
1291
  var Comp = as || "span";
1292
1292
  var style = _extends({}, defalutStyle, Int2.style || {});
1293
- var isRender = render && typeof render === "function";
1294
- var type = isRender && render(_extends({}, reset, {
1293
+ var isRender = render2 && typeof render2 === "function";
1294
+ var type = isRender && render2(_extends({}, reset, {
1295
1295
  style
1296
1296
  }), {
1297
1297
  type: "type",
@@ -1299,7 +1299,7 @@ var TypeInt = (_ref7) => {
1299
1299
  keyName,
1300
1300
  keys
1301
1301
  });
1302
- var child = isRender && render(_extends({}, reset, {
1302
+ var child = isRender && render2(_extends({}, reset, {
1303
1303
  children,
1304
1304
  className: "w-rjv-value"
1305
1305
  }), {
@@ -1330,12 +1330,12 @@ var TypeBigint = (_ref8) => {
1330
1330
  } = useTypesStore();
1331
1331
  var {
1332
1332
  as,
1333
- render
1333
+ render: render2
1334
1334
  } = CompBigint, reset = _objectWithoutPropertiesLoose(CompBigint, _excluded8);
1335
1335
  var Comp = as || "span";
1336
1336
  var style = _extends({}, defalutStyle, CompBigint.style || {});
1337
- var isRender = render && typeof render === "function";
1338
- var type = isRender && render(_extends({}, reset, {
1337
+ var isRender = render2 && typeof render2 === "function";
1338
+ var type = isRender && render2(_extends({}, reset, {
1339
1339
  style
1340
1340
  }), {
1341
1341
  type: "type",
@@ -1343,7 +1343,7 @@ var TypeBigint = (_ref8) => {
1343
1343
  keyName,
1344
1344
  keys
1345
1345
  });
1346
- var child = isRender && render(_extends({}, reset, {
1346
+ var child = isRender && render2(_extends({}, reset, {
1347
1347
  children,
1348
1348
  className: "w-rjv-value"
1349
1349
  }), {
@@ -1374,12 +1374,12 @@ var TypeUrl = (_ref9) => {
1374
1374
  } = useTypesStore();
1375
1375
  var {
1376
1376
  as,
1377
- render
1377
+ render: render2
1378
1378
  } = Url2, reset = _objectWithoutPropertiesLoose(Url2, _excluded9);
1379
1379
  var Comp = as || "span";
1380
1380
  var style = _extends({}, defalutStyle, Url2.style);
1381
- var isRender = render && typeof render === "function";
1382
- var type = isRender && render(_extends({}, reset, {
1381
+ var isRender = render2 && typeof render2 === "function";
1382
+ var type = isRender && render2(_extends({}, reset, {
1383
1383
  style
1384
1384
  }), {
1385
1385
  type: "type",
@@ -1387,7 +1387,7 @@ var TypeUrl = (_ref9) => {
1387
1387
  keyName,
1388
1388
  keys
1389
1389
  });
1390
- var child = isRender && render(_extends({}, reset, {
1390
+ var child = isRender && render2(_extends({}, reset, {
1391
1391
  children: children == null ? void 0 : children.href,
1392
1392
  className: "w-rjv-value"
1393
1393
  }), {
@@ -1421,12 +1421,12 @@ var TypeDate = (_ref0) => {
1421
1421
  } = useTypesStore();
1422
1422
  var {
1423
1423
  as,
1424
- render
1424
+ render: render2
1425
1425
  } = CompData, reset = _objectWithoutPropertiesLoose(CompData, _excluded0);
1426
1426
  var Comp = as || "span";
1427
1427
  var style = _extends({}, defalutStyle, CompData.style || {});
1428
- var isRender = render && typeof render === "function";
1429
- var type = isRender && render(_extends({}, reset, {
1428
+ var isRender = render2 && typeof render2 === "function";
1429
+ var type = isRender && render2(_extends({}, reset, {
1430
1430
  style
1431
1431
  }), {
1432
1432
  type: "type",
@@ -1435,7 +1435,7 @@ var TypeDate = (_ref0) => {
1435
1435
  keys
1436
1436
  });
1437
1437
  var childStr = children instanceof Date ? children.toLocaleString() : children;
1438
- var child = isRender && render(_extends({}, reset, {
1438
+ var child = isRender && render2(_extends({}, reset, {
1439
1439
  children: childStr,
1440
1440
  className: "w-rjv-value"
1441
1441
  }), {
@@ -1466,12 +1466,12 @@ var TypeUndefined = (_ref1) => {
1466
1466
  } = useTypesStore();
1467
1467
  var {
1468
1468
  as,
1469
- render
1469
+ render: render2
1470
1470
  } = Undefined2, reset = _objectWithoutPropertiesLoose(Undefined2, _excluded1);
1471
1471
  var Comp = as || "span";
1472
1472
  var style = _extends({}, defalutStyle, Undefined2.style || {});
1473
- var isRender = render && typeof render === "function";
1474
- var type = isRender && render(_extends({}, reset, {
1473
+ var isRender = render2 && typeof render2 === "function";
1474
+ var type = isRender && render2(_extends({}, reset, {
1475
1475
  style
1476
1476
  }), {
1477
1477
  type: "type",
@@ -1479,7 +1479,7 @@ var TypeUndefined = (_ref1) => {
1479
1479
  keyName,
1480
1480
  keys
1481
1481
  });
1482
- var child = isRender && render(_extends({}, reset, {
1482
+ var child = isRender && render2(_extends({}, reset, {
1483
1483
  children,
1484
1484
  className: "w-rjv-value"
1485
1485
  }), {
@@ -1507,12 +1507,12 @@ var TypeNull = (_ref10) => {
1507
1507
  } = useTypesStore();
1508
1508
  var {
1509
1509
  as,
1510
- render
1510
+ render: render2
1511
1511
  } = Null2, reset = _objectWithoutPropertiesLoose(Null2, _excluded10);
1512
1512
  var Comp = as || "span";
1513
1513
  var style = _extends({}, defalutStyle, Null2.style || {});
1514
- var isRender = render && typeof render === "function";
1515
- var type = isRender && render(_extends({}, reset, {
1514
+ var isRender = render2 && typeof render2 === "function";
1515
+ var type = isRender && render2(_extends({}, reset, {
1516
1516
  style
1517
1517
  }), {
1518
1518
  type: "type",
@@ -1520,7 +1520,7 @@ var TypeNull = (_ref10) => {
1520
1520
  keyName,
1521
1521
  keys
1522
1522
  });
1523
- var child = isRender && render(_extends({}, reset, {
1523
+ var child = isRender && render2(_extends({}, reset, {
1524
1524
  children,
1525
1525
  className: "w-rjv-value"
1526
1526
  }), {
@@ -1548,12 +1548,12 @@ var TypeNan = (_ref11) => {
1548
1548
  } = useTypesStore();
1549
1549
  var {
1550
1550
  as,
1551
- render
1551
+ render: render2
1552
1552
  } = Nan2, reset = _objectWithoutPropertiesLoose(Nan2, _excluded11);
1553
1553
  var Comp = as || "span";
1554
1554
  var style = _extends({}, defalutStyle, Nan2.style || {});
1555
- var isRender = render && typeof render === "function";
1556
- var type = isRender && render(_extends({}, reset, {
1555
+ var isRender = render2 && typeof render2 === "function";
1556
+ var type = isRender && render2(_extends({}, reset, {
1557
1557
  style
1558
1558
  }), {
1559
1559
  type: "type",
@@ -1561,7 +1561,7 @@ var TypeNan = (_ref11) => {
1561
1561
  keyName,
1562
1562
  keys
1563
1563
  });
1564
- var child = isRender && render(_extends({}, reset, {
1564
+ var child = isRender && render2(_extends({}, reset, {
1565
1565
  children: children == null ? void 0 : children.toString(),
1566
1566
  className: "w-rjv-value"
1567
1567
  }), {
@@ -1705,11 +1705,11 @@ var KeyNameComp = (props) => {
1705
1705
  } = useSectionStore();
1706
1706
  var {
1707
1707
  as,
1708
- render
1708
+ render: render2
1709
1709
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$7);
1710
1710
  reset.style = _extends({}, reset.style, style);
1711
1711
  var Elm = as || "span";
1712
- var child = render && typeof render === "function" && render(_extends({}, reset, {
1712
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
1713
1713
  children
1714
1714
  }), {
1715
1715
  value,
@@ -1745,10 +1745,10 @@ var RowComp = (props) => {
1745
1745
  } = useSectionStore();
1746
1746
  var {
1747
1747
  as,
1748
- render
1748
+ render: render2
1749
1749
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$3);
1750
1750
  var Elm = as || "div";
1751
- var child = render && typeof render === "function" && render(_extends({}, other, reset, {
1751
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, other, reset, {
1752
1752
  children
1753
1753
  }), {
1754
1754
  value,
@@ -1886,13 +1886,13 @@ var Copied$2 = (props) => {
1886
1886
  onClick: click
1887
1887
  };
1888
1888
  var {
1889
- render
1889
+ render: render2
1890
1890
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$2);
1891
1891
  var elmProps = _extends({}, reset, other, svgProps, {
1892
1892
  style: _extends({}, reset.style, other.style, svgProps.style)
1893
1893
  });
1894
- var isRender = render && typeof render === "function";
1895
- var child = isRender && render(_extends({}, elmProps, {
1894
+ var isRender = render2 && typeof render2 === "function";
1895
+ var child = isRender && render2(_extends({}, elmProps, {
1896
1896
  "data-copied": copied
1897
1897
  }), {
1898
1898
  value,
@@ -2112,13 +2112,13 @@ var CountInfoExtraComps = (props) => {
2112
2112
  } = useSectionStore();
2113
2113
  var {
2114
2114
  as,
2115
- render
2115
+ render: render2
2116
2116
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$1);
2117
- if (!render && !reset.children) return null;
2117
+ if (!render2 && !reset.children) return null;
2118
2118
  var Elm = as || "span";
2119
- var isRender = render && typeof render === "function";
2119
+ var isRender = render2 && typeof render2 === "function";
2120
2120
  var elmProps = _extends({}, reset, other);
2121
- var child = isRender && render(elmProps, {
2121
+ var child = isRender && render2(elmProps, {
2122
2122
  value,
2123
2123
  keyName
2124
2124
  });
@@ -2149,7 +2149,7 @@ var CountInfoComp = (props) => {
2149
2149
  if (!displayObjectSize) return null;
2150
2150
  var {
2151
2151
  as,
2152
- render
2152
+ render: render2
2153
2153
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
2154
2154
  var Elm = as || "span";
2155
2155
  reset.style = _extends({}, reset.style, props.style);
@@ -2158,8 +2158,8 @@ var CountInfoComp = (props) => {
2158
2158
  reset.children = len + " item" + (len === 1 ? "" : "s");
2159
2159
  }
2160
2160
  var elmProps = _extends({}, reset, other);
2161
- var isRender = render && typeof render === "function";
2162
- var child = isRender && render(_extends({}, elmProps, {
2161
+ var isRender = render2 && typeof render2 === "function";
2162
+ var child = isRender && render2(_extends({}, elmProps, {
2163
2163
  "data-length": len
2164
2164
  }), {
2165
2165
  value,
@@ -2189,10 +2189,10 @@ var EllipsisComp = (_ref) => {
2189
2189
  } = useSectionStore();
2190
2190
  var {
2191
2191
  as,
2192
- render
2192
+ render: render2
2193
2193
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$2);
2194
2194
  var Elm = as || "span";
2195
- var child = render && typeof render === "function" && render(_extends({}, reset, {
2195
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
2196
2196
  "data-expanded": isExpanded
2197
2197
  }), {
2198
2198
  value,
@@ -2946,7 +2946,7 @@ const config$1 = defineRouteConfig({
2946
2946
  icon: ListBullet
2947
2947
  });
2948
2948
  const useOrders = (params = {}, options) => {
2949
- const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id" } = params;
2949
+ const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id", order = "-created_at" } = params;
2950
2950
  const queryKey = [
2951
2951
  "orders",
2952
2952
  ...extraKey
@@ -2954,7 +2954,8 @@ const useOrders = (params = {}, options) => {
2954
2954
  const query = {
2955
2955
  limit,
2956
2956
  offset,
2957
- fields
2957
+ fields,
2958
+ order
2958
2959
  };
2959
2960
  const { data, ...rest } = useQuery({
2960
2961
  queryKey,
@@ -7373,2381 +7374,246 @@ const getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc,
7373
7374
  acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
7374
7375
  return acc;
7375
7376
  }, 0);
7376
- const TEMPLATES_NAMES = {
7377
- ORDER_PLACED: "order-placed",
7378
- CONTACT_FORM: "contact-form"
7379
- };
7380
- const isString = (obj) => typeof obj === "string";
7381
- const defer = () => {
7382
- let res;
7383
- let rej;
7384
- const promise = new Promise((resolve, reject) => {
7385
- res = resolve;
7386
- rej = reject;
7387
- });
7388
- promise.resolve = res;
7389
- promise.reject = rej;
7390
- return promise;
7391
- };
7392
- const makeString = (object) => {
7393
- if (object == null) return "";
7394
- return "" + object;
7395
- };
7396
- const copy = (a, s, t) => {
7397
- a.forEach((m) => {
7398
- if (s[m]) t[m] = s[m];
7399
- });
7400
- };
7401
- const lastOfPathSeparatorRegExp = /###/g;
7402
- const cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
7403
- const canNotTraverseDeeper = (object) => !object || isString(object);
7404
- const getLastOfPath = (object, path, Empty) => {
7405
- const stack = !isString(path) ? path : path.split(".");
7406
- let stackIndex = 0;
7407
- while (stackIndex < stack.length - 1) {
7408
- if (canNotTraverseDeeper(object)) return {};
7409
- const key = cleanKey(stack[stackIndex]);
7410
- if (!object[key] && Empty) object[key] = new Empty();
7411
- if (Object.prototype.hasOwnProperty.call(object, key)) {
7412
- object = object[key];
7413
- } else {
7414
- object = {};
7415
- }
7416
- ++stackIndex;
7417
- }
7418
- if (canNotTraverseDeeper(object)) return {};
7419
- return {
7420
- obj: object,
7421
- k: cleanKey(stack[stackIndex])
7422
- };
7423
- };
7424
- const setPath = (object, path, newValue) => {
7425
- const {
7426
- obj,
7427
- k
7428
- } = getLastOfPath(object, path, Object);
7429
- if (obj !== void 0 || path.length === 1) {
7430
- obj[k] = newValue;
7431
- return;
7432
- }
7433
- let e = path[path.length - 1];
7434
- let p = path.slice(0, path.length - 1);
7435
- let last = getLastOfPath(object, p, Object);
7436
- while (last.obj === void 0 && p.length) {
7437
- e = `${p[p.length - 1]}.${e}`;
7438
- p = p.slice(0, p.length - 1);
7439
- last = getLastOfPath(object, p, Object);
7440
- if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") {
7441
- last.obj = void 0;
7442
- }
7443
- }
7444
- last.obj[`${last.k}.${e}`] = newValue;
7445
- };
7446
- const pushPath = (object, path, newValue, concat) => {
7447
- const {
7448
- obj,
7449
- k
7450
- } = getLastOfPath(object, path, Object);
7451
- obj[k] = obj[k] || [];
7452
- obj[k].push(newValue);
7453
- };
7454
- const getPath = (object, path) => {
7455
- const {
7456
- obj,
7457
- k
7458
- } = getLastOfPath(object, path);
7459
- if (!obj) return void 0;
7460
- return obj[k];
7461
- };
7462
- const getPathWithDefaults = (data, defaultData, key) => {
7463
- const value = getPath(data, key);
7464
- if (value !== void 0) {
7465
- return value;
7466
- }
7467
- return getPath(defaultData, key);
7468
- };
7469
- const deepExtend = (target, source, overwrite) => {
7470
- for (const prop in source) {
7471
- if (prop !== "__proto__" && prop !== "constructor") {
7472
- if (prop in target) {
7473
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
7474
- if (overwrite) target[prop] = source[prop];
7475
- } else {
7476
- deepExtend(target[prop], source[prop], overwrite);
7477
- }
7478
- } else {
7479
- target[prop] = source[prop];
7480
- }
7481
- }
7482
- }
7483
- return target;
7484
- };
7485
- const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
7486
- var _entityMap = {
7487
- "&": "&amp;",
7488
- "<": "&lt;",
7489
- ">": "&gt;",
7490
- '"': "&quot;",
7491
- "'": "&#39;",
7492
- "/": "&#x2F;"
7493
- };
7494
- const escape = (data) => {
7495
- if (isString(data)) {
7496
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
7497
- }
7498
- return data;
7499
- };
7500
- class RegExpCache {
7501
- constructor(capacity) {
7502
- this.capacity = capacity;
7503
- this.regExpMap = /* @__PURE__ */ new Map();
7504
- this.regExpQueue = [];
7505
- }
7506
- getRegExp(pattern) {
7507
- const regExpFromCache = this.regExpMap.get(pattern);
7508
- if (regExpFromCache !== void 0) {
7509
- return regExpFromCache;
7510
- }
7511
- const regExpNew = new RegExp(pattern);
7512
- if (this.regExpQueue.length === this.capacity) {
7513
- this.regExpMap.delete(this.regExpQueue.shift());
7514
- }
7515
- this.regExpMap.set(pattern, regExpNew);
7516
- this.regExpQueue.push(pattern);
7517
- return regExpNew;
7518
- }
7377
+ function SectionBlock({
7378
+ id,
7379
+ props,
7380
+ data,
7381
+ isLastBlock,
7382
+ isFirstBlock
7383
+ }) {
7384
+ return /* @__PURE__ */ jsx(Section$1, { className: "m-0 p-0", children: /* @__PURE__ */ jsx(BlockRenderer, { blocks: props.blocks || [], data }) });
7519
7385
  }
7520
- const chars = [" ", ",", "?", "!", ";"];
7521
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
7522
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
7523
- nsSeparator = nsSeparator || "";
7524
- keySeparator = keySeparator || "";
7525
- const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
7526
- if (possibleChars.length === 0) return true;
7527
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
7528
- let matched = !r.test(key);
7529
- if (!matched) {
7530
- const ki = key.indexOf(keySeparator);
7531
- if (ki > 0 && !r.test(key.substring(0, ki))) {
7532
- matched = true;
7533
- }
7534
- }
7535
- return matched;
7536
- };
7537
- const deepFind = function(obj, path) {
7538
- let keySeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
7539
- if (!obj) return void 0;
7540
- if (obj[path]) return obj[path];
7541
- const tokens = path.split(keySeparator);
7542
- let current = obj;
7543
- for (let i = 0; i < tokens.length; ) {
7544
- if (!current || typeof current !== "object") {
7545
- return void 0;
7546
- }
7547
- let next;
7548
- let nextPath = "";
7549
- for (let j = i; j < tokens.length; ++j) {
7550
- if (j !== i) {
7551
- nextPath += keySeparator;
7552
- }
7553
- nextPath += tokens[j];
7554
- next = current[nextPath];
7555
- if (next !== void 0) {
7556
- if (["string", "number", "boolean"].indexOf(typeof next) > -1 && j < tokens.length - 1) {
7557
- continue;
7558
- }
7559
- i += j - i + 1;
7560
- break;
7561
- }
7562
- }
7563
- current = next;
7564
- }
7565
- return current;
7566
- };
7567
- const getCleanedCode = (code) => code && code.replace("_", "-");
7568
- const consoleLogger = {
7569
- type: "logger",
7570
- log(args) {
7571
- this.output("log", args);
7572
- },
7573
- warn(args) {
7574
- this.output("warn", args);
7575
- },
7576
- error(args) {
7577
- this.output("error", args);
7578
- },
7579
- output(type, args) {
7580
- if (console && console[type]) console[type].apply(console, args);
7581
- }
7582
- };
7583
- class Logger {
7584
- constructor(concreteLogger) {
7585
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7586
- this.init(concreteLogger, options);
7587
- }
7588
- init(concreteLogger) {
7589
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7590
- this.prefix = options.prefix || "i18next:";
7591
- this.logger = concreteLogger || consoleLogger;
7592
- this.options = options;
7593
- this.debug = options.debug;
7594
- }
7595
- log() {
7596
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7597
- args[_key] = arguments[_key];
7598
- }
7599
- return this.forward(args, "log", "", true);
7600
- }
7601
- warn() {
7602
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
7603
- args[_key2] = arguments[_key2];
7604
- }
7605
- return this.forward(args, "warn", "", true);
7606
- }
7607
- error() {
7608
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
7609
- args[_key3] = arguments[_key3];
7610
- }
7611
- return this.forward(args, "error", "");
7612
- }
7613
- deprecate() {
7614
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
7615
- args[_key4] = arguments[_key4];
7616
- }
7617
- return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
7618
- }
7619
- forward(args, lvl, prefix, debugOnly) {
7620
- if (debugOnly && !this.debug) return null;
7621
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
7622
- return this.logger[lvl](args);
7623
- }
7624
- create(moduleName) {
7625
- return new Logger(this.logger, {
7626
- ...{
7627
- prefix: `${this.prefix}:${moduleName}:`
7628
- },
7629
- ...this.options
7630
- });
7631
- }
7632
- clone(options) {
7633
- options = options || this.options;
7634
- options.prefix = options.prefix || this.prefix;
7635
- return new Logger(this.logger, options);
7636
- }
7386
+ function TextBlock({
7387
+ id,
7388
+ props,
7389
+ isLastBlock,
7390
+ isFirstBlock
7391
+ }) {
7392
+ const className = clx(
7393
+ isLastBlock ? "mb-0" : "mb-4",
7394
+ isFirstBlock && "mt-0"
7395
+ );
7396
+ return /* @__PURE__ */ jsx(Text$1, { className, children: typeof props.value === "string" ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value }, id);
7637
7397
  }
7638
- var baseLogger = new Logger();
7639
- class EventEmitter {
7640
- constructor() {
7641
- this.observers = {};
7642
- }
7643
- on(events, listener) {
7644
- events.split(" ").forEach((event) => {
7645
- if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
7646
- const numListeners = this.observers[event].get(listener) || 0;
7647
- this.observers[event].set(listener, numListeners + 1);
7648
- });
7649
- return this;
7650
- }
7651
- off(event, listener) {
7652
- if (!this.observers[event]) return;
7653
- if (!listener) {
7654
- delete this.observers[event];
7655
- return;
7656
- }
7657
- this.observers[event].delete(listener);
7658
- }
7659
- emit(event) {
7660
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7661
- args[_key - 1] = arguments[_key];
7662
- }
7663
- if (this.observers[event]) {
7664
- const cloned = Array.from(this.observers[event].entries());
7665
- cloned.forEach((_ref) => {
7666
- let [observer, numTimesAdded] = _ref;
7667
- for (let i = 0; i < numTimesAdded; i++) {
7668
- observer(...args);
7669
- }
7670
- });
7671
- }
7672
- if (this.observers["*"]) {
7673
- const cloned = Array.from(this.observers["*"].entries());
7674
- cloned.forEach((_ref2) => {
7675
- let [observer, numTimesAdded] = _ref2;
7676
- for (let i = 0; i < numTimesAdded; i++) {
7677
- observer.apply(observer, [event, ...args]);
7678
- }
7679
- });
7680
- }
7681
- }
7398
+ function RepeaterBlock({
7399
+ id,
7400
+ props,
7401
+ data
7402
+ }) {
7403
+ const array = props.itemBlocks;
7404
+ return /* @__PURE__ */ jsx(BlockRenderer, { blocks: array, data });
7682
7405
  }
7683
- class ResourceStore extends EventEmitter {
7684
- constructor(data) {
7685
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
7686
- ns: ["translation"],
7687
- defaultNS: "translation"
7688
- };
7689
- super();
7690
- this.data = data || {};
7691
- this.options = options;
7692
- if (this.options.keySeparator === void 0) {
7693
- this.options.keySeparator = ".";
7694
- }
7695
- if (this.options.ignoreJSONStructure === void 0) {
7696
- this.options.ignoreJSONStructure = true;
7697
- }
7698
- }
7699
- addNamespaces(ns) {
7700
- if (this.options.ns.indexOf(ns) < 0) {
7701
- this.options.ns.push(ns);
7702
- }
7703
- }
7704
- removeNamespaces(ns) {
7705
- const index = this.options.ns.indexOf(ns);
7706
- if (index > -1) {
7707
- this.options.ns.splice(index, 1);
7708
- }
7709
- }
7710
- getResource(lng, ns, key) {
7711
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
7712
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7713
- const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
7714
- let path;
7715
- if (lng.indexOf(".") > -1) {
7716
- path = lng.split(".");
7717
- } else {
7718
- path = [lng, ns];
7719
- if (key) {
7720
- if (Array.isArray(key)) {
7721
- path.push(...key);
7722
- } else if (isString(key) && keySeparator) {
7723
- path.push(...key.split(keySeparator));
7724
- } else {
7725
- path.push(key);
7726
- }
7727
- }
7728
- }
7729
- const result = getPath(this.data, path);
7730
- if (!result && !ns && !key && lng.indexOf(".") > -1) {
7731
- lng = path[0];
7732
- ns = path[1];
7733
- key = path.slice(2).join(".");
7734
- }
7735
- if (result || !ignoreJSONStructure || !isString(key)) return result;
7736
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
7737
- }
7738
- addResource(lng, ns, key, value) {
7739
- let options = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
7740
- silent: false
7741
- };
7742
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7743
- let path = [lng, ns];
7744
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
7745
- if (lng.indexOf(".") > -1) {
7746
- path = lng.split(".");
7747
- value = ns;
7748
- ns = path[1];
7749
- }
7750
- this.addNamespaces(ns);
7751
- setPath(this.data, path, value);
7752
- if (!options.silent) this.emit("added", lng, ns, key, value);
7753
- }
7754
- addResources(lng, ns, resources) {
7755
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
7756
- silent: false
7757
- };
7758
- for (const m in resources) {
7759
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
7760
- silent: true
7761
- });
7762
- }
7763
- if (!options.silent) this.emit("added", lng, ns, resources);
7764
- }
7765
- addResourceBundle(lng, ns, resources, deep, overwrite) {
7766
- let options = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
7767
- silent: false,
7768
- skipCopy: false
7769
- };
7770
- let path = [lng, ns];
7771
- if (lng.indexOf(".") > -1) {
7772
- path = lng.split(".");
7773
- deep = resources;
7774
- resources = ns;
7775
- ns = path[1];
7776
- }
7777
- this.addNamespaces(ns);
7778
- let pack = getPath(this.data, path) || {};
7779
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
7780
- if (deep) {
7781
- deepExtend(pack, resources, overwrite);
7782
- } else {
7783
- pack = {
7784
- ...pack,
7785
- ...resources
7786
- };
7787
- }
7788
- setPath(this.data, path, pack);
7789
- if (!options.silent) this.emit("added", lng, ns, resources);
7790
- }
7791
- removeResourceBundle(lng, ns) {
7792
- if (this.hasResourceBundle(lng, ns)) {
7793
- delete this.data[lng][ns];
7794
- }
7795
- this.removeNamespaces(ns);
7796
- this.emit("removed", lng, ns);
7797
- }
7798
- hasResourceBundle(lng, ns) {
7799
- return this.getResource(lng, ns) !== void 0;
7800
- }
7801
- getResourceBundle(lng, ns) {
7802
- if (!ns) ns = this.options.defaultNS;
7803
- if (this.options.compatibilityAPI === "v1") return {
7804
- ...{},
7805
- ...this.getResource(lng, ns)
7806
- };
7807
- return this.getResource(lng, ns);
7808
- }
7809
- getDataByLanguage(lng) {
7810
- return this.data[lng];
7811
- }
7812
- hasLanguageSomeTranslations(lng) {
7813
- const data = this.getDataByLanguage(lng);
7814
- const n = data && Object.keys(data) || [];
7815
- return !!n.find((v) => data[v] && Object.keys(data[v]).length > 0);
7816
- }
7817
- toJSON() {
7818
- return this.data;
7819
- }
7406
+ function HeadingBlock({
7407
+ id,
7408
+ props,
7409
+ data,
7410
+ isLastBlock,
7411
+ isFirstBlock
7412
+ }) {
7413
+ const className = clx(
7414
+ "text-xl",
7415
+ "font-bold",
7416
+ isLastBlock ? "mb-0" : "mb-4",
7417
+ isFirstBlock ? "mt-0" : "mt-4"
7418
+ );
7419
+ return /* @__PURE__ */ jsx(Heading$1, { className, children: props.value });
7820
7420
  }
7821
- var postProcessor = {
7822
- processors: {},
7823
- addPostProcessor(module) {
7824
- this.processors[module.name] = module;
7825
- },
7826
- handle(processors, value, key, options, translator) {
7827
- processors.forEach((processor) => {
7828
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
7829
- });
7830
- return value;
7831
- }
7832
- };
7833
- const checkedLoadedFor = {};
7834
- class Translator extends EventEmitter {
7835
- constructor(services) {
7836
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7837
- super();
7838
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
7839
- this.options = options;
7840
- if (this.options.keySeparator === void 0) {
7841
- this.options.keySeparator = ".";
7842
- }
7843
- this.logger = baseLogger.create("translator");
7844
- }
7845
- changeLanguage(lng) {
7846
- if (lng) this.language = lng;
7847
- }
7848
- exists(key) {
7849
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
7850
- interpolation: {}
7851
- };
7852
- if (key === void 0 || key === null) {
7853
- return false;
7854
- }
7855
- const resolved = this.resolve(key, options);
7856
- return resolved && resolved.res !== void 0;
7857
- }
7858
- extractFromKey(key, options) {
7859
- let nsSeparator = options.nsSeparator !== void 0 ? options.nsSeparator : this.options.nsSeparator;
7860
- if (nsSeparator === void 0) nsSeparator = ":";
7861
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7862
- let namespaces = options.ns || this.options.defaultNS || [];
7863
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
7864
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
7865
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
7866
- const m = key.match(this.interpolator.nestingRegexp);
7867
- if (m && m.length > 0) {
7868
- return {
7869
- key,
7870
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7871
- };
7872
- }
7873
- const parts = key.split(nsSeparator);
7874
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
7875
- key = parts.join(keySeparator);
7876
- }
7877
- return {
7878
- key,
7879
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7880
- };
7881
- }
7882
- translate(keys, options, lastKey) {
7883
- if (typeof options !== "object" && this.options.overloadTranslationOptionHandler) {
7884
- options = this.options.overloadTranslationOptionHandler(arguments);
7885
- }
7886
- if (typeof options === "object") options = {
7887
- ...options
7888
- };
7889
- if (!options) options = {};
7890
- if (keys === void 0 || keys === null) return "";
7891
- if (!Array.isArray(keys)) keys = [String(keys)];
7892
- const returnDetails = options.returnDetails !== void 0 ? options.returnDetails : this.options.returnDetails;
7893
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7894
- const {
7895
- key,
7896
- namespaces
7897
- } = this.extractFromKey(keys[keys.length - 1], options);
7898
- const namespace = namespaces[namespaces.length - 1];
7899
- const lng = options.lng || this.language;
7900
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
7901
- if (lng && lng.toLowerCase() === "cimode") {
7902
- if (appendNamespaceToCIMode) {
7903
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
7904
- if (returnDetails) {
7905
- return {
7906
- res: `${namespace}${nsSeparator}${key}`,
7907
- usedKey: key,
7908
- exactUsedKey: key,
7909
- usedLng: lng,
7910
- usedNS: namespace,
7911
- usedParams: this.getUsedParamsDetails(options)
7912
- };
7913
- }
7914
- return `${namespace}${nsSeparator}${key}`;
7915
- }
7916
- if (returnDetails) {
7917
- return {
7918
- res: key,
7919
- usedKey: key,
7920
- exactUsedKey: key,
7921
- usedLng: lng,
7922
- usedNS: namespace,
7923
- usedParams: this.getUsedParamsDetails(options)
7924
- };
7925
- }
7926
- return key;
7927
- }
7928
- const resolved = this.resolve(keys, options);
7929
- let res = resolved && resolved.res;
7930
- const resUsedKey = resolved && resolved.usedKey || key;
7931
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
7932
- const resType = Object.prototype.toString.apply(res);
7933
- const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
7934
- const joinArrays = options.joinArrays !== void 0 ? options.joinArrays : this.options.joinArrays;
7935
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
7936
- const handleAsObject = !isString(res) && typeof res !== "boolean" && typeof res !== "number";
7937
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
7938
- if (!options.returnObjects && !this.options.returnObjects) {
7939
- if (!this.options.returnedObjectHandler) {
7940
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
7941
- }
7942
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
7943
- ...options,
7944
- ns: namespaces
7945
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
7946
- if (returnDetails) {
7947
- resolved.res = r;
7948
- resolved.usedParams = this.getUsedParamsDetails(options);
7949
- return resolved;
7950
- }
7951
- return r;
7952
- }
7953
- if (keySeparator) {
7954
- const resTypeIsArray = Array.isArray(res);
7955
- const copy2 = resTypeIsArray ? [] : {};
7956
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
7957
- for (const m in res) {
7958
- if (Object.prototype.hasOwnProperty.call(res, m)) {
7959
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
7960
- copy2[m] = this.translate(deepKey, {
7961
- ...options,
7962
- ...{
7963
- joinArrays: false,
7964
- ns: namespaces
7965
- }
7966
- });
7967
- if (copy2[m] === deepKey) copy2[m] = res[m];
7968
- }
7969
- }
7970
- res = copy2;
7971
- }
7972
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
7973
- res = res.join(joinArrays);
7974
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
7975
- } else {
7976
- let usedDefault = false;
7977
- let usedKey = false;
7978
- const needsPluralHandling = options.count !== void 0 && !isString(options.count);
7979
- const hasDefaultValue = Translator.hasDefaultValue(options);
7980
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : "";
7981
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
7982
- ordinal: false
7983
- }) : "";
7984
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
7985
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
7986
- if (!this.isValidLookup(res) && hasDefaultValue) {
7987
- usedDefault = true;
7988
- res = defaultValue;
7989
- }
7990
- if (!this.isValidLookup(res)) {
7991
- usedKey = true;
7992
- res = key;
7993
- }
7994
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
7995
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
7996
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
7997
- if (usedKey || usedDefault || updateMissing) {
7998
- this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
7999
- if (keySeparator) {
8000
- const fk = this.resolve(key, {
8001
- ...options,
8002
- keySeparator: false
8003
- });
8004
- 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.");
8005
- }
8006
- let lngs = [];
8007
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
8008
- if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
8009
- for (let i = 0; i < fallbackLngs.length; i++) {
8010
- lngs.push(fallbackLngs[i]);
8011
- }
8012
- } else if (this.options.saveMissingTo === "all") {
8013
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
8014
- } else {
8015
- lngs.push(options.lng || this.language);
8016
- }
8017
- const send = (l, k, specificDefaultValue) => {
8018
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
8019
- if (this.options.missingKeyHandler) {
8020
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
8021
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
8022
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
8023
- }
8024
- this.emit("missingKey", l, namespace, k, res);
8025
- };
8026
- if (this.options.saveMissing) {
8027
- if (this.options.saveMissingPlurals && needsPluralHandling) {
8028
- lngs.forEach((language) => {
8029
- const suffixes = this.pluralResolver.getSuffixes(language, options);
8030
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
8031
- suffixes.push(`${this.options.pluralSeparator}zero`);
8032
- }
8033
- suffixes.forEach((suffix) => {
8034
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
8035
- });
8036
- });
8037
- } else {
8038
- send(lngs, key, defaultValue);
8039
- }
8040
- }
8041
- }
8042
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
8043
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
8044
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8045
- if (this.options.compatibilityAPI !== "v1") {
8046
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0);
8047
- } else {
8048
- res = this.options.parseMissingKeyHandler(res);
8049
- }
8050
- }
8051
- }
8052
- if (returnDetails) {
8053
- resolved.res = res;
8054
- resolved.usedParams = this.getUsedParamsDetails(options);
8055
- return resolved;
8056
- }
8057
- return res;
8058
- }
8059
- extendTranslation(res, key, options, resolved, lastKey) {
8060
- var _this = this;
8061
- if (this.i18nFormat && this.i18nFormat.parse) {
8062
- res = this.i18nFormat.parse(res, {
8063
- ...this.options.interpolation.defaultVariables,
8064
- ...options
8065
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
8066
- resolved
8067
- });
8068
- } else if (!options.skipInterpolation) {
8069
- if (options.interpolation) this.interpolator.init({
8070
- ...options,
8071
- ...{
8072
- interpolation: {
8073
- ...this.options.interpolation,
8074
- ...options.interpolation
8075
- }
8076
- }
8077
- });
8078
- const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
8079
- let nestBef;
8080
- if (skipOnVariables) {
8081
- const nb = res.match(this.interpolator.nestingRegexp);
8082
- nestBef = nb && nb.length;
8083
- }
8084
- let data = options.replace && !isString(options.replace) ? options.replace : options;
8085
- if (this.options.interpolation.defaultVariables) data = {
8086
- ...this.options.interpolation.defaultVariables,
8087
- ...data
8088
- };
8089
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
8090
- if (skipOnVariables) {
8091
- const na = res.match(this.interpolator.nestingRegexp);
8092
- const nestAft = na && na.length;
8093
- if (nestBef < nestAft) options.nest = false;
8094
- }
8095
- if (!options.lng && this.options.compatibilityAPI !== "v1" && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
8096
- if (options.nest !== false) res = this.interpolator.nest(res, function() {
8097
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8098
- args[_key] = arguments[_key];
8099
- }
8100
- if (lastKey && lastKey[0] === args[0] && !options.context) {
8101
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
7421
+ function RowBlock({
7422
+ id,
7423
+ props,
7424
+ data,
7425
+ isLastBlock,
7426
+ isFirstBlock
7427
+ }) {
7428
+ return /* @__PURE__ */ jsxs(Row$1, { children: [
7429
+ /* @__PURE__ */ jsx(Column, { className: "font-semibold", children: props.label }),
7430
+ /* @__PURE__ */ jsx(Column, { className: "text-right", children: typeof props.value === "string" ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7431
+ ] });
7432
+ }
7433
+ function SeparatorBlock({
7434
+ id,
7435
+ props,
7436
+ isLastBlock,
7437
+ isFirstBlock
7438
+ }) {
7439
+ return /* @__PURE__ */ jsx(Hr, { className: "my-4 border-ui-border" });
7440
+ }
7441
+ function ProductItemBlock({
7442
+ props,
7443
+ data,
7444
+ isLastBlock,
7445
+ isFirstBlock
7446
+ }) {
7447
+ return /* @__PURE__ */ jsxs(Row$1, { children: [
7448
+ props.thumbnail && /* @__PURE__ */ jsxs(Fragment, { children: [
7449
+ /* @__PURE__ */ jsx(Column, { className: "w-[50px]", children: /* @__PURE__ */ jsx("img", { src: props.thumbnail, width: 50, height: 50 }) }),
7450
+ /* @__PURE__ */ jsx(Column, { className: "w-[12px]" })
7451
+ ] }),
7452
+ /* @__PURE__ */ jsx(Column, { className: "text-left", children: typeof props.value === "string" ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7453
+ ] });
7454
+ }
7455
+ function BlockRenderer({ blocks, data }) {
7456
+ return blocks.map((block, index) => {
7457
+ const blockKey = block.id || `block-${index}`;
7458
+ const isLastBlock = index === blocks.length - 1;
7459
+ const isFirstBlock = index === 0;
7460
+ switch (block.type) {
7461
+ case "section":
7462
+ return /* @__PURE__ */ jsx(
7463
+ SectionBlock,
7464
+ {
7465
+ id: blockKey,
7466
+ props: block.props,
7467
+ data,
7468
+ isLastBlock,
7469
+ isFirstBlock
7470
+ },
7471
+ blockKey
7472
+ );
7473
+ case "row":
7474
+ return /* @__PURE__ */ jsx(
7475
+ RowBlock,
7476
+ {
7477
+ id: blockKey,
7478
+ props: block.props,
7479
+ data,
7480
+ isLastBlock,
7481
+ isFirstBlock
7482
+ },
7483
+ blockKey
7484
+ );
7485
+ case "product-item":
7486
+ return /* @__PURE__ */ jsx(
7487
+ ProductItemBlock,
7488
+ {
7489
+ id: blockKey,
7490
+ props: block.props,
7491
+ data,
7492
+ isLastBlock,
7493
+ isFirstBlock
7494
+ },
7495
+ blockKey
7496
+ );
7497
+ case "heading":
7498
+ return /* @__PURE__ */ jsx(
7499
+ HeadingBlock,
7500
+ {
7501
+ id: blockKey,
7502
+ props: block.props,
7503
+ data,
7504
+ isLastBlock,
7505
+ isFirstBlock
7506
+ },
7507
+ blockKey
7508
+ );
7509
+ case "text":
7510
+ return /* @__PURE__ */ jsx(
7511
+ TextBlock,
7512
+ {
7513
+ id: blockKey,
7514
+ props: block.props,
7515
+ isLastBlock,
7516
+ isFirstBlock
7517
+ },
7518
+ blockKey
7519
+ );
7520
+ case "separator":
7521
+ return /* @__PURE__ */ jsx(
7522
+ SeparatorBlock,
7523
+ {
7524
+ id: blockKey,
7525
+ props: block.props,
7526
+ isLastBlock,
7527
+ isFirstBlock
7528
+ },
7529
+ blockKey
7530
+ );
7531
+ case "repeater":
7532
+ if (!data) {
7533
+ console.warn("RepeaterBlock requires data prop");
8102
7534
  return null;
8103
7535
  }
8104
- return _this.translate(...args, key);
8105
- }, options);
8106
- if (options.interpolation) this.interpolator.reset();
7536
+ return /* @__PURE__ */ jsx(
7537
+ RepeaterBlock,
7538
+ {
7539
+ id: blockKey,
7540
+ props: block.props,
7541
+ data
7542
+ },
7543
+ blockKey
7544
+ );
7545
+ default:
7546
+ return null;
8107
7547
  }
8108
- const postProcess = options.postProcess || this.options.postProcess;
8109
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
8110
- if (res !== void 0 && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
8111
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
8112
- i18nResolved: {
8113
- ...resolved,
8114
- usedParams: this.getUsedParamsDetails(options)
7548
+ });
7549
+ }
7550
+ function renderHTMLReact(data, options) {
7551
+ const theme = options.theme || {};
7552
+ const blocks = options.blocks || [];
7553
+ return /* @__PURE__ */ jsxs(Html, { children: [
7554
+ /* @__PURE__ */ jsx(Head, {}),
7555
+ /* @__PURE__ */ jsx(
7556
+ Tailwind,
7557
+ {
7558
+ config: {
7559
+ presets: [pixelBasedPreset],
7560
+ theme
8115
7561
  },
8116
- ...options
8117
- } : options, this);
8118
- }
8119
- return res;
8120
- }
8121
- resolve(keys) {
8122
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8123
- let found;
8124
- let usedKey;
8125
- let exactUsedKey;
8126
- let usedLng;
8127
- let usedNS;
8128
- if (isString(keys)) keys = [keys];
8129
- keys.forEach((k) => {
8130
- if (this.isValidLookup(found)) return;
8131
- const extracted = this.extractFromKey(k, options);
8132
- const key = extracted.key;
8133
- usedKey = key;
8134
- let namespaces = extracted.namespaces;
8135
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
8136
- const needsPluralHandling = options.count !== void 0 && !isString(options.count);
8137
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
8138
- const needsContextHandling = options.context !== void 0 && (isString(options.context) || typeof options.context === "number") && options.context !== "";
8139
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
8140
- namespaces.forEach((ns) => {
8141
- if (this.isValidLookup(found)) return;
8142
- usedNS = ns;
8143
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
8144
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
8145
- 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!!!");
8146
- }
8147
- codes.forEach((code) => {
8148
- if (this.isValidLookup(found)) return;
8149
- usedLng = code;
8150
- const finalKeys = [key];
8151
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
8152
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
8153
- } else {
8154
- let pluralSuffix;
8155
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
8156
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
8157
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
8158
- if (needsPluralHandling) {
8159
- finalKeys.push(key + pluralSuffix);
8160
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8161
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8162
- }
8163
- if (needsZeroSuffixLookup) {
8164
- finalKeys.push(key + zeroSuffix);
8165
- }
8166
- }
8167
- if (needsContextHandling) {
8168
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
8169
- finalKeys.push(contextKey);
8170
- if (needsPluralHandling) {
8171
- finalKeys.push(contextKey + pluralSuffix);
8172
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8173
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8174
- }
8175
- if (needsZeroSuffixLookup) {
8176
- finalKeys.push(contextKey + zeroSuffix);
8177
- }
8178
- }
8179
- }
8180
- }
8181
- let possibleKey;
8182
- while (possibleKey = finalKeys.pop()) {
8183
- if (!this.isValidLookup(found)) {
8184
- exactUsedKey = possibleKey;
8185
- found = this.getResource(code, ns, possibleKey, options);
8186
- }
8187
- }
8188
- });
8189
- });
8190
- });
8191
- return {
8192
- res: found,
8193
- usedKey,
8194
- exactUsedKey,
8195
- usedLng,
8196
- usedNS
8197
- };
8198
- }
8199
- isValidLookup(res) {
8200
- return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
8201
- }
8202
- getResource(code, ns, key) {
8203
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8204
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
8205
- return this.resourceStore.getResource(code, ns, key, options);
8206
- }
8207
- getUsedParamsDetails() {
8208
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8209
- const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
8210
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
8211
- let data = useOptionsReplaceForData ? options.replace : options;
8212
- if (useOptionsReplaceForData && typeof options.count !== "undefined") {
8213
- data.count = options.count;
8214
- }
8215
- if (this.options.interpolation.defaultVariables) {
8216
- data = {
8217
- ...this.options.interpolation.defaultVariables,
8218
- ...data
8219
- };
8220
- }
8221
- if (!useOptionsReplaceForData) {
8222
- data = {
8223
- ...data
8224
- };
8225
- for (const key of optionsKeys) {
8226
- delete data[key];
8227
- }
8228
- }
8229
- return data;
8230
- }
8231
- static hasDefaultValue(options) {
8232
- const prefix = "defaultValue";
8233
- for (const option in options) {
8234
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && void 0 !== options[option]) {
8235
- return true;
7562
+ children: /* @__PURE__ */ jsx(Body, { className: "mx-auto my-auto px-4 font-arial font-normal text-base bg-ui-bg text-ui-text", children: /* @__PURE__ */ jsx(Container$2, { className: "py-4", children: /* @__PURE__ */ jsx(BlockRenderer, { blocks, data }) }) })
8236
7563
  }
8237
- }
8238
- return false;
8239
- }
7564
+ )
7565
+ ] });
8240
7566
  }
8241
- const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
8242
- class LanguageUtil {
8243
- constructor(options) {
8244
- this.options = options;
8245
- this.supportedLngs = this.options.supportedLngs || false;
8246
- this.logger = baseLogger.create("languageUtils");
8247
- }
8248
- getScriptPartFromCode(code) {
8249
- code = getCleanedCode(code);
8250
- if (!code || code.indexOf("-") < 0) return null;
8251
- const p = code.split("-");
8252
- if (p.length === 2) return null;
8253
- p.pop();
8254
- if (p[p.length - 1].toLowerCase() === "x") return null;
8255
- return this.formatLanguageCode(p.join("-"));
8256
- }
8257
- getLanguagePartFromCode(code) {
8258
- code = getCleanedCode(code);
8259
- if (!code || code.indexOf("-") < 0) return code;
8260
- const p = code.split("-");
8261
- return this.formatLanguageCode(p[0]);
8262
- }
8263
- formatLanguageCode(code) {
8264
- if (isString(code) && code.indexOf("-") > -1) {
8265
- if (typeof Intl !== "undefined" && typeof Intl.getCanonicalLocales !== "undefined") {
8266
- try {
8267
- let formattedCode = Intl.getCanonicalLocales(code)[0];
8268
- if (formattedCode && this.options.lowerCaseLng) {
8269
- formattedCode = formattedCode.toLowerCase();
8270
- }
8271
- if (formattedCode) return formattedCode;
8272
- } catch (e) {
8273
- }
8274
- }
8275
- const specialCases = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
8276
- let p = code.split("-");
8277
- if (this.options.lowerCaseLng) {
8278
- p = p.map((part) => part.toLowerCase());
8279
- } else if (p.length === 2) {
8280
- p[0] = p[0].toLowerCase();
8281
- p[1] = p[1].toUpperCase();
8282
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
8283
- } else if (p.length === 3) {
8284
- p[0] = p[0].toLowerCase();
8285
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
8286
- if (p[0] !== "sgn" && p[2].length === 2) p[2] = p[2].toUpperCase();
8287
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
8288
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
8289
- }
8290
- return p.join("-");
8291
- }
8292
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
8293
- }
8294
- isSupportedCode(code) {
8295
- if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
8296
- code = this.getLanguagePartFromCode(code);
8297
- }
8298
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
8299
- }
8300
- getBestMatchFromCodes(codes) {
8301
- if (!codes) return null;
8302
- let found;
8303
- codes.forEach((code) => {
8304
- if (found) return;
8305
- const cleanedLng = this.formatLanguageCode(code);
8306
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
8307
- });
8308
- if (!found && this.options.supportedLngs) {
8309
- codes.forEach((code) => {
8310
- if (found) return;
8311
- const lngOnly = this.getLanguagePartFromCode(code);
8312
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
8313
- found = this.options.supportedLngs.find((supportedLng) => {
8314
- if (supportedLng === lngOnly) return supportedLng;
8315
- if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
8316
- if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
8317
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
8318
- });
8319
- });
7567
+ async function renderHTML(data, options) {
7568
+ return await pretty(await render(renderHTMLReact(data, options)));
7569
+ }
7570
+ async function renderText(data, options) {
7571
+ const html = await render(renderHTMLReact(data, options));
7572
+ return toPlainText(html);
7573
+ }
7574
+ async function getBaseTemplateHtml(data, options) {
7575
+ return await renderHTML(data, options);
7576
+ }
7577
+ async function getBaseTemplateText(data, options) {
7578
+ return await renderText(data, options);
7579
+ }
7580
+ function getBaseTemplateReactNode(data, options) {
7581
+ return renderHTMLReact(data, options);
7582
+ }
7583
+ const TEMPLATES_NAMES = {
7584
+ BASE_TEMPLATE: "base-template",
7585
+ INVENTORY_LEVEL: "inventory-level",
7586
+ ORDER_PLACED: "order-placed",
7587
+ ORDER_COMPLETED: "order-completed",
7588
+ CONTACT_FORM: "contact-form"
7589
+ };
7590
+ const baseTemplateConfig = {
7591
+ [TEMPLATES_NAMES.BASE_TEMPLATE]: {
7592
+ getHtml: async (data, options) => {
7593
+ return await getBaseTemplateHtml(data, options);
7594
+ },
7595
+ getText: async (data, options) => {
7596
+ return await getBaseTemplateText(data, options);
7597
+ },
7598
+ getReactNode: (data, options) => {
7599
+ return getBaseTemplateReactNode(data, options);
8320
7600
  }
8321
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
8322
- return found;
8323
7601
  }
8324
- getFallbackCodes(fallbacks, code) {
8325
- if (!fallbacks) return [];
8326
- if (typeof fallbacks === "function") fallbacks = fallbacks(code);
8327
- if (isString(fallbacks)) fallbacks = [fallbacks];
8328
- if (Array.isArray(fallbacks)) return fallbacks;
8329
- if (!code) return fallbacks.default || [];
8330
- let found = fallbacks[code];
8331
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
8332
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
8333
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
8334
- if (!found) found = fallbacks.default;
8335
- return found || [];
8336
- }
8337
- toResolveHierarchy(code, fallbackCode) {
8338
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
8339
- const codes = [];
8340
- const addCode = (c) => {
8341
- if (!c) return;
8342
- if (this.isSupportedCode(c)) {
8343
- codes.push(c);
8344
- } else {
8345
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
8346
- }
8347
- };
8348
- if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
8349
- if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
8350
- if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
8351
- if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
8352
- } else if (isString(code)) {
8353
- addCode(this.formatLanguageCode(code));
8354
- }
8355
- fallbackCodes.forEach((fc) => {
8356
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
8357
- });
8358
- return codes;
8359
- }
8360
- }
8361
- let sets = [{
8362
- lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
8363
- nr: [1, 2],
8364
- fc: 1
8365
- }, {
8366
- 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"],
8367
- nr: [1, 2],
8368
- fc: 2
8369
- }, {
8370
- lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
8371
- nr: [1],
8372
- fc: 3
8373
- }, {
8374
- lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
8375
- nr: [1, 2, 5],
8376
- fc: 4
8377
- }, {
8378
- lngs: ["ar"],
8379
- nr: [0, 1, 2, 3, 11, 100],
8380
- fc: 5
8381
- }, {
8382
- lngs: ["cs", "sk"],
8383
- nr: [1, 2, 5],
8384
- fc: 6
8385
- }, {
8386
- lngs: ["csb", "pl"],
8387
- nr: [1, 2, 5],
8388
- fc: 7
8389
- }, {
8390
- lngs: ["cy"],
8391
- nr: [1, 2, 3, 8],
8392
- fc: 8
8393
- }, {
8394
- lngs: ["fr"],
8395
- nr: [1, 2],
8396
- fc: 9
8397
- }, {
8398
- lngs: ["ga"],
8399
- nr: [1, 2, 3, 7, 11],
8400
- fc: 10
8401
- }, {
8402
- lngs: ["gd"],
8403
- nr: [1, 2, 3, 20],
8404
- fc: 11
8405
- }, {
8406
- lngs: ["is"],
8407
- nr: [1, 2],
8408
- fc: 12
8409
- }, {
8410
- lngs: ["jv"],
8411
- nr: [0, 1],
8412
- fc: 13
8413
- }, {
8414
- lngs: ["kw"],
8415
- nr: [1, 2, 3, 4],
8416
- fc: 14
8417
- }, {
8418
- lngs: ["lt"],
8419
- nr: [1, 2, 10],
8420
- fc: 15
8421
- }, {
8422
- lngs: ["lv"],
8423
- nr: [1, 2, 0],
8424
- fc: 16
8425
- }, {
8426
- lngs: ["mk"],
8427
- nr: [1, 2],
8428
- fc: 17
8429
- }, {
8430
- lngs: ["mnk"],
8431
- nr: [0, 1, 2],
8432
- fc: 18
8433
- }, {
8434
- lngs: ["mt"],
8435
- nr: [1, 2, 11, 20],
8436
- fc: 19
8437
- }, {
8438
- lngs: ["or"],
8439
- nr: [2, 1],
8440
- fc: 2
8441
- }, {
8442
- lngs: ["ro"],
8443
- nr: [1, 2, 20],
8444
- fc: 20
8445
- }, {
8446
- lngs: ["sl"],
8447
- nr: [5, 1, 2, 3],
8448
- fc: 21
8449
- }, {
8450
- lngs: ["he", "iw"],
8451
- nr: [1, 2, 20, 21],
8452
- fc: 22
8453
- }];
8454
- let _rulesPluralsTypes = {
8455
- 1: (n) => Number(n > 1),
8456
- 2: (n) => Number(n != 1),
8457
- 3: (n) => 0,
8458
- 4: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8459
- 5: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
8460
- 6: (n) => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
8461
- 7: (n) => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8462
- 8: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
8463
- 9: (n) => Number(n >= 2),
8464
- 10: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
8465
- 11: (n) => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
8466
- 12: (n) => Number(n % 10 != 1 || n % 100 == 11),
8467
- 13: (n) => Number(n !== 0),
8468
- 14: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
8469
- 15: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
8470
- 16: (n) => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
8471
- 17: (n) => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
8472
- 18: (n) => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
8473
- 19: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
8474
- 20: (n) => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
8475
- 21: (n) => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
8476
- 22: (n) => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
8477
- };
8478
- const nonIntlVersions = ["v1", "v2", "v3"];
8479
- const intlVersions = ["v4"];
8480
- const suffixesOrder = {
8481
- zero: 0,
8482
- one: 1,
8483
- two: 2,
8484
- few: 3,
8485
- many: 4,
8486
- other: 5
8487
- };
8488
- const createRules = () => {
8489
- const rules = {};
8490
- sets.forEach((set) => {
8491
- set.lngs.forEach((l) => {
8492
- rules[l] = {
8493
- numbers: set.nr,
8494
- plurals: _rulesPluralsTypes[set.fc]
8495
- };
8496
- });
8497
- });
8498
- return rules;
8499
- };
8500
- class PluralResolver {
8501
- constructor(languageUtils) {
8502
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8503
- this.languageUtils = languageUtils;
8504
- this.options = options;
8505
- this.logger = baseLogger.create("pluralResolver");
8506
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === "undefined" || !Intl.PluralRules)) {
8507
- this.options.compatibilityJSON = "v3";
8508
- 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.");
8509
- }
8510
- this.rules = createRules();
8511
- this.pluralRulesCache = {};
8512
- }
8513
- addRule(lng, obj) {
8514
- this.rules[lng] = obj;
8515
- }
8516
- clearCache() {
8517
- this.pluralRulesCache = {};
8518
- }
8519
- getRule(code) {
8520
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8521
- if (this.shouldUseIntlApi()) {
8522
- const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
8523
- const type = options.ordinal ? "ordinal" : "cardinal";
8524
- const cacheKey = JSON.stringify({
8525
- cleanedCode,
8526
- type
8527
- });
8528
- if (cacheKey in this.pluralRulesCache) {
8529
- return this.pluralRulesCache[cacheKey];
8530
- }
8531
- let rule;
8532
- try {
8533
- rule = new Intl.PluralRules(cleanedCode, {
8534
- type
8535
- });
8536
- } catch (err) {
8537
- if (!code.match(/-|_/)) return;
8538
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
8539
- rule = this.getRule(lngPart, options);
8540
- }
8541
- this.pluralRulesCache[cacheKey] = rule;
8542
- return rule;
8543
- }
8544
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
8545
- }
8546
- needsPlural(code) {
8547
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8548
- const rule = this.getRule(code, options);
8549
- if (this.shouldUseIntlApi()) {
8550
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
8551
- }
8552
- return rule && rule.numbers.length > 1;
8553
- }
8554
- getPluralFormsOfKey(code, key) {
8555
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8556
- return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
8557
- }
8558
- getSuffixes(code) {
8559
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8560
- const rule = this.getRule(code, options);
8561
- if (!rule) {
8562
- return [];
8563
- }
8564
- if (this.shouldUseIntlApi()) {
8565
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
8566
- }
8567
- return rule.numbers.map((number) => this.getSuffix(code, number, options));
8568
- }
8569
- getSuffix(code, count) {
8570
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8571
- const rule = this.getRule(code, options);
8572
- if (rule) {
8573
- if (this.shouldUseIntlApi()) {
8574
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
8575
- }
8576
- return this.getSuffixRetroCompatible(rule, count);
8577
- }
8578
- this.logger.warn(`no plural rule found for: ${code}`);
8579
- return "";
8580
- }
8581
- getSuffixRetroCompatible(rule, count) {
8582
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
8583
- let suffix = rule.numbers[idx];
8584
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
8585
- if (suffix === 2) {
8586
- suffix = "plural";
8587
- } else if (suffix === 1) {
8588
- suffix = "";
8589
- }
8590
- }
8591
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
8592
- if (this.options.compatibilityJSON === "v1") {
8593
- if (suffix === 1) return "";
8594
- if (typeof suffix === "number") return `_plural_${suffix.toString()}`;
8595
- return returnSuffix();
8596
- } else if (this.options.compatibilityJSON === "v2") {
8597
- return returnSuffix();
8598
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
8599
- return returnSuffix();
8600
- }
8601
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
8602
- }
8603
- shouldUseIntlApi() {
8604
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
8605
- }
8606
- }
8607
- const deepFindWithDefaults = function(data, defaultData, key) {
8608
- let keySeparator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".";
8609
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
8610
- let path = getPathWithDefaults(data, defaultData, key);
8611
- if (!path && ignoreJSONStructure && isString(key)) {
8612
- path = deepFind(data, key, keySeparator);
8613
- if (path === void 0) path = deepFind(defaultData, key, keySeparator);
8614
- }
8615
- return path;
8616
- };
8617
- const regexSafe = (val) => val.replace(/\$/g, "$$$$");
8618
- class Interpolator {
8619
- constructor() {
8620
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8621
- this.logger = baseLogger.create("interpolator");
8622
- this.options = options;
8623
- this.format = options.interpolation && options.interpolation.format || ((value) => value);
8624
- this.init(options);
8625
- }
8626
- init() {
8627
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8628
- if (!options.interpolation) options.interpolation = {
8629
- escapeValue: true
8630
- };
8631
- const {
8632
- escape: escape$1,
8633
- escapeValue,
8634
- useRawValueToEscape,
8635
- prefix,
8636
- prefixEscaped,
8637
- suffix,
8638
- suffixEscaped,
8639
- formatSeparator,
8640
- unescapeSuffix,
8641
- unescapePrefix,
8642
- nestingPrefix,
8643
- nestingPrefixEscaped,
8644
- nestingSuffix,
8645
- nestingSuffixEscaped,
8646
- nestingOptionsSeparator,
8647
- maxReplaces,
8648
- alwaysFormat
8649
- } = options.interpolation;
8650
- this.escape = escape$1 !== void 0 ? escape$1 : escape;
8651
- this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
8652
- this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
8653
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
8654
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
8655
- this.formatSeparator = formatSeparator || ",";
8656
- this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
8657
- this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
8658
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
8659
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
8660
- this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
8661
- this.maxReplaces = maxReplaces || 1e3;
8662
- this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
8663
- this.resetRegExp();
8664
- }
8665
- reset() {
8666
- if (this.options) this.init(this.options);
8667
- }
8668
- resetRegExp() {
8669
- const getOrResetRegExp = (existingRegExp, pattern) => {
8670
- if (existingRegExp && existingRegExp.source === pattern) {
8671
- existingRegExp.lastIndex = 0;
8672
- return existingRegExp;
8673
- }
8674
- return new RegExp(pattern, "g");
8675
- };
8676
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
8677
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
8678
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
8679
- }
8680
- interpolate(str, data, lng, options) {
8681
- let match2;
8682
- let value;
8683
- let replaces;
8684
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
8685
- const handleFormat = (key) => {
8686
- if (key.indexOf(this.formatSeparator) < 0) {
8687
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
8688
- return this.alwaysFormat ? this.format(path, void 0, lng, {
8689
- ...options,
8690
- ...data,
8691
- interpolationkey: key
8692
- }) : path;
8693
- }
8694
- const p = key.split(this.formatSeparator);
8695
- const k = p.shift().trim();
8696
- const f = p.join(this.formatSeparator).trim();
8697
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
8698
- ...options,
8699
- ...data,
8700
- interpolationkey: k
8701
- });
8702
- };
8703
- this.resetRegExp();
8704
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
8705
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
8706
- const todos = [{
8707
- regex: this.regexpUnescape,
8708
- safeValue: (val) => regexSafe(val)
8709
- }, {
8710
- regex: this.regexp,
8711
- safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
8712
- }];
8713
- todos.forEach((todo) => {
8714
- replaces = 0;
8715
- while (match2 = todo.regex.exec(str)) {
8716
- const matchedVar = match2[1].trim();
8717
- value = handleFormat(matchedVar);
8718
- if (value === void 0) {
8719
- if (typeof missingInterpolationHandler === "function") {
8720
- const temp = missingInterpolationHandler(str, match2, options);
8721
- value = isString(temp) ? temp : "";
8722
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
8723
- value = "";
8724
- } else if (skipOnVariables) {
8725
- value = match2[0];
8726
- continue;
8727
- } else {
8728
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
8729
- value = "";
8730
- }
8731
- } else if (!isString(value) && !this.useRawValueToEscape) {
8732
- value = makeString(value);
8733
- }
8734
- const safeValue = todo.safeValue(value);
8735
- str = str.replace(match2[0], safeValue);
8736
- if (skipOnVariables) {
8737
- todo.regex.lastIndex += value.length;
8738
- todo.regex.lastIndex -= match2[0].length;
8739
- } else {
8740
- todo.regex.lastIndex = 0;
8741
- }
8742
- replaces++;
8743
- if (replaces >= this.maxReplaces) {
8744
- break;
8745
- }
8746
- }
8747
- });
8748
- return str;
8749
- }
8750
- nest(str, fc) {
8751
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8752
- let match2;
8753
- let value;
8754
- let clonedOptions;
8755
- const handleHasOptions = (key, inheritedOptions) => {
8756
- const sep = this.nestingOptionsSeparator;
8757
- if (key.indexOf(sep) < 0) return key;
8758
- const c = key.split(new RegExp(`${sep}[ ]*{`));
8759
- let optionsString = `{${c[1]}`;
8760
- key = c[0];
8761
- optionsString = this.interpolate(optionsString, clonedOptions);
8762
- const matchedSingleQuotes = optionsString.match(/'/g);
8763
- const matchedDoubleQuotes = optionsString.match(/"/g);
8764
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
8765
- optionsString = optionsString.replace(/'/g, '"');
8766
- }
8767
- try {
8768
- clonedOptions = JSON.parse(optionsString);
8769
- if (inheritedOptions) clonedOptions = {
8770
- ...inheritedOptions,
8771
- ...clonedOptions
8772
- };
8773
- } catch (e) {
8774
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
8775
- return `${key}${sep}${optionsString}`;
8776
- }
8777
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
8778
- return key;
8779
- };
8780
- while (match2 = this.nestingRegexp.exec(str)) {
8781
- let formatters2 = [];
8782
- clonedOptions = {
8783
- ...options
8784
- };
8785
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
8786
- clonedOptions.applyPostProcessor = false;
8787
- delete clonedOptions.defaultValue;
8788
- let doReduce = false;
8789
- if (match2[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match2[1])) {
8790
- const r = match2[1].split(this.formatSeparator).map((elem) => elem.trim());
8791
- match2[1] = r.shift();
8792
- formatters2 = r;
8793
- doReduce = true;
8794
- }
8795
- value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
8796
- if (value && match2[0] === str && !isString(value)) return value;
8797
- if (!isString(value)) value = makeString(value);
8798
- if (!value) {
8799
- this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
8800
- value = "";
8801
- }
8802
- if (doReduce) {
8803
- value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
8804
- ...options,
8805
- interpolationkey: match2[1].trim()
8806
- }), value.trim());
8807
- }
8808
- str = str.replace(match2[0], value);
8809
- this.regexp.lastIndex = 0;
8810
- }
8811
- return str;
8812
- }
8813
- }
8814
- const parseFormatStr = (formatStr) => {
8815
- let formatName = formatStr.toLowerCase().trim();
8816
- const formatOptions = {};
8817
- if (formatStr.indexOf("(") > -1) {
8818
- const p = formatStr.split("(");
8819
- formatName = p[0].toLowerCase().trim();
8820
- const optStr = p[1].substring(0, p[1].length - 1);
8821
- if (formatName === "currency" && optStr.indexOf(":") < 0) {
8822
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
8823
- } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
8824
- if (!formatOptions.range) formatOptions.range = optStr.trim();
8825
- } else {
8826
- const opts = optStr.split(";");
8827
- opts.forEach((opt) => {
8828
- if (opt) {
8829
- const [key, ...rest] = opt.split(":");
8830
- const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
8831
- const trimmedKey = key.trim();
8832
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
8833
- if (val === "false") formatOptions[trimmedKey] = false;
8834
- if (val === "true") formatOptions[trimmedKey] = true;
8835
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
8836
- }
8837
- });
8838
- }
8839
- }
8840
- return {
8841
- formatName,
8842
- formatOptions
8843
- };
8844
- };
8845
- const createCachedFormatter = (fn) => {
8846
- const cache = {};
8847
- return (val, lng, options) => {
8848
- let optForCache = options;
8849
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
8850
- optForCache = {
8851
- ...optForCache,
8852
- [options.interpolationkey]: void 0
8853
- };
8854
- }
8855
- const key = lng + JSON.stringify(optForCache);
8856
- let formatter = cache[key];
8857
- if (!formatter) {
8858
- formatter = fn(getCleanedCode(lng), options);
8859
- cache[key] = formatter;
8860
- }
8861
- return formatter(val);
8862
- };
8863
- };
8864
- class Formatter {
8865
- constructor() {
8866
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8867
- this.logger = baseLogger.create("formatter");
8868
- this.options = options;
8869
- this.formats = {
8870
- number: createCachedFormatter((lng, opt) => {
8871
- const formatter = new Intl.NumberFormat(lng, {
8872
- ...opt
8873
- });
8874
- return (val) => formatter.format(val);
8875
- }),
8876
- currency: createCachedFormatter((lng, opt) => {
8877
- const formatter = new Intl.NumberFormat(lng, {
8878
- ...opt,
8879
- style: "currency"
8880
- });
8881
- return (val) => formatter.format(val);
8882
- }),
8883
- datetime: createCachedFormatter((lng, opt) => {
8884
- const formatter = new Intl.DateTimeFormat(lng, {
8885
- ...opt
8886
- });
8887
- return (val) => formatter.format(val);
8888
- }),
8889
- relativetime: createCachedFormatter((lng, opt) => {
8890
- const formatter = new Intl.RelativeTimeFormat(lng, {
8891
- ...opt
8892
- });
8893
- return (val) => formatter.format(val, opt.range || "day");
8894
- }),
8895
- list: createCachedFormatter((lng, opt) => {
8896
- const formatter = new Intl.ListFormat(lng, {
8897
- ...opt
8898
- });
8899
- return (val) => formatter.format(val);
8900
- })
8901
- };
8902
- this.init(options);
8903
- }
8904
- init(services) {
8905
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8906
- interpolation: {}
8907
- };
8908
- this.formatSeparator = options.interpolation.formatSeparator || ",";
8909
- }
8910
- add(name, fc) {
8911
- this.formats[name.toLowerCase().trim()] = fc;
8912
- }
8913
- addCached(name, fc) {
8914
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
8915
- }
8916
- format(value, format2, lng) {
8917
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8918
- const formats = format2.split(this.formatSeparator);
8919
- if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
8920
- const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
8921
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
8922
- }
8923
- const result = formats.reduce((mem, f) => {
8924
- const {
8925
- formatName,
8926
- formatOptions
8927
- } = parseFormatStr(f);
8928
- if (this.formats[formatName]) {
8929
- let formatted = mem;
8930
- try {
8931
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
8932
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
8933
- formatted = this.formats[formatName](mem, l, {
8934
- ...formatOptions,
8935
- ...options,
8936
- ...valOptions
8937
- });
8938
- } catch (error) {
8939
- this.logger.warn(error);
8940
- }
8941
- return formatted;
8942
- } else {
8943
- this.logger.warn(`there was no format function for ${formatName}`);
8944
- }
8945
- return mem;
8946
- }, value);
8947
- return result;
8948
- }
8949
- }
8950
- const removePending = (q, name) => {
8951
- if (q.pending[name] !== void 0) {
8952
- delete q.pending[name];
8953
- q.pendingCount--;
8954
- }
8955
- };
8956
- class Connector extends EventEmitter {
8957
- constructor(backend, store, services) {
8958
- let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8959
- super();
8960
- this.backend = backend;
8961
- this.store = store;
8962
- this.services = services;
8963
- this.languageUtils = services.languageUtils;
8964
- this.options = options;
8965
- this.logger = baseLogger.create("backendConnector");
8966
- this.waitingReads = [];
8967
- this.maxParallelReads = options.maxParallelReads || 10;
8968
- this.readingCalls = 0;
8969
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
8970
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
8971
- this.state = {};
8972
- this.queue = [];
8973
- if (this.backend && this.backend.init) {
8974
- this.backend.init(services, options.backend, options);
8975
- }
8976
- }
8977
- queueLoad(languages, namespaces, options, callback) {
8978
- const toLoad = {};
8979
- const pending = {};
8980
- const toLoadLanguages = {};
8981
- const toLoadNamespaces = {};
8982
- languages.forEach((lng) => {
8983
- let hasAllNamespaces = true;
8984
- namespaces.forEach((ns) => {
8985
- const name = `${lng}|${ns}`;
8986
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
8987
- this.state[name] = 2;
8988
- } else if (this.state[name] < 0) ;
8989
- else if (this.state[name] === 1) {
8990
- if (pending[name] === void 0) pending[name] = true;
8991
- } else {
8992
- this.state[name] = 1;
8993
- hasAllNamespaces = false;
8994
- if (pending[name] === void 0) pending[name] = true;
8995
- if (toLoad[name] === void 0) toLoad[name] = true;
8996
- if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
8997
- }
8998
- });
8999
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
9000
- });
9001
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
9002
- this.queue.push({
9003
- pending,
9004
- pendingCount: Object.keys(pending).length,
9005
- loaded: {},
9006
- errors: [],
9007
- callback
9008
- });
9009
- }
9010
- return {
9011
- toLoad: Object.keys(toLoad),
9012
- pending: Object.keys(pending),
9013
- toLoadLanguages: Object.keys(toLoadLanguages),
9014
- toLoadNamespaces: Object.keys(toLoadNamespaces)
9015
- };
9016
- }
9017
- loaded(name, err, data) {
9018
- const s = name.split("|");
9019
- const lng = s[0];
9020
- const ns = s[1];
9021
- if (err) this.emit("failedLoading", lng, ns, err);
9022
- if (!err && data) {
9023
- this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
9024
- skipCopy: true
9025
- });
9026
- }
9027
- this.state[name] = err ? -1 : 2;
9028
- if (err && data) this.state[name] = 0;
9029
- const loaded = {};
9030
- this.queue.forEach((q) => {
9031
- pushPath(q.loaded, [lng], ns);
9032
- removePending(q, name);
9033
- if (err) q.errors.push(err);
9034
- if (q.pendingCount === 0 && !q.done) {
9035
- Object.keys(q.loaded).forEach((l) => {
9036
- if (!loaded[l]) loaded[l] = {};
9037
- const loadedKeys = q.loaded[l];
9038
- if (loadedKeys.length) {
9039
- loadedKeys.forEach((n) => {
9040
- if (loaded[l][n] === void 0) loaded[l][n] = true;
9041
- });
9042
- }
9043
- });
9044
- q.done = true;
9045
- if (q.errors.length) {
9046
- q.callback(q.errors);
9047
- } else {
9048
- q.callback();
9049
- }
9050
- }
9051
- });
9052
- this.emit("loaded", loaded);
9053
- this.queue = this.queue.filter((q) => !q.done);
9054
- }
9055
- read(lng, ns, fcName) {
9056
- let tried = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
9057
- let wait = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout;
9058
- let callback = arguments.length > 5 ? arguments[5] : void 0;
9059
- if (!lng.length) return callback(null, {});
9060
- if (this.readingCalls >= this.maxParallelReads) {
9061
- this.waitingReads.push({
9062
- lng,
9063
- ns,
9064
- fcName,
9065
- tried,
9066
- wait,
9067
- callback
9068
- });
9069
- return;
9070
- }
9071
- this.readingCalls++;
9072
- const resolver = (err, data) => {
9073
- this.readingCalls--;
9074
- if (this.waitingReads.length > 0) {
9075
- const next = this.waitingReads.shift();
9076
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
9077
- }
9078
- if (err && data && tried < this.maxRetries) {
9079
- setTimeout(() => {
9080
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
9081
- }, wait);
9082
- return;
9083
- }
9084
- callback(err, data);
9085
- };
9086
- const fc = this.backend[fcName].bind(this.backend);
9087
- if (fc.length === 2) {
9088
- try {
9089
- const r = fc(lng, ns);
9090
- if (r && typeof r.then === "function") {
9091
- r.then((data) => resolver(null, data)).catch(resolver);
9092
- } else {
9093
- resolver(null, r);
9094
- }
9095
- } catch (err) {
9096
- resolver(err);
9097
- }
9098
- return;
9099
- }
9100
- return fc(lng, ns, resolver);
9101
- }
9102
- prepareLoading(languages, namespaces) {
9103
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
9104
- let callback = arguments.length > 3 ? arguments[3] : void 0;
9105
- if (!this.backend) {
9106
- this.logger.warn("No backend was added via i18next.use. Will not load resources.");
9107
- return callback && callback();
9108
- }
9109
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
9110
- if (isString(namespaces)) namespaces = [namespaces];
9111
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
9112
- if (!toLoad.toLoad.length) {
9113
- if (!toLoad.pending.length) callback();
9114
- return null;
9115
- }
9116
- toLoad.toLoad.forEach((name) => {
9117
- this.loadOne(name);
9118
- });
9119
- }
9120
- load(languages, namespaces, callback) {
9121
- this.prepareLoading(languages, namespaces, {}, callback);
9122
- }
9123
- reload(languages, namespaces, callback) {
9124
- this.prepareLoading(languages, namespaces, {
9125
- reload: true
9126
- }, callback);
9127
- }
9128
- loadOne(name) {
9129
- let prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
9130
- const s = name.split("|");
9131
- const lng = s[0];
9132
- const ns = s[1];
9133
- this.read(lng, ns, "read", void 0, void 0, (err, data) => {
9134
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
9135
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
9136
- this.loaded(name, err, data);
9137
- });
9138
- }
9139
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
9140
- let options = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
9141
- let clb = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
9142
- };
9143
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
9144
- 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!!!");
9145
- return;
9146
- }
9147
- if (key === void 0 || key === null || key === "") return;
9148
- if (this.backend && this.backend.create) {
9149
- const opts = {
9150
- ...options,
9151
- isUpdate
9152
- };
9153
- const fc = this.backend.create.bind(this.backend);
9154
- if (fc.length < 6) {
9155
- try {
9156
- let r;
9157
- if (fc.length === 5) {
9158
- r = fc(languages, namespace, key, fallbackValue, opts);
9159
- } else {
9160
- r = fc(languages, namespace, key, fallbackValue);
9161
- }
9162
- if (r && typeof r.then === "function") {
9163
- r.then((data) => clb(null, data)).catch(clb);
9164
- } else {
9165
- clb(null, r);
9166
- }
9167
- } catch (err) {
9168
- clb(err);
9169
- }
9170
- } else {
9171
- fc(languages, namespace, key, fallbackValue, clb, opts);
9172
- }
9173
- }
9174
- if (!languages || !languages[0]) return;
9175
- this.store.addResource(languages[0], namespace, key, fallbackValue);
9176
- }
9177
- }
9178
- const get = () => ({
9179
- debug: false,
9180
- initImmediate: true,
9181
- ns: ["translation"],
9182
- defaultNS: ["translation"],
9183
- fallbackLng: ["dev"],
9184
- fallbackNS: false,
9185
- supportedLngs: false,
9186
- nonExplicitSupportedLngs: false,
9187
- load: "all",
9188
- preload: false,
9189
- simplifyPluralSuffix: true,
9190
- keySeparator: ".",
9191
- nsSeparator: ":",
9192
- pluralSeparator: "_",
9193
- contextSeparator: "_",
9194
- partialBundledLanguages: false,
9195
- saveMissing: false,
9196
- updateMissing: false,
9197
- saveMissingTo: "fallback",
9198
- saveMissingPlurals: true,
9199
- missingKeyHandler: false,
9200
- missingInterpolationHandler: false,
9201
- postProcess: false,
9202
- postProcessPassResolved: false,
9203
- returnNull: false,
9204
- returnEmptyString: true,
9205
- returnObjects: false,
9206
- joinArrays: false,
9207
- returnedObjectHandler: false,
9208
- parseMissingKeyHandler: false,
9209
- appendNamespaceToMissingKey: false,
9210
- appendNamespaceToCIMode: false,
9211
- overloadTranslationOptionHandler: (args) => {
9212
- let ret = {};
9213
- if (typeof args[1] === "object") ret = args[1];
9214
- if (isString(args[1])) ret.defaultValue = args[1];
9215
- if (isString(args[2])) ret.tDescription = args[2];
9216
- if (typeof args[2] === "object" || typeof args[3] === "object") {
9217
- const options = args[3] || args[2];
9218
- Object.keys(options).forEach((key) => {
9219
- ret[key] = options[key];
9220
- });
9221
- }
9222
- return ret;
9223
- },
9224
- interpolation: {
9225
- escapeValue: true,
9226
- format: (value) => value,
9227
- prefix: "{{",
9228
- suffix: "}}",
9229
- formatSeparator: ",",
9230
- unescapePrefix: "-",
9231
- nestingPrefix: "$t(",
9232
- nestingSuffix: ")",
9233
- nestingOptionsSeparator: ",",
9234
- maxReplaces: 1e3,
9235
- skipOnVariables: true
7602
+ };
7603
+ ({
7604
+ [TEMPLATES_NAMES.CONTACT_FORM]: {
7605
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7606
+ },
7607
+ [TEMPLATES_NAMES.ORDER_PLACED]: {
7608
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7609
+ },
7610
+ [TEMPLATES_NAMES.ORDER_COMPLETED]: {
7611
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7612
+ },
7613
+ [TEMPLATES_NAMES.INVENTORY_LEVEL]: {
7614
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
9236
7615
  }
9237
7616
  });
9238
- const transformOptions = (options) => {
9239
- if (isString(options.ns)) options.ns = [options.ns];
9240
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
9241
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
9242
- if (options.supportedLngs && options.supportedLngs.indexOf("cimode") < 0) {
9243
- options.supportedLngs = options.supportedLngs.concat(["cimode"]);
9244
- }
9245
- return options;
9246
- };
9247
- const noop = () => {
9248
- };
9249
- const bindMemberFunctions = (inst) => {
9250
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
9251
- mems.forEach((mem) => {
9252
- if (typeof inst[mem] === "function") {
9253
- inst[mem] = inst[mem].bind(inst);
9254
- }
9255
- });
9256
- };
9257
- class I18n extends EventEmitter {
9258
- constructor() {
9259
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9260
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9261
- super();
9262
- this.options = transformOptions(options);
9263
- this.services = {};
9264
- this.logger = baseLogger;
9265
- this.modules = {
9266
- external: []
9267
- };
9268
- bindMemberFunctions(this);
9269
- if (callback && !this.isInitialized && !options.isClone) {
9270
- if (!this.options.initImmediate) {
9271
- this.init(options, callback);
9272
- return this;
9273
- }
9274
- setTimeout(() => {
9275
- this.init(options, callback);
9276
- }, 0);
9277
- }
9278
- }
9279
- init() {
9280
- var _this = this;
9281
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9282
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9283
- this.isInitializing = true;
9284
- if (typeof options === "function") {
9285
- callback = options;
9286
- options = {};
9287
- }
9288
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
9289
- if (isString(options.ns)) {
9290
- options.defaultNS = options.ns;
9291
- } else if (options.ns.indexOf("translation") < 0) {
9292
- options.defaultNS = options.ns[0];
9293
- }
9294
- }
9295
- const defOpts = get();
9296
- this.options = {
9297
- ...defOpts,
9298
- ...this.options,
9299
- ...transformOptions(options)
9300
- };
9301
- if (this.options.compatibilityAPI !== "v1") {
9302
- this.options.interpolation = {
9303
- ...defOpts.interpolation,
9304
- ...this.options.interpolation
9305
- };
9306
- }
9307
- if (options.keySeparator !== void 0) {
9308
- this.options.userDefinedKeySeparator = options.keySeparator;
9309
- }
9310
- if (options.nsSeparator !== void 0) {
9311
- this.options.userDefinedNsSeparator = options.nsSeparator;
9312
- }
9313
- const createClassOnDemand = (ClassOrObject) => {
9314
- if (!ClassOrObject) return null;
9315
- if (typeof ClassOrObject === "function") return new ClassOrObject();
9316
- return ClassOrObject;
9317
- };
9318
- if (!this.options.isClone) {
9319
- if (this.modules.logger) {
9320
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
9321
- } else {
9322
- baseLogger.init(null, this.options);
9323
- }
9324
- let formatter;
9325
- if (this.modules.formatter) {
9326
- formatter = this.modules.formatter;
9327
- } else if (typeof Intl !== "undefined") {
9328
- formatter = Formatter;
9329
- }
9330
- const lu = new LanguageUtil(this.options);
9331
- this.store = new ResourceStore(this.options.resources, this.options);
9332
- const s = this.services;
9333
- s.logger = baseLogger;
9334
- s.resourceStore = this.store;
9335
- s.languageUtils = lu;
9336
- s.pluralResolver = new PluralResolver(lu, {
9337
- prepend: this.options.pluralSeparator,
9338
- compatibilityJSON: this.options.compatibilityJSON,
9339
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
9340
- });
9341
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9342
- s.formatter = createClassOnDemand(formatter);
9343
- s.formatter.init(s, this.options);
9344
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
9345
- }
9346
- s.interpolator = new Interpolator(this.options);
9347
- s.utils = {
9348
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
9349
- };
9350
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
9351
- s.backendConnector.on("*", function(event) {
9352
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
9353
- args[_key - 1] = arguments[_key];
9354
- }
9355
- _this.emit(event, ...args);
9356
- });
9357
- if (this.modules.languageDetector) {
9358
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
9359
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
9360
- }
9361
- if (this.modules.i18nFormat) {
9362
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
9363
- if (s.i18nFormat.init) s.i18nFormat.init(this);
9364
- }
9365
- this.translator = new Translator(this.services, this.options);
9366
- this.translator.on("*", function(event) {
9367
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
9368
- args[_key2 - 1] = arguments[_key2];
9369
- }
9370
- _this.emit(event, ...args);
9371
- });
9372
- this.modules.external.forEach((m) => {
9373
- if (m.init) m.init(this);
9374
- });
9375
- }
9376
- this.format = this.options.interpolation.format;
9377
- if (!callback) callback = noop;
9378
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
9379
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9380
- if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
9381
- }
9382
- if (!this.services.languageDetector && !this.options.lng) {
9383
- this.logger.warn("init: no languageDetector is used and no lng is defined");
9384
- }
9385
- const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
9386
- storeApi.forEach((fcName) => {
9387
- this[fcName] = function() {
9388
- return _this.store[fcName](...arguments);
9389
- };
9390
- });
9391
- const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
9392
- storeApiChained.forEach((fcName) => {
9393
- this[fcName] = function() {
9394
- _this.store[fcName](...arguments);
9395
- return _this;
9396
- };
9397
- });
9398
- const deferred = defer();
9399
- const load = () => {
9400
- const finish = (err, t) => {
9401
- this.isInitializing = false;
9402
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
9403
- this.isInitialized = true;
9404
- if (!this.options.isClone) this.logger.log("initialized", this.options);
9405
- this.emit("initialized", this.options);
9406
- deferred.resolve(t);
9407
- callback(err, t);
9408
- };
9409
- if (this.languages && this.options.compatibilityAPI !== "v1" && !this.isInitialized) return finish(null, this.t.bind(this));
9410
- this.changeLanguage(this.options.lng, finish);
9411
- };
9412
- if (this.options.resources || !this.options.initImmediate) {
9413
- load();
9414
- } else {
9415
- setTimeout(load, 0);
9416
- }
9417
- return deferred;
9418
- }
9419
- loadResources(language) {
9420
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9421
- let usedCallback = callback;
9422
- const usedLng = isString(language) ? language : this.language;
9423
- if (typeof language === "function") usedCallback = language;
9424
- if (!this.options.resources || this.options.partialBundledLanguages) {
9425
- if (usedLng && usedLng.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
9426
- const toLoad = [];
9427
- const append = (lng) => {
9428
- if (!lng) return;
9429
- if (lng === "cimode") return;
9430
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
9431
- lngs.forEach((l) => {
9432
- if (l === "cimode") return;
9433
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
9434
- });
9435
- };
9436
- if (!usedLng) {
9437
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9438
- fallbacks.forEach((l) => append(l));
9439
- } else {
9440
- append(usedLng);
9441
- }
9442
- if (this.options.preload) {
9443
- this.options.preload.forEach((l) => append(l));
9444
- }
9445
- this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
9446
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
9447
- usedCallback(e);
9448
- });
9449
- } else {
9450
- usedCallback(null);
9451
- }
9452
- }
9453
- reloadResources(lngs, ns, callback) {
9454
- const deferred = defer();
9455
- if (typeof lngs === "function") {
9456
- callback = lngs;
9457
- lngs = void 0;
9458
- }
9459
- if (typeof ns === "function") {
9460
- callback = ns;
9461
- ns = void 0;
9462
- }
9463
- if (!lngs) lngs = this.languages;
9464
- if (!ns) ns = this.options.ns;
9465
- if (!callback) callback = noop;
9466
- this.services.backendConnector.reload(lngs, ns, (err) => {
9467
- deferred.resolve();
9468
- callback(err);
9469
- });
9470
- return deferred;
9471
- }
9472
- use(module) {
9473
- if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
9474
- if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
9475
- if (module.type === "backend") {
9476
- this.modules.backend = module;
9477
- }
9478
- if (module.type === "logger" || module.log && module.warn && module.error) {
9479
- this.modules.logger = module;
9480
- }
9481
- if (module.type === "languageDetector") {
9482
- this.modules.languageDetector = module;
9483
- }
9484
- if (module.type === "i18nFormat") {
9485
- this.modules.i18nFormat = module;
9486
- }
9487
- if (module.type === "postProcessor") {
9488
- postProcessor.addPostProcessor(module);
9489
- }
9490
- if (module.type === "formatter") {
9491
- this.modules.formatter = module;
9492
- }
9493
- if (module.type === "3rdParty") {
9494
- this.modules.external.push(module);
9495
- }
9496
- return this;
9497
- }
9498
- setResolvedLanguage(l) {
9499
- if (!l || !this.languages) return;
9500
- if (["cimode", "dev"].indexOf(l) > -1) return;
9501
- for (let li = 0; li < this.languages.length; li++) {
9502
- const lngInLngs = this.languages[li];
9503
- if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
9504
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
9505
- this.resolvedLanguage = lngInLngs;
9506
- break;
9507
- }
9508
- }
9509
- }
9510
- changeLanguage(lng, callback) {
9511
- var _this2 = this;
9512
- this.isLanguageChangingTo = lng;
9513
- const deferred = defer();
9514
- this.emit("languageChanging", lng);
9515
- const setLngProps = (l) => {
9516
- this.language = l;
9517
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
9518
- this.resolvedLanguage = void 0;
9519
- this.setResolvedLanguage(l);
9520
- };
9521
- const done = (err, l) => {
9522
- if (l) {
9523
- setLngProps(l);
9524
- this.translator.changeLanguage(l);
9525
- this.isLanguageChangingTo = void 0;
9526
- this.emit("languageChanged", l);
9527
- this.logger.log("languageChanged", l);
9528
- } else {
9529
- this.isLanguageChangingTo = void 0;
9530
- }
9531
- deferred.resolve(function() {
9532
- return _this2.t(...arguments);
9533
- });
9534
- if (callback) callback(err, function() {
9535
- return _this2.t(...arguments);
9536
- });
9537
- };
9538
- const setLng = (lngs) => {
9539
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
9540
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
9541
- if (l) {
9542
- if (!this.language) {
9543
- setLngProps(l);
9544
- }
9545
- if (!this.translator.language) this.translator.changeLanguage(l);
9546
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
9547
- }
9548
- this.loadResources(l, (err) => {
9549
- done(err, l);
9550
- });
9551
- };
9552
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
9553
- setLng(this.services.languageDetector.detect());
9554
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
9555
- if (this.services.languageDetector.detect.length === 0) {
9556
- this.services.languageDetector.detect().then(setLng);
9557
- } else {
9558
- this.services.languageDetector.detect(setLng);
9559
- }
9560
- } else {
9561
- setLng(lng);
9562
- }
9563
- return deferred;
9564
- }
9565
- getFixedT(lng, ns, keyPrefix) {
9566
- var _this3 = this;
9567
- const fixedT = function(key, opts) {
9568
- let options;
9569
- if (typeof opts !== "object") {
9570
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
9571
- rest[_key3 - 2] = arguments[_key3];
9572
- }
9573
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9574
- } else {
9575
- options = {
9576
- ...opts
9577
- };
9578
- }
9579
- options.lng = options.lng || fixedT.lng;
9580
- options.lngs = options.lngs || fixedT.lngs;
9581
- options.ns = options.ns || fixedT.ns;
9582
- if (options.keyPrefix !== "") options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
9583
- const keySeparator = _this3.options.keySeparator || ".";
9584
- let resultKey;
9585
- if (options.keyPrefix && Array.isArray(key)) {
9586
- resultKey = key.map((k) => `${options.keyPrefix}${keySeparator}${k}`);
9587
- } else {
9588
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
9589
- }
9590
- return _this3.t(resultKey, options);
9591
- };
9592
- if (isString(lng)) {
9593
- fixedT.lng = lng;
9594
- } else {
9595
- fixedT.lngs = lng;
9596
- }
9597
- fixedT.ns = ns;
9598
- fixedT.keyPrefix = keyPrefix;
9599
- return fixedT;
9600
- }
9601
- t() {
9602
- return this.translator && this.translator.translate(...arguments);
9603
- }
9604
- exists() {
9605
- return this.translator && this.translator.exists(...arguments);
9606
- }
9607
- setDefaultNamespace(ns) {
9608
- this.options.defaultNS = ns;
9609
- }
9610
- hasLoadedNamespace(ns) {
9611
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
9612
- if (!this.isInitialized) {
9613
- this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
9614
- return false;
9615
- }
9616
- if (!this.languages || !this.languages.length) {
9617
- this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
9618
- return false;
9619
- }
9620
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
9621
- const fallbackLng = this.options ? this.options.fallbackLng : false;
9622
- const lastLng = this.languages[this.languages.length - 1];
9623
- if (lng.toLowerCase() === "cimode") return true;
9624
- const loadNotPending = (l, n) => {
9625
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
9626
- return loadState === -1 || loadState === 0 || loadState === 2;
9627
- };
9628
- if (options.precheck) {
9629
- const preResult = options.precheck(this, loadNotPending);
9630
- if (preResult !== void 0) return preResult;
9631
- }
9632
- if (this.hasResourceBundle(lng, ns)) return true;
9633
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
9634
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
9635
- return false;
9636
- }
9637
- loadNamespaces(ns, callback) {
9638
- const deferred = defer();
9639
- if (!this.options.ns) {
9640
- if (callback) callback();
9641
- return Promise.resolve();
9642
- }
9643
- if (isString(ns)) ns = [ns];
9644
- ns.forEach((n) => {
9645
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
9646
- });
9647
- this.loadResources((err) => {
9648
- deferred.resolve();
9649
- if (callback) callback(err);
9650
- });
9651
- return deferred;
9652
- }
9653
- loadLanguages(lngs, callback) {
9654
- const deferred = defer();
9655
- if (isString(lngs)) lngs = [lngs];
9656
- const preloaded = this.options.preload || [];
9657
- const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
9658
- if (!newLngs.length) {
9659
- if (callback) callback();
9660
- return Promise.resolve();
9661
- }
9662
- this.options.preload = preloaded.concat(newLngs);
9663
- this.loadResources((err) => {
9664
- deferred.resolve();
9665
- if (callback) callback(err);
9666
- });
9667
- return deferred;
9668
- }
9669
- dir(lng) {
9670
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
9671
- if (!lng) return "rtl";
9672
- 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"];
9673
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
9674
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
9675
- }
9676
- static createInstance() {
9677
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9678
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9679
- return new I18n(options, callback);
9680
- }
9681
- cloneInstance() {
9682
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9683
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9684
- const forkResourceStore = options.forkResourceStore;
9685
- if (forkResourceStore) delete options.forkResourceStore;
9686
- const mergedOptions = {
9687
- ...this.options,
9688
- ...options,
9689
- ...{
9690
- isClone: true
9691
- }
9692
- };
9693
- const clone = new I18n(mergedOptions);
9694
- if (options.debug !== void 0 || options.prefix !== void 0) {
9695
- clone.logger = clone.logger.clone(options);
9696
- }
9697
- const membersToCopy = ["store", "services", "language"];
9698
- membersToCopy.forEach((m) => {
9699
- clone[m] = this[m];
9700
- });
9701
- clone.services = {
9702
- ...this.services
9703
- };
9704
- clone.services.utils = {
9705
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9706
- };
9707
- if (forkResourceStore) {
9708
- clone.store = new ResourceStore(this.store.data, mergedOptions);
9709
- clone.services.resourceStore = clone.store;
9710
- }
9711
- clone.translator = new Translator(clone.services, mergedOptions);
9712
- clone.translator.on("*", function(event) {
9713
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
9714
- args[_key4 - 1] = arguments[_key4];
9715
- }
9716
- clone.emit(event, ...args);
9717
- });
9718
- clone.init(mergedOptions, callback);
9719
- clone.translator.options = mergedOptions;
9720
- clone.translator.backendConnector.services.utils = {
9721
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9722
- };
9723
- return clone;
9724
- }
9725
- toJSON() {
9726
- return {
9727
- options: this.options,
9728
- store: this.store,
9729
- language: this.language,
9730
- languages: this.languages,
9731
- resolvedLanguage: this.resolvedLanguage
9732
- };
9733
- }
9734
- }
9735
- const instance = I18n.createInstance();
9736
- instance.createInstance = I18n.createInstance;
9737
- instance.createInstance;
9738
- instance.dir;
9739
- instance.init;
9740
- instance.loadResources;
9741
- instance.reloadResources;
9742
- instance.use;
9743
- instance.changeLanguage;
9744
- instance.getFixedT;
9745
- instance.t;
9746
- instance.exists;
9747
- instance.setDefaultNamespace;
9748
- instance.hasLoadedNamespace;
9749
- instance.loadNamespaces;
9750
- instance.loadLanguages;
9751
7617
  const OrderPlacedTemplate = ({ orderId }) => {
9752
7618
  const [templateData, setTemplateData] = useState(null);
9753
7619
  const [previewData, setPreviewData] = useState(null);
@@ -9761,7 +7627,6 @@ const OrderPlacedTemplate = ({ orderId }) => {
9761
7627
  const shippingAddressText = getFormattedAddress({ address: order.shipping_address }).join("<br/>");
9762
7628
  const billingAddressText = getFormattedAddress({ address: order.billing_address }).join("<br/>");
9763
7629
  const templateData2 = {
9764
- // subject: `#${order.display_id} - Zamówienie zostało złożone`,
9765
7630
  orderNumber: `#${order.display_id}`,
9766
7631
  customerName: order.email,
9767
7632
  customerEmail: order.email,
@@ -9770,9 +7635,9 @@ const OrderPlacedTemplate = ({ orderId }) => {
9770
7635
  var _a2, _b2, _c;
9771
7636
  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;
9772
7637
  }, 0),
9773
- currency: order.currency_code,
7638
+ currency_code: order.currency_code,
9774
7639
  items: order.items.map((item) => ({
9775
- thumbnail: item.thumbnail,
7640
+ thumbnail: item.thumbnail == null ? "" : item.thumbnail,
9776
7641
  title: item.title,
9777
7642
  quantity: item.quantity,
9778
7643
  price: getLocaleAmount(item.unit_price, order.currency_code)
@@ -9783,8 +7648,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9783
7648
  total: getLocaleAmount(order.summary.original_order_total, order.currency_code),
9784
7649
  paid_total: getLocaleAmount(getTotalCaptured(order.payment_collections || []), order.currency_code),
9785
7650
  tax_total: getLocaleAmount(order.tax_total, order.currency_code),
9786
- discount_total: getLocaleAmount(order.discount_total, order.currency_code),
9787
- currency: order.currency_code
7651
+ discount_total: getLocaleAmount(order.discount_total, order.currency_code)
9788
7652
  },
9789
7653
  sales_channel: {
9790
7654
  name: (_a = order == null ? void 0 : order.sales_channel) == null ? void 0 : _a.name,