@nextblock-cms/ecom 0.22.2 → 0.22.3

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 (87) hide show
  1. package/index.cjs +1 -1
  2. package/index.es.js +31 -31
  3. package/lib/components/Checkout.cjs +1 -1
  4. package/lib/components/Checkout.es.js +1 -0
  5. package/lib/components/SubscriptionSelector.cjs +1 -1
  6. package/lib/components/SubscriptionSelector.es.js +91 -92
  7. package/lib/coupon-server.cjs +1 -1
  8. package/lib/coupon-server.es.js +78 -61
  9. package/lib/coupons.cjs +1 -1
  10. package/lib/coupons.d.ts +9 -0
  11. package/lib/coupons.es.js +11 -2
  12. package/lib/currency-sync.cjs +1 -1
  13. package/lib/currency-sync.es.js +1 -1
  14. package/lib/freemius-coupons.cjs +1 -1
  15. package/lib/freemius-coupons.es.js +88 -92
  16. package/lib/freemius-license-claim.cjs +1 -1
  17. package/lib/freemius-license-claim.d.ts +13 -0
  18. package/lib/freemius-license-claim.es.js +44 -29
  19. package/lib/freemius-license.cjs +1 -1
  20. package/lib/freemius-license.es.js +19 -17
  21. package/lib/freemius-order-sync.cjs +1 -1
  22. package/lib/freemius-order-sync.d.ts +44 -0
  23. package/lib/freemius-order-sync.es.js +164 -77
  24. package/lib/freemius-pricing-server.cjs +1 -0
  25. package/lib/freemius-pricing-server.d.ts +65 -0
  26. package/lib/freemius-pricing-server.es.js +82 -0
  27. package/lib/freemius-pricing.cjs +1 -0
  28. package/lib/freemius-pricing.d.ts +53 -0
  29. package/lib/freemius-pricing.es.js +51 -0
  30. package/lib/invoice-server.cjs +1 -1
  31. package/lib/invoice-server.es.js +1 -0
  32. package/lib/pages/cms/coupons/CouponsPage.cjs +1 -1
  33. package/lib/pages/cms/coupons/CouponsPage.es.js +1 -0
  34. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -1
  35. package/lib/pages/cms/coupons/EditCouponPage.es.js +1 -0
  36. package/lib/pages/cms/coupons/actions.cjs +1 -1
  37. package/lib/pages/cms/coupons/actions.es.js +1 -0
  38. package/lib/pages/cms/orders/actions.cjs +1 -1
  39. package/lib/pages/cms/orders/actions.es.js +1 -0
  40. package/lib/pages/cms/orders/export-actions.cjs +1 -1
  41. package/lib/pages/cms/orders/export-actions.es.js +1 -0
  42. package/lib/pages/cms/orders/server-actions.cjs +1 -1
  43. package/lib/pages/cms/orders/server-actions.es.js +1 -0
  44. package/lib/pages/cms/products/ProductsPage.cjs +1 -1
  45. package/lib/pages/cms/products/ProductsPage.es.js +1 -0
  46. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -1
  47. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +1 -0
  48. package/lib/pages/cms/products/actions.cjs +3 -3
  49. package/lib/pages/cms/products/actions.d.ts +11 -5
  50. package/lib/pages/cms/products/actions.es.js +45 -12
  51. package/lib/pages/cms/products/inventory/actions.cjs +1 -1
  52. package/lib/pages/cms/products/inventory/actions.es.js +1 -0
  53. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -1
  54. package/lib/pages/cms/products/new/NewProductPage.es.js +1 -0
  55. package/lib/pages/cms/products/server-actions.cjs +1 -1
  56. package/lib/pages/cms/products/server-actions.es.js +1 -0
  57. package/lib/pages/cms/shipping/ShippingPage.cjs +1 -1
  58. package/lib/pages/cms/shipping/ShippingPage.es.js +1 -0
  59. package/lib/pages/cms/shipping/server-actions.cjs +1 -1
  60. package/lib/pages/cms/shipping/server-actions.es.js +1 -0
  61. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -1
  62. package/lib/pages/cms/taxes/TaxesPage.es.js +1 -0
  63. package/lib/payment-config.cjs +1 -1
  64. package/lib/payment-config.es.js +1 -0
  65. package/lib/providers/freemius.cjs +1 -1
  66. package/lib/providers/freemius.es.js +200 -187
  67. package/lib/providers/stripe.cjs +1 -1
  68. package/lib/providers/stripe.es.js +151 -150
  69. package/lib/server-actions/coupon-actions.cjs +1 -1
  70. package/lib/server-actions/coupon-actions.es.js +1 -0
  71. package/lib/server-actions/customer-actions.d.ts +6 -1
  72. package/lib/server-actions/require-ecom-role.cjs +1 -1
  73. package/lib/server-actions/require-ecom-role.es.js +22 -10
  74. package/lib/server-actions/tax-actions.cjs +1 -1
  75. package/lib/server-actions/tax-actions.es.js +1 -0
  76. package/lib/shared-inventory.cjs +1 -1
  77. package/lib/shared-inventory.es.js +1 -1
  78. package/lib/stripe/checkout.cjs +1 -1
  79. package/lib/stripe/checkout.es.js +1 -0
  80. package/lib/stripe/order-sync.cjs +1 -1
  81. package/lib/stripe/order-sync.es.js +1 -0
  82. package/lib/stripe/webhooks.cjs +1 -1
  83. package/lib/stripe/webhooks.d.ts +10 -0
  84. package/lib/stripe/webhooks.es.js +23 -10
  85. package/package.json +4 -4
  86. package/server.cjs +1 -1
  87. package/server.es.js +31 -31
package/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib/types.cjs"),t=require("./lib/currency.cjs"),n=require("./lib/currency-store.cjs"),r=require("./lib/CurrencyProvider.cjs"),i=require("./lib/cart-store.cjs"),a=require("./lib/use-cart.cjs"),o=require("./lib/trials.cjs"),s=require("./lib/coupons.cjs"),c=require("./lib/components/CouponForm.cjs"),l=require("./lib/components/CartDrawer.cjs"),u=require("./lib/variation-utils.cjs"),d=require("./lib/components/Cart.cjs"),f=require("./lib/PaymentReadinessProvider.cjs"),p=require("./lib/customer.cjs"),m=require("./lib/components/Checkout.cjs"),h=require("./lib/components/CartIcon.cjs"),g=require("./lib/components/CurrencySwitcher.cjs"),_=require("./lib/components/AddToCartButton.cjs"),v=require("./lib/components/ProductCard.cjs"),y=require("./lib/components/ProductGrid.cjs"),b=require("./lib/invoice-ui.cjs"),x=require("./lib/components/ProductGallery.cjs"),S=require("./lib/components/SimpleTiptapRenderer.cjs"),C=require("./lib/components/FeaturedProduct.cjs"),w=require("./lib/components/AccountNavigationMenu.cjs"),T=require("./lib/components/CustomerProfileForm.cjs"),E=require("./lib/components/SubscriptionSelector.cjs"),D=require("./lib/invoice.cjs"),O=require("./lib/order-tax-details.cjs"),k=require("./lib/components/InvoiceDocument.cjs"),A=require("./lib/components/InvoiceViewerShell.cjs"),j=require("./lib/components/FreemiusLicensePanel.cjs"),M=require("./lib/product-schema.cjs"),N=require("./lib/pages/cms/products/components/ProductCategorySelector.cjs"),P=require("./lib/pages/cms/products/components/ProductForm.cjs"),F=require("./lib/product-context.cjs"),I=require("./lib/components/ProductDetailsLayout.cjs");exports.AccountNavigationMenu=w.AccountNavigationMenu,exports.AddToCartButton=_.AddToCartButton,exports.COUPON_INVALID_ERROR_KEY=s.COUPON_INVALID_ERROR_KEY,exports.COUPON_INVALID_ERROR_MESSAGE=s.COUPON_INVALID_ERROR_MESSAGE,exports.COUPON_THROTTLED_ERROR_KEY=s.COUPON_THROTTLED_ERROR_KEY,exports.COUPON_THROTTLED_ERROR_MESSAGE=s.COUPON_THROTTLED_ERROR_MESSAGE,exports.CURRENCY_ROUNDING_MODES=t.CURRENCY_ROUNDING_MODES,exports.Cart=d.Cart,exports.CartDrawer=l.CartDrawer,exports.CartIcon=h.CartIcon,exports.Checkout=m.Checkout,exports.CouponForm=c.CouponForm,exports.CurrencyProvider=r.CurrencyProvider,exports.CurrencySwitcher=g.CurrencySwitcher,exports.CustomerProfileForm=T.CustomerProfileForm,exports.DEFAULT_ENABLED_PAYMENT_PROVIDERS=e.DEFAULT_ENABLED_PAYMENT_PROVIDERS,exports.DEFAULT_INVOICE_SETTINGS=D.DEFAULT_INVOICE_SETTINGS,exports.FeaturedProduct=C.FeaturedProduct,exports.FreemiusLicensePanel=j.FreemiusLicensePanel,exports.INVOICE_SETTINGS_KEY=D.INVOICE_SETTINGS_KEY,exports.InvoiceDocument=k.InvoiceDocument,exports.InvoiceViewerShell=A.InvoiceViewerShell,exports.PaymentReadinessProvider=f.PaymentReadinessProvider,exports.ProductCard=v.ProductCard,exports.ProductCategorySelector=N.ProductCategorySelector,exports.ProductDetailsLayout=I.ProductDetailsLayout,exports.ProductForm=P.ProductForm,exports.ProductGallery=x.ProductGallery,exports.ProductGrid=y.ProductGrid,exports.ProductProvider=F.ProductProvider,exports.SimpleTiptapRenderer=S.SimpleTiptapRenderer,exports.SubscriptionSelector=E.SubscriptionSelector,exports.addressesMatch=p.addressesMatch,exports.aggregateOrderTaxLines=O.aggregateOrderTaxLines,exports.applyCurrencyRounding=t.applyCurrencyRounding,exports.applyVariantSelection=u.applyVariantSelection,exports.buildCombinationKey=u.buildCombinationKey,exports.buildInvoiceDocumentLabels=b.buildInvoiceDocumentLabels,exports.buildOrderTaxDetailsFromCalculation=O.buildOrderTaxDetailsFromCalculation,exports.buildOrderTaxDetailsFromStripeSession=O.buildOrderTaxDetailsFromStripeSession,exports.buildVariantLabel=u.buildVariantLabel,exports.chooseInitialVariantSelections=u.chooseInitialVariantSelections,exports.convertMinorUnitAmount=t.convertMinorUnitAmount,exports.derivePaymentProviderFromProductType=e.derivePaymentProviderFromProductType,exports.describeCurrencyRoundingRule=t.describeCurrencyRoundingRule,exports.emptyCustomerAddress=p.emptyCustomerAddress,exports.emptyProviderDiscounts=s.emptyProviderDiscounts,exports.extractSelectedTermsByAttribute=u.extractSelectedTermsByAttribute,exports.findMatchingVariant=u.findMatchingVariant,exports.formatInvoiceCurrency=D.formatInvoiceCurrency,exports.formatInvoiceDate=D.formatInvoiceDate,exports.generateVariantDrafts=u.generateVariantDrafts,exports.getAvailableTermIdsForAttribute=u.getAvailableTermIdsForAttribute,exports.getCartItemActivePrice=i.getCartItemActivePrice,exports.getCartLineCouponKey=s.getCartLineCouponKey,exports.getCurrencyLookup=t.getCurrencyLookup,exports.getDefaultCurrency=t.getDefaultCurrency,exports.getExchangeRateForCurrency=t.getExchangeRateForCurrency,exports.getInvoiceAddressLines=D.getInvoiceAddressLines,exports.getInvoiceLocale=b.getInvoiceLocale,exports.getOrderTaxRateJurisdiction=O.getOrderTaxRateJurisdiction,exports.getOrderTaxRateLabel=O.getOrderTaxRateLabel,exports.getOrderTaxRatePercentage=O.getOrderTaxRatePercentage,exports.getProductPaymentProvider=e.getProductPaymentProvider,exports.getTrialCheckoutMode=o.getTrialCheckoutMode,exports.getTrialLabel=o.getTrialLabel,exports.getTrialPaymentRequirementLabel=o.getTrialPaymentRequirementLabel,exports.getTrialPeriodDays=o.getTrialPeriodDays,exports.getTrialSummary=o.getTrialSummary,exports.getVariantEffectivePriceRange=u.getVariantEffectivePriceRange,exports.inferCurrencyCodeFromLocale=t.inferCurrencyCodeFromLocale,exports.isCustomerAddressComplete=p.isCustomerAddressComplete,exports.isDigitalItem=e.isDigitalItem,exports.isDigitalProduct=e.isDigitalProduct,exports.isSaleWindowActive=t.isSaleWindowActive,exports.isScheduledPriceDue=t.isScheduledPriceDue,exports.localizeInvoicePresentationData=b.localizeInvoicePresentationData,exports.mapRawVariantRelations=u.mapRawVariantRelations,exports.normalizeCouponCode=s.normalizeCouponCode,exports.normalizeCurrencyRecord=t.normalizeCurrencyRecord,exports.normalizeCurrencyRoundingMode=t.normalizeCurrencyRoundingMode,exports.normalizeCustomerAddress=p.normalizeCustomerAddress,exports.normalizeEnabledPaymentProviders=e.normalizeEnabledPaymentProviders,exports.normalizeInvoiceSettings=D.normalizeInvoiceSettings,exports.normalizeOrderCustomerDetails=p.normalizeOrderCustomerDetails,exports.normalizeOrderTaxDetails=O.normalizeOrderTaxDetails,exports.normalizePriceMap=t.normalizePriceMap,exports.normalizeSalePriceMap=t.normalizeSalePriceMap,exports.normalizeSelectionsToAvailableVariants=u.normalizeSelectionsToAvailableVariants,exports.productSchema=M.productSchema,exports.resolveAttributeName=u.resolveAttributeName,exports.resolveEffectivePriceForCurrency=t.resolveEffectivePriceForCurrency,exports.resolvePriceForCurrency=t.resolvePriceForCurrency,exports.resolvePriceRangeForCurrency=t.resolvePriceRangeForCurrency,exports.resolveTermValue=u.resolveTermValue,exports.resolveTranslatedText=u.resolveTranslatedText,exports.serializeInvoiceSettings=D.serializeInvoiceSettings,exports.sortCurrencies=t.sortCurrencies,exports.toNoCookieEmbedSrc=S.toNoCookieEmbedSrc,exports.translateOrFallback=b.translateOrFallback,exports.translateOrderStatus=b.translateOrderStatus,exports.useCanPurchase=f.useCanPurchase,exports.useCart=a.useCart,exports.useCartStore=i.useCartStore,exports.useCartSubtotal=i.useCartSubtotal,exports.useCartTotalItems=i.useCartTotalItems,exports.useCurrency=r.useCurrency,exports.useCurrencyPreferenceStore=n.useCurrencyPreferenceStore,exports.useIsCartHydrated=a.useIsCartHydrated,exports.usePaymentReadiness=f.usePaymentReadiness,exports.useProduct=F.useProduct;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib/types.cjs"),t=require("./lib/currency.cjs"),n=require("./lib/currency-store.cjs"),r=require("./lib/CurrencyProvider.cjs"),i=require("./lib/cart-store.cjs"),a=require("./lib/use-cart.cjs"),o=require("./lib/trials.cjs"),s=require("./lib/coupons.cjs"),c=require("./lib/components/CouponForm.cjs"),l=require("./lib/components/CartDrawer.cjs"),u=require("./lib/variation-utils.cjs"),d=require("./lib/components/Cart.cjs"),f=require("./lib/PaymentReadinessProvider.cjs"),p=require("./lib/customer.cjs"),m=require("./lib/components/Checkout.cjs"),h=require("./lib/components/CartIcon.cjs"),g=require("./lib/components/CurrencySwitcher.cjs"),_=require("./lib/components/AddToCartButton.cjs"),v=require("./lib/components/ProductCard.cjs"),y=require("./lib/components/ProductGrid.cjs"),b=require("./lib/invoice-ui.cjs"),x=require("./lib/components/ProductGallery.cjs"),S=require("./lib/components/SimpleTiptapRenderer.cjs"),C=require("./lib/components/FeaturedProduct.cjs"),w=require("./lib/components/AccountNavigationMenu.cjs"),T=require("./lib/components/CustomerProfileForm.cjs"),E=require("./lib/components/SubscriptionSelector.cjs"),D=require("./lib/invoice.cjs"),O=require("./lib/order-tax-details.cjs"),k=require("./lib/components/InvoiceDocument.cjs"),A=require("./lib/components/InvoiceViewerShell.cjs"),j=require("./lib/components/FreemiusLicensePanel.cjs"),M=require("./lib/product-schema.cjs"),N=require("./lib/pages/cms/products/components/ProductCategorySelector.cjs"),P=require("./lib/pages/cms/products/components/ProductForm.cjs"),F=require("./lib/product-context.cjs"),I=require("./lib/components/ProductDetailsLayout.cjs");exports.AccountNavigationMenu=w.AccountNavigationMenu,exports.AddToCartButton=_.AddToCartButton,exports.COUPON_INVALID_ERROR_KEY=s.COUPON_INVALID_ERROR_KEY,exports.COUPON_INVALID_ERROR_MESSAGE=s.COUPON_INVALID_ERROR_MESSAGE,exports.COUPON_THROTTLED_ERROR_KEY=s.COUPON_THROTTLED_ERROR_KEY,exports.COUPON_THROTTLED_ERROR_MESSAGE=s.COUPON_THROTTLED_ERROR_MESSAGE,exports.CURRENCY_ROUNDING_MODES=t.CURRENCY_ROUNDING_MODES,exports.Cart=d.Cart,exports.CartDrawer=l.CartDrawer,exports.CartIcon=h.CartIcon,exports.Checkout=m.Checkout,exports.CouponForm=c.CouponForm,exports.CurrencyProvider=r.CurrencyProvider,exports.CurrencySwitcher=g.CurrencySwitcher,exports.CustomerProfileForm=T.CustomerProfileForm,exports.DEFAULT_ENABLED_PAYMENT_PROVIDERS=e.DEFAULT_ENABLED_PAYMENT_PROVIDERS,exports.DEFAULT_INVOICE_SETTINGS=D.DEFAULT_INVOICE_SETTINGS,exports.FeaturedProduct=C.FeaturedProduct,exports.FreemiusLicensePanel=j.FreemiusLicensePanel,exports.INVOICE_SETTINGS_KEY=D.INVOICE_SETTINGS_KEY,exports.InvoiceDocument=k.InvoiceDocument,exports.InvoiceViewerShell=A.InvoiceViewerShell,exports.PaymentReadinessProvider=f.PaymentReadinessProvider,exports.ProductCard=v.ProductCard,exports.ProductCategorySelector=N.ProductCategorySelector,exports.ProductDetailsLayout=I.ProductDetailsLayout,exports.ProductForm=P.ProductForm,exports.ProductGallery=x.ProductGallery,exports.ProductGrid=y.ProductGrid,exports.ProductProvider=F.ProductProvider,exports.SimpleTiptapRenderer=S.SimpleTiptapRenderer,exports.SubscriptionSelector=E.SubscriptionSelector,exports.addressesMatch=p.addressesMatch,exports.aggregateOrderTaxLines=O.aggregateOrderTaxLines,exports.applyCurrencyRounding=t.applyCurrencyRounding,exports.applyVariantSelection=u.applyVariantSelection,exports.buildCombinationKey=u.buildCombinationKey,exports.buildInvoiceDocumentLabels=b.buildInvoiceDocumentLabels,exports.buildOrderTaxDetailsFromCalculation=O.buildOrderTaxDetailsFromCalculation,exports.buildOrderTaxDetailsFromStripeSession=O.buildOrderTaxDetailsFromStripeSession,exports.buildVariantLabel=u.buildVariantLabel,exports.chooseInitialVariantSelections=u.chooseInitialVariantSelections,exports.convertMinorUnitAmount=t.convertMinorUnitAmount,exports.derivePaymentProviderFromProductType=e.derivePaymentProviderFromProductType,exports.describeCurrencyRoundingRule=t.describeCurrencyRoundingRule,exports.emptyCustomerAddress=p.emptyCustomerAddress,exports.emptyProviderDiscounts=s.emptyProviderDiscounts,exports.extractSelectedTermsByAttribute=u.extractSelectedTermsByAttribute,exports.findMatchingVariant=u.findMatchingVariant,exports.formatInvoiceCurrency=D.formatInvoiceCurrency,exports.formatInvoiceDate=D.formatInvoiceDate,exports.generateVariantDrafts=u.generateVariantDrafts,exports.getAvailableTermIdsForAttribute=u.getAvailableTermIdsForAttribute,exports.getCartItemActivePrice=i.getCartItemActivePrice,exports.getCartLineCouponKey=s.getCartLineCouponKey,exports.getCurrencyLookup=t.getCurrencyLookup,exports.getDefaultCurrency=t.getDefaultCurrency,exports.getExchangeRateForCurrency=t.getExchangeRateForCurrency,exports.getInvoiceAddressLines=D.getInvoiceAddressLines,exports.getInvoiceLocale=b.getInvoiceLocale,exports.getOrderTaxRateJurisdiction=O.getOrderTaxRateJurisdiction,exports.getOrderTaxRateLabel=O.getOrderTaxRateLabel,exports.getOrderTaxRatePercentage=O.getOrderTaxRatePercentage,exports.getProductPaymentProvider=e.getProductPaymentProvider,exports.getTrialCheckoutMode=o.getTrialCheckoutMode,exports.getTrialLabel=o.getTrialLabel,exports.getTrialPaymentRequirementLabel=o.getTrialPaymentRequirementLabel,exports.getTrialPeriodDays=o.getTrialPeriodDays,exports.getTrialSummary=o.getTrialSummary,exports.getVariantEffectivePriceRange=u.getVariantEffectivePriceRange,exports.inferCurrencyCodeFromLocale=t.inferCurrencyCodeFromLocale,exports.isCustomerAddressComplete=p.isCustomerAddressComplete,exports.isDigitalItem=e.isDigitalItem,exports.isDigitalProduct=e.isDigitalProduct,exports.isSaleWindowActive=t.isSaleWindowActive,exports.isScheduledPriceDue=t.isScheduledPriceDue,exports.localizeInvoicePresentationData=b.localizeInvoicePresentationData,exports.mapRawVariantRelations=u.mapRawVariantRelations,exports.normalizeCouponCode=s.normalizeCouponCode,exports.normalizeCurrencyRecord=t.normalizeCurrencyRecord,exports.normalizeCurrencyRoundingMode=t.normalizeCurrencyRoundingMode,exports.normalizeCustomerAddress=p.normalizeCustomerAddress,exports.normalizeEnabledPaymentProviders=e.normalizeEnabledPaymentProviders,exports.normalizeInvoiceSettings=D.normalizeInvoiceSettings,exports.normalizeOrderCustomerDetails=p.normalizeOrderCustomerDetails,exports.normalizeOrderTaxDetails=O.normalizeOrderTaxDetails,exports.normalizePriceMap=t.normalizePriceMap,exports.normalizeSalePriceMap=t.normalizeSalePriceMap,exports.normalizeSelectionsToAvailableVariants=u.normalizeSelectionsToAvailableVariants,exports.productSchema=M.productSchema,exports.reconcileCouponContextItems=s.reconcileCouponContextItems,exports.resolveAttributeName=u.resolveAttributeName,exports.resolveEffectivePriceForCurrency=t.resolveEffectivePriceForCurrency,exports.resolvePriceForCurrency=t.resolvePriceForCurrency,exports.resolvePriceRangeForCurrency=t.resolvePriceRangeForCurrency,exports.resolveTermValue=u.resolveTermValue,exports.resolveTranslatedText=u.resolveTranslatedText,exports.serializeInvoiceSettings=D.serializeInvoiceSettings,exports.sortCurrencies=t.sortCurrencies,exports.toNoCookieEmbedSrc=S.toNoCookieEmbedSrc,exports.translateOrFallback=b.translateOrFallback,exports.translateOrderStatus=b.translateOrderStatus,exports.useCanPurchase=f.useCanPurchase,exports.useCart=a.useCart,exports.useCartStore=i.useCartStore,exports.useCartSubtotal=i.useCartSubtotal,exports.useCartTotalItems=i.useCartTotalItems,exports.useCurrency=r.useCurrency,exports.useCurrencyPreferenceStore=n.useCurrencyPreferenceStore,exports.useIsCartHydrated=a.useIsCartHydrated,exports.usePaymentReadiness=f.usePaymentReadiness,exports.useProduct=F.useProduct;
package/index.es.js CHANGED
@@ -5,34 +5,34 @@ import { CurrencyProvider as T, useCurrency as E } from "./lib/CurrencyProvider.
5
5
  import { getCartItemActivePrice as D, useCartStore as O, useCartSubtotal as k, useCartTotalItems as A } from "./lib/cart-store.es.js";
