@gjsify/example-dom-excalibur-jelly-jumper 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gjs.js +2 -2
- package/package.json +7 -7
package/dist/gjs.js
CHANGED
|
@@ -6,7 +6,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,globalThis.process===void 0){l
|
|
|
6
6
|
`)}\r\n`);else{let e=X instanceof File$1?X:new File$1([X],`blob`,{type:X.type});W.push(`${Y}${escape(R)}"; filename="${escape(e.name)}"\r\nContent-Type: ${e.type||`application/octet-stream`}\r\n\r\n`),W.push(e),W.push(`\r
|
|
7
7
|
`)}return W.push(`--${R}--`),new Blob(W,{type:`multipart/form-data; boundary=${R}`})}var Ju=__esmMin(()=>{qu()});function normalizeValue(e,R,W){return typeof R==`string`?R:(R instanceof Blob&&!(R instanceof File$1)&&(R=new File$1([R],W??`blob`,{type:R.type})),R instanceof File$1&&W!==void 0&&(R=new File$1([R],W,{type:R.type,lastModified:R.lastModified})),R)}var Yu,FormData,Xu=__esmMin(()=>{qu(),Yu=Symbol(`FormData.entries`),FormData=class{[Yu]=[];constructor(){}append(e,R,W){this[Yu].push({name:String(e),value:normalizeValue(e,R,W)})}delete(e){let R=String(e);this[Yu]=this[Yu].filter(e=>e.name!==R)}get(e){let R=String(e),W=this[Yu].find(e=>e.name===R);return W?W.value:null}getAll(e){let R=String(e);return this[Yu].filter(e=>e.name===R).map(e=>e.value)}has(e){let R=String(e);return this[Yu].some(e=>e.name===R)}set(e,R,W){let Y=String(e),X=normalizeValue(Y,R,W),ie=!1;this[Yu]=this[Yu].filter(e=>e.name===Y?ie?!1:(ie=!0,e.value=X,!0):!0),ie||this[Yu].push({name:Y,value:X})}forEach(e,R){for(let W of this[Yu])e.call(R,W.value,W.name,this)}*entries(){for(let e of this[Yu])yield[e.name,e.value]}*keys(){for(let e of this[Yu])yield e.name}*values(){for(let e of this[Yu])yield e.value}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`FormData`}}}),Zu=__esmMin(()=>{Ju(),Xu()}),Qu=__exportAll$1({toFormData:()=>toFormData});function _fileName(e){let R=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!R)return;let W=R[2]||R[3]||``,Y=W.slice(W.lastIndexOf(`\\`)+1);return Y=Y.replace(/%22/g,`"`),Y=Y.replace(/&#(\d{4});/g,(e,R)=>String.fromCharCode(R)),Y}async function toFormData(e,R){if(!/multipart/i.test(R))throw TypeError(`Failed to fetch`);let W=R.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!W)throw TypeError(`no or bad content-type header, no multipart boundary`);let Y=new MultipartParser(W[1]||W[2]),X,ie,ae,le,_e,ye,be=[],Ce=new FormData,onPartData=e=>{ae+=Te.decode(e,{stream:!0})},appendToFile=e=>{be.push(e)},appendFileToFormData=()=>{let e=new qe(be,ye,{type:_e});Ce.append(le,e)},appendEntryToFormData=()=>{Ce.append(le,ae)},Te=new TextDecoder(`utf-8`);Te.decode(),Y.onPartBegin=function(){Y.onPartData=onPartData,Y.onPartEnd=appendEntryToFormData,X=``,ie=``,ae=``,le=``,_e=``,ye=null,be.length=0},Y.onHeaderField=function(e){X+=Te.decode(e,{stream:!0})},Y.onHeaderValue=function(e){ie+=Te.decode(e,{stream:!0})},Y.onHeaderEnd=function(){if(ie+=Te.decode(),X=X.toLowerCase(),X===`content-disposition`){let e=ie.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(le=e[2]||e[3]||``),ye=_fileName(ie),ye&&(Y.onPartData=appendToFile,Y.onPartEnd=appendFileToFormData)}else X===`content-type`&&(_e=ie);ie=``,X=``};for await(let R of e)Y.write(R);return Y.end(),Ce}var $u,ed,td,lower,noop,MultipartParser,nd=__esmMin(()=>{Zu(),$u=function(e){return e[e.START_BOUNDARY=0]=`START_BOUNDARY`,e[e.HEADER_FIELD_START=1]=`HEADER_FIELD_START`,e[e.HEADER_FIELD=2]=`HEADER_FIELD`,e[e.HEADER_VALUE_START=3]=`HEADER_VALUE_START`,e[e.HEADER_VALUE=4]=`HEADER_VALUE`,e[e.HEADER_VALUE_ALMOST_DONE=5]=`HEADER_VALUE_ALMOST_DONE`,e[e.HEADERS_ALMOST_DONE=6]=`HEADERS_ALMOST_DONE`,e[e.PART_DATA_START=7]=`PART_DATA_START`,e[e.PART_DATA=8]=`PART_DATA`,e[e.END=9]=`END`,e}($u||{}),ed=1,td={PART_BOUNDARY:ed,LAST_BOUNDARY:ed*=2},lower=e=>e|32,noop=(...e)=>{},MultipartParser=class{index=0;flags=0;boundary;lookbehind;state=0;onHeaderEnd=noop;onHeaderField=noop;onHeadersEnd=noop;onHeaderValue=noop;onPartBegin=noop;onPartData=noop;onPartEnd=noop;boundaryChars={};constructor(e){e=`\r
|
|
8
8
|
--`+e;let R=new Uint8Array(e.length);for(let W=0;W<e.length;W++)R[W]=e.charCodeAt(W),this.boundaryChars[R[W]]=!0;this.boundary=R,this.lookbehind=new Uint8Array(this.boundary.length+8)}write(e){let R=0,W=e.length,Y=this.index,{lookbehind:X,boundary:ie,boundaryChars:ae,index:le,state:_e,flags:ye}=this,be=this.boundary.length,Ce=be-1,Te=e.length,Oe,Ae,mark=e=>{this[e+`Mark`]=R},clear=e=>{delete this[e+`Mark`]},callback=(e,R,W,Y)=>{(R===void 0||R!==W)&&this[e](Y&&Y.subarray(R,W))},dataCallback=(W,Y=!1)=>{let X=W+`Mark`;X in this&&(Y?(callback(W,this[X],R,e),delete this[X]):(callback(W,this[X],e.length,e),this[X]=0))};for(R=0;R<W;R++)switch(Oe=e[R],_e){case 0:if(le===ie.length-2){if(Oe===45)ye|=td.LAST_BOUNDARY;else if(Oe!==13)return;le++;break}else if(le-1==ie.length-2){if(ye&td.LAST_BOUNDARY&&Oe===45)_e=9,ye=0;else if(!(ye&td.LAST_BOUNDARY)&&Oe===10)le=0,callback(`onPartBegin`),_e=1;else return;break}Oe!==ie[le+2]&&(le=-2),Oe===ie[le+2]&&le++;break;case 1:_e=2,mark(`onHeaderField`),le=0;case 2:if(Oe===13){clear(`onHeaderField`),_e=6;break}if(le++,Oe===45)break;if(Oe===58){if(le===1)return;dataCallback(`onHeaderField`,!0),_e=3;break}if(Ae=lower(Oe),Ae<97||Ae>122)return;break;case 3:if(Oe===32)break;mark(`onHeaderValue`),_e=4;case 4:Oe===13&&(dataCallback(`onHeaderValue`,!0),callback(`onHeaderEnd`),_e=5);break;case 5:if(Oe!==10)return;_e=1;break;case 6:if(Oe!==10)return;callback(`onHeadersEnd`),_e=7;break;case 7:_e=8,mark(`onPartData`);case 8:if(Y=le,le===0){for(R+=Ce;R<Te&&!(e[R]in ae);)R+=be;R-=Ce,Oe=e[R]}if(le<ie.length)ie[le]===Oe?(le===0&&dataCallback(`onPartData`,!0),le++):le=0;else if(le===ie.length)le++,Oe===13?ye|=td.PART_BOUNDARY:Oe===45?ye|=td.LAST_BOUNDARY:le=0;else if(le-1===ie.length)if(ye&td.PART_BOUNDARY){if(le=0,Oe===10){ye&=~td.PART_BOUNDARY,callback(`onPartEnd`),callback(`onPartBegin`),_e=1;break}}else ye&td.LAST_BOUNDARY&&Oe===45?(callback(`onPartEnd`),_e=9,ye=0):le=0;if(le>0)X[le-1]=Oe;else if(Y>0){let e=new Uint8Array(X.buffer,X.byteOffset,X.byteLength);callback(`onPartData`,0,Y,e),Y=0,mark(`onPartData`),R--}break;case 9:break;default:throw Error(`Unexpected state entered: ${_e}`)}dataCallback(`onHeaderField`),dataCallback(`onHeaderValue`),dataCallback(`onPartData`),this.index=le,this.state=_e,this.flags=ye}end(){if(this.state===1&&this.index===0||this.state===8&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==9)throw Error(`MultipartParser.end(): stream ended unexpectedly`)}}});bt(),zu(),Uu(),Ja(),mu(),Zu(),__name((e,R)=>new Promise((W,Y)=>{pipeline(e,R,e=>{e?Y(e):W()})}),`pipeline`);const rd=Symbol(`Body internals`);function isAnyArrayBuffer(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}var Body=class{[rd]={body:null,stream:null,boundary:``,disturbed:!1,error:null};size=0;constructor(e,R={size:0}){if(this.size=R.size||0,e==null)this[rd].body=null;else if(isURLSearchParameters(e))this[rd].body=Ka.from(e.toString());else if(isBlob(e))this[rd].body=e;else if(Ka.isBuffer(e))this[rd].body=e;else if(isAnyArrayBuffer(e))this[rd].body=Ka.from(e);else if(ArrayBuffer.isView(e))this[rd].body=Ka.from(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof cu)this[rd].body=e;else if(typeof ReadableStream<`u`&&e instanceof ReadableStream)this[rd].body=readableStreamToReadable(e);else if(e instanceof FormData){let R=formDataToBlob(e);this[rd].body=R,this[rd].boundary=R.type?.split(`boundary=`)?.[1]??``}else typeof e==`string`?this[rd].body=Ka.from(e):e instanceof ms?this[rd].body=Ka.from(e.toString()):(yt.warn(`Unknown body type "${typeof e}", try to parse the body to string!`),this[rd].body=Ka.from(String(e)));let W=this[rd].body;Ka.isBuffer(W)?this[rd].stream=cu.from(W):isBlob(W)?this[rd].stream=cu.from(blobToAsyncIterable(W)):W instanceof cu&&(this[rd].stream=W),W instanceof su&&W.on(`error`,e=>{let R=e instanceof FetchBaseError?e:new FetchError(`Invalid response body while trying to fetch ${this.url}: ${e.message}`,`system`,e);this[rd].error=R})}get body(){let e=this[rd].stream;if(!e)return null;if(typeof ReadableStream<`u`){let R=!1;return new ReadableStream({start(W){e.on(`data`,e=>{if(!R)try{W.enqueue(e instanceof Uint8Array?e:new Uint8Array(e))}catch{}}),e.on(`end`,()=>{if(!R){R=!0;try{W.close()}catch{}}}),e.on(`error`,e=>{if(!R){R=!0;try{W.error(e)}catch{}}})},cancel(){R=!0,e.destroy()}})}return null}get _stream(){return this[rd].stream}get _rawBodyBuffer(){let e=this[rd].body;return e===null?null:Ka.isBuffer(e)?e:e instanceof Uint8Array?Ka.from(e.buffer,e.byteOffset,e.byteLength):null}get bodyUsed(){return this[rd].disturbed}async arrayBuffer(){let{buffer:e,byteOffset:R,byteLength:W}=await consumeBody(this);return e.slice(R,R+W)}async formData(){let e=this.headers?.get(`content-type`);if(e?.startsWith(`application/x-www-form-urlencoded`)){let e=new FormData,R=new ms(await this.text());for(let[W,Y]of R)e.append(W,Y);return e}let{toFormData:R}=await Promise.resolve().then(()=>(nd(),Qu));return R(this.body,e)}async blob(){let e=this.headers?.get(`content-type`)||this[rd].body&&this[rd].body.type||``;return new Ke([await this.arrayBuffer()],{type:e})}async json(){let e=await this.text();return JSON.parse(e)}async text(){let e=await consumeBody(this);return new TextDecoder().decode(e)}};Object.defineProperties(Body.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});async function consumeBody(e){if(e[rd].disturbed)throw TypeError(`body used already for: ${e.url}`);if(e[rd].disturbed=!0,e[rd].error)throw e[rd].error;let{_stream:R}=e;if(R===null||!(R instanceof su))return Ka.alloc(0);let W=[],Y=0;try{for await(let X of R){if(e.size>0&&Y+X.length>e.size){let W=new FetchError(`content size at ${e.url} over limit: ${e.size}`,`max-size`);throw R.destroy(W),W}Y+=X.length,W.push(X)}}catch(R){let W=R instanceof Error?R:Error(String(R));throw R instanceof FetchBaseError?R:new FetchError(`Invalid response body while trying to fetch ${e.url}: ${W.message}`,`system`,W)}try{return W.every(e=>typeof e==`string`)?Ka.from(W.join(``)):Ka.concat(W,Y)}catch(R){let W=R instanceof Error?R:Error(String(R));throw new FetchError(`Could not create Buffer from response body for ${e.url}: ${W.message}`,`system`,W)}}const clone=(e,R)=>{let W,Y,{body:X}=e[rd];if(e.bodyUsed)throw Error(`cannot clone body after it is used`);return X instanceof su&&typeof X.getBoundary!=`function`&&(W=new fu({highWaterMark:R}),Y=new fu({highWaterMark:R}),X.pipe(W),X.pipe(Y),e[rd].stream=W,X=Y),X},extractContentType=(e,R)=>e===null?null:typeof e==`string`?`text/plain;charset=UTF-8`:isURLSearchParameters(e)?`application/x-www-form-urlencoded;charset=UTF-8`:isBlob(e)?e.type||null:Ka.isBuffer(e)||isAnyArrayBuffer(e)||ArrayBuffer.isView(e)?null:e instanceof FormData?`multipart/form-data; boundary=${R[rd].boundary}`:e instanceof su?null:`text/plain;charset=UTF-8`,getTotalBytes=e=>{let{body:R}=e[rd];if(R===null)return 0;if(isBlob(R))return R.size;if(Ka.isBuffer(R))return R.length;if(R&&typeof R.getLengthSync==`function`){let e=R;return e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null}return null};function readableStreamToReadable(e){let R=e.getReader();return new cu({async read(){try{let{done:e,value:W}=await R.read();e?this.push(null):this.push(Ka.from(W))}catch(e){this.destroy(e)}},destroy(e,W){R.cancel().then(()=>W(null),W)}})}async function*blobToAsyncIterable(e){if(typeof e.stream==`function`){let R=e.stream().getReader();for(;;){let{done:e,value:W}=await R.read();if(e)break;yield W}}else yield new Uint8Array(await e.arrayBuffer())}const id=new Set([301,302,303,307,308]),isRedirect=e=>id.has(e);$e(),st();const ad=Symbol(`Response internals`);var od=class Response extends Body{[ad];_inputStream=null;constructor(e=null,R={}){super(e,R);let W=R.status==null?200:R.status,Y=new Hu(R.headers);if(e!==null&&!Y.has(`Content-Type`)){let R=extractContentType(e,this);R&&Y.append(`Content-Type`,R)}this[ad]={type:`default`,url:R.url,status:W,statusText:R.statusText||``,headers:Y,counter:R.counter,highWaterMark:R.highWaterMark}}get type(){return this[ad].type}get url(){return this[ad].url||``}get status(){return this[ad].status}get ok(){return this[ad].status>=200&&this[ad].status<300}get redirected(){return this[ad].counter>0}get statusText(){return this[ad].statusText}get headers(){return this[ad].headers}get highWaterMark(){return this[ad].highWaterMark}clone(){return new Response(clone(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,R=302){if(!isRedirect(R))throw RangeError(`Failed to execute "redirect" on "response": Invalid status code`);return new Response(null,{headers:{location:new hs(e).toString()},status:R})}static error(){let e=new Response(null,{status:0,statusText:``});return e[ad].type=`error`,e}static json(e,R){let W=JSON.stringify(e),Y={...R},X=new Hu(Y.headers);return X.has(`content-type`)||X.set(`content-type`,`application/json`),Y.headers=X,new Response(W,Y)}get[Symbol.toStringTag](){return`Response`}async text(){if(!this._inputStream)return super.text();let e=at.MemoryOutputStream.new_resizable();await new Promise((R,W)=>{e.splice_async(this._inputStream,at.OutputStreamSpliceFlags.CLOSE_TARGET|at.OutputStreamSpliceFlags.CLOSE_SOURCE,Qe.PRIORITY_DEFAULT,null,(Y,X)=>{try{R(e.splice_finish(X))}catch(e){W(e)}})});let R=e.steal_as_bytes();return new TextDecoder().decode(R.toArray())}};Object.defineProperties(od.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),mu(),$e(),Vt();async function soupSendAsync(e,R,W=Qe.PRIORITY_DEFAULT,Y=null){return new Promise((X,ie)=>{e.send_async(R,W,Y,(R,W)=>{try{X(e.send_finish(W))}catch(e){ie(e)}})})}function inputStreamToReadable(e,R={}){return cu.from(inputStreamAsyncIterator(e),R)}st(),$e(),mu(),Vt(),st(),Vt(),cs(),st();function isIP(e){if(typeof e!=`string`)return 0;let R=e.includes(`%`)?e.split(`%`)[0]:e,W=at.InetAddress.new_from_string(R);if(!W)return 0;switch(W.get_family()){case at.SocketFamily.INVALID:return 0;case at.SocketFamily.IPV4:return 4;case at.SocketFamily.IPV6:return 6}}function stripURLForUseAsAReferrer(e,R=!1){if(e==null||e===`no-referrer`)return`no-referrer`;let W=new hs(e);return/^(about|blob|data):$/.test(W.protocol)?`no-referrer`:(W.username=``,W.password=``,W.hash=``,R&&(W.pathname=``,W.search=``),W)}const sd=new Set([``,`no-referrer`,`no-referrer-when-downgrade`,`same-origin`,`origin`,`strict-origin`,`origin-when-cross-origin`,`strict-origin-when-cross-origin`,`unsafe-url`]);function validateReferrerPolicy(e){if(!sd.has(e))throw TypeError(`Invalid referrerPolicy: ${e}`);return e}function isOriginPotentiallyTrustworthy(e){if(/^(http|ws)s:$/.test(e.protocol))return!0;let R=e.host.replace(/(^\[)|(]$)/g,``),W=isIP(R);return W===4&&R.startsWith(`127.`)||W===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(R)?!0:e.host===`localhost`||e.host.endsWith(`.localhost`)?!1:e.protocol===`file:`}function isUrlPotentiallyTrustworthy(e){return/^about:(blank|srcdoc)$/.test(e.toString())||(typeof e==`string`&&(e=new hs(e)),e.protocol===`data:`)||/^(blob|filesystem):$/.test(e.protocol)?!0:isOriginPotentiallyTrustworthy(e)}function determineRequestsReferrer(e,R={}){let{referrerURLCallback:W,referrerOriginCallback:Y}=R;if(e.referrer===`no-referrer`||e.referrerPolicy===``)return null;let X=e.referrerPolicy;if(e.referrer===`about:client`)return`no-referrer`;let ie=new hs(e.referrer),ae=stripURLForUseAsAReferrer(ie),le=stripURLForUseAsAReferrer(ie,!0);ae.toString().length>4096&&(ae=le),W&&(ae=W(ae)),Y&&(le=Y(le));let _e=new hs(e.url);switch(X){case`no-referrer`:return`no-referrer`;case`origin`:return le;case`unsafe-url`:return ae;case`strict-origin`:return isUrlPotentiallyTrustworthy(ae)&&!isUrlPotentiallyTrustworthy(_e)?`no-referrer`:le.toString();case`strict-origin-when-cross-origin`:return ae.origin===_e.origin?ae:isUrlPotentiallyTrustworthy(ae)&&!isUrlPotentiallyTrustworthy(_e)?`no-referrer`:le;case`same-origin`:return ae.origin===_e.origin?ae:`no-referrer`;case`origin-when-cross-origin`:return ae.origin===_e.origin?ae:le;case`no-referrer-when-downgrade`:return isUrlPotentiallyTrustworthy(ae)&&!isUrlPotentiallyTrustworthy(_e)?`no-referrer`:ae;default:throw TypeError(`Invalid referrerPolicy: ${X}`)}}function parseReferrerPolicyFromHeader(e){let R=(e.get(`referrer-policy`)||``).split(/[,\s]+/),W=``;for(let e of R)e&&sd.has(e)&&(W=e);return W}$e(),st();const cd=Symbol(`Request internals`);let ld=null;function envPositiveInt(e,R){let W=Qe.getenv(e);if(!W)return R;let Y=Number.parseInt(W,10);return Number.isFinite(Y)&&Y>0?Y:R}function getSharedSession(){if(ld===null){let e=envPositiveInt(`GJSIFY_FETCH_MAX_CONNS_PER_HOST`,16),R=Math.max(envPositiveInt(`GJSIFY_FETCH_MAX_CONNS`,64),e);ld=new Bu.Session({maxConns:R,maxConnsPerHost:e});try{ld.remove_feature_by_type(Bu.ContentDecoder.$gtype)}catch{}}return ld}const isRequest=e=>typeof e==`object`&&typeof e.url==`string`;var ud=class Request extends Body{cache;credentials;destination;get headers(){return this[cd].headers}integrity;keepalive;get method(){return this[cd].method}mode;get redirect(){return this[cd].redirect}get referrer(){if(this[cd].referrer===`no-referrer`)return``;if(this[cd].referrer===`client`)return`about:client`;if(this[cd].referrer)return this[cd].referrer.toString()}get referrerPolicy(){return this[cd].referrerPolicy}set referrerPolicy(e){this[cd].referrerPolicy=validateReferrerPolicy(e)}get signal(){return this[cd].signal}get url(){return this[cd].parsedURL.toString()}get _uri(){return Qe.Uri.parse(this.url,Qe.UriFlags.ENCODED)}get _session(){return this[cd].session}get _message(){return this[cd].message}get _inputStream(){return this[cd].inputStream}get[Symbol.toStringTag](){return`Request`}[cd];follow;compress=!1;counter=0;agent=``;highWaterMark=16384;insecureHTTPParser=!1;constructor(e,R){let W=e,Y=R||{},X,ie={};if(isRequest(e)?(X=new hs(W.url),ie=W):X=new hs(e),X.username!==``||X.password!==``)throw TypeError(`${X} is an url with embedded credentials.`);let ae=Y.method||ie.method||`GET`;if(/^(delete|get|head|options|post|put)$/i.test(ae)&&(ae=ae.toUpperCase()),(R?.body!=null||isRequest(e)&&W.body!==null)&&(ae===`GET`||ae===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body`);let le=R?.body?R.body:isRequest(e)&&W.body!==null?clone(e):null;super(le,{size:Y.size||0});let _e=new Hu(R?.headers||W.headers||{});if(le!==null&&!_e.has(`Content-Type`)){let e=extractContentType(le,this);e&&_e.set(`Content-Type`,e)}let ye=isRequest(e)?W.signal:null;if(R&&`signal`in R&&(ye=R.signal),ye!=null&&!isAbortSignal(ye))throw TypeError(`Expected signal to be an instanceof AbortSignal or EventTarget`);let be=R?.referrer==null?W.referrer:R.referrer;if(be===``)be=`no-referrer`;else if(be){let e=new hs(be);be=/^about:(\/\/)?client$/.test(e.toString())?`client`:e}else be=void 0;let Ce=X.protocol,Te=null,Oe=null;(Ce===`http:`||Ce===`https:`)&&(Te=getSharedSession(),Oe=new Bu.Message({method:ae,uri:Qe.Uri.parse(X.toString(),Qe.UriFlags.ENCODED)})),this[cd]={method:ae,redirect:R?.redirect||W.redirect||`follow`,headers:_e,parsedURL:X,signal:ye,referrer:be,referrerPolicy:``,session:Te,message:Oe},this.follow=Y.follow===void 0?W.follow===void 0?20:W.follow:Y.follow,this.compress=Y.compress===void 0?W.compress===void 0?!0:W.compress:Y.compress,this.counter=Y.counter||W.counter||0,this.agent=Y.agent||W.agent,this.highWaterMark=Y.highWaterMark||W.highWaterMark||16384,this.insecureHTTPParser=Y.insecureHTTPParser||W.insecureHTTPParser||!1,this.referrerPolicy=R?.referrerPolicy||W.referrerPolicy||``}async _send(e){let{session:R,message:W}=this[cd];if(!R||!W)throw Error(`Cannot send request: no Soup session (non-HTTP URL?)`);e.headers._appendToSoupMessage(W);let Y=this._rawBodyBuffer;if(Y!==null&&Y.byteLength>0){let R=e.headers.get(`content-type`)||null;W.set_request_body_from_bytes(R,new Qe.Bytes(Y))}let X=new at.Cancellable;return this[cd].inputStream=await soupSendAsync(R,W,Qe.PRIORITY_DEFAULT,X),this[cd].readable=inputStreamToReadable(this[cd].inputStream),{inputStream:this[cd].inputStream,readable:this[cd].readable,cancellable:X}}clone(){return new Request(this)}async arrayBuffer(){return super.arrayBuffer()}async blob(){return super.blob()}async formData(){return super.formData()}async json(){return super.json()}async text(){return super.text()}};Object.defineProperties(ud.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});const getSoupRequestOptions=e=>{let{parsedURL:R}=e[cd],W=new Hu(e[cd].headers);W.has(`Accept`)||W.set(`Accept`,`*/*`);let Y=null;if(e.body===null&&/^(post|put)$/i.test(e.method)&&(Y=`0`),e.body!==null){let R=getTotalBytes(e);typeof R==`number`&&!Number.isNaN(R)&&(Y=String(R))}Y&&W.set(`Content-Length`,Y),e.referrerPolicy===``&&(e.referrerPolicy=`strict-origin-when-cross-origin`),e.referrer&&e.referrer!==`no-referrer`?e[cd].referrer=determineRequestsReferrer(e):e[cd].referrer=`no-referrer`,e[cd].referrer instanceof hs&&W.set(`Referer`,e.referrer),W.has(`User-Agent`)||W.set(`User-Agent`,`gjsify-fetch`),e.compress&&!W.has(`Accept-Encoding`)&&W.set(`Accept-Encoding`,`gzip, deflate`);let{agent:X}=e;return typeof X==`function`&&(X=X(R)),!W.has(`Connection`)&&!X&&W.set(`Connection`,`close`),{parsedURL:R,options:{headers:W}}};function parseDataUri(e){let R=e.match(/^data:([^,]*?)(;base64)?,(.*)$/s);if(!R)throw TypeError(`Invalid data URI: ${e.slice(0,50)}...`);let W=R[1]||`text/plain;charset=US-ASCII`,Y=!!R[2],X=R[3],ie;if(Y){let e=atob(X);ie=new Uint8Array(e.length);for(let R=0;R<e.length;R++)ie[R]=e.charCodeAt(R)}else ie=new TextEncoder().encode(decodeURIComponent(X));return{buffer:ie,typeFull:W}}var AbortError=class extends FetchBaseError{constructor(e,R=`aborted`){super(e,R)}};let dd=0;function guessBlobExt(e){let R=e.toLowerCase().split(`?`)[0],W=R.lastIndexOf(`.`),Y=W>-1?R.slice(W):``;switch(Y){case`.png`:case`.jpg`:case`.jpeg`:case`.gif`:case`.webp`:case`.svg`:case`.bmp`:case`.ttf`:case`.otf`:case`.woff`:case`.woff2`:case`.mp3`:case`.wav`:case`.ogg`:case`.flac`:case`.m4a`:case`.mp4`:case`.webm`:case`.mkv`:case`.xml`:case`.tmx`:case`.json`:return Y;default:return`.bin`}}function writeBlobToTempFile(R,W){let Y=e.build_filenamev([e.get_tmp_dir(),`gjsify-blob-${dd++}${guessBlobExt(W)}`]);return e.file_set_contents(Y,R),Y}var XMLHttpRequest$1=class extends EventTarget{static{__name$1(this,`XMLHttpRequest`)}static UNSENT=0;static OPENED=1;static HEADERS_RECEIVED=2;static LOADING=3;static DONE=4;UNSENT=0;OPENED=1;HEADERS_RECEIVED=2;LOADING=3;DONE=4;readyState=0;status=0;statusText=``;responseType=``;responseText=``;response=null;responseURL=``;withCredentials=!1;timeout=0;upload=new XMLHttpRequestUpload;onreadystatechange=null;onload=null;onerror=null;onabort=null;ontimeout=null;onloadstart=null;onloadend=null;onprogress=null;_method=`GET`;_url=``;_headers=new Map;_responseHeaders=new Map;_controller=new AbortController;_aborted=!1;_timeoutId=null;open(e,R,W=!0,Y,X){this._method=e.toUpperCase(),this._url=R,this._headers.clear(),this._responseHeaders.clear(),this._aborted=!1,this._controller=new AbortController,this._setReadyState(1)}setRequestHeader(e,R){if(this.readyState<1)throw new DOMException(`Must open first`,`InvalidStateError`);this._headers.set(e.toLowerCase(),R)}getResponseHeader(e){return this._responseHeaders.get(e.toLowerCase())??null}getAllResponseHeaders(){let e=[];return this._responseHeaders.forEach((R,W)=>e.push(`${W}: ${R}`)),e.join(`\r
|
|
9
|
-
`)}send(e){if(this.readyState!==1)throw new DOMException(`Must open first`,`InvalidStateError`);if(this._aborted)return;let R={};this._headers.forEach((e,W)=>{R[W]=e});let W={method:this._method,headers:R,credentials:this.withCredentials?`include`:`omit`,signal:this._controller.signal};e!=null&&this._method!==`GET`&&this._method!==`HEAD`&&(W.body=e),this.timeout>0&&(this._timeoutId=setTimeout(()=>{this._controller.abort(),this._onTimeout()},this.timeout)),this.dispatchEvent(new Event(`loadstart`)),this.onloadstart&&this.onloadstart(new ProgressEvent(`loadstart`)),fetch$1(this._url,W).then(async e=>{if(!this._aborted){switch(this._timeoutId&&=(clearTimeout(this._timeoutId),null),this.status=e.status,this.statusText=e.statusText,this.responseURL=e.url,e.headers.forEach((e,R)=>{this._responseHeaders.set(R.toLowerCase(),e)}),this._setReadyState(2),this._setReadyState(3),this.responseType){case`arraybuffer`:{let R=await e.arrayBuffer();this.response=R,this.responseText=``;break}case`blob`:{let R=await e.arrayBuffer(),W=writeBlobToTempFile(new Uint8Array(R),this._url),Y=new Blob([R],{type:this._responseHeaders.get(`content-type`)??``});Y._tmpPath=W,this.response=Y,this.responseText=``;break}case`json`:{let R=await e.text();this.responseText=``;try{this.response=R.length>0?JSON.parse(R):null}catch{this.response=null}break}case`document`:{let R=await e.text();this.responseText=R,this.response=R;break}default:{let R=await e.text(),W=R.charCodeAt(0)===65279?R.slice(1):R;this.responseText=W,this.response=W;break}}this._setReadyState(4),this.dispatchEvent(new ProgressEvent(`load`)),this.dispatchEvent(new ProgressEvent(`loadend`)),this.onload&&this.onload(new ProgressEvent(`load`)),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))}}).catch(e=>{if(this._timeoutId&&=(clearTimeout(this._timeoutId),null),this._aborted)return;this._setReadyState(4);let R=new ProgressEvent(`error`);this.dispatchEvent(R),this.onerror&&this.onerror(R),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))})}abort(){if(this._aborted)return;this._aborted=!0,this._timeoutId&&=(clearTimeout(this._timeoutId),null),this._controller.abort(),this.readyState!==0&&this.readyState!==4&&(this._setReadyState(4),this.status=0);let e=new ProgressEvent(`abort`);this.dispatchEvent(e),this.onabort&&this.onabort(e),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))}overrideMimeType(e){}_onTimeout(){if(this._aborted)return;this._aborted=!0,this._setReadyState(4);let e=new ProgressEvent(`timeout`);this.dispatchEvent(e),this.ontimeout&&this.ontimeout(e)}_setReadyState(e){this.readyState=e;let R=new Event(`readystatechange`);this.dispatchEvent(R),this.onreadystatechange&&this.onreadystatechange(R)}},XMLHttpRequestUpload=class extends EventTarget{onprogress=null;onloadstart=null;onloadend=null;onload=null;onerror=null;onabort=null;ontimeout=null};bt(),mu(),$e();const fd=new Set([`data:`,`http:`,`https:`,`file:`]);function rewriteRootRelativeUrl(e){if(typeof e!=`string`||!e.startsWith(`/`)||e.startsWith(`//`))return e;let R=globalThis,W=R.__GJSIFY_DEBUG_FETCH===!0;try{let Y=R.imports?.system?.programPath??R.imports?.system?.programInvocationName??``;if(!Y)return e;let X=`file://${Qe.path_get_dirname(Y)}${e}`;return W&&yt.log(`[fetch] rewrite ${e} → ${X}`),X}catch(R){return W&&yt.warn(`[fetch] rewrite FAILED: ${R instanceof Error?R.message:String(R)}`),e}}async function fetch$1(e,R={}){e=rewriteRootRelativeUrl(e);let W=new ud(e,R),{parsedURL:Y,options:X}=getSoupRequestOptions(W);if(!fd.has(Y.protocol))throw TypeError(`@gjsify/fetch cannot load ${e}. URL scheme "${Y.protocol.replace(/:$/,``)}" is not supported.`);if(Y.protocol===`data:`){let{buffer:e,typeFull:R}=parseDataUri(W.url);return new od(Buffer.from(e),{headers:{"Content-Type":R}})}if(Y.protocol===`file:`){let e=globalThis.__GJSIFY_DEBUG_FETCH===!0;e&&yt.log(`[fetch] file:// ${W.url}`);try{let R=Qe.filename_from_uri(W.url)[0];e&&yt.log(`[fetch] file:// path=${R}`);let[Y,X]=Qe.file_get_contents(R);if(e&&yt.log(`[fetch] file:// ok=${Y} bytes=${X?.byteLength??`?`}`),!Y)throw new FetchError(`Failed to read file: ${R}`,`system`);let ie=X,ae=new Uint8Array(ie.byteLength);ae.set(ie);let le=new od(ae);return e&&yt.log(`[fetch] file:// response created`),le}catch(R){let Y=R instanceof Error?R:Error(String(R));throw e&&yt.warn(`[fetch] file:// FAIL: ${Y.message}`),new FetchError(`request to ${W.url} failed, reason: ${Y.message}`,`system`,Y)}}let{signal:ie}=W;if(ie&&ie.aborted)throw new AbortError(`The operation was aborted.`);let ae,le;try{let e=await W._send(X);ae=e.readable,le=e.cancellable}catch(e){let R=e instanceof Error?e:Error(String(e));throw new FetchError(`request to ${W.url} failed, reason: ${R.message}`,`system`,R)}let abortHandler=()=>{le.cancel()};ie&&ie.addEventListener(`abort`,abortHandler,{once:!0});let finalize=()=>{ie&&ie.removeEventListener(`abort`,abortHandler)};le.connect(()=>{ae.destroy(new AbortError(`The operation was aborted.`))}),ae.on(`error`,e=>{finalize()});let _e=W._message,ye=Hu._newFromSoupMessage(_e),be=_e.status_code,Ce=_e.get_reason_phrase();if(isRedirect(be)){let e=ye.get(`Location`),Y=null;try{Y=e===null?null:new hs(e,W.url)}catch{if(W.redirect!==`manual`)throw finalize(),new FetchError(`uri requested responds with an invalid redirect URL: ${e}`,`invalid-redirect`)}switch(W.redirect){case`error`:throw finalize(),new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${W.url}`,`no-redirect`);case`manual`:break;case`follow`:{if(Y===null)break;if(W.counter>=W.follow)throw finalize(),new FetchError(`maximum redirect reached at: ${W.url}`,`max-redirect`);let e={headers:new Hu(W.headers),follow:W.follow,counter:W.counter+1,agent:W.agent,compress:W.compress,method:W.method,body:clone(W),signal:W.signal,size:W.size,referrer:W.referrer,referrerPolicy:W.referrerPolicy};if(!isDomainOrSubdomain(W.url,Y)||!isSameProtocol(W.url,Y))for(let R of[`authorization`,`www-authenticate`,`cookie`,`cookie2`])e.headers.delete(R);if(be!==303&&W.body&&R.body instanceof pu.Readable)throw finalize(),new FetchError(`Cannot follow redirect with body being a readable stream`,`unsupported-redirect`);(be===303||(be===301||be===302)&&W.method===`POST`)&&(e.method=`GET`,e.body=void 0,e.headers.delete(`content-length`));let X=parseReferrerPolicyFromHeader(ye);return X&&(e.referrerPolicy=X),finalize(),fetch$1(new ud(Y,e))}default:throw TypeError(`Redirect option '${W.redirect}' is not a valid value of RequestRedirect`)}}let Te={url:W.url,status:be,statusText:Ce,headers:ye,size:W.size,counter:W.counter,highWaterMark:W.highWaterMark},Oe=ye.get(`Content-Encoding`);if(!W.compress||W.method===`HEAD`||Oe===null||be===204||be===304)return finalize(),new od(ae,Te);if(typeof DecompressionStream<`u`){let e=null;if(Oe===`gzip`||Oe===`x-gzip`?e=`gzip`:(Oe===`deflate`||Oe===`x-deflate`)&&(e=`deflate`),e){let R=new od(ae,Te).body;if(R){let W=R.pipeThrough(new DecompressionStream(e));return finalize(),new od(W,Te)}}}return finalize(),new od(ae,Te)}__name$1(fetch$1,`fetch`);const pd=globalThis;globalThis.fetch===void 0&&(pd.fetch=fetch$1),globalThis.Headers===void 0&&(pd.Headers=Hu),globalThis.Request===void 0&&(pd.Request=ud),globalThis.Response===void 0&&(pd.Response=od),globalThis.XMLHttpRequest===void 0&&(globalThis.XMLHttpRequest=XMLHttpRequest$1),globalThis.XMLHttpRequestUpload===void 0&&(globalThis.XMLHttpRequestUpload=XMLHttpRequestUpload);const md=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(md.ByteLengthQueuingStrategy=Nl),globalThis.CountQueuingStrategy===void 0&&(md.CountQueuingStrategy=Fl);const hd=globalThis;function isNativeStreamUsable$2(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(hd.ReadableStream=Al),hd.ReadableStreamBYOBReader===void 0&&(hd.ReadableStreamBYOBReader=ReadableStreamBYOBReader),hd.ReadableStreamBYOBRequest===void 0&&(hd.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),hd.ReadableByteStreamController===void 0&&(hd.ReadableByteStreamController=ReadableByteStreamController),hd.ReadableStreamDefaultController===void 0&&(hd.ReadableStreamDefaultController=ReadableStreamDefaultController),hd.ReadableStreamDefaultReader===void 0&&(hd.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const gd=globalThis;globalThis.TextEncoderStream===void 0&&(gd.TextEncoderStream=Ll),globalThis.TextDecoderStream===void 0&&(gd.TextDecoderStream=Rl);function isNativeStreamUsable$1(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}if(__name$1(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=Ml}function isNativeStreamUsable(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=jl}const _d=globalThis.WebAssembly;if(_d===void 0)throw Error(`@gjsify/webassembly: globalThis.WebAssembly is not defined; nothing to polyfill.`);const vd=_d.Module,yd=_d.Instance;function compile(e){try{return Promise.resolve(new vd(e))}catch(e){return Promise.reject(e)}}function validate(e){try{return new vd(e),!0}catch{return!1}}function instantiate(e,R){try{if(e instanceof vd)return Promise.resolve(new yd(e,R));let W=new vd(e),Y=new yd(W,R);return Promise.resolve({module:W,instance:Y})}catch(e){return Promise.reject(e)}}async function bufferFromSource(e){return(await e).arrayBuffer()}async function compileStreaming(e){return compile(await bufferFromSource(e))}async function instantiateStreaming(e,R){return instantiate(await bufferFromSource(e),R)}const bd=globalThis.WebAssembly;if(bd!==void 0){let replace=(e,R)=>{try{Object.defineProperty(bd,e,{value:R,writable:!0,configurable:!0,enumerable:!0})}catch{}};replace(`compile`,compile),replace(`compileStreaming`,compileStreaming),replace(`instantiate`,instantiate),replace(`instantiateStreaming`,instantiateStreaming),replace(`validate`,validate)}globalThis.imports;var WebGLContextAttributes=class{constructor(e,R,W,Y,X,ie,ae,le){this.alpha=e,this.depth=R,this.stencil=W,this.antialias=Y,this.premultipliedAlpha=X,this.preserveDrawingBuffer=ie,this.preferLowPowerToHighPerformance=ae,this.failIfMajorPerformanceCaveat=le}},WebGLUniformLocation=class{constructor(e,R,W){this._linkCount=0,this._array=null,this._=e,this._program=R,this._linkCount=R._linkCount,this._activeInfo=W,this._array=null}},OESElementIndexUint=class{};function getOESElementIndexUint(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_element_index_uint`)>=0&&(R=new OESElementIndexUint),R}var OESStandardDerivatives=class{constructor(){this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723}};function getOESStandardDerivatives(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_standard_derivatives`)>=0&&(R=new OESStandardDerivatives),R}var OESTextureFloat=class{};function getOESTextureFloat(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_texture_float`)>=0&&(R=new OESTextureFloat),R}var OESTextureFloatLinear=class{};function getOESTextureFloatLinear(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_texture_float_linear`)>=0&&(R=new OESTextureFloatLinear),R}var STACKGLDestroyContext=class{constructor(e){this.destroy=e.destroy.bind(e)}};function getSTACKGLDestroyContext(e){return new STACKGLDestroyContext(e)}var STACKGLResizeDrawingBuffer=class{constructor(e){this.resize=e.resize.bind(e)}};function getSTACKGLResizeDrawingBuffer(e){return new STACKGLResizeDrawingBuffer(e)}var EXTBlendMinMax=class{constructor(){this.MIN_EXT=32775,this.MAX_EXT=32776}};function getEXTBlendMinMax(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`EXT_blend_minmax`)>=0&&(R=new EXTBlendMinMax),R}var EXTColorBufferFloat=class{};function getEXTColorBufferFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`EXT_color_buffer_float`)>=0?new EXTColorBufferFloat:null}var EXTColorBufferHalfFloat=class{};function getEXTColorBufferHalfFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`EXT_color_buffer_half_float`)>=0?new EXTColorBufferHalfFloat:null}var EXTTextureFilterAnisotropic=class{constructor(){this.TEXTURE_MAX_ANISOTROPY_EXT=34046,this.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047}};function getEXTTextureFilterAnisotropic(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`EXT_texture_filter_anisotropic`)>=0&&(R=new EXTTextureFilterAnisotropic),R}var OESTextureHalfFloat=class{constructor(){this.HALF_FLOAT_OES=36193}};function getOESTextureHalfFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`OES_texture_half_float`)>=0||e._native2?new OESTextureHalfFloat:null}var WebGLTextureUnit=class{constructor(e,R){this._mode=0,this._bind2D=null,this._bindCube=null,this._ctx=e,this._idx=R}},Linkable=class{constructor(e){this._=0,this._references=[],this._refCount=0,this._pendingDelete=!1,this._binding=0,this._=e,this._references=[],this._refCount=0,this._pendingDelete=!1,this._binding=0}_link(e){return this._references.push(e),e._refCount+=1,!0}_unlink(e){let R=this._references.indexOf(e);if(R<0)return!1;for(;R>=0;)this._references[R]=this._references[this._references.length-1],this._references.pop(),--e._refCount,e._checkDelete(),R=this._references.indexOf(e);return!0}_linked(e){return this._references.indexOf(e)>=0}_checkDelete(){if(this._refCount<=0&&this._pendingDelete&&this._!==0){for(;this._references.length>0;)this._unlink(this._references[0]);this._performDelete(),this._=0}}_performDelete(){}},WebGLBuffer=class extends Linkable{constructor(e,R){super(e),this._size=0,this._elements=new Uint8Array,this._ctx=R}_performDelete(){let e=this._ctx;delete e._buffers[this._|0],e._gl.deleteBuffer(this._)}},WebGLVertexArrayObjectAttribute=class{constructor(e,R){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=0,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0,this._ctx=e,this._idx=R,this._pointerType=e.FLOAT,this._clear()}_clear(){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=this._ctx.FLOAT,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0}},WebGLVertexArrayGlobalAttribute=class{constructor(e){this._idx=0,this._idx=e,this._data=new Float32Array([0,0,0,1])}},WebGLVertexArrayObjectState=class{constructor(e){this._elementArrayBufferBinding=null;let R=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:R});for(let W=0;W<R;++W)this._attribs[W]=new WebGLVertexArrayObjectAttribute(e,W);this._elementArrayBufferBinding=null}setElementArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setElementArrayBuffer(WebGLBuffer?)`);let R=this._elementArrayBufferBinding;R!==e&&(R&&(--R._refCount,R._checkDelete()),e&&(e._refCount+=1),this._elementArrayBufferBinding=e)}cleanUp(){let e=this._elementArrayBufferBinding;e&&(--e._refCount,e._checkDelete(),this._elementArrayBufferBinding=null);for(let e=0;e<this._attribs.length;++e){let R=this._attribs[e];R._pointerBuffer&&(--R._pointerBuffer._refCount,R._pointerBuffer._checkDelete()),R._clear()}}releaseArrayBuffer(e){if(e)for(let R=0;R<this._attribs.length;++R){let W=this._attribs[R];W._pointerBuffer===e&&(--W._pointerBuffer._refCount,W._pointerBuffer._checkDelete(),W._clear())}}setVertexAttribPointer(e,R,W,Y,X,ie,ae,le,_e){let ye=this._attribs[R];e!==ye._pointerBuffer&&(ye._pointerBuffer&&(--ye._pointerBuffer._refCount,ye._pointerBuffer._checkDelete()),e&&(e._refCount+=1),ye._pointerBuffer=e),ye._pointerSize=W,ye._pointerOffset=Y,ye._pointerStride=X,ye._pointerType=ie,ye._pointerNormal=ae,ye._inputStride=le,ye._inputSize=_e}},WebGLVertexArrayGlobalState=class{constructor(e){this._arrayBufferBinding=null;let R=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:R});for(let e=0;e<R;++e)this._attribs[e]=new WebGLVertexArrayGlobalAttribute(e);this._arrayBufferBinding=null}setArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setArrayBuffer(WebGLBuffer?)`);let R=this._arrayBufferBinding;R!==e&&(R&&(--R._refCount,R._checkDelete()),e&&(e._refCount+=1),this._arrayBufferBinding=e)}},WebGLFramebuffer=class extends Linkable{constructor(e,R){if(super(e),this._binding=0,this._width=0,this._height=0,this._status=null,this._ctx=R,this._attachments={},this._attachments[R.COLOR_ATTACHMENT0]=null,this._attachments[R.DEPTH_ATTACHMENT]=null,this._attachments[R.STENCIL_ATTACHMENT]=null,this._attachments[R.DEPTH_STENCIL_ATTACHMENT]=null,this._attachmentLevel={},this._attachmentLevel[R.COLOR_ATTACHMENT0]=0,this._attachmentLevel[R.DEPTH_ATTACHMENT]=0,this._attachmentLevel[R.STENCIL_ATTACHMENT]=0,this._attachmentLevel[R.DEPTH_STENCIL_ATTACHMENT]=0,this._attachmentFace={},this._attachmentFace[R.COLOR_ATTACHMENT0]=0,this._attachmentFace[R.DEPTH_ATTACHMENT]=0,this._attachmentFace[R.STENCIL_ATTACHMENT]=0,this._attachmentFace[R.DEPTH_STENCIL_ATTACHMENT]=0,R._extensions.webgl_draw_buffers){let e=R._extensions.webgl_draw_buffers;this._attachments[e.COLOR_ATTACHMENT1_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT2_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT3_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT4_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT5_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT6_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT7_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT8_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT9_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT10_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT11_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT12_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT13_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT14_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT15_WEBGL]=null,this._attachments[R.NONE]=null,this._attachments[R.BACK]=null,this._attachmentLevel[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentLevel[R.NONE]=null,this._attachmentLevel[R.BACK]=null,this._attachmentFace[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentFace[R.NONE]=null,this._attachmentFace[R.BACK]=null}}_clearAttachment(e){let R=this._attachments[e];R&&(this._attachments[e]=null,this._unlink(R))}_setAttachment(e,R){this._attachments[R]!==e&&(this._clearAttachment(R),e&&(this._attachments[R]=e,this._link(e)))}_performDelete(){let e=this._ctx;delete e._framebuffers[this._|0],e._gl.deleteFramebuffer(this._|0)}},WebGLProgram=class extends Linkable{constructor(e,R){super(e),this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[],this._ctx=R,this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[]}_performDelete(){let e=this._ctx;delete e._programs[this._|0],e._gl.deleteProgram(this._|0)}},WebGLRenderbuffer=class extends Linkable{constructor(e,R){super(e),this._binding=0,this._width=0,this._height=0,this._format=0,this._ctx=R,this._binding=0,this._width=0,this._height=0,this._format=0}_performDelete(){let e=this._ctx;delete e._renderbuffers[this._|0],e._gl.deleteRenderbuffer(this._)}},WebGLShader=class extends Linkable{constructor(e,R,W){super(e),this._source=``,this._compileStatus=!1,this._compileInfo=``,this._needsRecompile=!1,this._type=W,this._ctx=R,this._source=``,this._compileStatus=!1,this._compileInfo=``}_performDelete(){let e=this._ctx;delete e._shaders[this._|0],e._gl.deleteShader(this._|0)}},WebGLTexture=class extends Linkable{constructor(e,R){super(e),this._binding=0,this._levelWidth=new Int32Array(32),this._levelHeight=new Int32Array(32),this._format=0,this._type=0,this._complete=!0,this._ctx=R}_performDelete(){let e=this._ctx;delete e._textures[this._|0],e._gl.deleteTexture(this._|0)}},WebGLDrawingBufferWrapper=class{constructor(e,R,W){this._framebuffer=e,this._color=R,this._depthStencil=W}},WebGLShaderPrecisionFormat=class{constructor(e){this.rangeMin=e.rangeMin,this.rangeMax=e.rangeMax,this.precision=e.precision}},WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}};$e();function checkObject(e){return typeof e==`object`||e===void 0}function checkUniform(e,R){return R instanceof WebGLUniformLocation&&R._program===e&&R._linkCount===e._linkCount}function isTypedArray(e){return e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function isValidString(e){let R=e.replace(/(?:\/\*(?:[\s\S]*?)\*\/)|(?:([\s;])+\/\/(?:.*)$)/gm,``);return!/["$`@\\'\0]/.test(R)}function vertexCount(e,R,W){switch(R){case e.TRIANGLES:return W-W%3;case e.LINES:return W-W%2;case e.LINE_LOOP:case e.POINTS:return W;case e.TRIANGLE_FAN:case e.LINE_STRIP:return W<2?0:W;case e.TRIANGLE_STRIP:return W<3?0:W;default:return-1}}function typeSize(e,R){switch(R){case e.UNSIGNED_BYTE:case e.BYTE:return 1;case e.UNSIGNED_SHORT:case e.SHORT:return 2;case e.UNSIGNED_INT:case e.INT:case e.FLOAT:return 4}return 0}function uniformTypeSize(e,R){switch(R){case e.BOOL_VEC4:case e.INT_VEC4:case e.FLOAT_VEC4:return 4;case e.BOOL_VEC3:case e.INT_VEC3:case e.FLOAT_VEC3:return 3;case e.BOOL_VEC2:case e.INT_VEC2:case e.FLOAT_VEC2:return 2;case e.BOOL:case e.INT:case e.FLOAT:case e.SAMPLER_2D:case e.SAMPLER_CUBE:return 1;default:return 0}}const listToArray=e=>{let R=[];for(let W of e.values())R.push(W);return R};function arrayToUint8Array(e){if(isTypedArray(e))return new Uint8Array(e.buffer).subarray(e.byteOffset,e.byteLength+e.byteOffset);if(Array.isArray(e)||e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e.values==`function`)return new Uint8Array(listToArray(e));throw Error(`Can't unpack typed array!`)}function Uint8ArrayToVariant(e){return new Qe.Variant(`ay`,e)}const extractImageData=e=>{let R=e.width,W=e.height;if(typeof e==`object`&&R!==void 0&&W!==void 0){if(e.data!==void 0)return e;let Y=null;if(typeof e.getContext==`function`)Y=e.getContext(`2d`);else if(typeof e.isPixbuf==`function`&&e.isPixbuf())return e.getImageData();else if(e.src!==void 0&&typeof document==`object`&&typeof document.createElement==`function`){let X=document.createElement(`canvas`);typeof X==`object`&&typeof X.getContext==`function`&&(X.width=R,X.height=W,Y=X.getContext(`2d`),Y!==null&&Y.drawImage(e,0,0))}if(Y!==null)return Y.getImageData(0,0,R,W)}return null};function formatSize(e,R){switch(R){case e.ALPHA:case e.LUMINANCE:return 1;case e.LUMINANCE_ALPHA:return 2;case e.RGB:return 3;case e.RGBA:return 4}return 0}function convertPixels(e){if(typeof e==`object`&&e){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint8ClampedArray||e instanceof Float32Array)return arrayToUint8Array(e);if(e instanceof Buffer)return new Uint8Array(e)}return null}function checkFormat(e,R){return R===e.ALPHA||R===e.LUMINANCE_ALPHA||R===e.LUMINANCE||R===e.RGB||R===e.RGBA}function validCubeTarget(e,R){return R===e.TEXTURE_CUBE_MAP_POSITIVE_X||R===e.TEXTURE_CUBE_MAP_NEGATIVE_X||R===e.TEXTURE_CUBE_MAP_POSITIVE_Y||R===e.TEXTURE_CUBE_MAP_NEGATIVE_Y||R===e.TEXTURE_CUBE_MAP_POSITIVE_Z||R===e.TEXTURE_CUBE_MAP_NEGATIVE_Z}function flag(e,R,W){return!e||typeof e!=`object`||!(R in e)?W:!!e[R]}function premultiplyAlpha(e){let R=new Uint8Array(e.length);for(let W=0;W<e.length;W+=4){let Y=e[W+3]/255;R[W]=Math.round(e[W]*Y),R[W+1]=Math.round(e[W+1]*Y),R[W+2]=Math.round(e[W+2]*Y),R[W+3]=e[W+3]}return R}const xd={enable(e=0){this._gl.enable(e)},disable(e=0){if(this._gl.disable(e),e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP){let R=this._getActiveTextureUnit();R._mode===e&&(R._mode=0)}},cullFace(e){this._gl.cullFace(e|0)},depthFunc(e){switch(e|=0,e){case this.NEVER:case this.LESS:case this.EQUAL:case this.LEQUAL:case this.GREATER:case this.NOTEQUAL:case this.GEQUAL:case this.ALWAYS:this._gl.depthFunc(e);return;default:this.setError(this.INVALID_ENUM)}},depthMask(e){this._gl.depthMask(!!e)},depthRange(e,R){if(e=+e,R=+R,e<=R){this._gl.depthRange(e,R);return}this.setError(this.INVALID_OPERATION)},frontFace(e=0){this._gl.frontFace(e)},lineWidth(e){if(isNaN(e)){this.setError(this.INVALID_VALUE);return}this._gl.lineWidth(+e)},polygonOffset(e,R){this._gl.polygonOffset(+e,+R)},sampleCoverage(e,R){this._gl.sampleCoverage(+e,!!R)},hint(e=0,R=0){let W=this._extensions.oes_standard_derivatives;if(!(e===this.GENERATE_MIPMAP_HINT||W&&e===W.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)){this.setError(this.INVALID_ENUM);return}if(R!==this.FASTEST&&R!==this.NICEST&&R!==this.DONT_CARE){this.setError(this.INVALID_ENUM);return}this._gl.hint(e,R)},finish(){this._gl.finish()},flush(){this._gl.flush()},blendColor(e=0,R=0,W=0,Y=0){this._gl.blendColor(+e,+R,+W,+Y)},blendEquation(e=0){if(this._validBlendMode(e)){this._gl.blendEquation(e);return}this.setError(this.INVALID_ENUM)},blendEquationSeparate(e=0,R=0){if(this._validBlendMode(e)&&this._validBlendMode(R)){this._gl.blendEquationSeparate(e,R);return}this.setError(this.INVALID_ENUM)},blendFunc(e=0,R=0){if(!this._validBlendFunc(e)||!this._validBlendFunc(R)){this.setError(this.INVALID_ENUM);return}if(this._isConstantBlendFunc(e)&&this._isConstantBlendFunc(R)){this.setError(this.INVALID_OPERATION);return}this._gl.blendFunc(e,R)},blendFuncSeparate(e=0,R=0,W=0,Y=0){if(!(this._validBlendFunc(e)&&this._validBlendFunc(R)&&this._validBlendFunc(W)&&this._validBlendFunc(Y))){this.setError(this.INVALID_ENUM);return}if(this._isConstantBlendFunc(e)&&this._isConstantBlendFunc(R)||this._isConstantBlendFunc(W)&&this._isConstantBlendFunc(Y)){this.setError(this.INVALID_OPERATION);return}this._gl.blendFuncSeparate(e,R,W,Y)},clear(e=0){this._framebufferOk()&&this._gl.clear(e)},clearColor(e,R,W,Y){this._gl.clearColor(+e,+R,+W,+Y)},clearDepth(e){this._gl.clearDepth(+e)},clearStencil(e=0){this._checkStencil=!1,this._gl.clearStencil(e)},colorMask(e,R,W,Y){this._gl.colorMask(!!e,!!R,!!W,!!Y)},stencilFunc(e,R,W){this._checkStencil=!0,this._gl.stencilFunc(e|0,R|0,W|0)},stencilFuncSeparate(e,R,W,Y){this._checkStencil=!0,this._gl.stencilFuncSeparate(e|0,R|0,W|0,Y|0)},stencilMask(e){this._checkStencil=!0,this._gl.stencilMask(e>>>0)},stencilMaskSeparate(e,R){this._checkStencil=!0,this._gl.stencilMaskSeparate(e|0,R>>>0)},stencilOp(e,R,W){this._checkStencil=!0,this._gl.stencilOp(e|0,R|0,W|0)},stencilOpSeparate(e,R,W,Y){this._checkStencil=!0,this._gl.stencilOpSeparate(e|0,R|0,W|0,Y|0)},isEnabled(e=0){return this._gl.isEnabled(e)},isContextLost(){return!1},getError(){return this._gl.getError()},setError(e){this._gl.setError(e)},isBuffer(e){return this._isObject(e,`isBuffer`,WebGLBuffer)?this._gl.isBuffer(e?._):!1},isFramebuffer(e){return this._isObject(e,`isFramebuffer`,WebGLFramebuffer)?this._gl.isFramebuffer(e?._):!1},isProgram(e){return this._isObject(e,`isProgram`,WebGLProgram)?this._gl.isProgram(e?._):!1},isRenderbuffer(e){return this._isObject(e,`isRenderbuffer`,WebGLRenderbuffer)?this._gl.isRenderbuffer(e?._):!1},isShader(e){return this._isObject(e,`isShader`,WebGLShader)?this._gl.isShader(e?._):!1},isTexture(e){return this._isObject(e,`isTexture`,WebGLTexture)?this._gl.isTexture(e?._):!1},generateMipmap(e=0){this._gl.generateMipmap(e)},_validBlendFunc(e){return e===this.ZERO||e===this.ONE||e===this.SRC_COLOR||e===this.ONE_MINUS_SRC_COLOR||e===this.DST_COLOR||e===this.ONE_MINUS_DST_COLOR||e===this.SRC_ALPHA||e===this.ONE_MINUS_SRC_ALPHA||e===this.DST_ALPHA||e===this.ONE_MINUS_DST_ALPHA||e===this.SRC_ALPHA_SATURATE||e===this.CONSTANT_COLOR||e===this.ONE_MINUS_CONSTANT_COLOR||e===this.CONSTANT_ALPHA||e===this.ONE_MINUS_CONSTANT_ALPHA},_validBlendMode(e){let R=this._extensions.ext_blend_minmax;return e===this.FUNC_ADD||e===this.FUNC_SUBTRACT||e===this.FUNC_REVERSE_SUBTRACT||!!(R&&(e===R.MIN_EXT||e===R.MAX_EXT))},_isConstantBlendFunc(e){return e===this.CONSTANT_COLOR||e===this.ONE_MINUS_CONSTANT_COLOR||e===this.CONSTANT_ALPHA||e===this.ONE_MINUS_CONSTANT_ALPHA},_saveError(){this._errorStack.push(this.getError())},_restoreError(e){let R=this._errorStack.pop();R===this.NO_ERROR?this.setError(e):R!==void 0&&this.setError(R)}};function installStateMethods(e){Object.assign(e,xd)}const Sd={bindBuffer(e=0,R){if(!checkObject(R))throw TypeError(`bindBuffer(GLenum, WebGLBuffer)`);if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}if(!R)R=null,this._gl.bindBuffer(e,0);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLBuffer)){if(R._binding&&R._binding!==e){this.setError(this.INVALID_OPERATION);return}R._binding=e|0,this._gl.bindBuffer(e,R._|0)}else return;e===this.ARRAY_BUFFER?this._vertexGlobalState.setArrayBuffer(R):this._vertexObjectState.setElementArrayBuffer(R)},bufferData(e=0,R,W=0){let Y=0,X=null;if(typeof R==`number`?Y=R:typeof R==`object`&&(X=R),W!==this.STREAM_DRAW&&W!==this.STATIC_DRAW&&W!==this.DYNAMIC_DRAW){this.setError(this.INVALID_ENUM);return}if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}let ie=this._getActiveBuffer(e);if(!ie){this.setError(this.INVALID_OPERATION);return}if(X){let R=null;if(isTypedArray(X)||X instanceof DataView||X instanceof ArrayBuffer)R=arrayToUint8Array(X);else{this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.bufferData(e,Uint8ArrayToVariant(R),W);let Y=this.getError();if(this._restoreError(Y),Y!==this.NO_ERROR)return;ie._size=R.length,e===this.ELEMENT_ARRAY_BUFFER&&(ie._elements=new Uint8Array(R))}else if(typeof R==`number`){if(Y<0){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.bufferDataSizeOnly(e,Y,W);let R=this.getError();if(this._restoreError(R),R!==this.NO_ERROR)return;ie._size=Y,e===this.ELEMENT_ARRAY_BUFFER&&(ie._elements=new Uint8Array(Y))}else this.setError(this.INVALID_VALUE)},bufferSubData(e=0,R=0,W){if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}if(typeof W!=`object`||!W)throw TypeError(`bufferSubData: data must be a BufferSource`);let Y=this._getActiveBuffer(e);if(!Y){this.setError(this.INVALID_OPERATION);return}if(R<0||R>=Y._size){this.setError(this.INVALID_VALUE);return}let X=null;if(isTypedArray(W)||W instanceof DataView||W instanceof ArrayBuffer)X=arrayToUint8Array(W);else{this.setError(this.INVALID_VALUE);return}if(R+X.length>Y._size){this.setError(this.INVALID_VALUE);return}e===this.ELEMENT_ARRAY_BUFFER&&Y._elements.set(X,R),this._gl.bufferSubData(e,R,Uint8ArrayToVariant(X))},createBuffer(){let e=this._gl.createBuffer();if(!e||e<=0)return null;let R=new WebGLBuffer(e,this);return this._buffers[e]=R,R},deleteBuffer(e){if(!checkObject(e)||e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`deleteBuffer(WebGLBuffer)`);if(!(e instanceof WebGLBuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._vertexGlobalState._arrayBufferBinding===e&&this.bindBuffer(this.ARRAY_BUFFER,null),this._vertexObjectState._elementArrayBufferBinding===e&&this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this._vertexObjectState===this._defaultVertexObjectState&&this._vertexObjectState.releaseArrayBuffer(e),e._pendingDelete=!0,e._checkDelete()},getBufferParameter(e=0,R=0){if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER)return this.setError(this.INVALID_ENUM),null;switch(R){case this.BUFFER_SIZE:case this.BUFFER_USAGE:return this._gl.getBufferParameteriv(e|0,R|0)[0];default:return this.setError(this.INVALID_ENUM),null}},_getActiveBuffer(e){return e===this.ARRAY_BUFFER?this._vertexGlobalState._arrayBufferBinding:e===this.ELEMENT_ARRAY_BUFFER?this._vertexObjectState._elementArrayBufferBinding:null}};function installBufferBindingMethods(e){Object.assign(e,Sd)}const Cd={activeTexture(e=0){let R=e-this.TEXTURE0;if(R>=0&&R<this._textureUnits.length){this._activeTextureUnit=R,this._gl.activeTexture(e);return}this.setError(this.INVALID_ENUM)},bindTexture(e=0,R){if(!checkObject(R))throw TypeError(`bindTexture(GLenum, WebGLTexture)`);if(!this._validTextureTarget(e)){this.setError(this.INVALID_ENUM);return}let W=0;if(!R)R=null;else if(R instanceof WebGLTexture&&R._pendingDelete)return;else if(this._checkWrapper(R,WebGLTexture)){if(R._binding&&R._binding!==e){this.setError(this.INVALID_OPERATION);return}R._binding=e,R._complete&&(W=R._|0)}else return;this._saveError(),this._gl.bindTexture(e,W);let Y=this.getError();if(this._restoreError(Y),Y!==this.NO_ERROR)return;let X=this._getActiveTextureUnit(),ie=this._getActiveTexture(e);ie!==R&&(ie&&(--ie._refCount,ie._checkDelete()),R&&(R._refCount+=1)),e===this.TEXTURE_2D?X._bind2D=R:e===this.TEXTURE_CUBE_MAP&&(X._bindCube=R)},createTexture(){let e=this._gl.createTexture();if(e<=0)return null;let R=new WebGLTexture(e,this);return this._textures[e]=R,R},deleteTexture(e){if(!checkObject(e))throw TypeError(`deleteTexture(WebGLTexture)`);if(e instanceof WebGLTexture){if(!this._checkOwns(e)){this.setError(this.INVALID_OPERATION);return}}else return;let R=this._activeTextureUnit;for(let R=0;R<this._textureUnits.length;++R){let W=this._textureUnits[R];W._bind2D===e?(this.activeTexture(this.TEXTURE0+R),this.bindTexture(this.TEXTURE_2D,null)):W._bindCube===e&&(this.activeTexture(this.TEXTURE0+R),this.bindTexture(this.TEXTURE_CUBE_MAP,null))}this.activeTexture(this.TEXTURE0+R),this._detachTextureFromAllFramebuffers(e),e._pendingDelete=!0,e._checkDelete()},_detachTextureFromAllFramebuffers(e){let R=this._activeFramebuffer,W=this._getAttachments(),Y=!1;for(let X in this._framebuffers){let ie=this._framebuffers[X];if(!(!ie||!ie._linked(e))){ie!==R&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,ie._|0),Y=!0);for(let R=0;R<W.length;++R){let Y=W[R];ie._attachments[Y]===e&&(this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,ie._attachmentFace[Y]||this.TEXTURE_2D,0,ie._attachmentLevel[Y]||0),ie._setAttachment(null,Y))}}}Y&&this._gl.bindFramebuffer(this.FRAMEBUFFER,R?R._|0:this._gtkFboId)},pixelStorei(e=0,R=0){if(typeof R==`boolean`&&(R=R===!1?0:1),e===this.UNPACK_ALIGNMENT)if(R===1||R===2||R===4||R===8)this._unpackAlignment=R;else{this.setError(this.INVALID_VALUE);return}else if(e===this.PACK_ALIGNMENT)if(R===1||R===2||R===4||R===8)this._packAlignment=R;else{this.setError(this.INVALID_VALUE);return}else if(e===this.UNPACK_COLORSPACE_CONVERSION_WEBGL){if(!(R===this.NONE||R===this.BROWSER_DEFAULT_WEBGL)){this.setError(this.INVALID_VALUE);return}}else if(e===this.UNPACK_FLIP_Y_WEBGL){this._unpackFlipY=!!R;return}else if(e===this.UNPACK_PREMULTIPLY_ALPHA_WEBGL){this._unpackPremultAlpha=!!R;return}this._gl.pixelStorei(e,R)}};function installTextureLifecycleMethods(e){Object.assign(e,Cd)}const wd={texImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe,Ae,Me=0;if(arguments.length===6)if(_e=X,Te=Y,ie instanceof le.Pixbuf)Ae=ie,be=Ae.get_width(),Ce=Ae.get_height(),ye=Ae.get_pixels();else{Oe=ie;let e=extractImageData(Oe);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else arguments.length===9&&(be=Y,Ce=X,Me=ie,Te=ae,ye=ye);if(typeof ye!=`object`&&ye!==void 0)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!checkFormat(this,Te)||!checkFormat(this,W)){this.setError(this.INVALID_ENUM);return}if(_e===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let Pe=this._getTexImage(e);if(!Pe||Te!==W){this.setError(this.INVALID_OPERATION);return}let Re=this._computePixelSize(_e,Te);if(Re===0||!this._checkDimensions(e,be,Ce,R))return;let Be=convertPixels(ye),Ve=this._computeRowStride(be,Re),He=Ve*Ce;if(Be&&Be.length<He){this.setError(this.INVALID_OPERATION);return}if(Me!==0||validCubeTarget(this,e)&&be!==Ce){this.setError(this.INVALID_VALUE);return}if(this._unpackPremultAlpha&&Be&&Te===this.RGBA&&(Be=premultiplyAlpha(Be)),this._unpackFlipY&&Be&&be>0&&Ce>0){let e=new Uint8Array(Be.length);for(let R=0;R<Ce;R++){let W=R*Ve,Y=(Ce-1-R)*Ve;e.set(Be.subarray(W,W+Ve),Y)}Be=e}this._saveError(),this._gl.texImage2D(e,R,W,be,Ce,Me,Te,_e,Uint8ArrayToVariant(Be));let Ue=this.getError();if(this._restoreError(Ue),Ue!==this.NO_ERROR)return;Pe._levelWidth[R]=be,Pe._levelHeight[R]=Ce,Pe._format=Te,Pe._type=_e;let We=this._activeFramebuffer;if(We){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(We._attachments[R[W]]===Pe){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}},texSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe,Ae;if(arguments.length===7)if(_e=ie,Te=X,ae instanceof le.Pixbuf)Ae=ae,be=Ae.get_width(),Ce=Ae.get_height(),ye=Ae.get_pixels();else{Oe=ae;let e=extractImageData(Oe);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else be=X,Ce=ie,Te=ae;if(typeof ye!=`object`)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(_e===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let Me=this._computePixelSize(_e,Te);if(Me===0||!this._checkDimensions(e,be,Ce,R))return;if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}let Pe=convertPixels(ye),Re=this._computeRowStride(be,Me),Be=Re*Ce;if(!Pe||Pe.length<Be){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&Pe&&Te===this.RGBA&&(Pe=premultiplyAlpha(Pe)),this._unpackFlipY&&Pe&&be>0&&Ce>0){let e=new Uint8Array(Pe.length);for(let R=0;R<Ce;R++){let W=R*Re,Y=(Ce-1-R)*Re;e.set(Pe.subarray(W,W+Re),Y)}Pe=e}this._gl.texSubImage2D(e,R,W,Y,be,Ce,Te,_e,Uint8ArrayToVariant(Pe))}};function installTexImage2DMethods(e){Object.assign(e,wd)}var Td=__toESM(__commonJSMin((e=>{e.INT_MIN=-1<<31,e.isPow2=function(e){return!(e&e-1)&&!!e},e.log2=function(e){var R=(e>65535)<<4,W;return e>>>=R,W=(e>255)<<3,e>>>=W,R|=W,W=(e>15)<<2,e>>>=W,R|=W,W=(e>3)<<1,e>>>=W,R|=W,R|e>>1},e.nextPow2=function(e){return e+=e===0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1},(function(e){for(var R=0;R<256;++R){var W=R,Y=R,X=7;for(W>>>=1;W;W>>>=1)Y<<=1,Y|=W&1,--X;e[R]=Y<<X&255}})(Array(256))}))(),1);const Ed={copyTexImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,le=0){let _e=this._getTexImage(e);if(!_e){this.setError(this.INVALID_OPERATION);return}if(W!==this.RGBA&&W!==this.RGB&&W!==this.ALPHA&&W!==this.LUMINANCE&&W!==this.LUMINANCE_ALPHA){this.setError(this.INVALID_ENUM);return}if(R<0||ie<0||ae<0||le!==0){this.setError(this.INVALID_VALUE);return}if(R>0&&!(Td.isPow2(ie)&&Td.isPow2(ae))){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.copyTexImage2D(e,R,W,Y,X,ie,ae,le);let ye=this.getError();this._restoreError(ye),ye===this.NO_ERROR&&(_e._levelWidth[R]=ie,_e._levelHeight[R]=ae,_e._format=this.RGBA,_e._type=this.UNSIGNED_BYTE)},copyTexSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,le=0){if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(ae<0||le<0||W<0||Y<0||R<0){this.setError(this.INVALID_VALUE);return}this._gl.copyTexSubImage2D(e,R,W,Y,X,ie,ae,le)},compressedTexImage2D(e,R,W,Y,X,ie,ae){this._gl.compressedTexImage2D(e,R,W,Y,X,ie,Uint8ArrayToVariant(arrayToUint8Array(ae)))},compressedTexSubImage2D(e,R,W,Y,X,ie,ae,le){this._gl.compressedTexSubImage2D(e,R,W,Y,X,ie,ae,Uint8ArrayToVariant(arrayToUint8Array(le)))}};function installCopyAndCompressedTextureMethods(e){Object.assign(e,Ed)}const Dd={texParameterf(e=0,R=0,W){if(W=+W,this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,R,W),R){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameterf(e,R,W);return}let Y=this._extensions.ext_texture_filter_anisotropic;if(Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameterf(e,R,W);return}this.setError(this.INVALID_ENUM)}},texParameteri(e=0,R=0,W=0){if(this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,R,W),R){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameteri(e,R,W);return}let Y=this._extensions.ext_texture_filter_anisotropic;if(Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameteri(e,R,W);return}this.setError(this.INVALID_ENUM)}},getTexParameter(e=0,R=0){if(!this._checkTextureTarget(e))return null;let W=this._getActiveTextureUnit();if(e===this.TEXTURE_2D&&!W._bind2D||e===this.TEXTURE_CUBE_MAP&&!W._bindCube)return this.setError(this.INVALID_OPERATION),null;switch(R){case this.TEXTURE_MAG_FILTER:case this.TEXTURE_MIN_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:return this._getTexParameterDirect(e,R)}let Y=this._extensions.ext_texture_filter_anisotropic;return Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT?this._getTexParameterDirect(e,R):(this.setError(this.INVALID_ENUM),null)},_getTexParameterDirect(e=0,R=0){return this._gl.getTexParameterx(e,R)?.unpack()}};function installTextureParameterMethods(e){Object.assign(e,Dd)}const Od={_getActiveTextureUnit(){return this._textureUnits[this._activeTextureUnit]},_getActiveTexture(e){let R=this._getActiveTextureUnit();return e===this.TEXTURE_2D?R._bind2D:e===this.TEXTURE_CUBE_MAP?R._bindCube:null},_getTexImage(e){let R=this._getActiveTextureUnit();return e===this.TEXTURE_2D?R._bind2D:validCubeTarget(this,e)?R._bindCube:(this.setError(this.INVALID_ENUM),null)},_checkTextureTarget(e){let R=this._getActiveTextureUnit(),W=null;if(e===this.TEXTURE_2D)W=R._bind2D;else if(e===this.TEXTURE_CUBE_MAP)W=R._bindCube;else return this.setError(this.INVALID_ENUM),!1;return W?!0:(this.setError(this.INVALID_OPERATION),!1)},_validTextureTarget(e){return e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP},_validCubeTarget(e){return e===this.TEXTURE_CUBE_MAP_POSITIVE_X||e===this.TEXTURE_CUBE_MAP_NEGATIVE_X||e===this.TEXTURE_CUBE_MAP_POSITIVE_Y||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Y||e===this.TEXTURE_CUBE_MAP_POSITIVE_Z||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Z},_verifyTextureCompleteness(e,R,W){let Y=this._getActiveTextureUnit(),X=null;if(e===this.TEXTURE_2D?X=Y._bind2D:this._validCubeTarget(e)&&(X=Y._bindCube),this._extensions.oes_texture_float&&!this._extensions.oes_texture_float_linear&&X&&X._type===this.FLOAT&&(R===this.TEXTURE_MAG_FILTER||R===this.TEXTURE_MIN_FILTER)&&(W===this.LINEAR||W===this.LINEAR_MIPMAP_NEAREST||W===this.NEAREST_MIPMAP_LINEAR||W===this.LINEAR_MIPMAP_LINEAR)){X._complete=!1,this.bindTexture(e,X);return}X&&X._complete===!1&&(X._complete=!0,this.bindTexture(e,X))},_computePixelSize(e,R){let W=formatSize(this,R);if(W===0)return this.setError(this.INVALID_ENUM),0;switch(e){case this.UNSIGNED_BYTE:return W;case this.UNSIGNED_SHORT_5_6_5:if(R!==this.RGB){this.setError(this.INVALID_OPERATION);break}return 2;case this.UNSIGNED_SHORT_4_4_4_4:case this.UNSIGNED_SHORT_5_5_5_1:if(R!==this.RGBA){this.setError(this.INVALID_OPERATION);break}return 2;case this.FLOAT:return 1}return this.setError(this.INVALID_ENUM),0},_computeRowStride(e,R){let W=e*R;return W%this._unpackAlignment&&(W+=this._unpackAlignment-W%this._unpackAlignment),W},_checkDimensions(e,R,W,Y){if(Y<0||R<0||W<0)return this.setError(this.INVALID_VALUE),!1;if(e===this.TEXTURE_2D){if(R>this._maxTextureSize||W>this._maxTextureSize||Y>this._maxTextureLevel)return this.setError(this.INVALID_VALUE),!1}else if(this._validCubeTarget(e)){if(R>this._maxCubeMapSize||W>this._maxCubeMapSize||Y>this._maxCubeMapLevel)return this.setError(this.INVALID_VALUE),!1}else return this.setError(this.INVALID_ENUM),!1;return!0}};function installTextureIntrospectionMethods(e){Object.assign(e,Od)}function installTextureManagementMethods(e){installTextureLifecycleMethods(e),installTexImage2DMethods(e),installCopyAndCompressedTextureMethods(e),installTextureParameterMethods(e),installTextureIntrospectionMethods(e)}const kd={bindFramebuffer(e,R){if(!checkObject(R))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(e!==this.FRAMEBUFFER){this.setError(this.INVALID_ENUM);return}if(!R)this._gl.bindFramebuffer(this.FRAMEBUFFER,this._gtkFboId);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLFramebuffer))this._gl.bindFramebuffer(this.FRAMEBUFFER,R._|0);else return;let W=this._activeFramebuffer;W!==R&&(W&&(--W._refCount,W._checkDelete()),R&&(R._refCount+=1)),this._activeFramebuffer=R,R&&this._updateFramebufferAttachments(R)},bindRenderbuffer(e,R){if(!checkObject(R))throw TypeError(`bindRenderbuffer(GLenum, WebGLRenderbuffer)`);if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}if(!R)this._gl.bindRenderbuffer(e|0,0);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLRenderbuffer))this._gl.bindRenderbuffer(e|0,R._|0);else return;let W=this._activeRenderbuffer;W!==R&&(W&&(--W._refCount,W._checkDelete()),R&&(R._refCount+=1)),this._activeRenderbuffer=R},framebufferRenderbuffer(e,R,W,Y){if(!checkObject(Y))throw TypeError(`framebufferRenderbuffer(GLenum, GLenum, GLenum, WebGLRenderbuffer)`);if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R)||W!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeFramebuffer;if(!X){this.setError(this.INVALID_OPERATION);return}Y&&!this._checkWrapper(Y,WebGLRenderbuffer)||(X._setAttachment(Y,R),this._updateFramebufferAttachments(X))},framebufferTexture2D(e,R,W,Y,X=0){if(e|=0,R|=0,W|=0,X|=0,!checkObject(Y))throw TypeError(`framebufferTexture2D(GLenum, GLenum, GLenum, WebGLTexture, GLint)`);if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R)){this.setError(this.INVALID_ENUM);return}if(X!==0){this.setError(this.INVALID_VALUE);return}if(Y&&!this._checkWrapper(Y,WebGLTexture))return;if(W===this.TEXTURE_2D){if(Y&&Y._binding!==this.TEXTURE_2D){this.setError(this.INVALID_OPERATION);return}}else if(this._validCubeTarget(W)){if(Y&&Y._binding!==this.TEXTURE_CUBE_MAP){this.setError(this.INVALID_OPERATION);return}}else{this.setError(this.INVALID_ENUM);return}let ie=this._activeFramebuffer;if(!ie){this.setError(this.INVALID_OPERATION);return}ie._attachmentLevel[R]=X,ie._attachmentFace[R]=W,ie._setAttachment(Y,R),this._updateFramebufferAttachments(ie)},createFramebuffer(){let e=this._gl.createFramebuffer();if(e<=0)return null;let R=new WebGLFramebuffer(e,this);return this._framebuffers[e]=R,R},deleteFramebuffer(e){if(!checkObject(e))throw TypeError(`deleteFramebuffer(WebGLFramebuffer)`);if(!(e instanceof WebGLFramebuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._activeFramebuffer===e&&this.bindFramebuffer(this.FRAMEBUFFER,null),e._pendingDelete=!0,e._checkDelete()},createRenderbuffer(){let e=this._gl.createRenderbuffer();if(e<=0)return null;let R=new WebGLRenderbuffer(e,this);return this._renderbuffers[e]=R,R},deleteRenderbuffer(e){if(!checkObject(e))throw TypeError(`deleteRenderbuffer(WebGLRenderbuffer)`);if(!(e instanceof WebGLRenderbuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._activeRenderbuffer===e&&this.bindRenderbuffer(this.RENDERBUFFER,null),this._detachRenderbufferFromAllFramebuffers(e),e._pendingDelete=!0,e._checkDelete()},renderbufferStorage(e=0,R=0,W=0,Y=0){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeRenderbuffer;if(!X){this.setError(this.INVALID_OPERATION);return}if(R!==this.RGBA4&&R!==this.RGB565&&R!==this.RGB5_A1&&R!==this.DEPTH_COMPONENT16&&R!==this.STENCIL_INDEX&&R!==this.STENCIL_INDEX8&&R!==this.DEPTH_STENCIL){this.setError(this.INVALID_ENUM);return}this._saveError(),this._gl.renderbufferStorage(e,R,W,Y);let ie=this.getError();if(this._restoreError(ie),ie!==this.NO_ERROR)return;X._width=W,X._height=Y,X._format=R;let ae=this._activeFramebuffer;if(ae){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(ae._attachments[R[W]]===X){e=!0;break}e&&this._updateFramebufferAttachments(this._activeFramebuffer)}},getFramebufferAttachmentParameter(e=0,R=0,W=0){if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R))return this.setError(this.INVALID_ENUM),null;let Y=this._activeFramebuffer;if(!Y)return this.setError(this.INVALID_OPERATION),null;let X=Y._attachments[R];if(X===null){if(W===this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)return this.NONE}else if(X instanceof WebGLTexture)switch(W){case this.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:return X;case this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:return this.TEXTURE;case this.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:return Y._attachmentLevel[R];case this.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:{let e=Y._attachmentFace[R];return e===this.TEXTURE_2D?0:e}}else if(X instanceof WebGLRenderbuffer)switch(W){case this.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:return X;case this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:return this.RENDERBUFFER}return this.setError(this.INVALID_ENUM),null},getRenderbufferParameter(e=0,R=0){if(e!==this.RENDERBUFFER)return this.setError(this.INVALID_ENUM),null;let W=this._activeRenderbuffer;if(!W)return this.setError(this.INVALID_OPERATION),null;switch(R){case this.RENDERBUFFER_INTERNAL_FORMAT:return W._format;case this.RENDERBUFFER_WIDTH:return W._width;case this.RENDERBUFFER_HEIGHT:return W._height;case this.MAX_RENDERBUFFER_SIZE:return this._maxRenderbufferSize;case this.RENDERBUFFER_RED_SIZE:case this.RENDERBUFFER_GREEN_SIZE:case this.RENDERBUFFER_BLUE_SIZE:case this.RENDERBUFFER_ALPHA_SIZE:case this.RENDERBUFFER_DEPTH_SIZE:case this.RENDERBUFFER_STENCIL_SIZE:return this._gl.getRenderbufferParameter(e,R)}return this.setError(this.INVALID_ENUM),null},checkFramebufferStatus(e){if(e!==this.FRAMEBUFFER)return this.setError(this.INVALID_ENUM),0;let R=this._activeFramebuffer;return R?this._preCheckFramebufferStatus(R):this.FRAMEBUFFER_COMPLETE},_preCheckFramebufferStatus(e){let R=e._attachments,W=[],Y=[],X=R[this.DEPTH_ATTACHMENT],ie=R[this.DEPTH_STENCIL_ATTACHMENT],ae=R[this.STENCIL_ATTACHMENT];if(ie&&(ae||X)||ae&&X)return this.FRAMEBUFFER_UNSUPPORTED;let le=this._getColorAttachments(),_e=0;for(let e in R)R[e]&&le.indexOf(Number(e))!==-1&&_e++;if(_e===0)return this.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;if(ie instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(ie instanceof WebGLRenderbuffer){if(ie._format!==this.DEPTH_STENCIL)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(ie._width),Y.push(ie._height)}if(X instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(X instanceof WebGLRenderbuffer){if(X._format!==this.DEPTH_COMPONENT16)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(X._width),Y.push(X._height)}if(ae instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(ae instanceof WebGLRenderbuffer){if(ae._format!==this.STENCIL_INDEX8)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(ae._width),Y.push(ae._height)}let ye=!1;for(let X=0;X<le.length;++X){let ie=R[le[X]];if(ie instanceof WebGLTexture){if(ie._format!==this.RGBA||!(ie._type===this.UNSIGNED_BYTE||ie._type===this.FLOAT))return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;ye=!0;let R=e._attachmentLevel[this.COLOR_ATTACHMENT0];if(R===null)throw TypeError(`level is null!`);W.push(ie._levelWidth[R]),Y.push(ie._levelHeight[R])}else if(ie instanceof WebGLRenderbuffer){let e=ie._format;if(e!==this.RGBA4&&e!==this.RGB565&&e!==this.RGB5_A1)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;ye=!0,W.push(ie._width),Y.push(ie._height)}}if(!ye&&!ae&&!X&&!ie)return this.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;if(W.length<=0||Y.length<=0)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;for(let e=1;e<W.length;++e)if(W[e-1]!==W[e]||Y[e-1]!==Y[e])return this.FRAMEBUFFER_INCOMPLETE_DIMENSIONS;return W[0]===0||Y[0]===0?this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:(e._width=W[0],e._height=Y[0],this.FRAMEBUFFER_COMPLETE)},_framebufferOk(){let e=this._activeFramebuffer;return e&&this._preCheckFramebufferStatus(e)!==this.FRAMEBUFFER_COMPLETE?(this.setError(this.INVALID_FRAMEBUFFER_OPERATION),!1):!0},_validFramebufferAttachment(e){switch(e){case this.DEPTH_ATTACHMENT:case this.STENCIL_ATTACHMENT:case this.DEPTH_STENCIL_ATTACHMENT:case this.COLOR_ATTACHMENT0:return!0}if(this._extensions.webgl_draw_buffers){let R=this._extensions.webgl_draw_buffers;return e<R.COLOR_ATTACHMENT0_WEBGL+R._maxDrawBuffers}return!1},_updateFramebufferAttachments(e){if(!e)return;let R=e._status,W=this._getAttachments();if(e._status=this._preCheckFramebufferStatus(e),e._status!==this.FRAMEBUFFER_COMPLETE){if(R===this.FRAMEBUFFER_COMPLETE)for(let R=0;R<W.length;++R){let Y=W[R];this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,0,e._attachmentLevel[Y]||0)}return}for(let R=0;R<W.length;++R){let Y=W[R];this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,0,e._attachmentLevel[Y]||0)}for(let R=0;R<W.length;++R){let Y=W[R],X=e._attachments[Y];X instanceof WebGLTexture?this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,X._|0,e._attachmentLevel[Y]||0):X instanceof WebGLRenderbuffer&&this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,Y,this.RENDERBUFFER,X._|0)}},_tryDetachFramebuffer(e,R){if(e&&e._linked(R)){let W=this._getAttachments();for(let Y=0;Y<W.length;++Y)e._attachments[W[Y]]===R&&this.framebufferTexture2D(this.FRAMEBUFFER,W[Y]|0,this.TEXTURE_2D,null)}},_detachRenderbufferFromAllFramebuffers(e){let R=this._activeFramebuffer,W=this._getAttachments(),Y=!1;for(let X in this._framebuffers){let ie=this._framebuffers[X];if(!(!ie||!ie._linked(e))){ie!==R&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,ie._|0),Y=!0);for(let R=0;R<W.length;++R){let Y=W[R];ie._attachments[Y]===e&&(this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,Y,this.RENDERBUFFER,0),ie._setAttachment(null,Y))}}}Y&&this._gl.bindFramebuffer(this.FRAMEBUFFER,R?R._|0:this._gtkFboId)},_getAttachments(){return this._extensions.webgl_draw_buffers?this._extensions.webgl_draw_buffers._ALL_ATTACHMENTS:this.DEFAULT_ATTACHMENTS},_getColorAttachments(){return this._extensions.webgl_draw_buffers?this._extensions.webgl_draw_buffers._ALL_COLOR_ATTACHMENTS:this.DEFAULT_COLOR_ATTACHMENTS},_resizeDrawingBuffer(e,R){let W=this._activeFramebuffer,Y=this._getActiveTexture(this.TEXTURE_2D),X=this._activeRenderbuffer,ie=this._contextAttributes,ae=this._drawingBuffer;ae?._framebuffer&&this._gl.bindFramebuffer(this.FRAMEBUFFER,ae?._framebuffer);let le=this._getAttachments();for(let e=0;e<le.length;++e)this._gl.framebufferTexture2D(this.FRAMEBUFFER,le[e],this.TEXTURE_2D,0,0);ae?._color&&this._gl.bindTexture(this.TEXTURE_2D,ae?._color);let _e=ie.alpha?this.RGBA:this.RGB;this._gl.texImage2D(this.TEXTURE_2D,0,_e,e,R,0,_e,this.UNSIGNED_BYTE,Uint8ArrayToVariant(null)),this._gl.texParameteri(this.TEXTURE_2D,this.TEXTURE_MIN_FILTER,this.NEAREST),this._gl.texParameteri(this.TEXTURE_2D,this.TEXTURE_MAG_FILTER,this.NEAREST),ae?._color&&this._gl.framebufferTexture2D(this.FRAMEBUFFER,this.COLOR_ATTACHMENT0,this.TEXTURE_2D,ae?._color,0);let ye=0,be=0;ie.depth&&ie.stencil?(ye=this.DEPTH_STENCIL,be=this.DEPTH_STENCIL_ATTACHMENT):ie.depth?(ye=33191,be=this.DEPTH_ATTACHMENT):ie.stencil&&(ye=this.STENCIL_INDEX8,be=this.STENCIL_ATTACHMENT),ye&&(ae?._depthStencil&&this._gl.bindRenderbuffer(this.RENDERBUFFER,ae?._depthStencil),this._gl.renderbufferStorage(this.RENDERBUFFER,ye,e,R),ae?._depthStencil&&this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,be,this.RENDERBUFFER,ae?._depthStencil)),this.bindFramebuffer(this.FRAMEBUFFER,W),this.bindTexture(this.TEXTURE_2D,Y),this.bindRenderbuffer(this.RENDERBUFFER,X)},_allocateDrawingBuffer(e,R){this._drawingBuffer=new WebGLDrawingBufferWrapper(this._gl.createFramebuffer(),this._gl.createTexture(),this._gl.createRenderbuffer()),this._resizeDrawingBuffer(e,R)},resize(e=0,R=0){if(e|=0,R|=0,e>0&&R>0)(e!==this.drawingBufferWidth||R!==this.drawingBufferHeight)&&this._resizeDrawingBuffer(e,R);else throw Error(`Invalid surface dimensions`)}};function installFramebufferMethods(e){Object.assign(e,kd)}var Ad=__commonJSMin(((e,R)=>{R.exports=`precision.highp.mediump.lowp.attribute.const.uniform.varying.break.continue.do.for.while.if.else.in.out.inout.float.int.uint.void.bool.true.false.discard.return.mat2.mat3.mat4.vec2.vec3.vec4.ivec2.ivec3.ivec4.bvec2.bvec3.bvec4.sampler1D.sampler2D.sampler3D.samplerCube.sampler1DShadow.sampler2DShadow.struct.asm.class.union.enum.typedef.template.this.packed.goto.switch.default.inline.noinline.volatile.public.static.extern.external.interface.long.short.double.half.fixed.unsigned.input.output.hvec2.hvec3.hvec4.dvec2.dvec3.dvec4.fvec2.fvec3.fvec4.sampler2DRect.sampler3DRect.sampler2DRectShadow.sizeof.cast.namespace.using`.split(`.`)})),jd=__commonJSMin(((e,R)=>{R.exports=`<<= >>= ++ -- << >> <= >= == != && || += -= *= /= %= &= ^^ ^= |= ( ) [ ] . ! ~ * / % + - < > & ^ | ? : = , ; { }`.split(` `)})),Md=__commonJSMin(((e,R)=>{R.exports=`abs.acos.all.any.asin.atan.ceil.clamp.cos.cross.dFdx.dFdy.degrees.distance.dot.equal.exp.exp2.faceforward.floor.fract.gl_BackColor.gl_BackLightModelProduct.gl_BackLightProduct.gl_BackMaterial.gl_BackSecondaryColor.gl_ClipPlane.gl_ClipVertex.gl_Color.gl_DepthRange.gl_DepthRangeParameters.gl_EyePlaneQ.gl_EyePlaneR.gl_EyePlaneS.gl_EyePlaneT.gl_Fog.gl_FogCoord.gl_FogFragCoord.gl_FogParameters.gl_FragColor.gl_FragCoord.gl_FragData.gl_FragDepth.gl_FragDepthEXT.gl_FrontColor.gl_FrontFacing.gl_FrontLightModelProduct.gl_FrontLightProduct.gl_FrontMaterial.gl_FrontSecondaryColor.gl_LightModel.gl_LightModelParameters.gl_LightModelProducts.gl_LightProducts.gl_LightSource.gl_LightSourceParameters.gl_MaterialParameters.gl_MaxClipPlanes.gl_MaxCombinedTextureImageUnits.gl_MaxDrawBuffers.gl_MaxFragmentUniformComponents.gl_MaxLights.gl_MaxTextureCoords.gl_MaxTextureImageUnits.gl_MaxTextureUnits.gl_MaxVaryingFloats.gl_MaxVertexAttribs.gl_MaxVertexTextureImageUnits.gl_MaxVertexUniformComponents.gl_ModelViewMatrix.gl_ModelViewMatrixInverse.gl_ModelViewMatrixInverseTranspose.gl_ModelViewMatrixTranspose.gl_ModelViewProjectionMatrix.gl_ModelViewProjectionMatrixInverse.gl_ModelViewProjectionMatrixInverseTranspose.gl_ModelViewProjectionMatrixTranspose.gl_MultiTexCoord0.gl_MultiTexCoord1.gl_MultiTexCoord2.gl_MultiTexCoord3.gl_MultiTexCoord4.gl_MultiTexCoord5.gl_MultiTexCoord6.gl_MultiTexCoord7.gl_Normal.gl_NormalMatrix.gl_NormalScale.gl_ObjectPlaneQ.gl_ObjectPlaneR.gl_ObjectPlaneS.gl_ObjectPlaneT.gl_Point.gl_PointCoord.gl_PointParameters.gl_PointSize.gl_Position.gl_ProjectionMatrix.gl_ProjectionMatrixInverse.gl_ProjectionMatrixInverseTranspose.gl_ProjectionMatrixTranspose.gl_SecondaryColor.gl_TexCoord.gl_TextureEnvColor.gl_TextureMatrix.gl_TextureMatrixInverse.gl_TextureMatrixInverseTranspose.gl_TextureMatrixTranspose.gl_Vertex.greaterThan.greaterThanEqual.inversesqrt.length.lessThan.lessThanEqual.log.log2.matrixCompMult.max.min.mix.mod.normalize.not.notEqual.pow.radians.reflect.refract.sign.sin.smoothstep.sqrt.step.tan.texture2D.texture2DLod.texture2DProj.texture2DProjLod.textureCube.textureCubeLod.texture2DLodEXT.texture2DProjLodEXT.textureCubeLodEXT.texture2DGradEXT.texture2DProjGradEXT.textureCubeGradEXT`.split(`.`)})),Nd=__commonJSMin(((e,R)=>{R.exports=Ad().slice().concat(`layout.centroid.smooth.case.mat2x2.mat2x3.mat2x4.mat3x2.mat3x3.mat3x4.mat4x2.mat4x3.mat4x4.uvec2.uvec3.uvec4.samplerCubeShadow.sampler2DArray.sampler2DArrayShadow.isampler2D.isampler3D.isamplerCube.isampler2DArray.usampler2D.usampler3D.usamplerCube.usampler2DArray.coherent.restrict.readonly.writeonly.resource.atomic_uint.noperspective.patch.sample.subroutine.common.partition.active.filter.image1D.image2D.image3D.imageCube.iimage1D.iimage2D.iimage3D.iimageCube.uimage1D.uimage2D.uimage3D.uimageCube.image1DArray.image2DArray.iimage1DArray.iimage2DArray.uimage1DArray.uimage2DArray.image1DShadow.image2DShadow.image1DArrayShadow.image2DArrayShadow.imageBuffer.iimageBuffer.uimageBuffer.sampler1DArray.sampler1DArrayShadow.isampler1D.isampler1DArray.usampler1D.usampler1DArray.isampler2DRect.usampler2DRect.samplerBuffer.isamplerBuffer.usamplerBuffer.sampler2DMS.isampler2DMS.usampler2DMS.sampler2DMSArray.isampler2DMSArray.usampler2DMSArray`.split(`.`))})),Pd=__commonJSMin(((e,R)=>{var W=Md();W=W.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),R.exports=W.concat(`gl_VertexID.gl_InstanceID.gl_Position.gl_PointSize.gl_FragCoord.gl_FrontFacing.gl_FragDepth.gl_PointCoord.gl_MaxVertexAttribs.gl_MaxVertexUniformVectors.gl_MaxVertexOutputVectors.gl_MaxFragmentInputVectors.gl_MaxVertexTextureImageUnits.gl_MaxCombinedTextureImageUnits.gl_MaxTextureImageUnits.gl_MaxFragmentUniformVectors.gl_MaxDrawBuffers.gl_MinProgramTexelOffset.gl_MaxProgramTexelOffset.gl_DepthRangeParameters.gl_DepthRange.trunc.round.roundEven.isnan.isinf.floatBitsToInt.floatBitsToUint.intBitsToFloat.uintBitsToFloat.packSnorm2x16.unpackSnorm2x16.packUnorm2x16.unpackUnorm2x16.packHalf2x16.unpackHalf2x16.outerProduct.transpose.determinant.inverse.texture.textureSize.textureProj.textureLod.textureOffset.texelFetch.texelFetchOffset.textureProjOffset.textureLodOffset.textureProjLod.textureProjLodOffset.textureGrad.textureGradOffset.textureProjGrad.textureProjGradOffset`.split(`.`))})),Fd=__commonJSMin(((e,R)=>{R.exports=tokenize;var W=Ad(),Y=jd(),X=Md(),ie=Nd(),ae=Pd(),le=999,_e=9999,ye=0,be=1,Ce=2,Te=3,Oe=4,Ae=5,Me=6,Pe=7,Re=8,Be=9,Ve=10,He=11,Ue=[`block-comment`,`line-comment`,`preprocessor`,`operator`,`integer`,`float`,`ident`,`builtin`,`keyword`,`whitespace`,`eof`,`integer`];function tokenize(e){var R=0,We=0,Ge=le,Ke,qe,Je=[],Ye=[],Xe=1,Ze=0,Qe=0,$e=!1,et=!1,tt=``,nt;e||={};var rt=X,it=W;e.version===`300 es`&&(rt=ae,it=ie);for(var at={},st={},R=0;R<rt.length;R++)at[rt[R]]=!0;for(var R=0;R<it.length;R++)st[it[R]]=!0;return function(e){return Ye=[],e===null?end():write(e)};function token(e){e.length&&Ye.push({type:Ue[Ge],data:e,position:Qe,line:Xe,column:Ze})}function write(e){R=0,e.toString&&(e=e.toString()),tt+=e.replace(/\r\n/g,`
|
|
9
|
+
`)}send(e){if(this.readyState!==1)throw new DOMException(`Must open first`,`InvalidStateError`);if(this._aborted)return;let R={};this._headers.forEach((e,W)=>{R[W]=e});let W={method:this._method,headers:R,credentials:this.withCredentials?`include`:`omit`,signal:this._controller.signal};e!=null&&this._method!==`GET`&&this._method!==`HEAD`&&(W.body=e),this.timeout>0&&(this._timeoutId=setTimeout(()=>{this._controller.abort(),this._onTimeout()},this.timeout)),this.dispatchEvent(new Event(`loadstart`)),this.onloadstart&&this.onloadstart(new ProgressEvent(`loadstart`)),fetch$1(this._url,W).then(async e=>{if(!this._aborted){switch(this._timeoutId&&=(clearTimeout(this._timeoutId),null),this.status=e.status,this.statusText=e.statusText,this.responseURL=e.url,e.headers.forEach((e,R)=>{this._responseHeaders.set(R.toLowerCase(),e)}),this._setReadyState(2),this._setReadyState(3),this.responseType){case`arraybuffer`:{let R=await e.arrayBuffer();this.response=R,this.responseText=``;break}case`blob`:{let R=await e.arrayBuffer(),W=writeBlobToTempFile(new Uint8Array(R),this._url),Y=new Blob([R],{type:this._responseHeaders.get(`content-type`)??``});Y._tmpPath=W,this.response=Y,this.responseText=``;break}case`json`:{let R=await e.text();this.responseText=``;try{this.response=R.length>0?JSON.parse(R):null}catch{this.response=null}break}case`document`:{let R=await e.text();this.responseText=R,this.response=R;break}default:{let R=await e.text(),W=R.charCodeAt(0)===65279?R.slice(1):R;this.responseText=W,this.response=W;break}}this._setReadyState(4),this.dispatchEvent(new ProgressEvent(`load`)),this.dispatchEvent(new ProgressEvent(`loadend`)),this.onload&&this.onload(new ProgressEvent(`load`)),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))}}).catch(e=>{if(this._timeoutId&&=(clearTimeout(this._timeoutId),null),this._aborted)return;this._setReadyState(4);let R=new ProgressEvent(`error`);this.dispatchEvent(R),this.onerror&&this.onerror(R),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))})}abort(){if(this._aborted)return;this._aborted=!0,this._timeoutId&&=(clearTimeout(this._timeoutId),null),this._controller.abort(),this.readyState!==0&&this.readyState!==4&&(this._setReadyState(4),this.status=0);let e=new ProgressEvent(`abort`);this.dispatchEvent(e),this.onabort&&this.onabort(e),this.onloadend&&this.onloadend(new ProgressEvent(`loadend`))}overrideMimeType(e){}_onTimeout(){if(this._aborted)return;this._aborted=!0,this._setReadyState(4);let e=new ProgressEvent(`timeout`);this.dispatchEvent(e),this.ontimeout&&this.ontimeout(e)}_setReadyState(e){this.readyState=e;let R=new Event(`readystatechange`);this.dispatchEvent(R),this.onreadystatechange&&this.onreadystatechange(R)}},XMLHttpRequestUpload=class extends EventTarget{onprogress=null;onloadstart=null;onloadend=null;onload=null;onerror=null;onabort=null;ontimeout=null};bt(),Uu(),mu(),$e();const fd=new Set([`data:`,`http:`,`https:`,`file:`]);function rewriteRootRelativeUrl(e){if(typeof e!=`string`||!e.startsWith(`/`)||e.startsWith(`//`))return e;let R=globalThis,W=R.__GJSIFY_DEBUG_FETCH===!0;try{let Y=R.imports?.system?.programPath??R.imports?.system?.programInvocationName??``;if(!Y)return e;let X=`file://${Qe.path_get_dirname(Y)}${e}`;return W&&yt.log(`[fetch] rewrite ${e} → ${X}`),X}catch(R){return W&&yt.warn(`[fetch] rewrite FAILED: ${R instanceof Error?R.message:String(R)}`),e}}async function fetch$1(e,R={}){e=rewriteRootRelativeUrl(e);let W=new ud(e,R),{parsedURL:Y,options:X}=getSoupRequestOptions(W);if(!fd.has(Y.protocol))throw TypeError(`@gjsify/fetch cannot load ${e}. URL scheme "${Y.protocol.replace(/:$/,``)}" is not supported.`);if(Y.protocol===`data:`){let{buffer:e,typeFull:R}=parseDataUri(W.url);return new od(Buffer.from(e),{headers:{"Content-Type":R}})}if(Y.protocol===`file:`){let e=globalThis.__GJSIFY_DEBUG_FETCH===!0;e&&yt.log(`[fetch] file:// ${W.url}`);try{let R=Qe.filename_from_uri(W.url)[0];e&&yt.log(`[fetch] file:// path=${R}`);let[Y,X]=Qe.file_get_contents(R);if(e&&yt.log(`[fetch] file:// ok=${Y} bytes=${X?.byteLength??`?`}`),!Y)throw new FetchError(`Failed to read file: ${R}`,`system`);let ie=X,ae=new Uint8Array(ie.byteLength);ae.set(ie);let le=new od(ae);return e&&yt.log(`[fetch] file:// response created`),le}catch(R){let Y=R instanceof Error?R:Error(String(R));throw e&&yt.warn(`[fetch] file:// FAIL: ${Y.message}`),new FetchError(`request to ${W.url} failed, reason: ${Y.message}`,`system`,Y)}}let{signal:ie}=W;if(ie&&ie.aborted)throw new AbortError(`The operation was aborted.`);let ae,le;try{let e=await W._send(X);ae=e.readable,le=e.cancellable}catch(e){let R=e instanceof Error?e:Error(String(e));throw new FetchError(`request to ${W.url} failed, reason: ${R.message}`,`system`,R)}let abortHandler=()=>{le.cancel()};ie&&ie.addEventListener(`abort`,abortHandler,{once:!0});let finalize=()=>{ie&&ie.removeEventListener(`abort`,abortHandler)};le.connect(()=>{ae.destroy(new AbortError(`The operation was aborted.`))}),ae.on(`error`,e=>{finalize()});let _e=W._message,ye=Hu._newFromSoupMessage(_e),be=_e.status_code,Ce=_e.get_reason_phrase();if(isRedirect(be)){let e=ye.get(`Location`),Y=null;try{Y=e===null?null:new hs(e,W.url)}catch{if(W.redirect!==`manual`)throw finalize(),new FetchError(`uri requested responds with an invalid redirect URL: ${e}`,`invalid-redirect`)}switch(W.redirect){case`error`:throw finalize(),new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${W.url}`,`no-redirect`);case`manual`:break;case`follow`:{if(Y===null)break;if(W.counter>=W.follow)throw finalize(),new FetchError(`maximum redirect reached at: ${W.url}`,`max-redirect`);let e={headers:new Hu(W.headers),follow:W.follow,counter:W.counter+1,agent:W.agent,compress:W.compress,method:W.method,body:clone(W),signal:W.signal,size:W.size,referrer:W.referrer,referrerPolicy:W.referrerPolicy};if(!isDomainOrSubdomain(W.url,Y)||!isSameProtocol(W.url,Y))for(let R of[`authorization`,`www-authenticate`,`cookie`,`cookie2`])e.headers.delete(R);if(be!==303&&W.body&&R.body instanceof pu.Readable)throw finalize(),new FetchError(`Cannot follow redirect with body being a readable stream`,`unsupported-redirect`);(be===303||(be===301||be===302)&&W.method===`POST`)&&(e.method=`GET`,e.body=void 0,e.headers.delete(`content-length`));let X=parseReferrerPolicyFromHeader(ye);return X&&(e.referrerPolicy=X),finalize(),fetch$1(new ud(Y,e))}default:throw TypeError(`Redirect option '${W.redirect}' is not a valid value of RequestRedirect`)}}let Te={url:W.url,status:be,statusText:Ce,headers:ye,size:W.size,counter:W.counter,highWaterMark:W.highWaterMark},Oe=ye.get(`Content-Encoding`);if(!W.compress||W.method===`HEAD`||Oe===null||be===204||be===304)return finalize(),new od(ae,Te);if(typeof DecompressionStream<`u`){let e=null;if(Oe===`gzip`||Oe===`x-gzip`?e=`gzip`:(Oe===`deflate`||Oe===`x-deflate`)&&(e=`deflate`),e){let R=new Ke([await new od(ae,Te).arrayBuffer()]).stream().pipeThrough(new DecompressionStream(e));return finalize(),new od(R,Te)}}return finalize(),new od(ae,Te)}__name$1(fetch$1,`fetch`);const pd=globalThis;globalThis.fetch===void 0&&(pd.fetch=fetch$1),globalThis.Headers===void 0&&(pd.Headers=Hu),globalThis.Request===void 0&&(pd.Request=ud),globalThis.Response===void 0&&(pd.Response=od),globalThis.XMLHttpRequest===void 0&&(globalThis.XMLHttpRequest=XMLHttpRequest$1),globalThis.XMLHttpRequestUpload===void 0&&(globalThis.XMLHttpRequestUpload=XMLHttpRequestUpload);const md=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(md.ByteLengthQueuingStrategy=Nl),globalThis.CountQueuingStrategy===void 0&&(md.CountQueuingStrategy=Fl);const hd=globalThis;function isNativeStreamUsable$2(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(hd.ReadableStream=Al),hd.ReadableStreamBYOBReader===void 0&&(hd.ReadableStreamBYOBReader=ReadableStreamBYOBReader),hd.ReadableStreamBYOBRequest===void 0&&(hd.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),hd.ReadableByteStreamController===void 0&&(hd.ReadableByteStreamController=ReadableByteStreamController),hd.ReadableStreamDefaultController===void 0&&(hd.ReadableStreamDefaultController=ReadableStreamDefaultController),hd.ReadableStreamDefaultReader===void 0&&(hd.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const gd=globalThis;globalThis.TextEncoderStream===void 0&&(gd.TextEncoderStream=Ll),globalThis.TextDecoderStream===void 0&&(gd.TextDecoderStream=Rl);function isNativeStreamUsable$1(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}if(__name$1(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=Ml}function isNativeStreamUsable(e,R){try{return typeof e==`function`?typeof e.prototype?.[R]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=jl}const _d=globalThis.WebAssembly;if(_d===void 0)throw Error(`@gjsify/webassembly: globalThis.WebAssembly is not defined; nothing to polyfill.`);const vd=_d.Module,yd=_d.Instance;function compile(e){try{return Promise.resolve(new vd(e))}catch(e){return Promise.reject(e)}}function validate(e){try{return new vd(e),!0}catch{return!1}}function instantiate(e,R){try{if(e instanceof vd)return Promise.resolve(new yd(e,R));let W=new vd(e),Y=new yd(W,R);return Promise.resolve({module:W,instance:Y})}catch(e){return Promise.reject(e)}}async function bufferFromSource(e){return(await e).arrayBuffer()}async function compileStreaming(e){return compile(await bufferFromSource(e))}async function instantiateStreaming(e,R){return instantiate(await bufferFromSource(e),R)}const bd=globalThis.WebAssembly;if(bd!==void 0){let replace=(e,R)=>{try{Object.defineProperty(bd,e,{value:R,writable:!0,configurable:!0,enumerable:!0})}catch{}};replace(`compile`,compile),replace(`compileStreaming`,compileStreaming),replace(`instantiate`,instantiate),replace(`instantiateStreaming`,instantiateStreaming),replace(`validate`,validate)}globalThis.imports;var WebGLContextAttributes=class{constructor(e,R,W,Y,X,ie,ae,le){this.alpha=e,this.depth=R,this.stencil=W,this.antialias=Y,this.premultipliedAlpha=X,this.preserveDrawingBuffer=ie,this.preferLowPowerToHighPerformance=ae,this.failIfMajorPerformanceCaveat=le}},WebGLUniformLocation=class{constructor(e,R,W){this._linkCount=0,this._array=null,this._=e,this._program=R,this._linkCount=R._linkCount,this._activeInfo=W,this._array=null}},OESElementIndexUint=class{};function getOESElementIndexUint(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_element_index_uint`)>=0&&(R=new OESElementIndexUint),R}var OESStandardDerivatives=class{constructor(){this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723}};function getOESStandardDerivatives(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_standard_derivatives`)>=0&&(R=new OESStandardDerivatives),R}var OESTextureFloat=class{};function getOESTextureFloat(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_texture_float`)>=0&&(R=new OESTextureFloat),R}var OESTextureFloatLinear=class{};function getOESTextureFloatLinear(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`OES_texture_float_linear`)>=0&&(R=new OESTextureFloatLinear),R}var STACKGLDestroyContext=class{constructor(e){this.destroy=e.destroy.bind(e)}};function getSTACKGLDestroyContext(e){return new STACKGLDestroyContext(e)}var STACKGLResizeDrawingBuffer=class{constructor(e){this.resize=e.resize.bind(e)}};function getSTACKGLResizeDrawingBuffer(e){return new STACKGLResizeDrawingBuffer(e)}var EXTBlendMinMax=class{constructor(){this.MIN_EXT=32775,this.MAX_EXT=32776}};function getEXTBlendMinMax(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`EXT_blend_minmax`)>=0&&(R=new EXTBlendMinMax),R}var EXTColorBufferFloat=class{};function getEXTColorBufferFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`EXT_color_buffer_float`)>=0?new EXTColorBufferFloat:null}var EXTColorBufferHalfFloat=class{};function getEXTColorBufferHalfFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`EXT_color_buffer_half_float`)>=0?new EXTColorBufferHalfFloat:null}var EXTTextureFilterAnisotropic=class{constructor(){this.TEXTURE_MAX_ANISOTROPY_EXT=34046,this.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047}};function getEXTTextureFilterAnisotropic(e){let R=null,W=e.getSupportedExtensions();return W&&W.indexOf(`EXT_texture_filter_anisotropic`)>=0&&(R=new EXTTextureFilterAnisotropic),R}var OESTextureHalfFloat=class{constructor(){this.HALF_FLOAT_OES=36193}};function getOESTextureHalfFloat(e){let R=e.getSupportedExtensions();return R&&R.indexOf(`OES_texture_half_float`)>=0||e._native2?new OESTextureHalfFloat:null}var WebGLTextureUnit=class{constructor(e,R){this._mode=0,this._bind2D=null,this._bindCube=null,this._ctx=e,this._idx=R}},Linkable=class{constructor(e){this._=0,this._references=[],this._refCount=0,this._pendingDelete=!1,this._binding=0,this._=e,this._references=[],this._refCount=0,this._pendingDelete=!1,this._binding=0}_link(e){return this._references.push(e),e._refCount+=1,!0}_unlink(e){let R=this._references.indexOf(e);if(R<0)return!1;for(;R>=0;)this._references[R]=this._references[this._references.length-1],this._references.pop(),--e._refCount,e._checkDelete(),R=this._references.indexOf(e);return!0}_linked(e){return this._references.indexOf(e)>=0}_checkDelete(){if(this._refCount<=0&&this._pendingDelete&&this._!==0){for(;this._references.length>0;)this._unlink(this._references[0]);this._performDelete(),this._=0}}_performDelete(){}},WebGLBuffer=class extends Linkable{constructor(e,R){super(e),this._size=0,this._elements=new Uint8Array,this._ctx=R}_performDelete(){let e=this._ctx;delete e._buffers[this._|0],e._gl.deleteBuffer(this._)}},WebGLVertexArrayObjectAttribute=class{constructor(e,R){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=0,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0,this._ctx=e,this._idx=R,this._pointerType=e.FLOAT,this._clear()}_clear(){this._isPointer=!1,this._pointerBuffer=null,this._pointerOffset=0,this._pointerSize=0,this._pointerStride=0,this._pointerType=this._ctx.FLOAT,this._pointerNormal=!1,this._divisor=0,this._inputSize=4,this._inputStride=0}},WebGLVertexArrayGlobalAttribute=class{constructor(e){this._idx=0,this._idx=e,this._data=new Float32Array([0,0,0,1])}},WebGLVertexArrayObjectState=class{constructor(e){this._elementArrayBufferBinding=null;let R=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:R});for(let W=0;W<R;++W)this._attribs[W]=new WebGLVertexArrayObjectAttribute(e,W);this._elementArrayBufferBinding=null}setElementArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setElementArrayBuffer(WebGLBuffer?)`);let R=this._elementArrayBufferBinding;R!==e&&(R&&(--R._refCount,R._checkDelete()),e&&(e._refCount+=1),this._elementArrayBufferBinding=e)}cleanUp(){let e=this._elementArrayBufferBinding;e&&(--e._refCount,e._checkDelete(),this._elementArrayBufferBinding=null);for(let e=0;e<this._attribs.length;++e){let R=this._attribs[e];R._pointerBuffer&&(--R._pointerBuffer._refCount,R._pointerBuffer._checkDelete()),R._clear()}}releaseArrayBuffer(e){if(e)for(let R=0;R<this._attribs.length;++R){let W=this._attribs[R];W._pointerBuffer===e&&(--W._pointerBuffer._refCount,W._pointerBuffer._checkDelete(),W._clear())}}setVertexAttribPointer(e,R,W,Y,X,ie,ae,le,_e){let ye=this._attribs[R];e!==ye._pointerBuffer&&(ye._pointerBuffer&&(--ye._pointerBuffer._refCount,ye._pointerBuffer._checkDelete()),e&&(e._refCount+=1),ye._pointerBuffer=e),ye._pointerSize=W,ye._pointerOffset=Y,ye._pointerStride=X,ye._pointerType=ie,ye._pointerNormal=ae,ye._inputStride=le,ye._inputSize=_e}},WebGLVertexArrayGlobalState=class{constructor(e){this._arrayBufferBinding=null;let R=e.getParameter(e.MAX_VERTEX_ATTRIBS);this._attribs=Array.from({length:R});for(let e=0;e<R;++e)this._attribs[e]=new WebGLVertexArrayGlobalAttribute(e);this._arrayBufferBinding=null}setArrayBuffer(e){if(e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`setArrayBuffer(WebGLBuffer?)`);let R=this._arrayBufferBinding;R!==e&&(R&&(--R._refCount,R._checkDelete()),e&&(e._refCount+=1),this._arrayBufferBinding=e)}},WebGLFramebuffer=class extends Linkable{constructor(e,R){if(super(e),this._binding=0,this._width=0,this._height=0,this._status=null,this._ctx=R,this._attachments={},this._attachments[R.COLOR_ATTACHMENT0]=null,this._attachments[R.DEPTH_ATTACHMENT]=null,this._attachments[R.STENCIL_ATTACHMENT]=null,this._attachments[R.DEPTH_STENCIL_ATTACHMENT]=null,this._attachmentLevel={},this._attachmentLevel[R.COLOR_ATTACHMENT0]=0,this._attachmentLevel[R.DEPTH_ATTACHMENT]=0,this._attachmentLevel[R.STENCIL_ATTACHMENT]=0,this._attachmentLevel[R.DEPTH_STENCIL_ATTACHMENT]=0,this._attachmentFace={},this._attachmentFace[R.COLOR_ATTACHMENT0]=0,this._attachmentFace[R.DEPTH_ATTACHMENT]=0,this._attachmentFace[R.STENCIL_ATTACHMENT]=0,this._attachmentFace[R.DEPTH_STENCIL_ATTACHMENT]=0,R._extensions.webgl_draw_buffers){let e=R._extensions.webgl_draw_buffers;this._attachments[e.COLOR_ATTACHMENT1_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT2_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT3_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT4_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT5_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT6_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT7_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT8_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT9_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT10_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT11_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT12_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT13_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT14_WEBGL]=null,this._attachments[e.COLOR_ATTACHMENT15_WEBGL]=null,this._attachments[R.NONE]=null,this._attachments[R.BACK]=null,this._attachmentLevel[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentLevel[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentLevel[R.NONE]=null,this._attachmentLevel[R.BACK]=null,this._attachmentFace[e.COLOR_ATTACHMENT1_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT2_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT3_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT4_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT5_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT6_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT7_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT8_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT9_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT10_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT11_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT12_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT13_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT14_WEBGL]=0,this._attachmentFace[e.COLOR_ATTACHMENT15_WEBGL]=0,this._attachmentFace[R.NONE]=null,this._attachmentFace[R.BACK]=null}}_clearAttachment(e){let R=this._attachments[e];R&&(this._attachments[e]=null,this._unlink(R))}_setAttachment(e,R){this._attachments[R]!==e&&(this._clearAttachment(R),e&&(this._attachments[R]=e,this._link(e)))}_performDelete(){let e=this._ctx;delete e._framebuffers[this._|0],e._gl.deleteFramebuffer(this._|0)}},WebGLProgram=class extends Linkable{constructor(e,R){super(e),this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[],this._ctx=R,this._linkCount=0,this._linkStatus=!1,this._linkInfoLog=`not linked`,this._attributes=[],this._uniforms=[]}_performDelete(){let e=this._ctx;delete e._programs[this._|0],e._gl.deleteProgram(this._|0)}},WebGLRenderbuffer=class extends Linkable{constructor(e,R){super(e),this._binding=0,this._width=0,this._height=0,this._format=0,this._ctx=R,this._binding=0,this._width=0,this._height=0,this._format=0}_performDelete(){let e=this._ctx;delete e._renderbuffers[this._|0],e._gl.deleteRenderbuffer(this._)}},WebGLShader=class extends Linkable{constructor(e,R,W){super(e),this._source=``,this._compileStatus=!1,this._compileInfo=``,this._needsRecompile=!1,this._type=W,this._ctx=R,this._source=``,this._compileStatus=!1,this._compileInfo=``}_performDelete(){let e=this._ctx;delete e._shaders[this._|0],e._gl.deleteShader(this._|0)}},WebGLTexture=class extends Linkable{constructor(e,R){super(e),this._binding=0,this._levelWidth=new Int32Array(32),this._levelHeight=new Int32Array(32),this._format=0,this._type=0,this._complete=!0,this._ctx=R}_performDelete(){let e=this._ctx;delete e._textures[this._|0],e._gl.deleteTexture(this._|0)}},WebGLDrawingBufferWrapper=class{constructor(e,R,W){this._framebuffer=e,this._color=R,this._depthStencil=W}},WebGLShaderPrecisionFormat=class{constructor(e){this.rangeMin=e.rangeMin,this.rangeMax=e.rangeMax,this.precision=e.precision}},WebGLActiveInfo=class{constructor(e){this.size=e.size,this.type=e.type,this.name=e.name}};$e();function checkObject(e){return typeof e==`object`||e===void 0}function checkUniform(e,R){return R instanceof WebGLUniformLocation&&R._program===e&&R._linkCount===e._linkCount}function isTypedArray(e){return e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function isValidString(e){let R=e.replace(/(?:\/\*(?:[\s\S]*?)\*\/)|(?:([\s;])+\/\/(?:.*)$)/gm,``);return!/["$`@\\'\0]/.test(R)}function vertexCount(e,R,W){switch(R){case e.TRIANGLES:return W-W%3;case e.LINES:return W-W%2;case e.LINE_LOOP:case e.POINTS:return W;case e.TRIANGLE_FAN:case e.LINE_STRIP:return W<2?0:W;case e.TRIANGLE_STRIP:return W<3?0:W;default:return-1}}function typeSize(e,R){switch(R){case e.UNSIGNED_BYTE:case e.BYTE:return 1;case e.UNSIGNED_SHORT:case e.SHORT:return 2;case e.UNSIGNED_INT:case e.INT:case e.FLOAT:return 4}return 0}function uniformTypeSize(e,R){switch(R){case e.BOOL_VEC4:case e.INT_VEC4:case e.FLOAT_VEC4:return 4;case e.BOOL_VEC3:case e.INT_VEC3:case e.FLOAT_VEC3:return 3;case e.BOOL_VEC2:case e.INT_VEC2:case e.FLOAT_VEC2:return 2;case e.BOOL:case e.INT:case e.FLOAT:case e.SAMPLER_2D:case e.SAMPLER_CUBE:return 1;default:return 0}}const listToArray=e=>{let R=[];for(let W of e.values())R.push(W);return R};function arrayToUint8Array(e){if(isTypedArray(e))return new Uint8Array(e.buffer).subarray(e.byteOffset,e.byteLength+e.byteOffset);if(Array.isArray(e)||e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e.values==`function`)return new Uint8Array(listToArray(e));throw Error(`Can't unpack typed array!`)}function Uint8ArrayToVariant(e){return new Qe.Variant(`ay`,e)}const extractImageData=e=>{let R=e.width,W=e.height;if(typeof e==`object`&&R!==void 0&&W!==void 0){if(e.data!==void 0)return e;let Y=null;if(typeof e.getContext==`function`)Y=e.getContext(`2d`);else if(typeof e.isPixbuf==`function`&&e.isPixbuf())return e.getImageData();else if(e.src!==void 0&&typeof document==`object`&&typeof document.createElement==`function`){let X=document.createElement(`canvas`);typeof X==`object`&&typeof X.getContext==`function`&&(X.width=R,X.height=W,Y=X.getContext(`2d`),Y!==null&&Y.drawImage(e,0,0))}if(Y!==null)return Y.getImageData(0,0,R,W)}return null};function formatSize(e,R){switch(R){case e.ALPHA:case e.LUMINANCE:return 1;case e.LUMINANCE_ALPHA:return 2;case e.RGB:return 3;case e.RGBA:return 4}return 0}function convertPixels(e){if(typeof e==`object`&&e){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint8ClampedArray||e instanceof Float32Array)return arrayToUint8Array(e);if(e instanceof Buffer)return new Uint8Array(e)}return null}function checkFormat(e,R){return R===e.ALPHA||R===e.LUMINANCE_ALPHA||R===e.LUMINANCE||R===e.RGB||R===e.RGBA}function validCubeTarget(e,R){return R===e.TEXTURE_CUBE_MAP_POSITIVE_X||R===e.TEXTURE_CUBE_MAP_NEGATIVE_X||R===e.TEXTURE_CUBE_MAP_POSITIVE_Y||R===e.TEXTURE_CUBE_MAP_NEGATIVE_Y||R===e.TEXTURE_CUBE_MAP_POSITIVE_Z||R===e.TEXTURE_CUBE_MAP_NEGATIVE_Z}function flag(e,R,W){return!e||typeof e!=`object`||!(R in e)?W:!!e[R]}function premultiplyAlpha(e){let R=new Uint8Array(e.length);for(let W=0;W<e.length;W+=4){let Y=e[W+3]/255;R[W]=Math.round(e[W]*Y),R[W+1]=Math.round(e[W+1]*Y),R[W+2]=Math.round(e[W+2]*Y),R[W+3]=e[W+3]}return R}const xd={enable(e=0){this._gl.enable(e)},disable(e=0){if(this._gl.disable(e),e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP){let R=this._getActiveTextureUnit();R._mode===e&&(R._mode=0)}},cullFace(e){this._gl.cullFace(e|0)},depthFunc(e){switch(e|=0,e){case this.NEVER:case this.LESS:case this.EQUAL:case this.LEQUAL:case this.GREATER:case this.NOTEQUAL:case this.GEQUAL:case this.ALWAYS:this._gl.depthFunc(e);return;default:this.setError(this.INVALID_ENUM)}},depthMask(e){this._gl.depthMask(!!e)},depthRange(e,R){if(e=+e,R=+R,e<=R){this._gl.depthRange(e,R);return}this.setError(this.INVALID_OPERATION)},frontFace(e=0){this._gl.frontFace(e)},lineWidth(e){if(isNaN(e)){this.setError(this.INVALID_VALUE);return}this._gl.lineWidth(+e)},polygonOffset(e,R){this._gl.polygonOffset(+e,+R)},sampleCoverage(e,R){this._gl.sampleCoverage(+e,!!R)},hint(e=0,R=0){let W=this._extensions.oes_standard_derivatives;if(!(e===this.GENERATE_MIPMAP_HINT||W&&e===W.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)){this.setError(this.INVALID_ENUM);return}if(R!==this.FASTEST&&R!==this.NICEST&&R!==this.DONT_CARE){this.setError(this.INVALID_ENUM);return}this._gl.hint(e,R)},finish(){this._gl.finish()},flush(){this._gl.flush()},blendColor(e=0,R=0,W=0,Y=0){this._gl.blendColor(+e,+R,+W,+Y)},blendEquation(e=0){if(this._validBlendMode(e)){this._gl.blendEquation(e);return}this.setError(this.INVALID_ENUM)},blendEquationSeparate(e=0,R=0){if(this._validBlendMode(e)&&this._validBlendMode(R)){this._gl.blendEquationSeparate(e,R);return}this.setError(this.INVALID_ENUM)},blendFunc(e=0,R=0){if(!this._validBlendFunc(e)||!this._validBlendFunc(R)){this.setError(this.INVALID_ENUM);return}if(this._isConstantBlendFunc(e)&&this._isConstantBlendFunc(R)){this.setError(this.INVALID_OPERATION);return}this._gl.blendFunc(e,R)},blendFuncSeparate(e=0,R=0,W=0,Y=0){if(!(this._validBlendFunc(e)&&this._validBlendFunc(R)&&this._validBlendFunc(W)&&this._validBlendFunc(Y))){this.setError(this.INVALID_ENUM);return}if(this._isConstantBlendFunc(e)&&this._isConstantBlendFunc(R)||this._isConstantBlendFunc(W)&&this._isConstantBlendFunc(Y)){this.setError(this.INVALID_OPERATION);return}this._gl.blendFuncSeparate(e,R,W,Y)},clear(e=0){this._framebufferOk()&&this._gl.clear(e)},clearColor(e,R,W,Y){this._gl.clearColor(+e,+R,+W,+Y)},clearDepth(e){this._gl.clearDepth(+e)},clearStencil(e=0){this._checkStencil=!1,this._gl.clearStencil(e)},colorMask(e,R,W,Y){this._gl.colorMask(!!e,!!R,!!W,!!Y)},stencilFunc(e,R,W){this._checkStencil=!0,this._gl.stencilFunc(e|0,R|0,W|0)},stencilFuncSeparate(e,R,W,Y){this._checkStencil=!0,this._gl.stencilFuncSeparate(e|0,R|0,W|0,Y|0)},stencilMask(e){this._checkStencil=!0,this._gl.stencilMask(e>>>0)},stencilMaskSeparate(e,R){this._checkStencil=!0,this._gl.stencilMaskSeparate(e|0,R>>>0)},stencilOp(e,R,W){this._checkStencil=!0,this._gl.stencilOp(e|0,R|0,W|0)},stencilOpSeparate(e,R,W,Y){this._checkStencil=!0,this._gl.stencilOpSeparate(e|0,R|0,W|0,Y|0)},isEnabled(e=0){return this._gl.isEnabled(e)},isContextLost(){return!1},getError(){return this._gl.getError()},setError(e){this._gl.setError(e)},isBuffer(e){return this._isObject(e,`isBuffer`,WebGLBuffer)?this._gl.isBuffer(e?._):!1},isFramebuffer(e){return this._isObject(e,`isFramebuffer`,WebGLFramebuffer)?this._gl.isFramebuffer(e?._):!1},isProgram(e){return this._isObject(e,`isProgram`,WebGLProgram)?this._gl.isProgram(e?._):!1},isRenderbuffer(e){return this._isObject(e,`isRenderbuffer`,WebGLRenderbuffer)?this._gl.isRenderbuffer(e?._):!1},isShader(e){return this._isObject(e,`isShader`,WebGLShader)?this._gl.isShader(e?._):!1},isTexture(e){return this._isObject(e,`isTexture`,WebGLTexture)?this._gl.isTexture(e?._):!1},generateMipmap(e=0){this._gl.generateMipmap(e)},_validBlendFunc(e){return e===this.ZERO||e===this.ONE||e===this.SRC_COLOR||e===this.ONE_MINUS_SRC_COLOR||e===this.DST_COLOR||e===this.ONE_MINUS_DST_COLOR||e===this.SRC_ALPHA||e===this.ONE_MINUS_SRC_ALPHA||e===this.DST_ALPHA||e===this.ONE_MINUS_DST_ALPHA||e===this.SRC_ALPHA_SATURATE||e===this.CONSTANT_COLOR||e===this.ONE_MINUS_CONSTANT_COLOR||e===this.CONSTANT_ALPHA||e===this.ONE_MINUS_CONSTANT_ALPHA},_validBlendMode(e){let R=this._extensions.ext_blend_minmax;return e===this.FUNC_ADD||e===this.FUNC_SUBTRACT||e===this.FUNC_REVERSE_SUBTRACT||!!(R&&(e===R.MIN_EXT||e===R.MAX_EXT))},_isConstantBlendFunc(e){return e===this.CONSTANT_COLOR||e===this.ONE_MINUS_CONSTANT_COLOR||e===this.CONSTANT_ALPHA||e===this.ONE_MINUS_CONSTANT_ALPHA},_saveError(){this._errorStack.push(this.getError())},_restoreError(e){let R=this._errorStack.pop();R===this.NO_ERROR?this.setError(e):R!==void 0&&this.setError(R)}};function installStateMethods(e){Object.assign(e,xd)}const Sd={bindBuffer(e=0,R){if(!checkObject(R))throw TypeError(`bindBuffer(GLenum, WebGLBuffer)`);if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}if(!R)R=null,this._gl.bindBuffer(e,0);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLBuffer)){if(R._binding&&R._binding!==e){this.setError(this.INVALID_OPERATION);return}R._binding=e|0,this._gl.bindBuffer(e,R._|0)}else return;e===this.ARRAY_BUFFER?this._vertexGlobalState.setArrayBuffer(R):this._vertexObjectState.setElementArrayBuffer(R)},bufferData(e=0,R,W=0){let Y=0,X=null;if(typeof R==`number`?Y=R:typeof R==`object`&&(X=R),W!==this.STREAM_DRAW&&W!==this.STATIC_DRAW&&W!==this.DYNAMIC_DRAW){this.setError(this.INVALID_ENUM);return}if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}let ie=this._getActiveBuffer(e);if(!ie){this.setError(this.INVALID_OPERATION);return}if(X){let R=null;if(isTypedArray(X)||X instanceof DataView||X instanceof ArrayBuffer)R=arrayToUint8Array(X);else{this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.bufferData(e,Uint8ArrayToVariant(R),W);let Y=this.getError();if(this._restoreError(Y),Y!==this.NO_ERROR)return;ie._size=R.length,e===this.ELEMENT_ARRAY_BUFFER&&(ie._elements=new Uint8Array(R))}else if(typeof R==`number`){if(Y<0){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.bufferDataSizeOnly(e,Y,W);let R=this.getError();if(this._restoreError(R),R!==this.NO_ERROR)return;ie._size=Y,e===this.ELEMENT_ARRAY_BUFFER&&(ie._elements=new Uint8Array(Y))}else this.setError(this.INVALID_VALUE)},bufferSubData(e=0,R=0,W){if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER){this.setError(this.INVALID_ENUM);return}if(typeof W!=`object`||!W)throw TypeError(`bufferSubData: data must be a BufferSource`);let Y=this._getActiveBuffer(e);if(!Y){this.setError(this.INVALID_OPERATION);return}if(R<0||R>=Y._size){this.setError(this.INVALID_VALUE);return}let X=null;if(isTypedArray(W)||W instanceof DataView||W instanceof ArrayBuffer)X=arrayToUint8Array(W);else{this.setError(this.INVALID_VALUE);return}if(R+X.length>Y._size){this.setError(this.INVALID_VALUE);return}e===this.ELEMENT_ARRAY_BUFFER&&Y._elements.set(X,R),this._gl.bufferSubData(e,R,Uint8ArrayToVariant(X))},createBuffer(){let e=this._gl.createBuffer();if(!e||e<=0)return null;let R=new WebGLBuffer(e,this);return this._buffers[e]=R,R},deleteBuffer(e){if(!checkObject(e)||e!==null&&!(e instanceof WebGLBuffer))throw TypeError(`deleteBuffer(WebGLBuffer)`);if(!(e instanceof WebGLBuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._vertexGlobalState._arrayBufferBinding===e&&this.bindBuffer(this.ARRAY_BUFFER,null),this._vertexObjectState._elementArrayBufferBinding===e&&this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this._vertexObjectState===this._defaultVertexObjectState&&this._vertexObjectState.releaseArrayBuffer(e),e._pendingDelete=!0,e._checkDelete()},getBufferParameter(e=0,R=0){if(e!==this.ARRAY_BUFFER&&e!==this.ELEMENT_ARRAY_BUFFER)return this.setError(this.INVALID_ENUM),null;switch(R){case this.BUFFER_SIZE:case this.BUFFER_USAGE:return this._gl.getBufferParameteriv(e|0,R|0)[0];default:return this.setError(this.INVALID_ENUM),null}},_getActiveBuffer(e){return e===this.ARRAY_BUFFER?this._vertexGlobalState._arrayBufferBinding:e===this.ELEMENT_ARRAY_BUFFER?this._vertexObjectState._elementArrayBufferBinding:null}};function installBufferBindingMethods(e){Object.assign(e,Sd)}const Cd={activeTexture(e=0){let R=e-this.TEXTURE0;if(R>=0&&R<this._textureUnits.length){this._activeTextureUnit=R,this._gl.activeTexture(e);return}this.setError(this.INVALID_ENUM)},bindTexture(e=0,R){if(!checkObject(R))throw TypeError(`bindTexture(GLenum, WebGLTexture)`);if(!this._validTextureTarget(e)){this.setError(this.INVALID_ENUM);return}let W=0;if(!R)R=null;else if(R instanceof WebGLTexture&&R._pendingDelete)return;else if(this._checkWrapper(R,WebGLTexture)){if(R._binding&&R._binding!==e){this.setError(this.INVALID_OPERATION);return}R._binding=e,R._complete&&(W=R._|0)}else return;this._saveError(),this._gl.bindTexture(e,W);let Y=this.getError();if(this._restoreError(Y),Y!==this.NO_ERROR)return;let X=this._getActiveTextureUnit(),ie=this._getActiveTexture(e);ie!==R&&(ie&&(--ie._refCount,ie._checkDelete()),R&&(R._refCount+=1)),e===this.TEXTURE_2D?X._bind2D=R:e===this.TEXTURE_CUBE_MAP&&(X._bindCube=R)},createTexture(){let e=this._gl.createTexture();if(e<=0)return null;let R=new WebGLTexture(e,this);return this._textures[e]=R,R},deleteTexture(e){if(!checkObject(e))throw TypeError(`deleteTexture(WebGLTexture)`);if(e instanceof WebGLTexture){if(!this._checkOwns(e)){this.setError(this.INVALID_OPERATION);return}}else return;let R=this._activeTextureUnit;for(let R=0;R<this._textureUnits.length;++R){let W=this._textureUnits[R];W._bind2D===e?(this.activeTexture(this.TEXTURE0+R),this.bindTexture(this.TEXTURE_2D,null)):W._bindCube===e&&(this.activeTexture(this.TEXTURE0+R),this.bindTexture(this.TEXTURE_CUBE_MAP,null))}this.activeTexture(this.TEXTURE0+R),this._detachTextureFromAllFramebuffers(e),e._pendingDelete=!0,e._checkDelete()},_detachTextureFromAllFramebuffers(e){let R=this._activeFramebuffer,W=this._getAttachments(),Y=!1;for(let X in this._framebuffers){let ie=this._framebuffers[X];if(!(!ie||!ie._linked(e))){ie!==R&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,ie._|0),Y=!0);for(let R=0;R<W.length;++R){let Y=W[R];ie._attachments[Y]===e&&(this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,ie._attachmentFace[Y]||this.TEXTURE_2D,0,ie._attachmentLevel[Y]||0),ie._setAttachment(null,Y))}}}Y&&this._gl.bindFramebuffer(this.FRAMEBUFFER,R?R._|0:this._gtkFboId)},pixelStorei(e=0,R=0){if(typeof R==`boolean`&&(R=R===!1?0:1),e===this.UNPACK_ALIGNMENT)if(R===1||R===2||R===4||R===8)this._unpackAlignment=R;else{this.setError(this.INVALID_VALUE);return}else if(e===this.PACK_ALIGNMENT)if(R===1||R===2||R===4||R===8)this._packAlignment=R;else{this.setError(this.INVALID_VALUE);return}else if(e===this.UNPACK_COLORSPACE_CONVERSION_WEBGL){if(!(R===this.NONE||R===this.BROWSER_DEFAULT_WEBGL)){this.setError(this.INVALID_VALUE);return}}else if(e===this.UNPACK_FLIP_Y_WEBGL){this._unpackFlipY=!!R;return}else if(e===this.UNPACK_PREMULTIPLY_ALPHA_WEBGL){this._unpackPremultAlpha=!!R;return}this._gl.pixelStorei(e,R)}};function installTextureLifecycleMethods(e){Object.assign(e,Cd)}const wd={texImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe,Ae,Me=0;if(arguments.length===6)if(_e=X,Te=Y,ie instanceof le.Pixbuf)Ae=ie,be=Ae.get_width(),Ce=Ae.get_height(),ye=Ae.get_pixels();else{Oe=ie;let e=extractImageData(Oe);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else arguments.length===9&&(be=Y,Ce=X,Me=ie,Te=ae,ye=ye);if(typeof ye!=`object`&&ye!==void 0)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!checkFormat(this,Te)||!checkFormat(this,W)){this.setError(this.INVALID_ENUM);return}if(_e===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let Pe=this._getTexImage(e);if(!Pe||Te!==W){this.setError(this.INVALID_OPERATION);return}let Re=this._computePixelSize(_e,Te);if(Re===0||!this._checkDimensions(e,be,Ce,R))return;let Be=convertPixels(ye),Ve=this._computeRowStride(be,Re),He=Ve*Ce;if(Be&&Be.length<He){this.setError(this.INVALID_OPERATION);return}if(Me!==0||validCubeTarget(this,e)&&be!==Ce){this.setError(this.INVALID_VALUE);return}if(this._unpackPremultAlpha&&Be&&Te===this.RGBA&&(Be=premultiplyAlpha(Be)),this._unpackFlipY&&Be&&be>0&&Ce>0){let e=new Uint8Array(Be.length);for(let R=0;R<Ce;R++){let W=R*Ve,Y=(Ce-1-R)*Ve;e.set(Be.subarray(W,W+Ve),Y)}Be=e}this._saveError(),this._gl.texImage2D(e,R,W,be,Ce,Me,Te,_e,Uint8ArrayToVariant(Be));let Ue=this.getError();if(this._restoreError(Ue),Ue!==this.NO_ERROR)return;Pe._levelWidth[R]=be,Pe._levelHeight[R]=Ce,Pe._format=Te,Pe._type=_e;let We=this._activeFramebuffer;if(We){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(We._attachments[R[W]]===Pe){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}},texSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe,Ae;if(arguments.length===7)if(_e=ie,Te=X,ae instanceof le.Pixbuf)Ae=ae,be=Ae.get_width(),Ce=Ae.get_height(),ye=Ae.get_pixels();else{Oe=ae;let e=extractImageData(Oe);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else be=X,Ce=ie,Te=ae;if(typeof ye!=`object`)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(_e===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let Me=this._computePixelSize(_e,Te);if(Me===0||!this._checkDimensions(e,be,Ce,R))return;if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}let Pe=convertPixels(ye),Re=this._computeRowStride(be,Me),Be=Re*Ce;if(!Pe||Pe.length<Be){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&Pe&&Te===this.RGBA&&(Pe=premultiplyAlpha(Pe)),this._unpackFlipY&&Pe&&be>0&&Ce>0){let e=new Uint8Array(Pe.length);for(let R=0;R<Ce;R++){let W=R*Re,Y=(Ce-1-R)*Re;e.set(Pe.subarray(W,W+Re),Y)}Pe=e}this._gl.texSubImage2D(e,R,W,Y,be,Ce,Te,_e,Uint8ArrayToVariant(Pe))}};function installTexImage2DMethods(e){Object.assign(e,wd)}var Td=__toESM(__commonJSMin((e=>{e.INT_MIN=-1<<31,e.isPow2=function(e){return!(e&e-1)&&!!e},e.log2=function(e){var R=(e>65535)<<4,W;return e>>>=R,W=(e>255)<<3,e>>>=W,R|=W,W=(e>15)<<2,e>>>=W,R|=W,W=(e>3)<<1,e>>>=W,R|=W,R|e>>1},e.nextPow2=function(e){return e+=e===0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1},(function(e){for(var R=0;R<256;++R){var W=R,Y=R,X=7;for(W>>>=1;W;W>>>=1)Y<<=1,Y|=W&1,--X;e[R]=Y<<X&255}})(Array(256))}))(),1);const Ed={copyTexImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,le=0){let _e=this._getTexImage(e);if(!_e){this.setError(this.INVALID_OPERATION);return}if(W!==this.RGBA&&W!==this.RGB&&W!==this.ALPHA&&W!==this.LUMINANCE&&W!==this.LUMINANCE_ALPHA){this.setError(this.INVALID_ENUM);return}if(R<0||ie<0||ae<0||le!==0){this.setError(this.INVALID_VALUE);return}if(R>0&&!(Td.isPow2(ie)&&Td.isPow2(ae))){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.copyTexImage2D(e,R,W,Y,X,ie,ae,le);let ye=this.getError();this._restoreError(ye),ye===this.NO_ERROR&&(_e._levelWidth[R]=ie,_e._levelHeight[R]=ae,_e._format=this.RGBA,_e._type=this.UNSIGNED_BYTE)},copyTexSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,le=0){if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(ae<0||le<0||W<0||Y<0||R<0){this.setError(this.INVALID_VALUE);return}this._gl.copyTexSubImage2D(e,R,W,Y,X,ie,ae,le)},compressedTexImage2D(e,R,W,Y,X,ie,ae){this._gl.compressedTexImage2D(e,R,W,Y,X,ie,Uint8ArrayToVariant(arrayToUint8Array(ae)))},compressedTexSubImage2D(e,R,W,Y,X,ie,ae,le){this._gl.compressedTexSubImage2D(e,R,W,Y,X,ie,ae,Uint8ArrayToVariant(arrayToUint8Array(le)))}};function installCopyAndCompressedTextureMethods(e){Object.assign(e,Ed)}const Dd={texParameterf(e=0,R=0,W){if(W=+W,this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,R,W),R){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameterf(e,R,W);return}let Y=this._extensions.ext_texture_filter_anisotropic;if(Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameterf(e,R,W);return}this.setError(this.INVALID_ENUM)}},texParameteri(e=0,R=0,W=0){if(this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,R,W),R){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameteri(e,R,W);return}let Y=this._extensions.ext_texture_filter_anisotropic;if(Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameteri(e,R,W);return}this.setError(this.INVALID_ENUM)}},getTexParameter(e=0,R=0){if(!this._checkTextureTarget(e))return null;let W=this._getActiveTextureUnit();if(e===this.TEXTURE_2D&&!W._bind2D||e===this.TEXTURE_CUBE_MAP&&!W._bindCube)return this.setError(this.INVALID_OPERATION),null;switch(R){case this.TEXTURE_MAG_FILTER:case this.TEXTURE_MIN_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:return this._getTexParameterDirect(e,R)}let Y=this._extensions.ext_texture_filter_anisotropic;return Y&&R===Y.TEXTURE_MAX_ANISOTROPY_EXT?this._getTexParameterDirect(e,R):(this.setError(this.INVALID_ENUM),null)},_getTexParameterDirect(e=0,R=0){return this._gl.getTexParameterx(e,R)?.unpack()}};function installTextureParameterMethods(e){Object.assign(e,Dd)}const Od={_getActiveTextureUnit(){return this._textureUnits[this._activeTextureUnit]},_getActiveTexture(e){let R=this._getActiveTextureUnit();return e===this.TEXTURE_2D?R._bind2D:e===this.TEXTURE_CUBE_MAP?R._bindCube:null},_getTexImage(e){let R=this._getActiveTextureUnit();return e===this.TEXTURE_2D?R._bind2D:validCubeTarget(this,e)?R._bindCube:(this.setError(this.INVALID_ENUM),null)},_checkTextureTarget(e){let R=this._getActiveTextureUnit(),W=null;if(e===this.TEXTURE_2D)W=R._bind2D;else if(e===this.TEXTURE_CUBE_MAP)W=R._bindCube;else return this.setError(this.INVALID_ENUM),!1;return W?!0:(this.setError(this.INVALID_OPERATION),!1)},_validTextureTarget(e){return e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP},_validCubeTarget(e){return e===this.TEXTURE_CUBE_MAP_POSITIVE_X||e===this.TEXTURE_CUBE_MAP_NEGATIVE_X||e===this.TEXTURE_CUBE_MAP_POSITIVE_Y||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Y||e===this.TEXTURE_CUBE_MAP_POSITIVE_Z||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Z},_verifyTextureCompleteness(e,R,W){let Y=this._getActiveTextureUnit(),X=null;if(e===this.TEXTURE_2D?X=Y._bind2D:this._validCubeTarget(e)&&(X=Y._bindCube),this._extensions.oes_texture_float&&!this._extensions.oes_texture_float_linear&&X&&X._type===this.FLOAT&&(R===this.TEXTURE_MAG_FILTER||R===this.TEXTURE_MIN_FILTER)&&(W===this.LINEAR||W===this.LINEAR_MIPMAP_NEAREST||W===this.NEAREST_MIPMAP_LINEAR||W===this.LINEAR_MIPMAP_LINEAR)){X._complete=!1,this.bindTexture(e,X);return}X&&X._complete===!1&&(X._complete=!0,this.bindTexture(e,X))},_computePixelSize(e,R){let W=formatSize(this,R);if(W===0)return this.setError(this.INVALID_ENUM),0;switch(e){case this.UNSIGNED_BYTE:return W;case this.UNSIGNED_SHORT_5_6_5:if(R!==this.RGB){this.setError(this.INVALID_OPERATION);break}return 2;case this.UNSIGNED_SHORT_4_4_4_4:case this.UNSIGNED_SHORT_5_5_5_1:if(R!==this.RGBA){this.setError(this.INVALID_OPERATION);break}return 2;case this.FLOAT:return 1}return this.setError(this.INVALID_ENUM),0},_computeRowStride(e,R){let W=e*R;return W%this._unpackAlignment&&(W+=this._unpackAlignment-W%this._unpackAlignment),W},_checkDimensions(e,R,W,Y){if(Y<0||R<0||W<0)return this.setError(this.INVALID_VALUE),!1;if(e===this.TEXTURE_2D){if(R>this._maxTextureSize||W>this._maxTextureSize||Y>this._maxTextureLevel)return this.setError(this.INVALID_VALUE),!1}else if(this._validCubeTarget(e)){if(R>this._maxCubeMapSize||W>this._maxCubeMapSize||Y>this._maxCubeMapLevel)return this.setError(this.INVALID_VALUE),!1}else return this.setError(this.INVALID_ENUM),!1;return!0}};function installTextureIntrospectionMethods(e){Object.assign(e,Od)}function installTextureManagementMethods(e){installTextureLifecycleMethods(e),installTexImage2DMethods(e),installCopyAndCompressedTextureMethods(e),installTextureParameterMethods(e),installTextureIntrospectionMethods(e)}const kd={bindFramebuffer(e,R){if(!checkObject(R))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(e!==this.FRAMEBUFFER){this.setError(this.INVALID_ENUM);return}if(!R)this._gl.bindFramebuffer(this.FRAMEBUFFER,this._gtkFboId);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLFramebuffer))this._gl.bindFramebuffer(this.FRAMEBUFFER,R._|0);else return;let W=this._activeFramebuffer;W!==R&&(W&&(--W._refCount,W._checkDelete()),R&&(R._refCount+=1)),this._activeFramebuffer=R,R&&this._updateFramebufferAttachments(R)},bindRenderbuffer(e,R){if(!checkObject(R))throw TypeError(`bindRenderbuffer(GLenum, WebGLRenderbuffer)`);if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}if(!R)this._gl.bindRenderbuffer(e|0,0);else if(R._pendingDelete)return;else if(this._checkWrapper(R,WebGLRenderbuffer))this._gl.bindRenderbuffer(e|0,R._|0);else return;let W=this._activeRenderbuffer;W!==R&&(W&&(--W._refCount,W._checkDelete()),R&&(R._refCount+=1)),this._activeRenderbuffer=R},framebufferRenderbuffer(e,R,W,Y){if(!checkObject(Y))throw TypeError(`framebufferRenderbuffer(GLenum, GLenum, GLenum, WebGLRenderbuffer)`);if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R)||W!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeFramebuffer;if(!X){this.setError(this.INVALID_OPERATION);return}Y&&!this._checkWrapper(Y,WebGLRenderbuffer)||(X._setAttachment(Y,R),this._updateFramebufferAttachments(X))},framebufferTexture2D(e,R,W,Y,X=0){if(e|=0,R|=0,W|=0,X|=0,!checkObject(Y))throw TypeError(`framebufferTexture2D(GLenum, GLenum, GLenum, WebGLTexture, GLint)`);if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R)){this.setError(this.INVALID_ENUM);return}if(X!==0){this.setError(this.INVALID_VALUE);return}if(Y&&!this._checkWrapper(Y,WebGLTexture))return;if(W===this.TEXTURE_2D){if(Y&&Y._binding!==this.TEXTURE_2D){this.setError(this.INVALID_OPERATION);return}}else if(this._validCubeTarget(W)){if(Y&&Y._binding!==this.TEXTURE_CUBE_MAP){this.setError(this.INVALID_OPERATION);return}}else{this.setError(this.INVALID_ENUM);return}let ie=this._activeFramebuffer;if(!ie){this.setError(this.INVALID_OPERATION);return}ie._attachmentLevel[R]=X,ie._attachmentFace[R]=W,ie._setAttachment(Y,R),this._updateFramebufferAttachments(ie)},createFramebuffer(){let e=this._gl.createFramebuffer();if(e<=0)return null;let R=new WebGLFramebuffer(e,this);return this._framebuffers[e]=R,R},deleteFramebuffer(e){if(!checkObject(e))throw TypeError(`deleteFramebuffer(WebGLFramebuffer)`);if(!(e instanceof WebGLFramebuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._activeFramebuffer===e&&this.bindFramebuffer(this.FRAMEBUFFER,null),e._pendingDelete=!0,e._checkDelete()},createRenderbuffer(){let e=this._gl.createRenderbuffer();if(e<=0)return null;let R=new WebGLRenderbuffer(e,this);return this._renderbuffers[e]=R,R},deleteRenderbuffer(e){if(!checkObject(e))throw TypeError(`deleteRenderbuffer(WebGLRenderbuffer)`);if(!(e instanceof WebGLRenderbuffer&&this._checkOwns(e))){this.setError(this.INVALID_OPERATION);return}this._activeRenderbuffer===e&&this.bindRenderbuffer(this.RENDERBUFFER,null),this._detachRenderbufferFromAllFramebuffers(e),e._pendingDelete=!0,e._checkDelete()},renderbufferStorage(e=0,R=0,W=0,Y=0){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeRenderbuffer;if(!X){this.setError(this.INVALID_OPERATION);return}if(R!==this.RGBA4&&R!==this.RGB565&&R!==this.RGB5_A1&&R!==this.DEPTH_COMPONENT16&&R!==this.STENCIL_INDEX&&R!==this.STENCIL_INDEX8&&R!==this.DEPTH_STENCIL){this.setError(this.INVALID_ENUM);return}this._saveError(),this._gl.renderbufferStorage(e,R,W,Y);let ie=this.getError();if(this._restoreError(ie),ie!==this.NO_ERROR)return;X._width=W,X._height=Y,X._format=R;let ae=this._activeFramebuffer;if(ae){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(ae._attachments[R[W]]===X){e=!0;break}e&&this._updateFramebufferAttachments(this._activeFramebuffer)}},getFramebufferAttachmentParameter(e=0,R=0,W=0){if(e!==this.FRAMEBUFFER||!this._validFramebufferAttachment(R))return this.setError(this.INVALID_ENUM),null;let Y=this._activeFramebuffer;if(!Y)return this.setError(this.INVALID_OPERATION),null;let X=Y._attachments[R];if(X===null){if(W===this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)return this.NONE}else if(X instanceof WebGLTexture)switch(W){case this.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:return X;case this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:return this.TEXTURE;case this.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:return Y._attachmentLevel[R];case this.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:{let e=Y._attachmentFace[R];return e===this.TEXTURE_2D?0:e}}else if(X instanceof WebGLRenderbuffer)switch(W){case this.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:return X;case this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:return this.RENDERBUFFER}return this.setError(this.INVALID_ENUM),null},getRenderbufferParameter(e=0,R=0){if(e!==this.RENDERBUFFER)return this.setError(this.INVALID_ENUM),null;let W=this._activeRenderbuffer;if(!W)return this.setError(this.INVALID_OPERATION),null;switch(R){case this.RENDERBUFFER_INTERNAL_FORMAT:return W._format;case this.RENDERBUFFER_WIDTH:return W._width;case this.RENDERBUFFER_HEIGHT:return W._height;case this.MAX_RENDERBUFFER_SIZE:return this._maxRenderbufferSize;case this.RENDERBUFFER_RED_SIZE:case this.RENDERBUFFER_GREEN_SIZE:case this.RENDERBUFFER_BLUE_SIZE:case this.RENDERBUFFER_ALPHA_SIZE:case this.RENDERBUFFER_DEPTH_SIZE:case this.RENDERBUFFER_STENCIL_SIZE:return this._gl.getRenderbufferParameter(e,R)}return this.setError(this.INVALID_ENUM),null},checkFramebufferStatus(e){if(e!==this.FRAMEBUFFER)return this.setError(this.INVALID_ENUM),0;let R=this._activeFramebuffer;return R?this._preCheckFramebufferStatus(R):this.FRAMEBUFFER_COMPLETE},_preCheckFramebufferStatus(e){let R=e._attachments,W=[],Y=[],X=R[this.DEPTH_ATTACHMENT],ie=R[this.DEPTH_STENCIL_ATTACHMENT],ae=R[this.STENCIL_ATTACHMENT];if(ie&&(ae||X)||ae&&X)return this.FRAMEBUFFER_UNSUPPORTED;let le=this._getColorAttachments(),_e=0;for(let e in R)R[e]&&le.indexOf(Number(e))!==-1&&_e++;if(_e===0)return this.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;if(ie instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(ie instanceof WebGLRenderbuffer){if(ie._format!==this.DEPTH_STENCIL)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(ie._width),Y.push(ie._height)}if(X instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(X instanceof WebGLRenderbuffer){if(X._format!==this.DEPTH_COMPONENT16)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(X._width),Y.push(X._height)}if(ae instanceof WebGLTexture)return this.FRAMEBUFFER_UNSUPPORTED;if(ae instanceof WebGLRenderbuffer){if(ae._format!==this.STENCIL_INDEX8)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;W.push(ae._width),Y.push(ae._height)}let ye=!1;for(let X=0;X<le.length;++X){let ie=R[le[X]];if(ie instanceof WebGLTexture){if(ie._format!==this.RGBA||!(ie._type===this.UNSIGNED_BYTE||ie._type===this.FLOAT))return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;ye=!0;let R=e._attachmentLevel[this.COLOR_ATTACHMENT0];if(R===null)throw TypeError(`level is null!`);W.push(ie._levelWidth[R]),Y.push(ie._levelHeight[R])}else if(ie instanceof WebGLRenderbuffer){let e=ie._format;if(e!==this.RGBA4&&e!==this.RGB565&&e!==this.RGB5_A1)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;ye=!0,W.push(ie._width),Y.push(ie._height)}}if(!ye&&!ae&&!X&&!ie)return this.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;if(W.length<=0||Y.length<=0)return this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;for(let e=1;e<W.length;++e)if(W[e-1]!==W[e]||Y[e-1]!==Y[e])return this.FRAMEBUFFER_INCOMPLETE_DIMENSIONS;return W[0]===0||Y[0]===0?this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:(e._width=W[0],e._height=Y[0],this.FRAMEBUFFER_COMPLETE)},_framebufferOk(){let e=this._activeFramebuffer;return e&&this._preCheckFramebufferStatus(e)!==this.FRAMEBUFFER_COMPLETE?(this.setError(this.INVALID_FRAMEBUFFER_OPERATION),!1):!0},_validFramebufferAttachment(e){switch(e){case this.DEPTH_ATTACHMENT:case this.STENCIL_ATTACHMENT:case this.DEPTH_STENCIL_ATTACHMENT:case this.COLOR_ATTACHMENT0:return!0}if(this._extensions.webgl_draw_buffers){let R=this._extensions.webgl_draw_buffers;return e<R.COLOR_ATTACHMENT0_WEBGL+R._maxDrawBuffers}return!1},_updateFramebufferAttachments(e){if(!e)return;let R=e._status,W=this._getAttachments();if(e._status=this._preCheckFramebufferStatus(e),e._status!==this.FRAMEBUFFER_COMPLETE){if(R===this.FRAMEBUFFER_COMPLETE)for(let R=0;R<W.length;++R){let Y=W[R];this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,0,e._attachmentLevel[Y]||0)}return}for(let R=0;R<W.length;++R){let Y=W[R];this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,0,e._attachmentLevel[Y]||0)}for(let R=0;R<W.length;++R){let Y=W[R],X=e._attachments[Y];X instanceof WebGLTexture?this._gl.framebufferTexture2D(this.FRAMEBUFFER,Y,e._attachmentFace[Y]||0,X._|0,e._attachmentLevel[Y]||0):X instanceof WebGLRenderbuffer&&this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,Y,this.RENDERBUFFER,X._|0)}},_tryDetachFramebuffer(e,R){if(e&&e._linked(R)){let W=this._getAttachments();for(let Y=0;Y<W.length;++Y)e._attachments[W[Y]]===R&&this.framebufferTexture2D(this.FRAMEBUFFER,W[Y]|0,this.TEXTURE_2D,null)}},_detachRenderbufferFromAllFramebuffers(e){let R=this._activeFramebuffer,W=this._getAttachments(),Y=!1;for(let X in this._framebuffers){let ie=this._framebuffers[X];if(!(!ie||!ie._linked(e))){ie!==R&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,ie._|0),Y=!0);for(let R=0;R<W.length;++R){let Y=W[R];ie._attachments[Y]===e&&(this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,Y,this.RENDERBUFFER,0),ie._setAttachment(null,Y))}}}Y&&this._gl.bindFramebuffer(this.FRAMEBUFFER,R?R._|0:this._gtkFboId)},_getAttachments(){return this._extensions.webgl_draw_buffers?this._extensions.webgl_draw_buffers._ALL_ATTACHMENTS:this.DEFAULT_ATTACHMENTS},_getColorAttachments(){return this._extensions.webgl_draw_buffers?this._extensions.webgl_draw_buffers._ALL_COLOR_ATTACHMENTS:this.DEFAULT_COLOR_ATTACHMENTS},_resizeDrawingBuffer(e,R){let W=this._activeFramebuffer,Y=this._getActiveTexture(this.TEXTURE_2D),X=this._activeRenderbuffer,ie=this._contextAttributes,ae=this._drawingBuffer;ae?._framebuffer&&this._gl.bindFramebuffer(this.FRAMEBUFFER,ae?._framebuffer);let le=this._getAttachments();for(let e=0;e<le.length;++e)this._gl.framebufferTexture2D(this.FRAMEBUFFER,le[e],this.TEXTURE_2D,0,0);ae?._color&&this._gl.bindTexture(this.TEXTURE_2D,ae?._color);let _e=ie.alpha?this.RGBA:this.RGB;this._gl.texImage2D(this.TEXTURE_2D,0,_e,e,R,0,_e,this.UNSIGNED_BYTE,Uint8ArrayToVariant(null)),this._gl.texParameteri(this.TEXTURE_2D,this.TEXTURE_MIN_FILTER,this.NEAREST),this._gl.texParameteri(this.TEXTURE_2D,this.TEXTURE_MAG_FILTER,this.NEAREST),ae?._color&&this._gl.framebufferTexture2D(this.FRAMEBUFFER,this.COLOR_ATTACHMENT0,this.TEXTURE_2D,ae?._color,0);let ye=0,be=0;ie.depth&&ie.stencil?(ye=this.DEPTH_STENCIL,be=this.DEPTH_STENCIL_ATTACHMENT):ie.depth?(ye=33191,be=this.DEPTH_ATTACHMENT):ie.stencil&&(ye=this.STENCIL_INDEX8,be=this.STENCIL_ATTACHMENT),ye&&(ae?._depthStencil&&this._gl.bindRenderbuffer(this.RENDERBUFFER,ae?._depthStencil),this._gl.renderbufferStorage(this.RENDERBUFFER,ye,e,R),ae?._depthStencil&&this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,be,this.RENDERBUFFER,ae?._depthStencil)),this.bindFramebuffer(this.FRAMEBUFFER,W),this.bindTexture(this.TEXTURE_2D,Y),this.bindRenderbuffer(this.RENDERBUFFER,X)},_allocateDrawingBuffer(e,R){this._drawingBuffer=new WebGLDrawingBufferWrapper(this._gl.createFramebuffer(),this._gl.createTexture(),this._gl.createRenderbuffer()),this._resizeDrawingBuffer(e,R)},resize(e=0,R=0){if(e|=0,R|=0,e>0&&R>0)(e!==this.drawingBufferWidth||R!==this.drawingBufferHeight)&&this._resizeDrawingBuffer(e,R);else throw Error(`Invalid surface dimensions`)}};function installFramebufferMethods(e){Object.assign(e,kd)}var Ad=__commonJSMin(((e,R)=>{R.exports=`precision.highp.mediump.lowp.attribute.const.uniform.varying.break.continue.do.for.while.if.else.in.out.inout.float.int.uint.void.bool.true.false.discard.return.mat2.mat3.mat4.vec2.vec3.vec4.ivec2.ivec3.ivec4.bvec2.bvec3.bvec4.sampler1D.sampler2D.sampler3D.samplerCube.sampler1DShadow.sampler2DShadow.struct.asm.class.union.enum.typedef.template.this.packed.goto.switch.default.inline.noinline.volatile.public.static.extern.external.interface.long.short.double.half.fixed.unsigned.input.output.hvec2.hvec3.hvec4.dvec2.dvec3.dvec4.fvec2.fvec3.fvec4.sampler2DRect.sampler3DRect.sampler2DRectShadow.sizeof.cast.namespace.using`.split(`.`)})),jd=__commonJSMin(((e,R)=>{R.exports=`<<= >>= ++ -- << >> <= >= == != && || += -= *= /= %= &= ^^ ^= |= ( ) [ ] . ! ~ * / % + - < > & ^ | ? : = , ; { }`.split(` `)})),Md=__commonJSMin(((e,R)=>{R.exports=`abs.acos.all.any.asin.atan.ceil.clamp.cos.cross.dFdx.dFdy.degrees.distance.dot.equal.exp.exp2.faceforward.floor.fract.gl_BackColor.gl_BackLightModelProduct.gl_BackLightProduct.gl_BackMaterial.gl_BackSecondaryColor.gl_ClipPlane.gl_ClipVertex.gl_Color.gl_DepthRange.gl_DepthRangeParameters.gl_EyePlaneQ.gl_EyePlaneR.gl_EyePlaneS.gl_EyePlaneT.gl_Fog.gl_FogCoord.gl_FogFragCoord.gl_FogParameters.gl_FragColor.gl_FragCoord.gl_FragData.gl_FragDepth.gl_FragDepthEXT.gl_FrontColor.gl_FrontFacing.gl_FrontLightModelProduct.gl_FrontLightProduct.gl_FrontMaterial.gl_FrontSecondaryColor.gl_LightModel.gl_LightModelParameters.gl_LightModelProducts.gl_LightProducts.gl_LightSource.gl_LightSourceParameters.gl_MaterialParameters.gl_MaxClipPlanes.gl_MaxCombinedTextureImageUnits.gl_MaxDrawBuffers.gl_MaxFragmentUniformComponents.gl_MaxLights.gl_MaxTextureCoords.gl_MaxTextureImageUnits.gl_MaxTextureUnits.gl_MaxVaryingFloats.gl_MaxVertexAttribs.gl_MaxVertexTextureImageUnits.gl_MaxVertexUniformComponents.gl_ModelViewMatrix.gl_ModelViewMatrixInverse.gl_ModelViewMatrixInverseTranspose.gl_ModelViewMatrixTranspose.gl_ModelViewProjectionMatrix.gl_ModelViewProjectionMatrixInverse.gl_ModelViewProjectionMatrixInverseTranspose.gl_ModelViewProjectionMatrixTranspose.gl_MultiTexCoord0.gl_MultiTexCoord1.gl_MultiTexCoord2.gl_MultiTexCoord3.gl_MultiTexCoord4.gl_MultiTexCoord5.gl_MultiTexCoord6.gl_MultiTexCoord7.gl_Normal.gl_NormalMatrix.gl_NormalScale.gl_ObjectPlaneQ.gl_ObjectPlaneR.gl_ObjectPlaneS.gl_ObjectPlaneT.gl_Point.gl_PointCoord.gl_PointParameters.gl_PointSize.gl_Position.gl_ProjectionMatrix.gl_ProjectionMatrixInverse.gl_ProjectionMatrixInverseTranspose.gl_ProjectionMatrixTranspose.gl_SecondaryColor.gl_TexCoord.gl_TextureEnvColor.gl_TextureMatrix.gl_TextureMatrixInverse.gl_TextureMatrixInverseTranspose.gl_TextureMatrixTranspose.gl_Vertex.greaterThan.greaterThanEqual.inversesqrt.length.lessThan.lessThanEqual.log.log2.matrixCompMult.max.min.mix.mod.normalize.not.notEqual.pow.radians.reflect.refract.sign.sin.smoothstep.sqrt.step.tan.texture2D.texture2DLod.texture2DProj.texture2DProjLod.textureCube.textureCubeLod.texture2DLodEXT.texture2DProjLodEXT.textureCubeLodEXT.texture2DGradEXT.texture2DProjGradEXT.textureCubeGradEXT`.split(`.`)})),Nd=__commonJSMin(((e,R)=>{R.exports=Ad().slice().concat(`layout.centroid.smooth.case.mat2x2.mat2x3.mat2x4.mat3x2.mat3x3.mat3x4.mat4x2.mat4x3.mat4x4.uvec2.uvec3.uvec4.samplerCubeShadow.sampler2DArray.sampler2DArrayShadow.isampler2D.isampler3D.isamplerCube.isampler2DArray.usampler2D.usampler3D.usamplerCube.usampler2DArray.coherent.restrict.readonly.writeonly.resource.atomic_uint.noperspective.patch.sample.subroutine.common.partition.active.filter.image1D.image2D.image3D.imageCube.iimage1D.iimage2D.iimage3D.iimageCube.uimage1D.uimage2D.uimage3D.uimageCube.image1DArray.image2DArray.iimage1DArray.iimage2DArray.uimage1DArray.uimage2DArray.image1DShadow.image2DShadow.image1DArrayShadow.image2DArrayShadow.imageBuffer.iimageBuffer.uimageBuffer.sampler1DArray.sampler1DArrayShadow.isampler1D.isampler1DArray.usampler1D.usampler1DArray.isampler2DRect.usampler2DRect.samplerBuffer.isamplerBuffer.usamplerBuffer.sampler2DMS.isampler2DMS.usampler2DMS.sampler2DMSArray.isampler2DMSArray.usampler2DMSArray`.split(`.`))})),Pd=__commonJSMin(((e,R)=>{var W=Md();W=W.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),R.exports=W.concat(`gl_VertexID.gl_InstanceID.gl_Position.gl_PointSize.gl_FragCoord.gl_FrontFacing.gl_FragDepth.gl_PointCoord.gl_MaxVertexAttribs.gl_MaxVertexUniformVectors.gl_MaxVertexOutputVectors.gl_MaxFragmentInputVectors.gl_MaxVertexTextureImageUnits.gl_MaxCombinedTextureImageUnits.gl_MaxTextureImageUnits.gl_MaxFragmentUniformVectors.gl_MaxDrawBuffers.gl_MinProgramTexelOffset.gl_MaxProgramTexelOffset.gl_DepthRangeParameters.gl_DepthRange.trunc.round.roundEven.isnan.isinf.floatBitsToInt.floatBitsToUint.intBitsToFloat.uintBitsToFloat.packSnorm2x16.unpackSnorm2x16.packUnorm2x16.unpackUnorm2x16.packHalf2x16.unpackHalf2x16.outerProduct.transpose.determinant.inverse.texture.textureSize.textureProj.textureLod.textureOffset.texelFetch.texelFetchOffset.textureProjOffset.textureLodOffset.textureProjLod.textureProjLodOffset.textureGrad.textureGradOffset.textureProjGrad.textureProjGradOffset`.split(`.`))})),Fd=__commonJSMin(((e,R)=>{R.exports=tokenize;var W=Ad(),Y=jd(),X=Md(),ie=Nd(),ae=Pd(),le=999,_e=9999,ye=0,be=1,Ce=2,Te=3,Oe=4,Ae=5,Me=6,Pe=7,Re=8,Be=9,Ve=10,He=11,Ue=[`block-comment`,`line-comment`,`preprocessor`,`operator`,`integer`,`float`,`ident`,`builtin`,`keyword`,`whitespace`,`eof`,`integer`];function tokenize(e){var R=0,We=0,Ge=le,Ke,qe,Je=[],Ye=[],Xe=1,Ze=0,Qe=0,$e=!1,et=!1,tt=``,nt;e||={};var rt=X,it=W;e.version===`300 es`&&(rt=ae,it=ie);for(var at={},st={},R=0;R<rt.length;R++)at[rt[R]]=!0;for(var R=0;R<it.length;R++)st[it[R]]=!0;return function(e){return Ye=[],e===null?end():write(e)};function token(e){e.length&&Ye.push({type:Ue[Ge],data:e,position:Qe,line:Xe,column:Ze})}function write(e){R=0,e.toString&&(e=e.toString()),tt+=e.replace(/\r\n/g,`
|
|
10
10
|
`),nt=tt.length;for(var W;Ke=tt[R],R<nt;){switch(W=R,Ge){case ye:R=block_comment();break;case be:R=line_comment();break;case Ce:R=preprocessor();break;case Te:R=operator();break;case Oe:R=integer();break;case He:R=hex();break;case Ae:R=decimal();break;case _e:R=readtoken();break;case Be:R=whitespace();break;case le:R=normal();break}if(W!==R)switch(tt[W]){case`
|
|
11
11
|
`:Ze=0,++Xe;break;default:++Ze;break}}return We+=R,tt=tt.slice(R),Ye}function end(e){return Je.length&&token(Je.join(``)),Ge=Ve,token(`(eof)`),Ye}function normal(){return Je=Je.length?[]:Je,qe===`/`&&Ke===`*`?(Qe=We+R-1,Ge=ye,qe=Ke,R+1):qe===`/`&&Ke===`/`?(Qe=We+R-1,Ge=be,qe=Ke,R+1):Ke===`#`?(Ge=Ce,Qe=We+R,R):/\s/.test(Ke)?(Ge=Be,Qe=We+R,R):($e=/\d/.test(Ke),et=/[^\w_]/.test(Ke),Qe=We+R,Ge=$e?Oe:et?Te:_e,R)}function whitespace(){return/[^\s]/g.test(Ke)?(token(Je.join(``)),Ge=le,R):(Je.push(Ke),qe=Ke,R+1)}function preprocessor(){return(Ke===`\r`||Ke===`
|
|
12
12
|
`)&&qe!==`\\`?(token(Je.join(``)),Ge=le,R):(Je.push(Ke),qe=Ke,R+1)}function line_comment(){return preprocessor()}function block_comment(){return Ke===`/`&&qe===`*`?(Je.push(Ke),token(Je.join(``)),Ge=le,R+1):(Je.push(Ke),qe=Ke,R+1)}function operator(){if(qe===`.`&&/\d/.test(Ke))return Ge=Ae,R;if(qe===`/`&&Ke===`*`)return Ge=ye,R;if(qe===`/`&&Ke===`/`)return Ge=be,R;if(Ke===`.`&&Je.length){for(;determine_operator(Je););return Ge=Ae,R}if(Ke===`;`||Ke===`)`||Ke===`(`){if(Je.length)for(;determine_operator(Je););return token(Ke),Ge=le,R+1}var e=Je.length===2&&Ke!==`=`;if(/[\w_\d\s]/.test(Ke)||e){for(;determine_operator(Je););return Ge=le,R}return Je.push(Ke),qe=Ke,R+1}function determine_operator(e){var R=0,W,X;do{if(W=Y.indexOf(e.slice(0,e.length+R).join(``)),X=Y[W],W===-1){if(R--+e.length>0)continue;X=e.slice(0,1).join(``)}return token(X),Qe+=X.length,Je=Je.slice(X.length),Je.length}while(1)}function hex(){return/[^a-fA-F0-9]/.test(Ke)?(token(Je.join(``)),Ge=le,R):(Je.push(Ke),qe=Ke,R+1)}function integer(){return Ke===`.`||/[eE]/.test(Ke)?(Je.push(Ke),Ge=Ae,qe=Ke,R+1):Ke===`x`&&Je.length===1&&Je[0]===`0`?(Ge=He,Je.push(Ke),qe=Ke,R+1):/[^\d]/.test(Ke)?(token(Je.join(``)),Ge=le,R):(Je.push(Ke),qe=Ke,R+1)}function decimal(){return Ke===`f`&&(Je.push(Ke),qe=Ke,R+=1),/[eE]/.test(Ke)||(Ke===`-`||Ke===`+`)&&/[eE]/.test(qe)?(Je.push(Ke),qe=Ke,R+1):/[^\d]/.test(Ke)?(token(Je.join(``)),Ge=le,R):(Je.push(Ke),qe=Ke,R+1)}function readtoken(){if(/[^\d\w_]/.test(Ke)){var e=Je.join(``);return Ge=st[e]?Re:at[e]?Pe:Me,token(Je.join(``)),Ge=le,R}return Je.push(Ke),qe=Ke,R+1}}})),Id=__toESM(__commonJSMin(((e,R)=>{var W=Fd();R.exports=tokenizeString;function tokenizeString(e,R){var Y=W(R),X=[];return X=X.concat(Y(e)),X=X.concat(Y(null)),X}}))(),1);const Ld={createShader(e=0){if(e!==this.FRAGMENT_SHADER&&e!==this.VERTEX_SHADER)return this.setError(this.INVALID_ENUM),null;let R=this._gl.createShader(e);if(R<0)return null;let W=new WebGLShader(R,this,e);return this._shaders[R]=W,W},deleteShader(e){this._deleteLinkable(`deleteShader`,e,WebGLShader)},compileShader(e){if(!checkObject(e))throw TypeError(`compileShader(WebGLShader)`);if(this._checkWrapper(e,WebGLShader)&&this._checkShaderSource(e)){let R=this.getError();this._gl.compileShader(e._|0),e._needsRecompile=!1;let W=this.getError();e._compileStatus=!!this._gl.getShaderParameter(e._|0,this.COMPILE_STATUS),e._compileInfo=this._gl.getShaderInfoLog(e._|0)||`null`,this.getError(),this.setError(R||W)}},shaderSource(e,R){if(!checkObject(e))throw TypeError(`shaderSource(WebGLShader, String)`);if(!e||!R&&typeof R!=`string`){this.setError(this.INVALID_VALUE);return}isValidString(R)?this._checkWrapper(e,WebGLShader)&&(R=this._wrapShader(e._type,R),this._gl.shaderSource(e._|0,R),e._source=R,e._needsRecompile=!0):this.setError(this.INVALID_VALUE)},getShaderInfoLog(e){if(!checkObject(e))throw TypeError(`getShaderInfoLog(WebGLShader)`);return this._checkWrapper(e,WebGLShader)?e._compileInfo:null},getShaderParameter(e,R=0){if(!checkObject(e))throw TypeError(`getShaderParameter(WebGLShader, GLenum)`);if(this._checkWrapper(e,WebGLShader)){switch(R){case this.DELETE_STATUS:return e._pendingDelete;case this.COMPILE_STATUS:return e._compileStatus;case this.SHADER_TYPE:return e._type}this.setError(this.INVALID_ENUM)}return null},getShaderPrecisionFormat(e=0,R=0){if(!(e===this.FRAGMENT_SHADER||e===this.VERTEX_SHADER)||!(R===this.LOW_FLOAT||R===this.MEDIUM_FLOAT||R===this.HIGH_FLOAT||R===this.LOW_INT||R===this.MEDIUM_INT||R===this.HIGH_INT))return this.setError(this.INVALID_ENUM),null;let W=this._gl.getShaderPrecisionFormat(e,R);return W?new WebGLShaderPrecisionFormat(W):null},getShaderSource(e){if(!checkObject(e))throw TypeError(`Input to getShaderSource must be an object`);return this._checkWrapper(e,WebGLShader)?e._source:null},_checkShaderSource(e){let R=e._source,W=(0,Id.default)(R),Y=!1,X=[];for(let e=0;e<W.length;++e){let R=W[e];if(R)switch(R.type){case`ident`:this._validGLSLIdentifier(R.data)||(Y=!0,X.push(R.line+`:`+R.column+` invalid identifier - `+R.data));break;case`preprocessor`:{let e=R.data.match(/^\s*#\s*(.*)$/);if(!e||e?.length<2)break;let W=(0,Id.default)(e[1]);for(let e=0;e<W.length;++e){let ie=W[e];(ie.type===`ident`||ie.type===void 0)&&(this._validGLSLIdentifier(ie.data)||(Y=!0,X.push(R.line+`:`+ie.column+` invalid identifier - `+ie.data)))}break}case`keyword`:switch(R.data){case`do`:Y=!0,X.push(R.line+`:`+R.column+` do not supported`);break}break;case`builtin`:switch(R.data){case`dFdx`:case`dFdy`:case`fwidth`:!this._extensions.oes_standard_derivatives&&this._getGlslVersion(!0)===`100`&&(Y=!0,X.push(R.line+`:`+R.column+` `+R.data+` not supported`));break}}}return Y&&(e._compileInfo=X.join(`
|
|
@@ -16,7 +16,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,globalThis.process===void 0){l
|
|
|
16
16
|
`),W){if(Y){let e=R.indexOf(`
|
|
17
17
|
`);R=e===-1?R+`
|
|
18
18
|
`+Y:R.slice(0,e+1)+Y+R.slice(e+1)}}else if(this.canvas){let e=this.canvas.getGlArea().get_use_es(),W=/\b(attribute|varying)\b/.test(R)?e?`100`:`120`:this._getGlslVersion(e);W?R=`#version `+W+`
|
|
19
|
-
`+Y+R:Y&&(R=Y+R)}else Y&&(R=Y+R);return R}};function installShaderLifecycleMethods(e){Object.assign(e,Ld)}const Rd={createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let R=new WebGLProgram(e,this);return this._programs[e]=R,R},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,WebGLProgram)},useProgram(e){if(!checkObject(e))throw TypeError(`useProgram(WebGLProgram)`);if(e)this._checkWrapper(e,WebGLProgram)&&(this._activeProgram!==e&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=e,e._refCount+=1),this._gl.useProgram(e._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(e){if(!checkObject(e))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(e,WebGLProgram)){e._linkCount+=1,e._attributes=[];let R=this.getError();for(let R of e._references)R instanceof WebGLShader&&R._needsRecompile&&(this._gl.compileShader(R._|0),R._needsRecompile=!1);this._gl.linkProgram(e._|0);let W=this.getError();W===this.NO_ERROR&&(e._linkStatus=this._fixupLink(e)),this.getError(),this.setError(R||W)}},validateProgram(e){if(this._checkWrapper(e,WebGLProgram)){this._gl.validateProgram(e._|0);let R=this.getError();R===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(R)}},attachShader(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!e||!R){this.setError(this.INVALID_VALUE);return}else if(e instanceof WebGLProgram&&R instanceof WebGLShader&&this._checkOwns(e)&&this._checkOwns(R)&&!e._linked(R)){this._saveError(),this._gl.attachShader(e._|0,R._|0);let W=this.getError();this._restoreError(W),W===this.NO_ERROR&&e._link(R);return}this.setError(this.INVALID_OPERATION)},detachShader(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(e,WebGLProgram)&&this._checkWrapper(R,WebGLShader)&&(e._linked(R)?(this._gl.detachShader(e._,R._),e._unlink(R)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(e,R,W){if(!checkObject(e)||typeof W!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);W+=``,!isValidString(W)||W.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(W)?this.setError(this.INVALID_OPERATION):this._checkWrapper(e,WebGLProgram)&&this._gl.bindAttribLocation(e._|0,R|0,W)},getAttachedShaders(e){if(!checkObject(e)||typeof e==`object`&&e&&!(e instanceof WebGLProgram))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!e)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram))return e._references.filter(e=>e instanceof WebGLShader);return null},getProgramInfoLog(e){if(!checkObject(e))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(e,WebGLProgram)?e._linkInfoLog:null},getProgramParameter(e,R=0){if(!checkObject(e))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(e,WebGLProgram)){switch(R){case this.DELETE_STATUS:return e._pendingDelete;case this.LINK_STATUS:return e._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(e._,R);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(e._,R);case this.ACTIVE_ATTRIBUTES:return e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._,R);case this.ACTIVE_UNIFORMS:return e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._,R)}this.setError(this.INVALID_ENUM)}return null},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let R=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),W=Array.from({length:R});e._attributes.length=R;for(let Y=0;Y<R;++Y)W[Y]=this.getActiveAttrib(e,Y)?.name,e._attributes[Y]=this.getAttribLocation(e,W[Y])|0;for(let R=0;R<W.length;++R)if(W[R].length>256)return e._linkInfoLog=`attribute `+W[R]+` is too long`,!1;for(let Y=0;Y<R;++Y)e._attributes[Y]<0||this._gl.bindAttribLocation(e._|0,e._attributes[Y],W[Y]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let Y=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=Y;for(let R=0;R<Y;++R){let W=this.getActiveUniform(e,R);W&&(e._uniforms[R]=W)}for(let R=0;R<e._uniforms.length;++R)if(e._uniforms[R].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[R].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(e,R,W){if(!checkObject(R))throw TypeError(e+`(`+W.name+`)`);if(R instanceof W&&this._checkOwns(R)){R._pendingDelete=!0,R._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installProgramLifecycleMethods(e){Object.assign(e,Rd)}const zd={getActiveAttrib(e,R){if(!checkObject(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram)){if(R>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let W=this._gl.getActiveAttrib(e._|0,R|0);if(W)return new WebGLActiveInfo(W)}return null},getActiveUniform(e,R){if(!checkObject(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram)){if(R>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let W=this._gl.getActiveUniform(e._|0,R|0);if(W)return new WebGLActiveInfo(W)}return null},getAttribLocation(e,R){if(!checkObject(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(R+=``,!isValidString(R)||R.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram))return this._gl.getAttribLocation(e._|0,R+``);return-1},getUniform(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!R)return null;if(this._checkWrapper(e,WebGLProgram)){if(!checkUniform(e,R))return this.setError(this.INVALID_OPERATION),null;let W=this._gl.getUniform(e._|0,R._|0);if(!W)return null;switch(R._activeInfo.type){case this.FLOAT:return W[0];case this.FLOAT_VEC2:return new Float32Array(W.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(W.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(W.slice(0,4));case this.INT:return W[0]|0;case this.INT_VEC2:return new Int32Array(W.slice(0,2));case this.INT_VEC3:return new Int32Array(W.slice(0,3));case this.INT_VEC4:return new Int32Array(W.slice(0,4));case this.BOOL:return!!W[0];case this.BOOL_VEC2:return[!!W[0],!!W[1]];case this.BOOL_VEC3:return[!!W[0],!!W[1],!!W[2]];case this.BOOL_VEC4:return[!!W[0],!!W[1],!!W[2],!!W[3]];case this.FLOAT_MAT2:return new Float32Array(W.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(W.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(W.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return W[0]|0;default:return null}}return null},getUniformLocation(e,R){if(!checkObject(e))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(R+=``,!isValidString(R))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(e,WebGLProgram)){let W=this._gl.getUniformLocation(e._|0,R);if(W!==null&&W>=0){let Y=R;/\[\d+\]$/.test(R)&&(Y=R.replace(/\[\d+\]$/,`[0]`));let X=Y+`[0]`,ie=null;for(let R=0;R<e._uniforms.length;++R){let W=e._uniforms[R];if(W.name===Y||W.name===X){ie={size:W.size,type:W.type,name:W.name};break}}ie||={name:Y,type:0,size:1};let ae=new WebGLUniformLocation(W,e,ie),le=R.match(/\[(\d+)\]$/),_e=le?+le[1]:-1;if(ie.name.endsWith(`[0]`)&&(_e===-1||_e===0)){let R=ie.name.replace(/\[0\]$/,``),W=[];this._saveError();for(let Y=0;this.getError()===this.NO_ERROR;++Y){let X=this._gl.getUniformLocation(e._|0,R+`[`+Y+`]`);if(this.getError()!==this.NO_ERROR||X==null||X<0)break;W.push(X)}this._restoreError(this.NO_ERROR),ae._array=W}else if(_e>0&&_e>=ie.size)return null;return ae}}return null}};function installIntrospectionMethods(e){Object.assign(e,zd)}bt();const Bd={uniform1f(e,R){this._checkUniformValid(e,R,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,R)},uniform1i(e,R){this._gl.uniform1i(e?._||0,R)},uniform2f(e,R,W){this._checkUniformValid(e,R,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,R,W)},uniform2i(e,R,W){this._checkUniformValid(e,R,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,R,W)},uniform3f(e,R,W,Y){this._checkUniformValid(e,R,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,R,W,Y)},uniform3i(e,R,W,Y){this._checkUniformValid(e,R,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,R,W,Y)},uniform4f(e,R,W,Y,X){if(!this._checkUniformValid(e,R,`uniform4f`,4,`f`)){yt.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,R,W,Y,X)},uniform4i(e,R,W,Y,X){this._checkUniformValid(e,R,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,R,W,Y,X)},uniform1fv(e,R){if(!(!e||!this._checkUniformValueValid(e,R,`uniform1fv`,1,`f`))){if(e?._array){let W=e._array;for(let e=0;e<W.length&&e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform1f(Y,R[e])}return}this._gl.uniform1f(e?._|0,R[0])}},uniform1iv(e,R){if(this._checkUniformValueValid(e,R,`uniform1iv`,1,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform1i(Y,R[e])}return}this.uniform1i(e,R[0])}},uniform2fv(e,R){if(this._checkUniformValueValid(e,R,`uniform2fv`,2,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&2*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform2f(Y,R[2*e],R[2*e+1])}return}this._gl.uniform2f(e?._||0,R[0],R[1])}},uniform2iv(e,R){if(this._checkUniformValueValid(e,R,`uniform2iv`,2,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&2*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform2i(Y,R[2*e],R[2*e+1])}return}this.uniform2i(e,R[0],R[1])}},uniform3fv(e,R){if(this._checkUniformValueValid(e,R,`uniform3fv`,3,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&3*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform3f(Y,R[3*e],R[3*e+1],R[3*e+2])}return}this._gl.uniform3f(e?._||0,R[0],R[1],R[2])}},uniform3iv(e,R){if(this._checkUniformValueValid(e,R,`uniform3iv`,3,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&3*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform3i(Y,R[3*e],R[3*e+1],R[3*e+2])}return}this.uniform3i(e,R[0],R[1],R[2])}},uniform4fv(e,R){if(this._checkUniformValueValid(e,R,`uniform4fv`,4,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&4*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform4f(Y,R[4*e],R[4*e+1],R[4*e+2],R[4*e+3])}return}this._gl.uniform4f(e?._||0,R[0],R[1],R[2],R[3])}},uniform4iv(e,R){if(this._checkUniformValueValid(e,R,`uniform4iv`,4,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&4*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform4i(Y,R[4*e],R[4*e+1],R[4*e+2],R[4*e+3])}return}this.uniform4i(e,R[0],R[1],R[2],R[3])}},uniformMatrix2fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix2fv`,2))return;let Y=new Float32Array(W);this._gl.uniformMatrix2fv(e?._||0,!!R,listToArray(Y))},uniformMatrix3fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix3fv`,3))return;let Y=new Float32Array(W);this._gl.uniformMatrix3fv(e?._||0,!!R,listToArray(Y))},uniformMatrix4fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix4fv`,4))return;let Y=new Float32Array(W);this._gl.uniformMatrix4fv(e?._||0,!!R,listToArray(Y))},_checkLocation(e){return e instanceof WebGLUniformLocation?e._program._ctx!==this||e._linkCount!==e._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,R,W,Y,X){if(!checkObject(e))throw TypeError(`${W}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let W=e._activeInfo.type;if(W===this.SAMPLER_2D||W===this.SAMPLER_CUBE){if(Y!==1)return this.setError(this.INVALID_VALUE),!1;if(X!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(R<0||R>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return uniformTypeSize(this,W)>Y?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,R,W,Y,X){if(!checkObject(e)||!checkObject(R))throw TypeError(`${W}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof R!=`object`||!R||typeof R.length!=`number`)throw TypeError(`Second argument to ${W} must be array`);return uniformTypeSize(this,e._activeInfo.type)>Y?(this.setError(this.INVALID_OPERATION),!1):R.length>=Y&&R.length%Y===0?e._array||R.length===Y?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,R,W,Y,X){if(!checkObject(e)||typeof W!=`object`)throw TypeError(Y+`(WebGLUniformLocation, Boolean, Array)`);return R||typeof W!=`object`||!W||!W.length||W.length%X*X!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:W.length===X*X||e._array?!0:(this.setError(this.INVALID_VALUE),!1)}};function installUniformsMethods(e){Object.assign(e,Bd)}function installShaderProgramMethods(e){installShaderLifecycleMethods(e),installProgramLifecycleMethods(e),installIntrospectionMethods(e),installUniformsMethods(e)}bt();const Vd={drawArrays(e=0,R=0,W=0){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||W===0)return;let X=R;W>0&&(X=W+R-1>>>0),this._checkVertexAttribState(X)&&this._gl.drawArrays(e,R,Y)},drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(this._extensions.oes_element_index_uint&&W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(R===0){this._checkVertexAttribState(0);return}if(R+ae>>>0>ie.length){this.setError(this.INVALID_OPERATION);return}let _e=-1;for(let e=ae;e<ae+R;++e)_e=Math.max(_e,ie[e]);if(_e<0){this._checkVertexAttribState(0);return}this._checkVertexAttribState(_e)&&le>0&&this._gl.drawElements(e,le,W,Y)},viewport(e,R,W,Y){this._viewport[0]=e|0,this._viewport[1]=R|0,this._viewport[2]=W|0,this._viewport[3]=Y|0,this._gl.viewport(e,R,W,Y)},scissor(e,R,W,Y){this._scissorBox[0]=e|0,this._scissorBox[1]=R|0,this._scissorBox[2]=W|0,this._scissorBox[3]=Y|0,this._gl.scissor(e|0,R|0,W|0,Y|0)},readPixels(e=0,R=0,W=0,Y=0,X=0,ie=0,ae){if(!ae)return;if(!(this._extensions.oes_texture_float&&ie===this.FLOAT&&X===this.RGBA)){if(X===this.RGB||X===this.ALPHA||ie!==this.UNSIGNED_BYTE){this.setError(this.INVALID_OPERATION);return}else if(X!==this.RGBA){this.setError(this.INVALID_ENUM);return}else if(W<0||Y<0||!(ae instanceof Uint8Array)){this.setError(this.INVALID_VALUE);return}}if(!this._framebufferOk()){yt.error(`framebuffer is not okay!`);return}let le=W*4;le%this._packAlignment!==0&&(le+=this._packAlignment-le%this._packAlignment);let _e=le*(Y-1)+W*4;if(_e<=0)return;if((ae.length||ae.byteLength||0)<_e){this.setError(this.INVALID_VALUE);return}let ye=this.drawingBufferWidth,be=this.drawingBufferHeight;this._activeFramebuffer&&(ye=this._activeFramebuffer._width,be=this._activeFramebuffer._height);let Ce=arrayToUint8Array(ae);if(e>=ye||e+W<=0||R>=be||R+Y<=0)for(let e=0;e<Ce.length;++e)Ce[e]=0;else if(e<0||e+W>ye||R<0||R+Y>be){for(let e=0;e<Ce.length;++e)Ce[e]=0;let ae=e,_e=W;e<0&&(_e+=e,ae=0),ae+W>ye&&(_e=ye-ae);let Te=R,Oe=Y;R<0&&(Oe+=R,Te=0),Te+Y>be&&(Oe=be-Te);let Ae=_e*4;if(Ae%this._packAlignment!==0&&(Ae+=this._packAlignment-Ae%this._packAlignment),_e>0&&Oe>0){let W=new Uint8Array(Ae*Oe),Y=this._gl.readPixels(ae,Te,_e,Oe,X,ie,Uint8ArrayToVariant(W)),ye=Y&&Y.length>0?Y:W,be=4*(ae-e)+(Te-R)*le;for(let e=0;e<Oe;++e)for(let R=0;R<_e;++R)for(let W=0;W<4;++W)Ce[be+e*le+4*R+W]=ye[e*Ae+4*R+W]}}else{let ae=this._gl.readPixels(e,R,W,Y,X,ie,Uint8ArrayToVariant(Ce));ae&&ae.length>0&&Ce.set(ae)}},enableVertexAttribArray(e){if(e<0||e>=this._vertexObjectState._attribs.length){this.setError(this.INVALID_VALUE);return}this._gl.enableVertexAttribArray(e),this._vertexObjectState._attribs[e]._isPointer=!0},disableVertexAttribArray(e=0){if(e<0||e>=this._vertexObjectState._attribs.length){this.setError(this.INVALID_VALUE);return}this._gl.disableVertexAttribArray(e),this._vertexObjectState._attribs[e]._isPointer=!1},vertexAttrib1f(e,R){if(e|=0,!this._checkVertexIndex(e))return;let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[1]=W[2]=0,W[0]=R,this._gl.vertexAttrib1f(e|0,+R)},vertexAttrib1fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<1){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=0,W[1]=0,W[0]=R[0],this._gl.vertexAttrib1f(e|0,+R[0])},vertexAttrib2f(e,R,W){if(e|=0,!this._checkVertexIndex(e))return;let Y=this._vertexGlobalState._attribs[e]._data;Y[3]=1,Y[2]=0,Y[1]=W,Y[0]=R,this._gl.vertexAttrib2f(e|0,+R,+W)},vertexAttrib2fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<2){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=0,W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib2f(e|0,+R[0],+R[1])},vertexAttrib3f(e,R,W,Y){if(e|=0,!this._checkVertexIndex(e))return;let X=this._vertexGlobalState._attribs[e]._data;X[3]=1,X[2]=Y,X[1]=W,X[0]=R,this._gl.vertexAttrib3f(e|0,+R,+W,+Y)},vertexAttrib3fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<3){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=R[2],W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib3f(e|0,+R[0],+R[1],+R[2])},vertexAttrib4f(e=0,R,W,Y,X){if(!this._checkVertexIndex(e))return;let ie=this._vertexGlobalState._attribs[e]._data;ie[3]=X,ie[2]=Y,ie[1]=W,ie[0]=R,this._gl.vertexAttrib4f(e|0,+R,+W,+Y,+X)},vertexAttrib4fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<4){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=R[3],W[2]=R[2],W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib4f(e|0,+R[0],+R[1],+R[2],+R[3])},vertexAttribPointer(e=0,R=0,W=0,Y=!1,X=0,ie=0){if(X<0||ie<0){this.setError(this.INVALID_VALUE);return}if(X<0||ie<0||e<0||e>=this._vertexObjectState._attribs.length||!(R===1||R===2||R===3||R===4)){this.setError(this.INVALID_VALUE);return}if(this._vertexGlobalState._arrayBufferBinding===null){this.setError(this.INVALID_OPERATION);return}let ae=typeSize(this,W);if(ae===0||W===this.INT||W===this.UNSIGNED_INT){this.setError(this.INVALID_ENUM);return}if(X>255||X<0){this.setError(this.INVALID_VALUE);return}if(X%ae!==0||ie%ae!==0){this.setError(this.INVALID_OPERATION);return}this._gl.vertexAttribPointer(e,R,W,Y,X,ie),this._vertexObjectState.setVertexAttribPointer(this._vertexGlobalState._arrayBufferBinding,e,R*ae,ie,X||R*ae,W,Y,X,R)},getVertexAttrib(e=0,R=0){if(e<0||e>=this._vertexObjectState._attribs.length)return this.setError(this.INVALID_VALUE),null;let W=this._vertexObjectState._attribs[e],Y=this._vertexGlobalState._attribs[e]._data,X=this._extensions.angle_instanced_arrays;if(X&&R===X.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)return W._divisor;switch(R){case this.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:return W._pointerBuffer;case this.VERTEX_ATTRIB_ARRAY_ENABLED:return W._isPointer;case this.VERTEX_ATTRIB_ARRAY_SIZE:return W._inputSize;case this.VERTEX_ATTRIB_ARRAY_STRIDE:return W._inputStride;case this.VERTEX_ATTRIB_ARRAY_TYPE:return W._pointerType;case this.VERTEX_ATTRIB_ARRAY_NORMALIZED:return W._pointerNormal;case this.CURRENT_VERTEX_ATTRIB:return new Float32Array(Y);default:return this.setError(this.INVALID_ENUM),null}},getVertexAttribOffset(e=0,R=0){return e<0||e>=this._vertexObjectState._attribs.length?(this.setError(this.INVALID_VALUE),-1):R===this.VERTEX_ATTRIB_ARRAY_POINTER?this._vertexObjectState._attribs[e]._pointerOffset:(this.setError(this.INVALID_ENUM),-1)},_checkVertexAttribState(e){let R=this._activeProgram;if(!R)return this.setError(this.INVALID_OPERATION),!1;let W=this._vertexObjectState._attribs;for(let Y=0;Y<W.length;++Y){let X=W[Y];if(X._isPointer){let W=X._pointerBuffer;if(!W)return this.setError(this.INVALID_OPERATION),!1;if(R._attributes.indexOf(Y)>=0){let R=0;if(R=X._divisor?X._pointerSize+X._pointerOffset:X._pointerStride*e+X._pointerSize+X._pointerOffset,R>W._size)return this.setError(this.INVALID_OPERATION),!1}}}return!0},_checkVertexIndex(e){return e<0||e>=this._vertexObjectState._attribs.length?(this.setError(this.INVALID_VALUE),!1):!0}};function installDrawingMethods(e){Object.assign(e,Vd)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var Hd=Ae;Vt();let Ud=0;const Wd={oes_element_index_uint:getOESElementIndexUint,oes_texture_float:getOESTextureFloat,oes_texture_float_linear:getOESTextureFloatLinear,oes_standard_derivatives:getOESStandardDerivatives,stackgl_destroy_context:getSTACKGLDestroyContext,stackgl_resize_drawingbuffer:getSTACKGLResizeDrawingBuffer,ext_blend_minmax:getEXTBlendMinMax,ext_color_buffer_float:getEXTColorBufferFloat,ext_color_buffer_half_float:getEXTColorBufferHalfFloat,ext_texture_filter_anisotropic:getEXTTextureFilterAnisotropic,oes_texture_half_float:getOESTextureHalfFloat};var WebGLContextBase=class{get drawingBufferHeight(){return this.canvas.height||0}get drawingBufferWidth(){return this.canvas.width||0}constructor(e,R={}){this.unpackColorSpace=`srgb`,this.RGBA8=32856,this.DEFAULT_ATTACHMENTS=[],this.DEFAULT_COLOR_ATTACHMENTS=[],this._=0,this._extensions={},this._programs={},this._shaders={},this._textures={},this._framebuffers={},this._renderbuffers={},this._buffers={},this._activeProgram=null,this._activeFramebuffer=null,this._activeRenderbuffer=null,this._checkStencil=!1,this._stencilState=!0,this._activeTextureUnit=0,this._errorStack=[],this._maxTextureSize=0,this._maxTextureLevel=0,this._maxCubeMapSize=0,this._maxCubeMapLevel=0,this._maxRenderbufferSize=0,this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this._viewport=new Int32Array([0,0,0,0]),this._scissorBox=new Int32Array([0,0,0,0]),this._gtkFboId=0,this._textureUnits=[],this._drawingBuffer=null,this.canvas=e,this._contextAttributes=new WebGLContextAttributes(flag(R,`alpha`,!0),flag(R,`depth`,!0),flag(R,`stencil`,!1),!1,flag(R,`premultipliedAlpha`,!0),flag(R,`preserveDrawingBuffer`,!1),flag(R,`preferLowPowerToHighPerformance`,!1),flag(R,`failIfMajorPerformanceCaveat`,!1)),this._contextAttributes.premultipliedAlpha=this._contextAttributes.premultipliedAlpha&&this._contextAttributes.alpha}_init(){let e=this._gl.getParameterx(36006);this._gtkFboId=e?.deepUnpack()|0,this._initGLConstants(),this.DEFAULT_ATTACHMENTS=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT],this.DEFAULT_COLOR_ATTACHMENTS=[this.COLOR_ATTACHMENT0];let R=this.drawingBufferWidth||0,W=this.drawingBufferHeight||0;this._=Ud++;let Y=this.getParameter(this.MAX_COMBINED_TEXTURE_IMAGE_UNITS);this._textureUnits=Array.from({length:Y});for(let e=0;e<Y;++e)this._textureUnits[e]=new WebGLTextureUnit(this,e);this.activeTexture(this.TEXTURE0),this._defaultVertexObjectState=new WebGLVertexArrayObjectState(this),this._vertexObjectState=this._defaultVertexObjectState,this._vertexGlobalState=new WebGLVertexArrayGlobalState(this),this._maxTextureSize=this.getParameter(this.MAX_TEXTURE_SIZE),this._maxTextureLevel=Td.log2(Td.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=Td.log2(Td.nextPow2(this._maxCubeMapSize)),this._maxRenderbufferSize=this.getParameter(this.MAX_RENDERBUFFER_SIZE),this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this.bindBuffer(this.ARRAY_BUFFER,null),this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this.bindFramebuffer(this.FRAMEBUFFER,null),this.bindRenderbuffer(this.RENDERBUFFER,null),this.viewport(0,0,R,W),this.scissor(0,0,R,W),this.clearDepth(1),this.clearColor(0,0,0,0),this.clearStencil(0),this.clear(this.COLOR_BUFFER_BIT|this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),this.disable(this.DEPTH_TEST),this.disable(this.STENCIL_TEST),this.disable(this.BLEND),this.disable(this.CULL_FACE),this.disable(this.POLYGON_OFFSET_FILL),this.disable(this.SCISSOR_TEST),this._gl.colorMask(!0,!0,!0,!0)}_initGLConstants(){let e=new Hd.WebGLRenderingContextBase().get_webgl_constants();for(let[R,W]of Object.entries(e))Object.defineProperty(this,R,{value:W})}_getGlslVersion(e){return e?`100`:`120`}_checkOwns(e){return typeof e==`object`&&!!e&&e._ctx===this}_checkValid(e,R){return e instanceof R&&e._!==0}_checkWrapper(e,R){return this._checkValid(e,R)?this._checkOwns(e)?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)}_isObject(e,R,W){if(e!=null&&!(e instanceof W))throw TypeError(R+`(`+W.name+`)`);return!!(this._checkValid(e,W)&&this._checkOwns(e))}_checkStencilState(){return this._checkStencil?(this._checkStencil=!1,this._stencilState=!0,(this.getParameter(this.STENCIL_WRITEMASK)!==this.getParameter(this.STENCIL_BACK_WRITEMASK)||this.getParameter(this.STENCIL_VALUE_MASK)!==this.getParameter(this.STENCIL_BACK_VALUE_MASK)||this.getParameter(this.STENCIL_REF)!==this.getParameter(this.STENCIL_BACK_REF))&&(this.setError(this.INVALID_OPERATION),this._stencilState=!1),this._stencilState):this._stencilState}_validGLSLIdentifier(e){return!(e.indexOf(`webgl_`)===0||e.indexOf(`_webgl_`)===0||e.length>256)}_getParameterDirect(e){return this._gl.getParameterx(e)?.deepUnpack()}getContextAttributes(){return this._contextAttributes}getExtension(e){let R=e.toLowerCase();if(R in this._extensions)return this._extensions[R];let W=Wd[R]?Wd[R](this):null;return W&&(this._extensions[R]=W),W}getSupportedExtensions(){let e=[`ANGLE_instanced_arrays`,`STACKGL_resize_drawingbuffer`,`STACKGL_destroy_context`],R=this._gl.getSupportedExtensions();return R?(R.indexOf(`GL_OES_element_index_uint`)>=0&&e.push(`OES_element_index_uint`),R.indexOf(`GL_OES_standard_derivatives`)>=0&&e.push(`OES_standard_derivatives`),R.indexOf(`GL_OES_texture_float`)>=0&&e.push(`OES_texture_float`),R.indexOf(`GL_OES_texture_float_linear`)>=0&&e.push(`OES_texture_float_linear`),(R.indexOf(`GL_OES_texture_half_float`)>=0||R.indexOf(`GL_ARB_half_float_pixel`)>=0)&&e.push(`OES_texture_half_float`),(R.indexOf(`GL_EXT_color_buffer_float`)>=0||R.indexOf(`GL_ARB_color_buffer_float`)>=0)&&e.push(`EXT_color_buffer_float`),R.indexOf(`GL_EXT_color_buffer_half_float`)>=0&&e.push(`EXT_color_buffer_half_float`),R.indexOf(`EXT_draw_buffers`)>=0&&e.push(`WEBGL_draw_buffers`),R.indexOf(`EXT_blend_minmax`)>=0&&e.push(`EXT_blend_minmax`),R.indexOf(`EXT_texture_filter_anisotropic`)>=0&&e.push(`EXT_texture_filter_anisotropic`),R.indexOf(`GL_OES_vertex_array_object`)>=0&&e.push(`OES_vertex_array_object`),e):e}getParameter(e=0){switch(e){case this.ARRAY_BUFFER_BINDING:return this._vertexGlobalState._arrayBufferBinding;case this.ELEMENT_ARRAY_BUFFER_BINDING:return this._vertexObjectState._elementArrayBufferBinding;case this.CURRENT_PROGRAM:return this._activeProgram;case this.FRAMEBUFFER_BINDING:return this._activeFramebuffer;case this.RENDERBUFFER_BINDING:return this._activeRenderbuffer;case this.TEXTURE_BINDING_2D:return this._getActiveTextureUnit()._bind2D;case this.TEXTURE_BINDING_CUBE_MAP:return this._getActiveTextureUnit()._bindCube;case this.VERSION:return`WebGL 1.0 0.0.1`;case this.VENDOR:return``;case this.RENDERER:return`ANGLE`;case this.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0 `;case this.COMPRESSED_TEXTURE_FORMATS:return new Uint32Array;case this.SCISSOR_BOX:return new Int32Array(this._scissorBox);case this.VIEWPORT:return new Int32Array(this._viewport);case this.MAX_VIEWPORT_DIMS:return new Int32Array([32767,32767]);case this.ALIASED_LINE_WIDTH_RANGE:case this.ALIASED_POINT_SIZE_RANGE:return new Float32Array([1,1]);case this.DEPTH_RANGE:return new Float32Array([0,1]);case this.BLEND_COLOR:case this.COLOR_CLEAR_VALUE:return new Float32Array(this._gl.getParameterfv(e,4));case this.COLOR_WRITEMASK:{let R=this._gl.getParameteriv(e,4);return[!!R[0],!!R[1],!!R[2],!!R[3]]}case this.DEPTH_CLEAR_VALUE:case this.LINE_WIDTH:case this.POLYGON_OFFSET_FACTOR:case this.POLYGON_OFFSET_UNITS:case this.SAMPLE_COVERAGE_VALUE:return this._gl.getParameterf(e);case this.BLEND:case this.CULL_FACE:case this.DEPTH_TEST:case this.DEPTH_WRITEMASK:case this.DITHER:case this.POLYGON_OFFSET_FILL:case this.SAMPLE_COVERAGE_INVERT:case this.SCISSOR_TEST:case this.STENCIL_TEST:case this.UNPACK_PREMULTIPLY_ALPHA_WEBGL:return!!this._gl.getParameteri(e);case this.UNPACK_FLIP_Y_WEBGL:return this._unpackFlipY;case this.ACTIVE_TEXTURE:case this.ALPHA_BITS:case this.BLEND_DST_ALPHA:case this.BLEND_DST_RGB:case this.BLEND_EQUATION_ALPHA:case this.BLEND_EQUATION_RGB:case this.BLEND_SRC_ALPHA:case this.BLEND_SRC_RGB:case this.BLUE_BITS:case this.CULL_FACE_MODE:case this.DEPTH_BITS:case this.DEPTH_FUNC:case this.FRONT_FACE:case this.GENERATE_MIPMAP_HINT:case this.GREEN_BITS:case this.MAX_COMBINED_TEXTURE_IMAGE_UNITS:case this.MAX_CUBE_MAP_TEXTURE_SIZE:case this.MAX_FRAGMENT_UNIFORM_VECTORS:case this.MAX_RENDERBUFFER_SIZE:case this.MAX_TEXTURE_IMAGE_UNITS:case this.MAX_TEXTURE_SIZE:case this.MAX_VARYING_VECTORS:case this.MAX_VERTEX_ATTRIBS:case this.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case this.MAX_VERTEX_UNIFORM_VECTORS:case this.PACK_ALIGNMENT:case this.RED_BITS:case this.SAMPLE_BUFFERS:case this.SAMPLES:case this.STENCIL_BACK_FAIL:case this.STENCIL_BACK_FUNC:case this.STENCIL_BACK_PASS_DEPTH_FAIL:case this.STENCIL_BACK_PASS_DEPTH_PASS:case this.STENCIL_BACK_REF:case this.STENCIL_BACK_VALUE_MASK:case this.STENCIL_BACK_WRITEMASK:case this.STENCIL_BITS:case this.STENCIL_CLEAR_VALUE:case this.STENCIL_FAIL:case this.STENCIL_FUNC:case this.STENCIL_PASS_DEPTH_FAIL:case this.STENCIL_PASS_DEPTH_PASS:case this.STENCIL_REF:case this.STENCIL_VALUE_MASK:case this.STENCIL_WRITEMASK:case this.SUBPIXEL_BITS:case this.UNPACK_ALIGNMENT:case this.UNPACK_COLORSPACE_CONVERSION_WEBGL:return this._gl.getParameteri(e);case this.IMPLEMENTATION_COLOR_READ_FORMAT:case this.IMPLEMENTATION_COLOR_READ_TYPE:return this._getParameterDirect(e);default:if(this._extensions.webgl_draw_buffers){let R=this._extensions.webgl_draw_buffers;switch(e){case R.DRAW_BUFFER0_WEBGL:case R.DRAW_BUFFER1_WEBGL:case R.DRAW_BUFFER2_WEBGL:case R.DRAW_BUFFER3_WEBGL:case R.DRAW_BUFFER4_WEBGL:case R.DRAW_BUFFER5_WEBGL:case R.DRAW_BUFFER6_WEBGL:case R.DRAW_BUFFER7_WEBGL:case R.DRAW_BUFFER8_WEBGL:case R.DRAW_BUFFER9_WEBGL:case R.DRAW_BUFFER10_WEBGL:case R.DRAW_BUFFER11_WEBGL:case R.DRAW_BUFFER12_WEBGL:case R.DRAW_BUFFER13_WEBGL:case R.DRAW_BUFFER14_WEBGL:case R.DRAW_BUFFER15_WEBGL:return R._buffersState.length===1&&R._buffersState[0]===this.BACK?this.BACK:this._getParameterDirect(e);case R.MAX_DRAW_BUFFERS_WEBGL:case R.MAX_COLOR_ATTACHMENTS_WEBGL:return this._getParameterDirect(e)}}let R=this._extensions.oes_standard_derivatives;if(R&&e===R.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)return this._getParameterDirect(e);let W=this._extensions.ext_texture_filter_anisotropic;if(W&&e===W.MAX_TEXTURE_MAX_ANISOTROPY_EXT)return this._getParameterDirect(e);let Y=this._extensions.oes_vertex_array_object;return Y&&e===Y.VERTEX_ARRAY_BINDING_OES?Y._activeVertexArrayObject:(this.setError(this.INVALID_ENUM),null)}}destroy(){warnNotImplemented(`destroy`)}};installAllContextMethods(WebGLContextBase.prototype);var WebGLRenderingContext=class extends WebGLContextBase{get _gl(){return this._native}constructor(e,R={}){super(e,R),this._attrib0Buffer=null,this._native=new Hd.WebGLRenderingContext({}),this._init();let W=this.createBuffer();this._attrib0Buffer=W}_beginAttrib0Hack(){this._native.bindBuffer(this.ARRAY_BUFFER,this._attrib0Buffer?._||0);let e=new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);this._native.bufferData(this.ARRAY_BUFFER,Uint8ArrayToVariant(e),this.STREAM_DRAW),this._native.enableVertexAttribArray(0),this._native.vertexAttribPointer(0,4,this.FLOAT,!1,0,0),this._native._vertexAttribDivisor(0,1)}_endAttrib0Hack(){let e=this._vertexObjectState._attribs[0];e._pointerBuffer?this._native.bindBuffer(this.ARRAY_BUFFER,e._pointerBuffer._):this._native.bindBuffer(this.ARRAY_BUFFER,0),this._native.vertexAttribPointer(0,e._inputSize,e._pointerType,e._pointerNormal,e._inputStride,e._pointerOffset),this._native._vertexAttribDivisor(0,e._divisor),this._native.disableVertexAttribArray(0),this._vertexGlobalState._arrayBufferBinding?this._native.bindBuffer(this.ARRAY_BUFFER,this._vertexGlobalState._arrayBufferBinding._):this._native.bindBuffer(this.ARRAY_BUFFER,0)}drawArrays(e=0,R=0,W=0){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||W===0)return;let X=R;if(W>0&&(X=W+R-1>>>0),this._checkVertexAttribState(X)){let W=this._extensions.webgl_draw_buffers;if(this._vertexObjectState._attribs[0]._isPointer||W&&W._buffersState&&W._buffersState.length>0)return this._native.drawArrays(e,R,Y);this._beginAttrib0Hack(),this._native._drawArraysInstanced(e,R,Y,1),this._endAttrib0Hack()}}drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(this._extensions.oes_element_index_uint&&W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(R===0){this._checkVertexAttribState(0);return}if(R+ae>>>0>ie.length){this.setError(this.INVALID_OPERATION);return}let _e=-1;for(let e=ae;e<ae+R;++e)_e=Math.max(_e,ie[e]);if(_e<0){this._checkVertexAttribState(0);return}if(this._checkVertexAttribState(_e)&&le>0){if(this._vertexObjectState._attribs[0]._isPointer)return this._native.drawElements(e,le,W,Y);this._beginAttrib0Hack(),this._native._drawElementsInstanced(e,le,W,Y,1),this._endAttrib0Hack()}}},WebGLQuery=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._queries[this._|0],e._native2.deleteQuery(this._|0)}},WebGLSampler=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._samplers[this._|0],e._native2.deleteSampler(this._|0)}},WebGLSync=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._syncs[this._|0],e._native2.deleteSync(this._|0)}},WebGLTransformFeedback=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._transformFeedbacks[this._|0],e._native2.deleteTransformFeedback(this._|0)}},WebGLVertexArrayObject=class extends Linkable{constructor(e,R){super(e),this._ctx=R,this._objectState=new WebGLVertexArrayObjectState(R)}_performDelete(){let e=this._ctx;e._vertexObjectState===this._objectState&&(e._vertexObjectState=e._defaultVertexObjectState),this._objectState.cleanUp(),delete e._vertexArrayObjects[this._|0],e._native2.deleteVertexArray(this._|0)}};Vt();const Gd={createVertexArray(){let e=this._native2.createVertexArray();if(!e)return null;let R=new WebGLVertexArrayObject(e,this);return this._vertexArrayObjects[e]=R,R},deleteVertexArray(e){!e||!(e instanceof WebGLVertexArrayObject)||(e._pendingDelete=!0,e._checkDelete())},isVertexArray(e){return!e||!(e instanceof WebGLVertexArrayObject)?!1:this._native2.isVertexArray(e._)},bindVertexArray(e){e===null?(this._native2.bindVertexArray(0),this._vertexObjectState=this._defaultVertexObjectState):e instanceof WebGLVertexArrayObject?(this._native2.bindVertexArray(e._),this._vertexObjectState=e._objectState):this.setError(this.INVALID_OPERATION)},createQuery(){let e=this._native2.createQuery();if(!e)return null;let R=new WebGLQuery(e,this);return this._queries[e]=R,R},deleteQuery(e){!e||!(e instanceof WebGLQuery)||(e._pendingDelete=!0,e._checkDelete())},isQuery(e){return!e||!(e instanceof WebGLQuery)?!1:this._native2.isQuery(e._)},beginQuery(e,R){R instanceof WebGLQuery&&this._native2.beginQuery(e,R._)},endQuery(e){this._native2.endQuery(e)},getQuery(e,R){return warnNotImplemented(`WebGL2RenderingContext.getQuery`),null},getQueryParameter(e,R){return e instanceof WebGLQuery?this._native2.getQueryParameter(e._,R):null},createSampler(){let e=this._native2.createSampler();if(!e)return null;let R=new WebGLSampler(e,this);return this._samplers[e]=R,R},deleteSampler(e){!e||!(e instanceof WebGLSampler)||(e._pendingDelete=!0,e._checkDelete())},isSampler(e){return!e||!(e instanceof WebGLSampler)?!1:this._native2.isSampler(e._)},bindSampler(e,R){this._native2.bindSampler(e,R?R._:0)},samplerParameteri(e,R,W){e instanceof WebGLSampler&&this._native2.samplerParameteri(e._,R,W)},samplerParameterf(e,R,W){e instanceof WebGLSampler&&this._native2.samplerParameterf(e._,R,W)},getSamplerParameter(e,R){return e instanceof WebGLSampler?R===33082||R===33083?this._native2.getSamplerParameterf(e._,R):this._native2.getSamplerParameteri(e._,R):null},fenceSync(e,R){let W=this._native2.fenceSync(e,R);if(!W)return null;let Y=new WebGLSync(W,this);return this._syncs[W]=Y,Y},isSync(e){return!e||!(e instanceof WebGLSync)?!1:this._native2.isSync(e._)},deleteSync(e){!e||!(e instanceof WebGLSync)||(e._pendingDelete=!0,e._checkDelete())},clientWaitSync(e,R,W){return e instanceof WebGLSync?this._native2.clientWaitSync(e._,R,W):37148},waitSync(e,R,W){e instanceof WebGLSync&&this._native2.waitSync(e._,R,W)},getSyncParameter(e,R){return e instanceof WebGLSync?this._native2.getSyncParameter(e._,R):null},createTransformFeedback(){let e=this._native2.createTransformFeedback();if(!e)return null;let R=new WebGLTransformFeedback(e,this);return this._transformFeedbacks[e]=R,R},deleteTransformFeedback(e){!e||!(e instanceof WebGLTransformFeedback)||(e._pendingDelete=!0,e._checkDelete())},isTransformFeedback(e){return!e||!(e instanceof WebGLTransformFeedback)?!1:this._native2.isTransformFeedback(e._)},bindTransformFeedback(e,R){this._native2.bindTransformFeedback(e,R?R._:0)},beginTransformFeedback(e){this._native2.beginTransformFeedback(e)},endTransformFeedback(){this._native2.endTransformFeedback()},pauseTransformFeedback(){this._native2.pauseTransformFeedback()},resumeTransformFeedback(){this._native2.resumeTransformFeedback()},transformFeedbackVaryings(e,R,W){this._native2.transformFeedbackVaryings(e._,R,W)},getTransformFeedbackVarying(e,R){let W=this._native2.getTransformFeedbackVarying(e._,R).deepUnpack();return new WebGLActiveInfo({size:W.size,type:W.type,name:W.name})}};function installObjectLifecycleMethods(e){Object.assign(e,Gd)}const Kd={texImage3D(e,R,W,Y,X,ie,ae,le,_e,ye){ye===null?this._native2.texImage3DNull(e,R,W,Y,X,ie,ae,le,_e):this._native2.texImage3D(e,R,W,Y,X,ie,ae,le,_e,Uint8ArrayToVariant(new Uint8Array(ye.buffer,ye.byteOffset,ye.byteLength)))},texSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,be){be!==null&&this._native2.texSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,Uint8ArrayToVariant(new Uint8Array(be.buffer,be.byteOffset,be.byteLength)))},compressedTexImage3D(e,R,W,Y,X,ie,ae,le,_e){this._native2.compressedTexImage3D(e,R,W,Y,X,ie,ae,Uint8ArrayToVariant(new Uint8Array(_e.buffer,_e.byteOffset,_e.byteLength)))},compressedTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,be){this._native2.compressedTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e,Uint8ArrayToVariant(new Uint8Array(be.buffer,be.byteOffset,be.byteLength)))},copyTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e){this._native2.copyTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e)},texStorage2D(e,R,W,Y,X){this._native2.texStorage2D(e,R,W,Y,X);let ie=this._getTexImage(e);if(ie){for(let e=0;e<R;e++)ie._levelWidth[e]=Math.max(1,Y>>e),ie._levelHeight[e]=Math.max(1,X>>e);ie._format=this.RGBA,ie._type=this.UNSIGNED_BYTE}},texStorage3D(e,R,W,Y,X,ie){this._native2.texStorage3D(e,R,W,Y,X,ie)}};function installTexImage3DMethods(e){Object.assign(e,Kd)}const qd={uniform1ui(e,R){e&&this._native2.uniform1ui(e._,R)},uniform2ui(e,R,W){e&&this._native2.uniform2ui(e._,R,W)},uniform3ui(e,R,W,Y){e&&this._native2.uniform3ui(e._,R,W,Y)},uniform4ui(e,R,W,Y,X){e&&this._native2.uniform4ui(e._,R,W,Y,X)},uniform1uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform1uiv(e._,X.length,X)},uniform2uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform2uiv(e._,X.length/2,X)},uniform3uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform3uiv(e._,X.length/3,X)},uniform4uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform4uiv(e._,X.length/4,X)},uniformMatrix2x3fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix2x3fv(e._,R,ie)},uniformMatrix3x2fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix3x2fv(e._,R,ie)},uniformMatrix2x4fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix2x4fv(e._,R,ie)},uniformMatrix4x2fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix4x2fv(e._,R,ie)},uniformMatrix3x4fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix3x4fv(e._,R,ie)},uniformMatrix4x3fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix4x3fv(e._,R,ie)}};function installUniformMethods(e){Object.assign(e,qd)}const Jd={clearBufferfv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferfv==`function`){X.clearBufferfv(e,R,Array.from(W));return}let ie=W;if(e===6144){let e=this.getParameter(this.COLOR_CLEAR_VALUE);this.clearColor(ie[0]??0,ie[1]??0,ie[2]??0,ie[3]??0),this.clear(this.COLOR_BUFFER_BIT),e&&this.clearColor(e[0],e[1],e[2],e[3])}else if(e===6145){let e=this.getParameter(this.DEPTH_CLEAR_VALUE);this.clearDepth(ie[0]??1),this.clear(this.DEPTH_BUFFER_BIT),e!==null&&this.clearDepth(e)}},clearBufferiv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferiv==`function`){X.clearBufferiv(e,R,Array.from(W));return}if(e===6146){let e=W,R=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearStencil(e[0]??0),this.clear(this.STENCIL_BUFFER_BIT),R!==null&&this.clearStencil(R)}},clearBufferuiv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferuiv==`function`){X.clearBufferuiv(e,R,Array.from(W));return}},clearBufferfi(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferfi==`function`){X.clearBufferfi(e,R,W,Y);return}if(e===34041){let e=this.getParameter(this.DEPTH_CLEAR_VALUE),R=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearDepth(W),this.clearStencil(Y),this.clear(this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),e!==null&&this.clearDepth(e),R!==null&&this.clearStencil(R)}}};function installClearBufferMethods(e){Object.assign(e,Jd)}bt();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Yd={drawArraysInstanced(e,R,W,Y){if(R<0||W<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=vertexCount(this,e,W);if(X<0){this.setError(this.INVALID_ENUM);return}if(this._framebufferOk()&&!(W===0||Y===0)&&this._checkVertexAttribState(W+R-1>>>0)){if(debugGlEnabled()){let e=this,R=e.__drawInstCount=(e.__drawInstCount|0)+1;(R<=5||R%100==0)&&yt.log(`[WebGL] drawArraysInstanced #${R} count=${X} instances=${Y} fbo=${this._activeFramebuffer?._??`_gtkFbo`}`)}this._native2.drawArraysInstanced(e,R,X,Y)}},drawElementsInstanced(e,R,W,Y,X){if(R<0||Y<0||X<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let ie=this._vertexObjectState._elementArrayBufferBinding;if(!ie){this.setError(this.INVALID_OPERATION);return}let ae=null,le=Y;if(W===this.UNSIGNED_SHORT){if(le%2){this.setError(this.INVALID_OPERATION);return}le>>=1,ae=new Uint16Array(ie._elements.buffer)}else if(W===this.UNSIGNED_INT){if(le%4){this.setError(this.INVALID_OPERATION);return}le>>=2,ae=new Uint32Array(ie._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ae=ie._elements;else{this.setError(this.INVALID_ENUM);return}let _e=R;switch(e){case this.TRIANGLES:R%3&&(_e-=R%3);break;case this.LINES:R%2&&(_e-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(_e===0||X===0){this._checkVertexAttribState(0);return}if(_e+le>>>0>ae.length){this.setError(this.INVALID_OPERATION);return}let ye=0;for(let e=le;e<le+_e;++e)ae[e]>ye&&(ye=ae[e]);this._checkVertexAttribState(ye)&&this._native2.drawElementsInstanced(e,_e,W,Y,X)},vertexAttribDivisor(e,R){this._native2.vertexAttribDivisor(e,R)},vertexAttribIPointer(e,R,W,Y,X){this._native2.vertexAttribIPointer(e,R,W,Y,X)},drawBuffers(e){let R=!1;for(let W=0;W<e.length;W++)if(e[W]===1029){R=!0;break}if(!R){this._native2.drawBuffers(e);return}this._native2.drawBuffers(e.map(e=>e===1029?this.COLOR_ATTACHMENT0:e))},drawRangeElements(e,R,W,Y,X,ie){if(Y<0||ie<0){this.setError(this.INVALID_VALUE);return}if(W<R){this.setError(this.INVALID_VALUE);return}this.drawElements(e,Y,X,ie)},blitFramebuffer(e,R,W,Y,X,ie,ae,le,_e,ye){if(debugGlEnabled()){let e=this._gl.getError();e!==0&&yt.log(`[WebGL] blitFramebuffer PRE-ERROR 0x${e.toString(16)}`)}if(this._native2.blitFramebuffer(e,R,W,Y,X,ie,ae,le,_e,ye),debugGlEnabled()){let X=this._gl.getError(),ie=this,ae=ie.__blitCount=(ie.__blitCount|0)+1;ae<=5&&yt.log(`[WebGL] blitFramebuffer #${ae} src=(${e},${R},${W},${Y}) readFbo=${this._activeReadFramebuffer?._??`_gtkFbo`} err=${X===0?`OK`:`0x`+X.toString(16)}`)}},framebufferTextureLayer(e,R,W,Y,X){this._native2.framebufferTextureLayer(e,R,W?W._:0,Y,X)},invalidateFramebuffer(e,R){this._native2.invalidateFramebuffer(e,R)},invalidateSubFramebuffer(e,R,W,Y,X,ie){this._native2.invalidateSubFramebuffer(e,R,W,Y,X,ie)},readBuffer(e){this._native2.readBuffer(e)},renderbufferStorageMultisample(e,R,W,Y,X){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let ie=this._activeRenderbuffer;if(!ie){this.setError(this.INVALID_OPERATION);return}this._saveError(),this._native2.renderbufferStorageMultisample(e,R,W,Y,X);let ae=this.getError();this._restoreError(ae),ae===this.NO_ERROR&&(ie._width=Y,ie._height=X,ie._format=W)}};function installInstancedAndFramebufferOpsMethods(e){Object.assign(e,Yd)}Vt();var Xd=class WebGL2RenderingContext extends WebGLContextBase{get _gl(){return this._native2}constructor(e,R={}){super(e,R),this._queries={},this._samplers={},this._transformFeedbacks={},this._vertexArrayObjects={},this._syncs={},this._activeReadFramebuffer=null,this._activeDrawFramebuffer=null,this._native2=new Hd.WebGL2RenderingContext({}),this._init()}_getGlslVersion(e){return e?`300 es`:`130`}_validFramebufferAttachment(e){return super._validFramebufferAttachment(e)?!0:e>=36065&&e<=36079}static{this._WGL2_ALL_COLOR_ATTACHMENTS=[36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079]}_getColorAttachments(){return WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS}_preCheckFramebufferStatus(e){let R=e._attachments,W=0,Y=0,X=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT,...WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS];for(let ie of X){let X=R[ie];if(X){if(X instanceof WebGLTexture){let R=e._attachmentLevel[ie]??0,ae=X._levelWidth[R]??0,le=X._levelHeight[R]??0;if(ae>0&&le>0){W=ae,Y=le;break}}else if(X instanceof WebGLRenderbuffer&&X._width>0&&X._height>0){W=X._width,Y=X._height;break}}}return W>0&&Y>0?(e._width=W,e._height=Y,this.FRAMEBUFFER_COMPLETE):this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT}_updateFramebufferAttachments(e){if(super._updateFramebufferAttachments(e),e)for(let R=1;R<=15;R++){let W=36064+R;if(!(W in e._attachments))continue;let Y=e._attachments[W];if(Y instanceof WebGLTexture){let R=e._attachmentFace[W]||this.TEXTURE_2D,X=e._attachmentLevel[W]??0;this._gl.framebufferTexture2D(this.FRAMEBUFFER,W,R,Y._|0,X|0)}else Y instanceof WebGLRenderbuffer?this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,W,this.RENDERBUFFER,Y._|0):this._gl.framebufferTexture2D(this.FRAMEBUFFER,W,this.TEXTURE_2D,0,0)}}bindBuffer(e,R){if(e===35345||e===35982||e===36662||e===36663){let W=R?R._|0:0;this._gl.bindBuffer(e,W);return}super.bindBuffer(e,R)}bindFramebuffer(e,R){if(e===36008||e===36009){if(!checkObject(R))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(R&&R._pendingDelete||R&&!this._checkWrapper(R,WebGLFramebuffer))return;let W=R?R._|0:this._gtkFboId;if(this._gl.bindFramebuffer(e,W),e===36008){let e=this._activeReadFramebuffer;e!==R&&(e&&(--e._refCount,e._checkDelete()),R&&(R._refCount+=1)),this._activeReadFramebuffer=R}else{let e=this._activeDrawFramebuffer;e!==R&&(e&&(--e._refCount,e._checkDelete()),R&&(R._refCount+=1)),this._activeDrawFramebuffer=R,this._activeFramebuffer=R}return}super.bindFramebuffer(this.FRAMEBUFFER,R),this._activeReadFramebuffer=R,this._activeDrawFramebuffer=R}deleteFramebuffer(e){this._activeReadFramebuffer===e&&this.bindFramebuffer(36008,null),this._activeDrawFramebuffer===e&&this.bindFramebuffer(36009,null),super.deleteFramebuffer(e)}bufferData(e,R,W){let Y=e===35345||e===35982||e===36662||e===36663,X=W===35041||W===35043||W===35045||W===35042||W===35044||W===35046?this.STATIC_DRAW:W;if(Y){if(typeof R==`number`)R>=0&&this._gl.bufferDataSizeOnly(e,R,X);else if(typeof R==`object`&&R){let W=arrayToUint8Array(R);this._gl.bufferData(e,Uint8ArrayToVariant(W),X)}return}super.bufferData(e,R,X)}bufferSubData(e,R,W){if(e===35345||e===35982||e===36662||e===36663){if(R<0){this.setError(this.INVALID_VALUE);return}if(!W){this.setError(this.INVALID_VALUE);return}let Y=arrayToUint8Array(W);this._gl.bufferSubData(e,R,Uint8ArrayToVariant(Y));return}super.bufferSubData(e,R,W)}bindTexture(e,R){if(e===32879||e===35866){let W=R,Y=W?W._|0:0;this._gl.bindTexture(e,Y),W&&(W._binding=e);return}super.bindTexture(e,R)}texParameteri(e,R,W){if(e===32879||e===35866){this._gl.texParameteri(e,R,W);return}if(R===32882||R===34892||R===34893||R===33084||R===33085||R===33083||R===33082){this._gl.texParameteri(e,R,W);return}super.texParameteri(e,R,W)}drawArrays(e,R,W){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}this._framebufferOk()&&W!==0&&this._checkVertexAttribState(W+R-1>>>0)&&this._native2.drawArrays(e,R,Y)}drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||R===0)return;let _e=0;for(let e=ae;e<ae+le;++e)e<ie.length&&ie[e]>_e&&(_e=ie[e]);this._checkVertexAttribState(_e)&&this._native2.drawElements(e,le,W,Y)}bindBufferBase(e,R,W){this._native2.bindBufferBase(e,R,W?W._:0)}bindBufferRange(e,R,W,Y,X){this._native2.bindBufferRange(e,R,W?W._:0,Y,X)}copyBufferSubData(e,R,W,Y,X){this._native2.copyBufferSubData(e,R,W,Y,X)}getBufferSubData(e,R,W,Y,X){let ie=X===void 0?W.byteLength-(Y??0):X,ae=this._native2.getBufferSubData(e,R,ie),le=new Uint8Array(W.buffer,W.byteOffset+(Y??0)*(W instanceof Uint8Array?1:W.BYTES_PER_ELEMENT??1));le.set(ae.subarray(0,le.byteLength))}texImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe=0;if(arguments.length===6)if(_e=X,Te=Y,ie instanceof le.Pixbuf){let e=ie;be=e.get_width(),Ce=e.get_height(),ye=e.get_pixels()}else{let e=extractImageData(ie);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else arguments.length>=9&&(be=Y,Ce=X,Oe=ie,Te=ae);let Ae=this._getTexImage(e);if(!Ae){this.setError(this.INVALID_OPERATION);return}let Me=convertPixels(ye);if(this._unpackPremultAlpha&&Me&&Te===this.RGBA&&(Me=premultiplyAlpha(Me)),this._unpackFlipY&&Me&&be>0&&Ce>0){let e=this._computePixelSize(_e,Te);if(e>0){let R=this._computeRowStride(be,e),W=new Uint8Array(Me.length);for(let e=0;e<Ce;e++){let Y=e*R,X=(Ce-1-e)*R;W.set(Me.subarray(Y,Y+R),X)}Me=W}}this._saveError(),this._gl.texImage2D(e,R,W,be,Ce,Oe,Te,_e,Uint8ArrayToVariant(Me));let Pe=this.getError();if(this._restoreError(Pe),Pe!==this.NO_ERROR)return;Ae._levelWidth[R]=be,Ae._levelHeight[R]=Ce,Ae._format=Te,Ae._type=_e;let Re=this._activeFramebuffer;if(Re){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(Re._attachments[R[W]]===Ae){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}}texSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0;if(arguments.length===7)if(_e=ie,Te=X,ae instanceof le.Pixbuf){let e=ae;be=e.get_width(),Ce=e.get_height(),ye=e.get_pixels()}else{let e=extractImageData(ae);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else be=X,Ce=ie,Te=ae;if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}let Oe=convertPixels(ye);if(!Oe){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&Oe&&Te===this.RGBA&&(Oe=premultiplyAlpha(Oe)),this._unpackFlipY&&Oe&&be>0&&Ce>0){let e=this._computePixelSize(_e,Te);if(e>0){let R=this._computeRowStride(be,e),W=new Uint8Array(Oe.length);for(let e=0;e<Ce;e++){let Y=e*R,X=(Ce-1-e)*R;W.set(Oe.subarray(Y,Y+R),X)}Oe=W}}this._gl.texSubImage2D(e,R,W,Y,be,Ce,Te,_e,Uint8ArrayToVariant(Oe))}getUniform(e,R){let W=R?._activeInfo?.type,Y=5125,X=36294,ie=36295,ae=W===Y||W===X||W===ie||W===36296,le=e;if(!ae)return super.getUniform(le,R);if(!e||!R)return null;let _e=this._native2.getUniformi(le._|0,R._|0);return _e?W===Y?_e[0]>>>0:W===X?new Uint32Array([_e[0]>>>0,_e[1]>>>0]):W===ie?new Uint32Array([_e[0]>>>0,_e[1]>>>0,_e[2]>>>0]):new Uint32Array([_e[0]>>>0,_e[1]>>>0,_e[2]>>>0,_e[3]>>>0]):null}getUniformBlockIndex(e,R){return this._native2.getUniformBlockIndex(e._,R)}uniformBlockBinding(e,R,W){this._native2.uniformBlockBinding(e._,R,W)}getActiveUniformBlockName(e,R){let W=this._native2.getActiveUniformBlockName(e._,R);return W.length>0?W:null}getActiveUniformBlockParameter(e,R,W){return this._native2.getActiveUniformBlockParameter(e._,R,W)}getActiveUniforms(e,R,W){return this._native2.getActiveUniforms(e._,R,W)}getFragDataLocation(e,R){return this._native2.getFragDataLocation(e._,R)}getIndexedParameter(e,R){return this._native2.getIndexedParameteri(e,R)}getInternalformatParameter(e,R,W){return this._native2.getInternalformatParameter(e,R,W)}getParameter(e){if(e===7938)return`WebGL 2.0`;if(e===35724)return`WebGL GLSL ES 3.00`;if(e===7939)return warnNotImplemented(`WebGL2RenderingContext.getParameter(GL_EXTENSIONS)`),``;if(e===36006)return this._activeDrawFramebuffer;if(e===36010)return this._activeReadFramebuffer;switch(e){case 36183:case 35071:case 32883:case 36063:case 34852:case 36203:case 33001:case 33e3:case 37157:case 35373:case 35657:case 35077:case 35978:case 35979:case 35968:case 35376:case 35375:case 35659:case 37154:case 35371:case 35658:case 35379:case 35374:case 35377:case 35076:case 3330:case 3332:case 3331:case 35053:case 35055:case 3074:case 32874:case 35869:case 36389:case 35983:case 35368:case 35380:case 32878:case 3314:case 32877:case 3316:case 3315:case 34045:return this._native2.getParameterx(e)?.deepUnpack()|0;case 35977:case 36388:case 36387:return!!this._native2.getParameterx(e)?.deepUnpack()}return super.getParameter(e)}getStringi(e,R){let W=this._native2.getStringi(e,R);return W.length>0?W:null}renderbufferStorage(e,R,W,Y){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeRenderbuffer;if(!X){this.setError(this.INVALID_OPERATION);return}if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}for(;this._gl.getError()!==this.NO_ERROR;);if(this._gl.renderbufferStorage(e,R,W,Y),this._gl.getError()!==this.NO_ERROR)return;X._width=W,X._height=Y,X._format=R;let ie=this._activeFramebuffer;if(ie){let e=this._getAttachments(),R=!1;for(let W=0;W<e.length;++W)if(ie._attachments[e[W]]===X){R=!0;break}R&&this._updateFramebufferAttachments(ie)}}getSupportedExtensions(){let e=super.getSupportedExtensions();for(let R of[`EXT_color_buffer_float`,`EXT_color_buffer_half_float`,`OES_texture_half_float`])e.indexOf(R)===-1&&e.push(R);return e}readPixels(e,R,W,Y,X,ie,ae){if(!ae)return;if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._framebufferOk())return;let le=X===6408||X===32856?4:X===6407?3:X===33319?2:1,_e=ie===5126?4:ie===5131||ie===36193?2:ie===5125||ie===5124?4:ie===5123||ie===5122?2:1,ye=W*Y*le*_e,be=new Uint8Array(ye);this._saveError();let Ce=this._gl.readPixels(e,R,W,Y,X,ie,Uint8ArrayToVariant(be)),Te=this.getError();if(this._restoreError(Te),Te!==this.NO_ERROR)return;let Oe=Ce&&Ce.length>0?Ce:be;if(ae instanceof Uint8Array)ae.set(Oe);else if(ae instanceof Float32Array){let e=new Float32Array(Oe.buffer,0,ae.length);ae.set(e)}}_framebufferOk(){return!0}};installObjectLifecycleMethods(Xd.prototype),installTexImage3DMethods(Xd.prototype),installUniformMethods(Xd.prototype),installClearBufferMethods(Xd.prototype),installInstancedAndFramebufferOpsMethods(Xd.prototype);function notifyElementResize(e,R,W){e._allocatedClientWidth=R,e._allocatedClientHeight=W,e._fireResizeSubscribers(R,W);let Y=e.parentNode;for(;Y;)Y instanceof Element&&(Y._allocatedClientWidth=R,Y._allocatedClientHeight=W,Y._fireResizeSubscribers(R,W)),Y=Y.parentNode}var HTMLCanvasElement=class extends hi{constructor(e){super(),this.gtkGlArea=e}get width(){return this.gtkGlArea.get_allocated_width()}set width(e){}get height(){return this.gtkGlArea.get_allocated_height()}set height(e){}get clientWidth(){return this.width}get clientHeight(){return this.height}get offsetWidth(){return this.width}get offsetHeight(){return this.height}getGlArea(){return this.gtkGlArea}getContext(e,R){return e===`webgl`||e===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new WebGLRenderingContext(this,R)),this._webgl):e===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new Xd(this,R)),this._webgl2):super.getContext(e,R)}};const Zd={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},Qd={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`};function gdkKeyvalToKey(e){let R=Y.keyval_name(e);if(R&&Zd[R])return Zd[R];let W=Y.keyval_to_unicode(e);return W>0?String.fromCodePoint(W):R??`Unidentified`}function gdkKeyvalToCode(e){let R=Y.keyval_name(e);if(R&&Qd[R])return Qd[R];let W=Y.keyval_to_unicode(e);if(W>=97&&W<=122)return`Key`+String.fromCodePoint(W-32);if(W>=65&&W<=90)return`Key`+String.fromCodePoint(W);if(W>=48&&W<=57)return`Digit`+String.fromCodePoint(W);if(R){let e={minus:`Minus`,equal:`Equal`,bracketleft:`BracketLeft`,bracketright:`BracketRight`,backslash:`Backslash`,semicolon:`Semicolon`,apostrophe:`Quote`,grave:`Backquote`,comma:`Comma`,period:`Period`,slash:`Slash`};if(e[R])return e[R]}return R??`Unidentified`}function gdkKeyvalToLocation(e){let R=Y.keyval_name(e);return R?R.startsWith(`KP_`)?3:R.endsWith(`_L`)?1:R.endsWith(`_R`)?2:0:0}function getGlobalEventTarget(){return globalThis.__gjsify_globalEventTarget}function extractModifiers(e){let R=e.get_current_event_state();return{shiftKey:!!(R&Y.ModifierType.SHIFT_MASK),ctrlKey:!!(R&Y.ModifierType.CONTROL_MASK),altKey:!!(R&Y.ModifierType.ALT_MASK),metaKey:!!(R&Y.ModifierType.SUPER_MASK)}}function gtkButtonToDom(e){return e===1?0:e===2?1:e===3?2:e-1}function buttonsFromModifiers(e){let R=e.get_current_event_state(),W=0;return R&Y.ModifierType.BUTTON1_MASK&&(W|=1),R&Y.ModifierType.BUTTON3_MASK&&(W|=2),R&Y.ModifierType.BUTTON2_MASK&&(W|=4),W}function attachEventControllers(e,R,W){e.set_focusable(!0),e.set_can_focus(!0);let X={lastX:0,lastY:0,buttonsPressed:0,pressedKeys:new Set},ie=new Ce.EventControllerMotion;ie.connect(`motion`,(W,Y,ae)=>{let le=R();if(!le)return;let _e=e.get_allocated_width(),ye=e.get_allocated_height(),be=Math.max(0,Math.min(Y,_e)),Ce=Math.max(0,Math.min(ae,ye)),Te=be-X.lastX,Oe=Ce-X.lastY,Ae=extractModifiers(ie),Me=buttonsFromModifiers(ie),Pe={...Ae,clientX:be,clientY:Ce,offsetX:be,offsetY:Ce,screenX:be,screenY:Ce,movementX:Te,movementY:Oe,buttons:Me,button:0,bubbles:!0,cancelable:!0};le.dispatchEvent(new PointerEvent$1(`pointermove`,{...Pe,pointerId:1,pointerType:`mouse`,isPrimary:!0})),le.dispatchEvent(new MouseEvent(`mousemove`,Pe)),X.lastX=be,X.lastY=Ce}),ie.connect(`enter`,(e,W,Y)=>{let ae=R();if(!ae)return;X.lastX=W,X.lastY=Y;let le={...extractModifiers(ie),clientX:W,clientY:Y,offsetX:W,offsetY:Y,screenX:W,screenY:Y,bubbles:!1,cancelable:!1};ae.dispatchEvent(new PointerEvent$1(`pointerenter`,{...le,pointerId:1,pointerType:`mouse`,isPrimary:!0})),ae.dispatchEvent(new MouseEvent(`mouseenter`,le)),ae.dispatchEvent(new MouseEvent(`mouseover`,{...le,bubbles:!0}))}),ie.connect(`leave`,()=>{let e=R();if(!e)return;let W={...extractModifiers(ie),clientX:X.lastX,clientY:X.lastY,bubbles:!1,cancelable:!1};e.dispatchEvent(new PointerEvent$1(`pointerleave`,{...W,pointerId:1,pointerType:`mouse`,isPrimary:!0})),e.dispatchEvent(new MouseEvent(`mouseleave`,W)),e.dispatchEvent(new MouseEvent(`mouseout`,{...W,bubbles:!0}))}),e.add_controller(ie);let ae=new Ce.GestureClick;ae.set_button(0),ae.connect(`pressed`,(W,Y,ie,le)=>{let _e=R();if(!_e)return;let ye=gtkButtonToDom(ae.get_current_button()),be=extractModifiers(ae);X.buttonsPressed|=1<<ye;let Ce={...be,clientX:ie,clientY:le,offsetX:ie,offsetY:le,screenX:ie,screenY:le,button:ye,buttons:X.buttonsPressed,detail:Y,bubbles:!0,cancelable:!0};_e.dispatchEvent(new PointerEvent$1(`pointerdown`,{...Ce,pointerId:1,pointerType:`mouse`,isPrimary:!0})),_e.dispatchEvent(new MouseEvent(`mousedown`,Ce)),e.grab_focus()}),ae.connect(`released`,(e,W,Y,ie)=>{let le=R();if(!le)return;let _e=gtkButtonToDom(ae.get_current_button()),ye=extractModifiers(ae);X.buttonsPressed&=~(1<<_e);let be={...ye,clientX:Y,clientY:ie,offsetX:Y,offsetY:ie,screenX:Y,screenY:ie,button:_e,buttons:X.buttonsPressed,detail:W,bubbles:!0,cancelable:!0};le.dispatchEvent(new PointerEvent$1(`pointerup`,{...be,pointerId:1,pointerType:`mouse`,isPrimary:!0})),le.dispatchEvent(new MouseEvent(`mouseup`,be)),_e===0&&(le.dispatchEvent(new MouseEvent(`click`,be)),W===2&&le.dispatchEvent(new MouseEvent(`dblclick`,be))),_e===2&&le.dispatchEvent(new MouseEvent(`contextmenu`,{...be,cancelable:!0}))}),e.add_controller(ae);let le=new Ce.EventControllerScroll({flags:Ce.EventControllerScrollFlags.BOTH_AXES});le.connect(`scroll`,(e,W,Y)=>{let ie=R();if(!ie)return;let ae={...extractModifiers(le),clientX:X.lastX,clientY:X.lastY,offsetX:X.lastX,offsetY:X.lastY,screenX:X.lastX,screenY:X.lastY,deltaX:W*100,deltaY:Y*100,deltaZ:0,deltaMode:0,bubbles:!0,cancelable:!0};return ie.dispatchEvent(new WheelEvent$1(`wheel`,ae)),!1}),e.add_controller(le);let _e=new Ce.EventControllerKey;_e.connect(`key-pressed`,(e,ie,ae,le)=>{let _e=R();if(!_e)return!1;let ye=X.pressedKeys.has(ie);X.pressedKeys.add(ie);let be=gdkKeyvalToKey(ie),Ce={key:be,code:gdkKeyvalToCode(ie),location:gdkKeyvalToLocation(ie),repeat:ye,altKey:!!(le&Y.ModifierType.ALT_MASK),ctrlKey:!!(le&Y.ModifierType.CONTROL_MASK),metaKey:!!(le&Y.ModifierType.SUPER_MASK),shiftKey:!!(le&Y.ModifierType.SHIFT_MASK),keyCode:be.length===1?be.toUpperCase().charCodeAt(0):0,which:be.length===1?be.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0},Te=new KeyboardEvent$1(`keydown`,Ce);return _e.dispatchEvent(Te),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent$1(`keydown`,Ce)),W?.captureKeys===!0}),_e.connect(`key-released`,(e,W,ie,ae)=>{let le=R();if(!le)return;X.pressedKeys.delete(W);let _e=gdkKeyvalToKey(W),ye={key:_e,code:gdkKeyvalToCode(W),location:gdkKeyvalToLocation(W),repeat:!1,altKey:!!(ae&Y.ModifierType.ALT_MASK),ctrlKey:!!(ae&Y.ModifierType.CONTROL_MASK),metaKey:!!(ae&Y.ModifierType.SUPER_MASK),shiftKey:!!(ae&Y.ModifierType.SHIFT_MASK),keyCode:_e.length===1?_e.toUpperCase().charCodeAt(0):0,which:_e.length===1?_e.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0};le.dispatchEvent(new KeyboardEvent$1(`keyup`,ye)),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent$1(`keyup`,ye))}),e.add_controller(_e);let ye=new Ce.EventControllerFocus;ye.connect(`enter`,()=>{let e=R();e&&(e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusin`,{bubbles:!0,cancelable:!1})))}),ye.connect(`leave`,()=>{let e=R();e&&(X.pressedKeys.clear(),e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,cancelable:!1})),getGlobalEventTarget()?.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})))}),e.add_controller(ye)}bt();const $d=Me.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends Ce.GLArea{constructor(R){super(R),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=e.get_monotonic_time(),this.set_use_es(!0),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((R,W)=>(this._frameCallback!==null&&this.queue_render(),e.SOURCE_CONTINUE));let W=this.connect(`render`,()=>{this.disconnect(W),this.make_current(),this._canvas=new HTMLCanvasElement(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let R=this._canvas.getContext(`webgl`);if(R){for(let e of this._readyCallbacks)e(this._canvas,R);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,R=>{if(this._frameCallback!==null){let R=(e.get_monotonic_time()-this._timeOrigin)/1e3;globalThis.__GJSIFY_DEBUG_RAF===!0&&yt.log(`[rAF] frame callback fires t=${R.toFixed(1)}`);let W=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,W(R)}return!0}),!0});this.connect(`resize`,()=>{let e=this.get_allocated_width(),R=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new Event$1(`resize`)),notifyElementResize(this._canvas,e,R));for(let W of this._resizeCallbacks)W(e,R);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}),this.connect(`unrealize`,()=>{this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._canvas=null})}get canvas(){return this._canvas}onReady(e){if(this._canvas){let R=this._canvas.getContext(`webgl`);if(R){e(this._canvas,R);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let R=this._nextFrameId++;return this._frameCallback=e,this._frameCallbackId=R,this.queue_render(),R}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0)}installGlobals(){let R=globalThis;R.requestAnimationFrame=e=>this.requestAnimationFrame(e),R.cancelAnimationFrame=e=>this.cancelAnimationFrame(e);let W=this._timeOrigin;R.performance={now:()=>(e.get_monotonic_time()-W)/1e3,timeOrigin:Date.now()}}});st();const ef=globalThis;ef.WebGLRenderingContext=WebGLRenderingContext,ef.WebGL2RenderingContext=Xd;const tf=Me.registerClass({GTypeName:`GjsifyCanvas2DBridge`},class Canvas2DBridge extends Ce.DrawingArea{constructor(R){super(R),this._canvas=null,this._ctx=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._tickCallbackId=null,this._frameCallback=null,this._timeOrigin=e.get_monotonic_time(),this.set_draw_func(this._onDraw.bind(this)),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this.connect(`unrealize`,()=>{this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._ctx&&this._ctx._dispose(),this._canvas=null,this._ctx=null})}_onDraw(e,R,W,Y){if(!this._canvas){if(this._canvas=new hi,this._canvas.width=W,this._canvas.height=Y,this._ctx=this._canvas.getContext(`2d`),this._ctx){for(let e of this._readyCallbacks)e(this._canvas,this._ctx);this._readyCallbacks=[]}}else if(this._canvas.width!==W||this._canvas.height!==Y){this._canvas.width=W,this._canvas.height=Y,this._canvas.dispatchEvent(new Event$1(`resize`)),notifyElementResize(this._canvas,W,Y);for(let e of this._resizeCallbacks)e(W,Y)}if(this._ctx){let e=this._ctx._getSurface();R.setSourceSurface(e,0,0),R.paint()}}get canvas(){return this._canvas}getContext(e){return this._ctx}onReady(e){if(this._canvas&&this._ctx){e(this._canvas,this._ctx);return}this._readyCallbacks.push(e)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(R){return this._frameCallback=R,this._tickCallbackId===null&&(this._tickCallbackId=this.add_tick_callback((R,W)=>{this._tickCallbackId=null;let Y=(W.get_frame_time()-this._timeOrigin)/1e3;return this._frameCallback?.(Y),this.queue_draw(),e.SOURCE_REMOVE})),this.queue_draw(),0}installGlobals(){let R=globalThis;R.requestAnimationFrame=e=>this.requestAnimationFrame(e);let W=this._timeOrigin;R.performance={now:()=>(e.get_monotonic_time()-W)/1e3,timeOrigin:Date.now()}}}),nf=Symbol.for(`gjsify_canvas2d_context`);hi.registerContextFactory(`2d`,(e,R)=>{let W=e,Y=W[nf];if(Y)return Y;let X=new CanvasRenderingContext2D(e,R);return W[nf]=X,X}),Object.defineProperty(globalThis,`CanvasRenderingContext2D`,{value:CanvasRenderingContext2D,writable:!0,configurable:!0}),Object.defineProperty(globalThis,`ImageData`,{value:OurImageData,writable:!0,configurable:!0}),Object.defineProperty(globalThis,`Path2D`,{value:Di,writable:!0,configurable:!0}),bt();
|
|
19
|
+
`+Y+R:Y&&(R=Y+R)}else Y&&(R=Y+R);return R}};function installShaderLifecycleMethods(e){Object.assign(e,Ld)}const Rd={createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let R=new WebGLProgram(e,this);return this._programs[e]=R,R},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,WebGLProgram)},useProgram(e){if(!checkObject(e))throw TypeError(`useProgram(WebGLProgram)`);if(e)this._checkWrapper(e,WebGLProgram)&&(this._activeProgram!==e&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=e,e._refCount+=1),this._gl.useProgram(e._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(e){if(!checkObject(e))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(e,WebGLProgram)){e._linkCount+=1,e._attributes=[];let R=this.getError();for(let R of e._references)R instanceof WebGLShader&&R._needsRecompile&&(this._gl.compileShader(R._|0),R._needsRecompile=!1);this._gl.linkProgram(e._|0);let W=this.getError();W===this.NO_ERROR&&(e._linkStatus=this._fixupLink(e)),this.getError(),this.setError(R||W)}},validateProgram(e){if(this._checkWrapper(e,WebGLProgram)){this._gl.validateProgram(e._|0);let R=this.getError();R===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(R)}},attachShader(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!e||!R){this.setError(this.INVALID_VALUE);return}else if(e instanceof WebGLProgram&&R instanceof WebGLShader&&this._checkOwns(e)&&this._checkOwns(R)&&!e._linked(R)){this._saveError(),this._gl.attachShader(e._|0,R._|0);let W=this.getError();this._restoreError(W),W===this.NO_ERROR&&e._link(R);return}this.setError(this.INVALID_OPERATION)},detachShader(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(e,WebGLProgram)&&this._checkWrapper(R,WebGLShader)&&(e._linked(R)?(this._gl.detachShader(e._,R._),e._unlink(R)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(e,R,W){if(!checkObject(e)||typeof W!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);W+=``,!isValidString(W)||W.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(W)?this.setError(this.INVALID_OPERATION):this._checkWrapper(e,WebGLProgram)&&this._gl.bindAttribLocation(e._|0,R|0,W)},getAttachedShaders(e){if(!checkObject(e)||typeof e==`object`&&e&&!(e instanceof WebGLProgram))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!e)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram))return e._references.filter(e=>e instanceof WebGLShader);return null},getProgramInfoLog(e){if(!checkObject(e))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(e,WebGLProgram)?e._linkInfoLog:null},getProgramParameter(e,R=0){if(!checkObject(e))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(e,WebGLProgram)){switch(R){case this.DELETE_STATUS:return e._pendingDelete;case this.LINK_STATUS:return e._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(e._,R);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(e._,R);case this.ACTIVE_ATTRIBUTES:return e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._,R);case this.ACTIVE_UNIFORMS:return e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._,R)}this.setError(this.INVALID_ENUM)}return null},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let R=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),W=Array.from({length:R});e._attributes.length=R;for(let Y=0;Y<R;++Y)W[Y]=this.getActiveAttrib(e,Y)?.name,e._attributes[Y]=this.getAttribLocation(e,W[Y])|0;for(let R=0;R<W.length;++R)if(W[R].length>256)return e._linkInfoLog=`attribute `+W[R]+` is too long`,!1;for(let Y=0;Y<R;++Y)e._attributes[Y]<0||this._gl.bindAttribLocation(e._|0,e._attributes[Y],W[Y]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let Y=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=Y;for(let R=0;R<Y;++R){let W=this.getActiveUniform(e,R);W&&(e._uniforms[R]=W)}for(let R=0;R<e._uniforms.length;++R)if(e._uniforms[R].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[R].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(e,R,W){if(!checkObject(R))throw TypeError(e+`(`+W.name+`)`);if(R instanceof W&&this._checkOwns(R)){R._pendingDelete=!0,R._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installProgramLifecycleMethods(e){Object.assign(e,Rd)}const zd={getActiveAttrib(e,R){if(!checkObject(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram)){if(R>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let W=this._gl.getActiveAttrib(e._|0,R|0);if(W)return new WebGLActiveInfo(W)}return null},getActiveUniform(e,R){if(!checkObject(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,WebGLProgram)){if(R>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let W=this._gl.getActiveUniform(e._|0,R|0);if(W)return new WebGLActiveInfo(W)}return null},getAttribLocation(e,R){if(!checkObject(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(R+=``,!isValidString(R)||R.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,WebGLProgram))return this._gl.getAttribLocation(e._|0,R+``);return-1},getUniform(e,R){if(!checkObject(e)||!checkObject(R))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!R)return null;if(this._checkWrapper(e,WebGLProgram)){if(!checkUniform(e,R))return this.setError(this.INVALID_OPERATION),null;let W=this._gl.getUniform(e._|0,R._|0);if(!W)return null;switch(R._activeInfo.type){case this.FLOAT:return W[0];case this.FLOAT_VEC2:return new Float32Array(W.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(W.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(W.slice(0,4));case this.INT:return W[0]|0;case this.INT_VEC2:return new Int32Array(W.slice(0,2));case this.INT_VEC3:return new Int32Array(W.slice(0,3));case this.INT_VEC4:return new Int32Array(W.slice(0,4));case this.BOOL:return!!W[0];case this.BOOL_VEC2:return[!!W[0],!!W[1]];case this.BOOL_VEC3:return[!!W[0],!!W[1],!!W[2]];case this.BOOL_VEC4:return[!!W[0],!!W[1],!!W[2],!!W[3]];case this.FLOAT_MAT2:return new Float32Array(W.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(W.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(W.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return W[0]|0;default:return null}}return null},getUniformLocation(e,R){if(!checkObject(e))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(R+=``,!isValidString(R))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(e,WebGLProgram)){let W=this._gl.getUniformLocation(e._|0,R);if(W!==null&&W>=0){let Y=R;/\[\d+\]$/.test(R)&&(Y=R.replace(/\[\d+\]$/,`[0]`));let X=Y+`[0]`,ie=null;for(let R=0;R<e._uniforms.length;++R){let W=e._uniforms[R];if(W.name===Y||W.name===X){ie={size:W.size,type:W.type,name:W.name};break}}ie||={name:Y,type:0,size:1};let ae=new WebGLUniformLocation(W,e,ie),le=R.match(/\[(\d+)\]$/),_e=le?+le[1]:-1;if(ie.name.endsWith(`[0]`)&&(_e===-1||_e===0)){let R=ie.name.replace(/\[0\]$/,``),W=[];this._saveError();for(let Y=0;this.getError()===this.NO_ERROR;++Y){let X=this._gl.getUniformLocation(e._|0,R+`[`+Y+`]`);if(this.getError()!==this.NO_ERROR||X==null||X<0)break;W.push(X)}this._restoreError(this.NO_ERROR),ae._array=W}else if(_e>0&&_e>=ie.size)return null;return ae}}return null}};function installIntrospectionMethods(e){Object.assign(e,zd)}bt();const Bd={uniform1f(e,R){this._checkUniformValid(e,R,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,R)},uniform1i(e,R){this._gl.uniform1i(e?._||0,R)},uniform2f(e,R,W){this._checkUniformValid(e,R,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,R,W)},uniform2i(e,R,W){this._checkUniformValid(e,R,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,R,W)},uniform3f(e,R,W,Y){this._checkUniformValid(e,R,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,R,W,Y)},uniform3i(e,R,W,Y){this._checkUniformValid(e,R,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,R,W,Y)},uniform4f(e,R,W,Y,X){if(!this._checkUniformValid(e,R,`uniform4f`,4,`f`)){yt.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,R,W,Y,X)},uniform4i(e,R,W,Y,X){this._checkUniformValid(e,R,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,R,W,Y,X)},uniform1fv(e,R){if(!(!e||!this._checkUniformValueValid(e,R,`uniform1fv`,1,`f`))){if(e?._array){let W=e._array;for(let e=0;e<W.length&&e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform1f(Y,R[e])}return}this._gl.uniform1f(e?._|0,R[0])}},uniform1iv(e,R){if(this._checkUniformValueValid(e,R,`uniform1iv`,1,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform1i(Y,R[e])}return}this.uniform1i(e,R[0])}},uniform2fv(e,R){if(this._checkUniformValueValid(e,R,`uniform2fv`,2,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&2*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform2f(Y,R[2*e],R[2*e+1])}return}this._gl.uniform2f(e?._||0,R[0],R[1])}},uniform2iv(e,R){if(this._checkUniformValueValid(e,R,`uniform2iv`,2,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&2*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform2i(Y,R[2*e],R[2*e+1])}return}this.uniform2i(e,R[0],R[1])}},uniform3fv(e,R){if(this._checkUniformValueValid(e,R,`uniform3fv`,3,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&3*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform3f(Y,R[3*e],R[3*e+1],R[3*e+2])}return}this._gl.uniform3f(e?._||0,R[0],R[1],R[2])}},uniform3iv(e,R){if(this._checkUniformValueValid(e,R,`uniform3iv`,3,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&3*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform3i(Y,R[3*e],R[3*e+1],R[3*e+2])}return}this.uniform3i(e,R[0],R[1],R[2])}},uniform4fv(e,R){if(this._checkUniformValueValid(e,R,`uniform4fv`,4,`f`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&4*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform4f(Y,R[4*e],R[4*e+1],R[4*e+2],R[4*e+3])}return}this._gl.uniform4f(e?._||0,R[0],R[1],R[2],R[3])}},uniform4iv(e,R){if(this._checkUniformValueValid(e,R,`uniform4iv`,4,`i`)){if(e?._array){let W=e._array;for(let e=0;e<W.length&&4*e<R.length;++e){let Y=W[e];Y!=null&&this._gl.uniform4i(Y,R[4*e],R[4*e+1],R[4*e+2],R[4*e+3])}return}this.uniform4i(e,R[0],R[1],R[2],R[3])}},uniformMatrix2fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix2fv`,2))return;let Y=new Float32Array(W);this._gl.uniformMatrix2fv(e?._||0,!!R,listToArray(Y))},uniformMatrix3fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix3fv`,3))return;let Y=new Float32Array(W);this._gl.uniformMatrix3fv(e?._||0,!!R,listToArray(Y))},uniformMatrix4fv(e,R,W){if(!this._checkUniformMatrix(e,R,W,`uniformMatrix4fv`,4))return;let Y=new Float32Array(W);this._gl.uniformMatrix4fv(e?._||0,!!R,listToArray(Y))},_checkLocation(e){return e instanceof WebGLUniformLocation?e._program._ctx!==this||e._linkCount!==e._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,R,W,Y,X){if(!checkObject(e))throw TypeError(`${W}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let W=e._activeInfo.type;if(W===this.SAMPLER_2D||W===this.SAMPLER_CUBE){if(Y!==1)return this.setError(this.INVALID_VALUE),!1;if(X!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(R<0||R>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return uniformTypeSize(this,W)>Y?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,R,W,Y,X){if(!checkObject(e)||!checkObject(R))throw TypeError(`${W}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof R!=`object`||!R||typeof R.length!=`number`)throw TypeError(`Second argument to ${W} must be array`);return uniformTypeSize(this,e._activeInfo.type)>Y?(this.setError(this.INVALID_OPERATION),!1):R.length>=Y&&R.length%Y===0?e._array||R.length===Y?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,R,W,Y,X){if(!checkObject(e)||typeof W!=`object`)throw TypeError(Y+`(WebGLUniformLocation, Boolean, Array)`);return R||typeof W!=`object`||!W||!W.length||W.length%X*X!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:W.length===X*X||e._array?!0:(this.setError(this.INVALID_VALUE),!1)}};function installUniformsMethods(e){Object.assign(e,Bd)}function installShaderProgramMethods(e){installShaderLifecycleMethods(e),installProgramLifecycleMethods(e),installIntrospectionMethods(e),installUniformsMethods(e)}bt();const Vd={drawArrays(e=0,R=0,W=0){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||W===0)return;let X=R;W>0&&(X=W+R-1>>>0),this._checkVertexAttribState(X)&&this._gl.drawArrays(e,R,Y)},drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(this._extensions.oes_element_index_uint&&W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(R===0){this._checkVertexAttribState(0);return}if(R+ae>>>0>ie.length){this.setError(this.INVALID_OPERATION);return}let _e=-1;for(let e=ae;e<ae+R;++e)_e=Math.max(_e,ie[e]);if(_e<0){this._checkVertexAttribState(0);return}this._checkVertexAttribState(_e)&&le>0&&this._gl.drawElements(e,le,W,Y)},viewport(e,R,W,Y){this._viewport[0]=e|0,this._viewport[1]=R|0,this._viewport[2]=W|0,this._viewport[3]=Y|0,this._gl.viewport(e,R,W,Y)},scissor(e,R,W,Y){this._scissorBox[0]=e|0,this._scissorBox[1]=R|0,this._scissorBox[2]=W|0,this._scissorBox[3]=Y|0,this._gl.scissor(e|0,R|0,W|0,Y|0)},readPixels(e=0,R=0,W=0,Y=0,X=0,ie=0,ae){if(!ae)return;if(!(this._extensions.oes_texture_float&&ie===this.FLOAT&&X===this.RGBA)){if(X===this.RGB||X===this.ALPHA||ie!==this.UNSIGNED_BYTE){this.setError(this.INVALID_OPERATION);return}else if(X!==this.RGBA){this.setError(this.INVALID_ENUM);return}else if(W<0||Y<0||!(ae instanceof Uint8Array)){this.setError(this.INVALID_VALUE);return}}if(!this._framebufferOk()){yt.error(`framebuffer is not okay!`);return}let le=W*4;le%this._packAlignment!==0&&(le+=this._packAlignment-le%this._packAlignment);let _e=le*(Y-1)+W*4;if(_e<=0)return;if((ae.length||ae.byteLength||0)<_e){this.setError(this.INVALID_VALUE);return}let ye=this.drawingBufferWidth,be=this.drawingBufferHeight;this._activeFramebuffer&&(ye=this._activeFramebuffer._width,be=this._activeFramebuffer._height);let Ce=arrayToUint8Array(ae);if(e>=ye||e+W<=0||R>=be||R+Y<=0)for(let e=0;e<Ce.length;++e)Ce[e]=0;else if(e<0||e+W>ye||R<0||R+Y>be){for(let e=0;e<Ce.length;++e)Ce[e]=0;let ae=e,_e=W;e<0&&(_e+=e,ae=0),ae+W>ye&&(_e=ye-ae);let Te=R,Oe=Y;R<0&&(Oe+=R,Te=0),Te+Y>be&&(Oe=be-Te);let Ae=_e*4;if(Ae%this._packAlignment!==0&&(Ae+=this._packAlignment-Ae%this._packAlignment),_e>0&&Oe>0){let W=new Uint8Array(Ae*Oe),Y=this._gl.readPixels(ae,Te,_e,Oe,X,ie,Uint8ArrayToVariant(W)),ye=Y&&Y.length>0?Y:W,be=4*(ae-e)+(Te-R)*le;for(let e=0;e<Oe;++e)for(let R=0;R<_e;++R)for(let W=0;W<4;++W)Ce[be+e*le+4*R+W]=ye[e*Ae+4*R+W]}}else{let ae=this._gl.readPixels(e,R,W,Y,X,ie,Uint8ArrayToVariant(Ce));ae&&ae.length>0&&Ce.set(ae)}},enableVertexAttribArray(e){if(e<0||e>=this._vertexObjectState._attribs.length){this.setError(this.INVALID_VALUE);return}this._gl.enableVertexAttribArray(e),this._vertexObjectState._attribs[e]._isPointer=!0},disableVertexAttribArray(e=0){if(e<0||e>=this._vertexObjectState._attribs.length){this.setError(this.INVALID_VALUE);return}this._gl.disableVertexAttribArray(e),this._vertexObjectState._attribs[e]._isPointer=!1},vertexAttrib1f(e,R){if(e|=0,!this._checkVertexIndex(e))return;let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[1]=W[2]=0,W[0]=R,this._gl.vertexAttrib1f(e|0,+R)},vertexAttrib1fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<1){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=0,W[1]=0,W[0]=R[0],this._gl.vertexAttrib1f(e|0,+R[0])},vertexAttrib2f(e,R,W){if(e|=0,!this._checkVertexIndex(e))return;let Y=this._vertexGlobalState._attribs[e]._data;Y[3]=1,Y[2]=0,Y[1]=W,Y[0]=R,this._gl.vertexAttrib2f(e|0,+R,+W)},vertexAttrib2fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<2){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=0,W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib2f(e|0,+R[0],+R[1])},vertexAttrib3f(e,R,W,Y){if(e|=0,!this._checkVertexIndex(e))return;let X=this._vertexGlobalState._attribs[e]._data;X[3]=1,X[2]=Y,X[1]=W,X[0]=R,this._gl.vertexAttrib3f(e|0,+R,+W,+Y)},vertexAttrib3fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<3){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=1,W[2]=R[2],W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib3f(e|0,+R[0],+R[1],+R[2])},vertexAttrib4f(e=0,R,W,Y,X){if(!this._checkVertexIndex(e))return;let ie=this._vertexGlobalState._attribs[e]._data;ie[3]=X,ie[2]=Y,ie[1]=W,ie[0]=R,this._gl.vertexAttrib4f(e|0,+R,+W,+Y,+X)},vertexAttrib4fv(e,R){if(e|=0,!this._checkVertexIndex(e))return;if(typeof R!=`object`||!R||R.length<4){this.setError(this.INVALID_OPERATION);return}let W=this._vertexGlobalState._attribs[e]._data;W[3]=R[3],W[2]=R[2],W[1]=R[1],W[0]=R[0],this._gl.vertexAttrib4f(e|0,+R[0],+R[1],+R[2],+R[3])},vertexAttribPointer(e=0,R=0,W=0,Y=!1,X=0,ie=0){if(X<0||ie<0){this.setError(this.INVALID_VALUE);return}if(X<0||ie<0||e<0||e>=this._vertexObjectState._attribs.length||!(R===1||R===2||R===3||R===4)){this.setError(this.INVALID_VALUE);return}if(this._vertexGlobalState._arrayBufferBinding===null){this.setError(this.INVALID_OPERATION);return}let ae=typeSize(this,W);if(ae===0||W===this.INT||W===this.UNSIGNED_INT){this.setError(this.INVALID_ENUM);return}if(X>255||X<0){this.setError(this.INVALID_VALUE);return}if(X%ae!==0||ie%ae!==0){this.setError(this.INVALID_OPERATION);return}this._gl.vertexAttribPointer(e,R,W,Y,X,ie),this._vertexObjectState.setVertexAttribPointer(this._vertexGlobalState._arrayBufferBinding,e,R*ae,ie,X||R*ae,W,Y,X,R)},getVertexAttrib(e=0,R=0){if(e<0||e>=this._vertexObjectState._attribs.length)return this.setError(this.INVALID_VALUE),null;let W=this._vertexObjectState._attribs[e],Y=this._vertexGlobalState._attribs[e]._data,X=this._extensions.angle_instanced_arrays;if(X&&R===X.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)return W._divisor;switch(R){case this.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:return W._pointerBuffer;case this.VERTEX_ATTRIB_ARRAY_ENABLED:return W._isPointer;case this.VERTEX_ATTRIB_ARRAY_SIZE:return W._inputSize;case this.VERTEX_ATTRIB_ARRAY_STRIDE:return W._inputStride;case this.VERTEX_ATTRIB_ARRAY_TYPE:return W._pointerType;case this.VERTEX_ATTRIB_ARRAY_NORMALIZED:return W._pointerNormal;case this.CURRENT_VERTEX_ATTRIB:return new Float32Array(Y);default:return this.setError(this.INVALID_ENUM),null}},getVertexAttribOffset(e=0,R=0){return e<0||e>=this._vertexObjectState._attribs.length?(this.setError(this.INVALID_VALUE),-1):R===this.VERTEX_ATTRIB_ARRAY_POINTER?this._vertexObjectState._attribs[e]._pointerOffset:(this.setError(this.INVALID_ENUM),-1)},_checkVertexAttribState(e){let R=this._activeProgram;if(!R)return this.setError(this.INVALID_OPERATION),!1;let W=this._vertexObjectState._attribs;for(let Y=0;Y<W.length;++Y){let X=W[Y];if(X._isPointer){let W=X._pointerBuffer;if(!W)return this.setError(this.INVALID_OPERATION),!1;if(R._attributes.indexOf(Y)>=0){let R=0;if(R=X._divisor?X._pointerSize+X._pointerOffset:X._pointerStride*e+X._pointerSize+X._pointerOffset,R>W._size)return this.setError(this.INVALID_OPERATION),!1}}}return!0},_checkVertexIndex(e){return e<0||e>=this._vertexObjectState._attribs.length?(this.setError(this.INVALID_VALUE),!1):!0}};function installDrawingMethods(e){Object.assign(e,Vd)}function installAllContextMethods(e){installStateMethods(e),installBufferBindingMethods(e),installTextureManagementMethods(e),installFramebufferMethods(e),installShaderProgramMethods(e),installDrawingMethods(e)}var Hd=Ae;Vt();let Ud=0;const Wd={oes_element_index_uint:getOESElementIndexUint,oes_texture_float:getOESTextureFloat,oes_texture_float_linear:getOESTextureFloatLinear,oes_standard_derivatives:getOESStandardDerivatives,stackgl_destroy_context:getSTACKGLDestroyContext,stackgl_resize_drawingbuffer:getSTACKGLResizeDrawingBuffer,ext_blend_minmax:getEXTBlendMinMax,ext_color_buffer_float:getEXTColorBufferFloat,ext_color_buffer_half_float:getEXTColorBufferHalfFloat,ext_texture_filter_anisotropic:getEXTTextureFilterAnisotropic,oes_texture_half_float:getOESTextureHalfFloat};var WebGLContextBase=class{get drawingBufferHeight(){return this.canvas.height||0}get drawingBufferWidth(){return this.canvas.width||0}constructor(e,R={}){this.drawingBufferColorSpace=`srgb`,this.unpackColorSpace=`srgb`,this.RGBA8=32856,this.DEFAULT_ATTACHMENTS=[],this.DEFAULT_COLOR_ATTACHMENTS=[],this._=0,this._extensions={},this._programs={},this._shaders={},this._textures={},this._framebuffers={},this._renderbuffers={},this._buffers={},this._activeProgram=null,this._activeFramebuffer=null,this._activeRenderbuffer=null,this._checkStencil=!1,this._stencilState=!0,this._activeTextureUnit=0,this._errorStack=[],this._maxTextureSize=0,this._maxTextureLevel=0,this._maxCubeMapSize=0,this._maxCubeMapLevel=0,this._maxRenderbufferSize=0,this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this._viewport=new Int32Array([0,0,0,0]),this._scissorBox=new Int32Array([0,0,0,0]),this._gtkFboId=0,this._textureUnits=[],this._drawingBuffer=null,this.canvas=e,this._contextAttributes=new WebGLContextAttributes(flag(R,`alpha`,!0),flag(R,`depth`,!0),flag(R,`stencil`,!1),!1,flag(R,`premultipliedAlpha`,!0),flag(R,`preserveDrawingBuffer`,!1),flag(R,`preferLowPowerToHighPerformance`,!1),flag(R,`failIfMajorPerformanceCaveat`,!1)),this._contextAttributes.premultipliedAlpha=this._contextAttributes.premultipliedAlpha&&this._contextAttributes.alpha}_init(){let e=this._gl.getParameterx(36006);this._gtkFboId=e?.deepUnpack()|0,this._initGLConstants(),this.DEFAULT_ATTACHMENTS=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT],this.DEFAULT_COLOR_ATTACHMENTS=[this.COLOR_ATTACHMENT0];let R=this.drawingBufferWidth||0,W=this.drawingBufferHeight||0;this._=Ud++;let Y=this.getParameter(this.MAX_COMBINED_TEXTURE_IMAGE_UNITS);this._textureUnits=Array.from({length:Y});for(let e=0;e<Y;++e)this._textureUnits[e]=new WebGLTextureUnit(this,e);this.activeTexture(this.TEXTURE0),this._defaultVertexObjectState=new WebGLVertexArrayObjectState(this),this._vertexObjectState=this._defaultVertexObjectState,this._vertexGlobalState=new WebGLVertexArrayGlobalState(this),this._maxTextureSize=this.getParameter(this.MAX_TEXTURE_SIZE),this._maxTextureLevel=Td.log2(Td.nextPow2(this._maxTextureSize)),this._maxCubeMapSize=this.getParameter(this.MAX_CUBE_MAP_TEXTURE_SIZE),this._maxCubeMapLevel=Td.log2(Td.nextPow2(this._maxCubeMapSize)),this._maxRenderbufferSize=this.getParameter(this.MAX_RENDERBUFFER_SIZE),this._unpackAlignment=4,this._packAlignment=4,this._unpackFlipY=!1,this._unpackPremultAlpha=!1,this.bindBuffer(this.ARRAY_BUFFER,null),this.bindBuffer(this.ELEMENT_ARRAY_BUFFER,null),this.bindFramebuffer(this.FRAMEBUFFER,null),this.bindRenderbuffer(this.RENDERBUFFER,null),this.viewport(0,0,R,W),this.scissor(0,0,R,W),this.clearDepth(1),this.clearColor(0,0,0,0),this.clearStencil(0),this.clear(this.COLOR_BUFFER_BIT|this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),this.disable(this.DEPTH_TEST),this.disable(this.STENCIL_TEST),this.disable(this.BLEND),this.disable(this.CULL_FACE),this.disable(this.POLYGON_OFFSET_FILL),this.disable(this.SCISSOR_TEST),this._gl.colorMask(!0,!0,!0,!0)}_initGLConstants(){let e=new Hd.WebGLRenderingContextBase().get_webgl_constants();for(let[R,W]of Object.entries(e))Object.defineProperty(this,R,{value:W})}_getGlslVersion(e){return e?`100`:`120`}_checkOwns(e){return typeof e==`object`&&!!e&&e._ctx===this}_checkValid(e,R){return e instanceof R&&e._!==0}_checkWrapper(e,R){return this._checkValid(e,R)?this._checkOwns(e)?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)}_isObject(e,R,W){if(e!=null&&!(e instanceof W))throw TypeError(R+`(`+W.name+`)`);return!!(this._checkValid(e,W)&&this._checkOwns(e))}_checkStencilState(){return this._checkStencil?(this._checkStencil=!1,this._stencilState=!0,(this.getParameter(this.STENCIL_WRITEMASK)!==this.getParameter(this.STENCIL_BACK_WRITEMASK)||this.getParameter(this.STENCIL_VALUE_MASK)!==this.getParameter(this.STENCIL_BACK_VALUE_MASK)||this.getParameter(this.STENCIL_REF)!==this.getParameter(this.STENCIL_BACK_REF))&&(this.setError(this.INVALID_OPERATION),this._stencilState=!1),this._stencilState):this._stencilState}_validGLSLIdentifier(e){return!(e.indexOf(`webgl_`)===0||e.indexOf(`_webgl_`)===0||e.length>256)}_getParameterDirect(e){return this._gl.getParameterx(e)?.deepUnpack()}getContextAttributes(){return this._contextAttributes}getExtension(e){let R=e.toLowerCase();if(R in this._extensions)return this._extensions[R];let W=Wd[R]?Wd[R](this):null;return W&&(this._extensions[R]=W),W}getSupportedExtensions(){let e=[`ANGLE_instanced_arrays`,`STACKGL_resize_drawingbuffer`,`STACKGL_destroy_context`],R=this._gl.getSupportedExtensions();return R?(R.indexOf(`GL_OES_element_index_uint`)>=0&&e.push(`OES_element_index_uint`),R.indexOf(`GL_OES_standard_derivatives`)>=0&&e.push(`OES_standard_derivatives`),R.indexOf(`GL_OES_texture_float`)>=0&&e.push(`OES_texture_float`),R.indexOf(`GL_OES_texture_float_linear`)>=0&&e.push(`OES_texture_float_linear`),(R.indexOf(`GL_OES_texture_half_float`)>=0||R.indexOf(`GL_ARB_half_float_pixel`)>=0)&&e.push(`OES_texture_half_float`),(R.indexOf(`GL_EXT_color_buffer_float`)>=0||R.indexOf(`GL_ARB_color_buffer_float`)>=0)&&e.push(`EXT_color_buffer_float`),R.indexOf(`GL_EXT_color_buffer_half_float`)>=0&&e.push(`EXT_color_buffer_half_float`),R.indexOf(`EXT_draw_buffers`)>=0&&e.push(`WEBGL_draw_buffers`),R.indexOf(`EXT_blend_minmax`)>=0&&e.push(`EXT_blend_minmax`),R.indexOf(`EXT_texture_filter_anisotropic`)>=0&&e.push(`EXT_texture_filter_anisotropic`),R.indexOf(`GL_OES_vertex_array_object`)>=0&&e.push(`OES_vertex_array_object`),e):e}getParameter(e=0){switch(e){case this.ARRAY_BUFFER_BINDING:return this._vertexGlobalState._arrayBufferBinding;case this.ELEMENT_ARRAY_BUFFER_BINDING:return this._vertexObjectState._elementArrayBufferBinding;case this.CURRENT_PROGRAM:return this._activeProgram;case this.FRAMEBUFFER_BINDING:return this._activeFramebuffer;case this.RENDERBUFFER_BINDING:return this._activeRenderbuffer;case this.TEXTURE_BINDING_2D:return this._getActiveTextureUnit()._bind2D;case this.TEXTURE_BINDING_CUBE_MAP:return this._getActiveTextureUnit()._bindCube;case this.VERSION:return`WebGL 1.0 0.0.1`;case this.VENDOR:return``;case this.RENDERER:return`ANGLE`;case this.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0 `;case this.COMPRESSED_TEXTURE_FORMATS:return new Uint32Array;case this.SCISSOR_BOX:return new Int32Array(this._scissorBox);case this.VIEWPORT:return new Int32Array(this._viewport);case this.MAX_VIEWPORT_DIMS:return new Int32Array([32767,32767]);case this.ALIASED_LINE_WIDTH_RANGE:case this.ALIASED_POINT_SIZE_RANGE:return new Float32Array([1,1]);case this.DEPTH_RANGE:return new Float32Array([0,1]);case this.BLEND_COLOR:case this.COLOR_CLEAR_VALUE:return new Float32Array(this._gl.getParameterfv(e,4));case this.COLOR_WRITEMASK:{let R=this._gl.getParameteriv(e,4);return[!!R[0],!!R[1],!!R[2],!!R[3]]}case this.DEPTH_CLEAR_VALUE:case this.LINE_WIDTH:case this.POLYGON_OFFSET_FACTOR:case this.POLYGON_OFFSET_UNITS:case this.SAMPLE_COVERAGE_VALUE:return this._gl.getParameterf(e);case this.BLEND:case this.CULL_FACE:case this.DEPTH_TEST:case this.DEPTH_WRITEMASK:case this.DITHER:case this.POLYGON_OFFSET_FILL:case this.SAMPLE_COVERAGE_INVERT:case this.SCISSOR_TEST:case this.STENCIL_TEST:case this.UNPACK_PREMULTIPLY_ALPHA_WEBGL:return!!this._gl.getParameteri(e);case this.UNPACK_FLIP_Y_WEBGL:return this._unpackFlipY;case this.ACTIVE_TEXTURE:case this.ALPHA_BITS:case this.BLEND_DST_ALPHA:case this.BLEND_DST_RGB:case this.BLEND_EQUATION_ALPHA:case this.BLEND_EQUATION_RGB:case this.BLEND_SRC_ALPHA:case this.BLEND_SRC_RGB:case this.BLUE_BITS:case this.CULL_FACE_MODE:case this.DEPTH_BITS:case this.DEPTH_FUNC:case this.FRONT_FACE:case this.GENERATE_MIPMAP_HINT:case this.GREEN_BITS:return this._gl.getParameteri(e);case this.MAX_RENDERBUFFER_SIZE:return this._maxRenderbufferSize;case this.MAX_COMBINED_TEXTURE_IMAGE_UNITS:case this.MAX_CUBE_MAP_TEXTURE_SIZE:case this.MAX_FRAGMENT_UNIFORM_VECTORS:case this.MAX_TEXTURE_IMAGE_UNITS:case this.MAX_TEXTURE_SIZE:case this.MAX_VARYING_VECTORS:case this.MAX_VERTEX_ATTRIBS:case this.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case this.MAX_VERTEX_UNIFORM_VECTORS:case this.PACK_ALIGNMENT:case this.RED_BITS:case this.SAMPLE_BUFFERS:case this.SAMPLES:case this.STENCIL_BACK_FAIL:case this.STENCIL_BACK_FUNC:case this.STENCIL_BACK_PASS_DEPTH_FAIL:case this.STENCIL_BACK_PASS_DEPTH_PASS:case this.STENCIL_BACK_REF:case this.STENCIL_BACK_VALUE_MASK:case this.STENCIL_BACK_WRITEMASK:case this.STENCIL_BITS:case this.STENCIL_CLEAR_VALUE:case this.STENCIL_FAIL:case this.STENCIL_FUNC:case this.STENCIL_PASS_DEPTH_FAIL:case this.STENCIL_PASS_DEPTH_PASS:case this.STENCIL_REF:case this.STENCIL_VALUE_MASK:case this.STENCIL_WRITEMASK:case this.SUBPIXEL_BITS:case this.UNPACK_ALIGNMENT:case this.UNPACK_COLORSPACE_CONVERSION_WEBGL:return this._gl.getParameteri(e);case this.IMPLEMENTATION_COLOR_READ_FORMAT:case this.IMPLEMENTATION_COLOR_READ_TYPE:return this._getParameterDirect(e);default:if(this._extensions.webgl_draw_buffers){let R=this._extensions.webgl_draw_buffers;switch(e){case R.DRAW_BUFFER0_WEBGL:case R.DRAW_BUFFER1_WEBGL:case R.DRAW_BUFFER2_WEBGL:case R.DRAW_BUFFER3_WEBGL:case R.DRAW_BUFFER4_WEBGL:case R.DRAW_BUFFER5_WEBGL:case R.DRAW_BUFFER6_WEBGL:case R.DRAW_BUFFER7_WEBGL:case R.DRAW_BUFFER8_WEBGL:case R.DRAW_BUFFER9_WEBGL:case R.DRAW_BUFFER10_WEBGL:case R.DRAW_BUFFER11_WEBGL:case R.DRAW_BUFFER12_WEBGL:case R.DRAW_BUFFER13_WEBGL:case R.DRAW_BUFFER14_WEBGL:case R.DRAW_BUFFER15_WEBGL:return R._buffersState.length===1&&R._buffersState[0]===this.BACK?this.BACK:this._getParameterDirect(e);case R.MAX_DRAW_BUFFERS_WEBGL:case R.MAX_COLOR_ATTACHMENTS_WEBGL:return this._getParameterDirect(e)}}let R=this._extensions.oes_standard_derivatives;if(R&&e===R.FRAGMENT_SHADER_DERIVATIVE_HINT_OES)return this._getParameterDirect(e);let W=this._extensions.ext_texture_filter_anisotropic;if(W&&e===W.MAX_TEXTURE_MAX_ANISOTROPY_EXT)return this._getParameterDirect(e);let Y=this._extensions.oes_vertex_array_object;return Y&&e===Y.VERTEX_ARRAY_BINDING_OES?Y._activeVertexArrayObject:(this.setError(this.INVALID_ENUM),null)}}destroy(){warnNotImplemented(`destroy`)}};installAllContextMethods(WebGLContextBase.prototype);var WebGLRenderingContext=class extends WebGLContextBase{get _gl(){return this._native}constructor(e,R={}){super(e,R),this._attrib0Buffer=null,this._native=new Hd.WebGLRenderingContext({}),this._init();let W=this.createBuffer();this._attrib0Buffer=W}_beginAttrib0Hack(){this._native.bindBuffer(this.ARRAY_BUFFER,this._attrib0Buffer?._||0);let e=new Uint8Array(this._vertexGlobalState._attribs[0]._data.buffer);this._native.bufferData(this.ARRAY_BUFFER,Uint8ArrayToVariant(e),this.STREAM_DRAW),this._native.enableVertexAttribArray(0),this._native.vertexAttribPointer(0,4,this.FLOAT,!1,0,0),this._native._vertexAttribDivisor(0,1)}_endAttrib0Hack(){let e=this._vertexObjectState._attribs[0];e._pointerBuffer?this._native.bindBuffer(this.ARRAY_BUFFER,e._pointerBuffer._):this._native.bindBuffer(this.ARRAY_BUFFER,0),this._native.vertexAttribPointer(0,e._inputSize,e._pointerType,e._pointerNormal,e._inputStride,e._pointerOffset),this._native._vertexAttribDivisor(0,e._divisor),this._native.disableVertexAttribArray(0),this._vertexGlobalState._arrayBufferBinding?this._native.bindBuffer(this.ARRAY_BUFFER,this._vertexGlobalState._arrayBufferBinding._):this._native.bindBuffer(this.ARRAY_BUFFER,0)}drawArrays(e=0,R=0,W=0){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||W===0)return;let X=R;if(W>0&&(X=W+R-1>>>0),this._checkVertexAttribState(X)){let W=this._extensions.webgl_draw_buffers;if(this._vertexObjectState._attribs[0]._isPointer||W&&W._buffersState&&W._buffersState.length>0)return this._native.drawArrays(e,R,Y);this._beginAttrib0Hack(),this._native._drawArraysInstanced(e,R,Y,1),this._endAttrib0Hack()}}drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(this._extensions.oes_element_index_uint&&W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(R===0){this._checkVertexAttribState(0);return}if(R+ae>>>0>ie.length){this.setError(this.INVALID_OPERATION);return}let _e=-1;for(let e=ae;e<ae+R;++e)_e=Math.max(_e,ie[e]);if(_e<0){this._checkVertexAttribState(0);return}if(this._checkVertexAttribState(_e)&&le>0){if(this._vertexObjectState._attribs[0]._isPointer)return this._native.drawElements(e,le,W,Y);this._beginAttrib0Hack(),this._native._drawElementsInstanced(e,le,W,Y,1),this._endAttrib0Hack()}}},WebGLQuery=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._queries[this._|0],e._native2.deleteQuery(this._|0)}},WebGLSampler=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._samplers[this._|0],e._native2.deleteSampler(this._|0)}},WebGLSync=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._syncs[this._|0],e._native2.deleteSync(this._|0)}},WebGLTransformFeedback=class extends Linkable{constructor(e,R){super(e),this._ctx=R}_performDelete(){let e=this._ctx;delete e._transformFeedbacks[this._|0],e._native2.deleteTransformFeedback(this._|0)}},WebGLVertexArrayObject=class extends Linkable{constructor(e,R){super(e),this._ctx=R,this._objectState=new WebGLVertexArrayObjectState(R)}_performDelete(){let e=this._ctx;e._vertexObjectState===this._objectState&&(e._vertexObjectState=e._defaultVertexObjectState),this._objectState.cleanUp(),delete e._vertexArrayObjects[this._|0],e._native2.deleteVertexArray(this._|0)}};Vt();const Gd={createVertexArray(){let e=this._native2.createVertexArray();if(!e)return null;let R=new WebGLVertexArrayObject(e,this);return this._vertexArrayObjects[e]=R,R},deleteVertexArray(e){!e||!(e instanceof WebGLVertexArrayObject)||(e._pendingDelete=!0,e._checkDelete())},isVertexArray(e){return!e||!(e instanceof WebGLVertexArrayObject)?!1:this._native2.isVertexArray(e._)},bindVertexArray(e){e===null?(this._native2.bindVertexArray(0),this._vertexObjectState=this._defaultVertexObjectState):e instanceof WebGLVertexArrayObject?(this._native2.bindVertexArray(e._),this._vertexObjectState=e._objectState):this.setError(this.INVALID_OPERATION)},createQuery(){let e=this._native2.createQuery();if(!e)return null;let R=new WebGLQuery(e,this);return this._queries[e]=R,R},deleteQuery(e){!e||!(e instanceof WebGLQuery)||(e._pendingDelete=!0,e._checkDelete())},isQuery(e){return!e||!(e instanceof WebGLQuery)?!1:this._native2.isQuery(e._)},beginQuery(e,R){R instanceof WebGLQuery&&this._native2.beginQuery(e,R._)},endQuery(e){this._native2.endQuery(e)},getQuery(e,R){return warnNotImplemented(`WebGL2RenderingContext.getQuery`),null},getQueryParameter(e,R){return e instanceof WebGLQuery?this._native2.getQueryParameter(e._,R):null},createSampler(){let e=this._native2.createSampler();if(!e)return null;let R=new WebGLSampler(e,this);return this._samplers[e]=R,R},deleteSampler(e){!e||!(e instanceof WebGLSampler)||(e._pendingDelete=!0,e._checkDelete())},isSampler(e){return!e||!(e instanceof WebGLSampler)?!1:this._native2.isSampler(e._)},bindSampler(e,R){this._native2.bindSampler(e,R?R._:0)},samplerParameteri(e,R,W){e instanceof WebGLSampler&&this._native2.samplerParameteri(e._,R,W)},samplerParameterf(e,R,W){e instanceof WebGLSampler&&this._native2.samplerParameterf(e._,R,W)},getSamplerParameter(e,R){return e instanceof WebGLSampler?R===33082||R===33083?this._native2.getSamplerParameterf(e._,R):this._native2.getSamplerParameteri(e._,R):null},fenceSync(e,R){let W=this._native2.fenceSync(e,R);if(!W)return null;let Y=new WebGLSync(W,this);return this._syncs[W]=Y,Y},isSync(e){return!e||!(e instanceof WebGLSync)?!1:this._native2.isSync(e._)},deleteSync(e){!e||!(e instanceof WebGLSync)||(e._pendingDelete=!0,e._checkDelete())},clientWaitSync(e,R,W){return e instanceof WebGLSync?this._native2.clientWaitSync(e._,R,W):37148},waitSync(e,R,W){e instanceof WebGLSync&&this._native2.waitSync(e._,R,W)},getSyncParameter(e,R){return e instanceof WebGLSync?this._native2.getSyncParameter(e._,R):null},createTransformFeedback(){let e=this._native2.createTransformFeedback();if(!e)return null;let R=new WebGLTransformFeedback(e,this);return this._transformFeedbacks[e]=R,R},deleteTransformFeedback(e){!e||!(e instanceof WebGLTransformFeedback)||(e._pendingDelete=!0,e._checkDelete())},isTransformFeedback(e){return!e||!(e instanceof WebGLTransformFeedback)?!1:this._native2.isTransformFeedback(e._)},bindTransformFeedback(e,R){this._native2.bindTransformFeedback(e,R?R._:0)},beginTransformFeedback(e){this._native2.beginTransformFeedback(e)},endTransformFeedback(){this._native2.endTransformFeedback()},pauseTransformFeedback(){this._native2.pauseTransformFeedback()},resumeTransformFeedback(){this._native2.resumeTransformFeedback()},transformFeedbackVaryings(e,R,W){this._native2.transformFeedbackVaryings(e._,R,W)},getTransformFeedbackVarying(e,R){let W=this._native2.getTransformFeedbackVarying(e._,R).deepUnpack();return new WebGLActiveInfo({size:W.size,type:W.type,name:W.name})}};function installObjectLifecycleMethods(e){Object.assign(e,Gd)}const Kd={texImage3D(e,R,W,Y,X,ie,ae,le,_e,ye){ye===null?this._native2.texImage3DNull(e,R,W,Y,X,ie,ae,le,_e):this._native2.texImage3D(e,R,W,Y,X,ie,ae,le,_e,Uint8ArrayToVariant(new Uint8Array(ye.buffer,ye.byteOffset,ye.byteLength)))},texSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,be){be!==null&&this._native2.texSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,Uint8ArrayToVariant(new Uint8Array(be.buffer,be.byteOffset,be.byteLength)))},compressedTexImage3D(e,R,W,Y,X,ie,ae,le,_e){this._native2.compressedTexImage3D(e,R,W,Y,X,ie,ae,Uint8ArrayToVariant(new Uint8Array(_e.buffer,_e.byteOffset,_e.byteLength)))},compressedTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e,ye,be){this._native2.compressedTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e,Uint8ArrayToVariant(new Uint8Array(be.buffer,be.byteOffset,be.byteLength)))},copyTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e){this._native2.copyTexSubImage3D(e,R,W,Y,X,ie,ae,le,_e)},texStorage2D(e,R,W,Y,X){this._native2.texStorage2D(e,R,W,Y,X);let ie=this._getTexImage(e);if(ie){for(let e=0;e<R;e++)ie._levelWidth[e]=Math.max(1,Y>>e),ie._levelHeight[e]=Math.max(1,X>>e);ie._format=this.RGBA,ie._type=this.UNSIGNED_BYTE}},texStorage3D(e,R,W,Y,X,ie){this._native2.texStorage3D(e,R,W,Y,X,ie)}};function installTexImage3DMethods(e){Object.assign(e,Kd)}const qd={uniform1ui(e,R){e&&this._native2.uniform1ui(e._,R)},uniform2ui(e,R,W){e&&this._native2.uniform2ui(e._,R,W)},uniform3ui(e,R,W,Y){e&&this._native2.uniform3ui(e._,R,W,Y)},uniform4ui(e,R,W,Y,X){e&&this._native2.uniform4ui(e._,R,W,Y,X)},uniform1uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform1uiv(e._,X.length,X)},uniform2uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform2uiv(e._,X.length/2,X)},uniform3uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform3uiv(e._,X.length/3,X)},uniform4uiv(e,R,W,Y){if(!e)return;let X=R instanceof Uint32Array?R:new Uint32Array(R);this._native2.uniform4uiv(e._,X.length/4,X)},uniformMatrix2x3fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix2x3fv(e._,R,ie)},uniformMatrix3x2fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix3x2fv(e._,R,ie)},uniformMatrix2x4fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix2x4fv(e._,R,ie)},uniformMatrix4x2fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix4x2fv(e._,R,ie)},uniformMatrix3x4fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix3x4fv(e._,R,ie)},uniformMatrix4x3fv(e,R,W,Y,X){if(!e)return;let ie=W instanceof Float32Array?W:new Float32Array(W);this._native2.uniformMatrix4x3fv(e._,R,ie)}};function installUniformMethods(e){Object.assign(e,qd)}const Jd={clearBufferfv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferfv==`function`){X.clearBufferfv(e,R,Array.from(W));return}let ie=W;if(e===6144){let e=this.getParameter(this.COLOR_CLEAR_VALUE);this.clearColor(ie[0]??0,ie[1]??0,ie[2]??0,ie[3]??0),this.clear(this.COLOR_BUFFER_BIT),e&&this.clearColor(e[0],e[1],e[2],e[3])}else if(e===6145){let e=this.getParameter(this.DEPTH_CLEAR_VALUE);this.clearDepth(ie[0]??1),this.clear(this.DEPTH_BUFFER_BIT),e!==null&&this.clearDepth(e)}},clearBufferiv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferiv==`function`){X.clearBufferiv(e,R,Array.from(W));return}if(e===6146){let e=W,R=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearStencil(e[0]??0),this.clear(this.STENCIL_BUFFER_BIT),R!==null&&this.clearStencil(R)}},clearBufferuiv(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferuiv==`function`){X.clearBufferuiv(e,R,Array.from(W));return}},clearBufferfi(e,R,W,Y){let X=this._native2;if(typeof X.clearBufferfi==`function`){X.clearBufferfi(e,R,W,Y);return}if(e===34041){let e=this.getParameter(this.DEPTH_CLEAR_VALUE),R=this.getParameter(this.STENCIL_CLEAR_VALUE);this.clearDepth(W),this.clearStencil(Y),this.clear(this.DEPTH_BUFFER_BIT|this.STENCIL_BUFFER_BIT),e!==null&&this.clearDepth(e),R!==null&&this.clearStencil(R)}}};function installClearBufferMethods(e){Object.assign(e,Jd)}bt();function debugGlEnabled(){return globalThis.__GJSIFY_DEBUG_GL===!0}const Yd={drawArraysInstanced(e,R,W,Y){if(R<0||W<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=vertexCount(this,e,W);if(X<0){this.setError(this.INVALID_ENUM);return}if(this._framebufferOk()&&!(W===0||Y===0)&&this._checkVertexAttribState(W+R-1>>>0)){if(debugGlEnabled()){let e=this,R=e.__drawInstCount=(e.__drawInstCount|0)+1;(R<=5||R%100==0)&&yt.log(`[WebGL] drawArraysInstanced #${R} count=${X} instances=${Y} fbo=${this._activeFramebuffer?._??`_gtkFbo`}`)}this._native2.drawArraysInstanced(e,R,X,Y)}},drawElementsInstanced(e,R,W,Y,X){if(R<0||Y<0||X<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let ie=this._vertexObjectState._elementArrayBufferBinding;if(!ie){this.setError(this.INVALID_OPERATION);return}let ae=null,le=Y;if(W===this.UNSIGNED_SHORT){if(le%2){this.setError(this.INVALID_OPERATION);return}le>>=1,ae=new Uint16Array(ie._elements.buffer)}else if(W===this.UNSIGNED_INT){if(le%4){this.setError(this.INVALID_OPERATION);return}le>>=2,ae=new Uint32Array(ie._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ae=ie._elements;else{this.setError(this.INVALID_ENUM);return}let _e=R;switch(e){case this.TRIANGLES:R%3&&(_e-=R%3);break;case this.LINES:R%2&&(_e-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk())return;if(_e===0||X===0){this._checkVertexAttribState(0);return}if(_e+le>>>0>ae.length){this.setError(this.INVALID_OPERATION);return}let ye=0;for(let e=le;e<le+_e;++e)ae[e]>ye&&(ye=ae[e]);this._checkVertexAttribState(ye)&&this._native2.drawElementsInstanced(e,_e,W,Y,X)},vertexAttribDivisor(e,R){this._native2.vertexAttribDivisor(e,R)},vertexAttribIPointer(e,R,W,Y,X){this._native2.vertexAttribIPointer(e,R,W,Y,X)},drawBuffers(e){let R=!1;for(let W=0;W<e.length;W++)if(e[W]===1029){R=!0;break}if(!R){this._native2.drawBuffers(e);return}this._native2.drawBuffers(e.map(e=>e===1029?this.COLOR_ATTACHMENT0:e))},drawRangeElements(e,R,W,Y,X,ie){if(Y<0||ie<0){this.setError(this.INVALID_VALUE);return}if(W<R){this.setError(this.INVALID_VALUE);return}this.drawElements(e,Y,X,ie)},blitFramebuffer(e,R,W,Y,X,ie,ae,le,_e,ye){if(debugGlEnabled()){let e=this._gl.getError();e!==0&&yt.log(`[WebGL] blitFramebuffer PRE-ERROR 0x${e.toString(16)}`)}if(this._native2.blitFramebuffer(e,R,W,Y,X,ie,ae,le,_e,ye),debugGlEnabled()){let X=this._gl.getError(),ie=this,ae=ie.__blitCount=(ie.__blitCount|0)+1;ae<=5&&yt.log(`[WebGL] blitFramebuffer #${ae} src=(${e},${R},${W},${Y}) readFbo=${this._activeReadFramebuffer?._??`_gtkFbo`} err=${X===0?`OK`:`0x`+X.toString(16)}`)}},framebufferTextureLayer(e,R,W,Y,X){this._native2.framebufferTextureLayer(e,R,W?W._:0,Y,X)},invalidateFramebuffer(e,R){this._native2.invalidateFramebuffer(e,R)},invalidateSubFramebuffer(e,R,W,Y,X,ie){this._native2.invalidateSubFramebuffer(e,R,W,Y,X,ie)},readBuffer(e){this._native2.readBuffer(e)},renderbufferStorageMultisample(e,R,W,Y,X){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let ie=this._activeRenderbuffer;if(!ie){this.setError(this.INVALID_OPERATION);return}this._saveError(),this._native2.renderbufferStorageMultisample(e,R,W,Y,X);let ae=this.getError();this._restoreError(ae),ae===this.NO_ERROR&&(ie._width=Y,ie._height=X,ie._format=W)}};function installInstancedAndFramebufferOpsMethods(e){Object.assign(e,Yd)}Vt();var Xd=class WebGL2RenderingContext extends WebGLContextBase{get _gl(){return this._native2}constructor(e,R={}){super(e,R),this._queries={},this._samplers={},this._transformFeedbacks={},this._vertexArrayObjects={},this._syncs={},this._activeReadFramebuffer=null,this._activeDrawFramebuffer=null,this._native2=new Hd.WebGL2RenderingContext({}),this._init()}_getGlslVersion(e){return e?`300 es`:`130`}_validFramebufferAttachment(e){return super._validFramebufferAttachment(e)?!0:e>=36065&&e<=36079}static{this._WGL2_ALL_COLOR_ATTACHMENTS=[36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079]}_getColorAttachments(){return WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS}_preCheckFramebufferStatus(e){let R=e._attachments,W=0,Y=0,X=[this.COLOR_ATTACHMENT0,this.DEPTH_ATTACHMENT,this.STENCIL_ATTACHMENT,this.DEPTH_STENCIL_ATTACHMENT,...WebGL2RenderingContext._WGL2_ALL_COLOR_ATTACHMENTS];for(let ie of X){let X=R[ie];if(X){if(X instanceof WebGLTexture){let R=e._attachmentLevel[ie]??0,ae=X._levelWidth[R]??0,le=X._levelHeight[R]??0;if(ae>0&&le>0){W=ae,Y=le;break}}else if(X instanceof WebGLRenderbuffer&&X._width>0&&X._height>0){W=X._width,Y=X._height;break}}}return W>0&&Y>0?(e._width=W,e._height=Y,this.FRAMEBUFFER_COMPLETE):this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT}_updateFramebufferAttachments(e){if(super._updateFramebufferAttachments(e),e)for(let R=1;R<=15;R++){let W=36064+R;if(!(W in e._attachments))continue;let Y=e._attachments[W];if(Y instanceof WebGLTexture){let R=e._attachmentFace[W]||this.TEXTURE_2D,X=e._attachmentLevel[W]??0;this._gl.framebufferTexture2D(this.FRAMEBUFFER,W,R,Y._|0,X|0)}else Y instanceof WebGLRenderbuffer?this._gl.framebufferRenderbuffer(this.FRAMEBUFFER,W,this.RENDERBUFFER,Y._|0):this._gl.framebufferTexture2D(this.FRAMEBUFFER,W,this.TEXTURE_2D,0,0)}}bindBuffer(e,R){if(e===35345||e===35982||e===36662||e===36663){let W=R?R._|0:0;this._gl.bindBuffer(e,W);return}super.bindBuffer(e,R)}bindFramebuffer(e,R){if(e===36008||e===36009){if(!checkObject(R))throw TypeError(`bindFramebuffer(GLenum, WebGLFramebuffer)`);if(R&&R._pendingDelete||R&&!this._checkWrapper(R,WebGLFramebuffer))return;let W=R?R._|0:this._gtkFboId;if(this._gl.bindFramebuffer(e,W),e===36008){let e=this._activeReadFramebuffer;e!==R&&(e&&(--e._refCount,e._checkDelete()),R&&(R._refCount+=1)),this._activeReadFramebuffer=R}else{let e=this._activeDrawFramebuffer;e!==R&&(e&&(--e._refCount,e._checkDelete()),R&&(R._refCount+=1)),this._activeDrawFramebuffer=R,this._activeFramebuffer=R}return}super.bindFramebuffer(this.FRAMEBUFFER,R),this._activeReadFramebuffer=R,this._activeDrawFramebuffer=R}deleteFramebuffer(e){this._activeReadFramebuffer===e&&this.bindFramebuffer(36008,null),this._activeDrawFramebuffer===e&&this.bindFramebuffer(36009,null),super.deleteFramebuffer(e)}bufferData(e,R,W){let Y=e===35345||e===35982||e===36662||e===36663,X=W===35041||W===35043||W===35045||W===35042||W===35044||W===35046?this.STATIC_DRAW:W;if(Y){if(typeof R==`number`)R>=0&&this._gl.bufferDataSizeOnly(e,R,X);else if(typeof R==`object`&&R){let W=arrayToUint8Array(R);this._gl.bufferData(e,Uint8ArrayToVariant(W),X)}return}super.bufferData(e,R,X)}bufferSubData(e,R,W){if(e===35345||e===35982||e===36662||e===36663){if(R<0){this.setError(this.INVALID_VALUE);return}if(!W){this.setError(this.INVALID_VALUE);return}let Y=arrayToUint8Array(W);this._gl.bufferSubData(e,R,Uint8ArrayToVariant(Y));return}super.bufferSubData(e,R,W)}bindTexture(e,R){if(e===32879||e===35866){let W=R,Y=W?W._|0:0;this._gl.bindTexture(e,Y),W&&(W._binding=e);return}super.bindTexture(e,R)}texParameteri(e,R,W){if(e===32879||e===35866){this._gl.texParameteri(e,R,W);return}if(R===32882||R===34892||R===34893||R===33084||R===33085||R===33083||R===33082){this._gl.texParameteri(e,R,W);return}super.texParameteri(e,R,W)}drawArrays(e,R,W){if(R<0||W<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let Y=vertexCount(this,e,W);if(Y<0){this.setError(this.INVALID_ENUM);return}this._framebufferOk()&&W!==0&&this._checkVertexAttribState(W+R-1>>>0)&&this._native2.drawArrays(e,R,Y)}drawElements(e=0,R=0,W=0,Y=0){if(R<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._checkStencilState())return;let X=this._vertexObjectState._elementArrayBufferBinding;if(!X){this.setError(this.INVALID_OPERATION);return}let ie=null,ae=Y;if(W===this.UNSIGNED_SHORT){if(ae%2){this.setError(this.INVALID_OPERATION);return}ae>>=1,ie=new Uint16Array(X._elements.buffer)}else if(W===this.UNSIGNED_INT){if(ae%4){this.setError(this.INVALID_OPERATION);return}ae>>=2,ie=new Uint32Array(X._elements.buffer)}else if(W===this.UNSIGNED_BYTE)ie=X._elements;else{this.setError(this.INVALID_ENUM);return}let le=R;switch(e){case this.TRIANGLES:R%3&&(le-=R%3);break;case this.LINES:R%2&&(le-=R%2);break;case this.POINTS:break;case this.LINE_LOOP:case this.LINE_STRIP:if(R<2){this.setError(this.INVALID_OPERATION);return}break;case this.TRIANGLE_FAN:case this.TRIANGLE_STRIP:if(R<3){this.setError(this.INVALID_OPERATION);return}break;default:this.setError(this.INVALID_ENUM);return}if(!this._framebufferOk()||R===0)return;let _e=0;for(let e=ae;e<ae+le;++e)e<ie.length&&ie[e]>_e&&(_e=ie[e]);this._checkVertexAttribState(_e)&&this._native2.drawElements(e,le,W,Y)}bindBufferBase(e,R,W){this._native2.bindBufferBase(e,R,W?W._:0)}bindBufferRange(e,R,W,Y,X){this._native2.bindBufferRange(e,R,W?W._:0,Y,X)}copyBufferSubData(e,R,W,Y,X){this._native2.copyBufferSubData(e,R,W,Y,X)}getBufferSubData(e,R,W,Y,X){let ie=X===void 0?W.byteLength-(Y??0):X,ae=this._native2.getBufferSubData(e,R,ie),le=new Uint8Array(W.buffer,W.byteOffset+(Y??0)*(W instanceof Uint8Array?1:W.BYTES_PER_ELEMENT??1));le.set(ae.subarray(0,le.byteLength))}texImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0,Oe=0;if(arguments.length===6)if(_e=X,Te=Y,ie instanceof le.Pixbuf){let e=ie;be=e.get_width(),Ce=e.get_height(),ye=e.get_pixels()}else{let e=extractImageData(ie);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else arguments.length>=9&&(be=Y,Ce=X,Oe=ie,Te=ae);let Ae=this._getTexImage(e);if(!Ae){this.setError(this.INVALID_OPERATION);return}let Me=convertPixels(ye);if(this._unpackPremultAlpha&&Me&&Te===this.RGBA&&(Me=premultiplyAlpha(Me)),this._unpackFlipY&&Me&&be>0&&Ce>0){let e=this._computePixelSize(_e,Te);if(e>0){let R=this._computeRowStride(be,e),W=new Uint8Array(Me.length);for(let e=0;e<Ce;e++){let Y=e*R,X=(Ce-1-e)*R;W.set(Me.subarray(Y,Y+R),X)}Me=W}}this._saveError(),this._gl.texImage2D(e,R,W,be,Ce,Oe,Te,_e,Uint8ArrayToVariant(Me));let Pe=this.getError();if(this._restoreError(Pe),Pe!==this.NO_ERROR)return;Ae._levelWidth[R]=be,Ae._levelHeight[R]=Ce,Ae._format=Te,Ae._type=_e;let Re=this._activeFramebuffer;if(Re){let e=!1,R=this._getAttachments();for(let W=0;W<R.length;++W)if(Re._attachments[R[W]]===Ae){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}}texSubImage2D(e=0,R=0,W=0,Y=0,X=0,ie=0,ae=0,_e=0,ye){let be=0,Ce=0,Te=0;if(arguments.length===7)if(_e=ie,Te=X,ae instanceof le.Pixbuf){let e=ae;be=e.get_width(),Ce=e.get_height(),ye=e.get_pixels()}else{let e=extractImageData(ae);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);be=e.width,Ce=e.height,ye=e.data}else be=X,Ce=ie,Te=ae;if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}let Oe=convertPixels(ye);if(!Oe){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&Oe&&Te===this.RGBA&&(Oe=premultiplyAlpha(Oe)),this._unpackFlipY&&Oe&&be>0&&Ce>0){let e=this._computePixelSize(_e,Te);if(e>0){let R=this._computeRowStride(be,e),W=new Uint8Array(Oe.length);for(let e=0;e<Ce;e++){let Y=e*R,X=(Ce-1-e)*R;W.set(Oe.subarray(Y,Y+R),X)}Oe=W}}this._gl.texSubImage2D(e,R,W,Y,be,Ce,Te,_e,Uint8ArrayToVariant(Oe))}getUniform(e,R){let W=R?._activeInfo?.type,Y=5125,X=36294,ie=36295,ae=W===Y||W===X||W===ie||W===36296,le=e;if(!ae)return super.getUniform(le,R);if(!e||!R)return null;let _e=this._native2.getUniformi(le._|0,R._|0);return _e?W===Y?_e[0]>>>0:W===X?new Uint32Array([_e[0]>>>0,_e[1]>>>0]):W===ie?new Uint32Array([_e[0]>>>0,_e[1]>>>0,_e[2]>>>0]):new Uint32Array([_e[0]>>>0,_e[1]>>>0,_e[2]>>>0,_e[3]>>>0]):null}getUniformBlockIndex(e,R){return this._native2.getUniformBlockIndex(e._,R)}uniformBlockBinding(e,R,W){this._native2.uniformBlockBinding(e._,R,W)}getActiveUniformBlockName(e,R){let W=this._native2.getActiveUniformBlockName(e._,R);return W.length>0?W:null}getActiveUniformBlockParameter(e,R,W){return this._native2.getActiveUniformBlockParameter(e._,R,W)}getActiveUniforms(e,R,W){return this._native2.getActiveUniforms(e._,R,W)}getFragDataLocation(e,R){return this._native2.getFragDataLocation(e._,R)}getIndexedParameter(e,R){return this._native2.getIndexedParameteri(e,R)}getInternalformatParameter(e,R,W){return this._native2.getInternalformatParameter(e,R,W)}getParameter(e){if(e===7938)return`WebGL 2.0`;if(e===35724)return`WebGL GLSL ES 3.00`;if(e===7939)return warnNotImplemented(`WebGL2RenderingContext.getParameter(GL_EXTENSIONS)`),``;if(e===36006)return this._activeDrawFramebuffer;if(e===36010)return this._activeReadFramebuffer;switch(e){case 36183:case 35071:case 32883:case 36063:case 34852:case 36203:case 33001:case 33e3:case 37157:case 35373:case 35657:case 35077:case 35978:case 35979:case 35968:case 35376:case 35375:case 35659:case 37154:case 35371:case 35658:case 35379:case 35374:case 35377:case 35076:case 3330:case 3332:case 3331:case 35053:case 35055:case 3074:case 32874:case 35869:case 36389:case 35983:case 35368:case 35380:case 32878:case 3314:case 32877:case 3316:case 3315:case 34045:return this._native2.getParameterx(e)?.deepUnpack()|0;case 35977:case 36388:case 36387:return!!this._native2.getParameterx(e)?.deepUnpack()}return super.getParameter(e)}getStringi(e,R){let W=this._native2.getStringi(e,R);return W.length>0?W:null}renderbufferStorage(e,R,W,Y){if(e!==this.RENDERBUFFER){this.setError(this.INVALID_ENUM);return}let X=this._activeRenderbuffer;if(!X){this.setError(this.INVALID_OPERATION);return}if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}for(;this._gl.getError()!==this.NO_ERROR;);if(this._gl.renderbufferStorage(e,R,W,Y),this._gl.getError()!==this.NO_ERROR)return;X._width=W,X._height=Y,X._format=R;let ie=this._activeFramebuffer;if(ie){let e=this._getAttachments(),R=!1;for(let W=0;W<e.length;++W)if(ie._attachments[e[W]]===X){R=!0;break}R&&this._updateFramebufferAttachments(ie)}}getSupportedExtensions(){let e=super.getSupportedExtensions();for(let R of[`EXT_color_buffer_float`,`EXT_color_buffer_half_float`,`OES_texture_half_float`])e.indexOf(R)===-1&&e.push(R);return e}readPixels(e,R,W,Y,X,ie,ae){if(!ae)return;if(W<0||Y<0){this.setError(this.INVALID_VALUE);return}if(!this._framebufferOk())return;let le=X===6408||X===32856?4:X===6407?3:X===33319?2:1,_e=ie===5126?4:ie===5131||ie===36193?2:ie===5125||ie===5124?4:ie===5123||ie===5122?2:1,ye=W*Y*le*_e,be=new Uint8Array(ye);this._saveError();let Ce=this._gl.readPixels(e,R,W,Y,X,ie,Uint8ArrayToVariant(be)),Te=this.getError();if(this._restoreError(Te),Te!==this.NO_ERROR)return;let Oe=Ce&&Ce.length>0?Ce:be;if(ae instanceof Uint8Array)ae.set(Oe);else if(ae instanceof Float32Array){let e=new Float32Array(Oe.buffer,0,ae.length);ae.set(e)}}_framebufferOk(){return!0}};installObjectLifecycleMethods(Xd.prototype),installTexImage3DMethods(Xd.prototype),installUniformMethods(Xd.prototype),installClearBufferMethods(Xd.prototype),installInstancedAndFramebufferOpsMethods(Xd.prototype);function notifyElementResize(e,R,W){e._allocatedClientWidth=R,e._allocatedClientHeight=W,e._fireResizeSubscribers(R,W);let Y=e.parentNode;for(;Y;)Y instanceof Element&&(Y._allocatedClientWidth=R,Y._allocatedClientHeight=W,Y._fireResizeSubscribers(R,W)),Y=Y.parentNode}var HTMLCanvasElement=class extends hi{constructor(e){super(),this.gtkGlArea=e}get width(){return this.gtkGlArea.get_allocated_width()}set width(e){}get height(){return this.gtkGlArea.get_allocated_height()}set height(e){}get clientWidth(){return this.width}get clientHeight(){return this.height}get offsetWidth(){return this.width}get offsetHeight(){return this.height}getGlArea(){return this.gtkGlArea}getContext(e,R){return e===`webgl`||e===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new WebGLRenderingContext(this,R)),this._webgl):e===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new Xd(this,R)),this._webgl2):super.getContext(e,R)}};const Zd={Return:`Enter`,KP_Enter:`Enter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`Delete`,Insert:`Insert`,KP_Insert:`Insert`,Home:`Home`,KP_Home:`Home`,End:`End`,KP_End:`End`,Page_Up:`PageUp`,KP_Page_Up:`PageUp`,Page_Down:`PageDown`,KP_Page_Down:`PageDown`,Left:`ArrowLeft`,KP_Left:`ArrowLeft`,Up:`ArrowUp`,KP_Up:`ArrowUp`,Right:`ArrowRight`,KP_Right:`ArrowRight`,Down:`ArrowDown`,KP_Down:`ArrowDown`,Shift_L:`Shift`,Shift_R:`Shift`,Control_L:`Control`,Control_R:`Control`,Alt_L:`Alt`,Alt_R:`Alt`,Super_L:`Meta`,Super_R:`Meta`,Meta_L:`Meta`,Meta_R:`Meta`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:` `,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`+`,KP_Subtract:`-`,KP_Multiply:`*`,KP_Divide:`/`,KP_Decimal:`.`,KP_Separator:`,`,KP_0:`0`,KP_1:`1`,KP_2:`2`,KP_3:`3`,KP_4:`4`,KP_5:`5`,KP_6:`6`,KP_7:`7`,KP_8:`8`,KP_9:`9`},Qd={Return:`Enter`,KP_Enter:`NumpadEnter`,Tab:`Tab`,ISO_Left_Tab:`Tab`,BackSpace:`Backspace`,Escape:`Escape`,Delete:`Delete`,KP_Delete:`NumpadDecimal`,Insert:`Insert`,KP_Insert:`Numpad0`,Home:`Home`,KP_Home:`Numpad7`,End:`End`,KP_End:`Numpad1`,Page_Up:`PageUp`,KP_Page_Up:`Numpad9`,Page_Down:`PageDown`,KP_Page_Down:`Numpad3`,Left:`ArrowLeft`,KP_Left:`Numpad4`,Up:`ArrowUp`,KP_Up:`Numpad8`,Right:`ArrowRight`,KP_Right:`Numpad6`,Down:`ArrowDown`,KP_Down:`Numpad2`,Shift_L:`ShiftLeft`,Shift_R:`ShiftRight`,Control_L:`ControlLeft`,Control_R:`ControlRight`,Alt_L:`AltLeft`,Alt_R:`AltRight`,Super_L:`MetaLeft`,Super_R:`MetaRight`,Meta_L:`MetaLeft`,Meta_R:`MetaRight`,Caps_Lock:`CapsLock`,Num_Lock:`NumLock`,Scroll_Lock:`ScrollLock`,Print:`PrintScreen`,Pause:`Pause`,Menu:`ContextMenu`,space:`Space`,F1:`F1`,F2:`F2`,F3:`F3`,F4:`F4`,F5:`F5`,F6:`F6`,F7:`F7`,F8:`F8`,F9:`F9`,F10:`F10`,F11:`F11`,F12:`F12`,KP_Add:`NumpadAdd`,KP_Subtract:`NumpadSubtract`,KP_Multiply:`NumpadMultiply`,KP_Divide:`NumpadDivide`,KP_Decimal:`NumpadDecimal`,KP_Separator:`NumpadComma`,KP_0:`Numpad0`,KP_1:`Numpad1`,KP_2:`Numpad2`,KP_3:`Numpad3`,KP_4:`Numpad4`,KP_5:`Numpad5`,KP_6:`Numpad6`,KP_7:`Numpad7`,KP_8:`Numpad8`,KP_9:`Numpad9`};function gdkKeyvalToKey(e){let R=Y.keyval_name(e);if(R&&Zd[R])return Zd[R];let W=Y.keyval_to_unicode(e);return W>0?String.fromCodePoint(W):R??`Unidentified`}function gdkKeyvalToCode(e){let R=Y.keyval_name(e);if(R&&Qd[R])return Qd[R];let W=Y.keyval_to_unicode(e);if(W>=97&&W<=122)return`Key`+String.fromCodePoint(W-32);if(W>=65&&W<=90)return`Key`+String.fromCodePoint(W);if(W>=48&&W<=57)return`Digit`+String.fromCodePoint(W);if(R){let e={minus:`Minus`,equal:`Equal`,bracketleft:`BracketLeft`,bracketright:`BracketRight`,backslash:`Backslash`,semicolon:`Semicolon`,apostrophe:`Quote`,grave:`Backquote`,comma:`Comma`,period:`Period`,slash:`Slash`};if(e[R])return e[R]}return R??`Unidentified`}function gdkKeyvalToLocation(e){let R=Y.keyval_name(e);return R?R.startsWith(`KP_`)?3:R.endsWith(`_L`)?1:R.endsWith(`_R`)?2:0:0}function getGlobalEventTarget(){return globalThis.__gjsify_globalEventTarget}function extractModifiers(e){let R=e.get_current_event_state();return{shiftKey:!!(R&Y.ModifierType.SHIFT_MASK),ctrlKey:!!(R&Y.ModifierType.CONTROL_MASK),altKey:!!(R&Y.ModifierType.ALT_MASK),metaKey:!!(R&Y.ModifierType.SUPER_MASK)}}function gtkButtonToDom(e){return e===1?0:e===2?1:e===3?2:e-1}function buttonsFromModifiers(e){let R=e.get_current_event_state(),W=0;return R&Y.ModifierType.BUTTON1_MASK&&(W|=1),R&Y.ModifierType.BUTTON3_MASK&&(W|=2),R&Y.ModifierType.BUTTON2_MASK&&(W|=4),W}function attachEventControllers(e,R,W){e.set_focusable(!0),e.set_can_focus(!0);let X={lastX:0,lastY:0,buttonsPressed:0,pressedKeys:new Set},ie=new Ce.EventControllerMotion;ie.connect(`motion`,(W,Y,ae)=>{let le=R();if(!le)return;let _e=e.get_allocated_width(),ye=e.get_allocated_height(),be=Math.max(0,Math.min(Y,_e)),Ce=Math.max(0,Math.min(ae,ye)),Te=be-X.lastX,Oe=Ce-X.lastY,Ae=extractModifiers(ie),Me=buttonsFromModifiers(ie),Pe={...Ae,clientX:be,clientY:Ce,offsetX:be,offsetY:Ce,screenX:be,screenY:Ce,movementX:Te,movementY:Oe,buttons:Me,button:0,bubbles:!0,cancelable:!0};le.dispatchEvent(new PointerEvent$1(`pointermove`,{...Pe,pointerId:1,pointerType:`mouse`,isPrimary:!0})),le.dispatchEvent(new MouseEvent(`mousemove`,Pe)),X.lastX=be,X.lastY=Ce}),ie.connect(`enter`,(e,W,Y)=>{let ae=R();if(!ae)return;X.lastX=W,X.lastY=Y;let le={...extractModifiers(ie),clientX:W,clientY:Y,offsetX:W,offsetY:Y,screenX:W,screenY:Y,bubbles:!1,cancelable:!1};ae.dispatchEvent(new PointerEvent$1(`pointerenter`,{...le,pointerId:1,pointerType:`mouse`,isPrimary:!0})),ae.dispatchEvent(new MouseEvent(`mouseenter`,le)),ae.dispatchEvent(new MouseEvent(`mouseover`,{...le,bubbles:!0}))}),ie.connect(`leave`,()=>{let e=R();if(!e)return;let W={...extractModifiers(ie),clientX:X.lastX,clientY:X.lastY,bubbles:!1,cancelable:!1};e.dispatchEvent(new PointerEvent$1(`pointerleave`,{...W,pointerId:1,pointerType:`mouse`,isPrimary:!0})),e.dispatchEvent(new MouseEvent(`mouseleave`,W)),e.dispatchEvent(new MouseEvent(`mouseout`,{...W,bubbles:!0}))}),e.add_controller(ie);let ae=new Ce.GestureClick;ae.set_button(0),ae.connect(`pressed`,(W,Y,ie,le)=>{let _e=R();if(!_e)return;let ye=gtkButtonToDom(ae.get_current_button()),be=extractModifiers(ae);X.buttonsPressed|=1<<ye;let Ce={...be,clientX:ie,clientY:le,offsetX:ie,offsetY:le,screenX:ie,screenY:le,button:ye,buttons:X.buttonsPressed,detail:Y,bubbles:!0,cancelable:!0};_e.dispatchEvent(new PointerEvent$1(`pointerdown`,{...Ce,pointerId:1,pointerType:`mouse`,isPrimary:!0})),_e.dispatchEvent(new MouseEvent(`mousedown`,Ce)),e.grab_focus()}),ae.connect(`released`,(e,W,Y,ie)=>{let le=R();if(!le)return;let _e=gtkButtonToDom(ae.get_current_button()),ye=extractModifiers(ae);X.buttonsPressed&=~(1<<_e);let be={...ye,clientX:Y,clientY:ie,offsetX:Y,offsetY:ie,screenX:Y,screenY:ie,button:_e,buttons:X.buttonsPressed,detail:W,bubbles:!0,cancelable:!0};le.dispatchEvent(new PointerEvent$1(`pointerup`,{...be,pointerId:1,pointerType:`mouse`,isPrimary:!0})),le.dispatchEvent(new MouseEvent(`mouseup`,be)),_e===0&&(le.dispatchEvent(new MouseEvent(`click`,be)),W===2&&le.dispatchEvent(new MouseEvent(`dblclick`,be))),_e===2&&le.dispatchEvent(new MouseEvent(`contextmenu`,{...be,cancelable:!0}))}),e.add_controller(ae);let le=new Ce.EventControllerScroll({flags:Ce.EventControllerScrollFlags.BOTH_AXES});le.connect(`scroll`,(e,W,Y)=>{let ie=R();if(!ie)return;let ae={...extractModifiers(le),clientX:X.lastX,clientY:X.lastY,offsetX:X.lastX,offsetY:X.lastY,screenX:X.lastX,screenY:X.lastY,deltaX:W*100,deltaY:Y*100,deltaZ:0,deltaMode:0,bubbles:!0,cancelable:!0};return ie.dispatchEvent(new WheelEvent$1(`wheel`,ae)),!1}),e.add_controller(le);let _e=new Ce.EventControllerKey;_e.connect(`key-pressed`,(e,ie,ae,le)=>{let _e=R();if(!_e)return!1;let ye=X.pressedKeys.has(ie);X.pressedKeys.add(ie);let be=gdkKeyvalToKey(ie),Ce={key:be,code:gdkKeyvalToCode(ie),location:gdkKeyvalToLocation(ie),repeat:ye,altKey:!!(le&Y.ModifierType.ALT_MASK),ctrlKey:!!(le&Y.ModifierType.CONTROL_MASK),metaKey:!!(le&Y.ModifierType.SUPER_MASK),shiftKey:!!(le&Y.ModifierType.SHIFT_MASK),keyCode:be.length===1?be.toUpperCase().charCodeAt(0):0,which:be.length===1?be.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0},Te=new KeyboardEvent$1(`keydown`,Ce);return _e.dispatchEvent(Te),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent$1(`keydown`,Ce)),W?.captureKeys===!0}),_e.connect(`key-released`,(e,W,ie,ae)=>{let le=R();if(!le)return;X.pressedKeys.delete(W);let _e=gdkKeyvalToKey(W),ye={key:_e,code:gdkKeyvalToCode(W),location:gdkKeyvalToLocation(W),repeat:!1,altKey:!!(ae&Y.ModifierType.ALT_MASK),ctrlKey:!!(ae&Y.ModifierType.CONTROL_MASK),metaKey:!!(ae&Y.ModifierType.SUPER_MASK),shiftKey:!!(ae&Y.ModifierType.SHIFT_MASK),keyCode:_e.length===1?_e.toUpperCase().charCodeAt(0):0,which:_e.length===1?_e.toUpperCase().charCodeAt(0):0,bubbles:!0,cancelable:!0};le.dispatchEvent(new KeyboardEvent$1(`keyup`,ye)),getGlobalEventTarget()?.dispatchEvent(new KeyboardEvent$1(`keyup`,ye))}),e.add_controller(_e);let ye=new Ce.EventControllerFocus;ye.connect(`enter`,()=>{let e=R();e&&(e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusin`,{bubbles:!0,cancelable:!1})))}),ye.connect(`leave`,()=>{let e=R();e&&(X.pressedKeys.clear(),e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})),e.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,cancelable:!1})),getGlobalEventTarget()?.dispatchEvent(new FocusEvent(`blur`,{bubbles:!1,cancelable:!1})))}),e.add_controller(ye)}bt();const $d=Me.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends Ce.GLArea{constructor(R){super(R),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=e.get_monotonic_time(),this.set_use_es(!0),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((R,W)=>(this._frameCallback!==null&&this.queue_render(),e.SOURCE_CONTINUE));let W=this.connect(`render`,()=>{this.disconnect(W),this.make_current(),this._canvas=new HTMLCanvasElement(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let R=this._canvas.getContext(`webgl`);if(R){for(let e of this._readyCallbacks)e(this._canvas,R);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,R=>{if(this._frameCallback!==null){let R=(e.get_monotonic_time()-this._timeOrigin)/1e3;globalThis.__GJSIFY_DEBUG_RAF===!0&&yt.log(`[rAF] frame callback fires t=${R.toFixed(1)}`);let W=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,W(R)}return!0}),!0});this.connect(`resize`,()=>{let e=this.get_allocated_width(),R=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new Event$1(`resize`)),notifyElementResize(this._canvas,e,R));for(let W of this._resizeCallbacks)W(e,R);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}),this.connect(`unrealize`,()=>{this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._canvas=null})}get canvas(){return this._canvas}onReady(e){if(this._canvas){let R=this._canvas.getContext(`webgl`);if(R){e(this._canvas,R);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let R=this._nextFrameId++;return this._frameCallback=e,this._frameCallbackId=R,this.queue_render(),R}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0)}installGlobals(){let R=globalThis;R.requestAnimationFrame=e=>this.requestAnimationFrame(e),R.cancelAnimationFrame=e=>this.cancelAnimationFrame(e);let W=this._timeOrigin;R.performance={now:()=>(e.get_monotonic_time()-W)/1e3,timeOrigin:Date.now()}}});st();const ef=globalThis;ef.WebGLRenderingContext=WebGLRenderingContext,ef.WebGL2RenderingContext=Xd;const tf=Me.registerClass({GTypeName:`GjsifyCanvas2DBridge`},class Canvas2DBridge extends Ce.DrawingArea{constructor(R){super(R),this._canvas=null,this._ctx=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._tickCallbackId=null,this._frameCallback=null,this._timeOrigin=e.get_monotonic_time(),this.set_draw_func(this._onDraw.bind(this)),attachEventControllers(this,()=>this._canvas,{captureKeys:!0}),this.connect(`unrealize`,()=>{this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._ctx&&this._ctx._dispose(),this._canvas=null,this._ctx=null})}_onDraw(e,R,W,Y){if(!this._canvas){if(this._canvas=new hi,this._canvas.width=W,this._canvas.height=Y,this._ctx=this._canvas.getContext(`2d`),this._ctx){for(let e of this._readyCallbacks)e(this._canvas,this._ctx);this._readyCallbacks=[]}}else if(this._canvas.width!==W||this._canvas.height!==Y){this._canvas.width=W,this._canvas.height=Y,this._canvas.dispatchEvent(new Event$1(`resize`)),notifyElementResize(this._canvas,W,Y);for(let e of this._resizeCallbacks)e(W,Y)}if(this._ctx){let e=this._ctx._getSurface();R.setSourceSurface(e,0,0),R.paint()}}get canvas(){return this._canvas}getContext(e){return this._ctx}onReady(e){if(this._canvas&&this._ctx){e(this._canvas,this._ctx);return}this._readyCallbacks.push(e)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(R){return this._frameCallback=R,this._tickCallbackId===null&&(this._tickCallbackId=this.add_tick_callback((R,W)=>{this._tickCallbackId=null;let Y=(W.get_frame_time()-this._timeOrigin)/1e3;return this._frameCallback?.(Y),this.queue_draw(),e.SOURCE_REMOVE})),this.queue_draw(),0}installGlobals(){let R=globalThis;R.requestAnimationFrame=e=>this.requestAnimationFrame(e);let W=this._timeOrigin;R.performance={now:()=>(e.get_monotonic_time()-W)/1e3,timeOrigin:Date.now()}}}),nf=Symbol.for(`gjsify_canvas2d_context`);hi.registerContextFactory(`2d`,(e,R)=>{let W=e,Y=W[nf];if(Y)return Y;let X=new CanvasRenderingContext2D(e,R);return W[nf]=X,X}),Object.defineProperty(globalThis,`CanvasRenderingContext2D`,{value:CanvasRenderingContext2D,writable:!0,configurable:!0}),Object.defineProperty(globalThis,`ImageData`,{value:OurImageData,writable:!0,configurable:!0}),Object.defineProperty(globalThis,`Path2D`,{value:Di,writable:!0,configurable:!0}),bt();
|
|
20
20
|
/*! excalibur - 0.32.0 - 2025-12-23
|
|
21
21
|
https://github.com/excaliburjs/Excalibur
|
|
22
22
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/example-dom-excalibur-jelly-jumper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "2D platformer showcase using Excalibur.js 0.32.0 with Tiled tilemaps, running natively on GJS/GTK4 and in the browser",
|
|
5
5
|
"main": "dist/gjs.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"@girs/glib-2.0": "2.88.0-4.0.4",
|
|
31
31
|
"@girs/gobject-2.0": "2.88.0-4.0.4",
|
|
32
32
|
"@girs/gtk-4.0": "4.23.0-4.0.4",
|
|
33
|
-
"@gjsify/adwaita-icons": "^0.
|
|
34
|
-
"@gjsify/adwaita-web": "^0.
|
|
35
|
-
"@gjsify/canvas2d": "^0.
|
|
36
|
-
"@gjsify/cli": "^0.
|
|
37
|
-
"@gjsify/vite-plugin-blueprint": "^0.
|
|
33
|
+
"@gjsify/adwaita-icons": "^0.6.0",
|
|
34
|
+
"@gjsify/adwaita-web": "^0.6.0",
|
|
35
|
+
"@gjsify/canvas2d": "^0.6.0",
|
|
36
|
+
"@gjsify/cli": "^0.6.0",
|
|
37
|
+
"@gjsify/vite-plugin-blueprint": "^0.6.0",
|
|
38
38
|
"@types/node": "^25.9.2",
|
|
39
39
|
"excalibur": "0.32.0",
|
|
40
40
|
"http-server": "^14.1.1",
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@gjsify/webgl": "^0.
|
|
44
|
+
"@gjsify/webgl": "^0.6.0"
|
|
45
45
|
},
|
|
46
46
|
"author": "Pascal Garber <pascal@artandcode.studio>",
|
|
47
47
|
"license": "MIT",
|