import type { FiatStepResponse, Surface } from '@fun-xyz/fiat-contract/types'; import type { SubmitTransition, SurfaceTransition } from './selectTransitions'; /** The tap sends a request this client builds. */ export interface SubmitControl { mode: 'SUBMIT'; cta: SubmitTransition; } /** A provider component is the control; the app draws no button of its own. */ export interface SurfaceControl { mode: 'CLIENT_SURFACE'; surface: Surface; transition: SurfaceTransition; } /** * The tap enters a step the response already carries. Banxa answers the quote * endpoint with a KYC round rather than a price, so there is a screen to reach * and nothing to send to reach it. */ export interface EnterControl { mode: 'ENTER'; stepResponse: FiatStepResponse; } /** * How the control is operated — named with the contract's own transition * modes rather than a client-side render word. Held apart from `kind` so that * intent and presentation vary independently: two intents may legitimately * draw the same way, and one intent may draw two ways depending on the rail. */ export type EntryControl = SubmitControl | SurfaceControl | EnterControl; /** * What the amount screen's primary control *means*. Intent only — how it is * drawn comes from `EntryControl` and the predicates below, so a screen never * has to infer presentation from the category. * * The legal set for a QUOTE state is enumerated by the contract itself, in * `TRANSITION_TABLE['QUOTE'].allowedTransitions` of `@fun-xyz/fiat-contract`, * with the condition each is emitted under. Read that for the authority; this * union only says what the client does about it. */ export type EntryCta = /** * This tap pays. It creates the order, authorises the method that will * create one, or hands off to the provider sheet that does both — three * rails, one intent. */ { kind: 'PAY'; control: EntryControl; } /** * The user is not established yet: a provider session (`POST /fiat/session`) * or a Fun identity (`POST /fiat/auth`). Nothing is wrong and nothing is * being verified — the flow simply has not met them. */ | { kind: 'AUTHENTICATE'; control: SubmitControl; } /** * A step this build does not know. It still renders and still submits — the * contract's `labelFallback` rule is what lets a new step ship without a * client release — but landing here means the backend moved ahead of us, * which is worth saying out loud rather than absorbing silently. */ | { kind: 'UNRECOGNIZED'; control: SubmitControl; } /** * The quote endpoint answered with a later step instead of a price — an * identity round, most often. The deposit is held on a screen past this one, * so the tap hands the envelope to the flow. */ | { kind: 'CONTINUE'; control: EnterControl; } /** Nothing to offer yet, or the flow has moved past this screen. */ | { kind: 'PENDING'; }; /** Whether the amount screen still owns the flow, or a later screen has it. */ export declare function isEntryOwnedState(stepResponse: FiatStepResponse | undefined): boolean; /** Whether there is any control to draw at all. */ export declare function shouldRenderCta(entry: EntryCta): boolean; /** * The provider-drawn control, or `undefined` when the app draws its own. * Returned rather than asserted so a caller can reach the surface without * narrowing a union it did not build. */ export declare function surfaceControl(entry: EntryCta): SurfaceControl | undefined; /** * Whether a provider component draws the control, in which case the app * renders no button of its own and the provider owns the tap. */ export declare function rendersOwnControl(entry: EntryCta): boolean; /** * The step a tap should hand to the flow, or `undefined` when the tap sends a * request instead. */ export declare function enteredStep(entry: EntryCta): FiatStepResponse | undefined; /** * The transition a tap should send, or `undefined` when the app has nothing * to send — no control at all, or one the provider operates itself. */ export declare function submittableTransition(entry: EntryCta): SubmitTransition | undefined; /** * Precedence is surface, then pay, then everything else — a running surface * outranks any button, and the paying CTA is found by endpoint wherever it * sits in the array. Position is never the discriminant. * * The remainder is split rather than pooled: `AUTHENTICATE` is the set the * contract enumerates, `UNRECOGNIZED` is anything else. Both draw the same * server-supplied label, so the split buys no rendering. What it buys is * telling a user who has not signed in apart from a backend that has moved * ahead of this build. */ export declare function selectEntryCta(stepResponse: FiatStepResponse | undefined): EntryCta; //# sourceMappingURL=entryCta.d.ts.map