/**
 * DevExtreme (cjs/renovation/ui/scheduler/header/utils.js)
 * Version: 23.2.4 (build 24056-0112)
 * Build date: Sun Feb 25 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.isMonthView = exports.isMobileLayout = exports.formatViews = exports.formToolbarItem = void 0;
var _view_switcher = require("./view_switcher");
var _date_navigator = require("./date_navigator");
var _m_utils = require("../../../../__internal/scheduler/header/m_utils");
var _devices = _interopRequireDefault(require("../../../../core/devices"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}
const DEFAULT_ELEMENT = "defaultElement";
const VIEW_SWITCHER = "viewSwitcher";
const DATE_NAVIGATOR = "dateNavigator";
const formToolbarItem = (item, options) => {
    const {
        captionText: captionText,
        isNextButtonDisabled: isNextButtonDisabled,
        isPreviousButtonDisabled: isPreviousButtonDisabled,
        selectedView: selectedView,
        setCurrentView: setCurrentView,
        showCalendar: showCalendar,
        updateDateByDirection: updateDateByDirection,
        useDropDownViewSwitcher: useDropDownViewSwitcher,
        views: views
    } = options;
    if (item.defaultElement) {
        const defaultElementType = item.defaultElement;
        switch (defaultElementType) {
            case VIEW_SWITCHER:
                if (useDropDownViewSwitcher) {
                    return (0, _view_switcher.getDropDownViewSwitcher)(item, selectedView, views, setCurrentView)
                }
                return (0, _view_switcher.getViewSwitcher)(item, selectedView, views, setCurrentView);
            case DATE_NAVIGATOR:
                return (0, _date_navigator.getDateNavigator)(item, showCalendar, captionText, updateDateByDirection, isPreviousButtonDisabled, isNextButtonDisabled);
            default:
                throw new Error("Unknown default item in the scheduler's toolbar")
        }
    }
    return item
};
exports.formToolbarItem = formToolbarItem;
const formatViews = views => {
    (0, _m_utils.validateViews)(views);
    return views.map(view => {
        const text = (0, _m_utils.getViewText)(view);
        const name = (0, _m_utils.getViewName)(view);
        return {
            text: text,
            name: name
        }
    })
};
exports.formatViews = formatViews;
const isMonthView = currentView => "month" === (0, _m_utils.getViewType)(currentView);
exports.isMonthView = isMonthView;
const isMobileLayout = () => !_devices.default.current().generic;
exports.isMobileLayout = isMobileLayout;
