react-luck-draw
Version:
react抽奖插件
17 lines (14 loc) • 38.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactLuckDraw={},t.React)}(this,(function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=n(e);function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function d(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=l(t);if(e){var r=l(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p(this,n)}}var g=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function i(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function o(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function a(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),r=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var i=arguments[1],r=0;r<n;){var o=e[r];if(t.call(i,o,r,e))return o;r++}}});var u=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},c=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;var e;if(/^rgba/.test(t)&&0===(null===(e=/([^\s,]+)\)$/.exec(t))?0:"object"==typeof e?NaN:"number"==typeof e?e:"string"==typeof e?"%"===e[e.length-1]?Number(e.slice(0,-1))/100:Number(e):NaN))return!1;return!0},l=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),f="__proto__"in{};function p(t,e,n,i){Object.defineProperty(t,e,{value:n,enumerable:!!i,writable:!0,configurable:!0})}var d=Array.prototype,g=Object.create(d);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){g[t]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=d[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),i}}));var y=function(){function t(t){this.dep=new l,p(t,"__luckyOb__",this),Array.isArray(t)&&(f?t.__proto__=g:Object.getOwnPropertyNames(g).forEach((function(e){p(t,e,g[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){m(t,e,t[e])}))},t}();function v(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new y(t)}function m(t,e,n){var i=new l,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(n=t[e]);var a=v(n);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):n;return l.target&&(i.addSub(l.target),a&&a.dep.addSub(l.target)),e},set:function(e){e!==n&&(n=e,o&&!s||(s?s.call(t,e):n=e,a=v(e),i.notify()))}})}}var b=0,w=function(){function t(t,e,n,i){void 0===i&&(i={}),this.id=b++,this.$lucky=t,this.expr=e,this.deep=!!i.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],n="",i=0;i<t.length;i++){var r=t[i];if(/\[|\./.test(r))e.push(n),n="";else{if(/\W/.test(r))continue;n+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=n,this.value=this.get()}return t.prototype.get=function(){l.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){u(t,"array","object")&&Object.keys(t).forEach((function(n){var i=t[n];e(i)}))};e(t)}(t),l.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),k=function(){function t(t){var e=this;this.htmlFontSize=16,this.rAF=function(){},this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.setDpr(),this.initWindowFunction(),t.flag||(t.flag="WEB"),Object.prototype.hasOwnProperty.call(t,"ob")||(t.ob=!0),t.el&&(t.divElement=document.querySelector(t.el));var n=0,i=0;t.divElement&&(n=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||n,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.5.2"),t.canvasElement.addEventListener("click",(function(t){return e.handleClick(t)})),t.canvasElement.addEventListener("mousemove",(function(t){return e.handleMouseMove(t)})),t.canvasElement.addEventListener("mousedown",(function(t){return e.handleMouseDown(t)})),t.canvasElement.addEventListener("mouseup",(function(t){return e.handleMouseUp(t)}))),this.ctx=t.ctx,t.ctx&&t.width&&t.height||console.error("无法获取到 CanvasContext2D 或宽高")}return t.prototype.handleClick=function(t){},t.prototype.handleMouseDown=function(t){},t.prototype.handleMouseUp=function(t){},t.prototype.handleMouseMove=function(t){},t.prototype.conversionAxis=function(t,e){return[0,0]},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame,t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,n=t.canvasElement,i=t.dpr,r=function(t){return(t*i-t)/(t*i)*(i/2)*100};n&&(n.width=t.width*i,n.height=t.height*i,n.style.width=n.width+"px",n.style.height=n.height+"px",n.style.transform="scale("+1/i+") translate(\n "+-r(n.width)+"%, "+-r(n.height)+"%\n )",e.scale(i,i))},t.prototype.loadImg=function(t,e,n){var i=this;return void 0===n&&(n="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"===i.config.flag){var s=new Image;s.src=t,s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")}}else e[n]=r}))},t.prototype.drawImage=function(t,e,n,i,r){var o,s=this.config,a=this.ctx;return["WEB","MP-WX"].includes(s.flag)?o=t:["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s.flag)&&(o=t.path),a.drawImage(o,e,n,i,r)},t.prototype.getLength=function(t){return u(t,"number")?t:u(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var n=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,i,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*n.htmlFontSize}}[r];if(o)return o(i);var s=n.config.unitFunc;return s?s(i,r):i})))},t.prototype.$set=function(t,e,n){t&&"object"==typeof t&&m(t,e,n)},t.prototype.$computed=function(t,e,n){var i=this;Object.defineProperty(t,e,{get:function(){return n.call(i)}})},t.prototype.$watch=function(t,e,n){void 0===n&&(n={}),"object"==typeof e&&(e=(n=e).handler);var i=new w(this,t,e,n);return n.immediate&&e.call(this,i.value),function(){}},t}(),z=function(t){return Math.PI/180*t},S=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},I=function(t,e){var n=-t/e;return[n,-n*t+e]},x=function(t,e,n,i,r,o){var s;if(void 0===o&&(o=!0),Math.abs(r-i).toFixed(8)>=z(180).toFixed(8)){var a=(r+i)/2;return o?(x(t,e,n,i,a,o),x(t,e,n,a,r,o)):(x(t,e,n,a,r,o),x(t,e,n,i,a,o)),!1}o||(i=(s=[r,i])[0],r=s[1]);var u=S(i,n),c=u[0],h=u[1],l=S(r,n),f=l[0],p=l[1],d=I(c,h),g=d[0],y=d[1],v=I(f,p),m=v[0],b=v[1],w=(b-y)/(g-m),k=(m*y-g*b)/(m-g);isNaN(w)&&(Math.abs(c)===+n.toFixed(8)&&(w=c),Math.abs(f)===+n.toFixed(8)&&(w=f)),g===1/0||g===-1/0?k=m*w+b:m!==1/0&&m!==-1/0||(k=g*w+y),e.lineTo(c,h),t.indexOf("MP")>0?e.quadraticCurveTo(w,k,f,p):e.arcTo(w,k,f,p,n)},O=function(t,e,n,i,r,o,s){var a=Math.min(i,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,n),t.lineTo(e+o,n),t.lineTo(e+i-o,n),t.quadraticCurveTo(e+i,n,e+i,n+o),t.lineTo(e+i,n+r-o),t.quadraticCurveTo(e+i,n+r,e+i-o,n+r),t.lineTo(e+o,n+r),t.quadraticCurveTo(e,n+r,e,n+r-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath(),t.fill()},C={easeIn:function(t,e,n,i){return t>=i&&(t=i),n*(t/=i)*t+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),-n*(t/=i)*(t-2)+e}},T={easeIn:function(t,e,n,i){return t>=i&&(t=i),-n*Math.cos(t/i*(Math.PI/2))+n+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),n*Math.sin(t/i*(Math.PI/2))+e}},E={easeIn:function(t,e,n,i){return t>=i&&(t=i),0==t?e:n*Math.pow(2,10*(t/i-1))+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),t==i?e+n:n*(1-Math.pow(2,-10*t/i))+e}},P={easeIn:function(t,e,n,i){return t>=i&&(t=i),-n*(Math.sqrt(1-(t/=i)*t)-1)+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),n*Math.sqrt(1-(t=t/i-1)*t)+e}},_=Object.freeze({__proto__:null,quad:C,cubic:{easeIn:function(t,e,n,i){return t>=i&&(t=i),n*(t/=i)*t*t+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),n*((t=t/i-1)*t*t+1)+e}},quart:{easeIn:function(t,e,n,i){return t>=i&&(t=i),n*(t/=i)*t*t*t+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),-n*((t=t/i-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,n,i){return t>=i&&(t=i),n*(t/=i)*t*t*t*t+e},easeOut:function(t,e,n,i){return t>=i&&(t=i),n*((t=t/i-1)*t*t*t*t+1)+e}},sine:T,expo:E,circ:P}),D=function(t){function e(e,n){void 0===n&&(n={});var i=t.call(this,e)||this;return i.blocks=[],i.prizes=[],i.buttons=[],i.defaultConfig={},i._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:.8},i.defaultStyle={},i._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",lineHeight:"",background:"transparent",wordWrap:!0,lengthLimit:"90%"},i.Radius=0,i.prizeRadius=0,i.prizeDeg=0,i.prizeRadian=0,i.rotateDeg=0,i.maxBtnRadius=0,i.startTime=0,i.endTime=0,i.stopDeg=0,i.endDeg=0,i.FPS=16.6,i.blockImgs=[[]],i.prizeImgs=[[]],i.btnImgs=[[]],e.ob&&(i.initData(n),i.initWatch()),i.initComputed(),i.init({blockImgs:i.blocks.map((function(t){return t.imgs})),prizeImgs:i.prizes.map((function(t){return t.imgs})),btnImgs:i.buttons.map((function(t){return t.imgs}))}),i}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return r({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:.8},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return r({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"transparent",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("blocks",(function(e){return t.init({blockImgs:e.map((function(t){return t.imgs}))})}),{deep:!0}),this.$watch("prizes",(function(e){return t.init({prizeImgs:e.map((function(t){return t.imgs}))})}),{deep:!0}),this.$watch("buttons",(function(e){return t.init({btnImgs:e.map((function(t){return t.imgs}))})}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init({})})),this.$watch("endCallback",(function(){return t.init({})}))},e.prototype.init=function(t){var e,n,i=this,r=this.config,o=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(r.width,r.height)/2,null===(e=r.beforeInit)||void 0===e||e.call(this),o.translate(this.Radius,this.Radius),this.draw(),Object.keys(t).forEach((function(e){var n=e,r={blockImgs:"blocks",prizeImgs:"prizes",btnImgs:"buttons"}[n],o=t[n];o&&o.forEach((function(t,e){t&&t.forEach((function(t,o){i.loadAndCacheImg(r,e,n,o,(function(){i.draw()}))}))}))})),null===(n=r.afterInit)||void 0===n||n.call(this)},e.prototype.handleClick=function(t){var e,n=this.ctx;n.beginPath(),n.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,n,i,r){return o(this,void 0,void 0,(function(){var o,a,u=this;return s(this,(function(s){return(o=this[t][e])&&o.imgs&&(a=o.imgs[i])?(this[n][e]||(this[n][e]=[]),this.loadImg(a.src,a).then((function(t){u[n][e][i]=t,r.call(u)})).catch((function(n){console.error(t+"["+e+"].imgs["+i+"] "+n)})),[2]):[2]}))}))},e.prototype.computedWidthAndHeight=function(t,e,n,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,n);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,i);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,n),this.getHeight(e.height,i)]},e.prototype.draw=function(){var t,e,n=this,i=this,r=i.config,o=i.ctx,s=i._defaultConfig,a=i._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,i){return h(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){if(n.blockImgs[i]){var s=n.blockImgs[i][r];if(s){var a=n.computedWidthAndHeight(s,e,2*t,2*t),u=a[0],c=a[1],h=[n.getOffsetX(u),n.getHeight(e.top,2*t)-t],l=h[0],f=h[1];o.save(),e.rotate&&o.rotate(z(n.rotateDeg)),n.drawImage(s,l,f,u,c),o.restore()}}})),t-n.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=z(this.prizeDeg);var u=z(-90+this.rotateDeg+s.offsetDegree),l=function(t){return n.getOffsetX(o.measureText(t).width)},f=function(t,e,i){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return n.getHeight(t.top,e)+(i+1)*n.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var i=u+e*n.prizeRadian,p=n.prizeRadius-n.maxBtnRadius,d=t.background||a.background;h(d)&&function(t,e,n,i,r,o,s,a){s?function(t,e,n,i,r,o,s,a){n||(n=s);var u=z(90/Math.PI/i*s),c=z(90/Math.PI/n*s),h=r+u,l=o-u,f=r+c,p=o-c;e.beginPath(),e.fillStyle=a,e.moveTo.apply(e,S(h,i)),x(t,e,i,h,l,!0),p>f?x(t,e,n,f,p,!1):e.lineTo.apply(e,S((r+o)/2,s/2/Math.abs(Math.sin((r-o)/2)))),e.closePath(),e.fill()}(t,e,n,i,r,o,s,a):(e.beginPath(),e.fillStyle=a,e.moveTo(0,0),e.arc(0,0,i,r,o,!1),e.closePath(),e.fill())}(r.flag,o,n.maxBtnRadius,n.prizeRadius,i-n.prizeRadian/2,i+n.prizeRadian/2,n.getLength(s.gutter),d);var g=Math.cos(i)*n.prizeRadius,y=Math.sin(i)*n.prizeRadius;o.translate(g,y),o.rotate(i+z(90)),t.imgs&&t.imgs.forEach((function(t,i){if(n.prizeImgs[e]){var r=n.prizeImgs[e][i];if(r){var o=n.computedWidthAndHeight(r,t,n.prizeRadian*n.prizeRadius,p),s=o[0],a=o[1],u=[n.getOffsetX(s),n.getHeight(t.top,p)],c=u[0],h=u[1];n.drawImage(r,c,h,s,a)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,i=t.fontWeight||a.fontWeight,r=n.getLength(t.fontSize||a.fontSize),u=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=i+" "+(r>>0)+"px "+u;var h=[],d=String(t.text);if(Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap){d=c(d);for(var g="",y=0;y<d.length;y++){g+=d[y];var v=o.measureText(g).width,m=(n.prizeRadius-f(t,p,h.length))*Math.tan(n.prizeRadian/2)*2-n.getLength(s.gutter);v>n.getWidth(t.lengthLimit||a.lengthLimit,m)&&(h.push(g.slice(0,-1)),g=d[y])}g&&h.push(g),h.length||h.push(d)}else h=d.split("\n");h.filter((function(t){return!!t})).forEach((function(e,n){o.fillText(e,l(e),f(t,p,n))}))})),o.rotate(z(360)-i-z(90)),o.translate(-g,-y)})),o.restore(),this.buttons.forEach((function(t,e){var i=n.getHeight(t.radius);n.maxBtnRadius=Math.max(n.maxBtnRadius,i),h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,i,0,2*Math.PI,!1),o.fill()),t.pointer&&h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-i,0),o.lineTo(i,0),o.lineTo(0,2*-i),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){if(n.btnImgs[e]){var o=n.btnImgs[e][r];if(o){var s=n.computedWidthAndHeight(o,t,2*i,2*i),a=s[0],u=s[1],c=[n.getOffsetX(a),n.getHeight(t.top,i)],h=c[0],l=c[1];n.drawImage(o,h,l,a,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=n.getLength(t.fontSize||a.fontSize),u=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+u,String(t.text).split("\n").forEach((function(e,n){o.fillText(e,l(e),f(t,i,n))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t<0?-1:t%this.prizes.length,-1===this.prizeFlag&&(this.rotateDeg=this.prizeDeg/2-this._defaultConfig.offsetDegree,this.draw())},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,n=e.rAF,i=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==i){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var u=(Math.random()*r-r/2)*this.getLength(s.stopRange),c=0;++c;){var h=360*c-i*r-o-s.offsetDegree+u;if(_[s.speedFunction].easeOut(this.FPS,this.stopDeg,h,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=h;break}}return this.slowDown()}this.rotateDeg=(o+_[s.speedFunction].easeIn(a,0,s.speed,s.accelerationTime))%360,this.draw(),n(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,n=e.rAF,i=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,u=e._defaultConfig,c=Date.now()-this.endTime;if(-1!==o){if(c>=u.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,r({},i.find((function(t,e){return e===o})))));this.rotateDeg=_[u.speedFunction].easeOut(c,s,a,u.decelerationTime)%360,this.draw(),n(this.slowDown.bind(this))}else this.startTime=0},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),u(t,"number")?t:u(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),u(t,"number")?t:u(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var n=this.config;return[t/n.dpr-this.Radius,e/n.dpr-this.Radius]},e}(k),$=function(t){function e(e,n){void 0===n&&(n={});var i=t.call(this,e)||this;i.rows=3,i.cols=3,i.blocks=[],i.prizes=[],i.buttons=[],i.defaultConfig={},i._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},i.defaultStyle={},i._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",lineHeight:"",background:"transparent",shadow:"",wordWrap:!0,lengthLimit:"90%"},i.activeStyle={},i._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},i.cellWidth=0,i.cellHeight=0,i.startTime=0,i.endTime=0,i.currIndex=0,i.stopIndex=0,i.endIndex=0,i.demo=!1,i.timer=0,i.FPS=16.6,i.prizeFlag=-1,i.cells=[],i.blockImgs=[[]],i.btnImgs=[[]],i.prizeImgs=[],e.ob&&(i.initData(n),i.initWatch()),i.initComputed();var r=i.buttons.map((function(t){return t.imgs}));return i.button&&r.push(i.button.imgs),i.init({blockImgs:i.blocks.map((function(t){return t.imgs})),prizeImgs:i.prizes.map((function(t){return t.imgs})),btnImgs:r}),i}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=r({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return r({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"transparent",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return r({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("blocks",(function(e){return t.init({blockImgs:e.map((function(t){return t.imgs}))})}),{deep:!0}),this.$watch("prizes",(function(e){return t.init({prizeImgs:e.map((function(t){return t.imgs}))})}),{deep:!0}),this.$watch("buttons",(function(e){var n=e.map((function(t){return t.imgs}));return t.button&&n.push(t.button.imgs),t.init({btnImgs:n})}),{deep:!0}),this.$watch("button",(function(){var e=t.buttons.map((function(t){return t.imgs}));return t.button&&e.push(t.button.imgs),t.init({btnImgs:e})}),{deep:!0}),this.$watch("rows",(function(){return t.init({})})),this.$watch("cols",(function(){return t.init({})})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init({})})),this.$watch("endCallback",(function(){return t.init({})}))},e.prototype.init=function(t){var e,n,i=this,r=this,o=r.config;r.ctx,r.button,this.setHTMLFontSize(),this.setDpr(),this.zoomCanvas(),null===(e=o.beforeInit)||void 0===e||e.call(this),this.draw(),Object.keys(t).forEach((function(e){var n=e,r=t[n],o={blockImgs:"blocks",prizeImgs:"prizes",btnImgs:"buttons"}[n];r&&r.forEach((function(t,e){t&&t.forEach((function(t,r){i.loadAndCacheImg(o,e,n,r,(function(){i.draw()}))}))}))})),null===(n=o.afterInit)||void 0===n||n.call(this)},e.prototype.handleClick=function(t){var e=this,n=this.ctx;a(this.buttons,[this.button]).forEach((function(i){var r;if(i){var o=e.getGeometricProperty([i.x,i.y,i.col||1,i.row||1]),s=o[0],a=o[1],u=o[2],c=o[3];n.beginPath(),n.rect(s,a,u,c),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(r=e.startCallback)||void 0===r||r.call(e,t))}}))},e.prototype.loadAndCacheImg=function(t,e,n,i,r){return o(this,void 0,void 0,(function(){var o,a,u,c=this;return s(this,(function(s){return o=this[t][e],"buttons"===t&&!this.buttons.length&&this.button&&(o=this.button),o&&o.imgs&&(a=o.imgs[i])?(this[n][e]||(this[n][e]=[]),u=[this.loadImg(a.src,a),a.activeSrc&&this.loadImg(a.activeSrc,a,"$activeResolve")],Promise.all(u).then((function(t){var o=t[0],s=t[1];c[n][e][i]={defaultImg:o,activeImg:s},r.call(c)})).catch((function(n){console.error(t+"["+e+"].imgs["+i+"] "+n)})),[2]):[2]}))}))},e.prototype.computedWidthAndHeight=function(t,e,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var i=this.getWidth(e.width,n.col);return[i,t.height*(i/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,n.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,n.col),this.getHeight(e.height,n.row)]},e.prototype.draw=function(){var t,e,n=this,i=this,r=i.config,o=i.ctx,s=i._defaultConfig,l=i._defaultStyle,f=i._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,r.width,r.height),this.cells=a(this.prizes,this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var i=t.x,r=t.y,s=t.w,a=t.h,c=function(t){var e,n=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],i=0,r=0,o=0,s=0;switch(n.length){case 1:i=r=o=s=n[0];break;case 2:i=r=n[0],o=s=n[1];break;case 3:i=n[0],o=s=n[1],r=n[2];break;default:i=n[0],r=n[1],o=n[2],s=n[3]}var a={paddingTop:i,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var c in a)a[c]=Object.prototype.hasOwnProperty.call(t,c)&&u(t[c],"string","number")?~~String(t[c]).replace(/px/g,""):a[c];return[i,r,o,s]}(e),f=c[0],p=c[1],d=c[2],g=c[3],y=e.borderRadius?n.getLength(e.borderRadius):0,v=e.background||l.background;return h(v)&&O(o,i,r,s,a,y,n.handleBackground(i,r,s,a,v)),{x:i+d,y:r+f,w:s-d-g,h:a-f-p}}),{x:0,y:0,w:r.width,h:r.height}),this.cellWidth=(this.prizeArea.w-s.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-s.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var i=n.getGeometricProperty([t.x,t.y,t.col,t.row]),s=i[0],a=i[1],u=i[2],p=i[3],d=!1;(void 0===n.prizeFlag||n.prizeFlag>-1)&&(d=e===n.currIndex%n.prizes.length>>0);var g=d?f.background:t.background||l.background;if(h(g)){var y=(d?f.shadow:t.shadow||l.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===y.length&&(o.shadowColor=y[3],o.shadowOffsetX=y[0]*r.dpr,o.shadowOffsetY=y[1]*r.dpr,o.shadowBlur=y[2],y[0]>0?u-=y[0]:(u+=y[0],s-=y[0]),y[1]>0?p-=y[1]:(p+=y[1],a-=y[1])),O(o,s,a,u,p,n.getLength(t.borderRadius?t.borderRadius:l.borderRadius),n.handleBackground(s,a,u,p,g)),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizeImgs";e>=n.prizes.length&&(v="btnImgs",e-=n.prizes.length),t.imgs&&t.imgs.forEach((function(i,r){if(n[v][e]){var o=n[v][e][r];if(o){var u=d&&o.activeImg||o.defaultImg;if(u){var c=n.computedWidthAndHeight(u,i,t),h=c[0],l=c[1],f=[s+n.getOffsetX(h,t.col),a+n.getHeight(i.top,t.row)],p=f[0],g=f[1];n.drawImage(u,p,g,h,l)}}}})),t.fonts&&t.fonts.forEach((function(e){var i=d&&f.fontStyle?f.fontStyle:e.fontStyle||l.fontStyle,r=d&&f.fontWeight?f.fontWeight:e.fontWeight||l.fontWeight,u=d&&f.fontSize?n.getLength(f.fontSize):n.getLength(e.fontSize||l.fontSize),h=d&&f.lineHeight?f.lineHeight:e.lineHeight||l.lineHeight||e.fontSize||l.fontSize;o.font=r+" "+(u>>0)+"px "+i,o.fillStyle=d&&f.fontColor?f.fontColor:e.fontColor||l.fontColor;var p=[],g=String(e.text);if(Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:l.wordWrap){g=c(g);for(var y="",v=0;v<g.length;v++)y+=g[v],o.measureText(y).width>n.getWidth(e.lengthLimit||l.lengthLimit,t.col)&&(p.push(y.slice(0,-1)),y=g[v]);y&&p.push(y),p.length||p.push(g)}else p=g.split("\n");p.forEach((function(i,r){o.fillText(i,s+n.getOffsetX(o.measureText(i).width,t.col),a+n.getHeight(e.top,t.row)+(r+1)*n.getLength(h))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,n,i,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,n,i,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),u=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?u=[e,n+r,e+i,n+r-i*c(a-0)]:a>=45&&a<90?u=[e,n+r,e+i-r*c(a-45),n]:a>=90&&a<135?u=[e+i,n+r,e+i-r*c(a-90),n]:a>=135&&a<180?u=[e+i,n+r,e,n+i*c(a-135)]:a>=180&&a<225?u=[e+i,n,e,n+i*c(a-180)]:a>=225&&a<270?u=[e+i,n,e+r*c(a-225),n+r]:a>=270&&a<315?u=[e,n,e+r*c(a-270),n+r]:a>=315&&a<360&&(u=[e,n,e+i,n+r-i*c(a-315)])}else a.includes("top")?u=[e,n+r,e,n]:a.includes("bottom")?u=[e,n,e,n+r]:a.includes("left")?u=[e+i,n,e,n]:a.includes("right")&&(u=[e,n,e+i,n]);var h=t.createLinearGradient.apply(t,u.map((function(t){return t>>0})));return s.reduce((function(t,e,n){var i=e.split(" ");return 1===i.length?t.addColorStop(n,i[0]):2===i.length&&t.addColorStop.apply(t,i),t}),h)}(o,t,e,n,i,r)),r},e.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t<0?-1:t%this.prizes.length,-1===this.prizeFlag&&(this.currIndex=0,this.draw())},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,n=e.rAF,i=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,u=Date.now()-s;if(u>=a.accelerationTime&&void 0!==o){this.FPS=u/t,this.endTime=Date.now(),this.stopIndex=i;for(var c=0;++c;){var h=r.length*c+o-(i>>0);if(C.easeOut(this.FPS,this.stopIndex,h,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=h;break}}return this.slowDown()}this.currIndex=(i+C.easeIn(u,.1,a.speed,a.accelerationTime))%r.length,this.draw(),n(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,n=e.rAF,i=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,u=e._defaultConfig,c=Date.now()-this.endTime;if(-1!==o){if(c>u.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,r({},i.find((function(t,e){return e===o})))));this.currIndex=C.easeOut(c,s,a,u.decelerationTime)%i.length,this.draw(),n(this.slowDown.bind(this))}else this.startTime=0},e.prototype.walk=function(){var t=this,e=this.config,n=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=n((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],n=t[1],i=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,u=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*n];return i&&r&&u.push(o*i+a*(i-1),s*r+a*(r-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),u(t,"number")?t:u(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),u(t,"number")?t:u(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e.prototype.conversionAxis=function(t,e){var n=this.config;return[t/n.dpr,e/n.dpr]},e}(k);e.LuckyGrid=$,e.LuckyWheel=D})),y="react-luck-draw",v="1.0.1",m=function(t){h(n,t);var e=d(n);function n(t){var o;return r(this,n),(o=e.call(this,t)).myLucky=i.default.createRef(),o}return s(n,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(y,"@").concat(v));try{this.init(),t.onSuccess&&t.onSuccess()}catch(e){t.onError&&t.onError(e)}finally{t.onFinally&&t.onFinally(err)}}},{key:"componentDidUpdate",value:function(t){this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.buttons!==t.buttons&&(this.$lucky.buttons=this.props.buttons)}},{key:"init",value:function(){var t=this.props;console.log(t),this.$lucky=new g.LuckyWheel({flag:"WEB",width:t.width,height:t.height,divElement:this.myLucky.current},c(c({},t),{},{start:function(){t.onStart&&t.onStart.apply(t,arguments)},end:function(){t.onEnd&&t.onEnd.apply(t,arguments)}}))}},{key:"play",value:function(){var t;(t=this.$lucky).play.apply(t,arguments)}},{key:"stop",value:function(){var t;(t=this.$lucky).stop.apply(t,arguments)}},{key:"render",value:function(){return i.default.createElement("div",{ref:this.myLucky})}}]),n}(i.default.Component);m.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var b=function(t){h(n,t);var e=d(n);function n(t){var o;return r(this,n),(o=e.call(this,t)).myLucky=i.default.createRef(),o}return s(n,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(y,"@").concat(v));try{this.init(),t.onSuccess&&t.onSuccess()}catch(e){t.onError&&t.onError(e)}finally{t.onFinally&&t.onFinally(err)}}},{key:"componentDidUpdate",value:function(t){this.props.cols!==t.cols&&(this.$lucky.cols=this.props.cols),this.props.rows!==t.rows&&(this.$lucky.rows=this.props.rows),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.buttons!==t.buttons&&(this.$lucky.buttons=this.props.buttons)}},{key:"init",value:function(){var t=this.props;this.$lucky=new g.LuckyGrid({flag:"WEB",width:t.width,height:t.height,divElement:this.myLucky.current},c(c({},t),{},{start:function(){t.onStart&&t.onStart.apply(t,arguments)},end:function(){t.onEnd&&t.onEnd.apply(t,arguments)}}))}},{key:"play",value:function(){var t;(t=this.$lucky).play.apply(t,arguments)}},{key:"stop",value:function(){var t;(t=this.$lucky).stop.apply(t,arguments)}},{key:"render",value:function(){return i.default.createElement("div",{ref:this.myLucky})}}]),n}(i.default.Component);b.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}},t.LuckyGrid=b,t.LuckyWheel=m,Object.defineProperty(t,"__esModule",{value:!0})}));