@codee-sh/medusa-plugin-notification-emails 0.0.2 → 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 (55) 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 +385 -2364
  6. package/.medusa/server/src/admin/index.mjs +307 -2286
  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 +183 -92
  26. package/.medusa/server/src/templates/emails/inventory-level/config.js +126 -0
  27. package/.medusa/server/src/templates/emails/inventory-level/index.js +6 -17
  28. package/.medusa/server/src/templates/emails/order-completed/config.js +233 -0
  29. package/.medusa/server/src/templates/emails/order-completed/index.js +6 -17
  30. package/.medusa/server/src/templates/emails/order-completed/translations/en.json +2 -1
  31. package/.medusa/server/src/templates/emails/order-completed/translations/pl.json +2 -1
  32. package/.medusa/server/src/templates/emails/order-placed/config.js +221 -0
  33. package/.medusa/server/src/templates/emails/order-placed/index.js +6 -17
  34. package/.medusa/server/src/templates/emails/order-placed/translations/en.json +1 -1
  35. package/.medusa/server/src/templates/emails/order-placed/translations/pl.json +1 -1
  36. package/.medusa/server/src/templates/emails/types.js +2 -1
  37. package/.medusa/server/src/utils/i18n/i18n.js +194 -0
  38. package/.medusa/server/src/utils/i18n/index.js +18 -0
  39. package/.medusa/server/src/utils/index.js +5 -1
  40. package/.medusa/server/src/utils/is-defined.js +7 -0
  41. package/.medusa/server/src/utils/is-object.js +7 -0
  42. package/.medusa/server/src/utils/pick-value-from-object.js +28 -0
  43. package/package.json +18 -11
  44. package/.medusa/server/src/templates/emails/contact-form/template.js +0 -28
  45. package/.medusa/server/src/templates/emails/contact-form/translations/index.js +0 -15
  46. package/.medusa/server/src/templates/emails/contact-form/types.js +0 -3
  47. package/.medusa/server/src/templates/emails/inventory-level/template.js +0 -28
  48. package/.medusa/server/src/templates/emails/inventory-level/types.js +0 -3
  49. package/.medusa/server/src/templates/emails/order-completed/template.js +0 -36
  50. package/.medusa/server/src/templates/emails/order-completed/types.js +0 -3
  51. package/.medusa/server/src/templates/emails/order-placed/template.js +0 -36
  52. package/.medusa/server/src/templates/emails/order-placed/types.js +0 -3
  53. package/.medusa/server/src/templates/shared/i18n/index.js +0 -6
  54. package/.medusa/server/src/templates/shared/i18n/languages.js +0 -187
  55. 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/render";
11
- import "@react-email/components";
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,2224 +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 == null ? void 0 : 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
- if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
7461
- return obj[k];
7462
- };
7463
- const getPathWithDefaults = (data, defaultData, key) => {
7464
- const value = getPath(data, key);
7465
- if (value !== void 0) {
7466
- return value;
7467
- }
7468
- return getPath(defaultData, key);
7469
- };
7470
- const deepExtend = (target, source, overwrite) => {
7471
- for (const prop in source) {
7472
- if (prop !== "__proto__" && prop !== "constructor") {
7473
- if (prop in target) {
7474
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
7475
- if (overwrite) target[prop] = source[prop];
7476
- } else {
7477
- deepExtend(target[prop], source[prop], overwrite);
7478
- }
7479
- } else {
7480
- target[prop] = source[prop];
7481
- }
7482
- }
7483
- }
7484
- return target;
7485
- };
7486
- const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
7487
- var _entityMap = {
7488
- "&": "&amp;",
7489
- "<": "&lt;",
7490
- ">": "&gt;",
7491
- '"': "&quot;",
7492
- "'": "&#39;",
7493
- "/": "&#x2F;"
7494
- };
7495
- const escape = (data) => {
7496
- if (isString(data)) {
7497
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
7498
- }
7499
- return data;
7500
- };
7501
- class RegExpCache {
7502
- constructor(capacity) {
7503
- this.capacity = capacity;
7504
- this.regExpMap = /* @__PURE__ */ new Map();
7505
- this.regExpQueue = [];
7506
- }
7507
- getRegExp(pattern) {
7508
- const regExpFromCache = this.regExpMap.get(pattern);
7509
- if (regExpFromCache !== void 0) {
7510
- return regExpFromCache;
7511
- }
7512
- const regExpNew = new RegExp(pattern);
7513
- if (this.regExpQueue.length === this.capacity) {
7514
- this.regExpMap.delete(this.regExpQueue.shift());
7515
- }
7516
- this.regExpMap.set(pattern, regExpNew);
7517
- this.regExpQueue.push(pattern);
7518
- return regExpNew;
7519
- }
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 }) });
7520
7385
  }
7521
- const chars = [" ", ",", "?", "!", ";"];
7522
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
7523
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
7524
- nsSeparator = nsSeparator || "";
7525
- keySeparator = keySeparator || "";
7526
- const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
7527
- if (possibleChars.length === 0) return true;
7528
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
7529
- let matched = !r.test(key);
7530
- if (!matched) {
7531
- const ki = key.indexOf(keySeparator);
7532
- if (ki > 0 && !r.test(key.substring(0, ki))) {
7533
- matched = true;
7534
- }
7535
- }
7536
- return matched;
7537
- };
7538
- const deepFind = (obj, path, keySeparator = ".") => {
7539
- if (!obj) return void 0;
7540
- if (obj[path]) {
7541
- if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
7542
- return obj[path];
7543
- }
7544
- const tokens = path.split(keySeparator);
7545
- let current = obj;
7546
- for (let i = 0; i < tokens.length; ) {
7547
- if (!current || typeof current !== "object") {
7548
- return void 0;
7549
- }
7550
- let next;
7551
- let nextPath = "";
7552
- for (let j = i; j < tokens.length; ++j) {
7553
- if (j !== i) {
7554
- nextPath += keySeparator;
7555
- }
7556
- nextPath += tokens[j];
7557
- next = current[nextPath];
7558
- if (next !== void 0) {
7559
- if (["string", "number", "boolean"].indexOf(typeof next) > -1 && j < tokens.length - 1) {
7560
- continue;
7561
- }
7562
- i += j - i + 1;
7563
- break;
7564
- }
7565
- }
7566
- current = next;
7567
- }
7568
- return current;
7569
- };
7570
- const getCleanedCode = (code) => code == null ? void 0 : code.replace("_", "-");
7571
- const consoleLogger = {
7572
- type: "logger",
7573
- log(args) {
7574
- this.output("log", args);
7575
- },
7576
- warn(args) {
7577
- this.output("warn", args);
7578
- },
7579
- error(args) {
7580
- this.output("error", args);
7581
- },
7582
- output(type, args) {
7583
- var _a, _b;
7584
- (_b = (_a = console == null ? void 0 : console[type]) == null ? void 0 : _a.apply) == null ? void 0 : _b.call(_a, console, args);
7585
- }
7586
- };
7587
- class Logger {
7588
- constructor(concreteLogger, options = {}) {
7589
- this.init(concreteLogger, options);
7590
- }
7591
- init(concreteLogger, options = {}) {
7592
- this.prefix = options.prefix || "i18next:";
7593
- this.logger = concreteLogger || consoleLogger;
7594
- this.options = options;
7595
- this.debug = options.debug;
7596
- }
7597
- log(...args) {
7598
- return this.forward(args, "log", "", true);
7599
- }
7600
- warn(...args) {
7601
- return this.forward(args, "warn", "", true);
7602
- }
7603
- error(...args) {
7604
- return this.forward(args, "error", "");
7605
- }
7606
- deprecate(...args) {
7607
- return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
7608
- }
7609
- forward(args, lvl, prefix, debugOnly) {
7610
- if (debugOnly && !this.debug) return null;
7611
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
7612
- return this.logger[lvl](args);
7613
- }
7614
- create(moduleName) {
7615
- return new Logger(this.logger, {
7616
- ...{
7617
- prefix: `${this.prefix}:${moduleName}:`
7618
- },
7619
- ...this.options
7620
- });
7621
- }
7622
- clone(options) {
7623
- options = options || this.options;
7624
- options.prefix = options.prefix || this.prefix;
7625
- return new Logger(this.logger, options);
7626
- }
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);
7627
7397
  }
