{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TGetCurrencyFormattedArgs = Parameters<typeof getCurrencyFormatted>;\n\nexport type TGetCurrencyFormattedReturn = ReturnType<typeof getCurrencyFormatted>;\n\n/**\n * Formats a number as currency using `Intl.NumberFormat`.\n * @param {number} num Source number\n * @param {string} currency ISO 4217 currency code\n * @param {Intl.LocalesArgument} [locales] Locale or locales\n * @param {Omit<Intl.NumberFormatOptions,\"style\"|\"currency\">} [options={}] Number format options\n * @returns {string} Localized currency value\n * @throws {TypeError} getCurrencyFormatted: num must be a valid number\n * @throws {TypeError} getCurrencyFormatted: currency must be a non-empty string\n * @example\n * getCurrencyFormatted(12.5, \"USD\", \"en-US\"); // \"$12.50\"\n * @example\n * // Format a product price for a Russian storefront\n * const priceLabel = getCurrencyFormatted(product.price, \"RUB\", \"ru-RU\", {\n *   maximumFractionDigits: 0,\n * });\n */\nexport const getCurrencyFormatted = (\n  num: number,\n  currency: string,\n  locales?: Intl.LocalesArgument,\n  options: Omit<Intl.NumberFormatOptions, \"style\" | \"currency\"> = {}\n): string => {\n  if (typeof num !== \"number\" || Number.isNaN(num)) {\n    throw new TypeError(\"getCurrencyFormatted: num must be a valid number\");\n  }\n  if (typeof currency !== \"string\" || currency.trim().length === 0) {\n    throw new TypeError(\"getCurrencyFormatted: currency must be a non-empty string\");\n  }\n  if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n    throw new TypeError(\"getCurrencyFormatted: options must be a plain object\");\n  }\n  return new Intl.NumberFormat(locales, {\n    ...options,\n    style: \"currency\",\n    currency,\n  }).format(num);\n};\n"],"names":["getCurrencyFormatted","num","currency","locales","options","Number","isNaN","TypeError","trim","length","Array","isArray","Intl","NumberFormat","style","format"],"mappings":"AAqBO,MAAMA,qBAAuB,CAClCC,IACAC,SACAC,QACAC,QAAgE,CAAA,KAEhE,UAAWH,MAAQ,UAAYI,OAAOC,MAAML,KAC1C,MAAM,IAAIM,UAAU,oDAEtB,UAAWL,WAAa,UAAYA,SAASM,OAAOC,SAAW,EAC7D,MAAM,IAAIF,UAAU,6DAEtB,IAAKH,gBAAkBA,UAAY,UAAYM,MAAMC,QAAQP,SAC3D,MAAM,IAAIG,UAAU,wDAEtB,OAAO,IAAIK,KAAKC,aAAaV,QAAS,IACjCC,QACHU,MAAO,WACPZ,oBACCa,OAAOd"}