Files
2023-08-25 13:31:04 +05:30

1 line
30 KiB
JavaScript

(()=>{var t={999:()=>{},502:()=>{},174:()=>{},966:()=>{},832:()=>{},242:()=>{},314:()=>{},407:()=>{},523:()=>{},558:()=>{},91:()=>{},763:()=>{}},e={};function i(n){var s=e[n];if(void 0!==s)return s.exports;var a=e[n]={exports:{}};return t[n](a,a.exports,i),a.exports}(()=>{"use strict";const t=function(t,e){for(var i=Math.abs(t)+"",n=t<0,s=e-i.length;s>0;s--)i="0"+i;return(n?"-":"")+i};var e={create:function(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(i=-1===e.SVG_ELEMENTS.indexOf(t)?document.createElement(t):document.createElementNS(e.SVG_NAMESPACE,t),n.constructor===String)i.setAttribute("class",n);else for(var a in n)i.setAttribute(a,n[a]);if(s instanceof Array)for(var r=0;r<s.length;r++)i.appendChild(s[r]);else i.textContent=s;return i},icon:function(t){var i=e.create("use");return i.setAttributeNS(e.XLINK_NAMESPACE,"href","#icon-"+t),e.create("svg",{class:"icon"},[i])},clear:function(t){for(var e=t.childNodes.length-1;e>=0;e--)t.childNodes[e].remove()},SVG_NAMESPACE:"http://www.w3.org/2000/svg",XLINK_NAMESPACE:"http://www.w3.org/1999/xlink",SVG_ELEMENTS:["svg","g","circle","line","path","use","rect"]};const n=e;function s(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)}}i(999);var a=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.setupTemplate()}var i,a;return i=e,a=[{key:"setupTemplate",value:function(){this.counterEl=n.create("span","countdown-counter"),this.barEl=n.create("span","countdown-content");var t=n.create("span","countdown-container",[this.barEl]);return this.el=n.create("div","countdown",[this.counterEl,t]),this.el}},{key:"setTimer",value:function(t,e){this.duration=t,this.remaining=t,this.endCallback=e,this.render()}},{key:"start",value:function(){this.interval||(this.interval=window.setInterval(this.decrement.bind(this),1e3))}},{key:"stop",value:function(){window.clearInterval(this.interval),this.interval=null}},{key:"decrement",value:function(){this.remaining--,this.render()}},{key:"render",value:function(){this.remaining=this.remaining>0?this.remaining:0,this.el.classList[this.remaining>10?"remove":"add"]("alert"),this.counterEl.textContent=t(this.remaining,3),this.barEl.style.width=this.remaining/this.duration*100+"%",0==this.remaining&&(this.stop(),this.endCallback&&this.endCallback())}}],a&&s(i.prototype,a),Object.defineProperty(i,"prototype",{writable:!1}),e}();const r=a;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)}}i(558);const l=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.cancelCallback=t,this.counterVal=null,this.setupTemplate()}var i,s;return i=e,(s=[{key:"setupTemplate",value:function(){return this.cancelBtnEl=n.create("button","status-bar-cancel","ABORT"),this.counterEl=n.create("span","status-bar-info"),this.countdown=new r,this.countdownEl=this.countdown.el,this.countdownEl.setAttribute("class","status-bar-info"),this.el=n.create("div","status-bar ui-row",[this.cancelBtnEl,this.counterEl,this.countdownEl]),this.el}},{key:"init",value:function(){var t=this;this.cancelBtnEl.addEventListener("click",(function(){t.cancelCallback(0)}))}},{key:"setCounter",value:function(t){this.counterEl.style.display="inherit",this.countdownEl.style.display="none",this.counterVal=t,this.updateCounter()}},{key:"updateCounter",value:function(){return this.counterEl.textContent=t(this.counterVal,3),this.counterVal}},{key:"decrementCounter",value:function(){return this.counterVal--,this.updateCounter()}},{key:"incrementCounter",value:function(){return this.counterVal++,this.updateCounter()}},{key:"setCountdown",value:function(t){var e=this;this.counterEl.style.display="none",this.countdownEl.style.display="inherit",this.countdown.setTimer(t,(function(){e.cancelCallback(1)})),this.countdown.start()}},{key:"stopCountdown",value:function(){this.countdown.stop()}}])&&o(i.prototype,s),Object.defineProperty(i,"prototype",{writable:!1}),e}();function c(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)}}i(966);var u=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.lastPattern=null,this.setupTemplate()}var e,i;return e=t,i=[{key:"setupTemplate",value:function(){return this.containerEl=n.create("div","history-container",""),this.el=n.create("div","history scrollbarlesque",[this.containerEl]),this.el}},{key:"stackPattern",value:function(t){this.lastPattern?this.containerEl.insertBefore(t,this.lastPattern):this.containerEl.appendChild(t),this.lastPattern=t,this.scrollToStart()}},{key:"scrollToStart",value:function(){var t=this.el.scrollLeft;this.el.scrollLeft=(Math.max(t/4,4),0),this.el.scrollLeft>0&&window.requestAnimationFrame(this.scrollToStart.bind(this))}},{key:"clear",value:function(t){this.lastPattern=null,this.containerEl.remove(),this.containerEl=n.create("div",{class:"history-container","data-helper":t}),this.el.appendChild(this.containerEl)}}],i&&c(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();const h=u;function d(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)}}var p=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dotLength=e,this.suite=[]}var e,i;return e=t,i=[{key:"fillRandomly",value:function(){for(;!this.isComplete();)this.addDot(Math.floor(9*Math.random()))}},{key:"addDot",value:function(t){if(this.isComplete()||~this.suite.indexOf(t))return[];var e=this.suite[this.suite.length-1],i=(e+t)/2;if(null!=e&&i>>0===i&&e%3-i%3==i%3-t%3&&Math.floor(e/3)-Math.floor(i/3)==Math.floor(i/3)-Math.floor(t/3)){var n=this.addDot(i);return this.isComplete()||(this.suite.push(t),n.push(t)),n}return this.suite.push(t),[t]}},{key:"isComplete",value:function(){return this.suite.length>=this.dotLength}},{key:"gotDot",value:function(t){return~this.suite.indexOf(t)}},{key:"compare",value:function(t){for(var e=0,i=0,n=0;n<this.dotLength;n++){this.suite[n]===t.suite[n]&&e++;for(var s=0;s<this.dotLength;s++)this.suite[s]===t.suite[n]&&i++}return[e,i-e,this.dotLength-i]}},{key:"reset",value:function(){this.suite=[]}}],i&&d(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();const f=p;function v(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)}}var y=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.el=n.create("svg",{viewBox:"0 0 "+this.SVG_WIDTH+" "+this.SVG_WIDTH})}var e,i;return e=t,i=[{key:"addBackgroundLayer",value:function(){var t=n.create("rect",{fill:"#fff","fill-opacity":"0",width:this.SVG_WIDTH,height:this.SVG_WIDTH});return this.el.appendChild(t),t}},{key:"addPattern",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#fff",s=[];i=i instanceof Array?i:[i];for(var a=1;a<t.suite.length;a++)s.push(n.create("line",{x1:t.suite[a-1]%3*this.GRID_GUTTER+this.SVG_MARGIN,y1:Math.floor(t.suite[a-1]/3)*this.GRID_GUTTER+this.SVG_MARGIN,x2:t.suite[a]%3*this.GRID_GUTTER+this.SVG_MARGIN,y2:Math.floor(t.suite[a]/3)*this.GRID_GUTTER+this.SVG_MARGIN,stroke:i[Math.min(i.length,a)-1]}));var r=t.suite[t.suite.length-1];return s.push(n.create("circle",{cx:r%3*this.GRID_GUTTER+this.SVG_MARGIN,cy:Math.floor(r/3)*this.GRID_GUTTER+this.SVG_MARGIN,fill:i[0],r:e/4})),this.addGroup({"stroke-width":e,"stroke-linecap":"round"},s)}},{key:"addDots",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=[];e.fill=e.fill||"#fff";for(var s=0;s<9;s++)i.push(n.create("circle",{cx:s%3*this.GRID_GUTTER+this.SVG_MARGIN,cy:Math.floor(s/3)*this.GRID_GUTTER+this.SVG_MARGIN,rel:s,r:t}));return this.addGroup(e,i)}},{key:"addGroup",value:function(t,e){var i=n.create("g",t,e);return this.el.appendChild(i),i}},{key:"addCombinaison",value:function(t,e,i){var s=t+e+i,a=Math.min(Math.floor(this.SVG_WIDTH/s),this.SVG_COMB_EXP),r=Math.floor(.75*a),o=r+Math.floor(.25*a),l=Math.floor((this.SVG_WIDTH-(s-1)*o)/2),c=this.SVG_WIDTH+Math.floor(this.SVG_COMB_EXP/2);this.el.setAttribute("viewBox","0 0 "+this.SVG_WIDTH+" "+(this.SVG_WIDTH+this.SVG_COMB_EXP));for(var u=[],h=0;h<s;h++)u.push(n.create("circle",{cx:l+h*o,cy:c,r:(r-this.DOT_BORDER)/2,"stroke-width":this.DOT_BORDER,fill:h<t?"#fff":"#000",stroke:h<t+e?"#fff":"#000","fill-opacity":h<t?"1":".25","stroke-opacity":h<t+e?"1":".25"}));return this.addGroup({},u)}},{key:"getSVG",value:function(){return this.el}}],i&&v(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();y.prototype.SVG_NAMESPACE="http://www.w3.org/2000/svg",y.prototype.SVG_WIDTH=100,y.prototype.SVG_COMB_EXP=20,y.prototype.SVG_MARGIN=15,y.prototype.GRID_GUTTER=35,y.prototype.DOT_BORDER=2,y.prototype.DOT_MAGNET=6;const m=y,b={GAME:{DIFFICULTY:{EASY:4,MEDIUM:5,HARD:6},TYPE:{PRACTICE:1,CHALLENGE:2,COUNTDOWN:3},ACTIONS:{SOLUTION:1,NEW_GAME:2,BACK_HOME:3}},SOCIAL:{PLATFORMS:{FB:{NAME:"Facebook",ICON:"facebook",URL:function(t){return"https://www.facebook.com/sharer/sharer.php?u=".concat(encodeURI(t))}},TWITTER:{NAME:"Twitter",ICON:"twitter",URL:function(t,e,i){return"http://twitter.com/"+(t?"share?":"intent/tweet?")+(e?"text=".concat(encodeURI(e),"&"):"")+(t?"url=".concat(encodeURI(t),"&"):"")+(i?"hashtags=".concat(encodeURI(i.join(","))):"")}}},MESSAGE:"I wasted my time on BreakLock, it's pointless, don't try it.",TAGS:["breaklock"]},URL:"https://maxwellito.github.io/breaklock/",COLORS:{BRIGHT:"#ffffff",DARK:"#14171b",SUCCESS:"#116699",ERROR:"#ff0000"},PATTERN:{HEX_COLOR_START:"66",HEX_COLOR_END:"FF"}};function E(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)}}i(242);const g=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.currentLine=null,this.onNewPattern=e,this.setupTemplate()}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){var t=new m;return t.addBackgroundLayer(),this.el=t.getSVG(),this.el.setAttribute("class","lock"),this.patternEl=t.addGroup({"stroke-width":"2",stroke:b.COLORS.BRIGHT,"stroke-linecap":"round"}),this.bigDotsEl=t.addDots(9,{class:"lock-flashdots"}),t.addDots(2),this.el}},{key:"init",value:function(){this.el.addEventListener("touchstart",this.touchStart.bind(this)),this.el.addEventListener("touchmove",this.touchUpdate.bind(this)),this.el.addEventListener("touchend",this.touchEnd.bind(this)),this.el.addEventListener("mousedown",this.mouseStart.bind(this))}},{key:"setDotLength",value:function(t){this.dotLength=t,this.pattern=new f(this.dotLength)}},{key:"mouseStart",value:function(t){this.reset(),this.mouseUpdateBind=this.mouseUpdate.bind(this),this.mouseEndBind=this.mouseEnd.bind(this),this.el.addEventListener("mousemove",this.mouseUpdateBind),window.addEventListener("mouseleave",this.mouseEndBind),window.addEventListener("mouseup",this.mouseEndBind),this.mouseUpdate(t)}},{key:"mouseUpdate",value:function(t){t.preventDefault(),t.stopPropagation();var e=t.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.prototype.SVG_WIDTH,Math.round(m.prototype.SVG_WIDTH/e.width*(t.pageX-e.left)))),n=Math.max(0,Math.min(m.prototype.SVG_WIDTH,Math.round(m.prototype.SVG_WIDTH/e.height*(t.pageY-e.top))));this.updatePoint(i,n)}},{key:"mouseEnd",value:function(t){this.isPendingReset||this.reset(),this.el.removeEventListener("mousemove",this.mouseUpdateBind),window.removeEventListener("mouseout",this.mouseEndBind),window.removeEventListener("mouseup",this.mouseEndBind)}},{key:"touchStart",value:function(t){this.reset(),this.touchUpdate(t)}},{key:"touchUpdate",value:function(t){t.preventDefault(),t.stopPropagation();var e=t.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.prototype.SVG_WIDTH,Math.round(m.prototype.SVG_WIDTH/e.width*(t.targetTouches[0].pageX-e.left)))),n=Math.max(0,Math.min(m.prototype.SVG_WIDTH,Math.round(m.prototype.SVG_WIDTH/e.height*(t.targetTouches[0].pageY-e.top))));this.updatePoint(i,n)}},{key:"touchEnd",value:function(){this.isPendingReset||this.reset()}},{key:"updatePoint",value:function(t,e){if(!this.isPendingReset){for(var i,n,s,a=0;a<3;a++){var r=m.prototype.GRID_GUTTER*a+m.prototype.SVG_MARGIN-m.prototype.DOT_MAGNET,o=m.prototype.GRID_GUTTER*a+m.prototype.SVG_MARGIN+m.prototype.DOT_MAGNET;i=r<=t&&o>=t?a:i,n=r<=e&&o>=e?a:n}if(void 0!==i&&null!=n){var l=3*n+i;s=this.triggerDot(l)}return s||this.updateLine(t,e),!0}}},{key:"triggerDot",value:function(t){var e=this;if(!this.pattern.gotDot(t)){var i=this.pattern.addDot(t);navigator.vibrate&&navigator.vibrate(20),i.forEach((function(t,n){var s=m.prototype.GRID_GUTTER*(t%3)+m.prototype.SVG_MARGIN,a=m.prototype.GRID_GUTTER*Math.floor(t/3)+m.prototype.SVG_MARGIN;if(e.closeLine(s,a),e.bigDotsEl.childNodes[t].classList.add("active"),n+1===i.length&&e.pattern.isComplete())return e.checkPattern();e.startLine(s,a)}))}}},{key:"reset",value:function(){clearTimeout(this.isPendingReset),this.isPendingReset=null,this.pattern.reset(),this.currentLine=null;for(var t=0;t<9;t++)this.bigDotsEl.childNodes[t].classList.remove("active");for(var e=this.patternEl.childNodes.length-1;e>=0;e--)this.patternEl.childNodes[e].remove();this.patternEl.setAttribute("stroke",b.COLORS.BRIGHT)}},{key:"checkPattern",value:function(){var t=this.onNewPattern(this.pattern);return this.isPendingReset=setTimeout(this.reset.bind(this),1e3),this.patternEl.setAttribute("stroke",t?b.COLORS.SUCCESS:b.COLORS.ERROR),t}},{key:"startLine",value:function(t,e){this.currentLine=n.create("line",{x1:t,y1:e}),this.patternEl.appendChild(this.currentLine)}},{key:"updateLine",value:function(t,e){this.currentLine&&(this.currentLine.setAttribute("x2",t),this.currentLine.setAttribute("y2",e))}},{key:"closeLine",value:function(t,e){this.updateLine(t,e),this.currentLine=null}}])&&E(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();var T=[{min:1,max:3,text:"That was pure luck, nothing else. Stop dreamin."},{min:2,max:4,text:"You got lucky, without staying up all night."},{min:1,max:2,text:"No merit. Absolutely none."},{min:2,max:5,text:"That was given on a golden plate."},{min:1,max:4,text:"Absolutely no synapse got used during that game."},{min:2,max:5,text:"Don\'t even dare to tweet your score."},{min:8,max:10,text:"Saperlipopette!! That was close."},{min:4,max:8,text:"Seems legit, with a bit of luck."},{min:7,max:10,text:"Pretty good!"},{min:9,max:10,text:"But you made it!"},{min:11,max:50,text:"Trying random patterns is not a strategy..."},{min:11,max:50,text:"That was looooooooong."},{min:11,max:50,text:"At least you made it."},{min:11,max:50,text:"You must hate this game by now."},{min:11,max:50,text:"I hope you didn\'t cheat."},{min:41,max:403,text:"Your dedication is impressive."},{min:404,max:404,text:"Logic not found."},{min:405,max:999,text:"No comment"}],k=["I believe there\'s some work to do.","Do you understand the game? Don\'t take it personnaly, I struggle to explain it.","One day you will make it...","It\'s not funny for you, but it is for me ;)","Don\'t stress, you will make it.","If you want to avoid battles, stay out of the grassy areas!","Even if you loose in battle, if you surpass what you\'ve done before, you have bested yourself.","TILT! Insert coin and try again"];var w=[];function C(t){for(var e=w.length-1;e>=0;e--)if(w[e].el===t)return w.splice(e,1)[0]}function _(t){if(t.counter-=1,t.counter<=0)return t.el.textContent=t.originalText,void C(t.el);var e=Math.floor(t.originalLength-t.counter/3);t.el.textContent=t.originalText.substr(0,e)+function(t){var e="",i="abcdefghijklmnopqrstuvwxyz0123456789 _*%!?#/\\|@";if(t<=0)return e;for(var n=0;n<t;n++)e+=i.charAt(Math.floor(Math.random()*i.length));return e}(Math.min(t.originalLength-e,3)),function(t){var e;t.nextFrame=(e=function(){_(t)},window.setTimeout(e,60))}(t)}const L=function(t,e){var i,n=C(t);n&&(i=n.nextFrame,window.clearTimeout(i));var s={el:t,counter:3*e.length,originalLength:e.length,originalText:e,nextFrame:null};_(s),w.push(s)};function G(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)}}i(91);const S=function(){function t(e){var i,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),n={NEW_GAME:"NEW_GAME",SOLUTION:"SOLUTION",BACK_HOME:"BACK_HOME"},(i="actionLabels")in this?Object.defineProperty(this,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[i]=n,this.onAction=e,this.setupTemplate(),this.init()}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){for(var t in this.actionButtons=[],b.GAME.ACTIONS){var e=n.create("button",{class:"summary-action-button",rel:b.GAME.ACTIONS[t]},[n.icon(t.toLowerCase()),n.create("span",{},this.actionLabels[t])]);this.actionButtons.push(e)}for(var i in this.socialButtons=[],b.SOCIAL.PLATFORMS){var s=n.create("a",{class:"summary-share-link",rel:"noopener noreferrer",target:"_blank",platform:i},[n.icon(b.SOCIAL.PLATFORMS[i].ICON)]);this.socialButtons.push(s)}var a=n.create("div","summary-feedback bloc",[n.create("p",{},[n.create("span",{},"Tweet me your feedback at "),n.create("a",{href:b.SOCIAL.PLATFORMS.TWITTER.URL("","@mxwllt",["breaklock"])},"@mxwllt")])]);return this.titleEl=n.create("h1","summary-title highlight"),this.detailsEl=n.create("p","summary-details"),this.revealEl=n.create("p","summary-reveal","Please select an option."),this.actionsEl=n.create("div","summary-actions bloc",this.actionButtons),this.socialEl=n.create("div","summary-share bloc",this.socialButtons),this.el=n.create("div","summary view",[n.create("div","view-bloc",[this.titleEl,this.detailsEl,this.revealEl]),n.create("div","view-bloc",[this.actionsEl,this.socialEl,a])]),this.el}},{key:"init",value:function(){var t=this;this.actionButtons.forEach((function(e){return e.addEventListener("click",t.triggerAction.bind(t))}))}},{key:"setContent",value:function(t,e){this.titleEl.classList.remove("fail"),this.titleEl.classList.remove("success"),this.titleEl.classList.add(t?"success":"fail"),L(this.titleEl,t?"Success!":"Fail!"),this.detailsEl.textContent=function(t,e){var i,n;return t?(i="Lock found in ".concat(e," attempts. "),n=T.filter((function(t){return t.min<=e&&t.max>=e})).map((function(t){return t.text}))):(i="Sorry, you didn\'t make it this time. ",n=k),i+n[Math.floor(n.length*Math.random())]}(t,e),this.revealEl.classList[t?"add":"remove"]("hide"),this.updateSocialLinks(),this.toggle(!0)}},{key:"toggle",value:function(t){t=null!=t?t:!this.el.classList.contains("active"),this.el.classList[t?"add":"remove"]("active")}},{key:"triggerAction",value:function(t){var e=parseInt(t.currentTarget.getAttribute("rel")||0,10);this.onAction(e)}},{key:"updateSocialLinks",value:function(){this.socialButtons.forEach((function(t){var e=t.getAttribute("platform"),i=b.SOCIAL.PLATFORMS[e];t.setAttribute("href",i.URL(b.URL,b.SOCIAL.MESSAGE,b.SOCIAL.TAGS))}))}}])&&G(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}(),A=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t="string"==typeof t?parseInt(t,16):t,e="string"==typeof e?parseInt(e,16):e,t=Math.min(255,Math.max(0,t));for(var n=[],s=((e=Math.min(255,Math.max(0,e)))-t)/++i,a=0;a<=i;a++){var r=Math.round(t+a*s),o=r.toString(16);n.push("#"+o+o+o)}return n};function I(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)}}i(174);const x=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.statusBar=new l(this.abort.bind(this)),this.history=new h,this.lock=new g(this.newAttempt.bind(this)),this.summary=new S(this.action.bind(this)),this.pattern=null,this.type=null,this.isEnded=!1,this.onEnd=e,this.statusBar.init(),this.lock.init(),this.setupTemplate()}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){return this.el=n.create("div","game-layout view",[n.create("div","view-bloc game-layout-dashboard",[this.statusBar.el,n.create("div","history-wrap",[this.history.el])]),n.create("div","view-bloc game-layout-lock",[this.lock.el]),this.summary.el]),this.el}},{key:"start",value:function(t,e){switch(this.type=t,this.difficulty=e,this.lock.setDotLength(e),this.pattern=new f(e),this.pattern.fillRandomly(),this.history.clear("Connect "+e+" dots"),this.count=0,this.isEnded=!1,t){case b.GAME.TYPE.PRACTICE:return this.statusBar.setCounter(0);case b.GAME.TYPE.CHALLENGE:return this.statusBar.setCounter(10);case b.GAME.TYPE.COUNTDOWN:return this.statusBar.setCountdown(60)}}},{key:"newAttempt",value:function(t){var e=this.pattern.compare(t),i=this.buildPatternSVG(t,e),n=e[0]===this.pattern.dotLength;if(this.count++,this.isEnded)this.statusBar.incrementCounter();else if(n)this.type===b.GAME.TYPE.COUNTDOWN&&this.statusBar.stopCountdown(),this.isEnded=i,this.summary.setContent(!0,this.count);else switch(this.type){case b.GAME.TYPE.PRACTICE:this.statusBar.incrementCounter();break;case b.GAME.TYPE.CHALLENGE:0===this.statusBar.decrementCounter()&&(this.isEnded=!0,this.summary.setContent(!1,this.count))}return this.history.stackPattern(i),n}},{key:"abort",value:function(t){t?(this.isEnded=!0,this.statusBar.stopCountdown(),this.summary.setContent(!1,this.count)):this.onEnd()}},{key:"action",value:function(t){switch(t){case b.GAME.ACTIONS.NEW_GAME:this.start(this.type,this.difficulty);break;case b.GAME.ACTIONS.BACK_HOME:this.abort();break;case b.GAME.ACTIONS.SOLUTION:if(!0===this.isEnded){var e=this.pattern.compare(this.pattern),i=this.buildPatternSVG(this.pattern,e);this.history.stackPattern(i)}this.statusBar.setCounter(this.count)}this.summary.toggle()}},{key:"buildPatternSVG",value:function(t,e){var i=new m;i.addDots(1),i.addPattern(t,14,A(b.PATTERN.HEX_COLOR_START,b.PATTERN.HEX_COLOR_END,t.dotLength-3)),e&&m.prototype.addCombinaison.apply(i,e);var n=i.getSVG();return e[0]===t.dotLength&&n.classList.add("success"),n}}])&&I(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function M(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)}}i(502);const R=function(){function t(e,i,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.title=e,this.content=i,this.isExpanded=n,this.setupTemplate()}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){var t=this.content instanceof String?this.content:[this.content];return this.buttonEl=n.create("button","extender-button",this.title),this.contentEl=n.create("div","extender-content",t),this.el=n.create("div","extender small-only",[this.buttonEl,this.contentEl]),this.render(),this.el}},{key:"init",value:function(){this.buttonEl.addEventListener("click",this.toggle.bind(this))}},{key:"toggle",value:function(t){this.isExpanded=t instanceof Boolean?t:!this.isExpanded,this.render()}},{key:"render",value:function(){this.el.classList[this.isExpanded?"add":"remove"]("active")}}])&&M(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();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)}}i(407);const P=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setupTemplate(),this.setChoices(e)}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){return this.el=n.create("div","selectbox"),this.el}},{key:"setChoices",value:function(t){var e=this,i=this.selectListener.bind(this);t.forEach((function(t,s){var a=n.create("span",{class:"selectbox-item",rel:t.value},t.label);return a.addEventListener("click",i),a.addEventListener("touchstart",i),e.el.appendChild(a),t.default&&e.selectFromTag(a),a})),this.el.classList.add("selectbox-"+t.length)}},{key:"selectListener",value:function(t){t.preventDefault(),t.stopPropagation(),this.selectFromTag(t.currentTarget)}},{key:"selectFromTag",value:function(t){this.selectedTag&&this.selectedTag.classList.remove("active"),this.selectedTag=t,this.selectedTag.classList.add("active"),this.selectedValue=window.parseInt(t.getAttribute("rel"),10)}},{key:"getValue",value:function(){return this.selectedValue}}])&&O(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function D(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)}}i(523);const N=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.selectionIndex=0,this.setupTemplate(),this.setChoices(e)}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){return this.btnLeft=n.create("span","selectbox-item active selector-left","<"),this.btnRight=n.create("span","selectbox-item active selector-right",">"),this.labelEl=n.create("span","selectbox-item selector-label"),this.el=n.create("div","selector selectbox",[this.btnLeft,this.btnRight,this.labelEl]),this.el}},{key:"init",value:function(){this.btnLeft.addEventListener("click",this.previous.bind(this)),this.btnLeft.addEventListener("touchstart",this.previous.bind(this)),this.btnRight.addEventListener("click",this.next.bind(this)),this.btnRight.addEventListener("touchstart",this.next.bind(this))}},{key:"setChoices",value:function(t){this.choices=t;for(var e=this.choices.length-1;e>=0;e--)this.selectionIndex=this.choices[e].default?e:this.selectionIndex;this.selectionIndex=this.selectionIndex||0,this.updateLabel()}},{key:"updateLabel",value:function(){this.selectionIndex=(this.selectionIndex+this.choices.length)%this.choices.length;var t=this.choices[this.selectionIndex];return this.labelEl.textContent=t.label,this.selectCallback&&this.selectCallback(this.choices[this.selectionIndex]),this.selectionIndex}},{key:"next",value:function(t){return t.preventDefault(),t.stopPropagation(),this.selectionIndex++,this.updateLabel()}},{key:"previous",value:function(t){return t.preventDefault(),t.stopPropagation(),this.selectionIndex--,this.updateLabel()}},{key:"onSelect",value:function(t){this.selectCallback=t,this.updateLabel()}},{key:"getValue",value:function(){var t=this.choices[this.selectionIndex];return t&&t.value}}])&&D(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function B(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)}}i(832);const V=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setupTemplate(),this.setChoices([{value:"en",label:"English"},{value:"fa",label:"فارسی"},{value:"zh",label:"简体中文"}])}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){var t=this;return this.el=n.create("div","lang-selector disabled"),this.el.onclick=function(){return t.el.classList.toggle("disabled")},this.el}},{key:"setChoices",value:function(t){var e=n.create("div");t.forEach((function(t){var i=n.create("a",{href:t.value},t.label);e.appendChild(i),e.appendChild(n.create("br"))})),this.el.appendChild(e)}}])&&B(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();function U(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)}}i(314);const H=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.onStart=e,this.setupTemplate()}var e,i;return e=t,(i=[{key:"setupTemplate",value:function(){var t=n.create("h1","-wrap highlight unselectable","BreakLock"),e=n.create("p","menu-intro","A hybrid of Mastermind and the Android pattern lock. A game you gonna love to hate.");this.title=t,this.typeHelpEl=n.create("p",{},"Future info about the challenge"),this.btnStarlEl=n.create("button","action-btn","START_"),L(t,"BreakLock");var i=new R("INSTRUCTIONS",document.getElementById("instructions-template"));i.init(),this.difficultyOption=new P([{value:b.GAME.DIFFICULTY.EASY,label:"Easy",default:!0},{value:b.GAME.DIFFICULTY.MEDIUM,label:"Medium"},{value:b.GAME.DIFFICULTY.HARD,label:"Hard"}]),this.typeSelector=new N([{value:b.GAME.TYPE.PRACTICE,label:"Practice",description:"No pressure, just discover and practice your game",default:!0},{value:b.GAME.TYPE.CHALLENGE,label:"Challenge",description:"Challenge mode give you 10 attempts only to win"},{value:b.GAME.TYPE.COUNTDOWN,label:"Countdown",description:"Solve the game in one minute, without limit of attempts"}]),function(){for(var t=window.location.pathname.split("/");;){var e=t.pop();if(void 0===e)return"EN";if(2===e.length)return e.toUpperCase()}}();var s=n.create("button","lang-button",[n.icon("lang")]),a=new V;return s.onclick=function(){a.el.classList.toggle("disabled")},this.el=n.create("div","menu-layout view",[n.create("div","view-bloc menu-layout-instructions",[n.create("div","ui-row",[t,s]),e,a.el,i.el]),n.create("div","view-bloc menu-layout-form",[this.difficultyOption.el,this.typeSelector.el,this.typeHelpEl,this.btnStarlEl])]),this.el}},{key:"init",value:function(){this.typeSelector.init(),this.typeSelector.onSelect(this.typeChange.bind(this)),this.btnStarlEl.addEventListener("click",this.start.bind(this)),this.title.addEventListener("dblclick",this.triggerEasterEgg.bind(this))}},{key:"start",value:function(){this.onStart(this.typeSelector.getValue(),this.difficultyOption.getValue())}},{key:"typeChange",value:function(t){this.typeHelpEl.textContent=t.description}},{key:"triggerEasterEgg",value:function(){localStorage.getItem("isDeepBlack")?(localStorage.setItem("isDeepBlack",""),document.body.classList.remove("deepblack")):(localStorage.setItem("isDeepBlack","on"),document.body.classList.add("deepblack"))}}])&&U(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();i(763);var j=document.getElementById("app-intro");j&&j.remove();var q=document.body,W=new x((function(){F.el.style.display="",W.el.style.display="none"}));q.appendChild(W.el);var F=new H((function(t,e){W.start(t,e),F.el.style.display="none",W.el.style.display=""}));F.init(),q.appendChild(F.el),W.el.style.display="none",window.scrollTo(0,0)})()})();