function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { formatDate } from "./formatDate";
import { formatWeekday } from "./formatWeekday";
import { getRelativeDay, getRelativeDayLabel } from "./relativeDay";

/**
 * 获取「日期部分」的展示文案（相对日内置在 datetime）
 * - 若开启 showRelativeDay 且日期为今天/昨天/明天，返回相对日文案（如「今天」「Yesterday」）
 * - 否则返回「星期, 日期」格式（用于时间区间跨天等场景）
 *
 * 供 PisellDateTimeDisplay、PisellTimeRangeDisplay 等统一使用，相对时间逻辑只在此处维护
 */
export function getDatePartDisplay(params) {
  var date = params.date,
    dateFormat = params.dateFormat,
    weekdayFormat = params.weekdayFormat,
    referenceDate = params.referenceDate,
    dateFormatOverride = params.dateFormatOverride;
  if (dateFormat !== null && dateFormat !== void 0 && dateFormat.showRelativeDay) {
    var rel = getRelativeDay(date, referenceDate);
    if (rel) {
      var _labels$rel;
      var labels = dateFormat.relativeDayLabels;
      return (_labels$rel = labels === null || labels === void 0 ? void 0 : labels[rel]) !== null && _labels$rel !== void 0 ? _labels$rel : getRelativeDayLabel(rel, date.locale());
    }
  }
  var mergedDateConfig = _objectSpread(_objectSpread({}, dateFormat), dateFormatOverride);
  var weekdayStr = formatWeekday(date, _objectSpread(_objectSpread({}, weekdayFormat), {}, {
    trailingComma: true
  }));
  var dateStr = formatDate(date, mergedDateConfig);
  return "".concat(weekdayStr, " ").concat(dateStr);
}