@lucky-canvas/react
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -15,3 +15,3 @@ "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("react"));function i(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function s(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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&&u(t,e)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function l(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function f(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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=c(t);if(e){var r=c(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return l(this,i)}} | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var p=function(t,e){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},p(t,e)};function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var g=function(){return g=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},g.apply(this,arguments)};function v(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function y(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function m(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var w=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},b=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!w(r,"object","array"))return r;t=r}return t},k=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},S=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},z=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},C=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&w(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},x=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},$=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},O=function(t){return Math.PI/180*t},I=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},E=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return I(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},_=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}(),W="__proto__"in{};function P(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var T=Array.prototype,R=Object.create(T);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){R[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=T[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var A=function(){function t(t){this.dep=new _,P(t,"__luckyOb__",this),Array.isArray(t)&&(W?t.__proto__=R:Object.getOwnPropertyNames(R).forEach((function(e){P(t,e,R[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){H(t,e,t[e])}))},t}();function D(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new A(t)}function H(t,e,i){var n=new _,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=D(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return _.target&&(n.addSub(_.target),a&&a.dep.addSub(_.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=D(e),n.notify()))}})}}var F=0,L=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=F++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){_.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){w(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),_.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}(),j=function(){function t(t,e){var i=this;this.version="1.7.6",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.6"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,m([i],n))},t.prototype.getLength=function(t){return w(t,"number")?t:w(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!k(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return E.apply(void 0,m([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&H(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new L(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),M=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},B=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},N=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 g({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return g({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return z(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate(O(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=O(this.prizeDeg);var h=O(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;z(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=O(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+O(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?$(o,S(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate(O(360)-n-O(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=B(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=x(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=M(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=B(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(j),X=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=g({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 g({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return g({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;m(m([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=m(m([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=C(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return z(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),I(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(z(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);I(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=$(o,S(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=B(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=x(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=M(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=B(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),w(t,"number")?t:w(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),w(t,"number")?t:w(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(j),U=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=g({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return g({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],w=g[2];s+=w;var S=n.background||e.background;if(z(S)){var C=t.getLength(k(n,"borderRadius")?n.borderRadius:e.borderRadius);I(v,y,m,a,a,C),v.fillStyle=S,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=b(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],w=f[3],S=s;S<p+s;){var C=t.displacement([d,S],[S,y]),x=C[0],$=C[1];t.drawImage(v,g,d,y,m,w,x,$,m,w),S+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=C(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return z(v)&&(I(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=b(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),S=k[0],z=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,S,z,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=B(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=M(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=B(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(j),G="@lucky-canvas/react",q=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 N({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();q.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var Y=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 X({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();Y.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var J=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new U({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();J.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}},exports.LuckyGrid=Y,exports.LuckyWheel=q,exports.SlotMachine=J; | ||
***************************************************************************** */var p=function(t,e){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},p(t,e)};function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var g=function(){return g=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},g.apply(this,arguments)};function v(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function y(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function m(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var w=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},b=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!w(r,"object","array"))return r;t=r}return t},k=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},S=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},z=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},C=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&w(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},x=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},$=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},O=function(t){return Math.PI/180*t},I=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},E=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return I(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},_=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}(),W="__proto__"in{};function P(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var R=Array.prototype,T=Object.create(R);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){T[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=R[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var A=function(){function t(t){this.dep=new _,P(t,"__luckyOb__",this),Array.isArray(t)&&(W?t.__proto__=T:Object.getOwnPropertyNames(T).forEach((function(e){P(t,e,T[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){H(t,e,t[e])}))},t}();function D(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new A(t)}function H(t,e,i){var n=new _,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=D(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return _.target&&(n.addSub(_.target),a&&a.dep.addSub(_.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=D(e),n.notify()))}})}}var F=0,L=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=F++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){_.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){w(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),_.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}(),j=function(){function t(t,e){var i=this;this.version="1.7.7",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.7"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,m([i],n))},t.prototype.getLength=function(t){return w(t,"number")?t:w(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!k(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return E.apply(void 0,m([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&H(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new L(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),M=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},B=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},N=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 g({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return g({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&0===this.step&&(null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return z(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate(O(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=O(this.prizeDeg);var h=O(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;z(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=O(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+O(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?$(o,S(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate(O(360)-n-O(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=B(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=x(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=M(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=B(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(j),X=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=g({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 g({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return g({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;m(m([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&0===e.step&&("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=m(m([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=C(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return z(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),I(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(z(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);I(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=$(o,S(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=B(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=x(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=M(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=B(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),w(t,"number")?t:w(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),w(t,"number")?t:w(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(j),U=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return d(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=g({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return g({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return v(this,void 0,void 0,(function(){var i;return y(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return v(this,void 0,void 0,(function(){var r=this;return y(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],w=g[2];s+=w;var S=n.background||e.background;if(z(S)){var C=t.getLength(k(n,"borderRadius")?n.borderRadius:e.borderRadius);I(v,y,m,a,a,C),v.fillStyle=S,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=b(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],w=f[3],S=s;S<p+s;){var C=t.displacement([d,S],[S,y]),x=C[0],$=C[1];t.drawImage(v,g,d,y,m,w,x,$,m,w),S+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=C(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return z(v)&&(I(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=b(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),S=k[0],z=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,S,z,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=B(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=M(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=B(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return w(t,"number")?t:w(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(j),G="@lucky-canvas/react",q=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 N({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();q.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var Y=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 X({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();Y.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var J=function(t){h(o,e["default"].Component);var i=f(o);function o(t){var n;return r(this,o),(n=i.call(this,t)).myLucky=e.default.createRef(),n}return s(o,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(G,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new U({flag:"WEB",divElement:this.myLucky.current},n(n({},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 e.default.createElement("div",{ref:this.myLucky})}}]),o}();J.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}},exports.LuckyGrid=Y,exports.LuckyWheel=q,exports.SlotMachine=J; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -15,3 +15,3 @@ import t from"react";function e(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function i(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function a(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&&c(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function u(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function l(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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=h(t);if(e){var r=h(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return u(this,i)}} | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},f(t,e)};function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var d=function(){return d=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},d.apply(this,arguments)};function g(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function v(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function y(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var m=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},w=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!m(r,"object","array"))return r;t=r}return t},b=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},k=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},z=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},S=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&m(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},C=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},x=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},$=function(t){return Math.PI/180*t},O=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},I=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return O(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},E=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}(),_="__proto__"in{};function W(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var P=Array.prototype,T=Object.create(P);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){T[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=P[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var R=function(){function t(t){this.dep=new E,W(t,"__luckyOb__",this),Array.isArray(t)&&(_?t.__proto__=T:Object.getOwnPropertyNames(T).forEach((function(e){W(t,e,T[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){D(t,e,t[e])}))},t}();function A(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new R(t)}function D(t,e,i){var n=new E,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=A(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return E.target&&(n.addSub(E.target),a&&a.dep.addSub(E.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=A(e),n.notify()))}})}}var H=0,F=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=H++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){E.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){m(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),E.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}(),L=function(){function t(t,e){var i=this;this.version="1.7.6",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.6"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,y([i],n))},t.prototype.getLength=function(t){return m(t,"number")?t:m(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!b(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return I.apply(void 0,y([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&D(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new F(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),j=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},M=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},B=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 d({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return d({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return z(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate($(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=$(this.prizeDeg);var h=$(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;z(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=$(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+$(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?x(o,k(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate($(360)-n-$(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=M(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=C(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=j(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=M(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(L),N=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=d({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 d({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return d({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;y(y([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=y(y([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=S(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return z(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),O(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(z(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);O(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=x(o,k(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=M(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=C(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=j(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=M(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),m(t,"number")?t:m(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),m(t,"number")?t:m(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(L),X=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=d({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return d({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],k=g[2];s+=k;var S=n.background||e.background;if(z(S)){var C=t.getLength(b(n,"borderRadius")?n.borderRadius:e.borderRadius);O(v,y,m,a,a,C),v.fillStyle=S,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=w(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],k=f[3],S=s;S<p+s;){var C=t.displacement([d,S],[S,y]),x=C[0],$=C[1];t.drawImage(v,g,d,y,m,k,x,$,m,k),S+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=S(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return z(v)&&(O(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=w(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),z=k[0],S=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,z,S,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=M(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=j(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=M(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(L),U="@lucky-canvas/react",G=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 B({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();G.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var q=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 N({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();q.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var Y=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.2"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new X({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();Y.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}};export{q as LuckyGrid,G as LuckyWheel,Y as SlotMachine}; | ||
***************************************************************************** */var f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},f(t,e)};function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var d=function(){return d=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},d.apply(this,arguments)};function g(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function v(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function y(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var m=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},w=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!m(r,"object","array"))return r;t=r}return t},b=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},k=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},z=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},S=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&m(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},C=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},x=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},$=function(t){return Math.PI/180*t},O=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},I=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return O(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},E=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}(),_="__proto__"in{};function W(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var P=Array.prototype,R=Object.create(P);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){R[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=P[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var T=function(){function t(t){this.dep=new E,W(t,"__luckyOb__",this),Array.isArray(t)&&(_?t.__proto__=R:Object.getOwnPropertyNames(R).forEach((function(e){W(t,e,R[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){D(t,e,t[e])}))},t}();function A(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new T(t)}function D(t,e,i){var n=new E,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=A(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return E.target&&(n.addSub(E.target),a&&a.dep.addSub(E.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=A(e),n.notify()))}})}}var H=0,F=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=H++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){E.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){m(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),E.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}(),L=function(){function t(t,e){var i=this;this.version="1.7.7",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.7"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,y([i],n))},t.prototype.getLength=function(t){return m(t,"number")?t:m(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!b(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return I.apply(void 0,y([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&D(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new F(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),j=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},M=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},B=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 d({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return d({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&0===this.step&&(null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return z(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate($(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=$(this.prizeDeg);var h=$(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;z(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=$(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+$(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?x(o,k(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate($(360)-n-$(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&z(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=M(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=C(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=j(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=M(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(L),N=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=d({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 d({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return d({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;y(y([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&0===e.step&&("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=y(y([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=S(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return z(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),O(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(z(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);O(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=x(o,k(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=M(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=C(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=j(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=M(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),m(t,"number")?t:m(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),m(t,"number")?t:m(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(L),X=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return p(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=d({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return d({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return g(this,void 0,void 0,(function(){var r=this;return v(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],k=g[2];s+=k;var S=n.background||e.background;if(z(S)){var C=t.getLength(b(n,"borderRadius")?n.borderRadius:e.borderRadius);O(v,y,m,a,a,C),v.fillStyle=S,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=w(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],k=f[3],S=s;S<p+s;){var C=t.displacement([d,S],[S,y]),x=C[0],$=C[1];t.drawImage(v,g,d,y,m,k,x,$,m,k),S+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=S(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return z(v)&&(O(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=w(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),z=k[0],S=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,z,S,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=M(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=j(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=M(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return m(t,"number")?t:m(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(L),U="@lucky-canvas/react",G=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 B({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();G.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var q=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 N({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();q.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var Y=function(e){a(s,t.Component);var r=l(s);function s(e){var i;return n(this,s),(i=r.call(this,e)).myLucky=t.createRef(),i}return o(s,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(U,"@").concat("0.1.3"));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new X({flag:"WEB",divElement:this.myLucky.current},i(i({},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 t.createElement("div",{ref:this.myLucky})}}]),s}();Y.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}};export{q as LuckyGrid,G as LuckyWheel,Y as SlotMachine}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -15,3 +15,3 @@ !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 i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=i(e);function r(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function o(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){c(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function h(t,e,i){return e&&a(t.prototype,e),i&&a(t,i),t}function c(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function u(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)},l(t)}function f(t,e){return f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},f(t,e)}function p(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=l(t);if(e){var r=l(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return p(this,i)}} | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},g(t,e)};function v(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var y=function(){return y=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},y.apply(this,arguments)};function m(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function w(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function b(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var k=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},S=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!k(r,"object","array"))return r;t=r}return t},z=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},C=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},x=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},$=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&k(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},O=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},I=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},E=function(t){return Math.PI/180*t},_=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},W=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return _(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},P=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}(),T="__proto__"in{};function R(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var A=Array.prototype,D=Object.create(A);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){D[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=A[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var H=function(){function t(t){this.dep=new P,R(t,"__luckyOb__",this),Array.isArray(t)&&(T?t.__proto__=D:Object.getOwnPropertyNames(D).forEach((function(e){R(t,e,D[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){F(t,e,t[e])}))},t}();function L(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new H(t)}function F(t,e,i){var n=new P,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=L(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return P.target&&(n.addSub(P.target),a&&a.dep.addSub(P.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=L(e),n.notify()))}})}}var j=0,M=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=j++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){P.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){k(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),P.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}(),B=function(){function t(t,e){var i=this;this.version="1.7.6",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.6"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,b([i],n))},t.prototype.getLength=function(t){return k(t,"number")?t:k(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!z(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return W.apply(void 0,b([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&F(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new M(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),N=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},X=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},U=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 y({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return y({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return x(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate(E(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=E(this.prizeDeg);var h=E(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;x(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=E(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+E(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?I(o,C(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate(E(360)-n-E(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),x(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&x(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=X(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=O(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=N(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=X(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(B),G=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=y({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 y({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return y({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;b(b([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=b(b([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=$(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return x(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),_(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(x(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);_(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=I(o,C(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=X(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=O(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=N(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=X(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),k(t,"number")?t:k(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),k(t,"number")?t:k(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(B),q=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=y({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return y({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],w=g[2];s+=w;var b=n.background||e.background;if(x(b)){var k=t.getLength(z(n,"borderRadius")?n.borderRadius:e.borderRadius);_(v,y,m,a,a,k),v.fillStyle=b,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=S(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],w=f[3],b=s;b<p+s;){var k=t.displacement([d,b],[b,y]),C=k[0],$=k[1];t.drawImage(v,g,d,y,m,w,C,$,m,w),b+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=$(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return x(v)&&(_(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=S(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),S=k[0],z=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,S,z,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=X(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=N(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=X(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(B),Y="@lucky-canvas/react",J="0.1.2",K=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 U({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);K.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var Q=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);Q.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var V=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new q({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);V.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}},t.LuckyGrid=Q,t.LuckyWheel=K,t.SlotMachine=V,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */var g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},g(t,e)};function v(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var y=function(){return y=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},y.apply(this,arguments)};function m(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function w(t,e){var i,n,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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=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++,n=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],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function b(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}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),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});var k=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},S=function(t,e){for(var i=0,n=e.split(".");i<n.length;i++){var r=t[n[i]];if(!k(r,"object","array"))return r;t=r}return t},z=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},C=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},x=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},$=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var a={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=Object.prototype.hasOwnProperty.call(t,h)&&k(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[n,r,o,s]},O=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},I=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],s=t.measureText("...").width,a=0;a<e.length;a++){r+=e[a];var h=t.measureText(r).width,c=i(o);if(n===o.length+1&&(h+=s),c<0)return o;if(h>c&&(o.push(r.slice(0,-1)),r=e[a]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},E=function(t){return Math.PI/180*t},_=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=Math.min(o,s),c=Math.PI;a>h/2&&(a=h/2),t.beginPath(),t.moveTo(n+a,r),t.lineTo(n+a,r),t.lineTo(n+o-a,r),t.arc(n+o-a,r+a,a,-c/2,0),t.lineTo(n+o,r+s-a),t.arc(n+o-a,r+s-a,a,0,c/2),t.lineTo(n+a,r+s),t.arc(n+a,r+s-a,a,c/2,c),t.lineTo(n,r+a),t.arc(n+a,r+a,a,c,-c/2),t.closePath()},W=function(t,e,i,n,r,o){var s=document.createElement("canvas"),a=s.getContext("2d"),h=t.width,c=t.height;s.width=h,s.height=c;var u=h/n;return _(a,e*u,i*u,n*u,r*u,o*u),a.clip(),a.drawImage(t,0,0,h,c),s},P=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}(),R="__proto__"in{};function T(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var A=Array.prototype,D=Object.create(A);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){D[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=A[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var H=function(){function t(t){this.dep=new P,T(t,"__luckyOb__",this),Array.isArray(t)&&(R?t.__proto__=D:Object.getOwnPropertyNames(D).forEach((function(e){T(t,e,D[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){F(t,e,t[e])}))},t}();function L(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new H(t)}function F(t,e,i){var n=new P,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,s=r&&r.set;o&&!s||2!==arguments.length||(i=t[e]);var a=L(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return P.target&&(n.addSub(P.target),a&&a.dep.addSub(P.target)),e},set:function(e){e!==i&&(i=e,o&&!s||(s?s.call(t,e):i=e,a=L(e),n.notify()))}})}}var j=0,M=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=j++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){P.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){k(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),P.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}(),B=function(){function t(t,e){var i=this;this.version="1.7.7",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.7.7"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){if(this.resize(),!this.boxWidth||!this.boxHeight)return console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},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.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],s=r[1];i&&(i.width=o,i.height=s,i.style.width=o+"px",i.style.height=s+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},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.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var s=new Image;s.onload=function(){return r(s)},s.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},s.src=t}))},t.prototype.drawImage=function(t,e){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.config,s=o.flag,a=o.dpr;if(["WEB","MP-WX"].includes(s))i=e;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(s))return console.error("意料之外的 flag, 该平台尚未兼容!");i=e.path}return 8===n.length&&(n=n.map((function(t,e){return e<4?t*a:t}))),t.drawImage.apply(t,b([i],n))},t.prototype.getLength=function(t){return k(t,"number")?t:k(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/,(function(t,n,r){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var s=i.config.unitFunc;return s?s(n,r):n})))},t.prototype.getOffscreenCanvas=function(t,e){if(!z(this,"_offscreenCanvas")){if(!window||!window.document)return console.error("无法创建离屏Canvas!");this._offscreenCanvas=document.createElement("canvas")}var i=this.config.dpr,n=this._offscreenCanvas;n.width=(t||300)*i,n.height=(e||150)*i;var r=n.getContext("2d");return r.clearRect(0,0,t,e),r.scale(i,i),r.dpr=i,{_offscreenCanvas:n,_ctx:r}},t.prototype.multiplyByDpr=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return e*t.config.dpr}))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return W.apply(void 0,b([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var s=n.getImageData(0,0,r,o),a=s.data,h=a.length,c=0;c<h;c+=4){var u=a[c+3];0!==u&&(a[c+3]=u*e/100)}n.putImageData(s,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var s=n.getImageData(0,0,r,o),a=s.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),s=[],a=0,h=-i;h<=i;h++)for(var c=-i;c<=i;c++){var u=o*Math.exp(-(h*h+c*c)/r);s.push(u),a+=u}for(var l=0;l<s.length;l++)s[l]/=a;return s}(e);return a.length,h.length,console.log(s),n.putImageData(s,0,0),i}(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&F(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new M(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),N=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},X=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},U=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.step=0,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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 y({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return y({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&0===this.step&&(null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._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,n){return x(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){var s=i.ImageCache.blocks;if(s&&s[n]){var a=s[n][r];if(a){var h=i.computedWidthAndHeight(a,e,2*t,2*t),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(e.top,2*t)-t],f=l[0],p=l[1];o.save(),e.rotate&&o.rotate(E(i.rotateDeg)),i.drawImage(o,a,f,p,c,u),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=E(this.prizeDeg);var h=E(this.rotateDeg-90+this.prizeDeg/2+s.offsetDegree),c=function(t){return i.getOffsetX(o.measureText(t).width)},u=function(t,e,n){var r=t.lineHeight||a.lineHeight||t.fontSize||a.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=h+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,l=t.background||a.background;x(l)&&(o.fillStyle=l,function(t,e,i,n,r,o){t.beginPath();var s,a,h=E(90/Math.PI/i*o),c=n+h,u=r-h;t.arc(0,0,i,c,u,!1),t.lineTo.apply(t,(s=(n+r)/2,a=o/2/Math.abs(Math.sin((n-r)/2)),[+(Math.cos(s)*a).toFixed(8),+(Math.sin(s)*a).toFixed(8)])),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(s.gutter)),o.fill());var f=Math.cos(n)*i.prizeRadius,p=Math.sin(n)*i.prizeRadius;o.translate(f,p),o.rotate(n+E(90)),t.imgs&&t.imgs.forEach((function(t,n){var s=i.ImageCache.prizes;if(s&&s[e]){var a=s[e][n];if(a){var h=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,r)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,n=t.fontWeight||a.fontWeight,h=i.getLength(t.fontSize||a.fontSize),l=t.fontStyle||a.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:a.wordWrap,p=t.lengthLimit||a.lengthLimit,d=t.lineClamp||a.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var g=String(t.text);(f?I(o,C(g),(function(e){var n=(i.prizeRadius-u(t,r,e.length))*Math.tan(i.prizeRadian/2)*2-i.getLength(s.gutter);return i.getWidth(p,n)}),d):g.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,c(e),u(t,r,i))}))})),o.rotate(E(360)-n-E(90)),o.translate(-f,-p)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),x(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&x(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var s=i.ImageCache.buttons;if(s&&s[e]){var a=s[e][r];if(a){var h=i.computedWidthAndHeight(a,t,2*n,2*n),c=h[0],u=h[1],l=[i.getOffsetX(c),i.getHeight(t.top,n)],f=l[0],p=l[1];i.drawImage(o,a,f,p,c,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||a.fontColor,r=t.fontWeight||a.fontWeight,s=i.getLength(t.fontSize||a.fontSize),h=t.fontStyle||a.fontStyle;o.fillStyle=e,o.font=r+" "+(s>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,c(e),u(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.prizeDeg,r=t.rotateDeg;this.endTime=Date.now();for(var o=this.stopDeg=r,s=e.speed,a=(Math.random()*n-n/2)*this.getLength(e.stopRange),h=0,c=0,u=0;++h;){var l=360*h-i*n-r-e.offsetDegree+a-n/2,f=X(this.FPS,o,l,e.decelerationTime)-o;if(f>s){this.endDeg=s-c>f-s?l:u;break}u=l,c=f}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=O(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizeFlag,s=i.stopDeg,a=i.endDeg,h=i._defaultConfig,c=h.accelerationTime,u=h.decelerationTime,l=h.speed;if(0!==r){if(-1!==o){3!==r||this.endDeg||this.carveOnGunwaleOfAMovingBoat();var f=Date.now()-this.startTime,p=Date.now()-this.endTime,d=this.rotateDeg;if(1===r||f<c){this.FPS=f/t;var g=N(f,0,l,c);g===l&&(this.step=2),d+=g%360}else 2===r?(d+=l%360,void 0!==o&&o>=0&&(this.step=3,this.stopDeg=0,this.endDeg=0)):3===r?(d=X(p,s,a,u),p>=u&&(this.step=0)):this.stop(-1);this.rotateDeg=d,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===o}))||{})},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(B),G=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.step=0,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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=y({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 y({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return y({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{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(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;b(b([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),s=o[0],a=o[1],h=o[2],c=o[3];i.beginPath(),i.rect(s,a,h,c),i.isPointInPath(t.offsetX,t.offsetY)&&0===e.step&&("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(a=r.button),a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]);var u=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(u).then((function(t){var s=t[0],a=t[1],u=h.formatter;"function"==typeof u&&(s=u.call(r,s),a&&(a=u.call(r,a))),c[i][e][n]={defaultImg:s,activeImg:a},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,s=n._defaultConfig,a=n._defaultStyle,h=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=b(b([],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 n=t.x,r=t.y,s=t.w,h=t.h,c=$(e),u=c[0],l=c[1],f=c[2],p=c[3],d=e.borderRadius?i.getLength(e.borderRadius):0,g=e.background||a.background;return x(g)&&(o.fillStyle=i.handleBackground(n,r,s,h,g),_(o,n,r,s,h,d),o.fill()),{x:n+f,y:r+u,w:s-f-p,h:h-u-l}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),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 n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),s=n[0],c=n[1],u=n[2],l=n[3],f=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(f=e===i.currIndex%i.prizes.length>>0);var p=f?h.background:t.background||a.background;if(x(p)){var d=(f?h.shadow:t.shadow||a.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(o.shadowColor=d[3],o.shadowOffsetX=d[0]*r.dpr,o.shadowOffsetY=d[1]*r.dpr,o.shadowBlur=d[2],d[0]>0?u-=d[0]:(u+=d[0],s-=d[0]),d[1]>0?l-=d[1]:(l+=d[1],c-=d[1])),o.fillStyle=i.handleBackground(s,c,u,l,p);var g=i.getLength(t.borderRadius?t.borderRadius:a.borderRadius);_(o,s,c,u,l,g),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var v="prizes";e>=i.prizes.length&&(v="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var a=i.ImageCache[v];if(a[e]){var h=a[e][r];if(h){var u=f&&h.activeImg||h.defaultImg;if(u){var l=i.computedWidthAndHeight(u,n,t),p=l[0],d=l[1],g=[s+i.getOffsetX(p,t.col),c+i.getHeight(n.top,t.row)],y=g[0],m=g[1];i.drawImage(o,u,y,m,p,d)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=f&&h.fontStyle?h.fontStyle:e.fontStyle||a.fontStyle,r=f&&h.fontWeight?h.fontWeight:e.fontWeight||a.fontWeight,u=f&&h.fontSize?i.getLength(h.fontSize):i.getLength(e.fontSize||a.fontSize),l=f&&h.lineHeight?h.lineHeight:e.lineHeight||a.lineHeight||e.fontSize||a.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:a.wordWrap,d=e.lengthLimit||a.lengthLimit,g=e.lineClamp||a.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=f&&h.fontColor?h.fontColor:e.fontColor||a.fontColor;var v=[],y=String(e.text);if(p){var m=i.getWidth(d,t.col);v=I(o,C(y),(function(){return m}),g)}else v=y.split("\n");v.forEach((function(n,r){o.fillText(n,s+i.getOffsetX(o.measureText(n).width,t.col),c+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[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?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var u=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),u)}(o,t,e,i,n,r)),r},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=t._defaultConfig,i=t.prizeFlag,n=t.currIndex;this.endTime=Date.now();for(var r=this.stopIndex=n,o=e.speed,s=0,a=0,h=0;++s;){var c=this.prizes.length*s+i-r,u=X(this.FPS,r,c,e.decelerationTime)-r;if(u>o){this.endIndex=o-a>u-o?c:h;break}h=c,a=u}},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){if(0!==this.step&&3!==this.step){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=O(e)}t<0?(this.step=0,this.prizeFlag=-1):(this.step=2,this.prizeFlag=t%this.prizes.length)}},e.prototype.run=function(t){var e;void 0===t&&(t=0);var i=this,n=i.rAF,r=i.step,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,u=c.accelerationTime,l=c.decelerationTime,f=c.speed;if(0!==r){if(-1!==s){3!==r||this.endIndex||this.carveOnGunwaleOfAMovingBoat();var p=Date.now()-this.startTime,d=Date.now()-this.endTime,g=this.currIndex;if(1===r||p<u){this.FPS=p/t;var v=N(p,.1,f-.1,u);v===f&&(this.step=2),g+=v%o.length}else 2===r?(g+=f%o.length,void 0!==s&&s>=0&&(this.step=3,this.stopIndex=0,this.endIndex=0)):3===r?(g=X(d,a,h,l),d>=l&&(this.step=0)):this.stop(-1);this.currIndex=g,this.draw(),n(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],s=void 0===o?1:o,a=this.cellWidth,h=this.cellHeight,c=this._defaultConfig.gutter,u=[this.prizeArea.x+(a+c)*e,this.prizeArea.y+(h+c)*i];return r&&s&&u.push(a*r+c*(r-1),h*s+c*(s-1)),u},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),k(t,"number")?t:k(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),k(t,"number")?t:k(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 i=this.config;return[t/i.dpr,e/i.dpr]},e}(B),q=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.slots=[],r.defaultConfig={},r._defaultConfig={},r.defaultStyle={},r._defaultStyle={},r.endCallback=function(){},r.cellWidth=0,r.cellHeight=0,r.cellAndSpacing=0,r.widthAndSpacing=0,r.heightAndSpacing=0,r.FPS=16.6,r.scroll=[],r.stopScroll=[],r.endScroll=[],r.startTime=0,r.endTime=0,r.step=0,r.prizeFlag=-1,r.ImageCache={blocks:[],prizes:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return v(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.FPS=16.6,this.prizeFlag=-1,this.step=0,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"slots",t.slots||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=y({mode:"vertical",rowSpacing:0,colSpacing:5,speed:20,direction:1,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.rowSpacing=t.getLength(e.rowSpacing),e.colSpacing=t.getLength(e.colSpacing),e})),this.$computed(this,"_defaultStyle",(function(){return y({borderRadius:0,fontColor:"#000",fontSize:"18px",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("slots",(function(e){t.drawOffscreenCanvas(),t.draw()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return m(this,void 0,void 0,(function(){var i;return w(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.drawOffscreenCanvas(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.drawOffscreenCanvas(),t.draw(),e()}))}))}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return m(this,void 0,void 0,(function(){var r=this;return w(this,(function(o){return[2,new Promise((function(o,s){var a=r[t][e];if(a&&a.imgs){var h=a.imgs[n];if(h){var c=r.ImageCache;c[i][e]||(c[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),c[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),s()}))}}}))]}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.drawOffscreenCanvas=function(){var t=this;this._defaultConfig;var e=this._defaultStyle,i=this.drawBlocks();i.x,i.y;var n=i.w,r=i.h,o=this.prizes.length,s=this.displacementWidthOrHeight(),a=s.cellWidth,h=s.cellHeight,c=s.widthAndSpacing,u=s.heightAndSpacing,l=new Array(o).fill(void 0).map((function(t,e){return e})),f=0,p=0;this.slots.forEach((function(e,i){void 0===t.scroll[i]&&(t.scroll[i]=0),e.order=e.order||l;var o=e.order.length;f=Math.max(f,n+c*o),p=Math.max(p,r+u*o)}));var d=this.getOffscreenCanvas(f,p),g=d._offscreenCanvas,v=d._ctx;this._offscreenCanvas=g,this.slots.forEach((function(i,n){var r=a*n,o=h*n,s=0,l=function(t,e){for(var i={},n=[],r=0;r<t.length;r++)i[r]=t[r];for(r=0;r<e.length;r++){var o=i[e[r]];o&&(n[r]=o)}return n}(t.prizes,i.order);if(l.length){l.forEach((function(n,l){if(n){var f=i.order[l],p=c*l,d=u*l,g=t.displacement([r,d,u],[p,o,c]),y=g[0],m=g[1],w=g[2];s+=w;var b=n.background||e.background;if(x(b)){var k=t.getLength(z(n,"borderRadius")?n.borderRadius:e.borderRadius);_(v,y,m,a,a,k),v.fillStyle=b,v.fill()}n.imgs&&n.imgs.forEach((function(e,i){var n=S(t.ImageCache,"prizes."+f+"."+i);if(n){var r=t.computedWidthAndHeight(n,e,a,h),o=r[0],s=r[1],c=[y+t.getOffsetX(o,a),m+t.getHeight(e.top,h)],u=c[0],l=c[1];t.drawImage(v,n,u,l,o,s)}}))}}));for(var f=t.displacement([r,0,a,s],[0,o,s,h]),d=f[0],y=f[1],m=f[2],w=f[3],b=s;b<p+s;){var k=t.displacement([d,b],[b,y]),C=k[0],$=k[1];t.drawImage(v,g,d,y,m,w,C,$,m,w),b+=s}}}))},e.prototype.drawBlocks=function(){var t=this,e=this;e.config;var i=e.ctx;e._defaultConfig;var n=e._defaultStyle;return this.prizeArea=this.blocks.reduce((function(e,r,o){var s=e.x,a=e.y,h=e.w,c=e.h,u=$(r),l=u[0],f=u[1],p=u[2],d=u[3],g=r.borderRadius?t.getLength(r.borderRadius):0,v=r.background||n.background;return x(v)&&(_(i,s,a,h,c,g),i.fillStyle=v,i.fill()),r.imgs&&r.imgs.forEach((function(e,n){var r=S(t.ImageCache,"blocks."+o+"."+n);if(r){var u=t.computedWidthAndHeight(r,e,h,c),l=u[0],f=u[1],p=[t.getOffsetX(l,h),t.getHeight(e.top,c)],d=p[0],g=p[1];t.drawImage(i,r,s+d,a+g,l,f)}})),{x:s+p,y:a+l,w:h-p-d,h:c-l-f}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight})},e.prototype.draw=function(){var t,e=this,i=this,n=i.config,r=i.ctx;i._defaultConfig,i._defaultStyle,null===(t=n.beforeDraw)||void 0===t||t.call(this,r),r.clearRect(0,0,this.boxWidth,this.boxHeight);var o=this.drawBlocks(),s=o.x,a=o.y,h=o.w,c=o.h;if(this._offscreenCanvas){var u=this,l=u.cellWidth,f=u.cellHeight,p=u.cellAndSpacing,d=u.widthAndSpacing,g=u.heightAndSpacing;this.slots.forEach((function(t,i){var n=p*t.order.length,o=e.displacement(-(c-f)/2,-(h-l)/2),u=e.scroll[i]+o;u<0&&(u=u%n+n),u>n&&(u%=n);var v=e.displacement([l*i,u,l,c],[u,f*i,h,f]),y=v[0],m=v[1],w=v[2],b=v[3],k=e.displacement([s+d*i,a,l,c],[s,a+g*i,h,f]),S=k[0],z=k[1],C=k[2],x=k[3];e.drawImage(r,e._offscreenCanvas,y,m,w,b,S,z,C,x)}))}},e.prototype.carveOnGunwaleOfAMovingBoat=function(){var t=this,e=this,i=e._defaultConfig,n=e.prizeFlag,r=e.cellAndSpacing;this.endTime=Date.now(),this.slots.forEach((function(e,o){var s=e.order;if(s.length)for(var a=e.speed||i.speed,h=e.direction||i.direction,c=s.findIndex((function(t){return t===n})),u=r*s.length,l=t.stopScroll[o]=t.scroll[o],f=0;++f;){var p=r*c+u*f*h-l,d=X(t.FPS,l,p,i.decelerationTime)-l;if(Math.abs(d)>a){t.endScroll[o]=p;break}}}))},e.prototype.play=function(){0===this.step&&(this.startTime=Date.now(),this.prizeFlag=void 0,this.step=1,this.run())},e.prototype.stop=function(t){0!==this.step&&3!==this.step&&(this.prizeFlag=t,this.step=t<0?0:2)},e.prototype.run=function(t){var e,i=this;void 0===t&&(t=0);var n=this,r=n.rAF,o=n.step,s=n.prizeFlag,a=n._defaultConfig,h=n.cellAndSpacing,c=a.accelerationTime,u=a.decelerationTime;if(0!==this.step){if(-1!==s){3!==this.step||this.endScroll.length||this.carveOnGunwaleOfAMovingBoat();var l=Date.now()-this.startTime,f=Date.now()-this.endTime;this.slots.forEach((function(e,n){var r=e.order;if(r&&r.length){var p=h*r.length,d=Math.abs(e.speed||a.speed),g=e.direction||a.direction,v=0,y=i.scroll[n];if(1===o||l<c){i.FPS=l/t;var m=N(l,0,d,c);m===d&&(i.step=2),v=(y+m*g)%p}else if(2===o)v=(y+d*g)%p,void 0!==s&&s>=0&&(i.step=3,i.stopScroll=[],i.endScroll=[]);else if(3===o&&f){var w=i.stopScroll[n],b=i.endScroll[n];v=X(f,w,b,u),f>=u&&(i.step=0)}i.scroll[n]=v}})),this.draw(),r(this.run.bind(this,t+1))}}else null===(e=this.endCallback)||void 0===e||e.call(this,this.prizes.find((function(t,e){return e===s}))||{})},e.prototype.displacement=function(t,e){return"horizontal"===this._defaultConfig.mode?e:t},e.prototype.displacementWidthOrHeight=function(){var t=this._defaultConfig.mode,e=this.slots.length,i=this._defaultConfig,n=i.colSpacing,r=i.rowSpacing,o=this.prizeArea||this.drawBlocks();o.x,o.y;var s,a,h=o.w,c=o.h,u=0,l=0;return"horizontal"===t?(l=this.cellHeight=(c-r*(e-1))/e,u=this.cellWidth=l):(u=this.cellWidth=(h-n*(e-1))/e,l=this.cellHeight=u),s=this.widthAndSpacing=this.cellWidth+n,a=this.heightAndSpacing=this.cellHeight+r,this.cellAndSpacing="horizontal"===t?s:a,{cellWidth:u,cellHeight:l,widthAndSpacing:s,heightAndSpacing:a}},e.prototype.getWidth=function(t,e){return k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return k(t,"number")?t:k(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t,e){return(e-t)/2},e}(B),Y="@lucky-canvas/react",J="0.1.3",K=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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 U({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);K.defaultProps={width:"",height:"",prizes:[],blocks:[],buttons:[],defaultStyle:{},defaultConfig:{}};var Q=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),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({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);Q.defaultProps={width:"",height:"",cols:3,rows:3,blocks:[],prizes:[],buttons:[],defaultStyle:{},activeStyle:{},defaultConfig:{}};var V=function(t){u(i,t);var e=d(i);function i(t){var r;return s(this,i),(r=e.call(this,t)).myLucky=n.default.createRef(),r}return h(i,[{key:"componentDidMount",value:function(){var t=this.props;this.myLucky.current.setAttribute("package","".concat(Y,"@").concat(J));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.$lucky&&(this.props.width!==t.width&&(this.$lucky.width=this.props.width),this.props.height!==t.height&&(this.$lucky.height=this.props.height),this.props.blocks!==t.blocks&&(this.$lucky.blocks=this.props.blocks),this.props.prizes!==t.prizes&&(this.$lucky.prizes=this.props.prizes),this.props.slots!==t.slots&&(this.$lucky.slots=this.props.slots))}},{key:"init",value:function(){var t=this.props;this.$lucky=new q({flag:"WEB",divElement:this.myLucky.current},o(o({},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 n.default.createElement("div",{ref:this.myLucky})}}]),i}(n.default.Component);V.defaultProps={width:"",height:"",blocks:[],prizes:[],slots:[],defaultStyle:{},defaultConfig:{}},t.LuckyGrid=Q,t.LuckyWheel=K,t.SlotMachine=V,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@lucky-canvas/react", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "react ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件", | ||
@@ -47,4 +47,4 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"lucky-canvas": "^1.7.6" | ||
"lucky-canvas": "^1.7.7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
334311
Updatedlucky-canvas@^1.7.7