UNPKG

stockfish

Version:

The Stockfish chess engine in Web Assembly (WASM)

14 lines 43.1 kB
/*! * Stockfish.js 16 (c) 2023, Chess.com, LLC * https://github.com/nmrugg/stockfish.js * License: GPLv3 * * Based on stockfish.wasm (c) * Niklas Fiekas <niklas.fiekas@backscattering.de> * Hiroshi Ogawa <hi.ogawa.zz@gmail.com> * https://github.com/niklasf/stockfish.wasm * https://github.com/hi-ogawa/Stockfish * * Based on Stockfish (c) T. Romstad, M. Costalba, J. Kiiski, G. Linscott and other contributors. * https://github.com/official-stockfish/Stockfish */!function(){var $t,n,t,r,e,a,o;function i(){function e(M){var i,k,T,t,n;M=M||{},(i=i||(void 0!==M?M:{})).ready=new Promise(function(e,t){k=e,T=t}),"undefined"==typeof XMLHttpRequest&&(global.XMLHttpRequest=function(){var n,r={open:function(e,t){n=t},send:function(){require("fs").readFile(n,function(e,t){r.readyState=4,e?(console.error(e),r.status=404,r.onerror(e)):(r.status=200,r.response=t,r.onreadystatechange(),r.onload())})}};return r}),i.postCustomMessage=function(e){for(var t of v.ya)t.postMessage({cmd:"custom",userData:e})},i.queue=(n=[],{get:async function(){return!B&&0<n.length?n.shift():await new Promise(function(e){return t=e})},put:function(e){t?(t(e),t=null):n.push(e)},process:function(){t&&n.length&&t(n.shift())}}),i.onCustomMessage=function(e){B?q.push(e):i.queue.put(e)};var B,e,q=[],N=(i.pauseQueue=function(){B=!0},i.unpauseQueue=function(){var e=q;B=!(q=[]),e.forEach(function(e){i.queue.put(e)}),i.queue.process()},i.postMessage=i.postCustomMessage,[]),W=(i.addMessageListener=function(e){N.push(e)},i.removeMessageListener=function(e){0<=(e=N.indexOf(e))&&N.splice(e,1)},i.print=i.printErr=function(e){if("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"!==e){if(0===N.length)return console.log(e);for(var t of N)t(e)}},i.terminate=function(){v.Ra()},i.__IS_NON_NESTED__=!0,{});for(e in i)i.hasOwnProperty(e)&&(W[e]=i[e]);var H=[],Y="./this.program";function G(e,t){if(0!==e)throw t}var r,V,z="object"==typeof window,o="function"==typeof importScripts,s="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f=i.ENVIRONMENT_IS_PTHREAD||!1,a="";function Q(e){return i.locateFile?i.locateFile(e,a):a+e}if(s){var a=o?require("path").dirname(a)+"/":__dirname+"/",X=function(e,t){return r=r||require("fs"),e=(V=V||require("path")).normalize(e),r.readFileSync(e,t?null:"utf8")},K=function(e){return re((e=(e=X(e,!0)).buffer?e:new Uint8Array(e)).buffer),e};1<process.argv.length&&(Y=process.argv[1].replace(/\\/g,"/")),H=process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof S))throw e}),process.on("unhandledRejection",y),G=function(e,t){if(_e())throw process.exitCode=e,t;process.exit(e)},i.inspect=function(){return"[Emscripten Module object]"};try{d=require("worker_threads")}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}global.Worker=d.Worker}else(z||o)&&(o?a=self.location.href:"undefined"!=typeof document&&document.currentScript&&(a=document.currentScript.src),a=0!==(a=Jt?Jt:a).indexOf("blob:")?a.substr(0,a.lastIndexOf("/")+1):"",s?(X=function(e,t){return r=r||require("fs"),e=(V=V||require("path")).normalize(e),r.readFileSync(e,t?null:"utf8")},K=function(e){return re((e=(e=X(e,!0)).buffer?e:new Uint8Array(e)).buffer),e}):(X=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},o&&(K=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})));s&&"undefined"==typeof performance&&(global.performance=require("perf_hooks").performance);var J,$,Z=i.print||console.log.bind(console),l=i.printErr||console.warn.bind(console);for(e in W)W.hasOwnProperty(e)&&(i[e]=W[e]);W=null,i.arguments&&(H=i.arguments),i.thisProgram&&(Y=i.thisProgram),i.quit&&(G=i.quit),i.wasmBinary&&($=i.wasmBinary);var ee=i.noExitRuntime||!1;"object"!=typeof WebAssembly&&y("no native wasm support detected");var u,te,ne,c=!1;function re(e,t){e||y("Assertion failed: "+t)}function ae(e){var t=new TextDecoder(e);this.decode=function(e){return e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),t.decode.call(t,e)}}var h,I,D,_,C,oe,ie="undefined"!=typeof TextDecoder?new ae("utf8"):void 0;function se(e,t,n){var r=t+n;for(n=t;e[n]&&!(r<=n);)++n;if(16<n-t&&e.subarray&&ie)return ie.decode(e.subarray(t,n));for(r="";t<n;){var a,o,i=e[t++];128&i?(a=63&e[t++],192==(224&i)?r+=String.fromCharCode((31&i)<<6|a):(o=63&e[t++],(i=224==(240&i)?(15&i)<<12|a<<6|o:(7&i)<<18|a<<12|o<<6|63&e[t++])<65536?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)))):r+=String.fromCharCode(i)}return r}function O(e){return e?se(I,e,void 0):""}function F(e,t,n,r){if(0<r){r=n+r-1;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if((o=55296<=o&&o<=57343?65536+((1023&o)<<10)|1023&e.charCodeAt(++a):o)<=127){if(r<=n)break;t[n++]=o}else{if(o<=2047){if(r<=n+1)break;t[n++]=192|o>>6}else{if(o<=65535){if(r<=n+2)break;t[n++]=224|o>>12}else{if(r<=n+3)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63}t[n++]=128|o>>6&63}t[n++]=128|63&o}}t[n]=0}}function ue(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);(r=55296<=r&&r<=57343?65536+((1023&r)<<10)|1023&e.charCodeAt(++n):r)<=127?++t:t=r<=2047?t+2:r<=65535?t+3:t+4}return t}function ce(e){var t=ue(e)+1,n=Nt(t);return F(e,h,n,t),n}"undefined"!=typeof TextDecoder&&new ae("utf-16le"),f&&(fe=i.buffer);var d=i.INITIAL_MEMORY||536870912;if(f)u=i.wasmMemory,fe=i.buffer;else if(i.wasmMemory)u=i.wasmMemory;else if(!((u=new WebAssembly.Memory({initial:d/65536,maximum:d/65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw l("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),s&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");(fe=u?u.buffer:fe).byteLength;var fe=d=fe,le=(i.HEAP8=h=new Int8Array(d),i.HEAP16=new Int16Array(d),i.HEAP32=_=new Int32Array(d),i.HEAPU8=I=new Uint8Array(d),i.HEAPU16=D=new Uint16Array(d),i.HEAPU32=C=new Uint32Array(d),i.HEAPF32=new Float32Array(d),i.HEAPF64=oe=new Float64Array(d),[]),de=[],pe=[],me=[],he=[],R=0;function _e(){return ee||0<R}var p,m=0,ye=null,ge=null;function ve(){m++,i.monitorRunDependencies&&i.monitorRunDependencies(m)}function we(){var e;m--,i.monitorRunDependencies&&i.monitorRunDependencies(m),0==m&&(null!==ye&&(clearInterval(ye),ye=null),ge)&&(e=ge,ge=null,e())}function y(e){throw i.onAbort&&i.onAbort(e),re(!f),l(e),c=!0,ne=1,e=new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info."),T(e),e}function be(){return p.startsWith("data:application/octet-stream;base64,")}function Ee(){var e=p;try{if(e==p&&$)return new Uint8Array($);if(K)return K(e);throw"both async and sync fetching of the wasm failed"}catch(e){y(e)}}i.preloadedImages={},i.preloadedAudios={},p="stockfish-nnue-16-no-Worker.wasm",be()||(p=Q(p));var Ae={30597:function(){throw"Canceled!"}};function g(e){for(;0<e.length;){var t,n=e.shift();"function"==typeof n?n(i):"number"==typeof(t=n.Pa)?void 0===n.Aa?Gt.call(null,t):P.apply(null,[t,n.Aa]):t(void 0===n.Aa?null:n.Aa)}}function xe(e,t){if(e<=0||e>h.length||1&e||t<0)return-28;if(0==t)return 0;2147483647<=t&&(t=1/0);var n=Atomics.load(_,zt>>2),r=0;if(n==e&&Atomics.compareExchange(_,zt>>2,n,0)==n&&(r=1,--t<=0))return 1;if(0<=(e=Atomics.notify(_,e>>2,t)))return e+r;throw"Atomics.notify returned an unexpected value "+e}function Se(e){if(f)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!e)throw"Internal Error! Null pthread_ptr in cleanupThread!";var t=v.va[e];t&&(_[e+12>>2]=0,v.Ja(t.worker))}i._emscripten_futex_wake=xe;var v={xa:[],ya:[],Ta:[],gb:function(){for(var e=0;e<4;++e)v.Ua()},hb:function(){for(var e=U(228),t=0;t<57;++t)C[e/4+t]=0;_[e+12>>2]=e,_[(t=e+152)>>2]=t;for(var n=U(512),t=0;t<128;++t)C[n/4+t]=0;Atomics.store(C,e+100>>2,n),Atomics.store(C,e+40>>2,e),jt(e,!o,1),kt(e)},ib:function(){v.receiveObjectTransfer=v.kb,v.threadInit=v.pb,v.threadCancel=v.ob,v.threadExit=v.ab,v.setExitStatus=v.mb},va:{},Sa:[],Za:function(){for(;0<v.Sa.length;)v.Sa.pop()();Pt()},$a:function(e,t){Atomics.store(C,e+56>>2,1),Atomics.store(C,e+60>>2,0),v.Za(),Atomics.store(C,e+4>>2,t),Atomics.store(C,e+0>>2,1),xe(e+0,2147483647),jt(0,0,0)},mb:function(e){ne=e},ab:function(e){var t=x();t&&(v.$a(t,e),f)&&postMessage({cmd:"exit"})},ob:function(){v.$a(x(),-1),postMessage({cmd:"cancelDone"})},Ra:function(){for(var e in v.va){var t=v.va[e];t&&t.worker&&v.Ja(t.worker)}for(v.va={},e=0;e<v.xa.length;++e){var n=v.xa[e];n.terminate()}for(v.xa=[],e=0;e<v.ya.length;++e)t=(n=v.ya[e]).ua,v.Oa(t),n.terminate();v.ya=[]},Oa:function(e){var t;e&&(e.wa&&(t=_[e.wa+100>>2],_[e.wa+100>>2]=0,A(t),A(e.wa)),e.wa=0,e.Na&&e.za&&A(e.za),e.za=0,e.worker)&&(e.worker.ua=null)},Ja:function(e){v.lb(function(){delete v.va[e.ua.wa],v.xa.push(e),v.ya.splice(v.ya.indexOf(e),1),v.Oa(e.ua),e.ua=void 0})},lb:function(e){_[Vt>>2]=0;try{e()}finally{_[Vt>>2]=1}},kb:function(){},pb:function(){for(var e in v.Ta)v.Ta[e]()},Xa:function(a,o){a.onmessage=function(e){var t=e.data,n=t.cmd;if(a.ua&&(v.bb=a.ua.wa),t.targetThread&&t.targetThread!=x()){var r=v.va[t.Hb];r?r.worker.postMessage(e.data,t.transferList):l('Internal error! Worker sent a message "'+n+'" to target pthread '+t.targetThread+", but that thread no longer exists!")}else if("processQueuedMainThreadWork"===n)Dt();else if("spawnThread"===n)ke(e.data);else if("cleanupThread"===n)Se(t.thread);else if("killThread"===n){if(e=t.thread,f)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!e)throw"Internal Error! Null pthread_ptr in killThread!";_[e+12>>2]=0,t=v.va[e],delete v.va[e],t.worker.terminate(),v.Oa(t),v.ya.splice(v.ya.indexOf(t.worker),1),t.worker.ua=void 0}else if("cancelThread"===n){if(e=t.thread,f)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!e)throw"Internal Error! Null pthread_ptr in cancelThread!";v.va[e].worker.postMessage({cmd:"cancel"})}else if("loaded"===n)a.loaded=!0,o&&o(a),a.Da&&(a.Da(),delete a.Da);else if("print"===n)Z("Thread "+t.threadId+": "+t.text);else if("printErr"===n)l("Thread "+t.threadId+": "+t.text);else if("alert"===n)alert("Thread "+t.threadId+": "+t.text);else if("exit"===n)a.ua&&Atomics.load(C,a.ua.wa+64>>2)&&v.Ja(a);else if("exitProcess"===n)try{Xt(t.returnCode)}catch(e){if(e instanceof S)return;throw e}else"cancelDone"===n?v.Ja(a):"objectTransfer"!==n&&("setimmediate"===e.data.target?a.postMessage(e.data):l("worker sent an unknown command "+n));v.bb=void 0},a.onerror=function(e){l("pthread sent an error! "+e.filename+":"+e.lineno+": "+e.message)},s&&(a.on("message",function(e){a.onmessage({data:e})}),a.on("error",function(e){a.onerror(e)}),a.on("exit",function(){})),a.postMessage({cmd:"load",urlOrBlob:i.mainScriptUrlOrBlob||Jt,wasmMemory:u,wasmModule:te})},Ua:function(){var e=Q("stockfish.worker.js");v.xa.push(new Worker(e))},eb:function(){return 0==v.xa.length&&(v.Ua(),v.Xa(v.xa[0])),v.xa.pop()},wb:function(e){for(e=performance.now()+e;performance.now()<e;);}};function Me(e,t){if(f)return w(1,1,e,t);me.unshift({Pa:e,Aa:t})}function ke(e){if(f)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var t=v.eb();if(!t)return 6;if(void 0!==t.ua)throw"Internal error!";if(!e.Ia)throw"Internal error, no pthread ptr!";v.ya.push(t);for(var n=U(512),r=0;r<128;++r)_[n+4*r>>2]=0;var a=e.za+e.Ba,o=(r=v.va[e.Ia]={worker:t,za:e.za,Ba:e.Ba,Na:e.Na,wa:e.Ia}).wa>>2,i=(Atomics.store(C,16+o,e.detached),Atomics.store(C,25+o,n),Atomics.store(C,10+o,r.wa),Atomics.store(C,20+o,e.Ba),Atomics.store(C,19+o,a),Atomics.store(C,26+o,e.Ba),Atomics.store(C,28+o,a),Atomics.store(C,29+o,e.detached),n=Lt()+40,Atomics.store(C,43+o,n),t.ua=r,{cmd:"run",start_routine:e.nb,arg:e.Aa,threadInfoStruct:e.Ia,stackBase:e.za,stackSize:e.Ba});return t.Da=function(){i.time=performance.now(),t.postMessage(i,e.ub)},t.loaded&&(t.Da(),delete t.Da),0}function Te(e,t,n){if(e<=0||e>h.length||1&e)return-28;if(z){if(Atomics.load(_,e>>2)!=t)return-6;for(n=performance.now()+n,Atomics.exchange(_,zt>>2,e);;){if(n<performance.now())return Atomics.exchange(_,zt>>2,0),-73;if(0==Atomics.exchange(_,zt>>2,0))break;if(Dt(),Atomics.load(_,e>>2)!=t)return-6;Atomics.exchange(_,zt>>2,e)}return 0}if("timed-out"===(e=Atomics.wait(_,e>>2,t,n)))return-73;if("not-equal"===e)return-6;if("ok"===e)return 0;throw"Atomics.wait returned an unexpected value "+e}function Ie(){s||o||(J=J||{})["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]||(J["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]=1,l("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"))}i.establishStackSpace=function(e,t){Wt(e,t),qt(e)},i.invokeEntryPoint=function(e,t){return Yt.apply(null,[e,t])};var De=s?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:f?function(){return performance.now()-i.__performance_now_clock_drift}:function(){return performance.now()},Ce=[null,[],[]];function Oe(e,t){var n=Ce[e];0===t||10===t?((1===e?Z:l)(se(n,0)),n.length=0):n.push(t)}var Fe={};function Re(e,t,n){return f?w(2,1,e,t,n):0}function je(e,t,n){return f?w(3,1,e,t,n):0}function Le(e,t,n){if(f)return w(4,1,e,t,n)}function Ue(){if(f)return w(5,1);y()}var Pe=[];function Be(e){if(f)return w(6,1,e);ee=!1,R=0,Xt(e)}function w(e,t){for(var n=arguments.length-2,r=Bt(),a=Nt(8*n),o=a>>3,i=0;i<n;i++)oe[o+i]=arguments[2+i];return n=Ct(e,n,a,t),qt(r),n}var qe=[],Ne=[0,"undefined"!=typeof document?document:0,"undefined"!=typeof window?window:0];function We(e){return e=2<e?O(e):e,Ne[e]||("undefined"!=typeof document?document.querySelector(e):void 0)}function He(e,t,n){var r,a,o,i,s=We(e);return s?(s.Ha&&(_[s.Ha>>2]=t,_[s.Ha+4>>2]=n),!s.Ya&&s.yb?s.Ha?(s=_[s.Ha+8>>2],e=e?O(e):"",r=Bt(),a=Nt(12),o=0,e&&(o=ue(e)+1,i=U(o),F(e,I,i,o),o=i),_[a>>2]=o,_[a+4>>2]=t,_[a+8>>2]=n,Ot(0,s,657457152,0,o,a),qt(r),1):-4:(e=!1,(s=s.Ya?s.Ya:s).Ga&&s.Ga.Fa&&(e=0===(e=s.Ga.Fa.getParameter(2978))[0]&&0===e[1]&&e[2]===s.width&&e[3]===s.height),s.width=t,s.height=n,e&&s.Ga.Fa.viewport(0,0,t,n),0)):-4}function Ye(e,t,n){return f?w(7,1,e,t,n):He(e,t,n)}function j(e,t){if(!c)if(t)e();else{try{e()}catch(e){if(e instanceof S)return;if("unwind"!==e)throw e&&"object"==typeof e&&e.stack&&l("exception thrown: "+[e,e.stack]),e}if(!_e())try{(f?Rt:Xt)(ne)}catch(e){if(!(e instanceof S))throw e}}}var Ge,Ve=[];function L(e,t){C[e>>2]=t,C[e+4>>2]=t/4294967296|0}function ze(r,n,a,o,t){function i(e){var t=0,n=0;e&&(n=w.response?w.response.byteLength:0,t=U(n),I.set(new Uint8Array(w.response),t)),C[r+12>>2]=t,L(r+16,n)}if(p=C[r+8>>2]){var e=O(p),s=(s=O(_=r+112))||"GET",u=C[_+52>>2],c=C[_+56>>2],f=!!C[_+60>>2],l=C[_+68>>2],d=C[_+72>>2],p=C[_+76>>2],m=C[_+80>>2],h=C[_+84>>2],_=C[_+88>>2],y=!!(1&u),g=!!(2&u),u=!!(64&u),l=l?O(l):void 0,d=d?O(d):void 0,v=m?O(m):void 0,w=new XMLHttpRequest;if(w.withCredentials=f,w.open(s,e,!u,l,d),u||(w.timeout=c),w.vb=e,w.responseType="arraybuffer",m&&w.overrideMimeType(v),p)for(;(s=C[p>>2])&&(e=C[p+4>>2]);)p+=8,s=O(s),e=O(e),w.setRequestHeader(s,e);Ve.push(w),C[r+0>>2]=Ve.length,p=h&&_?I.slice(h,h+_):null,w.onload=function(e){i(y&&!g);var t=w.response?w.response.byteLength:0;L(r+24,0),t&&L(r+32,t),D[r+40>>1]=w.readyState,D[r+42>>1]=w.status,w.statusText&&F(w.statusText,I,r+44,64),200<=w.status&&w.status<300?n&&n(r,w,e):a&&a(r,w,e)},w.onerror=function(e){i(y);var t=w.status;L(r+24,0),L(r+32,w.response?w.response.byteLength:0),D[r+40>>1]=w.readyState,D[r+42>>1]=t,a&&a(r,w,e)},w.ontimeout=function(e){a&&a(r,w,e)},w.onprogress=function(e){var t=y&&g&&w.response?w.response.byteLength:0,n=0;y&&g&&(n=U(t),I.set(new Uint8Array(w.response),n)),C[r+12>>2]=n,L(r+16,t),L(r+24,e.loaded-t),L(r+32,e.total),D[r+40>>1]=w.readyState,3<=w.readyState&&0===w.status&&0<e.loaded&&(w.status=200),D[r+42>>1]=w.status,w.statusText&&F(w.statusText,I,r+44,64),o&&o(r,w,e),n&&A(n)},w.onreadystatechange=function(e){D[r+40>>1]=w.readyState,2<=w.readyState&&(D[r+42>>1]=w.status),t&&t(r,w,e)};try{w.send(p)}catch(e){a&&a(r,w,e)}}else a(r,0,"no url specified!")}function Qe(t,e,n,r){var a=Ge;if(a){var o=O(C[t+112+64>>2]||C[t+8>>2]);try{var i=a.transaction(["FILES"],"readwrite").objectStore("FILES").put(e,o);i.onsuccess=function(){D[t+40>>1]=4,D[t+42>>1]=200,F("OK",I,t+44,64),n(t,0,o)},i.onerror=function(e){D[t+40>>1]=4,D[t+42>>1]=413,F("Payload Too Large",I,t+44,64),r(t,0,e)}}catch(e){r(t,0,e)}}else r(t,0,"IndexedDB not available!")}function Xe(n,e){n.Wa||(n.Wa=n.getContext,n.getContext=function(e,t){return"webgl"==e==(t=n.Wa(e,t))instanceof WebGLRenderingContext?t:null});var t,r,a,o=n.getContext("webgl",e);{if(o){if(o=o,e=e,r=U(8),_[r+4>>2]=x(),a={Cb:r,attributes:e,version:e.jb,Fa:o},o.canvas&&(o.canvas.Ga=a),(void 0===e.Va||e.Va)&&!(o=(o=a)||Ke).fb){o.fb=!0;var i=t=o.Fa,s=i.getExtension("ANGLE_instanced_arrays"),u=(s&&(i.vertexAttribDivisor=function(e,t){s.vertexAttribDivisorANGLE(e,t)},i.drawArraysInstanced=function(e,t,n,r){s.drawArraysInstancedANGLE(e,t,n,r)},i.drawElementsInstanced=function(e,t,n,r,a){s.drawElementsInstancedANGLE(e,t,n,r,a)}),t),c=u.getExtension("OES_vertex_array_object"),f=(c&&(u.createVertexArray=function(){return c.createVertexArrayOES()},u.deleteVertexArray=function(e){c.deleteVertexArrayOES(e)},u.bindVertexArray=function(e){c.bindVertexArrayOES(e)},u.isVertexArray=function(e){return c.isVertexArrayOES(e)}),t),l=f.getExtension("WEBGL_draw_buffers");l&&(f.drawBuffers=function(e,t){l.drawBuffersWEBGL(e,t)}),t.zb=t.getExtension("EXT_disjoint_timer_query"),t.Eb=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach(function(e){e.includes("lose_context")||e.includes("debug")||t.getExtension(e)})}return r}return 0}}var Ke,Je,$e=["default","low-power","high-performance"],Ze={};function et(){if(!Je){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Y||"./this.program"};for(e in Ze)void 0===Ze[e]?delete t[e]:t[e]=Ze[e];var n=[];for(e in t)n.push(e+"="+t[e]);Je=n}return Je}function tt(r,a){var o;return f?w(8,1,r,a):(o=0,et().forEach(function(e,t){var n=a+o;for(t=_[r+4*t>>2]=n,n=0;n<e.length;++n)h[t++>>0]=e.charCodeAt(n);h[t>>0]=0,o+=e.length+1}),0)}function nt(e,t){var n,r;return f?w(9,1,e,t):(n=et(),_[e>>2]=n.length,r=0,n.forEach(function(e){r+=e.length+1}),_[t>>2]=r,0)}function rt(e){return f?w(10,1,e):0}function at(e,t,n,r){return f?w(11,1,e,t,n,r):(e=Fe.Bb(e),t=Fe.Ab(e,t,n),_[r>>2]=t,0)}function ot(e,t,n,r,a){if(f)return w(12,1,e,t,n,r,a)}function it(e,t,n,r){if(f)return w(13,1,e,t,n,r);for(var a=0,o=0;o<n;o++){for(var i=_[t+8*o>>2],s=_[t+(8*o+4)>>2],u=0;u<s;u++)Oe(e,I[i+u]);a+=s}return _[r>>2]=a,0}function st(e){return 0==e%4&&(0!=e%100||0==e%400)}function ut(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var ct=[31,29,31,30,31,30,31,31,30,31,30,31],ft=[31,28,31,30,31,30,31,31,30,31,30,31];function lt(e,t){for(e=new Date(e.getTime());0<t;){var n=e.getMonth(),r=(st(e.getFullYear())?ct:ft)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),n<11?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function dt(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function o(e,t){return a(e,t,"0")}function i(e,t){function n(e){return e<0?-1:0<e?1:0}var r;return r=0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))?n(e.getDate()-t.getDate()):r}function s(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){e=lt(new Date(e.U+1900,0,1),e.Ma);var t=new Date(e.getFullYear()+1,0,4),n=s(new Date(e.getFullYear(),0,4)),t=s(t);return i(n,e)<=0?i(t,e)<=0?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var c,f=_[r+40>>2];for(c in r={sb:_[r>>2],rb:_[r+4>>2],Ka:_[r+8>>2],Ea:_[r+12>>2],Ca:_[r+16>>2],U:_[r+20>>2],La:_[r+24>>2],Ma:_[r+28>>2],Ib:_[r+32>>2],qb:_[r+36>>2],tb:f?O(f):""},n=O(n),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),f[c]);var l,d,p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),m="January February March April May June July August September October November December".split(" ");for(c in f={"%a":function(e){return p[e.La].substring(0,3)},"%A":function(e){return p[e.La]},"%b":function(e){return m[e.Ca].substring(0,3)},"%B":function(e){return m[e.Ca]},"%C":function(e){return o((e.U+1900)/100|0,2)},"%d":function(e){return o(e.Ea,2)},"%e":function(e){return a(e.Ea,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":u,"%H":function(e){return o(e.Ka,2)},"%I":function(e){return 0==(e=e.Ka)?e=12:12<e&&(e-=12),o(e,2)},"%j":function(e){return o(e.Ea+ut(st(e.U+1900)?ct:ft,e.Ca-1),3)},"%m":function(e){return o(e.Ca+1,2)},"%M":function(e){return o(e.rb,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.Ka&&e.Ka<12?"AM":"PM"},"%S":function(e){return o(e.sb,2)},"%t":function(){return"\t"},"%u":function(e){return e.La||7},"%U":function(e){var t=new Date(e.U+1900,0,1),n=0===t.getDay()?t:lt(t,7-t.getDay());return i(n,e=new Date(e.U+1900,e.Ca,e.Ea))<0?o(Math.ceil((31-n.getDate()+(ut(st(e.getFullYear())?ct:ft,e.getMonth()-1)-31)+e.getDate())/7),2):0===i(n,t)?"01":"00"},"%V":function(e){var t=new Date(e.U+1901,0,4),n=s(new Date(e.U+1900,0,4)),t=s(t),r=lt(new Date(e.U+1900,0,1),e.Ma);return i(r,n)<0?"53":i(t,r)<=0?"01":o(Math.ceil((n.getFullYear()<e.U+1900?e.Ma+32-n.getDate():e.Ma+1-n.getDate())/7),2)},"%w":function(e){return e.La},"%W":function(e){var t=new Date(e.U,0,1),n=1===t.getDay()?t:lt(t,0===t.getDay()?1:7-t.getDay()+1);return i(n,e=new Date(e.U+1900,e.Ca,e.Ea))<0?o(Math.ceil((31-n.getDate()+(ut(st(e.getFullYear())?ct:ft,e.getMonth()-1)-31)+e.getDate())/7),2):0===i(n,t)?"01":"00"},"%y":function(e){return(e.U+1900).toString().substring(2)},"%Y":function(e){return e.U+1900},"%z":function(e){var t=0<=(e=e.qb);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.tb},"%%":function(){return"%"}})n.includes(c)&&(n=n.replace(new RegExp(c,"g"),f[c](r)));return l=n,d=Array(ue(l)+1),F(l,d,0,d.length),(c=d).length>t?0:(h.set(c,e),c.length-1)}function pt(e){try{e()}catch(e){y(e)}}var b=0,E=null,mt=0,ht=[],_t={},yt={},gt=0,vt=null,wt=[],bt=[];function Et(n){var e,r={};for(e in n)!function(e){var t=n[e];r[e]="function"==typeof t?function(){ht.push(e);try{return t.apply(null,arguments)}catch(e){if(-1===e.message.indexOf("unreachable"))throw e}finally{c||(re(ht.pop()===e),E&&1===b&&0===ht.length&&(R+=1,b=0,pt(i._asyncify_stop_unwind),"undefined"!=typeof Fibers&&Fibers.Jb(),vt)&&(vt(),vt=null))}}:t}(e);return r}function At(e){var r,a,t,n;if(!c)return 0===b?(a=r=!1,e(function(e){var t,n;!c&&(mt=e||0,r=!0,a)&&(b=2,pt(function(){i._asyncify_start_rewind(E)}),"undefined"!=typeof Browser&&Browser.Qa.Pa&&Browser.Qa.resume(),n=i.asm[yt[_[E+8>>2]]],--R,t=n(),E||(e=wt,wt=[],e.forEach(function(e){e(t)})))}),a=!0,r||(b=1,e=U(4108),t=e+12,_[e>>2]=t,_[e+4>>2]=t+4096,t=ht[0],void 0===(n=_t[t])&&(n=gt++,_t[t]=n,yt[n]=t),_[e+8>>2]=n,E=e,pt(function(){i._asyncify_start_unwind(E)}),"undefined"!=typeof Browser&&Browser.Qa.Pa&&Browser.Qa.pause())):2===b?(b=0,pt(i._asyncify_stop_rewind),A(E),E=null,bt.forEach(function(e){j(e)})):y("invalid state: "+b),mt}f||v.gb(),f||(function(t,n){try{var e=indexedDB.open("emscripten_filesystem",1)}catch(e){return n(e)}e.onupgradeneeded=function(e){(e=e.target.result).objectStoreNames.contains("FILES")&&e.deleteObjectStore("FILES"),e.createObjectStore("FILES")},e.onsuccess=function(e){t(e.target.result)},e.onerror=function(e){n(e)}}(function(e){Ge=e,we()},function(){Ge=!1,we()}),"undefined"!=typeof ENVIRONMENT_IS_FETCH_WORKER&&ENVIRONMENT_IS_FETCH_WORKER)||ve();var xt,St=[null,Me,Re,je,Le,Ue,Be,Ye,tt,nt,rt,at,ot,it],Mt={e:function(e,t,n,r){y("Assertion failed: "+O(e)+", at: "+[t?O(t):"unknown filename",n,r?O(r):"unknown function"])},b:Me,p:function(e,t){v.Sa.push(function(){P.apply(null,[e,t])})},K:function(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return l("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!e)return l("pthread_create called with a null thread pointer!"),28;var a=[];if(f&&0===a.length)return It(687865856,e,t,n,r);var o,i=0,s=0;t&&-1!=t?(o=_[t>>2],o+=81920,i=_[t+8>>2],s=0!==_[t+12>>2]):o=2097152,(t=0==i)?i=Ht(16,o):re(0<(i-=o));for(var u=U(228),c=0;c<57;++c)C[(u>>2)+c]=0;return _[e>>2]=u,_[u+12>>2]=u,_[(e=u+152)>>2]=e,n={za:i,Ba:o,Na:t,detached:s,nb:n,Ia:u,Aa:r,ub:a},f?(n.xb="spawnThread",postMessage(n,a),0):ke(n)},I:function(e){throw f?v.ab(e):(v.Za(),Xt(e)),"unwind"},J:function(e,t){var n=e,r=t;if(!n)return l("pthread_join attempted on a null thread pointer!"),71;if(f&&x()==n)return l("PThread "+n+" is attempting to join to itself!"),16;if(!f&&Tt()==n)return l("Main thread "+n+" is attempting to join to itself!"),16;if(_[n+12>>2]!==n)return l("pthread_join attempted on thread "+n+", which does not point to a valid thread, or does not exist anymore!"),71;if(Atomics.load(C,n+64>>2))return l("Attempted to join thread "+n+", which was already detached!"),28;for(Ie();;){var a=Atomics.load(C,n>>2);if(1==a)return a=Atomics.load(C,n+4>>2),r&&(_[r>>2]=a),Atomics.store(C,n+64>>2,1),f?postMessage({cmd:"cleanupThread",thread:n}):Se(n),0;Ft(),f||Dt(),Te(n,a,f?100:1)}},k:Re,w:je,x:Le,O:function(e){delete Ve[e-1]},N:function(e,t){if(e==t)postMessage({cmd:"processQueuedMainThreadWork"});else if(f)postMessage({targetThread:e,cmd:"processThreadQueue"});else{if(!(e=(e=v.va[e])&&e.worker))return;e.postMessage({cmd:"processThreadQueue"})}return 1},d:Ue,D:function(e,t){if(0===e)e=Date.now();else{if(1!==e&&4!==e)return _[Ut()>>2]=28,-1;e=De()}return _[t>>2]=e/1e3|0,_[t+4>>2]=e%1e3*1e6|0,0},P:function(e,t,n){var r;for(Pe.length=0,n>>=2;r=I[t++];)(r=r<105)&&1&n&&n++,Pe.push(r?oe[n++>>1]:_[n]),++n;return Ae[e].apply(null,Pe)},E:Ie,n:function(){},r:Be,g:Te,f:xe,h:De,u:function(e,t,n){I.copyWithin(e,t,t+n)},F:function(e,t,n){qe.length=t,n>>=3;for(var r=0;r<t;r++)qe[r]=oe[n+r];return(e<0?Ae[-e-1]:St[e]).apply(null,qe)},v:function(){y("OOM")},G:function(e,t,n){return(We(e)?He:Ye)(e,t,n)},m:function(){},M:function(e,t,n){return R+=1,setTimeout(function(){--R,j(function(){P.apply(null,[e,n])})},t)},c:function(n){At(function(e){var t;t=e,R+=1,$t(function(){--R,j(t)},n)})},o:function(e,n,t,r,a){function o(e,t){Qe(e,t.response,function(e){--R,j(function(){d?P.apply(null,[d,e]):n&&n(e)},w)},function(e){--R,j(function(){d?P.apply(null,[d,e]):n&&n(e)},w)})}function i(e){j(function(){h?P.apply(null,[h,e]):a&&a(e)},w)}function s(e){--R,j(function(){p?P.apply(null,[p,e]):t&&t(e)},w)}function u(e){j(function(){m?P.apply(null,[m,e]):r&&r(e)},w)}function c(e){--R,j(function(){d?P.apply(null,[d,e]):n&&n(e)},w)}R+=1;var f=e+112,l=O(f),d=C[f+36>>2],p=C[f+40>>2],m=C[f+44>>2],h=C[f+48>>2],_=C[f+52>>2],y=!!(4&_),g=!!(32&_),v=!!(16&_),w=!!(64&_);if("EM_IDB_STORE"===l)l=C[f+84>>2],Qe(e,I.slice(l,l+C[f+88>>2]),c,s);else if("EM_IDB_DELETE"===l){var b=e;var E=c;var A=s;_=Ge;if(_){f=C[b+112+64>>2];f=O(f=f||C[b+8>>2]);try{var x=_.transaction(["FILES"],"readwrite").objectStore("FILES").delete(f);x.onsuccess=function(e){e=e.target.result,C[b+12>>2]=0,L(b+16,0),L(b+24,0),L(b+32,0),D[b+40>>1]=4,D[b+42>>1]=200,F("OK",I,b+44,64),E(b,0,e)},x.onerror=function(e){D[b+40>>1]=4,D[b+42>>1]=404,F("Not Found",I,b+44,64),A(b,0,e)}}catch(e){A(b,0,e)}}else A(b,0,"IndexedDB not available!")}else if(v){if(g)return 0;ze(e,y?o:c,s,u,i)}else{var S=e;var M=c;var k=g?s:y?function(e){ze(e,o,s,u,i)}:function(e){ze(e,c,s,u,i)};l=Ge;if(l){_=C[S+112+64>>2];_=O(_=_||C[S+8>>2]);try{var T=l.transaction(["FILES"],"readonly").objectStore("FILES").get(_);T.onsuccess=function(e){var t,n;e.target.result?(t=(e=e.target.result).byteLength||e.length,n=U(t),I.set(new Uint8Array(e),n),C[S+12>>2]=n,L(S+16,t),L(S+24,0),L(S+32,t),D[S+40>>1]=4,D[S+42>>1]=200,F("OK",I,S+44,64),M(S,0,e)):(D[S+40>>1]=4,D[S+42>>1]=404,F("Not Found",I,S+44,64),k(S,0,"no data"))},T.onerror=function(e){D[S+40>>1]=4,D[S+42>>1]=404,F("Not Found",I,S+44,64),k(S,0,e)}}catch(e){k(S,0,e)}}else k(S,0,"IndexedDB not available!")}return e},q:function(){return t=async()=>{var e=await i.queue.get(),t=ue(e)+1,n=U(t);return F(e,I,n,t),n},At(function(e){t().then(e)});var t},H:function(e,t){return t={alpha:!!_[t>>=2],depth:!!_[t+1],stencil:!!_[t+2],antialias:!!_[t+3],premultipliedAlpha:!!_[t+4],preserveDrawingBuffer:!!_[t+5],powerPreference:$e[_[t+6]],failIfMajorPerformanceCaveat:!!_[t+7],jb:_[t+8],Db:_[t+9],Va:_[t+10],cb:_[t+11],Fb:_[t+12],Gb:_[t+13]},!(e=We(e))||t.cb?0:Xe(e,t)},B:tt,C:nt,i:function(e){Xt(e)},l:rt,z:at,t:ot,y:it,L:function(){v.hb()},a:u||i.wasmMemory,s:function(){i.pauseQueue()},A:dt,j:function(){i.unpauseQueue()}},A=(!function(){function t(e,t){var n;e=Et(e=e.exports),i.asm=e,de.unshift(i.asm.Q),v.Ta.push(i.asm.T),te=t,f||(n=v.xa.length,v.xa.forEach(function(e){v.Xa(e,function(){--n||we()})}))}function n(e){t(e.instance,e.module)}function r(e){return($||!z&&!o||"function"!=typeof fetch?Promise.resolve().then(Ee):fetch(p,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+p+"'"}).catch(Ee)).then(function(e){return WebAssembly.instantiate(e,a)}).then(e,function(e){l("failed to asynchronously prepare wasm: "+e),y(e)})}var a={a:Mt};if(f||ve(),i.instantiateWasm)try{var e=i.instantiateWasm(a,t);return Et(e)}catch(e){return l("Module.instantiateWasm callback failed with error: "+e)}($||"function"!=typeof WebAssembly.instantiateStreaming||be()||"function"!=typeof fetch?r(n):fetch(p,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,a).then(n,function(e){return l("wasm streaming compile failed: "+e),l("falling back to ArrayBuffer instantiation"),r(n)})})).catch(T)}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.Q).apply(null,arguments)},i._main=function(){return(i._main=i.asm.R).apply(null,arguments)},i._free=function(){return(A=i._free=i.asm.S).apply(null,arguments)}),U=(i._emscripten_tls_init=function(){return(i._emscripten_tls_init=i.asm.T).apply(null,arguments)},i._malloc=function(){return(U=i._malloc=i.asm.V).apply(null,arguments)}),kt=(i._emscripten_current_thread_process_queued_calls=function(){return(i._emscripten_current_thread_process_queued_calls=i.asm.W).apply(null,arguments)},i._emscripten_register_main_browser_thread_id=function(){return(kt=i._emscripten_register_main_browser_thread_id=i.asm.X).apply(null,arguments)}),Tt=i._emscripten_main_browser_thread_id=function(){return(Tt=i._emscripten_main_browser_thread_id=i.asm.Y).apply(null,arguments)},It=i._emscripten_sync_run_in_main_thread_4=function(){return(It=i._emscripten_sync_run_in_main_thread_4=i.asm.Z).apply(null,arguments)},Dt=i._emscripten_main_thread_process_queued_calls=function(){return(Dt=i._emscripten_main_thread_process_queued_calls=i.asm._).apply(null,arguments)},Ct=i._emscripten_run_in_main_runtime_thread_js=function(){return(Ct=i._emscripten_run_in_main_runtime_thread_js=i.asm.$).apply(null,arguments)},Ot=i.__emscripten_call_on_thread=function(){return(Ot=i.__emscripten_call_on_thread=i.asm.aa).apply(null,arguments)},Ft=i._pthread_testcancel=function(){return(Ft=i._pthread_testcancel=i.asm.ba).apply(null,arguments)},x=i._pthread_self=function(){return(x=i._pthread_self=i.asm.ca).apply(null,arguments)},Rt=i._pthread_exit=function(){return(Rt=i._pthread_exit=i.asm.da).apply(null,arguments)},jt=i.__emscripten_thread_init=function(){return(jt=i.__emscripten_thread_init=i.asm.ea).apply(null,arguments)},Lt=i._emscripten_get_global_libc=function(){return(Lt=i._emscripten_get_global_libc=i.asm.fa).apply(null,arguments)},Ut=i.___errno_location=function(){return(Ut=i.___errno_location=i.asm.ga).apply(null,arguments)},Pt=i.___pthread_tsd_run_dtors=function(){return(Pt=i.___pthread_tsd_run_dtors=i.asm.ha).apply(null,arguments)},Bt=i.stackSave=function(){return(Bt=i.stackSave=i.asm.ia).apply(null,arguments)},qt=i.stackRestore=function(){return(qt=i.stackRestore=i.asm.ja).apply(null,arguments)},Nt=i.stackAlloc=function(){return(Nt=i.stackAlloc=i.asm.ka).apply(null,arguments)},Wt=i._emscripten_stack_set_limits=function(){return(Wt=i._emscripten_stack_set_limits=i.asm.la).apply(null,arguments)},Ht=i._memalign=function(){return(Ht=i._memalign=i.asm.ma).apply(null,arguments)},P=i.dynCall_vi=function(){return(P=i.dynCall_vi=i.asm.na).apply(null,arguments)},Yt=i.dynCall_ii=function(){return(Yt=i.dynCall_ii=i.asm.oa).apply(null,arguments)},Gt=i.dynCall_v=function(){return(Gt=i.dynCall_v=i.asm.pa).apply(null,arguments)},Vt=(i._asyncify_start_unwind=function(){return(i._asyncify_start_unwind=i.asm.qa).apply(null,arguments)},i._asyncify_stop_unwind=function(){return(i._asyncify_stop_unwind=i.asm.ra).apply(null,arguments)},i._asyncify_start_rewind=function(){return(i._asyncify_start_rewind=i.asm.sa).apply(null,arguments)},i._asyncify_stop_rewind=function(){return(i._asyncify_stop_rewind=i.asm.ta).apply(null,arguments)},i.__emscripten_allow_main_runtime_queued_calls=29752),zt=i.__emscripten_main_thread_futex=1246688;function S(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Qt(o){function e(){if(!xt&&(xt=!0,i.calledRun=!0,!c)){if(f||g(de),f||g(pe),k(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),Kt){var t=o,e=i._main,n=(t=t||[]).length+1,r=Nt(4*(n+1));_[r>>2]=ce(Y);for(var a=1;a<n;a++)_[(r>>2)+a]=ce(t[a-1]);_[(r>>2)+n]=0;try{Xt(e(n,r),!0)}catch(e){e instanceof S||"unwind"==e||((t=e)&&"object"==typeof e&&e.stack&&(t=[e,e.stack]),l("exception thrown: "+t),G(1,e))}}if(!f){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)t=i.postRun.shift(),he.unshift(t);g(he)}}}if(o=o||H,!(0<m))if(f)k(i),f||g(de),postMessage({cmd:"loaded"});else{if(!f){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)t=void 0,t=i.preRun.shift(),le.unshift(t);g(le)}0<m||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e())}var t}function Xt(e,t){if(ne=e,!t&&f)throw postMessage({cmd:"exitProcess",returnCode:e}),new S(e);_e()||(v.Ra(),f)||(g(me),"undefined"!=typeof _fflush&&_fflush(0),Ce[1].length&&Oe(1,10),Ce[2].length&&Oe(2,10)),ne=e,_e()||(v.Ra(),i.onExit&&i.onExit(e),c=!0),G(e,new S(e))}if(i.keepRuntimeAlive=_e,i.PThread=v,i.PThread=v,i.wasmMemory=u,i.ExitStatus=S,ge=function e(){xt||Qt(),xt||(ge=e)},i.run=Qt,i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();var Kt=!0;return i.noInitialRun&&(Kt=!1),f&&(ee=!1,v.ib()),Qt(),M.ready}var Jt;Jt="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(Jt=Jt||__filename);return"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define&&define.amd?define([],function(){return e}):"object"==typeof exports&&(exports.Stockfish=e),e}"undefined"!=typeof self&&"worker"===self.location.hash.split(",")[1]||"undefined"!=typeof global&&"[object process]"===Object.prototype.toString.call(global.process)&&!require("worker_threads").isMainThread?function(){"use strict";var e,t,n,a={};"object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&(e=require("worker_threads"),(t=e.parentPort).on("message",function(e){onmessage({data:e})}),n=require("fs"),Object.assign(global,{self:global,require:require,Module:a,location:{href:__filename},Worker:e.Worker,importScripts:function(e){(0,eval)(n.readFileSync(e,"utf8"))},postMessage:function(e){t.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}}));var o=function(){var e=Array.prototype.slice.call(arguments).join(" ");console.error(e)};self.alert=function(){var e=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:e,threadId:a._pthread_self()})},a.instantiateWasm=function(e,t){e=new WebAssembly.Instance(a.wasmModule,e);return t(e),a.wasmModule=null,e.exports},self.onmessage=function(e){try{if("load"===e.data.cmd)a.wasmModule=e.data.wasmModule,a.wasmMemory=e.data.wasmMemory,a.buffer=a.wasmMemory.buffer,a.ENVIRONMENT_IS_PTHREAD=!0,i()(a).then(function(e){a=e});else if("objectTransfer"===e.data.cmd)a.PThread.receiveObjectTransfer(e.data);else if("run"===e.data.cmd){a.__performance_now_clock_drift=performance.now()-e.data.time,a.__emscripten_thread_init(e.data.threadInfoStruct,0,0);var t=e.data.stackBase,n=e.data.stackBase+e.data.stackSize;a.establishStackSpace(n,t),a.PThread.receiveObjectTransfer(e.data),a.PThread.threadInit();try{var r=a.invokeEntryPoint(e.data.start_routine,e.data.arg);a.keepRuntimeAlive()?a.PThread.setExitStatus(r):a.PThread.threadExit(r)}catch(e){if("Canceled!"===e)a.PThread.threadCancel();else if("unwind"!=e){if(!(e instanceof a.ExitStatus))throw a.PThread.threadExit(-2),e;a.keepRuntimeAlive()||a.PThread.threadExit(e.status)}}}else"cancel"===e.data.cmd?a._pthread_self()&&a.PThread.threadCancel():"setimmediate"!==e.data.target&&("processThreadQueue"===e.data.cmd?a._pthread_self()&&a._emscripten_current_thread_process_queued_calls():(o("worker.js received unknown command "+e.data.cmd),o(e.data)))}catch(e){throw o("worker.js onmessage() captured an uncaught exception: "+e),e&&e.stack&&o(e.stack),e}};const r=self.onmessage;onmessage=self.onmessage=e=>{"custom"===e.data.cmd?"function"==typeof a.onCustomMessage&&a.onCustomMessage(e.data.userData):r(e)}}():"undefined"!=typeof onmessage&&("undefined"==typeof window||void 0===window.document)||"undefined"!=typeof global&&"[object process]"===Object.prototype.toString.call(global.process)?(a="undefined"!=typeof global&&"[object process]"===Object.prototype.toString.call(global.process),o=[],a?require.main===module?(r=require("path").join(__dirname,"stockfish-nnue-16-no-Worker.wasm"),e={locateFile:function(e){return-1<e.indexOf(".wasm")?r:__filename}},i()(e).then(function(t){(n=t).addMessageListener(function(e){console.log(e)}),o.length&&o.forEach(function(e){t.postMessage(e,!0)}),o=null}),require("readline").createInterface({input:process.stdin,output:process.stdout,completer:function(t){var e=["binc ","btime ","confidence ","depth ","infinite ","mate ","maxdepth ","maxtime ","mindepth ","mintime ","moves ","movestogo ","movetime ","ponder ","searchmoves ","shallow ","winc ","wtime "];function n(e){return 0===e.indexOf(t)}var r=["compiler","d","eval","exit","flip","go ","isready ","ponderhit ","position fen ","position startpos","position startpos moves","quit","setoption name Clear Hash value true","setoption name Contempt value ","setoption name Hash value ","setoption name Minimum Thinking Time value ","setoption name Move Overhead value ","setoption name MultiPV value ","setoption name Ponder value ","setoption name Skill Level value ","setoption name Slow Mover value ","setoption name Threads value ","setoption name UCI_Chess960 value false","setoption name UCI_Chess960 value true","setoption name UCI_AnalyseMode value true","setoption name UCI_AnalyseMode value false","setoption name UCI_LimitStrength value true","setoption name UCI_LimitStrength value false","setoption name UCI_Elo value ","setoption name UCI_ShowWDL value true","setoption name UCI_ShowWDL value false","setoption name Use NNUE value true","setoption name Use NNUE value false","setoption name nodestime value ","setoption name EvalFile value ","stop","uci","ucinewgame"].filter(n);return[r=r.length?r:(t=t.replace(/^.*\s/,""))?e.filter(n):e,t]},historySize:100}).on("line",function(e){e&&("quit"!==e&&"exit"!==e||process.exit(),n?n.postMessage(e,!0):o.push(e))}).on("close",function(){process.exit()}).setPrompt("")):module.exports=i:(t=function(e){n.__IS_NON_NESTED__||n.__IS_SINGLE_THREADED__?n.onCustomMessage(e):n.postMessage(e,!0)},a=self.location.hash.substr(1).split(","),r=decodeURIComponent(a[0]||"stockfish-nnue-16-no-Worker.wasm"),e={locateFile:function(e){return-1<e.indexOf(".wasm")?r:self.location.origin+self.location.pathname+"#"+r+",worker"}},i()(e).then(function(e){(n=e).addMessageListener(function(e){postMessage(e)}),o.length&&o.forEach(function(e){t(e)}),o=null}).catch(function(e){setTimeout(function(){throw e},1)}),onmessage=onmessage||function(e){n?t(e.data):o.push(e.data)})):"object"==typeof document&&document.currentScript?document.currentScript._exports=i():i(),function(n,o){"use strict";var r,i,s,a,u,c,t;function e(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];return i[r]={callback:e,args:t},u(r),r++}function f(e){if(s)setTimeout(f,0,e);else{var t=i[e];if(t){s=!0;try{var n=t,r=n.callback,a=n.args;switch(a.length){case 0:r();break;case 1:r(a[0]);break;case 2:r(a[0],a[1]);break;case 3:r(a[0],a[1],a[2]);break;default:r.apply(o,a)}}finally{delete i[e],s=!1}}}}function l(){function e(e){e.source===n&&"string"==typeof e.data&&0===e.data.indexOf(t)&&f(+e.data.slice(t.length))}var t="setImmediate$"+Math.random()+"$";n.addEventListener?n.addEventListener("message",e,!1):n.attachEvent("onmessage",e),u=function(e){n.postMessage(t+e,"*")}}$t=(n.setImmediate||(r=1,s=!(i={}),a=n.document,"[object process]"==={}.toString.call(n.process)?u=function(e){process.nextTick(function(){f(e)})}:!function(){var e,t;if(n.postMessage&&!n.importScripts)return e=!0,t=n.onmessage,n.onmessage=function(){e=!1},n.postMessage("","*"),n.onmessage=t,e}()?u=n.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){f(e.data)},function(e){t.port2.postMessage(e)}):a&&"onreadystatechange"in a.createElement("script")?(c=a.documentElement,function(e){var t=a.createElement("script");t.onreadystatechange=function(){f(e),t.onreadystatechange=null,c.removeChild(t),t=null},c.appendChild(t)}):function(e){setTimeout(f,0,e)}:l()),e)}("undefined"==typeof self?"undefined"==typeof global?this:global:self)}();