@rebuy/rebuy 3.20.0 → 3.21.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 (40) hide show
  1. package/dist/index.cjs +121 -46
  2. package/dist/index.mjs +121 -46
  3. package/dist/schema/checkout-and-beyond/constants.cjs +4 -0
  4. package/dist/schema/checkout-and-beyond/constants.mjs +4 -0
  5. package/dist/schema/checkout-and-beyond/index.cjs +44 -0
  6. package/dist/schema/checkout-and-beyond/index.mjs +44 -0
  7. package/dist/schema/widget-data.cjs +8 -0
  8. package/dist/schema/widget-data.mjs +8 -0
  9. package/dist/schema/widgetData.d.ts +18 -0
  10. package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +6 -0
  11. package/dist/schema/widgets/checkout-and-beyond/button.d.ts +6 -0
  12. package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +6 -0
  13. package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +6 -0
  14. package/dist/schema/widgets/checkout-and-beyond/common.d.ts +7 -0
  15. package/dist/schema/widgets/checkout-and-beyond/descriptionLabels.d.ts +37 -0
  16. package/dist/schema/widgets/checkout-and-beyond/discount.d.ts +6 -0
  17. package/dist/schema/widgets/checkout-and-beyond/image.d.ts +12 -0
  18. package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
  19. package/dist/schema/widgets/checkout-and-beyond/layout.d.ts +6 -0
  20. package/dist/schema/widgets/checkout-and-beyond/monetize.d.ts +6 -0
  21. package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +6 -0
  22. package/dist/schema/widgets/checkout-and-beyond/product.d.ts +6 -0
  23. package/dist/schema/widgets/checkout-and-beyond/products.d.ts +12 -0
  24. package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +6 -0
  25. package/dist/schema/widgets/checkout-and-beyond/quantity.d.ts +6 -0
  26. package/dist/schema/widgets/checkout-and-beyond/reviews.d.ts +6 -0
  27. package/dist/schema/widgets/checkout-and-beyond/root.d.ts +6 -0
  28. package/dist/schema/widgets/checkout-and-beyond/text.d.ts +6 -0
  29. package/dist/schema/widgets/checkout-and-beyond/variables.d.ts +37 -2
  30. package/dist/schema/widgets/checkout-and-beyond/variants.d.ts +6 -0
  31. package/dist/schema/widgets/contentBlock.d.ts +6 -0
  32. package/dist/schema/widgets/lineItemEditor.d.ts +6 -0
  33. package/dist/schema/widgets/rebuyButton.d.ts +6 -0
  34. package/dist/server/index.cjs +121 -23
  35. package/dist/server/index.mjs +121 -23
  36. package/dist/transforms/contentBlockV1/convertContentBlockTextToV2.d.ts +7 -0
  37. package/dist/transforms/index.cjs +121 -23
  38. package/dist/transforms/index.mjs +121 -23
  39. package/dist/transforms/offerV1/convertOfferToV2.d.ts +2 -2
  40. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ __export(src_exports, {
38
38
  CABButtonSection: () => CABButtonSection,
39
39
  CABCarouselSection: () => CABCarouselSection,
40
40
  CABCartLineSection: () => CABCartLineSection,
41
+ CABContentTrigger: () => CABContentTrigger,
41
42
  CABDataSourceSection: () => CABDataSourceSection,
42
43
  CABDiscount: () => CABDiscount,
43
44
  CABDiscountSection: () => CABDiscountSection,
@@ -86,7 +87,9 @@ __export(src_exports, {
86
87
  CheckoutExtension: () => CheckoutExtension,
87
88
  ContentBlock: () => ContentBlock,
88
89
  ContentBlockV1: () => ContentBlockV1,
90
+ ContentOperator: () => ContentOperator,
89
91
  DEFAULT_ENDPOINTS: () => DEFAULT_ENDPOINTS,
92
+ DESCRIPTION_LABELS: () => DESCRIPTION_LABELS,
90
93
  DYNAMIC_TOKEN_REGEX: () => DYNAMIC_TOKEN_REGEX,
91
94
  Direction: () => Direction,
92
95
  DiscountSource: () => DiscountSource,
@@ -189,6 +192,7 @@ __export(src_exports, {
189
192
  buttonFields: () => buttonFields,
190
193
  buttonStyles: () => buttonStyles,
191
194
  checkForHTML: () => checkForHTML,
195
+ contentOperators: () => contentOperators,
192
196
  convertNumericObjects: () => convertNumericObjectsLoose,
193
197
  convertOfferToV2: () => convertOfferToV2,
194
198
  convertProductToStorefrontFormat: () => convertProductToStorefrontFormat,
@@ -1707,6 +1711,8 @@ var buttonFields = [
1707
1711
  var ButtonField = freezeEnum(buttonFields);
1708
1712
  var buttonStyles = ["primary", "secondary", "plain", "custom"];
1709
1713
  var ButtonStyle = freezeEnum(buttonStyles);
1714
+ var contentOperators = ["is_empty", "is_not_empty"];
1715
+ var ContentOperator = freezeEnum(contentOperators);
1710
1716
  var directions = ["columns", "rows", "grid"];
1711
1717
  var Direction = freezeEnum(directions);
1712
1718
  var discountSources = ["price", "compare_at_price"];
@@ -2218,9 +2224,14 @@ var CABVisibility = import_zod12.z.object({
2218
2224
  variable: import_zod12.z.string().min(1),
2219
2225
  visibleWhen: import_zod12.z.boolean().default(true)
2220
2226
  });
2227
+ var contentOperator = import_zod12.z.enum(contentOperators);
2221
2228
  var resultCountOperator = import_zod12.z.enum(resultCountOperators);
2222
2229
  var resultTagOperator = import_zod12.z.enum(resultTagOperators);
2223
2230
  var mutatorEvent = import_zod12.z.enum(mutatorEvents);
2231
+ var CABContentTrigger = import_zod12.z.object({
2232
+ operator: contentOperator.default(ContentOperator.is_empty),
2233
+ type: import_zod12.z.literal("content")
2234
+ });
2224
2235
  var CABResultCountTrigger = import_zod12.z.object({
2225
2236
  operator: resultCountOperator.default(ResultCountOperator.equals),
2226
2237
  type: import_zod12.z.literal("result_count"),
@@ -2236,6 +2247,7 @@ var CABEventTrigger = import_zod12.z.object({
2236
2247
  type: import_zod12.z.literal("event")
2237
2248
  });
2238
2249
  var CABVariableTrigger = import_zod12.z.discriminatedUnion("type", [
2250
+ CABContentTrigger,
2239
2251
  CABEventTrigger,
2240
2252
  CABResultCountTrigger,
2241
2253
  CABResultTagTrigger
@@ -3324,6 +3336,38 @@ var WidgetData = import_zod37.z.discriminatedUnion("type", [
3324
3336
  RebuyMonetize
3325
3337
  ]);
3326
3338
 
3339
+ // src/schema/widgets/checkout-and-beyond/descriptionLabels.ts
3340
+ var DESCRIPTION_LABELS = {
3341
+ toggle: {
3342
+ ar: "\u0648\u0635\u0641",
3343
+ cs: "Popis",
3344
+ da: "Beskrivelse",
3345
+ de: "Beschreibung",
3346
+ en: "Description",
3347
+ es: "Descripci\xF3n",
3348
+ fi: "Kuvaus",
3349
+ fr: "Description",
3350
+ ga: "Cur s\xEDos",
3351
+ he: "\u05EA\u05D9\u05D0\u05D5\u05E8",
3352
+ hi: "\u0935\u093F\u0935\u0930\u0923",
3353
+ id: "Deskripsi",
3354
+ it: "Descrizione",
3355
+ ja: "\u8AAC\u660E",
3356
+ ko: "\uC124\uBA85",
3357
+ nl: "Beschrijving",
3358
+ no: "Beskrivelse",
3359
+ pl: "Opis",
3360
+ pt: "Descri\xE7\xE3o",
3361
+ ru: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435",
3362
+ sv: "Beskrivning",
3363
+ th: "\u0E04\u0E33\u0E2D\u0E18\u0E34\u0E1A\u0E32\u0E22",
3364
+ tr: "A\xE7\u0131klama",
3365
+ uk: "\u041E\u043F\u0438\u0441",
3366
+ vi: "M\xF4 t\u1EA3",
3367
+ zh: "\u63CF\u8FF0"
3368
+ }
3369
+ };
3370
+
3327
3371
  // src/schema/widgets/checkout-and-beyond/offerLabels.ts
3328
3372
  var OFFER_LABELS = {
3329
3373
  addedToCart: {
@@ -4070,37 +4114,10 @@ var normalizeTokens = (text, knownTokens = DEFAULT_KNOWN_TOKENS) => {
4070
4114
  };
4071
4115
 
4072
4116
  // src/transforms/contentBlockV1/convertContentBlockTextToV2.ts
4073
- var literalText = (_field, value) => normalizeTokens(value);
4074
- var convertContentBlockTextToV2 = (language, text = literalText, textAlign = "center") => {
4075
- const description = language?.description;
4076
- const superTitle = language?.superTitle;
4077
- const title = language?.title;
4078
- return TiptapDocument.parse({
4079
- attrs: { blockSpacing: "tight" },
4080
- content: [
4081
- superTitle ? convertTextToTiptapParagraph({
4082
- color: "base",
4083
- fontSize: "extraLarge",
4084
- marks: [{ type: "bold" }],
4085
- text: text("superTitle", superTitle),
4086
- textAlign
4087
- }) : null,
4088
- title ? convertTextToTiptapParagraph({
4089
- color: "base",
4090
- fontSize: "medium",
4091
- marks: [{ type: "bold" }],
4092
- text: text("title", title),
4093
- textAlign
4094
- }) : null,
4095
- description ? convertTextToTiptapParagraph({
4096
- color: "base",
4097
- fontSize: "base",
4098
- text: text("description", description),
4099
- textAlign
4100
- }) : null
4101
- ].filter((p) => p !== null),
4102
- type: "doc"
4103
- });
4117
+ var HEADER_PARAGRAPH_STYLES = {
4118
+ description: { color: "base", fontSize: "base" },
4119
+ superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
4120
+ title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
4104
4121
  };
4105
4122
 
4106
4123
  // src/transforms/v1Location.ts
@@ -4645,10 +4662,47 @@ var buildVariantTitle = (settings) => {
4645
4662
  }
4646
4663
  ];
4647
4664
  };
4665
+ var SHOW_DESCRIPTION = "showDescription";
4666
+ var HAS_DESCRIPTION = "hasDescription";
4648
4667
  var buildDescription = (settings) => {
4649
4668
  const show = settings.productOptions?.showProductDescription;
4650
4669
  if (!show || show === "hide") return [];
4651
- return [{ content: { en: buildStyledText("{{productDescription}}", void 0) }, sectionType: "text" }];
4670
+ return [
4671
+ {
4672
+ direction: "rows",
4673
+ sections: [
4674
+ {
4675
+ buttonStyle: "plain",
4676
+ sections: [{ buttonField: "buttonLabel", content: DESCRIPTION_LABELS.toggle, sectionType: "text" }],
4677
+ sectionType: "button",
4678
+ variableEffects: [{ effect: "toggle", variable: SHOW_DESCRIPTION }],
4679
+ visibility: { variable: HAS_DESCRIPTION, visibleWhen: true }
4680
+ },
4681
+ {
4682
+ content: { en: buildStyledText("{{productDescription}}", void 0) },
4683
+ mutators: [
4684
+ {
4685
+ effect: "set_false",
4686
+ variable: HAS_DESCRIPTION,
4687
+ when: { operator: "is_empty", type: "content" }
4688
+ },
4689
+ {
4690
+ effect: "set_true",
4691
+ variable: HAS_DESCRIPTION,
4692
+ when: { operator: "is_not_empty", type: "content" }
4693
+ }
4694
+ ],
4695
+ sectionType: "text",
4696
+ visibility: { variable: SHOW_DESCRIPTION, visibleWhen: true }
4697
+ }
4698
+ ],
4699
+ sectionType: "layout",
4700
+ variables: [
4701
+ { defaultValue: false, name: HAS_DESCRIPTION },
4702
+ { defaultValue: false, name: SHOW_DESCRIPTION }
4703
+ ]
4704
+ }
4705
+ ];
4652
4706
  };
4653
4707
  var buildVariants = (settings) => {
4654
4708
  if (settings.viewOptions?.displayActions === false) return [];
@@ -4796,22 +4850,43 @@ var sanitizedHeader = (language) => Object.fromEntries(
4796
4850
  return sanitized ? [[field, sanitized]] : [];
4797
4851
  })
4798
4852
  );
4799
- var hasHeaderText = (header) => Object.keys(header).length > 0;
4800
- var headerText = (field) => `{{${field}}}`;
4801
- var headerVariables = (header) => HEADER_FIELDS.flatMap((field) => {
4802
- const defaultValue = header[field];
4803
- return defaultValue === void 0 ? [] : [{ defaultValue, name: field, type: VariableType.text }];
4853
+ var headerVariables = (header) => HEADER_FIELDS.map((field) => ({ defaultValue: header[field] ?? "", name: field, type: VariableType.text }));
4854
+ var HAS_HEADER = "hasHeader";
4855
+ var headerFlag = (field) => `hasHeader${field.charAt(0).toUpperCase()}${field.slice(1)}`;
4856
+ var headerLine = (field, textAlign) => ({
4857
+ content: {
4858
+ en: {
4859
+ attrs: { blockSpacing: "tight" },
4860
+ content: [
4861
+ convertTextToTiptapParagraph({ ...HEADER_PARAGRAPH_STYLES[field], text: `{{${field}}}`, textAlign })
4862
+ ],
4863
+ type: "doc"
4864
+ }
4865
+ },
4866
+ mutators: [
4867
+ { effect: "set_false", variable: headerFlag(field), when: { operator: "is_empty", type: "content" } },
4868
+ { effect: "set_true", variable: headerFlag(field), when: { operator: "is_not_empty", type: "content" } },
4869
+ { effect: "set_true", variable: HAS_HEADER, when: { operator: "is_not_empty", type: "content" } }
4870
+ ],
4871
+ sectionType: "text",
4872
+ visibility: { variable: headerFlag(field), visibleWhen: true }
4804
4873
  });
4805
- var headerNode = (header, textAlign) => ({
4806
- content: { en: convertContentBlockTextToV2(header, headerText, textAlign) },
4807
- sectionType: "text"
4874
+ var headerNode = (textAlign) => ({
4875
+ alignment: { horizontal: textAlign, vertical: "top" },
4876
+ direction: "rows",
4877
+ name: "header",
4878
+ sections: HEADER_FIELDS.map((field) => headerLine(field, textAlign)),
4879
+ sectionType: "layout",
4880
+ spacing: "tight",
4881
+ variables: [HAS_HEADER, ...HEADER_FIELDS.map(headerFlag)].map((name) => ({ defaultValue: false, name })),
4882
+ visibility: { variable: HAS_HEADER, visibleWhen: true }
4808
4883
  });
4809
- var buildHeaderNavRow = (header) => ({
4884
+ var buildHeaderNavRow = () => ({
4810
4885
  alignment: { horizontal: "start", vertical: "bottom" },
4811
4886
  direction: "grid",
4812
4887
  grid: { columns: ["fill", "auto"] },
4813
- name: "header",
4814
- sections: [headerNode(header, "start"), buildCarouselNav()],
4888
+ name: "chrome",
4889
+ sections: [headerNode("start"), buildCarouselNav()],
4815
4890
  sectionType: "layout",
4816
4891
  spacing: "base"
4817
4892
  });
@@ -4907,7 +4982,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4907
4982
  const pageSize = Math.max(columns, 1);
4908
4983
  const limit = settings.limit ?? void 0;
4909
4984
  const showsNav = !!layout?.carousel && !paginationOff(layout.showPaginations) && (limit === void 0 || limit > pageSize);
4910
- const headerInChrome = showsNav && hasHeaderText(header);
4985
+ const headerInChrome = showsNav;
4911
4986
  const fitsOneRow = limit !== void 0 && limit <= pageSize;
4912
4987
  const sideBySide = direction === "grid" || direction === "columns";
4913
4988
  const offersDirection = sideBySide && (showsNav || fitsOneRow) ? "horizontal" : "vertical";
@@ -4974,7 +5049,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4974
5049
  itemsAtOnce: Math.max(showsNav ? columns : limit ?? ENGINE_LIMIT_CEILING, 1),
4975
5050
  ...listLayout,
4976
5051
  padding: gridChrome ? paddingFor(containerBorder.style) : "none",
4977
- sections: showsNav ? [headerInChrome ? buildHeaderNavRow(header) : buildCarouselNav(), offers] : [offers],
5052
+ sections: headerInChrome ? [buildHeaderNavRow(), offers] : [offers],
4978
5053
  sectionType: "carousel"
4979
5054
  };
4980
5055
  return CABRootSection.parse({
@@ -4984,7 +5059,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4984
5059
  // The widget name is required by the admin save schema; carry the legacy widget's name through.
4985
5060
  ...name && { name },
4986
5061
  previewMode: settings.previewMode,
4987
- sections: [...hasHeaderText(header) && !headerInChrome ? [headerNode(header, "center")] : [], display],
5062
+ sections: [...headerInChrome ? [] : [headerNode("center")], display],
4988
5063
  // CABTracking's schema fallbacks fill missing or null fields and the missing object; malformed values throw.
4989
5064
  tracking: settings.tracking,
4990
5065
  type: SHOPIFY_CHECKOUT_EXTENSION,
package/dist/index.mjs CHANGED
@@ -1417,6 +1417,8 @@ var buttonFields = [
1417
1417
  var ButtonField = freezeEnum(buttonFields);
1418
1418
  var buttonStyles = ["primary", "secondary", "plain", "custom"];
1419
1419
  var ButtonStyle = freezeEnum(buttonStyles);
1420
+ var contentOperators = ["is_empty", "is_not_empty"];
1421
+ var ContentOperator = freezeEnum(contentOperators);
1420
1422
  var directions = ["columns", "rows", "grid"];
1421
1423
  var Direction = freezeEnum(directions);
1422
1424
  var discountSources = ["price", "compare_at_price"];
@@ -1928,9 +1930,14 @@ var CABVisibility = z12.object({
1928
1930
  variable: z12.string().min(1),
1929
1931
  visibleWhen: z12.boolean().default(true)
1930
1932
  });
1933
+ var contentOperator = z12.enum(contentOperators);
1931
1934
  var resultCountOperator = z12.enum(resultCountOperators);
1932
1935
  var resultTagOperator = z12.enum(resultTagOperators);
1933
1936
  var mutatorEvent = z12.enum(mutatorEvents);
1937
+ var CABContentTrigger = z12.object({
1938
+ operator: contentOperator.default(ContentOperator.is_empty),
1939
+ type: z12.literal("content")
1940
+ });
1934
1941
  var CABResultCountTrigger = z12.object({
1935
1942
  operator: resultCountOperator.default(ResultCountOperator.equals),
1936
1943
  type: z12.literal("result_count"),
@@ -1946,6 +1953,7 @@ var CABEventTrigger = z12.object({
1946
1953
  type: z12.literal("event")
1947
1954
  });
1948
1955
  var CABVariableTrigger = z12.discriminatedUnion("type", [
1956
+ CABContentTrigger,
1949
1957
  CABEventTrigger,
1950
1958
  CABResultCountTrigger,
1951
1959
  CABResultTagTrigger
@@ -3034,6 +3042,38 @@ var WidgetData = z37.discriminatedUnion("type", [
3034
3042
  RebuyMonetize
3035
3043
  ]);
3036
3044
 
3045
+ // src/schema/widgets/checkout-and-beyond/descriptionLabels.ts
3046
+ var DESCRIPTION_LABELS = {
3047
+ toggle: {
3048
+ ar: "\u0648\u0635\u0641",
3049
+ cs: "Popis",
3050
+ da: "Beskrivelse",
3051
+ de: "Beschreibung",
3052
+ en: "Description",
3053
+ es: "Descripci\xF3n",
3054
+ fi: "Kuvaus",
3055
+ fr: "Description",
3056
+ ga: "Cur s\xEDos",
3057
+ he: "\u05EA\u05D9\u05D0\u05D5\u05E8",
3058
+ hi: "\u0935\u093F\u0935\u0930\u0923",
3059
+ id: "Deskripsi",
3060
+ it: "Descrizione",
3061
+ ja: "\u8AAC\u660E",
3062
+ ko: "\uC124\uBA85",
3063
+ nl: "Beschrijving",
3064
+ no: "Beskrivelse",
3065
+ pl: "Opis",
3066
+ pt: "Descri\xE7\xE3o",
3067
+ ru: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435",
3068
+ sv: "Beskrivning",
3069
+ th: "\u0E04\u0E33\u0E2D\u0E18\u0E34\u0E1A\u0E32\u0E22",
3070
+ tr: "A\xE7\u0131klama",
3071
+ uk: "\u041E\u043F\u0438\u0441",
3072
+ vi: "M\xF4 t\u1EA3",
3073
+ zh: "\u63CF\u8FF0"
3074
+ }
3075
+ };
3076
+
3037
3077
  // src/schema/widgets/checkout-and-beyond/offerLabels.ts
3038
3078
  var OFFER_LABELS = {
3039
3079
  addedToCart: {
@@ -3780,37 +3820,10 @@ var normalizeTokens = (text, knownTokens = DEFAULT_KNOWN_TOKENS) => {
3780
3820
  };
3781
3821
 
3782
3822
  // src/transforms/contentBlockV1/convertContentBlockTextToV2.ts
3783
- var literalText = (_field, value) => normalizeTokens(value);
3784
- var convertContentBlockTextToV2 = (language, text = literalText, textAlign = "center") => {
3785
- const description = language?.description;
3786
- const superTitle = language?.superTitle;
3787
- const title = language?.title;
3788
- return TiptapDocument.parse({
3789
- attrs: { blockSpacing: "tight" },
3790
- content: [
3791
- superTitle ? convertTextToTiptapParagraph({
3792
- color: "base",
3793
- fontSize: "extraLarge",
3794
- marks: [{ type: "bold" }],
3795
- text: text("superTitle", superTitle),
3796
- textAlign
3797
- }) : null,
3798
- title ? convertTextToTiptapParagraph({
3799
- color: "base",
3800
- fontSize: "medium",
3801
- marks: [{ type: "bold" }],
3802
- text: text("title", title),
3803
- textAlign
3804
- }) : null,
3805
- description ? convertTextToTiptapParagraph({
3806
- color: "base",
3807
- fontSize: "base",
3808
- text: text("description", description),
3809
- textAlign
3810
- }) : null
3811
- ].filter((p) => p !== null),
3812
- type: "doc"
3813
- });
3823
+ var HEADER_PARAGRAPH_STYLES = {
3824
+ description: { color: "base", fontSize: "base" },
3825
+ superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
3826
+ title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
3814
3827
  };
3815
3828
 
3816
3829
  // src/transforms/v1Location.ts
@@ -4355,10 +4368,47 @@ var buildVariantTitle = (settings) => {
4355
4368
  }
4356
4369
  ];
4357
4370
  };
4371
+ var SHOW_DESCRIPTION = "showDescription";
4372
+ var HAS_DESCRIPTION = "hasDescription";
4358
4373
  var buildDescription = (settings) => {
4359
4374
  const show = settings.productOptions?.showProductDescription;
4360
4375
  if (!show || show === "hide") return [];
4361
- return [{ content: { en: buildStyledText("{{productDescription}}", void 0) }, sectionType: "text" }];
4376
+ return [
4377
+ {
4378
+ direction: "rows",
4379
+ sections: [
4380
+ {
4381
+ buttonStyle: "plain",
4382
+ sections: [{ buttonField: "buttonLabel", content: DESCRIPTION_LABELS.toggle, sectionType: "text" }],
4383
+ sectionType: "button",
4384
+ variableEffects: [{ effect: "toggle", variable: SHOW_DESCRIPTION }],
4385
+ visibility: { variable: HAS_DESCRIPTION, visibleWhen: true }
4386
+ },
4387
+ {
4388
+ content: { en: buildStyledText("{{productDescription}}", void 0) },
4389
+ mutators: [
4390
+ {
4391
+ effect: "set_false",
4392
+ variable: HAS_DESCRIPTION,
4393
+ when: { operator: "is_empty", type: "content" }
4394
+ },
4395
+ {
4396
+ effect: "set_true",
4397
+ variable: HAS_DESCRIPTION,
4398
+ when: { operator: "is_not_empty", type: "content" }
4399
+ }
4400
+ ],
4401
+ sectionType: "text",
4402
+ visibility: { variable: SHOW_DESCRIPTION, visibleWhen: true }
4403
+ }
4404
+ ],
4405
+ sectionType: "layout",
4406
+ variables: [
4407
+ { defaultValue: false, name: HAS_DESCRIPTION },
4408
+ { defaultValue: false, name: SHOW_DESCRIPTION }
4409
+ ]
4410
+ }
4411
+ ];
4362
4412
  };
4363
4413
  var buildVariants = (settings) => {
4364
4414
  if (settings.viewOptions?.displayActions === false) return [];
@@ -4506,22 +4556,43 @@ var sanitizedHeader = (language) => Object.fromEntries(
4506
4556
  return sanitized ? [[field, sanitized]] : [];
4507
4557
  })
4508
4558
  );
4509
- var hasHeaderText = (header) => Object.keys(header).length > 0;
4510
- var headerText = (field) => `{{${field}}}`;
4511
- var headerVariables = (header) => HEADER_FIELDS.flatMap((field) => {
4512
- const defaultValue = header[field];
4513
- return defaultValue === void 0 ? [] : [{ defaultValue, name: field, type: VariableType.text }];
4559
+ var headerVariables = (header) => HEADER_FIELDS.map((field) => ({ defaultValue: header[field] ?? "", name: field, type: VariableType.text }));
4560
+ var HAS_HEADER = "hasHeader";
4561
+ var headerFlag = (field) => `hasHeader${field.charAt(0).toUpperCase()}${field.slice(1)}`;
4562
+ var headerLine = (field, textAlign) => ({
4563
+ content: {
4564
+ en: {
4565
+ attrs: { blockSpacing: "tight" },
4566
+ content: [
4567
+ convertTextToTiptapParagraph({ ...HEADER_PARAGRAPH_STYLES[field], text: `{{${field}}}`, textAlign })
4568
+ ],
4569
+ type: "doc"
4570
+ }
4571
+ },
4572
+ mutators: [
4573
+ { effect: "set_false", variable: headerFlag(field), when: { operator: "is_empty", type: "content" } },
4574
+ { effect: "set_true", variable: headerFlag(field), when: { operator: "is_not_empty", type: "content" } },
4575
+ { effect: "set_true", variable: HAS_HEADER, when: { operator: "is_not_empty", type: "content" } }
4576
+ ],
4577
+ sectionType: "text",
4578
+ visibility: { variable: headerFlag(field), visibleWhen: true }
4514
4579
  });
4515
- var headerNode = (header, textAlign) => ({
4516
- content: { en: convertContentBlockTextToV2(header, headerText, textAlign) },
4517
- sectionType: "text"
4580
+ var headerNode = (textAlign) => ({
4581
+ alignment: { horizontal: textAlign, vertical: "top" },
4582
+ direction: "rows",
4583
+ name: "header",
4584
+ sections: HEADER_FIELDS.map((field) => headerLine(field, textAlign)),
4585
+ sectionType: "layout",
4586
+ spacing: "tight",
4587
+ variables: [HAS_HEADER, ...HEADER_FIELDS.map(headerFlag)].map((name) => ({ defaultValue: false, name })),
4588
+ visibility: { variable: HAS_HEADER, visibleWhen: true }
4518
4589
  });
4519
- var buildHeaderNavRow = (header) => ({
4590
+ var buildHeaderNavRow = () => ({
4520
4591
  alignment: { horizontal: "start", vertical: "bottom" },
4521
4592
  direction: "grid",
4522
4593
  grid: { columns: ["fill", "auto"] },
4523
- name: "header",
4524
- sections: [headerNode(header, "start"), buildCarouselNav()],
4594
+ name: "chrome",
4595
+ sections: [headerNode("start"), buildCarouselNav()],
4525
4596
  sectionType: "layout",
4526
4597
  spacing: "base"
4527
4598
  });
@@ -4617,7 +4688,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4617
4688
  const pageSize = Math.max(columns, 1);
4618
4689
  const limit = settings.limit ?? void 0;
4619
4690
  const showsNav = !!layout?.carousel && !paginationOff(layout.showPaginations) && (limit === void 0 || limit > pageSize);
4620
- const headerInChrome = showsNav && hasHeaderText(header);
4691
+ const headerInChrome = showsNav;
4621
4692
  const fitsOneRow = limit !== void 0 && limit <= pageSize;
4622
4693
  const sideBySide = direction === "grid" || direction === "columns";
4623
4694
  const offersDirection = sideBySide && (showsNav || fitsOneRow) ? "horizontal" : "vertical";
@@ -4684,7 +4755,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4684
4755
  itemsAtOnce: Math.max(showsNav ? columns : limit ?? ENGINE_LIMIT_CEILING, 1),
4685
4756
  ...listLayout,
4686
4757
  padding: gridChrome ? paddingFor(containerBorder.style) : "none",
4687
- sections: showsNav ? [headerInChrome ? buildHeaderNavRow(header) : buildCarouselNav(), offers] : [offers],
4758
+ sections: headerInChrome ? [buildHeaderNavRow(), offers] : [offers],
4688
4759
  sectionType: "carousel"
4689
4760
  };
4690
4761
  return CABRootSection.parse({
@@ -4694,7 +4765,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
4694
4765
  // The widget name is required by the admin save schema; carry the legacy widget's name through.
4695
4766
  ...name && { name },
4696
4767
  previewMode: settings.previewMode,
4697
- sections: [...hasHeaderText(header) && !headerInChrome ? [headerNode(header, "center")] : [], display],
4768
+ sections: [...headerInChrome ? [] : [headerNode("center")], display],
4698
4769
  // CABTracking's schema fallbacks fill missing or null fields and the missing object; malformed values throw.
4699
4770
  tracking: settings.tracking,
4700
4771
  type: SHOPIFY_CHECKOUT_EXTENSION,
@@ -4723,6 +4794,7 @@ export {
4723
4794
  CABButtonSection,
4724
4795
  CABCarouselSection,
4725
4796
  CABCartLineSection,
4797
+ CABContentTrigger,
4726
4798
  CABDataSourceSection,
4727
4799
  CABDiscount,
4728
4800
  CABDiscountSection,
@@ -4771,7 +4843,9 @@ export {
4771
4843
  CheckoutExtension,
4772
4844
  ContentBlock,
4773
4845
  ContentBlockV1,
4846
+ ContentOperator,
4774
4847
  DEFAULT_ENDPOINTS,
4848
+ DESCRIPTION_LABELS,
4775
4849
  DYNAMIC_TOKEN_REGEX,
4776
4850
  Direction,
4777
4851
  DiscountSource,
@@ -4874,6 +4948,7 @@ export {
4874
4948
  buttonFields,
4875
4949
  buttonStyles,
4876
4950
  checkForHTML,
4951
+ contentOperators,
4877
4952
  convertNumericObjectsLoose as convertNumericObjects,
4878
4953
  convertOfferToV2,
4879
4954
  convertProductToStorefrontFormat,
@@ -27,6 +27,7 @@ __export(common_exports, {
27
27
  ButtonAction: () => ButtonAction,
28
28
  ButtonField: () => ButtonField,
29
29
  ButtonStyle: () => ButtonStyle,
30
+ ContentOperator: () => ContentOperator,
30
31
  Direction: () => Direction,
31
32
  DiscountSource: () => DiscountSource,
32
33
  DiscountType: () => DiscountType,
@@ -64,6 +65,7 @@ __export(common_exports, {
64
65
  buttonActions: () => buttonActions,
65
66
  buttonFields: () => buttonFields,
66
67
  buttonStyles: () => buttonStyles,
68
+ contentOperators: () => contentOperators,
67
69
  directions: () => directions,
68
70
  discountSources: () => discountSources,
69
71
  discountTypes: () => discountTypes,
@@ -154,6 +156,8 @@ var buttonFields = [
154
156
  var ButtonField = freezeEnum(buttonFields);
155
157
  var buttonStyles = ["primary", "secondary", "plain", "custom"];
156
158
  var ButtonStyle = freezeEnum(buttonStyles);
159
+ var contentOperators = ["is_empty", "is_not_empty"];
160
+ var ContentOperator = freezeEnum(contentOperators);
157
161
  var directions = ["columns", "rows", "grid"];
158
162
  var Direction = freezeEnum(directions);
159
163
  var discountSources = ["price", "compare_at_price"];
@@ -55,6 +55,8 @@ var buttonFields = [
55
55
  var ButtonField = freezeEnum(buttonFields);
56
56
  var buttonStyles = ["primary", "secondary", "plain", "custom"];
57
57
  var ButtonStyle = freezeEnum(buttonStyles);
58
+ var contentOperators = ["is_empty", "is_not_empty"];
59
+ var ContentOperator = freezeEnum(contentOperators);
58
60
  var directions = ["columns", "rows", "grid"];
59
61
  var Direction = freezeEnum(directions);
60
62
  var discountSources = ["price", "compare_at_price"];
@@ -206,6 +208,7 @@ export {
206
208
  ButtonAction,
207
209
  ButtonField,
208
210
  ButtonStyle,
211
+ ContentOperator,
209
212
  Direction,
210
213
  DiscountSource,
211
214
  DiscountType,
@@ -243,6 +246,7 @@ export {
243
246
  buttonActions,
244
247
  buttonFields,
245
248
  buttonStyles,
249
+ contentOperators,
246
250
  directions,
247
251
  discountSources,
248
252
  discountTypes,
@@ -35,6 +35,7 @@ __export(checkout_and_beyond_exports, {
35
35
  CABButtonSection: () => CABButtonSection,
36
36
  CABCarouselSection: () => CABCarouselSection,
37
37
  CABCartLineSection: () => CABCartLineSection,
38
+ CABContentTrigger: () => CABContentTrigger,
38
39
  CABDataSourceSection: () => CABDataSourceSection,
39
40
  CABDiscount: () => CABDiscount,
40
41
  CABDiscountSection: () => CABDiscountSection,
@@ -75,7 +76,9 @@ __export(checkout_and_beyond_exports, {
75
76
  CABVariantsSection: () => CABVariantsSection,
76
77
  CABVisibility: () => CABVisibility,
77
78
  COMBINED_ENDPOINTS: () => COMBINED_ENDPOINTS,
79
+ ContentOperator: () => ContentOperator,
78
80
  DEFAULT_ENDPOINTS: () => DEFAULT_ENDPOINTS,
81
+ DESCRIPTION_LABELS: () => DESCRIPTION_LABELS,
79
82
  DYNAMIC_TOKEN_REGEX: () => DYNAMIC_TOKEN_REGEX,
80
83
  Direction: () => Direction,
81
84
  DiscountSource: () => DiscountSource,
@@ -136,6 +139,7 @@ __export(checkout_and_beyond_exports, {
136
139
  buttonFields: () => buttonFields,
137
140
  buttonStyles: () => buttonStyles,
138
141
  checkForHTML: () => checkForHTML,
142
+ contentOperators: () => contentOperators,
139
143
  convertNumericObjects: () => convertNumericObjectsLoose,
140
144
  directions: () => directions,
141
145
  discountSources: () => discountSources,
@@ -258,6 +262,8 @@ var buttonFields = [
258
262
  var ButtonField = freezeEnum(buttonFields);
259
263
  var buttonStyles = ["primary", "secondary", "plain", "custom"];
260
264
  var ButtonStyle = freezeEnum(buttonStyles);
265
+ var contentOperators = ["is_empty", "is_not_empty"];
266
+ var ContentOperator = freezeEnum(contentOperators);
261
267
  var directions = ["columns", "rows", "grid"];
262
268
  var Direction = freezeEnum(directions);
263
269
  var discountSources = ["price", "compare_at_price"];
@@ -678,9 +684,14 @@ var CABVisibility = import_zod2.z.object({
678
684
  variable: import_zod2.z.string().min(1),
679
685
  visibleWhen: import_zod2.z.boolean().default(true)
680
686
  });
687
+ var contentOperator = import_zod2.z.enum(contentOperators);
681
688
  var resultCountOperator = import_zod2.z.enum(resultCountOperators);
682
689
  var resultTagOperator = import_zod2.z.enum(resultTagOperators);
683
690
  var mutatorEvent = import_zod2.z.enum(mutatorEvents);
691
+ var CABContentTrigger = import_zod2.z.object({
692
+ operator: contentOperator.default(ContentOperator.is_empty),
693
+ type: import_zod2.z.literal("content")
694
+ });
684
695
  var CABResultCountTrigger = import_zod2.z.object({
685
696
  operator: resultCountOperator.default(ResultCountOperator.equals),
686
697
  type: import_zod2.z.literal("result_count"),
@@ -696,6 +707,7 @@ var CABEventTrigger = import_zod2.z.object({
696
707
  type: import_zod2.z.literal("event")
697
708
  });
698
709
  var CABVariableTrigger = import_zod2.z.discriminatedUnion("type", [
710
+ CABContentTrigger,
699
711
  CABEventTrigger,
700
712
  CABResultCountTrigger,
701
713
  CABResultTagTrigger
@@ -1647,6 +1659,38 @@ var CABBannerSection = import_zod20.z.lazy(
1647
1659
  })
1648
1660
  );
1649
1661
 
1662
+ // src/schema/widgets/checkout-and-beyond/descriptionLabels.ts
1663
+ var DESCRIPTION_LABELS = {
1664
+ toggle: {
1665
+ ar: "\u0648\u0635\u0641",
1666
+ cs: "Popis",
1667
+ da: "Beskrivelse",
1668
+ de: "Beschreibung",
1669
+ en: "Description",
1670
+ es: "Descripci\xF3n",
1671
+ fi: "Kuvaus",
1672
+ fr: "Description",
1673
+ ga: "Cur s\xEDos",
1674
+ he: "\u05EA\u05D9\u05D0\u05D5\u05E8",
1675
+ hi: "\u0935\u093F\u0935\u0930\u0923",
1676
+ id: "Deskripsi",
1677
+ it: "Descrizione",
1678
+ ja: "\u8AAC\u660E",
1679
+ ko: "\uC124\uBA85",
1680
+ nl: "Beschrijving",
1681
+ no: "Beskrivelse",
1682
+ pl: "Opis",
1683
+ pt: "Descri\xE7\xE3o",
1684
+ ru: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435",
1685
+ sv: "Beskrivning",
1686
+ th: "\u0E04\u0E33\u0E2D\u0E18\u0E34\u0E1A\u0E32\u0E22",
1687
+ tr: "A\xE7\u0131klama",
1688
+ uk: "\u041E\u043F\u0438\u0441",
1689
+ vi: "M\xF4 t\u1EA3",
1690
+ zh: "\u63CF\u8FF0"
1691
+ }
1692
+ };
1693
+
1650
1694
  // src/schema/widgets/checkout-and-beyond/offerLabels.ts
1651
1695
  var OFFER_LABELS = {
1652
1696
  addedToCart: {