diff --git a/assets/index-BjnI3upL.js b/assets/index-DE4Of6GJ.js similarity index 89% rename from assets/index-BjnI3upL.js rename to assets/index-DE4Of6GJ.js index 1bee28f..a0e27be 100644 --- a/assets/index-BjnI3upL.js +++ b/assets/index-DE4Of6GJ.js @@ -1,8 +1,8 @@ -var go=Object.defineProperty;var me=i=>{throw TypeError(i)};var mo=(i,e,o)=>e in i?go(i,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[e]=o;var pe=(i,e,o)=>mo(i,typeof e!="symbol"?e+"":e,o),Bt=(i,e,o)=>e.has(i)||me("Cannot "+o);var st=(i,e,o)=>(Bt(i,e,"read from private field"),o?o.call(i):e.get(i)),Pt=(i,e,o)=>e.has(i)?me("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,o),Vt=(i,e,o,t)=>(Bt(i,e,"write to private field"),t?t.call(i,o):e.set(i,o),o),Xt=(i,e,o)=>(Bt(i,e,"access private method"),o);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))t(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const l of n.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&t(l)}).observe(document,{childList:!0,subtree:!0});function o(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function t(s){if(s.ep)return;s.ep=!0;const n=o(s);fetch(s.href,n)}})();var Wt,Y,Je,ht,de,We,Ht,ne,$t,te,_t={},Ge=[],po=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function rt(i,e){for(var o in e)i[o]=e[o];return i}function Ye(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function wo(i,e,o){var t,s,n,l={};for(n in e)n=="key"?t=e[n]:n=="ref"?s=e[n]:l[n]=e[n];if(arguments.length>2&&(l.children=arguments.length>3?Wt.call(arguments,2):o),typeof i=="function"&&i.defaultProps!=null)for(n in i.defaultProps)l[n]===void 0&&(l[n]=i.defaultProps[n]);return Kt(i,l,t,s,null)}function Kt(i,e,o,t,s){var n={type:i,props:e,key:o,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:s??++Je,__i:-1,__u:0};return s==null&&Y.vnode!=null&&Y.vnode(n),n}function qt(i){return i.children}function Nt(i,e){this.props=i,this.context=e}function pt(i,e){if(e==null)return i.__?pt(i.__,i.__i+1):null;for(var o;ee&&ht.sort(Ht));At.__r=0}function Le(i,e,o,t,s,n,l,r,c,a,u){var h,g,m,p,E,_=t&&t.__k||Ge,f=e.length;for(o.__d=c,Eo(o,e,_),c=o.__d,h=0;h0?Kt(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=i,s.__b=i.__b+1,n=null,(r=s.__i=_o(s,o,l,u))!==-1&&(u--,(n=o[r])&&(n.__u|=131072)),n==null||n.__v===null?(r==-1&&h--,typeof s.type!="function"&&(s.__u|=65536)):r!==l&&(r==l-1?h--:r==l+1?h++:(r>l?h--:h++,s.__u|=65536))):s=i.__k[t]=null;if(u)for(t=0;t(c!=null&&!(131072&c.__u)?1:0))for(;l>=0||r=0){if((c=e[l])&&!(131072&c.__u)&&s==c.key&&n===c.type)return l;l--}if(r=o.__.length&&o.__.push({}),o.__[i]}function H(i){return yt=1,qo($e,i)}function qo(i,e,o){var t=he(St++,2);if(t.t=i,!t.__c&&(t.__=[$e(void 0,e),function(r){var c=t.__N?t.__N[0]:t.__[0],a=t.t(c,r);c!==a&&(t.__N=[a,t.__[1]],t.__c.setState({}))}],t.__c=B,!B.u)){var s=function(r,c,a){if(!t.__c.__H)return!0;var u=t.__c.__H.__.filter(function(g){return!!g.__c});if(u.every(function(g){return!g.__N}))return!n||n.call(this,r,c,a);var h=!1;return u.forEach(function(g){if(g.__N){var m=g.__[0];g.__=g.__N,g.__N=void 0,m!==g.__[0]&&(h=!0)}}),!(!h&&t.__c.props===r)&&(!n||n.call(this,r,c,a))};B.u=!0;var n=B.shouldComponentUpdate,l=B.componentWillUpdate;B.componentWillUpdate=function(r,c,a){if(this.__e){var u=n;n=void 0,s(r,c,a),n=u}l&&l.call(this,r,c,a)},B.shouldComponentUpdate=s}return t.__N||t.__}function Et(i,e){var o=he(St++,3);!X.__s&&He(o.__H,e)&&(o.__=i,o.i=e,B.__H.__h.push(o))}function ze(i){return yt=5,Ze(function(){return{current:i}},[])}function Ze(i,e){var o=he(St++,7);return He(o.__H,e)&&(o.__=i(),o.__H=e,o.__h=i),o.__}function ko(i,e){return yt=8,Ze(function(){return i},e)}function Fo(){for(var i;i=Xe.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(Tt),i.__H.__h.forEach(ee),i.__H.__h=[]}catch(e){i.__H.__h=[],X.__e(e,i.__v)}}X.__b=function(i){B=null,ye&&ye(i)},X.__=function(i,e){i&&e.__k&&e.__k.__m&&(i.__m=e.__k.__m),Fe&&Fe(i,e)},X.__r=function(i){Ue&&Ue(i),St=0;var e=(B=i.__c).__H;e&&(zt===B?(e.__h=[],B.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.i=o.__N=void 0})):(e.__h.forEach(Tt),e.__h.forEach(ee),e.__h=[],St=0)),zt=B},X.diffed=function(i){Re&&Re(i);var e=i.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Se===X.requestAnimationFrame||((Se=X.requestAnimationFrame)||bo)(Fo)),e.__H.__.forEach(function(o){o.i&&(o.__H=o.i),o.i=void 0})),zt=B=null},X.__c=function(i,e){e.some(function(o){try{o.__h.forEach(Tt),o.__h=o.__h.filter(function(t){return!t.__||ee(t)})}catch(t){e.some(function(s){s.__h&&(s.__h=[])}),e=[],X.__e(t,o.__v)}}),qe&&qe(i,e)},X.unmount=function(i){ke&&ke(i);var e,o=i.__c;o&&o.__H&&(o.__H.__.forEach(function(t){try{Tt(t)}catch(s){e=s}}),o.__H=void 0,e&&X.__e(e,o.__v))};var be=typeof requestAnimationFrame=="function";function bo(i){var e,o=function(){clearTimeout(t),be&&cancelAnimationFrame(e),setTimeout(i)},t=setTimeout(o,100);be&&(e=requestAnimationFrame(o))}function Tt(i){var e=B,o=i.__c;typeof o=="function"&&(i.__c=void 0,o()),B=e}function ee(i){var e=B;i.__c=i.__(),B=e}function He(i,e){return!i||i.length!==e.length||e.some(function(o,t){return o!==i[t]})}function $e(i,e){return typeof e=="function"?e(i):e}function Gt(i,e){let o=0;for(let t=0;tl&&(l=c,n=r)}}else if(typeof t=="function"){let l=Number.MAX_VALUE;for(let r=0;rt)return!1;return!0}class xo{constructor(e,o,t,s,n){this.clusters=e,this.centroids=o,this.converged=t,this.iterations=s,this.distance=n}nearest(e){const o=new Array(e.length);return to(e,this.centroids,o,this.distance)}computeInformation(e){let o=this.centroids.map(t=>({centroid:t,error:0,size:0}));for(let t=0;ti.length||!Number.isInteger(e))throw new Error("K should be a positive integer smaller than the number of points")}function eo(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var o=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};o.prototype=e.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(i).forEach(function(t){var s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(o,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}),o}var Q={};const To=Object.prototype.toString;function Ut(i){const e=To.call(i);return e.endsWith("Array]")&&!e.includes("Big")}const Co=Object.freeze(Object.defineProperty({__proto__:null,isAnyArray:Ut},Symbol.toStringTag,{value:"Module"})),Qo=eo(Co);function Ao(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ut(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var o=e.fromIndex,t=o===void 0?0:o,s=e.toIndex,n=s===void 0?i.length:s;if(t<0||t>=i.length||!Number.isInteger(t))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=t||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var l=i[t],r=t+1;rl&&(l=i[r]);return l}function jo(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ut(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var o=e.fromIndex,t=o===void 0?0:o,s=e.toIndex,n=s===void 0?i.length:s;if(t<0||t>=i.length||!Number.isInteger(t))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=t||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var l=i[t],r=t+1;r1&&arguments[1]!==void 0?arguments[1]:{};if(Ut(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var o;if(e.output!==void 0){if(!Ut(e.output))throw new TypeError("output option must be an array if specified");o=e.output}else o=new Array(i.length);var t=jo(i),s=Ao(i);if(t===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var n=e.min,l=n===void 0?e.autoMinMax?t:0:n,r=e.max,c=r===void 0?e.autoMinMax?s:1:r;if(l>=c)throw new RangeError("min option must be smaller than max option");for(var a=(c-l)/(s-t),u=0;u{throw TypeError(i)};var mo=(i,e,o)=>e in i?go(i,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[e]=o;var pe=(i,e,o)=>mo(i,typeof e!="symbol"?e+"":e,o),Bt=(i,e,o)=>e.has(i)||me("Cannot "+o);var st=(i,e,o)=>(Bt(i,e,"read from private field"),o?o.call(i):e.get(i)),Pt=(i,e,o)=>e.has(i)?me("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,o),Vt=(i,e,o,t)=>(Bt(i,e,"write to private field"),t?t.call(i,o):e.set(i,o),o),Xt=(i,e,o)=>(Bt(i,e,"access private method"),o);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))t(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const l of n.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&t(l)}).observe(document,{childList:!0,subtree:!0});function o(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function t(s){if(s.ep)return;s.ep=!0;const n=o(s);fetch(s.href,n)}})();var Wt,Y,Je,ht,de,We,Ht,ne,$t,te,_t={},Ge=[],po=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function rt(i,e){for(var o in e)i[o]=e[o];return i}function Ye(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function wo(i,e,o){var t,s,n,l={};for(n in e)n=="key"?t=e[n]:n=="ref"?s=e[n]:l[n]=e[n];if(arguments.length>2&&(l.children=arguments.length>3?Wt.call(arguments,2):o),typeof i=="function"&&i.defaultProps!=null)for(n in i.defaultProps)l[n]===void 0&&(l[n]=i.defaultProps[n]);return Kt(i,l,t,s,null)}function Kt(i,e,o,t,s){var n={type:i,props:e,key:o,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:s??++Je,__i:-1,__u:0};return s==null&&Y.vnode!=null&&Y.vnode(n),n}function qt(i){return i.children}function Nt(i,e){this.props=i,this.context=e}function pt(i,e){if(e==null)return i.__?pt(i.__,i.__i+1):null;for(var o;ee&&ht.sort(Ht));At.__r=0}function Le(i,e,o,t,s,n,l,r,c,a,u){var h,g,m,p,E,_=t&&t.__k||Ge,f=e.length;for(o.__d=c,Eo(o,e,_),c=o.__d,h=0;h0?Kt(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=i,s.__b=i.__b+1,n=null,(r=s.__i=_o(s,o,l,u))!==-1&&(u--,(n=o[r])&&(n.__u|=131072)),n==null||n.__v===null?(r==-1&&h--,typeof s.type!="function"&&(s.__u|=65536)):r!==l&&(r==l-1?h--:r==l+1?h++:(r>l?h--:h++,s.__u|=65536))):s=i.__k[t]=null;if(u)for(t=0;t(c!=null&&!(131072&c.__u)?1:0))for(;l>=0||r=0){if((c=e[l])&&!(131072&c.__u)&&s==c.key&&n===c.type)return l;l--}if(r=o.__.length&&o.__.push({}),o.__[i]}function H(i){return Ut=1,qo($e,i)}function qo(i,e,o){var t=he(St++,2);if(t.t=i,!t.__c&&(t.__=[$e(void 0,e),function(r){var c=t.__N?t.__N[0]:t.__[0],a=t.t(c,r);c!==a&&(t.__N=[a,t.__[1]],t.__c.setState({}))}],t.__c=B,!B.u)){var s=function(r,c,a){if(!t.__c.__H)return!0;var u=t.__c.__H.__.filter(function(g){return!!g.__c});if(u.every(function(g){return!g.__N}))return!n||n.call(this,r,c,a);var h=!1;return u.forEach(function(g){if(g.__N){var m=g.__[0];g.__=g.__N,g.__N=void 0,m!==g.__[0]&&(h=!0)}}),!(!h&&t.__c.props===r)&&(!n||n.call(this,r,c,a))};B.u=!0;var n=B.shouldComponentUpdate,l=B.componentWillUpdate;B.componentWillUpdate=function(r,c,a){if(this.__e){var u=n;n=void 0,s(r,c,a),n=u}l&&l.call(this,r,c,a)},B.shouldComponentUpdate=s}return t.__N||t.__}function Et(i,e){var o=he(St++,3);!X.__s&&He(o.__H,e)&&(o.__=i,o.i=e,B.__H.__h.push(o))}function ze(i){return Ut=5,Ze(function(){return{current:i}},[])}function Ze(i,e){var o=he(St++,7);return He(o.__H,e)&&(o.__=i(),o.__H=e,o.__h=i),o.__}function ko(i,e){return Ut=8,Ze(function(){return i},e)}function Fo(){for(var i;i=Xe.shift();)if(i.__P&&i.__H)try{i.__H.__h.forEach(Tt),i.__H.__h.forEach(ee),i.__H.__h=[]}catch(e){i.__H.__h=[],X.__e(e,i.__v)}}X.__b=function(i){B=null,Ue&&Ue(i)},X.__=function(i,e){i&&e.__k&&e.__k.__m&&(i.__m=e.__k.__m),Fe&&Fe(i,e)},X.__r=function(i){ye&&ye(i),St=0;var e=(B=i.__c).__H;e&&(zt===B?(e.__h=[],B.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.i=o.__N=void 0})):(e.__h.forEach(Tt),e.__h.forEach(ee),e.__h=[],St=0)),zt=B},X.diffed=function(i){Re&&Re(i);var e=i.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Se===X.requestAnimationFrame||((Se=X.requestAnimationFrame)||bo)(Fo)),e.__H.__.forEach(function(o){o.i&&(o.__H=o.i),o.i=void 0})),zt=B=null},X.__c=function(i,e){e.some(function(o){try{o.__h.forEach(Tt),o.__h=o.__h.filter(function(t){return!t.__||ee(t)})}catch(t){e.some(function(s){s.__h&&(s.__h=[])}),e=[],X.__e(t,o.__v)}}),qe&&qe(i,e)},X.unmount=function(i){ke&&ke(i);var e,o=i.__c;o&&o.__H&&(o.__H.__.forEach(function(t){try{Tt(t)}catch(s){e=s}}),o.__H=void 0,e&&X.__e(e,o.__v))};var be=typeof requestAnimationFrame=="function";function bo(i){var e,o=function(){clearTimeout(t),be&&cancelAnimationFrame(e),setTimeout(i)},t=setTimeout(o,100);be&&(e=requestAnimationFrame(o))}function Tt(i){var e=B,o=i.__c;typeof o=="function"&&(i.__c=void 0,o()),B=e}function ee(i){var e=B;i.__c=i.__(),B=e}function He(i,e){return!i||i.length!==e.length||e.some(function(o,t){return o!==i[t]})}function $e(i,e){return typeof e=="function"?e(i):e}function Gt(i,e){let o=0;for(let t=0;tl&&(l=c,n=r)}}else if(typeof t=="function"){let l=Number.MAX_VALUE;for(let r=0;rt)return!1;return!0}class xo{constructor(e,o,t,s,n){this.clusters=e,this.centroids=o,this.converged=t,this.iterations=s,this.distance=n}nearest(e){const o=new Array(e.length);return to(e,this.centroids,o,this.distance)}computeInformation(e){let o=this.centroids.map(t=>({centroid:t,error:0,size:0}));for(let t=0;ti.length||!Number.isInteger(e))throw new Error("K should be a positive integer smaller than the number of points")}function eo(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var o=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};o.prototype=e.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(i).forEach(function(t){var s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(o,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}),o}var Q={};const To=Object.prototype.toString;function yt(i){const e=To.call(i);return e.endsWith("Array]")&&!e.includes("Big")}const Co=Object.freeze(Object.defineProperty({__proto__:null,isAnyArray:yt},Symbol.toStringTag,{value:"Module"})),Qo=eo(Co);function Ao(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!yt(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var o=e.fromIndex,t=o===void 0?0:o,s=e.toIndex,n=s===void 0?i.length:s;if(t<0||t>=i.length||!Number.isInteger(t))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=t||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var l=i[t],r=t+1;rl&&(l=i[r]);return l}function jo(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!yt(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var o=e.fromIndex,t=o===void 0?0:o,s=e.toIndex,n=s===void 0?i.length:s;if(t<0||t>=i.length||!Number.isInteger(t))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=t||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var l=i[t],r=t+1;r1&&arguments[1]!==void 0?arguments[1]:{};if(yt(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var o;if(e.output!==void 0){if(!yt(e.output))throw new TypeError("output option must be an array if specified");o=e.output}else o=new Array(i.length);var t=jo(i),s=Ao(i);if(t===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var n=e.min,l=n===void 0?e.autoMinMax?t:0:n,r=e.max,c=r===void 0?e.autoMinMax?s:1:r;if(l>=c)throw new RangeError("min option must be smaller than max option");for(var a=(c-l)/(s-t),u=0;u=0&&o?` ${ve(i,e-1)}`:ve(i,e)).padEnd(e)}function ve(i,e){let o=i.toString();if(o.length<=e)return o;let t=i.toFixed(e);if(t.length>e&&(t=i.toFixed(Math.max(0,e-(t.length-e)))),t.length<=e&&!t.startsWith("0.000")&&!t.startsWith("-0.000"))return t;let s=i.toExponential(e);return s.length>e&&(s=i.toExponential(Math.max(0,e-(s.length-e)))),s.slice(0)}function Do(i,e){i.prototype.add=function(t){return typeof t=="number"?this.addS(t):this.addM(t)},i.prototype.addS=function(t){for(let s=0;s>t);return this},i.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s>t.get(s,n));return this},i.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},i.prototype.rightShift=function(t){return typeof t=="number"?this.rightShiftS(t):this.rightShiftM(t)},i.prototype.rightShiftS=function(t){for(let s=0;s>>t);return this},i.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s>>t.get(s,n));return this},i.rightShift=function(t,s){return new e(t).rightShift(s)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let t=0;tt)throw new RangeError("Row index out of range")}function ot(i,e,o){let t=o?i.columns:i.columns-1;if(e<0||e>t)throw new RangeError("Column index out of range")}function ft(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function gt(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function ce(i,e){if(!$.isAnyArray(e))throw new TypeError("row indices must be an array");for(let o=0;o=i.rows)throw new RangeError("row indices are out of range")}function ae(i,e){if(!$.isAnyArray(e))throw new TypeError("column indices must be an array");for(let o=0;o=i.columns)throw new RangeError("column indices are out of range")}function oe(i,e,o,t,s){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Mt("startRow",e),Mt("endRow",o),Mt("startColumn",t),Mt("endColumn",s),e>o||t>s||e<0||e>=i.rows||o<0||o>=i.rows||t<0||t>=i.columns||s<0||s>=i.columns)throw new RangeError("Submatrix indices are out of range")}function Yt(i,e=0){let o=[];for(let t=0;t=n)throw new RangeError("min must be smaller than max");let r=n-s,c=new v(e,o);for(let a=0;at?(n=!0,t=o):(s=!1,n=!0);e++}return s}isReducedEchelonForm(){let e=0,o=0,t=-1,s=!0,n=!1;for(;et?(n=!0,t=o):(s=!1,n=!0);for(let l=o+1;le.get(s,t)&&(s=n);if(e.get(s,t)===0)t++;else{e.swapRows(o,s);let n=e.get(o,t);for(let l=t;l=0;)if(e.maxRow(s)===0)s--;else{let n=0,l=!1;for(;no[t]&&(o[t]=this.get(t,s));return o}case"column":{const o=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let t=0;to[s]&&(o[s]=this.get(t,s));return o}case void 0:{let o=this.get(0,0);for(let t=0;to&&(o=this.get(t,s));return o}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){ut(this);let e=this.get(0,0),o=[0,0];for(let t=0;te&&(e=this.get(t,s),o[0]=t,o[1]=s);return o}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const o=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let t=0;to&&(o=this.get(e,t));return o}maxRowIndex(e){et(this,e),ut(this);let o=this.get(e,0),t=[e,0];for(let s=1;so&&(o=this.get(e,s),t[1]=s);return t}minRow(e){if(et(this,e),this.isEmpty())return NaN;let o=this.get(e,0);for(let t=1;to&&(o=this.get(t,e));return o}maxColumnIndex(e){ot(this,e),ut(this);let o=this.get(0,e),t=[0,e];for(let s=1;so&&(o=this.get(s,e),t[0]=s);return t}minColumn(e){if(ot(this,e),this.isEmpty())return NaN;let o=this.get(0,e);for(let t=1;t=t)throw new RangeError("min must be smaller than max");let s=new v(this.rows,this.columns);for(let n=0;n0&&Ve(l,{min:o,max:t,output:l}),s.setRow(n,l)}return s}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:o=0,max:t=1}=e;if(!Number.isFinite(o))throw new TypeError("min must be a number");if(!Number.isFinite(t))throw new TypeError("max must be a number");if(o>=t)throw new RangeError("min must be smaller than max");let s=new v(this.rows,this.columns);for(let n=0;nt||o<0||o>=this.columns||t<0||t>=this.columns)throw new RangeError("Argument out of range");let s=new v(e.length,t-o+1);for(let n=0;n=this.rows)throw new RangeError(`Row index out of range: ${e[n]}`);s.set(n,l-o,this.get(e[n],l))}return s}subMatrixColumn(e,o,t){if(o===void 0&&(o=0),t===void 0&&(t=this.rows-1),o>t||o<0||o>=this.rows||t<0||t>=this.rows)throw new RangeError("Argument out of range");let s=new v(t-o+1,e.length);for(let n=0;n=this.columns)throw new RangeError(`Column index out of range: ${e[n]}`);s.set(l-o,n,this.get(l,e[n]))}return s}setSubMatrix(e,o,t){if(e=v.checkMatrix(e),e.isEmpty())return this;let s=o+e.rows-1,n=t+e.columns-1;oe(this,o,s,t,n);for(let l=0;ltypeof e=="number")}C.random=C.rand;C.randomInt=C.randInt;C.diagonal=C.diag;C.prototype.diagonal=C.prototype.diag;C.identity=C.eye;C.prototype.negate=C.prototype.neg;C.prototype.tensorProduct=C.prototype.kroneckerProduct;var Rt,se,at;let v=(at=class extends C{constructor(o,t){super();Pt(this,Rt);pe(this,"data");if(at.isMatrix(o))Xt(this,Rt,se).call(this,o.rows,o.columns),at.copy(o,this);else if(Number.isInteger(o)&&o>=0)Xt(this,Rt,se).call(this,o,t);else if($.isAnyArray(o)){const s=o;if(o=s.length,t=o?s[0].length:0,typeof t!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n"u"&&(t=o,o=this.columns),ot(this,o,!0),t=gt(this,t);for(let s=0;s=0)for(let s=0;s=0)Vt(this,Z,new v(o,o));else if(Vt(this,Z,new v(o)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return st(this,Z).size}get rows(){return st(this,Z).rows}get columns(){return st(this,Z).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(o){return v.isMatrix(o)&&o.klassType==="SymmetricMatrix"}static zeros(o){return new this(o)}static ones(o){return new this(o).fill(1)}clone(){const o=new Jt(this.diagonalSize);for(const[t,s,n]of this.upperRightEntries())o.set(t,s,n);return o}toMatrix(){return new v(this)}get(o,t){return st(this,Z).get(o,t)}set(o,t,s){return st(this,Z).set(o,t,s),st(this,Z).set(t,o,s),this}removeCross(o){return st(this,Z).removeRow(o),st(this,Z).removeColumn(o),this}addCross(o,t){t===void 0&&(t=o,o=this.diagonalSize);const s=t.slice();return s.splice(o,1),st(this,Z).addRow(o,s),st(this,Z).addColumn(o,t),this}applyMask(o){if(o.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const t=[];for(const[s,n]of o.entries())n||t.push(s);t.reverse();for(const s of t)this.removeCross(s);return this}toCompact(){const{diagonalSize:o}=this,t=new Array(o*(o+1)/2);for(let s=0,n=0,l=0;l=o&&(s=++n);return t}static fromCompact(o){const t=o.length,s=(Math.sqrt(8*t+1)-1)/2;if(!Number.isInteger(s))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(o)}`);const n=new Jt(s);for(let l=0,r=0,c=0;c=s&&(l=++r);return n}*upperRightEntries(){for(let o=0,t=0;o=this.diagonalSize&&(t=++o)}}*upperRightValues(){for(let o=0,t=0;o=this.diagonalSize&&(t=++o)}};Z=new WeakMap;let ct=Jt;ct.prototype.klassType="SymmetricMatrix";class Ot extends ct{static isDistanceMatrix(e){return ct.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,o,t){return e===o&&(t=0),super.set(e,o,t)}addCross(e,o){return o===void 0&&(o=e,e=this.diagonalSize),o=o.slice(),o[e]=0,super.addCross(e,o)}toSymmetricMatrix(){return new ct(this)}clone(){const e=new Ot(this.diagonalSize);for(const[o,t,s]of this.upperRightEntries())o!==t&&e.set(o,t,s);return e}toCompact(){const{diagonalSize:e}=this,o=(e-1)*e/2,t=new Array(o);for(let s=1,n=0,l=0;l=e&&(s=++n+1);return t}static fromCompact(e){const o=e.length;if(o===0)return new this(0);const t=(Math.sqrt(8*o+1)+1)/2;if(!Number.isInteger(t))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const s=new this(t);for(let n=1,l=0,r=0;r=t&&(n=++l+1);return s}}Ot.prototype.klassSubType="DistanceMatrix";class it extends C{constructor(e,o,t){super(),this.matrix=e,this.rows=o,this.columns=t}}class fs extends it{constructor(e,o){ot(e,o),super(e,e.rows,1),this.column=o}set(e,o,t){return this.matrix.set(e,this.column,t),this}get(e){return this.matrix.get(e,this.column)}}class gs extends it{constructor(e,o){ae(e,o),super(e,e.rows,o.length),this.columnIndices=o}set(e,o,t){return this.matrix.set(e,this.columnIndices[o],t),this}get(e,o){return this.matrix.get(e,this.columnIndices[o])}}class ms extends it{constructor(e){super(e,e.rows,e.columns)}set(e,o,t){return this.matrix.set(e,this.columns-o-1,t),this}get(e,o){return this.matrix.get(e,this.columns-o-1)}}class ps extends it{constructor(e){super(e,e.rows,e.columns)}set(e,o,t){return this.matrix.set(this.rows-e-1,o,t),this}get(e,o){return this.matrix.get(this.rows-e-1,o)}}class ds extends it{constructor(e,o){et(e,o),super(e,1,e.columns),this.row=o}set(e,o,t){return this.matrix.set(this.row,o,t),this}get(e,o){return this.matrix.get(this.row,o)}}class ws extends it{constructor(e,o){ce(e,o),super(e,o.length,e.columns),this.rowIndices=o}set(e,o,t){return this.matrix.set(this.rowIndices[e],o,t),this}get(e,o){return this.matrix.get(this.rowIndices[e],o)}}class Ct extends it{constructor(e,o,t){ce(e,o),ae(e,t),super(e,o.length,t.length),this.rowIndices=o,this.columnIndices=t}set(e,o,t){return this.matrix.set(this.rowIndices[e],this.columnIndices[o],t),this}get(e,o){return this.matrix.get(this.rowIndices[e],this.columnIndices[o])}}class Es extends it{constructor(e,o,t,s,n){oe(e,o,t,s,n),super(e,t-o+1,n-s+1),this.startRow=o,this.startColumn=s}set(e,o,t){return this.matrix.set(this.startRow+e,this.startColumn+o,t),this}get(e,o){return this.matrix.get(this.startRow+e,this.startColumn+o)}}class _s extends it{constructor(e){super(e,e.columns,e.rows)}set(e,o,t){return this.matrix.set(o,e,t),this}get(e,o){return this.matrix.get(o,e)}}class no extends C{constructor(e,o={}){const{rows:t=1}=o;if(e.length%t!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=t,this.columns=e.length/t,this.data=e}set(e,o,t){let s=this._calculateIndex(e,o);return this.data[s]=t,this}get(e,o){let t=this._calculateIndex(e,o);return this.data[t]}_calculateIndex(e,o){return e*this.columns+o}}class tt extends C{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,o,t){return this.data[e][o]=t,this}get(e,o){return this.data[e][o]}}function Ss(i,e){if($.isAnyArray(i))return i[0]&&$.isAnyArray(i[0])?new tt(i):new no(i,e);throw new Error("the argument is not an array")}class Lt{constructor(e){e=tt.checkMatrix(e);let o=e.clone(),t=o.rows,s=o.columns,n=new Float64Array(t),l=1,r,c,a,u,h,g,m,p,E;for(r=0;rMath.abs(p[u])&&(u=r);if(u!==c){for(a=0;a=0;a--){for(c=0;cl?s.set(n,l,e.get(n,l)):n===l?s.set(n,l,1):s.set(n,l,0);return s}get upperTriangularMatrix(){let e=this.LU,o=e.rows,t=e.columns,s=new v(o,t);for(let n=0;nMath.abs(e)?(o=e/i,Math.abs(i)*Math.sqrt(1+o*o)):e!==0?(o=i/e,Math.abs(e)*Math.sqrt(1+o*o)):0}class ue{constructor(e){e=tt.checkMatrix(e);let o=e.clone(),t=e.rows,s=e.columns,n=new Float64Array(s),l,r,c,a;for(c=0;c=0;a--){for(c=0;c=0;r--){for(n=0;n=0;d--)if(p[d]!==0){for(let S=d+1;S=0;d--){if(d0;){let d,S;for(d=F-2;d>=-1&&d!==-1;d--){const b=Number.MIN_VALUE+K*Math.abs(p[d]+Math.abs(p[d+1]));if(Math.abs(f[d])<=b||Number.isNaN(f[d])){f[d]=0;break}}if(d===F-2)S=4;else{let b;for(b=F-1;b>=d&&b!==d;b--){let U=(b!==F?Math.abs(f[b]):0)+(b!==d+1?Math.abs(f[b-1]):0);if(Math.abs(p[b])<=K*U){p[b]=0;break}}b===d?S=3:b===F-1?S=1:(S=2,d=b)}switch(d++,S){case 1:{let b=f[F-2];f[F-2]=0;for(let U=F-2;U>=d;U--){let G=nt(p[U],b),A=p[U]/G,M=b/G;if(p[U]=G,U!==d&&(b=-M*f[U-1],f[U-1]=A*f[U-1]),a)for(let N=0;N=p[d+1]);){let b=p[d];if(p[d]=p[d+1],p[d+1]=b,a&&do&&n.set(u,h,e.get(u,h)/this.s[h]);let l=this.U,r=l.rows,c=l.columns,a=new v(t,r);for(let u=0;ue&&o++;return o}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return v.diag(this.s)}}function ys(i,e=!1){return i=tt.checkMatrix(i),e?new dt(i).inverse():io(i,v.eye(i.rows))}function io(i,e,o=!1){return i=tt.checkMatrix(i),e=tt.checkMatrix(e),o?new dt(i).solve(e):i.isSquare()?new Lt(i).solve(e):new ue(i).solve(e)}function Qt(i){if(i=v.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let e,o,t,s;if(i.columns===2)return e=i.get(0,0),o=i.get(0,1),t=i.get(1,0),s=i.get(1,1),e*s-o*t;if(i.columns===3){let n,l,r;return n=new Ct(i,[1,2],[1,2]),l=new Ct(i,[1,2],[0,2]),r=new Ct(i,[1,2],[0,1]),e=i.get(0,0),o=i.get(0,1),t=i.get(0,2),e*Qt(n)-o*Qt(l)+t*Qt(r)}else return new Lt(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Us(i,e){let o=[];for(let t=0;ts)return new Array(e.rows+1).fill(0);{let n=e.addRow(o,[0]);for(let l=0;le?n[l]=1/n[l]:n[l]=0;return s.mmul(v.diag(n).mmul(t.transpose()))}function Fs(i,e=i,o={}){i=new v(i);let t=!1;if(typeof e=="object"&&!v.isMatrix(e)&&!$.isAnyArray(e)?(o=e,e=i,t=!0):e=new v(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0}=o;s&&(i=i.center("column"),t||(e=e.center("column")));const n=i.transpose().mmul(e);for(let l=0;l0?s.set(n,n+1,o[n]):o[n]<0&&s.set(n,n-1,o[n])}return s}}function Vs(i,e,o,t){let s,n,l,r,c,a,u,h;for(c=0;c0;r--){for(h=0,l=0,a=0;a0&&(n=-n),e[r]=h*n,l=l-s*n,o[r-1]=s-n,c=0;ca)do{for(s=o[a],h=(o[a+1]-s)/(2*e[a]),g=nt(h,1),h<0&&(g=-g),o[a]=e[a]/(h+g),o[a+1]=e[a]*(h+g),m=o[a+1],n=s-o[a],l=a+2;l=a;l--)for(_=E,E=p,y=w,s=p*e[l],n=p*h,g=nt(h,e[l]),e[l+1]=w*g,w=e[l]/g,p=h/g,h=p*o[l]-w*s,o[l+1]=n+w*(p*s+w*o[l]),c=0;ck*R);o[a]=o[a]+q,e[a]=0}for(l=0;l=h;a--)o[a]=e.get(a,h-1)/g,c+=o[a]*o[a];for(r=Math.sqrt(c),o[h]>0&&(r=-r),c=c-o[h]*r,o[h]=o[h]-r,u=h;u=h;a--)l+=o[a]*e.get(a,u);for(l=l/c,a=h;a<=n;a++)e.set(a,u,e.get(a,u)-l*o[a])}for(a=0;a<=n;a++){for(l=0,u=n;u>=h;u--)l+=o[u]*e.get(a,u);for(l=l/c,u=h;u<=n;u++)e.set(a,u,e.get(a,u)-l*o[u])}o[h]=g*o[h],e.set(h,h-1,g*r)}}for(a=0;a=s+1;h--)if(e.get(h,h-1)!==0){for(a=h+1;a<=n;a++)o[a]=e.get(a,h-1);for(u=h;u<=n;u++){for(r=0,a=h;a<=n;a++)r+=o[a]*t.get(a,u);for(r=r/o[h]/e.get(h,h-1),a=h;a<=n;a++)t.set(a,u,t.get(a,u)+r*o[a])}}}function Ms(i,e,o,t,s){let n=i-1,l=0,r=i-1,c=Number.EPSILON,a=0,u=0,h=0,g=0,m=0,p=0,E=0,_=0,f,w,y,q,R,k,F,V,K,d,S,b,U,G,A;for(f=0;fr)&&(o[f]=s.get(f,f),e[f]=0),w=Math.max(f-1,0);w=l;){for(q=n;q>l&&(p=Math.abs(s.get(q-1,q-1))+Math.abs(s.get(q,q)),p===0&&(p=u),!(Math.abs(s.get(q,q-1))=0){for(E=h>=0?h+E:h-E,o[n-1]=V+E,o[n]=o[n-1],E!==0&&(o[n]=V-F/E),e[n-1]=0,e[n]=0,V=s.get(n,n-1),p=Math.abs(V)+Math.abs(E),h=V/p,g=E/p,m=Math.sqrt(h*h+g*g),h=h/m,g=g/m,w=n-1;w0)){for(p=Math.sqrt(p),K=q&&(E=s.get(R,R),m=V-E,p=K-E,h=(m*p-F)/s.get(R+1,R)+s.get(R,R+1),g=s.get(R+1,R+1)-E-m-p,m=s.get(R+2,R+1),p=Math.abs(h)+Math.abs(g)+Math.abs(m),h=h/p,g=g/p,m=m/p,!(R===q||Math.abs(s.get(R,R-1))*(Math.abs(g)+Math.abs(m))R+2&&s.set(f,f-3,0);for(y=R;y<=n-1&&(G=y!==n-1,y!==R&&(h=s.get(y,y-1),g=s.get(y+1,y-1),m=G?s.get(y+2,y-1):0,V=Math.abs(h)+Math.abs(g)+Math.abs(m),V!==0&&(h=h/V,g=g/V,m=m/V)),V!==0);y++)if(p=Math.sqrt(h*h+g*g+m*m),h<0&&(p=-p),p!==0){for(y!==R?s.set(y,y-1,-p*V):q!==R&&s.set(y,y-1,-s.get(y,y-1)),h=h+p,V=h/p,K=g/p,E=m/p,g=g/h,m=m/h,w=y;w=0;n--)if(h=o[n],g=e[n],g===0)for(q=n,s.set(n,n,1),f=n-1;f>=0;f--){for(F=s.get(f,f)-h,m=0,w=q;w<=n;w++)m=m+s.get(f,w)*s.get(w,n);if(e[f]<0)E=F,p=m;else if(q=f,e[f]===0?s.set(f,n,F!==0?-m/F:-m/(c*u)):(V=s.get(f,f+1),K=s.get(f+1,f),g=(o[f]-h)*(o[f]-h)+e[f]*e[f],k=(V*p-E*m)/g,s.set(f,n,k),s.set(f+1,n,Math.abs(V)>Math.abs(E)?(-m-F*k)/V:(-p-K*k)/E)),k=Math.abs(s.get(f,n)),c*k*k>1)for(w=f;w<=n;w++)s.set(w,n,s.get(w,n)/k)}else if(g<0)for(q=n-1,Math.abs(s.get(n,n-1))>Math.abs(s.get(n-1,n))?(s.set(n-1,n-1,g/s.get(n,n-1)),s.set(n-1,n,-(s.get(n,n)-h)/s.get(n,n-1))):(A=xt(0,-s.get(n-1,n),s.get(n-1,n-1)-h,g),s.set(n-1,n-1,A[0]),s.set(n-1,n,A[1])),s.set(n,n-1,0),s.set(n,n,1),f=n-2;f>=0;f--){for(d=0,S=0,w=q;w<=n;w++)d=d+s.get(f,w)*s.get(w,n-1),S=S+s.get(f,w)*s.get(w,n);if(F=s.get(f,f)-h,e[f]<0)E=F,m=d,p=S;else if(q=f,e[f]===0?(A=xt(-d,-S,F,g),s.set(f,n-1,A[0]),s.set(f,n,A[1])):(V=s.get(f,f+1),K=s.get(f+1,f),b=(o[f]-h)*(o[f]-h)+e[f]*e[f]-g*g,U=(o[f]-h)*2*g,b===0&&U===0&&(b=c*u*(Math.abs(F)+Math.abs(g)+Math.abs(V)+Math.abs(K)+Math.abs(E))),A=xt(V*m-E*d+g*S,V*p-E*S-g*d,b,U),s.set(f,n-1,A[0]),s.set(f,n,A[1]),Math.abs(V)>Math.abs(E)+Math.abs(g)?(s.set(f+1,n-1,(-d-F*s.get(f,n-1)+g*s.get(f,n))/V),s.set(f+1,n,(-S-F*s.get(f,n)-g*s.get(f,n-1))/V)):(A=xt(-m-K*s.get(f,n-1),-p-K*s.get(f,n),E,g),s.set(f+1,n-1,A[0]),s.set(f+1,n,A[1]))),k=Math.max(Math.abs(s.get(f,n-1)),Math.abs(s.get(f,n))),c*k*k>1)for(w=f;w<=n;w++)s.set(w,n-1,s.get(w,n-1)/k),s.set(w,n,s.get(w,n)/k)}for(f=0;fr)for(w=f;w=l;w--)for(f=l;f<=r;f++){for(E=0,y=l;y<=Math.min(w,r);y++)E=E+t.get(f,y)*s.get(y,w);t.set(f,w,E)}}}function xt(i,e,o,t){let s,n;return Math.abs(o)>Math.abs(t)?(s=t/o,n=o+s*t,[(i+s*e)/n,(e-s*i)/n]):(s=o/t,n=t+s*o,[(s*i+e)/n,(s*e-i)/n])}class lo{constructor(e){if(e=tt.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let o=e,t=o.rows,s=new v(t,t),n=!0,l,r,c;for(r=0;r0,s.set(r,r,Math.sqrt(Math.max(a,0))),c=r+1;c=0;c--)for(r=0;rl;m++)h=e.transpose().mmul(r).div(r.transpose().mmul(r).get(0,0)),h=h.div(h.norm()),a=e.mmul(h).div(h.transpose().mmul(h).get(0,0)),m>0&&(c=a.clone().sub(g).pow(2).sum()),g=a.clone(),t?(u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),r=t.mmul(u).div(u.transpose().mmul(u).get(0,0))):r=a;if(t){let m=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));m=m.div(m.norm());let p=e.clone().sub(a.clone().mmul(m.transpose())),E=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),_=t.clone().sub(a.clone().mulS(E.get(0,0)).mmul(u.transpose()));this.t=a,this.p=m.transpose(),this.w=h.transpose(),this.q=u,this.u=r,this.s=a.transpose().mmul(a),this.xResidual=p,this.yResidual=_,this.betas=E}else this.w=h.transpose(),this.s=a.transpose().mmul(a).sqrt(),s?this.t=a.clone().div(this.s.get(0,0)):this.t=a,this.xResidual=e.sub(a.mmul(h.transpose()))}}Q.AbstractMatrix=C;Q.CHO=lo;Q.CholeskyDecomposition=lo;Q.DistanceMatrix=Ot;Q.EVD=ro;Q.EigenvalueDecomposition=ro;Q.LU=Lt;Q.LuDecomposition=Lt;var co=Q.Matrix=v;Q.MatrixColumnSelectionView=gs;Q.MatrixColumnView=fs;Q.MatrixFlipColumnView=ms;Q.MatrixFlipRowView=ps;Q.MatrixRowSelectionView=ws;Q.MatrixRowView=ds;Q.MatrixSelectionView=Ct;Q.MatrixSubView=Es;Q.MatrixTransposeView=_s;Q.NIPALS=ho;Q.Nipals=ho;Q.QR=ue;Q.QrDecomposition=ue;Q.SVD=dt;Q.SingularValueDecomposition=dt;Q.SymmetricMatrix=ct;Q.WrapperMatrix1D=no;Q.WrapperMatrix2D=tt;Q.correlation=bs;Q.covariance=Fs;var Me=Q.default=v;Q.determinant=Qt;Q.inverse=ys;Q.linearDependencies=qs;Q.pseudoInverse=ks;Q.solve=io;Q.wrap=Ss;const mt=co;Me.Matrix&&Me.Matrix;const xe=8,xs=1/16777216,Ks=15,Ns=18,Ts=11;function Cs(i,e){i>>>=0,e>>>=0;const o=i&65535;return((i-o)*e>>>0)+o*e>>>0}class Qs{constructor(e=Date.now()){this.state=new Uint32Array(4),this.init(e),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*xs}init(e){if(!Number.isInteger(e))throw new TypeError("seed must be an integer");this.state[0]=e,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let o=1;o>>30>>>0)>>>0;this.periodCertification();for(let o=0;o>>Ns,e^=this.state[3]<As)throw new Error(`probabilities should sum to 1, but instead sums to ${r[r.length-1]}`)}if(s===!1&&t>l.length)throw new Error("size option is too large");const c=[];for(let a=0;ao[s];)s++;return s}else return Math.floor(t*i)}class fe{constructor(e=Math.random){if(typeof e=="number"){const o=new Qs(e);this.randomGenerator=o.random}else this.randomGenerator=e}choice(e,o){return typeof e=="number"?Ke(e,o,this.randomGenerator):Ke(e,o,this.randomGenerator)}random(){return this.randomGenerator()}randInt(e,o){return o===void 0&&(o=e,e=0),e+Math.floor(this.randomGenerator()*(o-e))}randomSample(e){const o=[];for(let t=0;t1){let l={dist:-1,index:-1};for(let r=0;rl.dist&&(l.dist=o[n[0]][r],l.index=r);if(n[1]=l.index,e>2)for(let r=2;rc.dist&&(c={...u})}n[r]=c.index}}return n.map(l=>i[l])}function Ys(i,e,o={}){const t=new mt(i),s=t.rows,n=new fe(o.seed),l=[],r=o.localTrials||2+Math.floor(Math.log(e)),c=n.randInt(s);l.push(t.getRow(c));let a=new mt(1,t.rows);for(let m=0;mm&&(m=q,g=y)}const p=u.get(g),E=cv.boundingRect(p),_=t.roi(E),{gridCells:f,expandedRect:w}=Zs(_,e,o);return t.delete(),s.delete(),n.delete(),l.delete(),r.delete(),c.delete(),a.delete(),u.delete(),h.delete(),_.delete(),{gridCells:f,chessboardRect:{x:E.x+w.x,y:E.y+w.y,width:w.width,height:w.height}}}function Zs(i,e,o){const t=new cv.Mat;cv.cvtColor(i,t,cv.COLOR_RGBA2GRAY);const s=new cv.Mat;cv.GaussianBlur(t,s,new cv.Size(5,5),0);const n=new cv.Mat;cv.Canny(s,n,50,150);const l=new cv.Mat;if(cv.HoughLinesP(n,l,1,Math.PI/180,80,100,50),l.rows===0)return console.log("无法检测到棋盘线条。"),{gridCells:[],expandedRect:{x:0,y:0,width:0,height:0}};const r=[],c=[];for(let I=0;I80&&c.push([j,W,P,z])}if(r.length<10||c.length<9)return console.log("线条不足,无法进行 KMeans 聚类。"),{gridCells:[],expandedRect:{x:0,y:0,width:0,height:0}};const a=r.flatMap(I=>[I[1],I[3]]),u=c.flatMap(I=>[I[0],I[2]]),h=Te(a.map(I=>[I]),10,{maxIterations:100}),g=Te(u.map(I=>[I]),9,{maxIterations:100}),m=h.centroids.map(I=>I[0]).sort((I,j)=>I-j),p=g.centroids.map(I=>I[0]).sort((I,j)=>I-j),E=Math.floor(m[0]),_=Math.ceil(m[m.length-1]),f=Math.floor(p[0]),w=Math.ceil(p[p.length-1]),y=i.roi(new cv.Rect(f,E,w-f,_-E)),q=w-f,R=_-E,k=Math.floor(q*e),F=Math.floor(R*o),V=Math.max(0,f-k),K=Math.max(0,E-F),d=Math.min(i.cols-V,q+2*k),S=Math.min(i.rows-K,R+2*F),b=i.roi(new cv.Rect(V,K,d,S)),U=10,G=9,A=Math.floor(S/U),M=Math.floor(d/G),N=[];for(let I=0;Ie}function $s(i){const e=ge(i),o=jt(e,[0,120,120],[10,255,255],[160,120,120],[179,255,255]),t=jt(e,[0,0,0],[180,255,80]),s=i.width*i.height,n=cv.countNonZero(o),l=cv.countNonZero(t),r=n/s,c=l/s;return e.delete(),o.delete(),t.delete(),r>.05?"red":c>.05?"black":"unknown"}function tn(i,e){let o;if(e==="red")o=en(i);else if(e==="black")o=on(i);else return i;const t=sn(o);let s=new cv.Mat;t.channels()===1?cv.cvtColor(t,s,cv.COLOR_GRAY2RGBA):t.channels()===3?cv.cvtColor(t,s,cv.COLOR_RGB2RGBA):s=t.clone();const n=new ImageData(new Uint8ClampedArray(s.data),s.cols,s.rows);return o.delete(),t.delete(),s.delete(),n}function en(i){const e=ge(i),o=jt(e,[0,100,100],[10,255,255],[160,100,100],[179,255,255]);return e.delete(),o}function on(i){const e=ge(i),o=jt(e,[0,0,0],[180,255,100]);return e.delete(),o}function sn(i){const e=i.clone(),o=cv.Mat.ones(3,3,cv.CV_8U);cv.morphologyEx(i,i,cv.MORPH_CLOSE,o,new cv.Point(-1,-1),2);const t=new cv.MatVector,s=new cv.Mat;if(cv.findContours(i,t,s,cv.RETR_EXTERNAL,cv.CHAIN_APPROX_SIMPLE),t.size()===0)return o.delete(),t.delete(),s.delete(),e;const n=i.cols*i.rows,l=[];for(let m=0;m=.5&&l.push({contour:p,contourArea:f,rect:E})}p.delete()}if(l.length===0)return o.delete(),t.delete(),s.delete(),e;l.sort((m,p)=>p.contourArea-m.contourArea);const r=l[0],{x:c,y:a,width:u,height:h}=r.rect,g=e.roi(new cv.Rect(c,a,u,h));return o.delete(),t.delete(),s.delete(),e.delete(),g}function ge(i){const e=cv.matFromImageData(i),o=new cv.Mat;cv.cvtColor(e,o,cv.COLOR_RGBA2RGB);const t=new cv.Mat;return cv.cvtColor(o,t,cv.COLOR_RGB2HSV),e.delete(),o.delete(),t}function Ce(i,e,o){const t=new cv.Mat;return cv.inRange(i,cv.matFromArray(1,3,cv.CV_8UC1,e),cv.matFromArray(1,3,cv.CV_8UC1,o),t),t}function jt(i,e,o,t,s){const n=Ce(i,e,o);if(t&&s){const l=Ce(i,t,s),r=new cv.Mat;return cv.bitwise_or(n,l,r),n.delete(),l.delete(),r}return n}const nn={red_king:"帥",red_guard:"仕",red_bishop:"相",red_knight:"馬",red_rook:"車",red_cannon:"炮",red_pawn:"兵",black_king:"将",black_guard:"士",black_bishop:"象",black_knight:"馬",black_rook:"車",black_cannon:"炮",black_pawn:"卒"};function rn(i,e,o){const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const s=t.getContext("2d");s.drawImage(i,0,0,t.width,t.height),s.strokeStyle="rgba(0, 255, 0, 0.5)",s.lineWidth=2,s.strokeRect(e.x,e.y,e.width,e.height);const n=e.width/9,l=e.height/10;return o.forEach(r=>{const[c,a]=r.position,u=e.x+a*n,h=e.y+c*l;if(s.strokeStyle=r.color==="red"?"rgba(255, 0, 0, 0.7)":"rgba(0, 0, 0, 0.7)",s.lineWidth=2,s.strokeRect(u,h,n,l),r.type&&r.type!=="none"){const g=`${r.color}_${ln(r.type)}`,m=nn[g]||"";s.fillStyle=r.color==="red"?"rgba(255, 50, 50, 0.9)":"rgba(50, 50, 50, 0.9)",s.font="bold 24px Arial",s.textAlign="right",s.textBaseline="bottom",s.fillText(m,u+n-5,h+l-5)}}),t}function ln(i){return{k:"king",a:"guard",b:"bishop",n:"knight",r:"rook",c:"cannon",p:"pawn",none:"none"}[i]}const hn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEfUlEQVRoBbXBAbKqSAAEsPT9D907CCjigL6t+kl81dS9+Enca2oXR7VILeIHcauG1BATtYuv4kZt4kat0rgVl2oV39WQxp2Yq1W8qVWclVTciKka0jipXZzVQ1yJiXqImVrFhxriSnyqRUzVLj4VcSHO6iFm6iA+1RBTcVKLmKo3MVGL+BTvahFT9S5mKiU+xLsipuos5mqIsziqIabqQ1yoIU7ioIipmokLNcRRxUsNMVEfUkNcqCHexFMNcVZ34kpTcRRPJT7Um9S7uFBDHMSuiLP6Ii4V8RKbIj7UJvUStYsrRbzEqohPtUo9hXqKS0U8xUMRn2oRtYlFvcS1InbxUGKijmJVL3GnxC4WRUzUU2zqKO4UsYmhpDFRm9jUm7hXxCqGImZqEbt6E98UsYqhxFzjoN7EdyVWQYnv6iR+UMRDKPFV3YhrRSxCiXv1VVwoYhFF3KjfxFQRiyjiWv0sZooYosREiUXdCWoTE0UMKTFTxKKuxEPtYqLEkBIzNURt0qiX2NVLfCqClJips6hVHNRBTJQgJWbqUrzUm5goQSqmapUiqKfY1SaGiokSpGKqhiixql2sahP1EBNFSMVMbWJTT7GoXWoVM0VIxUw9xK6eYqgPcaGEVEzUKh7qm7hRQiom6k/iVgmpmKivUpv4ooRUTNS1qIP4qoQ0Zuo38Ysi0pipg9RJ/EkRaUzVS2qRWsW7iltFpDFVJ6EWcVKLuFZEGnNF6im1iJPaxKUi0pgroYjaxEk9xaUi0rhWi9QqTuogLhWRxpV6FydF1CouFZHGVE3EQQ2pRUpcKiKNiboSmyLqKS4VkYqTuhVDDVFPca2EVBzUD1JDqKe4UUIqnupTahP1EuopbhQhFbu6Eeop1FPcKkIqNnUn1FPUU9wrQUo81ElQL6E2qV18U4KUeKiDWNS71JuU+KYIUmJRu9jUTOogviqCFDHUQzzVV/GDEkOKoIY4qE+hXuIHJRZRhBIv9Sb1EOopflFiEUWc1FHUKtSb+KbEIop4V6vUELWKmogbRSxCEUd1EOoHMVdpLEIRRzVEDVE/iw9FPARFbCq1C+pv4k0RD0ERm3oJ9XfxUsQqhiJWtQvqJeo3sStiE0MNsapFLOolFrVJXYtNEZtYFLGqIRb1Eg+1ilU9pZ7ioYbYxEMRqxqCeolVPcRBbVK7WBSxi4ca4qEeUi+xqlW8q5MYaohdrIpY1UlsakiJD/Um1BBPsSliVW9iU5uYqpeoIV5iU0Os6iA2tYs7RRRxFLsaYlVvQq1S4gdFHMVTDbGquaj4QQ1xFC81xKqG1Luo+EEN8SYOaohVLVIHUfFdLeJdHNUQmzqJiu9qESfxpobY1EE0Kr6qRZzFu6bErp7iRzXEpzgr8VK7+Ekt4lOcNSVeahW/qCFm4lMtYleL+EUNMRUTRfwPNcSFmKlF/FENcSXmahG/q0Vciyu1iu9qEzfiUu3iRj3FncadeomJeol7jXt1FJs6iW8qflCpG/FdSeMHdSl+UaTxozqJn9WQin+uFinxj9XDfzKct20QZAU8AAAAAElFTkSuQmCC",cn=Object.freeze(Object.defineProperty({__proto__:null,default:hn},Symbol.toStringTag,{value:"Module"})),an="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABoCAAAAAAxnEoHAAAE30lEQVRoBbXBCYLCRgIEMNX/H13bPjBtMJhJNlL8oKkv4kdxrx5SRL2KX8R39RTvapPGrfimHuKj2sSd+KJWcadE40Z8Upv4SQ3xVVyrVfyupGl8FFdqE39S4ou4UKv4syI+iXe1iH+k0rgWr2oRNyouVVRciFc1xJ0a4kot4k2c1SJu1SouVEq8ipMa4ge1i3eVEi9iVkP8pHZxoYY4i0kRP6pDXClxEk81xK/qEBeKmMWhhvhZDalFvG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CDXELlZF3Km/SQ3xEKtK41b9KkWKOMSmUnGnfhJKFHGIXRH36k5QQ5R4iociflC/CRWTeKghflH3QolZHGqIn9UnMdQQs3iqIf6qSA3xVEOcxKSG+D+oRZzFrIb412oRL+KkhviXahGv4qyG+FdqEW/iRVPEv1DEhXhXxD9VQ1yJd0Ua/0Qt4lJcqCH+rlZxLa7UEH9Vi/gkLtUq/qIW8VF8ULv4Qe3ii/isdvFd7eKbxhf1FNfqEN81vqvUISZ1Ejcqje8adSvulFTcqm/iB0U0flJX4jc1RMVfVDQaf1CLKPEfq1Uo8Z+qzf8AA+cGfuc6ELgAAAAASUVORK5CYII=",un=Object.freeze(Object.defineProperty({__proto__:null,default:an},Symbol.toStringTag,{value:"Module"})),fn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAADgElEQVRoBbXBCWKjSAAEMNX/H13bxAdgY9wkO1J8Vd/ElDhXq9iqjZgQZ2oVB2oVX8RndRdn6i7OxSd1F1/VTZyJY3UTk2oRJ+JI3cQFtYiP4kD9iIuKND6Id7WIX6ghjsWrWsTv1CKOxItaxK9VSryLvRriLyol3sRODfE3tYhXsVVD/FkN8SI2ijhTYkINsRerIs7UTXxVxE48FXGmnuKLpsRWPNQQZ2orTtUQG3FXQ5yrrThXYiNuaogvaifO1BCruCniq9qJMzXEU/yoIb6rrThXxEMsiphRW3GuiIdYlJhTG3GuhriLoYg5tRFfFHEXQxFzaiO+KeImKDGrNuKbIm6CErNqFd8V8SOUmFarmFDiRygxrVYxoYhFFDGtVjGhiEWUmFermFHEkCLm1SpmFDGkxAW1ihlFDClxQa1iShGkxAW1iilFkBIX1CrmlCAVV9QqduoptkqQiitqFXf1JlZFSMUVNSseipCKK2pa3BUhFdPqkrgrIRUT6jfipoRUnKrfi5sS0vis/iZuSkhjo3FXfxJU3BSRxkP9r1JxU0QaDzUhNSkaN0Wk8VTXxVat4qmINJ7qmjhUi1gVkcZTzUjdxaQi0ljVJTGpiDRWdSKG2ohJRaSxUR/ETW3EpBLS2KgDsaqNmFRCKjbqRezURkwqIRVbtRGvaiPmFCEVO/UQ72oVk4qQir1axKFaxaQipOKCWsWkEqTiglrFpBKkxLxaxZwiSIl5tYo5JYYUMa1WMacIUsSs2ohaxKkSiygxqzainuKTEosoYlJ9FoeKWEQRk+pEHCliEYr4rr6Kd0UsQhFnala8KuJHUMSRuihe1BA/giLe1HXxooibGIp4VV9EvYqdGuImhhpir34jdoq4i0URL+q62Kkh7mJRQ+zVdbFVQzzEjyJeFKkj8VQbsVXEU9wUsVfv4lD9iK0a4inuitirvbiihljFXQ2xV6u4pobYiIca4kX9iKtqiK14qiH2ahGX1RBbsaoh9kpcVovYiY0a4u9qEXuxVcSf1SJexE5T4m9qEa9ir4b4ixriXbwq8Qe1iHfxqinxWzXEkXhXi/iNGuJQHKghrqshPogjtYiLaohP4lgtYlrdxEfxSd3Ed3UXJ+KjeogT9RRnGmdqFQdqFacqvqiNuKsX8U3FhDoX35WYUkPqQMwo0phUL2JaDan452qREv9Y/fgPjkgybvNri6cAAAAASUVORK5CYII=",gn=Object.freeze(Object.defineProperty({__proto__:null,default:fn},Symbol.toStringTag,{value:"Module"})),mn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAFMklEQVRoBbXBC3KkSgIEMOX9D51bxa+BBo/9IlaKf6p/iN+Jn9VHnNVJ/EL8pD7iQZEa4p/iXW3iJ7WKf4g3tYp/qyEVP4lntYrfKSnxg3hSq/iDmuJVPKgp/qqGeBNfahE/K3FTpPEs7mqKH9UmrmqIR3FTU/yoPuKiFvEtrmqIn9VFXFRKfImzmmLTeFKiPuKipriLsyIORdxVDPURFzXFTRqHIj5qiJvGVB9xVVMcaoiPGuKkpjhrLOojvhRxEYca4qwW8aC+xEdT4ix2NcRFreJLPYldDXEWmxriqjZxV4/iUMRJrIr4Upu4qhexqyE+YlXElxpSxFl9pM7iUMQhFkV8q12c1SFqSG1iV8QhpiIe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UqvtS3VFwVcYhVERe1im91FxUXNcQhNkVc1BRP6ltc1BAfsakhzmqKZ3URNzXESexqiLMa4kWdxVUNcRaHGuKsxKv6iKua4iw+aoizxk9qExofNcVFnNQQv1eb0DjUFFdxVsRf1CIah5riJi5qiD+oKU5qiru4akr8RQ1pbGqIb3FTxN+U2NUU3+KuKfEnFZsa4kl8qyn+g5riUTwo4j+oIV7Ek5rij2qIN/GspviDGuJdvKlV/Ftt4l3jVe3iB3WInzR+Uod4Uh/xo4qf1Vls6ib+ocQvVOoH8U9F/EZTb+IXakjjl+oufquGVPzf1ZQS/2e1+B/JLhl7oCCiRAAAAABJRU5ErkJggg==",pn=Object.freeze(Object.defineProperty({__proto__:null,default:mn},Symbol.toStringTag,{value:"Module"})),dn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEhklEQVRoBbXBW4KiQAAEsNT9D13bvAQUlPnYJB6o7+KR+KFe4qR28UCsKj7VS1yoITXEL7FqfKhZGt/UIr6LW7WI32pI45u4UYt4pqTii7hUi3iupHEvrtQk/qiGuBOfahZ36iVOirgRH2oSN+osjioal+JNTeJafYqTmsSneFNDXKor8aZS8SFOahKbxkvdiDc1xLs4KWJXYlYvqdQu3tUQb1KxqSEOaghKUIsUqVl8qCF2ReyKOKlJFDGrIbWJKzXESbzUEGe1iUUNqdQkrlUqjmJTxLvaxKIWKeJWDXEQm0rjXc1SsahFSnxRQ+xiVcSHGlJiUZMo4qsa4iUWNcSHWsWkjuK7Il5iVkN8qlUMdRZf1RCbmBVxoSZpUB/iuyJWMSniSg2pUBfiqyJWMSniShEVdSW+K2IRQ4lrRVTUlfihxCKGEpdqiIq6FN8VMQtKXKshFepK/FDELChxrYZUqKPULH4pYhJK3KghFepT/FbEJJS4UYtQL6lZPFFiEkXcqEVQmzQlniliiBJ3ahGbWsVTJYYocaMW8VKreKrEkBJ3ahGbOooniiAl7tQiFvUuHihBStypRczqQvxUgpS4UasY6lL8VIJU3KlVqDvxSxFScadWoe7ETyWk4k4tQr1LzeK3ElJxpxahVqmTeKCEVNyoVVCr1C4eKSEVN2oV1Ca1ioeKSMWNWsVQq9QsHisiFTdqFZOSeok/KJGKGzWk4qU28Rcl0rhTQyo2tYm/KCKNOzWkYlUvsatNXCsijTtFVMzqIOpSXCgijTu1iKGeig9FpHGnFqH+It4UkcadWqT+KM6KSONOLVJ/FSdFpHGrZqkrcVa7OCkiFXdqEmoWlRriQu3iqIg07tUk1ElcqV0clZCKWzXEUEdxpQ5iV4RU3CtiVlKLuFIHsStCKr4o8VKzlHhXR7ErQUo8VEdxVkexK0FKPFQf4qUO4qAEKfFMXYlFHcRBEaSIn+pWzGoXRyWGFPFLfRGT2sVBiUkUcaFmMalvQu3iqMQkihiKWNVBqFVqErULtYujEpMoYqinYlGrUC9xVMQkFEE9FJtaRL3ESRGTUMRQB1Gh3sVZY6iXOCpiFhRBncSkTuJabeKkiFlQBLUKGos6iGv1EkdFLGIogpqkcVKbuFGbOCliEUMRQ03iTS2CIt7VJo6KWMWkiKGG+FDErIizeomDGmIVsyKGIo0vaoij2sRREZuYFTEp4ptaxKYmUeKghtjEoohnahdqERUHNcRLrIp4pq5Exa6G2MWqhnimPqVxVEMcxKaGeKbepeKoiKN4KeKh+hS7msRR7GqIh4rUKiVeahIncVBDPFS7qNjVEGdxVMRTtYkSm5rEmzipIR6qg9jUJN7FWVPioSIVFS9FfIo3RRrP1CwVmxriU3wq8VBN0ljVEFfiQg3xSE1iUZO4FBeKeKiIRQ1xI67UJB6pWNQQd+JaTeKxpoa4F3dqEb/VKr6IW7WJL+olvopvahcXahffNb6r1Ess6l38UvFAfRe/lTR+q1vxSJGKZ+pdPFakxH9XQ4r4z2ryDw7EyW7nu7OBAAAAAElFTkSuQmCC",wn=Object.freeze(Object.defineProperty({__proto__:null,default:dn},Symbol.toStringTag,{value:"Module"})),En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABoCAAAAAAxnEoHAAAEY0lEQVR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ipgFRUzqKy7UKt4oYhEUMatZXKtFvFFDLGIo4qVaxBtFrGJSxDu1iBdqiFVMininFvGshviISQ3xSi3iUQ3xFbMa4o1axKMa4isWRbxRi3hSQ/yJVREv1CIe1BAb8VHEs5rFgxpiKz5qiEc1i3s1xE581RBPahb3aoid+FNDPKhZ3KlJ7MVGDXGvZnGjJnEQWzXErZrFtZrEUew0RdyoWVyqSfyIoyKu1Swu1RC/4kTFtZrEhRriTPwqaVypIS7UEKfiVw1xpYY409QQ5+JEDXGhhjhTQ1yJUzWkcaKG+FWTuBTnilT8KuKgUUPciCu1ioMSW7WKO41r9RFbFX/qK241btWfWJWY1EY8qHhQB6Gpg3hS0nhUO6G24lmRihfqT6iPeKWGlHir/sQ/qEmK+J/VLDXE/6tm/wHk3KtvFxNciwAAAABJRU5ErkJggg==",_n=Object.freeze(Object.defineProperty({__proto__:null,default:En},Symbol.toStringTag,{value:"Module"})),Sn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEdklEQVRoBbXBCRKbSAAEMPX/H90ZwAeYATtbGyl1Ekf1Tfwi9SEOaid2ai++Sh3EQT2kYqJILeKoqdQmSO3FXi3ii6Y2cVRPQWondmoVv6hNHJU0FaReYqdW8auKEkeNp9RTvNWQxkkRU40iLqQe4q0WcVJPcdbUEHOpTbzUIs7qLSaaGmImtYqXGmKmdmKqhphILeKlhpirnZiqVJylhnipIa7UIoq41DhLEU9F3Ki3uFBDfEqJlxriRj3FpRriQypeirhVT3Gthngr0nipIW7VQczVEAfxVsQ39SFmaoi9eCnim1qk3mKmhtiJpxrii5qImRriLR5qiFs1F1M1xEs8FHGjLsVcES+xKeJK3YoLRTzFqogrdScu1RAPsSriSn2Ieog7RTzEoohrdZRaxTdFbGIo4k4dpfGTGmIVQxG36kP8pohVUMQXtZOK3xSxCoq4VQcpQT3FlSIWoYg7tQnqSkwVsQhFXKtVrOpSTBUxhBLXahEPtUhNxEwRQxRxpRaxqU00JdRezJQYosSVIh7qKQ11FhMlhihxoYhNvUXNxVkRpIi5EpvaSQ3xUG8xUYKUmCuxqoOUeKu3OCtBSkyVWNVRSrzVW5yVIBVTRSxqIl5qJ86KkIqpIoYihgq1iZfaRImJElIxU0NQxFPtxKpWUWKmhFTM1Col3movFvUWM0WkYqZe4qEeohYx1FtMFZGKmXqJTb2kpGKol5grIhUztUnFUB9SsainuFBEKqbqKaiDUGlQL3GhiFTM1VPURCzqKa4UkYoL9RB1kCJWNaTEpSJScaU2UXspYlOkxLUiUnGlNjHUQWxqEzeKSMWlWsVDvcSmSIkbRaTiWq1iU29BPcWdIlJxrVaxqLmUuFNEGjdqFUNdi1tFpOJGLYJ6i9qLe0Wk4kYtQh0FtYkvikjFjVpEHaVe4psSUnGjJlJP8YMipOJOnaRW8aMSpMSNOkkN8bMipMSNmoq/UIKUuFMz8aFe4kMJUsSd+nuxUwQp4l6JVf0o3oogRfyk/kY8FDFEEV/UXuoHsSliiCJu1H8UqyKGKOJKTYT6LhY1xBCKOKsLqZ/EoohFKOKo/g9BDbEIiljVj+KsPgRFrIIiVnWWOou5eopFDbGKoYhF3Qj1ENdqEYsiNjHUEEPNxaYe4idFPMSiiEUNqb14qU38pIZ4iEUNsagPsVOb+EkRT7GqIRa1E0e1iV/UEE+xKWJVD3FSm/hBDfESD0V8U5v4roZ4i4ca4ovaxFc1xE481RD3ahNf1RA78VLEvdrEF7WIvXgr4laREl/UEAfxVkPcKVLiXg1xFDs1xI1axa1axIc4qCGulVTcqUV8ioNaxKWSihu1iJP4UIu4UFJxqVZxFp9qEXMlFVdqETNxUquYqSEu1CqmYqJWcVZDTNUm5mKmVnFWaczUKq7EXG3iQxEntYlrcalWcVDiU23iTlyqTRo7FR9qE7fiTj2kMdOoh7jXuFcHsamDNL5qfFdfxA8qje/qUvympOI39Sl+VqTEP1dDivjHavEHY5a9buolYuEAAAAASUVORK5CYII=",yn=Object.freeze(Object.defineProperty({__proto__:null,default:Sn},Symbol.toStringTag,{value:"Module"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xrLlpcreYv8jVkEZeW8ynfFhM5qfmLhdzSCOvLIf5lA/LvJE55WqIRn6anOYhD8s0mpvmJqc55WKIRr6Z3MyXPCxzajIPWRjyzRCNXI2c5kkeltGcMocWFoZ8M0RGLoaYJy1PRsvcZTksDLmaQ2TkYl7JwzJac5OHhZFv5hANuZgX8mw0N5ncLYxczSE0h1zMT3k2mrtcDLmaQ2gOuZif8mkZzSnfDLkacsiQq/mm5dMymnxYPg25GnLIHPJkzTctn5aR08hp5DCHXMwhhzDyZM03LReTkS8j5tDybHITc8iToXnS8mkxTX6aQ8uXtZZTrJFnE0bm1PJpMS0fhtzMIcunNS2nHEaejbCsNVmuRsyXHOaQ5dNaPuQ08mXExGKyXM17Wb5My00Oc8iXkU+T5cti3svyMIfc5bBGXllMlvfWwtzF8jDykJshLywmy5PlwzJhzYc8mUM+5G7khcVkeWn5MJlTvqwhH3Iz5IXFZHm2nJZPa80py92ylofcrCE/LCbfTZZnoyFf1pCH3K2RHxaj5e/mlE9DnuTDmrw0h/zVMmS5WUO+5MMa8sIc8guj5dOQJ3lYQ14Y8ndrstzMTZ7k0xpytRjyC5PlZhm5yJc15IchvzAtd3PKRZ6sId8N+TdDy1WerZGrNflHc8o3uVhzyLMh/2IOLd/lam7ybORfDHkh36zR8p+tOeSF/DCHlv9mTZZX8tPc5D9YRstLeWFO+XdzaPJaXptT/ska8l5eW3OTX5rmJm/ljblr+YV5yB/krfmSP5uGlj/KH0zmLm/NTZa/yJ8tc5EP803+Kn8zr8R8iJFfyC/MH2Tkd/I7c9U0Dfm9/JP5kn+X/6v8X/0Phhh8i1Cy6vcAAAAASUVORK5CYII=",Rn=Object.freeze(Object.defineProperty({__proto__:null,default:Un},Symbol.toStringTag,{value:"Module"})),qn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABrCAAAAACz/eiUAAAFdklEQVRoBb3BCRabSgIEMNX9D13TzWKDwUuSeV+KH9R38Yv4qn4T38VndRIndRLfxCe1icYb9RSfxXu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xVEN8VISUuKijUESjiJOKL4ogKi7qRjRKvKj4rAiixIumFqmnaDQV31U8FUGUeFGbaAxFNIr4QeOphiBKnDW1CBoU0dQQP2g81RCEEie1iqlBiaaG+K7EQw1BFHHU1CIWDSpqEd81jYcihijirBaxatBoaojvmsauhhiiKXFUUzwVoab4QdPYFDEFJU5qiBdNTfFVU7FpSkyhKbFr1BQvmpriBxWbpmlMQRGbRg1x0dQUv2gaU9M0FkFTcVBDvGpqih9UGotKYxE0JaaGCo2LphbxXaUxNEUsYihiaChxrzbxVmPRWNUQqxhqCA0lGncaRSjxSYWGksYmVvUQjVsNJYaa4qnEpogGlcYmVrVLxRsNRXxWQ0wVT7FoahfvNagh3qlVDBUHsWpKfNWYakjjoDHUIhU1xVPsiviqsagpHuokKNJ4iocivqt4qBtpTDXEQeyaEj+peGiaEmc1xUkclPhZEbcqFGkcxVERf6JWUVNqCJoiTuKkxP9FU2mcxVkR/66pNF7EUS3iXxVpvIqTRhH/pIY0LuJVScXfa0oaV/GiKan4S40St+Kihvg7tYh7cauG+CuVxr24U6v4I5Wa4o24V1P8rkQN8Va80RSp+ElFDfFBvNXUIr5qFKn4JD6oXXxUUzQ+i0/qRZzUUyq+ic/qjdSUGqLiB/FdpW6kFtE0fhG/KKFeBCV+Fr+rmBpUSvyZ+GM1ROPPxX8q/lP/A9zVYIqTjIeUAAAAAElFTkSuQmCC",kn=Object.freeze(Object.defineProperty({__proto__:null,default:qn},Symbol.toStringTag,{value:"Module"})),Fn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABsCAAAAACu+NgsAAAE+klEQVRoBb3BC3bqSgLAQGn/i9a0P4DbNoTkvjNV8o34TL4kP4mvyDfksziSp7iQH8kH8SK34kh+IO/FTj6KF/lI3okH+ULs5AN5I1YmX4qdvCW3YiO/Eit5R27ERn4tFvKGXMVK/iJWcksuYiV/Eyu5Iyexkj+LldyQWazkX8RCrmQSC/lObOQkFnIhR7GQl0DeiBeZxELO5CAWchAgt+J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MiYGMgsEkqNMVgIxyFFmLOQlHkw+SA4CZCUQCznIWMkkBpPvxSAbWQTIJFZyFCCz2MitQJ5kESBHsZGjkKckOcmQozDZySJAZrEweQrZJV8J5EU2YXIQBpK8ZPIbgRzIKgPkJSFkkvxSgDzJJpOzkH+RAfIiDyFnyb8JkBfZZYBMkn8QYHIgDxkmT0nI3wUmR/IUYPIUIH8UEshEjgL5b8RCZnKQgfwXAgyZySyQfxdgciYnAfKPMkwuZBaDyT/IQO7ISQYmf5aEyQ05ywD5qwxM7shFLEz+IAlMbsmNGOT3MlZyT27FYMgvJAQm78itMFbypYRYyFvyRjzIF2IlyQfyXjzIZ4GxkI/kg8BYmLwTGCv5gXyWxEoyeQrjxZAfyU/iwbglBPIF+Vl8IIR8Sb4TM1mF/Ib8QsaL/J78X8n/1f8Am9IOixOlrIUAAAAASUVORK5CYII=",bn=Object.freeze(Object.defineProperty({__proto__:null,default:Fn},Symbol.toStringTag,{value:"Module"})),Vn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABsCAAAAACu+NgsAAAF5klEQVRoBb3BSWLjRgAEMNT/H13p5k6JsuU5BIhv1M/iS/Gr+kZ8I35RpzQ29S5+FT+pUzypq/hFfFaH+Ent4mfxSe3iV7VJ4wfxQW3iS7WJj+JRbeI3tQi1iU/iSa3iV7ULtYoP4l2t4nd1CmqRxpN4U4sYivhBnWKqRTyJVzXFohbxSZ1iUYt4EC9qik2t4lldxKoW8SbuaopdreJZHdLY1CJexVVNcVGreFSHNHa1iBdxUVNc1S4e1EWcaoq7uKghbuoQ72pILeKqhriJUw1xUxfxrtLUFHc1xFXsaoqruol3jaYWcVNDXMWuhriqu3hSqUXc1RAXsakpTvUqHjW1iBc1xCk2RZzqTTyq1BRvijjFqoY41Jt4VqkpStzUELtY1BCHpq7is0aR2sSphtjFVFPs6iZ+UilSQ5oShxpiE1MNsatFahE/qtQUtYtNDbGJqYhDXcQvKvUmNjXEKoYiTo1axaqGeFKvUsSmhljEU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VNDfKV28UENsQhqiF1N8ZXaxQc1xCKGGmJTU3yldvGshljFUENsaorv1Cae1RCrmGqITRFfqk08qiE2MdUUqyK+VJt4UlNsYlFDbCq+Vqt4UkPsYlVD/INaxYOaYhermuIf1CIe1BCH2NQUf1dTvKspTrGrKf6spnhXU5ziUFP8WQ3xpqa4iFNN8Vc1xKua4ipOtYg/qiFe1BQ3cVGL+Jsa4q6muIurmuJvirirKV7ETU3xJ0Vc1SJexV1N8SclLmoRb+JVDfGtRomLWsS7eFNTfKdR4lSLeBAPaoivNEocaopH8aSG+E6JXS3iWTyqKb5QxKoW8Uk8q0X8qoipVvFRfFCH+EkJdYjP4qM6xWeVOsRP4id1ikd1FT+LX9SraKh38Zv4TX0pfhdfaOoX8ZX4Sv0gvhZ/UK/S+Iv4X8X/6j/OzIuL68bXyAAAAABJRU5ErkJggg==",vn=Object.freeze(Object.defineProperty({__proto__:null,default:Vn},Symbol.toStringTag,{value:"Module"})),In="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG8AAABsCAAAAABBOrMSAAAFg0lEQVRoBb3BSYKkRgAEMMX/Hx1OloKEWnsOluIX9UX8KL6r79L4RXxWV7GpF+Kr+KhO8UrN4ov4oA7xQZ3io3irHuKr2qXxQbxTu/hN7eK9eK028Qe1i3fipdrE39Qm3ogXahN/V5t4KZ7VKv5NreKVuKtV/KY2cahVvBA3tYrf1CEOtYoncVOLODVeq6s41Cru4qIWMSnxQt3FqRZxF7NaxKyIu3ohJjXETUxqEbNaxKrEql6IiyKu4lSLuKhVLIqgblLEVQ1xEYdaxEXtYqhF6iY1xE0NMYtDDXFVuxjqENRF3NUQk3ioIW7qIYZ6CGoWz4qYxK6GuKlDDLWLoVYp4pUa4hSbWsRNHWKoXQx1ipdqiENsaoibOsVQu6BO8UYRh1jVEDc1iaF2oSbxRg3xEIsa4q4mMdQm1EW8UUPsYlFD3NQshtqk7uKNInYx1BB3NYlFvRXvlNjFUEPc1CQW9V68U8QmqCHuapMSq3ov3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JXa1iFPsahGrpob4rq6iYleLOMVDLWLVVBo/qLvY1SImcahFrGqIX9RV7GoRszjVEJuKHzVNPcSuFnERp1rFX1XULja1iKuY1Cr+qlG7WNUibmJWq/ireohVLeIuLmoRf1abWNQqnsRVLeKvahOLWsSzuKsh/qqGWNQqXogntYg/KrGoVbwSL9QQ/6YW8Vq8UkP8g1rFG/FSLeKPahVvxWu1it/VLt6LN+oQ39VDfBJv1Sk+qkN8FJ/UKV6qSXwTn9VVDA31LL6Kb+pH8YP4QVOfxY/iJ/VB/C7+oG6i8Sfx/4r/13856SmLbWlT4gAAAABJRU5ErkJggg==",Mn=Object.freeze(Object.defineProperty({__proto__:null,default:In},Symbol.toStringTag,{value:"Module"})),xn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABqCAAAAAB4oTsxAAAEb0lEQVRoBb3BC5KDVgIEMPX9D937wGCD+XmS1Erxi3oSP4lH9Zt4FvdqJ3ZqJ57EndqIc/UR9+JareJBreJOXKlV/KAWcSPO1SJ+Vi9xKU7VS/xJzeJKnKiXOFUvcVSzOBdHNYkrtYqDeokzcVCzuFarOKhZnIhvNYk79RHfahZH8aUmcas24qAmcRB7NYlbtRVHNYlvsVWzuFV7caKG+BIbNYlb9S1O1CT2YqOGuFUHcaqG2ImPGuJOnYkzNYmteKshbtRBijhVk9iIVU3iUh2EpnGhJvERixriSp2IBzXERyxqiHN1Kp7UEG/xUkOcqi+hhjQe1BCrmNUQp2onSmoST2qIVcyKOFVboUQRP6ghFjGpIU7VVlQ0flVDLGKoSZyqL/EnNcRLDEVcqK34syJeghriQr3FlxriXg0xC2qIC/UWO7WKOzXEJCjiSn3ERm3EtRpiEhRxpTbirXbiUg0xCUVcqq1Y1Je4VEMMUUNcq42Y1FFcqiGGqCFu1Eeoc3GpiCGKuFe/iCs1BKkh7tUv4koNQWqIe/WLuFQEKeJB/SIuFUGKuFc/iUs1hBRxrw6ivsS1GkKKuFd7oQ7iRhFS4kFtpc7EnSKkxIP6CEWonbhThJS4V6uYNA21E7dqiJS4V4vQ0BhqJ27VEClxqxah4qV24l4NkRK36iVKvNROPKghUuJOLaLES71FxYMaIiXu1CI0ZvUWKp7UEClxpxbRmNVHaDyqIVLiTi2iMamPUPGohkiJO/URQ30EjWc1RCpu1UdQqZf4WQ2Rilv1FtRHKo1f1BCpuFVvUVtR0nhWQ6TEnXpLPYpTRUiJW7WRehYHRUiJW/VPxE4RUuJa/VOxVYSUOKp/L95qCCmxqiH1H4lVEaSIWf2XUmJRBCliUrNQp6KuhfoSiyJIEZP6z8VLDUEUMdSP4q0uhIpFDUEUMdSD2Ksb0VjUEEMUMdSlOFFbsVNiVUMMUUMMdRTXGr8pYhKKGGov/hs1xCTUENRHzIr4l4qYhRpiUkN8FHGqPuJOEbNQkzhRxEcRL7UTV4p4CWqIo6bErBaxqL04V8RLDEUc1CyGeom9WqVxpoZ4iaGG+FIHcVCrNI5qiEUMNYmtSr2kZnGm3uKohljErIi92otT9RHfaohVzGqIj6Z24qi+xJcijVW81BBvTW3FUR3EXg3xFi9NEataBBVn6lvs1BAfsaghVvUSRVyovdiqITZiVUMsmpqkxLXaiY2axEasahKrGlJp3Kit+CjS2Iq3GmLRKClxqz7ioyaxEx81iVmjpMS9eou3msRebNQkJk3N4kkt4q1msRdbNYlJvcSTSk1iVZP4Fjs1iUlN4lnNYlWTOIi9msVQxA9qEquaxFF8qVn8RRGrIo0T8a1m8Q/VLM7EQc3in6iXOBVnahJ/VYs4F6dqiL+pl7gUp2oVP6pVXIoL9RaP6i1uxKVaxb16i1txoz7iXG3Eg7hX31IX4lE8qB/FD+JZPYrfxE/qUvxB/EFtpdH4k/i/iv+r/wEEcJN6pgU6cwAAAABJRU5ErkJggg==",Kn=Object.freeze(Object.defineProperty({__proto__:null,default:xn},Symbol.toStringTag,{value:"Module"})),Nn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG8AAABsCAAAAABBOrMSAAAFa0lEQVRoBb3BR4IjRwADMPD/j6arc5Q0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EURUsRDLeKsoc7S+JMipIiHWsRFU4uoIY1d7eKqhpAiHmoRV7VLkTqLTcVJDSE1xF0t4oNKzeKDxq6GkBrirmbx1CihhrioVdBY1RCkhripRdw0FbP6LjQWNQSpIW5qEZ/UT1ExK2KIGuKqFrErsai/icasiCEUcVWLmFWs6iw1iaGhpM5iqCGGUMRVreKirlKpQyxqE0MNMYQa4qJ2sahdTGoRJ0UMtYihiEmoIS7qENQuhhI1xEOJSRHUEJOghjipReomaBqNIt7VIoYaYhJDESeNGlJnocSmxG81xCyGGuJQi2ioIYaKkxI/NSUWMdQQh1qExq5x0Wj8UkMsYlJD7GoRVFDirvFbEZuYFbGrRXzU0Gj8UEOsYlZDbJqaxEeNisZ3NYlVLGqIVVOT+KrR+KomsYlFTWLRqCG+qWh8U5PYxaqGWDRqiG8qGt/UEIdY1SQWjSK+qfiuSOMQm5rErKHiq0rji5rESexqErOm4rtK44sa4iwONYlZEV9VGh/VJC7ipCYxa/xQaXxSs7iIs5rE31QaH9QsruKsZvEnJT6oIR7iqob4g6bEu5rEQ9zUEL81JV7VJJ7irob4gxIvahYv4qFm8UMRTzWLN/GihvihaTzUIl7Fm5rEv6tFvIt3NYl/U4v4JN7VLP6uNvFRfFKb+K128UV8VCfxTe3iq/imDvGmTtL4IX6ou5jUU/wUv9SrUIdU/EH8Qf0UfxN/U5/F38U/qJto/JP4f8X/6z8dVxuL55I6qgAAAABJRU5ErkJggg==",Tn=Object.freeze(Object.defineProperty({__proto__:null,default:Nn},Symbol.toStringTag,{value:"Module"})),Cn=Object.assign({"/assets/chess_templates/black_bishop.png":cn,"/assets/chess_templates/black_cannon.png":un,"/assets/chess_templates/black_guard.png":gn,"/assets/chess_templates/black_king.png":pn,"/assets/chess_templates/black_knight.png":wn,"/assets/chess_templates/black_pawn.png":_n,"/assets/chess_templates/black_rook.png":yn,"/assets/chess_templates/red_bishop.png":Rn,"/assets/chess_templates/red_cannon.png":kn,"/assets/chess_templates/red_guard.png":bn,"/assets/chess_templates/red_king.png":vn,"/assets/chess_templates/red_knight.png":Mn,"/assets/chess_templates/red_pawn.png":Kn,"/assets/chess_templates/red_rook.png":Tn});function Qn(i,e){const o=new cv.Mat;return cv.resize(i,o,new cv.Size(e[0],e[1])),o}async function An(i=[60,60]){var o;const e={};for(const[t,s]of Object.entries(Cn)){const n=(o=t.split("/").pop())==null?void 0:o.split(".")[0];if(n){const l=new Image;l.src=s.default,await new Promise(u=>{l.onload=u});const r=cv.imread(l),c=new cv.Mat;cv.cvtColor(r,c,cv.COLOR_RGBA2GRAY);const a=Qn(c,i);e[n]=a,r.delete(),c.delete()}}return e}function jn(i,e,o){let t=-1,s="none";const n=[i.cols,i.rows],l=new cv.Mat;i.channels()===4?cv.cvtColor(i,l,cv.COLOR_RGBA2GRAY):i.channels()===3?cv.cvtColor(i,l,cv.COLOR_RGB2GRAY):i.copyTo(l);const r=Object.entries(e).filter(([a,u])=>o==="red"?a.startsWith("red_"):o==="black"?a.startsWith("black_"):!0);for(const[a,u]of r){const h=new cv.Mat;cv.resize(u,h,new cv.Size(n[0],n[1]));const g=new cv.Mat;cv.matchTemplate(l,h,g,cv.TM_CCOEFF_NORMED);const m=cv.minMaxLoc(g);if(m.maxVal>t){t=m.maxVal;const p={king:"k",guard:"a",bishop:"b",knight:"n",rook:"r",cannon:"c",pawn:"p"},E=a.split("_")[1];s=p[E]||"none"}h.delete(),g.delete()}return l.delete(),t>.3?s:"none"}function Jn({onImageUpload:i}){const e=ze(null);return x("section",{className:"upload-section",children:[x("h2",{children:"上传图片"}),x("input",{ref:e,type:"file",onChange:s=>{var l;const n=(l=s.target.files)==null?void 0:l[0];if(n){const r=new FileReader;r.onload=c=>{var u;const a=new Image;a.onload=()=>i(a),a.src=(u=c.target)==null?void 0:u.result},r.readAsDataURL(n)}},accept:"image/*",style:{display:"none"}}),x("button",{onClick:()=>{var s;(s=e.current)==null||s.click()},children:"选择图片"})]})}const Wn=360;function Gn({overlayImageSrc:i,chessboardRect:e={x:0,y:0,width:0,height:0},originalImageSize:o={width:0,height:0}}){const s=Math.max(0,e.x-15),n=Math.max(0,e.y-15),l=Math.min(o.width-s,e.width+2*15),r=Math.min(o.height-n,e.height+2*15),c=Math.min(1,Wn/Math.max(l,r)),a=o.width/l,u=l*c,h=r*c,g=u*a,m=(u-g)/2;return x("section",{className:"board-result-section",children:[x("h2",{children:"分析结果"}),x("div",{className:"image-container",style:{width:`${u}px`,paddingBottom:`${h}px`},children:x("img",{src:i,alt:"分析结果",className:"overlay-image",style:{left:`${m}px`,width:`${g}px`,height:`${o.height*c}px`,marginTop:`${-n*c}px`}})})]})}function Yn({fenCode:i,onCopy:e}){return x("div",{className:"fen-section",children:[x("h2",{children:"FEN代码"}),x("div",{className:"fen-container",children:[x("input",{type:"text",value:i,readOnly:!0}),x("button",{onClick:e,children:"复制"})]})]})}const Qe={k:"将",a:"士",b:"象",n:"馬",r:"車",c:"砲",p:"卒",K:"帥",A:"仕",B:"相",N:"傌",R:"車",C:"炮",P:"兵"};function On({fen:i,bestMove:e}){const[o,t]=H([]),s=ze(null),[n,l]=H(1);Et(()=>{const u=r(i);t(u)},[i]),Et(()=>{s.current&&(c(),e&&a(e))},[o,e]),Et(()=>{function u(){if(s.current){const g=window.innerWidth*.8,m=8*40+40,p=Math.min(1,g/m);l(p)}}return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);function r(u){const h=u.split(" ")[0].split("/"),g=[];for(let m of h){const p=[];for(let E of m)if(isNaN(parseInt(E))){const _=E===E.toUpperCase()?"red":"black",f=E.toLowerCase();p.push({color:_,type:f})}else{const _=parseInt(E);for(let f=0;f<_;f++)p.push(null)}g.push(p)}return g}function c(){const u=s.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const g=40,m=g/2,p=8*g+2*m,E=9*g+2*m;u.width=p*n,u.height=E*n,h.scale(n,n),h.fillStyle="#f0d9b5",h.fillRect(0,0,u.width,u.height),h.strokeStyle="#000",h.lineWidth=1;for(let w=0;w<=9;w++)h.beginPath(),h.moveTo(m,w*g+m),h.lineTo(p-m,w*g+m),h.stroke();for(let w=0;w<=8;w++)h.beginPath(),h.moveTo(w*g+m,m),h.lineTo(w*g+m,4*g+m),h.stroke(),h.beginPath(),h.moveTo(w*g+m,5*g+m),h.lineTo(w*g+m,E-m),h.stroke();h.beginPath(),h.moveTo(m,4*g+m),h.lineTo(m,5*g+m),h.stroke(),h.beginPath(),h.moveTo(p-m,4*g+m),h.lineTo(p-m,5*g+m),h.stroke(),h.font='18px "KaiTi", "楷体", sans-serif',h.fillStyle="rgba(0, 0, 0, 0.5)",h.textAlign="center",h.textBaseline="middle",h.fillText("楚 河",2*g+m,4.5*g+m),h.fillText("漢 界",6*g+m,4.5*g+m),h.beginPath(),h.moveTo(3*g+m,m),h.lineTo(5*g+m,2*g+m),h.moveTo(5*g+m,m),h.lineTo(3*g+m,2*g+m),h.moveTo(3*g+m,7*g+m),h.lineTo(5*g+m,9*g+m),h.moveTo(5*g+m,7*g+m),h.lineTo(3*g+m,9*g+m),h.stroke();function _(w,y,q=!1){if(!h)return;const R=g*.15,k=-g*.25;h.strokeStyle="rgba(0, 0, 0, 0.4)",h.lineWidth=1,(!q||w

p/2)&&(h.beginPath(),h.moveTo(w+R+k,y-k),h.lineTo(w+R+k,y-R-k),h.lineTo(w+k,y-R-k),h.stroke(),h.beginPath(),h.moveTo(w+R+k,y+k),h.lineTo(w+R+k,y+R+k),h.lineTo(w+k,y+R+k),h.stroke())}_(1*g+m,2*g+m),_(7*g+m,2*g+m),_(1*g+m,7*g+m),_(7*g+m,7*g+m);for(let w=0;w<5;w++){const y=w===0||w===4;_(2*w*g+m,3*g+m,y),_(2*w*g+m,6*g+m,y)}h.font="14px Arial",h.textAlign="center",h.textBaseline="middle",h.fillStyle="rgba(0, 0, 0, 0.4)";const f=["一","二","三","四","五","六","七","八","九"];for(let w=0;w<9;w++)h.fillText(f[w],(8-w)*g+m,E-m/2);for(let w=0;w<9;w++)h.fillText((9-w).toString(),(8-w)*g+m,m/2);o.forEach((w,y)=>{w.forEach((q,R)=>{if(q){const k=R*g+m,F=y*g+m,V=g*.4;h.beginPath(),h.arc(k+2,F+2,V,0,Math.PI*2),h.fillStyle="rgba(0, 0, 0, 0.3)",h.fill(),h.beginPath(),h.arc(k,F,V,0,Math.PI*2),h.fillStyle=q.color==="red"?"#ffcccc":"#e0e0e0",h.fill(),h.strokeStyle=q.color==="red"?"#c00000":"#000000",h.lineWidth=2,h.stroke(),h.fillStyle=q.color==="red"?"#c00000":"#000000",h.font='bold 25px "LiSu", "隶书", "STKaiti", "楷体", "KaiTi", "SimKai", sans-serif',h.textAlign="center",h.textBaseline="middle";const K=q.type.toUpperCase(),d=q.color==="red"?Qe[K]:Qe[K.toLowerCase()];h.fillText(d,k,F-V*.12)}})})}function a(u){const h=s.current;if(!h)return;const g=h.getContext("2d");if(!g)return;const m=40,p=m/2,[E,_]=u.match(/.{2}/g)||[];if(!E||!_)return;const f=E.charCodeAt(0)-97,w=9-parseInt(E[1]),y=_.charCodeAt(0)-97,q=9-parseInt(_[1]),R=f*m+p,k=w*m+p,F=y*m+p,V=q*m+p;g.beginPath(),g.moveTo(R,k),g.lineTo(F,V),g.strokeStyle="rgba(0, 0, 255, 0.7)",g.lineWidth=3,g.stroke();const K=Math.atan2(V-k,F-R);g.beginPath(),g.moveTo(F,V),g.lineTo(F-15*Math.cos(K-Math.PI/6),V-15*Math.sin(K-Math.PI/6)),g.lineTo(F-15*Math.cos(K+Math.PI/6),V-15*Math.sin(K+Math.PI/6)),g.closePath(),g.fillStyle="rgba(0, 0, 255, 0.7)",g.fill()}return x("div",{style:{width:"100%",display:"flex",justifyContent:"center"},children:x("canvas",{ref:s,className:"chessboard",style:{maxWidth:"80vw",height:"auto"}})})}function Ln(i,e){const[o,t]=i.trim().split(/\s+/),s=o.split("/");if(s.length!==10)throw new Error("无效的 FEN:行数不正确");const n=[];for(const q of s){const R=[];for(const k of q)if(k>="1"&&k<="9"){const F=parseInt(k,10);for(let V=0;V{let R="",k=0;for(const F of q)F?(k>0&&(R+=k.toString(),k=0),R+=F):k+=1;return k>0&&(R+=k.toString()),R}).join("/")} ${_} - - 0 1`}function Ae(i,e){const o={K:"帅",A:"仕",B:"相",N:"马",R:"车",C:"炮",P:"兵",k:"将",a:"士",b:"象",n:"马",r:"车",c:"炮",p:"卒"},t="abcdefghi",s=["零","一","二","三","四","五","六","七","八","九"],[n]=i.trim().split(/\s+/),l=n.split("/"),r=[];for(const w of l){const y=[];for(const q of w)if(q>="1"&&q<="9"){const R=parseInt(q,10);for(let k=0;k="A"&&g<="Z",p=o[g],E=m?s[9-c]:` ${c+1} `;let _="",f="";return c===u?(_=m?a>h?"进":"退":ah?"进":"退":a{const E=r[p];let _="";try{_=Ae(E,m)}catch(f){_="Error",console.error(`Error converting move to notation: ${f}`)}return x("span",{className:"move-item",children:_},p)}),h=i==="red_wins"||i==="black_wins",g=i==="red_wins"?"红方胜":i==="black_wins"?"黑方胜":"";return x("div",{className:"solution-section",children:[x("h2",{children:"解法展示"}),x("div",{className:"chessboard-display",children:x(On,{fen:l,bestMove:h?"":i})}),x("div",{className:"solution-controls",children:[x("button",{onClick:s,disabled:n.length===0,children:"上一步"}),x("button",{onClick:t,disabled:e||!i||h,children:"下一步"})]}),x("div",{className:"solution-debug",children:[e&&x("p",{children:"正在计算最佳走法..."}),o&&x("p",{style:{color:"red"},children:o}),!h&&i&&x("p",{children:[c,"最佳走法:",Ae(l,i)," (第 ",a," ","步)"]}),h&&x("p",{style:{fontWeight:"bold",color:"green"},children:g})]}),x("div",{className:"move-list",children:u})]})}function Bn(i,e){return{k:e==="red"?"K":"k",a:e==="red"?"A":"a",b:e==="red"?"B":"b",n:e==="red"?"N":"n",r:e==="red"?"R":"r",c:e==="red"?"C":"c",p:e==="red"?"P":"p",none:""}[i]}function Pn(i,e="red"){const o=[];for(const l of i){let r=0,c="";for(const a of l)if(a==="none")r++;else{r>0&&(c+=r.toString(),r=0);const[u,h]=a.split("_");c+=Bn(h,u)}r>0&&(c+=r.toString()),o.push(c),console.log(`FEN row: ${c}`)}const n=`${o.join("/")} ${e==="red"?"w":"b"} - - 0 1`;return console.log(`Generated FEN: ${n}`),n}const Xn="modulepreload",zn=function(i){return"/xiangqi-analysis/"+i},je={},Zn=function(e,o,t){let s=Promise.resolve();if(o&&o.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),r=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.allSettled(o.map(c=>{if(c=zn(c),c in je)return;je[c]=!0;const a=c.endsWith(".css"),u=a?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=a?"stylesheet":Xn,a||(h.as="script"),h.crossOrigin="",h.href=c,r&&h.setAttribute("nonce",r),document.head.appendChild(h),a)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function n(l){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=l,window.dispatchEvent(r),!r.defaultPrevented)throw l}return s.then(l=>{for(const r of l||[])r.status==="rejected"&&n(r.reason);return e().catch(n)})};class Hn{constructor(){this.engineReady=!1,this.currentResolve=null}async initEngine(){if(!this.engineReady)try{const e=await Zn(()=>import("./pikafish-ZteQ764f.js"),[]),o=e.default||e;window.Pikafish=o,this.engineInstance=await o({locateFile:t=>t==="pikafish.data"?`/xiangqi-analysis/wasm/data/${t}`:`/xiangqi-analysis/wasm/${t}`}),await this.engineInstance.ready,this.engineInstance.read_stdout=t=>{console.log("> ",t);const s=t.match(/bestmove\s(\S+)/);s&&this.currentResolve&&(this.currentResolve(s[1]),this.currentResolve=null)},this.engineInstance.send_command("uci"),this.engineReady=!0}catch(e){console.error("Failed to initialize Pikafish:",e)}}async getBestMove(e,o=14){if(!this.engineReady)throw new Error("Engine is not ready");return new Promise((t,s)=>{try{this.currentResolve=n=>{if(n==="(none)"){const r=e.split(" ")[1];t(r==="b"?"red_wins":"black_wins")}else t(n)},this.engineInstance.send_command(`position fen ${e}`),this.engineInstance.send_command(`go depth ${o}`),setTimeout(()=>{this.currentResolve&&(s(new Error("Engine timeout")),this.currentResolve=null)},5e3)}catch(n){s(n)}})}}function $n(){const[i,e]=H(""),[o,t]=H(""),[s,n]=H([]),[l,r]=H(null),[c,a]=H(""),[u,h]=H(!1),[g,m]=H(null),[p,E]=H([]),[_,f]=H(null),[w,y]=H(),[q,R]=H(),k=Number(localStorage.getItem("depth"))||14,[F,V]=H(k);Et(()=>{(async()=>{await new Promise(I=>{cv.onRuntimeInitialized=I}),console.log("OpenCV.js is ready");try{const I=await An();if(Object.keys(I).length===0){console.error("No templates were successfully loaded");return}f(I)}catch(I){console.error("Error loading templates:",I)}const N=new Hn;await N.initEngine(),r(N)})()},[]);const K=(M,N)=>{R({width:M.width,height:M.height});const{gridCells:I,chessboardRect:j}=zs(M);console.log("Original image size:",M.width,M.height),console.log("Detected chessboard rect:",j);const W={x:Math.max(0,j.x),y:Math.max(0,j.y),width:Math.min(j.width,M.width-j.x),height:Math.min(j.height,M.height-j.y)};console.log("Adjusted chessboard rect:",W),y(W);const P=[];for(let J=0;JArray(9).fill("none"));P.forEach(J=>{const[L,D]=J.position;J.type!==null&&(T[L][D]=`${J.color}_${J.type}`)});const O=Pn(T,"red");t(O),n([O])};Et(()=>{o&&l&&b(o)},[o,l,F]);const d=()=>{navigator.clipboard.writeText(o)},S=M=>{V(M),localStorage.setItem("depth",M.toString())},b=ko(async M=>{if(l){h(!0),m(null);try{const N=await l.getBestMove(M,F);if(a(N),N==="red_wins"||N==="black_wins"){h(!1);return}}catch(N){m(`Error: ${N.message}`)}finally{h(!1)}}},[l,F]);return x(qt,{children:[x("header",{children:x("h1",{children:"象棋棋盘识别与分析"})}),x("main",{className:"app-container",children:x("div",{className:"content-wrapper",children:[x("div",{className:"left-column",children:x(Dn,{bestMove:c,loading:u,error:g,onNextMove:async()=>{if(!c||c==="red_wins"||c==="black_wins"){m("No valid move available");return}const M=Ln(o,c);t(M),n(N=>[...N,M]),E(N=>[...N,c]),a("")},onPreviousMove:()=>{if(s.length>1){const M=s.slice(0,-1),N=p.slice(0,-1),I=M[M.length-1];n(M),E(N),t(I),a("")}},moveHistory:p,fenCode:o,fenHistory:s})}),x("div",{className:"right-column",children:[x(Jn,{onImageUpload:M=>{_?(n([]),E([]),a(""),m(null),K(M,_)):console.error("Templates not loaded yet")}}),x(Gn,{overlayImageSrc:i,chessboardRect:w,originalImageSize:q}),x(Yn,{fenCode:o,onCopy:d}),x("div",{className:"depth-control-section",children:[x("h2",{children:"搜索深度控制"}),x("div",{className:"depth-slider-container",children:[x("label",{htmlFor:"depth-slider",children:["当前深度: ",F]}),x("input",{id:"depth-slider",type:"range",min:"10",max:"30",value:F,onChange:M=>{M.target instanceof HTMLInputElement&&S(Number(M.target.value))}})]})]})]})]})}),x("footer",{children:x("p",{children:["© 2024 象棋棋盘识别与分析系统 | Powered by ",x("a",{href:"https://github.com/official-pikafish/Pikafish",children:" Pikafish"})," | ",x("a",{href:"https://github.com/iFwu/xiangqi-analysis",children:"GitHub 源码仓库"})]})})]})}Uo(x($n,{}),document.getElementById("app")); +${oo}`)}function Lo(i,e,o){return(i>=0&&o?` ${ve(i,e-1)}`:ve(i,e)).padEnd(e)}function ve(i,e){let o=i.toString();if(o.length<=e)return o;let t=i.toFixed(e);if(t.length>e&&(t=i.toFixed(Math.max(0,e-(t.length-e)))),t.length<=e&&!t.startsWith("0.000")&&!t.startsWith("-0.000"))return t;let s=i.toExponential(e);return s.length>e&&(s=i.toExponential(Math.max(0,e-(s.length-e)))),s.slice(0)}function Do(i,e){i.prototype.add=function(t){return typeof t=="number"?this.addS(t):this.addM(t)},i.prototype.addS=function(t){for(let s=0;s>t);return this},i.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s>t.get(s,n));return this},i.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},i.prototype.rightShift=function(t){return typeof t=="number"?this.rightShiftS(t):this.rightShiftM(t)},i.prototype.rightShiftS=function(t){for(let s=0;s>>t);return this},i.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s>>t.get(s,n));return this},i.rightShift=function(t,s){return new e(t).rightShift(s)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let t=0;tt)throw new RangeError("Row index out of range")}function ot(i,e,o){let t=o?i.columns:i.columns-1;if(e<0||e>t)throw new RangeError("Column index out of range")}function ft(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function gt(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function ce(i,e){if(!$.isAnyArray(e))throw new TypeError("row indices must be an array");for(let o=0;o=i.rows)throw new RangeError("row indices are out of range")}function ae(i,e){if(!$.isAnyArray(e))throw new TypeError("column indices must be an array");for(let o=0;o=i.columns)throw new RangeError("column indices are out of range")}function oe(i,e,o,t,s){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Mt("startRow",e),Mt("endRow",o),Mt("startColumn",t),Mt("endColumn",s),e>o||t>s||e<0||e>=i.rows||o<0||o>=i.rows||t<0||t>=i.columns||s<0||s>=i.columns)throw new RangeError("Submatrix indices are out of range")}function Yt(i,e=0){let o=[];for(let t=0;t=n)throw new RangeError("min must be smaller than max");let r=n-s,c=new v(e,o);for(let a=0;at?(n=!0,t=o):(s=!1,n=!0);e++}return s}isReducedEchelonForm(){let e=0,o=0,t=-1,s=!0,n=!1;for(;et?(n=!0,t=o):(s=!1,n=!0);for(let l=o+1;le.get(s,t)&&(s=n);if(e.get(s,t)===0)t++;else{e.swapRows(o,s);let n=e.get(o,t);for(let l=t;l=0;)if(e.maxRow(s)===0)s--;else{let n=0,l=!1;for(;no[t]&&(o[t]=this.get(t,s));return o}case"column":{const o=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let t=0;to[s]&&(o[s]=this.get(t,s));return o}case void 0:{let o=this.get(0,0);for(let t=0;to&&(o=this.get(t,s));return o}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){ut(this);let e=this.get(0,0),o=[0,0];for(let t=0;te&&(e=this.get(t,s),o[0]=t,o[1]=s);return o}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const o=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let t=0;to&&(o=this.get(e,t));return o}maxRowIndex(e){et(this,e),ut(this);let o=this.get(e,0),t=[e,0];for(let s=1;so&&(o=this.get(e,s),t[1]=s);return t}minRow(e){if(et(this,e),this.isEmpty())return NaN;let o=this.get(e,0);for(let t=1;to&&(o=this.get(t,e));return o}maxColumnIndex(e){ot(this,e),ut(this);let o=this.get(0,e),t=[0,e];for(let s=1;so&&(o=this.get(s,e),t[0]=s);return t}minColumn(e){if(ot(this,e),this.isEmpty())return NaN;let o=this.get(0,e);for(let t=1;t=t)throw new RangeError("min must be smaller than max");let s=new v(this.rows,this.columns);for(let n=0;n0&&Ve(l,{min:o,max:t,output:l}),s.setRow(n,l)}return s}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:o=0,max:t=1}=e;if(!Number.isFinite(o))throw new TypeError("min must be a number");if(!Number.isFinite(t))throw new TypeError("max must be a number");if(o>=t)throw new RangeError("min must be smaller than max");let s=new v(this.rows,this.columns);for(let n=0;nt||o<0||o>=this.columns||t<0||t>=this.columns)throw new RangeError("Argument out of range");let s=new v(e.length,t-o+1);for(let n=0;n=this.rows)throw new RangeError(`Row index out of range: ${e[n]}`);s.set(n,l-o,this.get(e[n],l))}return s}subMatrixColumn(e,o,t){if(o===void 0&&(o=0),t===void 0&&(t=this.rows-1),o>t||o<0||o>=this.rows||t<0||t>=this.rows)throw new RangeError("Argument out of range");let s=new v(t-o+1,e.length);for(let n=0;n=this.columns)throw new RangeError(`Column index out of range: ${e[n]}`);s.set(l-o,n,this.get(l,e[n]))}return s}setSubMatrix(e,o,t){if(e=v.checkMatrix(e),e.isEmpty())return this;let s=o+e.rows-1,n=t+e.columns-1;oe(this,o,s,t,n);for(let l=0;ltypeof e=="number")}C.random=C.rand;C.randomInt=C.randInt;C.diagonal=C.diag;C.prototype.diagonal=C.prototype.diag;C.identity=C.eye;C.prototype.negate=C.prototype.neg;C.prototype.tensorProduct=C.prototype.kroneckerProduct;var Rt,se,at;let v=(at=class extends C{constructor(o,t){super();Pt(this,Rt);pe(this,"data");if(at.isMatrix(o))Xt(this,Rt,se).call(this,o.rows,o.columns),at.copy(o,this);else if(Number.isInteger(o)&&o>=0)Xt(this,Rt,se).call(this,o,t);else if($.isAnyArray(o)){const s=o;if(o=s.length,t=o?s[0].length:0,typeof t!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n"u"&&(t=o,o=this.columns),ot(this,o,!0),t=gt(this,t);for(let s=0;s=0)for(let s=0;s=0)Vt(this,Z,new v(o,o));else if(Vt(this,Z,new v(o)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return st(this,Z).size}get rows(){return st(this,Z).rows}get columns(){return st(this,Z).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(o){return v.isMatrix(o)&&o.klassType==="SymmetricMatrix"}static zeros(o){return new this(o)}static ones(o){return new this(o).fill(1)}clone(){const o=new Jt(this.diagonalSize);for(const[t,s,n]of this.upperRightEntries())o.set(t,s,n);return o}toMatrix(){return new v(this)}get(o,t){return st(this,Z).get(o,t)}set(o,t,s){return st(this,Z).set(o,t,s),st(this,Z).set(t,o,s),this}removeCross(o){return st(this,Z).removeRow(o),st(this,Z).removeColumn(o),this}addCross(o,t){t===void 0&&(t=o,o=this.diagonalSize);const s=t.slice();return s.splice(o,1),st(this,Z).addRow(o,s),st(this,Z).addColumn(o,t),this}applyMask(o){if(o.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const t=[];for(const[s,n]of o.entries())n||t.push(s);t.reverse();for(const s of t)this.removeCross(s);return this}toCompact(){const{diagonalSize:o}=this,t=new Array(o*(o+1)/2);for(let s=0,n=0,l=0;l=o&&(s=++n);return t}static fromCompact(o){const t=o.length,s=(Math.sqrt(8*t+1)-1)/2;if(!Number.isInteger(s))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(o)}`);const n=new Jt(s);for(let l=0,r=0,c=0;c=s&&(l=++r);return n}*upperRightEntries(){for(let o=0,t=0;o=this.diagonalSize&&(t=++o)}}*upperRightValues(){for(let o=0,t=0;o=this.diagonalSize&&(t=++o)}};Z=new WeakMap;let ct=Jt;ct.prototype.klassType="SymmetricMatrix";class Ot extends ct{static isDistanceMatrix(e){return ct.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,o,t){return e===o&&(t=0),super.set(e,o,t)}addCross(e,o){return o===void 0&&(o=e,e=this.diagonalSize),o=o.slice(),o[e]=0,super.addCross(e,o)}toSymmetricMatrix(){return new ct(this)}clone(){const e=new Ot(this.diagonalSize);for(const[o,t,s]of this.upperRightEntries())o!==t&&e.set(o,t,s);return e}toCompact(){const{diagonalSize:e}=this,o=(e-1)*e/2,t=new Array(o);for(let s=1,n=0,l=0;l=e&&(s=++n+1);return t}static fromCompact(e){const o=e.length;if(o===0)return new this(0);const t=(Math.sqrt(8*o+1)+1)/2;if(!Number.isInteger(t))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const s=new this(t);for(let n=1,l=0,r=0;r=t&&(n=++l+1);return s}}Ot.prototype.klassSubType="DistanceMatrix";class it extends C{constructor(e,o,t){super(),this.matrix=e,this.rows=o,this.columns=t}}class fs extends it{constructor(e,o){ot(e,o),super(e,e.rows,1),this.column=o}set(e,o,t){return this.matrix.set(e,this.column,t),this}get(e){return this.matrix.get(e,this.column)}}class gs extends it{constructor(e,o){ae(e,o),super(e,e.rows,o.length),this.columnIndices=o}set(e,o,t){return this.matrix.set(e,this.columnIndices[o],t),this}get(e,o){return this.matrix.get(e,this.columnIndices[o])}}class ms extends it{constructor(e){super(e,e.rows,e.columns)}set(e,o,t){return this.matrix.set(e,this.columns-o-1,t),this}get(e,o){return this.matrix.get(e,this.columns-o-1)}}class ps extends it{constructor(e){super(e,e.rows,e.columns)}set(e,o,t){return this.matrix.set(this.rows-e-1,o,t),this}get(e,o){return this.matrix.get(this.rows-e-1,o)}}class ds extends it{constructor(e,o){et(e,o),super(e,1,e.columns),this.row=o}set(e,o,t){return this.matrix.set(this.row,o,t),this}get(e,o){return this.matrix.get(this.row,o)}}class ws extends it{constructor(e,o){ce(e,o),super(e,o.length,e.columns),this.rowIndices=o}set(e,o,t){return this.matrix.set(this.rowIndices[e],o,t),this}get(e,o){return this.matrix.get(this.rowIndices[e],o)}}class Ct extends it{constructor(e,o,t){ce(e,o),ae(e,t),super(e,o.length,t.length),this.rowIndices=o,this.columnIndices=t}set(e,o,t){return this.matrix.set(this.rowIndices[e],this.columnIndices[o],t),this}get(e,o){return this.matrix.get(this.rowIndices[e],this.columnIndices[o])}}class Es extends it{constructor(e,o,t,s,n){oe(e,o,t,s,n),super(e,t-o+1,n-s+1),this.startRow=o,this.startColumn=s}set(e,o,t){return this.matrix.set(this.startRow+e,this.startColumn+o,t),this}get(e,o){return this.matrix.get(this.startRow+e,this.startColumn+o)}}class _s extends it{constructor(e){super(e,e.columns,e.rows)}set(e,o,t){return this.matrix.set(o,e,t),this}get(e,o){return this.matrix.get(o,e)}}class no extends C{constructor(e,o={}){const{rows:t=1}=o;if(e.length%t!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=t,this.columns=e.length/t,this.data=e}set(e,o,t){let s=this._calculateIndex(e,o);return this.data[s]=t,this}get(e,o){let t=this._calculateIndex(e,o);return this.data[t]}_calculateIndex(e,o){return e*this.columns+o}}class tt extends C{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,o,t){return this.data[e][o]=t,this}get(e,o){return this.data[e][o]}}function Ss(i,e){if($.isAnyArray(i))return i[0]&&$.isAnyArray(i[0])?new tt(i):new no(i,e);throw new Error("the argument is not an array")}class Lt{constructor(e){e=tt.checkMatrix(e);let o=e.clone(),t=o.rows,s=o.columns,n=new Float64Array(t),l=1,r,c,a,u,h,g,m,p,E;for(r=0;rMath.abs(p[u])&&(u=r);if(u!==c){for(a=0;a=0;a--){for(c=0;cl?s.set(n,l,e.get(n,l)):n===l?s.set(n,l,1):s.set(n,l,0);return s}get upperTriangularMatrix(){let e=this.LU,o=e.rows,t=e.columns,s=new v(o,t);for(let n=0;nMath.abs(e)?(o=e/i,Math.abs(i)*Math.sqrt(1+o*o)):e!==0?(o=i/e,Math.abs(e)*Math.sqrt(1+o*o)):0}class ue{constructor(e){e=tt.checkMatrix(e);let o=e.clone(),t=e.rows,s=e.columns,n=new Float64Array(s),l,r,c,a;for(c=0;c=0;a--){for(c=0;c=0;r--){for(n=0;n=0;d--)if(p[d]!==0){for(let S=d+1;S=0;d--){if(d0;){let d,S;for(d=F-2;d>=-1&&d!==-1;d--){const b=Number.MIN_VALUE+K*Math.abs(p[d]+Math.abs(p[d+1]));if(Math.abs(f[d])<=b||Number.isNaN(f[d])){f[d]=0;break}}if(d===F-2)S=4;else{let b;for(b=F-1;b>=d&&b!==d;b--){let y=(b!==F?Math.abs(f[b]):0)+(b!==d+1?Math.abs(f[b-1]):0);if(Math.abs(p[b])<=K*y){p[b]=0;break}}b===d?S=3:b===F-1?S=1:(S=2,d=b)}switch(d++,S){case 1:{let b=f[F-2];f[F-2]=0;for(let y=F-2;y>=d;y--){let G=nt(p[y],b),A=p[y]/G,M=b/G;if(p[y]=G,y!==d&&(b=-M*f[y-1],f[y-1]=A*f[y-1]),a)for(let N=0;N=p[d+1]);){let b=p[d];if(p[d]=p[d+1],p[d+1]=b,a&&do&&n.set(u,h,e.get(u,h)/this.s[h]);let l=this.U,r=l.rows,c=l.columns,a=new v(t,r);for(let u=0;ue&&o++;return o}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return v.diag(this.s)}}function Us(i,e=!1){return i=tt.checkMatrix(i),e?new dt(i).inverse():io(i,v.eye(i.rows))}function io(i,e,o=!1){return i=tt.checkMatrix(i),e=tt.checkMatrix(e),o?new dt(i).solve(e):i.isSquare()?new Lt(i).solve(e):new ue(i).solve(e)}function Qt(i){if(i=v.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let e,o,t,s;if(i.columns===2)return e=i.get(0,0),o=i.get(0,1),t=i.get(1,0),s=i.get(1,1),e*s-o*t;if(i.columns===3){let n,l,r;return n=new Ct(i,[1,2],[1,2]),l=new Ct(i,[1,2],[0,2]),r=new Ct(i,[1,2],[0,1]),e=i.get(0,0),o=i.get(0,1),t=i.get(0,2),e*Qt(n)-o*Qt(l)+t*Qt(r)}else return new Lt(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ys(i,e){let o=[];for(let t=0;ts)return new Array(e.rows+1).fill(0);{let n=e.addRow(o,[0]);for(let l=0;le?n[l]=1/n[l]:n[l]=0;return s.mmul(v.diag(n).mmul(t.transpose()))}function Fs(i,e=i,o={}){i=new v(i);let t=!1;if(typeof e=="object"&&!v.isMatrix(e)&&!$.isAnyArray(e)?(o=e,e=i,t=!0):e=new v(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0}=o;s&&(i=i.center("column"),t||(e=e.center("column")));const n=i.transpose().mmul(e);for(let l=0;l0?s.set(n,n+1,o[n]):o[n]<0&&s.set(n,n-1,o[n])}return s}}function Vs(i,e,o,t){let s,n,l,r,c,a,u,h;for(c=0;c0;r--){for(h=0,l=0,a=0;a0&&(n=-n),e[r]=h*n,l=l-s*n,o[r-1]=s-n,c=0;ca)do{for(s=o[a],h=(o[a+1]-s)/(2*e[a]),g=nt(h,1),h<0&&(g=-g),o[a]=e[a]/(h+g),o[a+1]=e[a]*(h+g),m=o[a+1],n=s-o[a],l=a+2;l=a;l--)for(_=E,E=p,U=w,s=p*e[l],n=p*h,g=nt(h,e[l]),e[l+1]=w*g,w=e[l]/g,p=h/g,h=p*o[l]-w*s,o[l+1]=n+w*(p*s+w*o[l]),c=0;ck*R);o[a]=o[a]+q,e[a]=0}for(l=0;l=h;a--)o[a]=e.get(a,h-1)/g,c+=o[a]*o[a];for(r=Math.sqrt(c),o[h]>0&&(r=-r),c=c-o[h]*r,o[h]=o[h]-r,u=h;u=h;a--)l+=o[a]*e.get(a,u);for(l=l/c,a=h;a<=n;a++)e.set(a,u,e.get(a,u)-l*o[a])}for(a=0;a<=n;a++){for(l=0,u=n;u>=h;u--)l+=o[u]*e.get(a,u);for(l=l/c,u=h;u<=n;u++)e.set(a,u,e.get(a,u)-l*o[u])}o[h]=g*o[h],e.set(h,h-1,g*r)}}for(a=0;a=s+1;h--)if(e.get(h,h-1)!==0){for(a=h+1;a<=n;a++)o[a]=e.get(a,h-1);for(u=h;u<=n;u++){for(r=0,a=h;a<=n;a++)r+=o[a]*t.get(a,u);for(r=r/o[h]/e.get(h,h-1),a=h;a<=n;a++)t.set(a,u,t.get(a,u)+r*o[a])}}}function Ms(i,e,o,t,s){let n=i-1,l=0,r=i-1,c=Number.EPSILON,a=0,u=0,h=0,g=0,m=0,p=0,E=0,_=0,f,w,U,q,R,k,F,V,K,d,S,b,y,G,A;for(f=0;fr)&&(o[f]=s.get(f,f),e[f]=0),w=Math.max(f-1,0);w=l;){for(q=n;q>l&&(p=Math.abs(s.get(q-1,q-1))+Math.abs(s.get(q,q)),p===0&&(p=u),!(Math.abs(s.get(q,q-1))=0){for(E=h>=0?h+E:h-E,o[n-1]=V+E,o[n]=o[n-1],E!==0&&(o[n]=V-F/E),e[n-1]=0,e[n]=0,V=s.get(n,n-1),p=Math.abs(V)+Math.abs(E),h=V/p,g=E/p,m=Math.sqrt(h*h+g*g),h=h/m,g=g/m,w=n-1;w0)){for(p=Math.sqrt(p),K=q&&(E=s.get(R,R),m=V-E,p=K-E,h=(m*p-F)/s.get(R+1,R)+s.get(R,R+1),g=s.get(R+1,R+1)-E-m-p,m=s.get(R+2,R+1),p=Math.abs(h)+Math.abs(g)+Math.abs(m),h=h/p,g=g/p,m=m/p,!(R===q||Math.abs(s.get(R,R-1))*(Math.abs(g)+Math.abs(m))R+2&&s.set(f,f-3,0);for(U=R;U<=n-1&&(G=U!==n-1,U!==R&&(h=s.get(U,U-1),g=s.get(U+1,U-1),m=G?s.get(U+2,U-1):0,V=Math.abs(h)+Math.abs(g)+Math.abs(m),V!==0&&(h=h/V,g=g/V,m=m/V)),V!==0);U++)if(p=Math.sqrt(h*h+g*g+m*m),h<0&&(p=-p),p!==0){for(U!==R?s.set(U,U-1,-p*V):q!==R&&s.set(U,U-1,-s.get(U,U-1)),h=h+p,V=h/p,K=g/p,E=m/p,g=g/h,m=m/h,w=U;w=0;n--)if(h=o[n],g=e[n],g===0)for(q=n,s.set(n,n,1),f=n-1;f>=0;f--){for(F=s.get(f,f)-h,m=0,w=q;w<=n;w++)m=m+s.get(f,w)*s.get(w,n);if(e[f]<0)E=F,p=m;else if(q=f,e[f]===0?s.set(f,n,F!==0?-m/F:-m/(c*u)):(V=s.get(f,f+1),K=s.get(f+1,f),g=(o[f]-h)*(o[f]-h)+e[f]*e[f],k=(V*p-E*m)/g,s.set(f,n,k),s.set(f+1,n,Math.abs(V)>Math.abs(E)?(-m-F*k)/V:(-p-K*k)/E)),k=Math.abs(s.get(f,n)),c*k*k>1)for(w=f;w<=n;w++)s.set(w,n,s.get(w,n)/k)}else if(g<0)for(q=n-1,Math.abs(s.get(n,n-1))>Math.abs(s.get(n-1,n))?(s.set(n-1,n-1,g/s.get(n,n-1)),s.set(n-1,n,-(s.get(n,n)-h)/s.get(n,n-1))):(A=xt(0,-s.get(n-1,n),s.get(n-1,n-1)-h,g),s.set(n-1,n-1,A[0]),s.set(n-1,n,A[1])),s.set(n,n-1,0),s.set(n,n,1),f=n-2;f>=0;f--){for(d=0,S=0,w=q;w<=n;w++)d=d+s.get(f,w)*s.get(w,n-1),S=S+s.get(f,w)*s.get(w,n);if(F=s.get(f,f)-h,e[f]<0)E=F,m=d,p=S;else if(q=f,e[f]===0?(A=xt(-d,-S,F,g),s.set(f,n-1,A[0]),s.set(f,n,A[1])):(V=s.get(f,f+1),K=s.get(f+1,f),b=(o[f]-h)*(o[f]-h)+e[f]*e[f]-g*g,y=(o[f]-h)*2*g,b===0&&y===0&&(b=c*u*(Math.abs(F)+Math.abs(g)+Math.abs(V)+Math.abs(K)+Math.abs(E))),A=xt(V*m-E*d+g*S,V*p-E*S-g*d,b,y),s.set(f,n-1,A[0]),s.set(f,n,A[1]),Math.abs(V)>Math.abs(E)+Math.abs(g)?(s.set(f+1,n-1,(-d-F*s.get(f,n-1)+g*s.get(f,n))/V),s.set(f+1,n,(-S-F*s.get(f,n)-g*s.get(f,n-1))/V)):(A=xt(-m-K*s.get(f,n-1),-p-K*s.get(f,n),E,g),s.set(f+1,n-1,A[0]),s.set(f+1,n,A[1]))),k=Math.max(Math.abs(s.get(f,n-1)),Math.abs(s.get(f,n))),c*k*k>1)for(w=f;w<=n;w++)s.set(w,n-1,s.get(w,n-1)/k),s.set(w,n,s.get(w,n)/k)}for(f=0;fr)for(w=f;w=l;w--)for(f=l;f<=r;f++){for(E=0,U=l;U<=Math.min(w,r);U++)E=E+t.get(f,U)*s.get(U,w);t.set(f,w,E)}}}function xt(i,e,o,t){let s,n;return Math.abs(o)>Math.abs(t)?(s=t/o,n=o+s*t,[(i+s*e)/n,(e-s*i)/n]):(s=o/t,n=t+s*o,[(s*i+e)/n,(s*e-i)/n])}class lo{constructor(e){if(e=tt.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let o=e,t=o.rows,s=new v(t,t),n=!0,l,r,c;for(r=0;r0,s.set(r,r,Math.sqrt(Math.max(a,0))),c=r+1;c=0;c--)for(r=0;rl;m++)h=e.transpose().mmul(r).div(r.transpose().mmul(r).get(0,0)),h=h.div(h.norm()),a=e.mmul(h).div(h.transpose().mmul(h).get(0,0)),m>0&&(c=a.clone().sub(g).pow(2).sum()),g=a.clone(),t?(u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),r=t.mmul(u).div(u.transpose().mmul(u).get(0,0))):r=a;if(t){let m=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));m=m.div(m.norm());let p=e.clone().sub(a.clone().mmul(m.transpose())),E=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),_=t.clone().sub(a.clone().mulS(E.get(0,0)).mmul(u.transpose()));this.t=a,this.p=m.transpose(),this.w=h.transpose(),this.q=u,this.u=r,this.s=a.transpose().mmul(a),this.xResidual=p,this.yResidual=_,this.betas=E}else this.w=h.transpose(),this.s=a.transpose().mmul(a).sqrt(),s?this.t=a.clone().div(this.s.get(0,0)):this.t=a,this.xResidual=e.sub(a.mmul(h.transpose()))}}Q.AbstractMatrix=C;Q.CHO=lo;Q.CholeskyDecomposition=lo;Q.DistanceMatrix=Ot;Q.EVD=ro;Q.EigenvalueDecomposition=ro;Q.LU=Lt;Q.LuDecomposition=Lt;var co=Q.Matrix=v;Q.MatrixColumnSelectionView=gs;Q.MatrixColumnView=fs;Q.MatrixFlipColumnView=ms;Q.MatrixFlipRowView=ps;Q.MatrixRowSelectionView=ws;Q.MatrixRowView=ds;Q.MatrixSelectionView=Ct;Q.MatrixSubView=Es;Q.MatrixTransposeView=_s;Q.NIPALS=ho;Q.Nipals=ho;Q.QR=ue;Q.QrDecomposition=ue;Q.SVD=dt;Q.SingularValueDecomposition=dt;Q.SymmetricMatrix=ct;Q.WrapperMatrix1D=no;Q.WrapperMatrix2D=tt;Q.correlation=bs;Q.covariance=Fs;var Me=Q.default=v;Q.determinant=Qt;Q.inverse=Us;Q.linearDependencies=qs;Q.pseudoInverse=ks;Q.solve=io;Q.wrap=Ss;const mt=co;Me.Matrix&&Me.Matrix;const xe=8,xs=1/16777216,Ks=15,Ns=18,Ts=11;function Cs(i,e){i>>>=0,e>>>=0;const o=i&65535;return((i-o)*e>>>0)+o*e>>>0}class Qs{constructor(e=Date.now()){this.state=new Uint32Array(4),this.init(e),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*xs}init(e){if(!Number.isInteger(e))throw new TypeError("seed must be an integer");this.state[0]=e,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let o=1;o>>30>>>0)>>>0;this.periodCertification();for(let o=0;o>>Ns,e^=this.state[3]<As)throw new Error(`probabilities should sum to 1, but instead sums to ${r[r.length-1]}`)}if(s===!1&&t>l.length)throw new Error("size option is too large");const c=[];for(let a=0;ao[s];)s++;return s}else return Math.floor(t*i)}class fe{constructor(e=Math.random){if(typeof e=="number"){const o=new Qs(e);this.randomGenerator=o.random}else this.randomGenerator=e}choice(e,o){return typeof e=="number"?Ke(e,o,this.randomGenerator):Ke(e,o,this.randomGenerator)}random(){return this.randomGenerator()}randInt(e,o){return o===void 0&&(o=e,e=0),e+Math.floor(this.randomGenerator()*(o-e))}randomSample(e){const o=[];for(let t=0;t1){let l={dist:-1,index:-1};for(let r=0;rl.dist&&(l.dist=o[n[0]][r],l.index=r);if(n[1]=l.index,e>2)for(let r=2;rc.dist&&(c={...u})}n[r]=c.index}}return n.map(l=>i[l])}function Ys(i,e,o={}){const t=new mt(i),s=t.rows,n=new fe(o.seed),l=[],r=o.localTrials||2+Math.floor(Math.log(e)),c=n.randInt(s);l.push(t.getRow(c));let a=new mt(1,t.rows);for(let m=0;mm&&(m=q,g=U)}const p=u.get(g),E=cv.boundingRect(p),_=t.roi(E),{gridCells:f,expandedRect:w}=Zs(_,e,o);return t.delete(),s.delete(),n.delete(),l.delete(),r.delete(),c.delete(),a.delete(),u.delete(),h.delete(),_.delete(),{gridCells:f,chessboardRect:{x:E.x+w.x,y:E.y+w.y,width:w.width,height:w.height}}}function Zs(i,e,o){const t=new cv.Mat;cv.cvtColor(i,t,cv.COLOR_RGBA2GRAY);const s=new cv.Mat;cv.GaussianBlur(t,s,new cv.Size(5,5),0);const n=new cv.Mat;cv.Canny(s,n,50,150);const l=new cv.Mat;if(cv.HoughLinesP(n,l,1,Math.PI/180,80,100,50),l.rows===0)return console.log("无法检测到棋盘线条。"),{gridCells:[],expandedRect:{x:0,y:0,width:0,height:0}};const r=[],c=[];for(let I=0;I80&&c.push([j,W,P,z])}if(r.length<10||c.length<9)return console.log("线条不足,无法进行 KMeans 聚类。"),{gridCells:[],expandedRect:{x:0,y:0,width:0,height:0}};const a=r.flatMap(I=>[I[1],I[3]]),u=c.flatMap(I=>[I[0],I[2]]),h=Te(a.map(I=>[I]),10,{maxIterations:100}),g=Te(u.map(I=>[I]),9,{maxIterations:100}),m=h.centroids.map(I=>I[0]).sort((I,j)=>I-j),p=g.centroids.map(I=>I[0]).sort((I,j)=>I-j),E=Math.floor(m[0]),_=Math.ceil(m[m.length-1]),f=Math.floor(p[0]),w=Math.ceil(p[p.length-1]),U=i.roi(new cv.Rect(f,E,w-f,_-E)),q=w-f,R=_-E,k=Math.floor(q*e),F=Math.floor(R*o),V=Math.max(0,f-k),K=Math.max(0,E-F),d=Math.min(i.cols-V,q+2*k),S=Math.min(i.rows-K,R+2*F),b=i.roi(new cv.Rect(V,K,d,S)),y=10,G=9,A=Math.floor(S/y),M=Math.floor(d/G),N=[];for(let I=0;Ie}function $s(i){const e=ge(i),o=jt(e,[0,120,120],[10,255,255],[160,120,120],[179,255,255]),t=jt(e,[0,0,0],[180,255,80]),s=i.width*i.height,n=cv.countNonZero(o),l=cv.countNonZero(t),r=n/s,c=l/s;return e.delete(),o.delete(),t.delete(),r>.05?"red":c>.05?"black":"unknown"}function tn(i,e){let o;if(e==="red")o=en(i);else if(e==="black")o=on(i);else return i;const t=sn(o);let s=new cv.Mat;t.channels()===1?cv.cvtColor(t,s,cv.COLOR_GRAY2RGBA):t.channels()===3?cv.cvtColor(t,s,cv.COLOR_RGB2RGBA):s=t.clone();const n=new ImageData(new Uint8ClampedArray(s.data),s.cols,s.rows);return o.delete(),t.delete(),s.delete(),n}function en(i){const e=ge(i),o=jt(e,[0,100,100],[10,255,255],[160,100,100],[179,255,255]);return e.delete(),o}function on(i){const e=ge(i),o=jt(e,[0,0,0],[180,255,100]);return e.delete(),o}function sn(i){const e=i.clone(),o=cv.Mat.ones(3,3,cv.CV_8U);cv.morphologyEx(i,i,cv.MORPH_CLOSE,o,new cv.Point(-1,-1),2);const t=new cv.MatVector,s=new cv.Mat;if(cv.findContours(i,t,s,cv.RETR_EXTERNAL,cv.CHAIN_APPROX_SIMPLE),t.size()===0)return o.delete(),t.delete(),s.delete(),e;const n=i.cols*i.rows,l=[];for(let m=0;m=.5&&l.push({contour:p,contourArea:f,rect:E})}p.delete()}if(l.length===0)return o.delete(),t.delete(),s.delete(),e;l.sort((m,p)=>p.contourArea-m.contourArea);const r=l[0],{x:c,y:a,width:u,height:h}=r.rect,g=e.roi(new cv.Rect(c,a,u,h));return o.delete(),t.delete(),s.delete(),e.delete(),g}function ge(i){const e=cv.matFromImageData(i),o=new cv.Mat;cv.cvtColor(e,o,cv.COLOR_RGBA2RGB);const t=new cv.Mat;return cv.cvtColor(o,t,cv.COLOR_RGB2HSV),e.delete(),o.delete(),t}function Ce(i,e,o){const t=new cv.Mat;return cv.inRange(i,cv.matFromArray(1,3,cv.CV_8UC1,e),cv.matFromArray(1,3,cv.CV_8UC1,o),t),t}function jt(i,e,o,t,s){const n=Ce(i,e,o);if(t&&s){const l=Ce(i,t,s),r=new cv.Mat;return cv.bitwise_or(n,l,r),n.delete(),l.delete(),r}return n}const nn={red_king:"帥",red_guard:"仕",red_bishop:"相",red_knight:"傌",red_rook:"俥",red_cannon:"炮",red_pawn:"兵",black_king:"将",black_guard:"士",black_bishop:"象",black_knight:"馬",black_rook:"車",black_cannon:"炮",black_pawn:"卒"};function rn(i,e,o){const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const s=t.getContext("2d");s.drawImage(i,0,0,t.width,t.height),s.strokeStyle="rgba(0, 255, 0, 0.5)",s.lineWidth=2,s.strokeRect(e.x,e.y,e.width,e.height);const n=e.width/9,l=e.height/10;return o.forEach(r=>{const[c,a]=r.position,u=e.x+a*n,h=e.y+c*l;if(s.strokeStyle=r.color==="red"?"rgba(255, 0, 0, 0.7)":"rgba(0, 0, 0, 0.7)",s.lineWidth=2,s.strokeRect(u,h,n,l),r.type&&r.type!=="none"){const g=`${r.color}_${ln(r.type)}`,m=nn[g]||"";s.fillStyle=r.color==="red"?"rgba(255, 50, 50, 0.9)":"rgba(50, 50, 50, 0.9)",s.font="bold 24px Arial",s.textAlign="right",s.textBaseline="bottom",s.fillText(m,u+n-5,h+l-5)}}),t}function ln(i){return{k:"king",a:"guard",b:"bishop",n:"knight",r:"rook",c:"cannon",p:"pawn",none:"none"}[i]}const hn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEfUlEQVRoBbXBAbKqSAAEsPT9D907CCjigL6t+kl81dS9+Enca2oXR7VILeIHcauG1BATtYuv4kZt4kat0rgVl2oV39WQxp2Yq1W8qVWclVTciKka0jipXZzVQ1yJiXqImVrFhxriSnyqRUzVLj4VcSHO6iFm6iA+1RBTcVKLmKo3MVGL+BTvahFT9S5mKiU+xLsipuos5mqIsziqIabqQ1yoIU7ioIipmokLNcRRxUsNMVEfUkNcqCHexFMNcVZ34kpTcRRPJT7Um9S7uFBDHMSuiLP6Ii4V8RKbIj7UJvUStYsrRbzEqohPtUo9hXqKS0U8xUMRn2oRtYlFvcS1InbxU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EUNMRUTRfwPNcSFmKlF/FENcSXmahG/q0Vciyu1iu9qEzfiUu3iRj3FncadeomJeol7jXt1FJs6iW8qflCpG/FdSeMHdSl+UaTxozqJn9WQin+uFinxj9XDfzKct20QZAU8AAAAAElFTkSuQmCC",cn=Object.freeze(Object.defineProperty({__proto__:null,default:hn},Symbol.toStringTag,{value:"Module"})),an="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABoCAAAAAAxnEoHAAAE30lEQVRoBbXBCYLCRgIEMNX/H13bPjBtMJhJNlL8oKkv4kdxrx5SRL2KX8R39RTvapPGrfimHuKj2sSd+KJWcadE40Z8Upv4SQ3xVVyrVfyupGl8FFdqE39S4ou4UKv4syI+iXe1iH+k0rgWr2oRNyouVVRciFc1xJ0a4kot4k2c1SJu1SouVEq8ipMa4ge1i3eVEi9iVkP8pHZxoYY4i0kRP6pDXClxEk81xK/qEBeKmMWhhvhZDalFvGlKzOJQxJWKd/UUV0pM4qGId7WJs5rElSKeYlfEmzrESa2iiCs1xCE2Rbyok5jUKor4oIiH2JSY1bs41CQ+aSoeYlXioT6IQ62ixEeVil0sinioD+KhNlGhdvGqxC4WJQ71QWxqlprEWRGbGEo81bXY1DdxUsQmhhKTuhC7OqTexUkRq6CIWb2KhzqkqSE1i1kRq6CIk3qIIg51CBrqLGZFLEIRr2oTFZPapGZRh5gUsQglrtSQEpM6i0M9xKSIIZS4UqTErGYxqUM8FTFEiUtFKk7qEGd1iEkRRIkrRSrOahNv6hCTIogSV4pUnJW4VKsUMSmClLhSpMRZiV0RD7VIESclSIkrtYiPahebGlLEWQlScaVI45OaxFCLlHhRhFRcqFVcqVdB7eJVEVJxoUjFhXoXahdvSkjFuyIVF+pC1C7elZCKd7WIV/VB1JAS70pIxZsi3tWFUFFDKi6UkIo3RWxqiFW9iaFRQ1RcKCEVr2pIg9rFUKugVjE0apGKKyWk4lWRhprEUEM0tYpNDSlxpYhUPBUpolEnQa2CGlJC7eJSEal4ql0adRbUJmqRpqGGlLhURCom9ZB6FeosGrVKxbUiUjGrz0IRdSElrhWRilkdog6xqI+i4oMiUjGrh1jUIiqoWahZfFBEKib1FIsaYlNPUVGrKPFJEamY1FMsilQsaoiSmkSJj4pIxVNNYlGksahFDLWKIkV8VkQqDjWLRRGbGlKbWNQmvighFYeaxaJIY1GkFrErKfFFEVJiVycxFNFYFKmY1RDfFCElNrVJbUINsStSMSvxXRFSYlWbqE1qlcaiSMVJie9KkBKLWgV1lsaiSOPPSpASQ22COknFohbxg8ZTEaQIahVDncSuFnGvxKEIUgS1iEVN4qFWca/EoQiiBDXEqh5Si1jUKu6VeCixiCIUsamzWNUq7pV4KLGIImg81Cx2tYp7JXZFLEKJk3qKQy3iXhG7IhahiFk9xKRWcauIXRGLoMSsdjGrVdypRayKWAVFzGoTs1rFjVrFqohVUEPMahWz2sRXtYlFEZsYijipIU5qF5/VIaghNrEocVbEST3FpZoERexiUcRZibOaxVm9CDXELlZF3Km/SQ3xEKtK41b9KkWKOMSmUnGnfhJKFHGIXRH36k5QQ5R4iociflC/CRWTeKghflH3QolZHGqIn9UnMdQQs3iqIf6qSA3xVEOcxKSG+D+oRZzFrIb412oRL+KkhviXahGv4qyG+FdqEW/iRVPEv1DEhXhXxD9VQ1yJd0Ua/0Qt4lJcqCH+rlZxLa7UEH9Vi/gkLtUq/qIW8VF8ULv4Qe3ii/isdvFd7eKbxhf1FNfqEN81vqvUISZ1Ejcqje8adSvulFTcqm/iB0U0flJX4jc1RMVfVDQaf1CLKPEfq1Uo8Z+qzf8AA+cGfuc6ELgAAAAASUVORK5CYII=",un=Object.freeze(Object.defineProperty({__proto__:null,default:an},Symbol.toStringTag,{value:"Module"})),fn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAADgElEQVRoBbXBCWKjSAAEMNX/H13bxAdgY9wkO1J8Vd/ElDhXq9iqjZgQZ2oVB2oVX8RndRdn6i7OxSd1F1/VTZyJY3UTk2oRJ+JI3cQFtYiP4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6cAAAAASUVORK5CYII=",gn=Object.freeze(Object.defineProperty({__proto__:null,default:fn},Symbol.toStringTag,{value:"Module"})),mn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAFMklEQVRoBbXBC3KkSgIEMOX9D51bxa+BBo/9IlaKf6p/iN+Jn9VHnNVJ/EL8pD7iQZEa4p/iXW3iJ7WKf4g3tYp/qyEVP4lntYrfKSnxg3hSq/iDmuJVPKgp/qqGeBNfahE/K3FTpPEs7mqKH9UmrmqIR3FTU/yoPuKiFvEtrmqIn9VFXFRKfImzmmLTeFKiPuKipriLsyIORdxVDPURFzXFTRqHIj5qiJvGVB9xVVMcaoiPGuKkpjhrLOojvhRxEYca4qwW8aC+xEdT4ix2NcRFreJLPYldDXEWmxriqjZxV4/iUMRJrIr4Upu4qhexqyE+YlXElxpSxFl9pM7iUMQhFkV8q12c1SFqSG1iV8QhpiIe1JQSJ7WK2qU2sStiF1MRD2oXH7WJ+haHIjYxFPGkdvFRU9QiqCEocShiExTxqKaUONQUNcVQUyhxUsQqKOJRTVGxq0VqiEUNQYmTIlahiGc1RcWmFqkhFjWFxk0Ri1DiRU1RsahVlFjVFE+KWIQSL2qKiqlOYlNDPCuxiCJe1BQVU33EpqZ4VsQUJS4qNrWJqS5iUUO8KWJIEYs6xKoOQd0ENQSNJ0UMKbGqk5jqENRd1JQSj4oYUmJTHzHVLob6QbwoMaTEpk5iqE1M9S7eFEEqdnUSQ21iqkPqIl4VQSoOdRJqF1O9iXdFkIqP+gg1pMSiXsRPipCKk9oFtYlFEeomflSEVJxVagpqFXd1Ehc1xEcRUnFSi1jUKm7qJBZ1FbsipOKkpljUJk7qt2JVhDROaopF7eKkfi1WJaRxUtJY1CHO6tdiUUIaHyWNRR3ion4tFkWk8VFiVauUOKkXURcpMRWRxqHEqjYpcagnKaEuomIqIo1DY1WHlNjUu6igDrEpIo1dY1UfKbGoQ9RNVDwrIo1dY6pNahXqLLWJoYZovCgijU1jqikV9aPY1BCNF0WksWlQi2iod3FSpOJFEWlsKrWKBvUmLmoRL0pIY1WHWNWzuKlFvCghjUUdYlVDNI3axbdaxLMipLGoTdAYakiF2sSTWsSzIqRiqlXQmGpIxVBDbEp81CKeFSEVUy3io4ZUnNUudrWKR0VIxVSL+KghFR91EptaxLMSpGKqKU5qSMWurmJVi3hWgpSYithV1JCKTd3FqhbxpAhSYiri0CiiYlN3saopHhVBSkxFHGoRFZtapXaxqCkelRhSxFBEY1WLqDgrUkSJRS3iQYkpSkxF7GoRFWc1paZY1CoelJiiiKmITS2iYteos1jUIh4UMUURX2oRFbuS+ohVreJbEVPUEHe1SIlDCWqKXa3iWxFTKOKuDvFR4kut4ksRi6DEXR3ipIibWsWXIhZBETd1iJOa4qJWcVfEKqghbmoXZzXFWa3ipoZYxVBDXNUuLmoRH7WKmyI2MRVxVbu4qk1silTc1BCbmGqIi9rEXR1iqCEVVzXELhZFXNUqvtS3VFwVcYhVERe1im91FxUXNcQhNkVc1BRP6ltc1BAfsakhzmqKZ3URNzXESexqiLMa4kWdxVUNcRaHGuKsxKv6iKua4iw+aoizxk9qExofNcVFnNQQv1eb0DjUFFdxVsRf1CIah5riJi5qiD+oKU5qiru4akr8RQ1pbGqIb3FTxN+U2NUU3+KuKfEnFZsa4kl8qyn+g5riUTwo4j+oIV7Ek5rij2qIN/GspviDGuJdvKlV/Ftt4l3jVe3iB3WInzR+Uod4Uh/xo4qf1Vls6ib+ocQvVOoH8U9F/EZTb+IXakjjl+oufquGVPzf1ZQS/2e1+B/JLhl7oCCiRAAAAABJRU5ErkJggg==",pn=Object.freeze(Object.defineProperty({__proto__:null,default:mn},Symbol.toStringTag,{value:"Module"})),dn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEhklEQVRoBbXBW4KiQAAEsNT9D13bvAQUlPnYJB6o7+KR+KFe4qR28UCsKj7VS1yoITXEL7FqfKhZGt/UIr6LW7WI32pI45u4UYt4pqTii7h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eomDGmIVsyKGIo0vaoij2sRREZuYFTEp4ptaxKYmUeKghtjEoohnahdqERUHNcRLrIp4pq5Exa6G2MWqhnimPqVxVEMcxKaGeKbepeKoiKN4KeKh+hS7msRR7GqIh4rUKiVeahIncVBDPFS7qNjVEGdxVMRTtYkSm5rEmzipIR6qg9jUJN7FWVPioSIVFS9FfIo3RRrP1CwVmxriU3wq8VBN0ljVEFfiQg3xSE1iUZO4FBeKeKiIRQ1xI67UJB6pWNQQd+JaTeKxpoa4F3dqEb/VKr6IW7WJL+olvopvahcXahffNb6r1Ess6l38UvFAfRe/lTR+q1vxSJGKZ+pdPFakxH9XQ4r4z2ryDw7EyW7nu7OBAAAAAElFTkSuQmCC",wn=Object.freeze(Object.defineProperty({__proto__:null,default:dn},Symbol.toStringTag,{value:"Module"})),En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABoCAAAAAAxnEoHAAAEY0lEQVRoBbXBSYKjSAAEMMX/Hx2TLHYBZuvDSPGsnsQr8aA2Qgm1F2/EvfqKE7VIxZO4U6u4Vot4EtdqEV/1EVs1iXtxoRaxVRuxVUPciXM1i4Paiq1K40acqVn8qq3YKnEjTtQkztRO7BVxIX7UJC7UTuxVKk7FUU3iSu3FXkXT+BUHNcSN2omjmsSP2KshbtVW/KiUOIqdGuJBrVLiV6XEQWwV8aRWUXGuiL3YqCEe1CpFnKshduJPDfGgtuJSEVvxVcST2glqiIOmxFZ8FPGkdqJWcdCU2IiPEg/qRhzUEH9iVcStuhcHRfyJRRE36lkclfiKWRHn6q04aio+YlJDnKn34qiGWMWkxFHjo96IEyVWMSlxUOKjHsSFIhYxlDioG6mPuFfEIihxVJdSq3hWxCwocVRXooaoRdwpYhaKOKorKUJ9xJ0iJqHEjzoTSgwVahY3iphEEb/qRyoqhgpqFneKGKKIE7UXGhVDY1KzuFPEECXO1FYoqRgqJrWIG0UMKeJUrWJSkxhKTGoRd4ogRbxR0phUTGoVd4ogJd6oSQwlJrWKWyVIiRdqEpOKSX3ErRKk4oWaxKTEUF9xqwipeFazGIoYaiuuFSEVj2oRQ4mhDuJSCal4VIugCOpHXCkhFU/qI2oI6ldcKCEVD+ogqFXqKy6UkIp7dRTqTFwoIRW36kfUUdC4UEIqbtSJqEWoSai4UkQad+pEahZDfcSlItK4UbPUiRjqI64VkcaNmqROxFAfcaOING7UKtROUJMUcaeINK7VKib1J9QsStwqIo1rtYhZbaQ+4kkRaVyrWSzqVDwqIo1rNYmv2ogiXighjWs1xEbtxDslpOJSiZ36E6+VkIqXaidWdSI2ipCKN+ofxZ8ipOJRfUS9FR9FSMW9WsSkXouPEqTiTs2CuhW1F6sSpMSVmgR1FJU6iKEWsSiClDhVs9S/Ss1iUQQpcaKexFHtxaLEkCIO6krUKk7VV8xKTKLEV6OuxFCruFZDLIoYoohFXYtFreKdIiZRxKIuxFet4p0iJlFDzOpE7NQqXqkhJqGISR3Fj1rFK0XMghKz2ooztYpXipgFRUzqKy7UKt4oYhEUMatZXKtFvFFDLGIo4qVaxBtFrGJSxDu1iBdqiFVMininFvGshviISQ3xSi3iUQ3xFbMa4o1axKMa4isWRbxRi3hSQ/yJVREv1CIe1BAb8VHEs5rFgxpiKz5qiEc1i3s1xE581RBPahb3aoid+FNDPKhZ3KlJ7MVGDXGvZnGjJnEQWzXErZrFtZrEUew0RdyoWVyqSfyIoyKu1Swu1RC/4kTFtZrEhRriTPwqaVypIS7UEKfiVw1xpYY409QQ5+JEDXGhhjhTQ1yJUzWkcaKG+FWTuBTnilT8KuKgUUPciCu1ioMSW7WKO41r9RFbFX/qK241btWfWJWY1EY8qHhQB6Gpg3hS0nhUO6G24lmRihfqT6iPeKWGlHir/sQ/qEmK+J/VLDXE/6tm/wHk3KtvFxNciwAAAABJRU5ErkJggg==",_n=Object.freeze(Object.defineProperty({__proto__:null,default:En},Symbol.toStringTag,{value:"Module"})),Sn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAABmCAAAAADpSjAOAAAEdklEQVRoBbXBCRKb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ljVj+KsPgRFrIIiVnWWOou5eopFDbGKoYhF3Qj1ENdqEYsiNjHUEEPNxaYe4idFPMSiiEUNqb14qU38pIZ4iEUNsagPsVOb+EkRT7GqIRa1E0e1iV/UEE+xKWJVD3FSm/hBDfESD0V8U5v4roZ4i4ca4ovaxFc1xE481RD3ahNf1RA78VLEvdrEF7WIvXgr4laREl/UEAfxVkPcKVLiXg1xFDs1xI1axa1axIc4qCGulVTcqUV8ioNaxKWSihu1iJP4UIu4UFJxqVZxFp9qEXMlFVdqETNxUquYqSEu1CqmYqJWcVZDTNUm5mKmVnFWaczUKq7EXG3iQxEntYlrcalWcVDiU23iTlyqTRo7FR9qE7fiTj2kMdOoh7jXuFcHsamDNL5qfFdfxA8qje/qUvympOI39Sl+VqTEP1dDivjHavEHY5a9buolYuEAAAAASUVORK5CYII=",Un=Object.freeze(Object.defineProperty({__proto__:null,default:Sn},Symbol.toStringTag,{value:"Module"})),yn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABsCAAAAACu+NgsAAAFfklEQVRoBb3BUULbCgJFMZ39L/qOnRCIIWnp+xgpvzF/ll/KX82v5BfyF/NN7ua7/FX+aL7khXmWv8gfzIf80TR3+aO8Mw/5jfmQ9/LGfMhvzV3eykvzIf9gPuSNvDI3+Vdzl9fy09zlP5i7vJIf5ibPRn5lzSGv5Ls55WLu8gtzygv5Zk65mE/5hTnlh1zNKVfzJX83N/kuF3PKN/MkvzCnfJNnc8p38yy/MKdc5cmc8sNc5BfmlIt8mVN+WnPTHPIbc8qzfJpTXpon+ZU55Fk+DXljnuR35pQv+TCnvDF3DfmlOeRLPswh78xdQ35pTvmUuznlnblpyK/NKQ+5mVPemptG/sEc8pCbOeStuWvklTXywxzyIac55L35lJ/mU67mlLuc5pD35lN+mGe5mEPucphD/mA+5Zv5Ls/mkJsc5pD35lmezAt5MofchDnknfkhD/OheZYvQ27CkHfmhdzNG3ky5BRzyEvzWu7mnXwZcsoc8tK8kdE8yzzJpyGnzCE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5dOQJ3lYQ14Y8ndrstzMTZ7k0xpytRjyC5PlZhm5yJc15IchvzAtd3PKRZ6sId8N+TdDy1WerZGrNflHc8o3uVhzyLMh/2IOLd/lam7ybORfDHkh36zR8p+tOeSF/DCHlv9mTZZX8tPc5D9YRstLeWFO+XdzaPJaXptT/ska8l5eW3OTX5rmJm/ljblr+YV5yB/krfmSP5uGlj/KH0zmLm/NTZa/yJ8tc5EP803+Kn8zr8R8iJFfyC/MH2Tkd/I7c9U0Dfm9/JP5kn+X/6v8X/0Phhh8i1Cy6vcAAAAASUVORK5CYII=",Rn=Object.freeze(Object.defineProperty({__proto__:null,default:yn},Symbol.toStringTag,{value:"Module"})),qn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABrCAAAAACz/eiUAAAFdklEQVRoBb3BCRabSgIEMNX9D13TzWKDwUuSeV+KH9R38Yv4qn4T38VndRIndRLfxCe1icYb9RSfxXu1iy9qF5/EO7WKH9Uq3ot7tYmf1SbeiVu1iD9Tq3gjbtQi/lyt4lZc1SL+Si3iTlzUIqghbpW4U4u4Ea9qCmoVN2qKOzXFVZzVFFNt4qpWcaOmuIizmmKqXVzVJq5qildxVItYVGoVV7WJq5riRRzUFE+1iYt6iIua4iwOaoiD2sRVPcRFTXESTzXEUe3iop7ioqY4ioca4qR2cVEHcVFTHMSupjipXVzUQVzVFE+xqSFe1C5e1VHcqCGeYlNDvKhdvKijuFVDPMSqhnhVuzirVWqIN2qIXSxqiFf1EGe1SA3xTg2xi0UN8ap2cVYHoTZxVkNsYqohLmoXJ3WQeooXNcQqhprionZxUJ/ESQ2xiqGGuKpNHNRncVLEKqghbtRBbOqLOKohFkENcaOm1CIW9VUc1RBTqCHuNIrUIqb6Lg5qiCnUEKsSD416iqnuBPUQTzXEFIpY1RSbRhE1xVQvYlcP8VRDDFFDbGoRi6am1CKGeoqTeoqHGmKIGmJXU0y1iloFTa3iRT3FUxFDFPFQi6CuQm3iVT3EQQ1BaoiHWkXdCEUaN+oh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24U6v4I5Wa4o24V1P8rkQN8Va80RSp+ElFDfFBvNXUIr5qFKn4JD6oXXxUUzQ+i0/qRZzUUyq+ic/qjdSUGqLiB/FdpW6kFtE0fhG/KKFeBCV+Fr+rmBpUSvyZ+GM1ROPPxX8q/lP/A9zVYIqTjIeUAAAAAElFTkSuQmCC",kn=Object.freeze(Object.defineProperty({__proto__:null,default:qn},Symbol.toStringTag,{value:"Module"})),Fn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABsCAAAAACu+NgsAAAE+klEQVRoBb3BC3bqSgLAQGn/i9a0P4DbNoTkvjNV8o34TL4kP4mvyDfksziSp7iQH8kH8SK34kh+IO/FTj6KF/lI3okH+ULs5AN5I1YmX4qdvCW3YiO/Eit5R27ERn4tFvKGXMVK/iJWcksuYiV/Eyu5Iyexkj+LldyQWazkX8RCrmQSC/lObOQkFnIhR7GQl0DeiBeZxELO5CAWchAgt+JIJrGQE3mJhRzFQm7EkcxiITN5iUFmsZCrmMgsFjKRh1jIWSzkInbGICexkCN5iEEuYiNncSRnsZAD2cVCzuJBTmIiZ7GQF9nEIFfxJLOYyEUM8iKbGOQqnmQWE7mKQZ5kFYPciBeZxZFcxSBPsgqQG3EgsziSGzHIgyxikBtxILM4kjsxyE6GGORGHMksDuRWDLITiEFuxERmcSS3YpCNQAxyFTOZxYG8EYOshBjkRsxkFgfyRgyyEmKQO3EkJ3Eg7wTISgiQGxlHchIH8k4MspAY5CqJlTHIWRzIOzHIQmKQi4yNMchFHMhbMchgDHIVO2OQqziQt2KQwRjkInbGIDfiQHbJWYAMBshVHMmdOBAIkJBZDAIGyFnsjEFuxYkEEjKJQcBALuLA5E7MJGMjkwABAzmLidyKiUnsZBKDYCAnMZF7Ge/IJAbBQM7iQN7IeE8OYhAMZJKxMgZ5Iz6SowDBkEnM5E5CfCJHAYIhkziSi0AW8ZEcBAiGHMXOGOQkkFV8JgcBgiEvMZOjANnET+QgQDDkKWbyFMhD/EyOYhBDHuJENjHILr4h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iU1FhdpFo3ZxU0QqrmoVFHFRQUPFog5Rp7gpIhVXdYpNDUGFRokGjTqEWsVNEam4qik2dRUVjRINGnVI7eKmiJS4qEUs6l0aRUwNJfUibopIiYt6E+qURg0xNGqRuoi7IlLioq5iqqs0aoihUavUJhU3NURKnOoUi0pNqRgaRUyNIirqEDc1REpc1CINNQQ1pAgalcbUKKJC7eKmhkiJi7qIRa3SGBqVxtQookJN0bgrQkpc1CJOTS1i1RSxKaEx1BCNuyKkiFMt4tCoKTZNEVOjhKahpjTuipAiTrWIVQU1pLEpYtEoodFQQuOmhpAa4lCr1BBTDWnsKo1Fo8SuROOuCFJDHJoiLmqKxq5pLColFg0VjZsagtQQh6aIQ61C401Ncag07moIoobYNUpQd9F4U1OsmiJeFDFEDXFRh6hdNN7UIlZFvKghhlDEoVHEi8aDWqWxqHhVQwyhhtg1Kt4U8ap28UkNMQVF7BoVRZwqHtQuPqkhpqCIXVNDfKV28UENsQhqiF1N8ZXaxQc1xCKGGmJTU3yldvGshljFUENsaorv1Cae1RCrmGqITRFfqk08qiE2MdUUqyK+VJt4UlNsYlFDbCq+Vqt4UkPsYlVD/INaxYOaYhermuIf1CIe1BCH2NQUf1dTvKspTrGrKf6spnhXU5ziUFP8WQ3xpqa4iFNN8Vc1xKua4ipOtYg/qiFe1BQ3cVGL+Jsa4q6muIurmuJvirirKV7ETU3xJ0Vc1SJexV1N8SclLmoRb+JVDfGtRomLWsS7eFNTfKdR4lSLeBAPaoivNEocaopH8aSG+E6JXS3iWTyqKb5QxKoW8Uk8q0X8qoipVvFRfFCH+EkJdYjP4qM6xWeVOsRP4id1ikd1FT+LX9SraKh38Zv4TX0pfhdfaOoX8ZX4Sv0gvhZ/UK/S+Iv4X8X/6j/OzIuL68bXyAAAAABJRU5ErkJggg==",vn=Object.freeze(Object.defineProperty({__proto__:null,default:Vn},Symbol.toStringTag,{value:"Module"})),In="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG8AAABsCAAAAABBOrMSAA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F5MijZrEVZ3iUIQUcVe7mNUQahKzhtrFoQgp4q52MStiVZM4NNQuHoogRdzVLi4qNk3NYtNQu3goghRxV5t4ry5i1ahdHIogRdzVJl6rqJugUbs41BCkhripTbxSQt2FRu3iUEOQGuKmdvFCiVqkJtEoKeJUxBBFXNVD7GoXKorUVTRqFacaYoga4qImQVOTKKlZlKBWcSpiETXERZ1SpE6hHmKoIUXUKk41xCIUcVGnoJ6kFrEqUkSt4lRDLEINMatZapW6i4ciGrWKQw2xCoqYNPUsqE1qEVcNtYhTDbEKipg0tUodYlGnaFw0ilScaohVUEOcapd6iF1tQombWsSphtjEUEMcaheVGuJQq1BDHBpqiEkNsYlFEYfahaaGmJQYahEPjSIVhxpiF4sa4lCbUKt4oYZ4aCipONQQD7GoRTzUJihpvFRDUEMoUvFQi3iIVQ3xUJtYVLzRlHioIRUPNcQhNrWITVOL+KJWsapNPNQiDrGpRWxqFV/VJtQiJXa1iFPsahGrpob4rq6iYleLOMVDLWLVVBo/qLvY1SImcahFrGqIX9RV7GoRszjVEJuKHzVNPcSuFnERp1rFX1XULja1iKuY1Cr+qlG7WNUibmJWq/ireohVLeIuLmoRf1abWNQqnsRVLeKvahOLWsSzuKsh/qqGWNQqXogntYg/KrGoVbwSL9QQ/6YW8Vq8UkP8g1rFG/FSLeKPahVvxWu1it/VLt6LN+oQ39VDfBJv1Sk+qkN8FJ/UKV6qSXwTn9VVDA31LL6Kb+pH8YP4QVOfxY/iJ/VB/C7+oG6i8Sfx/4r/13856SmLbWlT4gAAAABJRU5ErkJggg==",Mn=Object.freeze(Object.defineProperty({__proto__:null,default:In},Symbol.toStringTag,{value:"Module"})),xn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABqCAAAAAB4oTsxAAAEb0lEQVRoBb3BC5KDVgIEMPX9D937wGCD+XmS1Erxi3oSP4lH9Zt4FvdqJ3ZqJ57EndqIc/UR9+JareJBreJOXKlV/KAWcSPO1SJ+Vi9xKU7VS/xJzeJKnKi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Vn6lvs1BAfsaghVvUSRVyovdiqITZiVUMsmpqkxLXaiY2axEasahKrGlJp3Kit+CjS2Iq3GmLRKClxqz7ioyaxEx81iVmjpMS9eou3msRebNQkJk3N4kkt4q1msRdbNYlJvcSTSk1iVZP4Fjs1iUlN4lnNYlWTOIi9msVQxA9qEquaxFF8qVn8RRGrIo0T8a1m8Q/VLM7EQc3in6iXOBVnahJ/VYs4F6dqiL+pl7gUp2oVP6pVXIoL9RaP6i1uxKVaxb16i1txoz7iXG3Eg7hX31IX4lE8qB/FD+JZPYrfxE/qUvxB/EFtpdH4k/i/iv+r/wEEcJN6pgU6cwAAAABJRU5ErkJggg==",Kn=Object.freeze(Object.defineProperty({__proto__:null,default:xn},Symbol.toStringTag,{value:"Module"})),Nn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG8AAABsCAAAAABBOrMSAAAFa0lEQVRoBb3BR4IjRwADMPD/j6arc5Q0ezEQf1I/xN/Eb/UHafxB/FB3Mamn+Cm+qpN4UyfxQ3xTu/iidvFVfFS7+KlW8U18Uqv4o1rFR/GuVvEPahGfxKtaxD+qRbyLNzWLr2qIm1rEm3iqRXxVq7ioRbyIh5rFd7WLq5rEi7irWfxSu7iqWTzETU3ipPGmdnFTs7iLqxrirMSb2sVdTeImzmoWZ0W8qF081RBXcVaTOKsh3tQmnmoSF3FSk7ioSbyoQzzUJM7iUJO4qlk81Vnc1SRO4lBDXNUinuoqbmoSh9jVEFe1ibu6i5sa4hCbGuKmdnFWL+KmJrGLVQ1xU4c41Lu4qUlsYlGTuKlDLOohahJPRWxiVpO4qZOY1V1qES9qiFXMaoibOolFfRCvahKLmNUQN3USi3oTH9UQi5jUEDdNHWJVZ6khvqghZjEp4q5O4lAX8V0NMYuhhripVUqc1EX8UMQsqCFuapUiDnUVtYkXNcQkqCFuapESh1qEehN3NcQk1BB3NUuJXc1iUg8pcVfEJNQQN3WITU1iVu/iroYYQg1xVYdY1SQm9UXcFDFEDXHVqFWsaohJ7VIPcVP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9zUEL81JV7VJJ7irob4gxIvahYv4qFm8UMRTzWLN/GihvihaTzUIl7Fm5rEv6tFvIt3NYl/U4v4JN7VLP6uNvFRfFKb+K128UV8VCfxTe3iq/imDvGmTtL4IX6ou5jUU/wUv9SrUIdU/EH8Qf0UfxN/U5/F38U/qJto/JP4f8X/6z8dVxuL55I6qgAAAABJRU5ErkJggg==",Tn=Object.freeze(Object.defineProperty({__proto__:null,default:Nn},Symbol.toStringTag,{value:"Module"})),Cn=Object.assign({"/assets/chess_templates/black_bishop.png":cn,"/assets/chess_templates/black_cannon.png":un,"/assets/chess_templates/black_guard.png":gn,"/assets/chess_templates/black_king.png":pn,"/assets/chess_templates/black_knight.png":wn,"/assets/chess_templates/black_pawn.png":_n,"/assets/chess_templates/black_rook.png":Un,"/assets/chess_templates/red_bishop.png":Rn,"/assets/chess_templates/red_cannon.png":kn,"/assets/chess_templates/red_guard.png":bn,"/assets/chess_templates/red_king.png":vn,"/assets/chess_templates/red_knight.png":Mn,"/assets/chess_templates/red_pawn.png":Kn,"/assets/chess_templates/red_rook.png":Tn});function Qn(i,e){const o=new cv.Mat;return cv.resize(i,o,new cv.Size(e[0],e[1])),o}async function An(i=[60,60]){var o;const e={};for(const[t,s]of Object.entries(Cn)){const n=(o=t.split("/").pop())==null?void 0:o.split(".")[0];if(n){const l=new Image;l.src=s.default,await new Promise(u=>{l.onload=u});const r=cv.imread(l),c=new cv.Mat;cv.cvtColor(r,c,cv.COLOR_RGBA2GRAY);const a=Qn(c,i);e[n]=a,r.delete(),c.delete()}}return e}function jn(i,e,o){let t=-1,s="none";const n=[i.cols,i.rows],l=new cv.Mat;i.channels()===4?cv.cvtColor(i,l,cv.COLOR_RGBA2GRAY):i.channels()===3?cv.cvtColor(i,l,cv.COLOR_RGB2GRAY):i.copyTo(l);const r=Object.entries(e).filter(([a,u])=>o==="red"?a.startsWith("red_"):o==="black"?a.startsWith("black_"):!0);for(const[a,u]of r){const h=new cv.Mat;cv.resize(u,h,new cv.Size(n[0],n[1]));const g=new cv.Mat;cv.matchTemplate(l,h,g,cv.TM_CCOEFF_NORMED);const m=cv.minMaxLoc(g);if(m.maxVal>t){t=m.maxVal;const p={king:"k",guard:"a",bishop:"b",knight:"n",rook:"r",cannon:"c",pawn:"p"},E=a.split("_")[1];s=p[E]||"none"}h.delete(),g.delete()}return l.delete(),t>.3?s:"none"}function Jn({onImageUpload:i}){const e=ze(null);return x("section",{className:"upload-section",children:[x("h2",{children:"上传图片"}),x("input",{ref:e,type:"file",onChange:s=>{var l;const n=(l=s.target.files)==null?void 0:l[0];if(n){const r=new FileReader;r.onload=c=>{var u;const a=new Image;a.onload=()=>i(a),a.src=(u=c.target)==null?void 0:u.result},r.readAsDataURL(n)}},accept:"image/*",style:{display:"none"}}),x("button",{onClick:()=>{var s;(s=e.current)==null||s.click()},children:"选择图片"})]})}const Wn=360;function Gn({overlayImageSrc:i,chessboardRect:e={x:0,y:0,width:0,height:0},originalImageSize:o={width:0,height:0}}){const s=Math.max(0,e.x-15),n=Math.max(0,e.y-15),l=Math.min(o.width-s,e.width+2*15),r=Math.min(o.height-n,e.height+2*15),c=Math.min(1,Wn/Math.max(l,r)),a=o.width/l,u=l*c,h=r*c,g=u*a,m=(u-g)/2;return x("section",{className:"board-result-section",children:[x("h2",{children:"分析结果"}),x("div",{className:"image-container",style:{width:`${u}px`,paddingBottom:`${h}px`},children:x("img",{src:i,alt:"分析结果",className:"overlay-image",style:{left:`${m}px`,width:`${g}px`,height:`${o.height*c}px`,marginTop:`${-n*c}px`}})})]})}function Yn({fenCode:i,onCopy:e}){return x("div",{className:"fen-section",children:[x("h2",{children:"FEN代码"}),x("div",{className:"fen-container",children:[x("input",{type:"text",value:i,readOnly:!0}),x("button",{onClick:e,children:"复制"})]})]})}const Qe={k:"将",a:"士",b:"象",n:"馬",r:"車",c:"砲",p:"卒",K:"帥",A:"仕",B:"相",N:"傌",R:"俥",C:"炮",P:"兵"};function On({fen:i,bestMove:e}){const[o,t]=H([]),s=ze(null),[n,l]=H(1);Et(()=>{const u=r(i);t(u)},[i]),Et(()=>{s.current&&(c(),e&&a(e))},[o,e]),Et(()=>{function u(){if(s.current){const g=window.innerWidth*.8,m=8*40+40,p=Math.min(1,g/m);l(p)}}return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);function r(u){const h=u.split(" ")[0].split("/"),g=[];for(let m of h){const p=[];for(let E of m)if(isNaN(parseInt(E))){const _=E===E.toUpperCase()?"red":"black",f=E.toLowerCase();p.push({color:_,type:f})}else{const _=parseInt(E);for(let f=0;f<_;f++)p.push(null)}g.push(p)}return g}function c(){const u=s.current;if(!u)return;const h=u.getContext("2d");if(!h)return;const g=40,m=g/2,p=8*g+2*m,E=9*g+2*m;u.width=p*n,u.height=E*n,h.scale(n,n),h.fillStyle="#f0d9b5",h.fillRect(0,0,u.width,u.height),h.strokeStyle="#000",h.lineWidth=1;for(let w=0;w<=9;w++)h.beginPath(),h.moveTo(m,w*g+m),h.lineTo(p-m,w*g+m),h.stroke();for(let w=0;w<=8;w++)h.beginPath(),h.moveTo(w*g+m,m),h.lineTo(w*g+m,4*g+m),h.stroke(),h.beginPath(),h.moveTo(w*g+m,5*g+m),h.lineTo(w*g+m,E-m),h.stroke();h.beginPath(),h.moveTo(m,4*g+m),h.lineTo(m,5*g+m),h.stroke(),h.beginPath(),h.moveTo(p-m,4*g+m),h.lineTo(p-m,5*g+m),h.stroke(),h.font='18px "KaiTi", "楷体", sans-serif',h.fillStyle="rgba(0, 0, 0, 0.5)",h.textAlign="center",h.textBaseline="middle",h.fillText("楚 河",2*g+m,4.5*g+m),h.fillText("漢 界",6*g+m,4.5*g+m),h.beginPath(),h.moveTo(3*g+m,m),h.lineTo(5*g+m,2*g+m),h.moveTo(5*g+m,m),h.lineTo(3*g+m,2*g+m),h.moveTo(3*g+m,7*g+m),h.lineTo(5*g+m,9*g+m),h.moveTo(5*g+m,7*g+m),h.lineTo(3*g+m,9*g+m),h.stroke();function _(w,U,q=!1){if(!h)return;const R=g*.15,k=-g*.25;h.strokeStyle="rgba(0, 0, 0, 0.4)",h.lineWidth=1,(!q||w

p/2)&&(h.beginPath(),h.moveTo(w+R+k,U-k),h.lineTo(w+R+k,U-R-k),h.lineTo(w+k,U-R-k),h.stroke(),h.beginPath(),h.moveTo(w+R+k,U+k),h.lineTo(w+R+k,U+R+k),h.lineTo(w+k,U+R+k),h.stroke())}_(1*g+m,2*g+m),_(7*g+m,2*g+m),_(1*g+m,7*g+m),_(7*g+m,7*g+m);for(let w=0;w<5;w++){const U=w===0||w===4;_(2*w*g+m,3*g+m,U),_(2*w*g+m,6*g+m,U)}h.font="14px Arial",h.textAlign="center",h.textBaseline="middle",h.fillStyle="rgba(0, 0, 0, 0.4)";const f=["一","二","三","四","五","六","七","八","九"];for(let w=0;w<9;w++)h.fillText(f[w],(8-w)*g+m,E-m/2);for(let w=0;w<9;w++)h.fillText((9-w).toString(),(8-w)*g+m,m/2);o.forEach((w,U)=>{w.forEach((q,R)=>{if(q){const k=R*g+m,F=U*g+m,V=g*.4;h.beginPath(),h.arc(k+2,F+2,V,0,Math.PI*2),h.fillStyle="rgba(0, 0, 0, 0.3)",h.fill(),h.beginPath(),h.arc(k,F,V,0,Math.PI*2),h.fillStyle=q.color==="red"?"#ffcccc":"#e0e0e0",h.fill(),h.strokeStyle=q.color==="red"?"#c00000":"#000000",h.lineWidth=2,h.stroke(),h.fillStyle=q.color==="red"?"#c00000":"#000000",h.font='bold 25px "LiSu", "隶书", "STKaiti", "楷体", "KaiTi", "SimKai", sans-serif',h.textAlign="center",h.textBaseline="middle";const K=q.type.toUpperCase(),d=q.color==="red"?Qe[K]:Qe[K.toLowerCase()];h.fillText(d,k,F-V*.12)}})})}function a(u){const h=s.current;if(!h)return;const g=h.getContext("2d");if(!g)return;const m=40,p=m/2,[E,_]=u.match(/.{2}/g)||[];if(!E||!_)return;const f=E.charCodeAt(0)-97,w=9-parseInt(E[1]),U=_.charCodeAt(0)-97,q=9-parseInt(_[1]),R=f*m+p,k=w*m+p,F=U*m+p,V=q*m+p;g.beginPath(),g.moveTo(R,k),g.lineTo(F,V),g.strokeStyle="rgba(0, 0, 255, 0.7)",g.lineWidth=3,g.stroke();const K=Math.atan2(V-k,F-R);g.beginPath(),g.moveTo(F,V),g.lineTo(F-15*Math.cos(K-Math.PI/6),V-15*Math.sin(K-Math.PI/6)),g.lineTo(F-15*Math.cos(K+Math.PI/6),V-15*Math.sin(K+Math.PI/6)),g.closePath(),g.fillStyle="rgba(0, 0, 255, 0.7)",g.fill()}return x("div",{style:{width:"100%",display:"flex",justifyContent:"center"},children:x("canvas",{ref:s,className:"chessboard",style:{maxWidth:"80vw",height:"auto"}})})}function Ln(i,e){const[o,t]=i.trim().split(/\s+/),s=o.split("/");if(s.length!==10)throw new Error("无效的 FEN:行数不正确");const n=[];for(const q of s){const R=[];for(const k of q)if(k>="1"&&k<="9"){const F=parseInt(k,10);for(let V=0;V{let R="",k=0;for(const F of q)F?(k>0&&(R+=k.toString(),k=0),R+=F):k+=1;return k>0&&(R+=k.toString()),R}).join("/")} ${_} - - 0 1`}function Ae(i,e){const o={K:"帅",A:"仕",B:"相",N:"马",R:"车",C:"炮",P:"兵",k:"将",a:"士",b:"象",n:"马",r:"车",c:"炮",p:"卒"},t="abcdefghi",s=["零","一","二","三","四","五","六","七","八","九"],[n]=i.trim().split(/\s+/),l=n.split("/"),r=[];for(const w of l){const U=[];for(const q of w)if(q>="1"&&q<="9"){const R=parseInt(q,10);for(let k=0;k="A"&&g<="Z",p=o[g],E=m?s[9-c]:` ${c+1} `;let _="",f="";return c===u?(_=m?a>h?"进":"退":ah?"进":"退":a{const E=r[p],_=Ae(E,m);return x("span",{className:"move-item",children:_},p)}),h=i==="red_wins"||i==="black_wins",g=i==="red_wins"?"红方胜":i==="black_wins"?"黑方胜":"";return x("div",{className:"solution-section",children:[x("h2",{children:"解法展示"}),x("div",{className:"chessboard-display",children:x(On,{fen:l,bestMove:h?"":i})}),x("div",{className:"solution-controls",children:[x("button",{onClick:s,disabled:n.length===0,children:"上一步"}),x("button",{onClick:t,disabled:e||!i||h,children:"下一步"})]}),x("div",{className:"solution-debug",children:[e&&x("p",{children:"正在计算最佳走法..."}),o&&x("p",{style:{color:"red"},children:o}),!h&&i&&x("p",{children:[c,"最佳走法:",Ae(l,i)," (第 ",a," ","步)"]}),h&&x("p",{style:{fontWeight:"bold",color:"green"},children:g})]}),x("div",{className:"move-list",children:u})]})}function Bn(i,e){return{k:e==="red"?"K":"k",a:e==="red"?"A":"a",b:e==="red"?"B":"b",n:e==="red"?"N":"n",r:e==="red"?"R":"r",c:e==="red"?"C":"c",p:e==="red"?"P":"p",none:""}[i]}function Pn(i,e="red"){const o=[];for(const l of i){let r=0,c="";for(const a of l)if(a==="none")r++;else{r>0&&(c+=r.toString(),r=0);const[u,h]=a.split("_");c+=Bn(h,u)}r>0&&(c+=r.toString()),o.push(c),console.log(`FEN row: ${c}`)}const n=`${o.join("/")} ${e==="red"?"w":"b"} - - 0 1`;return console.log(`Generated FEN: ${n}`),n}const Xn="modulepreload",zn=function(i){return"/xiangqi-analysis/"+i},je={},Zn=function(e,o,t){let s=Promise.resolve();if(o&&o.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),r=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.allSettled(o.map(c=>{if(c=zn(c),c in je)return;je[c]=!0;const a=c.endsWith(".css"),u=a?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=a?"stylesheet":Xn,a||(h.as="script"),h.crossOrigin="",h.href=c,r&&h.setAttribute("nonce",r),document.head.appendChild(h),a)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function n(l){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=l,window.dispatchEvent(r),!r.defaultPrevented)throw l}return s.then(l=>{for(const r of l||[])r.status==="rejected"&&n(r.reason);return e().catch(n)})};class Hn{constructor(){this.engineReady=!1,this.currentResolve=null}async initEngine(){if(!this.engineReady)try{const e=await Zn(()=>import("./pikafish-ZteQ764f.js"),[]),o=e.default||e;window.Pikafish=o,this.engineInstance=await o({locateFile:t=>t==="pikafish.data"?`/xiangqi-analysis/wasm/data/${t}`:`/xiangqi-analysis/wasm/${t}`}),await this.engineInstance.ready,this.engineInstance.read_stdout=t=>{console.log("> ",t);const s=t.match(/bestmove\s(\S+)/);s&&this.currentResolve&&(this.currentResolve(s[1]),this.currentResolve=null)},this.engineInstance.send_command("uci"),this.engineReady=!0}catch(e){console.error("Failed to initialize Pikafish:",e)}}async getBestMove(e,o=14){if(!this.engineReady)throw new Error("Engine is not ready");return new Promise((t,s)=>{try{this.currentResolve=n=>{if(n==="(none)"){const r=e.split(" ")[1];t(r==="b"?"red_wins":"black_wins")}else t(n)},this.engineInstance.send_command(`position fen ${e}`),this.engineInstance.send_command(`go depth ${o}`),setTimeout(()=>{this.currentResolve&&(s(new Error("Engine timeout")),this.currentResolve=null)},5e3)}catch(n){s(n)}})}}function $n(){const[i,e]=H(""),[o,t]=H(""),[s,n]=H([]),[l,r]=H(null),[c,a]=H(""),[u,h]=H(!1),[g,m]=H(null),[p,E]=H([]),[_,f]=H(null),[w,U]=H(),[q,R]=H(),k=Number(localStorage.getItem("depth"))||14,[F,V]=H(k);Et(()=>{(async()=>{await new Promise(I=>{cv.onRuntimeInitialized=I}),console.log("OpenCV.js is ready");try{const I=await An();if(Object.keys(I).length===0){console.error("No templates were successfully loaded");return}f(I)}catch(I){console.error("Error loading templates:",I)}const N=new Hn;await N.initEngine(),r(N)})()},[]);const K=(M,N)=>{R({width:M.width,height:M.height});const{gridCells:I,chessboardRect:j}=zs(M);console.log("Original image size:",M.width,M.height),console.log("Detected chessboard rect:",j);const W={x:Math.max(0,j.x),y:Math.max(0,j.y),width:Math.min(j.width,M.width-j.x),height:Math.min(j.height,M.height-j.y)};console.log("Adjusted chessboard rect:",W),U(W);const P=[];for(let J=0;JArray(9).fill("none"));P.forEach(J=>{const[L,D]=J.position;J.type!==null&&(T[L][D]=`${J.color}_${J.type}`)});const O=Pn(T,"red");t(O),n([O])};Et(()=>{o&&l&&b(o)},[o,l,F]);const d=()=>{navigator.clipboard.writeText(o)},S=M=>{V(M),localStorage.setItem("depth",M.toString())},b=ko(async M=>{if(l){h(!0),m(null);try{const N=await l.getBestMove(M,F);if(a(N),N==="red_wins"||N==="black_wins"){h(!1);return}}catch(N){m(`Error: ${N.message}`)}finally{h(!1)}}},[l,F]);return x(qt,{children:[x("header",{children:x("h1",{children:"象棋棋盘识别与分析"})}),x("main",{className:"app-container",children:x("div",{className:"content-wrapper",children:[x("div",{className:"left-column",children:x(Dn,{bestMove:c,loading:u,error:g,onNextMove:async()=>{if(!c||c==="red_wins"||c==="black_wins"){m("No valid move available");return}const M=Ln(o,c);t(M),n(N=>[...N,M]),E(N=>[...N,c]),a("")},onPreviousMove:()=>{if(s.length>1){const M=s.slice(0,-1),N=p.slice(0,-1),I=M[M.length-1];n(M),E(N),t(I),a("")}},moveHistory:p,fenCode:o,fenHistory:s})}),x("div",{className:"right-column",children:[x(Jn,{onImageUpload:M=>{_?(n([]),E([]),a(""),m(null),K(M,_)):console.error("Templates not loaded yet")}}),x(Gn,{overlayImageSrc:i,chessboardRect:w,originalImageSize:q}),x(Yn,{fenCode:o,onCopy:d}),x("div",{className:"depth-control-section",children:[x("h2",{children:"搜索深度控制"}),x("div",{className:"depth-slider-container",children:[x("label",{htmlFor:"depth-slider",children:["当前深度: ",F]}),x("input",{id:"depth-slider",type:"range",min:"10",max:"30",value:F,onChange:M=>{M.target instanceof HTMLInputElement&&S(Number(M.target.value))}})]})]})]})]})}),x("footer",{children:x("p",{children:["© 2024 象棋棋盘识别与分析系统 | Powered by ",x("a",{href:"https://github.com/official-pikafish/Pikafish",children:" Pikafish"})," | ",x("a",{href:"https://github.com/iFwu/xiangqi-analysis",children:"GitHub 源码仓库"})]})})]})}yo(x($n,{}),document.getElementById("app")); diff --git a/index.html b/index.html index 36e1828..d818077 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@ 象棋棋盘识别与分析系统 | 在线象棋分析工具 - +