@windrun-huaiin/third-ui 31.3.6 → 31.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/main/credit/credit-nav-button.d.ts +3 -2
  2. package/dist/main/credit/credit-nav-button.js +7 -9
  3. package/dist/main/credit/credit-nav-button.mjs +5 -7
  4. package/dist/main/credit/credit-overview-client.js +6 -3
  5. package/dist/main/credit/credit-overview-client.mjs +7 -4
  6. package/dist/main/credit/credit-overview-nav-client.d.ts +12 -2
  7. package/dist/main/credit/credit-overview-nav-client.js +21 -5
  8. package/dist/main/credit/credit-overview-nav-client.mjs +21 -5
  9. package/dist/main/credit/index.d.ts +1 -1
  10. package/dist/main/credit/types.d.ts +1 -0
  11. package/dist/main/money-price/index.d.ts +2 -0
  12. package/dist/main/money-price/index.js +4 -0
  13. package/dist/main/money-price/index.mjs +1 -0
  14. package/dist/main/money-price/money-price-interactive.d.ts +1 -1
  15. package/dist/main/money-price/money-price-interactive.js +7 -5
  16. package/dist/main/money-price/money-price-interactive.mjs +7 -5
  17. package/dist/main/money-price/money-price-types.d.ts +2 -0
  18. package/dist/main/money-price/money-price.d.ts +1 -1
  19. package/dist/main/money-price/money-price.js +2 -2
  20. package/dist/main/money-price/money-price.mjs +2 -2
  21. package/dist/main/money-price/pricing-modal.d.ts +33 -0
  22. package/dist/main/money-price/pricing-modal.js +109 -0
  23. package/dist/main/money-price/pricing-modal.mjs +105 -0
  24. package/package.json +3 -3
  25. package/src/main/credit/credit-nav-button.tsx +15 -56
  26. package/src/main/credit/credit-overview-client.tsx +36 -25
  27. package/src/main/credit/credit-overview-nav-client.tsx +51 -4
  28. package/src/main/credit/index.ts +1 -0
  29. package/src/main/credit/types.ts +1 -0
  30. package/src/main/money-price/index.ts +10 -0
  31. package/src/main/money-price/money-price-interactive.tsx +41 -31
  32. package/src/main/money-price/money-price-types.ts +2 -0
  33. package/src/main/money-price/money-price.tsx +2 -0
  34. package/src/main/money-price/pricing-modal.tsx +283 -0
@@ -1,12 +1,13 @@
1
1
  import type { MoneyPriceData } from '../money-price/money-price-types';
2
- import type { CreditPricingContext, PricingModalMode } from './types';
2
+ import type { CreditPricingContext, MobileBillingSwitchBehavior, PricingModalMode } from './types';
3
3
  interface CreditNavButtonProps {
4
4
  locale: string;
5
5
  totalBalance: number;
6
6
  totalLabel: string;
7
+ mobileBillingSwitchBehavior?: MobileBillingSwitchBehavior;
7
8
  children: React.ReactNode;
8
9
  }
