"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"), _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _DeviceEnum = require("./../../deviceManage/common/DeviceEnum"), _DeviceLang = require("./../../deviceManage/common/DeviceLang");

function _createSuper(e) {
    var t = _isNativeReflectConstruct();
    return function() {
        var l, i = (0, _getPrototypeOf2.default)(e);
        if (t) {
            var r = (0, _getPrototypeOf2.default)(this).constructor;
            l = Reflect.construct(i, arguments, r);
        } else l = i.apply(this, arguments);
        return (0, _possibleConstructorReturn2.default)(this, l);
    };
}

function _isNativeReflectConstruct() {
    if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
    if (Reflect.construct.sham) return !1;
    if ("function" == typeof Proxy) return !0;
    try {
        return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
        !0;
    } catch (e) {
        return !1;
    }
}

var obilityOptionData = [];

(0, _DeviceLang.enums2array)(_DeviceEnum.capacityClassifyEnum).map((function(e) {
    obilityOptionData.push({
        value: e.key,
        label: e.label,
        selected: !1,
        style: "all-filter-btn"
    });
}));

var ObilityOptionsFilter = function(e) {
    (0, _inherits2.default)(l, e);
    var t = _createSuper(l);
    function l(e) {
        var i;
        return (0, _classCallCheck2.default)(this, l), i = t.call(this, e), (0, _defineProperty2.default)((0, 
        _assertThisInitialized2.default)(i), "delFilter", (function() {
            var e = i.state, t = e.obilityOptions;
            e.clearBtnStyle;
            t.map((function(e) {
                e.selected = !1, e.style = "all-filter-btn";
            })), i.setState({
                obilityOptions: t,
                clearBtnStyle: "all-filter-btn selected-btn"
            }), i.props.obilitySelectFunc([]);
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "selectClick", (function(e) {
            var t = [], l = i.state, r = l.obilityOptions, n = l.clearBtnStyle;
            n = "all-filter-btn", r.map((function(l) {
                l.label === e.target.innerText && (l.selected ? (l.selected = !1, l.style = "all-filter-btn") : (l.selected = !0, 
                l.style = "all-filter-btn selected-btn")), l.selected && t.push(l);
            })), n = 0 === t.length ? "all-filter-btn selected-btn" : "all-filter-btn", i.setState({
                obilityOptions: r,
                clearBtnStyle: n
            }), i.props.obilitySelectFunc(t);
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "disableAllSelected", (function() {
            i.setState({
                clearBtnStyle: "all-filter-btn selected-btn"
            });
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "AllObilityOptionFunc", (function() {
            var e = i.state, t = e.obilityOptions, l = e.clearBtnStyle, r = [];
            return r.push(_react.default.createElement("div", {
                key: "obility",
                className: l,
                onClick: i.delFilter
            }, _react.default.createElement("div", null, "不限"))), t.map((function(e) {
                r.push(_react.default.createElement("div", {
                    key: "obility".concat(e.value),
                    className: e.style,
                    onClick: i.selectClick
                }, e.label));
            })), r;
        })), i.state = {
            obilityOptions: obilityOptionData,
            clearBtnStyle: "all-filter-btn selected-btn"
        }, i;
    }
    return (0, _createClass2.default)(l, [ {
        key: "render",
        value: function() {
            return this.AllObilityOptionFunc();
        }
    } ]), l;
}(_react.Component);

ObilityOptionsFilter.displayName = "ObilityOptionsFilter", ObilityOptionsFilter.propTypes = {
    obilitySelectFunc: _propTypes.default.func
};

var _default = ObilityOptionsFilter;

exports.default = _default;