import _extends from "@babel/runtime/helpers/extends";
import _Message from "@alifd/next/es/message";
import * as React from 'react';
import { useState } from 'react';
import "./index.scss";
import Shake from "./components/Shake";
import LuckDrawSucc from "../../common/LuckDrawSucc";
var ShakeSingle = function ShakeSingle(_ref) {
  var isBgColor = _ref.isBgColor,
    bgColor = _ref.bgColor,
    opacity = _ref.opacity,
    btnText = _ref.btnText;
  var _wrapStyle = {
    style: {
      // width: size[0].value === undefined ? 'auto' : `${size[0].value}${size[0].unit}`,
      // height: size[1].value === undefined ? 'auto' : `${size[1].value}${size[1].unit}`,
      backgroundColor: isBgColor === false ? 'transparent' : bgColor
    }
  };
  var _pkgStyle = {
    style: {
      opacity: opacity / 100
    }
  };
  var prizeTextList = {
    // icon: '//img.maimairen.com/low-code/components/shake-it/prize.png',
    // icon: 'no-prize',
    icon: 'prize',
    msg: '恭喜您中奖啦!',
    // msg: '很遗憾空无一物',
    prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
    // prizeLv: ['谢谢参于', '']
  };

  var _useState = useState({
      isOpenPrize: false,
      countPrized: 5
    }),
    state = _useState[0],
    setState = _useState[1];
  var btnState = function btnState() {
    setState({
      countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize
    });
  };
  var btnOnclick = function btnOnclick() {
    if (state.countPrized < 1) {
      _Message.error('你剩余的抽奖次数已用完。');
      return;
    }
    setState({
      countPrized: --state.countPrized,
      isOpenPrize: !state.isOpenPrize
    });
  };
  var isOpenPrize = state.isOpenPrize;
  return /*#__PURE__*/React.createElement("div", _extends({
    className: "shake-it"
  }, _wrapStyle), /*#__PURE__*/React.createElement(LuckDrawSucc, {
    btnState: btnState,
    prizeTextList: prizeTextList,
    isOpenPrize: isOpenPrize
  }), /*#__PURE__*/React.createElement(Shake, {
    style: _pkgStyle,
    btnFn: btnOnclick,
    btnText: btnText
  }));
};
export default ShakeSingle;