"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof = require("@babel/runtime/helpers/typeof");

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")), _amosFramework = require("amos-framework"), _rayEventpool = require("ray-eventpool"), _ActionConf = require("./../../common/ActionConf");

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

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

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

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 Panel = _amosFramework.Collapse.Panel, InterfacePropertyPanel = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var a;
    return (0, _classCallCheck2.default)(this, r), a = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "onAttributeChange", (function(e, t) {
      var r = a.state.interfaceProperty, n = a.props.updateInterfacePropertyCell;
      r[e] = t.target.value, n(e, t.target.value), a.setState({
        interfaceProperty: r
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "onChangeCollapseSize", (function(e) {
      void 0 !== e && void 0 !== e.length && a.setState({
        collapseKey: e
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "getBaseContent", (function() {
      var e = [], t = a.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;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "getAttributesEditContent", (function() {
      var e = [], t = a.props, r = t.intfc, n = t.updateInterfacePropertyCell, l = t.equipment, i = t.enable, o = a.state.interfaceProperty;
      return r.attributes.map((function(t) {
        var c = o["intfc_".concat(r.id, "_").concat(t.id)];
        if (void 0 === c) if (void 0 !== l && void 0 !== l.id) {
          var u = l.cfgParamMap;
          c = u["intfc_".concat(r.id, "_").concat(t.id)] ? u["intfc_".concat(r.id, "_").concat(t.id)] : c;
        } else c = t.valueStr;
        o["intfc_".concat(r.id, "_").concat(t.id)] = c, n("intfc_".concat(r.id, "_").concat(t.id), c), 
        e.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"
          }
        }, i ? _react.default.createElement(_amosFramework.Input, {
          value: c || t.valueStr,
          onChange: function(e) {
            return a.onAttributeChange("intfc_".concat(r.id, "_").concat(t.id), e);
          },
          style: {
            width: "140px"
          },
          placeholder: "请输入"
        }) : _react.default.createElement("div", {
          className: "property-normal-label",
          title: c || t.valueStr
        }, c || t.valueStr))));
      })), e;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "getCollapseHead", (function(e, t) {
      var r = a.props.getImgPath(t, a.state.collapseKey), n = [];
      return n.push(_react.default.createElement("div", {
        className: "config-collapse-head"
      }, _react.default.createElement("label", {
        className: "config-collapse-text"
      }, e), r)), n;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "closeInterfacePanel", (function() {
      _rayEventpool.PubSub.publish(_ActionConf.CONFIG_PANEL_HIDE_TOPIC.trigger, {});
    })), a.state = {
      collapseKey: [ "1", "2" ],
      interfaceProperty: {}
    }, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = this, t = 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: t,
        onChange: function(t) {
          return e.onChangeCollapseSize(t);
        }
      }, _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;
}(_react.Component);

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 = _default;