@drawbridge/components 0.1.46 → 0.1.48

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 (162) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain-shop.js +4 -1
  10. package/dist/bridge/form-subdomain-shop.mjs +4 -1
  11. package/dist/bridge/form-subdomain.js +24 -5
  12. package/dist/bridge/form-subdomain.mjs +25 -6
  13. package/dist/bridge/lib/age-gate.js +12 -0
  14. package/dist/bridge/lib/age-gate.mjs +11 -0
  15. package/dist/bridge/lib/cart.js +79 -0
  16. package/dist/bridge/lib/cart.mjs +48 -0
  17. package/dist/bridge/lib/checkout-kit.js +2 -32
  18. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  19. package/dist/bridge/lib/entry.js +41 -0
  20. package/dist/bridge/lib/entry.mjs +40 -0
  21. package/dist/bridge/product-tile.js +13 -6
  22. package/dist/bridge/product-tile.mjs +13 -6
  23. package/dist/bridge/template-layout.js +263 -129
  24. package/dist/bridge/template-layout.mjs +264 -130
  25. package/dist/bridge/template-modal.js +39 -74
  26. package/dist/bridge/template-modal.mjs +40 -75
  27. package/dist/dashboard/avatar.js +2 -3
  28. package/dist/dashboard/avatar.mjs +2 -3
  29. package/dist/dashboard/buttons-subscription.js +1 -1
  30. package/dist/dashboard/buttons-subscription.mjs +1 -1
  31. package/dist/dashboard/campaign-form.js +179 -155
  32. package/dist/dashboard/campaign-form.mjs +179 -155
  33. package/dist/dashboard/campaign-share.js +347 -0
  34. package/dist/dashboard/campaign-share.mjs +314 -0
  35. package/dist/dashboard/card-affiliate.js +1 -1
  36. package/dist/dashboard/card-affiliate.mjs +1 -1
  37. package/dist/dashboard/card-campaign-switch.js +4 -1
  38. package/dist/dashboard/card-campaign-switch.mjs +4 -1
  39. package/dist/dashboard/card-order.js +22 -4
  40. package/dist/dashboard/card-order.mjs +22 -4
  41. package/dist/dashboard/embed-stripe.js +145 -0
  42. package/dist/dashboard/embed-stripe.mjs +116 -0
  43. package/dist/dashboard/form-admin-provider.js +71 -17
  44. package/dist/dashboard/form-admin-provider.mjs +71 -17
  45. package/dist/dashboard/form-file-upload.js +3 -2
  46. package/dist/dashboard/form-file-upload.mjs +4 -3
  47. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  48. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  49. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  50. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  51. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  52. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  53. package/dist/dashboard/form-organization-campaign-page.js +73 -39
  54. package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
  55. package/dist/dashboard/form-organization-campaign.js +82 -0
  56. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  57. package/dist/dashboard/form-organization-connection.js +48 -6
  58. package/dist/dashboard/form-organization-connection.mjs +48 -7
  59. package/dist/dashboard/form-organization-product.js +1461 -0
  60. package/dist/dashboard/form-organization-product.mjs +1425 -0
  61. package/dist/dashboard/form-organization-workflow.js +72 -1
  62. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  63. package/dist/dashboard/form-otc.js +4 -5
  64. package/dist/dashboard/form-otc.mjs +4 -5
  65. package/dist/dashboard/form-stripe.js +12 -5
  66. package/dist/dashboard/form-stripe.mjs +12 -5
  67. package/dist/dashboard/input-combobox.js +6 -0
  68. package/dist/dashboard/input-combobox.mjs +6 -0
  69. package/dist/dashboard/input-fields.js +37 -161
  70. package/dist/dashboard/input-fields.mjs +37 -161
  71. package/dist/dashboard/input-file.js +21 -4
  72. package/dist/dashboard/input-file.mjs +21 -4
  73. package/dist/dashboard/input-font.js +2 -0
  74. package/dist/dashboard/input-font.mjs +2 -0
  75. package/dist/dashboard/input-gallery.js +201 -0
  76. package/dist/dashboard/input-gallery.mjs +172 -0
  77. package/dist/dashboard/input-group-ai.js +15 -3
  78. package/dist/dashboard/input-group-ai.mjs +15 -3
  79. package/dist/dashboard/lib/ab-tests.js +2 -2
  80. package/dist/dashboard/lib/ab-tests.mjs +2 -2
  81. package/dist/dashboard/lib/connection-controls.js +5 -2
  82. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  83. package/dist/dashboard/lib/form-page.js +1 -1
  84. package/dist/dashboard/lib/form-page.mjs +1 -1
  85. package/dist/dashboard/lib/menu.js +19 -0
  86. package/dist/dashboard/lib/menu.mjs +18 -0
  87. package/dist/dashboard/lib/products.js +169 -0
  88. package/dist/dashboard/lib/products.mjs +135 -0
  89. package/dist/dashboard/lib/settings-paths.js +35 -0
  90. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  91. package/dist/dashboard/lib/uppy.js +10 -1
  92. package/dist/dashboard/lib/uppy.mjs +11 -2
  93. package/dist/dashboard/menu.js +13 -2
  94. package/dist/dashboard/menu.mjs +13 -2
  95. package/dist/dashboard/order-sections.js +456 -6
  96. package/dist/dashboard/order-sections.mjs +453 -7
  97. package/dist/dashboard/preview.js +119 -52
  98. package/dist/dashboard/preview.mjs +119 -52
  99. package/dist/dashboard/provider-ui.js +9 -7
  100. package/dist/dashboard/provider-ui.mjs +9 -7
  101. package/dist/dashboard/recharts.js +10 -4
  102. package/dist/dashboard/recharts.mjs +10 -4
  103. package/dist/dashboard/shipping-rates.js +404 -0
  104. package/dist/dashboard/shipping-rates.mjs +371 -0
  105. package/dist/dashboard/template-buyer.js +301 -0
  106. package/dist/dashboard/template-buyer.mjs +267 -0
  107. package/dist/dashboard/template-dashboard.js +11 -1
  108. package/dist/dashboard/template-dashboard.mjs +11 -1
  109. package/dist/dashboard/template-design.js +209 -130
  110. package/dist/dashboard/template-design.mjs +210 -131
  111. package/dist/dashboard/template-ui.js +157 -55
  112. package/dist/dashboard/template-ui.mjs +158 -56
  113. package/dist/icons/flags.js +134 -0
  114. package/dist/icons/flags.mjs +115 -0
  115. package/dist/input-checkbox.js +28 -10
  116. package/dist/input-checkbox.mjs +28 -10
  117. package/dist/product.js +96 -24
  118. package/dist/product.mjs +97 -25
  119. package/dist/shared/carousel.js +14 -5
  120. package/dist/shared/carousel.mjs +14 -5
  121. package/dist/shared/lib/helpers.js +54 -6
  122. package/dist/shared/lib/helpers.mjs +53 -8
  123. package/dist/shared/order-summary.js +139 -0
  124. package/dist/shared/order-summary.mjs +110 -0
  125. package/package.json +84 -4
  126. package/types/bridge/cart-drawer.d.ts +31 -0
  127. package/types/bridge/fields.d.ts +14 -2
  128. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  129. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  130. package/types/bridge/form-subdomain.d.ts +13 -0
  131. package/types/bridge/lib/age-gate.d.ts +5 -0
  132. package/types/bridge/lib/cart.d.ts +44 -0
  133. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  134. package/types/bridge/lib/entry.d.ts +5 -0
  135. package/types/bridge/product-tile.d.ts +2 -0
  136. package/types/dashboard/campaign-share.d.ts +16 -0
  137. package/types/dashboard/card-order.d.ts +6 -0
  138. package/types/dashboard/embed-stripe.d.ts +25 -0
  139. package/types/dashboard/form-admin-provider.d.ts +9 -2
  140. package/types/dashboard/form-file-upload.d.ts +2 -1
  141. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  142. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  143. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  144. package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
  145. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  146. package/types/dashboard/form-organization-connection.d.ts +11 -0
  147. package/types/dashboard/form-organization-product.d.ts +24 -0
  148. package/types/dashboard/form-otc.d.ts +5 -1
  149. package/types/dashboard/form-stripe.d.ts +3 -2
  150. package/types/dashboard/input-combobox.d.ts +2 -0
  151. package/types/dashboard/input-file.d.ts +2 -0
  152. package/types/dashboard/input-gallery.d.ts +14 -0
  153. package/types/dashboard/lib/products.d.ts +14 -0
  154. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  155. package/types/dashboard/order-sections.d.ts +24 -1
  156. package/types/dashboard/preview.d.ts +11 -3
  157. package/types/dashboard/shipping-rates.d.ts +26 -0
  158. package/types/dashboard/template-buyer.d.ts +50 -0
  159. package/types/icons/flags.d.ts +5 -0
  160. package/types/input-checkbox.d.ts +2 -0
  161. package/types/shared/lib/helpers.d.ts +4 -0
  162. package/types/shared/order-summary.d.ts +19 -0
