"use strict";

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

var _fdx = require("@whalecloud/fdx");

var _react = _interopRequireWildcard(require("react"));

var _IconBase = require("../../assets/IconBase64");

require("./index.less");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

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

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

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

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

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

var TopBar = /*#__PURE__*/function (_Component) {
  _inherits(TopBar, _Component);

  var _super = _createSuper(TopBar);

  function TopBar(props) {
    var _this;

    _classCallCheck(this, TopBar);

    _this = _super.call(this, props);
    _this.state = {
      renderer: 'PC'
    };
    return _this;
  }

  _createClass(TopBar, [{
    key: "doSwitch",
    value: function doSwitch(event) {
      var renderer = event.currentTarget.dataset.renderer;
      this.props.switchRenderer && this.props.switchRenderer(renderer);
      this.setState(_objectSpread({}, this.state, {
        renderer: renderer
      }));
    }
  }, {
    key: "render",
    value: function render() {
      var ButtonGroup = _fdx.Button.Group;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "topBar"
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: "titleContainer"
      }, /*#__PURE__*/_react["default"].createElement("img", {
        alt: "",
        src: _IconBase.platformIcon
      }), /*#__PURE__*/_react["default"].createElement("p", null, "Magic Box")), /*#__PURE__*/_react["default"].createElement("div", {
        className: "btnContainer"
      }, /*#__PURE__*/_react["default"].createElement(ButtonGroup, null, /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        "data-renderer": "pc",
        type: this.state.renderer === 'pc' ? 'primary' : '',
        onClick: this.doSwitch.bind(this)
      }, /*#__PURE__*/_react["default"].createElement("img", {
        alt: "",
        src: _IconBase.PCIcon,
        className: "iconImg"
      })), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        "data-renderer": "mobile",
        type: this.state.renderer === 'mobile' ? 'primary' : '',
        onClick: this.doSwitch.bind(this)
      }, /*#__PURE__*/_react["default"].createElement("img", {
        alt: "",
        src: _IconBase.PhoneIcon,
        className: "iconImg"
      })))), /*#__PURE__*/_react["default"].createElement("div", {
        className: "iconContainer"
      }, this.state.renderer === 'mobile' && /*#__PURE__*/_react["default"].createElement(_fdx.Select, {
        style: {
          marginRight: 100
        },
        defaultValue: "iPhone",
        onChange: this.props.onChangeSelect
      }, /*#__PURE__*/_react["default"].createElement(Option, {
        value: "iPhone"
      }, "iPhone"), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "Huawei"
      }, "Huawei"), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "OPPO"
      }, "OPPO"), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "VIVO"
      }, "VIVO")), /*#__PURE__*/_react["default"].createElement(ButtonGroup, null, /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Preview",
        icon: "eye",
        onClick: this.props.onPreview
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Publish",
        icon: "to-top",
        onClick: this.props.onPublish
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Save, Ctrl+s",
        icon: "save",
        onClick: this.props.onSave
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Undo, Ctrl+y",
        icon: "undo",
        onClick: this.props.undo
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Redo, Ctrl+z",
        icon: "redo",
        onClick: this.props.redo
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Delete, hit Delete key.",
        icon: "delete",
        onClick: this.props.onDelComponent
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "View Data,Ctrl+d",
        icon: "tool",
        onClick: this.props.onViewData
      }), /*#__PURE__*/_react["default"].createElement(_fdx.Button, {
        title: "Help, Ctrl+h",
        icon: "question-circle"
      }))));
    }
  }]);

  return TopBar;
}(_react.Component);

exports["default"] = TopBar;