"use strict";

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

var _ecommerce = require("@whalecloud/ecommerce");

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

var _MagicBox = _interopRequireDefault(require("../../../core/MagicBox"));

var _MBaseComponent2 = _interopRequireDefault(require("../../MBaseComponent"));

require("./index.less");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

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

/**
 * @class MScroll 轮播
 * @author wang.chenye@iwhalecloud.com
 */
var MScroll = /*#__PURE__*/function (_MBaseComponent) {
  _inherits(MScroll, _MBaseComponent);

  var _super = _createSuper(MScroll);

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

    return _super.apply(this, arguments);
  }

  _createClass(MScroll, [{
    key: "render",
    value:
    /**
     * @required
     * React 会根据 type 动态创建组件的实例。
     */
    function render() {
      var _this = this;

      var tempProps = _objectSpread({}, this.props, {
        isLeaf: true,
        onComponentClick: this.onComponentClick
      });

      var dataTest = [{
        productName: 'CHOETECH 便携充电宝',
        id: '$300.00',
        productImageUrl: 'https://img11.360buyimg.com/mobilecms/s300x300_jfs/t25573/21/996335954/251516/593d93a3/5b84ac4cN64654a51.jpg!q70.jpg'
      }, {
        productName: '苹果 iPhone11 备用机',
        id: '$300.00',
        productImageUrl: 'https://img20.360buyimg.com/mobilecms/s300x300_jfs/t1/66959/4/9915/50676/5d789624E6c216310/c669fb95493ddbd3.jpg!q70.jpg'
      }, {
        productName: '朗科 4K超高清 存储卡',
        id: '$300.00',
        productImageUrl: 'https://img30.360buyimg.com/ceco/s300x300_jfs/t1/117526/28/14514/205764/5f32348fE84ce22c1/686f80ea0a4d7121.jpg!q70.jpg'
      }, {
        productName: 'iPad air2 纤薄平板',
        id: '$300.00',
        productImageUrl: 'https://img10.360buyimg.com/mobilecms/s300x300_jfs/t12217/92/2405045951/37323/e77cdda/5a3c98feN6818758f.jpg!q70.jpg'
      }, {
        productName: '爱尔康 恒润乐明 护理液',
        id: '$300.00',
        productImageUrl: 'https://img10.360buyimg.com/ceco/s300x300_jfs/t1/32397/13/12805/60241/5cb8a86eE85d4f52b/f729273f8e028423.jpg!q70.jpg'
      }, {
        productName: '8K全景相机',
        id: '$300.00',
        productImageUrl: 'https://img10.360buyimg.com/mobilecms/s300x300_jfs/t17950/46/380634758/33172/88079172/5a70629bN6af491d5.jpg!q70.jpg'
      }, {
        productName: '大疆 超远图传 4K无人机',
        id: '$300.00',
        productImageUrl: 'https://img14.360buyimg.com/ceco/s300x300_jfs/t1/109080/22/14268/98014/5ea652a0Ea18c0b20/ee848b5502e6d0cf.jpg!q30!q70.jpg'
      }, {
        productName: 'Avalon 强韧防脱 柔顺 洗发水',
        id: '$300.00',
        productImageUrl: 'https://img10.360buyimg.com/mobilecms/s300x300_jfs/t1/92763/23/2284/159616/5dce4479E2d9f80cf/653fe954f9ca6b3e.jpg!q70.jpg'
      }];
      var data = tempProps.productList ? _toConsumableArray(tempProps.productList) : dataTest;
      var _tempProps$imageLocat = tempProps.imageLocation,
          imageLocation = _tempProps$imageLocat === void 0 ? 'Left' : _tempProps$imageLocat;
      return /*#__PURE__*/_react["default"].createElement(_MagicBox["default"], tempProps, /*#__PURE__*/_react["default"].createElement("div", {
        style: tempProps.mode !== 'designer' ? {
          width: '1200px',
          margin: 'auto'
        } : {}
      }, /*#__PURE__*/_react["default"].createElement(_ecommerce.FindGoodThings, {
        imageLocation: imageLocation,
        clickItem: function clickItem(v) {
          return _this.clickItem("/offer-detail/".concat(v.offerId));
        },
        data: data,
        showWidth: "100%",
        imgUrl: tempProps.imgList && tempProps.imgList[0] && tempProps.imgList[0].imgUrl,
        clickHeaderImg: function clickHeaderImg() {
          return _this.clickItem(tempProps.imgList[0] && tempProps.imgList[0].link);
        }
      })));
    }
  }]);

  return MScroll;
}(_MBaseComponent2["default"]);

exports["default"] = MScroll;

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