@rebuy/rebuy 2.2.0-rc.1 → 2.2.0-rc.3

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 (45) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +628 -1
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +628 -1
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/schema/button.d.ts +5 -5
  8. package/dist/schema/button.d.ts.map +1 -1
  9. package/dist/schema/common.d.ts +1 -1
  10. package/dist/schema/common.d.ts.map +1 -1
  11. package/dist/schema/constants.d.ts +1 -1
  12. package/dist/schema/constants.d.ts.map +1 -1
  13. package/dist/schema/data-source.d.ts +1 -1
  14. package/dist/schema/data-source.d.ts.map +1 -1
  15. package/dist/schema/image.d.ts +1 -1
  16. package/dist/schema/image.d.ts.map +1 -1
  17. package/dist/schema/index.d.ts +19 -19
  18. package/dist/schema/index.d.ts.map +1 -1
  19. package/dist/schema/layout.d.ts +1 -1
  20. package/dist/schema/layout.d.ts.map +1 -1
  21. package/dist/schema/offers.d.ts +1 -1
  22. package/dist/schema/offers.d.ts.map +1 -1
  23. package/dist/schema/product.d.ts +2 -2
  24. package/dist/schema/product.d.ts.map +1 -1
  25. package/dist/schema/products.d.ts +2 -2
  26. package/dist/schema/products.d.ts.map +1 -1
  27. package/dist/schema/quantity.d.ts +1 -1
  28. package/dist/schema/quantity.d.ts.map +1 -1
  29. package/dist/schema/reviews.d.ts +1 -1
  30. package/dist/schema/reviews.d.ts.map +1 -1
  31. package/dist/schema/root.d.ts +1 -1
  32. package/dist/schema/root.d.ts.map +1 -1
  33. package/dist/schema/shared.d.ts +1 -1
  34. package/dist/schema/shared.d.ts.map +1 -1
  35. package/dist/schema/subscription.d.ts +1 -1
  36. package/dist/schema/subscription.d.ts.map +1 -1
  37. package/dist/schema/table.d.ts +1 -1
  38. package/dist/schema/table.d.ts.map +1 -1
  39. package/dist/schema/text.d.ts +5 -5
  40. package/dist/schema/text.d.ts.map +1 -1
  41. package/dist/schema/variants.d.ts +1 -1
  42. package/dist/schema/variants.d.ts.map +1 -1
  43. package/package.json +2 -6
  44. package/dist/schema/index.mjs +0 -629
  45. package/dist/schema/index.mjs.map +0 -7
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './client';
3
3
  export * from './cookie';
4
4
  export * from './geolocation';
5
5
  export * from './identity';
6
+ export * from './schema';
6
7
  export * from './session';
7
8
  export * from './utilities';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -21,36 +21,107 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Api: () => Api,
24
+ BorderRadius: () => BorderRadius,
25
+ BorderStyle: () => BorderStyle,
26
+ BorderWidth: () => BorderWidth,
27
+ ButtonAction: () => ButtonAction,
28
+ ButtonField: () => ButtonField,
29
+ ButtonStyle: () => ButtonStyle,
30
+ CABBorder: () => CABBorder,
31
+ CABButtonContent: () => CABButtonContent,
32
+ CABButtonSection: () => CABButtonSection,
33
+ CABDataSourceSection: () => CABDataSourceSection,
34
+ CABImageSection: () => CABImageSection,
35
+ CABLayoutSection: () => CABLayoutSection,
36
+ CABOffersSection: () => CABOffersSection,
37
+ CABProductSection: () => CABProductSection,
38
+ CABProductsSection: () => CABProductsSection,
39
+ CABQuantitySection: () => CABQuantitySection,
40
+ CABReviewsSection: () => CABReviewsSection,
41
+ CABRootSection: () => CABRootSection,
42
+ CABSection: () => CABSection,
43
+ CABSubscriptionSection: () => CABSubscriptionSection,
44
+ CABTableSection: () => CABTableSection,
45
+ CABTextSection: () => CABTextSection,
46
+ CABVariantsSection: () => CABVariantsSection,
47
+ COMBINED_ENDPOINTS: () => COMBINED_ENDPOINTS,
48
+ DEFAULT_ENDPOINTS: () => DEFAULT_ENDPOINTS,
49
+ DYNAMIC_TOKEN_REGEX: () => DYNAMIC_TOKEN_REGEX,
50
+ Direction: () => Direction,
51
+ EditorMode: () => EditorMode,
24
52
  Geolocation: () => Geolocation,
