import{R as t,r as u}from"./index-56c1d501.js";import{c as cl}from"./clsx-e0889333.js";import{u as h,m as f,a as O,B as il,A as B,c as ml,b as dl,d as ul,e as fl,t as pl,Q as bl,P as gl}from"./redux-thunk-93cdf4f0.js";import{u as Y}from"./use-sound.esm-86ef9aee.js";import{c as xl,a as yl,b as El,u as Ze,d as et,e as wl}from"./cardShuffle-4c63ea56.js";import{a as hl}from"./achievement-bell-6816205c.js";import{a as kl,s as _l}from"./sadTrombone-a3e2bf79.js";import{a as bt,g as vl}from"./ststistic-3f81b54e.js";import{u as Nl}from"./use-drag-controls-effae275.js";import{u as gt}from"./use-animation-894d55ea.js";import{u as tt}from"./use-motion-value-626d9b9f.js";import{F as R,a as ue,s as Al,t as Sl,u as Il,v as jl,w as Tl,x as Ll,y as Ol,z as Cl,m as De,q as Rl,l as xt}from"./index-63998e7b.js";import{p as $l,d as Ml,a as Dl,P as Ul}from"./index-bdb71453.js";import"./fingerprint-374ab551.js";import{_ as Bl}from"./preload-helper-f61836a9.js";import"./recaptcha-v3-f0e7cd4f.js";import"./index-f11686b8.js";const K="black",ne="red",ve="spade",Ne="heart",Ae="club",Se="diamond",Ie=[ve,Ne,Ae,Se],Gl="ace",Pl="two",Hl="three",Fl="four",Vl="five",Yl="six",ql="seven",Wl="eight",zl="nine",Jl="ten",Xl="jack",Kl="queen",Ql="king",yt="CARD",S="COLUMN",M="FOUNDATION",C="FREECELL",Zl="TABLEAU",ee={suits:{[ve]:{icon:"♠",color:K},[Ne]:{icon:"♥",color:ne},[Ae]:{icon:"♣",color:K},[Se]:{icon:"♦",color:ne}},suitsByColor:{[K]:[ve,Ae],[ne]:[Ne,Se]},cards:[{name:Gl,label:"A"},{name:Pl,label:"2"},{name:Hl,label:"3"},{name:Fl,label:"4"},{name:Vl,label:"5"},{name:Yl,label:"6"},{name:ql,label:"7"},{name:Wl,label:"8"},{name:zl,label:"9"},{name:Jl,label:"10"},{name:Xl,label:"J"},{name:Kl,label:"Q"},{name:Ql,label:"K"}]},L=e=>JSON.parse(JSON.stringify(e)),Q=e=>{const l=Math.floor(e/3600),a=Math.floor(e%3600/60),n=e%60,r=`${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`;return l===0?r:`${l.toString().padStart(2,"0")}:${r}`},Et=e=>{const l=new Date(e);return Q(Math.floor((new Date().getTime()-l.getTime())/1e3))},Ue=(e,l)=>{const{left:a,right:n,top:r,bottom:s}=l.current.getBoundingClientRect();return e.clientX>=a&&e.clientX<=n&&e.clientY>=r&&e.clientY<=s},F=(e,l)=>e&&l&&e.suit===l.suit&&e.value===l.value,H=(e,l)=>e&&l&&`${e.suit[0].toUpperCase()}${e.value-1}`===l,wt=(e,l,a)=>({suit:e,value:l,...ee.suits[e],...ee.cards[l-1],dragable:!1,...la(e,l),parent:a}),ea=e=>{const a={columns:e.board.map((n,r)=>({index:r,cards:n.map(s=>{const c=Ie.find(o=>o[0]===s[0].toLowerCase());return wt(c,parseInt(s.slice(1))+1,{type:S,index:r})})})),cards:[]};for(let n=0;n<8;n++)He(a,n);return a},Be=e=>{let l={};return e&&(l=ea(e)),{freecells:Array.from({length:4},(a,n)=>({index:n,card:null})),foundations:Ie.map((a,n)=>({index:n,suit:a,cards:[]})),columns:Array.from({length:8},(a,n)=>({index:n,cards:[]})),cards:Ie.flatMap(a=>Array.from({length:13},(n,r)=>wt(a,r+1,{type:Zl}))),...l}},Ge=(e,l)=>e.children.some(({suit:a,value:n})=>a===l.suit&&n===l.value),ta=(e,l)=>e.parents.some(({suit:a,value:n})=>a===l.suit&&n===l.value),Pe=(e,l)=>({...e,parent:l}),la=(e,l)=>{const a=ee.suits[e].color===K?ne:K,n=ee.suitsByColor[a];return{children:l>1?n.map(r=>({suit:r,value:l-1})):[],parents:l<13?n.map(r=>({suit:r,value:l+1})):[]}},te=(e,l)=>e&&(l.cards.length===0||Ge(l.cards[l.cards.length-1],e)),fe=(e,l,a)=>{const n=l.columns[a].cards.findIndex(r=>F(r,e));if(n>-1){for(let s=n;s<l.columns[a].cards.length-1;s++)if(!Ge(l.columns[a].cards[s],l.columns[a].cards[s+1]))return!1;const r=l.columns[a].cards.slice(n);return l.columns[a].cards=l.columns[a].cards.slice(0,n),He(l,a),r}else return!1},je=(e,l,a)=>{if(te(e[0],l.columns[a])){for(let n=0;n<e.length;n++)e[n]=Pe(e[n],{type:S,index:a});l.columns[a].cards=[...l.columns[a].cards,...e],He(l,a)}},He=(e,l)=>{let a=!0,n=e.columns[l].cards.length-1;if(!(n<0)){e.columns[l].cards[n].dragable=a;for(let r=e.columns[l].cards.length-2;r>=0;r--)a&&(r===e.columns[l].cards.length-1||ta(e.columns[l].cards[r+1],e.columns[l].cards[r]))?e.columns[l].cards[r].dragable=!0:(a=!1,e.columns[l].cards[r].dragable=!1)}},ht=(e,l)=>{const a=e.cards.findIndex(n=>F(n,l));if(a===-1)return!1;if(a===e.cards.length-1)return null;for(let n=a;n<e.cards.length-1;n++)if(!Ge(e.cards[n],e.cards[n+1]))return!1;return e.cards.slice(a+1)},Te=e=>e.card===null,pe=(e,l)=>{const a=L(e.freecells[l].card);return e.freecells[l].card=null,a},kt=(e,l,a)=>{e=Pe(e,{type:C,index:a}),l.freecells[a].card=e},lt=(e,l)=>e&&l.suit===e.suit&&l.cards.length+1===e.value,_t=(e,l,a)=>{e=Pe(e,{type:M,index:a}),e.dragable=!1,l.foundations[a].cards=[...l.foundations[a].cards,e]},Fe=e=>{for(let l=0;l<e.length;l++)if(e[l].cards.length<13)return!1;return!0},W=e=>{const l=[],{freecells:a,foundations:n,columns:r}=e,s=n.map(({index:o,suit:i,cards:m})=>({type:M,index:o,suit:i,value:m.length+1}));a.forEach(o=>{const i=s.find(m=>F(o.card,m));i&&l.push({from:{type:C,index:o.index},to:{type:M,index:i.index},card:L(o.card)})}),r.forEach(o=>{const i=s.find(m=>o.cards.length>0&&F(o.cards[o.cards.length-1],m));i&&l.push({from:{type:S,index:o.index},to:{type:M,index:i.index},card:L(o.cards[o.cards.length-1])})}),a.forEach(o=>{o.card&&r.forEach(i=>{te(o.card,i)&&l.push({from:{type:C,index:o.index},to:{type:S,index:i.index},card:L(o.card)})})});//! must update dragables before run this part
for(let o=0;o<8;o++)r[o].cards.forEach((i,m)=>{if(i.dragable){for(let d=0;d<8;d++)if(o!==d&&te(i,r[d])){const y=vt(e,d);r[o].cards.length-m<=y&&l.push({from:{type:S,index:r[o].index},to:{type:S,index:r[d].index},card:L(i),children:ht(r[o],i)})}}});const c=a.filter(o=>Te(o));return c.length>0&&r.forEach(o=>{o.cards.length>0&&l.push({from:{type:S,index:o.index},to:{type:C,index:c[0].index},card:L(o.cards[o.cards.length-1])})}),l},vt=(e,l=-1)=>{const a=e.freecells.reduce((r,s)=>r+(s.card===null?1:0),0),n=e.columns.reduce((r,s,c)=>r+(s.cards.length===0&&l!==c?1:0),0);return(a+1)*(n+1)},re=(e,l,a)=>{let n=0;for(let r=0;r<4;r++)n+=e.foundations[r].cards.length;return Math.max(n*250-a*100-Math.floor((new Date().getTime()-new Date(l).getTime())/1e3),0)},Nt=(e,l)=>{const a=[C,S,S,M][l[0]],n=W(e);return a===S?l[0]===1?n.filter(r=>r.to.type===a&&e.columns[r.to.index].cards.length>0&&H(r.card,l[1])&&H(e.columns[r.to.index].cards[e.columns[r.to.index].cards.length-1],l[2])):n.filter(r=>r.to.type===a&&e.columns[r.to.index].cards.length===0&&H(r.card,l[1])):n.filter(r=>r.to.type===a&&H(r.card,l[1]))},z=(e,l,a,n)=>{if(l<0||e.length<=l)return!1;const{to:r}=e[l];return r.type===a&&r.index===n},Le={played:0,completed:[],failed:0,streak:0,maxStreak:0},At=(e,l,a)=>{const n=St();n.played+=e,n.completed.push(...l),n.failed+=a,a===0?(n.streak+=1,n.maxStreak=Math.max(n.maxStreak,n.streak)):n.streak=0,localStorage.setItem("freecell-state","Completed"),localStorage.setItem("freecell-stats",JSON.stringify(n))},St=()=>{const e=localStorage.getItem("freecell-stats");return e?JSON.parse(e):Le},aa=()=>(localStorage.setItem("freecell-stats",JSON.stringify(Le)),Le),na=({playedTime:e,score:l,difficulty:a,isAuto:n,isUsedUndo:r})=>{At(1,[{playedTime:e,score:l,difficulty:a,isAuto:n,isUsedUndo:r}],0)},ra=()=>{At(1,[],1)},It=({suit:e,value:l})=>`${e.toUpperCase()[0]}${l-1}`,he=e=>e.map(({suit:l,value:a})=>It({suit:l,value:a})),oa=({cards:e,columns:l,freecells:a,foundations:n})=>({cards:he(e),columns:l.map(({cards:r})=>he(r)),freecells:a.map(({card:r})=>r?It(r):null),foundations:n.map(({cards:r})=>he(r))}),sa=(e,l)=>JSON.stringify(e.cards)===JSON.stringify(l.cards)&&JSON.stringify(e.columns)===JSON.stringify(l.columns)&&JSON.stringify(e.freecells)===JSON.stringify(l.freecells)&&JSON.stringify(e.foundations)===JSON.stringify(l.foundations),ca=(e,l)=>{for(let a=0;a<e.columns.length;a++){const n=e.columns[a];if(n.length>0&&n[n.length-1]===l){e.columns[a]=n.slice(0,n.length-1);break}}for(let a=0;a<e.freecells.length;a++)if(e.freecells[a]===l){e.freecells[a]=null;break}},ia=["S","H","C","D"],ma=(e,l)=>{if(ca(e,l[1]),l[0]===0){const a=e.freecells.indexOf(null);e.freecells[a]=l[1]}else if(l[0]===1){const a=e.columns.findIndex(n=>n[n.length-1]===l[2]);e.columns[a].push(l[1])}else if(l[0]===2){const a=e.columns.findIndex(n=>n.length===0);e.columns[a].push(l[1])}else if(l[0]===3){const a=ia.indexOf(l[1][0]);e.foundations[a].push(l[1])}},da=(e,l)=>{const a=oa(l),n={cards:[],columns:L(e.board),freecells:[null,null,null,null],foundations:[[],[],[],[]]};for(let r=-1;r<e.count-1;r++)if(r>-1&&ma(n,e.solution[r]),sa(a,n))return r+1;return 0},ua=async e=>new Promise(l=>setTimeout(l,e)),Ve=(e,l)=>{let a=0;return function(...n){const r=performance.now();if(!(r-a<l))return a=r,e(...n)}},jt="/build/assets/back0-4fb6bee4.png",Tt="/build/assets/back1-dea7a13a.png",Lt="/build/assets/back2-e7760619.png",Oe="/build/assets/ace-club-305b2666.webp",Ce="/build/assets/ace-diamond-df2c8159.webp",Re="/build/assets/ace-heart-6ed16f4b.webp",$e="/build/assets/ace-spade-bdd03d93.webp",at="/build/assets/ace-club-33f44092.webp",nt="/build/assets/ace-diamond-b06383ce.webp",rt="/build/assets/ace-heart-5243707f.webp",ot="/build/assets/ace-spade-2ee43642.webp",st="/build/assets/ace-club-ac8d6ed6.webp",ct="/build/assets/ace-diamond-5bb57cbd.webp",it="/build/assets/ace-heart-67fc3fc6.webp",mt="/build/assets/ace-spade-8c40dff3.webp",fa="/build/assets/jack-club-81336454.webp",pa="/build/assets/jack-diamond-34021226.webp",ba="/build/assets/jack-heart-01f48db4.webp",ga="/build/assets/jack-spade-a571a597.webp",xa="/build/assets/king-club-1b26eeb3.webp",ya="/build/assets/king-diamond-83fb81fb.webp",Ea="/build/assets/king-heart-e3836dce.webp",Ot="/build/assets/king-spade-b854987b.webp",wa="/build/assets/queen-club-40ecae4d.webp",ha="/build/assets/queen-diamond-12619e73.webp",ka="/build/assets/queen-heart-012b160a.webp",_a="/build/assets/queen-spade-93bd19e9.webp",va="/build/assets/jack-club-a7f5ec56.webp",Na="/build/assets/jack-diamond-63769c5c.webp",Aa="/build/assets/jack-heart-3ea04f59.webp",Sa="/build/assets/jack-spade-db13775d.webp",Ia="/build/assets/king-club-ac986644.webp",ja="/build/assets/king-diamond-ebdd843b.webp",Ta="/build/assets/king-heart-2b2a1ebd.webp",Ct="/build/assets/king-spade-b9743dbf.webp",La="/build/assets/queen-club-62768ba0.webp",Oa="/build/assets/queen-diamond-3c17f3c1.webp",Ca="/build/assets/queen-heart-fc53b2b2.webp",Ra="/build/assets/queen-spade-8f15c112.webp",$a="/build/assets/jack-club-1675dafd.webp",Ma="/build/assets/jack-diamond-b45418d7.webp",Da="/build/assets/jack-heart-1db1e71e.webp",Ua="/build/assets/jack-spade-1791c604.webp",Ba="/build/assets/king-club-a21c90f2.webp",Ga="/build/assets/king-diamond-611f60e2.webp",Pa="/build/assets/king-heart-448f9793.webp",Rt="/build/assets/king-spade-74958d67.webp",Ha="/build/assets/queen-club-55ea1829.webp",Fa="/build/assets/queen-diamond-90ee9f8f.webp",Va="/build/assets/queen-heart-fc1f1e29.webp",Ya="/build/assets/queen-spade-700be464.webp",dt=new URLSearchParams(window.location.search),N=dt.has("fullview")&&dt.get("fullview")==="true",$t=document.getElementById("root").getAttribute("data-game-title").replaceAll("\\",""),Mt=document.getElementById("root").getAttribute("data-menu").replaceAll("\\",""),Dt=document.getElementById("root").getAttribute("data-settings").replaceAll("\\",""),qa=document.getElementById("root").getAttribute("data-how-to-play").replaceAll("\\",""),Ut=document.getElementById("root").getAttribute("data-statics").replaceAll("\\",""),Wa=document.getElementById("root").getAttribute("data-congratulations").replaceAll("\\",""),Ye=document.getElementById("root").getAttribute("data-score").replaceAll("\\",""),Bt=document.getElementById("root").getAttribute("data-time").replaceAll("\\",""),Gt=document.getElementById("root").getAttribute("data-new-game").replaceAll("\\",""),za=document.getElementById("root").getAttribute("data-failed").replaceAll("\\",""),Ja=document.getElementById("root").getAttribute("data-no-moves-remaining").replaceAll("\\",""),Xa=document.getElementById("root").getAttribute("data-undo-last-move").replaceAll("\\",""),Ka=document.getElementById("root").getAttribute("data-card-type").replaceAll("\\",""),ut=document.getElementById("root").getAttribute("data-card").replaceAll("\\",""),ft=document.getElementById("root").getAttribute("data-background").replaceAll("\\",""),Qa=document.getElementById("root").getAttribute("data-options").replaceAll("\\",""),Za=document.getElementById("root").getAttribute("data-show-hint").replaceAll("\\","");document.getElementById("root").getAttribute("data-auto-move").replaceAll("\\","");const en=document.getElementById("root").getAttribute("data-sound").replaceAll("\\",""),tn=document.getElementById("root").getAttribute("data-new").replaceAll("\\",""),ln=document.getElementById("root").getAttribute("data-solver").replaceAll("\\",""),an=document.getElementById("root").getAttribute("data-stop-solving").replaceAll("\\",""),nn=document.getElementById("root").getAttribute("data-hint").replaceAll("\\","");document.getElementById("root").getAttribute("data-refresh").replaceAll("\\","");const rn=document.getElementById("root").getAttribute("data-reset").replaceAll("\\",""),on=document.getElementById("root").getAttribute("data-undo").replaceAll("\\",""),sn=document.getElementById("root").getAttribute("data-redo").replaceAll("\\",""),cn=document.getElementById("root").getAttribute("data-fullscreen").replaceAll("\\",""),mn=document.getElementById("root").getAttribute("data-windowed").replaceAll("\\",""),Pt=document.getElementById("root").getAttribute("data-easy").replaceAll("\\",""),dn=document.getElementById("root").getAttribute("data-medium").replaceAll("\\",""),un=document.getElementById("root").getAttribute("data-hard").replaceAll("\\",""),fn=document.getElementById("root").getAttribute("data-expert").replaceAll("\\",""),pn=document.getElementById("root").getAttribute("data-would-you-like-assistance-in-automatically-solving-this-puzzle").replaceAll("\\",""),bn=document.getElementById("root").getAttribute("data-please-move-card-a-to-b").replaceAll("\\",""),gn=document.getElementById("root").getAttribute("data-total-played").replaceAll("\\",""),xn=document.getElementById("root").getAttribute("data-win-ratio").replaceAll("\\",""),yn=document.getElementById("root").getAttribute("data-win-streak").replaceAll("\\",""),En=document.getElementById("root").getAttribute("data-highest-win-streak").replaceAll("\\",""),wn=document.getElementById("root").getAttribute("data-highest-score").replaceAll("\\",""),hn=document.getElementById("root").getAttribute("data-average-score").replaceAll("\\",""),kn=document.getElementById("root").getAttribute("data-average-win-time").replaceAll("\\",""),_n=document.getElementById("root").getAttribute("data-fastest-win-time").replaceAll("\\",""),vn=document.getElementById("root").getAttribute("data-latest-win-time").replaceAll("\\",""),qe=document.getElementById("root").getAttribute("data-cancel").replaceAll("\\",""),Ht=document.getElementById("root").getAttribute("data-ok").replaceAll("\\",""),Nn=document.getElementById("root").getAttribute("data-loading").replaceAll("\\",""),An=document.getElementById("root").getAttribute("data-how-to-play-description").replaceAll("\\",""),Sn=document.getElementById("root").getAttribute("data-random").replaceAll("\\",""),In=document.getElementById("root").getAttribute("data-note").replaceAll("\\",""),jn=document.getElementById("root").getAttribute("data-are-you-sure-you-want-to-reset-stats").replaceAll("\\",""),Tn=document.documentElement.lang,g=({children:e})=>t.createElement("div",null,e),A=({children:e})=>t.createElement("div",{className:"rotate-180"},e),j=({children:e})=>t.createElement("div",{className:`flex h-full flex-auto flex-col items-center justify-between py-1 text-xl !leading-3 ${N?"max-md:hidden lg:py-2 lg:text-2xl xl:text-3xl":"max-md:hidden max-[1180px]:block max-[1280px]:hidden"}`},e),P=({children:e})=>t.createElement("div",{className:`flex h-full flex-auto flex-col items-center justify-evenly text-xl !leading-3 ${N?"max-md:hidden lg:text-2xl xl:text-3xl":"max-md:hidden max-[1180px]:block max-[1280px]:hidden"}`},e),Ln=({data:e})=>{const{cardType:l}=h(({user:a})=>a.settings);return t.createElement(u.Fragment,null,e.value===1?t.createElement("div",{className:`flex h-full w-full  flex-col items-center justify-center ${N?"max-md:hidden":"max-md:hidden max-[1180px]:block max-[1280px]:hidden"}`},t.createElement("img",{className:"pointer-events-none h-2/3 w-2/3 object-contain ",src:new URL(Object.assign({"../../../../../image/freecell/faces0/ace-club.webp":Oe,"../../../../../image/freecell/faces0/ace-diamond.webp":Ce,"../../../../../image/freecell/faces0/ace-heart.webp":Re,"../../../../../image/freecell/faces0/ace-spade.webp":$e,"../../../../../image/freecell/faces1/ace-club.webp":at,"../../../../../image/freecell/faces1/ace-diamond.webp":nt,"../../../../../image/freecell/faces1/ace-heart.webp":rt,"../../../../../image/freecell/faces1/ace-spade.webp":ot,"../../../../../image/freecell/faces2/ace-club.webp":st,"../../../../../image/freecell/faces2/ace-diamond.webp":ct,"../../../../../image/freecell/faces2/ace-heart.webp":it,"../../../../../image/freecell/faces2/ace-spade.webp":mt})[`../../../../../image/freecell/faces${l}/ace-${e.suit}.webp`],self.location).href,alt:`faces${l}/ace-${e.suit}`})):e.value===2?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===3?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===4?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===5?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null,t.createElement(g,null,e.icon)),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===6?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===7?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null,t.createElement(g,null,e.icon),t.createElement("div",{className:"h-2 lg:h-4 xl:h-6"})),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===8?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null,t.createElement(g,null,e.icon),t.createElement("div",{className:"h-2 lg:h-4 xl:h-6"}),t.createElement(A,null,e.icon)),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon))):e.value===9?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null,t.createElement(g,null,e.icon)),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon),t.createElement(A,null,e.icon))):e.value===10?t.createElement(u.Fragment,null,t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon),t.createElement(A,null,e.icon)),t.createElement(P,null,t.createElement(g,null,e.icon),t.createElement("div",{className:"h-2 lg:h-4 xl:h-6"}),t.createElement(A,null,e.icon)),t.createElement(j,null,t.createElement(g,null,e.icon),t.createElement(g,null,e.icon),t.createElement(A,null,e.icon),t.createElement(A,null,e.icon))):t.createElement("img",{className:`pointer-events-none block h-full w-full ${N?"max-md:hidden":"max-md:hidden max-[1180px]:block max-[1280px]:hidden"}`,src:new URL(Object.assign({"../../../../../image/freecell/faces0/ace-club.webp":Oe,"../../../../../image/freecell/faces0/ace-diamond.webp":Ce,"../../../../../image/freecell/faces0/ace-heart.webp":Re,"../../../../../image/freecell/faces0/ace-spade.webp":$e,"../../../../../image/freecell/faces0/jack-club.webp":fa,"../../../../../image/freecell/faces0/jack-diamond.webp":pa,"../../../../../image/freecell/faces0/jack-heart.webp":ba,"../../../../../image/freecell/faces0/jack-spade.webp":ga,"../../../../../image/freecell/faces0/king-club.webp":xa,"../../../../../image/freecell/faces0/king-diamond.webp":ya,"../../../../../image/freecell/faces0/king-heart.webp":Ea,"../../../../../image/freecell/faces0/king-spade.webp":Ot,"../../../../../image/freecell/faces0/queen-club.webp":wa,"../../../../../image/freecell/faces0/queen-diamond.webp":ha,"../../../../../image/freecell/faces0/queen-heart.webp":ka,"../../../../../image/freecell/faces0/queen-spade.webp":_a,"../../../../../image/freecell/faces1/ace-club.webp":at,"../../../../../image/freecell/faces1/ace-diamond.webp":nt,"../../../../../image/freecell/faces1/ace-heart.webp":rt,"../../../../../image/freecell/faces1/ace-spade.webp":ot,"../../../../../image/freecell/faces1/jack-club.webp":va,"../../../../../image/freecell/faces1/jack-diamond.webp":Na,"../../../../../image/freecell/faces1/jack-heart.webp":Aa,"../../../../../image/freecell/faces1/jack-spade.webp":Sa,"../../../../../image/freecell/faces1/king-club.webp":Ia,"../../../../../image/freecell/faces1/king-diamond.webp":ja,"../../../../../image/freecell/faces1/king-heart.webp":Ta,"../../../../../image/freecell/faces1/king-spade.webp":Ct,"../../../../../image/freecell/faces1/queen-club.webp":La,"../../../../../image/freecell/faces1/queen-diamond.webp":Oa,"../../../../../image/freecell/faces1/queen-heart.webp":Ca,"../../../../../image/freecell/faces1/queen-spade.webp":Ra,"../../../../../image/freecell/faces2/ace-club.webp":st,"../../../../../image/freecell/faces2/ace-diamond.webp":ct,"../../../../../image/freecell/faces2/ace-heart.webp":it,"../../../../../image/freecell/faces2/ace-spade.webp":mt,"../../../../../image/freecell/faces2/jack-club.webp":$a,"../../../../../image/freecell/faces2/jack-diamond.webp":Ma,"../../../../../image/freecell/faces2/jack-heart.webp":Da,"../../../../../image/freecell/faces2/jack-spade.webp":Ua,"../../../../../image/freecell/faces2/king-club.webp":Ba,"../../../../../image/freecell/faces2/king-diamond.webp":Ga,"../../../../../image/freecell/faces2/king-heart.webp":Pa,"../../../../../image/freecell/faces2/king-spade.webp":Rt,"../../../../../image/freecell/faces2/queen-club.webp":Ha,"../../../../../image/freecell/faces2/queen-diamond.webp":Fa,"../../../../../image/freecell/faces2/queen-heart.webp":Va,"../../../../../image/freecell/faces2/queen-spade.webp":Ya})[`../../../../../image/freecell/faces${l}/${e.name}-${e.suit}.webp`],self.location).href,alt:`${e.name}-${e.suit}`}))},Ft=u.createContext(),J=()=>u.useContext(Ft),On=({children:e})=>{const l=h(({user:i})=>i.settings.playSound),[a]=Y(xl,{soundEnabled:l,html5:!0}),[n]=Y(yl,{soundEnabled:l,html5:!0}),[r]=Y(hl,{soundEnabled:l,html5:!0}),[s]=Y(El,{soundEnabled:l,html5:!0}),[c]=Y(kl,{soundEnabled:l}),[o]=Y(_l,{soundEnabled:l,html5:!0});return t.createElement(Ft.Provider,{value:{cardFlipDownSound:a,cardFlipUpSound:n,correctAnswerSound:r,cardShuffleSound:s,applauseSound:c,sadTromboneSound:o}},e)},Vt="SET_SETTINGS",be="SET_GLOBAL_MODAL",Yt="CLOSE_GLOBAL_MODAL",qt="START_NEW_GAME",Wt="SET_GAME_STATE",We="MOVE_CARD",zt="SET_SELECTED",ze="SET_FOLLOWERS",Jt="SET_RECORDED_TIME",Xt="HINT_VISIBLE",Kt="STOP_SOLVIING_STATE",oe="UPDATE_SOLVIING_STATE",Qt="UNDO_HISTORY",Zt="REDO_HISTORY",le="MODAL_COMPLETED",Z="MODAL_FAILED",se="MODAL_MENU",ce="MODAL_SETTING",ie="MODAL_HOW_TO_PLAY",me="MODAL_STATISTICS",Cn={HOWTOPLAY:"/how-to-play",STATISTICS:"/stat",MAIN:"/",ALL:"*"},x={PLAYING:1,LOADING:2,AUTO_SOLVING:3},el=[Pt,dn,un,fn],Rn=[{label:$t,to:Cn.MAIN},{label:Dt,modalName:ce},{label:qa,modalName:ie},{label:Ut,modalName:me}],tl=(e=null)=>l=>(l({type:Wt,payload:x.LOADING}),new Promise(async(a,n)=>{let r=null;e===null&&localStorage.getItem("freecell-state")==="Running"?(e=parseInt(localStorage.getItem("freecell-game")[0]),r=localStorage.getItem("freecell-game").slice(1)):((e===4||e===null)&&(e=Math.floor(Math.random()*4)),r=Math.floor(Math.random()*3500).toString().padStart(5,"0"));try{const s=await fetch(`/freecell/board_${e}${r}`);if(!s.ok)throw new Error("Network response was not ok");const c=await s.json(),o=JSON.parse(c.data),i=Be(o);l({type:qt,payload:{gameId:`${e}${r}`,gameInfo:o,difficulty:el[e]},tableau:i}),localStorage.setItem("freecell-game",`${e}${r}`),localStorage.setItem("freecell-state","Running"),a()}catch(s){n(s)}})),Je=Ve((e,l=null,a=()=>{})=>{localStorage.setItem("freecell-state","Initialized"),e(tl(l)),a()},1e3),ke=e=>l=>{l({type:zt,card:e}),e===null&&l({type:ze,cards:null})},$n=e=>l=>{l({type:ze,cards:e})},Mn=()=>e=>{e({type:Qt})},ll=Ve((e,l=()=>{})=>{e(Mn()),l()},500),Dn=()=>e=>{e({type:Zt})},Un=Ve((e,l=()=>{})=>{e(Dn()),l()},500),de=e=>(l,a)=>{const{gameId:n}=a().freecell,r=W(e);l({type:We,newTableau:e,hints:r}),r.length===0&&!Fe(e.foundations)&&(l({type:be,name:Z,payload:!0}),bt("freecell","fail",n))},Xe=()=>e=>{e({type:Jt})},Bn=()=>e=>{e({type:Xt})},Gn=()=>async(e,l)=>{const{gameInfo:a,tableau:n}=l().freecell,r=da(a,n),s=async(i,m,d)=>{e({type:oe,payload:{status:x.AUTO_SOLVING,tableau:i}}),await ua(500),e({type:oe,payload:{hints:m,showHintId:0,solvingStep:d,...d===0&&{score:0,created:new Date().toString(),undoUsages:0}}})},c=r>0?L(n):Be(a),o=Nt(c,a.solution[r]);await s(c,o,r)},Pn=()=>(e,l)=>{const{tableau:a}=l().freecell;e({type:Kt,payload:{status:x.PLAYING,hints:W(a),showHintId:-1}})},Ke=(e,l)=>(a,n)=>{const{solvingStep:r,gameInfo:s,tableau:c,hints:o,created:i,undoUsages:m,gameId:d}=n().freecell;if(e!==r)return;const{from:y,to:k,card:_}=o[0],E=L(c);y.type===C?pe(E,y.index):y.type===S&&fe(_,E,y.index),k.type===M?(_t(_,E,k.index),Fe(E.foundations)&&(a({type:be,name:le,payload:!0}),bt("freecell","success",d)),l()):k.type===C?kt(_,E,k.index):k.type===S&&je([_],E,k.index),a({type:We,newTableau:E,hints:o});const p=Math.min(e+1,s.solution.length-1),b=Nt(E,s.solution[p]),w={status:x.AUTO_SOLVING,tableau:E,hints:b,showHintId:0,solvingStep:p};o[0].to.type===M&&(w.score=re(E,i,m)),a({type:oe,payload:w})},_e=({text:e,className:l=""})=>t.createElement("div",{className:`select-none text-4xl text-yellow-400 md:text-6xl lg:text-8xl ${l}`},e),ge=({type:e,index:l,style:a})=>{const{hints:n,showHintId:r,selected:s}=h(({freecell:m})=>m),c=u.useMemo(()=>F,[]),o=(m,d)=>{var k;const y=`white-pulse pointer-events-none absolute z-20 flex aspect-[5/7] w-full flex-col items-center justify-center ${s===null?"bg-black/50":"bg-yellow-400/20"} outline outline-yellow-400/60`;return c(m.card,d)?t.createElement(f.div,{key:`hint-card-from-${d}`,layoutId:"hint-card-from",className:y,style:{top:0}},t.createElement(_e,{text:"A"})):(k=m.children)!=null&&k.some(_=>c(_,d))?t.createElement(f.div,{key:`hint-card-from-children-${d.suit}-${d.value}`,layoutId:`hint-card-from-children-${d.suit}-${d.value}`,className:y,style:{top:0}},t.createElement(_e,{text:"A"})):null},i=(m,d)=>{const y=`white-pulse pointer-events-none absolute z-20 flex aspect-[5/7] w-full flex-col items-center justify-center ${s===null?"bg-black/50":"bg-green-400/20"} outline outline-green-400/60`;return m.to.type===e&&m.to.index===d?t.createElement(f.div,{key:`hint-card-to-${d}`,layoutId:"hint-card-to",className:y,style:a},t.createElement(_e,{text:"B",className:"!text-green-400"})):null};return t.createElement(u.Fragment,null,r>-1&&n.length>r&&(e===yt?o(n[r],l):i(n[r],l)))},xe=({data:e,style:l,isdraging:a=!1,resetDragFactors:n=()=>{},isFliped:r=!0})=>{const s=Nl(),c=gt(),o=u.useRef(),[i,m]=u.useState(!1),d=O(),{cardBackType:y}=h(({user:v})=>v.settings),{cardFlipDownSound:k,cardFlipUpSound:_,correctAnswerSound:E}=J(),{selected:p,tableau:b,status:w,gameInfo:$,solvingStep:D}=h(({freecell:v})=>v);function X(v){if(w===x.PLAYING||w===x.AUTO_SOLVING&&H(e,$.solution[D][1])){if(p)return null;if(!e.dragable)return c.start({x:[-8,8,-5,5,-3,3,0],transition:{duration:.5}});if(s.start(v),k(),d(ke(e)),e.parent.type===S){const I=ht(b.columns[e.parent.index],e);I&&d($n(I.map(G=>`${G.suit}${G.label}`)))}}w===x.AUTO_SOLVING&&!H(e,$.solution[D][1])&&(H(e,$.solution[D][1])?(k(),d(forwardSolvingStep(E))):il.info(bn))}const ye=()=>{i===!1&&(w===x.PLAYING||w===x.AUTO_SOLVING)&&(d(ke(null)),o.current?_():n())},Ee=()=>m(!0),we=()=>{(w===x.PLAYING||w===x.AUTO_SOLVING)&&(o.current?(c.start({type:"onDragEnd",x:0,y:0}),_()):n())};return t.createElement(f.div,{ref:o,className:`relative aspect-[5/7] w-10 touch-none select-none ${N?"md:w-20 lg:w-24 xl:w-28 2xl:w-36 3xl:w-40":"md:w-16 min-[1180px]:w-10 min-[1280px]:w-14 min-[1350px]:w-16"} ${a?"z-50 ":"z-10"}`,key:`${e.suit}${e.value}`,layoutId:`${e.suit}${e.value}`,animate:c,drag:!0,dragControls:s,onPointerDown:X,onPointerUp:ye,onDragStart:Ee,onDragEnd:we,dragListener:!1,onAnimationComplete:v=>{v.type==="onDragEnd"&&d(ke(null))},style:{...l,color:e.color},whileTap:{cursor:"grabbing"}},t.createElement("div",{className:`relative h-full  w-full rounded border border-majky-800 bg-gradient-to-b from-gray-50 to-gray-200 p-4 shadow-md md:flex md:justify-evenly  ${a&&"outline outline-majky-400"} `,style:{transform:`rotateY(${r?0:180}deg)`,backfaceVisibility:"hidden"}},t.createElement("div",{className:"absolute left-0.5 top-0 block text-2xl md:hidden"},e.label),t.createElement("div",{className:"absolute bottom-0 right-0.5 block text-3xl max-xs:text-2xl md:hidden"},e.icon),t.createElement("div",{className:"absolute left-0.5 top-1  hidden flex-col items-center justify-center text-lg font-medium  leading-4 md:flex"},e.label,t.createElement("div",{className:"text-sm"},e.icon)),t.createElement(Ln,{data:e}),t.createElement("div",{className:"absolute bottom-1 right-0.5 hidden rotate-180 flex-col items-center justify-center text-lg font-medium leading-4 md:flex"},e.label,t.createElement("div",{className:"text-sm"},e.icon))),t.createElement("div",{className:"absolute left-0 top-0 h-full w-full  ",style:{backgroundImage:`url("${new URL(Object.assign({"../../../../../image/freecell/back0.png":jt,"../../../../../image/freecell/back1.png":Tt,"../../../../../image/freecell/back2.png":Lt})[`../../../../../image/freecell/back${y}.png`],self.location).href}")`,backgroundSize:"100% 100%",transform:`rotateY(${(r?0:180)+180}deg)`,backfaceVisibility:"hidden"}}),t.createElement(ge,{type:yt,index:e}))},Hn=({data:e})=>{const[l,a]=u.useState(!1),n=u.useRef(null),{selected:r,followers:s,tableau:c,status:o,hints:i,showHintId:m,solvingStep:d}=h(({freecell:p})=>p),{showHint:y}=h(({user:p})=>p.settings),{cardFlipUpSound:k,correctAnswerSound:_}=J(),E=O();return u.useEffect(()=>{const p=b=>{n.current&&a(Ue(b,n))};return r&&!s?document.addEventListener("pointermove",p):a(!1),()=>{document.removeEventListener("pointermove",p)}},[r,s]),u.useEffect(()=>{const p=()=>{if(l&&r&&!s)if(o===x.PLAYING&&Te(e)){const b=L(c);r.parent.type===C?pe(b,r.parent.index):r.parent.type===S&&fe(r,b,r.parent.index),kt(r,b,e.index),console.log(L(b)),E(de(b))}else o===x.AUTO_SOLVING&&z(i,m,C,e.index)&&(k(),E(Ke(d,_)))};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p)}},[E,l,r,s,d]),t.createElement(f.div,{ref:n,className:`relative mr-0.5 box-content flex aspect-[5/7] w-8 min-[430px]:w-10  flex-col items-center justify-center rounded border border-majky-400/50 bg-majky-600/50 ${N?"md:w-20 lg:w-24 xl:w-28 2xl:w-36 3xl:w-40 md:border-4":"md:w-16 min-[1180px]:w-10 min-[1280px]:w-14 min-[1350px]:w-16 2xl:border-4"}
      ${r&&!s&&m>-1&&(o===x.PLAYING&&Te(e)||o===x.AUTO_SOLVING&&z(i,m,C,e.index))&&(y&&!l?"white-pulse outline outline-green-400":l?"yellow-pulse z-10 border-yellow-400/50 bg-yellow-600/50 outline outline-yellow-400":"")}`},t.createElement("div",{className:"absolute text-2xl min-[430px]:text-3xl sm:text-4xl text-majky-400/50 md:text-6xl lg:text-8xl"},"A"),e.card&&t.createElement(xe,{data:e.card,isdraging:F(e.card,r)}),t.createElement(ge,{type:C,index:e.index}))},Fn=e=>l=>{l({type:Vt,payload:e})},Qe=(e,l)=>a=>{a({type:be,name:e,payload:l})},V=e=>l=>{l({type:Yt,name:e,payload:!1})},Vn={type:"correctCardEnd",outline:["2px solid rgb(255,255,255,0.5)","10px solid rgb(255,255,255,0)"],outlineOffset:["0px","30px"]},Yn=({data:e})=>{const[l,a]=u.useState(!1),n=u.useRef(null),r=gt(),{selected:s,followers:c,tableau:o,status:i,hints:m,showHintId:d,solvingStep:y}=h(({freecell:b})=>b),{showHint:k}=h(({user:b})=>b.settings),{cardFlipUpSound:_,correctAnswerSound:E}=J(),p=O();return u.useEffect(()=>{const b=w=>{n.current&&a(Ue(w,n))};return s&&!c?document.addEventListener("pointermove",b):a(!1),()=>{document.removeEventListener("pointermove",b)}},[s,c]),u.useEffect(()=>{const b=()=>{if(l&&s&&!c)if(i===x.PLAYING&&lt(s,e)){const w=L(o);s.parent.type===C?pe(w,s.parent.index):s.parent.type===S&&fe(s,w,s.parent.index),_t(s,w,e.index),p(de(w)),r.start(Vn),E()}else i===x.AUTO_SOLVING&&z(m,d,M,e.index)&&(_(),p(Ke(y,E)))};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b)}},[l,s,c,y]),t.createElement(f.div,{ref:n,animate:r,className:`relative ml-0.5  box-content flex aspect-[5/7] w-8 min-[430px]:w-10  flex-col items-center justify-center rounded border border-majky-400/50 bg-majky-600/50  
      ${N?"md:w-20 lg:w-24 xl:w-28 2xl:w-36 3xl:w-40 md:border-4":"md:w-16 min-[1180px]:w-10 min-[1280px]:w-14 min-[1350px]:w-16 2xl:border-4"}
      ${s&&!c&&d>-1&&(i===x.PLAYING&&lt(s,e)||i===x.AUTO_SOLVING&&z(m,d,M,e.index))&&(k&&!l?"white-pulse outline outline-green-400":l?"yellow-pulse z-10 border-yellow-400/50 bg-yellow-600/50 outline outline-yellow-400":"")}`,onAnimationComplete:b=>{b.type==="correctCardEnd"&&Fe(o.foundations)&&(p(Xe()),p(Qe(le,!0)))}},t.createElement("div",{className:"absolute text-2xl min-[430px]:text-3xl sm:text-4xl text-majky-400/50 md:text-6xl lg:text-8xl"},ee.suits[e.suit].icon),e.cards&&e.cards.map((b,w)=>t.createElement("div",{key:`foundation-${e.suit}-${w}`,className:"absolute top-0"},t.createElement(xe,{data:b}))),t.createElement(ge,{type:M,index:e.index}))},qn=({data:e})=>{const l=u.useRef(),a=u.useRef(),[n,r]=u.useState(50),{selected:s,followers:c,tableau:o,status:i,hints:m,showHintId:d,solvingStep:y}=h(({freecell:v})=>v),{showHint:k}=h(({user:v})=>v.settings);u.useEffect(()=>{if(l.current&&a.current){const v=l.current.getBoundingClientRect(),I=a.current.getBoundingClientRect();r(Math.min((v.height-I.height)/Math.max(e.cards.length,8),50))}},[e.cards.length]);const[_,E]=u.useState(!1),{cardFlipUpSound:p,correctAnswerSound:b}=J(),w=O();u.useEffect(()=>{const v=I=>{l.current&&E(Ue(I,l))};return s?document.addEventListener("pointermove",v):E(!1),()=>{document.removeEventListener("pointermove",v)}},[s]),u.useEffect(()=>{const v=()=>{if(_&&s)if(i===x.PLAYING&&te(s,e)){if(s.parent.type===C){const I=L(o);pe(I,s.parent.index),je([s],I,e.index),w(de(I))}else if(s.parent.type===S){const I=L(o),G=vt(I,e.index);if((c||[]).length+1<=G){const ae=fe(s,I,s.parent.index);je(ae,I,e.index),w(de(I))}}}else i===x.AUTO_SOLVING&&z(m,d,S,e.index)&&(p(),w(Ke(y,b)))};return document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointerup",v)}},[_,s,c,y]);const $={duration:.3},D=tt(0),X=tt(0),ye=Ze(D,$),Ee=Ze(X,$),we=()=>{et(D,0,{duration:0}),et(X,0,{duration:0})};return t.createElement("div",{ref:l,className:`relative w-10 ${N?"md:w-20 lg:w-24 xl:w-28 2xl:w-36 3xl:w-40":"md:w-16 min-[1180px]:w-10 min-[1280px]:w-14 min-[1350px]:w-16"}`},t.createElement("div",{ref:a,className:"relative flex aspect-[5/7] w-full flex-col items-center justify-center rounded border-2 border-majky-400/50  md:border-4"},t.createElement("div",{className:"absolute select-none text-4xl text-majky-400/50 md:text-6xl lg:text-8xl"},"A")),e.cards.map((v,I)=>{const G=F(v,s),ae=(c==null?void 0:c.indexOf(`${v.suit}${v.label}`))>-1;return t.createElement("div",{key:`card-${I}`,className:"absolute",style:{top:`${I*n}px`}},t.createElement(xe,{data:v,style:{...G&&{x:D,y:X},...ae&&{x:ye,y:Ee}},isdraging:G||ae,resetDragFactors:we}))}),t.createElement(ge,{type:S,index:e.index,style:{top:`${e.cards.length*n}px`}}),(k||_)&&d>-1&&(i===x.PLAYING&&te(s,e)||i===x.AUTO_SOLVING&&z(m,d,S,e.index))&&t.createElement("div",{className:`absolute z-10 aspect-[5/7] w-full rounded border 
          ${k&&!_?"white-pulse border-majky-600/80 bg-majky-400/50 outline outline-green-400":_?"yellow-pulse border-yellow-600/80 bg-yellow-400/50 outline outline-yellow-400":""}`,style:{top:`${e.cards.length*n}px`}}))},T=({className:e="",disabled:l=!1,children:a,onClick:n=()=>{}})=>{const[r,s]=u.useState([]),c=u.useRef(null);return u.useEffect(()=>{const o=m=>{const d=c.current,{left:y,top:k}=d.getBoundingClientRect(),_=m.clientX-y,E=m.clientY-k,b=Math.max(d.clientWidth,d.clientHeight)*2/2,w={x:_,y:E,radius:b,id:Date.now()};s($=>[...$,w]),setTimeout(()=>{s($=>$.filter(D=>D.id!==w.id))},1e3)},i=c.current;return i.addEventListener("click",o),()=>{i.removeEventListener("click",o)}},[s]),t.createElement(f.button,{ref:c,layout:!0,type:"button",className:`relative overflow-hidden shadow ${e} !outline-none ${l&&"!pointer-events-none"}`,disabled:l,onClick:n,whileHover:{scale:l?1:1.05},whileTap:{scale:l?1:.95}},a,r.map(o=>t.createElement("span",{key:o.id,className:"ripple",style:{left:o.x-o.radius+"px",top:o.y-o.radius+"px",width:o.radius*2+"px",height:o.radius*2+"px"}})))},Wn=({isOpen:e,setIsOpen:l})=>{const a=O();return u.useEffect(()=>{const n=()=>{l(!1)};return e&&document.addEventListener("click",n),()=>{e&&document.removeEventListener("click",n)}},[e,l]),t.createElement(B,null,e&&t.createElement(f.div,{className:"absolute left-0 z-50 w-screen max-w-xs rounded border  border-majky-400 bg-white   px-3 py-4 shadow-md dark:bg-slate-900/80 max-lg:bottom-full max-lg:mb-2 max-sm:w-60 lg:top-full lg:mt-2",initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1,y:0},closed:{opacity:0,y:-30,transition:{delay:.2,duration:.1}}},onClick:n=>{n.stopPropagation()}},t.createElement(f.div,{className:"flex flex-col items-stretch justify-center rounded text-base font-bold"},[...el,Sn].map((n,r)=>t.createElement(T,{key:`difficulty-${r}`,className:" border-majky-200 bg-majky-50 px-4 text-left leading-10 text-majky-800 hover:border-l-4 hover:border-majky-400  hover:text-majky-400 dark:bg-slate-800 dark:text-white dark:hover:text-majky-400 max-xs:leading-9",onClick:()=>{l(!1),Je(a,r)}},t.createElement("img",{src:new URL("/build/assets/playing-cards-c77367b2.svg",self.location).href,alt:"playing-cards.svg",className:"mr-2 inline-block w-6 fill-white"}),n)))))},zn=({isOpen:e,setIsOpen:l,onOK:a=()=>{}})=>(u.useEffect(()=>{const n=()=>{l(!1)};return e&&document.addEventListener("click",n),()=>{e&&document.removeEventListener("click",n)}},[e,l]),t.createElement(B,null,e&&t.createElement(f.div,{className:"absolute left-0 z-50 w-60 rounded border  border-majky-400 bg-white   px-3 py-4 shadow-md dark:bg-slate-900/80 max-lg:bottom-full max-lg:mb-2 max-sm:w-60 lg:top-full lg:mt-2",initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1,y:0},closed:{opacity:0,y:-30,transition:{delay:.2,duration:.1}}},onClick:n=>{n.stopPropagation()}},t.createElement("h2",{className:"relative px-2 text-center font-medium text-majky-800 dark:text-majky-400"},pn,t.createElement(R,{className:"absolute right-0 top-0 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:()=>{l(!1)},icon:ue})),t.createElement(f.div,{className:"mt-4 grid grid-cols-2 gap-2  font-medium"},t.createElement(T,{className:"rounded border-majky-200 bg-majky-50 py-1 text-center text-majky-800  dark:bg-slate-800 dark:text-majky-400",onClick:()=>{l(!1)}},qe),t.createElement(T,{className:" rounded border-majky-200  bg-majky-400 py-1 text-center text-white dark:bg-majky-600 dark:text-slate-800",onClick:()=>{a(),l(!1)}},Ht))))),q=({onClick:e=()=>{},icon:l,label:a,disabled:n,children:r})=>t.createElement("div",{className:"relative"},t.createElement(T,{className:`flex flex-col items-center justify-center rounded border border-majky-400 bg-majky-600 px-2 py-1 text-white shadow hover:text-majky-400 disabled:border-slate-800 disabled:text-slate-600 dark:bg-slate-800/80 max-xs:text-sm md:py-2 ${N?"lg:flex-row lg:justify-between lg:py-1":"min-[1350px]:flex-row min-[1350px]:justify-between min-[1350px]:py-1"}`,onClick:e,disabled:n},t.createElement(R,{className:`my-1 ${N?"lg:my-0 lg:mr-2":"min-2xl:my-0 2xl:mr-2"}`,icon:l}),t.createElement("span",{className:`max-sm:hidden ${N?"":"max-[1180px]:block max-2xl:hidden "}`,style:{wordBreak:"break-word",hyphens:"auto"}},a)),r),Me=()=>{const{past:e,future:l,hints:a,status:n}=h(({freecell:d})=>d),{settings:r}=h(({user:d})=>d),[s,c]=u.useState(!1),[o,i]=u.useState(!1),m=O();return t.createElement("div",{className:`mb-2 flex w-full items-center md:mb-4 md:text-lg ${N?"lg:mb-0 lg:justify-end justify-evenly lg:space-x-2 lg:text-sm":"2xl:mb-0 justify-between 2xl:space-x-2 2xl:text-xs 3xl:text-sm"}`},t.createElement(q,{label:tn,icon:Al,onClick:d=>{c(y=>!y),i(!1),d.stopPropagation()},disabled:!1},t.createElement(Wn,{isOpen:s,setIsOpen:c})),t.createElement(q,{label:n!==x.AUTO_SOLVING?ln:an,icon:n!==x.AUTO_SOLVING?Sl:Il,onClick:d=>{n===x.AUTO_SOLVING?m(Pn()):(c(!1),i(y=>!y),d.stopPropagation())}},t.createElement(zn,{isOpen:o,setIsOpen:i,onOK:()=>{m(Gn())}})),t.createElement(q,{label:nn,icon:jl,onClick:()=>{m(Bn())},disabled:!r.showHint||n!==x.PLAYING||a.length<1}),t.createElement(q,{label:on,icon:Tl,onClick:()=>{ll(m)},disabled:n!==x.PLAYING||e.length<=0}),t.createElement(q,{label:sn,icon:Ll,onClick:()=>{Un(m)},disabled:n!==x.PLAYING||l.length<=0}),window.innerWidth>1024&&t.createElement(q,{label:N?mn:cn,icon:N?Ol:Cl,onClick:()=>{N?window.location.search="":window.location.search="fullview=true"}}))},Jn=()=>{const{created:e}=h(({freecell:n})=>n),[l,a]=u.useState(Q(0));return u.useEffect(()=>{const n=setInterval(()=>{a(Et(new Date(e)||new Date))},500);return()=>{clearInterval(n)}},[e]),l},al=()=>{const e=Jn(),{difficulty:l,gameId:a,score:n}=h(({freecell:r})=>r);return t.createElement("div",{className:`h-full flex flex-row items-center justify-center text-slate-400 ${N?"max-lg:space-x-2 lg:flex-col lg:space-y-1 lg:rounded lg:border lg:border-slate-600 lg:bg-slate-800/80 text-lg xl:text-2xl lg:shadow-lg p-2 xl:p-4":"max-2xl:space-x-2 2xl:flex-col 2xl:space-y-1 2xl:rounded 2xl:border 2xl:border-slate-600 2xl:bg-slate-800/80 2xl:text-md 2xl:shadow-lg p-2"}`},t.createElement("div",{className:"text-center"},t.createElement(R,{icon:De,className:"mr-2"}),e),t.createElement("div",{className:"text-center text-xs font-bold"},l,t.createElement("br",null),"#",a),t.createElement("div",{className:"text-wrap text-center text-xs font-bold"},Ye,": ",n))},Xn=()=>{var o;const{past:e,tableau:l,gameInfo:a,gameId:n}=h(({freecell:i})=>i),[r,s]=u.useState(!1);u.useEffect(()=>{r||e.length&&(s(!0),vl("freecell",n))},[e]);const c=O();return u.useEffect(()=>{a===null&&c(tl())},[c,a]),t.createElement(f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"relative flex h-full w-full flex-1 flex-col justify-start gap-2 px-2 pt-2 md:px-4"},t.createElement("div",{className:"flex flex-row justify-between"},t.createElement("div",{className:"flex flex-row justify-between"},l==null?void 0:l.freecells.map((i,m)=>t.createElement(Hn,{key:`freecell-${m}`,data:i}))),t.createElement("div",{className:`hidden flex-col items-center justify-center ${N?"lg:flex":"2xl:flex"}`},t.createElement(al,null)),t.createElement("div",{className:"flex flex-row justify-between"},l==null?void 0:l.foundations.map((i,m)=>t.createElement(Yn,{key:`foundation-${m}`,data:i})))),t.createElement("div",{className:"relative mt-4 flex flex-1 flex-row justify-between pb-2"},l==null?void 0:l.columns.map((i,m)=>t.createElement(qn,{key:`column-${m}`,data:i}))),((o=l==null?void 0:l.cards)==null?void 0:o.length)>0&&t.createElement("div",{className:"fixed bottom-48 left-1/2 -ml-5 md:-ml-10  lg:-ml-12 xl:-ml-14 "},l==null?void 0:l.cards.map((i,m)=>t.createElement("div",{key:`card-${m}`,className:"absolute top-0"},t.createElement(xe,{data:i,isFliped:!0})))),t.createElement("div",{className:"relative w-full lg:hidden"},t.createElement(Me,null)))},Kn=()=>{const[e,l]=u.useState(localStorage.getItem("freecell-theme")||"dark"),a=e==="dark"?"light":"dark";return u.useEffect(()=>{const n=window.document.documentElement;n.classList.remove(a),n.classList.add(e),localStorage.setItem("freecell-theme",e)},[e,a]),[e,l]},Qn={settings:{cardType:0,cardBackType:0,backgroundType:0,playSound:!1,showHint:!0,autoMove:!0},modals:{[ce]:!1,[ie]:!1,[me]:!1,[le]:!1,[Z]:!1,[se]:!1}},Zn=(e=Qn,l)=>{switch(l.type){case Vt:return{...e,settings:{...e.settings,...l.payload}};case be:return{...e,modals:{...e.modals,[l.name]:l.payload}};case Yt:return{...e,modals:{...e.modals,[l.name]:l.payload}};default:return e}},er={difficulty:Pt,gameId:"000000",gameInfo:null,created:new Date().toString(),recordedTime:null,undoUsages:0,score:0,status:x.PLAYING,tableau:Be(),selected:null,followers:null,hints:[],showHintId:-1,solvingStep:-1,past:[],future:[]},tr=(e=er,l)=>{switch(l.type){case qt:return{...e,...l.payload,created:new Date().toString(),recordedTime:null,undoUsages:0,score:0,hints:W(l.tableau),showHintId:-1,past:[],future:[],status:x.PLAYING,tableau:l.tableau,selected:null,followers:null};case Wt:return{...e,status:l.payload};case zt:return{...e,selected:l.card};case ze:return{...e,followers:l.cards};case We:return{...e,selected:null,followers:null,past:[e.tableau,...e.past],tableau:l.newTableau,hints:l.hints,score:re(l.newTableau,e.created,e.undoUsages),showHintId:-1,future:[]};case Qt:return e.past.length>0?{...e,past:e.past.slice(1),tableau:e.past[0],hints:W(e.past[0]),showHintId:-1,score:re(e.past[0],e.created,e.undoUsages+1),future:[e.tableau,...e.future],undoUsages:e.undoUsages+1}:e;case Zt:return e.future.length>0?{...e,past:[e.tableau,...e.past],tableau:e.future[0],hints:W(e.future[0]),showHintId:-1,score:re(e.future[0],e.created,e.undoUsages),future:e.future.slice(1)}:e;case Jt:return{...e,recordedTime:Et(e.created)};case Xt:return{...e,showHintId:e.hints.length>e.showHintId+1?e.showHintId+1:0};case oe:return{...e,...l.payload};case Kt:return{...e,...l.payload};default:return e}},lr=ml({user:Zn,freecell:tr}),ar=wl(e=>e,(e,l)=>(l==="freecell"&&(e.selected=null,e.followers=null),e),{whitelist:["freecell"]}),nr={key:"freecell-game",storage:Ml,transforms:[ar]},rr=$l(nr,lr),or=fl,nl=dl(rr,or(ul(pl))),sr=Dl(nl);const cr=["spade","heart","club","diamond"],ir=()=>t.createElement(f.div,{className:"dark:text-slate fixed left-0 top-0 flex h-screen w-screen items-center justify-center dark:bg-slate-900",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},t.createElement(f.div,{className:"grid grid-cols-2 gap-2",style:{transform:"rotate(var(--rotate))"},initial:{"--rotate":"0deg"},animate:{"--rotate":"360deg"},transition:{duration:2,repeat:1/0,ease:"linear"}},cr.map((e,l)=>t.createElement(f.div,{key:l,layout:!0,className:"flex aspect-[5/7] w-16 flex-col items-center justify-center rounded-lg border bg-white shadow-md",style:{transform:"rotate(calc(-1 * var(--rotate)))"}},t.createElement(f.img,{src:new URL(Object.assign({"../../../../../image/freecell/faces0/ace-club.webp":Oe,"../../../../../image/freecell/faces0/ace-diamond.webp":Ce,"../../../../../image/freecell/faces0/ace-heart.webp":Re,"../../../../../image/freecell/faces0/ace-spade.webp":$e})[`../../../../../image/freecell/faces0/ace-${e}.webp`],self.location).href,alt:e,className:"w-3/5 rounded bg-white"}))))),rl="/build/assets/background0-facf9f6a.webp",ol="/build/assets/background1-0273ce68.webp",sl="/build/assets/background2-5e08a4cd.webp",mr="/build/assets/logo512-de.png",dr="/build/assets/logo512-en.png",ur=()=>{const e=O();return t.createElement("header",{className:"w-full border-b-2 border-slate-200 px-3 dark:border-slate-400"},t.createElement("div",{className:"flex h-16 w-full items-center justify-between max-xs:h-8"},t.createElement("div",null,t.createElement("h1",{className:"flex flex-auto select-none items-center space-x-4 font-bold text-2xl md:text-3xl"},t.createElement("img",{className:"aspect-square h-12 object-contain",src:new URL(Object.assign({"../../../../../image/freecell/logo512-de.png":mr,"../../../../../image/freecell/logo512-en.png":dr})[`../../../../../image/freecell/logo512-${Tn}.png`],self.location).href,alt:"logo"}),t.createElement("span",{className:`text-majky-600 dark:text-majky-400 ${N?"max-[1180px]:hidden":"max-2xl:hidden"}`},$t))),t.createElement("div",{className:`flex w-full justify-center ${N?"lg:hidden":"2xl:hidden"}`},t.createElement(al,null)),N&&t.createElement("div",{className:"flex-1 px-4 max-lg:hidden"},t.createElement(Me,null)),t.createElement("div",{className:"relative"},t.createElement(T,{className:"rounded border border-majky-600 bg-majky-600 px-3  py-2 text-white shadow shadow-white dark:bg-slate-900/50 dark:text-majky-400 max-xs:px-1 max-xs:py-0.5",onClick:()=>{e(Qe(se,!0))}},t.createElement(R,{icon:Rl}),t.createElement("div",{className:`md:pl-2 ${N?"hidden lg:inline-block":"hidden"}`},Mt)))),!N&&t.createElement("div",{className:"flex-1 px-4 max-lg:hidden mb-1"},t.createElement(Me,null)))},pt=({id:e,checked:l,onChange:a})=>t.createElement("div",{className:"inline-flex items-center"},t.createElement("div",{className:"relative inline-block h-4 w-8 cursor-pointer rounded-full border dark:border-majky-400"},t.createElement("input",{id:e,type:"checkbox",className:"peer absolute left-0 top-0 h-4 w-8 cursor-pointer appearance-none rounded-full bg-majky-100 transition-colors duration-300 checked:bg-majky-500 peer-checked:border-majky-500 peer-checked:before:bg-majky-500 dark:bg-majky-800 dark:checked:bg-majky-300 dark:peer-checked:border-majky-300 dark:peer-checked:before:bg-majky-300",checked:l,onChange:a}),t.createElement("label",{htmlFor:e,className:"before:content[''] before:bg-blue-slate-500 absolute -left-1  top-2/4 h-5 w-5 -translate-y-2/4 cursor-pointer rounded-full border border-majky-100 bg-white shadow-md transition-all duration-300 before:absolute before:left-2/4 before:top-2/4 before:block before:h-10 before:w-10 before:-translate-x-2/4 before:-translate-y-2/4 before:rounded-full before:opacity-0 before:transition-opacity hover:before:opacity-10 peer-checked:translate-x-full peer-checked:border-majky-500 peer-checked:before:bg-majky-500 dark:border-majky-400"},t.createElement("div",{className:"left-2/4 top-2/4 inline-block -translate-x-2/4 -translate-y-2/4 rounded-full p-5","data-ripple-dark":"true"})))),fr=()=>{const e=h(({user:s})=>{var c;return((c=s==null?void 0:s.modals)==null?void 0:c[ce])||null}),l=O(),{settings:a}=h(({user:s})=>s),n=(s,c)=>{l(Fn({[s]:c}))},r=()=>{l(V(ce))};return t.createElement(B,null,e&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:r},t.createElement(f.div,{className:"relative max-h-full w-full overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:s=>{s.stopPropagation()}},t.createElement(R,{className:"absolute left-4 top-4 h-6 w-6 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:r,icon:ue}),t.createElement(f.h2,{layout:!0,className:"border-b border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},Dt),t.createElement(f.div,{className:"my-4 grid grid-cols-3 gap-1 p-4 text-center shadow md:grid-cols-4"},t.createElement("div",{className:"col-span-3 grid grid-cols-3"},t.createElement("div",{className:"col-span-3 mb-2 border-b pb-1 text-base font-bold text-gray-600 dark:text-majky-400"},Ka),Array.from({length:3},(s,c)=>t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{scale:1,opacity:1},closed:{scale:.7,opacity:0}},key:`setting-face-${c}`},t.createElement(T,{onClick:()=>{n("cardType",c)},className:`rounded border border-transparent bg-white px-2 pt-2 text-base font-bold text-gray-600 shadow hover:border-gray-600 hover:bg-gray-100 dark:bg-transparent dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1 ${a.cardType===c&&"!border-majky-400 shadow-majky-400"}`},t.createElement("img",{className:"aspect-[5/7] h-24 rounded-lg border-2 bg-white object-fill p-2 md:h-28 lg:h-36",src:new URL(Object.assign({"../../../../../image/freecell/faces0/king-spade.webp":Ot,"../../../../../image/freecell/faces1/king-spade.webp":Ct,"../../../../../image/freecell/faces2/king-spade.webp":Rt})[`../../../../../image/freecell/faces${c}/king-spade.webp`],self.location).href,alt:`faces${c}/king-spade.webp`}),t.createElement("div",{className:"my-1"},ut," ",c+1)))),t.createElement("div",{className:"col-span-3 mb-2 mt-4 border-b pb-1 text-base font-bold text-gray-600 dark:text-majky-400"}),Array.from({length:3},(s,c)=>t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{scale:1,opacity:1,transition:{delay:.2}},closed:{scale:.7,opacity:0}},key:`setting-back-${c}`},t.createElement(T,{onClick:()=>{n("cardBackType",c)},className:`rounded border border-transparent bg-white px-2 pt-2 text-base font-bold text-gray-600 shadow hover:border-gray-600 hover:bg-gray-100 dark:bg-transparent    dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1 ${a.cardBackType===c&&"!border-majky-400 shadow-majky-400"}`},t.createElement("img",{className:"aspect-[5/7] h-24 border-2 border-black object-fill md:h-28 lg:h-36",src:new URL(Object.assign({"../../../../../image/freecell/back0.png":jt,"../../../../../image/freecell/back1.png":Tt,"../../../../../image/freecell/back2.png":Lt})[`../../../../../image/freecell/back${c}.png`],self.location).href,alt:`back${c}.png`}),t.createElement("div",{className:"my-1"},ut," ",c+1)))),t.createElement("div",{className:"col-span-3 mb-2 mt-4 border-b pb-1 text-base font-bold text-gray-600 dark:text-majky-400"},ft),Array.from({length:3},(s,c)=>t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{scale:1,opacity:1,transition:{delay:.4}},closed:{scale:.7,opacity:0}},key:`setting-background-${c}`},t.createElement(T,{onClick:()=>{n("backgroundType",c)},className:`rounded border border-transparent bg-white px-2 pt-2 text-base font-bold text-gray-600 shadow hover:border-gray-600 hover:bg-gray-100 dark:bg-transparent dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1 ${a.backgroundType===c&&"!border-majky-400 shadow-majky-400"}`},t.createElement("img",{className:`aspect-video  rounded-lg border-2 object-fill p-2 md:h-28 lg:h-36  ${a.backgroundType===c&&"!border-majky-400"}`,src:new URL(Object.assign({"../../../../../image/freecell/background0.webp":rl,"../../../../../image/freecell/background1.webp":ol,"../../../../../image/freecell/background2.webp":sl})[`../../../../../image/freecell/background${c}.webp`],self.location).href,alt:`background${c}.webp`}),t.createElement("div",{className:"my-1"},ft," ",c+1))))),t.createElement("div",{className:"col-span-3 mt-2 flex flex-col items-center md:col-span-1 md:mt-24 md:space-y-4"},t.createElement("div",{className:"w-full border-b pb-2 text-base font-bold text-gray-600 dark:text-majky-400"},Qa),t.createElement("div",{className:"mt-4 flex w-full max-w-60 cursor-pointer space-x-8 text-base font-bold text-gray-600 dark:text-majky-400 sm:mt-0"},t.createElement(pt,{id:"setting-show-hint",onChange:s=>{n("showHint",s.target.checked)},checked:a.showHint}),t.createElement("label",{className:"text-balance",htmlFor:"setting-show-hint"},Za)),t.createElement("div",{className:"mt-2 flex w-full max-w-60 cursor-pointer space-x-8 text-base font-bold text-gray-600 dark:text-majky-400 sm:mt-0"},t.createElement(pt,{id:"setting-play-sound",onChange:s=>{n("playSound",s.target.checked)},checked:a.playSound}),t.createElement("label",{className:"text-balance",htmlFor:"setting-play-sound"},en)))))))},pr=()=>t.createElement(f.div,{initial:{backdropFilter:"blur(0px)",opacity:0},animate:{backdropFilter:"blur(4px)",opacity:1},exit:{backdropFilter:"blur(0px)",opacity:0},transition:{duration:.6},className:"fixed left-0 top-0 z-50 h-screen w-screen bg-black/30"},t.createElement(f.img,{initial:{y:-300},animate:{y:0},exit:{y:-300},transition:{delay:.3,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l1-b15bb7e9.png",self.location).href,alt:"celebration_l1.png"}),t.createElement(f.img,{initial:{y:-400},animate:{y:0},exit:{y:-300},transition:{delay:.4,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l2-25c12ae6.png",self.location).href,alt:"celebration_l2.png"}),t.createElement(f.img,{initial:{y:-500},animate:{y:0},exit:{y:-300},transition:{delay:.1,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l3-24b64409.png",self.location).href,alt:"celebration_l3.png"}),t.createElement(f.img,{initial:{y:-400,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.4,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l1-b15bb7e9.png",self.location).href,alt:"celebration_r1.png"}),t.createElement(f.img,{initial:{y:-500,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.1,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l2-25c12ae6.png",self.location).href,alt:"celebration_r2.png"}),t.createElement(f.img,{initial:{y:-300,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.3,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l3-24b64409.png",self.location).href,alt:"celebration_l3.png"}),t.createElement("div",{className:"absolute left-1/2 top-0 -ml-[25%] w-1/2"},t.createElement(f.img,{initial:{y:-100},animate:{y:0},exit:{y:-100},transition:{delay:.1,type:"spring"},className:"absolute -top-2 ml-[12.5%] w-3/4 origin-top",src:new URL("/build/assets/celebration_c1-27ee5f77.png",self.location).href,alt:"celebration_c1.png"}),t.createElement(f.img,{initial:{y:-300},animate:{y:0},exit:{y:-300},transition:{delay:.5,type:"spring"},className:"absolute top-0 w-full",src:new URL("/build/assets/celebration_c2-33815d62.png",self.location).href,alt:"celebration_c2.png"}))),br=()=>{const e=O(),l=h(({user:m})=>{var d;return((d=m==null?void 0:m.modals)==null?void 0:d[le])||null}),{score:a,recordedTime:n,status:r,undoUsages:s,created:c,difficulty:o}=h(({freecell:m})=>m),{applauseSound:i}=J();return u.useEffect(()=>{l&&localStorage.getItem("freecell-state")==="Running"&&(i(),e(Xe()),na({playedTime:Math.floor((new Date().getTime()-new Date(c).getTime())/1e3),score:a,difficulty:o,isAuto:r===x.AUTO_SOLVING,isUsedUndo:s>0}))},[l]),t.createElement(u.Fragment,null,l&&t.createElement(pr,null),t.createElement(B,null,l&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:m=>{m.stopPropagation()}},t.createElement(f.div,{className:"grid max-h-full w-full grid-cols-1 overflow-y-auto rounded border bg-white p-2 pb-4 shadow-md dark:border-majky-400 dark:bg-slate-900/80 max-sm:w-full md:max-w-screen-md md:grid-cols-2 md:p-4"},t.createElement("div",{className:"relative m-2 flex justify-center overflow-hidden"},t.createElement("img",{src:new URL("/build/assets/sportlight-78fcd6da.png",self.location).href,alt:"sportlight.png",className:"aspect-auto h-full object-contain "}),t.createElement("img",{className:"absolute top-1/4 aspect-auto w-1/5 object-contain",src:new URL("/build/assets/blue-ribbon-05e5e154.webp",self.location).href,alt:"blue-ribbon.webp"})),t.createElement("div",{className:"flex w-full flex-1 flex-col items-center justify-center"},t.createElement("h2",{className:"w-full max-w-60 text-center text-xl font-bold text-majky-800 dark:text-majky-400 xs:text-2xl"},Wa),t.createElement(f.div,{className:"mt-6 flex w-full max-w-60 flex-row items-center justify-between rounded-t-lg border border-majky-600 bg-majky-50 px-4 py-1 text-majky-600 dark:bg-slate-900 dark:text-majky-400"},t.createElement(f.span,null,t.createElement(R,{icon:xt,className:"mr-2"}),Ye),t.createElement(f.span,null,a)),t.createElement(f.div,{layout:!0,className:"flex w-full max-w-60 flex-row items-center justify-between rounded-b-lg border border-majky-600 bg-majky-50 px-4 py-1 text-majky-600 dark:bg-slate-900 dark:text-majky-400"},t.createElement(f.span,null,t.createElement(R,{icon:De,className:"mr-2"}),Bt),t.createElement(f.span,null,n)),t.createElement(T,{onClick:()=>{Je(e,null,()=>{e(V(le))})},className:"mt-6 w-full max-w-60 rounded border border-transparent bg-majky-600 py-2 text-base font-bold  text-white  dark:bg-majky-400 dark:text-slate-900  max-xs:py-1"},Gt))))))},gr=()=>{const e=O(),{sadTromboneSound:l}=J(),a=h(({user:s})=>{var c;return((c=s==null?void 0:s.modals)==null?void 0:c[Z])||null}),{score:n,recordedTime:r}=h(({freecell:s})=>s);return u.useEffect(()=>{a&&localStorage.getItem("freecell-state")==="Running"&&(l(),e(Xe()),ra())},[e,a,l]),t.createElement(u.Fragment,null,t.createElement(B,null,a&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:s=>{s.stopPropagation()}},t.createElement(f.div,{className:"grid max-h-full w-full grid-cols-1 overflow-y-auto rounded border bg-white p-2 pb-4 shadow-md dark:border-yellow-400 dark:bg-slate-900/80 max-sm:w-full md:max-w-screen-md md:grid-cols-2 md:p-4"},t.createElement("div",{className:"relative m-2 flex justify-center overflow-hidden grayscale"},t.createElement("img",{src:new URL("/build/assets/sportlight-78fcd6da.png",self.location).href,alt:"sportlight.png",className:"aspect-auto h-full object-contain"}),t.createElement("img",{className:"absolute top-1/4 aspect-auto w-1/5 object-contain",src:new URL("/build/assets/red-ribbon-ea8ddbb9.webp",self.location).href,alt:"red-ribbon.webp"})),t.createElement("div",{className:"flex w-full flex-1 flex-col items-center justify-center"},t.createElement("h2",{className:"w-full max-w-60 text-center text-xl font-bold text-yellow-800 dark:text-yellow-400 xs:text-2xl"},za),t.createElement("h2",{className:"mt-3 w-full text-center text-sm font-bold text-yellow-800 dark:text-yellow-400"},Ja),t.createElement(f.div,{className:"mt-6 flex w-full max-w-60 flex-row items-center justify-between rounded-t-lg border border-yellow-600 bg-yellow-50 px-4 py-1 text-yellow-600 dark:bg-slate-900 dark:text-yellow-400"},t.createElement(f.span,null,t.createElement(R,{icon:xt,className:"mr-2"}),Ye),t.createElement(f.span,null,n)),t.createElement(f.div,{layout:!0,className:"flex w-full max-w-60 flex-row items-center justify-between rounded-b-lg border border-yellow-600 bg-yellow-50 px-4 py-1 text-yellow-600 dark:bg-slate-900 dark:text-yellow-400"},t.createElement(f.span,null,t.createElement(R,{icon:De,className:"mr-2"}),Bt),t.createElement(f.span,null,r)),t.createElement("div",{className:"mt-6 grid w-full max-w-60 grid-cols-1 gap-2 md:max-w-80 md:grid-cols-2"},t.createElement(T,{onClick:()=>{ll(e,()=>{e(V(Z))})},className:"rounded border border-transparent bg-yellow-600 py-2 text-base font-bold  text-white  dark:bg-yellow-400 dark:text-slate-900  max-xs:py-1"},Xa),t.createElement(T,{onClick:()=>{Je(e,null,()=>{e(V(Z))})},className:"rounded border border-transparent bg-yellow-600 py-2 text-base font-bold  text-white  dark:bg-yellow-400 dark:text-slate-900  max-xs:py-1"},Gt)))))))},xr=()=>{const e=h(({user:n})=>{var r;return((r=n==null?void 0:n.modals)==null?void 0:r[se])||null}),l=O(),a=()=>{l(V(se))};return t.createElement(B,null,e&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:a},t.createElement(f.div,{className:"relative flex max-h-full w-full flex-col overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-800 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-xs",onClick:n=>{n.stopPropagation()}},t.createElement(R,{className:"absolute left-4 top-4 h-6 w-6 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:a,icon:ue}),t.createElement(f.h2,{layout:!0,className:"border-b  border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},Mt),t.createElement(f.div,{className:"my-4 grid grid-cols-1 gap-1 text-center"},Rn.map(({label:n,to:r,modalName:s},c)=>t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{y:0,opacity:1,transition:{delay:c*.1}},closed:{y:10,opacity:0}},key:`menu-button-${c}`},t.createElement(T,{onClick:()=>{r&&(window.location.reload(),a()),s&&l(Qe(s,!0))},className:"rounded border  border-transparent bg-white px-2 py-2 text-base font-bold text-gray-600 shadow-none hover:border-gray-600 hover:bg-gray-100  dark:bg-slate-800  dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1"},n)))))))},yr=()=>{const e=O(),{settings:l,modals:a}=h(({user:m})=>m),n=(a==null?void 0:a[ie])||null,r=()=>{e(V(ie))},[s,c]=u.useState(null),[o,i]=u.useState(!1);return u.useEffect(()=>{n&&(async()=>{i(!0);try{c(An)}catch(d){console.error(d)}finally{i(!1)}})()},[n,s]),t.createElement(B,null,n&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:r},t.createElement(f.div,{className:"relative max-h-full w-full overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:r},o?t.createElement("p",{className:"my-4 text-center"},Nn):t.createElement("div",{className:"px-4 text-gray-600 dark:text-gray-300",dangerouslySetInnerHTML:{__html:s}}))))},Er=({isOpen:e,setIsOpen:l,onOK:a=()=>{}})=>(u.useEffect(()=>{const n=()=>{l(!1)};return e&&document.addEventListener("click",n),()=>{e&&document.removeEventListener("click",n)}},[e,l]),t.createElement(B,null,e&&t.createElement(f.div,{className:"absolute left-0 right-0 z-50 w-60 rounded border  border-majky-400 bg-white   px-3 py-4 shadow-md dark:bg-slate-900 max-sm:w-60 lg:mt-2 mx-auto",initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1,y:0},closed:{opacity:0,y:-30,transition:{delay:.2,duration:.1}}},onClick:n=>{n.stopPropagation()}},t.createElement("h2",{className:"relative px-2 text-center font-medium text-majky-800 dark:text-majky-400"},jn,t.createElement(R,{className:"absolute right-0 top-0 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:()=>{l(!1)},icon:ue})),t.createElement(f.div,{className:"mt-4 grid grid-cols-2 gap-2  font-medium"},t.createElement(T,{className:"rounded border-majky-200 bg-majky-50 py-1 text-center text-majky-800  dark:bg-slate-800 dark:text-majky-400",onClick:()=>{l(!1)}},qe),t.createElement(T,{className:" rounded border-majky-200  bg-majky-400 py-1 text-center text-white dark:bg-majky-600 dark:text-slate-800",onClick:()=>{a(),l(!1)}},Ht))))),U=({label:e,value:l})=>t.createElement("div",{className:"mt-2 w-full md:max-w-96"},t.createElement("span",{className:"inline-block w-40 text-right "},e),t.createElement("span",{className:"pl-4"},":"),t.createElement("span",{className:" inline-block w-32 md:w-40"},l)),wr=()=>{var m,d,y,k,_,E;const e=h(({user:p})=>{var b;return((b=p==null?void 0:p.modals)==null?void 0:b[me])||null}),l=O(),[a,n]=u.useState(!1),[r,s]=u.useState(!1),c=()=>{l(V(me))},[o,i]=u.useState(null);return u.useEffect(()=>{e&&i(St())},[e]),t.createElement(B,null,e&&t.createElement(f.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:c},t.createElement("div",{className:"relative flex max-h-full w-full flex-col items-center justify-between overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:p=>{p.stopPropagation()}},t.createElement("h2",{className:"w-full border-b border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},Ut),t.createElement("div",{className:"mt-4 flex w-full flex-col items-center text-center"},t.createElement(U,{label:gn,value:o==null?void 0:o.played}),t.createElement(U,{label:xn,value:`${(o==null?void 0:o.played)>0?parseInt((1-(o==null?void 0:o.failed)/(o==null?void 0:o.played))*100):0}%`}),t.createElement(U,{label:yn,value:o==null?void 0:o.streak}),t.createElement(U,{label:En,value:o==null?void 0:o.maxStreak}),t.createElement(U,{label:wn,value:Math.max(...((o==null?void 0:o.completed)||[]).map(({score:p})=>p),0)}),t.createElement(U,{label:hn,value:((o==null?void 0:o.completed)||[]).length>0?Math.floor(((m=o==null?void 0:o.completed)==null?void 0:m.reduce((p,{score:b})=>p+b,0))/((d=o==null?void 0:o.completed)==null?void 0:d.length)):0}),t.createElement(U,{label:kn,value:Q(Math.floor(((y=(o==null?void 0:o.completed)||[])==null?void 0:y.reduce((p,{playedTime:b})=>p+b,0))/(((k=o==null?void 0:o.completed)==null?void 0:k.length)||1)))}),t.createElement(U,{label:_n,value:Q(Math.max(...(_=(o==null?void 0:o.completed)||[])==null?void 0:_.map(({playedTime:p})=>p),0))}),t.createElement(U,{label:vn,value:Q(Math.min(...(E=(o==null?void 0:o.completed)||[])==null?void 0:E.map(({playedTime:p})=>p),0))})),t.createElement("div",{className:"mt-4 text-balance text-center text-sm text-majky-600"},In),t.createElement("div",{className:"mt-4 grid w-full max-w-80 grid-cols-2 gap-2  font-medium"},t.createElement(T,{className:"rounded border-majky-200  bg-majky-50 py-1 text-center text-majky-800  dark:bg-slate-800 dark:text-majky-400",onClick:p=>{n(!0),s(b=>!b)}},rn),t.createElement(T,{className:" rounded border-majky-200  bg-majky-400 py-1 text-center text-white dark:bg-majky-600 dark:text-slate-800",onClick:c},qe))),t.createElement(Er,{isOpen:r,setIsOpen:s,onOK:()=>{i(aa())}})))},hr=({children:e})=>{const{settings:l}=h(({user:a})=>a);return t.createElement(On,null,t.createElement(bl,{position:"top-center",newestOnTop:!0,closeOnClick:!0,limit:1,stacked:!0,toastClassName:"bg-white dark:text-slate-100 dark:bg-slate-900"}),t.createElement("div",{className:"relative flex h-full min-h-dvh w-full flex-auto !select-none flex-col items-center justify-start overflow-hidden bg-majky-600 bg-cover transition-all dark:bg-slate-900 dark:text-slate-100",style:{backgroundImage:`url('${new URL(Object.assign({"../../../../../image/freecell/background0.webp":rl,"../../../../../image/freecell/background1.webp":ol,"../../../../../image/freecell/background2.webp":sl})[`../../../../../image/freecell/background${l.backgroundType}.webp`],self.location).href}')`}},t.createElement("div",{className:`relative flex min-h-dvh w-full ${N?"":"max-w-screen-xl"} flex-col items-start justify-start`},t.createElement(ur,null),e),t.createElement(xr,null),t.createElement(fr,null),t.createElement(yr,null),t.createElement(wr,null),t.createElement(br,null),t.createElement(gr,null)))};function kr(){return Kn(),t.createElement(gl,{store:nl},t.createElement(Ul,{loading:null,persistor:sr},t.createElement(u.Suspense,{fallback:t.createElement(ir,null)},t.createElement(hr,null,t.createElement(Xn,null)))))}const _r=e=>{e&&e instanceof Function&&Bl(()=>import("./web-vitals-23d6d37b.js"),[]).then(({getCLS:l,getFID:a,getFCP:n,getLCP:r,getTTFB:s})=>{l(e),a(e),n(e),r(e),s(e)})},vr=cl.createRoot(document.getElementById("root"));vr.render(t.createElement(t.StrictMode,null,t.createElement(kr,null)));_r();