7628
- var baseLogger = new Logger();
7629
- class EventEmitter {
7630
- constructor() {
7631
- this.observers = {};
7632
- }
7633
- on(events, listener) {
7634
- events.split(" ").forEach((event) => {
7635
- if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
7636
- const numListeners = this.observers[event].get(listener) || 0;
7637
- this.observers[event].set(listener, numListeners + 1);
7638
- });
7639
- return this;
7640
- }
7641
- off(event, listener) {
7642
- if (!this.observers[event]) return;
7643
- if (!listener) {
7644
- delete this.observers[event];
7645
- return;
7646
- }
7647
- this.observers[event].delete(listener);
7648
- }
7649
- emit(event, ...args) {
7650
- if (this.observers[event]) {
7651
- const cloned = Array.from(this.observers[event].entries());
7652
- cloned.forEach(([observer, numTimesAdded]) => {
7653
- for (let i = 0; i < numTimesAdded; i++) {
7654
- observer(...args);
7655
- }
7656
- });
7657
- }
7658
- if (this.observers["*"]) {
7659
- const cloned = Array.from(this.observers["*"].entries());
7660
- cloned.forEach(([observer, numTimesAdded]) => {
7661
- for (let i = 0; i < numTimesAdded; i++) {
7662
- observer.apply(observer, [event, ...args]);
7663
- }
7664
- });
7665
- }
7666
- }
7398
+ function RepeaterBlock({
7399
+ id,
7400
+ props,
7401
+ data
7402
+ }) {
7403
+ const array = props.itemBlocks;
7404
+ return /* @__PURE__ */ jsx(BlockRenderer, { blocks: array, data });
7667
7405
  }
7668
- class ResourceStore extends EventEmitter {
7669
- constructor(data, options = {
7670
- ns: ["translation"],
7671
- defaultNS: "translation"
7672
- }) {
7673
- super();
7674
- this.data = data || {};
7675
- this.options = options;
7676
- if (this.options.keySeparator === void 0) {
7677
- this.options.keySeparator = ".";
7678
- }
7679
- if (this.options.ignoreJSONStructure === void 0) {
7680
- this.options.ignoreJSONStructure = true;
7681
- }
7682
- }
7683
- addNamespaces(ns) {
7684
- if (this.options.ns.indexOf(ns) < 0) {
7685
- this.options.ns.push(ns);
7686
- }
7687
- }
7688
- removeNamespaces(ns) {
7689
- const index = this.options.ns.indexOf(ns);
7690
- if (index > -1) {
7691
- this.options.ns.splice(index, 1);
7692
- }
7693
- }
7694
- getResource(lng, ns, key, options = {}) {
7695
- var _a, _b;
7696
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7697
- const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
7698
- let path;
7699
- if (lng.indexOf(".") > -1) {
7700
- path = lng.split(".");
7701
- } else {
7702
- path = [lng, ns];
7703
- if (key) {
7704
- if (Array.isArray(key)) {
7705
- path.push(...key);
7706
- } else if (isString(key) && keySeparator) {
7707
- path.push(...key.split(keySeparator));
7708
- } else {
7709
- path.push(key);
7710
- }
7711
- }
7712
- }
7713
- const result = getPath(this.data, path);
7714
- if (!result && !ns && !key && lng.indexOf(".") > -1) {
7715
- lng = path[0];
7716
- ns = path[1];
7717
- key = path.slice(2).join(".");
7718
- }
7719
- if (result || !ignoreJSONStructure || !isString(key)) return result;
7720
- return deepFind((_b = (_a = this.data) == null ? void 0 : _a[lng]) == null ? void 0 : _b[ns], key, keySeparator);
7721
- }
7722
- addResource(lng, ns, key, value, options = {
7723
- silent: false
7724
- }) {
7725
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7726
- let path = [lng, ns];
7727
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
7728
- if (lng.indexOf(".") > -1) {
7729
- path = lng.split(".");
7730
- value = ns;
7731
- ns = path[1];
7732
- }
7733
- this.addNamespaces(ns);
7734
- setPath(this.data, path, value);
7735
- if (!options.silent) this.emit("added", lng, ns, key, value);
7736
- }
7737
- addResources(lng, ns, resources, options = {
7738
- silent: false
7739
- }) {
7740
- for (const m in resources) {
7741
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
7742
- silent: true
7743
- });
7744
- }
7745
- if (!options.silent) this.emit("added", lng, ns, resources);
7746
- }
7747
- addResourceBundle(lng, ns, resources, deep, overwrite, options = {
7748
- silent: false,
7749
- skipCopy: false
7750
- }) {
7751
- let path = [lng, ns];
7752
- if (lng.indexOf(".") > -1) {
7753
- path = lng.split(".");
7754
- deep = resources;
7755
- resources = ns;
7756
- ns = path[1];
7757
- }
7758
- this.addNamespaces(ns);
7759
- let pack = getPath(this.data, path) || {};
7760
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
7761
- if (deep) {
7762
- deepExtend(pack, resources, overwrite);
7763
- } else {
7764
- pack = {
7765
- ...pack,
7766
- ...resources
7767
- };
7768
- }
7769
- setPath(this.data, path, pack);
7770
- if (!options.silent) this.emit("added", lng, ns, resources);
7771
- }
7772
- removeResourceBundle(lng, ns) {
7773
- if (this.hasResourceBundle(lng, ns)) {
7774
- delete this.data[lng][ns];
7775
- }
7776
- this.removeNamespaces(ns);
7777
- this.emit("removed", lng, ns);
7778
- }
7779
- hasResourceBundle(lng, ns) {
7780
- return this.getResource(lng, ns) !== void 0;
7781
- }
7782
- getResourceBundle(lng, ns) {
7783
- if (!ns) ns = this.options.defaultNS;
7784
- return this.getResource(lng, ns);
7785
- }
7786
- getDataByLanguage(lng) {
7787
- return this.data[lng];
7788
- }
7789
- hasLanguageSomeTranslations(lng) {
7790
- const data = this.getDataByLanguage(lng);
7791
- const n = data && Object.keys(data) || [];
7792
- return !!n.find((v) => data[v] && Object.keys(data[v]).length > 0);
7793
- }
7794
- toJSON() {
7795
- return this.data;
7796
- }
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 });
7797
7420
  }
7798
- var postProcessor = {
7799
- processors: {},
7800
- addPostProcessor(module) {
7801
- this.processors[module.name] = module;
7802
- },
7803
- handle(processors, value, key, options, translator) {
7804
- processors.forEach((processor) => {
7805
- var _a;
7806
- value = ((_a = this.processors[processor]) == null ? void 0 : _a.process(value, key, options, translator)) ?? value;
7807
- });
7808
- return value;
7809
- }
7810
- };
7811
- const PATH_KEY = Symbol("i18next/PATH_KEY");
7812
- function createProxy() {
7813
- const state = [];
7814
- const handler = /* @__PURE__ */ Object.create(null);
7815
- let proxy;
7816
- handler.get = (target, key) => {
7817
- var _a;
7818
- (_a = proxy == null ? void 0 : proxy.revoke) == null ? void 0 : _a.call(proxy);
7819
- if (key === PATH_KEY) return state;
7820
- state.push(key);
7821
- proxy = Proxy.revocable(target, handler);
7822
- return proxy.proxy;
7823
- };
7824
- return Proxy.revocable(/* @__PURE__ */ Object.create(null), handler).proxy;
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
+ ] });
7825
7432
  }
