@superlogic/spree-pay 0.4.14 → 0.5.1

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.cjs CHANGED
@@ -30,26 +30,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // src/types/errors.ts
34
- var PaymentError;
35
- var init_errors = __esm({
36
- "src/types/errors.ts"() {
37
- "use strict";
38
- PaymentError = class extends Error {
39
- status;
40
- details;
41
- constructor(message, status, details) {
42
- super(message);
43
- this.name = "PaymentError";
44
- this.status = status;
45
- this.details = details;
46
- }
47
- };
48
- }
49
- });
50
-
51
33
  // src/types/payments.ts
52
- var isNewCard, PaymentType;
34
+ var isNewCard, PaymentType, PaymentStatus;
53
35
  var init_payments = __esm({
54
36
  "src/types/payments.ts"() {
55
37
  "use strict";
@@ -62,6 +44,88 @@ var init_payments = __esm({
62
44
  PaymentType2["POINTS"] = "POINTS";
63
45
  return PaymentType2;
64
46
  })(PaymentType || {});
47
+ PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
48
+ PaymentStatus2["NOT_INITIALIZED"] = "NOT_INITIALIZED";
49
+ PaymentStatus2["PENDING"] = "PENDING";
50
+ PaymentStatus2["AUTHORIZED"] = "AUTHORIZED";
51
+ PaymentStatus2["FAILED"] = "FAILED";
52
+ PaymentStatus2["CAPTURED"] = "CAPTURED";
53
+ PaymentStatus2["VOIDED"] = "VOIDED";
54
+ PaymentStatus2["CAPTURE_FAILED"] = "CAPTURE_FAILED";
55
+ return PaymentStatus2;
56
+ })(PaymentStatus || {});
57
+ }
58
+ });
59
+
60
+ // src/types/errors.ts
61
+ var SpreePayHttpError, PaymentErrorCode, PaymentError, isPaymentError, isDeclineStatus, isSuccessStatus, isProcessorRejection, backendCodeFromBody, toPaymentError, settlePaymentResult;
62
+ var init_errors = __esm({
63
+ "src/types/errors.ts"() {
64
+ "use strict";
65
+ SpreePayHttpError = class extends Error {
66
+ constructor(status, body, url) {
67
+ const snippet = body.length > 200 ? `${body.slice(0, 200)}\u2026` : body;
68
+ super(snippet || `Request failed: ${status}`);
69
+ this.status = status;
70
+ this.body = body;
71
+ this.url = url;
72
+ this.name = "SpreePayHttpError";
73
+ }
74
+ status;
75
+ body;
76
+ url;
77
+ };
78
+ PaymentErrorCode = /* @__PURE__ */ ((PaymentErrorCode2) => {
79
+ PaymentErrorCode2["CARD_ERROR"] = "CARD_ERROR";
80
+ PaymentErrorCode2["PAYMENT_ERROR"] = "PAYMENT_ERROR";
81
+ return PaymentErrorCode2;
82
+ })(PaymentErrorCode || {});
83
+ PaymentError = class extends Error {
84
+ status;
85
+ code;
86
+ /**
87
+ * Optional stable code from the backend (e.g. `INSUFFICIENT_FUNDS`) for branching
88
+ * on specific cases without changing the `code` enum. Safe to expose (an
89
+ * identifier, not free-text); absent until the backend supplies one.
90
+ */
91
+ backendCode;
92
+ constructor(message, status, options) {
93
+ super(message, { cause: options?.cause });
94
+ this.name = "PaymentError";
95
+ this.status = status;
96
+ this.code = options?.code ?? "PAYMENT_ERROR" /* PAYMENT_ERROR */;
97
+ this.backendCode = options?.backendCode;
98
+ }
99
+ };
100
+ isPaymentError = (e) => e instanceof PaymentError;
101
+ isDeclineStatus = (status) => status === "FAILED" /* FAILED */ || status === "CAPTURE_FAILED" /* CAPTURE_FAILED */;
102
+ isSuccessStatus = (status) => status === "AUTHORIZED" /* AUTHORIZED */ || status === "CAPTURED" /* CAPTURED */;
103
+ isProcessorRejection = (e) => e instanceof SpreePayHttpError && e.status >= 400 && e.status < 500 && e.status !== 401 && e.status !== 403 && e.status !== 404;
104
+ backendCodeFromBody = (e) => {
105
+ try {
106
+ const parsed = JSON.parse(e.body);
107
+ const code = parsed?.code ?? parsed?.errorCode;
108
+ if (typeof code === "string" && code.trim()) return code;
109
+ } catch {
110
+ }
111
+ return void 0;
112
+ };
113
+ toPaymentError = (e, fallbackMessage = "Payment failed", declineCode = "PAYMENT_ERROR" /* PAYMENT_ERROR */) => {
114
+ if (e instanceof PaymentError) return e;
115
+ return new PaymentError(fallbackMessage, "FAILED" /* FAILED */, {
116
+ code: isProcessorRejection(e) ? declineCode : "PAYMENT_ERROR" /* PAYMENT_ERROR */,
117
+ backendCode: e instanceof SpreePayHttpError ? backendCodeFromBody(e) : void 0,
118
+ cause: e
119
+ });
120
+ };
121
+ settlePaymentResult = (res, fallbackMessage, failureCode = "PAYMENT_ERROR" /* PAYMENT_ERROR */) => {
122
+ if (isSuccessStatus(res.status)) {
123
+ return res;
124
+ }
125
+ throw new PaymentError(fallbackMessage, res.status, {
126
+ code: isDeclineStatus(res.status) ? failureCode : "PAYMENT_ERROR" /* PAYMENT_ERROR */
127
+ });
128
+ };
65
129
  }
66
130
  });
67
131
 
