@solvapay/react 1.0.8-preview.9 → 1.0.9

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.
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React, { Ref } from 'react';
3
- import { k as Plan, F as Product, y as UseTopupAmountSelectorReturn, D as PurchaseInfo, T as TopupFormProps } from '../CancelPlanButton-CieT9swn.cjs';
4
- export { a4 as ActivationFlow, a5 as ActivationFlowActivateButton, a6 as ActivationFlowActivated, a7 as ActivationFlowAmountPicker, a8 as ActivationFlowContinueButton, a9 as ActivationFlowError, aa as ActivationFlowLoading, ab as ActivationFlowRetrying, ac as ActivationFlowRoot, G as ActivationFlowStep, ad as ActivationFlowSummary, H as BalanceBadge, I as CancelPlanButton, O as MandateText, Q as MandateTextProps, ae as PaymentForm, e as PaymentFormCardElement, c as PaymentFormCustomerFields, j as PaymentFormError, i as PaymentFormLoading, f as PaymentFormMandateText, d as PaymentFormPaymentElement, af as PaymentFormRoot, h as PaymentFormSubmitButton, b as PaymentFormSummary, g as PaymentFormTermsCheckbox, Z as PlanBadge, _ as ProductBadge, $ as PurchaseGate, ag as PurchaseGateAllowed, ah as PurchaseGateBlocked, ai as PurchaseGateError, aj as PurchaseGateLoading, ak as PurchaseGateRoot, al as useActivationFlow, am as usePurchaseGate } from '../CancelPlanButton-CieT9swn.cjs';
3
+ import { b as Plan, w as Product, q as UseTopupAmountSelectorReturn, v as PurchaseInfo, T as TopupFormProps, t as PaywallStructuredContent } from '../index-WBjulQHf.cjs';
4
+ import { U as UsageSnapshot } from '../useUsage-BmOYXxgG.cjs';
5
+ export { r as ActivationFlow, s as ActivationFlowActivateButton, t as ActivationFlowActivated, v as ActivationFlowAmountPicker, w as ActivationFlowContinueButton, x as ActivationFlowError, y as ActivationFlowLoading, z as ActivationFlowRetrying, D as ActivationFlowRoot, A as ActivationFlowStep, E as ActivationFlowSummary, B as BalanceBadge, i as CancelPlanButton, M as MandateText, l as MandateTextProps, F as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, G as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, m as PlanBadge, n as ProductBadge, o as PurchaseGate, H as PurchaseGateAllowed, I as PurchaseGateBlocked, J as PurchaseGateError, K as PurchaseGateLoading, L as PurchaseGateRoot, N as useActivationFlow, O as usePurchaseGate } from '../useUsage-BmOYXxgG.cjs';
5
6
  import { PaymentElement } from '@stripe/react-stripe-js';
6
7
  import { Stripe, StripeElements } from '@stripe/stripe-js';
7
- import '@solvapay/server';
8
8
  import '../adapters/auth.cjs';
9
9
 
