// Pure price-mode logic (no DOM), imported by both the element and its test. /** Which of the two prices the tier radios should carry. */ export type PriceMode = 'founder' | 'list'; /** The two prices a tier card publishes as data attributes. */ export interface TierPrices { std: string | null; founder: string | null; } /** * The price a tier should carry in the given mode. * * Returns `null` when the card does not publish the price that mode needs, so * the caller leaves the DOM alone rather than writing `undefined` into a form * value the server computes on. That happens on a page rendered with the * founder window shut, where there is no toggle and nothing should move. */ export function priceFor(prices: TierPrices, mode: PriceMode): string | null { const chosen = mode === 'founder' ? prices.founder : prices.std; return chosen === null || chosen === '' ? null : chosen; } /** * Render a monthly price the way the tier card writes it. * * Kept here rather than inlined so the test pins the format: the server * renders the first one, the toggle renders every one after, and the two must * agree or the price visibly reformats the first time somebody flips it. */ export function formatMonthly(price: string): string { return `$${price}/mo`; }