7826
- function keysFromSelector(selector, opts) {
7827
- const {
7828
- [PATH_KEY]: path
7829
- } = selector(createProxy());
7830
- return path.join((opts == null ? void 0 : opts.keySeparator) ?? ".");
7433
+ function SeparatorBlock({
7434
+ id,
7435
+ props,
7436
+ isLastBlock,
7437
+ isFirstBlock
7438
+ }) {
7439
+ return /* @__PURE__ */ jsx(Hr, { className: "my-4 border-ui-border" });
7831
7440
  }
7832
- const checkedLoadedFor = {};
7833
- const shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
7834
- class Translator extends EventEmitter {
7835
- constructor(services, options = {}) {
7836
- super();
7837
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
7838
- this.options = options;
7839
- if (this.options.keySeparator === void 0) {
7840
- this.options.keySeparator = ".";
7841
- }
7842
- this.logger = baseLogger.create("translator");
7843
- }
7844
- changeLanguage(lng) {
7845
- if (lng) this.language = lng;
7846
- }
7847
- exists(key, o = {
7848
- interpolation: {}
7849
- }) {
7850
- const opt = {
7851
- ...o
7852
- };
7853
- if (key == null) return false;
7854
- const resolved = this.resolve(key, opt);
7855
- if ((resolved == null ? void 0 : resolved.res) === void 0) return false;
7856
- const isObject = shouldHandleAsObject(resolved.res);
7857
- if (opt.returnObjects === false && isObject) {
7858
- return false;
7859
- }
7860
- return true;
7861
- }
7862
- extractFromKey(key, opt) {
7863
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
7864
- if (nsSeparator === void 0) nsSeparator = ":";
7865
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
7866
- let namespaces = opt.ns || this.options.defaultNS || [];
7867
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
7868
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
7869
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
7870
- const m = key.match(this.interpolator.nestingRegexp);
7871
- if (m && m.length > 0) {
7872
- return {
7873
- key,
7874
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7875
- };
7876
- }
7877
- const parts = key.split(nsSeparator);
7878
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
7879
- key = parts.join(keySeparator);
7880
- }
7881
- return {
7882
- key,
7883
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7884
- };
7885
- }
7886
- translate(keys, o, lastKey) {
7887
- let opt = typeof o === "object" ? {
7888
- ...o
7889
- } : o;
7890
- if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
7891
- opt = this.options.overloadTranslationOptionHandler(arguments);
7892
- }
7893
- if (typeof opt === "object") opt = {
7894
- ...opt
7895
- };
7896
- if (!opt) opt = {};
7897
- if (keys == null) return "";
7898
- if (typeof keys === "function") keys = keysFromSelector(keys, {
7899
- ...this.options,
7900
- ...opt
7901
- });
7902
- if (!Array.isArray(keys)) keys = [String(keys)];
7903
- const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
7904
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
7905
- const {
7906
- key,
7907
- namespaces
7908
- } = this.extractFromKey(keys[keys.length - 1], opt);
7909
- const namespace = namespaces[namespaces.length - 1];
7910
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
7911
- if (nsSeparator === void 0) nsSeparator = ":";
7912
- const lng = opt.lng || this.language;
7913
- const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
7914
- if ((lng == null ? void 0 : lng.toLowerCase()) === "cimode") {
7915
- if (appendNamespaceToCIMode) {
7916
- if (returnDetails) {
7917
- return {
7918
- res: `${namespace}${nsSeparator}${key}`,
7919
- usedKey: key,
7920
- exactUsedKey: key,
7921
- usedLng: lng,
7922
- usedNS: namespace,
7923
- usedParams: this.getUsedParamsDetails(opt)
7924
- };
7925
- }
7926
- return `${namespace}${nsSeparator}${key}`;
7927
- }
7928
- if (returnDetails) {
7929
- return {
7930
- res: key,
7931
- usedKey: key,
7932
- exactUsedKey: key,
7933
- usedLng: lng,
7934
- usedNS: namespace,
7935
- usedParams: this.getUsedParamsDetails(opt)
7936
- };
7937
- }
7938
- return key;
7939
- }
7940
- const resolved = this.resolve(keys, opt);
7941
- let res = resolved == null ? void 0 : resolved.res;
7942
- const resUsedKey = (resolved == null ? void 0 : resolved.usedKey) || key;
7943
- const resExactUsedKey = (resolved == null ? void 0 : resolved.exactUsedKey) || key;
7944
- const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
7945
- const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
7946
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
7947
- const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
7948
- const hasDefaultValue = Translator.hasDefaultValue(opt);
7949
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
7950
- const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
7951
- ordinal: false
7952
- }) : "";
7953
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
7954
- const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
7955
- let resForObjHndl = res;
7956
- if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
7957
- resForObjHndl = defaultValue;
7958
- }
7959
- const handleAsObject = shouldHandleAsObject(resForObjHndl);
7960
- const resType = Object.prototype.toString.apply(resForObjHndl);
7961
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
7962
- if (!opt.returnObjects && !this.options.returnObjects) {
7963
- if (!this.options.returnedObjectHandler) {
7964
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
7965
- }
7966
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
7967
- ...opt,
7968
- ns: namespaces
7969
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
7970
- if (returnDetails) {
7971
- resolved.res = r;
7972
- resolved.usedParams = this.getUsedParamsDetails(opt);
7973
- return resolved;
7974
- }
7975
- return r;
7976
- }
7977
- if (keySeparator) {
7978
- const resTypeIsArray = Array.isArray(resForObjHndl);
7979
- const copy2 = resTypeIsArray ? [] : {};
7980
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
7981
- for (const m in resForObjHndl) {
7982
- if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
7983
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
7984
- if (hasDefaultValue && !res) {
7985
- copy2[m] = this.translate(deepKey, {
7986
- ...opt,
7987
- defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
7988
- ...{
7989
- joinArrays: false,
7990
- ns: namespaces
7991
- }
7992
- });
7993
- } else {
7994
- copy2[m] = this.translate(deepKey, {
7995
- ...opt,
7996
- ...{
7997
- joinArrays: false,
7998
- ns: namespaces
7999
- }
8000
- });
8001
- }
8002
- if (copy2[m] === deepKey) copy2[m] = resForObjHndl[m];
8003
- }
8004
- }
8005
- res = copy2;
8006
- }
8007
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
8008
- res = res.join(joinArrays);
8009
- if (res) res = this.extendTranslation(res, keys, opt, lastKey);
8010
- } else {
8011
- let usedDefault = false;
8012
- let usedKey = false;
8013
- if (!this.isValidLookup(res) && hasDefaultValue) {
8014
- usedDefault = true;
8015
- res = defaultValue;
8016
- }
8017
- if (!this.isValidLookup(res)) {
8018
- usedKey = true;
8019
- res = key;
8020
- }
8021
- const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
8022
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
8023
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
8024
- if (usedKey || usedDefault || updateMissing) {
8025
- this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
8026
- if (keySeparator) {
8027
- const fk = this.resolve(key, {
8028
- ...opt,
8029
- keySeparator: false
8030
- });
8031
- 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.");
8032
- }
8033
- let lngs = [];
8034
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
8035
- if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
8036
- for (let i = 0; i < fallbackLngs.length; i++) {
8037
- lngs.push(fallbackLngs[i]);
8038
- }
8039
- } else if (this.options.saveMissingTo === "all") {
8040
- lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
8041
- } else {
8042
- lngs.push(opt.lng || this.language);
8043
- }
8044
- const send = (l, k, specificDefaultValue) => {
8045
- var _a;
8046
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
8047
- if (this.options.missingKeyHandler) {
8048
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
8049
- } else if ((_a = this.backendConnector) == null ? void 0 : _a.saveMissing) {
8050
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
8051
- }
8052
- this.emit("missingKey", l, namespace, k, res);
8053
- };
8054
- if (this.options.saveMissing) {
8055
- if (this.options.saveMissingPlurals && needsPluralHandling) {
8056
- lngs.forEach((language) => {
8057
- const suffixes = this.pluralResolver.getSuffixes(language, opt);
8058
- if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
8059
- suffixes.push(`${this.options.pluralSeparator}zero`);
8060
- }
8061
- suffixes.forEach((suffix) => {
8062
- send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
8063
- });
8064
- });
8065
- } else {
8066
- send(lngs, key, defaultValue);
8067
- }
8068
- }
8069
- }
8070
- res = this.extendTranslation(res, keys, opt, resolved, lastKey);
8071
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
8072
- res = `${namespace}${nsSeparator}${key}`;
8073
- }
8074
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8075
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
8076
- }
8077
- }
8078
- if (returnDetails) {
8079
- resolved.res = res;
8080
- resolved.usedParams = this.getUsedParamsDetails(opt);
8081
- return resolved;
8082
- }
8083
- return res;
8084
- }
8085
- extendTranslation(res, key, opt, resolved, lastKey) {
8086
- var _a, _b;
8087
- if ((_a = this.i18nFormat) == null ? void 0 : _a.parse) {
8088
- res = this.i18nFormat.parse(res, {
8089
- ...this.options.interpolation.defaultVariables,
8090
- ...opt
8091
- }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
8092
- resolved
8093
- });
8094
- } else if (!opt.skipInterpolation) {
8095
- if (opt.interpolation) this.interpolator.init({
8096
- ...opt,
8097
- ...{
8098
- interpolation: {
8099
- ...this.options.interpolation,
8100
- ...opt.interpolation
8101
- }
8102
- }
8103
- });
8104
- const skipOnVariables = isString(res) && (((_b = opt == null ? void 0 : opt.interpolation) == null ? void 0 : _b.skipOnVariables) !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
8105
- let nestBef;
8106
- if (skipOnVariables) {
8107
- const nb = res.match(this.interpolator.nestingRegexp);
8108
- nestBef = nb && nb.length;
8109
- }
8110
- let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
8111
- if (this.options.interpolation.defaultVariables) data = {
8112
- ...this.options.interpolation.defaultVariables,
8113
- ...data
8114
- };
8115
- res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
8116
- if (skipOnVariables) {
8117
- const na = res.match(this.interpolator.nestingRegexp);
8118
- const nestAft = na && na.length;
8119
- if (nestBef < nestAft) opt.nest = false;
8120
- }
8121
- if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
8122
- if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
8123
- if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !opt.context) {
8124
- this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
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");
8125
7534
  return null;
8126
7535
  }
8127
- return this.translate(...args, key);
8128
- }, opt);
8129
- if (opt.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;
8130
7547
  }
8131
- const postProcess = opt.postProcess || this.options.postProcess;
8132
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
8133
- if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) && opt.applyPostProcessor !== false) {
8134
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
8135
- i18nResolved: {
8136
- ...resolved,
8137
- usedParams: this.getUsedParamsDetails(opt)
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
8138
7561
  },
8139
- ...opt
8140
- } : opt, this);
8141
- }
8142
- return res;
8143
- }
8144
- resolve(keys, opt = {}) {
8145
- let found;
8146
- let usedKey;
8147
- let exactUsedKey;
8148
- let usedLng;
8149
- let usedNS;
8150
- if (isString(keys)) keys = [keys];
8151
- keys.forEach((k) => {
8152
- if (this.isValidLookup(found)) return;
8153
- const extracted = this.extractFromKey(k, opt);
8154
- const key = extracted.key;
8155
- usedKey = key;
8156
- let namespaces = extracted.namespaces;
8157
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
8158
- const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
8159
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
8160
- const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
8161
- const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
8162
- namespaces.forEach((ns) => {
8163
- var _a, _b;
8164
- if (this.isValidLookup(found)) return;
8165
- usedNS = ns;
8166
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && ((_a = this.utils) == null ? void 0 : _a.hasLoadedNamespace) && !((_b = this.utils) == null ? void 0 : _b.hasLoadedNamespace(usedNS))) {
8167
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
8168
- 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!!!");
8169
- }
8170
- codes.forEach((code) => {
8171
- var _a2;
8172
- if (this.isValidLookup(found)) return;
8173
- usedLng = code;
8174
- const finalKeys = [key];
8175
- if ((_a2 = this.i18nFormat) == null ? void 0 : _a2.addLookupKeys) {
8176
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
8177
- } else {
8178
- let pluralSuffix;
8179
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
8180
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
8181
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
8182
- if (needsPluralHandling) {
8183
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8184
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8185
- }
8186
- finalKeys.push(key + pluralSuffix);
8187
- if (needsZeroSuffixLookup) {
8188
- finalKeys.push(key + zeroSuffix);
8189
- }
8190
- }
8191
- if (needsContextHandling) {
8192
- const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
8193
- finalKeys.push(contextKey);
8194
- if (needsPluralHandling) {
8195
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8196
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8197
- }
8198
- finalKeys.push(contextKey + pluralSuffix);
8199
- if (needsZeroSuffixLookup) {
8200
- finalKeys.push(contextKey + zeroSuffix);
8201
- }
8202
- }
8203
- }
8204
- }
8205
- let possibleKey;
8206
- while (possibleKey = finalKeys.pop()) {
8207
- if (!this.isValidLookup(found)) {
8208
- exactUsedKey = possibleKey;
8209
- found = this.getResource(code, ns, possibleKey, opt);
8210
- }
8211
- }
8212
- });
8213
- });
8214
- });
8215
- return {
8216
- res: found,
8217
- usedKey,
8218
- exactUsedKey,
8219
- usedLng,
8220
- usedNS
8221
- };
8222
- }
8223
- isValidLookup(res) {
8224
- return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
8225
- }
8226
- getResource(code, ns, key, options = {}) {
8227
- var _a;
8228
- if ((_a = this.i18nFormat) == null ? void 0 : _a.getResource) return this.i18nFormat.getResource(code, ns, key, options);
8229
- return this.resourceStore.getResource(code, ns, key, options);
8230
- }
8231
- getUsedParamsDetails(options = {}) {
8232
- const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
8233
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
8234
- let data = useOptionsReplaceForData ? options.replace : options;
8235
- if (useOptionsReplaceForData && typeof options.count !== "undefined") {
8236
- data.count = options.count;
8237
- }
8238
- if (this.options.interpolation.defaultVariables) {
8239
- data = {
8240
- ...this.options.interpolation.defaultVariables,
8241
- ...data
8242
- };
8243
- }
8244
- if (!useOptionsReplaceForData) {
8245
- data = {
8246
- ...data
8247
- };
8248
- for (const key of optionsKeys) {
8249
- delete data[key];
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 }) }) })
8250
7563
  }
