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

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

import React from 'react';
import { defaultImage } from '../../../assets/IconBase64';
import MagicBox from '../../../core/MagicBox';
import MBaseComponent from '../../MBaseComponent';
/**
 * @class MImg 图片
 * @author zhang.xiaofei38@iwhalecloud.com
 */

var MImg = /*#__PURE__*/function (_MBaseComponent) {
  _inherits(MImg, _MBaseComponent);

  var _super = _createSuper(MImg);

  /**
   * @required
   * React 会根据 type 动态创建组件的实例。
   */
  function MImg(props) {
    _classCallCheck(this, MImg);

    return _super.call(this, props);
  }

  _createClass(MImg, [{
    key: "render",
    value: function render() {
      var _this = this;

      var tempProps = _objectSpread({}, this.props, {
        isLeaf: true,
        onComponentClick: this.onComponentClick,
        style: {// background: '#fff',
        }
      });

      console.log(tempProps, 323232);
      var imgStyle = {
        minWidth: '24px',
        minHeight: '24px',
        width: '100%',
        height: '100%'
      };

      if (this.props.mode === 'designer' && !(tempProps.imgList && tempProps.imgList[0] && tempProps.imgList[0].imgUrl)) {
        imgStyle.height = '50px';
      }

      if (tempProps.terminalType === 'pc' && tempProps.mode !== 'designer') {
        tempProps.style = {
          width: '1200px',
          margin: 'auto'
        };
      }

      return /*#__PURE__*/React.createElement(MagicBox, tempProps, /*#__PURE__*/React.createElement("div", {
        style: {
          position: 'relative'
        }
      }, /*#__PURE__*/React.createElement("img", {
        onClick: function onClick() {
          return _this.clickItem(tempProps.imgList && tempProps.imgList[0] && tempProps.imgList[0].link);
        },
        style: imgStyle,
        src: tempProps.imgList && tempProps.imgList[0] && tempProps.imgList[0].imgUrl || defaultImage,
        alt: tempProps.alt || '',
        draggable: false
      }), tempProps.coordinates && tempProps.coordinates.map(function (v, i) {
        var aStyle = {
          position: 'absolute',
          top: v.y,
          left: v.x,
          width: v.width,
          height: v.height
        };
        return /*#__PURE__*/React.createElement("a", {
          href: v.inputVal,
          key: i,
          style: aStyle
        });
      })));
    }
  }]);

  return MImg;
}(MBaseComponent);

_defineProperty(MImg, "type", 'MImg');

export { MImg as default };