53
+ HEX_COLOR_REGEX: () => HEX_COLOR_REGEX,
54
+ HTML_TAGS_REGEX: () => HTML_TAGS_REGEX,
55
+ HorizontalAlignment: () => HorizontalAlignment,
25
56
  Identity: () => Identity,
57
+ LanguageKey: () => LanguageKey,
58
+ NO_HTML: () => NO_HTML,
59
+ ObjectFit: () => ObjectFit,
60
+ QuantityInput: () => QuantityInput,
26
61
  RebuyClient: () => RebuyClient,
62
+ STATIC_ENDPOINTS: () => STATIC_ENDPOINTS,
63
+ SectionType: () => SectionType,
27
64
  Session: () => Session,
65
+ Spacing: () => Spacing,
66
+ TextAlignment: () => TextAlignment,
67
+ TextColorName: () => TextColorName,
68
+ TextSizeName: () => TextSizeName,
69
+ TiptapDocument: () => TiptapDocument,
70
+ TiptapParagraph: () => TiptapParagraph,
71
+ TiptapText: () => TiptapText,
72
+ VariantSelector: () => VariantSelector,
73
+ VerticalAlignment: () => VerticalAlignment,
74
+ WidgetType: () => WidgetType,
28
75
  amountToCents: () => amountToCents,
76
+ borderRadii: () => borderRadii,
77
+ borderStyles: () => borderStyles,
78
+ borderWidths: () => borderWidths,
79
+ buttonActions: () => buttonActions,
80
+ buttonFields: () => buttonFields,
81
+ buttonStyles: () => buttonStyles,
82
+ checkForHTML: () => checkForHTML,
29
83
  convertProductToStorefrontFormat: () => convertProductToStorefrontFormat,
30
84
  convertToNodes: () => convertToNodes,
31
85
  convertVariantToStorefrontFormat: () => convertVariantToStorefrontFormat,
32
86
  dataToString: () => dataToString,
33
87
  destroy: () => destroy,
88
+ directions: () => directions,
89
+ editorModes: () => editorModes,
34
90
  enabled: () => enabled,
35
91
  find: () => find,
36
92
  firstAvailableVariant: () => firstAvailableVariant,
37
93
  get: () => get,
38
94
  getAll: () => getAll,
39
95
  getIdFromGraphUrl: () => getIdFromGraphUrl,
96
+ hasHTMLInDoc: () => hasHTMLInDoc,
97
+ horizontalAlignments: () => horizontalAlignments,
40
98
  isBase64Encoded: () => isBase64Encoded,
99
+ isHTML: () => isHTML,
100
+ languageKeys: () => languageKeys,
101
+ objectFits: () => objectFits,
41
102
  productImageObject: () => productImageObject,
103
+ quantityInputs: () => quantityInputs,
42
104
  queryStringToObject: () => queryStringToObject,
105
+ sectionTypes: () => sectionTypes,
43
106
  selectedVariantOptions: () => selectedVariantOptions,
44
107
  serialize: () => serialize,
45
108
  sessionId: () => sessionId,
46
109
  set: () => set,
110
+ spacings: () => spacings,
47
111
  stringToData: () => stringToData,
48
112
  stripHtml: () => stripHtml,
113
+ targetAreas: () => targetAreas,
114
+ textAlignments: () => textAlignments,
115
+ textColorNames: () => textColorNames,
116
+ textSizeNames: () => textSizeNames,
49
117
  utmObjectFromString: () => utmObjectFromString,
50
118
  uuid: () => uuid,
51
119
  variantAvailable: () => variantAvailable,
52
120
  variantMinMaxPriceObject: () => variantMinMaxPriceObject,
53
- variantPriceObject: () => variantPriceObject
121
+ variantPriceObject: () => variantPriceObject,
122
+ variantSelectors: () => variantSelectors,
123
+ verticalAlignments: () => verticalAlignments,
124
+ widgetTypes: () => widgetTypes
54
125
  });
55
126
  module.exports = __toCommonJS(index_exports);
56
127
 
@@ -788,4 +859,560 @@ var RebuyClient = class {
788
859
  return null;
789
860
  }
790
861
  };