8251
- }
8252
- return data;
8253
- }
8254
- static hasDefaultValue(options) {
8255
- const prefix = "defaultValue";
8256
- for (const option in options) {
8257
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && void 0 !== options[option]) {
8258
- return true;
8259
- }
8260
- }
8261
- return false;
8262
- }
7564
+ )
7565
+ ] });
8263
7566
  }
8264
- class LanguageUtil {
8265
- constructor(options) {
8266
- this.options = options;
8267
- this.supportedLngs = this.options.supportedLngs || false;
8268
- this.logger = baseLogger.create("languageUtils");
8269
- }
8270
- getScriptPartFromCode(code) {
8271
- code = getCleanedCode(code);
8272
- if (!code || code.indexOf("-") < 0) return null;
8273
- const p = code.split("-");
8274
- if (p.length === 2) return null;
8275
- p.pop();
8276
- if (p[p.length - 1].toLowerCase() === "x") return null;
8277
- return this.formatLanguageCode(p.join("-"));
8278
- }
8279
- getLanguagePartFromCode(code) {
8280
- code = getCleanedCode(code);
8281
- if (!code || code.indexOf("-") < 0) return code;
8282
- const p = code.split("-");
8283
- return this.formatLanguageCode(p[0]);
8284
- }
8285
- formatLanguageCode(code) {
8286
- if (isString(code) && code.indexOf("-") > -1) {
8287
- let formattedCode;
8288
- try {
8289
- formattedCode = Intl.getCanonicalLocales(code)[0];
8290
- } catch (e) {
8291
- }
8292
- if (formattedCode && this.options.lowerCaseLng) {
8293
- formattedCode = formattedCode.toLowerCase();
8294
- }
8295
- if (formattedCode) return formattedCode;
8296
- if (this.options.lowerCaseLng) {
8297
- return code.toLowerCase();
8298
- }
8299
- return code;
8300
- }
8301
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
8302
- }
8303
- isSupportedCode(code) {
8304
- if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
8305
- code = this.getLanguagePartFromCode(code);
8306
- }
8307
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
8308
- }
8309
- getBestMatchFromCodes(codes) {
8310
- if (!codes) return null;
8311
- let found;
8312
- codes.forEach((code) => {
8313
- if (found) return;
8314
- const cleanedLng = this.formatLanguageCode(code);
8315
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
8316
- });
8317
- if (!found && this.options.supportedLngs) {
8318
- codes.forEach((code) => {
8319
- if (found) return;
8320
- const lngScOnly = this.getScriptPartFromCode(code);
8321
- if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
8322
- const lngOnly = this.getLanguagePartFromCode(code);
8323
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
8324
- found = this.options.supportedLngs.find((supportedLng) => {
8325
- if (supportedLng === lngOnly) return supportedLng;
8326
- if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
8327
- if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
8328
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
8329
- });
8330
- });
8331
- }
8332
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
8333
- return found;
8334
- }
8335
- getFallbackCodes(fallbacks, code) {
8336
- if (!fallbacks) return [];
8337
- if (typeof fallbacks === "function") fallbacks = fallbacks(code);
8338
- if (isString(fallbacks)) fallbacks = [fallbacks];
8339
- if (Array.isArray(fallbacks)) return fallbacks;
8340
- if (!code) return fallbacks.default || [];
8341
- let found = fallbacks[code];
8342
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
8343
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
8344
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
8345
- if (!found) found = fallbacks.default;
8346
- return found || [];
8347
- }
8348
- toResolveHierarchy(code, fallbackCode) {
8349
- const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
8350
- const codes = [];
8351
- const addCode = (c) => {
8352
- if (!c) return;
8353
- if (this.isSupportedCode(c)) {
8354
- codes.push(c);
8355
- } else {
8356
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
8357
- }
8358
- };
8359
- if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
8360
- if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
8361
- if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
8362
- if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
8363
- } else if (isString(code)) {
8364
- addCode(this.formatLanguageCode(code));
8365
- }
8366
- fallbackCodes.forEach((fc) => {
8367
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
8368
- });
8369
- return codes;
8370
- }
7567
+ async function renderHTML(data, options) {
7568
+ return await pretty(await render(renderHTMLReact(data, options)));
8371
7569
  }
