"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _react = _interopRequireWildcard(require("react")),
  _propTypes = _interopRequireDefault(require("prop-types")),
  _amosFramework = require("amos-framework"),
  _rayEventpool = require("ray-eventpool"),
  _ActionConf = require("./../../common/ActionConf");

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

function _getRequireWildcardCache() {
  if ("function" != typeof WeakMap) return null;
  var e = new WeakMap;
  return _getRequireWildcardCache = function() {
    return e
  }, e
}

function _interopRequireWildcard(e) {
  if (e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var t = _getRequireWildcardCache();
  if (t && t.has(e)) return t.get(e);
  var r, n, a = {},
    o = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (r in e) Object.prototype.hasOwnProperty.call(e, r) && ((n = o ? Object.getOwnPropertyDescriptor(e, r) : null) && (n.get || n.set) ? Object.defineProperty(a, r, n) : a[r] = e[r]);
  return a.default = e, t && t.set(e, a), a
}

function _typeof(e) {
  return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e
  } : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  })(e)
}

function _classCallCheck(e, t) {
  if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}

function _defineProperties(e, t) {
  for (var r = 0; r < t.length; r++) {
    var n = t[r];
    n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n)
  }
}

function _createClass(e, t, r) {
  return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), e
}

function _inherits(e, t) {
  if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
  e.prototype = Object.create(t && t.prototype, {
    constructor: {
      value: e,
      writable: !0,
      configurable: !0
    }
  }), t && _setPrototypeOf(e, t)
}

function _setPrototypeOf(e, t) {
  return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) {
    return e.__proto__ = t, e
  })(e, t)
}

function _createSuper(r) {
  var n = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(r);
    return _possibleConstructorReturn(this, n ? (e = _getPrototypeOf(this).constructor, Reflect.construct(t, arguments, e)) : t.apply(this, arguments))
  }
}

function _possibleConstructorReturn(e, t) {
  return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t
}

function _assertThisInitialized(e) {
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return e
}

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

function _getPrototypeOf(e) {
  return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
    return e.__proto__ || Object.getPrototypeOf(e)
  })(e)
}

function _defineProperty(e, t, r) {
  return t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e
}
var Panel = _amosFramework.Collapse.Panel,
  InterfacePropertyPanel = function() {
    _inherits(r, _react.Component);
    var t = _createSuper(r);

    function r(e) {
      var u;
      return _classCallCheck(this, r), _defineProperty(_assertThisInitialized(u = t.call(this, e)), "onAttributeChange", function(e, t) {
        var r = u.state.interfaceProperty,
          n = u.props.updateInterfacePropertyCell;
        r[e] = t.target.value, n(e, t.target.value), u.setState({
          interfaceProperty: r
        })
      }), _defineProperty(_assertThisInitialized(u), "onChangeCollapseSize", function(e) {
        void 0 !== e && void 0 !== e.length && u.setState({
          collapseKey: e
        })
      }), _defineProperty(_assertThisInitialized(u), "getBaseContent", function() {
        var e = [],
          t = u.props.intfc;
        return e.push(_react.default.createElement("div", {
          className: "property-config-common"
        }, _react.default.createElement("div", {
          title: "通信方式",
          className: "property-key-style"
        }, "通信方式", "："), _react.default.createElement("div", {
          style: {
            width: "142px",
            float: "left"
          }
        }, _react.default.createElement("div", {
          className: "property-normal-label",
          title: t.name
        }, t.name)))), e
      }), _defineProperty(_assertThisInitialized(u), "getAttributesEditContent", function() {
        var n = [],
          e = u.props,
          a = e.intfc,
          o = e.updateInterfacePropertyCell,
          i = e.equipment,
          c = e.enable,
          l = u.state.interfaceProperty;
        return a.attributes.map(function(t) {
          var e, r = l["intfc_".concat(a.id, "_").concat(t.id)];
          void 0 === r && (r = void 0 !== i && void 0 !== i.id ? (e = i.cfgParamMap)["intfc_".concat(a.id, "_").concat(t.id)] ? e["intfc_".concat(a.id, "_").concat(t.id)] : r : t.valueStr), l["intfc_".concat(a.id, "_").concat(t.id)] = r, o("intfc_".concat(a.id, "_").concat(t.id), r), n.push(_react.default.createElement("div", {
            className: "property-config-common"
          }, _react.default.createElement("div", {
            className: "property-key-style",
            title: t.displayName
          }, t.displayName, "："), _react.default.createElement("div", {
            style: {
              width: "142px",
              float: "left"
            }
          }, c ? _react.default.createElement(_amosFramework.Input, {
            value: r || t.valueStr,
            onChange: function(e) {
              return u.onAttributeChange("intfc_".concat(a.id, "_").concat(t.id), e)
            },
            style: {
              width: "140px"
            },
            placeholder: "请输入"
          }) : _react.default.createElement("div", {
            className: "property-normal-label",
            title: r || t.valueStr
          }, r || t.valueStr))))
        }), n
      }), _defineProperty(_assertThisInitialized(u), "getCollapseHead", function(e, t) {
        var r = u.props.getImgPath(t, u.state.collapseKey),
          t = [];
        return t.push(_react.default.createElement("div", {
          className: "config-collapse-head"
        }, _react.default.createElement("label", {
          className: "config-collapse-text"
        }, e), r)), t
      }), _defineProperty(_assertThisInitialized(u), "closeInterfacePanel", function() {
        _rayEventpool.PubSub.publish(_ActionConf.CONFIG_PANEL_HIDE_TOPIC.trigger, {})
      }), u.state = {
        collapseKey: ["1", "2"],
        interfaceProperty: {}
      }, u
    }
    return _createClass(r, [{
      key: "componentWillMount",
      value: function() {}
    }, {
      key: "componentDidMount",
      value: function() {}
    }, {
      key: "componentWillReceiveProps",
      value: function() {}
    }, {
      key: "componentWillUnmount",
      value: function() {}
    }, {
      key: "render",
      value: function() {
        var t = this,
          e = this.state.collapseKey;
        return _react.default.createElement("div", {
          className: "interface-property-root"
        }, _react.default.createElement("div", {
          className: "interface-property-head"
        }, _react.default.createElement("div", {
          className: "common-property-text"
        }, "接口详情"), _react.default.createElement("div", {
          className: "del-button-view",
          onClick: this.closeInterfacePanel
        }, "关闭")), _react.default.createElement(_amosFramework.Collapse, {
          activeKey: e,
          onChange: function(e) {
            return t.onChangeCollapseSize(e)
          }
        }, _react.default.createElement(Panel, {
          showArrow: !1,
          header: this.getCollapseHead("设备接口", "1"),
          key: "1"
        }, _react.default.createElement("div", {
          className: "interface-base-info"
        }, this.getBaseContent())), _react.default.createElement(Panel, {
          showArrow: !1,
          header: this.getCollapseHead("通讯参数", "2"),
          key: "2"
        }, _react.default.createElement("div", {
          className: "interface-property-info"
        }, this.getAttributesEditContent()))))
      }
    }]), r
  }();
InterfacePropertyPanel.displayName = "InterfacePropertyPanel", InterfacePropertyPanel.propTypes = {
  getImgPath: _propTypes.default.func,
  intfc: _propTypes.default.object,
  updateInterfacePropertyCell: _propTypes.default.func,
  equipment: _propTypes.default.object,
  enable: _propTypes.default.bool
};
var _default = InterfacePropertyPanel;
exports.default = InterfacePropertyPanel, module.exports = exports.default;