@@ -69,7 +133,7 @@ var init_payments = __esm({
69
133
  var version;
70
134
  var init_package = __esm({
71
135
  "package.json"() {
72
- version = "0.4.14";
136
+ version = "0.5.1";
73
137
  }
74
138
  });
75
139
 
@@ -228,12 +292,11 @@ var init_SpreePayActionsContext = __esm({
228
292
  hash: data.hash,
229
293
  paymentType: selectedPaymentMethod.type
230
294
  });
231
- throw new PaymentError("Payment already in progress", "FAILED" /* FAILED */);
295
+ throw new Error("Payment already in progress");
232
296
  }
233
297
  processLogger.info("Payment process started", {
234
298
  hash: data.hash,
235
299
  capture: data.capture,
236
- hasMetadata: Boolean(data.metadata),
237
300
  paymentType: selectedPaymentMethod.type
238
301
  });
239
302
  inFlightRef.current = true;
@@ -253,8 +316,7 @@ var init_SpreePayActionsContext = __esm({
253
316
  paymentType: selectedPaymentMethod.type,
254
317
  errorMessage: e instanceof Error ? e.message : String(e)
255
318
  });
256
- if (e instanceof Error) throw e;
257
- throw new PaymentError("Payment failed", "FAILED" /* FAILED */, e);
319
+ throw toPaymentError(e);
258
320
  } finally {
259
321
  inFlightRef.current = false;
260
322
  setInternalProcessing(false);
@@ -614,10 +676,11 @@ var init_Iframe3ds = __esm({
614
676
  });
615
677
 
616
678
  // src/fetcher/client.ts
617
- var cfg, buildUrl, request, slapiApi, registerApi;
679
+ var cfg, buildUrl, parseResponse, publicGet, request, slapiApi, registerApi;
618
680
  var init_client = __esm({
619
681
  "src/fetcher/client.ts"() {
620
682
  "use strict";
683
+ init_errors();
621
684
  cfg = { baseUrl: void 0, accessToken: void 0, tenantId: void 0 };
622
685
  buildUrl = (key) => {
623
686
  if (!cfg.baseUrl) throw new Error("Missing SLAPI baseUrl. Call registerApi(...) first.");
@@ -631,6 +694,27 @@ var init_client = __esm({
631
694
  const qs = usp.toString();
632
695
  return cfg.baseUrl + url + (qs ? `?${qs}` : "");
633
696
  };
697
+ parseResponse = async (res) => {
698
+ if (!res.ok) {
699
+ const text = await res.text().catch(() => "");
700
+ throw new SpreePayHttpError(res.status, text, res.url);
701
+ }
702
+ const contentType = res.headers.get("content-type") || "";
703
+ if (!contentType.includes("application/json")) {
704
+ return await res.text();
705
+ }
706
+ return await res.json();
707
+ };
708
+ publicGet = async (baseUrl, tenantId, path) => {
709
+ const res = await fetch(`${baseUrl}${path}`, {
710
+ headers: {
711
+ Accept: "application/json",
712
+ ["X-Tenant-ID"]: tenantId
713
+ },
714
+ cache: "no-store"
715
+ });
716
+ return parseResponse(res);
717
+ };
634
718
  request = async (method, url, body) => {
635
719
  if (!cfg.accessToken) throw new Error("Missing SLAPI accessToken. Call registerApi(...) first.");
636
720
  if (!cfg.tenantId) throw new Error("Missing SLAPI tenantId. Call registerApi(...) first.");
@@ -656,15 +740,7 @@ var init_client = __esm({
656
740
  body: payload,
657
741
  cache: "no-store"
658
742
  });
659
- if (!res.ok) {
660
- const text = await res.text().catch(() => "");
661
- throw new Error(text || `Request failed: ${res.status}`);
662
- }
663
- const contentType = res.headers.get("content-type") || "";
664
- if (!contentType.includes("application/json")) {
665
- return await res.text();
666
- }
667
- return await res.json();
743
+ return parseResponse(res);
668
744
  };
669
745
  slapiApi = {
670
746
  get: async () => {
@@ -887,10 +963,17 @@ var init_useSpreePayConfig = __esm({
887
963
  "use strict";
888
964
  import_swr = __toESM(require("swr"), 1);
889
965
  init_SpreePayActionsContext();
966
+ init_StaticConfigContext();
967
+ init_client();
890
968
  URL = "/v1/tenants/configs/spree-pay";
891
969
  useSpreePayConfig = () => {
892
- const { origin } = useSpreePayEnv();
893
- const { data, isLoading } = (0, import_swr.default)(origin ? `${URL}?origin=${origin}` : URL);
970
+ const { origin, tenantId } = useSpreePayEnv();
971
+ const { staticConfig } = useStaticConfig();
972
+ const key = origin ? `${URL}?origin=${origin}` : URL;
973
+ const { data, isLoading } = (0, import_swr.default)(
974
+ key,
975
+ (path) => publicGet(staticConfig.slapiUrl, tenantId, path)
976
+ );
894
977
  return { spreePayConfig: data ?? null, configIsLoading: isLoading };
895
978
  };
896
979
  }
@@ -926,13 +1009,27 @@ var init_useSlapiBalance = __esm({
926
1009
  }
927
1010
  });
928
1011
 
1012
+ // src/context/LoginStatusContext.tsx
1013
+ var import_react6, import_jsx_runtime5, LoginStatusContext, LoginStatusProvider, useIsLoggedIn;
1014
+ var init_LoginStatusContext = __esm({
1015
+ "src/context/LoginStatusContext.tsx"() {
1016
+ "use strict";
1017
+ "use client";
1018
+ import_react6 = require("react");
1019
+ import_jsx_runtime5 = require("react/jsx-runtime");
1020
+ LoginStatusContext = (0, import_react6.createContext)(false);
1021
+ LoginStatusProvider = ({ isLoggedIn, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoginStatusContext.Provider, { value: isLoggedIn, children });
1022
+ useIsLoggedIn = () => (0, import_react6.useContext)(LoginStatusContext);
1023
+ }
1024
+ });
1025
+
929
1026
  // src/ui/spinner.tsx
930
- var import_jsx_runtime5, Spinner;
1027
+ var import_jsx_runtime6, Spinner;
931
1028
  var init_spinner = __esm({
932
1029
  "src/ui/spinner.tsx"() {
933
1030
  "use strict";
934
1031
  init_utils();
935
- import_jsx_runtime5 = require("react/jsx-runtime");
1032
+ import_jsx_runtime6 = require("react/jsx-runtime");
936
1033
  Spinner = (props) => {
937
1034
  const { size = "md", className } = props;
938
1035
  const sizeClasses = {
@@ -942,7 +1039,7 @@ var init_spinner = __esm({
942
1039
  lg: "size-12",
943
1040
  xl: "size-16"
944
1041
  };
945
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1042
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
946
1043
  "svg",
947
1044
  {
948
1045
  className: cn(`${sizeClasses[size]} animate-spin text-(--tertiary)`, className),
@@ -952,7 +1049,7 @@ var init_spinner = __esm({
952
1049
  width: "24",
953
1050
  height: "24",
954
1051
  children: [
955
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1052
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
956
1053
  "path",
957
1054
  {
958
1055
  d: "M32 3C35.8083 3 39.5794 3.75011 43.0978 5.20749C46.6163 6.66488 49.8132 8.80101 52.5061 11.4939C55.199 14.1868 57.3351 17.3837 58.7925 20.9022C60.2499 24.4206 61 28.1917 61 32C61 35.8083 60.2499 39.5794 58.7925 43.0978C57.3351 46.6163 55.199 49.8132 52.5061 52.5061C49.8132 55.199 46.6163 57.3351 43.0978 58.7925C39.5794 60.2499 35.8083 61 32 61C28.1917 61 24.4206 60.2499 20.9022 58.7925C17.3837 57.3351 14.1868 55.199 11.4939 52.5061C8.801 49.8132 6.66487 46.6163 5.20749 43.0978C3.7501 39.5794 3 35.8083 3 32C3 28.1917 3.75011 24.4206 5.2075 20.9022C6.66489 17.3837 8.80101 14.1868 11.4939 11.4939C14.1868 8.80099 17.3838 6.66487 20.9022 5.20749C24.4206 3.7501 28.1917 3 32 3L32 3Z",
@@ -962,7 +1059,7 @@ var init_spinner = __esm({
962
1059
  strokeLinejoin: "round"
963
1060
  }
964
1061
  ),
965
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1062
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
966
1063
  "path",
967
1064
  {
968
1065
  d: "M32 3C36.5778 3 41.0906 4.08374 45.1692 6.16256C49.2477 8.24138 52.7762 11.2562 55.466 14.9605C58.1558 18.6647 59.9304 22.9531 60.6448 27.4748C61.3591 31.9965 60.9928 36.6232 59.5759 40.9762",
@@ -1016,7 +1113,7 @@ var init_format = __esm({
1016
1113
 
1017
1114
  // src/ui/label.tsx
1018
1115
  function Label({ className, ...props }) {
1019
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1116
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1020
1117
  LabelPrimitive.Root,
1021
1118
  {
1022
1119
  "data-slot": "label",
@@ -1028,20 +1125,20 @@ function Label({ className, ...props }) {
1028
1125
  }
1029
1126
  );
1030
1127
  }
1031
- var LabelPrimitive, import_jsx_runtime6;
1128
+ var LabelPrimitive, import_jsx_runtime7;
1032
1129
  var init_label = __esm({
1033
1130
  "src/ui/label.tsx"() {
1034
1131
  "use strict";
1035
1132
  "use client";
1036
1133
  LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
1037
1134
  init_utils();
1038
- import_jsx_runtime6 = require("react/jsx-runtime");
1135
+ import_jsx_runtime7 = require("react/jsx-runtime");
1039
1136
  }
1040
1137
  });
1041
1138
 
1042
1139
  // src/ui/switch.tsx
1043
1140
  function Switch({ className, ...props }) {
1044
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1141
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1045
1142
  SwitchPrimitive.Root,
1046
1143
  {
1047
1144
  "data-slot": "switch",
@@ -1050,7 +1147,7 @@ function Switch({ className, ...props }) {
1050
1147
  className
1051
1148
  ),
1052
1149
  ...props,
1053
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1150
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1054
1151
  SwitchPrimitive.Thumb,
1055
1152
  {
1056
1153
  "data-slot": "switch-thumb",
@@ -1060,29 +1157,29 @@ function Switch({ className, ...props }) {
1060
1157
  }
1061
1158
  );
1062
1159
  }
1063
- var SwitchPrimitive, import_jsx_runtime7;
1160
+ var SwitchPrimitive, import_jsx_runtime8;
1064
1161
  var init_switch = __esm({
1065
1162
  "src/ui/switch.tsx"() {
1066
1163
  "use strict";
1067
1164
  "use client";
1068
1165
  SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
1069
1166
  init_utils();
1070
- import_jsx_runtime7 = require("react/jsx-runtime");
1167
+ import_jsx_runtime8 = require("react/jsx-runtime");
1071
1168
  }
1072
1169
  });
1073
1170
 
1074
1171
  // src/components/common/InfoBanner.tsx
1075
- var import_xss, import_jsx_runtime8, InfoBanner;
1172
+ var import_xss, import_jsx_runtime9, InfoBanner;
1076
1173
  var init_InfoBanner = __esm({
1077
1174
  "src/components/common/InfoBanner.tsx"() {
1078
1175
  "use strict";
1079
1176
  import_xss = __toESM(require("xss"), 1);
1080
1177
  init_utils();
1081
- import_jsx_runtime8 = require("react/jsx-runtime");
1178
+ import_jsx_runtime9 = require("react/jsx-runtime");
1082
1179
  InfoBanner = (props) => {
1083
1180
  const { type = "info", message } = props;
1084
1181
  if (!message) return null;
1085
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1182
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1086
1183
  "div",
1087
1184
  {
1088
1185
  className: cn("flex w-full gap-1.5 rounded-md p-2", {
@@ -1090,14 +1187,14 @@ var init_InfoBanner = __esm({
1090
1187
  "bg-(--s-warning)/10": type === "warning"
1091
1188
  }),
1092
1189
  children: [
1093
- type === "info" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1190
+ type === "info" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1094
1191
  "svg",
1095
1192
  {
1096
1193
  xmlns: "http://www.w3.org/2000/svg",
1097
1194
  fill: "none",
1098
1195
  viewBox: "0 0 20 20",
1099
1196
  className: "size-5 shrink-0 text-(--positive)",
1100
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1197
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1101
1198
  "path",
1102
1199
  {
1103
1200
  fill: "currentColor",
@@ -1106,14 +1203,14 @@ var init_InfoBanner = __esm({
1106
1203
  )
1107
1204
  }
1108
1205
  ),
1109
- type === "warning" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1206
+ type === "warning" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1110
1207
  "svg",
1111
1208
  {
1112
1209
  xmlns: "http://www.w3.org/2000/svg",
1113
1210
  fill: "none",
1114
1211
  viewBox: "0 0 20 20",
1115
1212
  className: "size-5 shrink-0 text-(--warning)",
1116
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1213
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1117
1214
  "path",
1118
1215
  {
1119
1216
  fill: "currentColor",
@@ -1122,7 +1219,7 @@ var init_InfoBanner = __esm({
1122
1219
  )
1123
1220
  }
1124
1221
  ),
1125
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1222
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1126
1223
  "p",
1127
1224
  {
1128
1225
  className: "break-anywhere text-[14px] leading-5 text-(--primary) [&_a]:underline",
@@ -1137,11 +1234,11 @@ var init_InfoBanner = __esm({
1137
1234
  });
1138
1235
 
1139
1236
  // src/components/common/PointsSwitch.tsx
1140
- var import_react6, import_jsx_runtime9, PointsSwitch;
1237
+ var import_react7, import_jsx_runtime10, PointsSwitch;
1141
1238
  var init_PointsSwitch = __esm({
1142
1239
  "src/components/common/PointsSwitch.tsx"() {
1143
1240
  "use strict";
1144
- import_react6 = require("react");
1241
+ import_react7 = require("react");
1145
1242
  init_StaticConfigContext();
1146
1243
  init_useSlapiBalance();
1147
1244
  init_useSpreePayConfig();
@@ -1149,7 +1246,7 @@ var init_PointsSwitch = __esm({
1149
1246
  init_switch();
1150
1247
  init_format();
1151
1248
  init_InfoBanner();
1152
- import_jsx_runtime9 = require("react/jsx-runtime");
1249
+ import_jsx_runtime10 = require("react/jsx-runtime");
1153
1250
  PointsSwitch = (props) => {
1154
1251
  const { disabled = false, value, onChange, message } = props;
1155
1252
  const { spreePayConfig } = useSpreePayConfig();
@@ -1158,29 +1255,29 @@ var init_PointsSwitch = __esm({
1158
1255
  const { balance } = useSlapiBalance();
1159
1256
  const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
1160
1257
  const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
1161
- const id = (0, import_react6.useId)();
1162
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-6", children: [
1163
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
1164
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3", children: [
1165
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
1166
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1258
+ const id = (0, import_react7.useId)();
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-6", children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
1261
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-3", children: [
1262
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
1263
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1167
1264
  Label,
1168
1265
  {
1169
1266
  htmlFor: id,
1170
1267
  className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-medium text-(--brand-primary) sm:flex-row sm:gap-2 md:text-[22px]",
1171
1268
  children: [
1172
1269
  "Use Points ",
1173
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-(--tertiary)", children: "Optional" })
1270
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-xs font-medium text-(--tertiary)", children: "Optional" })
1174
1271
  ]
1175
1272
  }
1176
1273
  )
1177
1274
  ] }),
1178
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2.5", children: [
1179
- balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-(--brand-primary)", children: [
1275
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-2.5", children: [
1276
+ balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-(--brand-primary)", children: [
1180
1277
  formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
1181
- !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-(--secondary)", children: ` \xB7 ${formatPointsValue(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
1278
+ !!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-(--secondary)", children: ` \xB7 ${formatPointsValue(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
1182
1279
  ] }) : null,
1183
- Boolean(topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1280
+ Boolean(topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1184
1281
  "a",
1185
1282
  {
1186
1283
  className: "cursor-pointer rounded-full bg-(--s-brand) px-2 py-1.5 text-xs font-medium text-(--inverse) hover:bg-(--s-brand-hover)",
@@ -1192,25 +1289,25 @@ var init_PointsSwitch = __esm({
1192
1289
  )
1193
1290
  ] })
1194
1291
  ] }),
1195
- message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfoBanner, { type: "warning", message })
1292
+ message && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoBanner, { type: "warning", message })
1196
1293
  ] });
1197
1294
  };
1198
1295
  }
1199
1296
  });
1200
1297
 
1201
1298
  // src/components/common/Legal.tsx
1202
- var import_jsx_runtime10, Legal;
1299
+ var import_jsx_runtime11, Legal;
1203
1300
  var init_Legal = __esm({
1204
1301
  "src/components/common/Legal.tsx"() {
1205
1302
  "use strict";
1206
1303
  init_useSpreePayConfig();
1207
- import_jsx_runtime10 = require("react/jsx-runtime");
1304
+ import_jsx_runtime11 = require("react/jsx-runtime");
1208
1305
  Legal = () => {
1209
1306
  const { spreePayConfig } = useSpreePayConfig();
1210
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "text-xs leading-5 font-medium text-(--secondary)", children: [
1307
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "text-xs leading-5 font-medium text-(--secondary)", children: [
1211
1308
  "By clicking on the button below I acknowledge that I have read and accepted the",
1212
1309
  " ",
1213
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1310
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1214
1311
  "a",
1215
1312
  {
1216
1313
  className: "whitespace-nowrap underline",
@@ -1237,10 +1334,11 @@ var init_common = __esm({
1237
1334
  });
1238
1335
 
1239
1336
  // src/components/CheckoutButton.tsx
1240
- var import_jsx_runtime11, CheckoutButton;
1337
+ var import_jsx_runtime12, CheckoutButton;
1241
1338
  var init_CheckoutButton = __esm({
1242
1339
  "src/components/CheckoutButton.tsx"() {
1243
1340
  "use strict";
1341
+ init_LoginStatusContext();
1244
1342
  init_SpreePayActionsContext();
1245
1343
  init_StaticConfigContext();
1246
1344
  init_useSpreePayConfig();
@@ -1249,8 +1347,9 @@ var init_CheckoutButton = __esm({
1249
1347
  init_split();
1250
1348
  init_transactionFee();
1251
1349
  init_common();
1252
- import_jsx_runtime11 = require("react/jsx-runtime");
1253
- CheckoutButton = ({ isLoggedIn }) => {
1350
+ import_jsx_runtime12 = require("react/jsx-runtime");
1351
+ CheckoutButton = () => {
1352
+ const isLoggedIn = useIsLoggedIn();
1254
1353
  const { appProps, staticConfig } = useStaticConfig();
1255
1354
  const {
1256
1355
  amount,
@@ -1280,7 +1379,7 @@ var init_CheckoutButton = __esm({
1280
1379
  };
1281
1380
  const getCheckoutContent = () => {
1282
1381
  if (!!isProcessing || isInternalProcessing) {
1283
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Spinner, { className: "inline", size: "sm" });
1382
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Spinner, { className: "inline", size: "sm" });
1284
1383
  }
1285
1384
  if (isCC && amount) {
1286
1385
  if (pointsAmount && usdAmount) {
@@ -1300,9 +1399,9 @@ var init_CheckoutButton = __esm({
1300
1399
  return "Checkout";
1301
1400
  };
1302
1401
  const checkoutClass = "text-(--inverse) h-14 leading-14 w-full cursor-pointer rounded-4xl bg-(--s-brand) hover:bg-(--s-brand-hover) px-4 text-center text-xl leading-6 font-medium disabled:cursor-not-allowed disabled:bg-(--s-disabled) disabled:text-(--disabled)";
1303
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex w-full flex-col gap-4 p-6 text-xs leading-5 font-medium text-(--secondary) md:px-7", children: [
1304
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Legal, {}),
1305
- isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1402
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex w-full flex-col gap-4 p-6 text-xs leading-5 font-medium text-(--secondary) md:px-7", children: [
1403
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Legal, {}),
1404
+ isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1306
1405
  "a",
1307
1406
  {
1308
1407
  href: `${staticConfig.keycloakUrl}/realms/${tenantId}/protocol/openid-connect/auth?client_id=${keycloakClientId ?? "oneof-next"}&response_type=code&redirect_uri=${window.location.href}`,
@@ -1310,9 +1409,9 @@ var init_CheckoutButton = __esm({
1310
1409
  children: spreePayConfig?.loginLabel || "Log in / Sign up"
1311
1410
  }
1312
1411
  ),
1313
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("a", { href: "https://www.spree.finance/", className: "flex items-center justify-center gap-2 hover:underline", children: [
1314
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: "Powered by" }),
1315
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-[30px]", viewBox: "0 0 66 30", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1412
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("a", { href: "https://www.spree.finance/", className: "flex items-center justify-center gap-2 hover:underline", children: [
1413
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: "Powered by" }),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-[30px]", viewBox: "0 0 66 30", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1316
1415
  "path",
1317
1416
  {
1318
1417
  fill: "currentColor",
@@ -1549,7 +1648,7 @@ var init_useCryptoPayment = __esm({
1549
1648
  });
1550
1649
  throw error;
1551
1650
  }
1552
- const { capture, hash, metadata } = params;
1651
+ const { capture, hash } = params;
1553
1652
  const TOKEN = selectedPaymentMethod.method.symbol;
1554
1653
  cryptoPaymentLogger.info("Starting crypto payment", {
1555
1654
  hash,
@@ -1609,7 +1708,6 @@ var init_useCryptoPayment = __esm({
1609
1708
  const paymentRes = await SlapiPaymentService.createPayment({
1610
1709
  hash,
1611
1710
  capture,
1612
- metadata,
1613
1711
  type: "CRYPTO" /* CRYPTO */,
1614
1712
  crypto: {
1615
1713
  token: TOKEN,
@@ -1663,26 +1761,26 @@ var init_useCryptoPayment = __esm({
1663
1761
  });
1664
1762
 
1665
1763
  // src/components/CryptoTab/Crypto/ConnectButton.tsx
1666
- var import_rainbowkit, import_jsx_runtime30, ConnectButton;
1764
+ var import_rainbowkit, import_jsx_runtime31, ConnectButton;
1667
1765
  var init_ConnectButton = __esm({
1668
1766
  "src/components/CryptoTab/Crypto/ConnectButton.tsx"() {
1669
1767
  "use strict";
1670
1768
  import_rainbowkit = require("@rainbow-me/rainbowkit");
1671
1769
  init_utils();
1672
- import_jsx_runtime30 = require("react/jsx-runtime");
1770
+ import_jsx_runtime31 = require("react/jsx-runtime");
1673
1771
  ConnectButton = () => {
1674
1772
  const buttonCN = "h-9 rounded-full border border-(--b-brand) px-4 text-sm font-medium text-(--brand-primary)";
1675
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_rainbowkit.ConnectButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
1773
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_rainbowkit.ConnectButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
1676
1774
  if (!mounted) return null;
1677
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: (() => {
1775
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: (() => {
1678
1776
  if (!mounted || !account || !chain) {
1679
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { className: buttonCN, onClick: openConnectModal, children: "Connect wallet" });
1777
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openConnectModal, children: "Connect wallet" });
1680
1778
  }
1681
1779
  if (chain.unsupported) {
1682
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { className: buttonCN, onClick: openChainModal, children: "Select a Network" });
1780
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openChainModal, children: "Select a Network" });
1683
1781
  }
1684
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("button", { className: cn(buttonCN, "flex items-center gap-2 pl-1.5"), onClick: openAccountModal, children: [
1685
- chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "size-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
1782
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { className: cn(buttonCN, "flex items-center gap-2 pl-1.5"), onClick: openAccountModal, children: [
1783
+ chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "size-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
1686
1784
  account.displayName
1687
1785
  ] });
1688
1786
  })() });
@@ -1695,32 +1793,32 @@ var init_ConnectButton = __esm({
1695
1793
  function getSymbolLogo(symbol) {
1696
1794
  return symbolLogos[symbol] ?? null;
1697
1795
  }
1698
- var import_jsx_runtime31, MOCA_SVG, USDC_SVG, USDT_SVG, WETH_SVG, symbolLogos;
1796
+ var import_jsx_runtime32, MOCA_SVG, USDC_SVG, USDT_SVG, WETH_SVG, symbolLogos;
1699
1797
  var init_symbolLogos = __esm({
1700
1798
  "src/config/symbolLogos.tsx"() {
1701
1799
  "use strict";
1702
- import_jsx_runtime31 = require("react/jsx-runtime");
1703
- MOCA_SVG = /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 28 28", children: [
1704
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("circle", { cx: "14", cy: "14", r: "13.5", fill: "#c15f97" }),
1705
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1800
+ import_jsx_runtime32 = require("react/jsx-runtime");
1801
+ MOCA_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 28 28", children: [
1802
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "14", cy: "14", r: "13.5", fill: "#c15f97" }),
1803
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1706
1804
  "path",
1707
1805
  {
1708
1806
  fill: "#fff",
1709
1807
  d: "M16.06 6.65c.3 0 .59.16.74.43l6.06 10.5a.85.85 0 1 1-1.47.84L16.06 9.2l-1.51 2.62-.02.03-3.8 6.57a.85.85 0 0 1-1.47-.84l3.57-6.18-1.27-2.2-5.32 9.22a.85.85 0 0 1-1.48-.84l6.07-10.5.06-.1a.85.85 0 0 1 1.4.1l1.52 2.62 1.52-2.62.06-.1c.16-.2.4-.33.67-.33"
1710
1808
  }
1711
1809
  ),
1712
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
1810
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
1713
1811
  ] });
1714
- USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
1715
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("path", { fill: "#2775ca", d: "M14 28c7.76 0 14-6.24 14-14S21.76 0 14 0 0 6.24 0 14s6.24 14 14 14" }),
1716
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1812
+ USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
1813
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#2775ca", d: "M14 28c7.76 0 14-6.24 14-14S21.76 0 14 0 0 6.24 0 14s6.24 14 14 14" }),
1814
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1717
1815
  "path",
1718
1816
  {
1719
1817
  fill: "#fff",
1720
1818
  d: "M17.85 16.22c0-2.04-1.23-2.74-3.68-3.04-1.75-.23-2.1-.7-2.1-1.51 0-.82.59-1.34 1.75-1.34 1.05 0 1.64.35 1.93 1.22.06.18.23.3.4.3h.94a.4.4 0 0 0 .41-.42v-.05a2.91 2.91 0 0 0-2.63-2.4v-1.4c0-.23-.17-.4-.46-.46h-.88c-.23 0-.4.17-.46.46v1.35c-1.75.23-2.86 1.4-2.86 2.85 0 1.93 1.16 2.69 3.61 2.98 1.64.29 2.16.64 2.16 1.57 0 .94-.81 1.58-1.92 1.58-1.52 0-2.04-.64-2.22-1.52-.06-.23-.23-.35-.4-.35h-1a.4.4 0 0 0-.4.41v.06c.23 1.46 1.16 2.5 3.08 2.8v1.4c0 .23.18.4.47.47h.88c.23 0 .4-.18.46-.47v-1.4c1.75-.3 2.92-1.52 2.92-3.1Z"
1721
1819
  }
1722
1820
  ),
1723
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1821
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1724
1822
  "path",
1725
1823
  {
1726
1824
  fill: "#fff",
@@ -1728,9 +1826,9 @@ var init_symbolLogos = __esm({
1728
1826
  }
1729
1827
  )
1730
1828
  ] });
1731
- USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
1732
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("path", { fill: "#26a17b", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28" }),
1733
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1829
+ USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
1830
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#26a17b", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28" }),
1831
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1734
1832
  "path",
1735
1833
  {
1736
1834
  fill: "#fff",
@@ -1738,23 +1836,23 @@ var init_symbolLogos = __esm({
1738
1836
  }
1739
1837
  )
1740
1838
  ] });
1741
- WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 24 24", children: [
1742
- /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("g", { clipPath: "url(#clip0_528_9173)", children: [
1743
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1839
+ WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 24 24", children: [
1840
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { clipPath: "url(#clip0_528_9173)", children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1744
1842
  "path",
1745
1843
  {
1746
1844
  fill: "#000",
1747
1845
  d: "M17.14 20.57c0 .95-1.31 2.01-3.39 2.4h-2.59c-4.65 0-8.42-1.07-8.42-2.4 0-1.32 3.77-2.4 8.42-2.4s5.98 1.08 5.98 2.4Z"
1748
1846
  }
1749
1847
  ),
1750
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1848
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1751
1849
  "path",
1752
1850
  {
1753
1851
  fill: "#F61F7D",
1754
1852
  d: "M23.31 11c0 5.86-5.18 11.63-11.07 11.63-5.9 0-11.9-6.17-11.9-12.03C.34 4.75 5.12 0 11.01 0s12.3 5.15 12.3 11Z"
1755
1853
  }
1756
1854
  ),
1757
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1855
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1758
1856
  "path",
1759
1857
  {
1760
1858
  fill: "#000",
@@ -1763,8 +1861,8 @@ var init_symbolLogos = __esm({
1763
1861
  clipRule: "evenodd"
1764
1862
  }
1765
1863
  ),
1766
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("path", { fill: "#fff", d: "M24 12.17a10.8 10.8 0 1 1-21.6 0 10.8 10.8 0 0 1 21.6 0Z" }),
1767
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1864
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M24 12.17a10.8 10.8 0 1 1-21.6 0 10.8 10.8 0 0 1 21.6 0Z" }),
1865
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1768
1866
  "path",
1769
1867
  {
1770
1868
  fill: "#000",
@@ -1773,8 +1871,8 @@ var init_symbolLogos = __esm({
1773
1871
  clipRule: "evenodd"
1774
1872
  }
1775
1873
  ),
1776
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
1777
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1874
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
1875
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1778
1876
  "path",
1779
1877
  {
1780
1878
  fill: "#000",
@@ -1782,7 +1880,7 @@ var init_symbolLogos = __esm({
1782
1880
  }
1783
1881
  )
1784
1882
  ] }),
1785
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
1883
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
1786
1884
  ] });
1787
1885
  symbolLogos = {
1788
1886
  MOCA: MOCA_SVG,
@@ -1794,18 +1892,18 @@ var init_symbolLogos = __esm({
1794
1892
  });
1795
1893
 
1796
1894
  // src/components/CryptoTab/Crypto/Logos.tsx
1797
- var import_jsx_runtime32, Logos;
1895
+ var import_jsx_runtime33, Logos;
1798
1896
  var init_Logos = __esm({
1799
1897
  "src/components/CryptoTab/Crypto/Logos.tsx"() {
1800
1898
  "use strict";
1801
1899
  init_symbolLogos();
1802
- import_jsx_runtime32 = require("react/jsx-runtime");
1900
+ import_jsx_runtime33 = require("react/jsx-runtime");
1803
1901
  Logos = () => {
1804
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex", children: [
1805
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "rounded-full border border-(--b-primary)", children: getSymbolLogo("MOCA") }),
1806
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDC") }),
1807
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDT") }),
1808
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary) bg-(--s-primary)", children: getSymbolLogo("WETH") })
1902
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex", children: [
1903
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "rounded-full border border-(--b-primary)", children: getSymbolLogo("MOCA") }),
1904
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDC") }),
1905
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDT") }),
1906
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary) bg-(--s-primary)", children: getSymbolLogo("WETH") })
1809
1907
  ] });
1810
1908
  };
1811
1909
  }
@@ -1813,7 +1911,7 @@ var init_Logos = __esm({
1813
1911
 
1814
1912
  // ../ui/src/components/input.tsx
1815
1913
  function Input2({ className, type, ...props }) {
1816
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1914
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1817
1915
  "input",
1818
1916
  {
1819
1917
  type,
@@ -1828,24 +1926,24 @@ function Input2({ className, type, ...props }) {
1828
1926
  }
1829
1927
  );
1830
1928
  }
1831
- var import_jsx_runtime33;
1929
+ var import_jsx_runtime34;
1832
1930
  var init_input = __esm({
1833
1931
  "../ui/src/components/input.tsx"() {
1834
1932
  "use strict";
1835
1933
  init_utils2();
1836
- import_jsx_runtime33 = require("react/jsx-runtime");
1934
+ import_jsx_runtime34 = require("react/jsx-runtime");
1837
1935
  }
1838
1936
  });
1839
1937
 
1840
1938
  // ../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs
1841
- var React13, ReactDOM2, import_react_slot5, import_jsx_runtime34, NODES2, Primitive2;
1939
+ var React13, ReactDOM2, import_react_slot5, import_jsx_runtime35, NODES2, Primitive2;
1842
1940
  var init_dist = __esm({
1843
1941
  "../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs"() {
1844
1942
  "use strict";
1845
1943
  React13 = __toESM(require("react"), 1);
1846
1944
  ReactDOM2 = __toESM(require("react-dom"), 1);
1847
1945
  import_react_slot5 = require("@radix-ui/react-slot");
1848
- import_jsx_runtime34 = require("react/jsx-runtime");
1946
+ import_jsx_runtime35 = require("react/jsx-runtime");
1849
1947
  NODES2 = [
1850
1948
  "a",
1851
1949
  "button",
@@ -1873,7 +1971,7 @@ var init_dist = __esm({
1873
1971
  if (typeof window !== "undefined") {
1874
1972
  window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
1875
1973
  }
1876
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
1974
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
1877
1975
  });
1878
1976
  Node2.displayName = `Primitive.${node}`;
1879
1977
  return { ...primitive, [node]: Node2 };
@@ -1885,13 +1983,13 @@ var init_dist = __esm({
1885
1983
  function isValidOrientation(orientation) {
1886
1984
  return ORIENTATIONS.includes(orientation);
1887
1985
  }
1888
- var React14, import_jsx_runtime35, NAME, DEFAULT_ORIENTATION, ORIENTATIONS, Separator, Root6;
1986
+ var React14, import_jsx_runtime36, NAME, DEFAULT_ORIENTATION, ORIENTATIONS, Separator, Root6;
1889
1987
  var init_dist2 = __esm({
1890
1988
  "../../node_modules/@radix-ui/react-separator/dist/index.mjs"() {
1891
1989
  "use strict";
1892
1990
  React14 = __toESM(require("react"), 1);
1893
1991
  init_dist();
1894
- import_jsx_runtime35 = require("react/jsx-runtime");
1992
+ import_jsx_runtime36 = require("react/jsx-runtime");
1895
1993
  NAME = "Separator";
1896
1994
  DEFAULT_ORIENTATION = "horizontal";
1897
1995
  ORIENTATIONS = ["horizontal", "vertical"];
@@ -1900,7 +1998,7 @@ var init_dist2 = __esm({
1900
1998
  const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
1901
1999
  const ariaOrientation = orientation === "vertical" ? orientation : void 0;
1902
2000
  const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
1903
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2001
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1904
2002
  Primitive2.div,
1905
2003
  {
1906
2004
  "data-orientation": orientation,
@@ -1922,7 +2020,7 @@ function Separator2({
1922
2020
  decorative = true,
1923
2021
  ...props
1924
2022
  }) {
1925
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2023
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1926
2024
  Root6,
1927
2025
  {
1928
2026
  "data-slot": "separator",
@@ -1936,14 +2034,14 @@ function Separator2({
1936
2034
  }
1937
2035
  );
1938
2036
  }
1939
- var import_jsx_runtime36;
2037
+ var import_jsx_runtime37;
1940
2038
  var init_separator = __esm({
1941
2039
  "../ui/src/components/separator.tsx"() {
1942
2040
  "use strict";
1943
2041
  "use client";
1944
2042
  init_dist2();
1945
2043
  init_utils2();
1946
- import_jsx_runtime36 = require("react/jsx-runtime");
2044
+ import_jsx_runtime37 = require("react/jsx-runtime");
1947
2045
  }
1948
2046
  });
1949
2047
 
@@ -2059,11 +2157,11 @@ var init_useBaseTokens = __esm({
2059
2157
  });
2060
2158
 
2061
2159
  // src/modals/CryptoSelectModal.tsx
2062
- var import_react16, import_nice_modal_react5, import_jsx_runtime37, CryptoSelectModal;
2160
+ var import_react17, import_nice_modal_react5, import_jsx_runtime38, CryptoSelectModal;
2063
2161
  var init_CryptoSelectModal = __esm({
2064
2162
  "src/modals/CryptoSelectModal.tsx"() {
2065
2163
  "use strict";
2066
- import_react16 = require("react");
2164
+ import_react17 = require("react");
2067
2165
  import_nice_modal_react5 = __toESM(require("@ebay/nice-modal-react"), 1);
2068
2166
  init_input();
2069
2167
  init_separator();
@@ -2073,14 +2171,14 @@ var init_CryptoSelectModal = __esm({
2073
2171
  init_useBaseNativeToken();
2074
2172
  init_useBaseTokens();
2075
2173
  init_dialog();
2076
- import_jsx_runtime37 = require("react/jsx-runtime");
2174
+ import_jsx_runtime38 = require("react/jsx-runtime");
2077
2175
  CryptoSelectModal = import_nice_modal_react5.default.create(() => {
2078
2176
  const modal = (0, import_nice_modal_react5.useModal)();
2079
2177
  const { isLoading, error, erc20Balances } = useBaseERC20Token();
2080
2178
  const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
2081
2179
  const { tokens, tokensIsLoading } = useBaseTokens();
2082
- const [search, setSearch] = (0, import_react16.useState)("");
2083
- const filteredCoins = (0, import_react16.useMemo)(() => {
2180
+ const [search, setSearch] = (0, import_react17.useState)("");
2181
+ const filteredCoins = (0, import_react17.useMemo)(() => {
2084
2182
  return tokens.filter(
2085
2183
  (coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
2086
2184
  );
@@ -2091,13 +2189,13 @@ var init_CryptoSelectModal = __esm({
2091
2189
  setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
2092
2190
  };
2093
2191
  const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
2094
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
2095
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DialogDescription, { className: "sr-only", children: "Crypto Select Modal" }),
2096
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2097
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
2098
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { className: "rounded-md hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-6", viewBox: "0 0 24 25", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { stroke: "currentColor", d: "m15 6.5-6 6 6 6" }) }) }),
2099
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DialogTitle, { className: "text-2xl font-medium text-(--brand-primary)", children: "Select a token" }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { className: "rounded-md p-1 hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 17", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2192
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
2193
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogDescription, { className: "sr-only", children: "Crypto Select Modal" }),
2194
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2195
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
2196
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-6", viewBox: "0 0 24 25", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { stroke: "currentColor", d: "m15 6.5-6 6 6 6" }) }) }),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogTitle, { className: "text-2xl font-medium text-(--brand-primary)", children: "Select a token" }),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md p-1 hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 17", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2101
2199
  "path",
2102
2200
  {
2103
2201
  fill: "currentColor",
@@ -2105,71 +2203,71 @@ var init_CryptoSelectModal = __esm({
2105
2203
  }
2106
2204
  ) }) })
2107
2205
  ] }),
2108
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
2206
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
2109
2207
  ] }),
2110
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Separator2, { className: "hidden md:block" }),
2111
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2112
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "Tokens with wallet balance" }),
2113
- (error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-center text-sm text-(--negative)", children: "Something wrong" }),
2114
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
2115
- isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2116
- nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2208
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Separator2, { className: "hidden md:block" }),
2209
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
2210
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "Tokens with wallet balance" }),
2211
+ (error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-center text-sm text-(--negative)", children: "Something wrong" }),
2212
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
2213
+ isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2214
+ nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
2117
2215
  "button",
2118
2216
  {
2119
2217
  className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover)",
2120
2218
  onClick: () => handleSelect(nativeBalance),
2121
2219
  children: [
2122
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2", children: [
2123
- nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("img", { className: "size-8 shrink-0", src: nativeBalance.logoURI, alt: `${nativeBalance.symbol} logo` }),
2124
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
2220
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
2221
+ nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: nativeBalance.logoURI, alt: `${nativeBalance.symbol} logo` }),
2222
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
2125
2223
  ] }),
2126
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
2224
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
2127
2225
  ]
2128
2226
  },
2129
2227
  nativeBalance.symbol
2130
2228
  ),
2131
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
2132
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2133
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2134
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
2229
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
2230
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2231
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2232
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
2135
2233
  ] }),
2136
2234
  erc20Balances.map((coin) => {
2137
2235
  const Icon = getSymbolLogo(coin.symbol);
2138
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2236
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
2139
2237
  "button",
2140
2238
  {
2141
2239
  className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
2142
2240
  onClick: () => handleSelect(coin),
2143
2241
  children: [
2144
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2", children: [
2242
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
2145
2243
  Boolean(Icon) && Icon,
2146
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
2244
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
2147
2245
  ] }),
2148
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
2246
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
2149
2247
  ]
2150
2248
  },
2151
2249
  coin.symbol
2152
2250
  );
2153
2251
  })
2154
2252
  ] }),
2155
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "All Tokens" }),
2156
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
2157
- tokensIsLoading && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
2158
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2159
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2160
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
2253
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "All Tokens" }),
2254
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
2255
+ tokensIsLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
2256
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2257
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
2258
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
2161
2259
  ] }),
2162
2260
  filteredCoins.map((token) => {
2163
2261
  const userCoin = userCoins.find((c) => c.symbol === token.symbol);
2164
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2262
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2165
2263
  "button",
2166
2264
  {
2167
2265
  disabled: !userCoin,
2168
2266
  onClick: () => userCoin && handleSelect(userCoin),
2169
2267
  className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
2170
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2", children: [
2171
- token.logoURI ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("img", { className: "size-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "size-8 shrink-0 rounded-full bg-(--s-tertiary)" }),
2172
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-sm font-medium", children: token.symbol })
2268
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
2269
+ token.logoURI ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "size-8 shrink-0 rounded-full bg-(--s-tertiary)" }),
2270
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: token.symbol })
2173
2271
  ] })
2174
2272
  },
2175
2273
  token.symbol
@@ -2184,25 +2282,25 @@ var init_CryptoSelectModal = __esm({
2184
2282
  });
2185
2283
 
2186
2284
  // src/components/CryptoTab/Crypto/SelectCoinButton.tsx
2187
- var import_nice_modal_react6, import_jsx_runtime38, SelectCoinButton;
2285
+ var import_nice_modal_react6, import_jsx_runtime39, SelectCoinButton;
2188
2286
  var init_SelectCoinButton = __esm({
2189
2287
  "src/components/CryptoTab/Crypto/SelectCoinButton.tsx"() {
2190
2288
  "use strict";
2191
2289
  import_nice_modal_react6 = __toESM(require("@ebay/nice-modal-react"), 1);
2192
2290
  init_CryptoSelectModal();
2193
- import_jsx_runtime38 = require("react/jsx-runtime");
2291
+ import_jsx_runtime39 = require("react/jsx-runtime");
2194
2292
  SelectCoinButton = () => {
2195
2293
  const openModal = () => {
2196
2294
  import_nice_modal_react6.default.show(CryptoSelectModal);
2197
2295
  };
2198
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2296
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
2199
2297
  "button",
2200
2298
  {
2201
2299
  onClick: openModal,
2202
2300
  className: "flex h-11 w-full overflow-hidden rounded-md bg-(--s-primary) hover:bg-(--s-primary-hover)",
2203
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
2204
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "font-medium text-(--secondary)", children: "Select a token" }) }),
2205
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { stroke: "currentColor", d: "m6 12.43 4-4-4-4" }) })
2301
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
2302
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "font-medium text-(--secondary)", children: "Select a token" }) }),
2303
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("path", { stroke: "currentColor", d: "m6 12.43 4-4-4-4" }) })
2206
2304
  ] })
2207
2305
  }
2208
2306
  );
@@ -2211,27 +2309,27 @@ var init_SelectCoinButton = __esm({
2211
2309
  });
2212
2310
 
2213
2311
  // src/components/CryptoTab/Crypto/SelectedCoin.tsx
2214
- var import_jsx_runtime39, SelectedCoin;
2312
+ var import_jsx_runtime40, SelectedCoin;
2215
2313
  var init_SelectedCoin = __esm({
2216
2314
  "src/components/CryptoTab/Crypto/SelectedCoin.tsx"() {
2217
2315
  "use strict";
2218
2316
  init_symbolLogos();
2219
- import_jsx_runtime39 = require("react/jsx-runtime");
2317
+ import_jsx_runtime40 = require("react/jsx-runtime");
2220
2318
  SelectedCoin = (props) => {
2221
2319
  const { coin, balance, logoURI } = props;
2222
2320
  const Icon = getSymbolLogo(coin);
2223
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex h-12 w-full overflow-hidden rounded-md border-2 border-(--b-brand) bg-(--s-primary)", children: [
2224
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-brand) bg-(--s-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) }) }),
2225
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex h-full w-full items-center justify-between rounded-r-md px-3", children: [
2226
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex items-center gap-1", children: [
2321
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-12 w-full overflow-hidden rounded-md border-2 border-(--b-brand) bg-(--s-primary)", children: [
2322
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-brand) bg-(--s-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) }) }),
2323
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-full w-full items-center justify-between rounded-r-md px-3", children: [
2324
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-1", children: [
2227
2325
  Icon,
2228
- !Icon && logoURI && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "mr-1 size-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
2229
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "font-semibold text-(--brand-primary)", children: coin }),
2230
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-4", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("path", { stroke: "currentColor", d: "m6 12.434 4-4-4-4" }) })
2326
+ !Icon && logoURI && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { className: "mr-1 size-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
2327
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "font-semibold text-(--brand-primary)", children: coin }),
2328
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-4", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("path", { stroke: "currentColor", d: "m6 12.434 4-4-4-4" }) })
2231
2329
  ] }),