9
- export declare function CreditNavButton({ locale, totalBalance, totalLabel, children, }: CreditNavButtonProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function CreditNavButton({ locale, totalBalance, totalLabel, mobileBillingSwitchBehavior, children, }: CreditNavButtonProps): import("react/jsx-runtime").JSX.Element;
10
11
  interface CreditNavPopoverContextValue {
11
12
  close: () => void;
12
13
  isMobile: boolean;
@@ -4,20 +4,18 @@
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var utils = require('@windrun-huaiin/lib/utils');
6
6
  var icons = require('@windrun-huaiin/base-ui/icons');
7
- var lib = require('@windrun-huaiin/base-ui/lib');
8
7
  var ui = require('@windrun-huaiin/base-ui/ui');
9
8
  var React = require('react');
10
- var moneyPriceInteractive = require('../money-price/money-price-interactive.js');
11
9
  var moneyPriceConfigUtil = require('../money-price/money-price-config-util.js');
12
- var dialogStyles = require('../alert-dialog/dialog-styles.js');
10
+ var pricingModal = require('../money-price/pricing-modal.js');
13
11
 
14
- function CreditNavButton({ locale, totalBalance, totalLabel, children, }) {
12
+ function CreditNavButton({ locale, totalBalance, totalLabel, mobileBillingSwitchBehavior, children, }) {
15
13
  const [open, setOpen] = React.useState(false);
16
14
  const [isMobile, setIsMobile] = React.useState(false);
17
15
  const triggerRef = React.useRef(null);
18
16
  const contentRef = React.useRef(null);
19
17
  const closeMenu = React.useCallback(() => setOpen(false), []);
20
- const [pricingModal, setPricingModal] = React.useState({
18
+ const [pricingModal$1, setPricingModal] = React.useState({
21
19
  open: false,
22
20
  mode: 'subscription',
23
21
  });
@@ -108,13 +106,13 @@ function CreditNavButton({ locale, totalBalance, totalLabel, children, }) {
108
106
  openPricingModal,
109
107
  closePricingModal,
110
108
  }), [closeMenu, isMobile, openPricingModal, closePricingModal]);
111
- const isOnetimeModal = pricingModal.mode === 'onetime';
109
+ const isOnetimeModal = pricingModal$1.mode === 'onetime';
112
110
  const modalInitialBillingType = React.useMemo(() => {
113
111
  var _a, _b;
114
112
  if (isOnetimeModal) {
115
113
  return 'onetime';
116
114
  }
117
- const pricingContext = pricingModal.pricingContext;
115
+ const pricingContext = pricingModal$1.pricingContext;
118
116
  const priceId = (_b = (_a = pricingContext === null || pricingContext === void 0 ? void 0 : pricingContext.initUserContext) === null || _a === void 0 ? void 0 : _a.xSubscription) === null || _b === void 0 ? void 0 : _b.priceId;
119
117
  if (!pricingContext || !priceId) {
120
118
  return undefined;
@@ -129,8 +127,8 @@ function CreditNavButton({ locale, totalBalance, totalLabel, children, }) {
129
127
  }
130
128
  }
131
129
  return undefined;
132
- }, [isOnetimeModal, pricingModal.pricingContext]);
133
- return (jsxRuntime.jsxs(CreditNavPopoverContext.Provider, { value: contextValue, children: [jsxRuntime.jsxs(ui.DropdownMenu, { modal: false, open: open, onOpenChange: setOpen, children: [jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: jsxRuntime.jsxs("button", { type: "button", "aria-label": `${formattedBalance} ${totalLabel}`, className: utils.cn('group relative mx-2 sm:mx-1 inline-flex items-center gap-2 overflow-hidden rounded-full border border-slate-200 bg-white pl-2 pr-4 py-1.5 text-sm font-semibold text-slate-700 shadow-sm transition-all duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100', 'hover:-translate-y-0.5 hover:scale-[1.02] hover:border-transparent hover:text-white hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-slate-400 dark:focus-visible:ring-slate-500'), ref: triggerRef, children: [jsxRuntime.jsx("span", { className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100 bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50", "aria-hidden": "true" }), jsxRuntime.jsx("span", { className: "relative z-10 flex h-6 w-6 items-center justify-center rounded-full bg-slate-100 text-slate-600 transition-transform duration-200 group-hover:scale-110 group-hover:bg-white/20 group-hover:text-white dark:bg-slate-800 dark:text-slate-200 dark:group-hover:bg-white/20 dark:group-hover:text-white", children: jsxRuntime.jsx(icons.GemIcon, { className: "h-3.5 w-3.5" }) }), jsxRuntime.jsxs("span", { className: "relative z-10 flex items-center", children: [jsxRuntime.jsx("span", { className: "text-base font-semibold leading-none", children: formattedBalance }), jsxRuntime.jsx("span", { className: "sr-only", children: ` ${totalLabel}` })] })] }) }), jsxRuntime.jsx(ui.DropdownMenuContent, { forceMount: true, sideOffset: 12, align: "end", className: "z-50 border-0 bg-transparent p-0 shadow-none mx-4 sm:mx-2 md:mx-1", children: jsxRuntime.jsx("div", { className: "w-[90vw] max-w-[90vw] max-h-[80vh] overflow-y-auto overflow-x-hidden rounded-3xl bg-transparent sm:w-[410px] sm:max-h-[90vh] sm:max-w-[95vw]", ref: contentRef, children: children }) })] }), pricingModal.modalMoneyPriceData && pricingModal.pricingContext ? (jsxRuntime.jsx(ui.AlertDialog, { open: pricingModal.open, onOpenChange: (open) => setPricingModal((prev) => (Object.assign(Object.assign({}, prev), { open }))), children: jsxRuntime.jsxs(ui.AlertDialogContent, { className: utils.cn('mt-5 sm:mt-6 md:mt-10 lg:mt-15 w-[95vw] max-w-[1200px] overflow-hidden border border-slate-200 p-0 shadow-[0_32px_90px_rgba(15,23,42,0.25)] ring-1 ring-black/5 dark:border-white/12 dark:shadow-[0_40px_120px_rgba(0,0,0,0.6)] dark:ring-white/10', lib.themeMainBgColor), overlayClassName: dialogStyles.dialogThemedOverlayClass, children: [jsxRuntime.jsxs(ui.AlertDialogHeader, { className: "flex flex-row items-center justify-between border-b border-slate-200 px-6 pt-4 pb-1 dark:border-slate-800", children: [jsxRuntime.jsx(ui.AlertDialogTitle, { asChild: true, children: jsxRuntime.jsxs("div", { className: "flex flex-wrap items-baseline gap-3 text-slate-900 dark:text-white", children: [jsxRuntime.jsx("span", { className: "text-2xl font-semibold leading-tight", children: pricingModal.modalMoneyPriceData.title }), pricingModal.modalMoneyPriceData.subtitle ? (jsxRuntime.jsx("span", { className: "text-sm font-medium text-slate-500 dark:text-slate-300", children: pricingModal.modalMoneyPriceData.subtitle })) : null] }) }), jsxRuntime.jsx("button", { type: "button", className: "rounded-full p-2 text-gray-400 transition hover:bg-gray-400 hover:text-gray-400 dark:text-white/80 dark:hover:bg-white/80 dark:hover:text-white/80", onClick: closePricingModal, children: jsxRuntime.jsx(icons.XIcon, { className: "h-6 w-6" }) })] }), jsxRuntime.jsx("div", { className: "max-h-[60vh] sm:max-h-[80vh] overflow-y-auto px-4 pt-2 pb-6", children: jsxRuntime.jsx("div", { className: "mx-auto w-full", children: jsxRuntime.jsx(moneyPriceInteractive.MoneyPriceInteractive, { data: pricingModal.modalMoneyPriceData, config: pricingModal.pricingContext.moneyPriceConfig, checkoutApiEndpoint: pricingModal.pricingContext.checkoutApiEndpoint, customerPortalApiEndpoint: pricingModal.pricingContext.customerPortalApiEndpoint, enableSubscriptionUpgrade: pricingModal.pricingContext.enableSubscriptionUpgrade, initialBillingType: modalInitialBillingType, disableAutoDetectBilling: isOnetimeModal, initUserContext: pricingModal.pricingContext.initUserContext }, pricingModal.mode) }) })] }) })) : null] }));
130
+ }, [isOnetimeModal, pricingModal$1.pricingContext]);
131
+ return (jsxRuntime.jsxs(CreditNavPopoverContext.Provider, { value: contextValue, children: [jsxRuntime.jsxs(ui.DropdownMenu, { modal: false, open: open, onOpenChange: setOpen, children: [jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: jsxRuntime.jsxs("button", { type: "button", "aria-label": `${formattedBalance} ${totalLabel}`, className: utils.cn('group relative mx-2 sm:mx-1 inline-flex items-center gap-2 overflow-hidden rounded-full border border-slate-200 bg-white pl-2 pr-4 py-1.5 text-sm font-semibold text-slate-700 shadow-sm transition-all duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100', 'hover:-translate-y-0.5 hover:scale-[1.02] hover:border-transparent hover:text-white hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-slate-400 dark:focus-visible:ring-slate-500'), ref: triggerRef, children: [jsxRuntime.jsx("span", { className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100 bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50", "aria-hidden": "true" }), jsxRuntime.jsx("span", { className: "relative z-10 flex h-6 w-6 items-center justify-center rounded-full bg-slate-100 text-slate-600 transition-transform duration-200 group-hover:scale-110 group-hover:bg-white/20 group-hover:text-white dark:bg-slate-800 dark:text-slate-200 dark:group-hover:bg-white/20 dark:group-hover:text-white", children: jsxRuntime.jsx(icons.GemIcon, { className: "h-3.5 w-3.5" }) }), jsxRuntime.jsxs("span", { className: "relative z-10 flex items-center", children: [jsxRuntime.jsx("span", { className: "text-base font-semibold leading-none", children: formattedBalance }), jsxRuntime.jsx("span", { className: "sr-only", children: ` ${totalLabel}` })] })] }) }), jsxRuntime.jsx(ui.DropdownMenuContent, { forceMount: true, sideOffset: 12, align: "end", className: "z-50 border-0 bg-transparent p-0 shadow-none mx-4 sm:mx-2 md:mx-1", children: jsxRuntime.jsx("div", { className: "w-[90vw] max-w-[90vw] max-h-[80vh] overflow-y-auto overflow-x-hidden rounded-3xl bg-transparent sm:w-[410px] sm:max-h-[90vh] sm:max-w-[95vw]", ref: contentRef, children: children }) })] }), pricingModal$1.modalMoneyPriceData && pricingModal$1.pricingContext ? (jsxRuntime.jsx(pricingModal.PricingModal, { open: pricingModal$1.open, onOpenChange: (open) => setPricingModal((prev) => (Object.assign(Object.assign({}, prev), { open }))), data: pricingModal$1.modalMoneyPriceData, config: pricingModal$1.pricingContext.moneyPriceConfig, checkoutApiEndpoint: pricingModal$1.pricingContext.checkoutApiEndpoint, customerPortalApiEndpoint: pricingModal$1.pricingContext.customerPortalApiEndpoint, mobileBillingSwitchBehavior: mobileBillingSwitchBehavior, enableSubscriptionUpgrade: pricingModal$1.pricingContext.enableSubscriptionUpgrade, billingType: modalInitialBillingType, initUserContext: pricingModal$1.pricingContext.initUserContext })) : null] }));
134
132
  }
135
133
  const CreditNavPopoverContext = React.createContext(null);
136
134
  function useCreditNavPopover() {
@@ -1,15 +1,13 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { cn } from '@windrun-huaiin/lib/utils';
4
- import { GemIcon, XIcon } from '@windrun-huaiin/base-ui/icons';
5
- import { themeMainBgColor } from '@windrun-huaiin/base-ui/lib';
6
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle } from '@windrun-huaiin/base-ui/ui';
4
+ import { GemIcon } from '@windrun-huaiin/base-ui/icons';
5
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from '@windrun-huaiin/base-ui/ui';
7
6
  import { createContext, useState, useRef, useCallback, useMemo, useEffect, useContext } from 'react';
8
- import { MoneyPriceInteractive } from '../money-price/money-price-interactive.mjs';
9
7
  import { getActiveProviderConfigUtil } from '../money-price/money-price-config-util.mjs';
10
- import { dialogThemedOverlayClass } from '../alert-dialog/dialog-styles.mjs';
8
+ import { PricingModal } from '../money-price/pricing-modal.mjs';
11
9
 
12
- function CreditNavButton({ locale, totalBalance, totalLabel, children, }) {
10
+ function CreditNavButton({ locale, totalBalance, totalLabel, mobileBillingSwitchBehavior, children, }) {
13
11
  const [open, setOpen] = useState(false);
14
12
  const [isMobile, setIsMobile] = useState(false);
15
13
  const triggerRef = useRef(null);
@@ -128,7 +126,7 @@ function CreditNavButton({ locale, totalBalance, totalLabel, children, }) {
128
126
  }
129
127
  return undefined;
130
128
  }, [isOnetimeModal, pricingModal.pricingContext]);
131
- return (jsxs(CreditNavPopoverContext.Provider, { value: contextValue, children: [jsxs(DropdownMenu, { modal: false, open: open, onOpenChange: setOpen, children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsxs("button", { type: "button", "aria-label": `${formattedBalance} ${totalLabel}`, className: cn('group relative mx-2 sm:mx-1 inline-flex items-center gap-2 overflow-hidden rounded-full border border-slate-200 bg-white pl-2 pr-4 py-1.5 text-sm font-semibold text-slate-700 shadow-sm transition-all duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100', 'hover:-translate-y-0.5 hover:scale-[1.02] hover:border-transparent hover:text-white hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-slate-400 dark:focus-visible:ring-slate-500'), ref: triggerRef, children: [jsx("span", { className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100 bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50", "aria-hidden": "true" }), jsx("span", { className: "relative z-10 flex h-6 w-6 items-center justify-center rounded-full bg-slate-100 text-slate-600 transition-transform duration-200 group-hover:scale-110 group-hover:bg-white/20 group-hover:text-white dark:bg-slate-800 dark:text-slate-200 dark:group-hover:bg-white/20 dark:group-hover:text-white", children: jsx(GemIcon, { className: "h-3.5 w-3.5" }) }), jsxs("span", { className: "relative z-10 flex items-center", children: [jsx("span", { className: "text-base font-semibold leading-none", children: formattedBalance }), jsx("span", { className: "sr-only", children: ` ${totalLabel}` })] })] }) }), jsx(DropdownMenuContent, { forceMount: true, sideOffset: 12, align: "end", className: "z-50 border-0 bg-transparent p-0 shadow-none mx-4 sm:mx-2 md:mx-1", children: jsx("div", { className: "w-[90vw] max-w-[90vw] max-h-[80vh] overflow-y-auto overflow-x-hidden rounded-3xl bg-transparent sm:w-[410px] sm:max-h-[90vh] sm:max-w-[95vw]", ref: contentRef, children: children }) })] }), pricingModal.modalMoneyPriceData && pricingModal.pricingContext ? (jsx(AlertDialog, { open: pricingModal.open, onOpenChange: (open) => setPricingModal((prev) => (Object.assign(Object.assign({}, prev), { open }))), children: jsxs(AlertDialogContent, { className: cn('mt-5 sm:mt-6 md:mt-10 lg:mt-15 w-[95vw] max-w-[1200px] overflow-hidden border border-slate-200 p-0 shadow-[0_32px_90px_rgba(15,23,42,0.25)] ring-1 ring-black/5 dark:border-white/12 dark:shadow-[0_40px_120px_rgba(0,0,0,0.6)] dark:ring-white/10', themeMainBgColor), overlayClassName: dialogThemedOverlayClass, children: [jsxs(AlertDialogHeader, { className: "flex flex-row items-center justify-between border-b border-slate-200 px-6 pt-4 pb-1 dark:border-slate-800", children: [jsx(AlertDialogTitle, { asChild: true, children: jsxs("div", { className: "flex flex-wrap items-baseline gap-3 text-slate-900 dark:text-white", children: [jsx("span", { className: "text-2xl font-semibold leading-tight", children: pricingModal.modalMoneyPriceData.title }), pricingModal.modalMoneyPriceData.subtitle ? (jsx("span", { className: "text-sm font-medium text-slate-500 dark:text-slate-300", children: pricingModal.modalMoneyPriceData.subtitle })) : null] }) }), jsx("button", { type: "button", className: "rounded-full p-2 text-gray-400 transition hover:bg-gray-400 hover:text-gray-400 dark:text-white/80 dark:hover:bg-white/80 dark:hover:text-white/80", onClick: closePricingModal, children: jsx(XIcon, { className: "h-6 w-6" }) })] }), jsx("div", { className: "max-h-[60vh] sm:max-h-[80vh] overflow-y-auto px-4 pt-2 pb-6", children: jsx("div", { className: "mx-auto w-full", children: jsx(MoneyPriceInteractive, { data: pricingModal.modalMoneyPriceData, config: pricingModal.pricingContext.moneyPriceConfig, checkoutApiEndpoint: pricingModal.pricingContext.checkoutApiEndpoint, customerPortalApiEndpoint: pricingModal.pricingContext.customerPortalApiEndpoint, enableSubscriptionUpgrade: pricingModal.pricingContext.enableSubscriptionUpgrade, initialBillingType: modalInitialBillingType, disableAutoDetectBilling: isOnetimeModal, initUserContext: pricingModal.pricingContext.initUserContext }, pricingModal.mode) }) })] }) })) : null] }));
129
+ return (jsxs(CreditNavPopoverContext.Provider, { value: contextValue, children: [jsxs(DropdownMenu, { modal: false, open: open, onOpenChange: setOpen, children: [jsx(DropdownMenuTrigger, { asChild: true, children: jsxs("button", { type: "button", "aria-label": `${formattedBalance} ${totalLabel}`, className: cn('group relative mx-2 sm:mx-1 inline-flex items-center gap-2 overflow-hidden rounded-full border border-slate-200 bg-white pl-2 pr-4 py-1.5 text-sm font-semibold text-slate-700 shadow-sm transition-all duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100', 'hover:-translate-y-0.5 hover:scale-[1.02] hover:border-transparent hover:text-white hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-slate-400 dark:focus-visible:ring-slate-500'), ref: triggerRef, children: [jsx("span", { className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100 bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50", "aria-hidden": "true" }), jsx("span", { className: "relative z-10 flex h-6 w-6 items-center justify-center rounded-full bg-slate-100 text-slate-600 transition-transform duration-200 group-hover:scale-110 group-hover:bg-white/20 group-hover:text-white dark:bg-slate-800 dark:text-slate-200 dark:group-hover:bg-white/20 dark:group-hover:text-white", children: jsx(GemIcon, { className: "h-3.5 w-3.5" }) }), jsxs("span", { className: "relative z-10 flex items-center", children: [jsx("span", { className: "text-base font-semibold leading-none", children: formattedBalance }), jsx("span", { className: "sr-only", children: ` ${totalLabel}` })] })] }) }), jsx(DropdownMenuContent, { forceMount: true, sideOffset: 12, align: "end", className: "z-50 border-0 bg-transparent p-0 shadow-none mx-4 sm:mx-2 md:mx-1", children: jsx("div", { className: "w-[90vw] max-w-[90vw] max-h-[80vh] overflow-y-auto overflow-x-hidden rounded-3xl bg-transparent sm:w-[410px] sm:max-h-[90vh] sm:max-w-[95vw]", ref: contentRef, children: children }) })] }), pricingModal.modalMoneyPriceData && pricingModal.pricingContext ? (jsx(PricingModal, { open: pricingModal.open, onOpenChange: (open) => setPricingModal((prev) => (Object.assign(Object.assign({}, prev), { open }))), data: pricingModal.modalMoneyPriceData, config: pricingModal.pricingContext.moneyPriceConfig, checkoutApiEndpoint: pricingModal.pricingContext.checkoutApiEndpoint, customerPortalApiEndpoint: pricingModal.pricingContext.customerPortalApiEndpoint, mobileBillingSwitchBehavior: mobileBillingSwitchBehavior, enableSubscriptionUpgrade: pricingModal.pricingContext.enableSubscriptionUpgrade, billingType: modalInitialBillingType, initUserContext: pricingModal.pricingContext.initUserContext })) : null] }));
132
130
  }
133
131
  const CreditNavPopoverContext = createContext(null);
134
132
  function useCreditNavPopover() {
@@ -17,7 +17,7 @@ const formatNumber = (locale, value) => new Intl.NumberFormat(locale, {
17
17
  maximumFractionDigits: 0,
18
18
  }).format(value);
19
19
  function CreditOverviewClient({ data, locale, translations, className, expiringSoonThresholdDays = 7, customActionHandlers, }) {
20
- var _a;
20
+ var _a, _b;
21
21
  const { redirectToSignIn } = nextjs.useClerk();
22
22
  const navPopover = creditNavButton.useCreditNavPopover();
23
23
  const isMobile = (_a = navPopover === null || navPopover === void 0 ? void 0 : navPopover.isMobile) !== null && _a !== void 0 ? _a : false;
@@ -59,6 +59,9 @@ function CreditOverviewClient({ data, locale, translations, className, expiringS
59
59
  const subscription = data.subscription;
60
60
  const pricingContext = data.pricingContext;
61
61
  const ctaBehaviors = data.ctaBehaviors;
62
+ const billingOptions = (_b = pricingContext === null || pricingContext === void 0 ? void 0 : pricingContext.moneyPriceData.billingSwitch.options) !== null && _b !== void 0 ? _b : [];
63
+ const subscriptionBillingEnabled = billingOptions.some((option) => option.key === 'monthly' || option.key === 'yearly');
64
+ const onetimeBillingEnabled = billingOptions.some((option) => option.key === 'onetime');
62
65
  const getModalMoneyPriceData = React.useCallback((mode) => {
63
66
  if (!pricingContext) {
64
67
  return null;
@@ -232,10 +235,10 @@ function CreditOverviewClient({ data, locale, translations, className, expiringS
232
235
  userToggledRef.current = true;
233
236
  setBucketExpanded(true);
234
237
  }, []);
235
- return (jsxRuntime.jsxs("section", { className: utils.cn("flex flex-col gap-2 p-2 shadow-inner rounded-xl bg-white dark:bg-slate-900", className), children: [jsxRuntime.jsxs("header", { className: "relative rounded-2xl bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 p-4 shadow-inner dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50 sm:p-6", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 sm:gap-3", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-start rounded-full ", children: [jsxRuntime.jsx(icons.GemIcon, { "aria-hidden": true, className: "mr-2 h-6 w-6 sm:h-8 sm:w-8" }), jsxRuntime.jsx("span", { className: "text-base sm:text-lg", children: translations.totalLabel })] }), jsxRuntime.jsx("div", { className: "flex justify-center text-3xl font-semibold leading-tight sm:text-4xl", children: formatNumber(locale, data.totalBalance) }), jsxRuntime.jsxs("div", { className: "flex-1 flex-col gap-1", children: [jsxRuntime.jsx("p", { className: "text-xs text-gray-700 dark:text-slate-100 sm:text-sm", children: translations.subscriptionPeriodLabel }), jsxRuntime.jsx("h4", { className: "text-xl font-semibold sm:text-2xl", children: subscription ? subscription.planName : translations.subscriptionInactive })] }), jsxRuntime.jsx("div", { className: "pt-2 sm:pt-0", children: jsxRuntime.jsx(gradientButton.GradientButton, { title: subscription ? translations.subscriptionManage : translations.subscribePay, align: "center", icon: subscription ? jsxRuntime.jsx(icons.Settings2Icon, {}) : jsxRuntime.jsx(icons.BellIcon, {}), openInNewTab: false, className: "w-full", onClick: subscription ? handleManageAction : handleSubscribeAction }) })] }), jsxRuntime.jsx("div", { className: "absolute right-3 top-3 sm:right-6 sm:top-6", children: jsxRuntime.jsx(HoverInfo, { label: translations.totalLabel, description: translations.summaryDescription }) })] }), jsxRuntime.jsxs("section", { className: "relative flex flex-col gap-3 rounded-2xl border p-4 shadow-inner sm:gap-2 sm:p-5", children: [jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [jsxRuntime.jsx("h3", { className: "text-base text-gray-500 dark:text-slate-100 sm:text-lg", children: translations.bucketsTitle }), hasBuckets ? (jsxRuntime.jsx("button", { type: "button", "aria-expanded": bucketExpanded, "aria-label": bucketExpanded ? translations.hiddenDetail : translations.expandDetail, onClick: toggleBucketExpanded, className: "flex h-7 w-7 items-center justify-center rounded-full border border-transparent bg-white text-purple-600 shadow-[0_6px_20px_rgba(99,102,241,0.25)] transition-colors hover:text-purple-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-purple-500 dark:bg-[#1b1541] dark:text-purple-100 dark:hover:text-purple-50 dark:shadow-[0_6px_22px_rgba(112,86,255,0.35)]", children: bucketExpanded ? (jsxRuntime.jsx(icons.ChevronUpIcon, { className: "h-4 w-4" })) : (jsxRuntime.jsx(icons.ChevronDownIcon, { className: "h-4 w-4" })) })) : null] }), hasBuckets ? (bucketExpanded ? (jsxRuntime.jsx("ul", { className: "flex flex-col gap-2", children: buckets.map((bucket) => {
238
+ return (jsxRuntime.jsxs("section", { className: utils.cn("flex flex-col gap-2 p-2 shadow-inner rounded-xl bg-white dark:bg-slate-900", className), children: [jsxRuntime.jsxs("header", { className: "relative rounded-2xl bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 p-4 shadow-inner dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50 sm:p-6", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 sm:gap-3", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-start rounded-full ", children: [jsxRuntime.jsx(icons.GemIcon, { "aria-hidden": true, className: "mr-2 h-6 w-6 sm:h-8 sm:w-8" }), jsxRuntime.jsx("span", { className: "text-base sm:text-lg", children: translations.totalLabel })] }), jsxRuntime.jsx("div", { className: "flex justify-center text-3xl font-semibold leading-tight sm:text-4xl", children: formatNumber(locale, data.totalBalance) }), subscriptionBillingEnabled ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "flex-1 flex-col gap-1", children: [jsxRuntime.jsx("p", { className: "text-xs text-gray-700 dark:text-slate-100 sm:text-sm", children: translations.subscriptionPeriodLabel }), jsxRuntime.jsx("h4", { className: "text-xl font-semibold sm:text-2xl", children: subscription ? subscription.planName : translations.subscriptionInactive })] }), jsxRuntime.jsx("div", { className: "pt-2 sm:pt-0", children: jsxRuntime.jsx(gradientButton.GradientButton, { title: subscription ? translations.subscriptionManage : translations.subscribePay, align: "center", icon: subscription ? jsxRuntime.jsx(icons.Settings2Icon, {}) : jsxRuntime.jsx(icons.BellIcon, {}), openInNewTab: false, className: "w-full", onClick: subscription ? handleManageAction : handleSubscribeAction }) })] })) : null] }), jsxRuntime.jsx("div", { className: "absolute right-3 top-3 sm:right-6 sm:top-6", children: jsxRuntime.jsx(HoverInfo, { label: translations.totalLabel, description: translations.summaryDescription }) })] }), jsxRuntime.jsxs("section", { className: "relative flex flex-col gap-3 rounded-2xl border p-4 shadow-inner sm:gap-2 sm:p-5", children: [jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [jsxRuntime.jsx("h3", { className: "text-base text-gray-500 dark:text-slate-100 sm:text-lg", children: translations.bucketsTitle }), hasBuckets ? (jsxRuntime.jsx("button", { type: "button", "aria-expanded": bucketExpanded, "aria-label": bucketExpanded ? translations.hiddenDetail : translations.expandDetail, onClick: toggleBucketExpanded, className: "flex h-7 w-7 items-center justify-center rounded-full border border-transparent bg-white text-purple-600 shadow-[0_6px_20px_rgba(99,102,241,0.25)] transition-colors hover:text-purple-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-purple-500 dark:bg-[#1b1541] dark:text-purple-100 dark:hover:text-purple-50 dark:shadow-[0_6px_22px_rgba(112,86,255,0.35)]", children: bucketExpanded ? (jsxRuntime.jsx(icons.ChevronUpIcon, { className: "h-4 w-4" })) : (jsxRuntime.jsx(icons.ChevronDownIcon, { className: "h-4 w-4" })) })) : null] }), hasBuckets ? (bucketExpanded ? (jsxRuntime.jsx("ul", { className: "flex flex-col gap-2", children: buckets.map((bucket) => {
236
239
  const balanceDisplay = formatNumber(locale, bucket.balance);
237
240
  return (jsxRuntime.jsxs("li", { "data-credit-kind": bucket.kind, className: "rounded-2xl border border-slate-200/70 bg-white/85 px-3 py-3 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 sm:px-4", children: [jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_auto] items-center gap-3 text-xs sm:text-sm", children: [jsxRuntime.jsx("span", { className: "flex min-w-0 items-center gap-2", children: jsxRuntime.jsx("span", { className: "max-w-full truncate rounded-full bg-purple-50 px-2 py-1 text-xs text-purple-600 shadow-sm dark:bg-purple-500/20 dark:text-purple-100 sm:text-sm", children: bucket.computedLabel }) }), jsxRuntime.jsx("span", { className: "flex min-w-0 justify-end", children: jsxRuntime.jsx("span", { className: "text-right text-base font-semibold leading-tight text-gray-500 dark:text-slate-100 sm:text-lg", title: balanceDisplay, children: balanceDisplay }) })] }), jsxRuntime.jsx("div", { className: "mt-3 flex justify-end gap-2", children: jsxRuntime.jsxs("span", { className: "text-[11px] text-gray-500 dark:text-slate-100 sm:text-xs", children: [translations.expiredAtLabel, ": ", bucket.expiresAt] }) })] }, bucket.kind));
238
- }) })) : (jsxRuntime.jsx("button", { type: "button", onClick: expandBuckets, className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 hover:text-purple-500", children: translations.expandDetail }))) : (jsxRuntime.jsx("div", { className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform dark:border-slate-800/60 dark:bg-slate-900/60 text-center", children: translations.bucketsEmpty })), jsxRuntime.jsx(gradientButton.GradientButton, { title: translations.onetimeBuy, icon: jsxRuntime.jsx(icons.ShoppingCartIcon, {}), align: "center", className: "w-full text-sm sm:text-base", onClick: handleOnetimeAction })] })] }));
241
+ }) })) : (jsxRuntime.jsx("button", { type: "button", onClick: expandBuckets, className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 hover:text-purple-500", children: translations.expandDetail }))) : (jsxRuntime.jsx("div", { className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform dark:border-slate-800/60 dark:bg-slate-900/60 text-center", children: translations.bucketsEmpty })), onetimeBillingEnabled ? (jsxRuntime.jsx(gradientButton.GradientButton, { title: translations.onetimeBuy, icon: jsxRuntime.jsx(icons.ShoppingCartIcon, {}), align: "center", className: "w-full text-sm sm:text-base", onClick: handleOnetimeAction })) : null] })] }));
239
242
  }
240
243
  function deriveStatus(expiresAt, thresholdDays = 7) {
241
244
  if (!expiresAt) {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { __awaiter } from 'tslib';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import { useClerk } from '@clerk/nextjs';
5
5
  import { GradientButton } from '../buttons/gradient-button.mjs';
6
6
  import { useState, useRef, useCallback, useMemo, useLayoutEffect } from 'react';
@@ -15,7 +15,7 @@ const formatNumber = (locale, value) => new Intl.NumberFormat(locale, {
15
15
  maximumFractionDigits: 0,
16
16
  }).format(value);
17
17
  function CreditOverviewClient({ data, locale, translations, className, expiringSoonThresholdDays = 7, customActionHandlers, }) {
18
- var _a;
18
+ var _a, _b;
19
19
  const { redirectToSignIn } = useClerk();
20
20
  const navPopover = useCreditNavPopover();
21
21
  const isMobile = (_a = navPopover === null || navPopover === void 0 ? void 0 : navPopover.isMobile) !== null && _a !== void 0 ? _a : false;
@@ -57,6 +57,9 @@ function CreditOverviewClient({ data, locale, translations, className, expiringS
57
57
  const subscription = data.subscription;
58
58
  const pricingContext = data.pricingContext;
59
59
  const ctaBehaviors = data.ctaBehaviors;
60
+ const billingOptions = (_b = pricingContext === null || pricingContext === void 0 ? void 0 : pricingContext.moneyPriceData.billingSwitch.options) !== null && _b !== void 0 ? _b : [];
61
+ const subscriptionBillingEnabled = billingOptions.some((option) => option.key === 'monthly' || option.key === 'yearly');
62
+ const onetimeBillingEnabled = billingOptions.some((option) => option.key === 'onetime');
60
63
  const getModalMoneyPriceData = useCallback((mode) => {
61
64
  if (!pricingContext) {
62
65
  return null;
@@ -230,10 +233,10 @@ function CreditOverviewClient({ data, locale, translations, className, expiringS
230
233
  userToggledRef.current = true;
231
234
  setBucketExpanded(true);
232
235
  }, []);
233
- return (jsxs("section", { className: cn("flex flex-col gap-2 p-2 shadow-inner rounded-xl bg-white dark:bg-slate-900", className), children: [jsxs("header", { className: "relative rounded-2xl bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 p-4 shadow-inner dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50 sm:p-6", children: [jsxs("div", { className: "flex flex-col gap-2 sm:gap-3", children: [jsxs("div", { className: "flex items-center justify-start rounded-full ", children: [jsx(GemIcon, { "aria-hidden": true, className: "mr-2 h-6 w-6 sm:h-8 sm:w-8" }), jsx("span", { className: "text-base sm:text-lg", children: translations.totalLabel })] }), jsx("div", { className: "flex justify-center text-3xl font-semibold leading-tight sm:text-4xl", children: formatNumber(locale, data.totalBalance) }), jsxs("div", { className: "flex-1 flex-col gap-1", children: [jsx("p", { className: "text-xs text-gray-700 dark:text-slate-100 sm:text-sm", children: translations.subscriptionPeriodLabel }), jsx("h4", { className: "text-xl font-semibold sm:text-2xl", children: subscription ? subscription.planName : translations.subscriptionInactive })] }), jsx("div", { className: "pt-2 sm:pt-0", children: jsx(GradientButton, { title: subscription ? translations.subscriptionManage : translations.subscribePay, align: "center", icon: subscription ? jsx(Settings2Icon, {}) : jsx(BellIcon, {}), openInNewTab: false, className: "w-full", onClick: subscription ? handleManageAction : handleSubscribeAction }) })] }), jsx("div", { className: "absolute right-3 top-3 sm:right-6 sm:top-6", children: jsx(HoverInfo, { label: translations.totalLabel, description: translations.summaryDescription }) })] }), jsxs("section", { className: "relative flex flex-col gap-3 rounded-2xl border p-4 shadow-inner sm:gap-2 sm:p-5", children: [jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [jsx("h3", { className: "text-base text-gray-500 dark:text-slate-100 sm:text-lg", children: translations.bucketsTitle }), hasBuckets ? (jsx("button", { type: "button", "aria-expanded": bucketExpanded, "aria-label": bucketExpanded ? translations.hiddenDetail : translations.expandDetail, onClick: toggleBucketExpanded, className: "flex h-7 w-7 items-center justify-center rounded-full border border-transparent bg-white text-purple-600 shadow-[0_6px_20px_rgba(99,102,241,0.25)] transition-colors hover:text-purple-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-purple-500 dark:bg-[#1b1541] dark:text-purple-100 dark:hover:text-purple-50 dark:shadow-[0_6px_22px_rgba(112,86,255,0.35)]", children: bucketExpanded ? (jsx(ChevronUpIcon, { className: "h-4 w-4" })) : (jsx(ChevronDownIcon, { className: "h-4 w-4" })) })) : null] }), hasBuckets ? (bucketExpanded ? (jsx("ul", { className: "flex flex-col gap-2", children: buckets.map((bucket) => {
236
+ return (jsxs("section", { className: cn("flex flex-col gap-2 p-2 shadow-inner rounded-xl bg-white dark:bg-slate-900", className), children: [jsxs("header", { className: "relative rounded-2xl bg-linear-to-bl from-indigo-200/60 via-indigo-400/90 to-purple-200/50 p-4 shadow-inner dark:from-indigo-300/20 dark:via-slate-400 dark:to-slate-500/50 sm:p-6", children: [jsxs("div", { className: "flex flex-col gap-2 sm:gap-3", children: [jsxs("div", { className: "flex items-center justify-start rounded-full ", children: [jsx(GemIcon, { "aria-hidden": true, className: "mr-2 h-6 w-6 sm:h-8 sm:w-8" }), jsx("span", { className: "text-base sm:text-lg", children: translations.totalLabel })] }), jsx("div", { className: "flex justify-center text-3xl font-semibold leading-tight sm:text-4xl", children: formatNumber(locale, data.totalBalance) }), subscriptionBillingEnabled ? (jsxs(Fragment, { children: [jsxs("div", { className: "flex-1 flex-col gap-1", children: [jsx("p", { className: "text-xs text-gray-700 dark:text-slate-100 sm:text-sm", children: translations.subscriptionPeriodLabel }), jsx("h4", { className: "text-xl font-semibold sm:text-2xl", children: subscription ? subscription.planName : translations.subscriptionInactive })] }), jsx("div", { className: "pt-2 sm:pt-0", children: jsx(GradientButton, { title: subscription ? translations.subscriptionManage : translations.subscribePay, align: "center", icon: subscription ? jsx(Settings2Icon, {}) : jsx(BellIcon, {}), openInNewTab: false, className: "w-full", onClick: subscription ? handleManageAction : handleSubscribeAction }) })] })) : null] }), jsx("div", { className: "absolute right-3 top-3 sm:right-6 sm:top-6", children: jsx(HoverInfo, { label: translations.totalLabel, description: translations.summaryDescription }) })] }), jsxs("section", { className: "relative flex flex-col gap-3 rounded-2xl border p-4 shadow-inner sm:gap-2 sm:p-5", children: [jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [jsx("h3", { className: "text-base text-gray-500 dark:text-slate-100 sm:text-lg", children: translations.bucketsTitle }), hasBuckets ? (jsx("button", { type: "button", "aria-expanded": bucketExpanded, "aria-label": bucketExpanded ? translations.hiddenDetail : translations.expandDetail, onClick: toggleBucketExpanded, className: "flex h-7 w-7 items-center justify-center rounded-full border border-transparent bg-white text-purple-600 shadow-[0_6px_20px_rgba(99,102,241,0.25)] transition-colors hover:text-purple-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-purple-500 dark:bg-[#1b1541] dark:text-purple-100 dark:hover:text-purple-50 dark:shadow-[0_6px_22px_rgba(112,86,255,0.35)]", children: bucketExpanded ? (jsx(ChevronUpIcon, { className: "h-4 w-4" })) : (jsx(ChevronDownIcon, { className: "h-4 w-4" })) })) : null] }), hasBuckets ? (bucketExpanded ? (jsx("ul", { className: "flex flex-col gap-2", children: buckets.map((bucket) => {
234
237
  const balanceDisplay = formatNumber(locale, bucket.balance);
235
238
  return (jsxs("li", { "data-credit-kind": bucket.kind, className: "rounded-2xl border border-slate-200/70 bg-white/85 px-3 py-3 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 sm:px-4", children: [jsxs("div", { className: "grid grid-cols-[1fr_auto] items-center gap-3 text-xs sm:text-sm", children: [jsx("span", { className: "flex min-w-0 items-center gap-2", children: jsx("span", { className: "max-w-full truncate rounded-full bg-purple-50 px-2 py-1 text-xs text-purple-600 shadow-sm dark:bg-purple-500/20 dark:text-purple-100 sm:text-sm", children: bucket.computedLabel }) }), jsx("span", { className: "flex min-w-0 justify-end", children: jsx("span", { className: "text-right text-base font-semibold leading-tight text-gray-500 dark:text-slate-100 sm:text-lg", title: balanceDisplay, children: balanceDisplay }) })] }), jsx("div", { className: "mt-3 flex justify-end gap-2", children: jsxs("span", { className: "text-[11px] text-gray-500 dark:text-slate-100 sm:text-xs", children: [translations.expiredAtLabel, ": ", bucket.expiresAt] }) })] }, bucket.kind));
236
- }) })) : (jsx("button", { type: "button", onClick: expandBuckets, className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 hover:text-purple-500", children: translations.expandDetail }))) : (jsx("div", { className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform dark:border-slate-800/60 dark:bg-slate-900/60 text-center", children: translations.bucketsEmpty })), jsx(GradientButton, { title: translations.onetimeBuy, icon: jsx(ShoppingCartIcon, {}), align: "center", className: "w-full text-sm sm:text-base", onClick: handleOnetimeAction })] })] }));
239
+ }) })) : (jsx("button", { type: "button", onClick: expandBuckets, className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform hover:-translate-y-0.5 hover:shadow-md dark:border-slate-800/60 dark:bg-slate-900/60 hover:text-purple-500", children: translations.expandDetail }))) : (jsx("div", { className: "w-full rounded-2xl border border-slate-200/70 bg-white/85 p-6 sm:px-4 text-sm shadow-sm transition-transform dark:border-slate-800/60 dark:bg-slate-900/60 text-center", children: translations.bucketsEmpty })), onetimeBillingEnabled ? (jsx(GradientButton, { title: translations.onetimeBuy, icon: jsx(ShoppingCartIcon, {}), align: "center", className: "w-full text-sm sm:text-base", onClick: handleOnetimeAction })) : null] })] }));
237
240
  }
238
241
  function deriveStatus(expiresAt, thresholdDays = 7) {
239
242
  if (!expiresAt) {
@@ -1,5 +1,5 @@
1
1
  import { type CreditOverviewTranslations } from './credit-overview-client';
2
- import type { CreditOverviewData } from './types';
2
+ import type { CreditOverviewData, MobileBillingSwitchBehavior } from './types';
3
3
  export declare const DEFAULT_CREDIT_OVERVIEW_REFRESH_EVENT = "windrun-huaiin:credit-overview:refresh";
4
4
  export interface CreditOverviewPayload {
5
5
  data: CreditOverviewData;
@@ -9,6 +9,16 @@ export interface CreditOverviewPayload {
9
9
  export interface CreditOverviewNavClientProps {
10
10
  locale: string;
11
11
  endpoint: string;
12
+ /**
13
+ * Billing types enabled by the business app.
14
+ * Defaults are handled by the API/payload builder when omitted.
15
+ */
16
+ enabledBillingTypes?: string[];
17
+ /**
18
+ * Mobile behavior for the pricing modal billing switch.
19
+ * Default: 'sticky'.
20
+ */
21
+ mobileBillingSwitchBehavior?: MobileBillingSwitchBehavior;
12
22
  /**
13
23
  * Browser event names that should trigger credit overview reload.
14
24
  * Business apps can dispatch these events after credit balance changes.
@@ -24,4 +34,4 @@ export interface CreditOverviewNavClientProps {
24
34
  refreshDebounceMs?: number;
25
35
  }
26
36
  export declare function dispatchCreditOverviewRefresh(eventName?: string): void;
27
- export declare function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebounceMs, }: CreditOverviewNavClientProps): import("react/jsx-runtime").JSX.Element | null;
37
+ export declare function CreditOverviewNavClient({ locale, endpoint, enabledBillingTypes, mobileBillingSwitchBehavior, refreshEvents, refreshDebounceMs, }: CreditOverviewNavClientProps): import("react/jsx-runtime").JSX.Element | null;
@@ -9,9 +9,23 @@ var creditNavButton = require('./credit-nav-button.js');
9
9
  var creditOverviewClient = require('./credit-overview-client.js');
10
10
 
11
11
  const DEFAULT_CREDIT_OVERVIEW_REFRESH_EVENT = 'windrun-huaiin:credit-overview:refresh';
12
- function buildCreditOverviewUrl(endpoint, locale) {
12
+ function normalizeEnabledBillingTypes(enabledBillingTypes) {
13
+ if (!(enabledBillingTypes === null || enabledBillingTypes === void 0 ? void 0 : enabledBillingTypes.length)) {
14
+ return [];
15
+ }
16
+ return Array.from(new Set(enabledBillingTypes
17
+ .map((billingType) => billingType.trim())
18
+ .filter((billingType) => billingType.length > 0)));
19
+ }
20
+ function buildEnabledBillingTypesKey(enabledBillingTypes) {
21
+ return normalizeEnabledBillingTypes(enabledBillingTypes).join('\n');
22
+ }
23
+ function buildCreditOverviewUrl(endpoint, locale, enabledBillingTypes) {
13
24
  const url = new URL(endpoint, window.location.origin);
14
25
  url.searchParams.set('locale', locale);
26
+ for (const billingType of enabledBillingTypes) {
27
+ url.searchParams.append('enabledBillingTypes', billingType);
28
+ }
15
29
  return url.toString();
16
30
  }
17
31
  function normalizeRefreshEvents(refreshEvents) {
@@ -29,13 +43,15 @@ function dispatchCreditOverviewRefresh(eventName = DEFAULT_CREDIT_OVERVIEW_REFRE
29
43
  }
30
44
  window.dispatchEvent(new CustomEvent(eventName));
31
45
  }
32
- function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebounceMs = 300, }) {
46
+ function CreditOverviewNavClient({ locale, endpoint, enabledBillingTypes, mobileBillingSwitchBehavior, refreshEvents, refreshDebounceMs = 300, }) {
33
47
  const { isLoaded, isSignedIn, userId } = nextjs.useAuth();
34
48
  const [payload, setPayload] = React.useState(null);
35
49
  const abortControllerRef = React.useRef(null);
36
50
  const isMountedRef = React.useRef(false);
37
51
  const refreshEventsKey = buildRefreshEventsKey(refreshEvents);
38
52
  const normalizedRefreshEvents = React.useMemo(() => refreshEventsKey.split('\n').filter(Boolean), [refreshEventsKey]);
53
+ const enabledBillingTypesKey = buildEnabledBillingTypesKey(enabledBillingTypes);
54
+ const normalizedEnabledBillingTypes = React.useMemo(() => enabledBillingTypesKey.split('\n').filter(Boolean), [enabledBillingTypesKey]);
39
55
  React.useEffect(() => {
40
56
  isMountedRef.current = true;
41
57
  return () => {
@@ -50,7 +66,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
50
66
  const controller = new AbortController();
51
67
  abortControllerRef.current = controller;
52
68
  try {
53
- const response = yield fetch(buildCreditOverviewUrl(endpoint, locale), {
69
+ const response = yield fetch(buildCreditOverviewUrl(endpoint, locale, normalizedEnabledBillingTypes), {
54
70
  cache: 'no-store',
55
71
  credentials: 'same-origin',
56
72
  signal: controller.signal,
@@ -77,7 +93,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
77
93
  abortControllerRef.current = null;
78
94
  }
79
95
  }
80
- }), [endpoint, locale]);
96
+ }), [endpoint, locale, normalizedEnabledBillingTypes]);
81
97
  React.useEffect(() => {
82
98
  var _a;
83
99
  if (!isLoaded) {
@@ -119,7 +135,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
119
135
  if (!payload) {
120
136
  return null;
121
137
  }
122
- return (jsxRuntime.jsx(creditNavButton.CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, children: jsxRuntime.jsx(creditOverviewClient.CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
138
+ return (jsxRuntime.jsx(creditNavButton.CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, mobileBillingSwitchBehavior: mobileBillingSwitchBehavior, children: jsxRuntime.jsx(creditOverviewClient.CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
123
139
  }
124
140
 
125
141
  exports.CreditOverviewNavClient = CreditOverviewNavClient;
@@ -7,9 +7,23 @@ import { CreditNavButton } from './credit-nav-button.mjs';
7
7
  import { CreditOverviewClient } from './credit-overview-client.mjs';
8
8
 
9
9
  const DEFAULT_CREDIT_OVERVIEW_REFRESH_EVENT = 'windrun-huaiin:credit-overview:refresh';
10
- function buildCreditOverviewUrl(endpoint, locale) {
10
+ function normalizeEnabledBillingTypes(enabledBillingTypes) {
11
+ if (!(enabledBillingTypes === null || enabledBillingTypes === void 0 ? void 0 : enabledBillingTypes.length)) {
12
+ return [];
13
+ }
14
+ return Array.from(new Set(enabledBillingTypes
15
+ .map((billingType) => billingType.trim())
16
+ .filter((billingType) => billingType.length > 0)));
17
+ }
18
+ function buildEnabledBillingTypesKey(enabledBillingTypes) {
19
+ return normalizeEnabledBillingTypes(enabledBillingTypes).join('\n');
20
+ }
21
+ function buildCreditOverviewUrl(endpoint, locale, enabledBillingTypes) {
11
22
  const url = new URL(endpoint, window.location.origin);
12
23
  url.searchParams.set('locale', locale);
24
+ for (const billingType of enabledBillingTypes) {
25
+ url.searchParams.append('enabledBillingTypes', billingType);
26
+ }
13
27
  return url.toString();
14
28
  }
15
29
  function normalizeRefreshEvents(refreshEvents) {
@@ -27,13 +41,15 @@ function dispatchCreditOverviewRefresh(eventName = DEFAULT_CREDIT_OVERVIEW_REFRE
27
41
  }
28
42
  window.dispatchEvent(new CustomEvent(eventName));
29
43
  }
30
- function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebounceMs = 300, }) {
44
+ function CreditOverviewNavClient({ locale, endpoint, enabledBillingTypes, mobileBillingSwitchBehavior, refreshEvents, refreshDebounceMs = 300, }) {
31
45
  const { isLoaded, isSignedIn, userId } = useAuth();
32
46
  const [payload, setPayload] = useState(null);
33
47
  const abortControllerRef = useRef(null);
34
48
  const isMountedRef = useRef(false);
35
49
  const refreshEventsKey = buildRefreshEventsKey(refreshEvents);
36
50
  const normalizedRefreshEvents = useMemo(() => refreshEventsKey.split('\n').filter(Boolean), [refreshEventsKey]);
51
+ const enabledBillingTypesKey = buildEnabledBillingTypesKey(enabledBillingTypes);
52
+ const normalizedEnabledBillingTypes = useMemo(() => enabledBillingTypesKey.split('\n').filter(Boolean), [enabledBillingTypesKey]);
37
53
  useEffect(() => {
38
54
  isMountedRef.current = true;
39
55
  return () => {
@@ -48,7 +64,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
48
64
  const controller = new AbortController();
49
65
  abortControllerRef.current = controller;
50
66
  try {
51
- const response = yield fetch(buildCreditOverviewUrl(endpoint, locale), {
67
+ const response = yield fetch(buildCreditOverviewUrl(endpoint, locale, normalizedEnabledBillingTypes), {
52
68
  cache: 'no-store',
53
69
  credentials: 'same-origin',
54
70
  signal: controller.signal,
@@ -75,7 +91,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
75
91
  abortControllerRef.current = null;
76
92
  }
77
93
  }
78
- }), [endpoint, locale]);
94
+ }), [endpoint, locale, normalizedEnabledBillingTypes]);
79
95
  useEffect(() => {
80
96
  var _a;
81
97
  if (!isLoaded) {
@@ -117,7 +133,7 @@ function CreditOverviewNavClient({ locale, endpoint, refreshEvents, refreshDebou
117
133
  if (!payload) {
118
134
  return null;
119
135
  }
120
- return (jsx(CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, children: jsx(CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
136
+ return (jsx(CreditNavButton, { locale: locale, totalBalance: payload.data.totalBalance, totalLabel: payload.totalLabel, mobileBillingSwitchBehavior: mobileBillingSwitchBehavior, children: jsx(CreditOverviewClient, { locale: locale, data: payload.data, translations: payload.translations }) }));
121
137
  }
122
138
 
123
139
  export { CreditOverviewNavClient, DEFAULT_CREDIT_OVERVIEW_REFRESH_EVENT, dispatchCreditOverviewRefresh };
@@ -3,4 +3,4 @@ export { CreditOverviewNavClient, DEFAULT_CREDIT_OVERVIEW_REFRESH_EVENT, dispatc
3
3
  export { CreditNavButton } from './credit-nav-button';
4
4
  export type { CreditOverviewTranslations } from './credit-overview-client';
5
5
  export type { CreditOverviewNavClientProps, CreditOverviewPayload, } from './credit-overview-nav-client';
6
- export type { CreditOverviewData, CreditBucket, CreditBucketStatus, SubscriptionInfo, } from './types';
6
+ export type { CreditOverviewData, CreditBucket, CreditBucketStatus, MobileBillingSwitchBehavior, SubscriptionInfo, } from './types';
@@ -1,5 +1,6 @@
1
1
  import type { InitUserContext, MoneyPriceConfig, MoneyPriceData } from '../money-price/money-price-types';
2
2
  export type PricingModalMode = 'subscription' | 'onetime';
3
+ export type MobileBillingSwitchBehavior = 'sticky' | 'static';
3
4
  export type CreditActionConfig = CreditModalAction | CreditRedirectAction | CreditAuthAction | CreditCustomAction;
4
5
  export interface CreditModalAction {
5
6
  kind: 'modal';
@@ -1,4 +1,6 @@
1
1
  export { MoneyPriceInteractive } from './money-price-interactive';
2
2
  export { MoneyPriceButton } from './money-price-button';
3
+ export { PricingModal, PricingModalProvider, usePricingModal, } from './pricing-modal';
3
4
  export type { MoneyPriceConfig, MoneyPriceData, MoneyPriceAnimeTone, MoneyPriceStrictDiffAnime, InitUserContext, MoneyPriceInteractiveProps, MoneyPriceButtonProps, PaymentProvider, PaymentProviderConfig, EnhancePricePlan, SubscriptionProductConfig, CreditPackProductConfig, UserContext, } from './money-price-types';
5
+ export type { OpenPricingModalOptions, PricingModalProps, PricingModalProviderProps, } from './pricing-modal';
4
6
  export { UserState } from './money-price-types';
@@ -3,12 +3,16 @@
3
3
 
4
4
  var moneyPriceInteractive = require('./money-price-interactive.js');
5
5
  var moneyPriceButton = require('./money-price-button.js');
6
+ var pricingModal = require('./pricing-modal.js');
6
7
  var moneyPriceTypes = require('./money-price-types.js');
7
8
 
8
9
 
9
10
 
10
11
  exports.MoneyPriceInteractive = moneyPriceInteractive.MoneyPriceInteractive;
11
12
  exports.MoneyPriceButton = moneyPriceButton.MoneyPriceButton;
13
+ exports.PricingModal = pricingModal.PricingModal;
14
+ exports.PricingModalProvider = pricingModal.PricingModalProvider;
15
+ exports.usePricingModal = pricingModal.usePricingModal;
12
16
  Object.defineProperty(exports, "UserState", {
13
17
  enumerable: true,
14
18
  get: function () { return moneyPriceTypes.UserState; }
@@ -1,4 +1,5 @@
1
1
  "use client";
2
2
  export { MoneyPriceInteractive } from './money-price-interactive.mjs';
3
3
  export { MoneyPriceButton } from './money-price-button.mjs';
4
+ export { PricingModal, PricingModalProvider, usePricingModal } from './pricing-modal.mjs';
4
5
  export { UserState } from './money-price-types.mjs';
@@ -1,2 +1,2 @@
1
1
  import { type MoneyPriceInteractiveProps } from './money-price-types';
2
- export declare function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal, enabledBillingTypes, enableSubscriptionUpgrade, initialBillingType, disableAutoDetectBilling, initUserContext, isInitLoading, }: MoneyPriceInteractiveProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal, enabledBillingTypes, mobileBillingSwitchBehavior, enableSubscriptionUpgrade, initialBillingType, disableAutoDetectBilling, initUserContext, isInitLoading, }: MoneyPriceInteractiveProps): import("react/jsx-runtime").JSX.Element;
@@ -17,7 +17,7 @@ require('animejs');
17
17
  require('../anime/anime-404-page.js');
18
18
 
19
19
  const PLAN_KEYS = ['F1', 'P2', 'U3'];
20
- function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, enabledBillingTypes, enableSubscriptionUpgrade = true, initialBillingType, disableAutoDetectBilling = false, initUserContext, isInitLoading = false, }) {
20
+ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, enabledBillingTypes, mobileBillingSwitchBehavior = 'static', enableSubscriptionUpgrade = true, initialBillingType, disableAutoDetectBilling = false, initUserContext, isInitLoading = false, }) {
21
21
  var _a, _b, _c, _d, _e, _f;
22
22
  const { redirectToSignIn, redirectToSignUp, user: clerkUser, openSignUp } = nextjs.useClerk();
23
23
  const router = navigation.useRouter();
@@ -37,6 +37,7 @@ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPort
37
37
  return acc;
38
38
  }, {});
39
39
  }, [billingOptions]);
40
+ const showBillingSwitch = billingOptions.length > 1;
40
41
  const defaultBilling = React.useMemo(() => {
41
42
  var _a;
42
43
  const defaultKey = data.billingSwitch.defaultKey;
@@ -309,15 +310,16 @@ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPort
309
310
  return null;
310
311
  return selectedBillingOption.discountText.replace('{percent}', String(discountPercent));
311
312
  }, [selectedBillingOption, providerConfig, billingType]);
312
- // Configure the mobile floating style for BillingTypeButton.
313
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex justify-center mb-6 max-md:sticky max-md:top-30 max-md:z-30 max-md:py-2 max-md:bg-transparent", children: jsxRuntime.jsx("div", { className: "inline-flex bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-full px-2 py-2 sm:px-3 sm:py-3 max-md:w-full max-md:max-w-[340px] max-md:mx-auto shadow-sm", "data-billing-switch": true, children: billingOptions.map(option => {
313
+ // Configure the mobile behavior for BillingTypeButton.
314
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showBillingSwitch ? (jsxRuntime.jsx("div", { className: utils.cn('mb-6 flex justify-center', mobileBillingSwitchBehavior === 'sticky' &&
315
+ 'max-md:sticky max-md:top-2 max-md:z-30 max-md:py-2 max-md:bg-transparent'), children: jsxRuntime.jsx("div", { className: "inline-flex max-w-[calc(100vw-2rem)] bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-full px-2 py-2 sm:px-3 sm:py-3 shadow-sm", "data-billing-switch": true, children: billingOptions.map(option => {
314
316
  const isActive = option.key === billingType;
315
317
  const buttonClasses = isActive
316
318
  ? utils.cn('text-white rounded-full shadow-sm', lib.themeButtonGradientClass, lib.themeButtonGradientHoverClass)
317
319
  : 'text-gray-800 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 rounded-full';
318
320
  const showBadge = option.key === billingType && !!discountBadgeText;
319
- return (jsxRuntime.jsxs("div", { className: "relative flex items-center justify-center mx-1", children: [showBadge && (jsxRuntime.jsx("span", { className: "absolute z-10 left-1/2 -translate-x-1/2 -top-3 sm:-top-4 translate-y-[-50%] px-3 py-0.5 text-[0.625rem] sm:text-xs rounded-md bg-yellow-100 text-yellow-800 font-semibold shadow-sm whitespace-nowrap", children: discountBadgeText })), jsxRuntime.jsx("button", { className: utils.cn('text-sm md:text-base font-medium transition relative text-center z-10 px-2 sm:px-4 py-2 min-w-[100px] sm:min-w-[120px]', buttonClasses), type: "button", "data-billing-button": option.key, onClick: () => setUserSelectedBillingType(option.key), children: option.name })] }, option.key));
320
- }) }) }), jsxRuntime.jsx("div", { className: "w-full", children: jsxRuntime.jsx("div", { className: "flex flex-wrap justify-center gap-5 md:gap-6 xl:gap-8 w-full max-w-6xl mx-auto", children: currentPlans.map((plan) => {
321
+ return (jsxRuntime.jsxs("div", { className: "relative flex items-center justify-center mx-1", children: [showBadge && (jsxRuntime.jsx("span", { className: "absolute z-10 left-1/2 -translate-x-1/2 -top-3 sm:-top-4 translate-y-[-50%] px-3 py-0.5 text-[0.625rem] sm:text-xs rounded-md bg-yellow-100 text-yellow-800 font-semibold shadow-sm whitespace-nowrap", children: discountBadgeText })), jsxRuntime.jsx("button", { className: utils.cn('text-sm md:text-base font-medium transition relative text-center z-10 px-2 sm:px-4 py-2 min-w-[88px] min-[360px]:min-w-[100px] sm:min-w-[120px]', buttonClasses), type: "button", "data-billing-button": option.key, onClick: () => setUserSelectedBillingType(option.key), children: option.name })] }, option.key));
322
+ }) }) })) : null, jsxRuntime.jsx("div", { className: "w-full", children: jsxRuntime.jsx("div", { className: "flex flex-wrap justify-center gap-5 md:gap-6 xl:gap-8 w-full max-w-6xl mx-auto", children: currentPlans.map((plan) => {
321
323
  var _a, _b;
322
324
  const planKey = plan.key;
323
325
  if (!PLAN_KEYS.includes(planKey)) {
@@ -15,7 +15,7 @@ import 'animejs';
15
15
  import '../anime/anime-404-page.mjs';
16
16
 
17
17
  const PLAN_KEYS = ['F1', 'P2', 'U3'];
18
- function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, enabledBillingTypes, enableSubscriptionUpgrade = true, initialBillingType, disableAutoDetectBilling = false, initUserContext, isInitLoading = false, }) {
18
+ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, enabledBillingTypes, mobileBillingSwitchBehavior = 'static', enableSubscriptionUpgrade = true, initialBillingType, disableAutoDetectBilling = false, initUserContext, isInitLoading = false, }) {
19
19
  var _a, _b, _c, _d, _e, _f;
20
20
  const { redirectToSignIn, redirectToSignUp, user: clerkUser, openSignUp } = useClerk();
21
21
  const router = useRouter();
@@ -35,6 +35,7 @@ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPort
35
35
  return acc;
36
36
  }, {});
37
37
  }, [billingOptions]);
38
+ const showBillingSwitch = billingOptions.length > 1;
38
39
  const defaultBilling = useMemo(() => {
39
40
  var _a;
40
41
  const defaultKey = data.billingSwitch.defaultKey;
@@ -307,15 +308,16 @@ function MoneyPriceInteractive({ data, config, checkoutApiEndpoint, customerPort
307
308
  return null;
308
309
  return selectedBillingOption.discountText.replace('{percent}', String(discountPercent));
309
310
  }, [selectedBillingOption, providerConfig, billingType]);
310
- // Configure the mobile floating style for BillingTypeButton.
311
- return (jsxs(Fragment, { children: [jsx("div", { className: "flex justify-center mb-6 max-md:sticky max-md:top-30 max-md:z-30 max-md:py-2 max-md:bg-transparent", children: jsx("div", { className: "inline-flex bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-full px-2 py-2 sm:px-3 sm:py-3 max-md:w-full max-md:max-w-[340px] max-md:mx-auto shadow-sm", "data-billing-switch": true, children: billingOptions.map(option => {
311
+ // Configure the mobile behavior for BillingTypeButton.
312
+ return (jsxs(Fragment, { children: [showBillingSwitch ? (jsx("div", { className: cn('mb-6 flex justify-center', mobileBillingSwitchBehavior === 'sticky' &&
313
+ 'max-md:sticky max-md:top-2 max-md:z-30 max-md:py-2 max-md:bg-transparent'), children: jsx("div", { className: "inline-flex max-w-[calc(100vw-2rem)] bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-full px-2 py-2 sm:px-3 sm:py-3 shadow-sm", "data-billing-switch": true, children: billingOptions.map(option => {
312
314
  const isActive = option.key === billingType;
313
315
  const buttonClasses = isActive
314
316
  ? cn('text-white rounded-full shadow-sm', themeButtonGradientClass, themeButtonGradientHoverClass)
315
317
  : 'text-gray-800 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 rounded-full';
316
318
  const showBadge = option.key === billingType && !!discountBadgeText;
317
- return (jsxs("div", { className: "relative flex items-center justify-center mx-1", children: [showBadge && (jsx("span", { className: "absolute z-10 left-1/2 -translate-x-1/2 -top-3 sm:-top-4 translate-y-[-50%] px-3 py-0.5 text-[0.625rem] sm:text-xs rounded-md bg-yellow-100 text-yellow-800 font-semibold shadow-sm whitespace-nowrap", children: discountBadgeText })), jsx("button", { className: cn('text-sm md:text-base font-medium transition relative text-center z-10 px-2 sm:px-4 py-2 min-w-[100px] sm:min-w-[120px]', buttonClasses), type: "button", "data-billing-button": option.key, onClick: () => setUserSelectedBillingType(option.key), children: option.name })] }, option.key));
318
- }) }) }), jsx("div", { className: "w-full", children: jsx("div", { className: "flex flex-wrap justify-center gap-5 md:gap-6 xl:gap-8 w-full max-w-6xl mx-auto", children: currentPlans.map((plan) => {
319
+ return (jsxs("div", { className: "relative flex items-center justify-center mx-1", children: [showBadge && (jsx("span", { className: "absolute z-10 left-1/2 -translate-x-1/2 -top-3 sm:-top-4 translate-y-[-50%] px-3 py-0.5 text-[0.625rem] sm:text-xs rounded-md bg-yellow-100 text-yellow-800 font-semibold shadow-sm whitespace-nowrap", children: discountBadgeText })), jsx("button", { className: cn('text-sm md:text-base font-medium transition relative text-center z-10 px-2 sm:px-4 py-2 min-w-[88px] min-[360px]:min-w-[100px] sm:min-w-[120px]', buttonClasses), type: "button", "data-billing-button": option.key, onClick: () => setUserSelectedBillingType(option.key), children: option.name })] }, option.key));
320
+ }) }) })) : null, jsx("div", { className: "w-full", children: jsx("div", { className: "flex flex-wrap justify-center gap-5 md:gap-6 xl:gap-8 w-full max-w-6xl mx-auto", children: currentPlans.map((plan) => {
319
321
  var _a, _b;
320
322
  const planKey = plan.key;
321
323
  if (!PLAN_KEYS.includes(planKey)) {
@@ -81,6 +81,7 @@ export interface MoneyPriceProps {
81
81
  enableClerkModal?: boolean;
82
82
  sectionClassName?: string;
83
83
  enabledBillingTypes?: string[];
84
+ mobileBillingSwitchBehavior?: 'sticky' | 'static';
84
85
  enableSubscriptionUpgrade?: boolean;
85
86
  initUserContext?: InitUserContext;
86
87
  initialBillingType?: string;
@@ -92,6 +93,7 @@ export interface MoneyPriceInteractiveProps {
92
93
  customerPortalApiEndpoint?: string;
93
94
  enableClerkModal?: boolean;
94
95
  enabledBillingTypes?: string[];
96
+ mobileBillingSwitchBehavior?: 'sticky' | 'static';
95
97
  enableSubscriptionUpgrade?: boolean;
96
98
  initialBillingType?: string;
97
99
  disableAutoDetectBilling?: boolean;
@@ -1,2 +1,2 @@
1
1
  import type { MoneyPriceProps } from './money-price-types';
2
- export declare function MoneyPrice({ locale, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal, sectionClassName, enabledBillingTypes, enableSubscriptionUpgrade, initUserContext, initialBillingType, }: MoneyPriceProps): Promise<import("react/jsx-runtime").JSX.Element>;
2
+ export declare function MoneyPrice({ locale, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal, sectionClassName, enabledBillingTypes, mobileBillingSwitchBehavior, enableSubscriptionUpgrade, initUserContext, initialBillingType, }: MoneyPriceProps): Promise<import("react/jsx-runtime").JSX.Element>;
@@ -7,13 +7,13 @@ var moneyPriceInteractive = require('./money-price-interactive.js');
7
7
  var moneyPriceData = require('./money-price-data.js');
8
8
 
9
9
  function MoneyPrice(_a) {
10
- return tslib.__awaiter(this, arguments, void 0, function* ({ locale, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, sectionClassName, enabledBillingTypes, enableSubscriptionUpgrade = true, initUserContext, initialBillingType, }) {
10
+ return tslib.__awaiter(this, arguments, void 0, function* ({ locale, config, checkoutApiEndpoint, customerPortalApiEndpoint, enableClerkModal = false, sectionClassName, enabledBillingTypes, mobileBillingSwitchBehavior, enableSubscriptionUpgrade = true, initUserContext, initialBillingType, }) {
11
11
  const data = yield moneyPriceData.buildMoneyPriceData({
12
12
  locale,
13
13
  currency: config.display.currency,
14
14
  enabledBillingTypes,
15
15
  });
16
- return (jsxRuntime.jsxs("section", { id: "money-pricing", className: utils.cn("px-4 py-4 md:px-16 md:py-8 mx-auto max-w-7xl scroll-mt-10", sectionClassName), children: [jsxRuntime.jsx("h2", { className: "text-3xl md:text-4xl font-bold text-center mb-3", children: data.title }), jsxRuntime.jsx("p", { className: "text-center text-gray-600 dark:text-gray-400 mb-4 text-base md:text-lg mx-auto", children: data.subtitle }), jsxRuntime.jsx(moneyPriceInteractive.MoneyPriceInteractive, { data: data, config: config, checkoutApiEndpoint: checkoutApiEndpoint, customerPortalApiEndpoint: customerPortalApiEndpoint, enableClerkModal: enableClerkModal, enabledBillingTypes: enabledBillingTypes, enableSubscriptionUpgrade: enableSubscriptionUpgrade, initUserContext: initUserContext, initialBillingType: initialBillingType })] }));
16
+ return (jsxRuntime.jsxs("section", { id: "money-pricing", className: utils.cn("px-4 py-4 md:px-16 md:py-8 mx-auto max-w-7xl scroll-mt-10", sectionClassName), children: [jsxRuntime.jsx("h2", { className: "text-3xl md:text-4xl font-bold text-center mb-3", children: data.title }), jsxRuntime.jsx("p", { className: "text-center text-gray-600 dark:text-gray-400 mb-4 text-base md:text-lg mx-auto", children: data.subtitle }), jsxRuntime.jsx(moneyPriceInteractive.MoneyPriceInteractive, { data: data, config: config, checkoutApiEndpoint: checkoutApiEndpoint, customerPortalApiEndpoint: customerPortalApiEndpoint, enableClerkModal: enableClerkModal, enabledBillingTypes: enabledBillingTypes, mobileBillingSwitchBehavior: mobileBillingSwitchBehavior, enableSubscriptionUpgrade: enableSubscriptionUpgrade, initUserContext: initUserContext, initialBillingType: initialBillingType })] }));
17
17
  });
18
18
  }
19
19