"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")), _classnames = _interopRequireDefault(require("classnames")), _amosTool = require("amos-tool"), _rayEventpool = require("ray-eventpool"), _amosProcessor = require("amos-processor"), _amosReactRouter = require("amos-react-router"), _urlConsts = require("../consts/urlConsts"), _home = _interopRequireDefault(require("./home")), _header = _interopRequireDefault(require("./main/header")), _LeftMaxContent = _interopRequireDefault(require("./main/LeftMaxContent")), _LeftMinContent = _interopRequireDefault(require("./main/LeftMinContent")), _RightMaxContent = _interopRequireDefault(require("./main/RightMaxContent")), _RightMinContent = _interopRequireDefault(require("./main/RightMinContent")), _topicConsts = require("./../consts/topicConsts");

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 i = {}, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var a in e) if ("default" !== a && Object.prototype.hasOwnProperty.call(e, a)) {
    var o = n ? Object.getOwnPropertyDescriptor(e, a) : null;
    o && (o.get || o.set) ? Object.defineProperty(i, a, o) : i[a] = e[a];
  }
  return i.default = e, r && r.set(e, i), i;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, i = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var n = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(i, arguments, n);
    } else r = i.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 boxList = [ {
  key: "collection",
  text: "我的收藏",
  icon: "collection",
  children: []
}, {
  key: "application",
  text: "我的应用",
  icon: "appstore",
  children: []
}, {
  key: "card",
  text: "可用卡片",
  icon: "card",
  children: []
} ], boxRightList = [ {
  key: "task",
  text: "周期任务",
  icon: "task",
  children: []
}, {
  key: "message",
  text: "未读消息",
  icon: "xiaoxi",
  children: []
} ], config = {
  slider: 20,
  minScale: 4
}, RootView = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var i;
    return (0, _classCallCheck2.default)(this, r), i = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(i), "onLeftTabChange", (function(e, t) {
      i.setState({
        leftActiveKey: t
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "onRightTabChange", (function(e, t) {
      i.setState({
        rightActiveKey: t
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "onSetAppList", (function(e) {
      (0, _amosProcessor.amosRequest)("".concat(_urlConsts.secExtUrl.opSearchMenusUrl, "?nodeName="), {
        method: "GET"
      }).then((function(e) {
        var t = (e || {}).dataList || [];
        i.setState({
          extendSystem: t
        });
      }));
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "closeBox", (function(e) {
      var t;
      i.setState((t = {}, (0, _defineProperty2.default)(t, "".concat(e, "Expand"), !1), 
      (0, _defineProperty2.default)(t, "".concat(e, "Center"), config.slider * config.minScale), 
      t));
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "openBox", (function(e) {
      var t, r = e.type, n = e.openKey;
      i.setState((t = {}, (0, _defineProperty2.default)(t, "".concat(r, "Expand"), !0), 
      (0, _defineProperty2.default)(t, "".concat(r, "ActiveKey"), n), t));
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "calcCenterStyle", (function(e) {
      var t = e.leftOffset, r = void 0 === t ? {} : t, n = e.rightOffset, a = void 0 === n ? {} : n;
      _amosTool.utils.isEmpty(r) || i.setState({
        leftCenter: r.width + config.slider
      }), _amosTool.utils.isEmpty(a) || i.setState({
        rightCenter: a.width + config.slider
      });
    })), i.state = {
      eyeMode: !0,
      leftExpand: !1,
      rightExpand: !1,
      leftActiveKey: "application",
      rightActiveKey: "task",
      leftCenter: 0,
      rightCenter: 0,
      extendSystem: [ {
        key: "1",
        name: "首页",
        url: "/main"
      } ]
    }, i;
  }
  return (0, _createClass2.default)(r, [ {
    key: "componentWillMount",
    value: function() {
      this.onSetAppList(), this.setState({
        leftExpand: !1,
        rightExpand: !1
      });
    }
  }, {
    key: "componentDidMount",
    value: function() {
      var e = this;
      this.pubsub_eyeModeChange = _rayEventpool.PubSub.subscribe(_topicConsts.EYE_MODE_CHANGE, (function(t, r) {
        e.setState({
          eyeMode: r
        });
      }));
    }
  }, {
    key: "componentWillReceiveProps",
    value: function(e) {
      e.isLoginout && (this.context.router ? this.context.router.push("login") : _amosReactRouter.browserHistory.push("login"));
    }
  }, {
    key: "componentWillUnmount",
    value: function() {
      _rayEventpool.PubSub.unsubscribe(this.pubsub_eyeModeChange);
    }
  }, {
    key: "render",
    value: function() {
      var e = this.state, t = e.eyeMode, r = e.rightExpand, i = e.rightActiveKey, n = e.leftExpand, a = e.leftActiveKey, o = this.props.children, l = (0, 
      _classnames.default)("view-port", {
        uneyemode: !t
      });
      return _react.default.createElement("div", {
        className: l
      }, _react.default.createElement("div", {
        className: "header"
      }, _react.default.createElement(_header.default, {
        extendSystem: this.state.extendSystem
      })), _react.default.createElement("div", {
        className: "content-body"
      }, _react.default.createElement("div", {
        className: "desktop"
      }, _react.default.createElement(_LeftMaxContent.default, {
        display: n,
        boxList: boxList,
        closeBox: this.closeBox,
        calcCenterStyle: this.calcCenterStyle,
        activeKey: a,
        onTabChange: this.onLeftTabChange
      }), !n && _react.default.createElement(_LeftMinContent.default, {
        display: !n,
        boxList: boxList,
        openBox: this.openBox,
        calcCenterStyle: this.calcCenterStyle
      }), _react.default.createElement("div", {
        className: "main-view"
      }, o || _react.default.createElement(_home.default, null)), _react.default.createElement(_RightMaxContent.default, {
        display: r,
        boxList: boxRightList,
        closeBox: this.closeBox,
        calcCenterStyle: this.calcCenterStyle,
        activeKey: i,
        onTabChange: this.onRightTabChange
      }), !r && _react.default.createElement(_RightMinContent.default, {
        display: n,
        boxList: boxRightList,
        openBox: this.openBox,
        calcCenterStyle: this.calcCenterStyle
      }))));
    }
  } ]), r;
}(_react.Component);

RootView.displayName = "RootView", RootView.propTypes = {
  children: _propTypes.default.node,
  isLoginout: _propTypes.default.bool
};

var _default = RootView;

exports.default = _default;