8372
- const suffixesOrder = {
8373
- zero: 0,
8374
- one: 1,
8375
- two: 2,
8376
- few: 3,
8377
- many: 4,
8378
- other: 5
8379
- };
8380
- const dummyRule = {
8381
- select: (count) => count === 1 ? "one" : "other",
8382
- resolvedOptions: () => ({
8383
- pluralCategories: ["one", "other"]
8384
- })
8385
- };
8386
- class PluralResolver {
8387
- constructor(languageUtils, options = {}) {
8388
- this.languageUtils = languageUtils;
8389
- this.options = options;
8390
- this.logger = baseLogger.create("pluralResolver");
8391
- this.pluralRulesCache = {};
8392
- }
8393
- addRule(lng, obj) {
8394
- this.rules[lng] = obj;
8395
- }
8396
- clearCache() {
8397
- this.pluralRulesCache = {};
8398
- }
8399
- getRule(code, options = {}) {
8400
- const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
8401
- const type = options.ordinal ? "ordinal" : "cardinal";
8402
- const cacheKey = JSON.stringify({
8403
- cleanedCode,
8404
- type
8405
- });
8406
- if (cacheKey in this.pluralRulesCache) {
8407
- return this.pluralRulesCache[cacheKey];
8408
- }
8409
- let rule;
8410
- try {
8411
- rule = new Intl.PluralRules(cleanedCode, {
8412
- type
8413
- });
8414
- } catch (err) {
8415
- if (!Intl) {
8416
- this.logger.error("No Intl support, please use an Intl polyfill!");
8417
- return dummyRule;
8418
- }
8419
- if (!code.match(/-|_/)) return dummyRule;
8420
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
8421
- rule = this.getRule(lngPart, options);
8422
- }
8423
- this.pluralRulesCache[cacheKey] = rule;
8424
- return rule;
8425
- }
8426
- needsPlural(code, options = {}) {
8427
- let rule = this.getRule(code, options);
8428
- if (!rule) rule = this.getRule("dev", options);
8429
- return (rule == null ? void 0 : rule.resolvedOptions().pluralCategories.length) > 1;
8430
- }
8431
- getPluralFormsOfKey(code, key, options = {}) {
8432
- return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
8433
- }
8434
- getSuffixes(code, options = {}) {
8435
- let rule = this.getRule(code, options);
8436
- if (!rule) rule = this.getRule("dev", options);
8437
- if (!rule) return [];
8438
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
8439
- }
8440
- getSuffix(code, count, options = {}) {
8441
- const rule = this.getRule(code, options);
8442
- if (rule) {
8443
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
8444
- }
8445
- this.logger.warn(`no plural rule found for: ${code}`);
8446
- return this.getSuffix("dev", count, options);
8447
- }
7570
+ async function renderText(data, options) {
7571
+ const html = await render(renderHTMLReact(data, options));
7572
+ return toPlainText(html);
8448
7573
  }
8449
- const deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
8450
- let path = getPathWithDefaults(data, defaultData, key);
8451
- if (!path && ignoreJSONStructure && isString(key)) {
8452
- path = deepFind(data, key, keySeparator);
8453
- if (path === void 0) path = deepFind(defaultData, key, keySeparator);
8454
- }
8455
- return path;
8456
- };
8457
- const regexSafe = (val) => val.replace(/\$/g, "$$$$");
8458
- class Interpolator {
8459
- constructor(options = {}) {
8460
- var _a;
8461
- this.logger = baseLogger.create("interpolator");
8462
- this.options = options;
8463
- this.format = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.format) || ((value) => value);
8464
- this.init(options);
8465
- }
8466
- init(options = {}) {
8467
- if (!options.interpolation) options.interpolation = {
8468
- escapeValue: true
8469
- };
8470
- const {
8471
- escape: escape$1,
8472
- escapeValue,
8473
- useRawValueToEscape,
8474
- prefix,
8475
- prefixEscaped,
8476
- suffix,
8477
- suffixEscaped,
8478
- formatSeparator,
8479
- unescapeSuffix,
8480
- unescapePrefix,
8481
- nestingPrefix,
8482
- nestingPrefixEscaped,
8483
- nestingSuffix,
8484
- nestingSuffixEscaped,
8485
- nestingOptionsSeparator,
8486
- maxReplaces,
8487
- alwaysFormat
8488
- } = options.interpolation;
8489
- this.escape = escape$1 !== void 0 ? escape$1 : escape;
8490
- this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
8491
- this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
8492
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
8493
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
8494
- this.formatSeparator = formatSeparator || ",";
8495
- this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
8496
- this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
8497
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
8498
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
8499
- this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
8500
- this.maxReplaces = maxReplaces || 1e3;
8501
- this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
8502
- this.resetRegExp();
8503
- }
8504
- reset() {
8505
- if (this.options) this.init(this.options);
8506
- }
8507
- resetRegExp() {
8508
- const getOrResetRegExp = (existingRegExp, pattern) => {
8509
- if ((existingRegExp == null ? void 0 : existingRegExp.source) === pattern) {
8510
- existingRegExp.lastIndex = 0;
8511
- return existingRegExp;
8512
- }
8513
- return new RegExp(pattern, "g");
8514
- };
8515
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
8516
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
8517
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
8518
- }
8519
- interpolate(str, data, lng, options) {
8520
- var _a;
8521
- let match2;
8522
- let value;
8523
- let replaces;
8524
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
8525
- const handleFormat = (key) => {
8526
- if (key.indexOf(this.formatSeparator) < 0) {
8527
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
8528
- return this.alwaysFormat ? this.format(path, void 0, lng, {
8529
- ...options,
8530
- ...data,
8531
- interpolationkey: key
8532
- }) : path;
8533
- }
8534
- const p = key.split(this.formatSeparator);
8535
- const k = p.shift().trim();
8536
- const f = p.join(this.formatSeparator).trim();
8537
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
8538
- ...options,
8539
- ...data,
8540
- interpolationkey: k
8541
- });
8542
- };
8543
- this.resetRegExp();
8544
- const missingInterpolationHandler = (options == null ? void 0 : options.missingInterpolationHandler) || this.options.missingInterpolationHandler;
8545
- const skipOnVariables = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.skipOnVariables) !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
8546
- const todos = [{
8547
- regex: this.regexpUnescape,
8548
- safeValue: (val) => regexSafe(val)
8549
- }, {
8550
- regex: this.regexp,
8551
- safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
8552
- }];
8553
- todos.forEach((todo) => {
8554
- replaces = 0;
8555
- while (match2 = todo.regex.exec(str)) {
8556
- const matchedVar = match2[1].trim();
8557
- value = handleFormat(matchedVar);
8558
- if (value === void 0) {
8559
- if (typeof missingInterpolationHandler === "function") {
8560
- const temp = missingInterpolationHandler(str, match2, options);
8561
- value = isString(temp) ? temp : "";
8562
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
8563
- value = "";
8564
- } else if (skipOnVariables) {
8565
- value = match2[0];
8566
- continue;
8567
- } else {
8568
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
8569
- value = "";
8570
- }
8571
- } else if (!isString(value) && !this.useRawValueToEscape) {
8572
- value = makeString(value);
8573
- }
8574
- const safeValue = todo.safeValue(value);
8575
- str = str.replace(match2[0], safeValue);
8576
- if (skipOnVariables) {
8577
- todo.regex.lastIndex += value.length;
8578
- todo.regex.lastIndex -= match2[0].length;
8579
- } else {
8580
- todo.regex.lastIndex = 0;
8581
- }
8582
- replaces++;
8583
- if (replaces >= this.maxReplaces) {
8584
- break;
8585
- }
8586
- }
8587
- });
8588
- return str;
8589
- }
8590
- nest(str, fc, options = {}) {
8591
- let match2;
8592
- let value;
8593
- let clonedOptions;
8594
- const handleHasOptions = (key, inheritedOptions) => {
8595
- const sep = this.nestingOptionsSeparator;
8596
- if (key.indexOf(sep) < 0) return key;
8597
- const c = key.split(new RegExp(`${sep}[ ]*{`));
8598
- let optionsString = `{${c[1]}`;
8599
- key = c[0];
8600
- optionsString = this.interpolate(optionsString, clonedOptions);
8601
- const matchedSingleQuotes = optionsString.match(/'/g);
8602
- const matchedDoubleQuotes = optionsString.match(/"/g);
8603
- if (((matchedSingleQuotes == null ? void 0 : matchedSingleQuotes.length) ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
8604
- optionsString = optionsString.replace(/'/g, '"');
8605
- }
8606
- try {
8607
- clonedOptions = JSON.parse(optionsString);
8608
- if (inheritedOptions) clonedOptions = {
8609
- ...inheritedOptions,
8610
- ...clonedOptions
8611
- };
8612
- } catch (e) {
8613
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
8614
- return `${key}${sep}${optionsString}`;
8615
- }
8616
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
8617
- return key;
8618
- };
8619
- while (match2 = this.nestingRegexp.exec(str)) {
8620
- let formatters2 = [];
8621
- clonedOptions = {
8622
- ...options
8623
- };
8624
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
8625
- clonedOptions.applyPostProcessor = false;
8626
- delete clonedOptions.defaultValue;
8627
- const keyEndIndex = /{.*}/.test(match2[1]) ? match2[1].lastIndexOf("}") + 1 : match2[1].indexOf(this.formatSeparator);
8628
- if (keyEndIndex !== -1) {
8629
- formatters2 = match2[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
8630
- match2[1] = match2[1].slice(0, keyEndIndex);
8631
- }
8632
- value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
8633
- if (value && match2[0] === str && !isString(value)) return value;
8634
- if (!isString(value)) value = makeString(value);
8635
- if (!value) {
8636
- this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
8637
- value = "";
8638
- }
8639
- if (formatters2.length) {
8640
- value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
8641
- ...options,
8642
- interpolationkey: match2[1].trim()
8643
- }), value.trim());
8644
- }
8645
- str = str.replace(match2[0], value);
8646
- this.regexp.lastIndex = 0;
8647
- }
8648
- return str;
8649
- }
7574
+ async function getBaseTemplateHtml(data, options) {
7575
+ return await renderHTML(data, options);
8650
7576
  }
8651
- const parseFormatStr = (formatStr) => {
8652
- let formatName = formatStr.toLowerCase().trim();
8653
- const formatOptions = {};
8654
- if (formatStr.indexOf("(") > -1) {
8655
- const p = formatStr.split("(");
8656
- formatName = p[0].toLowerCase().trim();
8657
- const optStr = p[1].substring(0, p[1].length - 1);
8658
- if (formatName === "currency" && optStr.indexOf(":") < 0) {
8659
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
8660
- } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
8661
- if (!formatOptions.range) formatOptions.range = optStr.trim();
8662
- } else {
8663
- const opts = optStr.split(";");
8664
- opts.forEach((opt) => {
8665
- if (opt) {
8666
- const [key, ...rest] = opt.split(":");
8667
- const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
8668
- const trimmedKey = key.trim();
8669
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
8670
- if (val === "false") formatOptions[trimmedKey] = false;
8671
- if (val === "true") formatOptions[trimmedKey] = true;
8672
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
8673
- }
8674
- });
8675
- }
8676
- }
8677
- return {
8678
- formatName,
8679
- formatOptions
8680
- };
8681
- };
8682
- const createCachedFormatter = (fn) => {
8683
- const cache = {};
8684
- return (v, l, o) => {
8685
- let optForCache = o;
8686
- if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
8687
- optForCache = {
8688
- ...optForCache,
8689
- [o.interpolationkey]: void 0
8690
- };
8691
- }
8692
- const key = l + JSON.stringify(optForCache);
8693
- let frm = cache[key];
8694
- if (!frm) {
8695
- frm = fn(getCleanedCode(l), o);
8696
- cache[key] = frm;
8697
- }
8698
- return frm(v);
8699
- };
8700
- };
8701
- const createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
8702
- class Formatter {
8703
- constructor(options = {}) {
8704
- this.logger = baseLogger.create("formatter");
8705
- this.options = options;
8706
- this.init(options);
8707
- }
8708
- init(services, options = {
8709
- interpolation: {}
8710
- }) {
8711
- this.formatSeparator = options.interpolation.formatSeparator || ",";
8712
- const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
8713
- this.formats = {
8714
- number: cf((lng, opt) => {
8715
- const formatter = new Intl.NumberFormat(lng, {
8716
- ...opt
8717
- });
8718
- return (val) => formatter.format(val);
8719
- }),
8720
- currency: cf((lng, opt) => {
8721
- const formatter = new Intl.NumberFormat(lng, {
8722
- ...opt,
8723
- style: "currency"
8724
- });
8725
- return (val) => formatter.format(val);
8726
- }),
8727
- datetime: cf((lng, opt) => {
8728
- const formatter = new Intl.DateTimeFormat(lng, {
8729
- ...opt
8730
- });
8731
- return (val) => formatter.format(val);
8732
- }),
8733
- relativetime: cf((lng, opt) => {
8734
- const formatter = new Intl.RelativeTimeFormat(lng, {
8735
- ...opt
8736
- });
8737
- return (val) => formatter.format(val, opt.range || "day");
8738
- }),
8739
- list: cf((lng, opt) => {
8740
- const formatter = new Intl.ListFormat(lng, {
8741
- ...opt
8742
- });
8743
- return (val) => formatter.format(val);
8744
- })
8745
- };
8746
- }
8747
- add(name, fc) {
8748
- this.formats[name.toLowerCase().trim()] = fc;
8749
- }
8750
- addCached(name, fc) {
8751
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
8752
- }
8753
- format(value, format2, lng, options = {}) {
8754
- const formats = format2.split(this.formatSeparator);
8755
- if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
8756
- const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
8757
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
8758
- }
8759
- const result = formats.reduce((mem, f) => {
8760
- var _a;
8761
- const {
8762
- formatName,
8763
- formatOptions
8764
- } = parseFormatStr(f);
8765
- if (this.formats[formatName]) {
8766
- let formatted = mem;
8767
- try {
8768
- const valOptions = ((_a = options == null ? void 0 : options.formatParams) == null ? void 0 : _a[options.interpolationkey]) || {};
8769
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
8770
- formatted = this.formats[formatName](mem, l, {
8771
- ...formatOptions,
8772
- ...options,
8773
- ...valOptions
8774
- });
8775
- } catch (error) {
8776
- this.logger.warn(error);
8777
- }
8778
- return formatted;
8779
- } else {
8780
- this.logger.warn(`there was no format function for ${formatName}`);
8781
- }
8782
- return mem;
8783
- }, value);
8784
- return result;
8785
- }
7577
+ async function getBaseTemplateText(data, options) {
7578
+ return await renderText(data, options);
8786
7579
  }
