"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "normalizeDateTime", {
    enumerable: true,
    get: function() {
        return normalizeDateTime;
    }
});
const _datejs = require("../../../utils/datejs");
const normalizeDateTime = ({ originalDate, lang, format, includeEdgeDates, min, max })=>{
    let dateCandidate = originalDate;
    _datejs.customDayjs.locale(lang);
    if (min && includeEdgeDates && min > originalDate) {
        dateCandidate = min;
    } else if (min && !includeEdgeDates && min >= originalDate) {
        dateCandidate = (0, _datejs.customDayjs)(min).add(1, 's').toDate();
    } else if (max && includeEdgeDates && max < originalDate) {
        dateCandidate = max;
    } else if (max && !includeEdgeDates && max <= originalDate) {
        dateCandidate = (0, _datejs.customDayjs)(max).subtract(1, 's').toDate();
    }
    const formattedDateCandidate = format ? (0, _datejs.customDayjs)(dateCandidate).format(format) : dateCandidate.toString();
    return {
        normalizedDate: dateCandidate,
        formattedNormalizedDate: formattedDateCandidate
    };
};
