"use client";
import { jsx } from "react/jsx-runtime";
import * as React from "react";
import { cn } from "@open-mercato/shared/lib/utils";
function formatPriceWithCurrency(amount, currency, fallback = "\u2014") {
  if (amount === null || amount === void 0) return fallback;
  const parsed = typeof amount === "string" ? Number(amount) : amount;
  if (Number.isNaN(parsed)) return fallback;
  if (currency) {
    try {
      return new Intl.NumberFormat(void 0, {
        style: "currency",
        currency,
        minimumFractionDigits: 2,
        maximumFractionDigits: 2
      }).format(parsed);
    } catch {
    }
  }
  return parsed.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
function PriceWithCurrency({ amount, currency, fallback = "\u2014", className }) {
  const label = React.useMemo(
    () => formatPriceWithCurrency(amount, currency, fallback),
    [amount, currency, fallback]
  );
  return /* @__PURE__ */ jsx("span", { className: cn("font-mono text-sm text-foreground", className), children: label });
}
export {
  PriceWithCurrency,
  formatPriceWithCurrency
};
//# sourceMappingURL=PriceWithCurrency.js.map
