(()=>{"use strict";var t,e=function(){function t(t,e,i){this.family=t,this.value=e,this.red=i,this.imgSrc="",this.imgFront=new Image,this.imgBack=new Image,this.img=new Image,this.tilt=0,this.setImgSrc()}return t.prototype.getFamily=function(){return this.family},t.prototype.getValue=function(){return this.value},t.prototype.isRed=function(){return this.red},t.prototype.setTilt=function(){this.tilt=.05*(1-2*Math.random())},t.prototype.drawTile=function(t,e,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=0),t.save(),t.translate(e+75*n/2,i+100*n/2),t.rotate(o+this.tilt),r?t.drawImage(this.imgBack,-75*n/2,-100*n/2,75*n,100*n):(t.drawImage(this.imgFront,-75*n/2,-100*n/2,75*n,100*n),t.drawImage(this.img,-75*n/2,-100*n/2,75*n,100*n)),t.restore()},t.prototype.isLessThan=function(t){return this.family0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0))return[];var e=this.tiles.pop(),n=this.count(e.getFamily(),e.getValue());if(n>=1&&!t){var r=this.find(e.getFamily(),e.getValue()),o=this.toGroup(!0);if(this.tiles.push(r),this.sort(),void 0!==o)return this.tiles.push(e),this.sort(),o.push(new i([e,r])),o}if(n>=2){r=this.find(e.getFamily(),e.getValue());var s=this.find(e.getFamily(),e.getValue());if(o=this.toGroup(t),this.tiles.push(r),this.tiles.push(s),this.sort(),void 0!==o)return o.push(new i([e,r,s])),this.tiles.push(e),this.sort(),o}if(this.count(e.getFamily(),e.getValue()-1)*this.count(e.getFamily(),e.getValue()-2)>0&&(r=this.find(e.getFamily(),e.getValue()-1),s=this.find(e.getFamily(),e.getValue()-2),o=this.toGroup(t),this.tiles.push(r),this.tiles.push(s),this.sort(),void 0!==o))return o.push(new i([s,r,e])),this.tiles.push(e),this.sort(),o;this.tiles.push(e),this.tiles.sort()},t.prototype.drawHand=function(t,e,i,n,r,o,s,l){void 0===o&&(o=void 0),void 0===s&&(s=!1),void 0===l&&(l=0);for(var a=(75+n)*r,u=Math.cos(l)*a,h=Math.sin(l)*a,c=0;c0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0;){var i=Math.floor(Math.random()*this.tiles.length);t=[this.tiles[0],this.tiles[i]],this.tiles[i]=t[0],this.tiles[0]=t[1],e.push(this.tiles.shift())}this.tiles=e},t.prototype.getRandomHand=function(){var t=new n;this.shuffle();for(var e=0;e<13;e++)t.push(this.pop());return t},t.prototype.cleanup=function(){this.tiles.forEach((function(t){return t.cleanup()})),this.tiles=[]},t.prototype.preload=function(){return t=this,e=void 0,n=function(){var t;return function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(l){return function(a){return function(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&l[0]?n.return:l[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,l[1])).done)return r;switch(n=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,n=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]=0&&r<14&&n>=800&&n<=875?r:void 0},i=function(t){void 0!==h&&(a[0].push(u[8].eject(h)),a[0].shuffle(),u[8].push(a[0].pop()),u[8].sort())},f.push((function(){p.removeEventListener("mousemove",e),p.removeEventListener("mousedown",i)})),p.addEventListener("mousemove",e),p.addEventListener("mousedown",i),requestAnimationFrame(m),window.cleanup=g,[2]}var e,i}))}))}().catch(console.error)})();