reactchessts
Version:
React TypeScript chess development toolkit
12 lines (11 loc) • 47.3 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("chess.js")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","chess.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ChessTs={},e.React,e.ReactDOM,e.Chess)}(this,(function(e,t,r,n){"use strict";var o,s={exports:{}},a={};var i,l={};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/"production"===process.env.NODE_ENV?s.exports=function(){if(o)return a;o=1;var e=t,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var o,a={},c=null,u=null;for(o in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)s.call(t,o)&&!l.hasOwnProperty(o)&&(a[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===a[o]&&(a[o]=t[o]);return{$$typeof:r,type:e,key:c,ref:u,props:a,_owner:i.current}}return a.Fragment=n,a.jsx=c,a.jsxs=c,a}():s.exports=(i||(i=1,"production"!==process.env.NODE_ENV&&function(){var e,r=t,n=Symbol.for("react.element"),o=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),y=Symbol.iterator,v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=v.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map((function(e){return String(e)}));o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}("error",e,r)}function k(e){return e.displayName||"Context"}function b(e){if(null==e)return null;if("number"==typeof e.tag&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case s:return"Fragment";case o:return"Portal";case i:return"Profiler";case a:return"StrictMode";case p:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case u:return k(e)+".Consumer";case c:return k(e._context)+".Provider";case f:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case h:var t=e.displayName||null;return null!==t?t:b(e.type)||"Memo";case g:var r=e,n=r._payload,l=r._init;try{return b(l(n))}catch(m){return null}}return null}e=Symbol.for("react.module.reference");var C,L,x,S,T,E,D,j=Object.assign,M=0;function P(){}P.__reactDisabledLog=!0;var O,_=v.ReactCurrentDispatcher;function $(e,t,r){if(void 0===O)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);O=n&&n[1]||""}return"\n"+O+e}var R,N=!1,q="function"==typeof WeakMap?WeakMap:Map;function z(e,t){if(!e||N)return"";var r,n=R.get(e);if(void 0!==n)return n;N=!0;var o,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=_.current,_.current=null,function(){if(0===M){C=console.log,L=console.info,x=console.warn,S=console.error,T=console.group,E=console.groupCollapsed,D=console.groupEnd;var e={configurable:!0,enumerable:!0,value:P,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}M++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(h){r=h}Reflect.construct(e,[],a)}else{try{a.call()}catch(h){r=h}e.call(a.prototype)}}else{try{throw Error()}catch(h){r=h}e()}}catch(g){if(g&&r&&"string"==typeof g.stack){for(var i=g.stack.split("\n"),l=r.stack.split("\n"),c=i.length-1,u=l.length-1;c>=1&&u>=0&&i[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(i[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||i[c]!==l[u]){var f="\n"+i[c].replace(" at new "," at ");return e.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",e.displayName)),"function"==typeof e&&R.set(e,f),f}}while(c>=1&&u>=0);break}}}finally{N=!1,_.current=o,function(){if(0==--M){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},e,{value:C}),info:j({},e,{value:L}),warn:j({},e,{value:x}),error:j({},e,{value:S}),group:j({},e,{value:T}),groupCollapsed:j({},e,{value:E}),groupEnd:j({},e,{value:D})})}M<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var p=e?e.displayName||e.name:"",d=p?$(p):"";return"function"==typeof e&&R.set(e,d),d}function U(e,t,r){if(null==e)return"";if("function"==typeof e)return z(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return $(e);switch(e){case p:return $("Suspense");case d:return $("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case f:return z(e.render,!1);case h:return U(e.type,t,r);case g:var o=e,s=o._payload,a=o._init;try{return U(a(s),t,r)}catch(i){}}return""}R=new q;var G=Object.prototype.hasOwnProperty,I={},F=v.ReactDebugCurrentFrame;function A(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);F.setExtraStackFrame(r)}else F.setExtraStackFrame(null)}var V=Array.isArray;function W(e){return V(e)}function Y(e){return""+e}function B(e){if(function(e){try{return Y(e),!1}catch(t){return!0}}(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),Y(e)}var X,J,H=v.ReactCurrentOwner,K={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,r,o,s){var a,i={},l=null,c=null;for(a in void 0!==r&&(B(r),l=""+r),function(e){if(G.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(B(t.key),l=""+t.key),function(e){if(G.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&H.current}(t)),t)G.call(t,a)&&!K.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps){var u=e.defaultProps;for(a in u)void 0===i[a]&&(i[a]=u[a])}if(l||c){var f="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var r=function(){X||(X=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(i,f),c&&function(e,t){var r=function(){J||(J=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(i,f)}return function(e,t,r,o,s,a,i){var l={$$typeof:n,type:e,key:t,ref:r,props:i,_owner:a,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,s,o,H.current,i)}var Z,ee=v.ReactCurrentOwner,te=v.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function oe(){if(ee.current){var e=b(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var se={};function ae(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=oe();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!se[r]){se[r]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+b(e._owner.type)+"."),re(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),re(null)}}}function ie(e,t){if("object"==typeof e)if(W(e))for(var r=0;r<e.length;r++){var n=e[r];ne(n)&&ae(n,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=y&&e[y]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var s,a=o.call(e);!(s=a.next()).done;)ne(s.value)&&ae(s.value,t)}}function le(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==f&&r.$$typeof!==h)return;t=r.propTypes}if(t){var n=b(r);!function(e,t,r,n,o){var s=Function.call.bind(G);for(var a in e)if(s(e,a)){var i=void 0;try{if("function"!=typeof e[a]){var l=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}i=e[a](t,a,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){i=c}!i||i instanceof Error||(A(o),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,a,typeof i),A(null)),i instanceof Error&&!(i.message in I)&&(I[i.message]=!0,A(o),w("Failed %s type: %s",r,i.message),A(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||Z||(Z=!0,w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ce={};function ue(t,r,o,l,y,v){var k=function(t){return"string"==typeof t||"function"==typeof t||t===s||t===i||t===a||t===p||t===d||t===m||"object"==typeof t&&null!==t&&(t.$$typeof===g||t.$$typeof===h||t.$$typeof===c||t.$$typeof===u||t.$$typeof===f||t.$$typeof===e||void 0!==t.getModuleId)}(t);if(!k){var C,L="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),L+=oe(),null===t?C="null":W(t)?C="array":void 0!==t&&t.$$typeof===n?(C="<"+(b(t.type)||"Unknown")+" />",L=" Did you accidentally export a JSX literal instead of a component?"):C=typeof t,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,L)}var x=Q(t,r,o,y,v);if(null==x)return x;if(k){var S=r.children;if(void 0!==S)if(l)if(W(S)){for(var T=0;T<S.length;T++)ie(S[T],t);Object.freeze&&Object.freeze(S)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ie(S,t)}if(G.call(r,"key")){var E=b(t),D=Object.keys(r).filter((function(e){return"key"!==e})),j=D.length>0?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}";ce[E+j]||(w('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',j,E,D.length>0?"{"+D.join(": ..., ")+": ...}":"{}",E),ce[E+j]=!0)}return t===s?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){re(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),re(null);break}}null!==e.ref&&(re(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(x):le(x),x}var fe=function(e,t,r){return ue(e,t,r,!1)},pe=function(e,t,r){return ue(e,t,r,!0)};l.Fragment=s,l.jsx=fe,l.jsxs=pe}()),l);var c=s.exports;const u={wp:"♙",wn:"♘",wb:"♗",wr:"♖",wq:"♕",wk:"♔",bp:"♟",bn:"♞",bb:"♝",br:"♜",bq:"♛",bk:"♚"},f=["wp","wn","wb","wr","wq","wk","bp","bn","bb","br","bq","bk"],p={p:"pawn",n:"knight",b:"bishop",r:"rook",q:"queen",k:"king"},d={wp:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cpath%20d='m%2022.5,9%20c%20-2.21,0%20-4,1.79%20-4,4%200,0.89%200.29,1.71%200.78,2.38%20C%2017.33,16.5%2016,18.59%2016,21%20c%200,2.03%200.94,3.84%202.41,5.03%20C%2015.41,27.09%2011,31.58%2011,39.5%20H%2034%20C%2034,31.58%2029.59,27.09%2026.59,26.03%2028.06,24.84%2029,23.03%2029,21%2029,18.59%2027.67,16.5%2025.72,15.38%2026.21,14.71%2026.5,13.89%2026.5,13%20c%200,-2.21%20-1.79,-4%20-4,-4%20z'%20style='opacity:1;%20fill:%23ffffff;%20fill-opacity:1;%20fill-rule:nonzero;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:miter;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'/%3e%3c/svg%3e",wn:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%2022,10%20C%2032.5,11%2038.5,18%2038,39%20L%2015,39%20C%2015,30%2025,32.5%2023,18'%20style='fill:%23ffffff;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2024,18%20C%2024.38,20.91%2018.45,25.37%2016,27%20C%2013,29%2013.18,31.34%2011,31%20C%209.958,30.06%2012.41,27.96%2011,28%20C%2010,28%2011.19,29.23%2010,30%20C%209,30%205.997,31%206,26%20C%206,24%2012,14%2012,14%20C%2012,14%2013.89,12.1%2014,10.5%20C%2013.27,9.506%2013.5,8.5%2013.5,7.5%20C%2014.5,6.5%2016.5,10%2016.5,10%20L%2018.5,10%20C%2018.5,10%2019.28,8.008%2021,7%20C%2022,7%2022,10%2022,10'%20style='fill:%23ffffff;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%209.5%2025.5%20A%200.5%200.5%200%201%201%208.5,25.5%20A%200.5%200.5%200%201%201%209.5%2025.5%20z'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2015%2015.5%20A%200.5%201.5%200%201%201%2014,15.5%20A%200.5%201.5%200%201%201%2015%2015.5%20z'%20transform='matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3c/g%3e%3c/svg%3e",wb:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-rule:evenodd;%20fill-opacity:1;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:round;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.6)'%3e%3cg%20style='fill:%23ffffff;%20stroke:%23000000;%20stroke-linecap:butt;'%3e%3cpath%20d='M%209,36%20C%2012.39,35.03%2019.11,36.43%2022.5,34%20C%2025.89,36.43%2032.61,35.03%2036,36%20C%2036,36%2037.65,36.54%2039,38%20C%2038.32,38.97%2037.35,38.99%2036,38.5%20C%2032.61,37.53%2025.89,38.96%2022.5,37.5%20C%2019.11,38.96%2012.39,37.53%209,38.5%20C%207.65,38.99%206.68,38.97%206,38%20C%207.35,36.54%209,36%209,36%20z'/%3e%3cpath%20d='M%2015,32%20C%2017.5,34.5%2027.5,34.5%2030,32%20C%2030.5,30.5%2030,30%2030,30%20C%2030,27.5%2027.5,26%2027.5,26%20C%2033,24.5%2033.5,14.5%2022.5,10.5%20C%2011.5,14.5%2012,24.5%2017.5,26%20C%2017.5,26%2015,27.5%2015,30%20C%2015,30%2014.5,30.5%2015,32%20z'/%3e%3cpath%20d='M%2025%208%20A%202.5%202.5%200%201%201%2020,8%20A%202.5%202.5%200%201%201%2025%208%20z'/%3e%3c/g%3e%3cpath%20d='M%2017.5,26%20L%2027.5,26%20M%2015,30%20L%2030,30%20M%2022.5,15.5%20L%2022.5,20.5%20M%2020,18%20L%2025,18'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'/%3e%3c/g%3e%3c/svg%3e",wr:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:%23ffffff;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%209,39%20L%2036,39%20L%2036,36%20L%209,36%20L%209,39%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,36%20L%2012,32%20L%2033,32%20L%2033,36%20L%2012,36%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2011,14%20L%2011,9%20L%2015,9%20L%2015,11%20L%2020,11%20L%2020,9%20L%2025,9%20L%2025,11%20L%2030,11%20L%2030,9%20L%2034,9%20L%2034,14'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2034,14%20L%2031,17%20L%2014,17%20L%2011,14'%20/%3e%3cpath%20d='M%2031,17%20L%2031,29.5%20L%2014,29.5%20L%2014,17'%20style='stroke-linecap:butt;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2031,29.5%20L%2032.5,32%20L%2012.5,32%20L%2014,29.5'%20/%3e%3cpath%20d='M%2011,14%20L%2034,14'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'%20/%3e%3c/g%3e%3c/svg%3e",wq:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:%23ffffff;stroke:%23000000;stroke-width:1.5;stroke-linejoin:round'%3e%3cpath%20d='M%209,26%20C%2017.5,24.5%2030,24.5%2036,26%20L%2038.5,13.5%20L%2031,25%20L%2030.7,10.9%20L%2025.5,24.5%20L%2022.5,10%20L%2019.5,24.5%20L%2014.3,10.9%20L%2014,25%20L%206.5,13.5%20L%209,26%20z'/%3e%3cpath%20d='M%209,26%20C%209,28%2010.5,28%2011.5,30%20C%2012.5,31.5%2012.5,31%2012,33.5%20C%2010.5,34.5%2011,36%2011,36%20C%209.5,37.5%2011,38.5%2011,38.5%20C%2017.5,39.5%2027.5,39.5%2034,38.5%20C%2034,38.5%2035.5,37.5%2034,36%20C%2034,36%2034.5,34.5%2033,33.5%20C%2032.5,31%2032.5,31.5%2033.5,30%20C%2034.5,28%2036,28%2036,26%20C%2027.5,24.5%2017.5,24.5%209,26%20z'/%3e%3cpath%20d='M%2011.5,30%20C%2015,29%2030,29%2033.5,30'%20style='fill:none'/%3e%3cpath%20d='M%2012,33.5%20C%2018,32.5%2027,32.5%2033,33.5'%20style='fill:none'/%3e%3ccircle%20cx='6'%20cy='12'%20r='2'%20/%3e%3ccircle%20cx='14'%20cy='9'%20r='2'%20/%3e%3ccircle%20cx='22.5'%20cy='8'%20r='2'%20/%3e%3ccircle%20cx='31'%20cy='9'%20r='2'%20/%3e%3ccircle%20cx='39'%20cy='12'%20r='2'%20/%3e%3c/g%3e%3c/svg%3e",wk:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='45'%20height='45'%3e%3cg%20fill='none'%20fill-rule='evenodd'%20stroke='%23000'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.5'%3e%3cpath%20stroke-linejoin='miter'%20d='M22.5%2011.63V6M20%208h5'/%3e%3cpath%20fill='%23fff'%20stroke-linecap='butt'%20stroke-linejoin='miter'%20d='M22.5%2025s4.5-7.5%203-10.5c0%200-1-2.5-3-2.5s-3%202.5-3%202.5c-1.5%203%203%2010.5%203%2010.5'/%3e%3cpath%20fill='%23fff'%20d='M12.5%2037c5.5%203.5%2014.5%203.5%2020%200v-7s9-4.5%206-10.5c-4-6.5-13.5-3.5-16%204V27v-3.5c-2.5-7.5-12-10.5-16-4-3%206%206%2010.5%206%2010.5v7'/%3e%3cpath%20d='M12.5%2030c5.5-3%2014.5-3%2020%200m-20%203.5c5.5-3%2014.5-3%2020%200m-20%203.5c5.5-3%2014.5-3%2020%200'/%3e%3c/g%3e%3c/svg%3e",bp:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cpath%20d='m%2022.5,9%20c%20-2.21,0%20-4,1.79%20-4,4%200,0.89%200.29,1.71%200.78,2.38%20C%2017.33,16.5%2016,18.59%2016,21%20c%200,2.03%200.94,3.84%202.41,5.03%20C%2015.41,27.09%2011,31.58%2011,39.5%20H%2034%20C%2034,31.58%2029.59,27.09%2026.59,26.03%2028.06,24.84%2029,23.03%2029,21%2029,18.59%2027.67,16.5%2025.72,15.38%2026.21,14.71%2026.5,13.89%2026.5,13%20c%200,-2.21%20-1.79,-4%20-4,-4%20z'%20style='opacity:1;%20fill:%23000000;%20fill-opacity:1;%20fill-rule:nonzero;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:miter;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'/%3e%3c/svg%3e",bn:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%2022,10%20C%2032.5,11%2038.5,18%2038,39%20L%2015,39%20C%2015,30%2025,32.5%2023,18'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2024,18%20C%2024.38,20.91%2018.45,25.37%2016,27%20C%2013,29%2013.18,31.34%2011,31%20C%209.958,30.06%2012.41,27.96%2011,28%20C%2010,28%2011.19,29.23%2010,30%20C%209,30%205.997,31%206,26%20C%206,24%2012,14%2012,14%20C%2012,14%2013.89,12.1%2014,10.5%20C%2013.27,9.506%2013.5,8.5%2013.5,7.5%20C%2014.5,6.5%2016.5,10%2016.5,10%20L%2018.5,10%20C%2018.5,10%2019.28,8.008%2021,7%20C%2022,7%2022,10%2022,10'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%209.5%2025.5%20A%200.5%200.5%200%201%201%208.5,25.5%20A%200.5%200.5%200%201%201%209.5%2025.5%20z'%20style='fill:%23ffffff;%20stroke:%23ffffff;'%20/%3e%3cpath%20d='M%2015%2015.5%20A%200.5%201.5%200%201%201%2014,15.5%20A%200.5%201.5%200%201%201%2015%2015.5%20z'%20transform='matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)'%20style='fill:%23ffffff;%20stroke:%23ffffff;'%20/%3e%3cpath%20d='M%2024.55,10.4%20L%2024.1,11.85%20L%2024.6,12%20C%2027.75,13%2030.25,14.49%2032.5,18.75%20C%2034.75,23.01%2035.75,29.06%2035.25,39%20L%2035.2,39.5%20L%2037.45,39.5%20L%2037.5,39%20C%2038,28.94%2036.62,22.15%2034.25,17.66%20C%2031.88,13.17%2028.46,11.02%2025.06,10.5%20L%2024.55,10.4%20z%20'%20style='fill:%23ffffff;%20stroke:none;'%20/%3e%3c/g%3e%3c/svg%3e",bb:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-rule:evenodd;%20fill-opacity:1;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:round;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.6)'%3e%3cg%20style='fill:%23000000;%20stroke:%23000000;%20stroke-linecap:butt;'%3e%3cpath%20d='M%209,36%20C%2012.39,35.03%2019.11,36.43%2022.5,34%20C%2025.89,36.43%2032.61,35.03%2036,36%20C%2036,36%2037.65,36.54%2039,38%20C%2038.32,38.97%2037.35,38.99%2036,38.5%20C%2032.61,37.53%2025.89,38.96%2022.5,37.5%20C%2019.11,38.96%2012.39,37.53%209,38.5%20C%207.65,38.99%206.68,38.97%206,38%20C%207.35,36.54%209,36%209,36%20z'/%3e%3cpath%20d='M%2015,32%20C%2017.5,34.5%2027.5,34.5%2030,32%20C%2030.5,30.5%2030,30%2030,30%20C%2030,27.5%2027.5,26%2027.5,26%20C%2033,24.5%2033.5,14.5%2022.5,10.5%20C%2011.5,14.5%2012,24.5%2017.5,26%20C%2017.5,26%2015,27.5%2015,30%20C%2015,30%2014.5,30.5%2015,32%20z'/%3e%3cpath%20d='M%2025%208%20A%202.5%202.5%200%201%201%2020,8%20A%202.5%202.5%200%201%201%2025%208%20z'/%3e%3c/g%3e%3cpath%20d='M%2017.5,26%20L%2027.5,26%20M%2015,30%20L%2030,30%20M%2022.5,15.5%20L%2022.5,20.5%20M%2020,18%20L%2025,18'%20style='fill:none;%20stroke:%23ffffff;%20stroke-linejoin:miter;'/%3e%3c/g%3e%3c/svg%3e",br:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:%23000000;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%209,39%20L%2036,39%20L%2036,36%20L%209,36%20L%209,39%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012.5,32%20L%2014,29.5%20L%2031,29.5%20L%2032.5,32%20L%2012.5,32%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,36%20L%2012,32%20L%2033,32%20L%2033,36%20L%2012,36%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2014,29.5%20L%2014,16.5%20L%2031,16.5%20L%2031,29.5%20L%2014,29.5%20z%20'%20style='stroke-linecap:butt;stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,16.5%20L%2011,14%20L%2034,14%20L%2031,16.5%20L%2014,16.5%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2011,14%20L%2011,9%20L%2015,9%20L%2015,11%20L%2020,11%20L%2020,9%20L%2025,9%20L%2025,11%20L%2030,11%20L%2030,9%20L%2034,9%20L%2034,14%20L%2011,14%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,35.5%20L%2033,35.5%20L%2033,35.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2013,31.5%20L%2032,31.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,29.5%20L%2031,29.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,16.5%20L%2031,16.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2011,14%20L%2034,14'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3c/g%3e%3c/svg%3e",bq:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:%23000000;stroke:%23000000;stroke-width:1.5;stroke-linejoin:round'%3e%3cpath%20d='M%209,26%20C%2017.5,24.5%2030,24.5%2036,26%20L%2038.5,13.5%20L%2031,25%20L%2030.7,10.9%20L%2025.5,24.5%20L%2022.5,10%20L%2019.5,24.5%20L%2014.3,10.9%20L%2014,25%20L%206.5,13.5%20L%209,26%20z'/%3e%3cpath%20d='m%209,26%20c%200,2%201.5,2%202.5,4%201,1.5%201,1%200.5,3.5%20-1.5,1%20-1,2.5%20-1,2.5%20-1.5,1.5%200,2.5%200,2.5%206.5,1%2016.5,1%2023,0%200,0%201.5,-1%200,-2.5%200,0%200.5,-1.5%20-1,-2.5%20-0.5,-2.5%20-0.5,-2%200.5,-3.5%201,-2%202.5,-2%202.5,-4%20-8.5,-1.5%20-18.5,-1.5%20-27,0%20z'/%3e%3cpath%20d='M%2011.5,30%20C%2015,29%2030,29%2033.5,30'%20style='fill:none'/%3e%3cpath%20d='m%2012,33.5%20c%206,-1%2015,-1%2021,0'%20style='fill:none'/%3e%3ccircle%20cx='6'%20cy='12'%20r='2'/%3e%3ccircle%20cx='14'%20cy='9'%20r='2'/%3e%3ccircle%20cx='22.5'%20cy='8'%20r='2'/%3e%3ccircle%20cx='31'%20cy='9'%20r='2'/%3e%3ccircle%20cx='39'%20cy='12'%20r='2'/%3e%3cpath%20d='M%2011,38.5%20A%2035,35%201%200%200%2034,38.5'%20style='fill:none'/%3e%3cg%20style='fill:none;stroke:%23ffffff'%3e%3cpath%20d='M%2011,29%20A%2035,35%201%200%201%2034,29'/%3e%3cpath%20d='M%2012.5,31.5%20L%2032.5,31.5'/%3e%3cpath%20d='M%2011.5,34.5%20A%2035,35%201%200%200%2033.5,34.5'/%3e%3cpath%20d='M%2010.5,37.5%20A%2035,35%201%200%200%2034.5,37.5'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",bk:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%3e%3cpath%20d='M%2022.5,11.63%20L%2022.5,6'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'%20id='path6570'/%3e%3cpath%20d='M%2022.5,25%20C%2022.5,25%2027,17.5%2025.5,14.5%20C%2025.5,14.5%2024.5,12%2022.5,12%20C%2020.5,12%2019.5,14.5%2019.5,14.5%20C%2018,17.5%2022.5,25%2022.5,25'%20style='fill:%23000000;fill-opacity:1;%20stroke-linecap:butt;%20stroke-linejoin:miter;'/%3e%3cpath%20d='M%2012.5,37%20C%2018,40.5%2027,40.5%2032.5,37%20L%2032.5,30%20C%2032.5,30%2041.5,25.5%2038.5,19.5%20C%2034.5,13%2025,16%2022.5,23.5%20L%2022.5,27%20L%2022.5,23.5%20C%2020,16%2010.5,13%206.5,19.5%20C%203.5,25.5%2012.5,30%2012.5,30%20L%2012.5,37'%20style='fill:%23000000;%20stroke:%23000000;'/%3e%3cpath%20d='M%2020,8%20L%2025,8'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'/%3e%3cpath%20d='M%2032,29.5%20C%2032,29.5%2040.5,25.5%2038.03,19.85%20C%2034.15,14%2025,18%2022.5,24.5%20L%2022.5,26.6%20L%2022.5,24.5%20C%2020,18%2010.85,14%206.97,19.85%20C%204.5,25.5%2013,29.5%2013,29.5'%20style='fill:none;%20stroke:%23ffffff;'/%3e%3cpath%20d='M%2012.5,30%20C%2018,27%2027,27%2032.5,30%20M%2012.5,33.5%20C%2018,30.5%2027,30.5%2032.5,33.5%20M%2012.5,37%20C%2018,34%2027,34%2032.5,37'%20style='fill:none;%20stroke:%23ffffff;'/%3e%3c/g%3e%3c/svg%3e"},h=()=>{const e={};return f.forEach((t=>{e[t]=""})),e},g=t.createContext({currentTheme:"default",themes:{},loadTheme:async()=>{},getPieceSvg:()=>null,setCustomPiece:()=>{},resetTheme:()=>{},preloadTheme:async()=>{},getThemeNames:()=>[],isThemeLoaded:()=>!1}),m=()=>{const e=t.useContext(g);if(!e)throw new Error("usePieces must be used within a PieceProvider");return e};const y=t.memo((({piece:e,square:n,isDragging:o,_theme:s="default"})=>{var a,i;const{getPieceSvg:l}=m(),u=l(e),f=t.useRef(null),[d,h]=t.useState(null),g=t.useRef(null),y=p[e[1]],v="w"===e[0]?"white":"black",w=`${v} ${y} on ${n}`,k=t.useCallback((e=>{if(!o||!g.current)return;const{x:t,y:r,rect:n}=g.current,s=e.pageX-t,a=e.pageY-r;h({x:n.left+window.scrollX+s,y:n.top+window.scrollY+a})}),[o]);t.useEffect((()=>{if(o&&f.current){const e=f.current.getBoundingClientRect();g.current={x:window.scrollX+e.left,y:window.scrollY+e.top,rect:e},h({x:window.scrollX+e.left,y:window.scrollY+e.top});const t=e=>{g.current&&(g.current.x=e.pageX,g.current.y=e.pageY,window.removeEventListener("mousemove",t))};window.addEventListener("mousemove",t,{once:!0}),window.addEventListener("mousemove",k)}else h(null);return()=>{window.removeEventListener("mousemove",k),g.current=null}}),[o,k]);const b=t.useCallback((()=>u?c.jsx("img",{src:u,alt:`${v} ${y}`,className:"piece-svg no-drag",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",opacity:o?.8:1,filter:e.startsWith("b")?"brightness(0.2)":"none",userSelect:"none"}}):null),[u,o,e,v,y]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{ref:f,className:"piece "+(o?"dragging":""),"data-piece":e,"data-square":n,role:"piece","aria-label":w,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:o?"grabbing":"grab",transition:o?"none":"transform 0.2s ease",pointerEvents:o?"none":"auto",touchAction:"none",willChange:"transform",transformOrigin:"center",zIndex:o?9999:1,opacity:o?0:1,backgroundColor:"transparent"},children:[!o&&b(),c.jsx("span",{className:"visually-hidden",children:w})]}),o&&d&&r.createPortal(c.jsx("div",{className:"dragged-piece",style:{position:"fixed",left:0,top:0,width:null==(a=g.current)?void 0:a.rect.width,height:null==(i=g.current)?void 0:i.rect.height,transform:`translate(${d.x}px, ${d.y}px)`,zIndex:9999,pointerEvents:"none",willChange:"transform",backgroundColor:"transparent"},children:b()}),document.body),c.jsx("style",{children:"\n .piece-svg {\n user-select: none;\n -webkit-user-drag: none;\n }\n \n .chess-board {\n position: relative;\n }\n\n .chess-board .square {\n position: relative;\n z-index: 1;\n }\n\n .piece {\n position: absolute;\n z-index: 2;\n transform-origin: center;\n background-color: transparent !important;\n }\n\n .piece.dragging {\n z-index: 9999;\n pointer-events: none;\n }\n\n .dragged-piece {\n pointer-events: none;\n transform-origin: center;\n background-color: transparent !important;\n }\n\n .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n\n .no-drag {\n -webkit-user-drag: none;\n -khtml-user-drag: none;\n -moz-user-drag: none;\n -o-user-drag: none;\n user-drag: none;\n }\n "})]})}));y.displayName="Piece";const v=t.createContext(null),w=()=>{const e=t.useContext(v);if(!e)throw new Error("useChess must be used within a ChessProvider");return e};e.ChessBoard=function({onPieceDrop:e,orientation:r="white",customSquareStyles:n={}}){const{position:o,makeMove:s,getPossibleMoves:a,turn:i}=w(),[l,u]=t.useState({piece:null,from:null,isDragging:!1}),[f,p]=t.useState(null),[d,h]=t.useState([]),g=t.useRef(null),m=t.useRef({handleMove:null,handleUp:null}),v=t.useMemo((()=>{const[e]=o.split(" "),t=e.split("/"),r={};return t.forEach(((e,t)=>{let n=0;for(let o=0;o<e.length;o++){const s=e[o];if(/\d/.test(s))n+=parseInt(s);else{const e=`${String.fromCharCode(97+n)}${8-t}`,o=s===s.toUpperCase()?"w":"b",a=s.toLowerCase();r[e]=`${o}${a}`,n++}}})),r}),[o]),k=t.useCallback((e=>{if(!g.current)return null;const t=g.current.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;if(n<0||n>t.width||o<0||o>t.height)return null;const s=Math.floor(n/t.width*8),a=Math.floor(o/t.height*8);return`${String.fromCharCode(97+("white"===r?s:7-s))}${8-a}`}),[r]),b=t.useCallback((()=>{m.current.handleMove&&window.removeEventListener("mousemove",m.current.handleMove),m.current.handleUp&&window.removeEventListener("mouseup",m.current.handleUp),m.current.handleMove=null,m.current.handleUp=null}),[]);t.useEffect((()=>()=>b()),[b]);const C=t.useCallback(((t,r)=>{const n=v[r];if(!n||"w"===i&&n.startsWith("b")||"b"===i&&n.startsWith("w"))return;t.preventDefault(),u({piece:n,from:r,isDragging:!0});const o=a(r);h(o);const s=e=>{if(e.preventDefault(),!g.current)return;document.querySelectorAll(".drop-target, .dragging-over").forEach((e=>{e.classList.remove("drop-target","dragging-over")}));const t=k(e);if(t&&o.includes(t)){const e=document.querySelector(`[data-square="${t}"]`);e&&e.classList.add("drop-target","dragging-over")}},l=t=>{t.preventDefault(),document.querySelectorAll(".drop-target").forEach((e=>{e.classList.remove("drop-target")}));const s=k(t);s&&s!==r&&o.includes(s)&&e&&e(r,s,n),u({piece:null,from:null,isDragging:!1}),h([]),b()};m.current.handleMove=s,m.current.handleUp=l,window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}),[v,a,i,k,e,b]),L=t.useCallback(((t,r)=>{if(t.stopPropagation(),!l.isDragging)if(f){if(r===f)return p(null),void h([]);if(a(f).includes(r)){s(f,r)&&e&&e(f,r,v[f])}p(null),h([])}else if(v[r]){const e=v[r];("w"===i&&e.startsWith("w")||"b"===i&&e.startsWith("b"))&&(p(r),h(a(r)))}else p(null),h([])}),[f,s,e,v,a,i,l.isDragging]),x=t.useCallback((e=>{e.target===e.currentTarget&&p(null)}),[]),S=t.useCallback(((e,t)=>{if("Enter"===e.key||" "===e.key){e.preventDefault();const r={stopPropagation:()=>{},target:e.target,currentTarget:e.currentTarget};L(r,t)}else if("Escape"===e.key)p(null);else{const r={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"}[e.key];if(r){e.preventDefault();const n=((e,t)=>{let r=e.charCodeAt(0)-97,n=8-parseInt(e[1]);switch(t){case"up":n--;break;case"down":n++;break;case"left":r--;break;case"right":r++}return r<0||r>7||n<0||n>7?null:`${String.fromCharCode(97+r)}${8-n}`})(t,r);if(n){const e=document.querySelector(`[data-square="${n}"]`);e instanceof HTMLElement&&e.focus()}}}}),[L]);return c.jsxs("div",{ref:g,className:"chess-board",role:"grid","aria-label":"Chess board",onClick:x,children:[Array.from({length:64},((e,t)=>{const o=Math.floor(t/8),s="white"===r?t%8:7-t%8,a=(o+s)%2==0,i=`${String.fromCharCode(97+s)}${8-o}`,u=v[i],p=d.includes(i);return c.jsx("div",{className:`square ${a?"light":"dark"} ${f===i?"selected":""} ${p?"highlighted":""}`,"data-square":i,style:n[i],onMouseDown:e=>u&&C(e,i),onClick:e=>L(e,i),role:"gridcell","aria-label":`${a?"light":"dark"} square ${i}${u?` with ${"w"===u[0]?"white":"black"} piece`:""}`,tabIndex:0,onKeyDown:e=>S(e,i),children:c.jsx("div",{className:"square-content",children:u&&c.jsx(y,{piece:u,square:i,isDragging:l.from===i})})},i)})),c.jsx("style",{children:`\n .chess-board {\n display: grid;\n grid-template-columns: repeat(8, 1fr);\n aspect-ratio: 1;\n background: #312E2B;\n position: relative;\n user-select: none;\n width: 100%;\n border: 4px solid #312E2B;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);\n touch-action: none;\n }\n\n .square {\n position: relative;\n width: 100%;\n padding-top: 100%;\n background-color: #EEEED2;\n transition: background-color 0.2s ease;\n cursor: pointer;\n }\n\n .square.dark {\n background-color: #769656;\n }\n\n .square-content {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: inherit;\n }\n\n .square.selected {\n box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5);\n }\n\n .square.drop-target {\n box-shadow: inset 0 0 0 3px rgba(0, 255, 0, 0.5);\n }\n\n .square.drop-target.selected {\n box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5),\n inset 0 0 0 6px rgba(0, 255, 0, 0.5);\n }\n\n .square:focus {\n outline: none;\n box-shadow: inset 0 0 0 3px rgba(0, 128, 255, 0.5);\n }\n\n .square.selected:focus {\n box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5),\n 0 0 0 3px rgba(0, 128, 255, 0.5);\n }\n\n .square::before {\n content: attr(data-square);\n position: absolute;\n bottom: 2px;\n left: 2px;\n font-size: 8px;\n opacity: 0.5;\n color: ${"white"===r?"#769656":"#EEEED2"};\n pointer-events: none;\n z-index: 1;\n }\n\n .square:hover .square-content::after {\n content: '';\n position: absolute;\n inset: 0;\n background: rgba(255, 255, 255, 0.1);\n pointer-events: none;\n }\n\n @media (hover: none) {\n .square:hover .square-content::after {\n display: none;\n }\n }\n\n .square.highlighted::after {\n content: '';\n position: absolute;\n inset: 0;\n background: rgba(0, 255, 0, 0.2);\n pointer-events: none;\n z-index: 1;\n }\n `})]})},e.ChessProvider=function({children:e,initialPosition:r="start",enableUndo:o=!0,onPositionChange:s,onGameEnd:a,persistState:i=!1,defaultTheme:l="default",customPieces:f=h(),preloadThemes:p=!1}){const[g]=t.useState((()=>new n.Chess("start"===r?void 0:r))),[m,y]=t.useState(g.fen()),[w,k]=t.useState([]),[b,C]=t.useState(new Map),[L,x]=t.useState(1),S=t.useRef([]),[T,E]=t.useState({}),[D,j]=t.useState(l),[M,P]=t.useState(new Set),[O,_]=t.useState(new Set),$=t.useCallback((()=>{try{const e=g.fen();y(e),k(g.history({verbose:!0}).map((e=>e.san))),x(Math.floor(g.moveNumber()/2)+1);const t=e.split(" ").slice(0,4).join(" ");if(C((e=>{const r=new Map(e);return r.set(t,(r.get(t)||0)+1),r})),null==s||s(e),g.isGameOver()){const e={winner:g.isCheckmate()?"w"===g.turn()?"black":"white":g.isDraw()?"draw":null,reason:g.isCheckmate()?"checkmate":g.isStalemate()?"stalemate":g.isInsufficientMaterial()?"insufficient-material":g.isThreefoldRepetition()?"threefold-repetition":g.isDraw()?"fifty-move-rule":null,score:g.isCheckmate()?"w"===g.turn()?"0-1":"1-0":"1/2-1/2"};null==a||a(e)}i&&localStorage.setItem("chess-game-state",JSON.stringify({fen:e,history:g.history({verbose:!0}),moveNumber:L}))}catch(e){}}),[g,s,a,i,L]),R=t.useCallback((()=>{const e=g.fen().split(" ").slice(0,4).join(" ");return(b.get(e)||0)>=3}),[g,b]),N=t.useCallback((()=>{const[,,,,e]=g.fen().split(" ");return parseInt(e)>=100}),[g]),q=t.useCallback((()=>{const e=g.board().flat().filter((e=>null!==e));if(e.length<=3){if(2===e.length)return!0;if(3===e.length){const t=e.find((e=>"k"!==(null==e?void 0:e.type)));return"b"===(null==t?void 0:t.type)||"n"===(null==t?void 0:t.type)}}return!1}),[g]),z=t.useCallback((e=>{try{return g.moves({square:e,verbose:!1}).map((e=>{if("string"==typeof e){if("O-O"===e||"O-O-O"===e){const t="w"===g.turn()?"1":"8";return"O-O"===e?`g${t}`:`c${t}`}const t=e.match(/[a-h][1-8]/);return t?t[0]:""}return""})).filter(Boolean)}catch(t){return[]}}),[g]),U=t.useCallback(((e,t,r)=>{try{return!!g.move({from:e,to:t,promotion:r})&&($(),!0)}catch(n){return!1}}),[g,$]),G=t.useCallback((()=>{if(!o)return!1;const e=g.undo();return!!e&&(S.current.push(e),$(),!0)}),[g,$,o]),I=t.useCallback((()=>{if(!o||0===S.current.length)return!1;const e=S.current.pop();if(e){if(g.move(e))return $(),!0}return!1}),[g,$,o]),F=t.useCallback((()=>{g.reset(),C(new Map),$()}),[g,$]),A=t.useCallback((()=>g.pgn()),[g]),V=t.useCallback((e=>{try{return(new n.Chess).load(e),!0}catch{return!1}}),[]),W=t.useCallback((e=>{try{return g.loadPgn(e),$(),S.current=[],!0}catch(t){return!1}}),[g,$]);t.useEffect((()=>{if(i){const t=localStorage.getItem("chess-game-state");if(t)try{const{fen:e,history:r}=JSON.parse(t);g.load(e),$()}catch(e){}}}),[i,g,$]);const Y=e=>Object.keys(d).includes(e),B=async e=>{if(!T[e]&&!M.has(e))try{P((t=>new Set([...t,e])));let t=h();if("default"===e)t=d;else{if("unicode"!==e)throw new Error(`Theme '${e}' not found`);t=u}const r={name:e,pieces:t};E((t=>({...t,[e]:r}))),_((t=>new Set([...t,e]))),j(e)}catch(t){throw t}finally{P((t=>{const r=new Set(t);return r.delete(e),r}))}},X=t.useCallback(((e,t)=>{if(!Y(e))throw new Error(`Invalid piece symbol: ${e}`);E((r=>({...r,[D]:{...r[D],pieces:{...r[D].pieces,[e]:t}}})))}),[D]),J=t.useCallback((()=>{"default"===D&&E((e=>({...e,default:{name:"default",pieces:d}})))}),[D]),H=t.useCallback((e=>{if(!Y(e))return null;const t=T[D];return t?t.pieces[e]||d[e]||null:d[e]||null}),[T,D]),K=t.useCallback((()=>Object.keys(T)),[T]),Q=t.useCallback((e=>O.has(e)),[O]);return t.useEffect((()=>{(async()=>{try{await B("default"),Object.entries(f).forEach((([e,t])=>{X(e,t)})),"default"!==l&&await B(l),p&&await Promise.all([B("unicode")])}catch(e){}})()}),[l,f,p,X]),c.jsx(v.Provider,{value:{game:g,position:m,isCheck:g.isCheck(),isCheckmate:g.isCheckmate(),isStalemate:g.isStalemate(),isDraw:g.isDraw(),isThreefoldRepetition:R(),isFiftyMoveRule:N(),isInsufficientMaterial:q(),turn:g.turn(),history:w,moveNumber:L,pgn:g.pgn(),makeMove:U,undo:G,redo:I,reset:F,getPossibleMoves:z,exportPGN:A,importPGN:W,getGameState:()=>({isCheck:g.isCheck(),isCheckmate:g.isCheckmate(),isStalemate:g.isStalemate(),isDraw:g.isDraw(),turn:"w"===g.turn()?"white":"black",moveNumber:L,halfMoves:g.moveNumber(),fen:g.fen(),pgn:g.pgn()}),validateFen:V,currentTheme:D,themes:T,loadTheme:B,getPieceSvg:H,setCustomPiece:X,resetTheme:J,preloadTheme:async e=>{O.has(e)||await B(e)},getThemeNames:K,isThemeLoaded:Q},children:e})},e.Piece=y,e.PieceProvider=function({children:e,defaultTheme:r="default",customPieces:n=h(),preloadThemes:o=!1}){const[s,a]=t.useState({default:{name:"default",pieces:d}}),[i,l]=t.useState(r),[f,p]=t.useState(new Set),[m,y]=t.useState(new Set(["default"])),v=e=>Object.keys(d).includes(e),w=async e=>{if(!s[e]&&!f.has(e)&&"default"!==e)try{p((t=>new Set([...t,e])));let t=h();if("unicode"!==e)throw new Error(`Theme '${e}' not found`);t=u;const r={name:e,pieces:t};a((t=>({...t,[e]:r}))),y((t=>new Set([...t,e]))),l(e)}catch(t){throw t}finally{p((t=>{const r=new Set(t);return r.delete(e),r}))}},k=t.useCallback(((e,t)=>{if(!v(e))throw new Error(`Invalid piece symbol: ${e}`);a((r=>({...r,[i]:{...r[i],pieces:{...r[i].pieces,[e]:t}}})))}),[i]),b=t.useCallback((()=>{"default"===i&&a((e=>({...e,default:{name:"default",pieces:d}})))}),[i]),C=t.useCallback((e=>{if(!v(e))return null;if("default"===i)return d[e]||null;const t=s[i];return t?t.pieces[e]||d[e]||null:d[e]||null}),[s,i]),L=t.useCallback((()=>Object.keys(s)),[s]),x=t.useCallback((e=>m.has(e)),[m]);return t.useEffect((()=>{(async()=>{try{await w("default"),Object.entries(n).forEach((([e,t])=>{k(e,t)})),"default"!==r&&await w(r),o&&await Promise.all([w("unicode")])}catch(e){}})()}),[r,n,o,k]),c.jsx(g.Provider,{value:{currentTheme:i,themes:s,loadTheme:w,getPieceSvg:C,setCustomPiece:k,resetTheme:b,preloadTheme:async e=>{m.has(e)||await w(e)},getThemeNames:L,isThemeLoaded:x},children:e})},e.generateFEN=e=>"",e.isValidMove=(e,t,r,n)=>!0,e.useChess=w,e.useChessGame=(e="start")=>{const[r,n]=t.useState(e),[o,s]=t.useState({isCheck:!1,isCheckmate:!1,isStalemate:!1,isDraw:!1,turn:"white",moveNumber:1,halfMoves:0,fen:e,pgn:""});return{position:r,gameState:o,makeMove:(e,t)=>!0}},e.usePieces=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
//# sourceMappingURL=index.umd.js.map