8787
- const removePending = (q, name) => {
8788
- if (q.pending[name] !== void 0) {
8789
- delete q.pending[name];
8790
- q.pendingCount--;
8791
- }
8792
- };
8793
- class Connector extends EventEmitter {
8794
- constructor(backend, store, services, options = {}) {
8795
- var _a, _b;
8796
- super();
8797
- this.backend = backend;
8798
- this.store = store;
8799
- this.services = services;
8800
- this.languageUtils = services.languageUtils;
8801
- this.options = options;
8802
- this.logger = baseLogger.create("backendConnector");
8803
- this.waitingReads = [];
8804
- this.maxParallelReads = options.maxParallelReads || 10;
8805
- this.readingCalls = 0;
8806
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
8807
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
8808
- this.state = {};
8809
- this.queue = [];
8810
- (_b = (_a = this.backend) == null ? void 0 : _a.init) == null ? void 0 : _b.call(_a, services, options.backend, options);
8811
- }
8812
- queueLoad(languages, namespaces, options, callback) {
8813
- const toLoad = {};
8814
- const pending = {};
8815
- const toLoadLanguages = {};
8816
- const toLoadNamespaces = {};
8817
- languages.forEach((lng) => {
8818
- let hasAllNamespaces = true;
8819
- namespaces.forEach((ns) => {
8820
- const name = `${lng}|${ns}`;
8821
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
8822
- this.state[name] = 2;
8823
- } else if (this.state[name] < 0) ;
8824
- else if (this.state[name] === 1) {
8825
- if (pending[name] === void 0) pending[name] = true;
8826
- } else {
8827
- this.state[name] = 1;
8828
- hasAllNamespaces = false;
8829
- if (pending[name] === void 0) pending[name] = true;
8830
- if (toLoad[name] === void 0) toLoad[name] = true;
8831
- if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
8832
- }
8833
- });
8834
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
8835
- });
8836
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
8837
- this.queue.push({
8838
- pending,
8839
- pendingCount: Object.keys(pending).length,
8840
- loaded: {},
8841
- errors: [],
8842
- callback
8843
- });
8844
- }
8845
- return {
8846
- toLoad: Object.keys(toLoad),
8847
- pending: Object.keys(pending),
8848
- toLoadLanguages: Object.keys(toLoadLanguages),
8849
- toLoadNamespaces: Object.keys(toLoadNamespaces)
8850
- };
8851
- }
8852
- loaded(name, err, data) {
8853
- const s = name.split("|");
8854
- const lng = s[0];
8855
- const ns = s[1];
8856
- if (err) this.emit("failedLoading", lng, ns, err);
8857
- if (!err && data) {
8858
- this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
8859
- skipCopy: true
8860
- });
8861
- }
8862
- this.state[name] = err ? -1 : 2;
8863
- if (err && data) this.state[name] = 0;
8864
- const loaded = {};
8865
- this.queue.forEach((q) => {
8866
- pushPath(q.loaded, [lng], ns);
8867
- removePending(q, name);
8868
- if (err) q.errors.push(err);
8869
- if (q.pendingCount === 0 && !q.done) {
8870
- Object.keys(q.loaded).forEach((l) => {
8871
- if (!loaded[l]) loaded[l] = {};
8872
- const loadedKeys = q.loaded[l];
8873
- if (loadedKeys.length) {
8874
- loadedKeys.forEach((n) => {
8875
- if (loaded[l][n] === void 0) loaded[l][n] = true;
8876
- });
8877
- }
8878
- });
8879
- q.done = true;
8880
- if (q.errors.length) {
8881
- q.callback(q.errors);
8882
- } else {
8883
- q.callback();
8884
- }
8885
- }
8886
- });
8887
- this.emit("loaded", loaded);
8888
- this.queue = this.queue.filter((q) => !q.done);
8889
- }
8890
- read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
8891
- if (!lng.length) return callback(null, {});
8892
- if (this.readingCalls >= this.maxParallelReads) {
8893
- this.waitingReads.push({
8894
- lng,
8895
- ns,
8896
- fcName,
8897
- tried,
8898
- wait,
8899
- callback
8900
- });
8901
- return;
8902
- }
8903
- this.readingCalls++;
8904
- const resolver = (err, data) => {
8905
- this.readingCalls--;
8906
- if (this.waitingReads.length > 0) {
8907
- const next = this.waitingReads.shift();
8908
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
8909
- }
8910
- if (err && data && tried < this.maxRetries) {
8911
- setTimeout(() => {
8912
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
8913
- }, wait);
8914
- return;
8915
- }
8916
- callback(err, data);
8917
- };
8918
- const fc = this.backend[fcName].bind(this.backend);
8919
- if (fc.length === 2) {
8920
- try {
8921
- const r = fc(lng, ns);
8922
- if (r && typeof r.then === "function") {
8923
- r.then((data) => resolver(null, data)).catch(resolver);
8924
- } else {
8925
- resolver(null, r);
8926
- }
8927
- } catch (err) {
8928
- resolver(err);
8929
- }
8930
- return;
8931
- }
8932
- return fc(lng, ns, resolver);
8933
- }
8934
- prepareLoading(languages, namespaces, options = {}, callback) {
8935
- if (!this.backend) {
8936
- this.logger.warn("No backend was added via i18next.use. Will not load resources.");
8937
- return callback && callback();
8938
- }
8939
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
8940
- if (isString(namespaces)) namespaces = [namespaces];
8941
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
8942
- if (!toLoad.toLoad.length) {
8943
- if (!toLoad.pending.length) callback();
8944
- return null;
8945
- }
8946
- toLoad.toLoad.forEach((name) => {
8947
- this.loadOne(name);
8948
- });
8949
- }
8950
- load(languages, namespaces, callback) {
8951
- this.prepareLoading(languages, namespaces, {}, callback);
8952
- }
8953
- reload(languages, namespaces, callback) {
8954
- this.prepareLoading(languages, namespaces, {
8955
- reload: true
8956
- }, callback);
8957
- }
8958
- loadOne(name, prefix = "") {
8959
- const s = name.split("|");
8960
- const lng = s[0];
8961
- const ns = s[1];
8962
- this.read(lng, ns, "read", void 0, void 0, (err, data) => {
8963
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
8964
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
8965
- this.loaded(name, err, data);
8966
- });
8967
- }
8968
- saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
8969
- }) {
8970
- var _a, _b, _c, _d, _e;
8971
- if (((_b = (_a = this.services) == null ? void 0 : _a.utils) == null ? void 0 : _b.hasLoadedNamespace) && !((_d = (_c = this.services) == null ? void 0 : _c.utils) == null ? void 0 : _d.hasLoadedNamespace(namespace))) {
8972
- 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!!!");
8973
- return;
8974
- }
8975
- if (key === void 0 || key === null || key === "") return;
8976
- if ((_e = this.backend) == null ? void 0 : _e.create) {
8977
- const opts = {
8978
- ...options,
8979
- isUpdate
8980
- };
8981
- const fc = this.backend.create.bind(this.backend);
8982
- if (fc.length < 6) {
8983
- try {
8984
- let r;
8985
- if (fc.length === 5) {
8986
- r = fc(languages, namespace, key, fallbackValue, opts);
8987
- } else {
8988
- r = fc(languages, namespace, key, fallbackValue);
8989
- }
8990
- if (r && typeof r.then === "function") {
8991
- r.then((data) => clb(null, data)).catch(clb);
8992
- } else {
8993
- clb(null, r);
8994
- }
8995
- } catch (err) {
8996
- clb(err);
8997
- }
8998
- } else {
8999
- fc(languages, namespace, key, fallbackValue, clb, opts);
9000
- }
9001
- }
9002
- if (!languages || !languages[0]) return;
9003
- this.store.addResource(languages[0], namespace, key, fallbackValue);
9004
- }
7580
+ function getBaseTemplateReactNode(data, options) {
7581
+ return renderHTMLReact(data, options);
9005
7582
  }
9006
- const get = () => ({
9007
- debug: false,
9008
- initAsync: true,
9009
- ns: ["translation"],
9010
- defaultNS: ["translation"],
9011
- fallbackLng: ["dev"],
9012
- fallbackNS: false,
9013
- supportedLngs: false,
9014
- nonExplicitSupportedLngs: false,
9015
- load: "all",
9016
- preload: false,
9017
- simplifyPluralSuffix: true,
9018
- keySeparator: ".",
9019
- nsSeparator: ":",
9020
- pluralSeparator: "_",
9021
- contextSeparator: "_",
9022
- partialBundledLanguages: false,
9023
- saveMissing: false,
9024
- updateMissing: false,
9025
- saveMissingTo: "fallback",
9026
- saveMissingPlurals: true,
9027
- missingKeyHandler: false,
9028
- missingInterpolationHandler: false,
9029
- postProcess: false,
9030
- postProcessPassResolved: false,
9031
- returnNull: false,
9032
- returnEmptyString: true,
9033
- returnObjects: false,
9034
- joinArrays: false,
9035
- returnedObjectHandler: false,
9036
- parseMissingKeyHandler: false,
9037
- appendNamespaceToMissingKey: false,
9038
- appendNamespaceToCIMode: false,
9039
- overloadTranslationOptionHandler: (args) => {
9040
- let ret = {};
9041
- if (typeof args[1] === "object") ret = args[1];
9042
- if (isString(args[1])) ret.defaultValue = args[1];
9043
- if (isString(args[2])) ret.tDescription = args[2];
9044
- if (typeof args[2] === "object" || typeof args[3] === "object") {
9045
- const options = args[3] || args[2];
9046
- Object.keys(options).forEach((key) => {
9047
- ret[key] = options[key];
9048
- });
9049
- }
9050
- return ret;
9051
- },
9052
- interpolation: {
9053
- escapeValue: true,
9054
- format: (value) => value,
9055
- prefix: "{{",
9056
- suffix: "}}",
9057
- formatSeparator: ",",
9058
- unescapePrefix: "-",
9059
- nestingPrefix: "$t(",
9060
- nestingSuffix: ")",
9061
- nestingOptionsSeparator: ",",
9062
- maxReplaces: 1e3,
9063
- skipOnVariables: true
9064
- },
9065
- cacheInBuiltFormats: true
9066
- });
9067
- const transformOptions = (options) => {
9068
- var _a, _b;
9069
- if (isString(options.ns)) options.ns = [options.ns];
9070
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
9071
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
9072
- if (((_b = (_a = options.supportedLngs) == null ? void 0 : _a.indexOf) == null ? void 0 : _b.call(_a, "cimode")) < 0) {
9073
- options.supportedLngs = options.supportedLngs.concat(["cimode"]);
9074
- }
9075
- if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
9076
- return options;
9077
- };
9078
- const noop = () => {
9079
- };
9080
- const bindMemberFunctions = (inst) => {
9081
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
9082
- mems.forEach((mem) => {
9083
- if (typeof inst[mem] === "function") {
9084
- inst[mem] = inst[mem].bind(inst);
9085
- }
9086
- });
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"
9087
7589
  };
