/** * Helpers for interpreting ParkSmarter parking estimates. * * Pulled out as pure functions so the "is this a free window?" decision is * testable without the app, the network, or React Native. The BigBrainParking * app's single-estimate fallback uses these to avoid showing a bogus "$0.00" * purchase ladder during free windows. */ /** * A free window: the single estimate reports no purchasable time. Live captures * show free zones return `MaxTime: 0` (and `$0.00`), while paid zones return a * positive MaxTime. Anything <= 0 (or non-numeric) counts as free. */ export function isFreeEstimate(probe: { MaxTime?: number | string | null } | null | undefined): boolean { return (Number(probe?.MaxTime) || 0) <= 0; } /** Every rung of a built ladder is $0.00 — effectively a free window too. */ export function ladderAllFree( rungs: ReadonlyArray<{ ParkingCost?: number | string | null }>, ): boolean { return rungs.length > 0 && rungs.every((r) => (Number(r?.ParkingCost) || 0) === 0); }