bitsnap-react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,2043 @@
1
+ import "./chunk-ZD7AOCMD.mjs";
2
+
3
+ // src/components/checkout/ApplePay.tsx
4
+ import ApplePayButton from "apple-pay-button";
5
+
6
+ // src/public.api.client.ts
7
+ import { createClient } from "@connectrpc/connect";
8
+ import { createConnectTransport } from "@connectrpc/connect-web";
9
+
10
+ // src/gen/proto/public/v1/public_api_pb.ts
11
+ import { enumDesc as enumDesc4, fileDesc as fileDesc5, messageDesc as messageDesc4, serviceDesc as serviceDesc2 } from "@bufbuild/protobuf/codegenv2";
12
+ import { file_google_protobuf_empty as file_google_protobuf_empty2, file_google_protobuf_timestamp as file_google_protobuf_timestamp3 } from "@bufbuild/protobuf/wkt";
13
+
14
+ // src/gen/proto/common/v1/gateway_pb.ts
15
+ import { enumDesc, fileDesc } from "@bufbuild/protobuf/codegenv2";
16
+ var file_common_v1_gateway = /* @__PURE__ */ fileDesc("Chdjb21tb24vdjEvZ2F0ZXdheS5wcm90bxIJY29tbW9uLnYxKrMBCgdHYXRld2F5Eg8KC0dBVEVXQVlfQUxMEAASFwoTR0FURVdBWV9QUlpFTEVXWV8yNBABEhIKDkdBVEVXQVlfU1RSSVBFEAISEAoMR0FURVdBWV9UUEFZEAMSHAoYR0FURVdBWV9DQVNIX09OX0RFTElWRVJZEAQSEAoMR0FURVdBWV9GUkVFEAUSFgoSR0FURVdBWV9JTlBPU1RfUEFZEAYSEAoMR0FURVdBWV9QQVlVEAdCTlpMZ2l0aHViLmNvbS9lbW1lbXMvc3VwZXItY2FydC9hcHBzL3Nydi13b3JrZXIvdXRpbHMvbW9kZWxzL2NvbW1vbi92MTtjb21tb252MWIGcHJvdG8z");
17
+
18
+ // src/gen/proto/common/v1/address_pb.ts
19
+ import { fileDesc as fileDesc2, messageDesc } from "@bufbuild/protobuf/codegenv2";
20
+ var file_common_v1_address = /* @__PURE__ */ fileDesc2("Chdjb21tb24vdjEvYWRkcmVzcy5wcm90bxIJY29tbW9uLnYxIocBCgdBZGRyZXNzEgwKBG5hbWUYASABKAkSDQoFbGluZTEYAiABKAkSEgoFbGluZTIYAyABKAlIAIgBARIMCgRjaXR5GAQgASgJEg8KB2NvdW50cnkYBSABKAkSFQoIemlwX2NvZGUYBiABKAlIAYgBAUIICgZfbGluZTJCCwoJX3ppcF9jb2RlIq4BCg5CaWxsaW5nQWRkcmVzcxIMCgRuYW1lGAEgASgJEg0KBWxpbmUxGAIgASgJEhIKBWxpbmUyGAMgASgJSACIAQESDAoEY2l0eRgEIAEoCRIPCgdjb3VudHJ5GAUgASgJEhUKCHppcF9jb2RlGAYgASgJSAGIAQESEwoGdGF4X2lkGAcgASgJSAKIAQFCCAoGX2xpbmUyQgsKCV96aXBfY29kZUIJCgdfdGF4X2lkQk5aTGdpdGh1Yi5jb20vZW1tZW1zL3N1cGVyLWNhcnQvYXBwcy9zcnYtd29ya2VyL3V0aWxzL21vZGVscy9jb21tb24vdjE7Y29tbW9udjFiBnByb3RvMw");
21
+ var AddressSchema = /* @__PURE__ */ messageDesc(file_common_v1_address, 0);
22
+ var BillingAddressSchema = /* @__PURE__ */ messageDesc(file_common_v1_address, 1);
23
+
24
+ // src/gen/proto/common/v1/push_notifications_pb.ts
25
+ import { enumDesc as enumDesc2, fileDesc as fileDesc3, messageDesc as messageDesc2 } from "@bufbuild/protobuf/codegenv2";
26
+ import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
27
+ var file_common_v1_push_notifications = /* @__PURE__ */ fileDesc3("CiJjb21tb24vdjEvcHVzaF9ub3RpZmljYXRpb25zLnByb3RvEgljb21tb24udjEi9gEKG1B1c2hOb3RpZmljYXRpb25EZXZpY2VUb2tlbhIXCgpwdXNoX3Rva2VuGAIgASgJSACIAQESNAoLZXhwaXJlX3RpbWUYAyABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wSAGIAQESEwoGcDI1NmRoGAQgASgJSAKIAQESFQoIZW5kcG9pbnQYBSABKAlIA4gBARIlCghwbGF0Zm9ybRgGIAEoDjITLmNvbW1vbi52MS5QbGF0Zm9ybUINCgtfcHVzaF90b2tlbkIOCgxfZXhwaXJlX3RpbWVCCQoHX3AyNTZkaEILCglfZW5kcG9pbnQiZwoXUHVzaE5vdGlmaWNhdGlvblBheWxvYWQSDQoFdGl0bGUYAiABKAkSFQoIb3Blbl91cmwYAyABKAlIAYgBARIOCgRib2R5GAQgASgJSABCCQoHbWVzc2FnZUILCglfb3Blbl91cmwqeAoIUGxhdGZvcm0SGAoUUExBVEZPUk1fVU5TUEVDSUZJRUQQABIQCgxQTEFURk9STV9XRUIQARIYChRQTEFURk9STV9JT1NfU0FOREJPWBACEhAKDFBMQVRGT1JNX0lPUxADEhQKEFBMQVRGT1JNX0FORFJPSUQQBCp0ChFOb3RpZmljYXRpb25FdmVudBIRCg1FVkVOVF9VTktOT1dOEAASEgoORVZFTlRfUkVDRUlWRUQQARIQCgxFVkVOVF9PUEVORUQQAhIRCg1FVkVOVF9DTElDS0VEEAMSEwoPRVZFTlRfRElTTUlTU0VEEAQqmQEKGU5vdGlmaWNhdGlvbkdyb3VwSG93T2Z0ZW4SJwojTk9USUZJQ0FUSU9OX0dST1VQX0hPV19PRlRFTl9SQVJFTFkQABImCiJOT1RJRklDQVRJT05fR1JPVVBfSE9XX09GVEVOX09GVEVOEAESKwonTk9USUZJQ0FUSU9OX0dST1VQX0hPV19PRlRFTl9WRVJZX09GVEVOEAJCTlpMZ2l0aHViLmNvbS9lbW1lbXMvc3VwZXItY2FydC9hcHBzL3Nydi13b3JrZXIvdXRpbHMvbW9kZWxzL2NvbW1vbi92MTtjb21tb252MWIGcHJvdG8z", [file_google_protobuf_timestamp]);
28
+
29
+ // src/gen/proto/dashboard/v1/audiobooks_pb.ts
30
+ import { enumDesc as enumDesc3, fileDesc as fileDesc4, messageDesc as messageDesc3, serviceDesc } from "@bufbuild/protobuf/codegenv2";
31
+ import { file_google_protobuf_empty, file_google_protobuf_timestamp as file_google_protobuf_timestamp2 } from "@bufbuild/protobuf/wkt";
32
+ var file_dashboard_v1_audiobooks = /* @__PURE__ */ fileDesc4("Ch1kYXNoYm9hcmQvdjEvYXVkaW9ib29rcy5wcm90bxIXZGFzaGJvYXJkLmF1ZGlvYm9va3MudjEiFgoUR2V0QXVkaW9ib29rc1JlcXVlc3QiIQoTR2V0QXVkaW9ib29rUmVxdWVzdBIKCgJpZBgBIAEoCSKrAQoHQ2hhcHRlchIKCgJpZBgBIAEoCRIMCgRuYW1lGAIgASgJEhgKC2Rlc2NyaXB0aW9uGAMgASgJSACIAQESGgoNbXVsdGltZWRpYV9pZBgEIAEoCUgBiAEBEi4KCmNyZWF0ZWRfYXQYBSABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wQg4KDF9kZXNjcmlwdGlvbkIQCg5fbXVsdGltZWRpYV9pZCLzAgoJQXVkaW9ib29rEg8KAmlkGAEgASgJSACIAQESEgoKcHJvamVjdF9pZBgCIAEoCRIMCgRuYW1lGAMgASgJEhMKC2Rlc2NyaXB0aW9uGAQgASgJEhMKC2NvdmVyX2ltYWdlGAUgASgJEhcKD3RodW1ibmFpbF9pbWFnZRgGIAEoCRIyCghjaGFwdGVycxgHIAMoCzIgLmRhc2hib2FyZC5hdWRpb2Jvb2tzLnYxLkNoYXB0ZXISFwoPaXNfZG93bmxvYWRhYmxlGAggASgIEi4KCmNyZWF0ZWRfYXQYCSABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEiQKF2lzX2Jyb3dzZXJfZG93bmxvYWRhYmxlGAogASgISAGIAQESGQoMYWNjZW50X2NvbG9yGAsgASgJSAKIAQFCBQoDX2lkQhoKGF9pc19icm93c2VyX2Rvd25sb2FkYWJsZUIPCg1fYWNjZW50X2NvbG9yIk8KFUdldEF1ZGlvYm9va3NSZXNwb25zZRI2CgphdWRpb2Jvb2tz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WNfYXBpLnYxLkFwcGxlUGF5VmFsaWRhdGVNZXJjaGFudFJlc3BvbnNlEnsKGEF1dGhvcml6ZU9uZUNsaWNrUGF5bWVudBIuLnB1YmxpY19hcGkudjEuT25lQ2xpY2tBdXRob3JpemVQYXltZW50UmVxdWVzdBovLnB1YmxpY19hcGkudjEuT25lQ2xpY2tBdXRob3JpemVQYXltZW50UmVzcG9uc2USdgoiTm90aWZ5VXNlckFib3V0UHJvZHVjdEF2YWlsYWJpbGl0eRI4LnB1YmxpY19hcGkudjEuTm90aWZ5VXNlckFib3V0UHJvZHVjdEF2YWlsYWJpbGl0eVJlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHliBnByb3RvMw", [file_google_protobuf_timestamp3, file_common_v1_gateway, file_common_v1_address, file_common_v1_push_notifications, file_google_protobuf_empty2, file_dashboard_v1_audiobooks]);
36
+ var PreOrderItemSchema = /* @__PURE__ */ messageDesc4(file_public_v1_public_api, 4);
37
+ var GetPreOrderDetailsRequestSchema = /* @__PURE__ */ messageDesc4(file_public_v1_public_api, 5);
38
+ var PublicApiService = /* @__PURE__ */ serviceDesc2(file_public_v1_public_api, 0);
39
+
40
+ // src/public.api.client.ts
41
+ var PublicApiClient;
42
+ ((PublicApiClient2) => {
43
+ function get(host) {
44
+ return createClient(PublicApiService, getTransport(host));
45
+ }
46
+ PublicApiClient2.get = get;
47
+ let transport;
48
+ function getTransport(host) {
49
+ if (transport == null) {
50
+ transport = createConnectTransport({
51
+ useBinaryFormat: true,
52
+ baseUrl: host + "/api/rpc"
53
+ });
54
+ }
55
+ return transport;
56
+ }
57
+ })(PublicApiClient || (PublicApiClient = {}));
58
+
59
+ // src/components/checkout/CartProvider.tsx
60
+ import { create as create2 } from "@bufbuild/protobuf";
61
+ import { createContext, useContext } from "react";
62
+ import { QueryClient, QueryClientProvider } from "react-query";
63
+ import zod from "zod";
64
+
65
+ // src/components/checkout/constants.ts
66
+ var HOST = "https://bitsnap.pl";
67
+ function setCustomHost(host) {
68
+ HOST = host;
69
+ }
70
+
71
+ // src/components/checkout/helper.methods.ts
72
+ function buildURL(projectID, path) {
73
+ return `${HOST}/api/integrations/${projectID}/public-commerce${path}`;
74
+ }
75
+
76
+ // src/components/checkout/lib/err.ts
77
+ function isErr(x) {
78
+ return typeof x === "object" && x != null && "ERR" in x;
79
+ }
80
+ function Err(message, type) {
81
+ return { ERR: true, error: message, type };
82
+ }
83
+
84
+ // src/components/checkout/lib/round.number.ts
85
+ function round(num, numberOfDecimals = 2) {
86
+ return Number(
87
+ +(Math.round(Number(num + "e+" + numberOfDecimals)) + "e-" + numberOfDecimals)
88
+ );
89
+ }
90
+ function formatCurrency(amount, currency) {
91
+ const formatter = Intl.NumberFormat(navigator.language, {
92
+ style: "currency",
93
+ currency,
94
+ currencyDisplay: "symbol"
95
+ });
96
+ return formatter.format(amount / 100);
97
+ }
98
+
99
+ // src/components/checkout/state.ts
100
+ import { create } from "zustand";
101
+ var useCheckoutStore = create((set) => ({
102
+ isCartVisible: false,
103
+ numberOfProductsInCart: 2,
104
+ showCart: () => set((state) => ({ ...state, isCartVisible: true })),
105
+ hideCart: () => set((state) => ({ ...state, isCartVisible: false })),
106
+ setNumberOfProductsInCart: (numberOfProductsInCart) => set((state) => ({ ...state, numberOfProductsInCart }))
107
+ }));
108
+
109
+ // src/components/checkout/methods.ts
110
+ var Bitsnap;
111
+ ((Bitsnap2) => {
112
+ async function addProductToCart(id, quantity = 1, metadata) {
113
+ const projectID = getProjectID();
114
+ if (projectID == null) {
115
+ throw new Error("No project ID found");
116
+ }
117
+ const methods = getCheckoutMethods(projectID);
118
+ const err = await methods.addProduct({
119
+ productID: id,
120
+ quantity,
121
+ metadata
122
+ });
123
+ if (err != null) {
124
+ return err;
125
+ }
126
+ return void 0;
127
+ }
128
+ Bitsnap2.addProductToCart = addProductToCart;
129
+ function showCart() {
130
+ useCheckoutStore.setState({ isCartVisible: true });
131
+ }
132
+ Bitsnap2.showCart = showCart;
133
+ function hideCart() {
134
+ useCheckoutStore.setState({ isCartVisible: false });
135
+ }
136
+ Bitsnap2.hideCart = hideCart;
137
+ })(Bitsnap || (Bitsnap = {}));
138
+ async function createPaymentURL(request) {
139
+ const projectID = getProjectID();
140
+ if (projectID == null) {
141
+ throw new Error("No project ID found");
142
+ }
143
+ request = injectReferenceToRequestIfNeeded(request);
144
+ const result = await fetch(buildURL(projectID, "/buy"), {
145
+ method: "POST",
146
+ headers: {
147
+ "Content-Type": "application/json"
148
+ },
149
+ body: JSON.stringify(request)
150
+ });
151
+ if (result.status != 200) {
152
+ console.warn(
153
+ "result",
154
+ await result.text(),
155
+ result.status,
156
+ result.statusText
157
+ );
158
+ return Err("internal-error", "internal");
159
+ }
160
+ const response = await result.json();
161
+ return {
162
+ url: response.url
163
+ };
164
+ }
165
+ async function createCheckout(request) {
166
+ const projectID = getProjectID();
167
+ if (projectID == null) {
168
+ throw new Error("No project ID found");
169
+ }
170
+ const headers = {
171
+ "Content-Type": "application/json",
172
+ ...request.apiKey != null ? { Authorization: `Bearer ${request.apiKey}` } : {}
173
+ };
174
+ const path = request.testMode ? `/api/payment/link/auto/${projectID}/test` : `/api/payment/link/auto/${projectID}`;
175
+ delete request.apiKey;
176
+ delete request.testMode;
177
+ const response = await fetch(HOST + path, {
178
+ method: "POST",
179
+ headers,
180
+ body: JSON.stringify(request)
181
+ });
182
+ const payload = await response.json();
183
+ return {
184
+ status: "ok",
185
+ redirectURL: payload.url
186
+ };
187
+ }
188
+ function getReferenceIfPossible() {
189
+ if (typeof localStorage == "undefined") {
190
+ return void 0;
191
+ }
192
+ const refLink = localStorage.getItem("bitsnap-ref");
193
+ if (refLink == null) {
194
+ return void 0;
195
+ }
196
+ return refLink;
197
+ }
198
+ function injectReferenceToRequestIfNeeded(request) {
199
+ const ref = getReferenceIfPossible();
200
+ if (ref == null) {
201
+ return request;
202
+ }
203
+ if (request.metadata == null) {
204
+ request.metadata = {};
205
+ }
206
+ request.metadata["ref"] = ref;
207
+ return request;
208
+ }
209
+
210
+ // src/components/checkout/google.pay.mapper.ts
211
+ function mapGooglePayConfiguration(args) {
212
+ var _a;
213
+ const { items, googlePayConfig, checkout, result, cartRequiresShipping } = args;
214
+ if (result.totalAmount == null) {
215
+ return void 0;
216
+ }
217
+ let intents = [];
218
+ if (cartRequiresShipping) {
219
+ intents.push("SHIPPING_ADDRESS");
220
+ intents.push("SHIPPING_OPTION");
221
+ }
222
+ const returnValue = {
223
+ apiVersion: 2,
224
+ apiVersionMinor: 0,
225
+ callbackIntents: intents,
226
+ allowedPaymentMethods: [
227
+ {
228
+ type: "CARD",
229
+ parameters: {
230
+ allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
231
+ allowedCardNetworks: ["MASTERCARD", "VISA"]
232
+ },
233
+ tokenizationSpecification: {
234
+ type: "PAYMENT_GATEWAY",
235
+ parameters: {
236
+ gateway: googlePayConfig.gateway,
237
+ gatewayMerchantId: googlePayConfig.gatewayId
238
+ }
239
+ }
240
+ }
241
+ ],
242
+ emailRequired: true,
243
+ shippingAddressParameters: {
244
+ phoneNumberRequired: cartRequiresShipping
245
+ },
246
+ shippingAddressRequired: cartRequiresShipping,
247
+ shippingOptionRequired: cartRequiresShipping,
248
+ shippingOptionParameters: cartRequiresShipping ? {
249
+ shippingOptions: result.methods.slice(0, 5).map((method) => {
250
+ var _a2;
251
+ return {
252
+ id: method.id,
253
+ label: method.name + ` - ${formatCurrency(method.amount, result.currency)}`,
254
+ description: (_a2 = method.description) != null ? _a2 : ""
255
+ };
256
+ }),
257
+ defaultSelectedOptionId: result.selectedDeliveryMethod
258
+ } : void 0,
259
+ merchantInfo: {
260
+ merchantId: googlePayConfig.merchantId + "",
261
+ merchantName: googlePayConfig.merchantName
262
+ },
263
+ transactionInfo: {
264
+ totalPriceStatus: "FINAL",
265
+ totalPriceLabel: "P\u0142atno\u015B\u0107 za koszyk",
266
+ totalPrice: `${round(result.totalAmount / 100, 2)}`,
267
+ currencyCode: result.currency,
268
+ countryCode: result.country,
269
+ checkoutOption: "COMPLETE_IMMEDIATE_PURCHASE",
270
+ displayItems: mapGooglePayDisplayItems(items, result.methods, (_a = result.selectedDeliveryMethod) != null ? _a : result.methods.length > 0 ? result.methods[0].id : void 0, checkout.couponCode, result.couponValue)
271
+ }
272
+ };
273
+ console.log("returnValue", returnValue);
274
+ return returnValue;
275
+ }
276
+ function mapGooglePayDisplayItems(items, methods, deliveryMethod, couponCode, couponValue) {
277
+ const displayItems = [];
278
+ let subtotalAmount = 0;
279
+ for (const item of items) {
280
+ if (item.details == null) {
281
+ continue;
282
+ }
283
+ subtotalAmount += item.details.price * item.quantity;
284
+ displayItems.push({
285
+ label: item.details.name + " x " + item.quantity,
286
+ price: `${round(item.details.price / 100, 2)}`,
287
+ type: "LINE_ITEM",
288
+ status: "FINAL"
289
+ });
290
+ }
291
+ const selectedDeliveryMethod = methods.find((method) => method.id === deliveryMethod);
292
+ if (selectedDeliveryMethod != null) {
293
+ displayItems.push({
294
+ label: selectedDeliveryMethod.name,
295
+ price: `${round(selectedDeliveryMethod.amount / 100, 2)}`,
296
+ type: "SHIPPING_OPTION",
297
+ status: "FINAL"
298
+ });
299
+ }
300
+ if (couponCode != null && couponValue != null) {
301
+ displayItems.push({
302
+ label: `Kupon ${couponCode}`,
303
+ price: `${round(couponValue / 100, 2)}`,
304
+ type: "DISCOUNT",
305
+ status: "FINAL"
306
+ });
307
+ }
308
+ if (subtotalAmount > 0) {
309
+ displayItems.push({
310
+ label: "Subtotal",
311
+ price: `${round(subtotalAmount / 100, 2)}`,
312
+ type: "SUBTOTAL",
313
+ status: "FINAL"
314
+ });
315
+ }
316
+ return displayItems;
317
+ }
318
+
319
+ // src/components/checkout/CartProvider.tsx
320
+ import { Fragment, jsx } from "react/jsx-runtime";
321
+ var MARKETING_AGREEMENT_ID = "__m_a";
322
+ var CartProviderContext = createContext(void 0);
323
+ var bitsnapProjectID = void 0;
324
+ function setProjectID(projectID) {
325
+ bitsnapProjectID = projectID;
326
+ }
327
+ function getProjectID() {
328
+ if (bitsnapProjectID != null) {
329
+ return bitsnapProjectID;
330
+ }
331
+ const me = document.querySelector(
332
+ 'script[data-id][data-name="internal-cart"]'
333
+ );
334
+ const projectID = me == null ? void 0 : me.getAttribute("data-id");
335
+ return projectID != null ? projectID : void 0;
336
+ }
337
+ function getNewHostIfExist() {
338
+ const me = document.querySelector(
339
+ 'script[data-id][data-name="internal-cart"]'
340
+ );
341
+ const customHost = me == null ? void 0 : me.getAttribute("data-custom-host");
342
+ return customHost != null ? customHost : void 0;
343
+ }
344
+ var CartProvider = ({ children }) => {
345
+ const queryClient = new QueryClient();
346
+ const projectID = getProjectID();
347
+ if (projectID == null) {
348
+ return /* @__PURE__ */ jsx(Fragment, {});
349
+ }
350
+ const checkoutMethods = getCheckoutMethods(projectID);
351
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CartProviderContext.Provider, { value: checkoutMethods, children }) });
352
+ };
353
+ var getProducts = async (projectID) => {
354
+ var _a, _b;
355
+ const products = (_b = (_a = getCheckout()) == null ? void 0 : _a.products) != null ? _b : [];
356
+ const productIds = Array.from(
357
+ new Set(products.map((product) => product.productID))
358
+ );
359
+ const params = new URLSearchParams();
360
+ params.set("ids", productIds.join(","));
361
+ const result = await fetch(
362
+ buildURL(projectID, `/products?${params.toString()}`),
363
+ {
364
+ method: "GET"
365
+ }
366
+ );
367
+ if (result.status != 200) {
368
+ return [];
369
+ }
370
+ const payload = await result.json();
371
+ products.forEach((product) => {
372
+ var _a2;
373
+ product["details"] = (_a2 = payload.result) == null ? void 0 : _a2.find((el) => {
374
+ if (el.id === product.productID) {
375
+ return true;
376
+ }
377
+ if (el.variants != null && el.variants.length > 0) {
378
+ const index = el.variants.findIndex(
379
+ (variant) => variant.id === product.productID
380
+ );
381
+ return index !== -1;
382
+ }
383
+ return false;
384
+ });
385
+ });
386
+ return products.filter((el) => "details" in el).map((el) => {
387
+ el.details = resolveProductDetailsFromSingleProduct(
388
+ el.productID,
389
+ el.details
390
+ );
391
+ return el;
392
+ });
393
+ };
394
+ var useCartProvider = () => {
395
+ const context = useContext(CartProviderContext);
396
+ if (context === void 0) {
397
+ throw new Error("useCartProvider must be used within a CartProvider");
398
+ }
399
+ return context;
400
+ };
401
+ var CartProvider_default = CartProvider;
402
+ var googlePayConfigSchema = zod.object({
403
+ isAvailable: zod.boolean(),
404
+ merchantId: zod.string(),
405
+ merchantName: zod.string(),
406
+ gateway: zod.string(),
407
+ gatewayId: zod.string()
408
+ });
409
+ var checkoutSchema = zod.object({
410
+ country: zod.string().optional(),
411
+ couponCode: zod.string().optional(),
412
+ selectedDeliveryMethod: zod.string().optional(),
413
+ postalCode: zod.string().optional(),
414
+ email: zod.string().optional(),
415
+ products: zod.array(
416
+ zod.object({
417
+ id: zod.string(),
418
+ productID: zod.string(),
419
+ quantity: zod.number(),
420
+ metadata: zod.record(zod.string(), zod.string().optional()).optional()
421
+ })
422
+ ).optional(),
423
+ googlePayConfig: googlePayConfigSchema.optional()
424
+ });
425
+ var emptyCheckout = {
426
+ country: void 0,
427
+ couponCode: void 0,
428
+ email: void 0,
429
+ selectedDeliveryMethod: void 0,
430
+ postalCode: void 0,
431
+ products: [],
432
+ googlePayConfig: void 0
433
+ };
434
+ var checkoutKey = "checkout";
435
+ function getCheckout() {
436
+ try {
437
+ const value = localStorage.getItem(checkoutKey);
438
+ if (value == null) {
439
+ return emptyCheckout;
440
+ }
441
+ return checkoutSchema.parse(JSON.parse(value));
442
+ } catch (e) {
443
+ return emptyCheckout;
444
+ }
445
+ }
446
+ function addProducts(products) {
447
+ const checkout = getCheckout();
448
+ if (checkout.products == null) {
449
+ checkout.products = [];
450
+ }
451
+ checkout.products.push(...products.map((el) => ({
452
+ id: Math.random().toString(36).substring(7),
453
+ productID: el.productID,
454
+ quantity: el.quantity,
455
+ metadata: el.metadata
456
+ })));
457
+ saveCheckout(checkout);
458
+ }
459
+ function removeProductFromCheckout(ids) {
460
+ var _a;
461
+ const checkout = getCheckout();
462
+ const newCheckout = {
463
+ ...checkout,
464
+ products: (_a = checkout == null ? void 0 : checkout.products) == null ? void 0 : _a.filter(
465
+ (product) => !ids.includes(product.productID) && !ids.includes(product.id)
466
+ )
467
+ };
468
+ saveCheckout(newCheckout);
469
+ }
470
+ function saveCheckout(model) {
471
+ localStorage.setItem(checkoutKey, JSON.stringify(model));
472
+ }
473
+ var getCheckoutMethods = (projectID) => {
474
+ const newHost = getNewHostIfExist();
475
+ if (newHost != null) {
476
+ setCustomHost(newHost);
477
+ }
478
+ return {
479
+ async checkIfApplePayIsAvailable() {
480
+ if (typeof window == "undefined" || typeof document == "undefined") {
481
+ return false;
482
+ }
483
+ if ("ApplePaySession" in window === false) {
484
+ return false;
485
+ }
486
+ try {
487
+ const result = await PublicApiClient.get(HOST).isOneClickPaymentAvailable({
488
+ projectId: projectID
489
+ });
490
+ return result.applePay;
491
+ } catch (e) {
492
+ console.error("Error checking if Apple Pay is available", e);
493
+ return false;
494
+ }
495
+ },
496
+ async getGooglePayConfiguration(args) {
497
+ if (typeof window == "undefined" || typeof document == "undefined") {
498
+ return {
499
+ isAvailable: false
500
+ };
501
+ }
502
+ try {
503
+ const googlePayConfig = await resolveGooglePayConfiguration(projectID);
504
+ if ((googlePayConfig == null ? void 0 : googlePayConfig.isAvailable) != true) {
505
+ return {
506
+ isAvailable: false
507
+ };
508
+ }
509
+ const checkout = getCheckout();
510
+ if (checkout == null) {
511
+ console.log("checkout is null");
512
+ return {
513
+ isAvailable: false
514
+ };
515
+ }
516
+ if (args && args.items != null && args.items.length > 0) {
517
+ if (checkout.products) {
518
+ removeProductFromCheckout(checkout.products.map((el) => el.productID));
519
+ }
520
+ addProducts(args.items);
521
+ }
522
+ const products = await getProducts(projectID);
523
+ if (isErr(products)) {
524
+ return {
525
+ isAvailable: false
526
+ };
527
+ }
528
+ const result = await PublicApiClient.get(HOST).getPreOrderDetails({
529
+ items: products.map(
530
+ (el) => create2(PreOrderItemSchema, { id: el.productID, quantity: el.quantity })
531
+ ),
532
+ projectId: projectID,
533
+ // we can detect 5 the closest inpost pickup point based on shipping address.
534
+ postCode: checkout.postalCode,
535
+ couponCode: checkout.couponCode,
536
+ countryCode: checkout.country,
537
+ selectedDeliveryMethod: checkout.selectedDeliveryMethod
538
+ });
539
+ if (result.totalAmount == null) {
540
+ return {
541
+ isAvailable: false
542
+ };
543
+ }
544
+ const cartRequiresShipping = products.find((el) => {
545
+ var _a;
546
+ return ((_a = el.details) == null ? void 0 : _a.isDeliverable) == true;
547
+ }) != null;
548
+ const mappedPaymentRequest = await mapGooglePayConfiguration({
549
+ items: products,
550
+ googlePayConfig,
551
+ checkout,
552
+ cartRequiresShipping,
553
+ result
554
+ });
555
+ if (mappedPaymentRequest == null) {
556
+ return {
557
+ isAvailable: false
558
+ };
559
+ }
560
+ return {
561
+ isAvailable: true,
562
+ config: mappedPaymentRequest
563
+ };
564
+ } catch (e) {
565
+ console.error("Error resolving Google Pay configuration", e);
566
+ return {
567
+ isAvailable: false
568
+ };
569
+ }
570
+ },
571
+ async clearCart() {
572
+ var _a;
573
+ const empty = structuredClone(emptyCheckout);
574
+ empty.country = (_a = getCheckout()) == null ? void 0 : _a.country;
575
+ saveCheckout(empty);
576
+ },
577
+ async getAvailableCountries() {
578
+ const result = await fetch(buildURL(projectID, "/countries"), {
579
+ method: "GET"
580
+ });
581
+ if (result.status != 200) {
582
+ return [];
583
+ }
584
+ try {
585
+ return zod.array(
586
+ zod.object({
587
+ name: zod.string(),
588
+ code: zod.string()
589
+ })
590
+ ).parse(await result.json());
591
+ } catch (e) {
592
+ return Err(e.toString(), "internal");
593
+ }
594
+ },
595
+ async getCountry() {
596
+ var _a;
597
+ let country = (_a = getCheckout()) == null ? void 0 : _a.country;
598
+ if (country == null) {
599
+ country = "PL";
600
+ const checkout = getCheckout();
601
+ checkout.country = country;
602
+ saveCheckout(checkout);
603
+ }
604
+ return country;
605
+ },
606
+ async getNumberOfElementsInCart() {
607
+ var _a, _b, _c;
608
+ return (_c = (_b = (_a = getCheckout()) == null ? void 0 : _a.products) == null ? void 0 : _b.reduce(
609
+ (acc, product) => acc + product.quantity,
610
+ 0
611
+ )) != null ? _c : 0;
612
+ },
613
+ async getProducts() {
614
+ return await getProducts(projectID);
615
+ },
616
+ async removeProductFromCart(args) {
617
+ return removeProductFromCheckout([args.id]);
618
+ },
619
+ async setCountry(country) {
620
+ const checkout = getCheckout();
621
+ checkout.country = country;
622
+ saveCheckout(checkout);
623
+ },
624
+ async setCouponCodeIfPossible(couponCode) {
625
+ const checkout = getCheckout();
626
+ checkout.couponCode = couponCode;
627
+ saveCheckout(checkout);
628
+ },
629
+ async setPostalCode(postalCode) {
630
+ const checkout = getCheckout();
631
+ checkout.postalCode = postalCode;
632
+ saveCheckout(checkout);
633
+ },
634
+ async setDeliveryMethod(deliveryMethod) {
635
+ const checkout = getCheckout();
636
+ checkout.selectedDeliveryMethod = deliveryMethod;
637
+ saveCheckout(checkout);
638
+ },
639
+ async setEmail(email) {
640
+ const checkout = getCheckout();
641
+ checkout.email = email;
642
+ saveCheckout(checkout);
643
+ },
644
+ async addProduct(args) {
645
+ return addProducts([args]);
646
+ },
647
+ async updateQuantity(args) {
648
+ var _a;
649
+ const checkout = getCheckout();
650
+ checkout.products = (_a = checkout.products) == null ? void 0 : _a.map((product) => {
651
+ if (product.id === args.id) {
652
+ product.quantity = args.quantity;
653
+ }
654
+ return product;
655
+ });
656
+ saveCheckout(checkout);
657
+ },
658
+ async redirectToNextStep() {
659
+ const checkout = getCheckout();
660
+ if (checkout.products == null || checkout.products.length == 0) {
661
+ return Err("cart-is-empty", "badInput");
662
+ }
663
+ const mergedMetadata = checkout.products.reduce(
664
+ (acc, product) => {
665
+ if (product.metadata != null) {
666
+ Object.keys(product.metadata).forEach((key) => {
667
+ var _a;
668
+ const value = (_a = product.metadata) == null ? void 0 : _a[key];
669
+ if (value != null) {
670
+ acc[key] = value;
671
+ }
672
+ });
673
+ }
674
+ return acc;
675
+ },
676
+ {}
677
+ );
678
+ const payload = {
679
+ items: checkout.products.map((el) => {
680
+ return {
681
+ id: el.productID,
682
+ quantity: el.quantity
683
+ };
684
+ }),
685
+ askForNote: true,
686
+ countries: checkout.country ? [checkout.country] : void 0,
687
+ metadata: mergedMetadata
688
+ };
689
+ const paymentResponse = await createPaymentURL(payload);
690
+ if (isErr(paymentResponse)) {
691
+ console.warn("cannot create payment URL", paymentResponse.error);
692
+ return paymentResponse;
693
+ }
694
+ return {
695
+ url: paymentResponse.url
696
+ };
697
+ },
698
+ async justRedirectToPayment(args) {
699
+ let payload = {
700
+ items: [
701
+ {
702
+ id: args.productID,
703
+ quantity: 1
704
+ }
705
+ ],
706
+ askForNote: false,
707
+ details: args.email || args.name ? {
708
+ name: args.name,
709
+ email: args.email
710
+ } : void 0
711
+ };
712
+ payload = injectReferenceToRequestIfNeeded(payload);
713
+ if (args.country == null) {
714
+ args.country = "pl";
715
+ }
716
+ if (payload.details == null) {
717
+ payload.details = {};
718
+ }
719
+ if (payload.details.address == null) {
720
+ payload.details.address = {};
721
+ }
722
+ payload.details.address.country = args.country;
723
+ if (args.marketingAgreement === true) {
724
+ payload.additionalAgreements = [
725
+ {
726
+ id: MARKETING_AGREEMENT_ID,
727
+ name: "",
728
+ required: true,
729
+ answer: true
730
+ }
731
+ ];
732
+ }
733
+ const result = await fetch(buildURL(projectID, "/buy"), {
734
+ method: "POST",
735
+ headers: {
736
+ "Content-Type": "application/json"
737
+ },
738
+ body: JSON.stringify(payload)
739
+ });
740
+ console.log("CODE", result.status);
741
+ if (result.status != 200) {
742
+ console.warn(
743
+ "result",
744
+ await result.text(),
745
+ result.status,
746
+ result.statusText
747
+ );
748
+ return Err("internal-error", "internal");
749
+ }
750
+ const response = await result.json();
751
+ console.log(response.url);
752
+ return {
753
+ url: response.url
754
+ };
755
+ },
756
+ async completeApplePayPayment(args) {
757
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
758
+ const checkout = getCheckout();
759
+ if (checkout == null) {
760
+ return Err("Checkout not found");
761
+ }
762
+ const products = await getProducts(projectID);
763
+ if (isErr(products)) {
764
+ return products;
765
+ }
766
+ try {
767
+ let shippingName = (_a = args.shippingContact) == null ? void 0 : _a.givenName;
768
+ if (((_b = args.shippingContact) == null ? void 0 : _b.familyName) != null) {
769
+ shippingName += " " + ((_c = args.shippingContact) == null ? void 0 : _c.familyName);
770
+ } else if (((_d = args.billingContact) == null ? void 0 : _d.familyName) != null) {
771
+ shippingName += " " + ((_e = args.billingContact) == null ? void 0 : _e.familyName);
772
+ }
773
+ let metadata = {};
774
+ const ref = getReferenceIfPossible();
775
+ if (ref != null) {
776
+ metadata["ref"] = ref;
777
+ }
778
+ const result = await PublicApiClient.get(HOST).authorizeOneClickPayment(
779
+ {
780
+ gateway: 0 /* APPLE_PAY */,
781
+ paymentData: JSON.stringify(args.token.paymentData),
782
+ paymentMethod: JSON.stringify(args.token.paymentMethod),
783
+ transactionIdentifier: args.token.transactionIdentifier,
784
+ order: create2(GetPreOrderDetailsRequestSchema, {
785
+ items: products.map((el) => ({
786
+ id: el.productID,
787
+ quantity: el.quantity
788
+ })),
789
+ couponCode: checkout.couponCode,
790
+ email: (_j = (_i = (_h = (_f = args.shippingContact) == null ? void 0 : _f.emailAddress) != null ? _h : (_g = args.billingContact) == null ? void 0 : _g.emailAddress) != null ? _i : checkout.email) != null ? _j : void 0,
791
+ phone: (_n = (_m = (_k = args.shippingContact) == null ? void 0 : _k.phoneNumber) != null ? _m : (_l = args.billingContact) == null ? void 0 : _l.phoneNumber) != null ? _n : void 0,
792
+ selectedDeliveryMethod: checkout.selectedDeliveryMethod,
793
+ postCode: checkout.postalCode,
794
+ projectId: projectID
795
+ }),
796
+ shippingAddress: create2(AddressSchema, {
797
+ line1: (_q = (_p = (_o = args.shippingContact) == null ? void 0 : _o.addressLines) == null ? void 0 : _p[0]) != null ? _q : "",
798
+ city: (_s = (_r = args.shippingContact) == null ? void 0 : _r.locality) != null ? _s : "",
799
+ country: (_u = (_t = args.shippingContact) == null ? void 0 : _t.countryCode) != null ? _u : "",
800
+ zipCode: (_w = (_v = args.shippingContact) == null ? void 0 : _v.postalCode) != null ? _w : "",
801
+ name: shippingName
802
+ }),
803
+ billingAddress: create2(BillingAddressSchema, {
804
+ name: (_A = (_x = args.billingContact) == null ? void 0 : _x.givenName) != null ? _A : " " + ((_z = (_y = args.billingContact) == null ? void 0 : _y.familyName) != null ? _z : ""),
805
+ line1: (_D = (_C = (_B = args.billingContact) == null ? void 0 : _B.addressLines) == null ? void 0 : _C[0]) != null ? _D : "",
806
+ city: (_F = (_E = args.billingContact) == null ? void 0 : _E.locality) != null ? _F : "",
807
+ country: (_H = (_G = args.billingContact) == null ? void 0 : _G.countryCode) != null ? _H : "",
808
+ zipCode: (_J = (_I = args.billingContact) == null ? void 0 : _I.postalCode) != null ? _J : ""
809
+ }),
810
+ metadata: Object.keys(metadata).length > 0 ? JSON.stringify(metadata) : void 0
811
+ }
812
+ );
813
+ return {
814
+ isSuccess: result.isSuccess,
815
+ redirectURL: result.redirectUrl
816
+ };
817
+ } catch (error) {
818
+ console.error(error);
819
+ return Err("Failed to authorize payment");
820
+ }
821
+ },
822
+ async completeGooglePayPayment(args) {
823
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
824
+ const checkout = getCheckout();
825
+ if (checkout == null) {
826
+ return Err("Checkout not found");
827
+ }
828
+ const products = await getProducts(projectID);
829
+ if (isErr(products)) {
830
+ return products;
831
+ }
832
+ try {
833
+ let shippingName = (_a = args.paymentData.shippingAddress) == null ? void 0 : _a.name;
834
+ let metadata = {};
835
+ const ref = getReferenceIfPossible();
836
+ if (ref != null) {
837
+ metadata["ref"] = ref;
838
+ }
839
+ const result = await PublicApiClient.get(HOST).authorizeOneClickPayment(
840
+ {
841
+ gateway: 1 /* GOOGLE_PAY */,
842
+ paymentData: args.paymentData.paymentMethodData.tokenizationData.token,
843
+ paymentMethod: args.paymentData.paymentMethodData.type,
844
+ transactionIdentifier: "",
845
+ order: create2(GetPreOrderDetailsRequestSchema, {
846
+ items: products.map((el) => ({
847
+ id: el.productID,
848
+ quantity: el.quantity
849
+ })),
850
+ couponCode: checkout.couponCode,
851
+ email: (_b = args.paymentData.email) != null ? _b : void 0,
852
+ phone: (_d = (_c = args.paymentData.shippingAddress) == null ? void 0 : _c.phoneNumber) != null ? _d : void 0,
853
+ selectedDeliveryMethod: (_f = (_e = args.paymentData.shippingOptionData) == null ? void 0 : _e.id) != null ? _f : checkout.selectedDeliveryMethod,
854
+ postCode: (_g = args.paymentData.shippingAddress) == null ? void 0 : _g.postalCode,
855
+ projectId: projectID
856
+ }),
857
+ shippingAddress: create2(AddressSchema, {
858
+ line1: (_i = (_h = args.paymentData.shippingAddress) == null ? void 0 : _h.address1) != null ? _i : "",
859
+ city: (_k = (_j = args.paymentData.shippingAddress) == null ? void 0 : _j.locality) != null ? _k : "",
860
+ country: (_m = (_l = args.paymentData.shippingAddress) == null ? void 0 : _l.countryCode) != null ? _m : "",
861
+ zipCode: (_o = (_n = args.paymentData.shippingAddress) == null ? void 0 : _n.postalCode) != null ? _o : "",
862
+ name: shippingName
863
+ }),
864
+ billingAddress: create2(BillingAddressSchema, {
865
+ name: (_q = (_p = args.paymentData.paymentMethodData.info) == null ? void 0 : _p.billingAddress) == null ? void 0 : _q.name,
866
+ line1: (_t = (_s = (_r = args.paymentData.paymentMethodData.info) == null ? void 0 : _r.billingAddress) == null ? void 0 : _s.address1) != null ? _t : "",
867
+ city: (_w = (_v = (_u = args.paymentData.paymentMethodData.info) == null ? void 0 : _u.billingAddress) == null ? void 0 : _v.locality) != null ? _w : "",
868
+ country: (_z = (_y = (_x = args.paymentData.paymentMethodData.info) == null ? void 0 : _x.billingAddress) == null ? void 0 : _y.countryCode) != null ? _z : "",
869
+ zipCode: (_C = (_B = (_A = args.paymentData.paymentMethodData.info) == null ? void 0 : _A.billingAddress) == null ? void 0 : _B.postalCode) != null ? _C : ""
870
+ }),
871
+ metadata: Object.keys(metadata).length > 0 ? JSON.stringify(metadata) : void 0
872
+ }
873
+ );
874
+ return {
875
+ isSuccess: result.isSuccess,
876
+ redirectURL: result.redirectUrl
877
+ };
878
+ } catch (error) {
879
+ console.error(error);
880
+ return Err("Failed to authorize payment");
881
+ }
882
+ return {
883
+ isSuccess: true
884
+ };
885
+ },
886
+ async getApplePayPaymentRequest(args) {
887
+ var _a, _b;
888
+ const checkout = getCheckout();
889
+ if (checkout == null) {
890
+ return Err("Checkout not found");
891
+ }
892
+ if (args && args.expectedItems != null && args.expectedItems.length > 0) {
893
+ if (checkout.products) {
894
+ removeProductFromCheckout(checkout.products.map((el) => el.productID));
895
+ }
896
+ addProducts(args.expectedItems);
897
+ }
898
+ const products = await getProducts(projectID);
899
+ if (isErr(products)) {
900
+ return products;
901
+ }
902
+ const result = await PublicApiClient.get(HOST).getPreOrderDetails({
903
+ items: products.map(
904
+ (el) => create2(PreOrderItemSchema, { id: el.productID, quantity: el.quantity })
905
+ ),
906
+ projectId: projectID,
907
+ // we can detect 5 the closest inpost pickup point based on shipping address.
908
+ postCode: checkout.postalCode,
909
+ couponCode: checkout.couponCode,
910
+ countryCode: checkout.country,
911
+ selectedDeliveryMethod: checkout.selectedDeliveryMethod
912
+ });
913
+ const items = products.map((el) => {
914
+ var _a2, _b2, _c;
915
+ return {
916
+ amount: `${round(el.quantity * ((_b2 = (_a2 = el.details) == null ? void 0 : _a2.price) != null ? _b2 : 0) / 100, 2)}`,
917
+ label: ((_c = el.details) == null ? void 0 : _c.name) + " - " + el.quantity,
918
+ type: "final"
919
+ };
920
+ });
921
+ if (result.selectedDeliveryMethod != null) {
922
+ const deliveryMethod = result.methods.find((el) => el.id == result.selectedDeliveryMethod);
923
+ if (deliveryMethod != null) {
924
+ items.push({
925
+ amount: `${round(deliveryMethod.amount / 100, 2)}`,
926
+ label: deliveryMethod.name,
927
+ type: "final"
928
+ });
929
+ }
930
+ }
931
+ if (result.couponCode != null && result.couponValue != null) {
932
+ items.push({
933
+ amount: `-${round(result.couponValue / 100, 2)}`,
934
+ label: result.couponCode,
935
+ type: "final"
936
+ });
937
+ }
938
+ return {
939
+ countryCode: (_a = checkout.country) != null ? _a : "PL",
940
+ merchantCapabilities: [
941
+ "supports3DS",
942
+ "supportsCredit",
943
+ "supportsDebit"
944
+ ],
945
+ supportedNetworks: ["visa", "masterCard"],
946
+ total: {
947
+ amount: `${round(((_b = result.totalAmount) != null ? _b : 0) / 100, 2)}`,
948
+ label: "P\u0142atno\u015B\u0107 za koszyk",
949
+ type: "final"
950
+ },
951
+ shippingMethods: result.methods.map((el) => {
952
+ var _a2, _b2, _c;
953
+ return {
954
+ amount: `${round(el.amount / 100, 2)}`,
955
+ detail: (_a2 = el.description) != null ? _a2 : "",
956
+ identifier: el.id,
957
+ label: el.name,
958
+ dateComponentsRange: {
959
+ startDateComponents: {
960
+ days: (_b2 = el.minDays) != null ? _b2 : 1,
961
+ hours: 0,
962
+ months: 0,
963
+ years: 0
964
+ },
965
+ endDateComponents: {
966
+ days: (_c = el.maxDays) != null ? _c : 14,
967
+ hours: 0,
968
+ months: 0,
969
+ years: 0
970
+ }
971
+ }
972
+ };
973
+ }),
974
+ lineItems: items,
975
+ currencyCode: "PLN"
976
+ };
977
+ }
978
+ };
979
+ };
980
+ async function resolveGooglePayConfiguration(projectID) {
981
+ var _a;
982
+ const checkout = getCheckout();
983
+ if (((_a = checkout.googlePayConfig) == null ? void 0 : _a.isAvailable) != true) {
984
+ const result = await PublicApiClient.get(HOST).isOneClickPaymentAvailable({
985
+ projectId: projectID
986
+ });
987
+ if (result.googlePay == true && result.googlePayConfig != null) {
988
+ checkout.googlePayConfig = {
989
+ isAvailable: true,
990
+ gateway: result.googlePayConfig.gateway,
991
+ gatewayId: result.googlePayConfig.gatewayMerchantId,
992
+ merchantName: result.googlePayConfig.merchantName,
993
+ merchantId: result.googlePayConfig.merchantId
994
+ };
995
+ } else {
996
+ checkout.googlePayConfig = {
997
+ isAvailable: false,
998
+ gateway: "",
999
+ gatewayId: "",
1000
+ merchantName: "",
1001
+ merchantId: ""
1002
+ };
1003
+ }
1004
+ }
1005
+ saveCheckout(checkout);
1006
+ return checkout.googlePayConfig;
1007
+ }
1008
+ function resolveProductDetailsFromSingleProduct(id, product) {
1009
+ var _a, _b, _c, _d;
1010
+ if (id == product.id) {
1011
+ const variantIndex = (_a = product.variants) == null ? void 0 : _a.findIndex((v) => v.id === id);
1012
+ if (variantIndex != null && variantIndex != -1) {
1013
+ const variant2 = product.variants[variantIndex];
1014
+ return {
1015
+ ...product,
1016
+ availableQuantity: variant2.availableQuantity,
1017
+ isDeliverable: variant2.isDeliverable,
1018
+ images: (_b = variant2.images) != null ? _b : product.images,
1019
+ name: product.name + " " + variant2.name,
1020
+ price: variant2.price,
1021
+ currency: variant2.currency
1022
+ };
1023
+ }
1024
+ return product;
1025
+ }
1026
+ const variant = (_c = product.variants) == null ? void 0 : _c.find((v) => v.id === id);
1027
+ if (variant == null) {
1028
+ return product;
1029
+ }
1030
+ return {
1031
+ ...product,
1032
+ id: variant.id,
1033
+ name: product.name + " " + variant.name,
1034
+ price: variant.price,
1035
+ currency: variant.currency,
1036
+ metadata: product.metadata,
1037
+ availableQuantity: variant.availableQuantity,
1038
+ isDeliverable: variant.isDeliverable,
1039
+ images: (_d = variant.images) != null ? _d : product.images
1040
+ };
1041
+ }
1042
+
1043
+ // src/components/checkout/ApplePay.tsx
1044
+ import { useQuery } from "react-query";
1045
+ import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
1046
+ function ApplePayButtonComponent({ style, buttonType, colorType, items, onClick }) {
1047
+ const {
1048
+ checkIfApplePayIsAvailable,
1049
+ getApplePayPaymentRequest,
1050
+ completeApplePayPayment,
1051
+ setCountry,
1052
+ setCouponCodeIfPossible,
1053
+ setDeliveryMethod,
1054
+ setEmail,
1055
+ setPostalCode,
1056
+ clearCart
1057
+ } = useCartProvider();
1058
+ const { data: isApplePayAvailable } = useQuery("is-apple-pay-available", checkIfApplePayIsAvailable);
1059
+ if (isApplePayAvailable != true) {
1060
+ return null;
1061
+ }
1062
+ const expectedItems = items.map((el) => ({
1063
+ productID: el.id,
1064
+ quantity: el.quantity,
1065
+ metadata: el.metadata
1066
+ }));
1067
+ async function beginSession() {
1068
+ const requiresShipping = items.find((el) => el.isDeliverable === true) != null;
1069
+ const session = new ApplePaySession(14, {
1070
+ countryCode: "PL",
1071
+ merchantCapabilities: ["supports3DS"],
1072
+ supportedNetworks: ["visa", "masterCard"],
1073
+ currencyCode: "PLN",
1074
+ total: {
1075
+ amount: `${round(items.reduce((acc, item) => acc + item.price * item.quantity, 0) / 100, 2)}`,
1076
+ label: "P\u0142atno\u015B\u0107 za koszyk",
1077
+ type: "pending"
1078
+ },
1079
+ lineItems: [
1080
+ ...items.map((item) => ({
1081
+ amount: `${round(item.price * item.quantity / 100, 2)}`,
1082
+ label: item.name,
1083
+ type: "final"
1084
+ })),
1085
+ requiresShipping ? {
1086
+ amount: `16.99`,
1087
+ type: "pending",
1088
+ label: "Dostawa"
1089
+ } : void 0
1090
+ ].filter((el) => el != null),
1091
+ ...requiresShipping ? {
1092
+ shippingMethods: [],
1093
+ supportsCouponCode: true,
1094
+ requiredBillingContactFields: ["name", "email", "postalAddress", "phone"],
1095
+ requiredShippingContactFields: ["name", "email", "postalAddress", "phone"]
1096
+ } : {}
1097
+ });
1098
+ await (onClick == null ? void 0 : onClick());
1099
+ const apRequest = await getApplePayPaymentRequest({ expectedItems });
1100
+ if (isErr(apRequest)) {
1101
+ console.error("Error creating ApplePaySession:", apRequest.error);
1102
+ return;
1103
+ }
1104
+ session.oncancel = (event) => {
1105
+ console.log("ApplePaySession cancelled", event);
1106
+ };
1107
+ session.onvalidatemerchant = async (event) => {
1108
+ try {
1109
+ const result = await PublicApiClient.get(HOST).applePayValidateMerchant(
1110
+ {
1111
+ validationUrl: event.validationURL,
1112
+ projectId: getProjectID()
1113
+ }
1114
+ );
1115
+ console.log("merchantSession", result.merchantSession);
1116
+ if (result.merchantSession.length > 0) {
1117
+ console.log("completing merchant session");
1118
+ session.completeMerchantValidation(
1119
+ JSON.parse(result.merchantSession)
1120
+ );
1121
+ } else {
1122
+ session.abort();
1123
+ }
1124
+ } catch (error) {
1125
+ session.abort;
1126
+ }
1127
+ };
1128
+ session.onshippingmethodselected = async (event) => {
1129
+ console.log("shipping method selected", event);
1130
+ await setDeliveryMethod(event.shippingMethod.identifier);
1131
+ const apRequest2 = await getApplePayPaymentRequest({ expectedItems });
1132
+ console.log("apRequest", apRequest2);
1133
+ if (isErr(apRequest2)) {
1134
+ session.abort();
1135
+ throw new Error("Failed to get Apple Pay payment request");
1136
+ }
1137
+ session.completeShippingMethodSelection({
1138
+ newTotal: apRequest2.total,
1139
+ newLineItems: apRequest2.lineItems,
1140
+ newShippingMethods: apRequest2.shippingMethods
1141
+ });
1142
+ };
1143
+ session.onshippingcontactselected = async (event) => {
1144
+ try {
1145
+ if (event.shippingContact.countryCode != null) {
1146
+ await setCountry(event.shippingContact.countryCode);
1147
+ }
1148
+ if (event.shippingContact.postalCode != null) {
1149
+ await setPostalCode(event.shippingContact.postalCode);
1150
+ }
1151
+ if (event.shippingContact.phoneNumber != null) {
1152
+ await setEmail(event.shippingContact.emailAddress);
1153
+ }
1154
+ const apRequest2 = await getApplePayPaymentRequest({ expectedItems });
1155
+ if (isErr(apRequest2)) {
1156
+ session.abort();
1157
+ throw new Error("Failed to get Apple Pay payment request");
1158
+ }
1159
+ console.log("apRequest", apRequest2);
1160
+ session.completeShippingContactSelection({
1161
+ newLineItems: apRequest2.lineItems,
1162
+ newTotal: apRequest2.total,
1163
+ newShippingMethods: apRequest2.shippingMethods
1164
+ });
1165
+ } catch (error) {
1166
+ console.log("shipping contact selected error", error);
1167
+ session.abort();
1168
+ }
1169
+ };
1170
+ session.oncouponcodechanged = async (event) => {
1171
+ try {
1172
+ console.log("coupon code changed", event);
1173
+ const result = await setCouponCodeIfPossible(event.couponCode);
1174
+ const apRequest2 = await getApplePayPaymentRequest({ expectedItems });
1175
+ console.log("apRequest", apRequest2);
1176
+ if (isErr(apRequest2)) {
1177
+ session.abort();
1178
+ throw new Error("Failed to get Apple Pay payment request");
1179
+ }
1180
+ session.completeCouponCodeChange({
1181
+ errors: isErr(result) ? [new ApplePayError("couponCodeInvalid")] : void 0,
1182
+ newTotal: apRequest2.total,
1183
+ newLineItems: apRequest2.lineItems,
1184
+ newShippingMethods: apRequest2.shippingMethods
1185
+ });
1186
+ } catch (error) {
1187
+ console.log("coupon code changed error", error);
1188
+ session.abort();
1189
+ }
1190
+ };
1191
+ session.onpaymentauthorized = async (event) => {
1192
+ try {
1193
+ const result = await completeApplePayPayment({
1194
+ token: event.payment.token,
1195
+ billingContact: event.payment.billingContact,
1196
+ shippingContact: event.payment.shippingContact
1197
+ });
1198
+ if (isErr(result)) {
1199
+ console.log("apple pay error", result);
1200
+ session.completePayment({
1201
+ status: ApplePaySession.STATUS_FAILURE
1202
+ });
1203
+ return;
1204
+ }
1205
+ if (result.redirectURL) {
1206
+ setTimeout(() => {
1207
+ open(result.redirectURL, "_self");
1208
+ }, 2e3);
1209
+ }
1210
+ session.completePayment({
1211
+ status: result.isSuccess ? ApplePaySession.STATUS_SUCCESS : ApplePaySession.STATUS_FAILURE
1212
+ });
1213
+ result.isSuccess && clearCart();
1214
+ } catch (e) {
1215
+ session.completePayment({
1216
+ status: ApplePaySession.STATUS_FAILURE
1217
+ });
1218
+ }
1219
+ };
1220
+ session.begin();
1221
+ }
1222
+ return /* @__PURE__ */ jsx2(ApplePayButton, { style, buttonStyle: colorType, type: buttonType, onClick: beginSession });
1223
+ }
1224
+ function Wrapper(props) {
1225
+ return /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2(CartProvider_default, { children: /* @__PURE__ */ jsx2(ApplePayButtonComponent, { ...props }) }) });
1226
+ }
1227
+ var ApplePay_default = Wrapper;
1228
+
1229
+ // src/components/checkout/GooglePay.tsx
1230
+ import GooglePayButton from "@google-pay/button-react";
1231
+ import { useMutation, useQuery as useQuery2 } from "react-query";
1232
+ import { Fragment as Fragment3, jsx as jsx3, jsxs } from "react/jsx-runtime";
1233
+ function GooglePayButtonComponent({ items, style, buttonColor, buttonSizeMode, test }) {
1234
+ const {
1235
+ getGooglePayConfiguration,
1236
+ completeGooglePayPayment,
1237
+ setCountry,
1238
+ setCouponCodeIfPossible,
1239
+ setDeliveryMethod,
1240
+ setEmail,
1241
+ setPostalCode,
1242
+ clearCart
1243
+ } = useCartProvider();
1244
+ const { data: googlePayConfiguration } = useQuery2(["get-google-pay-configuration", items.map((el) => el.id).join(",")], () => getGooglePayConfiguration({
1245
+ items: items.map((el) => ({
1246
+ ...el,
1247
+ id: void 0,
1248
+ productID: el.id
1249
+ }))
1250
+ }));
1251
+ const { mutateAsync: completeGooglePayPaymentAsync, isLoading } = useMutation(completeGooglePayPayment);
1252
+ if (googlePayConfiguration == null || googlePayConfiguration.isAvailable != true) {
1253
+ console.log("google pay configuration is not available", googlePayConfiguration);
1254
+ return null;
1255
+ }
1256
+ return /* @__PURE__ */ jsxs(Fragment3, { children: [
1257
+ /* @__PURE__ */ jsx3(
1258
+ GooglePayButton,
1259
+ {
1260
+ buttonSizeMode,
1261
+ buttonColor,
1262
+ style,
1263
+ existingPaymentMethodRequired: true,
1264
+ environment: test === true ? "TEST" : "PRODUCTION",
1265
+ onPaymentDataChanged: async (paymentData) => {
1266
+ var _a, _b, _c, _d, _e;
1267
+ console.log("payment data changed", paymentData);
1268
+ if (((_a = paymentData.shippingAddress) == null ? void 0 : _a.postalCode) != null) {
1269
+ await setPostalCode((_b = paymentData.shippingAddress) == null ? void 0 : _b.postalCode);
1270
+ }
1271
+ if (((_c = paymentData.shippingAddress) == null ? void 0 : _c.countryCode) != null) {
1272
+ await setCountry((_d = paymentData.shippingAddress) == null ? void 0 : _d.countryCode);
1273
+ }
1274
+ if (((_e = paymentData.shippingOptionData) == null ? void 0 : _e.id) != null) {
1275
+ await setDeliveryMethod(paymentData.shippingOptionData.id);
1276
+ }
1277
+ const config = await getGooglePayConfiguration({ items: [] });
1278
+ console.log("PAYMENT DATA CHANGED CONFIG", config);
1279
+ if (config.isAvailable) {
1280
+ return {
1281
+ error: void 0,
1282
+ newShippingOptionParameters: config.config.shippingOptionParameters,
1283
+ newTransactionInfo: config.config.transactionInfo
1284
+ };
1285
+ }
1286
+ return {
1287
+ error: void 0
1288
+ };
1289
+ },
1290
+ paymentRequest: googlePayConfiguration.config,
1291
+ onLoadPaymentData: async (paymentRequest) => {
1292
+ try {
1293
+ const result = await completeGooglePayPaymentAsync({
1294
+ paymentData: paymentRequest
1295
+ });
1296
+ if (isErr(result)) {
1297
+ console.log("apple pay error", result);
1298
+ return;
1299
+ }
1300
+ result.isSuccess && clearCart();
1301
+ if (result.redirectURL) {
1302
+ open(result.redirectURL, "_self");
1303
+ }
1304
+ } catch (e) {
1305
+ console.warn("error completing google pay payment", e);
1306
+ }
1307
+ }
1308
+ }
1309
+ ),
1310
+ isLoading ? "\u0141adowanie..." : null
1311
+ ] });
1312
+ }
1313
+ function Wrapper2(props) {
1314
+ return /* @__PURE__ */ jsx3(Fragment3, { children: /* @__PURE__ */ jsx3(CartProvider_default, { children: /* @__PURE__ */ jsx3(GooglePayButtonComponent, { ...props }) }) });
1315
+ }
1316
+ var GooglePay_default = Wrapper2;
1317
+
1318
+ // src/components/checkout/BitsnapCart.tsx
1319
+ import { useEffect as useEffect3 } from "react";
1320
+ import zod2 from "zod";
1321
+
1322
+ // src/components/checkout/CartComponent.tsx
1323
+ import { useAutoAnimate as useAutoAnimate2 } from "@formkit/auto-animate/react";
1324
+ import { createPortal } from "react-dom";
1325
+
1326
+ // src/components/checkout/CartComponentContent.tsx
1327
+ import { useAutoAnimate } from "@formkit/auto-animate/react";
1328
+ import React from "react";
1329
+ import { useMutation as useMutation2, useQuery as useQuery3 } from "react-query";
1330
+
1331
+ // src/components/checkout/CountrySelector.tsx
1332
+ import { AnimatePresence, motion } from "framer-motion";
1333
+ import { useEffect, useRef, useState } from "react";
1334
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
1335
+ function CountrySelector({
1336
+ id,
1337
+ open: open2,
1338
+ disabled = false,
1339
+ onToggle,
1340
+ onChange,
1341
+ selectedValue,
1342
+ countries
1343
+ }) {
1344
+ var _a;
1345
+ const ref = useRef(null);
1346
+ useEffect(() => {
1347
+ const mutableRef = ref;
1348
+ const handleClickOutside = (event) => {
1349
+ if (mutableRef.current && // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1350
+ // @ts-expect-error
1351
+ !mutableRef.current.contains(event.target) && open2) {
1352
+ onToggle();
1353
+ setQuery("");
1354
+ }
1355
+ };
1356
+ window.document.addEventListener("mousedown", handleClickOutside);
1357
+ return () => {
1358
+ document.removeEventListener("mousedown", handleClickOutside);
1359
+ };
1360
+ }, [ref]);
1361
+ useEffect(() => {
1362
+ if (selectedValue == null && countries.length > 0) {
1363
+ onChange(countries[0].code);
1364
+ }
1365
+ }, []);
1366
+ const [query, setQuery] = useState("");
1367
+ return /* @__PURE__ */ jsx4("div", { ref, children: /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
1368
+ /* @__PURE__ */ jsxs2(
1369
+ "button",
1370
+ {
1371
+ type: "button",
1372
+ className: `${disabled ? "bg-neutral-100" : "bg-extra-light-white"} relative w-full rounded-2xl shadow-sm pl-8 pr-10 py-3 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 sm:text-sm`,
1373
+ "aria-haspopup": "listbox",
1374
+ "aria-expanded": "true",
1375
+ "aria-labelledby": "listbox-label",
1376
+ onClick: onToggle,
1377
+ disabled,
1378
+ children: [
1379
+ /* @__PURE__ */ jsxs2("span", { className: "truncate flex items-center", children: [
1380
+ /* @__PURE__ */ jsx4(
1381
+ "img",
1382
+ {
1383
+ alt: `${selectedValue}`,
1384
+ src: `https://purecatamphetamine.github.io/country-flag-icons/3x2/${selectedValue}.svg`,
1385
+ className: "inline mr-2 h-4 rounded-sm"
1386
+ }
1387
+ ),
1388
+ (_a = countries.find((el) => el.code === selectedValue)) == null ? void 0 : _a.name
1389
+ ] }),
1390
+ /* @__PURE__ */ jsx4(
1391
+ "span",
1392
+ {
1393
+ className: `absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none ${disabled ? "hidden" : ""}`,
1394
+ children: /* @__PURE__ */ jsx4(
1395
+ "svg",
1396
+ {
1397
+ className: "h-5 w-5 text-light-purple",
1398
+ xmlns: "http://www.w3.org/2000/svg",
1399
+ viewBox: "0 0 20 20",
1400
+ fill: "currentColor",
1401
+ "aria-hidden": "true",
1402
+ children: /* @__PURE__ */ jsx4(
1403
+ "path",
1404
+ {
1405
+ fillRule: "evenodd",
1406
+ d: "M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",
1407
+ clipRule: "evenodd"
1408
+ }
1409
+ )
1410
+ }
1411
+ )
1412
+ }
1413
+ )
1414
+ ]
1415
+ }
1416
+ ),
1417
+ /* @__PURE__ */ jsx4(AnimatePresence, { children: open2 && /* @__PURE__ */ jsxs2(
1418
+ motion.ul,
1419
+ {
1420
+ initial: { opacity: 0 },
1421
+ animate: { opacity: 1 },
1422
+ exit: { opacity: 0 },
1423
+ transition: { duration: 0.1 },
1424
+ className: "absolute z-10 -mt-80 w-full dark:bg-neutral-800 bg-white shadow-lg max-h-80 rounded-md text-body-regular ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-body-regular",
1425
+ tabIndex: -1,
1426
+ role: "listbox",
1427
+ "aria-labelledby": "listbox-label",
1428
+ "aria-activedescendant": "listbox-option-3",
1429
+ children: [
1430
+ /* @__PURE__ */ jsxs2("div", { className: "sticky top-0 z-10 bg-white dark:bg-neutral-800", children: [
1431
+ /* @__PURE__ */ jsx4("li", { className: "dark:text-neutral-200 text-neutral-900 cursor-default select-none relative py-2 px-3", children: /* @__PURE__ */ jsx4(
1432
+ "input",
1433
+ {
1434
+ type: "search",
1435
+ name: "search",
1436
+ autoComplete: "off",
1437
+ className: "block w-full outline-none sm:text-body-regular dark:text-neutral-400 text-dark-blue bg-transparent border-light-purple rounded-md placeholder:text-light-purple",
1438
+ placeholder: "Znajd\u017A kraj",
1439
+ onChange: (e) => setQuery(e.target.value)
1440
+ }
1441
+ ) }),
1442
+ /* @__PURE__ */ jsx4("hr", {})
1443
+ ] }),
1444
+ /* @__PURE__ */ jsx4(
1445
+ "div",
1446
+ {
1447
+ className: "max-h-64 scrollbar scrollbar-track-gray-100 scrollbar-thumb-gray-300 hover:scrollbar-thumb-gray-600 scrollbar-thumb-rounded scrollbar-thin overflow-y-scroll",
1448
+ children: countries.filter(
1449
+ (country) => country.name.toLowerCase().startsWith(query.toLowerCase())
1450
+ ).length === 0 ? /* @__PURE__ */ jsx4("li", { className: "text-light-purple cursor-default select-none relative py-2 pl-3 pr-9", children: "No countries found" }) : countries.filter(
1451
+ (country) => country.name.toLowerCase().startsWith(query.toLowerCase())
1452
+ ).map((value, index) => {
1453
+ return /* @__PURE__ */ jsxs2(
1454
+ "li",
1455
+ {
1456
+ className: "text-dark-blue cursor-default select-none relative py-2 pl-3 pr-9 flex items-center hover:bg-extra-light-white transition",
1457
+ id: "listbox-option-0",
1458
+ role: "option",
1459
+ onClick: () => {
1460
+ onChange(value.code);
1461
+ setQuery("");
1462
+ onToggle();
1463
+ },
1464
+ children: [
1465
+ /* @__PURE__ */ jsx4(
1466
+ "img",
1467
+ {
1468
+ alt: `${value.code}`,
1469
+ src: `https://purecatamphetamine.github.io/country-flag-icons/3x2/${value.code}.svg`,
1470
+ className: "inline mr-2 h-4 rounded-sm"
1471
+ }
1472
+ ),
1473
+ /* @__PURE__ */ jsx4("span", { className: "font-normal truncate", children: value.name }),
1474
+ value.code === selectedValue ? /* @__PURE__ */ jsx4(
1475
+ "span",
1476
+ {
1477
+ className: "text-blue-600 absolute inset-y-0 right-0 flex items-center pr-8",
1478
+ children: /* @__PURE__ */ jsx4(
1479
+ "svg",
1480
+ {
1481
+ className: "h-5 w-5",
1482
+ xmlns: "http://www.w3.org/2000/svg",
1483
+ viewBox: "0 0 20 20",
1484
+ fill: "currentColor",
1485
+ "aria-hidden": "true",
1486
+ children: /* @__PURE__ */ jsx4(
1487
+ "path",
1488
+ {
1489
+ fillRule: "evenodd",
1490
+ d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
1491
+ clipRule: "evenodd"
1492
+ }
1493
+ )
1494
+ }
1495
+ )
1496
+ }
1497
+ ) : null
1498
+ ]
1499
+ },
1500
+ `${id}-${index}`
1501
+ );
1502
+ })
1503
+ }
1504
+ )
1505
+ ]
1506
+ }
1507
+ ) })
1508
+ ] }) });
1509
+ }
1510
+ var CountrySelector_default = CountrySelector;
1511
+
1512
+ // src/components/checkout/SingleProduct.tsx
1513
+ import { useEffect as useEffect2, useState as useState2 } from "react";
1514
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1515
+ var SingleProduct = ({ quantity, details, shouldUpdate }) => {
1516
+ var _a;
1517
+ return /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
1518
+ /* @__PURE__ */ jsx5("img", { className: "aspect-auto max-w-[30%] max-w-32 max-h-32", src: (_a = details.image_url) != null ? _a : "", alt: details.name }),
1519
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
1520
+ /* @__PURE__ */ jsx5("p", { className: "font-medium", children: details.name }),
1521
+ /* @__PURE__ */ jsx5("p", { className: "text-sm", children: formatCurrency(details.price, details.currency) }),
1522
+ /* @__PURE__ */ jsxs3("div", { className: "flex justify-between", children: [
1523
+ /* @__PURE__ */ jsx5(QuantityComponent, { className: "", quantity, shouldUpdate }),
1524
+ /* @__PURE__ */ jsx5("button", { className: "text-sm font-medium", onClick: () => shouldUpdate(0), children: "Usu\u0144" })
1525
+ ] })
1526
+ ] })
1527
+ ] });
1528
+ };
1529
+ var SingleProduct_default = SingleProduct;
1530
+ var QuantityComponent = ({
1531
+ quantity,
1532
+ shouldUpdate,
1533
+ className
1534
+ }) => {
1535
+ const [quantityString, setQuantityString] = useState2(quantity.toString());
1536
+ const [quantityValue, setQuantityValue] = useState2(quantity);
1537
+ useEffect2(() => {
1538
+ shouldUpdate(quantityValue);
1539
+ }, [quantityValue]);
1540
+ function setNewQuantity(newQuantity) {
1541
+ setQuantityString(newQuantity);
1542
+ if (newQuantity.length == 0) {
1543
+ return;
1544
+ }
1545
+ const parsedInt = parseInt(newQuantity);
1546
+ if (isNaN(parsedInt)) {
1547
+ setQuantityValue(1);
1548
+ setQuantityString("");
1549
+ return;
1550
+ }
1551
+ if (parsedInt == 0 || parsedInt < 0) {
1552
+ setQuantityValue(1);
1553
+ setQuantityString("1");
1554
+ return;
1555
+ }
1556
+ setQuantityValue(parsedInt);
1557
+ setQuantityString(parsedInt.toString());
1558
+ }
1559
+ function increaseQuantity() {
1560
+ setQuantityValue(quantity + 1);
1561
+ setQuantityString((quantity + 1).toString());
1562
+ }
1563
+ function decreaseQuantity() {
1564
+ if (quantity > 1) {
1565
+ setQuantityString((quantity - 1).toString());
1566
+ setQuantityValue(quantity - 1);
1567
+ return;
1568
+ }
1569
+ setQuantityString(quantity.toString());
1570
+ setQuantityValue(quantity);
1571
+ }
1572
+ return /* @__PURE__ */ jsxs3("div", { className: `flex ${className} items-center border dark:border-neutral-400 border-neutral-700 rounded-md my-1`, children: [
1573
+ /* @__PURE__ */ jsx5("button", { onClick: decreaseQuantity, className: "px-2 py-1", children: "-" }),
1574
+ /* @__PURE__ */ jsx5(
1575
+ "input",
1576
+ {
1577
+ className: "w-8 bg-transparent text-center",
1578
+ value: quantityString,
1579
+ onInput: (e) => {
1580
+ setNewQuantity(e.currentTarget.value);
1581
+ },
1582
+ type: "text"
1583
+ }
1584
+ ),
1585
+ /* @__PURE__ */ jsx5("button", { onClick: increaseQuantity, className: "px-2 py-1", children: "+" })
1586
+ ] });
1587
+ };
1588
+
1589
+ // src/components/checkout/Skeleton.tsx
1590
+ import { jsx as jsx6 } from "react/jsx-runtime";
1591
+ function Skeleton({ className, ...props }) {
1592
+ return /* @__PURE__ */ jsx6(
1593
+ "div",
1594
+ {
1595
+ "data-slot": "skeleton",
1596
+ className: "bg-neutral-700 animate-pulse rounded-md " + className,
1597
+ ...props
1598
+ }
1599
+ );
1600
+ }
1601
+
1602
+ // src/components/checkout/CartComponentContent.tsx
1603
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1604
+ var CartComponentContent = ({ className }) => {
1605
+ var _a, _b, _c, _d, _e;
1606
+ const provider = useCartProvider();
1607
+ const { mutateAsync: removeProduct } = useMutation2(
1608
+ provider.removeProductFromCart
1609
+ );
1610
+ const { mutateAsync: updateQuantity } = useMutation2(provider.updateQuantity);
1611
+ const { mutateAsync: setCountryAsync } = useMutation2(provider.setCountry);
1612
+ const { mutateAsync: clearCart } = useMutation2(provider.clearCart);
1613
+ const [errMsg, setErrMsg] = React.useState("");
1614
+ const [isCountryOpen, setIsCountryOpen] = React.useState(false);
1615
+ const {
1616
+ mutateAsync: continueToCheckoutAsync,
1617
+ isLoading: isContinueToCheckoutLoading
1618
+ } = useMutation2(provider.redirectToNextStep);
1619
+ const { data: availableCountries } = useQuery3(
1620
+ "cart-available-countries",
1621
+ provider.getAvailableCountries
1622
+ );
1623
+ const { data: isApplePayAvailable } = useQuery3("cart-one-click-payment", provider.checkIfApplePayIsAvailable);
1624
+ const { data, isLoading, refetch } = useQuery3("cart", provider.getProducts);
1625
+ const { data: countryData, refetch: refetchCountry } = useQuery3(
1626
+ "cart-country",
1627
+ provider.getCountry
1628
+ );
1629
+ const [productsParent] = useAutoAnimate(
1630
+ /* optional config */
1631
+ );
1632
+ const products = isErr(data) ? void 0 : data;
1633
+ const countries = isErr(availableCountries) ? [] : availableCountries;
1634
+ const sumOfProducts = (_a = products == null ? void 0 : products.reduce((prev, curr) => {
1635
+ if (curr.details == null) {
1636
+ return prev;
1637
+ }
1638
+ return prev + curr.details.price * curr.quantity;
1639
+ }, 0)) != null ? _a : 0;
1640
+ const currency = (_d = (_c = (_b = products == null ? void 0 : products[0]) == null ? void 0 : _b.details) == null ? void 0 : _c.currency) != null ? _d : "PLN";
1641
+ const isSomeProductDeliverable = (_e = products == null ? void 0 : products.some((product) => {
1642
+ var _a2;
1643
+ return ((_a2 = product.details) == null ? void 0 : _a2.isDeliverable) === true;
1644
+ })) != null ? _e : false;
1645
+ const selectedCountry = countryData != null && !isErr(countryData) && countryData != "" ? countryData : void 0;
1646
+ async function shouldUpdate(id, newQuantity) {
1647
+ if (newQuantity != null) {
1648
+ if (newQuantity <= 0) {
1649
+ await removeProduct({ id });
1650
+ await refetch();
1651
+ return;
1652
+ }
1653
+ await updateQuantity({
1654
+ id,
1655
+ quantity: newQuantity
1656
+ });
1657
+ await refetch();
1658
+ return;
1659
+ }
1660
+ }
1661
+ async function continueToCheckout() {
1662
+ try {
1663
+ setErrMsg("");
1664
+ const response = await continueToCheckoutAsync();
1665
+ if (isErr(response)) {
1666
+ setErrMsg(`${response.error}`);
1667
+ return;
1668
+ }
1669
+ await clearCart();
1670
+ window.location.href = response.url;
1671
+ } catch (e) {
1672
+ setErrMsg(`${e}`);
1673
+ }
1674
+ }
1675
+ return /* @__PURE__ */ jsxs4("div", { className: `${className} flex flex-col`, ref: productsParent, children: [
1676
+ isLoading && /* @__PURE__ */ jsxs4("div", { className: "relative flex w-full justify-center flex-col gap-4", children: [
1677
+ /* @__PURE__ */ jsx7(Skeleton, { className: "w-full h-32" }),
1678
+ /* @__PURE__ */ jsx7(Skeleton, { className: "w-full h-32" })
1679
+ ] }),
1680
+ !isLoading && (products == null || products.length == 0) && /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-4 p-4", children: /* @__PURE__ */ jsx7("p", { className: "dark:text-neutral-400 text-neutral-700", children: "Brak produkt\xF3w w koszyku." }) }),
1681
+ /* @__PURE__ */ jsx7(
1682
+ "div",
1683
+ {
1684
+ className: "max-h-[70vh] overflow-clip overflow-y-scroll",
1685
+ children: products != null && products.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "mt-5", children: products.map((product) => /* @__PURE__ */ jsx7(React.Fragment, { children: product.details != null && /* @__PURE__ */ jsxs4("li", { className: "mb-3", children: [
1686
+ /* @__PURE__ */ jsx7(
1687
+ SingleProduct_default,
1688
+ {
1689
+ quantity: product.quantity,
1690
+ details: product.details,
1691
+ shouldUpdate: (newQuantity) => {
1692
+ shouldUpdate(product.id, newQuantity).then().catch();
1693
+ }
1694
+ }
1695
+ ),
1696
+ /* @__PURE__ */ jsx7("hr", { className: "h-1 dark:border-neutral-700 border-neutral-400" })
1697
+ ] }) }, product.id)) })
1698
+ }
1699
+ ),
1700
+ /* @__PURE__ */ jsx7("div", { className: "grow" }),
1701
+ sumOfProducts > 0 && currency != null && /* @__PURE__ */ jsxs4(Fragment4, { children: [
1702
+ /* @__PURE__ */ jsx7("div", { className: "mx-3 flex flex-col", children: /* @__PURE__ */ jsxs4(
1703
+ "div",
1704
+ {
1705
+ className: "flex flex-row justify-between text-lg",
1706
+ children: [
1707
+ /* @__PURE__ */ jsx7(
1708
+ "p",
1709
+ {
1710
+ className: "dark:text-neutral-200 text-neutral-800 text-xl",
1711
+ children: "Suma:"
1712
+ }
1713
+ ),
1714
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-end", children: [
1715
+ /* @__PURE__ */ jsx7(
1716
+ "p",
1717
+ {
1718
+ className: "dark:text-neutral-200 text-neutral-800 font-medium",
1719
+ children: formatCurrency(sumOfProducts, currency)
1720
+ }
1721
+ ),
1722
+ isSomeProductDeliverable && /* @__PURE__ */ jsx7("p", { className: "opacity-70 text-right text-base", children: "+ dostawa" })
1723
+ ] })
1724
+ ]
1725
+ }
1726
+ ) }),
1727
+ countries && (countries == null ? void 0 : countries.length) > 1 && /* @__PURE__ */ jsxs4("div", { children: [
1728
+ /* @__PURE__ */ jsx7(
1729
+ "h4",
1730
+ {
1731
+ className: "ml-3 text-sm dark:text-neutral-400 text-neutral-700",
1732
+ children: "Wybierz kraj"
1733
+ }
1734
+ ),
1735
+ /* @__PURE__ */ jsx7(
1736
+ CountrySelector_default,
1737
+ {
1738
+ id: Math.random().toString(),
1739
+ open: isCountryOpen,
1740
+ onToggle: () => {
1741
+ setIsCountryOpen(!isCountryOpen);
1742
+ },
1743
+ onChange: (newValue) => {
1744
+ setCountryAsync(newValue).then(() => {
1745
+ refetchCountry().then().catch();
1746
+ });
1747
+ },
1748
+ selectedValue: selectedCountry != null ? selectedCountry : "",
1749
+ countries
1750
+ }
1751
+ )
1752
+ ] }),
1753
+ /* @__PURE__ */ jsxs4("div", { className: "mb-3 flex flex-col", children: [
1754
+ isApplePayAvailable && products != null && products.length > 0 && /* @__PURE__ */ jsx7("div", { className: "w-full px-2", children: /* @__PURE__ */ jsx7(ApplePay_default, { colorType: "white", style: { width: "100%" }, items: products == null ? void 0 : products.map((el) => {
1755
+ var _a2, _b2, _c2, _d2, _e2, _f;
1756
+ return {
1757
+ name: (_b2 = (_a2 = el.details) == null ? void 0 : _a2.name) != null ? _b2 : "",
1758
+ id: el.productID,
1759
+ price: (_d2 = (_c2 = el.details) == null ? void 0 : _c2.price) != null ? _d2 : 0,
1760
+ quantity: el.quantity,
1761
+ isDeliverable: (_f = (_e2 = el.details) == null ? void 0 : _e2.isDeliverable) != null ? _f : false,
1762
+ metadata: el.metadata
1763
+ };
1764
+ }) }) }),
1765
+ products != null && products.length > 0 && /* @__PURE__ */ jsx7("div", { className: "w-full px-2", children: /* @__PURE__ */ jsx7(GooglePay_default, { buttonSizeMode: "fill", buttonColor: "white", style: { width: "100%" }, items: products == null ? void 0 : products.map((el) => {
1766
+ var _a2, _b2, _c2, _d2, _e2, _f;
1767
+ return {
1768
+ name: (_b2 = (_a2 = el.details) == null ? void 0 : _a2.name) != null ? _b2 : "",
1769
+ id: el.productID,
1770
+ price: (_d2 = (_c2 = el.details) == null ? void 0 : _c2.price) != null ? _d2 : 0,
1771
+ quantity: el.quantity,
1772
+ isDeliverable: (_f = (_e2 = el.details) == null ? void 0 : _e2.isDeliverable) != null ? _f : false,
1773
+ metadata: el.metadata
1774
+ };
1775
+ }) }) }),
1776
+ /* @__PURE__ */ jsx7(
1777
+ "button",
1778
+ {
1779
+ onClick: continueToCheckout,
1780
+ disabled: isLoading || isContinueToCheckoutLoading || selectedCountry == null,
1781
+ className: "px-3 py-2 my-2 mx-2 rounded-md disabled:opacity-40 disabled:cursor-not-allowed dark:bg-neutral-300 dark:hover:bg-neutral-100 dark:text-neutral-800 hover:bg-neutral-900 text-neutral-200 bg-neutral-800 transition font-bold",
1782
+ children: isContinueToCheckoutLoading ? "\u0141adowanie..." : "Nast\u0119pny krok"
1783
+ }
1784
+ ),
1785
+ errMsg.length > 0 && /* @__PURE__ */ jsx7("p", { className: "text-red-500 text-sm text-center", children: errMsg })
1786
+ ] })
1787
+ ] })
1788
+ ] });
1789
+ };
1790
+ var CartComponentContent_default = CartComponentContent;
1791
+
1792
+ // src/components/checkout/CartComponent.tsx
1793
+ import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1794
+ function CartComponent({ isVisible, shouldHide }) {
1795
+ const [parent] = useAutoAnimate2(
1796
+ /* optional config */
1797
+ );
1798
+ return /* @__PURE__ */ jsx8("div", { ref: parent, className: "z-[999999]", children: isVisible && /* @__PURE__ */ jsxs5(Fragment5, { children: [
1799
+ /* @__PURE__ */ jsx8(
1800
+ "div",
1801
+ {
1802
+ className: "fixed top-0 right-0 left-0 bottom-0 bg-black/30 cursor-pointer",
1803
+ onClick: shouldHide
1804
+ }
1805
+ ),
1806
+ /* @__PURE__ */ jsxs5(
1807
+ "div",
1808
+ {
1809
+ className: "fixed top-0 right-0 bottom-0 w-full md:w-[350px] xl:w-[420px] dark:bg-neutral-900 bg-neutral-300 dark:text-neutral-200 text-neutral-900 flex flex-col",
1810
+ children: [
1811
+ /* @__PURE__ */ jsxs5(
1812
+ "div",
1813
+ {
1814
+ className: "mx-3 mt-7 flex justify-between items-center",
1815
+ children: [
1816
+ /* @__PURE__ */ jsx8("h1", { className: "text-2xl font-medium", children: "Koszyk" }),
1817
+ /* @__PURE__ */ jsx8(
1818
+ "button",
1819
+ {
1820
+ className: "rounded-full dark:hover:bg-neutral-700 hover:bg-neutral-400 p-2 transition",
1821
+ onClick: shouldHide,
1822
+ children: /* @__PURE__ */ jsxs5(
1823
+ "svg",
1824
+ {
1825
+ xmlns: "http://www.w3.org/2000/svg",
1826
+ width: "24",
1827
+ height: "24",
1828
+ viewBox: "0 0 24 24",
1829
+ fill: "none",
1830
+ stroke: "currentColor",
1831
+ strokeWidth: "2",
1832
+ strokeLinecap: "round",
1833
+ strokeLinejoin: "round",
1834
+ className: "lucide lucide-x",
1835
+ children: [
1836
+ /* @__PURE__ */ jsx8("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1837
+ /* @__PURE__ */ jsx8("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1838
+ ]
1839
+ }
1840
+ )
1841
+ }
1842
+ )
1843
+ ]
1844
+ }
1845
+ ),
1846
+ /* @__PURE__ */ jsx8(CartComponentContent_default, { className: "grow" })
1847
+ ]
1848
+ }
1849
+ )
1850
+ ] }) });
1851
+ }
1852
+ var WrapperCartComponent = (props) => {
1853
+ if (typeof window === "undefined") {
1854
+ return null;
1855
+ }
1856
+ return createPortal(
1857
+ /* @__PURE__ */ jsx8(CartProvider_default, { children: /* @__PURE__ */ jsx8(CartComponent, { ...props }) }),
1858
+ document.body
1859
+ );
1860
+ };
1861
+ var CartComponent_default = WrapperCartComponent;
1862
+
1863
+ // src/components/checkout/BitsnapCart.tsx
1864
+ import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1865
+ var cartAddToCartSchema = zod2.object({
1866
+ id: zod2.string(),
1867
+ isSubscription: zod2.boolean().default(false),
1868
+ quantity: zod2.number(),
1869
+ metadata: zod2.record(zod2.string(), zod2.string().optional()).optional()
1870
+ });
1871
+ function BitsnapCart({
1872
+ projectID,
1873
+ children,
1874
+ onVisibleChange,
1875
+ className
1876
+ }) {
1877
+ const { isCartVisible, showCart, hideCart } = useCheckoutStore();
1878
+ function sentPostMessageToIframe(msg) {
1879
+ const iframes = document.querySelectorAll("iframe");
1880
+ iframes.forEach((iframe) => {
1881
+ var _a;
1882
+ (_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(msg, "*");
1883
+ });
1884
+ }
1885
+ useEffect3(() => {
1886
+ onVisibleChange == null ? void 0 : onVisibleChange(isCartVisible);
1887
+ }, [isCartVisible]);
1888
+ useEffect3(() => {
1889
+ setProjectID(projectID);
1890
+ }, [projectID]);
1891
+ useEffect3(() => {
1892
+ if (!("cart" in window)) {
1893
+ const projectID2 = getProjectID();
1894
+ if (projectID2 == null) {
1895
+ console.warn("There is no project ID configured.");
1896
+ return;
1897
+ }
1898
+ window["cart"] = {
1899
+ buyProduct: async (args) => {
1900
+ try {
1901
+ const payload = zod2.object({
1902
+ productID: zod2.string(),
1903
+ email: zod2.string().optional(),
1904
+ name: zod2.string().optional(),
1905
+ country: zod2.string().optional(),
1906
+ marketingAgreement: zod2.boolean().optional()
1907
+ }).parse(args);
1908
+ const methods = getCheckoutMethods(projectID2);
1909
+ const result = await methods.justRedirectToPayment(payload);
1910
+ console.log("result", result);
1911
+ if (isErr(result) == false) {
1912
+ window.location.href = result.url;
1913
+ } else {
1914
+ alert(
1915
+ "Nie uda\u0142o si\u0119 przekierowa\u0107 do p\u0142atno\u015Bci. Spr\xF3buj ponownie p\xF3\u017Aniej."
1916
+ );
1917
+ }
1918
+ } catch (e) {
1919
+ console.warn(e);
1920
+ }
1921
+ }
1922
+ };
1923
+ }
1924
+ }, []);
1925
+ async function handleAddingToCart(id, payload) {
1926
+ const projectID2 = getProjectID();
1927
+ if (projectID2 == null) {
1928
+ console.warn("There is no project ID configured.");
1929
+ return;
1930
+ }
1931
+ try {
1932
+ const data = cartAddToCartSchema.parse(payload);
1933
+ if (data.isSubscription) {
1934
+ await handleAddingSubscriptionToCart(projectID2, data);
1935
+ return;
1936
+ }
1937
+ const methods = getCheckoutMethods(projectID2);
1938
+ await methods.addProduct({
1939
+ productID: data.id,
1940
+ quantity: data.quantity,
1941
+ metadata: data.metadata
1942
+ });
1943
+ sentPostMessageToIframe({
1944
+ id,
1945
+ type: "ADD_TO_CART" /* ADD_TO_CART */,
1946
+ success: true
1947
+ });
1948
+ showCart();
1949
+ } catch (e) {
1950
+ console.warn("cannot add item to cart", e);
1951
+ }
1952
+ }
1953
+ async function handleAddingSubscriptionToCart(projectID2, event) {
1954
+ alert(
1955
+ `TODO, nie jest to jeszcze zrobione ${projectID2} ${event.id} ${event.quantity}`
1956
+ );
1957
+ }
1958
+ function setupEventListener() {
1959
+ if ("__cart_is_listening" in window) {
1960
+ return;
1961
+ }
1962
+ window["__cart_is_listening"] = true;
1963
+ window.addEventListener("message", (event) => {
1964
+ if (typeof event.data["id"] != "undefined" && typeof event.data["type"] != "undefined") {
1965
+ const { id, type } = event.data;
1966
+ switch (type) {
1967
+ case "ADD_TO_CART" /* ADD_TO_CART */.toString():
1968
+ handleAddingToCart(id, event.data["payload"]).then().catch();
1969
+ break;
1970
+ default:
1971
+ break;
1972
+ }
1973
+ }
1974
+ });
1975
+ }
1976
+ useEffect3(() => {
1977
+ var _a;
1978
+ setupEventListener();
1979
+ if (typeof window !== "undefined") {
1980
+ try {
1981
+ const parsedParams = new URLSearchParams(window.location.search);
1982
+ const refLink = (_a = parsedParams.get("ref")) != null ? _a : parsedParams.get("utm-source");
1983
+ if (typeof localStorage != "undefined" && refLink && refLink.length > 0) {
1984
+ localStorage.setItem("bitsnap-ref", refLink);
1985
+ }
1986
+ } catch (e) {
1987
+ return;
1988
+ }
1989
+ }
1990
+ }, []);
1991
+ return /* @__PURE__ */ jsxs6("span", { className: "bitsnap-checkout", children: [
1992
+ /* @__PURE__ */ jsx9(
1993
+ "button",
1994
+ {
1995
+ onClick: () => isCartVisible ? hideCart() : showCart(),
1996
+ className: className != null ? className : "relative rounded-full hover:bg-neutral-300 transition p-1",
1997
+ children: children ? /* @__PURE__ */ jsx9(Fragment6, { children }) : /* @__PURE__ */ jsxs6(
1998
+ "svg",
1999
+ {
2000
+ xmlns: "http://www.w3.org/2000/svg",
2001
+ width: "24",
2002
+ height: "24",
2003
+ viewBox: "0 0 24 24",
2004
+ fill: "none",
2005
+ stroke: "currentColor",
2006
+ strokeWidth: "2",
2007
+ strokeLinecap: "round",
2008
+ strokeLinejoin: "round",
2009
+ className: "lucide lucide-shopping-cart",
2010
+ children: [
2011
+ /* @__PURE__ */ jsx9("circle", { cx: "8", cy: "21", r: "1" }),
2012
+ /* @__PURE__ */ jsx9("circle", { cx: "19", cy: "21", r: "1" }),
2013
+ /* @__PURE__ */ jsx9("path", { d: "M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12" })
2014
+ ]
2015
+ }
2016
+ )
2017
+ }
2018
+ ),
2019
+ /* @__PURE__ */ jsx9(
2020
+ CartComponent_default,
2021
+ {
2022
+ isVisible: isCartVisible,
2023
+ shouldHide: () => {
2024
+ hideCart();
2025
+ }
2026
+ }
2027
+ )
2028
+ ] });
2029
+ }
2030
+ var BitsnapCart_default = BitsnapCart;
2031
+ export {
2032
+ ApplePay_default as ApplePayButton,
2033
+ Bitsnap,
2034
+ BitsnapCart_default as BitsnapCheckout,
2035
+ GooglePay_default as GooglePayButton,
2036
+ createCheckout,
2037
+ createPaymentURL,
2038
+ getReferenceIfPossible,
2039
+ injectReferenceToRequestIfNeeded,
2040
+ setCustomHost,
2041
+ setProjectID
2042
+ };
2043
+ //# sourceMappingURL=index.mjs.map