@tagadapay/plugin-sdk 4.0.0 → 4.0.4

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 (65) hide show
  1. package/README.md +1129 -1129
  2. package/build-cdn.js +499 -499
  3. package/dist/external-tracker.js +156 -2
  4. package/dist/external-tracker.min.js +2 -2
  5. package/dist/external-tracker.min.js.map +4 -4
  6. package/dist/react/providers/TagadaProvider.js +5 -5
  7. package/dist/tagada-react-sdk-minimal.min.js +2 -2
  8. package/dist/tagada-react-sdk-minimal.min.js.map +4 -4
  9. package/dist/tagada-react-sdk.js +707 -253
  10. package/dist/tagada-react-sdk.min.js +2 -2
  11. package/dist/tagada-react-sdk.min.js.map +4 -4
  12. package/dist/tagada-sdk.js +2922 -102
  13. package/dist/tagada-sdk.min.js +2 -2
  14. package/dist/tagada-sdk.min.js.map +4 -4
  15. package/dist/v2/core/funnelClient.d.ts +40 -0
  16. package/dist/v2/core/funnelClient.js +30 -0
  17. package/dist/v2/core/pixelTracker.d.ts +51 -0
  18. package/dist/v2/core/pixelTracker.js +425 -0
  19. package/dist/v2/core/resources/checkout.d.ts +45 -1
  20. package/dist/v2/core/resources/checkout.js +13 -3
  21. package/dist/v2/core/resources/offers.d.ts +3 -3
  22. package/dist/v2/core/resources/offers.js +11 -3
  23. package/dist/v2/core/resources/promotionEvents.d.ts +5 -0
  24. package/dist/v2/core/resources/promotionEvents.js +2 -0
  25. package/dist/v2/core/resources/promotions.d.ts +6 -1
  26. package/dist/v2/core/resources/promotions.js +6 -1
  27. package/dist/v2/core/resources/shippingRates.d.ts +18 -0
  28. package/dist/v2/core/resources/shippingRates.js +18 -0
  29. package/dist/v2/core/utils/clickIdResolver.d.ts +79 -0
  30. package/dist/v2/core/utils/clickIdResolver.js +169 -0
  31. package/dist/v2/core/utils/index.d.ts +2 -0
  32. package/dist/v2/core/utils/index.js +4 -0
  33. package/dist/v2/core/utils/metaEventId.d.ts +14 -0
  34. package/dist/v2/core/utils/metaEventId.js +16 -0
  35. package/dist/v2/core/utils/previewModeIndicator.js +101 -101
  36. package/dist/v2/index.d.ts +7 -0
  37. package/dist/v2/index.js +10 -0
  38. package/dist/v2/react/components/ApplePayButton.js +50 -0
  39. package/dist/v2/react/components/FunnelScriptInjector.js +9 -9
  40. package/dist/v2/react/components/GooglePayButton.js +39 -1
  41. package/dist/v2/react/components/StripeExpressButton.js +54 -2
  42. package/dist/v2/react/hooks/payment-actions/useNgeniusThreedsAction.js +11 -11
  43. package/dist/v2/react/hooks/useCheckoutQuery.js +41 -29
  44. package/dist/v2/react/hooks/useDiscountsQuery.js +4 -0
  45. package/dist/v2/react/hooks/useFunnel.d.ts +7 -0
  46. package/dist/v2/react/hooks/useFunnel.js +2 -1
  47. package/dist/v2/react/hooks/useOfferQuery.d.ts +11 -0
  48. package/dist/v2/react/hooks/useOfferQuery.js +11 -0
  49. package/dist/v2/react/hooks/usePixelTracking.d.ts +10 -5
  50. package/dist/v2/react/hooks/usePixelTracking.js +32 -374
  51. package/dist/v2/react/hooks/usePreviewOffer.d.ts +3 -1
  52. package/dist/v2/react/hooks/usePreviewOffer.js +4 -2
  53. package/dist/v2/react/hooks/usePromotionsQuery.js +9 -3
  54. package/dist/v2/react/hooks/useShippingRatesQuery.js +36 -21
  55. package/dist/v2/react/hooks/useStepConfig.d.ts +9 -0
  56. package/dist/v2/react/hooks/useStepConfig.js +5 -1
  57. package/dist/v2/react/index.d.ts +5 -0
  58. package/dist/v2/react/index.js +9 -0
  59. package/dist/v2/react/providers/TagadaProvider.js +18 -5
  60. package/dist/v2/standalone/apple-pay-service.d.ts +1 -1
  61. package/dist/v2/standalone/index.d.ts +3 -0
  62. package/dist/v2/standalone/index.js +23 -0
  63. package/dist/v2/standalone/payment-service.d.ts +54 -1
  64. package/dist/v2/standalone/payment-service.js +228 -61
  65. package/package.json +115 -115
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TagadaPay React SDK v4.0.0
2
+ * TagadaPay React SDK v4.0.4
3
3
  * CDN Bundle - React hooks and TagadaProvider (Debug Build)
4
4
  * @license MIT
5
5
  */
@@ -3391,6 +3391,26 @@ var TagadaReactSDKBundle = (() => {
3391
3391
  "/api/v1/checkout-sessions/".concat(sessionId, "/shipping-rates/preview?").concat(queryParams.toString())
3392
3392
  );
3393
3393
  }
3394
+ /**
3395
+ * Preview shipping rates for a country AND persist the auto-selected rate on the session.
3396
+ *
3397
+ * Difference with `previewShippingRates` (which is read-only):
3398
+ * - the server picks the highlighted (or cheapest) rate for `countryCode`
3399
+ * - it writes `checkoutSession.shippingRateId` to the DB
3400
+ * - the next `getCheckout()` will return a summary that includes shipping cost
3401
+ *
3402
+ * Use this from the studio when geolocation (or any client-side hint) determines a country
3403
+ * BEFORE the user submits the full address. Otherwise the wallet sheet (Apple Pay, etc.) will
3404
+ * be opened with a stale total that doesn't include shipping fees.
3405
+ */
3406
+ async selectPreviewShippingRate(sessionId, params) {
3407
+ return this.apiClient.post(
3408
+ "/api/v1/checkout-sessions/".concat(sessionId, "/shipping-rates/select-preview"),
3409
+ __spreadValues({
3410
+ countryCode: params.countryCode
3411
+ }, params.stateCode ? { stateCode: params.stateCode } : {})
3412
+ );
3413
+ }
3394
3414
  };
3395
3415
  }
3396
3416
  });
