/** * @license * Copyright 2026 Aglyn LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type Theme } from '@mui/material/styles'; /** * Stripe Elements' `appearance`, built from the RESOLVED MUI theme. * * The card form is Stripe's iframe sitting in the middle of our own card, * between our own `TextField`s. If its fields are a different height, radius, * font or border weight, the seam is the thing the customer notices — which * is the whole objection inline Elements exist to answer. So every value here * is read off the theme, and none is written down: a hardcoded palette copy * stops matching the first time the scheme moves, and nothing would fail. * * ## Why CSS variables have to be resolved first * * The console's theme is served through MUI's `cssVariables` surfaces, so * `theme.palette.primary.main` can come back as the STRING * `'var(--mui-palette-primary-main)'` rather than a color. That string is * fine in our own DOM and useless to Stripe: Elements paints inside a * cross-origin iframe on Stripe's domain, where our custom properties do not * exist. The variable resolves to nothing, and the field renders with * Stripe's default — silently, on a surface nobody re-checks after a theme * change. * * `resolveCssVar` is therefore not a nicety. It reads the computed value off * the document once, so what crosses the iframe boundary is always a literal * color. */ /** Reads a custom property's computed value from the document root. */ export type CssVarResolver = (name: string) => string; /** * Turn whatever the theme handed us into a literal a cross-origin iframe can * paint with. * * Handles the nested form MUI emits — `var(--a, var(--b, #fff))` — by * resolving outside-in and falling back to the declared default, which is * what the browser itself would do. */ export declare function resolveThemeColor(value: unknown, resolveCssVar?: CssVarResolver, depth?: number): string; /** The subset of Stripe's appearance object this builds. */ export interface StripeAppearance { theme: 'stripe' | 'night'; variables: Record; rules: Record>; } /** * Build the appearance for one resolved MUI theme. * * `theme: 'night'` for a dark scheme rather than only recoloring: Stripe's * base theme decides things the variables do not reach — icon artwork, the * dropdown surface, autofill styling — and a light base wearing dark colors * shows through on exactly those. * * ## The scheme comes off the resolved surface * * On a `cssVariables` theme, `theme.palette` is the DEFAULT scheme whichever * one is showing: `useTheme()` hands the light palette to a page painted dark, * and the fields came out white on a dark panel with their labels unreadable. * `theme.vars.palette` holds the variables that do change, so those are what * gets resolved, and the base theme is read from the surface they resolve to. */ export declare function stripeAppearanceFromTheme(theme: Theme, resolveCssVar?: CssVarResolver): StripeAppearance;