862
+
863
+ // src/schema/button.ts
864
+ var import_uuid12 = require("uuid");
865
+ var import_v416 = require("zod/v4");
866
+
867
+ // src/schema/common.ts
868
+ var import_v4 = require("zod/v4");
869
+ var borderRadii = ["none", "small", "base", "large", "fullyRounded"];
870
+ var borderRadius = import_v4.z.enum(borderRadii);
871
+ var BorderRadius = borderRadius.enum;
872
+ var borderStyles = ["none", "base", "dotted", "dashed"];
873
+ var borderStyle = import_v4.z.enum(borderStyles);
874
+ var BorderStyle = borderStyle.enum;
875
+ var borderWidths = ["base", "medium", "thick"];
876
+ var borderWidth = import_v4.z.enum(borderWidths);
877
+ var BorderWidth = borderWidth.enum;
878
+ var buttonActions = [
879
+ "addToOrder",
880
+ "declineAllOffers",
881
+ "declineOffer",
882
+ "goToRebuyApp",
883
+ "goToRebuyVault",
884
+ "goToURL",
885
+ "removeFromCart",
886
+ "showVariants",
887
+ "switchToSubscription"
888
+ ];
889
+ var buttonAction = import_v4.z.enum(buttonActions);
890
+ var ButtonAction = buttonAction.enum;
891
+ var buttonFields = [
892
+ "addedToCart",
893
+ "addingToCart",
894
+ "addToCart",
895
+ "buttonLabel",
896
+ "declineAllOffers",
897
+ "declineOffer",
898
+ "destinationUrl",
899
+ "payNow",
900
+ "removeFromCart",
901
+ "showVariant",
902
+ "showVariants",
903
+ "soldOut",
904
+ "switchToOneTimeAction",
905
+ "switchToOneTimePurchase",
906
+ "switchToSubscriptionAction",
907
+ "switchToSubscriptionNoDiscount",
908
+ "switchToSubscriptionWithDiscount"
909
+ ];
910
+ var buttonField = import_v4.z.enum(buttonFields);
911
+ var ButtonField = buttonField.enum;
912
+ var buttonStyles = ["primary", "secondary", "plain", "custom"];
913
+ var buttonStyle = import_v4.z.enum(buttonStyles);
914
+ var ButtonStyle = buttonStyle.enum;
915
+ var directions = ["columns", "rows"];
916
+ var direction = import_v4.z.enum(directions);
917
+ var Direction = direction.enum;
918
+ var editorModes = [
919
+ "checkoutExtension",
920
+ "postPurchaseOffer",
921
+ "thankYouPage",
922
+ "orderStatusPage",
923
+ "ordersIndexPage",
924
+ "customerProfilePage"
925
+ ];
926
+ var editorMode = import_v4.z.enum(editorModes);
927
+ var EditorMode = editorMode.enum;
928
+ var horizontalAlignments = ["start", "center", "end"];
929
+ var horizontalAlignment = import_v4.z.enum(horizontalAlignments);
930
+ var HorizontalAlignment = horizontalAlignment.enum;
931
+ var languageKeys = [
932
+ "ar",
933
+ "cs",
934
+ "da",
935
+ "de",
936
+ "en",
937
+ "es",
938
+ "fi",
939
+ "fr",
940
+ "ga",
941
+ "he",
942
+ "hi",
943
+ "id",
944
+ "it",
945
+ "ja",
946
+ "ko",
947
+ "nl",
948
+ "no",
949
+ "pl",
950
+ "pt",
951
+ "ru",
952
+ "sv",
953
+ "th",
954
+ "tr",
955
+ "uk",
956
+ "vi",
957
+ "zh"
958
+ ];
959
+ var languageKey = import_v4.z.enum(languageKeys);
960
+ var LanguageKey = languageKey.enum;
961
+ var objectFits = ["cover", "contain"];
962
+ var objectFit = import_v4.z.enum(objectFits);
963
+ var ObjectFit = objectFit.enum;
964
+ var quantityInputs = ["select", "number"];
965
+ var quantityInput = import_v4.z.enum(quantityInputs);
966
+ var QuantityInput = quantityInput.enum;
967
+ var sectionTypes = [
968
+ "button",
969
+ "dataSource",
970
+ "image",
971
+ "layout",
972
+ "offers",
973
+ "product",
974
+ "products",
975
+ "quantity",
976
+ "reviews",
977
+ "subscription",
978
+ "table",
979
+ "text",
980
+ "variants"
981
+ ];
982
+ var sectionType = import_v4.z.enum(sectionTypes);
983
+ var SectionType = sectionType.enum;
984
+ var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
985
+ var spacing = import_v4.z.enum(spacings);
986
+ var Spacing = spacing.enum;
987
+ var textAlignments = ["start", "center", "end"];
988
+ var textAlignment = import_v4.z.enum(textAlignments);
989
+ var TextAlignment = textAlignment.enum;
990
+ var textColorNames = ["base", "subdued", "accent", "decorative", "success", "warning", "critical"];
991
+ var textColorName = import_v4.z.enum(textColorNames);
992
+ var TextColorName = textColorName.enum;
993
+ var textSizeNames = ["extraSmall", "small", "base", "medium", "large", "extraLarge"];
994
+ var textSizeName = import_v4.z.enum(textSizeNames);
995
+ var TextSizeName = textSizeName.enum;
996
+ var variantSelectors = ["menu", "button", "radio", "color", "image"];
997
+ var variantSelector = import_v4.z.enum(variantSelectors);
998
+ var VariantSelector = variantSelector.enum;
999
+ var verticalAlignments = ["top", "middle", "bottom"];
1000
+ var verticalAlignment = import_v4.z.enum(verticalAlignments);
1001
+ var VerticalAlignment = verticalAlignment.enum;
1002
+
1003
+ // src/schema/image.ts
1004
+ var import_uuid11 = require("uuid");
1005
+ var import_v415 = require("zod/v4");
1006
+
1007
+ // src/schema/regex.ts
1008
+ var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
1009
+ var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
1010
+ var HTML_TAGS_REGEX = /<[^>]*>/gi;
1011
+
1012
+ // src/schema/shared.ts
1013
+ var import_v414 = require("zod/v4");
1014
+
1015
+ // src/schema/data-source.ts
1016
+ var import_uuid = require("uuid");
1017
+ var import_v43 = require("zod/v4");
1018
+
1019
+ // src/schema/constants.ts
1020
+ var import_lodash_es = require("lodash-es");
1021
+ var import_v42 = require("zod/v4");
1022
+ var DEFAULT_ENDPOINTS = [
1023
+ { label: "Recommended (AI)", value: "/products/recommended" },
1024
+ { label: "Top Sellers", value: "/products/top_sellers" },
1025
+ { label: "Buy It Again", value: "/products/purchased" },
1026
+ { label: "Recently Viewed", value: "/products/viewed" },
1027
+ { label: "Products Search", value: "/products/search" },
1028
+ { label: "Collection Products", value: "/products/collections" },
1029
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
1030
+ ];
1031
+ var STATIC_ENDPOINTS = [
1032
+ { label: "Recommended (AI)", value: "/products/recommended" },
1033
+ { label: "Top Sellers", value: "/products/top_sellers" },
1034
+ { label: "Trending Products", value: "/products/trending_products" },
1035
+ { label: "Buy It Again", value: "/products/purchased" },
1036
+ { label: "Collection Products", value: "/products/collections" },
1037
+ { label: "Recently Viewed", value: "/products/viewed" },
1038
+ { label: "Static Products", value: "/products/static" },
1039
+ { label: "Products Search", value: "/products/search" },
1040
+ { label: "Similar Products (AI)", value: "/products/similar_products" }
1041
+ ];
1042
+ var COMBINED_ENDPOINTS = (0, import_lodash_es.uniqBy)([...DEFAULT_ENDPOINTS, ...STATIC_ENDPOINTS], "value");
1043
+ var targetAreas = {
1044
+ [EditorMode.checkoutExtension]: [
1045
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
1046
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
1047
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
1048
+ ],
1049
+ [EditorMode.postPurchaseOffer]: null,
1050
+ [EditorMode.thankYouPage]: [
1051
+ { icon: "splitscreen_top", label: "Header Area", width: "984px" },
1052
+ { icon: "splitscreen_left", label: "Main Column", width: "503px" },
1053
+ { icon: "splitscreen_right", label: "Summary Column", width: "404px" }
1054
+ ],
1055
+ [EditorMode.orderStatusPage]: [
1056
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1057
+ { icon: "splitscreen_top", label: "Header Area", width: "1124px" },
1058
+ { fill: true, icon: "view_column_2", label: "Main Area", width: "646px" },
1059
+ { icon: "splitscreen_bottom", label: "Footer Area", width: "1124px" }
1060
+ ],
1061
+ [EditorMode.ordersIndexPage]: [
1062
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1063
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
1064
+ ],
1065
+ [EditorMode.customerProfilePage]: [
1066
+ // { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
1067
+ { icon: "splitscreen_top", label: "Main Area", width: "1124px" }
1068
+ ]
1069
+ };
1070
+ var widgetTypes = [
1071
+ "bundle_builder",
1072
+ "cart",
1073
+ "cart_subscription",
1074
+ "dynamic_bundle",
1075
+ "gift_with_purchase",
1076
+ "pre_purchase",
1077
+ "product",
1078
+ "product_addon",
1079
+ "product_upsell",
1080
+ "recharge_checkout",
1081
+ "recharge_customer_portal",
1082
+ "recharge_post_purchase",
1083
+ "shopify_checkout",
1084
+ "shopify_checkout_extension",
1085
+ "shopify_post_purchase",
1086
+ "shopify_post_purchase_extension",
1087
+ "switch_to_subscription",
1088
+ "ui_extension_ad",
1089
+ "ui_extension_button",
1090
+ "ui_extension_content_block",
1091
+ "ui_extension_line_item_editor",
1092
+ "ui_extension_progress_bar"
1093
+ ];
1094
+ var widgetType = import_v42.z.enum(widgetTypes);
1095
+ var WidgetType = widgetType.enum;
1096
+
1097
+ // src/schema/data-source.ts
1098
+ var CABDataSourceSection = import_v43.z.strictObject({
1099
+ dataSourceId: import_v43.z.number().nullable().default(null),
1100
+ dataSourcePath: import_v43.z.string().default(DEFAULT_ENDPOINTS[0].value),
1101
+ limit: import_v43.z.number().default(1),
1102
+ name: import_v43.z.string().default(DEFAULT_ENDPOINTS[0].label),
1103
+ sectionId: import_v43.z.uuidv7().default(() => (0, import_uuid.v7)()),
1104
+ sectionType: import_v43.z.literal(SectionType.dataSource).default(SectionType.dataSource)
1105
+ });
1106
+
1107
+ // src/schema/layout.ts
1108
+ var import_uuid2 = require("uuid");
1109
+ var import_v44 = require("zod/v4");
1110
+ var CABLayoutSection = import_v44.z.strictObject({
1111
+ alignment: import_v44.z.strictObject({
1112
+ horizontal: import_v44.z.enum(horizontalAlignments).default(HorizontalAlignment.start),
1113
+ vertical: import_v44.z.enum(verticalAlignments).default(VerticalAlignment.top)
1114
+ }).default({
1115
+ horizontal: HorizontalAlignment.start,
1116
+ vertical: VerticalAlignment.top
1117
+ }),
1118
+ border: CABBorder,
1119
+ direction: import_v44.z.enum(directions).default(Direction.rows),
1120
+ name: import_v44.z.string().optional(),
1121
+ padding: import_v44.z.enum(spacings).default(Spacing.none),
1122
+ sectionId: import_v44.z.uuidv7().default(() => (0, import_uuid2.v7)()),
1123
+ sections: import_v44.z.array(import_v44.z.lazy(() => CABSection)).default(() => []),
1124
+ sectionType: import_v44.z.literal(SectionType.layout).default(SectionType.layout),
1125
+ spacing: import_v44.z.enum(spacings).default(Spacing.base),
1126
+ width: import_v44.z.number().default(100)
1127
+ });
1128
+
1129
+ // src/schema/offers.ts
1130
+ var import_v48 = require("zod/v4");
1131
+
1132
+ // src/schema/products.ts
1133
+ var import_uuid5 = require("uuid");
1134
+ var import_v47 = require("zod/v4");
1135
+
1136
+ // src/schema/product.ts
1137
+ var import_uuid4 = require("uuid");
1138
+ var import_v46 = require("zod/v4");
1139
+
1140
+ // src/schema/text.ts
1141
+ var import_lodash_es3 = require("lodash-es");
1142
+ var import_uuid3 = require("uuid");
1143
+ var import_v45 = require("zod/v4");
1144
+
1145
+ // src/schema/utils.ts
1146
+ var import_lodash_es2 = require("lodash-es");
1147
+ var isHTML = (html = "") => {
1148
+ if (typeof window !== "undefined") {
1149
+ const parser = new DOMParser();
1150
+ const doc = parser.parseFromString(html, "text/html");
1151
+ const hasHTML = (nodeList) => Array.from(nodeList).some((node) => node.nodeType === 1);
1152
+ return hasHTML(doc.body.childNodes) || hasHTML(doc.head.childNodes);
1153
+ }
1154
+ return HTML_TAGS_REGEX.test(html);
1155
+ };
1156
+ var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
1157
+ var checkForHTML = (input) => !((0, import_lodash_es2.isString)(input) && isHTML(input) || (0, import_lodash_es2.isPlainObject)(input) && hasHTMLInDoc(input));
1158
+ var NO_HTML = { message: "HTML is not supported" };
1159
+
1160
+ // src/schema/text.ts
1161
+ var enumOrOmit = (...vals) => import_v45.z.string().transform((val) => vals.includes(val) ? val : void 0).optional();
1162
+ var TiptapText = import_v45.z.strictObject({
1163
+ marks: import_v45.z.array(
1164
+ import_v45.z.discriminatedUnion("type", [
1165
+ import_v45.z.strictObject({ type: import_v45.z.literal("bold") }),
1166
+ import_v45.z.strictObject({ type: import_v45.z.literal("italic") }),
1167
+ import_v45.z.strictObject({
1168
+ attrs: import_v45.z.strictObject({
1169
+ class: import_v45.z.string().nullable(),
1170
+ href: import_v45.z.union([import_v45.z.url(), import_v45.z.string().regex(DYNAMIC_TOKEN_REGEX)]),
1171
+ rel: import_v45.z.string().default("noopener noreferrer nofollow"),
1172
+ target: import_v45.z.string().default("_blank")
1173
+ }),
1174
+ type: import_v45.z.literal("link")
1175
+ }),
1176
+ import_v45.z.strictObject({ type: import_v45.z.literal("strike") }),
1177
+ import_v45.z.strictObject({
1178
+ attrs: import_v45.z.strictObject({
1179
+ color: enumOrOmit(...textColorNames).default(TextColorName.base),
1180
+ fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
1181
+ }),
1182
+ type: import_v45.z.literal("textStyle")
1183
+ })
1184
+ ])
1185
+ ).optional(),
1186
+ text: import_v45.z.string().default(""),
1187
+ type: import_v45.z.literal("text").default("text")
1188
+ });
1189
+ var TiptapParagraph = import_v45.z.strictObject({
1190
+ attrs: import_v45.z.strictObject({
1191
+ textAlign: enumOrOmit(...textAlignments)
1192
+ }).default({ textAlign: TextAlignment.start }),
1193
+ content: import_v45.z.array(TiptapText).default([]),
1194
+ type: import_v45.z.literal("paragraph").default("paragraph")
1195
+ });
1196
+ var TiptapDocument = import_v45.z.strictObject({
1197
+ attrs: import_v45.z.strictObject({
1198
+ blockSpacing: enumOrOmit(...spacings)
1199
+ }).default({ blockSpacing: Spacing.base }),
1200
+ content: import_v45.z.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
1201
+ type: import_v45.z.literal("doc").default("doc")
1202
+ });
1203
+ var CABTextSection = import_v45.z.strictObject({
1204
+ buttonField: import_v45.z.enum(buttonFields).optional(),
1205
+ content: import_v45.z.record(import_v45.z.string(), import_v45.z.union([import_v45.z.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
1206
+ name: import_v45.z.string().optional(),
1207
+ sectionId: import_v45.z.uuidv7().default(() => (0, import_uuid3.v7)()),
1208
+ sectionType: import_v45.z.literal(SectionType.text).default(SectionType.text)
1209
+ }).superRefine(({ buttonField: buttonField2, content }, ctx) => {
1210
+ if (buttonField2 === ButtonField.destinationUrl && content) {
1211
+ (0, import_lodash_es3.forEach)(content, (value, lang) => {
1212
+ if (value && (0, import_lodash_es3.isString)(value)) {
1213
+ if (DYNAMIC_TOKEN_REGEX.test(value)) return;
1214
+ try {
1215
+ new URL(value);
1216
+ } catch {
1217
+ ctx.addIssue({
1218
+ code: "custom",
1219
+ message: "Invalid URL",
1220
+ path: ["content", lang]
1221
+ });
1222
+ }
1223
+ }
1224
+ });
1225
+ }
1226
+ });
1227
+
1228
+ // src/schema/product.ts
1229
+ var CABProductSection = import_v46.z.strictObject({
1230
+ name: import_v46.z.string().optional(),
1231
+ options: import_v46.z.array(
1232
+ import_v46.z.strictObject({
1233
+ /** `name` represents `Color`, `Size`, etc. */
1234
+ name: import_v46.z.string(),
1235
+ optionId: import_v46.z.number(),
1236
+ selector: import_v46.z.enum(variantSelectors).default(VariantSelector.menu),
1237
+ values: import_v46.z.array(
1238
+ import_v46.z.strictObject({
1239
+ color: import_v46.z.string().optional(),
1240
+ image: CABImageSection.optional(),
1241
+ /** `name` represents `Red`, `Blue`, etc. */
1242
+ name: import_v46.z.string(),
1243
+ text: CABTextSection.optional()
1244
+ })
1245
+ )
1246
+ })
1247
+ ).default(() => []),
1248
+ productId: import_v46.z.number().nullable().default(null),
1249
+ sectionId: import_v46.z.uuidv7().default(() => (0, import_uuid4.v7)()),
1250
+ sectionType: import_v46.z.literal(SectionType.product).default(SectionType.product)
1251
+ });
1252
+
1253
+ // src/schema/products.ts
1254
+ var CABProductsSection = import_v47.z.strictObject({
1255
+ name: import_v47.z.string().optional(),
1256
+ sectionId: import_v47.z.uuidv7().default(() => (0, import_uuid5.v7)()),
1257
+ sections: import_v47.z.array(CABProductSection).default(() => []),
1258
+ sectionType: import_v47.z.literal(SectionType.products).default(SectionType.products)
1259
+ });
1260
+
1261
+ // src/schema/offers.ts
1262
+ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
1263
+ import_v48.z.strictObject({
1264
+ sections: import_v48.z.array(import_v48.z.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
1265
+ sectionType: import_v48.z.literal(SectionType.offers).default(SectionType.offers)
1266
+ }).shape
1267
+ );
1268
+
1269
+ // src/schema/quantity.ts
1270
+ var import_uuid6 = require("uuid");
1271
+ var import_v49 = require("zod/v4");
1272
+ var CABQuantitySection = import_v49.z.strictObject({
1273
+ errorMessages: import_v49.z.record(
1274
+ import_v49.z.string(),
1275
+ import_v49.z.strictObject({
1276
+ max: import_v49.z.string().optional(),
1277
+ min: import_v49.z.string().optional(),
1278
+ neg: import_v49.z.string().optional()
1279
+ })
1280
+ ).default({
1281
+ en: {
1282
+ max: "Maximum quantity allowed is {{max}}",
1283
+ min: "Minimum quantity required is {{min}}",
1284
+ neg: "Quantity cannot be negative"
1285
+ }
1286
+ }),
1287
+ inputType: import_v49.z.enum(quantityInputs).default(QuantityInput.select),
1288
+ max: import_v49.z.number().min(1).max(100).default(10),
1289
+ min: import_v49.z.number().min(1).default(1),
1290
+ name: import_v49.z.string().optional(),
1291
+ sectionId: import_v49.z.uuidv7().default(() => (0, import_uuid6.v7)()),
1292
+ sectionType: import_v49.z.literal(SectionType.quantity).default(SectionType.quantity)
1293
+ });
1294
+
1295
+ // src/schema/reviews.ts
1296
+ var import_uuid7 = require("uuid");
1297
+ var import_v410 = require("zod/v4");
1298
+ var CABReviewsSection = import_v410.z.strictObject({
1299
+ name: import_v410.z.string().optional(),
1300
+ sectionId: import_v410.z.uuidv7().default(() => (0, import_uuid7.v7)()),
1301
+ sectionType: import_v410.z.literal(SectionType.reviews).default(SectionType.reviews)
1302
+ });
1303
+
1304
+ // src/schema/subscription.ts
1305
+ var import_uuid8 = require("uuid");
1306
+ var import_v411 = require("zod/v4");
1307
+ var CABSubscriptionSection = import_v411.z.strictObject({
1308
+ name: import_v411.z.string().optional(),
1309
+ sectionId: import_v411.z.uuidv7().default(() => (0, import_uuid8.v7)()),
1310
+ sectionType: import_v411.z.literal(SectionType.subscription).default(SectionType.subscription)
1311
+ });
1312
+
1313
+ // src/schema/table.ts
1314
+ var import_uuid9 = require("uuid");
1315
+ var import_v412 = require("zod/v4");
1316
+ var CABTableSection = import_v412.z.strictObject({
1317
+ name: import_v412.z.string().optional(),
1318
+ sectionId: import_v412.z.uuidv7().default(() => (0, import_uuid9.v7)()),
1319
+ sectionType: import_v412.z.literal(SectionType.table).default(SectionType.table)
1320
+ });
1321
+
1322
+ // src/schema/variants.ts
1323
+ var import_lodash_es4 = require("lodash-es");
1324
+ var import_uuid10 = require("uuid");
1325
+ var import_v413 = require("zod/v4");
1326
+ var CABVariantsSection = import_v413.z.strictObject({
1327
+ name: import_v413.z.string().optional(),
1328
+ sectionId: import_v413.z.uuidv7().default(() => (0, import_uuid10.v7)()),
1329
+ sectionType: import_v413.z.literal(SectionType.variants).default(SectionType.variants),
1330
+ selector: import_v413.z.enum((0, import_lodash_es4.slice)(variantSelectors, 0, 3)).default(VariantSelector.menu)
1331
+ });
1332
+
1333
+ // src/schema/shared.ts
1334
+ var CABBorder = import_v414.z.strictObject({
1335
+ radius: import_v414.z.enum(borderRadii).default(BorderRadius.base),
1336
+ style: import_v414.z.enum(borderStyles).default(BorderStyle.none),
1337
+ width: import_v414.z.enum(borderWidths).default(BorderWidth.base)
1338
+ }).default({
1339
+ radius: BorderRadius.base,
1340
+ style: BorderStyle.none,
1341
+ width: BorderWidth.base
1342
+ });
1343
+ var CABSection = import_v414.z.lazy(
1344
+ () => import_v414.z.discriminatedUnion("sectionType", [
1345
+ CABButtonSection,
1346
+ CABDataSourceSection,
1347
+ CABImageSection,
1348
+ CABLayoutSection,
1349
+ CABOffersSection,
1350
+ CABProductSection,
1351
+ CABProductsSection,
1352
+ CABQuantitySection,
1353
+ CABReviewsSection,
1354
+ CABSubscriptionSection,
1355
+ CABTableSection,
1356
+ CABTextSection,
1357
+ CABVariantsSection
1358
+ ])
1359
+ );
1360
+
1361
+ // src/schema/image.ts
1362
+ var CABImageSection = import_v415.z.strictObject({
1363
+ altText: import_v415.z.string().refine(checkForHTML, NO_HTML).default(""),
1364
+ aspectRatio: import_v415.z.literal(1).nullable().default(null),
1365
+ border: CABBorder,
1366
+ buttonField: import_v415.z.enum(buttonFields).optional(),
1367
+ category: import_v415.z.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
1368
+ name: import_v415.z.string().optional(),
1369
+ naturalHeight: import_v415.z.number().default(0),
1370
+ naturalWidth: import_v415.z.number().default(0),
1371
+ objectFit: import_v415.z.enum(objectFits).default(ObjectFit.cover),
1372
+ sectionId: import_v415.z.uuidv7().default(() => (0, import_uuid11.v7)()),
1373
+ sectionType: import_v415.z.literal(SectionType.image).default(SectionType.image),
1374
+ source: import_v415.z.union([import_v415.z.url(), import_v415.z.literal(""), import_v415.z.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
1375
+ width: import_v415.z.number().default(100)
1376
+ });
1377
+
1378
+ // src/schema/button.ts
1379
+ var CABButtonContent = import_v416.z.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
1380
+ var CABButtonSection = import_v416.z.strictObject({
1381
+ action: import_v416.z.union([import_v416.z.literal(""), import_v416.z.enum(buttonActions)]).default(""),
1382
+ buttonStyle: import_v416.z.enum(buttonStyles).default(ButtonStyle.primary),
1383
+ custom: import_v416.z.strictObject({
1384
+ color: import_v416.z.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
1385
+ height: import_v416.z.number().default(52),
1386
+ width: import_v416.z.number().default(300)
1387
+ }).default({
1388
+ color: "#005bd3",
1389
+ height: 52,
1390
+ width: 300
1391
+ }),
1392
+ name: import_v416.z.string().optional(),
1393
+ sectionId: import_v416.z.uuidv7().default(() => (0, import_uuid12.v7)()),
1394
+ sections: import_v416.z.array(CABButtonContent).default(() => []),
1395
+ sectionType: import_v416.z.literal(SectionType.button).default(SectionType.button)
1396
+ });
1397
+
1398
+ // src/schema/root.ts
1399
+ var import_v417 = require("zod/v4");
1400
+ var TargetArea = import_v417.z.strictObject({
1401
+ fill: import_v417.z.boolean().optional(),
1402
+ flip: import_v417.z.enum(["both", "horizontal", "vertical"]).optional(),
1403
+ icon: import_v417.z.string(),
1404
+ label: import_v417.z.string(),
1405
+ width: import_v417.z.string()
1406
+ }).default(targetAreas[EditorMode.checkoutExtension][1]);
1407
+ var CABRootSection = CABLayoutSection.extend(
1408
+ import_v417.z.strictObject({
1409
+ editorMode: import_v417.z.enum(editorModes).default(EditorMode.checkoutExtension),
1410
+ previewMode: import_v417.z.boolean().default(false),
1411
+ storeId: import_v417.z.number().nullable().default(null),
1412
+ targetArea: TargetArea.nullable(),
1413
+ type: import_v417.z.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
1414
+ version: import_v417.z.literal(2).default(2),
1415
+ widgetId: import_v417.z.number().nullable().default(null)
1416
+ }).shape
1417
+ );
791
1418
  //# sourceMappingURL=index.js.map