/**
 * DevExtreme (cjs/__internal/ui/calendar/m_calendar.navigator.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.default = void 0;
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _button = _interopRequireDefault(require("../../../ui/button"));
var _themes = require("../../../ui/themes");
var _widget = _interopRequireDefault(require("../widget"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function(target) {
        for (var i = 1; i < arguments.length; i++) {
            var source = arguments[i];
            for (var key in source) {
                if (Object.prototype.hasOwnProperty.call(source, key)) {
                    target[key] = source[key]
                }
            }
        }
        return target
    };
    return _extends.apply(this, arguments)
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
const CALENDAR_NAVIGATOR_CLASS = "dx-calendar-navigator";
const CALENDAR_NAVIGATOR_PREVIOUS_MONTH_CLASS = "dx-calendar-navigator-previous-month";
const CALENDAR_NAVIGATOR_NEXT_MONTH_CLASS = "dx-calendar-navigator-next-month";
const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = "dx-calendar-navigator-previous-view";
const CALENDAR_NAVIGATOR_NEXT_VIEW_CLASS = "dx-calendar-navigator-next-view";
const CALENDAR_NAVIGATOR_DISABLED_LINK_CLASS = "dx-calendar-disabled-navigator-link";
const CALENDAR_NAVIGATOR_CAPTION_BUTTON_CLASS = "dx-calendar-caption-button";
const BUTTON_TEXT_CLASS = "dx-button-text";
let Navigator = function(_Widget) {
    _inheritsLoose(Navigator, _Widget);

    function Navigator() {
        return _Widget.apply(this, arguments) || this
    }
    var _proto = Navigator.prototype;
    _proto._getDefaultOptions = function() {
        return _extends(_extends({}, _Widget.prototype._getDefaultOptions.call(this)), {
            onClick: void 0,
            onCaptionClick: void 0,
            type: "normal",
            stylingMode: "outlined",
            text: ""
        })
    };
    _proto._defaultOptionsRules = function() {
        return _Widget.prototype._defaultOptionsRules.call(this).concat([{
            device: () => (0, _themes.isMaterial)(),
            options: {
                type: "default",
                stylingMode: "text"
            }
        }, {
            device: () => (0, _themes.isFluent)(),
            options: {
                type: "normal",
                stylingMode: "text"
            }
        }])
    };
    _proto._init = function() {
        _Widget.prototype._init.call(this);
        this._initActions()
    };
    _proto._initActions = function() {
        this._clickAction = this._createActionByOption("onClick");
        this._captionClickAction = this._createActionByOption("onCaptionClick")
    };
    _proto._initMarkup = function() {
        _Widget.prototype._initMarkup.call(this);
        (0, _renderer.default)(this.element()).addClass("dx-calendar-navigator");
        this._renderButtons();
        this._renderCaption()
    };
    _proto._renderButtons = function() {
        const {
            rtlEnabled: rtlEnabled,
            type: type,
            stylingMode: stylingMode,
            focusStateEnabled: focusStateEnabled
        } = this.option();
        this._prevButton = this._createComponent((0, _renderer.default)("<div>"), _button.default, {
            focusStateEnabled: focusStateEnabled,
            icon: rtlEnabled ? "chevronright" : "chevronleft",
            onClick: e => {
                this._clickAction({
                    direction: -1,
                    event: e
                })
            },
            type: type,
            stylingMode: stylingMode,
            integrationOptions: {}
        });
        const $prevButton = (0, _renderer.default)(this._prevButton.element()).addClass("dx-calendar-navigator-previous-view").addClass("dx-calendar-navigator-previous-month");
        this._nextButton = this._createComponent((0, _renderer.default)("<div>"), _button.default, {
            focusStateEnabled: focusStateEnabled,
            icon: rtlEnabled ? "chevronleft" : "chevronright",
            onClick: e => {
                this._clickAction({
                    direction: 1,
                    event: e
                })
            },
            type: type,
            stylingMode: stylingMode,
            integrationOptions: {}
        });
        const $nextButton = (0, _renderer.default)(this._nextButton.element()).addClass("dx-calendar-navigator-next-view").addClass("dx-calendar-navigator-next-month");
        this._caption = this._createComponent((0, _renderer.default)("<div>").addClass("dx-calendar-caption-button"), _button.default, {
            focusStateEnabled: focusStateEnabled,
            onClick: e => {
                this._captionClickAction({
                    event: e
                })
            },
            type: type,
            stylingMode: stylingMode,
            template: (_, content) => {
                const {
                    text: text
                } = this.option();
                const viewCaptionTexts = text.split(" - ");
                viewCaptionTexts.forEach(captionText => {
                    (0, _renderer.default)(content).append((0, _renderer.default)("<span>").addClass("dx-button-text").text(captionText))
                })
            },
            integrationOptions: {}
        });
        const $caption = this._caption.$element();
        this.$element().append($prevButton, $caption, $nextButton)
    };
    _proto._renderCaption = function() {
        var _a;
        null === (_a = this._caption) || void 0 === _a ? void 0 : _a.option("text", this.option("text"))
    };
    _proto.toggleButton = function(buttonPrefix, value) {
        const buttonName = "_".concat(buttonPrefix, "Button");
        const button = this[buttonName];
        if (button) {
            button.option("disabled", value);
            button.$element().toggleClass("dx-calendar-disabled-navigator-link", value)
        }
    };
    _proto._optionChanged = function(args) {
        switch (args.name) {
            case "text":
                this._renderCaption();
                break;
            default:
                _Widget.prototype._optionChanged.call(this, args)
        }
    };
    return Navigator
}(_widget.default);
var _default = Navigator;
exports.default = _default;
