@roudanio/maze 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maze.css +1 -1
- package/dist/maze.iife.js +3 -3
- package/dist/maze.js +1072 -1075
- package/dist/maze.umd.js +3 -3
- package/package.json +1 -1
package/dist/maze.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.maze-game-container{position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%}.maze-game-container button{padding:8px 16px;background-color:#4caf50;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:16px;transition:background-color .2s}.maze-game-container button:hover{background-color:#45a049}.maze-game-container button:disabled{background-color:#ccc;cursor:not-allowed}.maze-game-container .link-button{background-color:transparent;color:#4caf50;cursor:pointer;font-size:16px;transition:color .2s}.maze-game-container .link-button:hover{color:#45a049;background-color:transparent}.maze-game-container .maze-canvas-container,.maze-game-container .single-maze-canvas-container{position:relative
|
|
1
|
+
.maze-game-container{position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%}.maze-game-container button{padding:8px 16px;background-color:#4caf50;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:16px;transition:background-color .2s}.maze-game-container button:hover{background-color:#45a049}.maze-game-container button:disabled{background-color:#ccc;cursor:not-allowed}.maze-game-container .link-button{background-color:transparent;color:#4caf50;cursor:pointer;font-size:16px;transition:color .2s}.maze-game-container .link-button:hover{color:#45a049;background-color:transparent}.maze-game-container .maze-canvas-container,.maze-game-container .single-maze-canvas-container{position:relative;-webkit-user-select:none;user-select:none;width:100%}.maze-game-container .maze-game-canvas{width:100%;height:100%;aspect-ratio:1 / 1;background-color:#fff;transition:opacity .1s ease}.maze-game-container .toast-container{position:absolute;pointer-events:none;width:100%;display:flex;justify-content:center;align-items:center;z-index:1000}.maze-game-container .toast-container.position-top{top:10px;left:0;right:0}.maze-game-container .toast-container.position-center{inset:0}.maze-game-container .toast-container.position-bottom{bottom:-36px;left:0;right:0}.maze-game-container .toast-message{font-size:16px;font-weight:700;text-align:center;padding:8px 12px;border-radius:8px;width:fit-content;max-width:90%;transition:opacity .3s ease,transform .3s ease;opacity:0;transform:translate(0,-10px,0);pointer-events:none;will-change:opacity,transform}.maze-game-container .toast-message.toast-visible{opacity:1;transform:translateZ(0)}.maze-game-container .game-panel-container{margin-bottom:15px;font-size:16px;background-color:#fff;border-radius:8px;box-shadow:0 4px 8px #0000001a;padding:12px 15px 15px;transition:all .3s ease;display:flex;flex-direction:row;justify-content:space-between;align-items:center}.maze-game-container .game-controls{display:flex;flex-direction:column;align-items:start;gap:12px}.maze-game-container .selectors-container{display:flex;justify-content:center;align-items:center;gap:10px;border-radius:10px}.maze-game-container .tier-dropdown,.maze-game-container .level-dropdown{padding:8px 12px;border-radius:8px;border:2px solid #3498db;background-color:#f8f9fa;color:#333;font-size:16px;font-weight:700;cursor:pointer;box-shadow:0 2px 4px #0000001a;appearance:none;background-image:url(data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E);background-repeat:no-repeat;background-position:right 12px top 50%;background-size:10px auto;min-width:120px;transition:all .3s ease;outline:none}.maze-game-container .level-dropdown{border-color:#9b59b6;width:150px}.maze-game-container .game-settings{display:flex;align-items:center;justify-content:center}.maze-game-container .game-settings .game-settings-icon{font-size:2rem;cursor:pointer}.maze-game-container .settings-stats{padding-top:20px;padding-bottom:20px;display:flex;flex-direction:column;align-items:start;gap:6px;text-align:left}.maze-game-container .settings-item-box{padding-top:20px;padding-bottom:20px;display:flex;flex-direction:column;align-items:start;gap:20px;text-align:left}.maze-game-container .settings-item-tip{color:#555}.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button{background-color:#aaa;color:#fff;cursor:pointer;transition:all .2s;border:none;outline:none;box-shadow:0 1px 3px #0003}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):hover{background-color:#d32f2f;box-shadow:0 2px 5px #0000004d}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):active{transform:scale(.95)}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):disabled+.settings-item-tip{color:#999}.maze-game-container .settings-clue-button.clue-on{background-color:#ff9800}.maze-game-container .settings-clue-button:hover{background-color:#ff9800;box-shadow:0 2px 5px #0000004d}.maze-game-container .settings-clue-button:active{transform:scale(.95)}.maze-game-container .settings-clue-button:disabled{background-color:#ccc;cursor:not-allowed;box-shadow:none;transform:none}.maze-game-container .level-complete-dialog .maze-dialog-buttons{justify-content:space-between}.maze-game-container .level-complete-dialog .maze-dialog-confirm{background-color:#ff9800}.maze-game-container .level-complete-dialog .maze-dialog-confirm:hover{background-color:#e67e00}.maze-game-container .level-complete-dialog .maze-continue-btn{background-color:#f1f1f1;color:#333}.maze-game-container .level-complete-dialog .maze-continue-btn:hover{background-color:#e1e1e1}.maze-game-container .maze-summary-message{width:75%;margin:30px auto;text-align:left}.maze-game-container .maze-go-next{margin:30px auto}.maze-game-container .maze-go-next-btn{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;font-size:1.5rem;gap:6px}.maze-game-container .maze-go-next-btn .spacebar-tip{font-size:.85rem}.maze-game-container .all-levels-completed{margin-top:20px;margin-bottom:20px}.maze-game-container .not-all-stars-collected{padding:10px;background-color:#fff8e1;color:#ff9800;border-radius:5px;text-align:center;font-size:14px}.maze-game-container .maze-dialog-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;z-index:1000;opacity:0;visibility:hidden;transition:opacity .3s,visibility .3s}.maze-game-container .maze-dialog-overlay.maze-dialog-visible{opacity:1;visibility:visible}.maze-game-container .maze-dialog-overlay.maze-dialog-visible .maze-dialog{transform:translateY(0)}.maze-game-container .maze-dialog{background-color:#fff;border-radius:8px;box-shadow:0 4px 16px #0003;width:300px;max-width:90%;padding:20px;text-align:center;transform:translateY(-20px);transition:transform .3s}.maze-game-container .maze-dialog-title{font-size:18px;font-weight:700;margin-bottom:10px;color:#333}.maze-game-container .maze-dialog-message{font-size:14px;color:#666;line-height:1.5}.maze-game-container .maze-dialog-buttons{margin-top:20px;display:flex;justify-content:center;gap:10px}.maze-game-container .maze-dialog-cancel{background-color:#f1f1f1;color:#333;font-size:14px}.maze-game-container .maze-dialog-cancel:hover{background-color:#e1e1e1}.maze-game-container .maze-dialog-confirm{background-color:#f44336;color:#fff;font-size:14px}.maze-game-container .maze-dialog-confirm:hover{background-color:#d32f2f}.maze-game-container .single-maze-canvas-container{position:relative;-webkit-user-select:none;user-select:none;width:100%}.maze-game-container .single-maze-loading,.maze-game-container .single-maze-error{display:flex;justify-content:center;align-items:center;height:200px;font-family:Arial,sans-serif;color:#666}.maze-game-container .single-maze-error{color:#d32f2f}.maze-game-container .single-maze-timer{text-align:center}.maze-game-container .maze-timer-text{font-size:18px;font-weight:700;color:#333;font-family:monospace}.maze-game-container .maze-timer-warning{color:#f44;animation:maze-timer-pulse 1s infinite}@keyframes maze-timer-pulse{0%,to{opacity:1}50%{opacity:.6}}
|
package/dist/maze.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Maze=function(){"use strict";var re,A,Ae,B,Pe,Ie,xe,Re,ge,pe,Ce,Fe,Q={},De=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function we(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?re.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return se(t,a,o,i,null)}function se(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ae,__i:-1,__u:0};return i==null&&A.vnode!=null&&A.vnode(s),s}function ae(t){return t.children}function le(t,e){this.props=t,this.context=e}function Y(t,e){if(e==null)return t.__?Y(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Y(t):null}function Oe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Oe(t)}}function ye(t){(!t.__d&&(t.__d=!0)&&B.push(t)&&!ce.__r++||Pe!=A.debounceRendering)&&((Pe=A.debounceRendering)||Ie)(ce)}function ce(){for(var t,e,n,o,i,s,a,r=1;B.length;)B.length>r&&B.sort(xe),t=B.shift(),r=B.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=H({},o)).__v=o.__v+1,A.vnode&&A.vnode(n),be(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??Y(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,je(s,n,a),n.__e!=i&&Oe(n)));ce.__r=0}function $e(t,e,n,o,i,s,a,r,l,c,d){var u,h,f,k,p,_,b=o&&o.__k||De,C=e.length;for(l=Tt(n,e,b,l,C),u=0;u<C;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?Q:b[f.__i]||Q,f.__i=u,_=be(t,f,h,i,s,a,r,l,c,d),k=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),d.push(f.ref,f.__c||k,f)),p==null&&k!=null&&(p=k),4&f.__u||h.__k===f.__k?l=Ue(f,l,t):typeof f.type=="function"&&_!==void 0?l=_:k&&(l=k.nextSibling),f.__u&=-7);return n.__e=p,l}function Tt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?se(null,a,null,null,null):ie(a)?se(ae,{children:a},null,null,null):a.constructor==null&&a.__b>0?se(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=kt(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=Y(r)),He(r,r));return o}function Ue(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ue(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=Y(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kt(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Ge(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||yt.test(e)?n:n+"px"}function ue(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Ge(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Ge(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Re,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ge,t.addEventListener(e,s?Ce:pe,s)):t.removeEventListener(e,s?Ce:pe,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ge++;else if(e.t<n.u)return;return n(A.event?A.event(e):e)}}}function be(t,e,n,o,i,s,a,r,l,c){var d,u,h,f,k,p,_,b,C,M,w,z,S,E,L,y,g,v=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=A.__b)&&d(e);e:if(typeof v=="function")try{if(b=e.props,C="prototype"in v&&v.prototype.render,M=(d=v.contextType)&&o[d.__c],w=d?M?M.props.value:d.__:o,n.__c?_=(u=e.__c=n.__c).__=u.__E:(C?e.__c=u=new v(b,w):(e.__c=u=new le(b,w),u.constructor=v,u.render=zt),M&&M.sub(u),u.props=b,u.state||(u.state={}),u.context=w,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&v.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,v.getDerivedStateFromProps(b,u.__s))),f=u.props,k=u.state,u.__v=e,h)C&&v.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&v.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,w),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,w)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),z=0;z<u._sb.length;z++)u.__h.push(u._sb[z]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,w),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,k,p)})}if(u.context=w,u.props=b,u.__P=t,u.__e=!1,S=A.__r,E=0,C){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),C&&!h&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(f,k)),y=d,d!=null&&d.type===ae&&d.key==null&&(y=qe(d.props.children)),r=$e(t,ie(y)?y:[y],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(T){if(e.__v=null,l||s!=null)if(T.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(g=s.length;g--;)we(s[g]);else e.__e=n.__e,e.__k=n.__k;A.__e(T,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=St(n.__e,e,n,o,i,s,a,l,c);return(d=A.diffed)&&d(e),128&e.__u?void 0:r}function je(t,e,n){for(var o=0;o<n.length;o++)Te(n[o],n[++o],n[++o]);A.__c&&A.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){A.__e(s,i.__v)}})}function qe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ie(t)?t.map(qe):H({},t)}function St(t,e,n,o,i,s,a,r,l){var c,d,u,h,f,k,p,_=n.props,b=e.props,C=e.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){t=f,s[c]=null;break}}if(t==null){if(C==null)return document.createTextNode(b);t=document.createElementNS(i,C,b.is&&b),r&&(A.__m&&A.__m(e,s),r=!1),s=null}if(C==null)_===b||r&&t.data==b||(t.data=b);else{if(s=s&&re.call(t.childNodes),_=n.props||Q,!r&&s!=null)for(_={},c=0;c<t.attributes.length;c++)_[(f=t.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ue(t,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?k=f:c=="checked"?p=f:r&&typeof f!="function"||_[c]===f||ue(t,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),$e(e.type=="template"?t.content:t,ie(h)?h:[h],e,n,o,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&Y(n,0),r,l),s!=null)for(c=s.length;c--;)we(s[c]);r||(c="value",C=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||C=="progress"&&!k||C=="option"&&k!=_[c])&&ue(t,c,k,_[c],i),c="checked",p!=null&&p!=t[c]&&ue(t,c,p,_[c],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){A.__e(i,n)}}function He(t,e,n){var o,i;if(A.unmount&&A.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Te(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){A.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&He(o[i],e,n||typeof t.type!="function");n||we(t.__e),t.__c=t.__=t.__e=void 0}function zt(t,e,n){return this.constructor(t,n)}function Be(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),A.__&&A.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],be(e,t=e.__k=bt(ae,null,[t]),i||Q,Q,e.namespaceURI,i?null:e.firstChild?re.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),je(s,t,a)}function Et(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,ye(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Fe++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}re=De.slice,A={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},Ae=0,le.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ye(this))},le.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ye(this))},le.prototype.render=ae,B=[],Ie=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},ce.__r=0,Re=/(PointerCapture)$|Capture$/i,ge=0,pe=We(!1),Ce=We(!0),Fe=0;var Lt=0;function m(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return A.vnode&&A.vnode(c),c}var K,P,ke,Ve,ee=0,Xe=[],F=A,Ye=F.__b,Ke=F.__r,Je=F.diffed,Ze=F.__c,Qe=F.unmount,et=F.__;function de(t,e){F.__h&&F.__h(P,t,ee||e),ee=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function U(t){return ee=1,Nt(rt,t)}function Nt(t,e,n){var o=de(K++,2);if(o.t=t,!o.__c&&(o.__=[rt(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};P.__f=!0;var s=P.shouldComponentUpdate,a=P.componentWillUpdate;P.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},P.shouldComponentUpdate=i}return o.__N||o.__}function R(t,e){var n=de(K++,3);!F.__s&&ot(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function D(t){return ee=5,J(function(){return{current:t}},[])}function J(t,e){var n=de(K++,7);return ot(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function tt(t,e){return ee=8,J(function(){return t},e)}function Mt(t){var e=P.context[t.__c],n=de(K++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(P)),e.props.value):t.__}function At(){for(var t;t=Xe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(he),t.__H.__h.forEach(Se),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Ye&&Ye(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),et&&et(t,e)},F.__r=function(t){Ke&&Ke(t),K=0;var e=(P=t.__c).__H;e&&(ke===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(he),e.__h.forEach(Se),e.__h=[],K=0)),ke=P},F.diffed=function(t){Je&&Je(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Ve===F.requestAnimationFrame||((Ve=F.requestAnimationFrame)||Pt)(At)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(o){return!o.__||Se(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],F.__e(o,n.__v)}}),Ze&&Ze(t,e)},F.unmount=function(t){Qe&&Qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{he(o)}catch(i){e=i}}),n.__H=void 0,e&&F.__e(e,n.__v))};var nt=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(o),nt&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function he(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function Se(t){var e=P;t.__c=t.__(),P=e}function ot(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function rt(t,e){return typeof e=="function"?e(t):e}const It=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),it=Et(void 0),st={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},ze={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:t,config:e})=>{const n=It(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=U(()=>o||{...st});R(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),R(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[a,r]=U({...ze}),l=D(a);R(()=>{l.current=a},[a]);const c=J(()=>[a.playerAtExit?1:0,a.foodCollected===a.totalFoodCount?1:0,a.showClue?0:1],[a.playerAtExit,a.foodCollected,a.totalFoodCount,a.showClue]),d=()=>{n.resetGameData(),s({...st}),r({...ze})};return m(it.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:a,setGamePlayState:r,gamePlayStateRef:l,currentScore:c,config:e,resetGame:d},children:t})},te=()=>{const t=Mt(it);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},ne=t=>J(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),Rt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=ne(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=ne(s),u=J(()=>{const[h,f]=d.getTierLevelsRange(a);return Array.from({length:f-h+1},(k,p)=>{const _=h+p,b=r[_]||0;return{level:_,score:b}})},[a,r]);return m("div",{className:"level-selector",children:m("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},oe=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=D(null);return R(()=>{const k=p=>{p.key==="Escape"&&h?.()};return t&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[t,h]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&m("div",{className:"maze-dialog-buttons",children:[!a&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:l}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},G={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=t,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},e)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:a}=te(),{i18n:r,levelConfig:l}=a,c=ne(l),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=t,k=c.getTotalLevels(),[p,_]=U(!1),[b,C]=U(!1),[M,w]=U(!1),z=O=>{const x=c.getFirstLevelOfTier(O);c.isLevelUnlocked(x,h)&&(e($=>({...$,currentTier:O})),S(x))},S=O=>{c.isLevelUnlocked(O,h)&&(e(x=>({...x,currentLevel:O})),G.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},E=()=>{_(!0)},L=()=>{_(!1)},y=()=>{w(!0)},g=()=>{w(!1)},v=()=>{G.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),w(!1)},T=()=>{C(!0)},N=()=>{s(),C(!1),G.show(r.resetDoneToast)},I=()=>{C(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:z,disabled:d}),m(Ft,{onLevelChange:S,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:y,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:E,children:"★ "+f})}),m(oe,{isOpen:p,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:L,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${k}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:T,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(oe,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:N,onCancel:I}),m(oe,{isOpen:M,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:v,onCancel:g})]})};function Ee(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Le(t,e,n){return e&&Ot(t.prototype,e),t}function at(t){return+t.replace(/px/,"")}function $t(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function W(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function lt(t){return t[W(0,t.length)]}var Ut=.00125,Gt=5e-4,Wt=9e-4,jt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ct(t){var e=1920;return Math.log(t)/Math.log(e)}var ut=function(){function t(e){Ee(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=W(Bt,Vt,3),d=c*ct(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=W(Xt,Yt,3),this.rotationSpeed=a.length?.01:W(Kt,Jt,3)*ct(l),this.dragForceCoefficient=W(Gt,Wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?W(0,.2,3):W(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=W(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?W(Qt,Zt)*Math.PI/180:W(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=W(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=a.length?null:lt(s),this.emoji=a.length?lt(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Le(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:jt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),t}();function rn(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function sn(t){var e=t.confettiRadius,n=e===void 0?qt:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?nn:tn):o,s=t.confettiColors,a=s===void 0?on:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?Ht:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var an=function(){function t(e){var n=this;Ee(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Le(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),ln=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ee(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Le(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},k={x:d,y:h},p=new an(this.canvasContext),_=0;_<s/2;_++){var b=new ut({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),C=new ut({initialPosition:k,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});p.addShapes(b,C)}return this.activeConfettiBatches.push(p),this.queueAnimationFrameIfNeeded(),p.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const cn=new ln,Ne=3,un=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=te(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:k,levelTransitioning:p}=o,{currentLevel:_}=s,[b,C]=U(!1);R(()=>{k&&p&&(cn.addConfetti(),G.show(r.levelCompleteToast),C(!0))},[k,p]);const M=ne(l),w=M.getTotalLevels(),z=J(()=>_>=w,[_,w]),S=()=>{C(!1),G.show(r.levelRestartToast),t?.()},E=()=>{C(!1),i(g=>({...g,isGameActive:!0,levelTransitioning:!1}))},L=()=>{C(!1);const g=M.getNextLevelInfo(_);if(!g)return;const{nextLevel:v,nextTier:T,isTierChange:N}=g;N&&G.show(r.tierUnlockedToast.replace("%TIER%",T.toString())),a(I=>({...I,currentLevel:v,currentTier:T,highestUnlockedLevel:Math.max(I.highestUnlockedLevel,v),highestUnlockedTier:Math.max(I.highestUnlockedTier,T),levelScores:{...I.levelScores,[I.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,I.levelScores[I.currentLevel]||0)}}))},y=()=>{C(!1),a(g=>{const v=Math.max(Object.values(n).filter(Boolean).length,g.levelScores[g.currentLevel]||0),T={...g.levelScores,[g.currentLevel]:v};let N=0,I=0;const O=Object.entries(T).sort((x,$)=>Number(x[0])-Number($[0]));for(const[x,$]of O)if($<Ne){N=Number(x),I=M.getTierByLevel(N);break}return(N>0&&N!==_||v<Ne)&&G.show(r.notCompleteLevel),(N===0||v<Ne)&&t?.(),{...g,currentLevel:N||g.currentLevel,currentTier:I||g.currentTier,levelScores:T}})};return R(()=>{const g=document.querySelector(".maze-game-container"),v=T=>{b&&((T.key===" "||T.code==="Space")&&g&&(g.contains(document.activeElement)||document.activeElement===document.body)&&(T.preventDefault(),z?y():L()),(T.key==="r"||T.code==="KeyR")&&S(),(T.key==="c"||T.code==="KeyC")&&E())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b,z]),m(oe,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:S,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:E,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),z&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:z?m("button",{className:"maze-go-next-btn",type:"button",onClick:y,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:L,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},dt=(t,e)=>{const n=D({canvasWidth:0,canvasHeight:0});return R(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},e?.()};o();let i=null;return window.ResizeObserver&&t.current&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},ht=(t,e,n)=>{const o=D({cellWidth:0,cellHeight:0});return R(()=>{const i=()=>{const a=t.current,r=e.maze;if(!a||!r)return;const{rows:l,cols:c}=r;if(l<=0||c<=0)return;const d=(a.width-n*2)/c,u=(a.height-n*2)/l;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return t.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(t.current)),()=>{t.current&&s?.disconnect()}},[t,e.maze,n]),o},fe={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},ft=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,moveSpeedRef:i,playerRadius:s,onFoodCollected:a,onExitReached:r,onFirstMove:l})=>{const c=()=>i?.current??o??.03,d=D(!1),u=D(new Set),h=D(!1),f=tt((w,z)=>{const S=e.current;if(!S.maze)return{canMove:!1,newCell:null};const E=c(),[L,y]=fe[w];if(mt(z,L,y,s,E,S.maze))return{canMove:!1,newCell:null};const{row:v,col:T}=z,N=v+L*E,I=T+y*E,O=-.5,x=S.maze.rows,$=S.maze.cols;if(N<O||N>=x||I<O||I>=$)return{canMove:!1,newCell:null};const V=v<0?0:Math.floor(v),X=T<0?0:Math.floor(T),j=N<0?0:Math.floor(N),q=I<0?0:Math.floor(I);return j!==V||q!==X?S.maze.isValid(j,q)?{canMove:!0,newCell:{row:j,col:q}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[s,c]),k=()=>{const w=e.current,{row:z,col:S}=w.playerCell,E=s*2,L=w.foodCells.findIndex(v=>Math.sqrt(Math.pow(z-v.row,2)+Math.pow(S-v.col,2))<E);L!==-1&&a&&(a(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((v,T)=>T!==L)});const g=fn(w.playerCell,w.exitCell,w.maze);g&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},r&&r(),requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10})):!g&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=w=>{const z=e.current,S=Math.round(w.row),E=Math.round(w.col),L=z.playerPath?.[z.playerPath.length-1],y=L?.row===S&&L?.col===E,g=Math.abs(L?.row??0-S),v=Math.abs(L?.col??0-E);if((g===1&&v===0||g===0&&v===1)&&!y){const N=`${L?.row},${L?.col}-${S},${E}`;e.current={...e.current,playerPath:[...e.current.playerPath??[],{row:S,col:E}],visitCounts:{...e.current.visitCounts,[N]:(e.current.visitCounts?.[N]||0)+1}}}},_=()=>{if(d.current||u.current.size===0)return;const w=e.current;!w.playerCell||!Array.from(u.current).some(S=>{const{canMove:E}=f(S,w.playerCell);return E})||(!h.current&&l&&(h.current=!0,l()),d.current=!0)};R(()=>{const w=y=>{if(y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key===" "){const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true"))return;y.preventDefault()}},z=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),e.current.isGameActive&&(u.current.has(g)||(u.current.add(g),d.current||_())))},S=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),u.current.delete(g),u.current.size===0&&C())},E=y=>{y.preventDefault();const g=e.current;if(!g.isGameActive||!g.maze||d.current)return;const v=y.touches[0],T=document.elementFromPoint(v.clientX,v.clientY);let N=null;T&&(T.classList.contains("maze-up")?N="ArrowUp":T.classList.contains("maze-down")?N="ArrowDown":T.classList.contains("maze-left")?N="ArrowLeft":T.classList.contains("maze-right")&&(N="ArrowRight")),N&&(u.current.clear(),u.current.add(N),_())},L=()=>{C()};return window.addEventListener("keydown",w,{capture:!0}),window.addEventListener("keydown",z),window.addEventListener("keyup",S),t.current?.addEventListener("touchstart",E,{passive:!1}),t.current?.addEventListener("touchend",L),()=>{window.removeEventListener("keydown",w,{capture:!0}),window.removeEventListener("keydown",z),window.removeEventListener("keyup",S),t.current?.removeEventListener("touchstart",E),t.current?.removeEventListener("touchend",L)}},[]);const b=tt(()=>{if(!d.current||u.current.size===0)return e.current.playerCell;const w=c(),z=e.current.playerCell;let S=0,E=0,L=0;for(const Z of u.current){const{canMove:Me}=f(Z,z);if(Me){const[wt,xn]=fe[Z];S+=wt,E+=xn,L++}}if(L===0)return e.current.playerCell;const y=Math.sqrt(S*S+E*E),g=y>0?S/y:0,v=y>0?E/y:0,T=Number((z.row+g*w).toFixed(2)),N=Number((z.col+v*w).toFixed(2)),I=T-z.row,O=N-z.col,x=Math.sqrt(I*I+O*O);if(x>0){const Z=I/x,Me=O/x;if(mt(z,Z,Me,s,x,e.current.maze))return e.current.playerCell}e.current.playerCell={row:T,col:N},k();const $=z.row<0?0:Math.round(z.row),V=z.col<0?0:Math.round(z.col),X=T<0?0:Math.round(T),j=N<0?0:Math.round(N);return(X!==$||j!==V)&&p({row:X,col:j}),e.current.playerCell},[c,f]),C=()=>{d.current=!1,u.current.clear()};return{updatePlayerPos:b,resetMovingState:C,resetFirstMoveState:()=>{h.current=!1}}};function mt(t,e,n,o,i,s){const a=t.row+e*i,r=t.col+n*i,l={row:a,col:r},c=[],d=t.row<0?0:Math.floor(t.row),u=t.col<0?0:Math.floor(t.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,k]of h){const p=d+f,_=u+k;s.isValid(p,_)&&c.push({row:p,col:_})}for(const f of c){const k=dn(f.row,f.col,s);for(const p of k)if(hn(l,p)<o)return!0}return!1}function dn(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function hn(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,f=t.row-u;return Math.sqrt(h*h+f*f)}function fn(t,e,n){if(!n.isValid(e.row,e.col))return!1;const o=t.col>=e.col-.5&&t.col<=e.col+.5,i=t.row>=e.row+.5,s=t.row>=e.row-.5;return o&&i&&s}function _t(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:k,visitCounts:p}=e,{padding:_,wallWidth:b,wallColor:C,playerColor:M,playerRadius:w,foodColor:z,backgroundColor:S,clueColor:E,exitColor:L,exitWallWidth:y,exitDashArray:g}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=S,t.fillRect(0,0,s,a),t.restore(),f&&Cn({ctx:t,playerPath:k??[],visitCounts:p??{},cellWidth:r,cellHeight:l,padding:_,clueColor:E}),mn({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:_,wallColor:C,wallWidth:b}),vn({ctx:t,maze:c,exitCell:u,cellWidth:r,cellHeight:l,padding:_,exitColor:L,exitWallWidth:y,exitDashArray:g}),gn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:_,foodColor:z}),_n({ctx:t,playerCell:d,playerRadius:w,cellWidth:r,cellHeight:l,padding:_,playerColor:M})}function mn({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),wn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function _n({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=me(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function vn({ctx:t,maze:e,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:a,exitWallWidth:r,exitDashArray:l=[8,12]}){const{row:c,col:d}=n;if(!e.isValid(c,d))return;const u=s+d*o,h=s+c*i;t.save(),t.globalCompositeOperation="destination-out",t.lineWidth=r,t.lineCap="round",t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.globalCompositeOperation="source-over",t.strokeStyle=a,t.lineWidth=r,t.setLineDash(l),t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.restore()}function gn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=me(r.row,r.col,n,o,i);pn(t,l,c,a*1.2,5,a*.6)})}function pn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function Cn({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),k=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${f})`}t.lineWidth=k,t.lineCap="round",t.lineJoin="round";const{x:p,y:_}=me(l.row,l.col,o,i,s),{x:b,y:C}=me(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(p,_),t.lineTo(b,C),t.stroke()}t.restore()}}function wn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function me(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function yn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class bn{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class vt{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new bn(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const gt=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,kn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new vt(r,l,i,o,c,d),h=Tn(t),f=[];for(let k=0;k<h;k++){let p;do p={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(p.row===c.row&&p.col===c.col||p.row===d.row&&p.col===d.col||!gt(u,p.row,p.col)||f.some(_=>_.row===p.row&&_.col===p.col));f.push(p)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:t,seed:e,method:n,foodCount:o})=>{const i=t,s=t,a={row:0,col:0},r={row:i-1,col:s-1},l=new vt(i,s,n,e,a,r),c=[];for(let d=0;d<o;d++){let u,h=0;do u={row:Math.floor(l.random()*i),col:Math.floor(l.random()*s)},h++;while(h<50&&(u.row===a.row&&u.col===a.col||u.row===r.row&&u.col===r.col||!gt(l,u.row,u.col)||c.some(f=>f.row===u.row&&f.col===u.col)));h<50&&c.push(u)}return{isGameActive:!0,levelTransitioning:!1,maze:l,playerCell:a,exitCell:r,foodCells:c,playerAtExit:!1,foodCollected:0,totalFoodCount:o}};function zn(){const{setGamePlayState:t,gamePlayState:e,gamePlayStateRef:n,gameProgress:o,config:i}=te(),s=D(null),a=D(null),{i18n:r,levelConfig:l,renderConfig:c}=i,d=ne(l),u=D(d.getLevelConfig(o.currentLevel));R(()=>{s.current&&G.attachTo(s.current)},[]);const h=D(),f=dt(a,()=>{h.current?.()}),k=ht(a,e,c.padding);R(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const p=()=>{const M=kn(o.currentLevel,u.current);M&&t(w=>({...w,...M}))};R(()=>{p()},[o.currentLevel]);const _=()=>{p()},{updatePlayerPos:b,resetMovingState:C}=ft({containerRef:s,gamePlayStateRef:n,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const M=n.current.totalFoodCount-n.current.foodCollected-1;M>0?G.show(r.foodCollectedToast.replace("%NUM%",M.toString()),3e3):G.show(r.allFoodCollectedToast)}});return R(()=>{C()},[o.currentLevel,C]),R(()=>{let M,w=!document.hidden;const z=()=>{const L=a.current?.getContext("2d"),y=n.current;if(!(w&&y?.isGameActive&&L&&y?.maze)){M=requestAnimationFrame(z);return}b(),S(),M=requestAnimationFrame(z)},S=()=>{const L=a.current?.getContext("2d"),y=n.current;if(L&&y?.maze){const g=u.current?.wallWidth||c?.wallWidth,v=u.current?.exitColor||c?.exitColor,T=u.current?.exitWallWidth||c?.exitWallWidth,N=u.current?.exitDashArray||c?.exitDashArray;_t(L,y,f.current,k.current,{...c,wallWidth:g,exitColor:v,exitWallWidth:T,exitDashArray:N})}};h.current=S;const E=L=>{const y=w;w=!document.hidden&&document.visibilityState==="visible"&&(!L||L.type!=="blur"),!y&&w?n.current?.levelTransitioning===!1&&t({...n.current,isGameActive:!0}):y&&!w&&t({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",E),window.addEventListener("focus",E),M=requestAnimationFrame(z),()=>{cancelAnimationFrame(M),document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",E),window.removeEventListener("focus",E)}},[]),R(()=>{G.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:[m("canvas",{ref:a,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})}const En=t=>{const e=Math.floor(t/60),n=t%60;return`${e.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:t,onTimeUp:e})=>{const[n,o]=U(t),i=D(),s=D(!1);return R(()=>{const a=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(l=>l<=1?(clearInterval(i.current),e(),0):l-1)},1e3))},r=()=>{clearInterval(i.current),i.current=void 0};return window.addEventListener("maze:firstMove",a),window.addEventListener("maze:gameSuccess",r),()=>{window.removeEventListener("maze:firstMove",a),window.removeEventListener("maze:gameSuccess",r),clearInterval(i.current)}},[]),R(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(t),s.current=!1},[t]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:t}){const{size:e,seed:n,method:o,foodCount:i,renderConfig:s,successCallback:a,failCallback:r,timer:l,i18n:c}=t,[d,u]=U({...ze}),[h,f]=U(!1),[k,p]=U(!1),[_,b]=U(!1),[C,M]=U(""),w=D(null),z=D(null),S=D(d),E=D(),L=dt(w,()=>{E.current?.()}),y=ht(w,d,s.padding);R(()=>{S.current=d},[d]);const{updatePlayerPos:g,resetMovingState:v,resetFirstMoveState:T}=ft({containerRef:z,gamePlayStateRef:S,setGamePlayState:u,playerRadius:s.playerRadius,moveSpeed:s.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{k||I()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),N=()=>{p(!0),M(`⏰ ${c.failMsg}`),b(!0),u(x=>({...x,isGameActive:!1})),r&&r()},I=()=>{p(!0),M(`🎉 ${c.successMsg}`),b(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess")),a&&a()},O=()=>{b(!1)};return R(()=>{(async()=>{f(!0);try{const $=Sn({size:e,seed:n,method:o,foodCount:i});S.current=$,u($)}catch($){console.error("Error generating single maze:",$)}finally{f(!1)}})()},[t]),R(()=>{let x;const $=!document.hidden,V=()=>{const j=w.current?.getContext("2d"),q=S.current;if(!($&&q?.isGameActive&&j&&q?.maze)){x=requestAnimationFrame(V);return}g(),X(),x=requestAnimationFrame(V)},X=()=>{const j=w.current?.getContext("2d"),q=S.current;j&&q?.maze&&_t(j,q,L.current,y.current,s)};return E.current=X,x=requestAnimationFrame(V),()=>{cancelAnimationFrame(x)}},[]),R(()=>{v(),T()},[t,v,T]),h?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):d?m("div",{className:"maze-game-container",children:[m(Ln,{timer:l,onTimeUp:N}),m("div",{className:"single-maze-canvas-container",ref:z,children:[m("canvas",{ref:w,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]}),m(oe,{isOpen:_,title:C,noConfirm:!0,cancelText:"OK",onCancel:O})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const pt=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],Ct={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},_e={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:Ct,levelConfig:pt},ve={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",foodCount:3,renderConfig:Ct,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:t={}}){const e={..._e.i18n,...t.i18n||{}},n={..._e.renderConfig,...t.renderConfig||{}},o=t.levelConfig||pt,i={..._e,...t,i18n:e,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:t={}}){const e={...ve.i18n,...t.i18n||{}},n={...ve.renderConfig,...t.renderConfig||{}},o={...ve,...t,i18n:e,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",..._e};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",...ve};return`${JSON.stringify(In,(t,e)=>typeof e=="function"?e.toString():e,2)}`,{showNotice(){console.warn("Cannot find the root element");const t=document.createElement("div");t.style.textAlign="center",t.style.padding="20px",t.innerHTML="Cannot find the root element",document.body.append(t)},addLoadingIndicator(t){const e=document.createElement("div"),n=document.createElement("div");e.style.cssText=`
|
|
1
|
+
var Maze=function(){"use strict";var se,M,Pe,V,Ie,xe,Re,Fe,Ce,we,ye,De,te={},Oe=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,le=Array.isArray;function H(e,t){for(var n in t)e[n]=t[n];return e}function be(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function bt(e,t,n){var o,i,s,l={};for(s in t)s=="key"?o=t[s]:s=="ref"?i=t[s]:l[s]=t[s];if(arguments.length>2&&(l.children=arguments.length>3?se.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)l[s]==null&&(l[s]=e.defaultProps[s]);return ae(e,l,o,i,null)}function ae(e,t,n,o,i){var s={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Pe,__i:-1,__u:0};return i==null&&M.vnode!=null&&M.vnode(s),s}function ce(e){return e.children}function ue(e,t){this.props=e,this.context=t}function K(e,t){if(t==null)return e.__?K(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?K(e):null}function $e(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return $e(e)}}function Te(e){(!e.__d&&(e.__d=!0)&&V.push(e)&&!de.__r++||Ie!=M.debounceRendering)&&((Ie=M.debounceRendering)||xe)(de)}function de(){for(var e,t,n,o,i,s,l,r=1;V.length;)V.length>r&&V.sort(Re),e=V.shift(),r=V.length,e.__d&&(n=void 0,i=(o=(t=e).__v).__e,s=[],l=[],t.__P&&((n=H({},o)).__v=o.__v+1,M.vnode&&M.vnode(n),ke(t.__P,n,o,t.__n,t.__P.namespaceURI,32&o.__u?[i]:null,s,i??K(o),!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,qe(s,n,l),n.__e!=i&&$e(n)));de.__r=0}function Ue(e,t,n,o,i,s,l,r,a,c,d){var u,h,f,p,v,_,b=o&&o.__k||Oe,C=t.length;for(a=Tt(n,t,b,a,C),u=0;u<C;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?te:b[f.__i]||te,f.__i=u,_=ke(e,f,h,i,s,l,r,a,c,d),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Se(h.ref,null,f),d.push(f.ref,f.__c||p,f)),v==null&&p!=null&&(v=p),4&f.__u||h.__k===f.__k?a=Ge(f,a,e):typeof f.type=="function"&&_!==void 0?a=_:p&&(a=p.nextSibling),f.__u&=-7);return n.__e=v,a}function Tt(e,t,n,o,i){var s,l,r,a,c,d=n.length,u=d,h=0;for(e.__k=new Array(i),s=0;s<i;s++)(l=t[s])!=null&&typeof l!="boolean"&&typeof l!="function"?(a=s+h,(l=e.__k[s]=typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?ae(null,l,null,null,null):le(l)?ae(ce,{children:l},null,null,null):l.constructor==null&&l.__b>0?ae(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):l).__=e,l.__b=e.__b+1,r=null,(c=l.__i=kt(l,n,a,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof l.type!="function"&&(l.__u|=4)):c!=a&&(c==a-1?h--:c==a+1?h++:(c>a?h--:h++,l.__u|=4))):e.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=K(r)),Be(r,r));return o}function Ge(e,t,n){var o,i;if(typeof e.type=="function"){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,t=Ge(o[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=K(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function kt(e,t,n,o){var i,s,l=e.key,r=e.type,a=t[n];if(a===null&&e.key==null||a&&l==a.key&&r==a.type&&(2&a.__u)==0)return n;if(o>(a!=null&&(2&a.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<t.length;){if(i>=0){if((a=t[i])&&(2&a.__u)==0&&l==a.key&&r==a.type)return i;i--}if(s<t.length){if((a=t[s])&&(2&a.__u)==0&&l==a.key&&r==a.type)return s;s++}}return-1}function We(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||yt.test(t)?n:n+"px"}function he(e,t,n,o,i){var s;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||We(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||We(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(Fe,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?o?n.u=o.u:(n.u=Ce,e.addEventListener(t,s?ye:we,s)):e.removeEventListener(t,s?ye:we,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function je(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Ce++;else if(t.t<n.u)return;return n(M.event?M.event(t):t)}}}function ke(e,t,n,o,i,s,l,r,a,c){var d,u,h,f,p,v,_,b,C,T,g,k,w,y,S,N,z,E=t.type;if(t.constructor!=null)return null;128&n.__u&&(a=!!(32&n.__u),s=[r=t.__e=n.__e]),(d=M.__b)&&d(t);e:if(typeof E=="function")try{if(b=t.props,C="prototype"in E&&E.prototype.render,T=(d=E.contextType)&&o[d.__c],g=d?T?T.props.value:d.__:o,n.__c?_=(u=t.__c=n.__c).__=u.__E:(C?t.__c=u=new E(b,g):(t.__c=u=new ue(b,g),u.constructor=E,u.render=zt),T&&T.sub(u),u.props=b,u.state||(u.state={}),u.context=g,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&E.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,E.getDerivedStateFromProps(b,u.__s))),f=u.props,p=u.state,u.__v=t,h)C&&E.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&E.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,g),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,g)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(L){L&&(L.__=t)}),k=0;k<u._sb.length;k++)u.__h.push(u._sb[k]);u._sb=[],u.__h.length&&l.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,g),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,p,v)})}if(u.context=g,u.props=b,u.__P=e,u.__e=!1,w=M.__r,y=0,C){for(u.state=u.__s,u.__d=!1,w&&w(t),d=u.render(u.props,u.state,u.context),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[]}else do u.__d=!1,w&&w(t),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++y<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),C&&!h&&u.getSnapshotBeforeUpdate!=null&&(v=u.getSnapshotBeforeUpdate(f,p)),N=d,d!=null&&d.type===ce&&d.key==null&&(N=He(d.props.children)),r=Ue(e,le(N)?N:[N],t,n,o,i,s,l,r,a,c),u.base=t.__e,t.__u&=-161,u.__h.length&&l.push(u),_&&(u.__E=u.__=null)}catch(L){if(t.__v=null,a||s!=null)if(L.then){for(t.__u|=a?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,t.__e=r}else for(z=s.length;z--;)be(s[z]);else t.__e=n.__e,t.__k=n.__k;M.__e(L,t,n)}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):r=t.__e=St(n.__e,t,n,o,i,s,l,a,c);return(d=M.diffed)&&d(t),128&t.__u?void 0:r}function qe(e,t,n){for(var o=0;o<n.length;o++)Se(n[o],n[++o],n[++o]);M.__c&&M.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){M.__e(s,i.__v)}})}function He(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:le(e)?e.map(He):H({},e)}function St(e,t,n,o,i,s,l,r,a){var c,d,u,h,f,p,v,_=n.props,b=t.props,C=t.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){e=f,s[c]=null;break}}if(e==null){if(C==null)return document.createTextNode(b);e=document.createElementNS(i,C,b.is&&b),r&&(M.__m&&M.__m(t,s),r=!1),s=null}if(C==null)_===b||r&&e.data==b||(e.data=b);else{if(s=s&&se.call(e.childNodes),_=n.props||te,!r&&s!=null)for(_={},c=0;c<e.attributes.length;c++)_[(f=e.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;he(e,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?p=f:c=="checked"?v=f:r&&typeof f!="function"||_[c]===f||he(e,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(u&&(e.innerHTML=""),Ue(t.type=="template"?e.content:e,le(h)?h:[h],t,n,o,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,l,s?s[0]:n.__k&&K(n,0),r,a),s!=null)for(c=s.length;c--;)be(s[c]);r||(c="value",C=="progress"&&p==null?e.removeAttribute("value"):p!=null&&(p!==e[c]||C=="progress"&&!p||C=="option"&&p!=_[c])&&he(e,c,p,_[c],i),c="checked",v!=null&&v!=e[c]&&he(e,c,v,_[c],i))}return e}function Se(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(i){M.__e(i,n)}}function Be(e,t,n){var o,i;if(M.unmount&&M.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Se(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){M.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(i=0;i<o.length;i++)o[i]&&Be(o[i],t,n||typeof e.type!="function");n||be(e.__e),e.__c=e.__=e.__e=void 0}function zt(e,t,n){return this.constructor(e,n)}function Ve(e,t,n){var o,i,s,l;t==document&&(t=document.documentElement),M.__&&M.__(e,t),i=(o=!1)?null:t.__k,s=[],l=[],ke(t,e=t.__k=bt(ce,null,[e]),i||te,te,t.namespaceURI,i?null:t.firstChild?se.call(t.childNodes):null,s,i?i.__e:t.firstChild,o,l),qe(s,e,l)}function Et(e){function t(n){var o,i;return this.getChildContext||(o=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(l){l.__e=!0,Te(l)})},this.sub=function(s){o.add(s);var l=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),l&&l.call(s)}}),n.children}return t.__c="__cC"+De++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,o){return n.children(o)}).contextType=t,t}se=Oe.slice,M={__e:function(e,t,n,o){for(var i,s,l;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),l=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,o||{}),l=i.__d),l)return i.__E=i}catch(r){e=r}throw e}},Pe=0,ue.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof e=="function"&&(e=e(H({},n),this.props)),e&&H(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Te(this))},ue.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Te(this))},ue.prototype.render=ce,V=[],xe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Re=function(e,t){return e.__v.__b-t.__v.__b},de.__r=0,Fe=/(PointerCapture)$|Capture$/i,Ce=0,we=je(!1),ye=je(!0),De=0;var Lt=0;function m(e,t,n,o,i,s){t||(t={});var l,r,a=t;if("ref"in a)for(r in a={},t)r=="ref"?l=t[r]:a[r]=t[r];var c={type:e,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof e=="function"&&(l=e.defaultProps))for(r in l)a[r]===void 0&&(a[r]=l[r]);return M.vnode&&M.vnode(c),c}var J,A,ze,Xe,ne=0,Ye=[],R=M,Ke=R.__b,Je=R.__r,Ze=R.diffed,Qe=R.__c,et=R.unmount,tt=R.__;function fe(e,t){R.__h&&R.__h(A,e,ne||t),ne=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function G(e){return ne=1,Nt(it,e)}function Nt(e,t,n){var o=fe(J++,2);if(o.t=e,!o.__c&&(o.__=[it(void 0,t),function(r){var a=o.__N?o.__N[0]:o.__[0],c=o.t(a,r);a!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=A,!A.__f)){var i=function(r,a,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,a,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,a,c)||u};A.__f=!0;var s=A.shouldComponentUpdate,l=A.componentWillUpdate;A.componentWillUpdate=function(r,a,c){if(this.__e){var d=s;s=void 0,i(r,a,c),s=d}l&&l.call(this,r,a,c)},A.shouldComponentUpdate=i}return o.__N||o.__}function I(e,t){var n=fe(J++,3);!R.__s&&rt(n.__H,t)&&(n.__=e,n.u=t,A.__H.__h.push(n))}function F(e){return ne=5,Z(function(){return{current:e}},[])}function Z(e,t){var n=fe(J++,7);return rt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function nt(e,t){return ne=8,Z(function(){return e},t)}function Mt(e){var t=A.context[e.__c],n=fe(J++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(A)),t.props.value):e.__}function At(){for(var e;e=Ye.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(me),e.__H.__h.forEach(Ee),e.__H.__h=[]}catch(t){e.__H.__h=[],R.__e(t,e.__v)}}R.__b=function(e){A=null,Ke&&Ke(e)},R.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tt&&tt(e,t)},R.__r=function(e){Je&&Je(e),J=0;var t=(A=e.__c).__H;t&&(ze===A?(t.__h=[],A.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(me),t.__h.forEach(Ee),t.__h=[],J=0)),ze=A},R.diffed=function(e){Ze&&Ze(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ye.push(t)!==1&&Xe===R.requestAnimationFrame||((Xe=R.requestAnimationFrame)||Pt)(At)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ze=A=null},R.__c=function(e,t){t.some(function(n){try{n.__h.forEach(me),n.__h=n.__h.filter(function(o){return!o.__||Ee(o)})}catch(o){t.some(function(i){i.__h&&(i.__h=[])}),t=[],R.__e(o,n.__v)}}),Qe&&Qe(e,t)},R.unmount=function(e){et&&et(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{me(o)}catch(i){t=i}}),n.__H=void 0,t&&R.__e(t,n.__v))};var ot=typeof requestAnimationFrame=="function";function Pt(e){var t,n=function(){clearTimeout(o),ot&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);ot&&(t=requestAnimationFrame(n))}function me(e){var t=A,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),A=t}function Ee(e){var t=A;e.__c=e.__(),A=t}function rt(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function it(e,t){return typeof t=="function"?t(e):t}const It=e=>({saveGameData(t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const t=localStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return console.error("Failed to load maze game data:",t),null}},resetGameData(){try{localStorage.removeItem(e)}catch(t){console.error("Failed to reset maze game data:",t)}}}),st=Et(void 0),lt={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},Le={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:e,config:t})=>{const n=It(t.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=G(()=>o||{...lt});I(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),I(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[l,r]=G({...Le}),a=F(l);I(()=>{a.current=l},[l]);const c=Z(()=>[l.playerAtExit?1:0,l.foodCollected===l.totalFoodCount?1:0,l.showClue?0:1],[l.playerAtExit,l.foodCollected,l.totalFoodCount,l.showClue]),d=()=>{n.resetGameData(),s({...lt}),r({...Le})};return m(st.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:l,setGamePlayState:r,gamePlayStateRef:a,currentScore:c,config:t,resetGame:d},children:e})},oe=()=>{const e=Mt(st);if(!e)throw new Error("useGameContext must be used within a GameProvider");return e},re=e=>Z(()=>{const t=e.map(r=>r.length),n=t.reduce((r,a)=>r+a,0),o=e.length,i=r=>{if(r<1||r>n)return 0;let a=0;for(let c=0;c<t.length;c++)if(a+=t[c],r<=a)return c+1;return 0},s=r=>r<1||r>o?0:t.slice(0,r-1).reduce((a,c)=>a+c,0)+1,l={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const a=s(r),c=a+t[r-1]-1;return[a,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const a=i(r),c=s(a),d=r-c;return e[a-1][d]},getTierConfig:r=>r<1||r>o?null:e[r-1],isLevelUnlocked:(r,a)=>r<=a,isTierUnlocked:(r,a)=>r<=a,getNextLevelInfo:r=>{if(r>=n)return null;const a=r+1,c=i(r),d=i(a);return{nextLevel:a,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,a)=>{const[c,d]=l.getTierLevelsRange(a),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const a=i(r),[,c]=l.getTierLevelsRange(a);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const a=r-1,c=i(r),d=i(a);return{prevLevel:a,prevTier:d,isTierChange:d<c}}};return l},[e]),Rt=({onTierChange:e,disabled:t})=>{const{gameProgress:n,config:o}=oe(),{i18n:i,levelConfig:s}=o,{currentTier:l,highestUnlockedTier:r}=n,c=re(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:l,onChange:d=>{d.target&&d.target.value&&e(Number(d.target.value))},disabled:t,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:e,disabled:t})=>{const{gameProgress:n,config:o}=oe(),{i18n:i,levelConfig:s}=o,{currentTier:l,levelScores:r,currentLevel:a,highestUnlockedLevel:c}=n,d=re(s),u=Z(()=>{const[h,f]=d.getTierLevelsRange(l);return Array.from({length:f-h+1},(p,v)=>{const _=h+v,b=r[_]||0;return{level:_,score:b}})},[l,r]);return m("div",{className:"level-selector",children:m("select",{value:a,onChange:h=>{h.target&&h.target.value&&e(Number(h.target.value))},disabled:t,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},ie=({isOpen:e,title:t,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:l=!1,confirmText:r="OK",cancelText:a="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=F(null);return I(()=>{const p=v=>{v.key==="Escape"&&h?.()};return e&&document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}},[e,h]),m("div",{className:`maze-dialog-overlay ${e?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:t}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!l||!s)&&m("div",{className:"maze-dialog-buttons",children:[!l&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:a}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},W={container:null,attachTo(e){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",e.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(e,t=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=e,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},t)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:e,setGameProgress:t,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:l}=oe(),{i18n:r,levelConfig:a}=l,c=re(a),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=e,p=c.getTotalLevels(),[v,_]=G(!1),[b,C]=G(!1),[T,g]=G(!1),k=O=>{const $=c.getFirstLevelOfTier(O);c.isLevelUnlocked($,h)&&(t(q=>({...q,currentTier:O})),w($))},w=O=>{c.isLevelUnlocked(O,h)&&(t($=>({...$,currentLevel:O})),W.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},y=()=>{_(!0)},S=()=>{_(!1)},N=()=>{g(!0)},z=()=>{g(!1)},E=()=>{W.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),g(!1)},L=()=>{C(!0)},P=()=>{s(),C(!1),W.show(r.resetDoneToast)},x=()=>{C(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:k,disabled:d}),m(Ft,{onLevelChange:w,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:N,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:y,children:"★ "+f})}),m(ie,{isOpen:v,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:S,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${p}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:L,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(ie,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:P,onCancel:x}),m(ie,{isOpen:T,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:E,onCancel:z})]})};function Ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ot(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function Me(e,t,n){return t&&Ot(e.prototype,t),e}function at(e){return+e.replace(/px/,"")}function $t(e){var t=window.devicePixelRatio,n=getComputedStyle(e),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));e.setAttribute("width",(o*t).toString()),e.setAttribute("height",(i*t).toString())}function j(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(t-e)+e;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function ct(e){return e[j(0,e.length)]}var Ut=.00125,Gt=5e-4,Wt=9e-4,jt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ut(e){var t=1920;return Math.log(e)/Math.log(t)}var dt=function(){function e(t){Ne(this,e);var n=t.initialPosition,o=t.direction,i=t.confettiRadius,s=t.confettiColors,l=t.emojis,r=t.emojiSize,a=t.canvasWidth,c=j(Bt,Vt,3),d=c*ut(a);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=j(Xt,Yt,3),this.rotationSpeed=l.length?.01:j(Kt,Jt,3)*ut(a),this.dragForceCoefficient=j(Gt,Wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?j(0,.2,3):j(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=j(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?j(Qt,Zt)*Math.PI/180:j(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=j(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=l.length?null:ct(s),this.emoji=l.length?ct(l):null,this.createdAt=new Date().getTime(),this.direction=o}return Me(e,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,l=this.emoji,r=this.rotationAngle,a=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):l&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(a),n.textAlign="center",n.fillText(l,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,l=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,a=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>l&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:jt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*a,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*a,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),e}();function rn(){var e=document.createElement("canvas");return e.style.position="fixed",e.style.width="100%",e.style.height="100%",e.style.top="0",e.style.left="0",e.style.zIndex="1000",e.style.pointerEvents="none",document.body.appendChild(e),e}function sn(e){var t=e.confettiRadius,n=t===void 0?qt:t,o=e.confettiNumber,i=o===void 0?e.confettiesNumber||(e.emojis?nn:tn):o,s=e.confettiColors,l=s===void 0?on:s,r=e.emojis,a=r===void 0?e.emojies||[]:r,c=e.emojiSize,d=c===void 0?Ht:c;return e.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),e.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:l,emojis:a,emojiSize:d}}var ln=function(){function e(t){var n=this;Ne(this,e),this.canvasContext=t,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Me(e,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,l=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(a){return a.updatePosition(l,r),a.draw(s.canvasContext),i?a.getIsVisibleOnCanvas(o):!0})}}]),e}(),an=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ne(this,e),this.activeConfettiBatches=[],this.canvas=t.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Me(e,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(l){return l.processShapes({timeDelta:o,currentTime:n},i,s),s?!l.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,l=o.confettiColors,r=o.emojis,a=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},p={x:d,y:h},v=new ln(this.canvasContext),_=0;_<s/2;_++){var b=new dt({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:l,confettiNumber:s,emojis:r,emojiSize:a,canvasWidth:d}),C=new dt({initialPosition:p,direction:"left",confettiRadius:i,confettiColors:l,confettiNumber:s,emojis:r,emojiSize:a,canvasWidth:d});v.addShapes(b,C)}return this.activeConfettiBatches.push(v),this.queueAnimationFrameIfNeeded(),v.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),e}();const cn=new an,Ae=3,un=({onRetry:e})=>{const{config:t,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:l}=oe(),{i18n:r,levelConfig:a}=t,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:p,levelTransitioning:v}=o,{currentLevel:_}=s,[b,C]=G(!1);I(()=>{p&&v&&(cn.addConfetti(),W.show(r.levelCompleteToast),C(!0))},[p,v]);const T=re(a),g=T.getTotalLevels(),k=Z(()=>_>=g,[_,g]),w=()=>{C(!1),W.show(r.levelRestartToast),e?.()},y=()=>{C(!1),i(z=>({...z,isGameActive:!0,levelTransitioning:!1}))},S=()=>{C(!1);const z=T.getNextLevelInfo(_);if(!z)return;const{nextLevel:E,nextTier:L,isTierChange:P}=z;P&&W.show(r.tierUnlockedToast.replace("%TIER%",L.toString())),l(x=>({...x,currentLevel:E,currentTier:L,highestUnlockedLevel:Math.max(x.highestUnlockedLevel,E),highestUnlockedTier:Math.max(x.highestUnlockedTier,L),levelScores:{...x.levelScores,[x.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,x.levelScores[x.currentLevel]||0)}}))},N=()=>{C(!1),l(z=>{const E=Math.max(Object.values(n).filter(Boolean).length,z.levelScores[z.currentLevel]||0),L={...z.levelScores,[z.currentLevel]:E};let P=0,x=0;const O=Object.entries(L).sort(($,q)=>Number($[0])-Number(q[0]));for(const[$,q]of O)if(q<Ae){P=Number($),x=T.getTierByLevel(P);break}return(P>0&&P!==_||E<Ae)&&W.show(r.notCompleteLevel),(P===0||E<Ae)&&e?.(),{...z,currentLevel:P||z.currentLevel,currentTier:x||z.currentTier,levelScores:L}})};return I(()=>{const z=document.querySelector(".maze-game-container"),E=L=>{b&&((L.key===" "||L.code==="Space")&&z&&(z.contains(document.activeElement)||document.activeElement===document.body)&&(L.preventDefault(),k?N():S()),(L.key==="r"||L.code==="KeyR")&&w(),(L.key==="c"||L.code==="KeyC")&&y())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[b,k]),m(ie,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:w,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:y,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),k&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:k?m("button",{className:"maze-go-next-btn",type:"button",onClick:N,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:S,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},ht=(e,t)=>{const n=F({canvasWidth:0,canvasHeight:0});return I(()=>{const o=()=>{const s=e.current;if(!s)return;const l=s.parentElement;if(!l)return;const r=l.clientWidth,a=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*a,d=r*a;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},t?.()};o();let i=null;return window.ResizeObserver&&e.current&&(i=new ResizeObserver(o),i.observe(e.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[e,t]),n},ft=(e,t,n)=>{const o=F({cellWidth:0,cellHeight:0});return I(()=>{const i=()=>{const l=e.current,r=t.maze;if(!l||!r)return;const{rows:a,cols:c}=r;if(a<=0||c<=0)return;const d=(l.width-n*2)/c,u=(l.height-n*2)/a;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return e.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(e.current)),()=>{e.current&&s?.disconnect()}},[e,t.maze,n]),o},_e={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},mt=({gamePlayStateRef:e,setGamePlayState:t,moveSpeed:n,moveSpeedRef:o,playerRadius:i,onFoodCollected:s,onExitReached:l,onFirstMove:r})=>{const a=()=>o?.current??n??.03,c=F(!1),d=F(new Set),u=F(!1),h=nt((T,g)=>{const k=e.current;if(!k.maze)return{canMove:!1,newCell:null};const w=a(),[y,S]=_e[T];if(_t(g,y,S,i,w,k.maze))return{canMove:!1,newCell:null};const{row:z,col:E}=g,L=z+y*w,P=E+S*w,x=-.5,O=k.maze.rows,$=k.maze.cols;if(L<x||L>=O||P<x||P>=$)return{canMove:!1,newCell:null};const q=z<0?0:Math.floor(z),Q=E<0?0:Math.floor(E),D=L<0?0:Math.floor(L),U=P<0?0:Math.floor(P);return D!==q||U!==Q?k.maze.isValid(D,U)?{canMove:!0,newCell:{row:D,col:U}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[i,a]),f=()=>{const T=e.current,{row:g,col:k}=T.playerCell,w=i*2,y=T.foodCells.findIndex(z=>Math.sqrt(Math.pow(g-z.row,2)+Math.pow(k-z.col,2))<w);y!==-1&&s&&(s(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((z,E)=>E!==y)});const N=fn(T.playerCell,T.exitCell,T.maze);N&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},l&&l(),requestIdleCallback(()=>{t(()=>({...e.current}))},{timeout:10})):!N&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=T=>{const g=e.current,k=Math.round(T.row),w=Math.round(T.col),y=g.playerPath[g.playerPath.length-1],S=y.row===k&&y.col===w,N=Math.abs(y.row-k),z=Math.abs(y.col-w);if((N===1&&z===0||N===0&&z===1)&&!S){const L=`${y.row},${y.col}-${k},${w}`;e.current={...e.current,playerPath:[...e.current.playerPath,{row:k,col:w}],visitCounts:{...e.current.visitCounts,[L]:(e.current.visitCounts[L]||0)+1}}}},v=()=>{if(c.current||d.current.size===0)return;const T=e.current;!T.playerCell||!Array.from(d.current).some(k=>{const{canMove:w}=h(k,T.playerCell);return w})||(!u.current&&r&&(u.current=!0,r()),c.current=!0)};I(()=>{const T=w=>{if(w.key==="ArrowUp"||w.key==="ArrowDown"||w.key==="ArrowLeft"||w.key==="ArrowRight"||w.key===" "){const y=document.activeElement;if(y&&(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.getAttribute("contenteditable")==="true"))return;w.preventDefault()}},g=w=>{const y=w.key;if(!(y in _e))return;const S=document.activeElement;S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.getAttribute("contenteditable")==="true")||(w.preventDefault(),e.current.isGameActive&&(d.current.has(y)||(d.current.add(y),c.current||v())))},k=w=>{const y=w.key;if(!(y in _e))return;const S=document.activeElement;S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.getAttribute("contenteditable")==="true")||(w.preventDefault(),d.current.delete(y),d.current.size===0&&b())};return window.addEventListener("keydown",T,{capture:!0}),window.addEventListener("keydown",g),window.addEventListener("keyup",k),()=>{window.removeEventListener("keydown",T,{capture:!0}),window.removeEventListener("keydown",g),window.removeEventListener("keyup",k)}},[]);const _=nt(()=>{if(!c.current||d.current.size===0)return e.current.playerCell;const T=a(),g=e.current.playerCell;let k=0,w=0,y=0;for(const B of d.current){const{canMove:ee}=h(B,g);if(ee){const[X,Y]=_e[B];k+=X,w+=Y,y++}}if(y===0)return e.current.playerCell;const S=Math.sqrt(k*k+w*w),N=S>0?k/S:0,z=S>0?w/S:0,E=Number((g.row+N*T).toFixed(2)),L=Number((g.col+z*T).toFixed(2)),P=E-g.row,x=L-g.col,O=Math.sqrt(P*P+x*x);if(O>0){const B=P/O,ee=x/O;if(_t(g,B,ee,i,O,e.current.maze))return e.current.playerCell}e.current.playerCell={row:E,col:L},f();const $=g.row<0?0:Math.round(g.row),q=g.col<0?0:Math.round(g.col),Q=E<0?0:Math.round(E),D=L<0?0:Math.round(L);return(Q!==$||D!==q)&&p({row:Q,col:D}),e.current.playerCell},[a,h]),b=()=>{c.current=!1,d.current.clear()};return{updatePlayerPos:_,resetMovingState:b,resetFirstMoveState:()=>{u.current=!1}}};function _t(e,t,n,o,i,s){const l=e.row+t*i,r=e.col+n*i,a={row:l,col:r},c=[],d=e.row<0?0:Math.floor(e.row),u=e.col<0?0:Math.floor(e.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,p]of h){const v=d+f,_=u+p;s.isValid(v,_)&&c.push({row:v,col:_})}for(const f of c){const p=dn(f.row,f.col,s);for(const v of p)if(hn(a,v)<o)return!0}return!1}function dn(e,t,n){const o=[],i=n.grid[e][t];return i.walls.top&&o.push({start:{row:e-.5,col:t-.5},end:{row:e-.5,col:t+.5}}),i.walls.right&&o.push({start:{row:e-.5,col:t+.5},end:{row:e+.5,col:t+.5}}),i.walls.bottom&&o.push({start:{row:e+.5,col:t-.5},end:{row:e+.5,col:t+.5}}),i.walls.left&&o.push({start:{row:e-.5,col:t-.5},end:{row:e+.5,col:t-.5}}),o}function hn(e,t){const{start:n,end:o}=t,i=o.col-n.col,s=o.row-n.row,l=e.col-n.col,r=e.row-n.row,a=i*i+s*s;if(a===0)return Math.sqrt(l*l+r*r);const c=Math.max(0,Math.min(1,(l*i+r*s)/a)),d=n.col+c*i,u=n.row+c*s,h=e.col-d,f=e.row-u;return Math.sqrt(h*h+f*f)}function fn(e,t,n){if(!n.isValid(t.row,t.col))return!1;const o=e.col>=t.col-.5&&e.col<=t.col+.5,i=e.row>=t.row+.5,s=e.row>=t.row-.5;return o&&i&&s}function vt(e,t,n,o,i){if(!e||!t.maze)return;const{canvasWidth:s,canvasHeight:l}=n,{cellWidth:r,cellHeight:a}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:p,visitCounts:v}=t,{padding:_,wallWidth:b,wallColor:C,playerColor:T,playerRadius:g,foodColor:k,backgroundColor:w,clueColor:y,exitColor:S,exitWallWidth:N,exitDashArray:z}=i;e.clearRect(0,0,s,l),e.save(),e.fillStyle=w,e.fillRect(0,0,s,l),e.restore(),f&&Cn({ctx:e,playerPath:p,visitCounts:v,cellWidth:r,cellHeight:a,padding:_,clueColor:y}),mn({ctx:e,maze:c,cellWidth:r,cellHeight:a,padding:_,wallColor:C,wallWidth:b}),vn({ctx:e,maze:c,exitCell:u,cellWidth:r,cellHeight:a,padding:_,exitColor:S,exitWallWidth:N,exitDashArray:z}),gn({ctx:e,foodCells:h,cellWidth:r,cellHeight:a,padding:_,foodColor:k}),_n({ctx:e,playerCell:d,playerRadius:g,cellWidth:r,cellHeight:a,padding:_,playerColor:T})}function mn({ctx:e,maze:t,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:l}){e.save(),e.strokeStyle=s,e.lineWidth=l,e.lineCap="round",e.beginPath(),wn(t,n,o,i).forEach(a=>{e.moveTo(a.x1,a.y1),e.lineTo(a.x2,a.y2)}),e.stroke(),e.restore()}function _n({ctx:e,playerCell:t,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:l}){const{x:r,y:a}=ve(t.row,t.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);e.save(),e.fillStyle=l,e.beginPath(),e.arc(r,a,c,0,Math.PI*2),e.fill(),e.restore()}function vn({ctx:e,maze:t,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:l,exitWallWidth:r,exitDashArray:a=[8,12]}){const{row:c,col:d}=n;if(!t.isValid(c,d))return;const u=s+d*o,h=s+c*i;e.save(),e.globalCompositeOperation="destination-out",e.lineWidth=r,e.lineCap="round",e.beginPath(),e.moveTo(u,h+i),e.lineTo(u+o,h+i),e.stroke(),e.globalCompositeOperation="source-over",e.strokeStyle=l,e.lineWidth=r,e.setLineDash(a),e.beginPath(),e.moveTo(u,h+i),e.lineTo(u+o,h+i),e.stroke(),e.restore()}function gn({ctx:e,foodCells:t,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){e.fillStyle=s;const l=Math.min(n,o)*.25;t.forEach(r=>{const{x:a,y:c}=ve(r.row,r.col,n,o,i);pn(e,a,c,l*1.2,5,l*.6)})}function pn(e,t,n,o,i,s){e.save(),e.beginPath();for(let l=0;l<i*2;l++){const r=l%2===0?o:s,a=Math.PI*l/i;e.lineTo(t+r*Math.sin(a),n+r*Math.cos(a))}e.closePath(),e.fill(),e.restore()}function Cn({ctx:e,playerPath:t,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:l}){if(!(!t||t.length<2||!n)){e.save();for(let r=1;r<t.length;r++){const a=t[r-1],c=t[r],d=`${a.row},${a.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${a.row},${a.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),p=Math.max(3,o*.1)+h*.5;try{e.strokeStyle=l.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{e.strokeStyle=`rgba(255, 0, 0, ${f})`}e.lineWidth=p,e.lineCap="round",e.lineJoin="round";const{x:v,y:_}=ve(a.row,a.col,o,i,s),{x:b,y:C}=ve(c.row,c.col,o,i,s);e.beginPath(),e.moveTo(v,_),e.lineTo(b,C),e.stroke()}e.restore()}}function wn(e,t,n,o){const i=[];for(let s=0;s<e.rows;s++)for(let l=0;l<e.cols;l++){const r=e.grid[s][l],a=o+l*t,c=o+s*n;r.walls.top&&i.push({x1:a,y1:c,x2:a+t,y2:c}),r.walls.right&&i.push({x1:a+t,y1:c,x2:a+t,y2:c+n}),r.walls.bottom&&i.push({x1:a,y1:c+n,x2:a+t,y2:c+n}),r.walls.left&&i.push({x1:a,y1:c,x2:a,y2:c+n})}return i}function ve(e,t,n,o,i){return{x:i+t*n+n/2,y:i+e*o+o/2}}function yn(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}class bn{constructor(t,n){this.row=t,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class gt{rows;cols;grid;seed;random;constructor(t,n,o,i,s={row:0,col:0},l={row:t-1,col:n-1}){this.rows=t,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,l)}initializeGrid(){const t=[];for(let n=0;n<this.rows;n++){t[n]=[];for(let o=0;o<this.cols;o++)t[n][o]=new bn(n,o)}return t}isValid(t,n){return t>=0&&t<this.rows&&n>=0&&n<this.cols}getNeighbors(t,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const l=t+s.r,r=n+s.c;this.isValid(l,r)&&o.push({row:l,col:r})}return o}getUnvisitedNeighbors(t,n){return this.getNeighbors(t,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(t,n){return this.getNeighbors(t,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(t,n,o,i){const s=this.grid[t][n],l=this.grid[o][i];t===o+1?(s.walls.top=!1,l.walls.bottom=!1):t===o-1?(s.walls.bottom=!1,l.walls.top=!1):n===i+1?(s.walls.left=!1,l.walls.right=!1):n===i-1&&(s.walls.right=!1,l.walls.left=!1)}generate(t,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(t){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${t}`)}this.addOpenings(n,o)}generateWithBacktracking(){const t=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,t.push(i);t.length>0;){i=t[t.length-1];const{row:s,col:l}=i,r=this.getUnvisitedNeighbors(s,l);if(r.length>0){const a=this.randomPick(r),{row:c,col:d}=a;this.removeWall(s,l,c,d),this.grid[c][d].visited=!0,t.push(a)}else t.pop()}}generateWithPrims(){const t=[],n=(s,l)=>{const r=this.getNeighbors(s,l);for(const a of r)!this.grid[a.row][a.col].visited&&!t.some(c=>c.row===a.row&&c.col===a.col)&&t.push(a)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);t.length>0;){const s=this.randomNumber(t.length),l=t[s],{row:r,col:a}=l,c=this.getVisitedNeighbors(r,a);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,a,d.row,d.col),this.grid[r][a].visited=!0,n(r,a)}t.splice(s,1)}}addOpenings(t,n){this.grid[t.row][t.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(t){return Math.floor(this.random()*t)}randomPick(t){return t[Math.floor(this.random()*t.length)]}}const pt=(e,t,n)=>{if(!e.isValid(t,n))return!1;const o=e.grid[t][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=e=>e===1?2:e>=2&&e<=5?3:e>=6&&e<=11?4:e>=12&&e<=15?5:6,kn=(e,t)=>{if(!t)return console.error(`Cannot find Level ${e}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:l}=t,r=n,a=n,c=s||{row:0,col:0},d=l||{row:r-1,col:a-1},u=new gt(r,a,i,o,c,d),h=Tn(e),f=[];for(let p=0;p<h;p++){let v;do v={row:Math.floor(u.random()*r),col:Math.floor(u.random()*a)};while(v.row===c.row&&v.col===c.col||v.row===d.row&&v.col===d.col||!pt(u,v.row,v.col)||f.some(_=>_.row===v.row&&_.col===v.col));f.push(v)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:e,seed:t,method:n,foodCount:o,clue:i})=>{const s=e,l=e,r={row:0,col:0},a={row:s-1,col:l-1},c=new gt(s,l,n,t,r,a),d=[];for(let u=0;u<o;u++){let h,f=0;do h={row:Math.floor(c.random()*s),col:Math.floor(c.random()*l)},f++;while(f<50&&(h.row===r.row&&h.col===r.col||h.row===a.row&&h.col===a.col||!pt(c,h.row,h.col)||d.some(p=>p.row===h.row&&p.col===h.col)));f<50&&d.push(h)}return{isGameActive:!0,levelTransitioning:!1,maze:c,playerCell:r,exitCell:a,foodCells:d,playerAtExit:!1,foodCollected:0,totalFoodCount:o,showClue:i,playerPath:[r],visitCounts:{[`${r.row},${r.col}`]:1}}};function zn(){const{setGamePlayState:e,gamePlayState:t,gamePlayStateRef:n,gameProgress:o,config:i}=oe(),s=F(null),l=F(null),{i18n:r,levelConfig:a,renderConfig:c}=i,d=re(a),u=F(d.getLevelConfig(o.currentLevel));I(()=>{s.current&&W.attachTo(s.current)},[]);const h=F(),f=ht(l,()=>{h.current?.()}),p=ft(l,t,c.padding);I(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const v=()=>{const T=kn(o.currentLevel,u.current);T&&e(g=>({...g,...T}))};I(()=>{v()},[o.currentLevel]);const _=()=>{v()},{updatePlayerPos:b,resetMovingState:C}=mt({gamePlayStateRef:n,setGamePlayState:e,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const T=n.current.totalFoodCount-n.current.foodCollected-1;T>0?W.show(r.foodCollectedToast.replace("%NUM%",T.toString()),3e3):W.show(r.allFoodCollectedToast)}});return I(()=>{C()},[o.currentLevel,C]),I(()=>{let T,g=!document.hidden;const k=()=>{const S=l.current?.getContext("2d"),N=n.current;if(!(g&&N?.isGameActive&&S&&N?.maze)){T=requestAnimationFrame(k);return}b(),w(),T=requestAnimationFrame(k)},w=()=>{const S=l.current?.getContext("2d"),N=n.current;if(S&&N?.maze){const z=u.current?.wallWidth||c?.wallWidth,E=u.current?.exitColor||c?.exitColor,L=u.current?.exitWallWidth||c?.exitWallWidth,P=u.current?.exitDashArray||c?.exitDashArray;vt(S,N,f.current,p.current,{...c,wallWidth:z,exitColor:E,exitWallWidth:L,exitDashArray:P})}};h.current=w;const y=S=>{const N=g;g=!document.hidden&&document.visibilityState==="visible"&&(!S||S.type!=="blur"),!N&&g?n.current?.levelTransitioning===!1&&e({...n.current,isGameActive:!0}):N&&!g&&e({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",y),window.addEventListener("blur",y),window.addEventListener("focus",y),T=requestAnimationFrame(k),()=>{cancelAnimationFrame(T),document.removeEventListener("visibilitychange",y),window.removeEventListener("blur",y),window.removeEventListener("focus",y)}},[]),I(()=>{W.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:m("canvas",{ref:l,className:"maze-game-canvas"})})]})}const En=e=>{const t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:e,onTimeUp:t})=>{const[n,o]=G(e),i=F(),s=F(!1),l=F(0);return I(()=>{const r=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(c=>(l.current=e-c+1,c<=1?(clearInterval(i.current),t(),0):c-1))},1e3))},a=()=>{clearInterval(i.current),i.current=void 0,window.dispatchEvent(new CustomEvent("maze:timeUsed",{detail:{timeUsed:l.current}}))};return window.addEventListener("maze:firstMove",r),window.addEventListener("maze:gameSuccess",a),()=>{window.removeEventListener("maze:firstMove",r),window.removeEventListener("maze:gameSuccess",a),clearInterval(i.current)}},[]),I(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(e),s.current=!1,l.current=0},[e]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:e}){const{size:t,seed:n,method:o,foodCount:i,clue:s,renderConfig:l,successCallback:r,failCallback:a,timer:c,i18n:d}=e,[u,h]=G({...Le}),[f,p]=G(!1),[v,_]=G(!1),[b,C]=G(!1),[T,g]=G(""),k=F(0),w=F(!1),y=F(null),S=F(null),N=F(u),z=F(),E=ht(y,()=>{z.current?.()}),L=ft(y,u,l.padding);I(()=>{N.current=u},[u]);const{updatePlayerPos:P,resetMovingState:x,resetFirstMoveState:O}=mt({gamePlayStateRef:N,setGamePlayState:h,playerRadius:l.playerRadius,moveSpeed:l.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{w.current=!0,v||q()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),$=()=>{_(!0),g(`⏰ ${d.failMsg}`),C(!0),h(D=>({...D,isGameActive:!1}))},q=()=>{_(!0),g(`🎉 ${d.successMsg}`),C(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess"))},Q=()=>{C(!1),h(D=>({...D,showClue:!0})),w.current?r?.(k.current):a?.()};return I(()=>{(async()=>{p(!0);try{const U=Sn({size:t,seed:n,method:o,foodCount:i,clue:s});N.current=U,h(U)}catch(U){console.error("Error generating single maze:",U)}finally{p(!1)}})()},[e]),I(()=>{let D;const U=!document.hidden,B=()=>{const X=y.current?.getContext("2d"),Y=N.current;if(!(U&&Y?.isGameActive&&X&&Y?.maze)){D=requestAnimationFrame(B);return}P(),ee(),D=requestAnimationFrame(B)},ee=()=>{const X=y.current?.getContext("2d"),Y=N.current;X&&Y?.maze&&vt(X,Y,E.current,L.current,l)};return z.current=ee,D=requestAnimationFrame(B),()=>{cancelAnimationFrame(D)}},[]),I(()=>{x(),O()},[e,x,O]),I(()=>{const D=U=>{k.current=U.detail.timeUsed};return window.addEventListener("maze:timeUsed",D),()=>{window.removeEventListener("maze:timeUsed",D)}},[]),f?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):u?m("div",{className:"maze-game-container",children:[m(Ln,{timer:c,onTimeUp:$}),m("div",{className:"single-maze-canvas-container",ref:S,children:m("canvas",{ref:y,className:"maze-game-canvas"})}),m(ie,{isOpen:b,title:T,noConfirm:!0,cancelText:"OK",onCancel:Q})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const Ct=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],wt={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},ge={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:wt,levelConfig:Ct},pe={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",clue:!1,foodCount:3,renderConfig:wt,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:e={}}){const t={...ge.i18n,...e.i18n||{}},n={...ge.renderConfig,...e.renderConfig||{}},o=e.levelConfig||Ct,i={...ge,...e,i18n:t,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:e={}}){const t={...pe.i18n,...e.i18n||{}},n={...pe.renderConfig,...e.renderConfig||{}},o={...pe,...e,i18n:t,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.3/dist/",...ge};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.3/dist/",...pe};return`${JSON.stringify(In,(e,t)=>typeof t=="function"?t.toString():t,2)}`,{showNotice(){console.warn("Cannot find the root element");const e=document.createElement("div");e.style.textAlign="center",e.style.padding="20px",e.innerHTML="Cannot find the root element",document.body.append(e)},addLoadingIndicator(e){const t=document.createElement("div"),n=document.createElement("div");t.style.cssText=`
|
|
2
2
|
height: 30px;
|
|
3
3
|
width: 100%;
|
|
4
4
|
border: solid 2px #999;
|
|
@@ -9,8 +9,8 @@ var Maze=function(){"use strict";var re,A,Ae,B,Pe,Ie,xe,Re,ge,pe,Ce,Fe,Q={},De=[
|
|
|
9
9
|
background: #999;
|
|
10
10
|
animation: loading 1.5s ease-in-out;
|
|
11
11
|
transition: width 1.5s ease-in-out;
|
|
12
|
-
`,
|
|
12
|
+
`,t.append(n),e.append(t);const o=document.createElement("style");o.innerHTML=`
|
|
13
13
|
@keyframes loading {
|
|
14
14
|
0% { width: 0%; }
|
|
15
15
|
100% { width: 99%; }
|
|
16
|
-
}`,document.head.appendChild(o)},async loadCSS(
|
|
16
|
+
}`,document.head.appendChild(o)},async loadCSS(e){const t=document.createElement("link");return t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap",document.head.appendChild(t),new Promise((n,o)=>{const i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.href=e,i.onload=n,i.onerror=o,document.head.appendChild(i)})},async init(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){this.showNotice();return}let{root:o=location.origin}=t;o.at(-1)!=="/"&&(o+="/"),this.addLoadingIndicator(n),await this.loadCSS(o+"maze.css"),n.innerHTML="",Ve(m(Mn,{config:t}),n)},async initSingle(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){this.showNotice();return}let{root:o=location.origin}=t;o.at(-1)!=="/"&&(o+="/"),this.addLoadingIndicator(n),await this.loadCSS(o+"maze.css"),n.innerHTML="",Ve(m(An,{config:t}),n)}}}();
|