From 887ce962b0754649c8b6cf7778441d7f440285ea Mon Sep 17 00:00:00 2001 From: ultraviolet-jordan Date: Mon, 8 Jan 2024 05:37:54 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=202004scap?= =?UTF-8?q?e/Client2@1c43f65e57381f26ac2bfa773cfc7e6dd511e0a5=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ba55e1fb..9ba763fe 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -(()=>{"use strict";var t={621:(t,e,i)=>{t.exports=i.p+"9f86b5397894e28b5ae2.wasm"}},e={};function i(s){var r=e[s];if(void 0!==r)return r.exports;var a=e[s]={exports:{}};return t[s](a,a.exports,i),a.exports}i.m=t,i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.p="/Client2/",i.b=document.baseURI||self.location.href,(()=>{class t{index;constructor(t){this.index=t}decodeType=t=>{for(;;){const e=t.g1;if(0===e)break;this.decode(e,t)}}}class e{static crctable=new Int32Array(256);static CRC32_POLYNOMIAL=3988292384;static bitmask=new Uint32Array(33);static{for(let t=0;t<32;t++)e.bitmask[t]=(1<>>1^e.CRC32_POLYNOMIAL:i>>>=1;e.crctable[t]=i}}data;pos;bitPos=0;constructor(t){if(!t)throw new Error("Input src packet array was null!");this.data=t,this.pos=0}static alloc=t=>new e(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):new Uint8Array(3e4));get g1(){return this.data[this.pos++]}get g1b(){return this.data[this.pos++]<<24>>24}get g2(){return(this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g2b(){return this.data[this.pos++]<<8|this.data[this.pos++]}get g3(){return(this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g4(){return(this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g4s(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g8(){return BigInt(this.g4)<<32n|BigInt(this.g4)}get gsmart(){return this.data[this.pos]<128?this.g1:this.g2-32768}get gsmarts(){return this.data[this.pos]<128?this.g1-64:this.g2-49152}get gjstr(){let t="";for(;10!=this.data[this.pos]&&this.posthis.data.subarray(t,t+e);p1=t=>{this.data[this.pos++]=t};p2=t=>{this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};ip2=t=>{this.data[this.pos++]=t,this.data[this.pos++]=t>>>8};p3=t=>{this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};p4=t=>{this.data[this.pos++]=t>>>24,this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};ip4=t=>{this.data[this.pos++]=t,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>24};p8=t=>{this.p4(Number(t>>32n)),this.p4(Number(0xffffffffn&t))};pjstr=t=>{for(let e=0;e{for(let s=i;s{this.data[this.pos-t-1]=t};bits=()=>{this.bitPos=8*this.pos};bytes=()=>{this.pos=(this.bitPos+7)/8>>>0};gBit=t=>{let i=this.bitPos>>>3,s=8-(7&this.bitPos),r=0;for(this.bitPos+=t;t>s;s=8)r+=(this.data[i++]&e.bitmask[s])<>>s-t&e.bitmask[t],r}}class s{static instances=[];static unpack=t=>{const i=new e(t.read("base_head.dat")),r=new e(t.read("base_type.dat")),a=new e(t.read("base_label.dat")),n=i.g2;i.pos+=2;for(let t=0;t{const i=new e(t.read("frame_head.dat")),a=new e(t.read("frame_tran1.dat")),n=new e(t.read("frame_tran2.dat")),o=new e(t.read("frame_del.dat")),l=i.g2;i.pos+=2;const h=new Uint32Array(500),c=new Uint32Array(500),f=new Uint32Array(500),d=new Uint32Array(500);for(let t=0;t0){if(0!=u.types[t])for(let e=t-1;e>m;e--)if(0==u.types[e]){h[p]=e,c[p]=0,f[p]=0,d[p]=0,p++;break}h[p]=t;let i=0;3==u.types[h[p]]&&(i=128),c[p]=0==(1&e)?i:n.gsmart,f[p]=0==(2&e)?i:n.gsmart,d[p]=0==(4&e)?i:n.gsmart,m=t,p++}}e.length=p,e.bases=new Uint32Array(p),e.x=new Uint32Array(p),e.y=new Uint32Array(p),e.z=new Uint32Array(p);for(let t=0;t{const i=new e(t.read("seq.dat"));this.count=i.g2;for(let t=0;ta.instances[t];frameCount=0;frames=null;iframes=null;delay=null;replayoff=-1;labelGroups=null;stretches=!1;priority=5;mainhand=-1;offhand=-1;replaycount=99;duration=0;decode=(t,e)=>{if(1===t){this.frameCount=e.g1,this.frames=new Uint16Array(this.frameCount),this.iframes=new Uint16Array(this.frameCount),this.delay=new Uint16Array(this.frameCount);for(let t=0;t{const i=new e(t.read("loc.dat"));this.count=i.g2;for(let t=0;t0&&10==e.shapes[0]?1:0,e.ops.length>0&&(e.active=1))}};static get=t=>n.instances[t];models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=-1;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;hasalpha=!1;walloff=16;ambient=0;contrast=0;ops=[];mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;decode=(t,e)=>{if(1===t){const t=e.g1;this.models=new Uint16Array(t),this.shapes=new Uint8Array(t);for(let i=0;i=30&&t<35)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i{const i=new e(t.read("flo.dat"));this.count=i.g2;for(let t=0;to.instances[t];rgb=0;texture=-1;opcode3=!1;occludes=!0;name=null;decode=(t,e)=>{1===t?this.rgb=e.g3:2===t?this.texture=e.g1:3===t?this.opcode3=!0:5===t?this.occludes=!1:6===t?this.name=e.gjstr:console.log("Error unrecognised config code: ",t)}}class l{static pixels=new Int32Array;static width=0;static height=0;static top=0;static bottom=0;static left=0;static right=0;static boundX=0;static centerX=0;static centerY=0;static bind=(t,e,i)=>{this.pixels=t,this.width=e,this.height=i,this.setBounds(0,0,e,i)};static resetBounds=()=>{this.left=0,this.top=0,this.right=this.width,this.bottom=this.height,this.boundX=this.right-1,this.centerX=this.right/2};static setBounds=(t,e,i,s)=>{t<0&&(t=0),e<0&&(e=0),i>this.width&&(i=this.width),s>this.height&&(s=this.height),this.top=e,this.bottom=s,this.left=t,this.right=i,this.boundX=this.right-1,this.centerX=this.right/2,this.centerY=this.bottom/2};static clear=()=>{this.pixels.fill(0)};static drawRect=(t,e,i,s,r)=>{this.drawHorizontalLine(t,e,r,i),this.drawHorizontalLine(t,e+s-1,r,i),this.drawVerticalLine(t,e,r,s),this.drawVerticalLine(t+i-1,e,r,s)};static drawHorizontalLine=(t,e,i,s)=>{if(e=this.bottom)return;tthis.right&&(s=this.right-t);const r=t+e*this.width;for(let t=0;t{if(t=this.right)return;ethis.bottom&&(s=this.bottom-e);const r=t+e*this.width;for(let t=0;t{const a=Math.abs(i-t),n=Math.abs(s-e),o=t=this.left&&t=this.top&&e-n&&(h-=n,t+=o),i{const a=this.pixels;let n=t,o=e,l=t+i,h=e+s;nthis.right&&(l=this.right),h>this.bottom&&(h=this.bottom);const c=this.width;for(let t=o;tt.bits-e.bits||t.code-e.code));let a=0,n=-1;const o=[];let l;for(let t=0;t=t.length)throw RangeError("Out of bound");const i=t.slice();t.sort(((t,e)=>t-e));const s={};for(let e=t.length-1;e>=0;e-=1)s[t[e]]=e;const r=[];for(let e=0;enew Promise((e=>setTimeout(e,t))),g=async t=>new Uint8Array(await(await fetch(t)).arrayBuffer()),m=(t,e=!0,i=!0)=>{if(e){const e=Uint8Array.from(["B".charCodeAt(0),"Z".charCodeAt(0),"h".charCodeAt(0),"1".charCodeAt(0)]);if(i){const i=t;(t=new Uint8Array(e.length+t.length)).set(i,e.length)}t.set(e,0)}return function(t,e=!1){let i=0,s=0,r=0;const a=e=>{if(e>=32){const t=e>>1;return a(t)*(1<>r-e&n;return r-=e,s&=~(n<=49&&n<=57))throw new Error("Invalid blocksize");n-=48;let o=new Uint8Array(1.5*t.length),l=0,u=-1;for(;;){const n=a(48),g=0|a(32);if(54156738319193!==n){if(25779555029136===n){a(7&r);break}throw new Error("Invalid bz2 blocktype")}{if(a(1))throw new Error("do not support randomised");const n=a(24),m=[],p=a(16);for(let t=32768;t>0;t>>=1){if(!(p&t)){for(let t=0;t<16;t+=1)m.push(!1);continue}const e=a(16);for(let t=32768;t>0;t>>=1)m.push(!!(e&t))}const w=a(3);if(w<2||w>6)throw new Error("Invalid number of huffman groups");const b=a(15),y=[],v=Array.from({length:w},((t,e)=>e));for(let t=0;t=w)throw new Error("MTF table out of range");const e=v[t];for(let e=t;e>0;v[e]=v[--e]);y.push(e),v[0]=e}const x=m.reduce(((t,e)=>t+e),0)+2,C=[];for(let t=0;t20)throw new Error("Huffman group length outside range");for(;a(1);)t-=2*a(1)-1;e.push(t)}C.push(f(e))}const S=[];for(let t=0;t>r-e],A)){s&=c[r-=e],A=A.code;break}if(A>=0&&A<=1)0===_&&(O=1),_+=O<0;_-=1)P.push(t)}if(A===x-1)break;{const t=S[A-1];for(let t=A-1;t>0;S[t]=S[--t]);S[0]=t,P.push(t)}}}const M=d(P,n);let E=0;for(;E=o.length){const t=o;o=new Uint8Array(2*t.length),o.set(t)}for(let s=0;s>24^t)]),o[l]=t,l+=1}if(e){const t=-1^u;if(t!==g)throw new Error(`CRC mismatch: ${t} !== ${g}`);u=-1}}}return o.subarray(0,l)}(t)},p=(t,e,i,s,r)=>{for(;r--;)i[s++]=t[e++]};class w{pixels;width;height;cropX;cropY;cropW;cropH;constructor(t,e){this.pixels=new Int32Array(t*e),this.width=this.cropW=t,this.height=this.cropH=e,this.cropX=this.cropY=0}static fromJpeg=async(t,e)=>{const i=t.read(e+".dat"),s=await(async t=>{if(!t)throw new Error("Input jpeg data was null!");255!==t[0]&&(t[0]=255);const e=document.createElement("img");e.src="data:image/jpeg;base64,"+btoa(String.fromCharCode(...t)),await new Promise((t=>e.onload=t));const i=document.createElement("canvas");i.width=e.naturalWidth,i.height=e.naturalHeight;const s=i.getContext("2d");if(!s)throw new Error("Canvas 2d not found!!!!!!!!");return s.drawImage(e,0,0),s.getImageData(0,0,i.width,i.height)})(i),r=new w(s.width,s.height),a=r.pixels,n=s.data;for(let t=0;t{const r=new e(t.read(i+".dat")),a=new e(t.read("index.dat"));a.pos=r.g2;const n=a.g2,o=a.g2,l=a.g1,h=new Uint32Array(l),c=l-1;for(let t=0;t{t|=0,e|=0;let i=(t+=this.cropX)+(e+=this.cropY)*l.width,s=0,r=this.height,a=this.width,n=l.width-a,o=0;if(el.bottom&&(r-=e+r-l.bottom),tl.right){const e=t+a-l.right;a-=e,o+=e,n+=e}a>0&&r>0&&this.copyImageDraw(a,r,this.pixels,s,o,l.pixels,i,n)};drawAlpha=(t,e,i)=>{e|=0,i|=0;let s=(e+=this.cropX)+(i+=this.cropY)*l.width,r=0,a=this.height,n=this.width,o=l.width-n,h=0;if(il.bottom&&(a-=i+a-l.bottom),el.right){const t=e+n-l.right;n-=t,h+=t,o+=t}n>0&&a>0&&this.copyPixelsAlpha(n,a,this.pixels,r,h,l.pixels,s,o,t)};blitOpaque=(t,e)=>{t|=0,e|=0;let i=(t+=this.cropX)+(e+=this.cropY)*l.width,s=0,r=this.height,a=this.width,n=l.width-a,o=0;if(el.bottom&&(r-=e+r-l.bottom),tl.right){const e=t+a-l.right;a-=e,o+=e,n+=e}a>0&&r>0&&this.copyImageBlitOpaque(a,r,this.pixels,s,o,l.pixels,i,n)};flipHorizontally=()=>{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{for(let s=0;s>16&255;a+=t,a<1?a=1:a>255&&(a=255);let n=r>>8&255;n+=e,n<1?n=1:n>255&&(n=255);let o=255&r;o+=i,o<1?o=1:o>255&&(o=255),this.pixels[s]=(a<<16)+(n<<8)+o}}};copyImageBlitOpaque=(t,e,i,s,r,a,n,o)=>{const l=-(t>>2);t=-(3&t);for(let h=-e;h<0;h++){for(let t=l;t<0;t++)a[n++]=i[s++],a[n++]=i[s++],a[n++]=i[s++],a[n++]=i[s++];for(let e=t;e<0;e++)a[n++]=i[s++];n+=o,s+=r}};copyPixelsAlpha=(t,e,i,s,r,a,n,o,l)=>{const h=256-l;for(let c=-e;c<0;c++){for(let e=-t;e<0;e++){const t=i[s++];if(0==t)n++;else{const e=a[n];a[n++]=((16711935&t)*l+(16711935&e)*h&4278255360)+((65280&t)*l+(65280&e)*h&16711680)>>8}}n+=o,s+=r}};copyImageDraw=(t,e,i,s,r,a,n,o)=>{const l=-(t>>2);t=-(3&t);for(let h=-e;h<0;h++){for(let t=l;t<0;t++){let t=i[s++];0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t}for(let e=t;e<0;e++){const t=i[s++];0===t?n++:a[n++]=t}n+=o,s+=r}}}class b extends t{static count=0;static instances=[];static unpack=(t,i)=>{const s=new e(t.read("obj.dat"));this.count=s.g2;for(let t=0;tb.instances[t];static getIcon=(t,e)=>new w(32,32);model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;ops=[];iops=[];manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;decode=(t,e)=>{if(1===t)this.model=e.g2;else if(2===t)this.name=e.gjstr;else if(3===t)this.desc=e.gjstr;else if(4===t)this.zoom2d=e.g2;else if(5===t)this.xan2d=e.g2;else if(6===t)this.yan2d=e.g2;else if(7===t)this.xof2d=e.g2b,this.xof2d>32767&&(this.xof2d-=65536);else if(8===t)this.yof2d=e.g2b,this.yof2d>32767&&(this.yof2d-=65536);else if(9===t)this.code9=!0;else if(10===t)this.code10=e.g2;else if(11===t)this.stackable=!0;else if(12===t)this.cost=e.g4s;else if(16===t)this.members=!0;else if(23===t)this.manwear=e.g2,this.manwearOffsetY=e.g1b;else if(24===t)this.manwear2=e.g2;else if(25===t)this.womanwear=e.g2,this.womanwearOffsetY=e.g1b;else if(26===t)this.womanwear2=e.g2;else if(t>=30&&t<35)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(t>=35&&t<40)this.iops[t-35]=e.gjstr;else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i=100&&t<110))throw new Error(`Unrecognized obj config code: ${t}`);this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[t-100]=e.g2,this.countco[t-100]=e.g2}};toCertificate=()=>{const t=b.get(this.certtemplate);this.model=t.model,this.zoom2d=t.zoom2d,this.xan2d=t.xan2d,this.yan2d=t.yan2d,this.zan2d=t.zan2d,this.xof2d=t.xof2d,this.yof2d=t.yof2d,this.recol_s=t.recol_s,this.recol_d=t.recol_d;const e=b.get(this.certlink);this.name=e.name,this.members=e.members,this.cost=e.cost;let i="a";const s=(e.name||"").toLowerCase().charAt(0);"a"!==s&&"e"!==s&&"i"!==s&&"o"!==s&&"u"!==s||(i="an"),this.desc=`Swap this note at any bank for ${i} ${e.name}.`,this.stackable=!0}}class y extends t{static count=0;static instances=[];static unpack=t=>{const i=new e(t.read("npc.dat"));this.count=i.g2;for(let t=0;ty.instances[t];name=null;desc=null;size=1;models=null;heads=null;hasanim=!1;readyanim=-1;walkanim=-1;walkanim_b=-1;walkanim_r=-1;walkanim_l=-1;hasalpha=!1;recol_s=null;recol_d=null;ops=[];code90=-1;code91=-1;code92=-1;visonmap=!0;vislevel=-1;resizeh=128;resizev=128;decode=(t,e)=>{if(1===t){const t=e.g1;this.models=new Uint16Array(t);for(let i=0;i=30&&t<40)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i{const i=new e(t.read("idk.dat"));this.count=i.g2;for(let t=0;tv.instances[t];type=-1;models=null;heads=new Uint16Array(5).fill(-1);recol_s=new Uint16Array(6);recol_d=new Uint16Array(6);disable=!1;decode=(t,e)=>{if(1===t)this.type=e.g1;else if(2===t){const t=e.g1;this.models=new Uint16Array(t);for(let i=0;i=40&&t<50)this.recol_s[t-40]=e.g2;else if(t>=50&&t<60)this.recol_d[t-50]=e.g2;else{if(!(t>=60&&t<70))throw new Error(`Unrecognized idk config code: ${t}`);this.heads[t-60]=e.g2}}}class x extends t{static count=0;static instances=[];static unpack=t=>{const i=new e(t.read("spotanim.dat"));this.count=i.g2;for(let t=0;tx.instances[t];model=0;anim=-1;seq=null;disposeAlpha=!1;recol_s=new Uint16Array(6);recol_d=new Uint16Array(6);resizeh=128;resizev=128;orientation=0;ambient=0;contrast=0;decode=(t,e)=>{if(1==t)this.model=e.g2;else if(2==t)this.anim=e.g2,null!=a.instances&&(this.seq=a.instances[this.anim]);else if(3==t)this.disposeAlpha=!0;else if(4==t)this.resizeh=e.g2;else if(5==t)this.resizev=e.g2;else if(6==t)this.orientation=e.g2;else if(7==t)this.ambient=e.g1;else if(8==t)this.contrast=e.g1;else if(t>=40&&t<50)this.recol_s[t-40]=e.g2;else{if(!(t>=50&&t<60))throw new Error(`Unrecognized spotanim config code: ${t}`);this.recol_d[t-50]=e.g2}}}class C extends t{static count=0;static instances=[];static code3=[];static code3Count=0;static unpack=t=>{const i=new e(t.read("varp.dat"));this.count=i.g2;for(let t=0;tC.instances[t];code10=null;code1=0;code2=0;hasCode3=!1;code4=!0;clientcode=0;code7=0;code6=!1;code8=!1;decode(t,e){if(1==t)this.code1=e.g1;else if(2==t)this.code2=e.g1;else if(3==t)this.hasCode3=!0,C.code3[C.code3Count++]=this.index;else if(4==t)this.code4=!1;else if(5==t)this.clientcode=e.g2;else if(6==t)this.code6=!0;else if(7==t)this.code7=e.g4;else if(8==t)this.code8=!0;else{if(10!=t)throw new Error(`Error unrecognised config code: ${t}`);this.code10=e.gjstr}}}class S{pixels;width;height;cropX;cropY;cropW;cropH;palette=new Uint32Array(0);constructor(t,e){this.pixels=new Uint8Array(t*e),this.width=this.cropW=t,this.height=this.cropH=e,this.cropX=this.cropY=0}static fromArchive=(t,i,s=0)=>{const r=new e(t?.read(i+".dat")),a=new e(t?.read("index.dat"));a.pos=r.g2;const n=a.g2,o=a.g2,l=a.g1,h=new Uint32Array(l);for(let t=0;t{t|=0,e|=0;let r=(t+=this.cropX)+(e+=this.cropY)*l.width,a=0,n=this.height,o=this.width;-1!==i&&(o=i),-1!==s&&(n=s);let h=l.width-o,c=0;if(el.bottom&&(n-=e+n-l.bottom),tl.right){const e=t+o-l.right;o-=e,c+=e,h+=e}o>0&&n>0&&this.copyImage(o,n,this.pixels,a,c,l.pixels,r,h)};flipHorizontally=()=>{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{for(let s=0;s>16&255;r+=t,r<0?r=0:r>255&&(r=255);let a=this.palette[s]>>8&255;a+=e,a<0?a=0:a>255&&(a=255);let n=255&this.palette[s];n+=i,n<0?n=0:n>255&&(n=255),this.palette[s]=(r<<16)+(a<<8)+n}};copyImage=(t,e,i,s,r,a,n,o)=>{for(let l=0;l{this.lineOffset=new Int32Array(l.height);for(let t=0;t{this.lineOffset=new Int32Array(e);for(let i=0;i{this.textureCount=0;for(let e=0;e<50;e++)try{this.textures[e]=S.fromArchive(t,e.toString()),this.textureCount++}catch(t){}};static setBrightness=t=>{t+=.3*Math.random()-.15;let e=0;for(let i=0;i<512;i++){const s=i/8/64+.0078125,r=(7&i)/8+.0625;for(let i=0;i<128;i++){const a=i/128;let n=a,o=a,l=a;if(r){let t;t=a<.5?a*(1+r):a+r-a*r;const e=2*a-t;let i=s+.3333333333333333;i>1&&i--;let h=s-.3333333333333333;h<0&&h++,n=6*i<1?e+6*(t-e)*i:2*i<1?t:3*i<2?e+6*(.6666666666666666-i)*(t-e):e,o=6*s<1?e+6*(t-e)*s:2*s<1?t:3*s<2?e+6*(.6666666666666666-s)*(t-e):e,l=6*h<1?e+6*(t-e)*h:2*h<1?t:3*h<2?e+6*(.6666666666666666-h)*(t-e):e}let h=Math.trunc(256*n)<<16|Math.trunc(256*o)<<8|Math.trunc(256*l);h=this.setGamma(h,t),0===h&&(h=1),this.palette[e++]=h}}};static setGamma=(t,e)=>{let i=(t>>16)/256,s=(t>>8&255)/256,r=(255&t)/256;return i=Math.pow(i,e),s=Math.pow(s,e),r=Math.pow(r,e),Math.trunc(256*i)<<16|Math.trunc(256*s)<<8|Math.trunc(256*r)};static initPool=t=>{null==this.texelPool&&(this.poolSize=t,this.texelPool=[],this.activeTexels=[])};static fillGouraudTriangle=(t,e,i,s,r,a,n,o,h)=>{let c=0,f=0,d=0,u=0,g=0,m=0;if(r!=s&&(c=(e-t<<16)/(r-s),u=(o-n<<15)/(r-s)),a!=r&&(f=(i-e<<16)/(a-r),g=(h-o<<15)/(a-r)),a!=s&&(d=(t-i<<16)/(s-a),m=(n-h<<15)/(s-a)),s<=r&&s<=a){if(s>=l.bottom)return;if(r>l.bottom&&(r=l.bottom),a>l.bottom&&(a=l.bottom),rf){for(a-=r,r-=s,s=this.lineOffset[s];--r>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,i>>16,t>>16,h>>7,n>>7),i+=d,t+=c,h+=m,n+=u;for(;--a>=0;)this.drawGouraudScanline(l.pixels,s,i>>16,e>>16,h>>7,o>>7),i+=d,e+=f,h+=m,o+=g,s+=l.width;return}for(a-=r,r-=s,s=this.lineOffset[s];--r>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,t>>16,i>>16,n>>7,h>>7),i+=d,t+=c,h+=m,n+=u;for(;--a>=0;)this.drawGouraudScanline(l.pixels,s,e>>16,i>>16,o>>7,h>>7),i+=d,e+=f,h+=m,o+=g,s+=l.width;return}if(e=t<<=16,o=n<<=15,s<0&&(e-=d*s,t-=c*s,o-=m*s,n-=u*s,s=0),i<<=16,h<<=15,a<0&&(i-=f*a,h-=g*a,a=0),s!=a&&dc){for(r-=a,a-=s,s=this.lineOffset[s];--a>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,e>>16,t>>16,o>>7,n>>7),e+=d,t+=c,o+=m,n+=u;for(;--r>=0;)this.drawGouraudScanline(l.pixels,s,i>>16,t>>16,h>>7,n>>7),i+=f,t+=c,h+=g,n+=u,s+=l.width;return}for(r-=a,a-=s,s=this.lineOffset[s];--a>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,t>>16,e>>16,n>>7,o>>7),e+=d,t+=c,o+=m,n+=u;for(;--r>=0;)this.drawGouraudScanline(l.pixels,s,t>>16,i>>16,n>>7,h>>7),i+=f,t+=c,h+=g,n+=u,s+=l.width}else if(r<=a){if(r>=l.bottom)return;if(a>l.bottom&&(a=l.bottom),s>l.bottom&&(s=l.bottom),ad){for(s-=a,a-=r,r=this.lineOffset[r];--a>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,t>>16,e>>16,n>>7,o>>7),t+=c,e+=f,n+=u,o+=g;for(;--s>=0;)this.drawGouraudScanline(l.pixels,r,t>>16,i>>16,n>>7,h>>7),t+=c,i+=d,n+=u,h+=m,r+=l.width;return}for(s-=a,a-=r,r=this.lineOffset[r];--a>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,e>>16,t>>16,o>>7,n>>7),t+=c,e+=f,n+=u,o+=g;for(;--s>=0;)this.drawGouraudScanline(l.pixels,r,i>>16,t>>16,h>>7,n>>7),t+=c,i+=d,n+=u,h+=m,r+=l.width;return}if(i=e<<=16,h=o<<=15,r<0&&(i-=c*r,e-=f*r,h-=u*r,o-=g*r,r=0),t<<=16,n<<=15,s<0&&(t-=d*s,n-=m*s,s=0),c=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,i>>16,e>>16,h>>7,o>>7),i+=c,e+=f,h+=u,o+=g;for(;--a>=0;)this.drawGouraudScanline(l.pixels,r,t>>16,e>>16,n>>7,o>>7),t+=d,e+=f,n+=m,o+=g,r+=l.width;return}for(a-=s,s-=r,r=this.lineOffset[r];--s>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,e>>16,i>>16,o>>7,h>>7),i+=c,e+=f,h+=u,o+=g;for(;--a>=0;)this.drawGouraudScanline(l.pixels,r,e>>16,t>>16,o>>7,n>>7),t+=d,e+=f,n+=m,o+=g,r+=l.width}else if(!(a>=l.bottom))if(s>l.bottom&&(s=l.bottom),r>l.bottom&&(r=l.bottom),s=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,e>>16,i>>16,o>>7,h>>7),e+=f,i+=d,o+=g,h+=m;for(;--r>=0;)this.drawGouraudScanline(l.pixels,a,e>>16,t>>16,o>>7,n>>7),e+=f,t+=c,o+=g,n+=u,a+=l.width;return}for(r-=s,s-=a,a=this.lineOffset[a];--s>=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,i>>16,e>>16,h>>7,o>>7),e+=f,i+=d,o+=g,h+=m;for(;--r>=0;)this.drawGouraudScanline(l.pixels,a,t>>16,e>>16,n>>7,o>>7),e+=f,t+=c,o+=g,n+=u,a+=l.width}else if(t=i<<=16,n=h<<=15,a<0&&(t-=f*a,i-=d*a,n-=g*a,h-=m*a,a=0),e<<=16,o<<=15,r<0&&(e-=c*r,o-=u*r,r=0),f=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,t>>16,i>>16,n>>7,h>>7),t+=f,i+=d,n+=g,h+=m;for(;--s>=0;)this.drawGouraudScanline(l.pixels,a,e>>16,i>>16,o>>7,h>>7),e+=c,i+=d,o+=u,h+=m,a+=l.width}else{for(s-=r,r-=a,a=this.lineOffset[a];--r>=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,i>>16,t>>16,h>>7,n>>7),t+=f,i+=d,n+=g,h+=m;for(;--s>=0;)this.drawGouraudScanline(l.pixels,a,i>>16,e>>16,h>>7,o>>7),e+=c,i+=d,o+=u,h+=m,a+=l.width}};static drawGouraudScanline=(t,e,i,s,r,a)=>{let n=0,o=0;if(this.jagged){let h=0;if(this.clipX){if(h=s-i>3?(a-r)/(s-i):0,s>l.right&&(s=l.right),i<0&&(r-=i*h,i=0),i>=s)return;e+=i,o=s-i>>2,h<<=2}else{if(i>=s)return;e+=i,o=s-i>>2,h=o>0?(a-r)*this.reciprocal15[o]>>15:0}if(0==this.alpha){for(;--o>=0;)n=this.palette[r>>8],r+=h,t[e++]=n,t[e++]=n,t[e++]=n,t[e++]=n;if(o=s-i&3,o>0){n=this.palette[r>>8];do{t[e++]=n}while(--o>0);return}}else{const a=this.alpha,l=256-this.alpha;for(;--o>=0;)n=this.palette[r>>8],r+=h,n=((16711935&n)*l>>8&16711935)+((65280&n)*l>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280);if(o=s-i&3,o>0){n=this.palette[r>>8],n=((16711935&n)*l>>8&16711935)+((65280&n)*l>>8&65280);do{t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280)}while(--o>0)}}return}if(i>=s)return;const h=(a-r)/(s-i);if(this.clipX&&(s>l.right&&(s=l.right),i<0&&(r-=i*h,i=0),i>=s))return;if(e+=i,o=s-i,0==this.alpha){do{t[e++]=this.palette[r>>8],r+=h}while(--o>0);return}const c=this.alpha,f=256-this.alpha;do{n=this.palette[r>>8],r+=h,n=((16711935&n)*f>>8&16711935)+((65280&n)*f>>8&65280),t[e++]=n+((16711935&t[e])*c>>8&16711935)+((65280&t[e])*c>>8&65280)}while(--o>0)};static fillTriangle=()=>{};static fillTexturedTriangle=()=>{}}class A{vertexCount=0;faceCount=0;texturedFaceCount=0;vertexFlagsOffset=-1;vertexXOffset=-1;vertexYOffset=-1;vertexZOffset=-1;vertexLabelsOffset=-1;faceVerticesOffset=-1;faceOrientationsOffset=-1;faceColorsOffset=-1;faceInfosOffset=-1;facePrioritiesOffset=0;faceAlphasOffset=-1;faceLabelsOffset=-1;faceTextureAxisOffset=-1}class k{x=0;y=0;z=0;w=0}class I{static metadata=null;static head=null;static face1=null;static face2=null;static face3=null;static face4=null;static face5=null;static point1=null;static point2=null;static point3=null;static point4=null;static point5=null;static vertex1=null;static vertex2=null;static axis=null;static faceClippedX=new Array(4096);static faceNearClipped=new Array(4096);static vertexScreenX=new Int32Array(4096);static vertexScreenY=new Int32Array(4096);static vertexScreenZ=new Int32Array(4096);static vertexViewSpaceX=new Int32Array(4096);static vertexViewSpaceY=new Int32Array(4096);static vertexViewSpaceZ=new Int32Array(4096);static tmpDepthFaceCount=new Int32Array(1500);static tmpDepthFaces=new Array(1500).fill(null).map((()=>new Int32Array(512)));static tmpPriorityFaceCount=new Int32Array(12);static tmpPriorityFaces=new Array(12).fill(null).map((()=>new Int32Array(2e3)));static tmpPriority10FaceDepth=new Int32Array(2e3);static tmpPriority11FaceDepth=new Int32Array(2e3);static tmpPriorityDepthSum=new Int32Array(12);static clippedX=new Int32Array(10);static clippedY=new Int32Array(10);static clippedColor=new Int32Array(10);static baseX=0;static baseY=0;static baseZ=0;static checkHover=!1;static mouseX=0;static mouseZ=0;static pickedCount=0;static pickedBitsets=new Int32Array(1e3);static unpack(t){try{I.head=new e(t.read("ob_head.dat")),I.face1=new e(t.read("ob_face1.dat")),I.face2=new e(t.read("ob_face2.dat")),I.face3=new e(t.read("ob_face3.dat")),I.face4=new e(t.read("ob_face4.dat")),I.face5=new e(t.read("ob_face5.dat")),I.point1=new e(t.read("ob_point1.dat")),I.point2=new e(t.read("ob_point2.dat")),I.point3=new e(t.read("ob_point3.dat")),I.point4=new e(t.read("ob_point4.dat")),I.point5=new e(t.read("ob_point5.dat")),I.vertex1=new e(t.read("ob_vertex1.dat")),I.vertex2=new e(t.read("ob_vertex2.dat")),I.axis=new e(t.read("ob_axis.dat")),I.head.pos=0,I.point1.pos=0,I.point2.pos=0,I.point3.pos=0,I.point4.pos=0,I.vertex1.pos=0,I.vertex2.pos=0;const i=I.head.g2;I.metadata=new Array(i+100);let s=0,r=0,a=0,n=0,o=0,l=0,h=0;for(let t=0;t127&&(e=127),127-e):((e=e*(127&t)>>7)<2?e=2:e>126&&(e=126),(65408&t)+e)}vertexCount=0;vertexX=null;vertexY=null;vertexZ=null;faceCount=0;faceVertexA=null;faceVertexB=null;faceVertexC=null;faceColorA=null;faceColorB=null;faceColorC=null;faceInfo=null;facePriority=null;faceAlpha=null;faceColor=null;priority=0;texturedFaceCount=0;texturedVertexA=null;texturedVertexB=null;texturedVertexC=null;minX=0;maxX=0;minZ=0;maxZ=0;radius=0;minY=0;maxY=0;maxDepth=0;minDepth=0;objRaise=0;vertexLabel=null;faceLabel=null;labelVertices=null;labelFaces=null;pickable=!1;vertexNormal=null;vertexNormalOriginal=null;constructor(t){if(null===I.head||null===I.face1||null===I.face2||null===I.face3||null===I.face4||null===I.face5||null===I.point1||null===I.point2||null===I.point3||null===I.point4||null===I.point5||null===I.vertex1||null===I.vertex2||null===I.axis)return;if(null===I.metadata)return;const e=I.metadata[t];if(void 0===e)return void console.log(`Error model:${t} not found!`);this.vertexCount=e.vertexCount,this.faceCount=e.faceCount,this.texturedFaceCount=e.texturedFaceCount,this.vertexX=new Int32Array(this.vertexCount),this.vertexY=new Int32Array(this.vertexCount),this.vertexZ=new Int32Array(this.vertexCount),this.faceVertexA=new Int32Array(this.faceCount),this.faceVertexB=new Int32Array(this.faceCount),this.faceVertexC=new Int32Array(this.faceCount),this.texturedVertexA=new Int32Array(this.texturedFaceCount),this.texturedVertexB=new Int32Array(this.texturedFaceCount),this.texturedVertexC=new Int32Array(this.texturedFaceCount),e.vertexLabelsOffset>=0&&(this.vertexLabel=new Int32Array(this.vertexCount)),e.faceInfosOffset>=0&&(this.faceInfo=new Int32Array(this.faceCount)),e.facePrioritiesOffset>=0?this.facePriority=new Int32Array(this.faceCount):this.priority=-e.facePrioritiesOffset-1,e.faceAlphasOffset>=0&&(this.faceAlpha=new Int32Array(this.faceCount)),e.faceLabelsOffset>=0&&(this.faceLabel=new Int32Array(this.faceCount)),this.faceColor=new Int32Array(this.faceCount),I.point1.pos=e.vertexFlagsOffset,I.point2.pos=e.vertexXOffset,I.point3.pos=e.vertexYOffset,I.point4.pos=e.vertexZOffset,I.point5.pos=e.vertexLabelsOffset;let i,s,r,a=0,n=0,o=0;for(let t=0;tthis.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const r=e*e+s*s;r>this.radius&&(this.radius=r)}this.radius=Math.trunc(Math.sqrt(this.radius)+.99),this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99)}}calculateBoundsY(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ){this.maxY=0,this.minY=0;for(let t=0;tthis.maxY&&(this.maxY=-e),e>this.minY&&(this.minY=e)}this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99)}}calculateBoundsAABB(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ){this.maxY=0,this.radius=0,this.minY=0,this.minX=999999,this.maxX=-999999,this.maxZ=-99999,this.minZ=99999;for(let t=0;tthis.maxX&&(this.maxX=e),sthis.maxZ&&(this.maxZ=s),-i>this.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const r=e*e+s*s;r>this.radius&&(this.radius=r)}this.radius=Math.trunc(Math.sqrt(this.radius)),this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY))}}createLabelReferences(){}applyTransform(t){}rotateY90(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ)for(let t=0;t>16;this.vertexZ[t]=this.vertexY[t]*e+this.vertexZ[t]*i>>16,this.vertexY[t]=s}}translate(t,e,i){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ)for(let s=0;s>8;if(null!==this.faceColorA&&null!==this.faceColorB&&null!==this.faceColorC||(this.faceColorA=new Int32Array(this.faceCount),this.faceColorB=new Int32Array(this.faceCount),this.faceColorC=new Int32Array(this.faceCount)),null===this.vertexNormal){this.vertexNormal=new Array(this.vertexCount);for(let t=0;t8192||p>8192||w>8192||m<-8192||p<-8192||w<-8192;)m>>=1,p>>=1,w>>=1;let b=Math.sqrt(m*m+p*p+w*w);if(b<=0&&(b=1),m=256*m/b,p=256*p/b,w=256*w/b,null===this.faceInfo||0==(1&this.faceInfo[e])){let t=this.vertexNormal[a];t.x+=m,t.y+=p,t.z+=w,t.w++,t=this.vertexNormal[o],t.x+=m,t.y+=p,t.z+=w,t.w++,t=this.vertexNormal[l],t.x+=m,t.y+=p,t.z+=w,t.w++}else{const a=t+(i*m+s*p+r*w)/(n+n/2);this.faceColorA[e]=I.mulColorLightness(this.faceColor[e],a,this.faceInfo[e])}}if(a)this.applyLighting(t,e,i,s,r);else{this.vertexNormalOriginal=new Array(this.vertexCount);for(let t=0;t>16;for(let s=0;s>16,b=b*d-w*f>>16,w=p),0!==t&&(p=b*l-y*o>>16,y=b*o+y*l>>16,b=p),0!==e&&(p=y*h+w*c>>16,y=y*c-w*h>>16,w=p),w+=r,b+=a,y+=n,p=b*g-y*u>>16,y=b*u+y*g>>16,b=p,I.vertexScreenX[s]=T.centerX+(w<<9)/y,I.vertexScreenY[s]=T.centerY+(b<<9)/y,I.vertexScreenZ[s]=y-m,this.texturedFaceCount>0&&(I.vertexViewSpaceX[s]=w,I.vertexViewSpaceY[s]=b,I.vertexViewSpaceZ[s]=y)}this.draw2(!1,!1,0)}draw(t,e,i,s,r,a,n,o,l){}draw2(t,e,i){if(null===I.vertexScreenX||null===I.vertexScreenY||null===I.vertexScreenZ)return;if(null===I.vertexViewSpaceX||null===I.vertexViewSpaceY||null===I.vertexViewSpaceZ)return;if(null===I.faceNearClipped||null===I.faceClippedX)return;if(null===I.tmpDepthFaceCount||null===I.tmpDepthFaces||null===I.tmpPriorityFaces||null===I.tmpPriorityFaceCount||null===I.tmpPriorityDepthSum||null===I.tmpPriority10FaceDepth||null===I.tmpPriority11FaceDepth)return;if(null===this.faceVertexA||null===this.faceVertexB||null===this.faceVertexC)return;for(let t=0;tl.boundX||h>l.boundX||c>l.boundX;const u=Math.trunc((I.vertexScreenZ[r]+I.vertexScreenZ[a]+I.vertexScreenZ[n])/3+this.minDepth);I.tmpDepthFaces[u][I.tmpDepthFaceCount[u]++]=s}else{I.faceNearClipped[s]=!0;const t=Math.trunc((I.vertexScreenZ[r]+I.vertexScreenZ[a]+I.vertexScreenZ[n])/3+this.minDepth);I.tmpDepthFaces[t][I.tmpDepthFaceCount[t]++]=s}}if(null==this.facePriority){for(let t=this.maxDepth-1;t>=0;t--){const e=I.tmpDepthFaceCount[t];if(e<=0)continue;const i=I.tmpDepthFaces[t];for(let t=0;t=0;t--){const e=I.tmpDepthFaceCount[t];if(e>0){const i=I.tmpDepthFaces[t];for(let s=0;s0||I.tmpPriorityFaceCount[2]>0)&&(s=Math.trunc((I.tmpPriorityDepthSum[1]+I.tmpPriorityDepthSum[2])/(I.tmpPriorityFaceCount[1]+I.tmpPriorityFaceCount[2])));let r=0;(I.tmpPriorityFaceCount[3]>0||I.tmpPriorityFaceCount[4]>0)&&(r=Math.trunc((I.tmpPriorityDepthSum[3]+I.tmpPriorityDepthSum[4])/(I.tmpPriorityFaceCount[3]+I.tmpPriorityFaceCount[4])));let a=0;(I.tmpPriorityFaceCount[6]>0||I.tmpPriorityFaceCount[8]>0)&&(a=Math.trunc((I.tmpPriorityDepthSum[6]+I.tmpPriorityDepthSum[8])/(I.tmpPriorityFaceCount[6]+I.tmpPriorityFaceCount[8])));let n,o=0,h=I.tmpPriorityFaceCount[10],c=I.tmpPriorityFaces[10],f=I.tmpPriority10FaceDepth;o==h&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=os;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=or;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=oa;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=oa&&e>n&&e>o||t{const r=new e(t.read("data"));let a=-1;for(r.pos+=2;r.pos0){e.scriptComparator=new Uint8Array(n).fill(0),e.scriptOperand=new Uint16Array(n).fill(0);for(let t=0;t0){e.scripts=new Array(o).fill(null);for(let t=0;t0){const r=s.lastIndexOf(",");e.inventorySlotImage[t]=w.fromArchive(i,s,r)}}for(let t=0;t<5;t++)e.inventoryOptions[t]=r.gjstr,0===e.inventoryOptions[t]?.length&&(e.inventoryOptions[t]=null);e.spellAction=r.gjstr,e.spellName=r.gjstr,e.spellFlags=r.g2;break;case _.TYPE_RECT:e.fill=1===r.g1,e.color=r.g4,e.activeColor=r.g4,e.hoverColor=r.g4;break;case _.TYPE_TEXT:e.center=1===r.g1,e.font=s[r.g1],e.shadow=1===r.g1,e.text=r.gjstr,e.activeText=r.gjstr,e.color=r.g4,e.activeColor=r.g4,e.hoverColor=r.g4;break;case _.TYPE_SPRITE:{const t=r.gjstr;if(t.length>0){const s=t.lastIndexOf(",");e.image=w.fromArchive(i,t.substring(0,s),parseInt(t.substring(s+1)))}const s=r.gjstr;if(s.length>0){const t=s.lastIndexOf(",");e.image=w.fromArchive(i,s.substring(0,t),parseInt(s.substring(t+1)))}break}case _.TYPE_MODEL:{const t=r.g1;0!==t&&(e.model=this.getModel((t-1<<8)+r.g1));const i=r.g1;0!==i&&(e.activeModel=this.getModel((i-1<<8)+r.g1)),e.seqId=r.g1,0==e.seqId?e.seqId=-1:e.seqId=(e.seqId-1<<8)+r.g1,e.activeSeqId=r.g1,0==e.activeSeqId?e.activeSeqId=-1:e.activeSeqId=(e.activeSeqId-1<<8)+r.g1,e.modelZoom=r.g2,e.modelPitch=r.g2,e.modelYaw=r.g2;break}case _.TYPE_INVENTORY_TEXT:e.inventorySlotObjId=new Int32Array(e.width*e.height),e.inventorySlotObjCount=new Int32Array(e.width*e.height),e.center=1===r.g1,e.font=s[r.g1],e.shadow=1===r.g1,e.color=r.g4,e.inventoryMarginX=r.g2b,e.inventoryMarginY=r.g2b,e.inventoryInteractable=1===r.g1,e.inventoryOptions=new Array(5).fill(null);for(let t=0;t<5;t++)e.inventoryOptions[t]=r.gjstr}2!=e.optionType&&2!=e.type||(e.spellAction=r.gjstr,e.spellName=r.gjstr,e.spellFlags=r.g2),1!=e.optionType&&4!=e.optionType&&5!=e.optionType&&6!=e.optionType||(e.option=r.gjstr,0==e.option.length&&(1==e.optionType?e.option="Ok":4==e.optionType||5==e.optionType?e.option="Select":6==e.optionType&&(e.option="Continue")))}};static get=t=>_.instances[t];static getModel=t=>new I(t);id=-1;parentId=-1;type=-1;optionType=-1;contentType=0;width=0;height=0;delegateHover=-1;scriptComparator=null;scriptOperand=null;scripts=null;scrollableHeight=0;hide=!1;inventoryDraggable=!1;inventoryInteractable=!1;inventoryUsable=!1;inventoryMarginX=0;inventoryMarginY=0;inventorySlotOffsetX=null;inventorySlotOffsetY=null;inventorySlotImage=null;inventoryOptions=[];fill=!1;center=!1;font=null;shadow=!1;text=null;activeText=null;color=0;activeColor=0;hoverColor=0;image=null;activeImage=null;model=null;activeModel=null;seqId=-1;activeSeqId=-1;modelZoom=0;modelPitch=0;modelYaw=0;spellAction=null;spellName=null;spellFlags=-1;option=null;childId=null;childX=null;childY=null;x=0;y=0;scrollPosition=0;inventorySlotObjId=null;inventorySlotObjCount=null;seqFrame=0;getModel=(t,e,i)=>{let s=this.model;return i&&(s=this.activeModel),null==s?null:-1==t&&-1==e&&null==s.faceColor?s:null}}class O{canvas;ctx;image;pixels;width;height;constructor(t,e,i){const s=t.getContext("2d");if(!s)throw new Error("Canvas 2d not found!!!!!!!!");this.canvas=t,this.ctx=s,this.image=s.getImageData(0,0,e,i),this.pixels=new Int32Array(e*i),this.width=e,this.height=i,this.bind()}clear=()=>{this.pixels.fill(0)};bind=()=>{l.bind(this.pixels,this.width,this.height)};draw=(t,e)=>{this.#t(),this.ctx.putImageData(this.image,t,e)};#t=()=>{const t=this.image.data;for(let e=0;e>16&255,t[s+1]=i>>8&255,t[s+2]=i>>0&255,t[s+3]=255}}}class P{static CHARSET=[];static{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";for(let e=0;e<256;e++){let i=t.indexOf(String.fromCharCode(e));-1===i&&(i=74),P.CHARSET[e]=i}}pixels=[];charWidth=[];charHeight=[];clipX=[];clipY=[];charSpace=[];drawWidth=[];fontHeight=-1;static fromArchive=(t,i)=>{const s=new e(t.read(i+".dat")),r=new e(t.read("index.dat"));r.pos=s.g2+4;const a=r.g1;a>0&&(r.pos+=3*(a-1));const n=new P;for(let t=0;t<94;t++){n.clipX[t]=r.g1,n.clipY[t]=r.g1;const e=n.charWidth[t]=r.g2,i=n.charHeight[t]=r.g2,a=e*i;n.pixels[t]=new Uint8Array(a);const o=r.g1;if(0===o)for(let r=0;rn.fontHeight&&(n.fontHeight=i),n.clipX[t]=1,n.charSpace[t]=e+2;{let s=0;for(let r=i/7;r{t|=0,e|=0;const r=i.length;e-=this.fontHeight;for(let a=0;a{t|=0,e|=0;const a=i.length;e-=this.fontHeight;for(let n=0;n{const e=t.length;let i=0;for(let s=0;s{const r=e-this.fontHeight;for(let e=0;e{this.drawStringTaggable(t-this.stringWidth(i)/2,e,i,s,r)};drawStringCenter=(t,e,i,s)=>{this.draw(t-this.stringWidth(i)/2,e,i,s)};drawRight=(t,e,i,s,r=!0)=>{r&&this.draw(t-this.stringWidth(i)+1,e+1,i,0),this.draw(t-this.stringWidth(i),e,i,s)};drawChar=(t,e,i,s,r,a)=>{s|=0,r|=0;let n=(e|=0)+(i|=0)*l.width,o=l.width-s,h=0,c=0;if(i=l.bottom&&(r-=i+r+1-l.bottom),e=l.right){const t=e+s+1-l.right;s-=t,h+=t,o+=t}s>0&&r>0&&this.drawMask(s,r,t,c,h,l.pixels,n,o,a)};drawMask=(t,e,i,s,r,a,n,o,l)=>{const h=-((t|=0)>>2);t=-(3&t);for(let c=-(e|=0);c<0;c++){for(let t=h;t<0;t++)0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l;for(let e=t;e<0;e++)0==i[s++]?n++:a[n++]=l;n+=o,s+=r}};copyCharacter=(t,e,i,s,r,a)=>{i|=0,s|=0;let n=(t|=0)+(e|=0)*l.width,o=0,h=l.width-i,c=0;if(el.bottom&&(s-=e+s+1-l.bottom),tl.right){const e=t+i+1-l.right;i-=e,c+=e,h+=e}i>0&&s>0&&this.copyImageMasked(i,s,r,o,c,l.pixels,n,h,a)};copyImageMasked=(t,e,i,s,r,a,n,o,l)=>{for(let h=0;h{switch(t){case"red":return 16711680;case"gre":return 65280;case"blu":return 255;case"yel":return 16776960;case"cya":return 65535;case"mag":return 16711935;case"whi":return 16777215;case"bla":default:return 0;case"lre":return 16748608;case"dre":return 8388608;case"dbl":return 128;case"or1":return 16756736;case"or2":return 16740352;case"or3":return 16723968;case"gr1":return 12648192;case"gr2":return 8453888;case"gr3":return 4259584}}}class M{static loadUrl=async t=>new M(await g(t));static genHash=t=>{let e=0;t=t.toUpperCase();for(let i=0;i>>0;return e};buffer;compressedWhole;fileCount;fileHash;fileSizeInflated;fileSizeDeflated;fileOffset;constructor(t){const i=new e(t),s=i.g3;let r;if(s==i.g3)r=i,this.compressedWhole=!1;else{const t=i.gdata(i.pos,s);r=new e(new Uint8Array(m(t))),this.compressedWhole=!0}this.buffer=r,this.fileCount=r.g2,this.fileHash=[],this.fileSizeInflated=[],this.fileSizeDeflated=[],this.fileOffset=[];let a=r.pos+10*this.fileCount;for(let t=0;t{const e=M.genHash(t),i=this.fileHash.indexOf(e);return-1==i?null:this.readIndex(i)};readIndex=t=>{if(t<0||t>=this.fileCount)return null;if(this.compressedWhole)return this.buffer.gdata(this.fileOffset[t],this.fileOffset[t]+this.fileSizeDeflated[t]);{const e=this.buffer.gdata(this.fileOffset[t],this.fileOffset[t]+this.fileSizeDeflated[t]);return m(e)}}}class E{static PERIOD=new Uint16Array(["d","o","t"].join("").split("").map((t=>t.charCodeAt(0))));static AMPERSAT=new Uint16Array(["(","a",")"].join("").split("").map((t=>t.charCodeAt(0))));static SLASH=new Uint16Array(["s","l","a","s","h"].join("").split("").map((t=>t.charCodeAt(0))));static whitelist=["cook","cook's","cooks","seeks","sheet"];static tlds=[];static tldTypes=[];static bads=[];static badCombinations=[];static domains=[];static fragments=[];static unpack=t=>{const i=new e(t.read("fragmentsenc.txt")),s=new e(t.read("badenc.txt")),r=new e(t.read("domainenc.txt")),a=new e(t.read("tldlist.txt"));this.read(s,r,i,a)};static filter=t=>{const e=[...t];this.format(e);const i=e.join("").trim(),s=i.toLowerCase(),r=[...s];this.filterTlds(r),this.filterBadWords(r),this.filterDomains(r),this.filterFragments(r);for(let t=0;t{this.readBadWords(t),this.readDomains(e),this.readFragments(i),this.readTld(s)};static readTld=t=>{const e=t.g4;for(let i=0;it.g1))};static readBadWords=t=>{const e=t.g4;for(let i=0;it.g1));const e=new Array(t.g1).fill([]).map((()=>[t.g1b,t.g1b]));e.length>0&&(this.badCombinations[i]=e)}};static readDomains=t=>{const e=t.g4;for(let i=0;it.g1))};static readFragments=t=>{const e=t.g4;for(let i=0;i{const e=[...t],i=[...t];this.filterBadCombinations(null,e,this.PERIOD),this.filterBadCombinations(null,i,this.SLASH);for(let s=0;s{for(let e=0;e<2;e++)for(let e=this.bads.length-1;e>=0;e--)this.filterBadCombinations(this.badCombinations[e],t,this.bads[e])};static filterDomains=t=>{const e=[...t],i=[...t];this.filterBadCombinations(null,e,this.AMPERSAT),this.filterBadCombinations(null,i,this.PERIOD);for(let s=this.domains.length-1;s>=0;s--)this.filterDomain(i,e,this.domains[s],t)};static filterFragments=t=>{for(let e=0;e=0&&r{if(this.isNumericalChars(t))return!0;const e=this.getInteger(t),i=this.fragments,s=i.length;if(e===i[0]||e===i[s-1])return!0;let r=0,a=s-1;for(;r<=a;){const t=Math.floor((r+a)/2);if(e===i[t])return!0;e{if(t.length>6)return 0;let e=0;for(let i=0;i{for(let i=e;i=0;i++)if(this.isNumerical(t[i]))return i;return-1};static indexOfNonNumber=(t,e)=>{for(let i=t;i=0;i++)if(!this.isNumerical(e[i]))return i;return e.length};static getEmulatedDomainCharLen=(t,e,i)=>e==i||"o"==e&&"0"==i?1:"o"==e&&"("==i&&")"==t?2:"c"!=e||"("!=i&&"<"!=i&&"["!=i?"e"==e&&"€"==i||"s"==e&&"$"==i||"l"==e&&"i"==i?1:0:1;static filterDomain=(t,e,i,s)=>{const r=i.length,a=s.length;for(let n=0;n<=a-r;n++){const{matched:r,currentIndex:a}=this.findMatchingDomain(n,i,s);if(!r)continue;const o=this.prefixSymbolStatus(n,s,3,e,["@"]),l=this.suffixSymbolStatus(a-1,s,3,t,[".",","]);(o>2||l>2)&&this.maskChars(n,a,s)}};static findMatchingDomain=(t,e,i)=>{const s=e.length;let r=t,a=0;for(;r0)r+=l,a++;else{if(0===a)break;const i=this.getEmulatedDomainCharLen(o,String.fromCharCode(e[a-1]),n);if(i>0)r+=i,1===a&&t++;else{if(a>=s||!this.isSymbol(n))break;r++}}}return{matched:a>=s,currentIndex:r}};static filterBadCombinations=(t,e,i)=>{if(!(i.length>e.length))for(let s=0;s<=e.length-i.length;s++){let r=s;const{currentIndex:a,badIndex:n,hasSymbol:o,hasNumber:l,hasDigit:h}=this.processBadCharacters(e,i,r);r=a;let c=e[r],f=r+1=i.length)||l&&h)continue;let d,u=!0;if(o){let t=!1,i=!1;if((s-1<0||this.isSymbol(e[s-1])&&"'"!=e[s-1])&&(t=!0),(r>=e.length||this.isSymbol(e[r])&&"'"!=e[r])&&(i=!0),!t||!i){let i=!1;for(d=s-2,t&&(d=s);!i&&d=0&&(!this.isSymbol(e[d])||"'"==e[d])){const t=[];let s;for(s=0;s<3&&d+s=0&&(!this.isSymbol(e[d-1])||"'"==e[d-1])&&(r=!1),r&&!this.isBadFragment(t)&&(i=!0)}d++}i||(u=!1)}}else{c=" ",s-1>=0&&(c=e[s-1]),f=" ",r{let s=i,r=0,a=0,n=!1,o=!1,l=!1;for(;s=t.length||o&&l);){const h=t[s],c=s+10)1===f&&this.isNumerical(h)&&(o=!0),2===f&&(this.isNumerical(h)||this.isNumerical(c))&&(o=!0),s+=f,r++;else{if(0===r)break;let t;if((t=this.getEmulatedBadCharLen(c,String.fromCharCode(e[r-1]),h))>0)s+=t;else{if(r>=e.length||!this.isNotLowercaseAlpha(h))break;if(this.isSymbol(h)&&"'"!==h&&(n=!0),this.isNumerical(h)&&(l=!0),s++,a++,100*a/(s-i)>90)break}}}return{currentIndex:s,badIndex:r,hasSymbol:n,hasNumber:o,hasDigit:l}};static getEmulatedBadCharLen=(t,e,i)=>{if(e==i)return 1;if(e>="a"&&e<="m"){if("a"==e)return"4"!=i&&"@"!=i&&"^"!=i?"/"==i&&"\\"==t?2:0:1;if("b"==e)return"6"!=i&&"8"!=i?"1"==i&&"3"==t?2:0:1;if("c"==e)return"("!=i&&"<"!=i&&"{"!=i&&"["!=i?0:1;if("d"==e)return"["==i&&")"==t?2:0;if("e"==e)return"3"!=i&&"€"!=i?0:1;if("f"==e)return"p"==i&&"h"==t?2:"£"==i?1:0;if("g"==e)return"9"!=i&&"6"!=i?0:1;if("h"==e)return"#"==i?1:0;if("i"==e)return"y"!=i&&"l"!=i&&"j"!=i&&"1"!=i&&"!"!=i&&":"!=i&&";"!=i&&"|"!=i?0:1;if("j"==e)return 0;if("k"==e)return 0;if("l"==e)return"1"!=i&&"|"!=i&&"i"!=i?0:1;if("m"==e)return 0}if(e>="n"&&e<="z"){if("n"==e)return 0;if("o"==e)return"0"!=i&&"*"!=i?"("==i&&")"==t||"["==i&&"]"==t||"{"==i&&"}"==t||"<"==i&&">"==t?2:0:1;if("p"==e)return 0;if("q"==e)return 0;if("r"==e)return 0;if("s"==e)return"5"!=i&&"z"!=i&&"$"!=i&&"2"!=i?0:1;if("t"==e)return"7"!=i&&"+"!=i?0:1;if("u"==e)return"v"==i?1:"\\"==i&&"/"==t||"\\"==i&&"|"==t||"|"==i&&"/"==t?2:0;if("v"==e)return"\\"==i&&"/"==t||"\\"==i&&"|"==t||"|"==i&&"/"==t?2:0;if("w"==e)return"v"==i&&"v"==t?2:0;if("x"==e)return")"==i&&"("==t||"}"==i&&"{"==t||"]"==i&&"["==t||">"==i&&"<"==t?2:0;if("y"==e)return 0;if("z"==e)return 0}return e>="0"&&e<="9"?"0"==e?"o"==i||"O"==i?1:"("==i&&")"==t||"{"==i&&"}"==t||"["==i&&"]"==t?2:0:"1"==e&&"l"==i?1:0:","==e?"."==i?1:0:"."==e?","==i?1:0:"!"==e&&"i"==i?1:0};static comboMatches=(t,e,i)=>{let s=0,r=e.length-1;for(;s<=r;){const a=Math.floor((s+r)/2);if(e[a][0]===t&&e[a][1]===i)return!0;tthis.isLowercaseAlpha(t)?t.charCodeAt(0)+1-"a".charCodeAt(0):"'"==t?28:this.isNumerical(t)?t.charCodeAt(0)+29-"0".charCodeAt(0):27;static filterTld=(t,e,i,s,r)=>{if(!(s.length>i.length))for(let a=0;a<=i.length-s.length;a++){const{currentIndex:n,tldIndex:o}=this.processTlds(i,s,a);if(o0&&c>0&&(l=!0),2==e&&(h>2&&c>0||h>0&&c>2)&&(l=!0),3==e&&h>0&&c>2&&(l=!0),!l)continue;let f,d=a,u=n-1,g=!1;if(h>2){if(4==h)for(g=!1,f=a-1;f>=0;f--)if(g){if("*"!=r[f])break;d=f}else"*"==r[f]&&(d=f,g=!0);for(g=!1,f=d-1;f>=0;f--)if(g){if(this.isSymbol(i[f]))break;d=f}else this.isSymbol(i[f])||(g=!0,d=f)}if(c>2){if(4==c)for(g=!1,f=u+1;f{let s=0;for(;i0)i+=n,s++;else{if(0===s)break;let t;if((t=this.getEmulatedDomainCharLen(a,String.fromCharCode(e[s-1]),r))>0)i+=t;else{if(!this.isSymbol(r))break;i++}}}return{currentIndex:i,tldIndex:s}};static isSymbol=t=>!this.isAlpha(t)&&!this.isNumerical(t);static isNotLowercaseAlpha=t=>!this.isLowercaseAlpha(t)||"v"==t||"x"==t||"j"==t||"q"==t||"z"==t;static isAlpha=t=>this.isLowercaseAlpha(t)||this.isUppercaseAlpha(t);static isNumerical=t=>t>="0"&&t<="9";static isLowercaseAlpha=t=>t>="a"&&t<="z";static isUppercaseAlpha=t=>t>="A"&&t<="Z";static isNumericalChars=t=>{for(let e=0;e{for(let s=t;s{let i=0;for(let s=e-1;s>=0&&this.isSymbol(t[s]);s--)"*"===t[s]&&i++;return i};static maskedCountForwards=(t,e)=>{let i=0;for(let s=e+1;s(r?this.maskedCountBackwards(e,i):this.maskedCountForwards(e,i))>=s?4:this.isSymbol(r?t[i-1]:t[i+1])?1:0;static prefixSymbolStatus=(t,e,i,s,r)=>{if(0===t)return 2;for(let i=t-1;i>=0&&this.isSymbol(e[i]);i--)if(r.includes(e[i]))return 3;return this.maskedCharsStatus(e,s,t,i,!0)};static suffixSymbolStatus=(t,e,i,s,r)=>{if(t+1===e.length)return 2;for(let i=t+1;i{let e=0;for(let i=0;it>=" "&&t<=""||" "==t||"\n"==t||"\t"==t||"£"==t||"€"==t;static replaceUppercases=(t,e)=>{for(let i=0;i{let e=!0;for(let i=0;i{this.resizeToFit&&this.resize(window.innerWidth,window.innerHeight)}),!1),window.addEventListener("keydown",this.keyDown),window.addEventListener("keyup",this.keyUp),window.addEventListener("mousedown",this.mousePressed),this.canvas.oncontextmenu=t=>{t.preventDefault()},await this.showProgress(0,"Loading..."),await this.load();for(let t=0;t<10;t++)this.otim[t]=Date.now();let t,e=0,i=256,s=1,r=0;for(;this.state>=0;){if(this.state>0&&(this.state--,0===this.state))return void this.shutdown();const a=i,n=s;i=300,s=1,t=Date.now();const o=this.otim[e];if(0===o?(i=a,s=n):t>o&&(i=Math.trunc(2560*this.deltime/(t-o))),i<25?i=25:i>256&&(i=256,s=Math.trunc(this.deltime-(t-o)/10)),this.otim[e]=t,e=(e+1)%10,s>1)for(let t=0;t<10;t++)0!==this.otim[t]&&(this.otim[t]+=s);for(s0&&(this.fps=Math.trunc(1e3*i/(256*this.deltime)));const l=performance.now();await this.draw(),this.frameTime[this.fpos]=(performance.now()-l)/1e3,this.fpos=(this.fpos+1)%this.frameTime.length}-1==this.state&&this.shutdown()}shutdown(){this.state=-2,this.unload()}setLoopRate(t){this.deltime=1e3/t}start(){this.state>=0&&(this.state=0)}stop(){this.state>=0&&(this.state=4e3/this.deltime)}destroy(){this.state=-1}async load(){}update(){}unload(){}async draw(){}refresh(){}async showProgress(t,e){const i=this.ctx,s=this.width,r=this.height;this.redrawScreen&&(i.fillStyle="black",i.clearRect(0,0,s,r),this.redrawScreen=!1);const a=r/2-18;i.fillStyle="rgb(140, 17, 17)",i.rect(s/2-152,a,304,34),i.fillRect(s/2-150,a+2,3*t,30),i.fillStyle="black",i.fillRect(s/2-150+3*t,a+2,300-3*t,30),i.font="bold 13px helvetica, sans-serif",i.textAlign="center",i.fillStyle="white",i.fillText(e,s/2,a+22),await u(5)}keyDown=t=>{this.idleCycles=0;const e=t.keyCode;let i=t.key.charCodeAt(0);83!==i&&(i<30&&(i=0),37==e?i=1:39==e?i=2:38==e?i=3:40==e?i=4:17==e?i=5:8==e||127==e?i=8:9==e?i=9:10==e?i=10:e>=112&&e<=123?i=e+1008-112:36==e?i=1e3:35==e?i=1001:33==e?i=1002:34==e&&(i=1003),i>0&&i<128&&(this.actionKey[i]=1),i>4&&(this.keyQueue[this.keyQueueWritePos]=i,this.keyQueueWritePos=this.keyQueueWritePos+1&127))};keyUp=t=>{this.idleCycles=0;let e=t.key.charCodeAt(0);"ArrowLeft"==t.key?e=1:"ArrowRight"==t.key?e=2:"ArrowUp"==t.key?e=3:"ArrowDown"==t.key&&(e=4),this.actionKey[e]=0};pollKey(){let t=-1;return this.keyQueueWritePos!=this.keyQueueReadPos&&(t=this.keyQueue[this.keyQueueReadPos],this.keyQueueReadPos=this.keyQueueReadPos+1&127),t}mousePressed=t=>{let e=t.x,i=t.y;const{top:s,left:r}=this.getInsets;e-=r,i-=s,this.idleCycles=0,this.mouseClickX=e,this.mouseClickY=i,2===t.buttons?(this.mouseClickButton=2,this.mouseButton=2):1===t.buttons&&(this.mouseClickButton=1,this.mouseButton=1)};get getInsets(){const t=this.canvas.getBoundingClientRect(),e=window.getComputedStyle(this.canvas),i=parseFloat(e.paddingLeft||"0"),s=parseFloat(e.paddingTop||"0"),r=parseFloat(e.borderLeftWidth||"0"),a=parseFloat(e.borderTopWidth||"0"),n=t.left+r+i;return{top:t.top+a+s,left:n}}get ms(){const t=this.frameTime.length;let e=0;for(let i=0;i{Object.getOwnPropertyDescriptor(r.ready,t)||Object.defineProperty(r.ready,t,{get:()=>W("You are getting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>W("You are setting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}));var a=Object.assign({},r),n=[],o="object"==typeof window,l="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,c=!o&&!h&&!l;if(r.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var f,d,u,g="";if(h){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var m,p;g=l?require("path").dirname(g)+"/":__dirname+"/";var w=()=>{p||(m=require("fs"),p=require("path"))};f=(t,e)=>(w(),t=p.normalize(t),m.readFileSync(t,e?void 0:"utf8")),u=t=>{var e=f(t,!0);return e.buffer||(e=new Uint8Array(e)),L(e.buffer),e},d=(t,e,i)=>{w(),t=p.normalize(t),m.readFile(t,(function(t,s){t?i(t):e(s.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),n=process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof st))throw t})),process.on("unhandledRejection",(function(t){throw t})),r.inspect=function(){return"[Emscripten Module object]"}}else if(c){if("object"==typeof process&&"function"==typeof require||"object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");"undefined"!=typeof read&&(f=function(t){return read(t)}),u=function(t){let e;return"function"==typeof readbuffer?new Uint8Array(readbuffer(t)):(e=read(t,"binary"),L("object"==typeof e),e)},d=function(t,e,i){setTimeout((()=>e(u(t))),0)},"undefined"!=typeof scriptArgs?n=scriptArgs:void 0!==arguments&&(n=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else{if(!o&&!l)throw new Error("environment detection error");if(l?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),F&&(g=F),g=0!==g.indexOf("blob:")?g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):"","object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");f=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},l&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),d=(t,e,i)=>{var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?e(s.response):i()},s.onerror=i,s.send(null)}}r.print||console.log.bind(console);var b,y,v,x=r.printErr||console.warn.bind(console);function C(t,e){Object.getOwnPropertyDescriptor(r,t)||Object.defineProperty(r,t,{configurable:!0,get:function(){W("Module."+t+" has been replaced with plain "+e+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}function S(t){return"FS_createPath"===t||"FS_createDataFile"===t||"FS_createPreloadedFile"===t||"FS_unlink"===t||"addRunDependency"===t||"FS_createLazyFile"===t||"FS_createDevice"===t||"removeRunDependency"===t}Object.assign(r,a),a=null,b="fetchSettings",Object.getOwnPropertyDescriptor(r,b)&&W("`Module."+b+"` was supplied but `"+b+"` not included in INCOMING_MODULE_JS_API"),r.arguments&&(n=r.arguments),C("arguments","arguments_"),r.thisProgram&&r.thisProgram,C("thisProgram","thisProgram"),r.quit&&r.quit,C("quit","quit_"),L(void 0===r.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.read,"Module.read option was removed (modify read_ in JS)"),L(void 0===r.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),L(void 0===r.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),L(void 0===r.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),L(void 0===r.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),C("read","read_"),C("readAsync","readAsync"),C("readBinary","readBinary"),C("setWindowTitle","setWindowTitle"),L(!c,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."),r.wasmBinary&&(y=r.wasmBinary),C("wasmBinary","wasmBinary"),r.noExitRuntime,C("noExitRuntime","noExitRuntime"),"object"!=typeof WebAssembly&&W("no native wasm support detected");var T,A,k,I,_,O,P,M,E=!1;function L(t,e){t||W("Assertion failed"+(e?": "+e:""))}function B(t){T=t,r.HEAP8=A=new Int8Array(t),r.HEAP16=I=new Int16Array(t),r.HEAP32=_=new Int32Array(t),r.HEAPU8=k=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=O=new Uint32Array(t),r.HEAPF32=P=new Float32Array(t),r.HEAPF64=M=new Float64Array(t)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf8");var R=5242880;r.TOTAL_STACK&&L(R===r.TOTAL_STACK,"the stack size can no longer be determined at runtime");var Y=r.INITIAL_MEMORY||16777216;function D(){if(!E){var t=ct(),e=O[t>>2],i=O[t+4>>2];34821223==e&&2310721022==i||W("Stack overflow! Stack cookie has been overwritten at 0x"+t.toString(16)+", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+i.toString(16)+" 0x"+e.toString(16)),1668509029!==O[0]&&W("Runtime error: The application has corrupted its heap memory area (address zero)!")}}C("INITIAL_MEMORY","INITIAL_MEMORY"),L(Y>=R,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+Y+"! (TOTAL_STACK="+R+")"),L("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),L(!r.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),L(16777216==Y,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var t=new Int16Array(1),e=new Int8Array(t.buffer);if(t[0]=25459,115!==e[0]||99!==e[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var U=[],G=[],H=[],X=!1;L(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var N=0,z=null,V=null,j={};function W(t){r.onAbort&&r.onAbort(t),x(t="Aborted("+t+")"),E=!0;var e=new WebAssembly.RuntimeError(t);throw s(e),e}var q={error:function(){W("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init:function(){q.error()},createDataFile:function(){q.error()},createPreloadedFile:function(){q.error()},createLazyFile:function(){q.error()},open:function(){q.error()},mkdev:function(){q.error()},registerDevice:function(){q.error()},analyzePath:function(){q.error()},loadFilesFromDB:function(){q.error()},ErrnoError:function(){q.error()}};r.FS_createDataFile=q.createDataFile,r.FS_createPreloadedFile=q.createPreloadedFile;var Z,$,K,J;function Q(t){return t.startsWith("data:application/octet-stream;base64,")}function tt(t){return t.startsWith("file://")}function et(t,e){return function(){var i=t,s=e;return e||(s=r.asm),L(X,"native function `"+i+"` called before runtime initialization"),s[t]||L(s[t],"exported native function `"+i+"` not found"),s[t].apply(null,arguments)}}function it(t){try{if(t==Z&&y)return new Uint8Array(y);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){W(t)}}function st(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function rt(t){for(;t.length>0;)t.shift()(r)}function at(t){at.shown||(at.shown={}),at.shown[t]||(at.shown[t]=1,h&&(t="warning: "+t),x(t))}function nt(t){try{return v.grow(t-T.byteLength+65535>>>16),B(v.buffer),1}catch(e){x("emscripten_realloc_buffer: Attempted to grow heap from "+T.byteLength+" bytes to "+t+" bytes, but got error: "+e)}}r.locateFile?Q(Z="tinymidipcm.wasm")||($=Z,Z=r.locateFile?r.locateFile($,g):g+$):Z=new URL(i(621),i.b).toString();var ot,lt={emscripten_memcpy_big:function(t,e,i){k.copyWithin(t,e,e+i)},emscripten_resize_heap:function(t){var e=k.length;L((t>>>=0)>e);var i,s=2147483648;if(t>s)return x("Cannot enlarge memory, asked to go up to "+t+" bytes, but the limit is "+s+" bytes!"),!1;for(var r=1;r<=4;r*=2){var a=e*(1+.2/r);a=Math.min(a,t+100663296);var n=Math.min(s,(i=Math.max(t,a))+(65536-i%65536)%65536);if(nt(n))return!0}return x("Failed to grow the heap from "+e+" bytes to "+n+" bytes, not enough memory!"),!1}},ht=(function(){var t,e={env:lt,wasi_snapshot_preview1:lt};function i(t,e){var i,s=t.exports;r.asm=s,L(v=r.asm.memory,"memory not found in wasm exports"),B(v.buffer),L(r.asm.__indirect_function_table,"table not found in wasm exports"),i=r.asm.__wasm_call_ctors,G.unshift(i),function(t){if(N--,r.monitorRunDependencies&&r.monitorRunDependencies(N),t?(L(j[t]),delete j[t]):x("warning: run dependency removed without ID"),0==N&&(null!==z&&(clearInterval(z),z=null),V)){var e=V;V=null,e()}}("wasm-instantiate")}t="wasm-instantiate",N++,r.monitorRunDependencies&&r.monitorRunDependencies(N),t?(L(!j[t]),j[t]=1,null===z&&"undefined"!=typeof setInterval&&(z=setInterval((function(){if(E)return clearInterval(z),void(z=null);var t=!1;for(var e in j)t||(t=!0,x("still waiting on run dependencies:")),x("dependency: "+e);t&&x("(end of list)")}),1e4))):x("warning: run dependency added without ID");var a=r;function n(t){L(r===a,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),a=null,i(t.instance)}function c(t){return function(){if(!y&&(o||l)){if("function"==typeof fetch&&!tt(Z))return fetch(Z,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+Z+"'";return t.arrayBuffer()})).catch((function(){return it(Z)}));if(d)return new Promise((function(t,e){d(Z,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return it(Z)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),tt(Z)&&x("warning: Loading from a file URI ("+Z+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),W(t)}))}if(r.instantiateWasm)try{return r.instantiateWasm(e,i)}catch(t){x("Module.instantiateWasm callback failed with error: "+t),s(t)}(y||"function"!=typeof WebAssembly.instantiateStreaming||Q(Z)||tt(Z)||h||"function"!=typeof fetch?c(n):fetch(Z,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),c(n)}))}))).catch(s)}(),r.___wasm_call_ctors=et("__wasm_call_ctors"),r._malloc=et("malloc"),r._free=et("free"),r._tsf_load_memory=et("tsf_load_memory"),r._tsf_close=et("tsf_close"),r._tsf_reset=et("tsf_reset"),r._tsf_set_output=et("tsf_set_output"),r._tsf_set_max_voices=et("tsf_set_max_voices"),r._realloc=et("realloc"),r._tsf_channel_set_presetnumber=et("tsf_channel_set_presetnumber"),r._tsf_channel_set_bank_preset=et("tsf_channel_set_bank_preset"),r._tml_load_memory=et("tml_load_memory"),r._midi_render=et("midi_render"),r.___errno_location=et("__errno_location"),r._fflush=et("fflush"),r._emscripten_stack_init=function(){return(ht=r._emscripten_stack_init=r.asm.emscripten_stack_init).apply(null,arguments)}),ct=(r._emscripten_stack_get_free=function(){return(r._emscripten_stack_get_free=r.asm.emscripten_stack_get_free).apply(null,arguments)},r._emscripten_stack_get_base=function(){return(r._emscripten_stack_get_base=r.asm.emscripten_stack_get_base).apply(null,arguments)},r._emscripten_stack_get_end=function(){return(ct=r._emscripten_stack_get_end=r.asm.emscripten_stack_get_end).apply(null,arguments)});function ft(t){function i(){ot||(ot=!0,r.calledRun=!0,E||(L(!X),X=!0,D(),rt(G),e(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),L(!r._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(D(),r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)t=r.postRun.shift(),H.unshift(t);var t;rt(H)}()))}var s;t=t||n,N>0||(ht(),L(0==(3&(s=ct()))),O[s>>2]=34821223,O[s+4>>2]=2310721022,O[0]=1668509029,function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)t=r.preRun.shift(),U.unshift(t);var t;rt(U)}(),N>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),i()}),1)):i(),D()))}if(r.stackSave=et("stackSave"),r.stackRestore=et("stackRestore"),r.stackAlloc=et("stackAlloc"),r.setValue=function(t,e,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":case"i8":A[t>>0]=e;break;case"i16":I[t>>1]=e;break;case"i32":_[t>>2]=e;break;case"i64":J=[e>>>0,(K=e,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],_[t>>2]=J[0],_[t+4>>2]=J[1];break;case"float":P[t>>2]=e;break;case"double":M[t>>3]=e;break;case"*":O[t>>2]=e;break;default:W("invalid type for setValue: "+i)}},r.getValue=function(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":case"i8":return A[t>>0];case"i16":return I[t>>1];case"i32":case"i64":return _[t>>2];case"float":return P[t>>2];case"double":return M[t>>3];case"*":return O[t>>2];default:W("invalid type for getValue: "+e)}return null},["run","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createDataFile","FS_createPreloadedFile","FS_createLazyFile","FS_createLink","FS_createDevice","FS_unlink","getLEB","getFunctionTables","alignFunctionTables","registerFunctions","prettyPrint","getCompilerSetting","print","printErr","callMain","abort","keepRuntimeAlive","wasmMemory","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","ptrToString","zeroMemory","stringToNewUTF8","exitJS","getHeapMax","emscripten_realloc_buffer","ENV","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","getHostByName","Protocols","Sockets","getRandomDevice","warnOnce","traverseStack","UNWIND_CACHE","convertPCtoSourceLocation","readAsmConstArgsArray","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","freeTableIndexes","functionsInTableMap","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","PATH","PATH_FS","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeArrayToMemory","writeAsciiToMemory","SYSCALLS","getSocketFromFD","getSocketAddress","JSEvents","registerKeyEventCallback","specialHTMLTargets","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","currentFullscreenStrategy","restoreOldWindowedStyle","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","demangle","demangleAll","jsStackTrace","stackTrace","ExitStatus","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","dlopenMissingError","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","exception_addRef","exception_decRef","Browser","setMainLoop","wget","FS","MEMFS","TTY","PIPEFS","SOCKFS","_setNetworkCallback","tempFixedLengthArray","miniTempWebGLFloatBuffers","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","GL","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","AL","SDL_unicode","SDL_ttfContext","SDL_audio","SDL","SDL_gfx","GLUT","EGL","GLFW_Window","GLFW","GLEW","IDBStore","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(t){Object.getOwnPropertyDescriptor(r,t)||Object.defineProperty(r,t,{configurable:!0,get:function(){var e="'"+t+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";S(t)&&(e+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),W(e)}})})),["ptrToString","zeroMemory","stringToNewUTF8","exitJS","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getRandomDevice","traverseStack","convertPCtoSourceLocation","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeAsciiToMemory","getSocketFromFD","getSocketAddress","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","ExceptionInfo","exception_addRef","exception_decRef","setMainLoop","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","SDL_unicode","SDL_ttfContext","SDL_audio","GLFW_Window","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(t){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,t)||Object.defineProperty(globalThis,t,{configurable:!0,get:function(){var e="`"+t+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line";S(t)&&(e+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),at(e)}})})),V=function t(){ot||ft(),ot||(V=t)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return ft(),t.ready}),R=class{constructor(t={}){this.wasmModule=void 0,this.soundfontBufferPtr=0,this.soundfontPtr=0,this.midiBufferPtr=0,this.renderInterval=t.renderInterval||100,this.sampleRate=t.sampleRate||44100,this.channels=t.channels||2,this.gain=t.gain||0,t.bufferSize?this.bufferSize=t.bufferSize:this.setBufferDuration(1),this.onPCMData=t.onPCMData||(()=>{}),this.onRenderEnd=t.onRenderEnd||(()=>{}),this.renderTimer=void 0,this.test=0}async init(){if(!this.wasmModule){if("undefined"!=typeof process){const{dirname:t}=await import("path"),{createRequire:e}=await import("module");globalThis.__dirname=t("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js"),globalThis.require=e("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js")}this.wasmModule=await B(),this.pcmBufferPtr=this.wasmModule._malloc(this.bufferSize),this.msecsPtr=this.wasmModule._malloc(8)}}setBufferDuration(t){this.bufferSize=4*this.sampleRate*this.channels*t}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}setSoundfont(t){this.ensureInitialized();const{_malloc:e,_free:i,_tsf_load_memory:s,_tsf_set_output:r,_tsf_channel_set_bank_preset:a,_tsf_set_max_voices:n,_tsf_channel_set_presetnumber:o}=this.wasmModule;i(this.soundfontBufferPtr),this.soundfontBufferPtr=e(t.length),this.wasmModule.HEAPU8.set(t,this.soundfontBufferPtr),this.soundfontPtr=s(this.soundfontBufferPtr,t.length),r(this.soundfontPtr,2===this.channels?0:2,this.sampleRate,this.gain)}getPCMBuffer(){this.ensureInitialized();const t=new Uint8Array(this.bufferSize);return t.set(this.wasmModule.HEAPU8.subarray(this.pcmBufferPtr,this.pcmBufferPtr+this.bufferSize)),t}getMIDIMessagePtr(t){const{_malloc:e,_free:i,_tml_load_memory:s}=this.wasmModule;return i(this.midiBufferPtr),this.midiBufferPtr=e(t.length),this.wasmModule.HEAPU8.set(t,this.midiBufferPtr),s(this.midiBufferPtr,t.length)}renderMIDIMessage(t){const{_midi_render:e}=this.wasmModule;return e(this.soundfontPtr,t,this.channels,this.sampleRate,this.pcmBufferPtr,this.bufferSize,this.msecsPtr)}render(t){if(this.ensureInitialized(),!this.soundfontPtr)throw new Error("no soundfont buffer set. call .setSoundfont");window.clearTimeout(this.renderTimer);const{setValue:e,getValue:i}=this.wasmModule;e(this.msecsPtr,0,"double"),this.wasmModule._tsf_reset(this.soundfontPtr),this.wasmModule._tsf_channel_set_bank_preset(this.soundfontPtr,9,128,0),t[0]==="R".charCodeAt(0)&&(t=t.slice(20));let s=this.getMIDIMessagePtr(t);const r=()=>{s=this.renderMIDIMessage(s);const t=this.getPCMBuffer();this.onPCMData(t),s?this.renderTimer=setTimeout(r,this.renderInterval):this.onRenderEnd(i(this.msecsPtr,"double"))};this.renderTimer=setTimeout(r,16)}};!function(){window.AudioContext=window.AudioContext||window.webkitAudioContext,window.AudioContext&&(window.audioContext=new window.AudioContext);var t=function(e){if(window.audioContext){var i=window.audioContext.createBuffer(1,1,22050),s=window.audioContext.createBufferSource();s.buffer=i,s.connect(window.audioContext.destination),s.start?s.start(0):s.play?s.play(0):s.noteOn&&s.noteOn(0)}document.removeEventListener("touchstart",t),document.removeEventListener("touchend",t),document.removeEventListener("click",t)};document.addEventListener("touchstart",t),document.addEventListener("touchend",t),document.addEventListener("click",t)}(),(async()=>{let t=0,e=null,i=new Float32Array,s=window.audioContext.createGain();s.gain.value=.1,s.connect(window.audioContext.destination);let r=0,a=window.audioContext.currentTime,n=[];const o=new R({renderInterval:30,onPCMData:t=>{let e=new Float32Array(t.buffer),s=new Float32Array(i.length+e.length);s.set(i,0),s.set(e,i.length),i=s},onRenderEnd:e=>{t=Math.floor(r+Math.floor(e/1e3))},bufferSize:102400});await o.init();const l=await fetch("./SCC1_Florestan.sf2"),h=new Uint8Array(await l.arrayBuffer());function c(){if(!window.audioContext||!i.length)return;let r=window.audioContext.createBufferSource();r.onended=function(i){const s=Math.floor(window.audioContext.currentTime);t>0&&Math.abs(s-t)<=2&&(t=0,e&&window._tinyMidiPlay(e,-1))};const o=i.length/2,l=window.audioContext.createBuffer(2,o,44100);for(let t=0;t<2;t++){const e=l.getChannelData(t);let s=t;for(let t=0;t{if(f&&clearInterval(f),e=null,i=new Float32Array,n.length){let t=s.gain.value;s.gain.value=0,n.forEach((t=>{t.stop(window.audioContext.currentTime)})),n=[],s.gain.value=t}},window._tinyMidiVolume=(t=1)=>{s.gain.value=t},window._tinyMidiPlay=async(t,i=1)=>{t&&(await window._tinyMidiStop(),-1!=i&&window._tinyMidiVolume(i),e=t,r=window.audioContext.currentTime,a=window.audioContext.currentTime,f=setInterval(c,250),o.render(t))}})();class Y{static unpack=t=>{}}class D{static BASE37_LOOKUP=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];static toBase37=t=>{t=t.trim();let e=0n;for(let i=0;i=65&&s<=90?e+=BigInt(s+1-65):s>=97&&s<=122?e+=BigInt(s+1-97):s>=48&&s<=57&&(e+=BigInt(s+27-48))}return e};static fromBase37=t=>{if(t<0n||t>=6582952005840035281n)return"invalid_name";if(t%37n==0n)return"invalid_name";let e=0;const i=[0,0,0,0,0,0,0,0,0,0,0,0];for(;0n!=t;){const s=t;t/=37n,i[11-e++]=Number(this.BASE37_LOOKUP[Number(s-37n*t)])}return i.slice(12-e).join("")};static toSentenceCase=t=>{const e=[...t.toLowerCase()];let i=!0;for(let t=0;t="a"&&s<="z"&&(e[t]=s.toUpperCase(),i=!1),"."!==s&&"!"!==s||(i=!0)}return e.join("")};static toAsterisks=t=>{let e="";for(let i=0;i{if(0==t.length)return t;const e=[...t];for(let t=0;t="a"&&e[t+1]<="z"&&(e[t+1]=String.fromCharCode(e[t+1].charCodeAt(0)+"A".charCodeAt(0)-97)));return e[0]>="a"&&e[0]<="z"&&(e[0]=String.fromCharCode(e[0].charCodeAt(0)+"A".charCodeAt(0)-97)),e.join("")}}class U{static visibilityMatrix=[];static viewportLeft=0;static viewportTop=0;static viewportRight=0;static viewportBottom=0;static viewportCenterX=0;static viewportCenterY=0;static sinEyePitch=0;static cosEyePitch=0;static sinEyeYaw=0;static cosEyeYaw=0;static{this.visibilityMatrix=new Array(8);for(let t=0;t<8;t++){this.visibilityMatrix[t]=new Array(32);for(let e=0;e<32;e++){this.visibilityMatrix[t][e]=new Array(51);for(let i=0;i<51;i++)this.visibilityMatrix[t][e][i]=new Array(51).fill(!1)}}}static init=(t,e,i,s,r)=>{this.viewportLeft=0,this.viewportTop=0,this.viewportRight=t,this.viewportBottom=e,this.viewportCenterX=t/2,this.viewportCenterY=e/2;const a=new Array(9);for(let t=0;t<9;t++){a[t]=new Array(32);for(let e=0;e<32;e++){a[t][e]=new Array(53);for(let i=0;i<53;i++)a[t][e][i]=new Array(53).fill(!1)}}for(let t=128;t<=384;t+=32)for(let e=0;e<2048;e+=64){this.sinEyePitch=T.sin[t],this.cosEyePitch=T.cos[t],this.sinEyeYaw=T.sin[e],this.cosEyeYaw=T.cos[e];const n=(t-128)/32,o=e/64;for(let t=-26;t<=26;t++)for(let e=-26;e<=26;e++){const l=128*t,h=128*e;let c=!1;for(let t=-i;t<=s;t+=128)if(this.testPoint(l,h,r[n]+t)){c=!0;break}a[n][o][t+25+1][e+25+1]=c}}for(let t=0;t<8;t++)for(let e=0;e<32;e++)for(let i=-25;i<25;i++)for(let s=-25;s<25;s++){let r=!1;t:for(let n=-1;n<=1;n++)for(let o=-1;o<=1;o++){if(a[t][e][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t][(e+1)%31][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t+1][e][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t+1][(e+1)%31][i+n+25+1][s+o+25+1]){r=!0;break t}}this.visibilityMatrix[t][e][i+25][s+25]=r}};static testPoint=(t,e,i)=>{const s=e*this.sinEyeYaw+t*this.cosEyeYaw>>16,r=e*this.cosEyeYaw-t*this.sinEyeYaw>>16,a=i*this.sinEyePitch+r*this.cosEyePitch>>16,n=i*this.cosEyePitch-r*this.sinEyePitch>>16;if(a<50||a>3500)return!1;const o=this.viewportCenterX+(s<<9)/a,l=this.viewportCenterY+(n<<9)/a;return o>=this.viewportLeft&&o<=this.viewportRight&&l>=this.viewportTop&&l<=this.viewportBottom}}class G extends L{static HOST="https://w2.225.2004scape.org";static CHARSET="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";static MEMBERS=!0;static LOW_MEMORY=!1;SCROLLBAR_TRACK=2301979;SCROLLBAR_GRIP_FOREGROUND=5063219;SCROLLBAR_GRIP_HIGHLIGHT=7759444;SCROLLBAR_GRIP_LOWLIGHT=3353893;alreadyStarted=!1;errorStarted=!1;errorLoading=!1;errorHost=!1;loopCycle=0;ingame=!1;archiveChecksums=[];redrawTitleBackground=!0;titleScreenState=0;titleLoginField=0;titleArchive=null;imageTitle2=null;imageTitle3=null;imageTitle4=null;imageTitle0=null;imageTitle1=null;imageTitle5=null;imageTitle6=null;imageTitle7=null;imageTitle8=null;imageTitlebox=null;imageTitlebutton=null;loginMessage0="";loginMessage1="";username="";password="";fontPlain11=null;fontPlain12=null;fontBold12=null;fontQuill8=null;imageRunes=[];flameActive=!1;imageFlamesLeft=null;imageFlamesRight=null;flameBuffer1=[];flameBuffer0=[];flameBuffer3=[];flameBuffer2=[];flameGradient=[];flameGradient0=[];flameGradient1=[];flameGradient2=[];flameLineOffset=[];flameCycle0=0;flameGradientCycle0=0;flameGradientCycle1=0;flamesInterval=null;areaSidebar=null;areaMapback=null;areaViewport=null;areaChatback=null;areaBackbase1=null;areaBackbase2=null;areaBackhmid1=null;areaBackleft1=null;areaBackleft2=null;areaBackright1=null;areaBackright2=null;areaBacktop1=null;areaBacktop2=null;areaBackvmid1=null;areaBackvmid2=null;areaBackvmid3=null;areaBackhmid2=null;areaChatbackOffsets=null;areaSidebarOffsets=null;areaViewportOffsets=null;compassMaskLineOffsets=new Uint16Array(33);compassMaskLineLengths=new Uint16Array(33);minimapMaskLineOffsets=new Uint16Array(151);minimapMaskLineLengths=new Uint16Array(151);imageInvback=null;imageChatback=null;imageMapback=null;imageBackbase1=null;imageBackbase2=null;imageBackhmid1=null;imageSideicons=[];imageCompass=null;imageMapscene=[];imageMapfunction=[];imageHitmarks=[];imageHeadicons=[];imageMapflag=null;imageCrosses=[];imageMapdot0=null;imageMapdot1=null;imageMapdot2=null;imageMapdot3=null;imageScrollbar0=null;imageScrollbar1=null;imageRedstone1=null;imageRedstone2=null;imageRedstone3=null;imageRedstone1h=null;imageRedstone2h=null;imageRedstone1v=null;imageRedstone2v=null;imageRedstone3v=null;imageRedstone1hv=null;imageRedstone2hv=null;redrawSidebar=!1;redrawChatback=!1;redrawSideicons=!1;redrawPrivacySettings=!1;dragCycles=0;sceneState=0;sceneDelta=0;menuVisible=!1;menuArea=0;menuX=0;menuY=0;menuWidth=0;menuHeight=0;menuSize=0;menuOption=[];sidebarInterfaceId=-1;chatInterfaceId=-1;chatInterface=new _;chatScrollHeight=78;chatScrollOffset=0;modalMessage=null;flashingTab=-1;selectedTab=3;tabInterfaceId=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];publicChatSetting=0;privateChatSetting=0;tradeChatSetting=0;scrollGrabbed=!1;scrollInputPadding=0;showSocialInput=!1;socialMessage="";socialInput="";chatbackInput="";chatbackInputOpen=!1;stickyChatInterfaceId=-1;messageText=[];messageSender=[];messageType=[];splitPrivateChat=0;chatTyped="";viewportHoveredInterfaceIndex=0;sidebarHoveredInterfaceIndex=0;chatHoveredInterfaceIndex=0;objDragInterfaceId=0;objDragSlot=0;objDragArea=0;objGrabX=0;objGrabY=0;objDragCycles=0;selectedArea=0;selectedItem=0;selectedInterface=0;selectedCycle=0;pressedContinueOption=!1;runFlames=()=>{this.flameActive&&(this.updateFlames(),this.updateFlames(),this.drawFlames())};load=async()=>{if(this.alreadyStarted)this.errorStarted=!0;else{this.alreadyStarted=!0;try{await this.showProgress(10,"Connecting to fileserver");const t=new e(await g(`${G.HOST}/crc`));for(let e=0;e<9;e++)this.archiveChecksums[e]=t.g4;await this.setMidi("scape_main",12345678),this.titleArchive=await this.loadArchive("title","title screen",this.archiveChecksums[1],10),this.fontPlain11=P.fromArchive(this.titleArchive,"p11"),this.fontPlain12=P.fromArchive(this.titleArchive,"p12"),this.fontBold12=P.fromArchive(this.titleArchive,"b12"),this.fontQuill8=P.fromArchive(this.titleArchive,"q8"),await this.loadTitleBackground(),this.loadTitleImages();const i=await this.loadArchive("config","config",this.archiveChecksums[2],15),l=await this.loadArchive("interface","interface",this.archiveChecksums[3],20),h=await this.loadArchive("media","2d graphics",this.archiveChecksums[4],30),c=await this.loadArchive("models","3d graphics",this.archiveChecksums[5],40),f=await this.loadArchive("textures","textures",this.archiveChecksums[6],60),d=await this.loadArchive("wordenc","chat system",this.archiveChecksums[7],65),u=await this.loadArchive("sounds","sound effects",this.archiveChecksums[8],70);await this.showProgress(75,"Unpacking media"),this.imageInvback=S.fromArchive(h,"invback",0),this.imageChatback=S.fromArchive(h,"chatback",0),this.imageMapback=S.fromArchive(h,"mapback",0),this.imageBackbase1=S.fromArchive(h,"backbase1",0),this.imageBackbase2=S.fromArchive(h,"backbase2",0),this.imageBackhmid1=S.fromArchive(h,"backhmid1",0);for(let t=0;t<13;t++)this.imageSideicons[t]=S.fromArchive(h,"sideicons",t);this.imageCompass=w.fromArchive(h,"compass",0);try{for(let t=0;t<50;t++)this.imageMapscene[t]=S.fromArchive(h,"mapscene",t)}catch(t){}try{for(let t=0;t<50;t++)this.imageMapfunction[t]=w.fromArchive(h,"mapfunction",t)}catch(t){}try{for(let t=0;t<20;t++)this.imageHitmarks[t]=w.fromArchive(h,"hitmarks",t)}catch(t){}try{for(let t=0;t<20;t++)this.imageHeadicons[t]=w.fromArchive(h,"headicons",t)}catch(t){}this.imageMapflag=w.fromArchive(h,"mapflag",0);for(let t=0;t<8;t++)this.imageCrosses[t]=w.fromArchive(h,"cross",t);this.imageMapdot0=w.fromArchive(h,"mapdots",0),this.imageMapdot1=w.fromArchive(h,"mapdots",1),this.imageMapdot2=w.fromArchive(h,"mapdots",2),this.imageMapdot3=w.fromArchive(h,"mapdots",3),this.imageScrollbar0=S.fromArchive(h,"scrollbar",0),this.imageScrollbar1=S.fromArchive(h,"scrollbar",1),this.imageRedstone1=S.fromArchive(h,"redstone1",0),this.imageRedstone2=S.fromArchive(h,"redstone2",0),this.imageRedstone3=S.fromArchive(h,"redstone3",0),this.imageRedstone1h=S.fromArchive(h,"redstone1",0),this.imageRedstone1h?.flipHorizontally(),this.imageRedstone2h=S.fromArchive(h,"redstone2",0),this.imageRedstone2h?.flipHorizontally(),this.imageRedstone1v=S.fromArchive(h,"redstone1",0),this.imageRedstone1v?.flipVertically(),this.imageRedstone2v=S.fromArchive(h,"redstone2",0),this.imageRedstone2v?.flipVertically(),this.imageRedstone3v=S.fromArchive(h,"redstone3",0),this.imageRedstone3v?.flipVertically(),this.imageRedstone1hv=S.fromArchive(h,"redstone1",0),this.imageRedstone1hv?.flipHorizontally(),this.imageRedstone1hv?.flipVertically(),this.imageRedstone2hv=S.fromArchive(h,"redstone2",0),this.imageRedstone2hv?.flipHorizontally(),this.imageRedstone2hv?.flipVertically();const m=this.canvas,p=w.fromArchive(h,"backleft1",0);this.areaBackleft1=new O(m,p.width,p.height),p.blitOpaque(0,0);const A=w.fromArchive(h,"backleft2",0);this.areaBackleft2=new O(m,A.width,A.height),A.blitOpaque(0,0);const k=w.fromArchive(h,"backright1",0);this.areaBackright1=new O(m,k.width,k.height),k.blitOpaque(0,0);const M=w.fromArchive(h,"backright2",0);this.areaBackright2=new O(m,M.width,M.height),M.blitOpaque(0,0);const L=w.fromArchive(h,"backtop1",0);this.areaBacktop1=new O(m,L.width,L.height),L.blitOpaque(0,0);const F=w.fromArchive(h,"backtop2",0);this.areaBacktop2=new O(m,F.width,F.height),F.blitOpaque(0,0);const B=w.fromArchive(h,"backvmid1",0);this.areaBackvmid1=new O(m,B.width,B.height),B.blitOpaque(0,0);const R=w.fromArchive(h,"backvmid2",0);this.areaBackvmid2=new O(m,R.width,R.height),R.blitOpaque(0,0);const D=w.fromArchive(h,"backvmid3",0);this.areaBackvmid3=new O(m,D.width,D.height),D.blitOpaque(0,0);const H=w.fromArchive(h,"backhmid2",0);this.areaBackhmid2=new O(m,H.width,H.height),H.blitOpaque(0,0);const X=Math.trunc(21*Math.random())-10,N=Math.trunc(21*Math.random())-10,z=Math.trunc(21*Math.random())-10,V=Math.trunc(41*Math.random())-20;for(let t=0;t<50;t++)null!=this.imageMapfunction[t]&&this.imageMapfunction[t].translate(X+V,N+V,z+V),null!=this.imageMapscene[t]&&this.imageMapscene[t].translate(X+V,N+V,z+V);await this.showProgress(80,"Unpacking textures"),T.unpackTextures(f),T.setBrightness(.8),T.initPool(20),await this.showProgress(83,"Unpacking models"),I.unpack(c),s.unpack(c),r.unpack(c),await this.showProgress(86,"Unpacking config"),a.unpack(i),n.unpack(i),o.unpack(i),b.unpack(i,G.MEMBERS),y.unpack(i),v.unpack(i),x.unpack(i),C.unpack(i),G.LOW_MEMORY||(await this.showProgress(90,"Unpacking sounds"),Y.unpack(u)),await this.showProgress(92,"Unpacking interfaces"),_.unpack(l,h,[this.fontPlain11,this.fontPlain12,this.fontBold12,this.fontQuill8]),await this.showProgress(97,"Preparing game engine");for(let t=0;t<33;t++){let e=999,i=0;for(let s=0;s<35;s++)if(0==this.imageMapback.pixels[s+t*this.imageMapback.width])999==e&&(e=s);else if(999!=e){i=s;break}this.compassMaskLineOffsets[t]=e,this.compassMaskLineLengths[t]=i-e}for(let t=9;t<160;t++){let e=999,i=0;for(let s=10;s<168;s++)if(0==this.imageMapback.pixels[s+t*this.imageMapback.width]&&(s>34||t>34))999==e&&(e=s);else if(999!=e){i=s;break}this.minimapMaskLineOffsets[t-9]=e-21,this.minimapMaskLineLengths[t-9]=i-e}T.init3D(479,96),this.areaChatbackOffsets=T.lineOffset,T.init3D(190,261),this.areaSidebarOffsets=T.lineOffset,T.init3D(512,334),this.areaViewportOffsets=T.lineOffset;const j=new Int32Array(9);for(let t=0;t<9;t++){const e=32*t+128+15,i=3*e+600,s=T.sin[e];j[t]=i*s>>16}U.init(512,334,500,800,j),E.unpack(d)}catch(t){console.error(t),this.errorLoading=!0}}};update=()=>{this.errorStarted||this.errorLoading||this.errorHost||(this.loopCycle++,this.ingame?this.updateGame():this.updateTitleScreen())};draw=async()=>{this.errorStarted||this.errorLoading||this.errorHost?this.drawError():(this.ingame?this.drawGame():await this.drawTitleScreen(),this.dragCycles=0)};refresh=()=>{this.redrawTitleBackground=!0};showProgress=async(t,e)=>{console.log(`${t}%: ${e}`),await this.loadTitle(),this.titleArchive?(this.imageTitle4?.bind(),this.fontBold12?.drawStringCenter(180,54,"RuneScape is loading - please wait...",16777215),l.drawRect(28,62,304,34,9179409),l.drawRect(29,63,302,32,0),l.fillRect(30,64,3*t,30,9179409),l.fillRect(30+3*t,64,300-3*t,30,0),this.fontBold12?.drawStringCenter(180,85,e,16777215),this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.flameActive||(this.imageTitle0?.draw(0,0),this.imageTitle1?.draw(661,0)),this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186)),await u(5)):await super.showProgress(t,e)};loadTitle=async()=>{if(null===this.imageTitle2){this.drawArea=null,this.areaChatback=null,this.areaMapback=null,this.areaSidebar=null,this.areaViewport=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null;const t=this.canvas;this.imageTitle0=new O(t,128,265),l.clear(),this.imageTitle1=new O(t,128,265),l.clear(),this.imageTitle2=new O(t,533,186),l.clear(),this.imageTitle3=new O(t,360,146),l.clear(),this.imageTitle4=new O(t,360,200),l.clear(),this.imageTitle5=new O(t,214,267),l.clear(),this.imageTitle6=new O(t,215,267),l.clear(),this.imageTitle7=new O(t,86,79),l.clear(),this.imageTitle8=new O(t,87,79),l.clear(),null!==this.titleArchive&&(await this.loadTitleBackground(),this.loadTitleImages()),this.redrawTitleBackground=!0}};loadTitleBackground=async()=>{if(!this.titleArchive)return;const t=await w.fromJpeg(this.titleArchive,"title");this.imageTitle0?.bind(),t.blitOpaque(0,0),this.imageTitle1?.bind(),t.blitOpaque(-661,0),this.imageTitle2?.bind(),t.blitOpaque(-128,0),this.imageTitle3?.bind(),t.blitOpaque(-214,-386),this.imageTitle4?.bind(),t.blitOpaque(-214,-186),this.imageTitle5?.bind(),t.blitOpaque(0,-265),this.imageTitle6?.bind(),t.blitOpaque(-128,-186),this.imageTitle7?.bind(),t.blitOpaque(-128,-186),this.imageTitle8?.bind(),t.blitOpaque(-574,-186),t.flipHorizontally(),this.imageTitle0?.bind(),t.blitOpaque(394,0),this.imageTitle1?.bind(),t.blitOpaque(-267,0),this.imageTitle2?.bind(),t.blitOpaque(266,0),this.imageTitle3?.bind(),t.blitOpaque(180,-386),this.imageTitle4?.bind(),t.blitOpaque(180,-186),this.imageTitle5?.bind(),t.blitOpaque(394,-265),this.imageTitle6?.bind(),t.blitOpaque(-180,-265),this.imageTitle7?.bind(),t.blitOpaque(212,-186),this.imageTitle8?.bind(),t.blitOpaque(-180,-186);const e=w.fromArchive(this.titleArchive,"logo");this.imageTitle2?.bind(),e.draw(this.width/2-e.width/2-128,18)};updateFlameBuffer=t=>{for(let t=0;t<32768;t++)this.flameBuffer0[t]=0;for(let t=0;t<5e3;t++){const t=Math.trunc(128*Math.random()*256);this.flameBuffer0[t]=Math.trunc(256*Math.random())}for(let t=0;t<20;t++){for(let t=1;t{if(this.titleArchive){this.imageTitlebox=S.fromArchive(this.titleArchive,"titlebox"),this.imageTitlebutton=S.fromArchive(this.titleArchive,"titlebutton");for(let t=0;t<12;t++)this.imageRunes[t]=S.fromArchive(this.titleArchive,"runes",t);this.imageFlamesLeft=new w(128,265),this.imageFlamesRight=new w(128,265),this.imageTitle0&&p(this.imageTitle0.pixels,0,this.imageFlamesLeft.pixels,0,33920),this.imageTitle1&&p(this.imageTitle1.pixels,0,this.imageFlamesRight.pixels,0,33920),this.flameGradient0=[];for(let t=0;t<64;t++)this.flameGradient0[t]=262144*t;for(let t=0;t<64;t++)this.flameGradient0[t+64]=1024*t+16711680;for(let t=0;t<64;t++)this.flameGradient0[t+128]=4*t+16776960;for(let t=0;t<64;t++)this.flameGradient0[t+192]=16777215;this.flameGradient1=[];for(let t=0;t<64;t++)this.flameGradient1[t]=1024*t;for(let t=0;t<64;t++)this.flameGradient1[t+64]=4*t+65280;for(let t=0;t<64;t++)this.flameGradient1[t+128]=262144*t+65535;for(let t=0;t<64;t++)this.flameGradient1[t+192]=16777215;this.flameGradient2=[];for(let t=0;t<64;t++)this.flameGradient2[t]=4*t;for(let t=0;t<64;t++)this.flameGradient2[t+64]=262144*t+255;for(let t=0;t<64;t++)this.flameGradient2[t+128]=1024*t+16711935;for(let t=0;t<64;t++)this.flameGradient2[t+192]=16777215;this.flameGradient=[],this.flameBuffer0=[],this.flameBuffer1=[],this.updateFlameBuffer(null),this.flameBuffer3=[],this.flameBuffer2=[],this.showProgress(10,"Connecting to fileserver").then((()=>{this.flameActive||(this.flameActive=!0,this.flamesInterval=setInterval(this.runFlames,35))}))}};updateTitleScreen=()=>{if(0===this.titleScreenState){let t=this.width/2-80,e=this.height/2+20;e+=20,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.titleScreenState=3,this.titleLoginField=0),t=this.width/2+80,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.loginMessage0="",this.loginMessage1="Enter your username & password.",this.titleScreenState=2,this.titleLoginField=0)}else if(2==this.titleScreenState){let t=this.height/2-40;t+=30,t+=25,1==this.mouseClickButton&&this.mouseClickY>=t-15&&this.mouseClickY=t-15&&this.mouseClickY=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&this.login(this.username,this.password,!1).then((()=>{})),e=this.width/2+80,1==this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&(this.titleScreenState=0,this.username="",this.password="");;){const t=this.pollKey();if(-1==t)return;let e=!1;for(let i=0;i0&&(this.username=this.username.substring(0,this.username.length-1)),9!=t&&10!=t&&13!=t||(this.titleLoginField=1),e&&(this.username=this.username+String.fromCharCode(t)),this.username.length>12&&(this.username=this.username.substring(0,12))):1==this.titleLoginField&&(8==t&&this.password.length>0&&(this.password=this.password.substring(0,this.password.length-1)),9!=t&&10!=t&&13!=t||(this.titleLoginField=0),e&&(this.password=this.password+String.fromCharCode(t)),this.password.length>20&&(this.password=this.password.substring(0,20)))}}else if(3==this.titleScreenState){const t=this.width/2;let e=this.height/2+50;e+=20,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.titleScreenState=0)}};drawTitleScreen=async()=>{if(await this.loadTitle(),this.imageTitle4?.bind(),this.imageTitlebox?.draw(0,0),0===this.titleScreenState){let t=180,e=80;this.fontBold12?.drawStringTaggableCenter(t,e,"Welcome to RuneScape",4294967040,!0),t=100,e=120,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"New user",4294967295,!0),t=260,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Existing User",4294967295,!0)}else if(2===this.titleScreenState){let t=100,e=60;0===this.loginMessage0.length?(this.fontBold12?.drawStringTaggableCenter(180,e-15,this.loginMessage0,16776960,!0),this.fontBold12?.drawStringTaggableCenter(180,e,this.loginMessage1,16776960,!0),e+=30):(this.fontBold12?.drawStringTaggableCenter(180,e-7,this.loginMessage1,16776960,!0),e+=30),this.fontBold12?.drawStringTaggable(90,e,`Username: ${this.username}${0==this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,16777215,!0),e+=15,this.fontBold12?.drawStringTaggable(92,e,`Password: ${D.toAsterisks(this.password)}${1==this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,16777215,!0),e=150,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Login",16777215,!0),t=260,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Cancel",16777215,!0)}else if(3==this.titleScreenState){this.fontBold12?.drawStringTaggableCenter(180,16776960,"Create a free account",40,!0);const t=180;let e=65;this.fontBold12?.drawStringTaggableCenter(180,e,"To create a new account you need to",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"go back to the main RuneScape webpage",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"and choose the red 'create account'",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"button at the top right of that page.",16777215,!0),e=150,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Cancel",16777215,!0)}this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186))};login=async(t,e,i)=>{try{this.ingame=!0,this.prepareGameScreen()}catch(t){this.loginMessage0="",this.loginMessage1="Error connecting to server."}};updateGame=()=>{this.ingame&&(this.sceneDelta++,1!=this.mouseButton&&1!=this.mouseClickButton||this.dragCycles++)};drawGame=()=>{this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.areaBackleft1?.draw(0,11),this.areaBackleft2?.draw(0,375),this.areaBackright1?.draw(729,5),this.areaBackright2?.draw(752,231),this.areaBacktop1?.draw(0,0),this.areaBacktop2?.draw(561,0),this.areaBackvmid1?.draw(520,11),this.areaBackvmid2?.draw(520,231),this.areaBackvmid3?.draw(501,375),this.areaBackhmid2?.draw(0,345),this.redrawSidebar=!0,this.redrawChatback=!0,this.redrawSideicons=!0,this.redrawPrivacySettings=!0,2!=this.sceneState&&(this.areaViewport?.draw(8,11),this.areaMapback?.draw(561,5))),2==this.sceneState&&this.drawScene(),this.menuVisible&&1==this.menuArea&&(this.redrawSidebar=!0);let t=!1;if(-1!=this.sidebarInterfaceId&&(t=this.updateInterfaceAnimation(this.sidebarInterfaceId,this.sceneDelta),t&&(this.redrawSidebar=!0)),2==this.selectedArea&&(this.redrawSidebar=!0),2==this.objDragArea&&(this.redrawSidebar=!0),this.redrawSidebar&&(this.drawSidebar(),this.redrawSidebar=!1),-1==this.chatInterfaceId){this.chatInterface.scrollPosition=this.chatScrollHeight-this.chatScrollOffset-77,this.mouseX>453&&this.mouseX<565&&this.mouseY>350&&this.handleScrollInput(this.mouseX-22,this.mouseY-375,this.chatScrollHeight,77,!1,463,0,this.chatInterface);let t=this.chatScrollHeight-this.chatInterface.scrollPosition-77;t<0&&(t=0),t>this.chatScrollHeight-77&&(t=this.chatScrollHeight-77),this.chatScrollOffset!=t&&(this.chatScrollOffset=t,this.redrawChatback=!0)}-1!=this.chatInterfaceId&&(t=this.updateInterfaceAnimation(this.chatInterfaceId,this.sceneDelta),t&&(this.redrawChatback=!0)),3==this.selectedArea&&(this.redrawChatback=!0),3==this.objDragArea&&(this.redrawChatback=!0),null!=this.modalMessage&&(this.redrawChatback=!0),this.menuVisible&&2==this.menuArea&&(this.redrawChatback=!0),this.redrawChatback&&(this.drawChatback(),this.redrawChatback=!1),2==this.sceneState&&(this.drawMinimap(),this.areaMapback?.draw(561,5)),-1!=this.flashingTab&&(this.redrawSideicons=!0),this.redrawSideicons&&(this.redrawSideicons=!1,this.areaBackhmid1?.bind(),this.imageBackhmid1?.draw(0,0),-1==this.sidebarInterfaceId&&(-1!=this.tabInterfaceId[this.selectedTab]&&(0==this.selectedTab?this.imageRedstone1?.draw(29,30):1==this.selectedTab?this.imageRedstone2?.draw(59,29):2==this.selectedTab?this.imageRedstone2?.draw(87,29):3==this.selectedTab?this.imageRedstone3?.draw(115,29):4==this.selectedTab?this.imageRedstone2h?.draw(156,29):5==this.selectedTab?this.imageRedstone2h?.draw(184,29):6==this.selectedTab&&this.imageRedstone1h?.draw(212,30)),-1!=this.tabInterfaceId[0]&&(0!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[0].draw(35,34),-1!=this.tabInterfaceId[1]&&(1!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[1].draw(59,32),-1!=this.tabInterfaceId[2]&&(2!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[2].draw(86,32),-1!=this.tabInterfaceId[3]&&(3!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[3].draw(121,33),-1!=this.tabInterfaceId[4]&&(4!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[4].draw(157,34),-1!=this.tabInterfaceId[5]&&(5!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[5].draw(185,32),-1!=this.tabInterfaceId[6]&&(6!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[6].draw(212,34)),this.areaBackhmid1?.draw(520,165),this.areaBackbase2?.bind(),this.imageBackbase2?.draw(0,0),-1==this.sidebarInterfaceId&&(-1!=this.tabInterfaceId[this.selectedTab]&&(7==this.selectedTab?this.imageRedstone1v?.draw(49,0):8==this.selectedTab?this.imageRedstone2v?.draw(81,0):9==this.selectedTab?this.imageRedstone2v?.draw(108,0):10==this.selectedTab?this.imageRedstone3v?.draw(136,1):11==this.selectedTab?this.imageRedstone2hv?.draw(178,0):12==this.selectedTab?this.imageRedstone2hv?.draw(205,0):13==this.selectedTab&&this.imageRedstone1hv?.draw(233,0)),-1!=this.tabInterfaceId[8]&&(8!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[7].draw(80,2),-1!=this.tabInterfaceId[9]&&(9!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[8].draw(107,3),-1!=this.tabInterfaceId[10]&&(10!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[9].draw(142,4),-1!=this.tabInterfaceId[11]&&(11!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[10].draw(179,2),-1!=this.tabInterfaceId[12]&&(12!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[11].draw(206,2),-1!=this.tabInterfaceId[13]&&(13!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[12].draw(230,2)),this.areaBackbase2?.draw(501,492),this.areaViewport?.bind()),this.redrawPrivacySettings&&(this.redrawPrivacySettings=!1,this.areaBackbase1?.bind(),this.imageBackbase1?.draw(0,0),this.fontPlain12?.drawStringTaggableCenter(57,33,"Public chat",16777215,!0),0==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"On",65280,!0),1==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Friends",16776960,!0),2==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Off",16711680,!0),3==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Hide",65535,!0),this.fontPlain12?.drawStringTaggableCenter(186,33,"Private chat",16777215,!0),0==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"On",65280,!0),1==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Friends",16776960,!0),2==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Off",16711680,!0),this.fontPlain12?.drawStringTaggableCenter(326,33,"Trade/duel",16777215,!0),0==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"On",65280,!0),1==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Friends",16776960,!0),2==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Off",16711680,!0),this.fontPlain12?.drawStringTaggableCenter(462,38,"Report abuse",16777215,!0),this.areaBackbase1?.draw(0,471),this.areaViewport?.bind()),this.sceneDelta=0};drawScene=()=>{};drawSidebar=()=>{};drawChatback=()=>{if(this.areaChatback?.bind(),this.areaChatbackOffsets&&(T.lineOffset=this.areaChatbackOffsets),this.imageChatback?.draw(0,0),this.showSocialInput)this.fontBold12?.drawStringCenter(239,40,this.socialMessage,0),this.fontBold12?.drawStringCenter(239,60,this.socialInput+"*",128);else if(this.chatbackInputOpen)this.fontBold12?.drawStringCenter(239,40,"Enter amount:",0),this.fontBold12?.drawStringCenter(239,60,this.chatbackInput+"*",128);else if(null!=this.modalMessage)this.fontBold12?.drawStringCenter(239,40,this.modalMessage,0),this.fontBold12?.drawStringCenter(239,60,"Click to continue",128);else if(-1!=this.chatInterfaceId)this.drawInterface(_.instances[this.chatInterfaceId],0,0,0);else if(-1==this.stickyChatInterfaceId){const t=this.fontPlain12;let e=0;l.setBounds(77,463,0,0);for(let i=0;i<100;i++)if(null!=this.messageText[i]){const s=this.messageType[i],r=this.chatScrollOffset+70-14*e;0===s&&(r>0&&r<110&&t?.drawString(4,r,this.messageText[i],0),e++),1===s&&(r>0&&r<110&&(t?.drawString(4,r,this.messageSender[i]+":",16777215),t?.drawString(t.stringWidth(this.messageSender[i])+12,r,this.messageText[i],255)),e++),2===s&&(0==this.publicChatSetting||1==this.publicChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&(t?.drawString(4,r,this.messageSender[i]+":",0),t?.drawString(t.stringWidth(this.messageSender[i])+12,r,this.messageText[i],255)),e++),3!==s&&7!==s||0!=this.splitPrivateChat||!(7==s||0==this.privateChatSetting||1==this.privateChatSetting&&this.isFriend(this.messageSender[i]))||(r>0&&r<110&&(t?.drawString(4,r,"From "+this.messageSender[i]+":",0),t?.drawString(t.stringWidth("From "+this.messageSender[i])+12,r,this.messageText[i],8388608)),e++),4===s&&(0==this.tradeChatSetting||1==this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&t?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],8388736),e++),5===s&&0==this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&t?.drawString(4,r,this.messageText[i],8388608),e++),6===s&&0==this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&(t?.drawString(4,r,"To "+this.messageSender[i]+":",0),t?.drawString(t.stringWidth("To "+this.messageSender[i])+12,r,this.messageText[i],8388608)),e++),8===s&&(0==this.tradeChatSetting||1==this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&t?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],13350793),e++)}l.resetBounds(),this.chatScrollHeight=14*e+7,this.chatScrollHeight<78&&(this.chatScrollHeight=78),this.drawScrollbar(463,0,this.chatScrollHeight-this.chatScrollOffset-77,this.chatScrollHeight,77),t?.drawString(4,90,D.formatName(this.username)+":",0),t?.drawString(t.stringWidth(this.username+": ")+6,90,this.chatTyped+"*",255),l.drawHorizontalLine(0,77,0,479)}else this.drawInterface(_.instances[this.stickyChatInterfaceId],0,0,0);this.menuVisible&&2==this.menuArea&&this.drawMenu(),this.areaChatback?.draw(22,375),this.areaViewport?.bind(),this.areaViewportOffsets&&(T.lineOffset=this.areaViewportOffsets)};drawScrollbar=(t,e,i,s,r)=>{this.imageScrollbar0?.draw(t,e),this.imageScrollbar1?.draw(t,e+r-16),l.fillRect(t,e+16,16,r-32,this.SCROLLBAR_TRACK);let a=(r-32)*r/s|0;a<8&&(a=8);const n=(r-a-32)*i/(s-r)|0;l.fillRect(t,e+n+16,16,a,this.SCROLLBAR_GRIP_FOREGROUND),l.drawVerticalLine(t,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,a),l.drawVerticalLine(t+1,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,a),l.drawHorizontalLine(t,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,16),l.drawHorizontalLine(t,e+n+17,this.SCROLLBAR_GRIP_HIGHLIGHT,16),l.drawVerticalLine(t+15,e+n+16,this.SCROLLBAR_GRIP_LOWLIGHT,a),l.drawVerticalLine(t+14,e+n+17,this.SCROLLBAR_GRIP_LOWLIGHT,a-1),l.drawHorizontalLine(t,e+n+a+15,this.SCROLLBAR_GRIP_LOWLIGHT,16),l.drawHorizontalLine(t+1,e+n+a+14,this.SCROLLBAR_GRIP_LOWLIGHT,15)};drawInterface=(t,e,i,s)=>{if(0!=t.type||null==t.childId||t.hide&&this.viewportHoveredInterfaceIndex!=t.id&&this.sidebarHoveredInterfaceIndex!=t.id&&this.chatHoveredInterfaceIndex!=t.id)return;const r=l.left,n=l.top,o=l.right,h=l.bottom;l.setBounds(i+t.height,e+t.width,i,e);const c=t.childId.length;for(let r=0;r0&&this.updateInterfaceContent(h),0==h.type)h.scrollPosition>h.scrollableHeight-h.height&&(h.scrollPosition=h.scrollableHeight-h.height),h.scrollPosition<0&&(h.scrollPosition=0),this.drawInterface(h,n,o,h.scrollPosition),h.scrollableHeight>h.height&&this.drawScrollbar(n+h.width,o,h.scrollPosition,h.scrollableHeight,h.height);else if(2==h.type){let t=0;for(let e=0;e0){let e=0,i=0;const a=h.inventorySlotObjId[t]-1;if(s>=-32&&s<=512&&r>=-32&&r<=334||0!=this.objDragArea&&this.objDragSlot==t){const n=b.getIcon(a,h.inventorySlotObjCount[t]);if(0!=this.objDragArea&&this.objDragSlot==t&&this.objDragInterfaceId==h.id?(e=this.mouseX-this.objGrabX,i=this.mouseY-this.objGrabY,e<5&&e>-5&&(e=0),i<5&&i>-5&&(i=0),this.objDragCycles<5&&(e=0,i=0),n.drawAlpha(128,s+e,r+i)):0!=this.selectedArea&&this.selectedItem==t&&this.selectedInterface==h.id?n.drawAlpha(128,s,r):n.draw(s,r),33==n.cropW||1!=h.inventorySlotObjCount[t]){const a=h.inventorySlotObjCount[t];this.fontPlain11?.drawString(s+e+1,r+10+i,this.formatObjCount(a),0),this.fontPlain11?.drawString(s+e,r+9+i,this.formatObjCount(a),16776960)}}}else if(null!=h.inventorySlotImage&&t<20){const e=h.inventorySlotImage[t];null!=e&&e.draw(s,r)}t++}}else if(3==h.type)h.fill?l.fillRect(n,o,h.color,h.width,h.height):l.drawRect(n,o,h.color,h.width,h.height);else if(4==h.type){const t=h.font;let e=h.color,i=h.text;if(this.chatHoveredInterfaceIndex!=h.id&&this.sidebarHoveredInterfaceIndex!=h.id&&this.viewportHoveredInterfaceIndex!=h.id||0==h.hoverColor||(e=h.hoverColor),this.executeInterfaceScript(h)&&(e=h.activeColor,h.activeText&&h.activeText.length>0&&(i=h.activeText)),6==h.optionType&&this.pressedContinueOption&&(i="Please wait...",e=h.color),!t||!i)continue;for(let s=o+t.fontHeight;i.length>0;s+=t.fontHeight){if(-1!=i.indexOf("%")){for(;;){const t=i.indexOf("%1");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,0))+i.substring(t+2)}for(;;){const t=i.indexOf("%2");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,1))+i.substring(t+2)}for(;;){const t=i.indexOf("%3");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,2))+i.substring(t+2)}for(;;){const t=i.indexOf("%4");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,3))+i.substring(t+2)}for(;;){const t=i.indexOf("%5");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,4))+i.substring(t+2)}}const r=i.indexOf("\\n");let a;-1!=r?(a=i.substring(0,r),i=i.substring(r+2)):(a=i,i=""),h.center?t.drawStringTaggableCenter(n+h.width/2,s,a,e,h.shadow):t.drawStringTaggable(n,s,a,e,h.shadow)}}else if(5==h.type){let t;t=this.executeInterfaceScript(h)?h.activeImage:h.image,null!=t&&t.draw(n,o)}else if(6==h.type){const t=T.centerX,e=T.centerY;T.centerX=n+h.width/2,T.centerY=o+h.height/2;const i=T.sin[h.modelPitch]*h.modelZoom>>16,s=T.cos[h.modelPitch]*h.modelZoom>>16,r=this.executeInterfaceScript(h);let l;l=r?h.activeSeqId:h.seqId;let c=null;if(-1==l)c=h.getModel(-1,-1,r);else{const t=a.instances[l];t.frames&&t.iframes&&(c=h.getModel(t.frames[h.seqFrame],t.iframes[h.seqFrame],r))}c&&c.drawSimple(0,h.modelYaw,0,h.modelPitch,0,i,s),T.centerX=t,T.centerY=e}else if(7==h.type){const t=h.font;if(!t||!h.inventorySlotObjId||!h.inventorySlotObjCount)continue;let e=0;for(let i=0;i0){const r=b.get(h.inventorySlotObjId[e]-1);let a=r.name;if((r.stackable||1!=h.inventorySlotObjCount[e])&&(a=a+" x"+this.formatObjCountTagged(h.inventorySlotObjCount[e])),!a)continue;const l=n+s*(h.inventoryMarginX+115),c=o+i*(h.inventoryMarginY+12);h.center?t.drawStringTaggableCenter(l+h.width/2,c,a,h.color,h.shadow):t.drawStringTaggable(l,c,a,h.color,h.shadow)}e++}}}l.setBounds(h,o,n,r)};drawMinimap=()=>{};drawMenu=()=>{const t=this.menuX,e=this.menuY,i=this.menuWidth,s=this.menuHeight,r=6116423;l.fillRect(t,e,i,s,r),l.fillRect(t+1,e+1,i-2,16,0),l.drawRect(t+1,e+18,i-2,s-19,0),this.fontBold12?.drawString(t+3,e+14,"Choose Option",r);let a=this.mouseX,n=this.mouseY;0==this.menuArea&&(a-=8,n-=11),1==this.menuArea&&(a-=562,n-=231),2==this.menuArea&&(a-=22,n-=375);for(let s=0;st&&ar-13&&n!1;handleScrollInput=(t,e,i,s,r,a,n,o)=>{if(this.scrollGrabbed?this.scrollInputPadding=32:this.scrollInputPadding=0,this.scrollGrabbed=!1,t>=a&&t=n&&e=a&&t=n+s-16&&e=a-this.scrollInputPadding&&t=n+16&&e0){let t=(s-32)*s/i;t<8&&(t=8);const a=e-n-t/2-16,l=s-t-32;o.scrollPosition=(i-s)*a/l,r&&(this.redrawSidebar=!0),this.scrollGrabbed=!0}};prepareGameScreen=()=>{if(null==this.areaChatback){this.unloadTitle(),this.drawArea=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null;const t=this.canvas;this.areaChatback=new O(t,479,96),this.areaMapback=new O(t,168,160),l.clear(),this.imageMapback?.draw(0,0),this.areaSidebar=new O(t,190,261),this.areaViewport=new O(t,512,334),l.clear(),this.areaBackbase1=new O(t,501,61),this.areaBackbase2=new O(t,288,40),this.areaBackhmid1=new O(t,269,66),this.redrawTitleBackground=!0}};isFriend=t=>!1;getIntString=t=>t<999999999?String(t):"*";formatObjCountTagged=t=>{let e=String(t);for(let t=e.length-3;t>0;t-=3)e=e.substring(0,t)+","+e.substring(t);return e.length>8?e="@gre@"+e.substring(0,e.length-8)+" million @whi@("+e+")":e.length>4&&(e="@cya@"+e.substring(0,e.length-4)+"K @whi@("+e+")")," "+e};formatObjCount=t=>t<1e5?String(t):t<1e7?Math.floor(t/1e3)+"K":Math.floor(t/1e6)+"M";executeClientscript1=(t,e)=>{if(null==t.scripts||e>=t.scripts.length)return-2;try{return-1}catch(t){return-1}};executeInterfaceScript=t=>{if(!t.scriptComparator||!t.scriptOperand)return!1;for(let e=0;e=s)return!1}else if(3==t.scriptComparator[e]){if(i<=s)return!1}else if(4==t.scriptComparator[e]){if(i==s)return!1}else if(i!=s)return!1}return!0};updateInterfaceContent=t=>{};unloadTitle=()=>{this.flameActive=!1,this.flamesInterval&&(clearInterval(this.flamesInterval),this.flamesInterval=null),this.imageTitlebox=null,this.imageTitlebutton=null,this.imageRunes=[],this.flameGradient=[],this.flameGradient0=[],this.flameGradient1=[],this.flameGradient2=[],this.flameBuffer0=[],this.flameBuffer1=[],this.flameBuffer3=[],this.flameBuffer2=[],this.imageFlamesLeft=null,this.imageFlamesRight=null};loadArchive=async(t,e,i,s)=>{await this.showProgress(s,`Requesting ${e}`);const r=await M.loadUrl(`${G.HOST}/${t}${i}`);return await this.showProgress(s,`Loading ${e} - 100%`),r};setMidi=async(t,i)=>{const s=new e(await g(`${G.HOST}/${t.replaceAll(" ","_")}_${i}.mid`));var r;r=m(s.data,!0,!1),window._tinyMidiPlay&&window._tinyMidiPlay(r,.75)};drawError=()=>{if(this.ctx.fillStyle="black",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.setLoopRate(1),this.errorLoading){this.flameActive=!1,this.ctx.font="bold 16px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="yellow";let t=35;this.ctx.fillText("Sorry, an error has occured whilst loading RuneScape",30,t),t+=50,this.ctx.fillStyle="white",this.ctx.fillText("To fix this try the following (in order):",30,t),t+=50,this.ctx.font="bold 12px helvetica, sans-serif",this.ctx.fillText("1: Try closing ALL open web-browser windows, and reloading",30,t),t+=30,this.ctx.fillText("2: Try clearing your web-browsers cache from tools->internet options",30,t),t+=30,this.ctx.fillText("3: Try using a different game-world",30,t),t+=30,this.ctx.fillText("4: Try rebooting your computer",30,t),t+=30,this.ctx.fillText("5: Try selecting a different version of Java from the play-game menu",30,t)}if(this.errorHost&&(this.flameActive=!1,this.ctx.font="bold 20px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="white",this.ctx.fillText("Error - unable to load game!",50,50),this.ctx.fillText("To play RuneScape make sure you play from",50,100),this.ctx.fillText("https://2004scape.org",50,150)),this.errorStarted){this.flameActive=!1,this.ctx.font="bold 13px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="yellow";let t=35;this.ctx.fillText("Error a copy of RuneScape already appears to be loaded",30,t),t+=50,this.ctx.fillStyle="white",this.ctx.fillText("To fix this try the following (in order):",30,t),t+=50,this.ctx.font="bold 12px helvetica, sans-serif",this.ctx.fillText("1: Try closing ALL open web-browser windows, and reloading",30,t),t+=30,this.ctx.fillText("2: Try rebooting your computer, and reloading",30,t)}};updateFlames=()=>{for(let t=10;t<117;t++)Math.trunc(100*Math.random())<50&&(this.flameBuffer3[t+32512]=255);for(let t=0;t<100;t++){const t=Math.trunc(124*Math.random()+2)+(Math.trunc(128*Math.random()+128)<<7);this.flameBuffer3[t]=192}for(let t=1;t<255;t++)for(let e=1;e<127;e++){const i=e+(t<<7);this.flameBuffer2[i]=(this.flameBuffer3[i-1]+this.flameBuffer3[i+1]+this.flameBuffer3[i-128]+this.flameBuffer3[i+128])/4|0}if(this.flameCycle0+=128,this.flameCycle0>32768){this.flameCycle0-=32768;const t=Math.trunc(12*Math.random());this.updateFlameBuffer(this.imageRunes[t])}for(let t=1;t<255;t++)for(let e=1;e<127;e++){const i=e+(t<<7);let s=this.flameBuffer2[i+128]-this.flameBuffer0[i+this.flameCycle0&32767]/5|0;s<0&&(s=0),this.flameBuffer3[i]=s}for(let t=0;t<255;t++)this.flameLineOffset[t]=this.flameLineOffset[t+1];if(this.flameLineOffset[255]=16*Math.sin(this.loopCycle/14)+14*Math.sin(this.loopCycle/15)+12*Math.sin(this.loopCycle/16)|0,this.flameGradientCycle0>0&&(this.flameGradientCycle0-=4),this.flameGradientCycle1>0&&(this.flameGradientCycle1-=4),0==this.flameGradientCycle0&&0==this.flameGradientCycle1){const t=Math.trunc(2e3*Math.random());0==t?this.flameGradientCycle0=1024:1==t&&(this.flameGradientCycle1=1024)}};mix=(t,e,i)=>{const s=256-e;return((16711935&t)*s+(16711935&i)*e&4278255360)+((65280&t)*s+(65280&i)*e&16711680)>>8};drawFlames=()=>{const t=256;if(this.flameGradientCycle0>0)for(let t=0;t<256;t++)this.flameGradientCycle0>768?this.flameGradient[t]=this.mix(this.flameGradient0[t],1024-this.flameGradientCycle0,this.flameGradient1[t]):this.flameGradientCycle0>256?this.flameGradient[t]=this.flameGradient1[t]:this.flameGradient[t]=this.mix(this.flameGradient1[t],256-this.flameGradientCycle0,this.flameGradient0[t]);else if(this.flameGradientCycle1>0)for(let t=0;t<256;t++)this.flameGradientCycle1>768?this.flameGradient[t]=this.mix(this.flameGradient0[t],1024-this.flameGradientCycle1,this.flameGradient2[t]):this.flameGradientCycle1>256?this.flameGradient[t]=this.flameGradient2[t]:this.flameGradient[t]=this.mix(this.flameGradient2[t],256-this.flameGradientCycle1,this.flameGradient0[t]);else for(let t=0;t<256;t++)this.flameGradient[t]=this.flameGradient0[t];for(let t=0;t<33920;t++)this.imageTitle0&&this.imageFlamesLeft&&(this.imageTitle0.pixels[t]=this.imageFlamesLeft.pixels[t]);let e=0,i=1152;for(let s=1;s<255;s++){let r=22+(this.flameLineOffset[s]*(t-s)/t|0);r<0&&(r=0),e+=r;for(let t=r;t<128;t++){let t=0|this.flameBuffer3[e++];if(0==t)i++;else{const e=t,s=256-t;if(t=this.flameGradient[t],this.imageTitle0){const r=this.imageTitle0.pixels[i];this.imageTitle0.pixels[i++]=((16711935&t)*e+(16711935&r)*s&4278255360)+((65280&t)*e+(65280&r)*s&16711680)>>8}}}i+=r}this.imageTitle0?.draw(0,0);for(let t=0;t<33920;t++)this.imageTitle1&&this.imageFlamesRight&&(this.imageTitle1.pixels[t]=this.imageFlamesRight.pixels[t]);e=0,i=1176;for(let s=1;s<255;s++){const r=this.flameLineOffset[s]*(t-s)/t|0,a=103-r;i+=r;for(let t=0;t>8}}}e+=128-a,i+=128-a-r}this.imageTitle1?.draw(661,0)}}(new G).run().then((()=>{}))})()})(); \ No newline at end of file +(()=>{"use strict";var t={621:(t,e,i)=>{t.exports=i.p+"9f86b5397894e28b5ae2.wasm"}},e={};function i(s){var r=e[s];if(void 0!==r)return r.exports;var a=e[s]={exports:{}};return t[s](a,a.exports,i),a.exports}i.m=t,i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.p="/Client2/",i.b=document.baseURI||self.location.href,(()=>{class t{index;constructor(t){this.index=t}decodeType=t=>{for(;;){const e=t.g1;if(0===e)break;this.decode(e,t)}}}class e{static crctable=new Int32Array(256);static CRC32_POLYNOMIAL=3988292384;static bitmask=new Uint32Array(33);static{for(let t=0;t<32;t++)e.bitmask[t]=(1<>>1^e.CRC32_POLYNOMIAL:i>>>=1;e.crctable[t]=i}}data;pos;bitPos=0;constructor(t){if(!t)throw new Error("Input src packet array was null!");this.data=t,this.pos=0}static alloc=t=>new e(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):new Uint8Array(3e4));get g1(){return this.data[this.pos++]}get g1b(){return this.data[this.pos++]<<24>>24}get g2(){return(this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g2b(){return this.data[this.pos++]<<8|this.data[this.pos++]}get g3(){return(this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g4(){return(this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++])>>>0}get g4s(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g8(){return BigInt(this.g4)<<32n|BigInt(this.g4)}get gsmart(){return this.data[this.pos]<128?this.g1:this.g2-32768}get gsmarts(){return this.data[this.pos]<128?this.g1-64:this.g2-49152}get gjstr(){let t="";for(;10!=this.data[this.pos]&&this.posthis.data.subarray(t,t+e);p1=t=>{this.data[this.pos++]=t};p2=t=>{this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};ip2=t=>{this.data[this.pos++]=t,this.data[this.pos++]=t>>>8};p3=t=>{this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};p4=t=>{this.data[this.pos++]=t>>>24,this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t};ip4=t=>{this.data[this.pos++]=t,this.data[this.pos++]=t>>>8,this.data[this.pos++]=t>>>16,this.data[this.pos++]=t>>>24};p8=t=>{this.p4(Number(t>>32n)),this.p4(Number(0xffffffffn&t))};pjstr=t=>{for(let e=0;e{for(let s=i;s{this.data[this.pos-t-1]=t};bits=()=>{this.bitPos=8*this.pos};bytes=()=>{this.pos=(this.bitPos+7)/8>>>0};gBit=t=>{let i=this.bitPos>>>3,s=8-(7&this.bitPos),r=0;for(this.bitPos+=t;t>s;s=8)r+=(this.data[i++]&e.bitmask[s])<>>s-t&e.bitmask[t],r}}class s{static instances=[];static unpack=t=>{const i=new e(t.read("base_head.dat")),r=new e(t.read("base_type.dat")),a=new e(t.read("base_label.dat")),n=i.g2;i.pos+=2;for(let t=0;t{const i=new e(t.read("frame_head.dat")),a=new e(t.read("frame_tran1.dat")),n=new e(t.read("frame_tran2.dat")),o=new e(t.read("frame_del.dat")),l=i.g2;i.pos+=2;const h=new Uint32Array(500),c=new Uint32Array(500),f=new Uint32Array(500),d=new Uint32Array(500);for(let t=0;t0){if(0!=u.types[t])for(let e=t-1;e>m;e--)if(0==u.types[e]){h[p]=e,c[p]=0,f[p]=0,d[p]=0,p++;break}h[p]=t;let i=0;3==u.types[h[p]]&&(i=128),c[p]=0==(1&e)?i:n.gsmart,f[p]=0==(2&e)?i:n.gsmart,d[p]=0==(4&e)?i:n.gsmart,m=t,p++}}e.length=p,e.bases=new Uint32Array(p),e.x=new Uint32Array(p),e.y=new Uint32Array(p),e.z=new Uint32Array(p);for(let t=0;t{const i=new e(t.read("seq.dat"));this.count=i.g2;for(let t=0;ta.instances[t];frameCount=0;frames=null;iframes=null;delay=null;replayoff=-1;labelGroups=null;stretches=!1;priority=5;mainhand=-1;offhand=-1;replaycount=99;duration=0;decode=(t,e)=>{if(1===t){this.frameCount=e.g1,this.frames=new Uint16Array(this.frameCount),this.iframes=new Uint16Array(this.frameCount),this.delay=new Uint16Array(this.frameCount);for(let t=0;t{const i=new e(t.read("loc.dat"));this.count=i.g2;for(let t=0;t0&&10==e.shapes[0]?1:0,e.ops.length>0&&(e.active=1))}};static get=t=>n.instances[t];models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=-1;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;hasalpha=!1;walloff=16;ambient=0;contrast=0;ops=[];mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;decode=(t,e)=>{if(1===t){const t=e.g1;this.models=new Uint16Array(t),this.shapes=new Uint8Array(t);for(let i=0;i=30&&t<35)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i{const i=new e(t.read("flo.dat"));this.count=i.g2;for(let t=0;to.instances[t];rgb=0;texture=-1;opcode3=!1;occludes=!0;name=null;decode=(t,e)=>{1===t?this.rgb=e.g3:2===t?this.texture=e.g1:3===t?this.opcode3=!0:5===t?this.occludes=!1:6===t?this.name=e.gjstr:console.log("Error unrecognised config code: ",t)}}class l{static pixels=new Int32Array;static width=0;static height=0;static top=0;static bottom=0;static left=0;static right=0;static boundX=0;static centerX=0;static centerY=0;static bind=(t,e,i)=>{this.pixels=t,this.width=e,this.height=i,this.setBounds(0,0,e,i)};static resetBounds=()=>{this.left=0,this.top=0,this.right=this.width,this.bottom=this.height,this.boundX=this.right-1,this.centerX=this.right/2};static setBounds=(t,e,i,s)=>{t<0&&(t=0),e<0&&(e=0),i>this.width&&(i=this.width),s>this.height&&(s=this.height),this.top=e,this.bottom=s,this.left=t,this.right=i,this.boundX=this.right-1,this.centerX=this.right/2,this.centerY=this.bottom/2};static clear=()=>{this.pixels.fill(0)};static drawRect=(t,e,i,s,r)=>{this.drawHorizontalLine(t,e,r,i),this.drawHorizontalLine(t,e+s-1,r,i),this.drawVerticalLine(t,e,r,s),this.drawVerticalLine(t+i-1,e,r,s)};static drawHorizontalLine=(t,e,i,s)=>{if(e=this.bottom)return;tthis.right&&(s=this.right-t);const r=t+e*this.width;for(let t=0;t{if(t=this.right)return;ethis.bottom&&(s=this.bottom-e);const r=t+e*this.width;for(let t=0;t{const a=Math.abs(i-t),n=Math.abs(s-e),o=t=this.left&&t=this.top&&e-n&&(h-=n,t+=o),i{const a=this.pixels;let n=t,o=e,l=t+i,h=e+s;nthis.right&&(l=this.right),h>this.bottom&&(h=this.bottom);const c=this.width;for(let t=o;tt.bits-e.bits||t.code-e.code));let a=0,n=-1;const o=[];let l;for(let t=0;t=t.length)throw RangeError("Out of bound");const i=t.slice();t.sort(((t,e)=>t-e));const s={};for(let e=t.length-1;e>=0;e-=1)s[t[e]]=e;const r=[];for(let e=0;enew Promise((e=>setTimeout(e,t))),g=async t=>new Uint8Array(await(await fetch(t)).arrayBuffer()),m=(t,e=!0,i=!0)=>{if(e){const e=Uint8Array.from(["B".charCodeAt(0),"Z".charCodeAt(0),"h".charCodeAt(0),"1".charCodeAt(0)]);if(i){const i=t;(t=new Uint8Array(e.length+t.length)).set(i,e.length)}t.set(e,0)}return function(t,e=!1){let i=0,s=0,r=0;const a=e=>{if(e>=32){const t=e>>1;return a(t)*(1<>r-e&n;return r-=e,s&=~(n<=49&&n<=57))throw new Error("Invalid blocksize");n-=48;let o=new Uint8Array(1.5*t.length),l=0,u=-1;for(;;){const n=a(48),g=0|a(32);if(54156738319193!==n){if(25779555029136===n){a(7&r);break}throw new Error("Invalid bz2 blocktype")}{if(a(1))throw new Error("do not support randomised");const n=a(24),m=[],p=a(16);for(let t=32768;t>0;t>>=1){if(!(p&t)){for(let t=0;t<16;t+=1)m.push(!1);continue}const e=a(16);for(let t=32768;t>0;t>>=1)m.push(!!(e&t))}const w=a(3);if(w<2||w>6)throw new Error("Invalid number of huffman groups");const b=a(15),y=[],v=Array.from({length:w},((t,e)=>e));for(let t=0;t=w)throw new Error("MTF table out of range");const e=v[t];for(let e=t;e>0;v[e]=v[--e]);y.push(e),v[0]=e}const x=m.reduce(((t,e)=>t+e),0)+2,C=[];for(let t=0;t20)throw new Error("Huffman group length outside range");for(;a(1);)t-=2*a(1)-1;e.push(t)}C.push(f(e))}const S=[];for(let t=0;t>r-e],A)){s&=c[r-=e],A=A.code;break}if(A>=0&&A<=1)0===_&&(O=1),_+=O<0;_-=1)P.push(t)}if(A===x-1)break;{const t=S[A-1];for(let t=A-1;t>0;S[t]=S[--t]);S[0]=t,P.push(t)}}}const M=d(P,n);let E=0;for(;E=o.length){const t=o;o=new Uint8Array(2*t.length),o.set(t)}for(let s=0;s>24^t)]),o[l]=t,l+=1}if(e){const t=-1^u;if(t!==g)throw new Error(`CRC mismatch: ${t} !== ${g}`);u=-1}}}return o.subarray(0,l)}(t)},p=(t,e,i,s,r)=>{for(;r--;)i[s++]=t[e++]};class w{pixels;width;height;cropX;cropY;cropW;cropH;constructor(t,e){this.pixels=new Int32Array(t*e),this.width=this.cropW=t,this.height=this.cropH=e,this.cropX=this.cropY=0}static fromJpeg=async(t,e)=>{const i=t.read(e+".dat"),s=await(async t=>{if(!t)throw new Error("Input jpeg data was null!");255!==t[0]&&(t[0]=255);const e=document.createElement("img");e.src="data:image/jpeg;base64,"+btoa(String.fromCharCode(...t)),await new Promise((t=>e.onload=t));const i=document.createElement("canvas");i.width=e.naturalWidth,i.height=e.naturalHeight;const s=i.getContext("2d");if(!s)throw new Error("Canvas 2d not found!!!!!!!!");return s.drawImage(e,0,0),s.getImageData(0,0,i.width,i.height)})(i),r=new w(s.width,s.height),a=r.pixels,n=s.data;for(let t=0;t{const r=new e(t.read(i+".dat")),a=new e(t.read("index.dat"));a.pos=r.g2;const n=a.g2,o=a.g2,l=a.g1,h=new Uint32Array(l),c=l-1;for(let t=0;t{t|=0,e|=0;let i=(t+=this.cropX)+(e+=this.cropY)*l.width,s=0,r=this.height,a=this.width,n=l.width-a,o=0;if(el.bottom&&(r-=e+r-l.bottom),tl.right){const e=t+a-l.right;a-=e,o+=e,n+=e}a>0&&r>0&&this.copyImageDraw(a,r,this.pixels,s,o,l.pixels,i,n)};drawAlpha=(t,e,i)=>{e|=0,i|=0;let s=(e+=this.cropX)+(i+=this.cropY)*l.width,r=0,a=this.height,n=this.width,o=l.width-n,h=0;if(il.bottom&&(a-=i+a-l.bottom),el.right){const t=e+n-l.right;n-=t,h+=t,o+=t}n>0&&a>0&&this.copyPixelsAlpha(n,a,this.pixels,r,h,l.pixels,s,o,t)};blitOpaque=(t,e)=>{t|=0,e|=0;let i=(t+=this.cropX)+(e+=this.cropY)*l.width,s=0,r=this.height,a=this.width,n=l.width-a,o=0;if(el.bottom&&(r-=e+r-l.bottom),tl.right){const e=t+a-l.right;a-=e,o+=e,n+=e}a>0&&r>0&&this.copyImageBlitOpaque(a,r,this.pixels,s,o,l.pixels,i,n)};flipHorizontally=()=>{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{for(let s=0;s>16&255;a+=t,a<1?a=1:a>255&&(a=255);let n=r>>8&255;n+=e,n<1?n=1:n>255&&(n=255);let o=255&r;o+=i,o<1?o=1:o>255&&(o=255),this.pixels[s]=(a<<16)+(n<<8)+o}}};copyImageBlitOpaque=(t,e,i,s,r,a,n,o)=>{const l=-(t>>2);t=-(3&t);for(let h=-e;h<0;h++){for(let t=l;t<0;t++)a[n++]=i[s++],a[n++]=i[s++],a[n++]=i[s++],a[n++]=i[s++];for(let e=t;e<0;e++)a[n++]=i[s++];n+=o,s+=r}};copyPixelsAlpha=(t,e,i,s,r,a,n,o,l)=>{const h=256-l;for(let c=-e;c<0;c++){for(let e=-t;e<0;e++){const t=i[s++];if(0==t)n++;else{const e=a[n];a[n++]=((16711935&t)*l+(16711935&e)*h&4278255360)+((65280&t)*l+(65280&e)*h&16711680)>>8}}n+=o,s+=r}};copyImageDraw=(t,e,i,s,r,a,n,o)=>{const l=-(t>>2);t=-(3&t);for(let h=-e;h<0;h++){for(let t=l;t<0;t++){let t=i[s++];0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t,t=i[s++],0===t?n++:a[n++]=t}for(let e=t;e<0;e++){const t=i[s++];0===t?n++:a[n++]=t}n+=o,s+=r}}}class b extends t{static count=0;static instances=[];static unpack=(t,i)=>{const s=new e(t.read("obj.dat"));this.count=s.g2;for(let t=0;tb.instances[t];static getIcon=(t,e)=>new w(32,32);model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;ops=[];iops=[];manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;decode=(t,e)=>{if(1===t)this.model=e.g2;else if(2===t)this.name=e.gjstr;else if(3===t)this.desc=e.gjstr;else if(4===t)this.zoom2d=e.g2;else if(5===t)this.xan2d=e.g2;else if(6===t)this.yan2d=e.g2;else if(7===t)this.xof2d=e.g2b,this.xof2d>32767&&(this.xof2d-=65536);else if(8===t)this.yof2d=e.g2b,this.yof2d>32767&&(this.yof2d-=65536);else if(9===t)this.code9=!0;else if(10===t)this.code10=e.g2;else if(11===t)this.stackable=!0;else if(12===t)this.cost=e.g4s;else if(16===t)this.members=!0;else if(23===t)this.manwear=e.g2,this.manwearOffsetY=e.g1b;else if(24===t)this.manwear2=e.g2;else if(25===t)this.womanwear=e.g2,this.womanwearOffsetY=e.g1b;else if(26===t)this.womanwear2=e.g2;else if(t>=30&&t<35)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(t>=35&&t<40)this.iops[t-35]=e.gjstr;else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i=100&&t<110))throw new Error(`Unrecognized obj config code: ${t}`);this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[t-100]=e.g2,this.countco[t-100]=e.g2}};toCertificate=()=>{const t=b.get(this.certtemplate);this.model=t.model,this.zoom2d=t.zoom2d,this.xan2d=t.xan2d,this.yan2d=t.yan2d,this.zan2d=t.zan2d,this.xof2d=t.xof2d,this.yof2d=t.yof2d,this.recol_s=t.recol_s,this.recol_d=t.recol_d;const e=b.get(this.certlink);this.name=e.name,this.members=e.members,this.cost=e.cost;let i="a";const s=(e.name||"").toLowerCase().charAt(0);"a"!==s&&"e"!==s&&"i"!==s&&"o"!==s&&"u"!==s||(i="an"),this.desc=`Swap this note at any bank for ${i} ${e.name}.`,this.stackable=!0}}class y extends t{static count=0;static instances=[];static unpack=t=>{const i=new e(t.read("npc.dat"));this.count=i.g2;for(let t=0;ty.instances[t];name=null;desc=null;size=1;models=null;heads=null;hasanim=!1;readyanim=-1;walkanim=-1;walkanim_b=-1;walkanim_r=-1;walkanim_l=-1;hasalpha=!1;recol_s=null;recol_d=null;ops=[];code90=-1;code91=-1;code92=-1;visonmap=!0;vislevel=-1;resizeh=128;resizev=128;decode=(t,e)=>{if(1===t){const t=e.g1;this.models=new Uint16Array(t);for(let i=0;i=30&&t<40)this.ops[t-30]=e.gjstr,"hidden"===this.ops[t-30]&&(this.ops[t-30]=null);else if(40===t){const t=e.g1;this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let i=0;i{const i=new e(t.read("idk.dat"));this.count=i.g2;for(let t=0;tv.instances[t];type=-1;models=null;heads=new Uint16Array(5).fill(-1);recol_s=new Uint16Array(6);recol_d=new Uint16Array(6);disable=!1;decode=(t,e)=>{if(1===t)this.type=e.g1;else if(2===t){const t=e.g1;this.models=new Uint16Array(t);for(let i=0;i=40&&t<50)this.recol_s[t-40]=e.g2;else if(t>=50&&t<60)this.recol_d[t-50]=e.g2;else{if(!(t>=60&&t<70))throw new Error(`Unrecognized idk config code: ${t}`);this.heads[t-60]=e.g2}}}class x extends t{static count=0;static instances=[];static unpack=t=>{const i=new e(t.read("spotanim.dat"));this.count=i.g2;for(let t=0;tx.instances[t];model=0;anim=-1;seq=null;disposeAlpha=!1;recol_s=new Uint16Array(6);recol_d=new Uint16Array(6);resizeh=128;resizev=128;orientation=0;ambient=0;contrast=0;decode=(t,e)=>{if(1==t)this.model=e.g2;else if(2==t)this.anim=e.g2,null!=a.instances&&(this.seq=a.instances[this.anim]);else if(3==t)this.disposeAlpha=!0;else if(4==t)this.resizeh=e.g2;else if(5==t)this.resizev=e.g2;else if(6==t)this.orientation=e.g2;else if(7==t)this.ambient=e.g1;else if(8==t)this.contrast=e.g1;else if(t>=40&&t<50)this.recol_s[t-40]=e.g2;else{if(!(t>=50&&t<60))throw new Error(`Unrecognized spotanim config code: ${t}`);this.recol_d[t-50]=e.g2}}}class C extends t{static count=0;static instances=[];static code3=[];static code3Count=0;static unpack=t=>{const i=new e(t.read("varp.dat"));this.count=i.g2;for(let t=0;tC.instances[t];code10=null;code1=0;code2=0;hasCode3=!1;code4=!0;clientcode=0;code7=0;code6=!1;code8=!1;decode(t,e){if(1==t)this.code1=e.g1;else if(2==t)this.code2=e.g1;else if(3==t)this.hasCode3=!0,C.code3[C.code3Count++]=this.index;else if(4==t)this.code4=!1;else if(5==t)this.clientcode=e.g2;else if(6==t)this.code6=!0;else if(7==t)this.code7=e.g4;else if(8==t)this.code8=!0;else{if(10!=t)throw new Error(`Error unrecognised config code: ${t}`);this.code10=e.gjstr}}}class S{pixels;width;height;cropX;cropY;cropW;cropH;palette=new Uint32Array(0);constructor(t,e){this.pixels=new Uint8Array(t*e),this.width=this.cropW=t,this.height=this.cropH=e,this.cropX=this.cropY=0}static fromArchive=(t,i,s=0)=>{const r=new e(t?.read(i+".dat")),a=new e(t?.read("index.dat"));a.pos=r.g2;const n=a.g2,o=a.g2,l=a.g1,h=new Uint32Array(l);for(let t=0;t{t|=0,e|=0;let r=(t+=this.cropX)+(e+=this.cropY)*l.width,a=0,n=this.height,o=this.width;-1!==i&&(o=i),-1!==s&&(n=s);let h=l.width-o,c=0;if(el.bottom&&(n-=e+n-l.bottom),tl.right){const e=t+o-l.right;o-=e,c+=e,h+=e}o>0&&n>0&&this.copyImage(o,n,this.pixels,a,c,l.pixels,r,h)};flipHorizontally=()=>{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{const t=this.pixels,e=this.width,i=this.height;for(let s=0;s{for(let s=0;s>16&255;r+=t,r<0?r=0:r>255&&(r=255);let a=this.palette[s]>>8&255;a+=e,a<0?a=0:a>255&&(a=255);let n=255&this.palette[s];n+=i,n<0?n=0:n>255&&(n=255),this.palette[s]=(r<<16)+(a<<8)+n}};copyImage=(t,e,i,s,r,a,n,o)=>{for(let l=0;l{this.lineOffset=new Int32Array(l.height);for(let t=0;t{this.lineOffset=new Int32Array(e);for(let i=0;i{this.textureCount=0;for(let e=0;e<50;e++)try{this.textures[e]=S.fromArchive(t,e.toString()),this.textureCount++}catch(t){}};static setBrightness=t=>{t+=.3*Math.random()-.15;let e=0;for(let i=0;i<512;i++){const s=i/8/64+.0078125,r=(7&i)/8+.0625;for(let i=0;i<128;i++){const a=i/128;let n=a,o=a,l=a;if(r){let t;t=a<.5?a*(1+r):a+r-a*r;const e=2*a-t;let i=s+.3333333333333333;i>1&&i--;let h=s-.3333333333333333;h<0&&h++,n=6*i<1?e+6*(t-e)*i:2*i<1?t:3*i<2?e+6*(.6666666666666666-i)*(t-e):e,o=6*s<1?e+6*(t-e)*s:2*s<1?t:3*s<2?e+6*(.6666666666666666-s)*(t-e):e,l=6*h<1?e+6*(t-e)*h:2*h<1?t:3*h<2?e+6*(.6666666666666666-h)*(t-e):e}let h=Math.trunc(256*n)<<16|Math.trunc(256*o)<<8|Math.trunc(256*l);h=this.setGamma(h,t),0===h&&(h=1),this.palette[e++]=h}}};static setGamma=(t,e)=>{let i=(t>>16)/256,s=(t>>8&255)/256,r=(255&t)/256;return i=Math.pow(i,e),s=Math.pow(s,e),r=Math.pow(r,e),Math.trunc(256*i)<<16|Math.trunc(256*s)<<8|Math.trunc(256*r)};static initPool=t=>{null==this.texelPool&&(this.poolSize=t,this.texelPool=[],this.activeTexels=[])};static fillGouraudTriangle=(t,e,i,s,r,a,n,o,h)=>{let c=0,f=0,d=0,u=0,g=0,m=0;if(r!=s&&(c=(e-t<<16)/(r-s),u=(o-n<<15)/(r-s)),a!=r&&(f=(i-e<<16)/(a-r),g=(h-o<<15)/(a-r)),a!=s&&(d=(t-i<<16)/(s-a),m=(n-h<<15)/(s-a)),s<=r&&s<=a){if(s>=l.bottom)return;if(r>l.bottom&&(r=l.bottom),a>l.bottom&&(a=l.bottom),rf){for(a-=r,r-=s,s=this.lineOffset[s];--r>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,i>>16,t>>16,h>>7,n>>7),i+=d,t+=c,h+=m,n+=u;for(;--a>=0;)this.drawGouraudScanline(l.pixels,s,i>>16,e>>16,h>>7,o>>7),i+=d,e+=f,h+=m,o+=g,s+=l.width;return}for(a-=r,r-=s,s=this.lineOffset[s];--r>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,t>>16,i>>16,n>>7,h>>7),i+=d,t+=c,h+=m,n+=u;for(;--a>=0;)this.drawGouraudScanline(l.pixels,s,e>>16,i>>16,o>>7,h>>7),i+=d,e+=f,h+=m,o+=g,s+=l.width;return}if(e=t<<=16,o=n<<=15,s<0&&(e-=d*s,t-=c*s,o-=m*s,n-=u*s,s=0),i<<=16,h<<=15,a<0&&(i-=f*a,h-=g*a,a=0),s!=a&&dc){for(r-=a,a-=s,s=this.lineOffset[s];--a>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,e>>16,t>>16,o>>7,n>>7),e+=d,t+=c,o+=m,n+=u;for(;--r>=0;)this.drawGouraudScanline(l.pixels,s,i>>16,t>>16,h>>7,n>>7),i+=f,t+=c,h+=g,n+=u,s+=l.width;return}for(r-=a,a-=s,s=this.lineOffset[s];--a>=0;s+=l.width)this.drawGouraudScanline(l.pixels,s,t>>16,e>>16,n>>7,o>>7),e+=d,t+=c,o+=m,n+=u;for(;--r>=0;)this.drawGouraudScanline(l.pixels,s,t>>16,i>>16,n>>7,h>>7),i+=f,t+=c,h+=g,n+=u,s+=l.width}else if(r<=a){if(r>=l.bottom)return;if(a>l.bottom&&(a=l.bottom),s>l.bottom&&(s=l.bottom),ad){for(s-=a,a-=r,r=this.lineOffset[r];--a>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,t>>16,e>>16,n>>7,o>>7),t+=c,e+=f,n+=u,o+=g;for(;--s>=0;)this.drawGouraudScanline(l.pixels,r,t>>16,i>>16,n>>7,h>>7),t+=c,i+=d,n+=u,h+=m,r+=l.width;return}for(s-=a,a-=r,r=this.lineOffset[r];--a>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,e>>16,t>>16,o>>7,n>>7),t+=c,e+=f,n+=u,o+=g;for(;--s>=0;)this.drawGouraudScanline(l.pixels,r,i>>16,t>>16,h>>7,n>>7),t+=c,i+=d,n+=u,h+=m,r+=l.width;return}if(i=e<<=16,h=o<<=15,r<0&&(i-=c*r,e-=f*r,h-=u*r,o-=g*r,r=0),t<<=16,n<<=15,s<0&&(t-=d*s,n-=m*s,s=0),c=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,i>>16,e>>16,h>>7,o>>7),i+=c,e+=f,h+=u,o+=g;for(;--a>=0;)this.drawGouraudScanline(l.pixels,r,t>>16,e>>16,n>>7,o>>7),t+=d,e+=f,n+=m,o+=g,r+=l.width;return}for(a-=s,s-=r,r=this.lineOffset[r];--s>=0;r+=l.width)this.drawGouraudScanline(l.pixels,r,e>>16,i>>16,o>>7,h>>7),i+=c,e+=f,h+=u,o+=g;for(;--a>=0;)this.drawGouraudScanline(l.pixels,r,e>>16,t>>16,o>>7,n>>7),t+=d,e+=f,n+=m,o+=g,r+=l.width}else if(!(a>=l.bottom))if(s>l.bottom&&(s=l.bottom),r>l.bottom&&(r=l.bottom),s=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,e>>16,i>>16,o>>7,h>>7),e+=f,i+=d,o+=g,h+=m;for(;--r>=0;)this.drawGouraudScanline(l.pixels,a,e>>16,t>>16,o>>7,n>>7),e+=f,t+=c,o+=g,n+=u,a+=l.width;return}for(r-=s,s-=a,a=this.lineOffset[a];--s>=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,i>>16,e>>16,h>>7,o>>7),e+=f,i+=d,o+=g,h+=m;for(;--r>=0;)this.drawGouraudScanline(l.pixels,a,t>>16,e>>16,n>>7,o>>7),e+=f,t+=c,o+=g,n+=u,a+=l.width}else if(t=i<<=16,n=h<<=15,a<0&&(t-=f*a,i-=d*a,n-=g*a,h-=m*a,a=0),e<<=16,o<<=15,r<0&&(e-=c*r,o-=u*r,r=0),f=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,t>>16,i>>16,n>>7,h>>7),t+=f,i+=d,n+=g,h+=m;for(;--s>=0;)this.drawGouraudScanline(l.pixels,a,e>>16,i>>16,o>>7,h>>7),e+=c,i+=d,o+=u,h+=m,a+=l.width}else{for(s-=r,r-=a,a=this.lineOffset[a];--r>=0;a+=l.width)this.drawGouraudScanline(l.pixels,a,i>>16,t>>16,h>>7,n>>7),t+=f,i+=d,n+=g,h+=m;for(;--s>=0;)this.drawGouraudScanline(l.pixels,a,i>>16,e>>16,h>>7,o>>7),e+=c,i+=d,o+=u,h+=m,a+=l.width}};static drawGouraudScanline=(t,e,i,s,r,a)=>{let n=0,o=0;if(this.jagged){let h=0;if(this.clipX){if(h=s-i>3?(a-r)/(s-i):0,s>l.right&&(s=l.right),i<0&&(r-=i*h,i=0),i>=s)return;e+=i,o=s-i>>2,h<<=2}else{if(i>=s)return;e+=i,o=s-i>>2,h=o>0?(a-r)*this.reciprocal15[o]>>15:0}if(0==this.alpha){for(;--o>=0;)n=this.palette[r>>8],r+=h,t[e++]=n,t[e++]=n,t[e++]=n,t[e++]=n;if(o=s-i&3,o>0){n=this.palette[r>>8];do{t[e++]=n}while(--o>0);return}}else{const a=this.alpha,l=256-this.alpha;for(;--o>=0;)n=this.palette[r>>8],r+=h,n=((16711935&n)*l>>8&16711935)+((65280&n)*l>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280),t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280);if(o=s-i&3,o>0){n=this.palette[r>>8],n=((16711935&n)*l>>8&16711935)+((65280&n)*l>>8&65280);do{t[e++]=n+((16711935&t[e])*a>>8&16711935)+((65280&t[e])*a>>8&65280)}while(--o>0)}}return}if(i>=s)return;const h=(a-r)/(s-i);if(this.clipX&&(s>l.right&&(s=l.right),i<0&&(r-=i*h,i=0),i>=s))return;if(e+=i,o=s-i,0==this.alpha){do{t[e++]=this.palette[r>>8],r+=h}while(--o>0);return}const c=this.alpha,f=256-this.alpha;do{n=this.palette[r>>8],r+=h,n=((16711935&n)*f>>8&16711935)+((65280&n)*f>>8&65280),t[e++]=n+((16711935&t[e])*c>>8&16711935)+((65280&t[e])*c>>8&65280)}while(--o>0)};static fillTriangle=()=>{};static fillTexturedTriangle=()=>{}}class A{vertexCount=0;faceCount=0;texturedFaceCount=0;vertexFlagsOffset=-1;vertexXOffset=-1;vertexYOffset=-1;vertexZOffset=-1;vertexLabelsOffset=-1;faceVerticesOffset=-1;faceOrientationsOffset=-1;faceColorsOffset=-1;faceInfosOffset=-1;facePrioritiesOffset=0;faceAlphasOffset=-1;faceLabelsOffset=-1;faceTextureAxisOffset=-1}class k{x=0;y=0;z=0;w=0}class I{static metadata=null;static head=null;static face1=null;static face2=null;static face3=null;static face4=null;static face5=null;static point1=null;static point2=null;static point3=null;static point4=null;static point5=null;static vertex1=null;static vertex2=null;static axis=null;static faceClippedX=new Array(4096);static faceNearClipped=new Array(4096);static vertexScreenX=new Int32Array(4096);static vertexScreenY=new Int32Array(4096);static vertexScreenZ=new Int32Array(4096);static vertexViewSpaceX=new Int32Array(4096);static vertexViewSpaceY=new Int32Array(4096);static vertexViewSpaceZ=new Int32Array(4096);static tmpDepthFaceCount=new Int32Array(1500);static tmpDepthFaces=new Array(1500).fill(null).map((()=>new Int32Array(512)));static tmpPriorityFaceCount=new Int32Array(12);static tmpPriorityFaces=new Array(12).fill(null).map((()=>new Int32Array(2e3)));static tmpPriority10FaceDepth=new Int32Array(2e3);static tmpPriority11FaceDepth=new Int32Array(2e3);static tmpPriorityDepthSum=new Int32Array(12);static clippedX=new Int32Array(10);static clippedY=new Int32Array(10);static clippedColor=new Int32Array(10);static baseX=0;static baseY=0;static baseZ=0;static checkHover=!1;static mouseX=0;static mouseZ=0;static pickedCount=0;static pickedBitsets=new Int32Array(1e3);static unpack(t){try{I.head=new e(t.read("ob_head.dat")),I.face1=new e(t.read("ob_face1.dat")),I.face2=new e(t.read("ob_face2.dat")),I.face3=new e(t.read("ob_face3.dat")),I.face4=new e(t.read("ob_face4.dat")),I.face5=new e(t.read("ob_face5.dat")),I.point1=new e(t.read("ob_point1.dat")),I.point2=new e(t.read("ob_point2.dat")),I.point3=new e(t.read("ob_point3.dat")),I.point4=new e(t.read("ob_point4.dat")),I.point5=new e(t.read("ob_point5.dat")),I.vertex1=new e(t.read("ob_vertex1.dat")),I.vertex2=new e(t.read("ob_vertex2.dat")),I.axis=new e(t.read("ob_axis.dat")),I.head.pos=0,I.point1.pos=0,I.point2.pos=0,I.point3.pos=0,I.point4.pos=0,I.vertex1.pos=0,I.vertex2.pos=0;const i=I.head.g2;I.metadata=new Array(i+100);let s=0,r=0,a=0,n=0,o=0,l=0,h=0;for(let t=0;t127&&(e=127),127-e):((e=e*(127&t)>>7)<2?e=2:e>126&&(e=126),(65408&t)+e)}vertexCount=0;vertexX=null;vertexY=null;vertexZ=null;faceCount=0;faceVertexA=null;faceVertexB=null;faceVertexC=null;faceColorA=null;faceColorB=null;faceColorC=null;faceInfo=null;facePriority=null;faceAlpha=null;faceColor=null;priority=0;texturedFaceCount=0;texturedVertexA=null;texturedVertexB=null;texturedVertexC=null;minX=0;maxX=0;minZ=0;maxZ=0;radius=0;minY=0;maxY=0;maxDepth=0;minDepth=0;objRaise=0;vertexLabel=null;faceLabel=null;labelVertices=null;labelFaces=null;pickable=!1;vertexNormal=null;vertexNormalOriginal=null;constructor(t){if(null===I.head||null===I.face1||null===I.face2||null===I.face3||null===I.face4||null===I.face5||null===I.point1||null===I.point2||null===I.point3||null===I.point4||null===I.point5||null===I.vertex1||null===I.vertex2||null===I.axis)return;if(null===I.metadata)return;const e=I.metadata[t];if(void 0===e)return void console.log(`Error model:${t} not found!`);this.vertexCount=e.vertexCount,this.faceCount=e.faceCount,this.texturedFaceCount=e.texturedFaceCount,this.vertexX=new Int32Array(this.vertexCount),this.vertexY=new Int32Array(this.vertexCount),this.vertexZ=new Int32Array(this.vertexCount),this.faceVertexA=new Int32Array(this.faceCount),this.faceVertexB=new Int32Array(this.faceCount),this.faceVertexC=new Int32Array(this.faceCount),this.texturedVertexA=new Int32Array(this.texturedFaceCount),this.texturedVertexB=new Int32Array(this.texturedFaceCount),this.texturedVertexC=new Int32Array(this.texturedFaceCount),e.vertexLabelsOffset>=0&&(this.vertexLabel=new Int32Array(this.vertexCount)),e.faceInfosOffset>=0&&(this.faceInfo=new Int32Array(this.faceCount)),e.facePrioritiesOffset>=0?this.facePriority=new Int32Array(this.faceCount):this.priority=-e.facePrioritiesOffset-1,e.faceAlphasOffset>=0&&(this.faceAlpha=new Int32Array(this.faceCount)),e.faceLabelsOffset>=0&&(this.faceLabel=new Int32Array(this.faceCount)),this.faceColor=new Int32Array(this.faceCount),I.point1.pos=e.vertexFlagsOffset,I.point2.pos=e.vertexXOffset,I.point3.pos=e.vertexYOffset,I.point4.pos=e.vertexZOffset,I.point5.pos=e.vertexLabelsOffset;let i,s,r,a=0,n=0,o=0;for(let t=0;tthis.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const r=e*e+s*s;r>this.radius&&(this.radius=r)}this.radius=Math.trunc(Math.sqrt(this.radius)+.99),this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99)}}calculateBoundsY(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ){this.maxY=0,this.minY=0;for(let t=0;tthis.maxY&&(this.maxY=-e),e>this.minY&&(this.minY=e)}this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99)}}calculateBoundsAABB(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ){this.maxY=0,this.radius=0,this.minY=0,this.minX=999999,this.maxX=-999999,this.maxZ=-99999,this.minZ=99999;for(let t=0;tthis.maxX&&(this.maxX=e),sthis.maxZ&&(this.maxZ=s),-i>this.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const r=e*e+s*s;r>this.radius&&(this.radius=r)}this.radius=Math.trunc(Math.sqrt(this.radius)),this.minDepth=Math.trunc(Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)),this.maxDepth=this.minDepth+Math.trunc(Math.sqrt(this.radius*this.radius+this.minY*this.minY))}}createLabelReferences(){}applyTransform(t){}rotateY90(){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ)for(let t=0;t>16;this.vertexZ[t]=this.vertexY[t]*e+this.vertexZ[t]*i>>16,this.vertexY[t]=s}}translate(t,e,i){if(null!==this.vertexX&&null!==this.vertexY&&null!==this.vertexZ)for(let s=0;s>8;if(null!==this.faceColorA&&null!==this.faceColorB&&null!==this.faceColorC||(this.faceColorA=new Int32Array(this.faceCount),this.faceColorB=new Int32Array(this.faceCount),this.faceColorC=new Int32Array(this.faceCount)),null===this.vertexNormal){this.vertexNormal=new Array(this.vertexCount);for(let t=0;t8192||p>8192||w>8192||m<-8192||p<-8192||w<-8192;)m>>=1,p>>=1,w>>=1;let b=Math.sqrt(m*m+p*p+w*w);if(b<=0&&(b=1),m=256*m/b,p=256*p/b,w=256*w/b,null===this.faceInfo||0==(1&this.faceInfo[e])){let t=this.vertexNormal[a];t.x+=m,t.y+=p,t.z+=w,t.w++,t=this.vertexNormal[o],t.x+=m,t.y+=p,t.z+=w,t.w++,t=this.vertexNormal[l],t.x+=m,t.y+=p,t.z+=w,t.w++}else{const a=t+(i*m+s*p+r*w)/(n+n/2);this.faceColorA[e]=I.mulColorLightness(this.faceColor[e],a,this.faceInfo[e])}}if(a)this.applyLighting(t,e,i,s,r);else{this.vertexNormalOriginal=new Array(this.vertexCount);for(let t=0;t>16;for(let s=0;s>16,b=b*d-w*f>>16,w=p),0!==t&&(p=b*l-y*o>>16,y=b*o+y*l>>16,b=p),0!==e&&(p=y*h+w*c>>16,y=y*c-w*h>>16,w=p),w+=r,b+=a,y+=n,p=b*g-y*u>>16,y=b*u+y*g>>16,b=p,I.vertexScreenX[s]=T.centerX+(w<<9)/y,I.vertexScreenY[s]=T.centerY+(b<<9)/y,I.vertexScreenZ[s]=y-m,this.texturedFaceCount>0&&(I.vertexViewSpaceX[s]=w,I.vertexViewSpaceY[s]=b,I.vertexViewSpaceZ[s]=y)}this.draw2(!1,!1,0)}draw(t,e,i,s,r,a,n,o,l){}draw2(t,e,i){if(null===I.vertexScreenX||null===I.vertexScreenY||null===I.vertexScreenZ)return;if(null===I.vertexViewSpaceX||null===I.vertexViewSpaceY||null===I.vertexViewSpaceZ)return;if(null===I.faceNearClipped||null===I.faceClippedX)return;if(null===I.tmpDepthFaceCount||null===I.tmpDepthFaces||null===I.tmpPriorityFaces||null===I.tmpPriorityFaceCount||null===I.tmpPriorityDepthSum||null===I.tmpPriority10FaceDepth||null===I.tmpPriority11FaceDepth)return;if(null===this.faceVertexA||null===this.faceVertexB||null===this.faceVertexC)return;for(let t=0;tl.boundX||h>l.boundX||c>l.boundX;const u=Math.trunc((I.vertexScreenZ[r]+I.vertexScreenZ[a]+I.vertexScreenZ[n])/3+this.minDepth);I.tmpDepthFaces[u][I.tmpDepthFaceCount[u]++]=s}else{I.faceNearClipped[s]=!0;const t=Math.trunc((I.vertexScreenZ[r]+I.vertexScreenZ[a]+I.vertexScreenZ[n])/3+this.minDepth);I.tmpDepthFaces[t][I.tmpDepthFaceCount[t]++]=s}}if(null==this.facePriority){for(let t=this.maxDepth-1;t>=0;t--){const e=I.tmpDepthFaceCount[t];if(e<=0)continue;const i=I.tmpDepthFaces[t];for(let t=0;t=0;t--){const e=I.tmpDepthFaceCount[t];if(e>0){const i=I.tmpDepthFaces[t];for(let s=0;s0||I.tmpPriorityFaceCount[2]>0)&&(s=Math.trunc((I.tmpPriorityDepthSum[1]+I.tmpPriorityDepthSum[2])/(I.tmpPriorityFaceCount[1]+I.tmpPriorityFaceCount[2])));let r=0;(I.tmpPriorityFaceCount[3]>0||I.tmpPriorityFaceCount[4]>0)&&(r=Math.trunc((I.tmpPriorityDepthSum[3]+I.tmpPriorityDepthSum[4])/(I.tmpPriorityFaceCount[3]+I.tmpPriorityFaceCount[4])));let a=0;(I.tmpPriorityFaceCount[6]>0||I.tmpPriorityFaceCount[8]>0)&&(a=Math.trunc((I.tmpPriorityDepthSum[6]+I.tmpPriorityDepthSum[8])/(I.tmpPriorityFaceCount[6]+I.tmpPriorityFaceCount[8])));let n,o=0,h=I.tmpPriorityFaceCount[10],c=I.tmpPriorityFaces[10],f=I.tmpPriority10FaceDepth;o==h&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=os;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=or;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=oa;)this.drawFace(c[o++]),o==h&&c!=I.tmpPriorityFaces[11]&&(o=0,h=I.tmpPriorityFaceCount[11],c=I.tmpPriorityFaces[11],f=I.tmpPriority11FaceDepth),n=oa&&e>n&&e>o||t{const r=new e(t.read("data"));let a=-1;for(r.pos+=2;r.pos0){e.scriptComparator=new Uint8Array(n).fill(0),e.scriptOperand=new Uint16Array(n).fill(0);for(let t=0;t0){e.scripts=new Array(o).fill(null);for(let t=0;t0){const r=s.lastIndexOf(",");e.inventorySlotImage[t]=w.fromArchive(i,s,r)}}for(let t=0;t<5;t++)e.inventoryOptions[t]=r.gjstr,0===e.inventoryOptions[t]?.length&&(e.inventoryOptions[t]=null);e.spellAction=r.gjstr,e.spellName=r.gjstr,e.spellFlags=r.g2;break;case _.TYPE_RECT:e.fill=1===r.g1,e.color=r.g4,e.activeColor=r.g4,e.hoverColor=r.g4;break;case _.TYPE_TEXT:e.center=1===r.g1,e.font=s[r.g1],e.shadow=1===r.g1,e.text=r.gjstr,e.activeText=r.gjstr,e.color=r.g4,e.activeColor=r.g4,e.hoverColor=r.g4;break;case _.TYPE_SPRITE:{const t=r.gjstr;if(t.length>0){const s=t.lastIndexOf(",");e.image=w.fromArchive(i,t.substring(0,s),parseInt(t.substring(s+1)))}const s=r.gjstr;if(s.length>0){const t=s.lastIndexOf(",");e.image=w.fromArchive(i,s.substring(0,t),parseInt(s.substring(t+1)))}break}case _.TYPE_MODEL:{const t=r.g1;0!==t&&(e.model=this.getModel((t-1<<8)+r.g1));const i=r.g1;0!==i&&(e.activeModel=this.getModel((i-1<<8)+r.g1)),e.seqId=r.g1,0==e.seqId?e.seqId=-1:e.seqId=(e.seqId-1<<8)+r.g1,e.activeSeqId=r.g1,0==e.activeSeqId?e.activeSeqId=-1:e.activeSeqId=(e.activeSeqId-1<<8)+r.g1,e.modelZoom=r.g2,e.modelPitch=r.g2,e.modelYaw=r.g2;break}case _.TYPE_INVENTORY_TEXT:e.inventorySlotObjId=new Int32Array(e.width*e.height),e.inventorySlotObjCount=new Int32Array(e.width*e.height),e.center=1===r.g1,e.font=s[r.g1],e.shadow=1===r.g1,e.color=r.g4,e.inventoryMarginX=r.g2b,e.inventoryMarginY=r.g2b,e.inventoryInteractable=1===r.g1,e.inventoryOptions=new Array(5).fill(null);for(let t=0;t<5;t++)e.inventoryOptions[t]=r.gjstr}2!=e.optionType&&2!=e.type||(e.spellAction=r.gjstr,e.spellName=r.gjstr,e.spellFlags=r.g2),1!=e.optionType&&4!=e.optionType&&5!=e.optionType&&6!=e.optionType||(e.option=r.gjstr,0==e.option.length&&(1==e.optionType?e.option="Ok":4==e.optionType||5==e.optionType?e.option="Select":6==e.optionType&&(e.option="Continue")))}};static get=t=>_.instances[t];static getModel=t=>new I(t);id=-1;parentId=-1;type=-1;optionType=-1;contentType=0;width=0;height=0;delegateHover=-1;scriptComparator=null;scriptOperand=null;scripts=null;scrollableHeight=0;hide=!1;inventoryDraggable=!1;inventoryInteractable=!1;inventoryUsable=!1;inventoryMarginX=0;inventoryMarginY=0;inventorySlotOffsetX=null;inventorySlotOffsetY=null;inventorySlotImage=null;inventoryOptions=[];fill=!1;center=!1;font=null;shadow=!1;text=null;activeText=null;color=0;activeColor=0;hoverColor=0;image=null;activeImage=null;model=null;activeModel=null;seqId=-1;activeSeqId=-1;modelZoom=0;modelPitch=0;modelYaw=0;spellAction=null;spellName=null;spellFlags=-1;option=null;childId=null;childX=null;childY=null;x=0;y=0;scrollPosition=0;inventorySlotObjId=null;inventorySlotObjCount=null;seqFrame=0;getModel=(t,e,i)=>{let s=this.model;return i&&(s=this.activeModel),null==s?null:-1==t&&-1==e&&null==s.faceColor?s:null}}class O{canvas;ctx;image;pixels;width;height;constructor(t,e,i){const s=t.getContext("2d");if(!s)throw new Error("Canvas 2d not found!!!!!!!!");this.canvas=t,this.ctx=s,this.image=s.getImageData(0,0,e,i),this.pixels=new Int32Array(e*i),this.width=e,this.height=i,this.bind()}clear=()=>{this.pixels.fill(0)};bind=()=>{l.bind(this.pixels,this.width,this.height)};draw=(t,e)=>{this.#t(),this.ctx.putImageData(this.image,t,e)};#t=()=>{const t=this.image.data;for(let e=0;e>16&255,t[s+1]=i>>8&255,t[s+2]=i>>0&255,t[s+3]=255}}}class P{static CHARSET=[];static{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";for(let e=0;e<256;e++){let i=t.indexOf(String.fromCharCode(e));-1===i&&(i=74),P.CHARSET[e]=i}}pixels=[];charWidth=[];charHeight=[];clipX=[];clipY=[];charSpace=[];drawWidth=[];fontHeight=-1;static fromArchive=(t,i)=>{const s=new e(t.read(i+".dat")),r=new e(t.read("index.dat"));r.pos=s.g2+4;const a=r.g1;a>0&&(r.pos+=3*(a-1));const n=new P;for(let t=0;t<94;t++){n.clipX[t]=r.g1,n.clipY[t]=r.g1;const e=n.charWidth[t]=r.g2,i=n.charHeight[t]=r.g2,a=e*i;n.pixels[t]=new Uint8Array(a);const o=r.g1;if(0===o)for(let r=0;rn.fontHeight&&(n.fontHeight=i),n.clipX[t]=1,n.charSpace[t]=e+2;{let s=0;for(let r=i/7;r{t|=0,e|=0;const r=i.length;e-=this.fontHeight;for(let a=0;a{t|=0,e|=0;const a=i.length;e-=this.fontHeight;for(let n=0;n{const e=t.length;let i=0;for(let s=0;s{const r=e-this.fontHeight;for(let e=0;e{this.drawStringTaggable(t-this.stringWidth(i)/2,e,i,s,r)};drawStringCenter=(t,e,i,s)=>{this.draw(t-this.stringWidth(i)/2,e,i,s)};drawRight=(t,e,i,s,r=!0)=>{r&&this.draw(t-this.stringWidth(i)+1,e+1,i,0),this.draw(t-this.stringWidth(i),e,i,s)};drawChar=(t,e,i,s,r,a)=>{s|=0,r|=0;let n=(e|=0)+(i|=0)*l.width,o=l.width-s,h=0,c=0;if(i=l.bottom&&(r-=i+r+1-l.bottom),e=l.right){const t=e+s+1-l.right;s-=t,h+=t,o+=t}s>0&&r>0&&this.drawMask(s,r,t,c,h,l.pixels,n,o,a)};drawMask=(t,e,i,s,r,a,n,o,l)=>{const h=-((t|=0)>>2);t=-(3&t);for(let c=-(e|=0);c<0;c++){for(let t=h;t<0;t++)0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l,0==i[s++]?n++:a[n++]=l;for(let e=t;e<0;e++)0==i[s++]?n++:a[n++]=l;n+=o,s+=r}};copyCharacter=(t,e,i,s,r,a)=>{i|=0,s|=0;let n=(t|=0)+(e|=0)*l.width,o=0,h=l.width-i,c=0;if(el.bottom&&(s-=e+s+1-l.bottom),tl.right){const e=t+i+1-l.right;i-=e,c+=e,h+=e}i>0&&s>0&&this.copyImageMasked(i,s,r,o,c,l.pixels,n,h,a)};copyImageMasked=(t,e,i,s,r,a,n,o,l)=>{for(let h=0;h{switch(t){case"red":return 16711680;case"gre":return 65280;case"blu":return 255;case"yel":return 16776960;case"cya":return 65535;case"mag":return 16711935;case"whi":return 16777215;case"bla":default:return 0;case"lre":return 16748608;case"dre":return 8388608;case"dbl":return 128;case"or1":return 16756736;case"or2":return 16740352;case"or3":return 16723968;case"gr1":return 12648192;case"gr2":return 8453888;case"gr3":return 4259584}}}class M{static loadUrl=async t=>new M(await g(t));static genHash=t=>{let e=0;t=t.toUpperCase();for(let i=0;i>>0;return e};buffer;compressedWhole;fileCount;fileHash;fileSizeInflated;fileSizeDeflated;fileOffset;constructor(t){const i=new e(t),s=i.g3;let r;if(s==i.g3)r=i,this.compressedWhole=!1;else{const t=i.gdata(i.pos,s);r=new e(new Uint8Array(m(t))),this.compressedWhole=!0}this.buffer=r,this.fileCount=r.g2,this.fileHash=[],this.fileSizeInflated=[],this.fileSizeDeflated=[],this.fileOffset=[];let a=r.pos+10*this.fileCount;for(let t=0;t{const e=M.genHash(t),i=this.fileHash.indexOf(e);return-1==i?null:this.readIndex(i)};readIndex=t=>{if(t<0||t>=this.fileCount)return null;if(this.compressedWhole)return this.buffer.gdata(this.fileOffset[t],this.fileOffset[t]+this.fileSizeDeflated[t]);{const e=this.buffer.gdata(this.fileOffset[t],this.fileOffset[t]+this.fileSizeDeflated[t]);return m(e)}}}class E{static PERIOD=new Uint16Array(["d","o","t"].join("").split("").map((t=>t.charCodeAt(0))));static AMPERSAT=new Uint16Array(["(","a",")"].join("").split("").map((t=>t.charCodeAt(0))));static SLASH=new Uint16Array(["s","l","a","s","h"].join("").split("").map((t=>t.charCodeAt(0))));static whitelist=["cook","cook's","cooks","seeks","sheet"];static tlds=[];static tldTypes=[];static bads=[];static badCombinations=[];static domains=[];static fragments=[];static unpack=t=>{const i=new e(t.read("fragmentsenc.txt")),s=new e(t.read("badenc.txt")),r=new e(t.read("domainenc.txt")),a=new e(t.read("tldlist.txt"));this.read(s,r,i,a)};static filter=t=>{const e=[...t];this.format(e);const i=e.join("").trim(),s=i.toLowerCase(),r=[...s];this.filterTlds(r),this.filterBadWords(r),this.filterDomains(r),this.filterFragments(r);for(let t=0;t{this.readBadWords(t),this.readDomains(e),this.readFragments(i),this.readTld(s)};static readTld=t=>{const e=t.g4;for(let i=0;it.g1))};static readBadWords=t=>{const e=t.g4;for(let i=0;it.g1));const e=new Array(t.g1).fill([]).map((()=>[t.g1b,t.g1b]));e.length>0&&(this.badCombinations[i]=e)}};static readDomains=t=>{const e=t.g4;for(let i=0;it.g1))};static readFragments=t=>{const e=t.g4;for(let i=0;i{const e=[...t],i=[...t];this.filterBadCombinations(null,e,this.PERIOD),this.filterBadCombinations(null,i,this.SLASH);for(let s=0;s{for(let e=0;e<2;e++)for(let e=this.bads.length-1;e>=0;e--)this.filterBadCombinations(this.badCombinations[e],t,this.bads[e])};static filterDomains=t=>{const e=[...t],i=[...t];this.filterBadCombinations(null,e,this.AMPERSAT),this.filterBadCombinations(null,i,this.PERIOD);for(let s=this.domains.length-1;s>=0;s--)this.filterDomain(i,e,this.domains[s],t)};static filterFragments=t=>{for(let e=0;e=0&&r{if(this.isNumericalChars(t))return!0;const e=this.getInteger(t),i=this.fragments,s=i.length;if(e===i[0]||e===i[s-1])return!0;let r=0,a=s-1;for(;r<=a;){const t=Math.floor((r+a)/2);if(e===i[t])return!0;e{if(t.length>6)return 0;let e=0;for(let i=0;i{for(let i=e;i=0;i++)if(this.isNumerical(t[i]))return i;return-1};static indexOfNonNumber=(t,e)=>{for(let i=t;i=0;i++)if(!this.isNumerical(e[i]))return i;return e.length};static getEmulatedDomainCharLen=(t,e,i)=>e==i||"o"==e&&"0"==i?1:"o"==e&&"("==i&&")"==t?2:"c"!=e||"("!=i&&"<"!=i&&"["!=i?"e"==e&&"€"==i||"s"==e&&"$"==i||"l"==e&&"i"==i?1:0:1;static filterDomain=(t,e,i,s)=>{const r=i.length,a=s.length;for(let n=0;n<=a-r;n++){const{matched:r,currentIndex:a}=this.findMatchingDomain(n,i,s);if(!r)continue;const o=this.prefixSymbolStatus(n,s,3,e,["@"]),l=this.suffixSymbolStatus(a-1,s,3,t,[".",","]);(o>2||l>2)&&this.maskChars(n,a,s)}};static findMatchingDomain=(t,e,i)=>{const s=e.length;let r=t,a=0;for(;r0)r+=l,a++;else{if(0===a)break;const i=this.getEmulatedDomainCharLen(o,String.fromCharCode(e[a-1]),n);if(i>0)r+=i,1===a&&t++;else{if(a>=s||!this.isSymbol(n))break;r++}}}return{matched:a>=s,currentIndex:r}};static filterBadCombinations=(t,e,i)=>{if(!(i.length>e.length))for(let s=0;s<=e.length-i.length;s++){let r=s;const{currentIndex:a,badIndex:n,hasSymbol:o,hasNumber:l,hasDigit:h}=this.processBadCharacters(e,i,r);r=a;let c=e[r],f=r+1=i.length)||l&&h)continue;let d,u=!0;if(o){let t=!1,i=!1;if((s-1<0||this.isSymbol(e[s-1])&&"'"!=e[s-1])&&(t=!0),(r>=e.length||this.isSymbol(e[r])&&"'"!=e[r])&&(i=!0),!t||!i){let i=!1;for(d=s-2,t&&(d=s);!i&&d=0&&(!this.isSymbol(e[d])||"'"==e[d])){const t=[];let s;for(s=0;s<3&&d+s=0&&(!this.isSymbol(e[d-1])||"'"==e[d-1])&&(r=!1),r&&!this.isBadFragment(t)&&(i=!0)}d++}i||(u=!1)}}else{c=" ",s-1>=0&&(c=e[s-1]),f=" ",r{let s=i,r=0,a=0,n=!1,o=!1,l=!1;for(;s=t.length||o&&l);){const h=t[s],c=s+10)1===f&&this.isNumerical(h)&&(o=!0),2===f&&(this.isNumerical(h)||this.isNumerical(c))&&(o=!0),s+=f,r++;else{if(0===r)break;let t;if((t=this.getEmulatedBadCharLen(c,String.fromCharCode(e[r-1]),h))>0)s+=t;else{if(r>=e.length||!this.isNotLowercaseAlpha(h))break;if(this.isSymbol(h)&&"'"!==h&&(n=!0),this.isNumerical(h)&&(l=!0),s++,a++,100*a/(s-i)>90)break}}}return{currentIndex:s,badIndex:r,hasSymbol:n,hasNumber:o,hasDigit:l}};static getEmulatedBadCharLen=(t,e,i)=>{if(e==i)return 1;if(e>="a"&&e<="m"){if("a"==e)return"4"!=i&&"@"!=i&&"^"!=i?"/"==i&&"\\"==t?2:0:1;if("b"==e)return"6"!=i&&"8"!=i?"1"==i&&"3"==t?2:0:1;if("c"==e)return"("!=i&&"<"!=i&&"{"!=i&&"["!=i?0:1;if("d"==e)return"["==i&&")"==t?2:0;if("e"==e)return"3"!=i&&"€"!=i?0:1;if("f"==e)return"p"==i&&"h"==t?2:"£"==i?1:0;if("g"==e)return"9"!=i&&"6"!=i?0:1;if("h"==e)return"#"==i?1:0;if("i"==e)return"y"!=i&&"l"!=i&&"j"!=i&&"1"!=i&&"!"!=i&&":"!=i&&";"!=i&&"|"!=i?0:1;if("j"==e)return 0;if("k"==e)return 0;if("l"==e)return"1"!=i&&"|"!=i&&"i"!=i?0:1;if("m"==e)return 0}if(e>="n"&&e<="z"){if("n"==e)return 0;if("o"==e)return"0"!=i&&"*"!=i?"("==i&&")"==t||"["==i&&"]"==t||"{"==i&&"}"==t||"<"==i&&">"==t?2:0:1;if("p"==e)return 0;if("q"==e)return 0;if("r"==e)return 0;if("s"==e)return"5"!=i&&"z"!=i&&"$"!=i&&"2"!=i?0:1;if("t"==e)return"7"!=i&&"+"!=i?0:1;if("u"==e)return"v"==i?1:"\\"==i&&"/"==t||"\\"==i&&"|"==t||"|"==i&&"/"==t?2:0;if("v"==e)return"\\"==i&&"/"==t||"\\"==i&&"|"==t||"|"==i&&"/"==t?2:0;if("w"==e)return"v"==i&&"v"==t?2:0;if("x"==e)return")"==i&&"("==t||"}"==i&&"{"==t||"]"==i&&"["==t||">"==i&&"<"==t?2:0;if("y"==e)return 0;if("z"==e)return 0}return e>="0"&&e<="9"?"0"==e?"o"==i||"O"==i?1:"("==i&&")"==t||"{"==i&&"}"==t||"["==i&&"]"==t?2:0:"1"==e&&"l"==i?1:0:","==e?"."==i?1:0:"."==e?","==i?1:0:"!"==e&&"i"==i?1:0};static comboMatches=(t,e,i)=>{let s=0,r=e.length-1;for(;s<=r;){const a=Math.floor((s+r)/2);if(e[a][0]===t&&e[a][1]===i)return!0;tthis.isLowercaseAlpha(t)?t.charCodeAt(0)+1-"a".charCodeAt(0):"'"==t?28:this.isNumerical(t)?t.charCodeAt(0)+29-"0".charCodeAt(0):27;static filterTld=(t,e,i,s,r)=>{if(!(s.length>i.length))for(let a=0;a<=i.length-s.length;a++){const{currentIndex:n,tldIndex:o}=this.processTlds(i,s,a);if(o0&&c>0&&(l=!0),2==e&&(h>2&&c>0||h>0&&c>2)&&(l=!0),3==e&&h>0&&c>2&&(l=!0),!l)continue;let f,d=a,u=n-1,g=!1;if(h>2){if(4==h)for(g=!1,f=a-1;f>=0;f--)if(g){if("*"!=r[f])break;d=f}else"*"==r[f]&&(d=f,g=!0);for(g=!1,f=d-1;f>=0;f--)if(g){if(this.isSymbol(i[f]))break;d=f}else this.isSymbol(i[f])||(g=!0,d=f)}if(c>2){if(4==c)for(g=!1,f=u+1;f{let s=0;for(;i0)i+=n,s++;else{if(0===s)break;let t;if((t=this.getEmulatedDomainCharLen(a,String.fromCharCode(e[s-1]),r))>0)i+=t;else{if(!this.isSymbol(r))break;i++}}}return{currentIndex:i,tldIndex:s}};static isSymbol=t=>!this.isAlpha(t)&&!this.isNumerical(t);static isNotLowercaseAlpha=t=>!this.isLowercaseAlpha(t)||"v"==t||"x"==t||"j"==t||"q"==t||"z"==t;static isAlpha=t=>this.isLowercaseAlpha(t)||this.isUppercaseAlpha(t);static isNumerical=t=>t>="0"&&t<="9";static isLowercaseAlpha=t=>t>="a"&&t<="z";static isUppercaseAlpha=t=>t>="A"&&t<="Z";static isNumericalChars=t=>{for(let e=0;e{for(let s=t;s{let i=0;for(let s=e-1;s>=0&&this.isSymbol(t[s]);s--)"*"===t[s]&&i++;return i};static maskedCountForwards=(t,e)=>{let i=0;for(let s=e+1;s(r?this.maskedCountBackwards(e,i):this.maskedCountForwards(e,i))>=s?4:this.isSymbol(r?t[i-1]:t[i+1])?1:0;static prefixSymbolStatus=(t,e,i,s,r)=>{if(0===t)return 2;for(let i=t-1;i>=0&&this.isSymbol(e[i]);i--)if(r.includes(e[i]))return 3;return this.maskedCharsStatus(e,s,t,i,!0)};static suffixSymbolStatus=(t,e,i,s,r)=>{if(t+1===e.length)return 2;for(let i=t+1;i{let e=0;for(let i=0;it>=" "&&t<=""||" "==t||"\n"==t||"\t"==t||"£"==t||"€"==t;static replaceUppercases=(t,e)=>{for(let i=0;i{let e=!0;for(let i=0;i{this.resizeToFit&&this.resize(window.innerWidth,window.innerHeight)}),!1),window.addEventListener("keydown",this.keyDown),window.addEventListener("keyup",this.keyUp),window.addEventListener("mousedown",this.mousePressed),this.canvas.oncontextmenu=t=>{t.preventDefault()},await this.showProgress(0,"Loading..."),await this.load();for(let t=0;t<10;t++)this.otim[t]=Date.now();let t,e=0,i=256,s=1,r=0;for(;this.state>=0;){if(this.state>0&&(this.state--,0===this.state))return void this.shutdown();const a=i,n=s;i=300,s=1,t=Date.now();const o=this.otim[e];if(0===o?(i=a,s=n):t>o&&(i=Math.trunc(2560*this.deltime/(t-o))),i<25?i=25:i>256&&(i=256,s=Math.trunc(this.deltime-(t-o)/10)),this.otim[e]=t,e=(e+1)%10,s>1)for(let t=0;t<10;t++)0!==this.otim[t]&&(this.otim[t]+=s);for(s0&&(this.fps=Math.trunc(1e3*i/(256*this.deltime)));const l=performance.now();await this.draw(),this.frameTime[this.fpos]=(performance.now()-l)/1e3,this.fpos=(this.fpos+1)%this.frameTime.length}-1==this.state&&this.shutdown()}shutdown(){this.state=-2,this.unload()}setLoopRate(t){this.deltime=1e3/t}start(){this.state>=0&&(this.state=0)}stop(){this.state>=0&&(this.state=4e3/this.deltime)}destroy(){this.state=-1}async load(){}update(){}unload(){}async draw(){}refresh(){}async showProgress(t,e){const i=this.ctx,s=this.width,r=this.height;this.redrawScreen&&(i.fillStyle="black",i.clearRect(0,0,s,r),this.redrawScreen=!1);const a=r/2-18;i.fillStyle="rgb(140, 17, 17)",i.rect(s/2-152,a,304,34),i.fillRect(s/2-150,a+2,3*t,30),i.fillStyle="black",i.fillRect(s/2-150+3*t,a+2,300-3*t,30),i.font="bold 13px helvetica, sans-serif",i.textAlign="center",i.fillStyle="white",i.fillText(e,s/2,a+22),await u(5)}keyDown=t=>{this.idleCycles=0;const e=t.keyCode;let i=t.key.charCodeAt(0);83!==i&&(i<30&&(i=0),37==e?i=1:39==e?i=2:38==e?i=3:40==e?i=4:17==e?i=5:8==e||127==e?i=8:9==e?i=9:10==e?i=10:e>=112&&e<=123?i=e+1008-112:36==e?i=1e3:35==e?i=1001:33==e?i=1002:34==e&&(i=1003),i>0&&i<128&&(this.actionKey[i]=1),i>4&&(this.keyQueue[this.keyQueueWritePos]=i,this.keyQueueWritePos=this.keyQueueWritePos+1&127))};keyUp=t=>{this.idleCycles=0;let e=t.key.charCodeAt(0);"ArrowLeft"==t.key?e=1:"ArrowRight"==t.key?e=2:"ArrowUp"==t.key?e=3:"ArrowDown"==t.key&&(e=4),this.actionKey[e]=0};pollKey(){let t=-1;return this.keyQueueWritePos!=this.keyQueueReadPos&&(t=this.keyQueue[this.keyQueueReadPos],this.keyQueueReadPos=this.keyQueueReadPos+1&127),t}mousePressed=t=>{let e=t.x,i=t.y;const{top:s,left:r}=this.getInsets;e-=r,i-=s,this.idleCycles=0,this.mouseClickX=e,this.mouseClickY=i,2===t.buttons?(this.mouseClickButton=2,this.mouseButton=2):1===t.buttons&&(this.mouseClickButton=1,this.mouseButton=1)};get getInsets(){const t=this.canvas.getBoundingClientRect(),e=window.getComputedStyle(this.canvas),i=parseFloat(e.paddingLeft||"0"),s=parseFloat(e.paddingTop||"0"),r=parseFloat(e.borderLeftWidth||"0"),a=parseFloat(e.borderTopWidth||"0"),n=t.left+r+i;return{top:t.top+a+s,left:n}}get ms(){const t=this.frameTime.length;let e=0;for(let i=0;i{Object.getOwnPropertyDescriptor(r.ready,t)||Object.defineProperty(r.ready,t,{get:()=>W("You are getting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>W("You are setting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}));var a=Object.assign({},r),n=[],o="object"==typeof window,l="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,c=!o&&!h&&!l;if(r.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var f,d,u,g="";if(h){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var m,p;g=l?require("path").dirname(g)+"/":__dirname+"/";var w=()=>{p||(m=require("fs"),p=require("path"))};f=(t,e)=>(w(),t=p.normalize(t),m.readFileSync(t,e?void 0:"utf8")),u=t=>{var e=f(t,!0);return e.buffer||(e=new Uint8Array(e)),L(e.buffer),e},d=(t,e,i)=>{w(),t=p.normalize(t),m.readFile(t,(function(t,s){t?i(t):e(s.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),n=process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof st))throw t})),process.on("unhandledRejection",(function(t){throw t})),r.inspect=function(){return"[Emscripten Module object]"}}else if(c){if("object"==typeof process&&"function"==typeof require||"object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");"undefined"!=typeof read&&(f=function(t){return read(t)}),u=function(t){let e;return"function"==typeof readbuffer?new Uint8Array(readbuffer(t)):(e=read(t,"binary"),L("object"==typeof e),e)},d=function(t,e,i){setTimeout((()=>e(u(t))),0)},"undefined"!=typeof scriptArgs?n=scriptArgs:void 0!==arguments&&(n=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else{if(!o&&!l)throw new Error("environment detection error");if(l?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),F&&(g=F),g=0!==g.indexOf("blob:")?g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):"","object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");f=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},l&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),d=(t,e,i)=>{var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?e(s.response):i()},s.onerror=i,s.send(null)}}r.print||console.log.bind(console);var b,y,v,x=r.printErr||console.warn.bind(console);function C(t,e){Object.getOwnPropertyDescriptor(r,t)||Object.defineProperty(r,t,{configurable:!0,get:function(){W("Module."+t+" has been replaced with plain "+e+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}function S(t){return"FS_createPath"===t||"FS_createDataFile"===t||"FS_createPreloadedFile"===t||"FS_unlink"===t||"addRunDependency"===t||"FS_createLazyFile"===t||"FS_createDevice"===t||"removeRunDependency"===t}Object.assign(r,a),a=null,b="fetchSettings",Object.getOwnPropertyDescriptor(r,b)&&W("`Module."+b+"` was supplied but `"+b+"` not included in INCOMING_MODULE_JS_API"),r.arguments&&(n=r.arguments),C("arguments","arguments_"),r.thisProgram&&r.thisProgram,C("thisProgram","thisProgram"),r.quit&&r.quit,C("quit","quit_"),L(void 0===r.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),L(void 0===r.read,"Module.read option was removed (modify read_ in JS)"),L(void 0===r.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),L(void 0===r.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),L(void 0===r.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),L(void 0===r.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),C("read","read_"),C("readAsync","readAsync"),C("readBinary","readBinary"),C("setWindowTitle","setWindowTitle"),L(!c,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."),r.wasmBinary&&(y=r.wasmBinary),C("wasmBinary","wasmBinary"),r.noExitRuntime,C("noExitRuntime","noExitRuntime"),"object"!=typeof WebAssembly&&W("no native wasm support detected");var T,A,k,I,_,O,P,M,E=!1;function L(t,e){t||W("Assertion failed"+(e?": "+e:""))}function B(t){T=t,r.HEAP8=A=new Int8Array(t),r.HEAP16=I=new Int16Array(t),r.HEAP32=_=new Int32Array(t),r.HEAPU8=k=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=O=new Uint32Array(t),r.HEAPF32=P=new Float32Array(t),r.HEAPF64=M=new Float64Array(t)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf8");var R=5242880;r.TOTAL_STACK&&L(R===r.TOTAL_STACK,"the stack size can no longer be determined at runtime");var Y=r.INITIAL_MEMORY||16777216;function D(){if(!E){var t=ct(),e=O[t>>2],i=O[t+4>>2];34821223==e&&2310721022==i||W("Stack overflow! Stack cookie has been overwritten at 0x"+t.toString(16)+", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+i.toString(16)+" 0x"+e.toString(16)),1668509029!==O[0]&&W("Runtime error: The application has corrupted its heap memory area (address zero)!")}}C("INITIAL_MEMORY","INITIAL_MEMORY"),L(Y>=R,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+Y+"! (TOTAL_STACK="+R+")"),L("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),L(!r.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),L(16777216==Y,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var t=new Int16Array(1),e=new Int8Array(t.buffer);if(t[0]=25459,115!==e[0]||99!==e[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var U=[],G=[],H=[],X=!1;L(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var N=0,z=null,V=null,j={};function W(t){r.onAbort&&r.onAbort(t),x(t="Aborted("+t+")"),E=!0;var e=new WebAssembly.RuntimeError(t);throw s(e),e}var q={error:function(){W("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init:function(){q.error()},createDataFile:function(){q.error()},createPreloadedFile:function(){q.error()},createLazyFile:function(){q.error()},open:function(){q.error()},mkdev:function(){q.error()},registerDevice:function(){q.error()},analyzePath:function(){q.error()},loadFilesFromDB:function(){q.error()},ErrnoError:function(){q.error()}};r.FS_createDataFile=q.createDataFile,r.FS_createPreloadedFile=q.createPreloadedFile;var Z,$,K,J;function Q(t){return t.startsWith("data:application/octet-stream;base64,")}function tt(t){return t.startsWith("file://")}function et(t,e){return function(){var i=t,s=e;return e||(s=r.asm),L(X,"native function `"+i+"` called before runtime initialization"),s[t]||L(s[t],"exported native function `"+i+"` not found"),s[t].apply(null,arguments)}}function it(t){try{if(t==Z&&y)return new Uint8Array(y);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){W(t)}}function st(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function rt(t){for(;t.length>0;)t.shift()(r)}function at(t){at.shown||(at.shown={}),at.shown[t]||(at.shown[t]=1,h&&(t="warning: "+t),x(t))}function nt(t){try{return v.grow(t-T.byteLength+65535>>>16),B(v.buffer),1}catch(e){x("emscripten_realloc_buffer: Attempted to grow heap from "+T.byteLength+" bytes to "+t+" bytes, but got error: "+e)}}r.locateFile?Q(Z="tinymidipcm.wasm")||($=Z,Z=r.locateFile?r.locateFile($,g):g+$):Z=new URL(i(621),i.b).toString();var ot,lt={emscripten_memcpy_big:function(t,e,i){k.copyWithin(t,e,e+i)},emscripten_resize_heap:function(t){var e=k.length;L((t>>>=0)>e);var i,s=2147483648;if(t>s)return x("Cannot enlarge memory, asked to go up to "+t+" bytes, but the limit is "+s+" bytes!"),!1;for(var r=1;r<=4;r*=2){var a=e*(1+.2/r);a=Math.min(a,t+100663296);var n=Math.min(s,(i=Math.max(t,a))+(65536-i%65536)%65536);if(nt(n))return!0}return x("Failed to grow the heap from "+e+" bytes to "+n+" bytes, not enough memory!"),!1}},ht=(function(){var t,e={env:lt,wasi_snapshot_preview1:lt};function i(t,e){var i,s=t.exports;r.asm=s,L(v=r.asm.memory,"memory not found in wasm exports"),B(v.buffer),L(r.asm.__indirect_function_table,"table not found in wasm exports"),i=r.asm.__wasm_call_ctors,G.unshift(i),function(t){if(N--,r.monitorRunDependencies&&r.monitorRunDependencies(N),t?(L(j[t]),delete j[t]):x("warning: run dependency removed without ID"),0==N&&(null!==z&&(clearInterval(z),z=null),V)){var e=V;V=null,e()}}("wasm-instantiate")}t="wasm-instantiate",N++,r.monitorRunDependencies&&r.monitorRunDependencies(N),t?(L(!j[t]),j[t]=1,null===z&&"undefined"!=typeof setInterval&&(z=setInterval((function(){if(E)return clearInterval(z),void(z=null);var t=!1;for(var e in j)t||(t=!0,x("still waiting on run dependencies:")),x("dependency: "+e);t&&x("(end of list)")}),1e4))):x("warning: run dependency added without ID");var a=r;function n(t){L(r===a,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),a=null,i(t.instance)}function c(t){return function(){if(!y&&(o||l)){if("function"==typeof fetch&&!tt(Z))return fetch(Z,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+Z+"'";return t.arrayBuffer()})).catch((function(){return it(Z)}));if(d)return new Promise((function(t,e){d(Z,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return it(Z)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),tt(Z)&&x("warning: Loading from a file URI ("+Z+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),W(t)}))}if(r.instantiateWasm)try{return r.instantiateWasm(e,i)}catch(t){x("Module.instantiateWasm callback failed with error: "+t),s(t)}(y||"function"!=typeof WebAssembly.instantiateStreaming||Q(Z)||tt(Z)||h||"function"!=typeof fetch?c(n):fetch(Z,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),c(n)}))}))).catch(s)}(),r.___wasm_call_ctors=et("__wasm_call_ctors"),r._malloc=et("malloc"),r._free=et("free"),r._tsf_load_memory=et("tsf_load_memory"),r._tsf_close=et("tsf_close"),r._tsf_reset=et("tsf_reset"),r._tsf_set_output=et("tsf_set_output"),r._tsf_set_max_voices=et("tsf_set_max_voices"),r._realloc=et("realloc"),r._tsf_channel_set_presetnumber=et("tsf_channel_set_presetnumber"),r._tsf_channel_set_bank_preset=et("tsf_channel_set_bank_preset"),r._tml_load_memory=et("tml_load_memory"),r._midi_render=et("midi_render"),r.___errno_location=et("__errno_location"),r._fflush=et("fflush"),r._emscripten_stack_init=function(){return(ht=r._emscripten_stack_init=r.asm.emscripten_stack_init).apply(null,arguments)}),ct=(r._emscripten_stack_get_free=function(){return(r._emscripten_stack_get_free=r.asm.emscripten_stack_get_free).apply(null,arguments)},r._emscripten_stack_get_base=function(){return(r._emscripten_stack_get_base=r.asm.emscripten_stack_get_base).apply(null,arguments)},r._emscripten_stack_get_end=function(){return(ct=r._emscripten_stack_get_end=r.asm.emscripten_stack_get_end).apply(null,arguments)});function ft(t){function i(){ot||(ot=!0,r.calledRun=!0,E||(L(!X),X=!0,D(),rt(G),e(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),L(!r._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(D(),r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)t=r.postRun.shift(),H.unshift(t);var t;rt(H)}()))}var s;t=t||n,N>0||(ht(),L(0==(3&(s=ct()))),O[s>>2]=34821223,O[s+4>>2]=2310721022,O[0]=1668509029,function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)t=r.preRun.shift(),U.unshift(t);var t;rt(U)}(),N>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),i()}),1)):i(),D()))}if(r.stackSave=et("stackSave"),r.stackRestore=et("stackRestore"),r.stackAlloc=et("stackAlloc"),r.setValue=function(t,e,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":case"i8":A[t>>0]=e;break;case"i16":I[t>>1]=e;break;case"i32":_[t>>2]=e;break;case"i64":J=[e>>>0,(K=e,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],_[t>>2]=J[0],_[t+4>>2]=J[1];break;case"float":P[t>>2]=e;break;case"double":M[t>>3]=e;break;case"*":O[t>>2]=e;break;default:W("invalid type for setValue: "+i)}},r.getValue=function(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":case"i8":return A[t>>0];case"i16":return I[t>>1];case"i32":case"i64":return _[t>>2];case"float":return P[t>>2];case"double":return M[t>>3];case"*":return O[t>>2];default:W("invalid type for getValue: "+e)}return null},["run","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createDataFile","FS_createPreloadedFile","FS_createLazyFile","FS_createLink","FS_createDevice","FS_unlink","getLEB","getFunctionTables","alignFunctionTables","registerFunctions","prettyPrint","getCompilerSetting","print","printErr","callMain","abort","keepRuntimeAlive","wasmMemory","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","ptrToString","zeroMemory","stringToNewUTF8","exitJS","getHeapMax","emscripten_realloc_buffer","ENV","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","getHostByName","Protocols","Sockets","getRandomDevice","warnOnce","traverseStack","UNWIND_CACHE","convertPCtoSourceLocation","readAsmConstArgsArray","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","freeTableIndexes","functionsInTableMap","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","PATH","PATH_FS","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeArrayToMemory","writeAsciiToMemory","SYSCALLS","getSocketFromFD","getSocketAddress","JSEvents","registerKeyEventCallback","specialHTMLTargets","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","currentFullscreenStrategy","restoreOldWindowedStyle","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","demangle","demangleAll","jsStackTrace","stackTrace","ExitStatus","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","dlopenMissingError","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","exception_addRef","exception_decRef","Browser","setMainLoop","wget","FS","MEMFS","TTY","PIPEFS","SOCKFS","_setNetworkCallback","tempFixedLengthArray","miniTempWebGLFloatBuffers","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","GL","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","AL","SDL_unicode","SDL_ttfContext","SDL_audio","SDL","SDL_gfx","GLUT","EGL","GLFW_Window","GLFW","GLEW","IDBStore","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(t){Object.getOwnPropertyDescriptor(r,t)||Object.defineProperty(r,t,{configurable:!0,get:function(){var e="'"+t+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";S(t)&&(e+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),W(e)}})})),["ptrToString","zeroMemory","stringToNewUTF8","exitJS","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getRandomDevice","traverseStack","convertPCtoSourceLocation","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeAsciiToMemory","getSocketFromFD","getSocketAddress","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","ExceptionInfo","exception_addRef","exception_decRef","setMainLoop","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","SDL_unicode","SDL_ttfContext","SDL_audio","GLFW_Window","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(t){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,t)||Object.defineProperty(globalThis,t,{configurable:!0,get:function(){var e="`"+t+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line";S(t)&&(e+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),at(e)}})})),V=function t(){ot||ft(),ot||(V=t)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return ft(),t.ready}),R=class{constructor(t={}){this.wasmModule=void 0,this.soundfontBufferPtr=0,this.soundfontPtr=0,this.midiBufferPtr=0,this.renderInterval=t.renderInterval||100,this.sampleRate=t.sampleRate||44100,this.channels=t.channels||2,this.gain=t.gain||0,t.bufferSize?this.bufferSize=t.bufferSize:this.setBufferDuration(1),this.onPCMData=t.onPCMData||(()=>{}),this.onRenderEnd=t.onRenderEnd||(()=>{}),this.renderTimer=void 0,this.test=0}async init(){if(!this.wasmModule){if("undefined"!=typeof process){const{dirname:t}=await import("path"),{createRequire:e}=await import("module");globalThis.__dirname=t("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js"),globalThis.require=e("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js")}this.wasmModule=await B(),this.pcmBufferPtr=this.wasmModule._malloc(this.bufferSize),this.msecsPtr=this.wasmModule._malloc(8)}}setBufferDuration(t){this.bufferSize=4*this.sampleRate*this.channels*t}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}setSoundfont(t){this.ensureInitialized();const{_malloc:e,_free:i,_tsf_load_memory:s,_tsf_set_output:r,_tsf_channel_set_bank_preset:a,_tsf_set_max_voices:n,_tsf_channel_set_presetnumber:o}=this.wasmModule;i(this.soundfontBufferPtr),this.soundfontBufferPtr=e(t.length),this.wasmModule.HEAPU8.set(t,this.soundfontBufferPtr),this.soundfontPtr=s(this.soundfontBufferPtr,t.length),r(this.soundfontPtr,2===this.channels?0:2,this.sampleRate,this.gain)}getPCMBuffer(){this.ensureInitialized();const t=new Uint8Array(this.bufferSize);return t.set(this.wasmModule.HEAPU8.subarray(this.pcmBufferPtr,this.pcmBufferPtr+this.bufferSize)),t}getMIDIMessagePtr(t){const{_malloc:e,_free:i,_tml_load_memory:s}=this.wasmModule;return i(this.midiBufferPtr),this.midiBufferPtr=e(t.length),this.wasmModule.HEAPU8.set(t,this.midiBufferPtr),s(this.midiBufferPtr,t.length)}renderMIDIMessage(t){const{_midi_render:e}=this.wasmModule;return e(this.soundfontPtr,t,this.channels,this.sampleRate,this.pcmBufferPtr,this.bufferSize,this.msecsPtr)}render(t){if(this.ensureInitialized(),!this.soundfontPtr)throw new Error("no soundfont buffer set. call .setSoundfont");window.clearTimeout(this.renderTimer);const{setValue:e,getValue:i}=this.wasmModule;e(this.msecsPtr,0,"double"),this.wasmModule._tsf_reset(this.soundfontPtr),this.wasmModule._tsf_channel_set_bank_preset(this.soundfontPtr,9,128,0),t[0]==="R".charCodeAt(0)&&(t=t.slice(20));let s=this.getMIDIMessagePtr(t);const r=()=>{s=this.renderMIDIMessage(s);const t=this.getPCMBuffer();this.onPCMData(t),s?this.renderTimer=setTimeout(r,this.renderInterval):this.onRenderEnd(i(this.msecsPtr,"double"))};this.renderTimer=setTimeout(r,16)}};!function(){window.AudioContext=window.AudioContext||window.webkitAudioContext,window.AudioContext&&(window.audioContext=new window.AudioContext);var t=function(e){if(window.audioContext){var i=window.audioContext.createBuffer(1,1,22050),s=window.audioContext.createBufferSource();s.buffer=i,s.connect(window.audioContext.destination),s.start?s.start(0):s.play?s.play(0):s.noteOn&&s.noteOn(0)}document.removeEventListener("touchstart",t),document.removeEventListener("touchend",t),document.removeEventListener("click",t)};document.addEventListener("touchstart",t),document.addEventListener("touchend",t),document.addEventListener("click",t)}(),(async()=>{let t=0,e=null,i=new Float32Array,s=window.audioContext.createGain();s.gain.value=.1,s.connect(window.audioContext.destination);let r=0,a=window.audioContext.currentTime,n=[];const o=new R({renderInterval:30,onPCMData:t=>{let e=new Float32Array(t.buffer),s=new Float32Array(i.length+e.length);s.set(i,0),s.set(e,i.length),i=s},onRenderEnd:e=>{t=Math.floor(r+Math.floor(e/1e3))},bufferSize:102400});await o.init();const l=await fetch("./SCC1_Florestan.sf2"),h=new Uint8Array(await l.arrayBuffer());function c(){if(!window.audioContext||!i.length)return;let r=window.audioContext.createBufferSource();r.onended=function(i){const s=Math.floor(window.audioContext.currentTime);t>0&&Math.abs(s-t)<=2&&(t=0,e&&window._tinyMidiPlay(e,-1))};const o=i.length/2,l=window.audioContext.createBuffer(2,o,44100);for(let t=0;t<2;t++){const e=l.getChannelData(t);let s=t;for(let t=0;t{if(f&&clearInterval(f),e=null,i=new Float32Array,n.length){let t=s.gain.value;s.gain.value=0,n.forEach((t=>{t.stop(window.audioContext.currentTime)})),n=[],s.gain.value=t}},window._tinyMidiVolume=(t=1)=>{s.gain.value=t},window._tinyMidiPlay=async(t,i=1)=>{t&&(await window._tinyMidiStop(),-1!=i&&window._tinyMidiVolume(i),e=t,r=window.audioContext.currentTime,a=window.audioContext.currentTime,f=setInterval(c,250),o.render(t))}})();class Y{static unpack=t=>{}}class D{static BASE37_LOOKUP=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];static toBase37=t=>{t=t.trim();let e=0n;for(let i=0;i=65&&s<=90?e+=BigInt(s+1-65):s>=97&&s<=122?e+=BigInt(s+1-97):s>=48&&s<=57&&(e+=BigInt(s+27-48))}return e};static fromBase37=t=>{if(t<0n||t>=6582952005840035281n)return"invalid_name";if(t%37n==0n)return"invalid_name";let e=0;const i=[0,0,0,0,0,0,0,0,0,0,0,0];for(;0n!=t;){const s=t;t/=37n,i[11-e++]=Number(this.BASE37_LOOKUP[Number(s-37n*t)])}return i.slice(12-e).join("")};static toSentenceCase=t=>{const e=[...t.toLowerCase()];let i=!0;for(let t=0;t="a"&&s<="z"&&(e[t]=s.toUpperCase(),i=!1),"."!==s&&"!"!==s||(i=!0)}return e.join("")};static toAsterisks=t=>{let e="";for(let i=0;i{if(0==t.length)return t;const e=[...t];for(let t=0;t="a"&&e[t+1]<="z"&&(e[t+1]=String.fromCharCode(e[t+1].charCodeAt(0)+"A".charCodeAt(0)-97)));return e[0]>="a"&&e[0]<="z"&&(e[0]=String.fromCharCode(e[0].charCodeAt(0)+"A".charCodeAt(0)-97)),e.join("")}}class U{static visibilityMatrix=[];static viewportLeft=0;static viewportTop=0;static viewportRight=0;static viewportBottom=0;static viewportCenterX=0;static viewportCenterY=0;static sinEyePitch=0;static cosEyePitch=0;static sinEyeYaw=0;static cosEyeYaw=0;static{this.visibilityMatrix=new Array(8);for(let t=0;t<8;t++){this.visibilityMatrix[t]=new Array(32);for(let e=0;e<32;e++){this.visibilityMatrix[t][e]=new Array(51);for(let i=0;i<51;i++)this.visibilityMatrix[t][e][i]=new Array(51).fill(!1)}}}static init=(t,e,i,s,r)=>{this.viewportLeft=0,this.viewportTop=0,this.viewportRight=t,this.viewportBottom=e,this.viewportCenterX=t/2,this.viewportCenterY=e/2;const a=new Array(9);for(let t=0;t<9;t++){a[t]=new Array(32);for(let e=0;e<32;e++){a[t][e]=new Array(53);for(let i=0;i<53;i++)a[t][e][i]=new Array(53).fill(!1)}}for(let t=128;t<=384;t+=32)for(let e=0;e<2048;e+=64){this.sinEyePitch=T.sin[t],this.cosEyePitch=T.cos[t],this.sinEyeYaw=T.sin[e],this.cosEyeYaw=T.cos[e];const n=(t-128)/32,o=e/64;for(let t=-26;t<=26;t++)for(let e=-26;e<=26;e++){const l=128*t,h=128*e;let c=!1;for(let t=-i;t<=s;t+=128)if(this.testPoint(l,h,r[n]+t)){c=!0;break}a[n][o][t+25+1][e+25+1]=c}}for(let t=0;t<8;t++)for(let e=0;e<32;e++)for(let i=-25;i<25;i++)for(let s=-25;s<25;s++){let r=!1;t:for(let n=-1;n<=1;n++)for(let o=-1;o<=1;o++){if(a[t][e][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t][(e+1)%31][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t+1][e][i+n+25+1][s+o+25+1]){r=!0;break t}if(a[t+1][(e+1)%31][i+n+25+1][s+o+25+1]){r=!0;break t}}this.visibilityMatrix[t][e][i+25][s+25]=r}};static testPoint=(t,e,i)=>{const s=e*this.sinEyeYaw+t*this.cosEyeYaw>>16,r=e*this.cosEyeYaw-t*this.sinEyeYaw>>16,a=i*this.sinEyePitch+r*this.cosEyePitch>>16,n=i*this.cosEyePitch-r*this.sinEyePitch>>16;if(a<50||a>3500)return!1;const o=this.viewportCenterX+(s<<9)/a,l=this.viewportCenterY+(n<<9)/a;return o>=this.viewportLeft&&o<=this.viewportRight&&l>=this.viewportTop&&l<=this.viewportBottom}}class G{socket;queue=[];buffer=void 0;remaining=0;offset=0;static openSocket=async t=>new Promise(((e,i)=>{const s=t.host.startsWith("https")?"wss":"ws",r=t.host.substring(t.host.indexOf("//")+2),a=new WebSocket(`${s}://${r}:${t.port}`,"binary");a.binaryType="arraybuffer",a.addEventListener("open",(()=>{console.log("connection open!"),e(a)})),a.addEventListener("error",(()=>{console.log("connection error!"),i(a)}))}));constructor(t){t.onmessage=this.onmessage,t.onclose=this.onclose,t.onerror=this.onerror,this.socket=t}get host(){return this.socket.url.split("/")[2]}get port(){return parseInt(this.socket.url.split(":")[2],10)}get available(){return this.remaining}onmessage=t=>{console.log("connection message!");const e=new Uint8Array(t.data);this.remaining+=e.length,this.queue.push(e)};onclose=t=>{console.log("connection close!")};onerror=t=>{console.log("connection error!")};write=(t,e,i)=>{if(1!==this.socket.readyState)throw new Error("Socket is not able to write!");const s=new Uint8Array(e);p(t,i,s,0,e),this.socket.send(s)};read=async()=>{if(1!==this.socket.readyState)throw new Error("Socket is not able to read!");if(this.remaining<1)return await u(5),this.read();if(this.buffer||(this.buffer=this.queue.pop(),this.buffer&&(this.offset=0)),!this.buffer)return this.read();const t=255&this.buffer[this.offset];return this.offset++,this.remaining--,this.offset===this.buffer.length&&(this.buffer=void 0),t};readBytes=async(t,e,i)=>{if(1!==this.socket.readyState)throw new Error("Socket is not able to read!");if(this.remaining<1)return await u(5),this.readBytes(t,e,i);for(let s=0;s{1===this.socket.readyState&&this.socket.close()};clear=()=>{1===this.socket.readyState&&this.socket.close(),this.queue.length=0,this.remaining=0,this.buffer=void 0,this.offset=0}}class H extends L{static HOST="https://w2.225.2004scape.org";static CHARSET="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";static MEMBERS=!0;static LOW_MEMORY=!1;SCROLLBAR_TRACK=2301979;SCROLLBAR_GRIP_FOREGROUND=5063219;SCROLLBAR_GRIP_HIGHLIGHT=7759444;SCROLLBAR_GRIP_LOWLIGHT=3353893;alreadyStarted=!1;errorStarted=!1;errorLoading=!1;errorHost=!1;loopCycle=0;ingame=!1;archiveChecksums=[];stream=null;in=e.alloc(1);out=e.alloc(1);serverSeed=0n;redrawTitleBackground=!0;titleScreenState=0;titleLoginField=0;titleArchive=null;imageTitle2=null;imageTitle3=null;imageTitle4=null;imageTitle0=null;imageTitle1=null;imageTitle5=null;imageTitle6=null;imageTitle7=null;imageTitle8=null;imageTitlebox=null;imageTitlebutton=null;loginMessage0="";loginMessage1="";username="";password="";fontPlain11=null;fontPlain12=null;fontBold12=null;fontQuill8=null;imageRunes=[];flameActive=!1;imageFlamesLeft=null;imageFlamesRight=null;flameBuffer1=[];flameBuffer0=[];flameBuffer3=[];flameBuffer2=[];flameGradient=[];flameGradient0=[];flameGradient1=[];flameGradient2=[];flameLineOffset=[];flameCycle0=0;flameGradientCycle0=0;flameGradientCycle1=0;flamesInterval=null;areaSidebar=null;areaMapback=null;areaViewport=null;areaChatback=null;areaBackbase1=null;areaBackbase2=null;areaBackhmid1=null;areaBackleft1=null;areaBackleft2=null;areaBackright1=null;areaBackright2=null;areaBacktop1=null;areaBacktop2=null;areaBackvmid1=null;areaBackvmid2=null;areaBackvmid3=null;areaBackhmid2=null;areaChatbackOffsets=null;areaSidebarOffsets=null;areaViewportOffsets=null;compassMaskLineOffsets=new Uint16Array(33);compassMaskLineLengths=new Uint16Array(33);minimapMaskLineOffsets=new Uint16Array(151);minimapMaskLineLengths=new Uint16Array(151);imageInvback=null;imageChatback=null;imageMapback=null;imageBackbase1=null;imageBackbase2=null;imageBackhmid1=null;imageSideicons=[];imageCompass=null;imageMapscene=[];imageMapfunction=[];imageHitmarks=[];imageHeadicons=[];imageMapflag=null;imageCrosses=[];imageMapdot0=null;imageMapdot1=null;imageMapdot2=null;imageMapdot3=null;imageScrollbar0=null;imageScrollbar1=null;imageRedstone1=null;imageRedstone2=null;imageRedstone3=null;imageRedstone1h=null;imageRedstone2h=null;imageRedstone1v=null;imageRedstone2v=null;imageRedstone3v=null;imageRedstone1hv=null;imageRedstone2hv=null;redrawSidebar=!1;redrawChatback=!1;redrawSideicons=!1;redrawPrivacySettings=!1;dragCycles=0;sceneState=0;sceneDelta=0;menuVisible=!1;menuArea=0;menuX=0;menuY=0;menuWidth=0;menuHeight=0;menuSize=0;menuOption=[];sidebarInterfaceId=-1;chatInterfaceId=-1;chatInterface=new _;chatScrollHeight=78;chatScrollOffset=0;modalMessage=null;flashingTab=-1;selectedTab=3;tabInterfaceId=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];publicChatSetting=0;privateChatSetting=0;tradeChatSetting=0;scrollGrabbed=!1;scrollInputPadding=0;showSocialInput=!1;socialMessage="";socialInput="";chatbackInput="";chatbackInputOpen=!1;stickyChatInterfaceId=-1;messageText=[];messageSender=[];messageType=[];splitPrivateChat=0;chatTyped="";viewportHoveredInterfaceIndex=0;sidebarHoveredInterfaceIndex=0;chatHoveredInterfaceIndex=0;objDragInterfaceId=0;objDragSlot=0;objDragArea=0;objGrabX=0;objGrabY=0;objDragCycles=0;selectedArea=0;selectedItem=0;selectedInterface=0;selectedCycle=0;pressedContinueOption=!1;runFlames=()=>{this.flameActive&&(this.updateFlames(),this.updateFlames(),this.drawFlames())};load=async()=>{if(this.alreadyStarted)this.errorStarted=!0;else{this.alreadyStarted=!0;try{await this.showProgress(10,"Connecting to fileserver");const t=new e(await g(`${H.HOST}/crc`));for(let e=0;e<9;e++)this.archiveChecksums[e]=t.g4;await this.setMidi("scape_main",12345678),this.titleArchive=await this.loadArchive("title","title screen",this.archiveChecksums[1],10),this.fontPlain11=P.fromArchive(this.titleArchive,"p11"),this.fontPlain12=P.fromArchive(this.titleArchive,"p12"),this.fontBold12=P.fromArchive(this.titleArchive,"b12"),this.fontQuill8=P.fromArchive(this.titleArchive,"q8"),await this.loadTitleBackground(),this.loadTitleImages();const i=await this.loadArchive("config","config",this.archiveChecksums[2],15),l=await this.loadArchive("interface","interface",this.archiveChecksums[3],20),h=await this.loadArchive("media","2d graphics",this.archiveChecksums[4],30),c=await this.loadArchive("models","3d graphics",this.archiveChecksums[5],40),f=await this.loadArchive("textures","textures",this.archiveChecksums[6],60),d=await this.loadArchive("wordenc","chat system",this.archiveChecksums[7],65),u=await this.loadArchive("sounds","sound effects",this.archiveChecksums[8],70);await this.showProgress(75,"Unpacking media"),this.imageInvback=S.fromArchive(h,"invback",0),this.imageChatback=S.fromArchive(h,"chatback",0),this.imageMapback=S.fromArchive(h,"mapback",0),this.imageBackbase1=S.fromArchive(h,"backbase1",0),this.imageBackbase2=S.fromArchive(h,"backbase2",0),this.imageBackhmid1=S.fromArchive(h,"backhmid1",0);for(let t=0;t<13;t++)this.imageSideicons[t]=S.fromArchive(h,"sideicons",t);this.imageCompass=w.fromArchive(h,"compass",0);try{for(let t=0;t<50;t++)this.imageMapscene[t]=S.fromArchive(h,"mapscene",t)}catch(t){}try{for(let t=0;t<50;t++)this.imageMapfunction[t]=w.fromArchive(h,"mapfunction",t)}catch(t){}try{for(let t=0;t<20;t++)this.imageHitmarks[t]=w.fromArchive(h,"hitmarks",t)}catch(t){}try{for(let t=0;t<20;t++)this.imageHeadicons[t]=w.fromArchive(h,"headicons",t)}catch(t){}this.imageMapflag=w.fromArchive(h,"mapflag",0);for(let t=0;t<8;t++)this.imageCrosses[t]=w.fromArchive(h,"cross",t);this.imageMapdot0=w.fromArchive(h,"mapdots",0),this.imageMapdot1=w.fromArchive(h,"mapdots",1),this.imageMapdot2=w.fromArchive(h,"mapdots",2),this.imageMapdot3=w.fromArchive(h,"mapdots",3),this.imageScrollbar0=S.fromArchive(h,"scrollbar",0),this.imageScrollbar1=S.fromArchive(h,"scrollbar",1),this.imageRedstone1=S.fromArchive(h,"redstone1",0),this.imageRedstone2=S.fromArchive(h,"redstone2",0),this.imageRedstone3=S.fromArchive(h,"redstone3",0),this.imageRedstone1h=S.fromArchive(h,"redstone1",0),this.imageRedstone1h?.flipHorizontally(),this.imageRedstone2h=S.fromArchive(h,"redstone2",0),this.imageRedstone2h?.flipHorizontally(),this.imageRedstone1v=S.fromArchive(h,"redstone1",0),this.imageRedstone1v?.flipVertically(),this.imageRedstone2v=S.fromArchive(h,"redstone2",0),this.imageRedstone2v?.flipVertically(),this.imageRedstone3v=S.fromArchive(h,"redstone3",0),this.imageRedstone3v?.flipVertically(),this.imageRedstone1hv=S.fromArchive(h,"redstone1",0),this.imageRedstone1hv?.flipHorizontally(),this.imageRedstone1hv?.flipVertically(),this.imageRedstone2hv=S.fromArchive(h,"redstone2",0),this.imageRedstone2hv?.flipHorizontally(),this.imageRedstone2hv?.flipVertically();const m=this.canvas,p=w.fromArchive(h,"backleft1",0);this.areaBackleft1=new O(m,p.width,p.height),p.blitOpaque(0,0);const A=w.fromArchive(h,"backleft2",0);this.areaBackleft2=new O(m,A.width,A.height),A.blitOpaque(0,0);const k=w.fromArchive(h,"backright1",0);this.areaBackright1=new O(m,k.width,k.height),k.blitOpaque(0,0);const M=w.fromArchive(h,"backright2",0);this.areaBackright2=new O(m,M.width,M.height),M.blitOpaque(0,0);const L=w.fromArchive(h,"backtop1",0);this.areaBacktop1=new O(m,L.width,L.height),L.blitOpaque(0,0);const F=w.fromArchive(h,"backtop2",0);this.areaBacktop2=new O(m,F.width,F.height),F.blitOpaque(0,0);const B=w.fromArchive(h,"backvmid1",0);this.areaBackvmid1=new O(m,B.width,B.height),B.blitOpaque(0,0);const R=w.fromArchive(h,"backvmid2",0);this.areaBackvmid2=new O(m,R.width,R.height),R.blitOpaque(0,0);const D=w.fromArchive(h,"backvmid3",0);this.areaBackvmid3=new O(m,D.width,D.height),D.blitOpaque(0,0);const G=w.fromArchive(h,"backhmid2",0);this.areaBackhmid2=new O(m,G.width,G.height),G.blitOpaque(0,0);const X=Math.trunc(21*Math.random())-10,N=Math.trunc(21*Math.random())-10,z=Math.trunc(21*Math.random())-10,V=Math.trunc(41*Math.random())-20;for(let t=0;t<50;t++)null!=this.imageMapfunction[t]&&this.imageMapfunction[t].translate(X+V,N+V,z+V),null!=this.imageMapscene[t]&&this.imageMapscene[t].translate(X+V,N+V,z+V);await this.showProgress(80,"Unpacking textures"),T.unpackTextures(f),T.setBrightness(.8),T.initPool(20),await this.showProgress(83,"Unpacking models"),I.unpack(c),s.unpack(c),r.unpack(c),await this.showProgress(86,"Unpacking config"),a.unpack(i),n.unpack(i),o.unpack(i),b.unpack(i,H.MEMBERS),y.unpack(i),v.unpack(i),x.unpack(i),C.unpack(i),H.LOW_MEMORY||(await this.showProgress(90,"Unpacking sounds"),Y.unpack(u)),await this.showProgress(92,"Unpacking interfaces"),_.unpack(l,h,[this.fontPlain11,this.fontPlain12,this.fontBold12,this.fontQuill8]),await this.showProgress(97,"Preparing game engine");for(let t=0;t<33;t++){let e=999,i=0;for(let s=0;s<35;s++)if(0==this.imageMapback.pixels[s+t*this.imageMapback.width])999==e&&(e=s);else if(999!=e){i=s;break}this.compassMaskLineOffsets[t]=e,this.compassMaskLineLengths[t]=i-e}for(let t=9;t<160;t++){let e=999,i=0;for(let s=10;s<168;s++)if(0==this.imageMapback.pixels[s+t*this.imageMapback.width]&&(s>34||t>34))999==e&&(e=s);else if(999!=e){i=s;break}this.minimapMaskLineOffsets[t-9]=e-21,this.minimapMaskLineLengths[t-9]=i-e}T.init3D(479,96),this.areaChatbackOffsets=T.lineOffset,T.init3D(190,261),this.areaSidebarOffsets=T.lineOffset,T.init3D(512,334),this.areaViewportOffsets=T.lineOffset;const j=new Int32Array(9);for(let t=0;t<9;t++){const e=32*t+128+15,i=3*e+600,s=T.sin[e];j[t]=i*s>>16}U.init(512,334,500,800,j),E.unpack(d)}catch(t){console.error(t),this.errorLoading=!0}}};update=()=>{this.errorStarted||this.errorLoading||this.errorHost||(this.loopCycle++,this.ingame?this.updateGame():this.updateTitleScreen())};draw=async()=>{this.errorStarted||this.errorLoading||this.errorHost?this.drawError():(this.ingame?this.drawGame():await this.drawTitleScreen(),this.dragCycles=0)};refresh=()=>{this.redrawTitleBackground=!0};showProgress=async(t,e)=>{console.log(`${t}%: ${e}`),await this.loadTitle(),this.titleArchive?(this.imageTitle4?.bind(),this.fontBold12?.drawStringCenter(180,54,"RuneScape is loading - please wait...",16777215),l.drawRect(28,62,304,34,9179409),l.drawRect(29,63,302,32,0),l.fillRect(30,64,3*t,30,9179409),l.fillRect(30+3*t,64,300-3*t,30,0),this.fontBold12?.drawStringCenter(180,85,e,16777215),this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.flameActive||(this.imageTitle0?.draw(0,0),this.imageTitle1?.draw(661,0)),this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186)),await u(5)):await super.showProgress(t,e)};loadTitle=async()=>{if(null===this.imageTitle2){this.drawArea=null,this.areaChatback=null,this.areaMapback=null,this.areaSidebar=null,this.areaViewport=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null;const t=this.canvas;this.imageTitle0=new O(t,128,265),l.clear(),this.imageTitle1=new O(t,128,265),l.clear(),this.imageTitle2=new O(t,533,186),l.clear(),this.imageTitle3=new O(t,360,146),l.clear(),this.imageTitle4=new O(t,360,200),l.clear(),this.imageTitle5=new O(t,214,267),l.clear(),this.imageTitle6=new O(t,215,267),l.clear(),this.imageTitle7=new O(t,86,79),l.clear(),this.imageTitle8=new O(t,87,79),l.clear(),null!==this.titleArchive&&(await this.loadTitleBackground(),this.loadTitleImages()),this.redrawTitleBackground=!0}};loadTitleBackground=async()=>{if(!this.titleArchive)return;const t=await w.fromJpeg(this.titleArchive,"title");this.imageTitle0?.bind(),t.blitOpaque(0,0),this.imageTitle1?.bind(),t.blitOpaque(-661,0),this.imageTitle2?.bind(),t.blitOpaque(-128,0),this.imageTitle3?.bind(),t.blitOpaque(-214,-386),this.imageTitle4?.bind(),t.blitOpaque(-214,-186),this.imageTitle5?.bind(),t.blitOpaque(0,-265),this.imageTitle6?.bind(),t.blitOpaque(-128,-186),this.imageTitle7?.bind(),t.blitOpaque(-128,-186),this.imageTitle8?.bind(),t.blitOpaque(-574,-186),t.flipHorizontally(),this.imageTitle0?.bind(),t.blitOpaque(394,0),this.imageTitle1?.bind(),t.blitOpaque(-267,0),this.imageTitle2?.bind(),t.blitOpaque(266,0),this.imageTitle3?.bind(),t.blitOpaque(180,-386),this.imageTitle4?.bind(),t.blitOpaque(180,-186),this.imageTitle5?.bind(),t.blitOpaque(394,-265),this.imageTitle6?.bind(),t.blitOpaque(-180,-265),this.imageTitle7?.bind(),t.blitOpaque(212,-186),this.imageTitle8?.bind(),t.blitOpaque(-180,-186);const e=w.fromArchive(this.titleArchive,"logo");this.imageTitle2?.bind(),e.draw(this.width/2-e.width/2-128,18)};updateFlameBuffer=t=>{for(let t=0;t<32768;t++)this.flameBuffer0[t]=0;for(let t=0;t<5e3;t++){const t=Math.trunc(128*Math.random()*256);this.flameBuffer0[t]=Math.trunc(256*Math.random())}for(let t=0;t<20;t++){for(let t=1;t{if(this.titleArchive){this.imageTitlebox=S.fromArchive(this.titleArchive,"titlebox"),this.imageTitlebutton=S.fromArchive(this.titleArchive,"titlebutton");for(let t=0;t<12;t++)this.imageRunes[t]=S.fromArchive(this.titleArchive,"runes",t);this.imageFlamesLeft=new w(128,265),this.imageFlamesRight=new w(128,265),this.imageTitle0&&p(this.imageTitle0.pixels,0,this.imageFlamesLeft.pixels,0,33920),this.imageTitle1&&p(this.imageTitle1.pixels,0,this.imageFlamesRight.pixels,0,33920),this.flameGradient0=[];for(let t=0;t<64;t++)this.flameGradient0[t]=262144*t;for(let t=0;t<64;t++)this.flameGradient0[t+64]=1024*t+16711680;for(let t=0;t<64;t++)this.flameGradient0[t+128]=4*t+16776960;for(let t=0;t<64;t++)this.flameGradient0[t+192]=16777215;this.flameGradient1=[];for(let t=0;t<64;t++)this.flameGradient1[t]=1024*t;for(let t=0;t<64;t++)this.flameGradient1[t+64]=4*t+65280;for(let t=0;t<64;t++)this.flameGradient1[t+128]=262144*t+65535;for(let t=0;t<64;t++)this.flameGradient1[t+192]=16777215;this.flameGradient2=[];for(let t=0;t<64;t++)this.flameGradient2[t]=4*t;for(let t=0;t<64;t++)this.flameGradient2[t+64]=262144*t+255;for(let t=0;t<64;t++)this.flameGradient2[t+128]=1024*t+16711935;for(let t=0;t<64;t++)this.flameGradient2[t+192]=16777215;this.flameGradient=[],this.flameBuffer0=[],this.flameBuffer1=[],this.updateFlameBuffer(null),this.flameBuffer3=[],this.flameBuffer2=[],this.showProgress(10,"Connecting to fileserver").then((()=>{this.flameActive||(this.flameActive=!0,this.flamesInterval=setInterval(this.runFlames,35))}))}};updateTitleScreen=()=>{if(0===this.titleScreenState){let t=this.width/2-80,e=this.height/2+20;e+=20,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.titleScreenState=3,this.titleLoginField=0),t=this.width/2+80,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.loginMessage0="",this.loginMessage1="Enter your username & password.",this.titleScreenState=2,this.titleLoginField=0)}else if(2==this.titleScreenState){let t=this.height/2-40;t+=30,t+=25,1==this.mouseClickButton&&this.mouseClickY>=t-15&&this.mouseClickY=t-15&&this.mouseClickY=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&this.login(this.username,this.password,!1).then((()=>{})),e=this.width/2+80,1==this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&(this.titleScreenState=0,this.username="",this.password="");;){const t=this.pollKey();if(-1==t)return;let e=!1;for(let i=0;i0&&(this.username=this.username.substring(0,this.username.length-1)),9!=t&&10!=t&&13!=t||(this.titleLoginField=1),e&&(this.username=this.username+String.fromCharCode(t)),this.username.length>12&&(this.username=this.username.substring(0,12))):1==this.titleLoginField&&(8==t&&this.password.length>0&&(this.password=this.password.substring(0,this.password.length-1)),9!=t&&10!=t&&13!=t||(this.titleLoginField=0),e&&(this.password=this.password+String.fromCharCode(t)),this.password.length>20&&(this.password=this.password.substring(0,20)))}}else if(3==this.titleScreenState){const t=this.width/2;let e=this.height/2+50;e+=20,1==this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=e-20&&this.mouseClickY<=e+20&&(this.titleScreenState=0)}};drawTitleScreen=async()=>{if(await this.loadTitle(),this.imageTitle4?.bind(),this.imageTitlebox?.draw(0,0),0===this.titleScreenState){let t=180,e=80;this.fontBold12?.drawStringTaggableCenter(t,e,"Welcome to RuneScape",4294967040,!0),t=100,e=120,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"New user",4294967295,!0),t=260,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Existing User",4294967295,!0)}else if(2===this.titleScreenState){let t=100,e=60;0===this.loginMessage0.length?(this.fontBold12?.drawStringTaggableCenter(180,e-15,this.loginMessage0,16776960,!0),this.fontBold12?.drawStringTaggableCenter(180,e,this.loginMessage1,16776960,!0),e+=30):(this.fontBold12?.drawStringTaggableCenter(180,e-7,this.loginMessage1,16776960,!0),e+=30),this.fontBold12?.drawStringTaggable(90,e,`Username: ${this.username}${0==this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,16777215,!0),e+=15,this.fontBold12?.drawStringTaggable(92,e,`Password: ${D.toAsterisks(this.password)}${1==this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,16777215,!0),e=150,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Login",16777215,!0),t=260,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Cancel",16777215,!0)}else if(3==this.titleScreenState){this.fontBold12?.drawStringTaggableCenter(180,16776960,"Create a free account",40,!0);const t=180;let e=65;this.fontBold12?.drawStringTaggableCenter(180,e,"To create a new account you need to",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"go back to the main RuneScape webpage",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"and choose the red 'create account'",16777215,!0),e+=15,this.fontBold12?.drawStringTaggableCenter(180,e,"button at the top right of that page.",16777215,!0),e=150,this.imageTitlebutton?.draw(t-73,e-20),this.fontBold12?.drawStringTaggableCenter(t,e+5,"Cancel",16777215,!0)}this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186))};login=async(t,e,i)=>{try{this.ingame=!0,this.stream=new G(await G.openSocket({host:H.HOST,port:43599})),await(this.stream?.readBytes(this.in.data,0,8)),this.in.pos=0,this.serverSeed=this.in.g8,this.prepareGameScreen()}catch(t){this.loginMessage0="",this.loginMessage1="Error connecting to server."}};updateGame=()=>{this.ingame&&(this.sceneDelta++,1!=this.mouseButton&&1!=this.mouseClickButton||this.dragCycles++)};drawGame=()=>{this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.areaBackleft1?.draw(0,11),this.areaBackleft2?.draw(0,375),this.areaBackright1?.draw(729,5),this.areaBackright2?.draw(752,231),this.areaBacktop1?.draw(0,0),this.areaBacktop2?.draw(561,0),this.areaBackvmid1?.draw(520,11),this.areaBackvmid2?.draw(520,231),this.areaBackvmid3?.draw(501,375),this.areaBackhmid2?.draw(0,345),this.redrawSidebar=!0,this.redrawChatback=!0,this.redrawSideicons=!0,this.redrawPrivacySettings=!0,2!=this.sceneState&&(this.areaViewport?.draw(8,11),this.areaMapback?.draw(561,5))),2==this.sceneState&&this.drawScene(),this.menuVisible&&1==this.menuArea&&(this.redrawSidebar=!0);let t=!1;if(-1!=this.sidebarInterfaceId&&(t=this.updateInterfaceAnimation(this.sidebarInterfaceId,this.sceneDelta),t&&(this.redrawSidebar=!0)),2==this.selectedArea&&(this.redrawSidebar=!0),2==this.objDragArea&&(this.redrawSidebar=!0),this.redrawSidebar&&(this.drawSidebar(),this.redrawSidebar=!1),-1==this.chatInterfaceId){this.chatInterface.scrollPosition=this.chatScrollHeight-this.chatScrollOffset-77,this.mouseX>453&&this.mouseX<565&&this.mouseY>350&&this.handleScrollInput(this.mouseX-22,this.mouseY-375,this.chatScrollHeight,77,!1,463,0,this.chatInterface);let t=this.chatScrollHeight-this.chatInterface.scrollPosition-77;t<0&&(t=0),t>this.chatScrollHeight-77&&(t=this.chatScrollHeight-77),this.chatScrollOffset!=t&&(this.chatScrollOffset=t,this.redrawChatback=!0)}-1!=this.chatInterfaceId&&(t=this.updateInterfaceAnimation(this.chatInterfaceId,this.sceneDelta),t&&(this.redrawChatback=!0)),3==this.selectedArea&&(this.redrawChatback=!0),3==this.objDragArea&&(this.redrawChatback=!0),null!=this.modalMessage&&(this.redrawChatback=!0),this.menuVisible&&2==this.menuArea&&(this.redrawChatback=!0),this.redrawChatback&&(this.drawChatback(),this.redrawChatback=!1),2==this.sceneState&&(this.drawMinimap(),this.areaMapback?.draw(561,5)),-1!=this.flashingTab&&(this.redrawSideicons=!0),this.redrawSideicons&&(this.redrawSideicons=!1,this.areaBackhmid1?.bind(),this.imageBackhmid1?.draw(0,0),-1==this.sidebarInterfaceId&&(-1!=this.tabInterfaceId[this.selectedTab]&&(0==this.selectedTab?this.imageRedstone1?.draw(29,30):1==this.selectedTab?this.imageRedstone2?.draw(59,29):2==this.selectedTab?this.imageRedstone2?.draw(87,29):3==this.selectedTab?this.imageRedstone3?.draw(115,29):4==this.selectedTab?this.imageRedstone2h?.draw(156,29):5==this.selectedTab?this.imageRedstone2h?.draw(184,29):6==this.selectedTab&&this.imageRedstone1h?.draw(212,30)),-1!=this.tabInterfaceId[0]&&(0!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[0].draw(35,34),-1!=this.tabInterfaceId[1]&&(1!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[1].draw(59,32),-1!=this.tabInterfaceId[2]&&(2!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[2].draw(86,32),-1!=this.tabInterfaceId[3]&&(3!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[3].draw(121,33),-1!=this.tabInterfaceId[4]&&(4!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[4].draw(157,34),-1!=this.tabInterfaceId[5]&&(5!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[5].draw(185,32),-1!=this.tabInterfaceId[6]&&(6!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[6].draw(212,34)),this.areaBackhmid1?.draw(520,165),this.areaBackbase2?.bind(),this.imageBackbase2?.draw(0,0),-1==this.sidebarInterfaceId&&(-1!=this.tabInterfaceId[this.selectedTab]&&(7==this.selectedTab?this.imageRedstone1v?.draw(49,0):8==this.selectedTab?this.imageRedstone2v?.draw(81,0):9==this.selectedTab?this.imageRedstone2v?.draw(108,0):10==this.selectedTab?this.imageRedstone3v?.draw(136,1):11==this.selectedTab?this.imageRedstone2hv?.draw(178,0):12==this.selectedTab?this.imageRedstone2hv?.draw(205,0):13==this.selectedTab&&this.imageRedstone1hv?.draw(233,0)),-1!=this.tabInterfaceId[8]&&(8!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[7].draw(80,2),-1!=this.tabInterfaceId[9]&&(9!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[8].draw(107,3),-1!=this.tabInterfaceId[10]&&(10!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[9].draw(142,4),-1!=this.tabInterfaceId[11]&&(11!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[10].draw(179,2),-1!=this.tabInterfaceId[12]&&(12!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[11].draw(206,2),-1!=this.tabInterfaceId[13]&&(13!=this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[12].draw(230,2)),this.areaBackbase2?.draw(501,492),this.areaViewport?.bind()),this.redrawPrivacySettings&&(this.redrawPrivacySettings=!1,this.areaBackbase1?.bind(),this.imageBackbase1?.draw(0,0),this.fontPlain12?.drawStringTaggableCenter(57,33,"Public chat",16777215,!0),0==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"On",65280,!0),1==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Friends",16776960,!0),2==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Off",16711680,!0),3==this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Hide",65535,!0),this.fontPlain12?.drawStringTaggableCenter(186,33,"Private chat",16777215,!0),0==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"On",65280,!0),1==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Friends",16776960,!0),2==this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Off",16711680,!0),this.fontPlain12?.drawStringTaggableCenter(326,33,"Trade/duel",16777215,!0),0==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"On",65280,!0),1==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Friends",16776960,!0),2==this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Off",16711680,!0),this.fontPlain12?.drawStringTaggableCenter(462,38,"Report abuse",16777215,!0),this.areaBackbase1?.draw(0,471),this.areaViewport?.bind()),this.sceneDelta=0};drawScene=()=>{};drawSidebar=()=>{};drawChatback=()=>{if(this.areaChatback?.bind(),this.areaChatbackOffsets&&(T.lineOffset=this.areaChatbackOffsets),this.imageChatback?.draw(0,0),this.showSocialInput)this.fontBold12?.drawStringCenter(239,40,this.socialMessage,0),this.fontBold12?.drawStringCenter(239,60,this.socialInput+"*",128);else if(this.chatbackInputOpen)this.fontBold12?.drawStringCenter(239,40,"Enter amount:",0),this.fontBold12?.drawStringCenter(239,60,this.chatbackInput+"*",128);else if(null!=this.modalMessage)this.fontBold12?.drawStringCenter(239,40,this.modalMessage,0),this.fontBold12?.drawStringCenter(239,60,"Click to continue",128);else if(-1!=this.chatInterfaceId)this.drawInterface(_.instances[this.chatInterfaceId],0,0,0);else if(-1==this.stickyChatInterfaceId){const t=this.fontPlain12;let e=0;l.setBounds(77,463,0,0);for(let i=0;i<100;i++)if(null!=this.messageText[i]){const s=this.messageType[i],r=this.chatScrollOffset+70-14*e;0===s&&(r>0&&r<110&&t?.drawString(4,r,this.messageText[i],0),e++),1===s&&(r>0&&r<110&&(t?.drawString(4,r,this.messageSender[i]+":",16777215),t?.drawString(t.stringWidth(this.messageSender[i])+12,r,this.messageText[i],255)),e++),2===s&&(0==this.publicChatSetting||1==this.publicChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&(t?.drawString(4,r,this.messageSender[i]+":",0),t?.drawString(t.stringWidth(this.messageSender[i])+12,r,this.messageText[i],255)),e++),3!==s&&7!==s||0!=this.splitPrivateChat||!(7==s||0==this.privateChatSetting||1==this.privateChatSetting&&this.isFriend(this.messageSender[i]))||(r>0&&r<110&&(t?.drawString(4,r,"From "+this.messageSender[i]+":",0),t?.drawString(t.stringWidth("From "+this.messageSender[i])+12,r,this.messageText[i],8388608)),e++),4===s&&(0==this.tradeChatSetting||1==this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&t?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],8388736),e++),5===s&&0==this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&t?.drawString(4,r,this.messageText[i],8388608),e++),6===s&&0==this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&(t?.drawString(4,r,"To "+this.messageSender[i]+":",0),t?.drawString(t.stringWidth("To "+this.messageSender[i])+12,r,this.messageText[i],8388608)),e++),8===s&&(0==this.tradeChatSetting||1==this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&t?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],13350793),e++)}l.resetBounds(),this.chatScrollHeight=14*e+7,this.chatScrollHeight<78&&(this.chatScrollHeight=78),this.drawScrollbar(463,0,this.chatScrollHeight-this.chatScrollOffset-77,this.chatScrollHeight,77),t?.drawString(4,90,D.formatName(this.username)+":",0),t?.drawString(t.stringWidth(this.username+": ")+6,90,this.chatTyped+"*",255),l.drawHorizontalLine(0,77,0,479)}else this.drawInterface(_.instances[this.stickyChatInterfaceId],0,0,0);this.menuVisible&&2==this.menuArea&&this.drawMenu(),this.areaChatback?.draw(22,375),this.areaViewport?.bind(),this.areaViewportOffsets&&(T.lineOffset=this.areaViewportOffsets)};drawScrollbar=(t,e,i,s,r)=>{this.imageScrollbar0?.draw(t,e),this.imageScrollbar1?.draw(t,e+r-16),l.fillRect(t,e+16,16,r-32,this.SCROLLBAR_TRACK);let a=(r-32)*r/s|0;a<8&&(a=8);const n=(r-a-32)*i/(s-r)|0;l.fillRect(t,e+n+16,16,a,this.SCROLLBAR_GRIP_FOREGROUND),l.drawVerticalLine(t,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,a),l.drawVerticalLine(t+1,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,a),l.drawHorizontalLine(t,e+n+16,this.SCROLLBAR_GRIP_HIGHLIGHT,16),l.drawHorizontalLine(t,e+n+17,this.SCROLLBAR_GRIP_HIGHLIGHT,16),l.drawVerticalLine(t+15,e+n+16,this.SCROLLBAR_GRIP_LOWLIGHT,a),l.drawVerticalLine(t+14,e+n+17,this.SCROLLBAR_GRIP_LOWLIGHT,a-1),l.drawHorizontalLine(t,e+n+a+15,this.SCROLLBAR_GRIP_LOWLIGHT,16),l.drawHorizontalLine(t+1,e+n+a+14,this.SCROLLBAR_GRIP_LOWLIGHT,15)};drawInterface=(t,e,i,s)=>{if(0!=t.type||null==t.childId||t.hide&&this.viewportHoveredInterfaceIndex!=t.id&&this.sidebarHoveredInterfaceIndex!=t.id&&this.chatHoveredInterfaceIndex!=t.id)return;const r=l.left,n=l.top,o=l.right,h=l.bottom;l.setBounds(i+t.height,e+t.width,i,e);const c=t.childId.length;for(let r=0;r0&&this.updateInterfaceContent(h),0==h.type)h.scrollPosition>h.scrollableHeight-h.height&&(h.scrollPosition=h.scrollableHeight-h.height),h.scrollPosition<0&&(h.scrollPosition=0),this.drawInterface(h,n,o,h.scrollPosition),h.scrollableHeight>h.height&&this.drawScrollbar(n+h.width,o,h.scrollPosition,h.scrollableHeight,h.height);else if(2==h.type){let t=0;for(let e=0;e0){let e=0,i=0;const a=h.inventorySlotObjId[t]-1;if(s>=-32&&s<=512&&r>=-32&&r<=334||0!=this.objDragArea&&this.objDragSlot==t){const n=b.getIcon(a,h.inventorySlotObjCount[t]);if(0!=this.objDragArea&&this.objDragSlot==t&&this.objDragInterfaceId==h.id?(e=this.mouseX-this.objGrabX,i=this.mouseY-this.objGrabY,e<5&&e>-5&&(e=0),i<5&&i>-5&&(i=0),this.objDragCycles<5&&(e=0,i=0),n.drawAlpha(128,s+e,r+i)):0!=this.selectedArea&&this.selectedItem==t&&this.selectedInterface==h.id?n.drawAlpha(128,s,r):n.draw(s,r),33==n.cropW||1!=h.inventorySlotObjCount[t]){const a=h.inventorySlotObjCount[t];this.fontPlain11?.drawString(s+e+1,r+10+i,this.formatObjCount(a),0),this.fontPlain11?.drawString(s+e,r+9+i,this.formatObjCount(a),16776960)}}}else if(null!=h.inventorySlotImage&&t<20){const e=h.inventorySlotImage[t];null!=e&&e.draw(s,r)}t++}}else if(3==h.type)h.fill?l.fillRect(n,o,h.color,h.width,h.height):l.drawRect(n,o,h.color,h.width,h.height);else if(4==h.type){const t=h.font;let e=h.color,i=h.text;if(this.chatHoveredInterfaceIndex!=h.id&&this.sidebarHoveredInterfaceIndex!=h.id&&this.viewportHoveredInterfaceIndex!=h.id||0==h.hoverColor||(e=h.hoverColor),this.executeInterfaceScript(h)&&(e=h.activeColor,h.activeText&&h.activeText.length>0&&(i=h.activeText)),6==h.optionType&&this.pressedContinueOption&&(i="Please wait...",e=h.color),!t||!i)continue;for(let s=o+t.fontHeight;i.length>0;s+=t.fontHeight){if(-1!=i.indexOf("%")){for(;;){const t=i.indexOf("%1");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,0))+i.substring(t+2)}for(;;){const t=i.indexOf("%2");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,1))+i.substring(t+2)}for(;;){const t=i.indexOf("%3");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,2))+i.substring(t+2)}for(;;){const t=i.indexOf("%4");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,3))+i.substring(t+2)}for(;;){const t=i.indexOf("%5");if(-1==t)break;i=i.substring(0,t)+this.getIntString(this.executeClientscript1(h,4))+i.substring(t+2)}}const r=i.indexOf("\\n");let a;-1!=r?(a=i.substring(0,r),i=i.substring(r+2)):(a=i,i=""),h.center?t.drawStringTaggableCenter(n+h.width/2,s,a,e,h.shadow):t.drawStringTaggable(n,s,a,e,h.shadow)}}else if(5==h.type){let t;t=this.executeInterfaceScript(h)?h.activeImage:h.image,null!=t&&t.draw(n,o)}else if(6==h.type){const t=T.centerX,e=T.centerY;T.centerX=n+h.width/2,T.centerY=o+h.height/2;const i=T.sin[h.modelPitch]*h.modelZoom>>16,s=T.cos[h.modelPitch]*h.modelZoom>>16,r=this.executeInterfaceScript(h);let l;l=r?h.activeSeqId:h.seqId;let c=null;if(-1==l)c=h.getModel(-1,-1,r);else{const t=a.instances[l];t.frames&&t.iframes&&(c=h.getModel(t.frames[h.seqFrame],t.iframes[h.seqFrame],r))}c&&c.drawSimple(0,h.modelYaw,0,h.modelPitch,0,i,s),T.centerX=t,T.centerY=e}else if(7==h.type){const t=h.font;if(!t||!h.inventorySlotObjId||!h.inventorySlotObjCount)continue;let e=0;for(let i=0;i0){const r=b.get(h.inventorySlotObjId[e]-1);let a=r.name;if((r.stackable||1!=h.inventorySlotObjCount[e])&&(a=a+" x"+this.formatObjCountTagged(h.inventorySlotObjCount[e])),!a)continue;const l=n+s*(h.inventoryMarginX+115),c=o+i*(h.inventoryMarginY+12);h.center?t.drawStringTaggableCenter(l+h.width/2,c,a,h.color,h.shadow):t.drawStringTaggable(l,c,a,h.color,h.shadow)}e++}}}l.setBounds(h,o,n,r)};drawMinimap=()=>{};drawMenu=()=>{const t=this.menuX,e=this.menuY,i=this.menuWidth,s=this.menuHeight,r=6116423;l.fillRect(t,e,i,s,r),l.fillRect(t+1,e+1,i-2,16,0),l.drawRect(t+1,e+18,i-2,s-19,0),this.fontBold12?.drawString(t+3,e+14,"Choose Option",r);let a=this.mouseX,n=this.mouseY;0==this.menuArea&&(a-=8,n-=11),1==this.menuArea&&(a-=562,n-=231),2==this.menuArea&&(a-=22,n-=375);for(let s=0;st&&ar-13&&n!1;handleScrollInput=(t,e,i,s,r,a,n,o)=>{if(this.scrollGrabbed?this.scrollInputPadding=32:this.scrollInputPadding=0,this.scrollGrabbed=!1,t>=a&&t=n&&e=a&&t=n+s-16&&e=a-this.scrollInputPadding&&t=n+16&&e0){let t=(s-32)*s/i;t<8&&(t=8);const a=e-n-t/2-16,l=s-t-32;o.scrollPosition=(i-s)*a/l,r&&(this.redrawSidebar=!0),this.scrollGrabbed=!0}};prepareGameScreen=()=>{if(null==this.areaChatback){this.unloadTitle(),this.drawArea=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null;const t=this.canvas;this.areaChatback=new O(t,479,96),this.areaMapback=new O(t,168,160),l.clear(),this.imageMapback?.draw(0,0),this.areaSidebar=new O(t,190,261),this.areaViewport=new O(t,512,334),l.clear(),this.areaBackbase1=new O(t,501,61),this.areaBackbase2=new O(t,288,40),this.areaBackhmid1=new O(t,269,66),this.redrawTitleBackground=!0}};isFriend=t=>!1;getIntString=t=>t<999999999?String(t):"*";formatObjCountTagged=t=>{let e=String(t);for(let t=e.length-3;t>0;t-=3)e=e.substring(0,t)+","+e.substring(t);return e.length>8?e="@gre@"+e.substring(0,e.length-8)+" million @whi@("+e+")":e.length>4&&(e="@cya@"+e.substring(0,e.length-4)+"K @whi@("+e+")")," "+e};formatObjCount=t=>t<1e5?String(t):t<1e7?Math.floor(t/1e3)+"K":Math.floor(t/1e6)+"M";executeClientscript1=(t,e)=>{if(null==t.scripts||e>=t.scripts.length)return-2;try{return-1}catch(t){return-1}};executeInterfaceScript=t=>{if(!t.scriptComparator||!t.scriptOperand)return!1;for(let e=0;e=s)return!1}else if(3==t.scriptComparator[e]){if(i<=s)return!1}else if(4==t.scriptComparator[e]){if(i==s)return!1}else if(i!=s)return!1}return!0};updateInterfaceContent=t=>{};unloadTitle=()=>{this.flameActive=!1,this.flamesInterval&&(clearInterval(this.flamesInterval),this.flamesInterval=null),this.imageTitlebox=null,this.imageTitlebutton=null,this.imageRunes=[],this.flameGradient=[],this.flameGradient0=[],this.flameGradient1=[],this.flameGradient2=[],this.flameBuffer0=[],this.flameBuffer1=[],this.flameBuffer3=[],this.flameBuffer2=[],this.imageFlamesLeft=null,this.imageFlamesRight=null};loadArchive=async(t,e,i,s)=>{await this.showProgress(s,`Requesting ${e}`);const r=await M.loadUrl(`${H.HOST}/${t}${i}`);return await this.showProgress(s,`Loading ${e} - 100%`),r};setMidi=async(t,i)=>{const s=new e(await g(`${H.HOST}/${t.replaceAll(" ","_")}_${i}.mid`));var r;r=m(s.data,!0,!1),window._tinyMidiPlay&&window._tinyMidiPlay(r,.75)};drawError=()=>{if(this.ctx.fillStyle="black",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.setLoopRate(1),this.errorLoading){this.flameActive=!1,this.ctx.font="bold 16px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="yellow";let t=35;this.ctx.fillText("Sorry, an error has occured whilst loading RuneScape",30,t),t+=50,this.ctx.fillStyle="white",this.ctx.fillText("To fix this try the following (in order):",30,t),t+=50,this.ctx.font="bold 12px helvetica, sans-serif",this.ctx.fillText("1: Try closing ALL open web-browser windows, and reloading",30,t),t+=30,this.ctx.fillText("2: Try clearing your web-browsers cache from tools->internet options",30,t),t+=30,this.ctx.fillText("3: Try using a different game-world",30,t),t+=30,this.ctx.fillText("4: Try rebooting your computer",30,t),t+=30,this.ctx.fillText("5: Try selecting a different version of Java from the play-game menu",30,t)}if(this.errorHost&&(this.flameActive=!1,this.ctx.font="bold 20px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="white",this.ctx.fillText("Error - unable to load game!",50,50),this.ctx.fillText("To play RuneScape make sure you play from",50,100),this.ctx.fillText("https://2004scape.org",50,150)),this.errorStarted){this.flameActive=!1,this.ctx.font="bold 13px helvetica, sans-serif",this.ctx.textAlign="left",this.ctx.fillStyle="yellow";let t=35;this.ctx.fillText("Error a copy of RuneScape already appears to be loaded",30,t),t+=50,this.ctx.fillStyle="white",this.ctx.fillText("To fix this try the following (in order):",30,t),t+=50,this.ctx.font="bold 12px helvetica, sans-serif",this.ctx.fillText("1: Try closing ALL open web-browser windows, and reloading",30,t),t+=30,this.ctx.fillText("2: Try rebooting your computer, and reloading",30,t)}};updateFlames=()=>{for(let t=10;t<117;t++)Math.trunc(100*Math.random())<50&&(this.flameBuffer3[t+32512]=255);for(let t=0;t<100;t++){const t=Math.trunc(124*Math.random()+2)+(Math.trunc(128*Math.random()+128)<<7);this.flameBuffer3[t]=192}for(let t=1;t<255;t++)for(let e=1;e<127;e++){const i=e+(t<<7);this.flameBuffer2[i]=(this.flameBuffer3[i-1]+this.flameBuffer3[i+1]+this.flameBuffer3[i-128]+this.flameBuffer3[i+128])/4|0}if(this.flameCycle0+=128,this.flameCycle0>32768){this.flameCycle0-=32768;const t=Math.trunc(12*Math.random());this.updateFlameBuffer(this.imageRunes[t])}for(let t=1;t<255;t++)for(let e=1;e<127;e++){const i=e+(t<<7);let s=this.flameBuffer2[i+128]-this.flameBuffer0[i+this.flameCycle0&32767]/5|0;s<0&&(s=0),this.flameBuffer3[i]=s}for(let t=0;t<255;t++)this.flameLineOffset[t]=this.flameLineOffset[t+1];if(this.flameLineOffset[255]=16*Math.sin(this.loopCycle/14)+14*Math.sin(this.loopCycle/15)+12*Math.sin(this.loopCycle/16)|0,this.flameGradientCycle0>0&&(this.flameGradientCycle0-=4),this.flameGradientCycle1>0&&(this.flameGradientCycle1-=4),0==this.flameGradientCycle0&&0==this.flameGradientCycle1){const t=Math.trunc(2e3*Math.random());0==t?this.flameGradientCycle0=1024:1==t&&(this.flameGradientCycle1=1024)}};mix=(t,e,i)=>{const s=256-e;return((16711935&t)*s+(16711935&i)*e&4278255360)+((65280&t)*s+(65280&i)*e&16711680)>>8};drawFlames=()=>{const t=256;if(this.flameGradientCycle0>0)for(let t=0;t<256;t++)this.flameGradientCycle0>768?this.flameGradient[t]=this.mix(this.flameGradient0[t],1024-this.flameGradientCycle0,this.flameGradient1[t]):this.flameGradientCycle0>256?this.flameGradient[t]=this.flameGradient1[t]:this.flameGradient[t]=this.mix(this.flameGradient1[t],256-this.flameGradientCycle0,this.flameGradient0[t]);else if(this.flameGradientCycle1>0)for(let t=0;t<256;t++)this.flameGradientCycle1>768?this.flameGradient[t]=this.mix(this.flameGradient0[t],1024-this.flameGradientCycle1,this.flameGradient2[t]):this.flameGradientCycle1>256?this.flameGradient[t]=this.flameGradient2[t]:this.flameGradient[t]=this.mix(this.flameGradient2[t],256-this.flameGradientCycle1,this.flameGradient0[t]);else for(let t=0;t<256;t++)this.flameGradient[t]=this.flameGradient0[t];for(let t=0;t<33920;t++)this.imageTitle0&&this.imageFlamesLeft&&(this.imageTitle0.pixels[t]=this.imageFlamesLeft.pixels[t]);let e=0,i=1152;for(let s=1;s<255;s++){let r=22+(this.flameLineOffset[s]*(t-s)/t|0);r<0&&(r=0),e+=r;for(let t=r;t<128;t++){let t=0|this.flameBuffer3[e++];if(0==t)i++;else{const e=t,s=256-t;if(t=this.flameGradient[t],this.imageTitle0){const r=this.imageTitle0.pixels[i];this.imageTitle0.pixels[i++]=((16711935&t)*e+(16711935&r)*s&4278255360)+((65280&t)*e+(65280&r)*s&16711680)>>8}}}i+=r}this.imageTitle0?.draw(0,0);for(let t=0;t<33920;t++)this.imageTitle1&&this.imageFlamesRight&&(this.imageTitle1.pixels[t]=this.imageFlamesRight.pixels[t]);e=0,i=1176;for(let s=1;s<255;s++){const r=this.flameLineOffset[s]*(t-s)/t|0,a=103-r;i+=r;for(let t=0;t>8}}}e+=128-a,i+=128-a-r}this.imageTitle1?.draw(661,0)}}(new H).run().then((()=>{}))})()})(); \ No newline at end of file