2232
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "text-xs font-medium text-(--secondary)", children: [
2330
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "text-xs font-medium text-(--secondary)", children: [
2233
2331
  "Wallet balance ",
2234
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "text-(--brand-primary)", children: balance })
2332
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-(--brand-primary)", children: balance })
2235
2333
  ] })
2236
2334
  ] })
2237
2335
  ] });
@@ -2240,11 +2338,11 @@ var init_SelectedCoin = __esm({
2240
2338
  });
2241
2339
 
2242
2340
  // src/components/CryptoTab/Crypto/Crypto.tsx
2243
- var import_react17, import_wagmi4, import_jsx_runtime40, Crypto;
2341
+ var import_react18, import_wagmi4, import_jsx_runtime41, Crypto;
2244
2342
  var init_Crypto = __esm({
2245
2343
  "src/components/CryptoTab/Crypto/Crypto.tsx"() {
2246
2344
  "use strict";
2247
- import_react17 = require("react");
2345
+ import_react18 = require("react");
2248
2346
  import_wagmi4 = require("wagmi");
2249
2347
  init_SpreePayActionsContext();
2250
2348
  init_useCryptoPayment();
@@ -2255,7 +2353,7 @@ var init_Crypto = __esm({
2255
2353
  init_Logos();
2256
2354
  init_SelectCoinButton();
2257
2355
  init_SelectedCoin();
2258
- import_jsx_runtime40 = require("react/jsx-runtime");
2356
+ import_jsx_runtime41 = require("react/jsx-runtime");
2259
2357
  Crypto = () => {
2260
2358
  const { address } = (0, import_wagmi4.useAccount)();
2261
2359
  const { selectedPaymentMethod } = useSpreePaymentMethod();
@@ -2263,31 +2361,28 @@ var init_Crypto = __esm({
2263
2361
  const { spreePayConfig } = useSpreePayConfig();
2264
2362
  const isWalletConnected = Boolean(address);
2265
2363
  const { register } = useSpreePayRegister();
2266
- const handlePay = (0, import_react17.useCallback)(
2364
+ const handlePay = (0, import_react18.useCallback)(
2267
2365
  async (data) => {
2268
2366
  try {
2269
2367
  const res = await cryptoPayment(data);
2270
- if (["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(res.status)) {
2271
- return Promise.resolve(res);
2272
- }
2273
- return Promise.reject(new PaymentError("Crypto payment failed", res.status));
2274
- } catch (_) {
2275
- return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
2368
+ return settlePaymentResult(res, "Crypto payment failed");
2369
+ } catch (e) {
2370
+ return Promise.reject(toPaymentError(e, "Crypto payment failed"));
2276
2371
  }
2277
2372
  },
2278
2373
  [cryptoPayment]
2279
2374
  );
2280
- (0, import_react17.useEffect)(() => {
2375
+ (0, import_react18.useEffect)(() => {
2281
2376
  register(handlePay);
2282
2377
  }, [register, handlePay]);
2283
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
2284
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
2285
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "text-lg leading-7 font-medium text-(--brand-primary) md:text-[22px]", children: "Pay with Crypto" }),
2286
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ConnectButton, {})
2378
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
2379
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
2380
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "text-lg leading-7 font-medium text-(--brand-primary) md:text-[22px]", children: "Pay with Crypto" }),
2381
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ConnectButton, {})
2287
2382
  ] }),
2288
- !isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Logos, {}),
2289
- isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
2290
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
2383
+ !isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Logos, {}),
2384
+ isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
2385
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2291
2386
  SelectedCoin,
2292
2387
  {
2293
2388
  coin: selectedPaymentMethod.method.symbol,
@@ -2295,9 +2390,9 @@ var init_Crypto = __esm({
2295
2390
  logoURI: selectedPaymentMethod.method.logoURI
2296
2391
  }
2297
2392
  ),
2298
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(SelectCoinButton, {})
2393
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SelectCoinButton, {})
2299
2394
  ] }),
