"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"), _classnames = _interopRequireDefault(require("classnames")), _amosIcon = _interopRequireDefault(require("amos-icon"));

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 = {}, l = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var o in e) if ("default" !== o && Object.prototype.hasOwnProperty.call(e, o)) {
    var n = l ? Object.getOwnPropertyDescriptor(e, o) : null;
    n && (n.get || n.set) ? Object.defineProperty(a, o, n) : a[o] = e[o];
  }
  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 l = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(a, arguments, l);
    } 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 LibItem = 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), "renderOperater", (function() {
      var e = a.props, t = e.toggleUse, r = e.togglePublish, l = e.enable, o = e.published;
      e.onSetting;
      return _react.default.createElement("div", {
        className: "item-content-operate"
      }, _react.default.createElement(_amosFramework.Switch, {
        className: "obj-publish-switch",
        onLabel: "已发布",
        offLabel: "调试中",
        onChange: r,
        onOff: o
      }), _react.default.createElement(_amosFramework.Switch, {
        className: "obj-startuse-switch",
        onLabel: "已启用",
        offLabel: "未启用",
        onChange: t,
        onOff: l
      }));
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "renderRuleOperate", (function() {
      var e = a.props, t = e.toggleUse, r = e.togglePublish, l = e.onDoubleClick, o = e.onSetting, n = e.published, i = e.enable, u = [];
      return u.push(_react.default.createElement("div", null, _react.default.createElement(_amosFramework.Row, {
        className: "rule-operate-row"
      }, _react.default.createElement(_amosFramework.Col, {
        span: 12,
        style: {
          height: "57px"
        }
      }, _react.default.createElement("div", {
        className: "rule-operate-cell"
      }, _react.default.createElement(_amosFramework.Switch, {
        className: "obj-publish-switch",
        onLabel: "已发布",
        offLabel: "调试中",
        onChange: r,
        onOff: n
      }))), _react.default.createElement(_amosFramework.Col, {
        span: 12,
        style: {
          height: "57px"
        }
      }, _react.default.createElement("div", {
        className: "rule-operate-cell-right"
      }, _react.default.createElement(_amosFramework.Switch, {
        className: "obj-startuse-switch",
        onLabel: "已启用",
        offLabel: "未启用",
        onChange: t,
        onOff: i
      })))), _react.default.createElement(_amosFramework.Row, {
        className: "rule-operate-row"
      }, _react.default.createElement(_amosFramework.Col, {
        span: 12
      }, _react.default.createElement("div", {
        className: "rule-operate-cell",
        onClick: o
      }, "编辑")), _react.default.createElement(_amosFramework.Col, {
        span: 12
      }, _react.default.createElement("div", {
        className: "rule-operate-cell-right",
        onClick: l
      }, "查看"))), _react.default.createElement(_amosFramework.Row, {
        className: "rule-operate-row"
      }, _react.default.createElement(_amosFramework.Col, {
        span: 12
      }, _react.default.createElement("div", {
        className: "rule-operate-cell",
        onClick: a.deleteRule
      }, "删除")), _react.default.createElement(_amosFramework.Col, {
        span: 12
      }, _react.default.createElement("div", {
        className: "rule-operate-cell-right"
      }))), _react.default.createElement(_amosFramework.Row, {
        className: "rule-operate-row"
      }, _react.default.createElement(_amosFramework.Col, {
        span: 24
      }, _react.default.createElement("div", {
        className: "rule-operate-cell-right"
      }))))), u;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "deleteRule", (function() {
      var e = a.props.onRemove;
      _amosFramework.Modal.confirm({
        title: "批量删除",
        content: "是否删除所选信息？",
        okText: "确定",
        cancelText: "取消",
        onOk: function() {
          e();
        },
        onCancel: function() {}
      });
    })), a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = this.props, t = e.title, r = e.enable, a = e.published, l = e.onDoubleClick, o = (e.showClose, 
      e.showSetting, e.descr), n = r || a, i = (0, _classnames.default)("rule-lib-item", {
        "obj-item-used": n
      });
      return _react.default.createElement("div", {
        tabIndex: "0",
        onDoubleClick: l,
        className: i
      }, _react.default.createElement("div", {
        className: "rule-lib-item-title t-o"
      }, t), _react.default.createElement("div", {
        className: "rule-lib-item-content-root"
      }, _react.default.createElement("div", {
        className: "rule-lib-item-content"
      }, _react.default.createElement("div", {
        className: "item-photo-wrapper"
      }, _react.default.createElement("div", {
        className: "item-photo-inner"
      })), _react.default.createElement("div", {
        className: "rule-lib-item-descr"
      }, "描述：".concat(o))), _react.default.createElement("div", {
        className: "rule-lib-item-operate"
      }, this.renderRuleOperate())));
    }
  } ]), r;
}(_react.Component);

(0, _defineProperty2.default)(LibItem, "propTypes", {
  title: _propTypes.default.string,
  descr: _propTypes.default.string,
  enable: _propTypes.default.bool,
  published: _propTypes.default.bool,
  toggleUse: _propTypes.default.func,
  togglePublish: _propTypes.default.func,
  onDoubleClick: _propTypes.default.func,
  showClose: _propTypes.default.bool,
  showSetting: _propTypes.default.bool,
  onRemove: _propTypes.default.func,
  onSetting: _propTypes.default.func
}), (0, _defineProperty2.default)(LibItem, "defaultProps", {
  showClose: !0,
  showSetting: !0
}), LibItem.displayName = "LibItem";

var _default = LibItem;

exports.default = _default;