var e=window.matchMedia("(max-width: 600px)");if(e.matches){var t=document.getElementById("gameField");t.style.height=window.innerHeight-75+"px"}const o={colors:["#F0F0F0","#FFED02","#FFB300","#D19700","#467700","#004734","#00339B","#E4231B","#86000E","#652516","#271D15","#001C43","#0C0C0C"],numGuesses:6,numAnswerBlocks:3,colorWeight:[.5,.34,.16],graphSplit:[50,8,17,25],correctColor:"forestgreen",misplacedColorLight:"#FFEA00",misplacedColorDark:"#d4c200",wrongColorLight:"#d3d3d3",wrongColorDark:"#36393b",graphBorderLight:"#ffffff",graphBorderDark:"#222425",lsCurr:"paint_currentPuzzle",lsAnswerPie:"paint_answerPieCurr",lsAnswerPieData:"paint_answerPieCurrData",lsTurn:"paint_turn",lsActive:"paint_activeBlock",lsBoard:"paint_guessBoard",lsBoardBorders:"paint_guessBoardBorders",lsColorFieldStatus:"paint_colorFieldStatus",lsGameOver:"paint_gameOver",lsCurrSelectedAvg:"paint_selectedAvg",lsWinStreak:"paint_winStreak",lsLongestStreak:"paint_longestStreak",lsWins:"paint_wins",lsLastCompleted:"paint_lastCompleted",lsSeenFaq:"seenFaq",lsDarkMode:"darkMode",lsContSession:"contSession"};var l=0,a=0,r=localStorage.getItem(o.lsSeenFaq),s=localStorage.getItem(o.lsDarkMode);const n=window.matchMedia("(prefers-color-scheme: dark)");var d=document.getElementById("lightDarkIcon");1==s?(document.body.classList.add("dark-mode"),d.classList.remove("fa-moon"),d.classList.add("fa-sun")):null==s&&n.matches?(s=1,localStorage.setItem(o.lsDarkMode,1),document.body.classList.add("dark-mode"),d.classList.remove("fa-moon"),d.classList.add("fa-sun")):s=0;var c,i=1==s?o.wrongColorDark:o.wrongColorLight,g=1==s?o.misplacedColorDark:o.misplacedColorLight,u=1==s?o.graphBorderDark:o.graphBorderLight;1!=r&&setTimeout((function(){document.getElementById("faqModal").style.display="block"}),400),localStorage.setItem(o.lsSeenFaq,"1");var m,y,p,h,b=0,f=0,C=0,k=[],S=[...Array(o.numGuesses)].map(e=>Array(o.numAnswerBlocks).fill(-1)),B=[...Array(o.numGuesses)].map(e=>Array(o.numAnswerBlocks).fill(0)),v=[Array(o.colors.length).fill(0),Array(o.colors.length).fill(0)],I=[],w=[],E=-1,L=[],M=[],A=[],D=[];for(let e=0;e+V+1&&(Q=0),h){var Z=localStorage.getItem(o.lsAnswerPie),ee=localStorage.getItem(o.lsAnswerPieData),te=localStorage.getItem(o.lsCurrSelectedAvg),oe=localStorage.getItem(o.lsGameOver),le=localStorage.getItem(o.lsTurn),ae=localStorage.getItem(o.lsActive),re=localStorage.getItem(o.lsBoard),se=localStorage.getItem(o.lsBoardBorders),ne=localStorage.getItem(o.lsColorFieldStatus);null!=Z&&null!=ee&&null!=le&&null!=ae&&null!=oe&&null!=re&&null!=se&&null!=ne&&null!=te&&($=JSON.parse(Z),j=JSON.parse(ee),b=le,f=ae,C=oe,S=JSON.parse(re),B=JSON.parse(se),v=JSON.parse(ne),E=te)}else localStorage.setItem(o.lsTurn,b),localStorage.setItem(o.lsActive,f),localStorage.setItem(o.lsGameOver,C),localStorage.setItem(o.lsAnswerPie,JSON.stringify($)),localStorage.setItem(o.lsAnswerPieData,JSON.stringify(j)),localStorage.setItem(o.lsCurrSelectedAvg,E),localStorage.setItem(o.lsBoard,JSON.stringify(S)),localStorage.setItem(o.lsBoardBorders,JSON.stringify(B)),localStorage.setItem(o.lsColorFieldStatus,JSON.stringify(v)),localStorage.setItem(o.lsCurr,H);var de=7,ce=0;for(let e=0;e<3;e++){let t=document.createElement("div");t.classList.add("colorRow"),document.getElementById("colorField").appendChild(t);for(let l=0;l=b)n.appendChild(c);else{var Ce=He([S[e][0],S[e][1],S[e][2],S[e][3]]),ke=je(Ce),Se=350;1==s&&(Se=400),Ce.r+Ce.g+Ce.ba&&(a=Be),d.innerHTML=Be+"%",n.classList.add("avgBlockActive"),n.onclick=Te}else n.appendChild(c);I.push(n),L.push(c),w.push(d)}var ve=localStorage.getItem(o.lsContSession);if(0!=C&&(document.getElementById("accuracyStat").innerHTML=Math.round(10*l/b)/10+"%!",1!=ve&&setTimeout((function(){document.getElementById("statsModal").style.display="block"}),600)),localStorage.setItem(o.lsContSession,0),!ie){var Ie=document.getElementsByClassName("guessBlock");Array.prototype.forEach.call(Ie,(function(e){e.style.height=e.offsetWidth+"px",e.style.width=e.offsetHeight+"px"})),Ie=document.getElementsByClassName("avgBlock"),Array.prototype.forEach.call(Ie,(function(e){e.style.width=e.offsetHeight+"px"})),(ge=document.getElementById("chartDiv")).style.width=ge.offsetHeight+"px"}function we(){E>=0&&(I[E].classList.remove("avgBlockSelected"),E=-1,localStorage.setItem(o.lsCurrSelectedAvg,E))}function Ee(){if(0==C&&f==o.numAnswerBlocks&&b=0&&I[E].classList.remove("avgBlockSelected"),E=b,localStorage.setItem(o.lsCurrSelectedAvg,E),I[b].classList.add("avgBlockSelected"),I[b].classList.add("avgBlockActive"),I[b].onclick=Te,L[b].remove();var n=We(e,y);if(l+=n,n>a&&(a=n),w[b].innerHTML=n+"%",I[b].setAttribute("data-animation","pop"),Je(),2!=C&&Le(y,t),b++,localStorage.setItem(o.lsTurn,b),b==o.numGuesses&&0==C){for(let e=0;e=0;t--)t0&&b<6&&(f--,localStorage.setItem(o.lsActive,f),Ae(),we(),S[b][f]=-1,localStorage.setItem(o.lsBoard,JSON.stringify(S)),k[b][f].style.backgroundColor=1==s?"#878a8c":"#D3D3D3",k[b][f].removeAttribute("data-animation"))}function Te(e){if(2!=C)if(e.target.classList.contains("avgBlockSelected"))Ae(),we();else{var t=e.target.getAttribute("data-row");if(E!=t){E>=0&&I[E].classList.remove("avgBlockSelected"),e.target.classList.add("avgBlockSelected"),E=t,localStorage.setItem(o.lsCurrSelectedAvg,E);var l=je(Ye(t));Le(y,l)}}}function Oe(e){if(0==C&&fU&&(U=Q,localStorage.setItem(o.lsLongestStreak,U)),localStorage.setItem(o.lsLastCompleted,H),document.getElementById("winStat").innerHTML=K,document.getElementById("currentStreakStat").innerHTML=Q,document.getElementById("maxStreakStat").innerHTML=U}}function He(e){var t=Pe(e),o=Re(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function Pe(e){var t=0,l=0,a=0;for(let r=0;r255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),Ge({r:t,y:l,b:a})}function qe(e){var t=_e(e),o=ze(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function _e(e){var t=0,l=0,a=0;for(let s=0;s255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),Ge({r:t,y:l,b:a})}function Re(e){var t=0,l=0,a=0;for(let r=0;r255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),{r:t,g:l,b:a}}function ze(e){var t=0,l=0,a=0;for(let s=0;s255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),{r:t,g:l,b:a}}function Ye(e){var t=$e(e),o=Xe(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function Xe(e){var t=0,l=0,a=0;for(let r=0;r-1?",":" ";s=s.substr(4).split(")")[0].split(n);let d=+s[0],c=+s[1],i=+s[2];t+=d*o.colorWeight[r],l+=c*o.colorWeight[r],a+=i*o.colorWeight[r]}return(t=Math.round(t))>255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),{r:t,g:l,b:a}}function $e(e){var t=0,l=0,a=0;for(let s=0;s-1?",":" ";var r;n=n.substr(4).split(")")[0].split(d),(r={}).r=+n[0],r.g=+n[1],r.b=+n[2],ryb=Fe(r),t+=ryb.r*o.colorWeight[s],l+=ryb.y*o.colorWeight[s],a+=ryb.b*o.colorWeight[s]}return(t=Math.round(t))>255&&(t=255),(l=Math.round(l))>255&&(l=255),(a=Math.round(a))>255&&(a=255),r=Ge({r:t,y:l,b:a})}function je(e){return"rgb("+e.r+","+e.g+","+e.b+")"}document.addEventListener("keyup",(function(e){"Enter"===e.code&&Ee(),"Backspace"===e.code&&De()}));var Ke=document.getElementById("homeTitle");Ke.onclick=function(){localStorage.setItem(o.lsContSession,1),window.location.href="/"};var Qe=document.getElementById("faqModal"),Ue=document.getElementById("faq-button"),Ve=document.getElementById("faqClose"),Ze=document.getElementById("statsModal");Ue.onclick=function(){Qe.style.display="block"},Ve.onclick=function(){Qe.style.display="none"};var et=document.getElementById("statsModalContent"),tt=document.getElementById("faqModalContent");Qe.addEventListener("touchstart",(function(e){tt.contains(e.target)||(Qe.style.display="none",e.stopPropagation(),e.preventDefault())})),Ze.addEventListener("touchstart",(function(e){et.contains(e.target)||(Ze.style.display="none",e.stopPropagation(),e.preventDefault())})),window.onclick=function(e){e.target==Qe&&(Qe.style.display="none"),e.target==Ze&&(Ze.style.display="none"),e.target==rt&&(rt.style.display="none")};var ot=document.getElementById("stats-button"),lt=document.getElementById("lightdark-button"),at=document.getElementById("statsClose");ot.onclick=function(){Ze.style.display="block"},at.onclick=function(){Ze.style.display="none"},lt.onclick=function(){1!=s?(s=1,localStorage.setItem(o.lsDarkMode,s),localStorage.setItem(o.lsContSession,1),window.location.reload()):(s=0,localStorage.setItem(o.lsDarkMode,s),localStorage.setItem(o.lsContSession,1),window.location.reload())};var rt=document.getElementById("settingsModal");at=document.getElementById("statsClose");settingsClose.onclick=function(){rt.style.display="none"};var st=document.getElementById("shareButton");function nt(){var e=(new Date).getTime(),t=O.getTime()-e,o=Math.floor(t%864e5/36e5),l=Math.floor(t%36e5/6e4),a=Math.floor(t%6e4/1e3);document.getElementById("timerTilNext").innerHTML=o+"h "+l+"m "+a+"s",0==o&&0==l&&0==a&&(clearInterval(G),document.getElementById("timerTilNext").innerHTML="Available now!")}function dt(){var e="Colorfle ";e+=H+" (Paint Edition) ";var t=6;e+=2==C?(t=b)+"/6 \n":"X/6 \n";for(let l=0;l