import type { Outcome } from '../types/outcome.type'; import { type FileFormat, type FileVersion } from '../utils/piperLiteFiles.util'; import type { FileWire } from '../types/file.type'; /** The slot of the card's own «Descargar»; version rows use `rowSlot`. */ export declare const CARD_SLOT = "card"; export declare const rowSlot: (version: string) => string; export type FileModel = { /** * `available`: the listing answered. `unavailable`: the route does not exist * yet (R11), so the card downloads `latest` and shows no versions. * `forbidden`: the listing refused the user. * `degraded`: the listing failed (5xx or network): the card still downloads * `latest` and offers to load the list again (Daniel, 2026-11-16, B5). */ listing: 'available' | 'unavailable' | 'forbidden' | 'degraded'; keep: number | null; stale: boolean; /** The newest ready version with at least one available file. */ latest: FileVersion | null; /** Every other version, newest first (generating and failed ones included). */ previous: FileVersion[]; /** The newest version is still being generated. */ generating: boolean; }; export type DownloadState = { status: 'signing'; } | { status: 'forbidden'; } | { status: 'notFound'; } | { status: 'failed'; version: string; format: FileFormat; }; export type UseFileResult = { outcome: Outcome; /** Loads the listing again after a retryable error. */ retry: () => void; /** A retry is in flight: the previous listing stays on screen meanwhile. */ reloading: boolean; /** One state per slot; a slot with no entry is idle. */ downloads: Readonly>; /** Signs `version` and opens the URL; ignored while that slot is in flight. */ download: (slot: string, version: string, format: FileFormat) => void; /** Repeats a failed download with the version and format it had. */ retryDownload: (slot: string) => void; }; /** * Behaviour of `v2.file`: reads the versions listing (a 404 or 405 is a * latest-only card, a failing one a degraded card, never an error) and signs a version on click. One sign in * flight per slot, everything aborted on unmount. The signed URL is a local of * the click handler: it is opened once and is never kept in state or logged. */ export declare const useFile: (wire: FileWire, userFlow: string) => UseFileResult;