9088
- class I18n extends EventEmitter {
9089
- constructor(options = {}, callback) {
9090
- super();
9091
- this.options = transformOptions(options);
9092
- this.services = {};
9093
- this.logger = baseLogger;
9094
- this.modules = {
9095
- external: []
9096
- };
9097
- bindMemberFunctions(this);
9098
- if (callback && !this.isInitialized && !options.isClone) {
9099
- if (!this.options.initAsync) {
9100
- this.init(options, callback);
9101
- return this;
9102
- }
9103
- setTimeout(() => {
9104
- this.init(options, callback);
9105
- }, 0);
9106
- }
9107
- }
9108
- init(options = {}, callback) {
9109
- this.isInitializing = true;
9110
- if (typeof options === "function") {
9111
- callback = options;
9112
- options = {};
9113
- }
9114
- if (options.defaultNS == null && options.ns) {
9115
- if (isString(options.ns)) {
9116
- options.defaultNS = options.ns;
9117
- } else if (options.ns.indexOf("translation") < 0) {
9118
- options.defaultNS = options.ns[0];
9119
- }
9120
- }
9121
- const defOpts = get();
9122
- this.options = {
9123
- ...defOpts,
9124
- ...this.options,
9125
- ...transformOptions(options)
9126
- };
9127
- this.options.interpolation = {
9128
- ...defOpts.interpolation,
9129
- ...this.options.interpolation
9130
- };
9131
- if (options.keySeparator !== void 0) {
9132
- this.options.userDefinedKeySeparator = options.keySeparator;
9133
- }
9134
- if (options.nsSeparator !== void 0) {
9135
- this.options.userDefinedNsSeparator = options.nsSeparator;
9136
- }
9137
- const createClassOnDemand = (ClassOrObject) => {
9138
- if (!ClassOrObject) return null;
9139
- if (typeof ClassOrObject === "function") return new ClassOrObject();
9140
- return ClassOrObject;
9141
- };
9142
- if (!this.options.isClone) {
9143
- if (this.modules.logger) {
9144
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
9145
- } else {
9146
- baseLogger.init(null, this.options);
9147
- }
9148
- let formatter;
9149
- if (this.modules.formatter) {
9150
- formatter = this.modules.formatter;
9151
- } else {
9152
- formatter = Formatter;
9153
- }
9154
- const lu = new LanguageUtil(this.options);
9155
- this.store = new ResourceStore(this.options.resources, this.options);
9156
- const s = this.services;
9157
- s.logger = baseLogger;
9158
- s.resourceStore = this.store;
9159
- s.languageUtils = lu;
9160
- s.pluralResolver = new PluralResolver(lu, {
9161
- prepend: this.options.pluralSeparator,
9162
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
9163
- });
9164
- const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
9165
- if (usingLegacyFormatFunction) {
9166
- this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
9167
- }
9168
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9169
- s.formatter = createClassOnDemand(formatter);
9170
- if (s.formatter.init) s.formatter.init(s, this.options);
9171
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
9172
- }
9173
- s.interpolator = new Interpolator(this.options);
9174
- s.utils = {
9175
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
9176
- };
9177
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
9178
- s.backendConnector.on("*", (event, ...args) => {
9179
- this.emit(event, ...args);
9180
- });
9181
- if (this.modules.languageDetector) {
9182
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
9183
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
9184
- }
9185
- if (this.modules.i18nFormat) {
9186
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
9187
- if (s.i18nFormat.init) s.i18nFormat.init(this);
9188
- }
9189
- this.translator = new Translator(this.services, this.options);
9190
- this.translator.on("*", (event, ...args) => {
9191
- this.emit(event, ...args);
9192
- });
9193
- this.modules.external.forEach((m) => {
9194
- if (m.init) m.init(this);
9195
- });
9196
- }
9197
- this.format = this.options.interpolation.format;
9198
- if (!callback) callback = noop;
9199
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
9200
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9201
- if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
9202
- }
9203
- if (!this.services.languageDetector && !this.options.lng) {
9204
- this.logger.warn("init: no languageDetector is used and no lng is defined");
9205
- }
9206
- const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
9207
- storeApi.forEach((fcName) => {
9208
- this[fcName] = (...args) => this.store[fcName](...args);
9209
- });
9210
- const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
9211
- storeApiChained.forEach((fcName) => {
9212
- this[fcName] = (...args) => {
9213
- this.store[fcName](...args);
9214
- return this;
9215
- };
9216
- });
9217
- const deferred = defer();
9218
- const load = () => {
9219
- const finish = (err, t) => {
9220
- this.isInitializing = false;
9221
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
9222
- this.isInitialized = true;
9223
- if (!this.options.isClone) this.logger.log("initialized", this.options);
9224
- this.emit("initialized", this.options);
9225
- deferred.resolve(t);
9226
- callback(err, t);
9227
- };
9228
- if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
9229
- this.changeLanguage(this.options.lng, finish);
9230
- };
9231
- if (this.options.resources || !this.options.initAsync) {
9232
- load();
9233
- } else {
9234
- setTimeout(load, 0);
9235
- }
9236
- return deferred;
9237
- }
9238
- loadResources(language, callback = noop) {
9239
- var _a, _b;
9240
- let usedCallback = callback;
9241
- const usedLng = isString(language) ? language : this.language;
9242
- if (typeof language === "function") usedCallback = language;
9243
- if (!this.options.resources || this.options.partialBundledLanguages) {
9244
- if ((usedLng == null ? void 0 : usedLng.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
9245
- const toLoad = [];
9246
- const append = (lng) => {
9247
- if (!lng) return;
9248
- if (lng === "cimode") return;
9249
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
9250
- lngs.forEach((l) => {
9251
- if (l === "cimode") return;
9252
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
9253
- });
9254
- };
9255
- if (!usedLng) {
9256
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9257
- fallbacks.forEach((l) => append(l));
9258
- } else {
9259
- append(usedLng);
9260
- }
9261
- (_b = (_a = this.options.preload) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (l) => append(l));
9262
- this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
9263
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
9264
- usedCallback(e);
9265
- });
9266
- } else {
9267
- usedCallback(null);
9268
- }
9269
- }
9270
- reloadResources(lngs, ns, callback) {
9271
- const deferred = defer();
9272
- if (typeof lngs === "function") {
9273
- callback = lngs;
9274
- lngs = void 0;
9275
- }
9276
- if (typeof ns === "function") {
9277
- callback = ns;
9278
- ns = void 0;
9279
- }
9280
- if (!lngs) lngs = this.languages;
9281
- if (!ns) ns = this.options.ns;
9282
- if (!callback) callback = noop;
9283
- this.services.backendConnector.reload(lngs, ns, (err) => {
9284
- deferred.resolve();
9285
- callback(err);
9286
- });
9287
- return deferred;
9288
- }
9289
- use(module) {
9290
- if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
9291
- if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
9292
- if (module.type === "backend") {
9293
- this.modules.backend = module;
9294
- }
9295
- if (module.type === "logger" || module.log && module.warn && module.error) {
9296
- this.modules.logger = module;
9297
- }
9298
- if (module.type === "languageDetector") {
9299
- this.modules.languageDetector = module;
9300
- }
9301
- if (module.type === "i18nFormat") {
9302
- this.modules.i18nFormat = module;
9303
- }
9304
- if (module.type === "postProcessor") {
9305
- postProcessor.addPostProcessor(module);
9306
- }
9307
- if (module.type === "formatter") {
9308
- this.modules.formatter = module;
9309
- }
9310
- if (module.type === "3rdParty") {
9311
- this.modules.external.push(module);
9312
- }
9313
- return this;
9314
- }
9315
- setResolvedLanguage(l) {
9316
- if (!l || !this.languages) return;
9317
- if (["cimode", "dev"].indexOf(l) > -1) return;
9318
- for (let li = 0; li < this.languages.length; li++) {
9319
- const lngInLngs = this.languages[li];
9320
- if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
9321
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
9322
- this.resolvedLanguage = lngInLngs;
9323
- break;
9324
- }
9325
- }
9326
- if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
9327
- this.resolvedLanguage = l;
9328
- this.languages.unshift(l);
9329
- }
9330
- }
9331
- changeLanguage(lng, callback) {
9332
- this.isLanguageChangingTo = lng;
9333
- const deferred = defer();
9334
- this.emit("languageChanging", lng);
9335
- const setLngProps = (l) => {
9336
- this.language = l;
9337
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
9338
- this.resolvedLanguage = void 0;
9339
- this.setResolvedLanguage(l);
9340
- };
9341
- const done = (err, l) => {
9342
- if (l) {
9343
- if (this.isLanguageChangingTo === lng) {
9344
- setLngProps(l);
9345
- this.translator.changeLanguage(l);
9346
- this.isLanguageChangingTo = void 0;
9347
- this.emit("languageChanged", l);
9348
- this.logger.log("languageChanged", l);
9349
- }
9350
- } else {
9351
- this.isLanguageChangingTo = void 0;
9352
- }
9353
- deferred.resolve((...args) => this.t(...args));
9354
- if (callback) callback(err, (...args) => this.t(...args));
9355
- };
9356
- const setLng = (lngs) => {
9357
- var _a, _b;
9358
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
9359
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
9360
- const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
9361
- if (l) {
9362
- if (!this.language) {
9363
- setLngProps(l);
9364
- }
9365
- if (!this.translator.language) this.translator.changeLanguage(l);
9366
- (_b = (_a = this.services.languageDetector) == null ? void 0 : _a.cacheUserLanguage) == null ? void 0 : _b.call(_a, l);
9367
- }
9368
- this.loadResources(l, (err) => {
9369
- done(err, l);
9370
- });
9371
- };
9372
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
9373
- setLng(this.services.languageDetector.detect());
9374
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
9375
- if (this.services.languageDetector.detect.length === 0) {
9376
- this.services.languageDetector.detect().then(setLng);
9377
- } else {
9378
- this.services.languageDetector.detect(setLng);
9379
- }
9380
- } else {
9381
- setLng(lng);
9382
- }
9383
- return deferred;
9384
- }
9385
- getFixedT(lng, ns, keyPrefix) {
9386
- const fixedT = (key, opts, ...rest) => {
9387
- let o;
9388
- if (typeof opts !== "object") {
9389
- o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9390
- } else {
9391
- o = {
9392
- ...opts
9393
- };
9394
- }
9395
- o.lng = o.lng || fixedT.lng;
9396
- o.lngs = o.lngs || fixedT.lngs;
9397
- o.ns = o.ns || fixedT.ns;
9398
- if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
9399
- const keySeparator = this.options.keySeparator || ".";
9400
- let resultKey;
9401
- if (o.keyPrefix && Array.isArray(key)) {
9402
- resultKey = key.map((k) => {
9403
- if (typeof k === "function") k = keysFromSelector(k, {
9404
- ...this.options,
9405
- ...opts
9406
- });
9407
- return `${o.keyPrefix}${keySeparator}${k}`;
9408
- });
9409
- } else {
9410
- if (typeof key === "function") key = keysFromSelector(key, {
9411
- ...this.options,
9412
- ...opts
9413
- });
9414
- resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
9415
- }
9416
- return this.t(resultKey, o);
9417
- };
9418
- if (isString(lng)) {
9419
- fixedT.lng = lng;
9420
- } else {
9421
- fixedT.lngs = lng;
9422
- }
9423
- fixedT.ns = ns;
9424
- fixedT.keyPrefix = keyPrefix;
9425
- return fixedT;
9426
- }
9427
- t(...args) {
9428
- var _a;
9429
- return (_a = this.translator) == null ? void 0 : _a.translate(...args);
9430
- }
9431
- exists(...args) {
9432
- var _a;
9433
- return (_a = this.translator) == null ? void 0 : _a.exists(...args);
9434
- }
9435
- setDefaultNamespace(ns) {
9436
- this.options.defaultNS = ns;
9437
- }
9438
- hasLoadedNamespace(ns, options = {}) {
9439
- if (!this.isInitialized) {
9440
- this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
9441
- return false;
9442
- }
9443
- if (!this.languages || !this.languages.length) {
9444
- this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
9445
- return false;
9446
- }
9447
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
9448
- const fallbackLng = this.options ? this.options.fallbackLng : false;
9449
- const lastLng = this.languages[this.languages.length - 1];
9450
- if (lng.toLowerCase() === "cimode") return true;
9451
- const loadNotPending = (l, n) => {
9452
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
9453
- return loadState === -1 || loadState === 0 || loadState === 2;
9454
- };
9455
- if (options.precheck) {
9456
- const preResult = options.precheck(this, loadNotPending);
9457
- if (preResult !== void 0) return preResult;
9458
- }
9459
- if (this.hasResourceBundle(lng, ns)) return true;
9460
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
9461
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
9462
- return false;
9463
- }
9464
- loadNamespaces(ns, callback) {
9465
- const deferred = defer();
9466
- if (!this.options.ns) {
9467
- if (callback) callback();
9468
- return Promise.resolve();
9469
- }
9470
- if (isString(ns)) ns = [ns];
9471
- ns.forEach((n) => {
9472
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
9473
- });
9474
- this.loadResources((err) => {
9475
- deferred.resolve();
9476
- if (callback) callback(err);
9477
- });
9478
- return deferred;
9479
- }
9480
- loadLanguages(lngs, callback) {
9481
- const deferred = defer();
9482
- if (isString(lngs)) lngs = [lngs];
9483
- const preloaded = this.options.preload || [];
9484
- const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
9485
- if (!newLngs.length) {
9486
- if (callback) callback();
9487
- return Promise.resolve();
9488
- }
9489
- this.options.preload = preloaded.concat(newLngs);
9490
- this.loadResources((err) => {
9491
- deferred.resolve();
9492
- if (callback) callback(err);
9493
- });
9494
- return deferred;
9495
- }
9496
- dir(lng) {
9497
- var _a, _b;
9498
- if (!lng) lng = this.resolvedLanguage || (((_a = this.languages) == null ? void 0 : _a.length) > 0 ? this.languages[0] : this.language);
9499
- if (!lng) return "rtl";
9500
- try {
9501
- const l = new Intl.Locale(lng);
9502
- if (l && l.getTextInfo) {
9503
- const ti = l.getTextInfo();
9504
- if (ti && ti.direction) return ti.direction;
9505
- }
9506
- } catch (e) {
9507
- }
9508
- 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"];
9509
- const languageUtils = ((_b = this.services) == null ? void 0 : _b.languageUtils) || new LanguageUtil(get());
9510
- if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
9511
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
9512
- }
9513
- static createInstance(options = {}, callback) {
9514
- const instance2 = new I18n(options, callback);
9515
- instance2.createInstance = I18n.createInstance;
9516
- return instance2;
9517
- }
9518
- cloneInstance(options = {}, callback = noop) {
9519
- const forkResourceStore = options.forkResourceStore;
9520
- if (forkResourceStore) delete options.forkResourceStore;
9521
- const mergedOptions = {
9522
- ...this.options,
9523
- ...options,
9524
- ...{
9525
- isClone: true
9526
- }
9527
- };
9528
- const clone = new I18n(mergedOptions);
9529
- if (options.debug !== void 0 || options.prefix !== void 0) {
9530
- clone.logger = clone.logger.clone(options);
9531
- }
9532
- const membersToCopy = ["store", "services", "language"];
9533
- membersToCopy.forEach((m) => {
9534
- clone[m] = this[m];
9535
- });
9536
- clone.services = {
9537
- ...this.services
9538
- };
9539
- clone.services.utils = {
9540
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9541
- };
9542
- if (forkResourceStore) {
9543
- const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
9544
- prev[l] = {
9545
- ...this.store.data[l]
9546
- };
9547
- prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
9548
- acc[n] = {
9549
- ...prev[l][n]
9550
- };
9551
- return acc;
9552
- }, prev[l]);
9553
- return prev;
9554
- }, {});
9555
- clone.store = new ResourceStore(clonedData, mergedOptions);
9556
- clone.services.resourceStore = clone.store;
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);
9557
7600
  }
