/** Format a numeric price for display in Iranian Toman (IRT). */
export function formatIrtPrice(value: number | null | undefined): string {
  if (value === null || value === undefined) return '—'
  return `${Math.round(value).toLocaleString('en-US')} IRT`
}

/** Format raw digits into comma-separated groups while typing. */
export function formatIrtInput(raw: string): string {
  const digits = raw.replace(/\D/g, '')
  if (!digits) return ''
  return Number(digits).toLocaleString('en-US')
}

/** Parse a formatted IRT input string back to a number. */
export function parseIrtInput(formatted: string): number | null {
  const digits = formatted.replace(/\D/g, '')
  if (!digits) return null
  return Number(digits)
}
