@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,5 +1,117 @@
1
- // src/schema/widgets/checkout-and-beyond/banner.ts
2
- import { z as z18 } from "zod/v4";
1
+ // src/server/shared.ts
2
+ var REBUY_ENGINE_HOST = "rebuyengine.com";
3
+ var UpstreamError = class extends Error {
4
+ constructor(status, body, message) {
5
+ super(message ?? `Upstream returned ${status}`);
6
+ this.body = body;
7
+ this.name = "UpstreamError";
8
+ this.status = status;
9
+ }
10
+ };
11
+ var NotFoundError = class extends Error {
12
+ constructor(message) {
13
+ super(message);
14
+ this.name = "NotFoundError";
15
+ }
16
+ };
17
+
18
+ // src/schema/userConfig.ts
19
+ import { z as z2 } from "zod/v4";
20
+
21
+ // src/schema/shopConfig.ts
22
+ import { z } from "zod/v4";
23
+ var ShopConfig = z.object({
24
+ activeExperiments: z.array(
25
+ z.object({
26
+ data: z.array(
27
+ z.object({
28
+ aliasName: z.string(),
29
+ cssInput: z.string().nullish(),
30
+ elementId: z.coerce.number(),
31
+ id: z.coerce.number(),
32
+ javascriptInput: z.string().nullish(),
33
+ traffic: z.coerce.number()
34
+ })
35
+ ),
36
+ id: z.coerce.number(),
37
+ name: z.string(),
38
+ pageTarget: z.string().nullable(),
39
+ pageTargetUrl: z.string().nullable(),
40
+ placeholderId: z.coerce.number().nullable(),
41
+ type: z.string()
42
+ })
43
+ ),
44
+ activePackages: z.array(
45
+ z.object({
46
+ cancelledAt: z.string().nullable(),
47
+ id: z.number(),
48
+ installedAt: z.string().nullable(),
49
+ isActive: z.boolean(),
50
+ isBillable: z.boolean(),
51
+ packageId: z.number(),
52
+ packageName: z.string(),
53
+ shortName: z.string(),
54
+ trialDays: z.number(),
55
+ uninstalledAt: z.string().nullable()
56
+ })
57
+ ),
58
+ apiKey: z.string(),
59
+ billingVersion: z.string().nullable(),
60
+ cacheKey: z.coerce.number(),
61
+ carousel: z.enum(["flickity", "splide"]),
62
+ currency: z.string(),
63
+ currencySymbol: z.string(),
64
+ domain: z.string(),
65
+ enabledJquery: z.boolean(),
66
+ enabledPresentmentCurrencies: z.array(z.string()),
67
+ hasSmartCollectionsEnabled: z.boolean(),
68
+ hasSmartSearchEnabled: z.boolean(),
69
+ id: z.coerce.number(),
70
+ integrations: z.record(
71
+ z.enum([
72
+ "attentive",
73
+ "judgeme",
74
+ "junip",
75
+ "klaviyo",
76
+ "loox",
77
+ "okendo",
78
+ "opinew",
79
+ "recharge",
80
+ "reviewsio",
81
+ "stamped",
82
+ "yotpo"
83
+ ]),
84
+ z.union([z.boolean(), z.unknown()])
85
+ ),
86
+ markets: z.object({
87
+ enabled: z.boolean()
88
+ }),
89
+ monetize: z.object({
90
+ publisherKey: z.string().nullable()
91
+ }).nullish(),
92
+ moneyFormat: z.string(),
93
+ myshopifyDomain: z.string(),
94
+ primaryLocale: z.string(),
95
+ productGroupsEnabled: z.enum(["no", "yes"]).transform((value) => value === "yes"),
96
+ rechargeCustomDomain: z.string().nullable(),
97
+ sellingPlansEnabled: z.boolean(),
98
+ shopId: z.number(),
99
+ shopifySellingPlansEnabled: z.boolean(),
100
+ shopName: z.string(),
101
+ storefrontAccessToken: z.string().nullable(),
102
+ useRebuyIcons: z.boolean()
103
+ });
104
+
105
+ // src/schema/userConfig.ts
106
+ var UserConfig = z2.object({
107
+ shop: ShopConfig,
108
+ smartCart: z2.unknown(),
109
+ smartFlows: z2.array(z2.unknown())
110
+ });
111
+
112
+ // src/schema/widgets/checkout-and-beyond/image.ts
113
+ import { v7 as uuidv713 } from "uuid";
114
+ import { z as z21 } from "zod/v4";
3
115
 
4
116
  // src/schema/widgets/checkout-and-beyond/common.ts
5
117
  var freezeEnum = (values) => Object.freeze(Object.fromEntries(values.map((v) => [v, v])));
