@rebuy/rebuy 2.27.0 → 2.28.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 (58) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1352 -366
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +1351 -365
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/schema/checkout-and-beyond/constants.js +1 -0
  8. package/dist/schema/checkout-and-beyond/constants.js.map +2 -2
  9. package/dist/schema/checkout-and-beyond/constants.mjs +1 -0
  10. package/dist/schema/checkout-and-beyond/constants.mjs.map +2 -2
  11. package/dist/schema/checkout-and-beyond/index.js +285 -92
  12. package/dist/schema/checkout-and-beyond/index.js.map +4 -4
  13. package/dist/schema/checkout-and-beyond/index.mjs +285 -92
  14. package/dist/schema/checkout-and-beyond/index.mjs.map +4 -4
  15. package/dist/schema/widget-data.js +165 -148
  16. package/dist/schema/widget-data.js.map +4 -4
  17. package/dist/schema/widget-data.mjs +165 -148
  18. package/dist/schema/widget-data.mjs.map +4 -4
  19. package/dist/schema/widgets/checkout-and-beyond/common.d.ts +2 -1
  20. package/dist/schema/widgets/checkout-and-beyond/common.d.ts.map +1 -1
  21. package/dist/schema/widgets/checkout-and-beyond/discount.d.ts +30 -0
  22. package/dist/schema/widgets/checkout-and-beyond/discount.d.ts.map +1 -0
  23. package/dist/schema/widgets/checkout-and-beyond/index.d.ts +2 -0
  24. package/dist/schema/widgets/checkout-and-beyond/index.d.ts.map +1 -1
  25. package/dist/schema/widgets/checkout-and-beyond/offerLabels.d.ts +178 -0
  26. package/dist/schema/widgets/checkout-and-beyond/offerLabels.d.ts.map +1 -0
  27. package/dist/schema/widgets/checkout-and-beyond/shared.d.ts +2 -1
  28. package/dist/schema/widgets/checkout-and-beyond/shared.d.ts.map +1 -1
  29. package/dist/schema/widgets/checkout-and-beyond/utils.d.ts +2 -0
  30. package/dist/schema/widgets/checkout-and-beyond/utils.d.ts.map +1 -1
  31. package/dist/server/dataSourceResults.d.ts +18 -0
  32. package/dist/server/dataSourceResults.d.ts.map +1 -0
  33. package/dist/server/index.d.ts +6 -2
  34. package/dist/server/index.d.ts.map +1 -1
  35. package/dist/server/index.js +1162 -435
  36. package/dist/server/index.js.map +4 -4
  37. package/dist/server/index.mjs +1161 -434
  38. package/dist/server/index.mjs.map +4 -4
  39. package/dist/server/userConfig.d.ts +8 -0
  40. package/dist/server/userConfig.d.ts.map +1 -0
  41. package/dist/server/widgetSettings.d.ts.map +1 -1
  42. package/dist/transforms/index.d.ts +4 -0
  43. package/dist/transforms/index.d.ts.map +1 -1
  44. package/dist/transforms/index.js +1004 -81
  45. package/dist/transforms/index.js.map +4 -4
  46. package/dist/transforms/index.mjs +1004 -81
  47. package/dist/transforms/index.mjs.map +4 -4
  48. package/dist/transforms/offerV1/buildOfferTemplate.d.ts +13 -0
  49. package/dist/transforms/offerV1/buildOfferTemplate.d.ts.map +1 -0
  50. package/dist/transforms/offerV1/convertOfferToV2.d.ts +18 -0
  51. package/dist/transforms/offerV1/convertOfferToV2.d.ts.map +1 -0
  52. package/dist/transforms/offerV1/offerCard.d.ts +17 -0
  53. package/dist/transforms/offerV1/offerCard.d.ts.map +1 -0
  54. package/dist/transforms/offerV1/offerTemplateSeed.d.ts +339 -0
  55. package/dist/transforms/offerV1/offerTemplateSeed.d.ts.map +1 -0
  56. package/dist/transforms/offerV1/types.d.ts +145 -0
  57. package/dist/transforms/offerV1/types.d.ts.map +1 -0
  58. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  // src/schema/widgets/checkout-and-beyond/image.ts
2
- import { v7 as uuidv712 } from "uuid";
3
- import { z as z18 } from "zod/v4";
2
+ import { v7 as uuidv713 } from "uuid";
3
+ import { z as z19 } from "zod/v4";
4
4
 
5
5
  // src/schema/widgets/checkout-and-beyond/common.ts
6
6
  var freezeEnum = (values) => Object.freeze(Object.fromEntries(values.map((v) => [v, v])));
@@ -120,6 +120,7 @@ var sectionTypes = [
120
120
  "carousel",
121
121
  "cartLine",
122
122
  "dataSource",
123
+ "discount",
123
124
  "image",
124
125
  "layout",
125
126
  "monetize",
@@ -221,7 +222,7 @@ var CABRule = z.object({
221
222
  });
222
223
 
223
224
  // src/schema/widgets/checkout-and-beyond/shared.ts
224
- import { z as z17 } from "zod/v4";
225
+ import { z as z18 } from "zod/v4";
225
226
 
226
227
  // src/schema/widgets/checkout-and-beyond/banner.ts
227
228
  import { z as z3 } from "zod/v4";
@@ -592,39 +593,54 @@ var CABCartLineSection = z11.lazy(
592
593
  })
593
594
  );
594
595
 
595
- // src/schema/widgets/checkout-and-beyond/monetize.ts
596
+ // src/schema/widgets/checkout-and-beyond/discount.ts
596
597
  import { v7 as uuidv77 } from "uuid";
597
598
  import { z as z12 } from "zod/v4";
