import type { BillingCheckoutStatus } from "@opengeni/sdk"; import type { OpenGeniBrowserClient } from "@opengeni/sdk/browser"; import type { PageHost } from "./navigation.js"; export type CreditCheckoutClient = Pick; /** Stripe replaces this placeholder in a success URL with the session id. */ export declare const CHECKOUT_SESSION_PLACEHOLDER = "{CHECKOUT_SESSION_ID}"; /** Organization billing, where a same-tab checkout returns and celebrates. */ export declare function billingCheckoutReturnUrl(origin: string, workspaceId: string, outcome: "success" | "cancelled"): string; /** The small static page a checkout tab lands on; it asks the person to go back. */ export declare function checkoutTabReturnUrl(origin: string, outcome: "success" | "cancelled"): string; /** * Query keys of a return to the page checkout started from. Organization * billing reads `checkoutSession` only beside its own `checkout=success`, so * it never handles this return a second time. */ export declare const CHECKOUT_RETURN_QUERY: { readonly outcome: "checkoutReturn"; readonly account: "checkoutAccount"; readonly session: "checkoutSession"; }; /** * The page checkout started from (a chat or the new-chat page), so paying * lands back where the person was, with their draft, instead of in settings. * The page confirms the credits from these query keys and removes them. */ export declare function checkoutPageReturnUrl(href: string, accountId: string, outcome: "success" | "cancelled"): string; export type CheckoutPageReturn = { outcome: "success"; accountId: string; checkoutSessionId: string; } | { outcome: "cancelled"; }; /** The checkout return in a page query, or null when there is none or it is malformed. */ export declare function readCheckoutPageReturn(query: URLSearchParams): CheckoutPageReturn | null; /** * Open the checkout tab inside the click handler, before any await, so the * browser allows it. It shows a short message until checkout loads. Null when * the browser blocks new tabs. */ export declare function openCheckoutTab(page: Pick): Window | null; export type StartedCreditCheckout = { checkoutSessionId: string; url: string; /** False when checkout took over this page (the browser blocked the tab). */ inNewTab: boolean; }; /** * Start a checkout for credits: a fixed amount, a promotion code, or both. A * fixed-amount USD code sets the amount by itself. `tab` comes from * `openCheckoutTab()` in the same click; without one, this page navigates. */ export declare function startCreditCheckout(client: CreditCheckoutClient, input: { accountId: string; workspaceId: string; amountUsd?: number | undefined; promotionCode?: string | undefined; tab: Window | null; signal?: AbortSignal | undefined; /** The console origin the checkout returns to. */ origin: string; /** Leaves for checkout when no tab was opened. */ navigate: (url: string) => void; /** `navigate` opens checkout beside this page (an embed) instead of leaving it. */ navigateOpensBeside?: boolean | undefined; }): Promise; /** * Poll one checkout until its credits are granted or it expires. Resolves with * the final status; rejects only when aborted. Transient read failures keep * polling. */ export declare function waitForCheckoutCredits(client: Pick, input: { accountId: string; checkoutSessionId: string; signal: AbortSignal; intervalMs?: number | undefined; onStatus?: ((status: BillingCheckoutStatus) => void) | undefined; }): Promise;