@superlogic/spree-pay 0.1.31 → 0.1.35

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.
package/build/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // src/SpreePay.tsx
2
- import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect3, useMemo as useMemo9, useRef as useRef7, useState as useState15 } from "react";
2
+ import { useCallback as useCallback8, useEffect as useEffect11, useMemo as useMemo10, useState as useState14 } from "react";
3
3
  import NiceModal7 from "@ebay/nice-modal-react";
4
4
  import { SWRConfig } from "swr";
5
5
 
6
6
  // package.json
7
- var version = "0.1.31";
7
+ var version = "0.1.35";
8
8
 
9
9
  // src/context/SpreePayActionsContext.tsx
10
10
  import { createContext, useCallback, useContext, useRef, useState } from "react";
@@ -56,7 +56,8 @@ var SpreePayProvider = ({ children, env }) => {
56
56
  }
57
57
  }, []);
58
58
  const value = {
59
- env,
59
+ // Set default to true for web3 points to backward compatibility
60
+ env: { ...env, useWeb3Points: env.useWeb3Points ?? true },
60
61
  enabled: Boolean(selectedPaymentMethod.method),
61
62
  isInternalProcessing,
62
63
  process,
@@ -110,6 +111,16 @@ var CONFIG = {
110
111
  slapiUrl: "https://slapi.dev.air.shop",
111
112
  keycloakUrl: "https://login.dev.air.shop",
112
113
  keycloakClientId: "oneof-next"
114
+ },
115
+ qiibee: {
116
+ slapiUrl: "https://slapi.dev.superlogic.com",
117
+ keycloakUrl: "https://sso.dev.tickets.qiibeefoundation.org",
118
+ keycloakClientId: "oneof-next"
119
+ },
120
+ umhp: {
121
+ slapiUrl: "https://slapi.dev.umusicpassport.com",
122
+ keycloakUrl: "https://auth.dev.umusicpassport.com",
123
+ keycloakClientId: "oneof-next"
113
124
  }
114
125
  },
115
126
  stg: {
@@ -122,6 +133,16 @@ var CONFIG = {
122
133
  slapiUrl: "https://slapi.stg.air.shop",
123
134
  keycloakUrl: "https://login.stg.air.shop",
124
135
  keycloakClientId: "oneof-next"
136
+ },
137
+ qiibee: {
138
+ slapiUrl: "https://slapi.stg.tickets.qiibeefoundation.org",
139
+ keycloakUrl: "https://sso.stg.tickets.qiibeefoundation.org",
140
+ keycloakClientId: "oneof-next"
141
+ },
142
+ umhp: {
143
+ slapiUrl: "https://slapi.stg.umusicpassport.com",
144
+ keycloakUrl: "https://auth.stg.umusicpassport.com",
145
+ keycloakClientId: "oneof-next"
125
146
  }
126
147
  },
127
148
  prod: {
@@ -134,6 +155,16 @@ var CONFIG = {
134
155
  slapiUrl: "https://slapi.air.shop",
135
156
  keycloakUrl: "https://login.air.shop",
136
157
  keycloakClientId: "oneof-next"
158
+ },
159
+ qiibee: {
160
+ slapiUrl: "https://slapi.tickets.qiibeefoundation.org",
161
+ keycloakUrl: "https://sso.tickets.qiibeefoundation.org",
162
+ keycloakClientId: "oneof-next"
163
+ },
164
+ umhp: {
165
+ slapiUrl: "https://slapi.umusicpassport.com",
166
+ keycloakUrl: "https://auth.umusicpassport.com",
167
+ keycloakClientId: "oneof-next"
137
168
  }
138
169
  }
139
170
  };