6
6
  import { useCart as j, useIsCartHydrated as M } from "./lib/use-cart.es.js";
7
7
  import { getTrialCheckoutMode as N, getTrialLabel as P, getTrialPaymentRequirementLabel as F, getTrialPeriodDays as I, getTrialSummary as L } from "./lib/trials.es.js";
8
- import { COUPON_INVALID_ERROR_KEY as R, COUPON_INVALID_ERROR_MESSAGE as z, COUPON_THROTTLED_ERROR_KEY as B, COUPON_THROTTLED_ERROR_MESSAGE as V, emptyProviderDiscounts as H, getCartLineCouponKey as U, normalizeCouponCode as W } from "./lib/coupons.es.js";
9
- import { CouponForm as G } from "./lib/components/CouponForm.es.js";
10
- import { CartDrawer as K } from "./lib/components/CartDrawer.es.js";
11
- import { applyVariantSelection as q, buildCombinationKey as J, buildVariantLabel as Y, chooseInitialVariantSelections as X, extractSelectedTermsByAttribute as Z, findMatchingVariant as Q, generateVariantDrafts as $, getAvailableTermIdsForAttribute as ee, getVariantEffectivePriceRange as te, mapRawVariantRelations as ne, normalizeSelectionsToAvailableVariants as re, resolveAttributeName as ie, resolveTermValue as ae, resolveTranslatedText as oe } from "./lib/variation-utils.es.js";
12
- import { Cart as se } from "./lib/components/Cart.es.js";
13
- import { PaymentReadinessProvider as ce, useCanPurchase as le, usePaymentReadiness as ue } from "./lib/PaymentReadinessProvider.es.js";
14
- import { addressesMatch as de, emptyCustomerAddress as fe, isCustomerAddressComplete as pe, normalizeCustomerAddress as me, normalizeOrderCustomerDetails as he } from "./lib/customer.es.js";
15
- import { Checkout as ge } from "./lib/components/Checkout.es.js";
16
- import { CartIcon as _e } from "./lib/components/CartIcon.es.js";
17
- import { CurrencySwitcher as ve } from "./lib/components/CurrencySwitcher.es.js";
18
- import { AddToCartButton as ye } from "./lib/components/AddToCartButton.es.js";
19
- import { ProductCard as be } from "./lib/components/ProductCard.es.js";
20
- import { ProductGrid as xe } from "./lib/components/ProductGrid.es.js";
21
- import { buildInvoiceDocumentLabels as Se, getInvoiceLocale as Ce, localizeInvoicePresentationData as we, translateOrFallback as Te, translateOrderStatus as Ee } from "./lib/invoice-ui.es.js";
22
- import { ProductGallery as De } from "./lib/components/ProductGallery.es.js";
23
- import { SimpleTiptapRenderer as Oe, toNoCookieEmbedSrc as ke } from "./lib/components/SimpleTiptapRenderer.es.js";
24
- import { FeaturedProduct as Ae } from "./lib/components/FeaturedProduct.es.js";
25
- import { AccountNavigationMenu as je } from "./lib/components/AccountNavigationMenu.es.js";
26
- import { CustomerProfileForm as Me } from "./lib/components/CustomerProfileForm.es.js";
27
- import { SubscriptionSelector as Ne } from "./lib/components/SubscriptionSelector.es.js";
28
- import { DEFAULT_INVOICE_SETTINGS as Pe, INVOICE_SETTINGS_KEY as Fe, formatInvoiceCurrency as Ie, formatInvoiceDate as Le, getInvoiceAddressLines as Re, normalizeInvoiceSettings as ze, serializeInvoiceSettings as Be } from "./lib/invoice.es.js";
29
- import { aggregateOrderTaxLines as Ve, buildOrderTaxDetailsFromCalculation as He, buildOrderTaxDetailsFromStripeSession as Ue, getOrderTaxRateJurisdiction as We, getOrderTaxRateLabel as Ge, getOrderTaxRatePercentage as Ke, normalizeOrderTaxDetails as qe } from "./lib/order-tax-details.es.js";
30
- import { InvoiceDocument as Je } from "./lib/components/InvoiceDocument.es.js";
31
- import { InvoiceViewerShell as Ye } from "./lib/components/InvoiceViewerShell.es.js";
32
- import { FreemiusLicensePanel as Xe } from "./lib/components/FreemiusLicensePanel.es.js";
33
- import { productSchema as Ze } from "./lib/product-schema.es.js";
34
- import { ProductCategorySelector as Qe } from "./lib/pages/cms/products/components/ProductCategorySelector.es.js";
35
- import { ProductForm as $e } from "./lib/pages/cms/products/components/ProductForm.es.js";
36
- import { ProductProvider as et, useProduct as tt } from "./lib/product-context.es.js";
37
- import { ProductDetailsLayout as nt } from "./lib/components/ProductDetailsLayout.es.js";
38
- export { je as AccountNavigationMenu, ye as AddToCartButton, R as COUPON_INVALID_ERROR_KEY, z as COUPON_INVALID_ERROR_MESSAGE, B as COUPON_THROTTLED_ERROR_KEY, V as COUPON_THROTTLED_ERROR_MESSAGE, o as CURRENCY_ROUNDING_MODES, se as Cart, K as CartDrawer, _e as CartIcon, ge as Checkout, G as CouponForm, T as CurrencyProvider, ve as CurrencySwitcher, Me as CustomerProfileForm, e as DEFAULT_ENABLED_PAYMENT_PROVIDERS, Pe as DEFAULT_INVOICE_SETTINGS, Ae as FeaturedProduct, Xe as FreemiusLicensePanel, Fe as INVOICE_SETTINGS_KEY, Je as InvoiceDocument, Ye as InvoiceViewerShell, ce as PaymentReadinessProvider, be as ProductCard, Qe as ProductCategorySelector, nt as ProductDetailsLayout, $e as ProductForm, De as ProductGallery, xe as ProductGrid, et as ProductProvider, Oe as SimpleTiptapRenderer, Ne as SubscriptionSelector, de as addressesMatch, Ve as aggregateOrderTaxLines, s as applyCurrencyRounding, q as applyVariantSelection, J as buildCombinationKey, Se as buildInvoiceDocumentLabels, He as buildOrderTaxDetailsFromCalculation, Ue as buildOrderTaxDetailsFromStripeSession, Y as buildVariantLabel, X as chooseInitialVariantSelections, c as convertMinorUnitAmount, t as derivePaymentProviderFromProductType, l as describeCurrencyRoundingRule, fe as emptyCustomerAddress, H as emptyProviderDiscounts, Z as extractSelectedTermsByAttribute, Q as findMatchingVariant, Ie as formatInvoiceCurrency, Le as formatInvoiceDate, $ as generateVariantDrafts, ee as getAvailableTermIdsForAttribute, D as getCartItemActivePrice, U as getCartLineCouponKey, u as getCurrencyLookup, d as getDefaultCurrency, f as getExchangeRateForCurrency, Re as getInvoiceAddressLines, Ce as getInvoiceLocale, We as getOrderTaxRateJurisdiction, Ge as getOrderTaxRateLabel, Ke as getOrderTaxRatePercentage, n as getProductPaymentProvider, N as getTrialCheckoutMode, P as getTrialLabel, F as getTrialPaymentRequirementLabel, I as getTrialPeriodDays, L as getTrialSummary, te as getVariantEffectivePriceRange, p as inferCurrencyCodeFromLocale, pe as isCustomerAddressComplete, r as isDigitalItem, i as isDigitalProduct, m as isSaleWindowActive, h as isScheduledPriceDue, we as localizeInvoicePresentationData, ne as mapRawVariantRelations, W as normalizeCouponCode, g as normalizeCurrencyRecord, _ as normalizeCurrencyRoundingMode, me as normalizeCustomerAddress, a as normalizeEnabledPaymentProviders, ze as normalizeInvoiceSettings, he as normalizeOrderCustomerDetails, qe as normalizeOrderTaxDetails, v as normalizePriceMap, y as normalizeSalePriceMap, re as normalizeSelectionsToAvailableVariants, Ze as productSchema, ie as resolveAttributeName, b as resolveEffectivePriceForCurrency, x as resolvePriceForCurrency, S as resolvePriceRangeForCurrency, ae as resolveTermValue, oe as resolveTranslatedText, Be as serializeInvoiceSettings, C as sortCurrencies, ke as toNoCookieEmbedSrc, Te as translateOrFallback, Ee as translateOrderStatus, le as useCanPurchase, j as useCart, O as useCartStore, k as useCartSubtotal, A as useCartTotalItems, E as useCurrency, w as useCurrencyPreferenceStore, M as useIsCartHydrated, ue as usePaymentReadiness, tt as useProduct };
8
+ import { COUPON_INVALID_ERROR_KEY as R, COUPON_INVALID_ERROR_MESSAGE as z, COUPON_THROTTLED_ERROR_KEY as B, COUPON_THROTTLED_ERROR_MESSAGE as V, emptyProviderDiscounts as H, getCartLineCouponKey as U, normalizeCouponCode as W, reconcileCouponContextItems as G } from "./lib/coupons.es.js";
9
+ import { CouponForm as K } from "./lib/components/CouponForm.es.js";
10
+ import { CartDrawer as q } from "./lib/components/CartDrawer.es.js";
11
+ import { applyVariantSelection as J, buildCombinationKey as Y, buildVariantLabel as X, chooseInitialVariantSelections as Z, extractSelectedTermsByAttribute as Q, findMatchingVariant as $, generateVariantDrafts as ee, getAvailableTermIdsForAttribute as te, getVariantEffectivePriceRange as ne, mapRawVariantRelations as re, normalizeSelectionsToAvailableVariants as ie, resolveAttributeName as ae, resolveTermValue as oe, resolveTranslatedText as se } from "./lib/variation-utils.es.js";
12
+ import { Cart as ce } from "./lib/components/Cart.es.js";
13
+ import { PaymentReadinessProvider as le, useCanPurchase as ue, usePaymentReadiness as de } from "./lib/PaymentReadinessProvider.es.js";
14
+ import { addressesMatch as fe, emptyCustomerAddress as pe, isCustomerAddressComplete as me, normalizeCustomerAddress as he, normalizeOrderCustomerDetails as ge } from "./lib/customer.es.js";
15
+ import { Checkout as _e } from "./lib/components/Checkout.es.js";
16
+ import { CartIcon as ve } from "./lib/components/CartIcon.es.js";
17
+ import { CurrencySwitcher as ye } from "./lib/components/CurrencySwitcher.es.js";
18
+ import { AddToCartButton as be } from "./lib/components/AddToCartButton.es.js";
19
+ import { ProductCard as xe } from "./lib/components/ProductCard.es.js";
20
+ import { ProductGrid as Se } from "./lib/components/ProductGrid.es.js";
21
+ import { buildInvoiceDocumentLabels as Ce, getInvoiceLocale as we, localizeInvoicePresentationData as Te, translateOrFallback as Ee, translateOrderStatus as De } from "./lib/invoice-ui.es.js";
22
+ import { ProductGallery as Oe } from "./lib/components/ProductGallery.es.js";
23
+ import { SimpleTiptapRenderer as ke, toNoCookieEmbedSrc as Ae } from "./lib/components/SimpleTiptapRenderer.es.js";
24
+ import { FeaturedProduct as je } from "./lib/components/FeaturedProduct.es.js";
25
+ import { AccountNavigationMenu as Me } from "./lib/components/AccountNavigationMenu.es.js";
26
+ import { CustomerProfileForm as Ne } from "./lib/components/CustomerProfileForm.es.js";
27
+ import { SubscriptionSelector as Pe } from "./lib/components/SubscriptionSelector.es.js";
28
+ import { DEFAULT_INVOICE_SETTINGS as Fe, INVOICE_SETTINGS_KEY as Ie, formatInvoiceCurrency as Le, formatInvoiceDate as Re, getInvoiceAddressLines as ze, normalizeInvoiceSettings as Be, serializeInvoiceSettings as Ve } from "./lib/invoice.es.js";
29
+ import { aggregateOrderTaxLines as He, buildOrderTaxDetailsFromCalculation as Ue, buildOrderTaxDetailsFromStripeSession as We, getOrderTaxRateJurisdiction as Ge, getOrderTaxRateLabel as Ke, getOrderTaxRatePercentage as qe, normalizeOrderTaxDetails as Je } from "./lib/order-tax-details.es.js";
30
+ import { InvoiceDocument as Ye } from "./lib/components/InvoiceDocument.es.js";
31
+ import { InvoiceViewerShell as Xe } from "./lib/components/InvoiceViewerShell.es.js";
32
+ import { FreemiusLicensePanel as Ze } from "./lib/components/FreemiusLicensePanel.es.js";
33
+ import { productSchema as Qe } from "./lib/product-schema.es.js";
34
+ import { ProductCategorySelector as $e } from "./lib/pages/cms/products/components/ProductCategorySelector.es.js";
35
+ import { ProductForm as et } from "./lib/pages/cms/products/components/ProductForm.es.js";
36
+ import { ProductProvider as tt, useProduct as nt } from "./lib/product-context.es.js";
37
+ import { ProductDetailsLayout as rt } from "./lib/components/ProductDetailsLayout.es.js";
38
+ export { Me as AccountNavigationMenu, be as AddToCartButton, R as COUPON_INVALID_ERROR_KEY, z as COUPON_INVALID_ERROR_MESSAGE, B as COUPON_THROTTLED_ERROR_KEY, V as COUPON_THROTTLED_ERROR_MESSAGE, o as CURRENCY_ROUNDING_MODES, ce as Cart, q as CartDrawer, ve as CartIcon, _e as Checkout, K as CouponForm, T as CurrencyProvider, ye as CurrencySwitcher, Ne as CustomerProfileForm, e as DEFAULT_ENABLED_PAYMENT_PROVIDERS, Fe as DEFAULT_INVOICE_SETTINGS, je as FeaturedProduct, Ze as FreemiusLicensePanel, Ie as INVOICE_SETTINGS_KEY, Ye as InvoiceDocument, Xe as InvoiceViewerShell, le as PaymentReadinessProvider, xe as ProductCard, $e as ProductCategorySelector, rt as ProductDetailsLayout, et as ProductForm, Oe as ProductGallery, Se as ProductGrid, tt as ProductProvider, ke as SimpleTiptapRenderer, Pe as SubscriptionSelector, fe as addressesMatch, He as aggregateOrderTaxLines, s as applyCurrencyRounding, J as applyVariantSelection, Y as buildCombinationKey, Ce as buildInvoiceDocumentLabels, Ue as buildOrderTaxDetailsFromCalculation, We as buildOrderTaxDetailsFromStripeSession, X as buildVariantLabel, Z as chooseInitialVariantSelections, c as convertMinorUnitAmount, t as derivePaymentProviderFromProductType, l as describeCurrencyRoundingRule, pe as emptyCustomerAddress, H as emptyProviderDiscounts, Q as extractSelectedTermsByAttribute, $ as findMatchingVariant, Le as formatInvoiceCurrency, Re as formatInvoiceDate, ee as generateVariantDrafts, te as getAvailableTermIdsForAttribute, D as getCartItemActivePrice, U as getCartLineCouponKey, u as getCurrencyLookup, d as getDefaultCurrency, f as getExchangeRateForCurrency, ze as getInvoiceAddressLines, we as getInvoiceLocale, Ge as getOrderTaxRateJurisdiction, Ke as getOrderTaxRateLabel, qe as getOrderTaxRatePercentage, n as getProductPaymentProvider, N as getTrialCheckoutMode, P as getTrialLabel, F as getTrialPaymentRequirementLabel, I as getTrialPeriodDays, L as getTrialSummary, ne as getVariantEffectivePriceRange, p as inferCurrencyCodeFromLocale, me as isCustomerAddressComplete, r as isDigitalItem, i as isDigitalProduct, m as isSaleWindowActive, h as isScheduledPriceDue, Te as localizeInvoicePresentationData, re as mapRawVariantRelations, W as normalizeCouponCode, g as normalizeCurrencyRecord, _ as normalizeCurrencyRoundingMode, he as normalizeCustomerAddress, a as normalizeEnabledPaymentProviders, Be as normalizeInvoiceSettings, ge as normalizeOrderCustomerDetails, Je as normalizeOrderTaxDetails, v as normalizePriceMap, y as normalizeSalePriceMap, ie as normalizeSelectionsToAvailableVariants, Qe as productSchema, G as reconcileCouponContextItems, ae as resolveAttributeName, b as resolveEffectivePriceForCurrency, x as resolvePriceForCurrency, S as resolvePriceRangeForCurrency, oe as resolveTermValue, se as resolveTranslatedText, Ve as serializeInvoiceSettings, C as sortCurrencies, Ae as toNoCookieEmbedSrc, Ee as translateOrFallback, De as translateOrderStatus, ue as useCanPurchase, j as useCart, O as useCartStore, k as useCartSubtotal, A as useCartTotalItems, E as useCurrency, w as useCurrencyPreferenceStore, M as useIsCartHydrated, de as usePaymentReadiness, nt as useProduct };
@@ -1 +1 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../types.cjs"),t=require("../CurrencyProvider.cjs"),n=require("../cart-store.cjs"),r=require("../use-cart.cjs"),i=require("../use-price-formatter.cjs"),a=require("../trials.cjs"),o=require("./CouponForm.cjs"),s=require("../countries.cjs"),c=require("../states.cjs"),ee=require("../server-actions/shipping-actions.cjs"),te=require("../PaymentReadinessProvider.cjs"),ne=require("../server-actions/tax-actions.cjs"),l=require("../customer.cjs");let re=require("@nextblock-cms/ui/badge"),ie=require("@nextblock-cms/ui/button"),u=require("react"),d=require("lucide-react"),ae=require("@nextblock-cms/utils"),f=require("react/jsx-runtime"),p=require("@nextblock-cms/ui/input"),m=require("@nextblock-cms/ui/label"),h=require("@nextblock-cms/ui/card"),oe=require("@nextblock-cms/ui/checkbox"),se=require("@nextblock-cms/ui/separator"),g=require("@nextblock-cms/ui/radio-group"),ce=require("@freemius/checkout");var le=process.env.NEXT_PUBLIC_IS_SANDBOX===`true`,_=`nextblock-checkout-draft-v1`;function v(e,t){return{...l.emptyCustomerAddress(),company_name:e?.company_name||``,recipient_name:e?.recipient_name||t||``,line1:e?.line1||``,line2:e?.line2||``,city:e?.city||``,state:e?.state||``,postal_code:e?.postal_code||``,country_code:s.normalizeCountryCode(e?.country_code)||`CA`}}function ue(e){let t=l.normalizeCustomerAddress(e);return!(!t?.country_code||!t.postal_code||c.countryUsesStructuredStates(t.country_code)&&!t.state)}function de(e,t,r){return e.reduce((e,i)=>{let{price:a,sale_price:o}=n.getCartItemActivePrice(i,{currencyCode:t,currencies:r});return e+(o??a)*i.quantity},0)}function fe({idPrefix:e,title:t,description:n,value:r,onChange:i}){let{t:a,lang:o}=(0,ae.useTranslations)(),ee=(0,u.useMemo)(()=>{try{return new Intl.DisplayNames([o],{type:`region`})}catch{return null}},[o]),te=a(`company_name`)===`company_name`?`Company name`:a(`company_name`),ne=a(`select_an_option`)===`select_an_option`?`Select an option`:a(`select_an_option`),l=a(`state_province`)===`state_province`?`State / Province`:a(`state_province`),re=c.getStatesForCountry(r.country_code),ie=c.countryUsesStructuredStates(r.country_code);return(0,f.jsxs)(h.Card,{children:[(0,f.jsxs)(h.CardHeader,{children:[(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.MapPin,{className:`w-5 h-5`}),t]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n})]}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-company`,children:te}),(0,f.jsx)(p.Input,{id:`${e}-company`,name:`${e}-company`,autoComplete:`${e} organization`,value:r.company_name,onChange:e=>i({...r,company_name:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-name`,children:a(`full_name`)}),(0,f.jsx)(p.Input,{id:`${e}-name`,name:`${e}-name`,autoComplete:`${e} name`,required:!0,value:r.recipient_name,onChange:e=>i({...r,recipient_name:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-country`,children:a(`country`)}),(0,f.jsx)(`select`,{id:`${e}-country`,name:`${e}-country`,autoComplete:`${e} country`,required:!0,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,value:r.country_code,onChange:e=>{let t=e.target.value,n=c.getStatesForCountry(t);i({...r,country_code:t,state:n.some(e=>e.code===r.state)?r.state:``})},children:s.countries.map(e=>(0,f.jsx)(`option`,{value:e.code,children:ee?.of(e.code)??e.name},e.code))})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-line1`,children:a(`address_line_1`)}),(0,f.jsx)(p.Input,{id:`${e}-line1`,name:`${e}-line1`,autoComplete:`${e} address-line1`,required:!0,value:r.line1,onChange:e=>i({...r,line1:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-line2`,children:a(`address_line_2`)}),(0,f.jsx)(p.Input,{id:`${e}-line2`,name:`${e}-line2`,autoComplete:`${e} address-line2`,value:r.line2,onChange:e=>i({...r,line2:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-city`,children:a(`city`)}),(0,f.jsx)(p.Input,{id:`${e}-city`,name:`${e}-city`,autoComplete:`${e} address-level2`,required:!0,value:r.city,onChange:e=>i({...r,city:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-state`,children:a(`state_province`)}),ie?(0,f.jsxs)(`select`,{id:`${e}-state`,name:`${e}-state`,autoComplete:`${e} address-level1`,required:!0,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,value:r.state,onChange:e=>i({...r,state:e.target.value}),children:[(0,f.jsx)(`option`,{value:``,children:`${ne}: ${l}`}),re.map(e=>(0,f.jsx)(`option`,{value:e.code,children:c.getSubdivisionLabel(r.country_code,e,o)},e.code))]}):(0,f.jsx)(p.Input,{id:`${e}-state`,name:`${e}-state`,autoComplete:`${e} address-level1`,value:r.state,onChange:e=>i({...r,state:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-postal`,children:a(`postal_zip_code`)}),(0,f.jsx)(p.Input,{id:`${e}-postal`,name:`${e}-postal`,autoComplete:`${e} postal-code`,required:!0,value:r.postal_code,onChange:e=>i({...r,postal_code:e.target.value})})]})]})]})]})}function pe({title:e,description:t,badgeLabel:n,children:r}){return(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(h.CardTitle,{role:`heading`,"aria-level":2,children:e}),(0,f.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),n?(0,f.jsx)(re.Badge,{variant:`secondary`,children:n}):null]})}),(0,f.jsx)(h.CardContent,{className:`space-y-4`,children:r})]})}var y=({initialCustomer:s})=>{let y=i.usePriceFormatter(),[me,he]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)({}),[w,ge]=(0,u.useState)(s?.email||``),[T,_e]=(0,u.useState)(``),[E,ve]=(0,u.useState)(s?.phone||``),[ye,be]=(0,u.useState)(!1),[xe,Se]=(0,u.useState)(null),[Ce,D]=(0,u.useState)(!1),[we,Te]=(0,u.useState)(!1),[Ee,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)([]),[j,M]=(0,u.useState)(null),[N,P]=(0,u.useState)(null),[F,De]=(0,u.useState)(null),[I,Oe]=(0,u.useState)(()=>v(s?.billingAddress,s?.fullName)),[L,ke]=(0,u.useState)(()=>v(s?.shippingAddress??s?.billingAddress,s?.fullName)),[R,Ae]=(0,u.useState)(!s?.shippingAddress||l.addressesMatch(s?.billingAddress,s?.shippingAddress)),z=r.useCart(e=>e),{t:B,lang:je}=(0,ae.useTranslations)(),{activeCurrencyCode:V,currencies:H}=t.useCurrency(),Me=te.usePaymentReadiness(),U=z?.items??[],W=(0,u.useMemo)(()=>U.filter(t=>!e.isDigitalItem(t)),[U]),G=(0,u.useMemo)(()=>U.filter(t=>e.isDigitalItem(t)),[U]),K=s?.isAuthenticated??!1,q=(e,t,n)=>{let r=B(e,n);if(r!==e)return r;if(!n)return t;let i=t;return Object.entries(n).forEach(([e,t])=>{i=i.replace(RegExp(`\\{${e}\\}`,`g`),String(t))}),i},J=W.length>0,Ne=(0,u.useMemo)(()=>de(U,V,H),[V,H,U]),Pe=(0,u.useMemo)(()=>de(W,V,H),[V,H,W]),Fe=(0,u.useMemo)(()=>de(G,V,H),[V,H,G]),Ie=F?.providerDiscounts.stripe??0,Le=F?.providerDiscounts.freemius??0,Y=Math.max(0,Pe-Ie),Re=Math.max(0,Fe-Le),X=(0,u.useMemo)(()=>R?I:L,[I,L,R]),Z=(0,u.useMemo)(()=>J?X:I,[I,J,X]),Q=!J||ue(X),$=(0,u.useMemo)(()=>k.find(e=>e.id===j),[k,j]),ze=(0,u.useMemo)(()=>Y+($?.amount??0)+(N&&!N.isPendingExternalCalculation?N.amount:0),[Y,$,N]),Be=ze+Re;if((0,u.useEffect)(()=>{if(!(K||typeof window>`u`))try{let e=window.localStorage.getItem(_);if(!e)return;let t=JSON.parse(e);t.email&&ge(t.email),t.phone&&ve(t.phone),t.billingAddress&&Oe(v(t.billingAddress)),t.shippingAddress&&ke(v(t.shippingAddress)),typeof t.useBillingForShipping==`boolean`&&Ae(t.useBillingForShipping),(typeof t.selectedMethodId==`string`||t.selectedMethodId===null)&&M(t.selectedMethodId)}catch(e){console.error(`[Checkout] Failed to restore checkout draft:`,e)}},[K]),(0,u.useEffect)(()=>{if(typeof window<`u`)try{if(K){window.localStorage.removeItem(_);return}window.localStorage.setItem(_,JSON.stringify({email:w,phone:E,billingAddress:I,shippingAddress:L,useBillingForShipping:R,selectedMethodId:j}))}catch{}},[I,w,K,E,j,L,R]),(0,u.useEffect)(()=>{if(!J){A([]),M(null),D(!1);return}if(!Q){A([]),M(null),D(!1);return}let e=!1,t=setTimeout(async()=>{if(X.country_code){D(!0),Te(!1);try{let t=await ee.getShippingEstimates(Y,{country:X.country_code,state:X.state,postal_code:X.postal_code},je,V);if(e)return;if(t.success&&t.methods){let e=t.methods;A(e),M(t=>t&&e.some(e=>e.id===t)?t:e[0]?.id??null)}else A([]),M(null)}catch(t){if(e)return;console.error(`[Checkout] Failed to load shipping rates:`,t),A([]),M(null),Te(!0)}finally{e||D(!1)}}},400);return()=>{e=!0,clearTimeout(t)}},[V,J,Q,je,X.country_code,X.postal_code,X.state,Y]),(0,u.useEffect)(()=>{let e=!1,t=setTimeout(async()=>{if(!J||!Z.country_code){O(!1),P(null);return}if(c.countryUsesStructuredStates(Z.country_code)&&!Z.state){O(!1),P(null);return}O(!0);try{let t=await ne.getTaxEstimate(W,{country_code:Z.country_code,state:Z.state},V,F?.code??null,U);if(e)return;P(t.success&&t.tax?t.tax:null)}catch(t){if(e)return;console.error(`[Checkout] Failed to load the tax estimate:`,t),P(null)}finally{e||O(!1)}},300);return()=>{e=!0,clearTimeout(t)}},[V,J,W,Z.country_code,Z.state,F?.code,U]),(0,u.useEffect)(()=>{let e=e=>{e.persisted&&x(null)};return window.addEventListener(`pageshow`,e),()=>window.removeEventListener(`pageshow`,e)},[]),!z)return(0,f.jsxs)(`div`,{role:`status`,"aria-busy":`true`,className:`container mx-auto px-4 py-12 md:px-6`,children:[(0,f.jsx)(`span`,{className:`sr-only`,children:B(`loading`)===`loading`?`Loading…`:B(`loading`)}),(0,f.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,f.jsx)(`div`,{className:`mb-8 h-9 w-48 rounded-md bg-muted`}),(0,f.jsxs)(`div`,{className:`grid gap-8 lg:grid-cols-12 lg:items-start`,children:[(0,f.jsxs)(`div`,{className:`space-y-6 lg:col-span-8`,children:[(0,f.jsx)(`div`,{className:`h-56 rounded-xl border bg-muted/40`}),(0,f.jsx)(`div`,{className:`h-96 rounded-xl border bg-muted/40`})]}),(0,f.jsx)(`div`,{className:`lg:col-span-4`,children:(0,f.jsx)(`div`,{className:`h-72 rounded-xl border bg-muted/40`})})]})]})]});let Ve=()=>{be(!1),Se(null)},He=ye?(0,f.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center overscroll-contain bg-black/60 backdrop-blur-sm`,onClick:Ve,onKeyDown:e=>{e.key===`Escape`&&Ve()},children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`sandbox-checkout-title`,className:`relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4`,onClick:e=>e.stopPropagation(),children:[(0,f.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:Ve,"aria-label":q(`close`,`Close`),className:`absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring`,children:(0,f.jsx)(d.X,{className:`w-5 h-5`})}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,f.jsx)(`div`,{className:`p-2 rounded-full bg-amber-100 dark:bg-amber-900/20`,children:(0,f.jsx)(d.FlaskConical,{className:`h-6 w-6 text-amber-600 dark:text-amber-400`})}),(0,f.jsx)(`h2`,{id:`sandbox-checkout-title`,className:`text-xl font-semibold`,children:B(`ecommerce.checkout_successful`)})]}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-2`,children:B(`ecommerce.sandbox_notice`)}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-2`,children:xe===`stripe`?q(`ecommerce.sandbox_checkout_stripe_description`,`This simulated step represents the Stripe checkout for physical products.`):q(`ecommerce.sandbox_checkout_freemius_description`,`This simulated step represents the Freemius checkout for digital products.`)}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-6`,children:B(`ecommerce.license_notice`)}),(0,f.jsx)(`a`,{href:`https://nextblock.dev`,target:`_blank`,rel:`noopener noreferrer`,className:`block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity`,children:B(`ecommerce.purchase_at`)})]})}):null,Ue=(e,t,n)=>(C(n=>({...n,[e]:t})),n&&document.getElementById(n)?.focus(),null),We=(e,t)=>t.recipient_name.trim()?t.line1.trim()?t.city.trim()?c.countryUsesStructuredStates(t.country_code)&&!t.state?`${e}-state`:t.postal_code.trim()?`${e}-line1`:`${e}-postal`:`${e}-city`:`${e}-line1`:`${e}-name`,Ge=e=>{if(!K&&(!w||!/^\S+@\S+\.\S+$/.test(w)))return _e(B(`ecommerce.invalid_email`)),Ue(e,B(`ecommerce.invalid_email`),`checkout-email`);let t=l.normalizeCustomerAddress(I);if(!l.isCustomerAddressComplete(t))return Ue(e,B(`checkout_complete_billing_address`),We(`billing`,I));let n=J?l.normalizeCustomerAddress(R?I:L):null;if(e===`stripe`){if(!l.isCustomerAddressComplete(n))return Ue(e,B(`checkout_complete_shipping_address`),R?We(`billing`,I):We(`shipping`,L));if(!j)return Ue(e,q(`ecommerce.shipping_method_required`,`Please select a shipping method before continuing.`))}return _e(``),{normalizedBillingAddress:t,normalizedShippingAddress:n}},Ke=async(e,t,n)=>{C(t=>({...t,[e]:``}));let r=Ge(e);if(r){if(le){let n=new Set(t.map(e=>e.id)),r=U.filter(e=>!n.has(e.id));if(z.setItems(r),r.length===0&&z.removeCoupon(),Se(e),be(!0),typeof window<`u`&&r.length===0)try{window.localStorage.removeItem(_)}catch{}return}x(n);try{let n=await fetch(`/api/checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({items:t,customerEmail:K?void 0:w,customerPhone:E||null,billingAddress:r.normalizedBillingAddress,shippingAddress:e===`stripe`?r.normalizedShippingAddress:null,shippingMethodId:e===`stripe`?j:null,locale:je,currencyCode:V,couponCode:F?.code??z.appliedCoupon?.code??null,couponContextItems:U})}),i=await n.json();if(!n.ok){let t=i?.errorKey&&typeof i.errorKey==`string`?q(i.errorKey,i?.error||q(`ecommerce.generic_error`,`Something went wrong.`),i.errorParams):i?.error||B(`ecommerce.generic_error`);C(n=>({...n,[e]:t})),x(null);return}if(i.customProps&&i.customProps.provider===`freemius`){let t=i.customProps,n=null,r=()=>{let e=t.success_token?`&token=${encodeURIComponent(t.success_token)}`:``;window.location.href=`/checkout/success?session_id=${t.order_id}${e}`},a=e=>(n||=fetch(`/api/checkout/freemius/sync`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({orderId:t.order_id,checkoutResponse:e})}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);console.error(`Freemius checkout sync failed:`,t)}}),n),o={product_id:t.plugin_id,public_key:t.public_key,sandbox:t.sandbox},s={name:B(`ecommerce.checkout_overlay_title`),plan_id:t.plan_id,...t.billing_cycle?{billing_cycle:t.billing_cycle}:{},...t.trial?{trial:t.trial}:{},...t.coupon?{coupon:t.coupon}:{},user_email:t.user_email,user_firstname:t.user_firstname,user_lastname:t.user_lastname,sandbox:t.sandbox,purchaseCompleted:function(e){a(e)},success:function(e){(async()=>{try{await a(e)}finally{r()}})()}};try{new ce.Checkout(o).open(s),x(null)}catch(t){console.error(`[Checkout] Freemius overlay failed to open:`,t),C(t=>({...t,[e]:B(`ecommerce.checkout_popup_blocked`)})),i.url&&(window.location.href=i.url),x(null)}}else i.url?window.location.href=i.url:(C(t=>({...t,[e]:B(`ecommerce.checkout_failed`)+(i.error||q(`ecommerce.unknown_error`,`Unknown error`))})),x(null))}catch(t){console.error(t),C(t=>({...t,[e]:B(`ecommerce.generic_error`)})),x(null)}}};if(U.length===0)return(0,f.jsxs)(f.Fragment,{children:[He,(0,f.jsxs)(`div`,{className:`container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center`,children:[(0,f.jsx)(`h1`,{className:`mb-4 text-2xl font-bold`,children:B(`ecommerce.cart_empty`)}),(0,f.jsx)(`p`,{className:`mb-8 text-muted-foreground`,children:B(`ecommerce.cart_empty_description`)}),(0,f.jsx)(ie.Button,{asChild:!0,children:(0,f.jsx)(`a`,{href:`/shop`,children:B(`ecommerce.go_to_shop`)})})]})]});let qe=q(`ecommerce.checkout_payments_unavailable`,`This store is not able to take payments right now. Please contact the seller to complete your purchase.`),Je=Me.stripe?null:qe,Ye=Me.freemius?null:qe,Xe=Je||(J?Q?Ce?q(`ecommerce.calculating_shipping`,`Calculating shipping...`):j?null:k.length>0?B(`ecommerce.select_rate`):B(`ecommerce.no_rates_for_region`):q(`ecommerce.waiting_on_address_info`,`Complete your shipping address to view available shipping options.`):null),Ze=b!==null||Xe!==null,Qe=W.length===1?q(`ecommerce.item_count_one`,`{count} item`,{count:W.length}):q(`ecommerce.item_count_other`,`{count} items`,{count:W.length}),$e=G.length===1?q(`ecommerce.license_count_one`,`{count} license`,{count:G.length}):q(`ecommerce.license_count_other`,`{count} licenses`,{count:G.length}),et=t=>e.isDigitalItem(t)?q(`ecommerce.digital_label`,`Digital`):q(`ecommerce.physical_label`,`Physical`),tt=e=>e===`monthly`?q(`ecommerce.checkout_billing_cycle_monthly`,`Monthly subscription`):e===`annual`?q(`ecommerce.checkout_billing_cycle_annual`,`Annual subscription`):e===`lifetime`?q(`ecommerce.checkout_billing_cycle_lifetime`,`Lifetime subscription`):null;return(0,f.jsxs)(`div`,{className:`container mx-auto px-4 py-12 md:px-6`,children:[He,(0,f.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,f.jsx)(`h1`,{className:`mb-8 text-3xl font-bold`,children:B(`ecommerce.checkout`)}),(0,f.jsxs)(`div`,{className:`grid gap-8 lg:grid-cols-12 lg:items-start`,children:[(0,f.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.CreditCard,{className:`w-5 h-5`}),B(`ecommerce.contact_information`)]})}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[K?(0,f.jsx)(`div`,{className:`rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground`,children:B(`checkout_prefill_notice`,{email:s?.email||``})}):(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsxs)(m.Label,{htmlFor:`checkout-email`,children:[B(`ecommerce.email_address`),` `,(0,f.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,f.jsx)(p.Input,{id:`checkout-email`,name:`email`,type:`email`,autoComplete:`email`,spellCheck:!1,"aria-invalid":T?!0:void 0,"aria-describedby":T?`checkout-email-error`:void 0,placeholder:B(`ecommerce.email_placeholder`),value:w,onChange:e=>{ge(e.target.value),T&&_e(``)},required:!0}),T?(0,f.jsx)(`p`,{id:`checkout-email-error`,role:`alert`,className:`text-xs text-destructive mt-1`,children:T}):null]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`checkout-phone`,children:B(`phone_number`)}),(0,f.jsx)(p.Input,{id:`checkout-phone`,name:`phone`,type:`tel`,inputMode:`tel`,autoComplete:`tel`,placeholder:B(`optional`),value:E,onChange:e=>ve(e.target.value)})]})]})]}),(0,f.jsx)(fe,{idPrefix:`billing`,title:B(`billing_address`),description:B(`checkout_billing_address_help`),value:I,onChange:Oe}),J?(0,f.jsxs)(`div`,{className:`flex items-center space-x-3 rounded-xl border bg-muted/20 p-4`,children:[(0,f.jsx)(oe.Checkbox,{id:`use-billing-for-shipping`,checked:R,onCheckedChange:e=>Ae(!!e)}),(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(m.Label,{htmlFor:`use-billing-for-shipping`,className:`cursor-pointer`,children:B(`use_billing_for_shipping`)}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:B(`checkout_use_billing_for_shipping_help`)})]})]}):null,J&&!R?(0,f.jsx)(fe,{idPrefix:`shipping`,title:B(`shipping_address`),description:B(`checkout_shipping_address_help`),value:L,onChange:ke}):null,J?(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.ChevronRight,{className:`w-5 h-5 text-primary`}),B(`ecommerce.shipping_method`)]})}),(0,f.jsx)(h.CardContent,{children:Ce?(0,f.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center py-6`,children:[(0,f.jsx)(d.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`}),(0,f.jsx)(`span`,{className:`sr-only`,children:q(`ecommerce.calculating_shipping`,`Calculating shipping…`)})]}):we?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg bg-destructive/10 px-4 py-3 text-center text-sm text-destructive`,children:q(`ecommerce.shipping_calculation_failed`,`We couldn't calculate shipping right now. Please try again.`)}):k.length>0?(0,f.jsx)(g.RadioGroup,{value:j??``,onValueChange:M,"aria-label":B(`ecommerce.shipping_method`),className:`space-y-3`,children:k.map(e=>(0,f.jsxs)(m.Label,{htmlFor:`shipping-method-${e.id}`,className:`flex items-center justify-between gap-3 p-4 rounded-lg border-2 cursor-pointer transition-colors ${j===e.id?`border-primary bg-primary/5`:`border-border hover:border-muted-foreground/40`}`,children:[(0,f.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,f.jsx)(g.RadioGroupItem,{id:`shipping-method-${e.id}`,value:e.id}),(0,f.jsx)(`span`,{className:`font-medium break-words`,children:e.name})]}),(0,f.jsx)(`span`,{className:`font-bold tabular-nums`,children:y(e.amount,V)})]},e.id))}):(0,f.jsx)(`div`,{className:`py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic`,children:Q?B(`ecommerce.no_rates_for_region`):q(`ecommerce.waiting_on_address_info`,`Complete your shipping address to view available shipping options.`)})})]}):null]}),(0,f.jsxs)(`div`,{className:`lg:col-span-4 space-y-6`,children:[(0,f.jsxs)(h.Card,{className:`top-6`,children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsx)(h.CardTitle,{role:`heading`,"aria-level":2,children:B(`ecommerce.order_summary`)})}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[(0,f.jsx)(`div`,{className:`space-y-3 max-h-[260px] overflow-y-auto pr-2`,children:U.map(e=>{let t=n.getCartItemActivePrice(e,{currencyCode:V,currencies:H}),r=a.getTrialSummary(e,B);return(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex gap-3`,children:[e.image_url?(0,f.jsx)(`div`,{className:`h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100`,children:(0,f.jsx)(`img`,{src:e.image_url,alt:e.title,className:`h-full w-full object-cover`})}):null,(0,f.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium text-xs line-clamp-1`,children:e.title}),(0,f.jsx)(re.Badge,{variant:`outline`,className:`text-[9px] uppercase`,children:et(e)})]}),e.variant_label?(0,f.jsx)(`span`,{className:`text-[10px] text-muted-foreground line-clamp-1`,children:e.variant_label}):null,(0,f.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[B(`ecommerce.qty`),`: `,e.quantity]}),r?(0,f.jsxs)(`span`,{className:`text-[10px] font-medium text-emerald-700`,children:[r.label,` - `,r.paymentRequirementLabel]}):null]})]}),(0,f.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5 shrink-0`,children:[(0,f.jsx)(`span`,{className:`font-medium text-xs`,children:y((t.sale_price??t.price)*e.quantity,V)}),t.sale_price?(0,f.jsx)(`span`,{className:`text-[9px] text-muted-foreground line-through`,children:y(t.price*e.quantity,V)}):null]})]},`${e.id}-${e.variant_id||`base`}`)})}),(0,f.jsx)(se.Separator,{}),(0,f.jsx)(o.CouponForm,{items:U,currencyCode:V,onQuoteChange:De}),(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:B(`ecommerce.subtotal`)}),(0,f.jsx)(`span`,{children:y(Ne,V)})]}),W.length>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.physical_products`,`Physical products`)}),(0,f.jsx)(`span`,{children:y(Pe,V)})]}):null,G.length>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.digital_products`,`Digital products`)}),(0,f.jsx)(`span`,{children:y(Fe,V)})]}):null,F?(0,f.jsxs)(`div`,{className:`flex justify-between text-emerald-600`,children:[(0,f.jsxs)(`span`,{children:[q(`ecommerce.discount`,`Discount`),` (`,F.code,`)`]}),(0,f.jsxs)(`span`,{children:[`-`,y(F.discountTotal,V)]})]}):null,(W.length>0||G.length>0)&&(0,f.jsxs)(`div`,{className:`flex justify-between font-bold text-lg pt-2 border-t mt-2`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.estimated_total`,`Estimated total`)}),(0,f.jsx)(`span`,{className:`text-primary`,children:y(Be,V)})]})]})]})]}),W.length>0?(0,f.jsxs)(pe,{title:q(`ecommerce.stripe_checkout_title`,`Stripe Checkout`),description:q(`ecommerce.stripe_checkout_description`,`Pay for physical products in one Stripe checkout session.`),badgeLabel:Qe,children:[(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.physical_subtotal`,`Physical subtotal`)}),(0,f.jsx)(`span`,{children:y(Pe,V)})]}),Ie>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-emerald-600`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.discount`,`Discount`)}),(0,f.jsxs)(`span`,{children:[`-`,y(Ie,V)]})]}):null,(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:B(`ecommerce.shipping`)}),(0,f.jsx)(`span`,{children:$?y($.amount,V):`-`})]}),(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.tax`,`Tax`)}),(0,f.jsx)(`span`,{children:Ee?`...`:N?.isPendingExternalCalculation?q(`ecommerce.tax_calculated_on_stripe`,`Calculated on Stripe`):N?y(N.amount,V):`-`})]}),N&&N.lines.length>0?(0,f.jsx)(`div`,{className:`rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:N.lines.map(e=>(0,f.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,f.jsxs)(`span`,{children:[e.name,` (`,e.rate.toFixed(4),`%)`]}),(0,f.jsx)(`span`,{children:y(e.amount,V)})]},e.id||`${e.name}-${e.rate}`))}):null,(0,f.jsxs)(`div`,{className:`flex justify-between font-semibold pt-2 border-t`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.total_on_stripe`,`Total on Stripe`)}),(0,f.jsx)(`span`,{children:y(ze,V)})]})]}),(0,f.jsxs)(ie.Button,{className:`w-full`,size:`lg`,onClick:()=>Ke(`stripe`,W,`stripe`),disabled:Ze,children:[b===`stripe`?(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}):(0,f.jsx)(d.Package,{className:`mr-2 h-4 w-4`}),b===`stripe`?B(`ecommerce.processing`):q(`ecommerce.checkout_physical_products`,`Checkout Physical Products`)]}),Xe&&b===null?(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:Xe}):null,S.stripe?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:S.stripe}):null,(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:N?.isPendingExternalCalculation?q(`checkout_stripe_tax_finalized_notice`,`Tax will be finalized by Stripe Tax on the payment step.`):q(`ecommerce.shipping_taxes_collected_on_stripe`,`Shipping and taxes are only collected during the Stripe step for physical products.`)})]}):null,G.length>0?(0,f.jsxs)(pe,{title:q(`ecommerce.freemius_checkout_title`,`Freemius Checkout`),description:q(`ecommerce.freemius_checkout_description`,`Digital products use the Freemius checkout flow.`),badgeLabel:$e,children:[(0,f.jsx)(`div`,{className:`space-y-3`,children:G.map(e=>{let t=n.getCartItemActivePrice(e,{currencyCode:V,currencies:H}),r=a.getTrialSummary(e,B),i=`freemius:${e.id}`,o=r?me[i]||`paid`:void 0;return(0,f.jsxs)(`div`,{className:`rounded-lg border p-3 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`p`,{className:`font-medium`,children:e.title}),e.billing_cycle?(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:tt(e.billing_cycle)}):null,r?(0,f.jsxs)(`p`,{className:`text-xs font-medium text-emerald-700`,children:[r.label,` - `,r.paymentRequirementLabel]}):null]}),(0,f.jsx)(`span`,{className:`font-medium`,children:y(t.sale_price??t.price,V)})]}),r&&!e.trial_requires_payment_method&&(0,f.jsxs)(`div`,{className:`bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3`,children:[(0,f.jsx)(`p`,{className:`font-medium mb-3`,children:q(`ecommerce.freemius_trial_preference_title`,`How would you like to start your trial?`)}),(0,f.jsxs)(g.RadioGroup,{value:me[i]||`paid`,onValueChange:e=>he(t=>({...t,[i]:e})),className:`gap-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,f.jsx)(g.RadioGroupItem,{value:`paid`,id:`${i}-paid`,className:`mt-1`}),(0,f.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,f.jsx)(m.Label,{htmlFor:`${i}-paid`,className:`font-medium leading-none cursor-pointer`,children:q(`ecommerce.freemius_trial_with_card`,`Enter Payment Details Now (Still get full trial length free)`)}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`ecommerce.freemius_trial_with_card_help`,`You will not be billed until the trial ends. Cancel anytime.`)})]})]}),(0,f.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,f.jsx)(g.RadioGroupItem,{value:`free`,id:`${i}-free`,className:`mt-1`}),(0,f.jsx)(`div`,{className:`grid gap-1.5`,children:(0,f.jsx)(m.Label,{htmlFor:`${i}-free`,className:`font-medium leading-none cursor-pointer`,children:q(`ecommerce.freemius_trial_no_card`,`Start Free Trial (No card required)`)})})]})]})]}),(0,f.jsxs)(ie.Button,{className:`w-full h-auto min-h-[2.75rem] py-2`,onClick:()=>Ke(`freemius`,[{...e,...o?{trial_preference:o}:{}}],i),disabled:b!==null||Ye!==null,children:[b===i?(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 shrink-0 animate-spin`}):(0,f.jsx)(d.Download,{className:`mr-2 h-4 w-4 shrink-0`}),(0,f.jsx)(`span`,{className:`whitespace-normal text-left`,children:b===i?B(`ecommerce.processing`):G.length>1?q(`ecommerce.checkout_product`,`Checkout {title}`,{title:e.title}):q(`ecommerce.checkout_digital_product`,`Checkout Digital Product`)})]})]},i)})}),(0,f.jsxs)(`div`,{className:`flex justify-between text-sm font-semibold border-t pt-3`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.digital_subtotal`,`Digital subtotal`)}),(0,f.jsx)(`span`,{children:y(Fe,V)})]}),Le>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-sm font-semibold text-emerald-600`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.discount`,`Discount`)}),(0,f.jsxs)(`span`,{children:[`-`,y(Le,V)]})]}):null,Ye?(0,f.jsx)(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs`,children:Ye}):null,S.freemius?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:S.freemius}):null,(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:G.length>1?q(`ecommerce.freemius_multi_checkout_notice`,`Freemius licenses are completed one at a time, so each digital product gets its own checkout action.`):q(`ecommerce.freemius_tax_notice`,`Taxes and compliance for digital products are handled inside the Freemius checkout.`)})]}):null]})]})]})]})};exports.Checkout=y;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../types.cjs"),t=require("../CurrencyProvider.cjs"),n=require("../cart-store.cjs"),r=require("../use-cart.cjs"),i=require("../use-price-formatter.cjs"),a=require("../trials.cjs"),o=require("./CouponForm.cjs"),s=require("../countries.cjs"),c=require("../states.cjs"),ee=require("../server-actions/shipping-actions.cjs"),te=require("../PaymentReadinessProvider.cjs"),ne=require("../server-actions/tax-actions.cjs"),l=require("../customer.cjs");let re=require("@nextblock-cms/ui/badge"),ie=require("@nextblock-cms/ui/button"),u=require("react"),d=require("lucide-react"),ae=require("@nextblock-cms/utils"),f=require("react/jsx-runtime"),p=require("@nextblock-cms/ui/input"),m=require("@nextblock-cms/ui/label"),h=require("@nextblock-cms/ui/card"),oe=require("@nextblock-cms/ui/checkbox"),se=require("@nextblock-cms/ui/separator"),g=require("@nextblock-cms/ui/radio-group"),ce=require("@freemius/checkout");var le=process.env.NEXT_PUBLIC_IS_SANDBOX===`true`,_=`nextblock-checkout-draft-v1`;function v(e,t){return{...l.emptyCustomerAddress(),company_name:e?.company_name||``,recipient_name:e?.recipient_name||t||``,line1:e?.line1||``,line2:e?.line2||``,city:e?.city||``,state:e?.state||``,postal_code:e?.postal_code||``,country_code:s.normalizeCountryCode(e?.country_code)||`CA`}}function ue(e){let t=l.normalizeCustomerAddress(e);return!(!t?.country_code||!t.postal_code||c.countryUsesStructuredStates(t.country_code)&&!t.state)}function de(e,t,r){return e.reduce((e,i)=>{let{price:a,sale_price:o}=n.getCartItemActivePrice(i,{currencyCode:t,currencies:r});return e+(o??a)*i.quantity},0)}function fe({idPrefix:e,title:t,description:n,value:r,onChange:i}){let{t:a,lang:o}=(0,ae.useTranslations)(),ee=(0,u.useMemo)(()=>{try{return new Intl.DisplayNames([o],{type:`region`})}catch{return null}},[o]),te=a(`company_name`)===`company_name`?`Company name`:a(`company_name`),ne=a(`select_an_option`)===`select_an_option`?`Select an option`:a(`select_an_option`),l=a(`state_province`)===`state_province`?`State / Province`:a(`state_province`),re=c.getStatesForCountry(r.country_code),ie=c.countryUsesStructuredStates(r.country_code);return(0,f.jsxs)(h.Card,{children:[(0,f.jsxs)(h.CardHeader,{children:[(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.MapPin,{className:`w-5 h-5`}),t]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n})]}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-company`,children:te}),(0,f.jsx)(p.Input,{id:`${e}-company`,name:`${e}-company`,autoComplete:`${e} organization`,value:r.company_name,onChange:e=>i({...r,company_name:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-name`,children:a(`full_name`)}),(0,f.jsx)(p.Input,{id:`${e}-name`,name:`${e}-name`,autoComplete:`${e} name`,required:!0,value:r.recipient_name,onChange:e=>i({...r,recipient_name:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-country`,children:a(`country`)}),(0,f.jsx)(`select`,{id:`${e}-country`,name:`${e}-country`,autoComplete:`${e} country`,required:!0,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,value:r.country_code,onChange:e=>{let t=e.target.value,n=c.getStatesForCountry(t);i({...r,country_code:t,state:n.some(e=>e.code===r.state)?r.state:``})},children:s.countries.map(e=>(0,f.jsx)(`option`,{value:e.code,children:ee?.of(e.code)??e.name},e.code))})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-line1`,children:a(`address_line_1`)}),(0,f.jsx)(p.Input,{id:`${e}-line1`,name:`${e}-line1`,autoComplete:`${e} address-line1`,required:!0,value:r.line1,onChange:e=>i({...r,line1:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-line2`,children:a(`address_line_2`)}),(0,f.jsx)(p.Input,{id:`${e}-line2`,name:`${e}-line2`,autoComplete:`${e} address-line2`,value:r.line2,onChange:e=>i({...r,line2:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-city`,children:a(`city`)}),(0,f.jsx)(p.Input,{id:`${e}-city`,name:`${e}-city`,autoComplete:`${e} address-level2`,required:!0,value:r.city,onChange:e=>i({...r,city:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-state`,children:a(`state_province`)}),ie?(0,f.jsxs)(`select`,{id:`${e}-state`,name:`${e}-state`,autoComplete:`${e} address-level1`,required:!0,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,value:r.state,onChange:e=>i({...r,state:e.target.value}),children:[(0,f.jsx)(`option`,{value:``,children:`${ne}: ${l}`}),re.map(e=>(0,f.jsx)(`option`,{value:e.code,children:c.getSubdivisionLabel(r.country_code,e,o)},e.code))]}):(0,f.jsx)(p.Input,{id:`${e}-state`,name:`${e}-state`,autoComplete:`${e} address-level1`,value:r.state,onChange:e=>i({...r,state:e.target.value})})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`${e}-postal`,children:a(`postal_zip_code`)}),(0,f.jsx)(p.Input,{id:`${e}-postal`,name:`${e}-postal`,autoComplete:`${e} postal-code`,required:!0,value:r.postal_code,onChange:e=>i({...r,postal_code:e.target.value})})]})]})]})]})}function pe({title:e,description:t,badgeLabel:n,children:r}){return(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(h.CardTitle,{role:`heading`,"aria-level":2,children:e}),(0,f.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),n?(0,f.jsx)(re.Badge,{variant:`secondary`,children:n}):null]})}),(0,f.jsx)(h.CardContent,{className:`space-y-4`,children:r})]})}var y=({initialCustomer:s})=>{let y=i.usePriceFormatter(),[me,he]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)({}),[w,ge]=(0,u.useState)(s?.email||``),[T,_e]=(0,u.useState)(``),[E,ve]=(0,u.useState)(s?.phone||``),[ye,be]=(0,u.useState)(!1),[xe,Se]=(0,u.useState)(null),[Ce,D]=(0,u.useState)(!1),[we,Te]=(0,u.useState)(!1),[Ee,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)([]),[j,M]=(0,u.useState)(null),[N,P]=(0,u.useState)(null),[F,De]=(0,u.useState)(null),[I,Oe]=(0,u.useState)(()=>v(s?.billingAddress,s?.fullName)),[L,ke]=(0,u.useState)(()=>v(s?.shippingAddress??s?.billingAddress,s?.fullName)),[R,Ae]=(0,u.useState)(!s?.shippingAddress||l.addressesMatch(s?.billingAddress,s?.shippingAddress)),z=r.useCart(e=>e),{t:B,lang:je}=(0,ae.useTranslations)(),{activeCurrencyCode:V,currencies:H}=t.useCurrency(),Me=te.usePaymentReadiness(),U=z?.items??[],W=(0,u.useMemo)(()=>U.filter(t=>!e.isDigitalItem(t)),[U]),G=(0,u.useMemo)(()=>U.filter(t=>e.isDigitalItem(t)),[U]),K=s?.isAuthenticated??!1,q=(e,t,n)=>{let r=B(e,n);if(r!==e)return r;if(!n)return t;let i=t;return Object.entries(n).forEach(([e,t])=>{i=i.replace(RegExp(`\\{${e}\\}`,`g`),String(t))}),i},J=W.length>0,Ne=(0,u.useMemo)(()=>de(U,V,H),[V,H,U]),Pe=(0,u.useMemo)(()=>de(W,V,H),[V,H,W]),Fe=(0,u.useMemo)(()=>de(G,V,H),[V,H,G]),Ie=F?.providerDiscounts.stripe??0,Le=F?.providerDiscounts.freemius??0,Y=Math.max(0,Pe-Ie),Re=Math.max(0,Fe-Le),X=(0,u.useMemo)(()=>R?I:L,[I,L,R]),Z=(0,u.useMemo)(()=>J?X:I,[I,J,X]),Q=!J||ue(X),$=(0,u.useMemo)(()=>k.find(e=>e.id===j),[k,j]),ze=(0,u.useMemo)(()=>Y+($?.amount??0)+(N&&!N.isPendingExternalCalculation?N.amount:0),[Y,$,N]),Be=ze+Re;if((0,u.useEffect)(()=>{if(!(K||typeof window>`u`))try{let e=window.localStorage.getItem(_);if(!e)return;let t=JSON.parse(e);t.email&&ge(t.email),t.phone&&ve(t.phone),t.billingAddress&&Oe(v(t.billingAddress)),t.shippingAddress&&ke(v(t.shippingAddress)),typeof t.useBillingForShipping==`boolean`&&Ae(t.useBillingForShipping),(typeof t.selectedMethodId==`string`||t.selectedMethodId===null)&&M(t.selectedMethodId)}catch(e){console.error(`[Checkout] Failed to restore checkout draft:`,e)}},[K]),(0,u.useEffect)(()=>{if(typeof window<`u`)try{if(K){window.localStorage.removeItem(_);return}window.localStorage.setItem(_,JSON.stringify({email:w,phone:E,billingAddress:I,shippingAddress:L,useBillingForShipping:R,selectedMethodId:j}))}catch{}},[I,w,K,E,j,L,R]),(0,u.useEffect)(()=>{if(!J){A([]),M(null),D(!1);return}if(!Q){A([]),M(null),D(!1);return}let e=!1,t=setTimeout(async()=>{if(X.country_code){D(!0),Te(!1);try{let t=await ee.getShippingEstimates(Y,{country:X.country_code,state:X.state,postal_code:X.postal_code},je,V);if(e)return;if(t.success&&t.methods){let e=t.methods;A(e),M(t=>t&&e.some(e=>e.id===t)?t:e[0]?.id??null)}else A([]),M(null)}catch(t){if(e)return;console.error(`[Checkout] Failed to load shipping rates:`,t),A([]),M(null),Te(!0)}finally{e||D(!1)}}},400);return()=>{e=!0,clearTimeout(t)}},[V,J,Q,je,X.country_code,X.postal_code,X.state,Y]),(0,u.useEffect)(()=>{let e=!1,t=setTimeout(async()=>{if(!J||!Z.country_code){O(!1),P(null);return}if(c.countryUsesStructuredStates(Z.country_code)&&!Z.state){O(!1),P(null);return}O(!0);try{let t=await ne.getTaxEstimate(W,{country_code:Z.country_code,state:Z.state},V,F?.code??null,U);if(e)return;P(t.success&&t.tax?t.tax:null)}catch(t){if(e)return;console.error(`[Checkout] Failed to load the tax estimate:`,t),P(null)}finally{e||O(!1)}},300);return()=>{e=!0,clearTimeout(t)}},[V,J,W,Z.country_code,Z.state,F?.code,U]),(0,u.useEffect)(()=>{let e=e=>{e.persisted&&x(null)};return window.addEventListener(`pageshow`,e),()=>window.removeEventListener(`pageshow`,e)},[]),!z)return(0,f.jsxs)(`div`,{role:`status`,"aria-busy":`true`,className:`container mx-auto px-4 py-12 md:px-6`,children:[(0,f.jsx)(`span`,{className:`sr-only`,children:B(`loading`)===`loading`?`Loading…`:B(`loading`)}),(0,f.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,f.jsx)(`div`,{className:`mb-8 h-9 w-48 rounded-md bg-muted`}),(0,f.jsxs)(`div`,{className:`grid gap-8 lg:grid-cols-12 lg:items-start`,children:[(0,f.jsxs)(`div`,{className:`space-y-6 lg:col-span-8`,children:[(0,f.jsx)(`div`,{className:`h-56 rounded-xl border bg-muted/40`}),(0,f.jsx)(`div`,{className:`h-96 rounded-xl border bg-muted/40`})]}),(0,f.jsx)(`div`,{className:`lg:col-span-4`,children:(0,f.jsx)(`div`,{className:`h-72 rounded-xl border bg-muted/40`})})]})]})]});let Ve=()=>{be(!1),Se(null)},He=ye?(0,f.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center overscroll-contain bg-black/60 backdrop-blur-sm`,onClick:Ve,onKeyDown:e=>{e.key===`Escape`&&Ve()},children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`sandbox-checkout-title`,className:`relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4`,onClick:e=>e.stopPropagation(),children:[(0,f.jsx)(`button`,{type:`button`,autoFocus:!0,onClick:Ve,"aria-label":q(`close`,`Close`),className:`absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring`,children:(0,f.jsx)(d.X,{className:`w-5 h-5`})}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,f.jsx)(`div`,{className:`p-2 rounded-full bg-amber-100 dark:bg-amber-900/20`,children:(0,f.jsx)(d.FlaskConical,{className:`h-6 w-6 text-amber-600 dark:text-amber-400`})}),(0,f.jsx)(`h2`,{id:`sandbox-checkout-title`,className:`text-xl font-semibold`,children:B(`ecommerce.checkout_successful`)})]}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-2`,children:B(`ecommerce.sandbox_notice`)}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-2`,children:xe===`stripe`?q(`ecommerce.sandbox_checkout_stripe_description`,`This simulated step represents the Stripe checkout for physical products.`):q(`ecommerce.sandbox_checkout_freemius_description`,`This simulated step represents the Freemius checkout for digital products.`)}),(0,f.jsx)(`p`,{className:`text-muted-foreground mb-6`,children:B(`ecommerce.license_notice`)}),(0,f.jsx)(`a`,{href:`https://nextblock.dev`,target:`_blank`,rel:`noopener noreferrer`,className:`block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity`,children:B(`ecommerce.purchase_at`)})]})}):null,Ue=(e,t,n)=>(C(n=>({...n,[e]:t})),n&&document.getElementById(n)?.focus(),null),We=(e,t)=>t.recipient_name.trim()?t.line1.trim()?t.city.trim()?c.countryUsesStructuredStates(t.country_code)&&!t.state?`${e}-state`:t.postal_code.trim()?`${e}-line1`:`${e}-postal`:`${e}-city`:`${e}-line1`:`${e}-name`,Ge=e=>{if(!K&&(!w||!/^\S+@\S+\.\S+$/.test(w)))return _e(B(`ecommerce.invalid_email`)),Ue(e,B(`ecommerce.invalid_email`),`checkout-email`);let t=l.normalizeCustomerAddress(I);if(!l.isCustomerAddressComplete(t))return Ue(e,B(`checkout_complete_billing_address`),We(`billing`,I));let n=J?l.normalizeCustomerAddress(R?I:L):null;if(e===`stripe`){if(!l.isCustomerAddressComplete(n))return Ue(e,B(`checkout_complete_shipping_address`),R?We(`billing`,I):We(`shipping`,L));if(!j)return Ue(e,q(`ecommerce.shipping_method_required`,`Please select a shipping method before continuing.`))}return _e(``),{normalizedBillingAddress:t,normalizedShippingAddress:n}},Ke=async(e,t,n)=>{C(t=>({...t,[e]:``}));let r=Ge(e);if(r){if(le){let n=new Set(t.map(e=>e.id)),r=U.filter(e=>!n.has(e.id));if(z.setItems(r),r.length===0&&z.removeCoupon(),Se(e),be(!0),typeof window<`u`&&r.length===0)try{window.localStorage.removeItem(_)}catch{}return}x(n);try{let n=await fetch(`/api/checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({items:t,customerEmail:K?void 0:w,customerPhone:E||null,billingAddress:r.normalizedBillingAddress,shippingAddress:e===`stripe`?r.normalizedShippingAddress:null,shippingMethodId:e===`stripe`?j:null,locale:je,currencyCode:V,couponCode:F?.code??z.appliedCoupon?.code??null,couponContextItems:U})}),i=await n.json();if(!n.ok){let t=i?.errorKey&&typeof i.errorKey==`string`?q(i.errorKey,i?.error||q(`ecommerce.generic_error`,`Something went wrong.`),i.errorParams):i?.error||B(`ecommerce.generic_error`);C(n=>({...n,[e]:t})),x(null);return}if(i.customProps&&i.customProps.provider===`freemius`){let t=i.customProps,n=null,r=()=>{let e=t.success_token?`&token=${encodeURIComponent(t.success_token)}`:``;window.location.href=`/checkout/success?session_id=${t.order_id}${e}`},a=e=>(n||=fetch(`/api/checkout/freemius/sync`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({orderId:t.order_id,token:t.success_token,checkoutResponse:e})}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);console.error(`Freemius checkout sync failed:`,t)}}),n),o={product_id:t.plugin_id,public_key:t.public_key,sandbox:t.sandbox},s={name:B(`ecommerce.checkout_overlay_title`),plan_id:t.plan_id,...t.billing_cycle?{billing_cycle:t.billing_cycle}:{},...t.trial?{trial:t.trial}:{},...t.coupon?{coupon:t.coupon}:{},user_email:t.user_email,user_firstname:t.user_firstname,user_lastname:t.user_lastname,sandbox:t.sandbox,purchaseCompleted:function(e){a(e)},success:function(e){(async()=>{try{await a(e)}finally{r()}})()}};try{new ce.Checkout(o).open(s),x(null)}catch(t){console.error(`[Checkout] Freemius overlay failed to open:`,t),C(t=>({...t,[e]:B(`ecommerce.checkout_popup_blocked`)})),i.url&&(window.location.href=i.url),x(null)}}else i.url?window.location.href=i.url:(C(t=>({...t,[e]:B(`ecommerce.checkout_failed`)+(i.error||q(`ecommerce.unknown_error`,`Unknown error`))})),x(null))}catch(t){console.error(t),C(t=>({...t,[e]:B(`ecommerce.generic_error`)})),x(null)}}};if(U.length===0)return(0,f.jsxs)(f.Fragment,{children:[He,(0,f.jsxs)(`div`,{className:`container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center`,children:[(0,f.jsx)(`h1`,{className:`mb-4 text-2xl font-bold`,children:B(`ecommerce.cart_empty`)}),(0,f.jsx)(`p`,{className:`mb-8 text-muted-foreground`,children:B(`ecommerce.cart_empty_description`)}),(0,f.jsx)(ie.Button,{asChild:!0,children:(0,f.jsx)(`a`,{href:`/shop`,children:B(`ecommerce.go_to_shop`)})})]})]});let qe=q(`ecommerce.checkout_payments_unavailable`,`This store is not able to take payments right now. Please contact the seller to complete your purchase.`),Je=Me.stripe?null:qe,Ye=Me.freemius?null:qe,Xe=Je||(J?Q?Ce?q(`ecommerce.calculating_shipping`,`Calculating shipping...`):j?null:k.length>0?B(`ecommerce.select_rate`):B(`ecommerce.no_rates_for_region`):q(`ecommerce.waiting_on_address_info`,`Complete your shipping address to view available shipping options.`):null),Ze=b!==null||Xe!==null,Qe=W.length===1?q(`ecommerce.item_count_one`,`{count} item`,{count:W.length}):q(`ecommerce.item_count_other`,`{count} items`,{count:W.length}),$e=G.length===1?q(`ecommerce.license_count_one`,`{count} license`,{count:G.length}):q(`ecommerce.license_count_other`,`{count} licenses`,{count:G.length}),et=t=>e.isDigitalItem(t)?q(`ecommerce.digital_label`,`Digital`):q(`ecommerce.physical_label`,`Physical`),tt=e=>e===`monthly`?q(`ecommerce.checkout_billing_cycle_monthly`,`Monthly subscription`):e===`annual`?q(`ecommerce.checkout_billing_cycle_annual`,`Annual subscription`):e===`lifetime`?q(`ecommerce.checkout_billing_cycle_lifetime`,`Lifetime subscription`):null;return(0,f.jsxs)(`div`,{className:`container mx-auto px-4 py-12 md:px-6`,children:[He,(0,f.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,f.jsx)(`h1`,{className:`mb-8 text-3xl font-bold`,children:B(`ecommerce.checkout`)}),(0,f.jsxs)(`div`,{className:`grid gap-8 lg:grid-cols-12 lg:items-start`,children:[(0,f.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.CreditCard,{className:`w-5 h-5`}),B(`ecommerce.contact_information`)]})}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[K?(0,f.jsx)(`div`,{className:`rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground`,children:B(`checkout_prefill_notice`,{email:s?.email||``})}):(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsxs)(m.Label,{htmlFor:`checkout-email`,children:[B(`ecommerce.email_address`),` `,(0,f.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,f.jsx)(p.Input,{id:`checkout-email`,name:`email`,type:`email`,autoComplete:`email`,spellCheck:!1,"aria-invalid":T?!0:void 0,"aria-describedby":T?`checkout-email-error`:void 0,placeholder:B(`ecommerce.email_placeholder`),value:w,onChange:e=>{ge(e.target.value),T&&_e(``)},required:!0}),T?(0,f.jsx)(`p`,{id:`checkout-email-error`,role:`alert`,className:`text-xs text-destructive mt-1`,children:T}):null]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(m.Label,{htmlFor:`checkout-phone`,children:B(`phone_number`)}),(0,f.jsx)(p.Input,{id:`checkout-phone`,name:`phone`,type:`tel`,inputMode:`tel`,autoComplete:`tel`,placeholder:B(`optional`),value:E,onChange:e=>ve(e.target.value)})]})]})]}),(0,f.jsx)(fe,{idPrefix:`billing`,title:B(`billing_address`),description:B(`checkout_billing_address_help`),value:I,onChange:Oe}),J?(0,f.jsxs)(`div`,{className:`flex items-center space-x-3 rounded-xl border bg-muted/20 p-4`,children:[(0,f.jsx)(oe.Checkbox,{id:`use-billing-for-shipping`,checked:R,onCheckedChange:e=>Ae(!!e)}),(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(m.Label,{htmlFor:`use-billing-for-shipping`,className:`cursor-pointer`,children:B(`use_billing_for_shipping`)}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:B(`checkout_use_billing_for_shipping_help`)})]})]}):null,J&&!R?(0,f.jsx)(fe,{idPrefix:`shipping`,title:B(`shipping_address`),description:B(`checkout_shipping_address_help`),value:L,onChange:ke}):null,J?(0,f.jsxs)(h.Card,{children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsxs)(h.CardTitle,{role:`heading`,"aria-level":2,className:`flex items-center gap-2`,children:[(0,f.jsx)(d.ChevronRight,{className:`w-5 h-5 text-primary`}),B(`ecommerce.shipping_method`)]})}),(0,f.jsx)(h.CardContent,{children:Ce?(0,f.jsxs)(`div`,{role:`status`,className:`flex items-center justify-center py-6`,children:[(0,f.jsx)(d.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`}),(0,f.jsx)(`span`,{className:`sr-only`,children:q(`ecommerce.calculating_shipping`,`Calculating shipping…`)})]}):we?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg bg-destructive/10 px-4 py-3 text-center text-sm text-destructive`,children:q(`ecommerce.shipping_calculation_failed`,`We couldn't calculate shipping right now. Please try again.`)}):k.length>0?(0,f.jsx)(g.RadioGroup,{value:j??``,onValueChange:M,"aria-label":B(`ecommerce.shipping_method`),className:`space-y-3`,children:k.map(e=>(0,f.jsxs)(m.Label,{htmlFor:`shipping-method-${e.id}`,className:`flex items-center justify-between gap-3 p-4 rounded-lg border-2 cursor-pointer transition-colors ${j===e.id?`border-primary bg-primary/5`:`border-border hover:border-muted-foreground/40`}`,children:[(0,f.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,f.jsx)(g.RadioGroupItem,{id:`shipping-method-${e.id}`,value:e.id}),(0,f.jsx)(`span`,{className:`font-medium break-words`,children:e.name})]}),(0,f.jsx)(`span`,{className:`font-bold tabular-nums`,children:y(e.amount,V)})]},e.id))}):(0,f.jsx)(`div`,{className:`py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic`,children:Q?B(`ecommerce.no_rates_for_region`):q(`ecommerce.waiting_on_address_info`,`Complete your shipping address to view available shipping options.`)})})]}):null]}),(0,f.jsxs)(`div`,{className:`lg:col-span-4 space-y-6`,children:[(0,f.jsxs)(h.Card,{className:`top-6`,children:[(0,f.jsx)(h.CardHeader,{children:(0,f.jsx)(h.CardTitle,{role:`heading`,"aria-level":2,children:B(`ecommerce.order_summary`)})}),(0,f.jsxs)(h.CardContent,{className:`space-y-4`,children:[(0,f.jsx)(`div`,{className:`space-y-3 max-h-[260px] overflow-y-auto pr-2`,children:U.map(e=>{let t=n.getCartItemActivePrice(e,{currencyCode:V,currencies:H}),r=a.getTrialSummary(e,B);return(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex gap-3`,children:[e.image_url?(0,f.jsx)(`div`,{className:`h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100`,children:(0,f.jsx)(`img`,{src:e.image_url,alt:e.title,className:`h-full w-full object-cover`})}):null,(0,f.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium text-xs line-clamp-1`,children:e.title}),(0,f.jsx)(re.Badge,{variant:`outline`,className:`text-[9px] uppercase`,children:et(e)})]}),e.variant_label?(0,f.jsx)(`span`,{className:`text-[10px] text-muted-foreground line-clamp-1`,children:e.variant_label}):null,(0,f.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[B(`ecommerce.qty`),`: `,e.quantity]}),r?(0,f.jsxs)(`span`,{className:`text-[10px] font-medium text-emerald-700`,children:[r.label,` - `,r.paymentRequirementLabel]}):null]})]}),(0,f.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5 shrink-0`,children:[(0,f.jsx)(`span`,{className:`font-medium text-xs`,children:y((t.sale_price??t.price)*e.quantity,V)}),t.sale_price?(0,f.jsx)(`span`,{className:`text-[9px] text-muted-foreground line-through`,children:y(t.price*e.quantity,V)}):null]})]},`${e.id}-${e.variant_id||`base`}`)})}),(0,f.jsx)(se.Separator,{}),(0,f.jsx)(o.CouponForm,{items:U,currencyCode:V,onQuoteChange:De}),(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:B(`ecommerce.subtotal`)}),(0,f.jsx)(`span`,{children:y(Ne,V)})]}),W.length>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.physical_products`,`Physical products`)}),(0,f.jsx)(`span`,{children:y(Pe,V)})]}):null,G.length>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.digital_products`,`Digital products`)}),(0,f.jsx)(`span`,{children:y(Fe,V)})]}):null,F?(0,f.jsxs)(`div`,{className:`flex justify-between text-emerald-600`,children:[(0,f.jsxs)(`span`,{children:[q(`ecommerce.discount`,`Discount`),` (`,F.code,`)`]}),(0,f.jsxs)(`span`,{children:[`-`,y(F.discountTotal,V)]})]}):null,(W.length>0||G.length>0)&&(0,f.jsxs)(`div`,{className:`flex justify-between font-bold text-lg pt-2 border-t mt-2`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.estimated_total`,`Estimated total`)}),(0,f.jsx)(`span`,{className:`text-primary`,children:y(Be,V)})]})]})]})]}),W.length>0?(0,f.jsxs)(pe,{title:q(`ecommerce.stripe_checkout_title`,`Stripe Checkout`),description:q(`ecommerce.stripe_checkout_description`,`Pay for physical products in one Stripe checkout session.`),badgeLabel:Qe,children:[(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.physical_subtotal`,`Physical subtotal`)}),(0,f.jsx)(`span`,{children:y(Pe,V)})]}),Ie>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-emerald-600`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.discount`,`Discount`)}),(0,f.jsxs)(`span`,{children:[`-`,y(Ie,V)]})]}):null,(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:B(`ecommerce.shipping`)}),(0,f.jsx)(`span`,{children:$?y($.amount,V):`-`})]}),(0,f.jsxs)(`div`,{className:`flex justify-between`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.tax`,`Tax`)}),(0,f.jsx)(`span`,{children:Ee?`...`:N?.isPendingExternalCalculation?q(`ecommerce.tax_calculated_on_stripe`,`Calculated on Stripe`):N?y(N.amount,V):`-`})]}),N&&N.lines.length>0?(0,f.jsx)(`div`,{className:`rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:N.lines.map(e=>(0,f.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,f.jsxs)(`span`,{children:[e.name,` (`,e.rate.toFixed(4),`%)`]}),(0,f.jsx)(`span`,{children:y(e.amount,V)})]},e.id||`${e.name}-${e.rate}`))}):null,(0,f.jsxs)(`div`,{className:`flex justify-between font-semibold pt-2 border-t`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.total_on_stripe`,`Total on Stripe`)}),(0,f.jsx)(`span`,{children:y(ze,V)})]})]}),(0,f.jsxs)(ie.Button,{className:`w-full`,size:`lg`,onClick:()=>Ke(`stripe`,W,`stripe`),disabled:Ze,children:[b===`stripe`?(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}):(0,f.jsx)(d.Package,{className:`mr-2 h-4 w-4`}),b===`stripe`?B(`ecommerce.processing`):q(`ecommerce.checkout_physical_products`,`Checkout Physical Products`)]}),Xe&&b===null?(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:Xe}):null,S.stripe?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:S.stripe}):null,(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:N?.isPendingExternalCalculation?q(`checkout_stripe_tax_finalized_notice`,`Tax will be finalized by Stripe Tax on the payment step.`):q(`ecommerce.shipping_taxes_collected_on_stripe`,`Shipping and taxes are only collected during the Stripe step for physical products.`)})]}):null,G.length>0?(0,f.jsxs)(pe,{title:q(`ecommerce.freemius_checkout_title`,`Freemius Checkout`),description:q(`ecommerce.freemius_checkout_description`,`Digital products use the Freemius checkout flow.`),badgeLabel:$e,children:[(0,f.jsx)(`div`,{className:`space-y-3`,children:G.map(e=>{let t=n.getCartItemActivePrice(e,{currencyCode:V,currencies:H}),r=a.getTrialSummary(e,B),i=`freemius:${e.id}`,o=r?me[i]||`paid`:void 0;return(0,f.jsxs)(`div`,{className:`rounded-lg border p-3 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`p`,{className:`font-medium`,children:e.title}),e.billing_cycle?(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:tt(e.billing_cycle)}):null,r?(0,f.jsxs)(`p`,{className:`text-xs font-medium text-emerald-700`,children:[r.label,` - `,r.paymentRequirementLabel]}):null]}),(0,f.jsx)(`span`,{className:`font-medium`,children:y(t.sale_price??t.price,V)})]}),r&&!e.trial_requires_payment_method&&(0,f.jsxs)(`div`,{className:`bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3`,children:[(0,f.jsx)(`p`,{className:`font-medium mb-3`,children:q(`ecommerce.freemius_trial_preference_title`,`How would you like to start your trial?`)}),(0,f.jsxs)(g.RadioGroup,{value:me[i]||`paid`,onValueChange:e=>he(t=>({...t,[i]:e})),className:`gap-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,f.jsx)(g.RadioGroupItem,{value:`paid`,id:`${i}-paid`,className:`mt-1`}),(0,f.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,f.jsx)(m.Label,{htmlFor:`${i}-paid`,className:`font-medium leading-none cursor-pointer`,children:q(`ecommerce.freemius_trial_with_card`,`Enter Payment Details Now (Still get full trial length free)`)}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`ecommerce.freemius_trial_with_card_help`,`You will not be billed until the trial ends. Cancel anytime.`)})]})]}),(0,f.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,f.jsx)(g.RadioGroupItem,{value:`free`,id:`${i}-free`,className:`mt-1`}),(0,f.jsx)(`div`,{className:`grid gap-1.5`,children:(0,f.jsx)(m.Label,{htmlFor:`${i}-free`,className:`font-medium leading-none cursor-pointer`,children:q(`ecommerce.freemius_trial_no_card`,`Start Free Trial (No card required)`)})})]})]})]}),(0,f.jsxs)(ie.Button,{className:`w-full h-auto min-h-[2.75rem] py-2`,onClick:()=>Ke(`freemius`,[{...e,...o?{trial_preference:o}:{}}],i),disabled:b!==null||Ye!==null,children:[b===i?(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 shrink-0 animate-spin`}):(0,f.jsx)(d.Download,{className:`mr-2 h-4 w-4 shrink-0`}),(0,f.jsx)(`span`,{className:`whitespace-normal text-left`,children:b===i?B(`ecommerce.processing`):G.length>1?q(`ecommerce.checkout_product`,`Checkout {title}`,{title:e.title}):q(`ecommerce.checkout_digital_product`,`Checkout Digital Product`)})]})]},i)})}),(0,f.jsxs)(`div`,{className:`flex justify-between text-sm font-semibold border-t pt-3`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.digital_subtotal`,`Digital subtotal`)}),(0,f.jsx)(`span`,{children:y(Fe,V)})]}),Le>0?(0,f.jsxs)(`div`,{className:`flex justify-between text-sm font-semibold text-emerald-600`,children:[(0,f.jsx)(`span`,{children:q(`ecommerce.discount`,`Discount`)}),(0,f.jsxs)(`span`,{children:[`-`,y(Le,V)]})]}):null,Ye?(0,f.jsx)(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs`,children:Ye}):null,S.freemius?(0,f.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:S.freemius}):null,(0,f.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:G.length>1?q(`ecommerce.freemius_multi_checkout_notice`,`Freemius licenses are completed one at a time, so each digital product gets its own checkout action.`):q(`ecommerce.freemius_tax_notice`,`Taxes and compliance for digital products are handled inside the Freemius checkout.`)})]}):null]})]})]})]})};exports.Checkout=y;
@@ -555,6 +555,7 @@ var T = ({ initialCustomer: s }) => {
555
555
  headers: { "Content-Type": "application/json" },
556
556
  body: JSON.stringify({
557
557
  orderId: t.order_id,
558
+ token: t.success_token,
558
559
  checkoutResponse: e
559
560
  })
560
561
  }).then(async (e) => {
@@ -1 +1 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../currency.cjs"),n=require("../CurrencyProvider.cjs"),r=require("../use-cart.cjs"),i=require("../use-price-formatter.cjs"),a=require("../trials.cjs"),o=require("../pages/cms/products/actions.cjs");let s=require("@nextblock-cms/ui/button"),c=require("react");c=e.__toESM(c,1);let l=require("lucide-react"),u=require("@nextblock-cms/utils"),d=require("react/jsx-runtime"),f=require("sonner"),p=require("@nextblock-cms/ui/Skeleton");var m=({product:e})=>{let m=i.usePriceFormatter(),h=r.useCart(e=>e),{t:g}=(0,u.useTranslations)(),{activeCurrencyCode:_,currencies:v,defaultCurrency:y}=n.useCurrency(),[b,x]=(0,c.useState)([]),[S,C]=(0,c.useState)(!0),[w,T]=(0,c.useState)(`annual`);if((0,c.useEffect)(()=>{async function t(){try{if(!e.id)return;let t=await o.getPublicFreemiusPricing(e.id);x(t)}catch(e){console.error(`Failed to load pricing:`,e)}finally{C(!1)}}t()},[e.id]),!h)return(0,d.jsx)(p.Skeleton,{className:`h-14 w-full`});let{addItem:E}=h,D=b[0],O=D?.pricing?.[0],k=()=>{let n=e.price,r=e.freemius_plan_id;O&&(w===`monthly`&&O.monthly_price!=null&&(n=(0,u.majorUnitAmountToMinor)(O.monthly_price,y.code)),w===`annual`&&O.annual_price!=null&&(n=(0,u.majorUnitAmountToMinor)(O.annual_price,y.code)),w===`lifetime`&&O.lifetime_price!=null&&(n=(0,u.majorUnitAmountToMinor)(O.lifetime_price,y.code)));let i=v.reduce((e,r)=>(e[r.code]=t.convertMinorUnitAmount({amount:n,fromCurrencyCode:y.code,toCurrencyCode:r.code,currencies:v,applyRounding:!0}),e),{}),a=i[_]??n;D&&D.id&&(r=D.id);let{success:o,error:s}=E({id:e.id,product_id:e.id,title:e.title,price:a,prices:i,image_url:e.image_url,slug:e.slug,sku:e.sku,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:`digital`,payment_provider:`freemius`,provider:`freemius`,billing_cycle:w,freemius_product_id:e.freemius_product_id,freemius_plan_id:r,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,is_taxable:e.is_taxable,currency_code:_});o?f.toast.success(g(`ecommerce.added_to_cart_success`,{item:e.title})):f.toast.error(s||g(`ecommerce.added_to_cart_error`))};if(S)return(0,d.jsx)(p.Skeleton,{className:`h-32 w-full`});if(!D||!O)return(0,d.jsx)(`div`,{className:`p-4 border border-dashed rounded-lg text-center text-muted-foreground`,children:g(`ecommerce.pricing_unavailable`)});let A=O.monthly_price!=null,j=O.annual_price!=null,M=O.lifetime_price!=null;w===`annual`&&!j&&(A?T(`monthly`):M&&T(`lifetime`));let N=a.getTrialSummary(e,g),P=e.price;return w===`monthly`&&O.monthly_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,u.majorUnitAmountToMinor)(O.monthly_price,y.code),fromCurrencyCode:y.code,toCurrencyCode:_,currencies:v,applyRounding:!0})),w===`annual`&&O.annual_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,u.majorUnitAmountToMinor)(O.annual_price,y.code),fromCurrencyCode:y.code,toCurrencyCode:_,currencies:v,applyRounding:!0})),w===`lifetime`&&O.lifetime_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,u.majorUnitAmountToMinor)(O.lifetime_price,y.code),fromCurrencyCode:y.code,toCurrencyCode:_,currencies:v,applyRounding:!0})),(0,d.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,d.jsxs)(`div`,{role:`group`,"aria-label":g(`ecommerce.billing_cycle`)===`ecommerce.billing_cycle`?`Billing cycle`:g(`ecommerce.billing_cycle`),className:`flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner`,children:[A&&(0,d.jsx)(`button`,{type:`button`,"aria-pressed":w===`monthly`,onClick:()=>T(`monthly`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${w===`monthly`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:g(`ecommerce.monthly`)}),j&&(0,d.jsx)(`button`,{type:`button`,"aria-pressed":w===`annual`,onClick:()=>T(`annual`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${w===`annual`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:g(`ecommerce.annual`)}),M&&(0,d.jsx)(`button`,{type:`button`,"aria-pressed":w===`lifetime`,onClick:()=>T(`lifetime`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${w===`lifetime`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:g(`ecommerce.lifetime`)})]}),(0,d.jsxs)(`div`,{className:`text-center`,children:[(0,d.jsx)(`span`,{className:`text-3xl font-extrabold text-foreground tabular-nums`,children:m(P,_)}),w!==`lifetime`&&(0,d.jsxs)(`span`,{className:`text-muted-foreground text-sm ml-1.5`,children:[`/ `,g(w===`annual`?`ecommerce.year`:`ecommerce.month`)]}),N&&(0,d.jsxs)(`div`,{className:`mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400`,children:[N.label,(0,d.jsx)(`span`,{className:`mx-2 text-muted-foreground/50`,children:`|`}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:N.paymentRequirementLabel})]})]}),(0,d.jsxs)(s.Button,{onClick:k,className:`w-full h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]`,children:[(0,d.jsx)(l.ShoppingCart,{className:`mr-2 h-4 w-4`}),N?.label?g(`ecommerce.start_trial`,{trial:N.label})===`ecommerce.start_trial`?`Start ${N.label}`:g(`ecommerce.start_trial`,{trial:N.label}):g(`ecommerce.get_license`)]})]})};exports.SubscriptionSelector=m;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../currency.cjs"),n=require("../CurrencyProvider.cjs"),r=require("../use-cart.cjs"),i=require("../use-price-formatter.cjs"),a=require("../trials.cjs"),o=require("../freemius-pricing.cjs"),s=require("../pages/cms/products/actions.cjs");let c=require("@nextblock-cms/ui/button"),l=require("react");l=e.__toESM(l,1);let u=require("lucide-react"),d=require("@nextblock-cms/utils"),f=require("react/jsx-runtime"),p=require("sonner"),m=require("@nextblock-cms/ui/Skeleton");var h=({product:e})=>{let h=i.usePriceFormatter(),g=r.useCart(e=>e),{t:_}=(0,d.useTranslations)(),{activeCurrencyCode:v,currencies:y,defaultCurrency:b}=n.useCurrency(),[x,S]=(0,l.useState)([]),[C,w]=(0,l.useState)(!0),[T,E]=(0,l.useState)(`annual`);if((0,l.useEffect)(()=>{async function t(){try{if(!e.id)return;let t=await s.getPublicFreemiusPricing(e.id);S(t)}catch(e){console.error(`Failed to load pricing:`,e)}finally{w(!1)}}t()},[e.id]),!g)return(0,f.jsx)(m.Skeleton,{className:`h-14 w-full`});let{addItem:D}=g,O=o.pickFreemiusPricingTier(x.flatMap(e=>e.pricing??[])),k=()=>{let n=e.price;O&&(T===`monthly`&&O.monthly_price!=null&&(n=(0,d.majorUnitAmountToMinor)(O.monthly_price,b.code)),T===`annual`&&O.annual_price!=null&&(n=(0,d.majorUnitAmountToMinor)(O.annual_price,b.code)),T===`lifetime`&&O.lifetime_price!=null&&(n=(0,d.majorUnitAmountToMinor)(O.lifetime_price,b.code)));let r=y.reduce((e,r)=>(e[r.code]=t.convertMinorUnitAmount({amount:n,fromCurrencyCode:b.code,toCurrencyCode:r.code,currencies:y,applyRounding:!0}),e),{}),i=r[v]??n,{success:a,error:o}=D({id:e.id,product_id:e.id,title:e.title,price:i,prices:r,image_url:e.image_url,slug:e.slug,sku:e.sku,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:`digital`,payment_provider:`freemius`,provider:`freemius`,billing_cycle:T,freemius_product_id:e.freemius_product_id,freemius_plan_id:e.freemius_plan_id,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,is_taxable:e.is_taxable,currency_code:v});a?p.toast.success(_(`ecommerce.added_to_cart_success`,{item:e.title})):p.toast.error(o||_(`ecommerce.added_to_cart_error`))};if(C)return(0,f.jsx)(m.Skeleton,{className:`h-32 w-full`});if(!O)return(0,f.jsx)(`div`,{className:`p-4 border border-dashed rounded-lg text-center text-muted-foreground`,children:_(`ecommerce.pricing_unavailable`)});let A=O.monthly_price!=null,j=O.annual_price!=null,M=O.lifetime_price!=null;T===`annual`&&!j&&(A?E(`monthly`):M&&E(`lifetime`));let N=a.getTrialSummary(e,_),P=e.price;return T===`monthly`&&O.monthly_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,d.majorUnitAmountToMinor)(O.monthly_price,b.code),fromCurrencyCode:b.code,toCurrencyCode:v,currencies:y,applyRounding:!0})),T===`annual`&&O.annual_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,d.majorUnitAmountToMinor)(O.annual_price,b.code),fromCurrencyCode:b.code,toCurrencyCode:v,currencies:y,applyRounding:!0})),T===`lifetime`&&O.lifetime_price!=null&&(P=t.convertMinorUnitAmount({amount:(0,d.majorUnitAmountToMinor)(O.lifetime_price,b.code),fromCurrencyCode:b.code,toCurrencyCode:v,currencies:y,applyRounding:!0})),(0,f.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,f.jsxs)(`div`,{role:`group`,"aria-label":_(`ecommerce.billing_cycle`)===`ecommerce.billing_cycle`?`Billing cycle`:_(`ecommerce.billing_cycle`),className:`flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner`,children:[A&&(0,f.jsx)(`button`,{type:`button`,"aria-pressed":T===`monthly`,onClick:()=>E(`monthly`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${T===`monthly`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:_(`ecommerce.monthly`)}),j&&(0,f.jsx)(`button`,{type:`button`,"aria-pressed":T===`annual`,onClick:()=>E(`annual`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${T===`annual`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:_(`ecommerce.annual`)}),M&&(0,f.jsx)(`button`,{type:`button`,"aria-pressed":T===`lifetime`,onClick:()=>E(`lifetime`),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${T===`lifetime`?`bg-background shadow-sm text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:_(`ecommerce.lifetime`)})]}),(0,f.jsxs)(`div`,{className:`text-center`,children:[(0,f.jsx)(`span`,{className:`text-3xl font-extrabold text-foreground tabular-nums`,children:h(P,v)}),T!==`lifetime`&&(0,f.jsxs)(`span`,{className:`text-muted-foreground text-sm ml-1.5`,children:[`/ `,_(T===`annual`?`ecommerce.year`:`ecommerce.month`)]}),N&&(0,f.jsxs)(`div`,{className:`mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400`,children:[N.label,(0,f.jsx)(`span`,{className:`mx-2 text-muted-foreground/50`,children:`|`}),(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:N.paymentRequirementLabel})]})]}),(0,f.jsxs)(c.Button,{onClick:k,className:`w-full h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]`,children:[(0,f.jsx)(u.ShoppingCart,{className:`mr-2 h-4 w-4`}),N?.label?_(`ecommerce.start_trial`,{trial:N.label})===`ecommerce.start_trial`?`Start ${N.label}`:_(`ecommerce.start_trial`,{trial:N.label}):_(`ecommerce.get_license`)]})]})};exports.SubscriptionSelector=h;
@@ -4,143 +4,142 @@ import { useCurrency as t } from "../CurrencyProvider.es.js";
4
4
  import { useCart as n } from "../use-cart.es.js";
5
5
  import { usePriceFormatter as r } from "../use-price-formatter.es.js";
6
6
  import { getTrialSummary as i } from "../trials.es.js";
7
- import { getPublicFreemiusPricing as a } from "../pages/cms/products/actions.es.js";
8
- import { Button as o } from "@nextblock-cms/ui/button";
9
- import { useEffect as s, useState as c } from "react";
10
- import { ShoppingCart as l } from "lucide-react";
11
- import { majorUnitAmountToMinor as u, useTranslations as d } from "@nextblock-cms/utils";
12
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
13
- import { toast as m } from "sonner";
14
- import { Skeleton as h } from "@nextblock-cms/ui/Skeleton";
7
+ import { pickFreemiusPricingTier as a } from "../freemius-pricing.es.js";
8
+ import { getPublicFreemiusPricing as o } from "../pages/cms/products/actions.es.js";
9
+ import { Button as s } from "@nextblock-cms/ui/button";
10
+ import { useEffect as c, useState as l } from "react";
11
+ import { ShoppingCart as u } from "lucide-react";
12
+ import { majorUnitAmountToMinor as d, useTranslations as f } from "@nextblock-cms/utils";
13
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
14
+ import { toast as h } from "sonner";
15
+ import { Skeleton as g } from "@nextblock-cms/ui/Skeleton";
15
16
  //#region src/lib/components/SubscriptionSelector.tsx
16
- var g = ({ product: g }) => {
17
- let _ = r(), v = n((e) => e), { t: y } = d(), { activeCurrencyCode: b, currencies: x, defaultCurrency: S } = t(), [C, w] = c([]), [T, E] = c(!0), [D, O] = c("annual");
18
- if (s(() => {
17
+ var _ = ({ product: _ }) => {
18
+ let v = r(), y = n((e) => e), { t: b } = f(), { activeCurrencyCode: x, currencies: S, defaultCurrency: C } = t(), [w, T] = l([]), [E, D] = l(!0), [O, k] = l("annual");
19
+ if (c(() => {
19
20
  async function e() {
20
21
  try {
21
- if (!g.id) return;
22
- let e = await a(g.id);
23
- w(e);
22
+ if (!_.id) return;
23
+ let e = await o(_.id);
24
+ T(e);
24
25
  } catch (e) {
25
26
  console.error("Failed to load pricing:", e);
26
27
  } finally {
27
- E(!1);
28
+ D(!1);
28
29
  }
29
30
  }
30
31
  e();
31
- }, [g.id]), !v) return /* @__PURE__ */ f(h, { className: "h-14 w-full" });
32
- let { addItem: k } = v, A = C[0], j = A?.pricing?.[0], M = () => {
33
- let t = g.price, n = g.freemius_plan_id;
34
- j && (D === "monthly" && j.monthly_price != null && (t = u(j.monthly_price, S.code)), D === "annual" && j.annual_price != null && (t = u(j.annual_price, S.code)), D === "lifetime" && j.lifetime_price != null && (t = u(j.lifetime_price, S.code)));
35
- let r = x.reduce((n, r) => (n[r.code] = e({
32
+ }, [_.id]), !y) return /* @__PURE__ */ p(g, { className: "h-14 w-full" });
33
+ let { addItem: A } = y, j = a(w.flatMap((e) => e.pricing ?? [])), M = () => {
34
+ let t = _.price;
35
+ j && (O === "monthly" && j.monthly_price != null && (t = d(j.monthly_price, C.code)), O === "annual" && j.annual_price != null && (t = d(j.annual_price, C.code)), O === "lifetime" && j.lifetime_price != null && (t = d(j.lifetime_price, C.code)));
36
+ let n = S.reduce((n, r) => (n[r.code] = e({
36
37
  amount: t,
37
- fromCurrencyCode: S.code,
38
+ fromCurrencyCode: C.code,
38
39
  toCurrencyCode: r.code,
39
- currencies: x,
40
+ currencies: S,
40
41
  applyRounding: !0
41
- }), n), {}), i = r[b] ?? t;
42
- A && A.id && (n = A.id);
43
- let { success: a, error: o } = k({
44
- id: g.id,
45
- product_id: g.id,
46
- title: g.title,
47
- price: i,
48
- prices: r,
49
- image_url: g.image_url,
50
- slug: g.slug,
51
- sku: g.sku,
52
- language_id: g.language_id,
53
- translation_group_id: g.translation_group_id,
42
+ }), n), {}), r = n[x] ?? t, { success: i, error: a } = A({
43
+ id: _.id,
44
+ product_id: _.id,
45
+ title: _.title,
46
+ price: r,
47
+ prices: n,
48
+ image_url: _.image_url,
49
+ slug: _.slug,
50
+ sku: _.sku,
51
+ language_id: _.language_id,
52
+ translation_group_id: _.translation_group_id,
54
53
  product_type: "digital",
55
54
  payment_provider: "freemius",
56
55
  provider: "freemius",
57
- billing_cycle: D,
58
- freemius_product_id: g.freemius_product_id,
59
- freemius_plan_id: n,
60
- trial_period_days: g.trial_period_days ?? 0,
61
- trial_requires_payment_method: g.trial_requires_payment_method ?? !1,
62
- is_taxable: g.is_taxable,
63
- currency_code: b
56
+ billing_cycle: O,
57
+ freemius_product_id: _.freemius_product_id,
58
+ freemius_plan_id: _.freemius_plan_id,
59
+ trial_period_days: _.trial_period_days ?? 0,
60
+ trial_requires_payment_method: _.trial_requires_payment_method ?? !1,
61
+ is_taxable: _.is_taxable,
62
+ currency_code: x
64
63
  });
65
- a ? m.success(y("ecommerce.added_to_cart_success", { item: g.title })) : m.error(o || y("ecommerce.added_to_cart_error"));
64
+ i ? h.success(b("ecommerce.added_to_cart_success", { item: _.title })) : h.error(a || b("ecommerce.added_to_cart_error"));
66
65
  };
67
- if (T) return /* @__PURE__ */ f(h, { className: "h-32 w-full" });
68
- if (!A || !j) return /* @__PURE__ */ f("div", {
66
+ if (E) return /* @__PURE__ */ p(g, { className: "h-32 w-full" });
67
+ if (!j) return /* @__PURE__ */ p("div", {
69
68
  className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground",
70
- children: y("ecommerce.pricing_unavailable")
69
+ children: b("ecommerce.pricing_unavailable")
71
70
  });
72
71
  let N = j.monthly_price != null, P = j.annual_price != null, F = j.lifetime_price != null;
73
- D === "annual" && !P && (N ? O("monthly") : F && O("lifetime"));
74
- let I = i(g, y), L = g.price;
75
- return D === "monthly" && j.monthly_price != null && (L = e({
76
- amount: u(j.monthly_price, S.code),
77
- fromCurrencyCode: S.code,
78
- toCurrencyCode: b,
79
- currencies: x,
72
+ O === "annual" && !P && (N ? k("monthly") : F && k("lifetime"));
73
+ let I = i(_, b), L = _.price;
74
+ return O === "monthly" && j.monthly_price != null && (L = e({
75
+ amount: d(j.monthly_price, C.code),
76
+ fromCurrencyCode: C.code,
77
+ toCurrencyCode: x,
78
+ currencies: S,
80
79
  applyRounding: !0
81
- })), D === "annual" && j.annual_price != null && (L = e({
82
- amount: u(j.annual_price, S.code),
83
- fromCurrencyCode: S.code,
84
- toCurrencyCode: b,
85
- currencies: x,
80
+ })), O === "annual" && j.annual_price != null && (L = e({
81
+ amount: d(j.annual_price, C.code),
82
+ fromCurrencyCode: C.code,
83
+ toCurrencyCode: x,
84
+ currencies: S,
86
85
  applyRounding: !0
87
- })), D === "lifetime" && j.lifetime_price != null && (L = e({
88
- amount: u(j.lifetime_price, S.code),
89
- fromCurrencyCode: S.code,
90
- toCurrencyCode: b,
91
- currencies: x,
86
+ })), O === "lifetime" && j.lifetime_price != null && (L = e({
87
+ amount: d(j.lifetime_price, C.code),
88
+ fromCurrencyCode: C.code,
89
+ toCurrencyCode: x,
90
+ currencies: S,
92
91
  applyRounding: !0
93
- })), /* @__PURE__ */ p("div", {
92
+ })), /* @__PURE__ */ m("div", {
94
93
  className: "flex flex-col gap-4",
95
94
  children: [
96
- /* @__PURE__ */ p("div", {
95
+ /* @__PURE__ */ m("div", {
97
96
  role: "group",
98
- "aria-label": y("ecommerce.billing_cycle") === "ecommerce.billing_cycle" ? "Billing cycle" : y("ecommerce.billing_cycle"),
97
+ "aria-label": b("ecommerce.billing_cycle") === "ecommerce.billing_cycle" ? "Billing cycle" : b("ecommerce.billing_cycle"),
99
98
  className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner",
100
99
  children: [
101
- N && /* @__PURE__ */ f("button", {
100
+ N && /* @__PURE__ */ p("button", {
102
101
  type: "button",
103
- "aria-pressed": D === "monthly",
104
- onClick: () => O("monthly"),
105
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
106
- children: y("ecommerce.monthly")
102
+ "aria-pressed": O === "monthly",
103
+ onClick: () => k("monthly"),
104
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${O === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
105
+ children: b("ecommerce.monthly")
107
106
  }),
108
- P && /* @__PURE__ */ f("button", {
107
+ P && /* @__PURE__ */ p("button", {
109
108
  type: "button",
110
- "aria-pressed": D === "annual",
111
- onClick: () => O("annual"),
112
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
113
- children: y("ecommerce.annual")
109
+ "aria-pressed": O === "annual",
110
+ onClick: () => k("annual"),
111
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${O === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
112
+ children: b("ecommerce.annual")
114
113
  }),
115
- F && /* @__PURE__ */ f("button", {
114
+ F && /* @__PURE__ */ p("button", {
116
115
  type: "button",
117
- "aria-pressed": D === "lifetime",
118
- onClick: () => O("lifetime"),
119
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${D === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
120
- children: y("ecommerce.lifetime")
116
+ "aria-pressed": O === "lifetime",
117
+ onClick: () => k("lifetime"),
118
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring ${O === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
119
+ children: b("ecommerce.lifetime")
121
120
  })
122
121
  ]
123
122
  }),
124
- /* @__PURE__ */ p("div", {
123
+ /* @__PURE__ */ m("div", {
125
124
  className: "text-center",
126
125
  children: [
127
- /* @__PURE__ */ f("span", {
126
+ /* @__PURE__ */ p("span", {
128
127
  className: "text-3xl font-extrabold text-foreground tabular-nums",
129
- children: _(L, b)
128
+ children: v(L, x)
130
129
  }),
131
- D !== "lifetime" && /* @__PURE__ */ p("span", {
130
+ O !== "lifetime" && /* @__PURE__ */ m("span", {
132
131
  className: "text-muted-foreground text-sm ml-1.5",
133
- children: ["/ ", y(D === "annual" ? "ecommerce.year" : "ecommerce.month")]
132
+ children: ["/ ", b(O === "annual" ? "ecommerce.year" : "ecommerce.month")]
134
133
  }),
135
- I && /* @__PURE__ */ p("div", {
134
+ I && /* @__PURE__ */ m("div", {
136
135
  className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400",
137
136
  children: [
138
137
  I.label,
139
- /* @__PURE__ */ f("span", {
138
+ /* @__PURE__ */ p("span", {
140
139
  className: "mx-2 text-muted-foreground/50",
141
140
  children: "|"
142
141
  }),
143
- /* @__PURE__ */ f("span", {
142
+ /* @__PURE__ */ p("span", {
144
143
  className: "text-muted-foreground",
145
144
  children: I.paymentRequirementLabel
146
145
  })
@@ -148,13 +147,13 @@ var g = ({ product: g }) => {
148
147
  })
149
148
  ]
150
149
  }),
151
- /* @__PURE__ */ p(o, {
150
+ /* @__PURE__ */ m(s, {
152
151
  onClick: M,
153
152
  className: "w-full h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]",
154
- children: [/* @__PURE__ */ f(l, { className: "mr-2 h-4 w-4" }), I?.label ? y("ecommerce.start_trial", { trial: I.label }) === "ecommerce.start_trial" ? `Start ${I.label}` : y("ecommerce.start_trial", { trial: I.label }) : y("ecommerce.get_license")]
153
+ children: [/* @__PURE__ */ p(u, { className: "mr-2 h-4 w-4" }), I?.label ? b("ecommerce.start_trial", { trial: I.label }) === "ecommerce.start_trial" ? `Start ${I.label}` : b("ecommerce.start_trial", { trial: I.label }) : b("ecommerce.get_license")]
155
154
  })
156
155
  ]
157
156
  });
158
157
  };
159
158
  //#endregion
160
- export { g as SubscriptionSelector };
159
+ export { _ as SubscriptionSelector };