xcore-casino
Version:
Casino Core module
1 lines • 35.7 kB
JavaScript
var __webpack_modules__={68:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{E:()=>WasmLoader});var _core_wasm_wasm_exec_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(686),_logger__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(675),_utils_wasm_support__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(806);class WasmLoader{static get wasmPath(){return WasmLoader._wasmPath}static set wasmPath(t){WasmLoader._wasmPath=t}static getCasino(){if(!WasmLoader.casinoInstance)throw WasmLoader.logger.error("Casino WASM module is not loaded"),new Error("Casino WASM module is not loaded");return WasmLoader.casinoInstance}static isLoaded(){return null!==WasmLoader.casinoInstance}static async forceReload(){return WasmLoader.casinoInstance=null,WasmLoader.wasmInstance=null,WasmLoader.isLoading=!1,WasmLoader.loadPromise=null,WasmLoader.clearCache(),WasmLoader.asyncLoad()}static async checkWasmFileAvailability(){try{WasmLoader.logger.debug(`Checking WASM file availability at ${WasmLoader.wasmPath}`);const t=await fetch(WasmLoader.wasmPath,{method:"HEAD"}),e=t.headers.get("Content-Type"),n={available:t.ok,status:t.status,contentType:e||void 0};return t.ok?e&&e.includes("application/wasm")||WasmLoader.logger.warn(`WASM file doesn't have correct MIME type: ${e||"not specified"}`):WasmLoader.logger.warn(`WASM file not available: ${t.statusText} (${t.status})`),n}catch(t){return WasmLoader.logger.error("Error checking WASM file availability",{error:t}),{available:!1}}}static async asyncLoad(){if(WasmLoader.isLoaded())WasmLoader.logger.debug("WASM module is already loaded");else{if(WasmLoader.isLoading&&WasmLoader.loadPromise)return WasmLoader.logger.debug("WASM module is already loading"),WasmLoader.loadPromise;try{WasmLoader.isLoading=!0,WasmLoader.logger.info("Starting WASM module load");const t=(0,_utils_wasm_support__WEBPACK_IMPORTED_MODULE_0__.c_)();if(!t.supported)throw new Error(`WebAssembly not supported: ${t.message}`);const e=(0,_utils_wasm_support__WEBPACK_IMPORTED_MODULE_0__.cR)();WasmLoader.logger.info("Environment information:",e),WasmLoader.debug&&console.log("Environment information:",e),WasmLoader._wasmPath&&"/casino.wasm"!==WasmLoader._wasmPath||WasmLoader.logger.warn(`Using default WASM path: ${WasmLoader._wasmPath}. If this is not correct, set WasmLoader.wasmPath before calling asyncLoad`);if(!(await WasmLoader.checkWasmFileAvailability()).available)throw new Error(`WASM file is not accessible at ${WasmLoader._wasmPath}. Please check the path and ensure the file is being served correctly.`);try{if(WasmLoader.loadPromise=WasmLoader.loadWasmModule(),await WasmLoader.loadPromise,WasmLoader.logger.info("WASM module loaded successfully"),WasmLoader.onInitialized&&WasmLoader.casinoInstance)try{WasmLoader.onInitialized(WasmLoader.casinoInstance)}catch(t){WasmLoader.logger.warn("Error in onInitialized callback",{callbackError:t})}}catch(t){throw WasmLoader.logger.error("Failed in WASM module loading process",{loadError:t}),WasmLoader.loadPromise=null,t}}catch(t){throw WasmLoader.logger.error("Failed to load WASM module",{error:t}),WasmLoader.loadPromise=null,t}finally{WasmLoader.isLoading=!1}}}static async loadWasmModule(){if("undefined"==typeof WebAssembly)throw WasmLoader.logger.error("WebAssembly is not supported"),new Error("WebAssembly is not supported in this environment");if(WasmLoader.wasmExecLoaded||(WasmLoader.logger.debug("Loading wasm_exec.js"),await WasmLoader.loadWasmExec()),void 0===window.Go)throw WasmLoader.logger.error("wasm_exec.js failed to load properly"),new Error("wasm_exec.js failed to load properly");const t=new window.Go;try{let e;WasmLoader.logger.debug(`Fetching WASM module from ${WasmLoader.wasmPath}`);if((0,_utils_wasm_support__WEBPACK_IMPORTED_MODULE_0__.c_)().streaming)try{let n;if(WasmLoader.logger.debug("Using streaming instantiation"),WasmLoader.wasmResponseCache)WasmLoader.logger.debug("Using cached WASM response for streaming"),n=WasmLoader.wasmResponseCache.clone();else{if(WasmLoader.logger.debug("Fetching fresh WASM response for streaming"),n=await fetch(WasmLoader.wasmPath),!n.ok)throw new Error(`Failed to fetch WASM module: ${n.statusText} (${n.status})`);WasmLoader.wasmResponseCache=n.clone()}const s=n.headers.get("Content-Type");s&&s.includes("application/wasm")||WasmLoader.logger.warn("WASM file is not served with correct MIME type (application/wasm). Streaming compilation may fail.",{contentType:s});const a=await WebAssembly.instantiateStreaming(n,t.importObject);e=a.instance}catch(n){let s;if(WasmLoader.logger.warn("Streaming instantiation failed, falling back to ArrayBuffer",{streamingError:n}),WasmLoader.wasmBufferCache)WasmLoader.logger.debug("Using cached WASM buffer"),s=WasmLoader.wasmBufferCache;else{let t;if(WasmLoader.logger.debug("Creating new WASM buffer"),WasmLoader.wasmResponseCache)t=WasmLoader.wasmResponseCache.clone();else{if(t=await fetch(WasmLoader.wasmPath),!t.ok)throw new Error(`Failed to fetch WASM module: ${t.statusText} (${t.status})`);WasmLoader.wasmResponseCache=t.clone()}s=await t.arrayBuffer(),WasmLoader.wasmBufferCache=s,WasmLoader.debug&&console.log(`WASM buffer size: ${s.byteLength} bytes`)}const a=await WebAssembly.instantiate(s,t.importObject);e=a.instance}else{let n;if(WasmLoader.logger.debug("Using ArrayBuffer instantiation"),WasmLoader.wasmBufferCache)WasmLoader.logger.debug("Using cached WASM buffer for non-streaming"),n=WasmLoader.wasmBufferCache;else{WasmLoader.logger.debug("Creating new WASM buffer for non-streaming");const t=await fetch(WasmLoader.wasmPath);if(!t.ok)throw new Error(`Failed to fetch WASM module: ${t.statusText} (${t.status})`);n=await t.arrayBuffer(),WasmLoader.wasmBufferCache=n,WasmLoader.debug&&console.log(`WASM buffer size: ${n.byteLength} bytes`)}const s=await WebAssembly.instantiate(n,t.importObject);e=s.instance}WasmLoader.wasmInstance=e,WasmLoader.logger.debug("Running WASM module");try{if(WasmLoader.debug&&console.log("Starting Go.run with WASM instance"),await new Promise(((n,s)=>{const a=setTimeout((()=>{s(new Error(`Timeout waiting for WASM module to initialize (${WasmLoader.timeoutDuration}ms)`))}),WasmLoader.timeoutDuration);try{WasmLoader.logger.debug("Starting Go runtime");const o=t.run(e),r=50,i=Math.floor(WasmLoader.timeoutDuration/r);let l=0;const c=()=>{l++,WasmLoader.debug&&l%20==0&&(console.log(`Still waiting for casino object... Check #${l}`),console.log("Window casino object:",window.casino),console.log("Global objects:",Object.keys(window).filter((t=>!t.startsWith("_"))).join(", "))),void 0!==window.casino?(WasmLoader.logger.debug("XCoreCasino object found on window"),WasmLoader.casinoInstance=window.casino,clearTimeout(a),n()):l>=i?(clearTimeout(a),s(new Error("Timeout waiting for WASM module to initialize XCoreCasino"))):setTimeout(c,r)};c(),o&&"function"==typeof o.catch&&o.catch((t=>{clearTimeout(a),s(new Error(`Error in Go runtime: ${t.message}`))}))}catch(t){clearTimeout(a),s(t)}})),!WasmLoader.casinoInstance)throw new Error("WASM module did not properly initialize XCoreCasino");WasmLoader.logger.debug("WASM module initialized successfully")}catch(t){throw WasmLoader.logger.error("Failed to run WASM module",{runError:t}),new Error(`Failed to run WASM module: ${t instanceof Error?t.message:String(t)}`)}}catch(t){throw WasmLoader.logger.error("WASM loading error",{error:t}),new Error(`Failed to load WASM module: ${t instanceof Error?t.message:String(t)}`)}}static clearCache(){WasmLoader.wasmResponseCache=null,WasmLoader.wasmBufferCache=null,WasmLoader.logger.debug("WASM cache cleared")}static getDiagnostics(){return{isLoaded:WasmLoader.isLoaded(),isLoading:WasmLoader.isLoading,hasLoadPromise:null!==WasmLoader.loadPromise,wasmExecLoaded:WasmLoader.wasmExecLoaded,hasWasmInstance:null!==WasmLoader.wasmInstance,wasmPath:WasmLoader.wasmPath,debug:WasmLoader.debug,timeoutDuration:WasmLoader.timeoutDuration,hasCachedResponse:null!==WasmLoader.wasmResponseCache,hasCachedBuffer:null!==WasmLoader.wasmBufferCache}}static async loadWasmExec(){if(!WasmLoader.wasmExecLoaded)return new Promise(((resolve,reject)=>{try{if(void 0!==window.Go)return WasmLoader.logger.debug("Go runtime is already available"),WasmLoader.wasmExecLoaded=!0,void resolve();WasmLoader.logger.debug("Loading wasm_exec.js using eval");try{if(eval(_core_wasm_wasm_exec_js__WEBPACK_IMPORTED_MODULE_1__.A),void 0!==window.Go)WasmLoader.logger.debug("wasm_exec.js loaded successfully via eval"),WasmLoader.wasmExecLoaded=!0,resolve();else{const t="wasm_exec.js evaluated but Go object is not defined";WasmLoader.logger.error(t),reject(new Error(t))}}catch(t){WasmLoader.logger.error("Error evaluating wasm_exec.js",{evalError:t}),WasmLoader.logger.debug("Falling back to script tag approach");const e=document.createElement("script");e.textContent=_core_wasm_wasm_exec_js__WEBPACK_IMPORTED_MODULE_1__.A;const n=setTimeout((()=>{reject(new Error(`Timeout waiting for wasm_exec.js to load (${WasmLoader.timeoutDuration}ms)`))}),WasmLoader.timeoutDuration);e.onload=()=>{if(clearTimeout(n),WasmLoader.logger.debug("wasm_exec.js loaded successfully via script tag"),void 0!==window.Go)WasmLoader.wasmExecLoaded=!0,resolve();else{const t="wasm_exec.js loaded but Go object is not defined";WasmLoader.logger.error(t),reject(new Error(t))}},e.onerror=t=>{clearTimeout(n);const e=`Failed to load wasm_exec.js: ${t}`;WasmLoader.logger.error(e),reject(new Error(e))},document.body.appendChild(e),WasmLoader.logger.debug("Loading wasm_exec.js via script tag")}}catch(t){WasmLoader.logger.error("Error while loading wasm_exec.js",{error:t}),reject(new Error(`Error while loading wasm_exec.js: ${t instanceof Error?t.message:String(t)}`))}}));WasmLoader.logger.debug("wasm_exec.js is already loaded")}}WasmLoader.isLoading=!1,WasmLoader.loadPromise=null,WasmLoader.wasmExecLoaded=!1,WasmLoader.wasmInstance=null,WasmLoader.casinoInstance=null,WasmLoader.logger=_logger__WEBPACK_IMPORTED_MODULE_2__.V.getLogger("WasmLoader"),WasmLoader.wasmResponseCache=null,WasmLoader.wasmBufferCache=null,WasmLoader._wasmPath="/casino.wasm",WasmLoader.debug=!1,WasmLoader.onInitialized=null,WasmLoader.timeoutDuration=1e4},675:(t,e,n)=>{var s;n.d(e,{V:()=>a}),function(t){t.DEBUG="debug",t.INFO="info",t.WARN="warn",t.ERROR="error"}(s||(s={}));class a{constructor(t){this.config={level:s.INFO,enabled:!0,console:!0},this.module=t}static getLogger(t){return a.instance||(a.instance=new a(t)),a.instance}debug(t,e){this.log(s.DEBUG,t,e)}info(t,e){this.log(s.INFO,t,e)}warn(t,e){this.log(s.WARN,t,e)}error(t,e){this.log(s.ERROR,t,e)}setConfig(t){this.config={...this.config,...t}}getConfig(){return{...this.config}}log(t,e,n){if(!this.config.enabled||!this.shouldLog(t))return;const s={timestamp:(new Date).toISOString(),level:t,module:this.module,message:e,data:n};this.config.console&&this.logToConsole(s),this.config.callback&&this.config.callback(s)}shouldLog(t){const e=Object.values(s),n=e.indexOf(this.config.level);return e.indexOf(t)>=n}logToConsole(t){const e=`[${t.timestamp}] [${t.level.toUpperCase()}] [${t.module}]`;switch(t.level){case s.DEBUG:console.debug(e,t.message,t.data??"");break;case s.INFO:console.info(e,t.message,t.data??"");break;case s.WARN:console.warn(e,t.message,t.data??"");break;case s.ERROR:console.error(e,t.message,t.data??"")}}}},686:(t,e,n)=>{n.d(e,{A:()=>s});const s='// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n"use strict";\n\n(() => {\n\tconst enosys = () => {\n\t\tconst err = new Error("not implemented");\n\t\terr.code = "ENOSYS";\n\t\treturn err;\n\t};\n\n\tif (!globalThis.fs) {\n\t\tlet outputBuf = "";\n\t\tglobalThis.fs = {\n\t\t\tconstants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused\n\t\t\twriteSync(fd, buf) {\n\t\t\t\toutputBuf += decoder.decode(buf);\n\t\t\t\tconst nl = outputBuf.lastIndexOf("\\n");\n\t\t\t\tif (nl != -1) {\n\t\t\t\t\tconsole.log(outputBuf.substring(0, nl));\n\t\t\t\t\toutputBuf = outputBuf.substring(nl + 1);\n\t\t\t\t}\n\t\t\t\treturn buf.length;\n\t\t\t},\n\t\t\twrite(fd, buf, offset, length, position, callback) {\n\t\t\t\tif (offset !== 0 || length !== buf.length || position !== null) {\n\t\t\t\t\tcallback(enosys());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst n = this.writeSync(fd, buf);\n\t\t\t\tcallback(null, n);\n\t\t\t},\n\t\t\tchmod(path, mode, callback) { callback(enosys()); },\n\t\t\tchown(path, uid, gid, callback) { callback(enosys()); },\n\t\t\tclose(fd, callback) { callback(enosys()); },\n\t\t\tfchmod(fd, mode, callback) { callback(enosys()); },\n\t\t\tfchown(fd, uid, gid, callback) { callback(enosys()); },\n\t\t\tfstat(fd, callback) { callback(enosys()); },\n\t\t\tfsync(fd, callback) { callback(null); },\n\t\t\tftruncate(fd, length, callback) { callback(enosys()); },\n\t\t\tlchown(path, uid, gid, callback) { callback(enosys()); },\n\t\t\tlink(path, link, callback) { callback(enosys()); },\n\t\t\tlstat(path, callback) { callback(enosys()); },\n\t\t\tmkdir(path, perm, callback) { callback(enosys()); },\n\t\t\topen(path, flags, mode, callback) { callback(enosys()); },\n\t\t\tread(fd, buffer, offset, length, position, callback) { callback(enosys()); },\n\t\t\treaddir(path, callback) { callback(enosys()); },\n\t\t\treadlink(path, callback) { callback(enosys()); },\n\t\t\trename(from, to, callback) { callback(enosys()); },\n\t\t\trmdir(path, callback) { callback(enosys()); },\n\t\t\tstat(path, callback) { callback(enosys()); },\n\t\t\tsymlink(path, link, callback) { callback(enosys()); },\n\t\t\ttruncate(path, length, callback) { callback(enosys()); },\n\t\t\tunlink(path, callback) { callback(enosys()); },\n\t\t\tutimes(path, atime, mtime, callback) { callback(enosys()); },\n\t\t};\n\t}\n\n\tif (!globalThis.process) {\n\t\tglobalThis.process = {\n\t\t\tgetuid() { return -1; },\n\t\t\tgetgid() { return -1; },\n\t\t\tgeteuid() { return -1; },\n\t\t\tgetegid() { return -1; },\n\t\t\tgetgroups() { throw enosys(); },\n\t\t\tpid: -1,\n\t\t\tppid: -1,\n\t\t\tumask() { throw enosys(); },\n\t\t\tcwd() { throw enosys(); },\n\t\t\tchdir() { throw enosys(); },\n\t\t}\n\t}\n\n\tif (!globalThis.path) {\n\t\tglobalThis.path = {\n\t\t\tresolve(...pathSegments) {\n\t\t\t\treturn pathSegments.join("/");\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!globalThis.crypto) {\n\t\tthrow new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");\n\t}\n\n\tif (!globalThis.performance) {\n\t\tthrow new Error("globalThis.performance is not available, polyfill required (performance.now only)");\n\t}\n\n\tif (!globalThis.TextEncoder) {\n\t\tthrow new Error("globalThis.TextEncoder is not available, polyfill required");\n\t}\n\n\tif (!globalThis.TextDecoder) {\n\t\tthrow new Error("globalThis.TextDecoder is not available, polyfill required");\n\t}\n\n\tconst encoder = new TextEncoder("utf-8");\n\tconst decoder = new TextDecoder("utf-8");\n\n\tglobalThis.Go = class {\n\t\tconstructor() {\n\t\t\tthis.argv = ["js"];\n\t\t\tthis.env = {};\n\t\t\tthis.exit = (code) => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tconsole.warn("exit code:", code);\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis._exitPromise = new Promise((resolve) => {\n\t\t\t\tthis._resolveExitPromise = resolve;\n\t\t\t});\n\t\t\tthis._pendingEvent = null;\n\t\t\tthis._scheduledTimeouts = new Map();\n\t\t\tthis._nextCallbackTimeoutID = 1;\n\n\t\t\tconst setInt64 = (addr, v) => {\n\t\t\t\tthis.mem.setUint32(addr + 0, v, true);\n\t\t\t\tthis.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\n\t\t\t}\n\n\t\t\tconst setInt32 = (addr, v) => {\n\t\t\t\tthis.mem.setUint32(addr + 0, v, true);\n\t\t\t}\n\n\t\t\tconst getInt64 = (addr) => {\n\t\t\t\tconst low = this.mem.getUint32(addr + 0, true);\n\t\t\t\tconst high = this.mem.getInt32(addr + 4, true);\n\t\t\t\treturn low + high * 4294967296;\n\t\t\t}\n\n\t\t\tconst loadValue = (addr) => {\n\t\t\t\tconst f = this.mem.getFloat64(addr, true);\n\t\t\t\tif (f === 0) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (!isNaN(f)) {\n\t\t\t\t\treturn f;\n\t\t\t\t}\n\n\t\t\t\tconst id = this.mem.getUint32(addr, true);\n\t\t\t\treturn this._values[id];\n\t\t\t}\n\n\t\t\tconst storeValue = (addr, v) => {\n\t\t\t\tconst nanHead = 0x7FF80000;\n\n\t\t\t\tif (typeof v === "number" && v !== 0) {\n\t\t\t\t\tif (isNaN(v)) {\n\t\t\t\t\t\tthis.mem.setUint32(addr + 4, nanHead, true);\n\t\t\t\t\t\tthis.mem.setUint32(addr, 0, true);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis.mem.setFloat64(addr, v, true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (v === undefined) {\n\t\t\t\t\tthis.mem.setFloat64(addr, 0, true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet id = this._ids.get(v);\n\t\t\t\tif (id === undefined) {\n\t\t\t\t\tid = this._idPool.pop();\n\t\t\t\t\tif (id === undefined) {\n\t\t\t\t\t\tid = this._values.length;\n\t\t\t\t\t}\n\t\t\t\t\tthis._values[id] = v;\n\t\t\t\t\tthis._goRefCounts[id] = 0;\n\t\t\t\t\tthis._ids.set(v, id);\n\t\t\t\t}\n\t\t\t\tthis._goRefCounts[id]++;\n\t\t\t\tlet typeFlag = 0;\n\t\t\t\tswitch (typeof v) {\n\t\t\t\t\tcase "object":\n\t\t\t\t\t\tif (v !== null) {\n\t\t\t\t\t\t\ttypeFlag = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase "string":\n\t\t\t\t\t\ttypeFlag = 2;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase "symbol":\n\t\t\t\t\t\ttypeFlag = 3;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase "function":\n\t\t\t\t\t\ttypeFlag = 4;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.mem.setUint32(addr + 4, nanHead | typeFlag, true);\n\t\t\t\tthis.mem.setUint32(addr, id, true);\n\t\t\t}\n\n\t\t\tconst loadSlice = (addr) => {\n\t\t\t\tconst array = getInt64(addr + 0);\n\t\t\t\tconst len = getInt64(addr + 8);\n\t\t\t\treturn new Uint8Array(this._inst.exports.mem.buffer, array, len);\n\t\t\t}\n\n\t\t\tconst loadSliceOfValues = (addr) => {\n\t\t\t\tconst array = getInt64(addr + 0);\n\t\t\t\tconst len = getInt64(addr + 8);\n\t\t\t\tconst a = new Array(len);\n\t\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\t\ta[i] = loadValue(array + i * 8);\n\t\t\t\t}\n\t\t\t\treturn a;\n\t\t\t}\n\n\t\t\tconst loadString = (addr) => {\n\t\t\t\tconst saddr = getInt64(addr + 0);\n\t\t\t\tconst len = getInt64(addr + 8);\n\t\t\t\treturn decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\n\t\t\t}\n\n\t\t\tconst testCallExport = (a, b) => {\n\t\t\t\tthis._inst.exports.testExport0();\n\t\t\t\treturn this._inst.exports.testExport(a, b);\n\t\t\t}\n\n\t\t\tconst timeOrigin = Date.now() - performance.now();\n\t\t\tthis.importObject = {\n\t\t\t\t_gotest: {\n\t\t\t\t\tadd: (a, b) => a + b,\n\t\t\t\t\tcallExport: testCallExport,\n\t\t\t\t},\n\t\t\t\tgojs: {\n\t\t\t\t\t// Go\'s SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)\n\t\t\t\t\t// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported\n\t\t\t\t\t// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).\n\t\t\t\t\t// This changes the SP, thus we have to update the SP used by the imported function.\n\n\t\t\t\t\t// func wasmExit(code int32)\n\t\t\t\t\t"runtime.wasmExit": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst code = this.mem.getInt32(sp + 8, true);\n\t\t\t\t\t\tthis.exited = true;\n\t\t\t\t\t\tdelete this._inst;\n\t\t\t\t\t\tdelete this._values;\n\t\t\t\t\t\tdelete this._goRefCounts;\n\t\t\t\t\t\tdelete this._ids;\n\t\t\t\t\t\tdelete this._idPool;\n\t\t\t\t\t\tthis.exit(code);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)\n\t\t\t\t\t"runtime.wasmWrite": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst fd = getInt64(sp + 8);\n\t\t\t\t\t\tconst p = getInt64(sp + 16);\n\t\t\t\t\t\tconst n = this.mem.getInt32(sp + 24, true);\n\t\t\t\t\t\tfs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func resetMemoryDataView()\n\t\t\t\t\t"runtime.resetMemoryDataView": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tthis.mem = new DataView(this._inst.exports.mem.buffer);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func nanotime1() int64\n\t\t\t\t\t"runtime.nanotime1": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tsetInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func walltime() (sec int64, nsec int32)\n\t\t\t\t\t"runtime.walltime": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst msec = (new Date).getTime();\n\t\t\t\t\t\tsetInt64(sp + 8, msec / 1000);\n\t\t\t\t\t\tthis.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func scheduleTimeoutEvent(delay int64) int32\n\t\t\t\t\t"runtime.scheduleTimeoutEvent": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst id = this._nextCallbackTimeoutID;\n\t\t\t\t\t\tthis._nextCallbackTimeoutID++;\n\t\t\t\t\t\tthis._scheduledTimeouts.set(id, setTimeout(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthis._resume();\n\t\t\t\t\t\t\t\twhile (this._scheduledTimeouts.has(id)) {\n\t\t\t\t\t\t\t\t\t// for some reason Go failed to register the timeout event, log and try again\n\t\t\t\t\t\t\t\t\t// (temporary workaround for https://github.com/golang/go/issues/28975)\n\t\t\t\t\t\t\t\t\tconsole.warn("scheduleTimeoutEvent: missed timeout event");\n\t\t\t\t\t\t\t\t\tthis._resume();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetInt64(sp + 8),\n\t\t\t\t\t\t));\n\t\t\t\t\t\tthis.mem.setInt32(sp + 16, id, true);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func clearTimeoutEvent(id int32)\n\t\t\t\t\t"runtime.clearTimeoutEvent": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst id = this.mem.getInt32(sp + 8, true);\n\t\t\t\t\t\tclearTimeout(this._scheduledTimeouts.get(id));\n\t\t\t\t\t\tthis._scheduledTimeouts.delete(id);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func getRandomData(r []byte)\n\t\t\t\t\t"runtime.getRandomData": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tcrypto.getRandomValues(loadSlice(sp + 8));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func finalizeRef(v ref)\n\t\t\t\t\t"syscall/js.finalizeRef": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst id = this.mem.getUint32(sp + 8, true);\n\t\t\t\t\t\tthis._goRefCounts[id]--;\n\t\t\t\t\t\tif (this._goRefCounts[id] === 0) {\n\t\t\t\t\t\t\tconst v = this._values[id];\n\t\t\t\t\t\t\tthis._values[id] = null;\n\t\t\t\t\t\t\tthis._ids.delete(v);\n\t\t\t\t\t\t\tthis._idPool.push(id);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\n\t\t\t\t\t// func stringVal(value string) ref\n\t\t\t\t\t"syscall/js.stringVal": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tstoreValue(sp + 24, loadString(sp + 8));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueGet(v ref, p string) ref\n\t\t\t\t\t"syscall/js.valueGet": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\tstoreValue(sp + 32, result);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueSet(v ref, p string, x ref)\n\t\t\t\t\t"syscall/js.valueSet": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tReflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueDelete(v ref, p string)\n\t\t\t\t\t"syscall/js.valueDelete": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tReflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueIndex(v ref, i int) ref\n\t\t\t\t\t"syscall/js.valueIndex": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tstoreValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n\t\t\t\t\t},\n\n\t\t\t\t\t// valueSetIndex(v ref, i int, x ref)\n\t\t\t\t\t"syscall/js.valueSetIndex": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tReflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueCall(v ref, m string, args []ref) (ref, bool)\n\t\t\t\t\t"syscall/js.valueCall": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst v = loadValue(sp + 8);\n\t\t\t\t\t\t\tconst m = Reflect.get(v, loadString(sp + 16));\n\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 32);\n\t\t\t\t\t\t\tconst result = Reflect.apply(m, v, args);\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 56, result);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 64, 1);\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 56, err);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 64, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueInvoke(v ref, args []ref) (ref, bool)\n\t\t\t\t\t"syscall/js.valueInvoke": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst v = loadValue(sp + 8);\n\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 16);\n\t\t\t\t\t\t\tconst result = Reflect.apply(v, undefined, args);\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 40, result);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 40, err);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueNew(v ref, args []ref) (ref, bool)\n\t\t\t\t\t"syscall/js.valueNew": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst v = loadValue(sp + 8);\n\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 16);\n\t\t\t\t\t\t\tconst result = Reflect.construct(v, args);\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 40, result);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above\n\t\t\t\t\t\t\tstoreValue(sp + 40, err);\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueLength(v ref) int\n\t\t\t\t\t"syscall/js.valueLength": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tsetInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n\t\t\t\t\t},\n\n\t\t\t\t\t// valuePrepareString(v ref) (ref, int)\n\t\t\t\t\t"syscall/js.valuePrepareString": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst str = encoder.encode(String(loadValue(sp + 8)));\n\t\t\t\t\t\tstoreValue(sp + 16, str);\n\t\t\t\t\t\tsetInt64(sp + 24, str.length);\n\t\t\t\t\t},\n\n\t\t\t\t\t// valueLoadString(v ref, b []byte)\n\t\t\t\t\t"syscall/js.valueLoadString": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst str = loadValue(sp + 8);\n\t\t\t\t\t\tloadSlice(sp + 16).set(str);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func valueInstanceOf(v ref, t ref) bool\n\t\t\t\t\t"syscall/js.valueInstanceOf": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tthis.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func copyBytesToGo(dst []byte, src ref) (int, bool)\n\t\t\t\t\t"syscall/js.copyBytesToGo": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst dst = loadSlice(sp + 8);\n\t\t\t\t\t\tconst src = loadValue(sp + 32);\n\t\t\t\t\t\tif (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst toCopy = src.subarray(0, dst.length);\n\t\t\t\t\t\tdst.set(toCopy);\n\t\t\t\t\t\tsetInt64(sp + 40, toCopy.length);\n\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);\n\t\t\t\t\t},\n\n\t\t\t\t\t// func copyBytesToJS(dst ref, src []byte) (int, bool)\n\t\t\t\t\t"syscall/js.copyBytesToJS": (sp) => {\n\t\t\t\t\t\tsp >>>= 0;\n\t\t\t\t\t\tconst dst = loadValue(sp + 8);\n\t\t\t\t\t\tconst src = loadSlice(sp + 16);\n\t\t\t\t\t\tif (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\n\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst toCopy = src.subarray(0, dst.length);\n\t\t\t\t\t\tdst.set(toCopy);\n\t\t\t\t\t\tsetInt64(sp + 40, toCopy.length);\n\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);\n\t\t\t\t\t},\n\n\t\t\t\t\t"debug": (value) => {\n\t\t\t\t\t\tconsole.log(value);\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tasync run(instance) {\n\t\t\tif (!(instance instanceof WebAssembly.Instance)) {\n\t\t\t\tthrow new Error("Go.run: WebAssembly.Instance expected");\n\t\t\t}\n\t\t\tthis._inst = instance;\n\t\t\tthis.mem = new DataView(this._inst.exports.mem.buffer);\n\t\t\tthis._values = [ // JS values that Go currently has references to, indexed by reference id\n\t\t\t\tNaN,\n\t\t\t\t0,\n\t\t\t\tnull,\n\t\t\t\ttrue,\n\t\t\t\tfalse,\n\t\t\t\tglobalThis,\n\t\t\t\tthis,\n\t\t\t];\n\t\t\tthis._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id\n\t\t\tthis._ids = new Map([ // mapping from JS values to reference ids\n\t\t\t\t[0, 1],\n\t\t\t\t[null, 2],\n\t\t\t\t[true, 3],\n\t\t\t\t[false, 4],\n\t\t\t\t[globalThis, 5],\n\t\t\t\t[this, 6],\n\t\t\t]);\n\t\t\tthis._idPool = []; // unused ids that have been garbage collected\n\t\t\tthis.exited = false; // whether the Go program has exited\n\n\t\t\t// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.\n\t\t\tlet offset = 4096;\n\n\t\t\tconst strPtr = (str) => {\n\t\t\t\tconst ptr = offset;\n\t\t\t\tconst bytes = encoder.encode(str + "\\0");\n\t\t\t\tnew Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n\t\t\t\toffset += bytes.length;\n\t\t\t\tif (offset % 8 !== 0) {\n\t\t\t\t\toffset += 8 - (offset % 8);\n\t\t\t\t}\n\t\t\t\treturn ptr;\n\t\t\t};\n\n\t\t\tconst argc = this.argv.length;\n\n\t\t\tconst argvPtrs = [];\n\t\t\tthis.argv.forEach((arg) => {\n\t\t\t\targvPtrs.push(strPtr(arg));\n\t\t\t});\n\t\t\targvPtrs.push(0);\n\n\t\t\tconst keys = Object.keys(this.env).sort();\n\t\t\tkeys.forEach((key) => {\n\t\t\t\targvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n\t\t\t});\n\t\t\targvPtrs.push(0);\n\n\t\t\tconst argv = offset;\n\t\t\targvPtrs.forEach((ptr) => {\n\t\t\t\tthis.mem.setUint32(offset, ptr, true);\n\t\t\t\tthis.mem.setUint32(offset + 4, 0, true);\n\t\t\t\toffset += 8;\n\t\t\t});\n\n\t\t\t// The linker guarantees global data starts from at least wasmMinDataAddr.\n\t\t\t// Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.\n\t\t\tconst wasmMinDataAddr = 4096 + 8192;\n\t\t\tif (offset >= wasmMinDataAddr) {\n\t\t\t\tthrow new Error("total length of command line and environment variables exceeds limit");\n\t\t\t}\n\n\t\t\tthis._inst.exports.run(argc, argv);\n\t\t\tif (this.exited) {\n\t\t\t\tthis._resolveExitPromise();\n\t\t\t}\n\t\t\tawait this._exitPromise;\n\t\t}\n\n\t\t_resume() {\n\t\t\tif (this.exited) {\n\t\t\t\tthrow new Error("Go program has already exited");\n\t\t\t}\n\t\t\tthis._inst.exports.resume();\n\t\t\tif (this.exited) {\n\t\t\t\tthis._resolveExitPromise();\n\t\t\t}\n\t\t}\n\n\t\t_makeFuncWrapper(id) {\n\t\t\tconst go = this;\n\t\t\treturn function () {\n\t\t\t\tconst event = { id: id, this: this, args: arguments };\n\t\t\t\tgo._pendingEvent = event;\n\t\t\t\tgo._resume();\n\t\t\t\treturn event.result;\n\t\t\t};\n\t\t}\n\t}\n})();\n'},806:(t,e,n)=>{function s(){if("undefined"==typeof WebAssembly)return{supported:!1,streaming:!1,threads:!1,message:"WebAssembly is not supported in this browser."};if("function"!=typeof WebAssembly.compile||"function"!=typeof WebAssembly.instantiate||"function"!=typeof WebAssembly.Module)return{supported:!1,streaming:!1,threads:!1,message:"WebAssembly API is incomplete in this browser."};try{const t=new Uint8Array([0,97,115,109,1,0,0,0]);if(!(new WebAssembly.Module(t)instanceof WebAssembly.Module))throw new Error("Failed to create a WebAssembly module")}catch(t){return{supported:!1,streaming:!1,threads:!1,message:"WebAssembly compilation failed: "+(t instanceof Error?t.message:String(t))}}const t="function"==typeof WebAssembly.instantiateStreaming;return{supported:!0,streaming:t,threads:"undefined"!=typeof SharedArrayBuffer&&"undefined"!=typeof Atomics,message:t?"WebAssembly is fully supported with streaming compilation.":"WebAssembly is supported but without streaming compilation."}}function a(){return!0===window.isSecureContext}function o(){const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return{wasmSupport:s(),secureContext:a(),userAgent:navigator.userAgent,isMobile:t}}n.d(e,{$w:()=>a,cR:()=>o,c_:()=>s})}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var n=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](n,n.exports,__webpack_require__),n.exports}__webpack_require__.d=(t,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var __webpack_exports__={};__webpack_require__.d(__webpack_exports__,{WF:()=>BaccaratGame,E4:()=>loader.E,c_:()=>wasm_support.c_,cR:()=>wasm_support.cR,$w:()=>wasm_support.$w});var loader=__webpack_require__(68),logger=__webpack_require__(675);const decoder=new TextDecoder,decode=t=>JSON.parse(decoder.decode(t)),encoder=new TextEncoder,encode=t=>("object"==typeof t&&null!==t?t=JSON.stringify(t):"string"!=typeof t&&(t=String(t)),encoder.encode(t));class BaccaratGame{constructor(){this.logger=logger.V.getLogger("BaccaratGame")}getBaccaratModule(){const t=loader.E.getCasino();return t.baccarat?t.baccarat:t}async rankHand(t){return this.logger.debug("Ranking baccarat hand",t),this.wrapWasmCall((()=>this.getBaccaratModule().rankHand(encode(t))))}async unrankHand(t){return this.logger.debug("Converting index to hand",{index:t}),this.wrapWasmCall((()=>this.getBaccaratModule().unrankHand(encode(t))))}async canDraw(t){return this.logger.debug("Checking draw possibilities",t),this.wrapWasmCall((()=>this.getBaccaratModule().canDraw(encode(t))))}async determineResult(t){return this.logger.debug("Determining hand result",t),this.wrapWasmCall((()=>this.getBaccaratModule().determineResult(encode(t))))}async idxToResultInfo(t){return this.logger.debug("Converting index to result info",{index:t}),this.wrapWasmCall((()=>this.getBaccaratModule().idxToResultInfo(encode(t))))}async resultInfoToIdx(t){return this.logger.debug("Converting result info to index",t),this.wrapWasmCall((()=>this.getBaccaratModule().resultInfoToIdx(encode(t))))}async info(){return this.logger.debug("Getting cards information"),this.wrapWasmCall((()=>this.getBaccaratModule().info()))}async roadmaps(t){return this.logger.debug("Generating roadmaps",{results:t}),this.wrapWasmCall((()=>this.getBaccaratModule().roadmaps(encode(t))))}async wrapWasmCall(t){try{const e=decode(t());if(0!==e.code)throw this.logger.error("WASM call failed",{code:e.code,message:e.message}),new Error(e.message);return e}catch(t){const e=`Baccarat game operation failed: ${t instanceof Error?t.message:String(t)}`;throw this.logger.error(e,{error:t}),new Error(e)}}}var wasm_support=__webpack_require__(806),__webpack_exports__BaccaratGame=__webpack_exports__.WF,__webpack_exports__WasmLoader=__webpack_exports__.E4,__webpack_exports__checkWasmSupport=__webpack_exports__.c_,__webpack_exports__getEnvironmentInfo=__webpack_exports__.cR,__webpack_exports__isSecureContext=__webpack_exports__.$w;export{__webpack_exports__BaccaratGame as BaccaratGame,__webpack_exports__WasmLoader as WasmLoader,__webpack_exports__checkWasmSupport as checkWasmSupport,__webpack_exports__getEnvironmentInfo as getEnvironmentInfo,__webpack_exports__isSecureContext as isSecureContext};