@@ -787,7 +818,11 @@ async function longPollCardStatus(paymentId) {
787
818
  if (detail.status === "FAILED" /* FAILED */) {
788
819
  throw new Error(`Something went wrong with the ${detail.validationType} payment`);
789
820
  }
790
- if (detail.validationType === "POINTS") {
821
+ if (
822
+ // Process to points payment
823
+ detail.validationType === "POINTS" || // early card payment completion
824
+ ["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)
825
+ ) {
791
826
  return detail.status;
792
827
  }
793
828
  if (!shown3ds && detail.card?.redirectUrl) {
@@ -804,7 +839,7 @@ async function longPollCardStatus(paymentId) {
804
839
  }
805
840
 
806
841
  // src/hooks/payments/usePointsPayment.ts
807
- var usePointsPayment = () => {
842
+ var usePointsPayment = (mode = "web2") => {
808
843
  const { selectedPaymentMethod } = useSpreePaymentMethod();
809
844
  const { spreePayConfig } = useSpreePayConfig();
810
845
  const pointsPayment = async (params) => {
@@ -814,31 +849,42 @@ var usePointsPayment = () => {
814
849
  const { hash, capture, metadata } = params;
815
850
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
816
851
  hash,
817
- capture,
852
+ // capture should be always true for web2 points payments
853
+ capture: mode === "web2" ? true : capture,
818
854
  metadata,
819
855
  type: "POINTS" /* POINTS */
820
856
  });
821
- const wallet = peekAirWallet();
822
- if (!wallet || !spreePayConfig?.pointsChain) {
823
- throw new Error("AirWallet not found");
824
- }
825
- const transaction = await handleSendErc20({
826
- amount: params.points,
827
- token: spreePayConfig.pointsChain.pointsCoin,
828
- recipient: spreePayConfig.pointsChain.recipientAddress
829
- });
830
- if (!transaction) {
831
- throw new Error("Points transaction failed");
857
+ if (mode === "web3") {
858
+ const wallet = peekAirWallet();
859
+ if (!wallet || !spreePayConfig?.pointsChain) {
860
+ throw new Error("AirWallet not found");
861
+ }
862
+ const transaction = await handleSendErc20({
863
+ amount: params.points,
864
+ token: spreePayConfig.pointsChain.pointsCoin,
865
+ recipient: spreePayConfig.pointsChain.recipientAddress
866
+ });
867
+ if (!transaction) {
868
+ throw new Error("Points transaction failed");
869
+ }
870
+ await SlapiPaymentService.validatePoints({
871
+ paymentId: paymentResData.id,
872
+ txHash: transaction.txHash
873
+ });
874
+ const pointsStatus2 = await longPollPoints(paymentResData.id);
875
+ return {
876
+ status: pointsStatus2,
877
+ txId: paymentResData.txId,
878
+ txHash: transaction.txHash,
879
+ paymentId: paymentResData.id,
880
+ paymentType: "POINTS" /* POINTS */
881
+ };
832
882
  }
833
- await SlapiPaymentService.validatePoints({
834
- paymentId: paymentResData.id,
835
- txHash: transaction.txHash
836
- });
837
883
  const pointsStatus = await longPollPoints(paymentResData.id);
838
884
  return {
839
885
  status: pointsStatus,
840
886
  txId: paymentResData.txId,
841
- txHash: transaction.txHash,
887
+ txHash: null,
842
888
  paymentId: paymentResData.id,
843
889
  paymentType: "POINTS" /* POINTS */
844
890
  };
@@ -847,7 +893,7 @@ var usePointsPayment = () => {
847
893
  };
848
894
 
849
895
  // src/hooks/payments/useSplitCardPayments.ts
850
- var useSplitCardPayments = () => {
896
+ var useSplitCardPayments = (mode = "web2") => {
851
897
  const { selectedPaymentMethod } = useSpreePaymentMethod();
852
898
  const { env } = useSpreePayEnv();
853
899
  const { appProps } = useStaticConfig();
@@ -881,30 +927,39 @@ var useSplitCardPayments = () => {
881
927
  amount: points
882
928
  }
883
929
  });
884
- await longPollCardStatus(paymentResData.id);
885
- const wallet = peekAirWallet();
886
- if (!wallet || !spreePayConfig?.pointsChain) {
887
- throw new Error("AirWallet not found");
888
- }
889
- const transaction = await handleSendErc20({
890
- amount: params.points,
891
- token: spreePayConfig.pointsChain.pointsCoin,
892
- recipient: spreePayConfig.pointsChain.recipientAddress
893
- });
894
- if (!transaction) {
895
- throw new Error("Points transaction failed");
930
+ const cardStatus = await longPollCardStatus(paymentResData.id);
931
+ if (mode === "web3") {
932
+ const wallet = peekAirWallet();
933
+ if (!wallet || !spreePayConfig?.pointsChain) {
934
+ throw new Error("AirWallet not found");
935
+ }
936
+ const transaction = await handleSendErc20({
937
+ amount: params.points,
938
+ token: spreePayConfig.pointsChain.pointsCoin,
939
+ recipient: spreePayConfig.pointsChain.recipientAddress
940
+ });
941
+ if (!transaction) {
942
+ throw new Error("Points transaction failed");
943
+ }
944
+ await SlapiPaymentService.validatePoints({
945
+ paymentId: paymentResData.id,
946
+ txHash: transaction.txHash
947
+ });
948
+ const pointsStatus = await longPollPoints(paymentResData.id);
949
+ return {
950
+ paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
951
+ status: pointsStatus,
952
+ paymentId: paymentResData.id,
953
+ txId: paymentResData.txId,
954
+ txHash: transaction.txHash
955
+ };
896
956
  }
897
- await SlapiPaymentService.validatePoints({
898
- paymentId: paymentResData.id,
899
- txHash: transaction.txHash
900
- });
901
- const pointsStatus = await longPollPoints(paymentResData.id);
902
957
  return {
903
958
  paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
904
- status: pointsStatus,
959
+ status: cardStatus,
905
960
  paymentId: paymentResData.id,
906
961
  txId: paymentResData.txId,
907
- txHash: transaction.txHash
962
+ txHash: null
908
963
  };
909
964
  };
910
965
  return { splitPayment };
@@ -944,7 +999,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
944
999
  e.stopPropagation();
945
1000
  if (isSelected || isRemoveDisabled) return;
946
1001
  };
947
- return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
1002
+ return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-sm", children: [
948
1003
  /* @__PURE__ */ jsx8(
949
1004
  "div",
950
1005
  {
@@ -958,7 +1013,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
958
1013
  "div",
959
1014
  {
960
1015
  className: cn(
961
- "flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-3",
1016
+ "flex h-full w-full items-center justify-between rounded-r-sm border border-l-0! border-transparent px-3",
962
1017
  {
963
1018
  "border-primary": isSelected
964
1019
  }
@@ -1001,8 +1056,8 @@ var CardsList = ({ selectedCard, setCard }) => {
1001
1056
  const { cards, cardsIsLoading } = useCards();
1002
1057
  if (cardsIsLoading) {
1003
1058
  return /* @__PURE__ */ jsxs6("div", { className: "flex w-full flex-col gap-1", children: [
1004
- /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" }),
1005
- /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" })
1059
+ /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" }),
1060
+ /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" })
1006
1061
  ] });
1007
1062
  }
1008
1063
  if (cards.length === 0) return null;
@@ -1326,7 +1381,7 @@ var PointsSwitch = (props) => {
1326
1381
  };
1327
1382
 
1328
1383
  // src/components/CreditCardTab/Points/SplitBlock.tsx
1329
- import { useCallback as useCallback4, useEffect as useEffect6, useState as useState9 } from "react";
1384
+ import { useCallback as useCallback4, useEffect as useEffect6, useRef as useRef6, useState as useState9 } from "react";
1330
1385
  import { BUILD_ENV as BUILD_ENV2 } from "@mocanetwork/airkit";
1331
1386
 
1332
1387
  // src/components/CreditCardTab/Points/PointsSelector.tsx
@@ -1362,7 +1417,7 @@ function clamp(value, [min, max]) {
1362
1417
  return Math.min(max, Math.max(min, value));
1363
1418
  }
1364
1419
 
1365
- // ../../node_modules/@radix-ui/react-slider/node_modules/@radix-ui/primitive/dist/index.mjs
1420
+ // ../../node_modules/@radix-ui/primitive/dist/index.mjs
1366
1421
  var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
1367
1422
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
1368
1423
  return function handleEvent(event) {
@@ -1545,7 +1600,6 @@ function useUncontrolledState({
1545
1600
  function isFunction(value) {
1546
1601
  return typeof value === "function";
1547
1602
  }
1548
- var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
1549
1603
 
1550
1604
  // ../../node_modules/@radix-ui/react-direction/dist/index.mjs
1551
1605
  import * as React6 from "react";
@@ -1636,7 +1690,7 @@ var Primitive = NODES.reduce((primitive, node) => {
1636
1690
  const { asChild, ...primitiveProps } = props;
1637
1691
  const Comp = asChild ? Slot2 : node;
1638
1692
  if (typeof window !== "undefined") {
1639
- window[Symbol.for("radix-ui")] = true;
1693
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
1640
1694
  }
1641
1695
  return /* @__PURE__ */ jsx19(Comp, { ...primitiveProps, ref: forwardedRef });
1642
1696
  });
@@ -2265,14 +2319,8 @@ function cn2(...inputs) {
2265
2319
 
2266
2320
  // src/ui/slider.tsx
2267
2321
  import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
2268
- function Slider2({
2269
- className,
2270
- defaultValue,
2271
- value,
2272
- min = 0,
2273
- max = 100,
2274
- ...props
2275
- }) {
2322
+ function Slider2(props) {
2323
+ const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
2276
2324
  const _values = React12.useMemo(
2277
2325
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
2278
2326
  [value, defaultValue, min, max]
@@ -2289,20 +2337,20 @@ function Slider2({
2289
2337
  "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
2290
2338
  className
2291
2339
  ),
2292
- ...props,
2340
+ ...rest,
2293
2341
  children: [
2294
2342
  /* @__PURE__ */ jsx23(
2295
2343
  Track,
2296
2344
  {
2297
2345
  "data-slot": "slider-track",
2298
2346
  className: cn2(
2299
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2347
+ "relative grow overflow-hidden rounded-full bg-black/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2300
2348
  ),
2301
2349
  children: /* @__PURE__ */ jsx23(
2302
2350
  Range,
2303
2351
  {
2304
2352
  "data-slot": "slider-range",
2305
- className: cn2("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2353
+ className: cn2("absolute bg-black data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2306
2354
  }
2307
2355
  )
2308
2356
  }
@@ -2311,7 +2359,7 @@ function Slider2({
2311
2359
  Thumb2,
2312
2360
  {
2313
2361
  "data-slot": "slider-thumb",
2314
- className: "border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2362
+ className: "ring-ring/50 block size-5 shrink-0 rounded-full border-1 border-white bg-black shadow-sm shadow-[#00000033] transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2315
2363
  },
2316
2364
  index
2317
2365
  ))
@@ -2345,7 +2393,7 @@ var PointsSelector = (props) => {
2345
2393
  {
2346
2394
  disabled: isDisabled,
2347
2395
  onClick: onSelect,
2348
- className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-md border-1 border-transparent", {
2396
+ className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-sm border-1 border-transparent", {
2349
2397
  "border-primary": isSelected,
2350
2398
  "cursor-not-allowed opacity-50": isDisabled
2351
2399
  }),
@@ -2419,6 +2467,7 @@ var SplitBlock = (props) => {
2419
2467
  const [walletReady, setWalletReady] = useState9(false);
2420
2468
  const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
2421
2469
  const { env } = useSpreePayEnv();
2470
+ const prevPointsChainRef = useRef6(spreePayConfig?.pointsChain);
2422
2471
  const initWallet = useCallback4(
2423
2472
  async (pointsChain) => {
2424
2473
  if (!pointsChain) return;
@@ -2440,11 +2489,20 @@ var SplitBlock = (props) => {
2440
2489
  [onToggle, env.environment]
2441
2490
  );
2442
2491
  useEffect6(() => {
2443
- setAddress(null);
2444
- setWalletReady(false);
2445
- initWallet(spreePayConfig?.pointsChain);
2446
- }, [spreePayConfig?.pointsChain, initWallet]);
2447
- return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs13(PointsSelector, { isDisabled: !walletReady, onSelect: () => onSelect("air"), isSelected, children: [
2492
+ if (!env.useWeb3Points) return;
2493
+ const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
2494
+ prevPointsChainRef.current = spreePayConfig?.pointsChain;
2495
+ const doInit = async () => {
2496
+ if (pointsChainChanged) {
2497
+ setAddress(null);
2498
+ setWalletReady(false);
2499
+ }
2500
+ await initWallet(spreePayConfig?.pointsChain);
2501
+ };
2502
+ doInit();
2503
+ }, [spreePayConfig?.pointsChain, initWallet, env.useWeb3Points]);
2504
+ const isPointsSelectorDisabled = env.useWeb3Points ? !walletReady : false;
2505
+ return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs13(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
2448
2506
  /* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ jsxs13("p", { className: "text-left text-xs font-medium text-black sm:text-sm", children: [
2449
2507
  /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: "Available" }),
2450
2508
  " ",
@@ -2497,14 +2555,16 @@ var Points = () => {
2497
2555
  import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
2498
2556
  var CreditCardTab = () => {
2499
2557
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
2558
+ const { env } = useSpreePayEnv();
2500
2559
  const { appProps } = useStaticConfig();
2501
2560
  const { spreePayConfig } = useSpreePayConfig();
2502
2561
  const { register } = useSpreePayRegister();
2503
2562
  const { mutateCards } = useCards();
2504
2563
  const { mutateBalance } = useSlapiBalance();
2564
+ const isWeb3Enabled = Boolean(env.useWeb3Points);
2505
2565
  const { cardPayment } = useCardPayment();
2506
- const { splitPayment } = useSplitCardPayments();
2507
- const { pointsPayment } = usePointsPayment();
2566
+ const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
2567
+ const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
2508
2568
  const handlePay = useCallback5(
2509
2569
  async (data) => {
2510
2570
  try {
@@ -2525,7 +2585,9 @@ var CreditCardTab = () => {
2525
2585
  } catch (_) {
2526
2586
  return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
2527
2587
  } finally {
2528
- setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2588
+ if ("token" in (selectedPaymentMethod.method || {})) {
2589
+ setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2590
+ }
2529
2591
  mutateCards();
2530
2592
  mutateBalance();
2531
2593
  }
@@ -2546,13 +2608,13 @@ var CreditCardTab = () => {
2546
2608
  register(handlePay);
2547
2609
  }, [register, handlePay]);
2548
2610
  return /* @__PURE__ */ jsxs15("div", { children: [
2549
- /* @__PURE__ */ jsx27("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx27(CreditCard, {}) }),
2611
+ /* @__PURE__ */ jsx27("div", { className: "border-b border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx27(CreditCard, {}) }),
2550
2612
  /* @__PURE__ */ jsx27("div", { className: "flex flex-col gap-6 px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ jsx27(Points, {}) })
2551
2613
  ] });
2552
2614
  };
2553
2615
 
2554
2616
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
2555
- import { useEffect as useEffect10, useState as useState13 } from "react";
2617
+ import { useMemo as useMemo9 } from "react";
2556
2618
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2557
2619
  import NiceModal6 from "@ebay/nice-modal-react";
2558
2620
  import { RainbowKitProvider, getDefaultConfig, lightTheme } from "@rainbow-me/rainbowkit";
@@ -2594,10 +2656,13 @@ async function waitForTransactionReceipt(config, parameters) {
2594
2656
  const receipt = await action({ ...rest, timeout });
2595
2657
  if (receipt.status === "reverted") {
2596
2658
  const action_getTransaction = getAction(client, getTransaction, "getTransaction");
2597
- const txn = await action_getTransaction({ hash: receipt.transactionHash });
2659
+ const { from: account, ...txn } = await action_getTransaction({
2660
+ hash: receipt.transactionHash
2661
+ });
2598
2662
  const action_call = getAction(client, call, "call");
2599
2663
  const code = await action_call({
2600
2664
  ...txn,
2665
+ account,
2601
2666
  data: txn.input,
2602
2667
  gasPrice: txn.type !== "eip1559" ? txn.gasPrice : void 0,
2603
2668
  maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
@@ -2910,18 +2975,58 @@ function Input2({ className, type, ...props }) {
2910
2975
  }
2911
2976
 
2912
2977
  // ../../node_modules/@radix-ui/react-separator/dist/index.mjs
2978
+ import * as React14 from "react";
2979
+
2980
+ // ../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs
2913
2981
  import * as React13 from "react";
2982
+ import * as ReactDOM2 from "react-dom";
2983
+ import { createSlot as createSlot3 } from "@radix-ui/react-slot";
2914
2984
  import { jsx as jsx32 } from "react/jsx-runtime";
2985
+ var NODES2 = [
2986
+ "a",
2987
+ "button",
2988
+ "div",
2989
+ "form",
2990
+ "h2",
2991
+ "h3",
2992
+ "img",
2993
+ "input",
2994
+ "label",
2995
+ "li",
2996
+ "nav",
2997
+ "ol",
2998
+ "p",
2999
+ "select",
3000
+ "span",
3001
+ "svg",
3002
+ "ul"
3003
+ ];
3004
+ var Primitive2 = NODES2.reduce((primitive, node) => {
3005
+ const Slot2 = createSlot3(`Primitive.${node}`);
3006
+ const Node2 = React13.forwardRef((props, forwardedRef) => {
3007
+ const { asChild, ...primitiveProps } = props;
3008
+ const Comp = asChild ? Slot2 : node;
3009
+ if (typeof window !== "undefined") {
3010
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
3011
+ }
3012
+ return /* @__PURE__ */ jsx32(Comp, { ...primitiveProps, ref: forwardedRef });
3013
+ });
3014
+ Node2.displayName = `Primitive.${node}`;
3015
+ return { ...primitive, [node]: Node2 };
3016
+ }, {});
3017
+
3018
+ // ../../node_modules/@radix-ui/react-separator/dist/index.mjs
3019
+ import { jsx as jsx33 } from "react/jsx-runtime";
2915
3020
  var NAME = "Separator";
2916
3021
  var DEFAULT_ORIENTATION = "horizontal";
2917
3022
  var ORIENTATIONS = ["horizontal", "vertical"];
2918
- var Separator = React13.forwardRef((props, forwardedRef) => {
3023
+ var Separator = React14.forwardRef((props, forwardedRef) => {
2919
3024
  const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
2920
3025
  const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
2921
3026
  const ariaOrientation = orientation === "vertical" ? orientation : void 0;
2922
3027
  const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
2923
- return /* @__PURE__ */ jsx32(
2924
- Primitive.div,
3028
+ return /* @__PURE__ */ jsx33(
3029
+ Primitive2.div,
2925
3030
  {
2926
3031
  "data-orientation": orientation,
2927
3032
  ...semanticProps,
@@ -2937,14 +3042,14 @@ function isValidOrientation(orientation) {
2937
3042
  var Root6 = Separator;
2938
3043
 
2939
3044
  // ../ui/src/components/separator.tsx
2940
- import { jsx as jsx33 } from "react/jsx-runtime";
3045
+ import { jsx as jsx34 } from "react/jsx-runtime";
2941
3046
  function Separator2({
2942
3047
  className,
2943
3048
  orientation = "horizontal",
2944
3049
  decorative = true,
2945
3050
  ...props
2946
3051
  }) {
2947
- return /* @__PURE__ */ jsx33(
3052
+ return /* @__PURE__ */ jsx34(
2948
3053
  Root6,
2949
3054
  {
2950
3055
  "data-slot": "separator",
@@ -2960,17 +3065,17 @@ function Separator2({
2960
3065
  }
2961
3066
 
2962
3067
  // src/hooks/useBaseERC20Token.ts
2963
- import * as React14 from "react";
3068
+ import * as React15 from "react";
2964
3069
  import { erc20Abi as erc20Abi3, formatUnits, getAddress } from "viem";
2965
3070
  import { useAccount, usePublicClient } from "wagmi";
2966
3071
  function useBaseERC20Token() {
2967
3072
  const { address } = useAccount();
2968
3073
  const baseClient = usePublicClient({ chainId: BASE_CHAIN_ID });
2969
3074
  const defaultClient = usePublicClient();
2970
- const [rows, setRows] = React14.useState([]);
2971
- const [isLoading, setLoading] = React14.useState(false);
2972
- const [error, setError] = React14.useState(null);
2973
- React14.useEffect(() => {
3075
+ const [rows, setRows] = React15.useState([]);
3076
+ const [isLoading, setLoading] = React15.useState(false);
3077
+ const [error, setError] = React15.useState(null);
3078
+ React15.useEffect(() => {
2974
3079
  let cancelled = false;
2975
3080
  async function run() {
2976
3081
  const client = baseClient ?? defaultClient;
@@ -3051,7 +3156,7 @@ var useBaseTokens = () => {
3051
3156
  };
3052
3157
 
3053
3158
  // src/modals/CryptoSelectModal.tsx
3054
- import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
3159
+ import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
3055
3160
  var CryptoSelectModal = NiceModal4.create(() => {
3056
3161
  const modal = useModal2();
3057
3162
  const { isLoading, error, erc20Balances } = useBaseERC20Token();
@@ -3071,13 +3176,13 @@ var CryptoSelectModal = NiceModal4.create(() => {
3071
3176
  const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
3072
3177
  const userCoinSymbols = userCoins.map((c) => c.symbol);
3073
3178
  return /* @__PURE__ */ jsxs19(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: [
3074
- /* @__PURE__ */ jsx34(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
3179
+ /* @__PURE__ */ jsx35(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
3075
3180
  /* @__PURE__ */ jsxs19(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
3076
3181
  /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
3077
3182
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between gap-4", children: [
3078
- /* @__PURE__ */ jsx34("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx34("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ jsx34("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
3079
- /* @__PURE__ */ jsx34(DialogTitle, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
3080
- /* @__PURE__ */ jsx34("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx34("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ jsx34(
3183
+ /* @__PURE__ */ jsx35("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx35("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ jsx35("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
3184
+ /* @__PURE__ */ jsx35(DialogTitle, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
3185
+ /* @__PURE__ */ jsx35("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx35("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ jsx35(
3081
3186
  "path",
3082
3187
  {
3083
3188
  fill: "#000",
@@ -3085,14 +3190,14 @@ var CryptoSelectModal = NiceModal4.create(() => {
3085
3190
  }
3086
3191
  ) }) })
3087
3192
  ] }),
3088
- /* @__PURE__ */ jsx34(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
3193
+ /* @__PURE__ */ jsx35(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
3089
3194
  ] }),
3090
- /* @__PURE__ */ jsx34(Separator2, { className: "hidden md:block" }),
3195
+ /* @__PURE__ */ jsx35(Separator2, { className: "hidden md:block" }),
3091
3196
  /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
3092
- /* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
3093
- (error || nativeError) && /* @__PURE__ */ jsx34("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
3197
+ /* @__PURE__ */ jsx35("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
3198
+ (error || nativeError) && /* @__PURE__ */ jsx35("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
3094
3199
  /* @__PURE__ */ jsxs19("div", { className: "flex w-full flex-col gap-1", children: [
3095
- isLoadingNative && /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3200
+ isLoadingNative && /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3096
3201
  nativeBalance && /* @__PURE__ */ jsxs19(
3097
3202
  "button",
3098
3203
  {
@@ -3100,7 +3205,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
3100
3205
  onClick: () => handleSelect(nativeBalance),
3101
3206
  children: [
3102
3207
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
3103
- nativeBalance.logoURI && /* @__PURE__ */ jsx34(
3208
+ nativeBalance.logoURI && /* @__PURE__ */ jsx35(
3104
3209
  "img",
3105
3210
  {
3106
3211
  className: "h-8 w-8 shrink-0",
@@ -3108,17 +3213,17 @@ var CryptoSelectModal = NiceModal4.create(() => {
3108
3213
  alt: `${nativeBalance.symbol} logo`
3109
3214
  }
3110
3215
  ),
3111
- /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
3216
+ /* @__PURE__ */ jsx35("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
3112
3217
  ] }),
3113
- /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
3218
+ /* @__PURE__ */ jsx35("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
3114
3219
  ]
3115
3220
  },
3116
3221
  nativeBalance.symbol
3117
3222
  ),
3118
3223
  isLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
3119
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3120
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3121
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
3224
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3225
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3226
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
3122
3227
  ] }),
3123
3228
  erc20Balances.map((coin) => {
3124
3229
  const Icon = getSymbolLogo(coin.symbol);
@@ -3130,31 +3235,31 @@ var CryptoSelectModal = NiceModal4.create(() => {
3130
3235
  children: [
3131
3236
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
3132
3237
  Boolean(Icon) && Icon,
3133
- /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: coin.symbol })
3238
+ /* @__PURE__ */ jsx35("p", { className: "text-sm font-medium", children: coin.symbol })
3134
3239
  ] }),
3135
- /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: coin.formatted })
3240
+ /* @__PURE__ */ jsx35("p", { className: "text-sm font-medium", children: coin.formatted })
3136
3241
  ]
3137
3242
  },
3138
3243
  coin.symbol
3139
3244
  );
3140
3245
  })
3141
3246
  ] }),
3142
- /* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
3247
+ /* @__PURE__ */ jsx35("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
3143
3248
  /* @__PURE__ */ jsxs19("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
3144
3249
  tokensIsLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
3145
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3146
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3147
- /* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
3250
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3251
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
3252
+ /* @__PURE__ */ jsx35("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
3148
3253
  ] }),
3149
- filteredCoins.map((token) => /* @__PURE__ */ jsx34(
3254
+ filteredCoins.map((token) => /* @__PURE__ */ jsx35(
3150
3255
  "button",
3151
3256
  {
3152
3257
  disabled: !userCoinSymbols.includes(token.symbol),
3153
3258
  onClick: () => handleSelect(userCoins.find((c) => c.symbol === token.symbol)),
3154
3259
  className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-black hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
3155
3260
  children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
3156
- token.logoURI ? /* @__PURE__ */ jsx34("img", { className: "h-8 w-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ jsx34("div", { className: "h-8 w-8 shrink-0 rounded-full bg-gray-400" }),
3157
- /* @__PURE__ */ jsx34("p", { className: "text-sm font-medium", children: token.symbol })
3261
+ token.logoURI ? /* @__PURE__ */ jsx35("img", { className: "h-8 w-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ jsx35("div", { className: "h-8 w-8 shrink-0 rounded-full bg-gray-400" }),
3262
+ /* @__PURE__ */ jsx35("p", { className: "text-sm font-medium", children: token.symbol })
3158
3263
  ] })
3159
3264
  },
3160
3265
  token.symbol
@@ -3167,44 +3272,44 @@ var CryptoSelectModal = NiceModal4.create(() => {
3167
3272
  CryptoSelectModal.displayName = "CryptoSelectModal";
3168
3273
 
3169
3274
  // src/components/CryptoTab/Crypto/SelectCoinButton.tsx
3170
- import { jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
3275
+ import { jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
3171
3276
  var SelectCoinButton = () => {
3172
3277
  const openModal = () => {
3173
3278
  NiceModal5.show(CryptoSelectModal);
3174
3279
  };
3175
3280
  return /* @__PURE__ */ jsxs20("button", { onClick: openModal, type: "button", className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
3176
- /* @__PURE__ */ jsx35("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx35("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
3281
+ /* @__PURE__ */ jsx36("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx36("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
3177
3282
  /* @__PURE__ */ jsxs20("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
3178
- /* @__PURE__ */ jsx35("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx35("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
3179
- /* @__PURE__ */ jsx35("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ jsx35("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
3283
+ /* @__PURE__ */ jsx36("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx36("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
3284
+ /* @__PURE__ */ jsx36("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ jsx36("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
3180
3285
  ] })
3181
3286
  ] });
3182
3287
  };
3183
3288
 
3184
3289
  // src/components/CryptoTab/Crypto/SelectedCoin.tsx
3185
- import { jsx as jsx36, jsxs as jsxs21 } from "react/jsx-runtime";
3290
+ import { jsx as jsx37, jsxs as jsxs21 } from "react/jsx-runtime";
3186
3291
  var SelectedCoin = (props) => {
3187
3292
  const { coin, balance, logoURI } = props;
3188
3293
  const Icon = getSymbolLogo(coin);
3189
3294
  return /* @__PURE__ */ jsxs21("div", { className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
3190
- /* @__PURE__ */ jsx36("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx36("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ jsx36("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
3295
+ /* @__PURE__ */ jsx37("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ jsx37("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ jsx37("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
3191
3296
  /* @__PURE__ */ jsxs21("div", { className: "border-primary flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 px-3", children: [
3192
3297
  /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
3193
3298
  Icon,
3194
- !Icon && logoURI && /* @__PURE__ */ jsx36("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
3195
- /* @__PURE__ */ jsx36("p", { className: "font-semibold text-black", children: coin }),
3196
- /* @__PURE__ */ jsx36("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx36("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
3299
+ !Icon && logoURI && /* @__PURE__ */ jsx37("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
3300
+ /* @__PURE__ */ jsx37("p", { className: "font-semibold text-black", children: coin }),
3301
+ /* @__PURE__ */ jsx37("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx37("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
3197
3302
  ] }),
3198
3303
  /* @__PURE__ */ jsxs21("p", { className: "text-xs font-medium text-black/50", children: [
3199
3304
  "Wallet balance ",
3200
- /* @__PURE__ */ jsx36("span", { className: "text-black", children: balance })
3305
+ /* @__PURE__ */ jsx37("span", { className: "text-black", children: balance })
3201
3306
  ] })
3202
3307
  ] })
3203
3308
  ] });
3204
3309
  };
3205
3310
 
3206
3311
  // src/components/CryptoTab/Crypto/Crypto.tsx
3207
- import { jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
3312
+ import { jsx as jsx38, jsxs as jsxs22 } from "react/jsx-runtime";
3208
3313
  var Crypto = () => {
3209
3314
  const { address } = useAccount3();
3210
3315
  const { selectedPaymentMethod } = useSpreePaymentMethod();
@@ -3230,12 +3335,12 @@ var Crypto = () => {
3230
3335
  }, [register, handlePay]);
3231
3336
  return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col items-baseline gap-4", children: [
3232
3337
  /* @__PURE__ */ jsxs22("div", { className: "flex w-full items-center justify-between gap-4", children: [
3233
- /* @__PURE__ */ jsx37("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
3234
- /* @__PURE__ */ jsx37(ConnectButton, {})
3338
+ /* @__PURE__ */ jsx38("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
3339
+ /* @__PURE__ */ jsx38(ConnectButton, {})
3235
3340
  ] }),
3236
- !isWalletConnected && /* @__PURE__ */ jsx37(Logos, {}),
3341
+ !isWalletConnected && /* @__PURE__ */ jsx38(Logos, {}),
3237
3342
  isWalletConnected && /* @__PURE__ */ jsxs22("div", { className: "flex w-full flex-col gap-1", children: [
3238
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ jsx37(
3343
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ jsx38(
3239
3344
  SelectedCoin,
3240
3345
  {
3241
3346
  coin: selectedPaymentMethod.method.symbol,
@@ -3243,13 +3348,13 @@ var Crypto = () => {
3243
3348
  logoURI: selectedPaymentMethod.method.logoURI
3244
3349
  }
3245
3350
  ),
3246
- /* @__PURE__ */ jsx37(SelectCoinButton, {})
3351
+ /* @__PURE__ */ jsx38(SelectCoinButton, {})
3247
3352
  ] })
3248
3353
  ] });
3249
3354
  };
3250
3355
 
3251
3356
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
3252
- import { jsx as jsx38 } from "react/jsx-runtime";
3357
+ import { jsx as jsx39 } from "react/jsx-runtime";
3253
3358
  var queryClient = new QueryClient();
3254
3359
  var CHAINS = [base];
3255
3360
  var wagmiConfigCache = /* @__PURE__ */ new Map();
@@ -3264,36 +3369,34 @@ function getCachedWagmiConfig(projectId, appName) {
3264
3369
  }
3265
3370
  var CryptoWrapper = () => {
3266
3371
  const { spreePayConfig, configIsLoading } = useSpreePayConfig();
3267
- const [wagmiConfig, setWagmiConfig] = useState13(null);
3268
- useEffect10(() => {
3269
- if (!spreePayConfig) return;
3270
- const cfg2 = getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
3271
- setWagmiConfig((prev) => prev ? prev : cfg2);
3372
+ const wagmiConfig = useMemo9(() => {
3373
+ if (!spreePayConfig) return null;
3374
+ return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
3272
3375
  }, [spreePayConfig]);
3273
3376
  if (configIsLoading || !wagmiConfig) return null;
3274
- return /* @__PURE__ */ jsx38(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx38(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx38(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx38(NiceModal6.Provider, { children: /* @__PURE__ */ jsx38(Crypto, {}) }) }) }) });
3377
+ return /* @__PURE__ */ jsx39(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx39(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx39(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx39(NiceModal6.Provider, { children: /* @__PURE__ */ jsx39(Crypto, {}) }) }) }) });
3275
3378
  };
3276
3379
 
3277
3380
  // src/components/CryptoTab/CryptoTab.tsx
3278
- import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
3381
+ import { jsx as jsx40, jsxs as jsxs23 } from "react/jsx-runtime";
3279
3382
  var CryptoTab = () => {
3280
3383
  const { spreePayConfig } = useSpreePayConfig();
3281
3384
  return /* @__PURE__ */ jsxs23("div", { children: [
3282
- /* @__PURE__ */ jsx39("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx39(CryptoWrapper, {}) }),
3283
- /* @__PURE__ */ jsx39("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx39(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
3385
+ /* @__PURE__ */ jsx40("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx40(CryptoWrapper, {}) }),
3386
+ /* @__PURE__ */ jsx40("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ jsx40(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
3284
3387
  ] });
3285
3388
  };
3286
3389
 
3287
3390
  // src/components/TabButtons.tsx
3288
- import { jsx as jsx40, jsxs as jsxs24 } from "react/jsx-runtime";
3289
- var TabButton = ({ isDisabled = true, isActive, children, onClick }) => {
3290
- return /* @__PURE__ */ jsx40(
3391
+ import { Fragment as Fragment7, jsx as jsx41, jsxs as jsxs24 } from "react/jsx-runtime";
3392
+ var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
3393
+ return /* @__PURE__ */ jsx41(
3291
3394
  "button",
3292
3395
  {
3293
3396
  disabled: isDisabled,
3294
3397
  onClick,
3295
3398
  className: cn(
3296
- "flex w-[132px] flex-col items-baseline rounded-sm border-1 border-black/50 px-2.5 py-1.5 text-sm text-black",
3399
+ "flex w-[132px] flex-col items-baseline rounded-sm border border-black/50 px-2.5 py-1.5 text-sm text-black",
3297
3400
  { "opacity-50": !isActive || isDisabled },
3298
3401
  { "cursor-not-allowed": isDisabled },
3299
3402
  { "bg-primary/7 border-primary text-primary": isActive }
@@ -3304,98 +3407,88 @@ var TabButton = ({ isDisabled = true, isActive, children, onClick }) => {
3304
3407
  };
3305
3408
  var TabButtons = (props) => {
3306
3409
  const { value, onChange } = props;
3307
- const { spreePayConfig } = useSpreePayConfig();
3410
+ const { spreePayConfig, configIsLoading } = useSpreePayConfig();
3308
3411
  const handleChange = (type) => () => {
3309
3412
  if (value !== type) {
3310
3413
  onChange({ type, method: null });
3311
3414
  }
3312
3415
  };
3313
3416
  return /* @__PURE__ */ jsxs24("div", { className: "flex gap-2", children: [
3314
- /* @__PURE__ */ jsxs24(
3315
- TabButton,
3316
- {
3317
- isDisabled: !spreePayConfig?.creditCard.enabled,
3318
- onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */),
3319
- isActive: value === "CREDIT_CARD" /* CREDIT_CARD */,
3320
- children: [
3321
- /* @__PURE__ */ jsx40("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ jsx40(
3322
- "path",
3323
- {
3324
- fill: "currentColor",
3325
- d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
3326
- }
3327
- ) }),
3328
- /* @__PURE__ */ jsx40("p", { className: "text-sm font-medium", children: "Card" })
3329
- ]
3330
- }
3331
- ),
3332
- /* @__PURE__ */ jsxs24(
3333
- TabButton,
3334
- {
3335
- isDisabled: !spreePayConfig?.crypto.enabled,
3336
- onClick: handleChange("CRYPTO" /* CRYPTO */),
3337
- isActive: value === "CRYPTO" /* CRYPTO */,
3338
- children: [
3339
- /* @__PURE__ */ jsxs24("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
3340
- /* @__PURE__ */ jsx40(
3341
- "path",
3342
- {
3343
- fill: "currentColor",
3344
- d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
3345
- }
3346
- ),
3347
- /* @__PURE__ */ jsx40(
3348
- "path",
3349
- {
3350
- fill: "currentColor",
3351
- d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
3352
- }
3353
- ),
3354
- /* @__PURE__ */ jsx40("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
3355
- ] }),
3356
- /* @__PURE__ */ jsx40("p", { className: "text-sm font-medium", children: "Crypto" })
3357
- ]
3358
- }
3359
- )
3417
+ configIsLoading && /* @__PURE__ */ jsxs24(Fragment7, { children: [
3418
+ /* @__PURE__ */ jsx41("div", { className: "bg-primary/7 h-[58px] w-[132px] animate-pulse rounded-sm" }),
3419
+ /* @__PURE__ */ jsx41("div", { className: "bg-primary/7 h-[58px] w-[132px] animate-pulse rounded-sm" })
3420
+ ] }),
3421
+ spreePayConfig?.creditCard.enabled && /* @__PURE__ */ jsxs24(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
3422
+ /* @__PURE__ */ jsx41("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ jsx41(
3423
+ "path",
3424
+ {
3425
+ fill: "currentColor",
3426
+ d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
3427
+ }
3428
+ ) }),
3429
+ /* @__PURE__ */ jsx41("p", { className: "text-sm font-medium", children: "Card" })
3430
+ ] }),
3431
+ spreePayConfig?.crypto.enabled && /* @__PURE__ */ jsxs24(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
3432
+ /* @__PURE__ */ jsxs24("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
3433
+ /* @__PURE__ */ jsx41(
3434
+ "path",
3435
+ {
3436
+ fill: "currentColor",
3437
+ d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
3438
+ }
3439
+ ),
3440
+ /* @__PURE__ */ jsx41(
3441
+ "path",
3442
+ {
3443
+ fill: "currentColor",
3444
+ d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
3445
+ }
3446
+ ),
3447
+ /* @__PURE__ */ jsx41("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
3448
+ ] }),
3449
+ /* @__PURE__ */ jsx41("p", { className: "text-sm font-medium", children: "Crypto" })
3450
+ ] })
3360
3451
  ] });
3361
3452
  };
3362
3453
 
3363
3454
  // src/components/Tabs.tsx
3364
- import { jsx as jsx41, jsxs as jsxs25 } from "react/jsx-runtime";
3455
+ import { jsx as jsx42, jsxs as jsxs25 } from "react/jsx-runtime";
3365
3456
  var Tabs = () => {
3366
3457
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
3367
3458
  return /* @__PURE__ */ jsxs25("div", { className: "mb-4 rounded-3xl border border-black/25 bg-white", children: [
3368
3459
  /* @__PURE__ */ jsxs25("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: [
3369
- /* @__PURE__ */ jsx41("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
3370
- /* @__PURE__ */ jsx41(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
3460
+ /* @__PURE__ */ jsx42("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
3461
+ /* @__PURE__ */ jsx42(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
3371
3462
  ] }),
3372
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx41(CreditCardTab, {}),
3373
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx41(CryptoTab, {})
3463
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx42(CreditCardTab, {}),
3464
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx42(CryptoTab, {})
3374
3465
  ] });
3375
3466
  };
3376
3467
 
3377
3468
  // src/SpreePayContent.tsx
3378
- import { jsx as jsx42, jsxs as jsxs26 } from "react/jsx-runtime";
3469
+ import { jsx as jsx43, jsxs as jsxs26 } from "react/jsx-runtime";
3379
3470
  var SpreePayContent = ({ isLoggedIn }) => {
3380
3471
  return /* @__PURE__ */ jsxs26("div", { className: "w-full", children: [
3381
- /* @__PURE__ */ jsx42(Tabs, {}),
3382
- /* @__PURE__ */ jsx42(CheckoutButton, { isLoggedIn }),
3383
- /* @__PURE__ */ jsx42(SpreeLegal, {})
3472
+ /* @__PURE__ */ jsx43(Tabs, {}),
3473
+ /* @__PURE__ */ jsx43(CheckoutButton, { isLoggedIn }),
3474
+ /* @__PURE__ */ jsx43(SpreeLegal, {})
3384
3475
  ] });
3385
3476
  };
3386
3477
 
3387
3478
  // src/hooks/useKeycloakSSO.ts
3388
- import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef6, useState as useState14 } from "react";
3479
+ import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef7, useState as useState13 } from "react";
3389
3480
  import Keycloak from "keycloak-js";
3390
3481
  var refreshAheadSeconds = 60;
3391
3482
  function useKeycloakSSO(config) {
3392
3483
  const { url, realm, clientId, ssoPageURI, enabled } = config;
3393
- const initRef = useRef6(false);
3394
- const kcRef = useRef6(null);
3395
- const refreshTimerRef = useRef6(null);
3396
- const [error, setError] = useState14(null);
3397
- const [isChecking, setIsChecking] = useState14(enabled);
3398
- const [accessToken, setAccessToken] = useState14(null);
3484
+ const initRef = useRef7(false);
3485
+ const kcRef = useRef7(null);
3486
+ const refreshTimerRef = useRef7(null);
3487
+ const scheduleRefreshRef = useRef7(() => {
3488
+ });
3489
+ const [error, setError] = useState13(null);
3490
+ const [isChecking, setIsChecking] = useState13(enabled);
3491
+ const [accessToken, setAccessToken] = useState13(null);
3399
3492
  const scheduleRefresh = useCallback7(() => {
3400
3493
  const kc = kcRef.current;
3401
3494
  if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
@@ -3410,17 +3503,19 @@ function useKeycloakSSO(config) {
3410
3503
  kc.updateToken(refreshAheadSeconds).then((refreshed) => {
3411
3504
  if (refreshed) {
3412
3505
  setAccessToken(kc.token ?? null);
3413
- scheduleRefresh();
3506
+ scheduleRefreshRef.current();
3414
3507
  }
3415
3508
  }).catch((_) => {
3416
3509
  kc.login().catch(console.error);
3417
3510
  });
3418
3511
  }, delayMs);
3419
3512
  }, []);
3420
- useEffect11(() => {
3513
+ useEffect10(() => {
3514
+ scheduleRefreshRef.current = scheduleRefresh;
3515
+ }, [scheduleRefresh]);
3516
+ useEffect10(() => {
3421
3517
  if (initRef.current || !enabled) return;
3422
3518
  initRef.current = true;
3423
- setIsChecking(true);
3424
3519
  const kc = new Keycloak({ url, realm, clientId });
3425
3520
  kcRef.current = kc;
3426
3521
  kc.onTokenExpired = () => {
@@ -3452,21 +3547,20 @@ function useKeycloakSSO(config) {
3452
3547
  }
3453
3548
 
3454
3549
  // src/SpreePay.tsx
3455
- import { jsx as jsx43, jsxs as jsxs27 } from "react/jsx-runtime";
3550
+ import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
3456
3551
  var SpreePayInner = () => {
3457
- const rootRef = useRef7(null);
3458
- const [portalEl, setPortalEl] = useState15(null);
3459
- useLayoutEffect3(() => {
3460
- if (!rootRef.current) return;
3461
- const el = rootRef.current.querySelector(":scope > .sl-spreepay__portal");
3552
+ const [portalEl, setPortalEl] = useState14(null);
3553
+ const rootRef = useCallback8((node) => {
3554
+ if (!node) return;
3555
+ const el = node.querySelector(":scope > .sl-spreepay__portal");
3462
3556
  setPortalEl(el ?? null);
3463
3557
  }, []);
3464
- useEffect12(() => {
3558
+ useEffect11(() => {
3465
3559
  console.log(`[spree-pay] v${version}`);
3466
3560
  }, []);
3467
3561
  const { env } = useSpreePayEnv();
3468
3562
  const { staticConfig, appProps } = useStaticConfig();
3469
- const tenantId = env?.tenantId || "bookit";
3563
+ const tenantId = env?.tenantId;
3470
3564
  const { isChecking, accessToken } = useKeycloakSSO({
3471
3565
  realm: tenantId,
3472
3566
  url: staticConfig.keycloakUrl,
@@ -3475,7 +3569,7 @@ var SpreePayInner = () => {
3475
3569
  enabled: !env?.accessToken
3476
3570
  });
3477
3571
  const _accessToken = env.accessToken ?? accessToken;
3478
- const slapiFetcher = useMemo9(() => {
3572
+ const slapiFetcher = useMemo10(() => {
3479
3573
  if (_accessToken) {
3480
3574
  return registerApi({
3481
3575
  accessToken: _accessToken,
@@ -3487,12 +3581,12 @@ var SpreePayInner = () => {
3487
3581
  const getContent = () => {
3488
3582
  if (isChecking) {
3489
3583
  return /* @__PURE__ */ jsxs27("div", { className: "flex w-full flex-col", children: [
3490
- /* @__PURE__ */ jsx43("div", { className: "bg-primary/8 mb-4 h-[315px] animate-pulse rounded-3xl" }),
3491
- /* @__PURE__ */ jsx43("div", { className: "bg-primary/8 h-[135px] animate-pulse rounded-3xl" }),
3492
- /* @__PURE__ */ jsx43(SpreeLegal, {})
3584
+ /* @__PURE__ */ jsx44("div", { className: "bg-primary/8 mb-4 h-[315px] animate-pulse rounded-3xl" }),
3585
+ /* @__PURE__ */ jsx44("div", { className: "bg-primary/8 h-[135px] animate-pulse rounded-3xl" }),
3586
+ /* @__PURE__ */ jsx44(SpreeLegal, {})
3493
3587
  ] });
3494
3588
  }
3495
- return /* @__PURE__ */ jsx43(
3589
+ return /* @__PURE__ */ jsx44(
3496
3590
  SWRConfig,
3497
3591
  {
3498
3592
  value: {
@@ -3501,23 +3595,23 @@ var SpreePayInner = () => {
3501
3595
  revalidateOnFocus: false,
3502
3596
  revalidateIfStale: false
3503
3597
  },
3504
- children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
3598
+ children: /* @__PURE__ */ jsx44(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx44(NiceModal7.Provider, { children: /* @__PURE__ */ jsx44(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
3505
3599
  }
3506
3600
  );
3507
3601
  };
3508
3602
  return /* @__PURE__ */ jsxs27("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
3509
- /* @__PURE__ */ jsx43("div", { className: "sl-spreepay__portal" }),
3603
+ /* @__PURE__ */ jsx44("div", { className: "sl-spreepay__portal" }),
3510
3604
  getContent()
3511
3605
  ] });
3512
3606
  };
3513
3607
  var SpreePay = (props) => {
3514
- return /* @__PURE__ */ jsx43(StaticConfigProvider, { props, children: /* @__PURE__ */ jsx43(SpreePayInner, {}) });
3608
+ return /* @__PURE__ */ jsx44(StaticConfigProvider, { props, children: /* @__PURE__ */ jsx44(SpreePayInner, {}) });
3515
3609
  };
3516
3610
 
3517
3611
  // src/hooks/useCapture3DS.ts
3518
- import { useEffect as useEffect13 } from "react";
3612
+ import { useEffect as useEffect12 } from "react";
3519
3613
  var useCapture3DS = (searchParams) => {
3520
- useEffect13(() => {
3614
+ useEffect12(() => {
3521
3615
  if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
3522
3616
  window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
3523
3617
  }