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); }

import { Button, Select } from '@whalecloud/fdx';
import React, { Component } from 'react';
import { PCIcon, PhoneIcon, platformIcon } from '../../assets/IconBase64';
import './index.less';

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

  var _super = _createSuper(TopBar);

  function TopBar() {
    _classCallCheck(this, TopBar);

    return _super.apply(this, arguments);
  }

  _createClass(TopBar, [{
    key: "doSwitch",
    value: function doSwitch(event) {
      var renderer = event.currentTarget.dataset.renderer;
      this.props.switchRenderer && this.props.switchRenderer(renderer);
    }
  }, {
    key: "render",
    value: function render() {
      var ButtonGroup = Button.Group;
      var Option = Select.Option;
      var _this$props = this.props,
          renderer = _this$props.renderer,
          readonly = _this$props.readonly;
      var readOnlyTip = 'The page is in use. Please copy or create a new page.';
      return /*#__PURE__*/React.createElement("div", {
        className: "topBar"
      }, /*#__PURE__*/React.createElement("div", {
        className: "titleContainer"
      }, /*#__PURE__*/React.createElement("img", {
        alt: "",
        src: platformIcon
      }), /*#__PURE__*/React.createElement("p", null, "Magic Box")), /*#__PURE__*/React.createElement("div", {
        className: "btnContainer"
      }, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
        "data-renderer": "pc",
        type: renderer === 'pc' ? 'primary' : '',
        onClick: this.doSwitch.bind(this)
      }, /*#__PURE__*/React.createElement("img", {
        alt: "",
        src: PCIcon,
        className: "iconImg"
      })), /*#__PURE__*/React.createElement(Button, {
        "data-renderer": "mobile",
        type: renderer === 'mobile' ? 'primary' : '',
        onClick: this.doSwitch.bind(this)
      }, /*#__PURE__*/React.createElement("img", {
        alt: "",
        src: PhoneIcon,
        className: "iconImg"
      })))), /*#__PURE__*/React.createElement("div", {
        className: "iconContainer"
      }, renderer === 'mobile' && /*#__PURE__*/React.createElement(Select, {
        style: {
          marginRight: 100
        },
        defaultValue: "iPhone",
        onChange: this.props.onChangeSelect
      }, /*#__PURE__*/React.createElement(Option, {
        value: "iPhone"
      }, "iPhone"), /*#__PURE__*/React.createElement(Option, {
        value: "Huawei"
      }, "Huawei"), /*#__PURE__*/React.createElement(Option, {
        value: "OPPO"
      }, "OPPO"), /*#__PURE__*/React.createElement(Option, {
        value: "VIVO"
      }, "VIVO")), /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
        title: "Preview",
        icon: "eye",
        onClick: this.props.onPreview
      }), /*#__PURE__*/React.createElement(Button, {
        title: readonly ? readOnlyTip : 'Publish',
        icon: "to-top",
        disabled: readonly,
        onClick: !readonly && this.props.onPublish
      }), /*#__PURE__*/React.createElement(Button, {
        title: readonly ? readOnlyTip : 'Save, Ctrl+s',
        icon: "save",
        disabled: readonly,
        onClick: !readonly && this.props.onSave
      }), /*#__PURE__*/React.createElement(Button, {
        title: readonly ? readOnlyTip : 'Undo, Ctrl+y',
        icon: "undo",
        disabled: readonly,
        onClick: !readonly && this.props.undo
      }), /*#__PURE__*/React.createElement(Button, {
        title: readonly ? readOnlyTip : 'Redo, Ctrl+z',
        icon: "redo",
        disabled: readonly,
        onClick: !readonly && this.props.redo
      }), /*#__PURE__*/React.createElement(Button, {
        title: readonly ? readOnlyTip : 'Delete, hit Delete key.',
        icon: "delete",
        disabled: readonly,
        onClick: !readonly && this.props.onDelComponent
      }))));
    }
  }]);

  return TopBar;
}(Component);

export { TopBar as default };