/**
 * DevExtreme (esm/renovation/ui/scheduler/appointment_edit_form/edit_form/editors/timeZoneEditor.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/
 */
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["date", "value", "valueChange"];
import {
    createComponentVNode
} from "inferno";
import {
    InfernoEffect,
    InfernoComponent
} from "@devextreme/runtime/inferno";
import {
    SelectBox
} from "../../../../editors/drop_down_editors/select_box";
import messageLocalization from "../../../../../../localization/message";
import timeZoneDataUtils from "../../../../../../__internal/scheduler/timezones/m_utils_timezones_data";
import DataSource from "../../../../../../data/data_source";
var noTzTitle = messageLocalization.format("dxScheduler-noTimezoneTitle");
export var viewFunction = _ref => {
    var {
        dataSource: dataSource,
        timeZone: timeZone
    } = _ref;
    return createComponentVNode(2, SelectBox, {
        value: timeZone,
        dataSource: dataSource,
        displayExpr: "title",
        valueExpr: "id",
        placeholder: noTzTitle,
        searchEnabled: true
    })
};
export var TimeZoneEditorProps = {};
import {
    convertRulesToOptions
} from "../../../../../../core/options/utils";
export class TimeZoneEditor extends InfernoComponent {
    constructor(props) {
        super(props);
        this.state = {
            timeZone: void 0
        };
        this.initDate = this.initDate.bind(this);
        this.updateDate = this.updateDate.bind(this)
    }
    createEffects() {
        return [new InfernoEffect(this.initDate, [])]
    }
    initDate() {
        if (!this.state.timeZone) {
            this.setState(__state_argument => ({
                timeZone: this.props.value
            }))
        }
    }
    updateDate(timeZone) {
        this.setState(__state_argument => ({
            timeZone: timeZone
        }));
        this.props.valueChange(timeZone)
    }
    get dataSource() {
        return new DataSource({
            store: timeZoneDataUtils.getDisplayedTimeZones(this.props.date),
            paginate: true,
            pageSize: 10
        })
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            timeZone: this.state.timeZone,
            updateDate: this.updateDate,
            dataSource: this.dataSource,
            restAttributes: this.restAttributes
        })
    }
}
TimeZoneEditor.defaultProps = TimeZoneEditorProps;
var __defaultOptionRules = [];
export function defaultOptions(rule) {
    __defaultOptionRules.push(rule);
    TimeZoneEditor.defaultProps = Object.create(Object.prototype, _extends(Object.getOwnPropertyDescriptors(TimeZoneEditor.defaultProps), Object.getOwnPropertyDescriptors(convertRulesToOptions(__defaultOptionRules))))
}
