@roudanio/maze 0.0.1
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/icon.png +0 -0
- package/dist/maze.css +1 -0
- package/dist/maze.iife.js +17 -0
- package/dist/maze.js +1573 -0
- package/dist/maze.umd.js +17 -0
- package/dist/settings.svg +1 -0
- package/package.json +20 -0
package/dist/icon.png
ADDED
|
Binary file
|
package/dist/maze.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.maze-game-container{position:relative;box-sizing:border-box}.maze-game-container .maze-game-canvas{width:100%;height:100%;aspect-ratio:1 / 1;background-color:#fff;transition:opacity .1s ease}.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 .maze-canvas-container{position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.maze-game-container .maze-touch-area{position:absolute;width:100%;height:100%;opacity:0}.maze-game-container .maze-up{clip-path:polygon(10% 0,90% 0,50% 40%);top:0}.maze-game-container .maze-down{clip-path:polygon(10% 100%,90% 100%,50% 60%);bottom:0}.maze-game-container .maze-left{clip-path:polygon(0 10%,40% 50%,0 90%);top:0;left:0}.maze-game-container .maze-right{clip-path:polygon(100% 10%,60% 50%,100% 90%);top:0;right:0}.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:10px;left:0;right:0}.maze-game-container .toast-message{font-size:16px;font-weight:700;text-align:center;background-color:#f5f5f5;padding:8px 12px;border-radius:8px;box-shadow:0 2px 4px #0003;width:fit-content;max-width:90%;transition:opacity .3s ease,transform .3s ease;opacity:0;transform:translateY(-10px);pointer-events:none}.maze-game-container .toast-message.toast-visible{opacity:1;transform:translateY(0)}.maze-game-container .toast-message.type-success{background-color:#e8f5e9;color:#4caf50}.maze-game-container .toast-message.type-info{background-color:#e3f2fd;color:#2196f3}.maze-game-container .toast-message.type-warning{background-color:#fff8e1;color:#ff9800}.maze-game-container .toast-message.type-error{background-color:#ffebee;color:#f44336}.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 :is(.tier-dropdown,.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}.maze-game-container .score-container{display:flex;flex-direction:row;gap:6px}.maze-game-container .game-settings{display:flex;align-items:center;justify-content:center}.maze-game-container .game-settings .game-settings-icon{width:32px;height:32px;cursor:pointer}.maze-game-container .maze-dialog-content{margin-bottom:15px}.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 :is(.settings-reset-button,.settings-clue-button){background-color:#aaa;color:#fff;cursor:pointer;transition:all .2s;border:none;outline:none;box-shadow:0 1px 3px #0003}.maze-game-container :is(.settings-reset-button,.settings-clue-button):hover{background-color:#d32f2f;box-shadow:0 2px 5px #0000004d}.maze-game-container :is(.settings-reset-button,.settings-clue-button):active{transform:scale(.95)}.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 .score-box{display:flex;flex-direction:row;align-items:center;gap:8px;padding:4px 10px;border-radius:16px}.maze-game-container .score-box.totalscore{background-color:#f3e5f5}.maze-game-container .score-box.currentscore{background-color:#e8f5e9}.maze-game-container .score-box.bestscore{background-color:#fff3e0}.maze-game-container .score-label{font-weight:700;color:#333;font-size:13px}.maze-game-container .score-data{font-weight:700;font-size:16px}.maze-game-container .totalscore .score-data{color:#9c27b0}.maze-game-container .currentscore .score-data{color:#4caf50}.maze-game-container .bestscore .score-data{color:#ff9800}.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;margin-bottom:20px;color:#666;line-height:1.5}.maze-game-container .maze-dialog-buttons{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}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var Maze=function(){"use strict";var V,w,fe,U,me,ve,Z,pe,ee,te,oe,ge,R={},we=[],Ye=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ne=Array.isArray;function $(t,e){for(var o in e)t[o]=e[o];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Xe(t,e,o){var n,r,i,s={};for(i in e)i=="key"?n=e[i]:i=="ref"?r=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?V.call(arguments,2):o),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return B(t,s,n,r,null)}function B(t,e,o,n,r){var i={type:t,props:e,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++fe,__i:-1,__u:0};return r==null&&w.vnode!=null&&w.vnode(i),i}function q(t){return t.children}function K(t,e){this.props=t,this.context=e}function D(t,e){if(e==null)return t.__?D(t.__,t.__i+1):null;for(var o;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null)return o.__e;return typeof t.type=="function"?D(t):null}function Ce(t){var e,o;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null){t.__e=t.__c.base=o.__e;break}return Ce(t)}}function ie(t){(!t.__d&&(t.__d=!0)&&U.push(t)&&!Y.__r++||me!==w.debounceRendering)&&((me=w.debounceRendering)||ve)(Y)}function Y(){var t,e,o,n,r,i,s,c;for(U.sort(Z);t=U.shift();)t.__d&&(e=U.length,n=void 0,i=(r=(o=t).__v).__e,s=[],c=[],o.__P&&((n=$({},r)).__v=r.__v+1,w.vnode&&w.vnode(n),se(o.__P,n,r,o.__n,o.__P.namespaceURI,32&r.__u?[i]:null,s,i??D(r),!!(32&r.__u),c),n.__v=r.__v,n.__.__k[n.__i]=n,Te(s,n,c),n.__e!=i&&Ce(n)),U.length>e&&U.sort(Z));Y.__r=0}function ye(t,e,o,n,r,i,s,c,a,d,_){var l,h,u,m,C,g,p=n&&n.__k||we,v=e.length;for(a=je(o,e,p,a,v),l=0;l<v;l++)(u=o.__k[l])!=null&&(h=u.__i===-1?R:p[u.__i]||R,u.__i=l,g=se(t,u,h,r,i,s,c,a,d,_),m=u.__e,u.ref&&h.ref!=u.ref&&(h.ref&&le(h.ref,null,u),_.push(u.ref,u.__c||m,u)),C==null&&m!=null&&(C=m),4&u.__u||h.__k===u.__k?a=ke(u,a,t):typeof u.type=="function"&&g!==void 0?a=g:m&&(a=m.nextSibling),u.__u&=-7);return o.__e=C,a}function je(t,e,o,n,r){var i,s,c,a,d,_=o.length,l=_,h=0;for(t.__k=new Array(r),i=0;i<r;i++)(s=e[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(a=i+h,(s=t.__k[i]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?B(null,s,null,null,null):ne(s)?B(q,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?B(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,c=null,(d=s.__i=Je(s,o,a,l))!==-1&&(l--,(c=o[d])&&(c.__u|=2)),c==null||c.__v===null?(d==-1&&h--,typeof s.type!="function"&&(s.__u|=4)):d!=a&&(d==a-1?h--:d==a+1?h++:(d>a?h--:h++,s.__u|=4))):t.__k[i]=null;if(l)for(i=0;i<_;i++)(c=o[i])!=null&&!(2&c.__u)&&(c.__e==n&&(n=D(c)),Pe(c,c));return n}function ke(t,e,o){var n,r;if(typeof t.type=="function"){for(n=t.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=t,e=ke(n[r],e,o));return e}t.__e!=e&&(e&&t.type&&!o.contains(e)&&(e=D(t)),o.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Je(t,e,o,n){var r,i,s=t.key,c=t.type,a=e[o];if(a===null||a&&s==a.key&&c===a.type&&!(2&a.__u))return o;if(n>(a!=null&&!(2&a.__u)?1:0))for(r=o-1,i=o+1;r>=0||i<e.length;){if(r>=0){if((a=e[r])&&!(2&a.__u)&&s==a.key&&c===a.type)return r;r--}if(i<e.length){if((a=e[i])&&!(2&a.__u)&&s==a.key&&c===a.type)return i;i++}}return-1}function be(t,e,o){e[0]=="-"?t.setProperty(e,o??""):t[e]=o==null?"":typeof o!="number"||Ye.test(e)?o:o+"px"}function X(t,e,o,n,r){var i;e:if(e=="style")if(typeof o=="string")t.style.cssText=o;else{if(typeof n=="string"&&(t.style.cssText=n=""),n)for(e in n)o&&e in o||be(t.style,e,"");if(o)for(e in o)n&&o[e]===n[e]||be(t.style,e,o[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(pe,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=o,o?n?o.u=n.u:(o.u=ee,t.addEventListener(e,i?oe:te,i)):t.removeEventListener(e,i?oe:te,i);else{if(r=="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]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&o==1?"":o))}}function ze(t){return function(e){if(this.l){var o=this.l[e.type+t];if(e.t==null)e.t=ee++;else if(e.t<o.u)return;return o(w.event?w.event(e):e)}}}function se(t,e,o,n,r,i,s,c,a,d){var _,l,h,u,m,C,g,p,v,b,z,S,P,F,M,E,L,x=e.type;if(e.constructor!==void 0)return null;128&o.__u&&(a=!!(32&o.__u),i=[c=e.__e=o.__e]),(_=w.__b)&&_(e);e:if(typeof x=="function")try{if(p=e.props,v="prototype"in x&&x.prototype.render,b=(_=x.contextType)&&n[_.__c],z=_?b?b.props.value:_.__:n,o.__c?g=(l=e.__c=o.__c).__=l.__E:(v?e.__c=l=new x(p,z):(e.__c=l=new K(p,z),l.constructor=x,l.render=Ze),b&&b.sub(l),l.props=p,l.state||(l.state={}),l.context=z,l.__n=n,h=l.__d=!0,l.__h=[],l._sb=[]),v&&l.__s==null&&(l.__s=l.state),v&&x.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=$({},l.__s)),$(l.__s,x.getDerivedStateFromProps(p,l.__s))),u=l.props,m=l.state,l.__v=e,h)v&&x.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),v&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(v&&x.getDerivedStateFromProps==null&&p!==u&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(p,z),!l.__e&&(l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(p,l.__s,z)===!1||e.__v==o.__v)){for(e.__v!=o.__v&&(l.props=p,l.state=l.__s,l.__d=!1),e.__e=o.__e,e.__k=o.__k,e.__k.some(function(G){G&&(G.__=e)}),S=0;S<l._sb.length;S++)l.__h.push(l._sb[S]);l._sb=[],l.__h.length&&s.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(p,l.__s,z),v&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(u,m,C)})}if(l.context=z,l.props=p,l.__P=t,l.__e=!1,P=w.__r,F=0,v){for(l.state=l.__s,l.__d=!1,P&&P(e),_=l.render(l.props,l.state,l.context),M=0;M<l._sb.length;M++)l.__h.push(l._sb[M]);l._sb=[]}else do l.__d=!1,P&&P(e),_=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++F<25);l.state=l.__s,l.getChildContext!=null&&(n=$($({},n),l.getChildContext())),v&&!h&&l.getSnapshotBeforeUpdate!=null&&(C=l.getSnapshotBeforeUpdate(u,m)),c=ye(t,ne(E=_!=null&&_.type===q&&_.key==null?_.props.children:_)?E:[E],e,o,n,r,i,s,c,a,d),l.base=e.__e,e.__u&=-161,l.__h.length&&s.push(l),g&&(l.__E=l.__=null)}catch(G){if(e.__v=null,a||i!=null)if(G.then){for(e.__u|=a?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i[i.indexOf(c)]=null,e.__e=c}else for(L=i.length;L--;)re(i[L]);else e.__e=o.__e,e.__k=o.__k;w.__e(G,e,o)}else i==null&&e.__v==o.__v?(e.__k=o.__k,e.__e=o.__e):c=e.__e=Qe(o.__e,e,o,n,r,i,s,a,d);return(_=w.diffed)&&_(e),128&e.__u?void 0:c}function Te(t,e,o){for(var n=0;n<o.length;n++)le(o[n],o[++n],o[++n]);w.__c&&w.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){w.__e(i,r.__v)}})}function Qe(t,e,o,n,r,i,s,c,a){var d,_,l,h,u,m,C,g=o.props,p=e.props,v=e.type;if(v=="svg"?r="http://www.w3.org/2000/svg":v=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(d=0;d<i.length;d++)if((u=i[d])&&"setAttribute"in u==!!v&&(v?u.localName==v:u.nodeType==3)){t=u,i[d]=null;break}}if(t==null){if(v==null)return document.createTextNode(p);t=document.createElementNS(r,v,p.is&&p),c&&(w.__m&&w.__m(e,i),c=!1),i=null}if(v===null)g===p||c&&t.data===p||(t.data=p);else{if(i=i&&V.call(t.childNodes),g=o.props||R,!c&&i!=null)for(g={},d=0;d<t.attributes.length;d++)g[(u=t.attributes[d]).name]=u.value;for(d in g)if(u=g[d],d!="children"){if(d=="dangerouslySetInnerHTML")l=u;else if(!(d in p)){if(d=="value"&&"defaultValue"in p||d=="checked"&&"defaultChecked"in p)continue;X(t,d,null,u,r)}}for(d in p)u=p[d],d=="children"?h=u:d=="dangerouslySetInnerHTML"?_=u:d=="value"?m=u:d=="checked"?C=u:c&&typeof u!="function"||g[d]===u||X(t,d,u,g[d],r);if(_)c||l&&(_.__html===l.__html||_.__html===t.innerHTML)||(t.innerHTML=_.__html),e.__k=[];else if(l&&(t.innerHTML=""),ye(t,ne(h)?h:[h],e,o,n,v=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,s,i?i[0]:o.__k&&D(o,0),c,a),i!=null)for(d=i.length;d--;)re(i[d]);c||(d="value",v=="progress"&&m==null?t.removeAttribute("value"):m!==void 0&&(m!==t[d]||v=="progress"&&!m||v=="option"&&m!==g[d])&&X(t,d,m,g[d],r),d="checked",C!==void 0&&C!==t[d]&&X(t,d,C,g[d],r))}return t}function le(t,e,o){try{if(typeof t=="function"){var n=typeof t.__u=="function";n&&t.__u(),n&&e==null||(t.__u=t(e))}else t.current=e}catch(r){w.__e(r,o)}}function Pe(t,e,o){var n,r;if(w.unmount&&w.unmount(t),(n=t.ref)&&(n.current&&n.current!==t.__e||le(n,null,e)),(n=t.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(i){w.__e(i,e)}n.base=n.__P=null}if(n=t.__k)for(r=0;r<n.length;r++)n[r]&&Pe(n[r],e,o||typeof t.type!="function");o||re(t.__e),t.__c=t.__=t.__e=void 0}function Ze(t,e,o){return this.constructor(t,o)}function et(t,e,o){var n,r,i,s;e==document&&(e=document.documentElement),w.__&&w.__(t,e),r=(n=!1)?null:e.__k,i=[],s=[],se(e,t=e.__k=Xe(q,null,[t]),r||R,R,e.namespaceURI,r?null:e.firstChild?V.call(e.childNodes):null,i,r?r.__e:e.firstChild,n,s),Te(i,t,s)}function xe(t,e){var o={__c:e="__cC"+ge++,__:t,Consumer:function(n,r){return n.children(r)},Provider:function(n){var r,i;return this.getChildContext||(r=new Set,(i={})[e]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(s){this.props.value!==s.value&&r.forEach(function(c){c.__e=!0,ie(c)})},this.sub=function(s){r.add(s);var c=s.componentWillUnmount;s.componentWillUnmount=function(){r&&r.delete(s),c&&c.call(s)}}),n.children}};return o.Provider.__=o.Consumer.contextType=o}V=we.slice,w={__e:function(t,e,o,n){for(var r,i,s;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,n||{}),s=r.__d),s)return r.__E=r}catch(c){t=c}throw t}},fe=0,K.prototype.setState=function(t,e){var o;o=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=$({},this.state),typeof t=="function"&&(t=t($({},o),this.props)),t&&$(o,t),t!=null&&this.__v&&(e&&this._sb.push(e),ie(this))},K.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ie(this))},K.prototype.render=q,U=[],ve=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Z=function(t,e){return t.__v.__b-e.__v.__b},Y.__r=0,pe=/(PointerCapture)$|Capture$/i,ee=0,te=ze(!1),oe=ze(!0),ge=0;var tt=0;function f(t,e,o,n,r,i){e||(e={});var s,c,a=e;if("ref"in a)for(c in a={},e)c=="ref"?s=e[c]:a[c]=e[c];var d={type:t,props:a,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--tt,__i:-1,__u:0,__source:r,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(c in s)a[c]===void 0&&(a[c]=s[c]);return w.vnode&&w.vnode(d),d}var H,y,ce,Le,W=0,Ne=[],k=w,Se=k.__b,Me=k.__r,$e=k.diffed,Ae=k.__c,Ee=k.unmount,Ue=k.__;function j(t,e){k.__h&&k.__h(y,t,W||e),W=0;var o=y.__H||(y.__H={__:[],__h:[]});return t>=o.__.length&&o.__.push({}),o.__[t]}function A(t){return W=1,ot(We,t)}function ot(t,e,o){var n=j(H++,2);if(n.t=t,!n.__c&&(n.__=[We(void 0,e),function(c){var a=n.__N?n.__N[0]:n.__[0],d=n.t(a,c);a!==d&&(n.__N=[d,n.__[1]],n.__c.setState({}))}],n.__c=y,!y.u)){var r=function(c,a,d){if(!n.__c.__H)return!0;var _=n.__c.__H.__.filter(function(h){return!!h.__c});if(_.every(function(h){return!h.__N}))return!i||i.call(this,c,a,d);var l=n.__c.props!==c;return _.forEach(function(h){if(h.__N){var u=h.__[0];h.__=h.__N,h.__N=void 0,u!==h.__[0]&&(l=!0)}}),i&&i.call(this,c,a,d)||l};y.u=!0;var i=y.shouldComponentUpdate,s=y.componentWillUpdate;y.componentWillUpdate=function(c,a,d){if(this.__e){var _=i;i=void 0,r(c,a,d),i=_}s&&s.call(this,c,a,d)},y.shouldComponentUpdate=r}return n.__N||n.__}function N(t,e){var o=j(H++,3);!k.__s&&Re(o.__H,e)&&(o.__=t,o.i=e,y.__H.__h.push(o))}function I(t){return W=5,Fe(function(){return{current:t}},[])}function Fe(t,e){var o=j(H++,7);return Re(o.__H,e)&&(o.__=t(),o.__H=e,o.__h=t),o.__}function Ge(t,e){return W=8,Fe(function(){return t},e)}function De(t){var e=y.context[t.__c],o=j(H++,9);return o.c=t,e?(o.__==null&&(o.__=!0,e.sub(y)),e.props.value):t.__}function nt(){for(var t;t=Ne.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(J),t.__H.__h.forEach(ae),t.__H.__h=[]}catch(e){t.__H.__h=[],k.__e(e,t.__v)}}k.__b=function(t){y=null,Se&&Se(t)},k.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Ue&&Ue(t,e)},k.__r=function(t){Me&&Me(t),H=0;var e=(y=t.__c).__H;e&&(ce===y?(e.__h=[],y.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.i=o.__N=void 0})):(e.__h.forEach(J),e.__h.forEach(ae),e.__h=[],H=0)),ce=y},k.diffed=function(t){$e&&$e(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ne.push(e)!==1&&Le===k.requestAnimationFrame||((Le=k.requestAnimationFrame)||rt)(nt)),e.__H.__.forEach(function(o){o.i&&(o.__H=o.i),o.i=void 0})),ce=y=null},k.__c=function(t,e){e.some(function(o){try{o.__h.forEach(J),o.__h=o.__h.filter(function(n){return!n.__||ae(n)})}catch(n){e.some(function(r){r.__h&&(r.__h=[])}),e=[],k.__e(n,o.__v)}}),Ae&&Ae(t,e)},k.unmount=function(t){Ee&&Ee(t);var e,o=t.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{J(n)}catch(r){e=r}}),o.__H=void 0,e&&k.__e(e,o.__v))};var He=typeof requestAnimationFrame=="function";function rt(t){var e,o=function(){clearTimeout(n),He&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(o,100);He&&(e=requestAnimationFrame(o))}function J(t){var e=y,o=t.__c;typeof o=="function"&&(t.__c=void 0,o()),y=e}function ae(t){var e=y;t.__c=t.__(),y=e}function Re(t,e){return!t||t.length!==e.length||e.some(function(o,n){return o!==t[n]})}function We(t,e){return typeof e=="function"?e(t):e}const it=t=>({saveGameData(e){try{const o={highestUnlockedLevel:e.highestUnlockedLevel,levelScores:e.levelScores,totalScore:e.totalScore,currentLevel:e.currentLevel};localStorage.setItem(t,JSON.stringify(o))}catch(o){console.error("Failed to save maze game data:",o)}},loadGameData(){try{const e=localStorage.getItem(t);if(!e)return null;const o=JSON.parse(e);return{highestUnlockedLevel:o.highestUnlockedLevel,levelScores:o.levelScores,totalScore:o.totalScore,currentLevel:o.currentLevel,currentTier:Math.ceil(o.currentLevel/12),highestUnlockedTier:Math.ceil(o.highestUnlockedLevel/12)}}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 game state:",e)}}}),Ie=xe(void 0),st=({children:t,config:e})=>{const o=I(e),n=it(e.lcPrefix+"score"),r=n.loadGameData(),[i,s]=A({currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,maze:null,playerPosition:{row:0,col:0},exitPosition:{row:0,col:0},foodPositions:[],playerPath:[],visitCounts:{},moveCount:0,playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,...r||{}});N(()=>{n.saveGameData(i)},[i.highestUnlockedLevel,i.levelScores,i.totalScore,i.currentLevel]);const c=()=>{n.resetGameData(),s(a=>({...a,currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,playerPath:[],visitCounts:{},moveCount:0,foodCollected:0,showClue:!1}))};return f(Ie.Provider,{value:{gameState:i,setGameState:s,config:o,resetGame:c},children:t})},Oe=()=>{const t=De(Ie);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},Ve=xe(void 0),lt=({children:t})=>{const[e,o]=A(null),[n,r]=A(!1),[i,s]=A("info"),[c,a]=A(null),d=Ge(()=>{r(!1),c&&(clearTimeout(c),a(null))},[c]),_=Ge((l,h="info",u=3e3)=>{if(n&&d(),o(l),s(h),r(!0),u>0){const m=setTimeout(()=>{r(!1)},u);a(m)}},[n,d]);return f(Ve.Provider,{value:{message:e,visible:n,type:i,showToast:_,hideToast:d},children:t})},de=()=>{const t=De(Ve);if(!t)throw new Error("useToast must be used within a ToastProvider");return t},ct=({i18n:t,totalTiers:e,currentTier:o,highestUnlockedTier:n,onTierChange:r,disabled:i})=>f("div",{className:"tier-selector",children:f("select",{value:o,onChange:s=>{s.target&&s.target.value&&r(Number(s.target.value))},disabled:i,className:"tier-dropdown",children:Array.from({length:e},(s,c)=>c+1).map(s=>f("option",{value:s,disabled:s>n,children:[t.tier," ",s]},`tier-${s}`))})}),at=({i18n:t,levelsPerTier:e,currentTier:o,currentLevel:n,highestUnlockedLevel:r,onLevelChange:i,disabled:s})=>f("div",{className:"level-selector",children:f("select",{value:n,onChange:c=>{c.target&&c.target.value&&i(Number(c.target.value))},disabled:s,className:"level-dropdown",children:Array.from({length:e},(c,a)=>(o-1)*e+a+1).map(c=>f("option",{value:c,disabled:c>r,children:[t.level," ",c]},`level-${c}`))})}),_e=({isOpen:t,title:e,message:o,children:n,noConfirm:r=!1,noCancel:i=!1,confirmText:s="OK",cancelText:c="Cancel",onConfirm:a,onCancel:d})=>{const _=I(null);return N(()=>{const l=h=>{h.key==="Escape"&&d?.()};return t&&document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[t,d]),f("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:f("div",{className:"maze-dialog",ref:_,children:[f("div",{className:"maze-dialog-title",children:e}),f("div",{className:"maze-dialog-content",children:n||f("div",{className:"maze-dialog-message",children:o})}),f("div",{className:"maze-dialog-buttons",children:[!i&&f("button",{className:"maze-dialog-cancel",onClick:d,children:c}),!r&&f("button",{className:"maze-dialog-confirm",onClick:a,children:s})]})]})})};function dt(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}}const ue=[{size:8,seed:12345,method:"backtracking"},{size:8,seed:23456,method:"backtracking"},{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"}],he={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",total:"Total",levelScore:"Level Score",bestScore:"Best 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 current score will be halved.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",clueTip:"Turn on clue will halve your current score in this level",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",warnNotAllFoodCollectedToast:"Collect all food first! %NUM% remaining.",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:{padding:10,wallWidth:4,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700"},levelConfig:ue,levelsPerTier:12},_t=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6;class ut{constructor(e,o){this.row=e,this.col=o}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class ht{rows;cols;grid;seed;random;constructor(e,o,n){this.rows=e,this.cols=o,this.seed=n??Math.floor(Math.random()*1e6),this.random=dt(this.seed),this.grid=this.initializeGrid()}initializeGrid(){const e=[];for(let o=0;o<this.rows;o++){e[o]=[];for(let n=0;n<this.cols;n++)e[o][n]=new ut(o,n)}return e}isValid(e,o){return e>=0&&e<this.rows&&o>=0&&o<this.cols}getNeighbors(e,o){const n=[],r=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const i of r){const s=e+i.r,c=o+i.c;this.isValid(s,c)&&n.push({row:s,col:c})}return n}getUnvisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>!this.grid[n.row][n.col].visited)}getVisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>this.grid[n.row][n.col].visited)}removeWall(e,o,n,r){const i=this.grid[e][o],s=this.grid[n][r];e===n+1?(i.walls.top=!1,s.walls.bottom=!1):e===n-1?(i.walls.bottom=!1,s.walls.top=!1):o===r+1?(i.walls.left=!1,s.walls.right=!1):o===r-1&&(i.walls.right=!1,s.walls.left=!1)}}class ft{maze;constructor(e,o,n,r,i={row:0,col:0},s={row:e-1,col:o-1}){switch(this.maze=new ht(e,o,r),n){case"backtracking":this.runBacktracking();break;case"prims":this.runPrims();break;default:throw new Error(`Unknown maze generation method: ${n}`)}this.addOpenings(i,s)}getMaze(){return this.maze}runBacktracking(){const e=[],o=this.randomNumber(this.maze.rows),n=this.randomNumber(this.maze.cols);let r={row:o,col:n};for(this.maze.grid[o][n].visited=!0,e.push(r);e.length>0;){r=e[e.length-1];const{row:i,col:s}=r,c=this.maze.getUnvisitedNeighbors(i,s);if(c.length>0){const a=this.randomPick(c),{row:d,col:_}=a;this.maze.removeWall(i,s,d,_),this.maze.grid[d][_].visited=!0,e.push(a)}else e.pop()}}runPrims(){const e=[],o=(i,s)=>{const c=this.maze.getNeighbors(i,s);for(const a of c)!this.maze.grid[a.row][a.col].visited&&!e.some(d=>d.row===a.row&&d.col===a.col)&&e.push(a)},n=this.randomNumber(this.maze.rows),r=this.randomNumber(this.maze.cols);for(this.maze.grid[n][r].visited=!0,o(n,r);e.length>0;){const i=this.randomNumber(e.length),s=e[i],{row:c,col:a}=s,d=this.maze.getVisitedNeighbors(c,a);if(d.length>0){const _=this.randomPick(d);this.maze.removeWall(c,a,_.row,_.col),this.maze.grid[c][a].visited=!0,o(c,a)}e.splice(i,1)}}addOpenings(e,o){this.maze.grid[e.row][e.col].walls.top=!1,this.maze.grid[o.row][o.col].walls.bottom=!1}randomNumber(e){return Math.floor(this.maze.random()*e)}randomPick(e){return e[Math.floor(this.maze.random()*e.length)]}}function mt(t,e,o,n,r,i){return new ft(t,e,o,n,r,i).getMaze()}const vt=(t,e,o)=>{if(!t.isValid(e,o))return!1;const n=t.grid[e][o];return!n.walls.top||!n.walls.right||!n.walls.bottom||!n.walls.left},Be=t=>{const e=t-1,o=ue[e];if(!o)return console.error(`Cannot find Level ${t}'s config.`),null;const n=o.size,r=n,i=n,s=o.seed,c=o.method,a=o.entry||{row:0,col:0},d=o.exit||{row:r-1,col:i-1},_=mt(r,i,c,s,a,d),l=_t(t),h=[];for(let u=0;u<l;u++){let m;do m={row:Math.floor(_.random()*r),col:Math.floor(_.random()*i)};while(m.row===a.row&&m.col===a.col||m.row===d.row&&m.col===d.col||!vt(_,m.row,m.col)||h.some(C=>C.row===m.row&&C.col===m.col));h.push(m)}return{maze:_,playerPosition:a,exitPosition:d,foodPositions:h,totalFoodCount:l,foodCollected:0,playerPath:[a],visitCounts:{[`${a.row},${a.col}`]:1},moveCount:0,currentScore:_.rows*_.cols,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1}},qe=({gameState:t,setGameState:e})=>({generateCurrentLevelMaze:()=>{const n=Be(t.currentLevel);n&&e(r=>({...r,...n}))}}),pt=()=>{const{gameState:t,setGameState:e,resetGame:o,config:n}=Oe(),r=n.current.i18n,{showToast:i}=de(),{currentLevel:s,totalScore:c,levelScores:a,currentScore:d,showClue:_}=t,l=a[s]||0,h=n.current.levelsPerTier,u=Math.ceil(n.current.levelConfig.length/h),[m,C]=A(!1),[g,p]=A(!1),[v,b]=A(!1),{generateCurrentLevelMaze:z}=qe({gameState:t,setGameState:e}),S=T=>{const Q=(T-1)*h+1;Q<=t.highestUnlockedLevel&&(e(Ut=>({...Ut,currentTier:T})),P(Q))},P=T=>{T>0&&T<=t.highestUnlockedLevel&&(e(Q=>({...Q,currentLevel:T,currentTier:Math.ceil(T/h)})),z(),i(r.levelGoToast.replace("%LEVEL%",T.toString()),"success"))},F=()=>{C(!0)},M=()=>{C(!1)},E=()=>{b(!0)},L=()=>{b(!1)},x=()=>{e(T=>(i(T.showClue?r.cluePathDisabled:r.cluePathEnabled),{...T,showClue:!T.showClue,currentScore:Math.floor(T.currentScore/2)})),b(!1)},G=()=>{p(!0)},At=()=>{o(),p(!1),i(r.resetDoneToast)},Et=()=>{p(!1)};return f("div",{class:"game-panel-container",children:[f("div",{className:"game-controls",children:[f("div",{className:"selectors-container",children:[f(ct,{i18n:r,totalTiers:u,currentTier:t.currentTier,highestUnlockedTier:t.highestUnlockedTier,onTierChange:S,disabled:t.levelTransitioning}),f(at,{i18n:r,levelsPerTier:h,currentTier:t.currentTier,currentLevel:t.currentLevel,highestUnlockedLevel:t.highestUnlockedLevel,onLevelChange:P,disabled:t.levelTransitioning})]}),f("div",{className:"score-container",children:[f("div",{className:"score-box currentscore",children:[f("span",{className:"score-label",children:[r.levelScore,":"]}),f("span",{className:"score-data",children:d})]}),f("div",{className:"score-box bestscore",children:[f("span",{className:"score-label",children:[r.bestScore,":"]}),f("span",{className:"score-data",children:l})]}),f("div",{className:"score-box totalscore",children:[f("span",{className:"score-label",children:[r.total,":"]}),f("span",{className:"score-data",children:c})]})]})]}),f("div",{className:"game-settings",children:f("img",{onClick:F,src:"/settings.svg",alt:"Settings",className:"game-settings-icon"})}),f(_e,{isOpen:m,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:M,children:[f("div",{className:"settings-item-box",children:[f("div",{}),f("button",{className:`settings-clue-button ${_?"clue-on":"clue-off"}`,title:"Toggle Clue",onClick:E,children:_?r.clueOn:r.clueOff}),f("div",{className:"settings-item-tip",children:r.clueTip})]}),f("div",{className:"settings-item-box",children:[f("button",{className:"settings-reset-button",title:"Reset Game",onClick:G,children:r.reset}),f("div",{className:"settings-item-tip",children:r.resetTip})]})]}),f(_e,{isOpen:g,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:At,onCancel:Et}),f(_e,{isOpen:v,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:x,onCancel:L})]})},gt=({message:t,visible:e,duration:o=2e3,onClose:n,position:r="center",type:i="info"})=>t?(N(()=>{let s;return e&&o>0&&n&&(s=setTimeout(()=>{n()},o)),()=>{s&&clearTimeout(s)}},[e,o,n]),f("div",{className:`toast-container position-${r}`,children:f("div",{className:`toast-message type-${i} ${e?"toast-visible":""}`,children:t})})):null,wt=(t,e,o)=>{N(()=>{const n=()=>{const r=t.current;if(!r)return;const i=r.parentElement;if(!i)return;const s=i.clientWidth,c=i.clientHeight,a=Math.min(s,c),d=window.devicePixelRatio||1;r.style.width=`${a}px`,r.style.height=`${a}px`,r.width=a*d,r.height=a*d,e(t,o.current)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[t,e,o])},Ke={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Ct=({containerRef:t,gameState:e,setGameState:o,onFoodCollected:n,onFoodNotAllCollected:r})=>{N(()=>{const i=a=>{if(!e.isGameActive||!e.maze)return;const[d,_]=Ke[a],{row:l,col:h}=e.playerPosition,u=l+d,m=h+_;if(!e.maze.isValid(u,m))return;const C=e.maze.grid[l][h];if(d===-1&&C.walls.top||d===1&&C.walls.bottom||_===-1&&C.walls.left||_===1&&C.walls.right)return;const g={row:u,col:m},p=`${u},${m}`;o(v=>{const b=v.foodPositions.some(L=>L.row===u&&L.col===m);b&&n();const z=Math.max(0,v.currentScore-1),S=`${l},${h}-${u},${m}`,P=u===v.exitPosition.row&&m===v.exitPosition.col,F=b?v.foodCollected+1:v.foodCollected,M=F===v.totalFoodCount,E=P&&M;return P&&!M&&r(),{...v,playerPosition:g,playerPath:[...v.playerPath,g],foodPositions:v.foodPositions.filter(L=>!(L.row===u&&L.col===m)),foodCollected:F,currentScore:z,visitCounts:{...v.visitCounts,[S]:(v.visitCounts[S]||0)+1,[p]:(v.visitCounts[p]||0)+1},moveCount:v.moveCount+1,playerAtExit:P,isGameActive:!E,levelTransitioning:E}})},s=a=>{if(!e.isGameActive||!e.maze)return;const d=a.key;d in Ke&&(a.preventDefault(),i(d))},c=a=>{if(a.preventDefault(),!e.isGameActive||!e.maze)return;const d=a.touches[0],_=document.elementFromPoint(d.clientX,d.clientY);_&&(_.classList.contains("maze-up")?i("ArrowUp"):_.classList.contains("maze-down")?i("ArrowDown"):_.classList.contains("maze-left")?i("ArrowLeft"):_.classList.contains("maze-right")&&i("ArrowRight"))};return window.addEventListener("keydown",s),t.current?.addEventListener("touchstart",c,{passive:!1}),()=>{window.removeEventListener("keydown",s),t.current?.removeEventListener("touchstart",c)}},[e.isGameActive,e.maze,e.playerPosition,e.exitPosition])},yt=({gameState:t,setGameState:e,config:o,onLevelComplete:n,onTierUnlocked:r})=>{N(()=>{if(t.levelTransitioning){n();const s=setTimeout(()=>{i(t.currentScore)},1e3);return()=>clearTimeout(s)}},[t.levelTransitioning]);const i=s=>{if(t.currentLevel>=o.current.levelConfig.length)return;const c=t.currentLevel+1,a=Math.ceil(c/o.current.levelsPerTier),d=Be(c);d&&e(_=>{const l=Math.ceil(_.currentLevel/o.current.levelsPerTier);a>l&&r(a);const h={..._.levelScores};return h[_.currentLevel]=Math.max(s,h[_.currentLevel]||0),{..._,...d,currentLevel:c,currentTier:a,highestUnlockedLevel:Math.max(_.highestUnlockedLevel,c),highestUnlockedTier:Math.max(_.highestUnlockedTier,a),levelScores:h,totalScore:Object.values(h).reduce((u,m)=>u+m,0),showClue:!1,isGameActive:!0,levelTransitioning:!1}})};return{handleLevelComplete:i}};function kt(t,e){const{ctx:o,width:n,height:r,maze:i}=t;e.playerColor=t.playerAtExit?e.playerAtExitColor:e.playerColor;const{padding:s,wallWidth:c,wallColor:a,playerColor:d,exitColor:_,foodColor:l,clueColor:h,backgroundColor:u}=e,m=i.cols,C=i.rows,g=(n-s*2)/m,p=(r-s*2)/C;o.clearRect(0,0,n,r),o.save(),o.fillStyle=u,o.fillRect(0,0,n,r),o.restore(),t.showClue&&t.playerPath&&t.playerPath.length>0&&Lt(t,{cellWidth:g,cellHeight:p,padding:s,clueColor:h}),bt(t,{cellWidth:g,cellHeight:p,padding:s,wallColor:a,wallWidth:c}),Pt(t,{cellWidth:g,cellHeight:p,padding:s,foodColor:l}),t.playerAtExit||Tt(t,{cellWidth:g,cellHeight:p,padding:s,exitColor:_}),zt(t,{cellWidth:g,cellHeight:p,padding:s,playerColor:d})}function bt(t,e){const{ctx:o,maze:n}=t,{cellWidth:r,cellHeight:i,padding:s,wallColor:c,wallWidth:a}=e;o.save(),o.strokeStyle=c,o.lineWidth=a,o.lineCap="round",o.beginPath();for(let d=0;d<n.rows;d++)for(let _=0;_<n.cols;_++){const l=n.grid[d][_],h=s+_*r,u=s+d*i;l.walls.top&&(o.moveTo(h,u),o.lineTo(h+r,u)),l.walls.right&&(o.moveTo(h+r,u),o.lineTo(h+r,u+i)),l.walls.bottom&&(o.moveTo(h+r,u+i),o.lineTo(h,u+i)),l.walls.left&&(o.moveTo(h,u+i),o.lineTo(h,u))}o.stroke(),o.restore()}function zt(t,e){const{ctx:o,playerPosition:n}=t,{cellWidth:r,cellHeight:i,padding:s,playerColor:c}=e,{x:a,y:d}=O(n.row,n.col,r,i,s),_=Math.min(r,i)*.35;o.save(),o.fillStyle=c,o.beginPath(),o.arc(a,d,_,0,Math.PI*2),o.fill(),o.restore()}function Tt(t,e){const{ctx:o,exitPosition:n}=t,{cellWidth:r,cellHeight:i,padding:s,exitColor:c}=e,{x:a,y:d}=O(n.row,n.col,r,i,s),_=Math.min(r,i)*.35;o.save(),o.fillStyle=c,o.beginPath(),o.arc(a,d,_,0,Math.PI*2),o.fill(),o.restore()}function Pt(t,e){const{ctx:o,foodPositions:n}=t,{cellWidth:r,cellHeight:i,padding:s,foodColor:c}=e;o.fillStyle=c;const a=Math.min(r,i)*.25;n.forEach(d=>{const{x:_,y:l}=O(d.row,d.col,r,i,s);xt(o,_,l,a*1.2,5,a*.6)})}function xt(t,e,o,n,r,i){t.save(),t.beginPath();for(let s=0;s<r*2;s++){const c=s%2===0?n:i,a=Math.PI*s/r;t.lineTo(e+c*Math.sin(a),o+c*Math.cos(a))}t.closePath(),t.fill(),t.restore()}function Lt(t,e){const{ctx:o,playerPath:n,visitCounts:r}=t,{cellWidth:i,cellHeight:s,padding:c,clueColor:a}=e;if(!(!n||n.length<2||!r)){o.save();for(let d=1;d<n.length;d++){const _=n[d-1],l=n[d],h=`${_.row},${_.col}-${l.row},${l.col}`,u=`${l.row},${l.col}-${_.row},${_.col}`,m=(r[h]||0)+(r[u]||0),C=Math.min(.2+m*.1,.9),g=Math.max(3,i*.1)+m*.5;try{o.strokeStyle=a.replace(")",`, ${C})`).replace("rgb(","rgba(")}catch{o.strokeStyle=`rgba(255, 0, 0, ${C})`}o.lineWidth=g,o.lineCap="round",o.lineJoin="round";const{x:p,y:v}=O(_.row,_.col,i,s,c),{x:b,y:z}=O(l.row,l.col,i,s,c);o.beginPath(),o.moveTo(p,v),o.lineTo(b,z),o.stroke()}o.restore()}}function O(t,e,o,n,r){return{x:r+e*o+o/2,y:r+t*n+n/2}}const Nt=()=>{const{message:t,visible:e,type:o,hideToast:n}=de();return f(gt,{message:t,visible:e,type:o,onClose:n,position:"top"})},St=()=>{const{gameState:t,setGameState:e,config:o}=Oe(),n=I(null),r=I(null),i=I(t),s=o.current.i18n,{showToast:c}=de();N(()=>{i.current=t},[t]);const a=()=>{const h=t.totalFoodCount-t.foodCollected-1;if(h>0){c(s.foodCollectedToast.replace("%NUM%",h.toString()),"success");return}c(s.allFoodCollectedToast,"success")},d=()=>{const h=t.totalFoodCount-t.foodCollected-1;c(s.warnNotAllFoodCollectedToast.replace("%NUM%",h.toString()),"warning")},_=(h,u)=>{const m=h.current?.getContext("2d");m&&u.maze&&kt({ctx:m,width:h.current.width,height:h.current.height,maze:u.maze,playerPosition:u.playerPosition,exitPosition:u.exitPosition,foodPositions:u.foodPositions,showClue:u.showClue,playerPath:u.playerPath,visitCounts:u.visitCounts,playerAtExit:u.playerAtExit},o.current.renderConfig||{})};N(()=>{c(s.useArrowKeyTips,"info",3e3)},[]),wt(r,_,i);const{generateCurrentLevelMaze:l}=qe({gameState:t,setGameState:e});return Ct({containerRef:n,gameState:t,setGameState:e,onFoodCollected:a,onFoodNotAllCollected:d}),yt({gameState:t,setGameState:e,config:o,onLevelComplete:()=>{c(s.levelCompleteToast,"success")},onTierUnlocked:h=>{c(s.tierUnlockedToast.replace("%TIER%",h.toString()),"success")}}),N(()=>{t.isGameActive&&!t.levelTransitioning&&l()},[t.currentLevel,t.isGameActive,t.levelTransitioning]),N(()=>{r.current&&t.maze&&_(r,t)},[t]),f("div",{className:"maze-game-container",children:[f(Nt,{}),f(pt,{}),f("div",{className:"maze-canvas-container",ref:n,children:[f("canvas",{ref:r,className:"maze-game-canvas"}),f("div",{className:"maze-touch-area maze-up"}),f("div",{className:"maze-touch-area maze-down"}),f("div",{className:"maze-touch-area maze-left"}),f("div",{className:"maze-touch-area maze-right"})]})]})};function Mt(){return f(lt,{children:f(St,{})})}function $t({config:t={}}){const e={...he.i18n,...t.i18n||{}},o={...he.renderConfig,...t.renderConfig||{}},n=t.levelConfig||ue;return t={...he,...t,i18n:e,levelConfig:n,renderConfig:o},f(st,{config:t,children:f(Mt,{})})}return{async init(t,e){const o=typeof t=="string"?document.querySelector(t):t;if(!o){console.warn("Cannot find the root element");const a=document.createElement("div");a.style.textAlign="center",a.style.padding="20px",a.innerHTML="Cannot find the root element",document.body.append(a);return}let{root:n=location.origin}=e;n.at(-1)!=="/"&&(n+="/");const r=document.createElement("div"),i=document.createElement("div");r.style.cssText=`
|
|
2
|
+
height: 30px;
|
|
3
|
+
width: 100%;
|
|
4
|
+
border: solid 2px #999;
|
|
5
|
+
margin: 20% auto;
|
|
6
|
+
`,i.style.cssText=`
|
|
7
|
+
width: 99%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
background: #999;
|
|
10
|
+
animation: loading 1.5s ease-in-out;
|
|
11
|
+
transition: width 1.5s ease-in-out;
|
|
12
|
+
transition: width 1.5s ease-in-out;
|
|
13
|
+
`,r.append(i),o.append(r);const s=document.createElement("style");s.innerHTML=`
|
|
14
|
+
@keyframes loading {
|
|
15
|
+
0% { width: 0%; }
|
|
16
|
+
100% { width: 99%; }
|
|
17
|
+
}`,document.head.appendChild(s),await(async a=>new Promise((d,_)=>{const l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.href=a,l.onload=d,l.onerror=_,document.head.appendChild(l)}))(n+"maze.css"),et(f($t,{config:e}),o)}}}();
|