9558
- clone.translator = new Translator(clone.services, mergedOptions);
9559
- clone.translator.on("*", (event, ...args) => {
9560
- clone.emit(event, ...args);
9561
- });
9562
- clone.init(mergedOptions, callback);
9563
- clone.translator.options = mergedOptions;
9564
- clone.translator.backendConnector.services.utils = {
9565
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9566
- };
9567
- return clone;
9568
7601
  }
9569
- toJSON() {
9570
- return {
9571
- options: this.options,
9572
- store: this.store,
9573
- language: this.language,
9574
- languages: this.languages,
9575
- resolvedLanguage: this.resolvedLanguage
9576
- };
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]
9577
7615
  }
9578
- }
9579
- const instance = I18n.createInstance();
9580
- instance.createInstance;
9581
- instance.dir;
9582
- instance.init;
9583
- instance.loadResources;
9584
- instance.reloadResources;
9585
- instance.use;
9586
- instance.changeLanguage;
9587
- instance.getFixedT;
9588
- instance.t;
9589
- instance.exists;
9590
- instance.setDefaultNamespace;
9591
- instance.hasLoadedNamespace;
9592
- instance.loadNamespaces;
9593
- instance.loadLanguages;
7616
+ });
9594
7617
  const OrderPlacedTemplate = ({ orderId }) => {
9595
7618
  const [templateData, setTemplateData] = useState(null);
9596
7619
  const [previewData, setPreviewData] = useState(null);
@@ -9604,7 +7627,6 @@ const OrderPlacedTemplate = ({ orderId }) => {
9604
7627
  const shippingAddressText = getFormattedAddress({ address: order.shipping_address }).join("<br/>");
9605
7628
  const billingAddressText = getFormattedAddress({ address: order.billing_address }).join("<br/>");
9606
7629
  const templateData2 = {
9607
- // subject: `#${order.display_id} - Zamówienie zostało złożone`,
9608
7630
  orderNumber: `#${order.display_id}`,
9609
7631
  customerName: order.email,
9610
7632
  customerEmail: order.email,
@@ -9613,9 +7635,9 @@ const OrderPlacedTemplate = ({ orderId }) => {
9613
7635
  var _a2, _b2, _c;
9614
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;
9615
7637
  }, 0),
9616
- currency: order.currency_code,
7638
+ currency_code: order.currency_code,
9617
7639
  items: order.items.map((item) => ({
9618
- thumbnail: item.thumbnail,
7640
+ thumbnail: item.thumbnail == null ? "" : item.thumbnail,
9619
7641
  title: item.title,
9620
7642
  quantity: item.quantity,
9621
7643
  price: getLocaleAmount(item.unit_price, order.currency_code)
@@ -9626,8 +7648,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9626
7648
  total: getLocaleAmount(order.summary.original_order_total, order.currency_code),
9627
7649
  paid_total: getLocaleAmount(getTotalCaptured(order.payment_collections || []), order.currency_code),
9628
7650
  tax_total: getLocaleAmount(order.tax_total, order.currency_code),
9629
- discount_total: getLocaleAmount(order.discount_total, order.currency_code),
9630
- currency: order.currency_code
7651
+ discount_total: getLocaleAmount(order.discount_total, order.currency_code)
9631
7652
  },
9632
7653
  sales_channel: {
9633
7654
  name: (_a = order == null ? void 0 : order.sales_channel) == null ? void 0 : _a.name,