10
10
  interface SlotProps extends React.HTMLAttributes<HTMLElement> {
@@ -141,6 +141,11 @@ type PlanSelectorContextValue = {
141
141
  isFree: (ref: string) => boolean;
142
142
  isPopular: (ref: string) => boolean;
143
143
  select: (ref: string) => void;
144
+ /**
145
+ * Clear the current selection so no plan is selected. Pins
146
+ * `userHasSelected` true so auto-selection doesn't reassert.
147
+ */
148
+ clearSelection: () => void;
144
149
  };
145
150
  declare const PlanSelectorRoot: React.ForwardRefExoticComponent<{
146
151
  productRef?: string;
@@ -248,15 +253,36 @@ declare function usePlanSelector(): PlanSelectorContextValue;
248
253
 
249
254
  type AmountPickerContextValue = UseTopupAmountSelectorReturn & {
250
255
  currency: string;
256
+ emit: 'major' | 'minor';
251
257
  creditsPerMinorUnit: number | null;
252
258
  displayExchangeRate: number | null;
253
259
  estimatedCredits: number | null;
254
260
  isApproximate: boolean;
261
+ /**
262
+ * `resolvedAmount` expressed in minor units (e.g. cents). Respects
263
+ * zero-decimal currencies: for JPY this equals `resolvedAmount`; for USD
264
+ * it equals `resolvedAmount * 100`. `null` when no valid amount is set.
265
+ */
266
+ resolvedAmountMinor: number | null;
255
267
  };
256
268
  declare const AmountPickerRoot: React.ForwardRefExoticComponent<{
257
269
  currency: string;
258
270
  minAmount?: number;
259
271
  maxAmount?: number;
272
+ /**
273
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
274
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
275
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
276
+ * (JPY → integer yen in either mode).
277
+ */
278
+ emit?: "major" | "minor";
279
+ /**
280
+ * Externally-owned selector. When provided, `Root` uses this instance
281
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
282
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
283
+ * picker so selections feed back into retry logic.
284
+ */
285
+ selector?: UseTopupAmountSelectorReturn;
260
286
  onChange?: (amount: number | null) => void;
261
287
  asChild?: boolean;
262
288
  children?: React.ReactNode;
@@ -277,6 +303,20 @@ declare const AmountPicker: {
277
303
  currency: string;
278
304
  minAmount?: number;
279
305
  maxAmount?: number;
306
+ /**
307
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
308
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
309
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
310
+ * (JPY → integer yen in either mode).
311
+ */
312
+ emit?: "major" | "minor";
313
+ /**
314
+ * Externally-owned selector. When provided, `Root` uses this instance
315
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
316
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
317
+ * picker so selections feed back into retry logic.
318
+ */
319
+ selector?: UseTopupAmountSelectorReturn;
280
320
  onChange?: (amount: number | null) => void;
281
321
  asChild?: boolean;
282
322
  children?: React.ReactNode;
@@ -328,7 +368,7 @@ declare const CancelledPlanNoticeRoot: React.ForwardRefExoticComponent<{
328
368
  onError?: (error: Error) => void;
329
369
  asChild?: boolean;
330
370
  children?: React.ReactNode;
331
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React.RefAttributes<HTMLDivElement>>;
371
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
332
372
  declare const CancelledPlanNoticeHeading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
333
373
  asChild?: boolean;
334
374
  } & React.RefAttributes<HTMLParagraphElement>>;
@@ -356,7 +396,7 @@ declare const CancelledPlanNotice: {
356
396
  onError?: (error: Error) => void;
357
397
  asChild?: boolean;
358
398
  children?: React.ReactNode;
359
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React.RefAttributes<HTMLDivElement>>;
399
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
360
400
  readonly Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
361
401
  asChild?: boolean;
362
402
  } & React.RefAttributes<HTMLParagraphElement>>;
@@ -456,20 +496,6 @@ declare const CreditGate: {
456
496
  };
457
497
  declare function useCreditGate(): CreditGateContextValue;
458
498
 
459
- /**
460
- * TopupForm compound primitive.
461
- *
462
- * Wraps `useTopup` + Stripe Elements to run a one-shot credit top-up.
463
- * Unlike `PaymentForm`, no backend reconciliation is needed — credits land
464
- * via the webhook handler, so `onSuccess` fires immediately after Stripe
465
- * confirmation.
466
- *
467
- * `TopupForm.AmountPicker` is re-exported from the `AmountPicker` primitive
468
- * so consumers can compose an in-place amount picker without importing from
469
- * two modules. The amount flows into the form either via the `amount` prop
470
- * on `Root` or via a sibling `AmountPicker` with matching state.
471
- */
472
-
473
499
  type TopupFormState = 'loading' | 'ready' | 'error';
474
500
  type TopupFormContextValue = {
475
501
  amount: number;
@@ -513,6 +539,8 @@ declare const TopupForm: {
513
539
  currency: string;
514
540
  minAmount?: number;
515
541
  maxAmount?: number;
542
+ emit?: "major" | "minor";
543
+ selector?: UseTopupAmountSelectorReturn;
516
544
  onChange?: (amount: number | null) => void;
517
545
  asChild?: boolean;
518
546
  children?: React.ReactNode;
@@ -530,4 +558,164 @@ declare const TopupForm: {
530
558
  };
531
559
  declare function useTopupForm(): TopupFormContextValue;
532
560
 
533
- export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePlanSelector, useTopupForm };
561
+ interface PaywallNoticeClassNames {
562
+ root?: string;
563
+ heading?: string;
564
+ message?: string;
565
+ productContext?: string;
566
+ balance?: string;
567
+ plans?: string;
568
+ hostedLink?: string;
569
+ embeddedCheckout?: string;
570
+ retryButton?: string;
571
+ }
572
+ interface PaywallNoticeContextValue {
573
+ content: PaywallStructuredContent;
574
+ resolved: boolean;
575
+ refetch: () => Promise<void>;
576
+ onResolved?: () => void;
577
+ classNames: PaywallNoticeClassNames;
578
+ }
579
+ interface PaywallNoticeRootProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {
580
+ content: PaywallStructuredContent;
581
+ /**
582
+ * Called once the paywall requirement is met (purchase created or plan
583
+ * activated). Consumers typically use this to dismiss the notice and
584
+ * retry the original tool call.
585
+ */
586
+ onResolved?: () => void;
587
+ classNames?: PaywallNoticeClassNames;
588
+ asChild?: boolean;
589
+ }
590
+ declare const Root$1: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
591
+ declare const Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
592
+ asChild?: boolean;
593
+ } & React.RefAttributes<HTMLHeadingElement>>;
594
+ declare const Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
595
+ asChild?: boolean;
596
+ } & React.RefAttributes<HTMLParagraphElement>>;
597
+ declare const ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
598
+ asChild?: boolean;
599
+ } & React.RefAttributes<HTMLDivElement>>;
600
+ declare const Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
601
+ asChild?: boolean;
602
+ } & React.RefAttributes<HTMLDivElement>>;
603
+ interface PlansProps {
604
+ /** Custom className forwarded to the underlying `<PlanSelector.Root>`. */
605
+ className?: string;
606
+ children?: React.ReactNode;
607
+ }
608
+ declare function Plans({ className, children }: PlansProps): react_jsx_runtime.JSX.Element | null;
609
+ declare const HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
610
+ asChild?: boolean;
611
+ } & React.RefAttributes<HTMLAnchorElement>>;
612
+ interface EmbeddedCheckoutProps {
613
+ /**
614
+ * Return URL forwarded to `<PaymentForm.Root>` for Stripe's
615
+ * confirmPayment step.
616
+ */
617
+ returnUrl: string;
618
+ className?: string;
619
+ children?: React.ReactNode;
620
+ }
621
+ declare function EmbeddedCheckout({ returnUrl, className, children, }: EmbeddedCheckoutProps): react_jsx_runtime.JSX.Element | null;
622
+ declare const Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
623
+ asChild?: boolean;
624
+ } & React.RefAttributes<HTMLButtonElement>>;
625
+ declare const PaywallNotice: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>> & {
626
+ Root: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
627
+ Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
628
+ asChild?: boolean;
629
+ } & React.RefAttributes<HTMLHeadingElement>>;
630
+ Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
631
+ asChild?: boolean;
632
+ } & React.RefAttributes<HTMLParagraphElement>>;
633
+ ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
634
+ asChild?: boolean;
635
+ } & React.RefAttributes<HTMLDivElement>>;
636
+ Plans: typeof Plans;
637
+ Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
638
+ asChild?: boolean;
639
+ } & React.RefAttributes<HTMLDivElement>>;
640
+ HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
641
+ asChild?: boolean;
642
+ } & React.RefAttributes<HTMLAnchorElement>>;
643
+ EmbeddedCheckout: typeof EmbeddedCheckout;
644
+ Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
645
+ asChild?: boolean;
646
+ } & React.RefAttributes<HTMLButtonElement>>;
647
+ };
648
+
649
+ declare function usePaywallNotice(): PaywallNoticeContextValue;
650
+
651
+ /**
652
+ * `<UsageMeter>` compound primitive — renders the authenticated customer's
653
+ * usage against their plan quota.
654
+ *
655
+ * Composes `useUsage()` internally so integrators only render the leaf
656
+ * primitives they care about. Leaves render `null` when the active plan
657
+ * isn't usage-based, so dropping the compound into any account page is
658
+ * safe.
659
+ *
660
+ * State:
661
+ * - root / bar `data-state="safe" | "warning" | "critical" | "loading"`
662
+ * - root `data-solvapay-usage-meter`
663
+ * - bar `data-solvapay-usage-meter-bar`
664
+ */
665
+
666
+ type UsageMeterState = 'safe' | 'warning' | 'critical' | 'loading';
667
+ interface UsageMeterContextValue {
668
+ usage: UsageSnapshot | null;
669
+ loading: boolean;
670
+ error: Error | null;
671
+ percentUsed: number | null;
672
+ isApproachingLimit: boolean;
673
+ isAtLimit: boolean;
674
+ isUnlimited: boolean;
675
+ state: UsageMeterState;
676
+ warningAt: number;
677
+ criticalAt: number;
678
+ }
679
+ interface UsageMeterClassNames {
680
+ root?: string;
681
+ bar?: string;
682
+ label?: string;
683
+ percentage?: string;
684
+ resetsIn?: string;
685
+ loading?: string;
686
+ empty?: string;
687
+ error?: string;
688
+ }
689
+ interface UsageMeterRootProps extends React.HTMLAttributes<HTMLDivElement> {
690
+ /** Percent at which the bar flips to `data-state="warning"`. Default 75. */
691
+ warningAt?: number;
692
+ /** Percent at which the bar flips to `data-state="critical"`. Default 90. */
693
+ criticalAt?: number;
694
+ classNames?: UsageMeterClassNames;
695
+ asChild?: boolean;
696
+ /**
697
+ * Override the usage snapshot rather than reading from `useUsage`.
698
+ * Mostly useful for tests / Storybook demos.
699
+ */
700
+ usageOverride?: UsageSnapshot | null;
701
+ }
702
+ declare const Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
703
+ declare const Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
704
+ declare const Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
705
+ declare const Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
706
+ declare const ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
707
+ declare const Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
708
+ declare const Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
709
+ declare const UsageMeter: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>> & {
710
+ Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
711
+ Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
712
+ Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
713
+ Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
714
+ ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
715
+ Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
716
+ Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
717
+ };
718
+
719
+ declare function useUsageMeter(): UsageMeterContextValue;
720
+
721
+ export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React, { Ref } from 'react';
3
- import { k as Plan, F as Product, y as UseTopupAmountSelectorReturn, D as PurchaseInfo, T as TopupFormProps } from '../CancelPlanButton-f56UlQN-.js';
4
- export { a4 as ActivationFlow, a5 as ActivationFlowActivateButton, a6 as ActivationFlowActivated, a7 as ActivationFlowAmountPicker, a8 as ActivationFlowContinueButton, a9 as ActivationFlowError, aa as ActivationFlowLoading, ab as ActivationFlowRetrying, ac as ActivationFlowRoot, G as ActivationFlowStep, ad as ActivationFlowSummary, H as BalanceBadge, I as CancelPlanButton, O as MandateText, Q as MandateTextProps, ae as PaymentForm, e as PaymentFormCardElement, c as PaymentFormCustomerFields, j as PaymentFormError, i as PaymentFormLoading, f as PaymentFormMandateText, d as PaymentFormPaymentElement, af as PaymentFormRoot, h as PaymentFormSubmitButton, b as PaymentFormSummary, g as PaymentFormTermsCheckbox, Z as PlanBadge, _ as ProductBadge, $ as PurchaseGate, ag as PurchaseGateAllowed, ah as PurchaseGateBlocked, ai as PurchaseGateError, aj as PurchaseGateLoading, ak as PurchaseGateRoot, al as useActivationFlow, am as usePurchaseGate } from '../CancelPlanButton-f56UlQN-.js';
3
+ import { b as Plan, w as Product, q as UseTopupAmountSelectorReturn, v as PurchaseInfo, T as TopupFormProps, t as PaywallStructuredContent } from '../index-onWNU7iT.js';
4
+ import { U as UsageSnapshot } from '../useUsage-nD7zwSbG.js';
5
+ export { r as ActivationFlow, s as ActivationFlowActivateButton, t as ActivationFlowActivated, v as ActivationFlowAmountPicker, w as ActivationFlowContinueButton, x as ActivationFlowError, y as ActivationFlowLoading, z as ActivationFlowRetrying, D as ActivationFlowRoot, A as ActivationFlowStep, E as ActivationFlowSummary, B as BalanceBadge, i as CancelPlanButton, M as MandateText, l as MandateTextProps, F as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, G as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, m as PlanBadge, n as ProductBadge, o as PurchaseGate, H as PurchaseGateAllowed, I as PurchaseGateBlocked, J as PurchaseGateError, K as PurchaseGateLoading, L as PurchaseGateRoot, N as useActivationFlow, O as usePurchaseGate } from '../useUsage-nD7zwSbG.js';
5
6
  import { PaymentElement } from '@stripe/react-stripe-js';
