import { toDateInputValue as toDateInputValueOrNull } from "@open-mercato/shared/lib/date/format";
function readString(value) {
  return typeof value === "string" ? value : null;
}
function toDateInputValue(value) {
  return toDateInputValueOrNull(value) ?? "";
}
function openNativeDatePicker(event) {
  const input = event.currentTarget;
  if (typeof input.showPicker === "function") {
    input.showPicker();
  }
}
function formatAmount(value, currency, locale) {
  const numeric = Number(value);
  if (!Number.isFinite(numeric)) return "--";
  try {
    if (currency && currency.trim().length > 0) {
      return new Intl.NumberFormat(locale ?? void 0, {
        style: "currency",
        currency,
        minimumFractionDigits: 2,
        maximumFractionDigits: 2
      }).format(numeric);
    }
    return new Intl.NumberFormat(locale ?? void 0, {
      style: "decimal",
      minimumFractionDigits: 0,
      maximumFractionDigits: 2
    }).format(numeric);
  } catch {
    return String(numeric);
  }
}
export {
  formatAmount,
  openNativeDatePicker,
  readString,
  toDateInputValue
};
//# sourceMappingURL=shared.js.map