@@ -92,6 +92,7 @@ const FormSubdomainSubmission = ({
92
92
  message,
93
93
  panel,
94
94
  preview,
95
+ quiet,
95
96
  repeat,
96
97
  slug,
97
98
  style,
@@ -219,6 +220,7 @@ const FormSubdomainSubmission = ({
219
220
  ...{
220
221
  button,
221
222
  preview,
223
+ quiet,
222
224
  style,
223
225
  title
224
226
  }
@@ -233,6 +235,9 @@ const FormSubdomainMessage = ({
233
235
  button,
234
236
  message,
235
237
  preview,
238
+ // @story campaigns/form-page
239
+ // The dashboard's own previews show no Preview mode line ( Darren, 2026-11-21 ).
240
+ quiet,
236
241
  style,
237
242
  svg: Svg,
238
243
  title
@@ -254,7 +259,7 @@ const FormSubdomainMessage = ({
254
259
  }
255
260
  }
256
261
  ),
257
- Boolean(preview) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
+ Boolean(preview) && !quiet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
258
263
  import_error.default,
259
264
  {
260
265
  ...{
@@ -328,6 +333,7 @@ const FormSubdomainGeocode = ({
328
333
  disabled,
329
334
  callback,
330
335
  preview,
336
+ quiet,
331
337
  still,
332
338
  style,
333
339
  values
@@ -433,7 +439,7 @@ const FormSubdomainGeocode = ({
433
439
  }
434
440
  }
435
441
  ),
436
- Boolean(preview) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
442
+ Boolean(preview) && !quiet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
437
443
  import_error.default,
438
444
  {
439
445
  ...{
@@ -480,6 +486,7 @@ const FormSubdomainAge = ({
480
486
  },
481
487
  disabled,
482
488
  preview,
489
+ quiet,
483
490
  style,
484
491
  values
485
492
  }) => {
@@ -525,7 +532,7 @@ const FormSubdomainAge = ({
525
532
  }
526
533
  }
527
534
  ),
528
- Boolean(preview) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
535
+ Boolean(preview) && !quiet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
529
536
  import_error.default,
530
537
  {
531
538
  ...{
@@ -825,6 +832,7 @@ const FormSubdomainSection = ({
825
832
  last,
826
833
  onAgreement,
827
834
  preview,
835
+ quiet,
828
836
  refused,
829
837
  section,
830
838
  slugs = [],
@@ -1065,7 +1073,7 @@ const FormSubdomainSection = ({
1065
1073
  )
1066
1074
  }
1067
1075
  ),
1068
- Boolean(preview) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1076
+ Boolean(preview) && !quiet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1069
1077
  "div",
1070
1078
  {
1071
1079
  ...{
@@ -1236,9 +1244,15 @@ const FormSubdomain = ({
1236
1244
  },
1237
1245
  params,
1238
1246
  preview,
1247
+ // The dashboard's own previews show no Preview mode line.
1248
+ quiet,
1239
1249
  // @story public-entry/read-agreement
1240
1250
  // False while the campaign's giveaway is off ( lib/entry giveawayOn ).
1241
1251
  giveaway,
1252
+ // @story campaigns/form-page
1253
+ // The Form page's preview: an agreement open over the form, and the location step drawn still.
1254
+ read = null,
1255
+ still,
1242
1256
  // The share payload's `sms` : false while texts are off on the platform.
1243
1257
  sms,
1244
1258
  step: start = 0,
@@ -1254,7 +1268,7 @@ const FormSubdomain = ({
1254
1268
  const token = searchParams.get("drwbrdg_pre");
1255
1269
  const [data, setData] = (0, import_react.useState)({});
1256
1270
  const [step, setStep] = (0, import_react.useState)(start);
1257
- const [reading, setReading] = (0, import_react.useState)(null);
1271
+ const [reading, setReading] = (0, import_react.useState)(read);
1258
1272
  const [refused, setRefused] = (0, import_react.useState)(null);
1259
1273
  const sections = (0, import_order.sectionsOf)(fields);
1260
1274
  const slugs = sections.flatMap((section) => ((section == null ? void 0 : section.fields) || []).map((field) => field == null ? void 0 : field.slug));
@@ -1338,6 +1352,8 @@ const FormSubdomain = ({
1338
1352
  disabled,
1339
1353
  style,
1340
1354
  preview,
1355
+ quiet,
1356
+ still,
1341
1357
  values: params
1342
1358
  }
1343
1359
  },
@@ -1353,6 +1369,7 @@ const FormSubdomain = ({
1353
1369
  callback: (object) => {
1354
1370
  setData({
1355
1371
  ...data,
1372
+ fields: (0, import_age_gate.ageBirthday)(fields, data.fields, object == null ? void 0 : object.birthday),
1356
1373
  integrations: {
1357
1374
  ...data.integrations,
1358
1375
  ...object
@@ -1368,6 +1385,7 @@ const FormSubdomain = ({
1368
1385
  },
1369
1386
  disabled,
1370
1387
  preview,
1388
+ quiet,
1371
1389
  style,
1372
1390
  values: (_e = integrations == null ? void 0 : integrations.age) == null ? void 0 : _e.settings
1373
1391
  }
@@ -1401,6 +1419,7 @@ const FormSubdomain = ({
1401
1419
  last: index === sections.length - 1,
1402
1420
  onAgreement: setReading,
1403
1421
  preview,
1422
+ quiet,
1404
1423
  refused,
1405
1424
  section,
1406
1425
  slugs,
@@ -10,7 +10,7 @@ import { ordersItems } from "@drawbridge/drawbridge-utils/fields-validate";
10
10
  import { captureException } from "@drawbridge/drawbridge-telemetry/nextjs";
11
11
  import { useForm, useWatch, Controller } from "react-hook-form";
12
12
  import yup, { resolver } from "./lib/yup.mjs";
13
- import { ageFor, ageGateSchema } from "./lib/age-gate.mjs";
13
+ import { ageBirthday, ageFor, ageGateSchema } from "./lib/age-gate.mjs";
14
14
  import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
15
15
  import { assertRecaptcha } from "./lib/recaptcha.mjs";
16
16
  import { submissionEndpoint } from "./lib/url.mjs";
@@ -55,6 +55,7 @@ const FormSubdomainSubmission = ({
55
55
  message,
56
56
  panel,
57
57
  preview,
58
+ quiet,
58
59
  repeat,
59
60
  slug,
60
61
  style,
@@ -182,6 +183,7 @@ const FormSubdomainSubmission = ({
182
183
  ...{
183
184
  button,
184
185
  preview,
186
+ quiet,
185
187
  style,
186
188
  title
187
189
  }
@@ -196,6 +198,9 @@ const FormSubdomainMessage = ({
196
198
  button,
197
199
  message,
198
200
  preview,
201
+ // @story campaigns/form-page
202
+ // The dashboard's own previews show no Preview mode line ( Darren, 2026-11-21 ).
203
+ quiet,
199
204
  style,
200
205
  svg: Svg,
201
206
  title
@@ -217,7 +222,7 @@ const FormSubdomainMessage = ({
217
222
  }
218
223
  }
219
224
  ),
220
- Boolean(preview) && /* @__PURE__ */ jsx(
225
+ Boolean(preview) && !quiet && /* @__PURE__ */ jsx(
221
226
  Error,
222
227
  {
223
228
  ...{
@@ -291,6 +296,7 @@ const FormSubdomainGeocode = ({
291
296
  disabled,
292
297
  callback,
293
298
  preview,
299
+ quiet,
294
300
  still,
295
301
  style,
296
302
  values
@@ -396,7 +402,7 @@ const FormSubdomainGeocode = ({
396
402
  }
397
403
  }
398
404
  ),
399
- Boolean(preview) && /* @__PURE__ */ jsx(
405
+ Boolean(preview) && !quiet && /* @__PURE__ */ jsx(
400
406
  Error,
401
407
  {
402
408
  ...{
@@ -443,6 +449,7 @@ const FormSubdomainAge = ({
443
449
  },
444
450
  disabled,
445
451
  preview,
452
+ quiet,
446
453
  style,
447
454
  values
448
455
  }) => {
@@ -488,7 +495,7 @@ const FormSubdomainAge = ({
488
495
  }
489
496
  }
490
497
  ),
491
- Boolean(preview) && /* @__PURE__ */ jsx(
498
+ Boolean(preview) && !quiet && /* @__PURE__ */ jsx(
492
499
  Error,
493
500
  {
494
501
  ...{
@@ -788,6 +795,7 @@ const FormSubdomainSection = ({
788
795
  last,
789
796
  onAgreement,
790
797
  preview,
798
+ quiet,
791
799
  refused,
792
800
  section,
793
801
  slugs = [],
@@ -1028,7 +1036,7 @@ const FormSubdomainSection = ({
1028
1036
  )
1029
1037
  }
1030
1038
  ),
1031
- Boolean(preview) && /* @__PURE__ */ jsx(
1039
+ Boolean(preview) && !quiet && /* @__PURE__ */ jsx(
1032
1040
  "div",
1033
1041
  {
1034
1042
  ...{
@@ -1199,9 +1207,15 @@ const FormSubdomain = ({
1199
1207
  },
1200
1208
  params,
1201
1209
  preview,
1210
+ // The dashboard's own previews show no Preview mode line.
1211
+ quiet,
1202
1212
  // @story public-entry/read-agreement
1203
1213
  // False while the campaign's giveaway is off ( lib/entry giveawayOn ).
1204
1214
  giveaway,
1215
+ // @story campaigns/form-page
1216
+ // The Form page's preview: an agreement open over the form, and the location step drawn still.
1217
+ read = null,
1218
+ still,
1205
1219
  // The share payload's `sms` : false while texts are off on the platform.
1206
1220
  sms,
1207
1221
  step: start = 0,
@@ -1217,7 +1231,7 @@ const FormSubdomain = ({
1217
1231
  const token = searchParams.get("drwbrdg_pre");
1218
1232
  const [data, setData] = useState({});
1219
1233
  const [step, setStep] = useState(start);
1220
- const [reading, setReading] = useState(null);
1234
+ const [reading, setReading] = useState(read);
1221
1235
  const [refused, setRefused] = useState(null);
1222
1236
  const sections = sectionsOf(fields);
1223
1237
  const slugs = sections.flatMap((section) => ((section == null ? void 0 : section.fields) || []).map((field) => field == null ? void 0 : field.slug));
@@ -1301,6 +1315,8 @@ const FormSubdomain = ({
1301
1315
  disabled,
1302
1316
  style,
1303
1317
  preview,
1318
+ quiet,
1319
+ still,
1304
1320
  values: params
1305
1321
  }
1306
1322
  },
@@ -1316,6 +1332,7 @@ const FormSubdomain = ({
1316
1332
  callback: (object) => {
1317
1333
  setData({
1318
1334
  ...data,
1335
+ fields: ageBirthday(fields, data.fields, object == null ? void 0 : object.birthday),
1319
1336
  integrations: {
1320
1337
  ...data.integrations,
1321
1338
  ...object
@@ -1331,6 +1348,7 @@ const FormSubdomain = ({
1331
1348
  },
1332
1349
  disabled,
1333
1350
  preview,
1351
+ quiet,
1334
1352
  style,
1335
1353
  values: (_e = integrations == null ? void 0 : integrations.age) == null ? void 0 : _e.settings
1336
1354
  }
@@ -1364,6 +1382,7 @@ const FormSubdomain = ({
1364
1382
  last: index === sections.length - 1,
1365
1383
  onAgreement: setReading,
1366
1384
  preview,
1385
+ quiet,
1367
1386
  refused,
1368
1387
  section,
1369
1388
  slugs,
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var age_gate_exports = {};
29
29
  __export(age_gate_exports, {
30
+ ageBirthday: () => ageBirthday,
30
31
  ageFor: () => ageFor,
31
32
  ageGateSchema: () => ageGateSchema
32
33
  });
@@ -48,8 +49,19 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
48
49
  })
49
50
  });
50
51
  };
52
+ const ageBirthday = (fields, answers = {}, birthday) => {
53
+ const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
54
+ const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
55
+ const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
56
+ if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
57
+ return {
58
+ ...answers,
59
+ [field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
60
+ };
61
+ };
51
62
  // Annotate the CommonJS export names for ESM import in node:
52
63
  0 && (module.exports = {
64
+ ageBirthday,
53
65
  ageFor,
54
66
  ageGateSchema
55
67
  });
@@ -15,7 +15,18 @@ const ageGateSchema = (values, currentYear = (/* @__PURE__ */ new Date()).getFul
15
15
  })
16
16
  });
17
17
  };
18
+ const ageBirthday = (fields, answers = {}, birthday) => {
19
+ const sections = Array.isArray(fields == null ? void 0 : fields.sections) ? fields.sections : [];
20
+ const field = sections.flatMap((section) => (section == null ? void 0 : section.fields) || []).find((item) => (item == null ? void 0 : item.slug) === "birthday");
21
+ const [month, day, year] = typeof birthday === "string" ? birthday.split("/") : [];
22
+ if (!(field == null ? void 0 : field.id) || (answers == null ? void 0 : answers[field.id]) || !(month && day && year)) return answers;
23
+ return {
24
+ ...answers,
25
+ [field.id]: [year, month.padStart(2, "0"), day.padStart(2, "0")].join("-")
26
+ };
27
+ };
18
28
  export {
29
+ ageBirthday,
19
30
  ageFor,
20
31
  ageGateSchema
21
32
  };
@@ -0,0 +1,79 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var cart_exports = {};
19
+ __export(cart_exports, {
20
+ canCheckout: () => canCheckout,
21
+ cartAlive: () => cartAlive,
22
+ cartCount: () => cartCount,
23
+ cartKey: () => cartKey,
24
+ continueRequest: () => continueRequest,
25
+ lineNote: () => lineNote,
26
+ productImage: () => productImage,
27
+ recommendedRow: () => recommendedRow,
28
+ withQuantity: () => withQuantity
29
+ });
30
+ module.exports = __toCommonJS(cart_exports);
31
+ var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
32
+ var import_products = require("@drawbridge/drawbridge-utils/products");
33
+ const cartKey = ({ campaign, subdomain }) => "drawbridge.cart." + subdomain + "." + campaign;
34
+ const DAY = 24 * 60 * 60 * 1e3;
35
+ const cartAlive = (made, now = Date.now()) => Number.isFinite(Number(made)) && Number(made) > 0 && now - Number(made) <= import_products.CART_DAYS * DAY;
36
+ const cartCount = (cart) => ((cart == null ? void 0 : cart.lines) || []).reduce((sum, line) => sum + ((line == null ? void 0 : line.quantity) || 0), 0);
37
+ const withQuantity = (cart, id, quantity) => cart && {
38
+ ...cart,
39
+ lines: (cart.lines || []).map((line) => line.id === id ? { ...line, quantity } : line).filter((line) => line.quantity > 0)
40
+ };
41
+ const lineNote = (line, cut = []) => (line == null ? void 0 : line.availableForSale) === false ? "Sold out" : (cut || []).includes(line == null ? void 0 : line.id) && Number.isFinite(line == null ? void 0 : line.left) ? "Only " + line.left + " left" : null;
42
+ const canCheckout = (cart) => ((cart == null ? void 0 : cart.lines) || []).length > 0 && !cart.lines.some((line) => line.availableForSale === false);
43
+ const continueRequest = ({ cartId, email, params, preview = false }) => !preview && cartId ? {
44
+ body: {
45
+ cartId,
46
+ email
47
+ },
48
+ endpoint: "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart",
49
+ method: "PUT"
50
+ } : null;
51
+ const productImage = (product, size) => {
52
+ var _a;
53
+ const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
54
+ const first = (_a = product == null ? void 0 : product.images) == null ? void 0 : _a[0];
55
+ const file = (first == null ? void 0 : first.file) && typeof first.file === "object" ? first.file : null;
56
+ return file && ((0, import_cdn.cdnSrc)(file, size, file.updatedAt) || (0, import_cdn.cdnSrc)(file, "original", file.updatedAt)) || (first == null ? void 0 : first.url) || (variant == null ? void 0 : variant.image) || (product == null ? void 0 : product.image) || null;
57
+ };
58
+ const recommendedRow = (product) => {
59
+ const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
60
+ return {
61
+ currency: (variant == null ? void 0 : variant.currency) || null,
62
+ id: product == null ? void 0 : product.id,
63
+ image: productImage(product, "100x100"),
64
+ price: Number.isFinite(variant == null ? void 0 : variant.price) ? variant.price : null,
65
+ title: (product == null ? void 0 : product.title) || ""
66
+ };
67
+ };
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ canCheckout,
71
+ cartAlive,
72
+ cartCount,
73
+ cartKey,
74
+ continueRequest,
75
+ lineNote,
76
+ productImage,
77
+ recommendedRow,
78
+ withQuantity
79
+ });
@@ -0,0 +1,48 @@
1
+ import { cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
2
+ import { CART_DAYS } from "@drawbridge/drawbridge-utils/products";
3
+ const cartKey = ({ campaign, subdomain }) => "drawbridge.cart." + subdomain + "." + campaign;
4
+ const DAY = 24 * 60 * 60 * 1e3;
5
+ const cartAlive = (made, now = Date.now()) => Number.isFinite(Number(made)) && Number(made) > 0 && now - Number(made) <= CART_DAYS * DAY;
6
+ const cartCount = (cart) => ((cart == null ? void 0 : cart.lines) || []).reduce((sum, line) => sum + ((line == null ? void 0 : line.quantity) || 0), 0);
7
+ const withQuantity = (cart, id, quantity) => cart && {
8
+ ...cart,
9
+ lines: (cart.lines || []).map((line) => line.id === id ? { ...line, quantity } : line).filter((line) => line.quantity > 0)
10
+ };
11
+ const lineNote = (line, cut = []) => (line == null ? void 0 : line.availableForSale) === false ? "Sold out" : (cut || []).includes(line == null ? void 0 : line.id) && Number.isFinite(line == null ? void 0 : line.left) ? "Only " + line.left + " left" : null;
12
+ const canCheckout = (cart) => ((cart == null ? void 0 : cart.lines) || []).length > 0 && !cart.lines.some((line) => line.availableForSale === false);
13
+ const continueRequest = ({ cartId, email, params, preview = false }) => !preview && cartId ? {
14
+ body: {
15
+ cartId,
16
+ email
17
+ },
18
+ endpoint: "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart",
19
+ method: "PUT"
20
+ } : null;
21
+ const productImage = (product, size) => {
22
+ var _a;
23
+ const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
24
+ const first = (_a = product == null ? void 0 : product.images) == null ? void 0 : _a[0];
25
+ const file = (first == null ? void 0 : first.file) && typeof first.file === "object" ? first.file : null;
26
+ return file && (cdnSrc(file, size, file.updatedAt) || cdnSrc(file, "original", file.updatedAt)) || (first == null ? void 0 : first.url) || (variant == null ? void 0 : variant.image) || (product == null ? void 0 : product.image) || null;
27
+ };
28
+ const recommendedRow = (product) => {
29
+ const variant = ((product == null ? void 0 : product.variants) || []).find((item) => (item == null ? void 0 : item.availableForSale) !== false) || null;
30
+ return {
31
+ currency: (variant == null ? void 0 : variant.currency) || null,
32
+ id: product == null ? void 0 : product.id,
33
+ image: productImage(product, "100x100"),
34
+ price: Number.isFinite(variant == null ? void 0 : variant.price) ? variant.price : null,
35
+ title: (product == null ? void 0 : product.title) || ""
36
+ };
37
+ };
38
+ export {
39
+ canCheckout,
40
+ cartAlive,
41
+ cartCount,
42
+ cartKey,
43
+ continueRequest,
44
+ lineNote,
45
+ productImage,
46
+ recommendedRow,
47
+ withQuantity
48
+ };
@@ -31,7 +31,6 @@ __export(checkout_kit_exports, {
31
31
  ensureCheckoutKit: () => ensureCheckoutKit
32
32
  });
33
33
  module.exports = __toCommonJS(checkout_kit_exports);
34
- var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
35
34
  var import_inapp_spy = __toESM(require("inapp-spy"));
36
35
  let registration = null;
37
36
  const ensureCheckoutKit = () => {
@@ -84,42 +83,13 @@ const openCheckoutPopup = ({ checkoutUrl, onClose, onComplete }) => {
84
83
  return true;
85
84
  };
86
85
  const checkout = async ({
87
- advertisement,
88
- affiliate,
89
- campaign,
90
86
  checkoutUrl,
91
- lines,
92
87
  onClose,
93
88
  onComplete,
94
89
  onOpen,
95
- onRedirect,
96
- organization,
97
- page,
98
- slug,
99
- subdomain
90
+ onRedirect
100
91
  }) => {
101
- let url = checkoutUrl;
102
- if (!url && lines) {
103
- const attributes = [
104
- ...campaign ? [{ key: "_drwbrdg_ca", value: campaign }] : [],
105
- ...organization ? [{ key: "_drwbrdg_or", value: organization }] : [],
106
- ...advertisement ? [{ key: "_drwbrdg_ad", value: advertisement }] : [],
107
- ...affiliate ? [{ key: "_drwbrdg_af", value: affiliate }] : [],
108
- ...page ? [{ key: "_drwbrdg_pg", value: page }] : []
109
- ];
110
- const { result } = await (0, import_fetch.request)({
111
- body: {
112
- lines: lines.map((line) => ({
113
- ...line,
114
- attributes
115
- }))
116
- },
117
- endpoint: "/subdomain/" + subdomain + "/page/" + slug + "/cart",
118
- method: "POST"
119
- });
120
- url = result == null ? void 0 : result.checkoutUrl;
121
- }
122
- ;
92
+ const url = checkoutUrl;
123
93
  if (!url) return null;
124
94
  const opened = openCheckoutPopup({
125
95
  checkoutUrl: url,
@@ -1,4 +1,3 @@
1
- import { request } from "@drawbridge/drawbridge-utils/fetch";
2
1
  import InAppSpy from "inapp-spy";
3
2
  let registration = null;
4
3
  const ensureCheckoutKit = () => {
@@ -51,42 +50,13 @@ const openCheckoutPopup = ({ checkoutUrl, onClose, onComplete }) => {
51
50
  return true;
52
51
  };
53
52
  const checkout = async ({
54
- advertisement,
55
- affiliate,
56
- campaign,
57
53
  checkoutUrl,
58
- lines,
59
54
  onClose,
60
55
  onComplete,
61
56
  onOpen,
62
- onRedirect,
63
- organization,
64
- page,
65
- slug,
66
- subdomain
57
+ onRedirect
67
58
  }) => {
68
- let url = checkoutUrl;
69
- if (!url && lines) {
70
- const attributes = [
71
- ...campaign ? [{ key: "_drwbrdg_ca", value: campaign }] : [],
72
- ...organization ? [{ key: "_drwbrdg_or", value: organization }] : [],
73
- ...advertisement ? [{ key: "_drwbrdg_ad", value: advertisement }] : [],
74
- ...affiliate ? [{ key: "_drwbrdg_af", value: affiliate }] : [],
75
- ...page ? [{ key: "_drwbrdg_pg", value: page }] : []
76
- ];
77
- const { result } = await request({
78
- body: {
79
- lines: lines.map((line) => ({
80
- ...line,
81
- attributes
82
- }))
83
- },
84
- endpoint: "/subdomain/" + subdomain + "/page/" + slug + "/cart",
85
- method: "POST"
86
- });
87
- url = result == null ? void 0 : result.checkoutUrl;
88
- }
89
- ;
59
+ const url = checkoutUrl;
90
60
  if (!url) return null;
91
61
  const opened = openCheckoutPopup({
92
62
  checkoutUrl: url,
@@ -34,11 +34,13 @@ __export(entry_exports, {
34
34
  giveawayOn: () => giveawayOn,
35
35
  menuAgreements: () => menuAgreements,
36
36
  panelMissions: () => panelMissions,
37
+ previewStep: () => previewStep,
37
38
  termsOptOut: () => termsOptOut,
38
39
  withLocale: () => withLocale
39
40
  });
40
41
  module.exports = __toCommonJS(entry_exports);
41
42
  var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
43
+ var import_order = require("./order");
42
44
  const copy = (data, key) => {
43
45
  var _a, _b, _c, _d, _e;
44
46
  return ((_a = data == null ? void 0 : data.defaults) == null ? void 0 : _a[key]) || ((_e = (_d = (_c = (_b = import_drawbridge_utils.constants) == null ? void 0 : _b.campaign) == null ? void 0 : _c.form) == null ? void 0 : _d.copy) == null ? void 0 : _e[key === "purchase" ? "order" : key]);
@@ -67,6 +69,44 @@ const afterOrder = (data) => {
67
69
  const order = (data == null ? void 0 : data.after) || ((_a = data == null ? void 0 : data.form) == null ? void 0 : _a.after);
68
70
  return Array.isArray(order) && order.length > 0 ? order : AFTER;
69
71
  };
72
+ const previewStep = (data, open = {}) => {
73
+ var _a, _b, _c, _d;
74
+ const { panel, state, step } = open;
75
+ if (!formOn(data)) return { face: null, modal: false };
76
+ if (step === "start") return { face: state || null, modal: false };
77
+ if (step === "after") return {
78
+ face: null,
79
+ modal: true,
80
+ panel: {
81
+ name: "submission",
82
+ data: {
83
+ after: afterOrder(data),
84
+ // The missions show while the giveaway is on, before entries are
85
+ // awarded too: what entrants will see once it runs ( Darren, 2026-11-21 ).
86
+ giveaway: giveawayOn(data),
87
+ message: copy(data, state === "order" ? "purchase" : state || "confirmation"),
88
+ panel: panel || {},
89
+ repeat: state === "rejection"
90
+ }
91
+ }
92
+ };
93
+ const geocode = Boolean((_b = (_a = data == null ? void 0 : data.integrations) == null ? void 0 : _a.geocode) == null ? void 0 : _b.enabled);
94
+ const before = Number(geocode) + Number(Boolean((_d = (_c = data == null ? void 0 : data.integrations) == null ? void 0 : _c.age) == null ? void 0 : _d.enabled));
95
+ const sections = (0, import_order.sectionsOf)(data == null ? void 0 : data.fields);
96
+ const index = sections.findIndex((section) => (section == null ? void 0 : section.id) === step);
97
+ const at = step === "location" ? 0 : step === "age" ? Number(geocode) : step === "agreements" ? before + sections.length - 1 : before + Math.max(index, 0);
98
+ return {
99
+ face: null,
100
+ modal: true,
101
+ panel: {
102
+ name: "enter",
103
+ ...step === "agreements" && state && {
104
+ read: state
105
+ },
106
+ step: at
107
+ }
108
+ };
109
+ };
70
110
  const panelMissions = (missions = [], repeat = false) => repeat ? (missions || []).filter((item) => (item == null ? void 0 : item.type) !== "form") : missions;
71
111
  const agreementTitles = {
72
112
  terms: "Terms and conditions",
@@ -122,6 +162,7 @@ const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If
122
162
  giveawayOn,
123
163
  menuAgreements,
124
164
  panelMissions,
165
+ previewStep,
125
166
  termsOptOut,
126
167
  withLocale
127
168
  });