scratchers
Version:
经典刮刮卡库, [效果预览](https://codepen.io/liejiayong/pen/eYpOypR)
2 lines (1 loc) • 26.4 kB
JavaScript
var Scratchers=function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.Math==Math&&t}function l(t){try{return!!t()}catch(t){return!0}}function o(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function p(t){return c.call(t).slice(8,-1)}function u(t){if(null==t)throw TypeError("Can't call method on "+t);return t}function s(t){return b(u(t))}function h(t){return"object"==typeof t?null!==t:"function"==typeof t}function f(t,e){if(!h(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!h(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!h(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!h(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}function v(t,e){return x.call(t,e)}function r(t){return _?E.createElement(t):{}}function C(t){if(!h(t))throw TypeError(t+" is not an object");return t}function d(e,n){try{P(g,e,n)}catch(t){g[e]=n}return n}var g=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),y=!l(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),i={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,m={f:a&&!i.call({1:2},1)?function(t){var e=a(this,t);return!!e&&e.enumerable}:i},c={}.toString,w="".split,b=l(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==p(t)?w.call(t,""):Object(t)}:Object,x={}.hasOwnProperty,E=g.document,_=h(E)&&h(E.createElement),I=!y&&!l(function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}),O=Object.getOwnPropertyDescriptor,T={f:y?O:function(t,e){if(t=s(t),e=f(e,!0),I)try{return O(t,e)}catch(t){}if(v(t,e))return o(!m.f.call(t,e),t[e])}},R=Object.defineProperty,S={f:y?R:function(t,e,n){if(C(t),e=f(e,!0),C(n),I)try{return R(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},P=y?function(t,e,n){return S.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t},k=g["__core-js_shared__"]||d("__core-js_shared__",{}),A=Function.toString;"function"!=typeof k.inspectSource&&(k.inspectSource=function(t){return A.call(t)});function j(t){return"Symbol("+(void 0===t?"":t)+")_"+(++K+B).toString(36)}function N(t){return $[t]||($[t]=j(t))}var D,M,U,F=k.inspectSource,L=g.WeakMap,X="function"==typeof L&&/native code/.test(F(L)),Y=e(function(t){(t.exports=function(t,e){return k[t]||(k[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.4",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})}),K=0,B=Math.random(),$=Y("keys"),z={};if(X){var G=new g.WeakMap,V=G.get,W=G.has,q=G.set;D=function(t,e){return q.call(G,t,e),e},M=function(t){return V.call(G,t)||{}},U=function(t){return W.call(G,t)}}else{var H=N("state");z[H]=!0,D=function(t,e){return P(t,H,e),e},M=function(t){return v(t,H)?t[H]:{}},U=function(t){return v(t,H)}}function J(t){return"function"==typeof t?t:void 0}function Q(t,e){return arguments.length<2?J(vt[t])||J(g[t]):vt[t]&&vt[t][e]||g[t]&&g[t][e]}function Z(t){return isNaN(t=+t)?0:(0<t?gt:dt)(t)}function tt(t){return 0<t?yt(Z(t),9007199254740991):0}function et(t,e){var n=Z(t);return n<0?mt(n+e,0):wt(n,e)}function nt(c){return function(t,e,n){var r,o=s(t),i=tt(o.length),a=et(n,i);if(c&&e!=e){for(;a<i;)if((r=o[a++])!=r)return!0}else for(;a<i;a++)if((c||a in o)&&o[a]===e)return c||a||0;return!c&&-1}}function rt(t,e){var n,r=s(t),o=0,i=[];for(n in r)!v(z,n)&&v(r,n)&&i.push(n);for(;o<e.length;)v(r,n=e[o++])&&(~bt(i,n)||i.push(n));return i}function ot(t,e){for(var n=Ot(e),r=S.f,o=T.f,i=0;i<n.length;i++){var a=n[i];v(t,a)||r(t,a,o(e,a))}}function it(t,e){var n=Rt[Ct(t)];return n==Pt||n!=St&&("function"==typeof e?l(e):!!e)}function at(t,e){var n,r,o,i,a,c=t.target,u=t.global,s=t.stat;if(n=u?g:s?g[c]||d(c,{}):(g[c]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(a=At(n,r))&&a.value:n[r],!kt(u?r:c+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;ot(i,o)}(t.sham||o&&o.sham)&&P(i,"sham",!0),pt(n,r,i,t)}}function ct(t){return Object(u(t))}function ut(t,e,n){var r=f(e);r in t?S.f(t,r,o(0,n)):t[r]=n}function st(t){return v(Mt,t)||(Nt&&v(Ut,t)?Mt[t]=Ut[t]:Mt[t]=Ft("Symbol."+t)),Mt[t]}var lt,ft,ht={set:D,get:M,has:U,enforce:function(t){return U(t)?M(t):D(t,{})},getterFor:function(n){return function(t){var e;if(!h(t)||(e=M(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},pt=e(function(t){var e=ht.get,c=ht.enforce,u=(String+"").split("String");(t.exports=function(t,e,n,r){var o=!!r&&!!r.unsafe,i=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||v(n,"name")||P(n,"name",e),c(n).source=u.join("string"==typeof e?e:"")),t!==g?(o?!a&&t[e]&&(i=!0):delete t[e],i?t[e]=n:P(t,e,n)):i?t[e]=n:d(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||F(this)})}),vt=g,dt=Math.ceil,gt=Math.floor,yt=Math.min,mt=Math.max,wt=Math.min,bt=(nt(!0),nt(!1)),xt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Et=xt.concat("length","prototype"),_t={f:Object.getOwnPropertyNames||function(t){return rt(t,Et)}},It={f:Object.getOwnPropertySymbols},Ot=Q("Reflect","ownKeys")||function(t){var e=_t.f(C(t)),n=It.f;return n?e.concat(n(t)):e},Tt=/#|\.prototype\./,Ct=it.normalize=function(t){return(t+"").replace(Tt,".").toLowerCase()},Rt=it.data={},St=it.NATIVE="N",Pt=it.POLYFILL="P",kt=it,At=T.f,jt=Array.isArray||function(t){return"Array"==p(t)},Nt=!!Object.getOwnPropertySymbols&&!l(function(){return!(Symbol()+"")}),Dt=Nt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Mt=Y("wks"),Ut=g.Symbol,Ft=Dt?Ut:Ut&&Ut.withoutSetter||j,Lt=st("species"),Xt=Q("navigator","userAgent")||"",Yt=g.process,Kt=Yt&&Yt.versions,Bt=Kt&&Kt.v8;Bt?ft=(lt=Bt.split("."))[0]+lt[1]:!Xt||(lt=Xt.match(/Edge\/(\d+)/))&<[1]<74||!(lt=Xt.match(/Chrome\/(\d+)/))||(ft=lt[1]);function $t(t){if(h(t)){var e=t[Vt];return void 0!==e?!!e:jt(t)}}var zt=ft&&+ft,Gt=st("species"),Vt=st("isConcatSpreadable"),Wt=51<=zt||!l(function(){var t=[];return t[Vt]=!1,t.concat()[0]!==t}),qt=51<=zt||!l(function(){var t=[];return(t.constructor={})[Gt]=function(){return{foo:1}},1!==t.concat(Boolean).foo});at({target:"Array",proto:!0,forced:!Wt||!qt},{concat:function(t){var e,n,r,o,i,a,c,u,s=ct(this),l=(c=0,jt(a=s)&&("function"==typeof(u=a.constructor)&&(u===Array||jt(u.prototype))||h(u)&&null===(u=u[Lt]))&&(u=void 0),new(void 0===u?Array:u)(0===c?0:c)),f=0;for(e=-1,r=arguments.length;e<r;e++)if($t(i=-1===e?s:arguments[e])){if(9007199254740991<f+(o=tt(i.length)))throw TypeError("Maximum allowed index exceeded");for(n=0;n<o;n++,f++)n in i&&ut(l,f,i[n])}else{if(9007199254740991<=f)throw TypeError("Maximum allowed index exceeded");ut(l,f++,i)}return l.length=f,l}});function Ht(){}function Jt(t){return"<script>"+t+"<\/script>"}var Qt,Zt=Object.keys||function(t){return rt(t,xt)},te=y?Object.defineProperties:function(t,e){C(t);for(var n,r=Zt(e),o=r.length,i=0;i<o;)S.f(t,n=r[i++],e[n]);return t},ee=Q("document","documentElement"),ne=N("IE_PROTO"),re=function(){try{Qt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;re=Qt?function(t){t.write(Jt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(Qt):((e=r("iframe")).style.display="none",ee.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write(Jt("document.F=Object")),t.close(),t.F);for(var n=xt.length;n--;)delete re.prototype[xt[n]];return re()};z[ne]=!0;var oe=Object.create||function(t,e){var n;return null!==t?(Ht.prototype=C(t),n=new Ht,Ht.prototype=null,n[ne]=t):n=re(),void 0===e?n:te(n,e)},ie=st("unscopables"),ae=Array.prototype;null==ae[ie]&&S.f(ae,ie,{configurable:!0,value:oe(null)}),at({target:"Array",proto:!0},{fill:function(t){for(var e=ct(this),n=tt(e.length),r=arguments.length,o=et(1<r?arguments[1]:void 0,n),i=2<r?arguments[2]:void 0,a=void 0===i?n:et(i,n);o<a;)e[o++]=t;return e}}),at({target:"Date",stat:ae[ie].fill=!0},{now:function(){return(new Date).getTime()}});var ce=Date.prototype,ue=ce.toString,se=ce.getTime;new Date(NaN)+""!="Invalid Date"&&pt(ce,"toString",function(){var t=se.call(this);return t==t?ue.call(this):"Invalid Date"});var le=[].slice,fe={};at({target:"Function",proto:!0},{bind:Function.bind||function(e){var n=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function");return t}(this),r=le.call(arguments,1),o=function(){var t=r.concat(le.call(arguments));return this instanceof o?function(t,e,n){if(!(e in fe)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";fe[e]=Function("C,a","return new C("+r.join(",")+")")}return fe[e](t,n)}(n,t.length,t):n.apply(e,t)};return h(n.prototype)&&(o.prototype=n.prototype),o}});function he(n){return function(t){var e=u(t)+"";return 1&n&&(e=e.replace(ge,"")),2&n&&(e=e.replace(ye,"")),e}}function pe(t){var e,n,r,o,i,a,c,u,s=f(t,!1);if("string"==typeof s&&2<s.length)if(43==(e=(s=Ee(s)).charCodeAt(0))||45==e){if(88==(n=s.charCodeAt(2))||120==n)return NaN}else if(48==e){switch(s.charCodeAt(1)){case 66:case 98:r=2,o=49;break;case 79:case 111:r=8,o=55;break;default:return+s}for(a=(i=s.slice(2)).length,c=0;c<a;c++)if((u=i.charCodeAt(c))<48||o<u)return NaN;return parseInt(i,r)}return+s}var ve=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),r=t instanceof Array}catch(n){}return function(t,e){return C(t),function(){if(!h(e)&&null!==e)throw TypeError("Can't set "+e+" as a prototype")}(),r?n.call(t,e):t.__proto__=e,t}}():void 0),de="[\t\n\v\f\r \u2028\u2029\ufeff]",ge=RegExp("^"+de+de+"*"),ye=RegExp(de+de+"*$"),me={start:he(1),end:he(2),trim:he(3)},we=_t.f,be=T.f,xe=S.f,Ee=me.trim,_e=g.Number,Ie=_e.prototype,Oe="Number"==p(oe(Ie));if(kt("Number",!_e(" 0o1")||!_e("0b1")||_e("+0x1"))){for(var Te,Ce=function(t){var e,n,r,o,i,a=arguments.length<1?0:t,c=this;return c instanceof Ce&&(Oe?l(function(){Ie.valueOf.call(c)}):"Number"!=p(c))?(e=new _e(pe(a)),n=c,r=Ce,ve&&"function"==typeof(o=n.constructor)&&o!==r&&h(i=o.prototype)&&i!==r.prototype&&ve(e,i),e):pe(a)},Re=y?we(_e):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),Se=0;Se<Re.length;Se++)v(_e,Te=Re[Se])&&!v(Ce,Te)&&xe(Ce,Te,be(_e,Te));pt(g,"Number",(Ce.prototype=Ie).constructor=Ce)}var Pe="".repeat,ke=1..toFixed,Ae=Math.floor,je=function(t,e,n){return 0===e?n:e%2==1?je(t,e-1,n*t):je(t*t,e/2,n)};at({target:"Number",proto:!0,forced:!l(function(){ke.call({})})},{toFixed:function(t){function e(t,e){for(var n=-1,r=e;++n<6;)l[n]=(r+=t*l[n])%1e7,r=Ae(r/1e7)}function n(t){for(var e=6,n=0;0<=--e;)l[e]=Ae((n+=l[e])/t),n=n%t*1e7}function r(){for(var t=6,e="";0<=--t;)if(""!==e||0===t||0!==l[t]){var n=l[t]+"";e=""===e?n:e+Pe.call("0",7-n.length)+n}return e}var o,i,a,c,u=function(t){if("number"!=typeof t&&"Number"!=p(t))throw TypeError("Incorrect invocation");return+t}(this),s=Z(t),l=[0,0,0,0,0,0],f="",h="0";if(s<0||20<s)throw RangeError("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||1e21<=u)return u+"";if(u<0&&(f="-",u=-u),1e-21<u)if(i=(o=function(){for(var t=0,e=u*je(2,69,1);4096<=e;)t+=12,e/=4096;for(;2<=e;)t+=1,e/=2;return t}()-69)<0?u*je(2,-o,1):u/je(2,o,1),i*=4503599627370496,0<(o=52-o)){for(e(0,i),a=s;7<=a;)e(1e7,0),a-=7;for(e(je(10,a,1),0),a=o-1;23<=a;)n(1<<23),a-=23;n(1<<a),e(1,1),n(2),h=r()}else e(0,i),e(1<<-o,0),h=r()+Pe.call("0",s);return 0<s?f+((c=h.length)>s?h.slice(0,c-s)+"."+h.slice(c-s):"0."+Pe.call("0",s-c)+h):f+h}});var Ne=Object.assign,De=Object.defineProperty,Me=!Ne||l(function(){if(y&&1!==Ne({b:1},Ne(De({},"a",{enumerable:!0,get:function(){De(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return 1;var t={},e={},n=Symbol();return t[n]=7,"abcdefghijklmnopqrst".split("").forEach(function(t){e[t]=t}),7!=Ne({},t)[n]||"abcdefghijklmnopqrst"!=Zt(Ne({},e)).join("")})?function(t,e){for(var n=ct(t),r=arguments.length,o=1,i=It.f,a=m.f;o<r;)for(var c,u=b(arguments[o++]),s=i?Zt(u).concat(i(u)):Zt(u),l=s.length,f=0;f<l;)c=s[f++],y&&!a.call(u,c)||(n[c]=u[c]);return n}:Ne;at({target:"Object",stat:!0,forced:Object.assign!==Me},{assign:Me});function Ue(t,e){return RegExp(t,e)}var Fe,Le,Xe={UNSUPPORTED_Y:l(function(){var t=Ue("a","y");return t.lastIndex=2,null!=t.exec("abcd")}),BROKEN_CARET:l(function(){var t=Ue("^r","gy");return t.lastIndex=2,null!=t.exec("str")})},Ye=RegExp.prototype.exec,Ke=Ye,Be=(Le=/b*/g,Ye.call(Fe=/a/,"a"),Ye.call(Le,"a"),0!==Fe.lastIndex||0!==Le.lastIndex),$e=Xe.UNSUPPORTED_Y||Xe.BROKEN_CARET;(Be||$e)&&(Ke=function(t){var e,n,r,o=this,i=$e&&o.sticky,a=function(){var t=C(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}.call(o),c=o.source,u=0,s=t;return i&&(~(a=a.replace("y","")).indexOf("g")||(a+="g"),s=(t+"").slice(o.lastIndex),0<o.lastIndex&&(!o.multiline||o.multiline&&"\n"!==t[o.lastIndex-1])&&(c="(?: "+c+")",s=" "+s,u++),n=RegExp("^(?:"+c+")",a)),Be&&(e=o.lastIndex),r=Ye.call(i?n:o,s),i?r?(r.input=r.input.slice(u),r[0]=r[0].slice(u),r.index=o.lastIndex,o.lastIndex+=r[0].length):o.lastIndex=0:Be&&r&&(o.lastIndex=o.global?r.index+r[0].length:e),r});var ze=Ke;at({target:"RegExp",proto:!0,forced:/./.exec!==ze},{exec:ze});function Ge(n,t,e,r){var o=st(n),i=!l(function(){var t={};return t[o]=function(){return 7},7!=""[n](t)}),a=i&&!l(function(){var t=!1,e=/a/;return"split"===n&&((e={}).constructor={},e.constructor[He]=function(){return e},e.flags="",e[o]=/./[o]),e.exec=function(){return t=!0,null},e[o](""),!t});if(!i||!a||"replace"===n&&(!Je||Ze)||"split"===n&&!tn){var c=/./[o],u=e(o,""[n],function(t,e,n,r,o){return e.exec===ze?i&&!o?{done:!0,value:c.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}},{REPLACE_KEEPS_$0:!0,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Ze}),s=u[1];pt(String.prototype,n,u[0]),pt(RegExp.prototype,o,2==t?function(t,e){return s.call(t,this,e)}:function(t){return s.call(t,this)})}r&&P(RegExp.prototype[o],"sham",!0)}function Ve(c){return function(t,e){var n,r,o=u(t)+"",i=Z(e),a=o.length;return i<0||a<=i?c?"":void 0:(n=o.charCodeAt(i))<55296||56319<n||i+1===a||(r=o.charCodeAt(i+1))<56320||57343<r?c?o[0|i]:n:c?o.slice(i,i+2):r-56320+(n-55296<<10)+65536}}function We(t,e,n){return e+(n?en(t,e).length:1)}function qe(t,e){var n=t.exec;if("function"==typeof n){var r=n.call(t,e);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==p(t))throw TypeError("RegExp#exec called on incompatible receiver");return ze.call(t,e)}var He=st("species"),Je=!l(function(){return/./.exec=function(){var t=[];return t.groups={a:"7"},t}}),Qe=st("replace"),Ze=!!/./[Qe]&&""===/./[Qe]("a","$0"),tn=!l(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}),en=(Ve(!1),Ve(!0));Ge("match",1,function(r,s,l){return[function(t){var e=u(this),n=null==t?void 0:t[r];return void 0!==n?n.call(t,e):RegExp(t)[r](e+"")},function(t){var e=l(s,t,this);if(e.done)return e.value;var n=C(t),r=this+"";if(!n.global)return qe(n,r);for(var o,i=n.unicode,a=[],c=n.lastIndex=0;null!==(o=qe(n,r));){var u=o[0]+"";(a[c]=u)||(n.lastIndex=We(r,tt(n.lastIndex),i)),c++}return 0===c?null:a}]});var nn=Math.max,rn=Math.min,on=Math.floor,an=/\$([$&'`]|\d\d?|<[^>]*>)/g,cn=/\$([$&'`]|\d\d?)/g;Ge("replace",2,function(o,x,E,t){var _=t.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,I=t.REPLACE_KEEPS_$0,O=_?"$":"$0";return[function(t,e){var n=u(this),r=null==t?void 0:t[o];return void 0!==r?r.call(t,n,e):x.call(n+"",t,e)},function(t,e){if(!_&&I||"string"==typeof e&&!~e.indexOf(O)){var n=E(x,t,this,e);if(n.done)return n.value}var r=C(t),o=this+"",i="function"==typeof e;i||(e+="");var a=r.global;if(a){var c=r.unicode;r.lastIndex=0}for(var u=[];;){var s=qe(r,o);if(null===s)break;if(u.push(s),!a)break;s[0]+""||(r.lastIndex=We(o,tt(r.lastIndex),c))}for(var l,f="",h=0,p=0;p<u.length;p++){for(var v=(s=u[p])[0]+"",d=nn(rn(Z(s.index),o.length),0),g=[],y=1;y<s.length;y++)g.push(void 0===(l=s[y])?l:l+"");var m=s.groups;if(i){var w=[v].concat(g,d,o);void 0!==m&&w.push(m);var b=e.apply(void 0,w)+""}else b=T(v,o,d,g,m,e);d<h||(f+=o.slice(h,d)+b,h=d+v.length)}return f+o.slice(h)}];function T(i,a,c,u,s,t){var l=c+i.length,f=u.length,e=cn;return void 0!==s&&(s=ct(s),e=an),x.call(t,e,function(t,e){var n;switch(e[0]){case"$":return"$";case"&":return i;case"`":return a.slice(0,c);case"'":return a.slice(l);case"<":n=s[e.slice(1,-1)];break;default:var r=+e;if(0==r)return t;if(f<r){var o=on(r/10);return 0===o||f<o?t:void 0===u[o-1]?e[1]:u[o-1]+e[1]}n=u[r-1]}return void 0===n?"":n})}});function un(o){return function(t,e){var n=2<arguments.length,r=n?sn.call(arguments,2):void 0;return o(n?function(){("function"==typeof t?t:Function(t)).apply(this,r)}:t,e)}}var sn=[].slice;at({global:!0,bind:!0,forced:/MSIE .\./.test(Xt)},{setTimeout:un(g.setTimeout),setInterval:un(g.setInterval)});var ln;function fn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function hn(t){var e=document.createElement("div"),n=function(){for(var t in{webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"})if("undefined"!==e[t])return t;return!1}();return!1!==n&&("standard"===n?t:n+t[0].toUpperCase()+t.substr(1))}var pn="ontouchstart"in window;document.createTouch||(document.createTouch=function(t,e,n,r,o,i,a){return new vn(e,n,{pageX:r,pageY:o,screenX:i,screenY:a,clientX:r-window.pageXOffset,clientY:o-window.pageYOffset},0,0)}),document.createTouchList||(document.createTouchList=function(){for(var t=dn(),e=0;e<arguments.length;e++)t[e]=arguments[e];return t.length=arguments.length,t});var vn=function(t,e,n,r,o){r=r||0,o=o||0,this.identifier=e,this.target=t,this.clientX=n.clientX+r,this.clientY=n.clientY+o,this.screenX=n.screenX+r,this.screenY=n.screenY+o,this.pageX=n.pageX+r,this.pageY=n.pageY+o};function dn(){var t=[];return t.item=function(t){return this[t]||null},t.identifiedTouch=function(t){return this[t+1]||null},t}function gn(o){return function(t){var e,n,r;1===t.which&&("mousedown"!==t.type&&ln&&(!ln||ln.dispatchEvent)||(ln=t.target),e=o,n=t,(r=document.createEvent("Event")).initEvent(e,!0,!0),r.altKey=n.altKey,r.ctrlKey=n.ctrlKey,r.metaKey=n.metaKey,r.shiftKey=n.shiftKey,r.touches=mn(n),r.targetTouches=mn(n),r.changedTouches=yn(n),ln.dispatchEvent(r),"mouseup"===t.type&&(ln=null))}}function yn(t){var e=dn();return e.push(new vn(ln,1,t,0,0)),e}function mn(t){return"mouseup"===t.type?dn():yn(t)}function wn(){!function(){for(var t=[window,document.documentElement],e=["ontouchstart","ontouchmove","ontouchcancel","ontouchend"],n=0;n<t.length;n++)for(var r=0;r<4;r++)t[n]&&void 0===t[n][e[r]]&&(t[n][e[r]]=null)}(),window.addEventListener("mousedown",gn("touchstart"),!0),window.addEventListener("mousemove",gn("touchmove"),!0),window.addEventListener("mouseup",gn("touchend"),!0)}return wn.multiTouchOffset=75,pn||new wn,fn(bn.prototype,[{key:"setLock",value:function(t){if("boolean"!=typeof t)return Error(" the paramtar must be Boolean false or true");this.cDisplayer.canvas.style.opacity=(this.lock=t)?0:1}},{key:"set",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{awardUrl:this.config.awardUrl,msg:this.config.awardMsg,coverUrl:this.config.coverUrl},n=e.awardUrl,r=e.msg,o=e.coverUrl;this.setLock(!0),this.setCover(o),setTimeout(function(){t.setAward({url:n,msg:r})},30)}},{key:"setCover",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.config.coverUrl,e=this.cCover,o=e.ctx,i=e.widthReal,a=e.heightReal;t?this.loadImg(t,function(t){var e=t.image,n=t.width,r=t.height;o.save(),o.globalCompositeOperation="source-over",o.drawImage(e,0,0,n,r,0,0,i,a),o.restore()},function(){console.log("the cover image load error.")}):(o.save(),o.globalCompositeOperation="source-over",o.fillStyle=this.config.coverColor,o.fillRect(0,0,i,a),o.restore()),o.canvas.style.opacity="1"}},{key:"setAward",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{url:this.config.awardUrl,msg:this.config.awardMsg},e=this,n=this.cDisplayer,r=n.ctx,o=n.widthReal,i=n.heightReal,a=this.config.awardColor,c=t.url;this.config.awardMsg=t.msg,this.config.awardUrl=c,"transparent"!==a&&(r.save(),r.fillStyle=a,r.fillRect(0,0,o,i),r.restore()),c?e.loadImg(c,function(t){r.drawImage(t.image,0,0,t.width,t.height,0,0,o,i),e._drawMsg()},function(){console.log("the award image load error.")}):e._drawMsg()}},{key:"_drawMsg",value:function(){var t=this.config,e=t.awardMsg,n=t.fontColor;if(e){var r=this.cDisplayer,o=r.ctx,i=r.widthReal,a=r.heightReal,c=this.fontSize;o.font=this.font;var u=(i-o.measureText(e).width)/2,s=(a-c)/2;o.fillStyle=n,o.textAlign="start",o.textBaseline="top",o.fillText(e,u,s,i)}}},{key:"loadImg",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){},r=new Image;r.setAttribute("crossorigin","anonymous"),r.src="".concat(t,"?timestamp=").concat(Date.now()),r.onload=function(){e({image:r,width:r.width,height:r.height})},r.onerror=function(){n(),console.error("Image loading fail.")}}},{key:"clear",value:function(){var t=this,e=this.cCover.canvas,n=this.config.duration;if(n<0)this._clearAll();else{var r=hn("transition");e.style[r]="all ".concat(n/1e3,"s linear"),e.style.opacity="0",setTimeout(function(){t._clearAll()},n)}}},{key:"_clearAll",value:function(){var t=this.cCover.canvas,e=hn("transition");this.isDone=!(t.style[e]="none"),this.lock=!0,this.config.onSuccess()}},{key:"_complete",value:function(){var t=this.config.percent,e=this._pixelPercent();e<t||(this.isDone=!0,this.clear()),this.config.onProgress(e)}},{key:"_pixelPercent",value:function(){for(var t=this.cCover.ctx.getImageData(0,0,this.width,this.height).data,e=t.length,n=[],r=0;r<e;r+=4)t[r+3]<128&&n.push(t[r+3]);return(n.length/(e/4)*100).toFixed(2)}},{key:"_drawPoint",value:function(t){var e=t.x,n=t.y,r=t.radius,o=this.cCover.ctx;o.save(),"default"===this.config.mode&&o.beginPath(),o.arc(e,n,r,0,2*Math.PI),"default"===this.config.mode&&o.closePath(),o.fill(),o.restore()}},{key:"_getPostion",value:function(t){if(!t||t&&!t.clientX)return{x:0,y:0,radius:0};var e=this.config.radius,n=this.cCover.pixelRatio,r=this.point,o=r.top,i=Math.abs(t.clientX-r.left)*n,a=Math.abs(t.clientY-o)*n;return i=i.toFixed(2),a=a.toFixed(2),this.isDown||(this.point.prevX=i,this.point.prevY=a),{x:i,y:a,radius:e}}},{key:"_event",value:function(){var t=this.cCover.canvas;t.addEventListener("touchstart",this._eventDown.bind(this),{passive:!1}),t.addEventListener("touchmove",this._eventMove.bind(this),{passive:!1}),t.addEventListener("touchend",this._eventUp.bind(this),{passive:!1}),t.addEventListener("touchcancel",this._eventUp.bind(this),{passive:!1}),t.addEventListener("touchleave",this._eventUp.bind(this),{passive:!1})}},{key:"_eventUp",value:function(t){t.preventDefault(),this.lock||(this.cCover.ctx.globalCompositeOperation="source-over",this.isDown=!1)}},{key:"_eventDown",value:function(t){if(t.preventDefault(),!this.lock){this.isReady||(this.isReady=!0,this.config.onReady());var e=this.cCover.ctx;"sector"===this.config.mode&&e.beginPath(),e.globalCompositeOperation="destination-out";var n=this.parent.getBoundingClientRect();this.point.left=n.left,this.point.top=n.top,this._drawPoint(this._getPostion(t.changedTouches[0])),this.isDown=!0}}},{key:"_eventMove",value:function(t){t.preventDefault(),this.lock||this.isDown&&!this.isDone&&(this._drawPoint(this._getPostion(t.changedTouches[0])),this._complete())}},{key:"_createCanvas",value:function(){var t=document.createElement("canvas"),e=t.getContext("2d"),n=this.width,r=this.height,o=(window.devicePixelRatio||1)/(e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),i=n*o,a=r*o;return e.scale(o,o),t.setAttribute("width",i),t.setAttribute("height",a),t.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%",{canvas:t,ctx:e,width:n,height:r,pixelRatio:this.pixelRatio=o,widthReal:i,heightReal:a}}},{key:"_createDOM",value:function(){var t,e,n=this.config,r=n.width,o=n.height,i=n.unit,a=n.containerClass,c=this.el,u=document.createElement("div");u.style.cssText="position:relative;margin:0 auto;text-align:center;width:".concat(r).concat(i,";height:").concat(o).concat(i,";overflow:hidden;"),u.className=a,t=this._createCanvas(),e=this._createCanvas(),u.appendChild(e.canvas),u.appendChild(t.canvas),c.appendChild(u),this.parent=u,this.cCover=t,this.cDisplayer=e}},{key:"_params",value:function(){var t=this.config.font,e=t.match(/(\d+)px/g)[0];e=+(e=e.replace("px","")*this.pixelRatio).toFixed(1),this.font=t.replace(/(\d+)px/g,"".concat(e,"px")),this.fontSize=e}},{key:"_init",value:function(){if(!this.el)return Error("the.el is not found.");this._createDOM(),this.setAward(),this.setCover(),this._event(),this._params()}}]),bn;function bn(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length?arguments[1]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,bn);this.config=Object.assign({},{width:300,height:150,awardUrl:"",awardColor:"#ffffff",awardMsg:"特等奖",font:"bold 30px Arial",fontColor:"#ffffff",coverUrl:"",coverColor:"#cccccc",radius:28,duration:500,percent:60,unit:"px",containerClass:"jy-scraping-container",mode:"default",onReady:function(){},onProgress:function(){},onSuccess:function(){}},e),this.el=t,this.parent=null,this.cCover=null,this.cDisplayer=null,this.width=this.config.width,this.height=this.config.height,this.point={left:0,top:0,prevX:0,prevY:0},this.pixelRatio=1,this.isDown=!1,this.isReady=!1,this.isDone=!1,this.lock=!0,this._init()}}();