6
7
  import { Stripe, StripeElements } from '@stripe/stripe-js';
7
- import '@solvapay/server';
8
8
  import '../adapters/auth.js';
9
9
 
10
10
  interface SlotProps extends React.HTMLAttributes<HTMLElement> {
@@ -141,6 +141,11 @@ type PlanSelectorContextValue = {
141
141
  isFree: (ref: string) => boolean;
142
142
  isPopular: (ref: string) => boolean;
143
143
  select: (ref: string) => void;
144
+ /**
145
+ * Clear the current selection so no plan is selected. Pins
146
+ * `userHasSelected` true so auto-selection doesn't reassert.
147
+ */
148
+ clearSelection: () => void;
144
149
  };
145
150
  declare const PlanSelectorRoot: React.ForwardRefExoticComponent<{
146
151
  productRef?: string;
@@ -248,15 +253,36 @@ declare function usePlanSelector(): PlanSelectorContextValue;
248
253
 
249
254
  type AmountPickerContextValue = UseTopupAmountSelectorReturn & {
250
255
  currency: string;
256
+ emit: 'major' | 'minor';
251
257
  creditsPerMinorUnit: number | null;
252
258
  displayExchangeRate: number | null;
253
259
  estimatedCredits: number | null;
254
260
  isApproximate: boolean;
261
+ /**
262
+ * `resolvedAmount` expressed in minor units (e.g. cents). Respects
263
+ * zero-decimal currencies: for JPY this equals `resolvedAmount`; for USD
264
+ * it equals `resolvedAmount * 100`. `null` when no valid amount is set.
265
+ */
266
+ resolvedAmountMinor: number | null;
255
267
  };
256
268
  declare const AmountPickerRoot: React.ForwardRefExoticComponent<{
257
269
  currency: string;
258
270
  minAmount?: number;
259
271
  maxAmount?: number;
272
+ /**
273
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
274
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
275
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
276
+ * (JPY → integer yen in either mode).
277
+ */
278
+ emit?: "major" | "minor";
279
+ /**
280
+ * Externally-owned selector. When provided, `Root` uses this instance
281
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
282
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
283
+ * picker so selections feed back into retry logic.
284
+ */
285
+ selector?: UseTopupAmountSelectorReturn;
260
286
  onChange?: (amount: number | null) => void;
261
287
  asChild?: boolean;
262
288
  children?: React.ReactNode;
@@ -277,6 +303,20 @@ declare const AmountPicker: {
277
303
  currency: string;
278
304
  minAmount?: number;
279
305
  maxAmount?: number;
306
+ /**
307
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
308
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
309
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
310
+ * (JPY → integer yen in either mode).
311
+ */
312
+ emit?: "major" | "minor";
313
+ /**
314
+ * Externally-owned selector. When provided, `Root` uses this instance
315
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
316
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
317
+ * picker so selections feed back into retry logic.
318
+ */
319
+ selector?: UseTopupAmountSelectorReturn;
280
320
  onChange?: (amount: number | null) => void;
281
321
  asChild?: boolean;
282
322
  children?: React.ReactNode;
@@ -328,7 +368,7 @@ declare const CancelledPlanNoticeRoot: React.ForwardRefExoticComponent<{
328
368
  onError?: (error: Error) => void;
329
369
  asChild?: boolean;
330
370
  children?: React.ReactNode;
331
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React.RefAttributes<HTMLDivElement>>;
371
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
332
372
  declare const CancelledPlanNoticeHeading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
333
373
  asChild?: boolean;
334
374
  } & React.RefAttributes<HTMLParagraphElement>>;
@@ -356,7 +396,7 @@ declare const CancelledPlanNotice: {
356
396
  onError?: (error: Error) => void;
357
397
  asChild?: boolean;
358
398
  children?: React.ReactNode;
359
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onError"> & React.RefAttributes<HTMLDivElement>>;
399
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
360
400
  readonly Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
361
401
  asChild?: boolean;
362
402
  } & React.RefAttributes<HTMLParagraphElement>>;
@@ -456,20 +496,6 @@ declare const CreditGate: {
456
496
  };
457
497
  declare function useCreditGate(): CreditGateContextValue;
458
498
 
459
- /**
460
- * TopupForm compound primitive.
461
- *
462
- * Wraps `useTopup` + Stripe Elements to run a one-shot credit top-up.
463
- * Unlike `PaymentForm`, no backend reconciliation is needed — credits land
464
- * via the webhook handler, so `onSuccess` fires immediately after Stripe
465
- * confirmation.
466
- *
467
- * `TopupForm.AmountPicker` is re-exported from the `AmountPicker` primitive
468
- * so consumers can compose an in-place amount picker without importing from
469
- * two modules. The amount flows into the form either via the `amount` prop
470
- * on `Root` or via a sibling `AmountPicker` with matching state.
471
- */
472
-
473
499
  type TopupFormState = 'loading' | 'ready' | 'error';
474
500
  type TopupFormContextValue = {
475
501
  amount: number;
@@ -513,6 +539,8 @@ declare const TopupForm: {
513
539
  currency: string;
514
540
  minAmount?: number;
515
541
  maxAmount?: number;
542
+ emit?: "major" | "minor";
543
+ selector?: UseTopupAmountSelectorReturn;
516
544
  onChange?: (amount: number | null) => void;
517
545
  asChild?: boolean;
518
546
  children?: React.ReactNode;
@@ -530,4 +558,164 @@ declare const TopupForm: {
530
558
  };
531
559
  declare function useTopupForm(): TopupFormContextValue;
532
560
 
533
- export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePlanSelector, useTopupForm };
561
+ interface PaywallNoticeClassNames {
562
+ root?: string;
563
+ heading?: string;
564
+ message?: string;
565
+ productContext?: string;
566
+ balance?: string;
567
+ plans?: string;
568
+ hostedLink?: string;
569
+ embeddedCheckout?: string;
570
+ retryButton?: string;
571
+ }
572
+ interface PaywallNoticeContextValue {
573
+ content: PaywallStructuredContent;
574
+ resolved: boolean;
575
+ refetch: () => Promise<void>;
576
+ onResolved?: () => void;
577
+ classNames: PaywallNoticeClassNames;
578
+ }
579
+ interface PaywallNoticeRootProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {
580
+ content: PaywallStructuredContent;
581
+ /**
582
+ * Called once the paywall requirement is met (purchase created or plan
583
+ * activated). Consumers typically use this to dismiss the notice and
584
+ * retry the original tool call.
585
+ */
586
+ onResolved?: () => void;
587
+ classNames?: PaywallNoticeClassNames;
588
+ asChild?: boolean;
589
+ }
590
+ declare const Root$1: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
591
+ declare const Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
592
+ asChild?: boolean;
593
+ } & React.RefAttributes<HTMLHeadingElement>>;
594
+ declare const Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
595
+ asChild?: boolean;
596
+ } & React.RefAttributes<HTMLParagraphElement>>;
597
+ declare const ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
598
+ asChild?: boolean;
599
+ } & React.RefAttributes<HTMLDivElement>>;
600
+ declare const Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
601
+ asChild?: boolean;
602
+ } & React.RefAttributes<HTMLDivElement>>;
603
+ interface PlansProps {
604
+ /** Custom className forwarded to the underlying `<PlanSelector.Root>`. */
605
+ className?: string;
606
+ children?: React.ReactNode;
607
+ }
608
+ declare function Plans({ className, children }: PlansProps): react_jsx_runtime.JSX.Element | null;
609
+ declare const HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
610
+ asChild?: boolean;
611
+ } & React.RefAttributes<HTMLAnchorElement>>;
612
+ interface EmbeddedCheckoutProps {
613
+ /**
614
+ * Return URL forwarded to `<PaymentForm.Root>` for Stripe's
615
+ * confirmPayment step.
616
+ */
617
+ returnUrl: string;
618
+ className?: string;
619
+ children?: React.ReactNode;
620
+ }
621
+ declare function EmbeddedCheckout({ returnUrl, className, children, }: EmbeddedCheckoutProps): react_jsx_runtime.JSX.Element | null;
622
+ declare const Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
623
+ asChild?: boolean;
624
+ } & React.RefAttributes<HTMLButtonElement>>;
625
+ declare const PaywallNotice: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>> & {
626
+ Root: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
627
+ Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
628
+ asChild?: boolean;
629
+ } & React.RefAttributes<HTMLHeadingElement>>;
630
+ Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
631
+ asChild?: boolean;
632
+ } & React.RefAttributes<HTMLParagraphElement>>;
633
+ ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
634
+ asChild?: boolean;
635
+ } & React.RefAttributes<HTMLDivElement>>;
636
+ Plans: typeof Plans;
637
+ Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
638
+ asChild?: boolean;
639
+ } & React.RefAttributes<HTMLDivElement>>;
640
+ HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
641
+ asChild?: boolean;
642
+ } & React.RefAttributes<HTMLAnchorElement>>;
643
+ EmbeddedCheckout: typeof EmbeddedCheckout;
644
+ Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
645
+ asChild?: boolean;
646
+ } & React.RefAttributes<HTMLButtonElement>>;
647
+ };
648
+
649
+ declare function usePaywallNotice(): PaywallNoticeContextValue;
650
+
651
+ /**
652
+ * `<UsageMeter>` compound primitive — renders the authenticated customer's
653
+ * usage against their plan quota.
654
+ *
655
+ * Composes `useUsage()` internally so integrators only render the leaf
656
+ * primitives they care about. Leaves render `null` when the active plan
657
+ * isn't usage-based, so dropping the compound into any account page is
658
+ * safe.
659
+ *
660
+ * State:
661
+ * - root / bar `data-state="safe" | "warning" | "critical" | "loading"`
662
+ * - root `data-solvapay-usage-meter`
663
+ * - bar `data-solvapay-usage-meter-bar`
664
+ */
665
+
666
+ type UsageMeterState = 'safe' | 'warning' | 'critical' | 'loading';
667
+ interface UsageMeterContextValue {
668
+ usage: UsageSnapshot | null;
669
+ loading: boolean;
670
+ error: Error | null;
671
+ percentUsed: number | null;
672
+ isApproachingLimit: boolean;
673
+ isAtLimit: boolean;
674
+ isUnlimited: boolean;
675
+ state: UsageMeterState;
676
+ warningAt: number;
677
+ criticalAt: number;
678
+ }
679
+ interface UsageMeterClassNames {
680
+ root?: string;
681
+ bar?: string;
682
+ label?: string;
683
+ percentage?: string;
684
+ resetsIn?: string;
685
+ loading?: string;
686
+ empty?: string;
687
+ error?: string;
688
+ }
689
+ interface UsageMeterRootProps extends React.HTMLAttributes<HTMLDivElement> {
690
+ /** Percent at which the bar flips to `data-state="warning"`. Default 75. */
691
+ warningAt?: number;
692
+ /** Percent at which the bar flips to `data-state="critical"`. Default 90. */
693
+ criticalAt?: number;
694
+ classNames?: UsageMeterClassNames;
695
+ asChild?: boolean;
696
+ /**
697
+ * Override the usage snapshot rather than reading from `useUsage`.
698
+ * Mostly useful for tests / Storybook demos.
699
+ */
700
+ usageOverride?: UsageSnapshot | null;
701
+ }
702
+ declare const Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
703
+ declare const Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
704
+ declare const Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
705
+ declare const Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
706
+ declare const ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
707
+ declare const Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
708
+ declare const Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
709
+ declare const UsageMeter: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>> & {
710
+ Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
711
+ Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
712
+ Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
713
+ Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
714
+ ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
715
+ Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
716
+ Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
717
+ };
718
+
719
+ declare function useUsageMeter(): UsageMeterContextValue;
720
+
721
+ export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };