var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { InternalDateOrder, InternalDateSeparator, InternalDateValidateCheck } from '../../../lib/date/types.js';
import { InternalDate } from '../../../lib/date/InternalDate.js';
import { MAX_FULLDATE, MIN_FULLDATE } from '../../../lib/date/constants.js';
import { isLessOrEqual } from '../../../lib/date/comparison.js';
var defaultOptions = {
    startOptional: false,
    endOptional: false,
    minDate: MIN_FULLDATE,
    maxDate: MAX_FULLDATE,
};
export function validateDateRangePicker(startValue, endValue, options) {
    if (options === void 0) { options = defaultOptions; }
    var _a = __assign(__assign({}, defaultOptions), options), startOptional = _a.startOptional, endOptional = _a.endOptional, minDate = _a.minDate, maxDate = _a.maxDate;
    var isStartEmpty = !startValue;
    var isStartRequired = !startOptional;
    var isEndEmpty = !endValue;
    var isEndRequired = !endOptional;
    if (!isStartEmpty && !isEndEmpty && !isRangeValid(startValue, endValue)) {
        return [false, false];
    }
    var internalDate = getInternalDate(minDate, maxDate);
    var isStartValid = isStartEmpty ? !isStartRequired : checkDate(internalDate.parseValue(startValue));
    var isEndValid = isEndEmpty ? !isEndRequired : checkDate(internalDate.parseValue(endValue));
    return [isStartValid, isEndValid];
}
function isRangeValid(startValue, endValue) {
    return isLessOrEqual(startValue || '', endValue || '');
}
function getInternalDate(minDate, maxDate) {
    return new InternalDate({
        order: InternalDateOrder.DMY,
        separator: InternalDateSeparator.Dot,
    })
        .setRangeStart(new InternalDate({ value: minDate }))
        .setRangeEnd(new InternalDate({ value: maxDate }));
}
function checkDate(internalDate) {
    return internalDate.validate({
        checks: [
            InternalDateValidateCheck.NotNull,
            InternalDateValidateCheck.Number,
            InternalDateValidateCheck.Native,
            InternalDateValidateCheck.Limits,
            InternalDateValidateCheck.Range,
        ],
    });
}
//# sourceMappingURL=validateDateRangePicker.js.map