/**
 * Per-file limit for the Carrier Dispatch "Create Trip" wizard (Nash,
 * 2026-10-01, decision W4: keep 1 MB per file — confirmed twice). The browser
 * refuses a larger file before anything is sent; the server action checks the
 * same number. The Server Action body cap (next.config.ts) is sized so one
 * rate confirmation plus several permits of this size fit in one submit.
 */
export const WIZARD_FILE_LIMIT_BYTES = 1 * 1024 * 1024
export const WIZARD_FILE_LIMIT_LABEL = '1 MB'

export function fileWithinWizardLimit(size: number): boolean {
  return size > 0 && size <= WIZARD_FILE_LIMIT_BYTES
}

/** "scan.pdf is 2.4 MB — files must be 1 MB or smaller." */
export function fileTooLargeMessage(name: string, size: number): string {
  const mb = size / (1024 * 1024)
  const shown = mb >= 10 ? mb.toFixed(0) : mb.toFixed(1)
  return `${name} is ${shown} MB — files must be ${WIZARD_FILE_LIMIT_LABEL} or smaller.`
}