@@ -9994,8 +10014,11 @@ var TagadaReactSDKBundle = (() => {
9994
10014
  FunnelClient: () => FunnelClient,
9995
10015
  TrackingProvider: () => TrackingProvider,
9996
10016
  findMethod: () => findMethod,
10017
+ getAssignedCheckoutOfferDefault: () => getAssignedCheckoutOfferDefault,
10018
+ getAssignedCheckoutOfferIds: () => getAssignedCheckoutOfferIds,
9997
10019
  getAssignedOrderBumpOfferIds: () => getAssignedOrderBumpOfferIds,
9998
10020
  getAssignedPaymentFlowId: () => getAssignedPaymentFlowId,
10021
+ getAssignedPaymentInitiator: () => getAssignedPaymentInitiator,
9999
10022
  getAssignedPixels: () => getAssignedPixels,
10000
10023
  getAssignedResources: () => getAssignedResources,
10001
10024
  getAssignedScripts: () => getAssignedScripts,
@@ -10140,7 +10163,8 @@ var TagadaReactSDKBundle = (() => {
10140
10163
  scripts: local.scripts,
10141
10164
  pixels: local.pixels,
10142
10165
  orderBumps: local.orderBumps,
10143
- upsellOffers: local.upsellOffers
10166
+ upsellOffers: local.upsellOffers,
10167
+ checkoutOffers: local.checkoutOffers
10144
10168
  };
10145
10169
  }
10146
10170
  function getAssignedStepConfig() {
@@ -10186,6 +10210,10 @@ var TagadaReactSDKBundle = (() => {
10186
10210
  }
10187
10211
  return void 0;
10188
10212
  }
10213
+ function getAssignedPaymentInitiator() {
10214
+ const stepConfig = getAssignedStepConfig();
10215
+ return stepConfig == null ? void 0 : stepConfig.paymentInitiator;
10216
+ }
10189
10217
  function getAssignedResources() {
10190
10218
  const stepConfig = getAssignedStepConfig();
10191
10219
  const legacy = stepConfig == null ? void 0 : stepConfig.staticResources;
@@ -10240,6 +10268,17 @@ var TagadaReactSDKBundle = (() => {
10240
10268
  if (stepConfig.upsellOffers.mode !== "custom") return void 0;
10241
10269
  return stepConfig.upsellOffers.enabledUpsellIds;
10242
10270
  }
10271
+ function getAssignedCheckoutOfferIds() {
10272
+ const stepConfig = getAssignedStepConfig();
10273
+ if (!(stepConfig == null ? void 0 : stepConfig.checkoutOffers)) return void 0;
10274
+ if (stepConfig.checkoutOffers.mode !== "custom") return void 0;
10275
+ return stepConfig.checkoutOffers.enabledOfferIds;
10276
+ }
10277
+ function getAssignedCheckoutOfferDefault() {
10278
+ var _a11;
10279
+ const stepConfig = getAssignedStepConfig();
10280
+ return (_a11 = stepConfig == null ? void 0 : stepConfig.checkoutOffers) == null ? void 0 : _a11.defaultOfferId;
10281
+ }
10243
10282
  var lazyInjectPreviewIndicator, TrackingProvider, localFunnelConfigCache, localFunnelConfigLoading, FunnelClient;
10244
10283
  var init_funnelClient = __esm({
10245
10284
  "src/v2/core/funnelClient.ts"() {
@@ -12768,47 +12807,12 @@ var TagadaReactSDKBundle = (() => {
12768
12807
  }
12769
12808
  });
12770
12809
 
12771
- // src/v2/react/hooks/useStepConfig.ts
12772
- function useStepConfig() {
12773
- const stepConfig = (0, import_react3.useMemo)(() => getAssignedStepConfig(), []);
12774
- const paymentFlowId = (0, import_react3.useMemo)(() => getAssignedPaymentFlowId(), []);
12775
- const resources = (0, import_react3.useMemo)(() => getAssignedResources(), []);
12776
- const pixels = (0, import_react3.useMemo)(() => getAssignedPixels(), []);
12777
- const getScripts = (0, import_react3.useMemo)(() => {
12778
- return (position) => {
12779
- return getAssignedScripts(position);
12780
- };
12781
- }, []);
12782
- const paymentSetupConfig = (0, import_react3.useMemo)(() => stepConfig == null ? void 0 : stepConfig.paymentSetupConfig, [stepConfig]);
12783
- const orderBumpOfferIds = (0, import_react3.useMemo)(() => getAssignedOrderBumpOfferIds(), []);
12784
- const upsellOfferIds = (0, import_react3.useMemo)(() => getAssignedUpsellOfferIds(), []);
12785
- return {
12786
- stepConfig,
12787
- paymentFlowId,
12788
- resources,
12789
- staticResources: resources,
12790
- getScripts,
12791
- pixels,
12792
- paymentSetupConfig,
12793
- orderBumpOfferIds,
12794
- upsellOfferIds
12795
- };
12796
- }
12797
- var import_react3;
12798
- var init_useStepConfig = __esm({
12799
- "src/v2/react/hooks/useStepConfig.ts"() {
12800
- "use strict";
12801
- import_react3 = __require("react");
12802
- init_funnelClient();
12803
- }
12804
- });
12805
-
12806
- // src/v2/react/hooks/usePixelTracking.tsx
12810
+ // src/v2/core/pixelTracker.ts
12807
12811
  function createDuplicateGuard(windowMs) {
12808
12812
  const lastEvents = /* @__PURE__ */ new Map();
12809
- return (eventName, parameters) => {
12813
+ return (eventName, parameters, eventId) => {
12810
12814
  try {
12811
- const key = JSON.stringify({ eventName, parameters });
12815
+ const key = JSON.stringify({ eventName, parameters, eventId });
12812
12816
  const now = Date.now();
12813
12817
  const last = lastEvents.get(key);
12814
12818
  if (last && now - last < windowMs) return false;
@@ -12819,112 +12823,36 @@ var TagadaReactSDKBundle = (() => {
12819
12823
  }
12820
12824
  };
12821
12825
  }
12822
- function PixelTrackingProvider({ children }) {
12823
- const { pixels } = useStepConfig();
12824
- const [pixelsInitialized, setPixelsInitialized] = (0, import_react4.useState)(false);
12825
- const isMountedRef = (0, import_react4.useRef)(true);
12826
- (0, import_react4.useEffect)(() => {
12827
- isMountedRef.current = true;
12828
- return () => {
12829
- isMountedRef.current = false;
12830
- };
12831
- }, []);
12832
- (0, import_react4.useEffect)(() => {
12833
- var _a11, _b2, _c, _d, _e;
12834
- if (!pixels || pixelsInitialized || !isMountedRef.current) return;
12835
- const loadPromises = [];
12836
- try {
12837
- (_a11 = pixels.facebook) == null ? void 0 : _a11.forEach((px) => {
12838
- if (px.enabled && px.pixelId) loadPromises.push(initMetaPixel(px.pixelId));
12839
- });
12840
- (_b2 = pixels.tiktok) == null ? void 0 : _b2.forEach((px) => {
12841
- if (px.enabled && px.pixelId) loadPromises.push(initTikTokPixel(px.pixelId));
12842
- });
12843
- (_c = pixels.snapchat) == null ? void 0 : _c.forEach((px) => {
12844
- if (px.enabled && px.pixelId) loadPromises.push(initSnapchatPixel(px.pixelId));
12845
- });
12846
- (_d = pixels.pinterest) == null ? void 0 : _d.forEach((px) => {
12847
- if (px.enabled && px.pixelId) loadPromises.push(initPinterestPixel(px.pixelId));
12848
- });
12849
- (_e = pixels.gtm) == null ? void 0 : _e.forEach((px) => {
12850
- if (px.enabled && px.containerId) loadPromises.push(initGTM(px.containerId));
12851
- });
12852
- Promise.all(loadPromises).then(() => {
12853
- if (isMountedRef.current) setPixelsInitialized(true);
12854
- });
12855
- } catch (error) {
12856
- console.error("[SDK Pixels] Initialization error:", error);
12857
- }
12858
- }, [pixels, pixelsInitialized]);
12859
- const track = (0, import_react4.useCallback)(
12860
- (eventName, parameters = {}) => {
12861
- if (!pixels || !pixelsInitialized || !isMountedRef.current) return;
12862
- if (!shouldTrackEvent(eventName, parameters)) return;
12863
- try {
12864
- const events = resolvePixelEvents(pixels, eventName, parameters);
12865
- const firedProviders = /* @__PURE__ */ new Set();
12866
- for (const { provider, mapped, pixel } of events) {
12867
- if (provider === "gtm" || provider === "tiktok") {
12868
- fire(provider, mapped.name, mapped.params, pixel);
12869
- } else {
12870
- if (!firedProviders.has(provider)) {
12871
- fire(provider, mapped.name, mapped.params);
12872
- firedProviders.add(provider);
12873
- }
12874
- }
12875
- }
12876
- } catch (error) {
12877
- console.error("[SDK Pixels] Tracking error:", error);
12878
- }
12879
- },
12880
- [pixels, pixelsInitialized]
12881
- );
12882
- (0, import_react4.useEffect)(() => {
12883
- if (!pixelsInitialized || !isMountedRef.current) return;
12884
- const id = setTimeout(() => {
12885
- if (isMountedRef.current) {
12886
- track("PageView", { path: typeof window !== "undefined" ? window.location.pathname : "" });
12887
- }
12888
- }, 0);
12889
- return () => clearTimeout(id);
12890
- }, [pixelsInitialized, track]);
12891
- const value = (0, import_react4.useMemo)(
12892
- () => ({ track, pixelsInitialized }),
12893
- [track, pixelsInitialized]
12894
- );
12895
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelTrackingContext.Provider, { value, children });
12896
- }
12897
- function usePixelTracking() {
12898
- const context = (0, import_react4.useContext)(PixelTrackingContext);
12899
- if (!context) throw new Error("usePixelTracking must be used within a PixelTrackingProvider");
12900
- return context;
12901
- }
12902
- function fire(provider, name, params, pixel) {
12903
- var _a11, _b2, _c, _d, _e, _f, _g;
12826
+ function fire(provider, name, params, pixel, options = {}) {
12827
+ var _a11, _b2, _c, _d, _e, _f, _g, _h, _i;
12904
12828
  if (typeof window === "undefined") return;
12905
12829
  const w2 = window;
12830
+ const eventId = options.eventId;
12906
12831
  switch (provider) {
12907
12832
  case "facebook":
12908
- (_a11 = w2.fbq) == null ? void 0 : _a11.call(w2, "track", name, params);
12833
+ if (eventId) (_a11 = w2.fbq) == null ? void 0 : _a11.call(w2, "track", name, params, { eventID: eventId });
12834
+ else (_b2 = w2.fbq) == null ? void 0 : _b2.call(w2, "track", name, params);
12909
12835
  break;
12910
12836
  case "tiktok": {
12911
12837
  const pixelId = pixel && "pixelId" in pixel ? pixel.pixelId : null;
12912
- const target = pixelId && ((_b2 = w2.ttq) == null ? void 0 : _b2.instance) ? w2.ttq.instance(pixelId) : w2.ttq;
12838
+ const target = pixelId && ((_c = w2.ttq) == null ? void 0 : _c.instance) ? w2.ttq.instance(pixelId) : w2.ttq;
12913
12839
  if (name === "Pageview") {
12914
- (_c = target == null ? void 0 : target.page) == null ? void 0 : _c.call(target);
12840
+ (_d = target == null ? void 0 : target.page) == null ? void 0 : _d.call(target);
12841
+ } else if (eventId) {
12842
+ (_e = target == null ? void 0 : target.track) == null ? void 0 : _e.call(target, name, params, { event_id: eventId });
12915
12843
  } else {
12916
- (_d = target == null ? void 0 : target.track) == null ? void 0 : _d.call(target, name, params);
12844
+ (_f = target == null ? void 0 : target.track) == null ? void 0 : _f.call(target, name, params);
12917
12845
  }
12918
12846
  break;
12919
12847
  }
12920
12848
  case "snapchat":
12921
- (_e = w2.snaptr) == null ? void 0 : _e.call(w2, "track", name, params);
12849
+ (_g = w2.snaptr) == null ? void 0 : _g.call(w2, "track", name, params);
12922
12850
  break;
12923
12851
  case "pinterest":
12924
12852
  if (name === "pagevisit") {
12925
- (_f = w2.pintrk) == null ? void 0 : _f.call(w2, "page");
12853
+ (_h = w2.pintrk) == null ? void 0 : _h.call(w2, "page");
12926
12854
  } else {
12927
- (_g = w2.pintrk) == null ? void 0 : _g.call(w2, "track", name, params);
12855
+ (_i = w2.pintrk) == null ? void 0 : _i.call(w2, "track", name, params);
12928
12856
  }
12929
12857
  break;
12930
12858
  case "gtm":
@@ -13142,17 +13070,72 @@ var TagadaReactSDKBundle = (() => {
13142
13070
  return waitForScriptLoad(script);
13143
13071
  }
13144
13072
  }
13145
- var import_react4, import_jsx_runtime4, PixelTrackingContext, shouldTrackEvent, win, SCRIPT_LOAD_TIMEOUT_MS, _metaScriptEl, _tiktokBaseInitialized, _snapchatScriptEl, _pinterestScriptEl;
13146
- var init_usePixelTracking = __esm({
13147
- "src/v2/react/hooks/usePixelTracking.tsx"() {
13073
+ function createPixelTracker(pixels) {
13074
+ const shouldTrackEvent = createDuplicateGuard(5e3);
13075
+ let pixelsInitialized = false;
13076
+ const initPromise = (async () => {
13077
+ var _a11, _b2, _c, _d, _e;
13078
+ if (!pixels || typeof window === "undefined") return;
13079
+ const loadPromises = [];
13080
+ try {
13081
+ (_a11 = pixels.facebook) == null ? void 0 : _a11.forEach((px) => {
13082
+ if (px.enabled && px.pixelId) loadPromises.push(initMetaPixel(px.pixelId));
13083
+ });
13084
+ (_b2 = pixels.tiktok) == null ? void 0 : _b2.forEach((px) => {
13085
+ if (px.enabled && px.pixelId) loadPromises.push(initTikTokPixel(px.pixelId));
13086
+ });
13087
+ (_c = pixels.snapchat) == null ? void 0 : _c.forEach((px) => {
13088
+ if (px.enabled && px.pixelId) loadPromises.push(initSnapchatPixel(px.pixelId));
13089
+ });
13090
+ (_d = pixels.pinterest) == null ? void 0 : _d.forEach((px) => {
13091
+ if (px.enabled && px.pixelId) loadPromises.push(initPinterestPixel(px.pixelId));
13092
+ });
13093
+ (_e = pixels.gtm) == null ? void 0 : _e.forEach((px) => {
13094
+ if (px.enabled && px.containerId) loadPromises.push(initGTM(px.containerId));
13095
+ });
13096
+ await Promise.all(loadPromises);
13097
+ } catch (error) {
13098
+ console.error("[SDK Pixels] Initialization error:", error);
13099
+ }
13100
+ pixelsInitialized = true;
13101
+ })();
13102
+ const track = (eventName, parameters = {}, options = {}) => {
13103
+ if (!pixels || !pixelsInitialized) return;
13104
+ if (!shouldTrackEvent(eventName, parameters, options.eventId)) return;
13105
+ try {
13106
+ const events = resolvePixelEvents(pixels, eventName, parameters);
13107
+ const firedProviders = /* @__PURE__ */ new Set();
13108
+ for (const { provider, mapped, pixel } of events) {
13109
+ if (provider === "gtm" || provider === "tiktok") {
13110
+ fire(provider, mapped.name, mapped.params, pixel, options);
13111
+ } else {
13112
+ if (!firedProviders.has(provider)) {
13113
+ fire(provider, mapped.name, mapped.params, void 0, options);
13114
+ firedProviders.add(provider);
13115
+ }
13116
+ }
13117
+ }
13118
+ } catch (error) {
13119
+ console.error("[SDK Pixels] Tracking error:", error);
13120
+ }
13121
+ };
13122
+ initPromise.then(() => {
13123
+ if (typeof window === "undefined") return;
13124
+ track("PageView", { path: window.location.pathname });
13125
+ });
13126
+ return {
13127
+ initPromise,
13128
+ get pixelsInitialized() {
13129
+ return pixelsInitialized;
13130
+ },
13131
+ track
13132
+ };
13133
+ }
13134
+ var win, SCRIPT_LOAD_TIMEOUT_MS, _metaScriptEl, _tiktokBaseInitialized, _snapchatScriptEl, _pinterestScriptEl;
13135
+ var init_pixelTracker = __esm({
13136
+ "src/v2/core/pixelTracker.ts"() {
13148
13137
  "use strict";
13149
- "use client";
13150
- import_react4 = __require("react");
13151
13138
  init_pixelMapping();
13152
- init_useStepConfig();
13153
- import_jsx_runtime4 = __require("react/jsx-runtime");
13154
- PixelTrackingContext = (0, import_react4.createContext)(null);
13155
- shouldTrackEvent = createDuplicateGuard(5e3);
13156
13139
  win = typeof window !== "undefined" ? window : void 0;
13157
13140
  SCRIPT_LOAD_TIMEOUT_MS = 5e3;
13158
13141
  _metaScriptEl = null;
@@ -13162,6 +13145,228 @@ var TagadaReactSDKBundle = (() => {
13162
13145
  }
13163
13146
  });
13164
13147
 
13148
+ // src/v2/react/hooks/useStepConfig.ts
13149
+ function useStepConfig() {
13150
+ const stepConfig = (0, import_react3.useMemo)(() => getAssignedStepConfig(), []);
13151
+ const paymentFlowId = (0, import_react3.useMemo)(() => getAssignedPaymentFlowId(), []);
13152
+ const resources = (0, import_react3.useMemo)(() => getAssignedResources(), []);
13153
+ const pixels = (0, import_react3.useMemo)(() => getAssignedPixels(), []);
13154
+ const getScripts = (0, import_react3.useMemo)(() => {
13155
+ return (position) => {
13156
+ return getAssignedScripts(position);
13157
+ };
13158
+ }, []);
13159
+ const paymentSetupConfig = (0, import_react3.useMemo)(() => stepConfig == null ? void 0 : stepConfig.paymentSetupConfig, [stepConfig]);
13160
+ const orderBumpOfferIds = (0, import_react3.useMemo)(() => getAssignedOrderBumpOfferIds(), []);
13161
+ const upsellOfferIds = (0, import_react3.useMemo)(() => getAssignedUpsellOfferIds(), []);
13162
+ const checkoutOfferIds = (0, import_react3.useMemo)(() => getAssignedCheckoutOfferIds(), []);
13163
+ const checkoutOfferDefaultId = (0, import_react3.useMemo)(() => getAssignedCheckoutOfferDefault(), []);
13164
+ return {
13165
+ stepConfig,
13166
+ paymentFlowId,
13167
+ resources,
13168
+ staticResources: resources,
13169
+ getScripts,
13170
+ pixels,
13171
+ paymentSetupConfig,
13172
+ orderBumpOfferIds,
13173
+ upsellOfferIds,
13174
+ checkoutOfferIds,
13175
+ checkoutOfferDefaultId
13176
+ };
13177
+ }
13178
+ var import_react3;
13179
+ var init_useStepConfig = __esm({
13180
+ "src/v2/react/hooks/useStepConfig.ts"() {
13181
+ "use strict";
13182
+ import_react3 = __require("react");
13183
+ init_funnelClient();
13184
+ }
13185
+ });
13186
+
13187
+ // src/v2/react/hooks/usePixelTracking.tsx
13188
+ function PixelTrackingProvider({ children }) {
13189
+ const { pixels } = useStepConfig();
13190
+ const trackerRef = (0, import_react4.useRef)(null);
13191
+ const [pixelsInitialized, setPixelsInitialized] = (0, import_react4.useState)(false);
13192
+ (0, import_react4.useEffect)(() => {
13193
+ if (!pixels) return;
13194
+ const tracker = createPixelTracker(pixels);
13195
+ trackerRef.current = tracker;
13196
+ setPixelsInitialized(false);
13197
+ let cancelled = false;
13198
+ tracker.initPromise.then(() => {
13199
+ if (!cancelled) setPixelsInitialized(true);
13200
+ });
13201
+ return () => {
13202
+ cancelled = true;
13203
+ trackerRef.current = null;
13204
+ };
13205
+ }, [pixels]);
13206
+ const value = (0, import_react4.useMemo)(
13207
+ () => ({
13208
+ track: (eventName, parameters, options) => {
13209
+ var _a11;
13210
+ (_a11 = trackerRef.current) == null ? void 0 : _a11.track(eventName, parameters, options);
13211
+ },
13212
+ pixelsInitialized
13213
+ }),
13214
+ [pixelsInitialized]
13215
+ );
13216
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelTrackingContext.Provider, { value, children });
13217
+ }
13218
+ function usePixelTracking() {
13219
+ const context = (0, import_react4.useContext)(PixelTrackingContext);
13220
+ if (!context) throw new Error("usePixelTracking must be used within a PixelTrackingProvider");
13221
+ return context;
13222
+ }
13223
+ var import_react4, import_jsx_runtime4, PixelTrackingContext;
13224
+ var init_usePixelTracking = __esm({
13225
+ "src/v2/react/hooks/usePixelTracking.tsx"() {
13226
+ "use strict";
13227
+ "use client";
13228
+ import_react4 = __require("react");
13229
+ init_pixelTracker();
13230
+ init_useStepConfig();
13231
+ import_jsx_runtime4 = __require("react/jsx-runtime");
13232
+ PixelTrackingContext = (0, import_react4.createContext)(null);
13233
+ }
13234
+ });
13235
+
13236
+ // src/v2/core/utils/clickIdResolver.ts
13237
+ function readCookie(name) {
13238
+ if (typeof document === "undefined" || !document.cookie) return null;
13239
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
13240
+ const m3 = document.cookie.match(new RegExp("(?:^|; )" + escaped + "=([^;]*)"));
13241
+ if (!m3) return null;
13242
+ try {
13243
+ return decodeURIComponent(m3[1]);
13244
+ } catch (e3) {
13245
+ return m3[1];
13246
+ }
13247
+ }
13248
+ function readUrlParam(search, name) {
13249
+ if (!search) return null;
13250
+ try {
13251
+ return new URLSearchParams(search).get(name);
13252
+ } catch (e3) {
13253
+ return null;
13254
+ }
13255
+ }
13256
+ function resolveClickId() {
13257
+ var _a11, _b2;
13258
+ const all3 = {};
13259
+ let clickId = null;
13260
+ let source = null;
13261
+ let key = null;
13262
+ const search = typeof window !== "undefined" ? (_b2 = (_a11 = window.location) == null ? void 0 : _a11.search) != null ? _b2 : "" : "";
13263
+ for (const name of CLICK_ID_URL_PARAMS) {
13264
+ const v2 = readUrlParam(search, name);
13265
+ if (v2) {
13266
+ all3["url:".concat(name)] = v2;
13267
+ if (clickId === null) {
13268
+ clickId = v2;
13269
+ source = "url";
13270
+ key = name;
13271
+ }
13272
+ }
13273
+ }
13274
+ for (const name of CLICK_ID_COOKIES) {
13275
+ const v2 = readCookie(name);
13276
+ if (v2) {
13277
+ all3["cookie:".concat(name)] = v2;
13278
+ if (clickId === null) {
13279
+ clickId = v2;
13280
+ source = "cookie";
13281
+ key = name;
13282
+ }
13283
+ }
13284
+ }
13285
+ return { clickId, source, key, all: all3 };
13286
+ }
13287
+ function publishTrackingGlobal() {
13288
+ var _a11;
13289
+ if (typeof window === "undefined") return null;
13290
+ const resolved = resolveClickId();
13291
+ const tracking = __spreadProps(__spreadValues({}, resolved), { resolvedAt: Date.now() });
13292
+ window.TagadaPay = __spreadProps(__spreadValues({}, (_a11 = window.TagadaPay) != null ? _a11 : {}), { tracking });
13293
+ return tracking;
13294
+ }
13295
+ var CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES;
13296
+ var init_clickIdResolver = __esm({
13297
+ "src/v2/core/utils/clickIdResolver.ts"() {
13298
+ "use strict";
13299
+ CLICK_ID_URL_PARAMS = Object.freeze([
13300
+ // Postback ad-trackers (most specific first)
13301
+ "cf_click_id",
13302
+ // ClickFlare canonical
13303
+ "cid",
13304
+ // Voluum canonical (also: ClickFlare receiving-side)
13305
+ "rtkclickid",
13306
+ // RedTrack canonical
13307
+ "cmc_tid",
13308
+ // ClickMagick canonical (replaces legacy #S2#)
13309
+ "cmc_id",
13310
+ // ClickMagick legacy
13311
+ "cmcid",
13312
+ // ClickMagick alt
13313
+ "clickid",
13314
+ // Generic affiliate-network token (Binom, RedTrack, Voluum, …)
13315
+ "click_id",
13316
+ // Generic snake_case (ClickFlare, ClickMagick, …)
13317
+ // Ad-platform native click ids
13318
+ "gclid",
13319
+ // Google Ads
13320
+ "gbraid",
13321
+ // Google Ads (iOS app)
13322
+ "wbraid",
13323
+ // Google Ads (web→app)
13324
+ "fbclid",
13325
+ // Meta
13326
+ "msclkid",
13327
+ // Microsoft Ads
13328
+ "ttclid",
13329
+ // TikTok
13330
+ "twclid",
13331
+ // X / Twitter
13332
+ "li_fat_id",
13333
+ // LinkedIn
13334
+ "epik",
13335
+ // Pinterest
13336
+ "dclid",
13337
+ // Display & Video 360
13338
+ "yclid",
13339
+ // Yandex
13340
+ "irclickid"
13341
+ // Impact
13342
+ ]);
13343
+ CLICK_ID_COOKIES = Object.freeze([
13344
+ // ClickFlare
13345
+ "cf_click_id",
13346
+ "cfclid",
13347
+ // RedTrack — `rtkclickid-store` is the canonical first-party cookie
13348
+ // set by RedTrack's Universal Tracking Script.
13349
+ "rtkclickid-store",
13350
+ "_rtkclickid",
13351
+ "rtkclickid",
13352
+ // Voluum
13353
+ "_voluum",
13354
+ "_voluumclickid",
13355
+ // Binom
13356
+ "_binom",
13357
+ "_binomclickid",
13358
+ // ClickMagick
13359
+ "_mck",
13360
+ "cmcid",
13361
+ // Other
13362
+ "skro-click-id",
13363
+ // Skro
13364
+ "click_id"
13365
+ // generic catch-all (last)
13366
+ ]);
13367
+ }
13368
+ });
13369
+
13165
13370
  // src/v2/core/utils/products.ts
13166
13371
  var init_products = __esm({
13167
13372
  "src/v2/core/utils/products.ts"() {
@@ -13520,6 +13725,16 @@ var TagadaReactSDKBundle = (() => {
13520
13725
  }
13521
13726
  });
13522
13727
 
13728
+ // src/v2/core/utils/metaEventId.ts
13729
+ function makeMetaEventId(eventName, entityId) {
13730
+ return "".concat(eventName, "_").concat(entityId);
13731
+ }
13732
+ var init_metaEventId = __esm({
13733
+ "src/v2/core/utils/metaEventId.ts"() {
13734
+ "use strict";
13735
+ }
13736
+ });
13737
+
13523
13738
  // src/v2/core/utils/index.ts
13524
13739
  var init_utils4 = __esm({
13525
13740
  "src/v2/core/utils/index.ts"() {
@@ -13535,6 +13750,18 @@ var TagadaReactSDKBundle = (() => {
13535
13750
  init_sessionStorage();
13536
13751
  init_funnelQueryKeys();
13537
13752
  init_configHotReload();
13753
+ init_metaEventId();
13754
+ init_clickIdResolver();
13755
+ }
13756
+ });
13757
+
13758
+ // src/v2/core/resources/promotionEvents.ts
13759
+ var PROMOTION_APPLIED, PROMOTION_REMOVED;
13760
+ var init_promotionEvents = __esm({
13761
+ "src/v2/core/resources/promotionEvents.ts"() {
13762
+ "use strict";
13763
+ PROMOTION_APPLIED = "PROMOTION_APPLIED";
13764
+ PROMOTION_REMOVED = "PROMOTION_REMOVED";
13538
13765
  }
13539
13766
  });
13540
13767
 
@@ -13543,9 +13770,11 @@ var TagadaReactSDKBundle = (() => {
13543
13770
  var init_checkout2 = __esm({
13544
13771
  "src/v2/core/resources/checkout.ts"() {
13545
13772
  "use strict";
13773
+ init_promotionEvents();
13546
13774
  CheckoutResource = class {
13547
- constructor(apiClient) {
13775
+ constructor(apiClient, bus) {
13548
13776
  this.apiClient = apiClient;
13777
+ this.bus = bus;
13549
13778
  }
13550
13779
  /**
13551
13780
  * Initialize a new checkout session (sync mode)
@@ -13660,15 +13889,25 @@ var TagadaReactSDKBundle = (() => {
13660
13889
  * Apply promotion code
13661
13890
  */
13662
13891
  async applyPromotionCode(checkoutSessionId, code) {
13663
- return this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/apply"), {
13892
+ var _a11;
13893
+ const result = await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/apply"), {
13664
13894
  code
13665
13895
  });
13896
+ if (result.success) {
13897
+ void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_APPLIED, { checkoutSessionId }));
13898
+ }
13899
+ return result;
13666
13900
  }
13667
13901
  /**
13668
13902
  * Remove promotion
13669
13903
  */
13670
13904
  async removePromotion(checkoutSessionId, promotionId) {
13671
- return this.apiClient.delete("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/").concat(promotionId));
13905
+ var _a11;
13906
+ const result = await this.apiClient.delete("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/").concat(promotionId));
13907
+ if (result.success) {
13908
+ void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_REMOVED, { checkoutSessionId }));
13909
+ }
13910
+ return result;
13672
13911
  }
13673
13912
  /**
13674
13913
  * Get applied promotions
@@ -13876,6 +14115,7 @@ var TagadaReactSDKBundle = (() => {
13876
14115
  "src/v2/core/resources/offers.ts"() {
13877
14116
  "use strict";
13878
14117
  init_previewMode();
14118
+ init_funnelClient();
13879
14119
  OffersResource = class {
13880
14120
  constructor(apiClient) {
13881
14121
  this.apiClient = apiClient;
@@ -13939,22 +14179,24 @@ var TagadaReactSDKBundle = (() => {
13939
14179
  * @param returnUrl - Optional return URL for checkout
13940
14180
  * @param mainOrderId - Optional main order ID (for upsells)
13941
14181
  */
13942
- async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
14182
+ async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId, initiatedBy) {
14183
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
13943
14184
  console.log("\u{1F4B3} [OffersResource] Calling pay-preview API:", {
13944
14185
  offerId,
13945
14186
  currency,
13946
14187
  lineItems,
13947
14188
  returnUrl,
13948
14189
  mainOrderId,
14190
+ initiatedBy: effectiveInitiatedBy,
13949
14191
  endpoint: "/api/v1/offers/".concat(offerId, "/pay-preview")
13950
14192
  });
13951
- const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), {
14193
+ const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), __spreadValues({
13952
14194
  offerId,
13953
14195
  currency,
13954
14196
  lineItems,
13955
14197
  returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
13956
14198
  mainOrderId
13957
- });
14199
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}));
13958
14200
  console.log("\u{1F4E5} [OffersResource] Pay-preview API response:", response);
13959
14201
  return response;
13960
14202
  }
@@ -14019,31 +14261,35 @@ var TagadaReactSDKBundle = (() => {
14019
14261
  /**
14020
14262
  * Pay with checkout session
14021
14263
  */
14022
- async payWithCheckoutSession(checkoutSessionId, orderId) {
14264
+ async payWithCheckoutSession(checkoutSessionId, orderId, initiatedBy) {
14023
14265
  const draft = isDraftMode();
14024
- await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/pay"), {
14266
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
14267
+ await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/pay"), __spreadProps(__spreadValues({
14025
14268
  checkoutSessionId,
14026
14269
  draft,
14027
14270
  // 🎯 Use dynamic draft mode instead of hardcoded false
14028
- returnUrl: typeof window !== "undefined" ? window.location.href : "",
14271
+ returnUrl: typeof window !== "undefined" ? window.location.href : ""
14272
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}), {
14029
14273
  metadata: {
14030
14274
  comingFromPostPurchase: true,
14031
14275
  postOrder: orderId,
14032
14276
  upsell: true,
14033
14277
  source: "offer"
14034
14278
  }
14035
- });
14279
+ }));
14036
14280
  }
14037
14281
  /**
14038
14282
  * Pay for an offer directly
14039
14283
  */
14040
- async payOffer(offerId, orderId) {
14284
+ async payOffer(offerId, orderId, initiatedBy) {
14041
14285
  const draft = isDraftMode();
14042
- return this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay"), {
14286
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
14287
+ return this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay"), __spreadProps(__spreadValues({
14043
14288
  offerId,
14044
14289
  draft,
14045
14290
  // 🎯 Use dynamic draft mode instead of hardcoded false
14046
- returnUrl: typeof window !== "undefined" ? window.location.href : "",
14291
+ returnUrl: typeof window !== "undefined" ? window.location.href : ""
14292
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}), {
14047
14293
  metadata: orderId ? {
14048
14294
  comingFromPostPurchase: true,
14049
14295
  postOrder: orderId,
@@ -14053,7 +14299,7 @@ var TagadaReactSDKBundle = (() => {
14053
14299
  upsell: true,
14054
14300
  source: "offer"
14055
14301
  }
14056
- });
14302
+ }));
14057
14303
  }
14058
14304
  /**
14059
14305
  * Transform offer to checkout session with dynamic variant selection
@@ -14657,9 +14903,11 @@ var TagadaReactSDKBundle = (() => {
14657
14903
  var init_promotions2 = __esm({
14658
14904
  "src/v2/core/resources/promotions.ts"() {
14659
14905
  "use strict";
14906
+ init_promotionEvents();
14660
14907
  PromotionsResource = class {
14661
- constructor(apiClient) {
14908
+ constructor(apiClient, bus) {
14662
14909
  this.apiClient = apiClient;
14910
+ this.bus = bus;
14663
14911
  }
14664
14912
  /**
14665
14913
  * Get applied promotions for a checkout session
@@ -14671,24 +14919,25 @@ var TagadaReactSDKBundle = (() => {
14671
14919
  * Apply a promotion code to a checkout session
14672
14920
  */
14673
14921
  async applyPromotionCode(checkoutSessionId, code) {
14674
- var _a11, _b2, _c, _d, _e, _f;
14922
+ var _a11, _b2, _c, _d, _e, _f, _g;
14675
14923
  try {
14676
14924
  const response = await this.apiClient.post(
14677
14925
  "/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/apply"),
14678
14926
  { code: code.trim() }
14679
14927
  );
14680
14928
  if (response.success) {
14929
+ void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_APPLIED, { checkoutSessionId }));
14681
14930
  return { success: true, promotion: response.promotion };
14682
14931
  } else {
14683
- return { success: false, error: ((_a11 = response.error) == null ? void 0 : _a11.message) || "Failed to apply promotion code" };
14932
+ return { success: false, error: ((_b2 = response.error) == null ? void 0 : _b2.message) || "Failed to apply promotion code" };
14684
14933
  }
14685
14934
  } catch (err) {
14686
14935
  let errorMessage = "Failed to apply promotion code";
14687
14936
  if (err && typeof err === "object" && "response" in err) {
14688
14937
  const apiError = err;
14689
- if ((_d = (_c = (_b2 = apiError.response) == null ? void 0 : _b2.data) == null ? void 0 : _c.error) == null ? void 0 : _d.message) {
14938
+ if ((_e = (_d = (_c = apiError.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) == null ? void 0 : _e.message) {
14690
14939
  errorMessage = apiError.response.data.error.message;
14691
- } else if ((_f = (_e = apiError.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) {
14940
+ } else if ((_g = (_f = apiError.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) {
14692
14941
  errorMessage = apiError.response.data.message;
14693
14942
  }
14694
14943
  }
@@ -14699,23 +14948,24 @@ var TagadaReactSDKBundle = (() => {
14699
14948
  * Remove a promotion from a checkout session
14700
14949
  */
14701
14950
  async removePromotionCode(checkoutSessionId, promotionId) {
14702
- var _a11, _b2, _c, _d, _e, _f;
14951
+ var _a11, _b2, _c, _d, _e, _f, _g;
14703
14952
  try {
14704
14953
  const response = await this.apiClient.delete(
14705
14954
  "/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/").concat(promotionId)
14706
14955
  );
14707
14956
  if (response.success) {
14957
+ void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_REMOVED, { checkoutSessionId }));
14708
14958
  return { success: true };
14709
14959
  } else {
14710
- return { success: false, error: ((_a11 = response.error) == null ? void 0 : _a11.message) || "Failed to remove promotion" };
14960
+ return { success: false, error: ((_b2 = response.error) == null ? void 0 : _b2.message) || "Failed to remove promotion" };
14711
14961
  }
14712
14962
  } catch (err) {
14713
14963
  let errorMessage = "Failed to remove promotion";
14714
14964
  if (err && typeof err === "object" && "response" in err) {
14715
14965
  const apiError = err;
14716
- if ((_d = (_c = (_b2 = apiError.response) == null ? void 0 : _b2.data) == null ? void 0 : _c.error) == null ? void 0 : _d.message) {
14966
+ if ((_e = (_d = (_c = apiError.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) == null ? void 0 : _e.message) {
14717
14967
  errorMessage = apiError.response.data.error.message;
14718
- } else if ((_f = (_e = apiError.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) {
14968
+ } else if ((_g = (_f = apiError.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) {
14719
14969
  errorMessage = apiError.response.data.message;
14720
14970
  }
14721
14971
  }
@@ -15739,7 +15989,7 @@ var TagadaReactSDKBundle = (() => {
15739
15989
  const { storeId } = usePluginConfig();
15740
15990
  const currency = useCurrency();
15741
15991
  const queryClient = useQueryClient();
15742
- const { isSessionInitialized, session } = useTagadaContext();
15992
+ const { isSessionInitialized, session, client } = useTagadaContext();
15743
15993
  const pendingSessionPromise = (0, import_react7.useRef)(null);
15744
15994
  const sessionResolvers = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
15745
15995
  (0, import_react7.useEffect)(() => {
@@ -15774,11 +16024,11 @@ var TagadaReactSDKBundle = (() => {
15774
16024
  }, [isSessionInitialized]);
15775
16025
  const checkoutResource = (0, import_react7.useMemo)(() => {
15776
16026
  try {
15777
- return new CheckoutResource(getGlobalApiClient());
16027
+ return new CheckoutResource(getGlobalApiClient(), client.bus);
15778
16028
  } catch (error2) {
15779
16029
  throw new Error(messages.initFailed + ": " + (error2 instanceof Error ? error2.message : "Unknown error"));
15780
16030
  }
15781
- }, []);
16031
+ }, [client.bus]);
15782
16032
  const [internalToken, setInternalToken] = (0, import_react7.useState)(providedToken);
15783
16033
  (0, import_react7.useEffect)(() => {
15784
16034
  if (providedToken && providedToken !== internalToken) {
@@ -16003,6 +16253,60 @@ var TagadaReactSDKBundle = (() => {
16003
16253
  promotionIds
16004
16254
  })
16005
16255
  });
16256
+ const init = (0, import_react7.useCallback)(async (params) => {
16257
+ var _a11;
16258
+ await waitForSession();
16259
+ const result = await initMutation.mutateAsync(params);
16260
+ setInternalToken(result.checkoutToken);
16261
+ return {
16262
+ checkoutSession: (_a11 = checkout == null ? void 0 : checkout.checkoutSession) != null ? _a11 : {},
16263
+ checkoutToken: result.checkoutToken
16264
+ };
16265
+ }, [waitForSession, initMutation.mutateAsync, checkout == null ? void 0 : checkout.checkoutSession]);
16266
+ const replaceSessionLineItems = (0, import_react7.useCallback)(
16267
+ (lineItems) => replaceSessionLineItemsMutation.mutateAsync({ lineItems }),
16268
+ [replaceSessionLineItemsMutation.mutateAsync]
16269
+ );
16270
+ const updateLineItems = (0, import_react7.useCallback)(
16271
+ (lineItems) => lineItemsMutation.mutateAsync({ lineItems }),
16272
+ [lineItemsMutation.mutateAsync]
16273
+ );
16274
+ const updateLineItemsOptimistic = (0, import_react7.useCallback)(
16275
+ (lineItems) => lineItemsMutation.mutate({ lineItems }),
16276
+ [lineItemsMutation.mutate]
16277
+ );
16278
+ const addLineItems = (0, import_react7.useCallback)(
16279
+ (lineItems) => addLineItemsMutation.mutateAsync({ lineItems }),
16280
+ [addLineItemsMutation.mutateAsync]
16281
+ );
16282
+ const removeLineItems = (0, import_react7.useCallback)(
16283
+ (lineItems) => removeLineItemsMutation.mutateAsync({ lineItems }),
16284
+ [removeLineItemsMutation.mutateAsync]
16285
+ );
16286
+ const setItemQuantity = (0, import_react7.useCallback)(
16287
+ (variantId, quantity, priceId) => quantityMutation.mutateAsync({ variantId, quantity, priceId }),
16288
+ [quantityMutation.mutateAsync]
16289
+ );
16290
+ const updateCustomer = (0, import_react7.useCallback)(
16291
+ (data) => customerMutation.mutateAsync(data),
16292
+ [customerMutation.mutateAsync]
16293
+ );
16294
+ const updateCustomerAndSessionInfo = (0, import_react7.useCallback)(
16295
+ (data) => customerAndSessionMutation.mutateAsync(data),
16296
+ [customerAndSessionMutation.mutateAsync]
16297
+ );
16298
+ const applyPromotionCode = (0, import_react7.useCallback)(
16299
+ (code) => promotionMutation.mutateAsync({ code }),
16300
+ [promotionMutation.mutateAsync]
16301
+ );
16302
+ const removePromotion = (0, import_react7.useCallback)(
16303
+ (promotionId) => removePromotionMutation.mutateAsync({ promotionId }),
16304
+ [removePromotionMutation.mutateAsync]
16305
+ );
16306
+ const previewCheckoutSession = (0, import_react7.useCallback)(
16307
+ (lineItems, promotionIds) => previewCheckoutSessionMutation.mutateAsync({ lineItems, promotionIds }),
16308
+ [previewCheckoutSessionMutation.mutateAsync]
16309
+ );
16006
16310
  return {
16007
16311
  // Query data
16008
16312
  checkout,
@@ -16010,29 +16314,20 @@ var TagadaReactSDKBundle = (() => {
16010
16314
  error,
16011
16315
  isSuccess,
16012
16316
  // Actions
16013
- init: async (params) => {
16014
- var _a11;
16015
- await waitForSession();
16016
- const result = await initMutation.mutateAsync(params);
16017
- setInternalToken(result.checkoutToken);
16018
- return {
16019
- checkoutSession: (_a11 = checkout == null ? void 0 : checkout.checkoutSession) != null ? _a11 : {},
16020
- checkoutToken: result.checkoutToken
16021
- };
16022
- },
16317
+ init,
16023
16318
  refresh,
16024
16319
  // Checkout operations
16025
- replaceSessionLineItems: (lineItems) => replaceSessionLineItemsMutation.mutateAsync({ lineItems }),
16026
- updateLineItems: (lineItems) => lineItemsMutation.mutateAsync({ lineItems }),
16027
- updateLineItemsOptimistic: (lineItems) => lineItemsMutation.mutate({ lineItems }),
16028
- addLineItems: (lineItems) => addLineItemsMutation.mutateAsync({ lineItems }),
16029
- removeLineItems: (lineItems) => removeLineItemsMutation.mutateAsync({ lineItems }),
16030
- setItemQuantity: (variantId, quantity, priceId) => quantityMutation.mutateAsync({ variantId, quantity, priceId }),
16031
- updateCustomer: (data) => customerMutation.mutateAsync(data),
16032
- updateCustomerAndSessionInfo: (data) => customerAndSessionMutation.mutateAsync(data),
16033
- applyPromotionCode: (code) => promotionMutation.mutateAsync({ code }),
16034
- removePromotion: (promotionId) => removePromotionMutation.mutateAsync({ promotionId }),
16035
- previewCheckoutSession: (lineItems, promotionIds) => previewCheckoutSessionMutation.mutateAsync({ lineItems, promotionIds })
16320
+ replaceSessionLineItems,
16321
+ updateLineItems,
16322
+ updateLineItemsOptimistic,
16323
+ addLineItems,
16324
+ removeLineItems,
16325
+ setItemQuantity,
16326
+ updateCustomer,
16327
+ updateCustomerAndSessionInfo,
16328
+ applyPromotionCode,
16329
+ removePromotion,
16330
+ previewCheckoutSession
16036
16331
  };
16037
16332
  }
16038
16333
  var import_react7, DEFAULT_MESSAGES;
@@ -18875,8 +19170,16 @@ var TagadaReactSDKBundle = (() => {
18875
19170
  init_client();
18876
19171
  init_useApiQuery();
18877
19172
  init_usePixelTracking();
19173
+ init_clickIdResolver();
18878
19174
  import_jsx_runtime6 = __require("react/jsx-runtime");
18879
19175
  import_meta2 = {};
19176
+ if (typeof window !== "undefined") {
19177
+ try {
19178
+ publishTrackingGlobal();
19179
+ } catch (error) {
19180
+ console.error("[TagadaProvider] Failed to publish tracking global:", error);
19181
+ }
19182
+ }
18880
19183
  FunnelScriptInjector2 = (0, import_react11.lazy)(() => Promise.resolve().then(() => (init_FunnelScriptInjector(), FunnelScriptInjector_exports)).then((m3) => ({ default: m3.FunnelScriptInjector })));
18881
19184
  DebugDrawer2 = (0, import_react11.lazy)(() => Promise.resolve().then(() => (init_DebugDrawer(), DebugDrawer_exports)));
18882
19185
  InitializationLoader = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
@@ -18924,9 +19227,9 @@ var TagadaReactSDKBundle = (() => {
18924
19227
  }
18925
19228
  });
18926
19229
 
18927
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js
19230
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js
18928
19231
  var require_BasisTheoryProvider = __commonJS({
18929
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js"(exports) {
19232
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js"(exports) {
18930
19233
  "use strict";
18931
19234
  Object.defineProperty(exports, "__esModule", {
18932
19235
  value: true
@@ -24787,9 +25090,9 @@ var TagadaReactSDKBundle = (() => {
24787
25090
  }
24788
25091
  });
24789
25092
 
24790
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js
25093
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js
24791
25094
  var require_BasisTheoryReact = __commonJS({
24792
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js"(exports) {
25095
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js"(exports) {
24793
25096
  "use strict";
24794
25097
  Object.defineProperty(exports, "__esModule", {
24795
25098
  value: true
@@ -24848,9 +25151,9 @@ var TagadaReactSDKBundle = (() => {
24848
25151
  }
24849
25152
  });
24850
25153
 
24851
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js
25154
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js
24852
25155
  var require_useBasisTheory = __commonJS({
24853
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js"(exports) {
25156
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js"(exports) {
24854
25157
  "use strict";
24855
25158
  Object.defineProperty(exports, "__esModule", {
24856
25159
  value: true
@@ -25293,9 +25596,9 @@ var TagadaReactSDKBundle = (() => {
25293
25596
  }
25294
25597
  });
25295
25598
 
25296
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/index.js
25599
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/index.js
25297
25600
  var require_core = __commonJS({
25298
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/core/index.js"(exports) {
25601
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/index.js"(exports) {
25299
25602
  "use strict";
25300
25603
  Object.defineProperty(exports, "__esModule", {
25301
25604
  value: true
@@ -25409,9 +25712,9 @@ var TagadaReactSDKBundle = (() => {
25409
25712
  }
25410
25713
  });
25411
25714
 
25412
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js
25715
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js
25413
25716
  var require_useBasisTheoryValue = __commonJS({
25414
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js"(exports) {
25717
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js"(exports) {
25415
25718
  "use strict";
25416
25719
  Object.defineProperty(exports, "__esModule", {
25417
25720
  value: true
@@ -25428,9 +25731,9 @@ var TagadaReactSDKBundle = (() => {
25428
25731
  }
25429
25732
  });
25430
25733
 
25431
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useElement.js
25734
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useElement.js
25432
25735
  var require_useElement = __commonJS({
25433
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useElement.js"(exports) {
25736
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useElement.js"(exports) {
25434
25737
  "use strict";
25435
25738
  Object.defineProperty(exports, "__esModule", {
25436
25739
  value: true
@@ -25496,9 +25799,9 @@ var TagadaReactSDKBundle = (() => {
25496
25799
  }
25497
25800
  });
25498
25801
 
25499
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useListener.js
25802
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useListener.js
25500
25803
  var require_useListener = __commonJS({
25501
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/useListener.js"(exports) {
25804
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useListener.js"(exports) {
25502
25805
  "use strict";
25503
25806
  Object.defineProperty(exports, "__esModule", {
25504
25807
  value: true
@@ -25519,9 +25822,9 @@ var TagadaReactSDKBundle = (() => {
25519
25822
  }
25520
25823
  });
25521
25824
 
25522
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js
25825
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js
25523
25826
  var require_CardElement = __commonJS({
25524
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js"(exports) {
25827
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js"(exports) {
25525
25828
  "use strict";
25526
25829
  Object.defineProperty(exports, "__esModule", {
25527
25830
  value: true
@@ -25640,9 +25943,9 @@ var TagadaReactSDKBundle = (() => {
25640
25943
  }
25641
25944
  });
25642
25945
 
25643
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js
25946
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js
25644
25947
  var require_TextElement = __commonJS({
25645
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js"(exports) {
25948
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js"(exports) {
25646
25949
  "use strict";
25647
25950
  Object.defineProperty(exports, "__esModule", {
25648
25951
  value: true
@@ -25767,9 +26070,9 @@ var TagadaReactSDKBundle = (() => {
25767
26070
  }
25768
26071
  });
25769
26072
 
25770
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js
26073
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js
25771
26074
  var require_CardNumberElement = __commonJS({
25772
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js"(exports) {
26075
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js"(exports) {
25773
26076
  "use strict";
25774
26077
  Object.defineProperty(exports, "__esModule", {
25775
26078
  value: true
@@ -25891,9 +26194,9 @@ var TagadaReactSDKBundle = (() => {
25891
26194
  }
25892
26195
  });
25893
26196
 
25894
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js
26197
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js
25895
26198
  var require_CardExpirationDateElement = __commonJS({
25896
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js"(exports) {
26199
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js"(exports) {
25897
26200
  "use strict";
25898
26201
  Object.defineProperty(exports, "__esModule", {
25899
26202
  value: true
@@ -26009,9 +26312,9 @@ var TagadaReactSDKBundle = (() => {
26009
26312
  }
26010
26313
  });
26011
26314
 
26012
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js
26315
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js
26013
26316
  var require_CardVerificationCodeElement = __commonJS({
26014
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js"(exports) {
26317
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js"(exports) {
26015
26318
  "use strict";
26016
26319
  Object.defineProperty(exports, "__esModule", {
26017
26320
  value: true
@@ -26129,9 +26432,9 @@ var TagadaReactSDKBundle = (() => {
26129
26432
  }
26130
26433
  });
26131
26434
 
26132
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/index.js
26435
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/index.js
26133
26436
  var require_elements4 = __commonJS({
26134
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/elements/index.js"(exports) {
26437
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/index.js"(exports) {
26135
26438
  "use strict";
26136
26439
  Object.defineProperty(exports, "__esModule", {
26137
26440
  value: true
@@ -26174,9 +26477,9 @@ var TagadaReactSDKBundle = (() => {
26174
26477
  }
26175
26478
  });
26176
26479
 
26177
- // ../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/index.js
26480
+ // ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/index.js
26178
26481
  var require_basis_theory_react = __commonJS({
26179
- "../../node_modules/.pnpm/@basis-theory+basis-theory-react@1.32.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@basis-theory/basis-theory-react/index.js"(exports) {
26482
+ "../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/index.js"(exports) {
26180
26483
  "use strict";
26181
26484
  Object.defineProperty(exports, "__esModule", {
26182
26485
  value: true
@@ -27537,9 +27840,9 @@ var TagadaReactSDKBundle = (() => {
27537
27840
  }
27538
27841
  });
27539
27842
 
27540
- // ../../node_modules/.pnpm/@google-pay+button-react@3.2.1_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2_artz6mpnatrpkeivsxoyu6cm2i/node_modules/@google-pay/button-react/dist/index.umd.min.js
27843
+ // ../../node_modules/.pnpm/@google-pay+button-react@3._bb72023390b4ccbcc01656d1bbc0eaa2/node_modules/@google-pay/button-react/dist/index.umd.min.js
27541
27844
  var require_index_umd_min = __commonJS({
27542
- "../../node_modules/.pnpm/@google-pay+button-react@3.2.1_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2_artz6mpnatrpkeivsxoyu6cm2i/node_modules/@google-pay/button-react/dist/index.umd.min.js"(exports, module) {
27845
+ "../../node_modules/.pnpm/@google-pay+button-react@3._bb72023390b4ccbcc01656d1bbc0eaa2/node_modules/@google-pay/button-react/dist/index.umd.min.js"(exports, module) {
27543
27846
  !function(e3, t3) {
27544
27847
  "object" == typeof exports && "undefined" != typeof module ? module.exports = t3(__require("react")) : "function" == typeof define && define.amd ? define(["react"], t3) : (e3 = "undefined" != typeof globalThis ? globalThis : e3 || self).GooglePayButton = t3(e3.React);
27545
27848
  }(exports, function(e3) {
@@ -27739,6 +28042,8 @@ var TagadaReactSDKBundle = (() => {
27739
28042
  var index_exports = {};
27740
28043
  __export(index_exports, {
27741
28044
  ApplePayButton: () => ApplePayButton,
28045
+ CLICK_ID_COOKIES: () => CLICK_ID_COOKIES,
28046
+ CLICK_ID_URL_PARAMS: () => CLICK_ID_URL_PARAMS,
27742
28047
  ExpressPaymentMethodsProvider: () => ExpressPaymentMethodsProvider,
27743
28048
  FunnelActionType: () => FunnelActionType,
27744
28049
  GooglePayButton: () => GooglePayButton,
@@ -27761,7 +28066,10 @@ var TagadaReactSDKBundle = (() => {
27761
28066
  getExpressMethods: () => getExpressMethods,
27762
28067
  getExpressMethodsByProcessor: () => getExpressMethodsByProcessor,
27763
28068
  isMethodEnabled: () => isMethodEnabled,
28069
+ makeMetaEventId: () => makeMetaEventId,
28070
+ publishTrackingGlobal: () => publishTrackingGlobal,
27764
28071
  queryKeys: () => queryKeys,
28072
+ resolveClickId: () => resolveClickId,
27765
28073
  useApiMutation: () => useApiMutation,
27766
28074
  useApiQuery: () => useApiQuery,
27767
28075
  useApplePayCheckout: () => useApplePayCheckout,
@@ -27867,8 +28175,7 @@ var TagadaReactSDKBundle = (() => {
27867
28175
  }, []);
27868
28176
  const effectiveSessionId = sessionId || ((_a11 = checkout == null ? void 0 : checkout.checkoutSession) == null ? void 0 : _a11.id);
27869
28177
  const hasSyncedInitialSelectionRef = (0, import_react.useRef)(false);
27870
- const [previewedRates, setPreviewedRates] = (0, import_react.useState)();
27871
- const [isPreviewLoading, setIsPreviewLoading] = (0, import_react.useState)(false);
28178
+ const [previewParams, setPreviewParams] = (0, import_react.useState)(null);
27872
28179
  const {
27873
28180
  data: shippingRatesData,
27874
28181
  isLoading: isFetching,
@@ -27897,6 +28204,24 @@ var TagadaReactSDKBundle = (() => {
27897
28204
  }
27898
28205
  });
27899
28206
  const shippingRates = shippingRatesData == null ? void 0 : shippingRatesData.rates;
28207
+ const {
28208
+ data: previewedRates,
28209
+ isLoading: isPreviewLoading
28210
+ } = useQuery({
28211
+ queryKey: ["shipping-rates-preview", effectiveSessionId, previewParams == null ? void 0 : previewParams.countryCode, previewParams == null ? void 0 : previewParams.stateCode],
28212
+ queryFn: async () => {
28213
+ const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, previewParams);
28214
+ return [...response.rates].sort((a3, b3) => {
28215
+ var _a12, _b3;
28216
+ if (a3.isFree && !b3.isFree) return -1;
28217
+ if (!a3.isFree && b3.isFree) return 1;
28218
+ return ((_a12 = a3.amount) != null ? _a12 : 0) - ((_b3 = b3.amount) != null ? _b3 : 0);
28219
+ });
28220
+ },
28221
+ enabled: !!effectiveSessionId && !!previewParams,
28222
+ staleTime: 3e4,
28223
+ refetchOnWindowFocus: false
28224
+ });
27900
28225
  const checkoutSelectedRateId = (_c = (_b2 = checkout == null ? void 0 : checkout.checkoutSession) == null ? void 0 : _b2.shippingRate) == null ? void 0 : _c.id;
27901
28226
  const setShippingRateMutation = useMutation({
27902
28227
  mutationFn: ({ rateId }) => {
@@ -27952,27 +28277,28 @@ var TagadaReactSDKBundle = (() => {
27952
28277
  }, [refetch]);
27953
28278
  const previewRates = (0, import_react.useCallback)(async (countryCode, stateCode) => {
27954
28279
  if (!enabled || !effectiveSessionId) return [];
28280
+ setPreviewParams({ countryCode, stateCode });
27955
28281
  try {
27956
- setIsPreviewLoading(true);
27957
- const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, {
27958
- countryCode,
27959
- stateCode
27960
- });
27961
- const sortedRates = [...response.rates].sort((a3, b3) => {
27962
- var _a12, _b3;
27963
- if (a3.isFree && !b3.isFree) return -1;
27964
- if (!a3.isFree && b3.isFree) return 1;
27965
- return ((_a12 = a3.amount) != null ? _a12 : 0) - ((_b3 = b3.amount) != null ? _b3 : 0);
28282
+ return await queryClient.fetchQuery({
28283
+ queryKey: ["shipping-rates-preview", effectiveSessionId, countryCode, stateCode],
28284
+ queryFn: async () => {
28285
+ const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, {
28286
+ countryCode,
28287
+ stateCode
28288
+ });
28289
+ return [...response.rates].sort((a3, b3) => {
28290
+ var _a12, _b3;
28291
+ if (a3.isFree && !b3.isFree) return -1;
28292
+ if (!a3.isFree && b3.isFree) return 1;
28293
+ return ((_a12 = a3.amount) != null ? _a12 : 0) - ((_b3 = b3.amount) != null ? _b3 : 0);
28294
+ });
28295
+ }
27966
28296
  });
27967
- setPreviewedRates(sortedRates);
27968
- return sortedRates;
27969
28297
  } catch (error) {
27970
28298
  console.error("[useShippingRatesQuery] Error previewing shipping rates:", error);
27971
28299
  return [];
27972
- } finally {
27973
- setIsPreviewLoading(false);
27974
28300
  }
27975
- }, [enabled, effectiveSessionId, shippingRatesResource]);
28301
+ }, [enabled, effectiveSessionId, queryClient, shippingRatesResource]);
27976
28302
  return {
27977
28303
  shippingRates,
27978
28304
  selectedRate,
@@ -31049,6 +31375,7 @@ var TagadaReactSDKBundle = (() => {
31049
31375
  }
31050
31376
 
31051
31377
  // src/v2/react/components/ApplePayButton.tsx
31378
+ init_useStepConfig();
31052
31379
  var import_jsx_runtime7 = __require("react/jsx-runtime");
31053
31380
  var applePayContactToAddress = (contact) => {
31054
31381
  var _a11, _b2;
@@ -31101,6 +31428,13 @@ var TagadaReactSDKBundle = (() => {
31101
31428
  } = useExpressPaymentMethods();
31102
31429
  const [processingPayment, setProcessingPayment] = (0, import_react34.useState)(false);
31103
31430
  const [isApplePayAvailable, setIsApplePayAvailable] = (0, import_react34.useState)(false);
31431
+ const { stepConfig } = useStepConfig();
31432
+ const countryAllowlist = (0, import_react34.useMemo)(() => {
31433
+ var _a12;
31434
+ const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
31435
+ if (!list || list.length === 0) return void 0;
31436
+ return list.map((c3) => c3.toUpperCase());
31437
+ }, [stepConfig]);
31104
31438
  const basistheoryPublicKey = (0, import_react34.useMemo)(() => getBasisTheoryApiKey(), []);
31105
31439
  const { processApplePayPayment } = usePaymentQuery();
31106
31440
  const { selectRate } = useShippingRatesQuery({ checkout });
@@ -31223,7 +31557,7 @@ var TagadaReactSDKBundle = (() => {
31223
31557
  amount: minorUnitsToCurrencyString(checkout.summary.totalAdjustedAmount, checkout.summary.currency),
31224
31558
  type: "final"
31225
31559
  };
31226
- const request = {
31560
+ const request = __spreadValues({
31227
31561
  countryCode: ((_b2 = applePayPaymentMethod == null ? void 0 : applePayPaymentMethod.metadata) == null ? void 0 : _b2.country) || "US",
31228
31562
  currencyCode: checkout.summary.currency,
31229
31563
  supportedNetworks: ["visa", "masterCard", "amex", "discover"],
@@ -31233,7 +31567,7 @@ var TagadaReactSDKBundle = (() => {
31233
31567
  lineItems,
31234
31568
  requiredShippingContactFields: ["name", "phone", "email", "postalAddress"],
31235
31569
  requiredBillingContactFields: ["postalAddress"]
31236
- };
31570
+ }, countryAllowlist ? { supportedCountries: countryAllowlist } : {});
31237
31571
  try {
31238
31572
  const session = new ApplePaySession(3, request);
31239
31573
  session.onvalidatemerchant = (event) => {
@@ -31254,6 +31588,14 @@ var TagadaReactSDKBundle = (() => {
31254
31588
  const billingContact = event.payment.billingContact;
31255
31589
  const shippingAddress = applePayContactToAddress(shippingContact);
31256
31590
  const billingAddress = applePayContactToAddress(billingContact);
31591
+ if (countryAllowlist && shippingAddress.country && !countryAllowlist.includes(shippingAddress.country.toUpperCase())) {
31592
+ console.error("[ApplePay] Shipping country not in allowlist:", shippingAddress.country);
31593
+ session.completePayment(ApplePaySession.STATUS_FAILURE);
31594
+ const errorMessage = "Shipping to this country is not supported";
31595
+ setContextError(errorMessage);
31596
+ if (onError3) onError3(errorMessage);
31597
+ return;
31598
+ }
31257
31599
  await updateCheckoutSessionValues({
31258
31600
  data: {
31259
31601
  shippingAddress,
@@ -31314,7 +31656,37 @@ var TagadaReactSDKBundle = (() => {
31314
31656
  };
31315
31657
  session.onshippingcontactselected = (event) => {
31316
31658
  void (async () => {
31659
+ var _a13, _b3, _c, _d;
31317
31660
  const shippingContact = event.shippingContact;
31661
+ const contactCountry = ((shippingContact == null ? void 0 : shippingContact.countryCode) || "").toUpperCase();
31662
+ if (countryAllowlist && contactCountry && !countryAllowlist.includes(contactCountry)) {
31663
+ console.warn("[ApplePay] Selected shipping country not in allowlist:", contactCountry);
31664
+ const ApplePayErrorCtor = window.ApplePayError;
31665
+ const currentTotal = {
31666
+ label: ((_a13 = checkout.checkoutSession.store) == null ? void 0 : _a13.name) || "Store",
31667
+ amount: minorUnitsToCurrencyString(
31668
+ (_c = (_b3 = checkout.summary) == null ? void 0 : _b3.totalAdjustedAmount) != null ? _c : 0,
31669
+ (_d = checkout.summary) == null ? void 0 : _d.currency
31670
+ ),
31671
+ type: "final"
31672
+ };
31673
+ const errors = ApplePayErrorCtor ? [new ApplePayErrorCtor(
31674
+ "shippingContactInvalid",
31675
+ "country",
31676
+ "Shipping to this country is not supported"
31677
+ )] : [{
31678
+ code: "shippingContactInvalid",
31679
+ contactField: "country",
31680
+ message: "Shipping to this country is not supported"
31681
+ }];
31682
+ session.completeShippingContactSelection({
31683
+ newTotal: currentTotal,
31684
+ newLineItems: lineItems,
31685
+ newShippingMethods: [],
31686
+ errors
31687
+ });
31688
+ return;
31689
+ }
31318
31690
  try {
31319
31691
  await updateCheckoutSessionValues({
31320
31692
  data: {
@@ -31370,6 +31742,7 @@ var TagadaReactSDKBundle = (() => {
31370
31742
  shippingMethods,
31371
31743
  lineItems,
31372
31744
  applePayPaymentMethod,
31745
+ countryAllowlist,
31373
31746
  minorUnitsToCurrencyString,
31374
31747
  validateMerchant,
31375
31748
  tokenizeApplePay,
@@ -31416,7 +31789,7 @@ var TagadaReactSDKBundle = (() => {
31416
31789
  );
31417
31790
  };
31418
31791
 
31419
- // ../../node_modules/.pnpm/@stripe+react-stripe-js@5.6.1_@stripe+stripe-js@8.11.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs
31792
+ // ../../node_modules/.pnpm/@stripe+react-stripe-js@5.6_b5ce487d3341346f9e43c58fb3ea9d2c/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs
31420
31793
  var import_react35 = __toESM(__require("react"), 1);
31421
31794
  var import_prop_types = __toESM(require_prop_types(), 1);
31422
31795
  function ownKeys2(object, enumerableOnly) {
@@ -32128,6 +32501,7 @@ var TagadaReactSDKBundle = (() => {
32128
32501
  // src/v2/react/components/StripeExpressButton.tsx
32129
32502
  var import_react36 = __require("react");
32130
32503
  init_payments();
32504
+ init_useStepConfig();
32131
32505
  init_useApiQuery();
32132
32506
  var import_jsx_runtime8 = __require("react/jsx-runtime");
32133
32507
  var EXPRESS_METHOD_KEYS = ["apple_pay", "google_pay", "link", "klarna_express"];
@@ -32146,6 +32520,13 @@ var TagadaReactSDKBundle = (() => {
32146
32520
  const { startPolling } = usePaymentPolling();
32147
32521
  const isProcessingRef = (0, import_react36.useRef)(false);
32148
32522
  const [visible, setVisible] = (0, import_react36.useState)(false);
32523
+ const { stepConfig } = useStepConfig();
32524
+ const countryAllowlist = (0, import_react36.useMemo)(() => {
32525
+ var _a12;
32526
+ const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
32527
+ if (!list || list.length === 0) return void 0;
32528
+ return list.map((c3) => c3.toUpperCase());
32529
+ }, [stepConfig]);
32149
32530
  const paymentsResource = (0, import_react36.useMemo)(() => new PaymentsResource(getGlobalApiClient()), []);
32150
32531
  const liveAmount = Math.round((_b2 = (_a11 = checkout.summary) == null ? void 0 : _a11.totalAdjustedAmount) != null ? _b2 : 0);
32151
32532
  const liveCurrency = (((_c = checkout.summary) == null ? void 0 : _c.currency) || "usd").toLowerCase();
@@ -32154,12 +32535,13 @@ var TagadaReactSDKBundle = (() => {
32154
32535
  elements.update({ amount: liveAmount, currency: liveCurrency });
32155
32536
  }, [elements, liveAmount, liveCurrency]);
32156
32537
  const onConfirm = async (event) => {
32157
- var _a12, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
32538
+ var _a12, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
32158
32539
  if (!stripe || !elements || isProcessingRef.current) return;
32159
32540
  isProcessingRef.current = true;
32160
32541
  const paymentMethod = event.expressPaymentType;
32161
32542
  try {
32162
32543
  const billing = event.billingDetails;
32544
+ const eventShipping = event.shippingAddress;
32163
32545
  if (billing) {
32164
32546
  const nameParts = ((_a12 = billing.name) != null ? _a12 : "").trim().split(/\s+/);
32165
32547
  const firstName = (_b3 = nameParts[0]) != null ? _b3 : "";
@@ -32176,9 +32558,28 @@ var TagadaReactSDKBundle = (() => {
32176
32558
  phone: (_o = billing.phone) != null ? _o : "",
32177
32559
  email: (_p = billing.email) != null ? _p : ""
32178
32560
  };
32561
+ const shippingFromEvent = (eventShipping == null ? void 0 : eventShipping.address) ? {
32562
+ firstName: (_r = ((_q = eventShipping.name) != null ? _q : "").trim().split(/\s+/)[0]) != null ? _r : "",
32563
+ lastName: ((_s = eventShipping.name) != null ? _s : "").trim().split(/\s+/).slice(1).join(" "),
32564
+ address1: (_t = eventShipping.address.line1) != null ? _t : "",
32565
+ address2: (_u = eventShipping.address.line2) != null ? _u : "",
32566
+ city: (_v = eventShipping.address.city) != null ? _v : "",
32567
+ state: (_w = eventShipping.address.state) != null ? _w : "",
32568
+ country: (_x = eventShipping.address.country) != null ? _x : "",
32569
+ postal: (_y = eventShipping.address.postal_code) != null ? _y : "",
32570
+ phone: (_z = billing.phone) != null ? _z : "",
32571
+ email: (_A = billing.email) != null ? _A : ""
32572
+ } : billingAddress;
32573
+ const shippingCountry = shippingFromEvent.country.toUpperCase();
32574
+ if (countryAllowlist && shippingCountry && !countryAllowlist.includes(shippingCountry)) {
32575
+ console.error("[StripeExpress] Shipping country not in allowlist:", shippingCountry);
32576
+ onError3 == null ? void 0 : onError3("Shipping to this country is not supported");
32577
+ isProcessingRef.current = false;
32578
+ return;
32579
+ }
32179
32580
  await updateCheckoutSessionValues({
32180
32581
  data: {
32181
- shippingAddress: billingAddress,
32582
+ shippingAddress: shippingFromEvent,
32182
32583
  billingAddress
32183
32584
  }
32184
32585
  });
@@ -32188,11 +32589,11 @@ var TagadaReactSDKBundle = (() => {
32188
32589
  }
32189
32590
  const { error: submitError } = await elements.submit();
32190
32591
  if (submitError) {
32191
- onError3 == null ? void 0 : onError3((_q = submitError.message) != null ? _q : "Validation failed");
32592
+ onError3 == null ? void 0 : onError3((_B = submitError.message) != null ? _B : "Validation failed");
32192
32593
  isProcessingRef.current = false;
32193
32594
  return;
32194
32595
  }
32195
- const shippingRateId = checkout.checkoutSession.shippingRateId || ((_r = checkout.checkoutSession.shippingRate) == null ? void 0 : _r.id);
32596
+ const shippingRateId = checkout.checkoutSession.shippingRateId || ((_C = checkout.checkoutSession.shippingRate) == null ? void 0 : _C.id);
32196
32597
  const response = await paymentsResource.processPaymentDirect(
32197
32598
  checkout.checkoutSession.id,
32198
32599
  "",
@@ -32205,7 +32606,7 @@ var TagadaReactSDKBundle = (() => {
32205
32606
  shippingRateId
32206
32607
  }
32207
32608
  );
32208
- const clientSecret = (_v = (_u = (_t = (_s = response == null ? void 0 : response.payment) == null ? void 0 : _s.requireActionData) == null ? void 0 : _t.metadata) == null ? void 0 : _u.stripeExpressCheckout) == null ? void 0 : _v.clientSecret;
32609
+ const clientSecret = (_G = (_F = (_E = (_D = response == null ? void 0 : response.payment) == null ? void 0 : _D.requireActionData) == null ? void 0 : _E.metadata) == null ? void 0 : _F.stripeExpressCheckout) == null ? void 0 : _G.clientSecret;
32209
32610
  if (!clientSecret) {
32210
32611
  onError3 == null ? void 0 : onError3("Express checkout configuration missing \u2014 no client secret returned");
32211
32612
  isProcessingRef.current = false;
@@ -32221,7 +32622,7 @@ var TagadaReactSDKBundle = (() => {
32221
32622
  redirect: "if_required"
32222
32623
  });
32223
32624
  if (confirmError) {
32224
- onError3 == null ? void 0 : onError3((_w = confirmError.message) != null ? _w : "Payment confirmation failed");
32625
+ onError3 == null ? void 0 : onError3((_H = confirmError.message) != null ? _H : "Payment confirmation failed");
32225
32626
  isProcessingRef.current = false;
32226
32627
  return;
32227
32628
  }
@@ -32250,7 +32651,13 @@ var TagadaReactSDKBundle = (() => {
32250
32651
  onError3 == null ? void 0 : onError3(msg);
32251
32652
  }
32252
32653
  };
32253
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { visibility: visible ? "visible" : "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32654
+ const hiddenStyle = {
32655
+ position: "absolute",
32656
+ left: "-9999px",
32657
+ top: "-9999px",
32658
+ pointerEvents: "none"
32659
+ };
32660
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: visible ? void 0 : hiddenStyle, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32254
32661
  ExpressCheckoutElement,
32255
32662
  {
32256
32663
  onReady: ({ availablePaymentMethods }) => {
@@ -32264,7 +32671,7 @@ var TagadaReactSDKBundle = (() => {
32264
32671
  isProcessingRef.current = false;
32265
32672
  onCancel == null ? void 0 : onCancel();
32266
32673
  },
32267
- options: {
32674
+ options: __spreadValues({
32268
32675
  buttonType: {
32269
32676
  applePay: "buy",
32270
32677
  googlePay: "buy"
@@ -32278,7 +32685,10 @@ var TagadaReactSDKBundle = (() => {
32278
32685
  },
32279
32686
  emailRequired: true,
32280
32687
  billingAddressRequired: true
32281
- }
32688
+ }, countryAllowlist ? {
32689
+ shippingAddressRequired: true,
32690
+ allowedShippingCountries: countryAllowlist
32691
+ } : {})
32282
32692
  }
32283
32693
  ) });
32284
32694
  }
@@ -32322,6 +32732,7 @@ var TagadaReactSDKBundle = (() => {
32322
32732
  // src/v2/react/components/GooglePayButton.tsx
32323
32733
  var import_button_react = __toESM(require_index_umd_min());
32324
32734
  var import_react37 = __require("react");
32735
+ init_useStepConfig();
32325
32736
  var import_jsx_runtime9 = __require("react/jsx-runtime");
32326
32737
  var GooglePayButton = ({
32327
32738
  className = "",
@@ -32365,6 +32776,13 @@ var TagadaReactSDKBundle = (() => {
32365
32776
  const [processingPayment, setProcessingPayment] = (0, import_react37.useState)(false);
32366
32777
  const [pendingPaymentData, setPendingPaymentData] = (0, import_react37.useState)(null);
32367
32778
  const [googlePayError, setGooglePayError] = (0, import_react37.useState)(null);
32779
+ const { stepConfig } = useStepConfig();
32780
+ const countryAllowlist = (0, import_react37.useMemo)(() => {
32781
+ var _a12;
32782
+ const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
32783
+ if (!list || list.length === 0) return void 0;
32784
+ return list.map((c3) => c3.toUpperCase());
32785
+ }, [stepConfig]);
32368
32786
  if (!googlePayPaymentMethod) {
32369
32787
  return null;
32370
32788
  }
@@ -32454,6 +32872,15 @@ var TagadaReactSDKBundle = (() => {
32454
32872
  if (paymentData.shippingAddress) {
32455
32873
  shippingAddress = googlePayAddressToAddress(paymentData.shippingAddress);
32456
32874
  }
32875
+ if (countryAllowlist && (shippingAddress == null ? void 0 : shippingAddress.country) && !countryAllowlist.includes(shippingAddress.country.toUpperCase())) {
32876
+ const msg = "Shipping to this country is not supported";
32877
+ console.error("[GooglePay] Shipping country not in allowlist:", shippingAddress.country);
32878
+ setProcessingPayment(false);
32879
+ setGooglePayError(msg);
32880
+ setContextError(msg);
32881
+ if (onError3) onError3(msg);
32882
+ return;
32883
+ }
32457
32884
  if (shippingAddress) {
32458
32885
  await updateCheckoutSessionValues({
32459
32886
  data: {
@@ -32491,6 +32918,7 @@ var TagadaReactSDKBundle = (() => {
32491
32918
  updateCustomerEmail,
32492
32919
  tokenizeGooglePayTokenWithBasisTheory,
32493
32920
  handleGooglePayPayment,
32921
+ countryAllowlist,
32494
32922
  onSuccess,
32495
32923
  onError3,
32496
32924
  setContextError
@@ -32519,6 +32947,17 @@ var TagadaReactSDKBundle = (() => {
32519
32947
  const paymentDataRequestUpdate = {};
32520
32948
  if (intermediatePaymentData.callbackTrigger === "SHIPPING_ADDRESS") {
32521
32949
  const address = intermediatePaymentData.shippingAddress;
32950
+ const addressCountry = ((address == null ? void 0 : address.countryCode) || "").toUpperCase();
32951
+ if (countryAllowlist && addressCountry && !countryAllowlist.includes(addressCountry)) {
32952
+ resolve({
32953
+ error: {
32954
+ reason: "SHIPPING_ADDRESS_UNSERVICEABLE",
32955
+ message: "Shipping to this country is not supported",
32956
+ intent: "SHIPPING_ADDRESS"
32957
+ }
32958
+ });
32959
+ return;
32960
+ }
32522
32961
  const shippingAddress = {
32523
32962
  address1: ((_a12 = address == null ? void 0 : address.addressLines) == null ? void 0 : _a12[0]) || "",
32524
32963
  address2: ((_b3 = address == null ? void 0 : address.addressLines) == null ? void 0 : _b3[1]) || "",
@@ -32586,7 +33025,7 @@ var TagadaReactSDKBundle = (() => {
32586
33025
  void processCallback();
32587
33026
  });
32588
33027
  },
32589
- [updateCheckoutSessionValues, reComputeOrderSummary, checkout, selectRate]
33028
+ [updateCheckoutSessionValues, reComputeOrderSummary, checkout, selectRate, countryAllowlist]
32590
33029
  );
32591
33030
  const handleGooglePayAuthorized = (0, import_react37.useCallback)(
32592
33031
  (paymentData) => {
@@ -32646,6 +33085,7 @@ var TagadaReactSDKBundle = (() => {
32646
33085
  emailRequired: true,
32647
33086
  callbackIntents: requiresShipping ? ["SHIPPING_OPTION", "SHIPPING_ADDRESS", "PAYMENT_AUTHORIZATION"] : ["PAYMENT_AUTHORIZATION"]
32648
33087
  }, requiresShipping && {
33088
+ shippingAddressParameters: countryAllowlist ? { allowedCountryCodes: countryAllowlist } : void 0,
32649
33089
  shippingOptionParameters: {
32650
33090
  defaultSelectedOptionId: ((_h = (_g = checkout.checkoutSession) == null ? void 0 : _g.shippingRate) == null ? void 0 : _h.id) || (shippingMethods.length > 0 ? shippingMethods[0].identifier : ""),
32651
33091
  shippingOptions: shippingMethods.map((method) => ({
@@ -35774,7 +36214,9 @@ var TagadaReactSDKBundle = (() => {
35774
36214
  if (sessionId) {
35775
36215
  await Promise.all([
35776
36216
  queryClient.invalidateQueries({ queryKey: ["discounts", sessionId] }),
35777
- queryClient.invalidateQueries({ queryKey: ["checkout"] })
36217
+ queryClient.invalidateQueries({ queryKey: ["checkout"] }),
36218
+ queryClient.invalidateQueries({ queryKey: ["shipping-rates", sessionId] }),
36219
+ queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", sessionId] })
35778
36220
  ]);
35779
36221
  }
35780
36222
  if (onApplySuccess) {
@@ -35798,7 +36240,9 @@ var TagadaReactSDKBundle = (() => {
35798
36240
  if (sessionId) {
35799
36241
  await Promise.all([
35800
36242
  queryClient.invalidateQueries({ queryKey: ["discounts", sessionId] }),
35801
- queryClient.invalidateQueries({ queryKey: ["checkout"] })
36243
+ queryClient.invalidateQueries({ queryKey: ["checkout"] }),
36244
+ queryClient.invalidateQueries({ queryKey: ["shipping-rates", sessionId] }),
36245
+ queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", sessionId] })
35802
36246
  ]);
35803
36247
  }
35804
36248
  if (onRemoveSuccess) {
@@ -37157,7 +37601,7 @@ var TagadaReactSDKBundle = (() => {
37157
37601
  };
37158
37602
  });
37159
37603
  }, [summary, effectiveCurrency]);
37160
- const pay = (0, import_react65.useCallback)(async (mainOrderId) => {
37604
+ const pay = (0, import_react65.useCallback)(async (mainOrderId, payOptions) => {
37161
37605
  if (isPaying) {
37162
37606
  throw new Error("Payment already in progress");
37163
37607
  }
@@ -37168,7 +37612,8 @@ var TagadaReactSDKBundle = (() => {
37168
37612
  effectiveCurrency,
37169
37613
  lineItemsForPreview,
37170
37614
  typeof window !== "undefined" ? window.location.href : void 0,
37171
- mainOrderId
37615
+ mainOrderId,
37616
+ payOptions == null ? void 0 : payOptions.initiatedBy
37172
37617
  );
37173
37618
  console.log("[usePreviewOffer] Payment initiated:", result);
37174
37619
  return {
@@ -37340,17 +37785,19 @@ var TagadaReactSDKBundle = (() => {
37340
37785
  init_modern2();
37341
37786
  init_promotions2();
37342
37787
  init_useApiQuery();
37788
+ init_TagadaProvider();
37343
37789
  function usePromotionsQuery(options = {}) {
37344
37790
  const { checkoutSessionId, enabled = true } = options;
37345
37791
  const queryClient = useQueryClient();
37346
- const client = getGlobalApiClient();
37792
+ const apiClient = getGlobalApiClient();
37793
+ const { client } = useTagadaContext();
37347
37794
  const promotionsResource = (0, import_react67.useMemo)(() => {
37348
37795
  try {
37349
- return new PromotionsResource(client);
37796
+ return new PromotionsResource(apiClient, client.bus);
37350
37797
  } catch (error2) {
37351
37798
  throw new Error("Failed to initialize promotions resource: " + (error2 instanceof Error ? error2.message : "Unknown error"));
37352
37799
  }
37353
- }, [client]);
37800
+ }, [apiClient, client.bus]);
37354
37801
  const {
37355
37802
  data: appliedPromotions = [],
37356
37803
  isLoading,
@@ -37375,6 +37822,8 @@ var TagadaReactSDKBundle = (() => {
37375
37822
  if (checkoutSessionId) {
37376
37823
  void queryClient.invalidateQueries({ queryKey: ["promotions", checkoutSessionId] });
37377
37824
  void queryClient.invalidateQueries({ queryKey: ["checkout", checkoutSessionId] });
37825
+ void queryClient.invalidateQueries({ queryKey: ["shipping-rates", checkoutSessionId] });
37826
+ void queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", checkoutSessionId] });
37378
37827
  }
37379
37828
  }
37380
37829
  });
@@ -37389,6 +37838,8 @@ var TagadaReactSDKBundle = (() => {
37389
37838
  if (checkoutSessionId) {
37390
37839
  void queryClient.invalidateQueries({ queryKey: ["promotions", checkoutSessionId] });
37391
37840
  void queryClient.invalidateQueries({ queryKey: ["checkout", checkoutSessionId] });
37841
+ void queryClient.invalidateQueries({ queryKey: ["shipping-rates", checkoutSessionId] });
37842
+ void queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", checkoutSessionId] });
37392
37843
  }
37393
37844
  }
37394
37845
  });
@@ -37606,7 +38057,8 @@ var TagadaReactSDKBundle = (() => {
37606
38057
  pixels: getAssignedPixels(),
37607
38058
  getScripts: (position) => getAssignedScripts(position),
37608
38059
  orderBumpOfferIds: getAssignedOrderBumpOfferIds(),
37609
- upsellOfferIds: getAssignedUpsellOfferIds()
38060
+ upsellOfferIds: getAssignedUpsellOfferIds(),
38061
+ paymentInitiator: getAssignedPaymentInitiator()
37610
38062
  };
37611
38063
  }, []);
37612
38064
  return __spreadProps(__spreadValues({}, funnel), {
@@ -38247,6 +38699,8 @@ var TagadaReactSDKBundle = (() => {
38247
38699
  init_funnel();
38248
38700
  init_funnelClient();
38249
38701
  init_money();
38702
+ init_metaEventId();
38703
+ init_clickIdResolver();
38250
38704
  init_errors();
38251
38705
  return __toCommonJS(index_exports);
38252
38706
  })();