598
- var CABMonetizeSection = z12.object({
599
+ var CABDiscountSection = z12.object({
600
+ amount: z12.union([z12.number(), z12.string()]).catch(0),
601
+ discountedBy: z12.string().optional(),
602
+ discountedFrom: z12.enum(discountSources).optional().catch(void 0),
603
+ message: z12.string().optional(),
599
604
  name: z12.string().optional(),
600
- rule: CABRule.optional(),
605
+ quantity: z12.number().default(1),
601
606
  sectionId: z12.uuid().default(() => uuidv77()),
602
- sectionType: z12.literal(SectionType.monetize).default(SectionType.monetize)
607
+ sectionType: z12.literal(SectionType.discount).default(SectionType.discount),
608
+ type: z12.enum(discountTypes).catch("none")
603
609
  });
604
610
 
605
- // src/schema/widgets/checkout-and-beyond/progressBar.ts
611
+ // src/schema/widgets/checkout-and-beyond/monetize.ts
606
612
  import { v7 as uuidv78 } from "uuid";
607
613
  import { z as z13 } from "zod/v4";
608
- var CABProgressBarSection = z13.object({
609
- /** Empty = shown everywhere; otherwise uppercase ISO country codes. */
610
- countryCodes: z13.array(z13.string()).default(() => []),
614
+ var CABMonetizeSection = z13.object({
611
615
  name: z13.string().optional(),
612
616
  rule: CABRule.optional(),
613
617
  sectionId: z13.uuid().default(() => uuidv78()),
614
- sections: z13.union([z13.array(CABTextSection), z13.strictObject({}).transform(() => [])]).default(() => []),
615
- sectionType: z13.literal(SectionType.progressBar).default(SectionType.progressBar)
618
+ sectionType: z13.literal(SectionType.monetize).default(SectionType.monetize)
616
619
  });
617
620
 
618
- // src/schema/widgets/checkout-and-beyond/quantity.ts
621
+ // src/schema/widgets/checkout-and-beyond/progressBar.ts
619
622
  import { v7 as uuidv79 } from "uuid";
620
623
  import { z as z14 } from "zod/v4";
621
- var CABQuantitySection = z14.object({
622
- errorMessages: z14.record(
623
- z14.string(),
624
- z14.object({
625
- max: z14.string().optional(),
626
- min: z14.string().optional(),
627
- neg: z14.string().optional()
624
+ var CABProgressBarSection = z14.object({
625
+ /** Empty = shown everywhere; otherwise uppercase ISO country codes. */
626
+ countryCodes: z14.array(z14.string()).default(() => []),
627
+ name: z14.string().optional(),
628
+ rule: CABRule.optional(),
629
+ sectionId: z14.uuid().default(() => uuidv79()),
630
+ sections: z14.union([z14.array(CABTextSection), z14.strictObject({}).transform(() => [])]).default(() => []),
631
+ sectionType: z14.literal(SectionType.progressBar).default(SectionType.progressBar)
632
+ });
633
+
634
+ // src/schema/widgets/checkout-and-beyond/quantity.ts
635
+ import { v7 as uuidv710 } from "uuid";
636
+ import { z as z15 } from "zod/v4";
637
+ var CABQuantitySection = z15.object({
638
+ errorMessages: z15.record(
639
+ z15.string(),
640
+ z15.object({
641
+ max: z15.string().optional(),
642
+ min: z15.string().optional(),
643
+ neg: z15.string().optional()
628
644
  })
629
645
  ).default({
630
646
  en: {
@@ -633,58 +649,59 @@ var CABQuantitySection = z14.object({
633
649
  neg: "Quantity cannot be negative"
634
650
  }
635
651
  }),
636
- inputType: z14.enum(quantityInputs).default(QuantityInput.select),
637
- max: z14.number().min(1).max(100).default(10),
638
- min: z14.number().min(1).default(1),
639
- name: z14.string().optional(),
640
- rule: CABRule.optional(),
641
- sectionId: z14.uuid().default(() => uuidv79()),
642
- sectionType: z14.literal(SectionType.quantity).default(SectionType.quantity)
643
- });
644
-
645
- // src/schema/widgets/checkout-and-beyond/reviews.ts
646
- import { v7 as uuidv710 } from "uuid";
647
- import { z as z15 } from "zod/v4";
648
- var CABReviewsSection = z15.object({
649
- color: z15.string().default("#fadb14"),
652
+ inputType: z15.enum(quantityInputs).default(QuantityInput.select),
653
+ max: z15.number().min(1).max(100).default(10),
654
+ min: z15.number().min(1).default(1),
650
655
  name: z15.string().optional(),
651
656
  rule: CABRule.optional(),
652
657
  sectionId: z15.uuid().default(() => uuidv710()),
653
- sectionType: z15.literal(SectionType.reviews).default(SectionType.reviews),
654
- size: z15.enum(reviewsSizes).default(ReviewsSize.default)
658
+ sectionType: z15.literal(SectionType.quantity).default(SectionType.quantity)
655
659
  });
656
660
 
657
- // src/schema/widgets/checkout-and-beyond/variants.ts
658
- import { slice } from "es-toolkit/compat";
661
+ // src/schema/widgets/checkout-and-beyond/reviews.ts
659
662
  import { v7 as uuidv711 } from "uuid";
660
663
  import { z as z16 } from "zod/v4";
661
- var CABVariantsSection = z16.object({
662
- hideOutOfStockVariants: z16.boolean().default(false),
664
+ var CABReviewsSection = z16.object({
665
+ color: z16.string().default("#fadb14"),
663
666
  name: z16.string().optional(),
664
667
  rule: CABRule.optional(),
665
668
  sectionId: z16.uuid().default(() => uuidv711()),
666
- sectionType: z16.literal(SectionType.variants).default(SectionType.variants),
667
- selector: z16.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
668
- variantMode: z16.enum(variantModes).default(VariantMode.multiple)
669
+ sectionType: z16.literal(SectionType.reviews).default(SectionType.reviews),
670
+ size: z16.enum(reviewsSizes).default(ReviewsSize.default)
671
+ });
672
+
673
+ // src/schema/widgets/checkout-and-beyond/variants.ts
674
+ import { slice } from "es-toolkit/compat";
675
+ import { v7 as uuidv712 } from "uuid";
676
+ import { z as z17 } from "zod/v4";
677
+ var CABVariantsSection = z17.object({
678
+ hideOutOfStockVariants: z17.boolean().default(false),
679
+ name: z17.string().optional(),
680
+ rule: CABRule.optional(),
681
+ sectionId: z17.uuid().default(() => uuidv712()),
682
+ sectionType: z17.literal(SectionType.variants).default(SectionType.variants),
683
+ selector: z17.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
684
+ variantMode: z17.enum(variantModes).default(VariantMode.multiple)
669
685
  });
670
686
 
671
687
  // src/schema/widgets/checkout-and-beyond/shared.ts
672
- var CABBorder = z17.object({
673
- radius: z17.enum(borderRadii).default(BorderRadius.base),
674
- style: z17.enum(borderStyles).default(BorderStyle.none),
675
- width: z17.enum(borderWidths).default(BorderWidth.base)
688
+ var CABBorder = z18.object({
689
+ radius: z18.enum(borderRadii).default(BorderRadius.base),
690
+ style: z18.enum(borderStyles).default(BorderStyle.none),
691
+ width: z18.enum(borderWidths).default(BorderWidth.base)
676
692
  }).default({
677
693
  radius: BorderRadius.base,
678
694
  style: BorderStyle.none,
679
695
  width: BorderWidth.base
680
696
  });
681
- var CABSection = z17.lazy(
682
- () => z17.discriminatedUnion("sectionType", [
697
+ var CABSection = z18.lazy(
698
+ () => z18.discriminatedUnion("sectionType", [
683
699
  CABBannerSection,
684
700
  CABButtonSection,
685
701
  CABCarouselSection,
686
702
  CABCartLineSection,
687
703
  CABDataSourceSection,
704
+ CABDiscountSection,
688
705
  CABImageSection,
689
706
  CABLayoutSection,
690
707
  CABMonetizeSection,
@@ -700,25 +717,25 @@ var CABSection = z17.lazy(
700
717
  );
701
718
 
702
719
  // src/schema/widgets/checkout-and-beyond/image.ts
703
- var CABImageSection = z18.object({
704
- altText: z18.string().refine(checkForHTML, NO_HTML).default(""),
705
- aspectRatio: z18.literal(1).nullable().default(null),
706
- border: z18.lazy(() => CABBorder),
707
- buttonField: z18.enum(buttonFields).optional(),
708
- category: z18.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
709
- name: z18.string().optional(),
710
- naturalHeight: z18.number().default(0),
711
- naturalWidth: z18.number().default(0),
720
+ var CABImageSection = z19.object({
721
+ altText: z19.string().refine(checkForHTML, NO_HTML).default(""),
722
+ aspectRatio: z19.literal(1).nullable().default(null),
723
+ border: z19.lazy(() => CABBorder),
724
+ buttonField: z19.enum(buttonFields).optional(),
725
+ category: z19.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
726
+ name: z19.string().optional(),
727
+ naturalHeight: z19.number().default(0),
728
+ naturalWidth: z19.number().default(0),
712
729
  /**
713
730
  * `contain` (the component default): dimensionless images render in s-image's 1/1 default frame, and
714
731
  * `cover` would crop non-square art (payment badges lost their edges — 15993); `contain` letterboxes.
715
732
  */
716
- objectFit: z18.enum(objectFits).default(ObjectFit.contain),
733
+ objectFit: z19.enum(objectFits).default(ObjectFit.contain),
717
734
  rule: CABRule.optional(),
718
- sectionId: z18.uuid().default(() => uuidv712()),
719
- sectionType: z18.literal(SectionType.image).default(SectionType.image),
720
- source: z18.union([z18.url(), z18.literal(""), z18.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
721
- width: z18.number().default(100)
735
+ sectionId: z19.uuid().default(() => uuidv713()),
736
+ sectionType: z19.literal(SectionType.image).default(SectionType.image),
737
+ source: z19.union([z19.url(), z19.literal(""), z19.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
738
+ width: z19.number().default(100)
722
739
  });
723
740
 
724
741
  // src/transforms/contentBlockV1/stripContentBlockHtml.ts
@@ -837,28 +854,28 @@ var convertContentBlockTextToV2 = (language) => {
837
854
  };
838
855
 
839
856
  // src/schema/widgets/checkout-and-beyond/root.ts
840
- import { z as z19 } from "zod/v4";
841
- var TargetArea = z19.object({
842
- fill: z19.boolean().optional(),
843
- flip: z19.enum(["both", "horizontal", "vertical"]).optional(),
844
- icon: z19.string(),
845
- label: z19.string(),
846
- width: z19.string()
857
+ import { z as z20 } from "zod/v4";
858
+ var TargetArea = z20.object({
859
+ fill: z20.boolean().optional(),
860
+ flip: z20.enum(["both", "horizontal", "vertical"]).optional(),
861
+ icon: z20.string(),
862
+ label: z20.string(),
863
+ width: z20.string()
847
864
  }).default(targetAreas[EditorMode.checkoutExtension][1]);
848
- var CABTracking = z19.object({
849
- enableAttribution: z19.boolean().default(true),
850
- enableSource: z19.boolean().default(true),
851
- enableWidget: z19.boolean().default(true)
865
+ var CABTracking = z20.object({
866
+ enableAttribution: z20.boolean().default(true),
867
+ enableSource: z20.boolean().default(true),
868
+ enableWidget: z20.boolean().default(true)
852
869
  }).default({ enableAttribution: true, enableSource: true, enableWidget: true });
853
870
  var CABRootSection = CABLayoutSection.extend({
854
- editorMode: z19.enum(editorModes).default(EditorMode.checkoutExtension),
855
- previewMode: z19.boolean().default(false),
856
- storeId: z19.number().nullable().default(null),
871
+ editorMode: z20.enum(editorModes).default(EditorMode.checkoutExtension),
872
+ previewMode: z20.boolean().default(false),
873
+ storeId: z20.number().nullable().default(null),
857
874
  targetArea: TargetArea.nullable(),
858
875
  tracking: CABTracking,
859
- type: z19.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
860
- version: z19.literal(2).default(2),
861
- widgetId: z19.number().nullable().default(null)
876
+ type: z20.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
877
+ version: z20.literal(2).default(2),
878
+ widgetId: z20.number().nullable().default(null)
862
879
  });
863
880
 
864
881
  // src/transforms/contentBlockV1/convertContentBlockToV2.ts
@@ -1409,22 +1426,928 @@ var normalizeTextContent = (node) => {
1409
1426
  return node;
1410
1427
  };
1411
1428
 
1429
+ // src/transforms/offerV1/offerTemplateSeed.ts
1430
+ var OFFER_TEMPLATE_SEED = {
1431
+ alignment: {
1432
+ horizontal: "center",
1433
+ vertical: "top"
1434
+ },
1435
+ border: {
1436
+ radius: "base",
1437
+ style: "none",
1438
+ width: "thick"
1439
+ },
1440
+ direction: "rows",
1441
+ editorMode: "checkoutExtension",
1442
+ grid: {
1443
+ columns: ["auto"],
1444
+ rows: ["auto"]
1445
+ },
1446
+ padding: "tight",
1447
+ previewMode: false,
1448
+ sections: [
1449
+ {
1450
+ alignment: {
1451
+ horizontal: "end",
1452
+ vertical: "top"
1453
+ },
1454
+ autoAdvanceInterval: 0,
1455
+ border: {
1456
+ radius: "base",
1457
+ style: "none",
1458
+ width: "base"
1459
+ },
1460
+ direction: "rows",
1461
+ grid: {
1462
+ columns: ["auto"],
1463
+ rows: ["auto", "auto"]
1464
+ },
1465
+ itemsAtOnce: 2,
1466
+ padding: "none",
1467
+ sections: [
1468
+ {
1469
+ alignment: {
1470
+ horizontal: "start",
1471
+ vertical: "middle"
1472
+ },
1473
+ border: {
1474
+ radius: "base",
1475
+ style: "none",
1476
+ width: "base"
1477
+ },
1478
+ direction: "columns",
1479
+ grid: {
1480
+ columns: ["auto", "auto"],
1481
+ rows: ["auto"]
1482
+ },
1483
+ name: "pagination",
1484
+ padding: "none",
1485
+ sections: [
1486
+ {
1487
+ action: "goToPrevPage",
1488
+ buttonStyle: "plain",
1489
+ disableDowngrade: false,
1490
+ popover: {
1491
+ alignment: "center",
1492
+ position: "blockStart"
1493
+ },
1494
+ sections: [
1495
+ {
1496
+ buttonField: "buttonLabel",
1497
+ content: {
1498
+ ar: "\u2039",
1499
+ cs: "\u2039",
1500
+ da: "\u2039",
1501
+ de: "\u2039",
1502
+ en: "\u2039",
1503
+ es: "\u2039",
1504
+ fi: "\u2039",
1505
+ fr: "\u2039",
1506
+ ga: "\u2039",
1507
+ he: "\u2039",
1508
+ hi: "\u2039",
1509
+ id: "\u2039",
1510
+ it: "\u2039",
1511
+ ja: "\u2039",
1512
+ ko: "\u2039",
1513
+ nl: "\u2039",
1514
+ no: "\u2039",
1515
+ pl: "\u2039",
1516
+ pt: "\u2039",
1517
+ ru: "\u2039",
1518
+ sv: "\u2039",
1519
+ th: "\u2039",
1520
+ tr: "\u2039",
1521
+ uk: "\u2039",
1522
+ vi: "\u2039",
1523
+ zh: "\u2039"
1524
+ },
1525
+ sectionType: "text"
1526
+ }
1527
+ ],
1528
+ sectionType: "button"
1529
+ },
1530
+ {
1531
+ action: "goToNextPage",
1532
+ buttonStyle: "plain",
1533
+ disableDowngrade: false,
1534
+ popover: {
1535
+ alignment: "center",
1536
+ position: "blockStart"
1537
+ },
1538
+ sections: [
1539
+ {
1540
+ buttonField: "buttonLabel",
1541
+ content: {
1542
+ ar: "\u203A",
1543
+ cs: "\u203A",
1544
+ da: "\u203A",
1545
+ de: "\u203A",
1546
+ en: "\u203A",
1547
+ es: "\u203A",
1548
+ fi: "\u203A",
1549
+ fr: "\u203A",
1550
+ ga: "\u203A",
1551
+ he: "\u203A",
1552
+ hi: "\u203A",
1553
+ id: "\u203A",
1554
+ it: "\u203A",
1555
+ ja: "\u203A",
1556
+ ko: "\u203A",
1557
+ nl: "\u203A",
1558
+ no: "\u203A",
1559
+ pl: "\u203A",
1560
+ pt: "\u203A",
1561
+ ru: "\u203A",
1562
+ sv: "\u203A",
1563
+ th: "\u203A",
1564
+ tr: "\u203A",
1565
+ uk: "\u203A",
1566
+ vi: "\u203A",
1567
+ zh: "\u203A"
1568
+ },
1569
+ sectionType: "text"
1570
+ }
1571
+ ],
1572
+ sectionType: "button"
1573
+ }
1574
+ ],
1575
+ sectionType: "layout",
1576
+ spacing: "base",
1577
+ width: 100
1578
+ },
1579
+ {
1580
+ alignment: {
1581
+ horizontal: "start",
1582
+ vertical: "middle"
1583
+ },
1584
+ border: {
1585
+ radius: "base",
1586
+ style: "base",
1587
+ width: "base"
1588
+ },
1589
+ direction: "rows",
1590
+ grid: {
1591
+ columns: ["15%"],
1592
+ rows: ["auto", "auto"]
1593
+ },
1594
+ padding: "base",
1595
+ sections: [
1596
+ {
1597
+ alignment: {
1598
+ horizontal: "start",
1599
+ vertical: "middle"
1600
+ },
1601
+ border: {
1602
+ radius: "base",
1603
+ style: "none",
1604
+ width: "base"
1605
+ },
1606
+ direction: "grid",
1607
+ grid: {
1608
+ columns: ["15%", "fill", "auto"],
1609
+ rows: ["auto"]
1610
+ },
1611
+ padding: "none",
1612
+ sections: [
1613
+ {
1614
+ altText: "",
1615
+ aspectRatio: null,
1616
+ border: {
1617
+ radius: "base",
1618
+ style: "none",
1619
+ width: "base"
1620
+ },
1621
+ category: null,
1622
+ name: "Product Image",
1623
+ naturalHeight: 0,
1624
+ naturalWidth: 0,
1625
+ objectFit: "cover",
1626
+ sectionType: "image",
1627
+ source: "{{productImage}}",
1628
+ width: 100
1629
+ },
1630
+ {
1631
+ content: {
1632
+ en: {
1633
+ attrs: {
1634
+ blockSpacing: "none"
1635
+ },
1636
+ content: [
1637
+ {
1638
+ attrs: {
1639
+ textAlign: "start"
1640
+ },
1641
+ content: [
1642
+ {
1643
+ marks: [
1644
+ {
1645
+ attrs: {
1646
+ color: "base",
1647
+ fontSize: "medium"
1648
+ },
1649
+ type: "textStyle"
1650
+ },
1651
+ {
1652
+ type: "bold"
1653
+ }
1654
+ ],
1655
+ text: "{{productAndVariantTitle}}",
1656
+ type: "text"
1657
+ }
1658
+ ],
1659
+ type: "paragraph"
1660
+ },
1661
+ {
1662
+ attrs: {
1663
+ textAlign: "start"
1664
+ },
1665
+ content: [
1666
+ {
1667
+ marks: [
1668
+ {
1669
+ attrs: {
1670
+ color: "accent",
1671
+ fontSize: "medium"
1672
+ },
1673
+ type: "textStyle"
1674
+ }
1675
+ ],
1676
+ text: "{{variantPrice}}",
1677
+ type: "text"
1678
+ }
1679
+ ],
1680
+ type: "paragraph"
1681
+ }
1682
+ ],
1683
+ type: "doc"
1684
+ }
1685
+ },
1686
+ name: "Product Info",
1687
+ sectionType: "text"
1688
+ },
1689
+ {
1690
+ action: "addToOrder",
1691
+ buttonStyle: "primary",
1692
+ disableDowngrade: false,
1693
+ popover: {
1694
+ alignment: "center",
1695
+ position: "blockStart"
1696
+ },
1697
+ sections: [
1698
+ {
1699
+ buttonField: "addingToCart",
1700
+ content: {
1701
+ ar: "\u064A\u062A\u0645 \u0627\u0644\u0625\u0636\u0627\u0641\u0629 \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629",
1702
+ cs: "P\u0159id\xE1v\xE1m do ko\u0161\xEDku",
1703
+ da: "Tilf\xF8jer til kurv",
1704
+ de: "Wird zum Warenkorb hinzugef\xFCgt",
1705
+ en: "Adding...",
1706
+ es: "Agregando al carrito",
1707
+ fi: "Lis\xE4t\xE4\xE4n ostoskoriin",
1708
+ fr: "Ajout au panier",
1709
+ ga: "\xC1 Chur le Cairt",
1710
+ he: "\u05DE\u05D5\u05E1\u05D9\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4",
1711
+ hi: "\u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C \u0930\u0939\u0947 \u0939\u0948\u0902",
1712
+ id: "Menambahkan ke Keranjang",
1713
+ it: "Aggiungendo al carrello",
1714
+ ja: "\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0\u4E2D",
1715
+ ko: "\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00 \uC911",
1716
+ nl: "Toevoegen aan winkelwagen",
1717
+ no: "Legger i handlekurv",
1718
+ pl: "Dodaj\u0119 do koszyka",
1719
+ pt: "Adicionando ao carrinho",
1720
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443",
1721
+ sv: "L\xE4gger till i varukorg",
1722
+ th: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E25\u0E07\u0E43\u0E19\u0E23\u0E16\u0E40\u0E02\u0E47\u0E19",
1723
+ tr: "Sepete Ekleniyor",
1724
+ uk: "\u0414\u043E\u0434\u0430\u0454\u043C\u043E \u0434\u043E \u043A\u043E\u0448\u0438\u043A\u0430",
1725
+ vi: "\u0110ang th\xEAm v\xE0o gi\u1ECF h\xE0ng",
1726
+ zh: "\u6B63\u5728\u52A0\u5165\u8D2D\u7269\u8F66"
1727
+ },
1728
+ sectionType: "text"
1729
+ },
1730
+ {
1731
+ buttonField: "addToCart",
1732
+ content: {
1733
+ ar: "\u0623\u0636\u0641 \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629",
1734
+ cs: "P\u0159idat do ko\u0161\xEDku",
1735
+ da: "F\xF8j til kurv",
1736
+ de: "In den Warenkorb",
1737
+ en: "Add",
1738
+ es: "Agregar al carrito",
1739
+ fi: "Lis\xE4\xE4 ostoskoriin",
1740
+ fr: "Ajouter au panier",
1741
+ ga: "Cuir le Cairt",
1742
+ he: "\u05D4\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4",
1743
+ hi: "\u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u0947\u0902",
1744
+ id: "Tambah ke Keranjang",
1745
+ it: "Aggiungi al carrello",
1746
+ ja: "\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",
1747
+ ko: "\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00",
1748
+ nl: "Toevoegen aan winkelwagen",
1749
+ no: "Legg i handlekurv",
1750
+ pl: "Dodaj do koszyka",
1751
+ pt: "Adicionar ao carrinho",
1752
+ ru: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443",
1753
+ sv: "L\xE4gg i varukorg",
1754
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E25\u0E07\u0E43\u0E19\u0E23\u0E16\u0E40\u0E02\u0E47\u0E19",
1755
+ tr: "Sepete Ekle",
1756
+ uk: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0434\u043E \u043A\u043E\u0448\u0438\u043A\u0430",
1757
+ vi: "Th\xEAm v\xE0o gi\u1ECF h\xE0ng",
1758
+ zh: "\u52A0\u5165\u8D2D\u7269\u8F66"
1759
+ },
1760
+ sectionType: "text"
1761
+ }
1762
+ ],
1763
+ sectionType: "button"
1764
+ }
1765
+ ],
1766
+ sectionType: "layout",
1767
+ spacing: "base",
1768
+ width: 100
1769
+ },
1770
+ {
1771
+ alignment: {
1772
+ horizontal: "start",
1773
+ vertical: "top"
1774
+ },
1775
+ border: {
1776
+ radius: "base",
1777
+ style: "none",
1778
+ width: "base"
1779
+ },
1780
+ direction: "rows",
1781
+ grid: {
1782
+ columns: ["auto"],
1783
+ rows: ["auto"]
1784
+ },
1785
+ padding: "none",
1786
+ sections: [
1787
+ {
1788
+ errorMessages: {
1789
+ en: {
1790
+ max: "Maximum quantity allowed is {{max}}",
1791
+ min: "Minimum quantity required is {{min}}",
1792
+ neg: "Quantity cannot be negative"
1793
+ }
1794
+ },
1795
+ inputType: "select",
1796
+ max: 10,
1797
+ min: 1,
1798
+ sectionType: "quantity"
1799
+ }
1800
+ ],
1801
+ sectionType: "layout",
1802
+ spacing: "base",
1803
+ width: 100
1804
+ },
1805
+ {
1806
+ limit: 3,
1807
+ sectionType: "dataSource"
1808
+ },
1809
+ {
1810
+ sectionType: "products"
1811
+ }
1812
+ ],
1813
+ sectionType: "offers",
1814
+ spacing: "base",
1815
+ width: 100
1816
+ }
1817
+ ],
1818
+ sectionType: "carousel",
1819
+ spacing: "base",
1820
+ width: 100
1821
+ }
1822
+ ],
1823
+ sectionType: "layout",
1824
+ spacing: "base",
1825
+ targetArea: {
1826
+ icon: "splitscreen_left",
1827
+ label: "Main Column",
1828
+ width: "503px"
1829
+ },
1830
+ type: "shopify_checkout_extension",
1831
+ version: 2,
1832
+ width: 100
1833
+ };
1834
+
1835
+ // src/transforms/offerV1/types.ts
1836
+ var SHOPIFY_CHECKOUT_EXTENSION = "shopify_checkout_extension";
1837
+ var isOfferV1 = (data) => {
1838
+ if (!data || typeof data !== "object") return false;
1839
+ return data.type === SHOPIFY_CHECKOUT_EXTENSION;
1840
+ };
1841
+
1842
+ // src/transforms/offerV1/buildOfferTemplate.ts
1843
+ var LOCATION_TO_EDITOR_MODE2 = {
1844
+ checkout: "checkoutExtension",
1845
+ "order-status": "orderStatusPage",
1846
+ "thank-you": "thankYouPage"
1847
+ };
1848
+ var buildOfferTemplate = ({ location, name } = {}) => CABRootSection.parse({
1849
+ ...OFFER_TEMPLATE_SEED,
1850
+ editorMode: LOCATION_TO_EDITOR_MODE2[location ?? "checkout"],
1851
+ ...name && { name },
1852
+ previewMode: false,
1853
+ type: SHOPIFY_CHECKOUT_EXTENSION
1854
+ });
1855
+
1856
+ // src/schema/widgets/checkout-and-beyond/offerLabels.ts
1857
+ var OFFER_LABELS = {
1858
+ addToCart: {
1859
+ ar: "\u0623\u0636\u0641 \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629",
1860
+ cs: "P\u0159idat do ko\u0161\xEDku",
1861
+ da: "L\xE6g i kurv",
1862
+ de: "In den Warenkorb",
1863
+ en: "Add to cart",
1864
+ es: "A\xF1adir al carrito",
1865
+ fi: "Lis\xE4\xE4 ostoskoriin",
1866
+ fr: "Ajouter au panier",
1867
+ ga: "Cuir sa chairt",
1868
+ he: "\u05D4\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4",
1869
+ hi: "\u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u0947\u0902",
1870
+ id: "Tambahkan ke keranjang",
1871
+ it: "Aggiungi al carrello",
1872
+ ja: "\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",
1873
+ ko: "\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00",
1874
+ nl: "In winkelwagen",
1875
+ no: "Legg i handlekurven",
1876
+ pl: "Dodaj do koszyka",
1877
+ pt: "Adicionar ao carrinho",
1878
+ ru: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443",
1879
+ sv: "L\xE4gg i varukorgen",
1880
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32",
1881
+ tr: "Sepete ekle",
1882
+ uk: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0432 \u043A\u043E\u0448\u0438\u043A",
1883
+ vi: "Th\xEAm v\xE0o gi\u1ECF h\xE0ng",
1884
+ zh: "\u52A0\u5165\u8D2D\u7269\u8F66"
1885
+ },
1886
+ addedToCart: {
1887
+ ar: "\u062A\u0645\u062A \u0627\u0644\u0625\u0636\u0627\u0641\u0629!",
1888
+ cs: "P\u0159id\xE1no!",
1889
+ da: "Tilf\xF8jet!",
1890
+ de: "Hinzugef\xFCgt!",
1891
+ en: "Added!",
1892
+ es: "\xA1A\xF1adido!",
1893
+ fi: "Lis\xE4tty!",
1894
+ fr: "Ajout\xE9 !",
1895
+ ga: "Curtha leis!",
1896
+ he: "\u05E0\u05D5\u05E1\u05E3!",
1897
+ hi: "\u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E!",
1898
+ id: "Ditambahkan!",
1899
+ it: "Aggiunto!",
1900
+ ja: "\u8FFD\u52A0\u3057\u307E\u3057\u305F\uFF01",
1901
+ ko: "\uCD94\uAC00\uB428!",
1902
+ nl: "Toegevoegd!",
1903
+ no: "Lagt til!",
1904
+ pl: "Dodano!",
1905
+ pt: "Adicionado!",
1906
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E!",
1907
+ sv: "Tillagd!",
1908
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E41\u0E25\u0E49\u0E27!",
1909
+ tr: "Eklendi!",
1910
+ uk: "\u0414\u043E\u0434\u0430\u043D\u043E!",
1911
+ vi: "\u0110\xE3 th\xEAm!",
1912
+ zh: "\u5DF2\u6DFB\u52A0\uFF01"
1913
+ },
1914
+ addedToCartMessage: {
1915
+ ar: "\u062A\u0645\u062A \u0625\u0636\u0627\u0641\u0629 {{quantity}} {{productTitle}} \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629.",
1916
+ cs: "{{quantity}} {{productTitle}} p\u0159id\xE1no do ko\u0161\xEDku.",
1917
+ da: "{{quantity}} {{productTitle}} lagt i kurven.",
1918
+ de: "{{quantity}} {{productTitle}} zum Warenkorb hinzugef\xFCgt.",
1919
+ en: "{{quantity}} {{productTitle}} added to cart.",
1920
+ es: "{{quantity}} {{productTitle}} a\xF1adido al carrito.",
1921
+ fi: "{{quantity}} {{productTitle}} lis\xE4tty ostoskoriin.",
1922
+ fr: "{{quantity}} {{productTitle}} ajout\xE9 au panier.",
1923
+ ga: "Cuireadh {{quantity}} {{productTitle}} sa chairt.",
1924
+ he: "{{quantity}} {{productTitle}} \u05E0\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4.",
1925
+ hi: "{{quantity}} {{productTitle}} \u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E\u0964",
1926
+ id: "{{quantity}} {{productTitle}} ditambahkan ke keranjang.",
1927
+ it: "{{quantity}} {{productTitle}} aggiunto al carrello.",
1928
+ ja: "{{quantity}} {{productTitle}}\u3092\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0\u3057\u307E\u3057\u305F\u3002",
1929
+ ko: "{{quantity}} {{productTitle}}\uC774(\uAC00) \uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",
1930
+ nl: "{{quantity}} {{productTitle}} toegevoegd aan winkelwagen.",
1931
+ no: "{{quantity}} {{productTitle}} lagt i handlekurven.",
1932
+ pl: "{{quantity}} {{productTitle}} dodano do koszyka.",
1933
+ pt: "{{quantity}} {{productTitle}} adicionado ao carrinho.",
1934
+ ru: "{{quantity}} {{productTitle}} \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443.",
1935
+ sv: "{{quantity}} {{productTitle}} har lagts i varukorgen.",
1936
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21 {{quantity}} {{productTitle}} \u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32\u0E41\u0E25\u0E49\u0E27",
1937
+ tr: "{{quantity}} {{productTitle}} sepete eklendi.",
1938
+ uk: "{{quantity}} {{productTitle}} \u0434\u043E\u0434\u0430\u043D\u043E \u0434\u043E \u043A\u043E\u0448\u0438\u043A\u0430.",
1939
+ vi: "\u0110\xE3 th\xEAm {{quantity}} {{productTitle}} v\xE0o gi\u1ECF h\xE0ng.",
1940
+ zh: "{{quantity}} {{productTitle}} \u5DF2\u52A0\u5165\u8D2D\u7269\u8F66\u3002"
1941
+ },
1942
+ addingToCart: {
1943
+ ar: "\u062C\u0627\u0631\u064D \u0627\u0644\u0625\u0636\u0627\u0641\u0629...",
1944
+ cs: "P\u0159id\xE1v\xE1n\xED...",
1945
+ da: "Tilf\xF8jer...",
1946
+ de: "Wird hinzugef\xFCgt...",
1947
+ en: "Adding...",
1948
+ es: "A\xF1adiendo...",
1949
+ fi: "Lis\xE4t\xE4\xE4n...",
1950
+ fr: "Ajout en cours...",
1951
+ ga: "\xC1 chur leis...",
1952
+ he: "\u05DE\u05D5\u05E1\u05D9\u05E3...",
1953
+ hi: "\u091C\u094B\u0921\u093C\u093E \u091C\u093E \u0930\u0939\u093E \u0939\u0948...",
1954
+ id: "Menambahkan...",
1955
+ it: "Aggiunta in corso...",
1956
+ ja: "\u8FFD\u52A0\u4E2D...",
1957
+ ko: "\uCD94\uAC00 \uC911...",
1958
+ nl: "Toevoegen...",
1959
+ no: "Legger til...",
1960
+ pl: "Dodawanie...",
1961
+ pt: "Adicionando...",
1962
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435...",
1963
+ sv: "L\xE4gger till...",
1964
+ th: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E1E\u0E34\u0E48\u0E21...",
1965
+ tr: "Ekleniyor...",
1966
+ uk: "\u0414\u043E\u0434\u0430\u0432\u0430\u043D\u043D\u044F...",
1967
+ vi: "\u0110ang th\xEAm...",
1968
+ zh: "\u6B63\u5728\u6DFB\u52A0..."
1969
+ },
1970
+ soldOut: {
1971
+ ar: "\u0646\u0641\u062F\u062A \u0627\u0644\u0643\u0645\u064A\u0629",
1972
+ cs: "Vyprod\xE1no",
1973
+ da: "Udsolgt",
1974
+ de: "Ausverkauft",
1975
+ en: "Sold out",
1976
+ es: "Agotado",
1977
+ fi: "Loppuunmyyty",
1978
+ fr: "\xC9puis\xE9",
1979
+ ga: "D\xEDolta amach",
1980
+ he: "\u05D0\u05D6\u05DC \u05DE\u05D4\u05DE\u05DC\u05D0\u05D9",
1981
+ hi: "\u0938\u094D\u091F\u0949\u0915 \u0916\u093C\u0924\u094D\u092E",
1982
+ id: "Habis terjual",
1983
+ it: "Esaurito",
1984
+ ja: "\u58F2\u308A\u5207\u308C",
1985
+ ko: "\uD488\uC808",
1986
+ nl: "Uitverkocht",
1987
+ no: "Utsolgt",
1988
+ pl: "Wyprzedane",
1989
+ pt: "Esgotado",
1990
+ ru: "\u0420\u0430\u0441\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
1991
+ sv: "Sluts\xE5ld",
1992
+ th: "\u0E2A\u0E34\u0E19\u0E04\u0E49\u0E32\u0E2B\u0E21\u0E14",
1993
+ tr: "T\xFCkendi",
1994
+ uk: "\u0420\u043E\u0437\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
1995
+ vi: "H\u1EBFt h\xE0ng",
1996
+ zh: "\u5DF2\u552E\u7F44"
1997
+ },
1998
+ undo: {
1999
+ ar: "\u062A\u0631\u0627\u062C\u0639",
2000
+ cs: "Zp\u011Bt",
2001
+ da: "Fortryd",
2002
+ de: "R\xFCckg\xE4ngig",
2003
+ en: "Undo",
2004
+ es: "Deshacer",
2005
+ fi: "Kumoa",
2006
+ fr: "Annuler",
2007
+ ga: "Cealaigh",
2008
+ he: "\u05D1\u05D8\u05DC",
2009
+ hi: "\u092A\u0942\u0930\u094D\u0935\u0935\u0924 \u0915\u0930\u0947\u0902",
2010
+ id: "Urungkan",
2011
+ it: "Annulla",
2012
+ ja: "\u5143\u306B\u623B\u3059",
2013
+ ko: "\uC2E4\uD589 \uCDE8\uC18C",
2014
+ nl: "Ongedaan maken",
2015
+ no: "Angre",
2016
+ pl: "Cofnij",
2017
+ pt: "Desfazer",
2018
+ ru: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",
2019
+ sv: "\xC5ngra",
2020
+ th: "\u0E40\u0E25\u0E34\u0E01\u0E17\u0E33",
2021
+ tr: "Geri al",
2022
+ uk: "\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438",
2023
+ vi: "Ho\xE0n t\xE1c",
2024
+ zh: "\u64A4\u9500"
2025
+ }
2026
+ };
2027
+
2028
+ // src/transforms/offerV1/offerCard.ts
2029
+ var VARIANT_SELECTOR = { button: "button", radio: "radio", select: "menu" };
2030
+ var localizedContent = (defaults, override) => {
2031
+ const trimmed = override?.trim();
2032
+ return trimmed ? { ...defaults, en: trimmed } : defaults;
2033
+ };
2034
+ var buildStyledText = (token, style, color = "base") => {
2035
+ const marks = [
2036
+ { attrs: { color, fontSize: style?.textSize ?? "base" }, type: "textStyle" }
2037
+ ];
2038
+ if (style?.textEmphasis === "bold") marks.push({ type: "bold" });
2039
+ if (style?.textEmphasis === "italic") marks.push({ type: "italic" });
2040
+ return { content: [{ content: [{ marks, text: token, type: "text" }], type: "paragraph" }], type: "doc" };
2041
+ };
2042
+ var buildPriceContent = (settings) => {
2043
+ const content = [{ text: "{{variantPrice}}", type: "text" }];
2044
+ if (settings.discount?.showSavingAmount !== false) {
2045
+ content.push(
2046
+ { text: " ", type: "text" },
2047
+ {
2048
+ marks: [{ type: "strike" }, { attrs: { color: "subdued" }, type: "textStyle" }],
2049
+ text: "{{variantCompareAtPrice}}",
2050
+ type: "text"
2051
+ }
2052
+ );
2053
+ }
2054
+ return { content: [{ content, type: "paragraph" }], type: "doc" };
2055
+ };
2056
+ var buildReviews = (settings) => {
2057
+ if (!settings.integrations || !Object.values(settings.integrations).some(Boolean)) return [];
2058
+ const reviews = settings.displaySettings?.reviews;
2059
+ return [
2060
+ {
2061
+ ...reviews?.color && { color: reviews.color },
2062
+ sectionType: "reviews",
2063
+ ...reviews?.size && { size: reviews.size }
2064
+ }
2065
+ ];
2066
+ };
2067
+ var buildImage = (settings) => ({
2068
+ ...settings.displaySettings?.image?.imageFit && {
2069
+ objectFit: settings.displaySettings.image.imageFit
2070
+ },
2071
+ sectionType: "image",
2072
+ source: settings.images?.source === "product" ? "{{productImage}}" : "{{variantImage}}",
2073
+ width: 100
2074
+ });
2075
+ var buildTitle = (settings) => ({
2076
+ content: { en: buildStyledText("{{productTitle}}", settings.displaySettings?.product) },
2077
+ sectionType: "text"
2078
+ });
2079
+ var buildPrice = (settings) => ({
2080
+ content: { en: buildPriceContent(settings) },
2081
+ sectionType: "text"
2082
+ });
2083
+ var buildVariantTitle = (settings) => {
2084
+ const show = settings.productOptions?.showVariantTitle;
2085
+ if (!show || show === "hide") return [];
2086
+ return [
2087
+ {
2088
+ content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
2089
+ sectionType: "text"
2090
+ }
2091
+ ];
2092
+ };
2093
+ var buildDescription = (settings) => {
2094
+ const show = settings.productOptions?.showProductDescription;
2095
+ if (!show || show === "hide") return [];
2096
+ return [{ content: { en: buildStyledText("{{productDescription}}", void 0) }, sectionType: "text" }];
2097
+ };
2098
+ var buildVariants = (settings) => {
2099
+ if (settings.productOptions?.showVariantOptions === "never") return [];
2100
+ const selector = settings.viewOptions?.variantSelector;
2101
+ return [
2102
+ {
2103
+ hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
2104
+ ...selector && { selector: VARIANT_SELECTOR[selector] },
2105
+ sectionType: "variants"
2106
+ }
2107
+ ];
2108
+ };
2109
+ var QUANTITY_INPUT_TYPE = {
2110
+ "buttons-manual-input": "number",
2111
+ "dropdown-select": "select"
2112
+ };
2113
+ var buildQuantityErrors = (quantity) => {
2114
+ const en = {
2115
+ ...quantity.maxError && { max: quantity.maxError },
2116
+ ...quantity.minError && { min: quantity.minError },
2117
+ ...quantity.negativeError && { neg: quantity.negativeError }
2118
+ };
2119
+ return Object.keys(en).length ? { errorMessages: { en } } : {};
2120
+ };
2121
+ var buildQuantity = (settings) => {
2122
+ const quantity = settings.quantityInputs;
2123
+ if (!quantity?.enabled) return [];
2124
+ const inputType = quantity.type ? QUANTITY_INPUT_TYPE[quantity.type] : void 0;
2125
+ return [
2126
+ {
2127
+ ...buildQuantityErrors(quantity),
2128
+ ...inputType && { inputType },
2129
+ max: quantity.maxValue ?? 10,
2130
+ min: quantity.minValue ?? 1,
2131
+ sectionType: "quantity"
2132
+ }
2133
+ ];
2134
+ };
2135
+ var buildSubscriptionButton = (settings) => {
2136
+ if (settings.productType !== "both" && settings.productType !== "subscription") return [];
2137
+ const language = settings.language;
2138
+ const slot = (buttonField, override) => ({
2139
+ buttonField,
2140
+ content: localizedContent(SWITCH_LABELS[buttonField], override),
2141
+ sectionType: "text"
2142
+ });
2143
+ return [
2144
+ {
2145
+ action: "switchToSubscription",
2146
+ buttonStyle: "plain",
2147
+ sections: [
2148
+ slot("subscriptionOption", void 0),
2149
+ slot("switchToOneTimePurchase", language?.cartSwitchToOnetime),
2150
+ slot("switchToSubscriptionNoDiscount", language?.cartSwitchToSubscription),
2151
+ slot("switchToSubscriptionWithDiscount", language?.upgradeToSubscription)
2152
+ ],
2153
+ sectionType: "button"
2154
+ }
2155
+ ];
2156
+ };
2157
+ var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
2158
+ var buildAddButton = (settings) => {
2159
+ const kind = settings.button?.kind;
2160
+ const slot = (buttonField, override) => ({
2161
+ buttonField,
2162
+ content: localizedContent(OFFER_LABELS[buttonField], override),
2163
+ sectionType: "text"
2164
+ });
2165
+ return {
2166
+ action: "addToOrder",
2167
+ buttonStyle: BUTTON_KINDS2.includes(kind) ? kind : "primary",
2168
+ sections: [
2169
+ slot("addToCart", settings.language?.addToCart),
2170
+ slot("addingToCart", settings.language?.addingToCart),
2171
+ slot("addedToCart", settings.language?.addedToCart),
2172
+ slot("soldOut", settings.language?.soldOutLabel)
2173
+ ],
2174
+ sectionType: "button"
2175
+ };
2176
+ };
2177
+ var rowsLayout = (sections) => ({
2178
+ direction: "rows",
2179
+ sections,
2180
+ sectionType: "layout"
2181
+ });
2182
+ var buildOfferCard = (settings, horizontal) => {
2183
+ const image = buildImage(settings);
2184
+ const title = buildTitle(settings);
2185
+ const variantTitle = buildVariantTitle(settings);
2186
+ const price = buildPrice(settings);
2187
+ const description = buildDescription(settings);
2188
+ const reviews = buildReviews(settings);
2189
+ const variants = buildVariants(settings);
2190
+ const quantity = buildQuantity(settings);
2191
+ const subscription = buildSubscriptionButton(settings);
2192
+ const addButton = buildAddButton(settings);
2193
+ if (!horizontal) {
2194
+ return [
2195
+ image,
2196
+ title,
2197
+ ...variantTitle,
2198
+ price,
2199
+ ...description,
2200
+ ...reviews,
2201
+ ...variants,
2202
+ ...quantity,
2203
+ ...subscription,
2204
+ addButton
2205
+ ];
2206
+ }
2207
+ const info = rowsLayout([title, ...variantTitle, price, ...description, ...reviews, ...variants]);
2208
+ const actions = [...subscription, addButton];
2209
+ const actionsCell = actions.length === 1 ? actions[0] : rowsLayout(actions);
2210
+ const card = {
2211
+ direction: "grid",
2212
+ grid: { columns: ["15%", "fill", "auto"], rows: ["auto"] },
2213
+ sections: [image, info, actionsCell],
2214
+ sectionType: "layout"
2215
+ };
2216
+ return [card, ...quantity];
2217
+ };
2218
+
2219
+ // src/transforms/offerV1/convertOfferToV2.ts
2220
+ var LOCATION_TO_EDITOR_MODE3 = {
2221
+ checkout: "checkoutExtension",
2222
+ "order-status": "orderStatusPage",
2223
+ "thank-you": "thankYouPage"
2224
+ };
2225
+ var STYLE_TO_DIRECTION = {
2226
+ grid: "grid",
2227
+ line: "columns",
2228
+ list: "rows",
2229
+ none: "rows"
2230
+ };
2231
+ var directionForStyle = (style) => style ? STYLE_TO_DIRECTION[style] : "rows";
2232
+ var buildProductListLayout = (direction, columns) => direction === "grid" ? { direction, grid: { columns: Array.from({ length: Math.max(columns, 1) }, () => "fill"), rows: ["auto"] } } : { direction };
2233
+ var hasHeaderText = (language) => !!(language?.title || language?.superTitle || language?.description);
2234
+ var DISCOUNTED_FROM = {
2235
+ compare_at_price: "compare_at_price",
2236
+ original_price: "price",
2237
+ price: "price"
2238
+ };
2239
+ var buildDiscountSection = (discount) => {
2240
+ if (!discount?.type || discount.type === "none") return [];
2241
+ const discountedFrom = discount.discountedFrom ? DISCOUNTED_FROM[discount.discountedFrom] : void 0;
2242
+ return [
2243
+ {
2244
+ amount: discount.amount ?? 0,
2245
+ ...discount.discountedBy && { discountedBy: discount.discountedBy },
2246
+ ...discountedFrom && { discountedFrom },
2247
+ ...discount.message && { message: discount.message },
2248
+ ...discount.quantity != null && { quantity: discount.quantity },
2249
+ sectionType: "discount",
2250
+ type: discount.type
2251
+ }
2252
+ ];
2253
+ };
2254
+ var buildBanner = (language) => language?.successBannerEnabled ? [
2255
+ {
2256
+ color: "success",
2257
+ dismissible: true,
2258
+ sections: [
2259
+ {
2260
+ /**
2261
+ * A defined v1 message (RTE doc or string) passes through verbatim as `en`;
2262
+ * absent falls back to the localized defaults (P4 language policy).
2263
+ */
2264
+ content: language.successBannerMessageRte ? { ...OFFER_LABELS.addedToCartMessage, en: language.successBannerMessageRte } : OFFER_LABELS.addedToCartMessage,
2265
+ sectionType: "text"
2266
+ },
2267
+ {
2268
+ action: "undoAddToOrder",
2269
+ buttonStyle: "plain",
2270
+ sections: [{ buttonField: "buttonLabel", content: OFFER_LABELS.undo, sectionType: "text" }],
2271
+ sectionType: "button"
2272
+ }
2273
+ ],
2274
+ sectionType: "banner"
2275
+ }
2276
+ ] : [];
2277
+ var convertOfferToV2 = ({ id, name, settings }) => {
2278
+ const layout = settings.layout?.large ?? settings.layout?.medium ?? settings.layout?.small;
2279
+ const columns = layout?.columns ?? 1;
2280
+ const direction = directionForStyle(layout?.style);
2281
+ const listLayout = buildProductListLayout(direction, columns);
2282
+ const horizontalCard = direction === "rows";
2283
+ const dataSource = {
2284
+ ...settings.endpoint && { dataSourcePath: settings.endpoint },
2285
+ ...settings.integrations && { integrations: settings.integrations },
2286
+ ...settings.limit !== void 0 && { limit: settings.limit },
2287
+ matchVariant: !!settings.productOptions?.matchVariant,
2288
+ matchVariantOutOfStock: !!settings.productOptions?.matchVariantOutOfStock,
2289
+ ...settings.productType && { productType: settings.productType },
2290
+ sectionType: "dataSource",
2291
+ ...settings.treatAsGwp && { treatAsGwp: true }
2292
+ };
2293
+ const offers = {
2294
+ sections: [
2295
+ ...buildOfferCard(settings, horizontalCard),
2296
+ dataSource,
2297
+ ...buildDiscountSection(settings.discount),
2298
+ ...buildBanner(settings.language)
2299
+ ],
2300
+ sectionType: "offers"
2301
+ };
2302
+ const display = {
2303
+ autoAdvanceInterval: 0,
2304
+ itemsAtOnce: layout?.carousel ? columns : settings.limit ?? columns,
2305
+ ...listLayout,
2306
+ sections: [offers],
2307
+ sectionType: "carousel"
2308
+ };
2309
+ return CABRootSection.parse({
2310
+ direction: "rows",
2311
+ editorMode: LOCATION_TO_EDITOR_MODE3[settings.location ?? "checkout"],
2312
+ // The widget name is required by the admin save schema; carry the legacy widget's name through.
2313
+ ...name && { name },
2314
+ previewMode: settings.previewMode,
2315
+ sections: [
2316
+ ...hasHeaderText(settings.language) ? [{ content: { en: convertContentBlockTextToV2(settings.language) }, sectionType: "text" }] : [],
2317
+ display
2318
+ ],
2319
+ tracking: {
2320
+ enableAttribution: settings.tracking?.enableAttribution ?? true,
2321
+ enableSource: settings.tracking?.enableSource ?? true,
2322
+ enableWidget: settings.tracking?.enableWidget ?? true
2323
+ },
2324
+ type: SHOPIFY_CHECKOUT_EXTENSION,
2325
+ version: 2,
2326
+ widgetId: id
2327
+ });
2328
+ };
2329
+
1412
2330
  // src/transforms/parseShielded.ts
1413
2331
  var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(transform(convertNumericObjects(deepCamelCase(raw))));
1414
2332
  export {
1415
2333
  CONTENT_BLOCK_MAX_IMAGE_WIDTH,
2334
+ SHOPIFY_CHECKOUT_EXTENSION,
1416
2335
  SHOPIFY_CHECKOUT_EXTENSION_CONTENT_BLOCK,
2336
+ buildOfferCard,
2337
+ buildOfferTemplate,
1417
2338
  convertContentBlockImageToV2,
1418
2339
  convertContentBlockTextToV2,
1419
2340
  convertContentBlockToV2,
1420
2341
  convertLineItemEditorToV2,
1421
2342
  convertNumericObjects,
2343
+ convertOfferToV2,
1422
2344
  convertTextToTiptapParagraph,
1423
2345
  deepCamelCase,
1424
2346
  htmlToTiptap,
1425
2347
  isCABRootSection,
1426
2348
  isContentBlockV1,
1427
2349
  isLineItemEditorV1,
2350
+ isOfferV1,
1428
2351
  normalizeTextContent,
1429
2352
  normalizeTokens,
1430
2353
  parseShielded