@superlogic/spree-pay 0.1.1 → 0.1.2
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/README.md +3 -3
- package/build/index.cjs +2649 -194
- package/build/index.css +122 -6
- package/build/index.d.cts +23 -19
- package/build/index.d.ts +23 -19
- package/build/index.js +2655 -200
- package/package.json +7 -2
package/build/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/SpreePay.tsx
|
|
2
|
-
import { useMemo as
|
|
2
|
+
import { useMemo as useMemo7 } from "react";
|
|
3
3
|
import { SWRConfig } from "swr";
|
|
4
4
|
|
|
5
5
|
// src/SpreePayContent.tsx
|
|
6
|
-
import { useCallback as
|
|
6
|
+
import { useCallback as useCallback8, useEffect as useEffect17 } from "react";
|
|
7
7
|
|
|
8
8
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
9
9
|
function r(e) {
|
|
@@ -22,12 +22,12 @@ function clsx() {
|
|
|
22
22
|
|
|
23
23
|
// ../../node_modules/tailwind-merge/dist/bundle-mjs.mjs
|
|
24
24
|
var CLASS_PART_SEPARATOR = "-";
|
|
25
|
-
var createClassGroupUtils = (
|
|
26
|
-
const classMap = createClassMap(
|
|
25
|
+
var createClassGroupUtils = (config2) => {
|
|
26
|
+
const classMap = createClassMap(config2);
|
|
27
27
|
const {
|
|
28
28
|
conflictingClassGroups,
|
|
29
29
|
conflictingClassGroupModifiers
|
|
30
|
-
} =
|
|
30
|
+
} = config2;
|
|
31
31
|
const getClassGroupId = (className) => {
|
|
32
32
|
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
33
33
|
if (classParts[0] === "" && classParts.length !== 1) {
|
|
@@ -75,11 +75,11 @@ var getGroupIdForArbitraryProperty = (className) => {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
var createClassMap = (
|
|
78
|
+
var createClassMap = (config2) => {
|
|
79
79
|
const {
|
|
80
80
|
theme,
|
|
81
81
|
classGroups
|
|
82
|
-
} =
|
|
82
|
+
} = config2;
|
|
83
83
|
const classMap = {
|
|
84
84
|
nextPart: /* @__PURE__ */ new Map(),
|
|
85
85
|
validators: []
|
|
@@ -169,11 +169,11 @@ var createLruCache = (maxCacheSize) => {
|
|
|
169
169
|
var IMPORTANT_MODIFIER = "!";
|
|
170
170
|
var MODIFIER_SEPARATOR = ":";
|
|
171
171
|
var MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
|
|
172
|
-
var createParseClassName = (
|
|
172
|
+
var createParseClassName = (config2) => {
|
|
173
173
|
const {
|
|
174
174
|
prefix,
|
|
175
175
|
experimentalParseClassName
|
|
176
|
-
} =
|
|
176
|
+
} = config2;
|
|
177
177
|
let parseClassName = (className) => {
|
|
178
178
|
const modifiers = [];
|
|
179
179
|
let bracketDepth = 0;
|
|
@@ -243,8 +243,8 @@ var stripImportantModifier = (baseClassName) => {
|
|
|
243
243
|
}
|
|
244
244
|
return baseClassName;
|
|
245
245
|
};
|
|
246
|
-
var createSortModifiers = (
|
|
247
|
-
const orderSensitiveModifiers = Object.fromEntries(
|
|
246
|
+
var createSortModifiers = (config2) => {
|
|
247
|
+
const orderSensitiveModifiers = Object.fromEntries(config2.orderSensitiveModifiers.map((modifier) => [modifier, true]));
|
|
248
248
|
const sortModifiers = (modifiers) => {
|
|
249
249
|
if (modifiers.length <= 1) {
|
|
250
250
|
return modifiers;
|
|
@@ -265,11 +265,11 @@ var createSortModifiers = (config) => {
|
|
|
265
265
|
};
|
|
266
266
|
return sortModifiers;
|
|
267
267
|
};
|
|
268
|
-
var createConfigUtils = (
|
|
269
|
-
cache: createLruCache(
|
|
270
|
-
parseClassName: createParseClassName(
|
|
271
|
-
sortModifiers: createSortModifiers(
|
|
272
|
-
...createClassGroupUtils(
|
|
268
|
+
var createConfigUtils = (config2) => ({
|
|
269
|
+
cache: createLruCache(config2.cacheSize),
|
|
270
|
+
parseClassName: createParseClassName(config2),
|
|
271
|
+
sortModifiers: createSortModifiers(config2),
|
|
272
|
+
...createClassGroupUtils(config2)
|
|
273
273
|
});
|
|
274
274
|
var SPLIT_CLASSES_REGEX = /\s+/;
|
|
275
275
|
var mergeClassList = (classList, configUtils) => {
|
|
@@ -362,8 +362,8 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
362
362
|
let cacheSet;
|
|
363
363
|
let functionToCall = initTailwindMerge;
|
|
364
364
|
function initTailwindMerge(classList) {
|
|
365
|
-
const
|
|
366
|
-
configUtils = createConfigUtils(
|
|
365
|
+
const config2 = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
366
|
+
configUtils = createConfigUtils(config2);
|
|
367
367
|
cacheGet = configUtils.cache.get;
|
|
368
368
|
cacheSet = configUtils.cache.set;
|
|
369
369
|
functionToCall = tailwindMerge;
|
|
@@ -3030,13 +3030,32 @@ var useSpreePayRegister = () => {
|
|
|
3030
3030
|
return { register: ctx.register };
|
|
3031
3031
|
};
|
|
3032
3032
|
|
|
3033
|
+
// src/utils/format.ts
|
|
3034
|
+
var formatUSD = (amount, currency = "USD") => {
|
|
3035
|
+
const formattedAmount = new Intl.NumberFormat("en-US", {
|
|
3036
|
+
style: "decimal",
|
|
3037
|
+
maximumFractionDigits: 5,
|
|
3038
|
+
minimumFractionDigits: 2
|
|
3039
|
+
}).format(amount);
|
|
3040
|
+
return `${formattedAmount} ${currency}`;
|
|
3041
|
+
};
|
|
3042
|
+
var formatCoin = (amount, currency = "USDC") => {
|
|
3043
|
+
const formattedAmount = new Intl.NumberFormat("en-US", {
|
|
3044
|
+
style: "decimal",
|
|
3045
|
+
maximumFractionDigits: 5,
|
|
3046
|
+
minimumFractionDigits: 2
|
|
3047
|
+
}).format(amount);
|
|
3048
|
+
return `${formattedAmount} ${currency}`;
|
|
3049
|
+
};
|
|
3050
|
+
|
|
3033
3051
|
// src/components/CheckoutButton.tsx
|
|
3034
3052
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
3035
3053
|
var CheckoutButton = ({ amount, onCheckout }) => {
|
|
3036
3054
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
3037
|
-
const isDisabled = !amount || !selectedPaymentMethod.method
|
|
3055
|
+
const isDisabled = !amount || !selectedPaymentMethod.method || selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */;
|
|
3056
|
+
const isUSD = selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */;
|
|
3038
3057
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col overflow-hidden rounded-[24px] border border-black/25 bg-white text-xs font-medium", children: [
|
|
3039
|
-
/* @__PURE__ */ jsx2("div", { className: "px-7 py-5", children: /* @__PURE__ */ jsxs("p", { className: "text-
|
|
3058
|
+
/* @__PURE__ */ jsx2("div", { className: "px-7 py-5", children: /* @__PURE__ */ jsxs("p", { className: "text-[#798B95]", children: [
|
|
3040
3059
|
"By clicking on the button below I acknowledge that I have read and accepted the",
|
|
3041
3060
|
" ",
|
|
3042
3061
|
/* @__PURE__ */ jsx2("a", { className: "underline", href: "/", children: "Property Policies" }),
|
|
@@ -3059,7 +3078,7 @@ var CheckoutButton = ({ amount, onCheckout }) => {
|
|
|
3059
3078
|
className: cn("bg-primary pointer w-full py-4 text-xl font-semibold text-white", {
|
|
3060
3079
|
"opacity-50": isDisabled
|
|
3061
3080
|
}),
|
|
3062
|
-
children: amount ? `Pay ${amount}` : "Checkout"
|
|
3081
|
+
children: amount ? `Pay ${isUSD ? formatUSD(amount) : formatCoin(amount)}` : "Checkout"
|
|
3063
3082
|
}
|
|
3064
3083
|
)
|
|
3065
3084
|
] });
|
|
@@ -3077,7 +3096,7 @@ var SpreeLegal = () => {
|
|
|
3077
3096
|
d: "M57.79 25.48a4.82 4.82 0 0 1-1.55-.25l.55-1.86c.34.1.65.15.92.15s.51-.1.72-.26c.21-.16.39-.43.53-.81l.2-.55-3.65-10.3h2.52l2.32 7.62h.1l2.34-7.62h2.53l-4.04 11.31c-.19.54-.44 1-.75 1.38-.31.38-.7.68-1.14.88-.45.2-.98.3-1.6.3ZM48.95 21.9a4.2 4.2 0 0 1-1.73-.35c-.5-.23-.9-.57-1.2-1.02a3 3 0 0 1-.44-1.67 2.44 2.44 0 0 1 1.18-2.3c.35-.23.76-.4 1.22-.5.46-.13.93-.21 1.42-.27l1.44-.16c.37-.05.64-.13.8-.24.18-.1.26-.27.26-.5v-.04c0-.5-.15-.88-.44-1.15-.3-.27-.72-.4-1.27-.4-.58 0-1.04.12-1.38.37-.34.26-.57.56-.69.9l-2.22-.31a3.54 3.54 0 0 1 2.35-2.47 6.29 6.29 0 0 1 3.38-.14c.48.1.92.3 1.32.56.4.26.72.6.96 1.06.25.44.37 1 .37 1.67v6.75h-2.29v-1.38h-.08a2.9 2.9 0 0 1-1.59 1.37c-.39.14-.84.22-1.37.22Zm.62-1.75c.48 0 .89-.1 1.24-.28.35-.2.62-.45.8-.77.2-.31.3-.65.3-1.03V16.9c-.08.06-.2.11-.38.17a18.34 18.34 0 0 1-1.8.32c-.36.05-.68.12-.96.23-.28.11-.5.27-.66.46-.16.2-.24.45-.24.75 0 .44.16.77.48 1 .32.22.72.33 1.22.33ZM34.43 21.7V8.23h5.05c1.03 0 1.9.2 2.6.58.7.38 1.23.91 1.6 1.59.36.67.54 1.43.54 2.28 0 .87-.18 1.63-.55 2.3a3.9 3.9 0 0 1-1.6 1.59c-.72.38-1.59.57-2.63.57H36.1v-2h3.01c.6 0 1.1-.11 1.49-.32.38-.21.67-.5.85-.87.2-.37.29-.79.29-1.27 0-.47-.1-.9-.29-1.26a1.92 1.92 0 0 0-.86-.84c-.38-.2-.88-.31-1.49-.31h-2.23v11.41h-2.44ZM14.54.46a14.54 14.54 0 1 1 0 29.08 14.54 14.54 0 0 1 0-29.08ZM5.59 18.12l-.84 3.35h.83l.84-3.35h-.83Zm1.66 0-.83 3.35h1.66l.84-3.35H7.25Zm3.35-9.58c-1.03 0-2.08.84-2.34 1.87l-1.1 4.4c-.26 1.03.37 1.87 1.4 1.87h9.64l-.34 1.44h-8.1l-.85 3.35h9.6c1.04 0 2.1-.85 2.35-1.89l1.05-4.4c.25-1.03-.38-1.85-1.4-1.85h-9.63l.36-1.44h8.13l.84-3.35H10.6Zm10.44 0-.84 3.35h1.67l.83-3.35h-1.66Zm2.5 0-.84 3.35h.83l.84-3.35h-.83Z"
|
|
3078
3097
|
}
|
|
3079
3098
|
) }),
|
|
3080
|
-
/* @__PURE__ */ jsxs2("p", { className: "text-
|
|
3099
|
+
/* @__PURE__ */ jsxs2("p", { className: "text-xs text-[#798B95]", children: [
|
|
3081
3100
|
"Spree enables seamless crypto payments for real-world goods, travel, and experiences. Enjoy secure, fast transactions and earn rewards.",
|
|
3082
3101
|
" ",
|
|
3083
3102
|
/* @__PURE__ */ jsx3("a", { className: "underline", href: "/", children: "Learn more" }),
|
|
@@ -3136,7 +3155,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
3136
3155
|
"div",
|
|
3137
3156
|
{
|
|
3138
3157
|
className: cn(
|
|
3139
|
-
"flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-
|
|
3158
|
+
"flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-3",
|
|
3140
3159
|
{
|
|
3141
3160
|
"border-primary": isSelected
|
|
3142
3161
|
}
|
|
@@ -3144,7 +3163,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
3144
3163
|
children: [
|
|
3145
3164
|
/* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4("p", { className: "text-sm font-medium text-black", children: card.schema }) }),
|
|
3146
3165
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
3147
|
-
/* @__PURE__ */ jsxs3("p", { className: "text-
|
|
3166
|
+
/* @__PURE__ */ jsxs3("p", { className: "text-sm font-medium text-[#798B95]", children: [
|
|
3148
3167
|
"Ending in ",
|
|
3149
3168
|
/* @__PURE__ */ jsx4("span", { className: "text-black", children: card.lastFourNumbers })
|
|
3150
3169
|
] }),
|
|
@@ -3229,7 +3248,7 @@ import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
|
3229
3248
|
// @__NO_SIDE_EFFECTS__
|
|
3230
3249
|
function createSlot(ownerName) {
|
|
3231
3250
|
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
3232
|
-
const
|
|
3251
|
+
const Slot22 = React2.forwardRef((props, forwardedRef) => {
|
|
3233
3252
|
const { children, ...slotProps } = props;
|
|
3234
3253
|
const childrenArray = React2.Children.toArray(children);
|
|
3235
3254
|
const slottable = childrenArray.find(isSlottable);
|
|
@@ -3247,8 +3266,8 @@ function createSlot(ownerName) {
|
|
|
3247
3266
|
}
|
|
3248
3267
|
return /* @__PURE__ */ jsx5(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
3249
3268
|
});
|
|
3250
|
-
|
|
3251
|
-
return
|
|
3269
|
+
Slot22.displayName = `${ownerName}.Slot`;
|
|
3270
|
+
return Slot22;
|
|
3252
3271
|
}
|
|
3253
3272
|
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
3254
3273
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -3313,10 +3332,10 @@ function getElementRef(element) {
|
|
|
3313
3332
|
// ../../node_modules/class-variance-authority/dist/index.mjs
|
|
3314
3333
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
3315
3334
|
var cx = clsx;
|
|
3316
|
-
var cva = (
|
|
3335
|
+
var cva = (base2, config2) => (props) => {
|
|
3317
3336
|
var _config_compoundVariants;
|
|
3318
|
-
if ((
|
|
3319
|
-
const { variants, defaultVariants } =
|
|
3337
|
+
if ((config2 === null || config2 === void 0 ? void 0 : config2.variants) == null) return cx(base2, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
3338
|
+
const { variants, defaultVariants } = config2;
|
|
3320
3339
|
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
3321
3340
|
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
3322
3341
|
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
@@ -3332,7 +3351,7 @@ var cva = (base, config) => (props) => {
|
|
|
3332
3351
|
acc[key] = value;
|
|
3333
3352
|
return acc;
|
|
3334
3353
|
}, {});
|
|
3335
|
-
const getCompoundVariantClassNames =
|
|
3354
|
+
const getCompoundVariantClassNames = config2 === null || config2 === void 0 ? void 0 : (_config_compoundVariants = config2.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
|
|
3336
3355
|
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
3337
3356
|
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
3338
3357
|
let [key, value] = param2;
|
|
@@ -3349,7 +3368,7 @@ var cva = (base, config) => (props) => {
|
|
|
3349
3368
|
cvClassName
|
|
3350
3369
|
] : acc;
|
|
3351
3370
|
}, []);
|
|
3352
|
-
return cx(
|
|
3371
|
+
return cx(base2, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
3353
3372
|
};
|
|
3354
3373
|
|
|
3355
3374
|
// ../ui/src/components/button.tsx
|
|
@@ -3397,9 +3416,25 @@ import * as React10 from "react";
|
|
|
3397
3416
|
// ../../node_modules/@radix-ui/react-context/dist/index.mjs
|
|
3398
3417
|
import * as React3 from "react";
|
|
3399
3418
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
3419
|
+
function createContext22(rootComponentName, defaultContext) {
|
|
3420
|
+
const Context = React3.createContext(defaultContext);
|
|
3421
|
+
const Provider = (props) => {
|
|
3422
|
+
const { children, ...context } = props;
|
|
3423
|
+
const value = React3.useMemo(() => context, Object.values(context));
|
|
3424
|
+
return /* @__PURE__ */ jsx7(Context.Provider, { value, children });
|
|
3425
|
+
};
|
|
3426
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
3427
|
+
function useContext22(consumerName) {
|
|
3428
|
+
const context = React3.useContext(Context);
|
|
3429
|
+
if (context) return context;
|
|
3430
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
3431
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
3432
|
+
}
|
|
3433
|
+
return [Provider, useContext22];
|
|
3434
|
+
}
|
|
3400
3435
|
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
3401
3436
|
let defaultContexts = [];
|
|
3402
|
-
function
|
|
3437
|
+
function createContext32(rootComponentName, defaultContext) {
|
|
3403
3438
|
const BaseContext = React3.createContext(defaultContext);
|
|
3404
3439
|
const index = defaultContexts.length;
|
|
3405
3440
|
defaultContexts = [...defaultContexts, defaultContext];
|
|
@@ -3432,7 +3467,7 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
|
3432
3467
|
};
|
|
3433
3468
|
};
|
|
3434
3469
|
createScope.scopeName = scopeName;
|
|
3435
|
-
return [
|
|
3470
|
+
return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
3436
3471
|
}
|
|
3437
3472
|
function composeContextScopes(...scopes) {
|
|
3438
3473
|
const baseScope = scopes[0];
|
|
@@ -3741,18 +3776,21 @@ var NODES = [
|
|
|
3741
3776
|
"ul"
|
|
3742
3777
|
];
|
|
3743
3778
|
var Primitive = NODES.reduce((primitive, node) => {
|
|
3744
|
-
const
|
|
3745
|
-
const
|
|
3779
|
+
const Slot3 = createSlot(`Primitive.${node}`);
|
|
3780
|
+
const Node2 = React9.forwardRef((props, forwardedRef) => {
|
|
3746
3781
|
const { asChild, ...primitiveProps } = props;
|
|
3747
|
-
const Comp = asChild ?
|
|
3782
|
+
const Comp = asChild ? Slot3 : node;
|
|
3748
3783
|
if (typeof window !== "undefined") {
|
|
3749
3784
|
window[Symbol.for("radix-ui")] = true;
|
|
3750
3785
|
}
|
|
3751
3786
|
return /* @__PURE__ */ jsx8(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
3752
3787
|
});
|
|
3753
|
-
|
|
3754
|
-
return { ...primitive, [node]:
|
|
3788
|
+
Node2.displayName = `Primitive.${node}`;
|
|
3789
|
+
return { ...primitive, [node]: Node2 };
|
|
3755
3790
|
}, {});
|
|
3791
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
3792
|
+
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
3793
|
+
}
|
|
3756
3794
|
|
|
3757
3795
|
// ../../node_modules/@radix-ui/react-checkbox/dist/index.mjs
|
|
3758
3796
|
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -4107,6 +4145,13 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
4107
4145
|
var __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
4108
4146
|
var Check = createLucideIcon("check", __iconNode);
|
|
4109
4147
|
|
|
4148
|
+
// ../../node_modules/lucide-react/dist/esm/icons/x.js
|
|
4149
|
+
var __iconNode2 = [
|
|
4150
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
4151
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
4152
|
+
];
|
|
4153
|
+
var X = createLucideIcon("x", __iconNode2);
|
|
4154
|
+
|
|
4110
4155
|
// ../ui/src/components/checkbox.tsx
|
|
4111
4156
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
4112
4157
|
function Checkbox2({ className, ...props }) {
|
|
@@ -4282,7 +4327,7 @@ var CreditCard = () => {
|
|
|
4282
4327
|
const [showForm, setShowForm] = useState7(false);
|
|
4283
4328
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
4284
4329
|
const { mutateCards } = useCards();
|
|
4285
|
-
const { config } = useConfig();
|
|
4330
|
+
const { config: config2 } = useConfig();
|
|
4286
4331
|
const setCard = (card) => {
|
|
4287
4332
|
setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: card });
|
|
4288
4333
|
};
|
|
@@ -4292,7 +4337,7 @@ var CreditCard = () => {
|
|
|
4292
4337
|
setShowForm(false);
|
|
4293
4338
|
};
|
|
4294
4339
|
return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
4295
|
-
/* @__PURE__ */ jsx14("h3", { className: "text-primary text-xl font-semibold", children: "Your Credit Cards" }),
|
|
4340
|
+
/* @__PURE__ */ jsx14("h3", { className: "text-primary text-xl leading-[34px] font-semibold", children: "Your Credit Cards" }),
|
|
4296
4341
|
!showForm && /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
4297
4342
|
/* @__PURE__ */ jsx14(
|
|
4298
4343
|
CardsList,
|
|
@@ -4301,173 +4346,2582 @@ var CreditCard = () => {
|
|
|
4301
4346
|
setCard
|
|
4302
4347
|
}
|
|
4303
4348
|
),
|
|
4304
|
-
|
|
4349
|
+
config2?.stripePublicKey && /* @__PURE__ */ jsx14("button", { onClick: () => setShowForm(true), className: "text-sm font-medium text-black", children: "Add new card" })
|
|
4305
4350
|
] }),
|
|
4306
|
-
|
|
4351
|
+
config2?.stripePublicKey && showForm && /* @__PURE__ */ jsx14(SripeWrapper, { saveNewCard, publicKey: config2.stripePublicKey })
|
|
4307
4352
|
] });
|
|
4308
4353
|
};
|
|
4309
4354
|
|
|
4310
|
-
// src/components/
|
|
4355
|
+
// src/components/Crypto/CryptoWrapper.tsx
|
|
4356
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4357
|
+
import NiceModal3 from "@ebay/nice-modal-react";
|
|
4358
|
+
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
|
|
4359
|
+
import { getDefaultConfig as getDefaultConfig2 } from "@rainbow-me/rainbowkit";
|
|
4360
|
+
import "@rainbow-me/rainbowkit/styles.css";
|
|
4361
|
+
import { WagmiProvider } from "wagmi";
|
|
4362
|
+
import { base } from "wagmi/chains";
|
|
4363
|
+
|
|
4364
|
+
// src/components/Crypto/Crypto.tsx
|
|
4365
|
+
import NiceModal2 from "@ebay/nice-modal-react";
|
|
4366
|
+
import { useAccount as useAccount3 } from "wagmi";
|
|
4367
|
+
|
|
4368
|
+
// src/config/symbolLogos.tsx
|
|
4311
4369
|
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4312
|
-
var
|
|
4313
|
-
|
|
4314
|
-
|
|
4370
|
+
var MOCA_SVG = /* @__PURE__ */ jsxs7("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
4371
|
+
/* @__PURE__ */ jsx15("circle", { cx: "14", cy: "14", r: "13.5", fill: "#C15F97" }),
|
|
4372
|
+
/* @__PURE__ */ jsx15(
|
|
4373
|
+
"path",
|
|
4315
4374
|
{
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
"flex w-[132px] flex-col items-baseline rounded-sm border-1 border-black px-2.5 py-1.5 text-sm text-black",
|
|
4319
|
-
{ "opacity-50": !isActive },
|
|
4320
|
-
{ "bg-primary/7 border-primary text-primary": isActive }
|
|
4321
|
-
),
|
|
4322
|
-
children
|
|
4375
|
+
fill: "#fff",
|
|
4376
|
+
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-.33Z"
|
|
4323
4377
|
}
|
|
4324
|
-
)
|
|
4325
|
-
}
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
"
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4378
|
+
),
|
|
4379
|
+
/* @__PURE__ */ jsx15("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
|
|
4380
|
+
] });
|
|
4381
|
+
var USDC_SVG = /* @__PURE__ */ jsxs7("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
4382
|
+
/* @__PURE__ */ jsxs7("g", { clipPath: "url(#clip0_528_9163)", children: [
|
|
4383
|
+
/* @__PURE__ */ jsx15("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 14Z" }),
|
|
4384
|
+
/* @__PURE__ */ jsx15(
|
|
4385
|
+
"path",
|
|
4386
|
+
{
|
|
4387
|
+
fill: "#fff",
|
|
4388
|
+
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"
|
|
4389
|
+
}
|
|
4390
|
+
),
|
|
4391
|
+
/* @__PURE__ */ jsx15(
|
|
4392
|
+
"path",
|
|
4393
|
+
{
|
|
4394
|
+
fill: "#fff",
|
|
4395
|
+
d: "M11.03 22.34a8.69 8.69 0 0 1-5.2-11.2 8.63 8.63 0 0 1 5.2-5.19c.23-.12.35-.3.35-.58v-.82c0-.23-.12-.4-.35-.47-.06 0-.18 0-.24.06a10.48 10.48 0 0 0 0 20.01c.24.12.47 0 .53-.23.06-.06.06-.12.06-.24v-.81c0-.18-.18-.41-.35-.53Zm6.18-18.2c-.23-.12-.47 0-.53.23-.05.06-.05.12-.05.24v.81c0 .24.17.47.35.59a8.69 8.69 0 0 1 5.19 11.2 8.63 8.63 0 0 1-5.2 5.19c-.23.12-.34.3-.34.58v.82c0 .23.11.4.35.47.05 0 .17 0 .23-.06a10.48 10.48 0 0 0 6.82-13.19 10.58 10.58 0 0 0-6.82-6.88Z"
|
|
4396
|
+
}
|
|
4397
|
+
)
|
|
4398
|
+
] }),
|
|
4399
|
+
/* @__PURE__ */ jsx15("defs", { children: /* @__PURE__ */ jsx15("clipPath", { id: "clip0_528_9163", children: /* @__PURE__ */ jsx15("path", { fill: "#fff", d: "M0 0h28v28H0z" }) }) })
|
|
4400
|
+
] });
|
|
4401
|
+
var USDT_SVG = /* @__PURE__ */ jsxs7("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
4402
|
+
/* @__PURE__ */ jsx15("path", { fill: "#26A17B", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28Z" }),
|
|
4403
|
+
/* @__PURE__ */ jsx15(
|
|
4404
|
+
"path",
|
|
4405
|
+
{
|
|
4406
|
+
fill: "#fff",
|
|
4407
|
+
d: "M15.5 15.3v-.01c-.1 0-.6.04-1.72.04-.88 0-1.5-.03-1.73-.04-3.42-.15-5.97-.74-5.97-1.46 0-.7 2.55-1.3 5.97-1.46v2.33a26 26 0 0 0 3.44 0v-2.32c3.42.15 5.96.74 5.96 1.46 0 .7-2.55 1.3-5.96 1.45m0-3.15v-2.08h4.76V6.89H7.3v3.17h4.76v2.08c-3.87.17-6.77.94-6.77 1.86 0 .92 2.9 1.68 6.77 1.86v6.67h3.45v-6.67c3.86-.18 6.76-.94 6.76-1.86 0-.92-2.9-1.68-6.76-1.86"
|
|
4408
|
+
}
|
|
4409
|
+
)
|
|
4410
|
+
] });
|
|
4411
|
+
var WETH_SVG = /* @__PURE__ */ jsxs7("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "28", height: "28", viewBox: "0 0 24 24", children: [
|
|
4412
|
+
/* @__PURE__ */ jsxs7("g", { clipPath: "url(#clip0_528_9173)", children: [
|
|
4413
|
+
/* @__PURE__ */ jsx15(
|
|
4414
|
+
"path",
|
|
4415
|
+
{
|
|
4416
|
+
fill: "#000",
|
|
4417
|
+
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"
|
|
4418
|
+
}
|
|
4419
|
+
),
|
|
4420
|
+
/* @__PURE__ */ jsx15(
|
|
4421
|
+
"path",
|
|
4422
|
+
{
|
|
4423
|
+
fill: "#F61F7D",
|
|
4424
|
+
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"
|
|
4425
|
+
}
|
|
4426
|
+
),
|
|
4427
|
+
/* @__PURE__ */ jsx15(
|
|
4428
|
+
"path",
|
|
4429
|
+
{
|
|
4430
|
+
fill: "#000",
|
|
4431
|
+
fillRule: "evenodd",
|
|
4432
|
+
d: "M19.19 18.27c1.87-2 3.03-4.65 3.03-7.26 0-2.52-1.39-5-3.56-6.87-2.18-1.88-5-3.05-7.65-3.05a9.54 9.54 0 0 0-9.57 9.51c0 2.57 1.33 5.31 3.42 7.44 2.1 2.13 4.8 3.5 7.38 3.5a9.7 9.7 0 0 0 6.95-3.27Zm-6.95 4.36c5.89 0 11.07-5.77 11.07-11.62C23.31 5.15 16.9 0 11.01 0A10.63 10.63 0 0 0 .34 10.6c0 5.86 6 12.03 11.9 12.03Z",
|
|
4433
|
+
clipRule: "evenodd"
|
|
4434
|
+
}
|
|
4435
|
+
),
|
|
4436
|
+
/* @__PURE__ */ jsx15("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" }),
|
|
4437
|
+
/* @__PURE__ */ jsx15(
|
|
4438
|
+
"path",
|
|
4439
|
+
{
|
|
4440
|
+
fill: "#000",
|
|
4441
|
+
fillRule: "evenodd",
|
|
4442
|
+
d: "M13.2 21.87a9.7 9.7 0 1 0 0-19.4 9.7 9.7 0 0 0 0 19.4Zm0 1.1a10.8 10.8 0 1 0 0-21.6 10.8 10.8 0 0 0 0 21.6Z",
|
|
4443
|
+
clipRule: "evenodd"
|
|
4444
|
+
}
|
|
4445
|
+
),
|
|
4446
|
+
/* @__PURE__ */ jsx15("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
|
|
4447
|
+
/* @__PURE__ */ jsx15(
|
|
4448
|
+
"path",
|
|
4449
|
+
{
|
|
4450
|
+
fill: "#000",
|
|
4451
|
+
d: "M5.83 9.94h.99l.31 3 .4-3h.78l.41 2.98.32-2.98h.98l-.63 5.15H8.37l-.45-3.1-.42 3.1H6.47l-.64-5.15ZM10.91 9.94h2.38v.78h-1.2v1.27H13v.8h-.92v1.53h1.22v.77h-2.39V9.94ZM14.64 10.79h-.81v-.85h2.78v.85h-.8v4.3h-1.17v-4.3ZM17.42 9.94h1.16v2.09h.82V9.94h1.17v5.15H19.4v-2.25h-.82v2.25h-1.16V9.94Z"
|
|
4452
|
+
}
|
|
4453
|
+
)
|
|
4454
|
+
] }),
|
|
4455
|
+
/* @__PURE__ */ jsx15("defs", { children: /* @__PURE__ */ jsx15("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ jsx15("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
|
|
4456
|
+
] });
|
|
4457
|
+
var symbolLogos = {
|
|
4458
|
+
MOCA: MOCA_SVG,
|
|
4459
|
+
USDC: USDC_SVG,
|
|
4460
|
+
USDT: USDT_SVG,
|
|
4461
|
+
WETH: WETH_SVG
|
|
4363
4462
|
};
|
|
4463
|
+
function getSymbolLogo(symbol) {
|
|
4464
|
+
return symbolLogos[symbol] ?? null;
|
|
4465
|
+
}
|
|
4364
4466
|
|
|
4365
|
-
// src/
|
|
4366
|
-
import {
|
|
4367
|
-
|
|
4368
|
-
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
4369
|
-
return /* @__PURE__ */ jsxs8("div", { className: "mb-4 rounded-2xl border border-black/25 bg-white", children: [
|
|
4370
|
-
/* @__PURE__ */ jsxs8("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
|
|
4371
|
-
/* @__PURE__ */ jsx16("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
|
|
4372
|
-
/* @__PURE__ */ jsx16(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
4373
|
-
] }),
|
|
4374
|
-
/* @__PURE__ */ jsxs8("div", { className: "px-7 py-6", children: [
|
|
4375
|
-
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx16(CreditCard, {}),
|
|
4376
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && null
|
|
4377
|
-
] })
|
|
4378
|
-
] });
|
|
4379
|
-
};
|
|
4467
|
+
// src/modals/CryptoSelectModal.tsx
|
|
4468
|
+
import { useState as useState16 } from "react";
|
|
4469
|
+
import NiceModal, { useModal } from "@ebay/nice-modal-react";
|
|
4380
4470
|
|
|
4381
|
-
//
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4471
|
+
// ../../node_modules/@radix-ui/react-dialog/dist/index.mjs
|
|
4472
|
+
import * as React28 from "react";
|
|
4473
|
+
|
|
4474
|
+
// ../../node_modules/@radix-ui/react-id/dist/index.mjs
|
|
4475
|
+
import * as React12 from "react";
|
|
4476
|
+
var useReactId = React12[" useId ".trim().toString()] || (() => void 0);
|
|
4477
|
+
var count = 0;
|
|
4478
|
+
function useId2(deterministicId) {
|
|
4479
|
+
const [id, setId] = React12.useState(useReactId());
|
|
4480
|
+
useLayoutEffect2(() => {
|
|
4481
|
+
if (!deterministicId) setId((reactId) => reactId ?? String(count++));
|
|
4482
|
+
}, [deterministicId]);
|
|
4483
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
// ../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
|
|
4487
|
+
import * as React15 from "react";
|
|
4488
|
+
|
|
4489
|
+
// ../../node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
|
|
4490
|
+
import * as React13 from "react";
|
|
4491
|
+
function useCallbackRef(callback) {
|
|
4492
|
+
const callbackRef = React13.useRef(callback);
|
|
4493
|
+
React13.useEffect(() => {
|
|
4494
|
+
callbackRef.current = callback;
|
|
4391
4495
|
});
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4496
|
+
return React13.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
4497
|
+
}
|
|
4498
|
+
|
|
4499
|
+
// ../../node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs
|
|
4500
|
+
import * as React14 from "react";
|
|
4501
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
4502
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
4503
|
+
React14.useEffect(() => {
|
|
4504
|
+
const handleKeyDown = (event) => {
|
|
4505
|
+
if (event.key === "Escape") {
|
|
4506
|
+
onEscapeKeyDown(event);
|
|
4507
|
+
}
|
|
4508
|
+
};
|
|
4509
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
4510
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
4511
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
// ../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
|
|
4515
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
4516
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
4517
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
4518
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
4519
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
4520
|
+
var originalBodyPointerEvents;
|
|
4521
|
+
var DismissableLayerContext = React15.createContext({
|
|
4522
|
+
layers: /* @__PURE__ */ new Set(),
|
|
4523
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
4524
|
+
branches: /* @__PURE__ */ new Set()
|
|
4525
|
+
});
|
|
4526
|
+
var DismissableLayer = React15.forwardRef(
|
|
4527
|
+
(props, forwardedRef) => {
|
|
4528
|
+
const {
|
|
4529
|
+
disableOutsidePointerEvents = false,
|
|
4530
|
+
onEscapeKeyDown,
|
|
4531
|
+
onPointerDownOutside,
|
|
4532
|
+
onFocusOutside,
|
|
4533
|
+
onInteractOutside,
|
|
4534
|
+
onDismiss,
|
|
4535
|
+
...layerProps
|
|
4536
|
+
} = props;
|
|
4537
|
+
const context = React15.useContext(DismissableLayerContext);
|
|
4538
|
+
const [node, setNode] = React15.useState(null);
|
|
4539
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
4540
|
+
const [, force] = React15.useState({});
|
|
4541
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
4542
|
+
const layers = Array.from(context.layers);
|
|
4543
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
4544
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
4545
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
4546
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
4547
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
4548
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
4549
|
+
const target = event.target;
|
|
4550
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
4551
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
4552
|
+
onPointerDownOutside?.(event);
|
|
4553
|
+
onInteractOutside?.(event);
|
|
4554
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
4555
|
+
}, ownerDocument);
|
|
4556
|
+
const focusOutside = useFocusOutside((event) => {
|
|
4557
|
+
const target = event.target;
|
|
4558
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
4559
|
+
if (isFocusInBranch) return;
|
|
4560
|
+
onFocusOutside?.(event);
|
|
4561
|
+
onInteractOutside?.(event);
|
|
4562
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
4563
|
+
}, ownerDocument);
|
|
4564
|
+
useEscapeKeydown((event) => {
|
|
4565
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
4566
|
+
if (!isHighestLayer) return;
|
|
4567
|
+
onEscapeKeyDown?.(event);
|
|
4568
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
4569
|
+
event.preventDefault();
|
|
4570
|
+
onDismiss();
|
|
4571
|
+
}
|
|
4572
|
+
}, ownerDocument);
|
|
4573
|
+
React15.useEffect(() => {
|
|
4574
|
+
if (!node) return;
|
|
4575
|
+
if (disableOutsidePointerEvents) {
|
|
4576
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
4577
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
4578
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
4579
|
+
}
|
|
4580
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
4581
|
+
}
|
|
4582
|
+
context.layers.add(node);
|
|
4583
|
+
dispatchUpdate();
|
|
4584
|
+
return () => {
|
|
4585
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
4586
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
4587
|
+
}
|
|
4588
|
+
};
|
|
4589
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
4590
|
+
React15.useEffect(() => {
|
|
4591
|
+
return () => {
|
|
4592
|
+
if (!node) return;
|
|
4593
|
+
context.layers.delete(node);
|
|
4594
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
4595
|
+
dispatchUpdate();
|
|
4596
|
+
};
|
|
4597
|
+
}, [node, context]);
|
|
4598
|
+
React15.useEffect(() => {
|
|
4599
|
+
const handleUpdate = () => force({});
|
|
4600
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
4601
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
4602
|
+
}, []);
|
|
4603
|
+
return /* @__PURE__ */ jsx16(
|
|
4604
|
+
Primitive.div,
|
|
4605
|
+
{
|
|
4606
|
+
...layerProps,
|
|
4607
|
+
ref: composedRefs,
|
|
4608
|
+
style: {
|
|
4609
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
4610
|
+
...props.style
|
|
4611
|
+
},
|
|
4612
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
4613
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
4614
|
+
onPointerDownCapture: composeEventHandlers(
|
|
4615
|
+
props.onPointerDownCapture,
|
|
4616
|
+
pointerDownOutside.onPointerDownCapture
|
|
4617
|
+
)
|
|
4618
|
+
}
|
|
4619
|
+
);
|
|
4620
|
+
}
|
|
4621
|
+
);
|
|
4622
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
4623
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
4624
|
+
var DismissableLayerBranch = React15.forwardRef((props, forwardedRef) => {
|
|
4625
|
+
const context = React15.useContext(DismissableLayerContext);
|
|
4626
|
+
const ref = React15.useRef(null);
|
|
4627
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
4628
|
+
React15.useEffect(() => {
|
|
4629
|
+
const node = ref.current;
|
|
4630
|
+
if (node) {
|
|
4631
|
+
context.branches.add(node);
|
|
4632
|
+
return () => {
|
|
4633
|
+
context.branches.delete(node);
|
|
4634
|
+
};
|
|
4635
|
+
}
|
|
4636
|
+
}, [context.branches]);
|
|
4637
|
+
return /* @__PURE__ */ jsx16(Primitive.div, { ...props, ref: composedRefs });
|
|
4638
|
+
});
|
|
4639
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
4640
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
4641
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
4642
|
+
const isPointerInsideReactTreeRef = React15.useRef(false);
|
|
4643
|
+
const handleClickRef = React15.useRef(() => {
|
|
4644
|
+
});
|
|
4645
|
+
React15.useEffect(() => {
|
|
4646
|
+
const handlePointerDown = (event) => {
|
|
4647
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
4648
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
4649
|
+
handleAndDispatchCustomEvent(
|
|
4650
|
+
POINTER_DOWN_OUTSIDE,
|
|
4651
|
+
handlePointerDownOutside,
|
|
4652
|
+
eventDetail,
|
|
4653
|
+
{ discrete: true }
|
|
4654
|
+
);
|
|
4655
|
+
};
|
|
4656
|
+
var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
|
|
4657
|
+
const eventDetail = { originalEvent: event };
|
|
4658
|
+
if (event.pointerType === "touch") {
|
|
4659
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
4660
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
4661
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
4662
|
+
} else {
|
|
4663
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
4664
|
+
}
|
|
4665
|
+
} else {
|
|
4666
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
4667
|
+
}
|
|
4668
|
+
isPointerInsideReactTreeRef.current = false;
|
|
4669
|
+
};
|
|
4670
|
+
const timerId = window.setTimeout(() => {
|
|
4671
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
4672
|
+
}, 0);
|
|
4673
|
+
return () => {
|
|
4674
|
+
window.clearTimeout(timerId);
|
|
4675
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
4676
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
4677
|
+
};
|
|
4678
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
4679
|
+
return {
|
|
4680
|
+
// ensures we check React component tree (not just DOM tree)
|
|
4681
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
4398
4682
|
};
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4683
|
+
}
|
|
4684
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
4685
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
4686
|
+
const isFocusInsideReactTreeRef = React15.useRef(false);
|
|
4687
|
+
React15.useEffect(() => {
|
|
4688
|
+
const handleFocus = (event) => {
|
|
4689
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
4690
|
+
const eventDetail = { originalEvent: event };
|
|
4691
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
4692
|
+
discrete: false
|
|
4693
|
+
});
|
|
4694
|
+
}
|
|
4695
|
+
};
|
|
4696
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
4697
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
4698
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
4699
|
+
return {
|
|
4700
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
4701
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
4702
|
+
};
|
|
4703
|
+
}
|
|
4704
|
+
function dispatchUpdate() {
|
|
4705
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
4706
|
+
document.dispatchEvent(event);
|
|
4707
|
+
}
|
|
4708
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
4709
|
+
const target = detail.originalEvent.target;
|
|
4710
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
4711
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
4712
|
+
if (discrete) {
|
|
4713
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
4714
|
+
} else {
|
|
4715
|
+
target.dispatchEvent(event);
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
|
|
4719
|
+
// ../../node_modules/@radix-ui/react-focus-scope/dist/index.mjs
|
|
4720
|
+
import * as React16 from "react";
|
|
4721
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
4722
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
4723
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
4724
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
4725
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
4726
|
+
var FocusScope = React16.forwardRef((props, forwardedRef) => {
|
|
4727
|
+
const {
|
|
4728
|
+
loop = false,
|
|
4729
|
+
trapped = false,
|
|
4730
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
4731
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
4732
|
+
...scopeProps
|
|
4733
|
+
} = props;
|
|
4734
|
+
const [container, setContainer] = React16.useState(null);
|
|
4735
|
+
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
4736
|
+
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
4737
|
+
const lastFocusedElementRef = React16.useRef(null);
|
|
4738
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
4739
|
+
const focusScope = React16.useRef({
|
|
4740
|
+
paused: false,
|
|
4741
|
+
pause() {
|
|
4742
|
+
this.paused = true;
|
|
4743
|
+
},
|
|
4744
|
+
resume() {
|
|
4745
|
+
this.paused = false;
|
|
4746
|
+
}
|
|
4747
|
+
}).current;
|
|
4748
|
+
React16.useEffect(() => {
|
|
4749
|
+
if (trapped) {
|
|
4750
|
+
let handleFocusIn2 = function(event) {
|
|
4751
|
+
if (focusScope.paused || !container) return;
|
|
4752
|
+
const target = event.target;
|
|
4753
|
+
if (container.contains(target)) {
|
|
4754
|
+
lastFocusedElementRef.current = target;
|
|
4755
|
+
} else {
|
|
4756
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
4757
|
+
}
|
|
4758
|
+
}, handleFocusOut2 = function(event) {
|
|
4759
|
+
if (focusScope.paused || !container) return;
|
|
4760
|
+
const relatedTarget = event.relatedTarget;
|
|
4761
|
+
if (relatedTarget === null) return;
|
|
4762
|
+
if (!container.contains(relatedTarget)) {
|
|
4763
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
4764
|
+
}
|
|
4765
|
+
}, handleMutations2 = function(mutations) {
|
|
4766
|
+
const focusedElement = document.activeElement;
|
|
4767
|
+
if (focusedElement !== document.body) return;
|
|
4768
|
+
for (const mutation of mutations) {
|
|
4769
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
4770
|
+
}
|
|
4771
|
+
};
|
|
4772
|
+
var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2, handleMutations = handleMutations2;
|
|
4773
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
4774
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
4775
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
4776
|
+
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
4777
|
+
return () => {
|
|
4778
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
4779
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
4780
|
+
mutationObserver.disconnect();
|
|
4781
|
+
};
|
|
4782
|
+
}
|
|
4783
|
+
}, [trapped, container, focusScope.paused]);
|
|
4784
|
+
React16.useEffect(() => {
|
|
4785
|
+
if (container) {
|
|
4786
|
+
focusScopesStack.add(focusScope);
|
|
4787
|
+
const previouslyFocusedElement = document.activeElement;
|
|
4788
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
4789
|
+
if (!hasFocusedCandidate) {
|
|
4790
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
4791
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
4792
|
+
container.dispatchEvent(mountEvent);
|
|
4793
|
+
if (!mountEvent.defaultPrevented) {
|
|
4794
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
4795
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
4796
|
+
focus(container);
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
return () => {
|
|
4801
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
4802
|
+
setTimeout(() => {
|
|
4803
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
4804
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
4805
|
+
container.dispatchEvent(unmountEvent);
|
|
4806
|
+
if (!unmountEvent.defaultPrevented) {
|
|
4807
|
+
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
4808
|
+
}
|
|
4809
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
4810
|
+
focusScopesStack.remove(focusScope);
|
|
4811
|
+
}, 0);
|
|
4812
|
+
};
|
|
4412
4813
|
}
|
|
4814
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
4815
|
+
const handleKeyDown = React16.useCallback(
|
|
4816
|
+
(event) => {
|
|
4817
|
+
if (!loop && !trapped) return;
|
|
4818
|
+
if (focusScope.paused) return;
|
|
4819
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
4820
|
+
const focusedElement = document.activeElement;
|
|
4821
|
+
if (isTabKey && focusedElement) {
|
|
4822
|
+
const container2 = event.currentTarget;
|
|
4823
|
+
const [first, last] = getTabbableEdges(container2);
|
|
4824
|
+
const hasTabbableElementsInside = first && last;
|
|
4825
|
+
if (!hasTabbableElementsInside) {
|
|
4826
|
+
if (focusedElement === container2) event.preventDefault();
|
|
4827
|
+
} else {
|
|
4828
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
4829
|
+
event.preventDefault();
|
|
4830
|
+
if (loop) focus(first, { select: true });
|
|
4831
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
4832
|
+
event.preventDefault();
|
|
4833
|
+
if (loop) focus(last, { select: true });
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
},
|
|
4838
|
+
[loop, trapped, focusScope.paused]
|
|
4839
|
+
);
|
|
4840
|
+
return /* @__PURE__ */ jsx17(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
4841
|
+
});
|
|
4842
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
4843
|
+
function focusFirst(candidates, { select = false } = {}) {
|
|
4844
|
+
const previouslyFocusedElement = document.activeElement;
|
|
4845
|
+
for (const candidate of candidates) {
|
|
4846
|
+
focus(candidate, { select });
|
|
4847
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
4413
4848
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4849
|
+
}
|
|
4850
|
+
function getTabbableEdges(container) {
|
|
4851
|
+
const candidates = getTabbableCandidates(container);
|
|
4852
|
+
const first = findVisible(candidates, container);
|
|
4853
|
+
const last = findVisible(candidates.reverse(), container);
|
|
4854
|
+
return [first, last];
|
|
4855
|
+
}
|
|
4856
|
+
function getTabbableCandidates(container) {
|
|
4857
|
+
const nodes = [];
|
|
4858
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
4859
|
+
acceptNode: (node) => {
|
|
4860
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
4861
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
4862
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
4863
|
+
}
|
|
4419
4864
|
});
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4865
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
4866
|
+
return nodes;
|
|
4867
|
+
}
|
|
4868
|
+
function findVisible(elements, container) {
|
|
4869
|
+
for (const element of elements) {
|
|
4870
|
+
if (!isHidden(element, { upTo: container })) return element;
|
|
4423
4871
|
}
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4872
|
+
}
|
|
4873
|
+
function isHidden(node, { upTo }) {
|
|
4874
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
4875
|
+
while (node) {
|
|
4876
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
4877
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
4878
|
+
node = node.parentElement;
|
|
4427
4879
|
}
|
|
4428
|
-
return
|
|
4429
|
-
}
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
},
|
|
4440
|
-
patch: async () => {
|
|
4441
|
-
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
4442
|
-
},
|
|
4443
|
-
delete: async () => {
|
|
4444
|
-
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
4880
|
+
return false;
|
|
4881
|
+
}
|
|
4882
|
+
function isSelectableInput(element) {
|
|
4883
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
4884
|
+
}
|
|
4885
|
+
function focus(element, { select = false } = {}) {
|
|
4886
|
+
if (element && element.focus) {
|
|
4887
|
+
const previouslyFocusedElement = document.activeElement;
|
|
4888
|
+
element.focus({ preventScroll: true });
|
|
4889
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
4890
|
+
element.select();
|
|
4445
4891
|
}
|
|
4446
|
-
}
|
|
4447
|
-
var
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
return request("POST", url, body);
|
|
4459
|
-
},
|
|
4460
|
-
put: async (key, body) => {
|
|
4461
|
-
const url = buildUrl(key);
|
|
4462
|
-
return request("PUT", url, body);
|
|
4463
|
-
},
|
|
4464
|
-
patch: async (key, body) => {
|
|
4465
|
-
const url = buildUrl(key);
|
|
4466
|
-
return request("PATCH", url, body);
|
|
4892
|
+
}
|
|
4893
|
+
var focusScopesStack = createFocusScopesStack();
|
|
4894
|
+
function createFocusScopesStack() {
|
|
4895
|
+
let stack = [];
|
|
4896
|
+
return {
|
|
4897
|
+
add(focusScope) {
|
|
4898
|
+
const activeFocusScope = stack[0];
|
|
4899
|
+
if (focusScope !== activeFocusScope) {
|
|
4900
|
+
activeFocusScope?.pause();
|
|
4901
|
+
}
|
|
4902
|
+
stack = arrayRemove(stack, focusScope);
|
|
4903
|
+
stack.unshift(focusScope);
|
|
4467
4904
|
},
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4905
|
+
remove(focusScope) {
|
|
4906
|
+
stack = arrayRemove(stack, focusScope);
|
|
4907
|
+
stack[0]?.resume();
|
|
4908
|
+
}
|
|
4909
|
+
};
|
|
4910
|
+
}
|
|
4911
|
+
function arrayRemove(array, item) {
|
|
4912
|
+
const updatedArray = [...array];
|
|
4913
|
+
const index = updatedArray.indexOf(item);
|
|
4914
|
+
if (index !== -1) {
|
|
4915
|
+
updatedArray.splice(index, 1);
|
|
4916
|
+
}
|
|
4917
|
+
return updatedArray;
|
|
4918
|
+
}
|
|
4919
|
+
function removeLinks(items) {
|
|
4920
|
+
return items.filter((item) => item.tagName !== "A");
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
// ../../node_modules/@radix-ui/react-portal/dist/index.mjs
|
|
4924
|
+
import * as React17 from "react";
|
|
4925
|
+
import ReactDOM2 from "react-dom";
|
|
4926
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
4927
|
+
var PORTAL_NAME = "Portal";
|
|
4928
|
+
var Portal = React17.forwardRef((props, forwardedRef) => {
|
|
4929
|
+
const { container: containerProp, ...portalProps } = props;
|
|
4930
|
+
const [mounted, setMounted] = React17.useState(false);
|
|
4931
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
4932
|
+
const container = containerProp || mounted && globalThis?.document?.body;
|
|
4933
|
+
return container ? ReactDOM2.createPortal(/* @__PURE__ */ jsx18(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
4934
|
+
});
|
|
4935
|
+
Portal.displayName = PORTAL_NAME;
|
|
4936
|
+
|
|
4937
|
+
// ../../node_modules/@radix-ui/react-focus-guards/dist/index.mjs
|
|
4938
|
+
import * as React18 from "react";
|
|
4939
|
+
var count2 = 0;
|
|
4940
|
+
function useFocusGuards() {
|
|
4941
|
+
React18.useEffect(() => {
|
|
4942
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
4943
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
4944
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
4945
|
+
count2++;
|
|
4946
|
+
return () => {
|
|
4947
|
+
if (count2 === 1) {
|
|
4948
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
4949
|
+
}
|
|
4950
|
+
count2--;
|
|
4951
|
+
};
|
|
4952
|
+
}, []);
|
|
4953
|
+
}
|
|
4954
|
+
function createFocusGuard() {
|
|
4955
|
+
const element = document.createElement("span");
|
|
4956
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
4957
|
+
element.tabIndex = 0;
|
|
4958
|
+
element.style.outline = "none";
|
|
4959
|
+
element.style.opacity = "0";
|
|
4960
|
+
element.style.position = "fixed";
|
|
4961
|
+
element.style.pointerEvents = "none";
|
|
4962
|
+
return element;
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
// ../../node_modules/tslib/tslib.es6.mjs
|
|
4966
|
+
var __assign = function() {
|
|
4967
|
+
__assign = Object.assign || function __assign2(t) {
|
|
4968
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4969
|
+
s = arguments[i];
|
|
4970
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
4971
|
+
}
|
|
4972
|
+
return t;
|
|
4973
|
+
};
|
|
4974
|
+
return __assign.apply(this, arguments);
|
|
4975
|
+
};
|
|
4976
|
+
function __rest(s, e) {
|
|
4977
|
+
var t = {};
|
|
4978
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4979
|
+
t[p] = s[p];
|
|
4980
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
4981
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
4982
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
4983
|
+
t[p[i]] = s[p[i]];
|
|
4984
|
+
}
|
|
4985
|
+
return t;
|
|
4986
|
+
}
|
|
4987
|
+
function __spreadArray(to, from, pack) {
|
|
4988
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4989
|
+
if (ar || !(i in from)) {
|
|
4990
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
4991
|
+
ar[i] = from[i];
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4995
|
+
}
|
|
4996
|
+
|
|
4997
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
4998
|
+
import * as React27 from "react";
|
|
4999
|
+
|
|
5000
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
5001
|
+
import * as React21 from "react";
|
|
5002
|
+
|
|
5003
|
+
// ../../node_modules/react-remove-scroll-bar/dist/es2015/constants.js
|
|
5004
|
+
var zeroRightClassName = "right-scroll-bar-position";
|
|
5005
|
+
var fullWidthClassName = "width-before-scroll-bar";
|
|
5006
|
+
var noScrollbarsClassName = "with-scroll-bars-hidden";
|
|
5007
|
+
var removedBarSizeVariable = "--removed-body-scroll-bar-size";
|
|
5008
|
+
|
|
5009
|
+
// ../../node_modules/use-callback-ref/dist/es2015/assignRef.js
|
|
5010
|
+
function assignRef(ref, value) {
|
|
5011
|
+
if (typeof ref === "function") {
|
|
5012
|
+
ref(value);
|
|
5013
|
+
} else if (ref) {
|
|
5014
|
+
ref.current = value;
|
|
5015
|
+
}
|
|
5016
|
+
return ref;
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
// ../../node_modules/use-callback-ref/dist/es2015/useRef.js
|
|
5020
|
+
import { useState as useState12 } from "react";
|
|
5021
|
+
function useCallbackRef2(initialValue, callback) {
|
|
5022
|
+
var ref = useState12(function() {
|
|
5023
|
+
return {
|
|
5024
|
+
// value
|
|
5025
|
+
value: initialValue,
|
|
5026
|
+
// last callback
|
|
5027
|
+
callback,
|
|
5028
|
+
// "memoized" public interface
|
|
5029
|
+
facade: {
|
|
5030
|
+
get current() {
|
|
5031
|
+
return ref.value;
|
|
5032
|
+
},
|
|
5033
|
+
set current(value) {
|
|
5034
|
+
var last = ref.value;
|
|
5035
|
+
if (last !== value) {
|
|
5036
|
+
ref.value = value;
|
|
5037
|
+
ref.callback(value, last);
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
};
|
|
5042
|
+
})[0];
|
|
5043
|
+
ref.callback = callback;
|
|
5044
|
+
return ref.facade;
|
|
5045
|
+
}
|
|
5046
|
+
|
|
5047
|
+
// ../../node_modules/use-callback-ref/dist/es2015/useMergeRef.js
|
|
5048
|
+
import * as React19 from "react";
|
|
5049
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React19.useLayoutEffect : React19.useEffect;
|
|
5050
|
+
var currentValues = /* @__PURE__ */ new WeakMap();
|
|
5051
|
+
function useMergeRefs(refs, defaultValue) {
|
|
5052
|
+
var callbackRef = useCallbackRef2(defaultValue || null, function(newValue) {
|
|
5053
|
+
return refs.forEach(function(ref) {
|
|
5054
|
+
return assignRef(ref, newValue);
|
|
5055
|
+
});
|
|
5056
|
+
});
|
|
5057
|
+
useIsomorphicLayoutEffect(function() {
|
|
5058
|
+
var oldValue = currentValues.get(callbackRef);
|
|
5059
|
+
if (oldValue) {
|
|
5060
|
+
var prevRefs_1 = new Set(oldValue);
|
|
5061
|
+
var nextRefs_1 = new Set(refs);
|
|
5062
|
+
var current_1 = callbackRef.current;
|
|
5063
|
+
prevRefs_1.forEach(function(ref) {
|
|
5064
|
+
if (!nextRefs_1.has(ref)) {
|
|
5065
|
+
assignRef(ref, null);
|
|
5066
|
+
}
|
|
5067
|
+
});
|
|
5068
|
+
nextRefs_1.forEach(function(ref) {
|
|
5069
|
+
if (!prevRefs_1.has(ref)) {
|
|
5070
|
+
assignRef(ref, current_1);
|
|
5071
|
+
}
|
|
5072
|
+
});
|
|
5073
|
+
}
|
|
5074
|
+
currentValues.set(callbackRef, refs);
|
|
5075
|
+
}, [refs]);
|
|
5076
|
+
return callbackRef;
|
|
5077
|
+
}
|
|
5078
|
+
|
|
5079
|
+
// ../../node_modules/use-sidecar/dist/es2015/medium.js
|
|
5080
|
+
function ItoI(a) {
|
|
5081
|
+
return a;
|
|
5082
|
+
}
|
|
5083
|
+
function innerCreateMedium(defaults, middleware) {
|
|
5084
|
+
if (middleware === void 0) {
|
|
5085
|
+
middleware = ItoI;
|
|
5086
|
+
}
|
|
5087
|
+
var buffer = [];
|
|
5088
|
+
var assigned = false;
|
|
5089
|
+
var medium = {
|
|
5090
|
+
read: function() {
|
|
5091
|
+
if (assigned) {
|
|
5092
|
+
throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
|
|
5093
|
+
}
|
|
5094
|
+
if (buffer.length) {
|
|
5095
|
+
return buffer[buffer.length - 1];
|
|
5096
|
+
}
|
|
5097
|
+
return defaults;
|
|
5098
|
+
},
|
|
5099
|
+
useMedium: function(data) {
|
|
5100
|
+
var item = middleware(data, assigned);
|
|
5101
|
+
buffer.push(item);
|
|
5102
|
+
return function() {
|
|
5103
|
+
buffer = buffer.filter(function(x) {
|
|
5104
|
+
return x !== item;
|
|
5105
|
+
});
|
|
5106
|
+
};
|
|
5107
|
+
},
|
|
5108
|
+
assignSyncMedium: function(cb) {
|
|
5109
|
+
assigned = true;
|
|
5110
|
+
while (buffer.length) {
|
|
5111
|
+
var cbs = buffer;
|
|
5112
|
+
buffer = [];
|
|
5113
|
+
cbs.forEach(cb);
|
|
5114
|
+
}
|
|
5115
|
+
buffer = {
|
|
5116
|
+
push: function(x) {
|
|
5117
|
+
return cb(x);
|
|
5118
|
+
},
|
|
5119
|
+
filter: function() {
|
|
5120
|
+
return buffer;
|
|
5121
|
+
}
|
|
5122
|
+
};
|
|
5123
|
+
},
|
|
5124
|
+
assignMedium: function(cb) {
|
|
5125
|
+
assigned = true;
|
|
5126
|
+
var pendingQueue = [];
|
|
5127
|
+
if (buffer.length) {
|
|
5128
|
+
var cbs = buffer;
|
|
5129
|
+
buffer = [];
|
|
5130
|
+
cbs.forEach(cb);
|
|
5131
|
+
pendingQueue = buffer;
|
|
5132
|
+
}
|
|
5133
|
+
var executeQueue = function() {
|
|
5134
|
+
var cbs2 = pendingQueue;
|
|
5135
|
+
pendingQueue = [];
|
|
5136
|
+
cbs2.forEach(cb);
|
|
5137
|
+
};
|
|
5138
|
+
var cycle = function() {
|
|
5139
|
+
return Promise.resolve().then(executeQueue);
|
|
5140
|
+
};
|
|
5141
|
+
cycle();
|
|
5142
|
+
buffer = {
|
|
5143
|
+
push: function(x) {
|
|
5144
|
+
pendingQueue.push(x);
|
|
5145
|
+
cycle();
|
|
5146
|
+
},
|
|
5147
|
+
filter: function(filter) {
|
|
5148
|
+
pendingQueue = pendingQueue.filter(filter);
|
|
5149
|
+
return buffer;
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
}
|
|
5153
|
+
};
|
|
5154
|
+
return medium;
|
|
5155
|
+
}
|
|
5156
|
+
function createSidecarMedium(options) {
|
|
5157
|
+
if (options === void 0) {
|
|
5158
|
+
options = {};
|
|
5159
|
+
}
|
|
5160
|
+
var medium = innerCreateMedium(null);
|
|
5161
|
+
medium.options = __assign({ async: true, ssr: false }, options);
|
|
5162
|
+
return medium;
|
|
5163
|
+
}
|
|
5164
|
+
|
|
5165
|
+
// ../../node_modules/use-sidecar/dist/es2015/exports.js
|
|
5166
|
+
import * as React20 from "react";
|
|
5167
|
+
var SideCar = function(_a) {
|
|
5168
|
+
var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
|
|
5169
|
+
if (!sideCar) {
|
|
5170
|
+
throw new Error("Sidecar: please provide `sideCar` property to import the right car");
|
|
5171
|
+
}
|
|
5172
|
+
var Target = sideCar.read();
|
|
5173
|
+
if (!Target) {
|
|
5174
|
+
throw new Error("Sidecar medium not found");
|
|
5175
|
+
}
|
|
5176
|
+
return React20.createElement(Target, __assign({}, rest));
|
|
5177
|
+
};
|
|
5178
|
+
SideCar.isSideCarExport = true;
|
|
5179
|
+
function exportSidecar(medium, exported) {
|
|
5180
|
+
medium.useMedium(exported);
|
|
5181
|
+
return SideCar;
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5184
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/medium.js
|
|
5185
|
+
var effectCar = createSidecarMedium();
|
|
5186
|
+
|
|
5187
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
5188
|
+
var nothing = function() {
|
|
5189
|
+
return;
|
|
5190
|
+
};
|
|
5191
|
+
var RemoveScroll = React21.forwardRef(function(props, parentRef) {
|
|
5192
|
+
var ref = React21.useRef(null);
|
|
5193
|
+
var _a = React21.useState({
|
|
5194
|
+
onScrollCapture: nothing,
|
|
5195
|
+
onWheelCapture: nothing,
|
|
5196
|
+
onTouchMoveCapture: nothing
|
|
5197
|
+
}), callbacks = _a[0], setCallbacks = _a[1];
|
|
5198
|
+
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
5199
|
+
var SideCar2 = sideCar;
|
|
5200
|
+
var containerRef = useMergeRefs([ref, parentRef]);
|
|
5201
|
+
var containerProps = __assign(__assign({}, rest), callbacks);
|
|
5202
|
+
return React21.createElement(
|
|
5203
|
+
React21.Fragment,
|
|
5204
|
+
null,
|
|
5205
|
+
enabled && React21.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
|
|
5206
|
+
forwardProps ? React21.cloneElement(React21.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React21.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
|
|
5207
|
+
);
|
|
5208
|
+
});
|
|
5209
|
+
RemoveScroll.defaultProps = {
|
|
5210
|
+
enabled: true,
|
|
5211
|
+
removeScrollBar: true,
|
|
5212
|
+
inert: false
|
|
5213
|
+
};
|
|
5214
|
+
RemoveScroll.classNames = {
|
|
5215
|
+
fullWidth: fullWidthClassName,
|
|
5216
|
+
zeroRight: zeroRightClassName
|
|
5217
|
+
};
|
|
5218
|
+
|
|
5219
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
5220
|
+
import * as React26 from "react";
|
|
5221
|
+
|
|
5222
|
+
// ../../node_modules/react-remove-scroll-bar/dist/es2015/component.js
|
|
5223
|
+
import * as React25 from "react";
|
|
5224
|
+
|
|
5225
|
+
// ../../node_modules/react-style-singleton/dist/es2015/hook.js
|
|
5226
|
+
import * as React24 from "react";
|
|
5227
|
+
|
|
5228
|
+
// ../../node_modules/get-nonce/dist/es2015/index.js
|
|
5229
|
+
var currentNonce;
|
|
5230
|
+
var getNonce = function() {
|
|
5231
|
+
if (currentNonce) {
|
|
5232
|
+
return currentNonce;
|
|
5233
|
+
}
|
|
5234
|
+
if (typeof __webpack_nonce__ !== "undefined") {
|
|
5235
|
+
return __webpack_nonce__;
|
|
5236
|
+
}
|
|
5237
|
+
return void 0;
|
|
5238
|
+
};
|
|
5239
|
+
|
|
5240
|
+
// ../../node_modules/react-style-singleton/dist/es2015/singleton.js
|
|
5241
|
+
function makeStyleTag() {
|
|
5242
|
+
if (!document)
|
|
5243
|
+
return null;
|
|
5244
|
+
var tag = document.createElement("style");
|
|
5245
|
+
tag.type = "text/css";
|
|
5246
|
+
var nonce = getNonce();
|
|
5247
|
+
if (nonce) {
|
|
5248
|
+
tag.setAttribute("nonce", nonce);
|
|
5249
|
+
}
|
|
5250
|
+
return tag;
|
|
5251
|
+
}
|
|
5252
|
+
function injectStyles(tag, css) {
|
|
5253
|
+
if (tag.styleSheet) {
|
|
5254
|
+
tag.styleSheet.cssText = css;
|
|
5255
|
+
} else {
|
|
5256
|
+
tag.appendChild(document.createTextNode(css));
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
function insertStyleTag(tag) {
|
|
5260
|
+
var head = document.head || document.getElementsByTagName("head")[0];
|
|
5261
|
+
head.appendChild(tag);
|
|
5262
|
+
}
|
|
5263
|
+
var stylesheetSingleton = function() {
|
|
5264
|
+
var counter = 0;
|
|
5265
|
+
var stylesheet = null;
|
|
5266
|
+
return {
|
|
5267
|
+
add: function(style2) {
|
|
5268
|
+
if (counter == 0) {
|
|
5269
|
+
if (stylesheet = makeStyleTag()) {
|
|
5270
|
+
injectStyles(stylesheet, style2);
|
|
5271
|
+
insertStyleTag(stylesheet);
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
counter++;
|
|
5275
|
+
},
|
|
5276
|
+
remove: function() {
|
|
5277
|
+
counter--;
|
|
5278
|
+
if (!counter && stylesheet) {
|
|
5279
|
+
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
|
5280
|
+
stylesheet = null;
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
};
|
|
5284
|
+
};
|
|
5285
|
+
|
|
5286
|
+
// ../../node_modules/react-style-singleton/dist/es2015/hook.js
|
|
5287
|
+
var styleHookSingleton = function() {
|
|
5288
|
+
var sheet = stylesheetSingleton();
|
|
5289
|
+
return function(styles, isDynamic) {
|
|
5290
|
+
React24.useEffect(function() {
|
|
5291
|
+
sheet.add(styles);
|
|
5292
|
+
return function() {
|
|
5293
|
+
sheet.remove();
|
|
5294
|
+
};
|
|
5295
|
+
}, [styles && isDynamic]);
|
|
5296
|
+
};
|
|
5297
|
+
};
|
|
5298
|
+
|
|
5299
|
+
// ../../node_modules/react-style-singleton/dist/es2015/component.js
|
|
5300
|
+
var styleSingleton = function() {
|
|
5301
|
+
var useStyle = styleHookSingleton();
|
|
5302
|
+
var Sheet = function(_a) {
|
|
5303
|
+
var styles = _a.styles, dynamic = _a.dynamic;
|
|
5304
|
+
useStyle(styles, dynamic);
|
|
5305
|
+
return null;
|
|
5306
|
+
};
|
|
5307
|
+
return Sheet;
|
|
5308
|
+
};
|
|
5309
|
+
|
|
5310
|
+
// ../../node_modules/react-remove-scroll-bar/dist/es2015/utils.js
|
|
5311
|
+
var zeroGap = {
|
|
5312
|
+
left: 0,
|
|
5313
|
+
top: 0,
|
|
5314
|
+
right: 0,
|
|
5315
|
+
gap: 0
|
|
5316
|
+
};
|
|
5317
|
+
var parse = function(x) {
|
|
5318
|
+
return parseInt(x || "", 10) || 0;
|
|
5319
|
+
};
|
|
5320
|
+
var getOffset = function(gapMode) {
|
|
5321
|
+
var cs = window.getComputedStyle(document.body);
|
|
5322
|
+
var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
|
|
5323
|
+
var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
|
|
5324
|
+
var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
|
|
5325
|
+
return [parse(left), parse(top), parse(right)];
|
|
5326
|
+
};
|
|
5327
|
+
var getGapWidth = function(gapMode) {
|
|
5328
|
+
if (gapMode === void 0) {
|
|
5329
|
+
gapMode = "margin";
|
|
5330
|
+
}
|
|
5331
|
+
if (typeof window === "undefined") {
|
|
5332
|
+
return zeroGap;
|
|
5333
|
+
}
|
|
5334
|
+
var offsets = getOffset(gapMode);
|
|
5335
|
+
var documentWidth = document.documentElement.clientWidth;
|
|
5336
|
+
var windowWidth = window.innerWidth;
|
|
5337
|
+
return {
|
|
5338
|
+
left: offsets[0],
|
|
5339
|
+
top: offsets[1],
|
|
5340
|
+
right: offsets[2],
|
|
5341
|
+
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
|
|
5342
|
+
};
|
|
5343
|
+
};
|
|
5344
|
+
|
|
5345
|
+
// ../../node_modules/react-remove-scroll-bar/dist/es2015/component.js
|
|
5346
|
+
var Style = styleSingleton();
|
|
5347
|
+
var lockAttribute = "data-scroll-locked";
|
|
5348
|
+
var getStyles = function(_a, allowRelative, gapMode, important) {
|
|
5349
|
+
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
|
|
5350
|
+
if (gapMode === void 0) {
|
|
5351
|
+
gapMode = "margin";
|
|
5352
|
+
}
|
|
5353
|
+
return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
|
|
5354
|
+
allowRelative && "position: relative ".concat(important, ";"),
|
|
5355
|
+
gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
|
5356
|
+
gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
|
|
5357
|
+
].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
|
5358
|
+
};
|
|
5359
|
+
var getCurrentUseCounter = function() {
|
|
5360
|
+
var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
|
|
5361
|
+
return isFinite(counter) ? counter : 0;
|
|
5362
|
+
};
|
|
5363
|
+
var useLockAttribute = function() {
|
|
5364
|
+
React25.useEffect(function() {
|
|
5365
|
+
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
5366
|
+
return function() {
|
|
5367
|
+
var newCounter = getCurrentUseCounter() - 1;
|
|
5368
|
+
if (newCounter <= 0) {
|
|
5369
|
+
document.body.removeAttribute(lockAttribute);
|
|
5370
|
+
} else {
|
|
5371
|
+
document.body.setAttribute(lockAttribute, newCounter.toString());
|
|
5372
|
+
}
|
|
5373
|
+
};
|
|
5374
|
+
}, []);
|
|
5375
|
+
};
|
|
5376
|
+
var RemoveScrollBar = function(_a) {
|
|
5377
|
+
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
|
|
5378
|
+
useLockAttribute();
|
|
5379
|
+
var gap = React25.useMemo(function() {
|
|
5380
|
+
return getGapWidth(gapMode);
|
|
5381
|
+
}, [gapMode]);
|
|
5382
|
+
return React25.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
|
|
5383
|
+
};
|
|
5384
|
+
|
|
5385
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
|
|
5386
|
+
var passiveSupported = false;
|
|
5387
|
+
if (typeof window !== "undefined") {
|
|
5388
|
+
try {
|
|
5389
|
+
options = Object.defineProperty({}, "passive", {
|
|
5390
|
+
get: function() {
|
|
5391
|
+
passiveSupported = true;
|
|
5392
|
+
return true;
|
|
5393
|
+
}
|
|
5394
|
+
});
|
|
5395
|
+
window.addEventListener("test", options, options);
|
|
5396
|
+
window.removeEventListener("test", options, options);
|
|
5397
|
+
} catch (err) {
|
|
5398
|
+
passiveSupported = false;
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
var options;
|
|
5402
|
+
var nonPassive = passiveSupported ? { passive: false } : false;
|
|
5403
|
+
|
|
5404
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/handleScroll.js
|
|
5405
|
+
var alwaysContainsScroll = function(node) {
|
|
5406
|
+
return node.tagName === "TEXTAREA";
|
|
5407
|
+
};
|
|
5408
|
+
var elementCanBeScrolled = function(node, overflow) {
|
|
5409
|
+
if (!(node instanceof Element)) {
|
|
5410
|
+
return false;
|
|
5411
|
+
}
|
|
5412
|
+
var styles = window.getComputedStyle(node);
|
|
5413
|
+
return (
|
|
5414
|
+
// not-not-scrollable
|
|
5415
|
+
styles[overflow] !== "hidden" && // contains scroll inside self
|
|
5416
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
|
|
5417
|
+
);
|
|
5418
|
+
};
|
|
5419
|
+
var elementCouldBeVScrolled = function(node) {
|
|
5420
|
+
return elementCanBeScrolled(node, "overflowY");
|
|
5421
|
+
};
|
|
5422
|
+
var elementCouldBeHScrolled = function(node) {
|
|
5423
|
+
return elementCanBeScrolled(node, "overflowX");
|
|
5424
|
+
};
|
|
5425
|
+
var locationCouldBeScrolled = function(axis, node) {
|
|
5426
|
+
var ownerDocument = node.ownerDocument;
|
|
5427
|
+
var current = node;
|
|
5428
|
+
do {
|
|
5429
|
+
if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
|
|
5430
|
+
current = current.host;
|
|
5431
|
+
}
|
|
5432
|
+
var isScrollable = elementCouldBeScrolled(axis, current);
|
|
5433
|
+
if (isScrollable) {
|
|
5434
|
+
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
|
5435
|
+
if (scrollHeight > clientHeight) {
|
|
5436
|
+
return true;
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
current = current.parentNode;
|
|
5440
|
+
} while (current && current !== ownerDocument.body);
|
|
5441
|
+
return false;
|
|
5442
|
+
};
|
|
5443
|
+
var getVScrollVariables = function(_a) {
|
|
5444
|
+
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
5445
|
+
return [
|
|
5446
|
+
scrollTop,
|
|
5447
|
+
scrollHeight,
|
|
5448
|
+
clientHeight
|
|
5449
|
+
];
|
|
5450
|
+
};
|
|
5451
|
+
var getHScrollVariables = function(_a) {
|
|
5452
|
+
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
5453
|
+
return [
|
|
5454
|
+
scrollLeft,
|
|
5455
|
+
scrollWidth,
|
|
5456
|
+
clientWidth
|
|
5457
|
+
];
|
|
5458
|
+
};
|
|
5459
|
+
var elementCouldBeScrolled = function(axis, node) {
|
|
5460
|
+
return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
5461
|
+
};
|
|
5462
|
+
var getScrollVariables = function(axis, node) {
|
|
5463
|
+
return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
5464
|
+
};
|
|
5465
|
+
var getDirectionFactor = function(axis, direction) {
|
|
5466
|
+
return axis === "h" && direction === "rtl" ? -1 : 1;
|
|
5467
|
+
};
|
|
5468
|
+
var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
|
|
5469
|
+
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
|
5470
|
+
var delta = directionFactor * sourceDelta;
|
|
5471
|
+
var target = event.target;
|
|
5472
|
+
var targetInLock = endTarget.contains(target);
|
|
5473
|
+
var shouldCancelScroll = false;
|
|
5474
|
+
var isDeltaPositive = delta > 0;
|
|
5475
|
+
var availableScroll = 0;
|
|
5476
|
+
var availableScrollTop = 0;
|
|
5477
|
+
do {
|
|
5478
|
+
if (!target) {
|
|
5479
|
+
break;
|
|
5480
|
+
}
|
|
5481
|
+
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
|
5482
|
+
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
|
5483
|
+
if (position || elementScroll) {
|
|
5484
|
+
if (elementCouldBeScrolled(axis, target)) {
|
|
5485
|
+
availableScroll += elementScroll;
|
|
5486
|
+
availableScrollTop += position;
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
var parent_1 = target.parentNode;
|
|
5490
|
+
target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
|
|
5491
|
+
} while (
|
|
5492
|
+
// portaled content
|
|
5493
|
+
!targetInLock && target !== document.body || // self content
|
|
5494
|
+
targetInLock && (endTarget.contains(target) || endTarget === target)
|
|
5495
|
+
);
|
|
5496
|
+
if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) {
|
|
5497
|
+
shouldCancelScroll = true;
|
|
5498
|
+
} else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) {
|
|
5499
|
+
shouldCancelScroll = true;
|
|
5500
|
+
}
|
|
5501
|
+
return shouldCancelScroll;
|
|
5502
|
+
};
|
|
5503
|
+
|
|
5504
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
5505
|
+
var getTouchXY = function(event) {
|
|
5506
|
+
return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
|
5507
|
+
};
|
|
5508
|
+
var getDeltaXY = function(event) {
|
|
5509
|
+
return [event.deltaX, event.deltaY];
|
|
5510
|
+
};
|
|
5511
|
+
var extractRef = function(ref) {
|
|
5512
|
+
return ref && "current" in ref ? ref.current : ref;
|
|
5513
|
+
};
|
|
5514
|
+
var deltaCompare = function(x, y) {
|
|
5515
|
+
return x[0] === y[0] && x[1] === y[1];
|
|
5516
|
+
};
|
|
5517
|
+
var generateStyle = function(id) {
|
|
5518
|
+
return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
|
|
5519
|
+
};
|
|
5520
|
+
var idCounter = 0;
|
|
5521
|
+
var lockStack = [];
|
|
5522
|
+
function RemoveScrollSideCar(props) {
|
|
5523
|
+
var shouldPreventQueue = React26.useRef([]);
|
|
5524
|
+
var touchStartRef = React26.useRef([0, 0]);
|
|
5525
|
+
var activeAxis = React26.useRef();
|
|
5526
|
+
var id = React26.useState(idCounter++)[0];
|
|
5527
|
+
var Style2 = React26.useState(styleSingleton)[0];
|
|
5528
|
+
var lastProps = React26.useRef(props);
|
|
5529
|
+
React26.useEffect(function() {
|
|
5530
|
+
lastProps.current = props;
|
|
5531
|
+
}, [props]);
|
|
5532
|
+
React26.useEffect(function() {
|
|
5533
|
+
if (props.inert) {
|
|
5534
|
+
document.body.classList.add("block-interactivity-".concat(id));
|
|
5535
|
+
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
5536
|
+
allow_1.forEach(function(el) {
|
|
5537
|
+
return el.classList.add("allow-interactivity-".concat(id));
|
|
5538
|
+
});
|
|
5539
|
+
return function() {
|
|
5540
|
+
document.body.classList.remove("block-interactivity-".concat(id));
|
|
5541
|
+
allow_1.forEach(function(el) {
|
|
5542
|
+
return el.classList.remove("allow-interactivity-".concat(id));
|
|
5543
|
+
});
|
|
5544
|
+
};
|
|
5545
|
+
}
|
|
5546
|
+
return;
|
|
5547
|
+
}, [props.inert, props.lockRef.current, props.shards]);
|
|
5548
|
+
var shouldCancelEvent = React26.useCallback(function(event, parent) {
|
|
5549
|
+
if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
|
|
5550
|
+
return !lastProps.current.allowPinchZoom;
|
|
5551
|
+
}
|
|
5552
|
+
var touch = getTouchXY(event);
|
|
5553
|
+
var touchStart = touchStartRef.current;
|
|
5554
|
+
var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
|
|
5555
|
+
var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
|
|
5556
|
+
var currentAxis;
|
|
5557
|
+
var target = event.target;
|
|
5558
|
+
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
|
|
5559
|
+
if ("touches" in event && moveDirection === "h" && target.type === "range") {
|
|
5560
|
+
return false;
|
|
5561
|
+
}
|
|
5562
|
+
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
5563
|
+
if (!canBeScrolledInMainDirection) {
|
|
5564
|
+
return true;
|
|
5565
|
+
}
|
|
5566
|
+
if (canBeScrolledInMainDirection) {
|
|
5567
|
+
currentAxis = moveDirection;
|
|
5568
|
+
} else {
|
|
5569
|
+
currentAxis = moveDirection === "v" ? "h" : "v";
|
|
5570
|
+
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
5571
|
+
}
|
|
5572
|
+
if (!canBeScrolledInMainDirection) {
|
|
5573
|
+
return false;
|
|
5574
|
+
}
|
|
5575
|
+
if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
|
|
5576
|
+
activeAxis.current = currentAxis;
|
|
5577
|
+
}
|
|
5578
|
+
if (!currentAxis) {
|
|
5579
|
+
return true;
|
|
5580
|
+
}
|
|
5581
|
+
var cancelingAxis = activeAxis.current || currentAxis;
|
|
5582
|
+
return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
|
|
5583
|
+
}, []);
|
|
5584
|
+
var shouldPrevent = React26.useCallback(function(_event) {
|
|
5585
|
+
var event = _event;
|
|
5586
|
+
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
|
|
5587
|
+
return;
|
|
5588
|
+
}
|
|
5589
|
+
var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
|
|
5590
|
+
var sourceEvent = shouldPreventQueue.current.filter(function(e) {
|
|
5591
|
+
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
5592
|
+
})[0];
|
|
5593
|
+
if (sourceEvent && sourceEvent.should) {
|
|
5594
|
+
if (event.cancelable) {
|
|
5595
|
+
event.preventDefault();
|
|
5596
|
+
}
|
|
5597
|
+
return;
|
|
5598
|
+
}
|
|
5599
|
+
if (!sourceEvent) {
|
|
5600
|
+
var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
|
|
5601
|
+
return node.contains(event.target);
|
|
5602
|
+
});
|
|
5603
|
+
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
5604
|
+
if (shouldStop) {
|
|
5605
|
+
if (event.cancelable) {
|
|
5606
|
+
event.preventDefault();
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
}
|
|
5610
|
+
}, []);
|
|
5611
|
+
var shouldCancel = React26.useCallback(function(name, delta, target, should) {
|
|
5612
|
+
var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
|
5613
|
+
shouldPreventQueue.current.push(event);
|
|
5614
|
+
setTimeout(function() {
|
|
5615
|
+
shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
|
|
5616
|
+
return e !== event;
|
|
5617
|
+
});
|
|
5618
|
+
}, 1);
|
|
5619
|
+
}, []);
|
|
5620
|
+
var scrollTouchStart = React26.useCallback(function(event) {
|
|
5621
|
+
touchStartRef.current = getTouchXY(event);
|
|
5622
|
+
activeAxis.current = void 0;
|
|
5623
|
+
}, []);
|
|
5624
|
+
var scrollWheel = React26.useCallback(function(event) {
|
|
5625
|
+
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
5626
|
+
}, []);
|
|
5627
|
+
var scrollTouchMove = React26.useCallback(function(event) {
|
|
5628
|
+
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
5629
|
+
}, []);
|
|
5630
|
+
React26.useEffect(function() {
|
|
5631
|
+
lockStack.push(Style2);
|
|
5632
|
+
props.setCallbacks({
|
|
5633
|
+
onScrollCapture: scrollWheel,
|
|
5634
|
+
onWheelCapture: scrollWheel,
|
|
5635
|
+
onTouchMoveCapture: scrollTouchMove
|
|
5636
|
+
});
|
|
5637
|
+
document.addEventListener("wheel", shouldPrevent, nonPassive);
|
|
5638
|
+
document.addEventListener("touchmove", shouldPrevent, nonPassive);
|
|
5639
|
+
document.addEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
5640
|
+
return function() {
|
|
5641
|
+
lockStack = lockStack.filter(function(inst) {
|
|
5642
|
+
return inst !== Style2;
|
|
5643
|
+
});
|
|
5644
|
+
document.removeEventListener("wheel", shouldPrevent, nonPassive);
|
|
5645
|
+
document.removeEventListener("touchmove", shouldPrevent, nonPassive);
|
|
5646
|
+
document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
5647
|
+
};
|
|
5648
|
+
}, []);
|
|
5649
|
+
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
5650
|
+
return React26.createElement(
|
|
5651
|
+
React26.Fragment,
|
|
5652
|
+
null,
|
|
5653
|
+
inert ? React26.createElement(Style2, { styles: generateStyle(id) }) : null,
|
|
5654
|
+
removeScrollBar ? React26.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
|
|
5655
|
+
);
|
|
5656
|
+
}
|
|
5657
|
+
function getOutermostShadowParent(node) {
|
|
5658
|
+
var shadowParent = null;
|
|
5659
|
+
while (node !== null) {
|
|
5660
|
+
if (node instanceof ShadowRoot) {
|
|
5661
|
+
shadowParent = node.host;
|
|
5662
|
+
node = node.host;
|
|
5663
|
+
}
|
|
5664
|
+
node = node.parentNode;
|
|
5665
|
+
}
|
|
5666
|
+
return shadowParent;
|
|
5667
|
+
}
|
|
5668
|
+
|
|
5669
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/sidecar.js
|
|
5670
|
+
var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
5671
|
+
|
|
5672
|
+
// ../../node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
5673
|
+
var ReactRemoveScroll = React27.forwardRef(function(props, ref) {
|
|
5674
|
+
return React27.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default }));
|
|
5675
|
+
});
|
|
5676
|
+
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
5677
|
+
var Combination_default = ReactRemoveScroll;
|
|
5678
|
+
|
|
5679
|
+
// ../../node_modules/aria-hidden/dist/es2015/index.js
|
|
5680
|
+
var getDefaultParent = function(originalTarget) {
|
|
5681
|
+
if (typeof document === "undefined") {
|
|
5682
|
+
return null;
|
|
5683
|
+
}
|
|
5684
|
+
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
5685
|
+
return sampleTarget.ownerDocument.body;
|
|
5686
|
+
};
|
|
5687
|
+
var counterMap = /* @__PURE__ */ new WeakMap();
|
|
5688
|
+
var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
5689
|
+
var markerMap = {};
|
|
5690
|
+
var lockCount = 0;
|
|
5691
|
+
var unwrapHost = function(node) {
|
|
5692
|
+
return node && (node.host || unwrapHost(node.parentNode));
|
|
5693
|
+
};
|
|
5694
|
+
var correctTargets = function(parent, targets) {
|
|
5695
|
+
return targets.map(function(target) {
|
|
5696
|
+
if (parent.contains(target)) {
|
|
5697
|
+
return target;
|
|
5698
|
+
}
|
|
5699
|
+
var correctedTarget = unwrapHost(target);
|
|
5700
|
+
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
5701
|
+
return correctedTarget;
|
|
5702
|
+
}
|
|
5703
|
+
console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
|
|
5704
|
+
return null;
|
|
5705
|
+
}).filter(function(x) {
|
|
5706
|
+
return Boolean(x);
|
|
5707
|
+
});
|
|
5708
|
+
};
|
|
5709
|
+
var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
|
|
5710
|
+
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
5711
|
+
if (!markerMap[markerName]) {
|
|
5712
|
+
markerMap[markerName] = /* @__PURE__ */ new WeakMap();
|
|
5713
|
+
}
|
|
5714
|
+
var markerCounter = markerMap[markerName];
|
|
5715
|
+
var hiddenNodes = [];
|
|
5716
|
+
var elementsToKeep = /* @__PURE__ */ new Set();
|
|
5717
|
+
var elementsToStop = new Set(targets);
|
|
5718
|
+
var keep = function(el) {
|
|
5719
|
+
if (!el || elementsToKeep.has(el)) {
|
|
5720
|
+
return;
|
|
5721
|
+
}
|
|
5722
|
+
elementsToKeep.add(el);
|
|
5723
|
+
keep(el.parentNode);
|
|
5724
|
+
};
|
|
5725
|
+
targets.forEach(keep);
|
|
5726
|
+
var deep = function(parent) {
|
|
5727
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
5728
|
+
return;
|
|
5729
|
+
}
|
|
5730
|
+
Array.prototype.forEach.call(parent.children, function(node) {
|
|
5731
|
+
if (elementsToKeep.has(node)) {
|
|
5732
|
+
deep(node);
|
|
5733
|
+
} else {
|
|
5734
|
+
try {
|
|
5735
|
+
var attr = node.getAttribute(controlAttribute);
|
|
5736
|
+
var alreadyHidden = attr !== null && attr !== "false";
|
|
5737
|
+
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
5738
|
+
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
5739
|
+
counterMap.set(node, counterValue);
|
|
5740
|
+
markerCounter.set(node, markerValue);
|
|
5741
|
+
hiddenNodes.push(node);
|
|
5742
|
+
if (counterValue === 1 && alreadyHidden) {
|
|
5743
|
+
uncontrolledNodes.set(node, true);
|
|
5744
|
+
}
|
|
5745
|
+
if (markerValue === 1) {
|
|
5746
|
+
node.setAttribute(markerName, "true");
|
|
5747
|
+
}
|
|
5748
|
+
if (!alreadyHidden) {
|
|
5749
|
+
node.setAttribute(controlAttribute, "true");
|
|
5750
|
+
}
|
|
5751
|
+
} catch (e) {
|
|
5752
|
+
console.error("aria-hidden: cannot operate on ", node, e);
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
});
|
|
5756
|
+
};
|
|
5757
|
+
deep(parentNode);
|
|
5758
|
+
elementsToKeep.clear();
|
|
5759
|
+
lockCount++;
|
|
5760
|
+
return function() {
|
|
5761
|
+
hiddenNodes.forEach(function(node) {
|
|
5762
|
+
var counterValue = counterMap.get(node) - 1;
|
|
5763
|
+
var markerValue = markerCounter.get(node) - 1;
|
|
5764
|
+
counterMap.set(node, counterValue);
|
|
5765
|
+
markerCounter.set(node, markerValue);
|
|
5766
|
+
if (!counterValue) {
|
|
5767
|
+
if (!uncontrolledNodes.has(node)) {
|
|
5768
|
+
node.removeAttribute(controlAttribute);
|
|
5769
|
+
}
|
|
5770
|
+
uncontrolledNodes.delete(node);
|
|
5771
|
+
}
|
|
5772
|
+
if (!markerValue) {
|
|
5773
|
+
node.removeAttribute(markerName);
|
|
5774
|
+
}
|
|
5775
|
+
});
|
|
5776
|
+
lockCount--;
|
|
5777
|
+
if (!lockCount) {
|
|
5778
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
5779
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
5780
|
+
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
5781
|
+
markerMap = {};
|
|
5782
|
+
}
|
|
5783
|
+
};
|
|
5784
|
+
};
|
|
5785
|
+
var hideOthers = function(originalTarget, parentNode, markerName) {
|
|
5786
|
+
if (markerName === void 0) {
|
|
5787
|
+
markerName = "data-aria-hidden";
|
|
5788
|
+
}
|
|
5789
|
+
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
5790
|
+
var activeParentNode = parentNode || getDefaultParent(originalTarget);
|
|
5791
|
+
if (!activeParentNode) {
|
|
5792
|
+
return function() {
|
|
5793
|
+
return null;
|
|
5794
|
+
};
|
|
5795
|
+
}
|
|
5796
|
+
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
|
|
5797
|
+
return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
|
|
5798
|
+
};
|
|
5799
|
+
|
|
5800
|
+
// ../../node_modules/@radix-ui/react-dialog/dist/index.mjs
|
|
5801
|
+
import { Fragment as Fragment8, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
5802
|
+
var DIALOG_NAME = "Dialog";
|
|
5803
|
+
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
5804
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
5805
|
+
var Dialog = (props) => {
|
|
5806
|
+
const {
|
|
5807
|
+
__scopeDialog,
|
|
5808
|
+
children,
|
|
5809
|
+
open: openProp,
|
|
5810
|
+
defaultOpen,
|
|
5811
|
+
onOpenChange,
|
|
5812
|
+
modal = true
|
|
5813
|
+
} = props;
|
|
5814
|
+
const triggerRef = React28.useRef(null);
|
|
5815
|
+
const contentRef = React28.useRef(null);
|
|
5816
|
+
const [open, setOpen] = useControllableState({
|
|
5817
|
+
prop: openProp,
|
|
5818
|
+
defaultProp: defaultOpen ?? false,
|
|
5819
|
+
onChange: onOpenChange,
|
|
5820
|
+
caller: DIALOG_NAME
|
|
5821
|
+
});
|
|
5822
|
+
return /* @__PURE__ */ jsx19(
|
|
5823
|
+
DialogProvider,
|
|
5824
|
+
{
|
|
5825
|
+
scope: __scopeDialog,
|
|
5826
|
+
triggerRef,
|
|
5827
|
+
contentRef,
|
|
5828
|
+
contentId: useId2(),
|
|
5829
|
+
titleId: useId2(),
|
|
5830
|
+
descriptionId: useId2(),
|
|
5831
|
+
open,
|
|
5832
|
+
onOpenChange: setOpen,
|
|
5833
|
+
onOpenToggle: React28.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
5834
|
+
modal,
|
|
5835
|
+
children
|
|
5836
|
+
}
|
|
5837
|
+
);
|
|
5838
|
+
};
|
|
5839
|
+
Dialog.displayName = DIALOG_NAME;
|
|
5840
|
+
var TRIGGER_NAME2 = "DialogTrigger";
|
|
5841
|
+
var DialogTrigger = React28.forwardRef(
|
|
5842
|
+
(props, forwardedRef) => {
|
|
5843
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
5844
|
+
const context = useDialogContext(TRIGGER_NAME2, __scopeDialog);
|
|
5845
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
5846
|
+
return /* @__PURE__ */ jsx19(
|
|
5847
|
+
Primitive.button,
|
|
5848
|
+
{
|
|
5849
|
+
type: "button",
|
|
5850
|
+
"aria-haspopup": "dialog",
|
|
5851
|
+
"aria-expanded": context.open,
|
|
5852
|
+
"aria-controls": context.contentId,
|
|
5853
|
+
"data-state": getState2(context.open),
|
|
5854
|
+
...triggerProps,
|
|
5855
|
+
ref: composedTriggerRef,
|
|
5856
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
5857
|
+
}
|
|
5858
|
+
);
|
|
5859
|
+
}
|
|
5860
|
+
);
|
|
5861
|
+
DialogTrigger.displayName = TRIGGER_NAME2;
|
|
5862
|
+
var PORTAL_NAME2 = "DialogPortal";
|
|
5863
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME2, {
|
|
5864
|
+
forceMount: void 0
|
|
5865
|
+
});
|
|
5866
|
+
var DialogPortal = (props) => {
|
|
5867
|
+
const { __scopeDialog, forceMount, children, container } = props;
|
|
5868
|
+
const context = useDialogContext(PORTAL_NAME2, __scopeDialog);
|
|
5869
|
+
return /* @__PURE__ */ jsx19(PortalProvider, { scope: __scopeDialog, forceMount, children: React28.Children.map(children, (child) => /* @__PURE__ */ jsx19(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx19(Portal, { asChild: true, container, children: child }) })) });
|
|
5870
|
+
};
|
|
5871
|
+
DialogPortal.displayName = PORTAL_NAME2;
|
|
5872
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
5873
|
+
var DialogOverlay = React28.forwardRef(
|
|
5874
|
+
(props, forwardedRef) => {
|
|
5875
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
5876
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
5877
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
5878
|
+
return context.modal ? /* @__PURE__ */ jsx19(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx19(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
5879
|
+
}
|
|
5880
|
+
);
|
|
5881
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
5882
|
+
var Slot2 = createSlot("DialogOverlay.RemoveScroll");
|
|
5883
|
+
var DialogOverlayImpl = React28.forwardRef(
|
|
5884
|
+
(props, forwardedRef) => {
|
|
5885
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
5886
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
5887
|
+
return (
|
|
5888
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
5889
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
5890
|
+
/* @__PURE__ */ jsx19(Combination_default, { as: Slot2, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx19(
|
|
5891
|
+
Primitive.div,
|
|
5892
|
+
{
|
|
5893
|
+
"data-state": getState2(context.open),
|
|
5894
|
+
...overlayProps,
|
|
5895
|
+
ref: forwardedRef,
|
|
5896
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
5897
|
+
}
|
|
5898
|
+
) })
|
|
5899
|
+
);
|
|
5900
|
+
}
|
|
5901
|
+
);
|
|
5902
|
+
var CONTENT_NAME = "DialogContent";
|
|
5903
|
+
var DialogContent = React28.forwardRef(
|
|
5904
|
+
(props, forwardedRef) => {
|
|
5905
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
5906
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
5907
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
5908
|
+
return /* @__PURE__ */ jsx19(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx19(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx19(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
5909
|
+
}
|
|
5910
|
+
);
|
|
5911
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
5912
|
+
var DialogContentModal = React28.forwardRef(
|
|
5913
|
+
(props, forwardedRef) => {
|
|
5914
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
5915
|
+
const contentRef = React28.useRef(null);
|
|
5916
|
+
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
5917
|
+
React28.useEffect(() => {
|
|
5918
|
+
const content = contentRef.current;
|
|
5919
|
+
if (content) return hideOthers(content);
|
|
5920
|
+
}, []);
|
|
5921
|
+
return /* @__PURE__ */ jsx19(
|
|
5922
|
+
DialogContentImpl,
|
|
5923
|
+
{
|
|
5924
|
+
...props,
|
|
5925
|
+
ref: composedRefs,
|
|
5926
|
+
trapFocus: context.open,
|
|
5927
|
+
disableOutsidePointerEvents: true,
|
|
5928
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
5929
|
+
event.preventDefault();
|
|
5930
|
+
context.triggerRef.current?.focus();
|
|
5931
|
+
}),
|
|
5932
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
5933
|
+
const originalEvent = event.detail.originalEvent;
|
|
5934
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
5935
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
5936
|
+
if (isRightClick) event.preventDefault();
|
|
5937
|
+
}),
|
|
5938
|
+
onFocusOutside: composeEventHandlers(
|
|
5939
|
+
props.onFocusOutside,
|
|
5940
|
+
(event) => event.preventDefault()
|
|
5941
|
+
)
|
|
5942
|
+
}
|
|
5943
|
+
);
|
|
5944
|
+
}
|
|
5945
|
+
);
|
|
5946
|
+
var DialogContentNonModal = React28.forwardRef(
|
|
5947
|
+
(props, forwardedRef) => {
|
|
5948
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
5949
|
+
const hasInteractedOutsideRef = React28.useRef(false);
|
|
5950
|
+
const hasPointerDownOutsideRef = React28.useRef(false);
|
|
5951
|
+
return /* @__PURE__ */ jsx19(
|
|
5952
|
+
DialogContentImpl,
|
|
5953
|
+
{
|
|
5954
|
+
...props,
|
|
5955
|
+
ref: forwardedRef,
|
|
5956
|
+
trapFocus: false,
|
|
5957
|
+
disableOutsidePointerEvents: false,
|
|
5958
|
+
onCloseAutoFocus: (event) => {
|
|
5959
|
+
props.onCloseAutoFocus?.(event);
|
|
5960
|
+
if (!event.defaultPrevented) {
|
|
5961
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
5962
|
+
event.preventDefault();
|
|
5963
|
+
}
|
|
5964
|
+
hasInteractedOutsideRef.current = false;
|
|
5965
|
+
hasPointerDownOutsideRef.current = false;
|
|
5966
|
+
},
|
|
5967
|
+
onInteractOutside: (event) => {
|
|
5968
|
+
props.onInteractOutside?.(event);
|
|
5969
|
+
if (!event.defaultPrevented) {
|
|
5970
|
+
hasInteractedOutsideRef.current = true;
|
|
5971
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
5972
|
+
hasPointerDownOutsideRef.current = true;
|
|
5973
|
+
}
|
|
5974
|
+
}
|
|
5975
|
+
const target = event.target;
|
|
5976
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
5977
|
+
if (targetIsTrigger) event.preventDefault();
|
|
5978
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
5979
|
+
event.preventDefault();
|
|
5980
|
+
}
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5983
|
+
);
|
|
5984
|
+
}
|
|
5985
|
+
);
|
|
5986
|
+
var DialogContentImpl = React28.forwardRef(
|
|
5987
|
+
(props, forwardedRef) => {
|
|
5988
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
5989
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
5990
|
+
const contentRef = React28.useRef(null);
|
|
5991
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
5992
|
+
useFocusGuards();
|
|
5993
|
+
return /* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
5994
|
+
/* @__PURE__ */ jsx19(
|
|
5995
|
+
FocusScope,
|
|
5996
|
+
{
|
|
5997
|
+
asChild: true,
|
|
5998
|
+
loop: true,
|
|
5999
|
+
trapped: trapFocus,
|
|
6000
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
6001
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
6002
|
+
children: /* @__PURE__ */ jsx19(
|
|
6003
|
+
DismissableLayer,
|
|
6004
|
+
{
|
|
6005
|
+
role: "dialog",
|
|
6006
|
+
id: context.contentId,
|
|
6007
|
+
"aria-describedby": context.descriptionId,
|
|
6008
|
+
"aria-labelledby": context.titleId,
|
|
6009
|
+
"data-state": getState2(context.open),
|
|
6010
|
+
...contentProps,
|
|
6011
|
+
ref: composedRefs,
|
|
6012
|
+
onDismiss: () => context.onOpenChange(false)
|
|
6013
|
+
}
|
|
6014
|
+
)
|
|
6015
|
+
}
|
|
6016
|
+
),
|
|
6017
|
+
/* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
6018
|
+
/* @__PURE__ */ jsx19(TitleWarning, { titleId: context.titleId }),
|
|
6019
|
+
/* @__PURE__ */ jsx19(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
6020
|
+
] })
|
|
6021
|
+
] });
|
|
6022
|
+
}
|
|
6023
|
+
);
|
|
6024
|
+
var TITLE_NAME = "DialogTitle";
|
|
6025
|
+
var DialogTitle = React28.forwardRef(
|
|
6026
|
+
(props, forwardedRef) => {
|
|
6027
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
6028
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
6029
|
+
return /* @__PURE__ */ jsx19(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
6030
|
+
}
|
|
6031
|
+
);
|
|
6032
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
6033
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
6034
|
+
var DialogDescription = React28.forwardRef(
|
|
6035
|
+
(props, forwardedRef) => {
|
|
6036
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
6037
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
6038
|
+
return /* @__PURE__ */ jsx19(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
6039
|
+
}
|
|
6040
|
+
);
|
|
6041
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
6042
|
+
var CLOSE_NAME = "DialogClose";
|
|
6043
|
+
var DialogClose = React28.forwardRef(
|
|
6044
|
+
(props, forwardedRef) => {
|
|
6045
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
6046
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
6047
|
+
return /* @__PURE__ */ jsx19(
|
|
6048
|
+
Primitive.button,
|
|
6049
|
+
{
|
|
6050
|
+
type: "button",
|
|
6051
|
+
...closeProps,
|
|
6052
|
+
ref: forwardedRef,
|
|
6053
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
6054
|
+
}
|
|
6055
|
+
);
|
|
6056
|
+
}
|
|
6057
|
+
);
|
|
6058
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
6059
|
+
function getState2(open) {
|
|
6060
|
+
return open ? "open" : "closed";
|
|
6061
|
+
}
|
|
6062
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
6063
|
+
var [WarningProvider, useWarningContext] = createContext22(TITLE_WARNING_NAME, {
|
|
6064
|
+
contentName: CONTENT_NAME,
|
|
6065
|
+
titleName: TITLE_NAME,
|
|
6066
|
+
docsSlug: "dialog"
|
|
6067
|
+
});
|
|
6068
|
+
var TitleWarning = ({ titleId }) => {
|
|
6069
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
6070
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
6071
|
+
|
|
6072
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
6073
|
+
|
|
6074
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
6075
|
+
React28.useEffect(() => {
|
|
6076
|
+
if (titleId) {
|
|
6077
|
+
const hasTitle = document.getElementById(titleId);
|
|
6078
|
+
if (!hasTitle) console.error(MESSAGE);
|
|
6079
|
+
}
|
|
6080
|
+
}, [MESSAGE, titleId]);
|
|
6081
|
+
return null;
|
|
6082
|
+
};
|
|
6083
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
6084
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
6085
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
6086
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
6087
|
+
React28.useEffect(() => {
|
|
6088
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
6089
|
+
if (descriptionId && describedById) {
|
|
6090
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
6091
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
6092
|
+
}
|
|
6093
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
6094
|
+
return null;
|
|
6095
|
+
};
|
|
6096
|
+
var Root2 = Dialog;
|
|
6097
|
+
var Portal2 = DialogPortal;
|
|
6098
|
+
var Overlay = DialogOverlay;
|
|
6099
|
+
var Content = DialogContent;
|
|
6100
|
+
var Title = DialogTitle;
|
|
6101
|
+
var Close = DialogClose;
|
|
6102
|
+
|
|
6103
|
+
// ../ui/src/components/dialog.tsx
|
|
6104
|
+
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
6105
|
+
function Dialog2({ ...props }) {
|
|
6106
|
+
return /* @__PURE__ */ jsx20(Root2, { "data-slot": "dialog", ...props });
|
|
6107
|
+
}
|
|
6108
|
+
function DialogPortal2({ ...props }) {
|
|
6109
|
+
return /* @__PURE__ */ jsx20(Portal2, { "data-slot": "dialog-portal", ...props });
|
|
6110
|
+
}
|
|
6111
|
+
function DialogOverlay2({ className, ...props }) {
|
|
6112
|
+
return /* @__PURE__ */ jsx20(
|
|
6113
|
+
Overlay,
|
|
6114
|
+
{
|
|
6115
|
+
"data-slot": "dialog-overlay",
|
|
6116
|
+
className: cn(
|
|
6117
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
6118
|
+
className
|
|
6119
|
+
),
|
|
6120
|
+
...props
|
|
6121
|
+
}
|
|
6122
|
+
);
|
|
6123
|
+
}
|
|
6124
|
+
function DialogContent2({
|
|
6125
|
+
className,
|
|
6126
|
+
children,
|
|
6127
|
+
showCloseButton = true,
|
|
6128
|
+
...props
|
|
6129
|
+
}) {
|
|
6130
|
+
return /* @__PURE__ */ jsxs9(DialogPortal2, { "data-slot": "dialog-portal", children: [
|
|
6131
|
+
/* @__PURE__ */ jsx20(DialogOverlay2, {}),
|
|
6132
|
+
/* @__PURE__ */ jsxs9(
|
|
6133
|
+
Content,
|
|
6134
|
+
{
|
|
6135
|
+
"data-slot": "dialog-content",
|
|
6136
|
+
className: cn(
|
|
6137
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
6138
|
+
className
|
|
6139
|
+
),
|
|
6140
|
+
...props,
|
|
6141
|
+
children: [
|
|
6142
|
+
children,
|
|
6143
|
+
showCloseButton && /* @__PURE__ */ jsxs9(
|
|
6144
|
+
Close,
|
|
6145
|
+
{
|
|
6146
|
+
"data-slot": "dialog-close",
|
|
6147
|
+
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
6148
|
+
children: [
|
|
6149
|
+
/* @__PURE__ */ jsx20(X, {}),
|
|
6150
|
+
/* @__PURE__ */ jsx20("span", { className: "sr-only", children: "Close" })
|
|
6151
|
+
]
|
|
6152
|
+
}
|
|
6153
|
+
)
|
|
6154
|
+
]
|
|
6155
|
+
}
|
|
6156
|
+
)
|
|
6157
|
+
] });
|
|
6158
|
+
}
|
|
6159
|
+
function DialogTitle2({ className, ...props }) {
|
|
6160
|
+
return /* @__PURE__ */ jsx20(
|
|
6161
|
+
Title,
|
|
6162
|
+
{
|
|
6163
|
+
"data-slot": "dialog-title",
|
|
6164
|
+
className: cn("text-lg leading-none font-semibold", className),
|
|
6165
|
+
...props
|
|
6166
|
+
}
|
|
6167
|
+
);
|
|
6168
|
+
}
|
|
6169
|
+
|
|
6170
|
+
// ../ui/src/components/input.tsx
|
|
6171
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
6172
|
+
function Input({ className, type, ...props }) {
|
|
6173
|
+
return /* @__PURE__ */ jsx21(
|
|
6174
|
+
"input",
|
|
6175
|
+
{
|
|
6176
|
+
type,
|
|
6177
|
+
"data-slot": "input",
|
|
6178
|
+
className: cn(
|
|
6179
|
+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
6180
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
6181
|
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
6182
|
+
className
|
|
6183
|
+
),
|
|
6184
|
+
...props
|
|
6185
|
+
}
|
|
6186
|
+
);
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
// ../../node_modules/@radix-ui/react-separator/dist/index.mjs
|
|
6190
|
+
import * as React29 from "react";
|
|
6191
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6192
|
+
var NAME2 = "Separator";
|
|
6193
|
+
var DEFAULT_ORIENTATION = "horizontal";
|
|
6194
|
+
var ORIENTATIONS = ["horizontal", "vertical"];
|
|
6195
|
+
var Separator = React29.forwardRef((props, forwardedRef) => {
|
|
6196
|
+
const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
|
|
6197
|
+
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
|
6198
|
+
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
|
6199
|
+
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
|
6200
|
+
return /* @__PURE__ */ jsx22(
|
|
6201
|
+
Primitive.div,
|
|
6202
|
+
{
|
|
6203
|
+
"data-orientation": orientation,
|
|
6204
|
+
...semanticProps,
|
|
6205
|
+
...domProps,
|
|
6206
|
+
ref: forwardedRef
|
|
6207
|
+
}
|
|
6208
|
+
);
|
|
6209
|
+
});
|
|
6210
|
+
Separator.displayName = NAME2;
|
|
6211
|
+
function isValidOrientation(orientation) {
|
|
6212
|
+
return ORIENTATIONS.includes(orientation);
|
|
6213
|
+
}
|
|
6214
|
+
var Root3 = Separator;
|
|
6215
|
+
|
|
6216
|
+
// ../ui/src/components/separator.tsx
|
|
6217
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
6218
|
+
function Separator2({
|
|
6219
|
+
className,
|
|
6220
|
+
orientation = "horizontal",
|
|
6221
|
+
decorative = true,
|
|
6222
|
+
...props
|
|
6223
|
+
}) {
|
|
6224
|
+
return /* @__PURE__ */ jsx23(
|
|
6225
|
+
Root3,
|
|
6226
|
+
{
|
|
6227
|
+
"data-slot": "separator",
|
|
6228
|
+
decorative,
|
|
6229
|
+
orientation,
|
|
6230
|
+
className: cn(
|
|
6231
|
+
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
|
6232
|
+
className
|
|
6233
|
+
),
|
|
6234
|
+
...props
|
|
6235
|
+
}
|
|
6236
|
+
);
|
|
6237
|
+
}
|
|
6238
|
+
|
|
6239
|
+
// src/hooks/useBaseERC20Token.ts
|
|
6240
|
+
import * as React30 from "react";
|
|
6241
|
+
import { erc20Abi, formatUnits, getAddress } from "viem";
|
|
6242
|
+
import { useAccount, usePublicClient } from "wagmi";
|
|
6243
|
+
|
|
6244
|
+
// src/config/baseTokens.ts
|
|
6245
|
+
var BASE_TOKENS = [
|
|
6246
|
+
{
|
|
6247
|
+
address: "0x2b11834ed1feaed4b4b3a86a6f571315e25a884d",
|
|
6248
|
+
chainId: 8453,
|
|
6249
|
+
decimals: 18,
|
|
6250
|
+
symbol: "MOCA",
|
|
6251
|
+
name: "Moca",
|
|
6252
|
+
logoURI: "https://assets.coingecko.com/coins/images/30046/standard/moca.png"
|
|
6253
|
+
},
|
|
6254
|
+
{
|
|
6255
|
+
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bDA02913",
|
|
6256
|
+
chainId: 8453,
|
|
6257
|
+
decimals: 6,
|
|
6258
|
+
symbol: "USDC",
|
|
6259
|
+
name: "USD Coin",
|
|
6260
|
+
logoURI: "https://cryptologos.cc/logos/usd-coin-usdc-logo.png"
|
|
6261
|
+
},
|
|
6262
|
+
{
|
|
6263
|
+
address: "0x4200000000000000000000000000000000000006",
|
|
6264
|
+
chainId: 8453,
|
|
6265
|
+
decimals: 18,
|
|
6266
|
+
symbol: "WETH",
|
|
6267
|
+
name: "Wrapped Ether",
|
|
6268
|
+
logoURI: "https://static.cdnlogo.com/logos/e/84/ethereum-eth_thumb.png"
|
|
6269
|
+
},
|
|
6270
|
+
{
|
|
6271
|
+
address: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
|
|
6272
|
+
chainId: 8453,
|
|
6273
|
+
decimals: 6,
|
|
6274
|
+
symbol: "USDT",
|
|
6275
|
+
name: "Tether USD",
|
|
6276
|
+
logoURI: "https://cryptologos.cc/logos/tether-usdt-logo.png"
|
|
6277
|
+
}
|
|
6278
|
+
];
|
|
6279
|
+
|
|
6280
|
+
// src/hooks/useBaseERC20Token.ts
|
|
6281
|
+
function useBaseERC20Token() {
|
|
6282
|
+
const { address } = useAccount();
|
|
6283
|
+
const baseClient = usePublicClient({ chainId: 8453 });
|
|
6284
|
+
const defaultClient = usePublicClient();
|
|
6285
|
+
const [rows, setRows] = React30.useState([]);
|
|
6286
|
+
const [isLoading, setLoading] = React30.useState(false);
|
|
6287
|
+
const [error, setError] = React30.useState(null);
|
|
6288
|
+
React30.useEffect(() => {
|
|
6289
|
+
let cancelled = false;
|
|
6290
|
+
async function run() {
|
|
6291
|
+
const client = baseClient ?? defaultClient;
|
|
6292
|
+
if (!address || !client) {
|
|
6293
|
+
setRows([]);
|
|
6294
|
+
return;
|
|
6295
|
+
}
|
|
6296
|
+
setLoading(true);
|
|
6297
|
+
try {
|
|
6298
|
+
const normalizedTokens = [];
|
|
6299
|
+
for (const t of BASE_TOKENS) {
|
|
6300
|
+
try {
|
|
6301
|
+
const addr = getAddress(t.address);
|
|
6302
|
+
normalizedTokens.push({ ...t, address: addr });
|
|
6303
|
+
} catch {
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
const res = await client.multicall({
|
|
6307
|
+
allowFailure: true,
|
|
6308
|
+
contracts: normalizedTokens.map((t) => ({
|
|
6309
|
+
address: t.address,
|
|
6310
|
+
abi: erc20Abi,
|
|
6311
|
+
functionName: "balanceOf",
|
|
6312
|
+
args: [address]
|
|
6313
|
+
}))
|
|
6314
|
+
});
|
|
6315
|
+
const acc = [];
|
|
6316
|
+
for (let idx = 0; idx < res.length; idx++) {
|
|
6317
|
+
const r2 = res[idx];
|
|
6318
|
+
const t = normalizedTokens[idx];
|
|
6319
|
+
if (r2.status === "success") {
|
|
6320
|
+
const raw = r2.result;
|
|
6321
|
+
if (raw > 0n) acc.push({ ...t, raw, formatted: formatUnits(raw, t.decimals) });
|
|
6322
|
+
}
|
|
6323
|
+
}
|
|
6324
|
+
if (!cancelled) setRows(acc);
|
|
6325
|
+
} catch (e) {
|
|
6326
|
+
if (!cancelled) {
|
|
6327
|
+
const msg = e instanceof Error ? e.message : "Multicall failed";
|
|
6328
|
+
setError(baseClient ? msg : "Base client unavailable. Ensure Base (8453) is configured in Wagmi.");
|
|
6329
|
+
}
|
|
6330
|
+
} finally {
|
|
6331
|
+
if (!cancelled) setLoading(false);
|
|
6332
|
+
}
|
|
6333
|
+
}
|
|
6334
|
+
run();
|
|
6335
|
+
return () => {
|
|
6336
|
+
cancelled = true;
|
|
6337
|
+
};
|
|
6338
|
+
}, [address, baseClient, defaultClient]);
|
|
6339
|
+
return { isLoading, error: error ?? null, erc20Balances: rows };
|
|
6340
|
+
}
|
|
6341
|
+
|
|
6342
|
+
// src/hooks/useBaseNativeToken.ts
|
|
6343
|
+
import { useAccount as useAccount2, useBalance } from "wagmi";
|
|
6344
|
+
function useBaseNativeToken() {
|
|
6345
|
+
const { address } = useAccount2();
|
|
6346
|
+
const { data, isLoading, error } = useBalance({
|
|
6347
|
+
address,
|
|
6348
|
+
chainId: 8453,
|
|
6349
|
+
// Base
|
|
6350
|
+
query: { enabled: !!address }
|
|
6351
|
+
});
|
|
6352
|
+
const nativeBalance = data ? { ...data, logoURI: "https://static.cdnlogo.com/logos/e/84/ethereum-eth_thumb.png" } : void 0;
|
|
6353
|
+
return {
|
|
6354
|
+
isLoadingNative: isLoading,
|
|
6355
|
+
nativeError: error?.message ?? null,
|
|
6356
|
+
nativeBalance
|
|
6357
|
+
};
|
|
6358
|
+
}
|
|
6359
|
+
|
|
6360
|
+
// src/modals/CryptoSelectModal.tsx
|
|
6361
|
+
import { Fragment as Fragment9, jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
6362
|
+
var CryptoSelectModal = NiceModal.create(() => {
|
|
6363
|
+
const modal = useModal();
|
|
6364
|
+
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
6365
|
+
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
6366
|
+
const { setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
6367
|
+
const [search, setSearch] = useState16("");
|
|
6368
|
+
const handleSelect = (coin) => {
|
|
6369
|
+
modal.remove();
|
|
6370
|
+
setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
|
|
6371
|
+
};
|
|
6372
|
+
return /* @__PURE__ */ jsx24(Dialog2, { open: modal.visible, onOpenChange: modal.remove, children: /* @__PURE__ */ jsxs10(DialogContent2, { showCloseButton: false, className: "gap-0 p-0", children: [
|
|
6373
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-6 px-7 py-6", children: [
|
|
6374
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between gap-4", children: [
|
|
6375
|
+
/* @__PURE__ */ jsx24("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx24("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ jsx24("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
|
|
6376
|
+
/* @__PURE__ */ jsx24(DialogTitle2, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
|
|
6377
|
+
/* @__PURE__ */ jsx24("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ jsx24("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ jsx24(
|
|
6378
|
+
"path",
|
|
6379
|
+
{
|
|
6380
|
+
fill: "#000",
|
|
6381
|
+
d: "M12.6 3.9c.2.2.2.52 0 .71L8.7 8.5l3.9 3.89a.5.5 0 1 1-.71.7L8 9.22 4.11 13.1a.5.5 0 1 1-.7-.71L7.28 8.5 3.4 4.61a.5.5 0 1 1 .71-.7L8 7.78l3.89-3.89c.2-.2.51-.2.7 0Z"
|
|
6382
|
+
}
|
|
6383
|
+
) }) })
|
|
6384
|
+
] }),
|
|
6385
|
+
/* @__PURE__ */ jsx24(Input, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
|
|
6386
|
+
] }),
|
|
6387
|
+
/* @__PURE__ */ jsx24(Separator2, { className: "hidden md:block" }),
|
|
6388
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-4 px-7 py-6", children: [
|
|
6389
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
|
|
6390
|
+
(error || nativeError) && /* @__PURE__ */ jsx24("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
|
|
6391
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex w-full flex-col gap-1", children: [
|
|
6392
|
+
isLoadingNative && /* @__PURE__ */ jsx24("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
6393
|
+
nativeBalance && /* @__PURE__ */ jsxs10(
|
|
6394
|
+
"button",
|
|
6395
|
+
{
|
|
6396
|
+
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 hover:bg-gray-100",
|
|
6397
|
+
onClick: () => handleSelect(nativeBalance),
|
|
6398
|
+
children: [
|
|
6399
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
6400
|
+
nativeBalance.logoURI && /* @__PURE__ */ jsx24(
|
|
6401
|
+
"img",
|
|
6402
|
+
{
|
|
6403
|
+
className: "h-8 w-8 shrink-0",
|
|
6404
|
+
src: nativeBalance.logoURI,
|
|
6405
|
+
alt: `${nativeBalance.symbol} logo`
|
|
6406
|
+
}
|
|
6407
|
+
),
|
|
6408
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
|
|
6409
|
+
] }),
|
|
6410
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
|
|
6411
|
+
]
|
|
6412
|
+
},
|
|
6413
|
+
nativeBalance.symbol
|
|
6414
|
+
),
|
|
6415
|
+
isLoading && /* @__PURE__ */ jsxs10(Fragment9, { children: [
|
|
6416
|
+
/* @__PURE__ */ jsx24("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
6417
|
+
/* @__PURE__ */ jsx24("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
6418
|
+
/* @__PURE__ */ jsx24("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
6419
|
+
] }),
|
|
6420
|
+
erc20Balances.map((coin) => {
|
|
6421
|
+
const Icon2 = getSymbolLogo(coin.symbol);
|
|
6422
|
+
return /* @__PURE__ */ jsxs10(
|
|
6423
|
+
"button",
|
|
6424
|
+
{
|
|
6425
|
+
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 hover:bg-gray-100",
|
|
6426
|
+
onClick: () => handleSelect(coin),
|
|
6427
|
+
children: [
|
|
6428
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
6429
|
+
Boolean(Icon2) && Icon2,
|
|
6430
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm font-medium", children: coin.symbol })
|
|
6431
|
+
] }),
|
|
6432
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm font-medium", children: coin.formatted })
|
|
6433
|
+
]
|
|
6434
|
+
},
|
|
6435
|
+
coin.symbol
|
|
6436
|
+
);
|
|
6437
|
+
})
|
|
6438
|
+
] })
|
|
6439
|
+
] })
|
|
6440
|
+
] }) });
|
|
6441
|
+
});
|
|
6442
|
+
CryptoSelectModal.displayName = "CryptoSelectModal";
|
|
6443
|
+
|
|
6444
|
+
// src/components/Crypto/ConnectButton.tsx
|
|
6445
|
+
import { ConnectButton as RainbowButton } from "@rainbow-me/rainbowkit";
|
|
6446
|
+
import { Fragment as Fragment10, jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
6447
|
+
var ConnectButton = () => {
|
|
6448
|
+
return /* @__PURE__ */ jsx25(RainbowButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
|
|
6449
|
+
if (!mounted) return null;
|
|
6450
|
+
return /* @__PURE__ */ jsx25(Fragment10, { children: (() => {
|
|
6451
|
+
if (!mounted || !account || !chain) {
|
|
6452
|
+
return /* @__PURE__ */ jsx25(
|
|
6453
|
+
"button",
|
|
6454
|
+
{
|
|
6455
|
+
className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium",
|
|
6456
|
+
onClick: openConnectModal,
|
|
6457
|
+
children: "Connect a Wallet"
|
|
6458
|
+
}
|
|
6459
|
+
);
|
|
6460
|
+
}
|
|
6461
|
+
if (chain.unsupported) {
|
|
6462
|
+
return /* @__PURE__ */ jsx25(
|
|
6463
|
+
"button",
|
|
6464
|
+
{
|
|
6465
|
+
className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium text-red-500",
|
|
6466
|
+
onClick: openChainModal,
|
|
6467
|
+
children: "Wrong network"
|
|
6468
|
+
}
|
|
6469
|
+
);
|
|
6470
|
+
}
|
|
6471
|
+
return /* @__PURE__ */ jsxs11(
|
|
6472
|
+
"button",
|
|
6473
|
+
{
|
|
6474
|
+
className: "flex h-[34px] items-center gap-2 rounded-md border-1 border-black px-1.5 text-sm font-medium",
|
|
6475
|
+
onClick: openAccountModal,
|
|
6476
|
+
children: [
|
|
6477
|
+
chain.hasIcon && /* @__PURE__ */ jsx25("div", { className: "h-6 w-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ jsx25("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
|
|
6478
|
+
account.displayName
|
|
6479
|
+
]
|
|
6480
|
+
}
|
|
6481
|
+
);
|
|
6482
|
+
})() });
|
|
6483
|
+
} });
|
|
6484
|
+
};
|
|
6485
|
+
|
|
6486
|
+
// src/components/Crypto/Logos.tsx
|
|
6487
|
+
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6488
|
+
var Logos = () => {
|
|
6489
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex", children: [
|
|
6490
|
+
/* @__PURE__ */ jsx26("div", { className: "rounded-full border border-[#F5F7FA]", children: getSymbolLogo("MOCA") }),
|
|
6491
|
+
/* @__PURE__ */ jsx26("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA]", children: getSymbolLogo("USDC") }),
|
|
6492
|
+
/* @__PURE__ */ jsx26("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA]", children: getSymbolLogo("USDT") }),
|
|
6493
|
+
/* @__PURE__ */ jsx26("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA] bg-[#F5F7FA]", children: getSymbolLogo("WETH") })
|
|
6494
|
+
] });
|
|
6495
|
+
};
|
|
6496
|
+
|
|
6497
|
+
// src/components/Crypto/Crypto.tsx
|
|
6498
|
+
import { jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6499
|
+
var SelectCoinButton = () => {
|
|
6500
|
+
const openModal = () => {
|
|
6501
|
+
NiceModal2.show(CryptoSelectModal);
|
|
6502
|
+
};
|
|
6503
|
+
return /* @__PURE__ */ jsxs13("button", { onClick: openModal, type: "button", className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
|
|
6504
|
+
/* @__PURE__ */ jsx27("div", { className: "bg-primary flex w-11 items-center justify-center", children: /* @__PURE__ */ jsx27("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
|
|
6505
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center justify-between px-3", children: [
|
|
6506
|
+
/* @__PURE__ */ jsx27("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx27("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
|
|
6507
|
+
/* @__PURE__ */ jsx27("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ jsx27("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
|
|
6508
|
+
] })
|
|
6509
|
+
] });
|
|
6510
|
+
};
|
|
6511
|
+
var SelectedCoin = (props) => {
|
|
6512
|
+
const { coin, balance, logoURI } = props;
|
|
6513
|
+
const Icon2 = getSymbolLogo(coin);
|
|
6514
|
+
return /* @__PURE__ */ jsxs13("div", { className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
|
|
6515
|
+
/* @__PURE__ */ jsx27("div", { className: "bg-primary flex w-11 items-center justify-center", children: /* @__PURE__ */ jsx27("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ jsx27("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
|
|
6516
|
+
/* @__PURE__ */ jsxs13("div", { className: "border-primary flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 px-3", children: [
|
|
6517
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
|
|
6518
|
+
Icon2,
|
|
6519
|
+
!Icon2 && logoURI && /* @__PURE__ */ jsx27("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
|
|
6520
|
+
/* @__PURE__ */ jsx27("p", { className: "font-semibold", children: coin }),
|
|
6521
|
+
/* @__PURE__ */ jsx27("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx27("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
|
|
6522
|
+
] }),
|
|
6523
|
+
/* @__PURE__ */ jsxs13("p", { className: "text-xs font-medium text-[#798B95]", children: [
|
|
6524
|
+
"Wallet balance ",
|
|
6525
|
+
/* @__PURE__ */ jsx27("span", { className: "text-black", children: balance })
|
|
6526
|
+
] })
|
|
6527
|
+
] })
|
|
6528
|
+
] });
|
|
6529
|
+
};
|
|
6530
|
+
var Crypto = () => {
|
|
6531
|
+
const { address } = useAccount3();
|
|
6532
|
+
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
6533
|
+
const isWalletConnected = Boolean(address);
|
|
6534
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
6535
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
6536
|
+
/* @__PURE__ */ jsx27("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
|
|
6537
|
+
/* @__PURE__ */ jsx27(ConnectButton, {})
|
|
6538
|
+
] }),
|
|
6539
|
+
!isWalletConnected && /* @__PURE__ */ jsx27(Logos, {}),
|
|
6540
|
+
isWalletConnected && /* @__PURE__ */ jsxs13("div", { className: "flex w-full flex-col gap-1", children: [
|
|
6541
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ jsx27(
|
|
6542
|
+
SelectedCoin,
|
|
6543
|
+
{
|
|
6544
|
+
coin: selectedPaymentMethod.method.symbol,
|
|
6545
|
+
balance: selectedPaymentMethod.method.formatted,
|
|
6546
|
+
logoURI: selectedPaymentMethod.method.logoURI
|
|
6547
|
+
}
|
|
6548
|
+
),
|
|
6549
|
+
/* @__PURE__ */ jsx27(SelectCoinButton, {})
|
|
6550
|
+
] })
|
|
6551
|
+
] });
|
|
6552
|
+
};
|
|
6553
|
+
|
|
6554
|
+
// src/components/Crypto/CryptoWrapper.tsx
|
|
6555
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
6556
|
+
var queryClient = new QueryClient();
|
|
6557
|
+
var config = getDefaultConfig2({
|
|
6558
|
+
appName: "Spree Pay",
|
|
6559
|
+
projectId: "YOUR_PROJECT_ID",
|
|
6560
|
+
chains: [base],
|
|
6561
|
+
ssr: true
|
|
6562
|
+
});
|
|
6563
|
+
var CryptoWrapper = () => {
|
|
6564
|
+
return /* @__PURE__ */ jsx28(WagmiProvider, { config, children: /* @__PURE__ */ jsx28(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx28(RainbowKitProvider, { children: /* @__PURE__ */ jsx28(NiceModal3.Provider, { children: /* @__PURE__ */ jsx28(Crypto, {}) }) }) }) });
|
|
6565
|
+
};
|
|
6566
|
+
|
|
6567
|
+
// ../../node_modules/@radix-ui/react-switch/dist/index.mjs
|
|
6568
|
+
import * as React31 from "react";
|
|
6569
|
+
|
|
6570
|
+
// ../../node_modules/@radix-ui/react-switch/node_modules/@radix-ui/primitive/dist/index.mjs
|
|
6571
|
+
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
6572
|
+
function composeEventHandlers2(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
6573
|
+
return function handleEvent(event) {
|
|
6574
|
+
originalEventHandler?.(event);
|
|
6575
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
6576
|
+
return ourEventHandler?.(event);
|
|
6577
|
+
}
|
|
6578
|
+
};
|
|
6579
|
+
}
|
|
6580
|
+
|
|
6581
|
+
// ../../node_modules/@radix-ui/react-switch/dist/index.mjs
|
|
6582
|
+
import { jsx as jsx29, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6583
|
+
var SWITCH_NAME = "Switch";
|
|
6584
|
+
var [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);
|
|
6585
|
+
var [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
|
|
6586
|
+
var Switch = React31.forwardRef(
|
|
6587
|
+
(props, forwardedRef) => {
|
|
6588
|
+
const {
|
|
6589
|
+
__scopeSwitch,
|
|
6590
|
+
name,
|
|
6591
|
+
checked: checkedProp,
|
|
6592
|
+
defaultChecked,
|
|
6593
|
+
required,
|
|
6594
|
+
disabled,
|
|
6595
|
+
value = "on",
|
|
6596
|
+
onCheckedChange,
|
|
6597
|
+
form,
|
|
6598
|
+
...switchProps
|
|
6599
|
+
} = props;
|
|
6600
|
+
const [button, setButton] = React31.useState(null);
|
|
6601
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
6602
|
+
const hasConsumerStoppedPropagationRef = React31.useRef(false);
|
|
6603
|
+
const isFormControl = button ? form || !!button.closest("form") : true;
|
|
6604
|
+
const [checked, setChecked] = useControllableState({
|
|
6605
|
+
prop: checkedProp,
|
|
6606
|
+
defaultProp: defaultChecked ?? false,
|
|
6607
|
+
onChange: onCheckedChange,
|
|
6608
|
+
caller: SWITCH_NAME
|
|
6609
|
+
});
|
|
6610
|
+
return /* @__PURE__ */ jsxs14(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [
|
|
6611
|
+
/* @__PURE__ */ jsx29(
|
|
6612
|
+
Primitive.button,
|
|
6613
|
+
{
|
|
6614
|
+
type: "button",
|
|
6615
|
+
role: "switch",
|
|
6616
|
+
"aria-checked": checked,
|
|
6617
|
+
"aria-required": required,
|
|
6618
|
+
"data-state": getState3(checked),
|
|
6619
|
+
"data-disabled": disabled ? "" : void 0,
|
|
6620
|
+
disabled,
|
|
6621
|
+
value,
|
|
6622
|
+
...switchProps,
|
|
6623
|
+
ref: composedRefs,
|
|
6624
|
+
onClick: composeEventHandlers2(props.onClick, (event) => {
|
|
6625
|
+
setChecked((prevChecked) => !prevChecked);
|
|
6626
|
+
if (isFormControl) {
|
|
6627
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
6628
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
6629
|
+
}
|
|
6630
|
+
})
|
|
6631
|
+
}
|
|
6632
|
+
),
|
|
6633
|
+
isFormControl && /* @__PURE__ */ jsx29(
|
|
6634
|
+
SwitchBubbleInput,
|
|
6635
|
+
{
|
|
6636
|
+
control: button,
|
|
6637
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
6638
|
+
name,
|
|
6639
|
+
value,
|
|
6640
|
+
checked,
|
|
6641
|
+
required,
|
|
6642
|
+
disabled,
|
|
6643
|
+
form,
|
|
6644
|
+
style: { transform: "translateX(-100%)" }
|
|
6645
|
+
}
|
|
6646
|
+
)
|
|
6647
|
+
] });
|
|
6648
|
+
}
|
|
6649
|
+
);
|
|
6650
|
+
Switch.displayName = SWITCH_NAME;
|
|
6651
|
+
var THUMB_NAME = "SwitchThumb";
|
|
6652
|
+
var SwitchThumb = React31.forwardRef(
|
|
6653
|
+
(props, forwardedRef) => {
|
|
6654
|
+
const { __scopeSwitch, ...thumbProps } = props;
|
|
6655
|
+
const context = useSwitchContext(THUMB_NAME, __scopeSwitch);
|
|
6656
|
+
return /* @__PURE__ */ jsx29(
|
|
6657
|
+
Primitive.span,
|
|
6658
|
+
{
|
|
6659
|
+
"data-state": getState3(context.checked),
|
|
6660
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
6661
|
+
...thumbProps,
|
|
6662
|
+
ref: forwardedRef
|
|
6663
|
+
}
|
|
6664
|
+
);
|
|
6665
|
+
}
|
|
6666
|
+
);
|
|
6667
|
+
SwitchThumb.displayName = THUMB_NAME;
|
|
6668
|
+
var BUBBLE_INPUT_NAME2 = "SwitchBubbleInput";
|
|
6669
|
+
var SwitchBubbleInput = React31.forwardRef(
|
|
6670
|
+
({
|
|
6671
|
+
__scopeSwitch,
|
|
6672
|
+
control,
|
|
6673
|
+
checked,
|
|
6674
|
+
bubbles = true,
|
|
6675
|
+
...props
|
|
6676
|
+
}, forwardedRef) => {
|
|
6677
|
+
const ref = React31.useRef(null);
|
|
6678
|
+
const composedRefs = useComposedRefs(ref, forwardedRef);
|
|
6679
|
+
const prevChecked = usePrevious(checked);
|
|
6680
|
+
const controlSize = useSize(control);
|
|
6681
|
+
React31.useEffect(() => {
|
|
6682
|
+
const input = ref.current;
|
|
6683
|
+
if (!input) return;
|
|
6684
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
6685
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
6686
|
+
inputProto,
|
|
6687
|
+
"checked"
|
|
6688
|
+
);
|
|
6689
|
+
const setChecked = descriptor.set;
|
|
6690
|
+
if (prevChecked !== checked && setChecked) {
|
|
6691
|
+
const event = new Event("click", { bubbles });
|
|
6692
|
+
setChecked.call(input, checked);
|
|
6693
|
+
input.dispatchEvent(event);
|
|
6694
|
+
}
|
|
6695
|
+
}, [prevChecked, checked, bubbles]);
|
|
6696
|
+
return /* @__PURE__ */ jsx29(
|
|
6697
|
+
"input",
|
|
6698
|
+
{
|
|
6699
|
+
type: "checkbox",
|
|
6700
|
+
"aria-hidden": true,
|
|
6701
|
+
defaultChecked: checked,
|
|
6702
|
+
...props,
|
|
6703
|
+
tabIndex: -1,
|
|
6704
|
+
ref: composedRefs,
|
|
6705
|
+
style: {
|
|
6706
|
+
...props.style,
|
|
6707
|
+
...controlSize,
|
|
6708
|
+
position: "absolute",
|
|
6709
|
+
pointerEvents: "none",
|
|
6710
|
+
opacity: 0,
|
|
6711
|
+
margin: 0
|
|
6712
|
+
}
|
|
6713
|
+
}
|
|
6714
|
+
);
|
|
6715
|
+
}
|
|
6716
|
+
);
|
|
6717
|
+
SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME2;
|
|
6718
|
+
function getState3(checked) {
|
|
6719
|
+
return checked ? "checked" : "unchecked";
|
|
6720
|
+
}
|
|
6721
|
+
var Root4 = Switch;
|
|
6722
|
+
var Thumb = SwitchThumb;
|
|
6723
|
+
|
|
6724
|
+
// ../ui/src/components/switch.tsx
|
|
6725
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
6726
|
+
function Switch2({ className, ...props }) {
|
|
6727
|
+
return /* @__PURE__ */ jsx30(
|
|
6728
|
+
Root4,
|
|
6729
|
+
{
|
|
6730
|
+
"data-slot": "switch",
|
|
6731
|
+
className: cn(
|
|
6732
|
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
6733
|
+
className
|
|
6734
|
+
),
|
|
6735
|
+
...props,
|
|
6736
|
+
children: /* @__PURE__ */ jsx30(
|
|
6737
|
+
Thumb,
|
|
6738
|
+
{
|
|
6739
|
+
"data-slot": "switch-thumb",
|
|
6740
|
+
className: cn(
|
|
6741
|
+
"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
6742
|
+
)
|
|
6743
|
+
}
|
|
6744
|
+
)
|
|
6745
|
+
}
|
|
6746
|
+
);
|
|
6747
|
+
}
|
|
6748
|
+
|
|
6749
|
+
// src/components/PointsSwitch.tsx
|
|
6750
|
+
import { jsx as jsx31, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6751
|
+
var PointsSwitch = () => {
|
|
6752
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-3", children: [
|
|
6753
|
+
/* @__PURE__ */ jsx31(Switch2, { disabled: true, id: "points" }),
|
|
6754
|
+
/* @__PURE__ */ jsxs15(Label2, { className: "items-baseline text-xl font-semibold text-black", htmlFor: "points", children: [
|
|
6755
|
+
"Use Points ",
|
|
6756
|
+
/* @__PURE__ */ jsx31("span", { className: "text-xs font-medium", children: "Optional" })
|
|
6757
|
+
] })
|
|
6758
|
+
] });
|
|
6759
|
+
};
|
|
6760
|
+
|
|
6761
|
+
// src/components/TabButtons.tsx
|
|
6762
|
+
import { jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6763
|
+
var TabButton = ({ isActive, children, onClick }) => {
|
|
6764
|
+
return /* @__PURE__ */ jsx32(
|
|
6765
|
+
"button",
|
|
6766
|
+
{
|
|
6767
|
+
onClick,
|
|
6768
|
+
className: cn(
|
|
6769
|
+
"flex w-[132px] flex-col items-baseline rounded-sm border-1 border-black px-2.5 py-1.5 text-sm text-black",
|
|
6770
|
+
{ "opacity-50": !isActive },
|
|
6771
|
+
{ "bg-primary/7 border-primary text-primary": isActive }
|
|
6772
|
+
),
|
|
6773
|
+
children
|
|
6774
|
+
}
|
|
6775
|
+
);
|
|
6776
|
+
};
|
|
6777
|
+
var TabButtons = (props) => {
|
|
6778
|
+
const { value, onChange } = props;
|
|
6779
|
+
const handleChange = (type) => () => {
|
|
6780
|
+
if (value !== type) {
|
|
6781
|
+
onChange({ type, method: null });
|
|
6782
|
+
}
|
|
6783
|
+
};
|
|
6784
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex gap-2", children: [
|
|
6785
|
+
/* @__PURE__ */ jsxs16(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
|
|
6786
|
+
/* @__PURE__ */ jsx32("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ jsx32(
|
|
6787
|
+
"path",
|
|
6788
|
+
{
|
|
6789
|
+
fill: "currentColor",
|
|
6790
|
+
d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
|
|
6791
|
+
}
|
|
6792
|
+
) }),
|
|
6793
|
+
/* @__PURE__ */ jsx32("p", { className: "text-sm font-medium", children: "Card" })
|
|
6794
|
+
] }),
|
|
6795
|
+
/* @__PURE__ */ jsxs16(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
|
|
6796
|
+
/* @__PURE__ */ jsxs16("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
|
|
6797
|
+
/* @__PURE__ */ jsx32(
|
|
6798
|
+
"path",
|
|
6799
|
+
{
|
|
6800
|
+
fill: "currentColor",
|
|
6801
|
+
d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
|
|
6802
|
+
}
|
|
6803
|
+
),
|
|
6804
|
+
/* @__PURE__ */ jsx32(
|
|
6805
|
+
"path",
|
|
6806
|
+
{
|
|
6807
|
+
fill: "currentColor",
|
|
6808
|
+
d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
|
|
6809
|
+
}
|
|
6810
|
+
),
|
|
6811
|
+
/* @__PURE__ */ jsx32("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
|
|
6812
|
+
] }),
|
|
6813
|
+
/* @__PURE__ */ jsx32("p", { className: "text-sm font-medium", children: "Crypto" })
|
|
6814
|
+
] })
|
|
6815
|
+
] });
|
|
6816
|
+
};
|
|
6817
|
+
|
|
6818
|
+
// src/components/Tabs.tsx
|
|
6819
|
+
import { jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6820
|
+
var Tabs = () => {
|
|
6821
|
+
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
6822
|
+
return /* @__PURE__ */ jsxs17("div", { className: "mb-4 rounded-2xl border border-black/25 bg-white", children: [
|
|
6823
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
|
|
6824
|
+
/* @__PURE__ */ jsx33("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
|
|
6825
|
+
/* @__PURE__ */ jsx33(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
6826
|
+
] }),
|
|
6827
|
+
/* @__PURE__ */ jsxs17("div", { className: "border-b-1 border-black/7 px-7 py-6", children: [
|
|
6828
|
+
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx33(CreditCard, {}),
|
|
6829
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx33(CryptoWrapper, {})
|
|
6830
|
+
] }),
|
|
6831
|
+
/* @__PURE__ */ jsx33("div", { className: "px-7 py-6", children: /* @__PURE__ */ jsx33(PointsSwitch, {}) })
|
|
6832
|
+
] });
|
|
6833
|
+
};
|
|
6834
|
+
|
|
6835
|
+
// src/fetcher/client.ts
|
|
6836
|
+
var cfg = { baseUrl: void 0, accessToken: void 0, tenantId: void 0 };
|
|
6837
|
+
var buildUrl = (key) => {
|
|
6838
|
+
if (!cfg.baseUrl) throw new Error("Missing SLAPI baseUrl. Call registerApi(...) first.");
|
|
6839
|
+
if (typeof key === "string") return cfg.baseUrl + key;
|
|
6840
|
+
const { url, params = {} } = key;
|
|
6841
|
+
const usp = new URLSearchParams();
|
|
6842
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
6843
|
+
if (v === void 0 || v === null) return;
|
|
6844
|
+
usp.append(k, String(v));
|
|
6845
|
+
});
|
|
6846
|
+
const qs = usp.toString();
|
|
6847
|
+
return cfg.baseUrl + url + (qs ? `?${qs}` : "");
|
|
6848
|
+
};
|
|
6849
|
+
var request = async (method, url, body) => {
|
|
6850
|
+
const headers = {
|
|
6851
|
+
Accept: "application/json"
|
|
6852
|
+
};
|
|
6853
|
+
if (!cfg.accessToken) throw new Error("Missing SLAPI accessToken. Call registerApi(...) first.");
|
|
6854
|
+
if (!cfg.tenantId) throw new Error("Missing SLAPI tenantId. Call registerApi(...) first.");
|
|
6855
|
+
headers.Authorization = `Bearer ${cfg.accessToken}`;
|
|
6856
|
+
headers["X-Tenant-ID"] = cfg.tenantId;
|
|
6857
|
+
let payload;
|
|
6858
|
+
if (method !== "GET" && method !== "DELETE" && body !== void 0) {
|
|
6859
|
+
if (typeof FormData !== "undefined" && body instanceof FormData) {
|
|
6860
|
+
payload = body;
|
|
6861
|
+
} else if (body instanceof Blob) {
|
|
6862
|
+
payload = body;
|
|
6863
|
+
} else {
|
|
6864
|
+
headers["Content-Type"] = "application/json";
|
|
6865
|
+
payload = JSON.stringify(body);
|
|
6866
|
+
}
|
|
6867
|
+
}
|
|
6868
|
+
const res = await fetch(url, {
|
|
6869
|
+
method,
|
|
6870
|
+
headers,
|
|
6871
|
+
body: payload,
|
|
6872
|
+
cache: "no-store"
|
|
6873
|
+
});
|
|
6874
|
+
if (!res.ok) {
|
|
6875
|
+
const text = await res.text().catch(() => "");
|
|
6876
|
+
throw new Error(text || `Request failed: ${res.status}`);
|
|
6877
|
+
}
|
|
6878
|
+
const contentType = res.headers.get("content-type") || "";
|
|
6879
|
+
if (!contentType.includes("application/json")) {
|
|
6880
|
+
return await res.text();
|
|
6881
|
+
}
|
|
6882
|
+
return await res.json();
|
|
6883
|
+
};
|
|
6884
|
+
var slapiApi = {
|
|
6885
|
+
get: async () => {
|
|
6886
|
+
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
6887
|
+
},
|
|
6888
|
+
post: async () => {
|
|
6889
|
+
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
6890
|
+
},
|
|
6891
|
+
put: async () => {
|
|
6892
|
+
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
6893
|
+
},
|
|
6894
|
+
patch: async () => {
|
|
6895
|
+
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
6896
|
+
},
|
|
6897
|
+
delete: async () => {
|
|
6898
|
+
throw new Error("slapiApi is not configured. Call registerApi(...) first.");
|
|
6899
|
+
}
|
|
6900
|
+
};
|
|
6901
|
+
var registerApi = (config2) => {
|
|
6902
|
+
cfg.baseUrl = config2.baseUrl;
|
|
6903
|
+
cfg.accessToken = config2.accessToken;
|
|
6904
|
+
cfg.tenantId = config2.tenantId;
|
|
6905
|
+
slapiApi = {
|
|
6906
|
+
get: async (key) => {
|
|
6907
|
+
const url = buildUrl(key);
|
|
6908
|
+
return request("GET", url);
|
|
6909
|
+
},
|
|
6910
|
+
post: async (key, body) => {
|
|
6911
|
+
const url = buildUrl(key);
|
|
6912
|
+
return request("POST", url, body);
|
|
6913
|
+
},
|
|
6914
|
+
put: async (key, body) => {
|
|
6915
|
+
const url = buildUrl(key);
|
|
6916
|
+
return request("PUT", url, body);
|
|
6917
|
+
},
|
|
6918
|
+
patch: async (key, body) => {
|
|
6919
|
+
const url = buildUrl(key);
|
|
6920
|
+
return request("PATCH", url, body);
|
|
6921
|
+
},
|
|
6922
|
+
delete: async (key) => {
|
|
6923
|
+
const url = buildUrl(key);
|
|
6924
|
+
return request("DELETE", url);
|
|
4471
6925
|
}
|
|
4472
6926
|
};
|
|
4473
6927
|
return (key) => slapiApi.get(key);
|
|
@@ -4552,12 +7006,12 @@ var cardPayment = async ({ card, hash }) => {
|
|
|
4552
7006
|
};
|
|
4553
7007
|
|
|
4554
7008
|
// src/SpreePayContent.tsx
|
|
4555
|
-
import { jsx as
|
|
7009
|
+
import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4556
7010
|
var SpreePayContent = (props) => {
|
|
4557
7011
|
const { className, amount, onProcess } = props;
|
|
4558
7012
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
4559
7013
|
const { register } = useSpreePayRegister();
|
|
4560
|
-
const handlePay =
|
|
7014
|
+
const handlePay = useCallback8(
|
|
4561
7015
|
(data) => {
|
|
4562
7016
|
if (selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method) {
|
|
4563
7017
|
return cardPayment({ card: selectedPaymentMethod.method, hash: data.hash });
|
|
@@ -4566,18 +7020,18 @@ var SpreePayContent = (props) => {
|
|
|
4566
7020
|
},
|
|
4567
7021
|
[selectedPaymentMethod]
|
|
4568
7022
|
);
|
|
4569
|
-
|
|
7023
|
+
useEffect17(() => {
|
|
4570
7024
|
register(handlePay);
|
|
4571
7025
|
}, [register, handlePay]);
|
|
4572
|
-
return /* @__PURE__ */
|
|
4573
|
-
/* @__PURE__ */
|
|
4574
|
-
/* @__PURE__ */
|
|
4575
|
-
/* @__PURE__ */
|
|
7026
|
+
return /* @__PURE__ */ jsx34("div", { className: cn("sl-spreepay", className), children: /* @__PURE__ */ jsxs18("div", { className: "w-full", children: [
|
|
7027
|
+
/* @__PURE__ */ jsx34(Tabs, {}),
|
|
7028
|
+
/* @__PURE__ */ jsx34(CheckoutButton, { onCheckout: onProcess, amount }),
|
|
7029
|
+
/* @__PURE__ */ jsx34(SpreeLegal, {})
|
|
4576
7030
|
] }) });
|
|
4577
7031
|
};
|
|
4578
7032
|
|
|
4579
7033
|
// src/SpreePay.tsx
|
|
4580
|
-
import { jsx as
|
|
7034
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
4581
7035
|
var envConfig = {
|
|
4582
7036
|
dev: { slapiUrl: "https://slapi.dev.superlogic.com", tenantId: "bookit" },
|
|
4583
7037
|
stg: { slapiUrl: "https://slapi.dev.superlogic.com", tenantId: "bookit" },
|
|
@@ -4585,7 +7039,7 @@ var envConfig = {
|
|
|
4585
7039
|
};
|
|
4586
7040
|
var SpreePay = (props) => {
|
|
4587
7041
|
const { env } = useSpreePayEnv();
|
|
4588
|
-
const slapiFetcher =
|
|
7042
|
+
const slapiFetcher = useMemo7(
|
|
4589
7043
|
() => registerApi({
|
|
4590
7044
|
accessToken: env.accessToken,
|
|
4591
7045
|
baseUrl: envConfig[env.environment].slapiUrl,
|
|
@@ -4593,7 +7047,7 @@ var SpreePay = (props) => {
|
|
|
4593
7047
|
}),
|
|
4594
7048
|
[env]
|
|
4595
7049
|
);
|
|
4596
|
-
return /* @__PURE__ */
|
|
7050
|
+
return /* @__PURE__ */ jsx35(
|
|
4597
7051
|
SWRConfig,
|
|
4598
7052
|
{
|
|
4599
7053
|
value: {
|
|
@@ -4602,7 +7056,7 @@ var SpreePay = (props) => {
|
|
|
4602
7056
|
revalidateIfStale: false,
|
|
4603
7057
|
revalidateOnReconnect: false
|
|
4604
7058
|
},
|
|
4605
|
-
children: /* @__PURE__ */
|
|
7059
|
+
children: /* @__PURE__ */ jsx35(SpreePayContent, { ...props })
|
|
4606
7060
|
}
|
|
4607
7061
|
);
|
|
4608
7062
|
};
|
|
@@ -4618,6 +7072,7 @@ lucide-react/dist/esm/defaultAttributes.js:
|
|
|
4618
7072
|
lucide-react/dist/esm/Icon.js:
|
|
4619
7073
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
4620
7074
|
lucide-react/dist/esm/icons/check.js:
|
|
7075
|
+
lucide-react/dist/esm/icons/x.js:
|
|
4621
7076
|
lucide-react/dist/esm/lucide-react.js:
|
|
4622
7077
|
(**
|
|
4623
7078
|
* @license lucide-react v0.525.0 - ISC
|