"use strict";

exports.__esModule = true;
exports.timePlaceholder = exports.formatTimePart = exports.formatDatePart = exports.datePlaceholder = void 0;
var _helpers = require("./helpers");
const dateFormatter = new Intl.DateTimeFormat(undefined, {
  day: '2-digit',
  month: '2-digit',
  year: 'numeric'
});
const timeFormatter = new Intl.DateTimeFormat(undefined, {
  hour: 'numeric',
  minute: '2-digit'
});
const formatDatePart = value => (0, _helpers.isValidDate)(value) ? dateFormatter.format(value) : '';
exports.formatDatePart = formatDatePart;
const formatTimePart = value => (0, _helpers.isValidDate)(value) ? timeFormatter.format(value) : '';
exports.formatTimePart = formatTimePart;
const DATE_PLACEHOLDER_SAMPLE = new Date(2026, 0, 31);
const TIME_PLACEHOLDER_SAMPLE = new Date(2026, 0, 1, 13, 30);

/** Looked up via the consumer's `t()` so each token is translatable. */

/**
 * Derives an input placeholder from the current locale's date format by
 * replacing each part with its translated stand-in (DD, MM, YYYY). E.g.
 * `MM/DD/YYYY` in en-US, `DD.MM.YYYY` in de-DE, `YYYY/MM/DD` in ja-JP.
 */
const datePlaceholder = tokens => dateFormatter.formatToParts(DATE_PLACEHOLDER_SAMPLE).map(part => {
  if (part.type === 'day') return tokens.day;
  if (part.type === 'month') return tokens.month;
  if (part.type === 'year') return tokens.year;
  return part.value;
}).join('');

/**
 * Derives a time input placeholder from the current locale's time format.
 * E.g. `HH:MM AM` in en-US (12-hour) or `HH:MM` in de-DE (24-hour).
 */
exports.datePlaceholder = datePlaceholder;
const timePlaceholder = tokens => timeFormatter.formatToParts(TIME_PLACEHOLDER_SAMPLE).map(part => {
  if (part.type === 'hour') return tokens.hour;
  if (part.type === 'minute') return tokens.minute;
  return part.value;
}).join('');
exports.timePlaceholder = timePlaceholder;
//# sourceMappingURL=formatters.js.map