"use strict";(self.webpackChunkcoinflip=self.webpackChunkcoinflip||[]).push([[770],{2770:(e,t,s)=>{s.d(t,{de:()=>M,d7:()=>F,Ct:()=>c,Q2:()=>d,FR:()=>T,VT:()=>A,gN:()=>n,Sf:()=>o,uz:()=>V,ew:()=>W,cU:()=>E,H2:()=>S,Ut:()=>H,vP:()=>D,qG:()=>w,Xp:()=>h,gy:()=>R,_l:()=>p,XN:()=>j,jU:()=>C,W4:()=>u,sx:()=>y,$m:()=>X});var a=s(6951);const r={loader:a.nw.LoadParser,resolver:a.nw.ResolveParser,cache:a.nw.CacheParser,detection:a.nw.DetectionParser};a.Rw.handle(a.nw.Asset,(e=>{const t=e.ref;Object.entries(r).filter((([e])=>!!t[e])).forEach((([e,s])=>a.Rw.add(Object.assign(t[e],{extension:t[e].extension??s}))))}),(e=>{const t=e.ref;Object.keys(r).filter((e=>!!t[e])).forEach((e=>a.Rw.remove(t[e])))}));class i{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach((e=>{this._assetList.push(e)})),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s(Array.isArray(e)||(e=[e]),t?e.map((e=>"string"==typeof e?t(e):e)):e),c=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const s=o(e);let r;for(let e=0;e{r[e]=t})));const i=Object.keys(r),n={cacheKeys:i,keys:s};if(s.forEach((e=>{this._cacheMap.set(e,n)})),i.forEach((e=>{this._cache.has(e)&&this._cache.get(e)!==t&&console.warn("[Cache] already has key:",e),this._cache.set(e,r[e])})),t instanceof a.xE){const e=t;s.forEach((t=>{e.baseTexture!==a.xE.EMPTY.baseTexture&&a.VL.addToCache(e.baseTexture,t),a.xE.addToCache(e,t)}))}}remove(e){if(this._cacheMap.get(e),!this._cacheMap.has(e))return void console.warn(`[Assets] Asset id ${e} was not found in the Cache`);const t=this._cacheMap.get(e);t.cacheKeys.forEach((e=>{this._cache.delete(e)})),t.keys.forEach((e=>{this._cacheMap.delete(e)}))}get parsers(){return this._parsers}},h=e=>!Array.isArray(e);class l{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,s)=>(this._parsersValidated=!1,e[t]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const s={promise:null,parser:null};return s.promise=(async()=>{let a=null,r=null;if(t.loadParser&&(r=this._parserHash[t.loadParser],r||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!r){for(let s=0;s({src:e}))),c=n.length,l=n.map((async e=>{const i=a.P6.path.toAbsolute(e.src);if(!r[e.src])try{this.promiseCache[i]||(this.promiseCache[i]=this._getLoadPromiseAndParser(i,e)),r[e.src]=await this.promiseCache[i].promise,t&&t(++s/c)}catch(t){throw delete this.promiseCache[i],delete r[e.src],new Error(`[Loader.load] Failed to load ${i}.\n${t}`)}}));return await Promise.all(l),i?r[n[0].src]:r}async unload(e){const t=o(e,(e=>({src:e}))).map((async e=>{const t=a.P6.path.toAbsolute(e.src),s=this.promiseCache[t];if(s){const a=await s.promise;s.parser?.unload?.(a,e,this),delete this.promiseCache[t]}}));await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter((e=>e.name)).reduce(((e,t)=>(e[t.name]&&console.warn(`[Assets] loadParser name conflict "${t.name}"`),{...e,[t.name]:t})),{})}}var d=(e=>(e[e.Low=0]="Low",e[e.Normal=1]="Normal",e[e.High=2]="High",e))(d||{});function A(e,t){if(Array.isArray(t)){for(const s of t)if(e.startsWith(`data:${s}`))return!0;return!1}return e.startsWith(`data:${t}`)}const p={extension:{type:a.nw.LoadParser,priority:d.Low},name:"loadJson",test:e=>A(e,"application/json")||n(e,".json"),async load(e){const t=await a.Xd.ADAPTER.fetch(e);return await t.json()}};a.Rw.add(p);const u={name:"loadTxt",extension:{type:a.nw.LoadParser,priority:d.Low},test:e=>A(e,"text/plain")||n(e,".txt"),async load(e){const t=await a.Xd.ADAPTER.fetch(e);return await t.text()}};a.Rw.add(u);const f=["normal","bold","100","200","300","400","500","600","700","800","900"],m=[".ttf",".otf",".woff",".woff2"],g=["font/ttf","font/otf","font/woff","font/woff2"],_=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function w(e){const t=a.P6.path.extname(e),s=a.P6.path.basename(e,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1)));let r=s.length>0;for(const e of s)if(!e.match(_)){r=!1;break}let i=s.join(" ");return r||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const y={extension:{type:a.nw.LoadParser,priority:d.Low},name:"loadWebFont",test:e=>A(e,g)||n(e,m),async load(e,t){const s=a.Xd.ADAPTER.getFontFaceSet();if(s){const a=[],r=t.data?.family??w(e),i=t.data?.weights?.filter((e=>f.includes(e)))??["normal"],n=t.data??{};for(let t=0;ta.Xd.ADAPTER.getFontFaceSet().delete(e)))}};a.Rw.add(y);let v,b=0;const B="\n async function checkImageBitmap()\n {\n try\n {\n if (typeof createImageBitmap !== 'function') return false;\n\n const response = await fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=');\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n }\n catch (e)\n {\n return false;\n }\n }\n checkImageBitmap().then((result) => { self.postMessage(result); });\n ",P="\n async function loadImageBitmap(url)\n {\n const response = await fetch(url);\n\n if (!response.ok)\n {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: `\n + `${response.status} ${response.statusText}`);\n }\n\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n\n return imageBitmap;\n }\n self.onmessage = async (event) =>\n {\n try\n {\n const imageBitmap = await loadImageBitmap(event.data.data[0]);\n\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id,\n }, [imageBitmap]);\n }\n catch(e)\n {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id,\n });\n }\n };";let I;const k=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise((e=>{const t=URL.createObjectURL(new Blob([B],{type:"application/javascript"})),s=new Worker(t);s.addEventListener("message",(a=>{s.terminate(),URL.revokeObjectURL(t),e(a.data)}))}))),this._isImageBitmapSupported}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){void 0===v&&(v=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers{this.complete(e.data),this.returnWorker(e.target),this.next()}))),e}returnWorker(e){this.workerPool.push(e)}complete(e){void 0!==e.error?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const s=new Promise(((s,a)=>{this.queue.push({id:e,arguments:t,resolve:s,reject:a})}));return this.next(),s}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),s=t.id;this.resolveHash[b]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:b++,id:s})}};function E(e,t,s){const r=new a.xE(e);return r.baseTexture.on("dispose",(()=>{delete t.promiseCache[s]})),r}const x=[".jpeg",".jpg",".png",".webp",".avif"],L=["image/jpeg","image/png","image/webp","image/avif"];async function R(e){const t=await a.Xd.ADAPTER.fetch(e);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${e}: ${t.status} ${t.statusText}`);const s=await t.blob();return await createImageBitmap(s)}const C={name:"loadTextures",extension:{type:a.nw.LoadParser,priority:d.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:e=>A(e,L)||n(e,x),async load(e,t,s){let r=null;r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await k.isImageBitmapSupported()?await k.loadImageBitmap(e):await R(e):await new Promise((t=>{r=new Image,r.crossOrigin=this.config.crossOrigin,r.src=e,r.complete?t(r):r.onload=()=>{t(r)}}));const i=new a.VL(r,{resolution:a.P6.getResolutionOfUrl(e),...t.data});return i.resource.src=e,E(i,s,e)},unload(e){e.destroy(!0)}};a.Rw.add(C);const j={extension:{type:a.nw.LoadParser,priority:d.High},name:"loadSVG",test:e=>A(e,"image/svg+xml")||n(e,".svg"),testParse:async e=>a.pX.test(e),async parse(e,t,s){const r=new a.pX(e,t?.data?.resourceOptions);await r.load();const i=new a.VL(r,{resolution:a.P6.getResolutionOfUrl(e),...t?.data});return i.resource.src=e,E(i,s,e)},load:async(e,t)=>(await a.Xd.ADAPTER.fetch(e)).text(),unload:C.unload};function O(e,t,s,a,r){const i=t[s];for(let n=0;n{const t=e.substring(1,e.length-1).split(",");a.push(t)})),O(e,a,0,t,s)}else s.push(e);return s}a.Rw.add(j);class ${constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach((e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))})),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if("string"==typeof e)this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach((e=>{this.addBundle(e.name,e.assets)}))}addBundle(e,t){const s=[];Array.isArray(t)?t.forEach((t=>{if("string"==typeof t.name){const a=this._createBundleAssetId(e,t.name);s.push(a),this.add([t.name,a],t.srcs,t.data)}else{const a=t.name.map((t=>this._createBundleAssetId(e,t)));a.forEach((e=>{s.push(e)})),this.add([...t.name,...a],t.srcs)}})):Object.keys(t).forEach((a=>{s.push(this._createBundleAssetId(e,a)),this.add([a,this._createBundleAssetId(e,a)],t[a])})),this._bundles[e]=s}add(e,t,s){const r=o(e);r.forEach((e=>{this.hasKey(e)&&console.warn(`[Resolver] already has key: ${e} overwriting`)})),Array.isArray(t)||(t="string"==typeof t?W(t):[t]);const i=t.map((e=>{let t=e;if("string"==typeof e){let s=!1;for(let a=0;a{this._assetMap[e]=i}))}resolveBundle(e){const t=h(e);e=o(e);const s={};return e.forEach((e=>{const t=this._bundles[e];if(t){const a=this.resolve(t),r={};for(const t in a){const s=a[t];r[this._extractAssetIdFromBundle(e,t)]=s}s[e]=r}})),t?s[e[0]]:s}resolveUrl(e){const t=this.resolve(e);if("string"!=typeof e){const e={};for(const s in t)e[s]=t[s].src;return e}return t.src}resolve(e){const t=h(e);e=o(e);const s={};return e.forEach((e=>{if(!this._resolverHash[e])if(this._assetMap[e]){let t=this._assetMap[e];const s=this._getPreferredOrder(t),a=t[0];s?.priority.forEach((e=>{s.params[e].forEach((s=>{const a=t.filter((t=>!!t[e]&&t[e]===s));a.length&&(t=a)}))})),this._resolverHash[e]=t[0]??a}else{let t=e;(this._basePath||this._rootPath)&&(t=a.P6.path.toAbsolute(t,this._basePath,this._rootPath)),t=this._appendDefaultSearchParams(t),this._resolverHash[e]={src:t}}s[e]=this._resolverHash[e]})),t?s[e[0]]:s}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;te.params.format.includes(t.format)));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){return this._defaultSearchParams?`${e}${/\?/.test(e)?"&":"?"}${this._defaultSearchParams}`:e}}class F{constructor(){this._detections=[],this._initialized=!1,this.resolver=new $,this.loader=new l,this.cache=c,this._backgroundLoader=new i(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized)return void console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let t=e.manifest;"string"==typeof t&&(t=await this.load(t)),this.resolver.addManifest(t)}const t=e.texturePreference?.resolution??1,s="number"==typeof t?[t]:t;let a=[];if(e.texturePreference?.format){const t=e.texturePreference?.format;a="string"==typeof t?[t]:t;for(const e of this._detections)await e.test()||(a=await e.remove(a))}else for(const e of this._detections)await e.test()&&(a=await e.add(a));this.resolver.prefer({params:{format:a,resolution:s}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,s){this.resolver.add(e,t,s)}async load(e,t){this._initialized||await this.init();const s=h(e),a=o(e).map((e=>"string"!=typeof e?(this.resolver.add(e.src,e),e.src):(this.resolver.hasKey(e)||this.resolver.add(e,e),e))),r=this.resolver.resolve(a),i=await this._mapLoadToResolve(r,t);return s?i[a[0]]:i}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let s=!1;"string"==typeof e&&(s=!0,e=[e]);const a=this.resolver.resolveBundle(e),r={},i=Object.keys(a);let n=0,o=0;const c=()=>{t?.(++n/o)},h=i.map((e=>{const t=a[e];return o+=Object.keys(t).length,this._mapLoadToResolve(t,c).then((t=>{r[e]=t}))}));return await Promise.all(h),s?r[e[0]]:r}async backgroundLoad(e){this._initialized||await this.init(),"string"==typeof e&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),"string"==typeof e&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach((e=>{this._backgroundLoader.add(Object.values(e))}))}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if("string"==typeof e)return c.get(e);const t={};for(let s=0;s{const s=r[e.src],n=[e.src];e.alias&&n.push(...e.alias),i[a[t]]=s,c.set(n,s)})),i}async unload(e){this._initialized||await this.init();const t=o(e).map((e=>"string"!=typeof e?e.src:e)),s=this.resolver.resolve(t);await this._unloadFromResolved(s)}async unloadBundle(e){this._initialized||await this.init(),e=o(e);const t=this.resolver.resolveBundle(e),s=Object.keys(t).map((e=>this._unloadFromResolved(t[e])));await Promise.all(s)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach((e=>{c.remove(e.src)})),await this.loader.unload(t)}get detections(){return this._detections}get preferWorkers(){return C.config.preferWorkers}set preferWorkers(e){a.P6.deprecation("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach((t=>{t.config&&Object.keys(t.config).filter((t=>t in e)).forEach((s=>{t.config[s]=e[s]}))}))}}const M=new F;a.Rw.handleByList(a.nw.LoadParser,M.loader.parsers).handleByList(a.nw.ResolveParser,M.resolver.parsers).handleByList(a.nw.CacheParser,M.cache.parsers).handleByList(a.nw.DetectionParser,M.detections);const T={extension:a.nw.CacheParser,test:e=>Array.isArray(e)&&e.every((e=>e instanceof a.xE)),getCacheableAssets:(e,t)=>{const s={};return e.forEach((e=>{t.forEach(((t,a)=>{s[e+(0===a?"":a+1)]=t}))})),s}};a.Rw.add(T);const S={extension:{type:a.nw.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const e=await a.Xd.ADAPTER.fetch("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=").then((e=>e.blob()));return createImageBitmap(e).then((()=>!0),(()=>!1))},add:async e=>[...e,"avif"],remove:async e=>e.filter((e=>"avif"!==e))};a.Rw.add(S);const D={extension:{type:a.nw.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const e=await a.Xd.ADAPTER.fetch("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=").then((e=>e.blob()));return createImageBitmap(e).then((()=>!0),(()=>!1))},add:async e=>[...e,"webp"],remove:async e=>e.filter((e=>"webp"!==e))};a.Rw.add(D);const U=["png","jpg","jpeg"],H={extension:{type:a.nw.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async e=>[...e,...U],remove:async e=>e.filter((e=>!U.includes(e)))};a.Rw.add(H);const X={extension:a.nw.ResolveParser,test:C.test,parse:e=>({resolution:parseFloat(a.Xd.RETINA_PREFIX.exec(e)?.[1]??"1"),format:e.split(".").pop(),src:e})};a.Rw.add(X);const V=(e,t)=>{const s=t.split("?")[1];return s&&(e+=`?${s}`),e}}}]);