import { Appearance } from '@stripe/stripe-js'; import { billing } from '@botpress/client'; import { ButtonHTMLAttributes } from 'react'; import { CancellationReason } from '@bpinternal/const'; import { ClassValue } from 'clsx'; import { Client } from '@botpress/client'; import { ComponentType } from 'react'; import { CreditGrantInterval } from '@bpinternal/const'; import { CSSProperties } from 'react'; import { InputHTMLAttributes } from 'react'; import { Interval } from '@bpinternal/const'; import { JSX } from 'react/jsx-runtime'; import { QueryClient } from '@tanstack/react-query'; import { ReactElement } from 'react'; import { ReactNode } from 'react'; import { ReactPortal } from 'react'; import { SelectHTMLAttributes } from 'react'; import { Stripe } from '@stripe/stripe-js'; import { StripeCardElementOptions } from '@stripe/stripe-js'; import { SupportedLocale } from './i18n'; import { SupportedLocale as SupportedLocale_2 } from '../i18n'; import { SVGProps } from 'react'; import { UseMutationResult } from '@tanstack/react-query'; import { UseQueryResult } from '@tanstack/react-query'; export declare function addDays(iso: string, days: number): string; export declare type Addon = Awaited>[number]; /** Strip Smaug's "Add-on - " name prefix. */ export declare function addonDisplayName(name: string): string; /** * "Now → New" resource totals: plan base + add-ons owned now (`currentQuantities`) vs. plan base + * the selected add-on quantities (`quantities`). One row per resource an add-on grants, even when * unchanged (e.g. reverting a scheduled downgrade). */ export declare function addonLimitsPreview(plan: Plan, addons: Addon[] | undefined, quantities: Record, currentQuantities?: Record): LimitPreviewRow[]; /** * Add-on price for a given plan. Smaug keys add-on prices by plan id * (e.g. { plus: { amount: 65 }, team: { amount: 50 } }); fall back to kind, then * to an interval key for environments that price add-ons globally. Add-ons are * billed monthly, so a plan interval with no add-on price (quarter, bi_annual) * uses the monthly price, like Smaug does. * * Deliberately does NOT fall back to "any price with a matching interval" — that * would borrow another plan's price for a plan that isn't sold add-ons at all * (e.g. community), making them look purchasable when they aren't. A plan with no * id/kind/interval-keyed price returns null → no add-ons offered. */ export declare function addonPrice(addon: Addon, plan: Plan, interval: BillingInterval): { amount: number; currency: string; } | null; /** * Clickable summary of active add-ons (current quantities from the live * subscription). Acts as a preview button that opens add-on management. */ export declare const AddonsSummaryCard: ({ onManage, className }: AddonsSummaryCardProps) => JSX.Element | null; export declare type AddonsSummaryCardProps = { /** Opens the manage-add-ons dialog. */ onManage: () => void; className?: string; }; export declare const AgentsIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const AiCreditsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: AiCreditsDialogProps) => JSX.Element | null; export declare type AiCreditsDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; onUpgrade?: () => void; }; export declare const ArrowRightIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare type AutoRechargeSetting = AutoRechargeSettings[string]; export declare type AutoRechargeSettingInput = { enabled?: boolean; targetType?: 'addon' | 'credit_grant'; thresholdType?: 'percentage' | 'remaining_amount'; threshold?: number; addonId?: string; chunkSize?: number | null; maxAmount?: number | null; }; export declare type AutoRechargeSettings = Awaited>['settings']; /** * Clickable summary of auto-recharge for the AI-spend credit wallet (on/off, * and the recharge amount + monthly limit when on). Acts as a preview button * that opens `AiCreditsDialog` — the settings themselves are edited there, * not inline. */ export declare const AutoRechargeSummaryCard: ({ onManage, className }: AutoRechargeSummaryCardProps) => JSX.Element | null; export declare type AutoRechargeSummaryCardProps = { /** Opens the auto-recharge management dialog. */ onManage: () => void; className?: string; }; export declare const Badge: ({ variant, children, className }: BadgeProps) => JSX.Element; export declare type BadgeProps = { variant?: 'accent' | 'neutral' | 'success' | 'danger'; children: ReactNode; className?: string; }; export declare const BankIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const BILLING_EVENTS: { readonly PLAN_PICKER_VIEWED: "billing_plan_picker_viewed"; readonly PLAN_INTERVAL_TOGGLED: "billing_plan_interval_toggled"; readonly PLAN_UPGRADE_INITIATED: "billing_plan_upgrade_initiated"; readonly PLAN_DOWNGRADED: "billing_plan_downgraded"; readonly PLAN_DOWNGRADE_CANCELLED: "billing_plan_downgrade_cancelled"; readonly DOWNGRADE_CONFIRM_VIEWED: "billing_downgrade_confirm_viewed"; readonly DOWNGRADE_SURVEY_VIEWED: "billing_downgrade_survey_viewed"; readonly DOWNGRADE_SURVEY_SUBMITTED: "billing_downgrade_survey_submitted"; readonly CHECKOUT_STEP_VIEWED: "billing_checkout_step_viewed"; readonly CHECKOUT_INTERVAL_CHANGED: "billing_checkout_interval_changed"; readonly PAYMENT_METHOD_SELECTED: "billing_payment_method_selected"; readonly PAYMENT_DETAILS_CONFIRMED: "billing_payment_details_confirmed"; readonly PLAN_UPGRADED: "billing_plan_upgraded"; readonly CHECKOUT_ERROR: "billing_checkout_error"; readonly PAYMENT_METHOD_UPDATED: "billing_payment_method_updated"; readonly BILLING_ADDRESS_UPDATED: "billing_address_updated"; readonly INVOICE_DOWNLOADED: "billing_invoice_downloaded"; readonly UPGRADE_CTA_CLICKED: "billing_upgrade_cta_clicked"; readonly AUTO_RECHARGE_UPDATED: "billing_auto_recharge_updated"; }; export declare const BillingActionCard: ({ Icon, title, description, onClick, className }: BillingActionCardProps) => JSX.Element; export declare type BillingActionCardProps = { Icon: ComponentType & { size?: number; }>; title: ReactNode; description: ReactNode; onClick: () => void; className?: string; }; export declare type BillingAddress = { lineOne?: string; lineTwo?: string; city?: string; state?: string; postalCode?: string; country: string; }; /** * Analytics sink the library captures billing events into. Structurally a subset * of a `posthog-js` instance — pass `posthog` straight in (no adapter), or any * object with a matching `capture`. The library never imports an analytics SDK, * so it stays publishable and provider-agnostic. Omit it and every event no-ops. * * Event names + property shapes the library emits live in `BILLING_EVENTS` * (./analytics) — that's the source of truth for what lands in your project. */ export declare type BillingAnalyticsClient = { capture: (event: string, properties?: Record) => void; }; export declare type BillingChangeEvent = { type: 'subscription' | 'addons' | 'payment-method' | 'billing-address' | 'auto-recharge' | 'pending-upgrade' | 'credit-grant'; }; /** * The billing engine surface this UI library talks to — literally the subset of * `@botpress/client`'s `billing.Client` (Smaug v4) we call. * * `@botpress/client` is a type-only import (erased at runtime — no hard * dependency): pass a real `billing.Client` instance straight in, or implement * this interface over your own backend proxy (e.g. tRPC) — the shapes are the * official wire shapes, the transport is yours. */ export declare type BillingClient = Pick & /** * `getWorkspaceMember` and `saveWorkspaceCancellationReasons` live on the * generic `@botpress/client`, not the billing client, but are REQUIRED here: * `useIsAuthorized` checks the caller's workspace membership, and the * downgrade flow saves the cancellation survey answers. Every host must pass * a client object that also exposes them. Still type-only — no runtime dep. */ Pick & /** * Per-bot usage breakdown is OPTIONAL: those methods also live on the * generic `@botpress/client`, but only a host that wants the per-bot view * needs to pass a client exposing them. Omit them and the UsageDashboard * hides the per-bot section. */ Partial>; export declare type BillingColorScheme = 'default' | 'neutral'; declare type BillingContextValue = { client: BillingClient; queryClient: QueryClient; /** Workspace scope used to namespace query keys (workspaceId or 'default'). */ scope: string; stripePromise: Promise; locale: SupportedLocale_2; isDark: boolean; colorScheme: BillingColorScheme; toast: (toast: BillingToast) => void; analytics: BillingAnalyticsClient; featureLabels?: Record string>; isOutdatedBilling: boolean; manageBillingUrl?: string; /** Background poll interval (ms) for queries; `false` when disabled (≤ 0). */ refetchInterval: number | false; /** Re-fetch all billing data (plans, subscription, add-ons, …). Awaitable. */ refresh: () => Promise; /** Internal: notify the host that billing changed. Called by the mutation hooks. */ notifyBillingChange: (event: BillingChangeEvent) => void; }; export declare type BillingEventName = (typeof BILLING_EVENTS)[keyof typeof BILLING_EVENTS]; /** BillingInterval describes all the possible intervals a plan can be billed at. * For some intervals (quarter, bi_annual) only customers actually onboarded to them * should be able to see them in their billing page. Other customers will only see the * self-serve intervals. */ export declare type BillingInterval = Interval; export declare const billingKeys: { /** Everything for one workspace — use to invalidate/clear the whole scope. */ root: (scope: string) => readonly ["bpb", string]; plans: (scope: string) => readonly ["bpb", string, "plans"]; addons: (scope: string) => readonly ["bpb", string, "addons"]; subscription: (scope: string) => readonly ["bpb", string, "subscription"]; preview: (scope: string, update: SubscriptionUpdate) => readonly ["bpb", string, "preview", SubscriptionUpdate]; paymentMethod: (scope: string) => readonly ["bpb", string, "payment-method"]; customer: (scope: string) => readonly ["bpb", string, "customer"]; invoices: (scope: string) => readonly ["bpb", string, "invoices"]; readonly: (scope: string) => readonly ["bpb", string, "billing-readonly"]; isAuthorized: (scope: string) => readonly ["bpb", string, "is-authorized"]; autoRecharge: (scope: string) => readonly ["bpb", string, "auto-recharge"]; usages: (scope: string, period: string) => readonly ["bpb", string, "usages", string]; bots: (scope: string) => readonly ["bpb", string, "bots"]; creditGrants: (scope: string) => readonly ["bpb", string, "credit-grants", "paged"]; usageByBot: (scope: string, type: string, period: string) => readonly ["bpb", string, "usage-by-bot", string, string]; }; export declare const BillingProvider: ({ client, stripePublishableKey, locale, theme, colorScheme, onToast, analytics, featureLabels, billingVersion, workspaceId, persist, manageBillingUrl, onBillingChange, refreshInterval, children, }: BillingProviderProps) => JSX.Element; export declare type BillingProviderProps = { /** Billing engine client — `@botpress/client`'s `billing.Client` or any compatible adapter */ client: BillingClient; /** Stripe publishable key (pk_…). The only Stripe key the frontend ever sees. */ stripePublishableKey: string; locale?: SupportedLocale_2; theme?: BillingTheme; colorScheme?: BillingColorScheme; onToast?: (toast: BillingToast) => void; /** * Analytics sink the library captures billing-funnel events into. Pass a * `posthog-js` instance directly (it satisfies the shape), or any object with * a matching `capture`. Omit and every event no-ops. The event names + props * the library emits are listed in `BILLING_EVENTS`. Every event also carries * `workspace_billing_version`, `workspace_plan` and `workspace_is_paid` when known. */ analytics?: BillingAnalyticsClient; /** Override the human label shown for a plan feature key (e.g. bot_count) */ featureLabels?: Record string>; /** * Workspace billing version (from the generic client's `getWorkspace().billingVersion`). * Pre-Smaug versions (v1-v3) make the dialogs render a "manage billing in * Dashboard" gate instead of the self-serve flow; v4 (Smaug) and later render * the self-serve flow. Omit if the host app gates on the version itself. */ billingVersion?: string; /** * Workspace id. Used to namespace the query cache so one workspace's billing * data never leaks into another's, and to scope persisted cache (see `persist`). * Strongly recommended when a host can switch workspaces. Defaults to 'default'. */ workspaceId?: string; /** * Persist the billing cache to localStorage so it survives reloads (instant * render, then a background refresh). On by default. Only the current * workspace's scope is stored, keyed by `workspaceId`. Set false to opt out. */ persist?: boolean; /** Where the gate sends the user, e.g. https://app.botpress.cloud/workspaces/{id}/billing */ manageBillingUrl?: string; /** * Fired after any billing change the library commits (subscribe, plan change, * add-on update). The library already refreshes its own queries; use this to * refresh billing UI the host renders OUTSIDE this provider (e.g. a plan badge * elsewhere in the app). The argument names what changed. */ onBillingChange?: (event: BillingChangeEvent) => void; /** * How often (ms) to poll billing data (subscription, usage, …) in the background. * Defaults to 30_000. Set to 0 (or any value ≤ 0) to disable background refresh. */ refreshInterval?: number; children: ReactNode; }; export declare type BillingTheme = 'light' | 'dark' | 'system'; export declare type BillingToast = { type: 'success' | 'error'; message: string; }; export declare const BoltIcon: ({ size, ...props }: IconProps) => JSX.Element; /** A per-bot usage row enriched with the bot's display name. */ export declare type BotUsageRow = { botId: string; name: string; value: number; }; export declare const Button: ({ variant, size, block, loading, className, disabled, children, type, ...props }: ButtonProps) => JSX.Element; export declare type ButtonProps = ButtonHTMLAttributes & { variant?: 'primary' | 'accent' | 'outline' | 'ghost'; size?: 'sm' | 'md' | 'lg'; block?: boolean; loading?: boolean; children?: ReactNode; }; export declare const CalendarIcon: ({ size, ...props }: IconProps) => JSX.Element; /** Answers from the cancellation survey shown before a downgrade. */ export declare type CancellationFeedback = { reason: CancellationReason; comment?: string; /** Plan being left. */ previousPlanId: string; /** Plan being downgraded to. */ planId: string; }; /** Two-step downgrade flow: what the user loses, then why they're leaving. */ export declare const CancellationSurveyDialog: ({ open, onOpenChange, planId, onConfirm, loading, planFeatures, }: CancellationSurveyDialogProps) => JSX.Element; export declare type CancellationSurveyDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; /** Plan the user is downgrading to. */ planId: string; onConfirm: (feedback: CancellationFeedback) => void; loading?: boolean; planFeatures?: Partial>; }; /** Saved-card brand mark. */ export declare const CardBrandBadge: ({ brand }: { brand: string; }) => JSX.Element; export declare const CardIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const ChartIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const CheckIcon: ({ size, ...props }: IconProps) => JSX.Element; /** * "Configure your plan" — checkout (plan interval, payment method via Stripe * PaymentElement, billing address, business VAT, proration preview + subscribe). * * The whole body mounts inside one tree so PaymentElement, AddressElement and * the subscribe button share the same Stripe context. The SetupIntent itself is only * requested from CheckoutBody at Subscribe time, not eagerly on open. */ export declare const CheckoutDialog: ({ open, onOpenChange, planId, interval, onBack, onSuccess }: CheckoutDialogProps) => JSX.Element | null; export declare type CheckoutDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; planId: string; /** Initial billing interval — the user can still switch inside the dialog */ interval: SelfServeBillingInterval; /** Back to the plan picker (renders the ‹ chevron when provided) */ onBack?: () => void; onSuccess?: () => void; }; export declare const ChevronDownIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const ChevronLeftIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const ChevronRightIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const CloseIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare function cn(...inputs: ClassValue[]): string; /** * Per-pack conversations pricing for a plan, e.g. { packSize: 100, amount: 65 } * → "+$65 per 100 conversations". Returns null when the plan has no overage add-on * (e.g. Free) or the add-on isn't priced for it. */ export declare function conversationPackPrice(addons: Addon[] | undefined, plan: Plan, interval: BillingInterval): { packSize: number; amount: number; currency: string; } | null; /** The add-on that sells extra conversations (keyed by its conversation_sessions increment). */ export declare function conversationsAddon(addons: Addon[] | undefined): Addon | null; /** Currency code → its symbol ("usd" → "$", "eur" → "€"); falls back to the uppercased code. */ export declare function currencySymbol(currency: string): string; export declare type Customer = Awaited>; /** * Human labels for Smaug plan feature keys. Overridable per-key via the * BillingProvider `featureLabels` prop. */ export declare const DEFAULT_FEATURE_LABELS: Record string>; /** * Curated marketing feature lists per plan kind — what the pricing table says, * mirroring Desk's billing-features. Quota numbers stay out of this list; the * conversations volume is rendered as the card's headline metric instead. * Override per-app via UpgradePlanDialog's `planFeatures` prop. */ export declare const DEFAULT_PLAN_FEATURES: Record; export declare const Dialog: ({ open, onOpenChange, size, children, className, showClose, ...aria }: DialogProps) => ReactPortal | null; export declare type DialogProps = { open: boolean; onOpenChange: (open: boolean) => void; /** sm = confirm, md = form, xl = full checkout / plan picker */ size?: 'sm' | 'md' | 'xl'; 'aria-label': string; children: ReactNode; className?: string; showClose?: boolean; }; export declare const DownloadIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const ENTERPRISE_CONTACT_URL = "https://botpress.com/contact-us/managed-plan"; export declare type Entitlement = { key: string; label: string; unit: 'count' | 'bytes'; /** Plan base allowance. */ base: number; /** Extra granted by active add-ons (Σ quantity × increment). */ added: number; /** base + added. */ total: number; }; export declare const ExternalLinkIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare function featureLabel(key: string, quantity: number, overrides?: Record string>): string; /** Human-readable bytes — "10 GB", "1.5 GB", "500 MB". */ export declare function formatBytes(bytes: number): string; export declare function formatCurrency(amount: number, currency?: string, decimal?: number, locale?: string): string; export declare function formatDate(iso: string, locale?: string): string; export declare function formatDateTime(iso: string, locale?: string): string; export declare function formatQuantity(n: number, locale?: string): string; export declare function formatUsage(value: number, unit: UsageUnit): string; export declare function getCardElementStyle(isDark: boolean): StripeCardElementOptions['style']; export declare function getStripeAppearance(isDark: boolean): Appearance; export declare function getStripePromise(publishableKey: string): Promise; export declare const GlobeIcon: ({ size, ...props }: IconProps) => JSX.Element; /** * Pick a feature glyph from its marketing label (ChatGPT-style top-feature icons). * Keyword-matched, with a generic sparkle fallback so every line still gets an icon. */ export declare function iconForFeature(label: string): (props: IconProps) => ReactElement; declare type IconProps = SVGProps & { size?: number; }; export declare const InboxIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const InfinityIcon: ({ size, ...props }: IconProps) => JSX.Element; /** * A dotted-underlined term that reveals an explanatory tooltip on hover or * keyboard focus. CSS-only positioning (centered above the term), so it carries * no JS/positioning dependency. */ export declare const InfoTooltip: ({ label, children }: InfoTooltipProps) => JSX.Element; export declare type InfoTooltipProps = { /** The term to annotate — gets a dotted underline + help cursor. */ label: ReactNode; /** Tooltip body shown on hover/focus. */ children: ReactNode; }; /** Floating-label input matching Stripe Elements' field look (grey fill, label inside). */ export declare const Input: ({ label, invalid, className, id, ...props }: InputProps) => JSX.Element; export declare type InputProps = InputHTMLAttributes & { label?: string; invalid?: boolean; }; export declare type Invoice = Awaited>['invoices'][number]; /** * Read-only billing history. Lists invoices newest-first with status, amount, * period, and a PDF download when Stripe provides one. */ export declare const InvoicesDialog: ({ open, onOpenChange }: InvoicesDialogProps) => JSX.Element | null; export declare type InvoicesDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; }; /** v4 (Smaug) and later (e.g. v5) are all self-serve — only v1-v3 are legacy. */ export declare function isLegacyBillingVersion(version: string): boolean; export declare const LayersIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare type LimitPreviewRow = { key: string; label: string; unit: 'count' | 'bytes'; now: number; next: number; }; export declare const LockIcon: ({ size, ...props }: IconProps) => JSX.Element; /** * Add-on management for the CURRENT subscription (Desk's manage-subscription * parity): quantities seeded from the live subscription (scheduled `next` * first), totals computed client-side, committed as absolute quantities via * setAddons — 0 removes an add-on. No plan change involved. */ export declare const ManageAddonsDialog: ({ open, onOpenChange, onSuccess, onUpgrade }: ManageAddonsDialogProps) => JSX.Element | null; export declare type ManageAddonsDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; /** Called when the user clicks "Upgrade plan" from the add-ons-unavailable state. */ onUpgrade?: () => void; }; export declare const MessageIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const MinusIcon: ({ size, ...props }: IconProps) => JSX.Element; /** Smaug reports ai_spend in nano-dollars (1e9 nano = $1) — same as the dashboard. */ export declare const NANO_DOLLARS_PER_DOLLAR = 1000000000; /** * Shown instead of the self-serve flow when the workspace isn't on billing v4 * (Smaug). Legacy versions (v1–v3) are managed in the Botpress Dashboard. */ export declare const OutdatedBillingGate: () => JSX.Element; /** * Free-plan upgrade modal — the proactive nudge shown when a Free workspace is * about to run out of its one-time conversation allowance. Frames the upgrade * (monthly allowance + packs + more channels) and offers the two self-serve * paid tiers (Plus / Team) with the same plan-card language as the pricing * table. Mount it once near the app root. * * Two modes: * - **controlled** — pass `open` / `onOpenChange` and drive it yourself. * - **auto** (omit `open`) — it opens itself when the workspace is on Free and * ≥75% through its conversations, at most once per day per workspace * (dismissed via localStorage, same as the usage banner). Returns the next day. */ export declare const OutgrowFreeDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, interval, planFeatures, featureDescriptions, period, }: OutgrowFreeDialogProps) => JSX.Element | null; export declare type OutgrowFreeDialogProps = { /** * Controlled visibility. Omit to let the dialog manage itself in `auto` mode: * it opens on its own when the workspace is on the Free plan and has used * ≥75% of its conversation allowance — at most once per day per workspace. */ open?: boolean; /** Required in controlled mode; also called when the dialog closes in auto mode. */ onOpenChange?: (open: boolean) => void; /** Called when the user picks a plan — open your CheckoutDialog with these values. */ onSelectPlan: (planId: string, interval: SelfServeBillingInterval) => void; /** Plan kind (or exact id) to mark Recommended. Default 'team'. */ recommendedPlanId?: string; /** Billing interval the prices are shown at. Default 'year' (annual). */ interval?: SelfServeBillingInterval; /** Per-kind marketing feature strings; defaults to DEFAULT_PLAN_FEATURES. */ planFeatures?: Partial>; /** Feature label → tooltip description; merged over DEFAULT_FEATURE_DESCRIPTIONS. */ featureDescriptions?: Record; /** Period (any datetime in the billing month) to evaluate usage; defaults to current month. */ period?: string; }; export declare const PaintIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare type PayInvoiceResult = Awaited>; export declare type PaymentMethod = NonNullable>['paymentMethod']>; export declare type PaymentMethodCard = NonNullable; /** * Update the saved card and/or billing address. The card form and the address form each mount * in their own tree, so neither blocks the other. The SetupIntent is created at save * time (deferred setup mode); the card is confirmed via confirmSetup, then persisted. The address * is saved independently — matching Desk's separation. */ export declare const PaymentMethodDialog: ({ open, onOpenChange, onSuccess }: PaymentMethodDialogProps) => JSX.Element | null; export declare type PaymentMethodDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; }; /** A plan/addon change awaiting payment confirmation. */ export declare type PendingUpgrade = NonNullable; /** * Full-width alert shown when the subscription has a plan/add-on change awaiting * payment confirmation (`subscription.pendingUpgrade`). Clicking it opens * `PendingUpgradeDialog` (or `onManage`, when the host wants to own that flow). * Renders nothing without a pending upgrade — safe to mount unconditionally. */ export declare const PendingUpgradeBanner: ({ onManage, className }: PendingUpgradeBannerProps) => JSX.Element | null; export declare type PendingUpgradeBannerProps = { /** Opens a host-owned pending-upgrade view instead of the library's own dialog. */ onManage?: () => void; className?: string; }; /** Standalone dialog around `PendingUpgradeContent` — opened from `PendingUpgradeBanner`. */ export declare const PendingUpgradeDialog: ({ open, onOpenChange, onSuccess }: PendingUpgradeDialogProps) => JSX.Element | null; export declare type PendingUpgradeDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; }; export declare type Plan = Awaited>[number]; /** Maps an English feature ID to its i18n label and tooltip description keys. */ export declare const PLAN_FEATURE_KEYS: { 'AI usage included': { label: "planFeatureAiUsageIncluded"; desc: "planFeatureDescAiUsageIncluded"; }; '3 seats': { label: "planFeature3Seats"; desc: "planFeatureDesc3Seats"; }; '3 AI agents': { label: "planFeature3AiAgents"; desc: "planFeatureDesc3AiAgents"; }; 'Botpress Desk': { label: "planFeatureBotpressDesk"; desc: "planFeatureDescBotpressDesk"; }; 'Botpress Studio + ADK': { label: "planFeatureBotpressStudioAdk"; desc: "planFeatureDescBotpressStudioAdk"; }; 'Botpress Viber': { label: "planFeatureBotpressViber"; desc: "planFeatureDescBotpressViber"; }; 'Help center': { label: "planFeatureHelpCenter"; desc: "planFeatureDescHelpCenter"; }; '1K table rows': { label: "planFeature1kTableRows"; desc: "planFeatureDesc1kTableRows"; }; '100K table rows': { label: "planFeature100kTableRows"; desc: "planFeatureDesc100kTableRows"; }; '500K table rows': { label: "planFeature500kTableRows"; desc: "planFeatureDesc500kTableRows"; }; '100MB file storage': { label: "planFeature100mbFileStorage"; desc: "planFeatureDesc100mbFileStorage"; }; '10GB file storage': { label: "planFeature10gbFileStorage"; desc: "planFeatureDesc10gbFileStorage"; }; '50GB file storage': { label: "planFeature50gbFileStorage"; desc: "planFeatureDesc50gbFileStorage"; }; '100MB vector DB storage': { label: "planFeature100mbVectorDb"; desc: "planFeatureDesc100mbVectorDb"; }; '1GB vector DB storage': { label: "planFeature1gbVectorDb"; desc: "planFeatureDesc1gbVectorDb"; }; '5GB vector DB storage': { label: "planFeature5gbVectorDb"; desc: "planFeatureDesc5gbVectorDb"; }; 'Unlimited AI agents': { label: "planFeatureUnlimitedAiAgents"; desc: "planFeatureDescUnlimitedAiAgents"; }; 'WhatsApp channel': { label: "planFeatureWhatsappChannel"; desc: "planFeatureDescWhatsappChannel"; }; 'Help Center custom domain': { label: "planFeatureHelpCenterCustomDomain"; desc: "planFeatureDescHelpCenterCustomDomain"; }; 'Whitelabel webchat': { label: "planFeatureWhitelabelWebchat"; desc: "planFeatureDescWhitelabelWebchat"; }; 'Technical support via live chat': { label: "planFeatureTechnicalSupportLiveChat"; desc: "planFeatureDescTechnicalSupportLiveChat"; }; 'Unlimited seats': { label: "planFeatureUnlimitedSeats"; desc: "planFeatureDescUnlimitedSeats"; }; 'Teams, routing & RBAC': { label: "planFeatureTeamsRoutingRbac"; desc: "planFeatureDescTeamsRoutingRbac"; }; 'Team-level analytics': { label: "planFeatureTeamLevelAnalytics"; desc: "planFeatureDescTeamLevelAnalytics"; }; 'Voice channel': { label: "planFeatureVoiceChannel"; desc: "planFeatureDescVoiceChannel"; }; 'Dedicated support': { label: "planFeatureDedicatedSupport"; desc: "planFeatureDescDedicatedSupport"; }; 'SLA & security review': { label: "planFeatureSlaSecurity"; desc: "planFeatureDescSlaSecurity"; }; 'Custom storage': { label: "planFeatureCustomStorage"; desc: "planFeatureDescCustomStorage"; }; }; export declare const PLAN_ORDER: PlanKind[]; /** * Full-width current-plan hero with per-tier color identity (accent rail + name, * soft tinted surface). Surfaces the plan name, total monthly/annual cost * (plan + add-ons), conversation allowance, the billing cadence and when it * renews (paid, self-serve plans only), plus a manage CTA. On legacy billing * it deep-links to the Dashboard. */ export declare const PlanBanner: ({ onManage, className }: PlanBannerProps) => JSX.Element | null; export declare type PlanBannerProps = { /** Opens the plan picker / checkout. */ onManage: () => void; className?: string; }; /** "Plan - Plus" → "Plus" (Smaug prefixes plan names) */ export declare function planDisplayName(name: string): string; /** * Current total entitlements per resource = plan base + active add-on packs. * `quantities` maps add-on id → owned quantity (from the live subscription). * Returns one row per known resource the plan or its add-ons provide, so a * caller can render e.g. "250 + 300 conversations" (base + added). */ export declare function planEntitlements(plan: Plan | undefined, addons: Addon[] | undefined, quantities: Record): Entitlement[]; export declare type PlanFeatureId = keyof typeof PLAN_FEATURE_KEYS; /** * Canonical plan kinds. Smaug plan ids/names vary by environment, so plans are * classified by name — same heuristic as the dashboard's getPlanNameFromId. */ export declare type PlanKind = 'community' | 'plus' | 'team' | 'enterprise' | 'managed'; export declare function planKind(plan: Pick): PlanKind; /** * Clickable summary of the current plan — name, interval, price, conversation * allowance. Acts as a preview button that opens the plan-management flow. */ export declare const PlanSummaryCard: ({ onManage, className }: PlanSummaryCardProps) => JSX.Element | null; export declare type PlanSummaryCardProps = { /** Opens the plan picker / checkout. */ onManage: () => void; className?: string; }; /** * Ultra-compact plan + conversations-usage summary for a dropdown/menu. * Full-width (adapts to the menu), shows the plan name and a "N left" * conversations bar with its reset date. Hidden on legacy billing. */ export declare const PlanUsageWidget: ({ onManage, period, variant, showHealthyEnterprise, className, style, }: PlanUsageWidgetProps) => JSX.Element | null; export declare type PlanUsageWidgetProps = { /** Click handler — e.g. open the plan picker or navigate to billing. Renders a › affordance when set. */ onManage?: () => void; /** Period (any datetime in the billing month); defaults to current month. */ period?: string; /** * Surface treatment: * - 'card' (default) — its own filled, rounded surface. * - 'plain' — transparent, no padding; inherits the host container's surface * (e.g. to blend into a sidebar). The host owns the background. */ variant?: 'card' | 'plain'; /** Keep the compact summary visible for healthy Enterprise workspaces. */ showHealthyEnterprise?: boolean; className?: string; /** * Inline styles on the root. Handy for overriding the surface via the library's * CSS variables, e.g. `style={{ ['--bpb-bg-input']: 'transparent' }}`. */ style?: CSSProperties; }; export declare const PlusIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare type PreviewLineItem = SubscriptionPreview['costs']['immediate']['lineItems'][number]; export declare type Price = NonNullable; export declare const PuzzleIcon: ({ size, ...props }: IconProps) => JSX.Element; declare type QueryOptions = { enabled?: boolean; }; export declare const ReceiptIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare type RecurringCreditGrantInterval = Exclude; export declare const SegmentedControl: ({ options, value, onChange, className, ...aria }: SegmentedControlProps) => JSX.Element; export declare type SegmentedControlOption = { value: T; label: string; badge?: string; }; export declare type SegmentedControlProps = { options: SegmentedControlOption[]; value: T; onChange: (value: T) => void; 'aria-label': string; className?: string; }; export declare const Select: ({ label, className, children, ...props }: SelectProps) => JSX.Element; export declare type SelectProps = SelectHTMLAttributes & { label?: string; }; /** Intervals a user can self-serve into via setPlan. quarter/bi_annual are only set manually in Stripe. */ export declare type SelfServeBillingInterval = Extract; export declare type SetAutoRechargeSettingsInput = { settings: Record; }; declare type SetCustomerInput = { name?: string; address?: BillingAddress; taxIds?: TaxId[]; }; declare type SetSubscriptionInput = { planId: string; interval: SelfServeBillingInterval; addons?: Record; couponCode?: string; }; export declare const ShieldIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const Skeleton: ({ width, height, rounded, className }: SkeletonProps) => JSX.Element; export declare type SkeletonProps = { width?: number | string; height?: number | string; rounded?: boolean; className?: string; }; export declare const SparkleIcon: ({ size, ...props }: IconProps) => JSX.Element; export declare const Stepper: ({ value, onChange, min, max, step, className, ...aria }: StepperProps) => JSX.Element; export declare type StepperProps = { value: number; onChange: (value: number) => void; min?: number; max?: number; step?: number; 'aria-label': string; className?: string; }; export declare type Subscription = Awaited>; export declare type SubscriptionPreview = Awaited>; export declare type SubscriptionStatus = Subscription['plan']['current']['status']; export declare type SubscriptionUpdate = { plan: { planId: string; interval: BillingInterval; }; /** Addon id → desired quantity. 0 removes the addon. */ addons?: Record; couponCode?: string; }; export { SupportedLocale } export declare const Switch: ({ checked, onChange, disabled, className, ...aria }: SwitchProps) => JSX.Element; export declare type SwitchProps = { checked: boolean; onChange: (checked: boolean) => void; disabled?: boolean; 'aria-label': string; className?: string; }; export declare type TaxId = Customer['taxIds'][number]; export declare function toStripeLocale(locale: string): string; export declare const UpgradePlanDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, defaultInterval, excludePlanIds, planFeatures, featureDescriptions, }: UpgradePlanDialogProps) => JSX.Element | null; export declare type UpgradePlanDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; /** Called when the user picks an upgrade — open the CheckoutDialog with these values. */ onSelectPlan: (planId: string, interval: SelfServeBillingInterval) => void; /** Plan kind (or exact id) to mark as Recommended. Desk recommends `team`. */ recommendedPlanId?: string; defaultInterval?: SelfServeBillingInterval; /** Additional plan ids to hide. Enterprise + managed are always hidden. */ excludePlanIds?: string[]; /** Per-kind marketing feature strings; defaults to DEFAULT_PLAN_FEATURES (Desk copy). */ planFeatures?: Partial>; /** Feature label → tooltip description; merged over DEFAULT_FEATURE_DESCRIPTIONS. */ featureDescriptions?: Record; }; /** * The user-facing billing quotas surfaced in usage UI. getWorkspaceUsages also * returns internal counters (bot count, incoming messages, collaborator count, * saved/indexed file counts, …) that aren't billing concerns — keys not listed * here are ignored. Order is the display priority. */ export declare const USAGE_METRICS: { key: string; label: string; unit: UsageUnit; }[]; /** * A usage warning banner — visible only when a quota is past `threshold` (90% * by default), on billing v4. Renders nothing otherwise (and on legacy billing), * so it's safe to mount unconditionally on any page. */ export declare const UsageBanner: ({ position, threshold, onUpgrade, dismissible, cta, ctaLabel, period, className, }: UsageBannerProps) => JSX.Element | null; export declare type UsageBannerProps = { /** * Mount behavior: * - 'inline' (default) — sits in normal flow and pushes the page content down. * - 'sticky-top' — sticks to the top of the scroll container. * - 'fixed-top' / 'fixed-bottom' — pinned to the viewport (overlays content). */ position?: 'inline' | 'sticky-top' | 'fixed-top' | 'fixed-bottom'; /** Consumption fraction that triggers the banner (0–1). Default 0.9 (90%). */ threshold?: number; /** * Primary CTA handler. If omitted, the banner opens its own plan picker + * checkout so it works with zero host wiring. */ onUpgrade?: () => void; /** * Show a dismiss (×) button. Dismissing hides the banner (for that metric) for * the rest of the day via localStorage; it returns the next day or if a * different metric crosses the threshold. Default true. */ dismissible?: boolean; /** * Which built-in (localized) CTA to show: 'upgrade' (default) → "Upgrade plan", * for banners that open the upgrade flow; 'manage' → "Manage plan", for banners * that navigate to billing management. */ cta?: 'upgrade' | 'manage'; /** Raw CTA label override — takes precedence over `cta` and skips localization. */ ctaLabel?: string; /** Period (any datetime in the billing month) to evaluate; defaults to current month. */ period?: string; className?: string; }; /** A client that can serve per-bot usage (both optional methods present). */ export declare type UsageBreakdownClient = Required>; /** One { botId, value } row from a per-bot usage breakdown. */ export declare type UsageBreakdownEntry = Awaited>['data'][number]; /** * Read-only usage overview for the current billing month, grouped into * Conversations / Storage / AI usage. Data comes from getWorkspaceUsages — the * UI invents no numbers. A bare-minimum dashboard, not a deep analytics view. */ export declare const UsageDashboard: ({ period, showPeriodSelector, periodMonths, className, onIncreaseLimits, }: UsageDashboardProps) => JSX.Element; export declare type UsageDashboardProps = { /** Any datetime within the billing month to report; defaults to the current month. */ period?: string; /** Show a month dropdown to browse past billing periods. Default true. */ showPeriodSelector?: boolean; /** How many recent months the period selector offers (incl. current). Default 12. */ periodMonths?: number; className?: string; onIncreaseLimits?: () => void; }; export declare type UsageEntry = WorkspaceUsages[string]; export declare type UsageItem = { key: string; label: string; unit: UsageUnit; used: number; quota: number; remaining: number; resets: boolean; /** Consumed percentage, 0–100. */ pct: number; }; /** Resolve the user-facing usage metrics (with a real quota), highest-consumed first. */ export declare function usageItems(quotas: WorkspaceUsages | undefined): UsageItem[]; /** * Wraps any element with a usage popover — a themed card showing the plan, * reset date, and every user-facing quota with a mini bar. Reveals on * hover/focus after `delay`. Renders the children plainly on legacy billing * or when there's no usage to show (the popover just never opens). */ export declare const UsagePopover: ({ children, delay, placement, align, period, onUpgrade, block, className, }: UsagePopoverProps) => JSX.Element; export declare type UsagePopoverProps = { /** The trigger — hovering/focusing it reveals the usage popover. */ children: ReactNode; /** Delay in ms before the popover appears on hover/focus. Default 200. */ delay?: number; /** Where the card opens relative to the trigger. Default 'top'. */ placement?: 'top' | 'bottom'; /** Horizontal anchor relative to the trigger. Default 'center'; use 'start' near an edge. */ align?: 'start' | 'center' | 'end'; /** Period (any datetime in the billing month); defaults to current month. */ period?: string; /** * Upgrade handler. When set, the popover shows a "Need more room?" nudge with a * CTA on plans that can move up (e.g. Free). Wire it to your plan picker / * billing route — same target as the widget's `onManage`. */ onUpgrade?: () => void; /** Stretch the trigger to fill its container (e.g. a full-width sidebar widget). */ block?: boolean; className?: string; }; /** * A compact circular usage indicator — the ring reflects the MOST-consumed * metric across all quotas (conversations, AI spend, storage, …), colored by * tier (blue ≤75%, amber 75–90%, red 90%+). Hovering reveals a UsagePopover * listing every metric. Renders nothing on legacy billing / while loading. */ export declare const UsageRing: ({ size, thickness, showLabel, onClick, popoverDelay, popoverAlign, trackColor, period, className, ...aria }: UsageRingProps) => JSX.Element | null; export declare type UsageRingProps = { /** Diameter in px. Default 20. */ size?: number; /** Ring thickness in px. Default 3.5. */ thickness?: number; /** Show the highest used % beside the ring. Default false. */ showLabel?: boolean; /** Click handler (e.g. open usage / upgrade). */ onClick?: () => void; /** Delay in ms before the usage popover appears on hover/focus. Default 200. */ popoverDelay?: number; /** Horizontal anchor of the popover relative to the ring. Default 'center'; use 'start' near an edge. */ popoverAlign?: 'start' | 'center' | 'end'; /** Track color weight. Default 'light'; use 'dark' for more contrast on busy/colored surfaces. */ trackColor?: 'light' | 'dark'; /** Period (any datetime in the billing month); defaults to current month. */ period?: string; className?: string; 'aria-label'?: string; }; /** Consumption tier for a used % — drives the blue/amber/red coloring. */ export declare function usageTier(pct: number): 'normal' | 'warning' | 'critical'; export declare type UsageUnit = 'count' | 'bytes' | 'nano-usd'; export declare function useAddons(): UseQueryResult; /** Auto-recharge settings, keyed by feature (e.g. 'ai_spend'). */ export declare function useAutoRechargeSettings(options?: QueryOptions): UseQueryResult; export declare function useBilling(): BillingContextValue; /** Managed/enterprise locks — when planReadonly, plan changes go through sales. */ export declare function useBillingReadonly(options?: QueryOptions): UseQueryResult<{ planReadonly: boolean; addonsReadonly: boolean; }, Error>; /** Cancels a pending upgrade (the plan/add-on change and its unpaid invoice), reverting to the current subscription. */ export declare function useCancelPendingSubscriptionUpgrade(): UseMutationResult; export declare function useCreatePaymentMethodIntent(): UseMutationResult<{ clientSecret: string; }, Error, void>; export declare function useCustomer(options?: QueryOptions): UseQueryResult; /** Whether a payment needs attention: a pending plan/add-on upgrade or a failed auto-recharge. */ export declare function useHasPaymentFailure(options?: QueryOptions): boolean; /** Whether the subscription has a plan/add-on change awaiting payment confirmation. */ export declare function useHasPendingUpgrade(options?: QueryOptions): boolean; export declare function useInvoices(options?: QueryOptions): UseQueryResult<{ invoices: Invoice[]; meta: { nextToken?: string; }; }, Error>; /** Whether the caller's role (via `getWorkspaceMember`) has `workspace.manageBilling`. */ export declare function useIsAuthorized(options?: QueryOptions): UseQueryResult; /** Pays the invoice tied to a pending upgrade, confirming the plan/add-on change. */ export declare function usePayInvoice(): UseMutationResult; export declare function usePaymentMethod(options?: QueryOptions): UseQueryResult<{ paymentMethod: PaymentMethod | null; }, Error>; export declare function usePlans(): UseQueryResult; export declare const UsersIcon: ({ size, ...props }: IconProps) => JSX.Element; /** Persists the cancellation survey answers; no-op without BillingProvider's `workspaceId`. */ export declare function useSaveCancellationFeedback(): UseMutationResult; /** Absolute add-on quantities for the current subscription (0 removes an add-on). */ export declare function useSetAddons(): UseMutationResult; couponCode?: string; }>; export declare function useSetAutoRechargeSettings(): UseMutationResult; export declare function useSetCustomer(): UseMutationResult; export declare function useSetPaymentMethod(): UseMutationResult; /** Commits the plan and add-ons. A failed charge returns `pendingUpgrade` instead of throwing. */ export declare function useSetSubscription(): UseMutationResult; export declare function useSubscription(options?: QueryOptions): UseQueryResult; /** Proration preview — gate with `enabled` so it only runs while checkout is open. */ export declare function useSubscriptionPreview(update: SubscriptionUpdate, options?: QueryOptions): UseQueryResult; /** Whether the configured client can serve a per-bot usage breakdown. */ export declare function useSupportsUsageByBot(): boolean; /** * Per-feature usage vs. quota for a billing month (defaults to the current month). * Returns the `quotas` map keyed by feature (conversation_sessions, table_rows, …). */ export declare function useUsage(options?: QueryOptions & { period?: string; }): UseQueryResult; /** * Per-bot usage breakdown for a quota type (e.g. ai_spend), joined with bot names. * Returns null when the client doesn't expose the generic per-bot methods (the * billing client alone can't do this) — callers should hide the per-bot UI then. */ export declare function useUsageByBot(type: string, options?: QueryOptions & { period?: string; }): UseQueryResult; /** The caller's own workspace membership, as returned by `getWorkspaceMember`. */ export declare type WorkspaceMember = Awaited>; export declare type WorkspaceUsages = Awaited>['quotas']; export { }