2300
- spreePayConfig?.crypto.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(InfoBanner, { message: spreePayConfig.crypto.infoMessage })
2395
+ spreePayConfig?.crypto.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(InfoBanner, { message: spreePayConfig.crypto.infoMessage })
2301
2396
  ] });
2302
2397
  };
2303
2398
  }
@@ -2313,31 +2408,33 @@ function getCachedWagmiConfig(projectId, appName) {
2313
2408
  }
2314
2409
  return cfg2;
2315
2410
  }
2316
- var import_react18, import_react_query, import_nice_modal_react7, import_rainbowkit2, import_styles, import_wagmi5, import_chains, import_jsx_runtime41, queryClient, CHAINS, wagmiConfigCache, CryptoWrapper;
2411
+ var import_react19, import_react_query, import_nice_modal_react7, import_rainbowkit2, import_styles, import_wagmi5, import_chains, import_jsx_runtime42, queryClient, CHAINS, wagmiConfigCache, CryptoWrapper;
2317
2412
  var init_CryptoWrapper = __esm({
2318
2413
  "src/components/CryptoTab/Crypto/CryptoWrapper.tsx"() {
2319
2414
  "use strict";
2320
- import_react18 = require("react");
2415
+ import_react19 = require("react");
2321
2416
  import_react_query = require("@tanstack/react-query");
2322
2417
  import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
2323
2418
  import_rainbowkit2 = require("@rainbow-me/rainbowkit");
2324
2419
  import_styles = require("@rainbow-me/rainbowkit/styles.css");
2325
2420
  import_wagmi5 = require("wagmi");
2326
2421
  import_chains = require("wagmi/chains");
2422
+ init_LoginStatusContext();
2327
2423
  init_useSpreePayConfig();
2328
2424
  init_Crypto();
2329
- import_jsx_runtime41 = require("react/jsx-runtime");
2425
+ import_jsx_runtime42 = require("react/jsx-runtime");
2330
2426
  queryClient = new import_react_query.QueryClient();
2331
2427
  CHAINS = [import_chains.base];
2332
2428
  wagmiConfigCache = /* @__PURE__ */ new Map();
2333
2429
  CryptoWrapper = () => {
2430
+ const isLoggedIn = useIsLoggedIn();
2334
2431
  const { spreePayConfig, configIsLoading } = useSpreePayConfig();
2335
- const wagmiConfig = (0, import_react18.useMemo)(() => {
2432
+ const wagmiConfig = (0, import_react19.useMemo)(() => {
2336
2433
  if (!spreePayConfig) return null;
2337
2434
  return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
2338
2435
  }, [spreePayConfig]);
2339
- if (configIsLoading || !wagmiConfig) return null;
2340
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Crypto, {}) }) }) }) });
2436
+ if (!isLoggedIn || configIsLoading || !wagmiConfig) return null;
2437
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Crypto, {}) }) }) }) });
2341
2438
  };
2342
2439
  }
2343
2440
  });
@@ -2351,7 +2448,7 @@ var init_Crypto2 = __esm({
2351
2448
  });
2352
2449
 
2353
2450
  // src/components/CryptoTab/CryptoTab.tsx
2354
- var import_jsx_runtime42, CryptoTab;
2451
+ var import_jsx_runtime43, CryptoTab;
2355
2452
  var init_CryptoTab = __esm({
2356
2453
  "src/components/CryptoTab/CryptoTab.tsx"() {
2357
2454
  "use strict";
@@ -2359,13 +2456,13 @@ var init_CryptoTab = __esm({
2359
2456
  init_CheckoutButton();
2360
2457
  init_common();
2361
2458
  init_Crypto2();
2362
- import_jsx_runtime42 = require("react/jsx-runtime");
2363
- CryptoTab = ({ isLoggedIn }) => {
2459
+ import_jsx_runtime43 = require("react/jsx-runtime");
2460
+ CryptoTab = () => {
2364
2461
  const { spreePayConfig } = useSpreePayConfig();
2365
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { children: [
2366
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CryptoWrapper, {}) }),
2367
- !spreePayConfig?.crypto.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) }),
2368
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CheckoutButton, { isLoggedIn })
2462
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
2463
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CryptoWrapper, {}) }),
2464
+ !spreePayConfig?.crypto.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) }),
2465
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CheckoutButton, {})
2369
2466
  ] });
2370
2467
  };
2371
2468
  }
