"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var _index2 = require("../koi-SlotMachine/index");
var _index3 = require("../yellow-SlotMachine/index");
var _index4 = require("../SlotMachine/index");
var _index5 = require("../Purple-SlotMachine/index");
var _index6 = require("../blue-SlotMachine/index");
var _LuckDrawSucc = _interopRequireDefault(require("../../common/LuckDrawSucc"));
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; }
// import { Component, createElement, useState, RefObject } from 'react';
// 锦鲤

// 黄色系列

var triger = function triger(koiSlotMachinProps) {
  var data = (0, _extends2["default"])({}, koiSlotMachinProps);
  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useState = (0, React.useState)({
      isOpenPrize: false,
      countPrized: 2,
      prizeTextList: {
        icon: 'prize',
        msg: '恭喜您中奖啦!',
        prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
      }
    }),
    state = _useState[0],
    setState = _useState[1];
  var btnState = function btnState(prize, message) {
    var _prize$imgs, _prize$imgs$, _prize$imgs2, _prize$imgs2$;
    console.log('11111', prize);
    // let winMessage;
    // if (prize.imgs && prize.imgs[1].src) {
    //   winMessage = prize.imgs[1].src
    // } else if (prize.imgs && prize.imgs[0].src) {
    //   winMessage = prize.imgs[0].src
    // }
    // console.log("winMessage", winMessage)
    setState({
      countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize,
      prizeTextList: {
        icon: prize.imgs && (((_prize$imgs = prize.imgs) === null || _prize$imgs === void 0 ? void 0 : (_prize$imgs$ = _prize$imgs[1]) === null || _prize$imgs$ === void 0 ? void 0 : _prize$imgs$.src) || ((_prize$imgs2 = prize.imgs) === null || _prize$imgs2 === void 0 ? void 0 : (_prize$imgs2$ = _prize$imgs2[0]) === null || _prize$imgs2$ === void 0 ? void 0 : _prize$imgs2$.src)),
        msg: message,
        prizeLv: [prize.fonts && prize.fonts[0].text, '']
      }
    });
  };
  var subtract = function subtract() {
    if (state.countPrized > 0) {
      setState({
        countPrized: --state.countPrized
      });
    }
  };
  var isOpenPrize = state.isOpenPrize,
    prizeTextList = state.prizeTextList,
    countPrized = state.countPrized;
  var trigerType = data.trigerType;
  var renderApp = function renderApp() {
    if (trigerType === 1) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index2.MySlotMachineChild, {
        data: data
      }));
    } else if (trigerType === 2) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index3.MySlotMachineChild02, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    } else if (trigerType === 3) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index4.MySlotMachineChild03, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    } else if (trigerType === 4) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index5.MySlotMachineChild04, {
        data: data
      }));
    } else if (trigerType === 5) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index6.MySlotMachineChild05, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    }
  };
  return /*#__PURE__*/React.createElement("div", null, renderApp());
};
var _default = triger;
exports["default"] = _default;