@@ -119,6 +231,7 @@ var sectionTypes = [
119
231
  "carousel",
120
232
  "cartLine",
121
233
  "dataSource",
234
+ "discount",
122
235
  "image",
123
236
  "layout",
124
237
  "monetize",
@@ -147,12 +260,13 @@ var VariantSelector = freezeEnum(variantSelectors);
147
260
  var verticalAlignments = ["top", "middle", "bottom"];
148
261
  var VerticalAlignment = freezeEnum(verticalAlignments);
149
262
 
150
- // src/schema/widgets/checkout-and-beyond/layout.ts
151
- import { v7 as uuidv712 } from "uuid";
152
- import { z as z17 } from "zod/v4";
263
+ // src/schema/widgets/checkout-and-beyond/regex.ts
264
+ var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
265
+ var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
266
+ var HTML_TAGS_REGEX = /<\/?[^>]+>/g;
153
267
 
154
268
  // src/schema/widgets/checkout-and-beyond/rule.ts
155
- import { z } from "zod/v4";
269
+ import { z as z3 } from "zod/v4";
156
270
  var ruleTypes = [
157
271
  "cart",
158
272
  "cart_count",
@@ -171,7 +285,7 @@ var ruleTypes = [
171
285
  "product_type",
172
286
  "product_vendor"
173
287
  ];
174
- var ruleType = z.enum(ruleTypes);
288
+ var ruleType = z3.enum(ruleTypes);
175
289
  var RuleType = ruleType.enum;
176
290
  var ruleOperators = [
177
291
  "after",
@@ -186,53 +300,93 @@ var ruleOperators = [
186
300
  "greater_than",
187
301
  "less_than"
188
302
  ];
189
- var ruleOperator = z.enum(ruleOperators);
303
+ var ruleOperator = z3.enum(ruleOperators);
190
304
  var RuleOperator = ruleOperator.enum;
191
- var RuleCondition = z.object({
192
- operator: z.enum(ruleOperators).default(RuleOperator.anything),
193
- products: z.union([z.array(z.unknown()), z.strictObject({}).transform(() => [])]).default(() => []),
194
- type: z.enum(ruleTypes).default(RuleType.cart_subtotal),
195
- value: z.coerce.string().default("")
305
+ var RuleCondition = z3.object({
306
+ operator: z3.enum(ruleOperators).default(RuleOperator.anything),
307
+ products: z3.union([z3.array(z3.unknown()), z3.strictObject({}).transform(() => [])]).default(() => []),
308
+ type: z3.enum(ruleTypes).default(RuleType.cart_subtotal),
309
+ value: z3.coerce.string().default("")
196
310
  });
197
- var RuleLogicBlock = z.object({
198
- rules: z.array(RuleCondition).default(() => [])
311
+ var RuleLogicBlock = z3.object({
312
+ rules: z3.array(RuleCondition).default(() => [])
199
313
  });
200
- var CABRule = z.object({
201
- dataSourceId: z.number().nullable().default(null),
202
- enabled: z.boolean().default(false),
203
- ruleset: z.union([
204
- z.array(
205
- z.object({
206
- exitIfMatched: z.boolean().default(true),
207
- logic: z.array(RuleLogicBlock).default(() => []),
208
- output: z.array(
209
- z.object({
210
- key: z.string().default("should_show"),
211
- type: z.literal("data_json").default("data_json"),
212
- value: z.string().default("true")
314
+ var CABRule = z3.object({
315
+ dataSourceId: z3.number().nullable().default(null),
316
+ enabled: z3.boolean().default(false),
317
+ ruleset: z3.union([
318
+ z3.array(
319
+ z3.object({
320
+ exitIfMatched: z3.boolean().default(true),
321
+ logic: z3.array(RuleLogicBlock).default(() => []),
322
+ output: z3.array(
323
+ z3.object({
324
+ key: z3.string().default("should_show"),
325
+ type: z3.literal("data_json").default("data_json"),
326
+ value: z3.string().default("true")
213
327
  })
214
328
  ).default(() => [{ key: "should_show", type: "data_json", value: "true" }])
215
329
  })
216
330
  ),
217
- z.strictObject({}).transform(() => [])
331
+ z3.strictObject({}).transform(() => [])
218
332
  ]).default(() => [])
219
333
  });
220
334
 
221
335
  // src/schema/widgets/checkout-and-beyond/shared.ts
222
- import { z as z16 } from "zod/v4";
336
+ import { z as z20 } from "zod/v4";
223
337
 
224
- // src/schema/widgets/checkout-and-beyond/button.ts
225
- import { v7 as uuidv73 } from "uuid";
226
- import { z as z4 } from "zod/v4";
338
+ // src/schema/widgets/checkout-and-beyond/banner.ts
339
+ import { z as z5 } from "zod/v4";
227
340
 
228
- // src/schema/widgets/checkout-and-beyond/image.ts
341
+ // src/schema/widgets/checkout-and-beyond/layout.ts
229
342
  import { v7 as uuidv7 } from "uuid";
230
- import { z as z2 } from "zod/v4";
343
+ import { z as z4 } from "zod/v4";
344
+ var GridItem = z4.union([z4.literal("auto"), z4.literal("fill"), z4.string().regex(/^\d+%$/), z4.number()]);
345
+ var CABLayoutSection = z4.object({
346
+ alignment: z4.object({
347
+ horizontal: z4.enum(horizontalAlignments).default(HorizontalAlignment.start),
348
+ vertical: z4.enum(verticalAlignments).default(VerticalAlignment.top)
349
+ }).default({
350
+ horizontal: HorizontalAlignment.start,
351
+ vertical: VerticalAlignment.top
352
+ }),
353
+ border: z4.lazy(() => CABBorder),
354
+ buttonField: z4.enum(buttonFields).optional(),
355
+ direction: z4.enum(directions).default(Direction.rows),
356
+ grid: z4.object({
357
+ columns: z4.union([z4.array(GridItem), z4.undefined()]).default(() => ["auto"]),
358
+ rows: z4.union([z4.array(GridItem), z4.undefined()]).default(() => ["auto"])
359
+ }).default({ columns: ["auto"], rows: ["auto"] }).optional(),
360
+ name: z4.string().optional(),
361
+ padding: z4.enum(spacings).default(Spacing.none),
362
+ rule: CABRule.optional(),
363
+ sectionId: z4.uuid().default(() => uuidv7()),
364
+ sections: z4.union([z4.array(z4.lazy(() => CABSection)), z4.strictObject({}).transform(() => [])]).default(() => []),
365
+ sectionType: z4.literal(SectionType.layout).default(SectionType.layout),
366
+ spacing: z4.enum(spacings).default(Spacing.base),
367
+ /** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
368
+ viewUrl: z4.string().optional(),
369
+ width: z4.number().default(100)
370
+ });
231
371
 
232
- // src/schema/widgets/checkout-and-beyond/regex.ts
233
- var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
234
- var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
235
- var HTML_TAGS_REGEX = /<\/?[^>]+>/g;
372
+ // src/schema/widgets/checkout-and-beyond/banner.ts
373
+ var CABBannerSection = z5.lazy(
374
+ () => CABLayoutSection.omit({ sectionType: true }).extend({
375
+ buttonField: z5.enum(buttonFields).optional(),
376
+ color: z5.enum(bannerColors).default("info"),
377
+ dismissible: z5.boolean().default(true),
378
+ sectionType: z5.literal(SectionType.banner).default(SectionType.banner)
379
+ })
380
+ );
381
+
382
+ // src/schema/widgets/checkout-and-beyond/button.ts
383
+ import { v7 as uuidv73 } from "uuid";
384
+ import { z as z7 } from "zod/v4";
385
+
386
+ // src/schema/widgets/checkout-and-beyond/text.ts
387
+ import { forEach, isString as isString2 } from "es-toolkit/compat";
388
+ import { v7 as uuidv72 } from "uuid";
389
+ import { z as z6 } from "zod/v4";
236
390
 
237
391
  // src/schema/widgets/checkout-and-beyond/utils.ts
238
392
  import { isPlainObject, mapValues } from "es-toolkit";
@@ -250,90 +404,65 @@ var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(
250
404
  var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject(input) && hasHTMLInDoc(input));
251
405
  var NO_HTML = { message: "HTML is not supported" };
252
406
 
253
- // src/schema/widgets/checkout-and-beyond/image.ts
254
- var CABImageSection = z2.object({
255
- altText: z2.string().refine(checkForHTML, NO_HTML).default(""),
256
- aspectRatio: z2.literal(1).nullable().default(null),
257
- border: z2.lazy(() => CABBorder),
258
- buttonField: z2.enum(buttonFields).optional(),
259
- category: z2.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
260
- name: z2.string().optional(),
261
- naturalHeight: z2.number().default(0),
262
- naturalWidth: z2.number().default(0),
263
- /**
264
- * `contain` (the component default): dimensionless images render in s-image's 1/1 default frame, and
265
- * `cover` would crop non-square art (payment badges lost their edges — 15993); `contain` letterboxes.
266
- */
267
- objectFit: z2.enum(objectFits).default(ObjectFit.contain),
268
- rule: CABRule.optional(),
269
- sectionId: z2.uuid().default(() => uuidv7()),
270
- sectionType: z2.literal(SectionType.image).default(SectionType.image),
271
- source: z2.union([z2.url(), z2.literal(""), z2.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
272
- width: z2.number().default(100)
273
- });
274
-
275
407
  // src/schema/widgets/checkout-and-beyond/text.ts
276
- import { forEach, isString as isString2 } from "es-toolkit/compat";
277
- import { v7 as uuidv72 } from "uuid";
278
- import { z as z3 } from "zod/v4";
279
- var enumOrOmit = (...vals) => z3.string().transform((val) => vals.includes(val) ? val : void 0).optional();
280
- var TiptapText = z3.object({
281
- marks: z3.union([
282
- z3.array(
283
- z3.discriminatedUnion("type", [
284
- z3.object({ type: z3.literal("bold") }),
285
- z3.object({ type: z3.literal("italic") }),
286
- z3.object({
287
- attrs: z3.object({
288
- class: z3.string().nullable(),
289
- href: z3.union([z3.url(), z3.literal("#"), z3.string().regex(DYNAMIC_TOKEN_REGEX)]),
290
- rel: z3.string().default("noopener noreferrer nofollow"),
291
- target: z3.string().default("_blank")
408
+ var enumOrOmit = (...vals) => z6.string().transform((val) => vals.includes(val) ? val : void 0).optional();
409
+ var TiptapText = z6.object({
410
+ marks: z6.union([
411
+ z6.array(
412
+ z6.discriminatedUnion("type", [
413
+ z6.object({ type: z6.literal("bold") }),
414
+ z6.object({ type: z6.literal("italic") }),
415
+ z6.object({
416
+ attrs: z6.object({
417
+ class: z6.string().nullable(),
418
+ href: z6.union([z6.url(), z6.literal("#"), z6.string().regex(DYNAMIC_TOKEN_REGEX)]),
419
+ rel: z6.string().default("noopener noreferrer nofollow"),
420
+ target: z6.string().default("_blank")
292
421
  }),
293
- type: z3.literal("link")
422
+ type: z6.literal("link")
294
423
  }),
295
- z3.object({ type: z3.literal("strike") }),
296
- z3.object({
297
- attrs: z3.object({
424
+ z6.object({ type: z6.literal("strike") }),
425
+ z6.object({
426
+ attrs: z6.object({
298
427
  color: enumOrOmit(...textColorNames).default(TextColorName.base),
299
428
  fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
300
429
  }),
301
- type: z3.literal("textStyle")
430
+ type: z6.literal("textStyle")
302
431
  })
303
432
  ])
304
433
  ),
305
- z3.strictObject({}).transform(() => [])
434
+ z6.strictObject({}).transform(() => [])
306
435
  ]).optional(),
307
- text: z3.string().default(""),
308
- type: z3.literal("text").default("text")
436
+ text: z6.string().default(""),
437
+ type: z6.literal("text").default("text")
309
438
  });
310
- var TiptapParagraph = z3.object({
311
- attrs: z3.object({
439
+ var TiptapParagraph = z6.object({
440
+ attrs: z6.object({
312
441
  textAlign: enumOrOmit(...textAlignments)
313
442
  }).default({ textAlign: TextAlignment.start }),
314
- content: z3.union([z3.array(TiptapText), z3.strictObject({}).transform(() => [])]).default(() => []),
315
- type: z3.literal("paragraph").default("paragraph")
443
+ content: z6.union([z6.array(TiptapText), z6.strictObject({}).transform(() => [])]).default(() => []),
444
+ type: z6.literal("paragraph").default("paragraph")
316
445
  });
317
- var TiptapDocument = z3.object({
318
- attrs: z3.object({
446
+ var TiptapDocument = z6.object({
447
+ attrs: z6.object({
319
448
  blockSpacing: enumOrOmit(...spacings)
320
449
  }).default({ blockSpacing: Spacing.base }),
321
- content: z3.union([z3.array(TiptapParagraph), z3.strictObject({}).transform(() => [])]).default(() => [TiptapParagraph.parse({})]),
322
- type: z3.literal("doc").default("doc")
450
+ content: z6.union([z6.array(TiptapParagraph), z6.strictObject({}).transform(() => [])]).default(() => [TiptapParagraph.parse({})]),
451
+ type: z6.literal("doc").default("doc")
323
452
  });
324
- var CABProgressTier = z3.object({
325
- threshold: z3.number().int().nonnegative(),
326
- thresholds: z3.record(z3.string(), z3.number().int().nonnegative()).default(() => ({})),
327
- tierType: z3.enum(progressTierTypes).default(ProgressTierType.shipping)
453
+ var CABProgressTier = z6.object({
454
+ threshold: z6.number().int().nonnegative(),
455
+ thresholds: z6.record(z6.string(), z6.number().int().nonnegative()).default(() => ({})),
456
+ tierType: z6.enum(progressTierTypes).default(ProgressTierType.shipping)
328
457
  });
329
- var CABTextSection = z3.object({
330
- buttonField: z3.enum(buttonFields).optional(),
331
- content: z3.record(z3.string(), z3.union([z3.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
332
- name: z3.string().optional(),
333
- optionId: z3.number().optional(),
458
+ var CABTextSection = z6.object({
459
+ buttonField: z6.enum(buttonFields).optional(),
460
+ content: z6.record(z6.string(), z6.union([z6.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
461
+ name: z6.string().optional(),
462
+ optionId: z6.number().optional(),
334
463
  rule: CABRule.optional(),
335
- sectionId: z3.uuid().default(() => uuidv72()),
336
- sectionType: z3.literal(SectionType.text).default(SectionType.text),
464
+ sectionId: z6.uuid().default(() => uuidv72()),
465
+ sectionType: z6.literal(SectionType.text).default(SectionType.text),
337
466
  tier: CABProgressTier.optional()
338
467
  }).superRefine(({ buttonField, content }, ctx) => {
339
468
  if (buttonField === ButtonField.destinationUrl && content) {
@@ -355,48 +484,48 @@ var CABTextSection = z3.object({
355
484
  });
356
485
 
357
486
  // src/schema/widgets/checkout-and-beyond/button.ts
358
- var CABButtonContent = z4.lazy(
359
- () => z4.discriminatedUnion("sectionType", [CABImageSection, CABLayoutSection, CABTextSection])
487
+ var CABButtonContent = z7.lazy(
488
+ () => z7.discriminatedUnion("sectionType", [CABImageSection, CABLayoutSection, CABTextSection])
360
489
  );
361
- var CABButtonSection = z4.object({
362
- action: z4.union([z4.literal(""), z4.enum(buttonActions)]).default(""),
363
- buttonStyle: z4.enum(buttonStyles).default(ButtonStyle.primary),
364
- custom: z4.object({
365
- color: z4.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
366
- height: z4.number().default(52),
367
- width: z4.number().default(300)
490
+ var CABButtonSection = z7.object({
491
+ action: z7.union([z7.literal(""), z7.enum(buttonActions)]).default(""),
492
+ buttonStyle: z7.enum(buttonStyles).default(ButtonStyle.primary),
493
+ custom: z7.object({
494
+ color: z7.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
495
+ height: z7.number().default(52),
496
+ width: z7.number().default(300)
368
497
  }).default({
369
498
  color: "#005bd3",
370
499
  height: 52,
371
500
  width: 300
372
501
  }),
373
- disableDowngrade: z4.boolean().default(false),
374
- name: z4.string().optional(),
375
- optionId: z4.number().optional(),
376
- popover: z4.object({
377
- alignment: z4.enum(textAlignments).default(TextAlignment.center),
378
- position: z4.enum(popoverPositions).default(PopoverPosition.blockStart)
502
+ disableDowngrade: z7.boolean().default(false),
503
+ name: z7.string().optional(),
504
+ optionId: z7.number().optional(),
505
+ popover: z7.object({
506
+ alignment: z7.enum(textAlignments).default(TextAlignment.center),
507
+ position: z7.enum(popoverPositions).default(PopoverPosition.blockStart)
379
508
  }).optional().default(() => ({
380
509
  alignment: TextAlignment.center,
381
510
  position: PopoverPosition.blockStart
382
511
  })),
383
512
  rule: CABRule.optional(),
384
- sectionId: z4.uuid().default(() => uuidv73()),
385
- sections: z4.union([z4.array(CABButtonContent), z4.strictObject({}).transform(() => [])]).default(() => []),
386
- sectionType: z4.literal(SectionType.button).default(SectionType.button),
513
+ sectionId: z7.uuid().default(() => uuidv73()),
514
+ sections: z7.union([z7.array(CABButtonContent), z7.strictObject({}).transform(() => [])]).default(() => []),
515
+ sectionType: z7.literal(SectionType.button).default(SectionType.button),
387
516
  /** Fire-and-forget pixel POSTed when the button is clicked (e.g. a Monetize decline). */
388
- trackingUrl: z4.string().optional()
517
+ trackingUrl: z7.string().optional()
389
518
  });
390
519
 
391
520
  // src/schema/widgets/checkout-and-beyond/carousel.ts
392
- import { z as z9 } from "zod/v4";
521
+ import { z as z12 } from "zod/v4";
393
522
 
394
523
  // src/schema/widgets/checkout-and-beyond/offers.ts
395
- import { z as z8 } from "zod/v4";
524
+ import { z as z11 } from "zod/v4";
396
525
 
397
526
  // src/schema/widgets/checkout-and-beyond/dataSource.ts
398
527
  import { v7 as uuidv74 } from "uuid";
399
- import { z as z5 } from "zod/v4";
528
+ import { z as z8 } from "zod/v4";
400
529
 
401
530
  // src/schema/widgets/checkout-and-beyond/constants.ts
402
531
  import { uniqBy } from "es-toolkit";
@@ -475,70 +604,70 @@ var widgetTypes = [
475
604
  var WidgetType = freezeEnum(widgetTypes);
476
605
 
477
606
  // src/schema/widgets/checkout-and-beyond/dataSource.ts
478
- var CABDiscount = z5.object({
479
- amount: z5.union([z5.number(), z5.string()]).catch(0),
480
- discountedBy: z5.string().optional(),
481
- discountedFrom: z5.enum(discountSources).optional().catch(void 0),
482
- type: z5.enum(discountTypes).catch("none")
607
+ var CABDiscount = z8.object({
608
+ amount: z8.union([z8.number(), z8.string()]).catch(0),
609
+ discountedBy: z8.string().optional(),
610
+ discountedFrom: z8.enum(discountSources).optional().catch(void 0),
611
+ type: z8.enum(discountTypes).catch("none")
483
612
  });
484
- var CABIntegrations = z5.object({
485
- judgeme: z5.boolean().default(false),
486
- junip: z5.boolean().default(false),
487
- klaviyo: z5.boolean().default(false),
488
- loox: z5.boolean().default(false),
489
- okendo: z5.boolean().default(false),
490
- opinew: z5.boolean().default(false),
491
- reviewsio: z5.boolean().default(false),
492
- stamped: z5.boolean().default(false),
493
- yotpo: z5.boolean().default(false)
613
+ var CABIntegrations = z8.object({
614
+ judgeme: z8.boolean().default(false),
615
+ junip: z8.boolean().default(false),
616
+ klaviyo: z8.boolean().default(false),
617
+ loox: z8.boolean().default(false),
618
+ okendo: z8.boolean().default(false),
619
+ opinew: z8.boolean().default(false),
620
+ reviewsio: z8.boolean().default(false),
621
+ stamped: z8.boolean().default(false),
622
+ yotpo: z8.boolean().default(false)
494
623
  });
495
- var CABDataSourceSection = z5.object({
496
- dataSourceId: z5.number().nullable().default(null),
497
- dataSourcePath: z5.string().default(DEFAULT_ENDPOINTS[0].value),
624
+ var CABDataSourceSection = z8.object({
625
+ dataSourceId: z8.number().nullable().default(null),
626
+ dataSourcePath: z8.string().default(DEFAULT_ENDPOINTS[0].value),
498
627
  discount: CABDiscount.optional(),
499
628
  integrations: CABIntegrations.optional(),
500
- limit: z5.number().default(1),
501
- matchVariant: z5.boolean().default(false),
502
- matchVariantOutOfStock: z5.boolean().default(false),
503
- name: z5.string().default(DEFAULT_ENDPOINTS[0].label),
504
- productType: z5.enum(productTypes).optional(),
505
- sectionId: z5.uuid().default(() => uuidv74()),
506
- sectionType: z5.literal(SectionType.dataSource).default(SectionType.dataSource),
507
- treatAsGwp: z5.boolean().default(false)
629
+ limit: z8.number().default(1),
630
+ matchVariant: z8.boolean().default(false),
631
+ matchVariantOutOfStock: z8.boolean().default(false),
632
+ name: z8.string().default(DEFAULT_ENDPOINTS[0].label),
633
+ productType: z8.enum(productTypes).optional(),
634
+ sectionId: z8.uuid().default(() => uuidv74()),
635
+ sectionType: z8.literal(SectionType.dataSource).default(SectionType.dataSource),
636
+ treatAsGwp: z8.boolean().default(false)
508
637
  });
509
638
 
510
639
  // src/schema/widgets/checkout-and-beyond/products.ts
511
640
  import { v7 as uuidv76 } from "uuid";
512
- import { z as z7 } from "zod/v4";
641
+ import { z as z10 } from "zod/v4";
513
642
 
514
643
  // src/schema/widgets/checkout-and-beyond/product.ts
515
644
  import { v7 as uuidv75 } from "uuid";
516
- import { z as z6 } from "zod/v4";
517
- var CABVariantContent = z6.lazy(
518
- () => z6.discriminatedUnion("sectionType", [CABButtonSection, CABTextSection])
645
+ import { z as z9 } from "zod/v4";
646
+ var CABVariantContent = z9.lazy(
647
+ () => z9.discriminatedUnion("sectionType", [CABButtonSection, CABTextSection])
519
648
  );
520
- var CABProductSection = z6.object({
521
- name: z6.string().optional(),
522
- productId: z6.number().nullable().default(null),
523
- sectionId: z6.uuid().default(() => uuidv75()),
524
- sections: z6.union([z6.array(CABVariantContent), z6.strictObject({}).transform(() => [])]).default(() => []),
525
- sectionType: z6.literal(SectionType.product).default(SectionType.product),
526
- selectors: z6.record(z6.string(), z6.enum(variantSelectors).default(VariantSelector.menu)).default(() => ({})),
527
- variantMode: z6.enum(variantModes).default(VariantMode.multiple)
649
+ var CABProductSection = z9.object({
650
+ name: z9.string().optional(),
651
+ productId: z9.number().nullable().default(null),
652
+ sectionId: z9.uuid().default(() => uuidv75()),
653
+ sections: z9.union([z9.array(CABVariantContent), z9.strictObject({}).transform(() => [])]).default(() => []),
654
+ sectionType: z9.literal(SectionType.product).default(SectionType.product),
655
+ selectors: z9.record(z9.string(), z9.enum(variantSelectors).default(VariantSelector.menu)).default(() => ({})),
656
+ variantMode: z9.enum(variantModes).default(VariantMode.multiple)
528
657
  });
529
658
 
530
659
  // src/schema/widgets/checkout-and-beyond/products.ts
531
- var CABProductsSection = z7.object({
532
- name: z7.string().optional(),
533
- sectionId: z7.uuid().default(() => uuidv76()),
534
- sections: z7.union([z7.array(z7.lazy(() => CABProductSection)), z7.strictObject({}).transform(() => [])]).default(() => []),
535
- sectionType: z7.literal(SectionType.products).default(SectionType.products)
660
+ var CABProductsSection = z10.object({
661
+ name: z10.string().optional(),
662
+ sectionId: z10.uuid().default(() => uuidv76()),
663
+ sections: z10.union([z10.array(z10.lazy(() => CABProductSection)), z10.strictObject({}).transform(() => [])]).default(() => []),
664
+ sectionType: z10.literal(SectionType.products).default(SectionType.products)
536
665
  });
537
666
 
538
667
  // src/schema/widgets/checkout-and-beyond/offers.ts
539
- var CABOffersSection = z8.lazy(
668
+ var CABOffersSection = z11.lazy(
540
669
  () => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
541
- sections: z8.union([z8.array(z8.lazy(() => CABSection)), z8.strictObject({}).transform(() => [])]).default(() => [
670
+ sections: z11.union([z11.array(z11.lazy(() => CABSection)), z11.strictObject({}).transform(() => [])]).default(() => [
542
671
  CABBannerSection.parse({
543
672
  buttonField: "undoAddToOrder",
544
673
  color: "success",
@@ -552,62 +681,77 @@ var CABOffersSection = z8.lazy(
552
681
  CABDataSourceSection.parse({}),
553
682
  CABProductsSection.parse({})
554
683
  ]),
555
- sectionType: z8.literal(SectionType.offers).default(SectionType.offers)
684
+ sectionType: z11.literal(SectionType.offers).default(SectionType.offers)
556
685
  })
557
686
  );
558
687
 
559
688
  // src/schema/widgets/checkout-and-beyond/carousel.ts
560
- var CABCarouselSection = z9.lazy(
689
+ var CABCarouselSection = z12.lazy(
561
690
  () => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
562
- autoAdvanceInterval: z9.number().default(0),
563
- itemsAtOnce: z9.number().min(1).default(1),
564
- sections: z9.union([z9.array(z9.lazy(() => CABSection)), z9.strictObject({}).transform(() => [])]).default(() => [CABOffersSection.parse({})]),
565
- sectionType: z9.literal(SectionType.carousel).default(SectionType.carousel)
691
+ autoAdvanceInterval: z12.number().default(0),
692
+ itemsAtOnce: z12.number().min(1).default(1),
693
+ sections: z12.union([z12.array(z12.lazy(() => CABSection)), z12.strictObject({}).transform(() => [])]).default(() => [CABOffersSection.parse({})]),
694
+ sectionType: z12.literal(SectionType.carousel).default(SectionType.carousel)
566
695
  })
567
696
  );
568
697
 
569
698
  // src/schema/widgets/checkout-and-beyond/cartLine.ts
570
- import { z as z10 } from "zod/v4";
571
- var CABCartLineSection = z10.lazy(
699
+ import { z as z13 } from "zod/v4";
700
+ var CABCartLineSection = z13.lazy(
572
701
  () => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
573
- sections: z10.union([z10.array(z10.lazy(() => CABSection)), z10.strictObject({}).transform(() => [])]).default(() => [CABButtonSection.parse({ action: ButtonAction.switchToSubscription })]),
574
- sectionType: z10.literal(SectionType.cartLine).default(SectionType.cartLine)
702
+ sections: z13.union([z13.array(z13.lazy(() => CABSection)), z13.strictObject({}).transform(() => [])]).default(() => [CABButtonSection.parse({ action: ButtonAction.switchToSubscription })]),
703
+ sectionType: z13.literal(SectionType.cartLine).default(SectionType.cartLine)
575
704
  })
576
705
  );
577
706
 
578
- // src/schema/widgets/checkout-and-beyond/monetize.ts
707
+ // src/schema/widgets/checkout-and-beyond/discount.ts
579
708
  import { v7 as uuidv77 } from "uuid";
580
- import { z as z11 } from "zod/v4";
581
- var CABMonetizeSection = z11.object({
582
- name: z11.string().optional(),
709
+ import { z as z14 } from "zod/v4";
710
+ var CABDiscountSection = z14.object({
711
+ amount: z14.union([z14.number(), z14.string()]).catch(0),
712
+ discountedBy: z14.string().optional(),
713
+ discountedFrom: z14.enum(discountSources).optional().catch(void 0),
714
+ message: z14.string().optional(),
715
+ name: z14.string().optional(),
716
+ quantity: z14.number().default(1),
717
+ sectionId: z14.uuid().default(() => uuidv77()),
718
+ sectionType: z14.literal(SectionType.discount).default(SectionType.discount),
719
+ type: z14.enum(discountTypes).catch("none")
720
+ });
721
+
722
+ // src/schema/widgets/checkout-and-beyond/monetize.ts
723
+ import { v7 as uuidv78 } from "uuid";
724
+ import { z as z15 } from "zod/v4";
725
+ var CABMonetizeSection = z15.object({
726
+ name: z15.string().optional(),
583
727
  rule: CABRule.optional(),
584
- sectionId: z11.uuid().default(() => uuidv77()),
585
- sectionType: z11.literal(SectionType.monetize).default(SectionType.monetize)
728
+ sectionId: z15.uuid().default(() => uuidv78()),
729
+ sectionType: z15.literal(SectionType.monetize).default(SectionType.monetize)
586
730
  });
587
731
 
588
732
  // src/schema/widgets/checkout-and-beyond/progressBar.ts
589
- import { v7 as uuidv78 } from "uuid";
590
- import { z as z12 } from "zod/v4";
591
- var CABProgressBarSection = z12.object({
733
+ import { v7 as uuidv79 } from "uuid";
734
+ import { z as z16 } from "zod/v4";
735
+ var CABProgressBarSection = z16.object({
592
736
  /** Empty = shown everywhere; otherwise uppercase ISO country codes. */
593
- countryCodes: z12.array(z12.string()).default(() => []),
594
- name: z12.string().optional(),
737
+ countryCodes: z16.array(z16.string()).default(() => []),
738
+ name: z16.string().optional(),
595
739
  rule: CABRule.optional(),
596
- sectionId: z12.uuid().default(() => uuidv78()),
597
- sections: z12.union([z12.array(CABTextSection), z12.strictObject({}).transform(() => [])]).default(() => []),
598
- sectionType: z12.literal(SectionType.progressBar).default(SectionType.progressBar)
740
+ sectionId: z16.uuid().default(() => uuidv79()),
741
+ sections: z16.union([z16.array(CABTextSection), z16.strictObject({}).transform(() => [])]).default(() => []),
742
+ sectionType: z16.literal(SectionType.progressBar).default(SectionType.progressBar)
599
743
  });
600
744
 
601
745
  // src/schema/widgets/checkout-and-beyond/quantity.ts
602
- import { v7 as uuidv79 } from "uuid";
603
- import { z as z13 } from "zod/v4";
604
- var CABQuantitySection = z13.object({
605
- errorMessages: z13.record(
606
- z13.string(),
607
- z13.object({
608
- max: z13.string().optional(),
609
- min: z13.string().optional(),
610
- neg: z13.string().optional()
746
+ import { v7 as uuidv710 } from "uuid";
747
+ import { z as z17 } from "zod/v4";
748
+ var CABQuantitySection = z17.object({
749
+ errorMessages: z17.record(
750
+ z17.string(),
751
+ z17.object({
752
+ max: z17.string().optional(),
753
+ min: z17.string().optional(),
754
+ neg: z17.string().optional()
611
755
  })
612
756
  ).default({
613
757
  en: {
@@ -616,58 +760,59 @@ var CABQuantitySection = z13.object({
616
760
  neg: "Quantity cannot be negative"
617
761
  }
618
762
  }),
619
- inputType: z13.enum(quantityInputs).default(QuantityInput.select),
620
- max: z13.number().min(1).max(100).default(10),
621
- min: z13.number().min(1).default(1),
622
- name: z13.string().optional(),
763
+ inputType: z17.enum(quantityInputs).default(QuantityInput.select),
764
+ max: z17.number().min(1).max(100).default(10),
765
+ min: z17.number().min(1).default(1),
766
+ name: z17.string().optional(),
623
767
  rule: CABRule.optional(),
624
- sectionId: z13.uuid().default(() => uuidv79()),
625
- sectionType: z13.literal(SectionType.quantity).default(SectionType.quantity)
768
+ sectionId: z17.uuid().default(() => uuidv710()),
769
+ sectionType: z17.literal(SectionType.quantity).default(SectionType.quantity)
626
770
  });
627
771
 
628
772
  // src/schema/widgets/checkout-and-beyond/reviews.ts
629
- import { v7 as uuidv710 } from "uuid";
630
- import { z as z14 } from "zod/v4";
631
- var CABReviewsSection = z14.object({
632
- color: z14.string().default("#fadb14"),
633
- name: z14.string().optional(),
773
+ import { v7 as uuidv711 } from "uuid";
774
+ import { z as z18 } from "zod/v4";
775
+ var CABReviewsSection = z18.object({
776
+ color: z18.string().default("#fadb14"),
777
+ name: z18.string().optional(),
634
778
  rule: CABRule.optional(),
635
- sectionId: z14.uuid().default(() => uuidv710()),
636
- sectionType: z14.literal(SectionType.reviews).default(SectionType.reviews),
637
- size: z14.enum(reviewsSizes).default(ReviewsSize.default)
779
+ sectionId: z18.uuid().default(() => uuidv711()),
780
+ sectionType: z18.literal(SectionType.reviews).default(SectionType.reviews),
781
+ size: z18.enum(reviewsSizes).default(ReviewsSize.default)
638
782
  });
639
783
 
640
784
  // src/schema/widgets/checkout-and-beyond/variants.ts
641
785
  import { slice } from "es-toolkit/compat";
642
- import { v7 as uuidv711 } from "uuid";
643
- import { z as z15 } from "zod/v4";
644
- var CABVariantsSection = z15.object({
645
- hideOutOfStockVariants: z15.boolean().default(false),
646
- name: z15.string().optional(),
786
+ import { v7 as uuidv712 } from "uuid";
787
+ import { z as z19 } from "zod/v4";
788
+ var CABVariantsSection = z19.object({
789
+ hideOutOfStockVariants: z19.boolean().default(false),
790
+ name: z19.string().optional(),
647
791
  rule: CABRule.optional(),
648
- sectionId: z15.uuid().default(() => uuidv711()),
649
- sectionType: z15.literal(SectionType.variants).default(SectionType.variants),
650
- selector: z15.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
651
- variantMode: z15.enum(variantModes).default(VariantMode.multiple)
792
+ sectionId: z19.uuid().default(() => uuidv712()),
793
+ sectionType: z19.literal(SectionType.variants).default(SectionType.variants),
794
+ selector: z19.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
795
+ variantMode: z19.enum(variantModes).default(VariantMode.multiple)
652
796
  });
653
797
 
654
798
  // src/schema/widgets/checkout-and-beyond/shared.ts
655
- var CABBorder = z16.object({
656
- radius: z16.enum(borderRadii).default(BorderRadius.base),
657
- style: z16.enum(borderStyles).default(BorderStyle.none),
658
- width: z16.enum(borderWidths).default(BorderWidth.base)
799
+ var CABBorder = z20.object({
800
+ radius: z20.enum(borderRadii).default(BorderRadius.base),
801
+ style: z20.enum(borderStyles).default(BorderStyle.none),
802
+ width: z20.enum(borderWidths).default(BorderWidth.base)
659
803
  }).default({
660
804
  radius: BorderRadius.base,
661
805
  style: BorderStyle.none,
662
806
  width: BorderWidth.base
663
807
  });
664
- var CABSection = z16.lazy(
665
- () => z16.discriminatedUnion("sectionType", [
808
+ var CABSection = z20.lazy(
809
+ () => z20.discriminatedUnion("sectionType", [
666
810
  CABBannerSection,
667
811
  CABButtonSection,
668
812
  CABCarouselSection,
669
813
  CABCartLineSection,
670
814
  CABDataSourceSection,
815
+ CABDiscountSection,
671
816
  CABImageSection,
672
817
  CABLayoutSection,
673
818
  CABMonetizeSection,
@@ -680,204 +825,29 @@ var CABSection = z16.lazy(
680
825
  CABTextSection,
681
826
  CABVariantsSection
682
827
  ])
683
- );
684
-
685
- // src/schema/widgets/checkout-and-beyond/layout.ts
686
- var GridItem = z17.union([z17.literal("auto"), z17.literal("fill"), z17.string().regex(/^\d+%$/), z17.number()]);
687
- var CABLayoutSection = z17.object({
688
- alignment: z17.object({
689
- horizontal: z17.enum(horizontalAlignments).default(HorizontalAlignment.start),
690
- vertical: z17.enum(verticalAlignments).default(VerticalAlignment.top)
691
- }).default({
692
- horizontal: HorizontalAlignment.start,
693
- vertical: VerticalAlignment.top
694
- }),
695
- border: z17.lazy(() => CABBorder),
696
- buttonField: z17.enum(buttonFields).optional(),
697
- direction: z17.enum(directions).default(Direction.rows),
698
- grid: z17.object({
699
- columns: z17.union([z17.array(GridItem), z17.undefined()]).default(() => ["auto"]),
700
- rows: z17.union([z17.array(GridItem), z17.undefined()]).default(() => ["auto"])
701
- }).default({ columns: ["auto"], rows: ["auto"] }).optional(),
702
- name: z17.string().optional(),
703
- padding: z17.enum(spacings).default(Spacing.none),
704
- rule: CABRule.optional(),
705
- sectionId: z17.uuid().default(() => uuidv712()),
706
- sections: z17.union([z17.array(z17.lazy(() => CABSection)), z17.strictObject({}).transform(() => [])]).default(() => []),
707
- sectionType: z17.literal(SectionType.layout).default(SectionType.layout),
708
- spacing: z17.enum(spacings).default(Spacing.base),
709
- /** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
710
- viewUrl: z17.string().optional(),
711
- width: z17.number().default(100)
712
- });
713
-
714
- // src/schema/widgets/checkout-and-beyond/banner.ts
715
- var CABBannerSection = z18.lazy(
716
- () => CABLayoutSection.omit({ sectionType: true }).extend({
717
- buttonField: z18.enum(buttonFields).optional(),
718
- color: z18.enum(bannerColors).default("info"),
719
- dismissible: z18.boolean().default(true),
720
- sectionType: z18.literal(SectionType.banner).default(SectionType.banner)
721
- })
722
- );
723
-
724
- // src/schema/widgets/checkout-and-beyond/root.ts
725
- import { z as z19 } from "zod/v4";
726
- var TargetArea = z19.object({
727
- fill: z19.boolean().optional(),
728
- flip: z19.enum(["both", "horizontal", "vertical"]).optional(),
729
- icon: z19.string(),
730
- label: z19.string(),
731
- width: z19.string()
732
- }).default(targetAreas[EditorMode.checkoutExtension][1]);
733
- var CABTracking = z19.object({
734
- enableAttribution: z19.boolean().default(true),
735
- enableSource: z19.boolean().default(true),
736
- enableWidget: z19.boolean().default(true)
737
- }).default({ enableAttribution: true, enableSource: true, enableWidget: true });
738
- var CABRootSection = CABLayoutSection.extend({
739
- editorMode: z19.enum(editorModes).default(EditorMode.checkoutExtension),
740
- previewMode: z19.boolean().default(false),
741
- storeId: z19.number().nullable().default(null),
742
- targetArea: TargetArea.nullable(),
743
- tracking: CABTracking,
744
- type: z19.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
745
- version: z19.literal(2).default(2),
746
- widgetId: z19.number().nullable().default(null)
747
- });
748
-
749
- // src/schema/widgets/checkout-and-beyond/switchLabels.ts
750
- var SWITCH_LABELS = {
751
- subscriptionOption: {
752
- ar: "\u064A\u062A\u0645 \u0627\u0644\u062A\u0648\u0635\u064A\u0644 \u0643\u0644 {{frequency}} {{interval}}",
753
- cs: "Doru\u010Den\xED ka\u017Ed\xFDch {{frequency}} {{interval}}",
754
- da: "Leveres hver {{frequency}} {{interval}}",
755
- de: "Lieferung alle {{frequency}} {{interval}}",
756
- en: "Delivers every {{frequency}} {{interval}}",
757
- es: "Entrega cada {{frequency}} {{interval}}",
758
- fi: "Toimitus {{frequency}} {{interval}} v\xE4lein",
759
- fr: "Livraison tous les {{frequency}} {{interval}}",
760
- ga: "Seachadtar gach {{frequency}} {{interval}}",
761
- he: "\u05DE\u05E9\u05DC\u05D5\u05D7 \u05DB\u05DC {{frequency}} {{interval}}",
762
- hi: "\u0939\u0930 {{frequency}} {{interval}} \u092E\u0947\u0902 \u0921\u093F\u0932\u0940\u0935\u0930\u0940",
763
- id: "Dikirim setiap {{frequency}} {{interval}}",
764
- it: "Consegna ogni {{frequency}} {{interval}}",
765
- ja: "{{frequency}} {{interval}}\u3054\u3068\u306B\u304A\u5C4A\u3051",
766
- ko: "{{frequency}} {{interval}}\uB9C8\uB2E4 \uBC30\uC1A1",
767
- nl: "Wordt elke {{frequency}} {{interval}} geleverd",
768
- no: "Leveres hver {{frequency}} {{interval}}",
769
- pl: "Dostawa co {{frequency}} {{interval}}",
770
- pt: "Entrega a cada {{frequency}} {{interval}}",
771
- ru: "\u0414\u043E\u0441\u0442\u0430\u0432\u043A\u0430 \u043A\u0430\u0436\u0434\u044B\u0435 {{frequency}} {{interval}}",
772
- sv: "Levereras var {{frequency}} {{interval}}",
773
- th: "\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E17\u0E38\u0E01 {{frequency}} {{interval}}",
774
- tr: "Her {{frequency}} {{interval}} aral\u0131\u011F\u0131nda teslimat",
775
- uk: "\u0414\u043E\u0441\u0442\u0430\u0432\u043A\u0430 \u043A\u043E\u0436\u043D\u0456 {{frequency}} {{interval}}",
776
- vi: "Giao h\xE0ng m\u1ED7i {{frequency}} {{interval}}",
777
- zh: "\u6BCF {{frequency}} {{interval}} \u914D\u9001\u4E00\u6B21"
778
- },
779
- switchToOneTimePurchase: {
780
- ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0634\u0631\u0627\u0621 \u0644\u0645\u0631\u0629 \u0648\u0627\u062D\u062F\u0629",
781
- cs: "P\u0159epnout na jednor\xE1zov\xFD n\xE1kup",
782
- da: "Skift til engangsk\xF8b",
783
- de: "Zu einmaligem Kauf wechseln",
784
- en: "Switch to One-time Purchase",
785
- es: "Cambiar a compra \xFAnica",
786
- fi: "Vaihda kertaluonteiseen ostoon",
787
- fr: "Passer \xE0 un achat unique",
788
- ga: "Athraigh go ceannach aonuaire",
789
- he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05E8\u05DB\u05D9\u05E9\u05D4 \u05D7\u05D3-\u05E4\u05E2\u05DE\u05D9\u05EA",
790
- hi: "\u090F\u0915 \u092C\u093E\u0930 \u0915\u0940 \u0916\u0930\u0940\u0926 \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902",
791
- id: "Beralih ke pembelian satu kali",
792
- it: "Passa all\u2019acquisto una tantum",
793
- ja: "1\u56DE\u9650\u308A\u306E\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u308B",
794
- ko: "\uC77C\uD68C\uC131 \uAD6C\uB9E4\uB85C \uC804\uD658",
795
- nl: "Overschakelen naar eenmalige aankoop",
796
- no: "Bytt til engangskj\xF8p",
797
- pl: "Prze\u0142\u0105cz na jednorazowy zakup",
798
- pt: "Mudar para compra \xFAnica",
799
- ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u0440\u0430\u0437\u043E\u0432\u0443\u044E \u043F\u043E\u043A\u0443\u043F\u043A\u0443",
800
- sv: "Byt till eng\xE5ngsk\xF6p",
801
- th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E0B\u0E37\u0E49\u0E2D\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",
802
- tr: "Tek seferlik sat\u0131n almaya ge\xE7",
803
- uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043E\u0434\u043D\u043E\u0440\u0430\u0437\u043E\u0432\u0443 \u043F\u043E\u043A\u0443\u043F\u043A\u0443",
804
- vi: "Chuy\u1EC3n sang mua m\u1ED9t l\u1EA7n",
805
- zh: "\u5207\u6362\u4E3A\u4E00\u6B21\u6027\u8D2D\u4E70"
806
- },
807
- switchToSubscriptionNoDiscount: {
808
- ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0627\u0634\u062A\u0631\u0627\u0643",
809
- cs: "P\u0159epnout na p\u0159edplatn\xE9",
810
- da: "Skift til abonnement",
811
- de: "Zu einem Abonnement wechseln",
812
- en: "Switch to Subscription",
813
- es: "Cambiar a suscripci\xF3n",
814
- fi: "Vaihda tilaukseen",
815
- fr: "Passer \xE0 un abonnement",
816
- ga: "Athraigh go s\xEDnti\xFAs",
817
- he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05DE\u05E0\u05D5\u05D9",
818
- hi: "\u0938\u0926\u0938\u094D\u092F\u0924\u093E \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902",
819
- id: "Beralih ke langganan",
820
- it: "Passa all\u2019abbonamento",
821
- ja: "\u5B9A\u671F\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u308B",
822
- ko: "\uAD6C\uB3C5\uC73C\uB85C \uC804\uD658",
823
- nl: "Overschakelen naar abonnement",
824
- no: "Bytt til abonnement",
825
- pl: "Prze\u0142\u0105cz na subskrypcj\u0119",
826
- pt: "Mudar para assinatura",
827
- ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0443",
828
- sv: "Byt till prenumeration",
829
- th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2A\u0E21\u0E31\u0E04\u0E23\u0E2A\u0E21\u0E32\u0E0A\u0E34\u0E01",
830
- tr: "Aboneli\u011Fe ge\xE7",
831
- uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043F\u0456\u0434\u043F\u0438\u0441\u043A\u0443",
832
- vi: "Chuy\u1EC3n sang \u0111\u0103ng k\xFD",
833
- zh: "\u5207\u6362\u4E3A\u8BA2\u9605"
834
- },
835
- switchToSubscriptionWithDiscount: {
836
- ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0627\u0634\u062A\u0631\u0627\u0643 \u0648\u062A\u0648\u0641\u064A\u0631 {{subscriptionDiscount}}%",
837
- cs: "P\u0159epnout na p\u0159edplatn\xE9 a u\u0161et\u0159it {{subscriptionDiscount}} %",
838
- da: "Skift til abonnement og spar {{subscriptionDiscount}}%",
839
- de: "Zu einem Abonnement wechseln und {{subscriptionDiscount}} % sparen",
840
- en: "Switch to Subscription & Save {{subscriptionDiscount}}%",
841
- es: "Cambiar a suscripci\xF3n y ahorrar {{subscriptionDiscount}}%",
842
- fi: "Vaihda tilaukseen ja s\xE4\xE4st\xE4 {{subscriptionDiscount}} %",
843
- fr: "Passer \xE0 un abonnement et \xE9conomiser {{subscriptionDiscount}} %",
844
- ga: "Athraigh go s\xEDnti\xFAs agus s\xE1bh\xE1il {{subscriptionDiscount}}%",
845
- he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05DE\u05E0\u05D5\u05D9 \u05D5\u05D7\u05E1\u05D5\u05DA {{subscriptionDiscount}}%",
846
- hi: "\u0938\u0926\u0938\u094D\u092F\u0924\u093E \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902 \u0914\u0930 {{subscriptionDiscount}}% \u092C\u091A\u093E\u090F\u0902",
847
- id: "Beralih ke langganan dan hemat {{subscriptionDiscount}}%",
848
- it: "Passa all\u2019abbonamento e risparmia {{subscriptionDiscount}}%",
849
- ja: "\u5B9A\u671F\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u3066{{subscriptionDiscount}}%\u304A\u5F97",
850
- ko: "\uAD6C\uB3C5\uC73C\uB85C \uC804\uD658\uD558\uACE0 {{subscriptionDiscount}}% \uC808\uC57D",
851
- nl: "Overschakelen naar abonnement en {{subscriptionDiscount}}% besparen",
852
- no: "Bytt til abonnement og spar {{subscriptionDiscount}}%",
853
- pl: "Prze\u0142\u0105cz na subskrypcj\u0119 i oszcz\u0119d\u017A {{subscriptionDiscount}}%",
854
- pt: "Mudar para assinatura e economizar {{subscriptionDiscount}}%",
855
- ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0443 \u0438 \u0441\u044D\u043A\u043E\u043D\u043E\u043C\u0438\u0442\u044C {{subscriptionDiscount}}%",
856
- sv: "Byt till prenumeration och spara {{subscriptionDiscount}}%",
857
- th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2A\u0E21\u0E31\u0E04\u0E23\u0E2A\u0E21\u0E32\u0E0A\u0E34\u0E01\u0E41\u0E25\u0E30\u0E1B\u0E23\u0E30\u0E2B\u0E22\u0E31\u0E14 {{subscriptionDiscount}}%",
858
- tr: "Aboneli\u011Fe ge\xE7 ve {{subscriptionDiscount}}% tasarruf et",
859
- uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043F\u0456\u0434\u043F\u0438\u0441\u043A\u0443 \u0442\u0430 \u0437\u0430\u043E\u0449\u0430\u0434\u0438\u0442\u0438 {{subscriptionDiscount}}%",
860
- vi: "Chuy\u1EC3n sang \u0111\u0103ng k\xFD v\xE0 ti\u1EBFt ki\u1EC7m {{subscriptionDiscount}}%",
861
- zh: "\u5207\u6362\u4E3A\u8BA2\u9605\u5E76\u8282\u7701 {{subscriptionDiscount}}%"
862
- }
863
- };
864
-
865
- // src/server/shared.ts
866
- var REBUY_ENGINE_HOST = "rebuyengine.com";
867
- var UpstreamError = class extends Error {
868
- constructor(status, body, message) {
869
- super(message ?? `Upstream returned ${status}`);
870
- this.body = body;
871
- this.name = "UpstreamError";
872
- this.status = status;
873
- }
874
- };
875
- var NotFoundError = class extends Error {
876
- constructor(message) {
877
- super(message);
878
- this.name = "NotFoundError";
879
- }
880
- };
828
+ );
829
+
830
+ // src/schema/widgets/checkout-and-beyond/image.ts
831
+ var CABImageSection = z21.object({
832
+ altText: z21.string().refine(checkForHTML, NO_HTML).default(""),
833
+ aspectRatio: z21.literal(1).nullable().default(null),
834
+ border: z21.lazy(() => CABBorder),
835
+ buttonField: z21.enum(buttonFields).optional(),
836
+ category: z21.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
837
+ name: z21.string().optional(),
838
+ naturalHeight: z21.number().default(0),
839
+ naturalWidth: z21.number().default(0),
840
+ /**
841
+ * `contain` (the component default): dimensionless images render in s-image's 1/1 default frame, and
842
+ * `cover` would crop non-square art (payment badges lost their edges — 15993); `contain` letterboxes.
843
+ */
844
+ objectFit: z21.enum(objectFits).default(ObjectFit.contain),
845
+ rule: CABRule.optional(),
846
+ sectionId: z21.uuid().default(() => uuidv713()),
847
+ sectionType: z21.literal(SectionType.image).default(SectionType.image),
848
+ source: z21.union([z21.url(), z21.literal(""), z21.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
849
+ width: z21.number().default(100)
850
+ });
881
851
 
882
852
  // src/transforms/contentBlockV1/stripContentBlockHtml.ts
883
853
  var HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
@@ -994,6 +964,31 @@ var convertContentBlockTextToV2 = (language) => {
994
964
  });
995
965
  };
996
966
 
967
+ // src/schema/widgets/checkout-and-beyond/root.ts
968
+ import { z as z22 } from "zod/v4";
969
+ var TargetArea = z22.object({
970
+ fill: z22.boolean().optional(),
971
+ flip: z22.enum(["both", "horizontal", "vertical"]).optional(),
972
+ icon: z22.string(),
973
+ label: z22.string(),
974
+ width: z22.string()
975
+ }).default(targetAreas[EditorMode.checkoutExtension][1]);
976
+ var CABTracking = z22.object({
977
+ enableAttribution: z22.boolean().default(true),
978
+ enableSource: z22.boolean().default(true),
979
+ enableWidget: z22.boolean().default(true)
980
+ }).default({ enableAttribution: true, enableSource: true, enableWidget: true });
981
+ var CABRootSection = CABLayoutSection.extend({
982
+ editorMode: z22.enum(editorModes).default(EditorMode.checkoutExtension),
983
+ previewMode: z22.boolean().default(false),
984
+ storeId: z22.number().nullable().default(null),
985
+ targetArea: TargetArea.nullable(),
986
+ tracking: CABTracking,
987
+ type: z22.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
988
+ version: z22.literal(2).default(2),
989
+ widgetId: z22.number().nullable().default(null)
990
+ });
991
+
997
992
  // src/transforms/contentBlockV1/convertContentBlockToV2.ts
998
993
  var LOCATION_TO_EDITOR_MODE = {
999
994
  checkout: "checkoutExtension",
@@ -1335,6 +1330,122 @@ var isCABRootSection = (input) => {
1335
1330
  return input.version === 2;
1336
1331
  };
1337
1332
 
1333
+ // src/schema/widgets/checkout-and-beyond/switchLabels.ts
1334
+ var SWITCH_LABELS = {
1335
+ subscriptionOption: {
1336
+ ar: "\u064A\u062A\u0645 \u0627\u0644\u062A\u0648\u0635\u064A\u0644 \u0643\u0644 {{frequency}} {{interval}}",
1337
+ cs: "Doru\u010Den\xED ka\u017Ed\xFDch {{frequency}} {{interval}}",
1338
+ da: "Leveres hver {{frequency}} {{interval}}",
1339
+ de: "Lieferung alle {{frequency}} {{interval}}",
1340
+ en: "Delivers every {{frequency}} {{interval}}",
1341
+ es: "Entrega cada {{frequency}} {{interval}}",
1342
+ fi: "Toimitus {{frequency}} {{interval}} v\xE4lein",
1343
+ fr: "Livraison tous les {{frequency}} {{interval}}",
1344
+ ga: "Seachadtar gach {{frequency}} {{interval}}",
1345
+ he: "\u05DE\u05E9\u05DC\u05D5\u05D7 \u05DB\u05DC {{frequency}} {{interval}}",
1346
+ hi: "\u0939\u0930 {{frequency}} {{interval}} \u092E\u0947\u0902 \u0921\u093F\u0932\u0940\u0935\u0930\u0940",
1347
+ id: "Dikirim setiap {{frequency}} {{interval}}",
1348
+ it: "Consegna ogni {{frequency}} {{interval}}",
1349
+ ja: "{{frequency}} {{interval}}\u3054\u3068\u306B\u304A\u5C4A\u3051",
1350
+ ko: "{{frequency}} {{interval}}\uB9C8\uB2E4 \uBC30\uC1A1",
1351
+ nl: "Wordt elke {{frequency}} {{interval}} geleverd",
1352
+ no: "Leveres hver {{frequency}} {{interval}}",
1353
+ pl: "Dostawa co {{frequency}} {{interval}}",
1354
+ pt: "Entrega a cada {{frequency}} {{interval}}",
1355
+ ru: "\u0414\u043E\u0441\u0442\u0430\u0432\u043A\u0430 \u043A\u0430\u0436\u0434\u044B\u0435 {{frequency}} {{interval}}",
1356
+ sv: "Levereras var {{frequency}} {{interval}}",
1357
+ th: "\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E17\u0E38\u0E01 {{frequency}} {{interval}}",
1358
+ tr: "Her {{frequency}} {{interval}} aral\u0131\u011F\u0131nda teslimat",
1359
+ uk: "\u0414\u043E\u0441\u0442\u0430\u0432\u043A\u0430 \u043A\u043E\u0436\u043D\u0456 {{frequency}} {{interval}}",
1360
+ vi: "Giao h\xE0ng m\u1ED7i {{frequency}} {{interval}}",
1361
+ zh: "\u6BCF {{frequency}} {{interval}} \u914D\u9001\u4E00\u6B21"
1362
+ },
1363
+ switchToOneTimePurchase: {
1364
+ ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0634\u0631\u0627\u0621 \u0644\u0645\u0631\u0629 \u0648\u0627\u062D\u062F\u0629",
1365
+ cs: "P\u0159epnout na jednor\xE1zov\xFD n\xE1kup",
1366
+ da: "Skift til engangsk\xF8b",
1367
+ de: "Zu einmaligem Kauf wechseln",
1368
+ en: "Switch to One-time Purchase",
1369
+ es: "Cambiar a compra \xFAnica",
1370
+ fi: "Vaihda kertaluonteiseen ostoon",
1371
+ fr: "Passer \xE0 un achat unique",
1372
+ ga: "Athraigh go ceannach aonuaire",
1373
+ he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05E8\u05DB\u05D9\u05E9\u05D4 \u05D7\u05D3-\u05E4\u05E2\u05DE\u05D9\u05EA",
1374
+ hi: "\u090F\u0915 \u092C\u093E\u0930 \u0915\u0940 \u0916\u0930\u0940\u0926 \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902",
1375
+ id: "Beralih ke pembelian satu kali",
1376
+ it: "Passa all\u2019acquisto una tantum",
1377
+ ja: "1\u56DE\u9650\u308A\u306E\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u308B",
1378
+ ko: "\uC77C\uD68C\uC131 \uAD6C\uB9E4\uB85C \uC804\uD658",
1379
+ nl: "Overschakelen naar eenmalige aankoop",
1380
+ no: "Bytt til engangskj\xF8p",
1381
+ pl: "Prze\u0142\u0105cz na jednorazowy zakup",
1382
+ pt: "Mudar para compra \xFAnica",
1383
+ ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u0440\u0430\u0437\u043E\u0432\u0443\u044E \u043F\u043E\u043A\u0443\u043F\u043A\u0443",
1384
+ sv: "Byt till eng\xE5ngsk\xF6p",
1385
+ th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E0B\u0E37\u0E49\u0E2D\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",
1386
+ tr: "Tek seferlik sat\u0131n almaya ge\xE7",
1387
+ uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043E\u0434\u043D\u043E\u0440\u0430\u0437\u043E\u0432\u0443 \u043F\u043E\u043A\u0443\u043F\u043A\u0443",
1388
+ vi: "Chuy\u1EC3n sang mua m\u1ED9t l\u1EA7n",
1389
+ zh: "\u5207\u6362\u4E3A\u4E00\u6B21\u6027\u8D2D\u4E70"
1390
+ },
1391
+ switchToSubscriptionNoDiscount: {
1392
+ ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0627\u0634\u062A\u0631\u0627\u0643",
1393
+ cs: "P\u0159epnout na p\u0159edplatn\xE9",
1394
+ da: "Skift til abonnement",
1395
+ de: "Zu einem Abonnement wechseln",
1396
+ en: "Switch to Subscription",
1397
+ es: "Cambiar a suscripci\xF3n",
1398
+ fi: "Vaihda tilaukseen",
1399
+ fr: "Passer \xE0 un abonnement",
1400
+ ga: "Athraigh go s\xEDnti\xFAs",
1401
+ he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05DE\u05E0\u05D5\u05D9",
1402
+ hi: "\u0938\u0926\u0938\u094D\u092F\u0924\u093E \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902",
1403
+ id: "Beralih ke langganan",
1404
+ it: "Passa all\u2019abbonamento",
1405
+ ja: "\u5B9A\u671F\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u308B",
1406
+ ko: "\uAD6C\uB3C5\uC73C\uB85C \uC804\uD658",
1407
+ nl: "Overschakelen naar abonnement",
1408
+ no: "Bytt til abonnement",
1409
+ pl: "Prze\u0142\u0105cz na subskrypcj\u0119",
1410
+ pt: "Mudar para assinatura",
1411
+ ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0443",
1412
+ sv: "Byt till prenumeration",
1413
+ th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2A\u0E21\u0E31\u0E04\u0E23\u0E2A\u0E21\u0E32\u0E0A\u0E34\u0E01",
1414
+ tr: "Aboneli\u011Fe ge\xE7",
1415
+ uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043F\u0456\u0434\u043F\u0438\u0441\u043A\u0443",
1416
+ vi: "Chuy\u1EC3n sang \u0111\u0103ng k\xFD",
1417
+ zh: "\u5207\u6362\u4E3A\u8BA2\u9605"
1418
+ },
1419
+ switchToSubscriptionWithDiscount: {
1420
+ ar: "\u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0625\u0644\u0649 \u0627\u0634\u062A\u0631\u0627\u0643 \u0648\u062A\u0648\u0641\u064A\u0631 {{subscriptionDiscount}}%",
1421
+ cs: "P\u0159epnout na p\u0159edplatn\xE9 a u\u0161et\u0159it {{subscriptionDiscount}} %",
1422
+ da: "Skift til abonnement og spar {{subscriptionDiscount}}%",
1423
+ de: "Zu einem Abonnement wechseln und {{subscriptionDiscount}} % sparen",
1424
+ en: "Switch to Subscription & Save {{subscriptionDiscount}}%",
1425
+ es: "Cambiar a suscripci\xF3n y ahorrar {{subscriptionDiscount}}%",
1426
+ fi: "Vaihda tilaukseen ja s\xE4\xE4st\xE4 {{subscriptionDiscount}} %",
1427
+ fr: "Passer \xE0 un abonnement et \xE9conomiser {{subscriptionDiscount}} %",
1428
+ ga: "Athraigh go s\xEDnti\xFAs agus s\xE1bh\xE1il {{subscriptionDiscount}}%",
1429
+ he: "\u05E2\u05D1\u05D5\u05E8 \u05DC\u05DE\u05E0\u05D5\u05D9 \u05D5\u05D7\u05E1\u05D5\u05DA {{subscriptionDiscount}}%",
1430
+ hi: "\u0938\u0926\u0938\u094D\u092F\u0924\u093E \u092A\u0930 \u0938\u094D\u0935\u093F\u091A \u0915\u0930\u0947\u0902 \u0914\u0930 {{subscriptionDiscount}}% \u092C\u091A\u093E\u090F\u0902",
1431
+ id: "Beralih ke langganan dan hemat {{subscriptionDiscount}}%",
1432
+ it: "Passa all\u2019abbonamento e risparmia {{subscriptionDiscount}}%",
1433
+ ja: "\u5B9A\u671F\u8CFC\u5165\u306B\u5207\u308A\u66FF\u3048\u3066{{subscriptionDiscount}}%\u304A\u5F97",
1434
+ ko: "\uAD6C\uB3C5\uC73C\uB85C \uC804\uD658\uD558\uACE0 {{subscriptionDiscount}}% \uC808\uC57D",
1435
+ nl: "Overschakelen naar abonnement en {{subscriptionDiscount}}% besparen",
1436
+ no: "Bytt til abonnement og spar {{subscriptionDiscount}}%",
1437
+ pl: "Prze\u0142\u0105cz na subskrypcj\u0119 i oszcz\u0119d\u017A {{subscriptionDiscount}}%",
1438
+ pt: "Mudar para assinatura e economizar {{subscriptionDiscount}}%",
1439
+ ru: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043D\u0430 \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0443 \u0438 \u0441\u044D\u043A\u043E\u043D\u043E\u043C\u0438\u0442\u044C {{subscriptionDiscount}}%",
1440
+ sv: "Byt till prenumeration och spara {{subscriptionDiscount}}%",
1441
+ th: "\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E2A\u0E21\u0E31\u0E04\u0E23\u0E2A\u0E21\u0E32\u0E0A\u0E34\u0E01\u0E41\u0E25\u0E30\u0E1B\u0E23\u0E30\u0E2B\u0E22\u0E31\u0E14 {{subscriptionDiscount}}%",
1442
+ tr: "Aboneli\u011Fe ge\xE7 ve {{subscriptionDiscount}}% tasarruf et",
1443
+ uk: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u043D\u0430 \u043F\u0456\u0434\u043F\u0438\u0441\u043A\u0443 \u0442\u0430 \u0437\u0430\u043E\u0449\u0430\u0434\u0438\u0442\u0438 {{subscriptionDiscount}}%",
1444
+ vi: "Chuy\u1EC3n sang \u0111\u0103ng k\xFD v\xE0 ti\u1EBFt ki\u1EC7m {{subscriptionDiscount}}%",
1445
+ zh: "\u5207\u6362\u4E3A\u8BA2\u9605\u5E76\u8282\u7701 {{subscriptionDiscount}}%"
1446
+ }
1447
+ };
1448
+
1338
1449
  // src/transforms/lineItemEditorV1/convertLineItemEditorToV2.ts
1339
1450
  var OVERRIDE_KEY = {
1340
1451
  subscriptionOption: "subscriptionOptionLabel",
@@ -1426,13 +1537,626 @@ var normalizeTextContent = (node) => {
1426
1537
  return node;
1427
1538
  };
1428
1539
 
1429
- // src/server/widgetSettings.ts
1540
+ // src/transforms/offerV1/types.ts
1541
+ var SHOPIFY_CHECKOUT_EXTENSION = "shopify_checkout_extension";
1542
+ var isOfferV1 = (data) => {
1543
+ if (!data || typeof data !== "object") return false;
1544
+ return data.type === SHOPIFY_CHECKOUT_EXTENSION;
1545
+ };
1546
+
1547
+ // src/schema/widgets/checkout-and-beyond/offerLabels.ts
1548
+ var OFFER_LABELS = {
1549
+ addToCart: {
1550
+ ar: "\u0623\u0636\u0641 \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629",
1551
+ cs: "P\u0159idat do ko\u0161\xEDku",
1552
+ da: "L\xE6g i kurv",
1553
+ de: "In den Warenkorb",
1554
+ en: "Add to cart",
1555
+ es: "A\xF1adir al carrito",
1556
+ fi: "Lis\xE4\xE4 ostoskoriin",
1557
+ fr: "Ajouter au panier",
1558
+ ga: "Cuir sa chairt",
1559
+ he: "\u05D4\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4",
1560
+ hi: "\u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u0947\u0902",
1561
+ id: "Tambahkan ke keranjang",
1562
+ it: "Aggiungi al carrello",
1563
+ ja: "\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",
1564
+ ko: "\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00",
1565
+ nl: "In winkelwagen",
1566
+ no: "Legg i handlekurven",
1567
+ pl: "Dodaj do koszyka",
1568
+ pt: "Adicionar ao carrinho",
1569
+ ru: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443",
1570
+ sv: "L\xE4gg i varukorgen",
1571
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32",
1572
+ tr: "Sepete ekle",
1573
+ uk: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0432 \u043A\u043E\u0448\u0438\u043A",
1574
+ vi: "Th\xEAm v\xE0o gi\u1ECF h\xE0ng",
1575
+ zh: "\u52A0\u5165\u8D2D\u7269\u8F66"
1576
+ },
1577
+ addedToCart: {
1578
+ ar: "\u062A\u0645\u062A \u0627\u0644\u0625\u0636\u0627\u0641\u0629!",
1579
+ cs: "P\u0159id\xE1no!",
1580
+ da: "Tilf\xF8jet!",
1581
+ de: "Hinzugef\xFCgt!",
1582
+ en: "Added!",
1583
+ es: "\xA1A\xF1adido!",
1584
+ fi: "Lis\xE4tty!",
1585
+ fr: "Ajout\xE9 !",
1586
+ ga: "Curtha leis!",
1587
+ he: "\u05E0\u05D5\u05E1\u05E3!",
1588
+ hi: "\u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E!",
1589
+ id: "Ditambahkan!",
1590
+ it: "Aggiunto!",
1591
+ ja: "\u8FFD\u52A0\u3057\u307E\u3057\u305F\uFF01",
1592
+ ko: "\uCD94\uAC00\uB428!",
1593
+ nl: "Toegevoegd!",
1594
+ no: "Lagt til!",
1595
+ pl: "Dodano!",
1596
+ pt: "Adicionado!",
1597
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E!",
1598
+ sv: "Tillagd!",
1599
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E41\u0E25\u0E49\u0E27!",
1600
+ tr: "Eklendi!",
1601
+ uk: "\u0414\u043E\u0434\u0430\u043D\u043E!",
1602
+ vi: "\u0110\xE3 th\xEAm!",
1603
+ zh: "\u5DF2\u6DFB\u52A0\uFF01"
1604
+ },
1605
+ addedToCartMessage: {
1606
+ ar: "\u062A\u0645\u062A \u0625\u0636\u0627\u0641\u0629 {{quantity}} {{productTitle}} \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629.",
1607
+ cs: "{{quantity}} {{productTitle}} p\u0159id\xE1no do ko\u0161\xEDku.",
1608
+ da: "{{quantity}} {{productTitle}} lagt i kurven.",
1609
+ de: "{{quantity}} {{productTitle}} zum Warenkorb hinzugef\xFCgt.",
1610
+ en: "{{quantity}} {{productTitle}} added to cart.",
1611
+ es: "{{quantity}} {{productTitle}} a\xF1adido al carrito.",
1612
+ fi: "{{quantity}} {{productTitle}} lis\xE4tty ostoskoriin.",
1613
+ fr: "{{quantity}} {{productTitle}} ajout\xE9 au panier.",
1614
+ ga: "Cuireadh {{quantity}} {{productTitle}} sa chairt.",
1615
+ he: "{{quantity}} {{productTitle}} \u05E0\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4.",
1616
+ hi: "{{quantity}} {{productTitle}} \u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E\u0964",
1617
+ id: "{{quantity}} {{productTitle}} ditambahkan ke keranjang.",
1618
+ it: "{{quantity}} {{productTitle}} aggiunto al carrello.",
1619
+ ja: "{{quantity}} {{productTitle}}\u3092\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0\u3057\u307E\u3057\u305F\u3002",
1620
+ ko: "{{quantity}} {{productTitle}}\uC774(\uAC00) \uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",
1621
+ nl: "{{quantity}} {{productTitle}} toegevoegd aan winkelwagen.",
1622
+ no: "{{quantity}} {{productTitle}} lagt i handlekurven.",
1623
+ pl: "{{quantity}} {{productTitle}} dodano do koszyka.",
1624
+ pt: "{{quantity}} {{productTitle}} adicionado ao carrinho.",
1625
+ ru: "{{quantity}} {{productTitle}} \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443.",
1626
+ sv: "{{quantity}} {{productTitle}} har lagts i varukorgen.",
1627
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21 {{quantity}} {{productTitle}} \u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32\u0E41\u0E25\u0E49\u0E27",
1628
+ tr: "{{quantity}} {{productTitle}} sepete eklendi.",
1629
+ uk: "{{quantity}} {{productTitle}} \u0434\u043E\u0434\u0430\u043D\u043E \u0434\u043E \u043A\u043E\u0448\u0438\u043A\u0430.",
1630
+ vi: "\u0110\xE3 th\xEAm {{quantity}} {{productTitle}} v\xE0o gi\u1ECF h\xE0ng.",
1631
+ zh: "{{quantity}} {{productTitle}} \u5DF2\u52A0\u5165\u8D2D\u7269\u8F66\u3002"
1632
+ },
1633
+ addingToCart: {
1634
+ ar: "\u062C\u0627\u0631\u064D \u0627\u0644\u0625\u0636\u0627\u0641\u0629...",
1635
+ cs: "P\u0159id\xE1v\xE1n\xED...",
1636
+ da: "Tilf\xF8jer...",
1637
+ de: "Wird hinzugef\xFCgt...",
1638
+ en: "Adding...",
1639
+ es: "A\xF1adiendo...",
1640
+ fi: "Lis\xE4t\xE4\xE4n...",
1641
+ fr: "Ajout en cours...",
1642
+ ga: "\xC1 chur leis...",
1643
+ he: "\u05DE\u05D5\u05E1\u05D9\u05E3...",
1644
+ hi: "\u091C\u094B\u0921\u093C\u093E \u091C\u093E \u0930\u0939\u093E \u0939\u0948...",
1645
+ id: "Menambahkan...",
1646
+ it: "Aggiunta in corso...",
1647
+ ja: "\u8FFD\u52A0\u4E2D...",
1648
+ ko: "\uCD94\uAC00 \uC911...",
1649
+ nl: "Toevoegen...",
1650
+ no: "Legger til...",
1651
+ pl: "Dodawanie...",
1652
+ pt: "Adicionando...",
1653
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435...",
1654
+ sv: "L\xE4gger till...",
1655
+ th: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E1E\u0E34\u0E48\u0E21...",
1656
+ tr: "Ekleniyor...",
1657
+ uk: "\u0414\u043E\u0434\u0430\u0432\u0430\u043D\u043D\u044F...",
1658
+ vi: "\u0110ang th\xEAm...",
1659
+ zh: "\u6B63\u5728\u6DFB\u52A0..."
1660
+ },
1661
+ soldOut: {
1662
+ ar: "\u0646\u0641\u062F\u062A \u0627\u0644\u0643\u0645\u064A\u0629",
1663
+ cs: "Vyprod\xE1no",
1664
+ da: "Udsolgt",
1665
+ de: "Ausverkauft",
1666
+ en: "Sold out",
1667
+ es: "Agotado",
1668
+ fi: "Loppuunmyyty",
1669
+ fr: "\xC9puis\xE9",
1670
+ ga: "D\xEDolta amach",
1671
+ he: "\u05D0\u05D6\u05DC \u05DE\u05D4\u05DE\u05DC\u05D0\u05D9",
1672
+ hi: "\u0938\u094D\u091F\u0949\u0915 \u0916\u093C\u0924\u094D\u092E",
1673
+ id: "Habis terjual",
1674
+ it: "Esaurito",
1675
+ ja: "\u58F2\u308A\u5207\u308C",
1676
+ ko: "\uD488\uC808",
1677
+ nl: "Uitverkocht",
1678
+ no: "Utsolgt",
1679
+ pl: "Wyprzedane",
1680
+ pt: "Esgotado",
1681
+ ru: "\u0420\u0430\u0441\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
1682
+ sv: "Sluts\xE5ld",
1683
+ th: "\u0E2A\u0E34\u0E19\u0E04\u0E49\u0E32\u0E2B\u0E21\u0E14",
1684
+ tr: "T\xFCkendi",
1685
+ uk: "\u0420\u043E\u0437\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
1686
+ vi: "H\u1EBFt h\xE0ng",
1687
+ zh: "\u5DF2\u552E\u7F44"
1688
+ },
1689
+ undo: {
1690
+ ar: "\u062A\u0631\u0627\u062C\u0639",
1691
+ cs: "Zp\u011Bt",
1692
+ da: "Fortryd",
1693
+ de: "R\xFCckg\xE4ngig",
1694
+ en: "Undo",
1695
+ es: "Deshacer",
1696
+ fi: "Kumoa",
1697
+ fr: "Annuler",
1698
+ ga: "Cealaigh",
1699
+ he: "\u05D1\u05D8\u05DC",
1700
+ hi: "\u092A\u0942\u0930\u094D\u0935\u0935\u0924 \u0915\u0930\u0947\u0902",
1701
+ id: "Urungkan",
1702
+ it: "Annulla",
1703
+ ja: "\u5143\u306B\u623B\u3059",
1704
+ ko: "\uC2E4\uD589 \uCDE8\uC18C",
1705
+ nl: "Ongedaan maken",
1706
+ no: "Angre",
1707
+ pl: "Cofnij",
1708
+ pt: "Desfazer",
1709
+ ru: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",
1710
+ sv: "\xC5ngra",
1711
+ th: "\u0E40\u0E25\u0E34\u0E01\u0E17\u0E33",
1712
+ tr: "Geri al",
1713
+ uk: "\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438",
1714
+ vi: "Ho\xE0n t\xE1c",
1715
+ zh: "\u64A4\u9500"
1716
+ }
1717
+ };
1718
+
1719
+ // src/transforms/offerV1/offerCard.ts
1720
+ var VARIANT_SELECTOR = { button: "button", radio: "radio", select: "menu" };
1721
+ var localizedContent = (defaults, override) => {
1722
+ const trimmed = override?.trim();
1723
+ return trimmed ? { ...defaults, en: trimmed } : defaults;
1724
+ };
1725
+ var buildStyledText = (token, style, color = "base") => {
1726
+ const marks = [
1727
+ { attrs: { color, fontSize: style?.textSize ?? "base" }, type: "textStyle" }
1728
+ ];
1729
+ if (style?.textEmphasis === "bold") marks.push({ type: "bold" });
1730
+ if (style?.textEmphasis === "italic") marks.push({ type: "italic" });
1731
+ return { content: [{ content: [{ marks, text: token, type: "text" }], type: "paragraph" }], type: "doc" };
1732
+ };
1733
+ var buildPriceContent = (settings) => {
1734
+ const content = [{ text: "{{variantPrice}}", type: "text" }];
1735
+ if (settings.discount?.showSavingAmount !== false) {
1736
+ content.push(
1737
+ { text: " ", type: "text" },
1738
+ {
1739
+ marks: [{ type: "strike" }, { attrs: { color: "subdued" }, type: "textStyle" }],
1740
+ text: "{{variantCompareAtPrice}}",
1741
+ type: "text"
1742
+ }
1743
+ );
1744
+ }
1745
+ return { content: [{ content, type: "paragraph" }], type: "doc" };
1746
+ };
1747
+ var buildReviews = (settings) => {
1748
+ if (!settings.integrations || !Object.values(settings.integrations).some(Boolean)) return [];
1749
+ const reviews = settings.displaySettings?.reviews;
1750
+ return [
1751
+ {
1752
+ ...reviews?.color && { color: reviews.color },
1753
+ sectionType: "reviews",
1754
+ ...reviews?.size && { size: reviews.size }
1755
+ }
1756
+ ];
1757
+ };
1758
+ var buildImage = (settings) => ({
1759
+ ...settings.displaySettings?.image?.imageFit && {
1760
+ objectFit: settings.displaySettings.image.imageFit
1761
+ },
1762
+ sectionType: "image",
1763
+ source: settings.images?.source === "product" ? "{{productImage}}" : "{{variantImage}}",
1764
+ width: 100
1765
+ });
1766
+ var buildTitle = (settings) => ({
1767
+ content: { en: buildStyledText("{{productTitle}}", settings.displaySettings?.product) },
1768
+ sectionType: "text"
1769
+ });
1770
+ var buildPrice = (settings) => ({
1771
+ content: { en: buildPriceContent(settings) },
1772
+ sectionType: "text"
1773
+ });
1774
+ var buildVariantTitle = (settings) => {
1775
+ const show = settings.productOptions?.showVariantTitle;
1776
+ if (!show || show === "hide") return [];
1777
+ return [
1778
+ {
1779
+ content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
1780
+ sectionType: "text"
1781
+ }
1782
+ ];
1783
+ };
1784
+ var buildDescription = (settings) => {
1785
+ const show = settings.productOptions?.showProductDescription;
1786
+ if (!show || show === "hide") return [];
1787
+ return [{ content: { en: buildStyledText("{{productDescription}}", void 0) }, sectionType: "text" }];
1788
+ };
1789
+ var buildVariants = (settings) => {
1790
+ if (settings.productOptions?.showVariantOptions === "never") return [];
1791
+ const selector = settings.viewOptions?.variantSelector;
1792
+ return [
1793
+ {
1794
+ hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
1795
+ ...selector && { selector: VARIANT_SELECTOR[selector] },
1796
+ sectionType: "variants"
1797
+ }
1798
+ ];
1799
+ };
1800
+ var QUANTITY_INPUT_TYPE = {
1801
+ "buttons-manual-input": "number",
1802
+ "dropdown-select": "select"
1803
+ };
1804
+ var buildQuantityErrors = (quantity) => {
1805
+ const en = {
1806
+ ...quantity.maxError && { max: quantity.maxError },
1807
+ ...quantity.minError && { min: quantity.minError },
1808
+ ...quantity.negativeError && { neg: quantity.negativeError }
1809
+ };
1810
+ return Object.keys(en).length ? { errorMessages: { en } } : {};
1811
+ };
1812
+ var buildQuantity = (settings) => {
1813
+ const quantity = settings.quantityInputs;
1814
+ if (!quantity?.enabled) return [];
1815
+ const inputType = quantity.type ? QUANTITY_INPUT_TYPE[quantity.type] : void 0;
1816
+ return [
1817
+ {
1818
+ ...buildQuantityErrors(quantity),
1819
+ ...inputType && { inputType },
1820
+ max: quantity.maxValue ?? 10,
1821
+ min: quantity.minValue ?? 1,
1822
+ sectionType: "quantity"
1823
+ }
1824
+ ];
1825
+ };
1826
+ var buildSubscriptionButton = (settings) => {
1827
+ if (settings.productType !== "both" && settings.productType !== "subscription") return [];
1828
+ const language = settings.language;
1829
+ const slot = (buttonField, override) => ({
1830
+ buttonField,
1831
+ content: localizedContent(SWITCH_LABELS[buttonField], override),
1832
+ sectionType: "text"
1833
+ });
1834
+ return [
1835
+ {
1836
+ action: "switchToSubscription",
1837
+ buttonStyle: "plain",
1838
+ sections: [
1839
+ slot("subscriptionOption", void 0),
1840
+ slot("switchToOneTimePurchase", language?.cartSwitchToOnetime),
1841
+ slot("switchToSubscriptionNoDiscount", language?.cartSwitchToSubscription),
1842
+ slot("switchToSubscriptionWithDiscount", language?.upgradeToSubscription)
1843
+ ],
1844
+ sectionType: "button"
1845
+ }
1846
+ ];
1847
+ };
1848
+ var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
1849
+ var buildAddButton = (settings) => {
1850
+ const kind = settings.button?.kind;
1851
+ const slot = (buttonField, override) => ({
1852
+ buttonField,
1853
+ content: localizedContent(OFFER_LABELS[buttonField], override),
1854
+ sectionType: "text"
1855
+ });
1856
+ return {
1857
+ action: "addToOrder",
1858
+ buttonStyle: BUTTON_KINDS2.includes(kind) ? kind : "primary",
1859
+ sections: [
1860
+ slot("addToCart", settings.language?.addToCart),
1861
+ slot("addingToCart", settings.language?.addingToCart),
1862
+ slot("addedToCart", settings.language?.addedToCart),
1863
+ slot("soldOut", settings.language?.soldOutLabel)
1864
+ ],
1865
+ sectionType: "button"
1866
+ };
1867
+ };
1868
+ var rowsLayout = (sections) => ({
1869
+ direction: "rows",
1870
+ sections,
1871
+ sectionType: "layout"
1872
+ });
1873
+ var buildOfferCard = (settings, horizontal) => {
1874
+ const image = buildImage(settings);
1875
+ const title = buildTitle(settings);
1876
+ const variantTitle = buildVariantTitle(settings);
1877
+ const price = buildPrice(settings);
1878
+ const description = buildDescription(settings);
1879
+ const reviews = buildReviews(settings);
1880
+ const variants = buildVariants(settings);
1881
+ const quantity = buildQuantity(settings);
1882
+ const subscription = buildSubscriptionButton(settings);
1883
+ const addButton = buildAddButton(settings);
1884
+ if (!horizontal) {
1885
+ return [
1886
+ image,
1887
+ title,
1888
+ ...variantTitle,
1889
+ price,
1890
+ ...description,
1891
+ ...reviews,
1892
+ ...variants,
1893
+ ...quantity,
1894
+ ...subscription,
1895
+ addButton
1896
+ ];
1897
+ }
1898
+ const info = rowsLayout([title, ...variantTitle, price, ...description, ...reviews, ...variants]);
1899
+ const actions = [...subscription, addButton];
1900
+ const actionsCell = actions.length === 1 ? actions[0] : rowsLayout(actions);
1901
+ const card = {
1902
+ direction: "grid",
1903
+ grid: { columns: ["15%", "fill", "auto"], rows: ["auto"] },
1904
+ sections: [image, info, actionsCell],
1905
+ sectionType: "layout"
1906
+ };
1907
+ return [card, ...quantity];
1908
+ };
1909
+
1910
+ // src/transforms/offerV1/convertOfferToV2.ts
1911
+ var LOCATION_TO_EDITOR_MODE2 = {
1912
+ checkout: "checkoutExtension",
1913
+ "order-status": "orderStatusPage",
1914
+ "thank-you": "thankYouPage"
1915
+ };
1916
+ var STYLE_TO_DIRECTION = {
1917
+ grid: "grid",
1918
+ line: "columns",
1919
+ list: "rows",
1920
+ none: "rows"
1921
+ };
1922
+ var directionForStyle = (style) => style ? STYLE_TO_DIRECTION[style] : "rows";
1923
+ var buildProductListLayout = (direction, columns) => direction === "grid" ? { direction, grid: { columns: Array.from({ length: Math.max(columns, 1) }, () => "fill"), rows: ["auto"] } } : { direction };
1924
+ var hasHeaderText = (language) => !!(language?.title || language?.superTitle || language?.description);
1925
+ var DISCOUNTED_FROM = {
1926
+ compare_at_price: "compare_at_price",
1927
+ original_price: "price",
1928
+ price: "price"
1929
+ };
1930
+ var buildDiscountSection = (discount) => {
1931
+ if (!discount?.type || discount.type === "none") return [];
1932
+ const discountedFrom = discount.discountedFrom ? DISCOUNTED_FROM[discount.discountedFrom] : void 0;
1933
+ return [
1934
+ {
1935
+ amount: discount.amount ?? 0,
1936
+ ...discount.discountedBy && { discountedBy: discount.discountedBy },
1937
+ ...discountedFrom && { discountedFrom },
1938
+ ...discount.message && { message: discount.message },
1939
+ ...discount.quantity != null && { quantity: discount.quantity },
1940
+ sectionType: "discount",
1941
+ type: discount.type
1942
+ }
1943
+ ];
1944
+ };
1945
+ var buildBanner = (language) => language?.successBannerEnabled ? [
1946
+ {
1947
+ color: "success",
1948
+ dismissible: true,
1949
+ sections: [
1950
+ {
1951
+ /**
1952
+ * A defined v1 message (RTE doc or string) passes through verbatim as `en`;
1953
+ * absent falls back to the localized defaults (P4 language policy).
1954
+ */
1955
+ content: language.successBannerMessageRte ? { ...OFFER_LABELS.addedToCartMessage, en: language.successBannerMessageRte } : OFFER_LABELS.addedToCartMessage,
1956
+ sectionType: "text"
1957
+ },
1958
+ {
1959
+ action: "undoAddToOrder",
1960
+ buttonStyle: "plain",
1961
+ sections: [{ buttonField: "buttonLabel", content: OFFER_LABELS.undo, sectionType: "text" }],
1962
+ sectionType: "button"
1963
+ }
1964
+ ],
1965
+ sectionType: "banner"
1966
+ }
1967
+ ] : [];
1968
+ var convertOfferToV2 = ({ id, name, settings }) => {
1969
+ const layout = settings.layout?.large ?? settings.layout?.medium ?? settings.layout?.small;
1970
+ const columns = layout?.columns ?? 1;
1971
+ const direction = directionForStyle(layout?.style);
1972
+ const listLayout = buildProductListLayout(direction, columns);
1973
+ const horizontalCard = direction === "rows";
1974
+ const dataSource = {
1975
+ ...settings.endpoint && { dataSourcePath: settings.endpoint },
1976
+ ...settings.integrations && { integrations: settings.integrations },
1977
+ ...settings.limit !== void 0 && { limit: settings.limit },
1978
+ matchVariant: !!settings.productOptions?.matchVariant,
1979
+ matchVariantOutOfStock: !!settings.productOptions?.matchVariantOutOfStock,
1980
+ ...settings.productType && { productType: settings.productType },
1981
+ sectionType: "dataSource",
1982
+ ...settings.treatAsGwp && { treatAsGwp: true }
1983
+ };
1984
+ const offers = {
1985
+ sections: [
1986
+ ...buildOfferCard(settings, horizontalCard),
1987
+ dataSource,
1988
+ ...buildDiscountSection(settings.discount),
1989
+ ...buildBanner(settings.language)
1990
+ ],
1991
+ sectionType: "offers"
1992
+ };
1993
+ const display = {
1994
+ autoAdvanceInterval: 0,
1995
+ itemsAtOnce: layout?.carousel ? columns : settings.limit ?? columns,
1996
+ ...listLayout,
1997
+ sections: [offers],
1998
+ sectionType: "carousel"
1999
+ };
2000
+ return CABRootSection.parse({
2001
+ direction: "rows",
2002
+ editorMode: LOCATION_TO_EDITOR_MODE2[settings.location ?? "checkout"],
2003
+ // The widget name is required by the admin save schema; carry the legacy widget's name through.
2004
+ ...name && { name },
2005
+ previewMode: settings.previewMode,
2006
+ sections: [
2007
+ ...hasHeaderText(settings.language) ? [{ content: { en: convertContentBlockTextToV2(settings.language) }, sectionType: "text" }] : [],
2008
+ display
2009
+ ],
2010
+ tracking: {
2011
+ enableAttribution: settings.tracking?.enableAttribution ?? true,
2012
+ enableSource: settings.tracking?.enableSource ?? true,
2013
+ enableWidget: settings.tracking?.enableWidget ?? true
2014
+ },
2015
+ type: SHOPIFY_CHECKOUT_EXTENSION,
2016
+ version: 2,
2017
+ widgetId: id
2018
+ });
2019
+ };
2020
+
2021
+ // src/transforms/parseShielded.ts
2022
+ var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(transform(convertNumericObjects(deepCamelCase(raw))));
2023
+
2024
+ // src/server/userConfig.ts
1430
2025
  var unwrapData = (body) => body && typeof body === "object" && "data" in body ? body.data : body;
2026
+ var isEmptyObject = (x) => x == null || typeof x === "object" && !Array.isArray(x) && Object.keys(x).length === 0;
2027
+ var isMissingShopPayload = (data) => {
2028
+ if (data == null || typeof data !== "object" || Array.isArray(data)) return true;
2029
+ return isEmptyObject(data.shop);
2030
+ };
2031
+ var fetchUserConfig = async (input, ctx) => {
2032
+ let upstream;
2033
+ try {
2034
+ upstream = await ctx.fetchUpstream("/api/v1/user/config", { shop: input.shop }, { host: ctx.host });
2035
+ } catch (err) {
2036
+ if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
2037
+ throw new NotFoundError(`Shop config not found: ${input.shop}`);
2038
+ }
2039
+ throw err;
2040
+ }
2041
+ const data = unwrapData(upstream);
2042
+ if (isMissingShopPayload(data)) throw new NotFoundError(`Shop config not found: ${input.shop}`);
2043
+ return parseShielded(UserConfig, data);
2044
+ };
2045
+
2046
+ // src/utilities.ts
2047
+ function serialize(obj) {
2048
+ const serialized = [];
2049
+ const add = (key, value) => {
2050
+ value = typeof value === "function" ? value() : value;
2051
+ value = value === null ? "" : value === void 0 ? "" : value;
2052
+ serialized[serialized.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
2053
+ };
2054
+ const buildParameters = (prefix, obj2) => {
2055
+ let i, key, len;
2056
+ if (prefix) {
2057
+ if (Array.isArray(obj2)) {
2058
+ for (i = 0, len = obj2.length; i < len; i++) {
2059
+ buildParameters(prefix + "[" + (typeof obj2[i] === "object" && obj2[i] ? i : "") + "]", obj2[i]);
2060
+ }
2061
+ } else if (Object.prototype.toString.call(obj2) === "[object Object]") {
2062
+ for (key in obj2) {
2063
+ buildParameters(prefix + "[" + key + "]", obj2[key]);
2064
+ }
2065
+ } else {
2066
+ add(prefix, obj2);
2067
+ }
2068
+ } else if (Array.isArray(obj2)) {
2069
+ for (i = 0, len = obj2.length; i < len; i++) {
2070
+ add(obj2[i].name, obj2[i].value);
2071
+ }
2072
+ } else {
2073
+ for (key in obj2) {
2074
+ buildParameters(key, obj2[key]);
2075
+ }
2076
+ }
2077
+ return serialized;
2078
+ };
2079
+ return buildParameters("", obj).join("&");
2080
+ }
2081
+
2082
+ // src/server/dataSourceResults.ts
2083
+ var encodeAttributes = (pairs = []) => encodeURIComponent(JSON.stringify(Object.fromEntries(pairs.map(({ key, value }) => [key, value ?? ""]))));
2084
+ var buildEngineParams = (input, key) => {
2085
+ const { cart, customerId, integrations, limit, productType, shop, visitorId } = input;
2086
+ const items = cart.items.map(({ productId, properties, quantity, subscriptionId, variantId }) => ({
2087
+ product_id: productId,
2088
+ properties: encodeAttributes(properties),
2089
+ quantity,
2090
+ ...subscriptionId && { subscription_id: subscriptionId },
2091
+ variant_id: variantId
2092
+ }));
2093
+ const itemCount = cart.items.reduce((total, { quantity }) => total + quantity, 0);
2094
+ const subtotal = cart.subtotal - (cart.discountTotal ?? 0);
2095
+ return {
2096
+ cart: {
2097
+ attributes: encodeAttributes(cart.attributes),
2098
+ /** `discount_code` rules match against this; React sends raw `useDiscountCodes()` as `[{code}]`. */
2099
+ ...cart.discountCodes?.length && { discount_codes: cart.discountCodes.map((code) => ({ code })) },
2100
+ item_count: itemCount,
2101
+ items,
2102
+ line_count: items.length,
2103
+ subtotal
2104
+ },
2105
+ cart_count: items.length,
2106
+ cart_item_count: itemCount,
2107
+ cart_line_count: items.length,
2108
+ cart_subtotal: subtotal,
2109
+ key,
2110
+ limit,
2111
+ metafields: Object.values(integrations ?? {}).some(Boolean) ? "yes" : "no",
2112
+ selling_plans: productType === "one-time" ? "no" : "yes",
2113
+ shop,
2114
+ ...customerId && { shopify_customer_id: customerId },
2115
+ shopify_product_ids: items.map(({ product_id: id }) => id).join(","),
2116
+ shopify_variant_ids: items.map(({ variant_id: id }) => id).join(","),
2117
+ ...visitorId && { uuid: visitorId }
2118
+ };
2119
+ };
2120
+ var dedupeById = (products) => {
2121
+ const seen = /* @__PURE__ */ new Set();
2122
+ return products.filter((product) => {
2123
+ const id = product.id;
2124
+ if (seen.has(id)) return false;
2125
+ seen.add(id);
2126
+ return true;
2127
+ });
2128
+ };
2129
+ var fetchDataSourceResults = async (input, ctx) => {
2130
+ const { shop } = await fetchUserConfig({ shop: input.shop }, ctx);
2131
+ let upstream;
2132
+ try {
2133
+ upstream = await ctx.fetchUpstream(
2134
+ `/api/v1${input.dataSourcePath}`,
2135
+ {},
2136
+ { host: ctx.host, search: serialize(buildEngineParams(input, shop.apiKey)) }
2137
+ );
2138
+ } catch (err) {
2139
+ if (err instanceof UpstreamError && (err.status === 404 || err.status === 410)) {
2140
+ throw new NotFoundError(`Data source not found: ${input.dataSourcePath}`);
2141
+ }
2142
+ throw err;
2143
+ }
2144
+ const raw = upstream && typeof upstream === "object" ? upstream : {};
2145
+ const products = Array.isArray(raw.data) ? deepCamelCase(raw.data) : [];
2146
+ return {
2147
+ metadata: raw.metadata == null ? null : deepCamelCase(raw.metadata),
2148
+ products: dedupeById(products)
2149
+ };
2150
+ };
2151
+
2152
+ // src/server/widgetSettings.ts
2153
+ var unwrapData2 = (body) => body && typeof body === "object" && "data" in body ? body.data : body;
1431
2154
  var isMissingUpstreamPayload = (data) => data == null || typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0;
1432
2155
  var dispatchWidgetTransform = (id, normalized) => {
1433
2156
  if (isCABRootSection(normalized)) return CABRootSection.parse(normalizeTextContent(normalized));
1434
2157
  if (isContentBlockV1(normalized)) return convertContentBlockToV2({ id, settings: normalized });
1435
2158
  if (isLineItemEditorV1(normalized)) return convertLineItemEditorToV2({ id, settings: normalized });
2159
+ if (isOfferV1(normalized)) return convertOfferToV2({ id, name: normalized.name, settings: normalized });
1436
2160
  return normalized;
1437
2161
  };
1438
2162
  var convertWidgetSettings = async (input, ctx) => {
@@ -1448,7 +2172,7 @@ var convertWidgetSettings = async (input, ctx) => {
1448
2172
  }
1449
2173
  throw err;
1450
2174
  }
1451
- const data = unwrapData(upstream);
2175
+ const data = unwrapData2(upstream);
1452
2176
  if (isMissingUpstreamPayload(data)) throw new NotFoundError(`Widget not found: ${input.id}`);
1453
2177
  return dispatchWidgetTransform(input.id, convertNumericObjects(deepCamelCase(data)));
1454
2178
  };
@@ -1456,6 +2180,9 @@ export {
1456
2180
  NotFoundError,
1457
2181
  REBUY_ENGINE_HOST,
1458
2182
  UpstreamError,
1459
- convertWidgetSettings
2183
+ buildEngineParams,
2184
+ convertWidgetSettings,
2185
+ fetchDataSourceResults,
2186
+ fetchUserConfig
1460
2187
  };
1461
2188
  //# sourceMappingURL=index.mjs.map