"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateValue = exports.transformerValue = void 0;
var date_fns_1 = __importDefault(require("date-fns"));
var services_1 = require("../../services");
function transformerValue(value, options) {
    if (options === void 0) { options = {}; }
    if (!value)
        return null;
    if (typeof value === 'string') {
        var date_1 = services_1.convertStringToDate(value);
        if (!date_1) {
            throw new Error('Data inválida');
        }
        return {
            day: date_fns_1.default.getDate(date_1),
            month: date_fns_1.default.getMonth(date_1) + 1,
            year: date_fns_1.default.getYear(date_1),
            date: date_1,
            dateYYYYMMDD: date_fns_1.default.format(date_1, 'yyyyMMdd'),
            dateYYYYMMDDhhiiss: date_fns_1.default.format(date_1, 'yyyyMMddHHmm00'),
            allDay: false,
            hour: date_fns_1.default.getHours(date_1),
            minutes: date_fns_1.default.getMinutes(date_1),
            isToday: date_fns_1.default.isToday(date_1),
        };
    }
    if (value instanceof Date) {
        return {
            day: date_fns_1.default.getDate(value),
            month: date_fns_1.default.getMonth(value) + 1,
            year: date_fns_1.default.getYear(value),
            date: value,
            dateYYYYMMDD: date_fns_1.default.format(value, 'yyyyMMdd'),
            dateYYYYMMDDhhiiss: (options === null || options === void 0 ? void 0 : options.allDay) ? date_fns_1.default.format(value, 'yyyyMMdd000000')
                : date_fns_1.default.format(value, 'yyyyMMddHHmm00'),
            allDay: !!(options === null || options === void 0 ? void 0 : options.allDay),
            hour: (options === null || options === void 0 ? void 0 : options.allDay) ? 0 : date_fns_1.default.getHours(value),
            minutes: (options === null || options === void 0 ? void 0 : options.allDay) ? 0 : date_fns_1.default.getMinutes(value),
            isToday: date_fns_1.default.isToday(value),
        };
    }
    if (!value.date || !(value.date instanceof Date)) {
        throw new Error('Data inválida');
    }
    var date = value.date;
    return {
        day: date_fns_1.default.getDate(date),
        month: date_fns_1.default.getMonth(date) + 1,
        year: date_fns_1.default.getYear(date),
        date: date,
        dateYYYYMMDD: date_fns_1.default.format(date, 'yyyyMMdd'),
        dateYYYYMMDDhhiiss: (options === null || options === void 0 ? void 0 : options.allDay) ? date_fns_1.default.format(date, 'yyyyMMdd000000')
            : date_fns_1.default.format(date, 'yyyyMMddHHmm00'),
        allDay: (options === null || options === void 0 ? void 0 : options.allDay) || !!value.allDay,
        hour: (options === null || options === void 0 ? void 0 : options.allDay) ? 0 : date_fns_1.default.getHours(date),
        minutes: (options === null || options === void 0 ? void 0 : options.allDay) ? 0 : date_fns_1.default.getMinutes(date),
        isToday: date_fns_1.default.isToday(date),
    };
}
exports.transformerValue = transformerValue;
function getDateValue(value) {
    if (!value)
        return null;
    if (typeof value === 'string') {
        var date = services_1.convertStringToDate(value);
        return date || null;
    }
    if (value instanceof Date) {
        return value;
    }
    if (!value.date || !(value.date instanceof Date)) {
        throw new Error('Data inválida');
    }
    return value.date;
}
exports.getDateValue = getDateValue;
//# sourceMappingURL=DatepickerFullscreen.interface.js.map