/**
 * @startsimpli/billing — Universal billing integration for StartSimpli apps.
 *
 * Usage:
 *   import { BillingProvider, useProduct, useCheckout } from "@startsimpli/billing";
 *
 *   <BillingProvider apiBaseUrl="/api">
 *     <PricingPage productId="raise-simpli" />
 *   </BillingProvider>
 */

// Context & Hooks
export {
  BillingProvider,
  useBillingContext,
  useProduct,
  useCheckout,
  usePortal,
  useSubscription,
  useSuccessSync,
  useOfferCheckout,
  useAutoCheckout,
  useUsage,
  usePlanChange,
  notifyUsageChanged,
  USAGE_CHANGED_EVENT,
} from "./hooks";
export type { BillingProviderProps, UseOfferCheckoutOptions, UseAutoCheckoutOptions, PlanChangeContext, PlanChangeConfirmState, PlanChangeProceed, UsePlanChangeResult } from "./hooks";

// Types
export type {
  BillingConfig,
  BillingProduct,
  ProductOffer,
  OfferFeature,
  CheckoutResult,
  CachedSubscriptionState,
  FreeSubscriptionResult,
  PaymentMethod,
  PlanChangePreview,
  PortalResult,
  SubscriptionInfo,
  UsageMap,
} from "./types";

// Components
export { PricingPage, PricingSection, PricingDetailPage, UpgradeModal, ManageSubscription, SubscriptionManager, PlanGate, CurrentPlanCard, LimitNudge, PlanChangeConfirm, planChangeCopy, UsageMeters } from "./components";
export type {
  PricingPageProps,
  PricingSectionProps,
  PricingDetailPageProps,
  UpgradeModalProps,
  ManageSubscriptionProps,
  SubscriptionManagerProps,
  PlanGateProps,
  CurrentPlanCardProps,
  LimitNudgeProps,
  PlanChangeConfirmProps,
  UsageMetersProps,
  UsageMetersCopy,
} from "./components";

// API client (for advanced usage)
export { BillingApiClient } from "./utils/api";

// Pure helpers
export {
  isPaidSubscription,
  isPayingSubscription,
  trialLabel,
  isUnlistedOffer,
  getFeatureLimit,
  resolvePlanEntitlement,
  resolveUsageWindow,
  resolveCurrentOfferId,
  resolveCurrentOffer,
  planDirection,
  planCtaLabel,
  trialApplies,
  TRIAL_NOTE_FEATURE_KEY,
} from "./utils/plan";
export type { PlanEntitlement, ResolvePlanEntitlementOptions, UsageWindow, CurrentPlanState, PlanDirection } from "./utils/plan";
export { formatPrice, formatFeatureLabel } from "./utils/format";
export { afterCheckout, checkoutSessionIdFrom, safeNextPath, withSessionPlaceholder } from "./utils/checkout-flow";
export type { CheckoutPaths } from "./utils/checkout-flow";
export { groupOffersByTier, offersForInterval, hasIntervalChoice, annualSavings, tierOffer } from "./utils/tiers";
export type { BillingInterval, OfferTier } from "./utils/tiers";

// Return-URL / hand-off helpers, credit-pack math, usage meters
export {
  autoCheckoutOffer,
  billingReturnUrl,
  creditReturnUrls,
  creditSessionFrom,
  signUpReturnUrl,
  statusMessageFrom,
} from "./utils/return-urls";
export type { CreditReturnPaths, PlanStatusMessage } from "./utils/return-urls";
export { formatPackPrice, pricePerCredit, savingsPercent } from "./utils/credit-math";
export type { PackPrice } from "./utils/credit-math";
export { meterRows } from "./utils/usage-meters";
export type { MeterRow, MeterState } from "./utils/usage-meters";