@@ -2401,11 +2498,10 @@ var init_useCryptoComPayment = __esm({
2401
2498
  if (selectedPaymentMethod.type !== "CDC" /* CDC */) {
2402
2499
  throw new Error("Unsupported payment method");
2403
2500
  }
2404
- const { hash, metadata } = params;
2501
+ const { hash } = params;
2405
2502
  cryptoComLogger.info("Starting Crypto.com Pay payment", { hash });
2406
2503
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
2407
2504
  hash,
2408
- metadata,
2409
2505
  type: "CDC" /* CDC */,
2410
2506
  cdc: {
2411
2507
  returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=success`,
@@ -2451,24 +2547,26 @@ var init_useCryptoComPayment = __esm({
2451
2547
  });
2452
2548
 
2453
2549
  // src/components/CryptoComTab/Checkout.tsx
2454
- var import_jsx_runtime43, Checkout;
2550
+ var import_jsx_runtime44, Checkout;
2455
2551
  var init_Checkout = __esm({
2456
2552
  "src/components/CryptoComTab/Checkout.tsx"() {
2457
2553
  "use strict";
2554
+ init_LoginStatusContext();
2458
2555
  init_SpreePayActionsContext();
2459
2556
  init_StaticConfigContext();
2460
- import_jsx_runtime43 = require("react/jsx-runtime");
2557
+ import_jsx_runtime44 = require("react/jsx-runtime");
2461
2558
  Checkout = () => {
2559
+ const isLoggedIn = useIsLoggedIn();
2462
2560
  const { appProps } = useStaticConfig();
2463
2561
  const { isInternalProcessing } = useSpreePaymentMethod();
2464
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2562
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2465
2563
  "button",
2466
2564
  {
2467
2565
  onClick: appProps.onProcess,
2468
- disabled: !!appProps.isProcessing || isInternalProcessing,
2566
+ disabled: !isLoggedIn || !!appProps.isProcessing || isInternalProcessing,
2469
2567
  className: "flex flex-col items-center rounded-md bg-(--crypto-pay-bg) p-2 text-(--brand-primary) hover:bg-(--crypto-pay-bg-hover) disabled:cursor-not-allowed disabled:bg-(--crypto-pay-bg-hover) disabled:text-(--disabled)",
2470
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-7 w-[76px]", fill: "none", viewBox: "0 0 76 28", children: [
2471
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2568
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-7 w-[76px]", fill: "none", viewBox: "0 0 76 28", children: [
2569
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2472
2570
  "path",
2473
2571
  {
2474
2572
  fill: "currentColor",
@@ -2477,7 +2575,7 @@ var init_Checkout = __esm({
2477
2575
  clipRule: "evenodd"
2478
2576
  }
2479
2577
  ),
2480
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2578
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2481
2579
  "path",
2482
2580
  {
2483
2581
  fill: "currentColor",
@@ -2486,7 +2584,7 @@ var init_Checkout = __esm({
2486
2584
  clipRule: "evenodd"
2487
2585
  }
2488
2586
  ),
2489
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2587
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2490
2588
  "path",
2491
2589
  {
2492
2590
  fill: "currentColor",
@@ -2495,7 +2593,7 @@ var init_Checkout = __esm({
2495
2593
  clipRule: "evenodd"
2496
2594
  }
2497
2595
  ),
2498
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2596
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2499
2597
  "path",
2500
2598
  {
2501
2599
  fill: "currentColor",
@@ -2504,7 +2602,7 @@ var init_Checkout = __esm({
2504
2602
  clipRule: "evenodd"
2505
2603
  }
2506
2604
  ),
2507
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2605
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2508
2606
  "path",
2509
2607
  {
2510
2608
  fill: "currentColor",
@@ -2521,43 +2619,40 @@ var init_Checkout = __esm({
2521
2619
  });
2522
2620
 
2523
2621
  // src/components/CryptoComTab/CryptoComTab.tsx
2524
- var import_react19, import_jsx_runtime44, CryptoComTab;
2622
+ var import_react20, import_jsx_runtime45, CryptoComTab;
2525
2623
  var init_CryptoComTab = __esm({
2526
2624
  "src/components/CryptoComTab/CryptoComTab.tsx"() {
2527
2625
  "use strict";
2528
- import_react19 = require("react");
2626
+ import_react20 = require("react");
2529
2627
  init_SpreePayActionsContext();
2530
2628
  init_useCryptoComPayment();
2531
2629
  init_useSpreePayConfig();
2532
2630
  init_errors();
2533
2631
  init_common();
2534
2632
  init_Checkout();
2535
- import_jsx_runtime44 = require("react/jsx-runtime");
2633
+ import_jsx_runtime45 = require("react/jsx-runtime");
2536
2634
  CryptoComTab = () => {
2537
2635
  const { register } = useSpreePayRegister();
2538
2636
  const { cryptoComPayment } = useCryptoComPayment();
2539
2637
  const { spreePayConfig } = useSpreePayConfig();
2540
- const handlePay = (0, import_react19.useCallback)(
2638
+ const handlePay = (0, import_react20.useCallback)(
2541
2639
  async (data) => {
2542
2640
  try {
2543
2641
  const res = await cryptoComPayment(data);
2544
- if (["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(res.status)) {
2545
- return Promise.resolve(res);
2546
- }
2547
- return Promise.reject(new PaymentError("Crypto payment failed", res.status));
2548
- } catch (_) {
2549
- return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
2642
+ return settlePaymentResult(res, "Crypto payment failed");
2643
+ } catch (e) {
2644
+ return Promise.reject(toPaymentError(e, "Crypto payment failed"));
2550
2645
  }
2551
2646
  },
2552
2647
  [cryptoComPayment]
2553
2648
  );
2554
- (0, import_react19.useEffect)(() => {
2649
+ (0, import_react20.useEffect)(() => {
2555
2650
  register(handlePay);
2556
2651
  }, [register, handlePay]);
2557
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
2558
- spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(InfoBanner, { message: spreePayConfig.cryptoCom.infoMessage }),
2559
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Legal, {}),
2560
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Checkout, {})
2652
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
2653
+ spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InfoBanner, { message: spreePayConfig.cryptoCom.infoMessage }),
2654
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Legal, {}),
2655
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Checkout, {})
2561
2656
  ] });
2562
2657
  };
2563
2658
  }
@@ -2579,10 +2674,15 @@ var init_CryptoComTab2 = __esm({
2579
2674
  var index_exports = {};
2580
2675
  __export(index_exports, {
2581
2676
  LogLevel: () => LogLevel,
2677
+ PaymentError: () => PaymentError,
2678
+ PaymentErrorCode: () => PaymentErrorCode,
2679
+ PaymentStatus: () => PaymentStatus,
2582
2680
  PaymentType: () => PaymentType,
2583
2681
  SpreePay: () => SpreePay,
2682
+ SpreePayHttpError: () => SpreePayHttpError,
2584
2683
  SpreePayProvider: () => SpreePayProvider,
2585
2684
  configureLogger: () => configureLogger,
2685
+ isPaymentError: () => isPaymentError,
2586
2686
  logger: () => logger,
2587
2687
  useCapture3DS: () => useCapture3DS,
2588
2688
  useSpreePay: () => useSpreePay
@@ -2590,15 +2690,15 @@ __export(index_exports, {
2590
2690
  module.exports = __toCommonJS(index_exports);
2591
2691
 
2592
2692
  // src/SpreePay.tsx
2593
- var import_react23 = require("react");
2693
+ var import_react24 = require("react");
2594
2694
  var import_nice_modal_react9 = __toESM(require("@ebay/nice-modal-react"), 1);
2595
2695
  var import_swr5 = require("swr");
2596
2696
 
2597
2697
  // src/SpreePayContent.tsx
2598
- var import_react20 = require("react");
2698
+ var import_react21 = require("react");
2599
2699
 
2600
2700
  // src/components/CreditCardTab/CreditCardTab.tsx
2601
- var import_react15 = require("react");
2701
+ var import_react16 = require("react");
2602
2702
  init_SpreePayActionsContext();
2603
2703
  init_StaticConfigContext();
2604
2704
 
@@ -2624,12 +2724,8 @@ var useCardPayment = () => {
2624
2724
  });
2625
2725
  throw error;
2626
2726
  }
2627
- const { hash, capture, metadata } = params;
2628
- cardPaymentLogger.info("Starting card payment", {
2629
- hash,
2630
- capture,
2631
- hasMetadata: Boolean(metadata)
2632
- });
2727
+ const { hash, capture } = params;
2728
+ cardPaymentLogger.info("Starting card payment", { hash, capture });
2633
2729
  const card = selectedPaymentMethod.method;
2634
2730
  let cardId;
2635
2731
  if ("token" in card) {
@@ -2660,7 +2756,6 @@ var useCardPayment = () => {
2660
2756
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
2661
2757
  hash,
2662
2758
  capture,
2663
- metadata,
2664
2759
  type: "CREDIT_CARD" /* CREDIT_CARD */,
2665
2760
  card: {
2666
2761
  cardId,
@@ -2828,16 +2923,20 @@ init_useSpreePayConfig();
2828
2923
  var import_nice_modal_react3 = __toESM(require("@ebay/nice-modal-react"), 1);
2829
2924
  init_Iframe3ds();
2830
2925
  init_slapi();
2926
+ init_errors();
2831
2927
  var REFRESH_INTERVAL = 3 * 1e3;
2832
2928
  var MAX_RETRIES = 10;
2833
2929
  async function longPollPoints(paymentId) {
2834
2930
  let retries = 0;
2835
2931
  while (retries < MAX_RETRIES) {
2836
2932
  const { detail } = await SlapiPaymentService.getStatus(paymentId);
2837
- if (detail.status === "FAILED" /* FAILED */) {
2838
- throw new Error("Something went wrong with the payment");
2933
+ if (isDeclineStatus(detail.status)) {
2934
+ throw new PaymentError("Something went wrong with the points payment.", detail.status, {
2935
+ code: "PAYMENT_ERROR" /* PAYMENT_ERROR */,
2936
+ backendCode: detail.errorCode ?? void 0
2937
+ });
2839
2938
  }
2840
- if (["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)) {
2939
+ if (isSuccessStatus(detail.status)) {
2841
2940
  return detail.status;
2842
2941
  }
2843
2942
  await new Promise((res) => setTimeout(res, REFRESH_INTERVAL));
@@ -2850,13 +2949,21 @@ async function longPollCardStatus(paymentId) {
2850
2949
  let shown3ds = false;
2851
2950
  while (retries < MAX_RETRIES) {
2852
2951
  const { detail } = await SlapiPaymentService.getStatus(paymentId);
2853
- if (detail.status === "FAILED" /* FAILED */) {
2854
- throw new Error(`Something went wrong with the ${detail.validationType} payment`);
2952
+ if (isDeclineStatus(detail.status)) {
2953
+ const isPointsLeg = detail.validationType === "POINTS";
2954
+ throw new PaymentError(
2955
+ isPointsLeg ? "Something went wrong with the points payment." : "Your card payment could not be completed.",
2956
+ detail.status,
2957
+ {
2958
+ code: isPointsLeg ? "PAYMENT_ERROR" /* PAYMENT_ERROR */ : "CARD_ERROR" /* CARD_ERROR */,
2959
+ backendCode: detail.errorCode ?? void 0
2960
+ }
2961
+ );
2855
2962
  }
2856
2963
  if (
2857
2964
  // Process to points payment
2858
2965
  detail.validationType === "POINTS" || // early card payment completion
2859
- ["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)
2966
+ isSuccessStatus(detail.status)
2860
2967
  ) {
2861
2968
  return detail.status;
2862
2969
  }
@@ -2886,7 +2993,7 @@ var usePointsPayment = (mode = "web2") => {
2886
2993
  });
2887
2994
  throw error;
2888
2995
  }
2889
- const { hash, capture, metadata } = params;
2996
+ const { hash, capture } = params;
2890
2997
  pointsPaymentLogger.info("Starting points payment", {
2891
2998
  hash,
2892
2999
  capture,
@@ -2901,7 +3008,6 @@ var usePointsPayment = (mode = "web2") => {
2901
3008
  hash,
2902
3009
  // capture should be always true for web2 points payments
2903
3010
  capture: mode === "web2" ? true : capture,
2904
- metadata,
2905
3011
  type: "POINTS" /* POINTS */
2906
3012
  });
2907
3013
  pointsPaymentLogger.info("Points payment created", {
@@ -3002,7 +3108,7 @@ var useSplitCardPayments = (mode = "web2") => {
3002
3108
  if (selectedPaymentMethod.type !== "CREDIT_CARD" /* CREDIT_CARD */ || !selectedPaymentMethod.method || !params.points) {
3003
3109
  throw new Error("Unsupported payment method");
3004
3110
  }
3005
- const { hash, capture, metadata, points } = params;
3111
+ const { hash, capture, points } = params;
3006
3112
  splitPaymentLogger.info("Starting split card+points payment", { hash, mode, points, capture });
3007
3113
  const card = selectedPaymentMethod.method;
3008
3114
  let cardId;
@@ -3030,7 +3136,6 @@ var useSplitCardPayments = (mode = "web2") => {
3030
3136
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
3031
3137
  hash,
3032
3138
  capture,
3033
- metadata,
3034
3139
  type: "SPLIT" /* CREDIT_CARD_SPLIT */,
3035
3140
  card: {
3036
3141
  cardId,
@@ -3147,21 +3252,22 @@ init_split();
3147
3252
  init_CheckoutButton();
3148
3253
 
3149
3254
  // src/components/CreditCardTab/CreditCard/CreditCard.tsx
3150
- var import_react9 = require("react");
3255
+ var import_react10 = require("react");
3151
3256
  var import_react_stripe_js2 = require("@stripe/react-stripe-js");
3152
3257
  var import_stripe_js = require("@stripe/stripe-js");
3258
+ init_LoginStatusContext();
3153
3259
  init_SpreePayActionsContext();
3154
3260
  init_useSpreePayConfig();
3155
3261
  init_InfoBanner();
3156
3262
 
3157
3263
  // src/components/CreditCardTab/CreditCard/CardsList.tsx
3158
- var import_react7 = require("react");
3264
+ var import_react8 = require("react");
3159
3265
  init_utils();
3160
3266
  init_slapi();
3161
3267
  init_payments();
3162
- var import_jsx_runtime12 = require("react/jsx-runtime");
3268
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3163
3269
  var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
3164
- const [isRemoving, setIsRemoving] = (0, import_react7.useState)(false);
3270
+ const [isRemoving, setIsRemoving] = (0, import_react8.useState)(false);
3165
3271
  const removeDisabled = isSelected || isRemoving;
3166
3272
  const handleRemove = async (e) => {
3167
3273
  e.stopPropagation();
@@ -3172,7 +3278,7 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
3172
3278
  setIsRemoving(false);
3173
3279
  }
3174
3280
  };
3175
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3281
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
3176
3282
  "div",
3177
3283
  {
3178
3284
  role: "button",
@@ -3184,36 +3290,36 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
3184
3290
  { "border-(--b-brand)": isSelected }
3185
3291
  ),
3186
3292
  children: [
3187
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3293
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3188
3294
  "div",
3189
3295
  {
3190
3296
  className: cn("flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-inverse)", {
3191
3297
  "border-(--b-brand)": isSelected
3192
3298
  }),
3193
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
3299
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
3194
3300
  }
3195
3301
  ),
3196
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3302
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
3197
3303
  "div",
3198
3304
  {
3199
3305
  className: cn("flex h-full w-full items-center justify-between rounded-r-sm pr-2 pl-3", {
3200
3306
  "border-(--primary)": isSelected
3201
3307
  }),
3202
3308
  children: [
3203
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: card.schema }) }),
3204
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
3205
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-sm font-medium text-(--secondary)", children: [
3309
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: card.schema }) }),
3310
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
3311
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "text-sm font-medium text-(--secondary)", children: [
3206
3312
  "Ending in ",
3207
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-(--brand-primary)", children: card.lastFourNumbers })
3313
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-(--brand-primary)", children: card.lastFourNumbers })
3208
3314
  ] }),
3209
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3315
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3210
3316
  "button",
3211
3317
  {
3212
3318
  type: "button",
3213
3319
  onClick: handleRemove,
3214
3320
  disabled: removeDisabled,
3215
3321
  className: "text-tertiary rounded-md p-1 transition-all hover:bg-(--s-secondary) disabled:cursor-not-allowed disabled:opacity-50",
3216
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", className: "size-5", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M6.35 16.17q-.57 0-.96-.4a1.3 1.3 0 0 1-.39-.95V4.5h-.83v-.83H7.5v-.64h5v.64h3.33v.83H15v10.32q0 .58-.39.96a1.3 1.3 0 0 1-.96.39zM14.17 4.5H5.83v10.32q0 .23.15.37.15.15.37.15h7.3q.2 0 .36-.16.15-.17.16-.36zm-6 9.17h.84v-7.5h-.84zm2.82 0h.84v-7.5h-.84z" }) })
3322
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", className: "size-5", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M6.35 16.17q-.57 0-.96-.4a1.3 1.3 0 0 1-.39-.95V4.5h-.83v-.83H7.5v-.64h5v.64h3.33v.83H15v10.32q0 .58-.39.96a1.3 1.3 0 0 1-.96.39zM14.17 4.5H5.83v10.32q0 .23.15.37.15.15.37.15h7.3q.2 0 .36-.16.15-.17.16-.36zm-6 9.17h.84v-7.5h-.84zm2.82 0h.84v-7.5h-.84z" }) })
3217
3323
  }
3218
3324
  )
3219
3325
  ] })
@@ -3226,7 +3332,7 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
3226
3332
  };
3227
3333
  var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
3228
3334
  const { cards, cardsIsLoading, mutateCards } = useCards();
3229
- const allCards = (0, import_react7.useMemo)(() => [...cards, ...newCards], [cards, newCards]);
3335
+ const allCards = (0, import_react8.useMemo)(() => [...cards, ...newCards], [cards, newCards]);
3230
3336
  const handleRemove = async (card) => {
3231
3337
  if (isNewCard(card)) {
3232
3338
  onRemoveNewCard(card);
@@ -3236,10 +3342,10 @@ var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
3236
3342
  }
3237
3343
  };
3238
3344
  if (cardsIsLoading) {
3239
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "h-11 animate-pulse rounded-sm bg-(--s-primary)" }) });
3345
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "h-11 animate-pulse rounded-sm bg-(--s-primary)" }) });
3240
3346
  }
3241
3347
  if (allCards.length === 0) return null;
3242
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col gap-4", children: allCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3348
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex w-full flex-col gap-4", children: allCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3243
3349
  CardListItem,
3244
3350
  {
3245
3351
  isSelected: selectedCard?.id === card.id,
@@ -3252,14 +3358,14 @@ var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
3252
3358
  };
3253
3359
 
3254
3360
  // src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
3255
- var import_react8 = require("react");
3361
+ var import_react9 = require("react");
3256
3362
  var import_react_stripe_js = require("@stripe/react-stripe-js");
3257
3363
 
3258
3364
  // src/ui/button.tsx
3259
3365
  var import_react_slot = require("@radix-ui/react-slot");
3260
3366
  var import_class_variance_authority = require("class-variance-authority");
3261
3367
  init_utils();
3262
- var import_jsx_runtime13 = require("react/jsx-runtime");
3368
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3263
3369
  var buttonVariants = (0, import_class_variance_authority.cva)(
3264
3370
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
3265
3371
  {
@@ -3294,16 +3400,16 @@ function Button({
3294
3400
  ...props
3295
3401
  }) {
3296
3402
  const Comp = asChild ? import_react_slot.Slot : "button";
3297
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props });
3403
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props });
3298
3404
  }
3299
3405
 
3300
3406
  // src/ui/checkbox.tsx
3301
3407
  var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"), 1);
3302
3408
  var import_lucide_react2 = require("lucide-react");
3303
3409
  init_utils();
3304
- var import_jsx_runtime14 = require("react/jsx-runtime");
3410
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3305
3411
  function Checkbox({ className, ...props }) {
3306
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3412
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3307
3413
  CheckboxPrimitive.Root,
3308
3414
  {
3309
3415
  "data-slot": "checkbox",
@@ -3312,12 +3418,12 @@ function Checkbox({ className, ...props }) {
3312
3418
  className
3313
3419
  ),
3314
3420
  ...props,
3315
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3421
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3316
3422
  CheckboxPrimitive.Indicator,
3317
3423
  {
3318
3424
  "data-slot": "checkbox-indicator",
3319
3425
  className: "flex items-center justify-center text-current transition-none",
3320
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react2.CheckIcon, { className: "size-3.5 text-(--inverse)" })
3426
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react2.CheckIcon, { className: "size-3.5 text-(--inverse)" })
3321
3427
  }
3322
3428
  )
3323
3429
  }
@@ -3327,7 +3433,7 @@ function Checkbox({ className, ...props }) {
3327
3433
  // src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
3328
3434
  init_label();
3329
3435
  init_logger();
3330
- var import_jsx_runtime15 = require("react/jsx-runtime");
3436
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3331
3437
  var cardFormLogger = logger.child("card-form");
3332
3438
  var stripeElementClasses = {
3333
3439
  base: "w-full rounded-[12px] bg-(--s-primary) px-5 py-4 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
@@ -3335,14 +3441,14 @@ var stripeElementClasses = {
3335
3441
  focus: "border-ring ring-ring/50 ring-2"
3336
3442
  };
3337
3443
  var CreditCardForm = ({ cancel, saveCard }) => {
3338
- const [cardError, setCardError] = (0, import_react8.useState)(void 0);
3339
- const [stripeStyles, setStripeStyles] = (0, import_react8.useState)({});
3340
- const [shouldSaveCard, setShouldSaveCard] = (0, import_react8.useState)(true);
3341
- const [isSubmitting, setIsSubmitting] = (0, import_react8.useState)(false);
3444
+ const [cardError, setCardError] = (0, import_react9.useState)(void 0);
3445
+ const [stripeStyles, setStripeStyles] = (0, import_react9.useState)({});
3446
+ const [shouldSaveCard, setShouldSaveCard] = (0, import_react9.useState)(true);
3447
+ const [isSubmitting, setIsSubmitting] = (0, import_react9.useState)(false);
3342
3448
  const elements = (0, import_react_stripe_js.useElements)();
3343
3449
  const stripe = (0, import_react_stripe_js.useStripe)();
3344
- const [id] = (0, import_react8.useState)(() => crypto.randomUUID());
3345
- const formRef = (0, import_react8.useCallback)((node) => {
3450
+ const [id] = (0, import_react9.useState)(() => crypto.randomUUID());
3451
+ const formRef = (0, import_react9.useCallback)((node) => {
3346
3452
  if (!node) return;
3347
3453
  const container = node.closest(".sl-spreepay");
3348
3454
  if (!container) return;
@@ -3400,9 +3506,9 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3400
3506
  setIsSubmitting(false);
3401
3507
  }
3402
3508
  };
3403
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
3404
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ref: formRef, className: "flex w-full flex-col gap-4", children: [
3405
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3509
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3510
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: formRef, className: "flex w-full flex-col gap-4", children: [
3511
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3406
3512
  import_react_stripe_js.CardNumberElement,
3407
3513
  {
3408
3514
  options: {
@@ -3412,8 +3518,8 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3412
3518
  }
3413
3519
  }
3414
3520
  ),
3415
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex w-full gap-4", children: [
3416
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3521
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full gap-4", children: [
3522
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3417
3523
  import_react_stripe_js.CardExpiryElement,
3418
3524
  {
3419
3525
  options: {
@@ -3423,7 +3529,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3423
3529
  }
3424
3530
  }
3425
3531
  ),
3426
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3532
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3427
3533
  import_react_stripe_js.CardCvcElement,
3428
3534
  {
3429
3535
  options: {
@@ -3434,14 +3540,14 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3434
3540
  }
3435
3541
  )
3436
3542
  ] }),
3437
- cardError && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-destructive mt-1 text-sm", children: cardError })
3543
+ cardError && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-destructive mt-1 text-sm", children: cardError })
3438
3544
  ] }),
3439
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
3440
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Checkbox, { checked: shouldSaveCard, onCheckedChange: (v) => setShouldSaveCard(v === true), id: "saveCard" }),
3441
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label, { className: "text-sm font-medium", htmlFor: "saveCard", children: "Save card for future purchases" })
3545
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
3546
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Checkbox, { checked: shouldSaveCard, onCheckedChange: (v) => setShouldSaveCard(v === true), id: "saveCard" }),
3547
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { className: "text-sm font-medium", htmlFor: "saveCard", children: "Save card for future purchases" })
3442
3548
  ] }),
3443
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex w-full justify-end gap-2", children: [
3444
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3549
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full justify-end gap-2", children: [
3550
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3445
3551
  Button,
3446
3552
  {
3447
3553
  variant: "outline",
@@ -3451,7 +3557,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3451
3557
  children: "Cancel"
3452
3558
  }
3453
3559
  ),
3454
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3560
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3455
3561
  Button,
3456
3562
  {
3457
3563
  className: "bg-(--s-brand) font-medium text-(--inverse) hover:bg-(--s-brand-hover)",
@@ -3465,13 +3571,14 @@ var CreditCardForm = ({ cancel, saveCard }) => {
3465
3571
  };
3466
3572
 
3467
3573
  // src/components/CreditCardTab/CreditCard/CreditCard.tsx
3468
- var import_jsx_runtime16 = require("react/jsx-runtime");
3574
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3469
3575
  var StripeWrapper = ({ onCancel, saveNewCard, publicKey }) => {
3470
- const stripePromise = (0, import_react9.useMemo)(() => (0, import_stripe_js.loadStripe)(publicKey), [publicKey]);
3471
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard }) });
3576
+ const stripePromise = (0, import_react10.useMemo)(() => (0, import_stripe_js.loadStripe)(publicKey), [publicKey]);
3577
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard }) });
3472
3578
  };
3473
3579
  var CreditCard = ({ newCards, setNewCards }) => {
3474
- const [showForm, setShowForm] = (0, import_react9.useState)(false);
3580
+ const [showForm, setShowForm] = (0, import_react10.useState)(false);
3581
+ const isLoggedIn = useIsLoggedIn();
3475
3582
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
3476
3583
  const { spreePayConfig } = useSpreePayConfig();
3477
3584
  const setCard = (card) => {
@@ -3487,7 +3594,7 @@ var CreditCard = ({ newCards, setNewCards }) => {
3487
3594
  setCard(newCard);
3488
3595
  setShowForm(false);
3489
3596
  };
3490
- const removeNewCard = (0, import_react9.useCallback)(
3597
+ const removeNewCard = (0, import_react10.useCallback)(
3491
3598
  (card) => {
3492
3599
  setNewCards((prev) => prev.filter((c) => c.id !== card.id));
3493
3600
  },
@@ -3504,10 +3611,10 @@ var CreditCard = ({ newCards, setNewCards }) => {
3504
3611
  const handleCancel = () => {
3505
3612
  setShowForm(false);
3506
3613
  };
3507
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
3508
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { className: "text-[22px] leading-9 font-medium text-(--brand-primary)", children: "Your Cards" }),
3509
- !showForm && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3510
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3614
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
3615
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h3", { className: "text-[22px] leading-9 font-medium text-(--brand-primary)", children: "Your Cards" }),
3616
+ !showForm && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3617
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3511
3618
  CardsList,
3512
3619
  {
3513
3620
  selectedCard: selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ ? selectedPaymentMethod.method : null,
@@ -3516,30 +3623,31 @@ var CreditCard = ({ newCards, setNewCards }) => {
3516
3623
  onRemoveNewCard: removeNewCard
3517
3624
  }
3518
3625
  ),
3519
- spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InfoBanner, { message: spreePayConfig.creditCard.infoMessage }),
3520
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3626
+ spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(InfoBanner, { message: spreePayConfig.creditCard.infoMessage }),
3627
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3521
3628
  "button",
3522
3629
  {
3523
3630
  onClick: handleAddNewCard,
3524
- disabled: !spreePayConfig?.stripePublicKey,
3631
+ disabled: !isLoggedIn || !spreePayConfig?.stripePublicKey,
3525
3632
  className: "text-md text-(--brand-primary) hover:underline disabled:cursor-not-allowed disabled:no-underline disabled:opacity-50",
3526
3633
  children: "Add new card"
3527
3634
  }
3528
3635
  )
3529
3636
  ] }),
3530
- spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StripeWrapper, { onCancel: handleCancel, saveNewCard, publicKey: spreePayConfig.stripePublicKey })
3637
+ isLoggedIn && spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(StripeWrapper, { onCancel: handleCancel, saveNewCard, publicKey: spreePayConfig.stripePublicKey })
3531
3638
  ] });
3532
3639
  };
3533
3640
 
3534
3641
  // src/components/CreditCardTab/Points/Points.tsx
3535
- var import_react14 = require("react");
3642
+ var import_react15 = require("react");
3643
+ init_LoginStatusContext();
3536
3644
  init_SpreePayActionsContext();
3537
3645
  init_StaticConfigContext();
3538
3646
  init_useSpreePayConfig();
3539
3647
  init_common();
3540
3648
 
3541
3649
  // src/components/CreditCardTab/Points/SplitBlock.tsx
3542
- var import_react13 = require("react");
3650
+ var import_react14 = require("react");
3543
3651
  var import_airkit2 = require("@mocanetwork/airkit");
3544
3652
  init_SpreePayActionsContext();
3545
3653
  init_StaticConfigContext();
@@ -3549,7 +3657,7 @@ init_format();
3549
3657
  init_logger();
3550
3658
 
3551
3659
  // src/components/CreditCardTab/Points/PointsSelector.tsx
3552
- var import_react12 = require("react");
3660
+ var import_react13 = require("react");
3553
3661
  init_SpreePayActionsContext();
3554
3662
  init_StaticConfigContext();
3555
3663
  init_useSlapiBalance();
@@ -3558,9 +3666,9 @@ init_utils();
3558
3666
 
3559
3667
  // src/ui/input.tsx
3560
3668
  init_utils();
3561
- var import_jsx_runtime17 = require("react/jsx-runtime");
3669
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3562
3670
  function Input({ className, type, ...props }) {
3563
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3671
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3564
3672
  "input",
3565
3673
  {
3566
3674
  type,
@@ -3637,7 +3745,7 @@ function useComposedRefs(...refs) {
3637
3745
 
3638
3746
  // ../../node_modules/@radix-ui/react-context/dist/index.mjs
3639
3747
  var React3 = __toESM(require("react"), 1);
3640
- var import_jsx_runtime18 = require("react/jsx-runtime");
3748
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3641
3749
  function createContextScope(scopeName, createContextScopeDeps = []) {
3642
3750
  let defaultContexts = [];
3643
3751
  function createContext32(rootComponentName, defaultContext) {
@@ -3648,7 +3756,7 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
3648
3756
  const { scope, children, ...context } = props;
3649
3757
  const Context = scope?.[scopeName]?.[index] || BaseContext;
3650
3758
  const value = React3.useMemo(() => context, Object.values(context));
3651
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Context.Provider, { value, children });
3759
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Context.Provider, { value, children });
3652
3760
  };
3653
3761
  Provider.displayName = rootComponentName + "Provider";
3654
3762
  function useContext22(consumerName, scope) {
@@ -3773,7 +3881,7 @@ function isFunction(value) {
3773
3881
 
3774
3882
  // ../../node_modules/@radix-ui/react-direction/dist/index.mjs
3775
3883
  var React6 = __toESM(require("react"), 1);
3776
- var import_jsx_runtime19 = require("react/jsx-runtime");
3884
+ var import_jsx_runtime20 = require("react/jsx-runtime");
3777
3885
  var DirectionContext = React6.createContext(void 0);
3778
3886
  function useDirection(localDir) {
3779
3887
  const globalDir = React6.useContext(DirectionContext);
@@ -3834,7 +3942,7 @@ function useSize(element) {
3834
3942
  var React9 = __toESM(require("react"), 1);
3835
3943
  var ReactDOM = __toESM(require("react-dom"), 1);
3836
3944
  var import_react_slot2 = require("@radix-ui/react-slot");
3837
- var import_jsx_runtime20 = require("react/jsx-runtime");
3945
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3838
3946
  var NODES = [
3839
3947
  "a",
3840
3948
  "button",
@@ -3862,19 +3970,19 @@ var Primitive = NODES.reduce((primitive, node) => {
3862
3970
  if (typeof window !== "undefined") {
3863
3971
  window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
3864
3972
  }
3865
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
3973
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
3866
3974
  });
3867
3975
  Node2.displayName = `Primitive.${node}`;
3868
3976
  return { ...primitive, [node]: Node2 };
3869
3977
  }, {});
3870
3978
 
3871
3979
  // ../../node_modules/@radix-ui/react-collection/dist/index.mjs
3872
- var import_react10 = __toESM(require("react"), 1);
3873
- var import_react_slot3 = require("@radix-ui/react-slot");
3874
- var import_jsx_runtime21 = require("react/jsx-runtime");
3875
3980
  var import_react11 = __toESM(require("react"), 1);
3876
- var import_react_slot4 = require("@radix-ui/react-slot");
3981
+ var import_react_slot3 = require("@radix-ui/react-slot");
3877
3982
  var import_jsx_runtime22 = require("react/jsx-runtime");
3983
+ var import_react12 = __toESM(require("react"), 1);
3984
+ var import_react_slot4 = require("@radix-ui/react-slot");
3985
+ var import_jsx_runtime23 = require("react/jsx-runtime");
3878
3986
  function createCollection(name) {
3879
3987
  const PROVIDER_NAME = name + "CollectionProvider";
3880
3988
  const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
@@ -3884,42 +3992,42 @@ function createCollection(name) {
3884
3992
  );
3885
3993
  const CollectionProvider = (props) => {
3886
3994
  const { scope, children } = props;
3887
- const ref = import_react10.default.useRef(null);
3888
- const itemMap = import_react10.default.useRef(/* @__PURE__ */ new Map()).current;
3889
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
3995
+ const ref = import_react11.default.useRef(null);
3996
+ const itemMap = import_react11.default.useRef(/* @__PURE__ */ new Map()).current;
3997
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
3890
3998
  };
3891
3999
  CollectionProvider.displayName = PROVIDER_NAME;
3892
4000
  const COLLECTION_SLOT_NAME = name + "CollectionSlot";
3893
4001
  const CollectionSlotImpl = (0, import_react_slot3.createSlot)(COLLECTION_SLOT_NAME);
3894
- const CollectionSlot = import_react10.default.forwardRef(
4002
+ const CollectionSlot = import_react11.default.forwardRef(
3895
4003
  (props, forwardedRef) => {
3896
4004
  const { scope, children } = props;
3897
4005
  const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
3898
4006
  const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
3899
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionSlotImpl, { ref: composedRefs, children });
4007
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionSlotImpl, { ref: composedRefs, children });
3900
4008
  }
3901
4009
  );
3902
4010
  CollectionSlot.displayName = COLLECTION_SLOT_NAME;
3903
4011
  const ITEM_SLOT_NAME = name + "CollectionItemSlot";
3904
4012
  const ITEM_DATA_ATTR = "data-radix-collection-item";
3905
4013
  const CollectionItemSlotImpl = (0, import_react_slot3.createSlot)(ITEM_SLOT_NAME);
3906
- const CollectionItemSlot = import_react10.default.forwardRef(
4014
+ const CollectionItemSlot = import_react11.default.forwardRef(
3907
4015
  (props, forwardedRef) => {
3908
4016
  const { scope, children, ...itemData } = props;
3909
- const ref = import_react10.default.useRef(null);
4017
+ const ref = import_react11.default.useRef(null);
3910
4018
  const composedRefs = useComposedRefs(forwardedRef, ref);
3911
4019
  const context = useCollectionContext(ITEM_SLOT_NAME, scope);
3912
- import_react10.default.useEffect(() => {
4020
+ import_react11.default.useEffect(() => {
3913
4021
  context.itemMap.set(ref, { ref, ...itemData });
3914
4022
  return () => void context.itemMap.delete(ref);
3915
4023
  });
3916
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
4024
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
3917
4025
  }
3918
4026
  );
3919
4027
  CollectionItemSlot.displayName = ITEM_SLOT_NAME;
3920
4028
  function useCollection2(scope) {
3921
4029
  const context = useCollectionContext(name + "CollectionConsumer", scope);
3922
- const getItems = import_react10.default.useCallback(() => {
4030
+ const getItems = import_react11.default.useCallback(() => {
3923
4031
  const collectionNode = context.collectionRef.current;
3924
4032
  if (!collectionNode) return [];
3925
4033
  const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
@@ -3939,7 +4047,7 @@ function createCollection(name) {
3939
4047
  }
3940
4048
 
3941
4049
  // ../../node_modules/@radix-ui/react-slider/dist/index.mjs
3942
- var import_jsx_runtime23 = require("react/jsx-runtime");
4050
+ var import_jsx_runtime24 = require("react/jsx-runtime");
3943
4051
  var PAGE_KEYS = ["PageUp", "PageDown"];
3944
4052
  var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
3945
4053
  var BACK_KEYS = {
@@ -4017,7 +4125,7 @@ var Slider = React11.forwardRef(
4017
4125
  }
4018
4126
  });
4019
4127
  }
4020
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4128
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4021
4129
  SliderProvider,
4022
4130
  {
4023
4131
  scope: props.__scopeSlider,
@@ -4030,7 +4138,7 @@ var Slider = React11.forwardRef(
4030
4138
  values,
4031
4139
  orientation,
4032
4140
  form,
4033
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4141
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4034
4142
  SliderOrientation,
4035
4143
  {
4036
4144
  "aria-disabled": disabled,
@@ -4099,7 +4207,7 @@ var SliderHorizontal = React11.forwardRef(
4099
4207
  rectRef.current = rect;
4100
4208
  return value(pointerPosition - rect.left);
4101
4209
  }
4102
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4210
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4103
4211
  SliderOrientationProvider,
4104
4212
  {
4105
4213
  scope: props.__scopeSlider,
@@ -4107,7 +4215,7 @@ var SliderHorizontal = React11.forwardRef(
4107
4215
  endEdge: isSlidingFromLeft ? "right" : "left",
4108
4216
  direction: isSlidingFromLeft ? 1 : -1,
4109
4217
  size: "width",
4110
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4218
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4111
4219
  SliderImpl,
4112
4220
  {
4113
4221
  dir: direction,
@@ -4165,7 +4273,7 @@ var SliderVertical = React11.forwardRef(
4165
4273
  rectRef.current = rect;
4166
4274
  return value(pointerPosition - rect.top);
4167
4275
  }
4168
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4276
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4169
4277
  SliderOrientationProvider,
4170
4278
  {
4171
4279
  scope: props.__scopeSlider,
@@ -4173,7 +4281,7 @@ var SliderVertical = React11.forwardRef(
4173
4281
  endEdge: isSlidingFromBottom ? "top" : "bottom",
4174
4282
  size: "height",
4175
4283
  direction: isSlidingFromBottom ? 1 : -1,
4176
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4284
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4177
4285
  SliderImpl,
4178
4286
  {
4179
4287
  "data-orientation": "vertical",
@@ -4219,7 +4327,7 @@ var SliderImpl = React11.forwardRef(
4219
4327
  ...sliderProps
4220
4328
  } = props;
4221
4329
  const context = useSliderContext(SLIDER_NAME, __scopeSlider);
4222
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4330
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4223
4331
  Primitive.span,
4224
4332
  {
4225
4333
  ...sliderProps,
@@ -4266,7 +4374,7 @@ var SliderTrack = React11.forwardRef(
4266
4374
  (props, forwardedRef) => {
4267
4375
  const { __scopeSlider, ...trackProps } = props;
4268
4376
  const context = useSliderContext(TRACK_NAME, __scopeSlider);
4269
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4377
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4270
4378
  Primitive.span,
4271
4379
  {
4272
4380
  "data-disabled": context.disabled ? "" : void 0,
@@ -4292,7 +4400,7 @@ var SliderRange = React11.forwardRef(
4292
4400
  );
4293
4401
  const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
4294
4402
  const offsetEnd = 100 - Math.max(...percentages);
4295
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4403
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4296
4404
  Primitive.span,
4297
4405
  {
4298
4406
  "data-orientation": context.orientation,
@@ -4319,7 +4427,7 @@ var SliderThumb = React11.forwardRef(
4319
4427
  () => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
4320
4428
  [getItems, thumb]
4321
4429
  );
4322
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index });
4430
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index });
4323
4431
  }
4324
4432
  );
4325
4433
  var SliderThumbImpl = React11.forwardRef(
@@ -4344,7 +4452,7 @@ var SliderThumbImpl = React11.forwardRef(
4344
4452
  };
4345
4453
  }
4346
4454
  }, [thumb, context.thumbs]);
4347
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4455
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
4348
4456
  "span",
4349
4457
  {
4350
4458
  style: {
@@ -4353,7 +4461,7 @@ var SliderThumbImpl = React11.forwardRef(
4353
4461
  [orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
4354
4462
  },
4355
4463
  children: [
4356
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4464
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4357
4465
  Primitive.span,
4358
4466
  {
4359
4467
  role: "slider",
@@ -4373,7 +4481,7 @@ var SliderThumbImpl = React11.forwardRef(
4373
4481
  })
4374
4482
  }
4375
4483
  ) }),
4376
- isFormControl && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4484
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4377
4485
  SliderBubbleInput,
4378
4486
  {
4379
4487
  name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
@@ -4406,7 +4514,7 @@ var SliderBubbleInput = React11.forwardRef(
4406
4514
  input.dispatchEvent(event);
4407
4515
  }
4408
4516
  }, [prevValue, value]);
4409
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4517
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4410
4518
  Primitive.input,
4411
4519
  {
4412
4520
  style: { display: "none" },
@@ -4482,14 +4590,14 @@ var Thumb2 = SliderThumb;
4482
4590
 
4483
4591
  // src/ui/slider.tsx
4484
4592
  init_utils2();
4485
- var import_jsx_runtime24 = require("react/jsx-runtime");
4593
+ var import_jsx_runtime25 = require("react/jsx-runtime");
4486
4594
  function Slider2(props) {
4487
4595
  const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
4488
4596
  const _values = React12.useMemo(
4489
4597
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
4490
4598
  [value, defaultValue, min, max]
4491
4599
  );
4492
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
4600
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4493
4601
  Root5,
4494
4602
  {
4495
4603
  "data-slot": "slider",
@@ -4503,14 +4611,14 @@ function Slider2(props) {
4503
4611
  ),
4504
4612
  ...rest,
4505
4613
  children: [
4506
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4614
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4507
4615
  Track,
4508
4616
  {
4509
4617
  "data-slot": "slider-track",
4510
4618
  className: cn2(
4511
4619
  "relative grow overflow-hidden rounded-full bg-(--primary)/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
4512
4620
  ),
4513
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4621
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4514
4622
  Range,
4515
4623
  {
4516
4624
  "data-slot": "slider-range",
@@ -4521,7 +4629,7 @@ function Slider2(props) {
4521
4629
  )
4522
4630
  }
4523
4631
  ),
4524
- Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4632
+ Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4525
4633
  Thumb2,
4526
4634
  {
4527
4635
  "data-slot": "slider-thumb",
@@ -4538,7 +4646,7 @@ function Slider2(props) {
4538
4646
  init_format();
4539
4647
  init_split();
4540
4648
  init_transactionFee();
4541
- var import_jsx_runtime25 = require("react/jsx-runtime");
4649
+ var import_jsx_runtime26 = require("react/jsx-runtime");
4542
4650
  var PointsSelector = (props) => {
4543
4651
  const { isDisabled, isSelected, onSelect, children } = props;
4544
4652
  const { balance } = useSlapiBalance();
@@ -4552,7 +4660,7 @@ var PointsSelector = (props) => {
4552
4660
  const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (amount ?? 0) / pointsConversionRatio : 0;
4553
4661
  const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
4554
4662
  const step = 10;
4555
- const [splitTokens, setSplitTokens] = (0, import_react12.useState)(0);
4663
+ const [splitTokens, setSplitTokens] = (0, import_react13.useState)(0);
4556
4664
  const usdAmount = getSplitAmount(amount ?? 0, splitTokens, pointsConversionRatio);
4557
4665
  const pointsValue = String(Math.round(splitTokens));
4558
4666
  const usdWithFee = usdAmount + getTransactionFee(usdAmount, transactionFeePercentage);
@@ -4567,7 +4675,7 @@ var PointsSelector = (props) => {
4567
4675
  foreignCurrencyAmount: hasForeignCurrency ? parseFloat((committedUsdWithFee / exchangeRate).toFixed(2)) : void 0
4568
4676
  });
4569
4677
  };
4570
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4678
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
4571
4679
  "button",
4572
4680
  {
4573
4681
  disabled: isDisabled,
@@ -4579,8 +4687,8 @@ var PointsSelector = (props) => {
4579
4687
  }
4580
4688
  ),
4581
4689
  children: [
4582
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex h-11 w-full bg-(--s-primary) hover:bg-(--s-primary-hover)", children: [
4583
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4690
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex h-11 w-full bg-(--s-primary) hover:bg-(--s-primary-hover)", children: [
4691
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4584
4692
  "div",
4585
4693
  {
4586
4694
  className: cn(
@@ -4589,14 +4697,14 @@ var PointsSelector = (props) => {
4589
4697
  "border-(--b-brand)": isSelected
4590
4698
  }
4591
4699
  ),
4592
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
4700
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
4593
4701
  }
4594
4702
  ),
4595
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
4703
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
4596
4704
  ] }),
4597
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "px-2 pt-5 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
4598
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
4599
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4705
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "px-2 pt-5 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
4706
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-1", children: [
4707
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4600
4708
  Input,
4601
4709
  {
4602
4710
  readOnly: true,
@@ -4607,9 +4715,9 @@ var PointsSelector = (props) => {
4607
4715
  onClick: (e) => e.stopPropagation()
4608
4716
  }
4609
4717
  ),
4610
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Points" })
4718
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Points" })
4611
4719
  ] }),
4612
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex w-full items-center pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4720
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex w-full items-center pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4613
4721
  Slider2,
4614
4722
  {
4615
4723
  value: [splitTokens],
@@ -4621,8 +4729,8 @@ var PointsSelector = (props) => {
4621
4729
  step
4622
4730
  }
4623
4731
  ) }),
4624
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
4625
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4732
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-1", children: [
4733
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4626
4734
  Input,
4627
4735
  {
4628
4736
  readOnly: true,
@@ -4633,7 +4741,7 @@ var PointsSelector = (props) => {
4633
4741
  onClick: (e) => e.stopPropagation()
4634
4742
  }
4635
4743
  ),
4636
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Card" })
4744
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Card" })
4637
4745
  ] })
4638
4746
  ] }) })
4639
4747
  ]
@@ -4642,7 +4750,7 @@ var PointsSelector = (props) => {
4642
4750
  };
4643
4751
 
4644
4752
  // src/components/CreditCardTab/Points/SplitBlock.tsx
4645
- var import_jsx_runtime26 = require("react/jsx-runtime");
4753
+ var import_jsx_runtime27 = require("react/jsx-runtime");
4646
4754
  var splitBlockLogger = logger.child("split-block");
4647
4755
  var SplitBlock = (props) => {
4648
4756
  const { onToggle, isSelected, onSelect } = props;
@@ -4650,14 +4758,14 @@ var SplitBlock = (props) => {
4650
4758
  const { spreePayConfig } = useSpreePayConfig();
4651
4759
  const { appProps } = useStaticConfig();
4652
4760
  const { currencyCode, exchangeRate, foreignCurrencyAmount } = appProps;
4653
- const [address, setAddress] = (0, import_react13.useState)(null);
4654
- const [walletReady, setWalletReady] = (0, import_react13.useState)(false);
4761
+ const [address, setAddress] = (0, import_react14.useState)(null);
4762
+ const [walletReady, setWalletReady] = (0, import_react14.useState)(false);
4655
4763
  const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
4656
4764
  const { useWeb3Points, environment } = useSpreePayEnv();
4657
4765
  const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
4658
4766
  const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
4659
- const prevPointsChainRef = (0, import_react13.useRef)(spreePayConfig?.pointsChain);
4660
- const initWallet = (0, import_react13.useCallback)(
4767
+ const prevPointsChainRef = (0, import_react14.useRef)(spreePayConfig?.pointsChain);
4768
+ const initWallet = (0, import_react14.useCallback)(
4661
4769
  async (pointsChain) => {
4662
4770
  if (!pointsChain) return;
4663
4771
  try {
@@ -4680,7 +4788,7 @@ var SplitBlock = (props) => {
4680
4788
  },
4681
4789
  [onToggle, environment]
4682
4790
  );
4683
- (0, import_react13.useEffect)(() => {
4791
+ (0, import_react14.useEffect)(() => {
4684
4792
  if (!useWeb3Points) return;
4685
4793
  const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
4686
4794
  prevPointsChainRef.current = spreePayConfig?.pointsChain;
@@ -4694,24 +4802,25 @@ var SplitBlock = (props) => {
4694
4802
  doInit();
4695
4803
  }, [spreePayConfig?.pointsChain, initWallet, useWeb3Points]);
4696
4804
  const isPointsSelectorDisabled = useWeb3Points ? !walletReady : false;
4697
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
4698
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
4699
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-(--secondary)", children: "Available" }),
4805
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
4806
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
4807
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-(--secondary)", children: "Available" }),
4700
4808
  " ",
4701
4809
  formatPoints(balance.availablePoints, pointsTitle),
4702
4810
  " ",
4703
- pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-(--secondary)", children: formatPointsValue(balance.availablePoints * pointsConversionRatio) })
4811
+ pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-(--secondary)", children: formatPointsValue(balance.availablePoints * pointsConversionRatio) })
4704
4812
  ] }) : null }),
4705
- isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "h-4 w-6 animate-pulse bg-(--s-secondary)" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: "No points available" }),
4706
- address && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-sm font-medium text-(--brand-primary)", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
4813
+ isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "h-4 w-6 animate-pulse bg-(--s-secondary)" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: "No points available" }),
4814
+ address && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-sm font-medium text-(--brand-primary)", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
4707
4815
  ] }) });
4708
4816
  };
4709
4817
 
4710
4818
  // src/components/CreditCardTab/Points/Points.tsx
4711
- var import_jsx_runtime27 = require("react/jsx-runtime");
4819
+ var import_jsx_runtime28 = require("react/jsx-runtime");
4712
4820
  var Points = () => {
4713
- const [usePoints, setUsePoints] = (0, import_react14.useState)(false);
4714
- const [selectedPointsType, setSelectedPointsType] = (0, import_react14.useState)(null);
4821
+ const isLoggedIn = useIsLoggedIn();
4822
+ const [usePoints, setUsePoints] = (0, import_react15.useState)(false);
4823
+ const [selectedPointsType, setSelectedPointsType] = (0, import_react15.useState)(null);
4715
4824
  const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
4716
4825
  const { spreePayConfig } = useSpreePayConfig();
4717
4826
  const { appProps } = useStaticConfig();
@@ -4722,17 +4831,17 @@ var Points = () => {
4722
4831
  setSelectedPaymentMethod({ ...selectedPaymentMethod, pointsAmount: void 0 });
4723
4832
  }
4724
4833
  };
4725
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
4726
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4834
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
4835
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4727
4836
  PointsSwitch,
4728
4837
  {
4729
4838
  value: usePoints,
4730
4839
  onChange: handleTogglePoints,
4731
4840
  message: spreePayConfig?.creditCard.pointsInfoMessage,
4732
- disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
4841
+ disabled: !isLoggedIn || !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
4733
4842
  }
4734
4843
  ),
4735
- usePoints && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4844
+ usePoints && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4736
4845
  SplitBlock,
4737
4846
  {
4738
4847
  onToggle: handleTogglePoints,
@@ -4744,8 +4853,8 @@ var Points = () => {
4744
4853
  };
4745
4854
 
4746
4855
  // src/components/CreditCardTab/CreditCardTab.tsx
4747
- var import_jsx_runtime28 = require("react/jsx-runtime");
4748
- var CreditCardTab = ({ isLoggedIn }) => {
4856
+ var import_jsx_runtime29 = require("react/jsx-runtime");
4857
+ var CreditCardTab = () => {
4749
4858
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
4750
4859
  const { useWeb3Points } = useSpreePayEnv();
4751
4860
  const { appProps } = useStaticConfig();
@@ -4753,30 +4862,30 @@ var CreditCardTab = ({ isLoggedIn }) => {
4753
4862
  const { register } = useSpreePayRegister();
4754
4863
  const { cards, mutateCards } = useCards();
4755
4864
  const { mutateBalance } = useSlapiBalance();
4756
- const [newCards, setNewCards] = (0, import_react15.useState)([]);
4865
+ const [newCards, setNewCards] = (0, import_react16.useState)([]);
4757
4866
  const isWeb3Enabled = Boolean(useWeb3Points);
4758
4867
  const { cardPayment } = useCardPayment();
4759
4868
  const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
4760
4869
  const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
4761
- const handlePay = (0, import_react15.useCallback)(
4870
+ const handlePay = (0, import_react16.useCallback)(
4762
4871
  async (data) => {
4872
+ const pointsAmount = selectedPaymentMethod.pointsAmount ?? 0;
4873
+ const usdAmount = getSplitAmount(appProps.amount ?? 0, pointsAmount, spreePayConfig?.pointsConversionRatio);
4874
+ const isPurePoints = !usdAmount && pointsAmount > 0;
4875
+ const failureMessage = isPurePoints ? "Points payment failed" : "Card payment failed";
4876
+ const failureCode = isPurePoints ? "PAYMENT_ERROR" /* PAYMENT_ERROR */ : "CARD_ERROR" /* CARD_ERROR */;
4763
4877
  try {
4764
- let res = null;
4765
- const pointsAmount = selectedPaymentMethod.pointsAmount ?? 0;
4766
- const usdAmount = getSplitAmount(appProps.amount ?? 0, pointsAmount, spreePayConfig?.pointsConversionRatio);
4878
+ let res;
4767
4879
  if (usdAmount && pointsAmount) {
4768
4880
  res = await splitPayment({ ...data, points: pointsAmount });
4769
- } else if (!usdAmount && pointsAmount) {
4881
+ } else if (isPurePoints) {
4770
4882
  res = await pointsPayment({ ...data, points: pointsAmount });
4771
4883
  } else {
4772
4884
  res = await cardPayment(data);
4773
4885
  }
4774
- if (["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(res.status)) {
4775
- return Promise.resolve(res);
4776
- }
4777
- return Promise.reject(new PaymentError("Card payment failed", res.status));
4778
- } catch (_) {
4779
- return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
4886
+ return settlePaymentResult(res, failureMessage, failureCode);
4887
+ } catch (e) {
4888
+ return Promise.reject(toPaymentError(e, failureMessage, failureCode));
4780
4889
  } finally {
4781
4890
  mutateBalance();
4782
4891
  if (selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method && isNewCard(selectedPaymentMethod.method)) {
@@ -4807,22 +4916,22 @@ var CreditCardTab = ({ isLoggedIn }) => {
4807
4916
  mutateBalance
4808
4917
  ]
4809
4918
  );
4810
- (0, import_react15.useEffect)(() => {
4919
+ (0, import_react16.useEffect)(() => {
4811
4920
  register(handlePay);
4812
4921
  }, [register, handlePay]);
4813
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
4814
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CreditCard, { newCards, setNewCards }) }),
4815
- !spreePayConfig?.creditCard.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Points, {}) }),
4816
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CheckoutButton, { isLoggedIn })
4922
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { children: [
4923
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CreditCard, { newCards, setNewCards }) }),
4924
+ !spreePayConfig?.creditCard.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Points, {}) }),
4925
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CheckoutButton, {})
4817
4926
  ] });
4818
4927
  };
4819
4928
 
4820
4929
  // src/components/TabButtons.tsx
4821
4930
  init_useSpreePayConfig();
4822
4931
  init_utils();
4823
- var import_jsx_runtime29 = require("react/jsx-runtime");
4932
+ var import_jsx_runtime30 = require("react/jsx-runtime");
4824
4933
  var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
4825
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4934
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4826
4935
  "button",
4827
4936
  {
4828
4937
  disabled: isDisabled,
@@ -4845,38 +4954,38 @@ var TabButtons = (props) => {
4845
4954
  onChange({ type, method: null });
4846
4955
  }
4847
4956
  };
4848
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-full gap-4 overflow-x-auto px-5 py-2 md:px-7", children: [
4849
- configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "h-[74px] w-[180px] animate-pulse rounded-md bg-(--s-primary)" }),
4850
- spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
4851
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4957
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full gap-4 overflow-x-auto px-5 py-2 md:px-7", children: [
4958
+ configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "h-[74px] w-[180px] animate-pulse rounded-md bg-(--s-primary)" }),
4959
+ spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
4960
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4852
4961
  "path",
4853
4962
  {
4854
4963
  fill: "currentColor",
4855
4964
  d: "M28 8.82v14.36q0 .92-.62 1.54-.6.6-1.53.61H6.15q-.91 0-1.53-.61A2 2 0 0 1 4 23.18V8.82q0-.92.62-1.54.6-.6 1.53-.61h19.7q.91 0 1.53.61.62.62.62 1.54M5.33 11.74h21.34V8.82q0-.31-.26-.56a.8.8 0 0 0-.56-.26H6.15q-.3 0-.56.26a.8.8 0 0 0-.26.56zm0 3.18v8.26q0 .31.26.56t.56.26h19.7q.3 0 .56-.26a.8.8 0 0 0 .26-.56v-8.26z"
4856
4965
  }
4857
4966
  ) }),
4858
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Card" })
4967
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Card" })
4859
4968
  ] }),
4860
- spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
4861
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4969
+ spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
4970
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4862
4971
  "path",
4863
4972
  {
4864
4973
  fill: "currentColor",
4865
4974
  d: "M21 9.86a8 8 0 0 1 3 5.43l-2.85-.71a5.4 5.4 0 0 0-3.86-3.67 5.3 5.3 0 0 0-6.46 3.8 5.3 5.3 0 0 0 3.91 6.4 5.4 5.4 0 0 0 5.14-1.43l2.85.7a8 8 0 0 1-5.2 3.39L16.72 27l-2.6-.65.64-2.57a8 8 0 0 1-1.3-.32l-.64 2.57-2.6-.65.82-3.24a7.9 7.9 0 0 1-2.8-8.08 7.9 7.9 0 0 1 6.27-5.82L15.32 5l2.6.64-.65 2.58q.67.1 1.3.32l.65-2.57 2.6.64z"
4866
4975
  }
4867
4976
  ) }),
4868
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto" })
4977
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto" })
4869
4978
  ] }),
4870
- spreePayConfig?.cryptoCom.enabled && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(TabButton, { onClick: handleChange("CDC" /* CDC */), isActive: value === "CDC" /* CDC */, children: [
4871
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-8 w-11", viewBox: "0 0 44 32", children: [
4872
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4979
+ spreePayConfig?.cryptoCom.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CDC" /* CDC */), isActive: value === "CDC" /* CDC */, children: [
4980
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-8 w-11", viewBox: "0 0 44 32", children: [
4981
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4873
4982
  "path",
4874
4983
  {
4875
4984
  fill: "currentColor",
4876
4985
  d: "M17.6 11v10l-8.8 5L0 21V11l8.8-5zM2.2 16.69l3.15 5.42h1.26l1.5-1.37v-.7L6.56 18.6v-2.32L4.51 15zm8.87-.42v2.32l-1.55 1.46v.69l1.5 1.35h1.24l3.15-5.4-2.32-1.72zm-4.5-1.95.75 1.95-.23 2.17H8.8l1.72-.01-.21-2.17.74-1.94zm-1.25-4-.8 3.48h8.56l-.83-3.47z"
4877
4986
  }
4878
4987
  ),
4879
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4988
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4880
4989
  "path",
4881
4990
  {
4882
4991
  fill: "#009fff",
@@ -4884,43 +4993,50 @@ var TabButtons = (props) => {
4884
4993
  }
4885
4994
  )
4886
4995
  ] }),
4887
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto.com Pay" })
4996
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto.com Pay" })
4888
4997
  ] })
4889
4998
  ] });
4890
4999
  };
4891
5000
 
4892
5001
  // src/SpreePayContent.tsx
5002
+ init_LoginStatusContext();
4893
5003
  init_SpreePayActionsContext();
4894
- var import_jsx_runtime45 = require("react/jsx-runtime");
4895
- var CryptoTab2 = (0, import_react20.lazy)(() => Promise.resolve().then(() => (init_CryptoTab2(), CryptoTab_exports)).then((module2) => ({ default: module2.CryptoTab })));
4896
- var CryptoComTab2 = (0, import_react20.lazy)(
5004
+ var import_jsx_runtime46 = require("react/jsx-runtime");
5005
+ var CryptoTab2 = (0, import_react21.lazy)(() => Promise.resolve().then(() => (init_CryptoTab2(), CryptoTab_exports)).then((module2) => ({ default: module2.CryptoTab })));
5006
+ var CryptoComTab2 = (0, import_react21.lazy)(
4897
5007
  () => Promise.resolve().then(() => (init_CryptoComTab2(), CryptoComTab_exports)).then((module2) => ({ default: module2.CryptoComTab }))
4898
5008
  );
4899
- var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
4900
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-(--border-component-specific-card) border-t-(--brand-primary)" }),
4901
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-sm text-(--text-tertiary)", children: "Loading payment method..." })
5009
+ var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
5010
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-(--border-component-specific-card) border-t-(--brand-primary)" }),
5011
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-sm text-(--text-tertiary)", children: "Loading payment method..." })
4902
5012
  ] }) });
4903
- var SpreePayContent = ({ isLoggedIn }) => {
5013
+ var SpreePayContent = () => {
5014
+ const isLoggedIn = useIsLoggedIn();
4904
5015
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
4905
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "w-full overflow-hidden rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
4906
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full flex-col gap-2 border-b border-b-(--border-component-specific-card) pt-5 pb-3 md:pt-6 md:pb-5", children: [
4907
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", { className: "px-5 text-[28px] leading-8 font-medium text-(--brand-primary) md:px-7", children: "Choose a payment method" }),
4908
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
5016
+ (0, import_react21.useEffect)(() => {
5017
+ if (!isLoggedIn) {
5018
+ setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
5019
+ }
5020
+ }, [isLoggedIn, setSelectedPaymentMethod]);
5021
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "w-full overflow-hidden rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
5022
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col gap-2 border-b border-b-(--border-component-specific-card) pt-5 pb-3 md:pt-6 md:pb-5", children: [
5023
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { className: "px-5 text-[28px] leading-8 font-medium text-(--brand-primary) md:px-7", children: "Choose a payment method" }),
5024
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
4909
5025
  ] }),
4910
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CreditCardTab, { isLoggedIn }),
4911
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react20.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(TabLoadingFallback, {}), children: [
4912
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoTab2, { isLoggedIn }),
4913
- selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoComTab2, {})
5026
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CreditCardTab, {}),
5027
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react21.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabLoadingFallback, {}), children: [
5028
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoTab2, {}),
5029
+ selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoComTab2, {})
4914
5030
  ] })
4915
5031
  ] });
4916
5032
  };
4917
5033
 
4918
5034
  // src/components/ErrorBoundary.tsx
4919
- var import_react21 = require("react");
5035
+ var import_react22 = require("react");
4920
5036
  init_utils();
4921
5037
  init_logger();
4922
- var import_jsx_runtime46 = require("react/jsx-runtime");
4923
- var ErrorBoundary = class extends import_react21.Component {
5038
+ var import_jsx_runtime47 = require("react/jsx-runtime");
5039
+ var ErrorBoundary = class extends import_react22.Component {
4924
5040
  constructor(props) {
4925
5041
  super(props);
4926
5042
  this.state = { hasError: false, error: null };
@@ -4938,8 +5054,8 @@ var ErrorBoundary = class extends import_react21.Component {
4938
5054
  if (this.props.fallback) {
4939
5055
  return this.props.fallback;
4940
5056
  }
4941
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: cn("sl-spreepay", this.props.className), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col items-center justify-center rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) p-8 shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
4942
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "mb-4 flex size-12 items-center justify-center rounded-full bg-(--s-warning-subtle)", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5057
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: cn("sl-spreepay", this.props.className), children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex w-full flex-col items-center justify-center rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) p-8 shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
5058
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "mb-4 flex size-12 items-center justify-center rounded-full bg-(--s-warning-subtle)", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
4943
5059
  "svg",
4944
5060
  {
4945
5061
  xmlns: "http://www.w3.org/2000/svg",
@@ -4951,14 +5067,14 @@ var ErrorBoundary = class extends import_react21.Component {
4951
5067
  strokeLinejoin: "round",
4952
5068
  className: "size-10 text-(--warning)",
4953
5069
  children: [
4954
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
4955
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
4956
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
5070
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
5071
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
5072
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
4957
5073
  ]
4958
5074
  }
4959
5075
  ) }),
4960
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h3", { className: "mb-2 text-lg font-semibold text-(--brand-primary)", children: "Payment Widget Error" }),
4961
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-center text-sm text-(--text-tertiary)", children: "Something went wrong loading the payment widget. Please refresh the page and try again." })
5076
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("h3", { className: "mb-2 text-lg font-semibold text-(--brand-primary)", children: "Payment Widget Error" }),
5077
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "text-center text-sm text-(--text-tertiary)", children: "Something went wrong loading the payment widget. Please refresh the page and try again." })
4962
5078
  ] }) });
4963
5079
  }
4964
5080
  return this.props.children;
@@ -4966,27 +5082,28 @@ var ErrorBoundary = class extends import_react21.Component {
4966
5082
  };
4967
5083
 
4968
5084
  // src/SpreePay.tsx
5085
+ init_LoginStatusContext();
4969
5086
  init_SpreePayActionsContext();
4970
5087
  init_StaticConfigContext();
4971
5088
  init_client();
4972
5089
 
4973
5090
  // src/hooks/useKeycloakSSO.ts
4974
- var import_react22 = require("react");
5091
+ var import_react23 = require("react");
4975
5092
  var import_keycloak_js = __toESM(require("keycloak-js"), 1);
4976
5093
  init_logger();
4977
5094
  var refreshAheadSeconds = 60;
4978
5095
  var keycloakLogger = logger.child("keycloak");
4979
5096
  function useKeycloakSSO(config2) {
4980
5097
  const { url, realm, clientId, ssoPageURI, enabled } = config2;
4981
- const initRef = (0, import_react22.useRef)(false);
4982
- const kcRef = (0, import_react22.useRef)(null);
4983
- const refreshTimerRef = (0, import_react22.useRef)(null);
4984
- const scheduleRefreshRef = (0, import_react22.useRef)(() => {
5098
+ const initRef = (0, import_react23.useRef)(false);
5099
+ const kcRef = (0, import_react23.useRef)(null);
5100
+ const refreshTimerRef = (0, import_react23.useRef)(null);
5101
+ const scheduleRefreshRef = (0, import_react23.useRef)(() => {
4985
5102
  });
4986
- const [error, setError] = (0, import_react22.useState)(null);
4987
- const [isChecking, setIsChecking] = (0, import_react22.useState)(enabled);
4988
- const [accessToken, setAccessToken] = (0, import_react22.useState)(null);
4989
- const scheduleRefresh = (0, import_react22.useCallback)(() => {
5103
+ const [error, setError] = (0, import_react23.useState)(null);
5104
+ const [isChecking, setIsChecking] = (0, import_react23.useState)(enabled);
5105
+ const [accessToken, setAccessToken] = (0, import_react23.useState)(null);
5106
+ const scheduleRefresh = (0, import_react23.useCallback)(() => {
4990
5107
  const kc = kcRef.current;
4991
5108
  if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
4992
5109
  return;
@@ -5010,10 +5127,10 @@ function useKeycloakSSO(config2) {
5010
5127
  });
5011
5128
  }, delayMs);
5012
5129
  }, []);
5013
- (0, import_react22.useEffect)(() => {
5130
+ (0, import_react23.useEffect)(() => {
5014
5131
  scheduleRefreshRef.current = scheduleRefresh;
5015
5132
  }, [scheduleRefresh]);
5016
- (0, import_react22.useEffect)(() => {
5133
+ (0, import_react23.useEffect)(() => {
5017
5134
  if (initRef.current || !enabled) return;
5018
5135
  initRef.current = true;
5019
5136
  const kc = new import_keycloak_js.default({ url, realm, clientId });
@@ -5063,16 +5180,17 @@ var isTokenExpired = (token) => {
5063
5180
  };
5064
5181
 
5065
5182
  // src/SpreePay.tsx
5066
- var import_jsx_runtime47 = require("react/jsx-runtime");
5183
+ var import_jsx_runtime48 = require("react/jsx-runtime");
5184
+ var unauthenticatedFetcher = () => Promise.resolve(null);
5067
5185
  var SpreePayInner = () => {
5068
- const [portalEl, setPortalEl] = (0, import_react23.useState)(null);
5069
- const rootRef = (0, import_react23.useCallback)((node) => {
5186
+ const [portalEl, setPortalEl] = (0, import_react24.useState)(null);
5187
+ const rootRef = (0, import_react24.useCallback)((node) => {
5070
5188
  if (!node) return;
5071
5189
  const el = node.querySelector(":scope > .sl-spreepay__portal");
5072
5190
  setPortalEl(el ?? null);
5073
5191
  }, []);
5074
5192
  const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
5075
- (0, import_react23.useEffect)(() => {
5193
+ (0, import_react24.useEffect)(() => {
5076
5194
  configureLogger({ environment });
5077
5195
  logger.logVersion();
5078
5196
  }, [environment]);
@@ -5086,8 +5204,7 @@ var SpreePayInner = () => {
5086
5204
  enabled: !envTokenValid
5087
5205
  });
5088
5206
  const _accessToken = envTokenValid ? envAccessToken : accessToken;
5089
- const unauthenticatedFetcher = (0, import_react23.useCallback)(() => Promise.resolve(null), []);
5090
- const slapiFetcher = (0, import_react23.useMemo)(() => {
5207
+ const slapiFetcher = (0, import_react24.useMemo)(() => {
5091
5208
  if (_accessToken) {
5092
5209
  return registerApi({
5093
5210
  accessToken: _accessToken,
@@ -5096,15 +5213,15 @@ var SpreePayInner = () => {
5096
5213
  });
5097
5214
  }
5098
5215
  return unauthenticatedFetcher;
5099
- }, [_accessToken, staticConfig, tenantId, unauthenticatedFetcher]);
5216
+ }, [_accessToken, staticConfig, tenantId]);
5100
5217
  const getContent = () => {
5101
5218
  if (isChecking) {
5102
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex w-full flex-col", children: [
5103
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "mb-4 h-[315px] animate-pulse rounded-3xl bg-(--s-primary)" }),
5104
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "h-[135px] animate-pulse rounded-3xl bg-(--s-primary)" })
5219
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex w-full flex-col", children: [
5220
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "mb-4 h-[315px] animate-pulse rounded-3xl bg-(--s-primary)" }),
5221
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "h-[135px] animate-pulse rounded-3xl bg-(--s-primary)" })
5105
5222
  ] });
5106
5223
  }
5107
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
5224
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5108
5225
  import_swr5.SWRConfig,
5109
5226
  {
5110
5227
  value: {
@@ -5113,40 +5230,46 @@ var SpreePayInner = () => {
5113
5230
  revalidateOnFocus: false,
5114
5231
  revalidateIfStale: false
5115
5232
  },
5116
- children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_nice_modal_react9.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
5233
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_nice_modal_react9.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(LoginStatusProvider, { isLoggedIn: Boolean(_accessToken), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SpreePayContent, {}) }) }) })
5117
5234
  }
5118
5235
  );
5119
5236
  };
5120
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
5121
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "sl-spreepay__portal" }),
5237
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
5238
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "sl-spreepay__portal" }),
5122
5239
  getContent()
5123
5240
  ] });
5124
5241
  };
5125
5242
  var SpreePay = (props) => {
5126
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ErrorBoundary, { className: props.className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SpreePayInner, {}) }) });
5243
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ErrorBoundary, { className: props.className, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SpreePayInner, {}) }) });
5127
5244
  };
5128
5245
 
5129
5246
  // src/hooks/useCapture3DS.ts
5130
- var import_react24 = require("react");
5131
- var useCapture3DS = (searchParams) => {
5132
- (0, import_react24.useEffect)(() => {
5133
- if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
5134
- window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
5247
+ var import_react25 = require("react");
5248
+ var useCapture3DS = ({ paymentIntent }) => {
5249
+ (0, import_react25.useEffect)(() => {
5250
+ if (typeof window !== "undefined" && window.parent && paymentIntent) {
5251
+ window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent });
5135
5252
  }
5136
- }, [searchParams]);
5253
+ }, [paymentIntent]);
5137
5254
  };
5138
5255
 
5139
5256
  // src/index.ts
5140
5257
  init_SpreePayActionsContext();
5141
5258
  init_payments();
5259
+ init_errors();
5142
5260
  init_logger();
5143
5261
  // Annotate the CommonJS export names for ESM import in node:
5144
5262
  0 && (module.exports = {
5145
5263
  LogLevel,
5264
+ PaymentError,
5265
+ PaymentErrorCode,
5266
+ PaymentStatus,
5146
5267
  PaymentType,
5147
5268
  SpreePay,
5269
+ SpreePayHttpError,
5148
5270
  SpreePayProvider,
5149
5271
  configureLogger,
5272
+ isPaymentError,
5150
5273
  logger,
5151
5274
  useCapture3DS,
5152
5275
  useSpreePay